Commit 4507ba0c authored by liuyuzhen's avatar liuyuzhen

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

parents dbfb3838 e8edbe52
...@@ -10,7 +10,7 @@ use Zend\Json\Server\Exception\ErrorException; ...@@ -10,7 +10,7 @@ use Zend\Json\Server\Exception\ErrorException;
class GoodsCommonServiceModel extends \Business\AbstractModel class GoodsCommonServiceModel extends \Business\AbstractModel
{ {
private $goodsStorageField = 'goods_id goodsId,goods_name goodsName,goods_verify goodsVerify,goods_state goodsState,goods_image goodsImage,goods_price goodsPrice,goods_storage goodsStorage,goods_spec goodsAttr,goods_storage_alarm as goodsStorageAlarm'; private $goodsStorageField = 'goods_id goodsId,goods_name goodsName,goods_verify goodsVerify,goods_state goodsState,goods_image goodsImage,goods_price goodsPrice,goods_storage goodsStorage,goods_spec goodsAttr';
private $setStorageType = array('add'=> 1, 'set'=>2); private $setStorageType = array('add'=> 1, 'set'=>2);
public function init() { public function init() {
...@@ -28,8 +28,6 @@ class GoodsCommonServiceModel extends \Business\AbstractModel ...@@ -28,8 +28,6 @@ class GoodsCommonServiceModel extends \Business\AbstractModel
*/ */
public function setGoodsStorage($storeId, $goodsId, $num = 0, $type='add') { public function setGoodsStorage($storeId, $goodsId, $num = 0, $type='add') {
$orderService=\Business\Order\OrderServiceModel::getInstance(); $orderService=\Business\Order\OrderServiceModel::getInstance();
$goodsDao=\DAO\GoodsModel::getInstance(DbNameConst::masterDBConnectName);
$commonDao = \DAO\GoodsCommonModel::getInstance();
if($goodsId === 0){ if($goodsId === 0){
\Error\ErrorModel::throwException(\Error\CodeConfigModel::commonError); \Error\ErrorModel::throwException(\Error\CodeConfigModel::commonError);
} }
...@@ -38,21 +36,6 @@ class GoodsCommonServiceModel extends \Business\AbstractModel ...@@ -38,21 +36,6 @@ class GoodsCommonServiceModel extends \Business\AbstractModel
}else{ }else{
$type=ApiConst::set; $type=ApiConst::set;
$where = array();
$where['store_id'] = $storeId;
$where['goods_id'] = $goodsId;
$data = $goodsDao->find($where, 'goods_id, goods_commonid');
$goodsDao->setDb($goodsDao->dbName);
$goodsDao->db->doTransaction();
$ret1 = $goodsDao->updateStorage($goodsId, $num, ApiConst::zero);
$ret2 = $commonDao->updateStorage($data['goods_commonid'],ApiConst::zero);
if(!$ret1 || !$ret2) {
$goodsDao->db->doRollback();
\Error\ErrorModel::throwException(\Error\CodeConfigModel::updateGoodsStorageForOrder);
}
$goodsDao->db->doCommit();
return true;
} }
$res=$orderService->updateGoodsStoregeByGoodsIds($storeId,$goodsId,$num,$type); $res=$orderService->updateGoodsStoregeByGoodsIds($storeId,$goodsId,$num,$type);
return $res; return $res;
...@@ -103,7 +86,7 @@ class GoodsCommonServiceModel extends \Business\AbstractModel ...@@ -103,7 +86,7 @@ class GoodsCommonServiceModel extends \Business\AbstractModel
$where = array(); $where = array();
$where[] = 'store_id = '.$storeId; $where[] = 'store_id = '.$storeId;
$where[] = 'goods_storage_alarm > 0'; $where[] = 'goods_storage_alarm > 0';
$where[] = 'goods_storage<goods_storage_alarm'; $where[] = 'goods_storage<=goods_storage_alarm';
//获得列表 //获得列表
if($datas = $goodsDao->getList(implode($where, ' and '), $this->goodsStorageField)) { if($datas = $goodsDao->getList(implode($where, ' and '), $this->goodsStorageField)) {
foreach ($datas as $key=>$val) { foreach ($datas as $key=>$val) {
...@@ -186,7 +169,6 @@ class GoodsCommonServiceModel extends \Business\AbstractModel ...@@ -186,7 +169,6 @@ class GoodsCommonServiceModel extends \Business\AbstractModel
$where[] = 'goods_commonid in('.trim($ids,',').')'; $where[] = 'goods_commonid in('.trim($ids,',').')';
} }
} }
$order[] = ['goodsCommonid','DESC'];
$saleSort ? $ttl = \Our\ApiConst::oneHour : \Our\ApiConst::oneDaySecond; $saleSort ? $ttl = \Our\ApiConst::oneHour : \Our\ApiConst::oneDaySecond;
if($activities){ if($activities){
$activities = array_keys($activities); $activities = array_keys($activities);
...@@ -438,12 +420,10 @@ class GoodsCommonServiceModel extends \Business\AbstractModel ...@@ -438,12 +420,10 @@ class GoodsCommonServiceModel extends \Business\AbstractModel
} }
if(!$result) { if(!$result) {
$statGoodsDao->db->doRollback(); $statGoodsDao->db->doRollback();
} } else { //商品报表更新成功
} $statGoodsDao->db->doCommit();
file_put_contents($this->baseDir . \Our\PathConst::goodsSellStatTime, $endTime);
if($result) { //商品报表更新成功 }
$statGoodsDao->db->doCommit();
file_put_contents($this->baseDir . \Our\PathConst::goodsSellStatTime, $endTime);
} }
} }
...@@ -486,7 +466,7 @@ class GoodsCommonServiceModel extends \Business\AbstractModel ...@@ -486,7 +466,7 @@ class GoodsCommonServiceModel extends \Business\AbstractModel
$keyword !== '' && $where[] = "goods_name like '%{$keyword}%'"; $keyword !== '' && $where[] = "goods_name like '%{$keyword}%'";
list($_where,$order,$attrStr,$saleSort) = $this->getParam($attrValue,$minPrice,$maxPrice,$goodsSort); list($_where,$order,$attrStr,$saleSort) = $this->getParam($attrValue,$minPrice,$maxPrice,$goodsSort);
$where = array_merge($where,$_where); $where = array_merge($where,$_where);
$order[] = ['goodsCommonId','DESC'];
$commonDAO = \DAO\GoodsCommonModel::getInstance(); $commonDAO = \DAO\GoodsCommonModel::getInstance();
$saleSort ? $ttl = \Our\ApiConst::oneHour : \Our\ApiConst::oneDaySecond; $saleSort ? $ttl = \Our\ApiConst::oneHour : \Our\ApiConst::oneDaySecond;
if(!$activities){ if(!$activities){
...@@ -1364,7 +1344,6 @@ class GoodsCommonServiceModel extends \Business\AbstractModel ...@@ -1364,7 +1344,6 @@ class GoodsCommonServiceModel extends \Business\AbstractModel
break; break;
} }
} }
return true;
} }
/** /**
...@@ -1378,9 +1357,6 @@ class GoodsCommonServiceModel extends \Business\AbstractModel ...@@ -1378,9 +1357,6 @@ class GoodsCommonServiceModel extends \Business\AbstractModel
if(!$oldTemp){ if(!$oldTemp){
$storeOnlineGoodsClassDao->insert($goodsClass); $storeOnlineGoodsClassDao->insert($goodsClass);
} }
$storeOnlineGoodsClassDao = \DAO\GoodsClass\StoreOnlineGoodsClassModel::getInstance();
\Our\RedisHelper::delCachedFunction(\Redis\Db6\StoreOnlineGoodsClassRedisModel::getInstance(),array(&$storeOnlineGoodsClassDao, 'getList'),array(),array($goodsClass['store_id']));
\Our\RedisHelper::delCachedFunction(\Redis\Db6\StoreOnlineGoodsClassRedisModel::getInstance(),array(&$storeOnlineGoodsClassDao, 'getStoreOnlineGoodsClassesByGcId'),array(),array($goodsClass['store_id']));
return true; return true;
} }
...@@ -1395,18 +1371,12 @@ class GoodsCommonServiceModel extends \Business\AbstractModel ...@@ -1395,18 +1371,12 @@ class GoodsCommonServiceModel extends \Business\AbstractModel
$where['store_id'] = $goodsClass['store_id']; $where['store_id'] = $goodsClass['store_id'];
$where['goods_state'] = \Our\ApiConst::onlineGoodsState; $where['goods_state'] = \Our\ApiConst::onlineGoodsState;
$where['goods_verify'] = \Our\ApiConst::onlineGoodsVerify; $where['goods_verify'] = \Our\ApiConst::onlineGoodsVerify;
$where['is_del'] = \Our\ApiConst::zero;
if($gcFrom==\Our\ApiConst::one){ if($gcFrom==\Our\ApiConst::one){
$where['goods_class_t_id'] = $goodsClass['gc_id_3']; $where['goods_class_t_id'] = $goodsClass['gc_id_3'];
} }
$tempOne = $goodsCommonDao->getOne($where,'goods_commonid'); $tempOne = $goodsCommonDao->getOne($where,'goods_commonid');
if(!$tempOne){ if(!$tempOne){
$result = $storeOnlineGoodsClassDao->del($goodsClass); $storeOnlineGoodsClassDao->del($goodsClass);
if($result){
$storeOnlineGoodsClassDao = \DAO\GoodsClass\StoreOnlineGoodsClassModel::getInstance();
\Our\RedisHelper::delCachedFunction(\Redis\Db6\StoreOnlineGoodsClassRedisModel::getInstance(),array(&$storeOnlineGoodsClassDao, 'getList'),array(),array($goodsClass['store_id']));
\Our\RedisHelper::delCachedFunction(\Redis\Db6\StoreOnlineGoodsClassRedisModel::getInstance(),array(&$storeOnlineGoodsClassDao, 'getStoreOnlineGoodsClassesByGcId'),array(),array($goodsClass['store_id']));
}
} }
} }
} }
...@@ -1505,9 +1475,4 @@ class GoodsCommonServiceModel extends \Business\AbstractModel ...@@ -1505,9 +1475,4 @@ class GoodsCommonServiceModel extends \Business\AbstractModel
} }
public function syncGoodsCommonStorageByGoods(){
$goodsCommonDao = \DAO\GoodsCommonModel::getInstance();
$return = $goodsCommonDao->syncGoodsCommonStorageByGoods();
}
} }
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