kefuId], ['from_type', '=', 'kefu'], ['to_id', '=', $this->params['user_id']], ['type', '=', ChatRecordEnum::TYPE_NORMAL] ]; $map2 = [ ['to_id', '=', $this->kefuId], ['to_type', '=', 'kefu'], ['from_id', '=', $this->params['user_id']], ['type', '=', ChatRecordEnum::TYPE_NORMAL] ]; return [$map1, $map2]; } /** * @notes 聊天记录列表 * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException * @author 段誉 * @date 2022/3/14 14:51 */ public function lists(): array { $lists = ChatRecord::whereOr($this->setWhere()) ->order('id desc') ->limit($this->limitOffset, $this->limitLength) ->select() ->toArray(); if (!empty($lists)) { $lists = ChatLogic::formatChatRecords($lists); } return $lists; } /** * @notes 记录数量 * @return int * @author 段誉 * @date 2022/3/14 14:52 */ public function count(): int { return ChatRecord::whereOr($this->setWhere())->count(); } }