feat: Add gRPC clients and services for Club, Commission, Network, and Discount functionalities
This commit is contained in:
@@ -28,8 +28,7 @@ public class WalletService
|
||||
try
|
||||
{
|
||||
var response = await _client.GetUserWalletAsync(new Empty());
|
||||
// TODO: DiscountBalance will be added in BFF protobuf later
|
||||
return new WalletBalances(response.Balance, 0 /* response.DiscountBalance */, response.NetworkBalance);
|
||||
return new WalletBalances(response.Balance, response.DiscountBalance, response.NetworkBalance);
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -40,9 +39,6 @@ public class WalletService
|
||||
|
||||
public async Task<List<WalletTransaction>> GetTransactionsAsync(long? referenceId = null, bool? isIncrease = null)
|
||||
{
|
||||
// TODO: Implement when BFF protobuf has GetAllUserWalletChangeLog
|
||||
await Task.CompletedTask;
|
||||
/*
|
||||
try
|
||||
{
|
||||
var request = new GetAllUserWalletChangeLogRequest();
|
||||
@@ -66,7 +62,6 @@ public class WalletService
|
||||
}
|
||||
catch
|
||||
{
|
||||
*/
|
||||
// Fallback to mock data if backend is unavailable
|
||||
var _transactions = new List<WalletTransaction>
|
||||
{
|
||||
@@ -76,7 +71,7 @@ public class WalletService
|
||||
new(DateTime.Now.AddDays(-9).ToString(), 900_000, "کیف پول شرکای تجاری", "اعتبار خرید"),
|
||||
};
|
||||
return _transactions.OrderByDescending(t => t.Date).ToList();
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
private static string ResolveTransactionDate(GetAllUserWalletChangeLogResponseModel model)
|
||||
@@ -105,10 +100,6 @@ public class WalletService
|
||||
|
||||
public async Task<bool> RequestWithdrawalAsync(long payoutId, WithdrawalMethodClient method, string? iban)
|
||||
{
|
||||
// TODO: Implement when BFF protobuf has WithdrawBalance
|
||||
await Task.CompletedTask;
|
||||
return true;
|
||||
/*
|
||||
var request = new WithdrawBalanceRequest
|
||||
{
|
||||
PayoutId = payoutId,
|
||||
@@ -125,44 +116,48 @@ public class WalletService
|
||||
}
|
||||
catch (Grpc.Core.RpcException ex)
|
||||
{
|
||||
// surface backend error text
|
||||
throw new InvalidOperationException(ex.Status.Detail ?? "خطا در ثبت برداشت", ex);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
public async Task<List<WalletWithdrawal>> GetWithdrawalsAsync(int? status = null)
|
||||
{
|
||||
// TODO: Implement when BFF protobuf has GetUserWithdrawals
|
||||
await Task.CompletedTask;
|
||||
return new List<WalletWithdrawal>();
|
||||
/*
|
||||
var request = new GetUserWithdrawalsRequest();
|
||||
if (status.HasValue)
|
||||
try
|
||||
{
|
||||
request.Status = status.Value;
|
||||
}
|
||||
var request = new GetUserWithdrawalsRequest();
|
||||
if (status.HasValue)
|
||||
{
|
||||
request.Status = status.Value;
|
||||
}
|
||||
|
||||
var response = await _client.GetUserWithdrawalsAsync(request);
|
||||
return response.Models
|
||||
.Select(m => new WalletWithdrawal(
|
||||
m.Id,
|
||||
m.WeekNumber,
|
||||
m.TotalAmount,
|
||||
m.Status,
|
||||
m.WithdrawalMethod?.Value,
|
||||
m.IbanNumber,
|
||||
m.Created.ToDateTime().MiladiToJalaliWithTime()))
|
||||
.ToList();
|
||||
*/
|
||||
var response = await _client.GetUserWithdrawalsAsync(request);
|
||||
return response.Models
|
||||
.Select(m => new WalletWithdrawal(
|
||||
m.Id,
|
||||
m.WeekNumber,
|
||||
m.TotalAmount,
|
||||
m.Status,
|
||||
m.WithdrawalMethod,
|
||||
m.IbanNumber,
|
||||
m.Created?.ToDateTime().MiladiToJalaliWithTime() ?? "-"))
|
||||
.ToList();
|
||||
}
|
||||
catch
|
||||
{
|
||||
return new List<WalletWithdrawal>();
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<WithdrawalSettings> GetWithdrawalSettingsAsync()
|
||||
{
|
||||
// TODO: Implement when BFF protobuf has GetWithdrawalSettings
|
||||
await Task.CompletedTask;
|
||||
return new WithdrawalSettings(1_000_000);
|
||||
// var response = await _client.GetWithdrawalSettingsAsync(new Empty());
|
||||
// return new WithdrawalSettings(response.MinWithdrawalAmount);
|
||||
try
|
||||
{
|
||||
var response = await _client.GetWithdrawalSettingsAsync(new Empty());
|
||||
return new WithdrawalSettings(response.MinWithdrawalAmount);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return new WithdrawalSettings(1_000_000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user