v4.0.18版本提交
This commit is contained in:
@@ -9,7 +9,8 @@ import {
|
||||
toWecomPluginMetricsView,
|
||||
toWecomPluginUserView,
|
||||
wecomPluginMetricsPeriod,
|
||||
type WecomReportStats,
|
||||
wecomReportCountedOrderWhere,
|
||||
type WecomReportStats,
|
||||
} from '@dukang/domain';
|
||||
import {
|
||||
WECOM_PLUGIN_TOOL_PATHS,
|
||||
@@ -428,10 +429,11 @@ export class WecomPluginQueryService {
|
||||
);
|
||||
}
|
||||
|
||||
/** 日报口径:用户=有效未合并;订单金额=已付 payAmount;核销=RedeemRecord。today 期末为当前时刻。 */
|
||||
/** 日报口径:用户=有效未合并;订单排除待支付/已取消/退款中;金额=已付 payAmount;核销=RedeemRecord。today 期末为当前时刻。 */
|
||||
private async loadStats(start: Date, cutoff: Date): Promise<WecomReportStats> {
|
||||
const userBase = { status: 1, mergedIntoUserId: null } as const;
|
||||
const partnerBase = { isPrimary: 1 } as const;
|
||||
const countedOrder = wecomReportCountedOrderWhere();
|
||||
const paid = { payStatus: 'PAID' as const };
|
||||
|
||||
const [
|
||||
@@ -462,15 +464,15 @@ export class WecomPluginQueryService {
|
||||
}),
|
||||
this.prisma.store.count({ where: { createdAt: { lt: cutoff } } }),
|
||||
this.prisma.store.count({ where: { createdAt: { gte: start, lt: cutoff } } }),
|
||||
this.prisma.order.count({ where: { createdAt: { lt: cutoff } } }),
|
||||
this.prisma.order.count({ where: { createdAt: { gte: start, lt: cutoff } } }),
|
||||
this.prisma.order.count({ where: { ...countedOrder, createdAt: { lt: cutoff } } }),
|
||||
this.prisma.order.count({ where: { ...countedOrder, createdAt: { gte: start, lt: cutoff } } }),
|
||||
this.prisma.order.aggregate({
|
||||
_sum: { payAmount: true },
|
||||
where: { ...paid, paidAt: { lt: cutoff } },
|
||||
where: { ...countedOrder, ...paid, paidAt: { lt: cutoff } },
|
||||
}),
|
||||
this.prisma.order.aggregate({
|
||||
_sum: { payAmount: true },
|
||||
where: { ...paid, paidAt: { gte: start, lt: cutoff } },
|
||||
where: { ...countedOrder, ...paid, paidAt: { gte: start, lt: cutoff } },
|
||||
}),
|
||||
this.prisma.redeemRecord.count({ where: { createdAt: { lt: cutoff } } }),
|
||||
this.prisma.redeemRecord.count({ where: { createdAt: { gte: start, lt: cutoff } } }),
|
||||
|
||||
Reference in New Issue
Block a user