Anyon пре 4 година
родитељ
комит
9ca2c6e816

+ 0 - 15
app/data/controller/api/Data.php

@@ -22,19 +22,4 @@ class Data extends Controller
         $data = sysdata(input('keys', 'slider'));
         $this->success('获取轮播图片数据', $data);
     }
-
-    /**
-     * 获取支付通道数据
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     */
-    public function getPayment()
-    {
-        $map = ['status' => 1, 'deleted' => 0];
-        $query = $this->app->db->name('DataPayment')->where($map);
-        $result = $query->order('sort desc,id desc')->field('id,name,type')->select();
-        $this->success('获取支付通道数据', $result->toArray());
-    }
-
 }

+ 32 - 0
app/data/controller/api/auth/Config.php

@@ -0,0 +1,32 @@
+<?php
+
+namespace app\data\controller\api\auth;
+
+use app\data\controller\api\Auth;
+use app\data\service\PaymentService;
+
+/**
+ * 接口数据配置
+ * Class Config
+ * @package app\data\controller\api\auth
+ */
+class Config extends Auth
+{
+    /**
+     * 获取支付通道数据
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     */
+    public function getPayment()
+    {
+        $types = [];
+        foreach (PaymentService::TYPES as $type => $arr) {
+            if (in_array($this->type, $arr['auth'])) $types[] = $type;
+        }
+        $map = ['status' => 1, 'deleted' => 0];
+        $query = $this->app->db->name('DataPayment')->where($map)->whereIn('type', $types);
+        $result = $query->order('sort desc,id desc')->field('id,name,type,create_at')->select();
+        $this->success('获取支付通道数据', $result->toArray());
+    }
+}

+ 12 - 3
app/data/service/PaymentService.php

@@ -23,9 +23,18 @@ abstract class PaymentService extends Service
 
     // 支付通道描述
     const TYPES = [
-        PaymentService::PAYMENT_WECHAT_JSAPI => '微信商户支付',
-        PaymentService::PAYMENT_JOINPAY_XCX  => '汇聚小程序支付',
-        PaymentService::PAYMENT_JOINPAY_GZH  => '汇聚服务号支付',
+        PaymentService::PAYMENT_JOINPAY_XCX  => [
+            'name' => '汇聚小程序支付',
+            'auth' => [UserService::APITYPE_WXAPP],
+        ],
+        PaymentService::PAYMENT_JOINPAY_GZH  => [
+            'name' => '汇聚服务号支付',
+            'auth' => 'UserService::APITYPE_WECHAT',
+        ],
+        PaymentService::PAYMENT_WECHAT_JSAPI => [
+            'name' => '微信商户支付',
+            'auth' => [UserService::APITYPE_WXAPP, UserService::APITYPE_WECHAT],
+        ],
     ];
 
     /**

+ 2 - 2
app/data/view/payment/form.html

@@ -17,9 +17,9 @@
                 {foreach $types as $k => $v}
                 <label class="think-radio notselect">
                     {if $vo.type eq $k}
-                    <input data-payment-type checked type="radio" name="type" value="{$k}" lay-ignore> {$v}
+                    <input data-payment-type checked type="radio" name="type" value="{$k}" lay-ignore> {$v.name}
                     {else}
-                    <input data-payment-type type="radio" name="type" value="{$k}" lay-ignore> {$v}
+                    <input data-payment-type type="radio" name="type" value="{$k}" lay-ignore> {$v.name}
                     {/if}
                 </label>
                 {/foreach}

+ 1 - 1
app/data/view/payment/index.html

@@ -40,7 +40,7 @@
                 <label><input data-action-blur="{:request()->url()}" data-value="id#{$vo.id};action#sort;sort#{value}" data-loading="false" value="{$vo.sort}" class="list-sort-input"></label>
             </td>
             <td class="text-left nowrap">{$vo.name|default=''}</td>
-            <td class="text-left nowrap">{$types[$vo.type]??$vo.type}</td>
+            <td class="text-left nowrap">{$types[$vo.type]['name']??$vo.type}</td>
             <td>{if $vo.status eq 0}<span class="color-red">已禁用</span>{elseif $vo.status eq 1}<span class="color-green">已激活</span>{/if}</td>
             <td class="text-left nowrap">{$vo.create_at|format_datetime}</td>
             <td class='text-left nowrap'>

+ 2 - 2
app/data/view/payment/index_search.html

@@ -14,9 +14,9 @@
                     <option value="">-- 全部 --</option>
                     {foreach $types as $k=>$v}
                     {if $k eq input('type')}
-                    <option selected value="{$k}">{$v}</option>
+                    <option selected value="{$k}">{$v.name}</option>
                     {else}
-                    <option value="{$k}">{$v}</option>
+                    <option value="{$k}">{$v.name}</option>
                     {/if}{/foreach}
                 </select>
             </div>