MemberCoinPay.php 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <?php
  2. /**
  3. * 前台注册用户管理控制器
  4. */
  5. namespace app\admin\controller;
  6. use app\common\library\MakeReportGo;
  7. use app\common\model\Members as MembersModel;
  8. class MemberCoinPay extends Admin
  9. {
  10. protected $membersModel;
  11. protected $where;
  12. protected $start_time;
  13. protected $end_time;
  14. protected $pay_haiwai = ['airwallex','airwallexh5'];
  15. /**
  16. * 不进行父类的登录验证,所以增加构造方法重写了父类的初始化方法
  17. */
  18. protected function _initialize()
  19. {
  20. parent::_initialize();
  21. $this->membersModel = new MembersModel;
  22. $this->where = [];
  23. }
  24. /**
  25. * 账户充值明细列表
  26. */
  27. public function getList()
  28. {
  29. $where = $this->_getDetListCondition();
  30. // var_dump($where);
  31. if (request()->isAjax() && input('download')) {
  32. $sql = model("MemberCoinPay")->alias('m')
  33. ->field("m.id,m.userid,cm.username,m.amount,m.real_amount,m.orderid,m.create_time,m.pay_time,m.paytype,m.status,m.callback_order")
  34. ->join('cy_members cm','cm.id=m.userid','left')
  35. ->where($where)
  36. ->whereNotIn('paytype',$this->pay_haiwai)
  37. ->order('m.create_time desc')
  38. ->fetchSql(true)->select();
  39. // echo $sql;
  40. if((new MakeReportGo())->addTask('admin.memberCoinPayDetailList',$sql,session_id())){
  41. $this->success('报表生成的任务已经提交, 报表生成完成后,会及时通知您,请耐心稍等');
  42. }
  43. else{
  44. $this->error('报表生成任务不可重复提交,如遇到无法导出情况,建议修改查询条件解除当前状态,提交重新生成报表任务!');
  45. }
  46. }
  47. $list = model("MemberCoinPay")->alias('m')
  48. ->field("m.id,m.userid,cm.username,m.amount,m.real_amount,m.orderid,m.create_time,m.paytype,m.status")
  49. ->join('cy_members cm','cm.id=m.userid','left')
  50. ->where($where)
  51. ->whereNotIn('paytype',$this->pay_haiwai)
  52. ->order('m.create_time desc')
  53. ->paginate(10, false, ['query' => input('get.')]);
  54. $data = $list->toArray()['data'];
  55. $totalAmount = $todayTotalAmount = $lastDayTotalAmount = 0;
  56. if ($list->total()>0) {
  57. //支付成功 或者支付查询条件未选择时
  58. if(input('status')==1 || input('status')==''){
  59. //充值完成总金额
  60. $totalAmount = model("MemberCoinPay")->alias('m')
  61. ->join('cy_members cm','cm.id=m.userid','left')
  62. ->field('sum(m.amount) as total_amount')->where($where)
  63. ->whereNotIn('paytype',$this->pay_haiwai)
  64. ->where('status=1')->find()['total_amount'];
  65. }
  66. }
  67. //今日充值
  68. $where = array();
  69. $where['m.create_time'] = [
  70. ['>=', strtotime(date('Y-m-d'))],
  71. ['<=', strtotime(date('Y-m-d') . ' 23:59:59')],
  72. ];
  73. $where['status'] = 1;
  74. $todayTotalAmount = floatval(model("MemberCoinPay")->alias('m')
  75. ->join('cy_members cm','cm.id=m.userid','left')
  76. ->field('sum(m.amount) as total_amount')->where($where)
  77. ->whereNotIn('paytype',$this->pay_haiwai)
  78. ->where('status=1')->find()['total_amount']);
  79. $where = array();
  80. $where['m.create_time'] = [
  81. ['>=', strtotime(date("Y-m-d",strtotime("-1 day")))],
  82. ['<', strtotime(date('Y-m-d'))],
  83. ];
  84. $where['status'] = 1;
  85. $lastDayTotalAmount = floatval(model("MemberCoinPay")->alias('m')
  86. ->join('cy_members cm','cm.id=m.userid','left')
  87. ->field('sum(m.amount) as total_amount')->where($where)
  88. ->whereNotIn('paytype',$this->pay_haiwai)
  89. ->where('status=1')->find()['total_amount']);
  90. $this->assign('paytype', config('paytype'));
  91. $this->assign('list', $data);
  92. $this->assign('total', $list->total()); //总条数
  93. $this->assign('page', $list->render());
  94. $this->assign('start_time', input('request.start_time', '', 'trim'));
  95. $this->assign('end_time', input('request.end_time', '', 'trim'));
  96. $this->assign('totalAmount', $totalAmount);
  97. $this->assign('todayTotalAmount', $todayTotalAmount);
  98. $this->assign('lastDayTotalAmount', $lastDayTotalAmount);
  99. return $this->fetch('get_list');
  100. }
  101. /**
  102. * 账户变动明细 条件查询
  103. * @return array
  104. */
  105. protected function _getDetListCondition()
  106. {
  107. $start_time = input('request.start_time', '', 'trim');
  108. $end_time = input('request.end_time', '', 'trim');
  109. $username = input('request.username', '', 'trim');
  110. $userid = input('request.userid', 0, 'intval');
  111. $status = input('status', '', 'trim');
  112. $orderid = input('orderid', '', 'trim');
  113. $paytype = input('paytype', '', 'trim');
  114. $where = array();
  115. // 获取查询日期
  116. if (!empty($start_time) || !empty($end_time)){
  117. $where['m.create_time'] = getTimeCondition($start_time,$end_time,false);
  118. }
  119. //用户ID
  120. if ($userid) {
  121. $where['m.userid'] = $userid;
  122. }
  123. //用户名
  124. if ($username != '') {
  125. $where['cm.username'] = $username;
  126. }
  127. if (!empty($orderid)) {
  128. $where['m.orderid'] = $orderid;
  129. }
  130. if (!empty($paytype)) {
  131. $where['m.paytype'] = $paytype;
  132. }
  133. if (is_numeric($status)) {
  134. $where['m.status'] = (int)$status;
  135. }
  136. return $where;
  137. }
  138. /**
  139. * 充值记录管理页-查看玩家账号
  140. */
  141. public function showUsername()
  142. {
  143. $userid = input('userid');
  144. if(empty($userid)){
  145. $this->error('玩家ID不能为空');
  146. }
  147. $username= model('Common/Members')->where(['id'=>$userid])->value('username');
  148. if(!empty($username)){
  149. //充值记录管理页
  150. $this->insertLog($this->current_node,'查看账号:'.$username,82);
  151. $this->result($username,1);
  152. }else{
  153. $this->error('玩家信息不存在');
  154. }
  155. }
  156. }