feat: implement Magic Wallet feature with charging and status display
Build and Deploy to Kubernetes / build-and-deploy (push) Failing after 6m25s
Build and Deploy to Kubernetes / build-and-deploy (push) Failing after 6m25s
This commit is contained in:
@@ -22,6 +22,7 @@ public static class RouteConstants
|
||||
public const string ChangePassword = "/profile/change-password";
|
||||
public const string Tree = "/profile/tree";
|
||||
public const string Wallet = "/profile/wallet";
|
||||
public const string MagicWallet = "/profile/magic-wallet";
|
||||
public const string WithdrawalRequests = "/profile/withdrawal-requests";
|
||||
}
|
||||
|
||||
|
||||
@@ -17,9 +17,9 @@ public class VATService
|
||||
private const string VAT_PERCENTAGE_KEY = "vat_percentage";
|
||||
private const string VAT_DATE_KEY = "vat_date";
|
||||
|
||||
// مقادیر پیشفرض
|
||||
private double _vatRate = 0.0999;
|
||||
private int _vatPercentage = 99;
|
||||
// مقادیر پیشفرض (10%)
|
||||
private double _vatRate = 0.10;
|
||||
private int _vatPercentage = 10;
|
||||
private bool _isEnabled = true;
|
||||
private bool _isLoaded = false;
|
||||
|
||||
|
||||
@@ -25,6 +25,16 @@ public enum WithdrawalMethodClient
|
||||
}
|
||||
public record WithdrawalSettings(long MinWithdrawalAmount);
|
||||
|
||||
public record MagicWalletStatus(
|
||||
int WalletMode,
|
||||
long MagicTotalDeposited,
|
||||
long MagicTotalCredited,
|
||||
long MagicMaxDeposit,
|
||||
long MagicRemainingDeposit,
|
||||
long Balance,
|
||||
DateTime? MagicActivatedAt
|
||||
);
|
||||
|
||||
public class WalletService
|
||||
{
|
||||
private readonly CMSMicroservice.Protobuf.Protos.UserWallet.UserWalletContract.UserWalletContractClient _client;
|
||||
@@ -183,4 +193,64 @@ public class WalletService
|
||||
return new WithdrawalSettings(0);
|
||||
}
|
||||
}
|
||||
|
||||
// ============= Magic Wallet =============
|
||||
|
||||
public async Task<MagicWalletStatus> GetMagicWalletStatusAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
var response = await _client.GetMagicWalletStatusAsync(new Empty());
|
||||
DateTime? activatedAt = response.MagicActivatedAt != null
|
||||
? response.MagicActivatedAt.ToDateTime().ToLocalTime()
|
||||
: null;
|
||||
|
||||
return new MagicWalletStatus(
|
||||
response.WalletMode,
|
||||
response.MagicTotalDeposited,
|
||||
response.MagicTotalCredited,
|
||||
response.MagicMaxDeposit,
|
||||
response.MagicRemainingDeposit,
|
||||
response.Balance,
|
||||
activatedAt
|
||||
);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return new MagicWalletStatus(0, 0, 0, 0, 0, 0, null);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<(bool Success, string? GatewayUrl, string? Error)> InitiateMagicChargeAsync(long amount)
|
||||
{
|
||||
try
|
||||
{
|
||||
var response = await _client.InitiateMagicChargeAsync(new InitiateMagicChargeRequest
|
||||
{
|
||||
Amount = amount
|
||||
});
|
||||
|
||||
if (response.IsSuccess)
|
||||
return (true, response.GatewayUrl, null);
|
||||
|
||||
return (false, null, response.ErrorMessage);
|
||||
}
|
||||
catch (Grpc.Core.RpcException ex)
|
||||
{
|
||||
return (false, null, ex.Status.Detail ?? "خطا در ارتباط با سرور");
|
||||
}
|
||||
}
|
||||
|
||||
public int GetWalletMode()
|
||||
{
|
||||
try
|
||||
{
|
||||
var response = _client.GetCustomerWallet(new Empty());
|
||||
return response.WalletMode;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user