goodsspecgetlogic.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package logic
  2. import (
  3. "context"
  4. "fmt"
  5. "bp.jydev.jianyu360.cn/BaseService/goodsCenter/rpc/pb"
  6. "bp.jydev.jianyu360.cn/BaseService/goodsCenter/public/service"
  7. "bp.jydev.jianyu360.cn/BaseService/goodsCenter/api/internal/svc"
  8. "bp.jydev.jianyu360.cn/BaseService/goodsCenter/api/internal/types"
  9. "github.com/zeromicro/go-zero/core/logx"
  10. )
  11. type GoodsSpecGetLogic struct {
  12. logx.Logger
  13. ctx context.Context
  14. svcCtx *svc.ServiceContext
  15. }
  16. func NewGoodsSpecGetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GoodsSpecGetLogic {
  17. return &GoodsSpecGetLogic{
  18. Logger: logx.WithContext(ctx),
  19. ctx: ctx,
  20. svcCtx: svcCtx,
  21. }
  22. }
  23. func (l *GoodsSpecGetLogic) GoodsSpecGet(req *types.GoodSpecIdReq) (resp *types.Reply, err error) {
  24. // todo: add your logic here and delete this line
  25. resp = &types.Reply{}
  26. goodsResp, err := service.GoodsCenterRpc.GoodsSpecGet(l.ctx, &pb.GoodsSpecGetReq{
  27. Appid: req.AppId,
  28. SpecId: req.Spec_id,
  29. })
  30. if goodsResp.ErrorMsg != "" {
  31. resp.Error_msg = goodsResp.ErrorMsg
  32. resp.Error_code = -1
  33. l.Error(fmt.Sprintf("%+v", req), resp.Error_msg)
  34. } else {
  35. resp.Data = &types.GoodsSpec{
  36. AppId: goodsResp.Appid,
  37. Name: goodsResp.Name,
  38. Goods_code: goodsResp.GoodsCode,
  39. Origin_price: goodsResp.OriginPrice,
  40. Sku_max: goodsResp.SkuMax,
  41. Calculation_type: goodsResp.CalculationType,
  42. Calculation_mode: goodsResp.CalculationMode,
  43. Calculation_formula: goodsResp.CalculationFormula,
  44. Tag: goodsResp.Tag,
  45. Remark: goodsResp.Remark,
  46. Actual_price: goodsResp.ActualPrice,
  47. }
  48. }
  49. return
  50. }