ComplexChannel.php 49 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262
  1. <?php
  2. /**
  3. * 聚合渠道控制器
  4. *
  5. */
  6. namespace app\admin\controller;
  7. use think\Db;
  8. use think\Exception;
  9. use app\common\model\ComplexChannelModel;
  10. use app\common\model\Game;
  11. use app\common\model\Polychannel;
  12. use app\common\model\PolychannelGame;
  13. use app\common\model\PolyChannelDeposit;
  14. use app\common\model\PolyChannelDepositRecord;
  15. use app\common\model\PolyChannelGameFrozen;
  16. use app\common\logic\Complex;
  17. use GuzzleHttp\Client;
  18. use GuzzleHttp\Exception\GuzzleException;
  19. class ComplexChannel extends Admin
  20. {
  21. public function _initialize()
  22. {
  23. parent::_initialize();
  24. $this->complexChannelModel = new ComplexChannelModel;
  25. $this->_gameModel = new Game;
  26. $this->_polyChannelDeposit = new PolyChannelDeposit;
  27. $this->_polyChannelDepositRecord= new polyChannelDepositRecord;
  28. $this->_polyChannelGameFrozen = new PolyChannelGameFrozen;
  29. $this->complexLogic = new Complex;
  30. }
  31. /**
  32. * 聚合渠道列表
  33. * @return mixed|string
  34. */
  35. public function index()
  36. {
  37. /**搜索条件**/
  38. $name = input('name');
  39. $status = input('status');
  40. $register = input('register');
  41. $login = input('login');
  42. $consume = input('consume');
  43. $where['a.flag'] = 4;
  44. if ($name) {
  45. $where['a.name'] = ['like', "%$name%"];
  46. }
  47. if ($status!='') {
  48. $where['a.status'] = $status;
  49. }
  50. if ($register!='') {
  51. if($register==1){
  52. $where['b.register'] = $register;
  53. }
  54. else{
  55. $where['b.register'] = [['eq',0],['exp',Db::raw('is null')],'or'];
  56. }
  57. }
  58. if ($login!='') {
  59. if($login==1){
  60. $where['b.login'] = $login;
  61. }
  62. else{
  63. $where['b.login'] = [['eq',0],['exp',Db::raw('is null')],'or'];
  64. }
  65. }
  66. if ($consume!='') {
  67. if($consume==1){
  68. $where['b.consume'] = $consume;
  69. }
  70. else{
  71. $where['b.consume'] = [['eq',0],['exp',Db::raw('is null')],'or'];
  72. }
  73. }
  74. $channles = $this->complexChannelModel
  75. ->alias('a')
  76. ->join("nw_polychannel b","a.id=b.channel_id","left")
  77. ->field('a.id,a.name,a.mark,a.remark,a.create_time,a.status,b.channel_id,b.param_field,b.login,b.register,b.consume')
  78. ->where($where)
  79. ->order("a.id DESC")
  80. ->paginate(30,false, ['query' => input('request.')]);
  81. // 获取分页显示
  82. $page = $channles->render();
  83. $this->assign('total', $channles->total());
  84. $this->assign("page", $page);
  85. $this->assign("channles", $channles);
  86. return $this->fetch();
  87. }
  88. /**
  89. * 添加渠道
  90. *
  91. * @return mixed
  92. */
  93. public function add()
  94. {
  95. return $this->fetch();
  96. }
  97. /**
  98. * 添加渠道
  99. *
  100. */
  101. public function addPost()
  102. {
  103. $polychannelModel = new Polychannel;
  104. $param_field = input('post.param_field','','trim');
  105. $field_client = input('post.field_client','','trim');
  106. $register= input('post.register',0,'intval');
  107. $login= input('post.login',0,'intval');
  108. $consume= input('post.consume',0,'intval');
  109. $data = [
  110. 'name' => input('post.name','','trim'),
  111. 'remark' => input('post.remark'),
  112. 'mark' => input('post.mark','','trim'),
  113. 'status' => input('post.status'),
  114. 'register' => input('post.register'),
  115. 'login' => input('post.login'),
  116. 'consume' => input('post.consume'),
  117. 'param_field' => $param_field,
  118. 'field_client' => $field_client,
  119. ];
  120. $result = $this->validate($data,
  121. [
  122. ['name', 'require', '请填写渠道名称'],
  123. ['remark', 'max:255', '渠道描述最大不超过255个字符'],
  124. ['mark', 'require|alphaNum|max:20', '请填写渠道标识|渠道标识必须为英文和数字|渠道标识最大不超过20个字符'],
  125. ['status', 'require|integer', '渠道状态不能为空|渠道状态必须为整数'],
  126. ['register', 'require|integer', '渠道新增状态不能为空|渠道新增状态必须为整数'],
  127. ['login', 'require|integer', '渠道登录状态不能为空|渠道登录状态必须为整数'],
  128. ['consume', 'require|integer', '渠道消费状态不能为空|渠道消费状态必须为整数'],
  129. ['param_field', 'max:500', '服务端参数字段名最大不超过500个字符'],
  130. ['field_client', 'max:500', '客户端参数字段名最大不超过500个字符'],
  131. ]);
  132. if (true !== $result) {
  133. $this->error($result);
  134. }
  135. // elseif(!empty($param_field) && count(explode(';',$param_field))!=2){
  136. // $this->error('参数字段超过两个或不足两个,请联系技术员进行特殊处理');
  137. // }
  138. else {
  139. Db::startTrans();
  140. try {
  141. //1. 添加渠道信息
  142. $channelInfo = $this->complexChannelModel->where(['name' => $data['name']])->find();
  143. if ($channelInfo) {
  144. throw new Exception("该渠道信息已存在");
  145. }
  146. if ( $this->complexChannelModel->where(['mark' => $data['mark']])->find() ) {
  147. throw new Exception("渠道标识不能重复");
  148. }
  149. unset($data['param_field']);
  150. unset($data['field_client']);
  151. unset($data['register']);
  152. unset($data['login']);
  153. unset($data['consume']);
  154. $data['flag'] = 4;
  155. $data['create_time'] = NOW_TIMESTAMP;
  156. //添加渠道信息
  157. $this->complexChannelModel->save($data);
  158. if ( !$this->complexChannelModel->id ) {
  159. throw new Exception("添加渠道信息失败");
  160. }
  161. //2. 添加聚合渠道参数
  162. $polyChannelData = array();
  163. $polyChannelData['channel_id'] = $this->complexChannelModel->id;
  164. if(!empty($param_field)){
  165. $polyChannelData['param_field'] = $param_field;
  166. }
  167. if(!empty($field_client)){
  168. $polyChannelData['field_client'] = $field_client;
  169. }
  170. $polyChannelData['register'] = $register?1:0;
  171. $polyChannelData['login'] = $login?1:0;
  172. $polyChannelData['consume'] = $consume?1:0;
  173. $polyChannelData['update_time'] = NOW_TIMESTAMP;
  174. $polychannelModel->save($polyChannelData);
  175. $status = $data['status'] ? '正常' : '冻结';
  176. $register = $register ? '冻结' : '正常';
  177. $login = $login ? '冻结' : '正常';
  178. $consume = $consume ? '冻结' : '正常';
  179. //写入日志
  180. $this->insertLog($this->current_node, "新增聚合渠道:{$data['name']},渠道标识:{$data['mark']},渠道状态:{$status},新增状态:{$register},登录状态:{$login},消费状态:{$consume}", 54);
  181. Db::commit();
  182. } catch (\Exception $e) {
  183. Db::rollback();
  184. $this->error("添加失败: " . $e->getMessage());
  185. }
  186. $this->success("添加成功!", "ComplexChannel/index");
  187. }
  188. }
  189. /**
  190. * 编辑渠道
  191. *
  192. * @return mixed
  193. */
  194. public function edit()
  195. {
  196. $polychannelModel = new Polychannel;
  197. $id = input('id', 0, 'intval');
  198. $channel = $this->complexChannelModel->where(["id" => $id])->find();
  199. if(empty($channel)){
  200. $this->error('聚合渠道信息不存在');
  201. }
  202. $polychannel = $polychannelModel->where(["channel_id" => $id])->find();
  203. if(!empty($channel)){
  204. $param_field = $polychannel['param_field'];
  205. $field_client = $polychannel['field_client'];
  206. $register = $polychannel['register'];
  207. $login = $polychannel['login'];
  208. $consume = $polychannel['consume'];
  209. }
  210. else{
  211. $param_field = '';
  212. $field_client = '';
  213. $register = 0;
  214. $login = 0;
  215. $consume = 0;
  216. }
  217. $this->assign('channel', $channel);
  218. $this->assign('param_field', $param_field);
  219. $this->assign('field_client', $field_client);
  220. $this->assign('register', $register);
  221. $this->assign('login', $login);
  222. $this->assign('consume', $consume);
  223. return $this->fetch();
  224. }
  225. /**
  226. * 编辑渠道接口
  227. *
  228. */
  229. public function editPost()
  230. {
  231. $id = input('post.id',0,'intval');
  232. $param_field= input('post.param_field','','trim');
  233. $field_client= input('post.field_client','','trim');
  234. $register= input('post.register',0,'intval');
  235. $login= input('post.login',0,'intval');
  236. $consume= input('post.consume',0,'intval');
  237. $polychannelModel = new Polychannel;
  238. $data = ['name' => input('post.name','','trim'),
  239. 'remark' => input('post.remark'),
  240. 'status' => input('post.status'),
  241. 'register' => input('post.register'),
  242. 'login' => input('post.login'),
  243. 'consume' => input('post.consume'),
  244. 'param_field' => $param_field,
  245. 'field_client' => $field_client
  246. ];
  247. $result = $this->validate($data,
  248. [
  249. ['name', 'require', '请填写渠道名称'],
  250. ['remark', 'max:255', '渠道描述最大不超过255个字符'],
  251. ['status', 'require|integer', '渠道状态不能为空|渠道状态必须为整数'],
  252. ['register', 'require|integer', '渠道新增状态不能为空|渠道新增状态必须为整数'],
  253. ['login', 'require|integer', '渠道登录状态不能为空|渠道登录状态必须为整数'],
  254. ['consume', 'require|integer', '渠道消费状态不能为空|渠道消费状态必须为整数'],
  255. ['param_field', 'max:500', '服务端参数字段名最大不超过500个字符'],
  256. ['field_client', 'max:500', '客户端参数字段名最大不超过500个字符'],
  257. ]);
  258. if (true !== $result) {
  259. $this->error($result);
  260. } elseif (empty($this->complexChannelModel->where(['id' => $id])->find())) {
  261. $this->error('聚合渠道不存在');
  262. }
  263. // elseif(!empty($param_field) && count(explode(';',$param_field))!=2){
  264. // $this->error('参数字段超过两个或不足两个,请联系技术员进行特殊处理');
  265. // }
  266. else {
  267. Db::startTrans();
  268. try {
  269. //1. 添加渠道信息
  270. $channelInfo = $this->complexChannelModel->where(['name' => $data['name'], 'id' => ['<>', $id]])->find();
  271. if ($channelInfo) {
  272. throw new Exception("渠道名称不能重复");
  273. }
  274. unset($data['param_field']);
  275. unset($data['field_client']);
  276. unset($data['register']);
  277. unset($data['login']);
  278. unset($data['consume']);
  279. //添加渠道信息
  280. $this->complexChannelModel->save($data, ['id' => $id]);
  281. //2. 添加聚合渠道参数
  282. $polyChannelData = array();
  283. if (!empty($param_field)) {
  284. $polyChannelData['param_field'] = $param_field;
  285. }
  286. if (!empty($field_client)) {
  287. $polyChannelData['field_client'] = $field_client;
  288. }
  289. $polyChannelData['register'] = $register ? 1 : 0;
  290. $polyChannelData['login'] = $login ? 1 : 0;
  291. $polyChannelData['consume'] = $consume ? 1 : 0;
  292. $polyChannelData['update_time'] = NOW_TIMESTAMP;
  293. //更新
  294. if($polychannelModel->where(['channel_id'=>$id])->find())
  295. {
  296. $result = $polychannelModel->save($polyChannelData,['channel_id'=>$id]);
  297. }
  298. //新增
  299. else{
  300. $polyChannelData['channel_id'] = $id;
  301. $result = $polychannelModel->save($polyChannelData);
  302. }
  303. $status = $data['status'] ? '正常' : '冻结';
  304. $mark = $this->complexChannelModel->where(['id' => $id])->value('mark');
  305. $register = $register ? '冻结' : '正常';
  306. $login = $login ? '冻结' : '正常';
  307. $consume = $consume ? '冻结' : '正常';
  308. //写入日志
  309. $this->insertLog($this->current_node, "修改聚合渠道:{$data['name']},渠道标识:{$mark},渠道状态:{$status},新增状态:{$register},登录状态:{$login},消费状态:{$consume}", 55);
  310. Db::commit();
  311. } catch (\Exception $e) {
  312. Db::rollback();
  313. $this->error("编辑失败: " . $e->getMessage());
  314. }
  315. $this->success("编辑成功!", "ComplexChannel/index");
  316. }
  317. }
  318. //变更渠道状态
  319. public function updateStatus()
  320. {
  321. $polychannelModel = new Polychannel;
  322. //渠道ID
  323. $id = input('id', 0, 'intval');
  324. $status = input('status', 0, 'intval');
  325. if (!empty($id)) {
  326. $result = $this->complexChannelModel->where(["id" => $id,'flag'=>4])->setField('status', $status);
  327. if ($result !== false) {
  328. //添加日志
  329. $frozenInfo = $polychannelModel->where(['id' => $id])->find();
  330. $channelInfo = $this->complexChannelModel->where(['id' => $id])->find();
  331. $channel_name = $channelInfo['name'];
  332. $mark = $channelInfo['mark'];
  333. $register = $frozenInfo['register'] ? '冻结' : '正常';
  334. $login = $frozenInfo['login'] ? '冻结' : '正常';
  335. $consume = $frozenInfo['consume'] ? '冻结' : '正常';
  336. $statusStr = $status ? '正常' : '冻结';
  337. $this->insertLog($this->current_node, "修改聚合渠道:{$channel_name},渠道标识:{$mark},渠道状态:{$statusStr},新增状态:{$register},登录状态:{$login},消费状态:{$consume}", 55);
  338. $this->success("更改渠道状态成功!", url("ComplexChannel/index"));
  339. } else {
  340. $this->error('更改渠道状态失败!');
  341. }
  342. } else {
  343. $this->error('数据传入失败!');
  344. }
  345. }
  346. // +----------------------------------------------------------------------
  347. // | 聚合游戏
  348. // +----------------------------------------------------------------------
  349. /**
  350. * 聚合游戏列表
  351. */
  352. public function gameList()
  353. {
  354. $is_down = input('request.download', '0', 'intval');
  355. $channel_id = input('request.channel_id', '0', 'intval');
  356. $gameid = $this->request->param('gameid', 0, 'intval');
  357. $type = input('request.type', '');
  358. $condition = [];
  359. if (!empty($channel_id)) {
  360. $condition['cg.channel_id'] = $channel_id;
  361. }
  362. if (!empty($gameid)) {
  363. $condition['cg.game_id'] = $gameid;
  364. }
  365. if (!empty($type)) {
  366. $condition['g.type'] = $type;
  367. }
  368. $polychannelGameModel = new PolychannelGame;
  369. if ($is_down) {
  370. $list = $polychannelGameModel->alias('cg')
  371. ->join('nw_complex_channel c', 'cg.channel_id=c.id', 'left')
  372. ->join('cy_game g', 'g.id=cg.game_id', 'left')
  373. ->join('cy_game_pay_discount cgpd', 'cgpd.game_id=cg.game_id', 'left')
  374. ->field('cg.game_id,cg.id,cg.create_time,cg.remark,cg.param,g.name game_name,g.origin_name,c.name channel_name,c.mark, cg.discount_status, cgpd.proportion')
  375. ->where($condition)
  376. ->order("cg.id DESC")
  377. ->select();
  378. } else {
  379. $list = $polychannelGameModel->alias('cg')
  380. ->join('nw_complex_channel c', 'cg.channel_id=c.id', 'left')
  381. ->join('cy_game g', 'g.id=cg.game_id', 'left')
  382. ->join('cy_game_pay_discount cgpd', 'cgpd.game_id=cg.game_id', 'left')
  383. ->field('cg.game_id,cg.id,cg.create_time,cg.remark,cg.param,g.name game_name,g.origin_name,c.name channel_name,c.mark, cg.discount_status, cgpd.proportion')
  384. ->where($condition)
  385. ->order("cg.id DESC")
  386. ->paginate(30, false, ['query' => input('get.')]);
  387. }
  388. if($is_down>0){
  389. $title = "聚合游戏列表-".date('YmdHis');
  390. if(!$list){
  391. $this->error('暂无数据');
  392. }
  393. $this->downloadexls($list, $title,'listGame');
  394. exit();
  395. }
  396. // 获取分页显示
  397. $page = $list->render();
  398. $channelList = $this->_getChannelList();
  399. $selfChannelList = array();
  400. foreach ($channelList as $channel) {
  401. $selfChannelList[ $channel['id']] = $channel;
  402. }
  403. $this->assign('channel_list', $selfChannelList);
  404. $this->assign('total', $list->total());
  405. $this->assign("page", $page);
  406. $this->assign('list',$list);
  407. $SelfGameList = model('Common/Game')->getAllByCondition('id,name', [],'','self');
  408. $GameList = array();
  409. foreach ($SelfGameList as $game) {
  410. $GameList[ $game['id']] = $game;
  411. }
  412. $this->assign('game_list', $GameList);
  413. return $this->fetch('game_list');
  414. }
  415. /**
  416. * 获得聚合渠道的参数
  417. */
  418. public function ajaxGetChannelGameParam()
  419. {
  420. if(request()->isAjax())
  421. {
  422. $polychannelGameModel = new PolychannelGame;
  423. $polychannelModel = new Polychannel;
  424. $id = input('post.id'); //渠道游戏ID
  425. $info = $polychannelGameModel->field('channel_id,game_id,param,param_client')
  426. ->where(['id'=>$id])
  427. ->find();
  428. if(empty($info)){
  429. $this->error('聚合渠道游戏信息不存在');
  430. }
  431. $return_html = '服务端参数<br>';
  432. $return_html_client = '客户端参数<br>';
  433. $return_html .= $info['param_client'].'<br>';
  434. $return_html_client .= $info['param'].'<br>';
  435. $this->result(['return_html'=>$return_html_client.'<br>'.$return_html],1);
  436. }
  437. else{
  438. $this->error('非法请求');
  439. }
  440. }
  441. /**
  442. * 聚合渠道游戏新增
  443. */
  444. public function gameAdd()
  445. {
  446. $complexChannelModel = new ComplexChannelModel;
  447. $gameModel = new Game;
  448. //表单提交
  449. if (request()->isPost()) {
  450. $polychannelGameModel = new PolychannelGame;
  451. $polychannelModel = new Polychannel;
  452. $input = input();
  453. // $param = input('post.param'); //参数
  454. $param = $input['param']; //参数
  455. $param_client = $input['param_client']??""; //参数
  456. $data = [
  457. 'game_id' => input('post.game_id', 0, 'intval'),
  458. 'channel_id' => input('post.channel_id', 0, 'intval'),
  459. 'remark' => input('post.remark'),
  460. 'discount_status' => input('post.discount_status', 2, 'intval'), // 折扣状态(1=开启、2=关闭)
  461. ];
  462. $result = $this->validate($data,
  463. [
  464. ['game_id', 'require|positiveInteger', '请选择游戏|游戏ID必须为整型'],
  465. ['channel_id', 'require|positiveInteger', '请选择渠道|渠道ID必须为整型'],
  466. ['remark', 'max:500', '备注最大不超过500个字符'],
  467. ]);
  468. if (true !== $result) {
  469. $this->error($result);
  470. } elseif ($polychannelGameModel->where(['game_id' => $data['game_id'], 'channel_id' => $data['channel_id']])->find()) {
  471. $this->error('渠道游戏信息已经存在');
  472. } else {
  473. $data['create_time'] = NOW_TIMESTAMP;
  474. $paramArr = $polychannelModel->field('param_field,field_client')->where(['channel_id' => $data['channel_id']])->find();
  475. if ($param && !empty($paramArr['param_field'])) {
  476. // if(count($param)!=2){
  477. // $this->error('参数字段超过两个或不足两个,请联系技术员进行特殊处理');
  478. // }
  479. $paramHandle = explode(';', $paramArr['param_field']);
  480. $newParam = [];
  481. for ($i = 0; $i < count($paramHandle); $i++) {
  482. $newParam[$paramHandle[$i]] = '';
  483. if (!empty($param[$i])) {
  484. $newParam[$paramHandle[$i]] = $param[$i];
  485. }
  486. }
  487. if ($newParam) {
  488. $newParam = json_encode($newParam);
  489. }
  490. $data['param'] = $newParam;
  491. }
  492. if ($param_client) {
  493. $data['param_client'] = $param_client;
  494. }
  495. // 判断当前游戏是否有折扣配置,没有则不能开启折扣
  496. $proportion = Db::table('cy_game_pay_discount')->where(['game_id' => $data['game_id']])->value('proportion')??0;
  497. if($data['discount_status'] == 1 && $proportion == 0){
  498. $this->error('当前游戏未配置折扣,不能开启使用');
  499. }
  500. Db::startTrans();
  501. try {
  502. $polychannelGameModel->insert($data);
  503. //如果聚合渠道预付款配置表没有记录时,新增
  504. if(!$this->_polyChannelDeposit->where(['channel_id'=>$data['channel_id']])->find())
  505. {
  506. //聚合渠道预付款配置
  507. $this->_polyChannelDeposit->insert(['channel_id'=>$data['channel_id'],'mobile'=>'','create_time'=>NOW_TIMESTAMP]);
  508. }
  509. //聚合渠道游戏冻结配置
  510. $this->_polyChannelGameFrozen->insert([
  511. 'game_id'=>$data['game_id'],
  512. 'channel_id'=>$data['channel_id'],
  513. 'create_time'=>NOW_TIMESTAMP
  514. ]);
  515. Db::commit();
  516. }
  517. catch (\Exception $e) {
  518. Db::rollback();
  519. $this->error("渠道游戏添加失败!".$e->getMessage());
  520. }
  521. $this->success('渠道游戏添加成功','ComplexChannel/gameList');
  522. }
  523. }
  524. $channelList= $complexChannelModel->field('id,name')->where(['status'=>1,'flag'=>4])->order('name asc')->select();
  525. $selfChannelList = array();
  526. foreach ($channelList as $channel) {
  527. $selfChannelList[ $channel['id']] = $channel;
  528. }
  529. $gameList = $gameModel->getAllByCondition('id,name',['isdelete'=>0],'name asc','self');
  530. $selfGameList = array();
  531. foreach ($gameList as $game) {
  532. $selfGameList[ $game['id']] = $game;
  533. }
  534. $this->assign('game_list',$selfGameList);
  535. $this->assign('channel_list',$selfChannelList);
  536. return $this->fetch('game_add');
  537. }
  538. /**
  539. * 获得聚合渠道的参数字段
  540. */
  541. public function ajaxGetChannelParamField()
  542. {
  543. if(request()->isAjax())
  544. {
  545. $channel_id = input('post.channel_id');
  546. $polychannelModel = new Polychannel;
  547. $param_field = $polychannelModel->field('param_field,field_client')->where(['channel_id'=>$channel_id])->find();
  548. $this->result(['param_field'=>$param_field['param_field'],'field_client'=>$param_field['field_client']],1);
  549. }
  550. else{
  551. $this->error('非法请求');
  552. }
  553. }
  554. /**
  555. * 聚合渠道游戏编辑
  556. */
  557. public function gameEdit()
  558. {
  559. $polychannelGameModel = new PolychannelGame;
  560. $polychannelModel = new Polychannel;
  561. $id = input('id',0,'intval');
  562. $info = $polychannelGameModel->table('cy_polychannel_game cg,nw_complex_channel c,cy_game g')
  563. ->field('cg.*,g.name game_name,c.name channel_name')
  564. ->where('cg.channel_id=c.id and g.id=cg.game_id')
  565. ->where(['cg.id'=>$id])
  566. ->find();
  567. if(empty($info)){
  568. $this->error('聚合渠道游戏信息不存在');
  569. }
  570. // 参数字段
  571. $param_field_arr = $polychannelModel->field('field_client,param_field')->where(['channel_id'=>$info['channel_id']])->find();
  572. $param_field = $param_field_arr['param_field'];
  573. $field_client = $param_field_arr['field_client'];
  574. // 折扣信息
  575. $proportion = Db::table('cy_game_pay_discount')->where(['game_id' => $info['game_id']])->value('proportion');
  576. //表单提交
  577. if(request()->isPost())
  578. {
  579. $param = input('post.param');
  580. $param_client = input('post.param_client'); // 参数
  581. $discount_status = input('post.discount_status'); // 折扣状态(1=开启、2=关闭)
  582. $data = [
  583. 'remark' => input('post.remark'),
  584. ];
  585. $result = $this->validate($data,
  586. [
  587. ['remark', 'max:500', '备注最大不超过500个字符'],
  588. ]);
  589. if (true !== $result) {
  590. $this->error($result);
  591. }
  592. else{
  593. if($param){
  594. // if(count($param)!=2){
  595. // $this->error('参数字段超过两个或不足两个,请联系技术员进行特殊处理');
  596. // }
  597. if(!is_json($param)){
  598. $this->error('json异常');
  599. }
  600. $data['param'] = $param;
  601. }
  602. if($param_client){
  603. $data['param_client'] = $param_client;
  604. }
  605. // 折扣状态
  606. if($discount_status){
  607. $data['discount_status'] = $discount_status;
  608. }
  609. $polychannelGameModel->save($data,['id'=>$id]);
  610. $this->success('渠道游戏编辑成功','ComplexChannel/gameList');
  611. }
  612. }
  613. $discountInfo = [
  614. 'status' => 2,
  615. 'proportion' => 0
  616. ];
  617. if($proportion > 0 && $proportion < 1){
  618. $discountInfo = [
  619. 'status' => 1,
  620. 'proportion' => $proportion
  621. ];
  622. }
  623. $this->assign('discountInfo',$discountInfo);
  624. $this->assign('info',$info);
  625. $this->assign('param_field',$param_field);
  626. $this->assign('arrParam',$info['param']);
  627. $this->assign('field_client',$field_client);
  628. $this->assign('arrParamClient',$info['param_client']);
  629. return $this->fetch('game_edit');
  630. }
  631. /**
  632. * 聚合游戏记录删除
  633. */
  634. public function gameDelete()
  635. {
  636. $id = $this->request->param('id', 0, 'intval');
  637. $polychannelGameModel = new PolychannelGame;
  638. Db::startTrans();
  639. try {
  640. // 获取游戏id和渠道id
  641. $info = $polychannelGameModel->where(['id'=>$id])->field('game_id,channel_id')->find();
  642. $polychannelGameModel->where(['id'=>$id])->delete();
  643. $this->_polyChannelGameFrozen->where(['game_id'=>$info['game_id'],'channel_id'=>$info['channel_id']])->delete();
  644. Db::commit();
  645. } catch (\Exception $e) {
  646. Db::rollback();
  647. $this->error("删除失败!".$e->getMessage());
  648. }
  649. $this->success("删除成功!");
  650. }
  651. // 聚合游戏冻结配置
  652. public function listGameFrozen(){
  653. $is_down = input('request.download', '0', 'intval');
  654. $channel_id = $this->request->param('channel_id', 0, 'intval');
  655. $condition = [];
  656. $condition['channel_id'] = $channel_id;
  657. $list = [];
  658. $count_total_amount = $count_real_amount = $total_advance = $balance = $last_advance = 0;
  659. $param = input();
  660. $whereTime = [];
  661. if(!empty($param['start_time'])){
  662. // $whereTime['start_time'] = strtotime($param['start_time'] . " 00:00:00");
  663. $whereTime['start_time'] = strtotime($param['start_time']);
  664. }
  665. if(!empty($param['end_time'])){
  666. // $whereTime['end_time'] = strtotime($param['end_time'] . " +1 day");
  667. $whereTime['end_time'] = strtotime($param['end_time']);
  668. }
  669. if (!empty($condition)) {
  670. if($is_down>0){
  671. $list = $this->_polyChannelGameFrozen->where($condition)->order('id desc')->select();
  672. // 安全写法
  673. if (is_object($list) && method_exists($list, 'toArray')) {
  674. $list = $list->toArray();
  675. } else {
  676. $list = collection($list)->toArray(); // TP5 自带 helper 函数
  677. }
  678. $gameIds = array_column($list, 'game_id');
  679. } else {
  680. $list = $this->_polyChannelGameFrozen->where($condition)->order('status desc, total_amount desc')->paginate(50, false, array('query' => $param));
  681. $gameIds = array_column($list->toArray()['data'], 'game_id');
  682. }
  683. // dump($whereTime);
  684. // ## 游戏配置信息 : divide_point=祈盟分成, proportion=折扣
  685. $gamePayConfig = Db::table('cy_polychannel_game_frozen')->alias('cpgf')
  686. ->join('cy_game_pay_discount cgpd', 'cpgf.game_id = cgpd.game_id', 'LEFT')
  687. ->where(['cpgf.game_id' => ['in', $gameIds], 'cpgf.channel_id' => $channel_id])
  688. ->column('cpgf.divide_point, cgpd.proportion', 'cpgf.game_id');
  689. // $gameByProportion = Db::table('cy_game_pay_discount')->where(['game_id' => ['in', $gameIds]])->column('game_id,proportion');
  690. $openGameIds = [];
  691. foreach ( $list as &$item ) {
  692. // 当前流水
  693. $item['total_amount'] = Db::table('nw_complex_pay')
  694. ->where(['gameid' => $item['game_id'], 'channel_id' => $channel_id, 'status' => 1])
  695. ->where(function($q) use ($whereTime) {
  696. if (!empty($whereTime['start_time'])) {
  697. $q->where('create_time', '>=', $whereTime['start_time']);
  698. }
  699. if (!empty($whereTime['end_time'])) {
  700. $q->where('create_time', '<', $whereTime['end_time']);
  701. }
  702. })
  703. ->sum('amount');
  704. $item['discount'] = 0;
  705. if(!empty($gamePayConfig[$item['game_id']]['proportion'])){
  706. $item['discount'] = $gamePayConfig[$item['game_id']]['proportion'];
  707. }
  708. $item['game_name'] = $this->_getGameName($item['game_id']);
  709. $item['origin_name'] = $this->_getGameOriginName($item['game_id']);
  710. $item['divide_point'] = (0 != $item['divide_point']) ? $item['divide_point']: 0;
  711. // 折扣后流水
  712. $discount_amount = cleanAmount($item['total_amount']);
  713. if($item['discount']){
  714. $discount_amount = cleanAmount(number_format($item['total_amount']*$item['discount'], 2));
  715. }
  716. $item['discount_amount'] = $discount_amount;
  717. // 扣除预付款
  718. $item['actual_amount'] = round($discount_amount*$item['divide_point'], 2);
  719. if($item['status'] == 1){
  720. $openGameIds[] = $item['game_id'];
  721. }
  722. }
  723. // ## 当前流水
  724. // $count_total_amount = $this->_polyChannelGameFrozen->where(['channel_id' => $channel_id, 'status' => 1, 'game_id' => ['in', $gameIds]])->sum('total_amount');
  725. $count_total_amount = Db::table('nw_complex_pay')
  726. ->where(['gameid' => ['in', $openGameIds], 'channel_id' => $channel_id, 'status' => 1])
  727. ->where(function($q) use ($whereTime) {
  728. if (!empty($whereTime['start_time'])) {
  729. $q->where('create_time', '>=', $whereTime['start_time']);
  730. }
  731. if (!empty($whereTime['end_time'])) {
  732. $q->where('create_time', '<', $whereTime['end_time']);
  733. }
  734. })
  735. ->sum('amount');
  736. $count_total_amount = floatval($count_total_amount);
  737. // ## 折扣后流水
  738. // $count_real_amount = $this->complexLogic->getChannelGameTotalAmount($channel_id);
  739. $count_real_amount = Db::table('nw_complex_pay')->alias('ncp')
  740. ->join('cy_game_pay_discount cgpd', 'ncp.gameid = cgpd.game_id', 'LEFT')
  741. ->where(['ncp.gameid' => ['in', $openGameIds], 'ncp.channel_id' => $channel_id, 'ncp.status' => 1])
  742. ->where(function($q) use ($whereTime) {
  743. if (!empty($whereTime['start_time'])) {
  744. $q->where('ncp.create_time', '>=', $whereTime['start_time']);
  745. }
  746. if (!empty($whereTime['end_time'])) {
  747. $q->where('ncp.create_time', '<', $whereTime['end_time']);
  748. }
  749. })
  750. ->value("ROUND(SUM(ncp.amount * COALESCE(cgpd.proportion, 1.000)), 2)");
  751. $count_real_amount = floatval($count_real_amount);
  752. // ## 扣除预付款累计
  753. $count_deduct_amount = 0;
  754. // $count_deduct_amount = Db::table('nw_complex_pay')->alias('ncp')
  755. // ->join('cy_polychannel_game_frozen cpgf', 'ncp.gameid = cpgf.game_id', 'LEFT')
  756. // ->where(['ncp.gameid' => ['in', $gameIds], 'ncp.channel_id' => $channel_id, 'ncp.create_time' => ['between', [$param['start_time'], $param['end_time']]], 'ncp.status' => 1])
  757. // ->value("ROUND(SUM(ncp.amount * cpgf.divide_point), 2)");
  758. $count_deduct_list = Db::table('nw_complex_pay')
  759. ->where(['gameid' => ['in', $openGameIds], 'channel_id' => $channel_id, 'status' => 1])
  760. ->where(function($q) use ($whereTime) {
  761. if (!empty($whereTime['start_time'])) {
  762. $q->where('create_time', '>=', $whereTime['start_time']);
  763. }
  764. if (!empty($whereTime['end_time'])) {
  765. $q->where('create_time', '<', $whereTime['end_time']);
  766. }
  767. })
  768. ->field("gameid, SUM(amount) as amount")
  769. ->group("gameid")
  770. ->select();
  771. foreach ($count_deduct_list as &$item) {
  772. $amount = $item['amount'];
  773. // 折扣
  774. if(!empty($gamePayConfig[$item['gameid']]) && $gamePayConfig[$item['gameid']]['proportion'] > 0){
  775. $amount = $amount * $gamePayConfig[$item['gameid']]['proportion'];
  776. }
  777. // 分成
  778. if(!empty($gamePayConfig[$item['gameid']]) && $gamePayConfig[$item['gameid']]['divide_point'] > 0){
  779. $amount = $amount * $gamePayConfig[$item['gameid']]['divide_point'];
  780. }
  781. $count_deduct_amount += $amount;
  782. }
  783. $count_deduct_amount = round($count_deduct_amount, 2);
  784. // ## 已交预付款
  785. $ChannelDepositInfo = $this->_polyChannelDeposit->where(['channel_id' => $channel_id])->find();
  786. if($ChannelDepositInfo){
  787. $total_advance = floatval($ChannelDepositInfo->total_advance);
  788. $last_advance = floatval($ChannelDepositInfo->last_advance);
  789. }
  790. // 查询时间内清空后交的预付款
  791. // $total_advance = Db::table('cy_polychannel_deposit_record')->where(['channel_id' => $channel_id])
  792. // ->where(function($q) use ($whereTime) {
  793. // if (!empty($whereTime['start_time'])) {
  794. // $q->where('create_time', '>=', $whereTime['start_time']);
  795. // }
  796. // if (!empty($whereTime['end_time'])) {
  797. // $q->where('create_time', '<', $whereTime['end_time']);
  798. // }
  799. // })->sum('amount');
  800. // dump($total_advance, $count_real_amount);
  801. // ## 剩余预付款 = 累计预付款 - 扣除预付款
  802. $balance = floatval(bcsub($total_advance, $count_deduct_amount, 2));
  803. if($is_down>0){
  804. $title = "聚合游戏冻结配置-".date('YmdHis');
  805. if(!$list){
  806. $this->error('暂无数据');
  807. }
  808. $list_more = array();
  809. $list_more['count_total_amount'] = $count_total_amount;
  810. $list_more['count_real_amount'] = $count_real_amount;
  811. $list_more['total_advance'] = $total_advance;
  812. $list_more['last_advance'] = $last_advance;
  813. $list_more['balance'] = $balance;
  814. $this->downloadexls($list, $title, 'listGameFrozen', $list_more);
  815. exit();
  816. }
  817. }
  818. $this->assign('list', $list);
  819. $this->assign('total', $list->total());
  820. $this->assign('page', $list->render());
  821. $this->assign('count', [
  822. $count_total_amount, // 当前流水
  823. $count_real_amount, // 折扣后流水
  824. $count_deduct_amount, // 扣除预付款
  825. $total_advance, // 累计预付款
  826. $balance, // 剩余预付款
  827. $last_advance, // 最近一次充值预付款
  828. ]);
  829. $channelList = $this->_getChannelList();
  830. $selfChannelList = array();
  831. foreach ($channelList as $channel) {
  832. $selfChannelList[ $channel['id']] = $channel;
  833. }
  834. $this->assign('channel_list', $selfChannelList);
  835. $this->assign('select_channel',$channel_id);
  836. return $this->fetch("listGameFrozen");
  837. }
  838. public function editGameFrozen() {
  839. if (request()->isPost()) {
  840. $divide_point = $this->request->param('divide_point', 0, 'floatval');
  841. $status = $this->request->param('status', 0, 'intval');
  842. $depf_register = $this->request->param('depf_register', 0, 'intval');
  843. $depf_login = $this->request->param('depf_login', 0, 'intval');
  844. $depf_consume = $this->request->param('depf_consume', 0, 'intval');
  845. if (0 >= $divide_point || 1 < $divide_point) {
  846. $this->error('‘祈盟所得分成’配置,只能在0-1之间!');
  847. }
  848. $switch = [0,1];
  849. if ( ! in_array($status, $switch) || ! in_array($depf_register, $switch) || ! in_array($depf_login, $switch) || ! in_array($depf_consume, $switch) ) {
  850. $this->error('预付状态|禁止新增|禁止登录|禁止充值等参数只能设定为1或0');
  851. }
  852. $id = $this->request->param('id', 0, 'intval');
  853. $data = [
  854. 'divide_point' => $divide_point,
  855. 'depf_register' => $depf_register,
  856. 'depf_login' => $depf_login,
  857. 'depf_consume' => $depf_consume,
  858. 'status' => $status,
  859. 'update_time' => time()
  860. ];
  861. $update = $this->_polyChannelGameFrozen->where(['id' => $id])->update($data);
  862. if ( false === $update ) {
  863. $this->error('更新失败');
  864. } else {
  865. $info = $this->_polyChannelGameFrozen->where(['id' => $id])->column('id,channel_id,game_id');
  866. $content = '编辑了渠道:'.$this->_getChannelName($info[$id]['channel_id']).",游戏:".$this->_getGameName($info[$id]['game_id']);
  867. $content .= ",分成配置:".$divide_point;
  868. $content .= ",预付状态:".($status ? '开启' : '关闭');
  869. $content .= ",禁止新增:".($depf_register ? '开启' : '关闭');
  870. $content .= ",禁止登录:".($depf_login ? '开启' : '关闭');
  871. $content .= ",禁止充值:".($depf_consume ? '开启' : '关闭');
  872. $this->insertLog($this->current_node, $content, 51);
  873. $this->success('更新成功', url('ComplexChannel/listGameFrozen', ['channel_id' => $info[$id]['channel_id'] ] ) );
  874. }
  875. } else {
  876. $id = $this->request->param('id', 0, 'intval');
  877. if ( empty($id) ) {
  878. $this->error('参数出错');
  879. }
  880. $info = $this->_polyChannelGameFrozen->field(['id', 'game_id', 'channel_id', 'divide_point', 'depf_register', 'depf_login', 'depf_consume', 'status'])->find($id);
  881. if ( empty($info) ) {
  882. $this->error('数据不存在');
  883. }
  884. $info['game_name'] = $this->_getGameName($info['game_id']);
  885. $info['divide_point'] = (0 != $info['divide_point']) ? $info['divide_point']: '';
  886. $this->assign('vo', $info);
  887. return $this->fetch("editGameFrozen");
  888. }
  889. }
  890. // 聚合渠道预付款配置
  891. public function listDeposit() {
  892. $channel_id = $this->request->param('channel_id', 0, 'intval');
  893. $condition = [];
  894. if (!empty($channel_id) ) {
  895. $condition['channel_id'] = $channel_id;
  896. }
  897. //查询参数
  898. $param = input('get.');
  899. $list = $this->_polyChannelDeposit->where($condition)->order('id desc')->paginate(20, false, array('query' => $param));
  900. // 批量获取渠道总流水
  901. $channel_ids = array_column($list->toArray()['data'], 'channel_id');
  902. // 批量获取渠道名称和描述
  903. $channelInfoMap = [];
  904. if (!empty($channel_ids)) {
  905. $channelInfoMap = $this->complexChannelModel
  906. ->where('id', 'in', $channel_ids)
  907. ->column('name,remark', 'id');
  908. }
  909. foreach ( $list as &$channel ) {
  910. $channelId = $channel['channel_id'];
  911. $channel['channel_name'] = $channelInfoMap[$channelId]['name'] ?? '';
  912. $channel['channel_desc'] = $channelInfoMap[$channelId]['remark'] ?? '';
  913. $channel['total_amount'] = $this->complexLogic->getChannelGameTotalAmount($channelId);
  914. }
  915. $this->assign('total', $list->total());
  916. $this->assign('page', $list->render());
  917. $this->assign('list', $list);
  918. $channelList = $this->_getChannelList();
  919. $selfChannelList = array();
  920. foreach ($channelList as $channel) {
  921. $selfChannelList[ $channel['id']] = $channel;
  922. }
  923. $this->assign('channel_list', $selfChannelList);
  924. return $this->fetch("listDeposit");
  925. }
  926. public function editDeposit() {
  927. if (request()->isPost()) {
  928. $last_advance = $this->request->param('add2advance', 0);
  929. $mobile = $this->request->param('mobile', '', 'trim');
  930. $warn_amount = $this->request->param('warn_amount', 0, 'floatval');
  931. $over_limit_amount = $this->request->param('over_limit_amount', 0, 'floatval');
  932. $remark = $this->request->param('remark', '', 'filterAndTrimInput');
  933. if ( 0 > $warn_amount || 0 > $over_limit_amount ) {
  934. $this->error('预警额度和可超额度都不能小于零');
  935. }
  936. /*
  937. if ($last_advance < 0) {
  938. $this->error('新增预付款必须为正整数,不追加请留空');
  939. }
  940. */
  941. $mobile = str_replace(PHP_EOL, ',', $mobile);
  942. $mobileArray = explode(",",$mobile);
  943. while(list($key,$val)=@each($mobileArray)){
  944. if (trim($val)) {
  945. if(! preg_match("/^1\d{10}$/", trim($val))){
  946. $this->error('存在手机号码不正确,请确认');
  947. }
  948. else{
  949. $mobileArray[$key] = trim($val);
  950. }
  951. }
  952. else{
  953. unset($mobileArray[$key]);
  954. }
  955. }
  956. $mobileArray = array_unique($mobileArray);
  957. $mobile = implode(",",$mobileArray);
  958. $id = $this->request->param('id', 0, 'intval');
  959. $data = [
  960. 'mobile' => $mobile,
  961. 'warn_amount' => $warn_amount,
  962. 'over_limit_amount' => $over_limit_amount,
  963. 'remark' => $remark,
  964. 'update_time' => time()
  965. ];
  966. // 启动事务
  967. $result = true;
  968. // Db::startTrans();
  969. try {
  970. if ( 0 <> $last_advance ) {
  971. $data['last_advance'] = $last_advance;
  972. $data['total_advance'] = Db::raw("total_advance+{$last_advance}");
  973. // $channel_id = $this->_polyChannelDeposit->where(['id' => $id])->value('channel_id');
  974. $depositInfo = $this->_polyChannelDeposit->where(['id' => $id])->field('channel_id,total_advance')->find();
  975. $total_amount = $this->complexLogic->getChannelGameTotalAmount($depositInfo['channel_id']);
  976. $remaining_amount = bcsub($depositInfo['total_advance'], $total_amount, 2);
  977. $recordData = [
  978. 'channel_id' => $depositInfo['channel_id'],
  979. 'amount' => $last_advance,
  980. 'remaining_amount' => $remaining_amount,
  981. 'admin_id' => session('ADMIN_ID') ?: 1,
  982. 'admin_name' => session('USERNAME') ?: '',
  983. 'remark' => $remark,
  984. 'create_time' => time(),
  985. ];
  986. // dump($recordData);
  987. $result = $this->_polyChannelDepositRecord->insert($recordData);
  988. }
  989. $update = $this->_polyChannelDeposit->where(['id' => $id])->update($data);
  990. if ( false === $update || false === $result) {
  991. throw new \Exception('更新失败');
  992. } else {
  993. $channel_id = $this->_polyChannelDeposit->where(['id' => $id])->value('channel_id');
  994. $content = '编辑了渠道:'.$this->_getChannelName($channel_id);
  995. ( 0 <> $last_advance ) && $content .= ",增加预付款:".$last_advance;
  996. $content .= ",手机号码:".$mobile;
  997. $content .= ",预警额度:{$warn_amount}元";
  998. $content .= ",可超额度:{$over_limit_amount}元";
  999. $content .= ",备注:".$remark;
  1000. $this->insertLog($this->current_node, $content, 52);
  1001. }
  1002. Db::commit();
  1003. $this->success('更新成功', url('ComplexChannel/listDeposit') );
  1004. } catch (\Exception $e){
  1005. Db::rollback();
  1006. if ($e instanceof \think\exception\HttpResponseException) {
  1007. throw $e;
  1008. }
  1009. $this->error('操作失败:' . $e->getMessage());
  1010. }
  1011. } else {
  1012. $id = $this->request->param('id', 0, 'intval');
  1013. if ( empty($id) ) {
  1014. $this->error('参数出错');
  1015. }
  1016. $info = $this->_polyChannelDeposit->field(['id', 'channel_id', 'total_advance', 'mobile', 'warn_amount', 'over_limit_amount', 'remark'])->find($id);
  1017. if ( empty($info) ) {
  1018. $this->error('数据不存在');
  1019. }
  1020. $info['channel_name'] = $this->_getChannelName($info['channel_id']);
  1021. $info['channel_desc'] = $this->_getChannelDesc($info['channel_id']);
  1022. $info['total_amount'] = $this->complexLogic->getChannelGameTotalAmount($info['channel_id']);
  1023. $info['mobile'] = str_replace(',',PHP_EOL, $info['mobile']); //多个手机号用逗号分隔
  1024. $this->assign('vo', $info);
  1025. return $this->fetch("editDeposit");
  1026. }
  1027. }
  1028. // 聚合渠道预付款记录
  1029. public function listDepositRecord() {
  1030. $channel_id = $this->request->param('channel_id', 0, 'intval');
  1031. $condition = [];
  1032. if ( ! empty($channel_id) ) {
  1033. $condition['channel_id'] = $channel_id;
  1034. }
  1035. $list = $this->_polyChannelDepositRecord->where($condition)->order('id desc')->select();
  1036. $this->assign('list', $list);
  1037. return $this->fetch("listDepositRecord");
  1038. }
  1039. /**
  1040. * 获取聚合渠道列表
  1041. *
  1042. * @return array
  1043. */
  1044. protected function _getChannelList() {
  1045. $list = $this->complexChannelModel->field(['id', 'name'])->where(['flag' => 4])->order('id desc')->select();
  1046. return $list ?: [];
  1047. }
  1048. /**
  1049. * 获取游戏名称
  1050. *
  1051. * @param int $game_id
  1052. * @return string
  1053. */
  1054. protected function _getGameName($game_id) {
  1055. $nickname = $this->_gameModel->getName($game_id);
  1056. return $nickname ?: '';
  1057. }
  1058. /**
  1059. * 获取游戏原名
  1060. *
  1061. * @param int $game_id
  1062. * @return string
  1063. */
  1064. protected function _getGameOriginName($game_id) {
  1065. $nickname = $this->_gameModel->getOriginName($game_id);
  1066. return $nickname ?: '';
  1067. }
  1068. /**
  1069. * 获取渠道名称
  1070. *
  1071. * @param int $channel_id
  1072. * @return string
  1073. */
  1074. protected function _getChannelName($channel_id) {
  1075. $name = $this->complexChannelModel->where(['id' => $channel_id] )->value('name');
  1076. return $name ?: '';
  1077. }
  1078. protected function _getChannelDesc($channel_id) {
  1079. $desc = $this->complexChannelModel->where(['id' => $channel_id] )->value('remark');
  1080. return $desc ?: '';
  1081. }
  1082. }