goodsspecpoweraddlogic.go 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 GoodsSpecPowerAddLogic struct {
  11. ctx context.Context
  12. svcCtx *svc.ServiceContext
  13. logx.Logger
  14. }
  15. func NewGoodsSpecPowerAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GoodsSpecPowerAddLogic {
  16. return &GoodsSpecPowerAddLogic{
  17. ctx: ctx,
  18. svcCtx: svcCtx,
  19. Logger: logx.WithContext(ctx),
  20. }
  21. }
  22. // 新增商品规格权益
  23. func (l *GoodsSpecPowerAddLogic) GoodsSpecPowerAdd(in *pb.GoodsSpecPowerAddReq) (*pb.StatusResp, error) {
  24. // todo: add your logic here and delete this line
  25. resp := &pb.StatusResp{}
  26. spec_power := &entity.Base_goods_spec_power_struct{
  27. Appid: in.Appid,
  28. Goods_function_id: in.GoodsFunctionId, //商品功能id
  29. Goods_code: in.GoodsCode, //商品代码
  30. Spec_id: in.SpecId, //规格id
  31. Function_code: in.FunctionCode, //功能代码
  32. Limit_strategy: in.LimitStrategy, //限制频率
  33. Cycle: in.Cycle, //周期
  34. Strategy_count: in.StrategyCount, //频率数量
  35. Max_num: in.MaxNum, //最大数量 不可修改,从原始表带过来
  36. Use_count: in.UseCount, //数量
  37. Power_type: in.PowerType, //权益所属类型 1:个人 2:企业
  38. Count_type: in.CountType, //数量类型 1:固定值 2:计算公式(生成权益时需要计算,比如:超级订阅送画像)
  39. Power_count: in.PowerCount, //授权数量
  40. Judge_repeat_mechanism: in.JudgeRepeatMechanism, //判重机制 0:无 1:通用判重 2:应用判重
  41. Judge_repeat_scope: in.JudgeRepeatScope, //判重范围
  42. Judge_repeat_flag: in.JudgeRepeatFlag, //判重标识 _id、projectid
  43. Judge_repeat_strategy: in.JudgeRepeatStrategy, //判重策略 0:无需判重 1:通用判重 2:应用自己判重
  44. }
  45. status, err := spec_power.Add()
  46. if err != nil {
  47. l.Error(fmt.Sprintf("%+v", in), err.Error())
  48. resp.ErrorMsg = err.Error()
  49. resp.ErrorCode = -1
  50. }
  51. resp.Status = status
  52. return resp, nil
  53. }