UserServiceLists.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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\agricultural_machinery;
  15. use app\adminapi\lists\BaseAdminDataLists;
  16. use app\common\lists\ListsSearchInterface;
  17. use app\common\lists\ListsSortInterface;
  18. use app\common\model\agricultural_machinery\ServiceCategory as AgriculturalMachineryServiceCategory;
  19. use app\common\model\agricultural_machinery\UserService;
  20. /**
  21. * 资讯分类列表
  22. * Class ArticleCateLists
  23. * @package app\adminapi\lists\article
  24. */
  25. class UserServiceLists extends BaseAdminDataLists implements ListsSearchInterface, ListsSortInterface
  26. {
  27. /**
  28. * @notes 设置搜索条件
  29. * @return array
  30. * @author heshihu
  31. * @date 2022/2/8 18:39
  32. */
  33. public function setSearch(): array
  34. {
  35. return [
  36. '%like%' => ['us.name','us.mobile'],
  37. '=' => ['us.type']
  38. ];
  39. }
  40. /**
  41. * @notes 自定查询条件
  42. * @return array
  43. * @author 段誉
  44. * @date 2022/10/25 16:53
  45. */
  46. public function queryWhere()
  47. {
  48. $where = [];
  49. if (isset($this->params['pay_status']) && !empty($this->params['pay_status'])) {
  50. $pay_status = $this->params['pay_status'];
  51. if($pay_status == -1){
  52. $pay_status = 0;
  53. }
  54. $where[] = ['ro.pay_status', '=', $pay_status];
  55. }
  56. if (isset($this->params['area_id'])) {
  57. $where[] = ['us.area_id', 'like','%'. ',' . $this->params['area_id']. ',' .'%'];
  58. }
  59. if (isset($this->params['cate_id'])) {
  60. $where[] = ['us.cate_id', 'like','%'. ',' . $this->params['cate_id']. ',' .'%'];
  61. }
  62. return $where;
  63. }
  64. /**
  65. * @notes 设置支持排序字段
  66. * @return array
  67. * @author heshihu
  68. * @date 2022/2/9 15:11
  69. */
  70. public function setSortFields(): array
  71. {
  72. return [ 'id' => 'id'];
  73. }
  74. /**
  75. * @notes 设置默认排序
  76. * @return array
  77. * @author heshihu
  78. * @date 2022/2/9 15:08
  79. */
  80. public function setDefaultOrder(): array
  81. {
  82. return ['us.id' => 'desc'];
  83. }
  84. /**
  85. * @notes 获取管理列表
  86. * @return array
  87. * @author heshihu
  88. * @date 2022/2/21 17:11
  89. */
  90. public function lists(): array
  91. {
  92. $ServerCateLists = UserService::alias('us')
  93. ->leftJoin('recharge_order ro','ro.id=us.order_id')
  94. ->field('us.id,us.user_id,us.type,us.name,us.mobile,us.agricultural_machinery_model,us.images,us.cate_id,us.area_id,us.money,us.content,us.status,us.expiration_time
  95. ,us.order_id,us.create_time,ro.sn,ro.pay_way,ro.pay_status,ro.pay_time')
  96. ->where($this->searchWhere)
  97. ->where($this->queryWhere())
  98. ->limit($this->limitOffset, $this->limitLength)
  99. ->order($this->sortOrder)
  100. ->append(['status_desc','pay_status_desc','type_desc','cate_desc','area_desc','user'])
  101. ->select()
  102. ->toArray();
  103. return $ServerCateLists;
  104. }
  105. /**
  106. * @notes 获取数量
  107. * @return int
  108. * @author heshihu
  109. * @date 2022/2/9 15:12
  110. */
  111. public function count(): int
  112. {
  113. return UserService::alias('us')->leftJoin('recharge_order ro','ro.id=us.order_id')->where($this->searchWhere)->where($this->queryWhere())->count();
  114. }
  115. public function extend()
  116. {
  117. return [];
  118. }
  119. }