Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public partial interface IPhoneOrderDataProvider
{
Task AddPhoneOrderRecordsAsync(List<PhoneOrderRecord> phoneOrderRecords, bool forceSave = true, CancellationToken cancellationToken = default);

Task<List<PhoneOrderRecord>> GetPhoneOrderRecordsAsync(List<int> agentIds, string name, DateTimeOffset? utcStart = null, DateTimeOffset? utcEnd = null, string orderId = null, CancellationToken cancellationToken = default);
Task<List<PhoneOrderRecord>> GetPhoneOrderRecordsAsync(List<int> agentIds, string name, DateTimeOffset? utcStart = null, DateTimeOffset? utcEnd = null, List<string> orderIds = null, CancellationToken cancellationToken = default);

Task<List<PhoneOrderOrderItem>> AddPhoneOrderItemAsync(List<PhoneOrderOrderItem> phoneOrderOrderItems, bool forceSave = true, CancellationToken cancellationToken = default);

Expand Down Expand Up @@ -70,7 +70,7 @@ public async Task AddPhoneOrderRecordsAsync(List<PhoneOrderRecord> phoneOrderRec
await _unitOfWork.SaveChangesAsync(cancellationToken).ConfigureAwait(false);
}

public async Task<List<PhoneOrderRecord>> GetPhoneOrderRecordsAsync(List<int> agentIds, string name, DateTimeOffset? utcStart = null, DateTimeOffset? utcEnd = null, string orderId = null, CancellationToken cancellationToken = default)
public async Task<List<PhoneOrderRecord>> GetPhoneOrderRecordsAsync(List<int> agentIds, string name, DateTimeOffset? utcStart = null, DateTimeOffset? utcEnd = null, List<string> orderIds = null, CancellationToken cancellationToken = default)
{
var agentsQuery = from agent in _repository.Query<Agent>()
join agentAssistant in _repository.Query<AgentAssistant>() on agent.Id equals agentAssistant.AgentId
Expand All @@ -89,10 +89,21 @@ join agentAssistant in _repository.Query<AgentAssistant>() on agent.Id equals ag
if (utcStart.HasValue && utcEnd.HasValue)
query = query.Where(record => record.CreatedDate >= utcStart.Value && record.CreatedDate < utcEnd.Value);

if (!string.IsNullOrEmpty(orderId))
query = query.Where(record => record.OrderId.Contains(orderId));
if (orderIds != null && orderIds.Any())
{
if (orderIds.Count == 1)
{
var singleOrderId = orderIds[0];
query = query.Where(r => r.OrderId != null && r.OrderId.Contains(singleOrderId));
}
}

var records = await query.OrderByDescending(r => r.CreatedDate).Take(1000).ToListAsync(cancellationToken).ConfigureAwait(false);

if (orderIds != null && orderIds.Count > 1)
records = records.Where(r => r.OrderId != null && orderIds.Any(id => r.OrderId.Contains($"\"{id}\""))).ToList();

return await query.OrderByDescending(record => record.CreatedDate).Take(1000).ToListAsync(cancellationToken).ConfigureAwait(false);
return records;
}

public async Task UpdatePhoneOrderRecordsAsync(PhoneOrderRecord record, bool forceSave = true, CancellationToken cancellationToken = default)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public async Task<GetPhoneOrderRecordsResponse> GetPhoneOrderRecordsAsync(GetPho
? (await _posDataProvider.GetPosAgentsAsync(storeIds: [request.StoreId.Value], cancellationToken: cancellationToken).ConfigureAwait(false)).Select(x => x.AgentId).ToList()
: [];

var records = await _phoneOrderDataProvider.GetPhoneOrderRecordsAsync(agentIds, request.Name, utcStart, utcEnd, request.OrderId, cancellationToken).ConfigureAwait(false);
var records = await _phoneOrderDataProvider.GetPhoneOrderRecordsAsync(agentIds, request.Name, utcStart, utcEnd, request.OrderIds, cancellationToken).ConfigureAwait(false);

var enrichedRecords = _mapper.Map<List<PhoneOrderRecordDto>>(records);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,7 @@ private GenerateAiOrdersRequestDto CreateDraftOrder(ExtractedOrderDto storeOrder
AiOrderInfoDto = new AiOrderInfoDto
{
SoldToId = soldToId,
AiAssistantId = aiSpeechAssistant.Id,
SoldToIds = string.IsNullOrEmpty(soldToId) ? assistantNameWithComma : soldToId,
DocumentDate = pacificNow.Date,
DeliveryDate = pacificDeliveryDate.Date,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ public class AiOrderInfoDto
{
public string SoldToId { get; set; }

public int AiAssistantId { get; set; }

public DateTime DocumentDate { get; set; }

public DateTime DeliveryDate { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class GetPhoneOrderRecordsRequest : IRequest

public DateTimeOffset? Date { get; set; }

public string OrderId { get; set; }
public List<string> OrderIds { get; set; }
}

public class GetPhoneOrderRecordsResponse : SmartTalkResponse<List<PhoneOrderRecordDto>>
Expand Down