@pisell/pisellos 2.3.62 → 2.3.64
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/index.d.ts +0 -7
- package/dist/core/index.js +65 -109
- package/dist/model/strategy/adapter/walletPass/evaluator.js +0 -1
- package/dist/model/strategy/adapter/walletPass/utils.js +0 -2
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +7 -3
- package/dist/modules/Customer/index.d.ts +4 -0
- package/dist/modules/Customer/index.js +91 -59
- package/dist/modules/Customer/types.d.ts +2 -0
- package/dist/modules/Order/index.js +4 -1
- package/dist/modules/Order/utils.js +36 -30
- package/dist/modules/Payment/walletpass.js +4 -5
- package/dist/modules/Quotation/index.d.ts +0 -6
- package/dist/modules/Quotation/index.js +19 -75
- package/dist/plugins/request.d.ts +0 -1
- package/dist/server/index.d.ts +2 -6
- package/dist/server/index.js +92 -133
- package/dist/server/modules/floor-plan/index.d.ts +0 -4
- package/dist/server/modules/floor-plan/index.js +98 -240
- package/dist/server/modules/menu/index.js +23 -48
- package/dist/server/modules/order/index.d.ts +8 -12
- package/dist/server/modules/order/index.js +348 -342
- package/dist/server/modules/products/index.d.ts +2 -8
- package/dist/server/modules/products/index.js +75 -167
- package/dist/server/modules/resource/index.js +13 -21
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +6 -3
- package/dist/solution/BookingTicket/index.d.ts +2 -0
- package/dist/solution/BookingTicket/index.js +34 -10
- package/lib/core/index.d.ts +0 -7
- package/lib/core/index.js +2 -20
- package/lib/model/strategy/adapter/promotion/index.js +0 -51
- package/lib/model/strategy/adapter/walletPass/evaluator.js +0 -1
- package/lib/model/strategy/adapter/walletPass/utils.js +0 -1
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +3 -0
- package/lib/modules/Customer/index.d.ts +4 -0
- package/lib/modules/Customer/index.js +11 -0
- package/lib/modules/Customer/types.d.ts +2 -0
- package/lib/modules/Order/index.js +3 -2
- package/lib/modules/Order/utils.js +3 -0
- package/lib/modules/Payment/walletpass.js +0 -1
- package/lib/modules/Quotation/index.d.ts +0 -6
- package/lib/modules/Quotation/index.js +5 -49
- package/lib/plugins/request.d.ts +0 -1
- package/lib/server/index.d.ts +2 -6
- package/lib/server/index.js +12 -34
- package/lib/server/modules/floor-plan/index.d.ts +0 -4
- package/lib/server/modules/floor-plan/index.js +6 -54
- package/lib/server/modules/menu/index.js +5 -31
- package/lib/server/modules/order/index.d.ts +8 -12
- package/lib/server/modules/order/index.js +94 -145
- package/lib/server/modules/products/index.d.ts +2 -8
- package/lib/server/modules/products/index.js +24 -97
- package/lib/server/modules/resource/index.js +2 -7
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +1 -0
- package/lib/solution/BookingTicket/index.d.ts +2 -0
- package/lib/solution/BookingTicket/index.js +18 -2
- package/package.json +1 -1
|
@@ -25,7 +25,6 @@ export declare class ProductsModule extends BaseModule implements Module {
|
|
|
25
25
|
private quotationBridgeLoadedKey?;
|
|
26
26
|
private quotationBridgeRefreshPromise?;
|
|
27
27
|
private quotationBridgeRefreshKey?;
|
|
28
|
-
private quotationBridgeUpdatedCallback?;
|
|
29
28
|
private quotationScheduleCache;
|
|
30
29
|
private quotationScheduleCacheSource;
|
|
31
30
|
private quotationScheduleCacheLoaded;
|
|
@@ -73,7 +72,6 @@ export declare class ProductsModule extends BaseModule implements Module {
|
|
|
73
72
|
scheduleModule?: any;
|
|
74
73
|
channel?: string;
|
|
75
74
|
customer_id?: number | string;
|
|
76
|
-
onQuotationUpdated?: () => void;
|
|
77
75
|
}): Promise<void>;
|
|
78
76
|
/**
|
|
79
77
|
* 刷新桥接器内的报价单列表。
|
|
@@ -183,9 +181,7 @@ export declare class ProductsModule extends BaseModule implements Module {
|
|
|
183
181
|
/**
|
|
184
182
|
* 通过 ProductDataSource SSE 加载完整商品列表
|
|
185
183
|
*/
|
|
186
|
-
loadProductsByServer(
|
|
187
|
-
trigger?: string;
|
|
188
|
-
}): Promise<any>;
|
|
184
|
+
loadProductsByServer(): Promise<any>;
|
|
189
185
|
/**
|
|
190
186
|
* 纯请求方法:通过 HTTP 接口获取商品列表(无副作用,不触发事件、不写 IndexDB)
|
|
191
187
|
* @param params 查询参数
|
|
@@ -335,9 +331,7 @@ export declare class ProductsModule extends BaseModule implements Module {
|
|
|
335
331
|
* 拿到完整数据后一次性替换 store,清除价格缓存,触发 onProductsSyncCompleted
|
|
336
332
|
* @returns 刷新后的商品列表
|
|
337
333
|
*/
|
|
338
|
-
silentRefresh(
|
|
339
|
-
trigger?: string;
|
|
340
|
-
}): Promise<ProductData[]>;
|
|
334
|
+
silentRefresh(): Promise<ProductData[]>;
|
|
341
335
|
/**
|
|
342
336
|
* 销毁同步资源(取消 pubsub 订阅、清除定时器)
|
|
343
337
|
*/
|
|
@@ -192,7 +192,7 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
|
|
|
192
192
|
* Server 层负责传入完整 schedule 模块,Products 只负责把报价单计算结果转成价格响应形状。
|
|
193
193
|
*/
|
|
194
194
|
async setupQuotationPriceBridge(params) {
|
|
195
|
-
var _a
|
|
195
|
+
var _a;
|
|
196
196
|
if (!this.core) {
|
|
197
197
|
this.logWarning("setupQuotationPriceBridge: core 尚未初始化");
|
|
198
198
|
return;
|
|
@@ -211,13 +211,13 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
|
|
|
211
211
|
this.quotationScheduleCacheSource = params.scheduleModule;
|
|
212
212
|
}
|
|
213
213
|
this.quotationPriceBridge.setScheduleResolver((id) => {
|
|
214
|
-
var _a2,
|
|
214
|
+
var _a2, _b, _c, _d, _e, _f;
|
|
215
215
|
const scheduleId = String(id);
|
|
216
216
|
if (this.quotationScheduleCache.has(scheduleId)) {
|
|
217
217
|
return this.quotationScheduleCache.get(scheduleId);
|
|
218
218
|
}
|
|
219
219
|
if (!this.quotationScheduleCacheLoaded) {
|
|
220
|
-
const scheduleList = ((
|
|
220
|
+
const scheduleList = ((_b = (_a2 = params.scheduleModule).getScheduleList) == null ? void 0 : _b.call(_a2)) || [];
|
|
221
221
|
for (const schedule of scheduleList) {
|
|
222
222
|
this.quotationScheduleCache.set(String(schedule.id), schedule);
|
|
223
223
|
}
|
|
@@ -226,21 +226,12 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
|
|
|
226
226
|
if (this.quotationScheduleCache.has(scheduleId)) {
|
|
227
227
|
return this.quotationScheduleCache.get(scheduleId);
|
|
228
228
|
}
|
|
229
|
-
const schedules = ((_d = (
|
|
229
|
+
const schedules = ((_d = (_c = params.scheduleModule).getScheduleListByIds) == null ? void 0 : _d.call(_c, [id])) || ((_f = (_e = params.scheduleModule).getScheduleByIds) == null ? void 0 : _f.call(_e, [id])) || [];
|
|
230
230
|
if (schedules[0])
|
|
231
231
|
this.quotationScheduleCache.set(scheduleId, schedules[0]);
|
|
232
232
|
return schedules[0];
|
|
233
233
|
});
|
|
234
234
|
}
|
|
235
|
-
if (params.onQuotationUpdated) {
|
|
236
|
-
this.quotationBridgeUpdatedCallback = params.onQuotationUpdated;
|
|
237
|
-
}
|
|
238
|
-
(_c = (_b = this.quotationPriceBridge).setQuotationListUpdatedListener) == null ? void 0 : _c.call(_b, () => {
|
|
239
|
-
var _a2;
|
|
240
|
-
this.quotationBridgeLoadedKey = this.getQuotationBridgeScopeKey();
|
|
241
|
-
this.clearPriceCache();
|
|
242
|
-
(_a2 = this.quotationBridgeUpdatedCallback) == null ? void 0 : _a2.call(this);
|
|
243
|
-
});
|
|
244
235
|
await this.refreshQuotationPriceBridge({ customer_id: params.customer_id });
|
|
245
236
|
}
|
|
246
237
|
/**
|
|
@@ -807,20 +798,17 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
|
|
|
807
798
|
*/
|
|
808
799
|
clearPriceCache() {
|
|
809
800
|
this.productsPriceCache.clear();
|
|
810
|
-
this.quotationScheduleCache.clear();
|
|
811
|
-
this.quotationScheduleCacheLoaded = false;
|
|
812
801
|
console.log("[ProductsModule] 🗑️ 商品价格缓存已清空");
|
|
813
802
|
}
|
|
814
803
|
/**
|
|
815
804
|
* 通过 ProductDataSource SSE 加载完整商品列表
|
|
816
805
|
*/
|
|
817
|
-
async loadProductsByServer(
|
|
806
|
+
async loadProductsByServer() {
|
|
818
807
|
if (!this.productDataSource) {
|
|
819
808
|
this.logWarning("loadProductsByServer: ProductDataSource 不可用");
|
|
820
809
|
return [];
|
|
821
810
|
}
|
|
822
|
-
|
|
823
|
-
this.logInfo("开始通过 DataSource SSE 加载商品列表", { trigger });
|
|
811
|
+
this.logInfo("开始通过 DataSource SSE 加载商品列表");
|
|
824
812
|
const t0 = performance.now();
|
|
825
813
|
try {
|
|
826
814
|
const tSSE = performance.now();
|
|
@@ -828,7 +816,6 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
|
|
|
828
816
|
const list = productList || [];
|
|
829
817
|
(0, import_product.perfMark)("loadProductsByServer.SSE", performance.now() - tSSE, { count: list.length });
|
|
830
818
|
this.logInfo("通过 DataSource SSE 加载商品列表成功", {
|
|
831
|
-
trigger,
|
|
832
819
|
productCount: list.length,
|
|
833
820
|
duration: `${Math.round(performance.now() - t0)}ms`
|
|
834
821
|
});
|
|
@@ -842,7 +829,6 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
|
|
|
842
829
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
843
830
|
console.error("[Products] 加载商品数据失败:", error);
|
|
844
831
|
this.logError("通过 DataSource SSE 加载商品列表失败", {
|
|
845
|
-
trigger,
|
|
846
832
|
duration: `${duration}ms`,
|
|
847
833
|
error: errorMessage
|
|
848
834
|
});
|
|
@@ -1033,9 +1019,7 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
|
|
|
1033
1019
|
async refreshProducts() {
|
|
1034
1020
|
const tTotal = performance.now();
|
|
1035
1021
|
this.logInfo("refreshProducts 开始");
|
|
1036
|
-
const products = await this.loadProductsByServer(
|
|
1037
|
-
trigger: "product_sync"
|
|
1038
|
-
});
|
|
1022
|
+
const products = await this.loadProductsByServer();
|
|
1039
1023
|
if (products && products.length > 0) {
|
|
1040
1024
|
this.store.list = products;
|
|
1041
1025
|
this.syncProductsMap();
|
|
@@ -1080,23 +1064,18 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
|
|
|
1080
1064
|
this.logWarning("loadProductsFromIndexDB: dbManager 不可用");
|
|
1081
1065
|
return [];
|
|
1082
1066
|
}
|
|
1083
|
-
const startedAt = performance.now();
|
|
1084
1067
|
try {
|
|
1068
|
+
const t0 = performance.now();
|
|
1085
1069
|
const products = await this.dbManager.getAll(INDEXDB_STORE_NAME);
|
|
1086
|
-
|
|
1087
|
-
(0, import_product.perfMark)("loadProductsFromIndexDB", durationMs, { count: (products == null ? void 0 : products.length) ?? 0 });
|
|
1070
|
+
(0, import_product.perfMark)("loadProductsFromIndexDB", performance.now() - t0, { count: (products == null ? void 0 : products.length) ?? 0 });
|
|
1088
1071
|
this.logInfo("从 IndexDB 加载商品数据", {
|
|
1089
|
-
productCount: (products == null ? void 0 : products.length) ?? 0
|
|
1090
|
-
durationMs
|
|
1072
|
+
productCount: (products == null ? void 0 : products.length) ?? 0
|
|
1091
1073
|
});
|
|
1092
1074
|
return products || [];
|
|
1093
1075
|
} catch (error) {
|
|
1094
1076
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
1095
1077
|
console.error("[Products] 从 IndexDB 读取数据失败:", error);
|
|
1096
|
-
this.logError("从 IndexDB 读取数据失败", {
|
|
1097
|
-
durationMs: +(performance.now() - startedAt).toFixed(2),
|
|
1098
|
-
error: errorMessage
|
|
1099
|
-
});
|
|
1078
|
+
this.logError("从 IndexDB 读取数据失败", { error: errorMessage });
|
|
1100
1079
|
return [];
|
|
1101
1080
|
}
|
|
1102
1081
|
}
|
|
@@ -1124,54 +1103,22 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
|
|
|
1124
1103
|
this.logWarning("replaceProductsSnapshotInIndexDB: dbManager 不可用");
|
|
1125
1104
|
return;
|
|
1126
1105
|
}
|
|
1127
|
-
const enqueuedAt = performance.now();
|
|
1128
|
-
let queueWaitMs = 0;
|
|
1129
|
-
let clearDurationMs = 0;
|
|
1130
|
-
let writeDurationMs = 0;
|
|
1131
1106
|
try {
|
|
1132
1107
|
await this.runInProductIndexDBSaveQueue(async () => {
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
this.
|
|
1136
|
-
source,
|
|
1137
|
-
productCount: products.length,
|
|
1138
|
-
queueWaitMs
|
|
1139
|
-
});
|
|
1140
|
-
const clearStartedAt = performance.now();
|
|
1141
|
-
try {
|
|
1142
|
-
await this.dbManager.clear(INDEXDB_STORE_NAME);
|
|
1143
|
-
} finally {
|
|
1144
|
-
clearDurationMs = +(performance.now() - clearStartedAt).toFixed(2);
|
|
1145
|
-
}
|
|
1108
|
+
this.logInfo("replaceProductsSnapshotInIndexDB 开始", { source, productCount: products.length });
|
|
1109
|
+
const t0 = performance.now();
|
|
1110
|
+
await this.dbManager.clear(INDEXDB_STORE_NAME);
|
|
1146
1111
|
if (products.length > 0) {
|
|
1147
|
-
|
|
1148
|
-
try {
|
|
1149
|
-
await this.dbManager.bulkUpdate(INDEXDB_STORE_NAME, products);
|
|
1150
|
-
} finally {
|
|
1151
|
-
writeDurationMs = +(performance.now() - writeStartedAt).toFixed(2);
|
|
1152
|
-
}
|
|
1112
|
+
await this.dbManager.bulkUpdate(INDEXDB_STORE_NAME, products);
|
|
1153
1113
|
}
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
this.logInfo("replaceProductsSnapshotInIndexDB 完成", {
|
|
1157
|
-
source,
|
|
1158
|
-
productCount: products.length,
|
|
1159
|
-
queueWaitMs,
|
|
1160
|
-
clearDurationMs,
|
|
1161
|
-
writeDurationMs,
|
|
1162
|
-
executeDurationMs,
|
|
1163
|
-
totalDurationMs: +(performance.now() - enqueuedAt).toFixed(2)
|
|
1164
|
-
});
|
|
1114
|
+
(0, import_product.perfMark)("replaceProductsSnapshotInIndexDB", performance.now() - t0, { count: products.length });
|
|
1115
|
+
this.logInfo("replaceProductsSnapshotInIndexDB 完成", { source, productCount: products.length });
|
|
1165
1116
|
});
|
|
1166
1117
|
} catch (error) {
|
|
1167
1118
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
1168
1119
|
this.logError("全量保存商品到 IndexDB 失败", {
|
|
1169
1120
|
source,
|
|
1170
1121
|
productCount: products.length,
|
|
1171
|
-
queueWaitMs,
|
|
1172
|
-
clearDurationMs,
|
|
1173
|
-
writeDurationMs,
|
|
1174
|
-
totalDurationMs: +(performance.now() - enqueuedAt).toFixed(2),
|
|
1175
1122
|
error: errorMessage
|
|
1176
1123
|
});
|
|
1177
1124
|
}
|
|
@@ -1253,7 +1200,6 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
|
|
|
1253
1200
|
source: "IndexDB"
|
|
1254
1201
|
});
|
|
1255
1202
|
this.logInfo("预加载完成(从 IndexDB)", {
|
|
1256
|
-
trigger: "preload",
|
|
1257
1203
|
productCount: cachedData.length,
|
|
1258
1204
|
duration: `${Math.round(performance.now() - tTotal)}ms`,
|
|
1259
1205
|
source: "IndexDB"
|
|
@@ -1269,9 +1215,7 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
|
|
|
1269
1215
|
this.logWarning("从 IndexDB 加载数据失败,准备从服务器加载", { error: errorMessage });
|
|
1270
1216
|
}
|
|
1271
1217
|
const tServer = performance.now();
|
|
1272
|
-
const products = await this.loadProductsByServer(
|
|
1273
|
-
trigger: "preload"
|
|
1274
|
-
});
|
|
1218
|
+
const products = await this.loadProductsByServer();
|
|
1275
1219
|
(0, import_product.perfMark)("preload.loadFromServer", performance.now() - tServer, { count: (products == null ? void 0 : products.length) ?? 0 });
|
|
1276
1220
|
if (products && products.length > 0) {
|
|
1277
1221
|
this.store.list = products;
|
|
@@ -1284,7 +1228,6 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
|
|
|
1284
1228
|
source: "Server"
|
|
1285
1229
|
});
|
|
1286
1230
|
this.logInfo("预加载完成(从服务器)", {
|
|
1287
|
-
trigger: "preload",
|
|
1288
1231
|
productCount: products.length,
|
|
1289
1232
|
duration: `${Math.round(performance.now() - tTotal)}ms`,
|
|
1290
1233
|
source: "Server"
|
|
@@ -1649,31 +1592,17 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
|
|
|
1649
1592
|
* 拿到完整数据后一次性替换 store,清除价格缓存,触发 onProductsSyncCompleted
|
|
1650
1593
|
* @returns 刷新后的商品列表
|
|
1651
1594
|
*/
|
|
1652
|
-
async silentRefresh(
|
|
1595
|
+
async silentRefresh() {
|
|
1653
1596
|
const t0 = performance.now();
|
|
1654
1597
|
const now = Date.now();
|
|
1655
|
-
const
|
|
1656
|
-
const
|
|
1657
|
-
|
|
1658
|
-
if (this.lastPreloadCompletedAtMs > 0 && elapsedSincePreloadMs < PRODUCT_SILENT_REFRESH_MIN_INTERVAL_MS || this.lastServerFullFetchAtMs > 0 && elapsedSinceFullFetchMs < PRODUCT_SILENT_REFRESH_MIN_INTERVAL_MS) {
|
|
1659
|
-
this.logInfo("silentRefresh 跳过全量 SSE", {
|
|
1660
|
-
trigger,
|
|
1661
|
-
reason: "within_min_interval",
|
|
1662
|
-
minIntervalMs: PRODUCT_SILENT_REFRESH_MIN_INTERVAL_MS,
|
|
1663
|
-
elapsedSincePreloadMs,
|
|
1664
|
-
elapsedSinceFullFetchMs,
|
|
1665
|
-
productCount: this.store.list.length
|
|
1666
|
-
});
|
|
1598
|
+
const elapsedSincePreload = now - this.lastPreloadCompletedAtMs;
|
|
1599
|
+
const elapsedSinceFullFetch = now - this.lastServerFullFetchAtMs;
|
|
1600
|
+
if (this.lastPreloadCompletedAtMs > 0 && elapsedSincePreload < PRODUCT_SILENT_REFRESH_MIN_INTERVAL_MS || this.lastServerFullFetchAtMs > 0 && elapsedSinceFullFetch < PRODUCT_SILENT_REFRESH_MIN_INTERVAL_MS) {
|
|
1667
1601
|
return this.store.list;
|
|
1668
1602
|
}
|
|
1669
|
-
this.logInfo("silentRefresh 开始"
|
|
1670
|
-
trigger,
|
|
1671
|
-
elapsedSincePreloadMs,
|
|
1672
|
-
elapsedSinceFullFetchMs,
|
|
1673
|
-
productCount: this.store.list.length
|
|
1674
|
-
});
|
|
1603
|
+
this.logInfo("silentRefresh 开始");
|
|
1675
1604
|
try {
|
|
1676
|
-
const products = await this.loadProductsByServer(
|
|
1605
|
+
const products = await this.loadProductsByServer();
|
|
1677
1606
|
if (products && products.length > 0) {
|
|
1678
1607
|
this.store.list = products;
|
|
1679
1608
|
this.syncProductsMap();
|
|
@@ -1681,7 +1610,6 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
|
|
|
1681
1610
|
this.core.effects.emit(import_types.ProductsHooks.onProductsChanged, this.store.list);
|
|
1682
1611
|
await this.core.effects.emit(import_types.ProductsHooks.onProductsSyncCompleted, null);
|
|
1683
1612
|
this.logInfo("silentRefresh 完成", {
|
|
1684
|
-
trigger,
|
|
1685
1613
|
productCount: products.length,
|
|
1686
1614
|
duration: `${Math.round(performance.now() - t0)}ms`
|
|
1687
1615
|
});
|
|
@@ -1693,7 +1621,6 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
|
|
|
1693
1621
|
} catch (error) {
|
|
1694
1622
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
1695
1623
|
this.logError("silentRefresh 失败", {
|
|
1696
|
-
trigger,
|
|
1697
1624
|
duration: `${Math.round(performance.now() - t0)}ms`,
|
|
1698
1625
|
error: errorMessage
|
|
1699
1626
|
});
|
|
@@ -88,18 +88,13 @@ var ResourceModule = class extends import_BaseModule.BaseModule {
|
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
async preload() {
|
|
91
|
+
await this.setupResourceSync();
|
|
91
92
|
const cachedResources = await this.loadResourcesFromSQLite();
|
|
92
93
|
if (cachedResources.length > 0) {
|
|
93
94
|
this.store.list = (0, import_lodash_es.cloneDeep)(cachedResources).map((item) => this.normalizeResource(item));
|
|
94
95
|
this.syncResourcesMap();
|
|
95
96
|
await this.safeEmit(import_types.ResourceHooks.onResourcesChanged, this.store.list);
|
|
96
|
-
|
|
97
|
-
this.logError("后台初始化资源同步失败", error);
|
|
98
|
-
});
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
await this.setupResourceSync();
|
|
102
|
-
if (this.store.list.length === 0) {
|
|
97
|
+
} else {
|
|
103
98
|
const resources = await this.loadResourcesByServer();
|
|
104
99
|
if (resources.length > 0) {
|
|
105
100
|
this.store.list = (0, import_lodash_es.cloneDeep)(resources).map((item) => this.normalizeResource(item));
|
|
@@ -230,6 +230,7 @@ function transformBaseProductToOrderProduct(params) {
|
|
|
230
230
|
},
|
|
231
231
|
product_bundle: productBundle,
|
|
232
232
|
discount_list: manualDiscountList,
|
|
233
|
+
...payload.bundle_edit !== void 0 ? { bundle_edit: payload.bundle_edit } : {},
|
|
233
234
|
// 折后行价由 normalizeOrderProduct 按 main + bundle 合成;手动改价时 bundle 已为分摊后单价
|
|
234
235
|
selling_price: lineCompositeTotal,
|
|
235
236
|
original_price: lineOriginalPrice,
|
|
@@ -63,6 +63,8 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
63
63
|
scanPromotionCode(code: string, customerId?: number): Promise<BaseSalesScanCodeResult>;
|
|
64
64
|
private hydrateOrderCustomerFromScanDiscounts;
|
|
65
65
|
private getDiscountCustomerId;
|
|
66
|
+
resolveCustomerById(customerId: string | number): Promise<ICustomer | null>;
|
|
67
|
+
/** 兼容既有优惠码扫码逻辑。 */
|
|
66
68
|
private resolveCustomerByDiscountCustomerId;
|
|
67
69
|
private findCustomerById;
|
|
68
70
|
private normalizeCustomer;
|
|
@@ -396,7 +396,7 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
|
396
396
|
}
|
|
397
397
|
return null;
|
|
398
398
|
}
|
|
399
|
-
async
|
|
399
|
+
async resolveCustomerById(customerId) {
|
|
400
400
|
var _a;
|
|
401
401
|
const localCustomers = this.store.customer.getCustomers();
|
|
402
402
|
const localCustomer = this.findCustomerById(localCustomers, customerId);
|
|
@@ -410,7 +410,23 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
|
410
410
|
num: 1
|
|
411
411
|
});
|
|
412
412
|
const remoteCustomer = this.findCustomerById((result == null ? void 0 : result.list) || [], customerId) || ((_a = result == null ? void 0 : result.list) == null ? void 0 : _a[0]) || null;
|
|
413
|
-
|
|
413
|
+
if (remoteCustomer) {
|
|
414
|
+
return this.normalizeCustomer(remoteCustomer);
|
|
415
|
+
}
|
|
416
|
+
try {
|
|
417
|
+
const detailCustomer = await this.store.customer.queryCustomerDetail(customerId);
|
|
418
|
+
return detailCustomer ? this.normalizeCustomer(detailCustomer) : null;
|
|
419
|
+
} catch (error) {
|
|
420
|
+
console.warn(
|
|
421
|
+
"[BookingTicket] resolveCustomerById detail request failed",
|
|
422
|
+
{ customerId, error }
|
|
423
|
+
);
|
|
424
|
+
return null;
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
/** 兼容既有优惠码扫码逻辑。 */
|
|
428
|
+
resolveCustomerByDiscountCustomerId(customerId) {
|
|
429
|
+
return this.resolveCustomerById(customerId);
|
|
414
430
|
}
|
|
415
431
|
findCustomerById(customers = [], customerId) {
|
|
416
432
|
return customers.find((customer) => {
|