GroupOrderLists.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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\group_activity;
  15. use app\adminapi\lists\BaseAdminDataLists;
  16. use app\common\model\group_activity\GroupOrder;
  17. use app\common\lists\ListsSearchInterface;
  18. /**
  19. * 拼团订单列表
  20. * Class GroupOrderLists
  21. * @package app\adminapi\listsgroup_activity
  22. */
  23. class GroupOrderLists extends BaseAdminDataLists implements ListsSearchInterface
  24. {
  25. /**
  26. * @notes 设置搜索条件
  27. * @return \string[][]
  28. * @author likeadmin
  29. * @date 2025/03/13 10:31
  30. */
  31. public function setSearch(): array
  32. {
  33. return [
  34. '=' => ['a.id','a.group_activity_id', 'a.sn','a.goods_id','a.equity_id','a.status','a.user_id'],
  35. ];
  36. }
  37. public function queryWhere(){
  38. $where = [];
  39. if (!empty($this->params['mobile'])) {
  40. $where[] = ['b.mobile', '=', $this->params['mobile']];
  41. }
  42. if(!empty($this->params['title'])){
  43. $where[] = ['c.title', 'like', '%'.$this->params['title'].'%'];
  44. }
  45. if(!empty($this->params['area'])){
  46. $where[] = ['d.area', 'like', '%'.$this->params['area'].'%'];
  47. }
  48. return $where;
  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 likeadmin
  57. * @date 2025/03/13 10:31
  58. */
  59. public function lists(): array
  60. {
  61. $list = GroupOrder::alias('a')
  62. ->leftJoin('user b', 'b.id = a.user_id')
  63. ->leftJoin('group_activity c', 'c.id = a.group_activity_id')
  64. ->leftJoin('group_activity_category d', 'd.id = c.group_category_id')
  65. ->where($this->searchWhere)
  66. ->where($this->queryWhere())
  67. ->field(['a.*','b.mobile', 'c.title', 'c.image','d.area'])
  68. ->limit($this->limitOffset, $this->limitLength)
  69. ->order(['a.id' => 'desc'])
  70. ->select()
  71. ->toArray();
  72. foreach($list as &$item) {
  73. $item['area'] = explode(",",$item['area']);
  74. }
  75. return $list;
  76. }
  77. /**
  78. * @notes 获取拼团活动数量
  79. * @return int
  80. * @author likeadmin
  81. * @date 2025/03/13 10:31
  82. */
  83. public function count(): int
  84. {
  85. return GroupOrder::alias('a')
  86. ->leftJoin('user b', 'b.id = a.user_id')
  87. ->leftJoin('group_activity c', 'c.id = a.group_activity_id')
  88. ->leftJoin('group_activity_category d', 'd.id = c.group_category_id')
  89. ->where($this->searchWhere)
  90. ->where($this->queryWhere())
  91. ->count();
  92. }
  93. }