buyserviceslogic.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. package logic
  2. import (
  3. "context"
  4. "fmt"
  5. "bp.jydev.jianyu360.cn/ApplicationCenter/threeMarket/public/entity"
  6. "bp.jydev.jianyu360.cn/ApplicationCenter/threeMarket/rpc/internal/svc"
  7. "bp.jydev.jianyu360.cn/ApplicationCenter/threeMarket/rpc/pb"
  8. "github.com/zeromicro/go-zero/core/logx"
  9. )
  10. type BuyServicesLogic struct {
  11. ctx context.Context
  12. svcCtx *svc.ServiceContext
  13. logx.Logger
  14. }
  15. func NewBuyServicesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *BuyServicesLogic {
  16. return &BuyServicesLogic{
  17. ctx: ctx,
  18. svcCtx: svcCtx,
  19. Logger: logx.WithContext(ctx),
  20. }
  21. }
  22. // 购买服务
  23. func (l *BuyServicesLogic) BuyServices(in *pb.BuyServicesReq) (*pb.BuyServicesResp, error) {
  24. // todo: add your logic here and delete this line
  25. resp := &pb.BuyServicesResp{}
  26. tripartite_market_service := &entity.Tripartite_market_service_struct{
  27. Appid: in.Appid,
  28. Business_id: in.BusinessId,
  29. Goods_code: in.GoodsCode,
  30. Content: in.Need,
  31. Piece: in.Num,
  32. Phone: in.Phone,
  33. User_id: in.BaseUserId,
  34. }
  35. status, service_id, err := tripartite_market_service.Add()
  36. if err != nil {
  37. l.Error(fmt.Sprintf("%+v", in), err.Error())
  38. resp.ErrorMsg = err.Error()
  39. resp.ErrorCode = -1
  40. } else {
  41. resp.ServiceId = service_id
  42. }
  43. resp.Status = status
  44. return resp, nil
  45. }