Przeglądaj źródła

修改“查询合同申请表单数据”接口BUG

zhou.xiaoning 5 lat temu
rodzic
commit
99d568e124
7 zmienionych plików z 49 dodań i 476 usunięć
  1. 21 10
      controllers/erms3/spotContract.go
  2. 2 166
      docs/docs.go
  3. 2 166
      docs/swagger.json
  4. 2 125
      docs/swagger.yaml
  5. 3 3
      models/account.go
  6. 13 6
      models/goods.go
  7. 6 0
      token/token.go

+ 21 - 10
controllers/erms3/spotContract.go

@@ -288,11 +288,11 @@ type CustomerInfo struct {
 
 // QuerySpotContractAppleFormRsp 查询合同申请表单数据返回模型
 type QuerySpotContractAppleFormRsp struct {
-	OurUser        CustomerInfo           `json:"ouruser"`        // 我方账号
-	OppositeUsers  []CustomerInfo         `json:"oppositeusers"`  // 对方账号列表
-	WrStandards    []models.Wrstandard    `json:"wrstandards"`    // 仓单标准列表
-	WareHouseInfos []models.Warehouseinfo `json:"warehouseinfos"` // 仓库信息列表
-	Goodses        []models.GoodsInfo     `json:"goodses"`        // 合约列表
+	OurUser        CustomerInfo            `json:"ouruser"`        // 我方账号
+	OppositeUsers  []CustomerInfo          `json:"oppositeusers"`  // 对方账号列表
+	WrStandards    []models.Wrstandard     `json:"wrstandards"`    // 仓单标准列表
+	WareHouseInfos []models.Warehouseinfo  `json:"warehouseinfos"` // 仓库信息列表
+	Goodses        []models.GoodsIDAndName `json:"goodses"`        // 合约列表
 }
 
 // QuerySpotContractAppleForm 查询合同申请表单数据
@@ -327,10 +327,13 @@ func QuerySpotContractAppleForm(c *gin.Context) {
 	}
 	rsp.OurUser.Userid = ourUser.Userid
 	rsp.OurUser.Customername = ourUser.Customername
-	key, _ := hex.DecodeString(utils.AESSecretKey)                     // 手机号码解密
-	if phonenum, err := hex.DecodeString(ourUser.Mobile); err == nil { // hex -> []byte
-		if mobile, err := utils.AESDecrypt(phonenum, key); err == nil {
-			rsp.OurUser.Mobile = string(mobile)
+	key, _ := hex.DecodeString(utils.AESSecretKey)
+	if len(ourUser.Mobile) > 0 {
+		// 手机号码解密
+		if phonenum, err := hex.DecodeString(ourUser.Mobile); err == nil { // hex -> []byte
+			if mobile, err := utils.AESDecrypt(phonenum, key); err == nil {
+				rsp.OurUser.Mobile = string(mobile)
+			}
 		}
 	}
 	taAccounts, err := models.GetTaAccountsByType(req.UserID, 3) // 获取内部资金账户,现货都使用内部资金账户
@@ -363,6 +366,14 @@ func QuerySpotContractAppleForm(c *gin.Context) {
 		userInfo := CustomerInfo{}
 		userInfo.Userid = v.Userid
 		userInfo.Customername = v.Customername
+		if len(v.Mobile) > 0 {
+			// 手机号码解密
+			if phonenum, err := hex.DecodeString(v.Mobile); err == nil { // hex -> []byte
+				if mobile, err := utils.AESDecrypt(phonenum, key); err == nil {
+					userInfo.Mobile = string(mobile)
+				}
+			}
+		}
 		// 获取客户的资金账户列表
 		opposTaAccounts, err := models.GetTaAccountsByType(int(v.Userid), 3) // 获取内部资金账户,现货都使用内部资金账户
 		if err != nil {
@@ -402,7 +413,7 @@ func QuerySpotContractAppleForm(c *gin.Context) {
 	rsp.WareHouseInfos = wareHouseInfos
 
 	// 获取合约信息
-	rsp.Goodses = make([]models.GoodsInfo, 0)
+	rsp.Goodses = make([]models.GoodsIDAndName, 0)
 	goodses, err := models.GetGoodsInfosByTradeModes("15")
 	if err != nil {
 		// 查询失败

+ 2 - 166
docs/docs.go

@@ -4528,7 +4528,7 @@ var doc = `{
                     "description": "合约列表",
                     "type": "array",
                     "items": {
-                        "$ref": "#/definitions/models.GoodsInfo"
+                        "$ref": "#/definitions/models.GoodsIDAndName"
                     }
                 },
                 "oppositeusers": {
@@ -4777,7 +4777,7 @@ var doc = `{
                 }
             }
         },
-        "models.GoodsInfo": {
+        "models.GoodsIDAndName": {
             "type": "object",
             "required": [
                 "goodscode",
@@ -4786,86 +4786,10 @@ var doc = `{
                 "marketid"
             ],
             "properties": {
-                "agreeunit": {
-                    "description": "合约单位",
-                    "type": "number"
-                },
-                "auditaccountid": {
-                    "description": "审核操作员账号",
-                    "type": "integer"
-                },
-                "audittime": {
-                    "description": "审核时间",
-                    "type": "string"
-                },
-                "cancelaccountid": {
-                    "description": "注销操作员账号",
-                    "type": "integer"
-                },
-                "canceltime": {
-                    "description": "注销时间",
-                    "type": "string"
-                },
-                "closepricemode": {
-                    "description": "强平价格方式 - 1:市价 2:最新价 3:涨跌停(未实现)",
-                    "type": "integer"
-                },
-                "closepriceparam": {
-                    "description": "强平最新价浮动比例 - 方式为2时使用  (\u003c1)买 上浮 (1+x)*最新价卖 下浮 (1-x)*最新价",
-                    "type": "number"
-                },
-                "createtime": {
-                    "description": "创建时间",
-                    "type": "string"
-                },
-                "creatorid": {
-                    "description": "创建人",
-                    "type": "integer"
-                },
-                "currencyid": {
-                    "description": "报价货币ID",
-                    "type": "integer"
-                },
-                "cutmode": {
-                    "description": "斩仓方式 - 1:不斩仓 2:自动斩仓 3:半自动斩仓",
-                    "type": "integer"
-                },
-                "decimalplace": {
-                    "description": "报价小数位",
-                    "type": "integer"
-                },
-                "delistingdate": {
-                    "description": "商品退市时间(状态:退市) -- 已作废",
-                    "type": "string"
-                },
-                "delistingmode": {
-                    "description": "退市方式 - 1:退市平仓 2:退市交收 3:不处理(仅期权\\币币兑换)",
-                    "type": "integer"
-                },
-                "deliveryflag": {
-                    "description": "交割标志 - 0:不可交割  1:可交割",
-                    "type": "integer"
-                },
-                "forceclosemode": {
-                    "description": "定期强平方式 - 1:无 2:每日 3:每周 4:每月[收益权]",
-                    "type": "integer"
-                },
-                "forceclosevalue": {
-                    "description": "定期强平参数 [收益权]",
-                    "type": "integer"
-                },
                 "goodscode": {
                     "description": "商品代码(内部)",
                     "type": "string"
                 },
-                "goodscurrencyid": {
-                    "description": "合约货币ID",
-                    "type": "integer"
-                },
-                "goodsgroupid": {
-                    "description": "所属商品组ID",
-                    "type": "integer"
-                },
                 "goodsid": {
                     "description": "商品ID(自增ID SEQ_GOODS)",
                     "type": "integer"
@@ -4874,97 +4798,9 @@ var doc = `{
                     "description": "商品名称",
                     "type": "string"
                 },
-                "goodsquotetype": {
-                    "description": "合约报价类型: 1-直接报价  2-间接报价",
-                    "type": "integer"
-                },
-                "goodsstatus": {
-                    "description": "商品状态- 1:待审核 2:未上市 3:上市 4:已注销 5:审核拒绝 6:退市 7:待退市",
-                    "type": "integer"
-                },
-                "goodstradetype": {
-                    "description": "商品交易权限类型 - 1:可建可平 3:不可建可平",
-                    "type": "integer"
-                },
-                "goodsunit": {
-                    "description": "报价单位",
-                    "type": "string"
-                },
-                "goodunitid": {
-                    "description": "报价单位ID",
-                    "type": "integer"
-                },
-                "hasquoter": {
-                    "description": "是否有报价商 - 0:无报价商 1:有报价商",
-                    "type": "integer"
-                },
-                "hqprotecttime": {
-                    "description": "行情保护时间(秒)",
-                    "type": "integer"
-                },
-                "innerdealmode": {
-                    "description": "内部成交方式[通道交易] - 1:净头寸 2:开平 3:平今",
-                    "type": "integer"
-                },
-                "isbuylimited": {
-                    "description": "是否限制建仓量 - 0:不限制 1:限制",
-                    "type": "integer"
-                },
-                "lasttradedate": {
-                    "description": "最后交易日期(状态:待退市)",
-                    "type": "string"
-                },
-                "listingdate": {
-                    "description": "交易开始日期",
-                    "type": "string"
-                },
                 "marketid": {
                     "description": "所属市场ID",
                     "type": "integer"
-                },
-                "modifierid": {
-                    "description": "修改人",
-                    "type": "integer"
-                },
-                "modifystatus": {
-                    "description": "变更状态 - 1:未变更 2:变更中 3:待审核 4:已审核",
-                    "type": "integer"
-                },
-                "modifytime": {
-                    "description": "修改时间",
-                    "type": "string"
-                },
-                "outerdealmode": {
-                    "description": "外部成交方式[通道交易]- 1:净头寸 2:开平 3:平今",
-                    "type": "integer"
-                },
-                "outgoodscode": {
-                    "description": "商品代码(外部)",
-                    "type": "string"
-                },
-                "qtydecimalplace": {
-                    "description": "成交量小数位",
-                    "type": "integer"
-                },
-                "quotegear": {
-                    "description": "行情档位(1-10)",
-                    "type": "integer"
-                },
-                "quoteminunit": {
-                    "description": "行情最小变动单位 [整数,报价小数位一起使用]",
-                    "type": "integer"
-                },
-                "quoteshowtype": {
-                    "description": "行情报价类型: 1:成交价 2:买卖中间价 3:含买价 4:含卖价做市模式固定为3:含买价",
-                    "type": "integer"
-                },
-                "quoteshowtypeinterval": {
-                    "description": "行情报价间隔时间(秒)(成交价时为0)",
-                    "type": "integer"
-                },
-                "remark": {
-                    "description": "备注",
-                    "type": "string"
                 }
             }
         },

+ 2 - 166
docs/swagger.json

@@ -4512,7 +4512,7 @@
                     "description": "合约列表",
                     "type": "array",
                     "items": {
-                        "$ref": "#/definitions/models.GoodsInfo"
+                        "$ref": "#/definitions/models.GoodsIDAndName"
                     }
                 },
                 "oppositeusers": {
@@ -4761,7 +4761,7 @@
                 }
             }
         },
-        "models.GoodsInfo": {
+        "models.GoodsIDAndName": {
             "type": "object",
             "required": [
                 "goodscode",
@@ -4770,86 +4770,10 @@
                 "marketid"
             ],
             "properties": {
-                "agreeunit": {
-                    "description": "合约单位",
-                    "type": "number"
-                },
-                "auditaccountid": {
-                    "description": "审核操作员账号",
-                    "type": "integer"
-                },
-                "audittime": {
-                    "description": "审核时间",
-                    "type": "string"
-                },
-                "cancelaccountid": {
-                    "description": "注销操作员账号",
-                    "type": "integer"
-                },
-                "canceltime": {
-                    "description": "注销时间",
-                    "type": "string"
-                },
-                "closepricemode": {
-                    "description": "强平价格方式 - 1:市价 2:最新价 3:涨跌停(未实现)",
-                    "type": "integer"
-                },
-                "closepriceparam": {
-                    "description": "强平最新价浮动比例 - 方式为2时使用  (\u003c1)买 上浮 (1+x)*最新价卖 下浮 (1-x)*最新价",
-                    "type": "number"
-                },
-                "createtime": {
-                    "description": "创建时间",
-                    "type": "string"
-                },
-                "creatorid": {
-                    "description": "创建人",
-                    "type": "integer"
-                },
-                "currencyid": {
-                    "description": "报价货币ID",
-                    "type": "integer"
-                },
-                "cutmode": {
-                    "description": "斩仓方式 - 1:不斩仓 2:自动斩仓 3:半自动斩仓",
-                    "type": "integer"
-                },
-                "decimalplace": {
-                    "description": "报价小数位",
-                    "type": "integer"
-                },
-                "delistingdate": {
-                    "description": "商品退市时间(状态:退市) -- 已作废",
-                    "type": "string"
-                },
-                "delistingmode": {
-                    "description": "退市方式 - 1:退市平仓 2:退市交收 3:不处理(仅期权\\币币兑换)",
-                    "type": "integer"
-                },
-                "deliveryflag": {
-                    "description": "交割标志 - 0:不可交割  1:可交割",
-                    "type": "integer"
-                },
-                "forceclosemode": {
-                    "description": "定期强平方式 - 1:无 2:每日 3:每周 4:每月[收益权]",
-                    "type": "integer"
-                },
-                "forceclosevalue": {
-                    "description": "定期强平参数 [收益权]",
-                    "type": "integer"
-                },
                 "goodscode": {
                     "description": "商品代码(内部)",
                     "type": "string"
                 },
-                "goodscurrencyid": {
-                    "description": "合约货币ID",
-                    "type": "integer"
-                },
-                "goodsgroupid": {
-                    "description": "所属商品组ID",
-                    "type": "integer"
-                },
                 "goodsid": {
                     "description": "商品ID(自增ID SEQ_GOODS)",
                     "type": "integer"
@@ -4858,97 +4782,9 @@
                     "description": "商品名称",
                     "type": "string"
                 },
-                "goodsquotetype": {
-                    "description": "合约报价类型: 1-直接报价  2-间接报价",
-                    "type": "integer"
-                },
-                "goodsstatus": {
-                    "description": "商品状态- 1:待审核 2:未上市 3:上市 4:已注销 5:审核拒绝 6:退市 7:待退市",
-                    "type": "integer"
-                },
-                "goodstradetype": {
-                    "description": "商品交易权限类型 - 1:可建可平 3:不可建可平",
-                    "type": "integer"
-                },
-                "goodsunit": {
-                    "description": "报价单位",
-                    "type": "string"
-                },
-                "goodunitid": {
-                    "description": "报价单位ID",
-                    "type": "integer"
-                },
-                "hasquoter": {
-                    "description": "是否有报价商 - 0:无报价商 1:有报价商",
-                    "type": "integer"
-                },
-                "hqprotecttime": {
-                    "description": "行情保护时间(秒)",
-                    "type": "integer"
-                },
-                "innerdealmode": {
-                    "description": "内部成交方式[通道交易] - 1:净头寸 2:开平 3:平今",
-                    "type": "integer"
-                },
-                "isbuylimited": {
-                    "description": "是否限制建仓量 - 0:不限制 1:限制",
-                    "type": "integer"
-                },
-                "lasttradedate": {
-                    "description": "最后交易日期(状态:待退市)",
-                    "type": "string"
-                },
-                "listingdate": {
-                    "description": "交易开始日期",
-                    "type": "string"
-                },
                 "marketid": {
                     "description": "所属市场ID",
                     "type": "integer"
-                },
-                "modifierid": {
-                    "description": "修改人",
-                    "type": "integer"
-                },
-                "modifystatus": {
-                    "description": "变更状态 - 1:未变更 2:变更中 3:待审核 4:已审核",
-                    "type": "integer"
-                },
-                "modifytime": {
-                    "description": "修改时间",
-                    "type": "string"
-                },
-                "outerdealmode": {
-                    "description": "外部成交方式[通道交易]- 1:净头寸 2:开平 3:平今",
-                    "type": "integer"
-                },
-                "outgoodscode": {
-                    "description": "商品代码(外部)",
-                    "type": "string"
-                },
-                "qtydecimalplace": {
-                    "description": "成交量小数位",
-                    "type": "integer"
-                },
-                "quotegear": {
-                    "description": "行情档位(1-10)",
-                    "type": "integer"
-                },
-                "quoteminunit": {
-                    "description": "行情最小变动单位 [整数,报价小数位一起使用]",
-                    "type": "integer"
-                },
-                "quoteshowtype": {
-                    "description": "行情报价类型: 1:成交价 2:买卖中间价 3:含买价 4:含卖价做市模式固定为3:含买价",
-                    "type": "integer"
-                },
-                "quoteshowtypeinterval": {
-                    "description": "行情报价间隔时间(秒)(成交价时为0)",
-                    "type": "integer"
-                },
-                "remark": {
-                    "description": "备注",
-                    "type": "string"
                 }
             }
         },

+ 2 - 125
docs/swagger.yaml

@@ -1298,7 +1298,7 @@ definitions:
       goodses:
         description: 合约列表
         items:
-          $ref: '#/definitions/models.GoodsInfo'
+          $ref: '#/definitions/models.GoodsIDAndName'
         type: array
       oppositeusers:
         description: 对方账号列表
@@ -1480,143 +1480,20 @@ definitions:
     - autoid
     - divisioncode
     type: object
-  models.GoodsInfo:
+  models.GoodsIDAndName:
     properties:
-      agreeunit:
-        description: 合约单位
-        type: number
-      auditaccountid:
-        description: 审核操作员账号
-        type: integer
-      audittime:
-        description: 审核时间
-        type: string
-      cancelaccountid:
-        description: 注销操作员账号
-        type: integer
-      canceltime:
-        description: 注销时间
-        type: string
-      closepricemode:
-        description: 强平价格方式 - 1:市价 2:最新价 3:涨跌停(未实现)
-        type: integer
-      closepriceparam:
-        description: 强平最新价浮动比例 - 方式为2时使用  (<1)买 上浮 (1+x)*最新价卖 下浮 (1-x)*最新价
-        type: number
-      createtime:
-        description: 创建时间
-        type: string
-      creatorid:
-        description: 创建人
-        type: integer
-      currencyid:
-        description: 报价货币ID
-        type: integer
-      cutmode:
-        description: 斩仓方式 - 1:不斩仓 2:自动斩仓 3:半自动斩仓
-        type: integer
-      decimalplace:
-        description: 报价小数位
-        type: integer
-      delistingdate:
-        description: 商品退市时间(状态:退市) -- 已作废
-        type: string
-      delistingmode:
-        description: 退市方式 - 1:退市平仓 2:退市交收 3:不处理(仅期权\币币兑换)
-        type: integer
-      deliveryflag:
-        description: 交割标志 - 0:不可交割  1:可交割
-        type: integer
-      forceclosemode:
-        description: 定期强平方式 - 1:无 2:每日 3:每周 4:每月[收益权]
-        type: integer
-      forceclosevalue:
-        description: 定期强平参数 [收益权]
-        type: integer
       goodscode:
         description: 商品代码(内部)
         type: string
-      goodscurrencyid:
-        description: 合约货币ID
-        type: integer
-      goodsgroupid:
-        description: 所属商品组ID
-        type: integer
       goodsid:
         description: 商品ID(自增ID SEQ_GOODS)
         type: integer
       goodsname:
         description: 商品名称
         type: string
-      goodsquotetype:
-        description: '合约报价类型: 1-直接报价  2-间接报价'
-        type: integer
-      goodsstatus:
-        description: 商品状态- 1:待审核 2:未上市 3:上市 4:已注销 5:审核拒绝 6:退市 7:待退市
-        type: integer
-      goodstradetype:
-        description: 商品交易权限类型 - 1:可建可平 3:不可建可平
-        type: integer
-      goodsunit:
-        description: 报价单位
-        type: string
-      goodunitid:
-        description: 报价单位ID
-        type: integer
-      hasquoter:
-        description: 是否有报价商 - 0:无报价商 1:有报价商
-        type: integer
-      hqprotecttime:
-        description: 行情保护时间(秒)
-        type: integer
-      innerdealmode:
-        description: 内部成交方式[通道交易] - 1:净头寸 2:开平 3:平今
-        type: integer
-      isbuylimited:
-        description: 是否限制建仓量 - 0:不限制 1:限制
-        type: integer
-      lasttradedate:
-        description: 最后交易日期(状态:待退市)
-        type: string
-      listingdate:
-        description: 交易开始日期
-        type: string
       marketid:
         description: 所属市场ID
         type: integer
-      modifierid:
-        description: 修改人
-        type: integer
-      modifystatus:
-        description: 变更状态 - 1:未变更 2:变更中 3:待审核 4:已审核
-        type: integer
-      modifytime:
-        description: 修改时间
-        type: string
-      outerdealmode:
-        description: 外部成交方式[通道交易]- 1:净头寸 2:开平 3:平今
-        type: integer
-      outgoodscode:
-        description: 商品代码(外部)
-        type: string
-      qtydecimalplace:
-        description: 成交量小数位
-        type: integer
-      quotegear:
-        description: 行情档位(1-10)
-        type: integer
-      quoteminunit:
-        description: 行情最小变动单位 [整数,报价小数位一起使用]
-        type: integer
-      quoteshowtype:
-        description: '行情报价类型: 1:成交价 2:买卖中间价 3:含买价 4:含卖价做市模式固定为3:含买价'
-        type: integer
-      quoteshowtypeinterval:
-        description: 行情报价间隔时间(秒)(成交价时为0)
-        type: integer
-      remark:
-        description: 备注
-        type: string
     required:
     - goodscode
     - goodsid

+ 3 - 3
models/account.go

@@ -415,14 +415,14 @@ func GetUserAccount(userID int) (*Useraccount, error) {
 func GetUserInfo(userID int) (*Userinfo, error) {
 	engine := db.GetEngine()
 
-	var userInfo *Userinfo
-	_, err := engine.Where("USERID = ?", userID).Get(userInfo)
+	var userInfo Userinfo
+	_, err := engine.Where("USERID = ?", userID).Get(&userInfo)
 	if err != nil {
 		// 查询失败
 		return nil, err
 	}
 
-	return userInfo, nil
+	return &userInfo, nil
 }
 
 // GetUserFavoriteGoodses 获取用户商品收藏信息

+ 13 - 6
models/goods.go

@@ -111,20 +111,27 @@ func GetGoodsesByStatus(goodsStatus int) ([]GoodsInfo, error) {
 	return goodsInfos, nil
 }
 
+// GoodsIDAndName 商品ID与名称
+type GoodsIDAndName struct {
+	Goodsid   int64  `json:"goodsid"  xorm:"'GOODSID'" binding:"required"`     // 商品ID(自增ID SEQ_GOODS)
+	Goodscode string `json:"goodscode"  xorm:"'GOODSCODE'" binding:"required"` // 商品代码(内部)
+	Goodsname string `json:"goodsname"  xorm:"'GOODSNAME'" binding:"required"` // 商品名称
+	Marketid  int64  `json:"marketid"  xorm:"'MARKETID'" binding:"required"`   // 所属市场ID
+}
+
 // GetGoodsInfosByTradeModes 获取指定交易模式的商品信息
 // 输入 tradeModes string 交易模式列表,格式 1,2,3
-func GetGoodsInfosByTradeModes(tradeModes string) ([]GoodsInfo, error) {
+func GetGoodsInfosByTradeModes(tradeModes string) ([]GoodsIDAndName, error) {
 	engine := db.GetEngine()
 
-	goodsInfos := make([]GoodsInfo, 0)
-	if err := engine.Table("GOODS").Select("GOODS.*, E1.ENUMDICNAME GOODSUNIT").
+	goodsIDAndNames := make([]GoodsIDAndName, 0)
+	if err := engine.Table("GOODS").Select("GOODS.*").
 		Join("LEFT", "MARKET M", "M.MARKETID = GOODS.MARKETID").
-		Join("LEFT", "ENUMDICITEM E1", "E1.ENUMITEMNAME = GOODS.GOODUNITID and E1.ENUMDICCODE = 'GOODSUNIT'").
-		Where("GOODS.GOODSSTATUS = 3 and M.TRADEMODE IN (?)", tradeModes).Find(&goodsInfos); err != nil {
+		Where("GOODS.GOODSSTATUS = 3 and M.TRADEMODE IN (?)", tradeModes).Find(&goodsIDAndNames); err != nil {
 		return nil, err
 	}
 
-	return goodsInfos, nil
+	return goodsIDAndNames, nil
 }
 
 // SearchGoods 检索商品信息

+ 6 - 0
token/token.go

@@ -3,6 +3,7 @@ package token
 import (
 	"errors"
 	"fmt"
+	"mtp2_if/config"
 	"mtp2_if/global/e"
 	"mtp2_if/rediscli"
 	"net/http"
@@ -31,6 +32,11 @@ func CheckToken(loginid string, token string) error {
 // Auth Token校验中间件
 func Auth() gin.HandlerFunc {
 	return func(c *gin.Context) {
+		if config.SerCfg.GetDebugMode() {
+			c.Next()
+			return
+		}
+
 		var code int
 		var data interface{}