...
|
...
|
@@ -65,8 +65,10 @@ class ShopCar extends Api |
|
|
$param = $this->request->param();
|
|
|
$is_shop = Db::name('shopcar')->where(['user_id' => $user_id])->where(['product_id' => $param['id']])->value('buy_num');
|
|
|
if (empty($is_shop)) {
|
|
|
echo '1';
|
|
|
$res = Db::name('shopcar')->insert(['product_id' => $param['id'], 'buy_num' => $param['num'], 'user_id' => $user_id]);
|
|
|
} else {
|
|
|
echo '2';
|
|
|
$shop_num = $is_shop + $param['num'];
|
|
|
$res = Db::name('shopcar')->where(['user_id' => $user_id])->where(['product_id' => $param['id']])->update(['buy_num' => $shop_num]);
|
|
|
}
|
...
|
...
|
@@ -125,7 +127,7 @@ class ShopCar extends Api |
|
|
$stock = Db::name('product')->where(['id' => $product_id])->value('stock');
|
|
|
if ($param['num'] > $stock) {
|
|
|
Db::name('shopcar')->where(['user_id' => $user_id])->where(['id' => $param['shop_id']])->update(['buy_num' => $stock]);
|
|
|
}else{
|
|
|
} else {
|
|
|
echo '1';
|
|
|
Db::name('shopcar')->where(['user_id' => $user_id])->where(['id' => $param['shop_id']])->update(['buy_num' => $param['num']]);
|
|
|
}
|
...
|
...
|
|