Member.php 69 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265
  1. <?php
  2. /**
  3. * 前台注册用户管理控制器
  4. */
  5. namespace app\guildapi\controller;
  6. use app\common\library\MakeReportGo;
  7. use think\Db;
  8. use think\Paginator;
  9. use think\Exception;
  10. use think\JsonException;
  11. use app\common\logic\Member as MemberService;
  12. use app\common\library\MakeReport;
  13. use think\paginator\driver\Bootstrap;
  14. use think\db\exception\DataNotFoundException;
  15. use think\db\exception\ModelNotFoundException;
  16. use think\exception\DbException;
  17. use think\Exception\httpResponseException;
  18. use app\common\model\Members as MembersModel;
  19. class Member extends Guild
  20. {
  21. protected function _initialize()
  22. {
  23. parent::_initialize();
  24. $this->membersModel = Db::name('cy_members');
  25. $this->membersGameModel = Db::name('nw_member_game_server');
  26. $this->nw_channel = Db::name('nw_channel');
  27. }
  28. /**
  29. * 注册用户列表
  30. */
  31. public function getMemberList()
  32. {
  33. $channelArr = [5813];
  34. $download = input('download');
  35. $list_rows = input('pageSize', 10);
  36. $page = input('page', 1);
  37. $type = input('type', 1);
  38. $where = $this->_getCondition('members', 1);
  39. //已接单的游戏才能展示2022-08-03
  40. $where['game.id'] = ['in', model('game')->getTakingGame($this->_channelId)];
  41. switch ($download) {
  42. case '1':
  43. if ($type == 2) {
  44. if (in_array($this->_channelId, $channelArr)) {
  45. $field = 'mcg.mcgr_id,game.name as game_name,members.username, mgs.servername,mgs.rolename,mgs.rolelevel, mgs.ip,mgs.imeil,FROM_UNIXTIME( members.reg_time ) AS create_time,IFNULL(FROM_UNIXTIME( mgs.update_time),FROM_UNIXTIME( mcg.update_time)) AS login_time,FROM_UNIXTIME( mgs.create_time) AS reg_time,channel.name as channel_name,members.mobile as mobile';
  46. } else {
  47. $field = 'mcg.mcgr_id,game.name as game_name,members.username, mgs.servername,mgs.rolename,mgs.rolelevel, mgs.ip,mgs.imeil,FROM_UNIXTIME( members.reg_time ) AS create_time,IFNULL(FROM_UNIXTIME( mgs.update_time),FROM_UNIXTIME( mcg.update_time)) AS login_time,FROM_UNIXTIME( mgs.create_time) AS reg_time,channel.name as channel_name,"" as mobile';
  48. }
  49. $sql = Db::name('cy_member_channel_game_rel')->alias('mcg')
  50. ->join('cy_game game', 'mcg.game_id = game.id', 'left')
  51. ->join('cy_members members', 'mcg.member_id = members.id', 'left')
  52. ->join('nw_member_game_server mgs', 'mcg.member_id=mgs.member_id and mcg.game_id=mgs.game_id', 'left')
  53. ->join('nw_channel channel', 'mcg.channel_id=channel.id AND (channel.id=' . $this->_channelId . ' or channel.id_path like "' . $this->_channelIdPath . '%")')
  54. ->field($field)
  55. ->where($where)
  56. ->where("game.is_default = 0")
  57. // ->group("members.username")
  58. ->group("mgs.rolename")
  59. ->order('mcg.mcgr_id desc,mgs.mgs_id desc')
  60. ->fetchSql(true)
  61. ->select();
  62. } else {
  63. if (in_array($this->_channelId, $channelArr)) {
  64. $field = 'mgs.mgs_id,game.name as game_name,members.username,mgs.servername,mgs.rolename,mgs.rolelevel,mgs.ip,mgs.imeil,FROM_UNIXTIME( members.reg_time ) AS create_time,FROM_UNIXTIME( mgs.update_time) AS login_time,FROM_UNIXTIME( mgs.create_time) AS reg_time,channel.NAME AS channel_name ,members.mobile as mobile';
  65. } else {
  66. $field = 'mgs.mgs_id,game.name as game_name,members.username,mgs.servername,mgs.rolename,mgs.rolelevel,mgs.ip,mgs.imeil,FROM_UNIXTIME( members.reg_time ) AS create_time,FROM_UNIXTIME( mgs.update_time) AS login_time,FROM_UNIXTIME( mgs.create_time) AS reg_time,channel.NAME AS channel_name ,"" as mobile';
  67. }
  68. $sql = Db::name('nw_member_game_server')->alias('mgs')
  69. ->join('cy_game game', 'mgs.game_id = game.id', 'left')
  70. ->join('cy_members members', 'mgs.member_id = members.id', 'left')
  71. ->join('nw_channel channel', 'mgs.channel_id=channel.id AND (channel.id=' . $this->_channelId . ' or channel.id_path like "' . $this->_channelIdPath . '%")')
  72. ->field($field)
  73. ->where($where)
  74. ->where("game.is_default = 0")
  75. // ->group("members.username")
  76. ->group("mgs.rolename")
  77. ->order('mgs.mgs_id desc')
  78. ->fetchSql(true)
  79. ->select();
  80. }
  81. // if ((new MakeReport())->addTask('guild.memberRegExport', $sql, 'cps'.$this->_adminId)){
  82. if ((new MakeReportGo())->addTask('guild.memberRegExport', $sql, 'cps' . $this->_adminId)) {
  83. return json(['data' => '', 'code' => 20000, 'msg' => '报表生成的任务已经提交, 报表生成完成后,会及时通知您,请耐心稍等']);
  84. } else {
  85. return json(['data' => '', 'code' => 20013, 'msg' => '报表生成任务不可重复提交,如遇到无法导出情况,建议修改查询条件解除当前状态,提交重新生成报表任务!']);
  86. }
  87. break;
  88. default:
  89. if ($type == 2) {
  90. if (in_array($this->_channelId, $channelArr)) {
  91. $field = 'mcg.mcgr_id,game.name as game_name,members.username, mgs.servername,mgs.rolename,mgs.rolelevel, mgs.ip,mgs.imeil,FROM_UNIXTIME( members.reg_time ) AS create_time,IFNULL(FROM_UNIXTIME( mgs.update_time),FROM_UNIXTIME( mcg.update_time)) AS login_time,FROM_UNIXTIME( mgs.create_time) AS reg_time,channel.name as channel_name,members.mobile as mobile';
  92. } else {
  93. $field = 'mcg.mcgr_id,game.name as game_name,members.username, mgs.servername,mgs.rolename,mgs.rolelevel, mgs.ip,mgs.imeil,FROM_UNIXTIME( members.reg_time ) AS create_time,IFNULL(FROM_UNIXTIME( mgs.update_time),FROM_UNIXTIME( mcg.update_time)) AS login_time,FROM_UNIXTIME( mgs.create_time) AS reg_time,channel.name as channel_name,"" as mobile';
  94. }
  95. $list = Db::name('cy_member_channel_game_rel')->alias('mcg')
  96. ->join('cy_game game', 'mcg.game_id = game.id', 'left')
  97. ->join('cy_members members', 'mcg.member_id = members.id', 'left')
  98. ->join('nw_member_game_server mgs', 'mcg.member_id=mgs.member_id and mcg.game_id=mgs.game_id', 'left')
  99. ->join('nw_channel channel', 'mcg.channel_id=channel.id AND (channel.id=' . $this->_channelId . ' or channel.id_path like "' . $this->_channelIdPath . '%")')
  100. ->field($field)
  101. ->where($where)
  102. ->where("game.is_default = 0")
  103. ->group("mgs.rolename")
  104. ->order('mcg.mcgr_id desc,mgs.mgs_id desc')
  105. ->paginate(['list_rows' => $list_rows, 'page' => $page])->toArray();
  106. } else {
  107. if (in_array($this->_channelId, $channelArr)) {
  108. $field = 'mgs.mgs_id,mgs.game_id,mgs.member_id,game.name as game_name,members.username,mgs.servername,mgs.rolename,mgs.rolelevel,mgs.ip,mgs.imeil,FROM_UNIXTIME( members.reg_time ) AS create_time,FROM_UNIXTIME( mgs.update_time) AS login_time,FROM_UNIXTIME( mgs.create_time) AS reg_time,channel.NAME AS channel_name ,members.mobile as mobile';
  109. } else {
  110. $field = 'mgs.mgs_id,mgs.game_id,mgs.member_id,game.name as game_name,members.username,mgs.servername,mgs.rolename,mgs.rolelevel,mgs.ip,mgs.imeil,FROM_UNIXTIME( members.reg_time ) AS create_time,FROM_UNIXTIME( mgs.update_time) AS login_time,FROM_UNIXTIME( mgs.create_time) AS reg_time,channel.NAME AS channel_name ,"" as mobile';
  111. }
  112. $list = Db::name('nw_member_game_server')->alias('mgs')
  113. ->join('cy_game game', 'mgs.game_id = game.id', 'left')
  114. ->join('cy_members members', 'mgs.member_id = members.id', 'left')
  115. ->join('nw_channel channel', 'mgs.channel_id=channel.id AND (channel.id=' . $this->_channelId . ' or channel.id_path like "' . $this->_channelIdPath . '%")')
  116. ->field($field)
  117. ->where($where)
  118. ->where("game.is_default = 0")
  119. ->group("mgs.rolename")
  120. ->order('mgs.mgs_id desc')
  121. ->paginate(['list_rows' => $list_rows, 'page' => $page])->toArray();
  122. foreach ($list['data'] as $k=> $value) {
  123. if ($value['game_name'] == "仙剑奇侠传3D回合(iOS)") {
  124. $level = Db::name('nw_member_game_server')->alias('mgs')
  125. ->join('cy_game game', 'mgs.game_id = game.id', 'left')
  126. ->where('game.name','=','仙剑奇侠传3D回合(iOS)')
  127. ->where('mgs.servername','=',$value['servername'])
  128. ->where('mgs.member_id','=',$value['member_id'])
  129. ->where('mgs.game_id','=',$value['game_id'])
  130. ->max('mgs.rolelevel');
  131. $list['data'][$k]['rolelevel'] = $level;
  132. }
  133. if ($value['game_name'] == "仙剑奇侠传3D回合(安卓)") {
  134. $level = Db::name('nw_member_game_server')->alias('mgs')
  135. ->join('cy_game game', 'mgs.game_id = game.id', 'left')
  136. ->where('game.name','=','仙剑奇侠传3D回合(安卓)')
  137. ->where('mgs.servername','=',$value['servername'])
  138. ->where('mgs.member_id','=',$value['member_id'])
  139. ->where('mgs.game_id','=',$value['game_id'])
  140. ->max('mgs.rolelevel');
  141. $list['data'][$k]['rolelevel'] = $level;
  142. }
  143. }
  144. }
  145. // echo Db::getLastSql();die;
  146. // $gameList = model('Common/Game')->getAllByCondition('id,name',['game_kind'=>1,'cooperation_status'=>['neq',0]],'','self');
  147. $gameList = $this->getTakingGameList();
  148. $channelList = Db::table('nw_channel')->field('id,name')->where(['level' => 3, 'id_path' => ['LIKE', $this->_channelIdPath . '%']])->select();
  149. return json(['data' => $list, 'code' => 20000, 'msg' => '获取数据成功', 'gameList' => $gameList, 'channelList' => $channelList]);
  150. break;
  151. }
  152. }
  153. /**************************************************************首页数据*****************************************/
  154. /**
  155. * 首页注册用户统计
  156. */
  157. public function getMemberCount()
  158. {
  159. $forbid_channel_ids = Db::table("nw_channel_view_limit")->column("channel_id");
  160. if (in_array($this->_channelId, $forbid_channel_ids)) {
  161. return json(['data' => '', 'code' => 10032, 'msg' => '暂时没有权限查看首页注册用户统计']);
  162. }
  163. $type = input('type');
  164. $where = [];
  165. //已接单的游戏才能展示2022-08-03
  166. $where['game.id'] = ['in', model('game')->getTakingGame($this->_channelId)];
  167. $weekormonth = [];
  168. switch ($type) {
  169. case 'month':
  170. $formdata = '%Y-%m';
  171. $where['mgs.create_time'] = [['>=', time() - 86400 * 220], ['<=', strtotime(date('Y-m-d 23:59:59'))]];
  172. // $where['mgs.create_time'] = [['>=', strtotime(date("Y",time())."-1"."-1")],['<=', strtotime(date('Y-m-d 23:59:59'))]];
  173. for ($i = 1; $i <= 7; $i++) {
  174. // $weekormonth[$i]['date'] = date('Y-m' ,strtotime( '+' . $i-7 .' month'));
  175. $weekormonth[$i]['date'] = date("Y-m", mktime(0, 0, 0, date("m") + ($i - 7), 01, date("Y")));
  176. $weekormonth[$i]['注册量'] = 0;
  177. }
  178. break;
  179. default:
  180. $formdata = '%Y-%m-%d';
  181. $where['mgs.create_time'] = [['>=', strtotime('-7 days 0:0:0')], ['<=', strtotime(date('Y-m-d 23:59:59'))]];
  182. for ($i = 1; $i <= 7; $i++) {
  183. $weekormonth[$i]['date'] = date('Y-m-d', strtotime('+' . $i - 7 . ' days'));
  184. $weekormonth[$i]['注册量'] = 0;
  185. }
  186. break;
  187. }
  188. $list = [];
  189. $list = Db::name('nw_member_game_server')->alias('mgs')
  190. ->join('cy_game game', 'mgs.game_id = game.id and game.game_kind=1')
  191. ->join('nw_channel channel', 'mgs.channel_id=channel.id AND (channel.id=' . $this->_channelId . ' or channel.id_path like "' . $this->_channelIdPath . '%")')
  192. ->field('from_unixtime( mgs.create_time, "' . $formdata . '" ) AS date,count(*) AS counts')
  193. ->where($where)
  194. ->where("game.is_default = 0")
  195. ->group('date')
  196. ->order('date ASC')
  197. ->select();
  198. $list = array_column($list, 'counts', 'date');
  199. foreach ($weekormonth as $key => $value) {
  200. if (isset($list[$value['date']])) {
  201. $weekormonth[$key]['注册量'] = $list[$value['date']];
  202. }
  203. }
  204. $result = [];
  205. $result['columns'] = ['date', '注册量'];
  206. $result['rows'] = array_values($weekormonth);
  207. return json(['data' => $result, 'code' => 20000, 'msg' => '获取数据成功']);
  208. }
  209. /**
  210. * 首页流水数据统计
  211. */
  212. public function getSumCount()
  213. {
  214. $forbid_channel_ids = Db::table("nw_channel_view_limit")->column("channel_id");
  215. if (in_array($this->_channelId, $forbid_channel_ids)) {
  216. return json(['data' => '', 'code' => 10032, 'msg' => '暂时没有权限查看首页流水数据统计']);
  217. }
  218. $type = input('type');
  219. $where = [];
  220. //已接单的游戏才能展示2022-08-03
  221. $where['game.id'] = ['in', model('game')->getTakingGame($this->_channelId)];
  222. $weekormonth = [];
  223. switch ($type) {
  224. case 'month':
  225. $formdata = '%Y-%m';
  226. $where['pay.create_time'] = [['>=', time() - 86400 * 220], ['<=', strtotime(date('Y-m-d 23:59:59'))]];
  227. // $where['pay.create_time'] = [['>=', strtotime(date("Y",time())."-1"."-1")],['<=', strtotime(date('Y-m-d 23:59:59'))]];
  228. for ($i = 1; $i <= 7; $i++) {
  229. // $weekormonth[$i]['date'] = date('Y-m' ,strtotime( '+' . $i-7 .' month'));
  230. $weekormonth[$i]['date'] = date("Y-m", mktime(0, 0, 0, date("m") + ($i - 7), 01, date("Y")));
  231. $weekormonth[$i]['流水'] = 0;
  232. }
  233. break;
  234. default:
  235. $formdata = '%Y-%m-%d';
  236. $where['pay.create_time'] = [['>=', strtotime('-7 days 0:0:0')], ['<=', strtotime(date('Y-m-d 23:59:59'))]];
  237. for ($i = 1; $i <= 7; $i++) {
  238. $weekormonth[$i]['date'] = date('Y-m-d', strtotime('+' . $i - 7 . ' days'));
  239. $weekormonth[$i]['流水'] = 0;
  240. }
  241. break;
  242. }
  243. $list = Db::name('cy_pay')->alias('pay')
  244. ->join('nw_channel channel', 'pay.channel_id=channel.id AND (channel.id=' . $this->_channelId . ' or channel.id_path like "' . $this->_channelIdPath . '%")')
  245. ->join('cy_game game', 'pay.gameid=game.id AND game.game_kind=1')
  246. ->field('from_unixtime( pay.create_time, "' . $formdata . '" ) AS date,sum(pay.pay_amount) as counts')
  247. ->where($where)
  248. ->where("game.is_default = 0")
  249. ->where(['pay.status' => 1])
  250. ->group('date')
  251. ->order('date ASC')
  252. ->select();
  253. $list = array_column($list, 'counts', 'date');
  254. foreach ($weekormonth as $key => $value) {
  255. if (isset($list[$value['date']])) {
  256. $weekormonth[$key]['流水'] = $list[$value['date']];
  257. }
  258. }
  259. $result = [];
  260. $result['columns'] = ['date', '流水'];
  261. $result['rows'] = array_values($weekormonth);
  262. return json(['data' => $result, 'code' => 20000, 'msg' => '获取数据成功']);
  263. }
  264. /**
  265. * 首页推广员数据
  266. */
  267. public function getAgentCount()
  268. {
  269. $forbid_channel_ids = Db::table("nw_channel_view_limit")->column("channel_id");
  270. if (in_array($this->_channelId, $forbid_channel_ids)) {
  271. return json(['data' => '', 'code' => 10032, 'msg' => '暂时没有权限查看首页推广员数据']);
  272. }
  273. $type = input('type');
  274. $where = [];
  275. $list_rows = input('pageSize', 5);
  276. $page = input('page', 1);
  277. $t_day = date('Y-m-d');//今日日期
  278. $yse_day = date("Y-m-d", strtotime("-1 day"));//昨日日期
  279. if ($type == 'agent') {
  280. $where['reg_time'] = [['>=', strtotime('-1 days 0:0:0')], ['<=', strtotime(date('Y-m-d 23:59:59'))]];
  281. $wherea['create_time'] = [['>=', strtotime('-1 days 0:0:0')], ['<=', strtotime(date('Y-m-d 23:59:59'))]];
  282. //$where['channel_id'] = [''.$this->_channelId.''];
  283. //$list = $this->membersGameModel->alias('members')
  284. //->join('nw_channel channel', 'members.channel_id=channel.id AND (channel.id='.$this->_channelId.' or channel.id_path like "'.$this->_channelIdPath.'%")')
  285. //->join('cy_game game','members.game_id=game.id AND game.game_kind=1')
  286. //->field('count(*) AS counts,channel.name,from_unixtime(members.create_time, "%Y-%m-%d" ) AS date,channel.id')
  287. //->where($where)
  288. //->where("game.is_default = 0")
  289. //->where(['channel.level' => 3 ])
  290. //->group('channel.id,date')
  291. //->order('date')
  292. //->select();
  293. $field = ['id', 'name'];
  294. $zong = $this->nw_channel
  295. ->field($field)
  296. //->where($wherea)
  297. //->where('parent_id = '.$this->_channelId.'')
  298. ->where('id_path', 'like', '%' . $this->_channelId . '%')
  299. ->paginate(['list_rows' => $list_rows, 'page' => $page])
  300. ->each(function ($item) {
  301. $zuotian['reg_time'] = [['>=', strtotime('-1 days 0:0:0')], ['<=', strtotime('-1 days 23:59:59')]];
  302. $jint['reg_time'] = [['>=', strtotime('0:0:0')], ['<=', time()]];
  303. //今天
  304. $item['tday_counts'] = $this->membersModel
  305. ->where('channel_id = ' . $item['id'] . '')
  306. ->where($jint)
  307. ->count();
  308. //昨天
  309. $item['ytay_counts'] = $this->membersModel
  310. ->where('channel_id = ' . $item['id'] . '')
  311. ->where($zuotian)
  312. ->count();
  313. return $item;
  314. })
  315. // ->select();
  316. ->toArray();
  317. //foreach ($zong as $k =>$v){
  318. //$list[] = $this->membersModel->field('id,username')
  319. // ->where('channel_id = '.$v['id'].'')
  320. //->where($where)
  321. // ->select();
  322. // }
  323. return json(['data' => $zong, 'code' => 20000, 'msg' => '获取数据成功']);
  324. }
  325. if ($type == 'sum') {
  326. //已接单的游戏才能展示2022-08-03
  327. $where['game.id'] = ['in', model('game')->getTakingGame($this->_channelId)];
  328. $where['pay.create_time'] = [['>=', strtotime('-100 days 0:0:0')], ['<=', strtotime(date('Y-m-d 23:59:59'))]];
  329. $list = Db::name('cy_pay')->alias('pay')
  330. ->join('nw_channel channel', 'pay.channel_id=channel.id AND (channel.id=' . $this->_channelId . ' or channel.id_path like "' . $this->_channelIdPath . '%")')
  331. ->join('cy_game game', 'pay.gameid=game.id AND game.game_kind=1')
  332. ->field('sum(pay.pay_amount) as counts,channel.name,from_unixtime(pay.create_time, "%Y-%m-%d" ) AS date,channel.id')
  333. ->where($where)
  334. ->where("game.is_default = 0")
  335. ->where(['channel.level' => 3, 'pay.status' => 1])
  336. ->group('channel.id,date')
  337. ->order('date')
  338. ->select();
  339. $out = [];
  340. foreach ($list as $key => $value) {
  341. $out[$value['id']]['name'] = $value['name'];
  342. empty($out[$value['id']]['tday_counts']) && $out[$value['id']]['tday_counts'] = 0;
  343. empty($out[$value['id']]['ytay_counts']) && $out[$value['id']]['ytay_counts'] = 0;
  344. if ($value['date'] == $t_day) {
  345. $out[$value['id']]['tday_counts'] = $value['counts'];
  346. } elseif ($value['date'] == $yse_day) {
  347. $out[$value['id']]['ytay_counts'] = $value['counts'];
  348. }
  349. }
  350. $last_names = array_column($out, 'tday_counts');
  351. array_multisort($last_names, SORT_DESC, $out);
  352. $curpage = input('page') ? input('page') : 1;//当前第x页,有效值为:1,2,3,4,5...
  353. $listRow = 5;//每页5行记录
  354. $dataTo = array();
  355. $dataTo = array_chunk($out, $listRow);
  356. $showdata = array();
  357. if ($dataTo) {
  358. $showdata = $dataTo[$curpage - 1];
  359. } else {
  360. $showdata = null;
  361. }
  362. $p = Bootstrap::make($showdata, $listRow, $curpage, count($out), false, [
  363. 'var_page' => 'page',
  364. 'path' => url('url'),//这里根据需要修改url
  365. 'fragment' => '',
  366. ]);
  367. return json(['data' => $p, 'code' => 20000, 'msg' => '获取数据成功']);
  368. }
  369. }
  370. /****************************************************************************************************************/
  371. /**
  372. * 订单用户列表
  373. */
  374. public function getOrderList()
  375. {
  376. $forbid_channel_ids = Db::table("nw_channel_view_limit")->column("channel_id");
  377. if (in_array($this->_channelId, $forbid_channel_ids)) {
  378. return json(['data' => '', 'code' => 10032, 'msg' => '暂时没有权限查看订单数据']);
  379. }
  380. $download = input('download');
  381. $list_rows = input('pageSize', 10);
  382. $page = input('page', 1);
  383. $where = $this->_getCondition('pay', 1);
  384. $status = input('status');
  385. $where['pay.status'] = 1;
  386. if($status == 2) {
  387. $where['pay.status'] = 2;
  388. }
  389. //已接单的游戏才能展示2022-08-03
  390. $where['game.id'] = ['in', model('game')->getTakingGame($this->_channelId)];
  391. switch ($download) {
  392. case '1':
  393. $sql = Db::table('cy_pay')->alias('pay')
  394. ->join('cy_game game', 'pay.gameid = game.id')
  395. ->join('nw_channel channel', 'pay.channel_id=channel.id AND (channel.id=' . $this->_channelId . ' or channel.id_path like "' . $this->_channelIdPath . '%")')
  396. // ->join('nw_game_server server', 'pay.gameid=server.game_id And pay.serverid = server.serverid','left')
  397. ->field('pay.id,game.name as game_name,game.id as game_id,pay.username,pay.rolename,pay.pay_amount as amount,pay.paytype,pay.orderid,FROM_UNIXTIME(pay.create_time) as create_time,channel.name as channel_name,pay.servername,pay.status,pay.coupon_amount,pay.real_coin,pay.pay_amount')
  398. ->where($where)
  399. ->where("game.is_default = 0")
  400. ->order('pay.id desc')
  401. ->fetchSql(true)
  402. ->select();
  403. // if ((new MakeReport())->addTask('guild.orderListExport', $sql, 'cps'.$this->_adminId)){
  404. if ((new MakeReportGo())->addTask('guild.orderListExport', $sql, 'cps' . $this->_adminId)) {
  405. return json(['data' => '', 'code' => 20000, 'msg' => '报表生成的任务已经提交, 报表生成完成后,会及时通知您,请耐心稍等']);
  406. } else {
  407. return json(['data' => '', 'code' => 20013, 'msg' => '报表生成任务不可重复提交,如遇到无法导出情况,建议修改查询条件解除当前状态,提交重新生成报表任务!']);
  408. }
  409. break;
  410. default:
  411. $list = Db::table('cy_pay')->alias('pay')
  412. ->join('cy_game game', 'pay.gameid = game.id')
  413. ->join('nw_channel channel', 'pay.channel_id=channel.id AND (channel.id=' . $this->_channelId . ' or channel.id_path like "' . $this->_channelIdPath . '%")')
  414. // ->join('nw_game_server server', 'pay.gameid=server.game_id And pay.serverid = server.serverid','left')
  415. ->field('pay.id,game.name as game_name,game.id as game_id,pay.username,pay.rolename,pay.pay_amount as amount,pay.paytype,pay.orderid,FROM_UNIXTIME(pay.create_time) as create_time,channel.name as channel_name,pay.servername,pay.status,pay.coupon_amount,pay.real_coin,pay.pay_amount')
  416. ->where($where)->order('pay.id desc')
  417. ->where("game.is_default = 0")
  418. ->paginate(['list_rows' => $list_rows, 'page' => $page])->toArray();
  419. /* foreach ($list['data'] as $key => $item) {
  420. if (in_array($item['paytype'], ['zfb-wap', 'zfbsmzf', 'xzzfbzf', 'old-zfb-wap'])) {
  421. $list['data'][$key]['paytype'] = "zfb";
  422. } else if (in_array($item['paytype'], ['wx-wap', 'wxsmzf'])) {
  423. $list['data'][$key]['paytype'] = "wxpay";
  424. }
  425. //$list['data'][$key]['orderid'] = $item['orderid'] . "--" . ($item['status'] == 1 ? "支付成功" : "待支付");
  426. }*/
  427. $total_amount = Db::table('cy_pay')->alias('pay')
  428. ->join('cy_game game', 'pay.gameid = game.id')
  429. ->join('nw_channel channel', 'pay.channel_id=channel.id AND (channel.id=' . $this->_channelId . ' or channel.id_path like "' . $this->_channelIdPath . '%")')
  430. ->where($where)
  431. ->where("game.is_default = 0")
  432. ->value('sum(pay.pay_amount)');
  433. // $gameList = model('Common/Game')->getAllByCondition('id,name',['game_kind'=>1,'cooperation_status'=>['neq',0]],'','self');
  434. $gameList = $this->getTakingGameList();
  435. $channelList = Db::table('nw_channel')->field('id,name')->where(['level' => 3, 'id_path' => ['LIKE', '%,' . $this->_channelId . ',%']])->select();
  436. if(!empty($list['per_page'])){
  437. $list['per_page'] = (int)$list['per_page'];
  438. }
  439. return json(['data' => $list, 'code' => 20000, 'msg' => '获取数据成功', 'gameList' => $gameList, 'channelList' => $channelList, 'total_amount' => $total_amount]);
  440. break;
  441. }
  442. }
  443. /**
  444. * 订单用户列表(汇总)
  445. */
  446. public function getSumOrderList()
  447. {
  448. $forbid_channel_ids = Db::table("nw_channel_view_limit")->column("channel_id");
  449. if (in_array($this->_channelId, $forbid_channel_ids)) {
  450. return json(['data' => '', 'code' => 10032, 'msg' => '暂时没有权限查看订单汇总数据']);
  451. }
  452. $download = input('download');//执行类型
  453. $list_rows = input('pageSize', 10);
  454. $page = input('page', 1);
  455. $where = $this->_getCondition('pay', 1);//条件选择func
  456. //已接单的游戏才能展示2022-08-03
  457. $where['game.id'] = ['in', model('game')->getTakingGame($this->_channelId)];
  458. $status = input('status');
  459. $where['pay.status'] = 1;
  460. if($status == 2) {
  461. $where['pay.status'] = 2;
  462. }
  463. switch ($download) {
  464. case '1'://py执行异步导出
  465. $sql = Db::table('cy_pay')->alias('pay')
  466. ->join('cy_game game', 'pay.gameid = game.id')
  467. ->join('nw_channel channel', 'pay.channel_id=channel.id AND (channel.id=' . $this->_channelId . ' or channel.id_path like "' . $this->_channelIdPath . '%")')
  468. ->field('sum(pay.pay_amount) as money,round(sum(pay.pay_amount)-sum(pay.coupon_amount),2) as actual_amount,sum(pay.coupon_amount) as coupon_amount,game.name as game_name,game.id as game_id,pay.rolename,pay.username,channel.name as channel_name')
  469. ->where("game.is_default = 0")
  470. ->where($where)
  471. ->order('pay.create_time desc')
  472. ->group('userid,gameid,roleid')
  473. ->fetchSql(true)
  474. ->select();
  475. // if ((new MakeReport())->addTask('guild.orderTotalExport', $sql, 'cps'.$this->_adminId)){
  476. if ((new MakeReportGo())->addTask('guild.orderTotalExport', $sql, 'cps' . $this->_adminId)) {
  477. return json(['data' => '', 'code' => 20000, 'msg' => '报表生成的任务已经提交, 报表生成完成后,会及时通知您,请耐心稍等']);
  478. } else {
  479. return json(['data' => '', 'code' => 20013, 'msg' => '报表生成任务不可重复提交,如遇到无法导出情况,建议修改查询条件解除当前状态,提交重新生成报表任务!']);
  480. }
  481. break;
  482. default://列表展示
  483. $list = Db::table('cy_pay')->alias('pay')
  484. ->join('cy_game game', 'pay.gameid = game.id')
  485. ->join('nw_channel channel', 'pay.channel_id=channel.id AND (channel.id=' . $this->_channelId . ' or channel.id_path like "' . $this->_channelIdPath . '%")')
  486. ->field('sum(pay.pay_amount) as money,round(sum(pay.pay_amount)-sum(pay.coupon_amount),2) as actual_amount,sum(pay.coupon_amount) as coupon_amount,game.name as game_name,game.id as game_id,pay.rolename,pay.username,channel.name as channel_name')
  487. ->where("game.is_default = 0")
  488. ->where($where)
  489. ->order('pay.create_time desc')
  490. ->group('userid,gameid,roleid')
  491. ->paginate(['list_rows' => $list_rows, 'page' => $page])->toArray();
  492. $total_info = Db::table('cy_pay')->alias('pay')
  493. ->join('cy_game game', 'pay.gameid = game.id')
  494. ->join('nw_channel channel', 'pay.channel_id=channel.id AND (channel.id=' . $this->_channelId . ' or channel.id_path like "' . $this->_channelIdPath . '%")')
  495. ->field('sum(pay.pay_amount) as money,round(sum(pay.pay_amount)-sum(pay.coupon_amount),2) as actual_amount,sum(pay.coupon_amount) as coupon_amount')
  496. ->where("game.is_default = 0")
  497. ->where($where)
  498. ->find();
  499. return json(['data' => $list, 'total_amount' => $total_info['money'], 'actual_amount' => $total_info['actual_amount'], 'coupon_amount' => $total_info['coupon_amount'], 'code' => 20000, 'msg' => '获取数据成功']);
  500. break;
  501. }
  502. }
  503. /**
  504. * 推广员数据列表(汇总)
  505. */
  506. public function getSumAgentList()
  507. {
  508. $download = input('download');
  509. $list_rows = input('pageSize', 10);
  510. $page = input('page', 1);
  511. $where = $this->_getCondition('pay', 1);
  512. $this->membersModel = new MembersModel;
  513. //if ($this->_channelLevel == 3 || $this->_channelLevel == 0) {
  514. // return json(['data'=>'','code'=>10032,'msg'=>'暂时没有权限查看推广员数据']);
  515. // }
  516. $forbid_channel_ids = Db::table("nw_channel_view_limit")->column("channel_id");
  517. if (in_array($this->_channelId, $forbid_channel_ids)) {
  518. return json(['data' => '', 'code' => 10032, 'msg' => '暂时没有权限查看推广员数据']);
  519. }
  520. //已接单的游戏才能展示2022-08-03
  521. $where['game.id'] = ['in', model('game')->getTakingGame($this->_channelId)];
  522. switch ($download) {
  523. case '1':
  524. $sql = Db::table('cy_pay')->alias('pay')
  525. ->group('pay.channel_id,pay.gameid')
  526. ->field('sum(pay.pay_amount) as money,round(sum(pay.pay_amount)-sum(pay.coupon_amount),2) as actual_amount,sum(pay.coupon_amount) as coupon_amount,game.name as game_name,channel.name as channel_name,channel.id as channel_id,parent.name as xinzeng')
  527. ->join('cy_game game', 'pay.gameid = game.id')
  528. ->join('nw_channel channel', 'pay.channel_id=channel.id AND (channel.id=' . $this->_channelId . ' or channel.id_path like "' . $this->_channelIdPath . '%")')
  529. ->join('nw_channel parent', 'channel.parent_id = parent.id and parent.level = 2', 'left')
  530. ->where("game.is_default = 0")
  531. ->where("pay.status =1")
  532. ->where($where)->order('pay.create_time desc')
  533. ->fetchSql(true)
  534. ->select();
  535. // if ((new MakeReport())->addTask('guild.sumAgentExport', $sql, 'cps'.$this->_adminId)){
  536. if ((new MakeReportGo())->addTask('guild.sumAgentExport', $sql, 'cps' . $this->_adminId)) {
  537. return json(['data' => '', 'code' => 20000, 'msg' => '报表生成的任务已经提交, 报表生成完成后,会及时通知您,请耐心稍等']);
  538. } else {
  539. return json(['data' => '', 'code' => 20013, 'msg' => '报表生成任务不可重复提交,如遇到无法导出情况,建议修改查询条件解除当前状态,提交重新生成报表任务!']);
  540. }
  541. break;
  542. default:
  543. //$where = $this->_getCondition('pay',1);
  544. $list = Db::table('cy_pay')->alias('pay')
  545. ->group('pay.channel_id,pay.gameid')
  546. ->field('sum(pay.pay_amount) as money,round(sum(pay.pay_amount)-sum(pay.coupon_amount),2) as actual_amount,sum(pay.coupon_amount) as coupon_amount,game.name as game_name,userid as member_id,rolename as rolename,game.id as game_id,channel.name as channel_name,channel.id as channel_id,parent.name as p_name')
  547. ->join('cy_game game', 'pay.gameid = game.id')
  548. ->join('nw_channel channel', 'pay.channel_id=channel.id AND (channel.id=' . $this->_channelId . ' or channel.id_path like "' . $this->_channelIdPath . '%")')
  549. ->join('nw_channel parent', 'channel.parent_id = parent.id and parent.level = 2', 'left')
  550. ->where("game.is_default = 0")
  551. ->where("pay.status =1")
  552. ->where($where)->order('pay.create_time desc')
  553. ->order('pay.gameid desc')
  554. ->paginate(['list_rows' => $list_rows, 'page' => $page])
  555. //->each(function($item){
  556. //$tj = Db::name('nw_member_game_server')->alias('mgs')
  557. //->join('cy_game game', 'mgs.game_id = game.id','left')
  558. //->join('cy_members members', 'mgs.member_id = members.id','left')
  559. //->join('nw_channel channel', 'mgs.channel_id=channel.id AND (channel.id='.$item['channel_id'].' or channel.id_path like "'.$this->_channelIdPath.'%")')
  560. //->field('mgs.mgs_id,game.name as game_name,members.username,mgs.servername,mgs.rolename,mgs.rolelevel,mgs.ip,mgs.imeil,FROM_UNIXTIME( members.reg_time ) AS create_time,FROM_UNIXTIME( mgs.update_time) AS login_time,FROM_UNIXTIME( mgs.create_time) AS reg_time,channel.NAME AS channel_name ')
  561. //->where('channel.id='.$item['channel_id'].'')
  562. //->where('game_id='.$item['game_id'].'')
  563. //->where($where1)
  564. //->where("game.is_default = 0")
  565. //->group("members.username")
  566. //->order('mgs.mgs_id desc')
  567. //->fetchSql(true)
  568. //->select();
  569. //$item['p_name'] = $tj;
  570. //return $item;
  571. // })
  572. ->toArray();
  573. $start_time = input('order_start_time');
  574. $end_time = input('order_end_time');
  575. $gameid = input('gameid');
  576. if (!empty($start_time)) {
  577. $reg['reg_time'] = [
  578. ['>=', strtotime($start_time)],
  579. ['<=', strtotime($end_time . ' 23:59:59')],
  580. ];
  581. } else {
  582. $reg = [];
  583. }
  584. //$where['reg_time'] =$this->getTimeCondition($start_time,$end_time);
  585. //print_r($where['pay.gameid']);die;
  586. foreach ($list['data'] as $k => $v) {
  587. $condition = [
  588. 'gameid' => $list['data'][$k]['game_id'],
  589. 'channel_id' => $list['data'][$k]['channel_id'],
  590. ];
  591. $zong = $this->membersModel->field('id')
  592. ->where($condition)
  593. ->where($reg)
  594. ->select();
  595. $list ['data'][$k]['p_name'] = count($zong);
  596. }
  597. // $gameList = model('Common/Game')->getAllByCondition('id,name',['game_kind'=>1,'cooperation_status'=>['neq',0]],'','self');
  598. $gameList = $this->getTakingGameList();
  599. $channelList = Db::table('nw_channel')->field('id,name')->where(['level' => 3, 'id_path' => ['LIKE', '%,' . $this->_channelId . ',%']])->select();
  600. return json(['data' => $list, 'code' => 20000, 'msg' => '获取数据成功', 'gameList' => $gameList, 'channelList' => $channelList]);
  601. break;
  602. }
  603. }
  604. /**
  605. *注册用户统计
  606. */
  607. public function getreglist()
  608. {
  609. $download = input('download');
  610. $list_rows = input('pageSize', 20);
  611. $page = input('page', 1);
  612. $type = input('type', 1);
  613. $where = $this->_getCondition('members', 1);
  614. $where['reg_time'] = [['>=', strtotime('-1 days 0:0:0')], ['<=', strtotime(date('Y-m-d 23:59:59'))]];
  615. $field = ['id', 'name'];
  616. $zong = $this->nw_channel
  617. ->field($field)
  618. //->where('parent_id = '.$this->_channelId.'')
  619. ->where('id_path', 'like', '%' . $this->_channelId . '%')
  620. ->paginate(['list_rows' => $list_rows, 'page' => $page])
  621. ->each(function ($item) {
  622. $zuotian['reg_time'] = [['>=', strtotime('-1 days 0:0:0')], ['<=', strtotime('-1 days 23:59:59')]];
  623. $jint['reg_time'] = [['>=', strtotime('0:0:0')], ['<=', time()]];
  624. $list_rows = input('pageSize', 20);
  625. $page = input('page', 1);
  626. $item['username'] = $this->membersModel
  627. ->where('id = ' . $item['id'] . '')
  628. ->value('username');
  629. $item['username'] = $this->membersModel
  630. ->where('id = ' . $item['id'] . '')
  631. ->value('username');
  632. //今天
  633. $item['tday_counts'] = $this->membersModel
  634. ->where('channel_id = ' . $item['id'] . '')
  635. ->where($jint)
  636. ->count();
  637. //昨天
  638. $item['ytay_counts'] = $this->membersModel
  639. ->where('channel_id = ' . $item['id'] . '')
  640. ->where($zuotian)
  641. ->count();
  642. //总注册量
  643. $item['total_counts'] = $this->membersModel
  644. ->where('channel_id = ' . $item['id'] . '')
  645. //->where($zuotian)
  646. ->count();
  647. return $item;
  648. })
  649. ->toArray();
  650. return json(['data' => $zong, 'code' => 20000, 'msg' => '获取数据成功']);
  651. }
  652. /**
  653. *注册用户统计详情
  654. */
  655. public function getregdetails()
  656. {
  657. $download = input('download');
  658. $list_rows = input('pageSize', 20);
  659. $page = input('page', 1);
  660. $type = input('type', 1);
  661. $aid = input('aid');
  662. $where = $this->_getCondition('reglist', 1);
  663. $list = $this->membersModel
  664. ->field('id,username,channel_id,gameid,reg_time,login_time')
  665. ->where('channel_id = ' . $aid . '')
  666. ->where($where)
  667. ->order("reg_time desc")
  668. ->paginate(['list_rows' => $list_rows, 'page' => $page])
  669. ->toArray();
  670. foreach ($list['data'] as $k => $v) {
  671. $list['data'][$k]['reg_time'] = date('Y-m-d H:i:s', $v['reg_time']);
  672. $list['data'][$k]['login_time'] = date('Y-m-d H:i:s', $v['login_time']);
  673. $list['data'][$k]['gameid'] = Db::table('cy_game')->where('id', $v['gameid'])->value('name');
  674. $list['data'][$k]['channel_id'] = Db::table('nw_channel')->where('id', $v['channel_id'])->value('name');
  675. }
  676. // $gameList = model('Common/Game')->getAllByCondition('id,name',['game_kind'=>1,'cooperation_status'=>['neq',0]],'','self');
  677. $gameList = $this->getTakingGameList();
  678. $channelList = Db::table('nw_channel')->field('id,name')->where(['id_path' => ['LIKE', '%,' . $this->_channelId . ',%']])->select();
  679. return json(['data' => $list, 'code' => 20000, 'msg' => '获取数据成功', 'gameList' => $gameList, 'channelList' => $channelList]);
  680. }
  681. /**
  682. * 子会长流水数据列表(汇总)
  683. */
  684. public function getSumChlidList()
  685. {
  686. $list_rows = input('pageSize', 10);
  687. $page = input('page', 1);
  688. $where = $this->_getCondition('chlid', 1);
  689. $order_start_time = input('order_start_time');
  690. $order_end_time = input('order_end_time');
  691. $download = input('download');
  692. if (empty($order_start_time) || empty($order_end_time)) {
  693. return json(['data' => '', 'code' => 20040, 'msg' => '请选择开始日期和结束日期']);
  694. } else if (date('Y-m-d', strtotime($order_start_time)) <> $order_start_time || date('Y-m-d', strtotime($order_end_time)) <> $order_end_time) {
  695. return json(['data' => '', 'code' => 20040, 'msg' => '开始/结束日期输入不合法']);
  696. }
  697. //已接单的游戏才能展示2022-08-03
  698. $where['g.id'] = ['in', model('game')->getTakingGame($this->_channelId)];
  699. switch ($download) {
  700. case '1':
  701. $time = $order_start_time . ' - ' . $order_end_time;
  702. $sql = Db::table('nw_channel')->alias('c1')
  703. ->group('p.gameid,c2.id')
  704. ->field('p.gameid,c2.id,c2.name,count(*) as total_cnt,sum(p.pay_amount) as total_amount,sum(p.pay_amount-p.coupon_amount) as actual_amount,sum(p.coupon_amount) as coupon_amount,g.name as gname,"' . $time . '" as time')
  705. ->join('nw_channel c2', 'c1.parent_id = c2.id AND c2.LEVEL = 2 AND c2.id_path LIKE "' . $this->_channelIdPath . '%"')
  706. ->join('cy_pay p', 'c1.id = p.channel_id AND p.status = 1')
  707. ->join('cy_game g', 'p.gameid = g.id')
  708. ->where("g.is_default = 0")
  709. ->where(['c1.level' => 3, 'c1.id_path' => ['LIKE', $this->_channelIdPath . '%']])
  710. ->where($where)
  711. ->fetchSql(true)
  712. ->select();
  713. // if ((new MakeReport())->addTask('guild.sumChlidExport', $sql, 'cps'.$this->_adminId)){
  714. if ((new MakeReportGo())->addTask('guild.sumChlidExport', $sql, 'cps' . $this->_adminId)) {
  715. return json(['data' => '', 'code' => 20000, 'msg' => '报表生成的任务已经提交, 报表生成完成后,会及时通知您,请耐心稍等']);
  716. } else {
  717. return json(['data' => '', 'code' => 20013, 'msg' => '报表生成任务不可重复提交,如遇到无法导出情况,建议修改查询条件解除当前状态,提交重新生成报表任务!']);
  718. }
  719. break;
  720. default:
  721. $list = Db::table('nw_channel')->alias('c1')
  722. ->group('p.gameid,c2.id')
  723. ->field('p.gameid,c2.id,c2.name,count(*) as total_cnt,sum(p.pay_amount) as total_amount,sum(p.pay_amount-p.coupon_amount) as actual_amount,sum(p.coupon_amount) as coupon_amount,g.name as gname')
  724. ->join('nw_channel c2', 'c1.parent_id = c2.id AND c2.LEVEL = 2 AND c2.id_path LIKE "' . $this->_channelIdPath . '%"')
  725. ->join('cy_pay p', 'c1.id = p.channel_id AND p.status = 1')
  726. ->join('cy_game g', 'p.gameid = g.id')
  727. ->where("g.is_default = 0")
  728. ->where(['c1.level' => 3, 'c1.id_path' => ['LIKE', $this->_channelIdPath . '%']])
  729. ->where($where)
  730. ->paginate(['list_rows' => $list_rows, 'page' => $page])->toArray();
  731. // $gameList = model('Common/Game')->getAllByCondition('id,name',['game_kind'=>1,'cooperation_status'=>['neq',0]],'','self');
  732. $gameList = $this->getTakingGameList();
  733. $channelList = Db::table('nw_channel')->field('id,name')->where(['level' => 2, 'id_path' => ['LIKE', '%,' . $this->_channelId . ',%']])->select();
  734. return json(['data' => $list, 'code' => 20000, 'msg' => '获取数据成功', 'gameList' => $gameList, 'channelList' => $channelList]);
  735. break;
  736. }
  737. }
  738. /************************************************联盟数据/报表**************************************/
  739. /**
  740. * 联盟流水数据列表(汇总)
  741. */
  742. public function getSumUnionList()
  743. {
  744. $download = input('download');
  745. if ($this->_channelLevel !== 0) {
  746. return json(['data' => '', 'code' => 20013, 'msg' => '只有联盟有查看权限!']);
  747. }
  748. $list_rows = input('pageSize', 10, 'intval');
  749. $page = input('page', 1, 'intval');
  750. $order_start_time = input('order_start_time', '', 'trim');
  751. $order_end_time = input('order_end_time', '', 'trim');
  752. $where = $this->_getCondition('chlid', 1);
  753. if (empty($order_start_time) || empty($order_end_time)) {
  754. return json(['data' => '', 'code' => 20040, 'msg' => '请选择开始日期和结束日期']);
  755. } else if (date('Y-m-d', strtotime($order_start_time)) <> $order_start_time || date('Y-m-d', strtotime($order_end_time)) <> $order_end_time) {
  756. return json(['data' => '', 'code' => 20040, 'msg' => '开始/结束日期输入不合法']);
  757. }
  758. switch ($download) {
  759. case '1':
  760. $time = $order_start_time . ' 00:00:00 - ' . $order_end_time . ' 23:59:59';
  761. $sql = Db::table('nw_channel')->alias('c1')
  762. ->group('p.gameid,c2.id')
  763. ->field('p.gameid,c2.id,c2.name,count(*) as total_cnt,sum(p.amount) as total_amount,g.name as gname,"' . $time . '" as time')
  764. ->join('nw_channel c2', 'c1.id_path like CONCAT("' . $this->_channelIdPath . '",c2.id,",%") AND c2.LEVEL = 1 AND c2.id_path LIKE "' . $this->_channelIdPath . '%"')
  765. ->join('cy_pay p', 'c1.id = p.channel_id AND p.status = 1')
  766. ->join('cy_game g', 'p.gameid = g.id')
  767. ->where("g.is_default = 0")
  768. ->where(['c1.level' => 3, 'c1.id_path' => ['LIKE', $this->_channelIdPath . '%']])
  769. ->where($where)
  770. ->fetchSql(true)
  771. ->select();
  772. // if ((new MakeReport())->addTask('guild.sumUnionExport', $sql, 'cps'.$this->_adminId)){
  773. if ((new MakeReportGo())->addTask('guild.sumUnionExport', $sql, 'cps' . $this->_adminId)) {
  774. return json(['data' => '', 'code' => 20000, 'msg' => '报表生成的任务已经提交, 报表生成完成后,会及时通知您,请耐心稍等']);
  775. } else {
  776. return json(['data' => '', 'code' => 20013, 'msg' => '报表生成任务不可重复提交,如遇到无法导出情况,建议修改查询条件解除当前状态,提交重新生成报表任务!']);
  777. }
  778. break;
  779. default:
  780. $list = Db::table('nw_channel')->alias('c1')
  781. ->group('p.gameid,c2.id')
  782. ->field('p.gameid,c2.id,c2.name,count(*) as total_cnt,sum(p.amount) as total_amount,g.name as gname')
  783. ->join('nw_channel c2', 'c1.id_path like CONCAT("' . $this->_channelIdPath . '",c2.id,",%") AND c2.LEVEL = 1 AND c2.id_path LIKE "' . $this->_channelIdPath . '%"')
  784. ->join('cy_pay p', 'c1.id = p.channel_id AND p.status = 1')
  785. ->join('cy_game g', 'p.gameid = g.id')
  786. ->where("g.is_default = 0")
  787. ->where(['c1.level' => 3, 'c1.id_path' => ['LIKE', $this->_channelIdPath . '%']])
  788. ->where($where)
  789. ->paginate(['list_rows' => $list_rows, 'page' => $page])->toArray();
  790. $total_amount = Db::table('nw_channel')->alias('c1')
  791. ->join('nw_channel c2', 'c1.id_path like CONCAT("' . $this->_channelIdPath . '",c2.id,",%") AND c2.LEVEL = 1 AND c2.id_path LIKE "' . $this->_channelIdPath . '%"')
  792. ->join('cy_pay p', 'c1.id = p.channel_id AND p.status = 1')
  793. ->join('cy_game g', 'p.gameid = g.id')
  794. ->where("g.is_default = 0")
  795. ->where(['c1.level' => 3, 'c1.id_path' => ['LIKE', $this->_channelIdPath . '%']])
  796. ->where($where)
  797. ->value('sum(p.amount)');
  798. // $gameList = model('Common/Game')->getAllByCondition('id,name',['game_kind'=>1,'cooperation_status'=>['neq',0]],'','self');
  799. $gameList = $this->getTakingGameList();
  800. $channelList = Db::table('nw_channel')->field('id,name')->where(['level' => 1, 'id_path' => ['LIKE', '%,' . $this->_channelId . ',%']])->select();
  801. return json(['data' => $list, 'code' => 20000, 'msg' => '获取数据成功', 'gameList' => $gameList, 'channelList' => $channelList, 'total_amount' => $total_amount]);
  802. break;
  803. }
  804. }
  805. /**
  806. * 联盟新增数据列表(汇总)
  807. */
  808. public function getAddUnionList()
  809. {
  810. $download = input('download', 0, 'intval');
  811. if ($this->_channelLevel !== 0) {
  812. return json(['data' => '', 'code' => 20013, 'msg' => '只有联盟有查看权限!']);
  813. }
  814. $list_rows = input('pageSize', 10);
  815. $page = input('page', 1);
  816. $reg_start_time = input('reg_start_time');
  817. $reg_end_time = input('reg_end_time');
  818. $where = $this->_getCondition('uniadd', 1);
  819. if (empty($reg_start_time) || empty($reg_end_time)) {
  820. return json(['data' => '', 'code' => 20040, 'msg' => '请选择开始日期和结束日期']);
  821. } else if (date('Y-m-d', strtotime($reg_start_time)) <> $reg_start_time || date('Y-m-d', strtotime($reg_end_time)) <> $reg_end_time) {
  822. return json(['data' => '', 'code' => 20040, 'msg' => '开始/结束日期输入不合法']);
  823. }
  824. if ($download) {
  825. $time = $reg_start_time . ' - ' . $reg_end_time;
  826. $sql = Db::name('nw_member_game_server')->alias('mgs')
  827. ->group('mgs.game_id,b.id')
  828. ->join('nw_channel c', 'mgs.channel_id=c.id')
  829. ->join('cy_game g', 'mgs.game_id = g.id')
  830. ->join('nw_channel b', 'c.id_path like CONCAT("' . $this->_channelIdPath . '",b.id,",%") AND b.LEVEL = 1 AND b.id_path LIKE "' . $this->_channelIdPath . '%"')
  831. ->field('mgs_id,b.id,b.name,count(*) AS total_cnt,g.NAME AS gname,"' . $time . '" as time')
  832. ->where(['c.level' => 3, 'c.id_path' => ['LIKE', $this->_channelIdPath . '%']])
  833. ->where("g.is_default = 0")
  834. ->where($where)
  835. ->order('mgs.mgs_id desc')
  836. ->fetchSql(true)
  837. ->select();
  838. // if ((new MakeReport())->addTask('guild.addUnionExport', $sql, 'cps'.$this->_adminId)){
  839. if ((new MakeReportGo())->addTask('guild.addUnionExport', $sql, 'cps' . $this->_adminId)) {
  840. return json(['data' => '', 'code' => 20000, 'msg' => '报表生成的任务已经提交, 报表生成完成后,会及时通知您,请耐心稍等']);
  841. } else {
  842. return json(['data' => '', 'code' => 20013, 'msg' => '报表生成任务不可重复提交,如遇到无法导出情况,建议修改查询条件解除当前状态,提交重新生成报表任务!']);
  843. }
  844. } else {
  845. $list = Db::name('nw_member_game_server')->alias('mgs')
  846. ->group('mgs.game_id,b.id')
  847. ->join('nw_channel c', 'mgs.channel_id=c.id')
  848. ->join('cy_game g', 'mgs.game_id = g.id')
  849. ->join('nw_channel b', 'c.id_path like CONCAT("' . $this->_channelIdPath . '",b.id,",%") AND b.LEVEL = 1 AND b.id_path LIKE "' . $this->_channelIdPath . '%"')
  850. ->field('mgs_id,b.id,b.name,count(*) AS total_cnt,g.NAME AS gname')
  851. ->where(['c.level' => 3, 'c.id_path' => ['LIKE', $this->_channelIdPath . '%']])
  852. ->where("g.is_default = 0")
  853. ->where($where)
  854. ->order('mgs.mgs_id desc')
  855. ->paginate(['list_rows' => $list_rows, 'page' => $page])->toArray();
  856. // $gameList = model('Common/Game')->getAllByCondition('id,name',['game_kind'=>1,'cooperation_status'=>['neq',0]],'','self');
  857. $gameList = $this->getTakingGameList();
  858. $channelList = Db::table('nw_channel')->field('id,name')->where(['level' => 1, 'id_path' => ['LIKE', '%,' . $this->_channelId . ',%']])->select();
  859. return json(['data' => $list, 'code' => 20000, 'msg' => '获取数据成功', 'gameList' => $gameList, 'channelList' => $channelList]);
  860. }
  861. }
  862. /************************************************end**************************************/
  863. /**
  864. * 区服数据列表(汇总)
  865. */
  866. public function getSumServerList()
  867. {
  868. $forbid_channel_ids = Db::table("nw_channel_view_limit")->column("channel_id");
  869. if (in_array($this->_channelId, $forbid_channel_ids)) {
  870. return json(['data' => '', 'code' => 10032, 'msg' => '暂无权限查看区服数据']);
  871. }
  872. $list_rows = input('pageSize', 10);
  873. $page = input('page', 1);
  874. $gameid = input('gameid', 0, 'intval');//游戏id
  875. $serverid = input('serverid');//区服id
  876. $time_start = input('time_start', '', 'trim');//时间起始
  877. $time_end = input('time_end', '', 'trim');//时间结束
  878. $where = [];
  879. $where['g.game_kind'] = 1;
  880. if (!empty($gameid)) {
  881. if (in_array($gameid, model('game')->getTakingGame($this->_channelId))) {
  882. $where['sever.game_id'] = $gameid;
  883. } else {
  884. return json(['data' => '', 'code' => 20000, 'msg' => '获取数据成功']);
  885. }
  886. } else {
  887. $where['sever.game_id'] = ['in', model('game')->getTakingGame($this->_channelId)];
  888. }
  889. if (!empty($serverid)) {
  890. $where['sever.serverid'] = $serverid;
  891. }
  892. if (!empty($time_start) && !empty($time_end)) {
  893. $where['sever.create_time'] = ['BETWEEN', [strtotime($time_start), strtotime($time_end)]];
  894. }
  895. $list = Db::table('nw_game_server')->alias('sever')
  896. ->field('sever.game_id,sever.serverid,count( DISTINCT role.member_id ) AS reg_count,g.name as gamename,sever.servername,role.channel_id')
  897. ->group('sever.game_id,sever.serverid')
  898. ->join('nw_member_game_server role', 'sever.game_id = role.game_id AND sever.serverid = role.serverid')
  899. ->join('cy_game g', 'sever.game_id = g.id')
  900. ->join('nw_channel channel', 'channel.id = role.channel_id AND (channel.id=' . $this->_channelId . ' or channel.id_path like "' . $this->_channelIdPath . '%")')
  901. ->where($where)
  902. ->where("g.is_default = 0")
  903. ->paginate(['list_rows' => $list_rows, 'page' => $page])->toArray();
  904. foreach ($list['data'] as $key => $value) {
  905. $res = $this->getOtherItem($value['serverid'], $value['game_id'], $time_start, $time_end);
  906. $list['data'][$key]['ip_cnt'] = $res['ip_cnt']['ip'];
  907. $list['data'][$key]['im_cnt'] = $res['im_cnt']['im'];
  908. $list['data'][$key]['money'] = $res['pay_cnt']['money'];
  909. }
  910. // $gameList = model('Common/Game')->getAllByCondition('id,name',['game_kind'=>1,'cooperation_status'=>['neq',0]],'','self');
  911. $gameList = $this->getTakingGameList();
  912. // $channelList = Db::table('nw_channel')->field('id,name')->where(['level'=>3,'id_path'=>['LIKE', $this->_channelId . ',%']])->select();
  913. return json(['data' => $list, 'code' => 20000, 'msg' => '获取数据成功', 'gameList' => $gameList]);
  914. }
  915. /**
  916. * 游戏角色列表
  917. * @return [type] [description]
  918. */
  919. public function getRoleList()
  920. {
  921. $list_rows = input('pageSize', 10);
  922. $page = input('page', 1);
  923. $gameid = input('gameid', 0, 'intval');//游戏id
  924. // $download = input('download', 1, 'intval');
  925. $download = 1;
  926. $where = [];
  927. if (empty($gameid)) {
  928. return json(['data' => [], 'code' => 10001, 'msg' => '请选择游戏']);
  929. } else {
  930. if (in_array($gameid, model('game')->getTakingGame($this->_channelId))) {
  931. $where['game.id'] = $gameid;
  932. } else {
  933. if ($download) {
  934. return json(['data' => '', 'code' => 20013, 'msg' => '没有数据可提供下载']);
  935. } else {
  936. return json(['data' => '', 'code' => 20000, 'msg' => '获取数据成功']);
  937. }
  938. }
  939. }
  940. if (input('username') <> '') {
  941. $where['user.username'] = ['LIKE', input('username') . '%'];
  942. }
  943. if (input('rolename') <> '') {
  944. $where['info.rolename'] = ['LIKE', input('rolename') . '%'];
  945. }
  946. if (!$download) {
  947. $sql = Db::table('cy_role_info')->alias('info')
  948. ->join('cy_members user', 'info.userid = user.id')
  949. ->join('cy_game game', 'game.id = info.gameid')
  950. ->join('cy_member_channel_game_rel mcgr', 'info.userid = mcgr.member_id and info.gameid=mcgr.game_id')
  951. ->join('nw_channel channel', 'mcgr.channel_id = channel.id AND (channel.id=' . $this->_channelId . ' or channel.id_path like "' . $this->_channelIdPath . '%")')
  952. ->field(['game.name', 'user.username', 'info.serverid', 'info.servername', 'info.roleid', 'info.rolename', 'info.rolelevel', 'info.create_time'])
  953. ->where($where)
  954. ->fetchSql(1)
  955. ->order('info.id', 'desc')->select();
  956. // if ((new MakeReport())->addTask('guild.getRoleExport', $sql, 'cps'.$this->_adminId)){
  957. if ((new MakeReportGo())->addTask('guild.getRoleExport', $sql, 'cps' . $this->_adminId)) {
  958. return json(['data' => '', 'code' => 20000, 'msg' => '报表生成的任务已经提交, 报表生成完成后,会及时通知您,请耐心稍等']);
  959. } else {
  960. return json(['data' => '', 'code' => 20013, 'msg' => '报表生成任务不可重复提交,如遇到无法导出情况,建议修改查询条件解除当前状态,提交重新生成报表任务!']);
  961. }
  962. } else {
  963. $roleList = Db::table('cy_role_info')->alias('info')
  964. ->join('cy_members user', 'info.userid = user.id')
  965. ->join('cy_game game', 'game.id = info.gameid')
  966. ->join('cy_member_channel_game_rel mcgr', 'info.userid = mcgr.member_id and info.gameid=mcgr.game_id')
  967. ->join('nw_channel channel', 'mcgr.channel_id = channel.id AND (channel.id=' . $this->_channelId . ' or channel.id_path like "' . $this->_channelIdPath . '%")')
  968. ->field(['game.name', 'user.username', 'info.serverid', 'info.servername', 'info.roleid', 'info.rolename', 'info.rolelevel', ' FROM_UNIXTIME(info.create_time) AS create_time'])
  969. ->where($where)
  970. ->order('info.id', 'desc')
  971. ->paginate(['list_rows' => $list_rows, 'page' => $page])->toArray();
  972. return json(['data' => $roleList, 'code' => 20000, 'msg' => '获取数据成功']);
  973. }
  974. }
  975. /**
  976. * Undocumented function
  977. *
  978. * @Author yxon 564556921@qq.com
  979. * @DateTime 2020-11-30
  980. * @return void
  981. */
  982. public function gameList()
  983. {
  984. // $gameList = model('Common/Game')->getAllByCondition('id,name',['game_kind'=>1,'cooperation_status'=>['neq',0]],'','self');
  985. $gameList = $this->getTakingGameList($this->_channelId);
  986. return json(['gameList' => $gameList, 'code' => 20000, 'msg' => '获取数据成功',]);
  987. }
  988. /**
  989. * [getOtherItem description]
  990. * @param [type] $severid [description]
  991. * @return [type] [description]
  992. */
  993. protected function getOtherItem($severid, $gameid, $time_start = null, $time_end = null)
  994. {
  995. $where = [];
  996. if (!empty($time_start) && !empty($time_end)) {
  997. $where['server.create_time'] = ['BETWEEN', [strtotime($time_start), strtotime($time_end)]];
  998. }
  999. $out = [];
  1000. $out['ip_cnt'] = Db::name('nw_game_server_ip')->alias('server')//ip数量统计
  1001. ->field('count(DISTINCT ip) as ip')
  1002. ->join('nw_channel channel', 'channel.id = server.channel_id AND (channel.id=' . $this->_channelId . ' or channel.id_path like "' . $this->_channelIdPath . '%")')
  1003. ->where($where)->where(['serverid' => $severid, 'game_id' => $gameid])
  1004. ->find();
  1005. $out['im_cnt'] = Db::name('nw_game_server_imeil')->alias('server')//im数量统计
  1006. ->field('count(DISTINCT imeil) as im')
  1007. ->join('nw_channel channel', 'channel.id = server.channel_id AND (channel.id=' . $this->_channelId . ' or channel.id_path like "' . $this->_channelIdPath . '%")')
  1008. ->where($where)->where(['serverid' => $severid, 'game_id' => $gameid])
  1009. ->find();
  1010. if (!empty($time_start) && !empty($time_end)) {
  1011. unset($where['server.create_time']);
  1012. $where['pay.create_time'] = ['BETWEEN', [strtotime($time_start), strtotime($time_end)]];
  1013. }
  1014. $out['pay_cnt'] = Db::name('cy_pay')->alias('pay')
  1015. ->field('COALESCE(sum(pay.pay_amount),0) as money')
  1016. ->join('nw_channel channel', 'channel.id = pay.channel_id AND (channel.id=' . $this->_channelId . ' or channel.id_path like "' . $this->_channelIdPath . '%")')
  1017. ->where($where)->where(['serverid' => $severid, 'gameid' => $gameid, 'pay.status' => 1])
  1018. ->find();
  1019. return $out;
  1020. }
  1021. // 公共搜索条件
  1022. protected function _getCondition($action = null, $game_kind = 1)
  1023. {
  1024. $gameid = input('gameid', 0, 'intval');//游戏id
  1025. $channelid = input('channelid', 0, 'intval');//推广员id
  1026. $username = input('username', '', 'trim');//账号
  1027. $pay_tpye = input('pay_tpye');//支付类型
  1028. $orderid = input('orderid');//订单id
  1029. $serverid = input('serverid');//区服id
  1030. $status = input('status');//订单id
  1031. $rolename = input('rolename', '', 'trim');//账号
  1032. $login_start_time = input('login_start_time', '', 'trim');//登录时间起始
  1033. $login_end_time = input('login_end_time', '', 'trim');//登录时间结束
  1034. $reg_start_time = input('reg_start_time', '', 'trim');//注册时间起始
  1035. $reg_end_time = input('reg_end_time', '', 'trim');//注册时间结束
  1036. $order_start_time = input('order_start_time', '', 'trim');//订单创建时间开始
  1037. $order_end_time = input('order_end_time', '', 'trim');//订单创建时间结束
  1038. $condition = [];
  1039. if ($action == 'members') {
  1040. if (input('username') <> '') {
  1041. $condition['members.username'] = ['LIKE', '%' . $username . '%'];
  1042. }
  1043. $condition['game.game_kind'] = $game_kind;
  1044. if (!empty($channelid)) {
  1045. $condition['mgs.channel_id'] = $channelid;
  1046. }
  1047. if (!empty($serverid)) {
  1048. $condition['mgs.serverid'] = $serverid;
  1049. }
  1050. if (input('rolename') <> '') {
  1051. $condition['mgs.rolename'] = ['LIKE', '%' . $rolename . '%'];;
  1052. }
  1053. if (!empty($gameid)) {
  1054. $condition['mgs.game_id'] = $gameid;
  1055. }
  1056. if (!empty($status)) {
  1057. $condition['mgs.status'] = $status;
  1058. }
  1059. if (!empty($login_start_time) && !empty($login_end_time)) {
  1060. $condition['mgs.update_time'] = ['BETWEEN', [strtotime($login_start_time), strtotime($login_end_time . ' 23:59:59')]];
  1061. }
  1062. if (!empty($reg_start_time) && !empty($reg_end_time)) {
  1063. $condition['members.reg_time'] = ['BETWEEN', [strtotime($reg_start_time), strtotime($reg_end_time . ' 23:59:59')]];
  1064. }
  1065. } else if ($action == 'pay') {
  1066. if (request()->action() == "getSumOrderList") {
  1067. $condition['pay.status'] = 1;
  1068. }
  1069. if (!empty($gameid)) {
  1070. $condition['pay.gameid'] = $gameid;
  1071. }
  1072. $condition['game.game_kind'] = $game_kind;
  1073. if (!empty($username) || $username === '0') {
  1074. $condition['pay.username'] = ['LIKE', '%' . $username . '%'];
  1075. }
  1076. if (!empty($serverid)) {
  1077. $condition['pay.serverid'] = $serverid;
  1078. }
  1079. if (!empty($pay_tpye)) {
  1080. if ($pay_tpye == 'wx') {
  1081. $condition['pay.paytype'] = ['IN', ['wxpay-h5', 'ybzf_wxmp_h5', 'coin-wxpay-h5', 'coin-ybzf_wxmp_h5', 'mix-wxpay-h5', 'mix-ybzf_wxmp_h5']];
  1082. } else if ($pay_tpye == 'zfb') {
  1083. $condition['pay.paytype'] = ['IN', ['zfb', 'old-zfb-wap', 'coin-zfb', 'old-zfb-wap', 'mix-zfb', 'mix-old-zfb-wap']];
  1084. } else if ($pay_tpye == 'coin'){
  1085. $condition['pay.paytype'] = ['IN', ['coinpay', 'coin-zfb', 'coin-old-zfb-wap', 'coin-wxpay-h5', 'coin-ybzf_wxmp_h5']];
  1086. } else if ($pay_tpye == 'coupon'){
  1087. $condition['pay.paytype'] = ['IN', ['coupon', 'mix-zfb', 'mix-old-zfb-wap', 'mix-wxpay-h5', 'mix-ybzf_wxmp_h5']];
  1088. }
  1089. }
  1090. if (!empty($channelid)) {
  1091. $condition['pay.channel_id'] = $channelid;
  1092. }
  1093. if (!empty($orderid)) {
  1094. $condition['pay.orderid'] = ['LIKE', '%' . $orderid . '%'];
  1095. }
  1096. if (!empty($status)) {
  1097. if ($status == '2') {
  1098. //$condition['pay.paytype'] = ['IN',['wxpay-h5','wxpay-h5-mihua','wxpay-h5-kj','wxpay-h5-sumpay']];
  1099. $condition['pay.status'] = ['IN', ['0']];
  1100. } else if ($status == '1') {
  1101. //$condition['pay.paytype'] = ['IN',['zfb','zfb-h5-mihua','zfb-h5-kj']];
  1102. $condition['pay.status'] = ['IN', ['1']];
  1103. } else {
  1104. $condition['pay.status'] = ['IN', ['0', '1', '2']];
  1105. }
  1106. }
  1107. if (!empty($order_start_time) && !empty($order_end_time)) {
  1108. $condition['pay.create_time'] = ['BETWEEN', [strtotime($order_start_time), strtotime($order_end_time . ' 23:59:59')]];
  1109. }
  1110. } else if ($action == 'chlid') {
  1111. if (!empty($gameid)) {
  1112. $condition['g.id'] = $gameid;
  1113. }
  1114. $condition['g.game_kind'] = $game_kind;
  1115. if (!empty($channelid)) {
  1116. $condition['c2.id'] = $channelid;
  1117. }
  1118. if (!empty($order_start_time) && !empty($order_end_time)) {
  1119. $condition['p.create_time'] = ['BETWEEN', [strtotime($order_start_time), strtotime($order_end_time . ' 23:59:59')]];
  1120. }
  1121. } else if ($action == 'add') {
  1122. if (!empty($gameid)) {
  1123. $condition['g.id'] = $gameid;
  1124. }
  1125. $condition['g.game_kind'] = $game_kind;
  1126. if (!empty($channelid)) {
  1127. $condition['b.id'] = $channelid;
  1128. }
  1129. if (!empty($reg_start_time) && !empty($reg_end_time)) {
  1130. $condition['member.mcgr_createtime'] = ['BETWEEN', [strtotime($reg_start_time), strtotime($reg_end_time . ' 23:59:59')]];
  1131. }
  1132. } else if ($action == 'reglist') {
  1133. if (!empty($gameid)) {
  1134. $condition['gameid'] = $gameid;
  1135. }
  1136. if (!empty($reg_start_time) && !empty($reg_end_time)) {
  1137. $condition['reg_time'] = ['BETWEEN', [strtotime($reg_start_time), strtotime($reg_end_time . ' 23:59:59')]];
  1138. }
  1139. } else if ($action == 'uniadd') {
  1140. if (!empty($gameid)) {
  1141. $condition['g.id'] = $gameid;
  1142. }
  1143. $condition['g.game_kind'] = $game_kind;
  1144. if (!empty($channelid)) {
  1145. $condition['b.id'] = $channelid;
  1146. }
  1147. if (!empty($reg_start_time) && !empty($reg_end_time)) {
  1148. $condition['mgs.create_time'] = ['BETWEEN', [strtotime($reg_start_time), strtotime($reg_end_time . ' 23:59:59')]];
  1149. }
  1150. }
  1151. return $condition;
  1152. }
  1153. public function getTakingGameList()
  1154. {
  1155. return model('Common/Game')->getAllByCondition('id,name', ['game_kind' => 1, 'cooperation_status' => ['neq', 0], 'id' => ['in', model('game')->getTakingGame($this->_channelId)]], '', 'self');
  1156. }
  1157. }