1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- package statisticsrv
- import (
- "Cold_Logistic/internal/server/infra/dao"
- "context"
- "gogs.baozhida.cn/Cold_Logistic_libs/pkg/contrib/core"
- "gogs.baozhida.cn/Cold_Logistic_libs/pkg/contrib/errors"
- )
- type StatisticService struct {
- store *dao.DataStore
- }
- func NewStatisticService(store *dao.DataStore) *StatisticService {
- return &StatisticService{store: store}
- }
- // OrderNumTimeStat 订单数量统计-按时间
- func (srv *StatisticService) OrderNumTimeStat(ctx context.Context, req OrderNumTimeStatReqVO) (res []dao.StaticNumData, err error) {
- dto := dao.StaticOrderNumDTO{
- StatType: req.StatType,
- TimeStart: req.TimeStart,
- TimeEnd: req.TimeEnd,
- OrderStatus: req.OrderStatus,
- }
- res, err = srv.store.ExpressOrder().StaticNumByTime(ctx, dto)
- if err != nil {
- return res, errors.WithStackOnce(err)
- }
- return res, nil
- }
- // OrderNumUserStat 订单数量统计-按用户+时间
- func (srv *StatisticService) OrderNumUserStat(ctx context.Context, req OrderNumUserStatReqVO) (res core.PageListResponse, err error) {
- dto := dao.StaticOrderNumDTO{
- Page: req.Page,
- StatType: req.Search.StatType,
- TimeStart: req.Search.TimeStart,
- TimeEnd: req.Search.TimeEnd,
- OrderStatus: req.Search.OrderStatus,
- }
- list, total, err := srv.store.ExpressOrder().StaticNumByUser(ctx, dto)
- if err != nil {
- return res, errors.WithStackOnce(err)
- }
- res.Total = total
- res.TotalPage = total / int64(req.Page.Size)
- res.Count = len(list)
- res.List = list
- return res, nil
- }
|