getalllotterylogic.go 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. package logic
  2. import (
  3. "app.yhyue.com/moapp/jyMarketing/rpc/activity"
  4. "app.yhyue.com/moapp/jyMarketing/rpc/internal/svc"
  5. "context"
  6. "github.com/zeromicro/go-zero/core/logx"
  7. )
  8. type GetAllLotteryLogic struct {
  9. ctx context.Context
  10. svcCtx *svc.ServiceContext
  11. logx.Logger
  12. }
  13. func NewGetAllLotteryLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetAllLotteryLogic {
  14. return &GetAllLotteryLogic{
  15. ctx: ctx,
  16. svcCtx: svcCtx,
  17. Logger: logx.WithContext(ctx),
  18. }
  19. }
  20. // 商品下所有奖券获取
  21. func (l *GetAllLotteryLogic) GetAllLottery(in *activity.Request) (*activity.ActivityResp, error) {
  22. result := &activity.ActivityResp{}
  23. code, msg, activityData := activityServiceNew.GetAllLottery(in)
  24. var activityArr []*activity.ActivityJson
  25. for _, activityValue := range activityData {
  26. activityEntity := activity.ActivityJson{}
  27. var lotteryList []*activity.LotteryJson
  28. for _, value := range activityValue.LotteryData {
  29. lottery := activity.LotteryJson{}
  30. lottery.PromotionalPrice = value.PromotionalPrice
  31. lottery.Full = value.Full
  32. lottery.Reduce = value.Reduce
  33. lottery.Discount = float32(value.Discount)
  34. lottery.LotteryType = value.LotteryType
  35. for _, value := range value.UseProductList {
  36. productJson := activity.ProductJson{}
  37. productJson.AppPage = value.AppPage
  38. productJson.ProductName = value.ProductName
  39. productJson.WxPage = value.WxPage
  40. productJson.PcPage = value.PcPage
  41. productJson.ProductCode = value.ProductCode
  42. productJson.ParentCode = value.ParentCode
  43. productJson.Describe = value.Describe
  44. lottery.UseProductList = append(lottery.UseProductList, &productJson)
  45. }
  46. lotteryList = append(lotteryList, &lottery)
  47. activityEntity.LotteryJson = lotteryList
  48. }
  49. activityArr = append(activityArr, &activityEntity)
  50. }
  51. result.Code = code
  52. result.Message = msg
  53. result.ActivityJson = activityArr
  54. return result, nil
  55. }