55 lines
1.2 KiB
Go
Raw Normal View History

2025-01-20 01:55:44 +08:00
package douyin
import (
"context"
"gitea.youtukeji.com.cn/xiabin/youtu_server/game_open_api/internal/app_api_helper"
2025-01-20 01:55:44 +08:00
"time"
"gitea.youtukeji.com.cn/xiabin/youtu_server/game_open_api/internal/svc"
2025-01-20 01:55:44 +08:00
"github.com/zeromicro/go-zero/core/logx"
)
type GetEcpmLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewGetEcpmLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetEcpmLogic {
app_api_helper.Init(ctx, svcCtx.AppAccount)
return &GetEcpmLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
2025-01-20 10:10:08 +08:00
func (l *GetEcpmLogic) GetEcpm() (result bool, errNeverNil error) {
at, err := svc.GetCtxToken(l.ctx)
2025-01-20 01:55:44 +08:00
if err != nil {
2025-01-20 10:10:08 +08:00
errNeverNil = err
2025-01-20 01:55:44 +08:00
return
}
2025-01-20 10:10:08 +08:00
res, err := app_api_helper.DouyinCli.GetEcpmData(at.AppIdStr, at.OpenId, time.Now().Format(time.DateOnly))
2025-01-20 01:55:44 +08:00
if err != nil {
l.Logger.Error(err.Error())
return
}
ecpm, err := app_api_helper.DouyinCli.GetEcpm(res)
if err != nil {
l.Logger.Error(err.Error())
return
}
2025-01-20 10:10:08 +08:00
if ecpm > float64(app_api_helper.DouyinCli.GetEcpmValue(at.AppIdStr)) && len(res) > int(app_api_helper.DouyinCli.GetEcpmViewCount(at.AppIdStr)) {
2025-01-20 01:55:44 +08:00
result = true
} else {
result = false
}
return
}