lotteryinfochecklogic.go 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. userLottery.UseProductList=append(userLottery.UseProductList,productJson)
  48. }
  49. userLottery.Instructions = data.Instructions
  50. userLottery.Remark = data.Remark
  51. userLottery.LotteryType=data.LotteryType
  52. userLottery.LotteryId = data.LotteryId
  53. userLottery.UseDate = data.UseDate
  54. result.Code=resp.Code
  55. result.Message = resp.Message
  56. result.Data = userLottery
  57. return result, nil
  58. }