Commit a5cb9817 authored by christ's avatar christ

storage

parent b9db13e2
......@@ -28,6 +28,8 @@ class GoodsCommonServiceModel extends \Business\AbstractModel
*/
public function setGoodsStorage($storeId, $goodsId, $num = 0, $type='add') {
$orderService=\Business\Order\OrderServiceModel::getInstance();
$goodsDao=\DAO\GoodsModel::getInstance(DbNameConst::masterDBConnectName);
$commonDao = \DAO\GoodsCommonModel::getInstance();
if($goodsId === 0){
\Error\ErrorModel::throwException(\Error\CodeConfigModel::commonError);
}
......@@ -36,6 +38,21 @@ class GoodsCommonServiceModel extends \Business\AbstractModel
}else{
$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);
return $res;
......
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