lotteryinfochecklogic.go 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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/zeromicro/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. ActivityType: req.ActivityType,
  29. })
  30. if err != nil {
  31. return nil, err
  32. }
  33. data := resp.Data
  34. var userLottery types.LotteryJson
  35. userLottery.Full = data.Full
  36. userLottery.Reduce = data.Reduce
  37. userLottery.LotteryBeginDate = data.LotteryBeginDate
  38. userLottery.LotteryendDate = data.LotteryendDate
  39. userLottery.LotteryName = data.LotteryName
  40. for _, value := range data.UseProductList {
  41. productJson := types.ProductJson{}
  42. productJson.AppPage = value.AppPage
  43. productJson.ProductName = value.ProductName
  44. productJson.WxPage = value.WxPage
  45. productJson.PcPage = value.PcPage
  46. productJson.ProductCode = value.ProductCode
  47. productJson.ParentCode = value.ParentCode
  48. productJson.Describe = value.Describe
  49. userLottery.UseProductList = append(userLottery.UseProductList, productJson)
  50. }
  51. userLottery.UserLotteryId = data.UserLotteryId
  52. userLottery.Instructions = data.Instructions
  53. userLottery.Remark = data.Remark
  54. userLottery.LotteryType = data.LotteryType
  55. userLottery.LotteryId = data.LotteryId
  56. userLottery.UseDate = data.UseDate
  57. userLottery.Discount = data.Discount
  58. userLottery.PromotionalPrice = data.PromotionalPrice
  59. userLottery.GiftCode = data.GiftCode
  60. result.Code = resp.Code
  61. result.Message = resp.Message
  62. result.Data = userLottery
  63. return result, nil
  64. }