Commit aae20f62 authored by liuyuzhen's avatar liuyuzhen

购物车缓存

parent 2a943e8b
......@@ -316,7 +316,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;
......
......@@ -259,7 +259,7 @@ 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));
}
/**
......@@ -267,7 +267,34 @@ class PBundlingModel extends \DAO\AbstractModel {
* @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