|
|
@@ -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 {
|
|
|
//构建应答数据
|