obtainshuntlogic.go 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. package logic
  2. import (
  3. "bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/api/messagecenter/internal/svc"
  4. "bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/api/messagecenter/internal/types"
  5. "context"
  6. "github.com/zeromicro/go-zero/core/logx"
  7. )
  8. type ObtainShuntLogic struct {
  9. logx.Logger
  10. ctx context.Context
  11. svcCtx *svc.ServiceContext
  12. }
  13. func NewObtainShuntLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ObtainShuntLogic {
  14. return &ObtainShuntLogic{
  15. Logger: logx.WithContext(ctx),
  16. ctx: ctx,
  17. svcCtx: svcCtx,
  18. }
  19. }
  20. func (l *ObtainShuntLogic) ObtainShunt(req *types.ShuntReq) (*types.CommonRes, error) {
  21. // todo: add your logic here and delete this line
  22. data := map[string]interface{}{}
  23. /* if C.IsShunt {
  24. data["isShunt"] = C.IsShunt
  25. //计算概率,获取分流途径
  26. shunt := "智齿"
  27. if rand.New(rand.NewSource(time.Now().UnixNano())).Int63n(100) <= C.ShuntProbability {
  28. shunt = "智齿"
  29. } else {
  30. shunt = "剑鱼"
  31. }
  32. if shunt == "智齿" {
  33. if req.Type == "PC" {
  34. data["url"] = C.ZhiCiUrl.Pc
  35. } else if req.Type == "APP" {
  36. data["url"] = C.ZhiCiUrl.App
  37. } else {
  38. data["url"] = C.ZhiCiUrl.Wx
  39. }
  40. } else {
  41. if req.Type == "PC" {
  42. data["url"] = C.MessageUrl.Pc
  43. } else if req.Type == "APP" {
  44. data["url"] = C.MessageUrl.App
  45. } else {
  46. data["url"] = C.MessageUrl.Wx
  47. }
  48. }
  49. } else {
  50. data["isShunt"] = C.IsShunt
  51. if req.Type == "PC" {
  52. data["url"] = C.ZhiCiUrl.Pc
  53. } else if req.Type == "App" {
  54. data["url"] = C.ZhiCiUrl.App
  55. } else {
  56. data["url"] = C.ZhiCiUrl.Wx
  57. }
  58. }*/
  59. return &types.CommonRes{
  60. Data: data,
  61. }, nil
  62. }