userlotterylogic.go 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. package logic
  2. import (
  3. "context"
  4. "fmt"
  5. "app.yhyue.com/moapp/jyMarketing/rpc/activity"
  6. "app.yhyue.com/moapp/jyMarketing/rpc/internal/svc"
  7. "github.com/tal-tech/go-zero/core/logx"
  8. )
  9. type UserLotteryLogic struct {
  10. ctx context.Context
  11. svcCtx *svc.ServiceContext
  12. logx.Logger
  13. }
  14. func NewUserLotteryLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserLotteryLogic {
  15. return &UserLotteryLogic{
  16. ctx: ctx,
  17. svcCtx: svcCtx,
  18. Logger: logx.WithContext(ctx),
  19. }
  20. }
  21. // 用户可用的奖券
  22. func (l *UserLotteryLogic) UserLottery(in *activity.Request) (*activity.ActivityLotteryResp, error) {
  23. // todo: add your logic here and delete this line
  24. result := &activity.ActivityLotteryResp{}
  25. code, msg, data,count := activityService.UserLottery(in)
  26. var userLotteryList []*activity.LotteryJson
  27. for _, value := range data {
  28. userLottery := activity.LotteryJson{}
  29. userLottery.Full = value.Full
  30. userLottery.Reduce=value.Reduce
  31. userLottery.LotteryBeginDate = value.BeginDate
  32. userLottery.LotteryendDate = value.EndDate
  33. userLottery.LotteryName = value.Name
  34. //userLottery.UseProductList = value.UseProductList
  35. userLottery.UserLotteryId=value.Id
  36. userLottery.Instructions=value.Instructions
  37. userLottery.Remark=value.Remark
  38. userLottery.LotteryId=value.LotteryId
  39. userLottery.UseDate=value.UseDate.Format("2006-01-02 15:04:05")
  40. userLottery.CreateTime=value.CreateTime.Format("2006-01-02 15:04:05")
  41. userLotteryList = append(userLotteryList, &userLottery)
  42. }
  43. fmt.Println(count)
  44. result.Code = code
  45. result.Message = msg
  46. result.Count=count
  47. result.Data = userLotteryList
  48. return result, nil
  49. }