作者 王智

222

... ... @@ -159,10 +159,18 @@ class Order extends Api
$this->DeleteCar($param['shop_id']);
}
$arr = json_decode(htmlspecialchars_decode($param['data']), true);
foreach ($arr as $k => $v) {
$stock[$k] = Db::name('product')->where(['id' => $v['product_id']])->value('stock');
$num[$k] = $stock[$k] - $v['buy_num'];
$res[$k] = Db::name('product')->where(['id' => $v['product_id']])->update(['stock' => $num[$k]]);
}
die;
//生成订单号
$order_sn = $this->order_sn();
//查询地址
$address = Db::name('address')->where(['id' => $param['address_id']])->find();
$address = Db::name('addesrs')->where(['id' => $param['address_id']])->find();
$order_data = [
'total' => $param['total'],
'user_id' => $user_id,
... ...