appointmentaddlogic.go 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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 AppointmentAddLogic struct {
  12. logx.Logger
  13. ctx context.Context
  14. svcCtx *svc.ServiceContext
  15. }
  16. func NewAppointmentAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AppointmentAddLogic {
  17. return &AppointmentAddLogic{
  18. Logger: logx.WithContext(ctx),
  19. ctx: ctx,
  20. svcCtx: svcCtx,
  21. }
  22. }
  23. func (l *AppointmentAddLogic) AppointmentAdd(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.AppointmentAdd(l.ctx, &pb.AppointmentAddReq{
  27. AppId: req.AppId,
  28. UserId: req.UserId,
  29. UseProductType: req.UseProductType,
  30. ProductId: req.ProductId,
  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. l.Error(fmt.Sprintf("%+v", req), resp.Error_msg)
  43. }
  44. resp.Data = map[string]interface{}{
  45. "status": marketingResp.Status,
  46. }
  47. return
  48. }