@pisell/pisellos 2.3.170 → 2.3.172

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 (82) hide show
  1. package/dist/index.d.ts +1 -0
  2. package/dist/index.js +1 -0
  3. package/dist/inventory/index.d.ts +92 -0
  4. package/dist/inventory/index.js +509 -0
  5. package/dist/model/strategy/adapter/promotion/evaluator.js +5 -4
  6. package/dist/modules/Discount/index.js +1 -0
  7. package/dist/modules/Discount/types.d.ts +4 -0
  8. package/dist/modules/Order/index.d.ts +25 -3
  9. package/dist/modules/Order/index.js +1791 -1318
  10. package/dist/modules/Order/types.d.ts +7 -0
  11. package/dist/modules/Order/utils/discountProductLineIdentity.js +2 -2
  12. package/dist/modules/Order/utils/productVoucherGroups.d.ts +15 -0
  13. package/dist/modules/Order/utils/productVoucherGroups.js +115 -0
  14. package/dist/modules/Payment/walletpass.js +32 -6
  15. package/dist/modules/Product/index.d.ts +1 -1
  16. package/dist/modules/ProductList/index.js +33 -12
  17. package/dist/modules/Rules/index.d.ts +5 -10
  18. package/dist/modules/Rules/index.js +197 -107
  19. package/dist/modules/Rules/promotionSelection.d.ts +14 -0
  20. package/dist/modules/Rules/promotionSelection.js +390 -0
  21. package/dist/modules/Rules/types.d.ts +9 -0
  22. package/dist/server/modules/order/index.d.ts +6 -0
  23. package/dist/server/modules/order/index.js +782 -447
  24. package/dist/solution/BaseSales/index.d.ts +16 -1
  25. package/dist/solution/BaseSales/index.js +1545 -1339
  26. package/dist/solution/BaseSales/utils/cartPromotion.js +5 -2
  27. package/dist/solution/BookingByStep/index.d.ts +2 -2
  28. package/dist/solution/BookingTicket/index.js +200 -108
  29. package/dist/solution/BookingTicket/types.d.ts +14 -2
  30. package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +1 -1
  31. package/dist/solution/BookingTicket/utils/addProductDecision.js +4 -3
  32. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +94 -58
  33. package/dist/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.d.ts +10 -0
  34. package/dist/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.js +117 -0
  35. package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +1 -0
  36. package/dist/solution/BookingTicket/utils/scan/handleScan.js +2 -1
  37. package/dist/solution/UnifiedBookingSales/index.d.ts +1 -1
  38. package/dist/solution/UnifiedBookingSales/index.js +69 -49
  39. package/dist/utils/platform.d.ts +2 -0
  40. package/dist/utils/platform.js +6 -0
  41. package/lib/index.d.ts +1 -0
  42. package/lib/index.js +12 -0
  43. package/lib/inventory/index.d.ts +92 -0
  44. package/lib/inventory/index.js +287 -0
  45. package/lib/model/strategy/adapter/promotion/evaluator.js +5 -4
  46. package/lib/model/strategy/adapter/promotion/index.js +1 -46
  47. package/lib/modules/Discount/index.js +1 -0
  48. package/lib/modules/Discount/types.d.ts +4 -0
  49. package/lib/modules/Order/index.d.ts +25 -3
  50. package/lib/modules/Order/index.js +203 -38
  51. package/lib/modules/Order/types.d.ts +7 -0
  52. package/lib/modules/Order/utils/discountProductLineIdentity.js +1 -1
  53. package/lib/modules/Order/utils/productVoucherGroups.d.ts +15 -0
  54. package/lib/modules/Order/utils/productVoucherGroups.js +64 -0
  55. package/lib/modules/Payment/walletpass.js +23 -1
  56. package/lib/modules/Product/index.d.ts +1 -1
  57. package/lib/modules/ProductList/index.js +15 -0
  58. package/lib/modules/Rules/index.d.ts +5 -10
  59. package/lib/modules/Rules/index.js +68 -22
  60. package/lib/modules/Rules/promotionSelection.d.ts +14 -0
  61. package/lib/modules/Rules/promotionSelection.js +230 -0
  62. package/lib/modules/Rules/types.d.ts +9 -0
  63. package/lib/server/modules/order/index.d.ts +6 -0
  64. package/lib/server/modules/order/index.js +226 -29
  65. package/lib/solution/BaseSales/index.d.ts +16 -1
  66. package/lib/solution/BaseSales/index.js +108 -14
  67. package/lib/solution/BaseSales/utils/cartPromotion.js +5 -2
  68. package/lib/solution/BookingByStep/index.d.ts +2 -2
  69. package/lib/solution/BookingTicket/index.js +38 -2
  70. package/lib/solution/BookingTicket/types.d.ts +14 -2
  71. package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +1 -1
  72. package/lib/solution/BookingTicket/utils/addProductDecision.js +4 -3
  73. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +14 -2
  74. package/lib/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.d.ts +10 -0
  75. package/lib/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.js +71 -0
  76. package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +1 -0
  77. package/lib/solution/BookingTicket/utils/scan/handleScan.js +2 -1
  78. package/lib/solution/UnifiedBookingSales/index.d.ts +1 -1
  79. package/lib/solution/UnifiedBookingSales/index.js +14 -3
  80. package/lib/utils/platform.d.ts +2 -0
  81. package/lib/utils/platform.js +7 -0
  82. package/package.json +1 -1
@@ -0,0 +1,287 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.salesGuardError = exports.InventoryController = void 0;
7
+ /** Optional, instance-scoped sales inventory. Never stored in ProductData or order payloads. */
8
+
9
+ const salesGuardError = message => Object.assign(new Error(message), {
10
+ code: 'SALES_GUARD_REJECTED'
11
+ });
12
+ exports.salesGuardError = salesGuardError;
13
+ const cancelled = () => Object.assign(new Error('Inventory request cancelled'), {
14
+ name: 'AbortError'
15
+ });
16
+ const variantIdentity = (productId, variantId) => JSON.stringify([String(productId), String(variantId ?? 0)]);
17
+ class InventoryController {
18
+ identity = Symbol('sales-inventory-instance');
19
+ scopeKey;
20
+ entries = new Map();
21
+ lastQuantities = new Map();
22
+ products = new Map();
23
+ keys = new Map();
24
+ catalogProducts = new Map();
25
+ listeners = new Set();
26
+ revision = 0;
27
+ state = 'stale';
28
+ pending;
29
+ disposed = false;
30
+ constructor(source) {
31
+ this.source = source;
32
+ this.scopeKey = source.scopeKey;
33
+ }
34
+ getRevision = () => this.revision;
35
+ subscribe = listener => {
36
+ this.listeners.add(listener);
37
+ return () => {
38
+ this.listeners.delete(listener);
39
+ };
40
+ };
41
+ publish() {
42
+ this.revision += 1;
43
+ this.listeners.forEach(listener => {
44
+ try {
45
+ listener();
46
+ } catch {/* A view cannot interrupt a stock update. */}
47
+ });
48
+ }
49
+ assertCurrent(signal) {
50
+ if (this.disposed || signal?.aborted) throw cancelled();
51
+ this.source.assertCurrent();
52
+ }
53
+ activate() {
54
+ this.disposed = false;
55
+ }
56
+ dispose() {
57
+ this.disposed = true;
58
+ this.invalidate();
59
+ }
60
+ invalidate() {
61
+ this.pending?.controller.abort();
62
+ this.pending = undefined;
63
+ this.state = 'stale';
64
+ this.publish();
65
+ }
66
+
67
+ /** Catalog replaces identities; partial detail only merges its variants, never its prices. */
68
+ registerProducts(products, complete = false) {
69
+ this.assertCurrent();
70
+ let changed = false;
71
+ for (const product of products) {
72
+ const id = String(product.id ?? product.product_id);
73
+ if (complete && this.catalogProducts.get(id) === product) continue;
74
+ if (complete) this.catalogProducts.set(id, product);
75
+ const previous = this.products.get(id);
76
+ if (complete) for (const variantId of previous?.keys() || []) this.keys.delete(variantIdentity(id, variantId));
77
+ const variants = complete ? new Map() : new Map(previous);
78
+ const list = product.variant?.length ? product.variant : [{
79
+ id: 0,
80
+ code: product.code
81
+ }];
82
+ for (const variant of list) {
83
+ const variantId = String(variant.id ?? variant.product_variant_id ?? 0);
84
+ const key = this.source.keyOf(product, variant) ?? previous?.get(variantId);
85
+ variants.set(variantId, key);
86
+ this.keys.set(variantIdentity(id, variantId), key);
87
+ }
88
+ if (!previous || previous.size !== variants.size || [...variants].some(([id, key]) => previous.get(id) !== key)) changed = true;
89
+ this.products.set(id, variants);
90
+ }
91
+ if (changed) this.publish();
92
+ }
93
+
94
+ /** Consumers share I/O; cancelling one detail does not cancel another consumer. */
95
+ async refresh(context) {
96
+ this.assertCurrent(context.signal);
97
+ if (context.force) this.invalidate();
98
+ let read = this.pending;
99
+ if (!read) {
100
+ read = {
101
+ controller: new AbortController(),
102
+ consumers: 0,
103
+ promise: Promise.resolve()
104
+ };
105
+ const current = read;
106
+ this.pending = current;
107
+ this.state = 'loading';
108
+ this.publish();
109
+ current.promise = (async () => {
110
+ try {
111
+ const entries = await this.source.read({
112
+ reason: context.reason,
113
+ signal: current.controller.signal
114
+ });
115
+ this.assertCurrent(current.controller.signal);
116
+ if (this.pending !== current) throw cancelled();
117
+ this.entries = entries;
118
+ for (const [key, stock] of entries) if (stock.quantity !== null && Number.isSafeInteger(stock.quantity) && stock.quantity >= 0) this.lastQuantities.set(key, stock.quantity);
119
+ this.state = 'ready';
120
+ } catch (error) {
121
+ if (this.pending !== current || current.controller.signal.aborted) throw cancelled();
122
+ this.state = 'error';
123
+ throw error;
124
+ } finally {
125
+ if (this.pending === current) {
126
+ this.pending = undefined;
127
+ this.publish();
128
+ }
129
+ }
130
+ })();
131
+ }
132
+ read.consumers += 1;
133
+ try {
134
+ if (!context.signal) await read.promise;else await new Promise((resolve, reject) => {
135
+ const signal = context.signal;
136
+ const abort = () => reject(cancelled());
137
+ signal.addEventListener('abort', abort, {
138
+ once: true
139
+ });
140
+ read.promise.then(resolve, reject).finally(() => signal.removeEventListener('abort', abort));
141
+ if (signal.aborted) abort();
142
+ });
143
+ this.assertCurrent(context.signal);
144
+ } finally {
145
+ read.consumers -= 1;
146
+ if (this.pending === read && read.consumers === 0) this.invalidate();
147
+ }
148
+ }
149
+ availabilityForKey(key) {
150
+ const stock = key ? this.entries.get(key) : undefined;
151
+ const quantity = key ? this.lastQuantities.get(key) : undefined;
152
+ if (this.state !== 'ready') return {
153
+ status: this.state,
154
+ quantity,
155
+ message: this.source.message('unavailable')
156
+ };
157
+ if (!stock) return {
158
+ status: 'unmapped',
159
+ quantity,
160
+ message: this.source.message('unmapped')
161
+ };
162
+ if (stock.quantity === null || !Number.isSafeInteger(stock.quantity) || stock.quantity < 0) return {
163
+ status: 'error',
164
+ quantity,
165
+ message: stock.message || this.source.message('unavailable')
166
+ };
167
+ return {
168
+ status: 'ready',
169
+ quantity: stock.quantity
170
+ };
171
+ }
172
+ availability(product, variantId) {
173
+ const id = product.id ?? product.product_id;
174
+ if (variantId !== undefined && variantId !== null) return this.availabilityForKey(this.keys.get(variantIdentity(id, variantId)));
175
+ const keys = [...new Set(this.products.get(String(id))?.values() || [])];
176
+ const states = keys.map(key => this.availabilityForKey(key));
177
+ if (!states.length) return this.availabilityForKey();
178
+ // Unmapped variants are not offered by this source. Exclude even their last
179
+ // known quantities, while preserving errors on variants that are configured.
180
+ const mappedStates = states.filter(entry => entry.status !== 'unmapped');
181
+ if (!mappedStates.length) return {
182
+ status: 'unmapped',
183
+ message: this.source.message('unmapped')
184
+ };
185
+ const quantity = mappedStates.every(entry => entry.quantity !== undefined) ? mappedStates.reduce((sum, entry) => sum + entry.quantity, 0) : undefined;
186
+ const failed = mappedStates.find(entry => entry.status !== 'ready');
187
+ if (quantity !== undefined && !Number.isSafeInteger(quantity)) return {
188
+ status: 'error',
189
+ message: this.source.message('unavailable')
190
+ };
191
+ return {
192
+ status: failed?.status || 'ready',
193
+ quantity,
194
+ message: failed?.message
195
+ };
196
+ }
197
+ keyForLine(item) {
198
+ return this.keys.get(variantIdentity(item.product_id, item.product_variant_id ?? item.product_sku?.product_variant_id));
199
+ }
200
+ /** Advisory UI limit only. The serialized cart guard remains authoritative. */
201
+ selectionAvailability(product, variantId, items, editingItem) {
202
+ const identity = variantIdentity(product.id ?? product.product_id, variantId);
203
+ const key = this.keys.get(identity);
204
+ let availability = this.availabilityForKey(key);
205
+ let reserved = 0;
206
+ let retainedQuantity = 0;
207
+ for (const item of items) {
208
+ const matches = key ? this.keyForLine(item) === key : variantIdentity(item.product_id, item.product_variant_id ?? item.product_sku?.product_variant_id) === identity;
209
+ if (!matches) continue;
210
+ const count = Number(item.num ?? item.quantity);
211
+ if (!Number.isSafeInteger(count) || count < 0) {
212
+ availability = {
213
+ ...availability,
214
+ status: 'error',
215
+ message: this.source.message('unavailable')
216
+ };
217
+ continue;
218
+ }
219
+ if (item === editingItem) retainedQuantity = count;else reserved += count;
220
+ }
221
+ if (!Number.isSafeInteger(reserved)) {
222
+ availability = {
223
+ ...availability,
224
+ status: 'error',
225
+ message: this.source.message('unavailable')
226
+ };
227
+ }
228
+ const availableQuantity = availability.status === 'ready' ? Math.max(0, availability.quantity - reserved) : 0;
229
+ return {
230
+ availability,
231
+ availableQuantity,
232
+ retainedQuantity,
233
+ maxQuantity: Math.max(availableQuantity, retainedQuantity)
234
+ };
235
+ }
236
+ totals(items) {
237
+ const totals = new Map();
238
+ for (const item of items) {
239
+ const key = this.keyForLine(item);
240
+ const identity = key ? JSON.stringify(['inventory', key]) : variantIdentity(item.product_id, item.product_variant_id);
241
+ const quantity = Number(item.num ?? item.quantity);
242
+ if (!Number.isSafeInteger(quantity) || quantity < 0) throw salesGuardError(this.source.message('unavailable'));
243
+ if (!quantity) continue;
244
+ const total = (totals.get(identity)?.quantity || 0) + quantity;
245
+ if (!Number.isSafeInteger(total)) throw salesGuardError(this.source.message('unavailable'));
246
+ totals.set(identity, {
247
+ key,
248
+ quantity: total
249
+ });
250
+ }
251
+ return totals;
252
+ }
253
+ validate(proposed, current = [], allowReductions = true) {
254
+ this.assertCurrent();
255
+ const previous = this.totals(current);
256
+ for (const [identity, {
257
+ key,
258
+ quantity
259
+ }] of this.totals(proposed)) {
260
+ if (allowReductions && quantity <= (previous.get(identity)?.quantity || 0)) continue;
261
+ const stock = this.availabilityForKey(key);
262
+ if (stock.status !== 'ready') throw salesGuardError(stock.message || this.source.message('unavailable'));
263
+ if (quantity > stock.quantity) throw salesGuardError(this.source.message('insufficient', {
264
+ key: key,
265
+ quantity: stock.quantity
266
+ }));
267
+ }
268
+ }
269
+ freezeCheckout(items) {
270
+ if (!items.length || items.some(item => Number(item.num ?? item.quantity) <= 0)) {
271
+ throw salesGuardError(this.source.message('unavailable'));
272
+ }
273
+ this.validate(items, [], false);
274
+ return Object.freeze({
275
+ scopeKey: this.scopeKey,
276
+ revision: this.revision,
277
+ lines: Object.freeze(items.map((item, index) => Object.freeze({
278
+ lineId: String(item.metadata?.unique_identification_number ?? item.unique_identification_number ?? item.order_detail_id ?? index),
279
+ productId: item.product_id,
280
+ variantId: item.product_variant_id ?? item.product_sku?.product_variant_id ?? 0,
281
+ quantity: Number(item.num ?? item.quantity),
282
+ inventoryKey: this.keyForLine(item)
283
+ })))
284
+ });
285
+ }
286
+ }
287
+ exports.InventoryController = InventoryController;
@@ -646,6 +646,7 @@ class PromotionEvaluator {
646
646
  // 按组内原价比例均摊
647
647
  // 记录每个原商品的均摊价格累加(用于后续聚合)
648
648
  const allocatedPricesByProductId = new Map();
649
+ let expectedPromoTotal = new _decimal.default(0);
649
650
  for (let g = 0; g < groupCount; g++) {
650
651
  const startIdx = g * x;
651
652
  const endIdx = startIdx + x;
@@ -654,8 +655,9 @@ class PromotionEvaluator {
654
655
  // 计算组内原价总和
655
656
  const groupOriginalTotal = groupUnits.reduce((sum, u) => sum.plus(u.price), new _decimal.default(0));
656
657
 
657
- // 按原价比例均摊
658
- const groupPriceDecimal = new _decimal.default(groupPrice);
658
+ // 组价高于本组原价时保留原价,尾差目标也必须使用封顶后的实际组价。
659
+ const groupPriceDecimal = _decimal.default.min(new _decimal.default(groupPrice), groupOriginalTotal);
660
+ expectedPromoTotal = expectedPromoTotal.plus(groupPriceDecimal);
659
661
  let allocatedSum = new _decimal.default(0);
660
662
  for (let i = 0; i < groupUnits.length; i++) {
661
663
  const unit = groupUnits[i];
@@ -759,9 +761,8 @@ class PromotionEvaluator {
759
761
  processedQuantityMap.set(key, processedQty + availableQty);
760
762
  }
761
763
 
762
- // 8. 尾差调整:确保促销商品的 finalPrice × quantity 之和精确等于 groupPrice × groupCount
764
+ // 8. 尾差调整:只补实际组价的舍入差额,不将高于原价的组价补到某一件。
763
765
  if (groupCount > 0) {
764
- const expectedPromoTotal = new _decimal.default(groupPrice).mul(groupCount);
765
766
  const promoItems = result.filter(p => p.inPromotion);
766
767
  let actualPromoTotal = new _decimal.default(0);
767
768
  for (const p of promoItems) {
@@ -1,46 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "BUY_X_GET_Y_FREE_STRATEGY", {
7
- enumerable: true,
8
- get: function () {
9
- return _examples.BUY_X_GET_Y_FREE_STRATEGY;
10
- }
11
- });
12
- Object.defineProperty(exports, "ITEM_REWARD_STRATEGY", {
13
- enumerable: true,
14
- get: function () {
15
- return _examples.ITEM_REWARD_STRATEGY;
16
- }
17
- });
18
- Object.defineProperty(exports, "PromotionAdapter", {
19
- enumerable: true,
20
- get: function () {
21
- return _adapter.PromotionAdapter;
22
- }
23
- });
24
- Object.defineProperty(exports, "PromotionEvaluator", {
25
- enumerable: true,
26
- get: function () {
27
- return _evaluator.PromotionEvaluator;
28
- }
29
- });
30
- Object.defineProperty(exports, "X_ITEMS_FOR_Y_PRICE_STRATEGY", {
31
- enumerable: true,
32
- get: function () {
33
- return _examples.X_ITEMS_FOR_Y_PRICE_STRATEGY;
34
- }
35
- });
36
- Object.defineProperty(exports, "default", {
37
- enumerable: true,
38
- get: function () {
39
- return _adapter.default;
40
- }
41
- });
42
- var _evaluator = require("./evaluator");
43
- var _adapter = _interopRequireWildcard(require("./adapter"));
44
- var _examples = require("./examples");
45
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
46
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
1
+ "use strict";
@@ -141,6 +141,7 @@ class DiscountModule extends _BaseModule.BaseModule {
141
141
  } = options || {};
142
142
  const result = await this.request.get(`/machinecode/batch-search`, {
143
143
  code,
144
+ resolve_ticket_order: 1,
144
145
  translate_flag: 1,
145
146
  tags: ['entitlement_pass', 'good_pass', 'product_discount_card'],
146
147
  // available: 1,
@@ -158,6 +158,10 @@ export interface Discount {
158
158
  discount_calculation_mode: 'item_level' | 'order_level';
159
159
  };
160
160
  isManualSelect?: boolean;
161
+ /** X 件 Y 元互斥选择的手动意图;isSelected 只表示本次实际应用结果。 */
162
+ promotionSelection?: 'card' | 'promotion';
163
+ /** 记录手动操作影响的促销组,避免卡失效后普通重算丢失取消意图。 */
164
+ promotionSelectionStrategyIds?: string[];
161
165
  isDisabled?: boolean;
162
166
  isSelected?: boolean;
163
167
  isAvailable?: boolean;
@@ -4,7 +4,8 @@ import { OrderModuleAPI, CommitOrderParams, UpdateOrderBookingParams, UpdateOrde
4
4
  import { CartItem } from '../Cart/types';
5
5
  import { type SubmitPayloadEnhancer } from './utils';
6
6
  import { type PickupTimingBooking, type PickupTimingBookingInput } from './pickupTiming';
7
- import type { OrderAmountSnapshot, AddProductBookingInput, AddProductToOrderOptions, OrderIdentitySnapshot, OrderPaymentSource, OrderSnapshot, OrderSyncState, SyncPaymentsToOrderParams, SyncPaymentsToOrderResult, SubmitSalesOrderParams, OrderProduct, OrderProductIdentity, OrderSummary, OrderTempOrder, OrderPaymentData, OrderPaymentUpdateOptions, OrderPaymentUpdateResult, SendCustomerPayLinkParams, UpdateTempOrderCustomerInput, OrderCustomerPatch, OrderCustomerView, OrderCartIntentCommitContext, ReplaceTempOrderOptions, OrderPromotionEvaluator, OrderGiftSelectResolver, OrderUnfulfilledPromotion, OrderLastGiftActions, RemoveProductsFromOrderOptions, SalesNote, SalesNotesMutationSnapshot, SetSalesNoteInput, PickupReferenceMode, PointCardSnapshotMergeContext, PointCardSnapshotItem, ShopServiceData, ShopServiceType } from './types';
7
+ import { type ProductVoucherGroup } from './utils/productVoucherGroups';
8
+ import type { OrderAmountSnapshot, AddProductBookingInput, AddProductToOrderOptions, OrderIdentitySnapshot, OrderPaymentSource, OrderSnapshot, OrderSyncState, SyncPaymentsToOrderParams, SyncPaymentsToOrderResult, SubmitSalesOrderParams, OrderProduct, OrderProductIdentity, OrderSummary, OrderTempOrder, OrderPaymentData, OrderPaymentUpdateOptions, OrderPaymentUpdateResult, SendCustomerPayLinkParams, UpdateTempOrderCustomerInput, OrderCustomerPatch, OrderCustomerView, OrderHooksConfig, OrderCartIntentCommitContext, ReplaceTempOrderOptions, OrderPromotionEvaluator, OrderGiftSelectResolver, OrderUnfulfilledPromotion, OrderLastGiftActions, RemoveProductsFromOrderOptions, SalesNote, SalesNotesMutationSnapshot, SetSalesNoteInput, PickupReferenceMode, PointCardSnapshotMergeContext, PointCardSnapshotItem, ShopServiceData, ShopServiceType } from './types';
8
9
  import type { ICustomer } from '../AccountList/types';
9
10
  import type { Discount } from '../Discount/types';
10
11
  import { UnavailableReason } from '../Rules/types';
@@ -29,6 +30,12 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
29
30
  private rulesHooksOverride?;
30
31
  private moduleHooksOverride?;
31
32
  private orderHooks?;
33
+ private cartCommandQueue;
34
+ private queueCartCommand;
35
+ /** Use the exact Order normalizers/merge rules on a private draft, not a second projection. */
36
+ private beginCartMutation;
37
+ /** Serializes checkout preparation with local cart commands; hydration remains outside this guard. */
38
+ prepareCheckout<T>(prepare: (items: OrderProduct[]) => Promise<T>): Promise<T>;
32
39
  private otherParams?;
33
40
  /** 评估器引用;由 SalesSdkProvider 注入,未注入时 applyPromotion 静默跳过 */
34
41
  private promotionEvaluator;
@@ -66,7 +73,11 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
66
73
  * @example
67
74
  * orderModule.updateOtherParams({ cacheId: 'cache-2', channel: 'pos' });
68
75
  */
69
- updateOtherParams(params: Record<string, any>): void;
76
+ updateOtherParams(params: Record<string, any>, options?: {
77
+ hooks?: OrderHooksConfig;
78
+ changedParams?: Record<string, any>;
79
+ cover?: boolean;
80
+ }): void;
70
81
  /** Internal intent boundary shared with asynchronous scanner/detail flows. */
71
82
  createCartIntentCommitGuard(action: OrderCartIntentCommitContext['action'], tempOrder?: OrderTempOrder | null): () => void;
72
83
  /** PC/H5 属于在线店铺;其它或缺失平台统一沿用 POS 行为。 */
@@ -84,6 +95,8 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
84
95
  */
85
96
  private logError;
86
97
  private registerDiscountModules;
98
+ setProductVoucherGroups(groups: ProductVoucherGroup[]): void;
99
+ validateProductVoucherSelection(): void;
87
100
  private createDefaultRulesHooks;
88
101
  /**
89
102
  * Stable across notifyTempOrderChanged's immutable copy, but changes when a
@@ -102,7 +115,9 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
102
115
  getCustomerWalletPrepareConfigEpoch(): number;
103
116
  private syncScannedDiscountsToOriginalDiscountList;
104
117
  private ensureEditDiscountConfigForProductChange;
105
- scanCode(code: string, customerId?: number): Promise<{
118
+ scanCode(code: string, customerId?: number, options?: {
119
+ productVouchersOnly?: boolean;
120
+ }): Promise<{
106
121
  isAvailable: boolean;
107
122
  isAccepted?: boolean;
108
123
  discountList: Discount[];
@@ -482,6 +497,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
482
497
  * // → tempOrder.products 新增 3 行,每行 num=1,bookings 3 条
483
498
  */
484
499
  addProductToOrder(product: Partial<OrderProduct> & OrderProductIdentity, booking?: AddProductBookingInput, options?: AddProductToOrderOptions): Promise<OrderProduct[]>;
500
+ private addProductToOrderDraft;
485
501
  /**
486
502
  * 批量添加商品行,所有行追加完成后只触发一次促销、折扣、summary 重算与持久化。
487
503
  *
@@ -497,6 +513,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
497
513
  }>, options?: {
498
514
  skipEditDiscountConfigRefresh?: boolean;
499
515
  }): Promise<OrderProduct[]>;
516
+ private addProductsToOrderDraft;
500
517
  private getFullCoveragePassDiscounts;
501
518
  private hasEntitlementPassDiscount;
502
519
  private hasGoodPassDiscount;
@@ -508,10 +525,13 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
508
525
  private isRestrictedCartProductUpdate;
509
526
  private applyOrderProductUpdateToTempOrder;
510
527
  updateOrderProduct(params: UpdateOrderProductParams): Promise<OrderProduct[]>;
528
+ private updateOrderProductDraft;
511
529
  updateOrderProducts(paramsList: UpdateOrderProductParams[]): Promise<OrderProduct[]>;
530
+ private updateOrderProductsDraft;
512
531
  updateOrderProductQuantity(params: UpdateOrderProductQuantityParams, options?: {
513
532
  isCurrentOrder?: () => boolean;
514
533
  }): Promise<OrderProduct[]>;
534
+ private updateOrderProductQuantityDraft;
515
535
  updateOrderBooking(params: UpdateOrderBookingParams): any[];
516
536
  /**
517
537
  * 商品行写路径收尾:促销 → 折扣 → 清洗 → summary → 持久化。
@@ -528,12 +548,14 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
528
548
  * await order.removeProductsFromOrder([identityA, identityB]);
529
549
  */
530
550
  removeProductsFromOrder(identities: OrderProductIdentity[], options?: RemoveProductsFromOrderOptions): Promise<OrderProduct[]>;
551
+ private removeProductsFromOrderDraft;
531
552
  removeProductFromOrder(identity: OrderProductIdentity, options?: RemoveProductsFromOrderOptions): Promise<OrderProduct[]>;
532
553
  /**
533
554
  * 仅清空购物车行(products / bookings),不重置整单。
534
555
  * 普通整单 note 保持不变;以商品行为主体的 Sales Notes 同步删除。
535
556
  */
536
557
  clearOrderCartLines(): Promise<OrderTempOrder>;
558
+ private clearOrderCartLinesDraft;
537
559
  /**
538
560
  * 切换购物车结算单位时清理所有会影响新币种的订单状态,但保留当前客户。
539
561
  */