lip 1 vecka sedan
förälder
incheckning
64437307fb

+ 99 - 0
app/Console/Commands/Sport.php

@@ -0,0 +1,99 @@
+<?php
+
+namespace App\Console\Commands;
+
+use Illuminate\Console\Command;
+use App\Models\Sport as SportModel;
+
+class Sport extends Command
+{
+    /**
+     * 命令名称和签名
+     *
+     * @var string
+     */
+    protected $signature = 'sport';
+
+    /**
+     * 命令描述
+     *
+     * @var string
+     */
+    protected $description = '当天会去更新明天的赛事(23:59:00执行一次)';
+    /**
+     * 执行命令
+     *
+     * @return int
+     */
+    public function handle()
+    {
+        $this->info('开始执行统计比赛数据任务...');
+
+        $this->sportData();
+        
+        $this->info('结束执行统计比赛数据任务');
+    }
+
+    public function sportData()
+    {
+        try {
+            $today = date('Y-m-d');
+            $host = env('SPORT_HOST');
+            $url = "{$host}/api/sport";
+            $url .= "?date={$today}";
+            $result = file_get_contents($url);
+            $result = $result ? json_decode($result, true) : [];
+            foreach ($result as $item) {
+                $info = SportModel::where('data_id',$item['data_id'])->first();
+                $data = [
+                    'home_team_id' => $item['home_team_id'] ?? '',
+                    'home_team_en' => $item['home_team_en'] ?? '',
+                    'home_team' => $item['home_team'] ?? '',
+                    'home_team_logo' => $item['home_team_logo'] ?? '',
+                    'guest_team_id' => $item['guest_team_id'] ?? '',
+                    'guest_team_en' => $item['guest_team_en'] ?? '',
+                    'guest_team' => $item['guest_team'] ?? '',
+                    'guest_team_logo' => $item['guest_team_logo'] ?? '',
+                    'half_score' => $item['half_score'] ?? '',
+                    'rbt' => $item['rbt'] ?? '',
+                    'is_roll' => $item['is_roll'] ?? 0,
+                    'score' => $item['score'] ?? '',
+                    'league_en' => $item['league_en'] ?? '',
+                    'league' => $item['league'] ?? '',
+                    'odds' => $item['odds'] ?? '',
+                    'state' => $item['state'] ?? 0,
+                    'game_time' => $item['game_time'] ?? 0,
+                    'status' => $item['status'] ?? 0,
+                    'handicap_limit' => $item['handicap_limit'] ?? '',
+                    'over_under_limit' => $item['over_under_limit'] ?? '',
+                    'duying_limit' => $item['duying_limit'] ?? '',
+                    'correct_core_limit' => $item['correct_core_limit'] ?? '',
+                    'odd_even_limit' => $item['odd_even_limit'] ?? '',
+                    'total_goal_limit' => $item['total_goal_limit'] ?? '',
+                    'is_handicap' => $item['is_handicap'] ?? 0,
+                    'is_over_under' => $item['is_over_under'] ?? 0,
+                    'is_duying' => $item['is_duying'] ?? 0,
+                    'is_correct_core' => $item['is_correct_core'] ?? 0,
+                    'is_odd_even' => $item['is_odd_even'] ?? 0,
+                    'is_total_goal' => $item['is_total_goal'] ?? 0,
+                    'is_locked' => $item['is_locked'] ?? 0,
+                ];
+                if ($info) {
+                    //更新数据
+                    SportModel::where('data_id',$item['data_id'])->update($data);
+                } else {
+                    $data['data_id'] = $item['data_id'];
+                    SportModel::create($data);
+                }
+            }
+        } catch (\Exception $e) {
+            $this->error($e->getMessage());
+        }
+
+        
+        
+       
+        return true;
+    }
+
+}

+ 77 - 0
app/Console/Commands/SportOdds.php

@@ -0,0 +1,77 @@
+<?php
+
+namespace App\Console\Commands;
+
+use Illuminate\Console\Command;
+use App\Models\Sport as SportModel;
+
+class SportOdds extends Command
+{
+    /**
+     * 命令名称和签名
+     *
+     * @var string
+     */
+    protected $signature = 'sport:odds {is_roll=0}';
+
+    protected $is_roll = 0;
+
+    /**
+     * 命令描述
+     *
+     * @var string
+     */
+    protected $description = '赔率(滚球5秒更新一次,普通的3小时更新一次)';
+    /**
+     * 执行命令
+     *
+     * @return int
+     */
+    public function handle()
+    {
+        $this->is_roll = $this->argument('is_roll');
+        if ($this->is_roll == 1) {
+            $this->info('滚球开始执行赔率任务...');
+            $this->sportOddsData($this->is_roll);
+        } else {
+            $this->info('普通开始执行赔率任务...');
+            $this->sportOddsData($this->is_roll);
+        }
+        
+        $this->info('结束执行赔率任务');
+    }
+
+    public function sportOddsData($is_roll)
+    {
+        try {
+            $host = env('SPORT_HOST');
+            $where['status'] = 1;
+            $where['is_roll'] = $is_roll;
+            //滚球(滚球是开赛后随时可以买,更新数据)
+            if ($is_roll == 1) {
+                $where['state'] = 1; //比赛状态:0未开始1进行中2已完场3延期4取消
+                $url = "{$host}/api/sport/oddsLive";
+            } else {
+                //普通球赛是开赛前购买,更新数据
+                $where['state'] = 0;
+                $url = "{$host}/api/sport/odds";
+            }
+
+            $list = SportModel::where($where)->get()->toArray();
+            foreach ($list as $item) { 
+                $url .= "?data_id={$item['data_id']}";
+                $result = file_get_contents($url);
+                $result = $result ? json_decode($result, true) : [];
+            }
+           
+        } catch (\Exception $e) {
+            $this->error($e->getMessage());
+        }
+
+        
+        
+       
+        return true;
+    }
+
+}

+ 2 - 0
app/Console/Kernel.php

@@ -24,6 +24,8 @@ class Kernel extends ConsoleKernel
         //      ->withoutOverlapping() // 防止重复执行
         //      ->withoutOverlapping() // 防止重复执行
         //      ->name('five-second-task') // 给任务起个名字
         //      ->name('five-second-task') // 给任务起个名字
         //      ->onOneServer();       // 如果在多服务器环境
         //      ->onOneServer();       // 如果在多服务器环境
+
+        $schedule->command('sport')->dailyAt('23:59:00');
     }
     }
 
 
     /**
     /**

+ 14 - 12
app/Http/Controllers/admin/Banner.php

@@ -31,13 +31,13 @@ class Banner extends Controller
             $query = new BannerModel();
             $query = new BannerModel();
             $count = $query->count();
             $count = $query->count();
             $list = $query
             $list = $query
-                ->forPage($page, $limit)
-                ->orderByDesc('create_time')
-                ->get();
+                 ->forPage($page, $limit)
+                ->orderByDesc("sort")
+                ->get()->toArray();
         } catch (ValidationException $e) {
         } catch (ValidationException $e) {
             return $this->error(HttpStatus::VALIDATION_FAILED, $e->validator->errors()->first());
             return $this->error(HttpStatus::VALIDATION_FAILED, $e->validator->errors()->first());
         } catch (Exception $e) {
         } catch (Exception $e) {
-            return $this->error(intval($e->getCode()));
+            return $this->error(HttpStatus::CUSTOM_ERROR, $e->getMessage());
         }
         }
         return $this->success(['total' => $count, 'data' => $list]);
         return $this->success(['total' => $count, 'data' => $list]);
     }
     }
@@ -56,22 +56,24 @@ class Banner extends Controller
         DB::beginTransaction();
         DB::beginTransaction();
         try {
         try {
             $params = request()->validate([
             $params = request()->validate([
-                'id' => ['required', 'integer', 'min:0', 'max:99999999'],
+                'id' => ['nullable'],
                 'title' => ['required'],
                 'title' => ['required'],
                 'image' => ['required'],
                 'image' => ['required'],
                 'link' => ['nullable'],
                 'link' => ['nullable'],
                 'type' => ['nullable'],
                 'type' => ['nullable'],
-                'sort' => ['nullable', 'integer', 'min:0', 'max:99999999'],
+                'sort' => ['nullable'],
             ]);
             ]);
-            $id = request()->input('id', 0);
+            $id = $params['id'] ?? null;
 
 
             BannerModel::updateOrCreate(
             BannerModel::updateOrCreate(
                 ['id' => $id],
                 ['id' => $id],
-                ['title' => $params['title']],
-                ['image' => $params['image']],
-                ['link' => $params['link']],
-                ['type' => $params['type']],
-                ['sort' => $params['sort']],
+                [
+                    'title' => $params['title'],
+                    'image' => $params['image'],
+                    'link' => $params['link'],
+                    'type' => $params['type'],
+                    'sort' => $params['sort']
+                ],
             );
             );
             DB::commit();
             DB::commit();
         } catch (ValidationException $e) {
         } catch (ValidationException $e) {

+ 5 - 5
app/Http/Controllers/admin/Operation.php

@@ -31,16 +31,16 @@ class Operation extends Controller
             if (isset($params['user_id'])) {
             if (isset($params['user_id'])) {
                 $user_id = $params['user_id'];
                 $user_id = $params['user_id'];
                 $query->where(function ($query1) use ($user_id) {
                 $query->where(function ($query1) use ($user_id) {
-                    $query1->where('user_id', $user_id)
-                        ->orWhere('first_name', 'like', "%{$user_id}%");
+                    $query1->where('member_id', $user_id)
+                    ->orWhere('first_name', 'like', "%{$user_id}%");
                 });
                 });
             }
             }
 
 
             $count = $query->count();
             $count = $query->count();
-            $list = $query->join('wallets', 'users.member_id', '=', 'wallets.member_id')
-                ->select(['users.id', 'users.member_id', 'users.user_id', 'users.first_name', 'users.money','users.remark','wallets.available_balance as money'])
+            $list = $query->join('wallets', 'users.id', '=', 'wallets.user_id')
+                ->select(['users.id', 'users.member_id', 'users.first_name', 'wallets.available_balance as money'])
                 ->forPage($page, $limit)
                 ->forPage($page, $limit)
-                ->orderByDesc("last_login_time")
+                ->orderByDesc("created_at")
                 ->get()->toArray();
                 ->get()->toArray();
             
             
             $start = !empty($params['start_time']) ? "{$params['start_time']} 00:00:00" : null;
             $start = !empty($params['start_time']) ? "{$params['start_time']} 00:00:00" : null;

+ 1 - 0
app/Models/Banner.php

@@ -3,5 +3,6 @@ namespace App\Models;
 
 
 class Banner extends BaseModel
 class Banner extends BaseModel
 {
 {
+    protected $table = 'banner';
     protected $fillable = ['title', 'image', 'link' ,'type' ,'sort' ,'cny_rate' ];
     protected $fillable = ['title', 'image', 'link' ,'type' ,'sort' ,'cny_rate' ];
 }
 }

+ 12 - 0
app/Models/Sport.php

@@ -0,0 +1,12 @@
+<?php
+
+namespace App\Models;
+
+class Sport extends BaseModel
+{
+    protected $table = 'sport';
+    protected $fillable = ['data_id', 'home_team_id', 'home_team_en', 'home_team', 'home_team_logo', 'guest_team_id', 'guest_team_en', 'guest_team', 'guest_team_logo', 'half_score', 'rbt', 
+    'is_roll', 'score', 'league_en','league','odds','state','game_time','status','handicap_limit','over_under_limit','duying_limit','correct_core_limit','odd_even_limit','total_goal_limit',
+    'is_handicap', 'is_over_under','is_duying','is_correct_core','is_odd_even','is_total_goal','is_locked'];
+ 
+}

+ 1 - 1
app/Models/Wallet.php

@@ -4,5 +4,5 @@ namespace App\Models;
 class Wallet extends BaseModel
 class Wallet extends BaseModel
 {
 {
     protected $table = 'wallets';
     protected $table = 'wallets';
-    // protected $fillable = ['user_id','member_id', 'coin', 'available_balance','frozen_balance','total_balance'];
+    protected $fillable = ['user_id','member_id', 'coin', 'available_balance','frozen_balance','total_balance'];
 }
 }