This commit is contained in:
mkm 2024-06-29 15:14:56 +08:00
commit 594a31e93c
3 changed files with 27 additions and 10 deletions

View File

@ -48,7 +48,11 @@ class CartController extends BaseApiController
return $this->fail('库存数量不足');
}
if ($result) {
$res = CartLogic::edit($params);
if(isset($params['type']) && $params['type'] == 1){
$res = CartLogic::add($params);
}else{
$res = CartLogic::edit($params);
}
} else {
$res = CartLogic::add($params);
}

View File

@ -33,16 +33,29 @@ class CartLogic extends BaseLogic
}
Db::startTrans();
try {
$cart = Cart::create([
//check
$check = Cart::where([
'uid' => $params['uid'],
'type' => $params['type']??'',
'store_id' => $params['store_id'],
'product_id' => $params['product_id'],
'store_id' => $params['store_id']??0,
'staff_id' => $params['staff_id']??0,
'product_attr_unique' => '',
'cart_num' => $params['cart_num'],
'is_new' => $params['is_new']??0,
]);
'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([
'uid' => $params['uid'],
'type' => $params['type']??'',
'product_id' => $params['product_id'],
'store_id' => $params['store_id']??0,
'staff_id' => $params['staff_id']??0,
'product_attr_unique' => '',
'cart_num' => $params['cart_num'],
'is_new' => $params['is_new']??0,
]);
}
StoreProductLog::create([
'type'=>'cart',
'uid' => $params['uid'],

View File

@ -66,7 +66,7 @@ class PayNotifyLogic extends BaseLogic
public static function balancePay($orderSn, $extra = [])
{
$order = StoreOrder::where('order_id', $orderSn)->findOrEmpty();
self::afterPay($order);d(444);
self::afterPay($order);
$user = User::where('id', $order['uid'])->find();
if ($user['now_money'] < $order['pay_price']) {
throw new \Exception('余额不足');