lotteryinfochecklogic.go 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 LotteryInfoCheckLogic struct {
  10. logx.Logger
  11. ctx context.Context
  12. svcCtx *svc.ServiceContext
  13. }
  14. func NewLotteryInfoCheckLogic(ctx context.Context, svcCtx *svc.ServiceContext) LotteryInfoCheckLogic {
  15. return LotteryInfoCheckLogic{
  16. Logger: logx.WithContext(ctx),
  17. ctx: ctx,
  18. svcCtx: svcCtx,
  19. }
  20. }
  21. func (l *LotteryInfoCheckLogic) LotteryInfoCheck(req types.Request) (*types.LotteryResp, error) {
  22. result := &types.LotteryResp{}
  23. lsi := l.svcCtx.Activity
  24. resp, err := lsi.LotteryInfo(l.ctx, &activity.Request{
  25. UserId: req.UserId,
  26. AppId: req.AppId,
  27. LotteryId: req.LotteryId,
  28. })
  29. if err != nil {
  30. return nil, err
  31. }
  32. data:=resp.Data
  33. var userLottery types.LotteryJson
  34. userLottery.Full = data.Full
  35. userLottery.Reduce = data.Reduce
  36. userLottery.LotteryBeginDate = data.LotteryBeginDate
  37. userLottery.LotteryendDate = data.LotteryendDate
  38. userLottery.LotteryName = data.LotteryName
  39. for _, value := range data.UseProductList {
  40. productJson:=types.ProductJson{}
  41. productJson.AppPage = value.AppPage
  42. productJson.ProductName = value.ProductName
  43. productJson.WxPage = value.WxPage
  44. productJson.PcPage = value.PcPage
  45. productJson.ProductCode=value.ProductCode
  46. productJson.ParentCode=value.ParentCode
  47. productJson.Describe=value.Describe
  48. userLottery.UseProductList=append(userLottery.UseProductList,productJson)
  49. }
  50. userLottery.UserLotteryId=data.UserLotteryId
  51. userLottery.Instructions = data.Instructions
  52. userLottery.Remark = data.Remark
  53. userLottery.LotteryType=data.LotteryType
  54. userLottery.LotteryId = data.LotteryId
  55. userLottery.UseDate = data.UseDate
  56. result.Code=resp.Code
  57. result.Message = resp.Message
  58. result.Data = userLottery
  59. return result, nil
  60. }