statistic.go 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. // statOrderNumByTime
  12. // @Tags 后台-统计
  13. // @Summary 根据订单开始时间统计
  14. // @Success 200 {object} dao.StaticNumData "成功响应的结构体"
  15. // @Param req body statisticsrv.OrderNumTimeStatReqVO true "请求参数"
  16. // @Accept application/json
  17. // @Router /manage/statistic/orderNum/byTime [post]
  18. func (api Api) statOrderNumByTime(c *gin.Context) {
  19. req := statisticsrv.OrderNumTimeStatReqVO{}
  20. if err := c.BindJSON(&req); err != nil {
  21. core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrBindJSON, ""))
  22. return
  23. }
  24. srv := statisticsrv.NewStatisticService(dao.NewDataStore(global.CommonConnectRepoInst.StoreDB))
  25. res, err := srv.OrderNumTimeStat(c, req)
  26. if err != nil {
  27. core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrQueryFailed, ""))
  28. return
  29. }
  30. core.WriteResponse(c, nil, res)
  31. }
  32. // statOrderNumByUser
  33. // @Tags 后台-统计
  34. // @Summary 根据订单用户统计
  35. // @Success 200 {object} swagger.PageListResponse "成功响应的结构体"
  36. // @Param req body swagger.OrderNumUserStatReqVO true "请求参数"
  37. // @Accept application/json
  38. // @Router /manage/statistic/orderNum/byUser [post]
  39. func (api Api) statOrderNumByUser(c *gin.Context) {
  40. req := statisticsrv.OrderNumUserStatReqVO{}
  41. if err := c.BindJSON(&req); err != nil {
  42. core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrBindJSON, ""))
  43. return
  44. }
  45. srv := statisticsrv.NewStatisticService(dao.NewDataStore(global.CommonConnectRepoInst.StoreDB))
  46. res, err := srv.OrderNumUserStat(c, req)
  47. if err != nil {
  48. core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrQueryFailed, ""))
  49. return
  50. }
  51. core.WriteResponse(c, nil, res)
  52. }