|
|
@@ -219,6 +219,7 @@ 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)
|
|
|
+ item["avatar"] = get_user_info(item["user_id"])["avatar"]
|
|
|
|
|
|
today_record = {}
|
|
|
if records_set:
|
|
|
@@ -571,8 +572,6 @@ def get_group_rank_list(request):
|
|
|
else:
|
|
|
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",50))
|
|
|
@@ -733,6 +732,8 @@ def add_model(cls,**kwargs):
|
|
|
player_id = player.id,
|
|
|
stock_date = stock_date
|
|
|
)
|
|
|
+ usobj.fund = ts["fund"]
|
|
|
+ usobj.save()
|
|
|
ts["stock_id"] = stock_id
|
|
|
new_stock_list.append(ts)
|
|
|
except Exception as e:
|
|
|
@@ -773,21 +774,27 @@ def add_model(cls,**kwargs):
|
|
|
#入资金
|
|
|
if fundin > fundout:
|
|
|
fundin = fundin - fundout
|
|
|
- today_income = (today_fund-(yesterday_fund+fundin))/(float(yesterday_fund) + fundin)
|
|
|
+ if yesterday:
|
|
|
+ today_income = (today_fund-(yesterday_fund+fundin))/(float(yesterday_fund) + fundin)
|
|
|
+ obj.yesterday_fund = obj.yesterday_fund + fundin
|
|
|
+ else:
|
|
|
+ today_income = 0.0
|
|
|
total_income = (today_fund-init_fund-fundin)/(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
|
|
|
#出资金
|
|
|
else:
|
|
|
fundout = fundout - fundin
|
|
|
- today_income = (today_fund-(yesterday_fund-fundout))/float(yesterday_fund)
|
|
|
+ if yesterday:
|
|
|
+ today_income = (today_fund-(yesterday_fund-fundout))/float(yesterday_fund)
|
|
|
+ obj.yesterday_fund = round(today_fund/(1+today_income),4)
|
|
|
+ else:
|
|
|
+ today_income = 0.0
|
|
|
total_income = (today_fund+fundout-init_fund)/init_fund
|
|
|
|
|
|
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)
|
|
|
|
|
|
if float(today_income)>0.6:
|
|
|
raise ce.TipException(u"今日盈利已超过60%,请仔细核对数据或直接联系顽主!")
|
|
|
@@ -1293,19 +1300,20 @@ def get_hot_stock_buy(**kwargs):
|
|
|
qset = cm.UserStock.objects.filter(stock_date=stock_date)
|
|
|
if kwargs.get("name"):
|
|
|
qset = cm.UserStock.objects.filter(stock_name__icontains=kwargs.get("name"))
|
|
|
- qset = qset.values("stock_id","stock_name").annotate(count=Count("stock_id")).order_by("-count")
|
|
|
+ qset = qset.values("stock_id","stock_name").annotate(count=Count("stock_id"),total_fund=Sum("fund")).order_by("-count")
|
|
|
data = []
|
|
|
for q in qset:
|
|
|
stock_id = q["stock_id"]
|
|
|
count = q["count"]
|
|
|
stock_name = q.get("stock_name")
|
|
|
+ total_fund = q["total_fund"]
|
|
|
|
|
|
comments_count = ccc.cache.get("%s_comments" % stock_id)
|
|
|
choice_count = ccc.cache.get("%s_choices" % stock_id)
|
|
|
comments_count = comments_count if comments_count else 0
|
|
|
choice_count = choice_count if choice_count else 0
|
|
|
|
|
|
- data.append({"stock_name":stock_name,"id":stock_id,"count":count,"comments_count":comments_count,"choice_count":choice_count})
|
|
|
+ data.append({"stock_name":stock_name,"id":stock_id,"count":count,"comments_count":comments_count,"choice_count":choice_count,"total_fund":total_fund})
|
|
|
|
|
|
|
|
|
page = int(kwargs.get("page",1))
|
|
|
@@ -1725,7 +1733,7 @@ def update_user_style(**kwargs):
|
|
|
"""
|
|
|
user_id = kwargs.pop("user_id")
|
|
|
#player_id = kwargs.pop("player_id")
|
|
|
- init_fund = kwargs.pop("init_fund")
|
|
|
+ #init_fund = kwargs.pop("init_fund")
|
|
|
#avatar = kwargs.pop("avatar")
|
|
|
|
|
|
cm.UserInfo.objects.filter(id=user_id).update(**kwargs)
|
|
|
@@ -2237,15 +2245,21 @@ def add_wanzhu_consult(request):
|
|
|
openid = request.user.get("openid")
|
|
|
qdata = request.json
|
|
|
content = qdata.get("cotent")
|
|
|
+ width = qdata.get("width")
|
|
|
+ height = qdata.get("height")
|
|
|
pid = qdata.get("pid")
|
|
|
|
|
|
- obj = cm.WanzhuConsult.objects.create(
|
|
|
+ wanzhu_obj = cm.WanzhuConsult.objects.create(
|
|
|
user_id = user_id,
|
|
|
user_name = user_name,
|
|
|
user_avatar = user_avatar,
|
|
|
content = content,
|
|
|
pid = pid
|
|
|
)
|
|
|
+ wanzhu_obj.width = width
|
|
|
+ wanzhu_obj.height = height
|
|
|
+ wanzhu_obj.save()
|
|
|
+
|
|
|
obj,flag = cm.Consult.objects.get_or_create(
|
|
|
user_id = user_id,
|
|
|
)
|
|
|
@@ -2254,6 +2268,8 @@ def add_wanzhu_consult(request):
|
|
|
obj.content = content
|
|
|
obj.view_status = 0
|
|
|
obj.reply_status = 0
|
|
|
+ obj.width = width
|
|
|
+ obj.height = height
|
|
|
obj.ctime = datetime.datetime.now()
|
|
|
obj.save()
|
|
|
#自动回复
|
|
|
@@ -2455,19 +2471,25 @@ def modify_user_fund(request):
|
|
|
#入资金
|
|
|
if fundin > fundout:
|
|
|
fundin = fundin - fundout
|
|
|
- today_income = round((today_fund-(yesterday_fund+fundin))/(float(yesterday_fund) + fundin),4)
|
|
|
+ if yesterday:
|
|
|
+ today_income = round((today_fund-(yesterday_fund+fundin))/(float(yesterday_fund) + fundin),4)
|
|
|
+ yesterday_fund = yesterday_fund + fundin
|
|
|
+ else:
|
|
|
+ today_income = 0.0
|
|
|
total_income = round((today_fund-init_fund-fundin)/(init_fund+fundin),4)
|
|
|
|
|
|
init_fund = init_fund + fundin
|
|
|
- yesterday_fund = yesterday_fund + fundin
|
|
|
#出资金
|
|
|
else:
|
|
|
fundout = fundout - fundin
|
|
|
- today_income = round((today_fund-(yesterday_fund-fundout))/float(yesterday_fund),4)
|
|
|
+ if yesterday:
|
|
|
+ today_income = round((today_fund-(yesterday_fund-fundout))/float(yesterday_fund),4)
|
|
|
+ yesterday_fund = round(today_fund/(1+today_income),4)
|
|
|
+ else:
|
|
|
+ today_income = 0.0
|
|
|
total_income = round((today_fund+fundout-init_fund)/init_fund,4)
|
|
|
|
|
|
init_fund = round(today_fund/(1+total_income),4)
|
|
|
- yesterday_fund = round(today_fund/(1+today_income),4)
|
|
|
|
|
|
today_income = "{}%".format(today_income*100)
|
|
|
total_income = "{}%".format(total_income*100)
|
|
|
@@ -2639,3 +2661,193 @@ def get_user_follows_v3(request):
|
|
|
return total,data
|
|
|
else:
|
|
|
return len(data),data
|
|
|
+
|
|
|
+
|
|
|
+def get_latest_match_info(request):
|
|
|
+ """
|
|
|
+ """
|
|
|
+ cur_match = cm.Match.objects.filter(match_status=3).order_by("-id").values().first()
|
|
|
+ cur_match_id = cur_match.get("id")
|
|
|
+ groups = list(cm.MatchGroup.objects.filter(match_id=cur_match_id,is_active=1).order_by("order").values())
|
|
|
+ cur_match["groups"] = groups
|
|
|
+ return cur_match
|
|
|
+
|
|
|
+def get_article_info(**kwargs):
|
|
|
+ """
|
|
|
+ """
|
|
|
+ _id = kwargs.get("id")
|
|
|
+ rst = cm.Article.objects.filter(id=_id).values().first()
|
|
|
+ rst["url"] = "https://www.hunanwanzhu.com/topic/article.html?id="+str(_id)
|
|
|
+ return rst
|
|
|
+
|
|
|
+
|
|
|
+def get_profit_list(**kwargs):
|
|
|
+ """盈亏列表
|
|
|
+ """
|
|
|
+ stock_date = kwargs.get("stock_date")
|
|
|
+ match_id = kwargs.get("match_id")
|
|
|
+ _type = kwargs.get("type")
|
|
|
+
|
|
|
+ if not stock_date:
|
|
|
+ stock_date = get_today_date()
|
|
|
+
|
|
|
+ qset = cm.PlayerRecord.get_db_model(match_id).objects.filter(stock_date=stock_date)
|
|
|
+
|
|
|
+ #if _type == "win":
|
|
|
+ # qset = qset.filter(today_income__gte=0).order_by("-today_income")
|
|
|
+ #if _type == "loss":
|
|
|
+ # qset = qset.filter(today_income__lt=0).order_by("today_income")
|
|
|
+
|
|
|
+ data = list(qset.values())
|
|
|
+ for item in data:
|
|
|
+ item["win_loss"] = item["today_fund"] - item["yesterday_fund"]
|
|
|
+ item["total_win_loss"] = item["today_fund"] - item["init_fund"]
|
|
|
+ if _type == "win":
|
|
|
+ data = sorted(data,key=lambda x:x["win_loss"],reverse=True)
|
|
|
+ if _type == "loss":
|
|
|
+ data = sorted(data,key=lambda x:x["win_loss"])
|
|
|
+ if _type == "total_win":
|
|
|
+ data = sorted(data,key=lambda x:x["total_win_loss"],reverse=True)
|
|
|
+ if _type == "total_loss":
|
|
|
+ data = sorted(data,key=lambda x:x["total_win_loss"])
|
|
|
+
|
|
|
+ page = int(kwargs.get("page",0))
|
|
|
+ page_size = int(kwargs.get("page_size",20))
|
|
|
+
|
|
|
+ if page and page_size:
|
|
|
+ total,data = ccf.get_page_list(data,page,page_size)
|
|
|
+ else:
|
|
|
+ total = len(data)
|
|
|
+ #data = list(qset.values())
|
|
|
+
|
|
|
+ return total,data
|
|
|
+
|
|
|
+
|
|
|
+def get_group_rank_list_v3(request):
|
|
|
+ """排名列表
|
|
|
+ """
|
|
|
+ qdata = request.json
|
|
|
+ kwargs = qdata
|
|
|
+
|
|
|
+ group_id = qdata.get("id")
|
|
|
+ match_id = qdata.get("match_id")
|
|
|
+
|
|
|
+ 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_users(match_id,group_id)
|
|
|
+ new_players = []
|
|
|
+ for player in players:
|
|
|
+ user_id = player["user_id"]
|
|
|
+ username = player["username"]
|
|
|
+ match_group = group_id
|
|
|
+ today_record = ccc.get_today_record(user_id,match_id,match_group,today)
|
|
|
+
|
|
|
+ if today_record:
|
|
|
+ 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(player["total_income"]*100)
|
|
|
+ player["today_income"] = "{}%".format(player["today_income"]*100)
|
|
|
+ player["fund"] = round(player["fund"],4)
|
|
|
+ player["init_fund"] = round(player["init_fund"],4)
|
|
|
+ player["today_fund"] = round(player["today_fund"],4)
|
|
|
+ player["today_stock_img"] = json.loads(player["today_stock_img"]) if player["today_stock_img"] else []
|
|
|
+ #player["win_rate"] = calc_win_rate(user_id,match_id)
|
|
|
+ player["zan_count"] = player["zans"]
|
|
|
+ new_players.append(player)
|
|
|
+
|
|
|
+ if kwargs.get("order_by") == "today_income__asc":
|
|
|
+ new_players = sorted(new_players,key=lambda x:x["org_today_income"])
|
|
|
+ elif kwargs.get("order_by") == "today_income__desc" :
|
|
|
+ new_players = sorted(new_players,key=lambda x:x["org_today_income"],reverse=True)
|
|
|
+ elif kwargs.get("order_by") == "total_income__asc":
|
|
|
+ new_players = sorted(new_players,key=lambda x:x["org_total_income"])
|
|
|
+ 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["org_total_income"],reverse=True)
|
|
|
+
|
|
|
+ #分页
|
|
|
+ page = int(kwargs.get("page",0))
|
|
|
+ page_size = int(kwargs.get("page_size",50))
|
|
|
+ if page and page_size:
|
|
|
+ total,new_players = ccf.get_page_list(new_players,page,page_size)
|
|
|
+ else:
|
|
|
+ total = len(new_players)
|
|
|
+ return total,new_players
|
|
|
+
|
|
|
+
|
|
|
+def get_article_type_list(**kwargs):
|
|
|
+ rst = [u"每日点评",u"冠军心得",u"腰斩心得",u"牛人专访"]
|
|
|
+ return rst
|
|
|
+
|
|
|
+
|
|
|
+def get_wanzhu_consult_list(**kwargs):
|
|
|
+ """
|
|
|
+ """
|
|
|
+ qset = cm.Consult.objects.all().order_by("-ctime")
|
|
|
+ if kwargs.get("username"):
|
|
|
+ qset = qset.filter(user_name__icontains=kwargs.get("username"))
|
|
|
+ if kwargs.get("reply_status"):
|
|
|
+ qset = qset.filter(reply_status=kwargs.get("reply_status"))
|
|
|
+ if kwargs.get("content"):
|
|
|
+ qset = qset.filter(Q(content__icontains=kwargs.get("content"))|Q(reply_content__icontains=kwargs.get("content")))
|
|
|
+ data = list(qset.values())
|
|
|
+ for item in data:
|
|
|
+ user_id = item["user_id"]
|
|
|
+ userinfo = get_user_info(user_id)
|
|
|
+ if userinfo:
|
|
|
+ item["user_code"] = userinfo.get("usercode")
|
|
|
+
|
|
|
+ #分页
|
|
|
+ page = int(kwargs.get("page",1))
|
|
|
+ page_size = int(kwargs.get("page_size",20))
|
|
|
+ if page and page_size:
|
|
|
+ total,data = ccf.get_page_list(data,page,page_size)
|
|
|
+ else:
|
|
|
+ total = len(data)
|
|
|
+ return total,data
|
|
|
+
|
|
|
+
|
|
|
+def get_sub_category(pid):
|
|
|
+ """
|
|
|
+ """
|
|
|
+ qset = cm.BaikeCategory.objects.filter(parent_id=pid)
|
|
|
+ qdata = list(qset.values())
|
|
|
+ if qdata:
|
|
|
+ for subitem in qdata:
|
|
|
+ subitem["type"] = "ent"
|
|
|
+ subitem["children"] = get_sub_category(subitem["id"])
|
|
|
+ return qdata
|
|
|
+
|
|
|
+
|
|
|
+def get_baike_category_tree(**kwargs):
|
|
|
+ """
|
|
|
+ """
|
|
|
+ parents = list(cm.BaikeCategory.objects.filter(parent_id__isnull=True).values())
|
|
|
+ for item in parents:
|
|
|
+ item["children"] = get_sub_category(item["id"])
|
|
|
+ return parents
|
|
|
+
|
|
|
+
|
|
|
+def get_baike_list_by_category(**kwargs):
|
|
|
+ category_id = kwargs.get("category_id")
|
|
|
+ qset = cm.BaikeDetail.objects.filter(category_id=category_id)
|
|
|
+ data = list(qset.values("id","name"))
|
|
|
+ return data
|
|
|
+
|
|
|
+
|
|
|
+def get_baike_detail(**kwargs):
|
|
|
+ #_id = kwargs.get("id")
|
|
|
+ category_id = kwargs.get("category_id")
|
|
|
+ data = list(cm.BaikeDetail.objects.filter(category_id=category_id).values())
|
|
|
+ return data
|
|
|
+
|
|
|
+
|