...
|
...
|
@@ -315,33 +315,33 @@ class Cars extends Api |
|
|
$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,stock,style g_style,introduce');
|
|
|
|
|
|
$total_price = 0;//总商品费用(不含运费)
|
|
|
$total_expense_price = 0;//总运费
|
|
|
foreach ($res as &$value){
|
|
|
$value['image'] = $this->auth->absolutionUrlOne($value['image']);
|
|
|
foreach($res_goods as $g_value){
|
|
|
if($value['id'] == $g_value['goods_id']){
|
|
|
$value['price'] = $g_value['price'];//商品价格
|
|
|
|
|
|
foreach($res_goods as &$g_value){
|
|
|
$g_value['id'] = $g_value['goods_id'];
|
|
|
foreach ($res as $value){
|
|
|
if($value['id'] == $g_value['goods_id']){
|
|
|
$g_value['name'] = $value['name'];
|
|
|
$g_value['image'] = $this->auth->absolutionUrlOne($value['image']);
|
|
|
$g_value['introduce'] = $value['introduce'];
|
|
|
//检测库存
|
|
|
$check_stock = Common::checkStock($g_value['style'],$g_value['goods_number'],$value['g_style'],$value['stock']);
|
|
|
if(!$check_stock){
|
|
|
$this->error('库存不足');
|
|
|
$this->error('商品名称:'.$value['name'].',规格:'.$g_value['style'].'库存不足');
|
|
|
}
|
|
|
$value['goods_number'] = $g_value['goods_number'];//商品数量
|
|
|
$value['style'] = $g_value['style'];//商品款式
|
|
|
$total_price += $g_value['price'] * $g_value['goods_number'];
|
|
|
$total_expense_price += $value['expense_price'];
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
$total_expense_price += $value['expense_price'];
|
|
|
unset($value['expense_price']);
|
|
|
unset($value['stock']);
|
|
|
$total_price += $g_value['price'] * $g_value['goods_number'];
|
|
|
}
|
|
|
$arr['data'] = $res;
|
|
|
$arr['data'] = $res_goods;
|
|
|
$arr['total_goods_price'] = $total_price;
|
|
|
$arr['total_expense_price'] = $total_expense_price;
|
|
|
$arr['total_price'] = $total_price + $total_expense_price;
|
|
|
|
|
|
$this->success('成功',$arr);
|
|
|
}else{
|
|
|
$this->error('请求方式错误');
|
...
|
...
|
|