Commit 07d9fbb2 authored by liuyuzhen's avatar liuyuzhen

库存问题修改

parent bb8b852b
......@@ -92,6 +92,7 @@ class HomeController extends \Our\Controller_AbstractIndex{
$this->success($nearbyStores);
}
/**
* 设置首页推荐分类
* @param bool $flag
......
File mode changed from 100755 to 100644
......@@ -43,6 +43,7 @@ class OrderConfirmUtil {
public function addOrder($data,$memberId,$currentAddress){
$storeCartData = $this->checkPostData($data,$memberId,$currentAddress);
//return $storeCartData;
$storeCartData = $this->checkDeliveryTypeAndPayway($storeCartData);
return $this->saveOrderInfo($storeCartData);
}
......@@ -221,7 +222,7 @@ class OrderConfirmUtil {
\Error\ErrorModel::throwException(\Error\CodeConfigModel::noExpressDeliveryForOrder);
}
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'];
}
......
......@@ -164,6 +164,8 @@ class NameConst {
const frontLogPath = '/data/log/';
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 {
}else{
$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['goodsMid'] = $tempCart['goods_mid'];
......@@ -278,6 +279,7 @@ class GroupSaleServiceModel extends \Business\AbstractModel {
$pbundlingInstance = \DAO\PBundlingModel::getInstance(\Our\DbNameConst::salveDBConnectName);
\Our\RedisHelper::delCachedFunction(\Redis\Db4\PBundlingRedisModel::getInstance(),array(&$pbundlingInstance, 'getList'),array(),array('*'.$blId));
}
/**
* 根据商品获取组合
* @param $goodsCommnId
......@@ -395,12 +397,13 @@ class GroupSaleServiceModel extends \Business\AbstractModel {
return false;
}
$pBundlingRedis = \Redis\Db4\PBundlingRedisModel::getInstance();
$pbundlingDao = \DAO\PBundlingModel::getInstance();
$returnList = array();
$noCacheList = array();
foreach($groupList as $group){
$newGroup = $pBundlingRedis->tableCacheGet('gid_'.$group['blId']);
$newGroup = $pbundlingDao->getPBundlingCacheByBlId($group['blId']);
if($newGroup){
$returnList[] = unserialize($newGroup);
$returnList[] = $newGroup;
}else{
$noCacheList[] = $group;
}
......@@ -413,7 +416,6 @@ class GroupSaleServiceModel extends \Business\AbstractModel {
$returnList = $dbPBundlingList;
}
}
if($withKeyFlag){
$newReturnList = array();
foreach($returnList as $temp){
......@@ -458,7 +460,7 @@ class GroupSaleServiceModel extends \Business\AbstractModel {
$goodsArray[$v['goods_id']] = $v;
}
foreach ($pBundlingGoodsArray as $bl_id => $pBundlingGoods){
$goodsPrefix = '';
$blSumPrice = \Our\ApiConst::zero;
if($pBundlingGoods && is_array($pBundlingGoods)){
......@@ -478,15 +480,19 @@ class GroupSaleServiceModel extends \Business\AbstractModel {
//unset($goods_temp['goods_image']);
//unset($goods_temp['bl_id']);
//$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'];
$tempGroup['goodsList'][] = $goods_temp;
}else{
$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;
}
}
......@@ -575,6 +581,8 @@ class GroupSaleServiceModel extends \Business\AbstractModel {
} else {
if($pBundling['bl_storage']<=\Our\ApiConst::zero){
\Error\ErrorModel::throwException(\Error\CodeConfigModel::noStorageForBundlingGoods);
}else if($pBundling['bl_storage']<$tempCart['goods_num']){
\Error\ErrorModel::throwException(\Error\CodeConfigModel::noEnoughStorageForBundlingGoods);
}
}
if(!$pBundling['goods_freight']){
......@@ -646,6 +654,8 @@ class GroupSaleServiceModel extends \Business\AbstractModel {
if ($goodsStorage['onlineFlag'] == \Our\ApiConst::one) {
if($goodsStorage['goodsStorage']<=\Our\ApiConst::zero){
\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) {
\Error\ErrorModel::throwException(\Error\CodeConfigModel::goodsOfflineForCartOrOrder);
......@@ -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()))) {
\Error\ErrorModel::throwException(\Error\CodeConfigModel::pBundlingOfflineForOrder);
} elseif($pBundling['bl_storage']<=\Our\ApiConst::zero){
if($pBundling['bl_storage']<=\Our\ApiConst::zero){
\Error\ErrorModel::throwException(\Error\CodeConfigModel::pBundlingNoStorageForOrder);
}/*else{
$tempObj['goodsState'] = \Our\ApiConst::cartGoodsOnline;
}*/
\Error\ErrorModel::throwException(\Error\CodeConfigModel::pBundlingNoStorageForOrder);
}else if($pBundling['bl_storage']<$goodsNum){
\Error\ErrorModel::throwException(\Error\CodeConfigModel::noEnoughStorageForBundlingGoods);
}
$goodsFreight = $pBundling['goods_freight'];//是否免邮1:是,0:否
......@@ -845,13 +853,13 @@ class GroupSaleServiceModel extends \Business\AbstractModel {
$allGcIds[] = $tempObj['gcId'];
$storeGcIds[] = $tempObj['gcId'];
if ($goodsStorage['onlineFlag'] == \Our\ApiConst::one) {
if($goodsStorage['goodsStorage']>\Our\ApiConst::zero){
$tempObj['goodsState'] = \Our\ApiConst::cartGoodsOnline;
}else{
$tempObj['goodsState'] = \Our\ApiConst::cartGoodsNoStorage;
if($goodsStorage['goodsStorage']<=\Our\ApiConst::zero){
\Error\ErrorModel::throwException(\Error\CodeConfigModel::goodsNoStoreForCartOrOrder);
}else if($goodsStorage['goodsStorage']<$tempObj['goodsNum']){
\Error\ErrorModel::throwException(\Error\CodeConfigModel::goodsNoStoreForCartOrOrder1);
}
} 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['goodsAttr'] = $goodsDao->getFormatGoodsAttr($goods['goods_spec']);
......
......@@ -102,6 +102,7 @@ class PBundlingModel extends \DAO\AbstractModel {
}
$pBundlingRedis = \Redis\Db4\PBundlingRedisModel::getInstance();
$result = $pBundlingRedis->tableHSet(\Our\NameConst::onlineStorageBlGoodsPrefix,$blId,$storeage,\Our\ApiConst::oneDaySecond);
$this->deletePBundlingByBlId($blId);
return $result;
}
......@@ -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 {
const noExpressDeliveryForOrder1 = 30115;
const goodsNoStoreForCartOrOrder1 = 30116;
const platFormAreadyIn=300117;
const noEnoughStorageForBundlingGoods = 30118;
//店铺相关错误码
//商品分类
......@@ -741,6 +743,7 @@ class CodeConfigModel {
self::notExistOrderGoods => '退款商品不存在',
self::noExpressDeliveryForOrder1 => '该店铺未配置快递配送',
self::goodsNoStoreForCartOrOrder1 => '商品库存紧张,您的购买数量太多啦',
self::noEnoughStorageForBundlingGoods =>'组合销售库存紧张,您购买的数量太多啦',
//销售员
self::emptySaleGoodsId=>'商品id不能为空',
self::emptySaleGoods=>'销售商品不存在',
......
......@@ -129,6 +129,10 @@ class AbstractModel {
return $this->getRedis()->get($this->_addPrefix($key));
}
public function getNoPrefix($key){
return $this->getRedis()->get($key);
}
/**
* redis自增1
*
......
......@@ -27,6 +27,26 @@ class AbstractModel extends \Redis\AbstractModel {
$result = $this->get($this->calcKey($id));
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){
$res=$this->set($this->calcKey($id), $data,$experio);
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