@pisell/pisellos 0.10.90 → 0.10.91

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 (227) hide show
  1. package/dist/model/strategy/adapter/itemRule/adapter.d.ts +3 -1
  2. package/dist/model/strategy/adapter/itemRule/adapter.js +74 -7
  3. package/dist/model/strategy/adapter/itemRule/evaluator.d.ts +3 -1
  4. package/dist/model/strategy/adapter/itemRule/evaluator.js +13 -0
  5. package/dist/model/strategy/adapter/itemRule/type.d.ts +40 -1
  6. package/dist/model/strategy/adapter/itemRule/type.js +10 -0
  7. package/dist/model/strategy/adapter/promotion/evaluator.d.ts +2 -1
  8. package/dist/model/strategy/adapter/promotion/evaluator.js +103 -112
  9. package/dist/modules/BookingContext/utils/calendarBooking.d.ts +15 -0
  10. package/dist/modules/BookingContext/utils/calendarBooking.js +207 -0
  11. package/dist/modules/BookingContext/utils/index.d.ts +1 -0
  12. package/dist/modules/BookingContext/utils/index.js +1 -0
  13. package/dist/modules/BookingContext/utils/productExtend.d.ts +21 -0
  14. package/dist/modules/BookingContext/utils/productExtend.js +132 -33
  15. package/dist/modules/BookingContext/utils/resources.js +1 -1
  16. package/dist/modules/Cart/index.js +4 -3
  17. package/dist/modules/Cart/types.d.ts +2 -0
  18. package/dist/modules/Cart/utils/cartProduct.d.ts +3 -1
  19. package/dist/modules/Cart/utils/cartProduct.js +59 -32
  20. package/dist/modules/Date/index.d.ts +1 -1
  21. package/dist/modules/Date/index.js +60 -14
  22. package/dist/modules/Date/types.d.ts +5 -0
  23. package/dist/modules/OpenData/salesSettings.js +1 -1
  24. package/dist/modules/OpenData/types.d.ts +9 -0
  25. package/dist/modules/OpenData/utils.d.ts +1 -1
  26. package/dist/modules/OpenData/utils.js +3 -2
  27. package/dist/modules/Order/index.d.ts +22 -7
  28. package/dist/modules/Order/index.js +1565 -1161
  29. package/dist/modules/Order/localEftposState.d.ts +13 -0
  30. package/dist/modules/Order/localEftposState.js +39 -0
  31. package/dist/modules/Order/types.d.ts +33 -11
  32. package/dist/modules/Order/types.js +2 -2
  33. package/dist/modules/Order/unpaidAmountGap.d.ts +6 -0
  34. package/dist/modules/Order/unpaidAmountGap.js +72 -0
  35. package/dist/modules/Order/utils.d.ts +4 -1
  36. package/dist/modules/Order/utils.js +75 -52
  37. package/dist/modules/Payment/walletpass.js +32 -6
  38. package/dist/modules/Product/types.d.ts +16 -0
  39. package/dist/modules/ProductList/index.js +1 -1
  40. package/dist/modules/ResourcePlanner/planner.d.ts +2 -0
  41. package/dist/modules/ResourcePlanner/planner.js +383 -24
  42. package/dist/modules/ResourcePlanner/types.d.ts +42 -0
  43. package/dist/modules/Rules/index.js +86 -54
  44. package/dist/modules/Schedule/index.d.ts +7 -1
  45. package/dist/modules/Schedule/index.js +155 -39
  46. package/dist/modules/Schedule/types.d.ts +2 -0
  47. package/dist/modules/bookingReadValidation.d.ts +6 -0
  48. package/dist/modules/bookingReadValidation.js +72 -0
  49. package/dist/plugins/request.d.ts +2 -0
  50. package/dist/server/index.d.ts +9 -0
  51. package/dist/server/index.js +1928 -1462
  52. package/dist/server/modules/form/index.d.ts +19 -0
  53. package/dist/server/modules/form/index.js +205 -0
  54. package/dist/server/modules/form/types.d.ts +13 -0
  55. package/dist/server/modules/form/types.js +3 -0
  56. package/dist/server/modules/index.d.ts +3 -0
  57. package/dist/server/modules/index.js +4 -0
  58. package/dist/server/modules/order/index.d.ts +21 -0
  59. package/dist/server/modules/order/index.js +1399 -831
  60. package/dist/server/modules/order/types.d.ts +3 -0
  61. package/dist/server/modules/order/utils/filterOrders.js +20 -0
  62. package/dist/server/modules/products/index.d.ts +28 -7
  63. package/dist/server/modules/products/index.js +1295 -769
  64. package/dist/server/modules/products/replication.d.ts +8 -0
  65. package/dist/server/modules/products/replication.js +69 -0
  66. package/dist/server/modules/products/types.d.ts +12 -1
  67. package/dist/server/modules/products/types.js +4 -0
  68. package/dist/shared/receipt/customerInvoiceLanguages.d.ts +1 -1
  69. package/dist/shared/receipt/customerInvoiceLanguages.js +5 -3
  70. package/dist/shared/receipt/small-ticket.d.ts +1 -0
  71. package/dist/shared/receipt/small-ticket.js +58 -26
  72. package/dist/shared/receipt/templateVisibility.d.ts +3 -0
  73. package/dist/shared/receipt/templateVisibility.js +6 -2
  74. package/dist/solution/BaseSales/fulfillmentItemRules.d.ts +27 -0
  75. package/dist/solution/BaseSales/fulfillmentItemRules.js +750 -0
  76. package/dist/solution/BaseSales/index.d.ts +22 -6
  77. package/dist/solution/BaseSales/index.js +1881 -1347
  78. package/dist/solution/BaseSales/pickupTiming.d.ts +4 -0
  79. package/dist/solution/BaseSales/pickupTiming.js +35 -8
  80. package/dist/solution/BaseSales/types.d.ts +4 -0
  81. package/dist/solution/BaseSales/types.js +1 -0
  82. package/dist/solution/BaseSales/utils/posDurationPricing.d.ts +21 -0
  83. package/dist/solution/BaseSales/utils/posDurationPricing.js +174 -0
  84. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +2 -0
  85. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +8 -8
  86. package/dist/solution/BookingByStep/index.d.ts +18 -2
  87. package/dist/solution/BookingByStep/index.js +681 -361
  88. package/dist/solution/BookingByStep/utils/resources.d.ts +10 -0
  89. package/dist/solution/BookingByStep/utils/resources.js +117 -76
  90. package/dist/solution/BookingTicket/index.d.ts +6 -0
  91. package/dist/solution/BookingTicket/index.js +666 -593
  92. package/dist/solution/BookingTicket/types.d.ts +1 -1
  93. package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +2 -1
  94. package/dist/solution/BookingTicket/utils/addProductDecision.js +35 -8
  95. package/dist/solution/BookingTicket/utils/redeemArrival.d.ts +3 -3
  96. package/dist/solution/BookingTicket/utils/resolveUniqueCartDetail.d.ts +8 -0
  97. package/dist/solution/BookingTicket/utils/resolveUniqueCartDetail.js +188 -0
  98. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +58 -94
  99. package/dist/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.d.ts +1 -3
  100. package/dist/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.js +33 -62
  101. package/dist/solution/OrderInvoicePreview/index.js +4 -3
  102. package/dist/solution/Sales/index.js +1 -1
  103. package/dist/solution/ScanOrder/index.d.ts +2 -0
  104. package/dist/solution/ScanOrder/index.js +230 -97
  105. package/dist/solution/ScanOrder/menuAvailability.d.ts +24 -0
  106. package/dist/solution/ScanOrder/menuAvailability.js +363 -0
  107. package/dist/solution/ScanOrder/types.d.ts +3 -0
  108. package/dist/solution/UnifiedBookingSales/index.d.ts +42 -10
  109. package/dist/solution/UnifiedBookingSales/index.js +2493 -1496
  110. package/dist/solution/UnifiedBookingSales/salesSettings.js +1 -1
  111. package/dist/solution/UnifiedBookingSales/types.d.ts +20 -5
  112. package/dist/utils/pos-receipt-auto-print.d.ts +4 -0
  113. package/dist/utils/pos-receipt-auto-print.js +14 -0
  114. package/lib/model/strategy/adapter/itemRule/adapter.d.ts +3 -1
  115. package/lib/model/strategy/adapter/itemRule/adapter.js +54 -4
  116. package/lib/model/strategy/adapter/itemRule/evaluator.d.ts +3 -1
  117. package/lib/model/strategy/adapter/itemRule/evaluator.js +9 -0
  118. package/lib/model/strategy/adapter/itemRule/type.d.ts +40 -1
  119. package/lib/model/strategy/adapter/itemRule/type.js +10 -0
  120. package/lib/model/strategy/adapter/promotion/evaluator.d.ts +2 -1
  121. package/lib/model/strategy/adapter/promotion/evaluator.js +22 -21
  122. package/lib/modules/BookingContext/utils/calendarBooking.d.ts +15 -0
  123. package/lib/modules/BookingContext/utils/calendarBooking.js +156 -0
  124. package/lib/modules/BookingContext/utils/index.d.ts +1 -0
  125. package/lib/modules/BookingContext/utils/index.js +11 -0
  126. package/lib/modules/BookingContext/utils/productExtend.d.ts +21 -0
  127. package/lib/modules/BookingContext/utils/productExtend.js +104 -5
  128. package/lib/modules/BookingContext/utils/resources.js +1 -1
  129. package/lib/modules/Cart/index.js +4 -2
  130. package/lib/modules/Cart/types.d.ts +2 -0
  131. package/lib/modules/Cart/utils/cartProduct.d.ts +3 -1
  132. package/lib/modules/Cart/utils/cartProduct.js +39 -20
  133. package/lib/modules/Date/index.d.ts +1 -1
  134. package/lib/modules/Date/index.js +28 -5
  135. package/lib/modules/Date/types.d.ts +5 -0
  136. package/lib/modules/OpenData/salesSettings.js +1 -1
  137. package/lib/modules/OpenData/types.d.ts +9 -0
  138. package/lib/modules/OpenData/utils.d.ts +1 -1
  139. package/lib/modules/OpenData/utils.js +3 -2
  140. package/lib/modules/Order/index.d.ts +22 -7
  141. package/lib/modules/Order/index.js +457 -174
  142. package/lib/modules/Order/localEftposState.d.ts +13 -0
  143. package/lib/modules/Order/localEftposState.js +44 -0
  144. package/lib/modules/Order/types.d.ts +33 -11
  145. package/lib/modules/Order/types.js +2 -2
  146. package/lib/modules/Order/unpaidAmountGap.d.ts +6 -0
  147. package/lib/modules/Order/unpaidAmountGap.js +60 -0
  148. package/lib/modules/Order/utils.d.ts +4 -1
  149. package/lib/modules/Order/utils.js +29 -3
  150. package/lib/modules/Payment/walletpass.js +23 -1
  151. package/lib/modules/Product/types.d.ts +16 -0
  152. package/lib/modules/ProductList/index.js +1 -1
  153. package/lib/modules/ResourcePlanner/planner.d.ts +2 -0
  154. package/lib/modules/ResourcePlanner/planner.js +299 -9
  155. package/lib/modules/ResourcePlanner/types.d.ts +42 -0
  156. package/lib/modules/Rules/index.js +32 -3
  157. package/lib/modules/Schedule/index.d.ts +7 -1
  158. package/lib/modules/Schedule/index.js +68 -4
  159. package/lib/modules/Schedule/types.d.ts +2 -0
  160. package/lib/modules/bookingReadValidation.d.ts +6 -0
  161. package/lib/modules/bookingReadValidation.js +56 -0
  162. package/lib/plugins/request.d.ts +2 -0
  163. package/lib/server/index.d.ts +9 -0
  164. package/lib/server/index.js +279 -30
  165. package/lib/server/modules/form/index.d.ts +19 -0
  166. package/lib/server/modules/form/index.js +73 -0
  167. package/lib/server/modules/form/types.d.ts +13 -0
  168. package/lib/server/modules/form/types.js +9 -0
  169. package/lib/server/modules/index.d.ts +3 -0
  170. package/lib/server/modules/index.js +15 -1
  171. package/lib/server/modules/order/index.d.ts +21 -0
  172. package/lib/server/modules/order/index.js +344 -35
  173. package/lib/server/modules/order/types.d.ts +3 -0
  174. package/lib/server/modules/order/utils/filterOrders.js +18 -0
  175. package/lib/server/modules/products/index.d.ts +28 -7
  176. package/lib/server/modules/products/index.js +224 -62
  177. package/lib/server/modules/products/replication.d.ts +8 -0
  178. package/lib/server/modules/products/replication.js +30 -0
  179. package/lib/server/modules/products/types.d.ts +12 -1
  180. package/lib/server/modules/products/types.js +3 -0
  181. package/lib/shared/receipt/customerInvoiceLanguages.d.ts +1 -1
  182. package/lib/shared/receipt/customerInvoiceLanguages.js +5 -3
  183. package/lib/shared/receipt/small-ticket.d.ts +1 -0
  184. package/lib/shared/receipt/small-ticket.js +53 -25
  185. package/lib/shared/receipt/templateVisibility.d.ts +3 -0
  186. package/lib/shared/receipt/templateVisibility.js +6 -2
  187. package/lib/solution/BaseSales/fulfillmentItemRules.d.ts +27 -0
  188. package/lib/solution/BaseSales/fulfillmentItemRules.js +259 -0
  189. package/lib/solution/BaseSales/index.d.ts +22 -6
  190. package/lib/solution/BaseSales/index.js +347 -59
  191. package/lib/solution/BaseSales/pickupTiming.d.ts +4 -0
  192. package/lib/solution/BaseSales/pickupTiming.js +24 -3
  193. package/lib/solution/BaseSales/types.d.ts +4 -0
  194. package/lib/solution/BaseSales/types.js +1 -0
  195. package/lib/solution/BaseSales/utils/posDurationPricing.d.ts +21 -0
  196. package/lib/solution/BaseSales/utils/posDurationPricing.js +133 -0
  197. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +2 -0
  198. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +1 -1
  199. package/lib/solution/BookingByStep/index.d.ts +18 -2
  200. package/lib/solution/BookingByStep/index.js +229 -17
  201. package/lib/solution/BookingByStep/utils/resources.d.ts +10 -0
  202. package/lib/solution/BookingByStep/utils/resources.js +25 -15
  203. package/lib/solution/BookingTicket/index.d.ts +6 -0
  204. package/lib/solution/BookingTicket/index.js +40 -5
  205. package/lib/solution/BookingTicket/types.d.ts +1 -1
  206. package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +2 -1
  207. package/lib/solution/BookingTicket/utils/addProductDecision.js +34 -4
  208. package/lib/solution/BookingTicket/utils/redeemArrival.d.ts +3 -3
  209. package/lib/solution/BookingTicket/utils/resolveUniqueCartDetail.d.ts +8 -0
  210. package/lib/solution/BookingTicket/utils/resolveUniqueCartDetail.js +136 -0
  211. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +2 -14
  212. package/lib/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.d.ts +1 -3
  213. package/lib/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.js +17 -34
  214. package/lib/solution/OrderInvoicePreview/index.js +1 -0
  215. package/lib/solution/Sales/index.js +1 -1
  216. package/lib/solution/ScanOrder/index.d.ts +2 -0
  217. package/lib/solution/ScanOrder/index.js +131 -22
  218. package/lib/solution/ScanOrder/menuAvailability.d.ts +24 -0
  219. package/lib/solution/ScanOrder/menuAvailability.js +203 -0
  220. package/lib/solution/ScanOrder/types.d.ts +3 -0
  221. package/lib/solution/UnifiedBookingSales/index.d.ts +42 -10
  222. package/lib/solution/UnifiedBookingSales/index.js +717 -144
  223. package/lib/solution/UnifiedBookingSales/salesSettings.js +1 -1
  224. package/lib/solution/UnifiedBookingSales/types.d.ts +20 -5
  225. package/lib/utils/pos-receipt-auto-print.d.ts +4 -0
  226. package/lib/utils/pos-receipt-auto-print.js +13 -0
  227. package/package.json +1 -1
@@ -0,0 +1,13 @@
1
+ /** Local reconciliation state; never part of a cloud checkout payload. */
2
+ export declare const LOCAL_EFTPOS_REFRESH_REQUIRED = "_local_eftpos_refresh_required";
3
+ export declare const LOCAL_EFTPOS_FINALIZED = "_local_eftpos_finalized";
4
+ export declare const PAYMENT_REFRESH_MESSAGE = "\u8BA2\u5355\u9700\u8981\u5237\u65B0\uFF0C\u8BF7\u8054\u7F51\u5237\u65B0\u8BA2\u5355\u540E\u518D\u4ED8\u6B3E";
5
+ export interface LocalEftposFinalization {
6
+ saleId: string | number;
7
+ paymentNumber: string;
8
+ result: 'failed' | 'not_started';
9
+ failedTransactionNumbers: string[];
10
+ }
11
+ export declare function requiresLocalPaymentRefresh(order: any): boolean;
12
+ export declare function isLocalFinalizedPayment(payment: any): boolean;
13
+ export declare function stripLocalEftposState<T extends Record<string, any>>(order: T): T;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.PAYMENT_REFRESH_MESSAGE = exports.LOCAL_EFTPOS_REFRESH_REQUIRED = exports.LOCAL_EFTPOS_FINALIZED = void 0;
7
+ exports.isLocalFinalizedPayment = isLocalFinalizedPayment;
8
+ exports.requiresLocalPaymentRefresh = requiresLocalPaymentRefresh;
9
+ exports.stripLocalEftposState = stripLocalEftposState;
10
+ /** Local reconciliation state; never part of a cloud checkout payload. */
11
+ const LOCAL_EFTPOS_REFRESH_REQUIRED = exports.LOCAL_EFTPOS_REFRESH_REQUIRED = '_local_eftpos_refresh_required';
12
+ const LOCAL_EFTPOS_FINALIZED = exports.LOCAL_EFTPOS_FINALIZED = '_local_eftpos_finalized';
13
+ const PAYMENT_REFRESH_MESSAGE = exports.PAYMENT_REFRESH_MESSAGE = '订单需要刷新,请联网刷新订单后再付款';
14
+ function requiresLocalPaymentRefresh(order) {
15
+ return order?.metadata?.[LOCAL_EFTPOS_REFRESH_REQUIRED] === true;
16
+ }
17
+ function isLocalFinalizedPayment(payment) {
18
+ return payment?.status === 'voided' && payment?.metadata?.[LOCAL_EFTPOS_FINALIZED] === true;
19
+ }
20
+ function stripLocalEftposState(order) {
21
+ const result = {
22
+ ...order
23
+ };
24
+ if (order.metadata) {
25
+ result.metadata = {
26
+ ...order.metadata
27
+ };
28
+ delete result.metadata[LOCAL_EFTPOS_REFRESH_REQUIRED];
29
+ }
30
+ if (Array.isArray(order.payments)) {
31
+ result.payments = order.payments.filter(payment => !isLocalFinalizedPayment(payment)).map(payment => {
32
+ if (!payment.metadata?.[LOCAL_EFTPOS_FINALIZED]) return payment;
33
+ const metadata = {
34
+ ...payment.metadata
35
+ };
36
+ delete metadata[LOCAL_EFTPOS_FINALIZED];
37
+ return {
38
+ ...payment,
39
+ metadata
40
+ };
41
+ });
42
+ }
43
+ return result;
44
+ }
@@ -71,8 +71,8 @@ export interface OrderGiftSelectResult {
71
71
  /**
72
72
  * 赠品解析回调签名(SDK → OS 的返回值)。
73
73
  *
74
- * - 单选项:SDK 内部自动构造商品,不弹窗
75
- * - 多选项:SDK 弹窗等用户确认后构造
74
+ * - 唯一且无规格/套餐的候选:SDK 自动构造商品
75
+ * - 有规格/套餐或多个候选:SDK 弹窗等用户确认后构造
76
76
  * - 用户取消:抛错或返回空数组(OS 视为放弃本次添加)
77
77
  *
78
78
  * 返回数组时沿用旧协议,只写 tempOrder.products;返回对象时可同时写入预约 bookings。
@@ -213,6 +213,7 @@ export interface VirtualCurrencySnapshotItem {
213
213
  id: number | string;
214
214
  tag: 'virtual_currency';
215
215
  product_id?: number | string;
216
+ code?: string;
216
217
  product_name: string;
217
218
  par_value: string;
218
219
  used_par_value: string;
@@ -448,6 +449,17 @@ export interface ReplaceTempOrderOptions {
448
449
  recalculateSummary?: boolean;
449
450
  persist?: boolean;
450
451
  saveDraft?: boolean;
452
+ /** Internal same-order updates may explicitly retain an anonymous order's session. */
453
+ preserveOrderSessionId?: string;
454
+ }
455
+ export interface OrderSessionChangedPayload {
456
+ sessionId: string | null;
457
+ previousSessionId: string | null;
458
+ }
459
+ export interface HydrateTempOrderOptions {
460
+ recalcOnHydrate?: boolean;
461
+ source?: 'salesDetail' | 'mergedSalesDetail' | 'sessionStorage';
462
+ preserveOrderSessionId?: string;
451
463
  }
452
464
  export type AddProductBookingInput = Record<string, any>;
453
465
  /**
@@ -459,13 +471,20 @@ export interface AddProductToOrderOptions {
459
471
  /** Associates a selection with an existing runtime voucher group. */
460
472
  productVoucherGroupKey?: string;
461
473
  insertAfterProductUid?: string;
474
+ /** 新增商品行插入 products 首位,优先于 insertAfterProductUid。 */
475
+ insertAtStart?: boolean;
462
476
  /** 跳过同商品/规格匹配,始终新增购物车行。 */
463
477
  disableMerge?: boolean;
464
478
  /** 商品行 UID 落定后,由 OrderModule 原子绑定到该行的 Sales Notes 草稿。 */
465
479
  salesNotes?: SalesNoteDraftInput[];
466
- /** Validate the captured booking intent before preparation and draft publication. */
480
+ /**
481
+ * 自动预约加购的同步提交门禁;抛错时不发布本次新增。
482
+ * 带门禁时先在私有草稿中准备全部商品/booking,异步等待后及原子发布前重新调用。
483
+ * 门禁须校验当前订单身份/版本和真实时间;发布前不会因本次拆行改变订单版本。
484
+ * 不传时保留原有人工加购行为。
485
+ */
467
486
  availabilityCommitGuard?: () => void;
468
- /** Ownership only; remains valid after this mutation changes products and prices. */
487
+ /** 发布后的订单/业务归属检查;只用于阻止旧异步收尾写入新单,不再校验截止或 revision。 */
469
488
  availabilityCommitTargetGuard?: () => boolean;
470
489
  }
471
490
  /** Atomic replacement of one unsubmitted Party booking and its explicitly confirmed retail children. */
@@ -482,9 +501,9 @@ export interface ReplaceBookingProductWithRelatedRetailParams {
482
501
  * 预约合并行减量时仍删除最新真实行,再把剩余代表行移动到被删除代表行原位置。
483
502
  */
484
503
  export interface RemoveProductsFromOrderOptions {
485
- /** Synchronous, read-only validation before draft mutation and again before publication after async guards; may throw. Never called during finalization. */
504
+ /** Validate the selected row/cascade snapshot before mutation; may throw. Not called during finalization. */
486
505
  beforeApply?: () => void;
487
- /** Prevent an asynchronous deletion/finalization from crossing order or business scopes. */
506
+ /** 自动购物车写入的订单归属检查;失效时不再变更或发布异步收尾结果。 */
488
507
  isCurrentOrder?: () => boolean;
489
508
  preserveDisplayPosition?: {
490
509
  remainingProductUid: string;
@@ -879,6 +898,10 @@ export interface OrderModuleAPI {
879
898
  salesSummaryModuleName?: string;
880
899
  }) => void;
881
900
  getTempOrder: () => OrderTempOrder | null;
901
+ /** Runtime-only identity; never part of an order or a persisted draft. */
902
+ getOrderSessionId: () => string | null;
903
+ /** Also rejects a session while an asynchronous order replacement is pending. */
904
+ isOrderSessionCurrent: (sessionId: string) => boolean;
882
905
  ensureTempOrder: () => OrderTempOrder;
883
906
  replaceTempOrder: (tempOrder: OrderTempOrder, options?: ReplaceTempOrderOptions) => Promise<OrderTempOrder>;
884
907
  addNewOrder: () => Promise<OrderTempOrder>;
@@ -937,7 +960,9 @@ export interface OrderModuleAPI {
937
960
  updateOrderProduct: (params: UpdateOrderProductParams) => Promise<OrderProduct[]>;
938
961
  /** 批量更新购物车行,末尾仅触发一次促销重算与 summary 刷新 */
939
962
  updateOrderProducts: (paramsList: UpdateOrderProductParams[], options?: UpdateOrderProductsOptions) => Promise<OrderProduct[]>;
940
- updateOrderProductQuantity: (params: UpdateOrderProductQuantityParams) => Promise<OrderProduct[]>;
963
+ updateOrderProductQuantity: (params: UpdateOrderProductQuantityParams, options?: {
964
+ isCurrentOrder?: () => boolean;
965
+ }) => Promise<OrderProduct[]>;
941
966
  updateOrderBooking: (params: UpdateOrderBookingParams) => any[];
942
967
  removeProductFromOrder: (identity: OrderProductIdentity, options?: RemoveProductsFromOrderOptions) => Promise<OrderProduct[]>;
943
968
  /** 批量删除购物车行,末尾仅触发一次促销重算与 summary 刷新 */
@@ -1008,10 +1033,7 @@ export interface OrderModuleAPI {
1008
1033
  }) => OrderPaymentData[];
1009
1034
  sendCustomerPayLink: <T = any>(params: SendCustomerPayLinkParams) => Promise<T>;
1010
1035
  saveDraft: () => Promise<void>;
1011
- hydrateTempOrderFromRecord: (record: Record<string, any>, options?: {
1012
- recalcOnHydrate?: boolean;
1013
- source?: 'salesDetail' | 'mergedSalesDetail' | 'sessionStorage';
1014
- }) => Promise<OrderTempOrder>;
1036
+ hydrateTempOrderFromRecord: (record: Record<string, any>, options?: HydrateTempOrderOptions) => Promise<OrderTempOrder>;
1015
1037
  syncPaymentsToOrder: <T = any>(params: SyncPaymentsToOrderParams) => Promise<SyncPaymentsToOrderResult<T>>;
1016
1038
  getSalesOrderByLookup: (params: SalesOrderLookupParams) => Promise<any>;
1017
1039
  getLastOrderInfo: () => Record<string, any> | undefined;
@@ -32,8 +32,8 @@ let OrderHooks = exports.OrderHooks = /*#__PURE__*/function (OrderHooks) {
32
32
  /**
33
33
  * 赠品解析回调签名(SDK → OS 的返回值)。
34
34
  *
35
- * - 单选项:SDK 内部自动构造商品,不弹窗
36
- * - 多选项:SDK 弹窗等用户确认后构造
35
+ * - 唯一且无规格/套餐的候选:SDK 自动构造商品
36
+ * - 有规格/套餐或多个候选:SDK 弹窗等用户确认后构造
37
37
  * - 用户取消:抛错或返回空数组(OS 视为放弃本次添加)
38
38
  *
39
39
  * 返回数组时沿用旧协议,只写 tempOrder.products;返回对象时可同时写入预约 bookings。
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Cloud saved orders with no payment rows report a zero gap, even while unpaid.
3
+ * Restore the OS payment target from the same snapshot, without repricing products.
4
+ * Voided rows are local payment history and are omitted from cloud checkout.
5
+ */
6
+ export declare function normalizeUnpaidOrderAmountGap<T extends Record<string, any>>(order: T): T;
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.normalizeUnpaidOrderAmountGap = normalizeUnpaidOrderAmountGap;
7
+ var _decimal = _interopRequireDefault(require("decimal.js"));
8
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
+ const UNPAID_STATUSES = new Set(['unpaid', 'payment_pending', 'payment_processing']);
10
+ const CANCELLED_STATUSES = new Set(['cancelled', 'canceled', 'voided']);
11
+ function firstValue(...values) {
12
+ return values.find(value => value != null && String(value).trim() !== '');
13
+ }
14
+ function money(value) {
15
+ if (typeof value !== 'string' && typeof value !== 'number') return undefined;
16
+ try {
17
+ const amount = new _decimal.default(value);
18
+ return amount.isFinite() ? amount : undefined;
19
+ } catch {
20
+ return undefined;
21
+ }
22
+ }
23
+
24
+ /**
25
+ * Cloud saved orders with no payment rows report a zero gap, even while unpaid.
26
+ * Restore the OS payment target from the same snapshot, without repricing products.
27
+ * Voided rows are local payment history and are omitted from cloud checkout.
28
+ */
29
+ function normalizeUnpaidOrderAmountGap(order) {
30
+ const summary = order.summary && typeof order.summary === 'object' && !Array.isArray(order.summary) ? order.summary : {};
31
+ const status = String(firstValue(order.payment_status, summary.payment_status, order.original_payment_status) ?? '').trim().toLowerCase();
32
+ if (!UNPAID_STATUSES.has(status) || CANCELLED_STATUSES.has(String(order.status ?? '').trim().toLowerCase())) return order;
33
+ if (Array.isArray(order.refunds) && order.refunds.length > 0) return order;
34
+
35
+ // An omitted collection is a sparse patch, not proof that the order has no payments.
36
+ if (!Array.isArray(order.payments) || order.payments.some(payment => String(payment?.status ?? '').trim().toLowerCase() !== 'voided')) return order;
37
+ for (const field of ['order_paid_amount', 'customer_paid_amount', 'total_refund_amount', 'paid_amount', 'payment_amount']) {
38
+ const values = [summary[field], order[field]].filter(value => value != null && String(value).trim() !== '');
39
+ if (values.some(value => !money(value)?.isZero())) return order;
40
+ }
41
+ const gapValue = firstValue(summary.amount_gap, order.amount_gap);
42
+ if (gapValue !== undefined && !money(gapValue)?.isZero()) return order;
43
+ const expected = money(firstValue(summary.expect_amount, order.expect_amount, summary.total_amount, order.total_amount));
44
+ if (!expected?.gt(0)) return order;
45
+ let target = expected;
46
+ if (Number(order.is_deposit) === 1) {
47
+ const deposit = money(firstValue(summary.deposit_amount, order.deposit_amount, 0));
48
+ if (!deposit || deposit.lt(0) || deposit.gt(expected)) return order;
49
+ if (deposit.gt(0)) target = deposit;
50
+ }
51
+ const amountGap = target.toFixed(2);
52
+ return {
53
+ ...order,
54
+ amount_gap: amountGap,
55
+ summary: {
56
+ ...summary,
57
+ amount_gap: amountGap
58
+ }
59
+ };
60
+ }
@@ -128,7 +128,9 @@ export declare function getBundleSellingMagnitude(bundle: Record<string, any> |
128
128
  *
129
129
  * Rules 钩子契约(hook_adapt 方案,Rules 内部保持不变):
130
130
  * - `getProduct.price` / `getProduct.original_price` 回传 **source-level 主价**
131
- * (`metadata.source_product_price`)。Rules 内部 `getProductTotalPrice` /
131
+ * (`metadata.source_product_price`);买赠行的 `price` 为 0,`original_price` 仍保留 source。
132
+ * 赠品基础价已被赠送优惠抵扣,只有收费 option / bundle 继续按卡券规则计算。
133
+ * Rules 内部 `getProductTotalPrice` /
132
134
  * `getProductOriginTotalPrice` 会自行叠加 option + bundle,喂 source 可避免 option 双加。
133
135
  * - `getProduct.total` = `selling_price × num`(行 composite × num),与 Rules 内部产出的
134
136
  * total(source + option + bundle)对齐。
@@ -217,6 +219,7 @@ export declare function normalizeBookingSubType(booking: Record<string, any>): s
217
219
  export declare function normalizeSubmitBooking<T extends {
218
220
  metadata?: Record<string, any>;
219
221
  }>(booking: T): T;
222
+ export declare function resolveTableOccupancyDuration(tempOrder: OrderTempOrder): number;
220
223
  /** 提交用人数:有限且为正则向下取整,否则为 1 */
221
224
  export declare function normalizeSubmitCollectPaxValue(value: unknown): number;
222
225
  /** 从临时订单 metadata 解析合成 booking 的 collect_pax */
@@ -110,6 +110,7 @@ Object.defineProperty(exports, "resolveSafeProductNum", {
110
110
  });
111
111
  exports.resolveSubmitCollectPax = resolveSubmitCollectPax;
112
112
  exports.resolveSubmitOrderType = resolveSubmitOrderType;
113
+ exports.resolveTableOccupancyDuration = resolveTableOccupancyDuration;
113
114
  exports.restoreRedeemVoucherTimes = restoreRedeemVoucherTimes;
114
115
  Object.defineProperty(exports, "shouldBuildManualProductDiscount", {
115
116
  enumerable: true,
@@ -288,6 +289,10 @@ function normalizeVirtualCurrencySnapshotItem(value) {
288
289
  if (productId !== undefined) {
289
290
  snapshot.product_id = productId;
290
291
  }
292
+ const code = normalizeSnapshotScalar(value.code);
293
+ if (code !== undefined) {
294
+ snapshot.code = String(code).trim();
295
+ }
291
296
  return snapshot;
292
297
  }
293
298
  function normalizeVirtualCurrencySnapshotList(value) {
@@ -318,6 +323,10 @@ function buildVirtualCurrencySnapshotFromList(value) {
318
323
  if (productId !== undefined) {
319
324
  snapshot.product_id = productId;
320
325
  }
326
+ const code = normalizeSnapshotScalar(item.code);
327
+ if (code !== undefined) {
328
+ snapshot.code = String(code).trim();
329
+ }
321
330
  result.push(snapshot);
322
331
  return result;
323
332
  }, []);
@@ -666,7 +675,9 @@ function getBundleSellingMagnitude(bundle) {
666
675
  *
667
676
  * Rules 钩子契约(hook_adapt 方案,Rules 内部保持不变):
668
677
  * - `getProduct.price` / `getProduct.original_price` 回传 **source-level 主价**
669
- * (`metadata.source_product_price`)。Rules 内部 `getProductTotalPrice` /
678
+ * (`metadata.source_product_price`);买赠行的 `price` 为 0,`original_price` 仍保留 source。
679
+ * 赠品基础价已被赠送优惠抵扣,只有收费 option / bundle 继续按卡券规则计算。
680
+ * Rules 内部 `getProductTotalPrice` /
670
681
  * `getProductOriginTotalPrice` 会自行叠加 option + bundle,喂 source 可避免 option 双加。
671
682
  * - `getProduct.total` = `selling_price × num`(行 composite × num),与 Rules 内部产出的
672
683
  * total(source + option + bundle)对齐。
@@ -949,7 +960,8 @@ function createDefaultOrderRulesHooks(getBookings, getHolderRelations) {
949
960
  _id: product.metadata?.unique_identification_number ? `${product.product_id}_${product.product_variant_id}_${product.metadata.unique_identification_number}` : `${product.product_id}_${product.product_variant_id}_${(0, _utils2.buildProductLineFingerprint)(getProductSkuOptions(product), product.product_bundle)}`,
950
961
  // Rules 内部 getProductTotalPrice / getProductOriginTotalPrice 会各自再叠加 bundle + option,
951
962
  // 所以这里必须喂 source-level(不含 option、不含 bundle、不含折扣)单价,避免双加 option。
952
- price: sourcePrice,
963
+ // 赠品基础价不再参与卡券;source 元数据保留原价,供后续与赠送优惠相抵。
964
+ price: metadataAny._giftInfo ? '0.00' : sourcePrice,
953
965
  // total / origin_total 使用 composite × num,跟 Rules 内部产出的 total 对齐(含 option + bundle)。
954
966
  total: new _decimal.default(product.selling_price || 0).times(product.num || 1).toNumber(),
955
967
  origin_total: new _decimal.default(product.original_price || product.selling_price || 0).times(product.num || 1).toNumber(),
@@ -1139,6 +1151,7 @@ function normalizeSubmitPlatform(platform) {
1139
1151
  const lower = value.toLowerCase();
1140
1152
  if (lower === 'pc') return 'PC';
1141
1153
  if (lower === 'h5') return 'H5';
1154
+ if (lower === 'webpos') return 'pos';
1142
1155
  return value;
1143
1156
  }
1144
1157
  function normalizeSubmitProductionCode(value) {
@@ -1154,7 +1167,7 @@ function formatSubmitOptionItems(options, formatOptions = {}) {
1154
1167
  const option = {
1155
1168
  ...(d && typeof d === 'object' ? d : {}),
1156
1169
  num: d?.num,
1157
- option_group_item_id: d?.option_group_item_id,
1170
+ option_group_item_id: d?.option_group_item_id ?? d?.product_option_item_id ?? d?.id,
1158
1171
  option_group_id: d?.option_group_id
1159
1172
  };
1160
1173
  const productionCode = normalizeSubmitProductionCode(d?.production_code);
@@ -1289,6 +1302,19 @@ function normalizeSubmitProduct(product, formatOptions = {}) {
1289
1302
  cleanMetadata[key] = rawMetadata[key];
1290
1303
  }
1291
1304
  }
1305
+ // Persist only an applied pricing snapshot, so reopening a saved order can
1306
+ // compare it with the latest catalog without reinterpreting legacy duration.
1307
+ const pricingMethod = rawMetadata.pricing_method?.type;
1308
+ if (pricingMethod === 'duration_based' || pricingMethod === 'fixed_price') {
1309
+ cleanMetadata.pricing_method = {
1310
+ type: pricingMethod
1311
+ };
1312
+ if (pricingMethod === 'duration_based' && rawMetadata.duration) {
1313
+ cleanMetadata.duration = {
1314
+ ...rawMetadata.duration
1315
+ };
1316
+ }
1317
+ }
1292
1318
  cleanMetadata.product_discount_difference = rawMetadata.product_discount_difference ?? '';
1293
1319
  if (rawMetadata.price_breakdown) {
1294
1320
  cleanMetadata.price_breakdown = rawMetadata.price_breakdown;
@@ -1146,7 +1146,10 @@ class WalletPassPaymentImpl {
1146
1146
  if (paymentAssets.length > 0) {
1147
1147
  this.searchResults = mergeWalletAssets(this.searchResults, paymentAssets);
1148
1148
  }
1149
- const asset = paymentAssets.find(item => String(item?.code || '') === normalizedCode) || paymentAssets[0];
1149
+ const matchedAsset = paymentAssets.find(item => String(item?.code || '') === normalizedCode);
1150
+ // 精确命中券码时仅处理该券;未命中时处理接口返回的全部结果。
1151
+ const assetsToApply = matchedAsset ? [matchedAsset] : paymentAssets;
1152
+ const asset = assetsToApply[0];
1150
1153
  if (!asset) {
1151
1154
  return {
1152
1155
  type: 'normalCode',
@@ -1155,6 +1158,25 @@ class WalletPassPaymentImpl {
1155
1158
  state: this.getWalletAssetsState()
1156
1159
  };
1157
1160
  }
1161
+
1162
+ // 根据 code 找不到结果时,则使用接口返回的所有券数据(扫手环)
1163
+ if (!matchedAsset && assetsToApply.length > 1) {
1164
+ const items = mergeWalletAssets(this.walletAssetsState.items, assetsToApply);
1165
+ const assetIds = assetsToApply.map(item => getWalletAssetId(item)).filter(id => id !== undefined && id !== null);
1166
+ const selectionSources = {
1167
+ ...this.walletAssetsState.selectionSources
1168
+ };
1169
+ assetIds.forEach(id => {
1170
+ selectionSources[String(id)] = 'scan';
1171
+ });
1172
+ const selected = this.walletAssetsBehavior.autoSelectAfterSearch ? this.recalculateWalletAssets(items, Array.from(new Set([...this.walletAssetsState.selectedIds, ...assetIds])), selectionSources) : this.recalculateWalletAssets(items, this.walletAssetsState.selectedIds, this.walletAssetsState.selectionSources);
1173
+ return {
1174
+ type: result.type,
1175
+ asset,
1176
+ selected: assetIds.some(id => selected.selectedIds.includes(id)),
1177
+ state: selected
1178
+ };
1179
+ }
1158
1180
  const items = mergeWalletAssets(this.walletAssetsState.items, [asset]);
1159
1181
  const recalculatedState = this.recalculateWalletAssets(items, this.walletAssetsState.selectedIds, this.walletAssetsState.selectionSources);
1160
1182
  const assetId = getWalletAssetId(asset);
@@ -42,6 +42,9 @@ export interface ProductSettlementOption extends Record<string, any> {
42
42
  available: boolean;
43
43
  disabled_reason?: string;
44
44
  }
45
+ export interface ProductPricingMethod {
46
+ type: 'fixed_price' | 'duration_based';
47
+ }
45
48
  /**
46
49
  * 商品基本信息接口
47
50
  */
@@ -74,6 +77,8 @@ export interface ProductData {
74
77
  sum_stock: number;
75
78
  /** 商品价格 */
76
79
  price: string;
80
+ /** POS booking pricing; missing configuration retains existing fixed pricing. */
81
+ pricing_method?: ProductPricingMethod;
77
82
  /** 当前上下文解析出的可选结算货币 */
78
83
  available_settlement_options?: ProductSettlementOption[];
79
84
  /** 商品原价 */
@@ -218,6 +223,17 @@ export interface ProductData {
218
223
  bundle?: any[];
219
224
  /** 商品选项组成 */
220
225
  options?: any[];
226
+ /** 单规格组;用于由已选 option 反查规格项名称、价格等商品快照字段。 */
227
+ option_group?: Array<{
228
+ id: number | string;
229
+ option_item?: Array<{
230
+ id: number | string;
231
+ name?: string | Record<string, any>;
232
+ title?: string | Record<string, any>;
233
+ [key: string]: any;
234
+ }>;
235
+ [key: string]: any;
236
+ }>;
221
237
  /** 商品原信息 */
222
238
  origin?: any;
223
239
  /** 容量 */
@@ -139,7 +139,7 @@ class ProductList extends _BaseModule.BaseModule {
139
139
  online_store: 'online-store',
140
140
  scan_to_order: 'online-store',
141
141
  'scan-to-order': 'online-store',
142
- scan_to_order_2: 'mobile_order',
142
+ scan_to_order_2: 'online-store',
143
143
  scan_to_order_3: 'scantoorder3'
144
144
  };
145
145
  const rawApplicationCode = this.otherParams?.channel;
@@ -1,5 +1,7 @@
1
1
  import type { AvailabilityProjection, AvailabilityProjectionInput, AvailabilityQuery, AvailabilityQueryResult, AvailabilitySelectionValidationParams, AvailabilitySelectionValidationResult, GetProductTimeRangesRequest, GetProductTimeRangesRuntimeOptions, ProductTimeRangeGroup } from './types';
2
2
  export declare function createAvailabilityProjection(input: AvailabilityProjectionInput): AvailabilityProjection;
3
+ /** Resolve the label without changing the real calendar timestamp. */
4
+ export declare function getDurationBusinessDate(projection: AvailabilityProjection, startAt: string): string;
3
5
  export declare function getProductTimeRanges(projection: AvailabilityProjection, request?: GetProductTimeRangesRequest, runtimeOptions?: GetProductTimeRangesRuntimeOptions): ProductTimeRangeGroup[];
4
6
  export declare function queryAvailabilityProjection(projection: AvailabilityProjection, request: AvailabilityQuery, runtimeOptions?: GetProductTimeRangesRuntimeOptions): AvailabilityQueryResult;
5
7
  export declare function validateAvailabilitySelection(projection: AvailabilityProjection, params: AvailabilitySelectionValidationParams, runtimeOptions?: GetProductTimeRangesRuntimeOptions): AvailabilitySelectionValidationResult;