SignInController.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. namespace App\Http\Controllers\Admin;
  3. use App\Http\helper\NumConfig;
  4. use Illuminate\Http\Request;
  5. use Illuminate\Support\Facades\DB;
  6. // 签到
  7. class SignInController
  8. {
  9. public function index(Request $request)
  10. {
  11. return false;
  12. $start_time = $request->start_time ?: date('Y-m-d').' 00:00:00';
  13. $end_time = $request->end_time ?: date('Y-m-d').' 23:59:59';
  14. $GameID = $request->GameID ?: '';
  15. $NickName = $request->NickName ?: '';
  16. $Channel = $request->Channel ?: '';
  17. $where[] = ['Reason', 44];
  18. !empty($start_time) && $where[] = ['UpdateTime', '>=', date('Y-m-d H:i:s', strtotime($start_time))];
  19. !empty($end_time) && $where[] = ['UpdateTime', '<=', date('Y-m-d H:i:s', strtotime($end_time))];
  20. !empty($GameID) && $where[] = ['GameID', $GameID];
  21. !empty($NickName) && $where[] = ['NickName', 'like', $NickName . '%'];
  22. !empty($Channel) && $where[] = ['Channel', $Channel];
  23. $ChannelList = DB::connection('write')->table('QPPlatformDB.dbo.ChannelPackageName')->pluck('Channel', 'ID');
  24. ////////////////////////
  25. // 查询范围需要在同一个月份,暂时不支持跨月份查询
  26. $from_mm = intval(date('Ym',strtotime($start_time)));
  27. $to_mm = intval(date('Ym',strtotime($end_time)));
  28. if( $from_mm != $to_mm ){
  29. throw new Exception('暂不支持跨月查询,开始时间和结束时间请选择相同月份');
  30. }
  31. //确定有效表范围,从202104月开始到当前月
  32. if($from_mm < 202104 || $from_mm > intval(date('Ym'))){
  33. $from_mm = date('Ym');
  34. }
  35. $table = 'QPTreasureDB.dbo.YN_RecordScoreInfo_'.$from_mm;
  36. //////////////////////
  37. $list = DB::connection('write')->table(DB::raw($table.' as ri WITH (NOLOCK)'))
  38. ->join(DB::raw('QPAccountsDB.dbo.AccountsInfo as ai WITH (NOLOCK)'), 'ri.UserID', 'ai.UserID')
  39. ->where($where)
  40. ->selectRaw('ri.*,ai.GameID,ai.NickName,Channel')
  41. ->orderByDesc('UpdateTime')
  42. ->paginate(50);
  43. foreach ($list as $value) {
  44. $value->ChangeScore = number_float($value->ChangeScore / NumConfig::NUM_VALUE);
  45. }
  46. $data = compact('list', 'ChannelList', 'start_time', 'end_time', 'GameID', 'NickName', 'Channel');
  47. return view('admin.sign_in.index', $data);
  48. }
  49. }