|
|
@ -36,7 +36,7 @@ class CouponRebateService implements CouponRebateServiceInterface |
|
|
$sendUserId = $params["send_user_id"]; |
|
|
$sendUserId = $params["send_user_id"]; |
|
|
$phone = $params["phone"]; |
|
|
$phone = $params["phone"]; |
|
|
$now = time(); |
|
|
$now = time(); |
|
|
$ids = is_array($ids) ? $ids : explode(',',$ids); |
|
|
|
|
|
|
|
|
$idsData = is_array($ids) ? $ids : explode(',',$ids); |
|
|
|
|
|
|
|
|
// status: 0领取成功 >0领取失败
|
|
|
// status: 0领取成功 >0领取失败
|
|
|
$result = [ |
|
|
$result = [ |
|
|
@ -53,8 +53,19 @@ class CouponRebateService implements CouponRebateServiceInterface |
|
|
'phone' =>$phone |
|
|
'phone' =>$phone |
|
|
]; |
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
$ssdb = ApplicationContext::getContainer()->get(SSDBTask::class); |
|
|
$receiveSsdb = []; |
|
|
$receiveSsdb = []; |
|
|
|
|
|
|
|
|
|
|
|
// 判断是否已全部领取
|
|
|
|
|
|
$couponActivity = $ssdb->exec('get', SsdbKeysPrefix::COUPON_REBATE_ACTIVITY); |
|
|
|
|
|
$userReceiveCouponIds = $ssdb->exec('hgetall', SsdbKeysPrefix::COUPON_REBATE_FORWARD . $couponActivity); |
|
|
|
|
|
if($userReceiveCouponIds !== false){ |
|
|
|
|
|
$ids = array_diff($idsData, $userReceiveCouponIds); |
|
|
|
|
|
}else{ |
|
|
|
|
|
$ids = $idsData; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(count($ids) > 0){ |
|
|
try{ |
|
|
try{ |
|
|
Db::transaction( function() use ($ids,$receiveType,$userId,$sendUserId,$phone,$now,&$result,&$errorData,&$receiveSsdb) { |
|
|
Db::transaction( function() use ($ids,$receiveType,$userId,$sendUserId,$phone,$now,&$result,&$errorData,&$receiveSsdb) { |
|
|
|
|
|
|
|
|
@ -168,6 +179,7 @@ class CouponRebateService implements CouponRebateServiceInterface |
|
|
$errorData |
|
|
$errorData |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if(count($receiveSsdb) > 0){ |
|
|
if(count($receiveSsdb) > 0){ |
|
|
$saveSsdb = []; |
|
|
$saveSsdb = []; |
|
|
foreach($receiveSsdb as $kssdb => $vssdb){ |
|
|
foreach($receiveSsdb as $kssdb => $vssdb){ |
|
|
@ -175,7 +187,6 @@ class CouponRebateService implements CouponRebateServiceInterface |
|
|
$saveSsdb[] = $vssdb; |
|
|
$saveSsdb[] = $vssdb; |
|
|
} |
|
|
} |
|
|
// 记录到ssdb
|
|
|
// 记录到ssdb
|
|
|
$ssdb = ApplicationContext::getContainer()->get(SSDBTask::class); |
|
|
|
|
|
if(false === $ssdb->exec('multi_hset',SsdbKeysPrefix::COUPON_REBATE_RECEIVE.$userId,$saveSsdb)){ |
|
|
if(false === $ssdb->exec('multi_hset',SsdbKeysPrefix::COUPON_REBATE_RECEIVE.$userId,$saveSsdb)){ |
|
|
$errorData['msg'] = '记录领取优惠券到ssdb失败'; |
|
|
$errorData['msg'] = '记录领取优惠券到ssdb失败'; |
|
|
$this->log->event( |
|
|
$this->log->event( |
|
|
@ -184,6 +195,11 @@ class CouponRebateService implements CouponRebateServiceInterface |
|
|
); |
|
|
); |
|
|
}; |
|
|
}; |
|
|
} |
|
|
} |
|
|
|
|
|
}else{ |
|
|
|
|
|
$result['status'] = 2; |
|
|
|
|
|
$result['coupon_text'] = '您已领取!赶快去下单吧~'; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return $result; |
|
|
return $result; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|