Browse Source

Merge branch 'develop' of http://120.24.33.109:11081/hyzjshwo/lanzu_api_hyperf into develop

* 'develop' of http://120.24.33.109:11081/hyzjshwo/lanzu_api_hyperf:
  no message
  可领优惠券加渠道
  差缺补漏
master
Mike 6 years ago
parent
commit
d455ad65e9
  1. 27
      app/Controller/CouponController.php

27
app/Controller/CouponController.php

@ -63,13 +63,18 @@ class CouponController extends BaseController
// 当前用户可领的优惠券ID // 当前用户可领的优惠券ID
$couponIds = array_diff($c_ids, $cr_ids); $couponIds = array_diff($c_ids, $cr_ids);
$c = Db::table('ims_system_coupon_user as u')
->where([
$whereC = [
['u.end_time','>',$nowTime], ['u.end_time','>',$nowTime],
['u.start_time','<=',$nowTime], ['u.start_time','<=',$nowTime],
['type.receive_type','=',$receive_type],
['u.status','=',1], ['u.status','=',1],
])
];
if (env('SUB_CHANNEL') == 1) {
array_push($whereC, ['type.receive_type','=',$receive_type]);
}
$c = Db::table('ims_system_coupon_user as u')
->where($whereC)
->join('ims_system_coupon_user_receivetype as type', 'u.id', '=', 'type.system_coupon_user_id') ->join('ims_system_coupon_user_receivetype as type', 'u.id', '=', 'type.system_coupon_user_id')
->whereRaw('u.inventory_use <= u.inventory and u.inventory-u.inventory_use > type.one_receive_number') ->whereRaw('u.inventory_use <= u.inventory and u.inventory-u.inventory_use > type.one_receive_number')
// ->whereIn('u.id',$c_ids) // ->whereIn('u.id',$c_ids)
@ -136,12 +141,16 @@ class CouponController extends BaseController
//$cps = Coupon::whereIn('id', $ids)->sharedLock()->get(); //$cps = Coupon::whereIn('id', $ids)->sharedLock()->get();
foreach ($cps as $key => $cp) { foreach ($cps as $key => $cp) {
$crt = CouponUserRecType::where(
[
$where = [
'system_coupon_user_id' => $cp->id, 'system_coupon_user_id' => $cp->id,
'receive_type' => $receiveType
]
)->first();
];
if (env('SUB_CHANNEL') == 1) {
$where['receive_type'] = $receiveType;
}
$crt = CouponUserRecType::where($where)->first();
$cr = new CouponRec; $cr = new CouponRec;
$cr->user_id = $userId; $cr->user_id = $userId;

Loading…
Cancel
Save