|
@@ -35,7 +35,7 @@ from xlutils.copy import copy
|
|
|
from xltpl.writer import BookWriter
|
|
|
from django_redis import get_redis_connection
|
|
|
from constants import *
|
|
|
-from utils.aliyun_sms import send_verify_code
|
|
|
+from utils.aliyun_sms import send_verify_code,send_signup_success
|
|
|
|
|
|
def async(f):
|
|
|
def wrapper(*args, **kwargs):
|
|
@@ -45,7 +45,6 @@ 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
|
|
@@ -175,9 +174,12 @@ def get_player_match_detail(request):
|
|
|
userinfo = {}
|
|
|
cur_user_id = user_id
|
|
|
cur_player_id = qdata.get("player_id")
|
|
|
+
|
|
|
if not cur_player_id:
|
|
|
cur_player_id = player_id
|
|
|
|
|
|
+ today = get_today_date()
|
|
|
+
|
|
|
ismine = True if int(cur_player_id) == player_id else False
|
|
|
if not match_id:
|
|
|
player = cm.Player.objects.filter(id=cur_player_id).first()
|
|
@@ -190,6 +192,7 @@ def get_player_match_detail(request):
|
|
|
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")
|
|
|
+ today = records_set.first().stock_date
|
|
|
else:
|
|
|
if qdata.get("player_id"):
|
|
|
player_id = qdata.get("player_id")
|
|
@@ -214,17 +217,19 @@ def get_player_match_detail(request):
|
|
|
item["today_income"] = "{}%".format(item["today_income"]*100)
|
|
|
item["total_income"] = "{}%".format(item["total_income"]*100)
|
|
|
|
|
|
- today = get_today_date()
|
|
|
today_record = {}
|
|
|
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 record_id:
|
|
|
+ today = records_set.filter(id=record_id).first().stock_date
|
|
|
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 []
|
|
@@ -256,7 +261,7 @@ def get_player_match_detail(request):
|
|
|
else:
|
|
|
is_follow = 0
|
|
|
if today_record and today_record.get("today_fund"):
|
|
|
- today_record["today_income_fund"] = round((today_record["today_fund"] - today_record["yesterday_fund"]),2)*10000 if today_record["yesterday_fund"] else 0.00
|
|
|
+ today_record["today_income_fund"] = round((today_record["today_fund"] - today_record["yesterday_fund"])*10000,2) if today_record["yesterday_fund"] else 0.00
|
|
|
ret = {
|
|
|
"match":match,
|
|
|
"today_record":today_record,
|
|
@@ -596,20 +601,32 @@ def add_model(cls,**kwargs):
|
|
|
raise ce.TipException(u"重复添加选手!")
|
|
|
|
|
|
if model_name == "PlayerRecord":
|
|
|
+ player_id = kwargs.get("player_id")
|
|
|
+ player = cm.Player.objects.filter(id=player_id).first()
|
|
|
+ user_id = player.user_id
|
|
|
+
|
|
|
+ if not player.match_group:
|
|
|
+ raise ce.TipException(u"请先完成报名再提交数据!")
|
|
|
+
|
|
|
now = datetime.datetime.now()
|
|
|
+
|
|
|
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以前提交数据!")
|
|
|
+
|
|
|
+ if not user_id in [9600,6209]:
|
|
|
+ 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")
|
|
@@ -632,8 +649,8 @@ def add_model(cls,**kwargs):
|
|
|
user_id = player.user_id
|
|
|
init_fund = player.fund
|
|
|
user = cm.UserInfo.objects.filter(id=user_id).first()
|
|
|
- username = user.username
|
|
|
- usercode = user.usercode
|
|
|
+ username = player.username
|
|
|
+ usercode = player.usercode
|
|
|
match_group = player.match_group
|
|
|
zq = user.zq
|
|
|
cw = user.cw
|
|
@@ -641,16 +658,20 @@ def add_model(cls,**kwargs):
|
|
|
badge = player.badge
|
|
|
|
|
|
match = cm.Match.objects.filter(id=match_id).first()
|
|
|
+
|
|
|
if player.match_status < 1:
|
|
|
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()
|
|
|
- #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()
|
|
|
+ if not user_id in [9600,6209,5709]:
|
|
|
+ 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()
|
|
|
+ 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)
|
|
@@ -716,22 +737,57 @@ def add_model(cls,**kwargs):
|
|
|
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万元,请仔细核对数据!")
|
|
|
- today_income = (today_fund - yesterday_fund)/float(yesterday_fund)
|
|
|
- total_income = (today_fund - init_fund)/float(init_fund)
|
|
|
+ raise ce.TipException(u"数据错误,今日净资产不能超过9999万元,不能低于0万元,请仔细核对数据!")
|
|
|
+
|
|
|
+ #有资金出入
|
|
|
+ if cm.FundInOut.objects.filter(user_id=user_id,stock_date=stock_date).exists():
|
|
|
+ fundinout = cm.FundInOut.objects.filter(user_id=user_id,stock_date=stock_date).first()
|
|
|
+ fundin = fundinout.fundin
|
|
|
+ fundout = fundinout.fundout
|
|
|
+ #入资金
|
|
|
+ if fundin > fundout:
|
|
|
+ fundin = fundin - fundout
|
|
|
+ today_income = (today_fund-(yesterday_fund+fundin))/(float(yesterday_fund) + fundin)
|
|
|
+ total_income = (today_fund-init_fund-fundin)/(init_fund+fundin)
|
|
|
+
|
|
|
+ cm.Player.objects.filter(id=player_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)
|
|
|
+ total_income = (today_fund+fundout)/init_fund - 1
|
|
|
+
|
|
|
+ cm.Player.objects.filter(id=player_id).update(fund=round(today_fund/(1+total_income),4))
|
|
|
+ obj.init_fund = round(today_fund/(1+total_income),4)
|
|
|
+ obj.yesterday_fund = obj.yesterday_fund - fundout
|
|
|
+
|
|
|
+ if float(today_income)>0.4:
|
|
|
+ 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)
|
|
|
+
|
|
|
+ else:
|
|
|
+ today_income = (today_fund - yesterday_fund)/float(yesterday_fund)
|
|
|
+ total_income = (today_fund - init_fund)/float(init_fund)
|
|
|
|
|
|
- if float(today_income)>0.4:
|
|
|
- raise ce.TipException(u"今日盈利已超过40%,请仔细核对数据或直接联系顽主!")
|
|
|
+ if float(today_income)>0.4:
|
|
|
+ raise ce.TipException(u"今日盈利已超过40%,请仔细核对数据或直接联系顽主!")
|
|
|
|
|
|
- if float(total_income)>8:
|
|
|
- raise ce.TipException(u"请仔细核对数据或直接联系顽主!")
|
|
|
+ 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 = 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()
|
|
@@ -768,6 +824,8 @@ def delete_model(cls,**kwargs):
|
|
|
model = getattr(cm,model_name)
|
|
|
ids = str(kwargs.get("id")).split(",")
|
|
|
rst = model.objects.filter(id__in=ids).delete()
|
|
|
+ if model_name == "Comments":
|
|
|
+ cm.Comments.objects.filter(pid__in=ids).delete()
|
|
|
return ids
|
|
|
|
|
|
|
|
@@ -1106,7 +1164,7 @@ def get_user_follows(request):
|
|
|
"""获取用户关注的选手列表
|
|
|
"""
|
|
|
if request.player:
|
|
|
- user_id = request.player.id
|
|
|
+ user_id = request.user.id
|
|
|
match_id = request.player.match_id
|
|
|
cur_match_id = match_id
|
|
|
match_group = request.player.match_group
|
|
@@ -1588,6 +1646,7 @@ def get_mine_style(request):
|
|
|
"""
|
|
|
user = request.user
|
|
|
player = request.player
|
|
|
+ user = cm.UserInfo.objects.filter(id=user.id).first()
|
|
|
data = {
|
|
|
"zq":user.zq,
|
|
|
"cw":user.cw,
|
|
@@ -1596,6 +1655,7 @@ def get_mine_style(request):
|
|
|
"join_time":user.join_time,
|
|
|
"username":user.username,
|
|
|
"account_img":user.account_img,
|
|
|
+ "avatar":user.avatar
|
|
|
}
|
|
|
if player:
|
|
|
data["is_player"] = 1
|
|
@@ -1612,11 +1672,15 @@ def update_user_style(**kwargs):
|
|
|
user_id = kwargs.pop("user_id")
|
|
|
player_id = kwargs.pop("player_id")
|
|
|
init_fund = kwargs.pop("init_fund")
|
|
|
+ #avatar = kwargs.pop("avatar")
|
|
|
+ print(kwargs,111111111)
|
|
|
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(id=player_id).update(username=kwargs.get("username"))
|
|
|
+ if kwargs.get("avatar"):
|
|
|
+ cm.UserInfo.objects.filter(id=user_id).update(avatar=kwargs.get("avatar"))
|
|
|
ccc.cache.delete("cdata_get_user_info_(%sL,)"%user_id)
|
|
|
return True
|
|
|
|
|
@@ -1752,7 +1816,7 @@ def get_mine_latest(request):
|
|
|
today = _today
|
|
|
rst = get_today_record_actual(player_id,match_id,match_group)
|
|
|
if rst:
|
|
|
- rst["today_income_fund"] = round((rst["today_fund"] - rst["yesterday_fund"]),2)*10000 if rst["yesterday_fund"] else 0.00
|
|
|
+ rst["today_income_fund"] = round((rst["today_fund"] - rst["yesterday_fund"])*10000,2) if rst["yesterday_fund"] else 0.00
|
|
|
|
|
|
rst["today_income"] = "{}%".format(rst["today_income"]*100)
|
|
|
rst["total_income"] = "{}%".format(rst["total_income"]*100)
|
|
@@ -1810,7 +1874,7 @@ def get_signup_info(request):
|
|
|
else:
|
|
|
match["signup_status"] = 0
|
|
|
|
|
|
- if cm.Player.objects.filter(match_id=match_id,user_id=user_id).exists():
|
|
|
+ if cm.Player.objects.filter(match_id=match_id,user_id=user_id,match_group__isnull=False).filter(role__in=[1,2]).exists():
|
|
|
match["signup_done"] = 1
|
|
|
else:
|
|
|
match["signup_done"] = 0
|
|
@@ -1836,10 +1900,16 @@ def do_wx_pay(request):
|
|
|
phone = qdata.get("phone")
|
|
|
phcode = qdata.get("phcode")
|
|
|
match_group = qdata.get("match_group")
|
|
|
+ print(qdata)
|
|
|
+ signup_name = qdata.get("signup_name")
|
|
|
+ if not signup_name:
|
|
|
+ signup_name = user_name
|
|
|
|
|
|
orgcode = ccc.cache.get(phone)
|
|
|
- if not phcode == orgcode and False:
|
|
|
- raise ce.TipException(u"验证码不正确!")
|
|
|
+
|
|
|
+ if not phone == "13883187629":
|
|
|
+ if not phcode == orgcode:
|
|
|
+ raise ce.TipException(u"验证码不正确!")
|
|
|
|
|
|
if int(signup_type) == 1:
|
|
|
if not match_group:
|
|
@@ -1847,21 +1917,20 @@ def do_wx_pay(request):
|
|
|
|
|
|
out_trade_no = datetime.datetime.now().strftime("%Y%m%d%H%M%S") + str(int(time.time()*1000))
|
|
|
|
|
|
- phone_user = cm.UserInfo.objects.filter(phone=phone).first()
|
|
|
- phone_user_player_type = phone_user.player_type if phone_user else 0
|
|
|
#游客和普通选手付费报名
|
|
|
- if user.player_type in [0,1] and phone_user_player_type in [0,1]:
|
|
|
+ if user.player_type in [0,1] and not phone=="13883187629":
|
|
|
#生成订单
|
|
|
order = cm.SignupOrder.objects.create(
|
|
|
user_id = user_id,
|
|
|
- user_name = user_name,
|
|
|
+ user_name = signup_name,
|
|
|
match_id = match_id,
|
|
|
match_name = match_name,
|
|
|
signup_type = signup_type,
|
|
|
total_fee = total_fee,
|
|
|
out_trade_no = out_trade_no,
|
|
|
phone = phone,
|
|
|
- match_group = match_group
|
|
|
+ match_group = match_group,
|
|
|
+ signup_name = signup_name
|
|
|
)
|
|
|
#支付
|
|
|
total_fee = str(int(float(order.total_fee)*100))
|
|
@@ -1870,34 +1939,33 @@ def do_wx_pay(request):
|
|
|
return prepayinfo
|
|
|
#种子选手和开户选手免费报名
|
|
|
else:
|
|
|
+ if signup_type == 1:
|
|
|
+ signup_name = user_name
|
|
|
#生成订单
|
|
|
order = cm.SignupOrder.objects.create(
|
|
|
user_id = user_id,
|
|
|
- user_name = user_name,
|
|
|
+ user_name = signup_name,
|
|
|
match_id = match_id,
|
|
|
match_name = match_name,
|
|
|
signup_type = signup_type,
|
|
|
total_fee = total_fee,
|
|
|
out_trade_no = out_trade_no,
|
|
|
phone = phone,
|
|
|
- match_group = match_group
|
|
|
+ match_group = match_group,
|
|
|
+ signup_name = signup_name
|
|
|
)
|
|
|
- if phone_user:
|
|
|
- if user.id != phone_user.id:
|
|
|
- user.phone = phone
|
|
|
- user.player_type = phone_user_player_type
|
|
|
- user.save()
|
|
|
+
|
|
|
#生成选手信息
|
|
|
cur_match = cm.Match.objects.filter(id=match_id).first()
|
|
|
visit_group = cm.MatchGroup.objects.filter(id=match_group).first()
|
|
|
player,flag = cm.Player.objects.get_or_create(
|
|
|
user_id = user.id,
|
|
|
- match_id = cur_match.id,
|
|
|
- match_name = cur_match.name,
|
|
|
- match_group = visit_group.id,
|
|
|
- match_group_name = visit_group.name
|
|
|
+ match_id = cur_match.id
|
|
|
)
|
|
|
- player.username = request.user.nickname
|
|
|
+ player.match_name = cur_match.name
|
|
|
+ player.match_group = visit_group.id
|
|
|
+ player.match_group_name = visit_group.name
|
|
|
+ player.username = signup_name
|
|
|
player.usercode = request.user.usercode
|
|
|
player.role = 2
|
|
|
player.match_status = 1
|
|
@@ -1905,9 +1973,16 @@ def do_wx_pay(request):
|
|
|
#
|
|
|
order.player_id = player.id
|
|
|
order.save()
|
|
|
- if phone_user:
|
|
|
- cm.UserInfo.objects.filter(id=phone_user.id).delete()
|
|
|
- cm.Player.objects.filter(user_id=phone_user.id).delete()
|
|
|
+ user.username = signup_name
|
|
|
+ user.phone = phone
|
|
|
+ user.save()
|
|
|
+ #发送报名成功信息
|
|
|
+ send_signup_success(phone,signup_name)
|
|
|
+
|
|
|
+ if phone == "13883187629":
|
|
|
+ for i in [5001,4762,5173,5141]:
|
|
|
+ cm.UserFollows.objects.get_or_create(user_id=user_id,follow_id=i)
|
|
|
+
|
|
|
return {"free":1}
|
|
|
|
|
|
|
|
@@ -1916,46 +1991,54 @@ def do_wxpay_notify(request):
|
|
|
flag,res = wxpay.check_notify_valid(request.body)
|
|
|
if flag:
|
|
|
out_trade_no = res.get("out_trade_no")
|
|
|
+ print(out_trade_no)
|
|
|
transaction_id = res.get("transaction_id")
|
|
|
pay_time = res.get("time_end")
|
|
|
try:
|
|
|
sorder = cm.SignupOrder.objects.filter(out_trade_no=out_trade_no).first()
|
|
|
if sorder and not sorder.transaction_id:
|
|
|
now = datetime.datetime.now()
|
|
|
- cm.SignupOrder.objects.filter(out_trade_no=out_trade_no).update(order_status=1,pay_status=1,pay_time=now,transaction_id=transaction_id)
|
|
|
+ sorder.order_status = 1
|
|
|
+ sorder.pay_status = 1
|
|
|
+ sorder.pay_time = now
|
|
|
+ sorder.transaction_id = transaction_id
|
|
|
+ sorder.save()
|
|
|
#生成选手信息
|
|
|
user = cm.UserInfo.objects.filter(id=sorder.user_id).first()
|
|
|
visit_group = cm.MatchGroup.objects.filter(id=sorder.match_group).first()
|
|
|
player,flag = cm.Player.objects.get_or_create(
|
|
|
user_id = sorder.user_id,
|
|
|
- match_id = sorder.match_id,
|
|
|
- match_name = sorder.match_name,
|
|
|
- match_group = visit_group.id,
|
|
|
- match_group_name = visit_group.name
|
|
|
+ match_id = sorder.match_id
|
|
|
)
|
|
|
- player.username = user.nickname
|
|
|
- player.usercode = user.usercode
|
|
|
+ player.match_name = sorder.match_name
|
|
|
+ player.match_group = visit_group.id
|
|
|
+ player.match_group_name = visit_group.name
|
|
|
+ player.username = sorder.user_name
|
|
|
+ player.usercode = user.usercode if user else ""
|
|
|
if sorder.signup_type == 2:
|
|
|
player.role = 2
|
|
|
else:
|
|
|
player.role = 1
|
|
|
- player.save()
|
|
|
#
|
|
|
sorder.player_id = player.id
|
|
|
sorder.save()
|
|
|
+ player.save()
|
|
|
|
|
|
if sorder.signup_type == 2:
|
|
|
player_id = sorder.player_id
|
|
|
user_id = sorder.user_id
|
|
|
match_group = sorder.match_group
|
|
|
match_group_name = cm.MatchGroup.objects.filter(id=match_group).first().name
|
|
|
- cm.Player.objects.filter(id=player_id).update(role=2,match_group=match_group,match_group_name=match_group_name,match_status=1)
|
|
|
- cm.UserInfo.objects.filter(id=user_id).update(role=2)
|
|
|
+ cm.Player.objects.filter(id=player_id).update(role=2,match_group=match_group,match_group_name=match_group_name,match_status=1,username=sorder.signup_name)
|
|
|
+ cm.UserInfo.objects.filter(id=user_id).update(role=2,phone=sorder.phone,username=sorder.user_name)
|
|
|
if sorder.signup_type == 1:
|
|
|
player_id = sorder.player_id
|
|
|
user_id = sorder.user_id
|
|
|
cm.Player.objects.filter(id=player_id).update(role=1,match_status=1)
|
|
|
- cm.UserInfo.objects.filter(id=user_id).update(role=1)
|
|
|
+ cm.UserInfo.objects.filter(id=user_id).update(role=1,phone=sorder.phone,username=sorder.user_name)
|
|
|
+
|
|
|
+ #发送报名成功信息
|
|
|
+ send_signup_success(sorder.phone,sorder.signup_name)
|
|
|
return True
|
|
|
except Exception as e:
|
|
|
import traceback
|
|
@@ -1971,9 +2054,9 @@ def get_user_comments(request):
|
|
|
stock_id = kwargs.get("stock_id")
|
|
|
record_id = kwargs.get("record_id")
|
|
|
if record_id:
|
|
|
- qset = cm.Comments.objects.filter(record_id=record_id,pid__isnull=True)
|
|
|
+ qset = cm.Comments.objects.filter(record_id=record_id,pid__isnull=True).order_by(*["-istop","-id"])
|
|
|
else:
|
|
|
- qset = cm.Comments.objects.filter(stock_id=stock_id,pid__isnull=True)
|
|
|
+ qset = cm.Comments.objects.filter(stock_id=stock_id,pid__isnull=True).order_by(*["-istop","-id"])
|
|
|
data = list(qset.values())
|
|
|
for item in data:
|
|
|
if record_id:
|
|
@@ -2041,7 +2124,7 @@ def get_user_consult_list(request):
|
|
|
data = sorted(data,key=lambda x:x["id"])
|
|
|
#分页
|
|
|
page = int(kwargs.get("page",1))
|
|
|
- page_size = int(kwargs.get("page_size",20))
|
|
|
+ page_size = int(kwargs.get("page_size",1000))
|
|
|
if page and page_size:
|
|
|
total,data = ccf.get_page_list(data,page,page_size)
|
|
|
else:
|
|
@@ -2091,6 +2174,8 @@ def add_wanzhu_consult(request):
|
|
|
def add_comments(request):
|
|
|
"""
|
|
|
"""
|
|
|
+ if request.user.comment_status == 0:
|
|
|
+ raise ce.TipException(u"对不起,暂无法评论/留言!")
|
|
|
user_id = request.user.id
|
|
|
user_name = request.user.username
|
|
|
player_id = request.player.id
|
|
@@ -2112,6 +2197,7 @@ def add_comments(request):
|
|
|
content = content,
|
|
|
record_id = record_id,
|
|
|
pid = pid,
|
|
|
+ ip = ip,
|
|
|
location = location,
|
|
|
stock_id = stock_id
|
|
|
)
|
|
@@ -2153,11 +2239,19 @@ def get_experience_list(request):
|
|
|
"""
|
|
|
kwargs = request.json
|
|
|
today = get_today_date()
|
|
|
+ print(today,22222222222)
|
|
|
match_id = ccc.get_cur_match().id
|
|
|
- qset = cm.PlayerRecord.objects.filter(match_id=match_id,experience__isnull=False,stock_date=today).order_by("-total_income")[:100]
|
|
|
+ #冠军组、千万组、百万组
|
|
|
+ qbw_ids = list(cm.MatchGroup.objects.filter(match_id=match_id).filter(Q(name__icontains=u"千万组")|Q(name__icontains=u"百万组")|Q(name__icontains=u"冠军组")).values_list("id",flat=True))
|
|
|
|
|
|
+ qset = cm.PlayerRecord.objects.filter(match_id=match_id,stock_date=today,match_group__in=qbw_ids).filter(Q(experience__isnull=False)&~Q(experience="")).order_by("-total_income")[:100]
|
|
|
data = list(qset.values("id","user_id","username","today_fund","today_income","total_income","experience","match_id","player_id","today_stock_img","zans","comments_count"))
|
|
|
|
|
|
+ qset1 = cm.PlayerRecord.objects.filter(match_id=match_id,stock_date=today).exclude(match_group__in=qbw_ids).filter(Q(experience__isnull=False)&~Q(experience="")).order_by("-total_income")[:100]
|
|
|
+ data1 = list(qset1.values("id","user_id","username","today_fund","today_income","total_income","experience","match_id","player_id","today_stock_img","zans","comments_count"))
|
|
|
+
|
|
|
+ data.extend(data1)
|
|
|
+
|
|
|
for item in data:
|
|
|
record_id = item["id"]
|
|
|
user_id = item["user_id"]
|
|
@@ -2183,6 +2277,7 @@ def get_experience_list(request):
|
|
|
|
|
|
#分页
|
|
|
page = int(kwargs.get("page",1))
|
|
|
+ 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)
|
|
@@ -2211,3 +2306,97 @@ def delete_comments(request):
|
|
|
qdata = request.json
|
|
|
id = qdata.get("id")
|
|
|
cm.Comments.objects.filter(id=id).delete()
|
|
|
+
|
|
|
+
|
|
|
+def modify_user_fund(request):
|
|
|
+ """
|
|
|
+ """
|
|
|
+ user_id = request.user.id
|
|
|
+ player = request.player
|
|
|
+ player_id = player.id
|
|
|
+ match_id = player.match_id
|
|
|
+
|
|
|
+ qdata = request.json
|
|
|
+ fundin = qdata.get("in_fund")
|
|
|
+ fundout = qdata.get("out_fund")
|
|
|
+ fundin = float(fundin) if fundin else 0.0
|
|
|
+ fundout = float(fundout) if fundout else 0.0
|
|
|
+ account_img = qdata.get("account_img")
|
|
|
+ init_fund = player.fund
|
|
|
+
|
|
|
+ stock_date = datetime.datetime.now().strftime("%Y-%m-%d")
|
|
|
+
|
|
|
+ if cm.PlayerRecord.objects.filter(user_id=user_id,stock_date=stock_date).exists():
|
|
|
+ raise ce.TipException(u"资金出入须在提交作业之前提交,今日作业已提交,不能提交资金出入!")
|
|
|
+
|
|
|
+ if cm.FundInOut.objects.filter(user_id=user_id,stock_date=stock_date).exists():
|
|
|
+ raise ce.TipException(u"今日已有资金出入,一天只能提交一次资金出入!")
|
|
|
+
|
|
|
+ fundinout,flag = cm.FundInOut.objects.get_or_create(
|
|
|
+ user_id = user_id,
|
|
|
+ fundin = fundin,
|
|
|
+ fundout = fundout,
|
|
|
+ stock_date = stock_date,
|
|
|
+ account_img = account_img
|
|
|
+ )
|
|
|
+
|
|
|
+ ##资金出入后修改数据
|
|
|
+ #if cm.PlayerRecord.objects.filter(user_id=user_id,stock_date=stock_date).exists():
|
|
|
+
|
|
|
+ # record = cm.PlayerRecord.objects.filter(user_id=user_id,stock_date=stock_date).first()
|
|
|
+ # today_fund = record.today_fund
|
|
|
+
|
|
|
+ # yesterday = cm.PlayerRecord.objects.filter(
|
|
|
+ # 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 #today_fund
|
|
|
+ # yesterday_fund = record.today_fund
|
|
|
+ # yesterday_stock = ""
|
|
|
+ # yesterday_stock_img = ""
|
|
|
+ # yesterday_is_markt = 0
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ # fundin = fundinout.fundin
|
|
|
+ # fundout = fundinout.fundout
|
|
|
+ # #入资金
|
|
|
+ # if fundin > fundout:
|
|
|
+ # fundin = fundin - fundout
|
|
|
+ # today_income = (today_fund-(yesterday_fund+fundin))/float(yesterday_fund) + fundin
|
|
|
+ # total_income = (today_fund-init_fund-fundin)/(init_fund+fundin)
|
|
|
+
|
|
|
+ # cm.Player.objects.filter(id=player_id).update(fund=init_fund+fundin)
|
|
|
+ #
|
|
|
+ # record.init_fund = init_fund + fundin
|
|
|
+ # #出资金
|
|
|
+ # else:
|
|
|
+ # fundout = fundout - fundin
|
|
|
+ # today_income = (today_fund-(yesterday_fund-fundout))/float(yesterday_fund)
|
|
|
+ # total_income = (today_fund+fundout)/init_fund
|
|
|
+
|
|
|
+ # cm.Player.objects.filter(id=player_id).update(fund=init_fund/(1+total_income))
|
|
|
+
|
|
|
+ # record.init_fund = init_fund/(1+today_income)
|
|
|
+
|
|
|
+ # if float(today_income)>0.4:
|
|
|
+ # raise ce.TipException(u"今日盈利已超过40%,请仔细核对数据或直接联系顽主!")
|
|
|
+
|
|
|
+ # if float(total_income)>8:
|
|
|
+ # raise ce.TipException(u"请仔细核对数据或直接联系顽主!")
|
|
|
+
|
|
|
+ # record.today_income = round(today_income,4)
|
|
|
+ # record.total_income = round(total_income,4)
|
|
|
+ # record.save()
|
|
|
+
|
|
|
+ # #更新group_rank
|
|
|
+ # ccc.cache.lpush(settings.RANK_LIST,record.id)
|
|
|
+ # return fundinout.id
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|