@pisell/pisellos 2.1.166 → 2.1.168

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 (81) hide show
  1. package/dist/index.d.ts +0 -1
  2. package/dist/index.js +0 -3
  3. package/dist/model/strategy/adapter/index.d.ts +0 -4
  4. package/dist/model/strategy/adapter/index.js +1 -5
  5. package/dist/model/strategy/adapter/promotion/index.js +9 -0
  6. package/dist/modules/Cart/utils/changePrice.js +16 -9
  7. package/dist/modules/Discount/index.d.ts +2 -5
  8. package/dist/modules/Discount/index.js +1 -21
  9. package/dist/modules/Discount/types.d.ts +0 -4
  10. package/dist/modules/Order/index.d.ts +0 -1
  11. package/dist/modules/Order/index.js +6 -18
  12. package/dist/modules/Order/types.d.ts +0 -2
  13. package/dist/modules/ProductList/index.d.ts +1 -3
  14. package/dist/modules/ProductList/index.js +11 -22
  15. package/dist/modules/Schedule/getDateIsInSchedule.js +0 -5
  16. package/dist/solution/BookingByStep/index.d.ts +2 -2
  17. package/dist/solution/ScanOrder/index.js +1 -1
  18. package/dist/solution/ShopDiscount/index.js +15 -16
  19. package/dist/solution/VenueBooking/index.d.ts +3 -40
  20. package/dist/solution/VenueBooking/index.js +261 -394
  21. package/dist/solution/VenueBooking/types.d.ts +1 -3
  22. package/dist/solution/VenueBooking/types.js +0 -1
  23. package/dist/solution/VenueBooking/utils/dateSummary.d.ts +2 -2
  24. package/dist/solution/VenueBooking/utils/dateSummary.js +25 -12
  25. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +6 -0
  26. package/dist/solution/VenueBooking/utils/slotMerge.js +9 -3
  27. package/dist/solution/VenueBooking/utils/timeSlot.d.ts +0 -2
  28. package/dist/solution/VenueBooking/utils/timeSlot.js +4 -9
  29. package/lib/index.d.ts +0 -1
  30. package/lib/index.js +0 -3
  31. package/lib/model/strategy/adapter/index.d.ts +0 -4
  32. package/lib/model/strategy/adapter/index.js +2 -13
  33. package/lib/model/strategy/adapter/promotion/index.js +0 -49
  34. package/lib/modules/Cart/utils/changePrice.js +13 -9
  35. package/lib/modules/Discount/index.d.ts +2 -5
  36. package/lib/modules/Discount/index.js +1 -11
  37. package/lib/modules/Discount/types.d.ts +0 -4
  38. package/lib/modules/Order/index.d.ts +0 -1
  39. package/lib/modules/Order/index.js +1 -11
  40. package/lib/modules/Order/types.d.ts +0 -2
  41. package/lib/modules/ProductList/index.d.ts +1 -3
  42. package/lib/modules/ProductList/index.js +39 -45
  43. package/lib/modules/Schedule/getDateIsInSchedule.js +0 -4
  44. package/lib/solution/BookingByStep/index.d.ts +2 -2
  45. package/lib/solution/ScanOrder/index.js +1 -1
  46. package/lib/solution/ShopDiscount/index.js +2 -3
  47. package/lib/solution/VenueBooking/index.d.ts +3 -40
  48. package/lib/solution/VenueBooking/index.js +111 -257
  49. package/lib/solution/VenueBooking/types.d.ts +1 -3
  50. package/lib/solution/VenueBooking/types.js +0 -1
  51. package/lib/solution/VenueBooking/utils/dateSummary.d.ts +2 -2
  52. package/lib/solution/VenueBooking/utils/dateSummary.js +10 -5
  53. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +6 -0
  54. package/lib/solution/VenueBooking/utils/slotMerge.js +4 -3
  55. package/lib/solution/VenueBooking/utils/timeSlot.d.ts +0 -2
  56. package/lib/solution/VenueBooking/utils/timeSlot.js +3 -7
  57. package/package.json +1 -1
  58. package/dist/model/strategy/adapter/dataVariant/adapter.d.ts +0 -50
  59. package/dist/model/strategy/adapter/dataVariant/adapter.js +0 -167
  60. package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +0 -89
  61. package/dist/model/strategy/adapter/dataVariant/evaluator.js +0 -780
  62. package/dist/model/strategy/adapter/dataVariant/examples.d.ts +0 -39
  63. package/dist/model/strategy/adapter/dataVariant/examples.js +0 -277
  64. package/dist/model/strategy/adapter/dataVariant/index.d.ts +0 -4
  65. package/dist/model/strategy/adapter/dataVariant/index.js +0 -4
  66. package/dist/model/strategy/adapter/dataVariant/type.d.ts +0 -148
  67. package/dist/model/strategy/adapter/dataVariant/type.js +0 -54
  68. package/dist/solution/VenueBooking/utils/smartPricing.d.ts +0 -70
  69. package/dist/solution/VenueBooking/utils/smartPricing.js +0 -233
  70. package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +0 -50
  71. package/lib/model/strategy/adapter/dataVariant/adapter.js +0 -149
  72. package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +0 -89
  73. package/lib/model/strategy/adapter/dataVariant/evaluator.js +0 -583
  74. package/lib/model/strategy/adapter/dataVariant/examples.d.ts +0 -39
  75. package/lib/model/strategy/adapter/dataVariant/examples.js +0 -293
  76. package/lib/model/strategy/adapter/dataVariant/index.d.ts +0 -4
  77. package/lib/model/strategy/adapter/dataVariant/index.js +0 -38
  78. package/lib/model/strategy/adapter/dataVariant/type.d.ts +0 -148
  79. package/lib/model/strategy/adapter/dataVariant/type.js +0 -31
  80. package/lib/solution/VenueBooking/utils/smartPricing.d.ts +0 -70
  81. package/lib/solution/VenueBooking/utils/smartPricing.js +0 -180
@@ -6,9 +6,7 @@ export declare enum VenueBookingHooks {
6
6
  onDestroy = "venueBooking:onDestroy",
7
7
  onRetryInit = "venueBooking:onRetryInit",
8
8
  onRefresh = "venueBooking:onRefresh",
9
- onCartValidationChanged = "venueBooking:onCartValidationChanged",
10
- /** 登录客户的智能定价、营销配置与订单汇总已完成刷新 */
11
- onSmartPricingUpdated = "venueBooking:onSmartPricingUpdated"
9
+ onCartValidationChanged = "venueBooking:onCartValidationChanged"
12
10
  }
13
11
  export type VenueBookingStatus = 'idle' | 'initializing' | 'ready' | 'error';
14
12
  export interface VenueBookingEntryContext {
@@ -4,7 +4,6 @@ export var VenueBookingHooks = /*#__PURE__*/function (VenueBookingHooks) {
4
4
  VenueBookingHooks["onRetryInit"] = "venueBooking:onRetryInit";
5
5
  VenueBookingHooks["onRefresh"] = "venueBooking:onRefresh";
6
6
  VenueBookingHooks["onCartValidationChanged"] = "venueBooking:onCartValidationChanged";
7
- VenueBookingHooks["onSmartPricingUpdated"] = "venueBooking:onSmartPricingUpdated";
8
7
  return VenueBookingHooks;
9
8
  }({});
10
9
 
@@ -1,11 +1,11 @@
1
1
  import type { VenueBookingSlotConfig, VenueResourceRawData, VenueDateSummaryItem, ResourceProductMapping } from '../types';
2
+ import type { QuotationModule } from '../../../modules/Quotation';
2
3
  export declare function buildDateRangeSummary(params: {
3
4
  startDate: string;
4
5
  endDate: string;
5
6
  config: VenueBookingSlotConfig;
6
7
  rawResources: VenueResourceRawData[];
7
8
  resourceProductMap: Map<number | string, ResourceProductMapping[]>;
9
+ quotationModule?: QuotationModule;
8
10
  resolveConfig?: (date: string) => VenueBookingSlotConfig;
9
- /** 按日期构建 slot 智能定价 Map */
10
- buildSlotPriceMap?: (date: string, config: VenueBookingSlotConfig, productIds: number[]) => Map<string, string | null>;
11
11
  }): VenueDateSummaryItem[];
@@ -6,31 +6,41 @@ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symb
6
6
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
7
7
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
8
8
  import dayjs from 'dayjs';
9
- import { buildTimeSlotGrid } from "./timeSlot";
9
+ import { buildTimeSlotGrid, generateTimeLabels } from "./timeSlot";
10
10
  export function buildDateRangeSummary(params) {
11
11
  var startDate = params.startDate,
12
12
  endDate = params.endDate,
13
13
  config = params.config,
14
14
  rawResources = params.rawResources,
15
15
  resourceProductMap = params.resourceProductMap,
16
- resolveConfig = params.resolveConfig,
17
- buildSlotPriceMap = params.buildSlotPriceMap;
16
+ quotationModule = params.quotationModule,
17
+ resolveConfig = params.resolveConfig;
18
18
  var result = [];
19
- var productIds = buildSlotPriceMap ? _toConsumableArray(new Set(_toConsumableArray(resourceProductMap.values()).flat().map(function (m) {
19
+ var productIds = quotationModule ? _toConsumableArray(new Set(_toConsumableArray(resourceProductMap.values()).flat().map(function (m) {
20
20
  return m.productId;
21
21
  }))) : [];
22
22
  var cursor = dayjs(startDate);
23
23
  var end = dayjs(endDate);
24
- while (!cursor.isAfter(end)) {
25
- var _date = cursor.format('YYYY-MM-DD');
26
- var effectiveConfig = (resolveConfig === null || resolveConfig === void 0 ? void 0 : resolveConfig(_date)) || config;
27
- var slotPriceMap = buildSlotPriceMap && productIds.length ? buildSlotPriceMap(_date, effectiveConfig, productIds) : undefined;
24
+ var _loop = function _loop() {
25
+ var date = cursor.format('YYYY-MM-DD');
26
+ var effectiveConfig = (resolveConfig === null || resolveConfig === void 0 ? void 0 : resolveConfig(date)) || config;
27
+ var quotationPriceMap;
28
+ if (quotationModule && productIds.length) {
29
+ var timeLabels = generateTimeLabels(effectiveConfig);
30
+ var timePoints = timeLabels.map(function (label) {
31
+ return "".concat(date, " ").concat(label);
32
+ });
33
+ quotationPriceMap = quotationModule.buildProductPriceMap({
34
+ productIds: productIds,
35
+ timePoints: timePoints
36
+ });
37
+ }
28
38
  var grid = buildTimeSlotGrid({
29
- date: _date,
39
+ date: date,
30
40
  config: effectiveConfig,
31
41
  rawResources: rawResources,
32
42
  resourceProductMap: resourceProductMap,
33
- slotPriceMap: slotPriceMap
43
+ quotationPriceMap: quotationPriceMap
34
44
  });
35
45
  var totalSlots = 0;
36
46
  var availableSlots = 0;
@@ -68,7 +78,7 @@ export function buildDateRangeSummary(params) {
68
78
  } finally {
69
79
  _iterator.f();
70
80
  }
71
- var status = void 0;
81
+ var status;
72
82
  if (totalSlots === 0) {
73
83
  status = 'unavailable';
74
84
  } else if (availableSlots === 0) {
@@ -79,13 +89,16 @@ export function buildDateRangeSummary(params) {
79
89
  status = 'available';
80
90
  }
81
91
  result.push({
82
- date: _date,
92
+ date: date,
83
93
  status: status,
84
94
  startingPrice: lowestPrice !== null ? lowestPrice.toFixed(2) : null,
85
95
  totalSlots: totalSlots,
86
96
  availableSlots: availableSlots
87
97
  });
88
98
  cursor = cursor.add(1, 'day');
99
+ };
100
+ while (!cursor.isAfter(end)) {
101
+ _loop();
89
102
  }
90
103
  return result;
91
104
  }
@@ -5,6 +5,12 @@ export declare function mergeConsecutiveSlots(slots: VenueSlotSelection[]): Merg
5
5
  export declare function buildPriceBreakdown(params: {
6
6
  group: MergedSlotGroup;
7
7
  productId: number;
8
+ quotation?: {
9
+ getQuotationShelfId: (p: {
10
+ productId: number;
11
+ datetime: string;
12
+ }) => number;
13
+ };
8
14
  }): PriceBreakdownEntry[];
9
15
  export interface BuildVenueBookingParams {
10
16
  group: MergedSlotGroup;
@@ -51,7 +51,9 @@ export function mergeConsecutiveSlots(slots) {
51
51
  return groups;
52
52
  }
53
53
  export function buildPriceBreakdown(params) {
54
- var group = params.group;
54
+ var group = params.group,
55
+ productId = params.productId,
56
+ quotation = params.quotation;
55
57
  if (!group.slots.length) return [];
56
58
  var entries = [];
57
59
  var _iterator = _createForOfIteratorHelper(group.slots),
@@ -60,10 +62,14 @@ export function buildPriceBreakdown(params) {
60
62
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
61
63
  var slot = _step.value;
62
64
  var unitPrice = Number(slot.price || '0');
65
+ var shelfId = quotation ? quotation.getQuotationShelfId({
66
+ productId: productId,
67
+ datetime: slot.startTime
68
+ }) : 0;
63
69
  var startHm = dayjs(slot.startTime, 'YYYY-MM-DD HH:mm').format('YYYY-MM-DD HH:mm');
64
70
  var endHm = dayjs(slot.endTime, 'YYYY-MM-DD HH:mm').format('YYYY-MM-DD HH:mm');
65
71
  var last = entries[entries.length - 1];
66
- if (last && last.unit_price === unitPrice && last.quotation_shelf_id === 0 && last.end_time === startHm) {
72
+ if (last && last.unit_price === unitPrice && last.quotation_shelf_id === shelfId && last.end_time === startHm) {
67
73
  last.end_time = endHm;
68
74
  last.quantity += 1;
69
75
  } else {
@@ -71,7 +77,7 @@ export function buildPriceBreakdown(params) {
71
77
  start_time: startHm,
72
78
  end_time: endHm,
73
79
  unit_price: unitPrice,
74
- quotation_shelf_id: 0,
80
+ quotation_shelf_id: shelfId,
75
81
  quantity: 1
76
82
  });
77
83
  }
@@ -27,8 +27,6 @@ export declare function buildTimeSlotGrid(params: {
27
27
  config: VenueBookingSlotConfig;
28
28
  rawResources: VenueResourceRawData[];
29
29
  resourceProductMap: Map<number | string, ResourceProductMapping[]>;
30
- /** @deprecated 使用 slotPriceMap */
31
30
  quotationPriceMap?: Map<string, string | null>;
32
- slotPriceMap?: Map<string, string | null>;
33
31
  }): VenueTimeSlotGrid;
34
32
  export {};
@@ -230,7 +230,6 @@ function buildProductSlots(params) {
230
230
  now = params.now,
231
231
  crossDay = params.crossDay,
232
232
  quotationPriceMap = params.quotationPriceMap,
233
- slotPriceMap = params.slotPriceMap,
234
233
  childRawResources = params.childRawResources,
235
234
  childTimesCache = params.childTimesCache,
236
235
  childEventsCache = params.childEventsCache,
@@ -240,7 +239,7 @@ function buildProductSlots(params) {
240
239
  _step7;
241
240
  try {
242
241
  for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
243
- var _resolvedPriceMap$get;
242
+ var _quotationPriceMap$ge;
244
243
  var label = _step7.value;
245
244
  var _label$split$map = label.split(':').map(Number),
246
245
  _label$split$map2 = _slicedToArray(_label$split$map, 1),
@@ -299,12 +298,11 @@ function buildProductSlots(params) {
299
298
  }
300
299
  var isBookable = status === 'available' || status === 'partially_occupied';
301
300
  var slotStartStr = slotStart.format('YYYY-MM-DD HH:mm');
302
- var resolvedPriceMap = slotPriceMap !== null && slotPriceMap !== void 0 ? slotPriceMap : quotationPriceMap;
303
301
  slots.push({
304
302
  startTime: slotStartStr,
305
303
  endTime: slotEnd.format('YYYY-MM-DD HH:mm'),
306
304
  status: status,
307
- price: isBookable ? (_resolvedPriceMap$get = resolvedPriceMap === null || resolvedPriceMap === void 0 ? void 0 : resolvedPriceMap.get("".concat(mapping.productId, ":").concat(slotStartStr))) !== null && _resolvedPriceMap$get !== void 0 ? _resolvedPriceMap$get : mapping.price : null,
305
+ price: isBookable ? (_quotationPriceMap$ge = quotationPriceMap === null || quotationPriceMap === void 0 ? void 0 : quotationPriceMap.get("".concat(mapping.productId, ":").concat(slotStartStr))) !== null && _quotationPriceMap$ge !== void 0 ? _quotationPriceMap$ge : mapping.price : null,
308
306
  resourceId: resource.resourceId,
309
307
  resourceFormId: resource.formId,
310
308
  capacity: status === 'past' || status === 'unavailable' ? null : resCapacity,
@@ -324,9 +322,7 @@ export function buildTimeSlotGrid(params) {
324
322
  config = params.config,
325
323
  rawResources = params.rawResources,
326
324
  resourceProductMap = params.resourceProductMap,
327
- quotationPriceMap = params.quotationPriceMap,
328
- slotPriceMap = params.slotPriceMap;
329
- var resolvedPriceMap = slotPriceMap !== null && slotPriceMap !== void 0 ? slotPriceMap : quotationPriceMap;
325
+ quotationPriceMap = params.quotationPriceMap;
330
326
  var timeLabels = generateTimeLabels(config);
331
327
  var now = dayjs();
332
328
  var crossDay = isBusinessHoursCrossDay(config);
@@ -381,8 +377,7 @@ export function buildTimeSlotGrid(params) {
381
377
  resCapacity: resCapacity,
382
378
  now: now,
383
379
  crossDay: crossDay,
384
- quotationPriceMap: resolvedPriceMap,
385
- slotPriceMap: resolvedPriceMap,
380
+ quotationPriceMap: quotationPriceMap,
386
381
  childRawResources: childRawResources,
387
382
  childTimesCache: childTimesCache,
388
383
  childEventsCache: childEventsCache,
package/lib/index.d.ts CHANGED
@@ -7,6 +7,5 @@ export * from './modules';
7
7
  export * from './plugins';
8
8
  export * from './solution';
9
9
  export { PisellOSCore } from './core';
10
- export { DataVariantEvaluator } from './model/strategy/adapter/dataVariant/evaluator';
11
10
  import PisellOSCore from './core';
12
11
  export default PisellOSCore;
package/lib/index.js CHANGED
@@ -30,7 +30,6 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/index.ts
31
31
  var src_exports = {};
32
32
  __export(src_exports, {
33
- DataVariantEvaluator: () => import_evaluator.DataVariantEvaluator,
34
33
  PisellOSCore: () => import_core.PisellOSCore,
35
34
  default: () => src_default
36
35
  });
@@ -40,12 +39,10 @@ __reExport(src_exports, require("./modules"), module.exports);
40
39
  __reExport(src_exports, require("./plugins"), module.exports);
41
40
  __reExport(src_exports, require("./solution"), module.exports);
42
41
  var import_core = require("./core");
43
- var import_evaluator = require("./model/strategy/adapter/dataVariant/evaluator");
44
42
  var import_core2 = __toESM(require("./core"));
45
43
  var src_default = import_core2.default;
46
44
  // Annotate the CommonJS export names for ESM import in node:
47
45
  0 && (module.exports = {
48
- DataVariantEvaluator,
49
46
  PisellOSCore,
50
47
  ...require("./types"),
51
48
  ...require("./modules"),
@@ -5,7 +5,3 @@ export { PromotionEvaluator } from './promotion/evaluator';
5
5
  export { PromotionAdapter } from './promotion/adapter';
6
6
  export { ItemRuleEvaluator } from './itemRule/evaluator';
7
7
  export { ItemRuleAdapter } from './itemRule/adapter';
8
- export { DataVariantEvaluator } from './dataVariant/evaluator';
9
- export { DataVariantAdapter } from './dataVariant/adapter';
10
- export { runDataVariantDemo } from './dataVariant/examples';
11
- export * from './dataVariant/type';
@@ -30,15 +30,12 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/model/strategy/adapter/index.ts
31
31
  var adapter_exports = {};
32
32
  __export(adapter_exports, {
33
- DataVariantAdapter: () => import_adapter3.DataVariantAdapter,
34
- DataVariantEvaluator: () => import_evaluator4.DataVariantEvaluator,
35
33
  ItemRuleAdapter: () => import_adapter2.ItemRuleAdapter,
36
34
  ItemRuleEvaluator: () => import_evaluator3.ItemRuleEvaluator,
37
35
  PromotionAdapter: () => import_adapter.PromotionAdapter,
38
36
  PromotionEvaluator: () => import_evaluator2.PromotionEvaluator,
39
37
  WalletPassAdapter: () => import_walletPass.default,
40
- WalletPassEvaluator: () => import_evaluator.WalletPassEvaluator,
41
- runDataVariantDemo: () => import_examples.runDataVariantDemo
38
+ WalletPassEvaluator: () => import_evaluator.WalletPassEvaluator
42
39
  });
43
40
  module.exports = __toCommonJS(adapter_exports);
44
41
  __reExport(adapter_exports, require("./type"), module.exports);
@@ -48,21 +45,13 @@ var import_evaluator2 = require("./promotion/evaluator");
48
45
  var import_adapter = require("./promotion/adapter");
49
46
  var import_evaluator3 = require("./itemRule/evaluator");
50
47
  var import_adapter2 = require("./itemRule/adapter");
51
- var import_evaluator4 = require("./dataVariant/evaluator");
52
- var import_adapter3 = require("./dataVariant/adapter");
53
- var import_examples = require("./dataVariant/examples");
54
- __reExport(adapter_exports, require("./dataVariant/type"), module.exports);
55
48
  // Annotate the CommonJS export names for ESM import in node:
56
49
  0 && (module.exports = {
57
- DataVariantAdapter,
58
- DataVariantEvaluator,
59
50
  ItemRuleAdapter,
60
51
  ItemRuleEvaluator,
61
52
  PromotionAdapter,
62
53
  PromotionEvaluator,
63
54
  WalletPassAdapter,
64
55
  WalletPassEvaluator,
65
- runDataVariantDemo,
66
- ...require("./type"),
67
- ...require("./dataVariant/type")
56
+ ...require("./type")
68
57
  });
@@ -1,49 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
-
29
- // src/model/strategy/adapter/promotion/index.ts
30
- var promotion_exports = {};
31
- __export(promotion_exports, {
32
- BUY_X_GET_Y_FREE_STRATEGY: () => import_examples.BUY_X_GET_Y_FREE_STRATEGY,
33
- PromotionAdapter: () => import_adapter.PromotionAdapter,
34
- PromotionEvaluator: () => import_evaluator.PromotionEvaluator,
35
- X_ITEMS_FOR_Y_PRICE_STRATEGY: () => import_examples.X_ITEMS_FOR_Y_PRICE_STRATEGY,
36
- default: () => import_adapter2.default
37
- });
38
- module.exports = __toCommonJS(promotion_exports);
39
- var import_evaluator = require("./evaluator");
40
- var import_adapter = require("./adapter");
41
- var import_adapter2 = __toESM(require("./adapter"));
42
- var import_examples = require("./examples");
43
- // Annotate the CommonJS export names for ESM import in node:
44
- 0 && (module.exports = {
45
- BUY_X_GET_Y_FREE_STRATEGY,
46
- PromotionAdapter,
47
- PromotionEvaluator,
48
- X_ITEMS_FOR_Y_PRICE_STRATEGY
49
- });
@@ -34,7 +34,7 @@ __export(changePrice_exports, {
34
34
  module.exports = __toCommonJS(changePrice_exports);
35
35
  var import_decimal = __toESM(require("decimal.js"));
36
36
  async function updateAllCartItemPrice(cartItems, priceData, getProduct, updateCart, updateItemInitInfo) {
37
- var _a, _b;
37
+ var _a, _b, _c, _d, _e, _f;
38
38
  for (const item of cartItems) {
39
39
  const targetProduct = priceData.find((n) => n.id === item.id);
40
40
  const cartProduct = await getProduct(
@@ -44,10 +44,14 @@ async function updateAllCartItemPrice(cartItems, priceData, getProduct, updateCa
44
44
  if (!productInfo) {
45
45
  productInfo = item._productOrigin;
46
46
  }
47
+ const variantId = ((_a = item == null ? void 0 : item._productOrigin) == null ? void 0 : _a.product_variant_id) ?? ((_c = (_b = item == null ? void 0 : item._origin) == null ? void 0 : _b.product) == null ? void 0 : _c.product_variant_id);
48
+ const targetVariant = (_d = targetProduct == null ? void 0 : targetProduct.variant) == null ? void 0 : _d.find(
49
+ (variant) => Number(variant.id) === Number(variantId)
50
+ );
47
51
  let bundle = item._bundleOrigin;
48
- productInfo.price = targetProduct == null ? void 0 : targetProduct.price;
49
- productInfo.base_price = targetProduct == null ? void 0 : targetProduct.base_price;
50
- productInfo.product_variant_id = (_a = item._productOrigin) == null ? void 0 : _a.product_variant_id;
52
+ productInfo.price = (targetVariant == null ? void 0 : targetVariant.price) ?? (targetProduct == null ? void 0 : targetProduct.price) ?? productInfo.price;
53
+ productInfo.base_price = (targetVariant == null ? void 0 : targetVariant.base_price) ?? (targetProduct == null ? void 0 : targetProduct.base_price) ?? productInfo.base_price;
54
+ productInfo.product_variant_id = (_e = item._productOrigin) == null ? void 0 : _e.product_variant_id;
51
55
  bundle = bundle == null ? void 0 : bundle.map((n) => {
52
56
  var _a2;
53
57
  const targetBundle = (_a2 = targetProduct == null ? void 0 : targetProduct.bundle_group) == null ? void 0 : _a2.find(
@@ -76,14 +80,14 @@ async function updateAllCartItemPrice(cartItems, priceData, getProduct, updateCa
76
80
  return n;
77
81
  });
78
82
  if (targetProduct == null ? void 0 : targetProduct.variant) {
79
- productInfo.variant = (_b = productInfo.variant) == null ? void 0 : _b.map((n) => {
83
+ productInfo.variant = (_f = productInfo.variant) == null ? void 0 : _f.map((n) => {
80
84
  var _a2;
81
- const targetVariant = (_a2 = targetProduct.variant) == null ? void 0 : _a2.find((m) => m.id === n.id);
82
- if (targetVariant) {
85
+ const targetVariant2 = (_a2 = targetProduct.variant) == null ? void 0 : _a2.find((m) => m.id === n.id);
86
+ if (targetVariant2) {
83
87
  return {
84
88
  ...n,
85
- price: targetVariant.price,
86
- base_price: targetVariant.base_price
89
+ price: targetVariant2.price,
90
+ base_price: targetVariant2.base_price
87
91
  };
88
92
  }
89
93
  return n;
@@ -1,6 +1,6 @@
1
1
  import { Module, PisellCore, ModuleOptions } from '../../types';
2
2
  import { BaseModule } from '../BaseModule';
3
- import { Discount, DiscountModuleAPI, DiscountWithReason, DiscountPrepareConfigResult } from './types';
3
+ import { Discount, DiscountModuleAPI, DiscountWithReason } from './types';
4
4
  export declare class DiscountModule extends BaseModule implements Module, DiscountModuleAPI {
5
5
  protected defaultName: string;
6
6
  protected defaultVersion: string;
@@ -22,12 +22,9 @@ export declare class DiscountModule extends BaseModule implements Module, Discou
22
22
  with_discount_card: 0 | 1;
23
23
  customer_id: number;
24
24
  with_wallet_pass_holder: 0 | 1;
25
- with_available_wallet_flag?: 0 | 1;
26
- with_available_wallet_pass_flag?: 0 | 1;
27
25
  request_timezone: string;
28
26
  order_id?: number;
29
- }): Promise<DiscountPrepareConfigResult>;
30
- private extractAvailableWalletIds;
27
+ }): Promise<Discount[]>;
31
28
  batchSearch(code: string, options?: {
32
29
  customerId?: number;
33
30
  orderId?: number;
@@ -100,17 +100,7 @@ var DiscountModule = class extends import_BaseModule.BaseModule {
100
100
  const goodPassList = this.filterEnabledDiscountList(
101
101
  [...((_a = prepareConfig == null ? void 0 : prepareConfig.data) == null ? void 0 : _a.good_pass_list) || [], ...((_b = prepareConfig == null ? void 0 : prepareConfig.data) == null ? void 0 : _b.discount_card_list) || []]
102
102
  ) || [];
103
- return {
104
- discountList: goodPassList,
105
- availableWalletIds: this.extractAvailableWalletIds(prepareConfig == null ? void 0 : prepareConfig.data)
106
- };
107
- }
108
- extractAvailableWalletIds(data) {
109
- const availableWalletList = Array.isArray(data == null ? void 0 : data.avaiable_wallet_list) ? data.avaiable_wallet_list : Array.isArray(data == null ? void 0 : data.available_wallet_list) ? data.available_wallet_list : [];
110
- const availableWalletPassList = Array.isArray(data == null ? void 0 : data.available_wallet_pass_list) ? data.available_wallet_pass_list : [];
111
- const walletIds = availableWalletList.map((item) => Number(item == null ? void 0 : item.wallet_id)).filter((id) => Number.isFinite(id) && id > 0);
112
- const walletPassProductIds = availableWalletPassList.map((item) => Number(item == null ? void 0 : item.product_id)).filter((id) => Number.isFinite(id) && id > 0);
113
- return Array.from(/* @__PURE__ */ new Set([...walletIds, ...walletPassProductIds]));
103
+ return goodPassList;
114
104
  }
115
105
  async batchSearch(code, options) {
116
106
  const { customerId, orderId } = options || {};
@@ -68,10 +68,6 @@ export interface DiscountWithReason {
68
68
  discountList: Discount[];
69
69
  unavailableReasonKey: DiscountFilterRejectKey | null;
70
70
  }
71
- export interface DiscountPrepareConfigResult {
72
- discountList: Discount[];
73
- availableWalletIds: number[];
74
- }
75
71
  interface ExtensionData {
76
72
  id: number;
77
73
  shop_id: number;
@@ -42,7 +42,6 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
42
42
  action?: 'create';
43
43
  }): Promise<void>;
44
44
  getDiscountList(): Discount[];
45
- getAvailableWalletIds(): number[];
46
45
  scanCode(code: string, customerId?: number): Promise<{
47
46
  isAvailable: boolean;
48
47
  discountList: Discount[];
@@ -76,9 +76,6 @@ var OrderModule = class extends import_BaseModule.BaseModule {
76
76
  if (!this.store.tempOrder) {
77
77
  this.store.tempOrder = null;
78
78
  }
79
- if (!Array.isArray(this.store.availableWalletIds)) {
80
- this.store.availableWalletIds = [];
81
- }
82
79
  this.request = this.core.getPlugin("request");
83
80
  this.window = this.core.getPlugin("window");
84
81
  const otherParams = options.otherParams || {};
@@ -166,18 +163,14 @@ var OrderModule = class extends import_BaseModule.BaseModule {
166
163
  // ─── Discount: 公共 API ───
167
164
  async loadDiscountConfig(params) {
168
165
  var _a, _b, _c, _d;
169
- const prepareConfig = await ((_a = this.store.discount) == null ? void 0 : _a.loadPrepareConfig({
166
+ const discountList = await ((_a = this.store.discount) == null ? void 0 : _a.loadPrepareConfig({
170
167
  customer_id: params.customerId,
171
168
  action: params.action || "create",
172
169
  with_good_pass: 1,
173
170
  with_discount_card: 1,
174
171
  with_wallet_pass_holder: 1,
175
- with_available_wallet_flag: 1,
176
- with_available_wallet_pass_flag: 1,
177
172
  request_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
178
173
  }));
179
- const discountList = prepareConfig == null ? void 0 : prepareConfig.discountList;
180
- this.store.availableWalletIds = (prepareConfig == null ? void 0 : prepareConfig.availableWalletIds) || [];
181
174
  if (discountList) {
182
175
  (_b = this.store.discount) == null ? void 0 : _b.setDiscountList(discountList);
183
176
  }
@@ -189,9 +182,6 @@ var OrderModule = class extends import_BaseModule.BaseModule {
189
182
  var _a;
190
183
  return ((_a = this.store.discount) == null ? void 0 : _a.getDiscountList()) || [];
191
184
  }
192
- getAvailableWalletIds() {
193
- return this.store.availableWalletIds || [];
194
- }
195
185
  async scanCode(code, customerId) {
196
186
  var _a, _b, _c, _d;
197
187
  const resultDiscountWithReason = await ((_a = this.store.discount) == null ? void 0 : _a.batchSearch(code, { customerId })) || { discountList: [], unavailableReasonKey: null };
@@ -15,7 +15,6 @@ export interface OrderState {
15
15
  discountList: any[];
16
16
  discount: DiscountModule | null;
17
17
  rules: RulesModule | null;
18
- availableWalletIds?: number[];
19
18
  }
20
19
  /** 更新购物车行:仅传 SKU 时命中同 SKU 第一行;多行同 SKU 须传 identity_key / 选项指纹等 */
21
20
  export interface UpdateProductInOrderParams {
@@ -249,6 +248,5 @@ export interface OrderModuleAPI {
249
248
  action?: 'create';
250
249
  }) => Promise<void>;
251
250
  getDiscountList: () => Discount[];
252
- getAvailableWalletIds: () => number[];
253
251
  applyDiscount: () => void;
254
252
  }
@@ -11,7 +11,7 @@ export declare class ProductList extends BaseModule implements Module {
11
11
  constructor(name?: string, version?: string);
12
12
  initialize(core: PisellCore, options: any): Promise<void>;
13
13
  storeChange(path?: string, value?: any): Promise<void>;
14
- loadProducts({ category_ids, product_ids, collection, menu_list_ids, customer_id: paramsCustomerId, with_count, schedule_datetime, schedule_date, cacheId, with_schedule, with_extra, }: {
14
+ loadProducts({ category_ids, product_ids, collection, menu_list_ids, customer_id: paramsCustomerId, with_count, schedule_datetime, schedule_date, cacheId, with_schedule, }: {
15
15
  category_ids?: number[];
16
16
  product_ids?: number[];
17
17
  collection?: number | string[];
@@ -22,8 +22,6 @@ export declare class ProductList extends BaseModule implements Module {
22
22
  menu_list_ids?: number[];
23
23
  with_count?: string[];
24
24
  with_schedule?: number;
25
- /** 追加到默认 with 字段(如 dataVariants) */
26
- with_extra?: string[];
27
25
  }): Promise<any>;
28
26
  loadProductsPrice({ ids, customer_id, schedule_date, channel, }: {
29
27
  ids?: number[];
@@ -59,8 +59,7 @@ var ProductList = class extends import_BaseModule.BaseModule {
59
59
  schedule_datetime,
60
60
  schedule_date,
61
61
  cacheId,
62
- with_schedule,
63
- with_extra = []
62
+ with_schedule
64
63
  }) {
65
64
  var _a;
66
65
  let userPlugin = this.core.getPlugin("user");
@@ -70,49 +69,44 @@ var ProductList = class extends import_BaseModule.BaseModule {
70
69
  } catch (error) {
71
70
  console.error(error);
72
71
  }
73
- try {
74
- const productsData = await this.request.post(
75
- `/product/query`,
76
- {
77
- open_quotation: 1,
78
- open_bundle: 0,
79
- exclude_extension_type: [
80
- "product_party",
81
- "product_event",
82
- "product_series_event",
83
- "product_package_ticket",
84
- "ticket",
85
- "event_item"
86
- ],
87
- with: ["category", "collection", "resourceRelation", ...with_extra],
88
- status: "published",
89
- num: 500,
90
- skip: 1,
91
- customer_id,
92
- category_ids,
93
- ids: product_ids,
94
- collection,
95
- front_end_cache_id: cacheId,
96
- with_count,
97
- // client_schedule_ids: schedule_ids,
98
- schedule_date,
99
- schedule_datetime,
100
- // application_code: this.otherParams?.channel === 'online_store' ? 'online-store' : this.otherParams?.channel,
101
- application_code: "online-store",
102
- with_schedule,
103
- is_eject: 1,
104
- menu_list_ids,
105
- open_deposit: 1
106
- },
107
- { useCache: true, customToast: () => {
108
- } }
109
- );
110
- const sortedList = (productsData.data.list || []).slice().sort((a, b) => Number(b.sort) - Number(a.sort));
111
- this.addProduct(sortedList);
112
- return sortedList;
113
- } catch (error) {
114
- return error;
115
- }
72
+ const productsData = await this.request.post(
73
+ `/product/query`,
74
+ {
75
+ open_quotation: 1,
76
+ open_bundle: 0,
77
+ exclude_extension_type: [
78
+ "product_party",
79
+ "product_event",
80
+ "product_series_event",
81
+ "product_package_ticket",
82
+ "ticket",
83
+ "event_item"
84
+ ],
85
+ with: ["category", "collection", "resourceRelation"],
86
+ status: "published",
87
+ num: 500,
88
+ skip: 1,
89
+ customer_id,
90
+ category_ids,
91
+ ids: product_ids,
92
+ collection,
93
+ front_end_cache_id: cacheId,
94
+ menu_list_ids,
95
+ with_count,
96
+ // client_schedule_ids: schedule_ids,
97
+ schedule_date,
98
+ // application_code: this.otherParams?.channel === 'online_store' ? 'online-store' : this.otherParams?.channel,
99
+ application_code: "online-store",
100
+ with_schedule,
101
+ schedule_datetime,
102
+ is_eject: 1
103
+ },
104
+ { useCache: true, customToast: () => {
105
+ } }
106
+ );
107
+ const sortedList = (productsData.data.list || []).slice().sort((a, b) => Number(b.sort) - Number(a.sort));
108
+ this.addProduct(sortedList);
109
+ return sortedList;
116
110
  }
117
111
  async loadProductsPrice({
118
112
  ids = [],