appointmentaddlogic.go 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. Data: map[string]interface{}{
  27. "status": -1,
  28. },
  29. }
  30. marketingResp, err := service.MarketingRpc.AppointmentAdd(l.ctx, &pb.AppointmentAddReq{
  31. AppId: req.AppId,
  32. UserId: req.UserId,
  33. UseProductType: req.UseProductType,
  34. ProductId: req.ProductId,
  35. })
  36. if err != nil || marketingResp == nil {
  37. l.Error(fmt.Sprintf("%+v", req), resp.Error_msg)
  38. resp.Error_code, resp.Error_msg = -1, "预约失败"
  39. return
  40. }
  41. if marketingResp.ErrorMsg != "" {
  42. resp.Error_msg = marketingResp.ErrorMsg
  43. resp.Error_code = -1
  44. l.Error(fmt.Sprintf("%+v", req), resp.Error_msg)
  45. }
  46. resp.Data = map[string]interface{}{
  47. "status": marketingResp.Status,
  48. }
  49. return
  50. }