| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- <?php
- namespace app\api\lists\property;
- use app\api\lists\BaseApiDataLists;
- use app\common\lists\ListsSearchInterface;
- use app\common\model\property\PropertyHead;
- use app\common\model\group_activity\GroupUserOrder;
- /**
- * 代理人拼团订单列表
- * Class PropertyGroupOrderLists
- * @package app\api\lists\property
- */
- class PropertyGroupOrderLists extends BaseApiDataLists implements ListsSearchInterface
- {
- /**
- * @notes 设置搜索条件
- * @return \string[][]
- * @author likeadmin
- * @date 2024/07/07 18:37
- */
- public function setSearch(): array
- {
- return [
- '=' => [],
- ];
- }
- public function queryWhere()
- {
- // 指定用户
- $propertyHeadId = PropertyHead::where('user_id',$this->userId)->value('id');
- $where[] = ['b.property_head_id', '=', $propertyHeadId];
- if (isset($this->params['status'])) {
- if ($this->params['status'] == 0) {
- $where[] = ['a.status', '=', 0];
- } elseif ($this->params['status'] == 1) {
- $where[] = ['a.status', '=', 1];
- } else {
- $where[] = ['a.status', '>', 1];
- }
- }
- if (isset($this->params['start_time']) && !empty($this->params['start_time'])) {
- $monthStart = strtotime(date("Y-m-01",strtotime($this->params['start_time'])));
- $monthEnd = strtotime(date("Y-m-t 23:59:59",strtotime($this->params['start_time'])));
- $where[] = ['a.create_time', 'between', [$monthStart, $monthEnd]];
- }
- return $where;
- }
-
- /**
- * @notes 获取列表
- * @return array
- */
- public function lists(): array
- {
- $lists = GroupUserOrder::alias('a')
- ->leftJoin('group_order b','a.group_order_id=b.id')
- ->leftJoin('group_activity c','a.group_activity_id=c.id')
- ->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,b.num,b.origin_price,b.end_time,c.title,c.image')
- ->where($this->queryWhere())
- ->limit($this->limitOffset, $this->limitLength)
- ->order('a.create_time', 'desc')
- ->select()
- ->toArray();
- return $lists;
- }
- /**
- * @notes 获取数量
- * @return int
- */
- public function count(): int
- {
- return GroupUserOrder::alias('a')
- ->leftJoin('group_order b','a.group_order_id=b.id')
- ->leftJoin('group_activity c','a.group_activity_id=c.id')
- ->where($this->queryWhere())
- ->count();
- }
- }
|