userlotterychecklogic.go 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. package logic
  2. import (
  3. "app.yhyue.com/moapp/jyMarketing/rpc/activity"
  4. "context"
  5. "app.yhyue.com/moapp/jyMarketing/api/internal/svc"
  6. "app.yhyue.com/moapp/jyMarketing/api/internal/types"
  7. "github.com/tal-tech/go-zero/core/logx"
  8. )
  9. type UserLotteryCheckLogic struct {
  10. logx.Logger
  11. ctx context.Context
  12. svcCtx *svc.ServiceContext
  13. }
  14. func NewUserLotteryCheckLogic(ctx context.Context, svcCtx *svc.ServiceContext) UserLotteryCheckLogic {
  15. return UserLotteryCheckLogic{
  16. Logger: logx.WithContext(ctx),
  17. ctx: ctx,
  18. svcCtx: svcCtx,
  19. }
  20. }
  21. func (l *UserLotteryCheckLogic) UserLotteryCheck(req types.Request) (*types.ActivityLotteryResp, error) {
  22. // todo: add your logic here and delete this line
  23. result := &types.ActivityLotteryResp{}
  24. lsi := l.svcCtx.Activity
  25. resp, err := lsi.UserLottery(l.ctx, &activity.Request{
  26. UserId: req.UserId,
  27. AppId: req.AppId,
  28. Model: req.Model,
  29. UserLottertId: req.UserLottertId,
  30. })
  31. if err != nil {
  32. return nil, err
  33. }
  34. var userLotteryList []*types.LotteryJson
  35. for _, value := range resp.Data {
  36. userLottery := types.LotteryJson{}
  37. userLottery.Reduce = value.Reduce
  38. userLottery.Full = value.Full
  39. userLottery.LotteryId = value.LotteryId
  40. userLottery.LotteryName = value.LotteryName
  41. for _, value := range value.UseProductList {
  42. productJson:=types.ProductJson{}
  43. productJson.AppPage = value.AppPage
  44. productJson.ProductName = value.ProductName
  45. productJson.WxPage = value.WxPage
  46. productJson.PcPage = value.PcPage
  47. productJson.ProductCode=value.ProductCode
  48. productJson.ParentCode=value.ParentCode
  49. userLottery.UseProductList=append(userLottery.UseProductList,productJson)
  50. }
  51. //userLottery.UseProductList = value.UseProductList
  52. userLottery.LotteryType=value.LotteryType
  53. userLottery.PrizeType=value.PrizeType
  54. userLottery.UserLotteryId = value.UserLotteryId
  55. userLottery.UseDate = value.UseDate
  56. userLottery.Instructions=value.Instructions
  57. userLottery.Remark=value.Remark
  58. userLottery.LotteryId=value.LotteryId
  59. userLotteryList = append(userLotteryList, &userLottery)
  60. }
  61. result.Code = resp.Code
  62. result.Message = resp.Message
  63. result.Data = userLotteryList
  64. result.Count=resp.Count
  65. return result, nil
  66. }