From 45fc94bceeba829672fb87db039781a17343aedf Mon Sep 17 00:00:00 2001 From: wucongxing <815046773@qq.com> Date: Thu, 13 Apr 2023 10:54:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=97=AE=E8=AF=8A=E9=80=80?= =?UTF-8?q?=E6=AC=BE=E5=9B=9E=E8=B0=83=EF=BC=8C=E5=8F=AA=E6=9C=89=E9=80=80?= =?UTF-8?q?=E6=AC=BE=E6=88=90=E5=8A=9F=EF=BC=8C=E6=89=8D=E4=BC=9A=E6=8E=A8?= =?UTF-8?q?=E9=80=81=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Controller/CallBackController.php | 44 ++++++++++++++++----------- app/Services/InquiryService.php | 3 -- extend/Kuaidi100/Kuaidi.php | 20 ++++++++---- 3 files changed, 41 insertions(+), 26 deletions(-) diff --git a/app/Controller/CallBackController.php b/app/Controller/CallBackController.php index ca7e841..c8e7b40 100644 --- a/app/Controller/CallBackController.php +++ b/app/Controller/CallBackController.php @@ -284,9 +284,11 @@ class CallBackController extends AbstractController OrderInquiryRefund::edit($params,$data); // 恢复优惠卷 - if (!empty($order_inquiry['coupon_amount_total']) && $order_inquiry['coupon_amount_total'] > 0) { - $InquiryService = new InquiryService(); - $InquiryService->returnInquiryCoupon($order_inquiry['order_inquiry_id'],$order_inquiry['user_id']); + if ($inquiry_refund_status == 3){ + if (!empty($order_inquiry['coupon_amount_total']) && $order_inquiry['coupon_amount_total'] > 0) { + $InquiryService = new InquiryService(); + $InquiryService->returnInquiryCoupon($order_inquiry['order_inquiry_id'],$order_inquiry['user_id']); + } } Db::commit(); @@ -300,23 +302,31 @@ class CallBackController extends AbstractController Log::getInstance()->info("微信退款回调处理成功,推送消息"); // 发送推送消息 - try { - // 发送站内、订阅、短信消息-问诊服务退款成功 - $MessagePush = new MessagePush($order_inquiry['user_id'],$order_inquiry['order_inquiry_id']); + if ($inquiry_refund_status == 3){ + try { + // 发送站内、订阅、短信消息-问诊服务退款成功 + $MessagePush = new MessagePush($order_inquiry['user_id'],$order_inquiry['order_inquiry_id']); - // 取消订单原因(1:医生未接诊 2:主动取消 3:无可分配医生 4:客服取消 5:支付超时) - if ($order_inquiry['cancel_reason'] == 1){ - $MessagePush->refundInquirySuccess(1); - } elseif ($order_inquiry['cancel_reason'] == 2){ - $MessagePush->refundInquirySuccess(3); - } elseif ($order_inquiry['cancel_reason'] == 3){ - $MessagePush->refundInquirySuccess(2); + // 取消订单原因(1:医生未接诊 2:主动取消 3:无可分配医生 4:客服取消 5:支付超时) + if ($order_inquiry['cancel_reason'] == 1){ + $MessagePush->refundInquirySuccess(1); + } elseif ($order_inquiry['cancel_reason'] == 2){ + $MessagePush->refundInquirySuccess(3); + } elseif ($order_inquiry['cancel_reason'] == 3){ + $MessagePush->refundInquirySuccess(2); + } + + // 发送站内消息-优惠卷退还 + $MessagePush = new MessagePush($order_inquiry['user_id'],$order_inquiry['order_inquiry_id']); + $MessagePush->patientRefundCoupon(); + + }catch (\Exception $e) { + // 验证失败 + Log::getInstance()->error("微信退款回调处理成功,推送消息失败:" . $e->getMessage()); + return $server->serve(); } - }catch (\Exception $e) { - // 验证失败 - Log::getInstance()->error("微信退款回调处理成功,推送消息失败:" . $e->getMessage()); - return $server->serve(); } + return $server->serve(); } diff --git a/app/Services/InquiryService.php b/app/Services/InquiryService.php index d98b2ec..cf2e8db 100644 --- a/app/Services/InquiryService.php +++ b/app/Services/InquiryService.php @@ -1210,9 +1210,6 @@ class InquiryService extends BaseService $params['user_coupon_id'] = $order_inquiry_coupon['user_coupon_id']; UserCoupon::edit($params, $data); - // 发送站内消息-优惠卷退还 - $MessagePush = new MessagePush($patient_user_id,$order_inquiry_id); - $MessagePush->patientRefundCoupon(); return true; } catch(\Exception $e){ Log::getInstance()->error("退还用户优惠卷失败" . $e->getMessage()); diff --git a/extend/Kuaidi100/Kuaidi.php b/extend/Kuaidi100/Kuaidi.php index e0d70f0..23cffa4 100644 --- a/extend/Kuaidi100/Kuaidi.php +++ b/extend/Kuaidi100/Kuaidi.php @@ -40,12 +40,12 @@ class Kuaidi * @return mixed * @throws GuzzleException */ - protected function httpRequest(string $path, array $arg = []): mixed + protected function httpRequest(string $path, string $arg = []): mixed { $option = [ - "headers" => [ - "sign" => config("ca.app_id"), - "signature" => $this->getRequestSign($arg), + "json" => [ + "schema" => "json", + "param" => json_encode($params, JSON_UNESCAPED_UNICODE), ], ]; @@ -75,8 +75,16 @@ class Kuaidi return $body['body']; } - protected function getSign(string $data){ - $sign = md5($data . config("kuaidi100.key") . config("kuaidi100.customer")); + /** + * 获取签名 + * @param string $params + * @return string + */ + protected function getSign(string $params): string + { + return md5($params . config("kuaidi100.key") . config("kuaidi100.customer")); } + public function + } \ No newline at end of file