feat: 实现多商户管理模块与前端服务
refactor: 优化服务层代码并修复类型问题 docs: 更新开发进度文档 feat(merchant): 新增商户监控与数据统计服务 feat(dashboard): 添加商户管理前端页面与服务 fix: 修复类型转换与可选参数处理 feat: 实现商户订单、店铺与结算管理功能 refactor: 重构审计日志格式与服务调用 feat: 新增商户入驻与身份注册功能 fix(controller): 修复路由参数类型问题 feat: 添加商户排名与统计报告功能 chore: 更新模拟数据与服务配置
This commit is contained in:
@@ -83,11 +83,12 @@ router.post('/governance/propose', requireTraceContext, requirePermission('tenan
|
||||
router.post('/audit/proof/generate', requireTraceContext, requirePermission('audit:write'), async (req, res) => {
|
||||
try {
|
||||
const { tenantId } = (req as any).traceContext;
|
||||
const { auditType, sensitiveData } = req.body;
|
||||
const { auditType, sensitiveData, threshold } = req.body;
|
||||
const record = await PrivateAuditService.generateAuditProof({
|
||||
tenantId,
|
||||
auditType,
|
||||
sensitiveData
|
||||
sensitiveData,
|
||||
threshold: threshold || 0.15
|
||||
});
|
||||
res.json({ success: true, data: record });
|
||||
} catch (err: any) {
|
||||
@@ -110,8 +111,8 @@ router.post('/audit/proof/verify', requireTraceContext, requirePermission('audit
|
||||
*/
|
||||
router.post('/reputation/verify', requireTraceContext, requirePermission('tenant:admin'), async (req, res) => {
|
||||
try {
|
||||
const { verificationHash } = req.body;
|
||||
const isValid = await ReputationZKPService.verifyReputationProof(verificationHash);
|
||||
const { verificationHash, publicSignals } = req.body;
|
||||
const isValid = await ReputationZKPService.verifyReputationProof(verificationHash, publicSignals || {});
|
||||
res.json({ success: true, data: { isValid } });
|
||||
} catch (err: any) {
|
||||
res.status(500).json({ success: false, error: err.message });
|
||||
|
||||
@@ -39,7 +39,7 @@ router.post('/reputation/publish', requireTraceContext, requirePermission('trade
|
||||
router.get('/reputation/:entityId/report', requireTraceContext, requirePermission('trade:read'), async (req, res) => {
|
||||
try {
|
||||
const { entityId } = req.params;
|
||||
const report = await SovereigntyReputationService.getReputationReport(entityId);
|
||||
const report = await SovereigntyReputationService.getReputationReport(entityId as string);
|
||||
|
||||
if (!report) {
|
||||
return res.status(404).json({ success: false, error: 'No reputation data found for this entity' });
|
||||
@@ -92,7 +92,7 @@ router.post('/fulfillment/consensus/event', requireTraceContext, requirePermissi
|
||||
router.get('/fulfillment/:orderId/consensus', requireTraceContext, requirePermission('trade:read'), async (req, res) => {
|
||||
try {
|
||||
const { orderId } = req.params;
|
||||
const chain = await FulfillmentConsensusService.getConsensusChain(orderId);
|
||||
const chain = await FulfillmentConsensusService.getConsensusChain(orderId as string);
|
||||
res.json({ success: true, data: chain });
|
||||
} catch (err: any) {
|
||||
res.status(500).json({ success: false, error: err.message });
|
||||
@@ -164,7 +164,7 @@ router.get('/eco/share/history', requireTraceContext, requirePermission('trade:r
|
||||
try {
|
||||
const { tenantId } = (req as any).traceContext;
|
||||
const history = await EcoValueSharingService.getSharingHistory(tenantId);
|
||||
res.json({ success: true, data: report });
|
||||
res.json({ success: true, data: history });
|
||||
} catch (err: any) {
|
||||
res.status(500).json({ success: false, error: err.message });
|
||||
}
|
||||
@@ -192,7 +192,7 @@ router.post('/settlement/trigger', requireTraceContext, requirePermission('finan
|
||||
router.get('/warehouses', requireTraceContext, async (req, res) => {
|
||||
try {
|
||||
const { tenantId } = (req as any).traceContext;
|
||||
const warehouses = await WarehouseService.listWarehouses(tenantId);
|
||||
const warehouses = await WarehouseService.listByTenant(tenantId as string);
|
||||
res.json({ success: true, data: warehouses });
|
||||
} catch (err: any) {
|
||||
res.status(500).json({ success: false, error: err.message });
|
||||
@@ -207,11 +207,17 @@ router.post('/warehouses', requireTraceContext, async (req, res) => {
|
||||
const { tenantId } = (req as any).traceContext;
|
||||
const { id, name, type, countryCode, address } = req.body;
|
||||
|
||||
const warehouseId = await WarehouseService.createWarehouse({
|
||||
id, tenantId, name, type, countryCode, address
|
||||
await WarehouseService.createWarehouse({
|
||||
id,
|
||||
tenantId: tenantId as string,
|
||||
name,
|
||||
type,
|
||||
countryCode,
|
||||
address,
|
||||
isActive: true
|
||||
});
|
||||
|
||||
res.json({ success: true, data: { warehouseId } });
|
||||
res.json({ success: true, data: { warehouseId: id } });
|
||||
} catch (err: any) {
|
||||
res.status(500).json({ success: false, error: err.message });
|
||||
}
|
||||
@@ -264,12 +270,15 @@ router.post('/b2b/tiered-price', requireTraceContext, requirePermission('trade:r
|
||||
const { tenantId, shopId, traceId } = (req as any).traceContext;
|
||||
const { productId, quantity, customerId } = req.body;
|
||||
|
||||
const result = await B2BTradeService.calculateTieredPrice(
|
||||
const result = await B2BTradeService.calculateTieredPrice({
|
||||
productId,
|
||||
quantity,
|
||||
customerId,
|
||||
{ tenantId, shopId, traceId, businessType: 'TOB' }
|
||||
);
|
||||
tenantId: tenantId as string,
|
||||
shopId: shopId as string,
|
||||
traceId,
|
||||
businessType: 'TOB'
|
||||
});
|
||||
|
||||
res.json({ success: true, data: result });
|
||||
} catch (err: any) {
|
||||
@@ -282,10 +291,10 @@ router.post('/b2b/tiered-price', requireTraceContext, requirePermission('trade:r
|
||||
*/
|
||||
router.get('/b2b/credit/:customerId', requireTraceContext, requirePermission('trade:read'), async (req, res) => {
|
||||
try {
|
||||
const { tenantId } = (req as any).traceContext;
|
||||
const { tenantId, traceId } = (req as any).traceContext;
|
||||
const { customerId } = req.params;
|
||||
|
||||
const result = await B2BTradeService.checkCreditLimit(customerId, tenantId);
|
||||
const result = await B2BTradeService.checkCreditLimit(customerId as string, tenantId as string, traceId as string);
|
||||
res.json({ success: true, data: result });
|
||||
} catch (err: any) {
|
||||
res.status(500).json({ success: false, error: err.message });
|
||||
@@ -320,7 +329,7 @@ router.get('/b2b/batch-order/:orderId', requireTraceContext, requirePermission('
|
||||
const { tenantId } = (req as any).traceContext;
|
||||
const { orderId } = req.params;
|
||||
|
||||
const result = await B2BTradeService.getBatchOrderById(orderId, tenantId);
|
||||
const result = await B2BTradeService.getBatchOrderById(orderId as string, tenantId as string);
|
||||
if (!result) {
|
||||
return res.status(404).json({ success: false, error: 'Order not found' });
|
||||
}
|
||||
@@ -339,7 +348,7 @@ router.put('/b2b/batch-order/:orderId/payment-status', requireTraceContext, requ
|
||||
const { orderId } = req.params;
|
||||
const { status } = req.body;
|
||||
|
||||
await B2BTradeService.updatePaymentStatus(orderId, status, { tenantId, shopId, traceId });
|
||||
await B2BTradeService.updatePaymentStatus(orderId as string, status, { tenantId: tenantId as string, shopId: shopId as string, traceId });
|
||||
res.json({ success: true, message: 'Payment status updated' });
|
||||
} catch (err: any) {
|
||||
res.status(500).json({ success: false, error: err.message });
|
||||
@@ -357,7 +366,7 @@ router.post('/b2b/payment-terms', requireTraceContext, requirePermission('trade:
|
||||
const result = await B2BTradeService.setPaymentTerms(
|
||||
customerId,
|
||||
{ days, autoApprove },
|
||||
{ tenantId, shopId, traceId, businessType: 'TOB' }
|
||||
{ tenantId: tenantId as string, traceId }
|
||||
);
|
||||
|
||||
res.json({ success: true, data: result });
|
||||
|
||||
Reference in New Issue
Block a user