| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- <?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\group_activity\GroupSettlement;
- use app\common\model\property\PropertyHead;
- use app\common\model\works\GroupServiceWork;
- /**
- * 代理人结算列表
- * Class PropertyGroupSettlementLists
- * @package app\api\lists\property
- */
- class PropertyGroupSettlementLists 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 = (int)PropertyHead::where('user_id',$this->userId)->value('id');
- $where[] = ['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[] = ['create_time', 'between', [$monthStart, $monthEnd]];
- }
- $where[] = ['settlement_type', '=', 1];
- return $where;
- }
-
- /**
- * @notes 获取列表
- * @return array
- */
- public function lists(): array
- {
- $lists = GroupSettlement::where($this->queryWhere())
- ->order("id","desc")
- ->limit($this->limitOffset, $this->limitLength)
- ->select()
- ->toArray();
- foreach($lists as &$item) {
- $item['create_time'] = date('n月j日', strtotime($item['create_time']));
- }
- return $lists;
- }
- /**
- * @notes 获取数量
- * @return int
- */
- public function count(): int
- {
- return GroupSettlement::where($this->queryWhere())->count();
- }
- /**
- * @notes 统计结算总额
- * @return float
- */
- public function extend(): array
- {
- $settlementedTotal = GroupSettlement::where($this->queryWhere())->sum('settlement_amount');
- return ["total_amount" => $settlementedTotal];
- }
- }
|