|
|
@@ -20,22 +20,37 @@ function register(app, ctx) {
|
|
|
// 关联运营数据:按学校名(含别名)匹配 ops_shop.school 与 ops_row.school
|
|
|
let shops = [];
|
|
|
let rows = [];
|
|
|
+ let platformRows = [];
|
|
|
let opsAvailable = false;
|
|
|
try {
|
|
|
const summary = await opsStore.summary();
|
|
|
shops = summary.shops || [];
|
|
|
rows = await opsStore.queryRows({});
|
|
|
+ platformRows = await opsStore.queryPlatformRows({});
|
|
|
opsAvailable = true;
|
|
|
} catch { /* ops 库不可用:只影响关联字段 */ }
|
|
|
|
|
|
const payload = schools.map((school) => {
|
|
|
const names = namesOf(school);
|
|
|
- const shopCount = shops.filter((s) => names.has(String(s.school || ''))).length;
|
|
|
+ // 门店口径:人工表的 shop_key 与平台明细的 shopId 取并集
|
|
|
+ const shopKeys = new Set();
|
|
|
+ for (const shop of shops) {
|
|
|
+ if (names.has(String(shop.school || ''))) shopKeys.add(String(shop.key || shop.shopId || ''));
|
|
|
+ }
|
|
|
+ for (const row of platformRows) {
|
|
|
+ if (names.has(String(row.school || ''))) shopKeys.add(String(row.shopId || ''));
|
|
|
+ }
|
|
|
+ shopKeys.delete('');
|
|
|
+ const shopCount = shopKeys.size;
|
|
|
let lastDate = '';
|
|
|
for (const row of rows) {
|
|
|
if (!names.has(String(row.school || ''))) continue;
|
|
|
if (!lastDate || row.date > lastDate) lastDate = row.date;
|
|
|
}
|
|
|
+ for (const row of platformRows) {
|
|
|
+ if (!names.has(String(row.school || ''))) continue;
|
|
|
+ if (!lastDate || row.date > lastDate) lastDate = row.date;
|
|
|
+ }
|
|
|
return {
|
|
|
...school,
|
|
|
ops: opsAvailable ? { shopCount, lastDate: lastDate || null } : null,
|