@pisell/pisellos 2.2.260 → 2.2.262

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 (107) hide show
  1. package/dist/model/strategy/adapter/dataVariant/adapter.d.ts +1 -0
  2. package/dist/model/strategy/adapter/dataVariant/adapter.js +15 -0
  3. package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +2 -0
  4. package/dist/model/strategy/adapter/dataVariant/evaluator.js +25 -0
  5. package/dist/model/strategy/adapter/dataVariant/examples.js +1 -6
  6. package/dist/model/strategy/adapter/dataVariant/type.d.ts +2 -0
  7. package/dist/model/strategy/adapter/promotion/index.js +0 -9
  8. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +23 -13
  9. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +2 -1
  10. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +1 -1
  11. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +32 -1
  12. package/dist/modules/Discount/index.d.ts +5 -2
  13. package/dist/modules/Discount/index.js +30 -7
  14. package/dist/modules/Discount/types.d.ts +4 -0
  15. package/dist/modules/Order/index.d.ts +45 -2
  16. package/dist/modules/Order/index.js +1552 -926
  17. package/dist/modules/Order/types.d.ts +36 -2
  18. package/dist/modules/Order/utils/bundleDiscountHydration.d.ts +5 -0
  19. package/dist/modules/Order/utils/bundleDiscountHydration.js +144 -0
  20. package/dist/modules/Order/utils/orderCollectionIdentity.d.ts +53 -0
  21. package/dist/modules/Order/utils/orderCollectionIdentity.js +405 -0
  22. package/dist/modules/Order/utils.d.ts +8 -3
  23. package/dist/modules/Order/utils.js +136 -56
  24. package/dist/modules/Rules/index.d.ts +4 -10
  25. package/dist/modules/Rules/index.js +63 -12
  26. package/dist/modules/Rules/types.d.ts +12 -2
  27. package/dist/modules/SalesSummary/index.d.ts +7 -3
  28. package/dist/modules/SalesSummary/index.js +67 -39
  29. package/dist/modules/SalesSummary/types.d.ts +1 -0
  30. package/dist/modules/SalesSummary/utils.js +2 -1
  31. package/dist/modules/SurchargeList/index.d.ts +6 -4
  32. package/dist/modules/SurchargeList/index.js +62 -39
  33. package/dist/modules/SurchargeList/types.d.ts +6 -2
  34. package/dist/server/index.d.ts +8 -0
  35. package/dist/server/index.js +1365 -911
  36. package/dist/server/modules/order/index.d.ts +32 -7
  37. package/dist/server/modules/order/index.js +551 -464
  38. package/dist/server/modules/order/types.d.ts +4 -0
  39. package/dist/server/modules/products/index.d.ts +5 -1
  40. package/dist/server/modules/products/index.js +384 -315
  41. package/dist/server/modules/products/types.d.ts +4 -0
  42. package/dist/solution/BaseSales/index.d.ts +42 -2
  43. package/dist/solution/BaseSales/index.js +1416 -775
  44. package/dist/solution/BaseSales/types.d.ts +7 -1
  45. package/dist/solution/BaseSales/types.js +3 -2
  46. package/dist/solution/BaseSales/utils/cartPromotion.js +19 -7
  47. package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +3 -3
  48. package/dist/solution/BaseSales/utils/parseSalesResponse.js +6 -8
  49. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +20 -4
  50. package/dist/solution/BookingByStep/index.d.ts +1 -1
  51. package/dist/solution/BookingTicket/index.d.ts +8 -0
  52. package/dist/solution/BookingTicket/index.js +212 -31
  53. package/dist/solution/ShopDiscount/index.js +15 -14
  54. package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +1 -0
  55. package/lib/model/strategy/adapter/dataVariant/adapter.js +10 -0
  56. package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +2 -0
  57. package/lib/model/strategy/adapter/dataVariant/evaluator.js +20 -1
  58. package/lib/model/strategy/adapter/dataVariant/examples.js +0 -2
  59. package/lib/model/strategy/adapter/dataVariant/type.d.ts +2 -0
  60. package/lib/model/strategy/adapter/promotion/index.js +0 -49
  61. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +16 -1
  62. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +1 -0
  63. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +1 -1
  64. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +23 -2
  65. package/lib/modules/Discount/index.d.ts +5 -2
  66. package/lib/modules/Discount/index.js +23 -3
  67. package/lib/modules/Discount/types.d.ts +4 -0
  68. package/lib/modules/Order/index.d.ts +45 -2
  69. package/lib/modules/Order/index.js +720 -116
  70. package/lib/modules/Order/types.d.ts +36 -2
  71. package/lib/modules/Order/utils/bundleDiscountHydration.d.ts +5 -0
  72. package/lib/modules/Order/utils/bundleDiscountHydration.js +139 -0
  73. package/lib/modules/Order/utils/orderCollectionIdentity.d.ts +53 -0
  74. package/lib/modules/Order/utils/orderCollectionIdentity.js +415 -0
  75. package/lib/modules/Order/utils.d.ts +8 -3
  76. package/lib/modules/Order/utils.js +104 -18
  77. package/lib/modules/Rules/index.d.ts +4 -10
  78. package/lib/modules/Rules/index.js +61 -9
  79. package/lib/modules/Rules/types.d.ts +12 -2
  80. package/lib/modules/SalesSummary/index.d.ts +7 -3
  81. package/lib/modules/SalesSummary/index.js +28 -11
  82. package/lib/modules/SalesSummary/types.d.ts +1 -0
  83. package/lib/modules/SalesSummary/utils.js +2 -0
  84. package/lib/modules/SurchargeList/index.d.ts +6 -4
  85. package/lib/modules/SurchargeList/index.js +41 -21
  86. package/lib/modules/SurchargeList/types.d.ts +6 -2
  87. package/lib/server/index.d.ts +8 -0
  88. package/lib/server/index.js +336 -11
  89. package/lib/server/modules/order/index.d.ts +32 -7
  90. package/lib/server/modules/order/index.js +298 -189
  91. package/lib/server/modules/order/types.d.ts +4 -0
  92. package/lib/server/modules/products/index.d.ts +5 -1
  93. package/lib/server/modules/products/index.js +21 -0
  94. package/lib/server/modules/products/types.d.ts +4 -0
  95. package/lib/solution/BaseSales/index.d.ts +42 -2
  96. package/lib/solution/BaseSales/index.js +535 -108
  97. package/lib/solution/BaseSales/types.d.ts +7 -1
  98. package/lib/solution/BaseSales/types.js +2 -1
  99. package/lib/solution/BaseSales/utils/cartPromotion.js +13 -1
  100. package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +3 -3
  101. package/lib/solution/BaseSales/utils/parseSalesResponse.js +4 -5
  102. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +14 -6
  103. package/lib/solution/BookingByStep/index.d.ts +1 -1
  104. package/lib/solution/BookingTicket/index.d.ts +8 -0
  105. package/lib/solution/BookingTicket/index.js +134 -8
  106. package/lib/solution/ShopDiscount/index.js +2 -1
  107. package/package.json +1 -1
@@ -198,6 +198,7 @@ export interface OrderProduct extends OrderProductIdentity {
198
198
  product_bundle: any[];
199
199
  booking_uid?: string;
200
200
  product_title?: OrderLocalizedText;
201
+ product_cover?: string;
201
202
  metadata: Record<string, any>;
202
203
  note?: string;
203
204
  }
@@ -308,6 +309,7 @@ export interface OrderState {
308
309
  lastOrderInfo?: Record<string, any>;
309
310
  syncState?: OrderSyncState;
310
311
  discountList: any[];
312
+ availableWalletIds?: number[];
311
313
  discount: DiscountModule | null;
312
314
  rules: RulesModule | null;
313
315
  }
@@ -340,6 +342,19 @@ export interface UpdateOrderProductParams {
340
342
  * });
341
343
  */
342
344
  allow_booking_reprice?: boolean;
345
+ /**
346
+ * Change time 重报价后,允许当前预约商品行重新应用已选编辑态折扣卡。
347
+ *
348
+ * @example
349
+ * await order.updateOrderProduct({
350
+ * product_id: 1,
351
+ * product_variant_id: 0,
352
+ * updates: { discount_list: [] },
353
+ * booking: { duration: 2 },
354
+ * allow_booking_discount_reapply: true,
355
+ * });
356
+ */
357
+ allow_booking_discount_reapply?: boolean;
343
358
  }
344
359
  /** 仅更新购物车行数量;行定位语义与 updateOrderProduct / removeProductFromOrder 保持一致 */
345
360
  export interface UpdateOrderProductQuantityParams extends OrderProductIdentity {
@@ -491,7 +506,7 @@ export interface OrderPaymentData {
491
506
  voucher_id?: string | number;
492
507
  origin_amount?: string;
493
508
  service_fee?: string;
494
- status?: 'active' | 'voided' | string;
509
+ status?: 'active' | 'paid' | 'voided' | 'payment_pending' | string;
495
510
  /** 支付时间 (格式: YYYY-MM-DD HH:mm:ss) */
496
511
  payment_time?: string;
497
512
  wallet_pass_usage_unit?: unknown;
@@ -537,9 +552,15 @@ export interface SyncPaymentsToOrderParams {
537
552
  smallTicketDataFlag?: number;
538
553
  businessCode?: string;
539
554
  channel?: string;
555
+ confirmPendingVoucherPayments?: boolean;
540
556
  }
541
557
  export interface SyncPaymentsToOrderResult<T = any> {
542
558
  isFullyPaid: boolean;
559
+ isOrderFullyPaid: boolean;
560
+ isDepositFullyPaid: boolean;
561
+ paymentStage: 'deposit' | 'normal';
562
+ depositAmount: string;
563
+ orderExpectedAmount: string;
543
564
  submitResult?: T;
544
565
  }
545
566
  export interface OrderIdentitySnapshot {
@@ -691,6 +712,7 @@ export interface OrderModuleAPI {
691
712
  payments?: OrderPaymentSource[];
692
713
  paymentStatus?: SubmitSalesOrderParams['query']['payment_status'];
693
714
  smallTicketDataFlag?: number;
715
+ confirmPendingVoucherPayments?: boolean;
694
716
  enhancePayload?: SubmitPayloadEnhancer;
695
717
  }) => Promise<T>;
696
718
  submitTempOrderAsync: <T = any>(params?: {
@@ -702,6 +724,7 @@ export interface OrderModuleAPI {
702
724
  payments?: OrderPaymentSource[];
703
725
  paymentStatus?: SubmitSalesOrderParams['query']['payment_status'];
704
726
  smallTicketDataFlag?: number;
727
+ confirmPendingVoucherPayments?: boolean;
705
728
  enhancePayload?: SubmitPayloadEnhancer;
706
729
  }) => Promise<T>;
707
730
  getOrderPayments: () => OrderPaymentData[];
@@ -709,7 +732,17 @@ export interface OrderModuleAPI {
709
732
  addOrderPayment: (payment: OrderPaymentSource) => OrderPaymentData[];
710
733
  updateOrderPayment: (paymentIdentity: string | number, updates: Partial<OrderPaymentData> & Record<string, any>) => OrderPaymentData[];
711
734
  deleteOrderPayment: (paymentIdentity: string | number) => OrderPaymentData[];
712
- updateVoucherOrderPayments: (payments: OrderPaymentSource[]) => OrderPaymentData[];
735
+ updateVoucherOrderPayments: (payments: OrderPaymentSource[], options?: {
736
+ status?: 'paid' | 'payment_pending';
737
+ }) => OrderPaymentData[];
738
+ confirmPendingVoucherPayments: (options?: {
739
+ persist?: boolean;
740
+ recalculateSummary?: boolean;
741
+ }) => OrderPaymentData[];
742
+ discardPendingVoucherPayments: (options?: {
743
+ persist?: boolean;
744
+ recalculateSummary?: boolean;
745
+ }) => OrderPaymentData[];
713
746
  sendCustomerPayLink: <T = any>(params: SendCustomerPayLinkParams) => Promise<T>;
714
747
  saveDraft: () => Promise<void>;
715
748
  hydrateTempOrderFromRecord: (record: Record<string, any>, options?: {
@@ -743,6 +776,7 @@ export interface OrderModuleAPI {
743
776
  apply?: boolean;
744
777
  }) => Promise<Discount[]>;
745
778
  getDiscountList: () => Discount[];
779
+ getAvailableWalletIds: () => number[];
746
780
  applyDiscount: () => void;
747
781
  /**
748
782
  * 注入促销评估器。
@@ -0,0 +1,5 @@
1
+ import type { OrderProductDiscountItem } from '../types';
2
+ type NormalizeDiscountList = (discountList?: unknown[] | null) => OrderProductDiscountItem[];
3
+ export declare function restoreHydratedBundleDiscounts<T extends Record<string, any>>(product: T, normalizeDiscountList: NormalizeDiscountList): T;
4
+ export declare function expandHydratedProductsForDiscountCollection(products: any[] | undefined | null): any[];
5
+ export {};
@@ -0,0 +1,144 @@
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 _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
3
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
+ 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); }
5
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
6
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
7
+ 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; }
8
+ 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; }
9
+ 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; }
10
+ 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; }
11
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
12
+ 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); }
13
+ 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); }
14
+ var BUNDLE_MAP_ID_KEY = 'custom_product_bundle_map_id';
15
+ function getBundleMapId(bundle) {
16
+ var _bundle$metadata;
17
+ var metadataMapId = bundle === null || bundle === void 0 || (_bundle$metadata = bundle.metadata) === null || _bundle$metadata === void 0 ? void 0 : _bundle$metadata[BUNDLE_MAP_ID_KEY];
18
+ if (metadataMapId !== undefined && metadataMapId !== null && metadataMapId !== '') {
19
+ return String(metadataMapId);
20
+ }
21
+ if ((bundle === null || bundle === void 0 ? void 0 : bundle._id) !== undefined && bundle._id !== null && bundle._id !== '') {
22
+ return String(bundle._id);
23
+ }
24
+ return null;
25
+ }
26
+ function getDiscountBundleMapId(discount) {
27
+ var _discount$metadata;
28
+ var mapId = discount === null || discount === void 0 || (_discount$metadata = discount.metadata) === null || _discount$metadata === void 0 ? void 0 : _discount$metadata[BUNDLE_MAP_ID_KEY];
29
+ if (mapId === undefined || mapId === null || mapId === '') return null;
30
+ return String(mapId);
31
+ }
32
+ function hasSameBundleDiscount(discountList, discount) {
33
+ var _ref, _discount$discount$re, _discount$discount;
34
+ var targetOrderDiscountId = discount.order_discount_id;
35
+ if (targetOrderDiscountId !== undefined && targetOrderDiscountId !== null) {
36
+ return discountList.some(function (item) {
37
+ return (item === null || item === void 0 ? void 0 : item.order_discount_id) === targetOrderDiscountId;
38
+ });
39
+ }
40
+ var targetResourceId = (_ref = (_discount$discount$re = discount === null || discount === void 0 || (_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.resource_id) !== null && _discount$discount$re !== void 0 ? _discount$discount$re : discount === null || discount === void 0 ? void 0 : discount.resource_id) !== null && _ref !== void 0 ? _ref : discount === null || discount === void 0 ? void 0 : discount.discount_id;
41
+ var targetMapId = getDiscountBundleMapId(discount);
42
+ return discountList.some(function (item) {
43
+ var _ref2, _item$discount$resour, _item$discount, _item$amount, _discount$amount;
44
+ var resourceId = (_ref2 = (_item$discount$resour = item === null || item === void 0 || (_item$discount = item.discount) === null || _item$discount === void 0 ? void 0 : _item$discount.resource_id) !== null && _item$discount$resour !== void 0 ? _item$discount$resour : item === null || item === void 0 ? void 0 : item.resource_id) !== null && _ref2 !== void 0 ? _ref2 : item === null || item === void 0 ? void 0 : item.discount_id;
45
+ return resourceId === targetResourceId && String((_item$amount = item === null || item === void 0 ? void 0 : item.amount) !== null && _item$amount !== void 0 ? _item$amount : '') === String((_discount$amount = discount === null || discount === void 0 ? void 0 : discount.amount) !== null && _discount$amount !== void 0 ? _discount$amount : '') && getDiscountBundleMapId(item) === targetMapId;
46
+ });
47
+ }
48
+ export function restoreHydratedBundleDiscounts(product, normalizeDiscountList) {
49
+ if (!Array.isArray(product.product_bundle) || !Array.isArray(product.discount_list)) {
50
+ return product;
51
+ }
52
+ var bundleByMapId = new Map();
53
+ product.product_bundle.forEach(function (bundle) {
54
+ if (!bundle || _typeof(bundle) !== 'object') return;
55
+ var mapId = getBundleMapId(bundle);
56
+ if (mapId) bundleByMapId.set(mapId, bundle);
57
+ });
58
+ if (!bundleByMapId.size) return product;
59
+ var mainDiscountList = [];
60
+ var bundleDiscounts = [];
61
+ product.discount_list.forEach(function (discount) {
62
+ var mapId = getDiscountBundleMapId(discount);
63
+ if (mapId && bundleByMapId.has(mapId)) {
64
+ bundleDiscounts.push({
65
+ mapId: mapId,
66
+ discount: discount
67
+ });
68
+ } else {
69
+ mainDiscountList.push(discount);
70
+ }
71
+ });
72
+ if (!bundleDiscounts.length) return product;
73
+ return _objectSpread(_objectSpread({}, product), {}, {
74
+ discount_list: normalizeDiscountList(mainDiscountList),
75
+ product_bundle: product.product_bundle.map(function (bundle) {
76
+ if (!bundle || _typeof(bundle) !== 'object') return bundle;
77
+ var mapId = getBundleMapId(bundle);
78
+ if (!mapId) return bundle;
79
+ var matchedDiscounts = bundleDiscounts.filter(function (item) {
80
+ return item.mapId === mapId;
81
+ }).map(function (item) {
82
+ return item.discount;
83
+ });
84
+ if (!matchedDiscounts.length) return bundle;
85
+ var currentDiscountList = Array.isArray(bundle.discount_list) ? _toConsumableArray(bundle.discount_list) : [];
86
+ var _iterator = _createForOfIteratorHelper(matchedDiscounts),
87
+ _step;
88
+ try {
89
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
90
+ var discount = _step.value;
91
+ if (!hasSameBundleDiscount(currentDiscountList, discount)) {
92
+ currentDiscountList.push(discount);
93
+ }
94
+ }
95
+ } catch (err) {
96
+ _iterator.e(err);
97
+ } finally {
98
+ _iterator.f();
99
+ }
100
+ return _objectSpread(_objectSpread({}, bundle), {}, {
101
+ discount_list: normalizeDiscountList(currentDiscountList),
102
+ metadata: _objectSpread(_objectSpread({}, bundle.metadata || {}), {}, _defineProperty({}, BUNDLE_MAP_ID_KEY, mapId))
103
+ });
104
+ })
105
+ });
106
+ }
107
+ export function expandHydratedProductsForDiscountCollection(products) {
108
+ var expanded = [];
109
+ var _iterator2 = _createForOfIteratorHelper(products || []),
110
+ _step2;
111
+ try {
112
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
113
+ var product = _step2.value;
114
+ expanded.push(product);
115
+ var _iterator3 = _createForOfIteratorHelper((product === null || product === void 0 ? void 0 : product.product_bundle) || []),
116
+ _step3;
117
+ try {
118
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
119
+ var _ref3, _ref4, _bundle$bundle_produc, _ref5, _bundle$num, _ref6, _bundle$quantity, _ref7, _bundle$original_pric, _bundle$bundle_sellin, _bundle$is_charge_tax;
120
+ var bundle = _step3.value;
121
+ if (!Array.isArray(bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || bundle.discount_list.length === 0) continue;
122
+ expanded.push(_objectSpread(_objectSpread({}, product), {}, {
123
+ product_id: (_ref3 = (_ref4 = (_bundle$bundle_produc = bundle.bundle_product_id) !== null && _bundle$bundle_produc !== void 0 ? _bundle$bundle_produc : bundle._bundle_product_id) !== null && _ref4 !== void 0 ? _ref4 : bundle.product_id) !== null && _ref3 !== void 0 ? _ref3 : product === null || product === void 0 ? void 0 : product.product_id,
124
+ num: (_ref5 = (_bundle$num = bundle.num) !== null && _bundle$num !== void 0 ? _bundle$num : bundle.quantity) !== null && _ref5 !== void 0 ? _ref5 : product === null || product === void 0 ? void 0 : product.num,
125
+ product_quantity: (_ref6 = (_bundle$quantity = bundle.quantity) !== null && _bundle$quantity !== void 0 ? _bundle$quantity : bundle.num) !== null && _ref6 !== void 0 ? _ref6 : product === null || product === void 0 ? void 0 : product.product_quantity,
126
+ original_price: (_ref7 = (_bundle$original_pric = bundle.original_price) !== null && _bundle$original_pric !== void 0 ? _bundle$original_pric : bundle.product_price) !== null && _ref7 !== void 0 ? _ref7 : bundle.price,
127
+ selling_price: (_bundle$bundle_sellin = bundle.bundle_selling_price) !== null && _bundle$bundle_sellin !== void 0 ? _bundle$bundle_sellin : bundle.price,
128
+ is_charge_tax: (_bundle$is_charge_tax = bundle.is_charge_tax) !== null && _bundle$is_charge_tax !== void 0 ? _bundle$is_charge_tax : product === null || product === void 0 ? void 0 : product.is_charge_tax,
129
+ discount_list: bundle.discount_list
130
+ }));
131
+ }
132
+ } catch (err) {
133
+ _iterator3.e(err);
134
+ } finally {
135
+ _iterator3.f();
136
+ }
137
+ }
138
+ } catch (err) {
139
+ _iterator2.e(err);
140
+ } finally {
141
+ _iterator2.f();
142
+ }
143
+ return expanded;
144
+ }
@@ -0,0 +1,53 @@
1
+ export type OrderCollectionKind = 'product' | 'booking' | 'payment';
2
+ export interface OrderCollectionIdentityStats {
3
+ backfilledUidCount: number;
4
+ collapsedDuplicateCount: number;
5
+ uidConflictCount: number;
6
+ anonymousRowCount: number;
7
+ }
8
+ export interface OrderCollectionUidRemap {
9
+ kind: OrderCollectionKind;
10
+ from: string;
11
+ to: string;
12
+ persistentId: string | null;
13
+ /** 默认全局迁移;UID 冲突时只能迁移能由另一侧 UID 明确定位的引用。 */
14
+ scope?: 'global' | 'linked-owner';
15
+ referenceOwnerUid?: string | null;
16
+ }
17
+ export interface NormalizeOrderCollectionResult<T> {
18
+ items: T[];
19
+ stats: OrderCollectionIdentityStats;
20
+ uidRemaps: OrderCollectionUidRemap[];
21
+ }
22
+ export interface NormalizeOrderCollectionsResult<T> {
23
+ order: T;
24
+ stats: Record<OrderCollectionKind, OrderCollectionIdentityStats>;
25
+ uidRemaps: OrderCollectionUidRemap[];
26
+ }
27
+ export declare function createUuidV4(): string;
28
+ export declare function isBlankOrderCollectionIdentity(value: unknown): boolean;
29
+ export declare function getOrderCollectionPersistentId(kind: OrderCollectionKind, item: unknown): string | null;
30
+ export declare function getOrderCollectionUid(kind: OrderCollectionKind, item: unknown): string | null;
31
+ export declare function buildOrderCollectionFallbackUid(kind: OrderCollectionKind, persistentId: string | number): string;
32
+ export declare function getOrderCollectionReferenceUid(kind: OrderCollectionKind, item: unknown): string | null;
33
+ export declare function setOrderCollectionUid<T>(kind: OrderCollectionKind, item: T, uid: string): T;
34
+ /**
35
+ * 持久化行 ID 是服务端事实主键;只有至少一侧尚未持久化时,才允许用 runtime UID 对齐。
36
+ */
37
+ export declare function isSameOrderCollectionItem(kind: OrderCollectionKind, left: unknown, right: unknown): boolean;
38
+ export declare function mergeOrderCollectionItems<T>(kind: OrderCollectionKind, currentItem: T, incomingItem: T, options?: {
39
+ ensureUid?: boolean;
40
+ createAnonymousUid?: () => string;
41
+ }): T;
42
+ /**
43
+ * 规范化单一数组:强身份重复时保留首次位置、用最后一条业务字段覆盖,并统一补 UID。
44
+ */
45
+ export declare function normalizeOrderCollection<T>(kind: OrderCollectionKind, items: T[] | null | undefined, options?: {
46
+ ensureUid?: boolean;
47
+ createAnonymousUid?: () => string;
48
+ }): NormalizeOrderCollectionResult<T>;
49
+ export declare function applyOrderCollectionUidRemaps<T extends Record<string, any>>(sourceOrder: T, uidRemaps: OrderCollectionUidRemap[]): T;
50
+ export declare function normalizeOrderCollections<T extends Record<string, any>>(sourceOrder: T, options?: {
51
+ ensureUid?: boolean;
52
+ createAnonymousUid?: () => string;
53
+ }): NormalizeOrderCollectionsResult<T>;