Commit 6cb49176 authored by chenchuanwen's avatar chenchuanwen

Merge branch 'lyz_goods_storage' of git.shenbd.com:qm-develop/shenbd into lyz_goods_storage

parents d828c06a aae20f62
......@@ -974,7 +974,7 @@ class OrderConfirmUtil {
$goodsDao = \DAO\GoodsModel::getInstance();
if($blGoodsList){
foreach($blGoodsList as $key=>$blGoods){
$pBundlingCacheResult = $pBundlingDao->opBlGoodsStorage($key,$blGoods['blStorage'],$op);//组合销售库存删减
$pBundlingCacheResult = $pBundlingDao->updatePBundlingStorageCacheByBlId($key,$blGoods['blStorage'],$op);//组合销售库存删减
if($pBundlingCacheResult===false){
\Error\ErrorModel::throwException(\Error\CodeConfigModel::blGoodsStorageToCacheFailedForOrder);
}
......
......@@ -319,7 +319,8 @@ class GoodsModel extends \DAO\AbstractModel {
}
}
}
\DAO\PBundlingModel::getInstance()->deletePBundlingByGoodsCommonId($goodsCommonId);
//\DAO\PBundlingModel::getInstance()->deletePBundlingByGoodsCommonId($goodsCommonId);
\DAO\PBundlingModel::getInstance()->updatePBundlingByGoodsCommonId($goodsCommonId);
\Lock\RedisLock::getInstance()->releaseLock(\Our\NameConst::goodsStorageRedisPrefix.$goodsCommonId);
}
return true;
......
......@@ -192,6 +192,7 @@ class PBundlingModel extends \DAO\AbstractModel {
return false;
}
$pBundling = $result['result'];
\Our\Log::getInstance()->write(json_encode($pBundling),'/data/log/apptest');
$key = $result['key'];
if($op == \Our\ApiConst::minus){
$pBundling['bl_storage'] = $pBundling['bl_storage']-$blStorage;
......@@ -204,8 +205,10 @@ class PBundlingModel extends \DAO\AbstractModel {
$pBundling['bl_storage'] = $pBundling['bl_storage']+$blStorage;
$pBundling['bl_origin_storage'] = $pBundling['bl_origin_storage']+$blStorage;
}
\Our\Log::getInstance()->write(json_encode($pBundling),'/data/log/apptest');
\Lock\RedisLock::getInstance()->releaseLock(\Our\NameConst::pBundlingStorageRedisPrefix.$blId);
return $pBundlingRedisDao->setNoPrefix($key,$pBundling,\Our\ApiConst::oneDaySecond);
\Our\Log::getInstance()->write($key,'/data/log/apptest');
return $pBundlingRedisDao->setNoPrefix($key,serialize($pBundling),\Our\ApiConst::oneDaySecond);
}
......@@ -256,7 +259,42 @@ class PBundlingModel extends \DAO\AbstractModel {
public function deletePBundlingByGoodsCommonId($goodsCommonId){
$pBundlingDao = \Redis\Db4\PBundlingRedisModel::getInstance();
$pBundlingDao->tableDelAll($pBundlingDao->tableKeys('*'.\Our\NameConst::blGoods.$goodsCommonId));
return $pBundlingDao->tableDelAll($pBundlingDao->tableKeys('*'.\Our\NameConst::blGoods.$goodsCommonId));
}
/**
* 根据GoodsCommonIds反向更新组合销售数据
* @param $goodsCommonId
*/
public function updatePBundlingByGoodsCommonId($goodsCommonId){
$goodsRedis = \Redis\Db4\GoodsRedisModel::getInstance();
$onlineStorageGoodsKey = \Our\NameConst::onlineStorageGoodsPrefix.$goodsCommonId;
$onlineStorageGoods = $goodsRedis->tableHGAll($onlineStorageGoodsKey);
$pBundlingRedisDao = \Redis\Db4\PBundlingRedisModel::getInstance();
$keys = $pBundlingRedisDao->tableKeys('*'.\Our\NameConst::blGoods.$goodsCommonId);
foreach($keys as $blIdKey){
$pBundling = $pBundlingRedisDao->getNoPrefix($blIdKey);
if(\Our\Common::isSerialized($pBundling)){
$pBundling = unserialize($pBundling);
}
$goodsList = $pBundling['goodsList'];
if($goodsList){
$newGoods = array();
foreach($goodsList as $goods){
if($goods['goodsCommonId']==$goodsCommonId){
$goods['goodsStorage'] = unserialize($onlineStorageGoods[$goods['goods_id']])['goodsStorage'];
if(intval($goods['goodsStorage']/$goods['num'])<$pBundling['bl_storage']){
$pBundling['bl_storage'] = intval($goods['goodsStorage']/$goods['num']);
}
}
$newGoods[] = $goods;
}
$pBundling['goodsList'] = $newGoods;
}
$pBundlingRedisDao->setNoPrefix($blIdKey,serialize($pBundling),\Our\ApiConst::oneDaySecond);
}
return true;
}
public function delPBundlingListByStoreIdAndBlIds($storeId=false,$blId=false){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment