|
|
|
@ -176,21 +176,19 @@ class CouponRebateService implements CouponRebateServiceInterface |
|
|
|
* */ |
|
|
|
public function isCouponRebate($user_id) |
|
|
|
{ |
|
|
|
//获取SSDB上的活动信息
|
|
|
|
$ssdb = ApplicationContext::getContainer()->get(SSDBTask::class); |
|
|
|
$active = $ssdb->exec('hgetall',SsdbKeysPrefix::COUPON_REBATE_ACTIVITY); |
|
|
|
$coupon_ids = explode(',',$active['forward']); |
|
|
|
$res = Db::table('ims_system_coupon_user as u') |
|
|
|
->leftjoin('ims_system_coupon_user_receive as r', 'u.id', '=', 'r.system_coupon_user_id') |
|
|
|
->whereIn('r.system_coupon_user_id',$coupon_ids) |
|
|
|
->where([ |
|
|
|
['r.user_id', '=', $user_id], |
|
|
|
['r.receive_type', '=', 4], |
|
|
|
['u.active_type', '=', 2], |
|
|
|
]) |
|
|
|
->select('r.id') |
|
|
|
->first(); |
|
|
|
return $res; |
|
|
|
$activity = $ssdb->exec('hget', SsdbKeysPrefix::COUPON_REBATE_ACTIVITY ,'activity'); |
|
|
|
// ssdb 键值
|
|
|
|
$ssdbKey = 'activity_'.$activity.'_user_'.$user_id; |
|
|
|
|
|
|
|
// 判断是否已全部领取过
|
|
|
|
$userReceive = $ssdb->exec('hget', SsdbKeysPrefix::COUPON_REBATE_RECEIVE,$ssdbKey); |
|
|
|
if($userReceive === false || is_null($userReceive)){ |
|
|
|
return false; |
|
|
|
}else{ |
|
|
|
return $userReceive; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/* |
|
|
|
@ -201,6 +199,7 @@ class CouponRebateService implements CouponRebateServiceInterface |
|
|
|
//获取SSDB上的活动信息
|
|
|
|
$ssdb = ApplicationContext::getContainer()->get(SSDBTask::class); |
|
|
|
$active = $ssdb->exec('hgetall',SsdbKeysPrefix::COUPON_REBATE_ACTIVITY); |
|
|
|
return $active; |
|
|
|
$coupon_ids = explode(',',$active['forward']); |
|
|
|
$time = time(); |
|
|
|
$res = Db::table('ims_system_coupon_user') |
|
|
|
@ -347,17 +346,13 @@ class CouponRebateService implements CouponRebateServiceInterface |
|
|
|
|
|
|
|
//添加领取记录到ssdb
|
|
|
|
$data = [ |
|
|
|
'msg', '领券', |
|
|
|
'order_id',$order_id, |
|
|
|
'user_id' , $coupon->user_id, |
|
|
|
'send_usr_id' , $coupon->send_user_id |
|
|
|
$order_id,$coupon->user_id, |
|
|
|
]; |
|
|
|
$ssdb->execWithoutTask('multi_hset', SsdbKeysPrefix::COUPON_REBATE_LIST, $data); |
|
|
|
$ssdb->execWithoutTask('multi_hset', SsdbKeysPrefix::COUPON_REBATE_LIST.$coupon->send_user_id, $data); |
|
|
|
// 提交
|
|
|
|
Db::commit(); |
|
|
|
} catch (\Exception $e) { |
|
|
|
// 回滚
|
|
|
|
Db::rollBack(); |
|
|
|
//写入日志文件
|
|
|
|
$log_Data = array(); |
|
|
|
$log_Data['name'] = '返券'; |
|
|
|
$log_Data['order_id'] = $order_id; |
|
|
|
@ -366,6 +361,8 @@ class CouponRebateService implements CouponRebateServiceInterface |
|
|
|
LogLabel::COUPON_LOG, |
|
|
|
$log_Data |
|
|
|
); |
|
|
|
// 回滚
|
|
|
|
Db::rollBack(); |
|
|
|
} |
|
|
|
} |
|
|
|
return true; |
|
|
|
|