From 4f5667bba2c846cbbcdaa74586dbda3188c29fe4 Mon Sep 17 00:00:00 2001 From: Rmiku <46063139+Rmiku@users.noreply.github.com> Date: Fri, 24 Jan 2025 17:56:56 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=85=8D=E7=BD=AE=E6=94=AF=E4=BB=98?= =?UTF-8?q?=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Dictionary/Order/Type.php | 18 ++++++ app/Http/Logics/Notify/NotifyLogic.php | 4 +- app/Http/Logics/Outpatient/PaymentLogic.php | 12 ++-- .../Logics/Registration/RegisterLogic.php | 6 +- config/payment.php | 57 ------------------- config/unify.php | 10 ++-- .../unify_payment/src/Cores/BasicClient.php | 2 +- .../src/Modules/Pay/MiniProgramClient.php | 2 +- .../src/Modules/Pay/OfficialAccountClient.php | 2 +- 9 files changed, 37 insertions(+), 76 deletions(-) delete mode 100644 config/payment.php diff --git a/app/Dictionary/Order/Type.php b/app/Dictionary/Order/Type.php index 501298d..c5a9020 100644 --- a/app/Dictionary/Order/Type.php +++ b/app/Dictionary/Order/Type.php @@ -41,4 +41,22 @@ enum Type: int self::INPATIENT_PREPAID_CARD_REFUND => '住院预交金退费' }; } + + /** + * 支付平台订单类型 + * @return string + */ + public function unifyOrderType(): string + { + return match ($this) { + self::TODAY_REGISTRATION => 'A', + self::APPOINTMENT_REGISTRATION => 'F', + self::OUTPATIENT_PAYMENT => 'B', + self::INPATIENT_RECHARGE => 'E', + self::OUTPATIENT_PREPAID_CARD_RECHARGE, + self::INPATIENT_PREPAID_CARD_RECHARGE, + self::OUTPATIENT_PREPAID_CARD_REFUND, + self::INPATIENT_PREPAID_CARD_REFUND => 'H' + }; +} } diff --git a/app/Http/Logics/Notify/NotifyLogic.php b/app/Http/Logics/Notify/NotifyLogic.php index 2322350..818bab3 100644 --- a/app/Http/Logics/Notify/NotifyLogic.php +++ b/app/Http/Logics/Notify/NotifyLogic.php @@ -249,7 +249,7 @@ class NotifyLogic { try { $refund = new RefundOrder($order_id, $refund_order_id, (string)($refund_fee / 100), '确认挂号失败,自动冲正,错误消息:'. $refund_reason); - $response = Unify::common(config('unify'))->order->setMockHandler([new RefundOrderHandler(true)])->refund($refund); + $response = Unify::common(config('unify'))->order->refund($refund); $this->info('退号退费结果', $response); if ($response['status'] === 200 || $response['success'] === true) { @@ -337,7 +337,7 @@ class NotifyLogic { try { $query_order = new QueryOrder($order_id); - $response = Unify::common(config('unify'))->order->setMockHandler([new QueryOrderHandler(true)])->query($query_order); + $response = Unify::common(config('unify'))->order->query($query_order); $this->info('支付平台查询结果', $response); if ($response['status'] === 200 && $response['success'] === true) { diff --git a/app/Http/Logics/Outpatient/PaymentLogic.php b/app/Http/Logics/Outpatient/PaymentLogic.php index 8faa441..3f11862 100644 --- a/app/Http/Logics/Outpatient/PaymentLogic.php +++ b/app/Http/Logics/Outpatient/PaymentLogic.php @@ -199,27 +199,27 @@ class PaymentLogic * 申请支付 * @param Type $order_type * @param string $order_id - * @param float $reg_fee + * @param float $total_fee * @param string $patient_id * @param string $patient_name * @return array * @throws GeneralException */ - protected function applyPayment(Type $order_type, string $order_id, float $reg_fee, string $patient_id, string $patient_name): array + protected function applyPayment(Type $order_type, string $order_id, float $total_fee, string $patient_id, string $patient_name): array { try { $order_obj = new CreateOrder( $order_type->label(), $order_id, - (string) $reg_fee, - '1', + (string) $total_fee, + 'tag001', $patient_id. '|'. $patient_name, - 'A', + $order_type->unifyOrderType(), $this->open_id, url('/Api/Notify', [], true) ); - $response = Unify::pay(config('unify'))->mini->setMockHandler([new CreateOrderHandler(true)])->jsapi($order_obj); + $response = Unify::pay(config('unify'))->mini->jsapi($order_obj); $this->info('jsapi 支付参数', $response); if (!$response['success'] || empty($response['response'])) { diff --git a/app/Http/Logics/Registration/RegisterLogic.php b/app/Http/Logics/Registration/RegisterLogic.php index f5cf043..f8f6510 100644 --- a/app/Http/Logics/Registration/RegisterLogic.php +++ b/app/Http/Logics/Registration/RegisterLogic.php @@ -295,14 +295,14 @@ class RegisterLogic $order_type->label(), $order_id, (string) $reg_fee, - '1', + 'tag001', $patient_id. '|'. $patient_name, - 'A', + $order_type->unifyOrderType(), $this->open_id, url('/Api/Notify', [], true) ); - $response = Unify::pay(config('unify'))->mini->setMockHandler([new CreateOrderHandler(true)])->jsapi($order_obj); + $response = Unify::pay(config('unify'))->mini->jsapi($order_obj); $this->info('jsapi 支付参数', $response); if (!$response['success'] && empty($response['response'])) { diff --git a/config/payment.php b/config/payment.php deleted file mode 100644 index a74ff89..0000000 --- a/config/payment.php +++ /dev/null @@ -1,57 +0,0 @@ - 120, - - // 微信 - 'wechat' => [ - // 公众号 APPID - 'app_id' => '', - - // 小程序 APPID - 'miniapp_id' => '', - - // APP 引用的 APPID - 'appid' => '', - - // 子商户 APP APPID - 'sub_appid' => '', - - // 微信支付分配的微信商户号 - 'mch_id' => '', - - // 子商户商户号 - 'sub_mch_id' => '', - - // 微信支付异步通知地址 - 'notify_url' => '', - - // 微信支付签名秘钥 - 'key' => 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCB', - - // 客户端证书路径,退款、红包等需要用到。请填写绝对路径,linux 请确保权限问题。pem 格式。 - 'cert_client' => base_path('pem'. DIRECTORY_SEPARATOR. 'apiclient_cert.pem'), - - // 客户端秘钥路径,退款、红包等需要用到。请填写绝对路径,linux 请确保权限问题。pem 格式。 - 'cert_key' => base_path('pem'. DIRECTORY_SEPARATOR. 'apiclient_key.pem'), - - // optional 服务商模式 - 'mode' => 'service', - - // optional,默认 warning;日志路径为:sys_get_temp_dir().'/logs/yansongda.pay.log' - 'log' => [ // optional - 'file' => storage_path('/logs/wechat.log'), - 'level' => 'info', // 建议生产环境等级调整为 info,开发环境为 debug - 'type' => 'daily', // optional, 可选 daily, daily 时将按时间自动划分文件. - ], - - // http, 请求option配置 更多配置项请参考 Guzzle 文档 - 'http' => [ - 'verify' => false, - 'timeout' => 20, // 超时时间 20s - 'connect_timeout' => 5.0, // 连接时间 5s - ], - ], - -]; diff --git a/config/unify.php b/config/unify.php index 063daa5..d960f26 100644 --- a/config/unify.php +++ b/config/unify.php @@ -16,9 +16,9 @@ return [ | apiSecret: 应用秘钥 | */ - 'domain' => 'http://fangding.picp.vip:5025', + 'domain' => 'http://fangding.picp.vip:7878/', - 'apiSecret' => '123456', + 'apiSecret' => '16f62721-c156-4514-8743-bd969bed32af', /* |-------------------------------------------------------------------------- @@ -36,11 +36,11 @@ return [ 'channels' => [ 'default' => [ - 'merchantId' => 'QY2Y20230301', - 'secret' => 'af4d32227ed4d63e1bb8726ebd0b6110', + 'merchantId' => 'ZHXZEY20250124', + 'secret' => '94aaadd840a3b97c6bbee4f440b986ce', 'channelId' => 'FD001', 'operatorId' => [ - 'wx001', + 'MN001', ], ] diff --git a/packagist/unify_payment/src/Cores/BasicClient.php b/packagist/unify_payment/src/Cores/BasicClient.php index 843337f..514d64d 100644 --- a/packagist/unify_payment/src/Cores/BasicClient.php +++ b/packagist/unify_payment/src/Cores/BasicClient.php @@ -283,4 +283,4 @@ class BasicClient return $response; } -} \ No newline at end of file +} diff --git a/packagist/unify_payment/src/Modules/Pay/MiniProgramClient.php b/packagist/unify_payment/src/Modules/Pay/MiniProgramClient.php index 9556866..8968e58 100644 --- a/packagist/unify_payment/src/Modules/Pay/MiniProgramClient.php +++ b/packagist/unify_payment/src/Modules/Pay/MiniProgramClient.php @@ -32,4 +32,4 @@ class MiniProgramClient extends BasicClient return $this->request('post', '/index.php/api/pay/miniapp'); } -} \ No newline at end of file +} diff --git a/packagist/unify_payment/src/Modules/Pay/OfficialAccountClient.php b/packagist/unify_payment/src/Modules/Pay/OfficialAccountClient.php index 6eebb80..f1d78ce 100644 --- a/packagist/unify_payment/src/Modules/Pay/OfficialAccountClient.php +++ b/packagist/unify_payment/src/Modules/Pay/OfficialAccountClient.php @@ -31,4 +31,4 @@ class OfficialAccountClient extends BasicClient return $this->request('post', '/index.php/api/pay/mp'); } -} \ No newline at end of file +}