|
|
@@ -793,6 +793,7 @@ def add_model(cls,**kwargs):
|
|
|
|
|
|
with transaction.atomic():
|
|
|
#记录持股情况
|
|
|
+ today_stock_fund = 0
|
|
|
new_stock_list = []
|
|
|
today_stock_list = json.loads(today_stock)
|
|
|
month = "%s%s" % (stock_date.split("-")[0],stock_date.split("-")[1])
|
|
|
@@ -811,6 +812,10 @@ def add_model(cls,**kwargs):
|
|
|
)
|
|
|
if ts.get("fund"):
|
|
|
usobj.fund = ts["fund"]
|
|
|
+ try:
|
|
|
+ today_stock_fund += float(ts["fund"])
|
|
|
+ except:
|
|
|
+ pass
|
|
|
if ts.get("name"):
|
|
|
usobj.stock_name = ts.get("name")
|
|
|
if match_group:
|
|
|
@@ -850,6 +855,10 @@ def add_model(cls,**kwargs):
|
|
|
#计算今日收益和总收益
|
|
|
if float(today_fund)>9999 or float(today_fund)<=0:
|
|
|
raise ce.TipException(u"数据错误,今日净资产不能超过9999万元,不能低于0万元,请仔细核对数据!")
|
|
|
+
|
|
|
+ #如果今日持仓金额大于总资产的10倍,则提示数据有问题
|
|
|
+ if today_stock_total > float(today_fund)*10:
|
|
|
+ raise ce.TipException(u"今日持仓金额有误,请修改持仓金额!")
|
|
|
|
|
|
#有资金出入
|
|
|
if cm.FundInOut.objects.filter(user_id=user_id,stock_date=stock_date).exists() and player.fund>0:
|
|
|
@@ -2482,6 +2491,8 @@ def add_wanzhu_consult(request):
|
|
|
user_id = request.user.get("id",0)
|
|
|
user_name = request.user.get("username")
|
|
|
user_avatar = request.user.get("avatar")
|
|
|
+ user_code = request.user.get("usercode")
|
|
|
+ phone = request.user.get("phone")
|
|
|
openid = request.user.get("openid")
|
|
|
qdata = request.json
|
|
|
content = qdata.get("cotent")
|
|
|
@@ -2496,6 +2507,8 @@ def add_wanzhu_consult(request):
|
|
|
content = content,
|
|
|
pid = pid
|
|
|
)
|
|
|
+ wanzhu_obj.user_code = user_code
|
|
|
+ wanzhu_obj.phone = phone
|
|
|
wanzhu_obj.width = width
|
|
|
wanzhu_obj.height = height
|
|
|
wanzhu_obj.save()
|
|
|
@@ -2505,6 +2518,8 @@ def add_wanzhu_consult(request):
|
|
|
)
|
|
|
obj.user_name = user_name
|
|
|
obj.user_avatar = user_avatar
|
|
|
+ obj.user_code = user_code
|
|
|
+ obj.phone = phone
|
|
|
obj.content = content
|
|
|
obj.view_status = 0
|
|
|
obj.reply_status = 0
|
|
|
@@ -3169,12 +3184,16 @@ def reply_wanzhu_consult(**kwargs):
|
|
|
user = cm.UserInfo.objects.filter(id=user_id).first()
|
|
|
user_name = user.username
|
|
|
user_avatar = user.avatar
|
|
|
+ user_code = user.usercode
|
|
|
+ phone = user.phone
|
|
|
|
|
|
obj,flag = cm.Consult.objects.get_or_create(
|
|
|
user_id = user_id,
|
|
|
)
|
|
|
obj.user_name = user_name
|
|
|
obj.user_avatar = user_avatar
|
|
|
+ obj.user_code = user_code
|
|
|
+ obj.phone = phone
|
|
|
#obj.reply_content = content
|
|
|
obj.view_status = 1
|
|
|
obj.reply_status = 0
|
|
|
@@ -3186,6 +3205,8 @@ def reply_wanzhu_consult(**kwargs):
|
|
|
user_name = user_name,
|
|
|
user_avatar = user_avatar
|
|
|
)
|
|
|
+ wanzhu_obj.user_code = user_code
|
|
|
+ wanzhu_obj.phone = phone
|
|
|
wanzhu_obj.width = width
|
|
|
wanzhu_obj.height = height
|
|
|
wanzhu_obj.save()
|
|
|
@@ -3916,3 +3937,83 @@ def check_msg_content(request):
|
|
|
rst = json.loads(os.popen(cmdStr).read())
|
|
|
return rst
|
|
|
return {}
|
|
|
+
|
|
|
+
|
|
|
+def delete_user_stock(request):
|
|
|
+ """
|
|
|
+ """
|
|
|
+
|
|
|
+ qdata = request.json
|
|
|
+ stock_date = qdata.get("stock_date")
|
|
|
+ user_id = qdata.get("user_id")
|
|
|
+ match_id = qdata.get("match_id")
|
|
|
+
|
|
|
+ player = cm.Player.objects.filter(user_id=user_id,match_id=match_id).first()
|
|
|
+ if player:
|
|
|
+ player_id = player.id
|
|
|
+ #删除今日作业数据
|
|
|
+ cm.PlayerRecord.get_db_model(match_id).objects.filter(user_id=user_id,stock_date=stock_date).delete()
|
|
|
+
|
|
|
+ #删除今日持仓数据
|
|
|
+ month = "%s%s" % (stock_date.split("-")[0],stock_date.split("-")[1])
|
|
|
+ cm.UserStock.get_db_model(month).objects.filter(
|
|
|
+ player_id = player.id,
|
|
|
+ stock_date = stock_date
|
|
|
+ ).delete()
|
|
|
+
|
|
|
+ #删除今日出入资金数据
|
|
|
+ if cm.FundInOut.objects.filter(user_id = user_id,stock_date=stock_date).exists():
|
|
|
+ cm.FundInOut.objects.filter(user_id = user_id,stock_date=stock_date).delete()
|
|
|
+
|
|
|
+ #用前一天数据重置选手初始资金
|
|
|
+ yesterday = cm.PlayerRecord.get_db_model(match_id).objects.filter(
|
|
|
+ match_id=match_id,player_id=player_id).order_by("-stock_date").first()
|
|
|
+
|
|
|
+ if yesterday:
|
|
|
+ player.fund = yesterday.init_fund
|
|
|
+ player.save()
|
|
|
+
|
|
|
+
|
|
|
+def get_user_fundinout(request):
|
|
|
+ """
|
|
|
+ """
|
|
|
+ try:
|
|
|
+ user_id = request.user.get("id",0)
|
|
|
+ except:
|
|
|
+ user_id = 0
|
|
|
+ if not user_id:
|
|
|
+ user_id = qdata.get("user_id")
|
|
|
+ qdata = request.json()
|
|
|
+ stock_date = qdata.get("stock_date")
|
|
|
+
|
|
|
+ rst = cm.FundInOut.objects.filter(user_id = user_id,stock_date=stock_date).values().first()
|
|
|
+ return rst
|
|
|
+
|
|
|
+
|
|
|
+def delete_user_fundinout(request):
|
|
|
+ try:
|
|
|
+ user_id = request.user.get("id",0)
|
|
|
+ except:
|
|
|
+ user_id = 0
|
|
|
+ if not user_id:
|
|
|
+ user_id = qdata.get("user_id")
|
|
|
+ match_id = ccc.get_cur_match().id
|
|
|
+ qdata = request.json()
|
|
|
+ stock_date = qdata.get("stock_date")
|
|
|
+
|
|
|
+ #删除出入资金
|
|
|
+ if cm.FundInOut.objects.filter(user_id = user_id,stock_date=stock_date).exists():
|
|
|
+ cm.FundInOut.objects.filter(user_id = user_id,stock_date=stock_date).delete()
|
|
|
+
|
|
|
+ #player = cm.Player.objects.filter(user_id=user.id,match_id=match_id).first()
|
|
|
+ #if player:
|
|
|
+ # player_id = player.id
|
|
|
+
|
|
|
+ # #用前一天数据重置选手初始资金
|
|
|
+ # yesterday = cm.PlayerRecord.get_db_model(match_id).objects.filter(
|
|
|
+ # match_id=match_id,stock_date=stock_date).order_by("-stock_date").first()
|
|
|
+
|
|
|
+ # #if yesterday:
|
|
|
+ # # player.fund = yesterday.init_fund
|
|
|
+ # # player.save()
|
|
|
+
|