where('mer_id', $where['mer_id']); } if (isset($where['status']) && $where['status']) { $model = $model->where('status', $where['status']); } if (isset($where['title']) && $where['title']) { $model = $model->where('nickname', 'like', "%$where[title]%"); } return $model; } /** * @return array */ public static function getList($where) { $data = self::setWhere($where)->page($where['page'], $where['limit'])->order('sort desc,id desc')->select(); $data = count($data) > 0 ? $data->toArray() : []; $count = self::setWhere($where['mer_id'])->count(); return compact('data', 'count'); } /** * @return array */ public static function getChatUser($uid, $mer_id, $page, $limit) { $list = []; $count = 0; $where = 'mer_id = ' . $mer_id . ' AND (uid = ' . $uid . ' OR to_uid=' . $uid . ')'; $chat_list = ServiceLogModel::field("uid,to_uid")->page($page,$limit)->where($where)->group("uid,to_uid")->select(); if (!count($chat_list)) return compact('list', 'count'); $arr_user = $arr_to_user = []; foreach ($chat_list as $key => $value) { array_push($arr_user, $value["uid"]); array_push($arr_to_user, $value["to_uid"]); } $uids = array_merge($arr_user, $arr_to_user); $data = User::field("uid,nickname,avatar")->where(array("uid" => array(array("in", $uids), array("neq", $uid))))->select(); $data = count($data) > 0 ? $data->toArray() : []; foreach ($data as $index => $user) { $service = self::field("uid,nickname,avatar")->where(array("uid" => $user["uid"]))->find(); if ($service) $data[$index] = $service; } $count = User::where(array("uid" => array(array("in", $uids), array("neq", $uid))))->count(); return compact('data', 'count'); } }