lotteryreceivechecklogic.go 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package logic
  2. import (
  3. "app.yhyue.com/moapp/jyMarketing/rpc/activity"
  4. "context"
  5. "strconv"
  6. "strings"
  7. "app.yhyue.com/moapp/jyMarketing/api/internal/svc"
  8. "app.yhyue.com/moapp/jyMarketing/api/internal/types"
  9. "github.com/tal-tech/go-zero/core/logx"
  10. )
  11. type LotteryReceiveCheckLogic struct {
  12. logx.Logger
  13. ctx context.Context
  14. svcCtx *svc.ServiceContext
  15. }
  16. func NewLotteryReceiveCheckLogic(ctx context.Context, svcCtx *svc.ServiceContext) LotteryReceiveCheckLogic {
  17. return LotteryReceiveCheckLogic{
  18. Logger: logx.WithContext(ctx),
  19. ctx: ctx,
  20. svcCtx: svcCtx,
  21. }
  22. }
  23. func (l *LotteryReceiveCheckLogic) LotteryReceiveCheck(req types.LotteryOperation) (*types.Response, error) {
  24. result := &types.Response{}
  25. lsi := l.svcCtx.Activity
  26. var arr []int64
  27. lotteryIdArr := strings.Split(req.LotteryIdArr, ",")
  28. for _, value := range lotteryIdArr {
  29. valueInt, _ := strconv.ParseInt(value, 10, 64)
  30. arr = append(arr, valueInt)
  31. }
  32. resp, err := lsi.LotteryReceive(l.ctx, &activity.LotteryOperation{
  33. UserId: req.UserId,
  34. AppId: req.AppId,
  35. LotteryIdArr: arr,
  36. UserName:req.UserName,
  37. })
  38. if err != nil {
  39. return nil, err
  40. }
  41. result.Code = resp.Code
  42. result.Message = resp.Message
  43. return result, nil
  44. }