feat: 积分商城-完成

This commit is contained in:
2026-07-31 19:08:15 +08:00
parent 898e239463
commit 20d059443c
21 changed files with 2122 additions and 181 deletions
+29
View File
@@ -37,6 +37,7 @@ import {
} from './controllers/order.controller.js'
import {
merchantAfterSaleAuditController,
merchantAfterSaleDetailController,
merchantAfterSaleListController,
merchantAfterSaleReceiveController,
merchantAfterSaleShipController,
@@ -68,6 +69,7 @@ const handlers: Record<string, FunctionHandler> = {
'cart-add': cartAddController,
login: loginController,
'merchant-after-sale-audit': merchantAfterSaleAuditController,
'merchant-after-sale-detail': merchantAfterSaleDetailController,
'merchant-after-sale-list': merchantAfterSaleListController,
'merchant-after-sale-receive': merchantAfterSaleReceiveController,
'merchant-after-sale-ship': merchantAfterSaleShipController,
@@ -124,6 +126,16 @@ const writeResponse = async (ctx: Koa.Context, response: Response) => {
const dispatch = (name: string) => async (ctx: Koa.Context) => {
logger.info('dispatch api request', { name, method: ctx.method, path: ctx.path })
logger.supplierDebug(ctx.path.startsWith('/supplierOpenApi/') ? 'zhgh-receive' : 'backend-receive',
ctx.path.startsWith('/supplierOpenApi/') ? '接收ZHGH请求' : '当前后端接收请求',
{
name,
method: ctx.method,
path: ctx.path,
url: ctx.originalUrl,
query: ctx.query,
body: ctx.request.body || {}
})
const handler = handlers[name]
if (!handler) {
ctx.status = 404
@@ -144,6 +156,23 @@ app.use(async (ctx, next) => {
await next()
})
router.get('/api/supplier-logs', ctx => {
Object.entries(corsHeaders).forEach(([key, value]) => ctx.set(key, value))
ctx.body = {
success: true,
data: {
logs: logger.getSupplierDebugLogs()
}
}
})
router.delete('/api/supplier-logs', ctx => {
Object.entries(corsHeaders).forEach(([key, value]) => ctx.set(key, value))
logger.clearSupplierDebugLogs()
ctx.body = {
success: true,
data: {}
}
})
router.all('/api/:name', async ctx => dispatch(ctx.params.name)(ctx))
router.post('/supplierOpenApi/pointOrder/queryOrderInfo', dispatch('supplier-order-info'))
router.post('/supplierOpenApi/debug/tokens', dispatch('supplier-debug-tokens'))