@pisell/pisellos 2.2.190 → 2.2.192

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 (67) hide show
  1. package/dist/model/strategy/adapter/promotion/index.js +0 -9
  2. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +2 -1
  3. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +2 -7
  4. package/dist/modules/Cart/utils/cartProduct.js +13 -2
  5. package/dist/modules/Order/index.d.ts +1 -3
  6. package/dist/modules/Order/index.js +69 -95
  7. package/dist/modules/Order/types.d.ts +9 -6
  8. package/dist/modules/Order/utils.d.ts +9 -2
  9. package/dist/modules/Order/utils.js +36 -13
  10. package/dist/modules/SalesSummary/types.d.ts +3 -1
  11. package/dist/modules/SalesSummary/utils.js +7 -3
  12. package/dist/server/modules/order/index.d.ts +60 -7
  13. package/dist/server/modules/order/index.js +670 -178
  14. package/dist/server/modules/order/types.d.ts +0 -2
  15. package/dist/server/modules/products/index.d.ts +33 -6
  16. package/dist/server/modules/products/index.js +528 -231
  17. package/dist/solution/BaseSales/index.js +13 -7
  18. package/dist/solution/BaseSales/types.d.ts +8 -5
  19. package/dist/solution/BaseSales/types.js +2 -3
  20. package/dist/solution/BaseSales/utils/cartPromotion.js +7 -7
  21. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +1 -0
  22. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +16 -13
  23. package/dist/solution/BaseSales/utils.d.ts +1 -1
  24. package/dist/solution/BaseSales/utils.js +22 -19
  25. package/dist/solution/BookingByStep/index.d.ts +1 -1
  26. package/dist/solution/BookingTicket/index.d.ts +1 -1
  27. package/dist/solution/ScanOrder/index.js +7 -5
  28. package/dist/solution/ScanOrder/types.d.ts +8 -5
  29. package/dist/solution/ScanOrder/types.js +2 -3
  30. package/dist/solution/ScanOrder/utils.d.ts +1 -1
  31. package/dist/solution/ScanOrder/utils.js +26 -23
  32. package/dist/solution/VenueBooking/index.js +5 -3
  33. package/dist/solution/VenueBooking/sales-section-4-annotated.json +0 -2
  34. package/lib/model/strategy/adapter/promotion/index.js +0 -49
  35. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +2 -1
  36. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +2 -1
  37. package/lib/modules/Cart/utils/cartProduct.js +9 -2
  38. package/lib/modules/Order/index.d.ts +1 -3
  39. package/lib/modules/Order/index.js +45 -58
  40. package/lib/modules/Order/types.d.ts +9 -6
  41. package/lib/modules/Order/utils.d.ts +9 -2
  42. package/lib/modules/Order/utils.js +41 -10
  43. package/lib/modules/SalesSummary/types.d.ts +3 -1
  44. package/lib/modules/SalesSummary/utils.js +5 -3
  45. package/lib/server/modules/order/index.d.ts +60 -7
  46. package/lib/server/modules/order/index.js +350 -40
  47. package/lib/server/modules/order/types.d.ts +0 -2
  48. package/lib/server/modules/products/index.d.ts +33 -6
  49. package/lib/server/modules/products/index.js +159 -30
  50. package/lib/solution/BaseSales/index.js +14 -5
  51. package/lib/solution/BaseSales/types.d.ts +8 -5
  52. package/lib/solution/BaseSales/utils/cartPromotion.js +6 -6
  53. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +1 -0
  54. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +21 -14
  55. package/lib/solution/BaseSales/utils.d.ts +1 -1
  56. package/lib/solution/BaseSales/utils.js +11 -7
  57. package/lib/solution/BookingByStep/index.d.ts +1 -1
  58. package/lib/solution/BookingTicket/index.d.ts +1 -1
  59. package/lib/solution/ScanOrder/index.js +4 -4
  60. package/lib/solution/ScanOrder/types.d.ts +8 -5
  61. package/lib/solution/ScanOrder/utils.d.ts +1 -1
  62. package/lib/solution/ScanOrder/utils.js +12 -8
  63. package/lib/solution/VenueBooking/index.js +2 -2
  64. package/lib/solution/VenueBooking/sales-section-4-annotated.json +0 -2
  65. package/package.json +1 -1
  66. package/dist/solution/Checkout/appointmentDemo.json +0 -1
  67. package/lib/solution/Checkout/appointmentDemo.json +0 -1
@@ -13,7 +13,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
13
13
  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; }
14
14
  import dayjs from 'dayjs';
15
15
  import Decimal from 'decimal.js';
16
- import { composeLinePrice, createUuidV4, resolveManualOverrideLineOriginalPrice, sumOptionUnitPrice } from "../../modules/Order/utils";
16
+ import { composeLinePrice, createUuidV4, ensureProductSku, getProductSkuOptions, normalizeProductSkuOptions, resolveManualOverrideLineOriginalPrice, sumOptionUnitPrice } from "../../modules/Order/utils";
17
17
  import { ensureManualProductDiscountList } from "../../modules/Order/utils/manualProductDiscount";
18
18
 
19
19
  /**
@@ -380,12 +380,12 @@ export function attachItemRuleLimitsToTopLevelProducts(productList, limits) {
380
380
  export function buildProductLineFingerprint(productOptionItem, productBundle) {
381
381
  var optArr = Array.isArray(productOptionItem) ? productOptionItem : [];
382
382
  var normalizedOpts = optArr.map(function (item) {
383
- var _item$price;
383
+ var _ref, _item$add_price;
384
384
  return {
385
385
  option_group_item_id: Number(item === null || item === void 0 ? void 0 : item.option_group_item_id) || 0,
386
386
  option_group_id: Number(item === null || item === void 0 ? void 0 : item.option_group_id) || 0,
387
387
  num: typeof (item === null || item === void 0 ? void 0 : item.num) === 'number' && !Number.isNaN(item.num) ? Math.max(1, Math.floor(item.num)) : 1,
388
- price: String((_item$price = item === null || item === void 0 ? void 0 : item.price) !== null && _item$price !== void 0 ? _item$price : '')
388
+ price: String((_ref = (_item$add_price = item === null || item === void 0 ? void 0 : item.add_price) !== null && _item$add_price !== void 0 ? _item$add_price : item === null || item === void 0 ? void 0 : item.price) !== null && _ref !== void 0 ? _ref : '')
389
389
  };
390
390
  }).sort(function (p, q) {
391
391
  if (p.option_group_item_id !== q.option_group_item_id) {
@@ -397,9 +397,9 @@ export function buildProductLineFingerprint(productOptionItem, productBundle) {
397
397
  });
398
398
  var bundleArr = Array.isArray(productBundle) ? productBundle : [];
399
399
  var normalizedBundles = bundleArr.map(function (item) {
400
- var _ref, _item$bundle_id;
400
+ var _ref2, _item$bundle_id;
401
401
  return {
402
- bundle_id: Number((_ref = (_item$bundle_id = item === null || item === void 0 ? void 0 : item.bundle_id) !== null && _item$bundle_id !== void 0 ? _item$bundle_id : item === null || item === void 0 ? void 0 : item.id) !== null && _ref !== void 0 ? _ref : 0) || 0,
402
+ bundle_id: Number((_ref2 = (_item$bundle_id = item === null || item === void 0 ? void 0 : item.bundle_id) !== null && _item$bundle_id !== void 0 ? _item$bundle_id : item === null || item === void 0 ? void 0 : item.id) !== null && _ref2 !== void 0 ? _ref2 : 0) || 0,
403
403
  product_id: Number(item === null || item === void 0 ? void 0 : item.product_id) || 0,
404
404
  num: typeof (item === null || item === void 0 ? void 0 : item.num) === 'number' && !Number.isNaN(item.num) ? Math.max(1, Math.floor(item.num)) : 1
405
405
  };
@@ -413,15 +413,15 @@ export function buildProductLineFingerprint(productOptionItem, productBundle) {
413
413
 
414
414
  /**
415
415
  * removeProductFromOrder 仅传 SKU 时的通配 identity(对象上未声明选项键)。
416
- * 与显式 `product_option_item: []` 区分:后者只匹配「无选项」行。
416
+ * 与显式 `product_sku: { option: [] }` 区分:后者只匹配「无选项」行。
417
417
  */
418
418
  export function isSkuOnlyDeleteIdentity(x) {
419
419
  if (x.unique_identification_number || x.identity_key) return false;
420
- return !('product_option_item' in x) && !('product_bundle' in x);
420
+ return !('product_sku' in x) && !('product_bundle' in x);
421
421
  }
422
422
  function fingerprintForIdentityWithOptionKeys(x) {
423
423
  var row = x;
424
- var opts = 'product_option_item' in row ? Array.isArray(row.product_option_item) ? row.product_option_item : [] : [];
424
+ var opts = 'product_sku' in row ? getProductSkuOptions(row) : [];
425
425
  var buds = 'product_bundle' in row ? Array.isArray(row.product_bundle) ? row.product_bundle : [] : [];
426
426
  return buildProductLineFingerprint(opts, buds);
427
427
  }
@@ -437,10 +437,10 @@ function fingerprintForIdentityWithOptionKeys(x) {
437
437
  * 忽略线侧 identity_key,按内容语义匹配。这给「行已 opaque、调用方却想按 SKU 通配 / 选项指纹删除」留兼容入口。
438
438
  */
439
439
  export function isIdentityMatch(a, b) {
440
- var _ref2, _metadata$unique_iden, _metadata2, _ref3, _metadata$unique_iden2, _metadata3;
440
+ var _ref3, _metadata$unique_iden, _metadata2, _ref4, _metadata$unique_iden2, _metadata3;
441
441
  if (a.product_id !== b.product_id || a.product_variant_id !== b.product_variant_id) return false;
442
- var aUid = (_ref2 = (_metadata$unique_iden = (_metadata2 = a.metadata) === null || _metadata2 === void 0 ? void 0 : _metadata2.unique_identification_number) !== null && _metadata$unique_iden !== void 0 ? _metadata$unique_iden : a.unique_identification_number) !== null && _ref2 !== void 0 ? _ref2 : a.identity_key;
443
- var bUid = (_ref3 = (_metadata$unique_iden2 = (_metadata3 = b.metadata) === null || _metadata3 === void 0 ? void 0 : _metadata3.unique_identification_number) !== null && _metadata$unique_iden2 !== void 0 ? _metadata$unique_iden2 : b.unique_identification_number) !== null && _ref3 !== void 0 ? _ref3 : b.identity_key;
442
+ var aUid = (_ref3 = (_metadata$unique_iden = (_metadata2 = a.metadata) === null || _metadata2 === void 0 ? void 0 : _metadata2.unique_identification_number) !== null && _metadata$unique_iden !== void 0 ? _metadata$unique_iden : a.unique_identification_number) !== null && _ref3 !== void 0 ? _ref3 : a.identity_key;
443
+ var bUid = (_ref4 = (_metadata$unique_iden2 = (_metadata3 = b.metadata) === null || _metadata3 === void 0 ? void 0 : _metadata3.unique_identification_number) !== null && _metadata$unique_iden2 !== void 0 ? _metadata$unique_iden2 : b.unique_identification_number) !== null && _ref4 !== void 0 ? _ref4 : b.identity_key;
444
444
  var aHasKey = typeof aUid === 'string' && aUid.length > 0;
445
445
  var bHasKey = typeof bUid === 'string' && bUid.length > 0;
446
446
  if (aHasKey && bHasKey) return aUid === bUid;
@@ -481,7 +481,7 @@ export function getProductIdentityIndex(products, identity) {
481
481
  * - 因此多次 normalize 不会重复叠加 option/bundle。
482
482
  */
483
483
  export function normalizeOrderProduct(product) {
484
- var _product$metadata, _metadata$origin, _metadata$origin2, _variantList$find, _product$is_charge_ta;
484
+ var _product$metadata, _metadata$origin, _product$product_sku, _metadata$origin2, _variantList$find, _product$is_charge_ta;
485
485
  var metadata = _objectSpread({}, product.metadata || {});
486
486
  // 不透明 identity 契约:每条订单行必须带 identity_key。
487
487
  // 调用方未传时由 SDK 自动生成 UUID,后续 update/remove 只做严格比对,避免猜测合成 key。
@@ -493,9 +493,9 @@ export function normalizeOrderProduct(product) {
493
493
  if (priceOverride !== undefined && priceOverride !== null && priceOverride !== '' && Array.isArray(originOtherBundle) && originOtherBundle.length > 0) {
494
494
  var priceById = new Map();
495
495
  originOtherBundle.forEach(function (item) {
496
- var _item$price2;
496
+ var _item$price;
497
497
  if ((item === null || item === void 0 ? void 0 : item.id) == null) return;
498
- var unit = (_item$price2 = item.price) !== null && _item$price2 !== void 0 ? _item$price2 : item.bundle_selling_price;
498
+ var unit = (_item$price = item.price) !== null && _item$price !== void 0 ? _item$price : item.bundle_selling_price;
499
499
  if (unit === undefined || unit === null) return;
500
500
  priceById.set(String(item.id), String(unit));
501
501
  });
@@ -510,19 +510,22 @@ export function normalizeOrderProduct(product) {
510
510
  });
511
511
  }
512
512
  var normalizedBundle = bundleInput.map(function (item) {
513
- var _item$bundle_id2, _item$bundle_product_, _item$bundle_group_id, _ref4, _item$bundle_selling_, _ref5, _ref6, _item$price3, _ref7, _item$price_type, _ref8, _item$price_type_ext;
513
+ var _item$bundle_id2, _item$bundle_product_, _item$bundle_group_id, _ref5, _item$bundle_selling_, _ref6, _ref7, _item$price2, _ref8, _item$price_type, _ref9, _item$price_type_ext;
514
514
  return _objectSpread(_objectSpread({}, item), {}, {
515
515
  bundle_id: (_item$bundle_id2 = item.bundle_id) !== null && _item$bundle_id2 !== void 0 ? _item$bundle_id2 : item.id,
516
516
  bundle_product_id: (_item$bundle_product_ = item.bundle_product_id) !== null && _item$bundle_product_ !== void 0 ? _item$bundle_product_ : item._bundle_product_id,
517
517
  bundle_group_id: (_item$bundle_group_id = item.bundle_group_id) !== null && _item$bundle_group_id !== void 0 ? _item$bundle_group_id : item.group_id,
518
- bundle_selling_price: (_ref4 = (_item$bundle_selling_ = item.bundle_selling_price) !== null && _item$bundle_selling_ !== void 0 ? _item$bundle_selling_ : item.price) !== null && _ref4 !== void 0 ? _ref4 : '0.00',
519
- price: (_ref5 = (_ref6 = (_item$price3 = item.price) !== null && _item$price3 !== void 0 ? _item$price3 : item.custom_price) !== null && _ref6 !== void 0 ? _ref6 : item.bundle_selling_price) !== null && _ref5 !== void 0 ? _ref5 : '0.00',
520
- price_type: (_ref7 = (_item$price_type = item.price_type) !== null && _item$price_type !== void 0 ? _item$price_type : item.custom_price_type) !== null && _ref7 !== void 0 ? _ref7 : '',
521
- price_type_ext: (_ref8 = (_item$price_type_ext = item.price_type_ext) !== null && _item$price_type_ext !== void 0 ? _item$price_type_ext : item.custom_price_type_ext) !== null && _ref8 !== void 0 ? _ref8 : ''
518
+ bundle_selling_price: (_ref5 = (_item$bundle_selling_ = item.bundle_selling_price) !== null && _item$bundle_selling_ !== void 0 ? _item$bundle_selling_ : item.price) !== null && _ref5 !== void 0 ? _ref5 : '0.00',
519
+ price: (_ref6 = (_ref7 = (_item$price2 = item.price) !== null && _item$price2 !== void 0 ? _item$price2 : item.custom_price) !== null && _ref7 !== void 0 ? _ref7 : item.bundle_selling_price) !== null && _ref6 !== void 0 ? _ref6 : '0.00',
520
+ price_type: (_ref8 = (_item$price_type = item.price_type) !== null && _item$price_type !== void 0 ? _item$price_type : item.custom_price_type) !== null && _ref8 !== void 0 ? _ref8 : '',
521
+ price_type_ext: (_ref9 = (_item$price_type_ext = item.price_type_ext) !== null && _item$price_type_ext !== void 0 ? _item$price_type_ext : item.custom_price_type_ext) !== null && _ref9 !== void 0 ? _ref9 : ''
522
522
  });
523
523
  });
524
- var normalizedOptions = product.product_option_item || [];
524
+ var normalizedOptions = normalizeProductSkuOptions((_product$product_sku = product.product_sku) === null || _product$product_sku === void 0 ? void 0 : _product$product_sku.option);
525
525
  var optionSum = sumOptionUnitPrice(normalizedOptions);
526
+ var productSku = _objectSpread(_objectSpread({}, ensureProductSku(product)), {}, {
527
+ option: normalizedOptions
528
+ });
526
529
 
527
530
  // 1) 解析 source_product_price。
528
531
  // 优先级:
@@ -538,7 +541,7 @@ export function normalizeOrderProduct(product) {
538
541
  var variantPrice = Array.isArray(variantList) ? (_variantList$find = variantList.find(function (v) {
539
542
  return Number(v === null || v === void 0 ? void 0 : v.id) === variantId;
540
543
  })) === null || _variantList$find === void 0 ? void 0 : _variantList$find.price : undefined;
541
- var resolvedSource = function (_product$_origin, _product$_origin2, _ref9, _product$original_pri) {
544
+ var resolvedSource = function (_product$_origin, _product$_origin2, _ref10, _product$original_pri) {
542
545
  if (metadata.source_product_price !== undefined) {
543
546
  return String(metadata.source_product_price);
544
547
  }
@@ -556,7 +559,7 @@ export function normalizeOrderProduct(product) {
556
559
  if (!isV2 && metadata.main_product_original_price !== undefined) {
557
560
  return String(metadata.main_product_original_price);
558
561
  }
559
- return (_ref9 = (_product$original_pri = product.original_price) !== null && _product$original_pri !== void 0 ? _product$original_pri : product.selling_price) !== null && _ref9 !== void 0 ? _ref9 : '0.00';
562
+ return (_ref10 = (_product$original_pri = product.original_price) !== null && _product$original_pri !== void 0 ? _product$original_pri : product.selling_price) !== null && _ref10 !== void 0 ? _ref10 : '0.00';
560
563
  }();
561
564
 
562
565
  // 2) 派生 main_product_original_price(含 option、不含折扣)
@@ -625,7 +628,7 @@ export function normalizeOrderProduct(product) {
625
628
  product_id: product.product_id,
626
629
  num: getSafeProductNum(product.num),
627
630
  product_variant_id: product.product_variant_id,
628
- product_option_item: normalizedOptions,
631
+ product_sku: productSku,
629
632
  selling_price: composedSellingPrice,
630
633
  original_price: manualOriginalPrice,
631
634
  tax_fee: product.tax_fee || '0.00',
@@ -45,7 +45,7 @@ import { extractResourceIds, buildResourceProductMap } from "./utils/resource";
45
45
  import { buildTimeSlotGrid, isBusinessHoursCrossDay, generateTimeLabels } from "./utils/timeSlot";
46
46
  import { buildDateRangeSummary } from "./utils/dateSummary";
47
47
  import { mergeConsecutiveSlots, expandMergedSlotToIndividual, buildVenueIdentityKey, buildVenueBookingEntry, buildVenueResourceMetadata, buildPriceBreakdown } from "./utils/slotMerge";
48
- import { composeLinePrice, createUuidV4, sumOptionUnitPrice } from "../../modules/Order/utils";
48
+ import { composeLinePrice, createUuidV4, getProductSkuOptions, sumOptionUnitPrice } from "../../modules/Order/utils";
49
49
  import { OrderModule } from "../../modules/Order";
50
50
  import { RegisterAndLoginHooks } from "../RegisterAndLogin/types";
51
51
  import Decimal from 'decimal.js';
@@ -1726,7 +1726,9 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
1726
1726
  product_variant_id: 0,
1727
1727
  num: 1,
1728
1728
  product_bundle: [],
1729
- product_option_item: [],
1729
+ product_sku: {
1730
+ option: []
1731
+ },
1730
1732
  discount_list: [],
1731
1733
  custom_deposit_data: customDepositData,
1732
1734
  metadata: {}
@@ -2183,7 +2185,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
2183
2185
  totalPerUnitDiscount = (product.discount_list || []).reduce(function (sum, pd) {
2184
2186
  return sum + (pd.amount || 0);
2185
2187
  }, 0);
2186
- optionSum = sumOptionUnitPrice(product.product_option_item);
2188
+ optionSum = sumOptionUnitPrice(getProductSkuOptions(product));
2187
2189
  sourcePrice = (_product$metadata$sou = (_product$metadata3 = product.metadata) === null || _product$metadata3 === void 0 ? void 0 : _product$metadata3.source_product_price) !== null && _product$metadata$sou !== void 0 ? _product$metadata$sou : ((_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4.main_product_original_price) != null ? new Decimal(Number(product.metadata.main_product_original_price) || 0).minus(optionSum).toFixed(2) : (_product$original_pri = product.original_price) !== null && _product$original_pri !== void 0 ? _product$original_pri : '0';
2188
2190
  newSourceSellingPrice = new Decimal(Number(sourcePrice) || 0).minus(totalPerUnitDiscount).toDecimalPlaces(2).toString();
2189
2191
  newMainSellingPrice = new Decimal(Number(newSourceSellingPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
@@ -71,8 +71,6 @@
71
71
  "num__comment": "数量;int;↕;必填。统一使用 num,不再使用 product_quantity。",
72
72
  "product_variant_id": 0,
73
73
  "product_variant_id__comment": "多规格 ID;int;↕;可选。",
74
- "product_option_item": [],
75
- "product_option_item__comment": "选项配置;array;↕;可选。",
76
74
  "selling_price": "50.00",
77
75
  "selling_price__comment": "销售单价(交易快照);string;←;服务端返回,不能依赖基准数据回填。",
78
76
  "original_price": "60.00",
@@ -1,49 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
-
29
- // src/model/strategy/adapter/promotion/index.ts
30
- var promotion_exports = {};
31
- __export(promotion_exports, {
32
- BUY_X_GET_Y_FREE_STRATEGY: () => import_examples.BUY_X_GET_Y_FREE_STRATEGY,
33
- PromotionAdapter: () => import_adapter.PromotionAdapter,
34
- PromotionEvaluator: () => import_evaluator.PromotionEvaluator,
35
- X_ITEMS_FOR_Y_PRICE_STRATEGY: () => import_examples.X_ITEMS_FOR_Y_PRICE_STRATEGY,
36
- default: () => import_adapter2.default
37
- });
38
- module.exports = __toCommonJS(promotion_exports);
39
- var import_evaluator = require("./evaluator");
40
- var import_adapter = require("./adapter");
41
- var import_adapter2 = __toESM(require("./adapter"));
42
- var import_examples = require("./examples");
43
- // Annotate the CommonJS export names for ESM import in node:
44
- 0 && (module.exports = {
45
- BUY_X_GET_Y_FREE_STRATEGY,
46
- PromotionAdapter,
47
- PromotionEvaluator,
48
- X_ITEMS_FOR_Y_PRICE_STRATEGY
49
- });
@@ -33,6 +33,7 @@ __export(buildCacheItemFromOrderLine_exports, {
33
33
  });
34
34
  module.exports = __toCommonJS(buildCacheItemFromOrderLine_exports);
35
35
  var import_dayjs = __toESM(require("dayjs"));
36
+ var import_utils = require("../../Order/utils");
36
37
  var import_manualProductDiscount = require("../../Order/utils/manualProductDiscount");
37
38
  var import_orderLineDisplay = require("./orderLineDisplay");
38
39
  function safeFormat(value, fmt) {
@@ -182,7 +183,7 @@ function buildCacheItemFromOrderLine(input) {
182
183
  const productOptionString = (0, import_orderLineDisplay.buildProductOptionStringFromOrderLine)(product);
183
184
  const other = {
184
185
  product_variant_id: product.product_variant_id ?? 0,
185
- option: Array.isArray(product.product_option_item) ? [...product.product_option_item] : [],
186
+ option: (0, import_utils.getProductSkuOptions)(product),
186
187
  bundle: Array.isArray(product.product_bundle) ? [...product.product_bundle] : []
187
188
  };
188
189
  const extend = {
@@ -22,6 +22,7 @@ __export(buildNormalProductCacheItemFromOrderLine_exports, {
22
22
  buildNormalProductCacheItemFromOrderLine: () => buildNormalProductCacheItemFromOrderLine
23
23
  });
24
24
  module.exports = __toCommonJS(buildNormalProductCacheItemFromOrderLine_exports);
25
+ var import_utils = require("../../Order/utils");
25
26
  var import_orderLineDisplay = require("./orderLineDisplay");
26
27
  function resolveSourceProductPrice(product, sourceProduct) {
27
28
  var _a, _b, _c;
@@ -81,7 +82,7 @@ function buildNormalProductCacheItemFromOrderLine(input) {
81
82
  const selling = Number(product.selling_price ?? 0);
82
83
  const original = Number(product.original_price ?? selling);
83
84
  const uid = (_a = product.metadata) == null ? void 0 : _a.unique_identification_number;
84
- const option = Array.isArray(product.product_option_item) ? [...product.product_option_item] : [];
85
+ const option = (0, import_utils.getProductSkuOptions)(product);
85
86
  const bundle = mapOrderBundleToOtherBundle(
86
87
  Array.isArray(product.product_bundle) ? product.product_bundle : []
87
88
  );
@@ -185,7 +185,7 @@ var formatProductToCartItemOrigin = (params) => {
185
185
  product_id: product.id,
186
186
  product_variant_id: product_variant_id || 0,
187
187
  product_bundle: ((_b = origin.product) == null ? void 0 : _b.product_bundle) || [],
188
- product_option_item: ((_c = origin.product) == null ? void 0 : _c.product_option_item) || [],
188
+ product_sku: ((_c = origin.product) == null ? void 0 : _c.product_sku) || { option: [] },
189
189
  metadata: {
190
190
  product_discount_difference
191
191
  }
@@ -196,7 +196,14 @@ var formatProductToCartItemOrigin = (params) => {
196
196
  origin.product.product_bundle = formatBundleToOrigin(bundle);
197
197
  }
198
198
  if (options == null ? void 0 : options.length) {
199
- origin.product.product_option_item = formatOptionsToOrigin(options);
199
+ origin.product.product_sku = {
200
+ ...origin.product.product_sku || {},
201
+ option: formatOptionsToOrigin(options).map((option) => {
202
+ const next = { ...option, add_price: option.add_price ?? option.price };
203
+ delete next.price;
204
+ return next;
205
+ })
206
+ };
200
207
  }
201
208
  }
202
209
  return origin;
@@ -265,7 +265,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
265
265
  private logSubmitBackendRejected;
266
266
  syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
267
267
  createOrder(params: CommitOrderParams['query']): {
268
- type: "virtual" | "appointment_booking";
268
+ type: "appointment_booking" | "virtual";
269
269
  platform: string;
270
270
  sales_channel: string;
271
271
  order_sales_channel: string;
@@ -317,8 +317,6 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
317
317
  private formatHydratedNamePair;
318
318
  private buildHydratedProductOptionString;
319
319
  private normalizeHydratedProductOptionItem;
320
- private mergeHydratedProductOptionDisplayFields;
321
- private resolveHydratedProductOptions;
322
320
  private normalizeHydratedOrderProduct;
323
321
  getLastOrderInfo(): Record<string, any> | undefined;
324
322
  getOrderInfo(order_id: number): Promise<any>;
@@ -109,7 +109,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
109
109
  if ((_a = product.metadata) == null ? void 0 : _a.is_manual_discount)
110
110
  return product;
111
111
  const totalPerUnitDiscount = (0, import_utils.resolveEffectivePerUnitDiscount)(product);
112
- const optionSum = (0, import_utils.sumOptionUnitPrice)(product.product_option_item);
112
+ const optionSum = (0, import_utils.sumOptionUnitPrice)((0, import_utils.getProductSkuOptions)(product));
113
113
  const sourcePrice = ((_b = product.metadata) == null ? void 0 : _b.source_product_price) ?? (((_c = product.metadata) == null ? void 0 : _c.main_product_original_price) != null ? new import_decimal.default(Number(product.metadata.main_product_original_price) || 0).minus(optionSum).toFixed(2) : product.original_price ?? "0");
114
114
  const newSourceSellingPrice = new import_decimal.default(Number(sourcePrice) || 0).minus(totalPerUnitDiscount).toDecimalPlaces(2).toString();
115
115
  const newMainSellingPrice = new import_decimal.default(Number(newSourceSellingPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
@@ -1449,7 +1449,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
1449
1449
  const linked = booking ? this.createLinkedProductAndBooking({ product, booking }) : null;
1450
1450
  const productToAdd = (linked == null ? void 0 : linked.product) || product;
1451
1451
  const incomingFingerprint = (0, import_utils3.buildProductLineFingerprint)(
1452
- productToAdd.product_option_item,
1452
+ (0, import_utils.getProductSkuOptions)(productToAdd),
1453
1453
  productToAdd.product_bundle
1454
1454
  );
1455
1455
  const normalizedIncoming = (0, import_utils.mergeOrderProductDisplayFields)(
@@ -1471,14 +1471,14 @@ var OrderModule = class extends import_BaseModule.BaseModule {
1471
1471
  if (item.product_variant_id !== productToAdd.product_variant_id)
1472
1472
  return false;
1473
1473
  const existedFingerprint2 = (0, import_utils3.buildProductLineFingerprint)(
1474
- item.product_option_item,
1474
+ (0, import_utils.getProductSkuOptions)(item),
1475
1475
  item.product_bundle
1476
1476
  );
1477
1477
  return existedFingerprint2 === incomingFingerprint;
1478
1478
  });
1479
1479
  const matchedProduct = matchedIndex === -1 ? null : tempOrder.products[matchedIndex];
1480
1480
  const existedFingerprint = matchedProduct ? (0, import_utils3.buildProductLineFingerprint)(
1481
- matchedProduct.product_option_item,
1481
+ (0, import_utils.getProductSkuOptions)(matchedProduct),
1482
1482
  matchedProduct.product_bundle
1483
1483
  ) : "";
1484
1484
  const shouldMerge = matchedProduct ? await this.shouldMergeProductToOrder({
@@ -1529,6 +1529,11 @@ var OrderModule = class extends import_BaseModule.BaseModule {
1529
1529
  ...normalizedProduct.metadata || {},
1530
1530
  unique_identification_number: targetUid
1531
1531
  },
1532
+ product_sku: {
1533
+ ...targetProduct.product_sku || { option: [] },
1534
+ ...normalizedProduct.product_sku || { option: [] },
1535
+ option: (0, import_utils.getProductSkuOptions)(normalizedProduct)
1536
+ },
1532
1537
  note: targetProduct.note,
1533
1538
  order_detail_id: targetProduct.order_detail_id,
1534
1539
  num: (0, import_utils3.getSafeProductNum)(targetProduct.num + normalizedProduct.num)
@@ -1568,14 +1573,14 @@ var OrderModule = class extends import_BaseModule.BaseModule {
1568
1573
  );
1569
1574
  }
1570
1575
  async updateOrderProduct(params) {
1571
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
1576
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
1572
1577
  const {
1573
1578
  product_id,
1574
1579
  product_variant_id,
1575
1580
  updates,
1576
1581
  unique_identification_number,
1577
1582
  identity_key,
1578
- product_option_item,
1583
+ product_sku,
1579
1584
  product_bundle,
1580
1585
  booking
1581
1586
  } = params;
@@ -1593,8 +1598,8 @@ var OrderModule = class extends import_BaseModule.BaseModule {
1593
1598
  if (identity_key !== void 0) {
1594
1599
  identityLookup.identity_key = identity_key;
1595
1600
  }
1596
- if (product_option_item !== void 0)
1597
- identityLookup.product_option_item = product_option_item;
1601
+ if (product_sku !== void 0)
1602
+ identityLookup.product_sku = product_sku;
1598
1603
  if (product_bundle !== void 0)
1599
1604
  identityLookup.product_bundle = product_bundle;
1600
1605
  let productIndex = -1;
@@ -1623,23 +1628,28 @@ var OrderModule = class extends import_BaseModule.BaseModule {
1623
1628
  ...targetProduct.metadata || {},
1624
1629
  ...(updates == null ? void 0 : updates.metadata) || {},
1625
1630
  unique_identification_number: ((_a = targetProduct.metadata) == null ? void 0 : _a.unique_identification_number) || unique_identification_number
1631
+ },
1632
+ product_sku: {
1633
+ ...targetProduct.product_sku || { option: [] },
1634
+ ...(updates == null ? void 0 : updates.product_sku) && typeof updates.product_sku === "object" ? updates.product_sku : {},
1635
+ option: Array.isArray((_b = updates == null ? void 0 : updates.product_sku) == null ? void 0 : _b.option) ? updates.product_sku.option : (0, import_utils.getProductSkuOptions)(targetProduct)
1626
1636
  }
1627
1637
  };
1628
1638
  nextProduct.num = (0, import_utils3.getSafeProductNum)(nextProduct.num);
1629
1639
  const callerUpdatesTopPrice = Object.prototype.hasOwnProperty.call(updates || {}, "selling_price") || Object.prototype.hasOwnProperty.call(updates || {}, "original_price");
1630
- const callerUpdatesMainMeta = ((_b = updates == null ? void 0 : updates.metadata) == null ? void 0 : _b.main_product_selling_price) !== void 0 || ((_c = updates == null ? void 0 : updates.metadata) == null ? void 0 : _c.main_product_original_price) !== void 0 || ((_d = updates == null ? void 0 : updates.metadata) == null ? void 0 : _d.source_product_price) !== void 0;
1640
+ const callerUpdatesMainMeta = ((_c = updates == null ? void 0 : updates.metadata) == null ? void 0 : _c.main_product_selling_price) !== void 0 || ((_d = updates == null ? void 0 : updates.metadata) == null ? void 0 : _d.main_product_original_price) !== void 0 || ((_e = updates == null ? void 0 : updates.metadata) == null ? void 0 : _e.source_product_price) !== void 0;
1631
1641
  const isPersistedOrderLine = targetProduct.order_detail_id !== void 0 && targetProduct.order_detail_id !== null;
1632
- const callerUpdatesManualPrice = ((_e = updates == null ? void 0 : updates.metadata) == null ? void 0 : _e.price_override) !== void 0 || ((_f = updates == null ? void 0 : updates.metadata) == null ? void 0 : _f.is_manual_discount) !== void 0 || ((_g = updates == null ? void 0 : updates.metadata) == null ? void 0 : _g.product_discount_reason) !== void 0 || Array.isArray(updates == null ? void 0 : updates.discount_list) && updates.discount_list.length > 0;
1642
+ const callerUpdatesManualPrice = ((_f = updates == null ? void 0 : updates.metadata) == null ? void 0 : _f.price_override) !== void 0 || ((_g = updates == null ? void 0 : updates.metadata) == null ? void 0 : _g.is_manual_discount) !== void 0 || ((_h = updates == null ? void 0 : updates.metadata) == null ? void 0 : _h.product_discount_reason) !== void 0 || Array.isArray(updates == null ? void 0 : updates.discount_list) && updates.discount_list.length > 0;
1633
1643
  if (isPersistedOrderLine && !callerUpdatesManualPrice) {
1634
1644
  nextProduct.selling_price = targetProduct.selling_price;
1635
1645
  nextProduct.original_price = targetProduct.original_price;
1636
1646
  nextProduct.payment_price = targetProduct.payment_price;
1637
1647
  nextProduct.metadata = {
1638
1648
  ...nextProduct.metadata || {},
1639
- source_product_price: (_h = targetProduct.metadata) == null ? void 0 : _h.source_product_price,
1640
- main_product_selling_price: (_i = targetProduct.metadata) == null ? void 0 : _i.main_product_selling_price,
1641
- main_product_original_price: (_j = targetProduct.metadata) == null ? void 0 : _j.main_product_original_price,
1642
- price_schema_version: (_k = targetProduct.metadata) == null ? void 0 : _k.price_schema_version
1649
+ source_product_price: (_i = targetProduct.metadata) == null ? void 0 : _i.source_product_price,
1650
+ main_product_selling_price: (_j = targetProduct.metadata) == null ? void 0 : _j.main_product_selling_price,
1651
+ main_product_original_price: (_k = targetProduct.metadata) == null ? void 0 : _k.main_product_original_price,
1652
+ price_schema_version: (_l = targetProduct.metadata) == null ? void 0 : _l.price_schema_version
1643
1653
  };
1644
1654
  } else if (callerUpdatesTopPrice && !callerUpdatesMainMeta) {
1645
1655
  const existedMeta = nextProduct.metadata || {};
@@ -1656,7 +1666,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
1656
1666
  normalizedProduct.discount_list = (0, import_utils.normalizeOrderProductDiscountList)(
1657
1667
  normalizedProduct.discount_list
1658
1668
  );
1659
- const preservedBookingUid = nextProduct.booking_uid || ((_l = nextProduct.metadata) == null ? void 0 : _l.booking_uid) || targetProduct.booking_uid || ((_m = targetProduct.metadata) == null ? void 0 : _m.booking_uid);
1669
+ const preservedBookingUid = nextProduct.booking_uid || ((_m = nextProduct.metadata) == null ? void 0 : _m.booking_uid) || targetProduct.booking_uid || ((_n = targetProduct.metadata) == null ? void 0 : _n.booking_uid);
1660
1670
  if (!booking && preservedBookingUid) {
1661
1671
  normalizedProduct.booking_uid = preservedBookingUid;
1662
1672
  normalizedProduct.metadata = {
@@ -1666,7 +1676,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
1666
1676
  }
1667
1677
  if (booking) {
1668
1678
  const productUid = String(
1669
- ((_n = normalizedProduct.metadata) == null ? void 0 : _n.unique_identification_number) || ((_o = targetProduct.metadata) == null ? void 0 : _o.unique_identification_number) || unique_identification_number || (0, import_utils.createUuidV4)()
1679
+ ((_o = normalizedProduct.metadata) == null ? void 0 : _o.unique_identification_number) || ((_p = targetProduct.metadata) == null ? void 0 : _p.unique_identification_number) || unique_identification_number || (0, import_utils.createUuidV4)()
1670
1680
  );
1671
1681
  normalizedProduct.metadata = {
1672
1682
  ...normalizedProduct.metadata || {},
@@ -1696,7 +1706,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
1696
1706
  tempOrder,
1697
1707
  updates,
1698
1708
  tempOrder.products[productIndex],
1699
- (_p = tempOrder.products[productIndex].metadata) == null ? void 0 : _p.unique_identification_number
1709
+ (_q = tempOrder.products[productIndex].metadata) == null ? void 0 : _q.unique_identification_number
1700
1710
  );
1701
1711
  await this.applyPromotion();
1702
1712
  this.applyDiscount();
@@ -1712,7 +1722,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
1712
1722
  num,
1713
1723
  unique_identification_number,
1714
1724
  identity_key,
1715
- product_option_item,
1725
+ product_sku,
1716
1726
  product_bundle
1717
1727
  } = params;
1718
1728
  const tempOrder = this.ensureTempOrder();
@@ -1728,8 +1738,8 @@ var OrderModule = class extends import_BaseModule.BaseModule {
1728
1738
  }
1729
1739
  if (identity_key !== void 0)
1730
1740
  identityLookup.identity_key = identity_key;
1731
- if (product_option_item !== void 0)
1732
- identityLookup.product_option_item = product_option_item;
1741
+ if (product_sku !== void 0)
1742
+ identityLookup.product_sku = product_sku;
1733
1743
  if (product_bundle !== void 0)
1734
1744
  identityLookup.product_bundle = product_bundle;
1735
1745
  let productIndex = -1;
@@ -2404,14 +2414,16 @@ var OrderModule = class extends import_BaseModule.BaseModule {
2404
2414
  normalizeHydratedProductOptionItem(optionItem) {
2405
2415
  const rawNum = (optionItem == null ? void 0 : optionItem.num) ?? (optionItem == null ? void 0 : optionItem.quantity) ?? 1;
2406
2416
  const parsedNum = Number(rawNum);
2407
- const rawPrice = (optionItem == null ? void 0 : optionItem.price) ?? (optionItem == null ? void 0 : optionItem.add_price) ?? 0;
2417
+ const rawPrice = (optionItem == null ? void 0 : optionItem.add_price) ?? (optionItem == null ? void 0 : optionItem.price) ?? 0;
2408
2418
  const parsedPrice = Number(rawPrice);
2409
2419
  const normalized = {
2420
+ ...optionItem,
2410
2421
  option_group_item_id: optionItem == null ? void 0 : optionItem.option_group_item_id,
2411
2422
  option_group_id: optionItem == null ? void 0 : optionItem.option_group_id,
2412
2423
  num: Number.isFinite(parsedNum) && parsedNum > 0 ? parsedNum : 1,
2413
- price: Number.isFinite(parsedPrice) ? parsedPrice : 0
2424
+ add_price: Number.isFinite(parsedPrice) ? parsedPrice : 0
2414
2425
  };
2426
+ delete normalized.price;
2415
2427
  if ((optionItem == null ? void 0 : optionItem.name) !== void 0)
2416
2428
  normalized.name = optionItem.name;
2417
2429
  if ((optionItem == null ? void 0 : optionItem.group_name) !== void 0)
@@ -2420,46 +2432,21 @@ var OrderModule = class extends import_BaseModule.BaseModule {
2420
2432
  normalized.id = optionItem.id;
2421
2433
  return normalized;
2422
2434
  }
2423
- mergeHydratedProductOptionDisplayFields(options, skuOptions) {
2424
- if (!Array.isArray(skuOptions) || skuOptions.length === 0)
2425
- return options;
2426
- const displayByItemId = /* @__PURE__ */ new Map();
2427
- for (const option of skuOptions) {
2428
- const key = option == null ? void 0 : option.option_group_item_id;
2429
- if (key === void 0 || key === null || key === "")
2430
- continue;
2431
- displayByItemId.set(String(key), option);
2432
- }
2433
- return options.map((option) => {
2434
- const display = displayByItemId.get(String((option == null ? void 0 : option.option_group_item_id) ?? ""));
2435
- if (!display)
2436
- return option;
2437
- return {
2438
- ...option,
2439
- ...option.name === void 0 && display.name !== void 0 ? { name: display.name } : {},
2440
- ...option.group_name === void 0 && display.group_name !== void 0 ? { group_name: display.group_name } : {},
2441
- ...option.id === void 0 && display.id !== void 0 ? { id: display.id } : {}
2442
- };
2443
- });
2444
- }
2445
- resolveHydratedProductOptions(row) {
2446
- var _a;
2447
- const skuOptions = (_a = row.product_sku) == null ? void 0 : _a.option;
2448
- if (Array.isArray(row.product_option_item) && row.product_option_item.length > 0) {
2449
- return this.mergeHydratedProductOptionDisplayFields(row.product_option_item, skuOptions);
2450
- }
2451
- if (!Array.isArray(skuOptions))
2452
- return [];
2453
- return skuOptions.map(
2454
- (optionItem) => this.normalizeHydratedProductOptionItem(optionItem || {})
2455
- );
2456
- }
2457
2435
  normalizeHydratedOrderProduct(product) {
2458
2436
  const row = { ...product || {} };
2459
2437
  if (row.num === void 0 && row.product_quantity !== void 0) {
2460
2438
  row.num = row.product_quantity;
2461
2439
  }
2462
- row.product_option_item = this.resolveHydratedProductOptions(row);
2440
+ const productSku = (0, import_utils.ensureProductSku)(row);
2441
+ row.product_sku = {
2442
+ ...productSku,
2443
+ option: (0, import_utils.normalizeProductSkuOptions)(
2444
+ productSku.option.map(
2445
+ (optionItem) => this.normalizeHydratedProductOptionItem(optionItem || {})
2446
+ )
2447
+ )
2448
+ };
2449
+ delete row[`product_${"option"}_item`];
2463
2450
  if (!Array.isArray(row.product_bundle))
2464
2451
  row.product_bundle = [];
2465
2452
  if (!row.metadata || typeof row.metadata !== "object")
@@ -2478,7 +2465,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
2478
2465
  const result = {
2479
2466
  ...row,
2480
2467
  ...normalized,
2481
- product_sku: row.product_sku,
2468
+ product_sku: normalized.product_sku,
2482
2469
  metadata: {
2483
2470
  ...row.metadata,
2484
2471
  ...normalized.metadata
@@ -161,15 +161,18 @@ export interface OrderProductIdentity {
161
161
  product_id: number | null;
162
162
  product_variant_id: number;
163
163
  unique_identification_number?: string;
164
- product_option_item?: any[];
164
+ product_sku?: OrderProductSku;
165
165
  product_bundle?: any[];
166
166
  }
167
+ export interface OrderProductSku {
168
+ option: any[];
169
+ [key: string]: any;
170
+ }
167
171
  export interface OrderProduct extends OrderProductIdentity {
168
172
  order_detail_id: number | null;
169
173
  num: number;
170
174
  bundle_edit?: number;
171
- product_option_item: any[];
172
- product_sku?: Record<string, any>;
175
+ product_sku: OrderProductSku;
173
176
  gift_card?: number;
174
177
  selling_price: string;
175
178
  original_price: string;
@@ -262,10 +265,10 @@ export interface OrderTempOrder {
262
265
  [key: string]: any;
263
266
  };
264
267
  }
265
- export interface OrderSubmitProduct extends Omit<OrderProduct, 'unique_identification_number' | 'num' | 'product_option_item'> {
268
+ export interface OrderSubmitProduct extends Omit<OrderProduct, 'unique_identification_number' | 'num'> {
266
269
  product_quantity: number;
267
270
  payment_price: string;
268
- product_sku: Record<string, any>;
271
+ product_sku: OrderProductSku;
269
272
  }
270
273
  export interface OrderSubmitPayload extends Omit<OrderTempOrder, 'platform' | 'products' | '_extend' | 'customer' | 'discount_list' | 'created_at'> {
271
274
  platform: string;
@@ -300,7 +303,7 @@ export interface UpdateOrderProductParams {
300
303
  updates: Partial<OrderProduct>;
301
304
  unique_identification_number?: string;
302
305
  identity_key?: string;
303
- product_option_item?: any[];
306
+ product_sku?: OrderProductSku;
304
307
  product_bundle?: any[];
305
308
  booking?: AddProductBookingInput;
306
309
  }
@@ -28,11 +28,18 @@ export declare function composeLinePrice(params: {
28
28
  }> | null;
29
29
  useOriginalBundle?: boolean;
30
30
  }): string;
31
+ export declare function normalizeProductSkuOptions(options?: unknown): Record<string, any>[];
32
+ export declare function ensureProductSku(product?: Record<string, any> | null): Record<string, any> & {
33
+ option: Record<string, any>[];
34
+ };
35
+ export declare function getProductSkuOptions(product?: Record<string, any> | null): Record<string, any>[];
31
36
  /**
32
- * 计算 option 单价合计:Σ(option.price × option.num)。
37
+ * 计算 option 单价合计:Σ(option.add_price × option.num)。
38
+ * 兼容入参仍带旧 `price` 的调用方,但运行时归一化后只维护 `add_price`。
33
39
  * 在新语义 v2 下,main_product_original_price = source_product_price + 本函数结果。
34
40
  */
35
41
  export declare function sumOptionUnitPrice(options?: Array<{
42
+ add_price?: any;
36
43
  price?: any;
37
44
  num?: any;
38
45
  }> | null): Decimal;
@@ -162,7 +169,7 @@ export declare function mapPaymentItemsToOrderPayments(paymentItems: OrderPaymen
162
169
  export declare function formatV1Product(products: OrderSubmitProduct[]): {
163
170
  bundle: any[];
164
171
  key: number | null;
165
- option: any;
172
+ option: any[];
166
173
  product_id: number | null;
167
174
  product_variant_id: number;
168
175
  num: number;