Browse Source

Merge branch 'liuzj-pay-dev' into test

liuzejian 1 year ago
parent
commit
c25fec0753

+ 20 - 5
modules/Common/config/common.php

@@ -21,15 +21,30 @@ return [
      * 支付方式
      */
     'payType' => [
-        'palmpay' => '易宝支付',
-        'wechatpay' => '微信原生支付',
-        'tiktokpay' => '抖音支付'
+        [
+            'key' => 1,
+            'val' => '易宝支付',
+        ],
+        [
+            'key' => 2,
+            'val' => '微信原生支付',
+        ],
+        [
+            'key' => 3,
+            'val' => '抖音支付'
+        ],
     ],
     /**
      * 小程序类型
      */
     'miniprogramType' => [
-        'wechat' => '微信',
-        'tiktok' => '抖音'
+        [
+            'key' => 1,
+            'val' => '微信'
+        ],
+        [
+            'key' => 2,
+            'val' => '抖音'
+        ]
     ],
 ];

+ 9 - 6
modules/Manage/Http/Controllers/PayConfigController.php

@@ -20,8 +20,8 @@ class PayConfigController extends CatchController
     public function list(Request $request) {
         $this->validate($request,[
             'name' => 'nullable|string|max:256',
-            'pay_type' => 'nullable|string|in:palmpay,wechatpay,tiktokpay',
-            'miniprogram_type' => 'nullable|string|in:wechat,tiktok',
+            'pay_type' => 'nullable|in:1,2,3',
+            'miniprogram_type' => 'nullable|in:1,2',
             'remark' => 'nullable|string|max:256',
             'pay_appid' => 'nullable|string|max:256',
         ]);
@@ -53,9 +53,11 @@ class PayConfigController extends CatchController
             $result =  $sql->paginate($request->input('limit', 15));
         }
 
+        $payTypeMap = collect($commonConfig['payType'])->keyBy('key');
+        $miniprogramTypeMap = collect($commonConfig['miniprogramType'])->keyBy('key');
         foreach ($result as $item) {
-            $item->pay_type_str = $commonConfig['payType'][$item->pay_type] ?? '';
-            $item->miniprogram_type_str = $commonConfig['miniprogramType'][$item->miniprogram_type] ?? '';
+            $item->pay_type_str = $payTypeMap[$item->pay_type]['val'] ?? '';
+            $item->miniprogram_type_str = $miniprogramTypeMap[$item->miniprogram_type]['val'] ?? '';
         }
 
         return $result;
@@ -84,14 +86,15 @@ class PayConfigController extends CatchController
             'name' => 'required|string|max:256',
             'payee_name' => 'required|string|max:256',
             'pay_appid' => 'required',
-            'pay_type' => 'required|string|in:palmpay,wechatpay,tiktokpay',
+            'pay_type' => 'required|integer|in:1,2,3',
             'pay_common_params' => 'required',
-            'miniprogram_type' => 'required|in:wechat,tiktok',
+            'miniprogram_type' => 'required|in:1,2',
             'remark' => 'nullable|string|max:256'
         ]);
         $data = $request->only(['name', 'payee_name', 'pay_appid', 'pay_type', 'miniprogram_type']);
         $now = date('Y-m-d H:i:s');
         $data['created_at'] = $data['updated_at'] = $now;
+        $data['pay_common_params'] = \json_encode($request->input('pay_common_params', []));
         $data['remark'] = $request->input('remark', '');
             DB::table('pay_merchants')
             ->insert($data);

+ 1 - 1
tests/Common/Http/Controllers/OptionControllerTest.php

@@ -14,7 +14,7 @@ class OptionControllerTest extends UsedTestCase
         $res = $this->withHeaders([
             'Authorization' => 'Bearer '. $this->token,
         ])->json('get','http://localhost/api/options/CommonParams');
-//        $res->dump();
+        $res->dump();
         $this->dumpJson($res);
     }
 }

+ 1 - 0
tests/Manage/Http/Controllers/PayConfigControllerTest.php

@@ -44,6 +44,7 @@ class PayConfigControllerTest extends UsedTestCase
         $res = $this->withHeaders([
             'Authorization' => 'Bearer '. $this->token,
         ])->json('get','http://localhost/api/manage/payConfig/list', [
+
             'pay_appid' => '12342142412'
         ]);
         $res->dump();