GroupOrderLists.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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.group_activity_id', 'a.sn','a.goods_id','a.status','a.user_id'],
  35. ];
  36. }
  37. public function queryWhere(){
  38. $where = [];
  39. if(!empty($this->params['title'])){
  40. $where[] = ['b.title', 'like', '%'.$this->params['title'].'%'];
  41. }
  42. if (!empty($this->params['account'])) {
  43. $where[] = ['c.account', 'like', '%'.$this->params['account'].'%'];
  44. }
  45. return $where;
  46. }
  47. /**
  48. * @notes 获取拼团订单列表
  49. * @return array
  50. * @throws \think\db\exception\DataNotFoundException
  51. * @throws \think\db\exception\DbException
  52. * @throws \think\db\exception\ModelNotFoundException
  53. * @author likeadmin
  54. * @date 2025/03/13 10:31
  55. */
  56. public function lists(): array
  57. {
  58. $list = GroupOrder::alias('a')->leftJoin('group_activity b', 'b.id = a.group_activity_id')
  59. ->leftJoin('user c', 'c.id = a.user_id')
  60. ->where($this->searchWhere)
  61. ->where($this->queryWhere())
  62. ->field(['a.*', 'b.title', 'b.image','c.account'])
  63. ->limit($this->limitOffset, $this->limitLength)
  64. ->order(['a.id' => 'desc'])
  65. ->select()
  66. ->toArray();
  67. return $list;
  68. }
  69. /**
  70. * @notes 获取拼团活动数量
  71. * @return int
  72. * @author likeadmin
  73. * @date 2025/03/13 10:31
  74. */
  75. public function count(): int
  76. {
  77. return GroupOrder::alias('a')
  78. ->leftJoin('group_activity b', 'b.id = a.group_activity_id')
  79. ->leftJoin('user c', 'c.id = a.user_id')
  80. ->where($this->searchWhere)
  81. ->where($this->queryWhere())
  82. ->count();
  83. }
  84. }