Browse Source

后台数据编辑出入金计算,数据提交出入金bug

xjc 2 years ago
parent
commit
500af2835b

+ 40 - 0
src/manage/controls.py

@@ -1120,4 +1120,44 @@ def refund_out_trade_order(**kwargs):
     else:
         raise ce.TipException(u"该订单不存在退款失败!")
 
+# 计算出入资金
+def caculate_inout(**kwargs):
+    """
+    """
+
+    fundin = kwargs.get("in_fund")
+    fundout = kwargs.get("out_fund")
+    init_fund = kwargs.get("init_fund")
+    today_fund = kwargs.get("today_fund")
+    yesterday_fund = kwargs.get("yesterday_fund")
+    fundin = float(fundin) if fundin else 0.0
+    fundout = float(fundout) if fundout else 0.0
+    init_fund = float(init_fund) if init_fund else 0.0
+    today_fund = float(today_fund) if today_fund else 0.0
+    yesterday_fund = float(yesterday_fund) if yesterday_fund else 0.0
+    #入资金
+    if fundin > fundout:
+        fundin = fundin - fundout
+        today_income = round((today_fund-(yesterday_fund+fundin))/(float(yesterday_fund) + fundin),4)
+        yesterday_fund = yesterday_fund + fundin
+        total_income = round((today_fund-init_fund-fundin)/(init_fund+fundin),4)
+        init_fund = init_fund + fundin
+    #出资金
+    else:
+        fundout = fundout - fundin
+        today_income = round((today_fund-(yesterday_fund-fundout))/float(yesterday_fund),4)
+        yesterday_fund = round(today_fund/(1+today_income),4)
+        total_income = round((today_fund+fundout-init_fund)/init_fund,4)
+        init_fund = round(today_fund/(1+total_income),4)
+
+    today_income = "{}%".format(today_income*100)
+    total_income = "{}%".format(total_income*100)
+    yesterday_fund = round(yesterday_fund,4)
+    init_fund      = round(init_fund,4)
+
+    return {"yesterday_fund":yesterday_fund,
+            "today_income":today_income,
+            "total_income":total_income,
+            "init_fund":init_fund}
+        
 

+ 1 - 0
src/manage/urls_backstage.py

@@ -51,6 +51,7 @@ urlpatterns = [
     url(r'^signup/olduser$', views.SignupOldUserView.as_view()),
     url(r'^user/fundinout$', views.FundInOutView.as_view()),
     url(r'^user/fundinout/list$', views.FundInOutListView.as_view()),
+    url(r'^user/fundinout/caculate$', views.FundInOutCaculateView.as_view()),
     url(r'^user/consult/detail$', views.UserConsultDetailView.as_view()),
     url(r'^baike/category$', views.BaikeCategoryView.as_view()),
     url(r'^baike/category/list$', views.BaikeCategoryListView.as_view()),

+ 12 - 1
src/manage/views.py

@@ -1330,7 +1330,18 @@ class FundInOutListView(cv.AdminView):
             cv.tracefail()
             return cv.to_fail(e)
 
-
+class FundInOutCaculateView(cv.AdminView):
+    def get(self, request):
+        """#资金出入计算(平台管理后台)
+        """
+        qdata = request.json
+        try:
+            rst = ctl.caculate_inout(**qdata)
+            return cv.to_suc(rst)
+        except Exception as e:
+            cv.tracefail()
+            return cv.to_fail(e)
+        
 class UserConsultDetailView(cv.AdminView):
     def get(self, request):
         """#咨询详情(平台管理后台)

+ 17 - 11
src/weixin/controls.py

@@ -434,9 +434,9 @@ def get_cache_rank_list(match_id,today):
                 player["total_income"] = "{}%".format(today_record["total_income"]*100)
                 player["today_income"] = "{}%".format(today_record["today_income"]*100)
 
-                if player["org_today_income"] >= 0.09:
+                if player["org_today_income"] >= 0.05:
                     win_count += 1
-                if player["org_today_income"] <= -0.09:
+                if player["org_today_income"] <= -0.05:
                     loss_count += 1
 
                 try:
@@ -787,14 +787,18 @@ def add_model(cls,**kwargs):
                     else:
                         today_income = 0.0
                     
-                    
-                    total_income = (today_fund-init_fund-fundin)/(init_fund+fundin)
                     obj.today_income = round(today_income,4)
-                    obj.total_income = round(total_income,4)
+                    
                     
                     if flag:
-	                    cm.Player.objects.filter(user_id=user_id,match_id=match_id).update(fund=init_fund+fundin)
-	                    obj.init_fund = init_fund + fundin
+                        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
+                    else:
+                        total_income = (today_fund - init_fund)/float(init_fund) if init_fund else 0.0
+                    
+                    obj.total_income = round(total_income,4)
+                    
                 #出资金
                 else:
                     fundout = fundout - fundin
@@ -804,15 +808,17 @@ def add_model(cls,**kwargs):
                     else:
                         today_income = 0.0
                         
-                    
-                    total_income = (today_fund+fundout-init_fund)/init_fund if init_fund else 0.0
-                    
                     obj.today_income = round(today_income,4)
-                    obj.total_income = round(total_income,4)
                     
+
                     if flag:
+                        total_income = (today_fund+fundout-init_fund)/init_fund if init_fund else 0.0
                         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)
+                    else:
+                        total_income = (today_fund - init_fund)/float(init_fund) if init_fund else 0.0
+
+                    obj.total_income = round(total_income,4)
                         
                 if float(today_income)>0.4:                                                   
                     raise ce.TipException(u"今日盈利已超过40%,请仔细核对数据或直接联系顽主!")

templates/css/chunk-1dff01ba.3cf20b6d.css → templates/css/chunk-4f7140b7.3cf20b6d.css


File diff suppressed because it is too large
+ 1 - 1
templates/index.html


File diff suppressed because it is too large
+ 2 - 2
templates/js/app.d2ae8cdb.js


File diff suppressed because it is too large
+ 1 - 0
templates/js/app.9bdaf7a6.js.map


File diff suppressed because it is too large
+ 0 - 1
templates/js/app.d2ae8cdb.js.map


File diff suppressed because it is too large
+ 0 - 2
templates/js/chunk-1dff01ba.8566e3fb.js


File diff suppressed because it is too large
+ 0 - 1
templates/js/chunk-1dff01ba.8566e3fb.js.map


File diff suppressed because it is too large
+ 2 - 0
templates/js/chunk-4f7140b7.7029a1e3.js


File diff suppressed because it is too large
+ 1 - 0
templates/js/chunk-4f7140b7.7029a1e3.js.map


File diff suppressed because it is too large
+ 2 - 0
templates/js/chunk-5088936d.66ed8abd.js


File diff suppressed because it is too large
+ 1 - 0
templates/js/chunk-5088936d.66ed8abd.js.map


File diff suppressed because it is too large
+ 0 - 2
templates/js/chunk-5088936d.b812e280.js


File diff suppressed because it is too large
+ 0 - 1
templates/js/chunk-5088936d.b812e280.js.map