ChannelAccountDet.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <?php
  2. /**
  3. * 前台注册用户管理控制器
  4. */
  5. namespace app\admin\controller;
  6. use app\common\model\Members as MembersModel;
  7. use app\common\model\MembersTwo;
  8. use think\Db;
  9. use app\common\logic\Member as MemberService;
  10. use app\common\library\MakeReport;
  11. use app\common\library\FileUpload;
  12. use think\Exception;
  13. class ChannelAccountDet extends Admin
  14. {
  15. protected $membersModel;
  16. protected $where;
  17. protected $start_time;
  18. protected $end_time;
  19. /**
  20. * 不进行父类的登录验证,所以增加构造方法重写了父类的初始化方法
  21. */
  22. protected function _initialize()
  23. {
  24. parent::_initialize();
  25. $this->membersModel = new MembersModel;
  26. $this->gameList = $gameList = model('Common/Game')->getAllByCondition('id,name');
  27. $this->selfGameList = $selfGameList = model('Common/Game')->getAllByCondition('id,name', [],'','self');
  28. $this->where = [];
  29. }
  30. /**
  31. * 渠道账户明细列表
  32. */
  33. public function detList()
  34. {
  35. $where = $this->_getDetListCondition();
  36. //var_dump($where);
  37. $list = model("ChannelAccountDet")->alias('d')
  38. ->join('nw_channel channel', 'd.channel_id = channel.id','left')
  39. ->field("d.id,d.channel_id,d.channel_name,d.change_amount,d.change_amount,d.account_type,d.type,d.out_orderid,d.create_time,channel.level,channel.status,channel.amount,channel.js_amount")
  40. ->where($where)
  41. ->order('d.create_time desc')
  42. ->paginate(10, false, ['query' => input('get.')]);
  43. $data = $list->toArray()['data'];
  44. $this->assign('list', $data);
  45. $this->assign('total', $list->total()); //总条数
  46. $this->assign('page', $list->render());
  47. $this->assign('start_time', $this->start_time);
  48. $this->assign('end_time', $this->end_time);
  49. return $this->fetch('det_list');
  50. }
  51. /**
  52. * 账户变动明细 条件查询
  53. * @return array
  54. */
  55. protected function _getDetListCondition()
  56. {
  57. $start_time = input('request.start_time', '', 'trim');
  58. $end_time = input('request.end_time', '', 'trim');
  59. $channel_name = input('request.channel_name', '', 'trim');
  60. $channel_id = input('request.channel_id', 0, 'intval');
  61. $type = input('request.type', '', 'trim');
  62. $account_type = input('request.account_type', '', 'trim');
  63. $out_orderid = input('request.out_orderid', '', 'trim');
  64. $where = array();
  65. // 获取查询日期
  66. if (!empty($start_time) || !empty($end_time)){
  67. $where['d.create_time'] = $this->getTimeCondition($start_time,$end_time,false);
  68. }
  69. //渠道ID
  70. if ($channel_id) {
  71. $where['d.channel_id'] = $channel_id;
  72. }
  73. //渠道名称
  74. if ($channel_name != '') {
  75. $where['d.channel_name'] = $channel_name;
  76. }
  77. //账户类型
  78. if ($account_type != '') {
  79. $where['d.account_type'] = $account_type;
  80. }
  81. //类型
  82. if ($type != '') {
  83. $where['d.type'] = $type;
  84. }
  85. //游戏ID
  86. if ($out_orderid != '') {
  87. $where['d.out_orderid'] = $out_orderid;
  88. }
  89. return $where;
  90. }
  91. /**
  92. * 获取日期查询条件
  93. * @param int $start_time 开始时间
  94. * @param int $end_time 结束时间
  95. * @param bool $isdefault 是否默认今天日期
  96. * @return
  97. */
  98. private function getTimeCondition($start_time,$end_time,$isdefault = true)
  99. {
  100. $this->start_time = $start_time;
  101. $this->end_time = $end_time;
  102. $time = [];
  103. //开始时间和结束时间不为空时
  104. if ($start_time != '' && $end_time != '') {
  105. $time = [
  106. ['>=', strtotime($start_time)],
  107. ['<=', strtotime($end_time . ' 23:59:59')],
  108. ];
  109. } //开始时间不为空时
  110. elseif ($start_time != '') {
  111. $time = ['>=', strtotime($start_time)];
  112. } //结束时间不为空时
  113. elseif ($end_time != '') {
  114. $time = ['<=', strtotime($end_time . ' 23:59:59')];
  115. } else {
  116. if($isdefault){
  117. $this->start_time = $this->end_time = date('Y-m-d', time());
  118. $time = [
  119. ['>=', strtotime($this->start_time)],
  120. ['<=', strtotime($this->end_time . ' 23:59:59')],
  121. ];
  122. }
  123. }
  124. return $time;
  125. }
  126. }