goodsspecpoweraddlogic.go 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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 GoodsSpecPowerAddLogic struct {
  12. logx.Logger
  13. ctx context.Context
  14. svcCtx *svc.ServiceContext
  15. }
  16. func NewGoodsSpecPowerAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GoodsSpecPowerAddLogic {
  17. return &GoodsSpecPowerAddLogic{
  18. Logger: logx.WithContext(ctx),
  19. ctx: ctx,
  20. svcCtx: svcCtx,
  21. }
  22. }
  23. func (l *GoodsSpecPowerAddLogic) GoodsSpecPowerAdd(req *types.GoodsSpecPowerAddReq) (resp *types.Reply, err error) {
  24. // todo: add your logic here and delete this line
  25. resp = &types.Reply{}
  26. goodsResp, err := service.GoodsCenterRpc.GoodsSpecPowerAdd(l.ctx, &pb.GoodsSpecPowerAddReq{
  27. Appid: req.Appid,
  28. GoodsFunctionId: req.Goods_function_id,
  29. GoodsCode: req.Goods_code,
  30. SpecId: req.Spec_id,
  31. FunctionCode: req.Function_code,
  32. LimitStrategy: req.Limit_strategy,
  33. Cycle: req.Cycle,
  34. StrategyCount: req.Strategy_count,
  35. MaxNum: req.Max_num,
  36. UseCount: req.Use_count,
  37. PowerType: req.Power_type,
  38. CountType: req.Count_type,
  39. PowerCount: req.Power_count,
  40. JudgeRepeatMechanism: req.Judge_repeat_mechanism,
  41. JudgeRepeatScope: req.Judge_repeat_scope,
  42. JudgeRepeatFlag: req.Judge_repeat_flag,
  43. JudgeRepeatStrategy: req.Judge_repeat_strategy,
  44. })
  45. if goodsResp.ErrorMsg != "" {
  46. resp.Error_msg = goodsResp.ErrorMsg
  47. resp.Error_code = -1
  48. l.Error(fmt.Sprintf("%+v", req), resp.Error_msg)
  49. }
  50. resp.Data = map[string]interface{}{
  51. "status": goodsResp.Status,
  52. }
  53. return
  54. }