[], ]; } public function queryWhere() { // 指定用户 $propertyHeadId = PropertyHead::where('user_id',$this->userId)->value('id'); $where[] = ['b.property_head_id', '=', $propertyHeadId]; 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[] = ['b.create_time', 'between', [$monthStart, $monthEnd]]; } // $where[] = ['a.service_status', '=', 3]; return $where; } /** * @notes 获取列表 * @return array */ public function lists(): array { $lists = GroupServiceWork::alias('a') ->leftJoin('group_order b','a.group_order_id=b.id') ->field('a.id,a.work_total,a.address,a.mobile,a.real_name,b.create_time') ->where($this->queryWhere()) ->limit($this->limitOffset, $this->limitLength) ->order('b.create_time', 'desc') ->select() ->toArray(); return $lists; } /** * @notes 获取数量 * @return int */ public function count(): int { return GroupServiceWork::alias('a') ->leftJoin('group_order b','a.group_order_id=b.id') ->where($this->queryWhere()) ->count(); } /** * @notes 统计工单总收益 * @return float */ public function extend(): array { $totalWorkTotal = GroupUserOrder::alias('a') ->leftJoin('group_order b', 'a.group_order_id = b.id') ->leftJoin('group_service_work c', 'a.id = c.group_user_order_id') ->where($this->queryWhere()) ->sum('c.work_total'); $totalWorkAmount = GroupUserOrder::alias('a') ->leftJoin('group_order b', 'a.group_order_id = b.id') ->leftJoin('group_service_work c', 'a.id = c.group_user_order_id') ->where($this->queryWhere()) ->sum('c.work_amount'); return ["total_amount" => $totalWorkTotal - $totalWorkAmount]; } }