fix(settlement): align winery bill T+3 window to order completedAt
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -258,7 +258,7 @@ export default function WineryBillsPage() {
|
|||||||
酒厂对账单
|
酒厂对账单
|
||||||
</Typography.Title>
|
</Typography.Title>
|
||||||
<Typography.Text type="secondary">
|
<Typography.Text type="secondary">
|
||||||
每日 8:00 汇总昨日已付订单(实付 × {ratePct}%);未打款红色、已打款绿色,可展开订单明细
|
T+3:每日 8:00 汇总 3 天前(自然日)已完成的同城/跨城订单(实付 × {ratePct}%);未打款红色、已打款绿色,可展开订单明细
|
||||||
</Typography.Text>
|
</Typography.Text>
|
||||||
</Space>
|
</Space>
|
||||||
{canEditWineryBank ? (
|
{canEditWineryBank ? (
|
||||||
|
|||||||
@@ -183,7 +183,7 @@ export const STORE_SETTLEMENT_DEFAULT_RATE = 0.6;
|
|||||||
/** 酒厂账单结算比例(酒单实付 × 比例),暂定 30% */
|
/** 酒厂账单结算比例(酒单实付 × 比例),暂定 30% */
|
||||||
export const WINERY_SETTLEMENT_RATE = 0.3;
|
export const WINERY_SETTLEMENT_RATE = 0.3;
|
||||||
|
|
||||||
/** 酒厂账单出账滞后自然日(T+3:支付日 + 3 天后纳入账单) */
|
/** 酒厂账单出账滞后自然日(T+3:订单完成日 + 3 天后纳入账单) */
|
||||||
export const WINERY_SETTLEMENT_LAG_DAYS = 3;
|
export const WINERY_SETTLEMENT_LAG_DAYS = 3;
|
||||||
|
|
||||||
export type { LogisticsSettlementMethod } from './enums';
|
export type { LogisticsSettlementMethod } from './enums';
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { AlertService } from '../common/alert/alert.service';
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 财务对账单定时任务(Asia/Shanghai)
|
* 财务对账单定时任务(Asia/Shanghai)
|
||||||
* - 每日 08:00:酒厂日账单 + 门店日账单(统计昨日 00:00~今日 00:00)
|
* - 每日 08:00:酒厂日账单(T+3:3 天前已完成订单)+ 门店日账单(昨日核销)
|
||||||
* - 每月 1 日 08:00:合伙人上一自然月账单 + 物流承运商上一自然月对账
|
* - 每月 1 日 08:00:合伙人上一自然月账单 + 物流承运商上一自然月对账
|
||||||
* - 工作日 18:05:门店提现 T+0 审完预警(FIN-003)
|
* - 工作日 18:05:门店提现 T+0 审完预警(FIN-003)
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1581,13 +1581,15 @@ export class SettlementService {
|
|||||||
return { billDate: billDate.toISOString().slice(0, 10), skipped: true, reason: '已打款' };
|
return { billDate: billDate.toISOString().slice(0, 10), skipped: true, reason: '已打款' };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// T+3:纳入「账单日」当天完成的同城/跨城订单(完成日 = 今天 − lagDays)
|
||||||
const orders = await this.prisma.order.findMany({
|
const orders = await this.prisma.order.findMany({
|
||||||
where: {
|
where: {
|
||||||
|
status: 'COMPLETED',
|
||||||
payStatus: 'PAID',
|
payStatus: 'PAID',
|
||||||
deliveryType: { in: ['LOCAL', 'CROSS_CITY'] },
|
deliveryType: { in: ['LOCAL', 'CROSS_CITY'] },
|
||||||
paidAt: { gte: start, lt: end },
|
completedAt: { gte: start, lt: end },
|
||||||
},
|
},
|
||||||
orderBy: { paidAt: 'asc' },
|
orderBy: { completedAt: 'asc' },
|
||||||
});
|
});
|
||||||
|
|
||||||
if (orders.length === 0 && !existing) {
|
if (orders.length === 0 && !existing) {
|
||||||
@@ -1633,7 +1635,8 @@ export class SettlementService {
|
|||||||
deliveryType: o.deliveryType,
|
deliveryType: o.deliveryType,
|
||||||
payAmount: o.payAmount,
|
payAmount: o.payAmount,
|
||||||
wineryAmount: round2(Number(o.payAmount) * rate),
|
wineryAmount: round2(Number(o.payAmount) * rate),
|
||||||
paidAt: o.paidAt!,
|
// 明细仍保留支付时间;账期窗口按 completedAt 归属
|
||||||
|
paidAt: o.paidAt ?? o.completedAt!,
|
||||||
})),
|
})),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user