|
|
@@ -44,6 +44,7 @@ def async(f):
|
|
|
|
|
|
|
|
|
def get_today_date():
|
|
|
+ #return '2021-12-31'
|
|
|
if datetime.datetime.now().strftime("%H:%M") < "15:00":
|
|
|
if datetime.datetime.now().weekday() in [5,6] or datetime.datetime.now().strftime("%Y-%m-%d") in MISS_DATES:
|
|
|
today = cm.PlayerRecord.objects.all().order_by("-stock_date").first().stock_date
|
|
|
@@ -141,6 +142,9 @@ def get_player_match_list(request):
|
|
|
#match_ids = list(cm.Player.objects.filter(user_id=uid,match_id=cur_match_id).values_list("match_id",flat=True))
|
|
|
match_ids = list(cm.Player.objects.filter(user_id=uid).values_list("match_id",flat=True))
|
|
|
matchs = list(cm.Match.objects.filter(id__in=match_ids).values())
|
|
|
+ for item in matchs:
|
|
|
+ player = cm.Player.objects.filter(user_id=uid,match_id=item["id"]).first()
|
|
|
+ item["player_id"] = player.id if player else 0
|
|
|
|
|
|
return matchs
|
|
|
|
|
|
@@ -164,22 +168,29 @@ def get_player_match_detail(request):
|
|
|
"""
|
|
|
qdata = request.json
|
|
|
player_id = request.player.id
|
|
|
+ user_id = request.player.user_id
|
|
|
org_player_id = request.player.id
|
|
|
match_group = request.player.match_group
|
|
|
match_id = qdata.get("id")
|
|
|
record_id = qdata.get("record_id")
|
|
|
+ cur_player_id = qdata.get("player_id")
|
|
|
+
|
|
|
+ ismine = True if int(cur_player_id) == player_id else False
|
|
|
|
|
|
if record_id:
|
|
|
records_set = cm.PlayerRecord.objects.filter(id=record_id)
|
|
|
- match_id = records_set.first().match_id
|
|
|
- match_group = records_set.first().match_group
|
|
|
- player_id = records_set.first().player_id
|
|
|
- records_set = cm.PlayerRecord.objects.filter(player_id=player_id,match_id=match_id).order_by("-stock_date")
|
|
|
+ if records_set:
|
|
|
+ match_id = records_set.first().match_id
|
|
|
+ match_group = records_set.first().match_group
|
|
|
+ player_id = records_set.first().player_id
|
|
|
+ records_set = cm.PlayerRecord.objects.filter(player_id=player_id,match_id=match_id).order_by("-stock_date")
|
|
|
else:
|
|
|
if qdata.get("player_id"):
|
|
|
player_id = qdata.get("player_id")
|
|
|
match_group = cm.Player.objects.filter(id=player_id).first().match_group
|
|
|
-
|
|
|
+ else:
|
|
|
+ #为了兼容老版本没有传player_id要获取用户的某届赛事player_id
|
|
|
+ player_id = cm.Player.objects.filter(user_id=user_id,match_id=match_id).first().id
|
|
|
records_set = cm.PlayerRecord.objects.filter(player_id=player_id,match_id=match_id).order_by("-stock_date")
|
|
|
|
|
|
|
|
|
@@ -191,11 +202,6 @@ def get_player_match_detail(request):
|
|
|
else:
|
|
|
records = []
|
|
|
|
|
|
- today = get_today_date()
|
|
|
-
|
|
|
- today = records_set.first().stock_date
|
|
|
- today_record = get_today_record(player_id,int(match_id),int(match_group),today)
|
|
|
-
|
|
|
for item in records:
|
|
|
item["today_stock"] = json.loads(item["today_stock"]) if item["today_stock"] else []
|
|
|
item["today_stock_img"] = json.loads(item["today_stock_img"]) if item["today_stock_img"] else []
|
|
|
@@ -203,20 +209,36 @@ def get_player_match_detail(request):
|
|
|
item["yesterday_stock_img"] = json.loads(item["yesterday_stock_img"]) if item["yesterday_stock_img"] else []
|
|
|
item["today_income"] = "{}%".format(item["today_income"]*100)
|
|
|
item["total_income"] = "{}%".format(item["total_income"]*100)
|
|
|
- if today_record:
|
|
|
- today_record["today_stock_img"] = json.loads(today_record["today_stock_img"]) if today_record["today_stock_img"] else []
|
|
|
- today_record["today_stock"] = json.loads(today_record["today_stock"]) if today_record["today_stock"] else []
|
|
|
- today_record["today_income"] = "{}%".format(today_record["today_income"]*100)
|
|
|
- today_record["total_income"] = "{}%".format(today_record["total_income"]*100)
|
|
|
- today_record["match_group_name"] = cm.MatchGroup.objects.filter(id=today_record["match_group"]).first().name
|
|
|
- today_record["players_num"] = cm.Player.objects.filter(match_group=today_record["match_group"]).count()
|
|
|
- today_record["win_rate"] = calc_win_rate(player_id,today_record["match_id"])
|
|
|
- badest = cm.PlayerRecord.objects.filter(player_id=player_id,match_id=match_id).order_by("today_income").first()
|
|
|
- if badest:
|
|
|
- today_record["badest_income"] = "{}%".format(badest.today_income*100)
|
|
|
+
|
|
|
+ today = get_today_date()
|
|
|
+ if records_set.first():
|
|
|
+ today = records_set.first().stock_date
|
|
|
+ #today_record = get_today_record(player_id,int(match_id),int(match_group),today)
|
|
|
+ #if not today_record:
|
|
|
+ # today_record = get_today_record_actual(player_id,match_id,today)
|
|
|
+ if ismine:
|
|
|
+ today_record = get_today_record_actual(player_id,match_id,match_group,today)
|
|
|
+ else:
|
|
|
+ today_record = get_today_record(player_id,int(match_id),int(match_group),today)
|
|
|
+ if today_record:
|
|
|
+ today_record["today_stock_img"] = json.loads(today_record["today_stock_img"]) if today_record["today_stock_img"] else []
|
|
|
+ today_record["today_stock"] = json.loads(today_record["today_stock"]) if today_record["today_stock"] else []
|
|
|
+ today_record["today_income"] = "{}%".format(today_record["today_income"]*100)
|
|
|
+ today_record["total_income"] = "{}%".format(today_record["total_income"]*100)
|
|
|
+ today_record["match_group_name"] = cm.MatchGroup.objects.filter(id=today_record["match_group"]).first().name
|
|
|
+ today_record["players_num"] = cm.Player.objects.filter(match_group=today_record["match_group"]).count()
|
|
|
+ today_record["win_rate"] = calc_win_rate(player_id,today_record["match_id"])
|
|
|
+ badest = cm.PlayerRecord.objects.filter(player_id=player_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)
|
|
|
+ userinfo = get_user_info(today_record["user_id"])
|
|
|
+ today_record["style"] = userinfo.get("style")
|
|
|
+ else:
|
|
|
+ today_record = {}
|
|
|
|
|
|
match["groups"] = [today_record["match_group_name"]] if today_record else []
|
|
|
- records = sorted(records,key=lambda x:x["stock_date"],reverse=True)[:5]
|
|
|
+ records = sorted(records,key=lambda x:x["stock_date"],reverse=True)
|
|
|
if cm.UserFollows.objects.filter(user_id=org_player_id,follow_id=player_id).exists():
|
|
|
is_follow = 1
|
|
|
else:
|
|
|
@@ -256,17 +278,47 @@ def get_today_record(player_id,match_id,match_group,today):
|
|
|
traceback.print_exc()
|
|
|
return today_record
|
|
|
|
|
|
+
|
|
|
+def get_today_record_actual(player_id,match_id,match_group,today=None):
|
|
|
+ """
|
|
|
+ """
|
|
|
+ if today:
|
|
|
+ qset = cm.PlayerRecord.objects.filter(match_id=match_id,match_group=match_group,player_id=player_id,stock_date=today)
|
|
|
+ else:
|
|
|
+ qset = cm.PlayerRecord.objects.filter(match_id=match_id,match_group=match_group,player_id=player_id).order_by("-stock_date")
|
|
|
+ today_record = qset.values().first()
|
|
|
+
|
|
|
+ if today_record:
|
|
|
+ user_info = get_user_info(today_record["user_id"])
|
|
|
+ if user_info:
|
|
|
+ user_info.pop("id")
|
|
|
+ today_record.update(user_info)
|
|
|
+
|
|
|
+ #仓位
|
|
|
+ today_stock_total = 0
|
|
|
+ today_stock = json.loads(today_record["today_stock"])
|
|
|
+ for ts in today_stock:
|
|
|
+ if ts["fund"]:
|
|
|
+ try:
|
|
|
+ today_stock_total += float(ts["fund"])
|
|
|
+ except Exception as e:
|
|
|
+ print e
|
|
|
+ today_record["cangwei"] = "{}%".format(round(today_stock_total/today_record["today_fund"],4)*100)
|
|
|
+ today_record["today_stock_total"] = today_stock_total
|
|
|
+ return today_record
|
|
|
+
|
|
|
+
|
|
|
@ccc.cache_data()
|
|
|
def get_match_group_players(match_id,match_group):
|
|
|
players = list(cm.Player.objects.filter(match_id=match_id,match_group=match_group).values())
|
|
|
return players
|
|
|
|
|
|
-#@ccc.cache_data()
|
|
|
+@ccc.cache_data()
|
|
|
def get_match_groups(match_id):
|
|
|
"""
|
|
|
"""
|
|
|
match = cm.Match.objects.filter(id=match_id).values().first()
|
|
|
- groups = list(cm.MatchGroup.objects.filter(match_id=match_id,is_active=1).values())
|
|
|
+ groups = list(cm.MatchGroup.objects.filter(match_id=match_id,is_active=1).order_by("order").values())
|
|
|
#groups = list(cm.MatchGroup.objects.filter(match_id=match_id).values())
|
|
|
return match,groups
|
|
|
|
|
|
@@ -275,15 +327,18 @@ def get_cache_rank_list(player_id,match_id,today):
|
|
|
"""
|
|
|
"""
|
|
|
match,groups = get_match_groups(match_id)
|
|
|
+ #groups = sorted(groups,key=lambda x:x["id"])
|
|
|
|
|
|
#if datetime.datetime.now().hour < 15:
|
|
|
# today = (datetime.datetime.now()-datetime.timedelta(days=1)).strftime("%Y-%m-%d")
|
|
|
#else:
|
|
|
# today = datetime.datetime.now().strftime("%Y-%m-%d")
|
|
|
-
|
|
|
+ data = []
|
|
|
for item in groups:
|
|
|
new_players = []
|
|
|
players = get_match_group_players(match_id,item["id"])
|
|
|
+ win_count = 0
|
|
|
+ loss_count = 0
|
|
|
for player in players:
|
|
|
user_id = player["user_id"]
|
|
|
user = get_user_info(user_id)
|
|
|
@@ -296,9 +351,15 @@ def get_cache_rank_list(player_id,match_id,today):
|
|
|
player.update(today_record)
|
|
|
player["username"] = username
|
|
|
player["org_today_income"] = player["today_income"]
|
|
|
+ player["org_total_income"] = player["total_income"]
|
|
|
player["total_income"] = "{}%".format(today_record["total_income"]*100)
|
|
|
player["today_income"] = "{}%".format(today_record["today_income"]*100)
|
|
|
|
|
|
+ if player["org_today_income"] >= 0.05:
|
|
|
+ win_count += 1
|
|
|
+ if player["org_today_income"] <= -0.05:
|
|
|
+ loss_count += 1
|
|
|
+
|
|
|
try:
|
|
|
player["fund"] = round(player["fund"],4) if player["fund"] else 0.0
|
|
|
player["init_fund"] = round(player["init_fund"],4)
|
|
|
@@ -308,15 +369,20 @@ def get_cache_rank_list(player_id,match_id,today):
|
|
|
except Exception as e:
|
|
|
print player
|
|
|
pass
|
|
|
- new_players = sorted(new_players,key=lambda x:x["group_rank"])
|
|
|
- win_count = filter(lambda x:x["org_today_income"]>=0.05,new_players)
|
|
|
- loss_count = filter(lambda x:x["org_today_income"]<=-0.05,new_players)
|
|
|
- #item["players_num"] = cm.Player.objects.filter(match_group=item["id"]).count()
|
|
|
+ #win_count = filter(lambda x:x["org_today_income"]>=0.05,new_players)
|
|
|
+ #loss_count = filter(lambda x:x["org_today_income"]<=-0.05,new_players)
|
|
|
+
|
|
|
+ new_players_sort = list(sorted(new_players,key=lambda x:x["org_total_income"],reverse=True))
|
|
|
+ #new_players_sort = new_players
|
|
|
+
|
|
|
item["players_num"] = len(players)
|
|
|
- item["win_count"] = len(win_count)
|
|
|
- item["loss_count"] = len(loss_count)
|
|
|
- item["players"] = new_players[:3]
|
|
|
- return match,groups
|
|
|
+ #item["win_count"] = len(win_count)
|
|
|
+ #item["loss_count"] = len(loss_count)
|
|
|
+ item["win_count"] = win_count
|
|
|
+ item["loss_count"] = loss_count
|
|
|
+ item["players"] = new_players_sort[:3]
|
|
|
+ data.append(item)
|
|
|
+ return match,data
|
|
|
|
|
|
|
|
|
def get_rank_list(request):
|
|
|
@@ -324,9 +390,12 @@ def get_rank_list(request):
|
|
|
"""
|
|
|
qdata = request.json
|
|
|
player_id = request.player.id
|
|
|
- match_id = request.player.match_id
|
|
|
+
|
|
|
+ match_id = qdata.get("match_id")
|
|
|
|
|
|
today = qdata.get("stock_date")
|
|
|
+ if not today:
|
|
|
+ today = get_today_date()
|
|
|
|
|
|
match,groups = get_cache_rank_list(player_id,match_id,today)
|
|
|
|
|
|
@@ -369,20 +438,25 @@ def get_group_rank_list(request):
|
|
|
group_id = qdata.get("id")
|
|
|
player_id = request.player.id
|
|
|
match_id = request.player.match_id
|
|
|
- today = qdata.get("stock_date")
|
|
|
+ match_id = qdata.get("match_id")
|
|
|
|
|
|
- match_id = 8
|
|
|
+ match_id = cm.MatchGroup.objects.filter(id=group_id).first().match_id
|
|
|
+
|
|
|
+ today = qdata.get("stock_date")
|
|
|
+ if not today:
|
|
|
+ today = get_today_date()
|
|
|
|
|
|
match = get_match_info(match_id)
|
|
|
group = get_group_info(group_id)
|
|
|
|
|
|
players = get_match_group_players(match_id,group_id)
|
|
|
+ print(match_id,group_id)
|
|
|
+ print(len(players))
|
|
|
new_players = []
|
|
|
for player in players:
|
|
|
user_id = player["user_id"]
|
|
|
user = get_user_info(user_id)
|
|
|
username = user["username"] if user else ""
|
|
|
-
|
|
|
player_id = player["id"]
|
|
|
match_group = group_id
|
|
|
today_record = get_today_record(player_id,match_id,int(match_group),today)
|
|
|
@@ -408,12 +482,14 @@ def get_group_rank_list(request):
|
|
|
elif kwargs.get("order_by") == "total_income__desc":
|
|
|
new_players = sorted(new_players,key=lambda x:x["org_total_income"],reverse=True)
|
|
|
else:
|
|
|
- new_players = sorted(new_players,key=lambda x:x["group_rank"])
|
|
|
+ new_players = sorted(new_players,key=lambda x:x["org_total_income"],reverse=True)
|
|
|
+
|
|
|
+ #new_players = []
|
|
|
|
|
|
#分页
|
|
|
page = int(kwargs.get("page",0))
|
|
|
- page_size = int(kwargs.get("page_size",20))
|
|
|
- page_size = 50
|
|
|
+ page_size = int(kwargs.get("page_size",50))
|
|
|
+ #page_size = 50
|
|
|
if page and page_size:
|
|
|
total,new_players = ccf.get_page_list(new_players,page,page_size)
|
|
|
else:
|
|
|
@@ -444,11 +520,11 @@ def get_player_match_records(request):
|
|
|
page = int(qdata.get("page",0))
|
|
|
page_size = int(qdata.get("page_size",20))
|
|
|
|
|
|
- if int(match_id) == 7:
|
|
|
- player = cm.Player.objects.filter(match_id=match_id,usercode=request.user.usercode).first()
|
|
|
- if player:
|
|
|
- player_id = player.id
|
|
|
- match_group = player.match_group
|
|
|
+ #if int(match_id) == 7:
|
|
|
+ # player = cm.Player.objects.filter(match_id=match_id,usercode=request.user.usercode).first()
|
|
|
+ # if player:
|
|
|
+ # player_id = player.id
|
|
|
+ # match_group = player.match_group
|
|
|
|
|
|
records_set = cm.PlayerRecord.objects.filter(player_id=player_id,match_id=match_id).order_by("-stock_date")
|
|
|
data = list(records_set.values())
|
|
|
@@ -493,19 +569,34 @@ def add_model(cls,**kwargs):
|
|
|
|
|
|
if model_name == "PlayerRecord":
|
|
|
now = datetime.datetime.now()
|
|
|
- if now.weekday() in [5,6] or now.strftime("%Y-%m-%d") in MISS_DATES:
|
|
|
+ match_id = kwargs.get("match_id")
|
|
|
+ if now.weekday() in [5,6] or not now.strftime("%Y-%m-%d") in get_match_validdates(match_id):
|
|
|
raise ce.TipException(u"今日不能提交数据!")
|
|
|
+
|
|
|
+ now_time = datetime.datetime.now().strftime("%H:%S")
|
|
|
+ if now_time<"15:00" or now_time > "23:50":
|
|
|
+ raise ce.TipException(u"当日数据请在当日15:00以后23:50以前提交数据!")
|
|
|
+
|
|
|
match_id = kwargs.get("match_id")
|
|
|
stock_date = kwargs.get("stock_date")
|
|
|
+ #stock_date = "2022-04-26"
|
|
|
+ stock_date = datetime.datetime.now().strftime("%Y-%m-%d")
|
|
|
today_stock = json.dumps(kwargs.get("today_stock"))
|
|
|
today_stock_img = json.dumps(kwargs.get("today_stock_img"))
|
|
|
player_id = kwargs.get("player_id")
|
|
|
today_fund = float(kwargs.get("today_fund",0))
|
|
|
is_markt = int(kwargs.get("is_markt",0))
|
|
|
+ experience = kwargs.get("experience")
|
|
|
+
|
|
|
+ #计算今日和昨日盈亏
|
|
|
+ if float(today_fund)>9999 or float(today_fund)<=0:
|
|
|
+ raise ce.TipException(u"数据错误,今日净资产不能超过9999万元,不能低于0万元,请仔细核对数据!")
|
|
|
|
|
|
player = cm.Player.objects.filter(id=player_id).first()
|
|
|
- if player.fund <= 0:
|
|
|
- raise ce.TipException(u"请先输入您的初始资金后再提交数据!")
|
|
|
+
|
|
|
+ #if player.fund <= 0:
|
|
|
+ # raise ce.TipException(u"请先输入您的初始资金后再提交数据!")
|
|
|
+
|
|
|
user_id = player.user_id
|
|
|
init_fund = player.fund
|
|
|
user = cm.UserInfo.objects.filter(id=user_id).first()
|
|
|
@@ -522,22 +613,35 @@ def add_model(cls,**kwargs):
|
|
|
raise ce.TipException(u"该账号已暂停/退出比赛,如有疑问请联系管理员获取详情信息!")
|
|
|
now_date = datetime.datetime.now().strftime("%Y-%m-%d")
|
|
|
if match.end_time < now_date:
|
|
|
- raise ce.TipException(u"该比赛已结束!")
|
|
|
- cm.PlayerRecord.objects.filter(match_id=match_id,player_id=player_id,stock_date=stock_date).delete()
|
|
|
+ raise ce.TipException(u"该比赛已结束或您未参加此次比赛不能提交数据!")
|
|
|
|
|
|
+ #cm.PlayerRecord.objects.filter(match_id=match_id,player_id=player_id,stock_date=stock_date).delete()
|
|
|
#yesterday_date = (datetime.datetime.now()-datetime.timedelta(days=1)).strftime("%Y-%m-%d")
|
|
|
+ #yesterday = cm.PlayerRecord.objects.filter(
|
|
|
+ # match_id=match_id,player_id=player_id).exclude(stock_date=stock_date).order_by("-stock_date").first()
|
|
|
+
|
|
|
+ validdates = get_match_validdates(match_id)
|
|
|
+ today_index = validdates.index(stock_date)
|
|
|
+ yesterday_index = today_index -1 if today_index >=1 else 0
|
|
|
+ yesterday_date = validdates[yesterday_index]
|
|
|
+
|
|
|
yesterday = cm.PlayerRecord.objects.filter(
|
|
|
- match_id=match_id,player_id=player_id).order_by("-stock_date").first()
|
|
|
+ match_id=match_id,player_id=player_id,stock_date=yesterday_date).exclude(stock_date=stock_date).first()
|
|
|
if yesterday:
|
|
|
yesterday_fund = yesterday.today_fund
|
|
|
yesterday_stock = yesterday.today_stock
|
|
|
yesterday_stock_img = yesterday.today_stock_img
|
|
|
yesterday_is_markt = yesterday.is_markt
|
|
|
else:
|
|
|
- yesterday_fund = init_fund
|
|
|
+ #yesterday_fund = init_fund #today_fund
|
|
|
+ yesterday_fund = today_fund
|
|
|
yesterday_stock = ""
|
|
|
yesterday_stock_img = ""
|
|
|
yesterday_is_markt = 0
|
|
|
+ if not cm.PlayerRecord.objects.filter(match_id=match_id,player_id=player_id).exists():
|
|
|
+ init_fund = today_fund
|
|
|
+ cm.Player.objects.filter(id=player_id).update(fund=today_fund)
|
|
|
+
|
|
|
with transaction.atomic():
|
|
|
#记录持股情况
|
|
|
new_stock_list = []
|
|
|
@@ -551,6 +655,7 @@ def add_model(cls,**kwargs):
|
|
|
usobj,flag = cm.UserStock.objects.get_or_create(
|
|
|
player_id = player_id,
|
|
|
stock_id = stock_id,
|
|
|
+ stock_name = ts["name"],
|
|
|
stock_date = stock_date
|
|
|
)
|
|
|
ts["stock_id"] = stock_id
|
|
|
@@ -578,6 +683,7 @@ def add_model(cls,**kwargs):
|
|
|
obj.cw = cw
|
|
|
obj.df = df
|
|
|
obj.badge = badge
|
|
|
+ obj.experience = experience
|
|
|
#计算今日和昨日盈亏
|
|
|
if float(today_fund)>9999 or float(today_fund)<=0:
|
|
|
raise ce.TipException(u"数据错误,今日净资产不能超过9999万元,不能低于0万元,请仔细核对数据!")
|
|
|
@@ -585,10 +691,15 @@ def add_model(cls,**kwargs):
|
|
|
total_income = (today_fund - init_fund)/float(init_fund)
|
|
|
|
|
|
if float(today_income)>0.4:
|
|
|
- raise ce.TipException(u"今日盈利已超过40%,请仔细核对数据或直接联系副主编!")
|
|
|
+ raise ce.TipException(u"今日盈利已超过40%,请仔细核对数据或直接联系顽主!")
|
|
|
+
|
|
|
+ if float(total_income)>8:
|
|
|
+ raise ce.TipException(u"请仔细核对数据或直接联系顽主!")
|
|
|
|
|
|
obj.today_income = round(today_income,4)
|
|
|
obj.total_income = round(total_income,4)
|
|
|
+ #obj.today_income = 0
|
|
|
+ #obj.total_income = 0
|
|
|
if not flag:
|
|
|
obj.ctime = datetime.datetime.now()
|
|
|
obj.save()
|
|
|
@@ -643,6 +754,7 @@ def get_search_list(cls,**kwargs):
|
|
|
if model_name == "Player":
|
|
|
data = list(qset.values("id","username"))
|
|
|
if model_name == "Stock":
|
|
|
+ qset = qset.filter(code__isnull=False)
|
|
|
data = list(qset.values("id","name","code"))
|
|
|
for item in data:
|
|
|
if item["code"]:
|
|
|
@@ -743,22 +855,33 @@ def get_list_info(cls,**kwargs):
|
|
|
def add_player_record_single(**kwargs):
|
|
|
"""用户单独上传数据
|
|
|
"""
|
|
|
+ return None
|
|
|
now = datetime.datetime.now()
|
|
|
if now.weekday() in [5,6] or now.strftime("%Y-%m-%d") in MISS_DATES:
|
|
|
raise ce.TipException(u"今日不能提交数据!")
|
|
|
+
|
|
|
+ now_time = datetime.datetime.now().strftime("%H:%S")
|
|
|
+ if now_time<"15:00" or now_time > "23:50":
|
|
|
+ raise ce.TipException(u"当日数据请在当日15:00以后23:50以前提交数据!")
|
|
|
+
|
|
|
usercode = kwargs.get("usercode")
|
|
|
match_id = kwargs.get("match_id")
|
|
|
if not cm.Player.objects.filter(usercode=usercode,match_id=match_id).exists():
|
|
|
raise ce.TipException(u"用户代码错误")
|
|
|
stock_date = kwargs.get("stock_date")
|
|
|
+ #stock_date = "2022-04-26"
|
|
|
+ stock_date = datetime.datetime.now().strftime("%Y-%m-%d")
|
|
|
today_stock = json.dumps(kwargs.get("today_stock"))
|
|
|
today_stock_img = json.dumps(kwargs.get("today_stock_img"))
|
|
|
today_fund = float(kwargs.get("today_fund"))
|
|
|
is_markt = int(kwargs.get("is_markt",0))
|
|
|
|
|
|
+ if int(today_fund)>9999 or int(today_fund)<0:
|
|
|
+ raise ce.TipException(u"数据错误,今日净资产不能超过9999万元,不能低于0万元,请仔细核对数据!")
|
|
|
+
|
|
|
player = cm.Player.objects.filter(usercode=usercode,match_id=match_id).first()
|
|
|
- if player.fund <=0 :
|
|
|
- raise ce.TipException(u"请先输入您的初始资金后再提交数据!")
|
|
|
+ #if player.fund <=0 :
|
|
|
+ # raise ce.TipException(u"请先输入您的初始资金后再提交数据!")
|
|
|
player_id = player.id
|
|
|
user_id = player.user_id
|
|
|
init_fund = player.fund
|
|
|
@@ -783,9 +906,12 @@ def add_player_record_single(**kwargs):
|
|
|
yesterday_stock = yesterday.today_stock
|
|
|
yesterday_stock_img = yesterday.today_stock_img
|
|
|
else:
|
|
|
- yesterday_fund = init_fund
|
|
|
+ #yesterday_fund = init_fund
|
|
|
+ yesterday_fund = today_fund
|
|
|
+ init_fund = today_fund
|
|
|
yesterday_stock = ""
|
|
|
yesterday_stock_img = ""
|
|
|
+ cm.Player.objects.filter(id=player_id).update(fund=today_fund)
|
|
|
|
|
|
#记录持股情况
|
|
|
new_stock_list = []
|
|
|
@@ -799,6 +925,7 @@ def add_player_record_single(**kwargs):
|
|
|
usobj,flag = cm.UserStock.objects.get_or_create(
|
|
|
player_id = player_id,
|
|
|
stock_id = stock_id,
|
|
|
+ stock_name = ts["name"],
|
|
|
stock_date = stock_date
|
|
|
)
|
|
|
ts["stock_id"] = stock_id
|
|
|
@@ -824,8 +951,8 @@ def add_player_record_single(**kwargs):
|
|
|
#计算今日和昨日盈亏
|
|
|
today_income = (today_fund - yesterday_fund)/float(yesterday_fund)
|
|
|
total_income = (today_fund - init_fund)/float(init_fund)
|
|
|
- if int(today_fund)>9999 or int(today_fund)<0:
|
|
|
- raise ce.TipException(u"数据错误,今日净资产不能超过9999万元,不能低于0万元,请仔细核对数据!")
|
|
|
+ #if int(today_fund)>9999 or int(today_fund)<0:
|
|
|
+ # raise ce.TipException(u"数据错误,今日净资产不能超过9999万元,不能低于0万元,请仔细核对数据!")
|
|
|
if int(today_income)>2:
|
|
|
raise ce.TipException(u"数据错误,今日盈利已超过2倍,请仔细核对数据!")
|
|
|
|
|
|
@@ -900,38 +1027,64 @@ def get_user_follows(request):
|
|
|
"""获取用户关注的选手列表
|
|
|
"""
|
|
|
user_id = request.player.id
|
|
|
- print user_id
|
|
|
match_id = request.player.match_id
|
|
|
+ cur_match_id = match_id
|
|
|
match_group = request.player.match_group
|
|
|
+ cur_match_group = match_group
|
|
|
qdata = request.json
|
|
|
today = get_today_date()
|
|
|
- print today
|
|
|
|
|
|
data = []
|
|
|
|
|
|
qset = cm.UserFollows.objects.filter(user_id=user_id)
|
|
|
follow_ids = list(qset.values_list("follow_id",flat=True))
|
|
|
|
|
|
+ _today = today
|
|
|
for player_id in follow_ids:
|
|
|
- last = cm.PlayerRecord.objects.filter(player_id=player_id,match_id=match_id).order_by("-stock_date").first()
|
|
|
- if last:
|
|
|
- today = last.stock_date
|
|
|
+ _match_id = ccc.cache.hget("PLAYER_LATEST_%d"%player_id,"match_id")
|
|
|
+
|
|
|
+ #last = cm.PlayerRecord.objects.filter(player_id=player_id,match_id=_match_id).order_by("-stock_date").first()
|
|
|
+ #if last:
|
|
|
+ # _today = last.stock_date
|
|
|
+
|
|
|
+ _today = ccc.cache.hget("PLAYER_LATEST_%d"%player_id,"stock_date")
|
|
|
+ _match_group = ccc.cache.hget("PLAYER_LATEST_%d"%player_id,"match_group")
|
|
|
+
|
|
|
+ today_record = get_today_record(player_id,_match_id,_match_group,_today)
|
|
|
+ #today_record = get_today_record_actual(player_id,_match_id,_match_group,_today)
|
|
|
+ if today_record:
|
|
|
+ data.append(today_record)
|
|
|
+
|
|
|
+ data = sorted(data,key=lambda x:x["stock_date"],reverse=True)
|
|
|
+
|
|
|
+
|
|
|
+ _match_id = ccc.cache.hget("PLAYER_LATEST_%d"%user_id,"match_id")
|
|
|
+ _today = ccc.cache.hget("PLAYER_LATEST_%d"%user_id,"stock_date")
|
|
|
+ _match_group = ccc.cache.hget("PLAYER_LATEST_%d"%user_id,"match_group")
|
|
|
+
|
|
|
+ cur_today_record = get_today_record(user_id,_match_id,_match_group,_today)
|
|
|
+ if cur_today_record:
|
|
|
+ data.insert(0,cur_today_record)
|
|
|
|
|
|
- today_record = get_today_record(player_id,match_id,last.match_group,today)
|
|
|
- if today_record:
|
|
|
- data.append(today_record)
|
|
|
- data = sorted(data,key=lambda x:x["group_rank"])
|
|
|
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:
|
|
|
- item["today_stock"] = json.loads(item["today_stock"])
|
|
|
- item["today_stock_img"] = json.loads(item["today_stock_img"])
|
|
|
- item["win_rate"] = calc_win_rate(item["player_id"],item["match_id"])
|
|
|
- item["today_income"] = "{}%".format(item["today_income"]*100)
|
|
|
- item["total_income"] = "{}%".format(item["total_income"]*100)
|
|
|
+ if item:
|
|
|
+ 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"])
|
|
|
+ #item["win_rate"] = calc_win_rate(item["player_id"],item["match_id"])
|
|
|
+ win_rate = ccc.cache.hget("PLAYER_LATEST_%d"%item["player_id"],"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)
|
|
|
return total,data
|
|
|
else:
|
|
|
return len(data),data
|
|
|
@@ -950,27 +1103,32 @@ def get_hot_stock_rank(**kwargs):
|
|
|
}
|
|
|
return data
|
|
|
|
|
|
+@ccc.cache_data()
|
|
|
+def get_stock_info(stock_id):
|
|
|
+ """
|
|
|
+ """
|
|
|
+ stock = cm.Stock.objects.filter(id=stock_id).values().first()
|
|
|
+ return stock
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
def get_hot_stock_buy(**kwargs):
|
|
|
"""
|
|
|
"""
|
|
|
stock_date = kwargs.get("stock_date")
|
|
|
qset = cm.UserStock.objects.filter(stock_date=stock_date)
|
|
|
- qset = qset.values("stock_id").annotate(count=Count("stock_id")).order_by("-count")
|
|
|
+ if kwargs.get("name"):
|
|
|
+ qset = qset.filter(stock_name__icontains=kwargs.get("name"))
|
|
|
+ qset = qset.values("stock_id","stock_name").annotate(count=Count("stock_id")).order_by("-count")
|
|
|
data = []
|
|
|
for q in qset:
|
|
|
stock_id = q["stock_id"]
|
|
|
count = q["count"]
|
|
|
- data.append(
|
|
|
- {
|
|
|
- "stock_name":cm.Stock.objects.filter(id=stock_id).first().name,
|
|
|
- "count":count,
|
|
|
- "id":stock_id
|
|
|
- }
|
|
|
- )
|
|
|
+ stock_name = q.get("stock_name")
|
|
|
+ #stock = get_stock_info(stock_id)
|
|
|
+ data.append({"stock_name":stock_name,"id":stock_id,"count":count})
|
|
|
|
|
|
- if kwargs.get("name"):
|
|
|
- data = filter(lambda x:kwargs.get("name") in x["stock_name"],data)
|
|
|
|
|
|
page = int(kwargs.get("page",1))
|
|
|
page_size = int(kwargs.get("page_size",20))
|
|
|
@@ -988,33 +1146,44 @@ def get_hot_follow(**kwargs):
|
|
|
"""
|
|
|
stock_date = kwargs.get("stock_date")
|
|
|
#qset = cm.UserFollows.objects.filter(stock_date=stock_date)
|
|
|
- qset = cm.UserFollows.objects.all()
|
|
|
+ cur_match_id = 9
|
|
|
+ player_ids = list(cm.Player.objects.filter(match_id=cur_match_id,match_status=1).values_list("id",flat=True))
|
|
|
+ qset = cm.UserFollows.objects.filter(follow_id__in=player_ids)
|
|
|
qset = qset.values("follow_id").annotate(count=Count("follow_id")).order_by("-count")
|
|
|
data = []
|
|
|
for q in qset:
|
|
|
player_id = q["follow_id"]
|
|
|
count = q["count"]
|
|
|
- player = cm.Player.objects.filter(id=player_id).first()
|
|
|
- today = cm.PlayerRecord.objects.filter(player_id=player_id).order_by("-stock_date").first().stock_date
|
|
|
- badest_income = cm.PlayerRecord.objects.filter(player_id=player_id).order_by("-today_income").first().today_income
|
|
|
- today_record = get_today_record(player_id,int(player.match_id),int(player.match_group),today)
|
|
|
- userinfo = get_user_info(today_record["user_id"])
|
|
|
-
|
|
|
- data.append(
|
|
|
- {
|
|
|
- "player_name":player.username,
|
|
|
- "count":count,
|
|
|
- "id":player_id,
|
|
|
- "today_fund":today_record["today_fund"],
|
|
|
- "total_income":"{}%".format(today_record["total_income"]*100),
|
|
|
- "today_income":"{}%".format(today_record["today_income"]*100),
|
|
|
- "badest_income":"{}%".format(badest_income*100),
|
|
|
- "style":userinfo.get("style"),
|
|
|
- "badge":userinfo.get("badge"),
|
|
|
- "match_id":player.match_id,
|
|
|
- "win_rate":calc_win_rate(player_id,player.match_id)
|
|
|
- }
|
|
|
- )
|
|
|
+
|
|
|
+ today = ccc.cache.hget("PLAYER_LATEST_%d"%player_id,"stock_date")
|
|
|
+ match_id = ccc.cache.hget("PLAYER_LATEST_%d"%player_id,"match_id")
|
|
|
+ match_group = ccc.cache.hget("PLAYER_LATEST_%d"%player_id,"match_group")
|
|
|
+ badest_income = ccc.cache.hget("PLAYER_LATEST_%d"%player_id,"badest_income")
|
|
|
+
|
|
|
+ today_record = get_today_record(player_id,match_id,match_group,today)
|
|
|
+
|
|
|
+ if today_record:
|
|
|
+ userinfo = get_user_info(today_record["user_id"])
|
|
|
+
|
|
|
+ win_rate = ccc.cache.hget("PLAYER_LATEST_%d"%today_record["player_id"],"win_rate")
|
|
|
+ win_rate = str(float(win_rate)*100)+"%"
|
|
|
+ if userinfo:
|
|
|
+ data.append(
|
|
|
+ {
|
|
|
+ "player_name":userinfo.get("username"),
|
|
|
+ "count":count,
|
|
|
+ "id":player_id,
|
|
|
+ "today_fund":today_record["today_fund"],
|
|
|
+ "total_income":"{}%".format(today_record["total_income"]*100),
|
|
|
+ "today_income":"{}%".format(today_record["today_income"]*100),
|
|
|
+ "badest_income":"{}%".format(badest_income*100),
|
|
|
+ "style":userinfo.get("style"),
|
|
|
+ "badge":userinfo.get("badge"),
|
|
|
+ "match_id":match_id,
|
|
|
+ "win_rate":win_rate
|
|
|
+ #"win_rate":calc_win_rate(player_id,match_id)
|
|
|
+ }
|
|
|
+ )
|
|
|
|
|
|
if kwargs.get("name"):
|
|
|
data = filter(lambda x:kwargs.get("name") in x["player_name"],data)
|
|
|
@@ -1047,7 +1216,10 @@ def get_hot_stock_sell(**kwargs):
|
|
|
# if td_count < yes_count:
|
|
|
# stock_name = cm.Stock.objects.filter(id=ysi).first().name
|
|
|
# data.append({"stock_name":stock_name,"count":yes_count-td_count,"id":ysi})
|
|
|
- qset = cm.HotStockSellCount.objects.filter(stock_date=stock_date).order_by("-count")
|
|
|
+ qset = cm.HotStockSellCount.objects.filter(stock_date=stock_date)
|
|
|
+ if kwargs.get("name"):
|
|
|
+ qset = qset.filter(stock_name__icontains=kwargs.get("name"))
|
|
|
+ qset = qset.order_by("-count")
|
|
|
|
|
|
data = list(qset.values("stock_name","stock_id","count"))
|
|
|
for item in data:
|
|
|
@@ -1098,7 +1270,7 @@ def get_hot_stock_sell_players(**kwargs):
|
|
|
today_record["today_income"] = "{}%".format(today_record["today_income"]*100)
|
|
|
today_record["total_income"] = "{}%".format(today_record["total_income"]*100)
|
|
|
data.append(today_record)
|
|
|
-
|
|
|
+ data = sorted(data,key=lambda x:x["today_fund"],reverse=True)
|
|
|
page = int(kwargs.get("page",0))
|
|
|
page_size = int(kwargs.get("page_size",20))
|
|
|
|
|
|
@@ -1117,10 +1289,18 @@ def get_win_rate_rank(request):
|
|
|
match_id = request.player.match_id
|
|
|
match_group = request.player.match_group
|
|
|
kwargs = request.json
|
|
|
+ match_id = 9
|
|
|
|
|
|
- qset = cm.WinDefendRank.objects.filter(match_id=match_id).order_by("-win_rate")
|
|
|
+ qset = cm.WinDefendRank.objects.filter(match_id=match_id,auto_complete__lt=5,match_status=1).order_by("-win_rate")
|
|
|
data = list(qset.values())
|
|
|
|
|
|
+ #data = []
|
|
|
+ #for item in datas:
|
|
|
+ # player = cm.Player.objects.filter(id=item["player_id"]).first()
|
|
|
+ # item["match_status"] = player.match_status if player else -1
|
|
|
+ # if item["match_status"] > -1:
|
|
|
+ # data.append(item)
|
|
|
+
|
|
|
page = int(kwargs.get("page",1))
|
|
|
page_size = int(kwargs.get("page_size",20))
|
|
|
|
|
|
@@ -1133,8 +1313,10 @@ def get_win_rate_rank(request):
|
|
|
item["badest_income"] = "{}%".format(item["badest_income"]*100)
|
|
|
item["total_income"] = "{}%".format(item["total_income"]*100)
|
|
|
userinfo = get_user_info(item["user_id"])
|
|
|
- item["badge"] = userinfo.get("badge")
|
|
|
- item["style"] = userinfo.get("style")
|
|
|
+ if userinfo:
|
|
|
+ item["badge"] = userinfo.get("badge")
|
|
|
+ item["style"] = userinfo.get("style")
|
|
|
+ item["username"] = userinfo.get("username")
|
|
|
|
|
|
|
|
|
return total,data
|
|
|
@@ -1148,9 +1330,16 @@ def get_defend_rank(request):
|
|
|
match_group = request.player.match_group
|
|
|
kwargs = request.json
|
|
|
|
|
|
- qset = cm.WinDefendRank.objects.filter(match_id=match_id).order_by("-badest_income")
|
|
|
+ qset = cm.WinDefendRank.objects.filter(match_id=match_id,auto_complete__lte=5,match_status=1).order_by("-badest_income")
|
|
|
data = list(qset.values())
|
|
|
|
|
|
+ #data = []
|
|
|
+ #for item in datas:
|
|
|
+ # player = cm.Player.objects.filter(id=item["player_id"]).first()
|
|
|
+ # item["match_status"] = player.match_status if player else -1
|
|
|
+ # if item["match_status"] > -1:
|
|
|
+ # data.append(item)
|
|
|
+
|
|
|
page = int(kwargs.get("page",1))
|
|
|
page_size = int(kwargs.get("page_size",20))
|
|
|
|
|
|
@@ -1162,14 +1351,12 @@ def get_defend_rank(request):
|
|
|
item["win_rate"] = "{}%".format(item["win_rate"]*100)
|
|
|
item["badest_income"] = "{}%".format(item["badest_income"]*100)
|
|
|
item["total_income"] = "{}%".format(item["total_income"]*100)
|
|
|
- item["style"] = []
|
|
|
- if item["zq"]:
|
|
|
- item["style"].apepnd(item["zq"])
|
|
|
- if item["cw"]:
|
|
|
- item["style"].apepnd(item["cw"])
|
|
|
- if item["df"]:
|
|
|
- item["style"].apepnd(item["df"])
|
|
|
- item["badge"] = cm.Player.objects.filter(id=item["player_id"]).first().badge
|
|
|
+
|
|
|
+ userinfo = get_user_info(item["user_id"])
|
|
|
+ if userinfo:
|
|
|
+ item["badge"] = userinfo.get("badge")
|
|
|
+ item["style"] = userinfo.get("style")
|
|
|
+ item["username"] = userinfo.get("username")
|
|
|
|
|
|
return total,data
|
|
|
|
|
|
@@ -1178,7 +1365,7 @@ def get_champion_articles_list(request):
|
|
|
"""
|
|
|
"""
|
|
|
kwargs = request.json
|
|
|
- qset = cm.Article.objects.filter(status=2,type="champion")
|
|
|
+ qset = cm.Article.objects.filter(status=2,type="champion").order_by("-id")
|
|
|
|
|
|
page = int(kwargs.get("page",0))
|
|
|
page_size = int(kwargs.get("page_size",20))
|
|
|
@@ -1197,7 +1384,6 @@ def get_wanzhu_comment(**kwargs):
|
|
|
"""
|
|
|
match_id = kwargs.get("match_id")
|
|
|
group_id = kwargs.get("group_id")
|
|
|
- print match_id
|
|
|
today = get_today_date()
|
|
|
players = get_match_group_players(match_id,group_id)
|
|
|
new_players = []
|
|
|
@@ -1259,7 +1445,10 @@ def get_enum_list(request):
|
|
|
u"核按钮"
|
|
|
],
|
|
|
"pz":[
|
|
|
- u"N/C字头新股",
|
|
|
+ u"10厘米",
|
|
|
+ u"20厘米",
|
|
|
+ u"30厘米",
|
|
|
+ u"N/C新股",
|
|
|
u"次新股",
|
|
|
u"可转债",
|
|
|
u"港股",
|
|
|
@@ -1286,6 +1475,10 @@ def get_player_list(**kwargs):
|
|
|
user_id = item["user_id"]
|
|
|
player_id = item["id"]
|
|
|
#user = cm.UserInfo.objects.filter(id=user_id).first()
|
|
|
+
|
|
|
+ today = ccc.cache.hget("PLAYER_LATEST_%d"%player_id,"stock_date")
|
|
|
+ match_id = ccc.cache.hget("PLAYER_LATEST_%d"%player_id,"match_id")
|
|
|
+ match_group = ccc.cache.hget("PLAYER_LATEST_%d"%player_id,"match_group")
|
|
|
today_record = get_today_record(player_id,match_id,match_group,today)
|
|
|
if today_record:
|
|
|
today_record.pop("id")
|
|
|
@@ -1294,6 +1487,9 @@ def get_player_list(**kwargs):
|
|
|
if user_info:
|
|
|
user_info.pop("id")
|
|
|
item.update(user_info)
|
|
|
+ if item.get("today_income"):
|
|
|
+ item["today_income"] = "{}%".format(item["today_income"]*100)
|
|
|
+ item["total_income"] = "{}%".format(item["total_income"]*100)
|
|
|
|
|
|
if kwargs.get("zq"):
|
|
|
data = filter(lambda x:kwargs.get("zq") == x["zq"],data)
|
|
|
@@ -1328,7 +1524,7 @@ def get_mine_style(request):
|
|
|
}
|
|
|
if player:
|
|
|
data["is_player"] = 1
|
|
|
- data["init_fund"] = player.fund
|
|
|
+ data["init_fund"] = player.fund if player.fund else 0
|
|
|
else:
|
|
|
data["is_player"] = 0
|
|
|
data["init_fund"] = None
|
|
|
@@ -1370,7 +1566,7 @@ def get_stock_players(**kwargs):
|
|
|
today_record["today_income"] = "{}%".format(today_record["today_income"]*100)
|
|
|
today_record["total_income"] = "{}%".format(today_record["total_income"]*100)
|
|
|
data.append(today_record)
|
|
|
-
|
|
|
+ data = sorted(data,key=lambda x:x["today_fund"],reverse=True)
|
|
|
#分页
|
|
|
page = int(kwargs.get("page",1))
|
|
|
page_size = int(kwargs.get("page_size",20))
|
|
|
@@ -1430,3 +1626,77 @@ def get_player_match_calendar(**kwargs):
|
|
|
return newdata
|
|
|
|
|
|
|
|
|
+def get_all_match(request):
|
|
|
+ """
|
|
|
+ """
|
|
|
+ now = datetime.datetime.now().strftime("%Y-%m-%d")
|
|
|
+ qset = cm.Match.objects.filter(start_time__lte=now).order_by("id")
|
|
|
+ data = list(qset.values())
|
|
|
+ return data
|
|
|
+
|
|
|
+
|
|
|
+def get_default_date(**kwargs):
|
|
|
+ """
|
|
|
+ """
|
|
|
+ match_id = kwargs.get("match_id")
|
|
|
+ record = cm.PlayerRecord.objects.filter(match_id=match_id).order_by("-stock_date").first()
|
|
|
+ if record:
|
|
|
+ return record.stock_date
|
|
|
+ else:
|
|
|
+ return get_today_date()
|
|
|
+
|
|
|
+@ccc.cache_data()
|
|
|
+def get_stock_search(**kwargs):
|
|
|
+ """
|
|
|
+ """
|
|
|
+ qset = cm.Stock.objects.all()
|
|
|
+ data = list(qset.values("id","name","code"))
|
|
|
+ for item in data:
|
|
|
+ if item["code"]:
|
|
|
+ item["label"] = "%s(%s)" % (item["name"],item["code"])
|
|
|
+ else:
|
|
|
+ item["label"] = "%s" % item["name"]
|
|
|
+ return data
|
|
|
+
|
|
|
+def get_mine_latest(request):
|
|
|
+ """
|
|
|
+ """
|
|
|
+ player_id = request.player.id
|
|
|
+ match_id = request.player.match_id
|
|
|
+ match_group = request.player.match_group
|
|
|
+
|
|
|
+ today = get_today_date()
|
|
|
+
|
|
|
+ _match_id = ccc.cache.hget("PLAYER_LATEST_%d"%player_id,"match_id")
|
|
|
+ if _match_id:
|
|
|
+ match_id = _match_id
|
|
|
+ _today = ccc.cache.hget("PLAYER_LATEST_%d"%player_id,"stock_date")
|
|
|
+ if _today:
|
|
|
+ today = _today
|
|
|
+ _match_group = ccc.cache.hget("PLAYER_LATEST_%d"%player_id,"match_group")
|
|
|
+ if _match_group:
|
|
|
+ match_group = _match_group
|
|
|
+
|
|
|
+ #rst = get_today_record(player_id,match_id,match_group,today)
|
|
|
+ try:
|
|
|
+ rst = get_today_record_actual(player_id,match_id,match_group)
|
|
|
+
|
|
|
+ rst["today_income"] = "{}%".format(rst["today_income"]*100)
|
|
|
+ rst["total_income"] = "{}%".format(rst["total_income"]*100)
|
|
|
+
|
|
|
+ return rst
|
|
|
+ except:
|
|
|
+ return {}
|
|
|
+
|
|
|
+def get_match_validdates(match_id):
|
|
|
+ """
|
|
|
+ """
|
|
|
+ #qdata = request.json
|
|
|
+ #match_id = qdata.get("match_id")
|
|
|
+
|
|
|
+ match = cm.Match.objects.filter(id=match_id).first()
|
|
|
+ if match:
|
|
|
+ validdates = json.loads(match.valid_dates) if match.valid_dates else []
|
|
|
+ validdates.sort()
|
|
|
+ return validdates
|
|
|
+ return []
|