Ver Fonte

修改用户昵称查询

lip há 22 horas atrás
pai
commit
d1bf136cf7

+ 75 - 253
app/Console/Commands/Basketball.php

@@ -6,11 +6,9 @@ use Illuminate\Console\Command;
 use App\Models\Sport as SportModel;
 use App\Models\Sport as SportModel;
 use App\Models\SportTeam;
 use App\Models\SportTeam;
 use App\Models\SportLeague;
 use App\Models\SportLeague;
-use App\Models\SportStatistics;
 use App\Services\SportClientService;
 use App\Services\SportClientService;
 use Carbon\Carbon;
 use Carbon\Carbon;
 use Illuminate\Support\Facades\DB;
 use Illuminate\Support\Facades\DB;
-use App\Models\SportEvent;
 use App\Models\Config;
 use App\Models\Config;
 
 
 class Basketball extends Command
 class Basketball extends Command
@@ -24,26 +22,40 @@ class Basketball extends Command
     protected $is_live = 0;
     protected $is_live = 0;
 
 
     protected  $short_status = [
     protected  $short_status = [
-            'TBD' => 0,
-            'LIVE' => 1,
+            'NS' => 0,
+            'Q1' => 1,
+            'Q2' => 1,
+            'Q3' => 1,
+            'Q4' => 1,
+            'OT' => 1,
+            'BT' => 1,
+            'HT' => 1,
+            'FT' => 2,
+            'AOT' => 2,
+            'POST' => 3,
+            'CANC' => 4,
+            'SUSP' => 4,
+            'AWD' => 4,
+            'ABD' => 4,
         ];
         ];
+
     protected $long_status = [
     protected $long_status = [
-        'Time To Be Defined' => 0,
         'Not Started' => 0,
         'Not Started' => 0,
-        'First Half' => 1,
-    ];        
-    
-    protected $fixture_status = [
-        'First Half' => 1,
-        'First Half, Kick Off' => 1,
-        'Halftime' => 1,
-        'Second Half' => 1,
-        'Second Half, 2nd Half Started' => 1,
-        'Extra Time' => 1,
+        'Quarter 1' => 1,
+        'Quarter 2' => 1,
+        'Quarter 3' => 1,
+        'Quarter 4' => 1,
+        'Over Time' => 1,
         'Break Time' => 1,
         'Break Time' => 1,
-        'Penalty In Progress' => 1,
-    ];     
-   
+        'Halftime' => 1,
+        'Game Finished' => 2,
+        'After Over Time' => 2,
+        'Game Postponed' => 3,
+        'Game Cancelled' => 4,
+        'Game Suspended' => 4,
+        'Game Awarded' => 4,
+        'Game Abandoned' => 4,
+    ];        
 
 
     /**
     /**
      * 命令描述
      * 命令描述
@@ -73,32 +85,25 @@ class Basketball extends Command
             //未开始的赛事拉取
             //未开始的赛事拉取
             $this->fixtures();
             $this->fixtures();
         } elseif ($this->is_live == 1) {
         } elseif ($this->is_live == 1) {
-            //进行中的赛事,定时更新
-            $this->liveFixtures();
+            
         } elseif ($this->is_live == 2){
         } elseif ($this->is_live == 2){
             $this->checkLiveFixtures();
             $this->checkLiveFixtures();
         } elseif ($this->is_live == 3) {
         } elseif ($this->is_live == 3) {
             $this->checkOvertimeFixtures();
             $this->checkOvertimeFixtures();
-        } else {
-            $this->initOdds();
-        }
+        } 
+        
     }
     }
 
 
 
 
     //到了比赛开始时间,但是状态还是未开始,检查比赛
     //到了比赛开始时间,但是状态还是未开始,检查比赛
     public function checkOvertimeFixtures()
     public function checkOvertimeFixtures()
     { 
     { 
-        //体育赛事结束前几(分钟)锁盘,90分钟结束
-        $sport_locked = Config::where('field', 'sport_locked')->first()->val ?? 1;
-        
         // 比赛开始后,状态还是未开始的数据检测
         // 比赛开始后,状态还是未开始的数据检测
-        $ids = SportModel::where('state', 0)->where('game_time', '<=', time())->pluck('data_id')->toArray();
+        $ids = SportModel::where('type', 2)->where('state', 0)->where('game_time', '<=', time())->where('game_time', '>', strtotime(date('Y-m-d')))->pluck('data_id')->toArray();
         if ($ids) {
         if ($ids) {
-            $chunks = array_chunk($ids, 10);
-            foreach ($chunks as $chunk) {
-                $ids = implode('-', $chunk);
-                $data = SportClientService::fixtures(['ids' => $ids]);
-                $this->updateOrCreateSport($data, $sport_locked, 1);
+            foreach ($ids as $id) {
+                $data = SportClientService::basketballGames(['id' => $id]);
+                $this->updateOrCreateSport($data, 1);
             }
             }
         }
         }
         return true;
         return true;
@@ -107,151 +112,84 @@ class Basketball extends Command
     //进行中超过3分钟没有更新数据的赛事,检查比赛是否结束
     //进行中超过3分钟没有更新数据的赛事,检查比赛是否结束
     public function checkLiveFixtures()
     public function checkLiveFixtures()
     { 
     { 
-        //体育赛事结束前几(分钟)锁盘,90分钟结束
-        $sport_locked = Config::where('field', 'sport_locked')->first()->val ?? 1;
-
         //1. 统一锁盘时间(比赛开始前1分钟)
         //1. 统一锁盘时间(比赛开始前1分钟)
-        SportModel::where(['is_locked' => 0, 'is_roll' => 0])->where('game_time', '<=', time() + 90)->update(['is_locked' => 1]);
+        SportModel::where('type', 2)->where(['is_locked' => 0, 'is_roll' => 0])->where('game_time', '<=', time() + 90)->update(['is_locked' => 1]);
 
 
         //2. 比赛进行中,超过3分钟未更新的数据检测
         //2. 比赛进行中,超过3分钟未更新的数据检测
         $end_time = date("Y-m-d H:i:s", time() - 180);
         $end_time = date("Y-m-d H:i:s", time() - 180);
-        $ids = SportModel::where('state', 1)->where('updated_at', '<=', $end_time)->pluck('data_id')->toArray();
+        $ids = SportModel::where('type', 2)->where('state', 1)->where('updated_at', '<=', $end_time)->pluck('data_id')->toArray();
         if ($ids) {
         if ($ids) {
-            $chunks = array_chunk($ids, 10);
-            foreach ($chunks as $chunk) {
-                $ids = implode('-', $chunk);
-                $data = SportClientService::fixtures(['ids' => $ids]);
-                $this->updateOrCreateSport($data, $sport_locked, 1);
+            foreach ($ids as $id) {
+                $data = SportClientService::basketballGames(['id' => $id]);
+                $this->updateOrCreateSport($data, 1);
             }
             }
         }
         }
         return true;
         return true;
     }
     }
-    
-    //更新进行中的赛事
-    public function liveFixtures()
-    {
+
+    private function updateOrCreateSport($data, $is_check = 0) {
         //体育赛事结束前几(分钟)锁盘,90分钟结束
         //体育赛事结束前几(分钟)锁盘,90分钟结束
         $sport_locked = Config::where('field', 'sport_locked')->first()->val ?? 1;
         $sport_locked = Config::where('field', 'sport_locked')->first()->val ?? 1;
-        $data = SportClientService::fixtures(['live' => 'all']);
-        file_put_contents("fixturesLive.json", json_encode($data));
-        $this->updateOrCreateSport($data, $sport_locked);
-        return true;
-    }
 
 
-    private function updateOrCreateSport($data, $sport_locked, $is_check = 0) {
         $data = $data['response'];
         $data = $data['response'];
         $tableData = [];
         $tableData = [];
         $status = $this->short_status;
         $status = $this->short_status;
         foreach ($data as $item) {
         foreach ($data as $item) {
-            $home_statistics = !empty($item['statistics']) ? $item['statistics'][0]['statistics'] : '';
-            $away_statistics = !empty($item['statistics']) ? $item['statistics'][1]['statistics'] : '';
-
+            $data_id = $item['id'];
             $sport_data = [
             $sport_data = [
-                'data_id' => $item['fixture']['id'],
+                'data_id' => $item['id'],
+                'type' => 2,
                 'home_team_id' => $item['teams']['home']['id'],
                 'home_team_id' => $item['teams']['home']['id'],
                 'home_team_en' => $item['teams']['home']['name'],
                 'home_team_en' => $item['teams']['home']['name'],
                 'home_team_logo' => $item['teams']['home']['logo'],
                 'home_team_logo' => $item['teams']['home']['logo'],
                 'guest_team_id' => $item['teams']['away']['id'],
                 'guest_team_id' => $item['teams']['away']['id'],
                 'guest_team_en' => $item['teams']['away']['name'],
                 'guest_team_en' => $item['teams']['away']['name'],
                 'guest_team_logo' => $item['teams']['away']['logo'],
                 'guest_team_logo' => $item['teams']['away']['logo'],
-                'half_score' => "{$item['score']['halftime']['home']}-{$item['score']['halftime']['away']}",
-                'rbt' => $item['fixture']['timestamp'],
-                'score' => isset($item['goals']) ? "{$item['goals']['home']}-{$item['goals']['away']}":'-',
-                'extra_score' => isset($item['score']['extratime']) ? "{$item['score']['extratime']['home']}-{$item['score']['extratime']['away']}" : "",//加时赛比分
+                'half_score' => "",
+                'rbt' => $item['timestamp'],
+                'score' => isset($item['scores']['home']) && isset($item['scores']['away']) ? "{$item['scores']['home']['total']}-{$item['scores']['away']['total']}":'-',
+                'extra_score' => isset($item['scores']['home']) && isset($item['scores']['away']) ? "{$item['scores']['home']['over_time']}-{$item['scores']['away']['over_time']}":'-',
                 'league_id' => $item['league']['id'],
                 'league_id' => $item['league']['id'],
                 'league_en' => $item['league']['name'],
                 'league_en' => $item['league']['name'],
                 'league_data' => json_encode($item['league']),
                 'league_data' => json_encode($item['league']),
-                'state' => $status[$item['fixture']['status']['short']],//比赛状态:0未开始1进行中2已完场3延期4取消
-                'game_time' => $item['fixture']['timestamp'],
-                'updated_at' => date('Y-m-d H:i:s'),
-                'home_statistics' => json_encode($home_statistics),
-                'away_statistics' => json_encode($away_statistics),
+                'scores' => json_encode($item['scores']),
+                'state' => $status[$item['status']['short']],//比赛状态:0未开始1进行中2已完场3延期4取消
+                'game_time' => $item['timestamp'],
+                'updated_at' => now(),
                 'is_send' => 0,
                 'is_send' => 0,
             ];
             ];
-            
-            
-            $info = SportModel::where('data_id', $item['fixture']['id'])->first();
-            
-            $fixture_status = null;
-            if (isset($item['fixture']['status']['long']) ) {
-                $long = $item['fixture']['status']['long'];
-                if (isset($this->fixture_status[$long])) {
-                    $fixture_status = json_encode($item['fixture']['status']);
-                    $sport_data['fixture_status'] = $fixture_status;
-                } 
-                if (isset($this->long_status[$long])) {
-                    $sport_data['state'] = $this->long_status[$long];
-                }
-            }
-            //提前锁盘(比赛进行时长,分钟)
-            if (isset($item['fixture']['status']['elapsed'])) {
-                $elapsed = $item['fixture']['status']['elapsed'];
-                if ((int)$elapsed >= 90 - $sport_locked ) {
-                   $sport_data['is_locked'] = 1;
-                }
-            }
-            
+            $info = SportModel::where('type', 2)->where('data_id', $data_id)->first();
+        
             $sport_data['score'] = $sport_data['score'] == '-' ? '' : $sport_data['score'];
             $sport_data['score'] = $sport_data['score'] == '-' ? '' : $sport_data['score'];
-            $sport_data['half_score'] = $sport_data['half_score'] == '-' ? '' : $sport_data['half_score'];
             $sport_data['extra_score'] = $sport_data['extra_score'] == '-' ? '' : $sport_data['extra_score'];
             $sport_data['extra_score'] = $sport_data['extra_score'] == '-' ? '' : $sport_data['extra_score'];
             
             
-            //锁盘
-            if (isset($item['fixture']['status']['blocked']) && $item['fixture']['status']['blocked']) {
-                $sport_data['is_locked'] = 1;
-            }
-            //已结束
-            if (isset($item['fixture']['status']['finished']) && $item['fixture']['status']['finished']) {
-                $sport_data['state'] = 2;
-            }
-
             //如果赛事取消、延期等,标记需要退款
             //如果赛事取消、延期等,标记需要退款
             if ($sport_data['state'] > 2) {
             if ($sport_data['state'] > 2) {
                 $sport_data['refund_status'] = 1;
                 $sport_data['refund_status'] = 1;
             }
             }
-            
+            if (empty($info['league'])) {
+                $sport_data['league'] = SportLeague::getLeagueName($sport_data['league_id'], 2);
+            }
+            if (empty($info['home_team'])) {
+                $sport_data['home_team'] = SportTeam::getTeamName($sport_data['home_team_id'], 2);
+            }
+            if (empty($info['guest_team'])) {
+                $sport_data['guest_team'] = SportTeam::getTeamName($sport_data['guest_team_id'], 2);
+            }
+
             if (!$info) {
             if (!$info) {
                 $sport_data['created_at'] = date('Y-m-d H:i:s');
                 $sport_data['created_at'] = date('Y-m-d H:i:s');
                 $sport_data['status'] = 1;
                 $sport_data['status'] = 1;
-                $sport_data['home_team'] = SportTeam::getTeamName($sport_data['home_team_id']);
-                $sport_data['guest_team'] = SportTeam::getTeamName($sport_data['guest_team_id']);
-                $sport_data['league'] = SportLeague::getLeagueName($sport_data['league_id']);
                 $tableData[] = $sport_data;
                 $tableData[] = $sport_data;
             } else {
             } else {
-                if (empty($info['league'])) {
-                    $sport_data['league'] = SportLeague::getLeagueName($sport_data['league_id']);
-                }
-                if (empty($info['home_team'])) {
-                    $sport_data['home_team'] = SportTeam::getTeamName($sport_data['home_team_id']);
-                }
-                if (empty($info['guest_team'])) {
-                    $sport_data['guest_team'] = SportTeam::getTeamName($sport_data['guest_team_id']);
-                }
-                SportModel::where('data_id', $item['fixture']['id'])->update($sport_data);
+                SportModel::where('type', 2)->where('data_id', $data_id)->update($sport_data);
             }
             }
+            //更新或创建球队和联赛信息
+            SportModel::addSportTeam($sport_data);
+            SportModel::addSportLeague($item['league']);
 
 
-            if ($sport_data['state'] == 2) {
-                $data_id = $item['fixture']['id'];
-                //比赛结束,插入比赛事件
-                if (!empty($item['events'])) {
-                    $this->insertSportEvents($data_id, $item['events']);
-                }
-                //比赛结束,插入比赛统计数据
-                $data = SportClientService::statistics(['fixture' => $data_id,'half' => 'true']);
-                // file_put_contents("fixturesStatistics.json", json_encode($data));
-                $statistics_data = empty($data['response']) ? [] : $data['response'];
-                foreach($statistics_data as $item) {
-                    $team_id = $item['team']['id'];
-                    //上半场的数据
-                    if(!empty($item['statistics_1h'])) {
-                        $statistics_1h = $item['statistics_1h'];
-                        $this->insertSportStatistics($data_id, $team_id, $statistics_1h, 1); 
-                    }
-                    //下半场的数据
-                    if(!empty($item['statistics_2h'])) {
-                        $statistics_2h = $item['statistics_2h'];
-                        $this->insertSportStatistics($data_id, $team_id, $statistics_2h, 2); 
-                    }
-                }
+            //比赛结束,插入比赛事件
+            if (isset($sport_data['state']) && $sport_data['state'] == 2 ) {
                 
                 
             }
             }
         }
         }
@@ -273,134 +211,18 @@ class Basketball extends Command
         for($i=0;$i<$days;$i++) {
         for($i=0;$i<$days;$i++) {
             $date = Carbon::today()->addDay($i)->toDateString();
             $date = Carbon::today()->addDay($i)->toDateString();
             $data = SportClientService::basketballGames(['date' => $date]);
             $data = SportClientService::basketballGames(['date' => $date]);
-    
-            $data = $data['response'];
-            $tableData = [];
-            $status = $this->short_status;
-            foreach ($data as $item) {
-                $data_id = $item['id'];
-                $sport_data = [
-                    'data_id' => $item['id'],
-                    'type' => 2,
-                    'home_team_id' => $item['teams']['home']['id'],
-                    'home_team_en' => $item['teams']['home']['name'],
-                    'home_team_logo' => $item['teams']['home']['logo'],
-                    'guest_team_id' => $item['teams']['away']['id'],
-                    'guest_team_en' => $item['teams']['away']['name'],
-                    'guest_team_logo' => $item['teams']['away']['logo'],
-                    'half_score' => "",
-                    'rbt' => $item['timestamp'],
-                    'score' => isset($item['scores']['home']) && isset($item['scores']['away']) ? "{$item['scores']['home']['total']}-{$item['scores']['away']['total']}":'-',
-                    'extra_score' => isset($item['scores']['home']) && isset($item['scores']['away']) ? "{$item['scores']['home']['over_time']}-{$item['scores']['away']['over_time']}":'-',
-                    'league_id' => $item['league']['id'],
-                    'league_en' => $item['league']['name'],
-                    'league_data' => json_encode($item['league']),
-                    'scores' => json_encode($item['scores']),
-                    // 'state' => $status[$item['fixture']['status']['short']],//比赛状态:0未开始1进行中2已完场3延期4取消
-                    'game_time' => $item['timestamp'],
-                    'updated_at' => now(),
-                    'is_send' => 0,
-                ];
-                $status_short = strtoupper($item['fixture']['status']['short']);
-                if (isset($status[$status_short])) {
-                    $sport_data['state'] = $status[$status_short];
-                }
-                $sport_data['score'] = $sport_data['score'] == '-' ? '' : $sport_data['score'];
-                $sport_data['extra_score'] = $sport_data['extra_score'] == '-' ? '' : $sport_data['extra_score'];
-    
-                if (!SportModel::where('data_id', $data_id)->exists()) {
-                    $sport_data['created_at'] = now();
-                    
-                    $sport_data['home_team'] = SportTeam::getTeamName($sport_data['home_team_id']);
-                    $sport_data['guest_team'] = SportTeam::getTeamName($sport_data['guest_team_id']);
-                    $sport_data['league'] = SportLeague::getLeagueName($sport_data['league_id']);
-                    $tableData[] = $sport_data;
-                } else {
-                    
-                    $sport_data['home_team'] = SportTeam::getTeamName($sport_data['home_team_id']);
-                    $sport_data['guest_team'] = SportTeam::getTeamName($sport_data['guest_team_id']);
-                    $sport_data['league'] = SportLeague::getLeagueName($sport_data['league_id']);
-                    SportModel::where('data_id', $item['fixture']['id'])->update($sport_data);
-                }
-
-                //更新或创建球队和联赛信息
-                SportModel::addSportTeam($sport_data);
-                SportModel::addSportLeague($item['league']);
-
-                //比赛结束,插入比赛事件
-                if (isset($sport_data['state']) && $sport_data['state'] == 2 ) {
-                    
-                    $data_id = $item['fixture']['id'];
-                    if (!empty($item['events'])) {
-                        $this->insertSportEvents($data_id, $item['events']);
-                    }
-                    
-                    //比赛结束,插入比赛事件
-                    $data = SportClientService::statistics(['fixture' => $data_id,'half' => 'true']);
-                    // file_put_contents("fixturesStatistics.json", json_encode($data));
-                    $statistics_data = empty($data['response']) ? [] : $data['response'];
-                    foreach($statistics_data as $item) {
-                        $team_id = $item['team']['id'];
-                        //上半场的数据
-                        if(!empty($item['statistics_1h'])) {
-                            $statistics_1h = $item['statistics_1h'];
-                            $this->insertSportStatistics($data_id, $team_id, $statistics_1h, 1); 
-                        }
-                        //下半场的数据
-                        if(!empty($item['statistics_2h'])) {
-                            $statistics_2h = $item['statistics_2h'];
-                            $this->insertSportStatistics($data_id, $team_id, $statistics_2h, 2); 
-                        }
-                    }
-                }
-            }
-            if ($tableData) {
-                SportModel::insert($tableData);
-            }
+            $this->updateOrCreateSport($data);
         }
         }
         
         
         return true;
         return true;
     }
     }
-    public function initOdds(){
-        $page = 1;
-        $limit = 10;
-        while (true) { 
-            $list = SportModel::where('odds','<>', null)->forPage($page, $limit)->get()->toArray();
-            if (empty($list)) {
-                break;
-            }
-            echo $page.PHP_EOL;
-            foreach($list as $item) {
-                $odds = json_decode($item['odds'], true);
-                foreach($odds as $odd) {
-                    $odd_id = $odd['id'];
-                    $odd_name = $odd['name'];
-                    $info = DB::table('sport_odds')->where('odd_id',$odd_id)->where('odd_name_en',$odd_name)->first();
-                    if ($info && (!$info->odd_name || $odd_name != $info->odd_name_en)) {
-                        DB::table('sport_odds')->where('id', $info->id)->update([
-                            'odd_name_en' => $odd_name,
-                        ]);
-                    } elseif (!$info) {
-                        DB::table('sport_odds')->insert([
-                            'odd_id' => $odd_id,
-                            'odd_name_en' => $odd_name,
-                            'created_at' => date('Y-m-d H:i:s'),
-                            'updated_at' => date('Y-m-d H:i:s'),
-                        ]);
-                    }
-                }
-            }
-
-            $page++;
-        }
-    }
 
 
     //比赛开始后,超过3个小时,并且更新时间超过10分钟,还是进行中的数据,更新成已完成
     //比赛开始后,超过3个小时,并且更新时间超过10分钟,还是进行中的数据,更新成已完成
     public function updateOvertimeFixtures()
     public function updateOvertimeFixtures()
     { 
     { 
         // 比赛开始后,状态还是未开始的数据检测
         // 比赛开始后,状态还是未开始的数据检测
         $end_time = date("Y-m-d H:i:s", time() - 600);
         $end_time = date("Y-m-d H:i:s", time() - 600);
-        SportModel::where('status', 1)->where('state', 1)->where('game_time', '<=', time() - 60*60*3)->where('updated_at', '<=', $end_time)->update(['state' =>2]);
+        SportModel::where('type', 2)->where('status', 1)->where('state', 1)->where('game_time', '<=', time() - 60*60*3)->where('updated_at', '<=', $end_time)->update(['state' =>2]);
         return true;
         return true;
     }
     }
 
 

+ 1 - 0
app/Http/Controllers/admin/PaymentOrder.php

@@ -72,6 +72,7 @@ class PaymentOrder extends Controller
                 'order_no' => ['nullable', 'string'],
                 'order_no' => ['nullable', 'string'],
                 'status' => ['nullable', 'integer', 'in:0,1,2,3'],
                 'status' => ['nullable', 'integer', 'in:0,1,2,3'],
                 'member_id' => ['nullable', 'integer'],
                 'member_id' => ['nullable', 'integer'],
+                'first_name' => ['nullable'],
             ]);
             ]);
 
 
             $params['type'] = 1;
             $params['type'] = 1;

+ 13 - 5
app/Http/Controllers/admin/User.php

@@ -167,28 +167,36 @@ class User extends Controller
                 'page' => ['nullable', 'integer', 'min:1'],
                 'page' => ['nullable', 'integer', 'min:1'],
                 'limit' => ['nullable', 'integer', 'min:1'],
                 'limit' => ['nullable', 'integer', 'min:1'],
                 'user_id' => ['nullable'],
                 'user_id' => ['nullable'],
+                'member_id' => ['nullable'],
+                'first_name' => ['nullable'],
                 'start_time' => ['nullable', 'date', 'date_format:Y-m-d', 'required_with:end_time'],
                 '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'],
                 'end_time' => ['nullable', 'date', 'date_format:Y-m-d', 'required_with:start_time'],
             ]);
             ]);
             $page = request()->input('page', 1);
             $page = request()->input('page', 1);
             $limit = request()->input('limit', 15);
             $limit = request()->input('limit', 15);
 
 
-            $query = new UserLogin();
+            $query = UserLogin::join('users', 'user_login.user_id', '=', 'users.user_id');
             if (!empty($params['user_id'])) {
             if (!empty($params['user_id'])) {
-                $query = $query->where('user_id', $params['user_id']);
+                $query = $query->where('user_login.user_id', $params['user_id']);
+            }
+            if (!empty($params['member_id'])) {
+                $query = $query->where('user_login.user_id', $params['member_id']);
+            }
+            if (!empty($params['first_name'])) {
+                $query = $query->where('users.first_name', 'like', "%{$params['first_name']}%");
             }
             }
             if (!empty($params['start_time'])) {
             if (!empty($params['start_time'])) {
                 $startTime = $params['start_time'] . " 00:00:00";
                 $startTime = $params['start_time'] . " 00:00:00";
-                $query = $query->where('created_at', '>=', $startTime);
+                $query = $query->where('user_login.created_at', '>=', $startTime);
             }
             }
             if (!empty($params['end_time'])) {
             if (!empty($params['end_time'])) {
                 $endTime = $params['end_time'] . " 23:59:59";
                 $endTime = $params['end_time'] . " 23:59:59";
-                $query = $query->where('updated_at', '<=', $endTime);
+                $query = $query->where('user_login.updated_at', '<=', $endTime);
             }
             }
             $count = $query->count();
             $count = $query->count();
             $list = $query
             $list = $query
                 ->forPage($page, $limit)
                 ->forPage($page, $limit)
-                ->orderByDesc('created_at')
+                ->orderByDesc('user_login.created_at')
                 ->get();
                 ->get();
         } catch (Exception $e) {
         } catch (Exception $e) {
             return $this->error(HttpStatus::CUSTOM_ERROR,$e->getMessage());
             return $this->error(HttpStatus::CUSTOM_ERROR,$e->getMessage());

+ 1 - 0
app/Http/Controllers/admin/Wallet.php

@@ -449,6 +449,7 @@ class Wallet extends Controller
                 'member_id' => ['nullable', 'string', 'min:1'],
                 'member_id' => ['nullable', 'string', 'min:1'],
                 'status' => ['nullable', 'string', 'min:0', 'max:3'],
                 'status' => ['nullable', 'string', 'min:0', 'max:3'],
                 'type' => ['nullable', 'integer', 'in:1,2'],
                 'type' => ['nullable', 'integer', 'in:1,2'],
+                'first_name' => ['nullable'],
             ]);
             ]);
             $search = request()->all();
             $search = request()->all();
             $result = RechargeService::paginate($search);
             $result = RechargeService::paginate($search);

+ 2 - 2
app/Models/SportLeague.php

@@ -13,7 +13,7 @@ class SportLeague extends BaseModel
     const CREATED_AT = 'create_time';
     const CREATED_AT = 'create_time';
     const UPDATED_AT = 'update_time';
     const UPDATED_AT = 'update_time';
 
 
-    public static function getLeagueName($league_id){
-        return self::where(['league_id' => $league_id])->value('league');
+    public static function getLeagueName($league_id, $type = 1){
+        return self::where(['league_id' => $league_id, 'type' => $type])->value('league');
     }
     }
 }
 }

+ 2 - 2
app/Models/SportTeam.php

@@ -13,7 +13,7 @@ class SportTeam extends BaseModel
     const CREATED_AT = 'create_time';
     const CREATED_AT = 'create_time';
     const UPDATED_AT = 'update_time';
     const UPDATED_AT = 'update_time';
 
 
-    public static function getTeamName($team_id){
-        return self::where(['team_id' => $team_id])->value('team_name');
+    public static function getTeamName($team_id, $type = 1){
+        return self::where(['team_id' => $team_id, 'type' => $type])->value('team_name');
     }
     }
 }
 }

+ 12 - 8
app/Services/PaymentOrderService.php

@@ -53,22 +53,25 @@ class PaymentOrderService extends BaseService
     {
     {
         $where = [];
         $where = [];
         if (isset($search['member_id']) && !empty($search['member_id'])) {
         if (isset($search['member_id']) && !empty($search['member_id'])) {
-            $where[] = ['member_id', '=', $search['member_id']];
+            $where[] = ['payment_orders.member_id', '=', $search['member_id']];
         }
         }
         if (isset($search['type']) && !empty($search['type'])) {
         if (isset($search['type']) && !empty($search['type'])) {
-            $where[] = ['type', '=', $search['type']];
+            $where[] = ['payment_orders.type', '=', $search['type']];
         }
         }
         if (isset($search['channel']) && !empty($search['channel'])) {
         if (isset($search['channel']) && !empty($search['channel'])) {
-            $where[] = ['channel', '=', $search['channel']];
+            $where[] = ['payment_orders.channel', '=', $search['channel']];
         }
         }
         if (isset($search['order_no']) && !empty($search['order_no'])) {
         if (isset($search['order_no']) && !empty($search['order_no'])) {
-            $where[] = ['order_no', '=', $search['order_no']];
+            $where[] = ['payment_orders.order_no', '=', $search['order_no']];
         }
         }
         if (isset($search['id']) && !empty($search['id'])) {
         if (isset($search['id']) && !empty($search['id'])) {
-            $where[] = ['id', '=', $search['id']];
+            $where[] = ['payment_orders.id', '=', $search['id']];
         }
         }
         if (isset($search['status']) && $search['status'] != '') {
         if (isset($search['status']) && $search['status'] != '') {
-            $where[] = ['status', '=', $search['status']];
+            $where[] = ['payment_orders.status', '=', $search['status']];
+        }
+        if (isset($search['first_name']) && !empty($search['first_name'])) {
+            $where[] = ['users.first_name', 'like', "%" . $search['first_name'] . "%"];
         }
         }
         return $where;
         return $where;
     }
     }
@@ -102,8 +105,9 @@ class PaymentOrderService extends BaseService
     {
     {
         $limit = isset($search['limit']) ? $search['limit'] : 15;
         $limit = isset($search['limit']) ? $search['limit'] : 15;
         $paginator = static::$MODEL::where(self::getWhere($search))
         $paginator = static::$MODEL::where(self::getWhere($search))
-            ->with(['userInfo'])
-            ->orderByDesc('created_at')
+            ->join('users', 'users.member_id', '=', 'payment_orders.member_id')
+            ->select("payment_orders.*", "users.first_name") // 提前查好需要的字段
+            ->orderByDesc('payment_orders.created_at')
             ->paginate($limit);
             ->paginate($limit);
 
 
 
 

+ 6 - 0
app/Services/RechargeService.php

@@ -116,8 +116,14 @@ class RechargeService extends BaseService
     public static function paginate(array $search = [])
     public static function paginate(array $search = [])
     {
     {
         $limit = isset($search['limit']) ? $search['limit'] : 15;
         $limit = isset($search['limit']) ? $search['limit'] : 15;
+        $first_name = $search['first_name'] ?? '';
         $paginator = static::$MODEL::where(self::getWhere($search))
         $paginator = static::$MODEL::where(self::getWhere($search))
             ->with(['member'])
             ->with(['member'])
+            ->when($first_name, function ($query) use ($first_name) {
+                $query->whereHas('member', function ($q) use ($first_name) {
+                    $q->where('first_name', 'like', "%{$first_name}%");
+                });
+            })
             ->orderBy("created_at", 'desc')
             ->orderBy("created_at", 'desc')
             ->paginate($limit);
             ->paginate($limit);
         $list = $paginator->items();
         $list = $paginator->items();