statistic.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package manage
  2. import (
  3. "Cold_Logistic/internal/pkg/common/codex"
  4. "Cold_Logistic/internal/pkg/common/global"
  5. "Cold_Logistic/internal/server/application/statisticsrv"
  6. "Cold_Logistic/internal/server/infra/dao"
  7. "github.com/gin-gonic/gin"
  8. "gogs.baozhida.cn/Cold_Logistic_libs/pkg/contrib/core"
  9. "gogs.baozhida.cn/Cold_Logistic_libs/pkg/contrib/errors"
  10. )
  11. func (api Api) statOrderNumByTime(c *gin.Context) {
  12. req := statisticsrv.OrderNumTimeStatReqVO{}
  13. if err := c.BindJSON(&req); err != nil {
  14. core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrBindJSON, ""))
  15. return
  16. }
  17. srv := statisticsrv.NewStatisticService(dao.NewDataStore(global.CommonConnectRepoInst.StoreDB))
  18. res, err := srv.OrderNumTimeStat(c, req)
  19. if err != nil {
  20. core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrQueryFailed, ""))
  21. return
  22. }
  23. core.WriteResponse(c, nil, res)
  24. }
  25. func (api Api) statOrderNumByUser(c *gin.Context) {
  26. req := statisticsrv.OrderNumUserStatReqVO{}
  27. if err := c.BindJSON(&req); err != nil {
  28. core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrBindJSON, ""))
  29. return
  30. }
  31. srv := statisticsrv.NewStatisticService(dao.NewDataStore(global.CommonConnectRepoInst.StoreDB))
  32. res, err := srv.OrderNumUserStat(c, req)
  33. if err != nil {
  34. core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrQueryFailed, ""))
  35. return
  36. }
  37. core.WriteResponse(c, nil, res)
  38. }