Browse Source

1.查贸易圈接口增加品种、品种名称
2.查挂单增加挂牌金额字段

zou.yingbin 4 years ago
parent
commit
5ac43ba48f
5 changed files with 152 additions and 51 deletions
  1. 1 0
      controllers/wrTrade2/qryWrTrade.go
  2. 27 0
      docs/docs.go
  3. 27 0
      docs/swagger.json
  4. 20 0
      docs/swagger.yaml
  5. 77 51
      models/wrTrade2.go

+ 1 - 0
controllers/wrTrade2/qryWrTrade.go

@@ -70,6 +70,7 @@ func QueryOrderQuoteDetail(c *gin.Context) {
 // @Security ApiKeyAuth
 // @Param page query int false "页码"
 // @Param pagesize query int false "每页条数"
+// @Param userid query int true "用户id"
 // @Param marketid query int false "仓单贸易市场id"
 // @Param haswr query int true "0:仓单预售 1:仓单贸易"
 // @Param buyorsell query int true "买卖方向 0-买 1-卖"

+ 27 - 0
docs/docs.go

@@ -11350,6 +11350,13 @@ var doc = `{
                     },
                     {
                         "type": "integer",
+                        "description": "用户id",
+                        "name": "userid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
                         "description": "仓单贸易市场id",
                         "name": "marketid",
                         "in": "query"
@@ -31919,6 +31926,10 @@ var doc = `{
                     "description": "是否全好友可见 - 0:否 1:是",
                     "type": "integer"
                 },
+                "amount": {
+                    "description": "挂牌金额 = 委托数量 * 固定价或升贴水",
+                    "type": "number"
+                },
                 "buyorsell": {
                     "description": "买卖 - 0:买 1:卖(挂牌类型 买为采购 卖为销售)",
                     "type": "integer"
@@ -32938,10 +32949,18 @@ var doc = `{
                     "description": "起摘数量",
                     "type": "number"
                 },
+                "deliverygoodscode": {
+                    "description": "品种代码",
+                    "type": "string"
+                },
                 "deliverygoodsid": {
                     "description": "品种ID",
                     "type": "integer"
                 },
+                "deliverygoodsname": {
+                    "description": "品种名称",
+                    "type": "string"
+                },
                 "deliverymonth": {
                     "description": "交收月",
                     "type": "string"
@@ -33014,10 +33033,18 @@ var doc = `{
                     "description": "仓单要素id",
                     "type": "string"
                 },
+                "wrstandardcode": {
+                    "description": "现货商品代码",
+                    "type": "string"
+                },
                 "wrstandardid": {
                     "description": "现货商品ID",
                     "type": "integer"
                 },
+                "wrstandardname": {
+                    "description": "商品名称",
+                    "type": "string"
+                },
                 "wrtradeorderid": {
                     "description": "仓单贸易委托单ID(320+Unix秒时间戳(10位)+xxxxxx)",
                     "type": "string"

+ 27 - 0
docs/swagger.json

@@ -11334,6 +11334,13 @@
                     },
                     {
                         "type": "integer",
+                        "description": "用户id",
+                        "name": "userid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
                         "description": "仓单贸易市场id",
                         "name": "marketid",
                         "in": "query"
@@ -31903,6 +31910,10 @@
                     "description": "是否全好友可见 - 0:否 1:是",
                     "type": "integer"
                 },
+                "amount": {
+                    "description": "挂牌金额 = 委托数量 * 固定价或升贴水",
+                    "type": "number"
+                },
                 "buyorsell": {
                     "description": "买卖 - 0:买 1:卖(挂牌类型 买为采购 卖为销售)",
                     "type": "integer"
@@ -32922,10 +32933,18 @@
                     "description": "起摘数量",
                     "type": "number"
                 },
+                "deliverygoodscode": {
+                    "description": "品种代码",
+                    "type": "string"
+                },
                 "deliverygoodsid": {
                     "description": "品种ID",
                     "type": "integer"
                 },
+                "deliverygoodsname": {
+                    "description": "品种名称",
+                    "type": "string"
+                },
                 "deliverymonth": {
                     "description": "交收月",
                     "type": "string"
@@ -32998,10 +33017,18 @@
                     "description": "仓单要素id",
                     "type": "string"
                 },
+                "wrstandardcode": {
+                    "description": "现货商品代码",
+                    "type": "string"
+                },
                 "wrstandardid": {
                     "description": "现货商品ID",
                     "type": "integer"
                 },
+                "wrstandardname": {
+                    "description": "商品名称",
+                    "type": "string"
+                },
                 "wrtradeorderid": {
                     "description": "仓单贸易委托单ID(320+Unix秒时间戳(10位)+xxxxxx)",
                     "type": "string"

+ 20 - 0
docs/swagger.yaml

@@ -14297,6 +14297,9 @@ definitions:
       allfriendsflag:
         description: 是否全好友可见 - 0:否 1:是
         type: integer
+      amount:
+        description: 挂牌金额 = 委托数量 * 固定价或升贴水
+        type: number
       buyorsell:
         description: 买卖 - 0:买 1:卖(挂牌类型 买为采购 卖为销售)
         type: integer
@@ -15064,9 +15067,15 @@ definitions:
       delistminqty:
         description: 起摘数量
         type: number
+      deliverygoodscode:
+        description: 品种代码
+        type: string
       deliverygoodsid:
         description: 品种ID
         type: integer
+      deliverygoodsname:
+        description: 品种名称
+        type: string
       deliverymonth:
         description: 交收月
         type: string
@@ -15121,9 +15130,15 @@ definitions:
       wrfactortypeid:
         description: 仓单要素id
         type: string
+      wrstandardcode:
+        description: 现货商品代码
+        type: string
       wrstandardid:
         description: 现货商品ID
         type: integer
+      wrstandardname:
+        description: 商品名称
+        type: string
       wrtradeorderid:
         description: 仓单贸易委托单ID(320+Unix秒时间戳(10位)+xxxxxx)
         type: string
@@ -24716,6 +24731,11 @@ paths:
         in: query
         name: pagesize
         type: integer
+      - description: 用户id
+        in: query
+        name: userid
+        required: true
+        type: integer
       - description: 仓单贸易市场id
         in: query
         name: marketid

+ 77 - 51
models/wrTrade2.go

@@ -77,7 +77,7 @@ func (r *WrOrderQuote) buildSqlFixedPrice() string {
 		"                  nvl(t.deliverymonth,'0') deliverymonth," +
 		"                  rank() over(partition by t.wrfactortypeid, nvl(t.deliverymonth,'0') order by t.fixedprice desc) cnt" +
 		"             from wrtrade_orderdetail t" +
-		"            where t.wrtradetype = 1 and t.buyorsell = 0 and t.wrtradeorderstatus in(3,10) %v" +
+		"            where t.wrtradetype = 1 and t.isspecified=0 and t.buyorsell = 0 and t.wrtradeorderstatus in(3,10) %v" +
 		"          ) a" +
 		"   where a.cnt = 1" +
 		"   group by a.wrfactortypeid, a.fixedprice, a.deliverymonth)," +
@@ -92,7 +92,7 @@ func (r *WrOrderQuote) buildSqlFixedPrice() string {
 		"                  nvl(t.deliverymonth,'0') deliverymonth," +
 		"                  rank() over(partition by t.wrfactortypeid, nvl(t.deliverymonth,'0') order by t.fixedprice asc) cnt" +
 		"             from wrtrade_orderdetail t" +
-		"            where t.wrtradetype = 1 and t.buyorsell = 1 and t.wrtradeorderstatus in(3,10) %v " +
+		"            where t.wrtradetype = 1 and t.isspecified=0 and t.buyorsell = 1 and t.wrtradeorderstatus in(3,10) %v " +
 		"          ) a" +
 		"   where a.cnt = 1" +
 		"   group by a.wrfactortypeid, a.fixedprice, a.deliverymonth)," +
@@ -176,7 +176,7 @@ func (r *WrOrderQuote) buildSqlPriceMove() string {
 		"            from wrtrade_orderdetail t" +
 		"            left join WRTrade_GoodsConfig c" +
 		"              on t.wrtradeorderid = c.wrtradeorderid" +
-		"           where t.wrtradetype = 1 and t.wrtradeorderstatus in(3,10)" +
+		"           where t.wrtradetype = 1 and t.isspecified=0 and t.wrtradeorderstatus in(3,10)" +
 		"             and t.buyorsell = 0 %v) a" +
 		"   where a.cnt = 1" +
 		"   group by a.wrfactortypeid, a.pricemove, a.goodsid, a.goodscode, a.deliverymonth)," +
@@ -199,7 +199,7 @@ func (r *WrOrderQuote) buildSqlPriceMove() string {
 		"            from wrtrade_orderdetail t" +
 		"            left join WRTrade_GoodsConfig c" +
 		"              on t.wrtradeorderid = c.wrtradeorderid" +
-		"           where t.wrtradetype = 1 and t.wrtradeorderstatus in(3,10)" +
+		"           where t.wrtradetype = 1 and t.isspecified=0 and t.wrtradeorderstatus in(3,10)" +
 		"             and t.buyorsell = 1 %v) a" +
 		"   where a.cnt = 1" +
 		"   group by a.wrfactortypeid, a.pricemove, a.goodsid, a.goodscode, a.deliverymonth)," +
@@ -336,6 +336,7 @@ func (r *WrOrderQuoteDetail) buildSql() string {
 		"  left join enumdicitem e on wd.unitid=e.enumitemname and e.enumdiccode='goodsunit'" +
 		" where 1 = 1" +
 		"   and t.wrtradetype = 1" +
+		"   and t.isspecified = 0" +
 		"   and t.wrtradeorderstatus in (3, 10)"
 	sqlId.And("t.haswr", r.HasWr)
 	sqlId.And("t.wrpricetype", r.WrPriceType)
@@ -655,7 +656,8 @@ type WrOrderDetail struct {
 	Wr2FactorType `xorm:"extends"`
 	PageEx        `xorm:"extends"`
 
-	FUTUSHOW string `json:"futushow"` // 期货合约/升贴水
+	FUTUSHOW string   `json:"futushow"` // 期货合约/升贴水
+	AMOUNT   SFLOAT64 `json:"amount"`   // 挂牌金额 = 委托数量 * 固定价或升贴水
 }
 
 func (r *WrOrderDetail) calc() {
@@ -666,6 +668,11 @@ func (r *WrOrderDetail) calc() {
 	}
 	r.Wr2FactorType.Calc()
 	r.MATCHUSERNAME = EncryptByStar(r.MATCHUSERNAME)
+	if r.WRPRICETYPE == 1 {
+		r.AMOUNT.Set(r.ORDERQTY * r.FIXEDPRICE)
+	} else {
+		r.AMOUNT.Set(r.ORDERQTY * r.PRICEMOVE)
+	}
 }
 
 func (r *WrOrderDetail) buildSql() string {
@@ -2815,6 +2822,10 @@ type WrQuoteOrderMyq struct {
 	WRSTANDARDID          int64   `json:"wrstandardid"  xorm:"WRSTANDARDID" form:"wrstandardid"`          // 现货商品ID
 	DELIVERYGOODSID       int32   `json:"deliverygoodsid"  xorm:"DELIVERYGOODSID" form:"deliverygoodsid"` // 品种ID
 	WRFACTORTYPEID        string  `json:"wrfactortypeid"  xorm:"'WRFACTORTYPEID'"`                        // 仓单要素id
+	WRSTANDARDNAME        string  `json:"wrstandardname"  xorm:"'WRSTANDARDNAME'"`                        // 商品名称
+	WRSTANDARDCODE        string  `json:"wrstandardcode"  xorm:"WRSTANDARDCODE" form:"wrstandardcode"`    // 现货商品代码
+	DELIVERYGOODSCODE     string  `json:"deliverygoodscode"  xorm:"'DELIVERYGOODSCODE'"`                  // 品种代码
+	DELIVERYGOODSNAME     string  `json:"deliverygoodsname"  xorm:"'DELIVERYGOODSNAME'"`                  // 品种名称
 	PageEx                `xorm:"extends"`
 
 	HasWr       int32  `json:"-" form:"haswr"`       // 是否有仓单 0-没有 1-有
@@ -2830,52 +2841,67 @@ func (r *WrQuoteOrderMyq) calc() {
 }
 
 func (r *WrQuoteOrderMyq) buildSql() string {
-	var sqlId utils.SQLVal = "select to_char(t.wrtradeorderid) wrtradeorderid," +
-		"       to_char(t.wrfactortypeid) wrfactortypeid," +
-		"       t.userid," +
-		"       t.orderqty - t.tradeqty as qty," +
-		"       t.fixedprice as price," +
-		"       t.pricemove," +
-		"       t.wrpricetype," +
-		"       t.buyorsell," +
-		"       t.deliverymonth," +
-		"       t.delistminqty," +
-		"       t.haswr," +
-		"       t.canbargain," +
-		"       t.canpart," +
-		"       t.marginflag," +
-		"       t.marginvalue," +
-		"       t.validtype," +
-		"       to_char(t.validtime, 'yyyy-mm-dd hh24:mi:ss') validtime," +
-		"       t.performancetemplateid," +
-		"       to_char(t.ordertime, 'yyyy-mm-dd hh24:mi:ss') ordertime," +
-		"       u.accountname as username," +
-		"       c.goodsid," +
-		"       c.goodscode," +
-		"       wd.minivalue," +
-		"       e.enumdicname," +
-		"       wd.wrstandardname || w.wrfactortypename2 WRTYPENAME," +
-		"       w.wrstandardid," +
-		"       w.deliverygoodsid," +
-		"       s.templatename," +
-		"       h.warehousename" +
-		"  from WRTRADE_ORDERDETAIL t" +
-		"  left join WRTRADE_GOODSCONFIG c" +
-		"    on t.wrtradeorderid = c.wrtradeorderid" +
-		"  left join Useraccount u" +
-		"    on t.userid = u.userid" +
-		"  left join wrfactortype w" +
-		"    on t.wrfactortypeid = w.wrfactortypeid" +
-		"  left join wrstandard wd" +
-		"    on w.wrstandardid = wd.wrstandardid" +
-		"  left join performanceplantemplate s on t.performancetemplateid=s.autoid" +
-		"  left join warehouseinfo h on w.warehouseid=h.autoid" +
-		"  left join enumdicitem e" +
-		"    on wd.unitid = e.enumitemname" +
-		"   and e.enumdiccode = 'goodsunit'" +
-		" where 1 = 1" +
-		"   and t.wrtradetype = 1" +
-		"   and t.wrtradeorderstatus in (3, 10)"
+	var sqlId utils.SQLVal = `
+select to_char(t.wrtradeorderid) wrtradeorderid,
+       to_char(t.wrfactortypeid) wrfactortypeid,
+       t.userid,
+       t.orderqty - t.tradeqty as qty,
+       t.fixedprice as price,
+       t.pricemove,
+       t.wrpricetype,
+       t.buyorsell,
+       t.deliverymonth,
+       t.delistminqty,
+       t.haswr,
+       t.canbargain,
+       t.canpart,
+       t.marginflag,
+       t.marginvalue,
+       t.validtype,
+       to_char(t.validtime, 'yyyy-mm-dd hh24:mi:ss') validtime,
+       t.performancetemplateid,
+       to_char(t.ordertime, 'yyyy-mm-dd hh24:mi:ss') ordertime,
+       u.accountname as username,
+       c.goodsid,
+       c.goodscode,
+       wd.minivalue,
+       wd.wrstandardname,
+       wd.wrstandardcode,
+       g.deliverygoodscode,
+       g.deliverygoodsname,
+       e.enumdicname,
+       wd.wrstandardname || w.wrfactortypename2 WRTYPENAME,
+       w.wrstandardid,
+       w.deliverygoodsid,
+       s.templatename,
+       h.warehousename
+  from WRTRADE_ORDERDETAIL t
+  left join WRTRADE_GOODSCONFIG c
+    on t.wrtradeorderid = c.wrtradeorderid
+  left join Useraccount u
+    on t.userid = u.userid
+  left join wrfactortype w
+    on t.wrfactortypeid = w.wrfactortypeid
+  left join wrstandard wd
+    on w.wrstandardid = wd.wrstandardid
+  left join performanceplantemplate s
+    on t.performancetemplateid = s.autoid
+  left join warehouseinfo h
+    on w.warehouseid = h.autoid
+  left join deliverygoods g on w.deliverygoodsid=g.deliverygoodsid
+  left join enumdicitem e
+    on wd.unitid = e.enumitemname
+   and e.enumdiccode = 'goodsunit'
+ where 1 = 1
+   and t.wrtradetype = 1
+   and t.isspecified=1
+   and t.wrtradeorderstatus in (3, 10)
+   and (t.userid=%v or
+   (t.allfriendsflag=1 and t.userid in(select frienduserid from userfriend where userid=%v)) 
+   or (t.allfriendsflag=0 and %v in(select k.matchuserid from wrtrade_matchdetail k where k.wrtradeorderid=t.wrtradeorderid))
+   )
+`
+	sqlId.FormatParam(r.USERID, r.USERID, r.USERID)
 	sqlId.And("t.haswr", r.HasWr)
 	r.WrPriceType = 1 // 查固定价
 	sqlId.And("t.wrpricetype", r.WrPriceType)