|
|
@@ -0,0 +1,93 @@
|
|
|
+<?php
|
|
|
+namespace app\api\lists\property;
|
|
|
+
|
|
|
+use app\api\lists\BaseApiDataLists;
|
|
|
+use app\common\lists\ListsExtendInterface;
|
|
|
+use app\common\lists\ListsSearchInterface;
|
|
|
+use app\common\model\property\PropertyHead;
|
|
|
+use app\common\model\works\GroupServiceWork;
|
|
|
+use app\common\model\group_activity\GroupUserOrder;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 代理人完结工单列表
|
|
|
+ * Class PropertyServiceWorkLists
|
|
|
+ * @package app\api\lists\property
|
|
|
+ */
|
|
|
+class PropertyServiceWorkLists extends BaseApiDataLists implements ListsSearchInterface, ListsExtendInterface
|
|
|
+{
|
|
|
+ /**
|
|
|
+ * @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['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];
|
|
|
+ }
|
|
|
+
|
|
|
+}
|