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