@pisell/pisellos 2.2.308 → 2.2.310

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 (130) hide show
  1. package/dist/model/strategy/adapter/promotion/index.js +9 -0
  2. package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +2 -0
  3. package/dist/model/strategy/adapter/walletPass/evaluator.js +4 -2
  4. package/dist/modules/BookingContext/index.js +4 -4
  5. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +58 -19
  6. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +24 -12
  7. package/dist/modules/Customer/index.js +6 -3
  8. package/dist/modules/Customer/types.d.ts +2 -0
  9. package/dist/modules/Discount/availability.d.ts +7 -0
  10. package/dist/modules/Discount/availability.js +49 -0
  11. package/dist/modules/Discount/entitlementPass.d.ts +34 -0
  12. package/dist/modules/Discount/entitlementPass.js +147 -0
  13. package/dist/modules/Discount/index.d.ts +2 -2
  14. package/dist/modules/Discount/index.js +37 -151
  15. package/dist/modules/Discount/types.d.ts +36 -5
  16. package/dist/modules/OpenData/index.d.ts +1 -1
  17. package/dist/modules/OpenData/index.js +21 -12
  18. package/dist/modules/Order/index.d.ts +33 -4
  19. package/dist/modules/Order/index.js +830 -411
  20. package/dist/modules/Order/types.d.ts +17 -0
  21. package/dist/modules/Order/utils/orderCollectionIdentity.js +16 -12
  22. package/dist/modules/Order/utils/weighedProduct.d.ts +12 -0
  23. package/dist/modules/Order/utils/weighedProduct.js +94 -0
  24. package/dist/modules/Order/utils.d.ts +14 -2
  25. package/dist/modules/Order/utils.js +280 -79
  26. package/dist/modules/Payment/index.d.ts +0 -5
  27. package/dist/modules/Payment/index.js +35 -85
  28. package/dist/modules/Payment/types.d.ts +21 -1
  29. package/dist/modules/Payment/types.js +2 -0
  30. package/dist/modules/Payment/walletpass.d.ts +1 -1
  31. package/dist/modules/Payment/walletpass.js +80 -47
  32. package/dist/modules/ProductList/index.js +18 -5
  33. package/dist/modules/Rules/index.d.ts +2 -2
  34. package/dist/modules/Rules/index.js +484 -188
  35. package/dist/modules/Rules/types.d.ts +6 -0
  36. package/dist/server/index.js +8 -5
  37. package/dist/server/modules/order/index.js +6 -0
  38. package/dist/server/modules/order/types.d.ts +12 -0
  39. package/dist/server/modules/payment/index.d.ts +25 -6
  40. package/dist/server/modules/payment/index.js +660 -133
  41. package/dist/server/utils/small-ticket.d.ts +8 -5
  42. package/dist/server/utils/small-ticket.js +1269 -199
  43. package/dist/solution/BaseSales/index.d.ts +11 -2
  44. package/dist/solution/BaseSales/index.js +1463 -1173
  45. package/dist/solution/BaseSales/types.d.ts +7 -3
  46. package/dist/solution/BaseSales/utils/cartPromotion.js +141 -126
  47. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +40 -25
  48. package/dist/solution/BaseSales/utils.js +3 -2
  49. package/dist/solution/BookingTicket/index.d.ts +11 -2
  50. package/dist/solution/BookingTicket/index.js +663 -542
  51. package/dist/solution/BookingTicket/types.d.ts +5 -1
  52. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +2 -0
  53. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +338 -147
  54. package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +8 -4
  55. package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +6 -0
  56. package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.js +19 -6
  57. package/dist/solution/ScanOrder/utils.js +3 -2
  58. package/dist/solution/ShopDiscount/index.d.ts +2 -0
  59. package/dist/solution/ShopDiscount/index.js +99 -42
  60. package/dist/solution/ShopDiscount/utils.d.ts +4 -2
  61. package/dist/solution/ShopDiscount/utils.js +43 -23
  62. package/dist/solution/UnifiedBookingSales/index.d.ts +2 -2
  63. package/dist/solution/UnifiedBookingSales/index.js +5 -5
  64. package/dist/utils/os-private-payload.d.ts +5 -0
  65. package/dist/utils/os-private-payload.js +17 -0
  66. package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +2 -0
  67. package/lib/model/strategy/adapter/walletPass/evaluator.js +2 -0
  68. package/lib/modules/BookingContext/index.js +3 -3
  69. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +35 -6
  70. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +13 -6
  71. package/lib/modules/Customer/index.js +5 -1
  72. package/lib/modules/Customer/types.d.ts +2 -0
  73. package/lib/modules/Discount/availability.d.ts +7 -0
  74. package/lib/modules/Discount/availability.js +43 -0
  75. package/lib/modules/Discount/entitlementPass.d.ts +34 -0
  76. package/lib/modules/Discount/entitlementPass.js +141 -0
  77. package/lib/modules/Discount/index.d.ts +2 -2
  78. package/lib/modules/Discount/index.js +23 -129
  79. package/lib/modules/Discount/types.d.ts +36 -5
  80. package/lib/modules/OpenData/index.d.ts +1 -1
  81. package/lib/modules/OpenData/index.js +11 -2
  82. package/lib/modules/Order/index.d.ts +33 -4
  83. package/lib/modules/Order/index.js +411 -81
  84. package/lib/modules/Order/types.d.ts +17 -0
  85. package/lib/modules/Order/utils/orderCollectionIdentity.js +14 -11
  86. package/lib/modules/Order/utils/weighedProduct.d.ts +12 -0
  87. package/lib/modules/Order/utils/weighedProduct.js +89 -0
  88. package/lib/modules/Order/utils.d.ts +14 -2
  89. package/lib/modules/Order/utils.js +189 -5
  90. package/lib/modules/Payment/index.d.ts +0 -5
  91. package/lib/modules/Payment/index.js +3 -28
  92. package/lib/modules/Payment/types.d.ts +21 -1
  93. package/lib/modules/Payment/types.js +1 -0
  94. package/lib/modules/Payment/walletpass.d.ts +1 -1
  95. package/lib/modules/Payment/walletpass.js +29 -9
  96. package/lib/modules/ProductList/index.js +14 -1
  97. package/lib/modules/Rules/index.d.ts +2 -2
  98. package/lib/modules/Rules/index.js +361 -112
  99. package/lib/modules/Rules/types.d.ts +6 -0
  100. package/lib/server/index.js +8 -5
  101. package/lib/server/modules/order/index.js +6 -0
  102. package/lib/server/modules/order/types.d.ts +12 -0
  103. package/lib/server/modules/payment/index.d.ts +25 -6
  104. package/lib/server/modules/payment/index.js +350 -78
  105. package/lib/server/utils/small-ticket.d.ts +8 -5
  106. package/lib/server/utils/small-ticket.js +1009 -121
  107. package/lib/solution/BaseSales/index.d.ts +11 -2
  108. package/lib/solution/BaseSales/index.js +164 -30
  109. package/lib/solution/BaseSales/types.d.ts +7 -3
  110. package/lib/solution/BaseSales/utils/cartPromotion.js +12 -4
  111. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +24 -9
  112. package/lib/solution/BaseSales/utils.js +2 -1
  113. package/lib/solution/BookingTicket/index.d.ts +11 -2
  114. package/lib/solution/BookingTicket/index.js +103 -41
  115. package/lib/solution/BookingTicket/types.d.ts +5 -1
  116. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +2 -0
  117. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +174 -42
  118. package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +8 -4
  119. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +6 -0
  120. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +11 -3
  121. package/lib/solution/ScanOrder/utils.js +2 -1
  122. package/lib/solution/ShopDiscount/index.d.ts +2 -0
  123. package/lib/solution/ShopDiscount/index.js +55 -9
  124. package/lib/solution/ShopDiscount/utils.d.ts +4 -2
  125. package/lib/solution/ShopDiscount/utils.js +42 -25
  126. package/lib/solution/UnifiedBookingSales/index.d.ts +2 -2
  127. package/lib/solution/UnifiedBookingSales/index.js +5 -5
  128. package/lib/utils/os-private-payload.d.ts +5 -0
  129. package/lib/utils/os-private-payload.js +22 -0
  130. package/package.json +1 -1
@@ -199,12 +199,27 @@ export interface PointCardSnapshotItem {
199
199
  id: number | string;
200
200
  tag: 'point_card';
201
201
  product_id?: number | string;
202
+ code?: string;
202
203
  product_name: string;
203
204
  par_value: string;
204
205
  used_par_value: string;
205
206
  }
207
+ export interface PointCardSnapshotMergeContext {
208
+ customerId?: number | string | null;
209
+ orderIdentity?: OrderIdentitySnapshot | null;
210
+ }
211
+ export interface VirtualCurrencySnapshotItem {
212
+ id: number | string;
213
+ tag: 'virtual_currency';
214
+ product_id?: number | string;
215
+ product_name: string;
216
+ par_value: string;
217
+ used_par_value: string;
218
+ name: Record<string, string>;
219
+ }
206
220
  export interface OrderMetaList {
207
221
  point_cards_snapshot?: PointCardSnapshotItem[];
222
+ virtual_currency_snapshot?: VirtualCurrencySnapshotItem[];
208
223
  }
209
224
  export interface OrderProduct extends OrderProductIdentity {
210
225
  order_detail_id: number | null;
@@ -964,6 +979,8 @@ export interface OrderModuleAPI {
964
979
  }) => Promise<Discount[]>;
965
980
  getDiscountList: () => Discount[];
966
981
  getAvailableWalletIds: () => number[];
982
+ getCustomerWalletPrepareConfigEpoch: () => number;
983
+ mergePointCardSnapshotCodes: (walletPassList: unknown, context?: PointCardSnapshotMergeContext) => PointCardSnapshotItem[];
967
984
  applyDiscount: () => void;
968
985
  /**
969
986
  * 注入促销评估器。
@@ -12,6 +12,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
12
12
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
13
13
  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); }
14
14
  import { cloneDeep } from 'lodash-es';
15
+ import { isFullCoveragePass } from "../../Discount/entitlementPass";
15
16
  var IDENTITY_CONFIG = {
16
17
  product: {
17
18
  persistentIdField: 'order_detail_id',
@@ -74,22 +75,25 @@ export function setOrderCollectionUid(kind, item, uid) {
74
75
  delete record[uidField];
75
76
  return record;
76
77
  }
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';
78
+ function getFullCoveragePassIdentity(product) {
79
+ var _ref, _ref2, _pass$discount$resour, _pass$discount;
80
+ var pass = (product.discount_list || []).find(function (item) {
81
+ return isFullCoveragePass(item);
83
82
  });
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);
83
+ if (!pass) return null;
84
+ var resourceId = (_ref = (_ref2 = (_pass$discount$resour = (_pass$discount = pass.discount) === null || _pass$discount === void 0 ? void 0 : _pass$discount.resource_id) !== null && _pass$discount$resour !== void 0 ? _pass$discount$resour : pass.resource_id) !== null && _ref2 !== void 0 ? _ref2 : pass.discount_id) !== null && _ref !== void 0 ? _ref : pass.id;
85
+ if (isBlankOrderCollectionIdentity(resourceId)) return null;
86
+ return {
87
+ type: String(pass.type || pass.tag),
88
+ resourceId: String(resourceId)
89
+ };
87
90
  }
88
91
  function buildSplitProductUid(originalUid, product, duplicateOrdinal) {
89
92
  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
+ var passIdentity = getFullCoveragePassIdentity(product);
94
+ if (passIdentity) {
95
+ var passType = passIdentity.type === 'good_pass' ? 'good-pass' : 'entitlement-pass';
96
+ return "os-split:product:".concat(encodedOriginalUid, ":").concat(passType, ":").concat(encodeURIComponent(passIdentity.resourceId), ":").concat(duplicateOrdinal);
93
97
  }
94
98
  return "os-split:product:".concat(encodedOriginalUid, ":duplicate:").concat(duplicateOrdinal);
95
99
  }
@@ -0,0 +1,12 @@
1
+ /** Only pricing/measurement fields participate; display and option data do not. */
2
+ export declare function getWeighedProductPriceFingerprint(sku?: Record<string, any>): string;
3
+ /**
4
+ * A weighed line's source is the amount for its net weight, never its catalog unit price.
5
+ * Persisted SKU measurements and the full catalog snapshot take priority over runtime
6
+ * _extend.weighing, which can survive repricing with an obsolete total_amount.
7
+ */
8
+ export declare function resolveWeighedSourcePrice(sku?: Record<string, any>, weighing?: Record<string, any>): string | undefined;
9
+ /** Original bundle totals must use the nested options before manual distribution. */
10
+ export declare function withOriginalBundleOptionPrices(bundles?: Array<Record<string, any>>): {
11
+ option: any;
12
+ }[] | undefined;
@@ -0,0 +1,94 @@
1
+ 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); }
2
+ 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; }
3
+ 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; }
4
+ 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; }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
+ 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); }
7
+ import Decimal from 'decimal.js';
8
+ var UNIT_GRAMS = {
9
+ kg: '1000',
10
+ KILOGRAMS: '1000',
11
+ g: '1',
12
+ GRAMS: '1',
13
+ lb: '453.59237',
14
+ POUNDS: '453.59237',
15
+ oz: '28.349523125',
16
+ OUNCES: '28.349523125'
17
+ };
18
+ function nonNegative(value) {
19
+ if (value === null || value === undefined || value === '') return undefined;
20
+ try {
21
+ var result = new Decimal(value);
22
+ return result.isFinite() && result.gte(0) ? result : undefined;
23
+ } catch (_unused) {
24
+ return undefined;
25
+ }
26
+ }
27
+ function numericKey(value) {
28
+ var _nonNegative;
29
+ return (_nonNegative = nonNegative(value)) === null || _nonNegative === void 0 ? void 0 : _nonNegative.toString();
30
+ }
31
+ function unitKey(value) {
32
+ return UNIT_GRAMS[String(value)] || (value == null ? undefined : String(value));
33
+ }
34
+ function snapshotKey(snapshot) {
35
+ var _snapshot$unit_value;
36
+ return [numericKey(snapshot === null || snapshot === void 0 ? void 0 : snapshot.price), unitKey(snapshot === null || snapshot === void 0 ? void 0 : snapshot.unit), numericKey((_snapshot$unit_value = snapshot === null || snapshot === void 0 ? void 0 : snapshot.unit_value) !== null && _snapshot$unit_value !== void 0 ? _snapshot$unit_value : 1)];
37
+ }
38
+
39
+ /** Only pricing/measurement fields participate; display and option data do not. */
40
+ export function getWeighedProductPriceFingerprint(sku) {
41
+ var _sku$unit_weight;
42
+ if (Number(sku === null || sku === void 0 ? void 0 : sku.open_sold_weight) !== 1) return 'unweighed';
43
+ return JSON.stringify([1, numericKey(sku === null || sku === void 0 ? void 0 : sku.net_weight), unitKey(sku === null || sku === void 0 ? void 0 : sku.unit), numericKey(sku === null || sku === void 0 ? void 0 : sku.unit_price), numericKey((_sku$unit_weight = sku === null || sku === void 0 ? void 0 : sku.unit_weight) !== null && _sku$unit_weight !== void 0 ? _sku$unit_weight : 1), snapshotKey(sku === null || sku === void 0 ? void 0 : sku.unit_data_snapshot)]);
44
+ }
45
+
46
+ /**
47
+ * A weighed line's source is the amount for its net weight, never its catalog unit price.
48
+ * Persisted SKU measurements and the full catalog snapshot take priority over runtime
49
+ * _extend.weighing, which can survive repricing with an obsolete total_amount.
50
+ */
51
+ export function resolveWeighedSourcePrice(sku, weighing) {
52
+ var _snapshot$unit_value2, _weighing$unit_weight, _sku$unit_weight2, _measurement$unit_wei;
53
+ if ((sku === null || sku === void 0 ? void 0 : sku.open_sold_weight) != null && Number(sku.open_sold_weight) !== 1) return undefined;
54
+ if (Number(sku === null || sku === void 0 ? void 0 : sku.open_sold_weight) !== 1 && !weighing) return undefined;
55
+ var hasSkuMeasurement = (sku === null || sku === void 0 ? void 0 : sku.net_weight) !== undefined && (sku === null || sku === void 0 ? void 0 : sku.net_weight) !== null;
56
+ var measurement = hasSkuMeasurement ? sku : weighing;
57
+ var netWeight = nonNegative(measurement === null || measurement === void 0 ? void 0 : measurement.net_weight);
58
+ if (netWeight === undefined) return undefined;
59
+ var snapshot = hasSkuMeasurement ? sku === null || sku === void 0 ? void 0 : sku.unit_data_snapshot : weighing === null || weighing === void 0 ? void 0 : weighing.scalePriceProduct;
60
+ var snapshotPrice = nonNegative(snapshot === null || snapshot === void 0 ? void 0 : snapshot.price);
61
+ var snapshotUnits = nonNegative((_snapshot$unit_value2 = snapshot === null || snapshot === void 0 ? void 0 : snapshot.unit_value) !== null && _snapshot$unit_value2 !== void 0 ? _snapshot$unit_value2 : 1);
62
+ var sourceGrams = UNIT_GRAMS[String(snapshot === null || snapshot === void 0 ? void 0 : snapshot.unit)];
63
+ var targetGrams = UNIT_GRAMS[String(measurement === null || measurement === void 0 ? void 0 : measurement.unit)];
64
+ if (snapshotPrice && snapshotUnits !== null && snapshotUnits !== void 0 && snapshotUnits.gt(0) && sourceGrams && targetGrams) {
65
+ return snapshotPrice.mul(netWeight).mul(targetGrams).div(sourceGrams).div(snapshotUnits).toFixed(2);
66
+ }
67
+
68
+ // Legacy callers may only retain the native scale's amount. Do not let an old
69
+ // amount overwrite a changed SKU measurement, unit price, or pricing snapshot.
70
+ var runtimeAmount = nonNegative(weighing === null || weighing === void 0 ? void 0 : weighing.total_amount);
71
+ var runtimeMatchesSku = !hasSkuMeasurement || numericKey(weighing === null || weighing === void 0 ? void 0 : weighing.net_weight) === numericKey(sku === null || sku === void 0 ? void 0 : sku.net_weight) && unitKey(weighing === null || weighing === void 0 ? void 0 : weighing.unit) === unitKey(sku === null || sku === void 0 ? void 0 : sku.unit) && numericKey(weighing === null || weighing === void 0 ? void 0 : weighing.unit_price) === numericKey(sku === null || sku === void 0 ? void 0 : sku.unit_price) && numericKey((_weighing$unit_weight = weighing === null || weighing === void 0 ? void 0 : weighing.unit_weight) !== null && _weighing$unit_weight !== void 0 ? _weighing$unit_weight : 1) === numericKey((_sku$unit_weight2 = sku === null || sku === void 0 ? void 0 : sku.unit_weight) !== null && _sku$unit_weight2 !== void 0 ? _sku$unit_weight2 : 1) && JSON.stringify(snapshotKey(weighing === null || weighing === void 0 ? void 0 : weighing.scalePriceProduct)) === JSON.stringify(snapshotKey(sku === null || sku === void 0 ? void 0 : sku.unit_data_snapshot));
72
+ if (runtimeAmount && runtimeMatchesSku) return runtimeAmount.toFixed(2);
73
+
74
+ // Older persisted orders have only a rounded per-scale-unit price.
75
+ var unitPrice = nonNegative(measurement === null || measurement === void 0 ? void 0 : measurement.unit_price);
76
+ var unitWeight = nonNegative((_measurement$unit_wei = measurement === null || measurement === void 0 ? void 0 : measurement.unit_weight) !== null && _measurement$unit_wei !== void 0 ? _measurement$unit_wei : 1);
77
+ if (!unitPrice || !(unitWeight !== null && unitWeight !== void 0 && unitWeight.gt(0))) return undefined;
78
+ return netWeight.div(unitWeight).mul(unitPrice).toFixed(2);
79
+ }
80
+
81
+ /** Original bundle totals must use the nested options before manual distribution. */
82
+ export function withOriginalBundleOptionPrices(bundles) {
83
+ return bundles === null || bundles === void 0 ? void 0 : bundles.map(function (bundle) {
84
+ var _bundle$option;
85
+ return _objectSpread(_objectSpread({}, bundle), {}, {
86
+ option: (_bundle$option = bundle.option) === null || _bundle$option === void 0 ? void 0 : _bundle$option.map(function (option) {
87
+ var _ref, _option$original_pric;
88
+ return _objectSpread(_objectSpread({}, option), {}, {
89
+ add_price: (_ref = (_option$original_pric = option.original_price) !== null && _option$original_pric !== void 0 ? _option$original_pric : option.add_price) !== null && _ref !== void 0 ? _ref : option.price
90
+ });
91
+ })
92
+ });
93
+ });
94
+ }
@@ -1,6 +1,6 @@
1
1
  import Decimal from 'decimal.js';
2
2
  import type { CartItem } from "../Cart";
3
- import type { OrderProductDiscountItem, OrderMetaList, OrderProduct, OrderSubmitPayload, OrderSubmitProduct, OrderSummary, OrderTempOrder, PointCardSnapshotItem } from './types';
3
+ import type { OrderProductDiscountItem, OrderMetaList, OrderProduct, OrderSubmitPayload, OrderSubmitProduct, OrderSummary, OrderTempOrder, PointCardSnapshotItem, VirtualCurrencySnapshotItem } from './types';
4
4
  import type { RulesParamsHooks } from '../Rules/types';
5
5
  import type { MapOrderPaymentsOptions, OrderPaymentData, OrderPaymentSource } from './types';
6
6
  import { createUuidV4 } from './utils/orderCollectionIdentity';
@@ -18,6 +18,18 @@ export interface OrderProductsDepositSummary {
18
18
  import type { WindowPlugin } from '../../plugins';
19
19
  export declare function normalizePointCardSnapshotItem(value: unknown): PointCardSnapshotItem | null;
20
20
  export declare function buildPointCardSnapshotFromWalletPassList(value: unknown): PointCardSnapshotItem[];
21
+ export declare function collectPointCardSnapshotCodeCandidates(value: unknown): Array<{
22
+ id: string;
23
+ code: string;
24
+ }>;
25
+ /**
26
+ * Payment 的 WalletPass 列表包含实例 code,而 prepare/config 通常只提供
27
+ * 卡名称和余额。按实例 ID 仅补齐 Snapshot 缺失的 code,避免后到的运行态
28
+ * 数据覆盖下单时已经冻结的卡名称和余额。
29
+ */
30
+ export declare function mergePointCardSnapshotCodes(snapshotsValue: unknown, walletPassesValue: unknown): PointCardSnapshotItem[];
31
+ export declare function normalizeVirtualCurrencySnapshotItem(value: unknown): VirtualCurrencySnapshotItem | null;
32
+ export declare function buildVirtualCurrencySnapshotFromList(value: unknown): VirtualCurrencySnapshotItem[];
21
33
  export declare function normalizeOrderMetaList(value: unknown): OrderMetaList | undefined;
22
34
  /**
23
35
  * 把"含 option 的主商品单价"与 bundle 合成"单行 composite 单价"。
@@ -159,7 +171,7 @@ export declare function resolveManualOverrideLineOriginalPrice(params: {
159
171
  * // => -4
160
172
  */
161
173
  export declare function resolveEffectivePerUnitDiscount(product: Record<string, any>): number;
162
- export declare function createDefaultOrderRulesHooks(): RulesParamsHooks;
174
+ export declare function createDefaultOrderRulesHooks(getBookings?: () => OrderTempOrder['bookings']): RulesParamsHooks;
163
175
  /**
164
176
  * 通过 session 类商品的开始时间结束时间生成商品的时长
165
177
  * @param {CartItem} cartItem