This commit is contained in:
sysadmin
2025-08-27 22:19:39 +01:00
parent 5c6abe5686
commit bbf5acbb6b
22 changed files with 15571 additions and 6 deletions

View File

@@ -8,4 +8,5 @@ public interface IMessageService
Task<bool> MarkMessageAsSentAsync(Guid messageId, string? platformMessageId = null);
Task<bool> MarkMessageAsFailedAsync(Guid messageId, string reason);
Task<bool> CreateCustomerMessageAsync(object messageData);
Task<List<CustomerMessage>?> GetCustomerMessagesAsync(Guid customerId);
}

View File

@@ -6,6 +6,7 @@ public interface IOrderService
{
Task<ApiResponse<Order>> CreateOrderAsync(CreateOrderRequest request);
Task<ApiResponse<List<Order>>> GetOrdersByIdentityAsync(string identityReference);
Task<ApiResponse<List<Order>>> GetOrdersByCustomerIdAsync(Guid customerId);
Task<ApiResponse<Order>> GetOrderByIdAsync(Guid id);
Task<ApiResponse<CryptoPayment>> CreatePaymentAsync(Guid orderId, int currency);
Task<ApiResponse<List<CryptoPayment>>> GetOrderPaymentsAsync(Guid orderId);

View File

@@ -84,4 +84,26 @@ public class MessageService : IMessageService
return false;
}
}
public async Task<List<CustomerMessage>?> GetCustomerMessagesAsync(Guid customerId)
{
try
{
var response = await _httpClient.GetAsync($"api/bot/messages/customer/{customerId}");
if (response.IsSuccessStatusCode)
{
var messages = await response.Content.ReadFromJsonAsync<List<CustomerMessage>>();
return messages ?? new List<CustomerMessage>();
}
_logger.LogWarning("Failed to get customer messages: {StatusCode}", response.StatusCode);
return new List<CustomerMessage>();
}
catch (Exception ex)
{
_logger.LogError(ex, "Error getting customer messages");
return new List<CustomerMessage>();
}
}
}

View File

@@ -64,6 +64,30 @@ public class OrderService : IOrderService
System.Net.HttpStatusCode.InternalServerError);
}
}
public async Task<ApiResponse<List<Order>>> GetOrdersByCustomerIdAsync(Guid customerId)
{
try
{
var response = await _httpClient.GetAsync($"api/orders/by-customer/{customerId}");
if (response.IsSuccessStatusCode)
{
var orders = await response.Content.ReadFromJsonAsync<List<Order>>();
return ApiResponse<List<Order>>.Success(orders ?? new List<Order>());
}
var error = await response.Content.ReadAsStringAsync();
return ApiResponse<List<Order>>.Failure(error, response.StatusCode);
}
catch (Exception ex)
{
_logger.LogError(ex, "Failed to get orders for customer {CustomerId}", customerId);
return ApiResponse<List<Order>>.Failure(
ex.Message,
System.Net.HttpStatusCode.InternalServerError);
}
}
public async Task<ApiResponse<Order>> GetOrderByIdAsync(Guid id)
{