购物车逻辑兼容
This commit is contained in:
parent
f96538a4b4
commit
af4af0d1ed
@ -48,7 +48,11 @@ class CartController extends BaseApiController
|
|||||||
return $this->fail('库存数量不足');
|
return $this->fail('库存数量不足');
|
||||||
}
|
}
|
||||||
if ($result) {
|
if ($result) {
|
||||||
|
if(isset($params['type']) && $params['type'] == 1){
|
||||||
|
$res = CartLogic::add($params);
|
||||||
|
}else{
|
||||||
$res = CartLogic::edit($params);
|
$res = CartLogic::edit($params);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$res = CartLogic::add($params);
|
$res = CartLogic::add($params);
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,18 @@ class CartLogic extends BaseLogic
|
|||||||
}
|
}
|
||||||
Db::startTrans();
|
Db::startTrans();
|
||||||
try {
|
try {
|
||||||
|
//check
|
||||||
|
$check = Cart::where([
|
||||||
|
'uid' => $params['uid'],
|
||||||
|
'store_id' => $params['store_id'],
|
||||||
|
'product_id' => $params['product_id'],
|
||||||
|
'is_pay'=>0
|
||||||
|
])->field('id')->find();
|
||||||
|
if($check){
|
||||||
|
Cart::where('id',$check['id'])->inc('cart_num',$params['cart_num'])
|
||||||
|
->update();
|
||||||
|
$cart['id'] = $check['id'];
|
||||||
|
}else{
|
||||||
$cart = Cart::create([
|
$cart = Cart::create([
|
||||||
'uid' => $params['uid'],
|
'uid' => $params['uid'],
|
||||||
'type' => $params['type']??'',
|
'type' => $params['type']??'',
|
||||||
@ -43,6 +55,7 @@ class CartLogic extends BaseLogic
|
|||||||
'cart_num' => $params['cart_num'],
|
'cart_num' => $params['cart_num'],
|
||||||
'is_new' => $params['is_new']??0,
|
'is_new' => $params['is_new']??0,
|
||||||
]);
|
]);
|
||||||
|
}
|
||||||
StoreProductLog::create([
|
StoreProductLog::create([
|
||||||
'type'=>'cart',
|
'type'=>'cart',
|
||||||
'uid' => $params['uid'],
|
'uid' => $params['uid'],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user