ChannelController.php 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826
  1. <?php
  2. namespace App\Http\Controllers\Admin;
  3. // 渠道管理
  4. use App\Facade\TableName;
  5. use App\Game\WebChannelConfig;
  6. use App\Http\helper\Helper;
  7. use App\Http\logic\admin\ChannelLogic;
  8. use App\Http\logic\admin\RechargeLogic;
  9. use App\Jobs\ClearCache;
  10. use App\Models\AppSwitch;
  11. use App\Models\SystemStatusInfo;
  12. use App\Models\WithdrawalChannelPositionConfig;
  13. use App\Models\WithdrawalPositionConfig;
  14. use App\Services\GameRoomInfo;
  15. use App\Util;
  16. use Illuminate\Http\Request;
  17. use Illuminate\Support\Facades\DB;
  18. use Illuminate\Support\Facades\Redis;
  19. use Illuminate\Support\Facades\Validator;
  20. class ChannelController
  21. {
  22. public function index(Request $request)
  23. {
  24. $where = [];
  25. $name = $request->Name ?: '';
  26. !empty($name) && $where[] = ['Name', 'like', $name . '%'];
  27. // $notIn = [1, 2, 3, 4, 5, 7, 10, 13, 14, 15, 16, 17];
  28. $list = DB::connection('write')->table('QPPlatformDB.dbo.ChannelConfig')
  29. // ->whereNotIn('ChannelIndex', $notIn)
  30. ->where($where)
  31. ->paginate(10);
  32. return view('admin.channel.index', ['list' => $list, 'Name' => $name]);
  33. }
  34. public function channelAdd(Request $request)
  35. {
  36. if ($request->isMethod('post')) {
  37. $post = $request->post();
  38. $Channel = $post['Channel'];
  39. $post['ChannelType'] = 100;
  40. $post['ChannelIndex'] = $Channel - $post['ChannelType'];
  41. $post['ReviewState'] = 1;
  42. unset($post['Channel']);
  43. DB::connection('write')->table('QPPlatformDB.dbo.ChannelConfig')
  44. ->insert($post);
  45. // 同步添加渠道包
  46. DB::connection('write')->table('QPPlatformDB.dbo.ChannelRechargeGameOpen')
  47. ->insert(['ChannelPackageName' => $post['Name'], 'Channel' => $Channel]);
  48. return apiReturnSuc();
  49. } else {
  50. return view('admin.channel.channel_add');
  51. }
  52. }
  53. public function channelNew(Request $request)
  54. {
  55. if ($request->isMethod('post')) {
  56. $post = $request->post();
  57. $post['Remarks'] = $post['AliasName'];
  58. $post['AppKey']= Util::generateRandomString();
  59. while(DB::connection('write')->table('QPPlatformDB.dbo.ChannelPackageName')->where('AppKey', $post['AppKey'])->exists()) {
  60. $post['AppKey'] = Util::generateRandomString();
  61. }
  62. DB::connection('write')->table('QPPlatformDB.dbo.ChannelPackageName')
  63. ->insert($post);
  64. $channel = @$post['Channel'];
  65. if($channel){
  66. $createConfig = function () use($channel) {
  67. $config = new WithdrawalChannelPositionConfig();
  68. $config->channel = $channel;
  69. return $config;
  70. };
  71. $config = WithdrawalChannelPositionConfig::query()->where('channel', $channel)->first() ?: $createConfig();
  72. $config->save();
  73. }
  74. return apiReturnSuc();
  75. } else {
  76. return view('admin.channel.channel_new');
  77. }
  78. }
  79. public function channelEdit(Request $request, $id)
  80. {
  81. $ChannelIndex = $request->ChannelIndex;
  82. $AndroidVersion = $request->AndroidVersion;
  83. $where = [
  84. ['ChannelType', '=', $id],
  85. ['ChannelIndex', '=', $ChannelIndex],
  86. ['AndroidVersion', '=', $AndroidVersion],
  87. ];
  88. if ($request->isMethod('post')) {
  89. $post = $request->post();
  90. //$post['ChannelIndex'] = $post['Channel'] - $post['ChannelType'];
  91. unset($post['Channel']);
  92. DB::connection('write')->table('QPPlatformDB.dbo.ChannelConfig')
  93. ->where($where)
  94. ->update($post);
  95. // 同步修改渠道包
  96. DB::connection('write')->table('QPPlatformDB.dbo.ChannelRechargeGameOpen')
  97. ->where('Channel', ($id + $ChannelIndex))
  98. ->update(['ChannelPackageName' => $post['Name']]);
  99. return apiReturnSuc();
  100. } else {
  101. $info = DB::connection('write')->table('QPPlatformDB.dbo.ChannelConfig')
  102. ->where($where)
  103. ->first();
  104. return view('admin.channel.channel_edit', compact('info', 'id', 'ChannelIndex', 'AndroidVersion'));
  105. }
  106. }
  107. public function switch_control(Request $request, $id)
  108. {
  109. $type = $request->type;
  110. $ChannelIndex = $request->ChannelIndex;
  111. $AndroidVersion = $request->AndroidVersion;
  112. $logic = new ChannelLogic();
  113. $res = $logic->switch_control($id, $ChannelIndex, $AndroidVersion, $type);
  114. if ($res === false) {
  115. return apiReturnFail($logic->getError());
  116. }
  117. return apiReturnSuc();
  118. }
  119. public function update(Request $request, $ChannelType)
  120. {
  121. $ChannelIndex = $request->ChannelIndex ?: '';
  122. $ChannelName = $request->ChannelName ?: '';
  123. $AndroidVersion = $request->AndroidVersion;
  124. $data = $request->data ?: '';
  125. $where[] = ['ChannelIndex', '=', $ChannelIndex];
  126. $where[] = ['ChannelType', '=', $ChannelType];
  127. $where[] = ['AndroidVersion', '=', $AndroidVersion];
  128. if ($request->isMethod('POST')) {
  129. DB::connection('write')->table('QPPlatformDB.dbo.ChannelConfig')
  130. ->where($where)
  131. ->updateOrInsert($where, $data);
  132. return apiReturnSuc();
  133. } else {
  134. $info = DB::connection('read')->table('QPPlatformDB.dbo.ChannelConfig')
  135. ->where($where)
  136. ->first();
  137. return view('admin.channel.update', [
  138. 'info' => $info,
  139. 'ChannelName' => $ChannelName
  140. ]);
  141. }
  142. }
  143. public function ChannelSaveLog()
  144. {
  145. $list = DB::connection('read')->table('agent.dbo.ChannelSaveLog as log')
  146. ->join('agent.dbo.admin_users as au', 'log.admin_id', '=', 'au.id')
  147. ->select('au.account', 'log.*')
  148. ->paginate(10);
  149. foreach ($list as &$val) {
  150. $ChannelName = '';
  151. switch ($val->channel) {
  152. case 0:
  153. $ChannelName = '官方';
  154. break;
  155. case 100: // 谷歌渠道
  156. switch ($val->ChannelIndex) {
  157. case 0:
  158. $ChannelName = '谷歌渠道';
  159. break;
  160. case 1:
  161. $ChannelName = 'Teenpatti Royal';
  162. break;
  163. case 2:
  164. $ChannelName = 'teenpatti club';
  165. break;
  166. case 3:
  167. $ChannelName = 'Teenpatti.Champion';
  168. break;
  169. case 4:
  170. $ChannelName = 'com.teempatti.Victory';
  171. break;
  172. case 5:
  173. $ChannelName = 'com.teempatti.fun';
  174. break;
  175. case 6:
  176. $ChannelName = 'teenpatti Exceed';
  177. break;
  178. case 7:
  179. $ChannelName = 'com.teempatti.reward';
  180. break;
  181. case 8:
  182. $ChannelName = 'com.teempatti.qplayer';
  183. break;
  184. case 9:
  185. $ChannelName = 'com.teempatti.q3acard';
  186. break;
  187. case 10:
  188. $ChannelName = 'com.teempatti.qnobles';
  189. break;
  190. case 11:
  191. $ChannelName = 'com.teempatti.qgrandparty';
  192. break;
  193. case 12:
  194. $ChannelName = 'com.teempatti.queen';
  195. break;
  196. case 13:
  197. $ChannelName = 'com.teempatti.royalclub';
  198. break;
  199. case 14:
  200. $ChannelName = 'com.teempatti.queencard';
  201. break;
  202. case 15:
  203. $ChannelName = 'com.teempatti.queensnice';
  204. break;
  205. case 16:
  206. $ChannelName = 'com.teempatti.queensplay';
  207. break;
  208. case 17:
  209. $ChannelName = 'com.teempatti.queensclub';
  210. break;
  211. }
  212. }
  213. $val->ChannelName = $ChannelName;
  214. }
  215. return view('admin.channel.ChannelSaveLog', ['list' => $list]);
  216. }
  217. // 渠道审核屏蔽ID白名单
  218. public function ChannelShieldIDWhite()
  219. {
  220. // $list = DB::connection('write')->table('QPPlatformDB.dbo.ChannelShieldIDWhite')->paginate(10);
  221. $list = DB::connection('read')->table('QPAccountsDB.dbo.IDWhiteUser as white')
  222. ->join('QPAccountsDB.dbo.AccountsInfo as acc', 'acc.UserID', '=', 'white.UserID')
  223. ->select('acc.GameID', 'acc.UserID','white.Remarks')
  224. ->paginate(100);
  225. // print_r($list);die;
  226. return view('admin.channel.channel_shield_id_white', compact('list'));
  227. }
  228. // 渠道审核屏蔽ID白名单 -- 添加ID
  229. public function add(Request $request)
  230. {
  231. if ($request->isMethod('post')) {
  232. $post = $request->post();
  233. $userid = DB::connection('write')->table('QPAccountsDB.dbo.AccountsInfo')
  234. ->where('GameID', $post['GameID'])
  235. ->select('UserID')
  236. ->first()->UserID;
  237. if (!$userid) {
  238. return apiReturnFail('用户ID不存在');
  239. }
  240. $first = DB::connection('write')->table('QPAccountsDB.dbo.IDWhiteUser')
  241. ->where('UserID', $userid)
  242. ->first();
  243. if ($first) {
  244. return apiReturnFail('用户已经存在');
  245. }
  246. DB::connection('write')->table('QPAccountsDB.dbo.IDWhiteUser')
  247. ->insert(['UserID'=>$userid,'Remarks'=>$post['Remarks']]);
  248. return apiReturnSuc();
  249. }
  250. return view('admin.channel.channel_shield_id_white_add');
  251. }
  252. // 渠道审核屏蔽ID白名单 -- 修改ID
  253. public function edit(Request $request, $ID)
  254. {
  255. if ($request->isMethod('post')) {
  256. $post = $request->post();
  257. DB::connection('write')->table('QPAccountsDB.dbo.IDWhiteUser')
  258. ->where('UserID', $ID)
  259. ->update($post);
  260. return apiReturnSuc();
  261. }
  262. $info = DB::connection('write')->table('QPAccountsDB.dbo.IDWhiteUser')
  263. ->where('UserID', $ID)
  264. ->first();
  265. return view('admin.channel.channel_shield_id_white_add', compact('info'));
  266. }
  267. // 渠道审核屏蔽ID白名单 -- 删除ID
  268. public function del($ID)
  269. {
  270. DB::connection('write')->table('QPAccountsDB.dbo.IDWhiteUser')
  271. ->where('UserID', $ID)
  272. ->delete();
  273. return apiReturnSuc();
  274. }
  275. // 渠道审核屏蔽ID白名单 -- 修改状态
  276. public function updateState(Request $request)
  277. {
  278. $State = (int)$request->State;
  279. $State = DB::connection('write')->table('QPAccountsDB.dbo.SystemStatusInfo')
  280. ->where('StatusName', 'ChannelShieldIDWhite')
  281. ->update(['StatusValue' => $State]);
  282. return apiReturnSuc();
  283. }
  284. // 渠道包配置充值和游戏
  285. public function rechargeGame(Request $request)
  286. {
  287. $ChannelPackageName = $request->ChannelPackageName ?: '';
  288. $list = (new ChannelLogic())->rechargeGame($ChannelPackageName);
  289. return view('admin.channel.recharge_game', compact('list'));
  290. }
  291. // 开放游戏配置修改 $Channel == -1 默认游戏配置
  292. // 开放游戏配置修改 $Channel == -1 默认游戏配置
  293. public function OpenGames(Request $request, $Channel)
  294. {
  295. $ChannelPackageName = $request->ChannelPackageName ?: '';
  296. if ($request->isMethod('post')) {
  297. $post = $request->all();
  298. $GameShareUrl = $post['ShareUrl'] ?? '';
  299. unset($post['ShareUrl']);
  300. $arr = [];
  301. if (isset($post['KindID'])) {
  302. for ($i = 0; $i < count($post['KindID']); $i++) {
  303. if (isset($post['KindID'][$i]) && $post['KindID'][$i] >= 0) {
  304. $arr[$i]['KindID'] = $post['KindID'][$i];
  305. $arr[$i]['Status'] = $post['Status'][$i] ?? 1;
  306. $arr[$i]['Sort'] = $post['Sort'][$i] ?? 0;
  307. $arr[$i]['SecondStageStatus'] = $post['SecondStageStatus'][$i] ?? 0;
  308. $arr[$i]['SecondStageSort'] = $post['SecondStageSort'][$i] ?? 0;
  309. $arr[$i]['IconType'] = $post['IconType'][$i] ?? 1;
  310. $arr[$i]['Channel'] = $Channel;
  311. $arr[$i]['LimitCV'] = $post['LimitCV'][$i]??0;
  312. $arr[$i]['VIP'] = $post['VIP'][$i]??0;
  313. }
  314. }
  315. }
  316. DB::connection('write')->table('QPPlatformDB.dbo.ChannelGameOpen')
  317. ->where('Channel', $Channel)
  318. ->delete();
  319. DB::connection('write')->table('QPPlatformDB.dbo.ChannelGameOpen')
  320. ->insert($arr);
  321. // 修改默认游戏分享链接
  322. if (!empty($GameShareUrl)) {
  323. DB::table(TableName::QPAccountsDB() . 'SystemStatusInfo')
  324. ->where('StatusName', 'GameShareUrl')
  325. ->update(['StatusString' => $GameShareUrl]);
  326. }
  327. // ted提现开关
  328. if ($request->input('ted_switch', null) !== null) {
  329. $tedSwitch = AppSwitch::query()->firstOrNew(['name' => 'ted', 'scene' => 1, 'channel' => $Channel]);
  330. $tedSwitch->status = $request->input('ted_switch');
  331. $tedSwitch->save();
  332. }
  333. return apiReturnSuc();
  334. }
  335. $openGames = config('games.openKGame');
  336. $list = DB::connection('write')->table('QPPlatformDB.dbo.GameKindItem as gi')
  337. ->leftJoin('QPPlatformDB.dbo.ChannelGameOpen as cg', function ($join) use ($Channel) {
  338. $join->on('gi.KindID', 'cg.KindID');
  339. $join->where('Channel', $Channel);
  340. })
  341. ->whereIn('gi.KindID', $openGames)
  342. ->selectRaw('IsNull(Status,2) Status,KindName,gi.KindID,cg.Sort,SecondStageStatus,SecondStageSort,IconType,LimitCV,VIP')
  343. ->orderByDesc('Sort')
  344. ->get();
  345. // 游戏默认分享链接
  346. $GameShareUrl = DB::table(TableName::QPAccountsDB() . 'SystemStatusInfo')
  347. ->where('StatusName', 'GameShareUrl')
  348. ->value('StatusString');
  349. $tedSwitch = AppSwitch::query()->where([
  350. 'name' => 'ted',
  351. 'channel' => $Channel
  352. ])->first();
  353. return view(
  354. 'admin.channel.open_games',
  355. compact('list', 'ChannelPackageName', 'Channel', 'GameShareUrl', 'tedSwitch')
  356. );
  357. }
  358. public function payMethods($channel, Request $request)
  359. {
  360. $list = DB::connection('write')->table('agent.dbo.admin_configs as ac')
  361. ->leftJoin('QPPlatformDB.dbo.ChannelOpenRecharge as oc', function ($join) use ($channel) {
  362. $join->on('ac.id', '=', 'oc.ConfigID');
  363. $join->where('Channel', $channel);
  364. })
  365. ->where('type', 'pay_method')
  366. ->selectRaw('IsNull(oc.Status,2) Status,name,ac.id,oc.Sort, ac.config_key')
  367. ->get();
  368. foreach ($list as $k => $v) {
  369. $channels = DB::table('agent.dbo.admin_configs as ac')->where([
  370. 'type' => 'pay',
  371. 'new_pay_type' => $v->config_key
  372. ])
  373. ->leftJoin('QPPlatformDB.dbo.ChannelOpenRecharge as oc', function ($join) use ($channel) {
  374. $join->on('ac.id', '=', 'oc.ConfigID');
  375. $join->where('Channel', $channel);
  376. })
  377. ->selectRaw('IsNull(oc.Status,2) Status,name,ac.id,oc.Sort, ac.config_key')
  378. ->get();
  379. $list[$k]->channels = $channels;
  380. }
  381. $switch = intval(Redis::get("recharge_config_switch_{$channel}"));
  382. return view('admin.channel.pay_methods', [
  383. 'list' => $list,
  384. 'channel' => $channel,
  385. 'switch' => $switch
  386. ]);
  387. }
  388. public function updatePayConfig($channel, Request $request)
  389. {
  390. $switch = $request->input('switch', 0);
  391. Redis::set("recharge_config_switch_{$channel}", $switch);
  392. $switchOpened = DB::table('agent.dbo.admin_configs')->where([
  393. 'type' => 'pay',
  394. 'status' => 1,
  395. ])->pluck('id');
  396. $payMethodOpened = DB::table('agent.dbo.admin_configs')->where([
  397. 'type' => 'pay_method',
  398. 'status' => 1,
  399. ])->pluck('id');
  400. $inserts = [];
  401. foreach ($request->input('items') as $k => $v) {
  402. if (!in_array($v['id'], $payMethodOpened->toArray()) && $v['status'] == 1) {
  403. return apiReturnFail($v['id'] . '总开关已关闭,无法开启');
  404. }
  405. $inserts[] = [
  406. 'ConfigID' => $v['id'],
  407. 'Status' => $v['status'],
  408. 'Sort' => $v['sort'],
  409. 'Channel' => $channel
  410. ];
  411. $percent = 0;
  412. foreach ($v['channels'] ?? [] as $k1 => $v1) {
  413. if (!in_array($v1['id'], $switchOpened->toArray()) && $v1['status'] == 1) {
  414. return apiReturnFail($v1['id'] . '总开关已关闭,无法开启');
  415. }
  416. $inserts[] = [
  417. 'ConfigID' => $v1['id'],
  418. 'Status' => $v1['status'],
  419. 'Sort' => $v1['sort'],
  420. 'Channel' => $channel
  421. ];
  422. $percent += $v1['sort'];
  423. }
  424. if ($percent != 100 && $v['status'] == 1) {
  425. return apiReturnFail('权重值分配不正确');
  426. }
  427. }
  428. DB::connection('write')->table('QPPlatformDB.dbo.ChannelOpenRecharge')
  429. ->where('Channel', $channel)
  430. ->delete();
  431. DB::connection('write')->table('QPPlatformDB.dbo.ChannelOpenRecharge')
  432. ->insert($inserts);
  433. ClearCache::dispatch();
  434. return apiReturnSuc();
  435. }
  436. // 充值配置修改
  437. public function OpenRecharge(Request $request, $Channel)
  438. {
  439. $ChannelPackageName = $request->ChannelPackageName ?: '';
  440. if ($request->isMethod('post')) {
  441. $post = $request->all();
  442. $arr = [];
  443. if (isset($post['id'])) {
  444. for ($i = 0; $i < count($post['id']); $i++) {
  445. $arr[$i]['ConfigID'] = $post['id'][$i] ?? 0;
  446. $arr[$i]['Status'] = $post['Status'][$i] ?? 1;
  447. $arr[$i]['Sort'] = $post['Sort'][$i] ?? 0;
  448. $arr[$i]['Channel'] = $Channel;
  449. }
  450. }
  451. DB::connection('write')->table('QPPlatformDB.dbo.ChannelOpenRecharge')
  452. ->where('Channel', $Channel)
  453. ->delete();
  454. DB::connection('write')->table('QPPlatformDB.dbo.ChannelOpenRecharge')
  455. ->insert($arr);
  456. ClearCache::dispatch();
  457. return apiReturnSuc();
  458. }
  459. $list = DB::connection('write')->table('agent.dbo.admin_configs as ac')
  460. ->leftJoin('QPPlatformDB.dbo.ChannelOpenRecharge as oc', function ($join) use ($Channel) {
  461. $join->on('ac.id', '=', 'oc.ConfigID');
  462. $join->where('Channel', $Channel);
  463. })
  464. ->where('ac.status', 1)
  465. ->where('type', 'pay')
  466. ->selectRaw('IsNull(oc.Status,2) Status,name,ac.id,oc.Sort')
  467. ->get();
  468. return view('admin.channel.open_recharge', compact('list', 'ChannelPackageName', 'Channel'));
  469. }
  470. // 修改备注
  471. public function appkey(Request $request, $id)
  472. {
  473. $app=DB::connection('write')->table('QPPlatformDB.dbo.ChannelPackageName')
  474. ->where('ID', $id)->first();
  475. if(empty($app->AppKey)) {
  476. $AppKey=Util::generateRandomString(random_int(6,12));
  477. DB::connection('write')->table('QPPlatformDB.dbo.ChannelPackageName')
  478. ->where('ID', $id)
  479. ->update(['AppKey' => $AppKey]);
  480. }else{
  481. $AppKey=$app->AppKey;
  482. }
  483. return apiReturnSuc($AppKey);
  484. }
  485. // 修改备注
  486. public function app_key_set(Request $request, $id)
  487. {
  488. $config = DB::table('QPPlatformDB.dbo.ChannelPackageName')->where('ID', $id)->first();
  489. if ($request->method() == 'GET') {
  490. return view('admin.channel.app_key_set', [
  491. 'config' => $config,
  492. ]);
  493. }
  494. $data=$request->all();
  495. $data['AdjustConfig']=$data['AdjustConfig']??"";
  496. DB::table('QPPlatformDB.dbo.ChannelPackageName')->where('ID', $id)->update($data);
  497. return apiReturnSuc();
  498. }
  499. // 修改备注
  500. public function review(Request $request, $id)
  501. {
  502. $review=$request->status?:0;
  503. DB::connection('write')->table('QPPlatformDB.dbo.ChannelPackageName')
  504. ->where('ID', $id)
  505. ->update(['InReview' => $review]);
  506. $app=DB::connection('write')->table('QPPlatformDB.dbo.ChannelPackageName')
  507. ->where('ID', $id)->first();
  508. Redis::del("InReview_{$id}");
  509. Redis::del("InReview_{$app->PackageName}");
  510. return apiReturnSuc($review);
  511. }
  512. // 修改备注
  513. public function remarks(Request $request, $id)
  514. {
  515. $remarks = $request->remark ?: '';
  516. DB::connection('write')->table('QPPlatformDB.dbo.ChannelPackageName')
  517. ->where('ID', $id)
  518. ->update(['Remarks' => $remarks,'AliasName'=>$remarks]);
  519. $cp=DB::connection('write')->table('QPPlatformDB.dbo.ChannelPackageName')
  520. ->where('ID', $id)->select('Channel','PackageName')->first();
  521. $Channel=$cp->Channel;
  522. $PackageName=$cp->PackageName;
  523. if(WebChannelConfig::where('Channel', $Channel)->exists()) {
  524. WebChannelConfig::where('Channel', $Channel)->update(['Remarks' => $remarks]);
  525. }else{
  526. $config=WebChannelConfig::getByChannel(50)->toArray();
  527. $config['Remarks']=$remarks;
  528. $config['Channel']=$Channel;
  529. $config['PackageName']=$PackageName;
  530. unset($config['ID']);
  531. WebChannelConfig::insert($config);
  532. }
  533. $dcatChannel=DB::connection('mysql')->table('dcat-admin.channel')->where('channel',$Channel);
  534. if($dcatChannel->exists()){
  535. $dcatChannel->update(['channel_name'=>$remarks]);
  536. }else{
  537. DB::connection('mysql')->table('dcat-admin.channel')->insert(['channel'=>$Channel,'channel_name'=>$remarks,'package_name'=>'','remark'=>'']);
  538. }
  539. $dcatChannel=DB::connection('mysql')->table('dcat-admin.channel_ownership')->where('channel',$Channel);
  540. if($dcatChannel->exists()){
  541. $dcatChannel->update(['name'=>$remarks]);
  542. }else{
  543. DB::connection('mysql')->table('dcat-admin.channel_ownership')->insert(['channel'=>$Channel,'name'=>$remarks]);
  544. }
  545. return apiReturnSuc();
  546. }
  547. // 分享url
  548. public function shareUrl(Request $request, $id, $field)
  549. {
  550. $ShareUrl = $request->ShareUrl ?: '';
  551. DB::connection('write')->table('QPPlatformDB.dbo.ChannelPackageName')
  552. ->where('ID', $id)
  553. ->update([$field => $ShareUrl]);
  554. return apiReturnSuc();
  555. }
  556. // 修改minScore
  557. public function minScore(Request $request, $id)
  558. {
  559. $MinScore = $request->MinScore ?: 0;
  560. DB::connection('write')->table('QPPlatformDB.dbo.ChannelPackageName')
  561. ->where('ID', $id)
  562. ->update(['MinScore' => $MinScore]);
  563. return apiReturnSuc();
  564. }
  565. // 修改ContrlScore
  566. public function contrlScore(Request $request, $id)
  567. {
  568. $ContrlScore = $request->ContrlScore ?: 0;
  569. DB::connection('write')->table('QPPlatformDB.dbo.ChannelPackageName')
  570. ->where('ID', $id)
  571. ->update(['ContrlScore' => $ContrlScore]);
  572. return apiReturnSuc();
  573. }
  574. // 修改Rate
  575. public function rateN(Request $request, $id)
  576. {
  577. $Rate = $request->Rate ?: 0;
  578. DB::connection('write')->table('QPPlatformDB.dbo.ChannelPackageName')
  579. ->where('ID', $id)
  580. ->update(['Rate' => $Rate]);
  581. return apiReturnSuc();
  582. }
  583. public function shareConfig(Request $request, $id)
  584. {
  585. $config = DB::table('QPPlatformDB.dbo.ChannelPackageName')->where('ID', $id)->first();
  586. if ($request->method() == 'GET') {
  587. return view('admin.channel.share_config', [
  588. 'config' => $config,
  589. ]);
  590. }
  591. $validator = Validator::make($request->all(), [
  592. 'UrlStatus' => 'required|in:0,1',
  593. 'UrlSelect' => 'required|in:1,2',
  594. 'ShareUrl' => 'nullable|url',
  595. 'SpreadShareUrl' => 'nullable|url',
  596. ]);
  597. if ($validator->fails()) {
  598. return apiReturnFail($validator->errors()->first());
  599. }
  600. $data = $request->only(['UrlStatus', 'UrlSelect']);
  601. $data['ShareUrl'] = strval($request->input('ShareUrl'));
  602. $data['SpreadShareUrl'] = strval($request->input('SpreadShareUrl'));
  603. DB::table('QPPlatformDB.dbo.ChannelPackageName')->where('ID', $id)->update($data);
  604. return apiReturnSuc();
  605. }
  606. // 提现免审配置
  607. public function withdrawalConfigAll(Request $request)
  608. {
  609. $createConfig = function () {
  610. $config = new WithdrawalChannelPositionConfig();
  611. $config->channel = 100;
  612. return $config;
  613. };
  614. $config = WithdrawalChannelPositionConfig::query()->where('channel', 100)->first() ?: $createConfig();
  615. if ($request->method() == 'GET') {
  616. $agent = DB::table('agent.dbo.admin_configs')
  617. ->where('type', 'cash')
  618. ->where('status', 1)
  619. ->get();
  620. return view('admin.channel.channel_withdrawal_configall', [
  621. 'config' => $config,
  622. 'agent' => $agent,
  623. ]);
  624. }
  625. $data = array_filter($request->all(), function ($item) {
  626. return $item !== null && $item !== '';
  627. });
  628. $validator = Validator::make($data, [
  629. 'status' => 'required|in:1,2',
  630. 'agent' => 'required|integer',
  631. ]);
  632. if ($validator->fails()) {
  633. return apiReturnFail($validator->errors()->first());
  634. }
  635. // $configs=WithdrawalChannelPositionConfig::query()->where('channel','<>',103)->get() ;
  636. $configs=WithdrawalChannelPositionConfig::query()->get() ;
  637. foreach ($configs as $config) {
  638. // if($config->channel==103)continue;
  639. $config->status = $request->input('status', 0);
  640. $config->agent = $request->input('agent', 0);
  641. $config->limit_manual_review_show = $request->input('limit_manual_review_show', 0);
  642. $config->save();
  643. //$config->update(['status'=>$request->input('status', 0),'agent'=>$request->input('agent', 0),'limit_manual_review_show'=>$request->input('limit_manual_review_show', 0)]);
  644. }
  645. return apiReturnSuc();
  646. }
  647. // 提现免审配置
  648. public function withdrawalSwitch(Request $request)
  649. {
  650. $key="WithDrawSwitch";
  651. if ($request->method() == 'GET') {
  652. $info=SystemStatusInfo::CacheValue($key);
  653. return view('admin.channel.channel_withdrawal_switch', [
  654. 'State' => $info->StatusValue,
  655. ]);
  656. }
  657. $State = (int)$request->State;
  658. SystemStatusInfo::CacheValue($key,$State);
  659. return apiReturnSuc();
  660. }
  661. // 提现免审配置
  662. public function withdrawalConfig($channel, Request $request)
  663. {
  664. $createConfig = function () use($channel) {
  665. $config = new WithdrawalChannelPositionConfig();
  666. $config->channel = $channel;
  667. return $config;
  668. };
  669. $config = WithdrawalChannelPositionConfig::query()->where('channel', $channel)->first() ?: $createConfig();
  670. if ($request->method() == 'GET') {
  671. $agent = DB::table('agent.dbo.admin_configs')
  672. ->where('type', 'cash')
  673. ->where('status', 1)
  674. ->get();
  675. return view('admin.channel.channel_withdrawal_config', [
  676. 'config' => $config,
  677. 'agent' => $agent,
  678. ]);
  679. }
  680. $data = array_filter($request->all(), function ($item) {
  681. return $item !== null && $item !== '';
  682. });
  683. $validator = Validator::make($data, [
  684. 'status' => 'required|in:1,2',
  685. 'agent' => 'required|integer',
  686. ]);
  687. if ($validator->fails()) {
  688. return apiReturnFail($validator->errors()->first());
  689. }
  690. $config->status = $request->input('status', 0);
  691. $config->agent = $request->input('agent', 0);
  692. $config->limit_manual_review_show = $request->input('limit_manual_review_show', 0);
  693. $config->save();
  694. return apiReturnSuc();
  695. }
  696. }