SelffetchVerifierLists.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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\selffetch_shop;
  20. use app\adminapi\lists\BaseAdminDataLists;
  21. use app\common\lists\ListsExcelInterface;
  22. use app\common\lists\ListsSearchInterface;
  23. use app\common\model\SelffetchVerifier;
  24. use app\common\service\FileService;
  25. /**
  26. * 核销员列表
  27. * Class SelffetchVerifierLists
  28. * @package app\adminapi\lists\selffetch_shop
  29. */
  30. class SelffetchVerifierLists extends BaseAdminDataLists implements ListsExcelInterface
  31. {
  32. /**
  33. * @notes 设置搜索条件
  34. * @return \string[][]
  35. * @author ljj
  36. * @date 2021/8/11 7:51 下午
  37. */
  38. public function setSearch()
  39. {
  40. if(isset($this->params['name']) && $this->params['name']){
  41. $this->searchWhere[] = ['sv.name', 'like', '%'.$this->params['name'].'%'];
  42. }
  43. if(isset($this->params['shop_name']) && $this->params['shop_name']){
  44. $this->searchWhere[] = ['ss.name', 'like', '%'.$this->params['shop_name'].'%'];
  45. }
  46. if(isset($this->params['status']) && $this->params['status']){
  47. $this->searchWhere[] = ['sv.status', '=', $this->params['status']];
  48. }
  49. }
  50. /**
  51. * @notes 查看核销员列表
  52. * @return array
  53. * @throws \think\db\exception\DataNotFoundException
  54. * @throws \think\db\exception\DbException
  55. * @throws \think\db\exception\ModelNotFoundException
  56. * @author ljj
  57. * @date 2021/8/11 7:51 下午
  58. */
  59. public function lists(): array
  60. {
  61. $this->setSearch();
  62. $lists = SelffetchVerifier::alias('sv')
  63. ->join('user u', 'u.id = sv.user_id')
  64. ->join('selffetch_shop ss', 'ss.id = sv.selffetch_shop_id')
  65. ->field('sv.id,sv.name,sv.status,sv.sn,u.nickname,u.avatar,ss.name as selffetch_shop_name,sv.create_time')
  66. ->append(['status_desc'])
  67. ->order('sv.id','desc')
  68. ->where($this->searchWhere)
  69. ->limit($this->limitOffset, $this->limitLength)
  70. ->select()
  71. ->toArray();
  72. if (empty($lists)) {
  73. return [];
  74. }
  75. foreach ($lists as &$list) {
  76. $list['avatar'] = empty($list['avatar']) ? '' : FileService::getFileUrl($list['avatar']);
  77. }
  78. return $lists;
  79. }
  80. /**
  81. * @notes 查看核销员总数
  82. * @return int
  83. * @author ljj
  84. * @date 2021/8/11 7:51 下午
  85. */
  86. public function count(): int
  87. {
  88. return SelffetchVerifier::alias('sv')
  89. ->join('user u', 'u.id = sv.user_id')
  90. ->join('selffetch_shop ss', 'ss.id = sv.selffetch_shop_id')
  91. ->where($this->searchWhere)
  92. ->count();
  93. }
  94. /**
  95. * @notes 设置导出字段
  96. * @return string[]
  97. * @author ljj
  98. * @date 2021/8/11 8:14 下午
  99. */
  100. public function setExcelFields(): array
  101. {
  102. return [
  103. // '数据库字段名(支持别名) => 'Excel表字段名'
  104. 'id' => 'ID',
  105. 'name' => '核销员名称',
  106. 'nickname' => '用户名称',
  107. 'selffetch_shop_name' => '自提门店名称',
  108. 'status_desc' => '状态',
  109. 'create_time' => '创建时间',
  110. ];
  111. }
  112. /**
  113. * @notes 设置默认表名
  114. * @return string
  115. * @author ljj
  116. * @date 2021/8/11 8:14 下午
  117. */
  118. public function setFileName(): string
  119. {
  120. return '核销员';
  121. }
  122. }