transfer_rs/cmd/api/internal/logic/transfer/marketLogic.go

55 lines
1.1 KiB
Go
Raw Normal View History

2024-06-18 18:14:57 +08:00
package transfer
import (
"context"
"rs/rpc/transfer"
"github.com/jinzhu/copier"
"github.com/zeromicro/go-zero/core/logx"
"rs/cmd/api/internal/svc"
"rs/cmd/api/internal/types"
)
type MarketLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
// 荣数立减金发放
func NewMarketLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MarketLogic {
return &MarketLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *MarketLogic) Market(req *types.Req) (resp *types.Resp, err error) {
var (
reqData transfer.RsCouponGrantReq
res types.Resp
)
prefix := req.Data.VoucherTag[0:6]
prefixData, err := l.svcCtx.ProductRedirectConf.FindOneByProductNoPrefix(l.ctx, prefix)
if err != nil {
return nil, err
}
_ = copier.Copy(&reqData, &req)
if prefixData == nil {
result, _err := l.svcCtx.TransferRpc.RsCouponGrant(l.ctx, &reqData)
if _err != nil {
return nil, err
}
_ = copier.Copy(&res, &result)
} else {
result, _err := l.svcCtx.TransferRpc.ZltxRsMiXue(l.ctx, &reqData)
if _err != nil {
return nil, err
}
_ = copier.Copy(&res, &result)
}
return &res, nil
}