searchWhere[] = ['user_id', '=', $this->userId]; } /** * @notes 账户流水列表 * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException * @author Tab * @date 2021/8/9 17:37 */ public function lists(): array { // 设置搜索条件 $this->setWhere(); $field = 'user_id,card_pass,card_money,used_time'; $lists = GiftCardInfo::field($field) ->where($this->searchWhere) ->order('used_time', 'desc') ->limit($this->limitOffset, $this->limitLength) ->order('used_time', 'desc') ->select() ->toArray(); foreach($lists as &$item) { // $item['used_time'] = $item['action'] == AccountLogEnum::DEC ? '-' . $item['change_amount'] : '+' . $item['change_amount']; } return $lists; } /** * @notes 账户流水记录数 * @return int * @author Tab * @date 2021/8/9 17:36 */ public function count(): int { // 设置搜索条件 $this->setWhere(); $count = GiftCardInfo::where($this->searchWhere)->count(); return $count; } }