feat: v3.4.12 ticket iteration

Refund rollback, winery T+3, multi withdraw, mini-user store detail, dev plan batch edit and WeCom dispatch, support ticket edit/attachments/batch status, package imageUrl.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-04 23:53:31 +08:00
parent 71f508e02b
commit 4372018c09
34 changed files with 1032 additions and 86 deletions
@@ -3,6 +3,7 @@ import { Prisma } from '@prisma/client';
import {
DEFAULT_STORE_WITHDRAW_DAILY_LIMIT,
DEFAULT_XFX_LOGISTICS_PRICING,
WINERY_SETTLEMENT_LAG_DAYS,
WINERY_SETTLEMENT_RATE,
} from '@dukang/shared-types';
import {
@@ -40,6 +41,15 @@ function dayWindow(anchor = new Date()) {
return { start, end, billDate: start };
}
function wineryDayWindow(anchor = new Date(), lagDays = WINERY_SETTLEMENT_LAG_DAYS) {
const billDate = startOfDay(anchor);
billDate.setDate(billDate.getDate() - lagDays);
const start = billDate;
const end = new Date(start);
end.setDate(end.getDate() + 1);
return { start, end, billDate: start };
}
function round2(n: number) {
return Math.round(n * 100) / 100;
}
@@ -205,7 +215,6 @@ export class SettlementService {
remainingDailyLimit: Math.max(0, round2(dailyLimit - todayApplied)),
isPrimary: account.isPrimary === 1,
hasBankAccount,
hasPendingRequest: !!pending,
bankAccount: {
bankAccountName: account.bankAccountName,
bankAccountNo: account.bankAccountNo,
@@ -264,7 +273,6 @@ export class SettlementService {
requestAmount,
todayApplied,
dailyLimit,
hasPendingRequest: !!pending,
hasBankAccount,
});
if (!guard.ok) throw new BadRequestException(guard.message);
@@ -276,14 +284,6 @@ export class SettlementService {
if (!picked.ok) throw new BadRequestException(picked.message);
const created = await this.prisma.$transaction(async (tx) => {
const stillPending = await tx.storeWithdrawRequest.findFirst({
where: { storeId, status: 'PENDING_REVIEW' },
select: { id: true },
});
if (stillPending) {
throw new BadRequestException('已有待审核提现申请,请等待处理完成');
}
const payoutIds = picked.selected.map((p) => p.id);
const locked = await tx.storePayout.findMany({
where: {
@@ -1573,7 +1573,7 @@ export class SettlementService {
// ─── Winery bills ────────────────────────────────────
async generateWineryBillForDay(anchor = new Date()) {
const { start, end, billDate } = dayWindow(anchor);
const { start, end, billDate } = wineryDayWindow(anchor);
const rate = WINERY_SETTLEMENT_RATE;
const existing = await this.prisma.wineryBill.findUnique({ where: { billDate } });