目录重组:后端按core/domains分领域存放(仅移动与更新引用)

- 50个后端模块用git mv移入core/与domains/<领域>/,入口server.js、launch.js、restore.js及server/原位不动
- 所有require路径由脚本按新旧位置统一换算(后端、server/、测试)
- 新增test/app-paths.test.js,锁定默认数据目录、public目录与飞书配置文件的绝对位置
- 维护与部署.md补充目录说明并更新模块路径

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
黄健铭andClaude Opus 5.5 committed 2026-12-04 13:01:19 -08:00
1 parent 95c481c74a
commit 9ec37196d4
172 files changed
+458 -384

No files matched your search

@@ -0,0 +1,97 @@
'use strict';
const { workbook } = require('../../core/xlsx');
const TeamMembers = require('../team/team-members');
const MIME = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
const types = {
increase: '增加',
decrease: '减少',
transfer: '平移',
opening: '开账',
count_opening: '对数盘点基准',
purchase: '入库',
adjustment: '调整',
manual: '手动变动',
sale: '销售出库',
return: '退货入库',
manual_reversal: '更正冲回',
lock_purchase: '锁价黄金入库',
lock_finished: '锁价成品入库',
order_edit_reverse: '改单出库冲回',
order_edit_sale: '改单出库',
order_cancel_reverse: '订单作废冲回',
recovery: '回收旧料入库',
};
const filters = {
all: '全部流水',
increase: '手动增加',
decrease: '手动减少',
transfer: '手动平移',
manual: '全部手动变动',
};
function status(row) {
if (row.reversal || row.kind === 'manual_reversal') return '更正记录 · 撤回旧记录的库存影响';
if (row.current === false)
return row.status === 'deleted'
? '原记录 · 已删除'
: row.status === 'modified'
? '原记录 · 已修改'
: '冲正/历史记录';
const value = row.status === 'modified' ? '修改后有效' : row.manual ? '当前有效' : '随原业务记录保留';
return value + (row.manual && row.pendingApproval ? ';待麦麦审批' : '');
}
function recordedAt(value) {
const date = new Date(value);
return Number.isNaN(date.getTime())
? '时间未提供'
: new Intl.DateTimeFormat('sv-SE', {
timeZone: 'Asia/Shanghai',
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
second: '2-digit',
hourCycle: 'h23',
}).format(date);
}
function actorDisplayName(value, label) {
const member =
value === '麦麦'
? 'owner'
: value === '助理2'
? 'assistant2'
: value === '助理' || value === '助理1'
? 'assistant'
: null;
return member ? label(member) : value;
}
function inventoryMovementsFile(
result,
date,
pocketLabel = key => key,
memberLabel = key => TeamMembers.MEMBERS.find(row => row.member === key)?.label ?? key,
) {
const rows = [
['序号', '日期', '货盘', '增减克重(g)', '类型', '备注/原单', '经办人', '记录时间', '状态', '增减对数(对)'],
...result.movements.map((row, index) => [
index + 1,
row.date,
pocketLabel(row.pocket),
row.mg / 1000,
types[row.kind] || '其他库存变动(' + row.kind + ')',
row.reversal || row.kind === 'manual_reversal' ? '撤回旧记录的库存影响' : row.note || '',
actorDisplayName(row.actor, memberLabel),
recordedAt(row.created),
status(row),
row.stockCount ?? (row.countUnit === 'pair' ? '未登记' : ''),
]),
];
const name = (result.pocket ? pocketLabel(result.pocket) : '全部货盘').replace(/[\\/:*?"<>|\u0000-\u001f]/g, '_');
const period = result.from || result.to ? `${result.from || '最早'}至${result.to || '今'}` : date;
return {
buffer: workbook(rows, { widths: [8, 14, 16, 18, 20, 48, 18, 24, 30, 18], optionalNumericColumns: [9] }),
filename: `库存流水-${name}-${filters[result.kind]}-${period}.xlsx`,
contentType: MIME,
};
}
module.exports = { inventoryMovementsFile, MIME };