Sfoglia il codice sorgente

/Order/QueryTradePosition 增加自定义主键出参

zhou.xiaoning 2 anni fa
parent
commit
72c1bc4ff7

+ 6 - 6
config/config.xml

@@ -13,11 +13,11 @@
     <DbAddress value="192.168.31.88"/>
     <DbName value="orcl"/>
     <DbPort value="1521"/>
-    <DbUser value="mtp2_test171"/>
+    <DbUser value="mtp2_test204"/>
     <DbPwd value="muchinfo"/>
   </DbSetting>
   <RedisSetting>
-    <Address value="192.168.31.171"/>
+    <Address value="192.168.31.204"/>
     <Port value="5007"/>
     <Timeout value="3"/>
     <ConnNum value="1"/>
@@ -25,11 +25,11 @@
     <Pwd value=""/>
   </RedisSetting>
   <MqSetting>
-    <Url value="amqp://guest:guest@192.168.31.171:5020/test"/>
+    <Url value="amqp://guest:guest@192.168.31.204:5020/test"/>
     <Exchange value="entry"/>
   </MqSetting>
   <MongoDBSetting>
-    <HostName value="192.168.31.171"/>
+    <HostName value="192.168.31.204"/>
     <Port value="5025"/>
     <DBName value="HistoryQuote"/>
     <Username value="quote_test01"/>
@@ -38,8 +38,8 @@
   <MySQLSetting>
     <Host value="192.168.30.72"/>
     <Port value="3306"/>
-    <DBName value="historyquote_test171"/>
-    <Username value="quote_test171"/>
+    <DBName value="historyquote_test204"/>
+    <Username value="quote_test204"/>
     <Password value="123456"/>
   </MySQLSetting>
 </Configuration>

+ 4 - 4
controllers/guangzuan/tradeService.go

@@ -18,8 +18,8 @@ import (
 // @Security Group
 // @Param    userid   query    int    true  "用户ID"
 // @Param    executestatus query    int false "执行状态 - 1:未生效 2:进行中 3:已结束"
-// @Param    page          query    int false "页码"
-// @Param    pagesize      query    int false "每页条数"
+// @Param    page     query    int    false "页码"
+// @Param    pagesize query    int    false "每页条数"
 // @Success  200           {array}  models.GzcjjcorderM
 // @Failure  500     {object} app.Response
 // @Router   /Guangzuan/QueryGZCJJCOrder [get]
@@ -39,8 +39,8 @@ func QueryGZCJJCOrder(c *gin.Context) {
 // @Security Group
 // @Param    userid        query    int true  "用户ID"
 // @Param    orderid  query    string false "单据ID"
-// @Param    page     query    int    false "页码"
-// @Param    pagesize query    int    false "每页条数"
+// @Param    page          query    int false "页码"
+// @Param    pagesize      query    int false "每页条数"
 // @Success  200      {array}  models.GzcjjcorderdetailM
 // @Failure  500           {object} app.Response
 // @Router   /Guangzuan/QueryGZCJJCOrderDetail [get]

+ 7 - 0
controllers/order/order.go

@@ -83,6 +83,8 @@ type QueryTradePositionRsp struct {
 	REFGOODSID      int32   `json:"refgoodsid"  xorm:"'REFGOODSID'"`              // 参考商品ID
 	REFGOODSCODE    string  `json:"refgoodscode"  xorm:"'REFGOODSCODE'"`          // 参考商品代码
 	MatchName       string  `json:"matchname"  xorm:"'MATCHNAME'"`                // ProviderUserID 企业名称
+
+	PKID string `json:"pkid" xorm:"-"` // 自定义主键
 }
 
 // QueryTradePosition 持仓汇总查询(合约市场)
@@ -234,6 +236,8 @@ func GetTradePosition(accIds string, tradeModes string) (rst []QueryTradePositio
 					tradePosition.PositionPLRate, _ = strconv.ParseFloat(utils.FormatFloat(tradePosition.PositionPLRate, 4), 64)
 				}
 
+				tradePosition.PKID = fmt.Sprintf("%v_%v_%v", tradePosition.AccountID, tradePosition.Goodsid, tradePosition.BuyOrSell)
+
 				rst = append(rst, tradePosition)
 			}
 		}
@@ -276,6 +280,9 @@ func GetTradePosition(accIds string, tradeModes string) (rst []QueryTradePositio
 					tradePosition.PositionPLRate = tradePosition.PositionPL / tradePosition.CurHolderAmount
 					tradePosition.PositionPLRate, _ = strconv.ParseFloat(utils.FormatFloat(tradePosition.PositionPLRate, 4), 64)
 				}
+
+				tradePosition.PKID = fmt.Sprintf("%v_%v_%v", tradePosition.AccountID, tradePosition.Goodsid, tradePosition.BuyOrSell)
+
 				rst = append(rst, tradePosition)
 			}
 		}

+ 4 - 0
docs/docs.go

@@ -59093,6 +59093,10 @@ const docTemplate = `{
                     "description": "持仓其他冻结数量(交割冻结)",
                     "type": "number"
                 },
+                "pkid": {
+                    "description": "自定义主键",
+                    "type": "string"
+                },
                 "positionpl": {
                     "description": "持仓盈亏 买方向 = (最新价 - 持仓均价) * 买期末头寸 * 合约单位;卖方向 = (持仓均价 - 最新价) * 卖期末头寸 * 合约单位",
                     "type": "number"

+ 4 - 0
docs/swagger.json

@@ -59084,6 +59084,10 @@
                     "description": "持仓其他冻结数量(交割冻结)",
                     "type": "number"
                 },
+                "pkid": {
+                    "description": "自定义主键",
+                    "type": "string"
+                },
                 "positionpl": {
                     "description": "持仓盈亏 买方向 = (最新价 - 持仓均价) * 买期末头寸 * 合约单位;卖方向 = (持仓均价 - 最新价) * 卖期末头寸 * 合约单位",
                     "type": "number"

+ 3 - 0
docs/swagger.yaml

@@ -27977,6 +27977,9 @@ definitions:
       otherfrozenqty:
         description: 持仓其他冻结数量(交割冻结)
         type: number
+      pkid:
+        description: 自定义主键
+        type: string
       positionpl:
         description: 持仓盈亏 买方向 = (最新价 - 持仓均价) * 买期末头寸 * 合约单位;卖方向 = (持仓均价 - 最新价) * 卖期末头寸
           * 合约单位

+ 11 - 2
models/common.go

@@ -1330,8 +1330,17 @@ func GetJ10News(limit int) (datas []GetJ10NewsRsp, err error) {
 		b := a[:len(a)-1]
 
 		err = json.Unmarshal([]byte(b), &datas)
-		if len(datas) > limit {
-			datas = datas[:limit]
+
+		// 去掉<打头的记录,以及空的记录
+		r := make([]GetJ10NewsRsp, 0)
+		for _, item := range datas {
+			if item.Data.Content != "" && item.Data.Content[0] != []byte("<")[0] {
+				r = append(r, item)
+			}
+		}
+
+		if len(r) > limit {
+			datas = r[:limit]
 		}
 	}