Przeglądaj źródła

增加执行中和已完成合同的查询接口QuerySpotContractDetail

zhou.yingan 5 lat temu
rodzic
commit
ac00b0ae64
8 zmienionych plików z 590 dodań i 0 usunięć
  1. 1 0
      .gitignore
  2. 158 0
      controllers/erms3/spotContract.go
  3. 128 0
      docs/docs.go
  4. 128 0
      docs/swagger.json
  5. 89 0
      docs/swagger.yaml
  6. 8 0
      models/account.go
  7. 76 0
      models/erms3.go
  8. 2 0
      routers/router.go

+ 1 - 0
.gitignore

@@ -7,3 +7,4 @@ mtp2_if
 QueryService
 go.sum
 mtp2_if.exe
+.idea

+ 158 - 0
controllers/erms3/spotContract.go

@@ -4,12 +4,15 @@ import (
 	"encoding/hex"
 	"encoding/json"
 	"math"
+	"mtp2_if/db"
 	"mtp2_if/global/app"
 	"mtp2_if/global/e"
 	"mtp2_if/logger"
 	"mtp2_if/models"
 	"mtp2_if/utils"
 	"net/http"
+	"strconv"
+	"strings"
 	"time"
 
 	"github.com/gin-gonic/gin"
@@ -427,3 +430,158 @@ func QuerySpotContractAppleForm(c *gin.Context) {
 	logger.GetLogger().Debugln("QuerySpotContractAppleForm successed: %v", rsp)
 	appG.Response(http.StatusOK, e.SUCCESS, rsp)
 }
+
+// QuerySpotContractInfoReq 查询合同明细请求.
+type QuerySpotContractInfoReq struct {
+	Accountids string `form:"accountids" binding:"required"` // 资金账号ID列表,逗号分隔.
+	ContractType int32 `form:"contracttype" binding:"required"` // 合同类型,1-采购合同 2-销售合同.
+	ContractMode int32 `form:"contractmode" binding:"required"` // 合同模式,1-普通合同 2-回购销售合同.
+	Status int32 `form:"status"` // 合同状态,0-履约中 1-已完成.
+}
+
+// QuerySpotContractInfoRsp 查询合同明细响应.
+type QuerySpotContractInfoRsp struct {
+	SpotContractID string `json:"spotcontractid"` // 合同ID
+	CustomerName string `json:"customername"` // 若合同类型为采购合同,表示采购方ID;若合同类型为销售合同,表示销售方ID.
+	AccountID int64 `json:"accountid"` // 表示交易员ID.
+	MatchCustomerName string `json:"matchcustomername"` // 若合同类型为采购合同,表示销售方;若合同类型为销售合同,表示采购方ID.
+	MatchAccountID int64 `json:"matchaccountid"` // 表示业务员ID.
+	WRStandardName string `json:"wrstandardname"` // 表示商品ID.
+	TotalQty float64 `json:"totalqty"` // 表示合同量.
+	PricedQty float64 `json:"priceqty"` // 表示定价量.
+	UnPricedQty float64 `json:"unpricedqty"` // 表示未定价量.
+	DeliveryQty float64 `json:"deliveryqty"` // 表示交收量.
+	CurDeliveryQty float64 `json:"curdeliveryqty"` // 表示未交收量.
+	SignDate string `json:"signdate"` // 表示签订日期.
+	DeliveryGoodsID string `json:"deliverygoodsid"` // 表示品种ID.
+	RelatedBizID string `json:"relatedbizid"` // 表示业务ID.
+	Status int32 `json:"status"` // 表示状态,0-履约中 1-已完成.
+}
+
+// QuerySpotContractDetail 查询合同详细信息.
+// @Summary 查询合同详细信息
+// @Produce json
+// @Security ApiKeyAuth
+// @Param accountids query string true "资金账号ID列表,用逗号分隔"
+// @Param contracttype query int true "合同类型,1-采购合同 2-销售合同"
+// @Param contractmode query int true "合同模式,1-普通合同 2-回购销售合同"
+// @Param status query int true "状态,0-履约中 1-已完成"
+// @Success 200 {array} QuerySpotContractInfoRsp
+// @Failure 500 {object} app.Response
+// @Router /Erms3/QuerySpotContractDetail [get]
+// @Tags 风险管理v3
+func QuerySpotContractDetail(c *gin.Context) {
+	appG := app.Gin{C: c}
+
+	// 获取请求参数
+	var req QuerySpotContractInfoReq
+	err := appG.C.ShouldBindQuery(&req)
+	if err != nil {
+		logger.GetLogger().Errorf("QuerySpotContractDetail failed: %s", err.Error())
+		appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
+
+		return
+	}
+
+	strids := strings.Split(strings.TrimSpace(req.Accountids), ",")
+	accountids := make([]int64, len(strids))
+	for i := range strids {
+		accountids[i], err = strconv.ParseInt(strids[i], 10, 64)
+		if err != nil {
+			logger.GetLogger().Errorf("ParseInt failed: %s", err.Error())
+			appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
+
+			return
+		}
+	}
+
+	// 查询数据.
+	type spotContractDetail struct {
+		models.Erms3Spotcontractdetail `xorm:"extends"`
+		Areauserid           int64     `json:"areauserid" xorm:"AREAUSERID"`                     // 所属机构
+		Accountid            int64     `json:"accountid" xorm:"ACCOUNTID"`                       // 资金账户ID
+		Customeruserid       int64     `json:"customeruserid" xorm:"CUSTOMERUSERID"`             // 客户ID
+		Customeraccountid    int64     `json:"customeraccountid" xorm:"CUSTOMERACCOUNTID"`       // 客户资金账户ID
+		Signdate             time.Time `json:"signdate" xorm:"SIGNDATE"`                         // 签订日期
+		Closestatus          int32     `json:"closestatus" xorm:"CLOSESTATUS"`                   // 完结状态 - 0:未完结 1:已完结
+		Relatedbizid         string    `json:"relatedbizid" xorm:"RELATEDBIZID"`                 // 关联业务ID
+		Goodunit             string    `json:"goodunit" xorm:"'GOODUNIT'"`                       // 报价单位
+		Wrstandardcode       string    `json:"wrstandardcode"  xorm:"'WRSTANDARDCODE'"`          // 仓单标准代码
+		Wrstandardname       string    `json:"wrstandardname"  xorm:"'WRSTANDARDNAME'"`          // 仓单标准名称
+		Deliverygoodscode    string    `json:"deliverygoodscode"  xorm:"'DELIVERYGOODSCODE'"`    // 交割商品代码
+		Deliverygoodsname    string    `json:"deliverygoodsname"  xorm:"'DELIVERYGOODSNAME'"`    // 交割商品名称
+	}
+
+	datas := make([]spotContractDetail, 0)
+	engine := db.GetEngine()
+	s := engine.Table("ERMS3_SPOTCONTRACTDETAIL").
+		Join("LEFT", "ERMS3_SPOTCONTRACT", "ERMS3_SPOTCONTRACTDETAIL.SPOTCONTRACTID = ERMS3_SPOTCONTRACT.SPOTCONTRACTID").
+		Join("LEFT", "ERMS3_BIZTRADEDETAIL", "ERMS3_BIZTRADEDETAIL.SPOTDETAILID = ERMS3_SPOTCONTRACTDETAIL.SPOTDETAILID").
+		Join("LEFT", "WRSTANDARD", "WRSTANDARD.WRSTANDARDID = ERMS3_SPOTCONTRACTDETAIL.WRSTANDARDID").
+		Join("LEFT", "DELIVERYGOODS", "DELIVERYGOODS.DELIVERYGOODSID = WRSTANDARD.DELIVERYGOODSID").
+		Join("LEFT", "ENUMDICITEM", "WRSTANDARD.UNITID = ENUMDICITEM.ENUMITEMNAME AND ENUMDICITEM.ENUMDICCODE = 'goodsunit'").
+		Select(`to_char(ERMS3_SPOTCONTRACTDETAIL.SPOTCONTRACTID) SPOTCONTRACTID, ERMS3_SPOTCONTRACT.AREAUSERID, ERMS3_SPOTCONTRACT.ACCOUNTID, ERMS3_SPOTCONTRACT.CUSTOMERUSERID, 
+ERMS3_SPOTCONTRACT.CUSTOMERACCOUNTID, ERMS3_SPOTCONTRACT.CLOSESTATUS, ERMS3_SPOTCONTRACT.SIGNDATE, ERMS3_SPOTCONTRACTDETAIL.*, WRSTANDARD.WRSTANDARDNAME, WRSTANDARD.WRSTANDARDCODE, DELIVERYGOODS.DELIVERYGOODSNAME, DELIVERYGOODS.DELIVERYGOODSCODE, 
+to_char(ERMS3_BIZTRADEDETAIL.RELATEDBIZID) RELATEDBIZID, ENUMDICITEM.ENUMDICNAME GOODUNIT`).
+		Where("ERMS3_SPOTCONTRACT.CONTRACTTYPE = ? AND ERMS3_SPOTCONTRACT.CONTRACTMODE = ? AND ERMS3_SPOTCONTRACT.CLOSESTATUS = ?", req.ContractType, req.ContractMode, req.Status).
+		In("ERMS3_SPOTCONTRACT.ACCOUNTID", accountids).
+		Desc("ERMS3_SPOTCONTRACTDETAIL.SPOTCONTRACTID")
+	if err := s.Find(&datas); err != nil {
+		// 查询失败
+		logger.GetLogger().Errorf("QuerySpotContract failed: %s", err.Error())
+		appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
+
+		return
+	}
+
+	userids := make(map[int64]struct{})
+	for i := range datas {
+		userids[datas[i].Areauserid] = struct{}{}
+		userids[datas[i].Customeruserid] = struct{}{}
+	}
+
+	arrayids := make([]int64, 0, len(userids))
+	for k, _ :=range userids {
+		arrayids = append(arrayids, k)
+	}
+
+	// 获取所有用户信息.
+	userinfos, err := models.GetUserInfoByIDS(arrayids)
+	if err != nil {
+		// 查询失败
+		logger.GetLogger().Errorf("QueryUserInfo failed: %s", err.Error())
+		appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
+
+		return
+	}
+
+	userid2names := make(map[int64]string, len(userinfos))
+	for i := range userinfos {
+		userid2names[userinfos[i].Userid] = userinfos[i].Customername
+	}
+
+	infos := make([]QuerySpotContractInfoRsp, 0, len(datas))
+	for i := range datas {
+		infos = append(infos, QuerySpotContractInfoRsp{
+			SpotContractID:    datas[i].Spotcontractid,
+			CustomerName:      userid2names[datas[i].Areauserid],
+			AccountID:         datas[i].Accountid,
+			MatchCustomerName: userid2names[datas[i].Customeruserid],
+			MatchAccountID:    datas[i].Customeraccountid,
+			WRStandardName:    strings.Join([]string{datas[i].Wrstandardname, datas[i].Wrstandardcode}, "/"),
+			TotalQty:          datas[i].Pricedqty - datas[i].Pricedcancelledqty + datas[i].Unpricedqty - datas[i].Unpricedcancelledqty,
+			PricedQty:         datas[i].Pricedqty - datas[i].Pricedcancelledqty,
+			UnPricedQty:       datas[i].Unpricedqty - datas[i].Unpricedcancelledqty,
+			DeliveryQty:       datas[i].Deliveryqty,
+			CurDeliveryQty:    datas[i].Curdeliveryqty,
+			SignDate:          datas[i].Signdate.Format("2006-01-02"),
+			DeliveryGoodsID:   strings.Join([]string{datas[i].Deliverygoodsname, datas[i].Deliverygoodscode}, "/"),
+			RelatedBizID:      datas[i].Relatedbizid,
+			Status:            datas[i].Closestatus,
+		})
+	}
+
+	// 查询成功
+	logger.GetLogger().Debugln("QuerySpotContractDetail successed: %v", infos)
+	appG.Response(http.StatusOK, e.SUCCESS, infos)
+}

+ 128 - 0
docs/docs.go

@@ -869,6 +869,69 @@ var doc = `{
                 }
             }
         },
+        "/Erms3/QuerySpotContractDetail": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "风险管理v3"
+                ],
+                "summary": "查询合同详细信息",
+                "parameters": [
+                    {
+                        "type": "string",
+                        "description": "资金账号ID列表,用逗号分隔",
+                        "name": "accountids",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "合同类型,1-采购合同 2-销售合同",
+                        "name": "contracttype",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "合同模式,1-普通合同 2-回购销售合同",
+                        "name": "contractmode",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "状态,0-履约中 1-已完成",
+                        "name": "status",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/erms3.QuerySpotContractInfoRsp"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/HSBY/GetHsbyMyCount": {
             "get": {
                 "security": [
@@ -4558,6 +4621,71 @@ var doc = `{
                 }
             }
         },
+        "erms3.QuerySpotContractInfoRsp": {
+            "type": "object",
+            "properties": {
+                "accountid": {
+                    "description": "表示交易员ID.",
+                    "type": "integer"
+                },
+                "curdeliveryqty": {
+                    "description": "表示未交收量.",
+                    "type": "number"
+                },
+                "customername": {
+                    "description": "若合同类型为采购合同,表示采购方ID;若合同类型为销售合同,表示销售方ID.",
+                    "type": "string"
+                },
+                "deliverygoodsid": {
+                    "description": "表示品种ID.",
+                    "type": "string"
+                },
+                "deliveryqty": {
+                    "description": "表示交收量.",
+                    "type": "number"
+                },
+                "matchaccountid": {
+                    "description": "表示业务员ID.",
+                    "type": "integer"
+                },
+                "matchcustomername": {
+                    "description": "若合同类型为采购合同,表示销售方;若合同类型为销售合同,表示采购方ID.",
+                    "type": "string"
+                },
+                "priceqty": {
+                    "description": "表示定价量.",
+                    "type": "number"
+                },
+                "relatedbizid": {
+                    "description": "表示业务ID.",
+                    "type": "string"
+                },
+                "signdate": {
+                    "description": "表示签订日期.",
+                    "type": "string"
+                },
+                "spotcontractid": {
+                    "description": "合同ID",
+                    "type": "string"
+                },
+                "status": {
+                    "description": "表示状态,0-履约中 1-已完成.",
+                    "type": "integer"
+                },
+                "totalqty": {
+                    "description": "表示合同量.",
+                    "type": "number"
+                },
+                "unpricedqty": {
+                    "description": "表示未定价量.",
+                    "type": "number"
+                },
+                "wrstandardname": {
+                    "description": "表示商品ID.",
+                    "type": "string"
+                }
+            }
+        },
         "erms3.SoptContractDetail": {
             "type": "object",
             "required": [

+ 128 - 0
docs/swagger.json

@@ -853,6 +853,69 @@
                 }
             }
         },
+        "/Erms3/QuerySpotContractDetail": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "风险管理v3"
+                ],
+                "summary": "查询合同详细信息",
+                "parameters": [
+                    {
+                        "type": "string",
+                        "description": "资金账号ID列表,用逗号分隔",
+                        "name": "accountids",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "合同类型,1-采购合同 2-销售合同",
+                        "name": "contracttype",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "合同模式,1-普通合同 2-回购销售合同",
+                        "name": "contractmode",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "状态,0-履约中 1-已完成",
+                        "name": "status",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/erms3.QuerySpotContractInfoRsp"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/HSBY/GetHsbyMyCount": {
             "get": {
                 "security": [
@@ -4542,6 +4605,71 @@
                 }
             }
         },
+        "erms3.QuerySpotContractInfoRsp": {
+            "type": "object",
+            "properties": {
+                "accountid": {
+                    "description": "表示交易员ID.",
+                    "type": "integer"
+                },
+                "curdeliveryqty": {
+                    "description": "表示未交收量.",
+                    "type": "number"
+                },
+                "customername": {
+                    "description": "若合同类型为采购合同,表示采购方ID;若合同类型为销售合同,表示销售方ID.",
+                    "type": "string"
+                },
+                "deliverygoodsid": {
+                    "description": "表示品种ID.",
+                    "type": "string"
+                },
+                "deliveryqty": {
+                    "description": "表示交收量.",
+                    "type": "number"
+                },
+                "matchaccountid": {
+                    "description": "表示业务员ID.",
+                    "type": "integer"
+                },
+                "matchcustomername": {
+                    "description": "若合同类型为采购合同,表示销售方;若合同类型为销售合同,表示采购方ID.",
+                    "type": "string"
+                },
+                "priceqty": {
+                    "description": "表示定价量.",
+                    "type": "number"
+                },
+                "relatedbizid": {
+                    "description": "表示业务ID.",
+                    "type": "string"
+                },
+                "signdate": {
+                    "description": "表示签订日期.",
+                    "type": "string"
+                },
+                "spotcontractid": {
+                    "description": "合同ID",
+                    "type": "string"
+                },
+                "status": {
+                    "description": "表示状态,0-履约中 1-已完成.",
+                    "type": "integer"
+                },
+                "totalqty": {
+                    "description": "表示合同量.",
+                    "type": "number"
+                },
+                "unpricedqty": {
+                    "description": "表示未定价量.",
+                    "type": "number"
+                },
+                "wrstandardname": {
+                    "description": "表示商品ID.",
+                    "type": "string"
+                }
+            }
+        },
         "erms3.SoptContractDetail": {
             "type": "object",
             "required": [

+ 89 - 0
docs/swagger.yaml

@@ -1319,6 +1319,54 @@ definitions:
           $ref: '#/definitions/models.Wrstandard'
         type: array
     type: object
+  erms3.QuerySpotContractInfoRsp:
+    properties:
+      accountid:
+        description: 表示交易员ID.
+        type: integer
+      curdeliveryqty:
+        description: 表示未交收量.
+        type: number
+      customername:
+        description: 若合同类型为采购合同,表示采购方ID;若合同类型为销售合同,表示销售方ID.
+        type: string
+      deliverygoodsid:
+        description: 表示品种ID.
+        type: string
+      deliveryqty:
+        description: 表示交收量.
+        type: number
+      matchaccountid:
+        description: 表示业务员ID.
+        type: integer
+      matchcustomername:
+        description: 若合同类型为采购合同,表示销售方;若合同类型为销售合同,表示采购方ID.
+        type: string
+      priceqty:
+        description: 表示定价量.
+        type: number
+      relatedbizid:
+        description: 表示业务ID.
+        type: string
+      signdate:
+        description: 表示签订日期.
+        type: string
+      spotcontractid:
+        description: 合同ID
+        type: string
+      status:
+        description: 表示状态,0-履约中 1-已完成.
+        type: integer
+      totalqty:
+        description: 表示合同量.
+        type: number
+      unpricedqty:
+        description: 表示未定价量.
+        type: number
+      wrstandardname:
+        description: 表示商品ID.
+        type: string
+    type: object
   erms3.SoptContractDetail:
     properties:
       deliverygoodsdesc:
@@ -4626,6 +4674,47 @@ paths:
       summary: 查询合同申请表单数据
       tags:
       - 风险管理v3
+  /Erms3/QuerySpotContractDetail:
+    get:
+      parameters:
+      - description: 资金账号ID列表,用逗号分隔
+        in: query
+        name: accountids
+        required: true
+        type: string
+      - description: 合同类型,1-采购合同 2-销售合同
+        in: query
+        name: contracttype
+        required: true
+        type: integer
+      - description: 合同模式,1-普通合同 2-回购销售合同
+        in: query
+        name: contractmode
+        required: true
+        type: integer
+      - description: 状态,0-履约中 1-已完成
+        in: query
+        name: status
+        required: true
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            items:
+              $ref: '#/definitions/erms3.QuerySpotContractInfoRsp'
+            type: array
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 查询合同详细信息
+      tags:
+      - 风险管理v3
   /HSBY/GetHsbyMyCount:
     get:
       description: 说明: 不包括已完成的数量。

+ 8 - 0
models/account.go

@@ -425,6 +425,14 @@ func GetUserInfo(userID int) (*Userinfo, error) {
 	return &userInfo, nil
 }
 
+// GetUserInfoByIDS 批量获取用户信息.
+func GetUserInfoByIDS(userids []int64) ([]Userinfo, error) {
+	engine := db.GetEngine()
+	infos := make([]Userinfo, 0)
+	err := engine.In("USERID", userids).Find(&infos)
+	return infos, err
+}
+
 // GetUserFavoriteGoodses 获取用户商品收藏信息
 func GetUserFavoriteGoodses(userID int) ([]Userfavoritegoods, error) {
 	engine := db.GetEngine()

+ 76 - 0
models/erms3.go

@@ -3,9 +3,57 @@ package models
 
 import (
 	"mtp2_if/db"
+	"strconv"
+	"strings"
 	"time"
 )
 
+// Erms3Spotcontractdetail 合同标的明细表
+type Erms3Spotcontractdetail struct {
+	Spotdetailid          string    `json:"spotdetailid" xorm:"SPOTDETAILID"`                   // 标的明细ID(346+Unix秒时间戳(10位)+xxxxxx)
+	Spotcontractid        string    `json:"spotcontractid" xorm:"SPOTCONTRACTID"`               // 现货合同ID
+	Wrstandardid          int64     `json:"wrstandardid" xorm:"WRSTANDARDID"`                   // 仓单标准ID
+	Deliverygoodsid       int64     `json:"deliverygoodsid" xorm:"DELIVERYGOODSID"`             // 现货品种ID
+	Tradedate             string    `json:"tradedate" xorm:"TRADEDATE"`                         // 交易日(yyyyMMdd)
+	Contracttype          int32     `json:"contracttype" xorm:"CONTRACTTYPE"`                   // 现货合同类型 - 1:采购 -1:销售
+	Accountid             int64     `json:"accountid" xorm:"ACCOUNTID"`                         // 资金账户ID
+	Customeraccountid     int64     `json:"customeraccountid" xorm:"CUSTOMERACCOUNTID"`         // 客户资金账户ID
+	Producttype           int32     `json:"producttype" xorm:"PRODUCTTYPE"`                     // 产品类型 - 1:标准仓单 2:等标 3:非标
+	Deliverygoodsdesc     string    `json:"deliverygoodsdesc" xorm:"DELIVERYGOODSDESC"`         // 产品规格 - 根据此字段生成仓单标准、仓单要素类型
+	Warehouseid           int64     `json:"warehouseid" xorm:"WAREHOUSEID"`                     // 仓库ID
+	Pointdesc             string    `json:"pointdesc" xorm:"POINTDESC"`                         // 点价描述
+	Priceqty              float64   `json:"priceqty" xorm:"PRICEQTY"`                           // 指定价类总量
+	Pointqty              float64   `json:"pointqty" xorm:"POINTQTY"`                           // 点价类总量
+	Unpricedqty           float64   `json:"unpricedqty" xorm:"UNPRICEDQTY"`                     // 未确定量
+	Unpricedrelatedqty    float64   `json:"unpricedrelatedqty" xorm:"UNPRICEDRELATEDQTY"`       // 未确定量关联量
+	Unpricedavaliableqty  float64   `json:"unpricedavaliableqty" xorm:"UNPRICEDAVALIABLEQTY"`   // 未确定量可关联量
+	Unpricedcancelledqty  float64   `json:"unpricedcancelledqty" xorm:"UNPRICEDCANCELLEDQTY"`   // 未确定量撤销量(非业务)
+	Pricedqty             float64   `json:"pricedqty" xorm:"PRICEDQTY"`                         // 确定量
+	Pricedamount          float64   `json:"pricedamount" xorm:"PRICEDAMOUNT"`                   // 确定金额
+	Pricedrelatedqty      float64   `json:"pricedrelatedqty" xorm:"PRICEDRELATEDQTY"`           // 确定量关联量
+	Pricedavaliableqty    float64   `json:"pricedavaliableqty" xorm:"PRICEDAVALIABLEQTY"`       // 确定量可关联量
+	Pricedcancelledqty    float64   `json:"pricedcancelledqty" xorm:"PRICEDCANCELLEDQTY"`       // 确定量撤销量(非业务)
+	Pricedcancelledamount float64   `json:"pricedcancelledamount" xorm:"PRICEDCANCELLEDAMOUNT"` // 确定量撤销金额(非业务)
+	Deliveryqty           float64   `json:"deliveryqty" xorm:"DELIVERYQTY"`                     // 交收数量(非业务)
+	Deliveryamount        float64   `json:"deliveryamount" xorm:"DELIVERYAMOUNT"`               // 交收金额(非业务)
+	Deliveryovershortqty  float64   `json:"deliveryovershortqty" xorm:"DELIVERYOVERSHORTQTY"`   // 交收溢短数量(非业务)
+	Deliveryactualamount  float64   `json:"deliveryactualamount" xorm:"DELIVERYACTUALAMOUNT"`   // 交收实际金额(非业务)
+	Deliveryotheramount   float64   `json:"deliveryotheramount" xorm:"DELIVERYOTHERAMOUNT"`     // 交收其它费用(非业务)
+	Curdeliveryqty        float64   `json:"curdeliveryqty" xorm:"CURDELIVERYQTY"`               // 剩余交收数量
+	Curdeliveryamount     float64   `json:"curdeliveryamount" xorm:"CURDELIVERYAMOUNT"`         // 剩余交收金额
+	Remark                string    `json:"remark" xorm:"REMARK"`                               // 备注
+	Marketid              int64     `json:"marketid" xorm:"MARKETID"`                           // 市场ID
+	Handlestatus          int32     `json:"handlestatus" xorm:"HANDLESTATUS"`                   // 处理状态
+	Updatetime            time.Time `json:"updatetime" xorm:"UPDATETIME"`                       // 更新时间
+	Reckonedamount        float64   `json:"reckonedamount" xorm:"RECKONEDAMOUNT"`               // 已结金额
+	Invoicedamount        float64   `json:"invoicedamount" xorm:"INVOICEDAMOUNT"`               // 已开票金额
+}
+
+// TableName is ERMS3_SPOTCONTRACTDETAIL
+func (Erms3Spotcontractdetail) TableName() string {
+	return "ERMS3_SPOTCONTRACTDETAIL"
+}
+
 // Erms3SpotContractApply 现货合同申请表
 type Erms3SpotContractApply struct {
 	SpotContractID     int64     `json:"spotcontractid"  xorm:"'SPOTCONTRACTID'" binging:"required"` // 现货合同ID(345+Unix秒时间戳(10位)+xxxxxx)
@@ -106,3 +154,31 @@ func AddSpotContractApply(spotContractApply Erms3SpotContractApply) error {
 
 	return err
 }
+
+// GetSpotContractByParams 根据参数来获取合同.
+func GetSpotContractByParams(accountids string, contracttype int32, contractmode int32, status int32) ([]Erms3Spotcontract, error) {
+	engine := db.GetEngine()
+	strids := strings.Split(accountids, ",")
+	ids := make([]int64, len(strids))
+	for i := range strids {
+		id, err := strconv.ParseInt(strids[i], 10, 64)
+		if err != nil {
+			return nil, err
+		}
+
+		ids[i] = id
+	}
+
+	scs := make([]Erms3Spotcontract, 0)
+	err := engine.Where("CONTRACTMODE = ? and CONTRACTTYPE = ? and CLOSESTATUS = ?", contractmode, contracttype, status).In("ACCOUNTID", ids).Find(&scs)
+
+	return scs, err
+}
+
+// GetSpotContractDetailByID 根据合同ID来获取明细.
+func GetSpotContractDetailByID(spotcontractids []string) ([]Erms3Spotcontractdetail, error) {
+	engine := db.GetEngine()
+	details := make([]Erms3Spotcontractdetail, 0)
+	err := engine.In("SPOTCONTRACTID", spotcontractids).Find(&details)
+	return details, err
+}

+ 2 - 0
routers/router.go

@@ -179,6 +179,8 @@ func InitRouter() *gin.Engine {
 		erms3R.POST("/AddSpotContractApply", erms3.AddSpotContractApply)
 		// 查询合同申请表单数据
 		erms3R.GET("/QuerySpotContractAppleForm", erms3.QuerySpotContractAppleForm)
+		// 查询合同详细信息.
+		erms3R.GET("/QuerySpotContractDetail", erms3.QuerySpotContractDetail)
 	}
 	// ************************ 定制【尚志大宗】 ************************
 	szdzR := apiR.Group("SZDZ")