@pisell/pisellos 2.2.273 → 2.2.274

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 (105) hide show
  1. package/dist/core/index.d.ts +0 -2
  2. package/dist/core/index.js +0 -7
  3. package/dist/model/strategy/adapter/promotion/adapter.d.ts +0 -4
  4. package/dist/model/strategy/adapter/promotion/adapter.js +0 -23
  5. package/dist/model/strategy/adapter/promotion/evaluator.d.ts +0 -17
  6. package/dist/model/strategy/adapter/promotion/evaluator.js +6 -279
  7. package/dist/model/strategy/adapter/promotion/examples.d.ts +0 -86
  8. package/dist/model/strategy/adapter/promotion/examples.js +0 -99
  9. package/dist/model/strategy/adapter/promotion/index.d.ts +1 -1
  10. package/dist/model/strategy/adapter/promotion/index.js +9 -0
  11. package/dist/model/strategy/adapter/promotion/type.d.ts +2 -90
  12. package/dist/model/strategy/adapter/promotion/type.js +0 -45
  13. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +12 -10
  14. package/dist/modules/OpenData/index.d.ts +0 -2
  15. package/dist/modules/OpenData/index.js +0 -8
  16. package/dist/modules/Order/index.d.ts +13 -32
  17. package/dist/modules/Order/index.js +555 -771
  18. package/dist/modules/Order/types.d.ts +22 -36
  19. package/dist/modules/Order/types.js +11 -0
  20. package/dist/modules/Order/utils/orderCollectionIdentity.js +2 -7
  21. package/dist/modules/Order/utils.js +6 -10
  22. package/dist/modules/Payment/index.d.ts +0 -2
  23. package/dist/modules/Payment/index.js +50 -79
  24. package/dist/modules/Payment/types.d.ts +27 -29
  25. package/dist/modules/Payment/types.js +3 -5
  26. package/dist/modules/Rules/index.d.ts +0 -1
  27. package/dist/modules/Rules/index.js +39 -55
  28. package/dist/modules/SalesSummary/utils.js +7 -1
  29. package/dist/server/index.d.ts +0 -16
  30. package/dist/server/index.js +1036 -1933
  31. package/dist/server/modules/order/index.d.ts +4 -54
  32. package/dist/server/modules/order/index.js +695 -1595
  33. package/dist/server/modules/order/types.d.ts +3 -11
  34. package/dist/server/modules/order/types.js +1 -1
  35. package/dist/solution/BaseSales/index.d.ts +25 -59
  36. package/dist/solution/BaseSales/index.js +490 -767
  37. package/dist/solution/BaseSales/utils/cartPromotion.d.ts +1 -3
  38. package/dist/solution/BaseSales/utils/cartPromotion.js +36 -93
  39. package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -6
  40. package/dist/solution/BookingByStep/index.d.ts +1 -1
  41. package/dist/solution/BookingTicket/index.d.ts +5 -21
  42. package/dist/solution/BookingTicket/index.js +49 -126
  43. package/dist/solution/BookingTicket/types.d.ts +3 -0
  44. package/dist/solution/BookingTicket/utils/cartView.js +44 -32
  45. package/dist/solution/Sales/index.d.ts +0 -1
  46. package/dist/solution/Sales/index.js +2 -10
  47. package/dist/solution/ScanOrder/index.js +20 -31
  48. package/dist/solution/VenueBooking/index.js +19 -30
  49. package/dist/types/index.d.ts +0 -1
  50. package/lib/core/index.d.ts +0 -2
  51. package/lib/core/index.js +0 -4
  52. package/lib/model/strategy/adapter/promotion/adapter.d.ts +0 -4
  53. package/lib/model/strategy/adapter/promotion/adapter.js +0 -20
  54. package/lib/model/strategy/adapter/promotion/evaluator.d.ts +0 -17
  55. package/lib/model/strategy/adapter/promotion/evaluator.js +0 -235
  56. package/lib/model/strategy/adapter/promotion/examples.d.ts +0 -86
  57. package/lib/model/strategy/adapter/promotion/examples.js +0 -91
  58. package/lib/model/strategy/adapter/promotion/index.d.ts +1 -1
  59. package/lib/model/strategy/adapter/promotion/index.js +0 -2
  60. package/lib/model/strategy/adapter/promotion/type.d.ts +2 -90
  61. package/lib/model/strategy/adapter/promotion/type.js +0 -2
  62. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +3 -1
  63. package/lib/modules/OpenData/index.d.ts +0 -2
  64. package/lib/modules/OpenData/index.js +0 -5
  65. package/lib/modules/Order/index.d.ts +13 -32
  66. package/lib/modules/Order/index.js +142 -201
  67. package/lib/modules/Order/types.d.ts +22 -36
  68. package/lib/modules/Order/utils/orderCollectionIdentity.js +0 -3
  69. package/lib/modules/Order/utils.js +4 -11
  70. package/lib/modules/Payment/index.d.ts +0 -2
  71. package/lib/modules/Payment/index.js +13 -34
  72. package/lib/modules/Payment/types.d.ts +27 -29
  73. package/lib/modules/Payment/types.js +3 -3
  74. package/lib/modules/Rules/index.d.ts +0 -1
  75. package/lib/modules/Rules/index.js +22 -41
  76. package/lib/modules/SalesSummary/utils.js +5 -1
  77. package/lib/server/index.d.ts +0 -16
  78. package/lib/server/index.js +18 -670
  79. package/lib/server/modules/order/index.d.ts +4 -54
  80. package/lib/server/modules/order/index.js +66 -679
  81. package/lib/server/modules/order/types.d.ts +3 -11
  82. package/lib/solution/BaseSales/index.d.ts +25 -59
  83. package/lib/solution/BaseSales/index.js +79 -246
  84. package/lib/solution/BaseSales/utils/cartPromotion.d.ts +1 -3
  85. package/lib/solution/BaseSales/utils/cartPromotion.js +17 -65
  86. package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -6
  87. package/lib/solution/BookingByStep/index.d.ts +1 -1
  88. package/lib/solution/BookingTicket/index.d.ts +5 -21
  89. package/lib/solution/BookingTicket/index.js +8 -59
  90. package/lib/solution/BookingTicket/types.d.ts +3 -0
  91. package/lib/solution/BookingTicket/utils/cartView.js +43 -30
  92. package/lib/solution/Sales/index.d.ts +0 -1
  93. package/lib/solution/Sales/index.js +3 -5
  94. package/lib/solution/ScanOrder/index.js +0 -8
  95. package/lib/solution/VenueBooking/index.js +0 -8
  96. package/lib/types/index.d.ts +0 -1
  97. package/package.json +1 -1
  98. package/dist/modules/Order/payment-utils.d.ts +0 -26
  99. package/dist/modules/Order/payment-utils.js +0 -225
  100. package/dist/utils/payment-number.d.ts +0 -9
  101. package/dist/utils/payment-number.js +0 -69
  102. package/lib/modules/Order/payment-utils.d.ts +0 -26
  103. package/lib/modules/Order/payment-utils.js +0 -224
  104. package/lib/utils/payment-number.d.ts +0 -9
  105. package/lib/utils/payment-number.js +0 -64
@@ -77,43 +77,19 @@ function getOrderProductOriginalPriceForPromotion(product) {
77
77
  }
78
78
  return getOrderProductBasePrice(product);
79
79
  }
80
- var X_ITEMS_FOR_Y_PRICE = "X_ITEMS_FOR_Y_PRICE";
81
- var ITEM_REWARD = "ITEM_REWARD";
82
- function isItemRewardPromotionDiscountItem(item) {
83
- var _a, _b;
84
- return (item == null ? void 0 : item.type) === "product" && ((_a = item == null ? void 0 : item.metadata) == null ? void 0 : _a.source) === "promotion" && ((_b = item == null ? void 0 : item.metadata) == null ? void 0 : _b.actionType) === ITEM_REWARD;
85
- }
86
- function isManagedPromotionDiscountItem(item) {
87
- if ((item == null ? void 0 : item.type) === "promotion")
88
- return true;
89
- return isItemRewardPromotionDiscountItem(item);
90
- }
91
- function wasInPromotionBeforeEvaluation(item) {
92
- var _a, _b;
93
- if (((_b = (_a = item == null ? void 0 : item.metadata) == null ? void 0 : _a._promotion) == null ? void 0 : _b.inPromotion) === true)
94
- return true;
95
- return Array.isArray(item == null ? void 0 : item.discount_list) && item.discount_list.some(isItemRewardPromotionDiscountItem);
96
- }
97
- function updatePromotionDiscountList(item, promotionDiscount, options) {
80
+ function updatePromotionDiscountList(item, promotionDiscount) {
98
81
  let discountList = Array.isArray(item.discount_list) ? [...item.discount_list] : [];
99
- discountList = discountList.filter((d) => !isManagedPromotionDiscountItem(d));
82
+ discountList = discountList.filter((d) => (d == null ? void 0 : d.type) !== "promotion");
100
83
  if (promotionDiscount) {
101
- const discountType = (options == null ? void 0 : options.discountType) || "promotion";
102
84
  discountList.push({
103
- type: discountType,
85
+ type: "promotion",
104
86
  amount: promotionDiscount.amount,
105
87
  discount: {
106
88
  original_amount: promotionDiscount.original_amount,
107
89
  fixed_amount: promotionDiscount.fixed_amount,
108
90
  title: promotionDiscount.title,
109
91
  resource_id: ""
110
- },
111
- ...discountType === "product" ? {
112
- metadata: {
113
- source: "promotion",
114
- actionType: (options == null ? void 0 : options.actionType) || ITEM_REWARD
115
- }
116
- } : {}
92
+ }
117
93
  });
118
94
  }
119
95
  if (discountList.length > 0) {
@@ -122,15 +98,7 @@ function updatePromotionDiscountList(item, promotionDiscount, options) {
122
98
  delete item.discount_list;
123
99
  }
124
100
  }
125
- function evaluatorHasActionType(evaluator, actionType) {
126
- var _a;
127
- const configs = (_a = evaluator == null ? void 0 : evaluator.getStrategyConfigs) == null ? void 0 : _a.call(evaluator);
128
- if (!Array.isArray(configs))
129
- return false;
130
- return configs.some(
131
- (config) => ((config == null ? void 0 : config.actions) || []).some((action) => (action == null ? void 0 : action.type) === actionType)
132
- );
133
- }
101
+ var X_ITEMS_FOR_Y_PRICE = "X_ITEMS_FOR_Y_PRICE";
134
102
  function applyPromoUnitPriceToLine(item, input) {
135
103
  const metadata = item.metadata || (item.metadata = {});
136
104
  const optionSum = (0, import_utils.sumOptionUnitPrice)((0, import_utils.getProductSkuOptions)(item)).toNumber();
@@ -157,9 +125,6 @@ function applyPromoUnitPriceToLine(item, input) {
157
125
  amount: discountAmount,
158
126
  original_amount: catalogSource,
159
127
  fixed_amount: discountAmount
160
- }, {
161
- actionType: input.actionType,
162
- discountType: input.actionType === ITEM_REWARD ? "product" : "promotion"
163
128
  });
164
129
  } else {
165
130
  updatePromotionDiscountList(item, null);
@@ -367,8 +332,11 @@ function getProductLineNoteSignature(product) {
367
332
  return uid ? `note:${uid}` : `note:${normalizedNote}`;
368
333
  }
369
334
  function getPromotionLineMergeBoundary(product) {
370
- var _a;
371
- if (((_a = product == null ? void 0 : product.metadata) == null ? void 0 : _a.is_edit_for_runtime) !== true)
335
+ var _a, _b;
336
+ if (Number(((_a = product == null ? void 0 : product.product_sku) == null ? void 0 : _a.open_sold_weight) || 0) === 1) {
337
+ return `weighing:${getOrderProductUid(product)}`;
338
+ }
339
+ if (((_b = product == null ? void 0 : product.metadata) == null ? void 0 : _b.is_edit_for_runtime) !== true)
372
340
  return "";
373
341
  return `edit:${getOrderProductUid(product)}`;
374
342
  }
@@ -431,13 +399,14 @@ function buildConsolidateKeyForPromotion(item) {
431
399
  ].join("#");
432
400
  }
433
401
  function consolidateMainProductsForPromotion(entries) {
402
+ var _a, _b;
434
403
  if (!Array.isArray(entries) || entries.length <= 1) {
435
404
  return [...entries || []];
436
405
  }
437
406
  const groups = /* @__PURE__ */ new Map();
438
407
  for (const { item, originalListIndex } of entries) {
439
408
  const key = buildConsolidateKeyForPromotion(item);
440
- const wasInPromotion = wasInPromotionBeforeEvaluation(item);
409
+ const wasInPromotion = ((_b = (_a = item == null ? void 0 : item.metadata) == null ? void 0 : _a._promotion) == null ? void 0 : _b.inPromotion) === true;
441
410
  const existing = groups.get(key);
442
411
  if (!existing) {
443
412
  const mergedItem = (0, import_lodash_es.cloneDeep)(item);
@@ -503,9 +472,6 @@ function splitXItemsPromoLinesByGroup(lines, strategyActionMap) {
503
472
  function generateNumericId() {
504
473
  return Math.floor(Math.random() * 1e9) + Date.now();
505
474
  }
506
- function isBookingEditProductLine(product) {
507
- return (product == null ? void 0 : product.booking_id) !== void 0 && (product == null ? void 0 : product.booking_id) !== null && product.booking_id !== 0 && product.booking_id !== "0";
508
- }
509
475
  function convertToPromotionProduct(product, index) {
510
476
  const metadata = (product == null ? void 0 : product.metadata) || {};
511
477
  const numericId = generateNumericId();
@@ -518,7 +484,6 @@ function convertToPromotionProduct(product, index) {
518
484
  price: getOrderProductOriginalPriceForPromotion(product),
519
485
  quantity: Number((product == null ? void 0 : product.num) ?? 1) || 1,
520
486
  bundle: getProductBundleForEvaluator(product),
521
- _promotionOnlyForItemReward: isBookingEditProductLine(product),
522
487
  _originalItem: originalItem,
523
488
  _originalId: getOrderProductUid(product),
524
489
  _originalIndex: index
@@ -620,9 +585,6 @@ function resolveStrategyRequiredQuantity(matched) {
620
585
  if (matched.actionType === "BUY_X_GET_Y_FREE") {
621
586
  return Number(detail.buyQuantity) || 1;
622
587
  }
623
- if (matched.actionType === "ITEM_REWARD") {
624
- return Number(detail.triggerQuantity) || 1;
625
- }
626
588
  return 1;
627
589
  }
628
590
  function resolveStrategyEligibleProducts(matched) {
@@ -733,10 +695,6 @@ function processCartPromotion(list, evaluator, options) {
733
695
  };
734
696
  if (!list || list.length === 0 || !evaluator)
735
697
  return empty;
736
- const shouldIncludeEditProductsForItemReward = evaluatorHasActionType(
737
- evaluator,
738
- ITEM_REWARD
739
- );
740
698
  const mainProductsWithIndex = [];
741
699
  const existingGiftsWithIndex = [];
742
700
  const editProductsWithIndex = [];
@@ -747,12 +705,8 @@ function processCartPromotion(list, evaluator, options) {
747
705
  editProductsWithIndex.push({ item, originalListIndex: i });
748
706
  } else if (giftInfo) {
749
707
  existingGiftsWithIndex.push({ item, originalListIndex: i });
750
- } else if (isBookingEditProductLine(item)) {
751
- if (shouldIncludeEditProductsForItemReward) {
752
- mainProductsWithIndex.push({ item, originalListIndex: i });
753
- } else {
754
- editProductsWithIndex.push({ item, originalListIndex: i });
755
- }
708
+ } else if ((item == null ? void 0 : item.booking_id) !== void 0 && (item == null ? void 0 : item.booking_id) !== null && item.booking_id !== 0 && item.booking_id !== "0") {
709
+ editProductsWithIndex.push({ item, originalListIndex: i });
756
710
  } else {
757
711
  mainProductsWithIndex.push({ item, originalListIndex: i });
758
712
  }
@@ -795,8 +749,7 @@ function processCartPromotion(list, evaluator, options) {
795
749
  name: ((_a2 = item == null ? void 0 : item.metadata) == null ? void 0 : _a2.product_name) || (item == null ? void 0 : item.title) || "",
796
750
  price: getOrderProductBasePrice(item),
797
751
  quantity: Number((item == null ? void 0 : item.num) ?? 1) || 1,
798
- bundle: getProductBundleForEvaluator(item),
799
- _promotionOnlyForItemReward: isBookingEditProductLine(item)
752
+ bundle: getProductBundleForEvaluator(item)
800
753
  };
801
754
  });
802
755
  for (let i = 0; i < consolidatedMainProductsWithIndex.length; i++) {
@@ -865,7 +818,7 @@ function processCartPromotion(list, evaluator, options) {
865
818
  const metadata = newItem.metadata || {};
866
819
  const sourceCartNum = (0, import_utils2.getSafeProductNum)(originalItem.num);
867
820
  newItem._sourceCartNum = sourceCartNum;
868
- const wasInPromotion = wasInPromotionBeforeEvaluation(originalItem) || originalItem._wasInPromotionBeforeConsolidate === true;
821
+ const wasInPromotion = ((_a = metadata._promotion) == null ? void 0 : _a.inPromotion) === true || originalItem._wasInPromotionBeforeConsolidate === true;
869
822
  delete metadata._promotion;
870
823
  if (Array.isArray(newItem.product_bundle)) {
871
824
  for (const b of newItem.product_bundle) {
@@ -882,8 +835,7 @@ function processCartPromotion(list, evaluator, options) {
882
835
  applyPromoUnitPriceToLine(newItem, {
883
836
  promoUnitPrice,
884
837
  originalBasePrice,
885
- strategyTitle: (_a = priced.strategyMetadata) == null ? void 0 : _a.name,
886
- actionType: priced.strategyId ? (_b = strategyActionMap.get(priced.strategyId)) == null ? void 0 : _b.actionType : void 0
838
+ strategyTitle: (_b = priced.strategyMetadata) == null ? void 0 : _b.name
887
839
  });
888
840
  } else {
889
841
  const optionSum = (0, import_utils.sumOptionUnitPrice)((0, import_utils.getProductSkuOptions)(newItem)).toNumber();
@@ -82,13 +82,8 @@ export interface ISalesBooking {
82
82
  metadata?: Record<string, any> | null;
83
83
  [key: string]: any;
84
84
  }
85
- export interface ISalesPaymentMetadata extends Record<string, any> {
86
- /** 刷卡机设备快照;OS 不解析内部字段 */
87
- card_reader_snapshot?: Record<string, unknown>;
88
- }
89
85
  export interface ISalesPayment {
90
86
  order_payment_id?: number | null;
91
- payment_number?: string;
92
87
  custom_payment_id?: number;
93
88
  code?: string;
94
89
  name?: string;
@@ -100,7 +95,7 @@ export interface ISalesPayment {
100
95
  status?: string;
101
96
  payment_time?: string | null;
102
97
  service_charge?: Record<string, any> | null;
103
- metadata?: ISalesPaymentMetadata | null;
98
+ metadata?: Record<string, any> | null;
104
99
  [key: string]: any;
105
100
  }
106
101
  export interface ISalesSurcharge {
@@ -311,7 +311,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
311
311
  date: string;
312
312
  status: string;
313
313
  week: string;
314
- weekNum: 0 | 2 | 1 | 6 | 4 | 5 | 3;
314
+ weekNum: 0 | 1 | 2 | 6 | 4 | 3 | 5;
315
315
  }[]>;
316
316
  submitTimeSlot(timeSlots: TimeSliceItem): void;
317
317
  private getScheduleDataByIds;
@@ -46,8 +46,6 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
46
46
  private getIdGeneratorPlugin;
47
47
  private loadOpenDataConfig;
48
48
  getOpenData(): Promise<OpenDataConfig | null>;
49
- /** 清除店铺级 OpenData;下一次 getOpenData 时会重新拉取。 */
50
- clearOpenDataCache(): void;
51
49
  private getShortNumberOrDeviceId;
52
50
  private configureIdGeneratorFromOpenData;
53
51
  private normalizePositiveInteger;
@@ -191,12 +189,10 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
191
189
  */
192
190
  getCustomer(): ICustomer | null;
193
191
  /**
194
- * 通过 ids 获取商品列表;默认只读取内存,显式开启 loadMissing 时按当前订单上下文补查缺失商品。
195
- * 补查直接写入 ProductList,不更新 BookingTicket.productCatalog,避免当前商品列表被查询子集覆盖。
192
+ * 通过 ids 获取商品列表(不加载到模块中)
193
+ * @returns 商品列表
196
194
  */
197
- getProductByIds(ids: number[], options?: {
198
- loadMissing?: boolean;
199
- }): Promise<ProductData[]>;
195
+ getProductByIds(ids: number[]): Promise<ProductData[] | undefined>;
200
196
  /**
201
197
  * 获取日程时间段点
202
198
  * @param params 参数
@@ -326,7 +322,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
326
322
  * 获取当前的客户搜索条件
327
323
  * @returns 当前搜索条件
328
324
  */
329
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
325
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
330
326
  /**
331
327
  * 获取客户列表状态(包含滚动加载相关状态)
332
328
  * @returns 客户状态
@@ -445,19 +441,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
445
441
  * 加车两阶段主决策(规格弹窗 / 资源编辑 / 直接加车)。
446
442
  * 与 ticketBooking `handleSelectProduct` + `handleBooking4Service` 等价。
447
443
  */
448
- decideAddProduct(item: any, options?: Partial<AddProductDecideContext>): {
449
- action: "reloadCatalog";
450
- } | {
451
- action: "add";
452
- cacheItem: any;
453
- } | {
454
- action: "requiresDetail";
455
- payload: AddProductRequiresDetailPayload;
456
- } | {
457
- action: "requiresBookingEdit";
458
- cacheItem: any;
459
- payload: import("./utils/addProductDecision").AddProductRequiresBookingEditPayload;
460
- };
444
+ decideAddProduct(item: any, options?: Partial<AddProductDecideContext>): import("./utils/addProductDecision").AddProductDecision;
461
445
  /** 规格弹窗 callback 后的第二段决策。 */
462
446
  decideAfterDetail(cacheItem: any, options?: Partial<AddProductDecideContext>): import("./utils/addProductDecision").AddProductDecision;
463
447
  /**
@@ -219,14 +219,8 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
219
219
  }
220
220
  }
221
221
  async getOpenData() {
222
- return this.loadOpenDataConfig();
223
- }
224
- /** 清除店铺级 OpenData;下一次 getOpenData 时会重新拉取。 */
225
- clearOpenDataCache() {
226
222
  var _a;
227
- this.loadOpenDataConfigInFlight = null;
228
- this.otherParams.openData = null;
229
- (_a = this.store.openData) == null ? void 0 : _a.clearCache();
223
+ return (_a = this.store.openData) == null ? void 0 : _a.getOpenData();
230
224
  }
231
225
  async getShortNumberOrDeviceId() {
232
226
  const getAsyncIotDeviceInfo = this.getAppData("async_iot_device_info");
@@ -239,7 +233,6 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
239
233
  return String(this.getAppData("device_id") || 0).slice(-2);
240
234
  }
241
235
  async configureIdGeneratorFromOpenData() {
242
- this.setPaymentNumberDevicePrefix(null);
243
236
  let openDataConfig = null;
244
237
  try {
245
238
  openDataConfig = await this.loadOpenDataConfig();
@@ -271,7 +264,6 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
271
264
  const resetReceiptSequenceDaily = typeof (openDataConfig == null ? void 0 : openDataConfig["sale.short_number_daily_reset"]) === "boolean" ? openDataConfig == null ? void 0 : openDataConfig["sale.short_number_daily_reset"] : false;
272
265
  const operatingDayBoundary = this.getAppData("operating_day_boundary");
273
266
  const deviceId = await this.getShortNumberOrDeviceId();
274
- this.setPaymentNumberDevicePrefix(deviceId);
275
267
  const businessCode = this.getBookingTicketBusinessCode();
276
268
  if (!businessCode) {
277
269
  console.warn("[BookingTicket] businessCode 缺失,跳过 idGenerator 配置");
@@ -722,53 +714,11 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
722
714
  return this.getOrderCustomerSnapshot();
723
715
  }
724
716
  /**
725
- * 通过 ids 获取商品列表;默认只读取内存,显式开启 loadMissing 时按当前订单上下文补查缺失商品。
726
- * 补查直接写入 ProductList,不更新 BookingTicket.productCatalog,避免当前商品列表被查询子集覆盖。
717
+ * 通过 ids 获取商品列表(不加载到模块中)
718
+ * @returns 商品列表
727
719
  */
728
- async getProductByIds(ids, options) {
729
- var _a, _b;
730
- const normalizedIds = Array.from(
731
- new Set(
732
- (ids || []).map((id) => Number(id)).filter((id) => Number.isFinite(id))
733
- )
734
- );
735
- const localProducts = await this.store.products.getProductByIds(normalizedIds) || [];
736
- if (!(options == null ? void 0 : options.loadMissing)) {
737
- return localProducts;
738
- }
739
- const localProductIds = new Set(
740
- localProducts.map((product) => Number(product.id))
741
- );
742
- const missingIds = normalizedIds.filter(
743
- (id) => !localProductIds.has(id)
744
- );
745
- if (!missingIds.length) {
746
- return localProducts;
747
- }
748
- const rawBookingDate = this.getBookingDate();
749
- const bookingDate = rawBookingDate && (0, import_dayjs.default)(rawBookingDate).isValid() ? (0, import_dayjs.default)(rawBookingDate) : null;
750
- const customerId = Number(
751
- ((_a = this.getOrderCustomerSnapshot()) == null ? void 0 : _a.id) ?? ((_b = this.getOrderCustomer()) == null ? void 0 : _b.customer_id)
752
- );
753
- const loadedProducts = await this.store.products.loadProducts({
754
- product_ids: missingIds,
755
- with_count: ["bundleGroup", "optionGroup"],
756
- with_schedule: 1,
757
- cacheId: this.cacheId,
758
- ...bookingDate ? {
759
- schedule_date: bookingDate.format("YYYY-MM-DD"),
760
- schedule_datetime: bookingDate.format("YYYY-MM-DD HH:mm:ss")
761
- } : {},
762
- ...Number.isFinite(customerId) && customerId > 0 ? { customer_id: customerId } : {}
763
- });
764
- const productById = /* @__PURE__ */ new Map();
765
- [...localProducts, ...loadedProducts || []].forEach((product) => {
766
- const productId = Number(product.id);
767
- if (Number.isFinite(productId)) {
768
- productById.set(productId, product);
769
- }
770
- });
771
- return normalizedIds.map((id) => productById.get(id)).filter((product) => Boolean(product));
720
+ async getProductByIds(ids) {
721
+ return this.store.products.getProductByIds(ids);
772
722
  }
773
723
  /**
774
724
  * 获取日程时间段点
@@ -1203,8 +1153,7 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
1203
1153
  }
1204
1154
  /** 读取当前 booking config。 */
1205
1155
  getBookingConfig() {
1206
- var _a;
1207
- return (_a = this.store.bookingContext) == null ? void 0 : _a.getBookingConfig();
1156
+ return this.store.bookingContext.getBookingConfig();
1208
1157
  }
1209
1158
  /** 写入资源全集(来源:`/form/schedule`),同步派生 resourcesOriginMap。 */
1210
1159
  setResources(resources) {
@@ -1577,8 +1526,8 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
1577
1526
  return result;
1578
1527
  }
1579
1528
  async setOtherParams(params, { cover = false } = {}) {
1580
- await super.setOtherParams(params, { cover });
1581
- if ((params == null ? void 0 : params.businessCode) !== void 0 || (params == null ? void 0 : params.business_code) !== void 0) {
1529
+ super.setOtherParams(params, { cover });
1530
+ if (params == null ? void 0 : params.businessCode) {
1582
1531
  await this.configureIdGeneratorFromOpenData();
1583
1532
  }
1584
1533
  }
@@ -118,12 +118,15 @@ export interface BookingTicketCartBookingView extends ISalesBooking {
118
118
  canAddTime: boolean;
119
119
  };
120
120
  }
121
+ export type BookingTicketCartLineView = BookingTicketCartBookingView | BookingTicketCartItemView;
121
122
  /**
122
123
  * BookingTicket 面向 UI 的购物车视图。
123
124
  */
124
125
  export interface BookingTicketCartView {
125
126
  bookings: BookingTicketCartBookingView[];
126
127
  items: BookingTicketCartItemView[];
128
+ /** 以 tempOrder.products 为唯一顺序真源的统一购物车行(旧到新)。 */
129
+ lines: BookingTicketCartLineView[];
127
130
  }
128
131
  /**
129
132
  * BookingTicket 面向 UI 的客户展示视图。
@@ -86,29 +86,27 @@ function isGiftProductLine(line) {
86
86
  function buildCartView(lines, bookings, options = {}) {
87
87
  const productLines = Array.isArray(lines) ? lines : [];
88
88
  const bookingList = Array.isArray(bookings) ? bookings : [];
89
+ const childBookings = bookingList.filter((booking) => booking.parent_id !== 0);
90
+ const bookingsByProductUid = indexBookingsByProductUid(childBookings);
89
91
  const linesByUid = indexProductsByUid(productLines);
90
92
  const addTimeLinesByBookingUid = indexAddTimeProductsByBookingUid(productLines);
91
- const claimedUids = /* @__PURE__ */ new Set();
92
93
  const claimedAddTimeLines = /* @__PURE__ */ new Set();
93
- const cartBookings = bookingList.filter((booking) => booking.parent_id !== 0).reduce((acc, booking) => {
94
- const uid = booking == null ? void 0 : booking.product_uid;
94
+ childBookings.forEach((booking) => {
95
+ const bookingUid = getBookingUid(booking);
96
+ if (!bookingUid)
97
+ return;
98
+ (addTimeLinesByBookingUid[bookingUid] || []).forEach((line) => {
99
+ claimedAddTimeLines.add(line);
100
+ });
101
+ });
102
+ const claimedBookings = /* @__PURE__ */ new Set();
103
+ const cartBookings = [];
104
+ const items = [];
105
+ const orderedLines = [];
106
+ const buildBookingView = (booking, product) => {
95
107
  const bookingUid = getBookingUid(booking);
96
- let product = null;
97
- if (uid !== void 0 && uid !== null && uid !== "") {
98
- const key = String(uid);
99
- if (!claimedUids.has(key)) {
100
- const line = linesByUid[key];
101
- if (isGiftProductLine(line))
102
- return acc;
103
- if (line) {
104
- claimedUids.add(key);
105
- product = line;
106
- }
107
- }
108
- }
109
108
  const addTimeProduct = bookingUid ? addTimeLinesByBookingUid[bookingUid] || [] : [];
110
- addTimeProduct.forEach((line) => claimedAddTimeLines.add(line));
111
- acc.push({
109
+ return {
112
110
  ...booking,
113
111
  _extend: {
114
112
  product,
@@ -122,21 +120,36 @@ function buildCartView(lines, bookings, options = {}) {
122
120
  shopOpeningHours: options.shopOpeningHours
123
121
  })
124
122
  }
125
- });
126
- return acc;
127
- }, []);
128
- const items = productLines.filter((line) => {
123
+ };
124
+ };
125
+ productLines.forEach((line) => {
129
126
  var _a;
130
- if (isGiftProductLine(line))
131
- return false;
132
- if (claimedAddTimeLines.has(line))
133
- return false;
127
+ if (isGiftProductLine(line) || claimedAddTimeLines.has(line))
128
+ return;
134
129
  const uid = (_a = line.metadata) == null ? void 0 : _a.unique_identification_number;
135
- if (uid === void 0 || uid === null || uid === "")
136
- return true;
137
- return !claimedUids.has(String(uid));
130
+ const matchedBooking = uid === void 0 || uid === null || uid === "" ? void 0 : (bookingsByProductUid[String(uid)] || []).find(
131
+ (booking) => !claimedBookings.has(booking)
132
+ );
133
+ if (matchedBooking) {
134
+ claimedBookings.add(matchedBooking);
135
+ const bookingView = buildBookingView(matchedBooking, line);
136
+ cartBookings.push(bookingView);
137
+ orderedLines.push(bookingView);
138
+ return;
139
+ }
140
+ items.push(line);
141
+ orderedLines.push(line);
142
+ });
143
+ childBookings.forEach((booking) => {
144
+ if (claimedBookings.has(booking))
145
+ return;
146
+ const uid = booking == null ? void 0 : booking.product_uid;
147
+ const linkedProduct = uid === void 0 || uid === null || uid === "" ? null : linesByUid[String(uid)] || null;
148
+ if (isGiftProductLine(linkedProduct))
149
+ return;
150
+ cartBookings.push(buildBookingView(booking, null));
138
151
  });
139
- return { bookings: cartBookings, items };
152
+ return { bookings: cartBookings, items, lines: orderedLines };
140
153
  }
141
154
  function isWalkInCustomer(customer) {
142
155
  if (!customer)
@@ -83,7 +83,6 @@ export declare class SalesImpl extends BaseModule implements Module, SalesModule
83
83
  private getBookingAppointmentStatus;
84
84
  private isBookingIncludedInStats;
85
85
  private getBookingOrderPaymentStatus;
86
- private isUnpaidBooking;
87
86
  private countBookingOrders;
88
87
  private countCompletedBookings;
89
88
  private groupBookingsByResource;
@@ -39,7 +39,6 @@ var import_dayjs = __toESM(require("dayjs"));
39
39
  var import_BaseModule = require("../../modules/BaseModule");
40
40
  var import_types = require("./types");
41
41
  __reExport(Sales_exports, require("./types"), module.exports);
42
- var UNPAID_PAYMENT_STATUSES = /* @__PURE__ */ new Set(["unpaid", "partially_paid", "payment_processing"]);
43
42
  var SalesImpl = class extends import_BaseModule.BaseModule {
44
43
  // LoggerManager 实例
45
44
  constructor(name, version) {
@@ -259,9 +258,6 @@ var SalesImpl = class extends import_BaseModule.BaseModule {
259
258
  var _a;
260
259
  return String(((_a = booking.order) == null ? void 0 : _a.payment_status) ?? "");
261
260
  }
262
- isUnpaidBooking(booking) {
263
- return UNPAID_PAYMENT_STATUSES.has(this.getBookingOrderPaymentStatus(booking));
264
- }
265
261
  countBookingOrders(bookings) {
266
262
  const orderIds = /* @__PURE__ */ new Set();
267
263
  bookings.forEach((booking) => {
@@ -635,7 +631,9 @@ var SalesImpl = class extends import_BaseModule.BaseModule {
635
631
  const completedBookingList = matchedBookingList.filter(
636
632
  (booking) => this.getBookingAppointmentStatus(booking) === "completed"
637
633
  );
638
- const unpaidBookingList = matchedBookingList.filter((booking) => this.isUnpaidBooking(booking));
634
+ const unpaidBookingList = matchedBookingList.filter(
635
+ (booking) => this.getBookingOrderPaymentStatus(booking) === "unpaid" || this.getBookingOrderPaymentStatus(booking) === "payment_processing"
636
+ );
639
637
  const bookings = this.pickBookingsForCurrentPoint(
640
638
  current,
641
639
  this.normalizeResourceBookings(current, deviceCurrent, matchedBookingList)
@@ -48,10 +48,6 @@ var import_utils2 = require("../../modules/Order/utils");
48
48
  var import_dayjs = __toESM(require("dayjs"));
49
49
  var import_itemRule = require("../../model/strategy/adapter/itemRule");
50
50
  __reExport(ScanOrder_exports, require("./types"), module.exports);
51
- function isItemRewardProductDiscount(discount) {
52
- var _a, _b;
53
- return (discount == null ? void 0 : discount.type) === "product" && ((_a = discount == null ? void 0 : discount.metadata) == null ? void 0 : _a.source) === "promotion" && ((_b = discount == null ? void 0 : discount.metadata) == null ? void 0 : _b.actionType) === "ITEM_REWARD";
54
- }
55
51
  var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
56
52
  constructor(name, version) {
57
53
  super(name, version);
@@ -746,10 +742,6 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
746
742
  for (const product of tempOrder.products) {
747
743
  if ((_c = product._origin) == null ? void 0 : _c.isManualDiscount)
748
744
  continue;
749
- if ((product.discount_list || []).some(isItemRewardProductDiscount)) {
750
- product.discount_list = (product.discount_list || []).filter(isItemRewardProductDiscount);
751
- continue;
752
- }
753
745
  product.discount_list = (product.discount_list || []).filter((pd) => {
754
746
  var _a2;
755
747
  const rid = ((_a2 = pd.discount) == null ? void 0 : _a2.resource_id) ?? pd.id;
@@ -65,10 +65,6 @@ var OPEN_DATA_SECTION_CODES = [
65
65
  "workflow",
66
66
  "checkout"
67
67
  ];
68
- function isItemRewardProductDiscount(discount) {
69
- var _a, _b;
70
- return (discount == null ? void 0 : discount.type) === "product" && ((_a = discount == null ? void 0 : discount.metadata) == null ? void 0 : _a.source) === "promotion" && ((_b = discount == null ? void 0 : discount.metadata) == null ? void 0 : _b.actionType) === "ITEM_REWARD";
71
- }
72
68
  function cloneCustomDepositData(customDepositData) {
73
69
  if (!customDepositData || typeof customDepositData !== "object")
74
70
  return void 0;
@@ -1343,10 +1339,6 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
1343
1339
  for (const product of tempOrder.products) {
1344
1340
  if ((_c = product._origin) == null ? void 0 : _c.isManualDiscount)
1345
1341
  continue;
1346
- if ((product.discount_list || []).some(isItemRewardProductDiscount)) {
1347
- product.discount_list = (product.discount_list || []).filter(isItemRewardProductDiscount);
1348
- continue;
1349
- }
1350
1342
  product.discount_list = (product.discount_list || []).filter((pd) => {
1351
1343
  var _a2;
1352
1344
  const rid = ((_a2 = pd.discount) == null ? void 0 : _a2.resource_id) ?? pd.id;
@@ -47,7 +47,6 @@ export interface PisellCore {
47
47
  getModule: <T extends Module>(name: string) => T | null;
48
48
  getModuleExports: <T = any>(name: string) => T | null;
49
49
  hasModule: (name: string) => boolean;
50
- getModuleNames: () => string[];
51
50
  effects: {
52
51
  on: (event: string, callback: (payload: any) => void) => () => void;
53
52
  once: (event: string, callback: (payload: any) => void) => () => void;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.2.273",
4
+ "version": "2.2.274",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -1,26 +0,0 @@
1
- export type OrderPaymentTransactionStatus = 'success' | 'fail';
2
- export interface OrderPaymentTransaction {
3
- number: string;
4
- status: OrderPaymentTransactionStatus;
5
- }
6
- export type OrderPaymentIdentityType = 'order_payment_id' | 'payment_number' | 'unique_payment_number';
7
- export interface OrderPaymentIdentityMatch<T> {
8
- index: number;
9
- payment: T;
10
- matchedBy: OrderPaymentIdentityType;
11
- }
12
- export declare function getOrderPaymentIdentityKeys(payment: unknown): string[];
13
- export declare function isPendingOrderPayment(payment: unknown): boolean;
14
- export declare function isIdentifiedPendingOrderPayment(payment: unknown): boolean;
15
- export declare function hasOrderPaymentIdentityOverlap(left: unknown, right: unknown): boolean;
16
- export declare function resolveOrderPaymentIdentity<T extends Record<string, any>>(payments: T[] | null | undefined, identity: string | number, mode?: 'payment_number' | 'compat'): OrderPaymentIdentityMatch<T> | null;
17
- export declare function ensureOrderPaymentNumber<T extends Record<string, any>>(payment: T, devicePrefix: string, createPaymentNumber: () => string): T & {
18
- payment_number: string;
19
- };
20
- export declare function mergeOrderPaymentTransactions(current: unknown, incoming: unknown): OrderPaymentTransaction[];
21
- export declare function mergeOrderPaymentRecord<T extends Record<string, any>>(payment: T, updates: Record<string, any>): T;
22
- export declare function mergeOrderPaymentSnapshot<T extends Record<string, any>>(current: T, incoming: T): T;
23
- export declare function mergeOrderPaymentListsByIdentity<T extends Record<string, any>>(existing: T[] | null | undefined, incoming: T[] | null | undefined, options?: {
24
- preserveUnmatchedExisting?: boolean;
25
- preserveUnmatchedExistingWhen?: (payment: T) => boolean;
26
- }): T[];