fix(order): complete order after POS payment instead of stopping at Processing
PayOrderCommandHandler was calling MarkAsPaid() + MarkAsProcessing() but NOT MarkAsCompleted(), leaving orders stuck at status_id=4 (Processing) instead of 5 (Completed). For POS direct sales (cash/card/qr/transfer), the full chain is now: Validated(2) → Paid(3) → Processing(4) → Completed(5) All 4 payment methods tested and confirmed: - cash: Completed ✓ - card: Completed ✓ - qr: Completed ✓ - transfer: Completed ✓ Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -87,9 +87,11 @@ public class PayOrderCommandHandler : IRequestHandler<PayOrderCommand, PayOrderR
|
||||
var transactionId = $"CASH-{DateTime.UtcNow:yyyyMMddHHmmss}-{Guid.NewGuid().ToString("N")[..8].ToUpper()}";
|
||||
var changeAmount = amountTendered - order.TotalAmount;
|
||||
|
||||
// EN: Mark as paid and processing / VI: Đánh dấu đã thanh toán và đang xử lý
|
||||
// EN: Mark as paid → processing → completed (POS direct sale — no kitchen/prep step)
|
||||
// VI: Đánh dấu đã thanh toán → đang xử lý → hoàn thành (POS bán trực tiếp — không qua bếp)
|
||||
order.MarkAsPaid("cash", transactionId, amountTendered);
|
||||
order.MarkAsProcessing();
|
||||
order.MarkAsCompleted();
|
||||
|
||||
await _orderRepository.UnitOfWork.SaveEntitiesAsync(cancellationToken);
|
||||
|
||||
@@ -114,9 +116,11 @@ public class PayOrderCommandHandler : IRequestHandler<PayOrderCommand, PayOrderR
|
||||
{
|
||||
var transactionId = $"CARD-{DateTime.UtcNow:yyyyMMddHHmmss}-{Guid.NewGuid().ToString("N")[..8].ToUpper()}";
|
||||
|
||||
// EN: Mark as paid and processing / VI: Đánh dấu đã thanh toán và đang xử lý
|
||||
// EN: Mark as paid → processing → completed (POS direct sale — card/qr/transfer confirmed at terminal)
|
||||
// VI: Đánh dấu đã thanh toán → đang xử lý → hoàn thành (POS bán trực tiếp — thẻ/QR/CK xác nhận tại máy)
|
||||
order.MarkAsPaid(request.PaymentMethod.ToLowerInvariant(), transactionId);
|
||||
order.MarkAsProcessing();
|
||||
order.MarkAsCompleted();
|
||||
|
||||
await _orderRepository.UnitOfWork.SaveEntitiesAsync(cancellationToken);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user