Ken пре 2 месеци
родитељ
комит
ea79937510
2 измењених фајлова са 21 додато и 6 уклоњено
  1. 14 5
      app/Http/Controllers/admin/Bet.php
  2. 7 1
      app/Services/BetService.php

+ 14 - 5
app/Http/Controllers/admin/Bet.php

@@ -14,20 +14,29 @@ class Bet extends Controller
     /**
      * @description: 分页数据
      * @return {*}
+     *
+     * @apiParam {String} [start_time] 开始时间
+     * - 格式:`yyyy-mm-dd`
+     * @apiParam {String} [end_time] 截止时间
+     * - 格式:`yyyy-mm-dd`
      */
     function index()
     {
         try {
-            request()->validate([
-                'issue_no' => ['nullable', 'string'],
+            $params = request()->validate([
+                'page' => ['nullable', 'integer', 'min:1'],
+                'limit' => ['nullable', 'integer', 'min:1'],
                 'member_id' => ['nullable', 'string'],
+                'keywords' => ['nullable', 'string', 'min:1'],
+                'issue_no' => ['nullable', 'string'],
                 'id' => ['nullable', 'string'],
                 'status' => ['nullable', 'integer', 'in:1,2'],
-                'keywords' => ['nullable', 'string', 'min:1'],
                 'username' => ['nullable', 'string', 'min:1'],
+                'start_time' => ['nullable', 'date', 'date_format:Y-m-d', 'required_with:end_time'],
+                'end_time' => ['nullable', 'date', 'date_format:Y-m-d', 'required_with:start_time'],
+
             ]);
-            $search = request()->all();
-            $result = BetService::paginate($search);
+            $result = BetService::paginate($params);
         } catch (ValidationException $e) {
             return $this->error(HttpStatus::VALIDATION_FAILED, $e->validator->errors()->first());
         } catch (Exception $e) {

+ 7 - 1
app/Services/BetService.php

@@ -74,6 +74,12 @@ class BetService extends BaseService
         }
 
 
+        if (isset($search['start_time']) && !empty($search['status'])) {
+            $where[] = ['created_at', '>=', "{$search['start_time']} 00:00:00"];
+            $where[] = ['created_at', '<=', "{$search['end_time']} 23:59:59"];
+        }
+
+
         return $where;
     }
 
@@ -286,7 +292,7 @@ class BetService extends BaseService
         //         WalletService::updateBalance($memberId,$rebateAmount);
 
         //         $walletInfo = WalletService::findOne(['member_id' => $memberId]);
-        //         $balance = $walletInfo['available_balance']; 
+        //         $balance = $walletInfo['available_balance'];
 
         //         BalanceLogService::addLog($memberId,$rebateAmount,$balance,($balance+$rebateAmount),'返水',$bet_id,'');
         //     }