WithdrawLists.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeshop100%开源免费商用商城系统
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 开源版本可自由商用,可去除界面版权logo
  7. // | 商业版本务必购买商业授权,以免引起法律纠纷
  8. // | 禁止对系统程序代码以任何目的,任何形式的再发布
  9. // | gitee下载:https://gitee.com/likeshop_gitee
  10. // | github下载:https://github.com/likeshop-github
  11. // | 访问官网:https://www.likeshop.cn
  12. // | 访问社区:https://home.likeshop.cn
  13. // | 访问手册:http://doc.likeshop.cn
  14. // | 微信公众号:likeshop技术社区
  15. // | likeshop团队 版权所有 拥有最终解释权
  16. // +----------------------------------------------------------------------
  17. // | author: likeshopTeam
  18. // +----------------------------------------------------------------------
  19. namespace app\adminapi\lists\withdraw;
  20. use app\adminapi\lists\BaseAdminDataLists;
  21. use app\common\enum\WithdrawEnum;
  22. use app\common\lists\ListsExcelInterface;
  23. use app\common\lists\ListsExtendInterface;
  24. use app\common\lists\ListsSearchInterface;
  25. use app\common\model\UserLevel;
  26. use app\common\model\WithdrawApply;
  27. use app\common\service\FileService;
  28. /**
  29. * 提现列表
  30. * Class WithdrawLists
  31. * @package app\adminapi\lists\withdraw
  32. */
  33. class WithdrawLists extends BaseAdminDataLists implements ListsSearchInterface,ListsExtendInterface,ListsExcelInterface
  34. {
  35. /**
  36. * @notes 设置导出字段
  37. * @return array
  38. * @author Tab
  39. * @date 2021/8/9 16:24
  40. */
  41. public function setExcelFields(): array
  42. {
  43. return [
  44. 'sn' => '提现单号',
  45. 'nickname' => '用户昵称',
  46. 'money' => '提现金额',
  47. 'type_desc' => '提现方式',
  48. 'status_desc' => '提现状态',
  49. 'apply_remark' => '提现说明',
  50. 'create_time' => '提现时间',
  51. ];
  52. }
  53. /**
  54. * @notes 设置导出的表名
  55. * @return string
  56. * @author Tab
  57. * @date 2021/8/9 16:24
  58. */
  59. public function setFileName(): string
  60. {
  61. return '提现申请表';
  62. }
  63. /**
  64. * @notes 统计信息
  65. * @return array
  66. * @author Tab
  67. * @date 2021/8/6 20:12
  68. */
  69. public function extend()
  70. {
  71. $all = WithdrawApply::count();
  72. $statusWait = WithdrawApply::where('status', WithdrawEnum::STATUS_WAIT)->count();
  73. $statusIng = WithdrawApply::where('status', WithdrawEnum::STATUS_ING)->count();
  74. $statusSuccess = WithdrawApply::where('status', WithdrawEnum::STATUS_SUCCESS)->count();
  75. $statusFail = WithdrawApply::where('status', WithdrawEnum::STATUS_FAIL)->count();
  76. return [
  77. 'all' => $all,
  78. 'status_wait' => $statusWait,
  79. 'status_ing' => $statusIng,
  80. 'status_success' => $statusSuccess,
  81. 'status_fail' => $statusFail,
  82. ];
  83. }
  84. /**
  85. * @notes 设置搜索
  86. * @return array
  87. * @author Tab
  88. * @date 2021/8/6 20:12
  89. */
  90. public function setSearch(): array
  91. {
  92. return [
  93. '=' =>['wa.type','wa.sn', 'wa.status'],
  94. 'between_time' => 'wa.create_time'
  95. ];
  96. }
  97. /**
  98. * @notes 附加搜索
  99. * @author Tab
  100. * @date 2021/9/17 16:26
  101. */
  102. public function attachSearch()
  103. {
  104. // 用户信息
  105. if(isset($this->params['user_info']) && !empty($this->params['user_info'])) {
  106. $this->searchWhere[] = ['u.sn|u.nickname|u.mobile', 'like', '%'.$this->params['user_info'].'%'];
  107. }
  108. }
  109. /**
  110. * @notes 提现列表
  111. * @return array
  112. * @author Tab
  113. * @date 2021/8/6 20:12
  114. */
  115. public function lists(): array
  116. {
  117. $this->attachSearch();
  118. $field = 'wa.id,wa.sn,wa.money,wa.type,wa.status,wa.apply_remark,wa.create_time,wa.type as type_desc,wa.status as status_desc,wa.handling_fee,wa.left_money';
  119. $field .= ',u.avatar,u.sn as user_sn,u.nickname,u.level,u.mobile';
  120. $lists = WithdrawApply::alias('wa')
  121. ->leftJoin('user u', 'u.id = wa.user_id')
  122. ->field($field)
  123. ->where($this->searchWhere)
  124. ->limit($this->limitOffset, $this->limitLength)
  125. ->order('wa.id', 'desc')
  126. ->select()
  127. ->toArray();
  128. foreach($lists as &$item) {
  129. $item['avatar'] = FileService::getFileUrl($item['avatar']);
  130. $item['level_name'] = UserLevel::getLevelName($item['level']);
  131. }
  132. return $lists;
  133. }
  134. /**
  135. * @notes 提现记录数
  136. * @return int
  137. * @author Tab
  138. * @date 2021/8/6 20:12
  139. */
  140. public function count(): int
  141. {
  142. $this->attachSearch();
  143. $count = WithdrawApply::alias('wa')
  144. ->leftJoin('user u', 'u.id = wa.user_id')
  145. ->where($this->searchWhere)
  146. ->count();
  147. return $count;
  148. }
  149. }