2025-01-21 16:48:55 +08:00

55 lines
1.1 KiB
Go

package douyin
import (
"context"
"time"
"gitea.youtukeji.com.cn/xiabin/youtu_server/game_open_api/internal/svc"
"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 {
return &GetEcpmLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *GetEcpmLogic) GetEcpm() (result bool, errNeverNil error) {
at, err := svc.GetCtxToken(l.ctx)
if err != nil {
errNeverNil = err
return
}
at.AppIdStr = "tt5bc32d7ec4f6ccb907"
at.OpenId = "_0005ITFnsqTvXpTC7wqg6yvQ1_mXhk1TbOv"
res, err := l.svcCtx.DouyinCli.GetEcpmData(at.AppIdStr, at.OpenId, time.Now().Format(time.DateOnly))
if err != nil {
l.Logger.Error(err.Error())
return
}
ecpm, err := l.svcCtx.DouyinCli.GetEcpm(res)
if err != nil {
l.Logger.Error(err.Error())
return
}
if ecpm > float64(l.svcCtx.DouyinCli.GetEcpmValue(at.AppIdStr)) && len(res) > int(l.svcCtx.DouyinCli.GetEcpmViewCount(at.AppIdStr)) {
result = true
} else {
result = false
}
return
}