Jelajahi Sumber

Merge branch 'master' of 192.168.30.132:MTP2.0/MTP20_IF

zhou.xiaoning 4 tahun lalu
induk
melakukan
b34f61f431
7 mengubah file dengan 100 tambahan dan 37 penghapusan
  1. 2 2
      controllers/ermcp/qryOPApply.go
  2. 8 0
      docs/docs.go
  3. 8 0
      docs/swagger.json
  4. 6 0
      docs/swagger.yaml
  5. 4 0
      models/ermcp.go
  6. 71 35
      models/ermcpExposure.go
  7. 1 0
      models/ermcpUser.go

+ 2 - 2
controllers/ermcp/qryOPApply.go

@@ -178,7 +178,7 @@ func QueryBusinessJsEx(c *gin.Context) {
 			if len(rsp.DETAILJSON) > 0 {
 				if err := json.Unmarshal([]byte(rsp.DETAILJSON), &rd); err == nil{
 					if rd.ReckonRealQty != nil{
-						rsp.ReckonType = "结算量"
+						rsp.ReckonType = "确定量"
 						rsp.ReckonValue = *rd.ReckonRealQty
 						sData = append(sData, rsp)
 					}
@@ -198,7 +198,7 @@ func QueryBusinessJsEx(c *gin.Context) {
 						sData = append(sData, rsp)
 					}
 					if rd.DecMargin != nil{
-						rsp.ReckonType = "减少保证金"
+						rsp.ReckonType = "退还保证金"
 						rsp.ReckonValue = *rd.DecMargin
 						sData = append(sData, rsp)
 					}

+ 8 - 0
docs/docs.go

@@ -7379,6 +7379,10 @@ var doc = `{
                     "description": "账户名称",
                     "type": "string"
                 },
+                "attachment": {
+                    "description": "附件",
+                    "type": "string"
+                },
                 "audittime": {
                     "description": "审核时间",
                     "type": "string"
@@ -7853,6 +7857,10 @@ var doc = `{
                     "description": "金额 [1:一口价、3:暂定价]",
                     "type": "number"
                 },
+                "attachment": {
+                    "description": "附件",
+                    "type": "string"
+                },
                 "auditremark": {
                     "description": "审核意见",
                     "type": "string"

+ 8 - 0
docs/swagger.json

@@ -7363,6 +7363,10 @@
                     "description": "账户名称",
                     "type": "string"
                 },
+                "attachment": {
+                    "description": "附件",
+                    "type": "string"
+                },
                 "audittime": {
                     "description": "审核时间",
                     "type": "string"
@@ -7837,6 +7841,10 @@
                     "description": "金额 [1:一口价、3:暂定价]",
                     "type": "number"
                 },
+                "attachment": {
+                    "description": "附件",
+                    "type": "string"
+                },
                 "auditremark": {
                     "description": "审核意见",
                     "type": "string"

+ 6 - 0
docs/swagger.yaml

@@ -1481,6 +1481,9 @@ definitions:
       accountname:
         description: 账户名称
         type: string
+      attachment:
+        description: 附件
+        type: string
       audittime:
         description: 审核时间
         type: string
@@ -1831,6 +1834,9 @@ definitions:
       amount:
         description: 金额 [1:一口价、3:暂定价]
         type: number
+      attachment:
+        description: 附件
+        type: string
       auditremark:
         description: 审核意见
         type: string

+ 4 - 0
models/ermcp.go

@@ -54,6 +54,7 @@ type ErmcpSpotContractModel struct {
 	SPOTGOODSBRANDID  int32   `json:"spotgoodsbrandid"  xorm:"'SPOTGOODSBRANDID'"`   // 现货品牌ID
 	BRANDNAME         string  `json:"brandname"  xorm:"'brandname'"`                 // 品牌名称
 	MODELNAME         string  `json:"modelname"  xorm:"'modelname'"`                 // 型号名称
+	ATTACHMENT        string  `json:"attachment"  xorm:"'ATTACHMENT'"`               // 附件
 }
 
 func (r *ErmcpSpotContractModel) buildSql(nQueryType int32) string {
@@ -82,6 +83,7 @@ func (r *ErmcpSpotContractModel) buildSql(nQueryType int32) string {
 		"       t.contractmargin," +
 		"       t.remark," +
 		"       t.auditremark," +
+		"       to_char(t.contractattachment) attachment," +
 		"       t.contractstatus," +
 		"       t.SPOTGOODSMODELID," +
 		"       t.SPOTGOODSBRANDID," +
@@ -176,6 +178,7 @@ type ErmcpModel struct {
 	Margin             float64 `json:"margin"  xorm:"'MARGIN'"`                         // 保证金
 	CONTRACTMARGIN     float64 `json:"contractmargin"  xorm:"'CONTRACTMARGIN'"`         // 合同保证金
 	Remark             string  `json:"remark"  xorm:"'Remark'"`                         // 备注
+	ATTACHMENT         string  `json:"attachment"  xorm:"'ATTACHMENT'"`                 // 附件
 	ReckonRealQty      float64 `json:"reckonrealqty"  xorm:"'ReckonRealQty'"`           // 已确定量
 	ReckonOtherAmount  float64 `json:"reckonotheramount"  xorm:"'ReckonOtherAmount'"`   // 其它费用
 	ReckonAdjustAmount float64 `json:"reckonadjustamount"  xorm:"'ReckonAdjustAmount'"` // 调整金额
@@ -236,6 +239,7 @@ func (r *ErmcpModel) buildSql(nContractType, nQueryType int32) string {
 		"       t.producttype," +
 		"       t.contracttype," +
 		"       t.remark," +
+		"       to_char(t.contractattachment) attachment," +
 		"       t.margin," +
 		"       t.contractmargin," +
 		"       u.accountname," +

+ 71 - 35
models/ermcpExposure.go

@@ -111,7 +111,7 @@ func (r *ErmcpRealExposureModel) GetData() ([]ErmcpRealExposureModel, error) {
 
 /*************敞口明细**************/
 
-//敞口明细结构
+//敞口现货明细结构
 type ErmcpExposureDetailModel struct {
 	Createtime      string  `json:"createtime"  xorm:"'createtime'"`           // 时间
 	Areauserid      uint32  `json:"areauserid"  xorm:"'areauserid'"`           // 机构ID
@@ -136,10 +136,11 @@ func (r *ErmcpExposureDetailModel) buildSql() string {
 	str := "with tmp as" +
 		" (select 2                as LogType," +
 		"         s.spotcontractid as relatedid," +
-		"         s.contractno     as relateNo" +
+		"         s.contractno     as relateNo," +
+		"         s.qty " +
 		"    from ermcp_spotcontract s" +
 		"  union all" +
-		"  select 1, t.hedgeplanid as relateid, t.hedgeplanno as relateNo" +
+		"  select 1, t.hedgeplanid as relateid, t.hedgeplanno as relateNo, t.planqty as qty " +
 		"    from ermcp_hedgeplan t)" +
 		"select to_char(t.createtime, 'yyyy-mm-dd hh24:mi:ss') createtime," +
 		"       t.middlegoodsid," +
@@ -147,10 +148,10 @@ func (r *ErmcpExposureDetailModel) buildSql() string {
 		"       t.logtype," +
 		"       t.contracttype," +
 		"       wc.wrstandardid," +
-		"       t.qty," +
+		"       tmp.qty," +
 		"       t.convertfactor," +
 		"       t.convertratio," +
-		"       t.qty * t.convertfactor * t.convertratio as changeQty," +
+		"       t.qty changeQty," +
 		"       tmp.relateNo," +
 		"       m.middlegoodsname," +
 		"       m.middlegoodscode," +
@@ -177,6 +178,21 @@ func (r *ErmcpExposureDetailModel) buildSql() string {
 	return fmt.Sprintf(str, r.MiddlegoodsId, r.Areauserid)
 }
 
+// 处理数据
+func (r *ErmcpExposureDetailModel) Calc() {
+	// 销售合同转换为负数
+	if r.Logtype == 2 && r.Contracttype == -1 {
+		r.ChangeQty *= -1
+		r.Qty *= -1
+	}
+
+	// 采购计划 转换为负数
+	if r.Logtype == 1 && r.Contracttype == 1 {
+		r.ChangeQty *= -1
+		r.Qty *= -1
+	}
+}
+
 // 查询敞口现货明细
 func (r *ErmcpExposureDetailModel) GetData() ([]ErmcpExposureDetailModel, error) {
 	e := db.GetEngine()
@@ -185,6 +201,9 @@ func (r *ErmcpExposureDetailModel) GetData() ([]ErmcpExposureDetailModel, error)
 	if err := s.Find(&sData); err != nil {
 		return nil, err
 	}
+	for i := range sData {
+		sData[i].Calc()
+	}
 	return sData, nil
 }
 
@@ -273,37 +292,41 @@ type ErmcpAreaSpotDetailModel struct {
 
 // 组建查询SQL
 func (r *ErmcpAreaSpotDetailModel) buildSql() string {
-	str := "select to_char(t.hedgeplanid) relatedid," +
-		"       t.hedgeplanno relatedno," +
-		"       1 as logType," +
-		"       t.contracttype," +
-		"       w.wrstandardname," +
-		"       w.wrstandardcode," +
-		"       t.planqty qty," +
-		"        w.unitid," +
-		"       to_char(t.createtime, 'yyyy-mm-dd hh:mi:ss') createtime" +
-		"  from ermcp_hedgeplan t" +
-		"  left join wrstandard w" +
-		"    on t.wrstandardid = w.wrstandardid" +
-		" where t.hedgeplanstatus in (2, 3, 5)" +
-		"   and t.areauserid = %v and t.wrstandardid = %v" +
-		" union all " +
-		"select to_char(t.spotcontractid)," +
-		"       t.contractno," +
-		"       1 as logType," +
-		"       t.contracttype," +
+	str := "with tmp as" +
+		" (select to_char(t.hedgeplanid) relatedid," +
+		"         t.hedgeplanno relatedno," +
+		"         1 as logType," +
+		"         t.contracttype" +
+		"    from ermcp_hedgeplan t" +
+		"   where t.areauserid = %v" +
+		"     and t.wrstandardid = %v" +
+		"  union all " +
+		"  select to_char(t.spotcontractid)," +
+		"         t.contractno," +
+		"         2 as logType," +
+		"         t.contracttype" +
+		"    from ermcp_spotcontract t" +
+		"   where t.userid = %v" +
+		"     and t.wrstandardid = %v)" +
+		"select t.relatedid," +
+		"       tmp.relatedno," +
+		"       t.LogType," +
+		"       tmp.contracttype," +
+		"       t.RealQty qty," +
+		"       to_char(t.createtime, 'yyyy-mm-dd hh:mi:ss') createtime," +
 		"       w.wrstandardname," +
 		"       w.wrstandardcode," +
-		"       t.qty," +
-		"       w.unitid," +
-		"       to_char(t.createtime, 'yyyy-mm-dd hh:mi:ss') createtime" +
-		"  from ermcp_spotcontract t" +
+		"       w.unitid" +
+		"  from ermcp_spotlog t" +
+		" inner join tmp" +
+		"    on t.LogType = tmp.logType" +
+		"   and t.relatedid = tmp.relatedid" +
+		"   and t.areauserid = %v" +
+		"   and t.wrstandardid = %v" +
 		"  left join wrstandard w" +
-		"    on t.wrstandardid = w.wrstandardid" +
-		" where t.contractstatus in (2, 3, 5)" +
-		"   and t.userid = %v and t.wrstandardid = %v"
+		"    on t.wrstandardid = w.wrstandardid"
 
-	return fmt.Sprintf(str, r.UserId, r.WrstandardId, r.UserId, r.WrstandardId)
+	return fmt.Sprintf(str, r.UserId, r.WrstandardId, r.UserId, r.WrstandardId, r.UserId, r.WrstandardId)
 }
 
 // 现货头寸-明细:数据加工处理
@@ -319,8 +342,18 @@ func (r *ErmcpAreaSpotDetailModel) Calc() {
 		contractTypeName = "采购"
 	} else {
 		contractTypeName = "销售"
+	}
+
+	// 销售合同 数量转为负数
+	if r.LogType == 2 && r.Contracttype == -1 {
+		if r.Qty > 0 {
+			r.Qty = r.Qty * -1
+		}
+	}
+
+	// 采购计划 数量转为负数
+	if r.LogType == 1 && r.Contracttype == 1 {
 		if r.Qty > 0 {
-			// 销售的数量转为负数
 			r.Qty = r.Qty * -1
 		}
 	}
@@ -561,6 +594,9 @@ func (r *ErmcpHedgePosition) buildSql() string {
 func (r *ErmcpHedgePosition) GetData() ([]ErmcpHedgePosition, error) {
 	sData := make([]ErmcpHedgePosition, 0)
 	err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
+	for i := range sData {
+		sData[i].Calc()
+	}
 	return sData, err
 }
 
@@ -592,7 +628,7 @@ func (r *ErmcpExposurePostion) ParseFromPos(val *ErmcpTradeGoods, data *ErmcpTra
 	r.DiffQty = r.CurQty - r.YdQty
 	r.DiffHedgeQty = float64(r.DiffQty) * float64(val.AGREEUNIT) * val.CONVERTRATIO
 	r.CONVERTRATIO = val.CONVERTRATIO
-	if strName := mtpcache.GetEnumDicitemName(val.GOODSUNITID); len(strName) > 0{
+	if strName := mtpcache.GetEnumDicitemName(val.GOODSUNITID); len(strName) > 0 {
 		r.AGREEUNIT = fmt.Sprintf("%v%v/手", val.AGREEUNIT, strName)
 	}
 }
@@ -610,7 +646,7 @@ func (r *ErmcpExposurePostion) ParseFromHedgePos(val *ErmcpTradeGoods, data *Erm
 	r.DiffQty = r.CurQty - r.YdQty
 	r.DiffHedgeQty = float64(r.DiffQty) * float64(val.AGREEUNIT) * val.CONVERTRATIO
 	r.CONVERTRATIO = val.CONVERTRATIO
-	if strName := mtpcache.GetEnumDicitemName(val.GOODSUNITID); len(strName) > 0{
+	if strName := mtpcache.GetEnumDicitemName(val.GOODSUNITID); len(strName) > 0 {
 		r.AGREEUNIT = fmt.Sprintf("%v%v/手", val.AGREEUNIT, strName)
 	}
 }

+ 1 - 0
models/ermcpUser.go

@@ -115,6 +115,7 @@ func (r *ErmcpUserModel) DecryptField(decryptAddress bool) {
 
 	r.CARDNUM = fd(r.CARDNUM)
 	r.MOBILE = fd(r.MOBILE)
+	r.TELPHONE = fd(r.TELPHONE)
 
 	if decryptAddress {
 		r.ADDRESS = fd(r.ADDRESS)