浏览代码

查询现货合同条件修改

zou.yingbin 4 年之前
父节点
当前提交
d65fa96ea2
共有 5 个文件被更改,包括 28 次插入24 次删除
  1. 8 8
      controllers/ermcp3/qryErmcp3.go
  2. 3 3
      docs/docs.go
  3. 3 3
      docs/swagger.json
  4. 3 3
      docs/swagger.yaml
  5. 11 7
      models/ermcp3.go

+ 8 - 8
controllers/ermcp3/qryErmcp3.go

@@ -91,22 +91,22 @@ func QueryMiddleGoodsDetail(c *gin.Context) {
 
 // QryContractReq 查询合同请求
 type QryContractReq struct {
-	AreadUserId  int64  `form:"userid" binding:"required"`    // 所属机构Id
-	CONTRACTTYPE int32  `form:"contracttype"`                 // 合同类型 1-采购, -1-销售
-	QUERYTYPE    int32  `form:"querytype" binding:"required"` // 查询类型
-	USERID       int64  `form:"userid"`                       // 用户Id
-	USERTYPE     int32  `form:"usertype"`                     // 用户类型
-	CONTRACTID   string `form:"contractid"`                   // 合同ID(SpotContractId)
+	AreadUserId  int64  `form:"userid"`       // 所属机构Id
+	CONTRACTTYPE int32  `form:"contracttype"` // 合同类型 1-采购, -1-销售
+	QUERYTYPE    int32  `form:"querytype"`    // 查询类型
+	USERID       int64  `form:"userid"`       // 用户Id
+	USERTYPE     int32  `form:"usertype"`     // 用户类型
+	CONTRACTID   string `form:"contractid"`   // 合同ID(SpotContractId)
 }
 
 // QuerySpotContract
 // @Summary 查询现货合同
 // @Produce json
 // @Security ApiKeyAuth
-// @Param userid query int true "用户id"
+// @Param userid query int true "用户id(当指定contractid, userid可不填)"
 // @Param usertype query int false "用户类型 2-机构 7-企业成员"
 // @Param contracttype query int false "合同类型 1-采购, -1-销售"
-// @Param querytype query int true "查询类型 1-未提交 2-待审核 3-履约中 4-已完成"
+// @Param querytype query int true "查询类型 1-未提交 2-待审核 3-履约中 4-已完成 (当指定contractid, querytype可不填)"
 // @Param contractid query string false "合同ID(SpotContractId)"
 // @Success 200 {array} models.Ermcp3Contract
 // @Failure 500 {object} app.Response

+ 3 - 3
docs/docs.go

@@ -4645,7 +4645,7 @@ var doc = `{
                 "parameters": [
                     {
                         "type": "integer",
-                        "description": "用户id",
+                        "description": "用户id(当指定contractid, userid可不填)",
                         "name": "userid",
                         "in": "query",
                         "required": true
@@ -4664,7 +4664,7 @@ var doc = `{
                     },
                     {
                         "type": "integer",
-                        "description": "查询类型 1-未提交 2-待审核 3-履约中 4-已完成",
+                        "description": "查询类型 1-未提交 2-待审核 3-履约中 4-已完成 (当指定contractid, querytype可不填)",
                         "name": "querytype",
                         "in": "query",
                         "required": true
@@ -36120,7 +36120,7 @@ var doc = `{
                     "type": "number"
                 },
                 "tv": {
-                    "description": "总量",
+                    "description": "总量(成交量)",
                     "type": "integer"
                 }
             }

+ 3 - 3
docs/swagger.json

@@ -4629,7 +4629,7 @@
                 "parameters": [
                     {
                         "type": "integer",
-                        "description": "用户id",
+                        "description": "用户id(当指定contractid, userid可不填)",
                         "name": "userid",
                         "in": "query",
                         "required": true
@@ -4648,7 +4648,7 @@
                     },
                     {
                         "type": "integer",
-                        "description": "查询类型 1-未提交 2-待审核 3-履约中 4-已完成",
+                        "description": "查询类型 1-未提交 2-待审核 3-履约中 4-已完成 (当指定contractid, querytype可不填)",
                         "name": "querytype",
                         "in": "query",
                         "required": true
@@ -36104,7 +36104,7 @@
                     "type": "number"
                 },
                 "tv": {
-                    "description": "总量",
+                    "description": "总量(成交量)",
                     "type": "integer"
                 }
             }

+ 3 - 3
docs/swagger.yaml

@@ -16988,7 +16988,7 @@ definitions:
         description: 总金额
         type: number
       tv:
-        description: 总量
+        description: 总量(成交量)
         type: integer
     type: object
   quote.HistoryTikData:
@@ -20934,7 +20934,7 @@ paths:
   /Ermcp3/QuerySpotContract:
     get:
       parameters:
-      - description: 用户id
+      - description: 用户id(当指定contractid, userid可不填)
         in: query
         name: userid
         required: true
@@ -20947,7 +20947,7 @@ paths:
         in: query
         name: contracttype
         type: integer
-      - description: 查询类型 1-未提交 2-待审核 3-履约中 4-已完成
+      - description: 查询类型 1-未提交 2-待审核 3-履约中 4-已完成 (当指定contractid, querytype可不填)
         in: query
         name: querytype
         required: true

+ 11 - 7
models/ermcp3.go

@@ -758,13 +758,17 @@ SELECT to_char(t.SPOTCONTRACTID) SPOTCONTRACTID,
     on t.applyid = l.loginid
  where 1 = 1
 `
-	sqlId.AndEx("t.SPOTCONTRACTID", r.SPOTCONTRACTID, len(r.SPOTCONTRACTID) > 0)
-	sqlId.AndEx("t.CONTRACTTYPE", r.CONTRACTTYPE, r.CONTRACTTYPE != 0)
-	// 用户条件
-	sqlId.Join(fmt.Sprintf(" and %v in(t.userid, t.saleuserid, t.tradeuserid, t.meruserid, l.userid)", r.OwnUserId))
-	status := r.getQryTypeStatus()
-	if len(status) > 0 {
-		sqlId.Join(fmt.Sprintf(" and t.contractstatus in (%v)", status))
+	if len(r.SPOTCONTRACTID) > 0 {
+		// 如果指定了合同id, 合同id是key , 则不需要再判断其它条件
+		sqlId.AndEx("t.SPOTCONTRACTID", r.SPOTCONTRACTID, len(r.SPOTCONTRACTID) > 0)
+	} else {
+		sqlId.AndEx("t.CONTRACTTYPE", r.CONTRACTTYPE, r.CONTRACTTYPE != 0)
+		// 用户条件
+		sqlId.Join(fmt.Sprintf(" and %v in(t.userid, t.saleuserid, t.tradeuserid, t.meruserid, l.userid)", r.OwnUserId))
+		status := r.getQryTypeStatus()
+		if len(status) > 0 {
+			sqlId.Join(fmt.Sprintf(" and t.contractstatus in (%v)", status))
+		}
 	}
 
 	return sqlId.String()