diff --git a/app/Amqp/Consumer/SendStationMessageConsumer.php b/app/Amqp/Consumer/SendStationMessageConsumer.php index a099648..bb132d7 100644 --- a/app/Amqp/Consumer/SendStationMessageConsumer.php +++ b/app/Amqp/Consumer/SendStationMessageConsumer.php @@ -78,7 +78,7 @@ class SendStationMessageConsumer extends ConsumerMessage // 消息内容 $message_content_data = array(); $message_content_data['message_type'] = $message_type; - $message_content_data['content'] = $data['notice_title'] ?: "消息推送"; + $message_content_data['content'] = $data['notice_brief_type'] ?: "消息推送"; $message_content_data['desc'] = $data['notice_content'] ?? ""; $message_content = [ 'Data' => json_encode($message_content_data,JSON_UNESCAPED_UNICODE), @@ -139,7 +139,7 @@ class SendStationMessageConsumer extends ConsumerMessage } // 消息标题 - if (!isset($push_data['notice_title'])){ + if (!isset($push_data['notice_title']) && !isset($push_data['notice_brief_type'])){ return false; } @@ -217,11 +217,14 @@ class SendStationMessageConsumer extends ConsumerMessage $notice_data['from_name'] = $push_data['from_name'] ; } - $notice_data['notice_title'] = $push_data['notice_title'] ; $notice_data['notice_send_time'] = date('Y-m-d H:i:s',time()); - if (isset($push_data['notice_content'])){ - $notice_data['notice_content'] = $push_data['notice_content'] ; + if (isset($push_data['notice_title'])){ + $notice_data['notice_title'] = $push_data['notice_title'] ; + } + + if (isset($push_data['notice_brief_type'])){ + $notice_data['notice_brief_type'] = $push_data['notice_brief_type'] ; } if (isset($push_data['notice_content'])){ diff --git a/app/Amqp/Producer/SendStationMessageProducer.php b/app/Amqp/Producer/SendStationMessageProducer.php index 9187220..a13695c 100644 --- a/app/Amqp/Producer/SendStationMessageProducer.php +++ b/app/Amqp/Producer/SendStationMessageProducer.php @@ -18,6 +18,7 @@ class SendStationMessageProducer extends ProducerMessage * "notice_system_type":"系统消息类型(患者端系统消息存在 1:服务消息 2:福利消息 3:退款消息 4:物流消息)", * "inquiry_type:"问诊类型(医生端服务通知存在 1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药)", * "from_name:"发送人姓名", + * "notice_brief_type:"缩略消息标题(列表页展示)", * "notice_title:"消息标题", * "notice_content:"内容", * "button_type:"按钮类型(1:我的账户 2:联系客服 3:查看协议 4:订单详情 5:查看处方 )", diff --git a/app/Common/Common.php b/app/Common/Common.php index aa399a3..a25e1ec 100644 --- a/app/Common/Common.php +++ b/app/Common/Common.php @@ -177,11 +177,11 @@ function inquiryTypeToString(int|string $inquiry_type): string } /** - * 转换取消订单原因-字符串 + * 转换问诊订单取消原因-字符串 * @param int|string $cancel_reason 取消订单原因(1:医生未接诊 2:主动取消 3:无可分配医生 4:客服取消 5:支付超时) * @return string */ -function cancelReasonToString(int|string $cancel_reason): string +function inquiryCancelReasonToString(int|string $cancel_reason): string { if ($cancel_reason == 1) { $result = "医生未接诊"; @@ -197,4 +197,25 @@ function cancelReasonToString(int|string $cancel_reason): string $result = "未知"; } return $result; +} + +/** + * 转换药品订单取消原因-字符串 + * @param int|string $cancel_reason 订单取消原因(1:主动取消 2:复核失败/库存不足 3:支付超时 4:客服取消) + * @return string + */ +function productCancelReasonToString(int|string $cancel_reason): string +{ + if ($cancel_reason == 1) { + $result = "主动取消"; + } elseif ($cancel_reason == 2) { + $result = "复核失败/库存不足"; + } elseif ($cancel_reason == 3) { + $result = "支付超时"; + } elseif ($cancel_reason == 4) { + $result = "客服取消"; + } else { + $result = "未知"; + } + return $result; } \ No newline at end of file diff --git a/app/Controller/CallBackController.php b/app/Controller/CallBackController.php index 425c399..b3dc54a 100644 --- a/app/Controller/CallBackController.php +++ b/app/Controller/CallBackController.php @@ -174,7 +174,7 @@ class CallBackController extends AbstractController // 消息内容 $message_content_data = array(); $message_content_data['message_type'] = 1; - $message_content_data['content'] = "--等待医生接诊--"; + $message_content_data['title'] = "--等待医生接诊--"; $message_content_data['desc'] = "温馨提示:您可继续补充问诊内容,便于更快确认病情,医生均在临床一线工作,还请耐心等待,医生接诊会第一时间短信通知您。"; $message_content = [ 'Data' => json_encode($message_content_data,JSON_UNESCAPED_UNICODE), diff --git a/app/Controller/TestController.php b/app/Controller/TestController.php index 6dc19a1..984af70 100644 --- a/app/Controller/TestController.php +++ b/app/Controller/TestController.php @@ -6,6 +6,7 @@ use App\Amqp\Producer\CancelUnpayOrdersDelayDirectProducer; use App\Constants\HttpEnumCode; use App\Model\DoctorInquiryTime; use App\Model\DoctorPharmacistCert; +use App\Model\OrderInquiry; use App\Model\UserDoctor; use App\Services\ImService; use App\Services\MessagePush; @@ -439,8 +440,50 @@ class TestController extends AbstractController // $MessagePush = new MessagePush(2,"491923510680424449","499172549291458560"); // $result = $MessagePush->noInquiry(); - $MessagePush = new MessagePush(3,"491925054435950592","499176434366210048"); - $result = $MessagePush->doctorAcceptedInquiry(); +// $MessagePush = new MessagePush(3,"491925054435950592","499176434366210048"); +// $result = $MessagePush->doctorAcceptedInquiry(); + +// $ImService = new ImService(); +// +// $params = array(); +// $params['order_inquiry_id'] = "499313028868112385"; +// $order_inquiry = OrderInquiry::getOne($params); +// if (!empty($order_inquiry)) { +// $this->order_inquiry = $order_inquiry->toArray(); +// } +// +// // 获取订单医生数据 +// $params = array(); +// $params['doctor_id'] = $order_inquiry['doctor_id']; +// $user_doctor = UserDoctor::getOne($params); +// +// // 自定义消息 +// $cloud_custom_data = array(); +// $cloud_custom_data['order_inquiry_id'] = $order_inquiry['order_inquiry_id']; +// $cloud_custom_data['is_system'] = 1; +// $cloud_custom_data['inquiry_type'] = $order_inquiry['inquiry_type']; +// $cloud_custom_data['message_rounds'] = 0; +// $cloud_custom_data['patient_family_data']['patient_name'] = $order_inquiry['patient_name']; +// $cloud_custom_data['patient_family_data']['patient_sex'] = $order_inquiry['patient_sex']; +// $cloud_custom_data['patient_family_data']['patient_age'] = $order_inquiry['patient_age']; +// +// // 消息内容 +// $message_content_data = array(); +// $message_content_data['message_type'] = 6; +// $message_content_data['title'] = "--等待医生接诊--"; +// $message_content_data['desc'] = "温馨提示:您可继续补充问诊内容,便于更快确认病情,医生均在临床一线工作,还请耐心等待,医生接诊会第一时间短信通知您。"; +// $message_content_data['data'] = [ +// "order_inquiry_id" => "499313028868112385", +// "order_prescription_id" => "498938545791315968", +// "product_name" => "测试药品", +// "pharmacist_verify_time" => date('Y-m-d H:i:s',time()), +// ]; +// $message_content = [ +// 'Data' => json_encode($message_content_data,JSON_UNESCAPED_UNICODE), +// ]; +// +// $ImService->sendMessage($user_doctor['user_id'], $order_inquiry['user_id'], $message_content, "TIMCustomElem", $cloud_custom_data); + } } \ No newline at end of file diff --git a/app/Model/MessageNotice.php b/app/Model/MessageNotice.php index 80e6d4a..ba49e2e 100644 --- a/app/Model/MessageNotice.php +++ b/app/Model/MessageNotice.php @@ -18,12 +18,13 @@ use Hyperf\Snowflake\Concern\Snowflake; * @property int $read_status 读取状态(0:未读 1:已读) * @property int $inquiry_type 问诊类型(医生端服务通知存在 1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药) * @property string $from_name 发送人姓名 + * @property string $notice_brief_type 缩略消息标题(列表页展示) * @property string $notice_title 消息标题 * @property string $notice_send_time 发送时间 * @property string $notice_content 内容 * @property int $send_status 发送状态(0:未处理 1:已发送 2:发送失败) * @property string $send_fail_reason 发送失败原因 - * @property int $button_type 按钮类型(1:我的账户 2:联系客服 3:查看协议 4:订单详情 5:查看处方 ) + * @property int $button_type 按钮类型(1:我的账户 2:联系客服 3:查看协议 4:订单详情 5:查看处方 6:问诊详情 ) * @property int $link_type 跳转页面类型(1:聊天详情页 2:问诊结束列表页 3:问诊消息列表页 4:我的名片 5:我的简介 6:我的账户 7:我的福利 8:药品订单详情页 9:物流详情 10:问诊订单详情 11:联系客服 12:协议详情 13:处方详情) * @property string $link_params 跳转参数(json) * @property int $show_type 展示类型(1:医生数据) @@ -43,7 +44,7 @@ class MessageNotice extends Model /** * The attributes that are mass assignable. */ - protected array $fillable = ['notice_id', 'user_id', 'user_type', 'notice_type', 'notice_system_type', 'read_status', 'inquiry_type', 'from_name', 'notice_title', 'notice_send_time', 'notice_content', 'send_status', 'send_fail_reason', 'button_type', 'link_type', 'link_params', 'show_type', 'show_params', 'created_at', 'updated_at']; + protected array $fillable = ['notice_id', 'user_id', 'user_type', 'notice_type', 'notice_system_type', 'read_status', 'inquiry_type', 'from_name', 'notice_brief_type', 'notice_title', 'notice_send_time', 'notice_content', 'send_status', 'send_fail_reason', 'button_type', 'link_type', 'link_params', 'show_type', 'show_params', 'created_at', 'updated_at']; protected string $primaryKey = "notice_id"; diff --git a/app/Model/OrderProduct.php b/app/Model/OrderProduct.php index 1c16e2c..c250090 100644 --- a/app/Model/OrderProduct.php +++ b/app/Model/OrderProduct.php @@ -24,14 +24,15 @@ use Hyperf\Snowflake\Concern\Snowflake; * @property int $pay_channel 支付渠道(1:小程序支付 2:微信扫码支付) * @property int $pay_status 支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款) * @property int $is_delete 删除状态(0:否 1:是) - * @property int $cancel_reason 订单取消原因(1:主动取消 2:复核失败/库存不足 3:支付超时) + * @property int $cancel_reason 订单取消原因(1:主动取消 2:复核失败/库存不足 3:支付超时 4:客服取消) * @property string $amount_total 订单金额 * @property string $payment_amount_total 实际付款金额 * @property string $logistics_fee 运费金额 * @property string $logistics_no 物流编号 + * @property string $delivery_time 发货时间 * @property string $pay_time 支付时间 * @property string $remarks 订单备注 - * @property int $refund_status 商品订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭) + * @property int $refund_status 商品订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭 6:退款异常) * @property string $cancel_time 订单取消时间 * @property string $cancel_remarks 订单取消备注(自动添加) * @property int $province_id 省份id @@ -48,7 +49,10 @@ use Hyperf\Snowflake\Concern\Snowflake; * @property string $consignee_tel_mask 收货人电话(掩码) * @property \Carbon\Carbon $created_at 创建时间 * @property \Carbon\Carbon $updated_at 修改时间 + * @property-read OrderPrescription $OrderPrescription + * @property-read \Hyperf\Database\Model\Collection|OrderPrescriptionIcd[] $OrderPrescriptionIcd * @property-read \Hyperf\Database\Model\Collection|OrderProductItem[] $OrderProductItem + * @property-read PatientFamily $PatientFamily */ class OrderProduct extends Model { @@ -62,7 +66,7 @@ class OrderProduct extends Model /** * The attributes that are mass assignable. */ - protected array $fillable = ['order_product_id', 'order_inquiry_id', 'order_prescription_id', 'doctor_id', 'patient_id', 'family_id', 'order_product_no', 'escrow_trade_no', 'order_product_status', 'pay_channel', 'pay_status', 'is_delete', 'cancel_reason', 'amount_total', 'payment_amount_total', 'logistics_fee', 'logistics_no', 'pay_time', 'remarks', 'refund_status', 'cancel_time', 'cancel_remarks', 'province_id', 'province', 'city_id', 'city', 'county_id', 'county', 'address', 'address_mask', 'consignee_name', 'consignee_name_mask', 'consignee_tel', 'consignee_tel_mask', 'created_at', 'updated_at']; + protected array $fillable = ['order_product_id', 'order_inquiry_id', 'order_prescription_id', 'doctor_id', 'patient_id', 'family_id', 'order_product_no', 'escrow_trade_no', 'order_product_status', 'pay_channel', 'pay_status', 'is_delete', 'cancel_reason', 'amount_total', 'payment_amount_total', 'logistics_fee', 'logistics_no', 'delivery_time', 'pay_time', 'remarks', 'refund_status', 'cancel_time', 'cancel_remarks', 'province_id', 'province', 'city_id', 'city', 'county_id', 'county', 'address', 'address_mask', 'consignee_name', 'consignee_name_mask', 'consignee_tel', 'consignee_tel_mask', 'created_at', 'updated_at']; protected string $primaryKey = "order_product_id"; diff --git a/app/Services/InquiryService.php b/app/Services/InquiryService.php index 35dec35..b37f595 100644 --- a/app/Services/InquiryService.php +++ b/app/Services/InquiryService.php @@ -295,7 +295,7 @@ class InquiryService extends BaseService $result = array(); $result['inquiry_no'] = (string)$order_inquiry['inquiry_no']; // 订单编号 - $result['order_inquiry_id'] = $order_inquiry['order_inquiry_id']; // 订单主键id + $result['order_inquiry_id'] = (string)$order_inquiry['order_inquiry_id']; // 订单主键id return success($result); } diff --git a/app/Services/MessagePush.php b/app/Services/MessagePush.php index ed86182..18a0c04 100644 --- a/app/Services/MessagePush.php +++ b/app/Services/MessagePush.php @@ -8,7 +8,11 @@ use App\Amqp\Producer\SendSubMessageProducer; use App\Constants\HttpEnumCode; use App\Exception\BusinessException; use App\Model\OrderInquiry; +use App\Model\OrderInquiryCase; use App\Model\OrderPrescription; +use App\Model\OrderProduct; +use App\Model\OrderProductItem; +use App\Model\Product; use App\Model\SystemInquiryConfig; use App\Model\User; use App\Model\UserDoctor; @@ -83,15 +87,15 @@ class MessagePush extends BaseService $data['from_name'] = "肝胆小秘书"; if ($this->order_inquiry['inquiry_type'] == 1 || $this->order_inquiry['inquiry_type'] == 3) { // 专家-公益 - $inquiry_type_string = inquiryTypeToString($this->order_inquiry['inquiry_type']); - $data['notice_title'] = "【{$inquiry_type_string}】医生未接诊:您咨询的医生因工作繁忙没有时间接诊,点击查看详情。"; - $data['notice_content'] = "【{$inquiry_type_string}】未接诊:您咨询的服务当前排队人较多,暂无空闲医生接诊。给您带来不便敬请谅解,平台会在24小时内进行退款,您可以点击订单详情查看退款详情。"; + $data['notice_brief_type'] = "您咨询的服务暂无医生接诊,点击查看详情。"; + $data['notice_title'] = "您咨询的服务暂无医生接诊,点击查看详情。"; + $data['notice_content'] = "您咨询的服务当前排队人较多,暂无空闲医生接诊。给您带来不便敬请谅解,平台会在24小时内进行退款,您可以点击订单详情查看退款详情。"; } elseif ($this->order_inquiry['inquiry_type'] == 1 || $this->order_inquiry['inquiry_type'] == 4) { // 快速-购药 - $inquiry_type_string = inquiryTypeToString($this->order_inquiry['inquiry_type']); - $data['notice_title'] = "【{$inquiry_type_string}】未接诊:您咨询的服务暂无医生接诊,点击查看详情。"; - $data['notice_content'] = "【{$inquiry_type_string}】医生未接诊:您咨询的医生因工作繁忙,暂无空闲时间接诊。给您带来不便敬请谅解,平台会在24小时内进行退款,您可以点击订单详情查看退款详情。"; + $data['notice_brief_type'] = "您咨询的医生因工作繁忙没有时间接诊,点击查看详情。"; + $data['notice_title'] = "您咨询的医生因工作繁忙没有时间接诊,点击查看详情。"; + $data['notice_content'] = "您咨询的医生因工作繁忙,暂无空闲时间接诊。给您带来不便敬请谅解,平台会在24小时内进行退款,您可以点击订单详情查看退款详情。"; } $data['link_type'] = 10;// 问诊订单详情 @@ -126,7 +130,7 @@ class MessagePush extends BaseService "character_string1" => $this->order_inquiry['inquiry_no'],// 订单ID "name2" => (string)$user_doctor['user_name'],// 问诊医生 "date3" => $this->order_inquiry['created_at'],// 问诊时间 - "thing4" => cancelReasonToString($this->order_inquiry['cancel_reason']),// 取消原因 + "thing4" => inquiryCancelReasonToString($this->order_inquiry['cancel_reason']),// 取消原因 "thing5" => "点击详情更换医生问诊",// 提示说明 ]; @@ -165,7 +169,7 @@ class MessagePush extends BaseService $sub_data = array(); $sub_data['push_user_id'] = $this->user['user_id']; $sub_data['template_title'] = "患者回复通知"; - $sub_data['params']['page'] = "Pages/yishi/chat/index?from_account={$this->user['user_id']}&order_inquiry_id={$this->order_inquiry['order_inquiry_id']}&inquiry_type={$this->order_inquiry['inquiry_type']}"; + $sub_data['params']['page'] = "Pages/yishi/wenzhen_v2/wenzhen"; $sub_data['params']['data'] = [ "thing1" => $this->user['user_name'],// 患者姓名 "thing2" => $content,// 回复内容 @@ -208,12 +212,12 @@ class MessagePush extends BaseService if ($this->push_type == 1) { // 站内 - // 服务消息 $data = array(); $data['user_id'] = $this->user['user_id']; $data['notice_type'] = 3; $data['notice_system_type'] = 1; $data['from_name'] = "肝胆小秘书"; + $data['notice_brief_type'] = "{$user_doctor['user_name']}医生已接诊,请尽快和医生进行沟通交流病情,点击查看详情"; $data['notice_title'] = "{$user_doctor['user_name']}医生已接诊,请尽快和医生进行沟通交流病情,点击查看详情"; $data['notice_content'] = "{$user_doctor['user_name']}医生已接诊,请您尽快和医生进行沟通交流病情,您可以点击问诊详情进行交流。"; $data['link_type'] = 1;// 聊天详情页 @@ -330,6 +334,7 @@ class MessagePush extends BaseService $data['notice_type'] = 3; $data['notice_system_type'] = 1; $data['from_name'] = "肝胆小秘书"; + $data['notice_brief_type'] = "您咨询的【{$inquiry_type_string}】服务已结束,点击查看详情。"; $data['notice_title'] = "您咨询的【{$inquiry_type_string}】服务已结束,点击查看详情。"; $data['notice_content'] = "您咨询{$user_doctor['user_name']}医生的服务已结束,请对本次问诊服务做出评价。您的评价对医生和其他患者也有很重要的参考价值。您也可以点击医生头像,进入医生主页关注医生。"; $data['link_type'] = 10;// 聊天详情页 @@ -414,6 +419,7 @@ class MessagePush extends BaseService $data['notice_type'] = 3; $data['notice_system_type'] = 1; $data['from_name'] = "肝胆小秘书"; + $data['notice_brief_type'] = "{$user_doctor['user_name']}医生为您开具的电子处方已审核通过,点击查看详情。"; $data['notice_title'] = "{$user_doctor['user_name']}医生为您开具的电子处方已审核通过,点击查看详情。"; $data['notice_content'] = "{$user_doctor['user_name']}医生为您开具的电子处方已审核通过,您可以点击查看处方进行购买药品。"; $data['link_type'] = 13; @@ -490,6 +496,7 @@ class MessagePush extends BaseService $data['notice_type'] = 3; $data['notice_system_type'] = 2; // 系统消息类型(患者端系统消息存在 1:服务消息 2:福利消息 3:退款消息 4:物流消息) $data['from_name'] = "肝胆小秘书"; + $data['notice_brief_type'] = "有新的优惠券已下发至您的账户,点击查看详情。"; $data['notice_title'] = "【优惠劵名称】已到账"; $data['notice_content'] = "有新的优惠劵已下发至您的账户中,点击查看详情!"; $data['link_type'] = 7; @@ -541,6 +548,7 @@ class MessagePush extends BaseService $data['notice_type'] = 3; $data['notice_system_type'] = 2; // 系统消息类型(患者端系统消息存在 1:服务消息 2:福利消息 3:退款消息 4:物流消息) $data['from_name'] = "肝胆小秘书"; + $data['notice_brief_type'] = "您有优惠劵已退还至您的账户,点击查看详情。"; $data['notice_title'] = "【优惠劵名称】已退还"; $data['notice_content'] = "您有优惠劵已退还至您的账户,请点击查看详情!"; $data['link_type'] = 7; @@ -592,6 +600,7 @@ class MessagePush extends BaseService $data['notice_type'] = 3; $data['notice_system_type'] = 2; // 系统消息类型(患者端系统消息存在 1:服务消息 2:福利消息 3:退款消息 4:物流消息) $data['from_name'] = "肝胆小秘书"; + $data['notice_brief_type'] = "您有一张优惠劵即将过期,点击查看详情。"; $data['notice_title'] = "【优惠劵名称】即将过期"; $data['notice_content'] = "您有一张优惠劵即将过期,点击查看详情!"; $data['link_type'] = 7; @@ -640,14 +649,17 @@ class MessagePush extends BaseService $data['from_name'] = "肝胆小秘书"; if ($type == 1){ // 已支付未接诊 + $data['notice_brief_type'] = "您咨询的【{$inquiry_type_string}】服务,平台 已退款成功,点击查看详情。"; $data['notice_title'] = "您咨询的【{$inquiry_type_string}】服务,平台 已退款成功"; $data['notice_content'] = "因医生繁忙未及时接诊,平台会在24小时内给您退款至原账户中,带来的不便敬请谅解。"; }elseif ($type == 2){ // 已支付未成功分配医生 + $data['notice_brief_type'] = "您咨询的【{$inquiry_type_string}】服务,平台 已退款成功,点击查看详情。"; $data['notice_title'] = "您咨询的【{$inquiry_type_string}】服务,平台 已退款成功"; $data['notice_content'] = "当前服务排队人较多,暂无空闲医生为您接诊,平台会在24小时内给您退款至原账户中,带来的不便敬请谅解。"; }elseif ($type == 2){ // 已支付未接诊患者取消订单 + $data['notice_brief_type'] = "您咨询的【{$inquiry_type_string}】服务,平台 已退款成功,点击查看详情。"; $data['notice_title'] = "您咨询的【{$inquiry_type_string}】服务,平台 已退款成功"; $data['notice_content'] = "您已取消成功当前服务,平台会在24小时内给您退还至原账户中,带来的不便敬请谅解。"; }else{ @@ -693,31 +705,14 @@ class MessagePush extends BaseService } elseif ($this->push_type == 3) { // 短信 // 获取系统接诊配置 - $params = array(); - $params['inquiry_type'] = $this->order_inquiry['inquiry_type']; - $params['inquiry_mode'] = $this->order_inquiry['inquiry_mode']; - $system_inquiry_config = SystemInquiryConfig::getOne($params); - if (empty($system_inquiry_config)) { - throw new BusinessException("加入推送队列失败:获取系统接诊配置失败"); - } - - $duration = $system_inquiry_config['duration']; - if ($duration <= 0){ - $duration = "不限制"; - }else{ - $duration = $duration . "分钟"; - } - $data = array(); - $data['template_code'] = "SMS_271955088"; - $data['scene_desc'] = "医生已接诊"; + $data['template_code'] = "SMS_272180110"; + $data['scene_desc'] = "患者问诊退款"; $data['phone'] = $this->user['mobile']; $data['user_id'] = $this->user['user_id']; $template_param = array(); $template_param['type'] = inquiryTypeToString($this->order_inquiry['inquiry_type']); - $template_param['name'] = $user_doctor['user_name']; - $template_param['duration'] = $duration; // 服务时长 $data['template_param'] = $template_param; @@ -734,4 +729,446 @@ class MessagePush extends BaseService return true; } + + /** + * 药品订单退款成功 + * 站内、订阅、短信 + * @param string $order_product_id + * @return bool + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + */ + public function refundProductSuccess(string $order_product_id): bool + { + try { + // 获取药品订单数据 + $params = array(); + $params['order_product_id'] = $order_product_id; + $order_product = OrderProduct::getOne($params); + if (empty($order_product)){ + throw new BusinessException("加入推送队列失败:药品订单数据为空"); + } + + // 获取药品订单商品数据 + $params = array(); + $params['order_product_id'] = $order_product_id; + $order_product_item = OrderProductItem::getList($params); + if (empty($order_product_item)){ + throw new BusinessException("加入推送队列失败:商品订单列表数据为空"); + } + + // 获取商品数据 + $product_name_array = array(); + foreach ($order_product_item as $item){ + $params = array(); + $params['product_id'] = $item['product_id']; + $product = Product::getOne($params); + if (empty($product)){ + throw new BusinessException("加入推送队列失败:商品数据为空"); + } + + $product_name_array[] = $product['common_name']; + } + + $product_name = implode('、',$product_name_array); + + if ($this->push_type == 1) { + // 站内 + $data = array(); + $data['user_id'] = $this->user['user_id']; + $data['notice_type'] = 3; + $data['notice_system_type'] = 3; + $data['from_name'] = "肝胆小秘书"; + $data['notice_brief_type'] = "您购买的【{$product_name}】药品,平台已退款成功,点击查看详情"; + $data['notice_title'] = "您购买的【{$product_name}】药品,平台已退款成功"; + $data['notice_content'] = "因平台特殊情况发生,导致您的药品无法邮寄。平台已进行退款处理,并退款成功,带来的不便敬请谅解。"; + + $data['link_type'] = 8;// 药品订单详情页 + + $link_params = array(); + $link_params['order_product_id'] = $order_product_id; + $data['link_params'] = json_encode($link_params,JSON_UNESCAPED_UNICODE);// 跳转参数 + + $message = new SendStationMessageProducer($data); + $producer = ApplicationContext::getContainer()->get(Producer::class); + $result = $producer->produce($message); + if (!$result) { + throw new BusinessException("加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); + } + } elseif ($this->push_type == 2) { + // 订阅 + $sub_data = array(); + $sub_data['push_user_id'] = $this->user['user_id']; + $sub_data['template_title'] = "药品订单取消通知"; + $sub_data['params']['page'] = "pages/orderDetail/orderDetail?order_inquiry_id={$this->order_inquiry['order_inquiry_id']}"; + $sub_data['params']['data'] = [ + "character_string3" => $order_product['order_product_no'],// 订单号 + + "time5" => $order_product['cancel_time'],// 取消时间 + + "amount4" => $order_product['payment_amount_total'],// 退款金额 + + "thing1" => productCancelReasonToString($order_product['cancel_reason']),// 取消原因 + + "thing6" => "点击详情查看",// 温馨提示 + + ]; + + $data = array(); + $data['sub_data'] = $sub_data; + $data['sms_data'] = array(); + + $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)); + } + } elseif ($this->push_type == 3) { + // 短信 + // 获取系统接诊配置 + $data = array(); + $data['template_code'] = "SMS_271955204"; + $data['scene_desc'] = "患者药品费用退款"; + $data['phone'] = $this->user['mobile']; + $data['user_id'] = $this->user['user_id']; + + $template_param = array(); + $template_param['name'] = $product_name; + $template_param['status'] = productCancelReasonToString($order_product['cancel_reason']); + $data['template_param'] = $template_param; + + + $message = new SendSmsMessageProducer($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) { + throw new BusinessException("加入推送队列失败" . $e->getMessage()); + } + + return true; + } + + /** + * 物流信息-暂时无法开发,无物流信息表 + * 已揽收、已发货、自动收货 + * 站内 + * @param string $order_product_id + * @return bool + */ + public function logistics(string $order_product_id): bool + { + try { + + } catch (\Exception $e) { + throw new BusinessException("加入推送队列失败" . $e->getMessage()); + } + + return true; + } + + /** + * 药品已发货 + * 订阅失败发送短信 + * @param string $order_product_id + * @return bool + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + */ + public function ProductDelivery(string $order_product_id): bool + { + try { + // 获取药品订单数据 + $params = array(); + $params['order_product_id'] = $order_product_id; + $order_product = OrderProduct::getOne($params); + if (empty($order_product)){ + throw new BusinessException("加入推送队列失败:药品订单数据为空"); + } + + // 获取药品订单商品数据 + $params = array(); + $params['order_product_id'] = $order_product_id; + $order_product_item = OrderProductItem::getList($params); + if (empty($order_product_item)){ + throw new BusinessException("加入推送队列失败:商品订单列表数据为空"); + } + + // 获取商品数据 + $product_name_array = array(); + foreach ($order_product_item as $item){ + $params = array(); + $params['product_id'] = $item['product_id']; + $product = Product::getOne($params); + if (empty($product)){ + throw new BusinessException("加入推送队列失败:商品数据为空"); + } + + $product_name_array[] = $product['common_name']; + } + + $product_name = implode('、',$product_name_array); + + if ($this->push_type == 2) { + // 订阅 + $sub_data = array(); + $sub_data['push_user_id'] = $this->user['user_id']; + $sub_data['template_title'] = "药品发货通知"; + $sub_data['params']['page'] = "pages/orderDetail/orderDetail?order_inquiry_id={$this->order_inquiry['order_inquiry_id']}"; + $sub_data['params']['data'] = [ + "character_string9" => $order_product['order_product_no'],// 快递单号 + + "time7" => $order_product['delivery_time'],// 发货时间 + + "thing3" => $order_product['province'] . $order_product['city'] . $order_product['county'],// 收货地址 + + "thing6" => $order_product['consignee_name'],// 收货人 + + "thing5" => "您的药品已发货,点击可以查看订单详情。",// 备注 + ]; + + // 短信 + $sms_data = array(); + $sms_data['template_code'] = "SMS_271980127"; + $sms_data['scene_desc'] = "药品发货通知"; + $sms_data['phone'] = $this->user['mobile']; + $sms_data['user_id'] = $this->user['user_id']; + + $template_param = array(); + $template_param['name'] = $product_name; + $template_param['code'] = $order_product['logistics_no'] ?: ""; + $sms_data['template_param'] = $template_param; + + + + $data = array(); + $data['sub_data'] = $sub_data; + $data['sms_data'] = $sms_data; + + $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) { + throw new BusinessException("加入推送队列失败" . $e->getMessage()); + } + + return true; + } + + /** + * 药品收货-用药提醒-无法开发, + * 订阅失败发送短信 + * @param string $order_product_id + * @return bool + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + */ + public function medicationReminder(string $order_product_id): bool + { + try { + + } catch (\Exception $e) { + throw new BusinessException("加入推送队列失败" . $e->getMessage()); + } + + return true; + } + + /** + * 新问诊 + * 站内、订阅失败发送短信 + * @return bool + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + */ + public function newInquiry(): bool + { + try { + // 获取医生数据 + $params = array(); + $params['doctor_id'] = $this->order_inquiry['doctor_id']; + $user_doctor = UserDoctor::getOne($params); + if (empty($user_doctor)){ + throw new BusinessException("加入推送队列失败:医生数据为空"); + } + + if ($this->push_type == 1) { + // 站内 + $data = array(); + $data['user_id'] = $this->user['user_id']; + $data['notice_type'] = 1; + $data['inquiry_type'] = $this->order_inquiry['inquiry_type']; // 问诊类型(医生端服务通知存在 1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药) + $data['from_name'] = "肝胆小秘书"; + $data['notice_brief_type'] = "您有新的问诊咨询,请注意查看。"; + $data['notice_title'] = "您有新的问诊咨询,请注意查看。"; + $data['notice_content'] = "您有新的问诊咨询,请注意查看。"; + $data['link_type'] = 1; // 聊天详情页 + + $link_params = array(); + $link_params['order_inquiry_id'] = $this->order_inquiry['order_inquiry_id']; + $link_params['inquiry_type'] = $this->order_inquiry['inquiry_type']; + $link_params['doctor_user_id'] = $user_doctor['user_id']; + $link_params['patient_user_id'] = $this->order_inquiry['user_id']; + $data['link_params'] = json_encode($link_params,JSON_UNESCAPED_UNICODE);// 跳转参数 + + $message = new SendStationMessageProducer($data); + $producer = ApplicationContext::getContainer()->get(Producer::class); + $result = $producer->produce($message); + if (!$result) { + throw new BusinessException("加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); + } + } elseif ($this->push_type == 2) { + // 订阅 + $inquiry_type = inquiryTypeToString($this->order_inquiry['inquiry_type']); + + $sub_data = array(); + $sub_data['push_user_id'] = $this->user['user_id']; + $sub_data['template_title'] = "咨询提醒"; +// $sub_data['params']['page'] = "Pages/yishi/chat/index?from_account={$this->order_inquiry['user_id']}&order_inquiry_id={$this->order_inquiry['order_inquiry_id']}&inquiry_type={$this->order_inquiry['inquiry_type']}"; + $sub_data['params']['page'] = "Pages/yishi/wenzhen_v2/wenzhen"; + $sub_data['params']['data'] = [ + "thing1" => "您有新的患者向您发起了({$inquiry_type})服务,请您尽快上线接诊;",// 提醒内容 + + "name2" => $this->order_inquiry['patient_name'],// 患者姓名 + + "thing4" => (string)$user_doctor['user_name'],// 病情描述 + + "thing6" => "24小时内未接诊,平台将自动取消问诊。",// 提示说明 + + "thing5" => "",// 咨询内容 + + ]; + // 短信 + $sms_data = array(); + $sms_data['template_code'] = "SMS_272015117"; + $sms_data['scene_desc'] = "医生接到新问诊"; + $sms_data['phone'] = $this->user['mobile']; + $sms_data['user_id'] = $this->user['user_id']; + + $template_param = array(); + $template_param['type'] = inquiryTypeToString($this->order_inquiry['inquiry_type']); + $sms_data['template_param'] = $template_param; + + $data = array(); + $data['sub_data'] = $sub_data; + $data['sms_data'] = $sms_data; + + $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) { + throw new BusinessException("加入推送队列失败" . $e->getMessage()); + } + + return true; + } + + /** + * 医生xx时间后还未接诊 + * 站内、订阅失败发送短信 + * @return bool + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + */ + public function doctorNotYetInquiry(): bool + { + try { + // 获取问诊订单关联病例 + $params = array(); + $params['order_inquiry_id'] = $this->order_inquiry['order_inquiry_id']; + $order_inquiry_case = OrderInquiryCase::getOne($params); + if (empty($order_inquiry_case)){ + throw new BusinessException("加入推送队列失败:问诊病例为空"); + } + + if ($this->push_type == 1) { + // 站内 + $data = array(); + $data['user_id'] = $this->user['user_id']; + $data['notice_type'] = 1; + $data['inquiry_type'] = $this->order_inquiry['inquiry_type']; // 问诊类型(医生端服务通知存在 1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药) + $data['from_name'] = "肝胆小秘书"; + $data['notice_brief_type'] = "{$this->order_inquiry['patient_name']}患者的问诊您还未接诊,请注意查看。"; + $data['notice_title'] = "{$this->order_inquiry['patient_name']}患者的问诊您还未接诊,请注意查看。"; + $data['notice_content'] = "{$this->order_inquiry['patient_name']}患者的问诊您还未接诊,请注意查看。"; + $data['link_type'] = 1; // 聊天详情页 + + $link_params = array(); + $link_params['order_inquiry_id'] = $this->order_inquiry['order_inquiry_id']; + $link_params['inquiry_type'] = $this->order_inquiry['inquiry_type']; + $link_params['doctor_user_id'] = $this->user['user_id']; + $link_params['patient_user_id'] = $this->order_inquiry['user_id']; + $data['link_params'] = json_encode($link_params,JSON_UNESCAPED_UNICODE);// 跳转参数 + + $message = new SendStationMessageProducer($data); + $producer = ApplicationContext::getContainer()->get(Producer::class); + $result = $producer->produce($message); + if (!$result) { + throw new BusinessException("加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); + } + } elseif ($this->push_type == 2) { + // 订阅 + $inquiry_type = inquiryTypeToString($this->order_inquiry['inquiry_type']); + + $sub_data = array(); + $sub_data['push_user_id'] = $this->user['user_id']; + $sub_data['template_title'] = "咨询提醒"; +// $sub_data['params']['page'] = "Pages/yishi/chat/index?from_account={$this->order_inquiry['user_id']}&order_inquiry_id={$this->order_inquiry['order_inquiry_id']}&inquiry_type={$this->order_inquiry['inquiry_type']}"; + $sub_data['params']['page'] = "Pages/yishi/wenzhen_v2/wenzhen"; + $sub_data['params']['data'] = [ + "thing1" => "您好医生,{$this->order_inquiry['patient_name']}患者的({$inquiry_type})服务您还未接诊;",// 提醒内容 + + "name2" => $this->order_inquiry['patient_name'],// 患者姓名 + + "thing4" => mb_substr($order_inquiry_case['disease_desc'],0,18),// 病情描述 + + "thing6" => "24小时内未接诊,平台将自动取消问诊。",// 提示说明 + + "thing5" => "",// 咨询内容 + + ]; + + // 短信 + $sms_data = array(); + $sms_data['template_code'] = "SMS_272015117"; + $sms_data['scene_desc'] = "医生接到新问诊"; + $sms_data['phone'] = $this->user['mobile']; + $sms_data['user_id'] = $this->user['user_id']; + + $template_param = array(); + $template_param['type'] = inquiryTypeToString($this->order_inquiry['inquiry_type']); + $template_param['name'] = $this->order_inquiry['patient_name']; + $sms_data['template_param'] = $template_param; + + $data = array(); + $data['sub_data'] = $sub_data; + $data['sms_data'] = $sms_data; + + $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) { + throw new BusinessException("加入推送队列失败" . $e->getMessage()); + } + + return true; + } } \ No newline at end of file diff --git a/app/Services/UserPharmacistService.php b/app/Services/UserPharmacistService.php index 1793104..edc201b 100644 --- a/app/Services/UserPharmacistService.php +++ b/app/Services/UserPharmacistService.php @@ -7,6 +7,7 @@ use App\Model\OrderPrescription; use App\Model\User; use App\Model\UserPharmacist; use App\Model\UserPharmacistInfo; +use Hyperf\DbConnection\Db; /** * 药师 @@ -157,7 +158,21 @@ class UserPharmacistService extends BaseService return fail(HttpEnumCode::HTTP_ERROR,"处方已审核,请勿重复审核"); } - // + Db::beginTransaction(); + + try { + // 修改处方审核状态 + $data = array(); + + Db::commit(); + } catch (\Exception $e) { + Db::rollBack(); + return fail(HttpEnumCode::HTTP_ERROR, $e->getMessage()); + } + + // 新增商品订单表 + // 新增商品订单明细表 + // 新增未支付取消订单队列