diff --git a/app/Service/CouponRebateService.php b/app/Service/CouponRebateService.php index c31cf19..be0225a 100644 --- a/app/Service/CouponRebateService.php +++ b/app/Service/CouponRebateService.php @@ -64,14 +64,13 @@ class CouponRebateService implements CouponRebateServiceInterface }else{ $ids = $idsData; } - + if(count($ids) > 0){ try{ Db::transaction( function() use ($ids,$receiveType,$userId,$sendUserId,$phone,$now,&$result,&$errorData,&$receiveSsdb) { $success = []; $fail = []; - $isr = []; //读写锁,完全控制,性能低 $coupons = Coupon::whereIn('id', $ids)->lockForUpdate() @@ -128,14 +127,14 @@ class CouponRebateService implements CouponRebateServiceInterface $couponReceive->send_user_id = $sendUserId; $couponReceive->phone = $phone; - // if ( $couponReceive->save() && $coupon->save() ) { - // $success[] = $coupon; - // $receiveSsdb[] = $coupon->id;; - // } + if ( $couponReceive->save() && $coupon->save() ) { + $success[] = $coupon; + $receiveSsdb[] = $coupon->id;; + } }else{ $fail[] = $coupon; $receiveSsdb[] = $coupon->id; - $result['status'] = 2; + $result['status'] = 3; $result['coupon_text'] = '您已领取!赶快去下单吧~'; $errorData['msg'] = '用户已经领取了优惠券';