39 lines
1.1 KiB
Go
39 lines
1.1 KiB
Go
package walletservicelogic
|
|
|
|
import (
|
|
"context"
|
|
|
|
"tianyuan-api/apps/user/internal/svc"
|
|
"tianyuan-api/apps/user/user"
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
)
|
|
|
|
type GetDeductionByTransactionIdLogic struct {
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
logx.Logger
|
|
}
|
|
|
|
func NewGetDeductionByTransactionIdLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetDeductionByTransactionIdLogic {
|
|
return &GetDeductionByTransactionIdLogic{
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
Logger: logx.WithContext(ctx),
|
|
}
|
|
}
|
|
|
|
func (l *GetDeductionByTransactionIdLogic) GetDeductionByTransactionId(in *user.GetDeductionByTransactionIdRequest) (*user.GetDeductionByTransactionIdResponse, error) {
|
|
deduction, err := l.svcCtx.DeductionsModel.FindOneByTransactionId(l.ctx, in.TransactionId)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &user.GetDeductionByTransactionIdResponse{
|
|
Id: deduction.Id,
|
|
UserId: deduction.UserId,
|
|
Amount: deduction.Amount,
|
|
TransactionId: deduction.TransactionId,
|
|
CreatedAt: deduction.CreatedAt.Format("2006-01-02 15:04:05"),
|
|
}, nil
|
|
}
|