create_supplier_invoice.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package handler
  2. import (
  3. "github.com/gin-gonic/gin"
  4. "youngee_b_api/model/http_model"
  5. "youngee_b_api/service"
  6. )
  7. func WrapCreateSupplierInvoiceHandler(ctx *gin.Context) {
  8. handler := newCreateSupplierInvoiceHandler(ctx)
  9. baseRun(handler)
  10. }
  11. func newCreateSupplierInvoiceHandler(ctx *gin.Context) *CreateSupplierInvoiceHandler {
  12. return &CreateSupplierInvoiceHandler{
  13. req: http_model.NewCreateSupplierInvoiceRequest(),
  14. resp: http_model.NewCreateSupplierInvoiceResponse(),
  15. ctx: ctx,
  16. }
  17. }
  18. type CreateSupplierInvoiceHandler struct {
  19. req *http_model.CreateSupplierInvoiceRequest
  20. resp *http_model.CommonResponse
  21. ctx *gin.Context
  22. }
  23. func (h *CreateSupplierInvoiceHandler) getRequest() interface{} {
  24. return h.req
  25. }
  26. func (h *CreateSupplierInvoiceHandler) getContext() *gin.Context {
  27. return h.ctx
  28. }
  29. func (h *CreateSupplierInvoiceHandler) getResponse() interface{} {
  30. return h.resp
  31. }
  32. func (h *CreateSupplierInvoiceHandler) run() {
  33. // 1. 合并收入回票
  34. err := service.Supplier.CreateSupplierInvoice(h.ctx, h.req)
  35. if err != nil {
  36. h.resp.Data = err.Error()
  37. h.resp.Message = "合并失败"
  38. }
  39. // 2. 修改收入状态
  40. incomeErr := service.Supplier.UpdateSupplierIncomeStatus(h.ctx, h.req.IncomeIds, 2)
  41. if incomeErr != nil {
  42. h.resp.Data = incomeErr.Error()
  43. h.resp.Message = "修改收入状态失败"
  44. }
  45. h.resp.Message = "合并修改成功"
  46. }
  47. func (h *CreateSupplierInvoiceHandler) checkParam() error {
  48. return nil
  49. }