From 0fdd3dc6abbab35aab68da099cbe0c2d28e6f31d Mon Sep 17 00:00:00 2001 From: manghe Date: Fri, 21 Mar 2025 20:21:14 +0000 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/Config.php | 18 ++++ app/admin/view/Config/systemconfig.html | 110 ++++++++++++----------- app/admin/view/Config/weixinpay.html | 113 +++++++++++++++++++++++- app/api/controller/Pay.php | 37 +++++++- app/common.php | 23 ++++- app/common/helper/WxPayHelper.php | 63 +++++++++++++ app/common/server/WechatRefund.php | 43 ++++++--- config/menu.php | 21 ++--- 8 files changed, 343 insertions(+), 85 deletions(-) diff --git a/app/admin/controller/Config.php b/app/admin/controller/Config.php index a14bce0..74250a5 100755 --- a/app/admin/controller/Config.php +++ b/app/admin/controller/Config.php @@ -31,6 +31,7 @@ class Config extends Base 'name' => '默认商户', 'mch_id' => $old_config['mch_id'] ?? '', 'keys' => $old_config['keys'] ?? '', + 'order_prefix' => $old_config['order_prefix'] ?? 'MYH', 'weight' => 1 ] ] @@ -92,6 +93,23 @@ class Config extends Base $data = input("post."); $data['update_time'] = time(); + // 处理微信支付商户前缀验证 + if ($data['key'] == 'weixinpay_setting' && isset($data['merchants']) && is_array($data['merchants'])) { + // 检查前缀的唯一性 + $prefixes = []; + foreach ($data['merchants'] as $index => $merchant) { + if (empty($merchant['order_prefix']) || strlen($merchant['order_prefix']) !== 3) { + return $this->renderError('商户前缀必须是3位字符'); + } + + if (in_array($merchant['order_prefix'], $prefixes)) { + return $this->renderError('商户前缀"'.$merchant['order_prefix'].'"重复,每个商户的前缀必须唯一'); + } + + $prefixes[] = $merchant['order_prefix']; + } + } + // 处理同步地址数据格式 if ($data['key'] == 'systemconfig') { $syncAddresses = []; diff --git a/app/admin/view/Config/systemconfig.html b/app/admin/view/Config/systemconfig.html index 30c63a2..b0f7cc3 100755 --- a/app/admin/view/Config/systemconfig.html +++ b/app/admin/view/Config/systemconfig.html @@ -4,60 +4,7 @@

系统设置

-
-
-
盒子同步地址
-
-
- -
- -
-
- {if isset($data.sync_address) && is_array($data.sync_address)} - {foreach $data.sync_address as $index => $address} -
-
- -
-
- -
- -
- {/foreach} - {else} -
-
- -
-
- -
- -
- {/if} -
-
- - -
-
-
-
-
-
-
+
@@ -126,6 +73,61 @@
+
+
+
盒子同步地址
+
+
+ +
+ +
+
+ {if isset($data.sync_address) && is_array($data.sync_address)} + {foreach $data.sync_address as $index => $address} +
+
+ +
+
+ +
+ +
+ {/foreach} + {else} +
+
+ +
+
+ +
+ +
+ {/if} +
+
+ + +
+
+
+
+
+
+
+
微信公众号设置
diff --git a/app/admin/view/Config/weixinpay.html b/app/admin/view/Config/weixinpay.html index c3b109e..cc23fb8 100755 --- a/app/admin/view/Config/weixinpay.html +++ b/app/admin/view/Config/weixinpay.html @@ -14,7 +14,7 @@
- 微信Appid和AppSecret已移至系统设置页面,请在那里设置 + 微信Appid和AppSecret已移至系统设置页面,请在那里设置。ps:权重越高,支付几率越多。订单前缀必填,用于区分哪一个商户号支付的。
@@ -41,6 +41,12 @@
+
+ +
+ +
+
@@ -71,6 +77,12 @@
+
+ +
+ +
+
@@ -101,6 +113,56 @@