def format_home_users(user_list=list()): """ 格式化首页的用户 """ result = [] if not user_list: return result image_list = ImageModel.query_image_by_image_id_list( array_column(user_list, "image_id")) image_list = array_column_key(image_list, "user_id") for user in user_list: item = dict() # 用户信息 user_info = UserInfoModel.query_user_model_by_id(user.user_id) item["user_info"] = UserInfoModel.format_user_info(user_info) image_model = image_list.get(user.user_id, None) item["cover"] = ImageModel.generate_image_url( image_model, "c") if image_model else "" item["last_id"] = 0 item["offset"] = 0 item["relation_type"] = 0 result.append(item) return result
def get(self, params): params["limit"] = self.per_page user_list = [] field = "" # 关注 if params["type"] == 2: user_list = FollowModel.query_follow_list(params) field = "follow_id" # 粉丝 elif params["type"] == 3: user_list = FollowModel.query_fans_list(params) field = "user_id" # 好友 elif params["type"] == 4: user_list = FollowModel.query_friends_list(params) field = "follow_id" if not user_list: return json_success_response(user_list) other_user_id_list = array_column(user_list, field) user_relations_dict = FollowModel.query_relation_to_user_list(g.account["user_id"], other_user_id_list) result = list() for follow_model in user_list: item = dict() item["id"] = follow_model.id user_id = getattr(follow_model, field) item["relation_type"] = user_relations_dict.get(user_id, 0) user_model = UserInfoModel.query_user_model_by_id(user_id) item["user_info"] = UserInfoModel.format_user_info(user_model) result.append(item) return json_success_response(result)
def format_offer_info(offer_model, share_model, login_user_id): if not offer_model: return dict() icon_info = RewardIconModel.query_icon_with_id(offer_model.present_id) if not share_model: from app.models.social.share import ShareModel share_model = ShareModel.query_share_model(offer_model.share_id) result = dict() result["present_url"] = icon_info.url if icon_info else "" result["price"] = share_model.price / 100 result["total_number"] = offer_model.total_number result["join_number"] = offer_model.join_number result["status"] = offer_model.status result["offer_status"] = offer_model.offer_status result["limit_time"] = (offer_model.due_time - datetime.datetime.now()).seconds offer_enter = OfferListModel.check_offer_enter_status(offer_model.offer_id, login_user_id) result["enter_status"] = 1 if offer_enter else 0 if offer_model.offer_status == 3: winner_info = UserInfoModel.query_user_model_by_id(offer_model.winner_user_id) result["winner"] = UserInfoModel.format_user_info(winner_info) elif offer_model.offer_status in [1, 2]: result["list"] = OfferListModel.query_offer_list(offer_model.offer_id) return result
def get(self, params): offset = IndexHandler.per_page * params["limit"] user_black_list = UserBlackModel.query_user_black_list( g.account["user_id"], 1, offset, IndexHandler.per_page) user_id_list = array_column(user_black_list, "black_user_id") result = list() for user_id in user_id_list: user_info = UserInfoModel.query_user_model_by_id(user_id) if not user_info: continue item = dict() item["user_id"] = user_info.user_id item["nickname"] = user_info.nickname item["avatar"] = UserInfoModel.format_user_avatar(user_info) user_id_relation = UserIdRelationModel.query_user_id_relation( user_info.user_id) item[ "huanxin_uid"] = user_id_relation.str_id if user_id_relation else "" result.append(item) return json_success_response(result)
def post(self, params): permit = UserPermitModel.query_user_permit_model(g.account["user_id"]) if permit and permit.allow_post_wechat == 0: return json_fail_response(2408) wechat = UserWeChatModel() wechat.user_id = g.account["user_id"] wechat.wechat = params["wechat"] wechat.price = params["price"] * 100 wechat.status = 1 db.session.add(wechat) try: db.session.commit() UserInfoModel.query_user_model_by_id(g.account["user_id"], True) return json_success_response({ "data": 1, "message": "设置成功", }) except: return json_success_response({ "data": 0, "message": "设置失败", })
def query_share_info(share_id): share_info = ShareModel.query_share_model(share_id) if not share_info or share_info.status not in status_public: return None user_info = UserInfoModel.query_user_model_by_id(share_info.user_id) if share_info.type_id == 10: image = ImageModel.query.filter_by( share_id=share_id, status=1).order_by(ImageModel.image_id.asc()).first() image_url = ImageModel.generate_image_url(image, 'c') elif share_info.type_id == 11: image = ImageModel.query.filter_by( share_id=share_id, status=1).order_by(ImageModel.image_id.asc()).first() image_url = ImageModel.generate_image_url(image, 'x') elif share_info.type_id == 30: image_url = "" else: image_url = UserInfoModel.format_user_info(user_info)["avatar"] result = { "image": image_url, "content": share_info.content, "nickname": user_info.nickname, } return result
def post(self, params): item = params["item"] if item == "nickname": # 设置昵称,但是又没有写昵称 if not params["nickname"]: return json_fail_response(5100) # 检查昵称被占用 duplicated = UserInfoModel.duplicate_nick_name( nickname=params["nickname"], user_id=g.account["user_id"]) if duplicated: return json_fail_response(5101) success = True if item in ["nickname", "gender", "city_name"]: success = UserInfoModel.update_user_info(g.account["user_id"], {item: params[item]}) elif item in [ "vocation_name", "school_name", "language", "emotional_state", "live_region_name" ]: success = UserSocialInfoModel.update_user_social_info( g.account["user_id"], {item: params[item]}) UserSocialInfoModel.query_user_social_info(g.account["user_id"], True) elif item in ["height", "weight", "star_sign", "age"]: success = UserPersonalInfoModel.update_user_personal_info( g.account["user_id"], {item: params[item]}) result = { "data": 1 if success else 0, "message": "更新成功" if success else "更新失败", } return json_success_response(result)
def black_able(black_user_id): user = UserInfoModel.query_user_model_by_id(black_user_id) user_info = UserInfoModel.format_user_info(user) if user_info and user_info.get("role_id", 0) == 8: return {"data": 0, "message": "不能拉黑系统管理员"} return None
def get(self, params): login_user_id = g.account["user_id"] RedisModel.reset_new_message(login_user_id, RedisModel.new_visitor) visitor_list = list() while not visitor_list: visitor_list = VisitorRecordModel.query_visitor_list_by_day( login_user_id, 20, params["last_id"]) params["last_id"] += 1 # 最多查询30天 if params["last_id"] > 30: break visitor_dict_list = list() for visitor in visitor_list: item = dict() user_info = UserInfoModel.query_user_model_by_id( visitor.visitor_user_id) item["user_info"] = UserInfoModel.format_user_info( user_info) if user_info else {} item["time"] = visitor.created_time visitor_dict_list.append(item) return json_success_response({ "last_id": params["last_id"], "list": visitor_dict_list })
def post(self, params): img_upload = UploadImage() print(params) if params["cover_type"] == 1: if not img_upload.images: return json_fail_response(2402) img_upload.save_images() image_model = img_upload.images[0]["image"] ChangeCoverHandler.change_cover_image(image_model) else: pass cover_info = SocialPageModel.query_social_page_model( g.account["user_id"]) result = { "user_banner": cover_info.get("cover", ""), "user_banner_type": cover_info.get("cover_type", 0) } if result.get("user_banner_type", 0) == 2: result["orientation"] = cover_info.get("orientation") result["user_banner_cover"] = cover_info.get("video_img", "") UserInfoModel.query_user_model_by_id(g.account["user_id"], True) return json_success_response(result)
def get(self, *args): user_id = g.account["user_id"] user_info = UserInfoModel.query_user_model_by_id(user_id) if not user_info: return json_success_response({}) result = dict() result["user_info"] = UserInfoModel.format_user_info(user_info) result["profit_today"] = 0 result["ok_percent"] = UserInfoModel.calculate_ok_percent(user_id) invite_code = UserInviteCodeModel.query_user_invite_code(user_id) result["invite_url"] = user_invite_url + invite_code result["new_visitor"] = RedisModel.query_new_message( user_id, RedisModel.new_visitor) result["follow_add"] = 0 social_meta = SocialMetaModel.query_social_meta_info( g.account["user_id"]) result["wechat_info"] = MeHandler.format_wechat_info( g.account["user_id"], social_meta.wechat_want if social_meta else 0) return json_success_response(result)
def check_offer_enter_enable(offer_id, user_id): """ 检查当前是否还可以报名参加悬赏 :param offer_id: 悬赏id :param user_id: 用户id """ offer = OfferModel.query_offer_mode_with_offer_id(offer_id) if not offer: return False, "悬赏不存在" if offer.user_id == user_id: return False, "自己无法报名自己的悬赏" publish_user = UserInfoModel.query_user_model_by_id(offer.user_id) join_user = UserInfoModel.query_user_model_by_id(user_id) if publish_user.gender == join_user.gender: return False, "禁止同性报名" if OfferListModel.check_offer_enter_status(offer_id, user_id): return False, "您已经报名过此悬赏" if offer.offer_status == 1: return False, "悬赏尚未开始" elif offer.offer_status == 3: return False, "悬赏已经结束" elif offer.offer_status == 4: return False, "悬赏已被取消" elif offer.offer_status == 2: if offer.join_number >= offer.total_number: return False, "人数已满" return True, "可以报名"
def post(self, params): # 处理自己关注自己的情况 if params["user_id"] == params["follow_id"]: return json_fail_response(2301) user_follow = FollowModel.query_user_follow(user_id=params["user_id"], follow_id=params["follow_id"]) result = dict() if not user_follow: user_follow = FollowModel() user_follow.user_id = params["user_id"] user_follow.follow_id = params["follow_id"] user_follow.status = params["status"] db.session.add(user_follow) db.session.commit() # 添加新的关注的redis if params["status"] == 1: RedisModel.add_new_message(params["follow_id"], RedisModel.new_follow) result = { "data": 1, "message": "关注成功" if params["status"] == 1 else "取消成功" } IndexHandler.update_social_meta(params["user_id"], params["follow_id"], params["status"]) elif user_follow.status != params["status"]: user_follow.status = params["status"] db.session.commit() # 添加新的关注的redis if params["status"] == 1: RedisModel.add_new_message(params["follow_id"], RedisModel.new_follow) result = { "data": 1, "message": "关注成功" if params["status"] == 1 else "取消成功" } IndexHandler.update_social_meta(params["user_id"], params["follow_id"], params["status"]) elif user_follow.status == 1: result = { "data": 1, "message": "已关注", } follow_status = FollowModel.query_relation_to_user_list(params["user_id"], [params["follow_id"]]) result["follow_status"] = follow_status[params["follow_id"]] UserInfoModel.query_user_model_by_id(params["user_id"], True) UserInfoModel.query_user_model_by_id(params["follow_id"], True) return json_success_response(result)
def register_by_mobile(mobile, country): # 注册一个新的账户 account = UserAccountModel() account.username = mobile account.mobile = mobile account.country = country db.session.add(account) db.session.commit() # 使用事务提交默认参数 user_info = UserInfoModel() user_info.user_id = account.id user_info.nickname = "Aha" + str(account.id) # 私人信息 user_personal_info = UserPersonalInfoModel() user_personal_info.user_id = account.id user_personal_info.age = 16 # Aha账户 aha_account = AhaAccountModel() aha_account.user_id = account.id aha_account.aha_id = 1000000 + account.id aha_account.changeable_aha = 1 # 社交信息 user_social = UserSocialInfoModel() user_social.user_id = account.id user_social.language = "中文" user_social.emotional_state = "保密" user_social.live_region_name = "中国" # 环信账号 user_id_relation = UserIdRelationModel() user_id_relation.user_id = account.id user_id_relation.str_id = md5( str(account.id )) # md5(app.config["CACHE_KEY_PREFIX"] + str(account.id)) # 注册环信账号 mob_client().register_new_user(user_id_relation.str_id) # 提交到数据库 db.session.add(user_info) db.session.add(user_personal_info) db.session.add(aha_account) db.session.add(user_social) db.session.add(user_id_relation) db.session.commit() return account
def format_offer_list(offer_list): result = list() if not offer_list: return result for offer_list_model in offer_list: item = offer_list_model.to_dict(filter_params=True) user_info = UserInfoModel.query_user_model_by_id( offer_list_model.apply_user_id) item["user_info"] = UserInfoModel.format_user_info(user_info) result.append(item) return result
def post(self): image_list = UploadImage() image_list.save_images() if not image_list.images: return json_fail_response(2401) image_model = image_list.images[0]["image"] user_info = UserInfoModel.query_user_model_by_id( g.account["user_id"], True) if not user_info: return json_fail_response(2101) # 缓存旧的头像 old_avatar = user_info.avatar # 更新头像 user_info.avatar = image_model.image_id # 头像绑定到图片模型 image_model.user_id = user_info.user_id # 解绑旧的头像 if old_avatar: ImageModel.query.filter_by(image_id=old_avatar).update( dict(user_id=0)) db.session.commit() user_model = UserInfoModel.query_user_model_by_id( g.account["user_id"], True) AccountDataModel.query_request_account_by_token( g.account["access_token"], True) user_info = UserInfoModel.format_user_info(user_model) small_dict = { "url": user_info.get("avatar", ""), "width": 240, "height": 240, } big_dict = { "url": user_info.get("big_avatar", ""), "width": 800, "height": 800 } result = {"small": small_dict, "big": big_dict} return json_success_response(result)
def format_ease_mob_user(login_user_id, user_id): user_info = UserInfoModel.query_user_model_by_id(user_id) has_trade = UserConsumerModel.query_trade_relationship( user_id, login_user_id) follow_status = FollowModel.query_relation_to_user( login_user_id, user_id) remark_name = RemarkNameModel.query_remark_name(login_user_id, user_id) result = { "user_info": UserInfoModel.format_user_info(user_info), "had_trade": has_trade, "follow_status": follow_status, "black_status": 0, "remark_name": remark_name.remark_nickname if remark_name else "" } return result
def get(self, params): query = LikeModel.query.filter_by(share_id=params["share_id"], status=1) if params["last_id"]: query = query.filter(LikeModel.like_id < params["last_id"]) like_model_list = query.order_by( LikeModel.like_id.desc()).limit(20).all() result = list() for model in like_model_list: user_info = UserInfoModel.query_user_model_by_id(model.user_id) user_info = UserInfoModel.format_user_info(user_info) user_info["like_id"] = model.like_id result.append(user_info) return json_success_response(result)
def check_share_image_price(share_id, user_id): share_image_list = ImageModel.query_share_images(share_id) user_info = UserInfoModel.query_user_model_by_id(user_id) # 认证用户每张照片1块钱, 普通用户每张照片5毛 image_count = len(share_image_list) if user_info.identified == 1: return image_count * 100 else: return image_count * 0.5 * 100
def get(self): result = {"new_comment": 0, "image_url": ""} new_comment = RedisModel.query_new_message(g.account["user_id"], RedisModel.new_comment) result["new_comment"] = new_comment if new_comment: relation_list = CommentRelationModel.query_relation_info( g.account["user_id"], per_page=3, last_cid=0) for model in relation_list: if model.user_id != g.account["user_id"]: user_info = UserInfoModel.query_user_model_by_id( model.user_id) result["image_url"] = UserInfoModel.format_user_info( user_info)["avatar"] break return json_success_response(result)
def get(self, params): RedisModel.reset_new_message(g.account["user_id"], RedisModel.new_comment) comment_list = CommentRelationModel.query_relation_info( g.account["user_id"], 20, params["last_id"]) if not comment_list: return json_success_response(list()) comment_id_list = array_column(comment_list, "comment_id") comment_info_list = CommentModel.query_comment_list(comment_id_list) comment_info_dict = array_column_key(comment_info_list, "comment_id") if not comment_info_list: return json_success_response(list()) result = list() for comment_relation_model in comment_list: share_info = GetCommentHandler.query_share_info( comment_relation_model.share_id) if not share_info: continue if comment_info_dict[comment_relation_model. comment_id].user_id == g.account["user_id"]: continue user_info = UserInfoModel.query_user_model_by_id( comment_relation_model.user_id) item = dict() item["share_id"] = comment_relation_model.share_id item["share_img"] = share_info["image"] item["share_content"] = share_info["content"] item["share_nickname"] = share_info["nickname"] item["content"] = comment_info_dict[ comment_relation_model.comment_id].content item["created_time"] = comment_relation_model.created_time item["status"] = comment_relation_model.status item["comment_id"] = comment_relation_model.comment_id item["user_info"] = UserInfoModel.format_user_info(user_info) result.append(item) return json_success_response(result)
def format_like_info(like_model_list=list()): result = [] if not like_model_list: return result from app.models.account.user_info import UserInfoModel for model in like_model_list: user_info = UserInfoModel.query_user_model_by_id(model.user_id) user_info = UserInfoModel.format_user_info(user_info) item_dict = { "avatar": user_info.get("avatar", ""), "like_id": model.like_id, } result.append(item_dict) return result
def post(self): img_uploader = UploadImage() img_count = db.session.query(func.count( ImageModel.image_id)).filter_by( user_id=g.account["user_id"], status=1).filter(ImageModel.album_id != 0).scalar() photo_count = len(img_uploader.images) + img_count if photo_count > album_max: return json_fail_response(2404) img_uploader.save_images() result = ImageDataModel.config_photo({"user_id": g.account["user_id"]}, img_uploader.images) if result: SocialMetaModel.query.filter_by( user_id=g.account["user_id"]).update({"photo": photo_count}) UserInfoModel.query_user_model_by_id(g.account["user_id"], True) return json_success_response(result)
def format_user_wechat_data(order_meta_list, params, buyer_type="", seller_type=""): order_info_list = OrderInfoModel.query_order_info_model( array_column(order_meta_list, "order_id")) order_info_dict = array_column_key(order_info_list, "order_id") result = list() for order_meta in order_meta_list: item = dict() user_info_model = UserInfoModel.query_user_model_by_id( getattr(order_meta, seller_type, default=0)) item["user_info"] = UserInfoModel.format_user_info( user_info_model) if user_info_model else dict() item["id"] = order_meta.id item["order_id"] = order_meta.order_id order_info = order_info_dict.get(order_meta.order_id) item["price"] = order_info.order_price / 100 if order_info else 0 item["time"] = order_meta["created_time"] wechat_status = UserWeChatModel.format_wechat_status( order_meta, params["user_id"]) item["wechat_complain_status"] = wechat_status.get( "wechat_complain_status", 0) item["wechat_order_status"] = wechat_status.get( "wechat_order_status", 0) if buyer_type == "seller_id": item["wechat"] = order_info.order_message if order_info else "" result.append(item) return result
def get(self): user_id = g.account["user_id"] result = {"user_id": user_id} # Aha 账号 aha_account = AhaAccountModel.query_aha_account_by_id(user_id) result = dict(result, **aha_account) # 社交信息 params = ["vocation_name", "school_name", "language", "emotional_state", "live_region_name"] user_social = UserSocialInfoModel.query_user_social_info(user_id) user_social_dic = user_social.format_model(params) result = dict(result, **user_social_dic) # 个人信息 params = ["weight", "height", "star_sign", "age"] user_personal_model = UserPersonalInfoModel.query_personal_info_by_user_id(user_id) user_personal_dic = user_personal_model.format_model(params) result = dict(result, **user_personal_dic) # 用户信息 user_info_model = UserInfoModel.query_user_model_by_id(user_id) user_info_dic = UserInfoModel.format_user_info(user_info_model) result = dict(result, **user_info_dic) # social_page_dic = SocialPageModel.query_social_page_model(user_id) result["user_banner_type"] = social_page_dic.get("cover_type", 1) result["user_banner"] = social_page_dic.get("cover", "") if social_page_dic["cover_type"] == 2: result["orientation"] = social_page_dic.get("orientation", "") result["user_banner_cover"] = social_page_dic.get("video_img", "") result["album"] = UserInfoModel.query_user_album(user_id) return json_success_response(result)
def get(self, params): social_page_info = SocialPageModel.query_social_page_model(params["user_id"]) result = dict() result["user_banner"] = social_page_info.get("cover", "") result["user_banner_type"] = social_page_info.get("cover_type", 0) if result["user_banner_type"] == 2: result["orientation"] = social_page_info.get("orientation", "") result["user_banner_cover"] = social_page_info.get("video_img", "") result["album"] = UserInfoModel.query_user_album(params["user_id"]) return result
def config_photo(params, image_model_list): album = AlbumModel.query_album_by_user_id(params["user_id"]) user_info = UserInfoModel.query_user_model_by_id(params["user_id"]) if not album: album = AlbumModel() album.user_id = params["user_id"] album.status = 1 album.album_name = user_info.nickname + "的相册" if user_info else "" album.album_cover = "" db.session.add(album) db.session.commit() small_list = [] big_list = [] for image in image_model_list: image = image.get("image", None) if not image: continue image.album_id = album.id image.user_id = params["user_id"] small_list.append({ "url": ImageModel.generate_image_url(image, 'b'), "width": 240, "height": 240, "image_id": image.image_id, }) big_list.append({ "url": ImageModel.generate_image_url(image, "f"), "width": 800, "height": 800, "image_id": image.image_id, }) db.session.commit() return {"small": small_list, "big": big_list}
def query_request_account_by_token(token, refresh=False): """ 通过用户的token交换到用户信息 :param token: 用户的token :param refresh: 是否使用缓存中的数据 """ from app import cache cache_key = account_data_cache_key + token if not refresh: result = cache.get(cache_key) if result: return result account_dict = dict() # 1. 用户access_token信息 access_token = UserAccessTokenModel.query_useful_access_token( token, refresh) user_id = 0 if access_token: user_id = access_token.user_id account_dict = dict(access_token.to_dict(filter_params=True), **account_dict) account = UserAccountModel.query_account_by_user_id(user_id) if account: account_dict = dict(account.to_dict(filter_params=True), **account_dict) user_info = UserInfoModel.query_user_model_by_id(user_id, refresh=refresh) if user_info: account_dict = dict(user_info.to_dict(filter_params=True), **account_dict) cache.set(cache_key, account_dict) return account_dict
def format_share_model(share_info_list=list(), account=0): """ 统一的格式化动态模型 1. 动态格式化 2. 图片格式化 3. 评论格式化 4. 点赞格式化 """ result_list = [] if not share_info_list: return result_list share_id_list = array_column(share_info_list, "share_id") # 获取到share_meta模型(一次sql比多次sql要好) share_meta_list = ShareMetaModel.query_share_meta_model_list(share_id_list, auto_format=False) share_meta_dict = array_column_key(share_meta_list, "share_id") img_model_dict = ImageModel.query_share_image_list(share_id_list) like_status_list = ShareModel.query_share_check_list(account, share_id_list) # 逐条格式化 for share_model in share_info_list: share_dic = share_model.to_dict() share_meta = share_meta_dict.get(share_model.share_id, None) share_dic["like_status"] = 1 if like_status_list.get(share_model.share_id, None) else 0 share_dic["like_count"] = share_meta.like if share_meta else 0 share_dic["comment_count"] = share_meta.comment if share_meta else 0 share_dic["click"] = share_meta.click if share_meta else 0 share_dic["image"] = dict() share_dic["video"] = dict() # 格式化用户信息 from app.models.account.user_info import UserInfoModel user_model = UserInfoModel.query_user_model_by_id(share_model.user_id) share_dic["user_info"] = UserInfoModel.format_user_info(user_model) # 格式化图片信息 if share_model.type_id in [8, 10, 11, 40, 50, 51]: img_model_list = img_model_dict.get(share_model.share_id, None) share_dic["image"] = { "big": ImageModel.format_image_model(img_model_list, size='f'), "small": ImageModel.format_image_model(img_model_list, size='c'), } # 格式化视频信息 elif share_model.type_id in [30, 31]: video_model = VideoModel.query_share_video_info(share_model.share_id) share_dic["video"] = VideoModel.format_video_info(video_model) share_dic["like_list"] = LikeModel.query_like_list(share_model.share_id, limit=5) # 删除无用数据 del share_dic["data"] # 格式化悬赏数据 share_dic["offer_info"] = dict() if share_model.type_id == 90: offer_model = OfferModel.query_offer_mode_with_offer_id(share_model.offer_id) share_dic["offer_info"] = OfferModel.format_offer_info(offer_model, share_model, account) result_list.append(share_dic) return result_list
def get(self, params): if params["user_id"] == 0: return json_fail_response(2101) user_info = UserInfoModel.query_user_model_by_id(params["user_id"]) result = UserInfoModel.format_user_info(user_info) social_meta_info = SocialMetaModel.query_social_meta_info( params["user_id"]) result["share_num"] = social_meta_info.share if social_meta_info else 0 result[ "follow_num"] = social_meta_info.following if social_meta_info else 0 result[ "fans_num"] = social_meta_info.follower if social_meta_info else 0 result["follow_status"] = FollowModel.query_relation_to_user( g.account["user_id"], params["user_id"]) result["album"] = UserInfoModel.query_user_album(params["user_id"]) social_page_info = SocialPageModel.query_social_page_model( params["user_id"]) result["user_banner"] = social_page_info.get("cover", "") result["user_banner_type"] = social_page_info.get("cover_type", 1) if result["user_banner_type"] == 2: result["orientation"] = "" result["user_banner_cover"] = "" if params["user_id"] == g.account["user_id"]: result["profit"] = IndexHandler.query_user_profit( params["user_id"]) if result["identified"] == 1: result["identify_title"] = "官方认证:" + result["identify_title"] result["wechat_info"] = MeHandler.format_wechat_info( params["user_id"], social_meta_info.wechat_want if social_meta_info else 0) user_location = UserLocationModel.query.filter( UserLocationModel.id == user_info.location_id).first() result["latitude"] = user_location.latitude if user_location else 0 result["longitude"] = user_location.longitude if user_location else 0 result["changeable_aha"] = 1 result["aha_id"] = '' aha_info = AhaAccountModel.query_aha_account_by_id(params['user_id'], auto_formated=False) if aha_info: result["changeable_aha"] = aha_info.changeable_aha if aha_info.changeable_aha == 0: result["aha_id"] = aha_info.aha_id # 最近的动态 result["share_info"] = ShareModel.query_recent_share_photo( params['user_id'], g.account["user_id"]) # 是否有交易记录 result["had_trade"] = 1 # 备注昵称 result["remark_name"] = "" last_login = OpenLogModel.query_last_login(params["user_id"]) result["last_login"] = 0 if last_login: result["last_login"] = time.time() - time.mktime( last_login.created_time.timetuple()) # 插入访客记录 if g.account["user_id"] != 0 and g.account["user_id"] != params[ "user_id"]: RedisModel.add_new_message(params["user_id"], RedisModel.new_visitor) VisitorRecordModel(user_id=params["user_id"], visitor_user_id=g.account["user_id"]) return json_success_response(result)