fix(orders): 订单项替换统一分摊收入
This commit is contained in:
@@ -42,9 +42,22 @@ export async function replaceOrderItems(
|
||||
orderId: number | string,
|
||||
items: OrderItemReplaceInput[],
|
||||
): Promise<OrderItemRow[]> {
|
||||
return withTransaction((client: PoolClient) =>
|
||||
replaceOrderItemsWithExecutor(client.query.bind(client), orderId, items),
|
||||
)
|
||||
return withTransaction(async (client: PoolClient) => {
|
||||
const executor = client.query.bind(client)
|
||||
await replaceOrderItemsWithExecutor(executor, orderId, items)
|
||||
const order = await client.query<{ total_amount: string | number }>(
|
||||
`SELECT total_amount FROM orders WHERE id = $1`,
|
||||
[orderId],
|
||||
)
|
||||
if (order.rows[0]) {
|
||||
await applyOrderItemRevenueAllocationWithExecutor(
|
||||
executor,
|
||||
orderId,
|
||||
Number(order.rows[0].total_amount) || 0,
|
||||
)
|
||||
}
|
||||
return listOrderItemsByOrderIdWithExecutor(executor, orderId)
|
||||
})
|
||||
}
|
||||
|
||||
export async function applyOrderItemRevenueAllocationWithExecutor(
|
||||
|
||||
Reference in New Issue
Block a user