activityinfologic.go 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. package logic
  2. import (
  3. "context"
  4. "fmt"
  5. "bp.jydev.jianyu360.cn/ApplicationCenter/marketing/api/internal/svc"
  6. "bp.jydev.jianyu360.cn/ApplicationCenter/marketing/api/internal/types"
  7. "bp.jydev.jianyu360.cn/ApplicationCenter/marketing/public/service"
  8. "bp.jydev.jianyu360.cn/ApplicationCenter/marketing/rpc/pb"
  9. "github.com/zeromicro/go-zero/core/logx"
  10. )
  11. type ActivityInfoLogic struct {
  12. logx.Logger
  13. ctx context.Context
  14. svcCtx *svc.ServiceContext
  15. }
  16. func NewActivityInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ActivityInfoLogic {
  17. return &ActivityInfoLogic{
  18. Logger: logx.WithContext(ctx),
  19. ctx: ctx,
  20. svcCtx: svcCtx,
  21. }
  22. }
  23. func (l *ActivityInfoLogic) ActivityInfo(req *types.AppointmentAddReq) (resp *types.Reply, err error) {
  24. // todo: add your logic here and delete this line
  25. resp = &types.Reply{}
  26. marketingResp, err := service.MarketingRpc.AppointmentInfo(l.ctx, &pb.AppointmentInfoReq{
  27. AppId: req.AppId,
  28. UserId: req.UserId,
  29. ProductId: req.ProductId,
  30. UseProductType: req.UseProductType,
  31. })
  32. if err != nil {
  33. l.Error(fmt.Sprintf("%+v", req), resp.Error_msg)
  34. resp.Data = map[string]interface{}{
  35. "status": -1,
  36. }
  37. resp.Error_code, resp.Error_msg = -1, "预约失败"
  38. }
  39. if marketingResp.ErrorMsg != "" {
  40. resp.Error_msg = marketingResp.ErrorMsg
  41. resp.Error_code = -1
  42. resp.Data = nil
  43. l.Error(fmt.Sprintf("%+v", req), resp.Error_msg)
  44. } else {
  45. resp.Data = map[string]interface{}{
  46. "activityName": marketingResp.ActivityName,
  47. "activityId": marketingResp.ActivityId,
  48. "activityType": marketingResp.ActivityType,
  49. "startTime": marketingResp.StartTime,
  50. "endTime": marketingResp.EndTime,
  51. "preStartTime": marketingResp.PreheatStartTime,
  52. "stockNumber": marketingResp.StockNumber,
  53. "isAppointment": marketingResp.PreheatStatus,
  54. }
  55. }
  56. return
  57. }