RechargeLists.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeadmin快速开发前后端分离管理后台(PHP版)
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 开源版本可自由商用,可去除界面版权logo
  7. // | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
  8. // | github下载:https://github.com/likeshop-github/likeadmin
  9. // | 访问官网:https://www.likeadmin.cn
  10. // | likeadmin团队 版权所有 拥有最终解释权
  11. // +----------------------------------------------------------------------
  12. // | author: likeadminTeam
  13. // +----------------------------------------------------------------------
  14. namespace app\adminapi\lists\recharge;
  15. use app\adminapi\lists\BaseAdminDataLists;
  16. use app\common\enum\PayEnum;
  17. use app\common\lists\ListsExcelInterface;
  18. use app\common\lists\ListsSearchInterface;
  19. use app\common\model\recharge\RechargeOrder;
  20. use app\common\service\FileService;
  21. /**
  22. * 充值记录列表
  23. * Class RecharLists
  24. * @package app\adminapi\lists
  25. */
  26. class RechargeLists extends BaseAdminDataLists implements ListsSearchInterface, ListsExcelInterface
  27. {
  28. /**
  29. * @notes 导出字段
  30. * @return string[]
  31. * @author 段誉
  32. * @date 2023/2/24 16:07
  33. */
  34. public function setExcelFields(): array
  35. {
  36. return [
  37. 'sn' => '充值单号',
  38. 'nickname' => '用户昵称',
  39. 'order_amount' => '充值金额',
  40. 'pay_way_text' => '支付方式',
  41. 'pay_status_text' => '支付状态',
  42. 'pay_time' => '支付时间',
  43. 'create_time' => '下单时间',
  44. ];
  45. }
  46. /**
  47. * @notes 导出表名
  48. * @return string
  49. * @author 段誉
  50. * @date 2023/2/24 16:07
  51. */
  52. public function setFileName(): string
  53. {
  54. return '充值记录';
  55. }
  56. /**
  57. * @notes 搜索条件
  58. * @return \string[][]
  59. * @author 段誉
  60. * @date 2023/2/24 16:08
  61. */
  62. public function setSearch(): array
  63. {
  64. return [
  65. '=' => ['ro.sn', 'ro.pay_way', 'ro.pay_status'],
  66. ];
  67. }
  68. /**
  69. * @notes 搜索条件
  70. * @author 段誉
  71. * @date 2023/2/24 16:08
  72. */
  73. public function queryWhere()
  74. {
  75. $where = [];
  76. // 用户编号
  77. if (!empty($this->params['user_info'])) {
  78. $where[] = ['u.sn|u.nickname|u.mobile|u.account', 'like', '%' . $this->params['user_info'] . '%'];
  79. }
  80. // 下单时间
  81. if (!empty($this->params['start_time']) && !empty($this->params['end_time'])) {
  82. $time = [strtotime($this->params['start_time']), strtotime($this->params['end_time'])];
  83. $where[] = ['ro.create_time', 'between', $time];
  84. }
  85. return $where;
  86. }
  87. /**
  88. * @notes 获取列表
  89. * @return array
  90. * @author 段誉
  91. * @date 2023/2/24 16:13
  92. */
  93. public function lists(): array
  94. {
  95. $field = 'ro.id,ro.sn,ro.order_amount,ro.pay_way,ro.pay_time,ro.pay_status,ro.create_time,ro.refund_status';
  96. $field .= ',u.avatar,u.nickname,u.account';
  97. $lists = RechargeOrder::alias('ro')
  98. ->join('user u', 'u.id = ro.user_id')
  99. ->field($field)
  100. ->where($this->queryWhere())
  101. ->where($this->searchWhere)
  102. ->order('ro.id', 'desc')
  103. ->limit($this->limitOffset, $this->limitLength)
  104. ->append(['pay_status_text', 'pay_way_text'])
  105. ->select()
  106. ->toArray();
  107. foreach ($lists as &$item) {
  108. $item['avatar'] = FileService::getFileUrl($item['avatar']);
  109. $item['pay_time'] = empty($item['pay_time']) ? '' : date('Y-m-d H:i:s', $item['pay_time']);
  110. }
  111. return $lists;
  112. }
  113. /**
  114. * @notes 获取数量
  115. * @return int
  116. * @author 段誉
  117. * @date 2023/2/24 16:13
  118. */
  119. public function count(): int
  120. {
  121. return RechargeOrder::alias('ro')
  122. ->join('user u', 'u.id = ro.user_id')
  123. ->where($this->queryWhere())
  124. ->where($this->searchWhere)
  125. ->count();
  126. }
  127. }