fix
This commit is contained in:
parent
830d9ae9d9
commit
ca66cc91d4
@ -100,7 +100,8 @@ func (l *GetPromotionStatsTotalLogic) GetPromotionStatsTotal(req *types.GetPromo
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 获取今日统计数据
|
// 获取今日统计数据
|
||||||
today := time.Now().Truncate(24 * time.Hour)
|
now := time.Now()
|
||||||
|
today := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local)
|
||||||
var todayClickCount, todayPayCount int64
|
var todayClickCount, todayPayCount int64
|
||||||
var todayPayAmount float64
|
var todayPayAmount float64
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ func NewAdminPromotionLinkStatsService(svcCtx *ServiceContext) *AdminPromotionLi
|
|||||||
func (s *AdminPromotionLinkStatsService) ensureTotalStats(ctx context.Context, session sqlx.Session, linkId int64) (*model.AdminPromotionLinkStatsTotal, error) {
|
func (s *AdminPromotionLinkStatsService) ensureTotalStats(ctx context.Context, session sqlx.Session, linkId int64) (*model.AdminPromotionLinkStatsTotal, error) {
|
||||||
totalStats, err := s.svcCtx.AdminPromotionLinkStatsTotalModel.FindOneByLinkId(ctx, linkId)
|
totalStats, err := s.svcCtx.AdminPromotionLinkStatsTotalModel.FindOneByLinkId(ctx, linkId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == model.ErrNotFound {
|
if errors.Is(err, model.ErrNotFound) {
|
||||||
// 如果记录不存在,创建新记录
|
// 如果记录不存在,创建新记录
|
||||||
totalStats = &model.AdminPromotionLinkStatsTotal{
|
totalStats = &model.AdminPromotionLinkStatsTotal{
|
||||||
LinkId: linkId,
|
LinkId: linkId,
|
||||||
@ -63,7 +63,7 @@ func (s *AdminPromotionLinkStatsService) ensureTotalStats(ctx context.Context, s
|
|||||||
func (s *AdminPromotionLinkStatsService) ensureHistoryStats(ctx context.Context, session sqlx.Session, linkId int64, today time.Time) (*model.AdminPromotionLinkStatsHistory, error) {
|
func (s *AdminPromotionLinkStatsService) ensureHistoryStats(ctx context.Context, session sqlx.Session, linkId int64, today time.Time) (*model.AdminPromotionLinkStatsHistory, error) {
|
||||||
historyStats, err := s.svcCtx.AdminPromotionLinkStatsHistoryModel.FindOneByLinkIdStatsDate(ctx, linkId, today)
|
historyStats, err := s.svcCtx.AdminPromotionLinkStatsHistoryModel.FindOneByLinkIdStatsDate(ctx, linkId, today)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == model.ErrNotFound {
|
if errors.Is(err, model.ErrNotFound) {
|
||||||
// 如果记录不存在,创建新记录
|
// 如果记录不存在,创建新记录
|
||||||
historyStats = &model.AdminPromotionLinkStatsHistory{
|
historyStats = &model.AdminPromotionLinkStatsHistory{
|
||||||
LinkId: linkId,
|
LinkId: linkId,
|
||||||
@ -106,7 +106,8 @@ func (s *AdminPromotionLinkStatsService) UpdateLinkStats(ctx context.Context, li
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 确保历史统计记录存在
|
// 确保历史统计记录存在
|
||||||
today := time.Now().Truncate(24 * time.Hour)
|
now := time.Now()
|
||||||
|
today := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local)
|
||||||
historyStats, err := s.ensureHistoryStats(ctx, session, linkId, today)
|
historyStats, err := s.ensureHistoryStats(ctx, session, linkId, today)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -143,7 +144,8 @@ func (s *AdminPromotionLinkStatsService) UpdatePaymentStats(ctx context.Context,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 确保历史统计记录存在
|
// 确保历史统计记录存在
|
||||||
today := time.Now().Truncate(24 * time.Hour)
|
now := time.Now()
|
||||||
|
today := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local)
|
||||||
historyStats, err := s.ensureHistoryStats(ctx, session, linkId, today)
|
historyStats, err := s.ensureHistoryStats(ctx, session, linkId, today)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -188,7 +190,8 @@ func (s *AdminPromotionLinkStatsService) CreateLinkStats(ctx context.Context, li
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 创建今日历史统计记录
|
// 创建今日历史统计记录
|
||||||
today := time.Now().Truncate(24 * time.Hour)
|
now := time.Now()
|
||||||
|
today := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local)
|
||||||
historyStats := &model.AdminPromotionLinkStatsHistory{
|
historyStats := &model.AdminPromotionLinkStatsHistory{
|
||||||
LinkId: linkId,
|
LinkId: linkId,
|
||||||
StatsDate: today,
|
StatsDate: today,
|
||||||
|
Loading…
Reference in New Issue
Block a user