|
@@ -833,12 +833,16 @@ def add_model(cls,**kwargs):
|
|
|
user_id=user_id,
|
|
|
match_id=match_id,
|
|
|
stock_date=stock_date)
|
|
|
+ #计算仓位
|
|
|
+ today_cangwei = round(today_stock_fund/today_fund,4)*100
|
|
|
|
|
|
obj.init_fund = init_fund
|
|
|
obj.yesterday_fund = yesterday_fund
|
|
|
obj.yesterday_stock = yesterday_stock
|
|
|
obj.yesterday_stock_img = yesterday_stock_img
|
|
|
obj.today_fund = today_fund
|
|
|
+ obj.today_stock_total = today_stock_fund
|
|
|
+ obj.today_cangwei = today_cangwei
|
|
|
obj.today_stock = today_stock
|
|
|
obj.today_stock_img = today_stock_img
|
|
|
obj.username = username
|
|
@@ -1912,11 +1916,15 @@ def update_user_style(**kwargs):
|
|
|
print(e)
|
|
|
#avatar = kwargs.pop("avatar")
|
|
|
|
|
|
+ if re.search(settings.FORBID_NAME,kwargs.get("username")):
|
|
|
+ raise ce.TipException(u"名字中包含特殊关键字,请更换名称后重试!")
|
|
|
+
|
|
|
cm.UserInfo.objects.filter(id=user_id).update(**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(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)
|
|
@@ -2191,6 +2199,10 @@ def do_wx_pay(request):
|
|
|
|
|
|
orgcode = ccc.cache.get(phone)
|
|
|
|
|
|
+ print(signup_name)
|
|
|
+ if re.search(settings.FORBID_NAME,signup_name):
|
|
|
+ raise ce.TipException(u"名字中包含特殊关键字,请更换名称后重试!")
|
|
|
+
|
|
|
if not phone == "13883187629":
|
|
|
if not phcode == orgcode:
|
|
|
raise ce.TipException(u"验证码不正确!")
|
|
@@ -3983,7 +3995,7 @@ def get_user_fundinout(request):
|
|
|
user_id = 0
|
|
|
if not user_id:
|
|
|
user_id = qdata.get("user_id")
|
|
|
- qdata = request.json()
|
|
|
+ qdata = request.json
|
|
|
stock_date = qdata.get("stock_date")
|
|
|
|
|
|
rst = cm.FundInOut.objects.filter(user_id = user_id,stock_date=stock_date).values().first()
|
|
@@ -3998,7 +4010,7 @@ def delete_user_fundinout(request):
|
|
|
if not user_id:
|
|
|
user_id = qdata.get("user_id")
|
|
|
match_id = ccc.get_cur_match().id
|
|
|
- qdata = request.json()
|
|
|
+ qdata = request.json
|
|
|
stock_date = qdata.get("stock_date")
|
|
|
|
|
|
#删除出入资金
|
|
@@ -4017,3 +4029,30 @@ def delete_user_fundinout(request):
|
|
|
# # player.fund = yesterday.init_fund
|
|
|
# # player.save()
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+#@ccc.cache_data_kw(5*60)
|
|
|
+def get_match_cangwei_avg_allday(**qdata):
|
|
|
+ """每天人均仓位情况
|
|
|
+ """
|
|
|
+ match_id = qdata.get("match_id")
|
|
|
+
|
|
|
+ allday_cangwei_avg_list = []
|
|
|
+ prset = cm.PlayerRecord.get_db_model(match_id).objects.filter(match_id=match_id).values("stock_date")\
|
|
|
+ .annotate(cnt=Count("stock_date"),total=Sum("today_cangwei"))
|
|
|
+ for item in prset:
|
|
|
+ stock_date = item["stock_date"]
|
|
|
+ cnt = item["cnt"]
|
|
|
+ total = item["total"]
|
|
|
+
|
|
|
+ if cnt and total:
|
|
|
+ today_cangwei_avg = "{}%".format(round(total/cnt,2)) if cnt>0 else 0.0
|
|
|
+
|
|
|
+ allday_cangwei_avg_list.append({
|
|
|
+ "stock_date":stock_date,
|
|
|
+ "today_cangwei_avg":today_cangwei_avg
|
|
|
+ })
|
|
|
+
|
|
|
+ allday_cangwei_avg_list = sorted(allday_cangwei_avg_list,key=lambda x:x["stock_date"],reverse=True)
|
|
|
+ rst = {"list":allday_cangwei_avg_list}
|
|
|
+ return rst
|