fix
This commit is contained in:
@@ -35,7 +35,7 @@ func NewAdminPromotionLinkStatsService(svcCtx *ServiceContext) *AdminPromotionLi
|
||||
func (s *AdminPromotionLinkStatsService) ensureTotalStats(ctx context.Context, session sqlx.Session, linkId int64) (*model.AdminPromotionLinkStatsTotal, error) {
|
||||
totalStats, err := s.svcCtx.AdminPromotionLinkStatsTotalModel.FindOneByLinkId(ctx, linkId)
|
||||
if err != nil {
|
||||
if err == model.ErrNotFound {
|
||||
if errors.Is(err, model.ErrNotFound) {
|
||||
// 如果记录不存在,创建新记录
|
||||
totalStats = &model.AdminPromotionLinkStatsTotal{
|
||||
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) {
|
||||
historyStats, err := s.svcCtx.AdminPromotionLinkStatsHistoryModel.FindOneByLinkIdStatsDate(ctx, linkId, today)
|
||||
if err != nil {
|
||||
if err == model.ErrNotFound {
|
||||
if errors.Is(err, model.ErrNotFound) {
|
||||
// 如果记录不存在,创建新记录
|
||||
historyStats = &model.AdminPromotionLinkStatsHistory{
|
||||
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)
|
||||
if err != nil {
|
||||
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)
|
||||
if err != nil {
|
||||
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{
|
||||
LinkId: linkId,
|
||||
StatsDate: today,
|
||||
|
||||
Reference in New Issue
Block a user