|
@@ -43,6 +43,7 @@ def async(f):
|
|
|
|
|
|
|
|
|
def get_today_date():
|
|
|
+ #return "2021-12-10"
|
|
|
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
|
|
@@ -134,6 +135,10 @@ def get_player_match_list(request):
|
|
|
"""选手参赛列表数据
|
|
|
"""
|
|
|
uid = request.user.id
|
|
|
+ now_str = datetime.datetime.now().strftime("%Y-%m-%d")
|
|
|
+ cur_match_id = cm.Match.objects.filter(start_time__lte=now_str).first().id
|
|
|
+ cur_match_id = 7
|
|
|
+ #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())
|
|
|
|
|
@@ -169,6 +174,11 @@ def get_player_match_detail(request):
|
|
|
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 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")
|
|
|
|
|
|
match = cm.Match.objects.filter(id=match_id).values().first()
|
|
@@ -181,6 +191,7 @@ def get_player_match_detail(request):
|
|
|
#today_record = {}
|
|
|
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:
|
|
@@ -229,6 +240,7 @@ 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).values())
|
|
|
return match,groups
|
|
|
|
|
|
#@ccc.cache_data()
|
|
@@ -259,10 +271,15 @@ def get_cache_rank_list(player_id,match_id):
|
|
|
player["username"] = username
|
|
|
player["total_income"] = "{}%".format(today_record["total_income"]*100)
|
|
|
|
|
|
- player["fund"] = round(player["fund"],4)
|
|
|
- player["init_fund"] = round(player["init_fund"],4)
|
|
|
- player["today_fund"] = round(player["today_fund"],4)
|
|
|
- new_players.append(player)
|
|
|
+ try:
|
|
|
+ player["fund"] = round(player["fund"],4) if player["fund"] else 0.0
|
|
|
+ player["init_fund"] = round(player["init_fund"],4)
|
|
|
+ player["fund"] = round(player["init_fund"],4)
|
|
|
+ player["today_fund"] = round(player["today_fund"],4)
|
|
|
+ new_players.append(player)
|
|
|
+ except Exception as e:
|
|
|
+ print player
|
|
|
+ pass
|
|
|
new_players = sorted(new_players,key=lambda x:x["group_rank"])
|
|
|
item["players"] = new_players[:3]
|
|
|
return match,groups
|
|
@@ -274,6 +291,7 @@ def get_rank_list(request):
|
|
|
qdata = request.json
|
|
|
player_id = request.player.id
|
|
|
match_id = request.player.match_id
|
|
|
+ match_id = 8
|
|
|
match,groups = get_cache_rank_list(player_id,match_id)
|
|
|
|
|
|
ret = {"match":match,"groups":groups}
|
|
@@ -307,6 +325,8 @@ def get_group_rank_list(request):
|
|
|
player_id = request.player.id
|
|
|
match_id = request.player.match_id
|
|
|
|
|
|
+ match_id = 8
|
|
|
+
|
|
|
match = get_match_info(match_id)
|
|
|
group = get_group_info(group_id)
|
|
|
|
|
@@ -330,12 +350,16 @@ def get_group_rank_list(request):
|
|
|
|
|
|
if today_record:
|
|
|
player.update(today_record)
|
|
|
- player["username"] = username
|
|
|
- player["total_income"] = "{}%".format(player["total_income"]*100)
|
|
|
- player["fund"] = round(player["fund"],4)
|
|
|
- player["init_fund"] = round(player["init_fund"],4)
|
|
|
- player["today_fund"] = round(player["today_fund"],4)
|
|
|
- new_players.append(player)
|
|
|
+ try:
|
|
|
+ player["username"] = username
|
|
|
+ player["total_income"] = "{}%".format(player["total_income"]*100)
|
|
|
+ player["fund"] = round(player["fund"],4) if player["fund"] else 0
|
|
|
+ player["init_fund"] = round(player["init_fund"],4)
|
|
|
+ player["fund"] = round(player["init_fund"],4)
|
|
|
+ player["today_fund"] = round(player["today_fund"],4)
|
|
|
+ new_players.append(player)
|
|
|
+ except Exception as e:
|
|
|
+ print e
|
|
|
new_players = sorted(new_players,key=lambda x:x["group_rank"])
|
|
|
|
|
|
#分页
|
|
@@ -363,6 +387,12 @@ 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
|
|
|
+
|
|
|
records_set = cm.PlayerRecord.objects.filter(player_id=player_id,match_id=match_id).order_by("-stock_date")
|
|
|
data = list(records_set.values())
|
|
|
for item in data:
|
|
@@ -417,6 +447,8 @@ def add_model(cls,**kwargs):
|
|
|
is_markt = int(kwargs.get("is_markt",0))
|
|
|
|
|
|
player = cm.Player.objects.filter(id=player_id).first()
|
|
|
+ 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()
|
|
@@ -629,6 +661,8 @@ def add_player_record_single(**kwargs):
|
|
|
is_markt = int(kwargs.get("is_markt",0))
|
|
|
|
|
|
player = cm.Player.objects.filter(usercode=usercode,match_id=match_id).first()
|
|
|
+ if player.fund <=0 :
|
|
|
+ raise ce.TipException(u"请先输入您的初始资金后再提交数据!")
|
|
|
player_id = player.id
|
|
|
user_id = player.user_id
|
|
|
init_fund = player.fund
|
|
@@ -719,3 +753,13 @@ def get_cur_record(request):
|
|
|
data["today_stock"] = json.loads(data["today_stock"]) if data["today_stock"] else []
|
|
|
return data
|
|
|
|
|
|
+def update_user_fund(**kwargs):
|
|
|
+ """
|
|
|
+ """
|
|
|
+ user_id = kwargs.pop("user_id")
|
|
|
+ player_id = kwargs.pop("player_id")
|
|
|
+ init_fund = kwargs.pop("init_fund")
|
|
|
+ if player_id and init_fund:
|
|
|
+ cm.Player.objects.filter(id=player_id).update(fund=init_fund)
|
|
|
+ return True
|
|
|
+
|