where('mer_id', $mer_id); $model = $model->whereIn('uid', [$where['uid'], $where['to_uid']]); $model = $model->whereIn('to_uid', [$where['uid'], $where['to_uid']]); $count = $model->count(); $model->order("add_time desc"); $list = $model->select() ->each(function ($item) use ($mer_id) { $user = StoreService::field("nickname,avatar")->where('mer_id', $mer_id)->where(array("uid" => $item["uid"]))->find(); if (!$user) $user = User::field("nickname,avatar")->where(array("uid" => $item["uid"]))->find(); $item["nickname"] = $user["nickname"]; $item["avatar"] = $user["avatar"]; }); return compact('count', 'list'); } }