|
|
@@ -205,8 +205,10 @@ def get_player_match_detail(request):
|
|
|
match = cm.Match.objects.filter(id=match_id).values().first()
|
|
|
groups = list(cm.MatchGroup.objects.filter(match_id=match_id).values_list("name",flat=True))
|
|
|
match["groups"] = groups
|
|
|
- if records_set:
|
|
|
- records = list(records_set.values())
|
|
|
+
|
|
|
+ all_records_set = cm.PlayerRecord.get_db_model(match_id).objects.filter(user_id=cur_user_id,match_id=match_id).order_by("-stock_date")
|
|
|
+ if all_records_set:
|
|
|
+ records = list(all_records_set.values())
|
|
|
else:
|
|
|
records = []
|
|
|
|
|
|
@@ -239,7 +241,7 @@ def get_player_match_detail(request):
|
|
|
badest = cm.PlayerRecord.get_db_model(match_id).objects.filter(user_id=cur_user_id,match_id=match_id).order_by("today_income").first()
|
|
|
if badest:
|
|
|
today_record["badest_income"] = "{}%".format(badest.today_income*100)
|
|
|
- today_record["today_stock_total"] = round(today_record["today_stock_total"],4)
|
|
|
+ today_record["today_stock_total"] = round(today_record.get("today_stock_total",0.0),4)
|
|
|
userinfo = get_user_info(today_record["user_id"])
|
|
|
today_record["style"] = userinfo.get("style")
|
|
|
|
|
|
@@ -287,10 +289,10 @@ def get_today_record(player_id,match_id,match_group,today):
|
|
|
today_record = ccc.cache.get(key)
|
|
|
today_record = json.loads(today_record) if today_record else {}
|
|
|
|
|
|
- if match_id:
|
|
|
- #记得这里上线后要注释掉
|
|
|
- today_record = cm.PlayerRecord.get_db_model(match_id).objects.filter(user_id=player_id,match_id=match_id,stock_date=today)
|
|
|
- today_record = today_record.values().first()
|
|
|
+ #if match_id:
|
|
|
+ # #记得这里上线后要注释掉
|
|
|
+ # today_record = cm.PlayerRecord.get_db_model(match_id).objects.filter(user_id=player_id,match_id=match_id,stock_date=today)
|
|
|
+ # today_record = today_record.values().first()
|
|
|
|
|
|
try:
|
|
|
if today_record:
|
|
|
@@ -335,11 +337,18 @@ def format_today_record(today_record):
|
|
|
today_record["cangwei"] = "{}%".format(round(today_stock_total/today_record["today_fund"],4)*100)
|
|
|
today_record["today_stock_total"] = today_stock_total
|
|
|
|
|
|
- win_rate = ccc.cache.hget("PLAYER_LATEST_%d" % today_record["user_id"],"win_rate")
|
|
|
- if win_rate:
|
|
|
- today_record["win_rate"] = str(float(win_rate)*100)+"%"
|
|
|
- else:
|
|
|
- today_record["win_rate"] = "0.0%"
|
|
|
+ #win_rate = ccc.cache.hget("PLAYER_LATEST_%d" % today_record["user_id"],"win_rate")
|
|
|
+ #if win_rate:
|
|
|
+ # today_record["win_rate"] = str(float(win_rate)*100)+"%"
|
|
|
+ #else:
|
|
|
+ # today_record["win_rate"] = "0.0%"
|
|
|
+
|
|
|
+ #
|
|
|
+ win_rate = calc_win_rate(today_record["user_id"],today_record["match_id"])
|
|
|
+ today_record["win_rate"] = win_rate
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
except Exception as e:
|
|
|
import traceback
|
|
|
traceback.print_exc()
|
|
|
@@ -355,8 +364,6 @@ def get_today_record_actual(player_id,match_id,match_group,today=None):
|
|
|
else:
|
|
|
qset = cm.PlayerRecord.get_db_model(match_id).objects.filter(match_id=match_id,match_group=match_group,player_id=player_id).order_by("-stock_date")
|
|
|
today_record = qset.values().first()
|
|
|
- print(player_id,match_id,match_group,today,4444444444444444444)
|
|
|
- print(today_record,1111111111)
|
|
|
|
|
|
if today_record:
|
|
|
user_info = get_user_info(today_record["user_id"])
|
|
|
@@ -384,9 +391,10 @@ def get_match_group_players(match_id,match_group):
|
|
|
return players
|
|
|
|
|
|
|
|
|
-@ccc.cache_data()
|
|
|
+#@ccc.cache_data()
|
|
|
def get_match_group_users(match_id,match_group):
|
|
|
- users = list(cm.UserMatch.objects.filter(match_id=match_id,match_group=match_group).values())
|
|
|
+ #users = list(cm.UserMatch.objects.filter(match_id=match_id,match_group=match_group).values())
|
|
|
+ users = list(cm.Player.objects.filter(match_id=match_id,match_group=match_group).values())
|
|
|
return users
|
|
|
|
|
|
@ccc.cache_data()
|
|
|
@@ -409,7 +417,8 @@ def get_cache_rank_list(match_id,today):
|
|
|
loss_count = 0
|
|
|
for player in players:
|
|
|
user_id = player["user_id"]
|
|
|
- username = player["signup_name"]
|
|
|
+ #username = player["signup_name"]
|
|
|
+ username = player["username"]
|
|
|
match_group = player["match_group"]
|
|
|
|
|
|
today_record = ccc.get_today_record(user_id,match_id,match_group,today)
|
|
|
@@ -477,6 +486,19 @@ def get_user_info(uid):
|
|
|
return user
|
|
|
|
|
|
|
|
|
+def get_user_info_actual(uid):
|
|
|
+ user = cm.UserInfo.objects.filter(id=uid).values().first()
|
|
|
+ if user:
|
|
|
+ user["style"] = []
|
|
|
+ if user["zq"]:
|
|
|
+ user["style"].append(user["zq"])
|
|
|
+ if user["cw"]:
|
|
|
+ user["style"].append(user["cw"])
|
|
|
+ if user["df"]:
|
|
|
+ user["style"].append(user["df"])
|
|
|
+ return user
|
|
|
+
|
|
|
+
|
|
|
#@ccc.cache_data()
|
|
|
def get_player_info(player_id):
|
|
|
player = cm.Player.objects.filter(id=player_id).values().first()
|
|
|
@@ -490,8 +512,11 @@ def get_match_info(match_id):
|
|
|
@ccc.cache_data()
|
|
|
def get_group_info(group_id):
|
|
|
group = cm.MatchGroup.objects.filter(id=group_id).values().first()
|
|
|
- group["players_num"] = cm.Player.objects.filter(match_group=group["id"]).count()
|
|
|
- return group
|
|
|
+ if group:
|
|
|
+ group["players_num"] = cm.Player.objects.filter(match_group=group["id"]).count()
|
|
|
+ return group
|
|
|
+ else:
|
|
|
+ return {}
|
|
|
|
|
|
|
|
|
def get_group_rank_list(request):
|
|
|
@@ -517,7 +542,8 @@ def get_group_rank_list(request):
|
|
|
user_id = player["user_id"]
|
|
|
#user = get_user_info(user_id)
|
|
|
#username = user["username"] if user else ""
|
|
|
- username = player["signup_name"]
|
|
|
+ #username = player["signup_name"]
|
|
|
+ username = player["username"]
|
|
|
|
|
|
match_group = group_id
|
|
|
today_record = ccc.get_today_record(user_id,match_id,match_group,today)
|
|
|
@@ -613,8 +639,7 @@ def add_model(cls,**kwargs):
|
|
|
stock_date = kwargs.get("stock_date")
|
|
|
|
|
|
now = datetime.datetime.now()
|
|
|
- print(user_id,match_id)
|
|
|
- if not cm.UserMatch.objects.filter(user_id=user_id,match_id=match_id).exists():
|
|
|
+ if not cm.Player.objects.filter(user_id=user_id,match_id=match_id).exists():
|
|
|
raise ce.TipException(u"请先完成报名再提交数据!")
|
|
|
|
|
|
if now.weekday() in [5,6] or not now.strftime("%Y-%m-%d") in get_match_validdates(match_id):
|
|
|
@@ -622,7 +647,7 @@ def add_model(cls,**kwargs):
|
|
|
|
|
|
now_time = datetime.datetime.now().strftime("%H:%S")
|
|
|
|
|
|
- if not user_id in [9600,6209,5709]:
|
|
|
+ if not user_id in [9600,6209,5709,25953]:
|
|
|
if now_time<"15:00" or now_time > "23:50":
|
|
|
raise ce.TipException(u"当日数据请在当日15:00以后23:50以前提交数据!")
|
|
|
|
|
|
@@ -641,7 +666,7 @@ def add_model(cls,**kwargs):
|
|
|
if float(today_fund)>9999 or float(today_fund)<=0:
|
|
|
raise ce.TipException(u"数据错误,今日净资产不能超过9999万元,不能低于0万元,请仔细核对数据!")
|
|
|
|
|
|
- player = cm.UserMatch.objects.filter(user_id=user_id,match_id=match_id).first()
|
|
|
+ player = cm.Player.objects.filter(user_id=user_id,match_id=match_id).first()
|
|
|
|
|
|
user_id = player.user_id
|
|
|
init_fund = player.fund
|
|
|
@@ -681,9 +706,14 @@ def add_model(cls,**kwargs):
|
|
|
yesterday_stock = ""
|
|
|
yesterday_stock_img = ""
|
|
|
yesterday_is_markt = 0
|
|
|
- if not cm.PlayerRecord.get_db_model(match_id).objects.filter(match_id=match_id,user_id=user_id).exists():
|
|
|
- init_fund = today_fund
|
|
|
- cm.UserMatch.objects.filter(id=user_id,match_id=match_id).update(fund=today_fund)
|
|
|
+ if kwargs.get("id"):
|
|
|
+ if cm.PlayerRecord.get_db_model(match_id).objects.filter(match_id=match_id,user_id=user_id).count()==1:
|
|
|
+ init_fund = today_fund
|
|
|
+ cm.Player.objects.filter(user_id=user_id,match_id=match_id).update(fund=today_fund)
|
|
|
+ else:
|
|
|
+ if not cm.PlayerRecord.get_db_model(match_id).objects.filter(match_id=match_id,user_id=user_id).exists():
|
|
|
+ init_fund = today_fund
|
|
|
+ cm.Player.objects.filter(user_id=user_id,match_id=match_id).update(fund=today_fund)
|
|
|
|
|
|
with transaction.atomic():
|
|
|
#记录持股情况
|
|
|
@@ -700,6 +730,7 @@ def add_model(cls,**kwargs):
|
|
|
user_id = user_id,
|
|
|
stock_id = stock_id,
|
|
|
stock_name = ts["name"],
|
|
|
+ player_id = player.id,
|
|
|
stock_date = stock_date
|
|
|
)
|
|
|
ts["stock_id"] = stock_id
|
|
|
@@ -745,7 +776,7 @@ def add_model(cls,**kwargs):
|
|
|
today_income = (today_fund-(yesterday_fund+fundin))/(float(yesterday_fund) + fundin)
|
|
|
total_income = (today_fund-init_fund-fundin)/(init_fund+fundin)
|
|
|
|
|
|
- cm.UserMatch.objects.filter(user_id=user_id,match_id=match_id).update(fund=init_fund+fundin)
|
|
|
+ cm.Player.objects.filter(user_id=user_id,match_id=match_id).update(fund=init_fund+fundin)
|
|
|
obj.init_fund = init_fund + fundin
|
|
|
obj.yesterday_fund = obj.yesterday_fund + fundin
|
|
|
#出资金
|
|
|
@@ -754,7 +785,7 @@ def add_model(cls,**kwargs):
|
|
|
today_income = (today_fund-(yesterday_fund-fundout))/float(yesterday_fund)
|
|
|
total_income = (today_fund+fundout-init_fund)/init_fund
|
|
|
|
|
|
- cm.UserMatch.objects.filter(user_id=user_id,match_id=match_id).update(fund=round(today_fund/(1+total_income),4))
|
|
|
+ cm.Player.objects.filter(user_id=user_id,match_id=match_id).update(fund=round(today_fund/(1+total_income),4))
|
|
|
obj.init_fund = round(today_fund/(1+total_income),4)
|
|
|
obj.yesterday_fund = round(today_fund/(1+today_income),4)
|
|
|
|
|
|
@@ -768,8 +799,8 @@ def add_model(cls,**kwargs):
|
|
|
obj.total_income = round(total_income,4)
|
|
|
|
|
|
else:
|
|
|
- today_income = (today_fund - yesterday_fund)/float(yesterday_fund)
|
|
|
- total_income = (today_fund - init_fund)/float(init_fund)
|
|
|
+ today_income = (today_fund - yesterday_fund)/float(yesterday_fund) if yesterday_fund else 0.0
|
|
|
+ total_income = (today_fund - init_fund)/float(init_fund) if init_fund else 0.0
|
|
|
|
|
|
if float(today_income)>0.4:
|
|
|
raise ce.TipException(u"今日盈利已超过40%,请仔细核对数据或直接联系顽主!")
|
|
|
@@ -785,7 +816,8 @@ def add_model(cls,**kwargs):
|
|
|
obj.save()
|
|
|
|
|
|
#更新group_rank
|
|
|
- ccc.cache.lpush(settings.RANK_LIST,obj.id)
|
|
|
+ #ccc.cache.lpush(settings.RANK_LIST,obj.id)
|
|
|
+ ccc.cache.lpush(settings.RANK_LIST,"%s_%s" %(obj.match_id,obj.id))
|
|
|
return obj.id
|
|
|
|
|
|
|
|
|
@@ -1091,13 +1123,28 @@ def get_user_follower(request):
|
|
|
match_id = ccc.get_cur_match().id
|
|
|
|
|
|
qdata = request.json
|
|
|
+ if qdata.get("user_id"):
|
|
|
+ user_id = int(qdata.get("user_id"))
|
|
|
_today = get_today_date()
|
|
|
|
|
|
data = []
|
|
|
|
|
|
qset = cm.UserFollows.objects.filter(follow_id=user_id)
|
|
|
follow_ids = list(qset.values_list("user_id",flat=True))
|
|
|
+
|
|
|
+ userset = cm.UserInfo.objects.filter(id__in=follow_ids)
|
|
|
+ data = list(userset.values())
|
|
|
|
|
|
+ page = int(qdata.get("page",1))
|
|
|
+ page_size = int(qdata.get("page_size",20))
|
|
|
+
|
|
|
+ if page and page_size:
|
|
|
+ total,data = ccf.get_page_list(data,page,page_size)
|
|
|
+ return total,data
|
|
|
+ else:
|
|
|
+ return len(data),data
|
|
|
+
|
|
|
+ #
|
|
|
for player_id in follow_ids:
|
|
|
latest_key = "PLAYER_LATEST_%d"%player_id
|
|
|
_match_id = ccc.cache.hget(latest_key,"match_id")
|
|
|
@@ -1108,6 +1155,7 @@ def get_user_follower(request):
|
|
|
today_record = ccc.get_today_record(player_id,_match_id,_match_group,_today)
|
|
|
if today_record:
|
|
|
data.append(today_record)
|
|
|
+ #data.append(today_record)
|
|
|
|
|
|
data = sorted(data,key=lambda x:x["stock_date"],reverse=True)
|
|
|
|
|
|
@@ -1148,11 +1196,27 @@ def get_user_follows(request):
|
|
|
"""
|
|
|
user_id = request.user.get("id",0)
|
|
|
qdata = request.json
|
|
|
+ if qdata.get("user_id"):
|
|
|
+ user_id = qdata.get("user_id")
|
|
|
|
|
|
qset = cm.UserFollows.objects.filter(user_id=user_id)
|
|
|
follow_ids = list(qset.values_list("follow_id",flat=True))
|
|
|
+
|
|
|
+ userset = cm.UserInfo.objects.filter(id__in=follow_ids)
|
|
|
+ data = list(userset.values())
|
|
|
+
|
|
|
+ page = int(qdata.get("page",1))
|
|
|
+ page_size = int(qdata.get("page_size",20))
|
|
|
+
|
|
|
+ if page and page_size:
|
|
|
+ total,data = ccf.get_page_list(data,page,page_size)
|
|
|
+ return total,data
|
|
|
+ else:
|
|
|
+ return len(data),data
|
|
|
+
|
|
|
today = get_today_date()
|
|
|
_today = today
|
|
|
+
|
|
|
data = []
|
|
|
for user_id in follow_ids:
|
|
|
latest_key = "PLAYER_LATEST_%d"%user_id
|
|
|
@@ -1169,7 +1233,6 @@ def get_user_follows(request):
|
|
|
|
|
|
data = sorted(data,key=lambda x:x["stock_date"],reverse=True)
|
|
|
|
|
|
-
|
|
|
page = int(qdata.get("page",1))
|
|
|
page_size = int(qdata.get("page_size",20))
|
|
|
|
|
|
@@ -1669,8 +1732,14 @@ def update_user_style(**kwargs):
|
|
|
#if player_id and init_fund:
|
|
|
# cm.Player.objects.filter(id=player_id).update(fund=init_fund)
|
|
|
|
|
|
- #if kwargs.get("username"):
|
|
|
- # cm.Player.objects.filter(id=player_id).update(username=kwargs.get("username"))
|
|
|
+ if kwargs.get("username"):
|
|
|
+ cm.Player.objects.filter(user_id=user_id).update(username=kwargs.get("username"))
|
|
|
+ match_id = ccc.get_cur_match().id
|
|
|
+ upset = cm.PlayerRecord.get_db_model(match_id).objects.filter(user_id=user_id)
|
|
|
+ upset.update(username=kwargs.get("username"))
|
|
|
+ record_ids = list(upset.values_list("id",flat=True))
|
|
|
+ for _id in record_ids:
|
|
|
+ ccc.cache.lpush(settings.RANK_LIST,"%s_%s" %(match_id,_id))
|
|
|
|
|
|
if kwargs.get("avatar"):
|
|
|
cm.UserInfo.objects.filter(id=user_id).update(avatar=kwargs.get("avatar"))
|
|
|
@@ -1739,8 +1808,6 @@ def get_player_match_calendar(**kwargs):
|
|
|
sdate = month + "-" + sday
|
|
|
edate = month + "-" + eday
|
|
|
|
|
|
- print sdate,edate
|
|
|
-
|
|
|
qset = cm.PlayerRecord.get_db_model(match_id).objects.filter(user_id=user_id,match_id=match_id)\
|
|
|
.filter(stock_date__gte=sdate,stock_date__lte=edate)
|
|
|
data = list(qset.values())
|
|
|
@@ -1748,14 +1815,21 @@ def get_player_match_calendar(**kwargs):
|
|
|
dct = {}
|
|
|
for item in data:
|
|
|
item["today_income"] = "{}%".format(item["today_income"]*100)
|
|
|
- dct[item["stock_date"]] = item["today_income"]
|
|
|
+ #dct[item["stock_date"]] = item["today_income"]
|
|
|
+ dct[item["stock_date"]] = [item["today_income"],item["id"]]
|
|
|
|
|
|
newdata = []
|
|
|
for i in range(1,int(eday)+1):
|
|
|
stock_date = month + "-" + str(i).zfill(2)
|
|
|
+ today_tpl = dct.get(stock_date,[])
|
|
|
+
|
|
|
+ today_income = today_tpl[0] if today_tpl else None
|
|
|
+ record_id = today_tpl[1] if today_tpl else None
|
|
|
+
|
|
|
newdata.append({
|
|
|
"stock_date":stock_date,
|
|
|
- "today_income":dct.get(stock_date,""),
|
|
|
+ "today_income":today_income,
|
|
|
+ "record_id":record_id
|
|
|
})
|
|
|
|
|
|
return newdata
|
|
|
@@ -1801,17 +1875,12 @@ def get_mine_latest(request):
|
|
|
"""
|
|
|
try:
|
|
|
user_id = request.user.get("id")
|
|
|
- match_id = ccc.get_cur_match().id
|
|
|
|
|
|
- player_id = request.player.id
|
|
|
- match_id = request.player.match_id
|
|
|
- match_group = request.player.match_group
|
|
|
- today = get_today_date()
|
|
|
-
|
|
|
- _today = ccc.cache.hget("PLAYER_LATEST_%d"%player_id,"stock_date")
|
|
|
+ match_id = ccc.cache.hget("PLAYER_LATEST_%d" % user_id,"match_id")
|
|
|
+ match_group = ccc.cache.hget("PLAYER_LATEST_%d" % user_id,"match_group")
|
|
|
+ _today = ccc.cache.hget("PLAYER_LATEST_%d" % user_id,"stock_date")
|
|
|
if _today:
|
|
|
- today = _today
|
|
|
- rst = get_today_record_actual(player_id,match_id,match_group)
|
|
|
+ rst = ccc.get_today_record(int(user_id),int(match_id),int(match_group),_today)
|
|
|
if rst:
|
|
|
rst["today_income_fund"] = round((rst["today_fund"] - rst["yesterday_fund"])*10000,2) if rst["yesterday_fund"] else 0.00
|
|
|
|
|
|
@@ -1825,7 +1894,7 @@ def get_mine_latest(request):
|
|
|
print(e)
|
|
|
return {"player_id":user_id,"match_id":match_id,"user_id":user_id}
|
|
|
|
|
|
-@ccc.cache_data()
|
|
|
+#@ccc.cache_data()
|
|
|
def get_match_validdates(match_id):
|
|
|
"""
|
|
|
"""
|
|
|
@@ -1914,9 +1983,12 @@ def do_wx_pay(request):
|
|
|
match_group = cm.MatchGroup.objects.filter(match_id=match_id,charge=0).first().id
|
|
|
|
|
|
out_trade_no = datetime.datetime.now().strftime("%Y%m%d%H%M%S") + str(int(time.time()*1000))
|
|
|
+
|
|
|
#游客和普通选手付费报名
|
|
|
+ #gt_time = datetime.timedelta(days=-365)+datetime.datetime.now()
|
|
|
+ #old_player = cm.Player.objects.filter(user_id=user_id,match_status=1,ctime__gte=gt_time).exists()
|
|
|
#if user["player_type"] in [0,1] and not phone=="13883187629":
|
|
|
- if user["player_type"] in [0,1]:
|
|
|
+ if user["player_type"] in [0,1] and not phone=="13883187629":
|
|
|
#生成订单
|
|
|
order = cm.SignupOrder.objects.create(
|
|
|
user_id = user_id,
|
|
|
@@ -1977,7 +2049,7 @@ def do_wx_pay(request):
|
|
|
user.role = 2
|
|
|
user.save()
|
|
|
#发送报名成功信息
|
|
|
- send_signup_success(phone,signup_name)
|
|
|
+ #send_signup_success(phone,signup_name)
|
|
|
|
|
|
if phone == "13883187629":
|
|
|
for i in [5001,4762,5173,5141]:
|
|
|
@@ -1991,7 +2063,6 @@ def do_wxpay_notify(request):
|
|
|
flag,res = wxpay.check_notify_valid(request.body)
|
|
|
if flag:
|
|
|
out_trade_no = res.get("out_trade_no")
|
|
|
- print(out_trade_no)
|
|
|
transaction_id = res.get("transaction_id")
|
|
|
pay_time = res.get("time_end")
|
|
|
try:
|
|
|
@@ -2038,7 +2109,7 @@ def do_wxpay_notify(request):
|
|
|
cm.UserInfo.objects.filter(id=user_id).update(role=1,phone=sorder.phone,username=sorder.user_name)
|
|
|
|
|
|
#发送报名成功信息
|
|
|
- send_signup_success(sorder.phone,sorder.signup_name)
|
|
|
+ #send_signup_success(sorder.phone,sorder.signup_name)
|
|
|
return True
|
|
|
except Exception as e:
|
|
|
import traceback
|
|
|
@@ -2429,7 +2500,7 @@ def get_user_match_list(request):
|
|
|
user_id = kwargs.get("user_id")
|
|
|
if not user_id:
|
|
|
user_id = request.user.get("id")
|
|
|
- qset = cm.Player.objects.filter(user_id=user_id).order_by("-id")
|
|
|
+ qset = cm.Player.objects.filter(user_id=user_id).filter(match_group__isnull=False).order_by("-id")
|
|
|
qset = qset.values("user_id","match_id","match_group").annotate(cnt=Count("match_id"))
|
|
|
|
|
|
page = int(kwargs.get("page",0))
|
|
|
@@ -2440,24 +2511,31 @@ def get_user_match_list(request):
|
|
|
else:
|
|
|
total = qset.count()
|
|
|
|
|
|
- today = get_today_date(user_id=user_id)
|
|
|
+ #today = get_today_date(user_id=user_id)
|
|
|
data = list(qset.values("user_id","match_id","match_group"))
|
|
|
+ new_data = []
|
|
|
for item in data:
|
|
|
match_id = item["match_id"]
|
|
|
match_group = item["match_group"]
|
|
|
user_id = item["user_id"]
|
|
|
+ today = get_today_date(match_id=match_id,user_id=user_id)
|
|
|
|
|
|
item["match_info"] = get_match_info(match_id)
|
|
|
item["match_group_info"] = get_group_info(match_group)
|
|
|
- today_record = ccc.get_today_record(user_id,int(match_id),int(match_group),today)
|
|
|
- today_record = format_today_record(today_record)
|
|
|
- if today_record.get("today_income"):
|
|
|
- today_record["today_income"] = "{}%".format(today_record["today_income"]*100)
|
|
|
- if today_record.get("total_income"):
|
|
|
- today_record["total_income"] = "{}%".format(today_record["total_income"]*100)
|
|
|
- item["today_record"] = today_record
|
|
|
|
|
|
- return total,data
|
|
|
+ if match_id and match_group:
|
|
|
+ today_record = ccc.get_today_record(user_id,int(match_id),int(match_group),today)
|
|
|
+ today_record = format_today_record(today_record)
|
|
|
+ if today_record:
|
|
|
+ if today_record.get("today_income"):
|
|
|
+ today_record["today_income"] = "{}%".format(today_record["today_income"]*100)
|
|
|
+ if today_record.get("total_income"):
|
|
|
+ today_record["total_income"] = "{}%".format(today_record["total_income"]*100)
|
|
|
+ item["today_record"] = today_record
|
|
|
+ new_data.append(item)
|
|
|
+
|
|
|
+ #return total,data
|
|
|
+ return total,new_data
|
|
|
|
|
|
|
|
|
def get_format_user_info(request):
|
|
|
@@ -2467,7 +2545,7 @@ def get_format_user_info(request):
|
|
|
q_user_id = kwargs.get("user_id")
|
|
|
if q_user_id:
|
|
|
user_id = q_user_id
|
|
|
- userinfo = get_user_info(q_user_id)
|
|
|
+ userinfo = get_user_info_actual(q_user_id)
|
|
|
userinfo["fans"] = cm.UserFollows.objects.filter(follow_id=user_id).count()
|
|
|
userinfo["followers"] = cm.UserFollows.objects.filter(user_id=user_id).count()
|
|
|
del userinfo["phone"]
|
|
|
@@ -2503,3 +2581,61 @@ def get_day_inout_rank_list(request):
|
|
|
return total,data
|
|
|
|
|
|
|
|
|
+
|
|
|
+def get_user_follows_v3(request):
|
|
|
+ """获取用户关注的选手列表
|
|
|
+ """
|
|
|
+ user_id = request.user.get("id",0)
|
|
|
+ qdata = request.json
|
|
|
+ if qdata.get("user_id"):
|
|
|
+ user_id = qdata.get("user_id")
|
|
|
+
|
|
|
+ qset = cm.UserFollows.objects.filter(user_id=user_id)
|
|
|
+ follow_ids = list(qset.values_list("follow_id",flat=True))
|
|
|
+
|
|
|
+ today = get_today_date()
|
|
|
+ _today = today
|
|
|
+
|
|
|
+ data = []
|
|
|
+ for user_id in follow_ids:
|
|
|
+ latest_key = "PLAYER_LATEST_%d"%user_id
|
|
|
+
|
|
|
+ _match_id = ccc.cache.hget(latest_key,"match_id")
|
|
|
+ _today = ccc.cache.hget(latest_key,"stock_date")
|
|
|
+ _match_group = ccc.cache.hget(latest_key,"match_group")
|
|
|
+
|
|
|
+ today_record = ccc.get_today_record(user_id,_match_id,_match_group,_today)
|
|
|
+ if today_record:
|
|
|
+ today_record["zan_count"] = today_record.get("zans",0) if today_record.get("zans") else 0
|
|
|
+ today_record["comments_count"] = cm.Comments.objects.filter(record_id=today_record.get("id",0)).count()
|
|
|
+ data.append(today_record)
|
|
|
+
|
|
|
+ data = sorted(data,key=lambda x:x["stock_date"],reverse=True)
|
|
|
+
|
|
|
+ page = int(qdata.get("page",1))
|
|
|
+ page_size = int(qdata.get("page_size",20))
|
|
|
+
|
|
|
+ if page and page_size:
|
|
|
+ total,data = ccf.get_page_list(data,page,page_size)
|
|
|
+ for item in data:
|
|
|
+ if item:
|
|
|
+ user_id = item["user_id"]
|
|
|
+ latest_key = "PLAYER_LATEST_%d"%user_id
|
|
|
+
|
|
|
+ today_stock = json.loads(item["today_stock"])
|
|
|
+ today_stock = filter(lambda x:x["name"] and x["fund"],today_stock)
|
|
|
+ item["today_stock"] = today_stock
|
|
|
+ item["today_stock_img"] = json.loads(item["today_stock_img"])
|
|
|
+
|
|
|
+ win_rate = ccc.cache.hget(latest_key,"win_rate")
|
|
|
+ if win_rate:
|
|
|
+ item["win_rate"] = str(float(win_rate)*100)+"%"
|
|
|
+ else:
|
|
|
+ item["win_rate"] = "0.0%"
|
|
|
+ item["today_income"] = "{}%".format(item["today_income"]*100)
|
|
|
+ item["total_income"] = "{}%".format(item["total_income"]*100)
|
|
|
+ item["zans_count"] = item.get("zans",0)
|
|
|
+ item["comments_count"] = cm.Comments.objects.filter(record_id=item.get("id",0)).count()
|
|
|
+ return total,data
|
|
|
+ else:
|
|
|
+ return len(data),data
|