feat(F-113): completed feature
This commit is contained in:
@@ -74,12 +74,12 @@ export class OrderService implements OrderServicePort {
|
||||
return this.repo.findById(id);
|
||||
}
|
||||
|
||||
async transitionAdmin(id: string, next: OrderState, trackingNumber?: string): Promise<OrderView> {
|
||||
async transitionAdmin(id: string, next: OrderState, trackingNumber?: string, courier?: string): Promise<OrderView> {
|
||||
const existing = await this.repo.findById(id);
|
||||
if (!existing) throw new OrderNotFoundError();
|
||||
if (!isTransitionAllowed(existing.state, next))
|
||||
throw new OrderStateTransitionError(existing.state, next);
|
||||
const updated = await this.repo.updateState(id, next, trackingNumber);
|
||||
const updated = await this.repo.updateState(id, next, trackingNumber, courier);
|
||||
if (!updated) throw new OrderNotFoundError();
|
||||
if (next === 'PAID')
|
||||
await this.events.emit({ type: 'OrderPaid', orderId: id, userId: existing.userId });
|
||||
|
||||
Reference in New Issue
Block a user