|
|
@@ -14,6 +14,7 @@ import common.models as cm
|
|
|
import common.error_info as ce
|
|
|
import common.common_functions as ccf
|
|
|
import common.common_control as ccc
|
|
|
+import common.constant as const
|
|
|
import account.password_handle as ph
|
|
|
from utils.exceltool import ExcelTool
|
|
|
from utils.jgpush import send_notification_by_registration_ids
|
|
|
@@ -916,6 +917,10 @@ def get_detail_info(cls,**kwargs):
|
|
|
if model_name == "Stock":
|
|
|
rst["choiced"] = ccc.cache.get("%s_choices" % id)
|
|
|
rst["user_num"] = ccc.cache.get("%s_choices" % id)
|
|
|
+ if model_name == "UserArticleRelation":
|
|
|
+ article_ids = rst["article_ids"].split(",")
|
|
|
+ articles = list(cm.Article.objects.filter(id__in=article_ids).values())
|
|
|
+ rst["articles"] = articles
|
|
|
return rst
|
|
|
|
|
|
#@ccc.cache_data()
|
|
|
@@ -956,8 +961,14 @@ def get_list_info(cls,**kwargs):
|
|
|
qset = qset.filter(username__icontains=kwargs.get("username"))
|
|
|
if kwargs.get("usercode"):
|
|
|
qset = qset.filter(usercode=kwargs.get("usercode"))
|
|
|
+ if model_name == "StockComments":
|
|
|
+ if kwargs.get("stock_id"):
|
|
|
+ qset = qset.filter(stock_id=kwargs.get("stock_id"))
|
|
|
+ if model_name == "UserArticleRelation":
|
|
|
+ data = list(qset.order_by("-id").values("id","user_id","user_name","user_avatar"))
|
|
|
+ else:
|
|
|
+ data = list(qset.order_by("-id").values())
|
|
|
|
|
|
- data = list(qset.order_by("-id").values())
|
|
|
page = int(kwargs.get("page",0))
|
|
|
page_size = int(kwargs.get("page_size",20))
|
|
|
if page and page_size:
|
|
|
@@ -1965,7 +1976,6 @@ def send_phcode(request):
|
|
|
"""
|
|
|
qdata = request.json
|
|
|
phone = qdata.get("phone")
|
|
|
- import random
|
|
|
code = "%s%s%s%s" % (random.randint(0,9),random.randint(0,9),random.randint(0,9),random.randint(0,9))
|
|
|
send_verify_code(phone,code)
|
|
|
ccc.cache.set(phone,code,120)
|
|
|
@@ -2850,6 +2860,7 @@ def get_group_rank_list_v3(request):
|
|
|
|
|
|
def get_article_type_list(**kwargs):
|
|
|
rst = [u"腰斩专场",u"冠军交割",u"牛人专场",u"游资列传",u"妖股列传"]
|
|
|
+ rst = const.ARTICLE_TYPE_LIST
|
|
|
return rst
|
|
|
|
|
|
|
|
|
@@ -3005,3 +3016,49 @@ def delete_user_info(request):
|
|
|
cm.Player.objects.filter(user_id=uid).delete()
|
|
|
#cm.PlayerRecord.objects.filter(user_id=uid).delete()
|
|
|
|
|
|
+def get_random_bake_list(**kwargs):
|
|
|
+ """
|
|
|
+ """
|
|
|
+ baikes = list(cm.BaikeDetail.objects.all().values())
|
|
|
+ randomi = []
|
|
|
+ while len(randomi) < 5:
|
|
|
+ num = random.randint(0,len(baikes))
|
|
|
+ if not num in randomi:
|
|
|
+ randomi.append(num)
|
|
|
+ rst = [baikes[x] for x in randomi]
|
|
|
+ return rst
|
|
|
+
|
|
|
+
|
|
|
+def articles_top5_by_type(**kwargs):
|
|
|
+ """
|
|
|
+ """
|
|
|
+ cats = const.ARTICLE_TYPE_LIST
|
|
|
+ data = []
|
|
|
+ for cat in cats:
|
|
|
+ articles = list(cm.Article.objects.filter(category=cat).order_by("-id").values()[:5])
|
|
|
+ data.append({"category":cat,"articles":articles})
|
|
|
+ return data
|
|
|
+
|
|
|
+def get_match_winlost_top5(**kwargs):
|
|
|
+ """
|
|
|
+ """
|
|
|
+ data = []
|
|
|
+ matchs = cm.Match.objects.filter(id__gte=8)
|
|
|
+ for match in matchs:
|
|
|
+ match_id = match.id
|
|
|
+ match_name = match.name
|
|
|
+ end_time = match.end_time
|
|
|
+ records = cm.PlayerRecord.get_db_model(match_id).objects.filter(stock_date=end_time)
|
|
|
+ if kwargs.get("order_by") == "total_income_ratio":
|
|
|
+ records = records.order_by("total_income")
|
|
|
+ if kwargs.get("order_by") == "-total_income_ratio":
|
|
|
+ records = records.order_by("-total_income")
|
|
|
+ records = list(records.values()[:5])
|
|
|
+ for item in records:
|
|
|
+ item["total_win"] = item["today_fund"] - item["init_fund"]
|
|
|
+ data.append({"match_id":match_id,"match_name":match_name,"top5records":records})
|
|
|
+ return data
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|