hotfix: wallet deducting logic
This commit is contained in:
parent
065e66e820
commit
797cba4920
|
|
@ -35,7 +35,7 @@ var (
|
|||
ErrGenerateRandomOutcome = errors.New("failed to generate any random outcome for events")
|
||||
ErrOutcomesNotCompleted = errors.New("some bet outcomes are still pending")
|
||||
ErrEventHasBeenRemoved = errors.New("event has been removed")
|
||||
ErrEventHasBeenDisabled = errors.New("event has been disabled")
|
||||
ErrEventHasBeenDisabled = errors.New("event has been disabled")
|
||||
|
||||
ErrEventHasNotEnded = errors.New("event has not ended yet")
|
||||
ErrOddHasBeenDisabled = errors.New("odd has been disabled")
|
||||
|
|
@ -555,34 +555,50 @@ func (s *Service) DeductBetFromBranchWallet(ctx context.Context, amount float32,
|
|||
return ErrCompanyDeductedPercentInvalid
|
||||
}
|
||||
|
||||
// This is the amount that we take from a company/tenant when they
|
||||
// create a bet. I.e. if its 5% (0.05), then thats the percentage we take every
|
||||
deductedAmount := amount * company.DeductedPercentage
|
||||
|
||||
if deductedAmount == 0 {
|
||||
s.mongoLogger.Fatal("Amount",
|
||||
zap.Int64("wallet_id", walletID),
|
||||
zap.Float32("amount", deductedAmount),
|
||||
zap.Error(err),
|
||||
)
|
||||
return err
|
||||
}
|
||||
_, err = s.walletSvc.DeductFromWallet(ctx,
|
||||
walletID, domain.ToCurrency(deductedAmount), domain.ValidInt64{
|
||||
walletID, domain.ToCurrency(amount), domain.ValidInt64{
|
||||
Value: userID,
|
||||
Valid: true,
|
||||
}, domain.TRANSFER_DIRECT,
|
||||
fmt.Sprintf("Deducted %v amount from wallet by system while placing bet", deductedAmount))
|
||||
fmt.Sprintf("Deducted %v amount from wallet by system while placing bet", amount))
|
||||
|
||||
if err != nil {
|
||||
s.mongoLogger.Error("failed to deduct from wallet",
|
||||
zap.Int64("wallet_id", walletID),
|
||||
zap.Float32("amount", deductedAmount),
|
||||
zap.Float32("amount", amount),
|
||||
zap.Error(err),
|
||||
)
|
||||
return err
|
||||
}
|
||||
|
||||
// This is the amount that we take from a company/tenant when they
|
||||
// create a bet. I.e. if its 5% (0.05), then thats the percentage we take every
|
||||
// deductedAmount := amount * company.DeductedPercentage
|
||||
|
||||
// if deductedAmount == 0 {
|
||||
// s.mongoLogger.Fatal("Amount",
|
||||
// zap.Int64("wallet_id", walletID),
|
||||
// zap.Float32("amount", deductedAmount),
|
||||
// zap.Error(err),
|
||||
// )
|
||||
// return err
|
||||
// }
|
||||
// _, err = s.walletSvc.DeductFromWallet(ctx,
|
||||
// walletID, domain.ToCurrency(deductedAmount), domain.ValidInt64{
|
||||
// Value: userID,
|
||||
// Valid: true,
|
||||
// }, domain.TRANSFER_DIRECT,
|
||||
// fmt.Sprintf("Deducted %v amount from wallet by system while placing bet", deductedAmount))
|
||||
|
||||
// if err != nil {
|
||||
// s.mongoLogger.Error("failed to deduct from wallet",
|
||||
// zap.Int64("wallet_id", walletID),
|
||||
// zap.Float32("amount", deductedAmount),
|
||||
// zap.Error(err),
|
||||
// )
|
||||
// return err
|
||||
// }
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user