123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- package logic
- import (
- "context"
- "fmt"
- . "bp.jydev.jianyu360.cn/BaseService/resourceCenter/rpc/internal/entity"
- "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 PowerHandleLogic struct {
- ctx context.Context
- svcCtx *svc.ServiceContext
- logx.Logger
- }
- func NewPowerHandleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PowerHandleLogic {
- return &PowerHandleLogic{
- ctx: ctx,
- svcCtx: svcCtx,
- Logger: logx.WithContext(ctx),
- }
- }
- //开通或者取消权益
- func (l *PowerHandleLogic) PowerHandle(in *pb.PowerReq) (*pb.Resp, error) {
- l.Info("开通或者取消权益请求参数", fmt.Sprintf("%+v", in))
- resp := &pb.Resp{}
- if in.Appid == "" {
- l.Error(fmt.Sprintf("%+v", in), "无效的参数appid")
- return resp, nil
- } else if in.GoodsCode == "" {
- l.Error(fmt.Sprintf("%+v", in), "无效的参数goods_code")
- return resp, nil
- } else if in.UserId == 0 && in.EntId == 0 {
- l.Error(fmt.Sprintf("%+v", in), "无效的参数user_id、ent_id")
- return resp, nil
- } else if in.StartTime == "" {
- l.Error(fmt.Sprintf("%+v", in), "无效的参数start_time")
- return resp, nil
- } else if in.EndTime == "" {
- l.Error(fmt.Sprintf("%+v", in), "无效的参数end_time")
- return resp, nil
- } else if in.Type != 1 && in.Type != -1 {
- l.Error(fmt.Sprintf("%+v", in), "无效的参数type")
- return resp, nil
- }
- if in.Type == 1 { //开通
- list := Base_goods_function.FindByGoodsCode(in.Appid, in.GoodsCode)
- if list != nil {
- if Base_power.OpenPower(in.Appid, in.GoodsCode, in.UserId, in.EntId, in.StartTime, in.EndTime, in.UseCount, list) {
- return &pb.Resp{Status: 1}, nil
- }
- }
- } else if in.Type == -1 { //取消
- if Base_power.CancelPower(in.Appid, in.GoodsCode, in.UserId, in.EntId) {
- return &pb.Resp{Status: 1}, nil
- }
- }
- return &pb.Resp{}, nil
- }
|