|
|
@@ -0,0 +1,106 @@
|
|
|
+<?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);
|
|
|
+ }
|
|
|
+}
|