@pisell/pisellos 2.1.171 → 2.1.173
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/index.d.ts +0 -1
- package/dist/index.js +0 -3
- package/dist/model/strategy/adapter/index.d.ts +0 -4
- package/dist/model/strategy/adapter/index.js +1 -5
- package/dist/modules/Discount/index.d.ts +2 -5
- package/dist/modules/Discount/index.js +1 -21
- package/dist/modules/Discount/types.d.ts +0 -4
- package/dist/modules/Order/index.d.ts +0 -1
- package/dist/modules/Order/index.js +6 -18
- package/dist/modules/Order/types.d.ts +0 -2
- package/dist/modules/ProductList/index.d.ts +1 -3
- package/dist/modules/ProductList/index.js +11 -22
- package/dist/modules/Schedule/getDateIsInSchedule.js +0 -5
- package/dist/solution/BookingByStep/index.d.ts +2 -2
- package/dist/solution/ScanOrder/index.js +1 -1
- package/dist/solution/ShopDiscount/index.js +15 -16
- package/dist/solution/VenueBooking/index.d.ts +3 -59
- package/dist/solution/VenueBooking/index.js +299 -771
- package/dist/solution/VenueBooking/types.d.ts +1 -3
- package/dist/solution/VenueBooking/types.js +0 -1
- package/dist/solution/VenueBooking/utils/dateSummary.d.ts +2 -2
- package/dist/solution/VenueBooking/utils/dateSummary.js +25 -12
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +6 -0
- package/dist/solution/VenueBooking/utils/slotMerge.js +9 -3
- package/dist/solution/VenueBooking/utils/timeSlot.d.ts +0 -2
- package/dist/solution/VenueBooking/utils/timeSlot.js +4 -9
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -3
- package/lib/model/strategy/adapter/index.d.ts +0 -4
- package/lib/model/strategy/adapter/index.js +2 -13
- package/lib/modules/Discount/index.d.ts +2 -5
- package/lib/modules/Discount/index.js +1 -11
- package/lib/modules/Discount/types.d.ts +0 -4
- package/lib/modules/Order/index.d.ts +0 -1
- package/lib/modules/Order/index.js +1 -11
- package/lib/modules/Order/types.d.ts +0 -2
- package/lib/modules/ProductList/index.d.ts +1 -3
- package/lib/modules/ProductList/index.js +40 -46
- package/lib/modules/Schedule/getDateIsInSchedule.js +0 -4
- package/lib/solution/BookingByStep/index.d.ts +2 -2
- package/lib/solution/ScanOrder/index.js +1 -1
- package/lib/solution/ShopDiscount/index.js +2 -3
- package/lib/solution/VenueBooking/index.d.ts +3 -59
- package/lib/solution/VenueBooking/index.js +111 -550
- package/lib/solution/VenueBooking/types.d.ts +1 -3
- package/lib/solution/VenueBooking/types.js +0 -1
- package/lib/solution/VenueBooking/utils/dateSummary.d.ts +2 -2
- package/lib/solution/VenueBooking/utils/dateSummary.js +10 -5
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +6 -0
- package/lib/solution/VenueBooking/utils/slotMerge.js +4 -3
- package/lib/solution/VenueBooking/utils/timeSlot.d.ts +0 -2
- package/lib/solution/VenueBooking/utils/timeSlot.js +3 -7
- package/package.json +2 -2
- package/dist/model/strategy/adapter/dataVariant/adapter.d.ts +0 -50
- package/dist/model/strategy/adapter/dataVariant/adapter.js +0 -167
- package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +0 -89
- package/dist/model/strategy/adapter/dataVariant/evaluator.js +0 -780
- package/dist/model/strategy/adapter/dataVariant/examples.d.ts +0 -39
- package/dist/model/strategy/adapter/dataVariant/examples.js +0 -277
- package/dist/model/strategy/adapter/dataVariant/index.d.ts +0 -4
- package/dist/model/strategy/adapter/dataVariant/index.js +0 -4
- package/dist/model/strategy/adapter/dataVariant/type.d.ts +0 -148
- package/dist/model/strategy/adapter/dataVariant/type.js +0 -54
- package/dist/solution/VenueBooking/utils/smartPricing.d.ts +0 -70
- package/dist/solution/VenueBooking/utils/smartPricing.js +0 -233
- package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +0 -50
- package/lib/model/strategy/adapter/dataVariant/adapter.js +0 -149
- package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +0 -89
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +0 -583
- package/lib/model/strategy/adapter/dataVariant/examples.d.ts +0 -39
- package/lib/model/strategy/adapter/dataVariant/examples.js +0 -293
- package/lib/model/strategy/adapter/dataVariant/index.d.ts +0 -4
- package/lib/model/strategy/adapter/dataVariant/index.js +0 -38
- package/lib/model/strategy/adapter/dataVariant/type.d.ts +0 -148
- package/lib/model/strategy/adapter/dataVariant/type.js +0 -31
- package/lib/solution/VenueBooking/utils/smartPricing.d.ts +0 -70
- package/lib/solution/VenueBooking/utils/smartPricing.js +0 -180
|
@@ -50,7 +50,6 @@ var import_resource = require("./utils/resource");
|
|
|
50
50
|
var import_timeSlot = require("./utils/timeSlot");
|
|
51
51
|
var import_dateSummary = require("./utils/dateSummary");
|
|
52
52
|
var import_slotMerge = require("./utils/slotMerge");
|
|
53
|
-
var import_smartPricing = require("./utils/smartPricing");
|
|
54
53
|
var import_utils3 = require("../../modules/Order/utils");
|
|
55
54
|
var import_Order = require("../../modules/Order");
|
|
56
55
|
var import_types4 = require("../RegisterAndLogin/types");
|
|
@@ -111,10 +110,6 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
111
110
|
this.loadAllProductsInFlight = null;
|
|
112
111
|
this.productsLoaded = false;
|
|
113
112
|
this.loadOpenDataConfigInFlight = null;
|
|
114
|
-
/** 按日期缓存 slot 智能定价 Map,避免同周重复 resolveProducts */
|
|
115
|
-
this.slotPriceMapCache = /* @__PURE__ */ new Map();
|
|
116
|
-
/** loadProducts 后缓存的全量商品(venue + addon),供分段算价复用 */
|
|
117
|
-
this.smartPricingProductCatalog = [];
|
|
118
113
|
}
|
|
119
114
|
getLoggerContext() {
|
|
120
115
|
return {
|
|
@@ -190,75 +185,6 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
190
185
|
extra
|
|
191
186
|
});
|
|
192
187
|
}
|
|
193
|
-
/**
|
|
194
|
-
* 临时线上排查日志:
|
|
195
|
-
* - 仅对指定页面 cacheId 开启,避免影响其他页面
|
|
196
|
-
* - 不 await,且吞掉日志上报异常,保证日志系统不会阻断登录/商品加载主流程
|
|
197
|
-
*/
|
|
198
|
-
logPricingDiagnostics(title, payload = {}) {
|
|
199
|
-
if (!this.isPricingDiagnosticsEnabled())
|
|
200
|
-
return;
|
|
201
|
-
void this.addVenueBookingLog({
|
|
202
|
-
level: "info",
|
|
203
|
-
title,
|
|
204
|
-
payload
|
|
205
|
-
}).catch((error) => {
|
|
206
|
-
console.warn("[VenueBooking] pricing diagnostic log failed", error);
|
|
207
|
-
});
|
|
208
|
-
}
|
|
209
|
-
isPricingDiagnosticsEnabled() {
|
|
210
|
-
return String(this.cacheId || "") === _VenueBookingImpl.PRICING_DEBUG_CACHE_ID;
|
|
211
|
-
}
|
|
212
|
-
getAvailableWalletIdsForDiagnostics() {
|
|
213
|
-
var _a, _b;
|
|
214
|
-
try {
|
|
215
|
-
return (_b = (_a = this.store.order) == null ? void 0 : _a.getAvailableWalletIds) == null ? void 0 : _b.call(_a);
|
|
216
|
-
} catch (error) {
|
|
217
|
-
return {
|
|
218
|
-
readFailed: true,
|
|
219
|
-
error: this.serializeError(error)
|
|
220
|
-
};
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
getOrderPricingSnapshotForDiagnostics() {
|
|
224
|
-
var _a, _b;
|
|
225
|
-
try {
|
|
226
|
-
const products = (_b = (_a = this.store.order) == null ? void 0 : _a.getTempOrder()) == null ? void 0 : _b.products;
|
|
227
|
-
if (!Array.isArray(products))
|
|
228
|
-
return [];
|
|
229
|
-
return products.map((product) => {
|
|
230
|
-
var _a2, _b2, _c, _d, _e, _f;
|
|
231
|
-
return {
|
|
232
|
-
productId: product == null ? void 0 : product.product_id,
|
|
233
|
-
resourceId: (_a2 = product == null ? void 0 : product.metadata) == null ? void 0 : _a2.resource_id,
|
|
234
|
-
isVenueBooking: !!((_b2 = product == null ? void 0 : product.metadata) == null ? void 0 : _b2.venue_booking),
|
|
235
|
-
sellingPrice: product == null ? void 0 : product.selling_price,
|
|
236
|
-
originalPrice: product == null ? void 0 : product.original_price,
|
|
237
|
-
sourceProductPrice: (_c = product == null ? void 0 : product.metadata) == null ? void 0 : _c.source_product_price,
|
|
238
|
-
mainProductOriginalPrice: (_d = product == null ? void 0 : product.metadata) == null ? void 0 : _d.main_product_original_price,
|
|
239
|
-
mainProductSellingPrice: (_e = product == null ? void 0 : product.metadata) == null ? void 0 : _e.main_product_selling_price,
|
|
240
|
-
priceBreakdown: (_f = product == null ? void 0 : product.metadata) == null ? void 0 : _f.price_breakdown,
|
|
241
|
-
discountList: product == null ? void 0 : product.discount_list
|
|
242
|
-
};
|
|
243
|
-
});
|
|
244
|
-
} catch (error) {
|
|
245
|
-
return [{ readFailed: true, error: this.serializeError(error) }];
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
getCatalogPricingSnapshotForDiagnostics() {
|
|
249
|
-
const orderProductIds = new Set(
|
|
250
|
-
this.getOrderPricingSnapshotForDiagnostics().map((product) => Number(product.productId)).filter((productId) => Number.isFinite(productId))
|
|
251
|
-
);
|
|
252
|
-
return this.getAllProductsForSmartPricing().filter((product) => orderProductIds.has(Number(product == null ? void 0 : product.id))).map((product) => ({
|
|
253
|
-
productId: product == null ? void 0 : product.id,
|
|
254
|
-
price: product == null ? void 0 : product.price,
|
|
255
|
-
sellingPrice: product == null ? void 0 : product.selling_price,
|
|
256
|
-
dataVariants: Array.isArray(product == null ? void 0 : product.data_variants) ? product.data_variants.map((variant) => ({
|
|
257
|
-
ruleId: variant == null ? void 0 : variant.data_variant_rule_id,
|
|
258
|
-
data: variant == null ? void 0 : variant.data
|
|
259
|
-
})) : []
|
|
260
|
-
}));
|
|
261
|
-
}
|
|
262
188
|
logMethodStart(method, payload = {}) {
|
|
263
189
|
void this.addVenueBookingLog({
|
|
264
190
|
level: "info",
|
|
@@ -346,32 +272,23 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
346
272
|
});
|
|
347
273
|
}
|
|
348
274
|
registerCustomerLoginListeners() {
|
|
275
|
+
var _a, _b, _c, _d;
|
|
349
276
|
this.clearLoginEffectListeners();
|
|
350
|
-
const
|
|
277
|
+
const accountModule = (_a = this.core) == null ? void 0 : _a.getModule("account");
|
|
278
|
+
const registerAndLoginModule = (_b = this.core) == null ? void 0 : _b.getModule("registerAndLogin");
|
|
279
|
+
const currentAccount = ((_c = accountModule == null ? void 0 : accountModule.getCurrentAccount) == null ? void 0 : _c.call(accountModule)) || ((_d = accountModule == null ? void 0 : accountModule.getAccount) == null ? void 0 : _d.call(accountModule)) || null;
|
|
280
|
+
const createHandleLogin = (eventName) => async (payload) => {
|
|
351
281
|
const customerId = this.resolveCustomerIdFromLoginPayload(payload);
|
|
352
282
|
if (!customerId)
|
|
353
283
|
return;
|
|
354
284
|
await this.refreshOrderMarketingAfterLogin({ customerId });
|
|
355
285
|
};
|
|
356
|
-
this.registerLoginEffect(
|
|
357
|
-
this.registerLoginEffect(
|
|
358
|
-
this.registerLoginEffect(import_types4.RegisterAndLoginHooks.onLoginSuccess, createHandleLogin());
|
|
286
|
+
this.registerLoginEffect(import_types3.AccountHooks.OnLogin, createHandleLogin(import_types3.AccountHooks.OnLogin));
|
|
287
|
+
this.registerLoginEffect(import_types4.RegisterAndLoginHooks.onLoginSuccess, createHandleLogin(import_types4.RegisterAndLoginHooks.onLoginSuccess));
|
|
359
288
|
}
|
|
360
289
|
async refreshOrderMarketingAfterLogin(params) {
|
|
361
290
|
if (!this.store.order)
|
|
362
291
|
throw new Error("order 模块未初始化");
|
|
363
|
-
const pricingDiagnosticsEnabled = this.isPricingDiagnosticsEnabled();
|
|
364
|
-
if (pricingDiagnosticsEnabled) {
|
|
365
|
-
this.logPricingDiagnostics("[VenueBooking] refreshOrderMarketingAfterLogin entered", {
|
|
366
|
-
customerId: params.customerId,
|
|
367
|
-
hasCustomerLoginRefreshInFlight: !!this.customerLoginRefreshInFlight,
|
|
368
|
-
customerLoginRefreshIdInFlight: this.customerLoginRefreshIdInFlight,
|
|
369
|
-
hasLoadAllProductsInFlight: !!this.loadAllProductsInFlight,
|
|
370
|
-
productsLoaded: this.productsLoaded,
|
|
371
|
-
smartPricingProductCatalogCount: this.smartPricingProductCatalog.length,
|
|
372
|
-
note: "This login refresh reloads products with the confirmed customer context before recalculation"
|
|
373
|
-
});
|
|
374
|
-
}
|
|
375
292
|
if (this.customerLoginRefreshInFlight) {
|
|
376
293
|
if (this.customerLoginRefreshIdInFlight === params.customerId) {
|
|
377
294
|
await this.customerLoginRefreshInFlight;
|
|
@@ -381,139 +298,25 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
381
298
|
}
|
|
382
299
|
this.customerLoginRefreshIdInFlight = params.customerId;
|
|
383
300
|
const refreshTask = (async () => {
|
|
384
|
-
var _a
|
|
385
|
-
this.
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
customerId: params.customerId,
|
|
389
|
-
userPluginCustomerId: this.resolveCustomerIdForSmartPricing(),
|
|
390
|
-
availableWalletIdsBeforeDiscountConfig: this.getAvailableWalletIdsForDiagnostics(),
|
|
391
|
-
orderProductsBeforeDiscountConfig: this.getOrderPricingSnapshotForDiagnostics()
|
|
301
|
+
var _a;
|
|
302
|
+
if (this.store.quotation) {
|
|
303
|
+
await this.store.quotation.loadQuotations({
|
|
304
|
+
channel: (_a = this.otherParams) == null ? void 0 : _a.channel
|
|
392
305
|
});
|
|
393
306
|
}
|
|
307
|
+
this.recalculateOrderPricesFromQuotation();
|
|
394
308
|
await this.store.order.loadDiscountConfig({
|
|
395
309
|
customerId: params.customerId
|
|
396
310
|
});
|
|
397
|
-
if (pricingDiagnosticsEnabled) {
|
|
398
|
-
const productsLoadBeforeLogin = this.loadAllProductsInFlight;
|
|
399
|
-
if (productsLoadBeforeLogin) {
|
|
400
|
-
this.logPricingDiagnostics("[VenueBooking] login waiting for previous product load", {
|
|
401
|
-
customerId: params.customerId
|
|
402
|
-
});
|
|
403
|
-
try {
|
|
404
|
-
await productsLoadBeforeLogin;
|
|
405
|
-
} catch (error) {
|
|
406
|
-
this.logPricingDiagnostics("[VenueBooking] previous product load failed before login reload", {
|
|
407
|
-
customerId: params.customerId,
|
|
408
|
-
error: this.serializeError(error)
|
|
409
|
-
});
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
this.logPricingDiagnostics("[VenueBooking] login product reload starting", {
|
|
413
|
-
customerId: params.customerId,
|
|
414
|
-
productsLoadedBeforeReload: this.productsLoaded,
|
|
415
|
-
catalogCountBeforeReload: this.smartPricingProductCatalog.length,
|
|
416
|
-
availableWalletIds: this.getAvailableWalletIdsForDiagnostics()
|
|
417
|
-
});
|
|
418
|
-
const loginProducts = await this.loadAllProducts();
|
|
419
|
-
this.logPricingDiagnostics("[VenueBooking] login product reload completed", {
|
|
420
|
-
customerId: params.customerId,
|
|
421
|
-
venueProductCount: loginProducts.venueProducts.length,
|
|
422
|
-
addonProductCount: loginProducts.addonProducts.length,
|
|
423
|
-
catalogCountAfterReload: this.smartPricingProductCatalog.length,
|
|
424
|
-
resourceProductMapSize: this.resourceProductMap.size
|
|
425
|
-
});
|
|
426
|
-
}
|
|
427
|
-
if (pricingDiagnosticsEnabled) {
|
|
428
|
-
const smartPricingContext = this.buildSmartPricingContext();
|
|
429
|
-
const strategyConfigs = ((_b = (_a = smartPricingContext.evaluator) == null ? void 0 : _a.getStrategyConfigs) == null ? void 0 : _b.call(_a)) || [];
|
|
430
|
-
this.logPricingDiagnostics("[VenueBooking] login discount config loaded", {
|
|
431
|
-
customerId: params.customerId,
|
|
432
|
-
availableWalletIdsAfterDiscountConfig: this.getAvailableWalletIdsForDiagnostics(),
|
|
433
|
-
discountList: this.store.order.getDiscountList(),
|
|
434
|
-
smartPricingContext: {
|
|
435
|
-
customerId: smartPricingContext.customerId,
|
|
436
|
-
availableWalletIds: smartPricingContext.availableWalletIds,
|
|
437
|
-
channel: smartPricingContext.channel,
|
|
438
|
-
businessCode: smartPricingContext.businessCode,
|
|
439
|
-
orderType: smartPricingContext.orderType,
|
|
440
|
-
scheduleCount: ((_c = smartPricingContext.scheduleList) == null ? void 0 : _c.length) || 0,
|
|
441
|
-
menuCount: ((_d = smartPricingContext.menuList) == null ? void 0 : _d.length) || 0,
|
|
442
|
-
hasEvaluator: !!smartPricingContext.evaluator
|
|
443
|
-
},
|
|
444
|
-
strategyConfigs: strategyConfigs.map((config) => {
|
|
445
|
-
var _a2, _b2, _c2, _d2, _e2, _f2;
|
|
446
|
-
return {
|
|
447
|
-
ruleId: (_a2 = config == null ? void 0 : config.metadata) == null ? void 0 : _a2.id,
|
|
448
|
-
name: (_b2 = config == null ? void 0 : config.metadata) == null ? void 0 : _b2.name,
|
|
449
|
-
status: (_d2 = (_c2 = config == null ? void 0 : config.metadata) == null ? void 0 : _c2.custom) == null ? void 0 : _d2.status,
|
|
450
|
-
priority: (_f2 = (_e2 = config == null ? void 0 : config.metadata) == null ? void 0 : _e2.custom) == null ? void 0 : _f2.priority,
|
|
451
|
-
conditions: config == null ? void 0 : config.conditions
|
|
452
|
-
};
|
|
453
|
-
}),
|
|
454
|
-
productsLoaded: this.productsLoaded,
|
|
455
|
-
smartPricingProductCatalogCount: (_e = this.smartPricingProductCatalog) == null ? void 0 : _e.length,
|
|
456
|
-
resourceProductMapSize: this.resourceProductMap.size,
|
|
457
|
-
matchingCatalogProducts: this.getCatalogPricingSnapshotForDiagnostics()
|
|
458
|
-
});
|
|
459
|
-
}
|
|
460
|
-
this.clearSlotPriceMapCache();
|
|
461
|
-
if (pricingDiagnosticsEnabled) {
|
|
462
|
-
this.logPricingDiagnostics("[VenueBooking] login smart pricing recalculation starting", {
|
|
463
|
-
slotPriceMapCacheSizeAfterClear: this.slotPriceMapCache.size,
|
|
464
|
-
orderProductsBeforeRecalculation: this.getOrderPricingSnapshotForDiagnostics()
|
|
465
|
-
});
|
|
466
|
-
}
|
|
467
|
-
this.recalculateOrderPricesFromSmartPricing();
|
|
468
|
-
if (pricingDiagnosticsEnabled) {
|
|
469
|
-
this.logPricingDiagnostics("[VenueBooking] login smart pricing recalculation completed", {
|
|
470
|
-
orderProductsAfterRecalculation: this.getOrderPricingSnapshotForDiagnostics()
|
|
471
|
-
});
|
|
472
|
-
}
|
|
473
|
-
this.store.order.applyDiscount();
|
|
474
|
-
this.normalizeDiscountedOrderPrices(
|
|
475
|
-
this.store.order.getDiscountList()
|
|
476
|
-
);
|
|
477
|
-
if (pricingDiagnosticsEnabled) {
|
|
478
|
-
this.logPricingDiagnostics("[VenueBooking] login discounts reapplied", {
|
|
479
|
-
discountList: this.store.order.getDiscountList(),
|
|
480
|
-
orderProductsAfterDiscount: this.getOrderPricingSnapshotForDiagnostics()
|
|
481
|
-
});
|
|
482
|
-
}
|
|
483
311
|
await this.store.order.recalculateSummary({ createIfMissing: true });
|
|
484
312
|
this.store.order.persistTempOrder();
|
|
485
|
-
if (pricingDiagnosticsEnabled) {
|
|
486
|
-
this.logPricingDiagnostics("[VenueBooking] login pricing summary persisted", {
|
|
487
|
-
summary: (_f = this.store.order.getTempOrder()) == null ? void 0 : _f.summary,
|
|
488
|
-
orderProducts: this.getOrderPricingSnapshotForDiagnostics()
|
|
489
|
-
});
|
|
490
|
-
}
|
|
491
313
|
await this.refreshItemRuleQuantityLimits();
|
|
492
314
|
await this.refreshCartValidationPassed();
|
|
493
|
-
await ((_i = (_h = (_g = this.core) == null ? void 0 : _g.effects) == null ? void 0 : _h.emit) == null ? void 0 : _i.call(_h, import_types.VenueBookingHooks.onSmartPricingUpdated, {
|
|
494
|
-
customerId: params.customerId
|
|
495
|
-
}));
|
|
496
|
-
if (pricingDiagnosticsEnabled) {
|
|
497
|
-
this.logPricingDiagnostics("[VenueBooking] login smart pricing update emitted", {
|
|
498
|
-
customerId: params.customerId,
|
|
499
|
-
cartValidation: this.store.cartValidation
|
|
500
|
-
});
|
|
501
|
-
}
|
|
502
315
|
})();
|
|
503
316
|
this.customerLoginRefreshInFlight = refreshTask;
|
|
504
317
|
try {
|
|
505
318
|
await refreshTask;
|
|
506
319
|
} catch (error) {
|
|
507
|
-
if (pricingDiagnosticsEnabled) {
|
|
508
|
-
this.logPricingDiagnostics("[VenueBooking] login smart pricing refresh failed", {
|
|
509
|
-
customerId: params.customerId,
|
|
510
|
-
error: this.serializeError(error),
|
|
511
|
-
productsLoaded: this.productsLoaded,
|
|
512
|
-
smartPricingProductCatalogCount: this.smartPricingProductCatalog.length,
|
|
513
|
-
resourceProductMapSize: this.resourceProductMap.size,
|
|
514
|
-
orderProducts: this.getOrderPricingSnapshotForDiagnostics()
|
|
515
|
-
});
|
|
516
|
-
}
|
|
517
320
|
throw error;
|
|
518
321
|
} finally {
|
|
519
322
|
if (this.customerLoginRefreshInFlight === refreshTask) {
|
|
@@ -523,12 +326,11 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
523
326
|
}
|
|
524
327
|
}
|
|
525
328
|
async initialize(core, options = {}) {
|
|
526
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
329
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
527
330
|
this.logMethodStart("initialize");
|
|
528
331
|
this.core = core;
|
|
529
332
|
this.initializeOptions = options || {};
|
|
530
333
|
this.store = { ...this.store, ...options.store };
|
|
531
|
-
this.smartPricingCustomerId = void 0;
|
|
532
334
|
this.store.entryContext = ((_a = options.otherParams) == null ? void 0 : _a.entryContext) || this.store.entryContext;
|
|
533
335
|
this.store.status = "initializing";
|
|
534
336
|
this.store.error = null;
|
|
@@ -660,6 +462,10 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
660
462
|
await this.loadRuntimeConfigs();
|
|
661
463
|
if (this.store.schedule) {
|
|
662
464
|
await this.store.schedule.loadAllSchedule();
|
|
465
|
+
this.injectScheduleResolverToQuotation();
|
|
466
|
+
(_k = this.store.quotation) == null ? void 0 : _k.loadQuotations({
|
|
467
|
+
channel: (_j = this.otherParams) == null ? void 0 : _j.channel
|
|
468
|
+
});
|
|
663
469
|
}
|
|
664
470
|
await this.refreshItemRuleQuantityLimits();
|
|
665
471
|
this.store.status = "ready";
|
|
@@ -735,95 +541,6 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
735
541
|
getCartValidation() {
|
|
736
542
|
return this.store.cartValidation || { passed: null, failures: [] };
|
|
737
543
|
}
|
|
738
|
-
/** 清除 slot 价格分段缓存(商品重载 / 登录后 customerId 变化时调用) */
|
|
739
|
-
clearSlotPriceMapCache() {
|
|
740
|
-
this.slotPriceMapCache.clear();
|
|
741
|
-
}
|
|
742
|
-
/** 读取当前登录 customerId */
|
|
743
|
-
resolveCustomerIdForSmartPricing() {
|
|
744
|
-
var _a, _b, _c;
|
|
745
|
-
if (this.smartPricingCustomerId)
|
|
746
|
-
return this.smartPricingCustomerId;
|
|
747
|
-
try {
|
|
748
|
-
const userPlugin = (_a = this.core) == null ? void 0 : _a.getPlugin("user");
|
|
749
|
-
const customerId = Number((_c = (_b = userPlugin == null ? void 0 : userPlugin.get) == null ? void 0 : _b.call(userPlugin)) == null ? void 0 : _c.id);
|
|
750
|
-
return Number.isFinite(customerId) && customerId > 0 ? customerId : void 0;
|
|
751
|
-
} catch {
|
|
752
|
-
return void 0;
|
|
753
|
-
}
|
|
754
|
-
}
|
|
755
|
-
resolveAvailableWalletIdsForSmartPricing() {
|
|
756
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
757
|
-
const orderWalletIds = (_b = (_a = this.store.order) == null ? void 0 : _a.getAvailableWalletIds) == null ? void 0 : _b.call(_a);
|
|
758
|
-
const fallbackWalletIds = ((_c = this.otherParams) == null ? void 0 : _c.available_wallet_ids) || ((_d = this.otherParams) == null ? void 0 : _d.availableWalletIds) || ((_f = (_e = this.otherParams) == null ? void 0 : _e.strategy_context) == null ? void 0 : _f.available_wallet_ids) || ((_h = (_g = this.otherParams) == null ? void 0 : _g.strategy_context) == null ? void 0 : _h.availableWalletIds);
|
|
759
|
-
const source = Array.isArray(orderWalletIds) && orderWalletIds.length ? orderWalletIds : fallbackWalletIds;
|
|
760
|
-
if (!Array.isArray(source))
|
|
761
|
-
return [];
|
|
762
|
-
const ids = source.map((item) => Number(item)).filter((item) => Number.isFinite(item) && item > 0);
|
|
763
|
-
return Array.from(new Set(ids));
|
|
764
|
-
}
|
|
765
|
-
/** 读取 schedule 全量列表,供智能定价 schedule_match 使用 */
|
|
766
|
-
getScheduleListForSmartPricing() {
|
|
767
|
-
var _a;
|
|
768
|
-
const scheduleModule = this.store.schedule;
|
|
769
|
-
const list = (_a = scheduleModule == null ? void 0 : scheduleModule.store) == null ? void 0 : _a.scheduleList;
|
|
770
|
-
return Array.isArray(list) ? list : [];
|
|
771
|
-
}
|
|
772
|
-
/** 构建智能定价上下文,对齐 OS Server buildProductFormatterContext */
|
|
773
|
-
buildSmartPricingContext(customerId) {
|
|
774
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
775
|
-
const evaluator = (_b = (_a = this.core) == null ? void 0 : _a.context) == null ? void 0 : _b.dataVariantEvaluator;
|
|
776
|
-
return {
|
|
777
|
-
evaluator,
|
|
778
|
-
scheduleList: this.getScheduleListForSmartPricing(),
|
|
779
|
-
menuList: ((_c = this.otherParams) == null ? void 0 : _c.menuList) || ((_e = (_d = this.otherParams) == null ? void 0 : _d.openData) == null ? void 0 : _e.menuList) || [],
|
|
780
|
-
customerId: customerId ?? this.resolveCustomerIdForSmartPricing(),
|
|
781
|
-
availableWalletIds: this.resolveAvailableWalletIdsForSmartPricing(),
|
|
782
|
-
channel: (_f = this.otherParams) == null ? void 0 : _f.channel,
|
|
783
|
-
businessCode: (_g = this.otherParams) == null ? void 0 : _g.businessCode,
|
|
784
|
-
orderType: ((_h = this.otherParams) == null ? void 0 : _h.orderType) || ((_i = this.otherParams) == null ? void 0 : _i.type),
|
|
785
|
-
strategy_context: (_j = this.otherParams) == null ? void 0 : _j.strategy_context
|
|
786
|
-
};
|
|
787
|
-
}
|
|
788
|
-
/** venue + addon 全量商品,供智能定价评估 */
|
|
789
|
-
getAllProductsForSmartPricing() {
|
|
790
|
-
if (this.smartPricingProductCatalog.length) {
|
|
791
|
-
return this.smartPricingProductCatalog;
|
|
792
|
-
}
|
|
793
|
-
const venueList = this.getVenueProducts();
|
|
794
|
-
const addonList = this.getAddonProductsList();
|
|
795
|
-
return [...venueList, ...addonList];
|
|
796
|
-
}
|
|
797
|
-
getSlotPriceMapCacheKey(date, context) {
|
|
798
|
-
return [
|
|
799
|
-
date,
|
|
800
|
-
context.customerId ?? "",
|
|
801
|
-
(context.availableWalletIds || []).join(","),
|
|
802
|
-
context.channel ?? "",
|
|
803
|
-
context.businessCode ?? ""
|
|
804
|
-
].join("|");
|
|
805
|
-
}
|
|
806
|
-
/**
|
|
807
|
-
* 按 schedule 分段构建 slot 价格 Map,带实例级缓存。
|
|
808
|
-
*/
|
|
809
|
-
buildSlotPriceMapForDate(date, config, productIds) {
|
|
810
|
-
const context = this.buildSmartPricingContext();
|
|
811
|
-
const cacheKey = this.getSlotPriceMapCacheKey(date, context);
|
|
812
|
-
const cached = this.slotPriceMapCache.get(cacheKey);
|
|
813
|
-
if (cached)
|
|
814
|
-
return cached;
|
|
815
|
-
const timeLabels = (0, import_timeSlot.generateTimeLabels)(config);
|
|
816
|
-
const slotPriceMap = (0, import_smartPricing.buildSlotPriceMapByScheduleSegments)({
|
|
817
|
-
products: this.getAllProductsForSmartPricing(),
|
|
818
|
-
productIds,
|
|
819
|
-
date,
|
|
820
|
-
timeLabels,
|
|
821
|
-
config,
|
|
822
|
-
context
|
|
823
|
-
});
|
|
824
|
-
this.slotPriceMapCache.set(cacheKey, slotPriceMap);
|
|
825
|
-
return slotPriceMap;
|
|
826
|
-
}
|
|
827
544
|
// ─── 场地商品 & 附加商品 ───
|
|
828
545
|
async loadAllProducts() {
|
|
829
546
|
if (this.loadAllProductsInFlight)
|
|
@@ -852,18 +569,9 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
852
569
|
menu_list_ids: menuListIds,
|
|
853
570
|
cacheId: this.cacheId,
|
|
854
571
|
schedule_date: (0, import_dayjs.default)().format("YYYY-MM-DD"),
|
|
855
|
-
schedule_datetime: (0, import_dayjs.default)().format("YYYY-MM-DD HH:mm:ss")
|
|
856
|
-
with_extra: ["dataVariants"]
|
|
572
|
+
schedule_datetime: (0, import_dayjs.default)().format("YYYY-MM-DD HH:mm:ss")
|
|
857
573
|
});
|
|
858
|
-
const
|
|
859
|
-
let list = rawList;
|
|
860
|
-
this.smartPricingProductCatalog = rawList.slice();
|
|
861
|
-
list = (0, import_smartPricing.formatProductsWithDataVariant)(
|
|
862
|
-
list,
|
|
863
|
-
this.buildSmartPricingContext(),
|
|
864
|
-
(0, import_dayjs.default)().format("YYYY-MM-DD HH:mm:ss")
|
|
865
|
-
);
|
|
866
|
-
this.clearSlotPriceMapCache();
|
|
574
|
+
const list = Array.isArray(allProducts) ? allProducts : [];
|
|
867
575
|
const venueList = list.filter((p) => p.duration != null);
|
|
868
576
|
const addonList = list.filter((p) => p.duration == null);
|
|
869
577
|
const venueStore = (_c = this.store.venueProducts) == null ? void 0 : _c.store;
|
|
@@ -1044,24 +752,29 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
1044
752
|
config: this.baseSlotConfig,
|
|
1045
753
|
rawResources: this.store.rawResourceData,
|
|
1046
754
|
resourceProductMap: this.resourceProductMap,
|
|
1047
|
-
|
|
1048
|
-
|
|
755
|
+
quotationModule: this.store.quotation,
|
|
756
|
+
resolveConfig: (date) => this.resolveSlotConfigForDate(date)
|
|
1049
757
|
});
|
|
1050
758
|
}
|
|
1051
759
|
getTimeSlotGrid(date) {
|
|
1052
760
|
const resolvedSlotConfig = this.syncOperatingHoursToSlotConfig(date);
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
761
|
+
let quotationPriceMap;
|
|
762
|
+
if (this.store.quotation) {
|
|
763
|
+
const productIds = [
|
|
764
|
+
...new Set(
|
|
765
|
+
[...this.resourceProductMap.values()].flat().map((m) => m.productId)
|
|
766
|
+
)
|
|
767
|
+
];
|
|
768
|
+
const timeLabels = (0, import_timeSlot.generateTimeLabels)(resolvedSlotConfig);
|
|
769
|
+
const timePoints = timeLabels.map((label) => `${date} ${label}`);
|
|
770
|
+
quotationPriceMap = this.store.quotation.buildProductPriceMap({ productIds, timePoints });
|
|
771
|
+
}
|
|
1059
772
|
return (0, import_timeSlot.buildTimeSlotGrid)({
|
|
1060
773
|
date,
|
|
1061
774
|
config: resolvedSlotConfig,
|
|
1062
775
|
rawResources: this.store.rawResourceData,
|
|
1063
776
|
resourceProductMap: this.resourceProductMap,
|
|
1064
|
-
|
|
777
|
+
quotationPriceMap
|
|
1065
778
|
});
|
|
1066
779
|
}
|
|
1067
780
|
// ─── 时间槽订单操作 ───
|
|
@@ -1346,7 +1059,8 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
1346
1059
|
booking_uid: bookingUuid,
|
|
1347
1060
|
price_breakdown: (0, import_slotMerge.buildPriceBreakdown)({
|
|
1348
1061
|
group,
|
|
1349
|
-
productId: mapping.productId
|
|
1062
|
+
productId: mapping.productId,
|
|
1063
|
+
quotation: this.store.quotation
|
|
1350
1064
|
})
|
|
1351
1065
|
},
|
|
1352
1066
|
_origin: {
|
|
@@ -1439,12 +1153,20 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
1439
1153
|
if (!this.store.schedule)
|
|
1440
1154
|
throw new Error("schedule 模块未初始化");
|
|
1441
1155
|
await this.store.schedule.loadAllSchedule();
|
|
1156
|
+
this.injectScheduleResolverToQuotation();
|
|
1442
1157
|
this.logMethodSuccess("loadSchedules");
|
|
1443
1158
|
} catch (error) {
|
|
1444
1159
|
this.logMethodError("loadSchedules", error);
|
|
1445
1160
|
throw error;
|
|
1446
1161
|
}
|
|
1447
1162
|
}
|
|
1163
|
+
injectScheduleResolverToQuotation() {
|
|
1164
|
+
if (this.store.quotation && this.store.schedule) {
|
|
1165
|
+
this.store.quotation.setScheduleResolver(
|
|
1166
|
+
(id) => this.store.schedule.getScheduleListByIds([id])[0]
|
|
1167
|
+
);
|
|
1168
|
+
}
|
|
1169
|
+
}
|
|
1448
1170
|
getScheduleListByIds(ids) {
|
|
1449
1171
|
if (!this.store.schedule)
|
|
1450
1172
|
return [];
|
|
@@ -1483,197 +1205,56 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
1483
1205
|
throw error;
|
|
1484
1206
|
}
|
|
1485
1207
|
}
|
|
1486
|
-
|
|
1487
|
-
* 接收 pisell2 VenueBooking 登录链路诊断日志。
|
|
1488
|
-
* 实际是否上报仍由 OS 内部 cacheId 白名单统一控制。
|
|
1489
|
-
*/
|
|
1490
|
-
logPricingDiagnosticsFromClient(params) {
|
|
1491
|
-
this.logPricingDiagnostics(
|
|
1492
|
-
`[VenueBooking][pisell2] ${String((params == null ? void 0 : params.title) || "diagnostic")}`,
|
|
1493
|
-
(params == null ? void 0 : params.payload) || {}
|
|
1494
|
-
);
|
|
1495
|
-
}
|
|
1496
|
-
recalculateOrderPricesFromSmartPricing() {
|
|
1208
|
+
recalculateOrderPricesFromQuotation() {
|
|
1497
1209
|
var _a, _b;
|
|
1498
|
-
if (!this.store.order)
|
|
1499
|
-
this.logPricingDiagnostics("[VenueBooking] order smart pricing recalculation skipped", {
|
|
1500
|
-
reason: "order module is missing"
|
|
1501
|
-
});
|
|
1210
|
+
if (!this.store.order || !this.store.quotation)
|
|
1502
1211
|
return;
|
|
1503
|
-
}
|
|
1504
1212
|
const tempOrder = this.store.order.getTempOrder();
|
|
1505
|
-
if (!((_a = tempOrder == null ? void 0 : tempOrder.products) == null ? void 0 : _a.length))
|
|
1506
|
-
this.logPricingDiagnostics("[VenueBooking] order smart pricing recalculation skipped", {
|
|
1507
|
-
reason: "temp order has no products"
|
|
1508
|
-
});
|
|
1213
|
+
if (!((_a = tempOrder == null ? void 0 : tempOrder.products) == null ? void 0 : _a.length))
|
|
1509
1214
|
return;
|
|
1510
|
-
}
|
|
1511
1215
|
const now = (0, import_dayjs.default)().format("YYYY-MM-DD HH:mm:ss");
|
|
1512
|
-
const catalog = this.getAllProductsForSmartPricing();
|
|
1513
|
-
const context = this.buildSmartPricingContext();
|
|
1514
|
-
const productDiagnostics = this.isPricingDiagnosticsEnabled() ? [] : null;
|
|
1515
1216
|
for (const product of tempOrder.products) {
|
|
1516
1217
|
if ((_b = product.metadata) == null ? void 0 : _b.venue_booking) {
|
|
1517
1218
|
const mappings = this.resourceProductMap.get(product.metadata.resource_id);
|
|
1518
|
-
if (!mappings || !mappings.length)
|
|
1519
|
-
productDiagnostics == null ? void 0 : productDiagnostics.push({
|
|
1520
|
-
productId: product.product_id,
|
|
1521
|
-
resourceId: product.metadata.resource_id,
|
|
1522
|
-
originalSellingPrice: product.selling_price,
|
|
1523
|
-
result: "skipped",
|
|
1524
|
-
reason: "resourceProductMap has no mapping for resource"
|
|
1525
|
-
});
|
|
1219
|
+
if (!mappings || !mappings.length)
|
|
1526
1220
|
continue;
|
|
1527
|
-
}
|
|
1528
1221
|
const mapping = mappings.find((m) => Number(m.productId) === Number(product.product_id)) || mappings[0];
|
|
1529
|
-
if (!mapping)
|
|
1530
|
-
productDiagnostics == null ? void 0 : productDiagnostics.push({
|
|
1531
|
-
productId: product.product_id,
|
|
1532
|
-
resourceId: product.metadata.resource_id,
|
|
1533
|
-
originalSellingPrice: product.selling_price,
|
|
1534
|
-
result: "skipped",
|
|
1535
|
-
reason: "no product mapping selected",
|
|
1536
|
-
mappings
|
|
1537
|
-
});
|
|
1222
|
+
if (!mapping)
|
|
1538
1223
|
continue;
|
|
1539
|
-
}
|
|
1540
1224
|
const slots = (0, import_slotMerge.expandMergedSlotToIndividual)(
|
|
1541
1225
|
product,
|
|
1542
1226
|
this.store.slotConfig.slotDurationMinutes
|
|
1543
1227
|
);
|
|
1544
|
-
const
|
|
1545
|
-
...
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
for (const slotDate of uniqueDates) {
|
|
1549
|
-
slotPriceMaps.set(
|
|
1550
|
-
slotDate,
|
|
1551
|
-
this.buildSlotPriceMapForDate(slotDate, this.store.slotConfig, [mapping.productId])
|
|
1552
|
-
);
|
|
1553
|
-
}
|
|
1554
|
-
const updatedSlots = slots.map((slot) => {
|
|
1555
|
-
const slotDate = (0, import_dayjs.default)(slot.startTime).format("YYYY-MM-DD");
|
|
1556
|
-
const slotPriceMap = slotPriceMaps.get(slotDate);
|
|
1557
|
-
return {
|
|
1558
|
-
...slot,
|
|
1228
|
+
const updatedSlots = slots.map((slot) => ({
|
|
1229
|
+
...slot,
|
|
1230
|
+
productId: mapping.productId,
|
|
1231
|
+
price: this.store.quotation.getPriceForProduct({
|
|
1559
1232
|
productId: mapping.productId,
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
slotStartTime: slot.startTime,
|
|
1564
|
-
fallbackPrice: mapping.price
|
|
1565
|
-
}) : mapping.price
|
|
1566
|
-
};
|
|
1567
|
-
});
|
|
1233
|
+
datetime: slot.startTime
|
|
1234
|
+
}) ?? mapping.price
|
|
1235
|
+
}));
|
|
1568
1236
|
const merged = (0, import_slotMerge.mergeConsecutiveSlots)(updatedSlots);
|
|
1569
1237
|
if (merged.length === 1) {
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
productId: mapping.productId
|
|
1577
|
-
})
|
|
1578
|
-
});
|
|
1579
|
-
productDiagnostics == null ? void 0 : productDiagnostics.push({
|
|
1580
|
-
productId: product.product_id,
|
|
1581
|
-
resourceId: product.metadata.resource_id,
|
|
1582
|
-
result: "price reset",
|
|
1583
|
-
previousSellingPrice,
|
|
1584
|
-
finalSellingPrice: product.selling_price,
|
|
1585
|
-
mapping,
|
|
1586
|
-
slots: updatedSlots,
|
|
1587
|
-
merged,
|
|
1588
|
-
slotPriceMaps: Array.from(slotPriceMaps.entries()).map(([date, priceMap]) => ({
|
|
1589
|
-
date,
|
|
1590
|
-
entries: Array.from(priceMap.entries())
|
|
1591
|
-
}))
|
|
1592
|
-
});
|
|
1593
|
-
} else {
|
|
1594
|
-
productDiagnostics == null ? void 0 : productDiagnostics.push({
|
|
1595
|
-
productId: product.product_id,
|
|
1596
|
-
resourceId: product.metadata.resource_id,
|
|
1597
|
-
originalSellingPrice: product.selling_price,
|
|
1598
|
-
result: "skipped",
|
|
1599
|
-
reason: "expanded slots did not merge into exactly one group",
|
|
1600
|
-
mapping,
|
|
1601
|
-
slots: updatedSlots,
|
|
1602
|
-
merged
|
|
1238
|
+
product.selling_price = merged[0].totalPrice;
|
|
1239
|
+
product.original_price = merged[0].totalPrice;
|
|
1240
|
+
product.metadata.price_breakdown = (0, import_slotMerge.buildPriceBreakdown)({
|
|
1241
|
+
group: merged[0],
|
|
1242
|
+
productId: mapping.productId,
|
|
1243
|
+
quotation: this.store.quotation
|
|
1603
1244
|
});
|
|
1604
1245
|
}
|
|
1605
1246
|
} else if (product.product_id != null) {
|
|
1606
|
-
const
|
|
1607
|
-
(item) => Number(item == null ? void 0 : item.id) === Number(product == null ? void 0 : product.product_id)
|
|
1608
|
-
) : void 0;
|
|
1609
|
-
const previousSellingPrice = product == null ? void 0 : product.selling_price;
|
|
1610
|
-
const smartPrice = (0, import_smartPricing.getPriceForProductAtDatetime)({
|
|
1611
|
-
products: catalog,
|
|
1612
|
-
context,
|
|
1613
|
-
productId: Number(product.product_id),
|
|
1614
|
-
datetime: now,
|
|
1615
|
-
fallbackPrice: product.selling_price
|
|
1616
|
-
});
|
|
1617
|
-
this.resetProductPriceForSmartPricing({
|
|
1618
|
-
product,
|
|
1619
|
-
price: smartPrice
|
|
1620
|
-
});
|
|
1621
|
-
productDiagnostics == null ? void 0 : productDiagnostics.push({
|
|
1247
|
+
const quotationPrice = this.store.quotation.getPriceForProduct({
|
|
1622
1248
|
productId: product.product_id,
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
resolvedSmartPrice: smartPrice,
|
|
1626
|
-
finalSellingPrice: product.selling_price,
|
|
1627
|
-
catalogProduct: catalogProduct ? {
|
|
1628
|
-
price: catalogProduct.price,
|
|
1629
|
-
sellingPrice: catalogProduct.selling_price,
|
|
1630
|
-
dataVariants: catalogProduct.data_variants
|
|
1631
|
-
} : null
|
|
1632
|
-
});
|
|
1633
|
-
} else {
|
|
1634
|
-
productDiagnostics == null ? void 0 : productDiagnostics.push({
|
|
1635
|
-
productId: product.product_id,
|
|
1636
|
-
originalSellingPrice: product.selling_price,
|
|
1637
|
-
result: "skipped",
|
|
1638
|
-
reason: "product_id is missing"
|
|
1249
|
+
variantId: product.product_variant_id ?? void 0,
|
|
1250
|
+
datetime: now
|
|
1639
1251
|
});
|
|
1252
|
+
if (quotationPrice !== null) {
|
|
1253
|
+
product.selling_price = quotationPrice;
|
|
1254
|
+
product.original_price = quotationPrice;
|
|
1255
|
+
}
|
|
1640
1256
|
}
|
|
1641
1257
|
}
|
|
1642
|
-
if (productDiagnostics) {
|
|
1643
|
-
this.logPricingDiagnostics("[VenueBooking] order smart pricing recalculation detail", {
|
|
1644
|
-
now,
|
|
1645
|
-
context: {
|
|
1646
|
-
customerId: context.customerId,
|
|
1647
|
-
availableWalletIds: context.availableWalletIds,
|
|
1648
|
-
channel: context.channel,
|
|
1649
|
-
businessCode: context.businessCode,
|
|
1650
|
-
orderType: context.orderType,
|
|
1651
|
-
hasEvaluator: !!context.evaluator
|
|
1652
|
-
},
|
|
1653
|
-
catalogCount: catalog.length,
|
|
1654
|
-
resourceProductMapSize: this.resourceProductMap.size,
|
|
1655
|
-
productDiagnostics
|
|
1656
|
-
});
|
|
1657
|
-
}
|
|
1658
|
-
}
|
|
1659
|
-
/**
|
|
1660
|
-
* DataVariant 重算价格后,同步刷新订单展示、Rules 与 Summary 共用的价格口径。
|
|
1661
|
-
* Rules 会在本轮结束后根据当前客户的 discountList 重新写入实际折扣。
|
|
1662
|
-
*/
|
|
1663
|
-
resetProductPriceForSmartPricing(params) {
|
|
1664
|
-
const { product, price, priceBreakdown } = params;
|
|
1665
|
-
const metadata = product.metadata || {};
|
|
1666
|
-
product.selling_price = price;
|
|
1667
|
-
product.original_price = price;
|
|
1668
|
-
product.discount_list = [];
|
|
1669
|
-
product.metadata = {
|
|
1670
|
-
...metadata,
|
|
1671
|
-
...priceBreakdown ? { price_breakdown: priceBreakdown } : {},
|
|
1672
|
-
source_product_price: price,
|
|
1673
|
-
main_product_original_price: price,
|
|
1674
|
-
main_product_selling_price: price,
|
|
1675
|
-
price_schema_version: 2
|
|
1676
|
-
};
|
|
1677
1258
|
}
|
|
1678
1259
|
async scanCode(code, customerId) {
|
|
1679
1260
|
this.logMethodStart("scanCode", { code });
|
|
@@ -1700,7 +1281,7 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
1700
1281
|
}
|
|
1701
1282
|
/** 勾选/取消勾选某张折扣券,重新计算折扣并持久化 */
|
|
1702
1283
|
async setDiscountSelected(params) {
|
|
1703
|
-
var _a, _b, _c, _d, _e;
|
|
1284
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1704
1285
|
this.logMethodStart("setDiscountSelected", params);
|
|
1705
1286
|
try {
|
|
1706
1287
|
if (!this.store.order)
|
|
@@ -1752,15 +1333,42 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
1752
1333
|
}
|
|
1753
1334
|
}
|
|
1754
1335
|
}
|
|
1755
|
-
|
|
1336
|
+
const selectedResourceIds = new Set(
|
|
1337
|
+
nextDiscountList.filter((d) => d.isSelected).map((d) => d.id)
|
|
1338
|
+
);
|
|
1339
|
+
for (const product of tempOrder.products) {
|
|
1340
|
+
if ((_c = product._origin) == null ? void 0 : _c.isManualDiscount)
|
|
1341
|
+
continue;
|
|
1342
|
+
product.discount_list = (product.discount_list || []).filter((pd) => {
|
|
1343
|
+
var _a2;
|
|
1344
|
+
const rid = ((_a2 = pd.discount) == null ? void 0 : _a2.resource_id) ?? pd.id;
|
|
1345
|
+
return rid != null && selectedResourceIds.has(rid);
|
|
1346
|
+
});
|
|
1347
|
+
const totalPerUnitDiscount = (product.discount_list || []).reduce(
|
|
1348
|
+
(sum, pd) => sum + (pd.amount || 0),
|
|
1349
|
+
0
|
|
1350
|
+
);
|
|
1351
|
+
const optionSum = (0, import_utils3.sumOptionUnitPrice)(product.product_option_item);
|
|
1352
|
+
const sourcePrice = ((_d = product.metadata) == null ? void 0 : _d.source_product_price) ?? (((_e = product.metadata) == null ? void 0 : _e.main_product_original_price) != null ? new import_decimal.default(Number(product.metadata.main_product_original_price) || 0).minus(optionSum).toFixed(2) : product.original_price ?? "0");
|
|
1353
|
+
const newSourceSellingPrice = new import_decimal.default(Number(sourcePrice) || 0).minus(totalPerUnitDiscount).toDecimalPlaces(2).toString();
|
|
1354
|
+
const newMainSellingPrice = new import_decimal.default(Number(newSourceSellingPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
|
|
1355
|
+
if (product.metadata) {
|
|
1356
|
+
product.metadata.main_product_selling_price = newMainSellingPrice;
|
|
1357
|
+
product.metadata.price_schema_version = 2;
|
|
1358
|
+
}
|
|
1359
|
+
product.selling_price = (0, import_utils3.composeLinePrice)({
|
|
1360
|
+
mainPrice: newMainSellingPrice,
|
|
1361
|
+
bundle: product.product_bundle
|
|
1362
|
+
});
|
|
1363
|
+
}
|
|
1756
1364
|
import_Order.OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
1757
1365
|
await (discountModule == null ? void 0 : discountModule.setDiscountList(nextDiscountList));
|
|
1758
1366
|
tempOrder.discount_list = (nextDiscountList || []).filter((d) => d.isSelected);
|
|
1759
1367
|
const afterApplyTarget = this.store.order.getDiscountList().find((d) => d.id === params.discountId) || null;
|
|
1760
1368
|
await this.store.order.recalculateSummary({ createIfMissing: true });
|
|
1761
1369
|
this.store.order.persistTempOrder();
|
|
1762
|
-
const finalSummary = ((
|
|
1763
|
-
const finalProduct = ((
|
|
1370
|
+
const finalSummary = ((_f = this.store.order.getTempOrder()) == null ? void 0 : _f.summary) || null;
|
|
1371
|
+
const finalProduct = ((_h = (_g = this.store.order.getTempOrder()) == null ? void 0 : _g.products) == null ? void 0 : _h[0]) || null;
|
|
1764
1372
|
this.logMethodSuccess("setDiscountSelected", params);
|
|
1765
1373
|
const finalTarget = this.store.order.getDiscountList().find((d) => d.id === params.discountId) || null;
|
|
1766
1374
|
return this.store.order.getDiscountList();
|
|
@@ -1769,51 +1377,6 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
1769
1377
|
throw error;
|
|
1770
1378
|
}
|
|
1771
1379
|
}
|
|
1772
|
-
/**
|
|
1773
|
-
* 统一 VenueBooking 折扣后的订单行价。
|
|
1774
|
-
*
|
|
1775
|
-
* Rules 的 `discount_list.amount` 是已经按适用规则计算出的每件优惠额;它是这里唯一
|
|
1776
|
-
* 的折扣金额来源。使用智能定价写入的 source_product_price 减去该金额,再同步
|
|
1777
|
-
* selling_price 与 Summary 使用的 main_product_selling_price,避免 UI 的购物车行价、
|
|
1778
|
-
* 小计和提交订单各自读取到不同的价格字段。
|
|
1779
|
-
*/
|
|
1780
|
-
normalizeDiscountedOrderPrices(discountList) {
|
|
1781
|
-
var _a;
|
|
1782
|
-
const order = this.store.order;
|
|
1783
|
-
if (!order)
|
|
1784
|
-
return;
|
|
1785
|
-
const tempOrder = order.ensureTempOrder();
|
|
1786
|
-
const selectedResourceIds = new Set(
|
|
1787
|
-
(discountList || []).filter((discount) => discount.isSelected).map((discount) => discount.id)
|
|
1788
|
-
);
|
|
1789
|
-
for (const product of tempOrder.products) {
|
|
1790
|
-
if ((_a = product._origin) == null ? void 0 : _a.isManualDiscount)
|
|
1791
|
-
continue;
|
|
1792
|
-
product.discount_list = (product.discount_list || []).filter((detail) => {
|
|
1793
|
-
var _a2;
|
|
1794
|
-
const resourceId = ((_a2 = detail.discount) == null ? void 0 : _a2.resource_id) ?? detail.id;
|
|
1795
|
-
return resourceId != null && selectedResourceIds.has(resourceId);
|
|
1796
|
-
});
|
|
1797
|
-
const totalPerUnitDiscount = (product.discount_list || []).reduce(
|
|
1798
|
-
(total, detail) => total.plus(detail.amount || 0),
|
|
1799
|
-
new import_decimal.default(0)
|
|
1800
|
-
);
|
|
1801
|
-
const metadata = product.metadata || (product.metadata = {});
|
|
1802
|
-
const optionSum = (0, import_utils3.sumOptionUnitPrice)(product.product_option_item);
|
|
1803
|
-
const sourcePrice = metadata.source_product_price ?? (metadata.main_product_original_price != null ? new import_decimal.default(Number(metadata.main_product_original_price) || 0).minus(optionSum).toFixed(2) : product.original_price ?? "0");
|
|
1804
|
-
const nextSourceSellingPrice = import_decimal.default.max(
|
|
1805
|
-
0,
|
|
1806
|
-
new import_decimal.default(Number(sourcePrice) || 0).minus(totalPerUnitDiscount)
|
|
1807
|
-
).toDecimalPlaces(2).toString();
|
|
1808
|
-
const nextMainSellingPrice = new import_decimal.default(Number(nextSourceSellingPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
|
|
1809
|
-
metadata.main_product_selling_price = nextMainSellingPrice;
|
|
1810
|
-
metadata.price_schema_version = 2;
|
|
1811
|
-
product.selling_price = (0, import_utils3.composeLinePrice)({
|
|
1812
|
-
mainPrice: nextMainSellingPrice,
|
|
1813
|
-
bundle: product.product_bundle
|
|
1814
|
-
});
|
|
1815
|
-
}
|
|
1816
|
-
}
|
|
1817
1380
|
async addNewOrder() {
|
|
1818
1381
|
this.logMethodStart("addNewOrder");
|
|
1819
1382
|
try {
|
|
@@ -1893,7 +1456,7 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
1893
1456
|
}
|
|
1894
1457
|
}
|
|
1895
1458
|
async addProductToOrder(product) {
|
|
1896
|
-
var _a
|
|
1459
|
+
var _a;
|
|
1897
1460
|
this.logMethodStart("addProductToOrder", {
|
|
1898
1461
|
product_id: product.product_id,
|
|
1899
1462
|
product_variant_id: product.product_variant_id
|
|
@@ -1901,18 +1464,18 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
1901
1464
|
try {
|
|
1902
1465
|
if (!this.store.order)
|
|
1903
1466
|
throw new Error("order 模块未初始化");
|
|
1904
|
-
if (!((_a = product.metadata) == null ? void 0 : _a.venue_booking) && product.product_id != null) {
|
|
1905
|
-
const
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
datetime: (0, import_dayjs.default)().format("YYYY-MM-DD HH:mm:ss"),
|
|
1910
|
-
fallbackPrice: product.selling_price
|
|
1467
|
+
if (!((_a = product.metadata) == null ? void 0 : _a.venue_booking) && this.store.quotation && product.product_id != null) {
|
|
1468
|
+
const quotationPrice = this.store.quotation.getPriceForProduct({
|
|
1469
|
+
productId: product.product_id,
|
|
1470
|
+
variantId: product.product_variant_id ?? void 0,
|
|
1471
|
+
datetime: (0, import_dayjs.default)().format("YYYY-MM-DD HH:mm:ss")
|
|
1911
1472
|
});
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1473
|
+
if (quotationPrice !== null) {
|
|
1474
|
+
product.selling_price = quotationPrice;
|
|
1475
|
+
product.original_price = quotationPrice;
|
|
1476
|
+
} else if (product.selling_price != null) {
|
|
1477
|
+
product.original_price = product.selling_price;
|
|
1478
|
+
}
|
|
1916
1479
|
}
|
|
1917
1480
|
const products = await this.store.order.addProductToOrder(product);
|
|
1918
1481
|
await this.refreshItemRuleQuantityLimits();
|
|
@@ -2378,9 +1941,7 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
2378
1941
|
}
|
|
2379
1942
|
};
|
|
2380
1943
|
var VenueBookingImpl = _VenueBookingImpl;
|
|
2381
|
-
VenueBookingImpl.PRICING_DEBUG_CACHE_ID = "031596279011848516";
|
|
2382
1944
|
VenueBookingImpl.OPEN_DATA_CACHE_TTL = 5 * 60 * 1e3;
|
|
2383
|
-
VenueBookingImpl.PISELL1_LOGIN_SUCCESS = "pisell1.login.success";
|
|
2384
1945
|
// ─── UI 状态缓存(按 cacheId 分桶,sessionStorage) ───
|
|
2385
1946
|
//
|
|
2386
1947
|
// 用于物料层持久化 UI 层面的轻量状态(如当前步骤、登录回跳意图等)。
|