修改消息推送

This commit is contained in:
wucongxing 2023-04-24 18:28:23 +08:00
parent 74b7746d88
commit 8215609eed
3 changed files with 159 additions and 188 deletions

View File

@ -45,18 +45,10 @@ class ReportPreProductOrderCommand extends HyperfCommand
{ {
$this->line("开始"); $this->line("开始");
try { // 获取可上报商品订单
// 获取可上报商品订单 $order_product_ids = $this->getExecProductOrder();
$order_product_ids = $this->getExecProductOrder(); if (empty($order_product_ids)){
if (empty($order_product_ids)){ $this->line("结束,无可上报的商品订单");
$this->line("结束,无可上报的商品订单");
return;
}
// 获取缓存
$redis = $this->container->get(Redis::class);
} catch (\Exception $e) {
$this->line("错误:" . $e->getMessage());
return; return;
} }

View File

@ -559,13 +559,11 @@ class CallBackController extends AbstractController
$params = array(); $params = array();
$params['patient_id'] = $order_product['patient_id']; $params['patient_id'] = $order_product['patient_id'];
$user_patient = UserPatient::getOne($params); $user_patient = UserPatient::getOne($params);
if (empty($user_patient)) { if (!empty($user_patient)) {
Log::getInstance()->error("微信退款回调处理成功,推送消息失败:推送用户数据错误"); // 发送站内、订阅、短信消息-药品订单退款成功
$MessagePush = new MessagePush($user_patient['user_id']);
$MessagePush->refundProductSuccess($order_product['order_product_id']);
} }
// 发送站内、订阅、短信消息-药品订单退款成功
$MessagePush = new MessagePush($user_patient['user_id']);
$MessagePush->refundProductSuccess($order_product['order_product_id']);
} catch (\Exception $e) { } catch (\Exception $e) {
// 验证失败 // 验证失败
Log::getInstance()->error("微信退款回调处理成功,推送消息失败:" . $e->getMessage()); Log::getInstance()->error("微信退款回调处理成功,推送消息失败:" . $e->getMessage());

View File

@ -64,11 +64,11 @@ class MessagePush extends BaseService
* 快速/购药的服务5分钟未接诊 * 快速/购药的服务5分钟未接诊
* 公益/专家24小时未接诊 * 公益/专家24小时未接诊
* 站内、订阅 * 站内、订阅
* @return bool * @return void
* @throws ContainerExceptionInterface * @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface * @throws NotFoundExceptionInterface
*/ */
public function patientNoInquiry(): bool public function patientNoInquiry(): void
{ {
try { try {
// 站内 // 站内
@ -103,7 +103,7 @@ class MessagePush extends BaseService
$producer = ApplicationContext::getContainer()->get(Producer::class); $producer = ApplicationContext::getContainer()->get(Producer::class);
$result = $producer->produce($message); $result = $producer->produce($message);
if (!$result) { if (!$result) {
throw new BusinessException("加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); Log::getInstance("MessagePush")->error("错误:" . json_encode($data,JSON_UNESCAPED_UNICODE));
} }
// 订阅 // 订阅
@ -112,7 +112,8 @@ class MessagePush extends BaseService
$params['doctor_id'] = $this->order_inquiry['doctor_id']; $params['doctor_id'] = $this->order_inquiry['doctor_id'];
$user_doctor = UserDoctor::getOne($params); $user_doctor = UserDoctor::getOne($params);
if (empty($user_doctor)){ if (empty($user_doctor)){
throw new BusinessException("加入推送队列失败:医生数据为空"); Log::getInstance("MessagePush")->error("错误:医生数据为空");
return;
} }
$sub_data = array(); $sub_data = array();
@ -135,13 +136,11 @@ class MessagePush extends BaseService
$producer = ApplicationContext::getContainer()->get(Producer::class); $producer = ApplicationContext::getContainer()->get(Producer::class);
$result = $producer->produce($message); $result = $producer->produce($message);
if (!$result) { if (!$result) {
throw new BusinessException("加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); Log::getInstance("MessagePush")->error("错误:" . json_encode($data,JSON_UNESCAPED_UNICODE));
} }
} catch (\Exception $e) { } catch (\Exception $e) {
throw new BusinessException("加入推送队列失败" . $e->getMessage()); Log::getInstance("MessagePush")->error("错误:" . $e->getMessage());
} }
return true;
} }
/** /**
@ -186,11 +185,11 @@ class MessagePush extends BaseService
/** /**
* 患者-通知患者医生已接诊 * 患者-通知患者医生已接诊
* 站内、订阅、短信 * 站内、订阅、短信
* @return bool * @return void
* @throws ContainerExceptionInterface * @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface * @throws NotFoundExceptionInterface
*/ */
public function patientAcceptedInquiry(): bool public function patientAcceptedInquiry(): void
{ {
try { try {
// 获取医生数据 // 获取医生数据
@ -198,7 +197,8 @@ class MessagePush extends BaseService
$params['doctor_id'] = $this->order_inquiry['doctor_id']; $params['doctor_id'] = $this->order_inquiry['doctor_id'];
$user_doctor = UserDoctor::getOne($params); $user_doctor = UserDoctor::getOne($params);
if (empty($user_doctor)){ if (empty($user_doctor)){
throw new BusinessException("加入推送队列失败:医生数据为空"); Log::getInstance("MessagePush")->error("错误:医生数据为空" );
return;
} }
// 站内 // 站内
@ -225,7 +225,7 @@ class MessagePush extends BaseService
$producer = ApplicationContext::getContainer()->get(Producer::class); $producer = ApplicationContext::getContainer()->get(Producer::class);
$result = $producer->produce($message); $result = $producer->produce($message);
if (!$result) { if (!$result) {
throw new BusinessException("加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE));
} }
// 订阅 // 订阅
@ -248,7 +248,7 @@ class MessagePush extends BaseService
$producer = ApplicationContext::getContainer()->get(Producer::class); $producer = ApplicationContext::getContainer()->get(Producer::class);
$result = $producer->produce($message); $result = $producer->produce($message);
if (!$result) { if (!$result) {
throw new BusinessException("加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE));
} }
// 短信 // 短信
@ -258,7 +258,7 @@ class MessagePush extends BaseService
$params['inquiry_mode'] = $this->order_inquiry['inquiry_mode']; $params['inquiry_mode'] = $this->order_inquiry['inquiry_mode'];
$system_inquiry_config = SystemInquiryConfig::getOne($params); $system_inquiry_config = SystemInquiryConfig::getOne($params);
if (empty($system_inquiry_config)) { if (empty($system_inquiry_config)) {
throw new BusinessException("加入推送队列失败:获取系统接诊配置失败"); Log::getInstance("MessagePush")->error("错误:获取系统接诊配置失败");
} }
$duration = $system_inquiry_config['duration']; $duration = $system_inquiry_config['duration'];
@ -285,23 +285,21 @@ class MessagePush extends BaseService
$producer = ApplicationContext::getContainer()->get(Producer::class); $producer = ApplicationContext::getContainer()->get(Producer::class);
$result = $producer->produce($message); $result = $producer->produce($message);
if (!$result) { if (!$result) {
throw new BusinessException("加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE));
} }
} catch (\Exception $e) { } catch (\Exception $e) {
throw new BusinessException("加入推送队列失败" . $e->getMessage()); Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . $e->getMessage());
} }
return true;
} }
/** /**
* 患者的问诊服务结束 * 患者的问诊服务结束
* 站内、订阅 * 站内、订阅
* @return bool * @return void
* @throws ContainerExceptionInterface * @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface * @throws NotFoundExceptionInterface
*/ */
public function patientInquiryFinish(): bool public function patientInquiryFinish(): void
{ {
try { try {
// 获取医生数据 // 获取医生数据
@ -309,7 +307,8 @@ class MessagePush extends BaseService
$params['doctor_id'] = $this->order_inquiry['doctor_id']; $params['doctor_id'] = $this->order_inquiry['doctor_id'];
$user_doctor = UserDoctor::getOne($params); $user_doctor = UserDoctor::getOne($params);
if (empty($user_doctor)){ if (empty($user_doctor)){
throw new BusinessException("加入推送队列失败:医生数据为空"); Log::getInstance("MessagePush")->error("错误:医生数据为空");
return;
} }
// 站内 // 站内
@ -339,7 +338,7 @@ class MessagePush extends BaseService
$producer = ApplicationContext::getContainer()->get(Producer::class); $producer = ApplicationContext::getContainer()->get(Producer::class);
$result = $producer->produce($message); $result = $producer->produce($message);
if (!$result) { if (!$result) {
throw new BusinessException("加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE));
} }
// 订阅 // 订阅
@ -362,23 +361,21 @@ class MessagePush extends BaseService
$producer = ApplicationContext::getContainer()->get(Producer::class); $producer = ApplicationContext::getContainer()->get(Producer::class);
$result = $producer->produce($message); $result = $producer->produce($message);
if (!$result) { if (!$result) {
throw new BusinessException("加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE));
} }
} catch (\Exception $e) { } catch (\Exception $e) {
throw new BusinessException("加入推送队列失败" . $e->getMessage()); Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . $e->getMessage());
} }
return true;
} }
/** /**
* 患者-处方被药师审核通过 * 患者-处方被药师审核通过
* 站内、短信 * 站内、短信
* @return bool * @return void
* @throws ContainerExceptionInterface * @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface * @throws NotFoundExceptionInterface
*/ */
public function patientPrescriptionVerifyPass(): bool public function patientPrescriptionVerifyPass(): void
{ {
try { try {
// 获取医生数据 // 获取医生数据
@ -386,7 +383,8 @@ class MessagePush extends BaseService
$params['doctor_id'] = $this->order_inquiry['doctor_id']; $params['doctor_id'] = $this->order_inquiry['doctor_id'];
$user_doctor = UserDoctor::getOne($params); $user_doctor = UserDoctor::getOne($params);
if (empty($user_doctor)){ if (empty($user_doctor)){
throw new BusinessException("加入推送队列失败:医生数据为空"); Log::getInstance("MessagePush")->error("错误:医生数据为空");
return ;
} }
// 站内 // 站内
@ -398,7 +396,8 @@ class MessagePush extends BaseService
$params['pharmacist_audit_status'] = 1; $params['pharmacist_audit_status'] = 1;
$order_prescription = OrderPrescription::getOne($params); $order_prescription = OrderPrescription::getOne($params);
if (empty($order_prescription)) { if (empty($order_prescription)) {
throw new BusinessException("加入推送队列失败:处方数据为空"); Log::getInstance("MessagePush")->error("错误:处方数据为空");
return ;
} }
$data = array(); $data = array();
@ -421,7 +420,7 @@ class MessagePush extends BaseService
$producer = ApplicationContext::getContainer()->get(Producer::class); $producer = ApplicationContext::getContainer()->get(Producer::class);
$result = $producer->produce($message); $result = $producer->produce($message);
if (!$result) { if (!$result) {
throw new BusinessException("加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE));
} }
// 短信 // 短信
@ -435,28 +434,25 @@ class MessagePush extends BaseService
$template_param['name'] = $user_doctor['user_name']; $template_param['name'] = $user_doctor['user_name'];
$data['template_param'] = $template_param; $data['template_param'] = $template_param;
$message = new SendSmsMessageProducer($data); $message = new SendSmsMessageProducer($data);
$producer = ApplicationContext::getContainer()->get(Producer::class); $producer = ApplicationContext::getContainer()->get(Producer::class);
$result = $producer->produce($message); $result = $producer->produce($message);
if (!$result) { if (!$result) {
throw new BusinessException("加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE));
} }
} catch (\Exception $e) { } catch (\Exception $e) {
throw new BusinessException("加入推送队列失败" . $e->getMessage()); Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . $e->getMessage());
} }
return true;
} }
/** /**
* 患者-处方审核未通过 * 患者-处方审核未通过
* 站内 * 站内
* @return bool * @return void
* @throws ContainerExceptionInterface * @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface * @throws NotFoundExceptionInterface
*/ */
public function patientPrescriptionVerifyFail(): bool public function patientPrescriptionVerifyFail(): void
{ {
try { try {
// 获取医生数据 // 获取医生数据
@ -464,7 +460,8 @@ class MessagePush extends BaseService
$params['doctor_id'] = $this->order_inquiry['doctor_id']; $params['doctor_id'] = $this->order_inquiry['doctor_id'];
$user_doctor = UserDoctor::getOne($params); $user_doctor = UserDoctor::getOne($params);
if (empty($user_doctor)){ if (empty($user_doctor)){
throw new BusinessException("加入推送队列失败:医生数据为空"); Log::getInstance("MessagePush")->error("错误:医生数据为空");
return ;
} }
// 站内 // 站内
@ -482,24 +479,22 @@ class MessagePush extends BaseService
$producer = ApplicationContext::getContainer()->get(Producer::class); $producer = ApplicationContext::getContainer()->get(Producer::class);
$result = $producer->produce($message); $result = $producer->produce($message);
if (!$result) { if (!$result) {
throw new BusinessException("加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE));
} }
} catch (\Exception $e) { } catch (\Exception $e) {
throw new BusinessException("加入推送队列失败" . $e->getMessage()); Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . $e->getMessage());
} }
return true;
} }
/** /**
* 患者-优惠劵发放 * 患者-优惠劵发放
* 站内 * 站内
* @param string $coupon_name * @param string $coupon_name
* @return bool * @return void
* @throws ContainerExceptionInterface * @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface * @throws NotFoundExceptionInterface
*/ */
public function patientDistributeCoupon(string $coupon_name): bool public function patientDistributeCoupon(string $coupon_name): void
{ {
try { try {
$data = array(); $data = array();
@ -516,23 +511,21 @@ class MessagePush extends BaseService
$producer = ApplicationContext::getContainer()->get(Producer::class); $producer = ApplicationContext::getContainer()->get(Producer::class);
$result = $producer->produce($message); $result = $producer->produce($message);
if (!$result) { if (!$result) {
throw new BusinessException("加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE));
} }
} catch (\Exception $e) { } catch (\Exception $e) {
throw new BusinessException("加入推送队列失败" . $e->getMessage()); Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . $e->getMessage());
} }
return true;
} }
/** /**
* 优惠劵退还 * 优惠劵退还
* 站内 * 站内
* @return bool * @return void
* @throws ContainerExceptionInterface * @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface * @throws NotFoundExceptionInterface
*/ */
public function patientRefundCoupon(): bool public function patientRefundCoupon(): void
{ {
try { try {
$data = array(); $data = array();
@ -549,23 +542,21 @@ class MessagePush extends BaseService
$producer = ApplicationContext::getContainer()->get(Producer::class); $producer = ApplicationContext::getContainer()->get(Producer::class);
$result = $producer->produce($message); $result = $producer->produce($message);
if (!$result) { if (!$result) {
throw new BusinessException("加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE));
} }
} catch (\Exception $e) { } catch (\Exception $e) {
throw new BusinessException("加入推送队列失败" . $e->getMessage()); Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . $e->getMessage());
} }
return true;
} }
/** /**
* 优惠劵过期 * 优惠劵过期
* 站内 * 站内
* @return bool * @return void
* @throws ContainerExceptionInterface * @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface * @throws NotFoundExceptionInterface
*/ */
public function patientExpireCoupon(): bool public function patientExpireCoupon(): void
{ {
try { try {
$data = array(); $data = array();
@ -582,24 +573,22 @@ class MessagePush extends BaseService
$producer = ApplicationContext::getContainer()->get(Producer::class); $producer = ApplicationContext::getContainer()->get(Producer::class);
$result = $producer->produce($message); $result = $producer->produce($message);
if (!$result) { if (!$result) {
throw new BusinessException("加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE));
} }
} catch (\Exception $e) { } catch (\Exception $e) {
throw new BusinessException("加入推送队列失败" . $e->getMessage()); Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . $e->getMessage());
} }
return true;
} }
/** /**
* 患者-问诊服务退款成功 * 患者-问诊服务退款成功
* 站内、订阅、短信 * 站内、订阅、短信
* @param int $type 类型 1:已支付未接诊 2:已支付未成功分配医生 3:已支付未接诊患者取消订单 * @param int $type 类型 1:已支付未接诊 2:已支付未成功分配医生 3:已支付未接诊患者取消订单
* @return bool * @return void
* @throws ContainerExceptionInterface * @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface * @throws NotFoundExceptionInterface
*/ */
public function refundInquirySuccess(int $type): bool public function refundInquirySuccess(int $type): void
{ {
try { try {
if (!empty($this->order_inquiry['doctor_id'])){ if (!empty($this->order_inquiry['doctor_id'])){
@ -608,7 +597,8 @@ class MessagePush extends BaseService
$params['doctor_id'] = $this->order_inquiry['doctor_id']; $params['doctor_id'] = $this->order_inquiry['doctor_id'];
$user_doctor = UserDoctor::getOne($params); $user_doctor = UserDoctor::getOne($params);
if (empty($user_doctor)){ if (empty($user_doctor)){
throw new BusinessException("加入推送队列失败:医生数据为空"); Log::getInstance("MessagePush")->error("错误:医生数据为空");
return ;
} }
} }
@ -636,7 +626,8 @@ class MessagePush extends BaseService
$data['notice_title'] = "您咨询的【{$inquiry_type_string}】服务,平台 已退款成功"; $data['notice_title'] = "您咨询的【{$inquiry_type_string}】服务,平台 已退款成功";
$data['notice_content'] = "您已取消成功当前服务平台会在24小时内给您退还至原账户中带来的不便敬请谅解。"; $data['notice_content'] = "您已取消成功当前服务平台会在24小时内给您退还至原账户中带来的不便敬请谅解。";
}else{ }else{
throw new BusinessException("加入推送队列失败:类型错误"); Log::getInstance("MessagePush")->error("错误:类型错误");
return ;
} }
$data['link_type'] = 10;// 问诊订单详情 $data['link_type'] = 10;// 问诊订单详情
@ -649,7 +640,7 @@ class MessagePush extends BaseService
$producer = ApplicationContext::getContainer()->get(Producer::class); $producer = ApplicationContext::getContainer()->get(Producer::class);
$result = $producer->produce($message); $result = $producer->produce($message);
if (!$result) { if (!$result) {
throw new BusinessException("加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE));
} }
// 订阅 // 订阅
@ -663,7 +654,8 @@ class MessagePush extends BaseService
// 已支付未接诊患者取消订单 // 已支付未接诊患者取消订单
$thing4 = "用户主动取消"; $thing4 = "用户主动取消";
}else{ }else{
throw new BusinessException("加入推送队列失败:类型错误"); Log::getInstance("MessagePush")->error("错误:类型错误");
return ;
} }
$sub_data = array(); $sub_data = array();
@ -686,7 +678,7 @@ class MessagePush extends BaseService
$producer = ApplicationContext::getContainer()->get(Producer::class); $producer = ApplicationContext::getContainer()->get(Producer::class);
$result = $producer->produce($message); $result = $producer->produce($message);
if (!$result) { if (!$result) {
throw new BusinessException("加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE));
} }
// 短信 // 短信
@ -706,24 +698,22 @@ class MessagePush extends BaseService
$producer = ApplicationContext::getContainer()->get(Producer::class); $producer = ApplicationContext::getContainer()->get(Producer::class);
$result = $producer->produce($message); $result = $producer->produce($message);
if (!$result) { if (!$result) {
throw new BusinessException("加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE));
} }
} catch (\Exception $e) { } catch (\Exception $e) {
throw new BusinessException("加入推送队列失败" . $e->getMessage()); Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . $e->getMessage());
} }
return true;
} }
/** /**
* 患者-药品订单退款成功 * 患者-药品订单退款成功
* 站内、订阅、短信 * 站内、订阅、短信
* @param string $order_product_id * @param string $order_product_id
* @return bool * @return void
* @throws ContainerExceptionInterface * @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface * @throws NotFoundExceptionInterface
*/ */
public function refundProductSuccess(string $order_product_id): bool public function refundProductSuccess(string $order_product_id): void
{ {
try { try {
// 获取药品订单数据 // 获取药品订单数据
@ -731,7 +721,8 @@ class MessagePush extends BaseService
$params['order_product_id'] = $order_product_id; $params['order_product_id'] = $order_product_id;
$order_product = OrderProduct::getOne($params); $order_product = OrderProduct::getOne($params);
if (empty($order_product)){ if (empty($order_product)){
throw new BusinessException("加入推送队列失败:药品订单数据为空"); Log::getInstance("MessagePush")->error("错误:药品订单数据为空");
return ;
} }
// 获取药品订单商品数据 // 获取药品订单商品数据
@ -739,7 +730,8 @@ class MessagePush extends BaseService
$params['order_product_id'] = $order_product_id; $params['order_product_id'] = $order_product_id;
$order_product_item = OrderProductItem::getList($params); $order_product_item = OrderProductItem::getList($params);
if (empty($order_product_item)){ if (empty($order_product_item)){
throw new BusinessException("加入推送队列失败:商品订单列表数据为空"); Log::getInstance("MessagePush")->error("错误:商品订单列表数据为空");
return ;
} }
// 获取商品数据 // 获取商品数据
@ -749,7 +741,8 @@ class MessagePush extends BaseService
$params['product_id'] = $item['product_id']; $params['product_id'] = $item['product_id'];
$product = Product::getOne($params); $product = Product::getOne($params);
if (empty($product)){ if (empty($product)){
throw new BusinessException("加入推送队列失败:商品数据为空"); Log::getInstance("MessagePush")->error("错误:商品数据为空");
return ;
} }
$product_name_array[] = $product['common_name']; $product_name_array[] = $product['common_name'];
@ -777,7 +770,7 @@ class MessagePush extends BaseService
$producer = ApplicationContext::getContainer()->get(Producer::class); $producer = ApplicationContext::getContainer()->get(Producer::class);
$result = $producer->produce($message); $result = $producer->produce($message);
if (!$result) { if (!$result) {
throw new BusinessException("加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE));
} }
// 订阅 // 订阅
@ -806,7 +799,7 @@ class MessagePush extends BaseService
$producer = ApplicationContext::getContainer()->get(Producer::class); $producer = ApplicationContext::getContainer()->get(Producer::class);
$result = $producer->produce($message); $result = $producer->produce($message);
if (!$result) { if (!$result) {
throw new BusinessException("加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE));
} }
// 短信 // 短信
@ -822,18 +815,15 @@ class MessagePush extends BaseService
$template_param['status'] = productCancelReasonToString($order_product['cancel_reason']); $template_param['status'] = productCancelReasonToString($order_product['cancel_reason']);
$data['template_param'] = $template_param; $data['template_param'] = $template_param;
$message = new SendSmsMessageProducer($data); $message = new SendSmsMessageProducer($data);
$producer = ApplicationContext::getContainer()->get(Producer::class); $producer = ApplicationContext::getContainer()->get(Producer::class);
$result = $producer->produce($message); $result = $producer->produce($message);
if (!$result) { if (!$result) {
throw new BusinessException("加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE));
} }
} catch (\Exception $e) { } catch (\Exception $e) {
throw new BusinessException("加入推送队列失败" . $e->getMessage()); Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . $e->getMessage());
} }
return true;
} }
/** /**
@ -858,11 +848,11 @@ class MessagePush extends BaseService
* 药品已发货 * 药品已发货
* 订阅失败发送短信 * 订阅失败发送短信
* @param string $order_product_id * @param string $order_product_id
* @return bool * @return void
* @throws ContainerExceptionInterface * @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface * @throws NotFoundExceptionInterface
*/ */
public function ProductDelivery(string $order_product_id): bool public function ProductDelivery(string $order_product_id): void
{ {
try { try {
// 获取药品订单数据 // 获取药品订单数据
@ -870,7 +860,8 @@ class MessagePush extends BaseService
$params['order_product_id'] = $order_product_id; $params['order_product_id'] = $order_product_id;
$order_product = OrderProduct::getOne($params); $order_product = OrderProduct::getOne($params);
if (empty($order_product)){ if (empty($order_product)){
throw new BusinessException("加入推送队列失败:药品订单数据为空"); Log::getInstance("MessagePush")->error("错误:药品订单数据为空");
return ;
} }
// 获取药品订单商品数据 // 获取药品订单商品数据
@ -878,7 +869,8 @@ class MessagePush extends BaseService
$params['order_product_id'] = $order_product_id; $params['order_product_id'] = $order_product_id;
$order_product_item = OrderProductItem::getList($params); $order_product_item = OrderProductItem::getList($params);
if (empty($order_product_item)){ if (empty($order_product_item)){
throw new BusinessException("加入推送队列失败:商品订单列表数据为空"); Log::getInstance("MessagePush")->error("错误:商品订单列表数据为空");
return ;
} }
// 获取商品数据 // 获取商品数据
@ -888,7 +880,8 @@ class MessagePush extends BaseService
$params['product_id'] = $item['product_id']; $params['product_id'] = $item['product_id'];
$product = Product::getOne($params); $product = Product::getOne($params);
if (empty($product)){ if (empty($product)){
throw new BusinessException("加入推送队列失败:商品数据为空"); Log::getInstance("MessagePush")->error("错误:商品数据为空");
return ;
} }
$product_name_array[] = $product['common_name']; $product_name_array[] = $product['common_name'];
@ -896,54 +889,48 @@ class MessagePush extends BaseService
$product_name = implode('、',$product_name_array); $product_name = implode('、',$product_name_array);
if ($this->push_type == 2) { // 订阅
// 订阅 $sub_data = array();
$sub_data = array(); $sub_data['push_user_id'] = $this->user['user_id'];
$sub_data['push_user_id'] = $this->user['user_id']; $sub_data['wx_template_id'] = "YFdVxDclV1ZjhS7E4Cs0zFdshTRizERpwYdZizj_UWo"; // 药品发货通知
$sub_data['wx_template_id'] = "YFdVxDclV1ZjhS7E4Cs0zFdshTRizERpwYdZizj_UWo"; // 药品发货通知 $sub_data['params']['page'] = "pages/orderDetail/orderDetail?order_inquiry_id={$this->order_inquiry['order_inquiry_id']}";
$sub_data['params']['page'] = "pages/orderDetail/orderDetail?order_inquiry_id={$this->order_inquiry['order_inquiry_id']}"; $sub_data['params']['data'] = [
$sub_data['params']['data'] = [ "character_string9" => $order_product['order_product_no'],// 快递单号
"character_string9" => $order_product['order_product_no'],// 快递单号
"time7" => $order_product['delivery_time'],// 发货时间 "time7" => $order_product['delivery_time'],// 发货时间
"thing3" => $order_product['province'] . $order_product['city'] . $order_product['county'],// 收货地址 "thing3" => $order_product['province'] . $order_product['city'] . $order_product['county'],// 收货地址
"thing6" => $order_product['consignee_name'],// 收货人 "thing6" => $order_product['consignee_name'],// 收货人
"thing5" => "您的药品已发货,点击可以查看订单详情。",// 备注 "thing5" => "您的药品已发货,点击可以查看订单详情。",// 备注
]; ];
// 短信 // 短信
$sms_data = array(); $sms_data = array();
$sms_data['template_code'] = "SMS_271980127"; $sms_data['template_code'] = "SMS_271980127";
$sms_data['scene_desc'] = "药品发货通知"; $sms_data['scene_desc'] = "药品发货通知";
$sms_data['phone'] = $this->user['mobile']; $sms_data['phone'] = $this->user['mobile'];
$sms_data['user_id'] = $this->user['user_id']; $sms_data['user_id'] = $this->user['user_id'];
$template_param = array(); $template_param = array();
$template_param['name'] = $product_name; $template_param['name'] = $product_name;
$template_param['code'] = $order_product['logistics_no'] ?: ""; $template_param['code'] = $order_product['logistics_no'] ?: "";
$sms_data['template_param'] = $template_param; $sms_data['template_param'] = $template_param;
$data = array();
$data['sub_data'] = $sub_data;
$data['sms_data'] = $sms_data;
$message = new SendSubMessageProducer($data);
$data = array(); $producer = ApplicationContext::getContainer()->get(Producer::class);
$data['sub_data'] = $sub_data; $result = $producer->produce($message);
$data['sms_data'] = $sms_data; if (!$result) {
Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE));
$message = new SendSubMessageProducer($data);
$producer = ApplicationContext::getContainer()->get(Producer::class);
$result = $producer->produce($message);
if (!$result) {
throw new BusinessException("加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE));
}
} }
} catch (\Exception $e) { } catch (\Exception $e) {
throw new BusinessException("加入推送队列失败" . $e->getMessage()); Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . $e->getMessage());
} }
return true;
} }
/** /**
@ -968,11 +955,11 @@ class MessagePush extends BaseService
/** /**
* 医生-医生有新问诊 * 医生-医生有新问诊
* 站内、订阅失败发送短信 * 站内、订阅失败发送短信
* @return bool * @return void
* @throws ContainerExceptionInterface * @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface * @throws NotFoundExceptionInterface
*/ */
public function doctorHaveNewInquiry(): bool public function doctorHaveNewInquiry(): void
{ {
try { try {
// 获取医生数据 // 获取医生数据
@ -980,7 +967,8 @@ class MessagePush extends BaseService
$params['doctor_id'] = $this->order_inquiry['doctor_id']; $params['doctor_id'] = $this->order_inquiry['doctor_id'];
$user_doctor = UserDoctor::getOne($params); $user_doctor = UserDoctor::getOne($params);
if (empty($user_doctor)){ if (empty($user_doctor)){
throw new BusinessException("加入推送队列失败:医生数据为空"); Log::getInstance("MessagePush")->error("错误:医生数据为空");
return;
} }
// 站内 // 站内
@ -1005,7 +993,7 @@ class MessagePush extends BaseService
$producer = ApplicationContext::getContainer()->get(Producer::class); $producer = ApplicationContext::getContainer()->get(Producer::class);
$result = $producer->produce($message); $result = $producer->produce($message);
if (!$result) { if (!$result) {
throw new BusinessException("加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); Log::getInstance("MessagePush")->error("错误:加入站内推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE));
} }
// 订阅 // 订阅
@ -1046,13 +1034,11 @@ class MessagePush extends BaseService
$producer = ApplicationContext::getContainer()->get(Producer::class); $producer = ApplicationContext::getContainer()->get(Producer::class);
$result = $producer->produce($message); $result = $producer->produce($message);
if (!$result) { if (!$result) {
throw new BusinessException("加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); Log::getInstance("MessagePush")->error("错误:加入订阅推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE));
} }
} catch (\Exception $e) { } catch (\Exception $e) {
throw new BusinessException("加入推送队列失败" . $e->getMessage()); Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . $e->getMessage());
} }
return true;
} }
/** /**
@ -1154,11 +1140,11 @@ class MessagePush extends BaseService
* 医生-问诊结束 * 医生-问诊结束
* 站内 * 站内
* 发送给医生 * 发送给医生
* @return bool * @return void
* @throws ContainerExceptionInterface * @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface * @throws NotFoundExceptionInterface
*/ */
public function finishInquiryToDoctor(): bool public function finishInquiryToDoctor(): void
{ {
try { try {
// 获取问诊订单关联病例 // 获取问诊订单关联病例
@ -1166,7 +1152,8 @@ class MessagePush extends BaseService
$params['order_inquiry_id'] = $this->order_inquiry['order_inquiry_id']; $params['order_inquiry_id'] = $this->order_inquiry['order_inquiry_id'];
$order_inquiry_case = OrderInquiryCase::getOne($params); $order_inquiry_case = OrderInquiryCase::getOne($params);
if (empty($order_inquiry_case)){ if (empty($order_inquiry_case)){
throw new BusinessException("加入推送队列失败:问诊病例为空"); Log::getInstance("MessagePush")->error("错误:问诊病例为空" );
return ;
} }
// 站内 // 站内
@ -1191,23 +1178,21 @@ class MessagePush extends BaseService
$producer = ApplicationContext::getContainer()->get(Producer::class); $producer = ApplicationContext::getContainer()->get(Producer::class);
$result = $producer->produce($message); $result = $producer->produce($message);
if (!$result) { if (!$result) {
throw new BusinessException("加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); Log::getInstance("MessagePush")->error("错误:加入站内推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE));
} }
} catch (\Exception $e) { } catch (\Exception $e) {
throw new BusinessException("加入推送队列失败" . $e->getMessage()); Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . $e->getMessage());
} }
return true;
} }
/** /**
* 医生-开具的处方审核通过 * 医生-开具的处方审核通过
* 站内、订阅失败发送短信 * 站内、订阅失败发送短信
* @return bool * @return void
* @throws ContainerExceptionInterface * @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface * @throws NotFoundExceptionInterface
*/ */
public function prescriptionVerifySuccess(): bool public function prescriptionVerifySuccess(): void
{ {
try { try {
// 获取问诊订单处方数据 // 获取问诊订单处方数据
@ -1217,7 +1202,8 @@ class MessagePush extends BaseService
$params['pharmacist_audit_status'] = 1; $params['pharmacist_audit_status'] = 1;
$order_prescription = OrderPrescription::getOne($params); $order_prescription = OrderPrescription::getOne($params);
if (empty($order_prescription)) { if (empty($order_prescription)) {
throw new BusinessException("加入推送队列失败:处方数据为空"); Log::getInstance("MessagePush")->error("错误:处方数据为空" );
return ;
} }
// 站内 // 站内
@ -1242,7 +1228,7 @@ class MessagePush extends BaseService
$producer = ApplicationContext::getContainer()->get(Producer::class); $producer = ApplicationContext::getContainer()->get(Producer::class);
$result = $producer->produce($message); $result = $producer->produce($message);
if (!$result) { if (!$result) {
throw new BusinessException("加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); Log::getInstance("MessagePush")->error("错误:加入站内推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE));
} }
// 订阅 // 订阅
@ -1276,24 +1262,22 @@ class MessagePush extends BaseService
$producer = ApplicationContext::getContainer()->get(Producer::class); $producer = ApplicationContext::getContainer()->get(Producer::class);
$result = $producer->produce($message); $result = $producer->produce($message);
if (!$result) { if (!$result) {
throw new BusinessException("加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); Log::getInstance("MessagePush")->error("错误:加入站内推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE));
} }
} catch (\Exception $e) { } catch (\Exception $e) {
throw new BusinessException("加入推送队列失败" . $e->getMessage()); Log::getInstance("MessagePush")->error("错误:加入站内推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE));
} }
return true;
} }
/** /**
* 医生-开具的处方审核未通过 * 医生-开具的处方审核未通过
* 订阅失败发送短信 * 订阅失败发送短信
* @param string $order_prescription_id * @param string $order_prescription_id
* @return bool * @return void
* @throws ContainerExceptionInterface * @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface * @throws NotFoundExceptionInterface
*/ */
public function prescriptionVerifyFail(string $order_prescription_id): bool public function prescriptionVerifyFail(string $order_prescription_id): void
{ {
try { try {
// 获取问诊订单处方数据 // 获取问诊订单处方数据
@ -1301,7 +1285,8 @@ class MessagePush extends BaseService
$params['order_prescription_id'] = $order_prescription_id; $params['order_prescription_id'] = $order_prescription_id;
$order_prescription = OrderPrescription::getOne($params); $order_prescription = OrderPrescription::getOne($params);
if (empty($order_prescription)) { if (empty($order_prescription)) {
return false; Log::getInstance("MessagePush")->error("错误:处方数据为空" );
return ;
} }
// 订阅 // 订阅
@ -1335,14 +1320,11 @@ class MessagePush extends BaseService
$producer = ApplicationContext::getContainer()->get(Producer::class); $producer = ApplicationContext::getContainer()->get(Producer::class);
$result = $producer->produce($message); $result = $producer->produce($message);
if (!$result) { if (!$result) {
throw new BusinessException("加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); Log::getInstance("MessagePush")->error("错误:加入站内推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE));
} }
} catch (\Exception $e) { } catch (\Exception $e) {
Log::getInstance("MessagePush")->error("错误:" . $e->getMessage()); Log::getInstance("MessagePush")->error("错误:加入站内推送队列失败" . $e->getMessage());
return false;
} }
return true;
} }
/** /**
@ -1733,7 +1715,7 @@ class MessagePush extends BaseService
* @throws ContainerExceptionInterface * @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface * @throws NotFoundExceptionInterface
*/ */
public function doctorSettlementSuccess(string $withdrawal_id): bool public function doctorSettlementSuccess(string $withdrawal_id)
{ {
try { try {
// 获取医生提现表数据 // 获取医生提现表数据
@ -1741,7 +1723,8 @@ class MessagePush extends BaseService
$params['withdrawal_id'] = $withdrawal_id; $params['withdrawal_id'] = $withdrawal_id;
$doctor_withdrawal = DoctorWithdrawal::getOne($params); $doctor_withdrawal = DoctorWithdrawal::getOne($params);
if (empty($doctor_withdrawal)){ if (empty($doctor_withdrawal)){
throw new BusinessException("加入推送队列失败:提现数据为空"); Log::getInstance("MessagePush")->error("错误:提现数据为空" );
return ;
} }
if ($this->push_type == 1) { if ($this->push_type == 1) {
@ -1774,7 +1757,7 @@ class MessagePush extends BaseService
$producer = ApplicationContext::getContainer()->get(Producer::class); $producer = ApplicationContext::getContainer()->get(Producer::class);
$result = $producer->produce($message); $result = $producer->produce($message);
if (!$result) { if (!$result) {
throw new BusinessException("加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); Log::getInstance("MessagePush")->error("错误:加入站内推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE));
} }
} elseif ($this->push_type == 3) { } elseif ($this->push_type == 3) {
// 短信 // 短信
@ -1794,11 +1777,11 @@ class MessagePush extends BaseService
$producer = ApplicationContext::getContainer()->get(Producer::class); $producer = ApplicationContext::getContainer()->get(Producer::class);
$result = $producer->produce($message); $result = $producer->produce($message);
if (!$result) { if (!$result) {
throw new BusinessException("加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE));
} }
} }
} catch (\Exception $e) { } catch (\Exception $e) {
throw new BusinessException("加入推送队列失败" . $e->getMessage()); Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . $e->getMessage());
} }
return true; return true;
@ -1963,11 +1946,11 @@ class MessagePush extends BaseService
/** /**
* 医生-患者取消问诊 * 医生-患者取消问诊
* 站内-订阅 * 站内-订阅
* @return bool * @return void
* @throws ContainerExceptionInterface * @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface * @throws NotFoundExceptionInterface
*/ */
public function patientCancelInquiryToDoctor(): bool public function patientCancelInquiryToDoctor(): void
{ {
try { try {
// 获取医生数据 // 获取医生数据
@ -1975,7 +1958,7 @@ class MessagePush extends BaseService
$params['doctor_id'] = $this->order_inquiry['doctor_id']; $params['doctor_id'] = $this->order_inquiry['doctor_id'];
$user_doctor = UserDoctor::getOne($params); $user_doctor = UserDoctor::getOne($params);
if (empty($user_doctor)){ if (empty($user_doctor)){
throw new BusinessException("加入推送队列失败:医生数据为空"); Log::getInstance("MessagePush")->error("错误:医生数据为空" );
} }
// 站内 // 站内
@ -2000,7 +1983,7 @@ class MessagePush extends BaseService
$producer = ApplicationContext::getContainer()->get(Producer::class); $producer = ApplicationContext::getContainer()->get(Producer::class);
$result = $producer->produce($message); $result = $producer->produce($message);
if (!$result) { if (!$result) {
throw new BusinessException("加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE));
} }
$sub_data = array(); $sub_data = array();
@ -2028,13 +2011,11 @@ class MessagePush extends BaseService
$producer = ApplicationContext::getContainer()->get(Producer::class); $producer = ApplicationContext::getContainer()->get(Producer::class);
$result = $producer->produce($message); $result = $producer->produce($message);
if (!$result) { if (!$result) {
throw new BusinessException("加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE));
} }
} catch (\Exception $e) { } catch (\Exception $e) {
throw new BusinessException("加入推送队列失败" . $e->getMessage()); Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . $e->getMessage());
} }
return true;
} }
} }