appointmentinfologic.go 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package logic
  2. import (
  3. "context"
  4. "fmt"
  5. "bp.jydev.jianyu360.cn/ApplicationCenter/marketing/public/entity"
  6. "bp.jydev.jianyu360.cn/ApplicationCenter/marketing/rpc/internal/svc"
  7. "bp.jydev.jianyu360.cn/ApplicationCenter/marketing/rpc/pb"
  8. "github.com/zeromicro/go-zero/core/logx"
  9. )
  10. type AppointmentInfoLogic struct {
  11. ctx context.Context
  12. svcCtx *svc.ServiceContext
  13. logx.Logger
  14. }
  15. func NewAppointmentInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AppointmentInfoLogic {
  16. return &AppointmentInfoLogic{
  17. ctx: ctx,
  18. svcCtx: svcCtx,
  19. Logger: logx.WithContext(ctx),
  20. }
  21. }
  22. // 预热信息
  23. func (l *AppointmentInfoLogic) AppointmentInfo(in *pb.AppointmentInfoReq) (*pb.AppointmentInfoResp, error) {
  24. // todo: add your logic here and delete this line
  25. resp := &pb.AppointmentInfoResp{}
  26. appointment := &entity.AppointmentStruct{
  27. Appid: in.AppId,
  28. UserId: in.UserId,
  29. ProductId: in.ProductId,
  30. UseProductType: in.UseProductType,
  31. }
  32. data, err := appointment.Info()
  33. if err != nil {
  34. l.Error(fmt.Sprintf("%+v", in), err.Error())
  35. resp.ErrorMsg = err.Error()
  36. resp.ErrorCode = -1
  37. } else {
  38. resp.ActivityId = data.ActivityId
  39. resp.ActivityName = data.ActivityName
  40. resp.ActivityType = data.ActivityType
  41. resp.StartTime = data.StartTime
  42. resp.EndTime = data.EndTime
  43. resp.PreheatStartTime = data.PreStartTime
  44. resp.PreheatEndTime = data.StartTime
  45. resp.PreheatStatus = data.IsAppointment
  46. resp.StockNumber = data.StockNumber
  47. }
  48. return resp, nil
  49. }