charge_off.go 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package http
  2. import (
  3. "kpt.xdmy/apiserver/model"
  4. "kpt.xdmy/pkg/util"
  5. )
  6. type ChargeOffReq struct {
  7. Dest `json:"DEST"`
  8. Data ChargeOff `json:"DATA"`
  9. }
  10. type ChargeOffDetail struct {
  11. RowNumber int `json:"ZEILE"`
  12. }
  13. type ChargeOff struct {
  14. ProofCode string `json:"MBLNR"` // 物料凭证号
  15. ProofYear string `json:"MJAHR"` // 物料凭证年度
  16. ChargeDate string `json:"BUDAT"` // 凭证中的过帐日期 YYYYMMDD
  17. OrderNumber string `json:"FRBNR"` // 设备管理平台单号
  18. RowsNumber []ChargeOffDetail `json:"TMSEG"` // 设备管理平台行号
  19. HasTicket string `json:"ZTHFLG"` // 是否已开票退货单 "是: X ,※仅采购业务需要
  20. }
  21. func (c *ChargeOffReq) NewDest() {
  22. c.Dest = Dest{
  23. DestID: "EQMAN",
  24. BussTp: "MM015",
  25. Url: "https://app.modernfarming.cn:7443/sap/Common/MM015/CancelMblnr",
  26. }
  27. }
  28. func (c *ChargeOffReq) NewReq(p *model.ProofReq) {
  29. c.NewDest()
  30. h := ChargeOff{
  31. ProofCode: p.ProofCode,
  32. ProofYear: p.ProofYear,
  33. ChargeDate: p.ChargeDate,
  34. OrderNumber: p.OrderNumber,
  35. HasTicket: util.ZeroStr(p.HasTicket == 1, "X"),
  36. }
  37. s := make([]ChargeOffDetail, len(p.RowsNumber))
  38. for v := range p.RowsNumber {
  39. s = append(s, ChargeOffDetail{RowNumber: v})
  40. }
  41. h.RowsNumber = s
  42. c.Data = h
  43. }