Prechádzať zdrojové kódy

1. 查现货报表修改(任务#95854)
2. 查出入金记录增加userid过滤

zou.yingbin 4 rokov pred
rodič
commit
88fdf070d4
6 zmenil súbory, kde vykonal 47 pridanie a 70 odobranie
  1. 3 1
      controllers/qhj/qryQhj.go
  2. 7 6
      docs/docs.go
  3. 7 6
      docs/swagger.json
  4. 5 4
      docs/swagger.yaml
  5. 23 52
      models/ermcp3Report.go
  6. 2 1
      models/qhj.go

+ 3 - 1
controllers/qhj/qryQhj.go

@@ -314,6 +314,7 @@ func QuerySiteColumnDetail(c *gin.Context) {
 // @Summary 查询充值提现
 // @Produce json
 // @Security ApiKeyAuth
+// @Param userid query int true "用户ID"
 // @Param begindate query string false "申请起始日期(格式yyyymmdd)"
 // @Param enddate query string false "申请截止日期(格式yyyymmdd)"
 // @Param likename query string false "模糊搜索名称"
@@ -324,6 +325,7 @@ func QuerySiteColumnDetail(c *gin.Context) {
 func QueryAccountInOutApply(c *gin.Context) {
 	a := app.GinUtils{Gin: app.Gin{C: c}}
 	req := struct {
+		USERID    int64  `form:"userid"`    // 用户id
 		BEGINDATE string `form:"begindate"` // 开始申请日期
 		ENDDATE   string `form:"enddate"`   // 结束申请日期
 		LIKENAME  string `form:"likename"`  // 模糊搜索名称
@@ -348,7 +350,7 @@ func QueryAccountInOutApply(c *gin.Context) {
 		}
 		return true
 	})
-	m := models.QhjAccountOutInApply{BeginDate: req.BEGINDATE, EndDate: req.ENDDATE, FilterName: req.LIKENAME}
+	m := models.QhjAccountOutInApply{USERID: req.USERID, BeginDate: req.BEGINDATE, EndDate: req.ENDDATE, FilterName: req.LIKENAME}
 	a.DoGetDataI(&m)
 }
 

+ 7 - 6
docs/docs.go

@@ -7070,6 +7070,13 @@ var doc = `{
                 "summary": "查询充值提现",
                 "parameters": [
                     {
+                        "type": "integer",
+                        "description": "用户ID",
+                        "name": "userid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
                         "type": "string",
                         "description": "申请起始日期(格式yyyymmdd)",
                         "name": "begindate",
@@ -8038,12 +8045,6 @@ var doc = `{
                         "in": "query"
                     },
                     {
-                        "type": "string",
-                        "description": "手机号码(模糊匹配)",
-                        "name": "mobile",
-                        "in": "query"
-                    },
-                    {
                         "type": "integer",
                         "description": "是否包含子级 1-包含",
                         "name": "includesub",

+ 7 - 6
docs/swagger.json

@@ -7054,6 +7054,13 @@
                 "summary": "查询充值提现",
                 "parameters": [
                     {
+                        "type": "integer",
+                        "description": "用户ID",
+                        "name": "userid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
                         "type": "string",
                         "description": "申请起始日期(格式yyyymmdd)",
                         "name": "begindate",
@@ -8022,12 +8029,6 @@
                         "in": "query"
                     },
                     {
-                        "type": "string",
-                        "description": "手机号码(模糊匹配)",
-                        "name": "mobile",
-                        "in": "query"
-                    },
-                    {
                         "type": "integer",
                         "description": "是否包含子级 1-包含",
                         "name": "includesub",

+ 5 - 4
docs/swagger.yaml

@@ -18342,6 +18342,11 @@ paths:
   /Qhj/QueryAccountInOutApply:
     get:
       parameters:
+      - description: 用户ID
+        in: query
+        name: userid
+        required: true
+        type: integer
       - description: 申请起始日期(格式yyyymmdd)
         in: query
         name: begindate
@@ -18947,10 +18952,6 @@ paths:
         in: query
         name: nickname
         type: string
-      - description: 手机号码(模糊匹配)
-        in: query
-        name: mobile
-        type: string
       - description: 是否包含子级 1-包含
         in: query
         name: includesub

+ 23 - 52
models/ermcp3Report.go

@@ -924,61 +924,23 @@ func (r *Ermcp3AreaSpotPLReport) calc() {
 	r.UNITIDNAME = mtpcache.GetEnumDicitemName(r.UNITID)
 	r.ACCOUNTNAME = mtpcache.GetUserNameByUserId(r.AREAUSERID)
 	r.CURRENCYNAME = mtpcache.GetCurrencyName(r.CURRENCYID)
-
-	if r.ORIQTY >= 0 && r.CURQTY >= 0 {
-		// 1.当期初量大于等于0时:期末量也大于等于0时:
-		// 期末均价 CurAveragePrice=(今采购额+期初额)/(今采购量+期初量)
-		// 期末额 CurAmoun =(今采购额 + 期初额)- 今销售量 * 期末均价
-		// 现货损益 ActualPL = 今销售额 - 今销售量 * 期末均价
-		// 浮动损益 = 期末市值 - 期末额
-		r.CURAVERAGEPRICE = (r.TODAYBUYAMOUNT + r.ORIAMOUNT) / (r.TODAYBUYQTY + r.ORIQTY)
-		r.CURAMOUNT = (r.TODAYBUYAMOUNT + r.ORIAMOUNT) - r.TODAYSELLQTY*r.CURAVERAGEPRICE
-		r.ACTUALPL = r.TODAYSELLAMOUNT - r.TODAYSELLQTY*r.CURAVERAGEPRICE
-		r.FLOATPL = r.CURMARKETVALUE - r.CURAMOUNT
-
-	} else if r.ORIQTY >= 0 && r.CURQTY < 0 {
-		// 2.当期初量大于等于0时:期末量也小于0时:
-		//期末均价=今销售额/今销售量
-		//期末额=(今采购量+期初量)*期末均价-今销售额
-		//现货损益=(今采购量+期初量)*期末均价-(今采购额+期初额)
-		//浮动损益 =期末市值 - 期末额
-		if r.TODAYSELLQTY > 0 {
-			r.CURAVERAGEPRICE = r.TODAYSELLAMOUNT / r.TODAYSELLQTY
-		} else {
-			r.CURAVERAGEPRICE = 0
-		}
-		r.CURAMOUNT = (r.TODAYBUYQTY+r.ORIQTY)*r.CURAVERAGEPRICE - r.TODAYSELLAMOUNT
-		r.ACTUALPL = (r.TODAYBUYQTY+r.ORIQTY)*r.CURAVERAGEPRICE - (r.TODAYBUYAMOUNT + r.ORIAMOUNT)
-		r.FLOATPL = r.CURMARKETVALUE - r.CURAMOUNT
-	} else if r.ORIQTY < 0 && r.CURQTY >= 0 {
-		// 3.当期初量小于0时:期末量也大于等于0时:
-		//期末均价=今采购额/今采购量
-		//期末额=今采购额-(今销售量-期初量)*期末均价
-		//现货损益=(今销售额-期初额)-(今销售量-期初量)*期末均价
-		//浮动损益 =期末市值 - 期末额
-		if r.TODAYBUYQTY > 0 {
-			r.CURAVERAGEPRICE = r.TODAYBUYAMOUNT / r.TODAYBUYQTY
-		} else {
-			r.CURAVERAGEPRICE = 0
-		}
-		r.CURAMOUNT = r.TODAYBUYAMOUNT - (r.TODAYSELLQTY-r.ORIQTY)*r.CURAVERAGEPRICE
-		r.ACTUALPL = (r.TODAYSELLAMOUNT - r.ORIAMOUNT) - (r.TODAYSELLQTY-r.ORIQTY)*r.CURAVERAGEPRICE
-		r.FLOATPL = r.CURMARKETVALUE - r.CURAMOUNT
-	} else if r.ORIQTY < 0 && r.CURQTY < 0 {
-		// 4.当期初量小于0时:期末量也小于0时:
-		//期末均价=(今销售额-期初额)/(今销售量-期初量)
-		//期末额=今采购量*期末均价-(今销售额-期初额)
-		//现货损益=今采购量*期末均价-今采购额
-		//浮动损益 =期末市值 - 期末额
-		if r.TODAYSELLQTY-r.ORIQTY != 0 {
-			r.CURAVERAGEPRICE = (r.TODAYSELLAMOUNT - r.ORIAMOUNT) / (r.TODAYSELLQTY - r.ORIQTY)
+	fCalcAvePrice := func(avePrice *float64, amount, qty float64) {
+		if qty > 1e-10 {
+			*avePrice = amount / qty
+		} else if qty < -1e-10 {
+			*avePrice = amount / qty
 		} else {
-			r.CURAVERAGEPRICE = 0
+			*avePrice = 0
 		}
-		r.CURAMOUNT = r.TODAYBUYQTY*r.CURAVERAGEPRICE - (r.TODAYSELLAMOUNT - r.ORIAMOUNT)
-		r.ACTUALPL = r.TODAYBUYQTY*r.CURAVERAGEPRICE - r.TODAYBUYAMOUNT
-		r.FLOATPL = r.CURMARKETVALUE - r.CURAVERAGEPRICE
 	}
+	// 期初均价
+	fCalcAvePrice(&r.ORIAVERAGEPRICE, r.ORIAMOUNT, r.ORIQTY)
+	// 期末均价
+	fCalcAvePrice(&r.CURAVERAGEPRICE, r.CURAMOUNT, r.CURQTY)
+	// 今采购均价
+	fCalcAvePrice(&r.TODAYBUYAVERAGEPRICE, r.TODAYBUYAMOUNT, r.TODAYBUYQTY)
+	// 今销售均价
+	fCalcAvePrice(&r.TODAYSELLAVERAGEPRICE, r.TODAYSELLAMOUNT, r.TODAYSELLQTY)
 }
 
 func (r *Ermcp3AreaSpotPLReport) buildSql() string {
@@ -1018,8 +980,11 @@ func (r *Ermcp3AreaSpotPLReport) buildSqlDay() string {
 		"               sum(t.CURSELLQTY) CURSELLQTY," +
 		"               sum(t.CURSELLAMOUNT) CURSELLAMOUNT," +
 		"               sum(t.CURQTY) CURQTY," +
+		"               sum(t.CURAMOUNT) CURAMOUNT," +
 		"               max(t.CURSPOTPRICE) CURSPOTPRICE," +
 		"               sum(t.CURMARKETVALUE) CURMARKETVALUE," +
+		"               sum(t.ACTUALPL) ACTUALPL," +
+		"               sum(t.FLOATPL) FLOATPL," +
 		"               sum(t.TODAYINQTY) TODAYINQTY," +
 		"               sum(t.TODAYOUTQTY) TODAYOUTQTY" +
 		"          FROM RECKON_ERMCP_AREASPOTPL t" +
@@ -1071,8 +1036,11 @@ func (r *Ermcp3AreaSpotPLReport) buildSqlDayDetail() string {
 		"               sum(t.CURSELLQTY) CURSELLQTY," +
 		"               sum(t.CURSELLAMOUNT) CURSELLAMOUNT," +
 		"               sum(t.CURQTY) CURQTY," +
+		"               sum(t.CURAMOUNT) CURAMOUNT," +
 		"               max(t.CURSPOTPRICE) CURSPOTPRICE," +
 		"               sum(t.CURMARKETVALUE) CURMARKETVALUE," +
+		"               sum(t.ACTUALPL) ACTUALPL," +
+		"               sum(t.FLOATPL) FLOATPL," +
 		"               sum(t.TODAYINQTY) TODAYINQTY," +
 		"               sum(t.TODAYOUTQTY) TODAYOUTQTY" +
 		"          FROM RECKON_ERMCP_AREASPOTPL t" +
@@ -1127,8 +1095,11 @@ func (r *Ermcp3AreaSpotPLReport) buildSqlCycle() string {
 		"               sum(t.CURSELLQTY) CURSELLQTY," +
 		"               sum(t.CURSELLAMOUNT) CURSELLAMOUNT," +
 		"               sum(t.CURQTY) CURQTY," +
+		"               sum(t.CURAMOUNT) CURAMOUNT," +
 		"               max(t.CURSPOTPRICE) CURSPOTPRICE," +
 		"               sum(t.CURMARKETVALUE) CURMARKETVALUE," +
+		"               sum(t.ACTUALPL) ACTUALPL," +
+		"               sum(t.FLOATPL) FLOATPL," +
 		"               sum(t.TODAYINQTY) TODAYINQTY," +
 		"               sum(t.TODAYOUTQTY) TODAYOUTQTY" +
 		"          FROM REPORT_ERMCP_AREASPOTPL t" +

+ 2 - 1
models/qhj.go

@@ -1509,7 +1509,7 @@ func (r *QhjAccountOutInApply) buildSql() string {
 		"       t.EXTOPERATEID," +
 		"       t.BANKTICKET," +
 		"       t.APPLYSTATUS," +
-		"       ta.userid," +
+		"       u.userid," +
 		"       u.accountname," +
 		"       ui.userinfotype," +
 		"       tmp.logincode" +
@@ -1519,6 +1519,7 @@ func (r *QhjAccountOutInApply) buildSql() string {
 		"  INNER JOIN USERINFO ui on u.userid=ui.userid" +
 		"  LEFT JOIN tmp on u.userid=tmp.userid" +
 		" WHERE 1 = 1"
+	sqlId.And("u.userid", r.USERID)
 	if len(r.BeginDate) > 0 {
 		sqlId.Join(fmt.Sprintf(" and t.UPDATETIME >= to_date(%v,'yyyymmdd')", r.BeginDate))
 	}