|
|
|
@ -100,10 +100,17 @@ class CouponController extends BaseController |
|
|
|
$test = $this->request->input("test", 0); |
|
|
|
|
|
|
|
$ids = explode(',', $ids); |
|
|
|
$cps = Coupon::whereIn('id', $ids)->get(); |
|
|
|
$now = time(); |
|
|
|
$success = []; |
|
|
|
$fail = []; |
|
|
|
|
|
|
|
|
|
|
|
Db::transaction(function () use ($ids,$receiveType,$userId,&$success,&$fail,$test) { |
|
|
|
//读写锁,完全控制,性能底
|
|
|
|
$cps = Coupon::whereIn('id', $ids)->lockForUpdate()->get(); |
|
|
|
//写锁,可能在高并发下,读取到脏数据,写入可能有超发情况
|
|
|
|
//$cps = Coupon::whereIn('id', $ids)->sharedLock()->get();
|
|
|
|
|
|
|
|
foreach ($cps as $key => $cp) { |
|
|
|
$crt = CouponUserRecType::where( |
|
|
|
[ |
|
|
|
@ -140,6 +147,7 @@ class CouponController extends BaseController |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
return $this->success([ |
|
|
|
'success' => $success, |
|
|
|
|