goodsspecgetlogic.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package logic
  2. import (
  3. "context"
  4. "fmt"
  5. "bp.jydev.jianyu360.cn/BaseService/goodsCenter/public/entity"
  6. "bp.jydev.jianyu360.cn/BaseService/goodsCenter/rpc/internal/svc"
  7. "bp.jydev.jianyu360.cn/BaseService/goodsCenter/rpc/pb"
  8. "github.com/zeromicro/go-zero/core/logx"
  9. )
  10. type GoodsSpecGetLogic struct {
  11. ctx context.Context
  12. svcCtx *svc.ServiceContext
  13. logx.Logger
  14. }
  15. func NewGoodsSpecGetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GoodsSpecGetLogic {
  16. return &GoodsSpecGetLogic{
  17. ctx: ctx,
  18. svcCtx: svcCtx,
  19. Logger: logx.WithContext(ctx),
  20. }
  21. }
  22. // 查看商品规格
  23. func (l *GoodsSpecGetLogic) GoodsSpecGet(in *pb.GoodsSpecGetReq) (*pb.GoodsSpecGetResp, error) {
  24. // todo: add your logic here and delete this line
  25. resp := &pb.GoodsSpecGetResp{}
  26. goods_spec := &entity.Base_goods_spec_struct{
  27. Appid: in.Appid,
  28. Id: in.SpecId,
  29. }
  30. goods_spec_detail, err := goods_spec.Get()
  31. if err != nil {
  32. l.Error(fmt.Sprintf("%+v", in), err.Error())
  33. resp.ErrorMsg = err.Error()
  34. resp.ErrorCode = -1
  35. }
  36. resp.SpecId = goods_spec_detail.Id
  37. resp.ActualPrice = goods_spec_detail.Actual_price
  38. resp.CalculationFormula = goods_spec_detail.Calculation_formula
  39. resp.CalculationMode = goods_spec_detail.Calculation_mode
  40. resp.CalculationType = goods_spec_detail.Calculation_mode
  41. resp.CreateTime = goods_spec_detail.Create_time
  42. resp.GoodsCode = goods_spec_detail.Goods_code
  43. resp.Name = goods_spec_detail.Name
  44. resp.OriginPrice = goods_spec_detail.Origin_price
  45. resp.Remark = goods_spec_detail.Remark
  46. resp.SkuMax = goods_spec_detail.Sku_max
  47. resp.Tag = goods_spec_detail.Tag
  48. resp.Appid = goods_spec_detail.Appid
  49. return resp, nil
  50. }