ソースを参照

查询采购销售全同增加保证金字段、查业务加款项类型字段

zou.yingbin 4 年 前
コミット
148cd473f1
2 ファイル変更27 行追加11 行削除
  1. 24 10
      controllers/ermcp/qryOPApply.go
  2. 3 1
      models/ermcp.go

+ 24 - 10
controllers/ermcp/qryOPApply.go

@@ -24,7 +24,7 @@ type DjData struct {
 
 //计算点价金额
 func (r *DjData) calc(priceMove float64) {
-	if r.PricedPrice != nil && r.PricedQty != nil{
+	if r.PricedPrice != nil && r.PricedQty != nil {
 		r.Amount = new(float64)
 		*r.Amount = (*r.PricedPrice + priceMove) * (*r.PricedQty)
 	}
@@ -44,6 +44,18 @@ type ReckonData struct {
 type KxData struct {
 	PayAmount    *float64 `json:"payamount,omitempty"`    //收付款(非必填)
 	DeductAmount *float64 `json:"deductamount,omitempty"` //退款(非必填)
+	KxType       int32    `json:"kxtype,omitempty"`       // 款项类型 1-收付款(PayAmount字段有值) 2-退款(DeductAmount字段有值) 3-收付款/退款(2个字段都有)
+}
+
+// 获取款项类型,1-收付款(PayAmount字段有值) 2-退款(DeductAmount字段有值) 3-收付款/退款(2个字段都有)
+func (r *KxData) CalcKxType(contractType int32) {
+	if r.PayAmount != nil && r.DeductAmount != nil {
+		r.KxType = 3
+	} else if r.PayAmount != nil {
+		r.KxType = 1
+	} else if r.DeductAmount != nil {
+		r.KxType = 2
+	}
 }
 
 //开票操作数据
@@ -53,7 +65,7 @@ type KpData struct {
 
 // 查询合同操作请求
 type QryOPApplyReq struct {
-	UserId    int64   `form:"UserId" binding:"required"`   //用户ID
+	UserId    int64  `form:"UserId" binding:"required"`    //用户ID
 	RelatedId string `form:"relatedid" binding:"required"` //现货合同ID, 不填则查所有
 }
 
@@ -76,7 +88,7 @@ type QryBusinessDjRsp struct {
 func QueryBusinessDj(c *gin.Context) {
 	appG := app.Gin{C: c}
 	var req QryOPApplyReq
-	_=c.ShouldBind(&req)
+	_ = c.ShouldBind(&req)
 	m := models.ErmcpOPApplyModel{RELATEDID: req.RelatedId, USERID: req.UserId}
 	if d, err := m.GetData(1); err == nil {
 		//构建应答数据
@@ -84,8 +96,8 @@ func QueryBusinessDj(c *gin.Context) {
 		for _, v := range d {
 			var rsp QryBusinessDjRsp
 			rsp.ErmcpOPApplyModel = v
-			if len(rsp.DETAILJSON) > 0{
-				if err := json.Unmarshal([]byte(rsp.DETAILJSON), &rsp.DjData); err == nil{
+			if len(rsp.DETAILJSON) > 0 {
+				if err := json.Unmarshal([]byte(rsp.DETAILJSON), &rsp.DjData); err == nil {
 					rsp.DjData.calc(rsp.PRICEMOVE)
 				}
 				sData = append(sData, rsp)
@@ -116,7 +128,7 @@ type QryBussinessJsRsp struct {
 func QueryBusinessJs(c *gin.Context) {
 	appG := app.Gin{C: c}
 	var req QryOPApplyReq
-	_=c.ShouldBind(&req)
+	_ = c.ShouldBind(&req)
 	m := models.ErmcpOPApplyModel{RELATEDID: req.RelatedId, USERID: req.UserId}
 	if d, err := m.GetData(2); err == nil {
 		//构建应答数据
@@ -154,7 +166,7 @@ type QryBussinessKxRsp struct {
 func QueryBusinessKx(c *gin.Context) {
 	appG := app.Gin{C: c}
 	var req QryOPApplyReq
-	_=c.ShouldBind(&req)
+	_ = c.ShouldBind(&req)
 	m := models.ErmcpOPApplyModel{RELATEDID: req.RelatedId, USERID: req.UserId}
 	if d, err := m.GetData(3); err == nil {
 		//构建应答数据
@@ -163,9 +175,11 @@ func QueryBusinessKx(c *gin.Context) {
 			var rsp QryBussinessKxRsp
 			rsp.ErmcpOPApplyModel = v
 			if len(rsp.DETAILJSON) > 0 {
-				_ = json.Unmarshal([]byte(rsp.DETAILJSON), &rsp.KxData)
+				if err := json.Unmarshal([]byte(rsp.DETAILJSON), &rsp.KxData); err == nil{
+					rsp.KxData.CalcKxType(rsp.CONTRACTTYPE)
+					sData = append(sData, rsp)
+				}
 			}
-			sData = append(sData, rsp)
 		}
 		appG.Response(http.StatusOK, e.SUCCESS, sData)
 	} else {
@@ -192,7 +206,7 @@ type QryBussinessFpRsp struct {
 func QueryBusinessFp(c *gin.Context) {
 	appG := app.Gin{C: c}
 	var req QryOPApplyReq
-	_=c.ShouldBind(&req)
+	_ = c.ShouldBind(&req)
 	m := models.ErmcpOPApplyModel{RELATEDID: req.RelatedId, USERID: req.UserId}
 	if d, err := m.GetData(4); err == nil {
 		//构建应答数据

+ 3 - 1
models/ermcp.go

@@ -150,7 +150,8 @@ type ErmcpModel struct {
 	Contracttype      float64 `json:"contracttype"  xorm:"'CONTRACTTYPE'"`           // 合同类型 1-采购, -1-销售
 	Pricedamount      float64 `json:"pricedamount"  xorm:"'PRICEDAMOUNT'"`           // 已定价额
 	PricedAvg         float64 `json:"pricedavg"  xorm:"'PRICEDAVG'"`                 // 已点均价
-	Remark            string  `json:"remark"  xorm:"'Remark'"`                       //备注
+	Margin            float64 `json:"margin"  xorm:"'MARGIN'"`                       // 保证金
+	Remark            string  `json:"remark"  xorm:"'Remark'"`                       // 备注
 }
 
 // 组装查询的sql
@@ -186,6 +187,7 @@ func (r *ErmcpModel) buildSql(nContractType, nQueryType int32) string {
 		"       t.producttype," +
 		"       t.contracttype," +
 		"       t.remark," +
+		"       t.margin," +
 		"       to_char(ta.accountid) accountid," +
 		"       ta.accountname," +
 		"       g.deliverygoodscode," +