ChannelController.php 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <?php
  2. namespace App\Http\Controllers\Api;
  3. use App\Facade\TableName;
  4. use Illuminate\Support\Facades\Redis;
  5. use Illuminate\Http\Request;
  6. use Illuminate\Support\Facades\DB;
  7. use Illuminate\Support\Facades\Log;
  8. class ChannelController
  9. {
  10. public function index()
  11. {
  12. $list = DB::table('QPPlatformDB.dbo.ChannelConfig')->where('ReviewState', 1)->get();
  13. return apiReturnSuc($list);
  14. }
  15. // 渠道包开放的充值渠道
  16. public function ChannelOpenRecharge(Request $request)
  17. {
  18. $Channel = $request->Channel ?: '0';
  19. $channelNumber = $request->ChannelNumber ?: null;
  20. if (!$channelNumber) {
  21. $channelNumber = DB::connection('write')->table('QPPlatformDB.dbo.ChannelPackageName')
  22. ->where('PackageName', $Channel)->value('Channel');
  23. }
  24. $list = DB::connection('write')->table('QPPlatformDB.dbo.ChannelOpenRecharge as go')
  25. ->join('agent.dbo.admin_configs as cf', 'go.ConfigID', '=', 'cf.id')
  26. ->where('go.Channel', $channelNumber)
  27. ->where('go.Status', 1)
  28. ->where('cf.type', 'pay_method')
  29. ->orderByDesc('go.Sort')
  30. ->select('name', 'ConfigID')
  31. ->get();
  32. if (!isset($list) || $list->count() == 0) { // 默认配置
  33. $list = DB::connection('write')->table('agent.dbo.admin_configs')
  34. ->where('type', 'pay_method')
  35. ->where('status', 1)
  36. ->select('id as ConfigID')
  37. ->get();
  38. }
  39. return apiReturnSuc($list);
  40. }
  41. // 渠道包开放的游戏渠道
  42. public function ChannelGameOpen(Request $request)
  43. {
  44. $PackageName=$request->PackageName?:0;
  45. if($PackageName)$Channel=$PackageName;
  46. else $Channel = $request->Channel ?: 1;
  47. $cv=1;
  48. if(isset($request->cv)){
  49. $cvstr=explode('.',$request->cv);
  50. $cv=array_pop($cvstr);
  51. }
  52. $list=self::searchChannel($Channel,$cv);
  53. return apiReturnSuc($list);
  54. }
  55. public static function searchChannel($Package, $cv){
  56. $key="gamelist_{$Package}_{$cv}";
  57. if(Redis::exists($key)){
  58. try{
  59. $list= \GuzzleHttp\json_decode(Redis::get($key), true);
  60. }catch (\Exception $e){
  61. }
  62. }
  63. if(!isset($list)||!count($list)){
  64. if ($Package != 1) {
  65. $list = DB::connection('write')->table('QPPlatformDB.dbo.ChannelPackageName as co')
  66. ->leftJoin('QPPlatformDB.dbo.ChannelGameOpen as go', 'co.Channel', 'go.Channel')
  67. ->where('PackageName', $Package)
  68. ->where('Status', 1)
  69. ->where('LimitCV', "<=", $cv)
  70. ->whereIn('KindID', config('games.openKGame'))
  71. ->orderByDesc('go.Sort')
  72. ->select('KindID', 'IconType', 'NewGame')
  73. ->get();
  74. }
  75. if (!isset($list) || $list->count() == 0) { // 默认配置
  76. $list = DB::connection('write')->table('QPPlatformDB.dbo.ChannelGameOpen')
  77. ->where('Channel', -1)
  78. ->where('Status', 1)
  79. ->where('LimitCV', "<=", $cv)
  80. ->whereIn('KindID', config('games.openKGame'))
  81. ->orderByDesc('Sort')
  82. ->select('KindID', 'IconType', 'NewGame')
  83. ->get();
  84. }
  85. Redis::set($key,json_encode($list));
  86. Redis::expire($key,60);
  87. }
  88. return $list;
  89. }
  90. // 渠道包是否展示在新次级游戏界面
  91. public function ChannelSecondStage(Request $request)
  92. {
  93. $Channel = $request->Channel ?: '0';
  94. if ($Channel != 1) {
  95. $list = DB::connection('write')->table('QPPlatformDB.dbo.ChannelPackageName as co')
  96. ->leftJoin('QPPlatformDB.dbo.ChannelGameOpen as go', 'co.Channel', 'go.Channel')
  97. ->where('PackageName', $Channel)
  98. ->where('Status', 1)
  99. ->whereIn('KindID', config('games.openKGame'))
  100. ->orderByDesc('go.SecondStageSort')
  101. ->select('KindID')
  102. ->selectRaw('IsNull(SecondStageStatus,2) SecondStageStatus,IsNull(SecondStageSort,0) SecondStageSort')
  103. ->get();
  104. }
  105. if (!isset($list) || $list->count() == 0) { // 默认配置
  106. $list = DB::connection('write')->table('QPPlatformDB.dbo.ChannelGameOpen')
  107. ->where('Channel', -1)
  108. ->where('Status', 1)
  109. ->whereIn('KindID', config('games.openKGame'))
  110. ->orderByDesc('SecondStageSort')
  111. ->select('KindID')
  112. ->selectRaw('IsNull(SecondStageStatus,2) SecondStageStatus,IsNull(SecondStageSort,0) SecondStageSort')
  113. ->get();
  114. }
  115. return apiReturnSuc($list);
  116. }
  117. // 分渠道展示游戏分享链接
  118. public function shareUrl(Request $request)
  119. {
  120. $Channel = $request->Channel ?: 100;
  121. $GameShareUrl = '';
  122. $UrlSelect = 1;
  123. if (!empty($Channel)) {
  124. $res = DB::table(TableName::QPPlatformDB() . 'ChannelPackageName')
  125. ->where('Channel', $Channel)
  126. ->first();
  127. if ($res && $res->UrlStatus && $res->UrlSelect == 1) {
  128. $GameShareUrl = $res->ShareUrl;
  129. }
  130. if ($res && $res->UrlStatus && $res->UrlSelect == 2) {
  131. $GameShareUrl = $res->SpreadShareUrl;
  132. $UrlSelect = $res->UrlSelect;
  133. }
  134. }
  135. if (empty($GameShareUrl) || empty($Channel)) {
  136. $GameShareUrl = DB::table(TableName::QPAccountsDB() . 'SystemStatusInfo')
  137. ->where('StatusName', 'GameShareUrl')
  138. ->value('StatusString');
  139. }
  140. $data = compact('GameShareUrl', 'UrlSelect');
  141. return apiReturnSuc($data);
  142. }
  143. }