@pisell/pisellos 2.2.278 → 2.2.280

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 (188) hide show
  1. package/dist/modules/BaseModule.d.ts +1 -0
  2. package/dist/modules/BaseModule.js +24 -28
  3. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +7 -3
  4. package/dist/modules/BookingContext/utils/productExtend.js +5 -9
  5. package/dist/modules/BookingContext/utils/timeSlices.js +24 -3
  6. package/dist/modules/Customer/index.d.ts +4 -0
  7. package/dist/modules/Customer/index.js +91 -59
  8. package/dist/modules/Customer/types.d.ts +2 -0
  9. package/dist/modules/Discount/index.d.ts +1 -0
  10. package/dist/modules/Discount/index.js +40 -11
  11. package/dist/modules/Discount/types.d.ts +1 -0
  12. package/dist/modules/Holder/index.d.ts +48 -0
  13. package/dist/modules/Holder/index.js +640 -0
  14. package/dist/modules/Holder/types.d.ts +123 -0
  15. package/dist/modules/Holder/types.js +1 -0
  16. package/dist/modules/Holder/utils.d.ts +13 -0
  17. package/dist/modules/Holder/utils.js +34 -0
  18. package/dist/modules/OpenData/index.js +2 -2
  19. package/dist/modules/Order/index.d.ts +32 -4
  20. package/dist/modules/Order/index.js +868 -675
  21. package/dist/modules/Order/types.d.ts +22 -1
  22. package/dist/modules/Order/utils/discountProductLineIdentity.d.ts +45 -0
  23. package/dist/modules/Order/utils/discountProductLineIdentity.js +227 -0
  24. package/dist/modules/Order/utils/orderCollectionIdentity.d.ts +15 -0
  25. package/dist/modules/Order/utils/orderCollectionIdentity.js +75 -0
  26. package/dist/modules/Order/utils.d.ts +10 -0
  27. package/dist/modules/Order/utils.js +71 -34
  28. package/dist/modules/Payment/index.d.ts +4 -0
  29. package/dist/modules/Payment/index.js +14 -4
  30. package/dist/modules/Payment/walletpass.js +21 -7
  31. package/dist/modules/Product/types.d.ts +1 -0
  32. package/dist/modules/ProductList/index.js +33 -13
  33. package/dist/modules/Quotation/index.d.ts +1 -1
  34. package/dist/modules/Quotation/index.js +2 -2
  35. package/dist/modules/ResourcePlanner/index.d.ts +24 -0
  36. package/dist/modules/ResourcePlanner/index.js +181 -0
  37. package/dist/modules/ResourcePlanner/planner.d.ts +14 -0
  38. package/dist/modules/ResourcePlanner/planner.js +1069 -0
  39. package/dist/modules/ResourcePlanner/types.d.ts +227 -0
  40. package/dist/modules/ResourcePlanner/types.js +1 -0
  41. package/dist/modules/Rules/index.js +153 -56
  42. package/dist/modules/SalesSummary/index.js +12 -13
  43. package/dist/modules/ScanOrderLogger/index.d.ts +2 -0
  44. package/dist/modules/ScanOrderLogger/index.js +15 -2
  45. package/dist/modules/ScanOrderLogger/providers/feishu.js +45 -27
  46. package/dist/modules/ScanOrderLogger/types.d.ts +1 -0
  47. package/dist/modules/Schedule/index.d.ts +3 -1
  48. package/dist/modules/Schedule/index.js +21 -16
  49. package/dist/modules/Summary/utils.js +38 -13
  50. package/dist/modules/index.d.ts +2 -0
  51. package/dist/modules/index.js +3 -1
  52. package/dist/plugins/window.d.ts +1 -0
  53. package/dist/server/index.d.ts +20 -0
  54. package/dist/server/index.js +1101 -909
  55. package/dist/server/modules/order/index.d.ts +2 -0
  56. package/dist/server/modules/order/index.js +261 -96
  57. package/dist/server/modules/order/types.d.ts +1 -1
  58. package/dist/solution/BaseSales/index.d.ts +20 -1
  59. package/dist/solution/BaseSales/index.js +989 -881
  60. package/dist/solution/BaseSales/utils/cartPromotion.js +19 -1
  61. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +6 -3
  62. package/dist/solution/BaseSales/utils.js +31 -20
  63. package/dist/solution/BookingByStep/index.d.ts +17 -2
  64. package/dist/solution/BookingByStep/index.js +294 -215
  65. package/dist/solution/BookingByStep/types.d.ts +2 -1
  66. package/dist/solution/BookingByStep/types.js +3 -1
  67. package/dist/solution/BookingByStep/utils/capacity.js +17 -1
  68. package/dist/solution/BookingByStep/utils/timeslots.d.ts +3 -1
  69. package/dist/solution/BookingByStep/utils/timeslots.js +19 -12
  70. package/dist/solution/BookingTicket/index.d.ts +21 -3
  71. package/dist/solution/BookingTicket/index.js +312 -226
  72. package/dist/solution/BookingTicket/utils/scan/handleScan.d.ts +3 -1
  73. package/dist/solution/BookingTicket/utils/scan/handleScan.js +10 -2
  74. package/dist/solution/ScanOrder/index.d.ts +26 -14
  75. package/dist/solution/ScanOrder/index.js +1142 -739
  76. package/dist/solution/ScanOrder/types.d.ts +21 -1
  77. package/dist/solution/ScanOrder/utils.d.ts +8 -0
  78. package/dist/solution/ScanOrder/utils.js +97 -45
  79. package/dist/solution/ShopDiscount/index.d.ts +1 -0
  80. package/dist/solution/ShopDiscount/index.js +125 -87
  81. package/dist/solution/UnifiedBookingSales/index.d.ts +204 -0
  82. package/dist/solution/UnifiedBookingSales/index.js +2211 -0
  83. package/dist/solution/UnifiedBookingSales/types.d.ts +150 -0
  84. package/dist/solution/UnifiedBookingSales/types.js +11 -0
  85. package/dist/solution/VenueBooking/index.d.ts +39 -11
  86. package/dist/solution/VenueBooking/index.js +1167 -841
  87. package/dist/solution/VenueBooking/types.d.ts +3 -0
  88. package/dist/solution/VenueBooking/utils/resource.js +1 -0
  89. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
  90. package/dist/solution/VenueBooking/utils/slotMerge.js +10 -5
  91. package/dist/solution/index.d.ts +1 -0
  92. package/dist/solution/index.js +2 -1
  93. package/dist/types/index.d.ts +1 -0
  94. package/lib/model/strategy/adapter/promotion/index.js +0 -51
  95. package/lib/modules/BaseModule.d.ts +1 -0
  96. package/lib/modules/BaseModule.js +24 -37
  97. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +3 -0
  98. package/lib/modules/BookingContext/utils/productExtend.js +4 -3
  99. package/lib/modules/BookingContext/utils/timeSlices.js +18 -3
  100. package/lib/modules/Customer/index.d.ts +4 -0
  101. package/lib/modules/Customer/index.js +11 -0
  102. package/lib/modules/Customer/types.d.ts +2 -0
  103. package/lib/modules/Discount/index.d.ts +1 -0
  104. package/lib/modules/Discount/index.js +9 -0
  105. package/lib/modules/Discount/types.d.ts +1 -0
  106. package/lib/modules/Holder/index.d.ts +48 -0
  107. package/lib/modules/Holder/index.js +402 -0
  108. package/lib/modules/Holder/types.d.ts +123 -0
  109. package/lib/modules/Holder/types.js +17 -0
  110. package/lib/modules/Holder/utils.d.ts +13 -0
  111. package/lib/modules/Holder/utils.js +71 -0
  112. package/lib/modules/OpenData/index.js +1 -1
  113. package/lib/modules/Order/index.d.ts +32 -4
  114. package/lib/modules/Order/index.js +372 -156
  115. package/lib/modules/Order/types.d.ts +22 -1
  116. package/lib/modules/Order/utils/discountProductLineIdentity.d.ts +45 -0
  117. package/lib/modules/Order/utils/discountProductLineIdentity.js +170 -0
  118. package/lib/modules/Order/utils/orderCollectionIdentity.d.ts +15 -0
  119. package/lib/modules/Order/utils/orderCollectionIdentity.js +70 -0
  120. package/lib/modules/Order/utils.d.ts +10 -0
  121. package/lib/modules/Order/utils.js +39 -6
  122. package/lib/modules/Payment/index.d.ts +4 -0
  123. package/lib/modules/Payment/index.js +7 -0
  124. package/lib/modules/Payment/walletpass.js +12 -0
  125. package/lib/modules/Product/types.d.ts +1 -0
  126. package/lib/modules/ProductList/index.js +49 -31
  127. package/lib/modules/Quotation/index.d.ts +1 -1
  128. package/lib/modules/Quotation/index.js +2 -2
  129. package/lib/modules/ResourcePlanner/index.d.ts +24 -0
  130. package/lib/modules/ResourcePlanner/index.js +148 -0
  131. package/lib/modules/ResourcePlanner/planner.d.ts +14 -0
  132. package/lib/modules/ResourcePlanner/planner.js +933 -0
  133. package/lib/modules/ResourcePlanner/types.d.ts +227 -0
  134. package/lib/modules/ResourcePlanner/types.js +17 -0
  135. package/lib/modules/Rules/index.js +117 -25
  136. package/lib/modules/SalesSummary/index.js +6 -7
  137. package/lib/modules/ScanOrderLogger/index.d.ts +2 -0
  138. package/lib/modules/ScanOrderLogger/index.js +13 -1
  139. package/lib/modules/ScanOrderLogger/providers/feishu.js +15 -6
  140. package/lib/modules/ScanOrderLogger/types.d.ts +1 -0
  141. package/lib/modules/Schedule/index.d.ts +3 -1
  142. package/lib/modules/Schedule/index.js +10 -8
  143. package/lib/modules/Summary/utils.js +21 -1
  144. package/lib/modules/index.d.ts +2 -0
  145. package/lib/modules/index.js +5 -1
  146. package/lib/plugins/window.d.ts +1 -0
  147. package/lib/server/index.d.ts +20 -0
  148. package/lib/server/index.js +124 -19
  149. package/lib/server/modules/order/index.d.ts +2 -0
  150. package/lib/server/modules/order/index.js +75 -5
  151. package/lib/server/modules/order/types.d.ts +1 -1
  152. package/lib/solution/BaseSales/index.d.ts +20 -1
  153. package/lib/solution/BaseSales/index.js +105 -31
  154. package/lib/solution/BaseSales/utils/cartPromotion.js +18 -0
  155. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +1 -0
  156. package/lib/solution/BaseSales/utils.js +29 -18
  157. package/lib/solution/BookingByStep/index.d.ts +17 -2
  158. package/lib/solution/BookingByStep/index.js +60 -18
  159. package/lib/solution/BookingByStep/types.d.ts +2 -1
  160. package/lib/solution/BookingByStep/types.js +5 -0
  161. package/lib/solution/BookingByStep/utils/capacity.js +20 -1
  162. package/lib/solution/BookingByStep/utils/timeslots.d.ts +3 -1
  163. package/lib/solution/BookingByStep/utils/timeslots.js +19 -11
  164. package/lib/solution/BookingTicket/index.d.ts +21 -3
  165. package/lib/solution/BookingTicket/index.js +75 -16
  166. package/lib/solution/BookingTicket/utils/scan/handleScan.d.ts +3 -1
  167. package/lib/solution/BookingTicket/utils/scan/handleScan.js +2 -2
  168. package/lib/solution/ScanOrder/index.d.ts +26 -14
  169. package/lib/solution/ScanOrder/index.js +449 -182
  170. package/lib/solution/ScanOrder/types.d.ts +21 -1
  171. package/lib/solution/ScanOrder/utils.d.ts +8 -0
  172. package/lib/solution/ScanOrder/utils.js +60 -18
  173. package/lib/solution/ShopDiscount/index.d.ts +1 -0
  174. package/lib/solution/ShopDiscount/index.js +14 -0
  175. package/lib/solution/UnifiedBookingSales/index.d.ts +204 -0
  176. package/lib/solution/UnifiedBookingSales/index.js +1273 -0
  177. package/lib/solution/UnifiedBookingSales/types.d.ts +150 -0
  178. package/lib/solution/UnifiedBookingSales/types.js +33 -0
  179. package/lib/solution/VenueBooking/index.d.ts +39 -11
  180. package/lib/solution/VenueBooking/index.js +322 -110
  181. package/lib/solution/VenueBooking/types.d.ts +3 -0
  182. package/lib/solution/VenueBooking/utils/resource.js +1 -0
  183. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
  184. package/lib/solution/VenueBooking/utils/slotMerge.js +6 -4
  185. package/lib/solution/index.d.ts +1 -0
  186. package/lib/solution/index.js +3 -1
  187. package/lib/types/index.d.ts +1 -0
  188. package/package.json +1 -1
@@ -414,6 +414,7 @@ export interface CommitOrderParams {
414
414
  type: 'virtual' | 'appointment_booking';
415
415
  platform?: string;
416
416
  extraData?: Record<string, any>;
417
+ business_code?: string;
417
418
  };
418
419
  }
419
420
  export interface OrderSubmitBooking {
@@ -578,6 +579,10 @@ export interface LoadSalesDetailParams {
578
579
  * 存在时 loadSalesDetail 会跳过远端 lookup,直接复用 hydrate 后半段逻辑。
579
580
  */
580
581
  preloadedSalesDetail?: Record<string, any>;
582
+ /**
583
+ * sessionStorage 快照复用详情 hydrate 时使用;不带该值时保持既有编辑订单语义。
584
+ */
585
+ hydrateSource?: 'sessionStorage';
581
586
  forceRemote?: boolean;
582
587
  merge?: boolean;
583
588
  }
@@ -589,6 +594,12 @@ export interface SyncPaymentsToOrderParams {
589
594
  payments: OrderPaymentSource[];
590
595
  paymentStatus?: SubmitSalesOrderParams['query']['payment_status'];
591
596
  submitWhenPaid?: boolean;
597
+ /**
598
+ * Whether the checkout should be queued as the local `sync_sales` task.
599
+ * Defaults to true to preserve the WebPOS retry path. Set to false when
600
+ * the caller must wait for the cloud checkout response before proceeding.
601
+ */
602
+ checkoutSyncTaskEnabled?: boolean;
592
603
  smallTicketDataFlag?: number;
593
604
  businessCode?: string;
594
605
  channel?: string;
@@ -742,8 +753,15 @@ export interface OrderModuleAPI {
742
753
  removeProductFromOrder: (identity: OrderProductIdentity, options?: RemoveProductsFromOrderOptions) => Promise<OrderProduct[]>;
743
754
  /** 批量删除购物车行,末尾仅触发一次促销重算与 summary 刷新 */
744
755
  removeProductsFromOrder: (identities: OrderProductIdentity[], options?: RemoveProductsFromOrderOptions) => Promise<OrderProduct[]>;
745
- /** @deprecated no-op;OrderModule 不再负责 tempOrder localStorage 持久化。 */
756
+ /** 在显式开启时保存当前 tempOrder sessionStorage 会话快照。 */
746
757
  persistTempOrder: () => void;
758
+ /**
759
+ * 删除当前 cacheId 的 tempOrder 会话快照,并阻止当前模块实例再次写入。
760
+ * 新模块实例初始化时会按 otherParams 重新启用持久化。
761
+ */
762
+ clearSessionStoragePersistedTempOrder: () => void;
763
+ /** 取出一次待恢复的 sessionStorage tempOrder 快照。 */
764
+ consumeSessionStorageRestore: () => Record<string, any> | null;
747
765
  /**
748
766
  * 控制 IndexedDB 草稿(saveDraft)开关;localStorage tempOrder 持久化已废弃。
749
767
  * BigSale 弹窗等场景传 false 可跳过 saveDraft。
@@ -751,6 +769,8 @@ export interface OrderModuleAPI {
751
769
  setEnableTempOrderPersist: (enabled: boolean) => void;
752
770
  /** 是否允许 saveDraft 写入 IndexedDB 草稿。 */
753
771
  isTempOrderPersistEnabled: () => boolean;
772
+ /** 提交 tempOrder 变更并触发 `{moduleName}:changed` 事件 */
773
+ notifyTempOrderChanged: () => void;
754
774
  submitTempOrder: <T = any>(params?: {
755
775
  cacheId?: string;
756
776
  platform?: string;
@@ -799,6 +819,7 @@ export interface OrderModuleAPI {
799
819
  saveDraft: () => Promise<void>;
800
820
  hydrateTempOrderFromRecord: (record: Record<string, any>, options?: {
801
821
  recalcOnHydrate?: boolean;
822
+ source?: 'salesDetail' | 'sessionStorage';
802
823
  }) => Promise<OrderTempOrder>;
803
824
  syncPaymentsToOrder: <T = any>(params: SyncPaymentsToOrderParams) => Promise<SyncPaymentsToOrderResult<T>>;
804
825
  getSalesOrderByLookup: (params: SalesOrderLookupParams) => Promise<any>;
@@ -0,0 +1,45 @@
1
+ import type { OrderTempOrder } from '../types';
2
+ /**
3
+ * 商品券拆行的身份与回并工具。
4
+ *
5
+ * 背景:
6
+ * Rules.calcDiscount 应用 good_pass 时,会把一个数量行拆成若干「用券行」和
7
+ * 「普通余量行」。Rules 返回的拆分行可能复制同一份
8
+ * metadata.unique_identification_number,进而造成:
9
+ * - 按 UID 删除时同时命中多行;
10
+ * - UI 把不同券行视为同一个商品;
11
+ * - 后续商品更新无法准确定位目标行。
12
+ *
13
+ * 处理原则:
14
+ * 1. 拆分后每一行必须拥有独立 UID;
15
+ * 2. 原始拆分来源仅记录在 tempOrder._extend.productsByUid 的运行态索引中,
16
+ * 不写入商品 metadata,不污染提交协议;
17
+ * 3. 券被移除后,只回并被本工具确认来自同一折扣拆分源的行;
18
+ * 4. 预约、赠品、促销、手动折扣、备注、称重、holder 和已落库行均为硬边界。
19
+ *
20
+ * 两个导出函数都会原地更新 tempOrder。调用顺序必须是:
21
+ * ensureUniqueProductLineUids -> consolidateDiscountFreeProductLines。
22
+ */
23
+ /** productsByUid 运行态记录中用于关联同一次折扣拆分的字段。 */
24
+ export declare const DISCOUNT_SPLIT_ORIGIN_UID_KEY = "discountSplitOriginUid";
25
+ /**
26
+ * 修复 Rules 折扣拆行复制 UID 的问题,并为拆分行记录共同来源。
27
+ *
28
+ * 第一条商品保留原 UID,后续重复行生成新 UUID;对应的 productsByUid.runtime
29
+ * 会复制原行 runtime(包括 origin),以保证删除、编辑及展示字段回读仍可工作。
30
+ *
31
+ * 没有 UID 的裸商品不会被补写 UID。这是为了兼容 Rules/mock 的历史协议形状;
32
+ * 正常 Order 写路径会在 normalize 阶段提前创建 UID。
33
+ */
34
+ export declare function ensureUniqueProductLineUids(tempOrder: OrderTempOrder): void;
35
+ /**
36
+ * 把券移除后已经恢复原价的同源折扣拆分行重新合并。
37
+ *
38
+ * 此函数刻意不执行通用的「同 SKU 合并」:没有 discountSplitOriginUid 的普通行
39
+ * 可能是业务 hook、导入订单或其它流程主动拆开的,不能在折扣重算时擅自合并。
40
+ *
41
+ * payment_price、tax_fee、surcharge_fee 属于 summary 计算层的派生值。券行与普通行
42
+ * 在回并前可能暂时不同,因此它们不参与 mergeKey;原始价格、SKU/option/bundle
43
+ * 结构以及税务/商品类型配置仍参与比较,防止不同商品语义被误合并。
44
+ */
45
+ export declare function consolidateDiscountFreeProductLines(tempOrder: OrderTempOrder): void;
@@ -0,0 +1,227 @@
1
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
2
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
3
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
4
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
5
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
6
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
7
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
8
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
9
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
10
+ import { cloneDeep } from 'lodash-es';
11
+ import { buildProductLineFingerprint, getSafeProductNum } from "../../../solution/ScanOrder/utils";
12
+ import { createUuidV4 } from "./orderCollectionIdentity";
13
+
14
+ /**
15
+ * 商品券拆行的身份与回并工具。
16
+ *
17
+ * 背景:
18
+ * Rules.calcDiscount 应用 good_pass 时,会把一个数量行拆成若干「用券行」和
19
+ * 「普通余量行」。Rules 返回的拆分行可能复制同一份
20
+ * metadata.unique_identification_number,进而造成:
21
+ * - 按 UID 删除时同时命中多行;
22
+ * - UI 把不同券行视为同一个商品;
23
+ * - 后续商品更新无法准确定位目标行。
24
+ *
25
+ * 处理原则:
26
+ * 1. 拆分后每一行必须拥有独立 UID;
27
+ * 2. 原始拆分来源仅记录在 tempOrder._extend.productsByUid 的运行态索引中,
28
+ * 不写入商品 metadata,不污染提交协议;
29
+ * 3. 券被移除后,只回并被本工具确认来自同一折扣拆分源的行;
30
+ * 4. 预约、赠品、促销、手动折扣、备注、称重、holder 和已落库行均为硬边界。
31
+ *
32
+ * 两个导出函数都会原地更新 tempOrder。调用顺序必须是:
33
+ * ensureUniqueProductLineUids -> consolidateDiscountFreeProductLines。
34
+ */
35
+
36
+ /** productsByUid 运行态记录中用于关联同一次折扣拆分的字段。 */
37
+ export var DISCOUNT_SPLIT_ORIGIN_UID_KEY = 'discountSplitOriginUid';
38
+
39
+ // 这里只保留本模块所需的最小读取逻辑,避免反向依赖体量较大的 Order/utils.ts
40
+ // 并形成 utils.ts -> 本文件 -> utils.ts 的循环引用。
41
+ function getProductLineUid(product) {
42
+ var _product$metadata$uni, _product$metadata;
43
+ if (!product || _typeof(product) !== 'object') return null;
44
+ var uid = (_product$metadata$uni = (_product$metadata = product.metadata) === null || _product$metadata === void 0 ? void 0 : _product$metadata.unique_identification_number) !== null && _product$metadata$uni !== void 0 ? _product$metadata$uni : product.unique_identification_number;
45
+ if (uid === undefined || uid === null || uid === '') return null;
46
+ return String(uid);
47
+ }
48
+ function getProductSkuOptions(product) {
49
+ var _product$product_sku;
50
+ return Array.isArray((_product$product_sku = product.product_sku) === null || _product$product_sku === void 0 ? void 0 : _product$product_sku.option) ? product.product_sku.option : [];
51
+ }
52
+ function hasProductLineNote(product) {
53
+ return typeof product.note === 'string' && product.note.trim().length > 0;
54
+ }
55
+ function isManualProductDiscountLine(product) {
56
+ var _product$metadata2, _product$metadata3;
57
+ return ((_product$metadata2 = product.metadata) === null || _product$metadata2 === void 0 ? void 0 : _product$metadata2.is_manual_discount) === true || ((_product$metadata3 = product.metadata) === null || _product$metadata3 === void 0 ? void 0 : _product$metadata3.is_manual_discount) === 1 || (product.discount_list || []).some(function (item) {
58
+ return (item === null || item === void 0 ? void 0 : item.type) === 'product';
59
+ });
60
+ }
61
+ function ensureProductsByUid(tempOrder) {
62
+ if (!tempOrder._extend || _typeof(tempOrder._extend) !== 'object') {
63
+ tempOrder._extend = {
64
+ productsByUid: {}
65
+ };
66
+ }
67
+ if (!tempOrder._extend.productsByUid) {
68
+ tempOrder._extend.productsByUid = {};
69
+ }
70
+ return tempOrder._extend.productsByUid;
71
+ }
72
+
73
+ /**
74
+ * 修复 Rules 折扣拆行复制 UID 的问题,并为拆分行记录共同来源。
75
+ *
76
+ * 第一条商品保留原 UID,后续重复行生成新 UUID;对应的 productsByUid.runtime
77
+ * 会复制原行 runtime(包括 origin),以保证删除、编辑及展示字段回读仍可工作。
78
+ *
79
+ * 没有 UID 的裸商品不会被补写 UID。这是为了兼容 Rules/mock 的历史协议形状;
80
+ * 正常 Order 写路径会在 normalize 阶段提前创建 UID。
81
+ */
82
+ export function ensureUniqueProductLineUids(tempOrder) {
83
+ // usedUids 只描述本次 Rules 返回的商品集合,不能直接依赖 productsByUid:
84
+ // productsByUid 可能还保留已删除行的历史 runtime,历史 UID 不应导致当前行被改号。
85
+ var usedUids = new Set();
86
+ var productsByUid = ensureProductsByUid(tempOrder);
87
+ tempOrder.products = (tempOrder.products || []).map(function (product) {
88
+ var sourceUid = getProductLineUid(product);
89
+ // 单测 mock 或兼容旧 Rules 时可能返回没有 UID 的裸商品。
90
+ // 这里不主动补 UID,避免一个“校验重复”的工具意外改变旧协议对象形状。
91
+ if (!sourceUid) return product;
92
+
93
+ // 实际场景:可乐 ×5 首次进入 Rules 时只有一行。
94
+ // 使用三张券后 Rules 可能返回「可乐 ×2 + 三条可乐 ×1」,但四条都复制原 UID。
95
+ // 第一条继续使用原 UID,可保留购物车已有引用、runtime origin 和删除定位的稳定性。
96
+ if (!usedUids.has(sourceUid)) {
97
+ usedUids.add(sourceUid);
98
+ return product;
99
+ }
100
+
101
+ // 从第二条重复 UID 开始生成真正的行级身份。
102
+ // 这样点击任意一条“可乐 ×1”时,只会删除该行,不会把所有同 UID 行一起删除。
103
+ var splitUid = createUuidV4();
104
+ while (usedUids.has(splitUid)) {
105
+ splitUid = createUuidV4();
106
+ }
107
+ product.metadata = _objectSpread(_objectSpread({}, product.metadata || {}), {}, {
108
+ unique_identification_number: splitUid
109
+ });
110
+ var sourceRuntime = productsByUid[sourceUid] || {};
111
+ // 如果当前行已经是上一轮拆分出来的子行,继续沿用最初的拆分来源。
112
+ // 例如删除一条券行后,空出的券再次把「可乐 ×2」拆成两条 ×1,
113
+ // 新行仍应归属于最初那条可乐,而不是形成一个无法回并的新分组。
114
+ var discountSplitOriginUid = String(sourceRuntime[DISCOUNT_SPLIT_ORIGIN_UID_KEY] || sourceUid);
115
+
116
+ // 来源只写入 _extend.productsByUid:
117
+ // - metadata.unique_identification_number 是对外的行身份,必须各不相同;
118
+ // - discountSplitOriginUid 是内部回并依据,不能进入提交给后端的商品 metadata。
119
+ productsByUid[sourceUid] = _objectSpread(_objectSpread({}, sourceRuntime), {}, _defineProperty({}, DISCOUNT_SPLIT_ORIGIN_UID_KEY, discountSplitOriginUid));
120
+ // 克隆 origin 等 runtime 数据,保证新拆分行仍能正确展示标题、封面等商品信息。
121
+ productsByUid[splitUid] = _objectSpread(_objectSpread({}, cloneDeep(sourceRuntime)), {}, _defineProperty({}, DISCOUNT_SPLIT_ORIGIN_UID_KEY, discountSplitOriginUid));
122
+ usedUids.add(splitUid);
123
+ return product;
124
+ });
125
+ }
126
+
127
+ /**
128
+ * 把券移除后已经恢复原价的同源折扣拆分行重新合并。
129
+ *
130
+ * 此函数刻意不执行通用的「同 SKU 合并」:没有 discountSplitOriginUid 的普通行
131
+ * 可能是业务 hook、导入订单或其它流程主动拆开的,不能在折扣重算时擅自合并。
132
+ *
133
+ * payment_price、tax_fee、surcharge_fee 属于 summary 计算层的派生值。券行与普通行
134
+ * 在回并前可能暂时不同,因此它们不参与 mergeKey;原始价格、SKU/option/bundle
135
+ * 结构以及税务/商品类型配置仍参与比较,防止不同商品语义被误合并。
136
+ */
137
+ export function consolidateDiscountFreeProductLines(tempOrder) {
138
+ // 实际目标场景:
139
+ // 选择客户后「可乐 ×5」被三张商品券拆成「×2、×1、×1、×1」;
140
+ // 清除客户/商品券后,四行都恢复为无折扣状态,应在本轮重算中立即回并为「可乐 ×5」。
141
+ var consolidatedProducts = [];
142
+ var productIndexByKey = new Map();
143
+ var _iterator = _createForOfIteratorHelper(tempOrder.products || []),
144
+ _step;
145
+ try {
146
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
147
+ var _product$booking_uid, _product$metadata4, _booking_id, _product$metadata5, _product$order_detail, _holder_id, _product$metadata6, _product$metadata7, _product$metadata8, _product$product_sku2, _product$metadata9, _tempOrder$_extend, _product$selling_pric, _product$original_pri, _custom_price, _product$is_charge_ta, _product$gift_card, _product$bundle_edit, _product$metadata$pri, _product$metadata10, _product$metadata$sou, _product$metadata11, _product$metadata$mai, _product$metadata12, _product$metadata$mai2, _product$metadata13, _product$product_vari;
148
+ var product = _step.value;
149
+ var productBundle = Array.isArray(product.product_bundle) ? product.product_bundle : [];
150
+ var hasDiscount = (product.discount_list || []).length > 0 || productBundle.some(function (bundle) {
151
+ return ((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []).length > 0;
152
+ });
153
+ var bookingUid = (_product$booking_uid = product.booking_uid) !== null && _product$booking_uid !== void 0 ? _product$booking_uid : (_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4.booking_uid;
154
+ var bookingId = (_booking_id = product.booking_id) !== null && _booking_id !== void 0 ? _booking_id : (_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.booking_id;
155
+ var orderDetailId = (_product$order_detail = product.order_detail_id) !== null && _product$order_detail !== void 0 ? _product$order_detail : product.orderDetailId;
156
+ var holderId = (_holder_id = product.holder_id) !== null && _holder_id !== void 0 ? _holder_id : (_product$metadata6 = product.metadata) === null || _product$metadata6 === void 0 ? void 0 : _product$metadata6.holder_id;
157
+
158
+ // 以下情况即使“看起来是同一个 SKU”也必须保持独立:
159
+ // - 仍有商品券/折扣:每条券行分别承担券归属和 savedAmount;
160
+ // - 赠品/促销:独立行承载策略来源,合并会破坏促销撤销和展示;
161
+ // - 手动改价/备注:用户显式表达了不同价格或不同制作要求;
162
+ // - 称重商品:每次称重的净重和金额属于独立交易事实;
163
+ // - 预约/holder/历史订单行:分别关联预约、持有人或后端 order_detail。
164
+ var hasMergeBoundary = hasDiscount || Boolean(((_product$metadata7 = product.metadata) === null || _product$metadata7 === void 0 ? void 0 : _product$metadata7._giftInfo) || product._giftInfo) || Boolean((_product$metadata8 = product.metadata) === null || _product$metadata8 === void 0 ? void 0 : _product$metadata8._promotion) || isManualProductDiscountLine(product) || hasProductLineNote(product) || Number(((_product$product_sku2 = product.product_sku) === null || _product$product_sku2 === void 0 ? void 0 : _product$product_sku2.open_sold_weight) || 0) === 1 || ((_product$metadata9 = product.metadata) === null || _product$metadata9 === void 0 ? void 0 : _product$metadata9.is_edit_for_runtime) === true || bookingId !== undefined && bookingId !== null && bookingId !== 0 && bookingId !== '0' || bookingUid !== undefined && bookingUid !== null && String(bookingUid) !== '' || holderId !== undefined && holderId !== null && String(holderId) !== '' || orderDetailId !== undefined && orderDetailId !== null && orderDetailId !== '';
165
+ if (hasMergeBoundary) {
166
+ consolidatedProducts.push(product);
167
+ continue;
168
+ }
169
+ var productUid = getProductLineUid(product);
170
+ var discountSplitOriginUid = productUid ? (_tempOrder$_extend = tempOrder._extend) === null || _tempOrder$_extend === void 0 || (_tempOrder$_extend = _tempOrder$_extend.productsByUid) === null || _tempOrder$_extend === void 0 || (_tempOrder$_extend = _tempOrder$_extend[productUid]) === null || _tempOrder$_extend === void 0 ? void 0 : _tempOrder$_extend[DISCOUNT_SPLIT_ORIGIN_UID_KEY] : undefined;
171
+
172
+ // 没有同源标记的两条可乐,可能是 onBeforeMergeProductToOrder 返回 false 后
173
+ // 由业务主动保留的独立行,也可能来自导入订单;不能仅凭 SKU 相同就擅自合并。
174
+ if (!discountSplitOriginUid) {
175
+ consolidatedProducts.push(product);
176
+ continue;
177
+ }
178
+
179
+ // 同属一次券拆分仍不代表一定可以合并。
180
+ // 例如两行后来选择了不同 option、套餐子商品或自定义价格,需要继续保持独立。
181
+ var fingerprint = buildProductLineFingerprint(getProductSkuOptions(product), productBundle);
182
+ var priceSignature = JSON.stringify({
183
+ selling_price: String((_product$selling_pric = product.selling_price) !== null && _product$selling_pric !== void 0 ? _product$selling_pric : ''),
184
+ original_price: String((_product$original_pri = product.original_price) !== null && _product$original_pri !== void 0 ? _product$original_pri : ''),
185
+ custom_price: String((_custom_price = product.custom_price) !== null && _custom_price !== void 0 ? _custom_price : ''),
186
+ is_charge_tax: Number((_product$is_charge_ta = product.is_charge_tax) !== null && _product$is_charge_ta !== void 0 ? _product$is_charge_ta : 0),
187
+ gift_card: Number((_product$gift_card = product.gift_card) !== null && _product$gift_card !== void 0 ? _product$gift_card : 0),
188
+ bundle_edit: Number((_product$bundle_edit = product.bundle_edit) !== null && _product$bundle_edit !== void 0 ? _product$bundle_edit : 0),
189
+ price_schema_version: (_product$metadata$pri = (_product$metadata10 = product.metadata) === null || _product$metadata10 === void 0 ? void 0 : _product$metadata10.price_schema_version) !== null && _product$metadata$pri !== void 0 ? _product$metadata$pri : '',
190
+ source_product_price: String((_product$metadata$sou = (_product$metadata11 = product.metadata) === null || _product$metadata11 === void 0 ? void 0 : _product$metadata11.source_product_price) !== null && _product$metadata$sou !== void 0 ? _product$metadata$sou : ''),
191
+ main_product_selling_price: String((_product$metadata$mai = (_product$metadata12 = product.metadata) === null || _product$metadata12 === void 0 ? void 0 : _product$metadata12.main_product_selling_price) !== null && _product$metadata$mai !== void 0 ? _product$metadata$mai : ''),
192
+ main_product_original_price: String((_product$metadata$mai2 = (_product$metadata13 = product.metadata) === null || _product$metadata13 === void 0 ? void 0 : _product$metadata13.main_product_original_price) !== null && _product$metadata$mai2 !== void 0 ? _product$metadata$mai2 : ''),
193
+ bundle: productBundle.map(function (bundle) {
194
+ var _ref, _bundle$bundle_id, _ref2, _ref3, _bundle$bundle_produc, _ref4, _ref5, _bundle$bundle_varian, _bundle$price, _bundle$original_pric, _bundle$bundle_sellin;
195
+ return {
196
+ bundle_id: (_ref = (_bundle$bundle_id = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_id) !== null && _bundle$bundle_id !== void 0 ? _bundle$bundle_id : bundle === null || bundle === void 0 ? void 0 : bundle.id) !== null && _ref !== void 0 ? _ref : '',
197
+ product_id: (_ref2 = (_ref3 = (_bundle$bundle_produc = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc !== void 0 ? _bundle$bundle_produc : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref3 !== void 0 ? _ref3 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id) !== null && _ref2 !== void 0 ? _ref2 : '',
198
+ product_variant_id: (_ref4 = (_ref5 = (_bundle$bundle_varian = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_variant_id) !== null && _bundle$bundle_varian !== void 0 ? _bundle$bundle_varian : bundle === null || bundle === void 0 ? void 0 : bundle.variant_id) !== null && _ref5 !== void 0 ? _ref5 : bundle === null || bundle === void 0 ? void 0 : bundle.product_variant_id) !== null && _ref4 !== void 0 ? _ref4 : 0,
199
+ price: String((_bundle$price = bundle === null || bundle === void 0 ? void 0 : bundle.price) !== null && _bundle$price !== void 0 ? _bundle$price : ''),
200
+ original_price: String((_bundle$original_pric = bundle === null || bundle === void 0 ? void 0 : bundle.original_price) !== null && _bundle$original_pric !== void 0 ? _bundle$original_pric : ''),
201
+ bundle_selling_price: String((_bundle$bundle_sellin = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_selling_price) !== null && _bundle$bundle_sellin !== void 0 ? _bundle$bundle_sellin : '')
202
+ };
203
+ })
204
+ });
205
+ var mergeKey = [discountSplitOriginUid, product.product_id, (_product$product_vari = product.product_variant_id) !== null && _product$product_vari !== void 0 ? _product$product_vari : 0, fingerprint, priceSignature].join('#');
206
+ var matchedIndex = productIndexByKey.get(mergeKey);
207
+
208
+ // 当前拆分来源 + 商品结构组合第一次出现时,保留该行作为回并目标。
209
+ // 后续相同行只累加数量,从而稳定保留首行 UID,避免 UI key 再次变化。
210
+ if (matchedIndex === undefined) {
211
+ productIndexByKey.set(mergeKey, consolidatedProducts.length);
212
+ consolidatedProducts.push(product);
213
+ continue;
214
+ }
215
+ var matchedProduct = consolidatedProducts[matchedIndex];
216
+ matchedProduct.num = getSafeProductNum(Number(matchedProduct.num || 0) + Number(product.num || 0));
217
+ // 示例:目标行 ×2,依次吸收三条 ×1,最终得到 ×5。
218
+ // 被吸收行的 productsByUid runtime 暂不删除:异步 UI/日志可能仍持有旧 UID,
219
+ // 保留历史索引比立即清理更安全;当前购物车身份始终以 tempOrder.products 为准。
220
+ }
221
+ } catch (err) {
222
+ _iterator.e(err);
223
+ } finally {
224
+ _iterator.f();
225
+ }
226
+ tempOrder.products = consolidatedProducts;
227
+ }
@@ -24,6 +24,16 @@ export interface NormalizeOrderCollectionsResult<T> {
24
24
  stats: Record<OrderCollectionKind, OrderCollectionIdentityStats>;
25
25
  uidRemaps: OrderCollectionUidRemap[];
26
26
  }
27
+ export interface ProductLineIdentityRepair {
28
+ index: number;
29
+ from: string;
30
+ to: string;
31
+ }
32
+ export interface RepairDuplicateProductLineIdentitiesResult<T> {
33
+ products: T[];
34
+ productsByUid?: Record<string, Record<string, any>>;
35
+ repairs: ProductLineIdentityRepair[];
36
+ }
27
37
  export declare function createUuidV4(): string;
28
38
  export declare function isBlankOrderCollectionIdentity(value: unknown): boolean;
29
39
  export declare function getOrderCollectionPersistentId(kind: OrderCollectionKind, item: unknown): string | null;
@@ -31,6 +41,11 @@ export declare function getOrderCollectionUid(kind: OrderCollectionKind, item: u
31
41
  export declare function buildOrderCollectionFallbackUid(kind: OrderCollectionKind, persistentId: string | number): string;
32
42
  export declare function getOrderCollectionReferenceUid(kind: OrderCollectionKind, item: unknown): string | null;
33
43
  export declare function setOrderCollectionUid<T>(kind: OrderCollectionKind, item: T, uid: string): T;
44
+ /**
45
+ * Rules 会把同一商品按商品券拆成多条真实订单行。拆行结果会继承原商品 UID,
46
+ * 因此必须在通用 collection normalization 之前为后续行派生稳定身份,避免被折叠。
47
+ */
48
+ export declare function repairDuplicateProductLineIdentities<T extends Record<string, any>>(products: T[] | null | undefined, productsByUid?: Record<string, Record<string, any>> | null): RepairDuplicateProductLineIdentitiesResult<T>;
34
49
  /**
35
50
  * 持久化行 ID 是服务端事实主键;只有至少一侧尚未持久化时,才允许用 runtime UID 对齐。
36
51
  */
@@ -74,6 +74,81 @@ export function setOrderCollectionUid(kind, item, uid) {
74
74
  delete record[uidField];
75
75
  return record;
76
76
  }
77
+ function getGoodPassResourceId(product) {
78
+ var _ref, _ref2, _goodPass$discount$re, _goodPass$discount;
79
+ var goodPass = (product.discount_list || []).find(function (item) {
80
+ var _item$discount, _item$discount2;
81
+ var type = (item === null || item === void 0 ? void 0 : item.type) || (item === null || item === void 0 ? void 0 : item.tag) || (item === null || item === void 0 || (_item$discount = item.discount) === null || _item$discount === void 0 ? void 0 : _item$discount.type) || (item === null || item === void 0 || (_item$discount2 = item.discount) === null || _item$discount2 === void 0 ? void 0 : _item$discount2.tag);
82
+ return type === 'good_pass';
83
+ });
84
+ if (!goodPass) return null;
85
+ var resourceId = (_ref = (_ref2 = (_goodPass$discount$re = (_goodPass$discount = goodPass.discount) === null || _goodPass$discount === void 0 ? void 0 : _goodPass$discount.resource_id) !== null && _goodPass$discount$re !== void 0 ? _goodPass$discount$re : goodPass.resource_id) !== null && _ref2 !== void 0 ? _ref2 : goodPass.discount_id) !== null && _ref !== void 0 ? _ref : goodPass.id;
86
+ return isBlankOrderCollectionIdentity(resourceId) ? null : String(resourceId);
87
+ }
88
+ function buildSplitProductUid(originalUid, product, duplicateOrdinal) {
89
+ var encodedOriginalUid = encodeURIComponent(originalUid);
90
+ var resourceId = getGoodPassResourceId(product);
91
+ if (resourceId) {
92
+ return "os-split:product:".concat(encodedOriginalUid, ":good-pass:").concat(encodeURIComponent(resourceId), ":").concat(duplicateOrdinal);
93
+ }
94
+ return "os-split:product:".concat(encodedOriginalUid, ":duplicate:").concat(duplicateOrdinal);
95
+ }
96
+
97
+ /**
98
+ * Rules 会把同一商品按商品券拆成多条真实订单行。拆行结果会继承原商品 UID,
99
+ * 因此必须在通用 collection normalization 之前为后续行派生稳定身份,避免被折叠。
100
+ */
101
+ export function repairDuplicateProductLineIdentities(products, productsByUid) {
102
+ var repairedProducts = cloneDeep(products || []);
103
+ var repairedProductsByUid = productsByUid ? cloneDeep(productsByUid) : undefined;
104
+ var occupiedUids = new Set(repairedProducts.map(function (product) {
105
+ return getOrderCollectionUid('product', product);
106
+ }).filter(function (uid) {
107
+ return Boolean(uid);
108
+ }));
109
+ Object.keys(repairedProductsByUid || {}).forEach(function (uid) {
110
+ return occupiedUids.add(uid);
111
+ });
112
+ var occurrences = new Map();
113
+ var repairs = [];
114
+ repairedProducts.forEach(function (product, index) {
115
+ var originalUid = getOrderCollectionUid('product', product);
116
+ if (!originalUid) return;
117
+ var occurrence = (occurrences.get(originalUid) || 0) + 1;
118
+ occurrences.set(originalUid, occurrence);
119
+ if (occurrence === 1) return;
120
+ var duplicateOrdinal = occurrence - 1;
121
+ var baseCandidate = buildSplitProductUid(originalUid, product, duplicateOrdinal);
122
+ var nextUid = baseCandidate;
123
+ var conflictOrdinal = 1;
124
+ while (occupiedUids.has(nextUid)) {
125
+ nextUid = "".concat(baseCandidate, ":conflict:").concat(conflictOrdinal);
126
+ conflictOrdinal += 1;
127
+ }
128
+ var repairedProduct = setOrderCollectionUid('product', product, nextUid);
129
+ repairedProduct.identity_key = nextUid;
130
+ repairedProducts[index] = repairedProduct;
131
+ occupiedUids.add(nextUid);
132
+ repairs.push({
133
+ index: index,
134
+ from: originalUid,
135
+ to: nextUid
136
+ });
137
+ var runtimeSource = repairedProductsByUid === null || repairedProductsByUid === void 0 ? void 0 : repairedProductsByUid[originalUid];
138
+ if (runtimeSource && repairedProductsByUid) {
139
+ repairedProductsByUid[nextUid] = _objectSpread(_objectSpread({}, cloneDeep(runtimeSource)), runtimeSource.rowKey !== undefined ? {
140
+ rowKey: nextUid
141
+ } : {});
142
+ }
143
+ });
144
+ return _objectSpread(_objectSpread({
145
+ products: repairedProducts
146
+ }, repairedProductsByUid ? {
147
+ productsByUid: repairedProductsByUid
148
+ } : {}), {}, {
149
+ repairs: repairs
150
+ });
151
+ }
77
152
 
78
153
  /**
79
154
  * 持久化行 ID 是服务端事实主键;只有至少一侧尚未持久化时,才允许用 runtime UID 对齐。
@@ -15,6 +15,7 @@ export interface OrderProductsDepositSummary {
15
15
  deposit_policy_ids: number[];
16
16
  hasDeposit: boolean;
17
17
  }
18
+ import type { WindowPlugin } from '../../plugins';
18
19
  /**
19
20
  * 把"含 option 的主商品单价"与 bundle 合成"单行 composite 单价"。
20
21
  *
@@ -177,6 +178,15 @@ export declare const mergeRelationForms: (relationForms: {
177
178
  form_id: number;
178
179
  form_record_ids: number[];
179
180
  }[];
181
+ export interface CartOrderHolder {
182
+ customer_id?: number;
183
+ form_id: number | string;
184
+ form_record: (number | string)[] | null;
185
+ }
186
+ /**
187
+ * 为购物车行补齐订单所需的 holder 信息(与 cartAccount 结构保持一致)
188
+ */
189
+ export declare function ensureCartItemOriginHolder(cartItem: CartItem, window?: WindowPlugin): void;
180
190
  export declare const getAllDiscountList: (cartItem: CartItem) => any;
181
191
  export { createUuidV4 };
182
192
  export declare function isTempOrder(data: any): data is OrderTempOrder;