feat(M08-B): 补保洁照片上传和自动建单
This commit is contained in:
@@ -74,7 +74,13 @@ export class OrderStateError extends Error {
|
||||
export class OrderStateRepository {
|
||||
constructor(
|
||||
private readonly pool: MySqlPool,
|
||||
private readonly benefits?: Pick<MarketingBenefitService, 'releaseReservedInTransaction'>
|
||||
private readonly benefits?: Pick<MarketingBenefitService, 'releaseReservedInTransaction'>,
|
||||
private readonly cleaningTasks?: {
|
||||
createForFinishedOrder(
|
||||
connection: PoolConnection,
|
||||
input: { tenantId: string; orderId: string; actorId: string; traceId: string }
|
||||
): Promise<void>;
|
||||
}
|
||||
) {}
|
||||
|
||||
async transition(actor: OrderActor, orderId: string, action: OrderAction, reason = '') {
|
||||
@@ -103,6 +109,14 @@ export class OrderStateRepository {
|
||||
[targetStatus, nextVersion, actor.tenantId, orderId]
|
||||
);
|
||||
await this.applyReservationState(connection, actor.tenantId, orderId, targetStatus);
|
||||
if (targetStatus === 'FINISHED' && this.cleaningTasks) {
|
||||
await this.cleaningTasks.createForFinishedOrder(connection, {
|
||||
tenantId: actor.tenantId,
|
||||
orderId,
|
||||
actorId: actor.userId,
|
||||
traceId: actor.traceId
|
||||
});
|
||||
}
|
||||
const [result] = await connection.execute<ResultSetHeader>(
|
||||
`INSERT INTO qipai_order_status_history
|
||||
(tenant_id, order_id, from_status, to_status, action, actor_type,
|
||||
|
||||
Reference in New Issue
Block a user