浏览代码

Merge branch 'stable' of 121.36.198.49:zy_duanju/duanju_manage

zhaoyang 1 年之前
父节点
当前提交
a46847dbe5

+ 0 - 4
app/Exceptions/Handler.php

@@ -65,10 +65,6 @@ class Handler extends ExceptionHandler
     public function render($request, Throwable $e): JsonResponse|Response
     {
         $message = $e->getMessage();
-        echo "<pre><hr>";
-        var_export($message);
-        echo  "<hr>";
-        die();
         if (method_exists($e, 'getStatusCode')) {
             if ($e->getStatusCode() == Response::HTTP_NOT_FOUND) {
                 $message = '路由未找到或未注册';

+ 3 - 2
modules/Callback/Http/Controllers/CallbackLogController.php

@@ -42,15 +42,16 @@ class CallbackLogController extends CatchController
             })->when($userRanseStartAtBeginTime, function ($query, $userRanseStartAtBeginTime){
                 return $query->where('user_ranse_start_at', '>=', $userRanseStartAtBeginTime);
             })->when($userRanseStartAtEndTime, function ($query, $userRanseStartAtEndTime){
-                return $query->where('user_ranse_start_at', '<=', $userRanseStartAtEndTime);
+                return $query->where('user_ranse_start_at', '<=', $userRanseStartAtEndTime . ' 23:59:59');
             })->when($orderCreatedAtBeginTime, function ($query, $orderCreatedAtBeginTime){
                 return $query->where('order_created_at', '>=', $orderCreatedAtBeginTime);
             })->when($miniprogramId, function ($query, $miniprogramId){
                 return $query->where('miniprogram_id', $miniprogramId);
             })
             ->when($orderCreatedAtEndTime, function ($query, $orderCreatedAtEndTime) {
-                return $query->where('order_created_at', '<=', $orderCreatedAtEndTime);
+                return $query->where('order_created_at', '<=', $orderCreatedAtEndTime. ' 23:59:59');
             })->orderBy('created_at', 'desc');
+   
         if($isExport) {
             $result = $sql->get();
         } else {

+ 1 - 1
modules/Callback/Http/Controllers/JuliangAccountController.php

@@ -25,7 +25,7 @@ class JuliangAccountController extends CatchController
                 return $query->where('adv_account_id' , $advAccountId);
             })->when($advAccountName, function ($query, $advAccountName) {
                 return $query->where('adv_account_name', 'like', '%'. $advAccountName. '%');
-            })
+            })->orderBy('id', 'desc')
             ->paginate($request->input('limit', 30));
     }
 

+ 2 - 1
modules/Channel/Http/Controllers/AdvertiserController.php

@@ -78,7 +78,8 @@ class AdvertiserController extends CatchController
             ->where([
                 'user_has_miniprograms.is_enabled' => 1,
                 'users.deleted_at' => 0,
-            ])->when($userContext['loginUserRoles']->contains('company'), function ($query) use($userContext){
+            ])->where('users.pid', '<>', 0)
+            ->when($userContext['loginUserRoles']->contains('company'), function ($query) use($userContext){
                 return $query->where('users.pid' , $userContext['loginUser']->id);
             })
             ->when($userContext['loginUserRoles']->contains('optimizer'), function ($query) use ($userContext){

+ 75 - 51
modules/Channel/Services/Order/OrderService.php

@@ -26,7 +26,7 @@ class OrderService
      */
     public static function getOrderList(array $param, $isAll = false)
     {
-        $list = self::getOrderQuerySql($param)->orderBy("orders.id",'desc');
+        $list = self::getOrderQuerySql($param)->select("orders.*", 'pay_merchants.name as pay_merchant_name', 'pay_merchants.payee_name', 'pay_merchants.pay_appid', 'miniprogram.play_name', "miniprogram.name as xcx_name", 'promotions.name as promotion_title')->orderBy("orders.id", 'desc');
 
         if ($isAll) {
             $list = $list->get();
@@ -35,20 +35,11 @@ class OrderService
         }
 
         if (!$list->isEmpty()) {
-
             $status = array_column(self::getOrderPayType(), null, 'value');
             $types = array_column(self::getOrderType(), null, 'value');
             foreach ($list as $val) {
                 $val->username = $val->user_id > 0 ? User::where('id', $val->user_id)->value('username') : "";
-                $val->company_name = "-";
-                $val->play_name = '-';
-                $company = Miniprogram::where('id', $val->miniprogram_id)->first();
-                if ($company) {
-                    $val->company_name = $val->puser_id >  0 ? $company->company() : "-";
-                    $val->play_name = $company->play_name;
-                    $val->xcx_name = $company->name;
-                }
-                $val->promotion_title = $val->promotion_id > 0 ? DB::table('promotions')->where('id', $val->promotion_id)->value('name') : "";
+                $val->company_name = $val->puser_id > 0 ? DB::table('users')->where('id', $val->puser_id)->value("username") : "-";
                 $val->total_count = Order::where('uid', $val->uid)->where('id', "<=", $val->id)->count();
                 if ($val->user_id > 0) {
                     $val->caompany_count = Order::where('uid', $val->uid)->where('puser_id', '>', 0)->where('puser_id', $val->puser_id)->where('id', "<=", $val->id)->count();
@@ -57,6 +48,12 @@ class OrderService
                     $val->caompany_count = Order::where('uid', $val->uid)->where('puser_id', '>', 0)->count();
                     $val->promotion_count = Order::where('uid', $val->uid)->where('user_id', '>', 0)->count();
                 }
+                $val->pay_appid = $val->pay_appid ?: '-';
+                $val->pay_merchant_name = $val->pay_merchant_name ?: '-';
+                $val->payee_name = $val->payee_name ?: '-';
+                $val->xcx_name = $val->xcx_name ?: '-';
+                $val->play_name = $val->play_name ?: '-';
+                $val->promotion_title = $val->promotion_title ?: '-';
                 $val->tip_text = $types[$val->order_type]['name'] ?? "-";
                 $val->status_txt = $status[$val->status]['name'] ?? "-";
                 $val->pay_name = '微信支付';
@@ -66,6 +63,13 @@ class OrderService
         return $list;
     }
 
+
+    /**
+     *  充值类型
+     * name: getOrderType
+     * @return \string[][]
+     * date 2023/06/02 09:56
+     */
     public static function getOrderType()
     {
         return [
@@ -77,6 +81,12 @@ class OrderService
         ];
     }
 
+    /**
+     *  订单状态
+     * name: getOrderPayType
+     * @return \string[][]
+     * date 2023/06/02 09:57
+     */
     public static function getOrderPayType()
     {
         return [
@@ -88,68 +98,82 @@ class OrderService
 
     private static function getOrderQuerySql(array $param)
     {
-        $sql = DB::table('orders');
+        $sql = DB::table('orders')->leftJoin('miniprogram', 'miniprogram.id', '=', 'orders.miniprogram_id')->leftJoin('promotions', 'promotions.id', '=', 'orders.promotion_id')->leftJoin('pay_merchants', 'pay_merchants.id', '=', 'orders.pay_merchant_id');
         // 优化师查询
         if (!empty(getProp($param, 'user_id'))) {
-            $sql->where('user_id', $param['user_id']);
+            $sql->where('orders.user_id', $param['user_id']);
         }
         // 公司查询
         if (!empty(getProp($param, 'puser_id'))) {
-            $sql->where('puser_id', $param['puser_id']);
+            $sql->where('orders.puser_id', $param['puser_id']);
         }
         // 小程序
         if (!empty(getProp($param, 'miniprogram_id'))) {
-            $sql->where('miniprogram_id', $param['miniprogram_id']);
+            $sql->where('orders.miniprogram_id', $param['miniprogram_id']);
         }
 
         // 推广id
         if (!empty(getProp($param, 'promotion_id'))) {
-            $sql->where('promotion_id', $param['promotion_id']);
+            $sql->where('orders.promotion_id', $param['promotion_id']);
         }
         // 订单状态查询
         if (!empty(getProp($param, 'status'))) {
-            $sql->where('status', $param['status']);
+            $sql->where('orders.status', $param['status']);
         }
 
         // 充值项类型
         if (!empty(getProp($param, 'order_type'))) {
-            $sql->where('order_type', $param['order_type']);
+            $sql->where('orders.order_type', $param['order_type']);
         }
         // 用户
         if (!empty(getProp($param, 'uid'))) {
-            $sql->where('uid', $param['uid']);
+            $sql->where('orders.uid', $param['uid']);
         }
         // 订单号查询
         if (!empty(getProp($param, 'trade_no'))) {
-            $sql->where('trade_no', "like", "%" . $param['trade_no'] . "%");
-            // $sql->where('trade_no',  $param['trade_no']);
+            $sql->where('orders.trade_no', "like", "%" . $param['trade_no'] . "%");
+            // $sql->where('orders.trade_no',  $param['trade_no']);
         }
         if (!empty(getProp($param, 'trade_no'))) {
-            // $sql->where('trade_no', "like", "%" . $param['trade_no'] . "%");
-            $sql->where('trade_no', $param['trade_no']);
+            // $sql->where('orders.trade_no', "like", "%" . $param['trade_no'] . "%");
+            $sql->where('orders.trade_no', $param['trade_no']);
         }
         // 支付时间
         if (!empty(getProp($param, 'pay_end_at_start'))) {
-            $sql->where('pay_end_at', ">=",$param['pay_end_at_start']);
+            $sql->where('orders.pay_end_at', ">=", $param['pay_end_at_start']);
         }
         if (!empty(getProp($param, 'pay_end_at_end'))) {
-            $end =$param['pay_end_at_end'];
-            if ($end == getProp($param,'pay_end_at_start','')){
-                $end = date("Y-m-d",strtotime($end)) . " 23:59:59";
+            $end = $param['pay_end_at_end'];
+            if ($end == getProp($param, 'pay_end_at_start', '')) {
+                $end = date("Y-m-d", strtotime($end)) . " 23:59:59";
             }
-            $sql->where('pay_end_at', "<=", $end);
+            $sql->where('orders.pay_end_at', "<=", $end);
         }
         // 创建时间
         if (!empty(getProp($param, 'created_at_start'))) {
-            $sql->where('created_at', '>=',$param['created_at_start']);
+            $sql->where('orders.created_at', '>=', $param['created_at_start']);
         }
 
         if (!empty(getProp($param, 'created_at_end'))) {
-            $end =$param['created_at_end'];
-            if ($end == getProp($param,'created_at_start','')){
-                $end = date("Y-m-d",strtotime($end)) . " 23:59:59";
+            $end = $param['created_at_end'];
+            if ($end == getProp($param, 'created_at_start', '')) {
+                $end = date("Y-m-d", strtotime($end)) . " 23:59:59";
             }
-            $sql->where('created_at', "<=", $end);
+            $sql->where('orders.created_at', "<=", $end);
+        }
+
+        // 支付配置信息查询
+        if (getProp($param, 'pay_merchant_name', '')) {
+            // 支付名称
+            $sql->where("pay_merchants.name", $param['pay_merchant_name']);
+        }
+        if (getProp($param, 'payee_name', '')) {
+            // 收款主体
+            $sql->where("pay_merchants.payee_name", "like", "%" . $param['payee_name'] . "%");
+        }
+        if (getProp($param, 'pay_appid', '')) {
+            // 商户号
+            $sql->where("pay_merchants.pay_appid", $param['pay_appid']);
         }
         return $sql;
     }
@@ -193,14 +217,14 @@ class OrderService
      * @return \Illuminate\Support\Collection
      * date 2023/05/23 18:13
      */
-    public static function promotionsOptions(mixed $uid, mixed $title,mixed $miniprogram_id,mixed $limit = 10)
+    public static function promotionsOptions(mixed $uid, mixed $title, mixed $miniprogram_id, mixed $limit = 10)
     {
         $operateUser = User::find($uid);
         $operateUserRoles = $operateUser->roles->pluck('identify');
         $list = DB::table('promotions')->select('id as promotion_id', 'name');
         if ($operateUserRoles->contains('optimizer')) {
-            if ($miniprogram_id){
-                $list->where('miniprogram_id',$miniprogram_id);
+            if ($miniprogram_id) {
+                $list->where('miniprogram_id', $miniprogram_id);
             }
             if ($title) {
                 $list->where('name', 'like', "%" . $title . "%");
@@ -213,14 +237,14 @@ class OrderService
             if ($title) {
                 $list->where('promotions.name', 'like', "%" . $title . "%");
             }
-            if ($miniprogram_id){
-                $list->where('promotions.miniprogram_id',$miniprogram_id);
+            if ($miniprogram_id) {
+                $list->where('promotions.miniprogram_id', $miniprogram_id);
             }
-            return $list->orderBy('promotions.id','desc')->limit($limit)->get();
+            return $list->orderBy('promotions.id', 'desc')->limit($limit)->get();
 
         } else {
-            if ($miniprogram_id){
-                $list->where('miniprogram_id',$miniprogram_id);
+            if ($miniprogram_id) {
+                $list->where('miniprogram_id', $miniprogram_id);
             }
             if ($title) {
                 $list->where('name', 'like', "%" . $title . "%");
@@ -237,28 +261,28 @@ class OrderService
      * @param mixed $limit
      * date 2023/05/26 09:22
      */
-    public static function promotionsUsers(mixed $pid, mixed $name,mixed $miniprogram_id, mixed $limit = 10)
+    public static function promotionsUsers(mixed $pid, mixed $name, mixed $miniprogram_id, mixed $limit = 10)
     {
         if ($pid > 0) {
             $list = DB::table('users')->where('pid', $pid)->select('users.id as user_id', 'users.username as  name');
             if ($name) {
                 $list->where('username', 'like', "%" . $name . "%");
             }
-            if ($miniprogram_id >  0){
-                $list->join('user_has_miniprograms','user_has_miniprograms.uid','users.id')
-                    ->where('user_has_miniprograms.miniprogram_id',$miniprogram_id);
+            if ($miniprogram_id > 0) {
+                $list->join('user_has_miniprograms', 'user_has_miniprograms.uid', 'users.id')
+                    ->where('user_has_miniprograms.miniprogram_id', $miniprogram_id);
             }
 
             return $list->orderBy('users.id', 'desc')->limit($limit)->get();
         }
 
-        $list = DB::table('users')->join('user_has_roles','users.id',"user_has_roles.user_id")->join('roles','roles.id','user_has_roles.role_id')
-            ->select('users.id as user_id', 'users.username as  name')->where('roles.identify','optimizer');
-        if ($miniprogram_id >  0){
-            $list->join('user_has_miniprograms','user_has_miniprograms.uid','users.id')
-                ->where('user_has_miniprograms.miniprogram_id',$miniprogram_id);
+        $list = DB::table('users')->join('user_has_roles', 'users.id', "user_has_roles.user_id")->join('roles', 'roles.id', 'user_has_roles.role_id')
+            ->select('users.id as user_id', 'users.username as  name')->where('roles.identify', 'optimizer');
+        if ($miniprogram_id > 0) {
+            $list->join('user_has_miniprograms', 'user_has_miniprograms.uid', 'users.id')
+                ->where('user_has_miniprograms.miniprogram_id', $miniprogram_id);
         }
-        if ($name){
+        if ($name) {
             $list->where('users.username', 'like', "%" . $name . "%");
         }
         return $list->orderBy('users.id', 'desc')->limit($limit)->get();

+ 26 - 0
modules/Common/Repository/Options/CommonParams.php

@@ -0,0 +1,26 @@
+<?php
+
+namespace Modules\Common\Repository\Options;
+
+use Catch\Enums\Status as StatusEnum;
+
+class CommonParams implements OptionInterface
+{
+    public function get(): array
+    {
+        /**
+         * @see modules/Common/config/common.php
+         */
+        $commonConfig = config('common.common');
+        return [
+            /**
+             * 支付类型
+             */
+           'payType' => $commonConfig['payType'],
+            /**
+             * 小程序类型
+             */
+            'miniprogramType' => $commonConfig['miniprogramType'],
+        ];
+    }
+}

+ 31 - 1
modules/Common/config/common.php

@@ -16,5 +16,35 @@ return [
     'moduleMap' => [
         '1' => 'weixin',
         '2' => 'douyin',
-    ]
+    ],
+    /**
+     * 支付方式
+     */
+    'payType' => [
+        [
+            'key' => 1,
+            'val' => '易宝支付',
+        ],
+        [
+            'key' => 2,
+            'val' => '微信原生支付',
+        ],
+        [
+            'key' => 3,
+            'val' => '抖音支付'
+        ],
+    ],
+    /**
+     * 小程序类型
+     */
+    'miniprogramType' => [
+        [
+            'key' => 1,
+            'val' => '微信'
+        ],
+        [
+            'key' => 2,
+            'val' => '抖音'
+        ]
+    ],
 ];

+ 0 - 1
modules/CpManage/routes/route.php

@@ -32,7 +32,6 @@ Route::prefix('cpManage')->group(function () {
         Route::post('subscribeStatisticData/saveFinalState',
             [CpSubscribeStatisticDataController::class, 'saveFinalState']);
 
-        Route::post('test/test1', [TestController::class, 'test1'])->withoutMiddleware(config('catch.route.middlewares'));
 
         Route::get('cpCollection',[CpListController::class,"cpCollection"])->withoutMiddleware(config('catch.route.middlewares'));
     });

+ 3 - 1
modules/Jiesuan/Http/Controllers/BankAccountController.php

@@ -33,9 +33,10 @@ class BankAccountController extends CatchController
 
         $company_uid = $this->getLoginUserId();
         $id = $request->input('id');
-        $data = $request->all();
         $now = date('Y-m-d H:i:s');
         if($id) {
+            $data = $request->only(['owner_name', 'name_of_payee', 'card_no',
+                'bank_name', 'sub_bank_name', 'phone_of_payee', 'business_id']);
             $data['updated_at'] = $now;
             // 只有待审核的允许修改
             DB::table('bank_cards')
@@ -43,6 +44,7 @@ class BankAccountController extends CatchController
                     'id' => $id, 'status' => 1, 'company_uid'=> $company_uid
                 ])->update($data);
         } else {
+            $data = $request->all();
             $data['status'] = 1;
             $data['updated_at'] = $data['created_at'] = $now;
             $data['company_uid'] = $company_uid;

+ 1 - 4
modules/Jiesuan/Http/Controllers/VerifyBankInfoController.php

@@ -44,10 +44,7 @@ class VerifyBankInfoController extends CatchController
 
     public function check(VerifyCheckRequest $request)
     {
-        $userContext = $this->getUserContext(null);
-        if (!$userContext['loginUserRoles']->contains('administrator')) {
-            throw  new  FailedException("没有操作权限");
-        }
+       
         $param = [
             'status' => $request->input('status'),
             'checked_user' => [

+ 5 - 5
modules/Jiesuan/Services/VerifyService.php

@@ -64,12 +64,12 @@ class VerifyService extends BaseService
             $sql->where('bank_cards.created_at', "<=", $end);
         }
         // 审核时间
-        if (getProp($param, 'checked_at_start')) {
-            $sql->where('bank_cards.checked_at', '>=', $param['checked_at_start']);
+        if (getProp($param, 'pay_at_start')) {
+            $sql->where('bank_cards.pay_at_at', '>=', $param['pay_at_start']);
         }
-        if (getProp($param, 'checked_at_end')) {
-            $end = date("Y-m-d",strtotime($param['checked_at_end'])). " 23:59:59";
-            $sql->where('bank_cards.checked_at', "<=", $end);
+        if (getProp($param, 'pay_at_end')) {
+            $end = date("Y-m-d",strtotime($param['pay_at_end'])). " 23:59:59";
+            $sql->where('bank_cards.pay_at', "<=", $end);
         }
         return $sql;
     }

+ 1 - 1
modules/Jiesuan/routes/route.php

@@ -37,7 +37,7 @@ Route::prefix('jiesuanManage')->group(function () {
         Route::any('list',[\Modules\Jiesuan\Http\Controllers\VerifyBankInfoController::class,"list"]);
         // 商户选择项
         Route::any('business/option',[\Modules\Jiesuan\Http\Controllers\VerifyBankInfoController::class,"businessOption"]);
-        Route::any('check',[\Modules\Jiesuan\Http\Controllers\VerifyBankInfoController::class,"check"]);
+        Route::any('check',[\Modules\Jiesuan\Http\Controllers\VerifyBankInfoController::class,"check"])->middleware(['roleCheck:financer,administrator']);
     });
 });
 

+ 57 - 11
modules/Manage/Http/Controllers/MiniprogramController.php

@@ -2,6 +2,7 @@
 
 namespace Modules\Manage\Http\Controllers;
 
+use Catch\Exceptions\FailedException;
 use Illuminate\Routing\Controller;
 use Catch\Base\CatchController;
 use Illuminate\Http\Request;
@@ -23,7 +24,7 @@ class MiniprogramController extends CatchController
     use UserTrait;
     public function __construct(protected readonly Miniprogram $miniprogram,protected readonly UserHasMiniprograms $userHasMiniprograms)
     {
-        
+
     }
 
     const  COMPANY_ROLE = 'company';
@@ -45,13 +46,13 @@ class MiniprogramController extends CatchController
         $page_size = $request->input('limit', 15);
         $where = [];
         if($name){
-            $where[] = ['name','like','%'.$name.'%']; 
+            $where[] = ['name','like','%'.$name.'%'];
         }
         if($play_name){
-            $where[] = ['play_name','like','%'.$play_name.'%']; 
+            $where[] = ['play_name','like','%'.$play_name.'%'];
         }
         if($company){
-            $where[] = ['company','like','%'.$company.'%']; 
+            $where[] = ['company','like','%'.$company.'%'];
         }
 
         if($type){
@@ -67,10 +68,11 @@ class MiniprogramController extends CatchController
             ->select('miniprogram.*')
             ->paginate($page_size);
         }
-       
         foreach($result as $item){
             $item->type_name = MiniprogramType::from($item->type)->name();
             $item->status_name = $item->status == 1 ?'启用':'禁用';
+            $item->pay_merchant_name = getProp($item->pay_merchant_info,'name','-');
+            unset($item->pay_merchant_info);
         }
         return $result;
     }
@@ -85,6 +87,29 @@ class MiniprogramController extends CatchController
     {
         $validate_result = $request->validated();
         $validate_result['remark'] = $request->post('remark','') ?? '';
+        $validate_result['pay_merchant_id'] = $request->post('pay_merchant_id',0);
+        if (getProp($validate_result,'pay_merchant_id',0)){
+            $info = DB::table('pay_merchants')->where('id',$validate_result['pay_merchant_id'])->first();
+            if (empty($info)){
+                throw  new  FailedException("支付方式不存在");
+            }
+            if ($info->miniprogram_type != $validate_result['type']){
+                throw  new  FailedException("小程序类型和支付的小程序类型不匹配");
+            }
+            $validate_result['pay_merchant_info'] = [
+                'pay_merchant_id' => $info->id,
+                'name' => $info->name,
+                'pay_type' => $info->pay_type,
+                'payee_name' => $info->payee_name,
+                'miniprogram_type' => $info->miniprogram_type,
+                'pay_appid' => $info->pay_appid,
+            ];
+
+        }else{
+            $validate_result['pay_merchant_id'] = 0;
+            $validate_result['pay_merchant_info'] = [];
+        }
+        
         return $this->miniprogram->create($validate_result)->toArray();
 
     }
@@ -113,6 +138,27 @@ class MiniprogramController extends CatchController
         if($request->post('remark','')){
             $validate_result['remark'] = $request->post('remark','');
         }
+        if (getProp($validate_result,'pay_merchant_id',0)){
+            $info = DB::table('pay_merchants')->where('id',$validate_result['pay_merchant_id'])->first();
+            if (empty($info)){
+                throw  new  FailedException("支付方式不存在");
+            }
+            if ($info->miniprogram_type != $validate_result['type']){
+                throw  new  FailedException("小程序类型和支付的小程序类型不匹配");
+            }
+            $validate_result['pay_merchant_info'] = [
+                'pay_merchant_id' => $info->id,
+                'name' => $info->name,
+                'pay_type' => $info->pay_type,
+                'payee_name' => $info->payee_name,
+                'miniprogram_type' => $info->miniprogram_type,
+                'pay_appid' => $info->pay_appid,
+            ];
+
+        }else{
+            $validate_result['pay_merchant_id'] = 0;
+            $validate_result['pay_merchant_info'] = [];
+        }
         $this->miniprogram->where('id',$id)->update($validate_result);
         return [];
     }
@@ -143,10 +189,10 @@ class MiniprogramController extends CatchController
 
     /**
      * 绑定小程序和投放公司的关系 或者投放公司把小程序分配给优化师
-     * @param [type] $miniprogram_id 
+     * @param [type] $miniprogram_id
      * @param Request $request  uid=2,3,4,5 actison=on|off on:分配,off取消分配
      * @return array
-     * 
+     *
      */
     public function allocationStore($miniprogram_id,Request $request)
     {
@@ -202,12 +248,12 @@ class MiniprogramController extends CatchController
      * response = [
      *      'on'=>[ ['id'=>1,'username'=>'公司1','user_has_miniprogram'=>1],[]  ],
      *      'off'=>[['id'=>1,'username'=>'公司1','user_has_miniprogram'=>0],[]],
-     *      'all'=>[ 
+     *      'all'=>[
      *          ['id'=>1,'username'=>'公司1','user_has_miniprogram'=>1],
-     *          ['id'=>2,'username'=>'公司1','user_has_miniprogram'=>0] 
+     *          ['id'=>2,'username'=>'公司1','user_has_miniprogram'=>0]
      *          ]
      *      ]
-     * 
+     *
      */
     public function getAllocationInfo($miniprogram_id){
         $uid = $this->getLoginUser()->id;
@@ -216,7 +262,7 @@ class MiniprogramController extends CatchController
         }else{
             $all_company_account = UserService::getOptimizers($uid,['users.username','users.id']);
         }
-       
+
         $result = $all_company_account->map(function ($item,$key) use($miniprogram_id) {
             $info = $this->userHasMiniprograms->where('uid',$item->id)->where('miniprogram_id',$miniprogram_id)->where('is_enabled',1)->count();
             if($info){

+ 104 - 0
modules/Manage/Http/Controllers/PayConfigController.php

@@ -0,0 +1,104 @@
+<?php
+
+namespace Modules\Manage\Http\Controllers;
+
+use Catch\Base\CatchController;
+use Illuminate\Foundation\Validation\ValidatesRequests;
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\DB;
+
+/**
+ * 支付配置管理
+ */
+class PayConfigController extends CatchController
+{
+    use ValidatesRequests;
+    /**
+     * 配置列表
+     * @param Request $request
+     */
+    public function list(Request $request) {
+        $this->validate($request,[
+            'name' => 'nullable|string|max:256',
+            'pay_type' => 'nullable|in:1,2,3',
+            'miniprogram_type' => 'nullable|in:1,2',
+            'remark' => 'nullable|string|max:256',
+            'pay_appid' => 'nullable|string|max:256',
+        ]);
+        $name = $request->input('name');
+        $payType = $request->input('pay_type');
+        $miniprogramType = $request->input('miniprogram_type');
+        $payAppid = $request->input('pay_appid');
+        $remark = $request->input('remark');
+        $isAll = $request->input('is_all', 0);
+        $commonConfig = config('common.common');
+
+
+        $sql = DB::table('pay_merchants')
+            ->when($name, function ($query, $name){
+                return $query->where('name', 'like', '%'. $name .'%');
+            })->when($payType, function ($query, $payType){
+                return $query->where('pay_type', $payType);
+            })->when($miniprogramType, function ($query, $miniprogramType) {
+                return $query->where('miniprogram_type', $miniprogramType);
+            })->when($payAppid, function ($query, $payAppid) {
+                return $query->where('pay_appid', $payAppid);
+            })->when($remark, function ($query, $remark){
+                return $query->where('remark', 'like', '%'. $remark. '%');
+            })->orderBy('id', 'desc');
+
+        if($isAll) {
+            $result =  $sql->get();
+        } else {
+            $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 = $payTypeMap[$item->pay_type]['val'] ?? '';
+            $item->miniprogram_type_str = $miniprogramTypeMap[$item->miniprogram_type]['val'] ?? '';
+        }
+
+        return $result;
+    }
+
+    /**
+     * 修改备注
+     * @param Request $request
+     */
+    public function remark(Request $request) {
+        $this->validate($request, ['id' => 'required']);
+        DB::table('pay_merchants')
+            ->where(['id' => $request->input('id')])
+            ->update(['remark' => $request->input('remark', ''),
+                'updated_at' => date('Y-m-d H:i:s')]);
+
+        return 'ok';
+    }
+
+    /**
+     * 添加支付配置信息
+     * @param Request $request
+     */
+    public function addConfig(Request $request) {
+        $this->validate($request, [
+            'name' => 'required|string|max:256',
+            'payee_name' => 'required|string|max:256',
+            'pay_appid' => 'required',
+            'pay_type' => 'required|integer|in:1,2,3',
+            'pay_common_params' => 'required',
+            '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);
+
+        return 'ok';
+    }
+}

+ 5 - 3
modules/Manage/Http/Requests/MiniprogramUpdateRequest.php

@@ -33,11 +33,12 @@ class MiniprogramUpdateRequest extends FormRequest
             ],
             'appsecret'=>'required|min:30|max:64',
             'appid'=>'required|min:18|max:32',
-            'status'=>'in:0,1'
+            'status'=>'in:0,1',
+            'pay_merchant_id' => "Integer|gt:0"
         ];
     }
 
-    
+
     public function messages(): array
     {
         return [
@@ -45,7 +46,8 @@ class MiniprogramUpdateRequest extends FormRequest
             'appid.min'=>'appid太短',
             'appid.max'=>'appid过长',
             'appsecret.min'=>'appsecret太短',
-            'appsecret.max'=>'appsecret过长'
+            'appsecret.max'=>'appsecret过长',
+            "pay_merchant_id" => "支付配置不正确",
         ];
     }
 }

+ 2 - 2
modules/Manage/Models/Miniprogram.php

@@ -14,7 +14,7 @@ class Miniprogram extends BaseModel
     protected $table = 'miniprogram';
 
     protected $fillable = [
-        'id', 'name', 'company', 'type', 'appid', 'appsecret', 'status', 'remark', 'play_name','created_at', 'updated_at'
+        'id', 'name', 'company', 'type', 'appid', 'appsecret',"pay_merchant_id","pay_merchant_info", 'status', 'remark', 'play_name','created_at', 'updated_at'
     ];
-
+    protected $casts = ['pay_merchant_info' =>'array'];
 }

+ 8 - 1
modules/Manage/routes/route.php

@@ -3,6 +3,7 @@
 use Illuminate\Support\Facades\Route;
 
 use Modules\Manage\Http\Controllers\MiniprogramController;
+use Modules\Manage\Http\Controllers\PayConfigController;
 
 Route::prefix('manage')->group(function(){
     Route::prefix('miniprogram')->group(function () {
@@ -33,4 +34,10 @@ Route::prefix('manage')->group(function(){
         ->withoutMiddleware(config('catch.route.middlewares'));
 
     });
-});
+
+    Route::prefix('payConfig')->group(function(){
+       Route::get('list', [PayConfigController::class, 'list']);
+       Route::post('remark', [PayConfigController::class, 'remark']);
+       Route::post('addConfig', [PayConfigController::class, 'addConfig']);
+    });
+});

+ 1 - 1
modules/OrderRefund/Models/OrdersRefundVerify.php

@@ -10,7 +10,7 @@ class OrdersRefundVerify extends BaseModel
     protected $table = 'orders_refund_verify';
 
     protected $fillable = [
-        'id', 'create_user_id', 'order_id', 'puser_id', 'user_id', 'uid', 'order_price', 'refund_price', 'trade_no', 'refund_no', 'refund_status', 'pay_at', 'pay_op_user', 'pt_verify_status', 'pt_verifty_user', 'pt_verify_at', 'pt_verify_remark', 'sh_verify_status', 'sh_verifty_user', 'sh_verify_remark', 'sh_verify_at', 'created_at', 'updated_at',
+        'id','third_orderid', 'create_user_id',"pay_merchant_id", 'order_id', 'puser_id', 'user_id', 'uid', 'order_price', 'refund_price', 'trade_no', 'refund_no', 'refund_status', 'pay_at', 'pay_op_user', 'pt_verify_status', 'pt_verifty_user', 'pt_verify_at', 'pt_verify_remark', 'sh_verify_status', 'sh_verifty_user', 'sh_verify_remark', 'sh_verify_at', 'created_at', 'updated_at',
     ];
     protected $casts = ['sh_verifty_user' => 'array','pt_verifty_user' => 'array','pay_op_user' => 'array'];
 

文件差异内容过多而无法显示
+ 89 - 73
modules/OrderRefund/Services/RefundOrderService.php


+ 20 - 0
tests/Common/Http/Controllers/OptionControllerTest.php

@@ -0,0 +1,20 @@
+<?php
+
+namespace Tests\Common\Http\Controllers;
+
+use Modules\Common\Http\Controllers\OptionController;
+use PHPUnit\Framework\TestCase;
+use Tests\UsedTestCase;
+
+class OptionControllerTest extends UsedTestCase
+{
+
+    public function testIndex()
+    {
+        $res = $this->withHeaders([
+            'Authorization' => 'Bearer '. $this->token,
+        ])->json('get','http://localhost/api/options/CommonParams');
+        $res->dump();
+        $this->dumpJson($res);
+    }
+}

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

@@ -0,0 +1,53 @@
+<?php
+
+namespace Tests\Manage\Http\Controllers;
+
+use Modules\Manage\Http\Controllers\PayConfigController;
+use PHPUnit\Framework\TestCase;
+use Tests\UsedTestCase;
+
+class PayConfigControllerTest extends UsedTestCase
+{
+
+    public function testAddConfig()
+    {
+        $res = $this->withHeaders([
+            'Authorization' => 'Bearer '. $this->token,
+        ])->json('post','http://localhost/api/manage/payConfig/addConfig', [
+            'name' => 'first',
+            'payee_name' => 'first-payee_name',
+            'pay_appid' => '12342142412',
+            'pay_type' => 1,
+            'pay_common_params' => [
+                'aa' => 'bb',
+                'bb' => 'cc',
+            ],
+            'miniprogram_type' => 1,
+            'remark' => '111'
+        ]);
+        $res->dump();
+        $this->dumpJson($res);
+    }
+    public function testRemark()
+    {
+        $res = $this->withHeaders([
+            'Authorization' => 'Bearer '. $this->token,
+        ])->json('post','http://localhost/api/manage/payConfig/remark', [
+            'id' => 1,
+            'remark' => 'first---',
+        ]);
+        $res->dump();
+        $this->dumpJson($res);
+    }
+    public function testList()
+    {
+        $res = $this->withHeaders([
+            'Authorization' => 'Bearer '. $this->token,
+        ])->json('get','http://localhost/api/manage/payConfig/list', [
+
+            'pay_appid' => '12342142412'
+        ]);
+        $res->dump();
+        $this->dumpJson($res);
+    }
+}

+ 2 - 2
tests/UsedTestCase.php

@@ -13,9 +13,9 @@ abstract class UsedTestCase extends BaseTestCase
     {
         parent::setUp(); // TODO: Change the autogenerated stub
         $tokenInfo = $this->post('http://localhost/api/login', [
-//            'email' => 'catch@admin.com',
+            'email' => 'catch@admin.com',
             'remember' => false,
-            'email' => 'xiaoli@qq.com',
+//            'email' => 'xiaoli@qq.com',
             'password' => 'catchadmin',
 //            'email' => 'aa4@test.com',
         ])->json();