zhou.yingan 5 anni fa
parent
commit
0788fe86d2
2 ha cambiato i file con 38 aggiunte e 37 eliminazioni
  1. 33 32
      controllers/erms3/business.go
  2. 5 5
      models/erms3.go

+ 33 - 32
controllers/erms3/business.go

@@ -1,8 +1,6 @@
 package erms3
 
 import (
-	"github.com/gin-gonic/gin"
-	"github.com/golang/protobuf/proto"
 	"mtp2_if/global/app"
 	"mtp2_if/global/e"
 	"mtp2_if/logger"
@@ -12,32 +10,35 @@ import (
 	"net/http"
 	"strconv"
 	"strings"
+
+	"github.com/gin-gonic/gin"
+	"github.com/golang/protobuf/proto"
 )
 
 // QueryBusinessInfoReq 查询业务请求.
 type QueryBusinessInfoReq struct {
-	Accountids   string `form:"accountids" binding:"required"`   // 资金账号ID列表,逗号分隔.
-	Status       int32  `form:"status"`                          // 合同状态,0-未结束 1-已结束.
+	Accountids string `form:"accountids" binding:"required"` // 资金账号ID列表,逗号分隔.
+	Status     int32  `form:"status"`                        // 合同状态,0-未结束 1-已结束.
 }
 
 // QueryBusinessInfoRsp 查询业务响应.
 type QueryBusinessInfoRsp struct {
-	BusinessID int64 `json:"businessid"` // 业务ID.
-	Type int32 `json:"type"` // 业务类型,1-期现套利,2-仓单回购,3-现货贸易.
-	GoodsID string `json:"goodsid"` // 商品名称/商品代码.
-	Buyqty string `json:"buyqty"` // 采购量.
-	BuyAmount float64 `json:"buyamount"` // 采购额.
-	Sellqty string `json:"sellqty"` // 销售量.
-	SellAmount float64 `json:"sellamount"` // 销售额.
-	Spotqty string `json:"spotqty"` // 现货量.
+	BusinessID      int64   `json:"businessid"`      // 业务ID.
+	Type            int32   `json:"type"`            // 业务类型,1-期现套利,2-仓单回购,3-现货贸易.
+	GoodsID         string  `json:"goodsid"`         // 商品名称/商品代码.
+	Buyqty          string  `json:"buyqty"`          // 采购量.
+	BuyAmount       float64 `json:"buyamount"`       // 采购额.
+	Sellqty         string  `json:"sellqty"`         // 销售量.
+	SellAmount      float64 `json:"sellamount"`      // 销售额.
+	Spotqty         string  `json:"spotqty"`         // 现货量.
 	SpotMarketValue float64 `json:"spotmarketvalue"` // 现货市值.
-	Hedgingqty string `json:"hedgingqty"` // 套保量.
-	Spotpl float64 `json:"spotpl"` // 浮动权益.
-	Futureqty string `json:"futureqty"` // 期货敞口.
-	Futurepl float64 `json:"futurepl"` // 期货盈亏.
-	Totalqty string `json:"totalqty"` // 总敞口.
-	Totalpl float64 `json:"totalpl"` // 总盈亏.
-	Status int32 `json:"statu"` // 状态,0-未结束 1-已结束.
+	Hedgingqty      string  `json:"hedgingqty"`      // 套保量.
+	Spotpl          float64 `json:"spotpl"`          // 浮动权益.
+	Futureqty       string  `json:"futureqty"`       // 期货敞口.
+	Futurepl        float64 `json:"futurepl"`        // 期货盈亏.
+	Totalqty        string  `json:"totalqty"`        // 总敞口.
+	Totalpl         float64 `json:"totalpl"`         // 总盈亏.
+	Status          int32   `json:"statu"`           // 状态,0-未结束 1-已结束.
 }
 
 // QueryBusinessInfo 查询业务数据
@@ -154,17 +155,17 @@ func QueryBusinessInfo(c *gin.Context) {
 			BusinessID:      asainfo[i].Asapplyid,
 			Type:            1,
 			GoodsID:         strings.Join([]string{goodsinfo.Deliverygoodsname, goodsinfo.Deliverygoodscode}, "/"),
-			Buyqty:          strconv.FormatFloat(detail.Buyqty, 'f', 2, 64)+goodsunit.Enumdicname,
+			Buyqty:          strconv.FormatFloat(detail.Buyqty, 'f', 2, 64) + goodsunit.Enumdicname,
 			BuyAmount:       detail.Buyamount,
-			Sellqty:         strconv.FormatFloat(detail.Sellqty, 'f', 2, 64)+goodsunit.Enumdicname,
+			Sellqty:         strconv.FormatFloat(detail.Sellqty, 'f', 2, 64) + goodsunit.Enumdicname,
 			SellAmount:      detail.Sellamount,
-			Spotqty:         strconv.FormatFloat(asainfo[i].Pricedspotqty, 'f', 2, 64)+goodsunit.Enumdicname,
+			Spotqty:         strconv.FormatFloat(asainfo[i].Pricedspotqty, 'f', 2, 64) + goodsunit.Enumdicname,
 			SpotMarketValue: 0.0,
-			Hedgingqty:      strconv.FormatFloat(asainfo[i].Futureqty, 'f', 2, 64)+goodsunit.Enumdicname,
+			Hedgingqty:      strconv.FormatFloat(asainfo[i].Futureqty, 'f', 2, 64) + goodsunit.Enumdicname,
 			Spotpl:          redisMsg.GetSpotPL(),
-			Futureqty:       strconv.FormatFloat(asainfo[i].Futureqty, 'f', 2, 64)+goodsunit.Enumdicname,
+			Futureqty:       strconv.FormatFloat(asainfo[i].Futureqty, 'f', 2, 64) + goodsunit.Enumdicname,
 			Futurepl:        redisMsg.GetFuturePL(),
-			Totalqty:        strconv.FormatFloat(asainfo[i].Pricedspotqty - asainfo[i].Futureqty, 'f', 2, 64)+goodsunit.Enumdicname,
+			Totalqty:        strconv.FormatFloat(asainfo[i].Pricedspotqty-asainfo[i].Futureqty, 'f', 2, 64) + goodsunit.Enumdicname,
 			Totalpl:         redisMsg.GetTotalPL(),
 			Status:          asainfo[i].Strategystatus,
 		}
@@ -203,11 +204,11 @@ func QueryBusinessInfo(c *gin.Context) {
 			BusinessID:      wrrcontracts[i].Wrrcontractid,
 			Type:            2,
 			GoodsID:         strings.Join([]string{goodsinfo.Deliverygoodsname, goodsinfo.Deliverygoodscode}, "/"),
-			Buyqty:          strconv.FormatFloat(detail.Buyqty, 'f', 2, 64)+goodsunit.Enumdicname,
+			Buyqty:          strconv.FormatFloat(detail.Buyqty, 'f', 2, 64) + goodsunit.Enumdicname,
 			BuyAmount:       detail.Buyamount,
-			Sellqty:         strconv.FormatFloat(detail.Sellqty, 'f', 2, 64)+goodsunit.Enumdicname,
+			Sellqty:         strconv.FormatFloat(detail.Sellqty, 'f', 2, 64) + goodsunit.Enumdicname,
 			SellAmount:      detail.Sellamount,
-			Spotqty:         strconv.FormatFloat(wrrcontracts[i].Contractqty, 'f', 2, 64)+goodsunit.Enumdicname,
+			Spotqty:         strconv.FormatFloat(wrrcontracts[i].Contractqty, 'f', 2, 64) + goodsunit.Enumdicname,
 			SpotMarketValue: 0,
 			Hedgingqty:      "-",
 			Spotpl:          0,
@@ -243,7 +244,7 @@ func QueryBusinessInfo(c *gin.Context) {
 
 		return
 	}
-	
+
 	for i := range spotTradeBiz {
 		goodsinfo := id2goods[int32(spotTradeBiz[i].Deliverygoodsid)]
 		goodsunit := id2enum[uint64(goodsinfo.Goodsunitid)]
@@ -252,11 +253,11 @@ func QueryBusinessInfo(c *gin.Context) {
 			BusinessID:      spotTradeBiz[i].Spottradeid,
 			Type:            3,
 			GoodsID:         strings.Join([]string{goodsinfo.Deliverygoodsname, goodsinfo.Deliverygoodscode}, "/"),
-			Buyqty:          strconv.FormatFloat(detail.Buyqty, 'f', 2, 64)+goodsunit.Enumdicname,
+			Buyqty:          strconv.FormatFloat(detail.Buyqty, 'f', 2, 64) + goodsunit.Enumdicname,
 			BuyAmount:       detail.Buyamount,
-			Sellqty:         strconv.FormatFloat(detail.Sellqty, 'f', 2, 64)+goodsunit.Enumdicname,
+			Sellqty:         strconv.FormatFloat(detail.Sellqty, 'f', 2, 64) + goodsunit.Enumdicname,
 			SellAmount:      detail.Sellamount,
-			Spotqty:         strconv.FormatFloat(spotTradeBiz[i].Buyqty+spotTradeBiz[i].Sellqty, 'f', 2, 64)+goodsunit.Enumdicname,
+			Spotqty:         strconv.FormatFloat(spotTradeBiz[i].Buyqty+spotTradeBiz[i].Sellqty, 'f', 2, 64) + goodsunit.Enumdicname,
 			SpotMarketValue: 0,
 			Hedgingqty:      "-",
 			Spotpl:          0,

+ 5 - 5
models/erms3.go

@@ -225,11 +225,11 @@ func QueryBizTradeDetailByBizID(relatedbizid []int64) ([]Erms3Biztradedetail, er
 
 // Erms3BizTradeInfo 汇总数据.
 type Erms3BizTradeInfo struct {
-	Relatedbizid int64     // 关联业务ID
-	Buyqty       float64   // 采购量.
-	Buyamount    float64   // 采购额.
-	Sellqty      float64   // 销售量.
-	Sellamount   float64   // 销售额.
+	Relatedbizid int64   // 关联业务ID
+	Buyqty       float64 // 采购量.
+	Buyamount    float64 // 采购额.
+	Sellqty      float64 // 销售量.
+	Sellamount   float64 // 销售额.
 }
 
 // QueryBizTradeInfo 根据关联业务ID查询汇总信息.