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

1.增加接口:查询可选的期货品种
2.fix bug:#93028

zou.yingbin преди 4 години
родител
ревизия
686a8c79f5
променени са 4 файла, в които са добавени 84 реда и са изтрити 12 реда
  1. 29 1
      controllers/ermcp/qryGGConvertconfig.go
  2. 11 9
      models/ermcp.go
  3. 43 2
      models/ermcpGGConvertconfig.go
  4. 1 0
      routers/router.go

+ 29 - 1
controllers/ermcp/qryGGConvertconfig.go

@@ -14,6 +14,7 @@ import (
 
 // 查询期货品种配置请求
 type QryGGCovertCfgReq struct {
+	GoodsGroupId int32 `form:"goodsgroupid"` // 品种id
 }
 
 // 查询期货品种配置应答
@@ -22,12 +23,39 @@ type QryGGCovertCfgRsp models.ErmcpGGConvertCfg
 // @Summary 查询期货品种配置(菜单:商品信息/期货品种)
 // @Produce json
 // @Security ApiKeyAuth
+// @Param goodsgroupid query int false  "品种id(不填则查所有)"
 // @Success 200 {array} QryGGCovertCfgRsp
 // @Failure 500 {object} app.Response
 // @Router /Ermcp/QueryGGConvertConfig [get]
 // @Tags 企业风险管理(app)
 func QueryGGConvertConfig(c *gin.Context) {
 	appG := app.GinUtils{Gin:app.Gin{C: c}}
-	m := models.ErmcpGGConvertCfg{}
+	var req QryGGCovertCfgReq
+	appG.DoBindReq(&req)
+	m := models.ErmcpGGConvertCfg{Destgoodsgroupid: req.GoodsGroupId}
 	appG.DoGetData(&m)
 }
+
+// 查询可配置期货品种请求
+type QryAvalidGPReq struct {
+	UserId int64 `form:"userid" binding:"required"` //用户ID
+}
+
+// 查询可配置期货品种响应
+type QryAvalidGPRsp models.ErmcpAvalidGoodsGroupModel
+
+// @Summary 查询可配置期货品种(菜单:商品信息/现货商品/新增现货商品/新增套保品种)
+// @Produce json
+// @Security ApiKeyAuth
+// @Param userid query int true  "所属机构ID"
+// @Success 200 {array} QryAvalidGPRsp
+// @Failure 500 {object} app.Response
+// @Router /Ermcp/QueryAvaildGoodsGroup [get]
+// @Tags 企业风险管理(app)
+func QueryAvaildGoodsGroup(c *gin.Context) {
+	appG := app.GinUtils{Gin:app.Gin{C: c}}
+	var req QryAvalidGPReq;
+	appG.DoBindReq(&req)
+	m := models.ErmcpAvalidGoodsGroupModel{AreaUserId: req.UserId}
+	appG.DoGetDataEx(&m)
+}

+ 11 - 9
models/ermcp.go

@@ -45,6 +45,7 @@ type ErmcpSpotContractModel struct {
 	EnumdicName       string  `json:"enumdicname"  xorm:"'ENUMDICNAME'"`             //单位名称
 	CONTRACCTSTATUS   int32   `json:"contracctstatus"  xorm:"'CONTRACTSTATUS'"`      //合同状态 - 0:未提交 1:待审核 2:执行中 3:正常完结 4:审核拒绝 5:异常完结 6:已撤回
 	Remark            string  `json:"remark"  xorm:"'Remark'"`                       //备注
+	AUDITTIME         string  `json:"audittime"  xorm:"'AUDITTIME'"`                 //审核时间
 }
 
 func (r *ErmcpSpotContractModel) buildSql(nQueryType int32) string {
@@ -71,6 +72,7 @@ func (r *ErmcpSpotContractModel) buildSql(nQueryType int32) string {
 		"       t.MARGIN," +
 		"       t.remark," +
 		"       t.contractstatus," +
+		"       to_char(t.audittime,'yyyy-mm-dd hh24:mi:ss') audittime," +
 		"       u1.accountname      BuyUserName," +
 		"       u2.accountname      SellUserName," +
 		"       g.deliverygoodscode," +
@@ -122,7 +124,6 @@ func (r *ErmcpSpotContractModel) GetData(nQueryType int32) ([]ErmcpSpotContractM
 type ErmcpModel struct {
 	UserID             int64   `json:"userid"  xorm:"'UserID'"`                         // 用户ID
 	SpotContractId     string  `json:"spotcontractid"  xorm:"'SPOTCONTRACTID'"`         // 合同ID
-	AccountId          string  `json:"accountid"  xorm:"'ACCOUNTID'"`                   // 账户ID
 	AccountName        string  `json:"accountname"  xorm:"'ACCOUNTNAME'"`               // 账户名称
 	DeliveryGoodsId    int     `json:"deliverygoodsid"  xorm:"'DELIVERYGOODSID'"`       // 现货商品ID
 	DeliveryGoodsCode  string  `json:"deliverygoodscode"  xorm:"'DELIVERYGOODSCODE'"`   // 现货商品代码
@@ -161,8 +162,9 @@ type ErmcpModel struct {
 	Contractno         string  `json:"contractno"  xorm:"'Contractno'"`                 // 合同编号
 	TotalAmount        float64 `json:"totalamount"  xorm:"'-'"`                         // 合计总额
 	ReckonedAmount     float64 `json:"reckonedamount"  xorm:"'ReckonedAmount'"`         // 已收付额(已确定额)
-	BUYUSERID          int64   `json:"-"  xorm:"'BUYUSERID'"`                           //采购方ID
-	SELLUSERID         int64   `json:"-"  xorm:"'SELLUSERID'"`                          //销售方ID
+	BUYUSERID          int64   `json:"-"  xorm:"'BUYUSERID'"`                           // 采购方ID
+	SELLUSERID         int64   `json:"-"  xorm:"'SELLUSERID'"`                          // 销售方ID
+	AUDITTIME          string `json:"audittime"  xorm:"'AUDITTIME'"`                    // 审核时间
 }
 
 func (r *ErmcpModel) calc() {
@@ -212,8 +214,7 @@ func (r *ErmcpModel) buildSql(nContractType, nQueryType int32) string {
 		"       t.contracttype," +
 		"       t.remark," +
 		"       t.margin," +
-		"       to_char(ta.accountid) accountid," +
-		"       ta.accountname," +
+		"       u.accountname," +
 		"       g.deliverygoodscode," +
 		"       g.deliverygoodsname," +
 		"       g2.goodscode," +
@@ -226,10 +227,11 @@ func (r *ErmcpModel) buildSql(nContractType, nQueryType int32) string {
 		"       t.ReckonAdjustAmount," +
 		"       t.Price," +
 		"       t.ReckonedAmount," +
+		"       to_char(t.audittime,'yyyy-mm-dd hh24:mi:ss') audittime," +
 		"       t.pricedamount + t.ReckonAdjustAmount as LoanAmount" +
 		"  from ermcp_spotcontract t" +
-		"  left join taaccount ta" +
-		"    on t.%v = ta.userid" +
+		"  left join useraccount u" +
+		"    on t.%v = u.userid" +
 		"  left join deliverygoods g" +
 		"    on t.deliverygoodsid = g.deliverygoodsid" +
 		"  left join goods g2" +
@@ -250,8 +252,8 @@ func (r *ErmcpModel) buildSql(nContractType, nQueryType int32) string {
 	} else if 2 == nQueryType {
 		// 待点价
 		status = "2"
-		str = str + "  and t.qty - t.pricedqty > 0 " +
-			"order by unpricedqty, t.audittime desc"
+		str = str + "  and t.qty - t.pricedqty > 0 and t.pricetype !=1 " +
+			"order by unpricedqty desc, t.audittime desc"
 	} else {
 		// 履约
 		status = "2"

+ 43 - 2
models/ermcpGGConvertconfig.go

@@ -24,7 +24,7 @@ type ErmcpGGConvertCfg struct {
 	DstName          string  `json:"dstname"  xorm:"'DstName'"`                   // 目标品种名称
 	DstCode          string  `json:"dstcode"  xorm:"'DstCode'"`                   // 目录品种代码
 	DstUnitid        uint32  `json:"dstunitid"  xorm:"'DstUnitid'"`               // 目标品种单位ID
-	DstUnitidName    string  `json:"dstunitidname"  xorm:"'-'"`                   // 目标品种单位名称
+	DstUnitidName    string  `json:"dstunitidname"`                               // 目标品种单位名称
 }
 
 func (r *ErmcpGGConvertCfg) Calc() {
@@ -64,5 +64,46 @@ func (r *ErmcpGGConvertCfg) buildSql() string {
 	if r.Destgoodsgroupid > 0 {
 		sqlId = sqlId + fmt.Sprintf("and t.Destgoodsgroupid=%v", r.Destgoodsgroupid)
 	}
+	if r.Srcgoodsgroupid > 0 {
+		sqlId = sqlId + fmt.Sprintf("and t.Srcgoodsgroupid=%v", r.Srcgoodsgroupid)
+	}
+	return sqlId
+}
+
+// 可选择的源期货品种
+type ErmcpAvalidGoodsGroupModel struct {
+	Goodsgroupid   int32  `json:"goodsgroupid"  xorm:"'Goodsgroupid'"`     // 期货品种id
+	Goodsgroupname string `json:"goodsgroupname"  xorm:"'Goodsgroupname'"` // 期货品种名称
+	Outergroupcode string `json:"outergroupcode"  xorm:"'Outergroupcode'"` // 期货品种代码
+	Goodunitid     int32  `json:"goodunitid"  xorm:"'Goodunitid'"`         // 品种单位id
+	GoodunitName   string `json:"goodunitname"  xorm:"'GoodunitName'"`     // 品种单位名称
+	AreaUserId     int64  `json:"-"`                                       // 所属机构id
+}
+
+// 获取数据
+func (r *ErmcpAvalidGoodsGroupModel) GetDataEx() (interface{}, error) {
+	sData := make([]ErmcpAvalidGoodsGroupModel, 0)
+	err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
+	return sData, err
+}
+
+func (r *ErmcpAvalidGoodsGroupModel) buildSql() string {
+	sqlId := "select g.groupcategroyid," +
+		"       g.goodsgroupid," +
+		"       g.goodsgroupname," +
+		"       g.outergroupcode," +
+		"       g.goodunitid" +
+		"  from ERMCP_GGConvertconfig t" +
+		"  left join goodsgroup g" +
+		"    on t.srcgoodsgroupid = g.goodsgroupid" +
+		" where g.groupcategroyid not in" +
+		"       (select g.groupcategroyid" +
+		"          from erms_middlegoods t" +
+		"          left join goodsgroup g" +
+		"            on t.goodsgroupid = g.goodsgroupid" +
+		"         where t.areauserid = %v" +
+		"           and t.goodsgroupid is not null)"
+	sqlId = fmt.Sprintf(sqlId, r.AreaUserId)
 	return sqlId
-}
+}
+

+ 1 - 0
routers/router.go

@@ -328,6 +328,7 @@ func InitRouter() *gin.Engine {
 		ermcpR.GET("/QueryMiddleGoodsDetail", ermcp.QueryMiddleGoodsDetail)
 		ermcpR.GET("/QueryGGConvertConfig", ermcp.QueryGGConvertConfig)
 		ermcpR.GET("/QueryMiddleGoodsChangeLog", ermcp.QueryMiddleGoodsChangeLog)
+		ermcpR.GET("/QueryAvaildGoodsGroup", ermcp.QueryAvaildGoodsGroup)
 	}
 
 	return r