docs: record backend capacity review

This commit is contained in:
Codex
2026-07-01 03:01:02 +08:00
parent ad1c69037b
commit 49358aae6b
8 changed files with 124 additions and 22 deletions

View File

@@ -2436,7 +2436,11 @@ export async function couponReportRoute(ctx: RequestContext) {
const campaignName = stringParam(ctx, 'campaignName');
const params: unknown[] = [auth.tenantId, startDate, endDate];
const couponFilters = ['c.tenant_id = $1'];
const redemptionFilters = ['cr.tenant_id = $1', `cr.created_at >= $2::date`, `cr.created_at < ($3::date + interval '1 day')`];
const redemptionFilters = [
'cr.tenant_id = $1',
`cr.created_at >= ($2::date::timestamp at time zone 'Asia/Shanghai')`,
`cr.created_at < (($3::date + interval '1 day')::timestamp at time zone 'Asia/Shanghai')`,
];
if (couponId) {
params.push(optionalUuidString(couponId, 'couponId'));
couponFilters.push(`c.id = $${params.length}::uuid`);
@@ -2474,8 +2478,8 @@ export async function couponReportRoute(ctx: RequestContext) {
from public.coupons c
left join public.coupon_redemptions cr on cr.tenant_id = c.tenant_id
and cr.coupon_id = c.id
and cr.created_at >= $2::date
and cr.created_at < ($3::date + interval '1 day')
and cr.created_at >= ($2::date::timestamp at time zone 'Asia/Shanghai')
and cr.created_at < (($3::date + interval '1 day')::timestamp at time zone 'Asia/Shanghai')
left join public.orders o on o.tenant_id = cr.tenant_id and o.id = cr.order_id
where ${couponFilters.join(' and ')}
group by c.id, c.code, c.status, c.campaign_name, c.used_count, c.max_uses