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

增加“查询合同申请表单数据”接口

zhou.xiaoning преди 5 години
родител
ревизия
1a1a744bab
променени са 10 файла, в които са добавени 1667 реда и са изтрити 334 реда
  1. 4 4
      config/config.xml
  2. 0 321
      controllers/erms3/erms3.go
  3. 454 0
      controllers/erms3/spotContract.go
  4. 402 0
      docs/docs.go
  5. 402 0
      docs/swagger.json
  6. 285 0
      docs/swagger.yaml
  7. 11 6
      models/account.go
  8. 21 0
      models/goods.go
  9. 83 0
      models/wrTrade.go
  10. 5 3
      routers/router.go

+ 4 - 4
config/config.xml

@@ -16,12 +16,12 @@
         <DbAddress value="192.168.31.117"/>
         <DbName    value="orcl"/>
         <DbPort    value="1521"/>
-        <DbUser    value="mtp2_test166"/>
+        <DbUser    value="mtp2_test104"/>
         <DbPwd     value="muchinfo"/>
     </DbSetting>
 
     <RedisSetting>
-        <Address   value="192.168.31.166"/>
+        <Address   value="192.168.31.104"/>
         <Port      value="5007"/>
         <Timeout   value="3"/>
         <ConnNum   value="1"/>
@@ -30,12 +30,12 @@
     </RedisSetting>
 
     <MqSetting>
-        <Url       value="amqp://guest:guest@192.168.31.166:5020/test"/>
+        <Url       value="amqp://guest:guest@192.168.31.104:5020/test"/>
         <Exchange  value="entry"/>
     </MqSetting>
 
     <MongoDBSetting>
-        <HostName   value="192.168.31.166"/>
+        <HostName   value="192.168.31.104"/>
         <Port       value="5025"/>
         <DBName     value="HistoryQuote"/>
         <Username   value="quote_test01"/>

+ 0 - 321
controllers/erms3/erms3.go

@@ -1,321 +0,0 @@
-package erms3
-
-import (
-	"encoding/json"
-	"math"
-	"mtp2_if/db"
-	"mtp2_if/global/app"
-	"mtp2_if/global/e"
-	"mtp2_if/logger"
-	"mtp2_if/models"
-	"net/http"
-	"time"
-
-	"github.com/gin-gonic/gin"
-)
-
-// RecordUtcCount UTC计数(毫秒)
-var RecordUtcCount int = 0
-
-// SecondCount 秒计数
-var SecondCount int = 0
-
-// SpotPriceOrder 定价明细
-type SpotPriceOrder struct {
-	Price  float64 `json:"price" binding:"required"`  // 价格
-	Qty    float64 `json:"qty" binding:"required"`    // 数量
-	Amount float64 `json:"amount" binding:"required"` // 金额
-}
-
-// SpotPointOrder 点价明细
-type SpotPointOrder struct {
-	GoodsID   int32   `json:"goodsid" binding:"required"`   // 商品ID
-	GoodsName string  `json:"goodsname"`                    // 商品名称
-	Qty       float64 `json:"qty" binding:"required"`       // 数量
-	Basic     float64 `json:"basic" binding:"required"`     // 基差
-	StartDate string  `json:"startdate" binding:"required"` // 点价开始日期
-	EndDate   string  `json:"enddate" binding:"required"`   // 点价结束日期
-}
-
-// SoptContractDetail 合同明细信息
-type SoptContractDetail struct {
-	WrStandardID         int64            `json:"wrstandardid" binding:"required"`    // 交易标的ID
-	WrStandardName       string           `json:"wrstandardname" binding:"required"`  // 交易标的名称
-	ProductType          int32            `json:"producttype" binding:"required"`     // 产品类型 1:标准仓单 2:等标 3:非标
-	ProductTypeName      string           `json:"producttypename"`                    // 产品类型名称
-	DeliveryGoodsID      int32            `json:"deliverygoodsid" binding:"required"` // 现货品种ID
-	DeliveryGoodsName    string           `json:"deliverygoodsname"`                  // 现货品种名称
-	DeliveryGoodsDesc    string           `json:"deliverygoodsdesc"`                  // 现货品种说明
-	WarehouseID          int32            `json:"warehouseid" binding:"required"`     // 仓库ID
-	WarehouseName        int32            `json:"warehousename"`                      // 仓库名称
-	UnitName             string           `json:"unitname" binding:"required"`        // 单位名称
-	PointDesc            string           `json:"pointdesc"`                          // 点价描述
-	SpotPriceOrderList   []SpotPriceOrder `json:"spotPriceOrderList"`                 // 定价列表
-	SpotPointOrderVoList []SpotPointOrder `json:"spotPointOrderVoList"`               // 点价列表
-}
-
-// SoptContractDetailSum 合同明细信息汇总(组织JSON使用)
-type SoptContractDetailSum struct {
-	WrStandardID          int64            `json:"wrstandardid" binding:"required"`    // 交易标的ID
-	WrStandardName        string           `json:"wrstandardname" binding:"required"`  // 交易标的名称
-	ProductType           int32            `json:"producttype" binding:"required"`     // 产品类型 1:标准仓单 2:等标 3:非标
-	ProductTypeName       string           `json:"producttypename"`                    // 产品类型名称
-	DeliveryGoodsID       int32            `json:"deliverygoodsid" binding:"required"` // 现货品种ID
-	DeliveryGoodsName     string           `json:"deliverygoodsname"`                  // 现货品种名称
-	DeliveryGoodsDesc     string           `json:"deliverygoodsdesc"`                  // 现货品种说明
-	WarehouseID           int32            `json:"warehouseid" binding:"required"`     // 仓库ID
-	WarehouseName         int32            `json:"warehousename"`                      // 仓库名称
-	UnitName              string           `json:"unitname" binding:"required"`        // 单位名称
-	PointDesc             string           `json:"pointdesc"`                          // 点价描述
-	SpotPriceOrderList    []SpotPriceOrder `json:"spotPriceOrderList"`                 // 定价列表
-	SpotPointOrderVoList  []SpotPointOrder `json:"spotPointOrderVoList"`               // 点价列表
-	TotalPriceOrderQty    float64          `json:"totalPriceOrderQty"`                 // 定价总数量
-	TotalPriceOrderPrice  float64          `json:"totalPriceOrderPrice"`               // 定价总价格
-	TotalPriceOrderAmount float64          `json:"totalPriceOrderAmount"`              // 定价总金额
-	TotalPointOrderQty    float64          `json:"totalPointOrderQty"`                 // 点价总数量
-	TotalQty              float64          `json:"totalQty"`                           // 总数量
-}
-
-// AddSpotContractApplyReq 新增现货合同申请请求
-type AddSpotContractApplyReq struct {
-	ContractNo         string               `json:"contractno" binding:"required"`        // 现货合同编号
-	ContractType       int32                `json:"contracttype" binding:"required"`      // 现货合同类型 - 1:采购 -1:销售
-	AreaUserID         int32                `json:"areauserid" binding:"required"`        // 所属机构
-	AccountID          int64                `json:"accountid" binding:"required"`         // 资金账户ID
-	CustomerUserID     int32                `json:"customeruserid" binding:"required"`    // 客户ID
-	CustomerAccountID  int64                `json:"customeraccountid" binding:"required"` // 客户资金账户ID
-	SignDate           time.Time            `json:"signdate" binding:"required"`          // 签订日期
-	LastDate           time.Time            `json:"lastdate" binding:"required"`          // 交货时间
-	ContractAttachment string               `json:"contractattachment"`                   // 合同附件
-	OriMarginPayer     int32                `json:"orimarginpayer" binding:"required"`    // 初始保证金支付方 -1:买方 2:卖方
-	OriMargin          float64              `json:"orimargin" binding:"required"`         // 初始保证金
-	Remark             string               `json:"remark"`                               // 备注
-	MarketID           int32                `json:"marketid" binding:"required"`          // 市场ID
-	CreatorID          int32                `json:"creatorid"`                            // 申请人
-	Details            []SoptContractDetail `json:"details" binding:"required"`           // 明细
-}
-
-// AddSpotContractApplyRsp 新增现货合同申请响应
-type AddSpotContractApplyRsp struct {
-	SpotContractID int64  `json:"spotcontractid"   binging:"required"` // 现货合同ID(345+Unix秒时间戳(10位)+xxxxxx)
-	ContractNo     string `json:"contractno" binding:"required""`      // 现货合同编号
-}
-
-// AddSpotContractApply 新增现货合同申请
-// @Summary 新增现货合同申请
-// @Produce json
-// @Security ApiKeyAuth
-// @Param contractno query string true "现货合同编号"
-// @Param contracttype query int true "现货合同类型, 1:采购 -1:销售"
-// @Param areauserid query int true "所属机构"
-// @Param accountid query int true "资金账户ID"
-// @Param customeruserid query int true "客户ID"
-// @Param customeraccountid query int true "客户资金账户ID"
-// @Param signdate query string true "签订日期, 格式:yyyy-MM-dd HH:mm:ss"
-// @Param lastdate query string true "交货时间, 格式:yyyy-MM-dd HH:mm:ss"
-// @Param contractattachment query string true "合同附件"
-// @Param orimarginpayer query int true "初始保证金支付方, 1:买方 2:卖方"
-// @Param orimargin query float true "初始保证金"
-// @Param remark query string true "备注"
-// @Param marketid query int true "市场ID"
-// @Param creatorid query int true "申请人"
-// @Param details query []SoptContractDetail true "明细"
-// @Success 200 {object} AddSpotContractApplyRsp
-// @Failure 500 {object} app.Response
-// @Router /Erms3/AddSpotContractApply [post]
-// @Tags 风险管理
-func AddSpotContractApply(c *gin.Context) {
-	appG := app.Gin{C: c}
-
-	// 获取请求参数
-	var req AddSpotContractApplyReq
-	err := appG.C.ShouldBindQuery(&req)
-	if err != nil {
-		logger.GetLogger().Errorf("AddSpotContractApply failed: %s", err.Error())
-		appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
-		return
-	}
-
-	// 生成申请ID
-	spotcontractid := GenSpotContractID()
-
-	// 获取当前交易日
-	tradedate, err := GetMarketTradeDate(int(req.MarketID))
-	if err != nil {
-		// 返回失败
-		logger.GetLogger().Errorf("AddSpotContractApply get market trade date failed: %s", err.Error())
-		appG.Response(http.StatusBadRequest, e.ERROR_OPERATION_FAILED, nil)
-		return
-	}
-
-	// 根据明细,生成JSON信息
-	detailjson, err := BuildDetailJSON(req.Details)
-	if err != nil {
-		// 返回失败
-		logger.GetLogger().Errorf("AddSpotContractApply build detail json failed: %s", err.Error())
-		appG.Response(http.StatusBadRequest, e.ERROR_OPERATION_FAILED, nil)
-		return
-	}
-
-	// 组织sql,插入现货合同申请信息
-	sql := `INSERT INTO ERMS3_SPOTCONTRACTAPPLY(SPOTCONTRACTID,
-				TRADEDATE,
-				CONTRACTNO,
-				CONTRACTTYPE,
-				AREAUSERID,
-				ACCOUNTID,
-				CUSTOMERUSERID,
-				CUSTOMERACCOUNTID,
-				SIGNDATE,
-				LASTDATE,
-				CONTRACTATTACHMENT,
-				ORIMARGINPAYER,
-				ORIMARGIN,
-				REMARK,
-				DETAILJSON,
-				APPLYSTATUS,
-				APPLYSRC,
-				MARKETID,
-				CREATORID,
-				CREATETIME)
-			VALUES(
-				?,
-				?,
-				?,
-				?,
-				?,
-				?,
-				?,
-				?,
-				to_date(?, 'YYYY-MM-DD HH24:MI:SS'),
-				to_date(?, 'YYYY-MM-DD HH24:MI:SS'),
-				?,
-				?,
-				?,
-				?,
-				?,
-				0,
-				2,
-				?,
-				?,
-				sysdate)`
-
-	engine := db.GetEngine()
-	if _, err := engine.Exec(sql,
-		spotcontractid,
-		tradedate,
-		req.ContractNo,
-		req.ContractType,
-		req.AreaUserID,
-		req.AccountID,
-		req.CustomerUserID,
-		req.CustomerAccountID,
-		req.SignDate,
-		req.LastDate,
-		req.ContractAttachment,
-		req.OriMarginPayer,
-		req.OriMargin,
-		req.Remark,
-		detailjson,
-		req.MarketID,
-		req.CreatorID); err != nil {
-		// 插入失败
-		logger.GetLogger().Errorf("AddSpotContractApply failed: %s", err.Error())
-		appG.Response(http.StatusBadRequest, e.ERROR_OPERATION_FAILED, nil)
-		return
-	}
-
-	rsp := AddSpotContractApplyRsp{
-		SpotContractID: spotcontractid,
-		ContractNo:     req.ContractNo,
-	}
-
-	// 查询成功
-	logger.GetLogger().Debugln("AddSpotContractApply successed: %v", rsp)
-	appG.Response(http.StatusOK, e.SUCCESS, rsp)
-}
-
-// GenSpotContractID 生成现货合同ID
-func GenSpotContractID() int64 {
-	// 获取当前时间
-	cur := time.Now()
-
-	// UnitNano获取的是纳秒,除以1000000获取毫秒级的时间戳
-	timestamp := cur.UnixNano() / 1000000
-
-	// 除以1000获取秒级的时间戳
-	var curutc int = int(timestamp / 1000)
-	if RecordUtcCount == curutc {
-		SecondCount = SecondCount + 1
-	} else {
-		RecordUtcCount = curutc
-		SecondCount = 1
-	}
-
-	var id int64 = int64(345)*int64(math.Pow(10, 16)) + int64(RecordUtcCount)*int64(math.Pow(10, 6)) + int64(SecondCount)
-	return id
-}
-
-// GetMarketTradeDate 获取市场交易日
-func GetMarketTradeDate(marketid int) (string, error) {
-	marketrun, err := models.GetMarketRun(marketid)
-	if err != nil {
-		return "", err
-	}
-	return marketrun.Tradedate, nil
-}
-
-// BuildDetailJSON 组件合同明细JSON
-func BuildDetailJSON(details []SoptContractDetail) (string, error) {
-	detailsums := make([]SoptContractDetailSum, 0)
-
-	for _, detail := range details {
-		var totalpriceorderqty float64 = 0
-		var totalpriceorderprice float64 = 0
-		var totalpriceorderamount float64 = 0
-		var totalpointorderqty float64 = 0
-		var totalqty float64 = 0
-
-		for _, spotpriceorder := range detail.SpotPriceOrderList {
-			totalpriceorderqty = totalpriceorderqty + spotpriceorder.Qty
-			totalpriceorderprice = totalpriceorderprice + spotpriceorder.Price
-			totalpriceorderamount = totalpriceorderamount + spotpriceorder.Amount
-		}
-
-		for _, spotpointorder := range detail.SpotPointOrderVoList {
-			totalpointorderqty = totalpointorderqty + spotpointorder.Qty
-		}
-
-		totalqty = totalpriceorderqty + totalpointorderqty
-
-		var detailsum SoptContractDetailSum
-		detailsum = SoptContractDetailSum{
-			WrStandardID:          detail.WrStandardID,
-			WrStandardName:        detail.WrStandardName,
-			ProductType:           detail.ProductType,
-			ProductTypeName:       detail.ProductTypeName,
-			DeliveryGoodsID:       detail.DeliveryGoodsID,
-			DeliveryGoodsName:     detail.DeliveryGoodsName,
-			DeliveryGoodsDesc:     detail.DeliveryGoodsDesc,
-			WarehouseID:           detail.WarehouseID,
-			WarehouseName:         detail.WarehouseName,
-			UnitName:              detail.UnitName,
-			PointDesc:             detail.PointDesc,
-			SpotPriceOrderList:    detail.SpotPriceOrderList,
-			SpotPointOrderVoList:  detail.SpotPointOrderVoList,
-			TotalPriceOrderQty:    totalpriceorderqty,
-			TotalPriceOrderPrice:  totalpriceorderprice,
-			TotalPriceOrderAmount: totalpriceorderamount,
-			TotalPointOrderQty:    totalpointorderqty,
-			TotalQty:              totalqty,
-		}
-		detailsums = append(detailsums, detailsum)
-	}
-
-	jsoninfo, err := json.Marshal(detailsums)
-	if err != nil {
-
-		return "", err
-	}
-	return string(jsoninfo), nil
-}

+ 454 - 0
controllers/erms3/spotContract.go

@@ -1,3 +1,457 @@
 package erms3
 
+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"
+	"time"
+
+	"github.com/gin-gonic/gin"
+)
+
 // spotContract.go 现货合同
+
+// RecordUtcCount UTC计数(毫秒)
+var RecordUtcCount int = 0
+
+// SecondCount 秒计数
+var SecondCount int = 0
+
+// SpotPriceOrder 定价明细
+type SpotPriceOrder struct {
+	Price  float64 `json:"price" binding:"required"`  // 价格
+	Qty    float64 `json:"qty" binding:"required"`    // 数量
+	Amount float64 `json:"amount" binding:"required"` // 金额
+}
+
+// SpotPointOrder 点价明细
+type SpotPointOrder struct {
+	GoodsID   int32   `json:"goodsid" binding:"required"`   // 商品ID
+	GoodsName string  `json:"goodsname"`                    // 商品名称
+	Qty       float64 `json:"qty" binding:"required"`       // 数量
+	Basic     float64 `json:"basic" binding:"required"`     // 基差
+	StartDate string  `json:"startdate" binding:"required"` // 点价开始日期
+	EndDate   string  `json:"enddate" binding:"required"`   // 点价结束日期
+}
+
+// SoptContractDetail 合同明细信息
+type SoptContractDetail struct {
+	WrStandardID         int64            `json:"wrstandardid" binding:"required"`    // 交易标的ID
+	WrStandardName       string           `json:"wrstandardname" binding:"required"`  // 交易标的名称
+	ProductType          int32            `json:"producttype" binding:"required"`     // 产品类型 1:标准仓单 2:等标 3:非标
+	ProductTypeName      string           `json:"producttypename"`                    // 产品类型名称
+	DeliveryGoodsID      int32            `json:"deliverygoodsid" binding:"required"` // 现货品种ID
+	DeliveryGoodsName    string           `json:"deliverygoodsname"`                  // 现货品种名称
+	DeliveryGoodsDesc    string           `json:"deliverygoodsdesc"`                  // 现货品种说明
+	WarehouseID          int32            `json:"warehouseid" binding:"required"`     // 仓库ID
+	WarehouseName        int32            `json:"warehousename"`                      // 仓库名称
+	UnitName             string           `json:"unitname" binding:"required"`        // 单位名称
+	PointDesc            string           `json:"pointdesc"`                          // 点价描述
+	SpotPriceOrderList   []SpotPriceOrder `json:"spotPriceOrderList"`                 // 定价列表
+	SpotPointOrderVoList []SpotPointOrder `json:"spotPointOrderVoList"`               // 点价列表
+}
+
+// SoptContractDetailSum 合同明细信息汇总(组织JSON使用)
+type SoptContractDetailSum struct {
+	WrStandardID          int64            `json:"wrstandardid" binding:"required"`    // 交易标的ID
+	WrStandardName        string           `json:"wrstandardname" binding:"required"`  // 交易标的名称
+	ProductType           int32            `json:"producttype" binding:"required"`     // 产品类型 1:标准仓单 2:等标 3:非标
+	ProductTypeName       string           `json:"producttypename"`                    // 产品类型名称
+	DeliveryGoodsID       int32            `json:"deliverygoodsid" binding:"required"` // 现货品种ID
+	DeliveryGoodsName     string           `json:"deliverygoodsname"`                  // 现货品种名称
+	DeliveryGoodsDesc     string           `json:"deliverygoodsdesc"`                  // 现货品种说明
+	WarehouseID           int32            `json:"warehouseid" binding:"required"`     // 仓库ID
+	WarehouseName         int32            `json:"warehousename"`                      // 仓库名称
+	UnitName              string           `json:"unitname" binding:"required"`        // 单位名称
+	PointDesc             string           `json:"pointdesc"`                          // 点价描述
+	SpotPriceOrderList    []SpotPriceOrder `json:"spotPriceOrderList"`                 // 定价列表
+	SpotPointOrderVoList  []SpotPointOrder `json:"spotPointOrderVoList"`               // 点价列表
+	TotalPriceOrderQty    float64          `json:"totalPriceOrderQty"`                 // 定价总数量
+	TotalPriceOrderPrice  float64          `json:"totalPriceOrderPrice"`               // 定价总价格
+	TotalPriceOrderAmount float64          `json:"totalPriceOrderAmount"`              // 定价总金额
+	TotalPointOrderQty    float64          `json:"totalPointOrderQty"`                 // 点价总数量
+	TotalQty              float64          `json:"totalQty"`                           // 总数量
+}
+
+// AddSpotContractApplyReq 新增现货合同申请请求
+type AddSpotContractApplyReq struct {
+	ContractNo         string               `json:"contractno" binding:"required"`        // 现货合同编号
+	ContractType       int32                `json:"contracttype" binding:"required"`      // 现货合同类型 - 1:采购 -1:销售
+	AreaUserID         int32                `json:"areauserid" binding:"required"`        // 所属机构
+	AccountID          int64                `json:"accountid" binding:"required"`         // 资金账户ID
+	CustomerUserID     int32                `json:"customeruserid" binding:"required"`    // 客户ID
+	CustomerAccountID  int64                `json:"customeraccountid" binding:"required"` // 客户资金账户ID
+	SignDate           time.Time            `json:"signdate" binding:"required"`          // 签订日期
+	LastDate           time.Time            `json:"lastdate" binding:"required"`          // 交货时间
+	ContractAttachment string               `json:"contractattachment"`                   // 合同附件
+	OriMarginPayer     int32                `json:"orimarginpayer" binding:"required"`    // 初始保证金支付方 -1:买方 2:卖方
+	OriMargin          float64              `json:"orimargin" binding:"required"`         // 初始保证金
+	Remark             string               `json:"remark"`                               // 备注
+	MarketID           int32                `json:"marketid" binding:"required"`          // 市场ID
+	CreatorID          int32                `json:"creatorid"`                            // 申请人
+	Details            []SoptContractDetail `json:"details" binding:"required"`           // 明细
+}
+
+// AddSpotContractApplyRsp 新增现货合同申请响应
+type AddSpotContractApplyRsp struct {
+	SpotContractID int64  `json:"spotcontractid"   binging:"required"` // 现货合同ID(345+Unix秒时间戳(10位)+xxxxxx)
+	ContractNo     string `json:"contractno" binding:"required""`      // 现货合同编号
+}
+
+// AddSpotContractApply 新增现货合同申请
+// @Summary 新增现货合同申请
+// @Produce json
+// @Security ApiKeyAuth
+// @Param contractno query string true "现货合同编号"
+// @Param contracttype query int true "现货合同类型, 1:采购 -1:销售"
+// @Param areauserid query int true "所属机构"
+// @Param accountid query int true "资金账户ID"
+// @Param customeruserid query int true "客户ID"
+// @Param customeraccountid query int true "客户资金账户ID"
+// @Param signdate query string true "签订日期, 格式:yyyy-MM-dd HH:mm:ss"
+// @Param lastdate query string true "交货时间, 格式:yyyy-MM-dd HH:mm:ss"
+// @Param contractattachment query string true "合同附件"
+// @Param orimarginpayer query int true "初始保证金支付方, 1:买方 2:卖方"
+// @Param orimargin query number true "初始保证金"
+// @Param remark query string true "备注"
+// @Param marketid query int true "市场ID"
+// @Param creatorid query int true "申请人"
+// @Param details query int true "明细"
+// @Success 200 {object} AddSpotContractApplyRsp
+// @Failure 500 {object} app.Response
+// @Router /Erms3/AddSpotContractApply [post]
+// @Tags 风险管理v3
+func AddSpotContractApply(c *gin.Context) {
+	appG := app.Gin{C: c}
+
+	// 获取请求参数
+	var req AddSpotContractApplyReq
+	err := appG.C.ShouldBindQuery(&req)
+	if err != nil {
+		logger.GetLogger().Errorf("AddSpotContractApply failed: %s", err.Error())
+		appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
+		return
+	}
+
+	// 生成申请ID
+	spotcontractid := GenSpotContractID()
+
+	// 获取当前交易日
+	tradedate, err := GetMarketTradeDate(int(req.MarketID))
+	if err != nil {
+		// 返回失败
+		logger.GetLogger().Errorf("AddSpotContractApply get market trade date failed: %s", err.Error())
+		appG.Response(http.StatusBadRequest, e.ERROR_OPERATION_FAILED, nil)
+		return
+	}
+
+	// 根据明细,生成JSON信息
+	detailjson, err := BuildDetailJSON(req.Details)
+	if err != nil {
+		// 返回失败
+		logger.GetLogger().Errorf("AddSpotContractApply build detail json failed: %s", err.Error())
+		appG.Response(http.StatusBadRequest, e.ERROR_OPERATION_FAILED, nil)
+		return
+	}
+
+	// 组织sql,插入现货合同申请信息
+	sql := `INSERT INTO ERMS3_SPOTCONTRACTAPPLY(SPOTCONTRACTID,
+				TRADEDATE,
+				CONTRACTNO,
+				CONTRACTTYPE,
+				AREAUSERID,
+				ACCOUNTID,
+				CUSTOMERUSERID,
+				CUSTOMERACCOUNTID,
+				SIGNDATE,
+				LASTDATE,
+				CONTRACTATTACHMENT,
+				ORIMARGINPAYER,
+				ORIMARGIN,
+				REMARK,
+				DETAILJSON,
+				APPLYSTATUS,
+				APPLYSRC,
+				MARKETID,
+				CREATORID,
+				CREATETIME)
+			VALUES(
+				?,
+				?,
+				?,
+				?,
+				?,
+				?,
+				?,
+				?,
+				to_date(?, 'YYYY-MM-DD HH24:MI:SS'),
+				to_date(?, 'YYYY-MM-DD HH24:MI:SS'),
+				?,
+				?,
+				?,
+				?,
+				?,
+				0,
+				2,
+				?,
+				?,
+				sysdate)`
+
+	engine := db.GetEngine()
+	if _, err := engine.Exec(sql,
+		spotcontractid,
+		tradedate,
+		req.ContractNo,
+		req.ContractType,
+		req.AreaUserID,
+		req.AccountID,
+		req.CustomerUserID,
+		req.CustomerAccountID,
+		req.SignDate,
+		req.LastDate,
+		req.ContractAttachment,
+		req.OriMarginPayer,
+		req.OriMargin,
+		req.Remark,
+		detailjson,
+		req.MarketID,
+		req.CreatorID); err != nil {
+		// 插入失败
+		logger.GetLogger().Errorf("AddSpotContractApply failed: %s", err.Error())
+		appG.Response(http.StatusBadRequest, e.ERROR_OPERATION_FAILED, nil)
+		return
+	}
+
+	rsp := AddSpotContractApplyRsp{
+		SpotContractID: spotcontractid,
+		ContractNo:     req.ContractNo,
+	}
+
+	// 查询成功
+	logger.GetLogger().Debugln("AddSpotContractApply successed: %v", rsp)
+	appG.Response(http.StatusOK, e.SUCCESS, rsp)
+}
+
+// GenSpotContractID 生成现货合同ID
+func GenSpotContractID() int64 {
+	// 获取当前时间
+	cur := time.Now()
+
+	// UnitNano获取的是纳秒,除以1000000获取毫秒级的时间戳
+	timestamp := cur.UnixNano() / 1000000
+
+	// 除以1000获取秒级的时间戳
+	var curutc int = int(timestamp / 1000)
+	if RecordUtcCount == curutc {
+		SecondCount = SecondCount + 1
+	} else {
+		RecordUtcCount = curutc
+		SecondCount = 1
+	}
+
+	var id int64 = int64(345)*int64(math.Pow(10, 16)) + int64(RecordUtcCount)*int64(math.Pow(10, 6)) + int64(SecondCount)
+	return id
+}
+
+// GetMarketTradeDate 获取市场交易日
+func GetMarketTradeDate(marketid int) (string, error) {
+	marketrun, err := models.GetMarketRun(marketid)
+	if err != nil {
+		return "", err
+	}
+	return marketrun.Tradedate, nil
+}
+
+// BuildDetailJSON 组件合同明细JSON
+func BuildDetailJSON(details []SoptContractDetail) (string, error) {
+	detailsums := make([]SoptContractDetailSum, 0)
+
+	for _, detail := range details {
+		var totalpriceorderqty float64 = 0
+		var totalpriceorderprice float64 = 0
+		var totalpriceorderamount float64 = 0
+		var totalpointorderqty float64 = 0
+		var totalqty float64 = 0
+
+		for _, spotpriceorder := range detail.SpotPriceOrderList {
+			totalpriceorderqty = totalpriceorderqty + spotpriceorder.Qty
+			totalpriceorderprice = totalpriceorderprice + spotpriceorder.Price
+			totalpriceorderamount = totalpriceorderamount + spotpriceorder.Amount
+		}
+
+		for _, spotpointorder := range detail.SpotPointOrderVoList {
+			totalpointorderqty = totalpointorderqty + spotpointorder.Qty
+		}
+
+		totalqty = totalpriceorderqty + totalpointorderqty
+
+		var detailsum SoptContractDetailSum
+		detailsum = SoptContractDetailSum{
+			WrStandardID:          detail.WrStandardID,
+			WrStandardName:        detail.WrStandardName,
+			ProductType:           detail.ProductType,
+			ProductTypeName:       detail.ProductTypeName,
+			DeliveryGoodsID:       detail.DeliveryGoodsID,
+			DeliveryGoodsName:     detail.DeliveryGoodsName,
+			DeliveryGoodsDesc:     detail.DeliveryGoodsDesc,
+			WarehouseID:           detail.WarehouseID,
+			WarehouseName:         detail.WarehouseName,
+			UnitName:              detail.UnitName,
+			PointDesc:             detail.PointDesc,
+			SpotPriceOrderList:    detail.SpotPriceOrderList,
+			SpotPointOrderVoList:  detail.SpotPointOrderVoList,
+			TotalPriceOrderQty:    totalpriceorderqty,
+			TotalPriceOrderPrice:  totalpriceorderprice,
+			TotalPriceOrderAmount: totalpriceorderamount,
+			TotalPointOrderQty:    totalpointorderqty,
+			TotalQty:              totalqty,
+		}
+		detailsums = append(detailsums, detailsum)
+	}
+
+	jsoninfo, err := json.Marshal(detailsums)
+	if err != nil {
+
+		return "", err
+	}
+	return string(jsoninfo), nil
+}
+
+// QuerySpotContractAppleFormReq 查询合同申请表单数据请求参数
+type QuerySpotContractAppleFormReq struct {
+	UserID int `form:"userID" binding:"required"`
+}
+
+// CustomerInfo 申请单账号信息
+type CustomerInfo struct {
+	Userid       int64  `json:"userid" binding:"required"` // 用户ID
+	Customername string `json:"customername"`              // 名称(企业名称)
+	Mobile       string `json:"mobile"`                    // 手机号码
+	AccountIDs   []int  `json:"accountids"`                // 资金账户ID列表
+}
+
+// QuerySpotContractAppleFormRsp 查询合同申请表单数据返回模型
+type QuerySpotContractAppleFormRsp struct {
+	OurUser        CustomerInfo           `json:"ouruser"`        // 我方账号
+	OppositeUsers  []CustomerInfo         `json:"oppositeusers"`  // 对方账号列表
+	WrStandards    []models.Wrstandard    `json:"wrstandards"`    // 仓单标准列表
+	WareHouseInfos []models.Warehouseinfo `json:"warehouseinfos"` // 仓库信息列表
+}
+
+// QuerySpotContractAppleForm 查询合同申请表单数据
+// @Summary 查询合同申请表单数据
+// @Produce json
+// @Security ApiKeyAuth
+// @Param userID query int true "用户ID"
+// @Success 200 {object} QuerySpotContractAppleFormRsp
+// @Failure 500 {object} app.Response
+// @Router /Erms3/QuerySpotContractAppleForm [get]
+// @Tags 风险管理v3
+func QuerySpotContractAppleForm(c *gin.Context) {
+	appG := app.Gin{C: c}
+
+	// 获取请求参数
+	var req QuerySpotContractAppleFormReq
+	err := appG.C.ShouldBindQuery(&req)
+	if err != nil {
+		logger.GetLogger().Errorf("QuerySpotContractAppleForm failed: %s", err.Error())
+		appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
+		return
+	}
+
+	rsp := QuerySpotContractAppleFormRsp{}
+	// 获取我方用户信息
+	ourUser, err := models.GetUserInfo(req.UserID)
+	if err != nil {
+		// 查询失败
+		logger.GetLogger().Errorf("QuerySpotContractAppleForm failed: %s", err.Error())
+		appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
+		return
+	}
+	rsp.OurUser.Userid = ourUser.Userid
+	rsp.OurUser.Customername = ourUser.Customername
+	key, _ := hex.DecodeString(utils.AESSecretKey)                     // 手机号码解密
+	if phonenum, err := hex.DecodeString(ourUser.Mobile); err == nil { // hex -> []byte
+		if mobile, err := utils.AESDecrypt(phonenum, key); err == nil {
+			rsp.OurUser.Mobile = string(mobile)
+		}
+	}
+	taAccounts, err := models.GetTaAccountsByType(req.UserID, 3) // 获取内部资金账户,现货都使用内部资金账户
+	if err != nil {
+		// 查询失败
+		logger.GetLogger().Errorf("QuerySpotContractAppleForm failed: %s", err.Error())
+		appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
+		return
+	}
+	rsp.OurUser.AccountIDs = make([]int, 0)
+	for _, v := range taAccounts {
+		rsp.OurUser.AccountIDs = append(rsp.OurUser.AccountIDs, int(v.Accountid))
+	}
+
+	// 获取客户信息
+	oppositeUsers, err := models.GetUsersByUserType(6)
+	if err != nil {
+		// 查询失败
+		logger.GetLogger().Errorf("QuerySpotContractAppleForm failed: %s", err.Error())
+		appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
+		return
+	}
+	rsp.OppositeUsers = make([]CustomerInfo, 0)
+	for _, v := range oppositeUsers {
+		// 把自己过滤掉
+		if int(v.Userid) == req.UserID {
+			continue
+		}
+
+		userInfo := CustomerInfo{}
+		userInfo.Userid = v.Userid
+		userInfo.Customername = v.Customername
+		// 获取客户的资金账户列表
+		opposTaAccounts, err := models.GetTaAccountsByType(int(v.Userid), 3) // 获取内部资金账户,现货都使用内部资金账户
+		if err != nil {
+			// 查询失败
+			logger.GetLogger().Errorf("QuerySpotContractAppleForm failed: %s", err.Error())
+			appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
+			return
+		}
+		userInfo.AccountIDs = make([]int, 0)
+		for _, v := range opposTaAccounts {
+			userInfo.AccountIDs = append(userInfo.AccountIDs, int(v.Accountid))
+		}
+
+		rsp.OppositeUsers = append(rsp.OppositeUsers, userInfo)
+	}
+
+	// 获取交易标的(仓单标准)
+	rsp.WrStandards = make([]models.Wrstandard, 0)
+	wrStandards, err := models.GetWrstandards()
+	if err != nil {
+		// 查询失败
+		logger.GetLogger().Errorf("QuerySpotContractAppleForm failed: %s", err.Error())
+		appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
+		return
+	}
+	rsp.WrStandards = wrStandards
+
+	// 获取仓库信息
+	rsp.WareHouseInfos = make([]models.Warehouseinfo, 0)
+	wareHouseInfos, err := models.GetWareHouseinfos()
+	if err != nil {
+		// 查询失败
+		logger.GetLogger().Errorf("QuerySpotContractAppleForm failed: %s", err.Error())
+		appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
+		return
+	}
+	rsp.WareHouseInfos = wareHouseInfos
+
+	// 查询成功
+	logger.GetLogger().Debugln("QuerySpotContractAppleForm successed: %v", rsp)
+	appG.Response(http.StatusOK, e.SUCCESS, rsp)
+}

+ 402 - 0
docs/docs.go

@@ -789,6 +789,182 @@ var doc = `{
                 }
             }
         },
+        "/Erms3/AddSpotContractApply": {
+            "post": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "风险管理v3"
+                ],
+                "summary": "新增现货合同申请",
+                "parameters": [
+                    {
+                        "type": "string",
+                        "description": "现货合同编号",
+                        "name": "contractno",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "现货合同类型, 1:采购 -1:销售",
+                        "name": "contracttype",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "所属机构",
+                        "name": "areauserid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "资金账户ID",
+                        "name": "accountid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "客户ID",
+                        "name": "customeruserid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "客户资金账户ID",
+                        "name": "customeraccountid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "签订日期, 格式:yyyy-MM-dd HH:mm:ss",
+                        "name": "signdate",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "交货时间, 格式:yyyy-MM-dd HH:mm:ss",
+                        "name": "lastdate",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "合同附件",
+                        "name": "contractattachment",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "初始保证金支付方, 1:买方 2:卖方",
+                        "name": "orimarginpayer",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "number",
+                        "description": "初始保证金",
+                        "name": "orimargin",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "备注",
+                        "name": "remark",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "市场ID",
+                        "name": "marketid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "申请人",
+                        "name": "creatorid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "明细",
+                        "name": "details",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/erms3.AddSpotContractApplyRsp"
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
+        "/Erms3/QuerySpotContractAppleForm": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "风险管理v3"
+                ],
+                "summary": "查询合同申请表单数据",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "用户ID",
+                        "name": "userID",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/erms3.QuerySpotContractAppleFormRsp"
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/HSBY/QueryHsbyBuyMyTradeDetail": {
             "get": {
                 "security": [
@@ -4276,6 +4452,79 @@ var doc = `{
                 }
             }
         },
+        "erms3.AddSpotContractApplyRsp": {
+            "type": "object",
+            "required": [
+                "contractno"
+            ],
+            "properties": {
+                "contractno": {
+                    "description": "现货合同编号",
+                    "type": "string"
+                },
+                "spotcontractid": {
+                    "description": "现货合同ID(345+Unix秒时间戳(10位)+xxxxxx)",
+                    "type": "integer"
+                }
+            }
+        },
+        "erms3.CustomerInfo": {
+            "type": "object",
+            "required": [
+                "userid"
+            ],
+            "properties": {
+                "accountids": {
+                    "description": "资金账户ID列表",
+                    "type": "array",
+                    "items": {
+                        "type": "integer"
+                    }
+                },
+                "customername": {
+                    "description": "名称(企业名称)",
+                    "type": "string"
+                },
+                "mobile": {
+                    "description": "手机号码",
+                    "type": "string"
+                },
+                "userid": {
+                    "description": "用户ID",
+                    "type": "integer"
+                }
+            }
+        },
+        "erms3.QuerySpotContractAppleFormRsp": {
+            "type": "object",
+            "properties": {
+                "oppositeusers": {
+                    "description": "对方账号列表",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/erms3.CustomerInfo"
+                    }
+                },
+                "ouruser": {
+                    "description": "我方账号",
+                    "$ref": "#/definitions/erms3.CustomerInfo"
+                },
+                "warehouseinfos": {
+                    "description": "仓库信息列表",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/models.Warehouseinfo"
+                    }
+                },
+                "wrstandards": {
+                    "description": "仓单标准列表",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/models.Wrstandard"
+                    }
+                }
+            }
+        },
         "hsby.QueryProvincesAndCitiesRsp": {
             "type": "object",
             "properties": {
@@ -5878,6 +6127,155 @@ var doc = `{
                 }
             }
         },
+        "models.Warehouseinfo": {
+            "type": "object",
+            "required": [
+                "autoid",
+                "warehousecode"
+            ],
+            "properties": {
+                "address": {
+                    "description": "详细地址",
+                    "type": "string"
+                },
+                "areauserid": {
+                    "description": "所属机构",
+                    "type": "integer"
+                },
+                "autoid": {
+                    "description": "自增ID",
+                    "type": "integer"
+                },
+                "cityid": {
+                    "description": "市",
+                    "type": "integer"
+                },
+                "contactname": {
+                    "description": "联系人",
+                    "type": "string"
+                },
+                "contactnum": {
+                    "description": "联系电话",
+                    "type": "string"
+                },
+                "countryid": {
+                    "description": "国家",
+                    "type": "integer"
+                },
+                "createtime": {
+                    "description": "创建时间",
+                    "type": "string"
+                },
+                "districtid": {
+                    "description": "区",
+                    "type": "integer"
+                },
+                "hasvideo": {
+                    "description": "是否有视频 - 0:无 1:有",
+                    "type": "integer"
+                },
+                "provinceid": {
+                    "description": "省",
+                    "type": "integer"
+                },
+                "remark": {
+                    "description": "审核备注",
+                    "type": "string"
+                },
+                "videourl": {
+                    "description": "视频地址",
+                    "type": "string"
+                },
+                "warehousecode": {
+                    "description": "仓库代码",
+                    "type": "string"
+                },
+                "warehousename": {
+                    "description": "仓库名称",
+                    "type": "string"
+                },
+                "warehousestatus": {
+                    "description": "仓库状态 - 1:正常 2:注销 3:待审核 4:审核拒绝",
+                    "type": "integer"
+                },
+                "warehousetype": {
+                    "description": "仓库类型 - 1 厂库  2 自有库  3 合作库",
+                    "type": "integer"
+                }
+            }
+        },
+        "models.Wrstandard": {
+            "type": "object",
+            "required": [
+                "wrstandardid"
+            ],
+            "properties": {
+                "createtime": {
+                    "description": "创建时间",
+                    "type": "string"
+                },
+                "creatorid": {
+                    "description": "创建人",
+                    "type": "integer"
+                },
+                "deliverygoodsid": {
+                    "description": "品种ID",
+                    "type": "integer"
+                },
+                "factoryitemjson": {
+                    "description": "要素项定义Json[{\"DGFactoryItemTypeID\": ,\"ItemTypeMode\": ,\"FactoryItemIDs\": },{.....},]DGFactoryItemTypeID - 要素项类型ID --DGFactoryItem-\u003eDGFactoryItemTypeIDItemTypeMode - 要素项类型模式 --DGFactoryItem-\u003eItemTypeModeFactoryItemIDs - 选择项IDs--DGFactoryItem-\u003eDGFactoryItemID, 逗号分隔",
+                    "type": "string"
+                },
+                "isvalid": {
+                    "description": "是否有效 - 0:无效 1:有效",
+                    "type": "integer"
+                },
+                "minivalue": {
+                    "description": "最小变动值",
+                    "type": "integer"
+                },
+                "minivaluedp": {
+                    "description": "最小变动值小数位",
+                    "type": "integer"
+                },
+                "realminivalue": {
+                    "description": "实际最小变动值",
+                    "type": "integer"
+                },
+                "realminivaluedp": {
+                    "description": "实际最小变动值小数位",
+                    "type": "integer"
+                },
+                "unitid": {
+                    "description": "单位ID",
+                    "type": "integer"
+                },
+                "updatetime": {
+                    "description": "更新时间",
+                    "type": "string"
+                },
+                "updatorid": {
+                    "description": "更新人",
+                    "type": "integer"
+                },
+                "wrsstatus": {
+                    "description": "状态 - 作废 - 0:未激活 1:正常",
+                    "type": "integer"
+                },
+                "wrstandardcode": {
+                    "description": "仓单标准代码",
+                    "type": "string"
+                },
+                "wrstandardid": {
+                    "description": "仓单标准ID(SEQ_WRSTANDARD)",
+                    "type": "integer"
+                },
+                "wrstandardname": {
+                    "description": "仓单标准名称",
+                    "type": "string"
+                }
+            }
+        },
         "order.QueryHisTradeDetailRsp": {
             "type": "object",
             "required": [
@@ -6905,6 +7303,10 @@ var doc = `{
                 "trademode": {
                     "description": "交易模式",
                     "type": "integer"
+                },
+                "usedmargin": {
+                    "description": "占用保证金[商品币种]",
+                    "type": "number"
                 }
             }
         },

+ 402 - 0
docs/swagger.json

@@ -773,6 +773,182 @@
                 }
             }
         },
+        "/Erms3/AddSpotContractApply": {
+            "post": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "风险管理v3"
+                ],
+                "summary": "新增现货合同申请",
+                "parameters": [
+                    {
+                        "type": "string",
+                        "description": "现货合同编号",
+                        "name": "contractno",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "现货合同类型, 1:采购 -1:销售",
+                        "name": "contracttype",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "所属机构",
+                        "name": "areauserid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "资金账户ID",
+                        "name": "accountid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "客户ID",
+                        "name": "customeruserid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "客户资金账户ID",
+                        "name": "customeraccountid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "签订日期, 格式:yyyy-MM-dd HH:mm:ss",
+                        "name": "signdate",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "交货时间, 格式:yyyy-MM-dd HH:mm:ss",
+                        "name": "lastdate",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "合同附件",
+                        "name": "contractattachment",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "初始保证金支付方, 1:买方 2:卖方",
+                        "name": "orimarginpayer",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "number",
+                        "description": "初始保证金",
+                        "name": "orimargin",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "备注",
+                        "name": "remark",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "市场ID",
+                        "name": "marketid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "申请人",
+                        "name": "creatorid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "明细",
+                        "name": "details",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/erms3.AddSpotContractApplyRsp"
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
+        "/Erms3/QuerySpotContractAppleForm": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "风险管理v3"
+                ],
+                "summary": "查询合同申请表单数据",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "用户ID",
+                        "name": "userID",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/erms3.QuerySpotContractAppleFormRsp"
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/HSBY/QueryHsbyBuyMyTradeDetail": {
             "get": {
                 "security": [
@@ -4260,6 +4436,79 @@
                 }
             }
         },
+        "erms3.AddSpotContractApplyRsp": {
+            "type": "object",
+            "required": [
+                "contractno"
+            ],
+            "properties": {
+                "contractno": {
+                    "description": "现货合同编号",
+                    "type": "string"
+                },
+                "spotcontractid": {
+                    "description": "现货合同ID(345+Unix秒时间戳(10位)+xxxxxx)",
+                    "type": "integer"
+                }
+            }
+        },
+        "erms3.CustomerInfo": {
+            "type": "object",
+            "required": [
+                "userid"
+            ],
+            "properties": {
+                "accountids": {
+                    "description": "资金账户ID列表",
+                    "type": "array",
+                    "items": {
+                        "type": "integer"
+                    }
+                },
+                "customername": {
+                    "description": "名称(企业名称)",
+                    "type": "string"
+                },
+                "mobile": {
+                    "description": "手机号码",
+                    "type": "string"
+                },
+                "userid": {
+                    "description": "用户ID",
+                    "type": "integer"
+                }
+            }
+        },
+        "erms3.QuerySpotContractAppleFormRsp": {
+            "type": "object",
+            "properties": {
+                "oppositeusers": {
+                    "description": "对方账号列表",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/erms3.CustomerInfo"
+                    }
+                },
+                "ouruser": {
+                    "description": "我方账号",
+                    "$ref": "#/definitions/erms3.CustomerInfo"
+                },
+                "warehouseinfos": {
+                    "description": "仓库信息列表",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/models.Warehouseinfo"
+                    }
+                },
+                "wrstandards": {
+                    "description": "仓单标准列表",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/models.Wrstandard"
+                    }
+                }
+            }
+        },
         "hsby.QueryProvincesAndCitiesRsp": {
             "type": "object",
             "properties": {
@@ -5862,6 +6111,155 @@
                 }
             }
         },
+        "models.Warehouseinfo": {
+            "type": "object",
+            "required": [
+                "autoid",
+                "warehousecode"
+            ],
+            "properties": {
+                "address": {
+                    "description": "详细地址",
+                    "type": "string"
+                },
+                "areauserid": {
+                    "description": "所属机构",
+                    "type": "integer"
+                },
+                "autoid": {
+                    "description": "自增ID",
+                    "type": "integer"
+                },
+                "cityid": {
+                    "description": "市",
+                    "type": "integer"
+                },
+                "contactname": {
+                    "description": "联系人",
+                    "type": "string"
+                },
+                "contactnum": {
+                    "description": "联系电话",
+                    "type": "string"
+                },
+                "countryid": {
+                    "description": "国家",
+                    "type": "integer"
+                },
+                "createtime": {
+                    "description": "创建时间",
+                    "type": "string"
+                },
+                "districtid": {
+                    "description": "区",
+                    "type": "integer"
+                },
+                "hasvideo": {
+                    "description": "是否有视频 - 0:无 1:有",
+                    "type": "integer"
+                },
+                "provinceid": {
+                    "description": "省",
+                    "type": "integer"
+                },
+                "remark": {
+                    "description": "审核备注",
+                    "type": "string"
+                },
+                "videourl": {
+                    "description": "视频地址",
+                    "type": "string"
+                },
+                "warehousecode": {
+                    "description": "仓库代码",
+                    "type": "string"
+                },
+                "warehousename": {
+                    "description": "仓库名称",
+                    "type": "string"
+                },
+                "warehousestatus": {
+                    "description": "仓库状态 - 1:正常 2:注销 3:待审核 4:审核拒绝",
+                    "type": "integer"
+                },
+                "warehousetype": {
+                    "description": "仓库类型 - 1 厂库  2 自有库  3 合作库",
+                    "type": "integer"
+                }
+            }
+        },
+        "models.Wrstandard": {
+            "type": "object",
+            "required": [
+                "wrstandardid"
+            ],
+            "properties": {
+                "createtime": {
+                    "description": "创建时间",
+                    "type": "string"
+                },
+                "creatorid": {
+                    "description": "创建人",
+                    "type": "integer"
+                },
+                "deliverygoodsid": {
+                    "description": "品种ID",
+                    "type": "integer"
+                },
+                "factoryitemjson": {
+                    "description": "要素项定义Json[{\"DGFactoryItemTypeID\": ,\"ItemTypeMode\": ,\"FactoryItemIDs\": },{.....},]DGFactoryItemTypeID - 要素项类型ID --DGFactoryItem-\u003eDGFactoryItemTypeIDItemTypeMode - 要素项类型模式 --DGFactoryItem-\u003eItemTypeModeFactoryItemIDs - 选择项IDs--DGFactoryItem-\u003eDGFactoryItemID, 逗号分隔",
+                    "type": "string"
+                },
+                "isvalid": {
+                    "description": "是否有效 - 0:无效 1:有效",
+                    "type": "integer"
+                },
+                "minivalue": {
+                    "description": "最小变动值",
+                    "type": "integer"
+                },
+                "minivaluedp": {
+                    "description": "最小变动值小数位",
+                    "type": "integer"
+                },
+                "realminivalue": {
+                    "description": "实际最小变动值",
+                    "type": "integer"
+                },
+                "realminivaluedp": {
+                    "description": "实际最小变动值小数位",
+                    "type": "integer"
+                },
+                "unitid": {
+                    "description": "单位ID",
+                    "type": "integer"
+                },
+                "updatetime": {
+                    "description": "更新时间",
+                    "type": "string"
+                },
+                "updatorid": {
+                    "description": "更新人",
+                    "type": "integer"
+                },
+                "wrsstatus": {
+                    "description": "状态 - 作废 - 0:未激活 1:正常",
+                    "type": "integer"
+                },
+                "wrstandardcode": {
+                    "description": "仓单标准代码",
+                    "type": "string"
+                },
+                "wrstandardid": {
+                    "description": "仓单标准ID(SEQ_WRSTANDARD)",
+                    "type": "integer"
+                },
+                "wrstandardname": {
+                    "description": "仓单标准名称",
+                    "type": "string"
+                }
+            }
+        },
         "order.QueryHisTradeDetailRsp": {
             "type": "object",
             "required": [
@@ -6889,6 +7287,10 @@
                 "trademode": {
                     "description": "交易模式",
                     "type": "integer"
+                },
+                "usedmargin": {
+                    "description": "占用保证金[商品币种]",
+                    "type": "number"
                 }
             }
         },

+ 285 - 0
docs/swagger.yaml

@@ -1200,6 +1200,57 @@ definitions:
     required:
     - spotcontractid
     type: object
+  erms3.AddSpotContractApplyRsp:
+    properties:
+      contractno:
+        description: 现货合同编号
+        type: string
+      spotcontractid:
+        description: 现货合同ID(345+Unix秒时间戳(10位)+xxxxxx)
+        type: integer
+    required:
+    - contractno
+    type: object
+  erms3.CustomerInfo:
+    properties:
+      accountids:
+        description: 资金账户ID列表
+        items:
+          type: integer
+        type: array
+      customername:
+        description: 名称(企业名称)
+        type: string
+      mobile:
+        description: 手机号码
+        type: string
+      userid:
+        description: 用户ID
+        type: integer
+    required:
+    - userid
+    type: object
+  erms3.QuerySpotContractAppleFormRsp:
+    properties:
+      oppositeusers:
+        description: 对方账号列表
+        items:
+          $ref: '#/definitions/erms3.CustomerInfo'
+        type: array
+      ouruser:
+        $ref: '#/definitions/erms3.CustomerInfo'
+        description: 我方账号
+      warehouseinfos:
+        description: 仓库信息列表
+        items:
+          $ref: '#/definitions/models.Warehouseinfo'
+        type: array
+      wrstandards:
+        description: 仓单标准列表
+        items:
+          $ref: '#/definitions/models.Wrstandard'
+        type: array
+    type: object
   hsby.QueryProvincesAndCitiesRsp:
     properties:
       cities:
@@ -2403,6 +2454,119 @@ definitions:
     required:
     - userid
     type: object
+  models.Warehouseinfo:
+    properties:
+      address:
+        description: 详细地址
+        type: string
+      areauserid:
+        description: 所属机构
+        type: integer
+      autoid:
+        description: 自增ID
+        type: integer
+      cityid:
+        description: 市
+        type: integer
+      contactname:
+        description: 联系人
+        type: string
+      contactnum:
+        description: 联系电话
+        type: string
+      countryid:
+        description: 国家
+        type: integer
+      createtime:
+        description: 创建时间
+        type: string
+      districtid:
+        description: 区
+        type: integer
+      hasvideo:
+        description: 是否有视频 - 0:无 1:有
+        type: integer
+      provinceid:
+        description: 省
+        type: integer
+      remark:
+        description: 审核备注
+        type: string
+      videourl:
+        description: 视频地址
+        type: string
+      warehousecode:
+        description: 仓库代码
+        type: string
+      warehousename:
+        description: 仓库名称
+        type: string
+      warehousestatus:
+        description: 仓库状态 - 1:正常 2:注销 3:待审核 4:审核拒绝
+        type: integer
+      warehousetype:
+        description: 仓库类型 - 1 厂库  2 自有库  3 合作库
+        type: integer
+    required:
+    - autoid
+    - warehousecode
+    type: object
+  models.Wrstandard:
+    properties:
+      createtime:
+        description: 创建时间
+        type: string
+      creatorid:
+        description: 创建人
+        type: integer
+      deliverygoodsid:
+        description: 品种ID
+        type: integer
+      factoryitemjson:
+        description: '要素项定义Json[{"DGFactoryItemTypeID": ,"ItemTypeMode": ,"FactoryItemIDs":
+          },{.....},]DGFactoryItemTypeID - 要素项类型ID --DGFactoryItem->DGFactoryItemTypeIDItemTypeMode
+          - 要素项类型模式 --DGFactoryItem->ItemTypeModeFactoryItemIDs - 选择项IDs--DGFactoryItem->DGFactoryItemID,
+          逗号分隔'
+        type: string
+      isvalid:
+        description: 是否有效 - 0:无效 1:有效
+        type: integer
+      minivalue:
+        description: 最小变动值
+        type: integer
+      minivaluedp:
+        description: 最小变动值小数位
+        type: integer
+      realminivalue:
+        description: 实际最小变动值
+        type: integer
+      realminivaluedp:
+        description: 实际最小变动值小数位
+        type: integer
+      unitid:
+        description: 单位ID
+        type: integer
+      updatetime:
+        description: 更新时间
+        type: string
+      updatorid:
+        description: 更新人
+        type: integer
+      wrsstatus:
+        description: 状态 - 作废 - 0:未激活 1:正常
+        type: integer
+      wrstandardcode:
+        description: 仓单标准代码
+        type: string
+      wrstandardid:
+        description: 仓单标准ID(SEQ_WRSTANDARD)
+        type: integer
+      wrstandardname:
+        description: 仓单标准名称
+        type: string
+    required:
+    - wrstandardid
+    type: object
   order.QueryHisTradeDetailRsp:
     properties:
       accountid:
@@ -3193,6 +3357,9 @@ definitions:
       trademode:
         description: 交易模式
         type: integer
+      usedmargin:
+        description: 占用保证金[商品币种]
+        type: number
     required:
     - goodsid
     type: object
@@ -4211,6 +4378,124 @@ paths:
       summary: 查询现货合同表信息(指定策略ID、未结束的)
       tags:
       - 风险管理
+  /Erms3/AddSpotContractApply:
+    post:
+      parameters:
+      - description: 现货合同编号
+        in: query
+        name: contractno
+        required: true
+        type: string
+      - description: 现货合同类型, 1:采购 -1:销售
+        in: query
+        name: contracttype
+        required: true
+        type: integer
+      - description: 所属机构
+        in: query
+        name: areauserid
+        required: true
+        type: integer
+      - description: 资金账户ID
+        in: query
+        name: accountid
+        required: true
+        type: integer
+      - description: 客户ID
+        in: query
+        name: customeruserid
+        required: true
+        type: integer
+      - description: 客户资金账户ID
+        in: query
+        name: customeraccountid
+        required: true
+        type: integer
+      - description: 签订日期, 格式:yyyy-MM-dd HH:mm:ss
+        in: query
+        name: signdate
+        required: true
+        type: string
+      - description: 交货时间, 格式:yyyy-MM-dd HH:mm:ss
+        in: query
+        name: lastdate
+        required: true
+        type: string
+      - description: 合同附件
+        in: query
+        name: contractattachment
+        required: true
+        type: string
+      - description: 初始保证金支付方, 1:买方 2:卖方
+        in: query
+        name: orimarginpayer
+        required: true
+        type: integer
+      - description: 初始保证金
+        in: query
+        name: orimargin
+        required: true
+        type: number
+      - description: 备注
+        in: query
+        name: remark
+        required: true
+        type: string
+      - description: 市场ID
+        in: query
+        name: marketid
+        required: true
+        type: integer
+      - description: 申请人
+        in: query
+        name: creatorid
+        required: true
+        type: integer
+      - description: 明细
+        in: query
+        name: details
+        required: true
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/erms3.AddSpotContractApplyRsp'
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 新增现货合同申请
+      tags:
+      - 风险管理v3
+  /Erms3/QuerySpotContractAppleForm:
+    get:
+      parameters:
+      - description: 用户ID
+        in: query
+        name: userID
+        required: true
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/erms3.QuerySpotContractAppleFormRsp'
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 查询合同申请表单数据
+      tags:
+      - 风险管理v3
   /HSBY/QueryHsbyBuyMyTradeDetail:
     get:
       parameters:

+ 11 - 6
models/account.go

@@ -510,24 +510,29 @@ func InsertMessageBoard(userID int, message string) int {
 	return 0
 }
 
-// GetUsers 获取批量用户信息
-// 输入 userIDs string 目标用户ID列表,格式:1,2,3
-func GetUsers(userIDs string) ([]Userinfo, error) {
+// GetUsersByUserType 获取批量指定类型的用户信息
+// 输入 userType int 账户类型 -  1:交易所 2:机构 3:会员子机构 4:经纪人 5:投资者 6:客户
+func GetUsersByUserType(userType int) ([]Userinfo, error) {
 	engine := db.GetEngine()
 
 	userInfos := make([]Userinfo, 0)
-	if err := engine.Where("USERID in (?)", userIDs).Find(&userInfos); err != nil {
+	if err := engine.Where("USERTYPE = ?", userType).Find(&userInfos); err != nil {
 		return nil, err
 	}
 
 	return userInfos, nil
 }
 
-func GetTaAccounts(userID int) ([]Taaccount, error) {
+// GetTaAccountsByType 获取指定用户的资金账户列表
+// 输入 userID int 关联用户ID
+// 输入 taAccountType int 账号类型 - 1:外部账号 2:内部账号 3:内部做市自营账号 4:内部做市接单账号
+func GetTaAccountsByType(userID, taAccountType int) ([]Taaccount, error) {
 	engine := db.GetEngine()
 
 	taAccounts := make([]Taaccount, 0)
-	engine.Where("")
+	if err := engine.Where("RELATEDUSERID = ?", userID).Find(&taAccounts); err != nil {
+		return nil, err
+	}
 
 	return taAccounts, nil
 }

+ 21 - 0
models/goods.go

@@ -90,6 +90,27 @@ func GetGoods(goodsID int) (*Goods, error) {
 	return &goods, nil
 }
 
+// GoodsInfo 商品信息
+type GoodsInfo struct {
+	Goods     `xorm:"extends"`
+	GoodsUnit string `json:"goodsunit" xorm:"GOODSUNIT"` // 报价单位
+}
+
+// GetGoodsesByStatus 获取指定状态的商品信息
+// 输入 goodsStatus int 商品状态- 1:待审核 2:未上市 3:上市 4:已注销 5:审核拒绝 6:退市 7:待退市
+func GetGoodsesByStatus(goodsStatus int) ([]GoodsInfo, error) {
+	engine := db.GetEngine()
+
+	goodsInfos := make([]GoodsInfo, 0)
+	if err := engine.Table("GOODS").Select("GOODS.*, E1.ENUMDICNAME GOODSUNIT").
+		Join("LEFT", "ENUMDICITEM E1", "E1.ENUMITEMNAME = GOODS.GOODUNITID and E1.ENUMDICCODE = 'GOODSUNIT'").
+		Where("GOODSSTATUS = ?", goodsStatus).Find(&goodsInfos); err != nil {
+		return nil, err
+	}
+
+	return goodsInfos, nil
+}
+
 // SearchGoods 检索商品信息
 type SearchGoods struct {
 	Goodsid   int64  `json:"goodsid"  xorm:"'GOODSID'" binding:"required"`     // 商品ID(自增ID SEQ_GOODS)

+ 83 - 0
models/wrTrade.go

@@ -0,0 +1,83 @@
+package models
+
+import (
+	"mtp2_if/db"
+	"time"
+)
+
+// 100.10仓单贸易
+
+// Wrstandard 仓单标准表
+type Wrstandard struct {
+	Wrstandardid    int64     `json:"wrstandardid"  xorm:"'WRSTANDARDID'" binding:"required"` // 仓单标准ID(SEQ_WRSTANDARD)
+	Wrstandardcode  string    `json:"wrstandardcode"  xorm:"'WRSTANDARDCODE'"`                // 仓单标准代码
+	Wrstandardname  string    `json:"wrstandardname"  xorm:"'WRSTANDARDNAME'"`                // 仓单标准名称
+	Deliverygoodsid int32     `json:"deliverygoodsid"  xorm:"'DELIVERYGOODSID'"`              // 品种ID
+	Unitid          int32     `json:"unitid"  xorm:"'UNITID'"`                                // 单位ID
+	Minivalue       int64     `json:"minivalue"  xorm:"'MINIVALUE'"`                          // 最小变动值
+	Minivaluedp     int64     `json:"minivaluedp"  xorm:"'MINIVALUEDP'"`                      // 最小变动值小数位
+	Realminivalue   int64     `json:"realminivalue"  xorm:"'REALMINIVALUE'"`                  // 实际最小变动值
+	Realminivaluedp int64     `json:"realminivaluedp"  xorm:"'REALMINIVALUEDP'"`              // 实际最小变动值小数位
+	Wrsstatus       int32     `json:"wrsstatus"  xorm:"'WRSSTATUS'"`                          // 状态 - 作废 - 0:未激活 1:正常
+	Creatorid       int64     `json:"creatorid"  xorm:"'CREATORID'"`                          // 创建人
+	Createtime      time.Time `json:"createtime"  xorm:"'CREATETIME'"`                        // 创建时间
+	Updatorid       int64     `json:"updatorid"  xorm:"'UPDATORID'"`                          // 更新人
+	Updatetime      time.Time `json:"updatetime"  xorm:"'UPDATETIME'"`                        // 更新时间
+	Factoryitemjson string    `json:"factoryitemjson"  xorm:"'FACTORYITEMJSON'"`              // 要素项定义Json[{"DGFactoryItemTypeID": ,"ItemTypeMode": ,"FactoryItemIDs": },{.....},]DGFactoryItemTypeID - 要素项类型ID --DGFactoryItem->DGFactoryItemTypeIDItemTypeMode - 要素项类型模式 --DGFactoryItem->ItemTypeModeFactoryItemIDs - 选择项IDs--DGFactoryItem->DGFactoryItemID, 逗号分隔
+	Isvalid         int32     `json:"isvalid"  xorm:"'ISVALID'"`                              // 是否有效 - 0:无效 1:有效
+}
+
+// TableName is WRSTANDARD
+func (Wrstandard) TableName() string {
+	return "WRSTANDARD"
+}
+
+// Warehouseinfo 仓库信息表
+type Warehouseinfo struct {
+	Autoid          int64     `json:"autoid"  xorm:"'AUTOID'" binding:"required"`               // 自增ID
+	Warehousecode   string    `json:"warehousecode"  xorm:"'WAREHOUSECODE'" binding:"required"` // 仓库代码
+	Warehousename   string    `json:"warehousename"  xorm:"'WAREHOUSENAME'"`                    // 仓库名称
+	Warehousetype   int32     `json:"warehousetype"  xorm:"'WAREHOUSETYPE'"`                    // 仓库类型 - 1 厂库  2 自有库  3 合作库
+	Areauserid      int64     `json:"areauserid"  xorm:"'AREAUSERID'"`                          // 所属机构
+	Warehousestatus int32     `json:"warehousestatus"  xorm:"'WAREHOUSESTATUS'"`                // 仓库状态 - 1:正常 2:注销 3:待审核 4:审核拒绝
+	Countryid       int32     `json:"countryid"  xorm:"'COUNTRYID'"`                            // 国家
+	Provinceid      int32     `json:"provinceid"  xorm:"'PROVINCEID'"`                          // 省
+	Cityid          int32     `json:"cityid"  xorm:"'CITYID'"`                                  // 市
+	Districtid      int32     `json:"districtid"  xorm:"'DISTRICTID'"`                          // 区
+	Address         string    `json:"address"  xorm:"'ADDRESS'"`                                // 详细地址
+	Remark          string    `json:"remark"  xorm:"'REMARK'"`                                  // 审核备注
+	Createtime      time.Time `json:"createtime"  xorm:"'CREATETIME'"`                          // 创建时间
+	Hasvideo        int32     `json:"hasvideo"  xorm:"'HASVIDEO'"`                              // 是否有视频 - 0:无 1:有
+	Videourl        string    `json:"videourl"  xorm:"'VIDEOURL'"`                              // 视频地址
+	Contactname     string    `json:"contactname"  xorm:"'CONTACTNAME'"`                        // 联系人
+	Contactnum      string    `json:"contactnum"  xorm:"'CONTACTNUM'"`                          // 联系电话
+}
+
+// TableName is WAREHOUSEINFO
+func (Warehouseinfo) TableName() string {
+	return "WAREHOUSEINFO"
+}
+
+// GetWrstandards 获取有效的仓单标准
+func GetWrstandards() ([]Wrstandard, error) {
+	engine := db.GetEngine()
+
+	wrStandards := make([]Wrstandard, 0)
+	if err := engine.Where("ISVALID = 1").Find(&wrStandards); err != nil {
+		return nil, err
+	}
+
+	return wrStandards, nil
+}
+
+// GetWareHouseinfos 获取有效的仓库信息
+func GetWareHouseinfos() ([]Warehouseinfo, error) {
+	engine := db.GetEngine()
+
+	wareHouseinfos := make([]Warehouseinfo, 0)
+	if err := engine.Where("WAREHOUSESTATUS = 1").Find(&wareHouseinfos); err != nil {
+		return nil, err
+	}
+
+	return wareHouseinfos, nil
+}

+ 5 - 3
routers/router.go

@@ -171,12 +171,14 @@ func InitRouter() *gin.Engine {
 		// 查询现货合同表信息(指定策略ID、未结束的)
 		erms2R.GET("/QuerySpotContract", erms2.QuerySpotContract)
 	}
-	// ************************ 风险管理2 ************************
+	// ************************ 风险管理v3 ************************
 	erms3R := apiR.Group("Erms3")
 	erms3R.Use(token.Auth())
 	{
-		// 查询内部成交单信息
-		erms3R.POST("/QueryInnerTradeDetail", erms3.AddSpotContractApply)
+		// 新增现货合同申请
+		erms3R.POST("/AddSpotContractApply", erms3.AddSpotContractApply)
+		// 查询合同申请表单数据
+		erms3R.GET("/QuerySpotContractAppleForm", erms3.QuerySpotContractAppleForm)
 	}
 	// ************************ 定制【尚志大宗】 ************************
 	szdzR := apiR.Group("SZDZ")