Browse Source

fix:优化后台

super-yimizi 2 months ago
parent
commit
dd1a645aaa

+ 1 - 1
application/api/controller/Pay.php

@@ -141,7 +141,7 @@ class Pay extends Base
             'total_amount' => $payModel->pay_fee,      // 剩余支付金额
             'total_amount' => $payModel->pay_fee,      // 剩余支付金额
         ];
         ];
         // 微信公众号,小程序支付,必须有 openid
         // 微信公众号,小程序支付,必须有 openid
-        if ($payment == 'wechat' || $payment == 'douyin'    ) {
+        if ($payment == 'wechat') {
 
 
             if (in_array($platform, ['WechatOfficialAccount', 'WechatMiniProgram','DouyinMiniProgram'])) {
             if (in_array($platform, ['WechatOfficialAccount', 'WechatMiniProgram','DouyinMiniProgram'])) {
                 if (isset($openid) && $openid) {
                 if (isset($openid) && $openid) {

+ 0 - 5
application/common/Service/Pay/PayService.php

@@ -35,11 +35,6 @@ class PayService
             throw new BusinessException('缺少用户端平台参数');
             throw new BusinessException('缺少用户端平台参数');
         }
         }
 
 
-        // 验证渠道参数
-        if ($this->channel && !ChannelEnum::isValidChannel($this->channel)) {
-            throw new BusinessException('无效的渠道参数: ' . $this->channel);
-        }
-
         // 验证支付方式
         // 验证支付方式
         if (!in_array($payment, ['wechat', 'alipay','douyin'])) {
         if (!in_array($payment, ['wechat', 'alipay','douyin'])) {
             throw new BusinessException('不支持的支付方式: ' . $payment);
             throw new BusinessException('不支持的支付方式: ' . $payment);

+ 17 - 2
application/common/Service/Pay/Provider/Base.php

@@ -106,13 +106,28 @@ class Base
     }
     }
 
 
     /**
     /**
+     * 转换平台名称格式
+     * 将前端驼峰命名转换为后端下划线格式
+     *
+     * @param string $platform
+     * @return string
+     */
+    protected function convertPlatformName($platform)
+    {
+        // 将驼峰命名转换为下划线格式
+        return strtolower(preg_replace('/([A-Z])/', '_$1', lcfirst($platform)));
+    }
+
+    /**
      * 获取平台配置参数
      * 获取平台配置参数
      *
      *
      * @return array
      * @return array
      */
      */
     protected function getPlatformConfig()
     protected function getPlatformConfig()
     {
     {
-        $platformConfig = ShopConfigService::getConfigs('shop.platform.' . $this->platform);
+        // 需要转换   前段穿 DouyinMiniProgram  后端配置是   douyin_mini_program
+        $platformKey = $this->convertPlatformName($this->platform);
+        $platformConfig = ShopConfigService::getConfigs('shop.platform.' . $platformKey);
 
 
         $paymentConfig = $platformConfig['payment'] ?? [];
         $paymentConfig = $platformConfig['payment'] ?? [];
         $app_id = $platformConfig['app_id'] ?? '';
         $app_id = $platformConfig['app_id'] ?? '';
@@ -167,7 +182,7 @@ class Base
                 'App' => 'app'                      //APP 支付 JsonResponse
                 'App' => 'app'                      //APP 支付 JsonResponse
             ],
             ],
             'douyin' => [
             'douyin' => [
-                'douyin_mini_program' => 'mini',       //小程序支付 Collection
+                'DouyinMiniProgram' => 'mini',       //小程序支付 Collection
             ],
             ],
         ];
         ];
         return $method[$payment][$this->platform];
         return $method[$payment][$this->platform];