@pisell/pisellos 2.3.81 → 2.3.83

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.
Files changed (32) hide show
  1. package/dist/model/strategy/adapter/promotion/index.js +0 -9
  2. package/dist/modules/BookingContext/index.d.ts +3 -0
  3. package/dist/modules/BookingContext/index.js +42 -13
  4. package/dist/modules/BookingContext/types.d.ts +4 -4
  5. package/dist/modules/BookingContext/types.js +3 -3
  6. package/dist/modules/ProductList/clientDataVariants.d.ts +23 -0
  7. package/dist/modules/ProductList/clientDataVariants.js +165 -11
  8. package/dist/modules/ProductList/index.d.ts +14 -0
  9. package/dist/modules/ProductList/index.js +78 -11
  10. package/dist/solution/BaseSales/index.d.ts +16 -1
  11. package/dist/solution/BaseSales/index.js +531 -273
  12. package/dist/solution/BookingByStep/index.d.ts +1 -1
  13. package/dist/solution/BookingTicket/index.d.ts +1 -1
  14. package/dist/solution/UnifiedBookingSales/index.js +2 -2
  15. package/dist/utils/platform.d.ts +8 -0
  16. package/dist/utils/platform.js +15 -0
  17. package/lib/modules/BookingContext/index.d.ts +3 -0
  18. package/lib/modules/BookingContext/index.js +35 -8
  19. package/lib/modules/BookingContext/types.d.ts +4 -4
  20. package/lib/modules/BookingContext/types.js +3 -3
  21. package/lib/modules/ProductList/clientDataVariants.d.ts +23 -0
  22. package/lib/modules/ProductList/clientDataVariants.js +147 -11
  23. package/lib/modules/ProductList/index.d.ts +14 -0
  24. package/lib/modules/ProductList/index.js +59 -1
  25. package/lib/solution/BaseSales/index.d.ts +16 -1
  26. package/lib/solution/BaseSales/index.js +258 -66
  27. package/lib/solution/BookingByStep/index.d.ts +1 -1
  28. package/lib/solution/BookingTicket/index.d.ts +1 -1
  29. package/lib/solution/UnifiedBookingSales/index.js +2 -2
  30. package/lib/utils/platform.d.ts +8 -0
  31. package/lib/utils/platform.js +22 -0
  32. package/package.json +1 -1
@@ -27,6 +27,7 @@ import { BaseModule } from "../BaseModule";
27
27
  import { cloneDeep } from 'lodash-es';
28
28
  import dayjs from 'dayjs';
29
29
  import { isProductQueryHandledByOsServer, PRODUCT_QUERY_DATA_VARIANT_RELATIONS, resolveClientDataVariants } from "./clientDataVariants";
30
+ import { isCustomerUserPlatform } from "../../utils/platform";
30
31
  export * from "./types";
31
32
  export var ProductList = /*#__PURE__*/function (_BaseModule) {
32
33
  _inherits(ProductList, _BaseModule);
@@ -40,6 +41,7 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
40
41
  _defineProperty(_assertThisInitialized(_this), "store", void 0);
41
42
  _defineProperty(_assertThisInitialized(_this), "request", void 0);
42
43
  _defineProperty(_assertThisInitialized(_this), "otherParams", {});
44
+ _defineProperty(_assertThisInitialized(_this), "rawProductPriceSources", new Map());
43
45
  return _this;
44
46
  }
45
47
  _createClass(ProductList, [{
@@ -53,6 +55,7 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
53
55
  this.core = core;
54
56
  this.store = options.store;
55
57
  this.otherParams = options.otherParams || {};
58
+ this.rawProductPriceSources.clear();
56
59
  if (Array.isArray((_options$initialState = options.initialState) === null || _options$initialState === void 0 ? void 0 : _options$initialState.list)) {
57
60
  this.store.list = options.initialState.list.slice().sort(function (a, b) {
58
61
  return Number(b.sort) - Number(a.sort);
@@ -63,7 +66,7 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
63
66
  this.store.selectProducts = [];
64
67
  }
65
68
  this.request = core.getPlugin('request');
66
- case 5:
69
+ case 6:
67
70
  case "end":
68
71
  return _context.stop();
69
72
  }
@@ -140,6 +143,7 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
140
143
  value: function () {
141
144
  var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
142
145
  var _this$otherParams,
146
+ _this$otherParams2,
143
147
  _this2 = this;
144
148
  var _ref,
145
149
  _ref$category_ids,
@@ -210,8 +214,9 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
210
214
  };
211
215
  rawApplicationCode = (_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.channel;
212
216
  mappedApplicationCode = typeof rawApplicationCode === 'string' ? channelMap[rawApplicationCode] || rawApplicationCode : rawApplicationCode;
213
- queryPayload = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
214
- open_quotation: 1,
217
+ queryPayload = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, isCustomerUserPlatform((_this$otherParams2 = this.otherParams) === null || _this$otherParams2 === void 0 ? void 0 : _this$otherParams2.platform) ? {} : {
218
+ open_quotation: 1
219
+ }), {}, {
215
220
  open_bundle: 0,
216
221
  exclude_extension_type: ['product_party', 'product_event', 'product_series_event', 'product_package_ticket', 'ticket', 'event_item'],
217
222
  with: _toConsumableArray(PRODUCT_QUERY_DATA_VARIANT_RELATIONS),
@@ -257,6 +262,11 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
257
262
  originalCallback(result);
258
263
  return _context4.abrupt("return");
259
264
  case 4:
265
+ if (!handledByOsServer) {
266
+ // Subscription callbacks may contain only changed products. Upsert
267
+ // their raw records without evicting other IDs from the scope.
268
+ _this2.rememberRawProductQueryResult(callbackList);
269
+ }
260
270
  products = resolveClientDataVariants({
261
271
  core: _this2.core,
262
272
  otherParams: _this2.otherParams,
@@ -264,15 +274,15 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
264
274
  queryPayload: queryPayload,
265
275
  handledByOsServer: handledByOsServer
266
276
  });
267
- _context4.next = 7;
277
+ _context4.next = 8;
268
278
  return _this2.addProduct(products);
269
- case 7:
279
+ case 8:
270
280
  originalCallback(handledByOsServer ? result : _objectSpread(_objectSpread({}, result), {}, {
271
281
  data: _objectSpread(_objectSpread({}, result.data), {}, {
272
282
  list: products
273
283
  })
274
284
  }));
275
- case 8:
285
+ case 9:
276
286
  case "end":
277
287
  return _context4.stop();
278
288
  }
@@ -291,6 +301,9 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
291
301
  });
292
302
  case 14:
293
303
  productsData = _context5.sent;
304
+ if (!handledByOsServer && Array.isArray(productsData.data.list)) {
305
+ this.replaceRawProductQueryResult(productsData.data.list, product_ids);
306
+ }
294
307
  resolvedList = resolveClientDataVariants({
295
308
  core: this.core,
296
309
  otherParams: this.otherParams,
@@ -309,7 +322,7 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
309
322
  // }
310
323
  this.addProduct(sortedList);
311
324
  return _context5.abrupt("return", sortedList);
312
- case 19:
325
+ case 20:
313
326
  case "end":
314
327
  return _context5.stop();
315
328
  }
@@ -352,6 +365,60 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
352
365
  }
353
366
  return loadProductsPrice;
354
367
  }()
368
+ /**
369
+ * Remember raw remote product records before client-side Data Variant
370
+ * evaluation. Quote-only reads can then always start from a clean baseline.
371
+ */
372
+ }, {
373
+ key: "rememberRawProductQueryResult",
374
+ value: function rememberRawProductQueryResult(products) {
375
+ var _this3 = this;
376
+ if (!Array.isArray(products)) return;
377
+ products.forEach(function (product) {
378
+ var _source$id;
379
+ var source = product;
380
+ var id = Number((_source$id = source === null || source === void 0 ? void 0 : source.id) !== null && _source$id !== void 0 ? _source$id : source === null || source === void 0 ? void 0 : source.product_id);
381
+ if (!Number.isFinite(id)) return;
382
+ _this3.rawProductPriceSources.set(id, cloneDeep(product));
383
+ });
384
+ }
385
+ }, {
386
+ key: "replaceRawProductQueryResult",
387
+ value: function replaceRawProductQueryResult(products, requestedIds) {
388
+ var _this4 = this;
389
+ if (Array.isArray(requestedIds) && requestedIds.length > 0) {
390
+ requestedIds.forEach(function (rawId) {
391
+ var id = Number(rawId);
392
+ if (Number.isFinite(id)) _this4.rawProductPriceSources.delete(id);
393
+ });
394
+ } else {
395
+ // A non-ID query represents the latest catalog scope. Clearing before
396
+ // replacing prevents removed products from surviving indefinitely.
397
+ this.rawProductPriceSources.clear();
398
+ }
399
+ this.rememberRawProductQueryResult(products);
400
+ }
401
+
402
+ /**
403
+ * Return isolated raw price sources for the requested products.
404
+ *
405
+ * Missing IDs are intentionally omitted so callers can remotely fetch only
406
+ * the incomplete part of a batch quote.
407
+ */
408
+ }, {
409
+ key: "getRawProductPriceSources",
410
+ value: function getRawProductPriceSources(ids) {
411
+ var _this5 = this;
412
+ var products = new Map();
413
+ if (!Array.isArray(ids)) return products;
414
+ ids.forEach(function (rawId) {
415
+ var id = Number(rawId);
416
+ if (!Number.isFinite(id) || products.has(id)) return;
417
+ var product = _this5.rawProductPriceSources.get(id);
418
+ if (product) products.set(id, cloneDeep(product));
419
+ });
420
+ return products;
421
+ }
355
422
  }, {
356
423
  key: "getProducts",
357
424
  value: function () {
@@ -430,7 +497,7 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
430
497
  key: "addProduct",
431
498
  value: function () {
432
499
  var _addProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(products) {
433
- var _this3 = this;
500
+ var _this6 = this;
434
501
  return _regeneratorRuntime().wrap(function _callee10$(_context10) {
435
502
  while (1) switch (_context10.prev = _context10.next) {
436
503
  case 0:
@@ -439,13 +506,13 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
439
506
  this.store.list = [];
440
507
  }
441
508
  products.forEach(function (n) {
442
- var index = _this3.store.list.findIndex(function (m) {
509
+ var index = _this6.store.list.findIndex(function (m) {
443
510
  return m.id === n.id;
444
511
  });
445
512
  if (index === -1) {
446
- _this3.store.list.push(n);
513
+ _this6.store.list.push(n);
447
514
  } else {
448
- _this3.store.list[index] = n;
515
+ _this6.store.list[index] = n;
449
516
  }
450
517
  });
451
518
  // 根据 sort 值做降序排序(数字越大越靠前)
@@ -129,8 +129,23 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
129
129
  */
130
130
  protected preferAuthoritativeProductQueryPrice(): boolean;
131
131
  private getPriceQuerySchedule;
132
+ private isCustomerUserPriceQuery;
133
+ private getPriceQueryScheduleList;
134
+ private buildPriceQueryPayload;
135
+ private getRawProductPriceSources;
136
+ private rememberRawProductPriceSources;
137
+ private getSelectedProductVariantId;
138
+ /**
139
+ * 将目录原始商品还原为本次选择的 SKU 基线。
140
+ *
141
+ * 这里绝不能复用已评估后的目录商品,否则从命中智能价切回不命中的
142
+ * 日期时会残留旧价格。套餐仅验证所选关系存在,最终仍由 merge 方法把
143
+ * 评估后的套餐价格映射回用户的选择数据。
144
+ */
145
+ private prepareRawProductForPriceQuery;
146
+ private resolveLocalProductForPriceQuery;
132
147
  private loadProductsForPriceQuery;
133
- private loadProductForPriceQuery;
148
+ private resolveProductsForPriceQuery;
134
149
  private getAuthoritativeBundleItems;
135
150
  private findAuthoritativeBundleItem;
136
151
  private getAuthoritativeBundleUnitPrice;