@pisell/pisellos 2.2.277 → 2.2.800

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 (127) hide show
  1. package/dist/core/index.d.ts +0 -2
  2. package/dist/core/index.js +1 -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 +0 -9
  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/model/strategy/adapter/walletPass/evaluator.js +2 -0
  14. package/dist/model/strategy/adapter/walletPass/type.d.ts +0 -5
  15. package/dist/model/strategy/adapter/walletPass/utils.js +26 -57
  16. package/dist/modules/OpenData/index.d.ts +0 -2
  17. package/dist/modules/OpenData/index.js +0 -8
  18. package/dist/modules/Order/index.d.ts +8 -28
  19. package/dist/modules/Order/index.js +496 -808
  20. package/dist/modules/Order/types.d.ts +1 -35
  21. package/dist/modules/Order/utils/orderCollectionIdentity.js +2 -7
  22. package/dist/modules/Order/utils.js +6 -10
  23. package/dist/modules/Payment/index.d.ts +0 -2
  24. package/dist/modules/Payment/index.js +49 -78
  25. package/dist/modules/Payment/types.d.ts +25 -106
  26. package/dist/modules/Payment/types.js +0 -17
  27. package/dist/modules/Payment/utils.js +1 -4
  28. package/dist/modules/Payment/walletpass.d.ts +1 -49
  29. package/dist/modules/Payment/walletpass.js +124 -1081
  30. package/dist/modules/Rules/index.d.ts +0 -3
  31. package/dist/modules/Rules/index.js +70 -100
  32. package/dist/server/index.d.ts +0 -25
  33. package/dist/server/index.js +1069 -2001
  34. package/dist/server/modules/index.d.ts +1 -1
  35. package/dist/server/modules/order/index.d.ts +4 -70
  36. package/dist/server/modules/order/index.js +728 -1816
  37. package/dist/server/modules/order/types.d.ts +3 -25
  38. package/dist/server/modules/order/types.js +1 -7
  39. package/dist/server/utils/small-ticket.js +2 -1
  40. package/dist/solution/BaseSales/index.d.ts +5 -109
  41. package/dist/solution/BaseSales/index.js +436 -1802
  42. package/dist/solution/BaseSales/types.d.ts +1 -55
  43. package/dist/solution/BaseSales/types.js +1 -2
  44. package/dist/solution/BaseSales/utils/cartPromotion.d.ts +1 -3
  45. package/dist/solution/BaseSales/utils/cartPromotion.js +31 -90
  46. package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -6
  47. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +4 -7
  48. package/dist/solution/BookingByStep/index.d.ts +1 -1
  49. package/dist/solution/BookingTicket/index.d.ts +5 -21
  50. package/dist/solution/BookingTicket/index.js +56 -139
  51. package/dist/solution/BookingTicket/types.d.ts +0 -1
  52. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +0 -8
  53. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +83 -173
  54. package/dist/solution/Sales/index.d.ts +0 -2
  55. package/dist/solution/Sales/index.js +4 -26
  56. package/dist/solution/ScanOrder/index.js +20 -31
  57. package/dist/solution/VenueBooking/index.d.ts +0 -1
  58. package/dist/solution/VenueBooking/index.js +19 -30
  59. package/dist/types/index.d.ts +0 -1
  60. package/lib/core/index.d.ts +0 -2
  61. package/lib/core/index.js +1 -4
  62. package/lib/model/strategy/adapter/promotion/adapter.d.ts +0 -4
  63. package/lib/model/strategy/adapter/promotion/adapter.js +0 -20
  64. package/lib/model/strategy/adapter/promotion/evaluator.d.ts +0 -17
  65. package/lib/model/strategy/adapter/promotion/evaluator.js +0 -235
  66. package/lib/model/strategy/adapter/promotion/examples.d.ts +0 -86
  67. package/lib/model/strategy/adapter/promotion/examples.js +0 -91
  68. package/lib/model/strategy/adapter/promotion/index.d.ts +1 -1
  69. package/lib/model/strategy/adapter/promotion/index.js +49 -0
  70. package/lib/model/strategy/adapter/promotion/type.d.ts +2 -90
  71. package/lib/model/strategy/adapter/promotion/type.js +0 -2
  72. package/lib/model/strategy/adapter/walletPass/evaluator.js +2 -0
  73. package/lib/model/strategy/adapter/walletPass/type.d.ts +0 -5
  74. package/lib/model/strategy/adapter/walletPass/utils.js +11 -62
  75. package/lib/modules/OpenData/index.d.ts +0 -2
  76. package/lib/modules/OpenData/index.js +0 -5
  77. package/lib/modules/Order/index.d.ts +8 -28
  78. package/lib/modules/Order/index.js +69 -231
  79. package/lib/modules/Order/types.d.ts +1 -35
  80. package/lib/modules/Order/utils/orderCollectionIdentity.js +0 -3
  81. package/lib/modules/Order/utils.js +4 -11
  82. package/lib/modules/Payment/index.d.ts +0 -2
  83. package/lib/modules/Payment/index.js +12 -33
  84. package/lib/modules/Payment/types.d.ts +25 -106
  85. package/lib/modules/Payment/types.js +0 -1
  86. package/lib/modules/Payment/utils.js +1 -5
  87. package/lib/modules/Payment/walletpass.d.ts +1 -49
  88. package/lib/modules/Payment/walletpass.js +22 -898
  89. package/lib/modules/Rules/index.d.ts +0 -3
  90. package/lib/modules/Rules/index.js +9 -38
  91. package/lib/server/index.d.ts +0 -25
  92. package/lib/server/index.js +31 -726
  93. package/lib/server/modules/index.d.ts +1 -1
  94. package/lib/server/modules/order/index.d.ts +4 -70
  95. package/lib/server/modules/order/index.js +69 -818
  96. package/lib/server/modules/order/types.d.ts +3 -25
  97. package/lib/server/modules/order/types.js +0 -1
  98. package/lib/server/utils/small-ticket.js +1 -1
  99. package/lib/solution/BaseSales/index.d.ts +5 -109
  100. package/lib/solution/BaseSales/index.js +27 -874
  101. package/lib/solution/BaseSales/types.d.ts +1 -55
  102. package/lib/solution/BaseSales/types.js +1 -2
  103. package/lib/solution/BaseSales/utils/cartPromotion.d.ts +1 -3
  104. package/lib/solution/BaseSales/utils/cartPromotion.js +12 -63
  105. package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -6
  106. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +3 -4
  107. package/lib/solution/BookingByStep/index.d.ts +1 -1
  108. package/lib/solution/BookingTicket/index.d.ts +5 -21
  109. package/lib/solution/BookingTicket/index.js +13 -64
  110. package/lib/solution/BookingTicket/types.d.ts +0 -1
  111. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +0 -8
  112. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +5 -37
  113. package/lib/solution/Sales/index.d.ts +0 -2
  114. package/lib/solution/Sales/index.js +6 -20
  115. package/lib/solution/ScanOrder/index.js +0 -8
  116. package/lib/solution/VenueBooking/index.d.ts +0 -1
  117. package/lib/solution/VenueBooking/index.js +0 -8
  118. package/lib/types/index.d.ts +0 -1
  119. package/package.json +1 -1
  120. package/dist/modules/Order/payment-utils.d.ts +0 -26
  121. package/dist/modules/Order/payment-utils.js +0 -225
  122. package/dist/utils/payment-number.d.ts +0 -9
  123. package/dist/utils/payment-number.js +0 -69
  124. package/lib/modules/Order/payment-utils.d.ts +0 -26
  125. package/lib/modules/Order/payment-utils.js +0 -224
  126. package/lib/utils/payment-number.d.ts +0 -9
  127. package/lib/utils/payment-number.js +0 -64
@@ -3,7 +3,6 @@ import { OrderModule, ProductList, QuotationModule, SalesSummaryModule, ScanOrde
3
3
  import type { ScanOrderLogInput as BaseSalesLogInput, ScanOrderLoggerProviderConfig as BaseSalesLoggerProviderConfig, ScanOrderLoggerProviderType as BaseSalesLoggerProviderType } from '../../modules/ScanOrderLogger/types';
4
4
  import type { QuantityCheckResult, QuantityLimitResult } from '../../model/strategy/adapter/itemRule';
5
5
  import type { QuotationCustomerScopeInfo } from '../../modules/Quotation/types';
6
- import type { PaymentMethod } from '../../modules/Payment/types';
7
6
  /**
8
7
  * BaseSales 流程 hook 后缀。
9
8
  * 完整事件名应由当前模块名动态拼接,避免多个实例共享固定事件 key。
@@ -17,62 +16,11 @@ export declare const BaseSalesHookNames: {
17
16
  readonly onPaymentSyncStart: "onPaymentSyncStart";
18
17
  readonly onPaymentSyncEnd: "onPaymentSyncEnd";
19
18
  readonly onDepositPaymentSyncEnd: "onDepositPaymentSyncEnd";
20
- readonly onWalletAssetsStateChanged: "onWalletAssetsStateChanged";
21
19
  };
22
20
  export type BaseSalesHookName = typeof BaseSalesHookNames[keyof typeof BaseSalesHookNames];
23
21
  export declare function createBaseSalesHook(moduleName: string, hookName: BaseSalesHookName): string;
24
22
  export type BaseSalesStatus = 'idle' | 'initializing' | 'ready' | 'error';
25
23
  export type BaseSalesPaymentStatus = 'paid' | 'partially_paid' | 'unpaid' | 'payment_processing' | string;
26
- export interface BaseSalesCashPaymentConfig {
27
- available: boolean;
28
- paymentMethod?: PaymentMethod;
29
- amountDue: number;
30
- recommendedAmounts: number[];
31
- }
32
- export interface BaseSalesPayCashParams {
33
- /** 实际计入订单的现金支付金额(部分支付时小于待付金额)。 */
34
- amount: number;
35
- /** 顾客实际交付现金;可大于 amount。 */
36
- actualPaidAmount?: number;
37
- changeAmount?: number;
38
- roundingAmount?: number;
39
- }
40
- export interface BaseSalesPayCashResult {
41
- payment: Record<string, any>;
42
- payments: Record<string, any>[];
43
- syncResult: Record<string, any>;
44
- isOrderFullyPaid: boolean;
45
- }
46
- export interface BaseSalesCommitPaymentMethodParams {
47
- /** 支付方式 id;与 paymentMethodCode 至少传一个。 */
48
- paymentMethodId?: number | string;
49
- /** 支付方式 code,大小写不敏感。 */
50
- paymentMethodCode?: string;
51
- /** 本次计入订单的支付金额。 */
52
- amount: number;
53
- /** 支付设备返回的原始金额;缺省时与 amount 相同。 */
54
- originAmount?: number;
55
- /** 支付设备返回的实际手续费配置。 */
56
- serviceCharge?: {
57
- amount?: string | number;
58
- percentage?: string | number;
59
- } | null;
60
- /** 支付设备返回的唯一流水号等扩展信息。 */
61
- metadata?: Record<string, any>;
62
- /** 少数支付方式需要透传的额外 payment 字段。 */
63
- paymentData?: Record<string, any>;
64
- }
65
- export interface BaseSalesCommitPaymentMethodResult {
66
- payment: Record<string, any>;
67
- payments: Record<string, any>[];
68
- syncResult: Record<string, any>;
69
- isOrderFullyPaid: boolean;
70
- }
71
- export interface BaseSalesConfirmWalletPaymentResult<T = Record<string, any>> {
72
- submitResult: T;
73
- payments: Record<string, any>[];
74
- isOrderFullyPaid: boolean;
75
- }
76
24
  export interface BaseSalesEntryContext {
77
25
  biz: string;
78
26
  mode: 'scan' | 'append';
@@ -439,10 +387,8 @@ export interface BaseSalesAddLogParams extends BaseSalesLogInput {
439
387
  /** BaseSales.scanPromotionCode 对外的轻量结果(UI 可用 getDiscountList 或 scannedDiscountList 补 Holder) */
440
388
  export interface BaseSalesScanCodeResult {
441
389
  isAvailable: boolean;
442
- /** 卡券已加入 Promotion;false 时可能是无效、过期或已使用。 */
443
- isAccepted?: boolean;
444
390
  type?: 'server' | string;
445
391
  unavailableReason?: 'time_limit' | string;
446
- /** batchSearch 原始结果;Holder 补全等流程可从这里读取原始卡券。 */
392
+ /** batchSearch 原始结果;isAvailable=false 时 discountList 可能未写入 store,Holder 补全需读此字段 */
447
393
  scannedDiscountList?: Discount[];
448
394
  }
@@ -31,8 +31,7 @@ var BaseSalesHookNames = {
31
31
  onCartValidationChanged: "onCartValidationChanged",
32
32
  onPaymentSyncStart: "onPaymentSyncStart",
33
33
  onPaymentSyncEnd: "onPaymentSyncEnd",
34
- onDepositPaymentSyncEnd: "onDepositPaymentSyncEnd",
35
- onWalletAssetsStateChanged: "onWalletAssetsStateChanged"
34
+ onDepositPaymentSyncEnd: "onDepositPaymentSyncEnd"
36
35
  };
37
36
  function createBaseSalesHook(moduleName, hookName) {
38
37
  return `${moduleName}:${hookName}`;
@@ -78,7 +78,6 @@ export interface CartPromotionEvaluator {
78
78
  }>;
79
79
  hasApplicableStrategy: boolean;
80
80
  }>;
81
- getStrategyConfigs?: () => unknown[];
82
81
  }
83
82
  /** 单个赠品减量项 */
84
83
  export interface GiftReduceItem {
@@ -268,8 +267,7 @@ export declare function appendPromotionTags<T extends Record<string, any>>(produ
268
267
  * 处理购物车的促销计算与赠品差异化。
269
268
  *
270
269
  * 流程:
271
- * 1. 分离 main / gift / edit-product 三类(普通促销下带 `booking_id` 的编辑态商品不参与;
272
- * 配置 ITEM_REWARD 时,编辑态商品也参与商品奖励重算)
270
+ * 1. 分离 main / gift / edit-product 三类(带 `booking_id` 的编辑态商品不参与促销)
273
271
  * 2. 转 PromotionProduct 喂评估器 → 拿到 `evaluateCartWithPricing` 与 `getProductsApplicableStrategies`
274
272
  * 3. 把 PricedProduct 映射回 OrderProduct 形态:
275
273
  * - 参与促销的,写 `metadata._promotion` + 调整 `selling_price` / `main_product_selling_price`
@@ -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);
@@ -437,13 +402,14 @@ function buildConsolidateKeyForPromotion(item) {
437
402
  ].join("#");
438
403
  }
439
404
  function consolidateMainProductsForPromotion(entries) {
405
+ var _a, _b;
440
406
  if (!Array.isArray(entries) || entries.length <= 1) {
441
407
  return [...entries || []];
442
408
  }
443
409
  const groups = /* @__PURE__ */ new Map();
444
410
  for (const { item, originalListIndex } of entries) {
445
411
  const key = buildConsolidateKeyForPromotion(item);
446
- const wasInPromotion = wasInPromotionBeforeEvaluation(item);
412
+ const wasInPromotion = ((_b = (_a = item == null ? void 0 : item.metadata) == null ? void 0 : _a._promotion) == null ? void 0 : _b.inPromotion) === true;
447
413
  const existing = groups.get(key);
448
414
  if (!existing) {
449
415
  const mergedItem = (0, import_lodash_es.cloneDeep)(item);
@@ -509,9 +475,6 @@ function splitXItemsPromoLinesByGroup(lines, strategyActionMap) {
509
475
  function generateNumericId() {
510
476
  return Math.floor(Math.random() * 1e9) + Date.now();
511
477
  }
512
- function isBookingEditProductLine(product) {
513
- 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";
514
- }
515
478
  function convertToPromotionProduct(product, index) {
516
479
  const metadata = (product == null ? void 0 : product.metadata) || {};
517
480
  const numericId = generateNumericId();
@@ -524,7 +487,6 @@ function convertToPromotionProduct(product, index) {
524
487
  price: getOrderProductOriginalPriceForPromotion(product),
525
488
  quantity: Number((product == null ? void 0 : product.num) ?? 1) || 1,
526
489
  bundle: getProductBundleForEvaluator(product),
527
- _promotionOnlyForItemReward: isBookingEditProductLine(product),
528
490
  _originalItem: originalItem,
529
491
  _originalId: getOrderProductUid(product),
530
492
  _originalIndex: index
@@ -626,9 +588,6 @@ function resolveStrategyRequiredQuantity(matched) {
626
588
  if (matched.actionType === "BUY_X_GET_Y_FREE") {
627
589
  return Number(detail.buyQuantity) || 1;
628
590
  }
629
- if (matched.actionType === "ITEM_REWARD") {
630
- return Number(detail.triggerQuantity) || 1;
631
- }
632
591
  return 1;
633
592
  }
634
593
  function resolveStrategyEligibleProducts(matched) {
@@ -739,10 +698,6 @@ function processCartPromotion(list, evaluator, options) {
739
698
  };
740
699
  if (!list || list.length === 0 || !evaluator)
741
700
  return empty;
742
- const shouldIncludeEditProductsForItemReward = evaluatorHasActionType(
743
- evaluator,
744
- ITEM_REWARD
745
- );
746
701
  const mainProductsWithIndex = [];
747
702
  const existingGiftsWithIndex = [];
748
703
  const editProductsWithIndex = [];
@@ -753,12 +708,8 @@ function processCartPromotion(list, evaluator, options) {
753
708
  editProductsWithIndex.push({ item, originalListIndex: i });
754
709
  } else if (giftInfo) {
755
710
  existingGiftsWithIndex.push({ item, originalListIndex: i });
756
- } else if (isBookingEditProductLine(item)) {
757
- if (shouldIncludeEditProductsForItemReward) {
758
- mainProductsWithIndex.push({ item, originalListIndex: i });
759
- } else {
760
- editProductsWithIndex.push({ item, originalListIndex: i });
761
- }
711
+ } 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") {
712
+ editProductsWithIndex.push({ item, originalListIndex: i });
762
713
  } else {
763
714
  mainProductsWithIndex.push({ item, originalListIndex: i });
764
715
  }
@@ -801,8 +752,7 @@ function processCartPromotion(list, evaluator, options) {
801
752
  name: ((_a2 = item == null ? void 0 : item.metadata) == null ? void 0 : _a2.product_name) || (item == null ? void 0 : item.title) || "",
802
753
  price: getOrderProductBasePrice(item),
803
754
  quantity: Number((item == null ? void 0 : item.num) ?? 1) || 1,
804
- bundle: getProductBundleForEvaluator(item),
805
- _promotionOnlyForItemReward: isBookingEditProductLine(item)
755
+ bundle: getProductBundleForEvaluator(item)
806
756
  };
807
757
  });
808
758
  for (let i = 0; i < consolidatedMainProductsWithIndex.length; i++) {
@@ -871,7 +821,7 @@ function processCartPromotion(list, evaluator, options) {
871
821
  const metadata = newItem.metadata || {};
872
822
  const sourceCartNum = (0, import_utils2.getSafeProductNum)(originalItem.num);
873
823
  newItem._sourceCartNum = sourceCartNum;
874
- const wasInPromotion = wasInPromotionBeforeEvaluation(originalItem) || originalItem._wasInPromotionBeforeConsolidate === true;
824
+ const wasInPromotion = ((_a = metadata._promotion) == null ? void 0 : _a.inPromotion) === true || originalItem._wasInPromotionBeforeConsolidate === true;
875
825
  delete metadata._promotion;
876
826
  if (Array.isArray(newItem.product_bundle)) {
877
827
  for (const b of newItem.product_bundle) {
@@ -888,8 +838,7 @@ function processCartPromotion(list, evaluator, options) {
888
838
  applyPromoUnitPriceToLine(newItem, {
889
839
  promoUnitPrice,
890
840
  originalBasePrice,
891
- strategyTitle: (_a = priced.strategyMetadata) == null ? void 0 : _a.name,
892
- actionType: priced.strategyId ? (_b = strategyActionMap.get(priced.strategyId)) == null ? void 0 : _b.actionType : void 0
841
+ strategyTitle: (_b = priced.strategyMetadata) == null ? void 0 : _b.name
893
842
  });
894
843
  } else {
895
844
  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 {
@@ -132,15 +132,14 @@ function transformBaseProductToOrderProduct(params) {
132
132
  ...callbackOrigin || {}
133
133
  };
134
134
  const matchedVariant = findVariantById(callbackOrigin, productVariantId) ?? findVariantById(sourceProduct, productVariantId) ?? findVariantById(origin, productVariantId);
135
- const hasPriceOverride = payload.price_override !== void 0 && payload.price_override !== null && payload.price_override !== "";
136
- const catalogSourcePrice = (matchedVariant == null ? void 0 : matchedVariant.price) ?? (matchedVariant == null ? void 0 : matchedVariant.base_price) ?? (origin == null ? void 0 : origin.price) ?? (origin == null ? void 0 : origin.base_price) ?? (sourceProduct == null ? void 0 : sourceProduct.price) ?? (sourceProduct == null ? void 0 : sourceProduct.selling_price) ?? (sourceProduct == null ? void 0 : sourceProduct.base_price);
137
135
  const sourceProductPrice = toPriceString(
138
- hasPriceOverride ? catalogSourcePrice ?? payload.price ?? payload.selling_price : payload.price ?? payload.selling_price ?? catalogSourcePrice,
136
+ payload.price ?? payload.selling_price ?? (matchedVariant == null ? void 0 : matchedVariant.price) ?? (matchedVariant == null ? void 0 : matchedVariant.base_price) ?? (origin == null ? void 0 : origin.price) ?? (origin == null ? void 0 : origin.base_price) ?? (sourceProduct == null ? void 0 : sourceProduct.price) ?? (sourceProduct == null ? void 0 : sourceProduct.selling_price) ?? (sourceProduct == null ? void 0 : sourceProduct.base_price),
139
137
  "0.00"
140
138
  );
141
139
  const explicitLineTotal = payload.line_total ?? payload.total ?? ((_c = payload._extend) == null ? void 0 : _c.total);
142
140
  const hasExplicitLineTotal = Number.isFinite(Number(explicitLineTotal));
143
141
  const lineCompositeTotal = toPriceString(explicitLineTotal, sourceProductPrice);
142
+ const hasPriceOverride = payload.price_override !== void 0 && payload.price_override !== null && payload.price_override !== "";
144
143
  const productOptionItem = (0, import_utils.normalizeProductSkuOptions)(
145
144
  normalizeOptionItems(
146
145
  ((_d = payload.product_sku) == null ? void 0 : _d.option) ?? payload.option ?? payload.options ?? payload.product_option_item
@@ -217,7 +216,7 @@ function transformBaseProductToOrderProduct(params) {
217
216
  }
218
217
  const productTitle = {
219
218
  ...(sourceProduct == null ? void 0 : sourceProduct.title_i18n) || {},
220
- original: (sourceProduct == null ? void 0 : sourceProduct.original_title) || (sourceProduct == null ? void 0 : sourceProduct.title) || ""
219
+ original: (sourceProduct == null ? void 0 : sourceProduct.title) || ""
221
220
  };
222
221
  return {
223
222
  product_id: productId,
@@ -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 | 3 | 4 | 5 | 6;
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 配置");
@@ -368,7 +360,6 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
368
360
  }
369
361
  return {
370
362
  isAvailable: raw.isAvailable,
371
- ...raw.isAccepted !== void 0 ? { isAccepted: raw.isAccepted } : {},
372
363
  type: raw.type,
373
364
  unavailableReason: raw.unavailableReason,
374
365
  scannedDiscountList: raw.scannedDiscountList
@@ -723,53 +714,11 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
723
714
  return this.getOrderCustomerSnapshot();
724
715
  }
725
716
  /**
726
- * 通过 ids 获取商品列表;默认只读取内存,显式开启 loadMissing 时按当前订单上下文补查缺失商品。
727
- * 补查直接写入 ProductList,不更新 BookingTicket.productCatalog,避免当前商品列表被查询子集覆盖。
717
+ * 通过 ids 获取商品列表(不加载到模块中)
718
+ * @returns 商品列表
728
719
  */
729
- async getProductByIds(ids, options) {
730
- var _a, _b;
731
- const normalizedIds = Array.from(
732
- new Set(
733
- (ids || []).map((id) => Number(id)).filter((id) => Number.isFinite(id))
734
- )
735
- );
736
- const localProducts = await this.store.products.getProductByIds(normalizedIds) || [];
737
- if (!(options == null ? void 0 : options.loadMissing)) {
738
- return localProducts;
739
- }
740
- const localProductIds = new Set(
741
- localProducts.map((product) => Number(product.id))
742
- );
743
- const missingIds = normalizedIds.filter(
744
- (id) => !localProductIds.has(id)
745
- );
746
- if (!missingIds.length) {
747
- return localProducts;
748
- }
749
- const rawBookingDate = this.getBookingDate();
750
- const bookingDate = rawBookingDate && (0, import_dayjs.default)(rawBookingDate).isValid() ? (0, import_dayjs.default)(rawBookingDate) : null;
751
- const customerId = Number(
752
- ((_a = this.getOrderCustomerSnapshot()) == null ? void 0 : _a.id) ?? ((_b = this.getOrderCustomer()) == null ? void 0 : _b.customer_id)
753
- );
754
- const loadedProducts = await this.store.products.loadProducts({
755
- product_ids: missingIds,
756
- with_count: ["bundleGroup", "optionGroup"],
757
- with_schedule: 1,
758
- cacheId: this.cacheId,
759
- ...bookingDate ? {
760
- schedule_date: bookingDate.format("YYYY-MM-DD"),
761
- schedule_datetime: bookingDate.format("YYYY-MM-DD HH:mm:ss")
762
- } : {},
763
- ...Number.isFinite(customerId) && customerId > 0 ? { customer_id: customerId } : {}
764
- });
765
- const productById = /* @__PURE__ */ new Map();
766
- [...localProducts, ...loadedProducts || []].forEach((product) => {
767
- const productId = Number(product.id);
768
- if (Number.isFinite(productId)) {
769
- productById.set(productId, product);
770
- }
771
- });
772
- return normalizedIds.map((id) => productById.get(id)).filter((product) => Boolean(product));
720
+ async getProductByIds(ids) {
721
+ return this.store.products.getProductByIds(ids);
773
722
  }
774
723
  /**
775
724
  * 获取日程时间段点
@@ -1204,8 +1153,7 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
1204
1153
  }
1205
1154
  /** 读取当前 booking config。 */
1206
1155
  getBookingConfig() {
1207
- var _a;
1208
- return (_a = this.store.bookingContext) == null ? void 0 : _a.getBookingConfig();
1156
+ return this.store.bookingContext.getBookingConfig();
1209
1157
  }
1210
1158
  /** 写入资源全集(来源:`/form/schedule`),同步派生 resourcesOriginMap。 */
1211
1159
  setResources(resources) {
@@ -1441,9 +1389,7 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
1441
1389
  decideAddProduct: (item, options) => this.decideAddProduct(item, options),
1442
1390
  decideAfterDetail: (cacheItem, options) => this.decideAfterDetail(cacheItem, options),
1443
1391
  transformDetailToProductAndBooking: (input) => this.transformDetailToProductAndBooking(input),
1444
- addProductToOrder: (product, booking) => this.addProductToOrder(product, booking),
1445
- refreshWalletAssets: (params) => this.refreshWalletAssets(params),
1446
- scanWalletAsset: (scanCode) => this.scanWalletAsset(scanCode)
1392
+ addProductToOrder: (product, booking) => this.addProductToOrder(product, booking)
1447
1393
  },
1448
1394
  formatted,
1449
1395
  bridge
@@ -1568,7 +1514,10 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
1568
1514
  });
1569
1515
  }
1570
1516
  if (typeof this.store.order.addProductsToOrder === "function") {
1571
- return this.store.order.addProductsToOrder(orderLines);
1517
+ return this.store.order.addProductsToOrder(orderLines, {
1518
+ skipEditDiscountConfigRefresh: true,
1519
+ skipDiscountRecalculation: true
1520
+ });
1572
1521
  }
1573
1522
  const result = [];
1574
1523
  for (const line of orderLines) {
@@ -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
  }
@@ -232,7 +232,6 @@ export interface GlobalScanHostBridge {
232
232
  */
233
233
  applyPromotionCode?: (code: string, customerId?: number) => Promise<{
234
234
  isAvailable?: boolean;
235
- isAccepted?: boolean;
236
235
  type?: string;
237
236
  unavailableReason?: string;
238
237
  }>;
@@ -24,14 +24,6 @@ export interface GlobalScanApplyHost {
24
24
  cacheItem: any;
25
25
  };
26
26
  addProductToOrder(product: any, booking?: any): Promise<any>;
27
- refreshWalletAssets?(params?: {
28
- preserveSelection?: boolean;
29
- }): Promise<any>;
30
- scanWalletAsset?(code: string): Promise<{
31
- type: 'walletCode' | 'normalCode';
32
- asset?: any;
33
- selected: boolean;
34
- }>;
35
27
  }
36
28
  /**
37
29
  * 应用全局扫码格式化结果:设客户 / 加车 / 开单 / 弹窗链。
@@ -101,55 +101,23 @@ async function applyGlobalScan(host, formatted, bridge) {
101
101
  return { status: "success", kind: "customer" };
102
102
  }
103
103
  if (searchType === "walletPass") {
104
+ if (!data) {
105
+ (_c = bridge == null ? void 0 : bridge.onNotify) == null ? void 0 : _c.call(bridge, "fail", "pisell2.text.scan-global-failed");
106
+ return { status: "failed", reason: "invalid_data" };
107
+ }
104
108
  const snapshot = host.getOrderCustomerSnapshot();
105
109
  const scannedCustomerIsWalkIn = (0, import_cartView.isWalkInCustomer)(data);
106
- const trySelectWalletAsset = async () => {
107
- var _a2, _b2;
108
- if (!host.scanWalletAsset)
109
- return null;
110
- const walletResult = await host.scanWalletAsset(scanCode).catch((error) => {
111
- console.warn("[GlobalScan] Wallet asset lookup failed", error);
112
- return null;
113
- });
114
- if (!walletResult)
115
- return null;
116
- if (walletResult.type !== "normalCode" || !walletResult.asset) {
117
- return null;
118
- }
119
- if (walletResult.selected) {
120
- (_a2 = bridge == null ? void 0 : bridge.onNotify) == null ? void 0 : _a2.call(bridge, "success");
121
- return { status: "success", kind: "promotion" };
122
- }
123
- (_b2 = bridge == null ? void 0 : bridge.onNotify) == null ? void 0 : _b2.call(bridge, "fail", "pisell2.text.goodpass.code-invalid-cart");
124
- return { status: "failed", reason: "invalid_data" };
125
- };
126
110
  if ((0, import_cartView.isWalkInCustomer)(snapshot) || scannedCustomerIsWalkIn) {
127
- const walletSelection2 = await trySelectWalletAsset();
128
- if (walletSelection2)
129
- return walletSelection2;
130
111
  if (!(bridge == null ? void 0 : bridge.applyPromotionCode)) {
131
112
  return { status: "failed", reason: "no_bridge" };
132
113
  }
133
114
  const result = await bridge.applyPromotionCode(scanCode);
134
- if ((result == null ? void 0 : result.isAccepted) ?? (result == null ? void 0 : result.isAvailable)) {
115
+ if (result == null ? void 0 : result.isAvailable) {
135
116
  return { status: "success", kind: "promotion" };
136
117
  }
137
118
  return { status: "failed", reason: "invalid_data" };
138
119
  }
139
120
  host.setOrderCustomer(data);
140
- await ((_c = host.refreshWalletAssets) == null ? void 0 : _c.call(host, { preserveSelection: false }));
141
- const walletSelection = await trySelectWalletAsset();
142
- if (walletSelection)
143
- return walletSelection;
144
- if (bridge == null ? void 0 : bridge.applyPromotionCode) {
145
- const promotionResult = await bridge.applyPromotionCode(
146
- scanCode,
147
- Number((data == null ? void 0 : data.id) ?? (data == null ? void 0 : data.customer_id)) || void 0
148
- );
149
- if ((promotionResult == null ? void 0 : promotionResult.isAccepted) ?? (promotionResult == null ? void 0 : promotionResult.isAvailable)) {
150
- return { status: "success", kind: "promotion" };
151
- }
152
- }
153
121
  (_d = bridge == null ? void 0 : bridge.onNotify) == null ? void 0 : _d.call(bridge, "success", "pisell2.text.add-client-success");
154
122
  return { status: "success", kind: "customer" };
155
123
  }
@@ -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;
@@ -95,7 +94,6 @@ export declare class SalesImpl extends BaseModule implements Module, SalesModule
95
94
  * 2) 若无 active,返回已超时且仍占用中的预约(允许并发多条)
96
95
  * 3) 若仍无,返回最近一组未来预约(同 start_time 的并发预约全部返回)
97
96
  * 4) 最后兜底返回一条(避免资源有历史预约时完全无反馈)
98
- * - includeAllFuture 时,保留选中预约并返回当天全部后续预约;仅详情接口启用。
99
97
  */
100
98
  private pickBookingsForCurrentPoint;
101
99
  /**