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 @@