userId]; // 用户月明细 if (isset($this->params['type']) && $this->params['type'] == 'um') { $where[] = ['change_type', 'in', AccountLogEnum::getUserMoneyChangeType()]; } // 变动类型 if (!empty($this->params['action'])) { $where[] = ['action', '=', $this->params['action']]; } return $where; } /** * @notes 获取列表 * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException * @author 段誉 * @date 2023/2/24 14:43 */ public function lists(): array { $field = 'change_type,change_amount,action,create_time,remark'; $lists = UserAccountLog::field($field) ->where($this->queryWhere()) ->order('id', 'desc') ->limit($this->limitOffset, $this->limitLength) ->select() ->toArray(); foreach ($lists as &$item) { $item['type_desc'] = AccountLogEnum::getChangeTypeDesc($item['change_type']); $symbol = $item['action'] == AccountLogEnum::DEC ? '-' : '+'; $item['change_amount_desc'] = $symbol . $item['change_amount']; } return $lists; } /** * @notes 获取数量 * @return int * @author 段誉 * @date 2023/2/24 14:44 */ public function count(): int { return UserAccountLog::where($this->queryWhere())->count(); } }