Commit 07d9fbb2 authored by liuyuzhen's avatar liuyuzhen

库存问题修改

parent bb8b852b
...@@ -92,6 +92,7 @@ class HomeController extends \Our\Controller_AbstractIndex{ ...@@ -92,6 +92,7 @@ class HomeController extends \Our\Controller_AbstractIndex{
$this->success($nearbyStores); $this->success($nearbyStores);
} }
/** /**
* 设置首页推荐分类 * 设置首页推荐分类
* @param bool $flag * @param bool $flag
......
File mode changed from 100755 to 100644
...@@ -43,6 +43,7 @@ class OrderConfirmUtil { ...@@ -43,6 +43,7 @@ class OrderConfirmUtil {
public function addOrder($data,$memberId,$currentAddress){ public function addOrder($data,$memberId,$currentAddress){
$storeCartData = $this->checkPostData($data,$memberId,$currentAddress); $storeCartData = $this->checkPostData($data,$memberId,$currentAddress);
//return $storeCartData;
$storeCartData = $this->checkDeliveryTypeAndPayway($storeCartData); $storeCartData = $this->checkDeliveryTypeAndPayway($storeCartData);
return $this->saveOrderInfo($storeCartData); return $this->saveOrderInfo($storeCartData);
} }
...@@ -221,7 +222,7 @@ class OrderConfirmUtil { ...@@ -221,7 +222,7 @@ class OrderConfirmUtil {
\Error\ErrorModel::throwException(\Error\CodeConfigModel::noExpressDeliveryForOrder); \Error\ErrorModel::throwException(\Error\CodeConfigModel::noExpressDeliveryForOrder);
} }
if($tempStore['goodsFreight']==\Our\ApiConst::zero&&!($tempStore['is_transport']&&$tempStore['transport_id']>\Our\ApiConst::zero&&isset($temp['shippingFee']))){ if($tempStore['goodsFreight']==\Our\ApiConst::zero&&!($tempStore['is_transport']&&$tempStore['transport_id']>\Our\ApiConst::zero&&isset($temp['shippingFee']))){
\Error\ErrorModel::throwException(\Error\CodeConfigModel::noExpressDeliveryForOrder); \Error\ErrorModel::throwException(\Error\CodeConfigModel::noExpressDeliveryForOrder1);
} }
$deliveryFee = $temp['shippingFee']; $deliveryFee = $temp['shippingFee'];
} }
......
...@@ -164,6 +164,8 @@ class NameConst { ...@@ -164,6 +164,8 @@ class NameConst {
const frontLogPath = '/data/log/'; const frontLogPath = '/data/log/';
const frontPrefix = 'front'; const frontPrefix = 'front';
const blGoods = '_goodsCommon';
} }
?> ?>
\ No newline at end of file
File mode changed from 100755 to 100644
...@@ -180,7 +180,8 @@ class GroupSaleServiceModel extends \Business\AbstractModel { ...@@ -180,7 +180,8 @@ class GroupSaleServiceModel extends \Business\AbstractModel {
}else{ }else{
$tempObj['goodsState'] = \Our\ApiConst::cartGoodsOffline; $tempObj['goodsState'] = \Our\ApiConst::cartGoodsOffline;
} }
$tempObj['goodsPrice']=\Goods\GoodsUtil::getInstance()->getRealPrice($tempCart['goods_id'],$memberId); $price = \Goods\GoodsUtil::getInstance()->getRealPrice($tempCart['goods_id'],$memberId);
$tempObj['goodsPrice'] = $price?$price:intval($tempCart['goods_price']);
} }
$tempObj['goodsAttr'] = $goodsDao->getFormatGoodsAttr($tempCart['goods_spec']); $tempObj['goodsAttr'] = $goodsDao->getFormatGoodsAttr($tempCart['goods_spec']);
$tempObj['goodsMid'] = $tempCart['goods_mid']; $tempObj['goodsMid'] = $tempCart['goods_mid'];
...@@ -278,6 +279,7 @@ class GroupSaleServiceModel extends \Business\AbstractModel { ...@@ -278,6 +279,7 @@ class GroupSaleServiceModel extends \Business\AbstractModel {
$pbundlingInstance = \DAO\PBundlingModel::getInstance(\Our\DbNameConst::salveDBConnectName); $pbundlingInstance = \DAO\PBundlingModel::getInstance(\Our\DbNameConst::salveDBConnectName);
\Our\RedisHelper::delCachedFunction(\Redis\Db4\PBundlingRedisModel::getInstance(),array(&$pbundlingInstance, 'getList'),array(),array('*'.$blId)); \Our\RedisHelper::delCachedFunction(\Redis\Db4\PBundlingRedisModel::getInstance(),array(&$pbundlingInstance, 'getList'),array(),array('*'.$blId));
} }
/** /**
* 根据商品获取组合 * 根据商品获取组合
* @param $goodsCommnId * @param $goodsCommnId
...@@ -395,12 +397,13 @@ class GroupSaleServiceModel extends \Business\AbstractModel { ...@@ -395,12 +397,13 @@ class GroupSaleServiceModel extends \Business\AbstractModel {
return false; return false;
} }
$pBundlingRedis = \Redis\Db4\PBundlingRedisModel::getInstance(); $pBundlingRedis = \Redis\Db4\PBundlingRedisModel::getInstance();
$pbundlingDao = \DAO\PBundlingModel::getInstance();
$returnList = array(); $returnList = array();
$noCacheList = array(); $noCacheList = array();
foreach($groupList as $group){ foreach($groupList as $group){
$newGroup = $pBundlingRedis->tableCacheGet('gid_'.$group['blId']); $newGroup = $pbundlingDao->getPBundlingCacheByBlId($group['blId']);
if($newGroup){ if($newGroup){
$returnList[] = unserialize($newGroup); $returnList[] = $newGroup;
}else{ }else{
$noCacheList[] = $group; $noCacheList[] = $group;
} }
...@@ -413,7 +416,6 @@ class GroupSaleServiceModel extends \Business\AbstractModel { ...@@ -413,7 +416,6 @@ class GroupSaleServiceModel extends \Business\AbstractModel {
$returnList = $dbPBundlingList; $returnList = $dbPBundlingList;
} }
} }
if($withKeyFlag){ if($withKeyFlag){
$newReturnList = array(); $newReturnList = array();
foreach($returnList as $temp){ foreach($returnList as $temp){
...@@ -458,7 +460,7 @@ class GroupSaleServiceModel extends \Business\AbstractModel { ...@@ -458,7 +460,7 @@ class GroupSaleServiceModel extends \Business\AbstractModel {
$goodsArray[$v['goods_id']] = $v; $goodsArray[$v['goods_id']] = $v;
} }
foreach ($pBundlingGoodsArray as $bl_id => $pBundlingGoods){ foreach ($pBundlingGoodsArray as $bl_id => $pBundlingGoods){
$goodsPrefix = '';
$blSumPrice = \Our\ApiConst::zero; $blSumPrice = \Our\ApiConst::zero;
if($pBundlingGoods && is_array($pBundlingGoods)){ if($pBundlingGoods && is_array($pBundlingGoods)){
...@@ -478,15 +480,19 @@ class GroupSaleServiceModel extends \Business\AbstractModel { ...@@ -478,15 +480,19 @@ class GroupSaleServiceModel extends \Business\AbstractModel {
//unset($goods_temp['goods_image']); //unset($goods_temp['goods_image']);
//unset($goods_temp['bl_id']); //unset($goods_temp['bl_id']);
//$goodsArray[] =$goods_temp; //unset($goods_temp['goods_image']); //$goodsArray[] =$goods_temp; //unset($goods_temp['goods_image']);
if($tempGroup['bl_storage']>0&&floor($goods_temp['goodsStorage']/$goods_temp['num'])<$tempGroup['bl_storage']){
$tempGroup['bl_storage'] = floor($goods_temp['goodsStorage']/$goods_temp['num']);
}
$goods_temp['goodsImagePath'] = $goods_temp['goods_image']; $goods_temp['goodsImagePath'] = $goods_temp['goods_image'];
$tempGroup['goodsList'][] = $goods_temp; $tempGroup['goodsList'][] = $goods_temp;
}else{ }else{
$tempGroup['goodsCountFlag'] = false; $tempGroup['goodsCountFlag'] = false;
} }
$tempGroup['sumPrice'] = $blSumPrice; $goodsPrefix .= \Our\NameConst::blGoods.$goods_temp['goodsCommonId'];
} }
} }
$bundlingRedis->tableCacheSet('gid_'.$bl_id,serialize($tempGroup),\Our\ApiConst::oneDaySecond); $tempGroup['sumPrice'] = $blSumPrice;
$bundlingRedis->tableCacheSet('gid_'.$bl_id.$goodsPrefix,serialize($tempGroup),\Our\ApiConst::oneDaySecond);
$group[] = $tempGroup; $group[] = $tempGroup;
} }
} }
...@@ -575,6 +581,8 @@ class GroupSaleServiceModel extends \Business\AbstractModel { ...@@ -575,6 +581,8 @@ class GroupSaleServiceModel extends \Business\AbstractModel {
} else { } else {
if($pBundling['bl_storage']<=\Our\ApiConst::zero){ if($pBundling['bl_storage']<=\Our\ApiConst::zero){
\Error\ErrorModel::throwException(\Error\CodeConfigModel::noStorageForBundlingGoods); \Error\ErrorModel::throwException(\Error\CodeConfigModel::noStorageForBundlingGoods);
}else if($pBundling['bl_storage']<$tempCart['goods_num']){
\Error\ErrorModel::throwException(\Error\CodeConfigModel::noEnoughStorageForBundlingGoods);
} }
} }
if(!$pBundling['goods_freight']){ if(!$pBundling['goods_freight']){
...@@ -646,6 +654,8 @@ class GroupSaleServiceModel extends \Business\AbstractModel { ...@@ -646,6 +654,8 @@ class GroupSaleServiceModel extends \Business\AbstractModel {
if ($goodsStorage['onlineFlag'] == \Our\ApiConst::one) { if ($goodsStorage['onlineFlag'] == \Our\ApiConst::one) {
if($goodsStorage['goodsStorage']<=\Our\ApiConst::zero){ if($goodsStorage['goodsStorage']<=\Our\ApiConst::zero){
\Error\ErrorModel::throwException(\Error\CodeConfigModel::goodsNoStoreForCartOrOrder); \Error\ErrorModel::throwException(\Error\CodeConfigModel::goodsNoStoreForCartOrOrder);
}else if($tempObj['goodsNum']>$goodsStorage['goodsStorage']){
\Error\ErrorModel::throwException(\Error\CodeConfigModel::goodsNoStoreForCartOrOrder1);
} }
} else if ($goodsStorage['onlineFlag'] == \Our\ApiConst::zero) { } else if ($goodsStorage['onlineFlag'] == \Our\ApiConst::zero) {
\Error\ErrorModel::throwException(\Error\CodeConfigModel::goodsOfflineForCartOrOrder); \Error\ErrorModel::throwException(\Error\CodeConfigModel::goodsOfflineForCartOrOrder);
...@@ -762,11 +772,9 @@ class GroupSaleServiceModel extends \Business\AbstractModel { ...@@ -762,11 +772,9 @@ class GroupSaleServiceModel extends \Business\AbstractModel {
} else if (!($pBundling['bl_state'] == \Our\ApiConst::one && ($pBundling['bl_quota_starttime'] < time() && $pBundling['endTime'] >= time()))) { } else if (!($pBundling['bl_state'] == \Our\ApiConst::one && ($pBundling['bl_quota_starttime'] < time() && $pBundling['endTime'] >= time()))) {
\Error\ErrorModel::throwException(\Error\CodeConfigModel::pBundlingOfflineForOrder); \Error\ErrorModel::throwException(\Error\CodeConfigModel::pBundlingOfflineForOrder);
} elseif($pBundling['bl_storage']<=\Our\ApiConst::zero){ } elseif($pBundling['bl_storage']<=\Our\ApiConst::zero){
if($pBundling['bl_storage']<=\Our\ApiConst::zero){
\Error\ErrorModel::throwException(\Error\CodeConfigModel::pBundlingNoStorageForOrder); \Error\ErrorModel::throwException(\Error\CodeConfigModel::pBundlingNoStorageForOrder);
}/*else{ }else if($pBundling['bl_storage']<$goodsNum){
$tempObj['goodsState'] = \Our\ApiConst::cartGoodsOnline; \Error\ErrorModel::throwException(\Error\CodeConfigModel::noEnoughStorageForBundlingGoods);
}*/
} }
$goodsFreight = $pBundling['goods_freight'];//是否免邮1:是,0:否 $goodsFreight = $pBundling['goods_freight'];//是否免邮1:是,0:否
...@@ -845,13 +853,13 @@ class GroupSaleServiceModel extends \Business\AbstractModel { ...@@ -845,13 +853,13 @@ class GroupSaleServiceModel extends \Business\AbstractModel {
$allGcIds[] = $tempObj['gcId']; $allGcIds[] = $tempObj['gcId'];
$storeGcIds[] = $tempObj['gcId']; $storeGcIds[] = $tempObj['gcId'];
if ($goodsStorage['onlineFlag'] == \Our\ApiConst::one) { if ($goodsStorage['onlineFlag'] == \Our\ApiConst::one) {
if($goodsStorage['goodsStorage']>\Our\ApiConst::zero){ if($goodsStorage['goodsStorage']<=\Our\ApiConst::zero){
$tempObj['goodsState'] = \Our\ApiConst::cartGoodsOnline; \Error\ErrorModel::throwException(\Error\CodeConfigModel::goodsNoStoreForCartOrOrder);
}else{ }else if($goodsStorage['goodsStorage']<$tempObj['goodsNum']){
$tempObj['goodsState'] = \Our\ApiConst::cartGoodsNoStorage; \Error\ErrorModel::throwException(\Error\CodeConfigModel::goodsNoStoreForCartOrOrder1);
} }
} else if ($goodsStorage['onlineFlag'] == \Our\ApiConst::zero) { } else if ($goodsStorage['onlineFlag'] == \Our\ApiConst::zero) {
$tempObj['goodsState'] = \Our\ApiConst::cartGoodsOffline; \Error\ErrorModel::throwException(\Error\CodeConfigModel::goodsOfflineForCartOrOrder);
} }
$tempObj['goods_spec'] = $goods['goods_spec']; $tempObj['goods_spec'] = $goods['goods_spec'];
$tempObj['goodsAttr'] = $goodsDao->getFormatGoodsAttr($goods['goods_spec']); $tempObj['goodsAttr'] = $goodsDao->getFormatGoodsAttr($goods['goods_spec']);
......
...@@ -102,6 +102,7 @@ class PBundlingModel extends \DAO\AbstractModel { ...@@ -102,6 +102,7 @@ class PBundlingModel extends \DAO\AbstractModel {
} }
$pBundlingRedis = \Redis\Db4\PBundlingRedisModel::getInstance(); $pBundlingRedis = \Redis\Db4\PBundlingRedisModel::getInstance();
$result = $pBundlingRedis->tableHSet(\Our\NameConst::onlineStorageBlGoodsPrefix,$blId,$storeage,\Our\ApiConst::oneDaySecond); $result = $pBundlingRedis->tableHSet(\Our\NameConst::onlineStorageBlGoodsPrefix,$blId,$storeage,\Our\ApiConst::oneDaySecond);
$this->deletePBundlingByBlId($blId);
return $result; return $result;
} }
...@@ -142,6 +143,21 @@ class PBundlingModel extends \DAO\AbstractModel { ...@@ -142,6 +143,21 @@ class PBundlingModel extends \DAO\AbstractModel {
public function getPBundlingCacheByBlId($blId){
$pBundlingDao = \Redis\Db4\PBundlingRedisModel::getInstance();
return $pBundlingDao->getByKeys('gid_'.$blId);
}
public function deletePBundlingByBlId($blId){
$pBundlingDao = \Redis\Db4\PBundlingRedisModel::getInstance();
$pBundlingDao->tableDelAll($pBundlingDao->tableKeys('gid_'.$blId));
}
public function deletePBundlingByGoodsCommonId($goodsCommonId){
$pBundlingDao = \Redis\Db4\PBundlingRedisModel::getInstance();
$pBundlingDao->tableDelAll($pBundlingDao->tableKeys('*'.\Our\NameConst::blGoods.$goodsCommonId));
}
/** /**
* 类实例 * 类实例
* *
......
...@@ -275,6 +275,8 @@ class CodeConfigModel { ...@@ -275,6 +275,8 @@ class CodeConfigModel {
const noExpressDeliveryForOrder1 = 30115; const noExpressDeliveryForOrder1 = 30115;
const goodsNoStoreForCartOrOrder1 = 30116; const goodsNoStoreForCartOrOrder1 = 30116;
const platFormAreadyIn=300117; const platFormAreadyIn=300117;
const noEnoughStorageForBundlingGoods = 30118;
//店铺相关错误码 //店铺相关错误码
//商品分类 //商品分类
...@@ -741,6 +743,7 @@ class CodeConfigModel { ...@@ -741,6 +743,7 @@ class CodeConfigModel {
self::notExistOrderGoods => '退款商品不存在', self::notExistOrderGoods => '退款商品不存在',
self::noExpressDeliveryForOrder1 => '该店铺未配置快递配送', self::noExpressDeliveryForOrder1 => '该店铺未配置快递配送',
self::goodsNoStoreForCartOrOrder1 => '商品库存紧张,您的购买数量太多啦', self::goodsNoStoreForCartOrOrder1 => '商品库存紧张,您的购买数量太多啦',
self::noEnoughStorageForBundlingGoods =>'组合销售库存紧张,您购买的数量太多啦',
//销售员 //销售员
self::emptySaleGoodsId=>'商品id不能为空', self::emptySaleGoodsId=>'商品id不能为空',
self::emptySaleGoods=>'销售商品不存在', self::emptySaleGoods=>'销售商品不存在',
......
...@@ -129,6 +129,10 @@ class AbstractModel { ...@@ -129,6 +129,10 @@ class AbstractModel {
return $this->getRedis()->get($this->_addPrefix($key)); return $this->getRedis()->get($this->_addPrefix($key));
} }
public function getNoPrefix($key){
return $this->getRedis()->get($key);
}
/** /**
* redis自增1 * redis自增1
* *
......
...@@ -27,6 +27,26 @@ class AbstractModel extends \Redis\AbstractModel { ...@@ -27,6 +27,26 @@ class AbstractModel extends \Redis\AbstractModel {
$result = $this->get($this->calcKey($id)); $result = $this->get($this->calcKey($id));
return $result; return $result;
} }
/**
* 通过前缀获取单个对象
* @param $id
* @return bool|mixed|string
*/
public function getByKeys($id){
$str = $this->tableKeys($id);
if($str){
$str = $str[0];
$result = $this->getNoPrefix($str);
if($this->is_serialized($result)){
return unserialize($result);
}
return $result;
}else{
return false;
}
}
public function tableCacheSet($id,$data,$experio){ public function tableCacheSet($id,$data,$experio){
$res=$this->set($this->calcKey($id), $data,$experio); $res=$this->set($this->calcKey($id), $data,$experio);
return $res; return $res;
......
{"type":"1","content":{"className":"\\DAO\\MemberModel","method":"getMemberAvatarUrl","params":["260","http:\/\/thirdqq.qlogo.cn\/qqapp\/1106959346\/73308A441DEC867A013C7238782B440B\/100"]}}["260","http:\/\/thirdqq.qlogo.cn\/qqapp\/1106959346\/73308A441DEC867A013C7238782B440B\/100"]success
\ No newline at end of file
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