package logic import ( "context" "fmt" . "bp.jydev.jianyu360.cn/BaseService/resourceCenter/public/service" "bp.jydev.jianyu360.cn/BaseService/resourceCenter/rpc/internal/svc" "bp.jydev.jianyu360.cn/BaseService/resourceCenter/rpc/pb" "github.com/zeromicro/go-zero/core/logx" ) type RechargeLogic struct { ctx context.Context svcCtx *svc.ServiceContext logx.Logger } func NewRechargeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RechargeLogic { return &RechargeLogic{ ctx: ctx, svcCtx: svcCtx, Logger: logx.WithContext(ctx), } } // 资源充值 func (l *RechargeLogic) Recharge(in *pb.RechargeReq) (*pb.Resp, error) { resp := &pb.Resp{} if in.Appid == "" { l.Error(fmt.Sprintf("%+v", in), "无效的参数appid") return resp, nil } else if in.FunctionCode == "" { l.Error(fmt.Sprintf("%+v", in), "无效的参数function_code") return resp, nil } else if in.Count <= 0 { l.Error(fmt.Sprintf("%+v", in), "无效的参数count") return resp, nil } else if in.UserId == 0 && in.EntId == 0 { l.Error(fmt.Sprintf("%+v", in), "无效的参数user_id、ent_id") return resp, nil } status, err := Deduction(in.Appid, in.FunctionCode, in.UserId, in.EntId, in.Count, in.Ids) if err != nil { l.Error(fmt.Sprintf("%+v", in), err) } resp.Status = status return resp, nil }