作者 jinglong
1 个管道 的构建 通过 耗费 0 秒

修改结算商品库存

... ... @@ -302,7 +302,7 @@ class Cars extends Api
$key = ['goods_id','price','goods_number','style'];
$res_goods = Common::array_merge_more($key,$goods_id_s,$price_s,$goods_number_s,$style_s);
//查询商品
$res = Common::selectSoftWhereData('goods',['id'=>['in',$goods_id_s]],'id,name,image,expense_price,introduce');
$res = Common::selectSoftWhereData('goods',['id'=>['in',$goods_id_s]],'id,name,image,expense_price,stock,introduce');
$total_price = 0;//总商品费用(不含运费)
$total_expense_price = 0;//总运费
foreach ($res as &$value){
... ... @@ -310,6 +310,9 @@ class Cars extends Api
foreach($res_goods as $g_value){
if($value['id'] == $g_value['goods_id']){
$value['price'] = $g_value['price'];//商品价格
if(($value['stock'] <=> $g_value['goods_number']) == -1){
$this->error('商品名称为'.$value['name'].'的库存不足');
}
$value['goods_number'] = $g_value['goods_number'];//商品数量
$value['style'] = $g_value['style'];//商品款式
$total_price += $g_value['price'] * $g_value['goods_number'];
... ...