order_report.go 979 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. package service
  2. import (
  3. "go-common/app/admin/ep/melloi/model"
  4. "go-common/library/log"
  5. )
  6. // AddReport add report
  7. func (s *Service) AddReport(userName string, report *model.OrderReport) (err error) {
  8. var qor *model.QueryOrderResponse
  9. report.UpdateBy = userName
  10. report.Active = 1
  11. // 更新order report
  12. if report.ID != 0 {
  13. return s.UpdateReportByID(report)
  14. }
  15. // 新增order report
  16. order := model.Order{ID: report.OrderID}
  17. if qor, err = s.dao.QueryOrder(&order, 1, 1); err != nil {
  18. log.Error("order_report.service get order error (%v)", err)
  19. return err
  20. }
  21. report.Name = qor.Orders[0].Name
  22. return s.dao.AddReport(report)
  23. }
  24. //QueryReportByOrderID query report
  25. func (s *Service) QueryReportByOrderID(orderID int64) (*model.OrderReport, error) {
  26. return s.dao.QueryReportByOrderID(orderID)
  27. }
  28. //UpdateReportByID update report by order_id
  29. func (s *Service) UpdateReportByID(report *model.OrderReport) (err error) {
  30. err = s.dao.UpdateReportByID(report)
  31. return
  32. }