@pisell/pisellos 2.3.38 → 2.3.40

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 (229) hide show
  1. package/dist/core/index.d.ts +0 -2
  2. package/dist/core/index.js +0 -7
  3. package/dist/model/strategy/adapter/promotion/adapter.d.ts +0 -4
  4. package/dist/model/strategy/adapter/promotion/adapter.js +0 -23
  5. package/dist/model/strategy/adapter/promotion/evaluator.d.ts +0 -17
  6. package/dist/model/strategy/adapter/promotion/evaluator.js +6 -279
  7. package/dist/model/strategy/adapter/promotion/examples.d.ts +0 -86
  8. package/dist/model/strategy/adapter/promotion/examples.js +0 -99
  9. package/dist/model/strategy/adapter/promotion/index.d.ts +1 -1
  10. package/dist/model/strategy/adapter/promotion/type.d.ts +2 -90
  11. package/dist/model/strategy/adapter/promotion/type.js +0 -45
  12. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +3 -5
  13. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +3 -6
  14. package/dist/modules/Discount/index.d.ts +1 -0
  15. package/dist/modules/Discount/index.js +40 -11
  16. package/dist/modules/Discount/types.d.ts +1 -0
  17. package/dist/modules/Holder/index.d.ts +48 -0
  18. package/dist/modules/Holder/index.js +640 -0
  19. package/dist/modules/Holder/types.d.ts +123 -0
  20. package/dist/modules/Holder/types.js +1 -0
  21. package/dist/modules/Holder/utils.d.ts +13 -0
  22. package/dist/modules/Holder/utils.js +34 -0
  23. package/dist/modules/OpenData/index.d.ts +0 -2
  24. package/dist/modules/OpenData/index.js +2 -10
  25. package/dist/modules/Order/index.d.ts +11 -28
  26. package/dist/modules/Order/index.js +509 -750
  27. package/dist/modules/Order/types.d.ts +10 -33
  28. package/dist/modules/Order/utils/orderCollectionIdentity.js +2 -7
  29. package/dist/modules/Order/utils.d.ts +10 -0
  30. package/dist/modules/Order/utils.js +41 -13
  31. package/dist/modules/Payment/index.d.ts +0 -2
  32. package/dist/modules/Payment/index.js +50 -79
  33. package/dist/modules/Payment/types.d.ts +28 -99
  34. package/dist/modules/Payment/types.js +3 -20
  35. package/dist/modules/Payment/walletpass.d.ts +1 -25
  36. package/dist/modules/Payment/walletpass.js +157 -707
  37. package/dist/modules/Product/types.d.ts +1 -0
  38. package/dist/modules/ProductList/index.js +33 -14
  39. package/dist/modules/Quotation/index.d.ts +1 -1
  40. package/dist/modules/Quotation/index.js +2 -2
  41. package/dist/modules/ResourcePlanner/index.d.ts +24 -0
  42. package/dist/modules/ResourcePlanner/index.js +181 -0
  43. package/dist/modules/ResourcePlanner/planner.d.ts +14 -0
  44. package/dist/modules/ResourcePlanner/planner.js +1069 -0
  45. package/dist/modules/ResourcePlanner/types.d.ts +227 -0
  46. package/dist/modules/ResourcePlanner/types.js +1 -0
  47. package/dist/modules/Rules/index.d.ts +0 -1
  48. package/dist/modules/Rules/index.js +96 -89
  49. package/dist/modules/SalesSummary/index.js +12 -13
  50. package/dist/modules/ScanOrderLogger/index.d.ts +2 -0
  51. package/dist/modules/ScanOrderLogger/index.js +15 -2
  52. package/dist/modules/ScanOrderLogger/providers/feishu.js +45 -27
  53. package/dist/modules/ScanOrderLogger/types.d.ts +1 -0
  54. package/dist/modules/Schedule/index.d.ts +3 -1
  55. package/dist/modules/Schedule/index.js +21 -16
  56. package/dist/modules/Summary/utils.js +38 -13
  57. package/dist/modules/index.d.ts +2 -0
  58. package/dist/modules/index.js +3 -1
  59. package/dist/plugins/window.d.ts +1 -0
  60. package/dist/server/index.d.ts +14 -16
  61. package/dist/server/index.js +1148 -1930
  62. package/dist/server/modules/order/index.d.ts +4 -54
  63. package/dist/server/modules/order/index.js +695 -1595
  64. package/dist/server/modules/order/types.d.ts +3 -11
  65. package/dist/server/modules/order/types.js +1 -1
  66. package/dist/solution/BaseSales/index.d.ts +20 -109
  67. package/dist/solution/BaseSales/index.js +481 -1797
  68. package/dist/solution/BaseSales/types.d.ts +0 -52
  69. package/dist/solution/BaseSales/types.js +1 -2
  70. package/dist/solution/BaseSales/utils/cartPromotion.d.ts +1 -3
  71. package/dist/solution/BaseSales/utils/cartPromotion.js +31 -90
  72. package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -6
  73. package/dist/solution/BookingByStep/index.d.ts +17 -2
  74. package/dist/solution/BookingByStep/index.js +294 -215
  75. package/dist/solution/BookingByStep/types.d.ts +2 -1
  76. package/dist/solution/BookingByStep/types.js +3 -1
  77. package/dist/solution/BookingByStep/utils/capacity.js +17 -1
  78. package/dist/solution/BookingByStep/utils/timeslots.d.ts +3 -1
  79. package/dist/solution/BookingByStep/utils/timeslots.js +19 -12
  80. package/dist/solution/BookingTicket/index.d.ts +4 -8
  81. package/dist/solution/BookingTicket/index.js +51 -134
  82. package/dist/solution/BookingTicket/utils/addProductDecision.js +0 -6
  83. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +0 -8
  84. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +82 -172
  85. package/dist/solution/BookingTicket/utils/scan/handleScan.d.ts +3 -1
  86. package/dist/solution/BookingTicket/utils/scan/handleScan.js +10 -2
  87. package/dist/solution/Sales/index.d.ts +0 -1
  88. package/dist/solution/Sales/index.js +2 -10
  89. package/dist/solution/ScanOrder/index.d.ts +26 -14
  90. package/dist/solution/ScanOrder/index.js +1148 -756
  91. package/dist/solution/ScanOrder/types.d.ts +21 -1
  92. package/dist/solution/ScanOrder/utils.d.ts +8 -0
  93. package/dist/solution/ScanOrder/utils.js +66 -25
  94. package/dist/solution/ShopDiscount/index.d.ts +1 -0
  95. package/dist/solution/ShopDiscount/index.js +125 -87
  96. package/dist/solution/UnifiedBookingSales/index.d.ts +183 -0
  97. package/dist/solution/UnifiedBookingSales/index.js +1871 -0
  98. package/dist/solution/UnifiedBookingSales/types.d.ts +143 -0
  99. package/dist/solution/UnifiedBookingSales/types.js +11 -0
  100. package/dist/solution/VenueBooking/index.d.ts +39 -11
  101. package/dist/solution/VenueBooking/index.js +1176 -860
  102. package/dist/solution/VenueBooking/types.d.ts +3 -0
  103. package/dist/solution/VenueBooking/utils/resource.js +1 -0
  104. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
  105. package/dist/solution/VenueBooking/utils/slotMerge.js +10 -5
  106. package/dist/solution/index.d.ts +1 -0
  107. package/dist/solution/index.js +2 -1
  108. package/dist/types/index.d.ts +1 -1
  109. package/lib/core/index.d.ts +0 -2
  110. package/lib/core/index.js +0 -4
  111. package/lib/model/strategy/adapter/promotion/adapter.d.ts +0 -4
  112. package/lib/model/strategy/adapter/promotion/adapter.js +0 -20
  113. package/lib/model/strategy/adapter/promotion/evaluator.d.ts +0 -17
  114. package/lib/model/strategy/adapter/promotion/evaluator.js +0 -235
  115. package/lib/model/strategy/adapter/promotion/examples.d.ts +0 -86
  116. package/lib/model/strategy/adapter/promotion/examples.js +0 -91
  117. package/lib/model/strategy/adapter/promotion/index.d.ts +1 -1
  118. package/lib/model/strategy/adapter/promotion/index.js +0 -2
  119. package/lib/model/strategy/adapter/promotion/type.d.ts +2 -90
  120. package/lib/model/strategy/adapter/promotion/type.js +0 -2
  121. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +1 -2
  122. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +1 -2
  123. package/lib/modules/Discount/index.d.ts +1 -0
  124. package/lib/modules/Discount/index.js +9 -0
  125. package/lib/modules/Discount/types.d.ts +1 -0
  126. package/lib/modules/Holder/index.d.ts +48 -0
  127. package/lib/modules/Holder/index.js +402 -0
  128. package/lib/modules/Holder/types.d.ts +123 -0
  129. package/lib/modules/Holder/types.js +17 -0
  130. package/lib/modules/Holder/utils.d.ts +13 -0
  131. package/lib/modules/Holder/utils.js +71 -0
  132. package/lib/modules/OpenData/index.d.ts +0 -2
  133. package/lib/modules/OpenData/index.js +1 -6
  134. package/lib/modules/Order/index.d.ts +11 -28
  135. package/lib/modules/Order/index.js +86 -196
  136. package/lib/modules/Order/types.d.ts +10 -33
  137. package/lib/modules/Order/utils/orderCollectionIdentity.js +0 -3
  138. package/lib/modules/Order/utils.d.ts +10 -0
  139. package/lib/modules/Order/utils.js +40 -16
  140. package/lib/modules/Payment/index.d.ts +0 -2
  141. package/lib/modules/Payment/index.js +13 -34
  142. package/lib/modules/Payment/types.d.ts +28 -99
  143. package/lib/modules/Payment/types.js +3 -4
  144. package/lib/modules/Payment/walletpass.d.ts +1 -25
  145. package/lib/modules/Payment/walletpass.js +21 -470
  146. package/lib/modules/Product/types.d.ts +1 -0
  147. package/lib/modules/ProductList/index.js +40 -31
  148. package/lib/modules/Quotation/index.d.ts +1 -1
  149. package/lib/modules/Quotation/index.js +2 -2
  150. package/lib/modules/ResourcePlanner/index.d.ts +24 -0
  151. package/lib/modules/ResourcePlanner/index.js +148 -0
  152. package/lib/modules/ResourcePlanner/planner.d.ts +14 -0
  153. package/lib/modules/ResourcePlanner/planner.js +933 -0
  154. package/lib/modules/ResourcePlanner/types.d.ts +227 -0
  155. package/lib/modules/ResourcePlanner/types.js +17 -0
  156. package/lib/modules/Rules/index.d.ts +0 -1
  157. package/lib/modules/Rules/index.js +40 -47
  158. package/lib/modules/SalesSummary/index.js +6 -7
  159. package/lib/modules/ScanOrderLogger/index.d.ts +2 -0
  160. package/lib/modules/ScanOrderLogger/index.js +13 -1
  161. package/lib/modules/ScanOrderLogger/providers/feishu.js +15 -6
  162. package/lib/modules/ScanOrderLogger/types.d.ts +1 -0
  163. package/lib/modules/Schedule/index.d.ts +3 -1
  164. package/lib/modules/Schedule/index.js +10 -8
  165. package/lib/modules/Summary/utils.js +21 -1
  166. package/lib/modules/index.d.ts +2 -0
  167. package/lib/modules/index.js +5 -1
  168. package/lib/plugins/window.d.ts +1 -0
  169. package/lib/server/index.d.ts +14 -16
  170. package/lib/server/index.js +83 -675
  171. package/lib/server/modules/order/index.d.ts +4 -54
  172. package/lib/server/modules/order/index.js +66 -679
  173. package/lib/server/modules/order/types.d.ts +3 -11
  174. package/lib/solution/BaseSales/index.d.ts +20 -109
  175. package/lib/solution/BaseSales/index.js +70 -881
  176. package/lib/solution/BaseSales/types.d.ts +0 -52
  177. package/lib/solution/BaseSales/types.js +1 -2
  178. package/lib/solution/BaseSales/utils/cartPromotion.d.ts +1 -3
  179. package/lib/solution/BaseSales/utils/cartPromotion.js +12 -63
  180. package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -6
  181. package/lib/solution/BookingByStep/index.d.ts +17 -2
  182. package/lib/solution/BookingByStep/index.js +60 -18
  183. package/lib/solution/BookingByStep/types.d.ts +2 -1
  184. package/lib/solution/BookingByStep/types.js +5 -0
  185. package/lib/solution/BookingByStep/utils/capacity.js +20 -1
  186. package/lib/solution/BookingByStep/utils/timeslots.d.ts +3 -1
  187. package/lib/solution/BookingByStep/utils/timeslots.js +19 -11
  188. package/lib/solution/BookingTicket/index.d.ts +4 -8
  189. package/lib/solution/BookingTicket/index.js +19 -64
  190. package/lib/solution/BookingTicket/utils/addProductDecision.js +0 -4
  191. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +0 -8
  192. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +4 -36
  193. package/lib/solution/BookingTicket/utils/scan/handleScan.d.ts +3 -1
  194. package/lib/solution/BookingTicket/utils/scan/handleScan.js +2 -2
  195. package/lib/solution/Sales/index.d.ts +0 -1
  196. package/lib/solution/Sales/index.js +3 -5
  197. package/lib/solution/ScanOrder/index.d.ts +26 -14
  198. package/lib/solution/ScanOrder/index.js +449 -190
  199. package/lib/solution/ScanOrder/types.d.ts +21 -1
  200. package/lib/solution/ScanOrder/utils.d.ts +8 -0
  201. package/lib/solution/ScanOrder/utils.js +31 -0
  202. package/lib/solution/ShopDiscount/index.d.ts +1 -0
  203. package/lib/solution/ShopDiscount/index.js +14 -0
  204. package/lib/solution/UnifiedBookingSales/index.d.ts +183 -0
  205. package/lib/solution/UnifiedBookingSales/index.js +1076 -0
  206. package/lib/solution/UnifiedBookingSales/types.d.ts +143 -0
  207. package/lib/solution/UnifiedBookingSales/types.js +33 -0
  208. package/lib/solution/VenueBooking/index.d.ts +39 -11
  209. package/lib/solution/VenueBooking/index.js +328 -123
  210. package/lib/solution/VenueBooking/types.d.ts +3 -0
  211. package/lib/solution/VenueBooking/utils/resource.js +1 -0
  212. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
  213. package/lib/solution/VenueBooking/utils/slotMerge.js +6 -4
  214. package/lib/solution/index.d.ts +1 -0
  215. package/lib/solution/index.js +3 -1
  216. package/lib/types/index.d.ts +1 -1
  217. package/package.json +1 -1
  218. package/dist/modules/Order/payment-utils.d.ts +0 -26
  219. package/dist/modules/Order/payment-utils.js +0 -225
  220. package/dist/solution/BookingTicket/utils/weighingProductSku.d.ts +0 -5
  221. package/dist/solution/BookingTicket/utils/weighingProductSku.js +0 -45
  222. package/dist/utils/payment-number.d.ts +0 -9
  223. package/dist/utils/payment-number.js +0 -69
  224. package/lib/modules/Order/payment-utils.d.ts +0 -26
  225. package/lib/modules/Order/payment-utils.js +0 -224
  226. package/lib/solution/BookingTicket/utils/weighingProductSku.d.ts +0 -5
  227. package/lib/solution/BookingTicket/utils/weighingProductSku.js +0 -63
  228. package/lib/utils/payment-number.d.ts +0 -9
  229. package/lib/utils/payment-number.js +0 -64
@@ -1,9 +1,9 @@
1
1
  import { Module, PisellCore, ModuleOptions } from '../../types';
2
2
  import { BaseModule } from '../BaseModule';
3
- import { OrderModuleAPI, CommitOrderParams, UpdateOrderBookingParams, UpdateOrderProductParams, UpdateOrderProductQuantityParams, CheckoutOrderParams, CancelOrderParams, ChangeBookingStatusParams } from './types';
3
+ import { OrderModuleAPI, CommitOrderParams, UpdateOrderBookingParams, UpdateOrderProductParams, UpdateOrderProductQuantityParams, CancelOrderParams, ChangeBookingStatusParams, CheckoutOrderParams } from './types';
4
4
  import { CartItem } from '../Cart/types';
5
5
  import { type SubmitPayloadEnhancer } from './utils';
6
- import type { OrderAmountSnapshot, AddProductBookingInput, OrderIdentitySnapshot, OrderPaymentSource, OrderSnapshot, OrderSyncState, SyncPaymentsToOrderParams, SyncPaymentsToOrderResult, SubmitSalesOrderParams, OrderProduct, OrderProductIdentity, OrderSummary, OrderTempOrder, OrderPaymentData, OrderPaymentUpdateOptions, OrderPaymentUpdateResult, SendCustomerPayLinkParams, UpdateTempOrderCustomerInput, OrderCustomerPatch, OrderCustomerView, ReplaceTempOrderOptions, OrderPromotionEvaluator, OrderGiftSelectResolver, OrderUnfulfilledPromotion, OrderLastGiftActions } from './types';
6
+ import type { OrderAmountSnapshot, AddProductBookingInput, OrderIdentitySnapshot, OrderPaymentSource, OrderSnapshot, OrderSyncState, SyncPaymentsToOrderParams, SyncPaymentsToOrderResult, SubmitSalesOrderParams, OrderProduct, OrderProductIdentity, OrderSummary, OrderTempOrder, OrderPaymentData, SendCustomerPayLinkParams, UpdateTempOrderCustomerInput, OrderCustomerPatch, OrderCustomerView, ReplaceTempOrderOptions, OrderPromotionEvaluator, OrderGiftSelectResolver, OrderUnfulfilledPromotion, OrderLastGiftActions } from './types';
7
7
  import type { ICustomer } from '../AccountList/types';
8
8
  import type { Discount } from '../Discount/types';
9
9
  import { UnavailableReason } from '../Rules/types';
@@ -14,7 +14,6 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
14
14
  private request;
15
15
  private logger;
16
16
  private window;
17
- private appPlugin;
18
17
  private cacheId;
19
18
  private salesSummaryModuleName;
20
19
  private rulesHooksOverride?;
@@ -146,6 +145,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
146
145
  isTempOrderPersistEnabled(): boolean;
147
146
  /** @deprecated OrderModule 不再负责 tempOrder localStorage 持久化;草稿保存请使用 IndexedDB saveDraft。 */
148
147
  persistTempOrder(): void;
148
+ notifyTempOrderChanged(): void;
149
149
  private createDefaultTempOrderInstance;
150
150
  private createExternalSaleNumber;
151
151
  private ensureExternalSaleNumber;
@@ -177,9 +177,6 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
177
177
  };
178
178
  private calculateDepositPaidAmount;
179
179
  private resolveNextOrderPaymentType;
180
- private getPaymentNumberAppData;
181
- private getPaymentNumberDevicePrefixSync;
182
- private getPaymentNumberDevicePrefixAsync;
183
180
  private normalizePaymentSource;
184
181
  private updateTempOrderPaymentStatus;
185
182
  private shouldKeepPaymentStatusAfterAmountRecalc;
@@ -311,20 +308,19 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
311
308
  * 用一组支付来源覆盖当前订单支付项。
312
309
  *
313
310
  * 入参允许来自 PaymentModule 的 PaymentItem,内部统一映射为 Sales 协议:
314
- * 新支付来源的 uuid 会作为 payment_number 的唯一号段,id -> custom_payment_id,
311
+ * uuid -> metadata.unique_payment_number,id -> custom_payment_id,
315
312
  * isSynced 等运行态字段不会进入 tempOrder.payments。
316
313
  */
317
314
  setOrderPayments(payments: OrderPaymentSource[]): OrderPaymentData[];
318
- /** 同步兼容入口:按调用当下的 device_id 或 LOCAL 生成支付编号。 */
315
+ /** 追加单个支付项,并立即持久化当前 tempOrder。 */
319
316
  addOrderPayment(payment: OrderPaymentSource): OrderPaymentData[];
320
- /** 异步入口:创建支付项时读取最新 IoT 设备短号。 */
321
- addOrderPaymentAsync(payment: OrderPaymentSource): Promise<OrderPaymentData[]>;
322
- private addOrderPaymentWithDevicePrefix;
323
317
  /**
324
- * 默认按支付唯一号精确更新;仅显式指定 legacy 时兼容历史支付标识。
325
- * metadata 与 transactions 会分别合并,避免覆盖支付会话号和已有交易记录。
318
+ * 按支付唯一号、后端支付 ID、自定义支付方式 ID 或旧 uuid 更新支付项。
319
+ *
320
+ * 该方法服务 PaymentModal 的 void / 编辑场景;更新 metadata 时会做浅合并,
321
+ * 避免覆盖 unique_payment_number、现金实付/找零等已有元数据。
326
322
  */
327
- updateOrderPayment(paymentIdentity: string | number, updates: Partial<OrderPaymentData> & Record<string, any>, options?: OrderPaymentUpdateOptions): Promise<OrderPaymentUpdateResult>;
323
+ updateOrderPayment(paymentIdentity: string | number, updates: Partial<OrderPaymentData> & Record<string, any>): OrderPaymentData[];
328
324
  /** 从当前订单支付项中移除指定支付项。 */
329
325
  deleteOrderPayment(paymentIdentity: string | number): OrderPaymentData[];
330
326
  private confirmPendingVoucherPaymentsInList;
@@ -347,11 +343,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
347
343
  */
348
344
  updateVoucherOrderPayments(payments: OrderPaymentSource[], options?: {
349
345
  status?: 'paid' | 'payment_pending';
350
- devicePrefix?: string;
351
346
  }): OrderPaymentData[];
352
- updateVoucherOrderPaymentsAsync(payments: OrderPaymentSource[], options?: {
353
- status?: 'paid' | 'payment_pending';
354
- }): Promise<OrderPaymentData[]>;
355
347
  private shouldMergeProductToOrder;
356
348
  private hasOrderProductLineNote;
357
349
  /**
@@ -436,14 +428,6 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
436
428
  type?: string;
437
429
  }): import("./types").OrderSubmitPayload;
438
430
  applyLocalPrintOrderNumbers(order?: Record<string, any> | null): Promise<OrderTempOrder>;
439
- saveTempOrderAsDraft<T = any>(params?: {
440
- cacheId?: string;
441
- platform?: string;
442
- businessCode?: string;
443
- channel?: string;
444
- type?: string;
445
- enhancePayload?: SubmitPayloadEnhancer;
446
- }): Promise<T>;
447
431
  /**
448
432
  * 提交当前 Sales tempOrder。
449
433
  *
@@ -495,6 +479,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
495
479
  is_deposit: number;
496
480
  relation_products: any[];
497
481
  relation_forms: any[];
482
+ business_code: string | undefined;
498
483
  };
499
484
  checkBeforeSubmitOrder(params: {
500
485
  cartItems: CartItem[];
@@ -548,8 +533,6 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
548
533
  */
549
534
  private seedAnonymousBookingUidsFromProducts;
550
535
  private normalizeTempOrderForRuntime;
551
- private isSyntheticDraftOrderIdForRuntime;
552
- private withoutSyntheticDraftOrderIdForRuntime;
553
536
  private hydrateLinkedBookingIdentity;
554
537
  private pickHydratedDisplayText;
555
538
  private formatHydratedNamePair;
@@ -37,8 +37,6 @@ var import_types = require("./types");
37
37
  var import_utils = require("./utils");
38
38
  var import_utils2 = require("../Product/utils");
39
39
  var import_dayjs = __toESM(require("dayjs"));
40
- var import_payment_utils = require("./payment-utils");
41
- var import_payment_number = require("../../utils/payment-number");
42
40
  var import_cartPromotion = require("../../solution/BaseSales/utils/cartPromotion");
43
41
  var import_utils3 = require("../../solution/ScanOrder/utils");
44
42
  var import_manualProductDiscount = require("./utils/manualProductDiscount");
@@ -85,11 +83,6 @@ function isPaidPaymentRecord(payment) {
85
83
  function isCommittedVoucherPaymentRecord(payment) {
86
84
  return isVoucherPaymentRecord(payment) && (payment == null ? void 0 : payment.status) !== "voided" && (hasSyncedOrderPaymentRecord(payment) || isPaidPaymentRecord(payment));
87
85
  }
88
- function getVoucherPaymentLifecycleKey(payment) {
89
- if (!isVoucherPaymentRecord(payment))
90
- return null;
91
- return `${String(payment.voucher_id)}::${String(payment.status || "")}`;
92
- }
93
86
  var OrderModule = class extends import_BaseModule.BaseModule {
94
87
  constructor(name, version) {
95
88
  super(name || "order", version);
@@ -307,7 +300,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
307
300
  });
308
301
  }
309
302
  async initialize(core, options) {
310
- var _a, _b, _c;
303
+ var _a, _b, _c, _d;
311
304
  this.core = core;
312
305
  this.store = options.store;
313
306
  if (!this.store.tempOrder) {
@@ -320,19 +313,19 @@ var OrderModule = class extends import_BaseModule.BaseModule {
320
313
  this.store.availableWalletIds = [];
321
314
  }
322
315
  this.request = this.core.getPlugin("request");
323
- this.appPlugin = this.core.getPlugin("app");
324
- if (!this.appPlugin) {
325
- throw new Error("Order 模块需要 app 插件支持");
316
+ const appPlugin = this.core.getPlugin("app");
317
+ if (!appPlugin) {
318
+ console.error("Order 模块需要 app 插件支持");
326
319
  }
327
- const app = this.appPlugin.getApp();
328
- this.logger = app.logger;
320
+ const app = (_a = appPlugin == null ? void 0 : appPlugin.getApp) == null ? void 0 : _a.call(appPlugin);
321
+ this.logger = app == null ? void 0 : app.logger;
329
322
  this.window = this.core.getPlugin("window");
330
323
  const otherParams = options.otherParams || {};
331
324
  this.cacheId = otherParams.cacheId;
332
325
  this.salesSummaryModuleName = otherParams.salesSummaryModuleName;
333
- this.rulesHooksOverride = (_a = otherParams.rules) == null ? void 0 : _a.hooks;
326
+ this.rulesHooksOverride = (_b = otherParams.rules) == null ? void 0 : _b.hooks;
334
327
  this.moduleHooksOverride = options.hooks;
335
- this.orderHooks = this.moduleHooksOverride || ((_b = otherParams.order) == null ? void 0 : _b.hooks) || ((_c = otherParams.hooks) == null ? void 0 : _c.order);
328
+ this.orderHooks = this.moduleHooksOverride || ((_c = otherParams.order) == null ? void 0 : _c.hooks) || ((_d = otherParams.hooks) == null ? void 0 : _d.order);
336
329
  this.otherParams = otherParams;
337
330
  this.registerDiscountModules(options);
338
331
  this.logInfo("OrderModule initialized successfully");
@@ -841,6 +834,16 @@ var OrderModule = class extends import_BaseModule.BaseModule {
841
834
  /** @deprecated OrderModule 不再负责 tempOrder localStorage 持久化;草稿保存请使用 IndexedDB saveDraft。 */
842
835
  persistTempOrder() {
843
836
  }
837
+ notifyTempOrderChanged() {
838
+ if (!this.store.tempOrder)
839
+ return;
840
+ this.store.tempOrder = {
841
+ ...this.store.tempOrder,
842
+ products: [...this.store.tempOrder.products],
843
+ bookings: this.store.tempOrder.bookings ? [...this.store.tempOrder.bookings] : []
844
+ };
845
+ this.persistTempOrder();
846
+ }
844
847
  // ─── TempOrder: 创建 & 获取 ───
845
848
  createDefaultTempOrderInstance() {
846
849
  return (0, import_utils.createDefaultTempOrder)({
@@ -1060,40 +1063,17 @@ var OrderModule = class extends import_BaseModule.BaseModule {
1060
1063
  const depositPaidAmount = this.calculateDepositPaidAmount(tempOrder.payments || []);
1061
1064
  return depositPaidAmount.lt(depositAmount) ? "deposit" : "normal";
1062
1065
  }
1063
- getPaymentNumberAppData(key) {
1064
- var _a, _b, _c, _d, _e;
1065
- const appPlugin = this.appPlugin;
1066
- if (!appPlugin)
1067
- return void 0;
1068
- const getData = (_a = appPlugin.getData) == null ? void 0 : _a.call(appPlugin);
1069
- if (typeof getData === "function")
1070
- return getData(key);
1071
- const app = appPlugin.getApp();
1072
- const coreData = (_e = (_c = (_b = app == null ? void 0 : app.models) == null ? void 0 : _b.getStore) == null ? void 0 : (_d = _c.call(_b)).getDataByModel) == null ? void 0 : _e.call(_d, "core", "core");
1073
- return coreData == null ? void 0 : coreData[key];
1074
- }
1075
- getPaymentNumberDevicePrefixSync() {
1076
- return (0, import_payment_number.resolvePaymentNumberDevicePrefixFromDeviceId)(
1077
- (key) => this.getPaymentNumberAppData(key)
1078
- );
1079
- }
1080
- getPaymentNumberDevicePrefixAsync() {
1081
- return (0, import_payment_number.resolvePaymentNumberDevicePrefix)(
1082
- (key) => this.getPaymentNumberAppData(key)
1083
- );
1084
- }
1085
1066
  normalizePaymentSource(payment, options) {
1086
1067
  const paymentRecord = payment;
1087
1068
  const metadata = paymentRecord.metadata && typeof paymentRecord.metadata === "object" ? { ...paymentRecord.metadata } : {};
1088
- const normalized = (0, import_payment_utils.ensureOrderPaymentNumber)(
1089
- {
1090
- ...paymentRecord,
1091
- metadata,
1092
- origin_amount: paymentRecord.origin_amount ?? paymentRecord.amount ?? "0.00"
1093
- },
1094
- (options == null ? void 0 : options.devicePrefix) || this.getPaymentNumberDevicePrefixSync(),
1095
- import_utils.createUuidV4
1096
- );
1069
+ if (!metadata.unique_payment_number) {
1070
+ metadata.unique_payment_number = (0, import_utils.createUuidV4)();
1071
+ }
1072
+ const normalized = {
1073
+ ...paymentRecord,
1074
+ metadata,
1075
+ origin_amount: paymentRecord.origin_amount ?? paymentRecord.amount ?? "0.00"
1076
+ };
1097
1077
  if (paymentRecord.status !== void 0) {
1098
1078
  normalized.status = paymentRecord.status;
1099
1079
  } else if ((options == null ? void 0 : options.defaultPaid) !== false) {
@@ -2514,36 +2494,17 @@ var OrderModule = class extends import_BaseModule.BaseModule {
2514
2494
  * 用一组支付来源覆盖当前订单支付项。
2515
2495
  *
2516
2496
  * 入参允许来自 PaymentModule 的 PaymentItem,内部统一映射为 Sales 协议:
2517
- * 新支付来源的 uuid 会作为 payment_number 的唯一号段,id -> custom_payment_id,
2497
+ * uuid -> metadata.unique_payment_number,id -> custom_payment_id,
2518
2498
  * isSynced 等运行态字段不会进入 tempOrder.payments。
2519
2499
  */
2520
2500
  setOrderPayments(payments) {
2521
2501
  const tempOrder = this.ensureTempOrder();
2522
- tempOrder.payments = (0, import_utils.mapPaymentItemsToOrderPayments)(
2523
- (payments || []).map((payment) => this.normalizePaymentSource(payment, { defaultPaid: false }))
2524
- );
2502
+ tempOrder.payments = (0, import_utils.mapPaymentItemsToOrderPayments)(payments);
2525
2503
  this.persistTempOrder();
2526
2504
  return tempOrder.payments;
2527
2505
  }
2528
- /** 同步兼容入口:按调用当下的 device_id 或 LOCAL 生成支付编号。 */
2506
+ /** 追加单个支付项,并立即持久化当前 tempOrder。 */
2529
2507
  addOrderPayment(payment) {
2530
- const hasPaymentNumber = String(
2531
- payment.payment_number || ""
2532
- ).trim() !== "";
2533
- return this.addOrderPaymentWithDevicePrefix(
2534
- payment,
2535
- hasPaymentNumber ? "LOCAL" : this.getPaymentNumberDevicePrefixSync()
2536
- );
2537
- }
2538
- /** 异步入口:创建支付项时读取最新 IoT 设备短号。 */
2539
- async addOrderPaymentAsync(payment) {
2540
- const hasPaymentNumber = String(
2541
- payment.payment_number || ""
2542
- ).trim() !== "";
2543
- const devicePrefix = hasPaymentNumber ? "LOCAL" : await this.getPaymentNumberDevicePrefixAsync();
2544
- return this.addOrderPaymentWithDevicePrefix(payment, devicePrefix);
2545
- }
2546
- addOrderPaymentWithDevicePrefix(payment, devicePrefix) {
2547
2508
  this.logInfo("addOrderPayment", {
2548
2509
  payment
2549
2510
  });
@@ -2556,7 +2517,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
2556
2517
  type: orderPaymentType,
2557
2518
  order_payment_type: orderPaymentType
2558
2519
  },
2559
- { defaultPaid: true, devicePrefix }
2520
+ { defaultPaid: true }
2560
2521
  )
2561
2522
  ]);
2562
2523
  tempOrder.payments = [...tempOrder.payments || [], ...mapped];
@@ -2569,55 +2530,57 @@ var OrderModule = class extends import_BaseModule.BaseModule {
2569
2530
  return tempOrder.payments;
2570
2531
  }
2571
2532
  /**
2572
- * 默认按支付唯一号精确更新;仅显式指定 legacy 时兼容历史支付标识。
2573
- * metadata 与 transactions 会分别合并,避免覆盖支付会话号和已有交易记录。
2533
+ * 按支付唯一号、后端支付 ID、自定义支付方式 ID 或旧 uuid 更新支付项。
2534
+ *
2535
+ * 该方法服务 PaymentModal 的 void / 编辑场景;更新 metadata 时会做浅合并,
2536
+ * 避免覆盖 unique_payment_number、现金实付/找零等已有元数据。
2574
2537
  */
2575
- async updateOrderPayment(paymentIdentity, updates, options = {}) {
2538
+ updateOrderPayment(paymentIdentity, updates) {
2576
2539
  const tempOrder = this.ensureTempOrder();
2577
2540
  const identity = String(paymentIdentity);
2578
- const matchMode = options.matchBy === "compat" || options.matchBy === "legacy" ? "compat" : "payment_number";
2579
- const matchedPayment = (0, import_payment_utils.resolveOrderPaymentIdentity)(
2580
- tempOrder.payments || [],
2581
- identity,
2582
- matchMode
2583
- );
2584
- if (!matchedPayment) {
2585
- throw new Error(`未找到支付项: ${identity}`);
2586
- }
2587
- let updatedPayment = null;
2588
- tempOrder.payments = (tempOrder.payments || []).map((payment, index) => {
2589
- if (index !== matchedPayment.index)
2541
+ tempOrder.payments = (tempOrder.payments || []).map((payment) => {
2542
+ var _a;
2543
+ const uniquePaymentNumber = (_a = payment == null ? void 0 : payment.metadata) == null ? void 0 : _a.unique_payment_number;
2544
+ const orderPaymentId = payment == null ? void 0 : payment.order_payment_id;
2545
+ const customPaymentId = payment == null ? void 0 : payment.custom_payment_id;
2546
+ const uuid = payment == null ? void 0 : payment.uuid;
2547
+ const matched = [
2548
+ uniquePaymentNumber,
2549
+ orderPaymentId,
2550
+ customPaymentId,
2551
+ uuid
2552
+ ].some((value) => value !== void 0 && String(value) === identity);
2553
+ if (!matched)
2590
2554
  return payment;
2591
- const nextPayment = (0, import_payment_utils.mergeOrderPaymentRecord)(payment, {
2555
+ return {
2556
+ ...payment,
2592
2557
  ...updates,
2593
- updated_at: updates.updated_at || (0, import_dayjs.default)().format("YYYY-MM-DD HH:mm:ss")
2594
- });
2595
- updatedPayment = nextPayment;
2596
- return nextPayment;
2558
+ metadata: {
2559
+ ...payment.metadata || {},
2560
+ ...updates.metadata || {}
2561
+ }
2562
+ };
2597
2563
  });
2598
2564
  this.persistTempOrder();
2599
- const summary = await this.recalculateSummary({ createIfMissing: true });
2600
- this.persistTempOrder();
2601
- const payments = tempOrder.payments;
2602
- return {
2603
- updated: true,
2604
- payment: payments[matchedPayment.index] || updatedPayment,
2605
- payments,
2606
- summary
2607
- };
2565
+ return tempOrder.payments;
2608
2566
  }
2609
2567
  /** 从当前订单支付项中移除指定支付项。 */
2610
2568
  deleteOrderPayment(paymentIdentity) {
2611
2569
  const tempOrder = this.ensureTempOrder();
2612
2570
  const identity = String(paymentIdentity);
2613
- const matchedPayment = (0, import_payment_utils.resolveOrderPaymentIdentity)(
2614
- tempOrder.payments || [],
2615
- identity,
2616
- "compat"
2617
- );
2618
- if (!matchedPayment)
2619
- return tempOrder.payments;
2620
- tempOrder.payments = (tempOrder.payments || []).filter((_, index) => index !== matchedPayment.index);
2571
+ tempOrder.payments = (tempOrder.payments || []).filter((payment) => {
2572
+ var _a;
2573
+ const uniquePaymentNumber = (_a = payment == null ? void 0 : payment.metadata) == null ? void 0 : _a.unique_payment_number;
2574
+ const orderPaymentId = payment == null ? void 0 : payment.order_payment_id;
2575
+ const customPaymentId = payment == null ? void 0 : payment.custom_payment_id;
2576
+ const uuid = payment == null ? void 0 : payment.uuid;
2577
+ return ![
2578
+ uniquePaymentNumber,
2579
+ orderPaymentId,
2580
+ customPaymentId,
2581
+ uuid
2582
+ ].some((value) => value !== void 0 && String(value) === identity);
2583
+ });
2621
2584
  this.persistTempOrder();
2622
2585
  return tempOrder.payments;
2623
2586
  }
@@ -2726,10 +2689,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
2726
2689
  payments.map(
2727
2690
  (payment) => this.normalizePaymentSource(
2728
2691
  normalizeVoucherPaymentStatus(withVoucherPaymentType(payment)),
2729
- {
2730
- defaultPaid: false,
2731
- devicePrefix: options == null ? void 0 : options.devicePrefix
2732
- }
2692
+ { defaultPaid: false }
2733
2693
  )
2734
2694
  )
2735
2695
  ).filter((payment) => {
@@ -2751,15 +2711,14 @@ var OrderModule = class extends import_BaseModule.BaseModule {
2751
2711
  const committedVoucherPaymentIds = new Set(
2752
2712
  committedVoucherPayments.filter((payment) => hasSyncedOrderPaymentRecord(payment)).map((payment) => String(payment.order_payment_id))
2753
2713
  );
2754
- const committedVoucherLifecycleKeys = new Set(
2755
- committedVoucherPayments.map((payment) => getVoucherPaymentLifecycleKey(payment)).filter((key) => key !== null)
2714
+ const committedVoucherIds = new Set(
2715
+ committedVoucherPayments.map((payment) => String(payment.voucher_id))
2756
2716
  );
2757
2717
  const replaceableVouchers = mappedVouchers.filter((payment) => {
2758
2718
  if (hasSyncedOrderPaymentRecord(payment) && committedVoucherPaymentIds.has(String(payment.order_payment_id))) {
2759
2719
  return false;
2760
2720
  }
2761
- const lifecycleKey = getVoucherPaymentLifecycleKey(payment);
2762
- if (lifecycleKey && committedVoucherLifecycleKeys.has(lifecycleKey)) {
2721
+ if (payment.voucher_id !== void 0 && committedVoucherIds.has(String(payment.voucher_id))) {
2763
2722
  return false;
2764
2723
  }
2765
2724
  return true;
@@ -2781,14 +2740,6 @@ var OrderModule = class extends import_BaseModule.BaseModule {
2781
2740
  });
2782
2741
  return tempOrder.payments;
2783
2742
  }
2784
- async updateVoucherOrderPaymentsAsync(payments, options) {
2785
- const needsPaymentNumber = (payments || []).some((payment) => String(payment.payment_number || "").trim() === "");
2786
- const devicePrefix = needsPaymentNumber ? await this.getPaymentNumberDevicePrefixAsync() : "LOCAL";
2787
- return this.updateVoucherOrderPayments(payments, {
2788
- ...options,
2789
- devicePrefix
2790
- });
2791
- }
2792
2743
  async shouldMergeProductToOrder(params) {
2793
2744
  var _a;
2794
2745
  const onBeforeMergeProductToOrder = (_a = this.orderHooks) == null ? void 0 : _a.onBeforeMergeProductToOrder;
@@ -3619,38 +3570,6 @@ var OrderModule = class extends import_BaseModule.BaseModule {
3619
3570
  await this.saveDraft();
3620
3571
  return tempOrder;
3621
3572
  }
3622
- async saveTempOrderAsDraft(params) {
3623
- var _a, _b, _c, _d, _e;
3624
- const tempOrder = this.ensureTempOrder();
3625
- this.ensureExternalSaleNumber(tempOrder);
3626
- this.persistTempOrder();
3627
- const latestSummary = await this.recalculateSummary({ createIfMissing: true }) || this.store.summary || (0, import_utils.createEmptySummary)();
3628
- const payload = (0, import_utils.buildSubmitPayload)({
3629
- tempOrder,
3630
- cacheId: (params == null ? void 0 : params.cacheId) ?? this.cacheId,
3631
- platform: (params == null ? void 0 : params.platform) || ((_a = this.otherParams) == null ? void 0 : _a.platform),
3632
- businessCode: (params == null ? void 0 : params.businessCode) || ((_b = this.otherParams) == null ? void 0 : _b.businessCode) || ((_c = this.otherParams) == null ? void 0 : _c.business_code) || tempOrder.business_code,
3633
- channel: params == null ? void 0 : params.channel,
3634
- type: (params == null ? void 0 : params.type) ?? ((_d = this.otherParams) == null ? void 0 : _d.type),
3635
- summary: latestSummary,
3636
- enhance: params == null ? void 0 : params.enhancePayload
3637
- });
3638
- if (!payload.created_at) {
3639
- payload.created_at = (0, import_dayjs.default)().format("YYYY-MM-DD HH:mm:ss");
3640
- }
3641
- payload.need_sync = 0;
3642
- payload.is_draft_order = 1;
3643
- this.logInfo("saveTempOrderAsDraft calling sales draft", {
3644
- orderId: payload.order_id,
3645
- externalSaleNumber: payload.external_sale_number,
3646
- productsCount: ((_e = payload.products) == null ? void 0 : _e.length) || 0
3647
- });
3648
- return this.request.post("/order/sales/draft", payload, {
3649
- osServer: true,
3650
- customToast: () => {
3651
- }
3652
- });
3653
- }
3654
3573
  /**
3655
3574
  * 提交当前 Sales tempOrder。
3656
3575
  *
@@ -3851,13 +3770,8 @@ var OrderModule = class extends import_BaseModule.BaseModule {
3851
3770
  }
3852
3771
  async syncPaymentsToOrder(params) {
3853
3772
  const tempOrder = this.ensureTempOrder();
3854
- const needsPaymentNumber = (params.payments || []).some((payment) => String(payment.payment_number || "").trim() === "");
3855
- const devicePrefix = needsPaymentNumber ? await this.getPaymentNumberDevicePrefixAsync() : "LOCAL";
3856
3773
  const mappedPayments = (0, import_utils.mapPaymentItemsToOrderPayments)(
3857
- (params.payments || []).map((payment) => this.normalizePaymentSource(payment, {
3858
- defaultPaid: false,
3859
- devicePrefix
3860
- }))
3774
+ params.payments || []
3861
3775
  );
3862
3776
  const shouldConfirmPendingVoucherPayments = params.confirmPendingVoucherPayments ?? params.submitWhenPaid === true;
3863
3777
  const effectivePayments = shouldConfirmPendingVoucherPayments ? this.confirmPendingVoucherPaymentsInList(mappedPayments) : params.confirmPendingVoucherPayments === false ? this.discardPendingVoucherPaymentsFromList(mappedPayments) : mappedPayments;
@@ -3879,7 +3793,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
3879
3793
  tempOrder,
3880
3794
  effectivePayments
3881
3795
  );
3882
- const submitResult = await this.submitTempOrder({
3796
+ const submitParams = {
3883
3797
  payments: effectivePayments,
3884
3798
  paymentStatus,
3885
3799
  smallTicketDataFlag: params.smallTicketDataFlag,
@@ -3893,7 +3807,8 @@ var OrderModule = class extends import_BaseModule.BaseModule {
3893
3807
  };
3894
3808
  return nextPayload;
3895
3809
  }
3896
- });
3810
+ };
3811
+ const submitResult = params.checkoutSyncTaskEnabled === false ? await this.submitTempOrderAsync(submitParams) : await this.submitTempOrder(submitParams);
3897
3812
  return { ...completion, submitResult };
3898
3813
  }
3899
3814
  createOrder(params) {
@@ -3910,11 +3825,13 @@ var OrderModule = class extends import_BaseModule.BaseModule {
3910
3825
  is_deposit: 0,
3911
3826
  relation_products: [],
3912
3827
  relation_forms: [],
3828
+ business_code: params == null ? void 0 : params.business_code,
3913
3829
  ...(params == null ? void 0 : params.extraData) || {}
3914
3830
  };
3915
3831
  let is_deposit = 0;
3916
3832
  if (params.cartItems.length > 0) {
3917
3833
  params.cartItems.forEach((item) => {
3834
+ var _a2;
3918
3835
  if (!item._origin.duration) {
3919
3836
  const { duration, durationType } = (0, import_utils.generateDuration)(item);
3920
3837
  item._origin.duration = duration;
@@ -3923,6 +3840,9 @@ var OrderModule = class extends import_BaseModule.BaseModule {
3923
3840
  item._origin.sub_type = (0, import_utils.normalizeBookingSubType)(item._origin);
3924
3841
  const discountList = (0, import_utils.getAllDiscountList)(item);
3925
3842
  item._origin.product.discount_list = discountList;
3843
+ if ((_a2 = params == null ? void 0 : params.extraData) == null ? void 0 : _a2.is_add_holder_info) {
3844
+ (0, import_utils.ensureCartItemOriginHolder)(item, this.window);
3845
+ }
3926
3846
  if ((0, import_utils2.isNormalProduct)(item._origin)) {
3927
3847
  order.relation_products.push(item._origin.product);
3928
3848
  const relationForms = item._origin.relation_forms || [];
@@ -4233,12 +4153,6 @@ var OrderModule = class extends import_BaseModule.BaseModule {
4233
4153
  }
4234
4154
  }
4235
4155
  const nextTempOrder = this.normalizeTempOrderForRuntime(raw, { makeEditMark: true });
4236
- const sourceLastOrderInfo = raw.lastOrderInfo || raw;
4237
- const isDraftOrder = Number(nextTempOrder.is_draft_order || 0) === 1;
4238
- const syntheticIdentityOptions = {
4239
- isDraftOrder,
4240
- externalSaleNumber: nextTempOrder.external_sale_number
4241
- };
4242
4156
  const rawSummary = raw.summary && typeof raw.summary === "object" ? raw.summary : {};
4243
4157
  const summarySurcharges = Array.isArray(rawSummary.surcharges) ? rawSummary.surcharges.map((s) => ({ ...s || {} })) : (0, import_lodash_es.cloneDeep)(nextTempOrder.surcharges || []);
4244
4158
  this.store.tempOrder = nextTempOrder;
@@ -4259,14 +4173,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
4259
4173
  productFingerprint: this.buildOrderProductsFingerprint(nextTempOrder.products || [])
4260
4174
  }
4261
4175
  };
4262
- this.store.lastOrderInfo = this.withoutSyntheticDraftOrderIdForRuntime(
4263
- sourceLastOrderInfo,
4264
- syntheticIdentityOptions
4265
- );
4266
- const hadSyntheticDraftOrderId = this.isSyntheticDraftOrderIdForRuntime(raw, syntheticIdentityOptions) || this.isSyntheticDraftOrderIdForRuntime(sourceLastOrderInfo, syntheticIdentityOptions);
4267
- if (hadSyntheticDraftOrderId && this.store.syncState !== "submitting") {
4268
- this.store.syncState = "local";
4269
- }
4176
+ this.store.lastOrderInfo = sourceRaw.lastOrderInfo || sourceRaw;
4270
4177
  const hydratedEditDiscounts = this.collectHydratedEditDiscounts(nextTempOrder.products);
4271
4178
  const currentDiscounts = typeof ((_a = this.store.discount) == null ? void 0 : _a.getDiscountList) === "function" ? this.store.discount.getDiscountList() || [] : [];
4272
4179
  const currentScanDiscounts = currentDiscounts.filter((discount) => discount == null ? void 0 : discount.isScan);
@@ -4379,13 +4286,12 @@ var OrderModule = class extends import_BaseModule.BaseModule {
4379
4286
  }
4380
4287
  normalizeTempOrderForRuntime(raw, options) {
4381
4288
  var _a, _b;
4382
- const runtimeRaw = this.withoutSyntheticDraftOrderIdForRuntime(raw);
4383
4289
  const nextTempOrder = {
4384
4290
  ...this.createDefaultTempOrderInstance(),
4385
- ...runtimeRaw || {}
4291
+ ...raw || {}
4386
4292
  };
4387
- if ((nextTempOrder.order_id === void 0 || nextTempOrder.order_id === null) && (runtimeRaw == null ? void 0 : runtimeRaw.id) !== void 0 && (runtimeRaw == null ? void 0 : runtimeRaw.id) !== null) {
4388
- nextTempOrder.order_id = runtimeRaw.id;
4293
+ if ((nextTempOrder.order_id === void 0 || nextTempOrder.order_id === null) && (raw == null ? void 0 : raw.id) !== void 0 && (raw == null ? void 0 : raw.id) !== null) {
4294
+ nextTempOrder.order_id = raw.id;
4389
4295
  }
4390
4296
  delete nextTempOrder.summary;
4391
4297
  delete nextTempOrder.lastOrderInfo;
@@ -4453,22 +4359,6 @@ var OrderModule = class extends import_BaseModule.BaseModule {
4453
4359
  nextTempOrder.vouchers = raw.vouchers || [];
4454
4360
  return nextTempOrder;
4455
4361
  }
4456
- isSyntheticDraftOrderIdForRuntime(record, options) {
4457
- const isDraftOrder = (options == null ? void 0 : options.isDraftOrder) ?? Number((record == null ? void 0 : record.is_draft_order) || 0) === 1;
4458
- const externalSaleNumber = (record == null ? void 0 : record.external_sale_number) ?? (options == null ? void 0 : options.externalSaleNumber);
4459
- const orderId = record == null ? void 0 : record.order_id;
4460
- return Boolean(
4461
- isDraftOrder && orderId !== void 0 && orderId !== null && orderId !== "" && externalSaleNumber !== void 0 && externalSaleNumber !== null && externalSaleNumber !== "" && String(orderId) === String(externalSaleNumber)
4462
- );
4463
- }
4464
- withoutSyntheticDraftOrderIdForRuntime(record, options) {
4465
- if (!this.isSyntheticDraftOrderIdForRuntime(record, options))
4466
- return record;
4467
- return {
4468
- ...record,
4469
- order_id: null
4470
- };
4471
- }
4472
4362
  hydrateLinkedBookingIdentity(tempOrder) {
4473
4363
  const bookingUidByProductUid = /* @__PURE__ */ new Map();
4474
4364
  const productByUid = /* @__PURE__ */ new Map();