Commit 1dc8d042 authored by chenchuanwen's avatar chenchuanwen

goodsStorage

parent 31880801
...@@ -70,6 +70,20 @@ class Common ...@@ -70,6 +70,20 @@ class Common
} }
return false; return false;
} }
/**
* @param $arr
* @param $key_name
* @return array
* 将数据库中查出的列表以指定的 id 作为数组的键名
*/
public static function convertArrKey($arr, $key_name)
{
$arr2 = array();
foreach ($arr as $key => $val) {
$arr2[$val[$key_name]] = $val;
}
return $arr2;
}
public static function isSerialized($data) public static function isSerialized($data)
{ {
......
...@@ -1198,7 +1198,9 @@ class OrderServiceModel extends \Business\AbstractModel ...@@ -1198,7 +1198,9 @@ class OrderServiceModel extends \Business\AbstractModel
public function updateGoodsStoregeByGoodsIds($storeId,$goodsid,$num=ApiConst::zero,$type=ApiConst::plus){ public function updateGoodsStoregeByGoodsIds($storeId,$goodsid,$num=ApiConst::zero,$type=ApiConst::plus){
if(is_array($goodsid)){ if(is_array($goodsid)){
$where['goods_id']=array('in',$goodsid); $goodsids=array($goodsid);
$convertGoodsId=Common::convertArrKey($goodsid,'goodsId');
$where['goods_id']=array('in',$goodsids);
}else{ }else{
$where['goods_id']=$goodsid; $where['goods_id']=$goodsid;
} }
...@@ -1206,9 +1208,15 @@ class OrderServiceModel extends \Business\AbstractModel ...@@ -1206,9 +1208,15 @@ class OrderServiceModel extends \Business\AbstractModel
$goodsDao = \DAO\GoodsModel::getInstance(DbNameConst::masterDBConnectName); $goodsDao = \DAO\GoodsModel::getInstance(DbNameConst::masterDBConnectName);
$goodses=$goodsDao->getList($where,$goodsDao->goodsDetailField); $goodses=$goodsDao->getList($where,$goodsDao->goodsDetailField);
if(!empty($goodses)){ if(!empty($goodses)){
if(is_array($goodsid)){
foreach($goodses as &$goods){
$goods['goodsNum']=$convertGoodsId[$goods['goodsId']]['num'];
}
}else{
foreach($goodses as &$goods){ foreach($goodses as &$goods){
$goods['goodsNum']=$num; $goods['goodsNum']=$num;
} }
}
if($this->updateDateGoodsStoregeByOrderGoods($goodses,$type,false)){ if($this->updateDateGoodsStoregeByOrderGoods($goodses,$type,false)){
return true; return true;
} }
......
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