|
|
@ -161,6 +161,13 @@ class CouponRebateService implements CouponRebateServiceInterface |
|
|
$result['coupon_text'] = '恭喜您领取成功!'; |
|
|
$result['coupon_text'] = '恭喜您领取成功!'; |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
|
|
|
} catch (Exception $e){ |
|
|
|
|
|
$errorData['msg'] = $e->getMessage(); |
|
|
|
|
|
$this->log->event( |
|
|
|
|
|
LogLabel::COUPON_LOG, |
|
|
|
|
|
$errorData |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
if(count($receiveSsdb) > 0){ |
|
|
if(count($receiveSsdb) > 0){ |
|
|
$saveSsdb = []; |
|
|
$saveSsdb = []; |
|
|
foreach($receiveSsdb as $kssdb => $vssdb){ |
|
|
foreach($receiveSsdb as $kssdb => $vssdb){ |
|
|
@ -186,11 +193,11 @@ class CouponRebateService implements CouponRebateServiceInterface |
|
|
public function isCouponRebate($user_id) |
|
|
public function isCouponRebate($user_id) |
|
|
{ |
|
|
{ |
|
|
$res = Db::table('ims_system_coupon_user as u') |
|
|
$res = Db::table('ims_system_coupon_user as u') |
|
|
->leftjoin('ims_system_coupon_user_receive as r','u.id','=','r.system_coupon_user_id') |
|
|
|
|
|
|
|
|
->leftjoin('ims_system_coupon_user_receive as r', 'u.id', '=', 'r.system_coupon_user_id') |
|
|
->where([ |
|
|
->where([ |
|
|
['r.user_id' ,'=', $user_id], |
|
|
|
|
|
['r.receive_type','=', 4], |
|
|
|
|
|
['u.active_type' ,'=', 2], |
|
|
|
|
|
|
|
|
['r.user_id', '=', $user_id], |
|
|
|
|
|
['r.receive_type', '=', 4], |
|
|
|
|
|
['u.active_type', '=', 2], |
|
|
]) |
|
|
]) |
|
|
->select('r.id') |
|
|
->select('r.id') |
|
|
->first(); |
|
|
->first(); |
|
|
@ -205,13 +212,13 @@ class CouponRebateService implements CouponRebateServiceInterface |
|
|
$time = time(); |
|
|
$time = time(); |
|
|
$res = Db::table('ims_system_coupon_user') |
|
|
$res = Db::table('ims_system_coupon_user') |
|
|
->where([ |
|
|
->where([ |
|
|
['status' ,'=', 1], |
|
|
|
|
|
['active_type' ,'=', 2], |
|
|
|
|
|
['start_time' ,'<=', $time], |
|
|
|
|
|
['end_time' ,'>', $time], |
|
|
|
|
|
|
|
|
['status', '=', 1], |
|
|
|
|
|
['active_type', '=', 2], |
|
|
|
|
|
['start_time', '<=', $time], |
|
|
|
|
|
['end_time', '>', $time], |
|
|
]) |
|
|
]) |
|
|
->whereRaw('inventory > inventory_use') |
|
|
->whereRaw('inventory > inventory_use') |
|
|
->orderBy('addtime','desc') |
|
|
|
|
|
|
|
|
->orderBy('addtime', 'desc') |
|
|
->get(); |
|
|
->get(); |
|
|
return $res; |
|
|
return $res; |
|
|
} |
|
|
} |
|
|
@ -221,7 +228,7 @@ class CouponRebateService implements CouponRebateServiceInterface |
|
|
* 领取优惠券 COUPON_REBATE_FORWARD 可多张 |
|
|
* 领取优惠券 COUPON_REBATE_FORWARD 可多张 |
|
|
* 返还优惠券 COUPON_REBATE_REPAY 只一张 |
|
|
* 返还优惠券 COUPON_REBATE_REPAY 只一张 |
|
|
*/ |
|
|
*/ |
|
|
public function tieCouponActive($couponActivity,$couponForward,$couponRepay) |
|
|
|
|
|
|
|
|
public function tieCouponActive($couponActivity, $couponForward, $couponRepay) |
|
|
{ |
|
|
{ |
|
|
$result = [ |
|
|
$result = [ |
|
|
'forward' => true, |
|
|
'forward' => true, |
|
|
@ -229,17 +236,17 @@ class CouponRebateService implements CouponRebateServiceInterface |
|
|
]; |
|
|
]; |
|
|
|
|
|
|
|
|
$ssdb = ApplicationContext::getContainer()->get(SSDBTask::class); |
|
|
$ssdb = ApplicationContext::getContainer()->get(SSDBTask::class); |
|
|
$rrss1 = $ssdb->exec('hgetall',SsdbKeysPrefix::COUPON_REBATE_FORWARD.$couponActivity); |
|
|
|
|
|
$rrss2 = $ssdb->exec('get',SsdbKeysPrefix::COUPON_REBATE_REPAY.$couponActivity); |
|
|
|
|
|
return [$rrss1,$rrss2]; |
|
|
|
|
|
|
|
|
$rrss1 = $ssdb->exec('hgetall', SsdbKeysPrefix::COUPON_REBATE_FORWARD . $couponActivity); |
|
|
|
|
|
$rrss2 = $ssdb->exec('get', SsdbKeysPrefix::COUPON_REBATE_REPAY . $couponActivity); |
|
|
|
|
|
return [$rrss1, $rrss2]; |
|
|
// 记录领取类型优惠券
|
|
|
// 记录领取类型优惠券
|
|
|
$forwardData = []; |
|
|
$forwardData = []; |
|
|
foreach($couponForward as $kForward => $vForward){ |
|
|
|
|
|
|
|
|
foreach ($couponForward as $kForward => $vForward) { |
|
|
$forwardData[] = $kForward; |
|
|
$forwardData[] = $kForward; |
|
|
$forwardData[] = $vForward; |
|
|
$forwardData[] = $vForward; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if(false === $ssdb->exec('multi_hset',SsdbKeysPrefix::COUPON_REBATE_FORWARD.$couponActivity,$forwardData)){ |
|
|
|
|
|
|
|
|
if (false === $ssdb->exec('multi_hset', SsdbKeysPrefix::COUPON_REBATE_FORWARD . $couponActivity, $forwardData)) { |
|
|
|
|
|
|
|
|
$this->log->event( |
|
|
$this->log->event( |
|
|
LogLabel::COUPON_LOG, |
|
|
LogLabel::COUPON_LOG, |
|
|
@ -253,7 +260,7 @@ class CouponRebateService implements CouponRebateServiceInterface |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
// 记录返还类型优惠券
|
|
|
// 记录返还类型优惠券
|
|
|
if(false === $ssdb->exec('set',SsdbKeysPrefix::COUPON_REBATE_REPAY.$couponActivity,$couponRepay)){ |
|
|
|
|
|
|
|
|
if (false === $ssdb->exec('set', SsdbKeysPrefix::COUPON_REBATE_REPAY . $couponActivity, $couponRepay)) { |
|
|
|
|
|
|
|
|
$this->log->event( |
|
|
$this->log->event( |
|
|
LogLabel::COUPON_LOG, |
|
|
LogLabel::COUPON_LOG, |
|
|
@ -344,4 +351,5 @@ class CouponRebateService implements CouponRebateServiceInterface |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return '返券成功'; |
|
|
return '返券成功'; |
|
|
}} |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
} |