ソースを参照

联调问题修改:字段类型、参数等

zou.yingbin 4 年 前
コミット
a71cf437cb
2 ファイル変更28 行追加23 行削除
  1. 2 2
      controllers/wrTrade2/qryWrTrade.go
  2. 26 21
      models/wrTrade2.go

+ 2 - 2
controllers/wrTrade2/qryWrTrade.go

@@ -36,7 +36,7 @@ func QueryOrderQuote(c *gin.Context) {
 	a.DoGetDataByPage(&m)
 }
 
-// QueryOrderQuote
+// QueryOrderQuoteDetail
 // @Summary 查询买卖大厅
 // @Produce json
 // @Security ApiKeyAuth
@@ -46,7 +46,7 @@ func QueryOrderQuote(c *gin.Context) {
 // @Param wrpricetype query int true "价格方式 - 1:固定价 2-浮动价"
 // @Param haswr query int true "0:仓单预售 1:仓单贸易"
 // @Param wrfactortypeid query int true "仓单要素id"
-// @Param goodsid query int true "期货商品id"
+// @Param goodsid query int false "期货商品id(浮动价方式时填)"
 // @Param buyorsell query int true "买卖方向 0-买 1-卖"
 // @Success 200 {array} models.WrOrderQuoteDetail
 // @Failure 500 {object} app.Response

+ 26 - 21
models/wrTrade2.go

@@ -250,7 +250,7 @@ type WrOrderQuoteDetail struct {
 	BUYORSELL      int32   `json:"buyorsell"  xorm:"BUYORSELL" form:"buyorsell"` // 买卖 - 0:买 1:卖
 	USERID         int64   `json:"userid"  xorm:"USERID" form:"userid"`          // 购买方(销售方)用户ID
 	QTY            float64 `json:"orderqty"  xorm:"ORDERQTY"`                    // 买(卖)量(=委托量-成交量)
-	PRICE          float64 `json:"fixedprice"  xorm:"FIXEDPRICE"`                // 买(卖)价
+	PRICE          float64 `json:"fixedprice"  xorm:"price"`                     // 买(卖)价
 	PRICEMOVE      float64 `json:"pricemove"  xorm:"PRICEMOVE"`                  // 买(卖)升贴水- 基差
 	USERNAME       string  `json:"username"  xorm:"'USERNAME'"`                  // 购买方(销售方)
 	PageEx         `xorm:"extends"`
@@ -282,14 +282,14 @@ func (r *WrOrderQuoteDetail) buildSql() string {
 		"  left join WRTRADE_GOODSCONFIG c" +
 		"    on t.wrtradeorderid = c.wrtradeorderid" +
 		"  left join Useraccount u" +
-		"    on t.userid = u.Accountname" +
+		"    on t.userid = u.userid" +
 		" where 1 = 1" +
 		"   and t.wrtradetype = 1" +
 		"   and t.wrtradeorderstatus in (3, 10)"
 	sqlId.And("t.haswr", r.HasWr)
 	sqlId.And("t.wrpricetype", r.WrPriceType)
 	sqlId.And("t.wrfactortypeid", r.WRFACTORTYPEID)
-	sqlId.And("c.goodsid", r.GOODSID)
+	sqlId.AndEx("c.goodsid", r.GOODSID, r.GOODSID > 0)
 	sqlId.And("t.buyorsell", r.BUYORSELL)
 	sqlId.AndEx("t.marketid", r.MarketId, r.MarketId > 0)
 
@@ -335,24 +335,26 @@ type Wr2FactorType struct {
 	WRSTANDARDNAME    string `json:"wrstandardname"  xorm:"'WRSTANDARDNAME'"`       // 商品名称
 	DELIVERYGOODSCODE string `json:"deliverygoodscode"  xorm:"'DELIVERYGOODSCODE'"` // 品种代码
 	DELIVERYGOODSNAME string `json:"deliverygoodsname"  xorm:"'DELIVERYGOODSNAME'"` // 品种名称
-	ENUMDICNAME       string `json:"enumdicname"`                                   // 单位名称
+	ENUMDICNAME       string `json:"enumdicname" xorm:"'enumdicname'"`              // 单位名称
 	WAREHOUSENAME     string `json:"warehousename"  xorm:"'WAREHOUSENAME'"`         // 仓库名称
 
-	WRTYPENAME string `json:"wrtypename"` // 商品
+	WRTYPENAME string `json:"wrtypename" xorm:"'WRTYPENAME'"` // 商品
 }
 
 func (r *Wr2FactorType) Calc() {
-	if len(r.WRFACTORTYPENAME) > 0 {
-		r.WRTYPENAME = r.WRSTANDARDNAME + "-" + r.WRFACTORTYPENAME
-	} else {
-		r.WRTYPENAME = r.WRSTANDARDNAME
+	if r.WRTYPENAME == "" {
+		if len(r.WRFACTORTYPENAME) > 0 {
+			r.WRTYPENAME = r.WRSTANDARDNAME + r.WRFACTORTYPENAME
+		} else {
+			r.WRTYPENAME = r.WRSTANDARDNAME
+		}
 	}
 	r.WRTYPENAME = strings.ReplaceAll(r.WRTYPENAME, ",", "-")
 }
 
 // WrPosition 仓单贸易持仓汇总
 type WrPosition struct {
-	WRPOSITIONID    int64   `json:"wrpositionid"  xorm:"WRPOSITIONID" form:"wrpositionid"`          // 仓单头寸ID(201+Unix秒时间戳(10位)+xxxxxx)
+	WRPOSITIONID    string  `json:"wrpositionid"  xorm:"WRPOSITIONID" form:"wrpositionid"`          // 仓单头寸ID(201+Unix秒时间戳(10位)+xxxxxx)
 	WRUSERID        int64   `json:"wruserid"  xorm:"WRUSERID" form:"userid"`                        // 持有人ID
 	TOTALQTY        float64 `json:"totalqty"  xorm:"TOTALQTY" form:"totalqty"`                      // 总数量(库存数量)
 	INCREASEQTY     float64 `json:"-"  xorm:"INCREASEQTY" form:"increaseqty"`                       // 今日增加数量
@@ -405,7 +407,7 @@ func (r *WrPosition) buildSql1() string {
 		"         w.wrstandardid," +
 		"         w.warehouseid," +
 		"         wd.wrstandardname," +
-		"         wd.wrstandardname || '-' ||w.wrfactortypename2 as wrtypename" +
+		"         wd.wrstandardname || w.wrfactortypename2 as wrtypename" +
 		"    from WRPOSITION t" +
 		"    left join WRFACTORTYPE w" +
 		"      on t.wrfactortypeid = w.wrfactortypeid" +
@@ -415,6 +417,7 @@ func (r *WrPosition) buildSql1() string {
 		"hld as" +
 		" (select k.deliverygoodsid," +
 		"         k.wrtypename," +
+		"         k.wrstandardid," +
 		"         sum(k.TOTALQTY) TOTALQTY," +
 		"         sum(k.INCREASEQTY) INCREASEQTY," +
 		"         sum(k.DECREASEQTY) DECREASEQTY," +
@@ -427,13 +430,15 @@ func (r *WrPosition) buildSql1() string {
 		"         sum(k.CREDITTRADEQTY) CREDITTRADEQTY" +
 		"    from tmp k" +
 		"   where 1 = 1" +
-		"   group by k.deliverygoodsid, k.wrstandardname, k.wrtypename)" +
+		"   group by k.deliverygoodsid, k.wrstandardname, k.wrtypename, k.wrstandardid)" +
 		"select h.*, g.deliverygoodsname, g.deliverygoodscode, e.enumdicname" +
 		"  from hld h" +
 		"  left join deliverygoods g" +
 		"    on h.deliverygoodsid = g.deliverygoodsid" +
+		"  left join wrstandard wd" +
+		"    on h.wrstandardid = wd.wrstandardid" +
 		"  left join enumdicitem e" +
-		"    on e.enumitemname = g.goodsunitid" +
+		"    on e.enumitemname = wd.unitid" +
 		"   and e.enumdiccode = 'goodsunit'"
 	sqlId.FormatParam(r.WRUSERID)
 	return sqlId.String()
@@ -444,7 +449,7 @@ func (r *WrPosition) buildSql2() string {
 }
 
 func (r *WrPosition) buildSql3() string {
-	var sqlId utils.SQLVal = "SELECT t.WRPOSITIONID," +
+	var sqlId utils.SQLVal = "SELECT to_char(t.WRPOSITIONID) WRPOSITIONID," +
 		"       t.WRUSERID," +
 		"       t.TOTALQTY," +
 		"       t.INCREASEQTY," +
@@ -459,7 +464,7 @@ func (r *WrPosition) buildSql3() string {
 		"       t.CREDITCURQTY," +
 		"       t.CREDITFREEZEQTY," +
 		"       t.CREDITTRADEQTY," +
-		"       w.WRFACTORTYPEID," +
+		"       to_char(w.WRFACTORTYPEID) WRFACTORTYPEID," +
 		"       w.WRFACTORTYPENAME2 WRFACTORTYPENAME," +
 		"       w.DELIVERYGOODSID," +
 		"       w.WAREHOUSEID," +
@@ -479,7 +484,7 @@ func (r *WrPosition) buildSql3() string {
 		"  LEFT JOIN WRSTANDARD wd" +
 		"    on w.wrstandardid = wd.wrstandardid" +
 		"  left join enumdicitem e" +
-		"    on e.enumitemname = dg.goodsunitid" +
+		"    on e.enumitemname = wd.unitid" +
 		"   and e.enumdiccode = 'goodsunit'" +
 		" WHERE 1 = 1"
 	sqlId.And("t.WRUSERID", r.WRUSERID)
@@ -548,7 +553,7 @@ func (r *WrOrderDetail) buildSql() string {
 		"         h.warehousecode," +
 		"         h.warehousename," +
 		"         e.enumdicname," +
-		"         w.wrstandardname || '-' || t.wrfactortypename2 as wrtypename" +
+		"         w.wrstandardname || t.wrfactortypename2 as wrtypename" +
 		"    from wrfactortype t" +
 		"    left join deliverygoods g" +
 		"      on t.deliverygoodsid = g.deliverygoodsid" +
@@ -642,7 +647,7 @@ func (r *WrTradeDetail) buildSql() string {
 		"         h.warehousecode," +
 		"         h.warehousename," +
 		"         e.enumdicname," +
-		"         w.wrstandardname || '-' || t.wrfactortypename2 as wrtypename" +
+		"         w.wrstandardname || t.wrfactortypename2 as wrtypename" +
 		"    from wrfactortype t" +
 		"    left join deliverygoods g" +
 		"      on t.deliverygoodsid = g.deliverygoodsid" +
@@ -737,7 +742,7 @@ func (r *WrSpecialMatchOrder) buildSql() string {
 		"         h.warehousecode," +
 		"         h.warehousename," +
 		"         e.enumdicname," +
-		"         w.wrstandardname || '-' || t.wrfactortypename2 as wrtypename" +
+		"         w.wrstandardname || t.wrfactortypename2 as wrtypename" +
 		"    from wrfactortype t" +
 		"    left join deliverygoods g" +
 		"      on t.deliverygoodsid = g.deliverygoodsid" +
@@ -1026,7 +1031,7 @@ func (r *WrPerformancePlan) buildSql() string {
 		"         h.warehousecode," +
 		"         h.warehousename," +
 		"         e.enumdicname," +
-		"         w.wrstandardname || '-' || t.wrfactortypename2 as wrtypename" +
+		"         w.wrstandardname || t.wrfactortypename2 as wrtypename" +
 		"    from wrfactortype t" +
 		"    left join deliverygoods g" +
 		"      on t.deliverygoodsid = g.deliverygoodsid" +
@@ -1152,7 +1157,7 @@ func (r *WrHoldLB) buildSql() string {
 		"         h.warehousecode," +
 		"         h.warehousename," +
 		"         e.enumdicname," +
-		"         w.wrstandardname || '-' || t.wrfactortypename2 as wrtypename" +
+		"         w.wrstandardname || t.wrfactortypename2 as wrtypename" +
 		"    from wrfactortype t" +
 		"    left join deliverygoods g" +
 		"      on t.deliverygoodsid = g.deliverygoodsid" +