fix(finance): 收口快手退款路由并修复销售事实变更后的总账同步
- 平台退款路由从通用订单路径改为 POST /api/v1/admin/kuaishou-industry/orders/:orderId/refunds/approve-and-record, 服务改名 approveAndRecordKuaishouRefund,明确仅快手 91 - 总账同步改为未关账期间按日整体重建销售凭证,解决收入回填/退款重算后 旧凭证金额不更新的问题;删除与重建放在同一事务,已关账期间保持不动 - 文档明确 revenue:backfill 是存量订单退款的前置条件: revenue_amount_fen=0 会导致退款登记按钮置灰 - 本地生产副本已执行 revenue:backfill:375,447 行全部回填, order 375483 可退金额恢复为 237.00 元 验证:backend check 844(840 pass / 4 skip);frontend check 172 + build; 集成测试通过(代录、总账平衡、关账阻断、对账)。
This commit is contained in:
@@ -12,7 +12,8 @@ import {
|
||||
resendAdminKuaishouIndustryVoucherCode,
|
||||
reverseAdminKuaishouIndustryVoucher,
|
||||
} from '../../services/admin/kuaishou-industry-admin-service.js'
|
||||
import { createJsonHandler, requireAdminRoles } from './session.js'
|
||||
import { createJsonHandler, requireAdminPermission, requireAdminRoles } from './session.js'
|
||||
import { approveAndRecordKuaishouRefund } from '../../services/finance/order-refund-service.js'
|
||||
import type {
|
||||
AdminKuaishouIndustryRefundApproveRouteBody,
|
||||
AdminKuaishouIndustryRefundDisagreeRouteBody,
|
||||
@@ -27,6 +28,42 @@ import type { KuaishouIndustryVoucherAdminListQuery } from '../../repositories/k
|
||||
|
||||
const router = Router()
|
||||
|
||||
router.post(
|
||||
'/kuaishou-industry/orders/:orderId/refunds/approve-and-record',
|
||||
requireAdminPermission('finance.config'),
|
||||
createJsonHandler(
|
||||
(req) => {
|
||||
const body = req.body as Record<string, unknown>
|
||||
return approveAndRecordKuaishouRefund(
|
||||
{
|
||||
orderId: String((req.params as Record<string, string>).orderId || ''),
|
||||
orderItemId: body?.orderItemId as string | undefined,
|
||||
amountFen: body?.amountFen as string | undefined,
|
||||
platformRefundId: String(body?.platformRefundId || ''),
|
||||
reason: body?.reason as string | undefined,
|
||||
note: body?.note as string | undefined,
|
||||
refundedAt: body?.refundedAt as string | undefined,
|
||||
sellerId: body?.sellerId as string | undefined,
|
||||
refundHandingWay: body?.refundHandingWay,
|
||||
desc: body?.desc as string | undefined,
|
||||
},
|
||||
req.adminSession || null,
|
||||
)
|
||||
},
|
||||
{
|
||||
successMessage: '快手退款已同意并登记',
|
||||
errorMessage: '快手平台退款失败',
|
||||
scope: '[admin/kuaishou-industry/orders/refunds/approve-and-record]',
|
||||
audit: (req, data) => ({
|
||||
action: 'kuaishou_order_refund_approved_and_recorded',
|
||||
targetType: 'order',
|
||||
targetId: String((req.params as Record<string, string>).orderId || ''),
|
||||
data: data && typeof data === 'object' ? (data as Record<string, unknown>) : {},
|
||||
}),
|
||||
},
|
||||
),
|
||||
)
|
||||
|
||||
router.get(
|
||||
'/kuaishou-industry/vouchers',
|
||||
createJsonHandler(
|
||||
|
||||
@@ -8,7 +8,6 @@ import {
|
||||
} from '../../services/admin/write/order-actions.js'
|
||||
import {
|
||||
createManualRefund,
|
||||
createPlatformRefund,
|
||||
listOrderRefunds,
|
||||
voidOrderRefund,
|
||||
} from '../../services/finance/order-refund-service.js'
|
||||
@@ -104,42 +103,6 @@ router.get(
|
||||
),
|
||||
)
|
||||
|
||||
router.post(
|
||||
'/orders/:orderId/refunds/platform',
|
||||
requireAdminPermission('finance.config'),
|
||||
createJsonHandler(
|
||||
(req) => {
|
||||
const body = req.body as Record<string, unknown>
|
||||
return createPlatformRefund(
|
||||
{
|
||||
orderId: String((req.params as AdminOrderRouteParams).orderId || ''),
|
||||
orderItemId: body?.orderItemId as string | undefined,
|
||||
amountFen: body?.amountFen as string | undefined,
|
||||
platformRefundId: String(body?.platformRefundId || ''),
|
||||
reason: body?.reason as string | undefined,
|
||||
note: body?.note as string | undefined,
|
||||
refundedAt: body?.refundedAt as string | undefined,
|
||||
sellerId: body?.sellerId as string | undefined,
|
||||
refundHandingWay: body?.refundHandingWay,
|
||||
desc: body?.desc as string | undefined,
|
||||
},
|
||||
req.adminSession || null,
|
||||
)
|
||||
},
|
||||
{
|
||||
successMessage: '平台退款已提交并登记',
|
||||
errorMessage: '平台退款失败',
|
||||
scope: '[admin/orders/:orderId/refunds/platform]',
|
||||
audit: (req, data) => ({
|
||||
action: 'order_platform_refund_created',
|
||||
targetType: 'order',
|
||||
targetId: String((req.params as AdminOrderRouteParams).orderId || ''),
|
||||
data: data && typeof data === 'object' ? (data as Record<string, unknown>) : {},
|
||||
}),
|
||||
},
|
||||
),
|
||||
)
|
||||
|
||||
router.post(
|
||||
'/orders/:orderId/refunds',
|
||||
requireAdminPermission('finance.config'),
|
||||
|
||||
Reference in New Issue
Block a user