Simon Zhou 5 년 전
부모
커밋
c261adc08f
4개의 변경된 파일38개의 추가작업 그리고 5개의 파일을 삭제
  1. 22 3
      controllers/szdz/szdz.go
  2. 6 1
      docs/docs.go
  3. 6 1
      docs/swagger.json
  4. 4 0
      docs/swagger.yaml

+ 22 - 3
controllers/szdz/szdz.go

@@ -17,9 +17,9 @@ import (
 type QueryRecieptOrderReq struct {
 	app.PageInfo
 	GoodsID     int    `form:"goodsID" binding:"required"` // 商品ID,必填
+	BuyOrSell   int    `form:"buyorsell"`                  // 方向
 	AccountName string `form:"accountName"`                // 所属账户名称
 	MarketID    int    `form:"marketID"`                   // 市场ID
-	BuyOrSell   int    `form:"buyorsell"`                  // 方向
 }
 
 // QueryRecieptOrderRsp 点选挂牌委托单据查询返回模型
@@ -33,6 +33,7 @@ type QueryRecieptOrderRsp struct {
 	Orderprice  float64 `json:"orderprice"  xorm:"'ORDERPRICE'"` // 委托价格
 	EnableQty   int64   `json:"enableqty" xorm:"ENABLEQTY"`      // 可摘数量
 	AccountName string  `json:"accountName" xorm:"ACCOUNTNAME"`  // 所属账号名称(已脱敏)
+	AccountID   int64   `json:"accountid" xorm:"ACCOUNTID"`      // 资金账号
 }
 
 // QueryRecieptOrder 点选挂牌委托单据查询(摘牌大厅)
@@ -45,7 +46,7 @@ type QueryRecieptOrderRsp struct {
 // @Param goodsID query int true "商品ID"
 // @Param accountName query string false "所属账户名称"
 // @Param marketID query int false "市场ID"
-// @Param buyorsell query int false "方向 - 0:买 1:卖"
+// @Param buyorsell query int true "方向 - 0:买 1:卖"
 // @Success 200 {object} QueryRecieptOrderRsp
 // @Failure 500 {object} app.Response
 // @Router /SZDZ/QueryRecieptOrder [get]
@@ -56,7 +57,6 @@ func QueryRecieptOrder(c *gin.Context) {
 
 	// 获取请求参数
 	var req QueryRecieptOrderReq
-	req.BuyOrSell = -1 // 买方向值为0,所以要初始赋值
 	if err := appG.C.ShouldBindQuery(&req); err != nil {
 		logger.GetLogger().Errorf("QueryRecieptOrder failed: %s", err.Error())
 		appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
@@ -118,6 +118,25 @@ func QueryRecieptOrder(c *gin.Context) {
 	}
 	datas = append(datas, d2...)
 
+	// 过滤相关账号下非买一卖一的单据(如买一卖一有多张单则都要显示)
+	// 先按价格倒序排列
+	sort.Slice(datas, func(i int, j int) bool {
+		return datas[i].Orderprice > datas[j].Orderprice
+	})
+	tmpDatas := make([]QueryRecieptOrderRsp, 0)
+	for _, v := range datas {
+		needAdd := true
+		for _, t := range tmpDatas {
+			if t.AccountID == v.AccountID && t.Buyorsell == v.Buyorsell && t.Orderprice > v.Orderprice {
+				needAdd = false
+			}
+		}
+		if needAdd {
+			tmpDatas = append(tmpDatas, v)
+		}
+	}
+	datas = tmpDatas
+
 	total := len(datas)
 	// FIXME: - 排序 & 分页
 	// 排序

+ 6 - 1
docs/docs.go

@@ -1196,7 +1196,8 @@ var doc = `{
                         "type": "integer",
                         "description": "方向 - 0:买 1:卖",
                         "name": "buyorsell",
-                        "in": "query"
+                        "in": "query",
+                        "required": true
                     }
                 ],
                 "responses": {
@@ -4808,6 +4809,10 @@ var doc = `{
                     "description": "所属账号名称(已脱敏)",
                     "type": "string"
                 },
+                "accountid": {
+                    "description": "资金账号",
+                    "type": "integer"
+                },
                 "buyorsell": {
                     "description": "方向 - 0:买 1:卖",
                     "type": "integer"

+ 6 - 1
docs/swagger.json

@@ -1180,7 +1180,8 @@
                         "type": "integer",
                         "description": "方向 - 0:买 1:卖",
                         "name": "buyorsell",
-                        "in": "query"
+                        "in": "query",
+                        "required": true
                     }
                 ],
                 "responses": {
@@ -4792,6 +4793,10 @@
                     "description": "所属账号名称(已脱敏)",
                     "type": "string"
                 },
+                "accountid": {
+                    "description": "资金账号",
+                    "type": "integer"
+                },
                 "buyorsell": {
                     "description": "方向 - 0:买 1:卖",
                     "type": "integer"

+ 4 - 0
docs/swagger.yaml

@@ -2456,6 +2456,9 @@ definitions:
       accountName:
         description: 所属账号名称(已脱敏)
         type: string
+      accountid:
+        description: 资金账号
+        type: integer
       buyorsell:
         description: 方向 - 0:买 1:卖
         type: integer
@@ -3395,6 +3398,7 @@ paths:
       - description: 方向 - 0:买 1:卖
         in: query
         name: buyorsell
+        required: true
         type: integer
       produces:
       - application/json