1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- package logic
- import (
- "context"
- "math/rand"
- "time"
- . "bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/api/messagecenter/common"
- "bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/api/messagecenter/internal/svc"
- "bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/api/messagecenter/internal/types"
- "github.com/zeromicro/go-zero/core/logx"
- )
- type ObtainShuntLogic struct {
- logx.Logger
- ctx context.Context
- svcCtx *svc.ServiceContext
- }
- func NewObtainShuntLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ObtainShuntLogic {
- return &ObtainShuntLogic{
- Logger: logx.WithContext(ctx),
- ctx: ctx,
- svcCtx: svcCtx,
- }
- }
- func (l *ObtainShuntLogic) ObtainShunt(req *types.ShuntReq) (*types.CommonRes, error) {
- // todo: add your logic here and delete this line
- data := map[string]interface{}{}
- if C.IsShunt {
- data["isShunt"] = C.IsShunt
- //计算概率,获取分流途径
- shunt := "智齿"
- if rand.New(rand.NewSource(time.Now().UnixNano())).Int63n(100) <= C.ShuntProbability {
- shunt = "智齿"
- } else {
- shunt = "剑鱼"
- }
- if shunt == "智齿" {
- if req.Type == "PC" {
- data["url"] = C.ZhiCiUrl.Pc
- } else if req.Type == "APP" {
- data["url"] = C.ZhiCiUrl.App
- } else {
- data["url"] = C.ZhiCiUrl.Wx
- }
- } else {
- if req.Type == "PC" {
- data["url"] = C.MessageUrl.Pc
- } else if req.Type == "APP" {
- data["url"] = C.MessageUrl.App
- } else {
- data["url"] = C.MessageUrl.Wx
- }
- }
- } else {
- data["isShunt"] = C.IsShunt
- if req.Type == "PC" {
- data["url"] = C.ZhiCiUrl.Pc
- } else if req.Type == "App" {
- data["url"] = C.ZhiCiUrl.App
- } else {
- data["url"] = C.ZhiCiUrl.Wx
- }
- }
- return &types.CommonRes{
- Data: data,
- }, nil
- }
|