UserOrderLists.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. namespace app\api\lists\group_activity;
  3. use app\api\lists\BaseApiDataLists;
  4. use app\common\lists\ListsSearchInterface;
  5. use app\common\model\group_activity\GroupUserOrder;
  6. /**
  7. * 拼团用户订单列表
  8. * Class RechargeLists
  9. * @package app\api\lists\group_activity
  10. */
  11. class UserOrderLists extends BaseApiDataLists implements ListsSearchInterface
  12. {
  13. /**
  14. * @notes 设置搜索条件
  15. * @return \string[][]
  16. * @author likeadmin
  17. * @date 2024/07/07 18:37
  18. */
  19. public function setSearch(): array
  20. {
  21. return [
  22. '=' => ['a.status'],
  23. ];
  24. }
  25. public function queryWhere(){
  26. $where = [];
  27. if (empty($this->params['status'])) {
  28. $where[] = ['a.status', '<>', 0];
  29. }
  30. return $where;
  31. }
  32. /**
  33. * @notes 获取列表
  34. * @return array
  35. */
  36. public function lists(): array
  37. {
  38. $lists = GroupUserOrder::alias('a')->leftJoin('group_order b','a.group_order_id=b.id')
  39. ->leftJoin('group_activity c','a.group_activity_id=c.id')
  40. ->field('a.id,a.sn,a.group_activity_id,a.status,a.order_amount,a.paid_amount,a.pay_status,a.refund_status,a.create_time,b.goods_id,a.num,b.origin_price,b.end_time,c.title,c.image')
  41. ->where([
  42. 'a.user_id' => $this->userId,
  43. ])
  44. ->where($this->searchWhere)
  45. ->where($this->queryWhere())
  46. ->limit($this->limitOffset, $this->limitLength)
  47. ->order('a.create_time', 'desc')
  48. ->select()
  49. ->toArray();
  50. return $lists;
  51. }
  52. /**
  53. * @notes 获取数量
  54. * @return int
  55. */
  56. public function count(): int
  57. {
  58. return GroupUserOrder::alias('a')->where([
  59. 'user_id' => $this->userId,
  60. ])
  61. ->where($this->searchWhere)
  62. ->where($this->queryWhere())
  63. ->count();
  64. }
  65. }