From 533a02806f6686f733ff47b173e6f72368927742 Mon Sep 17 00:00:00 2001 From: wucongxing8150 <815046773@qq.com> Date: Wed, 26 Jun 2024 09:02:37 +0800 Subject: [PATCH 01/10] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=8F=90=E7=8E=B0?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=20=E5=A2=9E=E5=8A=A0=E5=8F=AF=E6=8F=90?= =?UTF-8?q?=E7=8E=B0=E8=AE=A2=E5=8D=95=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Services/DoctorAccountService.php | 40 +++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/app/Services/DoctorAccountService.php b/app/Services/DoctorAccountService.php index f1cb7c6..f7f4075 100644 --- a/app/Services/DoctorAccountService.php +++ b/app/Services/DoctorAccountService.php @@ -306,6 +306,45 @@ class DoctorAccountService extends BaseService $amount_total = floor($doctor_account['balance_account'] * 100) / 100; } + // 获取可提现订单列表 + $params = array(); + $params['doctor_id'] = $user_info['client_user_id']; + $params['is_withdrawal'] = 0; + + $orders = Order:: getDoctorWithdrawalOrderList($params, $user_doctor['is_platform_deep_cooperation']); + if (empty($orders)){ + // 无订单,账户余额强制赋0; + $amount_total = 0; + } + + $OrderService = new OrderService(); + + // 可提现金额 + $expected_amount_total = 0; + + // 订单号数据 + $order_nos = []; + + foreach ($orders as $order){ + // 获取订单退款金额 + $refund_total = $OrderService->getOrderRefundAmount($order['order_no']); + + // 获取订单可提现金额 + $expected_amount_total = bcadd( + $expected_amount_total, + $OrderService->getOrderWithdrawalAmount($order,$refund_total), + 2 + ); + + $order_nos[] = $order['order_no']; + } + + // 对比订单金额和账户金额;金额相差1元及以上返回错误 + $diff_amount_total = abs($amount_total - $expected_amount_total); + if ($diff_amount_total >= 1){ + return fail(HttpEnumCode::HTTP_ERROR, "提现金额错误"); + } + /* // 获取可提现订单列表 $orders = Order:: getDoctorWithdrawalOrderList($params, $user_doctor['is_platform_deep_cooperation'], ['*']); if (empty($orders)){ @@ -353,6 +392,7 @@ class DoctorAccountService extends BaseService $result['amount_total'] = $amount_total; // 账户余额 $result['withdrawal_amount'] = $withdrawal_amount; // 提现金额 $result['income_tax'] = $income_tax; // 个人所得税 + $result['order_nos'] = $order_nos; // 可提现订单号 return success($result); } From 4100072ffac5bed6534f8a496a08ca263faab5e2 Mon Sep 17 00:00:00 2001 From: wucongxing8150 <815046773@qq.com> Date: Wed, 26 Jun 2024 09:17:32 +0800 Subject: [PATCH 02/10] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=8F=90=E7=8E=B0?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=20=E5=A2=9E=E5=8A=A0=E5=8F=AF=E6=8F=90?= =?UTF-8?q?=E7=8E=B0=E8=AE=A2=E5=8D=95=E5=8F=B71?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Services/OrderService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Services/OrderService.php b/app/Services/OrderService.php index 02db7cf..711c0a5 100644 --- a/app/Services/OrderService.php +++ b/app/Services/OrderService.php @@ -1068,7 +1068,7 @@ class OrderService extends BaseService // 获取订单退款数据 $params = array(); - $params['refund_no'] = $order_no; + $params['order_no'] = $order_no; $order_refunds = OrderRefund::getList($params); if (!empty($order_refunds)) { foreach ($order_refunds as $order_refund) { From 56e484ae2301fa8eb97ad38984b0bf34b64d61a1 Mon Sep 17 00:00:00 2001 From: wucongxing8150 <815046773@qq.com> Date: Wed, 26 Jun 2024 09:47:57 +0800 Subject: [PATCH 03/10] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=8F=90=E7=8E=B0?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=20=E5=A2=9E=E5=8A=A0=E5=8F=AF=E6=8F=90?= =?UTF-8?q?=E7=8E=B0=E8=AE=A2=E5=8D=95=E5=8F=B72?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Services/DoctorAccountService.php | 38 +++++++++++++++++++-------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/app/Services/DoctorAccountService.php b/app/Services/DoctorAccountService.php index f7f4075..414dc87 100644 --- a/app/Services/DoctorAccountService.php +++ b/app/Services/DoctorAccountService.php @@ -665,7 +665,7 @@ class DoctorAccountService extends BaseService } // 验证订单状态 - if ($order_service_package['order_service_status'] != 4 || $order_service_package['order_service_status'] != 5) { + if ($order_service_package['order_service_status'] != 4 && $order_service_package['order_service_status'] != 5) { return fail(HttpEnumCode::HTTP_ERROR, "提现失败"); } @@ -695,19 +695,35 @@ class DoctorAccountService extends BaseService } // 计算本次问诊服务包问诊金额 - $amount_total = bcadd( - (string)$amount_total, - bcsub( - bcmul( - (string)$order_service_package_detail['service_count'], - (string)$order_service_package_detail['single_inquiry_price'], + if ($order['order_type'] == 4){ + // 随访包 + $amount_total = bcadd( + (string)$amount_total, + bcsub( + (string)$order_service_package_detail['service_price'], + $refund_total, 3 ), - $refund_total, 3 - ), - 3 - ); + ); + } + + if ($order['order_type'] == 5){ + // 健康包 + $amount_total = bcadd( + (string)$amount_total, + bcsub( + bcmul( + (string)$order_service_package_detail['service_count'], + (string)$order_service_package_detail['single_inquiry_price'], + 3 + ), + $refund_total, + 3 + ), + 3 + ); + } } } From 4cf3a7f5df7a5dbf163e73433d23b97f2123362e Mon Sep 17 00:00:00 2001 From: wucongxing8150 <815046773@qq.com> Date: Wed, 26 Jun 2024 09:49:38 +0800 Subject: [PATCH 04/10] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=8E=AF=E5=A2=83?= =?UTF-8?q?=E5=8E=BB=E9=99=A4=E6=9C=8D=E5=8A=A1=E5=8C=85=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E9=87=91=E9=A2=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Services/OrderServicePackageService.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Services/OrderServicePackageService.php b/app/Services/OrderServicePackageService.php index 9062272..a858957 100644 --- a/app/Services/OrderServicePackageService.php +++ b/app/Services/OrderServicePackageService.php @@ -447,9 +447,9 @@ class OrderServicePackageService extends BaseService return fail(HttpEnumCode::HTTP_ERROR, "订单创建失败"); } - if (\Hyperf\Config\config("app_env") == "dev"){ - $service_price = 1; - } +// if (\Hyperf\Config\config("app_env") == "dev"){ +// $service_price = 1; +// } Db::beginTransaction(); From 7d978c27bdfafc79d2e50fd8bae01df97c7fae82 Mon Sep 17 00:00:00 2001 From: wucongxing8150 <815046773@qq.com> Date: Wed, 26 Jun 2024 11:52:34 +0800 Subject: [PATCH 05/10] =?UTF-8?q?=E5=8F=91=E8=B5=B7=E6=8F=90=E7=8E=B0?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=20=E9=97=AE=E8=AF=8A=E8=AE=A2=E5=8D=95id?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Services/DoctorAccountService.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/Services/DoctorAccountService.php b/app/Services/DoctorAccountService.php index 414dc87..6a7502c 100644 --- a/app/Services/DoctorAccountService.php +++ b/app/Services/DoctorAccountService.php @@ -814,6 +814,18 @@ class DoctorAccountService extends BaseService $data['withdrawal_id'] = $doctor_withdrawal['withdrawal_id']; $data['doctor_id'] = $user_info['client_user_id']; $data['order_id'] = $order['order_id']; + if ($order['order_type'] == 1){ + // 问诊订单 + $params = array(); + $params['order_id'] = $order['order_id']; + $order_inquiry = OrderInquiry::getOne($params); + if (empty($order_inquiry)){ + Db::rollBack(); + return fail(HttpEnumCode::HTTP_ERROR, "提现失败"); + } + + $data['order_inquiry_id'] = $order_inquiry['order_inquiry_id']; + } $doctor_withdrawal_order = DoctorWithdrawalOrder::addDoctorWithdrawalOrder($data); if (empty($doctor_withdrawal_order)) { Db::rollBack(); From 914ddb5abf36fc1d5b35d1331fa9fa2a4e6004ef Mon Sep 17 00:00:00 2001 From: wucongxing8150 <815046773@qq.com> Date: Wed, 26 Jun 2024 14:18:40 +0800 Subject: [PATCH 06/10] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=BA=86=E5=BE=AE?= =?UTF-8?q?=E4=BF=A1=E6=94=AF=E4=BB=98=20=E5=85=B3=E9=97=AD=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E3=80=82=E5=9C=A8=E5=8F=96=E6=B6=88=E6=9C=AA=E6=94=AF?= =?UTF-8?q?=E4=BB=98=E8=AE=A2=E5=8D=95=E4=B8=AD=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CancelUnpayOrdersDelayDirectConsumer.php | 7 +++ app/Model/Order.php | 1 - extend/Wechat/WechatPay.php | 43 +++++++++++++++++++ 3 files changed, 50 insertions(+), 1 deletion(-) diff --git a/app/Amqp/Consumer/CancelUnpayOrdersDelayDirectConsumer.php b/app/Amqp/Consumer/CancelUnpayOrdersDelayDirectConsumer.php index 064dc92..6e9e1d9 100644 --- a/app/Amqp/Consumer/CancelUnpayOrdersDelayDirectConsumer.php +++ b/app/Amqp/Consumer/CancelUnpayOrdersDelayDirectConsumer.php @@ -19,6 +19,7 @@ use App\Services\OrderProductService; use App\Services\OrderService; use App\Utils\Log; use App\Utils\Utils; +use Extend\Wechat\WechatPay; use Hyperf\Amqp\Message\ConsumerDelayedMessageTrait; use Hyperf\Amqp\Message\ProducerDelayedMessageTrait; use Hyperf\Amqp\Result; @@ -96,6 +97,12 @@ class CancelUnpayOrdersDelayDirectConsumer extends ConsumerMessage return Result::ACK; } + // 关闭支付订单 + $WechatPay = new WechatPay("1", 1); + + // 关闭订单 + $WechatPay->closeOrder($data['order_no']); + Db::commit(); Log::getInstance("queue-CancelUnpayOrders")->info("成功"); return Result::ACK; diff --git a/app/Model/Order.php b/app/Model/Order.php index 6bed845..283f92a 100644 --- a/app/Model/Order.php +++ b/app/Model/Order.php @@ -323,7 +323,6 @@ class Order extends Model ->where($params) ->whereIn('order_type',[1,4,5]); - // 问诊订单 $query = $query->where(function ($query) use ($is_platform_deep_cooperation){ $query->whereExists(function ($subQuery) use ($is_platform_deep_cooperation){ $subQuery->from('order_inquiry'); diff --git a/extend/Wechat/WechatPay.php b/extend/Wechat/WechatPay.php index 18b276c..8c318bf 100644 --- a/extend/Wechat/WechatPay.php +++ b/extend/Wechat/WechatPay.php @@ -250,4 +250,47 @@ class WechatPay throw new BusinessException($e->getMessage(), HttpEnumCode::SERVER_ERROR); } } + + /** + * 关闭订单 + * @param string $out_trade_no 商户系统内部订单号 + * @return array + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + */ + public function closeOrder(string $out_trade_no): array + { + $app = $this->createApp(); + + $options = [ + "mchid" => $this->pay_config['mch_id'], // <---- 商户号 + ]; + + Log::getInstance()->info(json_encode($options,JSON_UNESCAPED_UNICODE)); + try { + $url = "v3/pay/transactions/out-trade-no/" . $out_trade_no . "/close"; + + $response = $app->getClient()->postJson($url, $options); + if ($response->isFailed()) { + // 出错了,处理异常 + $result = $response->toArray(false); + Log::getInstance()->info(json_encode($result,JSON_UNESCAPED_UNICODE)); + if(empty($result)){ + // 返回值为空 + throw new BusinessException("发起支付失败"); + } + if (!empty($result['code'])){ + if ($result['code'] != 400){ + throw new BusinessException($result['message']); + } + }else{ + throw new BusinessException("关闭支付订单失败"); + } + } + + return $response->toArray(false); + } catch (\Exception $e) { + throw new BusinessException($e->getMessage(), HttpEnumCode::SERVER_ERROR); + } + } } \ No newline at end of file From 0fc0b46a0463d45af12e74ceaa00759c549e86b5 Mon Sep 17 00:00:00 2001 From: wucongxing8150 <815046773@qq.com> Date: Wed, 26 Jun 2024 14:51:44 +0800 Subject: [PATCH 07/10] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=82=A3=E8=80=85?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E6=94=AF=E4=BB=98=E6=95=B0=E6=8D=AE=20?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=BC=82=E5=B8=B8=E6=8A=93=E5=8E=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Services/PatientOrderService.php | 89 ++++++++++++++++------------ 1 file changed, 52 insertions(+), 37 deletions(-) diff --git a/app/Services/PatientOrderService.php b/app/Services/PatientOrderService.php index 2abc6dc..c3b3da8 100644 --- a/app/Services/PatientOrderService.php +++ b/app/Services/PatientOrderService.php @@ -769,8 +769,6 @@ class PatientOrderService extends BaseService /** * 获取患者订单支付数据 * @return array - * @throws ContainerExceptionInterface - * @throws NotFoundExceptionInterface */ public function getPatientOrderPayInfo(): array { @@ -854,17 +852,22 @@ class PatientOrderService extends BaseService $result['discount_amount'] = 0; // 优惠金额 if ($order_inquiry['payment_amount_total'] > 0) { - // 发起支付 - $WechatPay = new WechatPay(1, 1); + try { + // 发起支付 + $WechatPay = new WechatPay(1, 1); - // 获取预支付交易会话标识 - $prepay = $WechatPay->getJsapiPrepayId($order_no, (int)round($order_inquiry['payment_amount_total'] * 100), $user_info['open_id'], "问诊服务"); - if (empty($prepay)) { - return fail(HttpEnumCode::SERVER_ERROR); + // 获取预支付交易会话标识 + $prepay = $WechatPay->getJsapiPrepayId($order_no, (int)round($order_inquiry['payment_amount_total'] * 100), $user_info['open_id'], "问诊服务"); + if (empty($prepay)) { + return fail(HttpEnumCode::SERVER_ERROR); + } + + // 获取小程序支付配置 + $pay_config = $WechatPay->getAppletsPayConfig($prepay['prepay_id']); + }catch (\Throwable $e){ + return fail(HttpEnumCode::SERVER_ERROR, $e->getMessage()); } - // 获取小程序支付配置 - $pay_config = $WechatPay->getAppletsPayConfig($prepay['prepay_id']); } } @@ -966,17 +969,21 @@ class PatientOrderService extends BaseService }*/ if ($order_product['payment_amount_total'] > 0) { - // 发起支付 - $WechatPay = new WechatPay(1, 2); + try { + // 发起支付 + $WechatPay = new WechatPay(1, 2); - // 获取预支付交易会话标识 - $prepay = $WechatPay->getJsapiPrepayId($order_no, (int)round($order_product['payment_amount_total'] * 100), $user_info['open_id'], "问诊服务"); - if (empty($prepay)) { - return fail(HttpEnumCode::SERVER_ERROR); + // 获取预支付交易会话标识 + $prepay = $WechatPay->getJsapiPrepayId($order_no, (int)round($order_product['payment_amount_total'] * 100), $user_info['open_id'], "问诊服务"); + if (empty($prepay)) { + return fail(HttpEnumCode::SERVER_ERROR); + } + + // 获取小程序支付配置 + $pay_config = $WechatPay->getAppletsPayConfig($prepay['prepay_id']); + }catch (\Throwable $e){ + return fail(HttpEnumCode::SERVER_ERROR, $e->getMessage()); } - - // 获取小程序支付配置 - $pay_config = $WechatPay->getAppletsPayConfig($prepay['prepay_id']); } } @@ -1035,17 +1042,21 @@ class PatientOrderService extends BaseService $result['discount_amount'] = 0; if ($order_detection['payment_amount_total'] > 0) { - // 发起支付 - $WechatPay = new WechatPay(1, 3); + try { + // 发起支付 + $WechatPay = new WechatPay(1, 3); - // 获取预支付交易会话标识 - $prepay = $WechatPay->getJsapiPrepayId($order_no, (int)round($order_detection['payment_amount_total'] * 100), $user_info['open_id'], "检测服务"); - if (empty($prepay)) { - return fail(HttpEnumCode::SERVER_ERROR); + // 获取预支付交易会话标识 + $prepay = $WechatPay->getJsapiPrepayId($order_no, (int)round($order_detection['payment_amount_total'] * 100), $user_info['open_id'], "检测服务"); + if (empty($prepay)) { + return fail(HttpEnumCode::SERVER_ERROR); + } + + // 获取小程序支付配置 + $pay_config = $WechatPay->getAppletsPayConfig($prepay['prepay_id']); + }catch (\Throwable $e){ + return fail(HttpEnumCode::SERVER_ERROR, $e->getMessage()); } - - // 获取小程序支付配置 - $pay_config = $WechatPay->getAppletsPayConfig($prepay['prepay_id']); } } @@ -1148,17 +1159,21 @@ class PatientOrderService extends BaseService } if ($order_service_package['payment_amount_total'] > 0) { - // 发起支付 - $WechatPay = new WechatPay(1, 4); + try { + // 发起支付 + $WechatPay = new WechatPay(1, 4); - // 获取预支付交易会话标识 - $prepay = $WechatPay->getJsapiPrepayId($order_no, (int)round($order_service_package['payment_amount_total'] * 100), $user_info['open_id'], "检测服务"); - if (empty($prepay)) { - return fail(HttpEnumCode::SERVER_ERROR); + // 获取预支付交易会话标识 + $prepay = $WechatPay->getJsapiPrepayId($order_no, (int)round($order_service_package['payment_amount_total'] * 100), $user_info['open_id'], "检测服务"); + if (empty($prepay)) { + return fail(HttpEnumCode::SERVER_ERROR); + } + + // 获取小程序支付配置 + $pay_config = $WechatPay->getAppletsPayConfig($prepay['prepay_id']); + }catch (\Throwable $e){ + return fail(HttpEnumCode::SERVER_ERROR, $e->getMessage()); } - - // 获取小程序支付配置 - $pay_config = $WechatPay->getAppletsPayConfig($prepay['prepay_id']); } } From e2847b50796285be60057f3ec5e5c8ee8914f1a7 Mon Sep 17 00:00:00 2001 From: wucongxing8150 <815046773@qq.com> Date: Wed, 26 Jun 2024 14:54:50 +0800 Subject: [PATCH 08/10] 1 --- extend/Wechat/WechatPay.php | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/extend/Wechat/WechatPay.php b/extend/Wechat/WechatPay.php index 8c318bf..89c8723 100644 --- a/extend/Wechat/WechatPay.php +++ b/extend/Wechat/WechatPay.php @@ -271,20 +271,21 @@ class WechatPay $url = "v3/pay/transactions/out-trade-no/" . $out_trade_no . "/close"; $response = $app->getClient()->postJson($url, $options); - if ($response->isFailed()) { - // 出错了,处理异常 - $result = $response->toArray(false); - Log::getInstance()->info(json_encode($result,JSON_UNESCAPED_UNICODE)); - if(empty($result)){ - // 返回值为空 - throw new BusinessException("发起支付失败"); - } - if (!empty($result['code'])){ - if ($result['code'] != 400){ - throw new BusinessException($result['message']); + if (!empty($response)){ + if ($response->isFailed()) { + // 出错了,处理异常 + $result = $response->toArray(false); + if(empty($result)){ + // 返回值为空 + throw new BusinessException("关闭支付订单失败"); + } + if (!empty($result['code'])){ + if ($result['code'] != 400){ + throw new BusinessException($result['message']); + } + }else{ + throw new BusinessException("关闭支付订单失败"); } - }else{ - throw new BusinessException("关闭支付订单失败"); } } From 347f5d2891cf654c00be59d1e3f608b3ca398963 Mon Sep 17 00:00:00 2001 From: wucongxing8150 <815046773@qq.com> Date: Wed, 26 Jun 2024 14:58:30 +0800 Subject: [PATCH 09/10] 2 --- .../CancelUnpayOrdersDelayDirectConsumer.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/Amqp/Consumer/CancelUnpayOrdersDelayDirectConsumer.php b/app/Amqp/Consumer/CancelUnpayOrdersDelayDirectConsumer.php index 6e9e1d9..3591f5b 100644 --- a/app/Amqp/Consumer/CancelUnpayOrdersDelayDirectConsumer.php +++ b/app/Amqp/Consumer/CancelUnpayOrdersDelayDirectConsumer.php @@ -98,10 +98,16 @@ class CancelUnpayOrdersDelayDirectConsumer extends ConsumerMessage } // 关闭支付订单 - $WechatPay = new WechatPay("1", 1); + try { + $WechatPay = new WechatPay("1", 1); + + // 关闭订单 + $WechatPay->closeOrder($data['order_no']); + }catch (\Throwable $e){ + Log::getInstance("queue-CancelUnpayOrders")->error($e->getMessage()); + } + - // 关闭订单 - $WechatPay->closeOrder($data['order_no']); Db::commit(); Log::getInstance("queue-CancelUnpayOrders")->info("成功"); From 7839cbe073ef4c0703fe34d8cb3caf487d70bac7 Mon Sep 17 00:00:00 2001 From: wucongxing8150 <815046773@qq.com> Date: Wed, 26 Jun 2024 15:07:49 +0800 Subject: [PATCH 10/10] 333 --- extend/Wechat/WechatPay.php | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/extend/Wechat/WechatPay.php b/extend/Wechat/WechatPay.php index 89c8723..176d614 100644 --- a/extend/Wechat/WechatPay.php +++ b/extend/Wechat/WechatPay.php @@ -254,11 +254,10 @@ class WechatPay /** * 关闭订单 * @param string $out_trade_no 商户系统内部订单号 - * @return array * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ - public function closeOrder(string $out_trade_no): array + public function closeOrder(string $out_trade_no): void { $app = $this->createApp(); @@ -270,27 +269,8 @@ class WechatPay try { $url = "v3/pay/transactions/out-trade-no/" . $out_trade_no . "/close"; - $response = $app->getClient()->postJson($url, $options); - if (!empty($response)){ - if ($response->isFailed()) { - // 出错了,处理异常 - $result = $response->toArray(false); - if(empty($result)){ - // 返回值为空 - throw new BusinessException("关闭支付订单失败"); - } - if (!empty($result['code'])){ - if ($result['code'] != 400){ - throw new BusinessException($result['message']); - } - }else{ - throw new BusinessException("关闭支付订单失败"); - } - } - } - - return $response->toArray(false); - } catch (\Exception $e) { + $app->getClient()->postJson($url, $options); + } catch (\Throwable $e) { throw new BusinessException($e->getMessage(), HttpEnumCode::SERVER_ERROR); } }