瀏覽代碼

1、企业风管委托单增加母账户记录;
2、历史数据增加1小时、4小时、周和年周期数据;修改Tik数据查询报错的问题。

zhou.xiaoning 4 年之前
父節點
當前提交
c633fcc008
共有 6 個文件被更改,包括 297 次插入539 次删除
  1. 31 6
      controllers/ermcp/qryOrder.go
  2. 9 169
      docs/docs.go
  3. 9 169
      docs/swagger.json
  4. 9 130
      docs/swagger.yaml
  5. 226 64
      models/ermcpOrder.go
  6. 13 1
      models/quote.go

+ 31 - 6
controllers/ermcp/qryOrder.go

@@ -459,11 +459,11 @@ func QueryErmcpTradePosition(c *gin.Context) {
 				// 持仓均价 = 持仓成本 / 期末头寸 / 合约单位
 				item.PositionAveragePrice = v.Sellcurholderamount / float64(v.Sellcurpositionqty) / goods.Agreeunit
 				item.PositionAveragePrice, _ = strconv.ParseFloat(utils.FormatFloat(item.PositionAveragePrice, int(goods.Decimalplace)), 64)
-				// 盯市浮盈(MTP:浮动盈亏、持仓盈亏) 卖方向 = (持仓均价 - 最新价) * 期末头寸 * 合约单位
+				// 盯市浮盈(MTP:浮动盈亏、持仓盈亏) 卖方向 = (持仓均价 - 最新价) * 期末头寸 * 合约单位
 				if item.Last != 0 {
 					item.PositionPL = (item.PositionAveragePrice - item.Last) * float64(v.Sellcurpositionqty) * goods.Agreeunit
 				}
-				// 逐笔浮盈(MTP:开仓盈亏、平仓盈亏)卖方向 = (开仓均价 - 最新价) * 期末头寸 * 合约单位
+				// 逐笔浮盈(MTP:开仓盈亏、平仓盈亏)卖方向 = (开仓均价 - 最新价) * 期末头寸 * 合约单位
 				if item.Last != 0 {
 					item.OpenPL = (item.OpenAveragePrice - item.Last) * float64(v.Sellcurpositionqty) * goods.Agreeunit
 				}
@@ -493,7 +493,7 @@ type QueryErmcpOrderDetailsReq struct {
 // @Produce json
 // @Security ApiKeyAuth
 // @Param accountID query int true "资金账户ID"
-// @Success 200 {object} models.QueryHedgeInnerOrderDetailRsp
+// @Success 200 {object} models.QueryHedgeOrderDetailRsp
 // @Failure 500 {object} app.Response
 // @Router /Ermcp/QueryErmcpOrderDetails [get]
 // @Tags 企业风险管理(app)
@@ -508,14 +508,39 @@ func QueryErmcpOrderDetails(c *gin.Context) {
 		return
 	}
 
-	// 获取数据
-	rst, err := models.GetHedgeInnerOrderDetails(req.AccountID)
+	// 获取资金账户信息
+	taAccount, err := models.GetTaAccountByID(req.AccountID)
 	if err != nil {
-		// 查询失败
 		logger.GetLogger().Errorf("QueryErmcpOrderDetails failed: %s", err.Error())
 		appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
 		return
 	}
+	if taAccount == nil {
+		logger.GetLogger().Errorf("QueryErmcpOrderDetails failed")
+		appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
+		return
+	}
+
+	rst := make([]models.QueryHedgeOrderDetailRsp, 0)
+	if taAccount.Ismain == 1 {
+		// 母账户 -> 外部委托单
+		rst, err = models.GetHedgeOutOrderDetails(req.AccountID)
+		if err != nil {
+			// 查询失败
+			logger.GetLogger().Errorf("QueryErmcpOrderDetails failed: %s", err.Error())
+			appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
+			return
+		}
+	} else {
+		// 子账户 -> 内部委托单
+		rst, err = models.GetHedgeInnerOrderDetails(req.AccountID)
+		if err != nil {
+			// 查询失败
+			logger.GetLogger().Errorf("QueryErmcpOrderDetails failed: %s", err.Error())
+			appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
+			return
+		}
+	}
 
 	// 查询成功返回
 	logger.GetLogger().Debugln("QueryErmcpOrderDetails successed: %v", rst)

+ 9 - 169
docs/docs.go

@@ -1684,7 +1684,7 @@ var doc = `{
                     "200": {
                         "description": "OK",
                         "schema": {
-                            "$ref": "#/definitions/models.QueryHedgeInnerOrderDetailRsp"
+                            "$ref": "#/definitions/models.QueryHedgeOrderDetailRsp"
                         }
                     },
                     "500": {
@@ -14388,17 +14388,9 @@ var doc = `{
                 }
             }
         },
-        "models.QueryHedgeInnerOrderDetailRsp": {
+        "models.QueryHedgeOrderDetailRsp": {
             "type": "object",
-            "required": [
-                "goodscode",
-                "goodsname"
-            ],
             "properties": {
-                "accountcurrencyid": {
-                    "description": "账户币种ID",
-                    "type": "integer"
-                },
                 "accountid": {
                     "description": "账户ID",
                     "type": "integer"
@@ -14412,57 +14404,13 @@ var doc = `{
                     "type": "integer"
                 },
                 "channelinnerorderstatus": {
-                    "description": "委托状态 - 1:委托请求 2:冻结成功 3:委托失败 4:委托部成部失败                  5:委托成功 6:全部撤销 7:部成部撤 8:部成部撤部失败 9:全部成交",
+                    "description": "委托状态 - 1:委托请求 2:冻结成功 3:委托失败 4:委托部成部失败 5:委托成功 6:全部撤销 7:部成部撤 8:部成部撤部失败 9:全部成交",
                     "type": "integer"
                 },
                 "channeloperatetype": {
                     "description": "操作类型 - 1:正常委托 2:斩仓委托 3:强平委托",
                     "type": "integer"
                 },
-                "channelordersrc": {
-                    "description": "委托来源 -  1:客户端 2:风控服务 3:管理端 4:下单接口平台 5:交易服务 6:跟单服务 7:监控终端",
-                    "type": "integer"
-                },
-                "clientordertime": {
-                    "description": "客户端委托时间",
-                    "type": "string"
-                },
-                "clientticket": {
-                    "description": "客户端流水号",
-                    "type": "string"
-                },
-                "clienttype": {
-                    "description": "客户端类型 - 0:保留为未填终端类型 1:PC管理端 2:PC交易端 3:手机客户端_安卓 4:网页客户端 5:微信客户端 6:手机客户端_苹果 7:网上开户客户端 8:无效终端编号 9:报价终端(中江) 10;监控终端",
-                    "type": "integer"
-                },
-                "closecancelqty": {
-                    "description": "撤单数量",
-                    "type": "integer"
-                },
-                "closechargevalue": {
-                    "description": "平仓手续费设置值",
-                    "type": "number"
-                },
-                "closefailqty": {
-                    "description": "失败数量",
-                    "type": "integer"
-                },
-                "closefeealgorithm": {
-                    "description": "平仓手续费收取方式 1:比率  2:固定",
-                    "type": "integer"
-                },
-                "closeorderqty": {
-                    "description": "委托数量",
-                    "type": "integer"
-                },
-                "closesuccessqty": {
-                    "description": "委托成功数量",
-                    "type": "integer"
-                },
-                "closetradeqty": {
-                    "description": "成交数量",
-                    "type": "integer"
-                },
                 "closetype": {
                     "description": "平仓方式 - 0:无 1:平今 2:平昨",
                     "type": "integer"
@@ -14479,10 +14427,6 @@ var doc = `{
                     "description": "商品代码(内部)",
                     "type": "string"
                 },
-                "goodscurrencyid": {
-                    "description": "商品币种ID",
-                    "type": "integer"
-                },
                 "goodsid": {
                     "description": "商品ID",
                     "type": "integer"
@@ -14491,98 +14435,14 @@ var doc = `{
                     "description": "商品名称",
                     "type": "string"
                 },
-                "goodsorderprice": {
-                    "description": "委托价格(商品)",
-                    "type": "number"
-                },
-                "hedgeflag": {
-                    "description": "投机套保标志 - 0:无 1:投机 2:套保 3:套利",
-                    "type": "integer"
-                },
-                "marginalgorithm": {
-                    "description": "保证金收取方式  1:比率  2:固定",
-                    "type": "integer"
-                },
-                "margincurrencyid": {
-                    "description": "保证金币种ID 比率时等于账户币种",
-                    "type": "integer"
-                },
-                "marginrate": {
-                    "description": "保证金汇率-比率时等于1",
-                    "type": "number"
-                },
-                "marginvalue": {
-                    "description": "即市保证金设置值",
-                    "type": "number"
-                },
                 "marketid": {
                     "description": "市场ID",
                     "type": "integer"
                 },
-                "opencancelqty": {
-                    "description": "撤单数量",
-                    "type": "integer"
-                },
-                "openchargevalue": {
-                    "description": "建仓手续费设置值",
-                    "type": "number"
-                },
-                "openfailqty": {
-                    "description": "失败数量",
-                    "type": "integer"
-                },
-                "openfeealgorithm": {
-                    "description": "建仓手续费收取方式  1:比率  2:固定",
-                    "type": "integer"
-                },
-                "openfreezecharge": {
-                    "description": "建仓冻结手续费(账户)",
-                    "type": "number"
-                },
-                "openfreezecharge2": {
-                    "description": "建仓冻结手续费(商品)",
-                    "type": "number"
-                },
                 "openfreezemargin": {
                     "description": "冻结保证金(冻结交易金额)",
                     "type": "number"
                 },
-                "openfreezemargin2": {
-                    "description": "建仓冻结保证金(保证金/商品)",
-                    "type": "number"
-                },
-                "openorderqty": {
-                    "description": "委托数量",
-                    "type": "integer"
-                },
-                "opensuccessqty": {
-                    "description": "建仓委托成功数量",
-                    "type": "integer"
-                },
-                "opentradeqty": {
-                    "description": "成交数量",
-                    "type": "integer"
-                },
-                "openunfreezecharge": {
-                    "description": "建仓解冻手续费(账户)",
-                    "type": "number"
-                },
-                "openunfreezecharge2": {
-                    "description": "建仓解冻手续费(商品)",
-                    "type": "number"
-                },
-                "openunfreezemargin": {
-                    "description": "解冻保证金",
-                    "type": "number"
-                },
-                "openunfreezemargin2": {
-                    "description": "建仓解冻保证金(保证金/商品)",
-                    "type": "number"
-                },
-                "operatorid": {
-                    "description": "登录账号(LoginID)",
-                    "type": "integer"
-                },
                 "orderid": {
                     "description": "委托单号(107+Unix秒时间戳(10位)+2位(MarketServiceID)+xxxx)",
                     "type": "string"
@@ -14591,44 +14451,24 @@ var doc = `{
                     "description": "委托价格(账户)",
                     "type": "number"
                 },
+                "orderqty": {
+                    "description": "委托数量",
+                    "type": "integer"
+                },
                 "ordertime": {
                     "description": "委托时间",
                     "type": "string"
                 },
-                "parentaccountid": {
-                    "description": "所属母账户",
-                    "type": "integer"
-                },
                 "pricemode": {
                     "description": "取价方式 - 1:市价 2: 限价",
                     "type": "integer"
                 },
-                "retcode": {
-                    "description": "错误代码",
-                    "type": "integer"
-                },
-                "sessionid": {
-                    "description": "会话ID",
-                    "type": "integer"
-                },
                 "tradedate": {
                     "description": "交易日(yyyyMMdd)",
                     "type": "string"
                 },
-                "updatetime": {
-                    "description": "更新时间",
-                    "type": "string"
-                },
-                "uuid": {
-                    "description": "发起端唯一id",
-                    "type": "string"
-                },
-                "validtime": {
-                    "description": "有效期限",
-                    "type": "string"
-                },
-                "validtype": {
-                    "description": "有效类型 - 1当日有效",
+                "tradeqty": {
+                    "description": "成交数量",
                     "type": "integer"
                 }
             }

+ 9 - 169
docs/swagger.json

@@ -1668,7 +1668,7 @@
                     "200": {
                         "description": "OK",
                         "schema": {
-                            "$ref": "#/definitions/models.QueryHedgeInnerOrderDetailRsp"
+                            "$ref": "#/definitions/models.QueryHedgeOrderDetailRsp"
                         }
                     },
                     "500": {
@@ -14372,17 +14372,9 @@
                 }
             }
         },
-        "models.QueryHedgeInnerOrderDetailRsp": {
+        "models.QueryHedgeOrderDetailRsp": {
             "type": "object",
-            "required": [
-                "goodscode",
-                "goodsname"
-            ],
             "properties": {
-                "accountcurrencyid": {
-                    "description": "账户币种ID",
-                    "type": "integer"
-                },
                 "accountid": {
                     "description": "账户ID",
                     "type": "integer"
@@ -14396,57 +14388,13 @@
                     "type": "integer"
                 },
                 "channelinnerorderstatus": {
-                    "description": "委托状态 - 1:委托请求 2:冻结成功 3:委托失败 4:委托部成部失败                  5:委托成功 6:全部撤销 7:部成部撤 8:部成部撤部失败 9:全部成交",
+                    "description": "委托状态 - 1:委托请求 2:冻结成功 3:委托失败 4:委托部成部失败 5:委托成功 6:全部撤销 7:部成部撤 8:部成部撤部失败 9:全部成交",
                     "type": "integer"
                 },
                 "channeloperatetype": {
                     "description": "操作类型 - 1:正常委托 2:斩仓委托 3:强平委托",
                     "type": "integer"
                 },
-                "channelordersrc": {
-                    "description": "委托来源 -  1:客户端 2:风控服务 3:管理端 4:下单接口平台 5:交易服务 6:跟单服务 7:监控终端",
-                    "type": "integer"
-                },
-                "clientordertime": {
-                    "description": "客户端委托时间",
-                    "type": "string"
-                },
-                "clientticket": {
-                    "description": "客户端流水号",
-                    "type": "string"
-                },
-                "clienttype": {
-                    "description": "客户端类型 - 0:保留为未填终端类型 1:PC管理端 2:PC交易端 3:手机客户端_安卓 4:网页客户端 5:微信客户端 6:手机客户端_苹果 7:网上开户客户端 8:无效终端编号 9:报价终端(中江) 10;监控终端",
-                    "type": "integer"
-                },
-                "closecancelqty": {
-                    "description": "撤单数量",
-                    "type": "integer"
-                },
-                "closechargevalue": {
-                    "description": "平仓手续费设置值",
-                    "type": "number"
-                },
-                "closefailqty": {
-                    "description": "失败数量",
-                    "type": "integer"
-                },
-                "closefeealgorithm": {
-                    "description": "平仓手续费收取方式 1:比率  2:固定",
-                    "type": "integer"
-                },
-                "closeorderqty": {
-                    "description": "委托数量",
-                    "type": "integer"
-                },
-                "closesuccessqty": {
-                    "description": "委托成功数量",
-                    "type": "integer"
-                },
-                "closetradeqty": {
-                    "description": "成交数量",
-                    "type": "integer"
-                },
                 "closetype": {
                     "description": "平仓方式 - 0:无 1:平今 2:平昨",
                     "type": "integer"
@@ -14463,10 +14411,6 @@
                     "description": "商品代码(内部)",
                     "type": "string"
                 },
-                "goodscurrencyid": {
-                    "description": "商品币种ID",
-                    "type": "integer"
-                },
                 "goodsid": {
                     "description": "商品ID",
                     "type": "integer"
@@ -14475,98 +14419,14 @@
                     "description": "商品名称",
                     "type": "string"
                 },
-                "goodsorderprice": {
-                    "description": "委托价格(商品)",
-                    "type": "number"
-                },
-                "hedgeflag": {
-                    "description": "投机套保标志 - 0:无 1:投机 2:套保 3:套利",
-                    "type": "integer"
-                },
-                "marginalgorithm": {
-                    "description": "保证金收取方式  1:比率  2:固定",
-                    "type": "integer"
-                },
-                "margincurrencyid": {
-                    "description": "保证金币种ID 比率时等于账户币种",
-                    "type": "integer"
-                },
-                "marginrate": {
-                    "description": "保证金汇率-比率时等于1",
-                    "type": "number"
-                },
-                "marginvalue": {
-                    "description": "即市保证金设置值",
-                    "type": "number"
-                },
                 "marketid": {
                     "description": "市场ID",
                     "type": "integer"
                 },
-                "opencancelqty": {
-                    "description": "撤单数量",
-                    "type": "integer"
-                },
-                "openchargevalue": {
-                    "description": "建仓手续费设置值",
-                    "type": "number"
-                },
-                "openfailqty": {
-                    "description": "失败数量",
-                    "type": "integer"
-                },
-                "openfeealgorithm": {
-                    "description": "建仓手续费收取方式  1:比率  2:固定",
-                    "type": "integer"
-                },
-                "openfreezecharge": {
-                    "description": "建仓冻结手续费(账户)",
-                    "type": "number"
-                },
-                "openfreezecharge2": {
-                    "description": "建仓冻结手续费(商品)",
-                    "type": "number"
-                },
                 "openfreezemargin": {
                     "description": "冻结保证金(冻结交易金额)",
                     "type": "number"
                 },
-                "openfreezemargin2": {
-                    "description": "建仓冻结保证金(保证金/商品)",
-                    "type": "number"
-                },
-                "openorderqty": {
-                    "description": "委托数量",
-                    "type": "integer"
-                },
-                "opensuccessqty": {
-                    "description": "建仓委托成功数量",
-                    "type": "integer"
-                },
-                "opentradeqty": {
-                    "description": "成交数量",
-                    "type": "integer"
-                },
-                "openunfreezecharge": {
-                    "description": "建仓解冻手续费(账户)",
-                    "type": "number"
-                },
-                "openunfreezecharge2": {
-                    "description": "建仓解冻手续费(商品)",
-                    "type": "number"
-                },
-                "openunfreezemargin": {
-                    "description": "解冻保证金",
-                    "type": "number"
-                },
-                "openunfreezemargin2": {
-                    "description": "建仓解冻保证金(保证金/商品)",
-                    "type": "number"
-                },
-                "operatorid": {
-                    "description": "登录账号(LoginID)",
-                    "type": "integer"
-                },
                 "orderid": {
                     "description": "委托单号(107+Unix秒时间戳(10位)+2位(MarketServiceID)+xxxx)",
                     "type": "string"
@@ -14575,44 +14435,24 @@
                     "description": "委托价格(账户)",
                     "type": "number"
                 },
+                "orderqty": {
+                    "description": "委托数量",
+                    "type": "integer"
+                },
                 "ordertime": {
                     "description": "委托时间",
                     "type": "string"
                 },
-                "parentaccountid": {
-                    "description": "所属母账户",
-                    "type": "integer"
-                },
                 "pricemode": {
                     "description": "取价方式 - 1:市价 2: 限价",
                     "type": "integer"
                 },
-                "retcode": {
-                    "description": "错误代码",
-                    "type": "integer"
-                },
-                "sessionid": {
-                    "description": "会话ID",
-                    "type": "integer"
-                },
                 "tradedate": {
                     "description": "交易日(yyyyMMdd)",
                     "type": "string"
                 },
-                "updatetime": {
-                    "description": "更新时间",
-                    "type": "string"
-                },
-                "uuid": {
-                    "description": "发起端唯一id",
-                    "type": "string"
-                },
-                "validtime": {
-                    "description": "有效期限",
-                    "type": "string"
-                },
-                "validtype": {
-                    "description": "有效类型 - 1当日有效",
+                "tradeqty": {
+                    "description": "成交数量",
                     "type": "integer"
                 }
             }

+ 9 - 130
docs/swagger.yaml

@@ -6177,11 +6177,8 @@ definitions:
     required:
     - errorid
     type: object
-  models.QueryHedgeInnerOrderDetailRsp:
+  models.QueryHedgeOrderDetailRsp:
     properties:
-      accountcurrencyid:
-        description: 账户币种ID
-        type: integer
       accountid:
         description: 账户ID
         type: integer
@@ -6192,46 +6189,12 @@ definitions:
         description: 开平标志 - 0:无 1:建仓 2:平仓
         type: integer
       channelinnerorderstatus:
-        description: 委托状态 - 1:委托请求 2:冻结成功 3:委托失败 4:委托部成部失败                  5:委托成功
-          6:全部撤销 7:部成部撤 8:部成部撤部失败 9:全部成交
+        description: 委托状态 - 1:委托请求 2:冻结成功 3:委托失败 4:委托部成部失败 5:委托成功 6:全部撤销 7:部成部撤 8:部成部撤部失败
+          9:全部成交
         type: integer
       channeloperatetype:
         description: 操作类型 - 1:正常委托 2:斩仓委托 3:强平委托
         type: integer
-      channelordersrc:
-        description: 委托来源 -  1:客户端 2:风控服务 3:管理端 4:下单接口平台 5:交易服务 6:跟单服务 7:监控终端
-        type: integer
-      clientordertime:
-        description: 客户端委托时间
-        type: string
-      clientticket:
-        description: 客户端流水号
-        type: string
-      clienttype:
-        description: 客户端类型 - 0:保留为未填终端类型 1:PC管理端 2:PC交易端 3:手机客户端_安卓 4:网页客户端 5:微信客户端
-          6:手机客户端_苹果 7:网上开户客户端 8:无效终端编号 9:报价终端(中江) 10;监控终端
-        type: integer
-      closecancelqty:
-        description: 撤单数量
-        type: integer
-      closechargevalue:
-        description: 平仓手续费设置值
-        type: number
-      closefailqty:
-        description: 失败数量
-        type: integer
-      closefeealgorithm:
-        description: 平仓手续费收取方式 1:比率  2:固定
-        type: integer
-      closeorderqty:
-        description: 委托数量
-        type: integer
-      closesuccessqty:
-        description: 委托成功数量
-        type: integer
-      closetradeqty:
-        description: 成交数量
-        type: integer
       closetype:
         description: 平仓方式 - 0:无 1:平今 2:平昨
         type: integer
@@ -6244,123 +6207,39 @@ definitions:
       goodscode:
         description: 商品代码(内部)
         type: string
-      goodscurrencyid:
-        description: 商品币种ID
-        type: integer
       goodsid:
         description: 商品ID
         type: integer
       goodsname:
         description: 商品名称
         type: string
-      goodsorderprice:
-        description: 委托价格(商品)
-        type: number
-      hedgeflag:
-        description: 投机套保标志 - 0:无 1:投机 2:套保 3:套利
-        type: integer
-      marginalgorithm:
-        description: 保证金收取方式  1:比率  2:固定
-        type: integer
-      margincurrencyid:
-        description: 保证金币种ID 比率时等于账户币种
-        type: integer
-      marginrate:
-        description: 保证金汇率-比率时等于1
-        type: number
-      marginvalue:
-        description: 即市保证金设置值
-        type: number
       marketid:
         description: 市场ID
         type: integer
-      opencancelqty:
-        description: 撤单数量
-        type: integer
-      openchargevalue:
-        description: 建仓手续费设置值
-        type: number
-      openfailqty:
-        description: 失败数量
-        type: integer
-      openfeealgorithm:
-        description: 建仓手续费收取方式  1:比率  2:固定
-        type: integer
-      openfreezecharge:
-        description: 建仓冻结手续费(账户)
-        type: number
-      openfreezecharge2:
-        description: 建仓冻结手续费(商品)
-        type: number
       openfreezemargin:
         description: 冻结保证金(冻结交易金额)
         type: number
-      openfreezemargin2:
-        description: 建仓冻结保证金(保证金/商品)
-        type: number
-      openorderqty:
-        description: 委托数量
-        type: integer
-      opensuccessqty:
-        description: 建仓委托成功数量
-        type: integer
-      opentradeqty:
-        description: 成交数量
-        type: integer
-      openunfreezecharge:
-        description: 建仓解冻手续费(账户)
-        type: number
-      openunfreezecharge2:
-        description: 建仓解冻手续费(商品)
-        type: number
-      openunfreezemargin:
-        description: 解冻保证金
-        type: number
-      openunfreezemargin2:
-        description: 建仓解冻保证金(保证金/商品)
-        type: number
-      operatorid:
-        description: 登录账号(LoginID)
-        type: integer
       orderid:
         description: 委托单号(107+Unix秒时间戳(10位)+2位(MarketServiceID)+xxxx)
         type: string
       orderprice:
         description: 委托价格(账户)
         type: number
+      orderqty:
+        description: 委托数量
+        type: integer
       ordertime:
         description: 委托时间
         type: string
-      parentaccountid:
-        description: 所属母账户
-        type: integer
       pricemode:
         description: '取价方式 - 1:市价 2: 限价'
         type: integer
-      retcode:
-        description: 错误代码
-        type: integer
-      sessionid:
-        description: 会话ID
-        type: integer
       tradedate:
         description: 交易日(yyyyMMdd)
         type: string
-      updatetime:
-        description: 更新时间
-        type: string
-      uuid:
-        description: 发起端唯一id
-        type: string
-      validtime:
-        description: 有效期限
-        type: string
-      validtype:
-        description: 有效类型 - 1当日有效
+      tradeqty:
+        description: 成交数量
         type: integer
-    required:
-    - goodscode
-    - goodsname
     type: object
   models.QuotePrimaryMenu:
     properties:
@@ -9964,7 +9843,7 @@ paths:
         "200":
           description: OK
           schema:
-            $ref: '#/definitions/models.QueryHedgeInnerOrderDetailRsp'
+            $ref: '#/definitions/models.QueryHedgeOrderDetailRsp'
         "500":
           description: Internal Server Error
           schema:

+ 226 - 64
models/ermcpOrder.go

@@ -285,76 +285,101 @@ func GetHedgeInnerHolderDetails(goodsID, buyOrSell int) ([]Hedgeinnerholderdetai
 	return hedgeInnerHolderDetails, nil
 }
 
-// QueryHedgeInnerOrderDetailRsp 企业风管内部委托单查询返回模型
-type QueryHedgeInnerOrderDetailRsp struct {
-	Orderid                 string    `json:"orderid"  xorm:"'ORDERIDSTR'"`                              // 委托单号(107+Unix秒时间戳(10位)+2位(MarketServiceID)+xxxx)
-	Tradedate               string    `json:"tradedate"  xorm:"'TRADEDATE'"`                             // 交易日(yyyyMMdd)
-	Channelbuildtype        int32     `json:"channelbuildtype"  xorm:"'CHANNELBUILDTYPE'"`               // 开平标志 - 0:无 1:建仓 2:平仓
-	Closetype               int32     `json:"closetype"  xorm:"'CLOSETYPE'"`                             // 平仓方式 - 0:无 1:平今 2:平昨
-	Hedgeflag               int32     `json:"hedgeflag"  xorm:"'HEDGEFLAG'"`                             // 投机套保标志 - 0:无 1:投机 2:套保 3:套利
-	Marketid                int32     `json:"marketid"  xorm:"'MARKETID'"`                               // 市场ID
-	Goodsid                 int32     `json:"goodsid"  xorm:"'GOODSID'"`                                 // 商品ID
-	Accountid               int64     `json:"accountid"  xorm:"'ACCOUNTID'"`                             // 账户ID
-	Buyorsell               int32     `json:"buyorsell"  xorm:"'BUYORSELL'"`                             // 买卖 - 0:买 1:卖
-	Pricemode               int32     `json:"pricemode"  xorm:"'PRICEMODE'"`                             // 取价方式 - 1:市价 2: 限价
-	Orderprice              float64   `json:"orderprice"  xorm:"'ORDERPRICE'"`                           // 委托价格(账户)
-	Openorderqty            int64     `json:"openorderqty"  xorm:"'OPENORDERQTY'"`                       // 委托数量
-	Opentradeqty            int64     `json:"opentradeqty"  xorm:"'OPENTRADEQTY'"`                       // 成交数量
-	Opencancelqty           int64     `json:"opencancelqty"  xorm:"'OPENCANCELQTY'"`                     // 撤单数量
-	Openfailqty             int64     `json:"openfailqty"  xorm:"'OPENFAILQTY'"`                         // 失败数量
-	Opensuccessqty          int64     `json:"opensuccessqty"  xorm:"'OPENSUCCESSQTY'"`                   // 建仓委托成功数量
-	Closeorderqty           int64     `json:"closeorderqty"  xorm:"'CLOSEORDERQTY'"`                     // 委托数量
-	Closetradeqty           int64     `json:"closetradeqty"  xorm:"'CLOSETRADEQTY'"`                     // 成交数量
-	Closecancelqty          int64     `json:"closecancelqty"  xorm:"'CLOSECANCELQTY'"`                   // 撤单数量
-	Closefailqty            int64     `json:"closefailqty"  xorm:"'CLOSEFAILQTY'"`                       // 失败数量
-	Closesuccessqty         int64     `json:"closesuccessqty"  xorm:"'CLOSESUCCESSQTY'"`                 // 委托成功数量
-	Openfreezemargin        float64   `json:"openfreezemargin"  xorm:"'OPENFREEZEMARGIN'"`               // 冻结保证金(冻结交易金额)
-	Openunfreezemargin      float64   `json:"openunfreezemargin"  xorm:"'OPENUNFREEZEMARGIN'"`           // 解冻保证金
-	Openfreezecharge        float64   `json:"openfreezecharge"  xorm:"'OPENFREEZECHARGE'"`               // 建仓冻结手续费(账户)
-	Openunfreezecharge      float64   `json:"openunfreezecharge"  xorm:"'OPENUNFREEZECHARGE'"`           // 建仓解冻手续费(账户)
-	Validtype               int32     `json:"validtype"  xorm:"'VALIDTYPE'"`                             // 有效类型 - 1当日有效
-	Validtime               time.Time `json:"validtime"  xorm:"'VALIDTIME'"`                             // 有效期限
-	Channeloperatetype      int32     `json:"channeloperatetype"  xorm:"'CHANNELOPERATETYPE'"`           // 操作类型 - 1:正常委托 2:斩仓委托 3:强平委托
-	Ordertime               time.Time `json:"ordertime"  xorm:"'ORDERTIME'"`                             // 委托时间
-	Channelordersrc         int32     `json:"channelordersrc"  xorm:"'CHANNELORDERSRC'"`                 // 委托来源 -  1:客户端 2:风控服务 3:管理端 4:下单接口平台 5:交易服务 6:跟单服务 7:监控终端
-	Channelinnerorderstatus int32     `json:"channelinnerorderstatus"  xorm:"'CHANNELINNERORDERSTATUS'"` // 委托状态 - 1:委托请求 2:冻结成功 3:委托失败 4:委托部成部失败                  5:委托成功 6:全部撤销 7:部成部撤 8:部成部撤部失败 9:全部成交
-	Operatorid              int64     `json:"operatorid"  xorm:"'OPERATORID'"`                           // 登录账号(LoginID)
-	Updatetime              time.Time `json:"updatetime"  xorm:"'UPDATETIME'"`                           // 更新时间
-	Clientordertime         time.Time `json:"clientordertime"  xorm:"'CLIENTORDERTIME'"`                 // 客户端委托时间
-	Clientticket            string    `json:"clientticket"  xorm:"'CLIENTTICKET'"`                       // 客户端流水号
-	UUID                    string    `json:"uuid"  xorm:"'UUID'"`                                       // 发起端唯一id
-	Clienttype              int32     `json:"clienttype"  xorm:"'CLIENTTYPE'"`                           // 客户端类型 - 0:保留为未填终端类型 1:PC管理端 2:PC交易端 3:手机客户端_安卓 4:网页客户端 5:微信客户端 6:手机客户端_苹果 7:网上开户客户端 8:无效终端编号 9:报价终端(中江) 10;监控终端
-	Retcode                 int32     `json:"retcode"  xorm:"'RETCODE'"`                                 // 错误代码
-	Marginalgorithm         int32     `json:"marginalgorithm"  xorm:"'MARGINALGORITHM'"`                 // 保证金收取方式  1:比率  2:固定
-	Marginvalue             float64   `json:"marginvalue"  xorm:"'MARGINVALUE'"`                         // 即市保证金设置值
-	Openfeealgorithm        int32     `json:"openfeealgorithm"  xorm:"'OPENFEEALGORITHM'"`               // 建仓手续费收取方式  1:比率  2:固定
-	Openchargevalue         float64   `json:"openchargevalue"  xorm:"'OPENCHARGEVALUE'"`                 // 建仓手续费设置值
-	Closefeealgorithm       int32     `json:"closefeealgorithm"  xorm:"'CLOSEFEEALGORITHM'"`             // 平仓手续费收取方式 1:比率  2:固定
-	Closechargevalue        float64   `json:"closechargevalue"  xorm:"'CLOSECHARGEVALUE'"`               // 平仓手续费设置值
-	Accountcurrencyid       int32     `json:"accountcurrencyid"  xorm:"'ACCOUNTCURRENCYID'"`             // 账户币种ID
-	Goodscurrencyid         int32     `json:"goodscurrencyid"  xorm:"'GOODSCURRENCYID'"`                 // 商品币种ID
-	Margincurrencyid        int32     `json:"margincurrencyid"  xorm:"'MARGINCURRENCYID'"`               // 保证金币种ID 比率时等于账户币种
-	Marginrate              float64   `json:"marginrate"  xorm:"'MARGINRATE'"`                           // 保证金汇率-比率时等于1
-	Curexchangerate         float64   `json:"curexchangerate"  xorm:"'CUREXCHANGERATE'"`                 // 当前汇率
-	Goodsorderprice         float64   `json:"goodsorderprice"  xorm:"'GOODSORDERPRICE'"`                 // 委托价格(商品)
-	Openfreezemargin2       float64   `json:"openfreezemargin2"  xorm:"'OPENFREEZEMARGIN2'"`             // 建仓冻结保证金(保证金/商品)
-	Openfreezecharge2       float64   `json:"openfreezecharge2"  xorm:"'OPENFREEZECHARGE2'"`             // 建仓冻结手续费(商品)
-	Openunfreezemargin2     float64   `json:"openunfreezemargin2"  xorm:"'OPENUNFREEZEMARGIN2'"`         // 建仓解冻保证金(保证金/商品)
-	Openunfreezecharge2     float64   `json:"openunfreezecharge2"  xorm:"'OPENUNFREEZECHARGE2'"`         // 建仓解冻手续费(商品)
-	Parentaccountid         int64     `json:"parentaccountid"  xorm:"'PARENTACCOUNTID'"`                 // 所属母账户
-	Sessionid               int64     `json:"sessionid"  xorm:"'SESSIONID'"`                             // 会话ID
+// QueryHedgeOrderDetailRsp 企业风管委托单查询返回模型
+type QueryHedgeOrderDetailRsp struct {
+	Orderid                 string    `json:"orderid"`                 // 委托单号(107+Unix秒时间戳(10位)+2位(MarketServiceID)+xxxx)
+	Tradedate               string    `json:"tradedate"`               // 交易日(yyyyMMdd)
+	Channelbuildtype        int32     `json:"channelbuildtype"`        // 开平标志 - 0:无 1:建仓 2:平仓
+	Closetype               int32     `json:"closetype"`               // 平仓方式 - 0:无 1:平今 2:平昨
+	Marketid                int32     `json:"marketid"`                // 市场ID
+	Goodsid                 int32     `json:"goodsid"`                 // 商品ID
+	Accountid               int64     `json:"accountid"`               // 账户ID
+	Buyorsell               int32     `json:"buyorsell"`               // 买卖 - 0:买 1:卖
+	Pricemode               int32     `json:"pricemode"`               // 取价方式 - 1:市价 2: 限价
+	Orderprice              float64   `json:"orderprice"`              // 委托价格(账户)
+	Orderqty                int64     `json:"orderqty"`                // 委托数量
+	Tradeqty                int64     `json:"tradeqty"`                // 成交数量
+	Openfreezemargin        float64   `json:"openfreezemargin"`        // 冻结保证金(冻结交易金额)
+	Channeloperatetype      int32     `json:"channeloperatetype"`      // 操作类型 - 1:正常委托 2:斩仓委托 3:强平委托
+	Ordertime               time.Time `json:"ordertime"`               // 委托时间
+	Channelinnerorderstatus int32     `json:"channelinnerorderstatus"` // 委托状态 - 1:委托请求 2:冻结成功 3:委托失败 4:委托部成部失败 5:委托成功 6:全部撤销 7:部成部撤 8:部成部撤部失败 9:全部成交
+	Curexchangerate         float64   `json:"curexchangerate"`         // 当前汇率
 
-	Goodscode string `json:"goodscode"  xorm:"'GOODSCODE'" binding:"required"` // 商品代码(内部)
-	Goodsname string `json:"goodsname"  xorm:"'GOODSNAME'" binding:"required"` // 商品名称
+	Goodscode string `json:"goodscode"` // 商品代码(内部)
+	Goodsname string `json:"goodsname"` // 商品名称
 
 	Exchangefullname string `json:"exchangefullname"  xorm:"'EXCHANGEFULLNAME'"` // 外部交易所全称
 }
 
 // GetHedgeInnerOrderDetails 获取指定资金账号的通道交易内部委托单信息
-func GetHedgeInnerOrderDetails(accountID int) ([]QueryHedgeInnerOrderDetailRsp, error) {
-	hedgeInnerOrderDetails := make([]QueryHedgeInnerOrderDetailRsp, 0)
+func GetHedgeInnerOrderDetails(accountID int) ([]QueryHedgeOrderDetailRsp, error) {
+	type orderDetail struct {
+		Orderid                 int64     `json:"orderid"  xorm:"'ORDERID'" binding:"required"`              // 委托单号(107+Unix秒时间戳(10位)+2位(MarketServiceID)+xxxx)
+		Tradedate               string    `json:"tradedate"  xorm:"'TRADEDATE'"`                             // 交易日(yyyyMMdd)
+		Channelbuildtype        int32     `json:"channelbuildtype"  xorm:"'CHANNELBUILDTYPE'"`               // 开平标志 - 0:无 1:建仓 2:平仓
+		Closetype               int32     `json:"closetype"  xorm:"'CLOSETYPE'"`                             // 平仓方式 - 0:无 1:平今 2:平昨
+		Hedgeflag               int32     `json:"hedgeflag"  xorm:"'HEDGEFLAG'"`                             // 投机套保标志 - 0:无 1:投机 2:套保 3:套利
+		Marketid                int32     `json:"marketid"  xorm:"'MARKETID'"`                               // 市场ID
+		Goodsid                 int32     `json:"goodsid"  xorm:"'GOODSID'"`                                 // 商品ID
+		Accountid               int64     `json:"accountid"  xorm:"'ACCOUNTID'"`                             // 账户ID
+		Buyorsell               int32     `json:"buyorsell"  xorm:"'BUYORSELL'"`                             // 买卖 - 0:买 1:卖
+		Pricemode               int32     `json:"pricemode"  xorm:"'PRICEMODE'"`                             // 取价方式 - 1:市价 2: 限价
+		Orderprice              float64   `json:"orderprice"  xorm:"'ORDERPRICE'"`                           // 委托价格(账户)
+		Openorderqty            int64     `json:"openorderqty"  xorm:"'OPENORDERQTY'"`                       // 委托数量
+		Opentradeqty            int64     `json:"opentradeqty"  xorm:"'OPENTRADEQTY'"`                       // 成交数量
+		Opencancelqty           int64     `json:"opencancelqty"  xorm:"'OPENCANCELQTY'"`                     // 撤单数量
+		Openfailqty             int64     `json:"openfailqty"  xorm:"'OPENFAILQTY'"`                         // 失败数量
+		Opensuccessqty          int64     `json:"opensuccessqty"  xorm:"'OPENSUCCESSQTY'"`                   // 建仓委托成功数量
+		Closeorderqty           int64     `json:"closeorderqty"  xorm:"'CLOSEORDERQTY'"`                     // 委托数量
+		Closetradeqty           int64     `json:"closetradeqty"  xorm:"'CLOSETRADEQTY'"`                     // 成交数量
+		Closecancelqty          int64     `json:"closecancelqty"  xorm:"'CLOSECANCELQTY'"`                   // 撤单数量
+		Closefailqty            int64     `json:"closefailqty"  xorm:"'CLOSEFAILQTY'"`                       // 失败数量
+		Closesuccessqty         int64     `json:"closesuccessqty"  xorm:"'CLOSESUCCESSQTY'"`                 // 委托成功数量
+		Openfreezemargin        float64   `json:"openfreezemargin"  xorm:"'OPENFREEZEMARGIN'"`               // 冻结保证金(冻结交易金额)
+		Openunfreezemargin      float64   `json:"openunfreezemargin"  xorm:"'OPENUNFREEZEMARGIN'"`           // 解冻保证金
+		Openfreezecharge        float64   `json:"openfreezecharge"  xorm:"'OPENFREEZECHARGE'"`               // 建仓冻结手续费(账户)
+		Openunfreezecharge      float64   `json:"openunfreezecharge"  xorm:"'OPENUNFREEZECHARGE'"`           // 建仓解冻手续费(账户)
+		Validtype               int32     `json:"validtype"  xorm:"'VALIDTYPE'"`                             // 有效类型 - 1当日有效
+		Validtime               time.Time `json:"validtime"  xorm:"'VALIDTIME'"`                             // 有效期限
+		Channeloperatetype      int32     `json:"channeloperatetype"  xorm:"'CHANNELOPERATETYPE'"`           // 操作类型 - 1:正常委托 2:斩仓委托 3:强平委托
+		Ordertime               time.Time `json:"ordertime"  xorm:"'ORDERTIME'"`                             // 委托时间
+		Channelordersrc         int32     `json:"channelordersrc"  xorm:"'CHANNELORDERSRC'"`                 // 委托来源 -  1:客户端 2:风控服务 3:管理端 4:下单接口平台 5:交易服务 6:跟单服务 7:监控终端
+		Channelinnerorderstatus int32     `json:"channelinnerorderstatus"  xorm:"'CHANNELINNERORDERSTATUS'"` // 委托状态 - 1:委托请求 2:冻结成功 3:委托失败 4:委托部成部失败                  5:委托成功 6:全部撤销 7:部成部撤 8:部成部撤部失败 9:全部成交
+		Operatorid              int64     `json:"operatorid"  xorm:"'OPERATORID'"`                           // 登录账号(LoginID)
+		Updatetime              time.Time `json:"updatetime"  xorm:"'UPDATETIME'"`                           // 更新时间
+		Clientordertime         time.Time `json:"clientordertime"  xorm:"'CLIENTORDERTIME'"`                 // 客户端委托时间
+		Clientticket            string    `json:"clientticket"  xorm:"'CLIENTTICKET'"`                       // 客户端流水号
+		UUID                    string    `json:"uuid"  xorm:"'UUID'"`                                       // 发起端唯一id
+		Clienttype              int32     `json:"clienttype"  xorm:"'CLIENTTYPE'"`                           // 客户端类型 - 0:保留为未填终端类型 1:PC管理端 2:PC交易端 3:手机客户端_安卓 4:网页客户端 5:微信客户端 6:手机客户端_苹果 7:网上开户客户端 8:无效终端编号 9:报价终端(中江) 10;监控终端
+		Retcode                 int32     `json:"retcode"  xorm:"'RETCODE'"`                                 // 错误代码
+		Marginalgorithm         int32     `json:"marginalgorithm"  xorm:"'MARGINALGORITHM'"`                 // 保证金收取方式  1:比率  2:固定
+		Marginvalue             float64   `json:"marginvalue"  xorm:"'MARGINVALUE'"`                         // 即市保证金设置值
+		Openfeealgorithm        int32     `json:"openfeealgorithm"  xorm:"'OPENFEEALGORITHM'"`               // 建仓手续费收取方式  1:比率  2:固定
+		Openchargevalue         float64   `json:"openchargevalue"  xorm:"'OPENCHARGEVALUE'"`                 // 建仓手续费设置值
+		Closefeealgorithm       int32     `json:"closefeealgorithm"  xorm:"'CLOSEFEEALGORITHM'"`             // 平仓手续费收取方式 1:比率  2:固定
+		Closechargevalue        float64   `json:"closechargevalue"  xorm:"'CLOSECHARGEVALUE'"`               // 平仓手续费设置值
+		Accountcurrencyid       int32     `json:"accountcurrencyid"  xorm:"'ACCOUNTCURRENCYID'"`             // 账户币种ID
+		Goodscurrencyid         int32     `json:"goodscurrencyid"  xorm:"'GOODSCURRENCYID'"`                 // 商品币种ID
+		Margincurrencyid        int32     `json:"margincurrencyid"  xorm:"'MARGINCURRENCYID'"`               // 保证金币种ID 比率时等于账户币种
+		Marginrate              float64   `json:"marginrate"  xorm:"'MARGINRATE'"`                           // 保证金汇率-比率时等于1
+		Curexchangerate         float64   `json:"curexchangerate"  xorm:"'CUREXCHANGERATE'"`                 // 当前汇率
+		Goodsorderprice         float64   `json:"goodsorderprice"  xorm:"'GOODSORDERPRICE'"`                 // 委托价格(商品)
+		Openfreezemargin2       float64   `json:"openfreezemargin2"  xorm:"'OPENFREEZEMARGIN2'"`             // 建仓冻结保证金(保证金/商品)
+		Openfreezecharge2       float64   `json:"openfreezecharge2"  xorm:"'OPENFREEZECHARGE2'"`             // 建仓冻结手续费(商品)
+		Openunfreezemargin2     float64   `json:"openunfreezemargin2"  xorm:"'OPENUNFREEZEMARGIN2'"`         // 建仓解冻保证金(保证金/商品)
+		Openunfreezecharge2     float64   `json:"openunfreezecharge2"  xorm:"'OPENUNFREEZECHARGE2'"`         // 建仓解冻手续费(商品)
+		Parentaccountid         int64     `json:"parentaccountid"  xorm:"'PARENTACCOUNTID'"`                 // 所属母账户
+		Sessionid               int64     `json:"sessionid"  xorm:"'SESSIONID'"`                             // 会话ID
+
+		Orderidstr       string `xorm:"ORDERIDSTR"`
+		Goodscode        string `xorm:"GOODSCODE"`
+		Goodsname        string `xorm:"GOODSNAME"`
+		Exchangefullname string `xorm:"'EXCHANGEFULLNAME'"`
+	}
+
+	hedgeInnerOrderDetails := make([]orderDetail, 0)
 	if err := db.GetEngine().Table("HEDGE_INNERORDERDETAIL T").
-		Select("to_char(T.ORDERID) ORDERIDSTR, T.*, EX.EXCHANGEFULLNAME").
+		Select("to_char(T.ORDERID) ORDERIDSTR, G.GOODSCODE, G.GOODSNAME, T.*, EX.EXCHANGEFULLNAME").
 		Join("LEFT", "GOODS G", "G.GOODSID = T.GOODSID").
 		Join("LEFT", "GOODSGROUP GG", "GG.GOODSGROUPID = G.GOODSGROUPID").
 		Join("LEFT", "EXTERNALEXCHANGE EX", "GG.EXEXCHANGEID = EX.AUTOID").
@@ -362,6 +387,143 @@ func GetHedgeInnerOrderDetails(accountID int) ([]QueryHedgeInnerOrderDetailRsp,
 		Find(&hedgeInnerOrderDetails); err != nil {
 		return nil, err
 	}
+	rsp := make([]QueryHedgeOrderDetailRsp, 0)
+	for _, v := range hedgeInnerOrderDetails {
+		// 内部委托单分建平
+		orderQty := v.Openorderqty
+		tradeQty := v.Opentradeqty
+		if v.Channelbuildtype == 2 {
+			orderQty = v.Closeorderqty
+			tradeQty = v.Closetradeqty
+		}
+
+		rsp = append(rsp, QueryHedgeOrderDetailRsp{
+			Orderid:                 v.Orderidstr,
+			Tradedate:               v.Tradedate,
+			Channelbuildtype:        v.Channelbuildtype,
+			Closetype:               v.Closetype,
+			Marketid:                v.Marketid,
+			Goodsid:                 v.Goodsid,
+			Accountid:               v.Accountid,
+			Buyorsell:               v.Buyorsell,
+			Pricemode:               v.Pricemode,
+			Orderprice:              v.Orderprice,
+			Orderqty:                orderQty,
+			Tradeqty:                tradeQty,
+			Openfreezemargin:        v.Openfreezemargin,
+			Channeloperatetype:      v.Channeloperatetype,
+			Ordertime:               v.Ordertime,
+			Channelinnerorderstatus: v.Channelinnerorderstatus,
+			Curexchangerate:         v.Curexchangerate,
+			Goodscode:               v.Goodscode,
+			Goodsname:               v.Goodsname,
+			Exchangefullname:        v.Exchangefullname,
+		})
+	}
+
+	return rsp, nil
+}
+
+// GetHedgeOutOrderDetails 获取指定资金账号的通道交易外部委托单信息
+func GetHedgeOutOrderDetails(accountID int) ([]QueryHedgeOrderDetailRsp, error) {
+	type orderDetail struct {
+		Outorderid            int64     `json:"outorderid"  xorm:"'OUTORDERID'" binding:"required"`             // 外部委托单ID(113+Unix秒时间戳(10位)+2位(MarketServiceID)+xxxx)
+		Hedgeaccountcode      string    `json:"hedgeaccountcode"  xorm:"'HEDGEACCOUNTCODE'" binding:"required"` // 对冲账号
+		Tradedate             string    `json:"tradedate"  xorm:"'TRADEDATE'"`                                  // 交易日(yyyyMMdd)
+		Accountid             int64     `json:"accountid"  xorm:"'ACCOUNTID'"`                                  // 资金账号[外部母账户]
+		Relatedorderid        int64     `json:"relatedorderid"  xorm:"'RELATEDORDERID'"`                        // 关联内部委托单号
+		Marketid              int32     `json:"marketid"  xorm:"'MARKETID'"`                                    // 市场ID
+		Hedgegoodsid          int64     `json:"hedgegoodsid"  xorm:"'HEDGEGOODSID'"`                            // 对冲合约ID
+		Orderpricetype        int32     `json:"orderpricetype"  xorm:"'ORDERPRICETYPE'"`                        // 报单价格条件 - 1:市价 2: 限价
+		Buyorsell             int32     `json:"buyorsell"  xorm:"'BUYORSELL'"`                                  // 买卖方向 - 0:买 1:卖
+		Channelbuildtype      int32     `json:"channelbuildtype"  xorm:"'CHANNELBUILDTYPE'"`                    // 开平标志- 0:无 1:建仓 2:平仓
+		Closetype             int32     `json:"closetype"  xorm:"'CLOSETYPE'"`                                  // 平仓方式 - 0:无 1:平今 2:平昨
+		Orderprice            float64   `json:"orderprice"  xorm:"'ORDERPRICE'"`                                // 委托价格
+		Orderqty              int64     `json:"orderqty"  xorm:"'ORDERQTY'"`                                    // 委托数量
+		Tradeqty              int64     `json:"tradeqty"  xorm:"'TRADEQTY'"`                                    // 成交数量
+		Cancelqty             int64     `json:"cancelqty"  xorm:"'CANCELQTY'"`                                  // 撤销数量
+		Validtype             int32     `json:"validtype"  xorm:"'VALIDTYPE'"`                                  // 有效期类型 - 1::当日有效
+		Hedgeflag             int32     `json:"hedgeflag"  xorm:"'HEDGEFLAG'"`                                  // 投机套保标志 - 0:无 1:投机 2:套保 3:套利
+		Channeloutorderstatus int32     `json:"channeloutorderstatus"  xorm:"'CHANNELOUTORDERSTATUS'"`          // 外部单据状态 - 1 - 接收报文 2 - 发送报文成功 3 - 委托成功 4 - 委托失败 5 - 全部成交 6 - 部成部撤 7 - 全部撤单
+		Ordertime             time.Time `json:"ordertime"  xorm:"'ORDERTIME'"`                                  // 委托时间
+		Updatetime            time.Time `json:"updatetime"  xorm:"'UPDATETIME'"`                                // 更新时间
+		Mhpinnerorderid       int64     `json:"mhpinnerorderid"  xorm:"'MHPINNERORDERID'"`                      // 接口平台委托单ID
+		Mhprspcode            int64     `json:"mhprspcode"  xorm:"'MHPRSPCODE'"`                                // 渠道返回码
+		Mhprsptext            string    `json:"mhprsptext"  xorm:"'MHPRSPTEXT'"`                                // 渠道返回信息
+		Optiontype            int32     `json:"optiontype"  xorm:"'OPTIONTYPE'"`                                // 期权类型 - 1:认购(看涨) 2:认沽(看跌)
+		Premium               float64   `json:"premium"  xorm:"'PREMIUM'"`                                      // 权利金
+		Realoutorderid        int64     `json:"realoutorderid"  xorm:"'REALOUTORDERID'"`                        // 实际外部平台委托单ID
+		Relatedcreateorderid  int64     `json:"relatedcreateorderid"  xorm:"'RELATEDCREATEORDERID'"`            // 关联外部建仓委托单ID[平仓委托]
+		Channeloperatetype    int32     `json:"channeloperatetype"  xorm:"'CHANNELOPERATETYPE'"`                // 操作类型 - 1:正常委托 2:斩仓委托 3:强平委托
+		Channelordersrc       int32     `json:"channelordersrc"  xorm:"'CHANNELORDERSRC'"`                      // 委托来源 -  1:客户端 2:风控服务 3:管理端 4:下单接口平台 5:交易服务 6:跟单服务 7:监控终端
+		Operatorid            int64     `json:"operatorid"  xorm:"'OPERATORID'"`                                // 登录账号(LoginID)
+		Clientordertime       time.Time `json:"clientordertime"  xorm:"'CLIENTORDERTIME'"`                      // 客户端委托时间
+		Clientticket          string    `json:"clientticket"  xorm:"'CLIENTTICKET'"`                            // 客户端流水号
+		UUID                  string    `json:"uuid"  xorm:"'UUID'"`                                            // 发起端唯一id
+		Clienttype            int32     `json:"clienttype"  xorm:"'CLIENTTYPE'"`                                // 客户端类型 - 0:保留为未填终端类型 1:PC管理端 2:PC交易端 3:手机客户端_安卓 4:网页客户端 5:微信客户端 6:手机客户端_苹果 7:网上开户客户端 8:无效终端编号 9:报价终端(中江) 10;监控终端
+		Sessionid             int64     `json:"sessionid"  xorm:"'SESSIONID'"`                                  // 会话ID
+
+		Orderidstr       string `xorm:"ORDERIDSTR"`
+		Goodscode        string `xorm:"GOODSCODE"`
+		Goodsname        string `xorm:"GOODSNAME"`
+		Exchangefullname string `xorm:"'EXCHANGEFULLNAME'"`
+	}
+
+	hedgeOutOrderDetails := make([]orderDetail, 0)
+	if err := db.GetEngine().Table("HEDGE_OUTORDERDETAIL T").
+		Select("to_char(T.OUTORDERID) ORDERIDSTR, G.GOODSCODE, G.GOODSNAME, T.*, EX.EXCHANGEFULLNAME").
+		Join("LEFT", "GOODS G", "G.GOODSID = T.HEDGEGOODSID").
+		Join("LEFT", "GOODSGROUP GG", "GG.GOODSGROUPID = G.GOODSGROUPID").
+		Join("LEFT", "EXTERNALEXCHANGE EX", "GG.EXEXCHANGEID = EX.AUTOID").
+		Where("T.ACCOUNTID = ?", accountID).Desc("T.OUTORDERID").
+		Find(&hedgeOutOrderDetails); err != nil {
+		return nil, err
+	}
+	rsp := make([]QueryHedgeOrderDetailRsp, 0)
+	for _, v := range hedgeOutOrderDetails {
+		// 外部单据状态 -> 委托状态
+		// 外部单据状态 - 1 - 接收报文 2 - 发送报文成功 3 - 委托成功 4 - 委托失败 5 - 全部成交 6 - 部成部撤 7 - 全部撤单
+		// 委托状态 - 1:委托请求 2:冻结成功 3:委托失败 4:委托部成部失败 5:委托成功 6:全部撤销 7:部成部撤 8:部成部撤部失败 9:全部成交
+		status := v.Channeloutorderstatus
+		if v.Channeloutorderstatus == 1 {
+			status = 1
+		} else if v.Channeloutorderstatus == 2 {
+			status = 1
+		} else if v.Channeloutorderstatus == 3 {
+			status = 5
+		} else if v.Channeloutorderstatus == 4 {
+			status = 3
+		} else if v.Channeloutorderstatus == 5 {
+			status = 9
+		} else if v.Channeloutorderstatus == 6 {
+			status = 7
+		} else if v.Channeloutorderstatus == 7 {
+			status = 6
+		}
+
+		rsp = append(rsp, QueryHedgeOrderDetailRsp{
+			Orderid:                 v.Orderidstr,
+			Tradedate:               v.Tradedate,
+			Channelbuildtype:        v.Channelbuildtype,
+			Closetype:               v.Closetype,
+			Marketid:                v.Marketid,
+			Goodsid:                 int32(v.Hedgegoodsid),
+			Accountid:               v.Accountid,
+			Buyorsell:               v.Buyorsell,
+			Pricemode:               v.Orderpricetype,
+			Orderprice:              v.Orderprice,
+			Orderqty:                v.Orderqty,
+			Tradeqty:                v.Tradeqty,
+			Openfreezemargin:        0,
+			Channeloperatetype:      v.Channeloperatetype,
+			Ordertime:               v.Ordertime,
+			Channelinnerorderstatus: status,
+			Curexchangerate:         1,
+			Goodscode:               v.Goodscode,
+			Goodsname:               v.Goodsname,
+			Exchangefullname:        v.Exchangefullname,
+		})
+	}
 
-	return hedgeInnerOrderDetails, nil
+	return rsp, nil
 }

+ 13 - 1
models/quote.go

@@ -29,6 +29,10 @@ const (
 	CycleTypeMinutes240 CycleType = 240
 	// CycleTypeMinutesDay 周期类型 - 日线
 	CycleTypeMinutesDay CycleType = 11
+	// CycleTypeWeek 周期类型 - 周线
+	CycleTypeWeek CycleType = 12
+	// CycleTypeYear 周期类型 - 年线
+	CycleTypeYear CycleType = 14
 	// CycleTypeTik 周期类型 - Tik
 	CycleTypeTik CycleType = 10
 )
@@ -198,7 +202,7 @@ func GetHistoryCycleDatas(cycleType CycleType, goodsCode string, startTime, endT
 	// 获取目标Collection
 	collection := "mincycle"
 	switch cycleType {
-	case CycleTypeSecond:
+	case CycleTypeTik:
 		collection = "quotetik"
 	case CycleTypeMinutes1:
 		collection = "mincycle"
@@ -206,8 +210,16 @@ func GetHistoryCycleDatas(cycleType CycleType, goodsCode string, startTime, endT
 		collection = "min5cycle"
 	case CycleTypeMinutes30:
 		collection = "min30cycle"
+	case CycleTypeMinutes60:
+		collection = "min60cycle"
+	case CycleTypeMinutes240:
+		collection = "min240cycle"
 	case CycleTypeMinutesDay:
 		collection = "daycycle"
+	case CycleTypeWeek:
+		collection = "weekcycle"
+	case CycleTypeYear:
+		collection = "yearcycle"
 	default:
 		return nil, errors.New("不支持的周期类型")
 	}