Преглед на файлове

查询合同新接口、其它接口加字段

zou.yingbin преди 4 години
родител
ревизия
ef67ba82fb
променени са 8 файла, в които са добавени 2166 реда и са изтрити 133 реда
  1. 56 0
      controllers/ermcp3/qryErmcp3.go
  2. 641 39
      docs/docs.go
  3. 641 39
      docs/swagger.json
  4. 451 16
      docs/swagger.yaml
  5. 324 1
      models/ermcp3.go
  6. 34 26
      models/ermcpOPApply.go
  7. 17 12
      models/ermcpWrstandard.go
  8. 2 0
      routers/router.go

+ 56 - 0
controllers/ermcp3/qryErmcp3.go

@@ -57,3 +57,59 @@ func QueryDeliveryGoodsDetail(c *gin.Context) {
 		QryTradeGoods: req.QryTradeGoods}
 	a.DoGetDataI(&m)
 }
+
+// QryContractReq 查询合同请求
+type QryContractReq struct {
+	AreadUserId  int64  `form:"areauserid" binding:"required"`   // 所属机构Id
+	CONTRACTTYPE int32  `form:"contracttype" binding:"required"` // 合同类型 1-采购, -1-销售
+	QUERYTYPE    int64  `form:"querytype" binding:"required"`    // 查询类型 1-全部 2-待点价 3-履约结算 4-已完成
+	USERID       int64  `form:"userid"`                          // 用户Id
+	USERTYPE     int32  `form:"usertype"`                        // 用户类型
+	CONTRACTID   string `form:"contractid"`                      // 合同ID(SpotContractId)
+}
+
+// QuerySpotContract
+// @Summary 查询现货合同
+// @Produce json
+// @Security ApiKeyAuth
+// @Param areauserid query int true "所属机构ID"
+// @Param contracttype query int true "合同类型 1-采购, -1-销售"
+// @Param querytype query int true "查询类型 1-全部 2-待点价 3-履约结算 4-已完成"
+// @Param userid query int false "用户ID"
+// @Param usertype query int false "用户类型 2-机构 7-企业成员"
+// @Param contractid query string false "合同ID(SpotContractId)"
+// @Success 200 {array} models.Ermcp3Contract
+// @Failure 500 {object} app.Response
+// @Router /Ermcp3/QuerySpotContract [get]
+// @Tags 企业风险管理v3(app)
+func QuerySpotContract(c *gin.Context) {
+	a := app.GinUtils{Gin: app.Gin{C: c}}
+	req := QryContractReq{}
+	a.DoBindReq(&req)
+	m := models.Ermcp3Contract{USERID: req.AreadUserId, CONTRACTTYPE: req.CONTRACTTYPE,
+		OwnUserId: req.USERID, UserType: req.USERTYPE, SPOTCONTRACTID: req.CONTRACTID}
+	a.DoGetDataI(&m)
+}
+
+// QuerySpotContractBS
+// @Summary 查询合同(采购/销售)
+// @Produce json
+// @Security ApiKeyAuth
+// @Param areauserid query int true "所属机构ID"
+// @Param contracttype query int true "合同类型 1-采购, -1-销售"
+// @Param querytype query int true "查询类型 1-全部 2-待点价 3-履约结算 4-已完成"
+// @Param userid query int false "用户ID"
+// @Param usertype query int false "用户类型 2-机构 7-企业成员"
+// @Param contractid query string false "合同ID(SpotContractId)"
+// @Success 200 {array} models.Ermcp3SellBuyContract
+// @Failure 500 {object} app.Response
+// @Router /Ermcp3/QuerySpotContractBS [get]
+// @Tags 企业风险管理v3(app)
+func QuerySpotContractBS(c *gin.Context) {
+	a := app.GinUtils{Gin: app.Gin{C: c}}
+	req := QryContractReq{}
+	a.DoBindReq(&req)
+	m := models.Ermcp3SellBuyContract{UserID: req.AreadUserId, Contracttype: req.CONTRACTTYPE,
+		OwnUserId: req.USERID, UserType: req.USERTYPE, SpotContractId: req.CONTRACTID}
+	a.DoGetDataI(&m)
+}

+ 641 - 39
docs/docs.go

@@ -4119,6 +4119,154 @@ var doc = `{
                 }
             }
         },
+        "/Ermcp3/QuerySpotContract": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理v3(app)"
+                ],
+                "summary": "查询现货合同",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "所属机构ID",
+                        "name": "areauserid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "合同类型 1-采购, -1-销售",
+                        "name": "contracttype",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "查询类型 1-全部 2-待点价 3-履约结算 4-已完成",
+                        "name": "querytype",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "用户ID",
+                        "name": "userid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "用户类型 2-机构 7-企业成员",
+                        "name": "usertype",
+                        "in": "query"
+                    },
+                    {
+                        "type": "string",
+                        "description": "合同ID(SpotContractId)",
+                        "name": "contractid",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.Ermcp3Contract"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
+        "/Ermcp3/QuerySpotContractBS": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理v3(app)"
+                ],
+                "summary": "查询合同(采购/销售)",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "所属机构ID",
+                        "name": "areauserid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "合同类型 1-采购, -1-销售",
+                        "name": "contracttype",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "查询类型 1-全部 2-待点价 3-履约结算 4-已完成",
+                        "name": "querytype",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "用户ID",
+                        "name": "userid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "用户类型 2-机构 7-企业成员",
+                        "name": "usertype",
+                        "in": "query"
+                    },
+                    {
+                        "type": "string",
+                        "description": "合同ID(SpotContractId)",
+                        "name": "contractid",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.Ermcp3SellBuyContract"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Erms2/QueryArbitrageStrategy": {
             "get": {
                 "security": [
@@ -9082,6 +9230,18 @@ var doc = `{
                     "description": "现货合同类型 - 1:采购 -1:销售",
                     "type": "integer"
                 },
+                "deliverygoodscode": {
+                    "description": "现货品种代码",
+                    "type": "string"
+                },
+                "deliverygoodsid": {
+                    "description": "现货商品ID",
+                    "type": "integer"
+                },
+                "deliverygoodsname": {
+                    "description": "现货品种名称",
+                    "type": "string"
+                },
                 "enumdicname": {
                     "description": "单位名称",
                     "type": "string"
@@ -9131,15 +9291,15 @@ var doc = `{
                     "type": "integer"
                 },
                 "wrstandardcode": {
-                    "description": "现货商品代码",
+                    "description": "品代码",
                     "type": "string"
                 },
                 "wrstandardid": {
-                    "description": "现货商品id",
+                    "description": "品id",
                     "type": "integer"
                 },
                 "wrstandardname": {
-                    "description": "现货商品名称",
+                    "description": "品名称",
                     "type": "string"
                 }
             }
@@ -9195,6 +9355,18 @@ var doc = `{
                     "description": "现货合同类型 - 1:采购 -1:销售",
                     "type": "integer"
                 },
+                "deliverygoodscode": {
+                    "description": "现货品种代码",
+                    "type": "string"
+                },
+                "deliverygoodsid": {
+                    "description": "现货商品ID",
+                    "type": "integer"
+                },
+                "deliverygoodsname": {
+                    "description": "现货品种名称",
+                    "type": "string"
+                },
                 "enumdicname": {
                     "description": "单位名称",
                     "type": "string"
@@ -9240,15 +9412,15 @@ var doc = `{
                     "type": "integer"
                 },
                 "wrstandardcode": {
-                    "description": "现货商品代码",
+                    "description": "品代码",
                     "type": "string"
                 },
                 "wrstandardid": {
-                    "description": "现货商品id",
+                    "description": "品id",
                     "type": "integer"
                 },
                 "wrstandardname": {
-                    "description": "现货商品名称",
+                    "description": "品名称",
                     "type": "string"
                 }
             }
@@ -9304,6 +9476,18 @@ var doc = `{
                     "description": "现货合同类型 - 1:采购 -1:销售",
                     "type": "integer"
                 },
+                "deliverygoodscode": {
+                    "description": "现货品种代码",
+                    "type": "string"
+                },
+                "deliverygoodsid": {
+                    "description": "现货商品ID",
+                    "type": "integer"
+                },
+                "deliverygoodsname": {
+                    "description": "现货品种名称",
+                    "type": "string"
+                },
                 "enumdicname": {
                     "description": "单位名称",
                     "type": "string"
@@ -9353,15 +9537,15 @@ var doc = `{
                     "type": "integer"
                 },
                 "wrstandardcode": {
-                    "description": "现货商品代码",
+                    "description": "品代码",
                     "type": "string"
                 },
                 "wrstandardid": {
-                    "description": "现货商品id",
+                    "description": "品id",
                     "type": "integer"
                 },
                 "wrstandardname": {
-                    "description": "现货商品名称",
+                    "description": "品名称",
                     "type": "string"
                 }
             }
@@ -9425,6 +9609,18 @@ var doc = `{
                     "description": "减少保证金(非必填)",
                     "type": "number"
                 },
+                "deliverygoodscode": {
+                    "description": "现货品种代码",
+                    "type": "string"
+                },
+                "deliverygoodsid": {
+                    "description": "现货商品ID",
+                    "type": "integer"
+                },
+                "deliverygoodsname": {
+                    "description": "现货品种名称",
+                    "type": "string"
+                },
                 "enumdicname": {
                     "description": "单位名称",
                     "type": "string"
@@ -9482,15 +9678,15 @@ var doc = `{
                     "type": "integer"
                 },
                 "wrstandardcode": {
-                    "description": "现货商品代码",
+                    "description": "品代码",
                     "type": "string"
                 },
                 "wrstandardid": {
-                    "description": "现货商品id",
+                    "description": "品id",
                     "type": "integer"
                 },
                 "wrstandardname": {
-                    "description": "现货商品名称",
+                    "description": "品名称",
                     "type": "string"
                 }
             }
@@ -9550,6 +9746,18 @@ var doc = `{
                     "description": "退款(非必填)",
                     "type": "number"
                 },
+                "deliverygoodscode": {
+                    "description": "现货品种代码",
+                    "type": "string"
+                },
+                "deliverygoodsid": {
+                    "description": "现货商品ID",
+                    "type": "integer"
+                },
+                "deliverygoodsname": {
+                    "description": "现货品种名称",
+                    "type": "string"
+                },
                 "enumdicname": {
                     "description": "单位名称",
                     "type": "string"
@@ -9599,15 +9807,15 @@ var doc = `{
                     "type": "integer"
                 },
                 "wrstandardcode": {
-                    "description": "现货商品代码",
+                    "description": "品代码",
                     "type": "string"
                 },
                 "wrstandardid": {
-                    "description": "现货商品id",
+                    "description": "品id",
                     "type": "integer"
                 },
                 "wrstandardname": {
-                    "description": "现货商品名称",
+                    "description": "品名称",
                     "type": "string"
                 }
             }
@@ -11849,42 +12057,428 @@ var doc = `{
                 }
             }
         },
-        "models.ErmcpAreaSpotDetailModel": {
+        "models.Ermcp3Contract": {
             "type": "object",
             "properties": {
-                "contracttype": {
-                    "description": "合同类型 1-采购 -1-销售",
-                    "type": "integer"
+                "amount": {
+                    "description": "金额 [1:一口价、3:暂定价]",
+                    "type": "number"
                 },
-                "createtime": {
-                    "description": "创建时间",
+                "attachment": {
+                    "description": "附件",
                     "type": "string"
                 },
-                "enumdicname": {
-                    "description": "现货商品单位名称",
+                "auditremark": {
+                    "description": "审核意见",
                     "type": "string"
                 },
-                "logtype": {
-                    "description": "记录类型 1-套保 2-现货合同",
-                    "type": "integer"
-                },
-                "qty": {
-                    "description": "数量",
-                    "type": "number"
-                },
-                "recordname": {
-                    "description": "类型名称",
+                "audittime": {
+                    "description": "审核时间",
                     "type": "string"
                 },
-                "relatedid": {
-                    "description": "套保计划ID/现货合同ID",
+                "brandname": {
+                    "description": "品牌名称",
                     "type": "string"
                 },
-                "relatedno": {
-                    "description": "编号",
+                "buyuserid": {
+                    "description": "采购方ID",
+                    "type": "integer"
+                },
+                "buyusername": {
+                    "description": "采购方名称",
                     "type": "string"
                 },
-                "strtime": {
+                "contracctstatus": {
+                    "description": "合同状态 - 0:未提交 1:待审核 2:执行中 3:正常完结 4:审核拒绝 5:异常完结 6:已撤回",
+                    "type": "integer"
+                },
+                "contractmargin": {
+                    "description": "合同保证金",
+                    "type": "number"
+                },
+                "contractno": {
+                    "description": "现货合同编号",
+                    "type": "string"
+                },
+                "contracttype": {
+                    "description": "现货合同类型 - 1:采购 -1:销售",
+                    "type": "integer"
+                },
+                "convertfactor": {
+                    "description": "标仓系数(品类)",
+                    "type": "number"
+                },
+                "createtime": {
+                    "description": "创建时间",
+                    "type": "string"
+                },
+                "deliveryenddate": {
+                    "description": "交收期(结束)",
+                    "type": "string"
+                },
+                "deliverygoodscode": {
+                    "description": "现货品种代码",
+                    "type": "string"
+                },
+                "deliverygoodsid": {
+                    "description": "现货品种ID",
+                    "type": "integer"
+                },
+                "deliverygoodsname": {
+                    "description": "现货品种名称",
+                    "type": "string"
+                },
+                "deliverystartdate": {
+                    "description": "交收期(开始)",
+                    "type": "string"
+                },
+                "enddate": {
+                    "description": "点价结束日期 [2:点价 3:暂定价]",
+                    "type": "string"
+                },
+                "enumdicname": {
+                    "description": "单位名称",
+                    "type": "string"
+                },
+                "goodscode": {
+                    "description": "点价合约代码",
+                    "type": "string"
+                },
+                "goodsid": {
+                    "description": "点价合约ID - 0:为现货,其它为期货商品合约ID [2:点价 3:暂定价]",
+                    "type": "integer"
+                },
+                "goodsname": {
+                    "description": "点价商品名称",
+                    "type": "string"
+                },
+                "margin": {
+                    "description": "当前保证金",
+                    "type": "number"
+                },
+                "price": {
+                    "description": "价格\\暂定价 [1:一口价、3:暂定价]",
+                    "type": "number"
+                },
+                "pricemove": {
+                    "description": "升贴水 [2:点价 3:暂定价]",
+                    "type": "number"
+                },
+                "pricetype": {
+                    "description": "定价类型 - 1:一口价 2:点价 3:暂定价",
+                    "type": "integer"
+                },
+                "producttype": {
+                    "description": "产品类型 - 1:标准仓单 2:等标 3:非标",
+                    "type": "integer"
+                },
+                "qty": {
+                    "description": "数量",
+                    "type": "number"
+                },
+                "remark": {
+                    "description": "备注",
+                    "type": "string"
+                },
+                "selluserid": {
+                    "description": "销售方ID",
+                    "type": "integer"
+                },
+                "sellusername": {
+                    "description": "销售方名称",
+                    "type": "string"
+                },
+                "spotcontractid": {
+                    "description": "现货合同ID(602+Unix秒时间戳(10位)+xxxxxx)",
+                    "type": "string"
+                },
+                "spotgoodsbrandid": {
+                    "description": "现货品牌ID(DGFactoryItem表的ID)",
+                    "type": "integer"
+                },
+                "spotgoodsdesc": {
+                    "description": "商品型号",
+                    "type": "string"
+                },
+                "startdate": {
+                    "description": "点价开始日期 [2:点价 3:暂定价]",
+                    "type": "string"
+                },
+                "unitid": {
+                    "description": "单位id(取品类上的单位id)",
+                    "type": "integer"
+                },
+                "updatetime": {
+                    "description": "更新时间",
+                    "type": "string"
+                },
+                "userid": {
+                    "description": "所属机构ID",
+                    "type": "integer"
+                },
+                "wrstandardcode": {
+                    "description": "品类代码",
+                    "type": "string"
+                },
+                "wrstandardid": {
+                    "description": "品类ID",
+                    "type": "integer"
+                },
+                "wrstandardname": {
+                    "description": "品类名称",
+                    "type": "string"
+                }
+            }
+        },
+        "models.Ermcp3SellBuyContract": {
+            "type": "object",
+            "properties": {
+                "accountname": {
+                    "description": "账户名称",
+                    "type": "string"
+                },
+                "attachment": {
+                    "description": "附件",
+                    "type": "string"
+                },
+                "audittime": {
+                    "description": "审核时间",
+                    "type": "string"
+                },
+                "brandname": {
+                    "description": "品牌名称",
+                    "type": "string"
+                },
+                "contracctstatus": {
+                    "description": "合同状态- 0:未提交 1:待审核 2:执行中 3:正常完结 4:审核拒绝 5:异常完结 6:已撤回",
+                    "type": "integer"
+                },
+                "contractmargin": {
+                    "description": "合同保证金",
+                    "type": "number"
+                },
+                "contractno": {
+                    "description": "合同编号",
+                    "type": "string"
+                },
+                "contracttype": {
+                    "description": "合同类型 1-采购, -1-销售",
+                    "type": "integer"
+                },
+                "convertfactor": {
+                    "description": "标仓系数(品类)",
+                    "type": "number"
+                },
+                "createtime": {
+                    "description": "创建时间",
+                    "type": "string"
+                },
+                "daikaiamount": {
+                    "description": "应收(开)票额",
+                    "type": "number"
+                },
+                "deliveryenddate": {
+                    "description": "交割结束日",
+                    "type": "string"
+                },
+                "deliverygoodscode": {
+                    "description": "现货品种代码",
+                    "type": "string"
+                },
+                "deliverygoodsid": {
+                    "description": "现货商品ID",
+                    "type": "integer"
+                },
+                "deliverygoodsname": {
+                    "description": "现货品种名称",
+                    "type": "string"
+                },
+                "deliverystartdate": {
+                    "description": "交割开始日",
+                    "type": "string"
+                },
+                "enddate": {
+                    "description": "点价结束日",
+                    "type": "string"
+                },
+                "enumdicname": {
+                    "description": "单位名称",
+                    "type": "string"
+                },
+                "goodscode": {
+                    "description": "点价商品代码",
+                    "type": "string"
+                },
+                "goodsid": {
+                    "description": "点价商品ID",
+                    "type": "integer"
+                },
+                "goodsname": {
+                    "description": "点价商品名称",
+                    "type": "string"
+                },
+                "invoiceamount": {
+                    "description": "已开票额",
+                    "type": "number"
+                },
+                "loanamount": {
+                    "description": "贷款总额=已定价额+调整金额",
+                    "type": "number"
+                },
+                "margin": {
+                    "description": "保证金",
+                    "type": "number"
+                },
+                "payamount": {
+                    "description": "已收付额(收款或付款)",
+                    "type": "number"
+                },
+                "preinvoiceamount": {
+                    "description": "预收(开)票额",
+                    "type": "number"
+                },
+                "prepayamount": {
+                    "description": "预收付额",
+                    "type": "number"
+                },
+                "price": {
+                    "description": "价格",
+                    "type": "number"
+                },
+                "pricedamount": {
+                    "description": "已定价额",
+                    "type": "number"
+                },
+                "pricedavg": {
+                    "description": "已点均价",
+                    "type": "number"
+                },
+                "pricedqty": {
+                    "description": "已定价量",
+                    "type": "number"
+                },
+                "pricemove": {
+                    "description": "升贴水",
+                    "type": "number"
+                },
+                "pricetype": {
+                    "description": "定价类型 - 1:一口价 2:点价 3:暂定价",
+                    "type": "integer"
+                },
+                "producttype": {
+                    "description": "产品类型 - 1:标准仓单 2:等标 3:非标",
+                    "type": "integer"
+                },
+                "qty": {
+                    "description": "合同量",
+                    "type": "number"
+                },
+                "reckonadjustamount": {
+                    "description": "调整金额",
+                    "type": "number"
+                },
+                "reckonedamount": {
+                    "description": "实际已收付额(已确定额,已收付总额-已退款总额)",
+                    "type": "number"
+                },
+                "reckonotheramount": {
+                    "description": "其它费用",
+                    "type": "number"
+                },
+                "reckonrealqty": {
+                    "description": "已确定量",
+                    "type": "number"
+                },
+                "remark": {
+                    "description": "备注",
+                    "type": "string"
+                },
+                "spotcontractid": {
+                    "description": "合同ID",
+                    "type": "string"
+                },
+                "spotgoodsbrandid": {
+                    "description": "现货品牌ID(DGFactoryItem表的ID)",
+                    "type": "integer"
+                },
+                "spotgoodsdesc": {
+                    "description": "商品型号(商品规格)",
+                    "type": "string"
+                },
+                "startdate": {
+                    "description": "点价开始日",
+                    "type": "string"
+                },
+                "totalamount": {
+                    "description": "合计总额",
+                    "type": "number"
+                },
+                "unpayamount": {
+                    "description": "应收付款额(应支付或应收款)",
+                    "type": "number"
+                },
+                "unpricedqty": {
+                    "description": "未定价量",
+                    "type": "number"
+                },
+                "unsureqty": {
+                    "description": "未确定量",
+                    "type": "number"
+                },
+                "userid": {
+                    "description": "机构ID",
+                    "type": "integer"
+                },
+                "wrstandardcode": {
+                    "description": "品类代码",
+                    "type": "string"
+                },
+                "wrstandardid": {
+                    "description": "品类ID",
+                    "type": "integer"
+                },
+                "wrstandardname": {
+                    "description": "品类名称",
+                    "type": "string"
+                }
+            }
+        },
+        "models.ErmcpAreaSpotDetailModel": {
+            "type": "object",
+            "properties": {
+                "contracttype": {
+                    "description": "合同类型 1-采购 -1-销售",
+                    "type": "integer"
+                },
+                "createtime": {
+                    "description": "创建时间",
+                    "type": "string"
+                },
+                "enumdicname": {
+                    "description": "现货商品单位名称",
+                    "type": "string"
+                },
+                "logtype": {
+                    "description": "记录类型 1-套保 2-现货合同",
+                    "type": "integer"
+                },
+                "qty": {
+                    "description": "数量",
+                    "type": "number"
+                },
+                "recordname": {
+                    "description": "类型名称",
+                    "type": "string"
+                },
+                "relatedid": {
+                    "description": "套保计划ID/现货合同ID",
+                    "type": "string"
+                },
+                "relatedno": {
+                    "description": "编号",
+                    "type": "string"
+                },
+                "strtime": {
                     "description": "时间",
                     "type": "string"
                 },
@@ -19398,10 +19992,18 @@ var doc = `{
                     "description": "套保系数",
                     "type": "number"
                 },
+                "deliverygoodscode": {
+                    "description": "现货商品代码",
+                    "type": "string"
+                },
                 "deliverygoodsid": {
                     "description": "现货品种ID",
                     "type": "integer"
                 },
+                "deliverygoodsname": {
+                    "description": "现货商品名称",
+                    "type": "string"
+                },
                 "enumdicname": {
                     "description": "单位名称",
                     "type": "string"
@@ -19427,7 +20029,7 @@ var doc = `{
                     "type": "string"
                 },
                 "wrstandardid": {
-                    "description": "现货商品ID",
+                    "description": "品ID",
                     "type": "integer"
                 }
             }

+ 641 - 39
docs/swagger.json

@@ -4103,6 +4103,154 @@
                 }
             }
         },
+        "/Ermcp3/QuerySpotContract": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理v3(app)"
+                ],
+                "summary": "查询现货合同",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "所属机构ID",
+                        "name": "areauserid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "合同类型 1-采购, -1-销售",
+                        "name": "contracttype",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "查询类型 1-全部 2-待点价 3-履约结算 4-已完成",
+                        "name": "querytype",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "用户ID",
+                        "name": "userid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "用户类型 2-机构 7-企业成员",
+                        "name": "usertype",
+                        "in": "query"
+                    },
+                    {
+                        "type": "string",
+                        "description": "合同ID(SpotContractId)",
+                        "name": "contractid",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.Ermcp3Contract"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
+        "/Ermcp3/QuerySpotContractBS": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理v3(app)"
+                ],
+                "summary": "查询合同(采购/销售)",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "所属机构ID",
+                        "name": "areauserid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "合同类型 1-采购, -1-销售",
+                        "name": "contracttype",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "查询类型 1-全部 2-待点价 3-履约结算 4-已完成",
+                        "name": "querytype",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "用户ID",
+                        "name": "userid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "用户类型 2-机构 7-企业成员",
+                        "name": "usertype",
+                        "in": "query"
+                    },
+                    {
+                        "type": "string",
+                        "description": "合同ID(SpotContractId)",
+                        "name": "contractid",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.Ermcp3SellBuyContract"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Erms2/QueryArbitrageStrategy": {
             "get": {
                 "security": [
@@ -9066,6 +9214,18 @@
                     "description": "现货合同类型 - 1:采购 -1:销售",
                     "type": "integer"
                 },
+                "deliverygoodscode": {
+                    "description": "现货品种代码",
+                    "type": "string"
+                },
+                "deliverygoodsid": {
+                    "description": "现货商品ID",
+                    "type": "integer"
+                },
+                "deliverygoodsname": {
+                    "description": "现货品种名称",
+                    "type": "string"
+                },
                 "enumdicname": {
                     "description": "单位名称",
                     "type": "string"
@@ -9115,15 +9275,15 @@
                     "type": "integer"
                 },
                 "wrstandardcode": {
-                    "description": "现货商品代码",
+                    "description": "品代码",
                     "type": "string"
                 },
                 "wrstandardid": {
-                    "description": "现货商品id",
+                    "description": "品id",
                     "type": "integer"
                 },
                 "wrstandardname": {
-                    "description": "现货商品名称",
+                    "description": "品名称",
                     "type": "string"
                 }
             }
@@ -9179,6 +9339,18 @@
                     "description": "现货合同类型 - 1:采购 -1:销售",
                     "type": "integer"
                 },
+                "deliverygoodscode": {
+                    "description": "现货品种代码",
+                    "type": "string"
+                },
+                "deliverygoodsid": {
+                    "description": "现货商品ID",
+                    "type": "integer"
+                },
+                "deliverygoodsname": {
+                    "description": "现货品种名称",
+                    "type": "string"
+                },
                 "enumdicname": {
                     "description": "单位名称",
                     "type": "string"
@@ -9224,15 +9396,15 @@
                     "type": "integer"
                 },
                 "wrstandardcode": {
-                    "description": "现货商品代码",
+                    "description": "品代码",
                     "type": "string"
                 },
                 "wrstandardid": {
-                    "description": "现货商品id",
+                    "description": "品id",
                     "type": "integer"
                 },
                 "wrstandardname": {
-                    "description": "现货商品名称",
+                    "description": "品名称",
                     "type": "string"
                 }
             }
@@ -9288,6 +9460,18 @@
                     "description": "现货合同类型 - 1:采购 -1:销售",
                     "type": "integer"
                 },
+                "deliverygoodscode": {
+                    "description": "现货品种代码",
+                    "type": "string"
+                },
+                "deliverygoodsid": {
+                    "description": "现货商品ID",
+                    "type": "integer"
+                },
+                "deliverygoodsname": {
+                    "description": "现货品种名称",
+                    "type": "string"
+                },
                 "enumdicname": {
                     "description": "单位名称",
                     "type": "string"
@@ -9337,15 +9521,15 @@
                     "type": "integer"
                 },
                 "wrstandardcode": {
-                    "description": "现货商品代码",
+                    "description": "品代码",
                     "type": "string"
                 },
                 "wrstandardid": {
-                    "description": "现货商品id",
+                    "description": "品id",
                     "type": "integer"
                 },
                 "wrstandardname": {
-                    "description": "现货商品名称",
+                    "description": "品名称",
                     "type": "string"
                 }
             }
@@ -9409,6 +9593,18 @@
                     "description": "减少保证金(非必填)",
                     "type": "number"
                 },
+                "deliverygoodscode": {
+                    "description": "现货品种代码",
+                    "type": "string"
+                },
+                "deliverygoodsid": {
+                    "description": "现货商品ID",
+                    "type": "integer"
+                },
+                "deliverygoodsname": {
+                    "description": "现货品种名称",
+                    "type": "string"
+                },
                 "enumdicname": {
                     "description": "单位名称",
                     "type": "string"
@@ -9466,15 +9662,15 @@
                     "type": "integer"
                 },
                 "wrstandardcode": {
-                    "description": "现货商品代码",
+                    "description": "品代码",
                     "type": "string"
                 },
                 "wrstandardid": {
-                    "description": "现货商品id",
+                    "description": "品id",
                     "type": "integer"
                 },
                 "wrstandardname": {
-                    "description": "现货商品名称",
+                    "description": "品名称",
                     "type": "string"
                 }
             }
@@ -9534,6 +9730,18 @@
                     "description": "退款(非必填)",
                     "type": "number"
                 },
+                "deliverygoodscode": {
+                    "description": "现货品种代码",
+                    "type": "string"
+                },
+                "deliverygoodsid": {
+                    "description": "现货商品ID",
+                    "type": "integer"
+                },
+                "deliverygoodsname": {
+                    "description": "现货品种名称",
+                    "type": "string"
+                },
                 "enumdicname": {
                     "description": "单位名称",
                     "type": "string"
@@ -9583,15 +9791,15 @@
                     "type": "integer"
                 },
                 "wrstandardcode": {
-                    "description": "现货商品代码",
+                    "description": "品代码",
                     "type": "string"
                 },
                 "wrstandardid": {
-                    "description": "现货商品id",
+                    "description": "品id",
                     "type": "integer"
                 },
                 "wrstandardname": {
-                    "description": "现货商品名称",
+                    "description": "品名称",
                     "type": "string"
                 }
             }
@@ -11833,42 +12041,428 @@
                 }
             }
         },
-        "models.ErmcpAreaSpotDetailModel": {
+        "models.Ermcp3Contract": {
             "type": "object",
             "properties": {
-                "contracttype": {
-                    "description": "合同类型 1-采购 -1-销售",
-                    "type": "integer"
+                "amount": {
+                    "description": "金额 [1:一口价、3:暂定价]",
+                    "type": "number"
                 },
-                "createtime": {
-                    "description": "创建时间",
+                "attachment": {
+                    "description": "附件",
                     "type": "string"
                 },
-                "enumdicname": {
-                    "description": "现货商品单位名称",
+                "auditremark": {
+                    "description": "审核意见",
                     "type": "string"
                 },
-                "logtype": {
-                    "description": "记录类型 1-套保 2-现货合同",
-                    "type": "integer"
-                },
-                "qty": {
-                    "description": "数量",
-                    "type": "number"
-                },
-                "recordname": {
-                    "description": "类型名称",
+                "audittime": {
+                    "description": "审核时间",
                     "type": "string"
                 },
-                "relatedid": {
-                    "description": "套保计划ID/现货合同ID",
+                "brandname": {
+                    "description": "品牌名称",
                     "type": "string"
                 },
-                "relatedno": {
-                    "description": "编号",
+                "buyuserid": {
+                    "description": "采购方ID",
+                    "type": "integer"
+                },
+                "buyusername": {
+                    "description": "采购方名称",
                     "type": "string"
                 },
-                "strtime": {
+                "contracctstatus": {
+                    "description": "合同状态 - 0:未提交 1:待审核 2:执行中 3:正常完结 4:审核拒绝 5:异常完结 6:已撤回",
+                    "type": "integer"
+                },
+                "contractmargin": {
+                    "description": "合同保证金",
+                    "type": "number"
+                },
+                "contractno": {
+                    "description": "现货合同编号",
+                    "type": "string"
+                },
+                "contracttype": {
+                    "description": "现货合同类型 - 1:采购 -1:销售",
+                    "type": "integer"
+                },
+                "convertfactor": {
+                    "description": "标仓系数(品类)",
+                    "type": "number"
+                },
+                "createtime": {
+                    "description": "创建时间",
+                    "type": "string"
+                },
+                "deliveryenddate": {
+                    "description": "交收期(结束)",
+                    "type": "string"
+                },
+                "deliverygoodscode": {
+                    "description": "现货品种代码",
+                    "type": "string"
+                },
+                "deliverygoodsid": {
+                    "description": "现货品种ID",
+                    "type": "integer"
+                },
+                "deliverygoodsname": {
+                    "description": "现货品种名称",
+                    "type": "string"
+                },
+                "deliverystartdate": {
+                    "description": "交收期(开始)",
+                    "type": "string"
+                },
+                "enddate": {
+                    "description": "点价结束日期 [2:点价 3:暂定价]",
+                    "type": "string"
+                },
+                "enumdicname": {
+                    "description": "单位名称",
+                    "type": "string"
+                },
+                "goodscode": {
+                    "description": "点价合约代码",
+                    "type": "string"
+                },
+                "goodsid": {
+                    "description": "点价合约ID - 0:为现货,其它为期货商品合约ID [2:点价 3:暂定价]",
+                    "type": "integer"
+                },
+                "goodsname": {
+                    "description": "点价商品名称",
+                    "type": "string"
+                },
+                "margin": {
+                    "description": "当前保证金",
+                    "type": "number"
+                },
+                "price": {
+                    "description": "价格\\暂定价 [1:一口价、3:暂定价]",
+                    "type": "number"
+                },
+                "pricemove": {
+                    "description": "升贴水 [2:点价 3:暂定价]",
+                    "type": "number"
+                },
+                "pricetype": {
+                    "description": "定价类型 - 1:一口价 2:点价 3:暂定价",
+                    "type": "integer"
+                },
+                "producttype": {
+                    "description": "产品类型 - 1:标准仓单 2:等标 3:非标",
+                    "type": "integer"
+                },
+                "qty": {
+                    "description": "数量",
+                    "type": "number"
+                },
+                "remark": {
+                    "description": "备注",
+                    "type": "string"
+                },
+                "selluserid": {
+                    "description": "销售方ID",
+                    "type": "integer"
+                },
+                "sellusername": {
+                    "description": "销售方名称",
+                    "type": "string"
+                },
+                "spotcontractid": {
+                    "description": "现货合同ID(602+Unix秒时间戳(10位)+xxxxxx)",
+                    "type": "string"
+                },
+                "spotgoodsbrandid": {
+                    "description": "现货品牌ID(DGFactoryItem表的ID)",
+                    "type": "integer"
+                },
+                "spotgoodsdesc": {
+                    "description": "商品型号",
+                    "type": "string"
+                },
+                "startdate": {
+                    "description": "点价开始日期 [2:点价 3:暂定价]",
+                    "type": "string"
+                },
+                "unitid": {
+                    "description": "单位id(取品类上的单位id)",
+                    "type": "integer"
+                },
+                "updatetime": {
+                    "description": "更新时间",
+                    "type": "string"
+                },
+                "userid": {
+                    "description": "所属机构ID",
+                    "type": "integer"
+                },
+                "wrstandardcode": {
+                    "description": "品类代码",
+                    "type": "string"
+                },
+                "wrstandardid": {
+                    "description": "品类ID",
+                    "type": "integer"
+                },
+                "wrstandardname": {
+                    "description": "品类名称",
+                    "type": "string"
+                }
+            }
+        },
+        "models.Ermcp3SellBuyContract": {
+            "type": "object",
+            "properties": {
+                "accountname": {
+                    "description": "账户名称",
+                    "type": "string"
+                },
+                "attachment": {
+                    "description": "附件",
+                    "type": "string"
+                },
+                "audittime": {
+                    "description": "审核时间",
+                    "type": "string"
+                },
+                "brandname": {
+                    "description": "品牌名称",
+                    "type": "string"
+                },
+                "contracctstatus": {
+                    "description": "合同状态- 0:未提交 1:待审核 2:执行中 3:正常完结 4:审核拒绝 5:异常完结 6:已撤回",
+                    "type": "integer"
+                },
+                "contractmargin": {
+                    "description": "合同保证金",
+                    "type": "number"
+                },
+                "contractno": {
+                    "description": "合同编号",
+                    "type": "string"
+                },
+                "contracttype": {
+                    "description": "合同类型 1-采购, -1-销售",
+                    "type": "integer"
+                },
+                "convertfactor": {
+                    "description": "标仓系数(品类)",
+                    "type": "number"
+                },
+                "createtime": {
+                    "description": "创建时间",
+                    "type": "string"
+                },
+                "daikaiamount": {
+                    "description": "应收(开)票额",
+                    "type": "number"
+                },
+                "deliveryenddate": {
+                    "description": "交割结束日",
+                    "type": "string"
+                },
+                "deliverygoodscode": {
+                    "description": "现货品种代码",
+                    "type": "string"
+                },
+                "deliverygoodsid": {
+                    "description": "现货商品ID",
+                    "type": "integer"
+                },
+                "deliverygoodsname": {
+                    "description": "现货品种名称",
+                    "type": "string"
+                },
+                "deliverystartdate": {
+                    "description": "交割开始日",
+                    "type": "string"
+                },
+                "enddate": {
+                    "description": "点价结束日",
+                    "type": "string"
+                },
+                "enumdicname": {
+                    "description": "单位名称",
+                    "type": "string"
+                },
+                "goodscode": {
+                    "description": "点价商品代码",
+                    "type": "string"
+                },
+                "goodsid": {
+                    "description": "点价商品ID",
+                    "type": "integer"
+                },
+                "goodsname": {
+                    "description": "点价商品名称",
+                    "type": "string"
+                },
+                "invoiceamount": {
+                    "description": "已开票额",
+                    "type": "number"
+                },
+                "loanamount": {
+                    "description": "贷款总额=已定价额+调整金额",
+                    "type": "number"
+                },
+                "margin": {
+                    "description": "保证金",
+                    "type": "number"
+                },
+                "payamount": {
+                    "description": "已收付额(收款或付款)",
+                    "type": "number"
+                },
+                "preinvoiceamount": {
+                    "description": "预收(开)票额",
+                    "type": "number"
+                },
+                "prepayamount": {
+                    "description": "预收付额",
+                    "type": "number"
+                },
+                "price": {
+                    "description": "价格",
+                    "type": "number"
+                },
+                "pricedamount": {
+                    "description": "已定价额",
+                    "type": "number"
+                },
+                "pricedavg": {
+                    "description": "已点均价",
+                    "type": "number"
+                },
+                "pricedqty": {
+                    "description": "已定价量",
+                    "type": "number"
+                },
+                "pricemove": {
+                    "description": "升贴水",
+                    "type": "number"
+                },
+                "pricetype": {
+                    "description": "定价类型 - 1:一口价 2:点价 3:暂定价",
+                    "type": "integer"
+                },
+                "producttype": {
+                    "description": "产品类型 - 1:标准仓单 2:等标 3:非标",
+                    "type": "integer"
+                },
+                "qty": {
+                    "description": "合同量",
+                    "type": "number"
+                },
+                "reckonadjustamount": {
+                    "description": "调整金额",
+                    "type": "number"
+                },
+                "reckonedamount": {
+                    "description": "实际已收付额(已确定额,已收付总额-已退款总额)",
+                    "type": "number"
+                },
+                "reckonotheramount": {
+                    "description": "其它费用",
+                    "type": "number"
+                },
+                "reckonrealqty": {
+                    "description": "已确定量",
+                    "type": "number"
+                },
+                "remark": {
+                    "description": "备注",
+                    "type": "string"
+                },
+                "spotcontractid": {
+                    "description": "合同ID",
+                    "type": "string"
+                },
+                "spotgoodsbrandid": {
+                    "description": "现货品牌ID(DGFactoryItem表的ID)",
+                    "type": "integer"
+                },
+                "spotgoodsdesc": {
+                    "description": "商品型号(商品规格)",
+                    "type": "string"
+                },
+                "startdate": {
+                    "description": "点价开始日",
+                    "type": "string"
+                },
+                "totalamount": {
+                    "description": "合计总额",
+                    "type": "number"
+                },
+                "unpayamount": {
+                    "description": "应收付款额(应支付或应收款)",
+                    "type": "number"
+                },
+                "unpricedqty": {
+                    "description": "未定价量",
+                    "type": "number"
+                },
+                "unsureqty": {
+                    "description": "未确定量",
+                    "type": "number"
+                },
+                "userid": {
+                    "description": "机构ID",
+                    "type": "integer"
+                },
+                "wrstandardcode": {
+                    "description": "品类代码",
+                    "type": "string"
+                },
+                "wrstandardid": {
+                    "description": "品类ID",
+                    "type": "integer"
+                },
+                "wrstandardname": {
+                    "description": "品类名称",
+                    "type": "string"
+                }
+            }
+        },
+        "models.ErmcpAreaSpotDetailModel": {
+            "type": "object",
+            "properties": {
+                "contracttype": {
+                    "description": "合同类型 1-采购 -1-销售",
+                    "type": "integer"
+                },
+                "createtime": {
+                    "description": "创建时间",
+                    "type": "string"
+                },
+                "enumdicname": {
+                    "description": "现货商品单位名称",
+                    "type": "string"
+                },
+                "logtype": {
+                    "description": "记录类型 1-套保 2-现货合同",
+                    "type": "integer"
+                },
+                "qty": {
+                    "description": "数量",
+                    "type": "number"
+                },
+                "recordname": {
+                    "description": "类型名称",
+                    "type": "string"
+                },
+                "relatedid": {
+                    "description": "套保计划ID/现货合同ID",
+                    "type": "string"
+                },
+                "relatedno": {
+                    "description": "编号",
+                    "type": "string"
+                },
+                "strtime": {
                     "description": "时间",
                     "type": "string"
                 },
@@ -19382,10 +19976,18 @@
                     "description": "套保系数",
                     "type": "number"
                 },
+                "deliverygoodscode": {
+                    "description": "现货商品代码",
+                    "type": "string"
+                },
                 "deliverygoodsid": {
                     "description": "现货品种ID",
                     "type": "integer"
                 },
+                "deliverygoodsname": {
+                    "description": "现货商品名称",
+                    "type": "string"
+                },
                 "enumdicname": {
                     "description": "单位名称",
                     "type": "string"
@@ -19411,7 +20013,7 @@
                     "type": "string"
                 },
                 "wrstandardid": {
-                    "description": "现货商品ID",
+                    "description": "品ID",
                     "type": "integer"
                 }
             }

+ 451 - 16
docs/swagger.yaml

@@ -976,6 +976,15 @@ definitions:
       contracttype:
         description: 现货合同类型 - 1:采购 -1:销售
         type: integer
+      deliverygoodscode:
+        description: 现货品种代码
+        type: string
+      deliverygoodsid:
+        description: 现货商品ID
+        type: integer
+      deliverygoodsname:
+        description: 现货品种名称
+        type: string
       enumdicname:
         description: 单位名称
         type: string
@@ -1013,13 +1022,13 @@ definitions:
         description: 用户ID
         type: integer
       wrstandardcode:
-        description: 现货商品代码
+        description: 品代码
         type: string
       wrstandardid:
-        description: 现货商品id
+        description: 品id
         type: integer
       wrstandardname:
-        description: 现货商品名称
+        description: 品名称
         type: string
     type: object
   ermcp.QryBussinessFpRsp:
@@ -1060,6 +1069,15 @@ definitions:
       contracttype:
         description: 现货合同类型 - 1:采购 -1:销售
         type: integer
+      deliverygoodscode:
+        description: 现货品种代码
+        type: string
+      deliverygoodsid:
+        description: 现货商品ID
+        type: integer
+      deliverygoodsname:
+        description: 现货品种名称
+        type: string
       enumdicname:
         description: 单位名称
         type: string
@@ -1094,13 +1112,13 @@ definitions:
         description: 用户ID
         type: integer
       wrstandardcode:
-        description: 现货商品代码
+        description: 品代码
         type: string
       wrstandardid:
-        description: 现货商品id
+        description: 品id
         type: integer
       wrstandardname:
-        description: 现货商品名称
+        description: 品名称
         type: string
     type: object
   ermcp.QryBussinessJsExRsp:
@@ -1141,6 +1159,15 @@ definitions:
       contracttype:
         description: 现货合同类型 - 1:采购 -1:销售
         type: integer
+      deliverygoodscode:
+        description: 现货品种代码
+        type: string
+      deliverygoodsid:
+        description: 现货商品ID
+        type: integer
+      deliverygoodsname:
+        description: 现货品种名称
+        type: string
       enumdicname:
         description: 单位名称
         type: string
@@ -1178,13 +1205,13 @@ definitions:
         description: 用户ID
         type: integer
       wrstandardcode:
-        description: 现货商品代码
+        description: 品代码
         type: string
       wrstandardid:
-        description: 现货商品id
+        description: 品id
         type: integer
       wrstandardname:
-        description: 现货商品名称
+        description: 品名称
         type: string
     type: object
   ermcp.QryBussinessJsRsp:
@@ -1231,6 +1258,15 @@ definitions:
       decmargin:
         description: 减少保证金(非必填)
         type: number
+      deliverygoodscode:
+        description: 现货品种代码
+        type: string
+      deliverygoodsid:
+        description: 现货商品ID
+        type: integer
+      deliverygoodsname:
+        description: 现货品种名称
+        type: string
       enumdicname:
         description: 单位名称
         type: string
@@ -1274,13 +1310,13 @@ definitions:
         description: 用户ID
         type: integer
       wrstandardcode:
-        description: 现货商品代码
+        description: 品代码
         type: string
       wrstandardid:
-        description: 现货商品id
+        description: 品id
         type: integer
       wrstandardname:
-        description: 现货商品名称
+        description: 品名称
         type: string
     type: object
   ermcp.QryBussinessKxRsp:
@@ -1324,6 +1360,15 @@ definitions:
       deductamount:
         description: 退款(非必填)
         type: number
+      deliverygoodscode:
+        description: 现货品种代码
+        type: string
+      deliverygoodsid:
+        description: 现货商品ID
+        type: integer
+      deliverygoodsname:
+        description: 现货品种名称
+        type: string
       enumdicname:
         description: 单位名称
         type: string
@@ -1361,13 +1406,13 @@ definitions:
         description: 用户ID
         type: integer
       wrstandardcode:
-        description: 现货商品代码
+        description: 品代码
         type: string
       wrstandardid:
-        description: 现货商品id
+        description: 品id
         type: integer
       wrstandardname:
-        description: 现货商品名称
+        description: 品名称
         type: string
     type: object
   ermcp.QryErmcpRsp:
@@ -3027,6 +3072,294 @@ definitions:
     - enumdicid
     - enumitemname
     type: object
+  models.Ermcp3Contract:
+    properties:
+      amount:
+        description: 金额 [1:一口价、3:暂定价]
+        type: number
+      attachment:
+        description: 附件
+        type: string
+      auditremark:
+        description: 审核意见
+        type: string
+      audittime:
+        description: 审核时间
+        type: string
+      brandname:
+        description: 品牌名称
+        type: string
+      buyuserid:
+        description: 采购方ID
+        type: integer
+      buyusername:
+        description: 采购方名称
+        type: string
+      contracctstatus:
+        description: 合同状态 - 0:未提交 1:待审核 2:执行中 3:正常完结 4:审核拒绝 5:异常完结 6:已撤回
+        type: integer
+      contractmargin:
+        description: 合同保证金
+        type: number
+      contractno:
+        description: 现货合同编号
+        type: string
+      contracttype:
+        description: 现货合同类型 - 1:采购 -1:销售
+        type: integer
+      convertfactor:
+        description: 标仓系数(品类)
+        type: number
+      createtime:
+        description: 创建时间
+        type: string
+      deliveryenddate:
+        description: 交收期(结束)
+        type: string
+      deliverygoodscode:
+        description: 现货品种代码
+        type: string
+      deliverygoodsid:
+        description: 现货品种ID
+        type: integer
+      deliverygoodsname:
+        description: 现货品种名称
+        type: string
+      deliverystartdate:
+        description: 交收期(开始)
+        type: string
+      enddate:
+        description: 点价结束日期 [2:点价 3:暂定价]
+        type: string
+      enumdicname:
+        description: 单位名称
+        type: string
+      goodscode:
+        description: 点价合约代码
+        type: string
+      goodsid:
+        description: 点价合约ID - 0:为现货,其它为期货商品合约ID [2:点价 3:暂定价]
+        type: integer
+      goodsname:
+        description: 点价商品名称
+        type: string
+      margin:
+        description: 当前保证金
+        type: number
+      price:
+        description: 价格\暂定价 [1:一口价、3:暂定价]
+        type: number
+      pricemove:
+        description: 升贴水 [2:点价 3:暂定价]
+        type: number
+      pricetype:
+        description: 定价类型 - 1:一口价 2:点价 3:暂定价
+        type: integer
+      producttype:
+        description: 产品类型 - 1:标准仓单 2:等标 3:非标
+        type: integer
+      qty:
+        description: 数量
+        type: number
+      remark:
+        description: 备注
+        type: string
+      selluserid:
+        description: 销售方ID
+        type: integer
+      sellusername:
+        description: 销售方名称
+        type: string
+      spotcontractid:
+        description: 现货合同ID(602+Unix秒时间戳(10位)+xxxxxx)
+        type: string
+      spotgoodsbrandid:
+        description: 现货品牌ID(DGFactoryItem表的ID)
+        type: integer
+      spotgoodsdesc:
+        description: 商品型号
+        type: string
+      startdate:
+        description: 点价开始日期 [2:点价 3:暂定价]
+        type: string
+      unitid:
+        description: 单位id(取品类上的单位id)
+        type: integer
+      updatetime:
+        description: 更新时间
+        type: string
+      userid:
+        description: 所属机构ID
+        type: integer
+      wrstandardcode:
+        description: 品类代码
+        type: string
+      wrstandardid:
+        description: 品类ID
+        type: integer
+      wrstandardname:
+        description: 品类名称
+        type: string
+    type: object
+  models.Ermcp3SellBuyContract:
+    properties:
+      accountname:
+        description: 账户名称
+        type: string
+      attachment:
+        description: 附件
+        type: string
+      audittime:
+        description: 审核时间
+        type: string
+      brandname:
+        description: 品牌名称
+        type: string
+      contracctstatus:
+        description: 合同状态- 0:未提交 1:待审核 2:执行中 3:正常完结 4:审核拒绝 5:异常完结 6:已撤回
+        type: integer
+      contractmargin:
+        description: 合同保证金
+        type: number
+      contractno:
+        description: 合同编号
+        type: string
+      contracttype:
+        description: 合同类型 1-采购, -1-销售
+        type: integer
+      convertfactor:
+        description: 标仓系数(品类)
+        type: number
+      createtime:
+        description: 创建时间
+        type: string
+      daikaiamount:
+        description: 应收(开)票额
+        type: number
+      deliveryenddate:
+        description: 交割结束日
+        type: string
+      deliverygoodscode:
+        description: 现货品种代码
+        type: string
+      deliverygoodsid:
+        description: 现货商品ID
+        type: integer
+      deliverygoodsname:
+        description: 现货品种名称
+        type: string
+      deliverystartdate:
+        description: 交割开始日
+        type: string
+      enddate:
+        description: 点价结束日
+        type: string
+      enumdicname:
+        description: 单位名称
+        type: string
+      goodscode:
+        description: 点价商品代码
+        type: string
+      goodsid:
+        description: 点价商品ID
+        type: integer
+      goodsname:
+        description: 点价商品名称
+        type: string
+      invoiceamount:
+        description: 已开票额
+        type: number
+      loanamount:
+        description: 贷款总额=已定价额+调整金额
+        type: number
+      margin:
+        description: 保证金
+        type: number
+      payamount:
+        description: 已收付额(收款或付款)
+        type: number
+      preinvoiceamount:
+        description: 预收(开)票额
+        type: number
+      prepayamount:
+        description: 预收付额
+        type: number
+      price:
+        description: 价格
+        type: number
+      pricedamount:
+        description: 已定价额
+        type: number
+      pricedavg:
+        description: 已点均价
+        type: number
+      pricedqty:
+        description: 已定价量
+        type: number
+      pricemove:
+        description: 升贴水
+        type: number
+      pricetype:
+        description: 定价类型 - 1:一口价 2:点价 3:暂定价
+        type: integer
+      producttype:
+        description: 产品类型 - 1:标准仓单 2:等标 3:非标
+        type: integer
+      qty:
+        description: 合同量
+        type: number
+      reckonadjustamount:
+        description: 调整金额
+        type: number
+      reckonedamount:
+        description: 实际已收付额(已确定额,已收付总额-已退款总额)
+        type: number
+      reckonotheramount:
+        description: 其它费用
+        type: number
+      reckonrealqty:
+        description: 已确定量
+        type: number
+      remark:
+        description: 备注
+        type: string
+      spotcontractid:
+        description: 合同ID
+        type: string
+      spotgoodsbrandid:
+        description: 现货品牌ID(DGFactoryItem表的ID)
+        type: integer
+      spotgoodsdesc:
+        description: 商品型号(商品规格)
+        type: string
+      startdate:
+        description: 点价开始日
+        type: string
+      totalamount:
+        description: 合计总额
+        type: number
+      unpayamount:
+        description: 应收付款额(应支付或应收款)
+        type: number
+      unpricedqty:
+        description: 未定价量
+        type: number
+      unsureqty:
+        description: 未确定量
+        type: number
+      userid:
+        description: 机构ID
+        type: integer
+      wrstandardcode:
+        description: 品类代码
+        type: string
+      wrstandardid:
+        description: 品类ID
+        type: integer
+      wrstandardname:
+        description: 品类名称
+        type: string
+    type: object
   models.ErmcpAreaSpotDetailModel:
     properties:
       contracttype:
@@ -8656,9 +8989,15 @@ definitions:
       convertratio:
         description: 套保系数
         type: number
+      deliverygoodscode:
+        description: 现货商品代码
+        type: string
       deliverygoodsid:
         description: 现货品种ID
         type: integer
+      deliverygoodsname:
+        description: 现货商品名称
+        type: string
       enumdicname:
         description: 单位名称
         type: string
@@ -8678,7 +9017,7 @@ definitions:
         description: 修改时间
         type: string
       wrstandardid:
-        description: 现货商品ID
+        description: 品ID
         type: integer
     type: object
   models.WRStandardInfo:
@@ -13256,6 +13595,102 @@ paths:
       summary: 查询现货商品详情
       tags:
       - 企业风险管理v3(app)
+  /Ermcp3/QuerySpotContract:
+    get:
+      parameters:
+      - description: 所属机构ID
+        in: query
+        name: areauserid
+        required: true
+        type: integer
+      - description: 合同类型 1-采购, -1-销售
+        in: query
+        name: contracttype
+        required: true
+        type: integer
+      - description: 查询类型 1-全部 2-待点价 3-履约结算 4-已完成
+        in: query
+        name: querytype
+        required: true
+        type: integer
+      - description: 用户ID
+        in: query
+        name: userid
+        type: integer
+      - description: 用户类型 2-机构 7-企业成员
+        in: query
+        name: usertype
+        type: integer
+      - description: 合同ID(SpotContractId)
+        in: query
+        name: contractid
+        type: string
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            items:
+              $ref: '#/definitions/models.Ermcp3Contract'
+            type: array
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 查询现货合同
+      tags:
+      - 企业风险管理v3(app)
+  /Ermcp3/QuerySpotContractBS:
+    get:
+      parameters:
+      - description: 所属机构ID
+        in: query
+        name: areauserid
+        required: true
+        type: integer
+      - description: 合同类型 1-采购, -1-销售
+        in: query
+        name: contracttype
+        required: true
+        type: integer
+      - description: 查询类型 1-全部 2-待点价 3-履约结算 4-已完成
+        in: query
+        name: querytype
+        required: true
+        type: integer
+      - description: 用户ID
+        in: query
+        name: userid
+        type: integer
+      - description: 用户类型 2-机构 7-企业成员
+        in: query
+        name: usertype
+        type: integer
+      - description: 合同ID(SpotContractId)
+        in: query
+        name: contractid
+        type: string
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            items:
+              $ref: '#/definitions/models.Ermcp3SellBuyContract'
+            type: array
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 查询合同(采购/销售)
+      tags:
+      - 企业风险管理v3(app)
   /Erms2/QueryArbitrageStrategy:
     get:
       parameters:

+ 324 - 1
models/ermcp3.go

@@ -7,6 +7,7 @@
 package models
 
 import (
+	"fmt"
 	"mtp2_if/db"
 	"mtp2_if/mtpcache"
 	"mtp2_if/utils"
@@ -246,7 +247,7 @@ func (r *ErmcpDeliveryGoodsDetail) GetDataEx() (interface{}, error) {
 		}
 		sData = append(sData, val)
 	}
-	//品类
+	//品类/品牌/套保信息
 	gm := ErmcpWrstandard{AREAUSERID: int(r.Data.AREAUSERID), DELIVERYGOODSID: r.Data.DELIVERYGOODSID, ISVALID: 1}
 	gb := ErmcpBrand{DELIVERYGOODSID: r.Data.DELIVERYGOODSID}
 	WrsC := WRSConverTDetail{DELIVERYGOODSID: r.Data.DELIVERYGOODSID}
@@ -268,3 +269,325 @@ func (r *ErmcpDeliveryGoodsDetail) GetDataEx() (interface{}, error) {
 
 	return sData, nil
 }
+
+// Ermcp3Contract 现货合同
+type Ermcp3Contract struct {
+	SPOTCONTRACTID    string  `json:"spotcontractid"  xorm:"'SPOTCONTRACTID'"`       // 现货合同ID(602+Unix秒时间戳(10位)+xxxxxx)
+	CONTRACTNO        string  `json:"contractno"  xorm:"'CONTRACTNO'"`               // 现货合同编号
+	CONTRACTTYPE      int32   `json:"contracttype"  xorm:"'CONTRACTTYPE'"`           // 现货合同类型 - 1:采购 -1:销售
+	USERID            int64   `json:"userid"  xorm:"'USERID'"`                       // 所属机构ID
+	BUYUSERID         int64   `json:"buyuserid"  xorm:"'BUYUSERID'"`                 // 采购方ID
+	BUYUSERName       string  `json:"buyusername"  xorm:"'BUYUSERName'"`             // 采购方名称
+	SELLUSERID        int64   `json:"selluserid"  xorm:"'SELLUSERID'"`               // 销售方ID
+	SELLUSERNAME      string  `json:"sellusername"  xorm:"'SELLUSERNAME'"`           // 销售方名称
+	DELIVERYGOODSID   int32   `json:"deliverygoodsid"  xorm:"'DELIVERYGOODSID'"`     // 现货品种ID
+	WRSTANDARDID      int32   `json:"wrstandardid"  xorm:"'wrstandardid'"`           // 品类ID
+	WRSTANDARDNAME    string  `json:"wrstandardname"  xorm:"'WRSTANDARDNAME'"`       // 品类名称
+	WRSTANDARDCODE    string  `json:"wrstandardcode"  xorm:"'WRSTANDARDCODE'"`       // 品类代码
+	DELIVERYGOODSCODE string  `json:"deliverygoodscode"  xorm:"'DELIVERYGOODSCODE'"` // 现货品种代码
+	DELIVERYGOODSNAME string  `json:"deliverygoodsname"  xorm:"'DELIVERYGOODSNAME'"` // 现货品种名称
+	PRODUCTTYPE       int32   `json:"producttype"  xorm:"'PRODUCTTYPE'"`             // 产品类型 - 1:标准仓单 2:等标 3:非标
+	CONVERTFACTOR     float64 `json:"convertfactor"  xorm:"'CONVERTFACTOR'"`         // 标仓系数(品类)
+	SPOTGOODSDESC     string  `json:"spotgoodsdesc"  xorm:"'SPOTGOODSDESC'"`         // 商品型号
+	PRICETYPE         int32   `json:"pricetype"  xorm:"'PRICETYPE'"`                 // 定价类型 - 1:一口价 2:点价 3:暂定价
+	QTY               float64 `json:"qty"  xorm:"'QTY'"`                             // 数量
+	PRICE             float64 `json:"price"  xorm:"'PRICE'"`                         // 价格\暂定价 [1:一口价、3:暂定价]
+	AMOUNT            float64 `json:"amount"  xorm:"'AMOUNT'"`                       // 金额 [1:一口价、3:暂定价]
+	DELIVERYSTARTDATE string  `json:"deliverystartdate"  xorm:"'DELIVERYSTARTDATE'"` // 交收期(开始)
+	DELIVERYENDDATE   string  `json:"deliveryenddate"  xorm:"'DELIVERYENDDATE'"`     // 交收期(结束)
+	GOODSID           int32   `json:"goodsid"  xorm:"'GOODSID'"`                     // 点价合约ID - 0:为现货,其它为期货商品合约ID [2:点价 3:暂定价]
+	GOODSCODE         string  `json:"goodscode"  xorm:"'GOODSCODE'"`                 // 点价合约代码
+	GOODSNAME         string  `json:"goodsname"  xorm:"'GOODSNAME'"`                 // 点价商品名称
+	PRICEMOVE         float64 `json:"pricemove"  xorm:"'PRICEMOVE'"`                 // 升贴水 [2:点价 3:暂定价]
+	STARTDATE         string  `json:"startdate"  xorm:"'STARTDATE'"`                 // 点价开始日期 [2:点价 3:暂定价]
+	ENDDATE           string  `json:"enddate"  xorm:"'ENDDATE'"`                     // 点价结束日期 [2:点价 3:暂定价]
+	MARGIN            float64 `json:"margin"  xorm:"'MARGIN'"`                       // 当前保证金
+	CONTRACTMARGIN    float64 `json:"contractmargin"  xorm:"'CONTRACTMARGIN'"`       // 合同保证金
+	EnumdicName       string  `json:"enumdicname"  xorm:"'ENUMDICNAME'"`             // 单位名称
+	CONTRACCTSTATUS   int32   `json:"contracctstatus"  xorm:"'CONTRACTSTATUS'"`      // 合同状态 - 0:未提交 1:待审核 2:执行中 3:正常完结 4:审核拒绝 5:异常完结 6:已撤回
+	Remark            string  `json:"remark"  xorm:"'Remark'"`                       // 备注
+	AUDITREMARK       string  `json:"auditremark"  xorm:"'AUDITREMARK'"`             // 审核意见
+	AUDITTIME         string  `json:"audittime"  xorm:"'AUDITTIME'"`                 // 审核时间
+	CREATETIME        string  `json:"createtime"  xorm:"'CREATETIME'"`               // 创建时间
+	UPDATETIME        string  `json:"updatetime"  xorm:"'UPDATETIME'"`               // 更新时间
+	SPOTGOODSBRANDID  int32   `json:"spotgoodsbrandid"  xorm:"'SPOTGOODSBRANDID'"`   // 现货品牌ID(DGFactoryItem表的ID)
+	BRANDNAME         string  `json:"brandname"  xorm:"'brandname'"`                 // 品牌名称
+	ATTACHMENT        string  `json:"attachment"  xorm:"'ATTACHMENT'"`               // 附件
+	UNITID            int32   `json:"unitid"  xorm:"'UNITID'"`                       // 单位id(取品类上的单位id)
+
+	// 筛选条件
+	QryType   int32 `json:"-"` // 查询类型 1-未提交 2-待审核 3-履约中 4-已完成
+	UserType  int32 `json:"-"` // 用户类型  2-管理员 7-企业成员
+	OwnUserId int64 `json:"-"` // 登录用户id
+}
+
+func (r *Ermcp3Contract) getQryTypeStatus() string {
+	var status string
+	switch r.QryType {
+	case 1: // 未提交
+		status = "0,4,6"
+	case 2: // 待审核
+		status = "1"
+	case 3: // 履约中
+		status = "2"
+	case 4: // 已完成
+		status = "3,5"
+	}
+	return status
+}
+
+func (r *Ermcp3Contract) calc() {
+	r.BUYUSERName = mtpcache.GetUserNameByUserId(r.BUYUSERID)
+	r.SELLUSERNAME = mtpcache.GetUserNameByUserId(r.SELLUSERID)
+	r.EnumdicName = mtpcache.GetEnumDicitemName(r.UNITID)
+}
+
+func (r *Ermcp3Contract) buildSql() string {
+	var sqlId utils.SQLVal = "SELECT to_char(t.SPOTCONTRACTID) SPOTCONTRACTID," +
+		"       t.CONTRACTNO," +
+		"       t.CONTRACTTYPE," +
+		"       t.USERID," +
+		"       t.BUYUSERID," +
+		"       t.SELLUSERID," +
+		"       t.DELIVERYGOODSID," +
+		"       t.wrstandardid," +
+		"       t.PRODUCTTYPE," +
+		"       w.CONVERTFACTOR," +
+		"       t.SPOTGOODSDESC," +
+		"       t.PRICETYPE," +
+		"       t.QTY," +
+		"       t.PRICE," +
+		"       t.AMOUNT," +
+		"       to_char(t.DELIVERYSTARTDATE, 'yyyy-mm-dd hh24:mi:ss') DELIVERYSTARTDATE," +
+		"       to_char(t.DELIVERYENDDATE, 'yyyy-mm-dd hh24:mi:ss') DELIVERYENDDATE," +
+		"       t.GOODSID," +
+		"       t.PRICEMOVE," +
+		"       to_char(t.STARTDATE, 'yyyy-mm-dd hh24:mi:ss') STARTDATE," +
+		"       to_char(t.ENDDATE, 'yyyy-mm-dd hh24:mi:ss') ENDDATE," +
+		"       t.MARGIN," +
+		"       t.contractmargin," +
+		"       t.remark," +
+		"       t.auditremark," +
+		"       to_char(t.contractattachment) attachment," +
+		"       t.contractstatus," +
+		"       t.SPOTGOODSBRANDID," +
+		"       to_char(t.audittime, 'yyyy-mm-dd hh24:mi:ss') audittime," +
+		"       to_char(t.createtime, 'yyyy-mm-dd hh24:mi:ss') createtime," +
+		"       to_char(t.updatetime, 'yyyy-mm-dd hh24:mi:ss') updatetime," +
+		"       g.deliverygoodscode," +
+		"       g.deliverygoodsname," +
+		"       g2.goodscode," +
+		"       g2.goodsname," +
+		"       gb.dgfactoryitemvalue brandname," +
+		"       w.wrstandardname," +
+		"       w.wrstandardcode," +
+		"       w.unitid" +
+		"  FROM ERMCP_SPOTCONTRACT t" +
+		"  left join deliverygoods g" +
+		"    on t.deliverygoodsid = g.deliverygoodsid" +
+		"  left join goods g2" +
+		"    on t.goodsid = g2.goodsid" +
+		"  left join DGFACTORYITEM gb" +
+		"    on t.spotgoodsbrandid = gb.dgfactoryitemid" +
+		"  left join wrstandard w" +
+		"    on t.wrstandardid = w.wrstandardid" +
+		" where 1 = 1"
+	sqlId.AndEx("t.userid", r.USERID, r.USERID > 0)
+	sqlId.AndEx("t.SPOTCONTRACTID", r.SPOTCONTRACTID, len(r.SPOTCONTRACTID) > 0)
+	if r.UserType == 7 {
+		// 企业成员
+		sqlId.Join(fmt.Sprintf(" and %v in(t.saleuserid, t.tradeuserid, t.meruserid)", r.OwnUserId))
+	}
+	status := r.getQryTypeStatus()
+	if len(status) > 0 {
+		sqlId.Join(fmt.Sprintf(" and t.contractstatus in (%v)", status))
+	}
+
+	return sqlId.String()
+}
+
+// GetDataEx
+func (r *Ermcp3Contract) GetDataEx() (interface{}, error) {
+	sData := make([]Ermcp3Contract, 0)
+	err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
+	for i := range sData {
+		sData[i].calc()
+	}
+	return sData, err
+}
+
+// Ermcp3SellBuyContract 采购/销售合同
+type Ermcp3SellBuyContract struct {
+	UserID             int64   `json:"userid"  xorm:"'UserID'"`                         // 机构ID
+	SpotContractId     string  `json:"spotcontractid"  xorm:"'SPOTCONTRACTID'"`         // 合同ID
+	AccountName        string  `json:"accountname"  xorm:"'ACCOUNTNAME'"`               // 账户名称
+	DeliveryGoodsId    int     `json:"deliverygoodsid"  xorm:"'DELIVERYGOODSID'"`       // 现货商品ID
+	DeliveryGoodsCode  string  `json:"deliverygoodscode"  xorm:"'DELIVERYGOODSCODE'"`   // 现货品种代码
+	DeliveryGoodsName  string  `json:"deliverygoodsname"  xorm:"'DELIVERYGOODSNAME'"`   // 现货品种名称
+	SpotGoodsdesc      string  `json:"spotgoodsdesc"  xorm:"'SPOTGOODSDESC'"`           // 商品型号(商品规格)
+	GoodsId            int     `json:"goodsid"  xorm:"'GOODSID'"`                       // 点价商品ID
+	GOODSNAME          string  `json:"goodsname"  xorm:"'GOODSNAME'"`                   // 点价商品名称
+	Goodscode          string  `json:"goodscode"  xorm:"'GOODSCODE'"`                   // 点价商品代码
+	Pricemove          float64 `json:"pricemove"  xorm:"'PRICEMOVE'"`                   // 升贴水
+	Qty                float64 `json:"qty"  xorm:"'QTY'"`                               // 合同量
+	UnpricedQty        float64 `json:"unpricedqty"  xorm:"'UNPRICEDQTY'"`               // 未定价量
+	PricedQty          float64 `json:"pricedqty"  xorm:"'PRICEDQTY'"`                   // 已定价量
+	UnsureQty          float64 `json:"unsureqty"  xorm:"'UNSUREQTY'"`                   // 未确定量
+	PayAmount          float64 `json:"payamount"  xorm:"'PAYAMOUNT'"`                   // 已收付额(收款或付款)
+	UnpayAmount        float64 `json:"unpayamount"`                                     // 应收付款额(应支付或应收款)
+	PrePayAmount       float64 `json:"prepayamount"`                                    // 预收付额
+	InvoiceAmount      float64 `json:"invoiceamount"  xorm:"'INVOICEAMOUNT'"`           // 已开票额
+	DaikaiAmount       float64 `json:"daikaiamount"  xorm:"'DAIKAIAMOUNT'"`             // 应收(开)票额
+	PreInvoiceAmount   float64 `json:"preinvoiceamount"`                                // 预收(开)票额
+	StartDate          string  `json:"startdate"  xorm:"'STARTDATE'"`                   // 点价开始日
+	EndDate            string  `json:"enddate"  xorm:"'ENDDATE'"`                       // 点价结束日
+	DeliveryStartDate  string  `json:"deliverystartdate"  xorm:"'DELIVERYSTARTDATE'"`   // 交割开始日
+	DeliveryendDate    string  `json:"deliveryenddate"  xorm:"'DELIVERYENDDATE'"`       // 交割结束日
+	Convertfactor      float64 `json:"convertfactor"  xorm:"'CONVERTFACTOR'"`           // 标仓系数(品类)
+	EnumdicName        string  `json:"enumdicname"  xorm:"'ENUMDICNAME'"`               // 单位名称
+	Contracctstatus    uint    `json:"contracctstatus"  xorm:"'CONTRACTSTATUS'"`        // 合同状态- 0:未提交 1:待审核 2:执行中 3:正常完结 4:审核拒绝 5:异常完结 6:已撤回
+	PriceType          int     `json:"pricetype"  xorm:"'PRICETYPE'"`                   // 定价类型 - 1:一口价 2:点价 3:暂定价
+	ProductType        int     `json:"producttype"  xorm:"'PRODUCTTYPE'"`               // 产品类型 - 1:标准仓单 2:等标 3:非标
+	Contracttype       int32   `json:"contracttype"  xorm:"'CONTRACTTYPE'"`             // 合同类型 1-采购, -1-销售
+	Pricedamount       float64 `json:"pricedamount"  xorm:"'PRICEDAMOUNT'"`             // 已定价额
+	PricedAvg          float64 `json:"pricedavg"  xorm:"'PRICEDAVG'"`                   // 已点均价
+	Margin             float64 `json:"margin"  xorm:"'MARGIN'"`                         // 保证金
+	CONTRACTMARGIN     float64 `json:"contractmargin"  xorm:"'CONTRACTMARGIN'"`         // 合同保证金
+	Remark             string  `json:"remark"  xorm:"'Remark'"`                         // 备注
+	ATTACHMENT         string  `json:"attachment"  xorm:"'ATTACHMENT'"`                 // 附件
+	ReckonRealQty      float64 `json:"reckonrealqty"  xorm:"'ReckonRealQty'"`           // 已确定量
+	ReckonOtherAmount  float64 `json:"reckonotheramount"  xorm:"'ReckonOtherAmount'"`   // 其它费用
+	ReckonAdjustAmount float64 `json:"reckonadjustamount"  xorm:"'ReckonAdjustAmount'"` // 调整金额
+	Price              float64 `json:"price"  xorm:"'Price'"`                           // 价格
+	LoanAmount         float64 `json:"loanamount"  xorm:"'LoanAmount'"`                 // 贷款总额=已定价额+调整金额
+	Contractno         string  `json:"contractno"  xorm:"'Contractno'"`                 // 合同编号
+	TotalAmount        float64 `json:"totalamount"  xorm:"'-'"`                         // 合计总额
+	ReckonedAmount     float64 `json:"reckonedamount"  xorm:"'ReckonedAmount'"`         // 实际已收付额(已确定额,已收付总额-已退款总额)
+	BUYUSERID          int64   `json:"-"  xorm:"'BUYUSERID'"`                           // 采购方ID
+	SELLUSERID         int64   `json:"-"  xorm:"'SELLUSERID'"`                          // 销售方ID
+	AUDITTIME          string  `json:"audittime"  xorm:"'AUDITTIME'"`                   // 审核时间
+	CREATETIME         string  `json:"createtime"  xorm:"'CREATETIME'"`                 // 创建时间
+	SPOTGOODSBRANDID   int32   `json:"spotgoodsbrandid"  xorm:"'SPOTGOODSBRANDID'"`     // 现货品牌ID(DGFactoryItem表的ID)
+	BRANDNAME          string  `json:"brandname"  xorm:"'brandname'"`                   // 品牌名称
+	WRSTANDARDID       int64   `json:"wrstandardid"  xorm:"'WRSTANDARDID'"`             // 品类ID
+	WRSTANDARDNAME     string  `json:"wrstandardname"  xorm:"'WRSTANDARDNAME'"`         // 品类名称
+	WRSTANDARDCODE     string  `json:"wrstandardcode"  xorm:"'WRSTANDARDCODE'"`         // 品类代码
+
+	// 筛选条件
+	QryType   int32 `json:"-"` // 查询类型 1-未提交 2-待审核 3-履约中 4-已完成
+	UserType  int32 `json:"-"` // 用户类型  2-管理员 7-企业成员
+	OwnUserId int64 `json:"-"` // 登录用户id
+}
+
+func (r *Ermcp3SellBuyContract) calc() {
+	r.TotalAmount = r.LoanAmount + r.ReckonOtherAmount
+	r.UnpayAmount = r.TotalAmount - r.ReckonedAmount
+	r.PrePayAmount = r.ReckonedAmount - r.TotalAmount
+	r.PreInvoiceAmount = r.InvoiceAmount - r.TotalAmount
+	if r.Contracttype == 1 {
+		//采购合同, 取销售方名称
+		r.AccountName = mtpcache.GetUserNameByUserId(r.SELLUSERID)
+	} else {
+		//销售合同, 取采购方名称
+		r.AccountName = mtpcache.GetUserNameByUserId(r.BUYUSERID)
+	}
+}
+
+func (r *Ermcp3SellBuyContract) buildSql() string {
+	var sqlId utils.SQLVal = "select t.contractno," +
+		"       to_char(t.SpotContractId) SpotContractId," +
+		"       t.deliverygoodsid," +
+		"       t.spotgoodsdesc," +
+		"       t.goodsid," +
+		"       t.pricemove," +
+		"       t.userid," +
+		"       t.BUYUSERID," +
+		"       t.SELLUSERID," +
+		"       t.qty," +
+		"       t.qty - t.pricedqty unpricedqty," +
+		"       t.pricedqty," +
+		"       (case" +
+		"         when t.pricetype = 3 then" +
+		"          t.qty - t.RECKONREALQTY" +
+		"         else" +
+		"          t.pricedqty - t.ReckonRealQty" +
+		"       end) unsureqty," +
+		"       t.reckonedamount PayAmount," +
+		"       t.invoiceamount," +
+		"       (t.pricedamount + t.RECKONADJUSTAMOUNT + t.RECKONOTHERAMOUNT -" +
+		"       t.invoiceamount) as daikaiAmount," +
+		"       to_char(t.startdate, 'yyyy-mm-dd hh24:mi:ss') startdate," +
+		"       to_char(t.enddate, 'yyyy-mm-dd hh24:mi:ss') enddate," +
+		"       to_char(t.deliverystartdate, 'yyyy-mm-dd hh24:mi:ss') deliverystartdate," +
+		"       to_char(t.deliveryenddate, 'yyyy-mm-dd hh24:mi:ss') deliveryenddate," +
+		"       w.convertfactor," +
+		"       t.contractstatus," +
+		"       t.pricetype," +
+		"       t.producttype," +
+		"       t.contracttype," +
+		"       t.remark," +
+		"       to_char(t.contractattachment) attachment," +
+		"       t.margin," +
+		"       t.contractmargin," +
+		"       t.SPOTGOODSBRANDID," +
+		"       g.deliverygoodscode," +
+		"       g.deliverygoodsname," +
+		"       wr.wrstandardid," +
+		"       wr.wrstandardname," +
+		"       wr.wrstandardcode," +
+		"       g2.goodscode," +
+		"       g2.goodsname," +
+		"       e.enumdicname," +
+		"       t.contracttype," +
+		"       t.pricedamount," +
+		"       case" +
+		"         when t.pricedqty > 0 then" +
+		"          (t.pricedamount) / t.pricedqty" +
+		"         else" +
+		"          0" +
+		"       end pricedAvg," +
+		"       t.ReckonRealQty," +
+		"       t.ReckonOtherAmount," +
+		"       t.ReckonAdjustAmount," +
+		"       t.Price," +
+		"       t.ReckonedAmount," +
+		"       to_char(t.audittime, 'yyyy-mm-dd hh24:mi:ss') audittime," +
+		"       to_char(t.createtime, 'yyyy-mm-dd hh24:mi:ss') createtime," +
+		"       t.pricedamount + t.ReckonAdjustAmount as LoanAmount," +
+		"       gb.dgfactoryitemvalue BRANDNAME" +
+		"  from ermcp_spotcontract t" +
+		"  left join deliverygoods g" +
+		"    on t.deliverygoodsid = g.deliverygoodsid" +
+		"  left join goods g2" +
+		"    on t.goodsid = g2.goodsid" +
+		"  left join wrstandard wr" +
+		"    on t.wrstandardid = wr.wrstandardid" +
+		"  left join DGFactoryItem gb" +
+		"    on t.spotgoodsbrandid = gb.dgfactoryitemid" +
+		"  left join enumdicitem e" +
+		"    on wr.unitid = e.enumitemname" +
+		"   and e.enumdiccode = 'goodsunit'" +
+		" where 1 = 1"
+	sqlId.AndEx("t.userid", r.UserID, r.UserID > 0)
+	sqlId.AndEx("t.SpotContractId", r.SpotContractId, len(r.SpotContractId) > 0)
+	if r.UserType == 7 {
+		// 企业成员
+		sqlId.Join(fmt.Sprintf(" and %v in(t.saleuserid, t.tradeuserid, t.meruserid)", r.OwnUserId))
+	}
+	var tmp = Ermcp3Contract{QryType: r.QryType}
+	status := tmp.getQryTypeStatus()
+	if len(status) > 0 {
+		sqlId.Join(fmt.Sprintf(" and t.contractstatus in (%v)", status))
+	}
+	return sqlId.String()
+}
+
+// GetDataEx
+func (r *Ermcp3SellBuyContract) GetDataEx() (interface{}, error) {
+	sData := make([]Ermcp3SellBuyContract, 0)
+	err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
+	for i := range sData {
+		sData[i].calc()
+	}
+	return sData, err
+}

+ 34 - 26
models/ermcpOPApply.go

@@ -16,32 +16,35 @@ import (
 
 // ErmcpOPApplyModel 现货合同操作数据
 type ErmcpOPApplyModel struct {
-	USERID           int64   `json:"userid"  xorm:"'USERID'"`                     // 用户ID
-	OPERATEAPPLYID   string  `json:"operateapplyid"  xorm:"'OPERATEAPPLYID'"`     // 操作申请ID(603+Unix秒时间戳(10位)+xxxxxx)
-	OPERATEAPPLYTYPE int32   `json:"operateapplytype"  xorm:"'OPERATEAPPLYTYPE'"` // 操作申请类型 - 1:点价 2:结算登记 3:款项登记 4:发票登记
-	RELATEDID        string  `json:"relatedid"  xorm:"'RELATEDID'"`               // 现货合同ID
-	DETAILJSON       string  `json:"-"  xorm:"'DETAILJSON'"`                      // 明细JSON
-	APPLYID          string  `json:"applyid"  xorm:"'APPLYID'"`                   // 申请人
-	APPLYTIME        string  `json:"applytime"  xorm:"'APPLYTIME'"`               // 申请时间
-	APPLYSTATUS      int32   `json:"applystatus"  xorm:"'APPLYSTATUS'"`           // 申请状态 - 1:待审核 2:审核通过 3:审核拒绝 4:处理失败 5:已撤回
-	AUDITTIME        string  `json:"audittime"  xorm:"'AUDITTIME'"`               // 审核时间
-	CONTRACTTYPE     int32   `json:"contracttype"  xorm:"'CONTRACTTYPE'"`         // 现货合同类型 - 1:采购 -1:销售
-	CONTRACTNO       string  `json:"contractno"  xorm:"'CONTRACTNO'"`             // 合同编号
-	PRICETYPE        int32   `json:"pricetype"  xorm:"'PRICETYPE'"`               // 定价类型 - 1:一口价 2:点价 3:暂定价
-	PRICEMOVE        float64 `json:"pricemove"  xorm:"'PRICEMOVE'"`               // 升贴水
-	GOODSNAME        string  `json:"goodsname"  xorm:"'GOODSNAME'"`               // 商品名称
-	GOODSCODE        string  `json:"goodscode"  xorm:"'GOODSCODE'"`               // 点价合约
-	EnumdicName      string  `json:"enumdicname"  xorm:"'ENUMDICNAME'"`           // 单位名称
-	BUYUSERNAME      string  `json:"buyusername"  xorm:"'BUYUSERNAME'"`           // 采购方名称
-	SELLUSERNAME     string  `json:"sellusername"  xorm:"'SELLUSERNAME'"`         // 销售方名字
-	AUDITID          string  `json:"auditid"  xorm:"'AUDITID'"`                   // 审核人ID
-	APPLYNAME        string  `json:"applyname"  xorm:"'APPLYNAME'"`               // 申请人名称
-	AUDITNAME        string  `json:"auditname"  xorm:"'AUDITNAME'"`               // 审核人名称
-	CONTRACTSTATUS   int32   `json:"contractstatus"  xorm:"'CONTRACTSTATUS'"`     // 合同状态- 0:未提交 1:待审核 2:执行中 3:正常完结 4:审核拒绝 5:异常完结 6:已撤回
-	ATTACHURL        string  `json:"attachurl"  xorm:"'ATTACHURL'"`               // 附件
-	WRSTANDARDNAME   string  `json:"wrstandardname"  xorm:"'WRSTANDARDNAME'"`     // 现货商品名称
-	WRSTANDARDCODE   string  `json:"wrstandardcode"  xorm:"'WRSTANDARDCODE'"`     // 现货商品代码
-	WRSTANDARDID     int     `json:"wrstandardid"  xorm:"'WRSTANDARDID'"`         // 现货商品id
+	USERID            int64   `json:"userid"  xorm:"'USERID'"`                       // 用户ID
+	OPERATEAPPLYID    string  `json:"operateapplyid"  xorm:"'OPERATEAPPLYID'"`       // 操作申请ID(603+Unix秒时间戳(10位)+xxxxxx)
+	OPERATEAPPLYTYPE  int32   `json:"operateapplytype"  xorm:"'OPERATEAPPLYTYPE'"`   // 操作申请类型 - 1:点价 2:结算登记 3:款项登记 4:发票登记
+	RELATEDID         string  `json:"relatedid"  xorm:"'RELATEDID'"`                 // 现货合同ID
+	DETAILJSON        string  `json:"-"  xorm:"'DETAILJSON'"`                        // 明细JSON
+	APPLYID           string  `json:"applyid"  xorm:"'APPLYID'"`                     // 申请人
+	APPLYTIME         string  `json:"applytime"  xorm:"'APPLYTIME'"`                 // 申请时间
+	APPLYSTATUS       int32   `json:"applystatus"  xorm:"'APPLYSTATUS'"`             // 申请状态 - 1:待审核 2:审核通过 3:审核拒绝 4:处理失败 5:已撤回
+	AUDITTIME         string  `json:"audittime"  xorm:"'AUDITTIME'"`                 // 审核时间
+	CONTRACTTYPE      int32   `json:"contracttype"  xorm:"'CONTRACTTYPE'"`           // 现货合同类型 - 1:采购 -1:销售
+	CONTRACTNO        string  `json:"contractno"  xorm:"'CONTRACTNO'"`               // 合同编号
+	PRICETYPE         int32   `json:"pricetype"  xorm:"'PRICETYPE'"`                 // 定价类型 - 1:一口价 2:点价 3:暂定价
+	PRICEMOVE         float64 `json:"pricemove"  xorm:"'PRICEMOVE'"`                 // 升贴水
+	GOODSNAME         string  `json:"goodsname"  xorm:"'GOODSNAME'"`                 // 商品名称
+	GOODSCODE         string  `json:"goodscode"  xorm:"'GOODSCODE'"`                 // 点价合约
+	EnumdicName       string  `json:"enumdicname"  xorm:"'ENUMDICNAME'"`             // 单位名称
+	BUYUSERNAME       string  `json:"buyusername"  xorm:"'BUYUSERNAME'"`             // 采购方名称
+	SELLUSERNAME      string  `json:"sellusername"  xorm:"'SELLUSERNAME'"`           // 销售方名字
+	AUDITID           string  `json:"auditid"  xorm:"'AUDITID'"`                     // 审核人ID
+	APPLYNAME         string  `json:"applyname"  xorm:"'APPLYNAME'"`                 // 申请人名称
+	AUDITNAME         string  `json:"auditname"  xorm:"'AUDITNAME'"`                 // 审核人名称
+	CONTRACTSTATUS    int32   `json:"contractstatus"  xorm:"'CONTRACTSTATUS'"`       // 合同状态- 0:未提交 1:待审核 2:执行中 3:正常完结 4:审核拒绝 5:异常完结 6:已撤回
+	ATTACHURL         string  `json:"attachurl"  xorm:"'ATTACHURL'"`                 // 附件
+	WRSTANDARDNAME    string  `json:"wrstandardname"  xorm:"'WRSTANDARDNAME'"`       // 品类名称
+	WRSTANDARDCODE    string  `json:"wrstandardcode"  xorm:"'WRSTANDARDCODE'"`       // 品类代码
+	WRSTANDARDID      int     `json:"wrstandardid"  xorm:"'WRSTANDARDID'"`           // 品类id
+	DELIVERYGOODSID   int     `json:"deliverygoodsid"  xorm:"'DELIVERYGOODSID'"`     // 现货商品ID
+	DELIVERYGOODSCODE string  `json:"deliverygoodscode"  xorm:"'DELIVERYGOODSCODE'"` // 现货品种代码
+	DELIVERYGOODSNAME string  `json:"deliverygoodsname"  xorm:"'DELIVERYGOODSNAME'"` // 现货品种名称
 
 	FilterAppStatus string `json:"-"` // 状态过滤条件
 }
@@ -78,6 +81,9 @@ func (r *ErmcpOPApplyModel) buildSql(opType int32) string {
 		"       s.pricemove," +
 		"       s.userid," +
 		"       s.contractstatus," +
+		"       dg.deliverygoodsid," +
+		"       dg.deliverygoodscode," +
+		"       dg.deliverygoodsname," +
 		"       w.wrstandardname," +
 		"       w.wrstandardcode," +
 		"       w.wrstandardid," +
@@ -103,6 +109,8 @@ func (r *ErmcpOPApplyModel) buildSql(opType int32) string {
 		"    on s.buyuserid = u1.userid" +
 		"  left join useraccount u2" +
 		"    on s.selluserid = u2.userid" +
+		"  left join deliverygoods dg" +
+		"    on t.deliverygoodsid = dg.deliverygoodsid" +
 		"  left join enumdicitem e" +
 		"    on e.enumitemname = w.unitid" +
 		"   and e.enumdiccode = 'goodsunit'" +

+ 17 - 12
models/ermcpWrstandard.go

@@ -165,16 +165,17 @@ func (r *GoodsBrand) GetData() ([]GoodsBrand, error) {
 
 // WRSConverTDetail 现货商品折算配置明细表
 type WRSConverTDetail struct {
-	WRSTANDARDID    int64   `json:"wrstandardid"  xorm:"'WRSTANDARDID'"`       // 现货商品ID
-	DELIVERYGOODSID int32   `json:"deliverygoodsid"  xorm:"'DELIVERYGOODSID'"` // 现货品种ID
-	MIDDLEGOODSID   int64   `json:"middlegoodsid"  xorm:"'MIDDLEGOODSID'"`     // 套保品种ID
-	CONVERTRATIO    float64 `json:"convertratio"  xorm:"'CONVERTRATIO'"`       // 套保系数
-	MODIFYTIME      string  `json:"modifytime"  xorm:"'MODIFYTIME'"`           // 修改时间
-	MIDDLEGOODSNAME string  `json:"middlegoodsname"  xorm:"'middlegoodsname'"` // 套保品种名称
-	MIDDLEGOODSCODE string  `json:"middlegoodscode"  xorm:"'middlegoodscode'"` // 套保品种代码
-	GOODSUNITID     int32   `json:"goodsunitid"  xorm:"'GOODSUNITID'"`         // 套保品种单位id
-
-	ENUMDICNAME string `json:"enumdicname"` // 单位名称
+	WRSTANDARDID      int64   `json:"wrstandardid"  xorm:"'WRSTANDARDID'"`           // 品类ID
+	DELIVERYGOODSID   int32   `json:"deliverygoodsid"  xorm:"'DELIVERYGOODSID'"`     // 现货品种ID
+	MIDDLEGOODSID     int64   `json:"middlegoodsid"  xorm:"'MIDDLEGOODSID'"`         // 套保品种ID
+	CONVERTRATIO      float64 `json:"convertratio"  xorm:"'CONVERTRATIO'"`           // 套保系数
+	MODIFYTIME        string  `json:"modifytime"  xorm:"'MODIFYTIME'"`               // 修改时间
+	MIDDLEGOODSNAME   string  `json:"middlegoodsname"  xorm:"'middlegoodsname'"`     // 套保品种名称
+	MIDDLEGOODSCODE   string  `json:"middlegoodscode"  xorm:"'middlegoodscode'"`     // 套保品种代码
+	GOODSUNITID       int32   `json:"goodsunitid"  xorm:"'GOODSUNITID'"`             // 套保品种单位id
+	DELIVERYGOODSCODE string  `json:"deliverygoodscode"  xorm:"'DELIVERYGOODSCODE'"` // 现货商品代码
+	DELIVERYGOODSNAME string  `json:"deliverygoodsname"  xorm:"'DELIVERYGOODSNAME'"` // 现货商品名称
+	ENUMDICNAME       string  `json:"enumdicname"`                                   // 单位名称
 }
 
 func (r *WRSConverTDetail) calc() {
@@ -189,11 +190,15 @@ func (r *WRSConverTDetail) buildSql() string {
 		"       to_char(t.MODIFYTIME, 'yyyy-mm-dd hh24:mi:ss') MODIFYTIME," +
 		"       m.middlegoodsname," +
 		"       m.middlegoodscode," +
-		"       m.goodsunitid" +
+		"       m.goodsunitid," +
+		"       g.deliverygoodscode," +
+		"       g.deliverygoodsname" +
 		"  from Erms2_Wrsconvertdetail t" +
 		"  left join erms_middlegoods m" +
 		"    on t.middlegoodsid = m.middlegoodsid" +
-		"    where 1=1"
+		"  left join deliverygoods g" +
+		"    on t.deliverygoodsid = g.deliverygoodsid" +
+		" where 1 = 1"
 	if r.WRSTANDARDID > 0 {
 		sqlId = sqlId + fmt.Sprintf(" and t.wrstandardid=%v", r.WRSTANDARDID)
 	}

+ 2 - 0
routers/router.go

@@ -414,6 +414,8 @@ func InitRouter() *gin.Engine {
 	{
 		ermcp3R.GET("/QueryDeliveryGoods", ermcp3.QueryDeliveryGoods)
 		ermcp3R.GET("/QueryDeliveryGoodsDetail", ermcp3.QueryDeliveryGoodsDetail)
+		ermcp3R.GET("/QuerySpotContract", ermcp3.QuerySpotContract)
+		ermcp3R.GET("/QuerySpotContractBS", ermcp3.QuerySpotContractBS)
 	}
 
 	return r