ChannelTradeCoin.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. /**
  3. * 交易记录接口控制器
  4. *
  5. */
  6. namespace app\guildapi\controller;
  7. use app\guildapi\controller\Guild;
  8. use think\Db;
  9. use think\Config;
  10. use app\common\model\Setting;
  11. use think\Exception;
  12. class ChannelTradeCoin extends Guild {
  13. protected $nowTime;
  14. /**
  15. * 不进行父类的登录验证,所以增加构造方法重写了父类的初始化方法
  16. */
  17. public function _initialize()
  18. {
  19. parent::_initialize();
  20. $this->nowTime = NOW_TIMESTAMP;
  21. }
  22. /**
  23. * 我的交易记录列表
  24. * @return [type] [description]
  25. */
  26. public function index()
  27. {
  28. //判断当前账号是否有此功能
  29. if(!in_array($this->_channelLevel,[1,2])){
  30. $this->jsonResult('', 0, '您无权限使用该功能');
  31. }
  32. $list_rows = $this->input('list_rows',10);
  33. $page = $this->input('page',1);
  34. $type = $this->input('type','0','intval'); //类型:1(转账支出),2(转账收入),3(直充),4(充值收入),5(充值支出),6(币追回),7(结算充值),8(结算收入),9(提现),10(提现打回)
  35. $account = $this->input('account','','trim'); //收入账号
  36. $apply_begin_time = $this->input('apply_begin_time','','trim');
  37. $apply_end_time = $this->input('apply_end_time','','trim');
  38. $finish_begin_time = $this->input('finish_begin_time','','trim');
  39. $finish_end_time = $this->input('finish_end_time','','trim');
  40. $condition = [];
  41. if(!in_array($type,array(1,2,3,4,5,6,7,8,9,10))){
  42. $this->jsonResult('', 0, '请选择正确的交易类型');
  43. }
  44. else{
  45. $condition['a.type'] = $type;
  46. $condition['a.account_type'] = '3'; //结算币账户
  47. }
  48. if($account){
  49. $condition['a.channel_name'] = $account;
  50. }
  51. //到账开始时间和结束时间不为空时
  52. if ($finish_begin_time != '' && $finish_end_time != '') {
  53. $condition['a.create_time'] = [
  54. ['>=', strtotime($finish_begin_time)],
  55. ['<=', strtotime($finish_end_time . ' 23:59:59')],
  56. ];
  57. } //开始时间不为空时
  58. elseif ($finish_begin_time != '') {
  59. $condition['a.create_time'] = ['>=', strtotime($finish_begin_time)];
  60. } //结束时间不为空时
  61. elseif ($finish_end_time != '') {
  62. $condition['a.create_time'] = ['<=', strtotime($finish_end_time . ' 23:59:59')];
  63. }
  64. // var_dump($condition);
  65. $rechargeList = model('ChannelAccountDet')->alias('a')
  66. ->where($condition)
  67. ->paginate(['list_rows'=>$list_rows,'page'=>$page])
  68. ->toArray();
  69. // echo model('ChannelRecharge')->getLastSql()."-----lastsql------<br>";
  70. $this->jsonResult($rechargeList, 20000, '获取列表成功');
  71. }
  72. }