|
@@ -115,10 +115,11 @@ function saveRows(entityKey, rows) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function rowKey(row) {
|
|
function rowKey(row) {
|
|
|
- return `${row.date}|${row.shopId == null ? '' : row.shopId}`;
|
|
|
|
|
|
|
+ // scope 必须参与键:全公司行与连锁行的 shopId 都为空串,缺 scope 会互相覆盖
|
|
|
|
|
+ return `${row.date}|${row.scope || ''}|${row.shopId == null ? '' : row.shopId}`;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-/** 合并写入:按 date|shopId upsert,浅字段覆盖(raw 整体替换) */
|
|
|
|
|
|
|
+/** 合并写入:按 date|scope|shopId upsert,浅字段覆盖(raw 整体替换) */
|
|
|
function upsertRows(entityKey, incoming) {
|
|
function upsertRows(entityKey, incoming) {
|
|
|
if (!Array.isArray(incoming) || !incoming.length) return { added: 0, updated: 0, total: 0 };
|
|
if (!Array.isArray(incoming) || !incoming.length) return { added: 0, updated: 0, total: 0 };
|
|
|
const rows = loadRows(entityKey);
|
|
const rows = loadRows(entityKey);
|