作者 王智

222

... ... @@ -65,10 +65,8 @@ 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]);
}
... ...