Browse Source

fix:邀请记录

super-yimizi 1 day ago
parent
commit
4726dbd2db

+ 12 - 1
application/api/controller/commission/Agent.php

@@ -222,14 +222,25 @@ class Agent extends Commission
     // 我的团队
     public function team()
     {
+        $params = $this->request->param();
+        
+        // 使用验证器验证分页参数:page, page_size
+        $validate = new \app\api\validate\Agent();
+        if (!$validate->scene('team')->check($params)) {
+            $this->error($validate->getError());
+        }
+        
         $agentId = $this->service->user->id;
+        
+        // 获取验证后的分页参数
+        $pageSize = isset($params['page_size']) ? (int)$params['page_size'] : 8;
 
         $data = UserModel::where('parent_user_id', $agentId)
             ->where('status', 'normal')
             ->with(['agent' => function ($query) {
                 return $query->with('level_info');
             }])
-            ->paginate($this->request->param('list_rows', 8));
+            ->paginate($pageSize);
 
         $this->success("", $data);
     }

+ 24 - 0
application/api/validate/Agent.php

@@ -0,0 +1,24 @@
+<?php
+
+namespace app\api\validate;
+
+use think\Validate;
+
+class Agent extends Validate
+{
+    protected $rule = [
+        'page' => 'integer|egt:1',
+        'page_size' => 'integer|between:1,100',
+    ];
+
+    protected $message = [
+        'page.integer' => '页码必须为整数',
+        'page.egt' => '页码必须大于等于1',
+        'page_size.integer' => '分页大小必须为整数',
+        'page_size.between' => '分页大小必须在1-100之间',
+    ];
+
+    protected $scene = [
+        'team' => ['page', 'page_size'],
+    ];
+}

+ 6 - 0
application/common/model/Withdraw.php

@@ -8,6 +8,12 @@ use app\common\model\User;
 class Withdraw extends Model
 {
     protected $name = 'shop_withdraw';
+
+     // 开启自动写入时间戳字段
+     protected $autoWriteTimestamp = 'int';
+     // 定义时间戳字段名
+     protected $createTime = 'createtime';
+     protected $updateTime = 'updatetime';
     protected $type = [
         'withdraw_info' => 'json'
     ];

+ 4 - 1
application/common/model/WithdrawLog.php

@@ -9,5 +9,8 @@ class WithdrawLog extends Model
 {
     protected $name = 'shop_withdraw_log';
 
-
+    // 开启自动写入时间戳字段
+    protected $autoWriteTimestamp = 'int';
+    // 定义时间戳字段名
+    protected $createTime = 'createtime';
 }