goodsspecupdlogic.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 GoodsSpecUpdLogic struct {
  12. logx.Logger
  13. ctx context.Context
  14. svcCtx *svc.ServiceContext
  15. }
  16. func NewGoodsSpecUpdLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GoodsSpecUpdLogic {
  17. return &GoodsSpecUpdLogic{
  18. Logger: logx.WithContext(ctx),
  19. ctx: ctx,
  20. svcCtx: svcCtx,
  21. }
  22. }
  23. func (l *GoodsSpecUpdLogic) GoodsSpecUpd(req *types.GoodsSpecUpdReq) (resp *types.Reply, err error) {
  24. // todo: add your logic here and delete this line
  25. resp = &types.Reply{}
  26. goodsResp, err := service.GoodsCenterRpc.GoodsSpecUpd(l.ctx, &pb.GoodsSpecAddReq{
  27. GoodsSpec: &pb.GoodsSpec{
  28. Id: req.Id,
  29. Appid: req.AppId,
  30. Name: req.Name,
  31. GoodsCode: req.Goods_code,
  32. OriginPrice: req.Origin_price,
  33. SkuMax: req.Sku_max,
  34. CalculationType: req.Calculation_type,
  35. CalculationMode: req.Calculation_mode,
  36. CalculationFormula: req.Calculation_formula,
  37. Tag: req.Tag,
  38. Remark: req.Remark,
  39. ActualPrice: req.Actual_price,
  40. },
  41. })
  42. if goodsResp.ErrorMsg != "" {
  43. resp.Error_msg = goodsResp.ErrorMsg
  44. resp.Error_code = -1
  45. l.Error(fmt.Sprintf("%+v", req), resp.Error_msg)
  46. }
  47. resp.Data = map[string]interface{}{
  48. "status": goodsResp.Status,
  49. }
  50. return
  51. }