zhou.xiaoning 2 jaren geleden
bovenliggende
commit
722516cce2
7 gewijzigde bestanden met toevoegingen van 372 en 6 verwijderingen
  1. 4 4
      controllers/guangzuan/tradeService.go
  2. 1 2
      controllers/order/order.go
  3. 101 0
      docs/docs.go
  4. 101 0
      docs/swagger.json
  5. 75 0
      docs/swagger.yaml
  6. 58 0
      models/common.go
  7. 32 0
      models/ori.go

+ 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]

+ 1 - 2
controllers/order/order.go

@@ -143,12 +143,11 @@ func GetTradePosition(accIds string, tradeModes string) (rst []QueryTradePositio
 	// ORACLE好像在JOIN里不支持别名功能(在XORM中)
 	s := engine.Table("TRADEPOSITION").
 		Join("LEFT", "GOODS", "TRADEPOSITION.GOODSID = GOODS.GOODSID").
-		Join("LEFT", "GOODS G2", "GOODS.REFGOODSID = G2.GOODSID").
 		Join("LEFT", "GOODSEX EX", "EX.GOODSID = GOODS.GOODSID").
 		Join("LEFT", "MARKET", "GOODS.MARKETID = MARKET.MARKETID").
 		Join("LEFT", "ENUMDICITEM", "GOODS.GOODUNITID = ENUMDICITEM.ENUMITEMNAME and ENUMDICITEM.ENUMDICCODE = 'goodsunit'").
 		Join("LEFT", "USERINFO UI", "UI.USERID = GOODS.PROVIDERUSERID").
-		Select("TRADEPOSITION.*, GOODS.GOODSCODE, GOODS.GOODSNAME, GOODS.CURRENCYID, GOODS.GOODUNITID,GOODS.QTYDECIMALPLACE, G2.REFGOODSID, G2.REFGOODSCODE, " +
+		Select("TRADEPOSITION.*, GOODS.GOODSCODE, GOODS.GOODSNAME, GOODS.CURRENCYID, GOODS.GOODUNITID,GOODS.QTYDECIMALPLACE, GOODS.REFGOODSID, GOODS.REFGOODSCODE, " +
 			"ENUMDICITEM.ENUMDICNAME as GOODUNIT, GOODS.AGREEUNIT, GOODS.DECIMALPLACE, MARKET.MARKETID, MARKET.TRADEMODE, UI.CUSTOMERNAME as MATCHNAME, nvl(EX.MINDELIVERYLOT, 1) MINDELIVERYLOT").
 		Where(fmt.Sprintf(`TRADEPOSITION.ACCOUNTID in (%s)`, accIds))
 	if len(tradeModes) > 0 {

+ 101 - 0
docs/docs.go

@@ -37665,6 +37665,10 @@ const docTemplate = `{
         "models.GetTodayAccountConfigInfoRsp": {
             "type": "object",
             "properties": {
+                "riskRatioType": {
+                    "description": "风险率类型表",
+                    "$ref": "#/definitions/models.Riskratiotype"
+                },
                 "todayAccountMargins": {
                     "description": "今日账户保证金表",
                     "type": "array",
@@ -51309,6 +51313,103 @@ const docTemplate = `{
                 }
             }
         },
+        "models.Riskratiotype": {
+            "type": "object",
+            "properties": {
+                "addmarginriskratio": {
+                    "description": "追加保证金风险率",
+                    "type": "number"
+                },
+                "addsaferatio": {
+                    "description": "追加安全度",
+                    "type": "number"
+                },
+                "createtime": {
+                    "description": "创建时间",
+                    "type": "string"
+                },
+                "creatorid": {
+                    "description": "创建人",
+                    "type": "integer"
+                },
+                "customertype": {
+                    "description": "客户类别(机构/投资者客户类别枚举项值)",
+                    "type": "integer"
+                },
+                "cutbackriskratio": {
+                    "description": "斩仓恢复风险率(投资者用,会员转全部净头寸)",
+                    "type": "number"
+                },
+                "cutmarginseq": {
+                    "description": "斩仓市场顺序(按市场)",
+                    "type": "string"
+                },
+                "cutriskratio": {
+                    "description": "斩仓风险率",
+                    "type": "number"
+                },
+                "cutsaferatio": {
+                    "description": "斩仓安全度",
+                    "type": "number"
+                },
+                "cutthreshold": {
+                    "description": "净值斩仓阈值(做市会员用)",
+                    "type": "number"
+                },
+                "cutthresholdflag": {
+                    "description": "净值斩仓标志 - 0:不启用  1:启用(做市会员用)",
+                    "type": "integer"
+                },
+                "isdefault": {
+                    "description": "是否默认(每个风控模式必有且只能设置一个默认) -  0:非默认  1:默认",
+                    "type": "integer"
+                },
+                "issendcancel": {
+                    "description": "到达追加风险率是否撤单(交易) - 0:不撤 1:撤单",
+                    "type": "integer"
+                },
+                "issenddeliverycancel": {
+                    "description": "到达追加风险率是否撤单(交割) - 0:不撤 1:撤单",
+                    "type": "integer"
+                },
+                "modifierid": {
+                    "description": "修改人ID",
+                    "type": "integer"
+                },
+                "modifytime": {
+                    "description": "修改时间",
+                    "type": "string"
+                },
+                "notemarginriskratio": {
+                    "description": "提示保证金风险率",
+                    "type": "number"
+                },
+                "notesaferatio": {
+                    "description": "提示安全度",
+                    "type": "number"
+                },
+                "recoversaferatio": {
+                    "description": "恢复正常安全度(会员)",
+                    "type": "number"
+                },
+                "recovertraderiskratio": {
+                    "description": "恢复正常交易风险率(会员)",
+                    "type": "number"
+                },
+                "riskcontrolmode": {
+                    "description": "适用交易用户类型 1:投资者/机构自营 2:机构做市",
+                    "type": "integer"
+                },
+                "riskratiocalcmode": {
+                    "description": "风险率计算方法 - 1:占用/净值",
+                    "type": "integer"
+                },
+                "riskrationame": {
+                    "description": "类型名称",
+                    "type": "string"
+                }
+            }
+        },
         "models.RoleMenu": {
             "type": "object",
             "properties": {

+ 101 - 0
docs/swagger.json

@@ -37656,6 +37656,10 @@
         "models.GetTodayAccountConfigInfoRsp": {
             "type": "object",
             "properties": {
+                "riskRatioType": {
+                    "description": "风险率类型表",
+                    "$ref": "#/definitions/models.Riskratiotype"
+                },
                 "todayAccountMargins": {
                     "description": "今日账户保证金表",
                     "type": "array",
@@ -51300,6 +51304,103 @@
                 }
             }
         },
+        "models.Riskratiotype": {
+            "type": "object",
+            "properties": {
+                "addmarginriskratio": {
+                    "description": "追加保证金风险率",
+                    "type": "number"
+                },
+                "addsaferatio": {
+                    "description": "追加安全度",
+                    "type": "number"
+                },
+                "createtime": {
+                    "description": "创建时间",
+                    "type": "string"
+                },
+                "creatorid": {
+                    "description": "创建人",
+                    "type": "integer"
+                },
+                "customertype": {
+                    "description": "客户类别(机构/投资者客户类别枚举项值)",
+                    "type": "integer"
+                },
+                "cutbackriskratio": {
+                    "description": "斩仓恢复风险率(投资者用,会员转全部净头寸)",
+                    "type": "number"
+                },
+                "cutmarginseq": {
+                    "description": "斩仓市场顺序(按市场)",
+                    "type": "string"
+                },
+                "cutriskratio": {
+                    "description": "斩仓风险率",
+                    "type": "number"
+                },
+                "cutsaferatio": {
+                    "description": "斩仓安全度",
+                    "type": "number"
+                },
+                "cutthreshold": {
+                    "description": "净值斩仓阈值(做市会员用)",
+                    "type": "number"
+                },
+                "cutthresholdflag": {
+                    "description": "净值斩仓标志 - 0:不启用  1:启用(做市会员用)",
+                    "type": "integer"
+                },
+                "isdefault": {
+                    "description": "是否默认(每个风控模式必有且只能设置一个默认) -  0:非默认  1:默认",
+                    "type": "integer"
+                },
+                "issendcancel": {
+                    "description": "到达追加风险率是否撤单(交易) - 0:不撤 1:撤单",
+                    "type": "integer"
+                },
+                "issenddeliverycancel": {
+                    "description": "到达追加风险率是否撤单(交割) - 0:不撤 1:撤单",
+                    "type": "integer"
+                },
+                "modifierid": {
+                    "description": "修改人ID",
+                    "type": "integer"
+                },
+                "modifytime": {
+                    "description": "修改时间",
+                    "type": "string"
+                },
+                "notemarginriskratio": {
+                    "description": "提示保证金风险率",
+                    "type": "number"
+                },
+                "notesaferatio": {
+                    "description": "提示安全度",
+                    "type": "number"
+                },
+                "recoversaferatio": {
+                    "description": "恢复正常安全度(会员)",
+                    "type": "number"
+                },
+                "recovertraderiskratio": {
+                    "description": "恢复正常交易风险率(会员)",
+                    "type": "number"
+                },
+                "riskcontrolmode": {
+                    "description": "适用交易用户类型 1:投资者/机构自营 2:机构做市",
+                    "type": "integer"
+                },
+                "riskratiocalcmode": {
+                    "description": "风险率计算方法 - 1:占用/净值",
+                    "type": "integer"
+                },
+                "riskrationame": {
+                    "description": "类型名称",
+                    "type": "string"
+                }
+            }
+        },
         "models.RoleMenu": {
             "type": "object",
             "properties": {

+ 75 - 0
docs/swagger.yaml

@@ -11170,6 +11170,9 @@ definitions:
     type: object
   models.GetTodayAccountConfigInfoRsp:
     properties:
+      riskRatioType:
+        $ref: '#/definitions/models.Riskratiotype'
+        description: 风险率类型表
       todayAccountMargins:
         description: 今日账户保证金表
         items:
@@ -21333,6 +21336,78 @@ definitions:
     - accountid
     - cycletime
     type: object
+  models.Riskratiotype:
+    properties:
+      addmarginriskratio:
+        description: 追加保证金风险率
+        type: number
+      addsaferatio:
+        description: 追加安全度
+        type: number
+      createtime:
+        description: 创建时间
+        type: string
+      creatorid:
+        description: 创建人
+        type: integer
+      customertype:
+        description: 客户类别(机构/投资者客户类别枚举项值)
+        type: integer
+      cutbackriskratio:
+        description: 斩仓恢复风险率(投资者用,会员转全部净头寸)
+        type: number
+      cutmarginseq:
+        description: 斩仓市场顺序(按市场)
+        type: string
+      cutriskratio:
+        description: 斩仓风险率
+        type: number
+      cutsaferatio:
+        description: 斩仓安全度
+        type: number
+      cutthreshold:
+        description: 净值斩仓阈值(做市会员用)
+        type: number
+      cutthresholdflag:
+        description: 净值斩仓标志 - 0:不启用  1:启用(做市会员用)
+        type: integer
+      isdefault:
+        description: 是否默认(每个风控模式必有且只能设置一个默认) -  0:非默认  1:默认
+        type: integer
+      issendcancel:
+        description: 到达追加风险率是否撤单(交易) - 0:不撤 1:撤单
+        type: integer
+      issenddeliverycancel:
+        description: 到达追加风险率是否撤单(交割) - 0:不撤 1:撤单
+        type: integer
+      modifierid:
+        description: 修改人ID
+        type: integer
+      modifytime:
+        description: 修改时间
+        type: string
+      notemarginriskratio:
+        description: 提示保证金风险率
+        type: number
+      notesaferatio:
+        description: 提示安全度
+        type: number
+      recoversaferatio:
+        description: 恢复正常安全度(会员)
+        type: number
+      recovertraderiskratio:
+        description: 恢复正常交易风险率(会员)
+        type: number
+      riskcontrolmode:
+        description: 适用交易用户类型 1:投资者/机构自营 2:机构做市
+        type: integer
+      riskratiocalcmode:
+        description: 风险率计算方法 - 1:占用/净值
+        type: integer
+      riskrationame:
+        description: 类型名称
+        type: string
+    type: object
   models.RoleMenu:
     properties:
       hasright:

+ 58 - 0
models/common.go

@@ -1403,6 +1403,7 @@ type GetTodayAccountConfigInfoRsp struct {
 	TodayAccountMargins    []Todayaccountmargin    `json:"todayAccountMargins"`    // 今日账户保证金表
 	TodayAccountTradefees  []Todayaccounttradefee  `json:"todayAccountTradefees"`  // 今日账户交易费用表
 	TodayAccountTradeRules []Todayaccounttraderule `json:"todayAccountTradeRules"` // 今日账户交易规则信表
+	RiskRatioType          *Riskratiotype          `json:"riskRatioType"`          // 风险率类型表
 }
 
 func GetTodayAccountConfigInfo(accountid int) (rsp GetTodayAccountConfigInfoRsp, err error) {
@@ -1419,11 +1420,19 @@ func GetTodayAccountConfigInfo(accountid int) (rsp GetTodayAccountConfigInfoRsp,
 	if err = db.GetEngine().In("ACCOUNTID", []int{0, accountid}).Find(&todayAccountTradefees); err != nil {
 		return
 	}
+	for i := range todayAccountTradefees {
+		item := &todayAccountTradefees[i]
+		item.INFOCONTENT = base64.StdEncoding.EncodeToString([]byte(item.INFOCONTENT))
+	}
 
 	todayAccountTradeRules := make([]Todayaccounttraderule, 0)
 	if err = db.GetEngine().In("ACCOUNTID", []int{0, accountid}).Find(&todayAccountTradeRules); err != nil {
 		return
 	}
+	for i := range todayAccountTradeRules {
+		item := &todayAccountTradeRules[i]
+		item.INFOCONTENT = base64.StdEncoding.EncodeToString([]byte(item.INFOCONTENT))
+	}
 
 	rsp = GetTodayAccountConfigInfoRsp{
 		TodayAccountMargins:    todayAccountMargins,
@@ -1431,5 +1440,54 @@ func GetTodayAccountConfigInfo(accountid int) (rsp GetTodayAccountConfigInfoRsp,
 		TodayAccountTradeRules: todayAccountTradeRules,
 	}
 
+	sql := fmt.Sprintf(`
+	SELECT TA.ACCOUNTID,
+		NVL(NVL(NVL(UG.CUSTOMERTYPE, ARC.CUSTOMERTYPE), CTAD.CUSTOMERTYPE),
+			-1) AS RISKID
+	FROM TAACCOUNT TA
+	LEFT JOIN USERACCOUNT UA
+		ON UA.USERID = TA.USERID
+	LEFT JOIN USERGROUPDETAIL UGD
+		ON TA.USERID = UGD.USERID
+	LEFT JOIN USERGROUP UG
+		ON UGD.USERGROUPID = UG.AUTOID
+	LEFT JOIN ACCOUNTRISKCONFIG ARC
+		ON ARC.ACCOUNTID = TA.ACCOUNTID
+	LEFT JOIN CUSTOMERTYPEAREADETAIL CTAD
+		ON TA.USERID = CTAD.USERID
+	WHERE 
+	TA.TAACCOUNTTYPE IN (2)
+	AND TA.ACCOUNTID = %v
+	`, accountid)
+	results, err := db.GetEngine().QueryInterface(sql)
+	if err != nil {
+		return
+	}
+	if len(results) > 0 {
+		if riskid, ok := results[0]["RISKID"].(float64); ok {
+			if riskid == -1 {
+				var riskatiotype Riskratiotype
+				if ok, err = db.GetEngine().Where("riskcontrolmode = 1 and isdefault = 1").Get(&riskatiotype); err == nil && ok {
+					rsp.RiskRatioType = new(Riskratiotype)
+					*rsp.RiskRatioType = riskatiotype
+				} else {
+					if err == nil {
+						err = errors.New("获取数据失败")
+					}
+				}
+			} else {
+				var riskatiotype Riskratiotype
+				if ok, err = db.GetEngine().Where("CUSTOMERTYPE = ?", riskid).Get(&riskatiotype); err == nil && ok {
+					rsp.RiskRatioType = new(Riskratiotype)
+					*rsp.RiskRatioType = riskatiotype
+				} else {
+					if err == nil {
+						err = errors.New("获取数据失败")
+					}
+				}
+			}
+		}
+	}
+
 	return
 }

+ 32 - 0
models/ori.go

@@ -841,3 +841,35 @@ type Todayaccounttraderule struct {
 func (r *Todayaccounttraderule) TableName() string {
 	return "TODAY_ACCOUNTTRADERULE"
 }
+
+// Riskratiotype 风险率类型表
+type Riskratiotype struct {
+	CUSTOMERTYPE          int32     `json:"customertype" xorm:"CUSTOMERTYPE"`                   // 客户类别(机构/投资者客户类别枚举项值)
+	RISKCONTROLMODE       int32     `json:"riskcontrolmode" xorm:"RISKCONTROLMODE"`             // 适用交易用户类型 1:投资者/机构自营 2:机构做市
+	RISKRATIONAME         string    `json:"riskrationame" xorm:"RISKRATIONAME"`                 // 类型名称
+	RISKRATIOCALCMODE     int32     `json:"riskratiocalcmode" xorm:"RISKRATIOCALCMODE"`         // 风险率计算方法 - 1:占用/净值
+	NOTEMARGINRISKRATIO   float64   `json:"notemarginriskratio" xorm:"NOTEMARGINRISKRATIO"`     // 提示保证金风险率
+	ADDMARGINRISKRATIO    float64   `json:"addmarginriskratio" xorm:"ADDMARGINRISKRATIO"`       // 追加保证金风险率
+	RECOVERTRADERISKRATIO float64   `json:"recovertraderiskratio" xorm:"RECOVERTRADERISKRATIO"` // 恢复正常交易风险率(会员)
+	CUTBACKRISKRATIO      float64   `json:"cutbackriskratio" xorm:"CUTBACKRISKRATIO"`           // 斩仓恢复风险率(投资者用,会员转全部净头寸)
+	CUTRISKRATIO          float64   `json:"cutriskratio" xorm:"CUTRISKRATIO"`                   // 斩仓风险率
+	CUTMARGINSEQ          string    `json:"cutmarginseq" xorm:"CUTMARGINSEQ"`                   // 斩仓市场顺序(按市场)
+	CUTTHRESHOLDFLAG      int32     `json:"cutthresholdflag" xorm:"CUTTHRESHOLDFLAG"`           // 净值斩仓标志 - 0:不启用  1:启用(做市会员用)
+	CUTTHRESHOLD          float64   `json:"cutthreshold" xorm:"CUTTHRESHOLD"`                   // 净值斩仓阈值(做市会员用)
+	ISDEFAULT             int32     `json:"isdefault" xorm:"ISDEFAULT"`                         // 是否默认(每个风控模式必有且只能设置一个默认) -  0:非默认  1:默认
+	CREATETIME            time.Time `json:"createtime" xorm:"CREATETIME"`                       // 创建时间
+	CREATORID             int64     `json:"creatorid" xorm:"CREATORID"`                         // 创建人
+	MODIFYTIME            time.Time `json:"modifytime" xorm:"MODIFYTIME"`                       // 修改时间
+	MODIFIERID            int64     `json:"modifierid" xorm:"MODIFIERID"`                       // 修改人ID
+	ISSENDCANCEL          int32     `json:"issendcancel" xorm:"ISSENDCANCEL"`                   // 到达追加风险率是否撤单(交易) - 0:不撤 1:撤单
+	ISSENDDELIVERYCANCEL  int32     `json:"issenddeliverycancel" xorm:"ISSENDDELIVERYCANCEL"`   // 到达追加风险率是否撤单(交割) - 0:不撤 1:撤单
+	NOTESAFERATIO         float64   `json:"notesaferatio" xorm:"NOTESAFERATIO"`                 // 提示安全度
+	ADDSAFERATIO          float64   `json:"addsaferatio" xorm:"ADDSAFERATIO"`                   // 追加安全度
+	RECOVERSAFERATIO      float64   `json:"recoversaferatio" xorm:"RECOVERSAFERATIO"`           // 恢复正常安全度(会员)
+	CUTSAFERATIO          float64   `json:"cutsaferatio" xorm:"CUTSAFERATIO"`                   // 斩仓安全度
+}
+
+// TableName is RISKRATIOTYPE
+func (r *Riskratiotype) TableName() string {
+	return "RISKRATIOTYPE"
+}