From 245397dfa79730cc2f9b61b9c51757c27685ec6a Mon Sep 17 00:00:00 2001 From: wucongxing8150 <815046773@qq.com> Date: Tue, 16 Apr 2024 17:57:24 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=9E=E9=80=80=E4=BC=98=E6=83=A0=E5=8D=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Services/CouponService.php | 65 +++++++++++------------------- app/Services/UserDoctorService.php | 2 +- 2 files changed, 25 insertions(+), 42 deletions(-) diff --git a/app/Services/CouponService.php b/app/Services/CouponService.php index d9a0d57..cc31006 100644 --- a/app/Services/CouponService.php +++ b/app/Services/CouponService.php @@ -133,20 +133,18 @@ class CouponService extends BaseService } // 添加优惠卷过期队列 - if (!empty($user_coupon['valid_start_time']) && !empty($user_coupon['valid_end_time'])){ - $valid_end_time = strtotime($user_coupon['valid_start_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()); @@ -155,24 +153,22 @@ class CouponService extends BaseService try { // 添加优惠卷即将过期提醒队列 - if (!empty($user_coupon['valid_start_time']) && !empty($user_coupon['valid_end_time']) && isset($time)){ - $time = floor($time * 0.75); + $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()); } @@ -208,11 +204,9 @@ 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,string $start_time,string $finish_time): bool + public function GrantBuyOrderServicePackageCoupon(string $user_id): bool { // 获取购买服务包的用户可领取的优惠卷列表 $coupon = Coupon::getOrderServicePackageCouponList(); @@ -227,17 +221,6 @@ 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; diff --git a/app/Services/UserDoctorService.php b/app/Services/UserDoctorService.php index 896d2a0..cf4fa19 100644 --- a/app/Services/UserDoctorService.php +++ b/app/Services/UserDoctorService.php @@ -1911,7 +1911,7 @@ class UserDoctorService extends BaseService if (count($order_service_package_inquiry) <= 1){ // 发放优惠卷 $CouponService = new CouponService(); - $res = $CouponService->GrantBuyOrderServicePackageCoupon($order_inquiry['user_id'],$start_time,$finish_time); + $res = $CouponService->GrantBuyOrderServicePackageCoupon($order_inquiry['user_id']); if (!$res) { Db::rollBack(); return fail(HttpEnumCode::HTTP_ERROR, "接诊失败");