| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- <?php
- namespace app\adminapi\lists\finance;
- use app\adminapi\lists\BaseAdminDataLists;
- use app\common\lists\ListsSearchInterface;
- use app\common\lists\ListsExtendInterface;
- use app\common\model\master_worker\MasterWorkerRetentionMoneyLog;
- /**
- * 质保金流水列表
- * Class RetentionMoneyLogLists
- * @package app\adminapi\lists\finance
- */
- class RetentionMoneyLogLists extends BaseAdminDataLists implements ListsSearchInterface, ListsExtendInterface
- {
- /**
- * @notes 搜索条件
- * @return array
- */
- public function setSearch(): array
- {
- return [
- '=' => ['l.status','l.action'],
- ];
- }
- /**
- * @notes 搜索条件
- */
- public function queryWhere()
- {
- $where = [];
- if (!empty($this->params['worker'])) {
- $where[] = ['w.real_name|w.mobile', 'like', '%' . $this->params['worker'] . '%'];
- }
- if (!empty($this->params['start_time'])) {
- $where[] = ['l.create_time', '>=', strtotime($this->params['start_time'])];
- }
- if (!empty($this->params['end_time'])) {
- $where[] = ['l.create_time', '<=', strtotime($this->params['end_time'])];
- }
- return $where;
- }
- /**
- * @notes 获取列表
- * @return array
- */
- public function lists(): array
- {
- $field = 'w.real_name,w.mobile,l.*';
- $lists = MasterWorkerRetentionMoneyLog::alias('l')
- ->join('master_worker w', 'w.id = l.worker_id')
- ->field($field)
- ->where($this->searchWhere)
- ->where($this->queryWhere())
- ->order('l.id', 'desc')
- ->limit($this->limitOffset, $this->limitLength)
- ->select()
- ->toArray();
- foreach ($lists as &$item) {
- $symbol = $item['action'] == 1 ? '+' : '-';
- $item['amount'] = $symbol . $item['amount'];
- }
- return $lists;
- }
- /**
- * @notes 获取数量
- * @return int
- */
- public function count(): int
- {
- return MasterWorkerRetentionMoneyLog::alias('l')
- ->join('master_worker w', 'w.id = l.worker_id')
- ->where($this->queryWhere())
- ->where($this->searchWhere)
- ->count();
- }
- /**
- * @notes 额外参数
- * @return mixed|null
- */
- public function extend()
- {
- $count = (new MasterWorkerRetentionMoneyLog())->alias('l')
- ->join('master_worker w', 'w.id = l.worker_id')
- ->field([
- 'count(l.id) as total',
- 'count(if(l.action=1, true, null)) as ing',
- 'count(if(l.action=2, true, null)) as success',
- ])
- ->where($this->searchWhere)
- ->where($this->queryWhere(false))
- ->select()->toArray();
- return array_shift($count);
- }
- }
|