|
|
@@ -64,18 +64,6 @@ func QueryBusinessInfo(c *gin.Context) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- strids := strings.Split(strings.TrimSpace(req.Accountids), ",")
|
|
|
- accountids := make([]int64, len(strids))
|
|
|
- for i := range strids {
|
|
|
- accountids[i], err = strconv.ParseInt(strids[i], 10, 64)
|
|
|
- if err != nil {
|
|
|
- logger.GetLogger().Errorf("ParseInt failed: %s", err.Error())
|
|
|
- appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
|
|
|
-
|
|
|
- return
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
// 获取商品信息.
|
|
|
goods, err := models.GetDeliverGoods()
|
|
|
if err != nil {
|
|
|
@@ -106,27 +94,11 @@ func QueryBusinessInfo(c *gin.Context) {
|
|
|
id2enum[enuminfo[i].Enumitemname] = enuminfo[i]
|
|
|
}
|
|
|
|
|
|
- // 查询期现套利业务,首先查询业务ID集合.
|
|
|
- applyid, err := models.QueryASApplyIDSByAccountID(accountids)
|
|
|
- if err != nil {
|
|
|
- logger.GetLogger().Errorf("query applyid failed: %s", err.Error())
|
|
|
- appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
|
|
|
-
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- // 查询业务对应单据详细信息.
|
|
|
- tradeinfo, err := models.QueryBizTradeInfo(applyid)
|
|
|
- if err != nil {
|
|
|
- logger.GetLogger().Errorf("query biztradedetail failed: %s", err.Error())
|
|
|
- appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
|
|
|
-
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- asainfo, err := models.QueryArbitragestrategy(applyid, req.Status)
|
|
|
+ // 查询期现套利业务.
|
|
|
+ var asa models.Erms2Arbitragestrategy
|
|
|
+ asainfo, err := asa.GetByAccountIDSAndStatus(req.Accountids, req.Status)
|
|
|
if err != nil {
|
|
|
- logger.GetLogger().Errorf("query arbitragestrategy failed: %s", err.Error())
|
|
|
+ logger.GetLogger().Errorf("query asainfo failed: %s", err.Error())
|
|
|
appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
|
|
|
|
|
|
return
|
|
|
@@ -136,7 +108,7 @@ func QueryBusinessInfo(c *gin.Context) {
|
|
|
preKey := "Erms2_ArbitrageStrategy:"
|
|
|
rsp := make([]QueryBusinessInfoRsp, 0, len(asainfo))
|
|
|
for i := range asainfo {
|
|
|
- key := preKey + strconv.FormatInt(asainfo[i].Asapplyid, 10)
|
|
|
+ key := preKey + asainfo[i].Asapplyid
|
|
|
redisMsg := pb.Erms2ArbitrageStrategy{}
|
|
|
redisRsp, err := redisClient.Get(key).Result()
|
|
|
if err != nil {
|
|
|
@@ -150,15 +122,22 @@ func QueryBusinessInfo(c *gin.Context) {
|
|
|
|
|
|
goodsinfo := id2goods[int32(asainfo[i].Deliverygoodsid)]
|
|
|
goodsunit := id2enum[int64(goodsinfo.Goodsunitid)]
|
|
|
- detail := tradeinfo[asainfo[i].Asapplyid]
|
|
|
+ businessid, err := strconv.ParseInt(asainfo[i].Asapplyid, 10, 64)
|
|
|
+ if err != nil {
|
|
|
+ logger.GetLogger().Errorf("parse string[%s] to int failed: %s", asainfo[i].Asapplyid, err.Error())
|
|
|
+ appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
|
|
|
+
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
business := QueryBusinessInfoRsp{
|
|
|
- BusinessID: asainfo[i].Asapplyid,
|
|
|
+ BusinessID: businessid,
|
|
|
Type: 1,
|
|
|
GoodsID: strings.Join([]string{goodsinfo.Deliverygoodsname, goodsinfo.Deliverygoodscode}, "/"),
|
|
|
- Buyqty: strconv.FormatFloat(detail.Buyqty, 'f', 2, 64) + goodsunit.Enumdicname,
|
|
|
- BuyAmount: detail.Buyamount,
|
|
|
- Sellqty: strconv.FormatFloat(detail.Sellqty, 'f', 2, 64) + goodsunit.Enumdicname,
|
|
|
- SellAmount: detail.Sellamount,
|
|
|
+ Buyqty: strconv.FormatFloat(asainfo[i].Buyqty, 'f', 2, 64) + goodsunit.Enumdicname,
|
|
|
+ BuyAmount: asainfo[i].Buyamount,
|
|
|
+ Sellqty: strconv.FormatFloat(asainfo[i].Sellqty, 'f', 2, 64) + goodsunit.Enumdicname,
|
|
|
+ SellAmount: asainfo[i].Sellamount,
|
|
|
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,
|
|
|
@@ -174,7 +153,8 @@ func QueryBusinessInfo(c *gin.Context) {
|
|
|
}
|
|
|
|
|
|
// 查询仓单回购业务.
|
|
|
- wrrcontracts, err := models.QueryWRRContract(accountids, req.Status)
|
|
|
+ var wr models.Erms2Wrrcontract
|
|
|
+ wrrcontracts, err := wr.GetByAccountIDSAndStatus(req.Accountids, req.Status)
|
|
|
if err != nil {
|
|
|
logger.GetLogger().Errorf("query wrrcontract failed: %s", err.Error())
|
|
|
appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
|
|
|
@@ -182,32 +162,25 @@ func QueryBusinessInfo(c *gin.Context) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- wrrids := make([]int64, 0, len(wrrcontracts))
|
|
|
- for i := range wrrcontracts {
|
|
|
- wrrids = append(wrrids, wrrcontracts[i].Wrrcontractid)
|
|
|
- }
|
|
|
-
|
|
|
- // 查询业务对应单据详细信息.
|
|
|
- wrtradeinfo, err := models.QueryBizTradeInfo(wrrids)
|
|
|
- if err != nil {
|
|
|
- logger.GetLogger().Errorf("query biztradedetail failed: %s", err.Error())
|
|
|
- appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
|
|
|
-
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
for i := range wrrcontracts {
|
|
|
goodsinfo := id2goods[int32(wrrcontracts[i].Deliverygoodsid)]
|
|
|
goodsunit := id2enum[int64(goodsinfo.Goodsunitid)]
|
|
|
- detail := wrtradeinfo[wrrcontracts[i].Wrrcontractid]
|
|
|
+ businessid, err := strconv.ParseInt(wrrcontracts[i].Wrrcontractid, 10, 64)
|
|
|
+ if err != nil {
|
|
|
+ logger.GetLogger().Errorf("parse string[%s] to int failed: %s", asainfo[i].Asapplyid, err.Error())
|
|
|
+ appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
|
|
|
+
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
business := QueryBusinessInfoRsp{
|
|
|
- BusinessID: wrrcontracts[i].Wrrcontractid,
|
|
|
+ BusinessID: businessid,
|
|
|
Type: 2,
|
|
|
GoodsID: strings.Join([]string{goodsinfo.Deliverygoodsname, goodsinfo.Deliverygoodscode}, "/"),
|
|
|
- Buyqty: strconv.FormatFloat(detail.Buyqty, 'f', 2, 64) + goodsunit.Enumdicname,
|
|
|
- BuyAmount: detail.Buyamount,
|
|
|
- Sellqty: strconv.FormatFloat(detail.Sellqty, 'f', 2, 64) + goodsunit.Enumdicname,
|
|
|
- SellAmount: detail.Sellamount,
|
|
|
+ Buyqty: strconv.FormatFloat(wrrcontracts[i].Buyqty, 'f', 2, 64) + goodsunit.Enumdicname,
|
|
|
+ BuyAmount: wrrcontracts[i].Buyamount,
|
|
|
+ Sellqty: strconv.FormatFloat(wrrcontracts[i].Sellqty, 'f', 2, 64) + goodsunit.Enumdicname,
|
|
|
+ SellAmount: wrrcontracts[i].Sellamount,
|
|
|
Spotqty: strconv.FormatFloat(wrrcontracts[i].Contractqty, 'f', 2, 64) + goodsunit.Enumdicname,
|
|
|
SpotMarketValue: 0,
|
|
|
Hedgingqty: "-",
|
|
|
@@ -223,7 +196,8 @@ func QueryBusinessInfo(c *gin.Context) {
|
|
|
}
|
|
|
|
|
|
// 查询现货贸易业务.
|
|
|
- spotTradeBiz, err := models.QuerySpotTradeBiz(accountids, req.Status)
|
|
|
+ var sbt models.Erms2Spottradebiz
|
|
|
+ spotTradeBiz, err := sbt.GetByAccountIDSAndStatus(req.Accountids, req.Status)
|
|
|
if err != nil {
|
|
|
logger.GetLogger().Errorf("query spottradebiz failed: %s", err.Error())
|
|
|
appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
|
|
|
@@ -231,32 +205,25 @@ func QueryBusinessInfo(c *gin.Context) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- spotids := make([]int64, 0, len(spotTradeBiz))
|
|
|
- for i := range spotTradeBiz {
|
|
|
- spotids = append(spotids, spotTradeBiz[i].Spottradeid)
|
|
|
- }
|
|
|
-
|
|
|
- // 查询业务对应单据详细信息.
|
|
|
- spottradeinfo, err := models.QueryBizTradeInfo(spotids)
|
|
|
- if err != nil {
|
|
|
- logger.GetLogger().Errorf("query spottradedetail failed: %s", err.Error())
|
|
|
- appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
|
|
|
-
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
for i := range spotTradeBiz {
|
|
|
goodsinfo := id2goods[int32(spotTradeBiz[i].Deliverygoodsid)]
|
|
|
goodsunit := id2enum[int64(goodsinfo.Goodsunitid)]
|
|
|
- detail := spottradeinfo[spotTradeBiz[i].Spottradeid]
|
|
|
+ businessid, err := strconv.ParseInt(spotTradeBiz[i].Spottradeid, 10, 64)
|
|
|
+ if err != nil {
|
|
|
+ logger.GetLogger().Errorf("parse string[%s] to int failed: %s", asainfo[i].Asapplyid, err.Error())
|
|
|
+ appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
|
|
|
+
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
business := QueryBusinessInfoRsp{
|
|
|
- BusinessID: spotTradeBiz[i].Spottradeid,
|
|
|
+ BusinessID: businessid,
|
|
|
Type: 3,
|
|
|
GoodsID: strings.Join([]string{goodsinfo.Deliverygoodsname, goodsinfo.Deliverygoodscode}, "/"),
|
|
|
- Buyqty: strconv.FormatFloat(detail.Buyqty, 'f', 2, 64) + goodsunit.Enumdicname,
|
|
|
- BuyAmount: detail.Buyamount,
|
|
|
- Sellqty: strconv.FormatFloat(detail.Sellqty, 'f', 2, 64) + goodsunit.Enumdicname,
|
|
|
- SellAmount: detail.Sellamount,
|
|
|
+ Buyqty: strconv.FormatFloat(spotTradeBiz[i].TradeBuyqty, 'f', 2, 64) + goodsunit.Enumdicname,
|
|
|
+ BuyAmount: spotTradeBiz[i].TradeBuyamount,
|
|
|
+ Sellqty: strconv.FormatFloat(spotTradeBiz[i].TradeSellqty, 'f', 2, 64) + goodsunit.Enumdicname,
|
|
|
+ SellAmount: spotTradeBiz[i].TradeSellamount,
|
|
|
Spotqty: strconv.FormatFloat(spotTradeBiz[i].Buyqty+spotTradeBiz[i].Sellqty, 'f', 2, 64) + goodsunit.Enumdicname,
|
|
|
SpotMarketValue: 0,
|
|
|
Hedgingqty: "-",
|