发放购买服务包的关联优惠卷修改
This commit is contained in:
@@ -68,14 +68,16 @@ class CouponService extends BaseService
|
||||
}
|
||||
|
||||
// 判断该优惠卷过期时间
|
||||
if ($coupon['valid_type'] == 1){
|
||||
// 绝对时效
|
||||
$valid_end_time = strtotime($coupon['valid_end_time']);
|
||||
if (!empty($coupon['valid_type'])){
|
||||
if ($coupon['valid_type'] == 1){
|
||||
// 绝对时效
|
||||
$valid_end_time = strtotime($coupon['valid_end_time']);
|
||||
|
||||
$date = time() + 60 * 10;
|
||||
if ($valid_end_time < $date){
|
||||
// 超出结束使用时间
|
||||
return true;
|
||||
$date = time() + 60 * 10;
|
||||
if ($valid_end_time < $date){
|
||||
// 超出结束使用时间
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,18 +133,20 @@ class CouponService extends BaseService
|
||||
}
|
||||
|
||||
// 添加优惠卷过期队列
|
||||
$valid_end_time = strtotime($user_coupon->valid_end_time);
|
||||
if (!empty($user_coupon['valid_start_time']) && !empty($user_coupon['valid_end_time'])){
|
||||
$valid_end_time = strtotime($user_coupon['valid_start_time']);
|
||||
|
||||
$data = array();
|
||||
$data['user_coupon_id'] = $user_coupon['user_coupon_id'];
|
||||
$data = array();
|
||||
$data['user_coupon_id'] = $user_coupon['user_coupon_id'];
|
||||
|
||||
$time = $valid_end_time - time();
|
||||
$message = new UserCouponExpiredDelayDirectProducer($data);
|
||||
$message->setDelayMs(1000 * $time);
|
||||
$producer = $this->container->get(Producer::class);
|
||||
$res = $producer->produce($message);
|
||||
if (!$res) {
|
||||
return false;
|
||||
$time = $valid_end_time - time();
|
||||
$message = new UserCouponExpiredDelayDirectProducer($data);
|
||||
$message->setDelayMs(1000 * $time);
|
||||
$producer = $this->container->get(Producer::class);
|
||||
$res = $producer->produce($message);
|
||||
if (!$res) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}catch (\Throwable $e){
|
||||
Log::getInstance("CouponService-GrantUserCoupon")->error($e->getMessage());
|
||||
@@ -151,22 +155,24 @@ class CouponService extends BaseService
|
||||
|
||||
try {
|
||||
// 添加优惠卷即将过期提醒队列
|
||||
$time = floor($time * 0.75);
|
||||
if (!empty($user_coupon['valid_start_time']) && !empty($user_coupon['valid_end_time']) && isset($time)){
|
||||
$time = floor($time * 0.75);
|
||||
|
||||
// 时间低于5小时,不进行过期提醒
|
||||
if ($time > 60 * 60 * 5){
|
||||
$message = new UserCouponExpiredNoticeDelayDirectProducer($data);
|
||||
$message->setDelayMs(1000 * $time);
|
||||
$producer = $this->container->get(Producer::class);
|
||||
$res = $producer->produce($message);
|
||||
if (!$res) {
|
||||
Log::getInstance("CouponService-GrantUserCoupon")->error("添加优惠卷即将过期提醒队列");
|
||||
// 时间低于5小时,不进行过期提醒
|
||||
if ($time > 60 * 60 * 5){
|
||||
$message = new UserCouponExpiredNoticeDelayDirectProducer($data);
|
||||
$message->setDelayMs(1000 * $time);
|
||||
$producer = $this->container->get(Producer::class);
|
||||
$res = $producer->produce($message);
|
||||
if (!$res) {
|
||||
Log::getInstance("CouponService-GrantUserCoupon")->error("添加优惠卷即将过期提醒队列");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 通知-患者-优惠卷发放
|
||||
$MessagePush = new MessagePush($user_id);
|
||||
$MessagePush->patientDistributeCoupon($coupon['coupon_name']);
|
||||
// 通知-患者-优惠卷发放
|
||||
$MessagePush = new MessagePush($user_id);
|
||||
$MessagePush->patientDistributeCoupon($coupon['coupon_name']);
|
||||
}
|
||||
}catch (\Throwable $e){
|
||||
Log::getInstance("CouponService-GrantUserCoupon")->error($e->getMessage());
|
||||
}
|
||||
@@ -202,9 +208,11 @@ class CouponService extends BaseService
|
||||
/**
|
||||
* 发放购买服务包的关联优惠卷
|
||||
* @param string $user_id 用户id
|
||||
* @param string $start_time 开始使用时间
|
||||
* @param string $finish_time 结束有效时间
|
||||
* @return bool
|
||||
*/
|
||||
public function GrantBuyOrderServicePackageCoupon(string $user_id): bool
|
||||
public function GrantBuyOrderServicePackageCoupon(string $user_id,string $start_time,string $finish_time): bool
|
||||
{
|
||||
// 获取购买服务包的用户可领取的优惠卷列表
|
||||
$coupon = Coupon::getOrderServicePackageCouponList();
|
||||
@@ -219,6 +227,17 @@ class CouponService extends BaseService
|
||||
// 发放失败
|
||||
return false;
|
||||
}
|
||||
|
||||
// 增加优惠卷有效期
|
||||
$params = array();
|
||||
$params['user_id'] = $user_id;
|
||||
$params['coupon_id'] = $value['coupon_id'];
|
||||
$params['user_coupon_status'] = 0;
|
||||
|
||||
$data = array();
|
||||
$data['valid_start_time'] = $start_time;
|
||||
$data['valid_end_time'] = $finish_time;
|
||||
UserCoupon::edit($params,$data);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user