def fix_user(): from app.customer.models.user import User from app.customer.models.real_video_verify import RealVideoVerify users = User.objects.all() for user in users: status = RealVideoVerify.get_status(user.id) if status == 1: user.update(set__is_video_auth=1) else: if user.is_video_auth == 1: desc = u"<html><p>" + _( u'由于您未进行视频认证,将取消您的播主资格,如想再次成为视频播主,请进行申请视频认证,并添加审核人员微信: "honeynnm" ' ) + u"</p></html>" MessageSender.send_system_message(user.id, desc) user.update(set__is_video_auth=4)
def get(self): data = [] user_id = self.current_user_id moment_id = self.arg('moment_id', "") moment = UserMoment.objects.filter(show_status__ne=2, id=moment_id).first() if moment: UserMomentLook.inc_look(user_id, str(moment.id)) like_user_list = moment.like_user_list dic = convert_user_moment(moment) if int(user_id) in like_user_list: is_liked = 1 else: is_liked = 0 dic["is_liked"] = is_liked if moment.type == 3: buy_video_status = VideoPurchaseRecord.get_buy_status( user_id, moment.video_id) dic["buy_video_status"] = buy_video_status user_vip = UserVip.objects.filter(user_id=user_id).first() if user_vip: now = datetime.datetime.now() create_time = now.strftime("%Y-%m-%d") vip_watch_record = VipWatchVideoRecord.objects.filter( user_id=user_id, create_time=create_time, video_id=moment.video_id).first() vip_comment_status = 2 if vip_watch_record: vip_comment_status = 1 dic["vip_comment_status"] = vip_comment_status dic["check_real_video"] = RealVideoVerify.get_status( moment.user_id) data.append(dic) else: return self.write({'status': "fail", 'error': _(u"该动态已经被删除")}) return self.write({"status": "success", "data": data})
def get(self): data = [] current_user_id = self.current_user_id user_id = self.arg("user_id") if int(user_id) == int(current_user_id): videos = PrivateVideo.objects.filter( show_status__ne=2, user_id=user_id, delete_status=1).order_by("-create_time") else: videos = PrivateVideo.objects.filter( show_status=1, user_id=user_id, delete_status=1).order_by("-create_time") if videos: for video in videos: moment = UserMoment.objects.filter( video_id=str(video.id)).order_by("-create_time").first() if moment: dic = convert_user_moment(moment) buy_video_status = VideoPurchaseRecord.get_buy_status( current_user_id, moment.video_id) dic["buy_video_status"] = buy_video_status if user_id: like_user_list = moment.like_user_list if int(user_id) in like_user_list: is_liked = 1 else: is_liked = 0 dic["is_liked"] = is_liked data.append(dic) else: dic["is_liked"] = 0 data.append(dic) dic["check_real_video"] = RealVideoVerify.get_status( moment.user_id) self.write({"status": "success", "data": data})
def get(self): data = [] page = self.arg_int('page') user_id = self.current_user_id page_count = self.arg_int('page_count') # moments = UserMoment.objects.filter(show_status__in=[1, 3, 4], delete_status=1, is_public=1).order_by("-create_time")[(page - 1) * page_count:page * page_count] moments = UserMoment.get_index_moments(page, page_count, self.current_user) if moments: for moment in moments: if moment: dic = convert_user_moment(moment) if user_id: like_user_list = moment.like_user_list if int(user_id) in like_user_list: is_liked = 1 else: is_liked = 0 dic["is_liked"] = is_liked if moment.type == 3: buy_video_status = VideoPurchaseRecord.get_buy_status( user_id, moment.video_id) dic["buy_video_status"] = buy_video_status dic["check_real_video"] = RealVideoVerify.get_status( moment.user_id) data.append(dic) else: dic["is_liked"] = 0 data.append(dic) self.write({"status": "success", "data": data})
def normal_info(self): user_id = self.user_id user = User.objects.filter(id=user_id).first() head_image = user.image age = User.get_age(user.birth_date) create_time = UserMoment.get_time(self.create_time) date_time = self.create_time.strftime('%Y-%m-%d') imgs = self.img_list img_list = [] if imgs: for img in imgs: if int(img["status"]) == 1: img_list.append(img["url"]) moment_look = UserMomentLook.objects.filter( user_moment_id=str(self.id)).first() look_count = 0 if moment_look: look_user_ids = moment_look.user_id_list look_count = len(look_user_ids) price = self.price if not price: price = 0 type = self.type if not type: type = 1 show_video = RealVideoVerify.objects( user_id=user.id, status=1).order_by("-update_time").first() if show_video: real_video_auth = show_video.status else: real_video_auth = 3 if user: data = { "moment_id": str(self.id), "user_id": user.id, "gender": user.gender_desc, "head_image": head_image, "nickname": user.nickname, "age": age, "create_time": create_time, "img_list": img_list, "comment_count": self.comment_count, "like_count": self.like_count, "type": type, "look_count": look_count, "content": self.content, "date_time": date_time, "video_id": self.video_id, "cover_url": self.cover_url, "video_url": self.video_url, "price": price, "real_video_auth": real_video_auth } user_vip = UserVip.objects.filter(user_id=user_id).first() if user_vip: vip = Vip.objects.filter(id=user_vip.vip_id).first() data["vip_icon"] = vip.icon_url return data
def pushredis(self): now_time = int(time.time()) #pre_time = now_time - 120 pre_time = now_time - 3600 # heartbeats = UserHeartBeat.objects.filter(last_report_time__gte=pre_time) stuilabel = "598d7a2418ce423b1222d645" #首推标签id usersss = User.objects.filter(is_video_auth=1, is_block__ne=1).order_by("is_vip") stuianchors = [] for u in usersss: if stuilabel in u.label: stuianchors.append(u) hots = [] users = [] user_recommed_id = [] user_recommed_id_all = [] usermap = {} anchors = Anchor.objects.filter().order_by("seq") for anchor in anchors: user = User.objects.get(id=anchor.sid) user_heart = UserHeartBeat.objects.get(user=user) if user_heart.last_report_time > pre_time and user.disturb_mode != 1: hots.append(user) randomstui = [] for stui in stuianchors: user_heart = UserHeartBeat.objects.get(user=stui) if user_heart.last_report_time > pre_time and stui.disturb_mode != 1: randomstui.append(stui) # hot 和 stulist # random.shuffle(hots) random.shuffle(randomstui) hots = hots + randomstui for user in hots: if user.id in users: continue users.append(user.id) personal_tags = UserTags.get_usertags(user_id=user.id) if not personal_tags: personal_tags = [] user_vip = UserVip.objects.filter(user_id=user.id).first() # time = int(time.time()) # pre_time = time - 120 user_beat = UserHeartBeat.objects.filter( user=user, last_report_time__gte=pre_time).first() if user_beat: is_online = 1 # else: # is_online = 0 user_recommed_id_all.append(user.id) roomrecord = AudioRoomRecord.objects.filter( user_id=user.id).order_by("-open_time").first() if not user_vip: dic = { "user": { "_uid": user.sid, "logo_big": user.image, "nickname": user.nickname, "desc": user.desc }, "personal_tags": personal_tags, "is_online": is_online } else: vip = Vip.objects.filter(id=user_vip.vip_id).first() dic = { "user": { "_uid": user.sid, "logo_big": user.image, "nickname": user.nickname, "desc": user.desc }, "personal_tags": personal_tags, "vip": { "vip_type": vip.vip_type, "icon_url": Vip.convert_http_to_https(vip.icon_url) }, "is_online": is_online } show_video = RealVideoVerify.objects( user_id=user.id, status=1).order_by("-update_time").first() if show_video: dic["check_real_video"] = show_video.status else: real_video = RealVideoVerify.objects( user_id=user.id, status__ne=2).order_by("-update_time").first() if real_video: dic["check_real_video"] = real_video.status else: dic["check_real_video"] = 3 self.append(user.id) usermap[str(user.id)] = json.dumps(dic) if not roomrecord or roomrecord.status == 1: user_recommed_id.append(user.id) deletetui() if user_recommed_id: UserRedis.add_user_recommed_id_v3(user_recommed_id) UserRedis.add_user_recommed_id_all(user_recommed_id_all) UserRedis.add_user_recommed_v3(usermap) push_index_anchor(self)
def push_index_anchor(self): users = [] usermap = {} gaoyanzhi = "597ef92818ce420b6f46ce3f" xinggan = "597ef93418ce420b7d46ce17" yujie = "597ef86b18ce420b6f46ce3c" qingcun = "597ef85718ce420b7d46ce11" nodisllpay = "59956dfb18ce427fa83c9cec" randomvalist1 = [] randomvalist2 = [] randomvalist3 = [] randomvalist4 = [] randomvalist5 = [] randomvalist6 = [] index_id_all = [] anchors = User.objects.filter(is_video_auth=1, is_block__ne=1).order_by("is_vip") for anchor in anchors: if gaoyanzhi in anchor.label and xinggan in anchor.label: randomvalist1.append(anchor) elif gaoyanzhi in anchor.label and qingcun in anchor.label: randomvalist2.append(anchor) else: if xinggan in anchor.label: randomvalist3.append(anchor) elif qingcun in anchor.label: randomvalist6.append(anchor) elif yujie in anchor.label: randomvalist4.append(anchor) elif not anchor.label: randomvalist5.append(anchor) random.shuffle(randomvalist1) random.shuffle(randomvalist2) random.shuffle(randomvalist3) random.shuffle(randomvalist4) random.shuffle(randomvalist5) random.shuffle(randomvalist6) valist1 = randomvalist1 valist2 = randomvalist2 valist3 = randomvalist3 valist4 = randomvalist4 valist5 = randomvalist5 valist6 = randomvalist6 index_id = [] for gaoxing in valist1: if gaoxing not in users and gaoxing.disturb_mode == 0 and gaoxing.audio_room_id != "": users.append(gaoxing) for gaoqing in valist2: if gaoqing not in users and gaoqing.disturb_mode == 0 and gaoqing.audio_room_id != "": users.append(gaoqing) for xing in valist3: if xing not in users and xing.disturb_mode == 0 and xing.audio_room_id != "": users.append(xing) for qing in valist6: if qing not in users and qing.disturb_mode == 0 and qing.audio_room_id != "": users.append(qing) for yu in valist4: if yu not in users and yu.disturb_mode == 0 and yu.audio_room_id != "": users.append(yu) for wu in valist5: if wu not in users and wu.disturb_mode == 0 and wu.audio_room_id != "": users.append(wu) for user in users: #if not user.audio_room_id: # continue if user.id == 1 or user.id == 2: continue try: if user.id not in self and nodisllpay not in user.label: personal_tags = UserTags.get_usertags(user_id=user.id) if not personal_tags: personal_tags = [] user_vip = UserVip.objects.filter(user_id=user.id).first() # 是否在线 查看心跳 import time time = int(time.time()) pre_time = time - 3600 user_beat = UserHeartBeat.objects.filter( user=user, last_report_time__gte=pre_time).first() roomrecord = AudioRoomRecord.objects.filter( user_id=user.id).order_by("-open_time").first() if user_beat and user.disturb_mode != 1: index_id_all.append(user.id) is_online = 1 # 视频认证状态 real_video = RealVideoVerify.objects( user_id=user.id, status__ne=2).order_by("-update_time").first() show_video = RealVideoVerify.objects( user_id=user.id, status=1).order_by("-update_time").first() if user_vip: vip = Vip.objects.filter(id=user_vip.vip_id).first() dic = { "user": { "_uid": user.sid, "logo_big": user.image, "nickname": user.nickname, "desc": user.desc }, "personal_tags": personal_tags, "vip": { "vip_type": vip.vip_type, "icon_url": Vip.convert_http_to_https(vip.icon_url) }, "is_online": is_online } else: dic = { "user": { "_uid": user.sid, "logo_big": user.image, "nickname": user.nickname, "desc": user.desc }, "personal_tags": personal_tags, "is_online": is_online } if show_video: dic["check_real_video"] = show_video.status else: if real_video: dic["check_real_video"] = real_video.status else: dic["check_real_video"] = 3 usermap[str(user.id)] = json.dumps(dic) if not roomrecord or roomrecord.status == 1: index_id.append(user.id) except Exception, e: print e
def oldcommonlist(): now_time = int(time.time()) pre_time = now_time - 120 heartbeats = UserHeartBeat.objects.filter(last_report_time__gte=pre_time) hots = [] anchors = Anchor.objects.all() hot_ids = [] hot_list = [] for anchor in anchors: user = User.objects.get(id=anchor.sid) user_heart = UserHeartBeat.objects.get(user=user) if user_heart.last_report_time > pre_time and user.disturb_mode != 1: hots.append(user) hot_ids.append(user.id) for heartbeat in heartbeats: if heartbeat.user.charm_value > 3500 and heartbeat.user.disturb_mode != 1 \ and heartbeat.user.id not in hot_ids and heartbeat.user.is_video_auth == 1: hots.append(heartbeat.user) if not hots: hots = User.objects.filter( is_video_auth=1).order_by("-charm_value")[0:4] for user in hots: room = AudioRoomRecord.objects.get(id=user.audio_room_id) personal_tags = UserTags.get_usertags(user_id=room.user_id) if not personal_tags: personal_tags = [] user_vip = UserVip.objects.filter(user_id=user.id).first() # time = int(time.time()) # pre_time = time - 120 user_beat = UserHeartBeat.objects.filter( user=user, last_report_time__gte=pre_time).first() if user_beat: is_online = 1 else: is_online = 0 if not user_vip: dic = { "audioroom": convert_audioroom(room), "user": convert_user(user), "personal_tags": personal_tags, "time_stamp": int(time.time()), "is_online": is_online } else: vip = Vip.objects.filter(id=user_vip.vip_id).first() dic = { "audioroom": convert_audioroom(room), "user": convert_user(user), "personal_tags": personal_tags, "time_stamp": int(time.time()), "vip": convert_vip(vip), "is_online": is_online } show_video = RealVideoVerify.objects( user_id=user.id, status=1).order_by("-update_time").first() if show_video: dic["check_real_video"] = show_video.status else: real_video = RealVideoVerify.objects( user_id=user.id, status__ne=2).order_by("-update_time").first() if real_video: dic["check_real_video"] = real_video.status else: dic["check_real_video"] = 3 hot_list.append(json.dumps(dic)) return hot_list
def get(self): user_id = self.current_user_id is_old = True if user_id: is_target = (self.current_user.is_video_auth != 1 and UserRedis.is_target_user(user_id)) or \ (self.current_user.is_video_auth == 1 and not UserRedis.is_pure_anchor(user_id)) if not is_target: is_old = False else: is_old = False column_type = self.arg_int('column_type') page = self.arg_int('page') page_count = self.arg_int('page_count') nodisplay = "59956dfb18ce427fa83c9cec" data = [] if is_old: if column_type == 2: # 新人驾到 anchor_list = NewAnchorRank.objects.all() if anchor_list: anchor_list = anchor_list[(page - 1) * page_count:page * page_count] for anchor in anchor_list: user = User.objects.filter(id=anchor.user_id, is_video_auth=1).first() if not user: continue if user.disturb_mode != 1: if nodisplay not in user.label: if user.id == 1 or user.id == 2: continue if not user.audio_room_id: continue # 是否在线 查看心跳 import time time = int(time.time()) pre_time = time - 3600 user_beat = UserHeartBeat.objects.filter( user=user, last_report_time__gte=pre_time).first() if user_beat: is_online = 1 if not user.audio_room_id: AudioRoomRecord.create_roomrecord( user.id, datetime.datetime.now()) audioroom = AudioRoomRecord.objects.get( id=user.audio_room_id) personal_tags = UserTags.get_usertags( user_id=user.id) user_vip = UserVip.objects.filter( user_id=user.id).first() if user_vip: vip = Vip.objects.filter( id=user_vip.vip_id).first() dic = { "audioroom": convert_audioroom(audioroom), "user": convert_user(user), "personal_tags": personal_tags, "vip": convert_vip(vip), "is_online": is_online } else: dic = { "audioroom": convert_audioroom(audioroom), "user": convert_user(user), "is_online": is_online, "personal_tags": personal_tags } # 视频认证状态 real_video = RealVideoVerify.objects( user_id=user.id, status__ne=2).order_by( "-update_time").first() show_video = RealVideoVerify.objects( user_id=user.id, status=1).order_by( "-update_time").first() if show_video: dic["check_real_video"] = show_video.status else: if real_video: dic["check_real_video"] = real_video.status else: dic["check_real_video"] = 3 data.append(dic) else: recommed_list = UserRedis.get_recommed_list_pure() anchor_list = UserRedis.get_index_anchor_list_pure(0, -1) finaluser = recommed_list + anchor_list finaluser = finaluser[(page - 1) * page_count:page * page_count] if len(finaluser) > 0: for anchorid in finaluser: user = User.objects.filter(id=int(anchorid)).first() import time time = int(time.time()) pre_time = time - 3600 user_beat = UserHeartBeat.objects.filter( user=user, last_report_time__gte=pre_time).first() if user_beat: is_online = 1 else: is_online = 0 if not user.audio_room_id: AudioRoomRecord.create_roomrecord( user.id, datetime.datetime.now()) audioroom = AudioRoomRecord.objects.get( id=user.audio_room_id) personal_tags = UserTags.get_usertags(user_id=user.id) user_vip = UserVip.objects.filter(user_id=user.id).first() if user_vip: vip = Vip.objects.filter(id=user_vip.vip_id).first() dic = { "audioroom": convert_audioroom(audioroom), "user": convert_user(user), "personal_tags": personal_tags, "vip": convert_vip(vip), "is_online": is_online } else: dic = { "audioroom": convert_audioroom(audioroom), "user": convert_user(user), "is_online": is_online, "personal_tags": personal_tags } # 视频认证状态 real_video = RealVideoVerify.objects( user_id=user.id, status__ne=2).order_by("-update_time").first() show_video = RealVideoVerify.objects( user_id=user.id, status=1).order_by("-update_time").first() if show_video: dic["check_real_video"] = show_video.status else: if real_video: dic["check_real_video"] = real_video.status else: dic["check_real_video"] = 3 data.append(dic) return self.write({ "status": "success", "data": data, })
def push_index_anchor(self): users = [] usermap = {} qingcun = "597ef85718ce420b7d46ce11" randomvalist1 = [] index_id_all = [] anchors = User.objects.filter(is_video_auth=1, is_block__ne=1).order_by("is_vip") for anchor in anchors: if qingcun in anchor.label: randomvalist1.append(anchor) index_id = [] for qingcun in randomvalist1: if qingcun not in users: users.append(qingcun) zaixianbururao = [] zaixiancall = [] zaixianwurao = [] lixian = [] for user in users: if user.id == 1 or user.id == 2: continue import time time = int(time.time()) pre_time = time - 3600 user_beat = UserHeartBeat.objects.filter( user=user, last_report_time__gte=pre_time).first() if user_beat: if user.audio_status == 2: if user.disturb_mode == 0: zaixianbururao.append(user) else: zaixianwurao.append(user) else: zaixiancall.append(user) else: lixian.append(user) finalusers = zaixianbururao + zaixiancall for user in finalusers: if user.id not in self: index_id_all.append(user.id) personal_tags = UserTags.get_usertags(user_id=user.id) if not personal_tags: personal_tags = [] user_vip = UserVip.objects.filter(user_id=user.id).first() is_online = 1 if user_vip: vip = Vip.objects.filter(id=user_vip.vip_id).first() dic = { "user": { "_uid": user.sid, "logo_big": user.image, "nickname": user.nickname, "desc": user.desc }, "personal_tags": personal_tags, "vip": { "vip_type": vip.vip_type, "icon_url": Vip.convert_http_to_https(vip.icon_url) }, "is_online": is_online } dic["check_real_video"] = 1 else: dic = { "user": { "_uid": user.sid, "logo_big": user.image, "nickname": user.nickname, "desc": user.desc }, "personal_tags": personal_tags, "is_online": is_online } dic["check_real_video"] = 1 usermap[str(user.id)] = json.dumps(dic) index_id.append(user.id) lixian = zaixianwurao + lixian for user in lixian: if user.id not in self: index_id_all.append(user.id) personal_tags = UserTags.get_usertags(user_id=user.id) if not personal_tags: personal_tags = [] user_vip = UserVip.objects.filter(user_id=user.id).first() is_online = 0 # 视频认证状态 real_video = RealVideoVerify.objects( user_id=user.id, status__ne=2).order_by("-update_time").first() show_video = RealVideoVerify.objects( user_id=user.id, status=1).order_by("-update_time").first() if user_vip: vip = Vip.objects.filter(id=user_vip.vip_id).first() dic = { "user": { "_uid": user.sid, "logo_big": user.image, "nickname": user.nickname, "desc": user.desc }, "personal_tags": personal_tags, "vip": { "vip_type": vip.vip_type, "icon_url": Vip.convert_http_to_https(vip.icon_url) }, "is_online": is_online } dic["check_real_video"] = 1 else: dic = { "user": { "_uid": user.sid, "logo_big": user.image, "nickname": user.nickname, "desc": user.desc }, "personal_tags": personal_tags, "is_online": is_online } dic["check_real_video"] = 1 usermap[str(user.id)] = json.dumps(dic) index_id.append(user.id) deleteanchor() print "==================index_id", index_id UserRedis.add_index_id_pure(index_id) UserRedis.add_index_id_all_pure(index_id_all) UserRedis.add_index_anchor_pure(usermap) print "=============首页清纯数据入redis完毕"
def pushredis(self): now_time = int(time.time()) # pre_time = now_time - 120 pre_time = now_time - 3600 # heartbeats = UserHeartBeat.objects.filter(last_report_time__gte=pre_time) stuilabel = "598d7a2418ce423b1222d645" usersss = User.objects.filter(is_video_auth=1, is_block__ne=1).order_by("is_vip") stuianchors = [] for u in usersss: if stuilabel in u.label: stuianchors.append(u) hots = [] users = [] user_recommed_id = [] usermap = {} anchors = Anchor.objects.filter().order_by("seq") for anchor in anchors: user = User.objects.get(id=anchor.sid) user_heart = UserHeartBeat.objects.get(user=user) if user_heart.last_report_time > pre_time and user.disturb_mode != 1: hots.append(user) print "===================在线的热门主播", user.id stuilist = [] for stui in stuianchors: user_heart = UserHeartBeat.objects.get(user=stui) if user_heart.last_report_time > pre_time and stui.disturb_mode != 1: show_video = RealVideoVerify.objects( user_id=stui.id, status=1).order_by("-update_time").first() if show_video: stuilist.insert(0, stui) else: stuilist.append(stui) hots = hots + stuilist # for heartbeat in heartbeats: # if heartbeat.user.charm_value > 3500 and heartbeat.user.disturb_mode != 1 \ # and heartbeat.user.id not in hot_ids and heartbeat.user.is_video_auth == 1: # hots.append(heartbeat.user) # if not hots: # hots = User.objects.filter(is_video_auth=1).order_by("-charm_value")[0:4] for h in hots: roomrecord = AudioRoomRecord.objects.filter( user_id=h.id).order_by("-open_time").first() if h not in users: if not roomrecord or roomrecord.status == 1: users.append(h) for user in users: personal_tags = UserTags.get_usertags(user_id=user.id) if not personal_tags: personal_tags = [] user_vip = UserVip.objects.filter(user_id=user.id).first() # time = int(time.time()) # pre_time = time - 120 user_beat = UserHeartBeat.objects.filter( user=user, last_report_time__gte=pre_time).first() if user_beat: is_online = 1 else: is_online = 0 if not user_vip: dic = { "user": convert_user(user), "personal_tags": personal_tags, "time_stamp": int(time.time()), "is_online": is_online } else: vip = Vip.objects.filter(id=user_vip.vip_id).first() dic = { "user": convert_user(user), "personal_tags": personal_tags, "time_stamp": int(time.time()), "vip": convert_vip(vip), "is_online": is_online } show_video = RealVideoVerify.objects( user_id=user.id, status=1).order_by("-update_time").first() if show_video: dic["check_real_video"] = show_video.status else: real_video = RealVideoVerify.objects( user_id=user.id, status__ne=2).order_by("-update_time").first() if real_video: dic["check_real_video"] = real_video.status else: dic["check_real_video"] = 3 user_recommed_id.append(user.id) self.append(user.id) usermap[str(user.id)] = json.dumps(dic) deletetui() if user_recommed_id: UserRedis.add_user_recommed_id(user_recommed_id) UserRedis.add_user_recommed(usermap) push_index_anchor(self)
def push_index_anchor(self): users = [] usermap = {} gaoyanzhi = "597ef92818ce420b6f46ce3f" xinggan = "597ef93418ce420b7d46ce17" yujie = "597ef86b18ce420b6f46ce3c" qingcun = "597ef85718ce420b7d46ce11" nodisllpay = "59956dfb18ce427fa83c9cec" valist1 = [] valist2 = [] valist3 = [] valist4 = [] valist5 = [] index_id = [] anchors = User.objects.filter(is_video_auth=1, is_block__ne=1).order_by("is_vip") for anchor in anchors: if gaoyanzhi in anchor.label and xinggan in anchor.label: if anchor not in users: show_video = RealVideoVerify.objects( user_id=anchor.id, status=1).order_by("-update_time").first() if show_video: valist1.insert(0, anchor) else: valist1.append(anchor) elif gaoyanzhi in anchor.label and qingcun in anchor.label: if anchor not in users: show_video = RealVideoVerify.objects( user_id=anchor.id, status=1).order_by("-update_time").first() if show_video: valist2.insert(0, anchor) else: valist2.append(anchor) else: if xinggan in anchor.label: if anchor not in users: show_video = RealVideoVerify.objects( user_id=anchor.id, status=1).order_by("-update_time").first() if show_video: valist3.insert(0, anchor) else: valist3.append(anchor) elif yujie in anchor.label: if anchor not in users: show_video = RealVideoVerify.objects( user_id=anchor.id, status=1).order_by("-update_time").first() if show_video: valist4.insert(0, anchor) else: valist4.append(anchor) elif not anchor.label: show_video = RealVideoVerify.objects( user_id=anchor.id, status=1).order_by("-update_time").first() if show_video: valist5.insert(0, anchor) else: valist5.append(anchor) for gaoxing in valist1: if gaoxing not in users and gaoxing.disturb_mode == 0 and gaoxing.audio_room_id != "": users.append(gaoxing) for gaoqing in valist2: if gaoqing not in users and gaoqing.disturb_mode == 0 and gaoqing.audio_room_id != "": users.append(gaoqing) for xing in valist3: if xing not in users and xing.disturb_mode == 0 and xing.audio_room_id != "": users.append(xing) for yu in valist4: if yu not in users and yu.disturb_mode == 0 and yu.audio_room_id != "": users.append(yu) for wu in valist5: if wu not in users and wu.disturb_mode == 0 and wu.audio_room_id != "": users.append(wu) for user in users: #if not user.audio_room_id: # continue if user.id == 1 or user.id == 2: continue try: if user.id not in self and nodisllpay not in user.label: audioroom = AudioRoomRecord.objects.get(id=user.audio_room_id) personal_tags = UserTags.get_usertags(user_id=user.id) if not personal_tags: personal_tags = [] user_vip = UserVip.objects.filter(user_id=user.id).first() # 是否在线 查看心跳 import time time = int(time.time()) pre_time = time - 3600 user_beat = UserHeartBeat.objects.filter( user=user, last_report_time__gte=pre_time).first() roomrecord = AudioRoomRecord.objects.filter( user_id=user.id).order_by("-open_time").first() if user_beat and user.disturb_mode != 1: if not roomrecord or roomrecord.status == 1: is_online = 1 # 视频认证状态 real_video = RealVideoVerify.objects( user_id=user.id, status__ne=2).order_by("-update_time").first() show_video = RealVideoVerify.objects( user_id=user.id, status=1).order_by("-update_time").first() if user_vip: vip = Vip.objects.filter( id=user_vip.vip_id).first() dic = { "audioroom": convert_audioroom(audioroom), "user": convert_user(user), "personal_tags": personal_tags, "time_stamp": datetime_to_timestamp(audioroom.open_time), "vip": convert_vip(vip), "is_online": is_online } else: dic = { "audioroom": convert_audioroom(audioroom), "user": convert_user(user), "personal_tags": personal_tags, "time_stamp": datetime_to_timestamp(audioroom.open_time), "is_online": is_online } if show_video: dic["check_real_video"] = show_video.status else: if real_video: dic["check_real_video"] = real_video.status else: dic["check_real_video"] = 3 index_id.append(user.id) usermap[str(user.id)] = json.dumps(dic) except Exception, e: print e
def get(self): user = self.current_user user_id = self.current_user_id if not user_id: return self.write({"status": "success", "data": []}) list_type = self.arg_int("list_type") show_user_id = self.arg_int("show_user_id", 0) page = self.arg_int('page') page_count = self.arg_int('page_count') data = [] if list_type == 1: # 我的动态 moments = UserMoment.objects.filter( user_id=user.id, show_status__ne=2, delete_status=1, is_public=1).order_by("-create_time")[(page - 1) * page_count:page * page_count] elif list_type == 2: # 我的关注动态 follow_users = FollowUser.objects.filter(from_id=user.id) friend_users = FriendUser.objects.filter(from_id=user.id) user_ids = [] if follow_users: for follow_user in follow_users: fo_uid = follow_user.to_id if fo_uid not in user_ids: user_ids.append(fo_uid) if friend_users: for friend_user in friend_users: fr_uid = friend_user.to_id if fr_uid not in user_ids: user_ids.append(fr_uid) is_spec = False if self.current_user.is_video_auth != 1 and not UserRedis.is_target_user( user_id): is_pure = 1 is_spec = True elif self.current_user.is_video_auth == 1 and not UserRedis.is_pure_anchor( user_id): is_pure = 2 is_spec = True if not is_spec: moments = UserMoment.objects.filter( user_id__in=user_ids, show_status__in=[1, 3, 4], delete_status=1, is_public=1).order_by("-create_time")[(page - 1) * page_count:page * page_count] else: moments = UserMoment.objects.filter( user_id__in=user_ids, show_status__in=[1, 3, 4], delete_status=1, is_public=1, is_pure=is_pure).order_by("-create_time")[(page - 1) * page_count:page * page_count] elif list_type == 3: # 临时加一个 判断我的. 稍后客户端把lsit_type修复 if show_user_id == int(user_id): moments = UserMoment.objects.filter( user_id=user.id, show_status__ne=2, delete_status=1, is_public=1).order_by("-create_time")[(page - 1) * page_count:page * page_count] else: # 其他用户动态 moments = UserMoment.objects.filter( user_id=show_user_id, show_status__in=[1, 3, 4], delete_status=1, is_public=1).order_by("-create_time")[(page - 1) * page_count:page * page_count] if moments: for moment in moments: like_user_list = moment.like_user_list dic = convert_user_moment(moment) if int(user_id) in like_user_list: is_liked = 1 else: is_liked = 0 dic["is_liked"] = is_liked if moment.type == 3: buy_video_status = VideoPurchaseRecord.get_buy_status( user_id, moment.video_id) dic["buy_video_status"] = buy_video_status dic["check_real_video"] = RealVideoVerify.get_status( moment.user_id) data.append(dic) return self.write({"status": "success", "data": data})
def get(self): cover_url = self.arg("cover_url") video_url = self.arg("video_url") file_id = self.arg("file_id", "") user_id = self.current_user_id video_verify = RealVideoVerify() now = datetime.datetime.now() video_verify.user_id = int(user_id) video_verify.cover_url = cover_url video_verify.video_url = video_url video_verify.feedback_reason = "" video_verify.create_time = now video_verify.update_time = now video_verify.status = 0 video_verify.is_valid = 1 video_verify.file_id = file_id video_verify.save() self.write({"status": "success"})
def get(self): user_id = self.current_user_id user = self.current_user cover_url = self.arg('cover_url') video_url = self.arg('video_url') publish_status = self.arg_int('publish_status', 1) desc = self.arg('desc', "") file_id = self.arg('file_id', "") price = self.arg_int('price', 0) real_video_auth = RealVideoVerify.get_status(user_id) if int(real_video_auth) != 1: return self.write({ "status": "fail", 'error': _(u"视频认证通过后才可发布私房视频") }) code, message = PrivateVideo.check_video_count(user) if code == 2: return self.write({"status": "fail", 'error': _(message)}) if desc: # 文本内容鉴黄 ret, duration = shumei_text_spam(text=desc, timeout=1, user_id=user.id, channel="DYNAMIC_COMMENT", nickname=user.nickname, phone=user.phone, ip=self.user_ip) print ret is_pass = 0 if ret["code"] == 1100: if ret["riskLevel"] == "PASS": is_pass = 1 if ret["riskLevel"] == "REJECT": is_pass = 0 if ret["riskLevel"] == "REVIEW": # todo +人工审核逻辑 is_pass = 1 if not is_pass: return self.write({ 'status': "fail", 'error': _(u"经系统检测,您的内容涉及违规因素,请重新编辑") }) video = PrivateVideo() video.desc = desc video.user_id = int(user_id) video.cover_url = cover_url video.video_url = video_url video.price = price video.create_time = datetime.datetime.now() video.delete_status = 1 video.show_status = 3 video.is_valid = 1 video.file_id = file_id video.save() user_moment = UserMoment() user_moment.user_id = user_id user_moment.like_count = 0 user_moment.like_user_list = [] user_moment.comment_count = 0 user_moment.img_list = [] user_moment.content = desc user_moment.create_time = datetime.datetime.now() user_moment.show_status = 5 # 1:展示 2:数美屏蔽 3:举报 4:数美部分屏蔽 5:数美鉴定中 user_moment.delete_status = 1 # 1:未删除 2:删除 user_moment.ispass = 2 user_moment.type = 3 user_moment.video_id = str(video.id) user_moment.cover_url = cover_url user_moment.video_url = video_url user_moment.price = video.price # 同步到动态 if publish_status == 2: code, message = UserMoment.check_moment_count(user) if code == 2: return self.write({'status': "fail", 'error': _(message)}) user_moment.is_public = 1 else: user_moment.is_public = 2 user_moment.save() from app_redis.user.models.user import UserRedis pure_id = "597ef85718ce420b7d46ce11" if user.is_video_auth == 1: if user.label: if pure_id in user.label: user_moment.update(set__is_pure=1) else: user_moment.update(set__is_pure=3) else: user_moment.update(set__is_pure=3) else: if UserRedis.is_target_user(user.id): user_moment.update(set__is_pure=2) else: user_moment.update(set__is_pure=4) return self.write({"status": "success"})
def send_activity_tools(cls, user_id): from app.customer.models.real_video_verify import RealVideoVerify now = datetime.datetime.now() now_str = now.strftime('%Y-%m-%d 23:59:59') hm = cls.get_hm(now) activity_id = "" user = User.objects.filter(id=user_id).first() receive_data = {} if user.is_video_auth == 1: # 主播 verify = RealVideoVerify.objects( user_id=user.id, status=1).order_by("-update_time").first() if not verify: return if not verify.update_time: return verify_time = verify.update_time temp_end_time = verify_time + datetime.timedelta(days=7) endtime = temp_end_time.strftime('%Y-%m-%d 23:59:59') # 6-22 之前认证的都属于老主播 compare_time = datetime.datetime(2017, 6, 21) if verify_time < compare_time or datetime.datetime.strptime( endtime, "%Y-%m-%d %H:%M:%S") < now: # 老主播 status, activity = cls.check_receive(2, now, user_id) if status == 3: receive_data = eval(activity.tools_data) activity_id = str(activity.id) else: # 新主播 status, activity = cls.check_receive(1, now, user_id) if status == 3: receive_data = eval(activity.tools_data) activity_id = str(activity.id) else: # 非主播 if int(user.gender) == 1: status, activity = cls.check_receive(3, now, user_id) if status == 3: receive_data = eval(activity.tools_data) activity_id = str(activity.id) if receive_data: for key, value in receive_data.items(): tools = Tools.objects.filter(tools_type=int(key)).first() # 道具 user_tools = UserTools() user_tools.user_id = user_id user_tools.tools_id = str(tools.id) user_tools.tools_count = int(value) user_tools.time_type = 0 user_tools.get_type = 4 invalid_time = now + datetime.timedelta(days=1) user_tools.invalid_time = invalid_time user_tools.save() tools_record = UserToolsRecord() tools_record.user_id = user_id tools_record.tools_id = str(tools.id) tools_record.tools_count = 1 tools_record.time_type = 0 tools_record.oper_type = 4 tools_record.create_time = now tools_record.save() activity_record = ToolsActivityRecord() activity_record.user_id = user_id activity_record.date_time = datetime.datetime( now.year, now.month, now.day) activity_record.tools_activity_id = activity_id activity_record.save() desc = u"<html><p>" + _( u'您的活动奖励已发送至您的账户,在"我的道具"中,请注意查收,希望您在我们平台玩得开心~' ) + u"</p></html>" MessageSender.send_system_message(user.sid, desc)