@pisell/pisellos 2.2.252 → 2.2.254

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 (52) hide show
  1. package/dist/model/strategy/adapter/promotion/index.js +0 -9
  2. package/dist/modules/Order/index.d.ts +9 -0
  3. package/dist/modules/Order/index.js +448 -369
  4. package/dist/modules/Order/types.d.ts +2 -0
  5. package/dist/modules/Quotation/index.d.ts +16 -2
  6. package/dist/modules/Quotation/index.js +71 -38
  7. package/dist/modules/Quotation/types.d.ts +14 -0
  8. package/dist/modules/Rules/index.js +6 -4
  9. package/dist/modules/SalesSummary/index.d.ts +1 -0
  10. package/dist/modules/SalesSummary/index.js +7 -4
  11. package/dist/modules/Schedule/index.d.ts +4 -0
  12. package/dist/modules/Schedule/index.js +31 -1
  13. package/dist/modules/Schedule/types.d.ts +2 -0
  14. package/dist/server/index.js +13 -13
  15. package/dist/server/modules/products/index.d.ts +4 -0
  16. package/dist/server/modules/products/index.js +76 -45
  17. package/dist/server/modules/quotation/index.d.ts +39 -0
  18. package/dist/server/modules/quotation/index.js +278 -66
  19. package/dist/server/modules/schedule/index.d.ts +2 -0
  20. package/dist/server/modules/schedule/index.js +10 -2
  21. package/dist/solution/BaseSales/index.d.ts +10 -1
  22. package/dist/solution/BaseSales/index.js +825 -528
  23. package/dist/solution/BaseSales/types.d.ts +7 -0
  24. package/dist/solution/BaseSales/utils/quotationPrice.d.ts +12 -1
  25. package/dist/solution/BaseSales/utils/quotationPrice.js +16 -3
  26. package/dist/solution/BookingByStep/index.d.ts +1 -1
  27. package/lib/modules/Order/index.d.ts +9 -0
  28. package/lib/modules/Order/index.js +48 -7
  29. package/lib/modules/Order/types.d.ts +2 -0
  30. package/lib/modules/Quotation/index.d.ts +16 -2
  31. package/lib/modules/Quotation/index.js +49 -13
  32. package/lib/modules/Quotation/types.d.ts +14 -0
  33. package/lib/modules/Rules/index.js +6 -4
  34. package/lib/modules/SalesSummary/index.d.ts +1 -0
  35. package/lib/modules/SalesSummary/index.js +4 -3
  36. package/lib/modules/Schedule/index.d.ts +4 -0
  37. package/lib/modules/Schedule/index.js +21 -0
  38. package/lib/modules/Schedule/types.d.ts +2 -0
  39. package/lib/server/index.js +1 -1
  40. package/lib/server/modules/products/index.d.ts +4 -0
  41. package/lib/server/modules/products/index.js +43 -19
  42. package/lib/server/modules/quotation/index.d.ts +39 -0
  43. package/lib/server/modules/quotation/index.js +179 -1
  44. package/lib/server/modules/schedule/index.d.ts +2 -0
  45. package/lib/server/modules/schedule/index.js +8 -1
  46. package/lib/solution/BaseSales/index.d.ts +10 -1
  47. package/lib/solution/BaseSales/index.js +218 -19
  48. package/lib/solution/BaseSales/types.d.ts +7 -0
  49. package/lib/solution/BaseSales/utils/quotationPrice.d.ts +12 -1
  50. package/lib/solution/BaseSales/utils/quotationPrice.js +15 -3
  51. package/lib/solution/BookingByStep/index.d.ts +1 -1
  52. package/package.json +1 -1
@@ -3619,153 +3619,164 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3619
3619
  });
3620
3620
  });
3621
3621
  }
3622
+ }, {
3623
+ key: "applyOrderProductUpdateToTempOrder",
3624
+ value: function applyOrderProductUpdateToTempOrder(tempOrder, params) {
3625
+ var _targetProduct$metada2, _product_sku, _metadata2, _metadata3, _metadata4, _metadata5, _metadata6, _metadata7, _nextProduct$metadata, _targetProduct$metada8, _tempOrder$products$p;
3626
+ var product_id = params.product_id,
3627
+ product_variant_id = params.product_variant_id,
3628
+ updates = params.updates,
3629
+ unique_identification_number = params.unique_identification_number,
3630
+ identity_key = params.identity_key,
3631
+ product_sku = params.product_sku,
3632
+ product_bundle = params.product_bundle,
3633
+ booking = params.booking;
3634
+ var identityLookup = {
3635
+ product_id: product_id,
3636
+ product_variant_id: product_variant_id
3637
+ };
3638
+ if (unique_identification_number !== undefined) {
3639
+ identityLookup.unique_identification_number = unique_identification_number;
3640
+ if (identity_key === undefined) {
3641
+ identityLookup.identity_key = unique_identification_number;
3642
+ }
3643
+ }
3644
+ if (identity_key !== undefined) {
3645
+ identityLookup.identity_key = identity_key;
3646
+ }
3647
+ if (product_sku !== undefined) identityLookup.product_sku = product_sku;
3648
+ if (product_bundle !== undefined) identityLookup.product_bundle = product_bundle;
3649
+ var productIndex = -1;
3650
+ if (unique_identification_number !== undefined) {
3651
+ var targetUid = String(unique_identification_number);
3652
+ productIndex = tempOrder.products.findIndex(function (item) {
3653
+ var _item$metadata3;
3654
+ return String(((_item$metadata3 = item.metadata) === null || _item$metadata3 === void 0 ? void 0 : _item$metadata3.unique_identification_number) || item.unique_identification_number || '') === targetUid;
3655
+ });
3656
+ }
3657
+ if (productIndex === -1) {
3658
+ productIndex = getProductIdentityIndex(tempOrder.products, identityLookup);
3659
+ }
3660
+ if (productIndex === -1) {
3661
+ throw new Error('[Order] 目标商品不存在,无法更新');
3662
+ }
3663
+ var targetProduct = tempOrder.products[productIndex];
3664
+ var nextProduct = _objectSpread(_objectSpread(_objectSpread({}, targetProduct), updates), {}, {
3665
+ product_id: product_id,
3666
+ product_variant_id: product_variant_id,
3667
+ metadata: _objectSpread(_objectSpread(_objectSpread({}, targetProduct.metadata || {}), (updates === null || updates === void 0 ? void 0 : updates.metadata) || {}), {}, {
3668
+ unique_identification_number: ((_targetProduct$metada2 = targetProduct.metadata) === null || _targetProduct$metada2 === void 0 ? void 0 : _targetProduct$metada2.unique_identification_number) || unique_identification_number
3669
+ }),
3670
+ product_sku: _objectSpread(_objectSpread(_objectSpread({}, targetProduct.product_sku || {
3671
+ option: []
3672
+ }), updates !== null && updates !== void 0 && updates.product_sku && _typeof(updates.product_sku) === 'object' ? updates.product_sku : {}), {}, {
3673
+ option: Array.isArray(updates === null || updates === void 0 || (_product_sku = updates.product_sku) === null || _product_sku === void 0 ? void 0 : _product_sku.option) ? updates.product_sku.option : getProductSkuOptions(targetProduct)
3674
+ })
3675
+ });
3676
+ nextProduct.num = getSafeProductNum(nextProduct.num);
3677
+ // 兜底:caller 通过 updates 直接改了 selling_price / original_price 时,
3678
+ // 视为 "重新给 source-level 主价"(caller 侧旧约定仍是 main-only 单价)。
3679
+ // 清掉 metadata 里的 source_product_price / main_product_* / price_schema_version,
3680
+ // 让 normalize 把顶层 selling_price 当作 source 来重算 main_original(=source+options) /
3681
+ // main_selling / composite;否则旧 metadata 会反压顶层新值,触发口径不一致。
3682
+ // 如果 caller 走推荐路径(updates.metadata.* 显式指定主价),保留 metadata 由 normalize 认它。
3683
+ var callerUpdatesTopPrice = Object.prototype.hasOwnProperty.call(updates || {}, 'selling_price') || Object.prototype.hasOwnProperty.call(updates || {}, 'original_price');
3684
+ var callerUpdatesMainMeta = (updates === null || updates === void 0 || (_metadata2 = updates.metadata) === null || _metadata2 === void 0 ? void 0 : _metadata2.main_product_selling_price) !== undefined || (updates === null || updates === void 0 || (_metadata3 = updates.metadata) === null || _metadata3 === void 0 ? void 0 : _metadata3.main_product_original_price) !== undefined || (updates === null || updates === void 0 || (_metadata4 = updates.metadata) === null || _metadata4 === void 0 ? void 0 : _metadata4.source_product_price) !== undefined;
3685
+ var isPersistedOrderLine = targetProduct.order_detail_id !== undefined && targetProduct.order_detail_id !== null;
3686
+ var callerChangesDiscountList = Array.isArray(updates === null || updates === void 0 ? void 0 : updates.discount_list) && updates.discount_list.length > 0 && !isSameDiscountList(updates.discount_list, targetProduct.discount_list);
3687
+ var callerUpdatesManualPrice = (updates === null || updates === void 0 || (_metadata5 = updates.metadata) === null || _metadata5 === void 0 ? void 0 : _metadata5.price_override) !== undefined || (updates === null || updates === void 0 || (_metadata6 = updates.metadata) === null || _metadata6 === void 0 ? void 0 : _metadata6.is_manual_discount) !== undefined || (updates === null || updates === void 0 || (_metadata7 = updates.metadata) === null || _metadata7 === void 0 ? void 0 : _metadata7.product_discount_reason) !== undefined || callerChangesDiscountList;
3688
+ var callerAllowsBookingReprice = function () {
3689
+ if (params.allow_booking_reprice !== true || !booking || !callerUpdatesTopPrice || !callerUpdatesMainMeta) {
3690
+ return false;
3691
+ }
3692
+ var hasChangedPrice = function hasChangedPrice(nextValue, currentValue) {
3693
+ if (nextValue === undefined || nextValue === null || nextValue === '') {
3694
+ return false;
3695
+ }
3696
+ return !new Decimal(Number(nextValue) || 0).equals(new Decimal(Number(currentValue) || 0));
3697
+ };
3698
+ return hasChangedPrice(updates.selling_price, targetProduct.selling_price) || hasChangedPrice(updates.original_price, targetProduct.original_price);
3699
+ }();
3700
+ if (isPersistedOrderLine && !callerUpdatesManualPrice && !callerAllowsBookingReprice) {
3701
+ var _targetProduct$metada3, _targetProduct$metada4, _targetProduct$metada5, _targetProduct$metada6, _targetProduct$metada7;
3702
+ nextProduct.selling_price = targetProduct.selling_price;
3703
+ nextProduct.original_price = targetProduct.original_price;
3704
+ nextProduct.payment_price = targetProduct.payment_price;
3705
+ nextProduct.metadata = _objectSpread(_objectSpread({}, nextProduct.metadata || {}), {}, {
3706
+ source_product_price: (_targetProduct$metada3 = targetProduct.metadata) === null || _targetProduct$metada3 === void 0 ? void 0 : _targetProduct$metada3.source_product_price,
3707
+ main_product_selling_price: (_targetProduct$metada4 = targetProduct.metadata) === null || _targetProduct$metada4 === void 0 ? void 0 : _targetProduct$metada4.main_product_selling_price,
3708
+ main_product_original_price: (_targetProduct$metada5 = targetProduct.metadata) === null || _targetProduct$metada5 === void 0 ? void 0 : _targetProduct$metada5.main_product_original_price,
3709
+ price_schema_version: (_targetProduct$metada6 = (_targetProduct$metada7 = targetProduct.metadata) === null || _targetProduct$metada7 === void 0 ? void 0 : _targetProduct$metada7.price_schema_version) !== null && _targetProduct$metada6 !== void 0 ? _targetProduct$metada6 : 2
3710
+ });
3711
+ nextProduct.product_bundle = this.preservePersistedBundlePriceFields(targetProduct.product_bundle, nextProduct.product_bundle);
3712
+ } else if (callerUpdatesTopPrice && !callerUpdatesMainMeta) {
3713
+ var existedMeta = nextProduct.metadata || {};
3714
+ nextProduct.metadata = _objectSpread({}, existedMeta);
3715
+ delete nextProduct.metadata.source_product_price;
3716
+ delete nextProduct.metadata.main_product_selling_price;
3717
+ delete nextProduct.metadata.main_product_original_price;
3718
+ delete nextProduct.metadata.price_schema_version;
3719
+ }
3720
+ // normalizeOrderProduct 幂等:v2 metadata 存在 → 保留 main_product_* 折扣重算 composite;
3721
+ // 否则 → 把顶层 selling_price 视作 source,派生 main_product_* 并写 price_schema_version: 2。
3722
+ var normalizedProduct = mergeOrderProductDisplayFields(nextProduct, normalizeOrderProduct(nextProduct));
3723
+ normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
3724
+ var preservedBookingUid = nextProduct.booking_uid || ((_nextProduct$metadata = nextProduct.metadata) === null || _nextProduct$metadata === void 0 ? void 0 : _nextProduct$metadata.booking_uid) || targetProduct.booking_uid || ((_targetProduct$metada8 = targetProduct.metadata) === null || _targetProduct$metada8 === void 0 ? void 0 : _targetProduct$metada8.booking_uid);
3725
+ if (!booking && preservedBookingUid) {
3726
+ normalizedProduct.booking_uid = preservedBookingUid;
3727
+ normalizedProduct.metadata = _objectSpread(_objectSpread({}, normalizedProduct.metadata || {}), {}, {
3728
+ booking_uid: preservedBookingUid
3729
+ });
3730
+ }
3731
+ if (booking) {
3732
+ var _normalizedProduct$me, _targetProduct$metada9;
3733
+ var productUid = String(((_normalizedProduct$me = normalizedProduct.metadata) === null || _normalizedProduct$me === void 0 ? void 0 : _normalizedProduct$me.unique_identification_number) || ((_targetProduct$metada9 = targetProduct.metadata) === null || _targetProduct$metada9 === void 0 ? void 0 : _targetProduct$metada9.unique_identification_number) || unique_identification_number || createUuidV4());
3734
+ normalizedProduct.metadata = _objectSpread(_objectSpread({}, normalizedProduct.metadata || {}), {}, {
3735
+ unique_identification_number: productUid
3736
+ });
3737
+ var linked = this.createLinkedProductAndBooking({
3738
+ product: _objectSpread(_objectSpread({}, normalizedProduct), {}, {
3739
+ unique_identification_number: productUid
3740
+ }),
3741
+ booking: booking
3742
+ });
3743
+ this.removeLinkedBookingsForProduct(tempOrder, targetProduct);
3744
+ normalizedProduct = _objectSpread(_objectSpread({}, normalizedProduct), {}, {
3745
+ booking_uid: linked.bookingUid,
3746
+ metadata: _objectSpread(_objectSpread({}, normalizedProduct.metadata || {}), {}, {
3747
+ booking_uid: linked.bookingUid,
3748
+ unique_identification_number: productUid
3749
+ })
3750
+ });
3751
+ tempOrder.bookings = [].concat(_toConsumableArray(tempOrder.bookings || []), [linked.booking]);
3752
+ }
3753
+ tempOrder.products[productIndex] = normalizedProduct;
3754
+ this.syncTempOrderHolderFromBookings(tempOrder);
3755
+ this.captureProductRuntime(tempOrder, updates, tempOrder.products[productIndex], (_tempOrder$products$p = tempOrder.products[productIndex].metadata) === null || _tempOrder$products$p === void 0 ? void 0 : _tempOrder$products$p.unique_identification_number);
3756
+ }
3622
3757
  }, {
3623
3758
  key: "updateOrderProduct",
3624
3759
  value: function () {
3625
3760
  var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(params) {
3626
- var _targetProduct$metada2, _product_sku, _metadata2, _metadata3, _metadata4, _metadata5, _metadata6, _metadata7, _nextProduct$metadata, _targetProduct$metada8, _tempOrder$products$p;
3627
- var product_id, product_variant_id, updates, unique_identification_number, identity_key, product_sku, product_bundle, booking, tempOrder, identityLookup, productIndex, targetUid, targetProduct, nextProduct, callerUpdatesTopPrice, callerUpdatesMainMeta, isPersistedOrderLine, callerChangesDiscountList, callerUpdatesManualPrice, callerAllowsBookingReprice, _targetProduct$metada3, _targetProduct$metada4, _targetProduct$metada5, _targetProduct$metada6, _targetProduct$metada7, existedMeta, normalizedProduct, preservedBookingUid, _normalizedProduct$me, _targetProduct$metada9, productUid, linked;
3761
+ var tempOrder;
3628
3762
  return _regeneratorRuntime().wrap(function _callee19$(_context21) {
3629
3763
  while (1) switch (_context21.prev = _context21.next) {
3630
3764
  case 0:
3631
- product_id = params.product_id, product_variant_id = params.product_variant_id, updates = params.updates, unique_identification_number = params.unique_identification_number, identity_key = params.identity_key, product_sku = params.product_sku, product_bundle = params.product_bundle, booking = params.booking;
3632
3765
  tempOrder = this.ensureTempOrder();
3633
- identityLookup = {
3634
- product_id: product_id,
3635
- product_variant_id: product_variant_id
3636
- };
3637
- if (unique_identification_number !== undefined) {
3638
- identityLookup.unique_identification_number = unique_identification_number;
3639
- if (identity_key === undefined) {
3640
- identityLookup.identity_key = unique_identification_number;
3641
- }
3642
- }
3643
- if (identity_key !== undefined) {
3644
- identityLookup.identity_key = identity_key;
3645
- }
3646
- if (product_sku !== undefined) identityLookup.product_sku = product_sku;
3647
- if (product_bundle !== undefined) identityLookup.product_bundle = product_bundle;
3648
- productIndex = -1;
3649
- if (unique_identification_number !== undefined) {
3650
- targetUid = String(unique_identification_number);
3651
- productIndex = tempOrder.products.findIndex(function (item) {
3652
- var _item$metadata3;
3653
- return String(((_item$metadata3 = item.metadata) === null || _item$metadata3 === void 0 ? void 0 : _item$metadata3.unique_identification_number) || item.unique_identification_number || '') === targetUid;
3654
- });
3655
- }
3656
- if (productIndex === -1) {
3657
- productIndex = getProductIdentityIndex(tempOrder.products, identityLookup);
3658
- }
3659
- if (!(productIndex === -1)) {
3660
- _context21.next = 12;
3661
- break;
3662
- }
3663
- throw new Error('[Order] 目标商品不存在,无法更新');
3664
- case 12:
3665
- targetProduct = tempOrder.products[productIndex];
3666
- nextProduct = _objectSpread(_objectSpread(_objectSpread({}, targetProduct), updates), {}, {
3667
- product_id: product_id,
3668
- product_variant_id: product_variant_id,
3669
- metadata: _objectSpread(_objectSpread(_objectSpread({}, targetProduct.metadata || {}), (updates === null || updates === void 0 ? void 0 : updates.metadata) || {}), {}, {
3670
- unique_identification_number: ((_targetProduct$metada2 = targetProduct.metadata) === null || _targetProduct$metada2 === void 0 ? void 0 : _targetProduct$metada2.unique_identification_number) || unique_identification_number
3671
- }),
3672
- product_sku: _objectSpread(_objectSpread(_objectSpread({}, targetProduct.product_sku || {
3673
- option: []
3674
- }), updates !== null && updates !== void 0 && updates.product_sku && _typeof(updates.product_sku) === 'object' ? updates.product_sku : {}), {}, {
3675
- option: Array.isArray(updates === null || updates === void 0 || (_product_sku = updates.product_sku) === null || _product_sku === void 0 ? void 0 : _product_sku.option) ? updates.product_sku.option : getProductSkuOptions(targetProduct)
3676
- })
3677
- });
3678
- nextProduct.num = getSafeProductNum(nextProduct.num);
3679
- // 兜底:caller 通过 updates 直接改了 selling_price / original_price 时,
3680
- // 视为 "重新给 source-level 主价"(caller 侧旧约定仍是 main-only 单价)。
3681
- // 清掉 metadata 里的 source_product_price / main_product_* / price_schema_version,
3682
- // 让 normalize 把顶层 selling_price 当作 source 来重算 main_original(=source+options) /
3683
- // main_selling / composite;否则旧 metadata 会反压顶层新值,触发口径不一致。
3684
- // 如果 caller 走推荐路径(updates.metadata.* 显式指定主价),保留 metadata 由 normalize 认它。
3685
- callerUpdatesTopPrice = Object.prototype.hasOwnProperty.call(updates || {}, 'selling_price') || Object.prototype.hasOwnProperty.call(updates || {}, 'original_price');
3686
- callerUpdatesMainMeta = (updates === null || updates === void 0 || (_metadata2 = updates.metadata) === null || _metadata2 === void 0 ? void 0 : _metadata2.main_product_selling_price) !== undefined || (updates === null || updates === void 0 || (_metadata3 = updates.metadata) === null || _metadata3 === void 0 ? void 0 : _metadata3.main_product_original_price) !== undefined || (updates === null || updates === void 0 || (_metadata4 = updates.metadata) === null || _metadata4 === void 0 ? void 0 : _metadata4.source_product_price) !== undefined;
3687
- isPersistedOrderLine = targetProduct.order_detail_id !== undefined && targetProduct.order_detail_id !== null;
3688
- callerChangesDiscountList = Array.isArray(updates === null || updates === void 0 ? void 0 : updates.discount_list) && updates.discount_list.length > 0 && !isSameDiscountList(updates.discount_list, targetProduct.discount_list);
3689
- callerUpdatesManualPrice = (updates === null || updates === void 0 || (_metadata5 = updates.metadata) === null || _metadata5 === void 0 ? void 0 : _metadata5.price_override) !== undefined || (updates === null || updates === void 0 || (_metadata6 = updates.metadata) === null || _metadata6 === void 0 ? void 0 : _metadata6.is_manual_discount) !== undefined || (updates === null || updates === void 0 || (_metadata7 = updates.metadata) === null || _metadata7 === void 0 ? void 0 : _metadata7.product_discount_reason) !== undefined || callerChangesDiscountList;
3690
- callerAllowsBookingReprice = function () {
3691
- if (params.allow_booking_reprice !== true || !booking || !callerUpdatesTopPrice || !callerUpdatesMainMeta) {
3692
- return false;
3693
- }
3694
- var hasChangedPrice = function hasChangedPrice(nextValue, currentValue) {
3695
- if (nextValue === undefined || nextValue === null || nextValue === '') {
3696
- return false;
3697
- }
3698
- return !new Decimal(Number(nextValue) || 0).equals(new Decimal(Number(currentValue) || 0));
3699
- };
3700
- return hasChangedPrice(updates.selling_price, targetProduct.selling_price) || hasChangedPrice(updates.original_price, targetProduct.original_price);
3701
- }();
3702
- if (isPersistedOrderLine && !callerUpdatesManualPrice && !callerAllowsBookingReprice) {
3703
- nextProduct.selling_price = targetProduct.selling_price;
3704
- nextProduct.original_price = targetProduct.original_price;
3705
- nextProduct.payment_price = targetProduct.payment_price;
3706
- nextProduct.metadata = _objectSpread(_objectSpread({}, nextProduct.metadata || {}), {}, {
3707
- source_product_price: (_targetProduct$metada3 = targetProduct.metadata) === null || _targetProduct$metada3 === void 0 ? void 0 : _targetProduct$metada3.source_product_price,
3708
- main_product_selling_price: (_targetProduct$metada4 = targetProduct.metadata) === null || _targetProduct$metada4 === void 0 ? void 0 : _targetProduct$metada4.main_product_selling_price,
3709
- main_product_original_price: (_targetProduct$metada5 = targetProduct.metadata) === null || _targetProduct$metada5 === void 0 ? void 0 : _targetProduct$metada5.main_product_original_price,
3710
- price_schema_version: (_targetProduct$metada6 = (_targetProduct$metada7 = targetProduct.metadata) === null || _targetProduct$metada7 === void 0 ? void 0 : _targetProduct$metada7.price_schema_version) !== null && _targetProduct$metada6 !== void 0 ? _targetProduct$metada6 : 2
3711
- });
3712
- nextProduct.product_bundle = this.preservePersistedBundlePriceFields(targetProduct.product_bundle, nextProduct.product_bundle);
3713
- } else if (callerUpdatesTopPrice && !callerUpdatesMainMeta) {
3714
- existedMeta = nextProduct.metadata || {};
3715
- nextProduct.metadata = _objectSpread({}, existedMeta);
3716
- delete nextProduct.metadata.source_product_price;
3717
- delete nextProduct.metadata.main_product_selling_price;
3718
- delete nextProduct.metadata.main_product_original_price;
3719
- delete nextProduct.metadata.price_schema_version;
3720
- }
3721
- // normalizeOrderProduct 幂等:v2 metadata 存在 → 保留 main_product_* 折扣重算 composite;
3722
- // 否则 → 把顶层 selling_price 视作 source,派生 main_product_* 并写 price_schema_version: 2。
3723
- normalizedProduct = mergeOrderProductDisplayFields(nextProduct, normalizeOrderProduct(nextProduct));
3724
- normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
3725
- preservedBookingUid = nextProduct.booking_uid || ((_nextProduct$metadata = nextProduct.metadata) === null || _nextProduct$metadata === void 0 ? void 0 : _nextProduct$metadata.booking_uid) || targetProduct.booking_uid || ((_targetProduct$metada8 = targetProduct.metadata) === null || _targetProduct$metada8 === void 0 ? void 0 : _targetProduct$metada8.booking_uid);
3726
- if (!booking && preservedBookingUid) {
3727
- normalizedProduct.booking_uid = preservedBookingUid;
3728
- normalizedProduct.metadata = _objectSpread(_objectSpread({}, normalizedProduct.metadata || {}), {}, {
3729
- booking_uid: preservedBookingUid
3730
- });
3731
- }
3732
- if (booking) {
3733
- productUid = String(((_normalizedProduct$me = normalizedProduct.metadata) === null || _normalizedProduct$me === void 0 ? void 0 : _normalizedProduct$me.unique_identification_number) || ((_targetProduct$metada9 = targetProduct.metadata) === null || _targetProduct$metada9 === void 0 ? void 0 : _targetProduct$metada9.unique_identification_number) || unique_identification_number || createUuidV4());
3734
- normalizedProduct.metadata = _objectSpread(_objectSpread({}, normalizedProduct.metadata || {}), {}, {
3735
- unique_identification_number: productUid
3736
- });
3737
- linked = this.createLinkedProductAndBooking({
3738
- product: _objectSpread(_objectSpread({}, normalizedProduct), {}, {
3739
- unique_identification_number: productUid
3740
- }),
3741
- booking: booking
3742
- });
3743
- this.removeLinkedBookingsForProduct(tempOrder, targetProduct);
3744
- normalizedProduct = _objectSpread(_objectSpread({}, normalizedProduct), {}, {
3745
- booking_uid: linked.bookingUid,
3746
- metadata: _objectSpread(_objectSpread({}, normalizedProduct.metadata || {}), {}, {
3747
- booking_uid: linked.bookingUid,
3748
- unique_identification_number: productUid
3749
- })
3750
- });
3751
- tempOrder.bookings = [].concat(_toConsumableArray(tempOrder.bookings || []), [linked.booking]);
3752
- }
3753
- tempOrder.products[productIndex] = normalizedProduct;
3754
- this.syncTempOrderHolderFromBookings(tempOrder);
3755
- this.captureProductRuntime(tempOrder, updates, tempOrder.products[productIndex], (_tempOrder$products$p = tempOrder.products[productIndex].metadata) === null || _tempOrder$products$p === void 0 ? void 0 : _tempOrder$products$p.unique_identification_number);
3756
- _context21.next = 32;
3766
+ this.applyOrderProductUpdateToTempOrder(tempOrder, params);
3767
+ _context21.next = 4;
3757
3768
  return this.applyPromotion();
3758
- case 32:
3769
+ case 4:
3759
3770
  this.applyDiscount();
3760
3771
  this.sanitizeTempOrderProducts(tempOrder);
3761
- _context21.next = 36;
3772
+ _context21.next = 8;
3762
3773
  return this.recalculateSummary({
3763
3774
  createIfMissing: true
3764
3775
  });
3765
- case 36:
3776
+ case 8:
3766
3777
  this.persistTempOrder();
3767
3778
  return _context21.abrupt("return", tempOrder.products);
3768
- case 38:
3779
+ case 10:
3769
3780
  case "end":
3770
3781
  return _context21.stop();
3771
3782
  }
@@ -3776,14 +3787,48 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3776
3787
  }
3777
3788
  return updateOrderProduct;
3778
3789
  }()
3790
+ }, {
3791
+ key: "updateOrderProducts",
3792
+ value: function () {
3793
+ var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(paramsList) {
3794
+ var _this22 = this;
3795
+ var tempOrder;
3796
+ return _regeneratorRuntime().wrap(function _callee20$(_context22) {
3797
+ while (1) switch (_context22.prev = _context22.next) {
3798
+ case 0:
3799
+ tempOrder = this.ensureTempOrder();
3800
+ if (paramsList.length) {
3801
+ _context22.next = 3;
3802
+ break;
3803
+ }
3804
+ return _context22.abrupt("return", tempOrder.products);
3805
+ case 3:
3806
+ paramsList.forEach(function (params) {
3807
+ _this22.applyOrderProductUpdateToTempOrder(tempOrder, params);
3808
+ });
3809
+ _context22.next = 6;
3810
+ return this.finalizeAfterProductsMutation(tempOrder);
3811
+ case 6:
3812
+ return _context22.abrupt("return", tempOrder.products);
3813
+ case 7:
3814
+ case "end":
3815
+ return _context22.stop();
3816
+ }
3817
+ }, _callee20, this);
3818
+ }));
3819
+ function updateOrderProducts(_x24) {
3820
+ return _updateOrderProducts.apply(this, arguments);
3821
+ }
3822
+ return updateOrderProducts;
3823
+ }()
3779
3824
  }, {
3780
3825
  key: "updateOrderProductQuantity",
3781
3826
  value: function () {
3782
- var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(params) {
3827
+ var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(params) {
3783
3828
  var _targetProduct$metada10;
3784
3829
  var product_id, product_variant_id, num, unique_identification_number, identity_key, product_sku, product_bundle, tempOrder, identityLookup, productIndex, targetUid, targetProduct, normalizedProduct;
3785
- return _regeneratorRuntime().wrap(function _callee20$(_context22) {
3786
- while (1) switch (_context22.prev = _context22.next) {
3830
+ return _regeneratorRuntime().wrap(function _callee21$(_context23) {
3831
+ while (1) switch (_context23.prev = _context23.next) {
3787
3832
  case 0:
3788
3833
  product_id = params.product_id, product_variant_id = params.product_variant_id, num = params.num, unique_identification_number = params.unique_identification_number, identity_key = params.identity_key, product_sku = params.product_sku, product_bundle = params.product_bundle;
3789
3834
  tempOrder = this.ensureTempOrder();
@@ -3812,7 +3857,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3812
3857
  productIndex = getProductIdentityIndex(tempOrder.products, identityLookup);
3813
3858
  }
3814
3859
  if (!(productIndex === -1)) {
3815
- _context22.next = 12;
3860
+ _context23.next = 12;
3816
3861
  break;
3817
3862
  }
3818
3863
  throw new Error('[Order] 目标商品不存在,无法更新数量');
@@ -3826,25 +3871,25 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3826
3871
  }));
3827
3872
  normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
3828
3873
  tempOrder.products[productIndex] = normalizedProduct;
3829
- _context22.next = 18;
3874
+ _context23.next = 18;
3830
3875
  return this.applyPromotion();
3831
3876
  case 18:
3832
3877
  this.applyDiscount();
3833
3878
  this.sanitizeTempOrderProducts(tempOrder);
3834
- _context22.next = 22;
3879
+ _context23.next = 22;
3835
3880
  return this.recalculateSummary({
3836
3881
  createIfMissing: true
3837
3882
  });
3838
3883
  case 22:
3839
3884
  this.persistTempOrder();
3840
- return _context22.abrupt("return", tempOrder.products);
3885
+ return _context23.abrupt("return", tempOrder.products);
3841
3886
  case 24:
3842
3887
  case "end":
3843
- return _context22.stop();
3888
+ return _context23.stop();
3844
3889
  }
3845
- }, _callee20, this);
3890
+ }, _callee21, this);
3846
3891
  }));
3847
- function updateOrderProductQuantity(_x24) {
3892
+ function updateOrderProductQuantity(_x25) {
3848
3893
  return _updateOrderProductQuantity.apply(this, arguments);
3849
3894
  }
3850
3895
  return updateOrderProductQuantity;
@@ -3885,17 +3930,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3885
3930
  }, {
3886
3931
  key: "finalizeAfterProductsMutation",
3887
3932
  value: (function () {
3888
- var _finalizeAfterProductsMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(tempOrder) {
3889
- return _regeneratorRuntime().wrap(function _callee21$(_context23) {
3890
- while (1) switch (_context23.prev = _context23.next) {
3933
+ var _finalizeAfterProductsMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(tempOrder) {
3934
+ return _regeneratorRuntime().wrap(function _callee22$(_context24) {
3935
+ while (1) switch (_context24.prev = _context24.next) {
3891
3936
  case 0:
3892
3937
  this.syncTempOrderHolderFromBookings(tempOrder);
3893
- _context23.next = 3;
3938
+ _context24.next = 3;
3894
3939
  return this.applyPromotion();
3895
3940
  case 3:
3896
3941
  this.applyDiscount();
3897
3942
  this.sanitizeTempOrderProducts(tempOrder);
3898
- _context23.next = 7;
3943
+ _context24.next = 7;
3899
3944
  return this.recalculateSummary({
3900
3945
  createIfMissing: true
3901
3946
  });
@@ -3903,11 +3948,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3903
3948
  this.persistTempOrder();
3904
3949
  case 8:
3905
3950
  case "end":
3906
- return _context23.stop();
3951
+ return _context24.stop();
3907
3952
  }
3908
- }, _callee21, this);
3953
+ }, _callee22, this);
3909
3954
  }));
3910
- function finalizeAfterProductsMutation(_x25) {
3955
+ function finalizeAfterProductsMutation(_x26) {
3911
3956
  return _finalizeAfterProductsMutation.apply(this, arguments);
3912
3957
  }
3913
3958
  return finalizeAfterProductsMutation;
@@ -3922,18 +3967,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3922
3967
  }, {
3923
3968
  key: "removeProductsFromOrder",
3924
3969
  value: (function () {
3925
- var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(identities) {
3926
- var _this22 = this;
3970
+ var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(identities) {
3971
+ var _this23 = this;
3927
3972
  var tempOrder, productsBeforeRemove, bookingsBeforeRemove, matchedProducts, removedProducts, _i2, _removedProducts, product, linkedBookingUidsToRemove, _iterator21, _step21, _loop3;
3928
- return _regeneratorRuntime().wrap(function _callee22$(_context25) {
3929
- while (1) switch (_context25.prev = _context25.next) {
3973
+ return _regeneratorRuntime().wrap(function _callee23$(_context26) {
3974
+ while (1) switch (_context26.prev = _context26.next) {
3930
3975
  case 0:
3931
3976
  tempOrder = this.ensureTempOrder();
3932
3977
  if (identities.length) {
3933
- _context25.next = 3;
3978
+ _context26.next = 3;
3934
3979
  break;
3935
3980
  }
3936
- return _context25.abrupt("return", tempOrder.products);
3981
+ return _context26.abrupt("return", tempOrder.products);
3937
3982
  case 3:
3938
3983
  productsBeforeRemove = tempOrder.products || [];
3939
3984
  bookingsBeforeRemove = tempOrder.bookings || [];
@@ -3956,29 +4001,29 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3956
4001
  }
3957
4002
  linkedBookingUidsToRemove = new Set();
3958
4003
  _iterator21 = _createForOfIteratorHelper(matchedProducts);
3959
- _context25.prev = 11;
4004
+ _context26.prev = 11;
3960
4005
  _loop3 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop3() {
3961
4006
  var _metadata8, _metadata9, _metadata10, _metadata11;
3962
4007
  var product, productUid, productBookingUid, isAddTimeProduct;
3963
- return _regeneratorRuntime().wrap(function _loop3$(_context24) {
3964
- while (1) switch (_context24.prev = _context24.next) {
4008
+ return _regeneratorRuntime().wrap(function _loop3$(_context25) {
4009
+ while (1) switch (_context25.prev = _context25.next) {
3965
4010
  case 0:
3966
4011
  product = _step21.value;
3967
4012
  productUid = (product === null || product === void 0 || (_metadata8 = product.metadata) === null || _metadata8 === void 0 ? void 0 : _metadata8.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
3968
4013
  productBookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_metadata9 = product.metadata) === null || _metadata9 === void 0 ? void 0 : _metadata9.booking_uid);
3969
4014
  isAddTimeProduct = (product === null || product === void 0 || (_metadata10 = product.metadata) === null || _metadata10 === void 0 ? void 0 : _metadata10.product_add_schedule_time) !== undefined && (product === null || product === void 0 || (_metadata11 = product.metadata) === null || _metadata11 === void 0 ? void 0 : _metadata11.product_add_schedule_time) !== null;
3970
4015
  if (!isAddTimeProduct) {
3971
- _context24.next = 6;
4016
+ _context25.next = 6;
3972
4017
  break;
3973
4018
  }
3974
- return _context24.abrupt("return", 1);
4019
+ return _context25.abrupt("return", 1);
3975
4020
  case 6:
3976
4021
  if (productBookingUid !== undefined && productBookingUid !== null && productBookingUid !== '') {
3977
4022
  linkedBookingUidsToRemove.add(String(productBookingUid));
3978
4023
  }
3979
4024
  if (productUid !== undefined && productUid !== null && productUid !== '') {
3980
4025
  bookingsBeforeRemove.forEach(function (booking) {
3981
- var bookingUid = _this22.getBookingUniqueIdentificationNumber(booking);
4026
+ var bookingUid = _this23.getBookingUniqueIdentificationNumber(booking);
3982
4027
  if (bookingUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) {
3983
4028
  linkedBookingUidsToRemove.add(bookingUid);
3984
4029
  }
@@ -3986,37 +4031,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3986
4031
  }
3987
4032
  case 8:
3988
4033
  case "end":
3989
- return _context24.stop();
4034
+ return _context25.stop();
3990
4035
  }
3991
4036
  }, _loop3);
3992
4037
  });
3993
4038
  _iterator21.s();
3994
4039
  case 14:
3995
4040
  if ((_step21 = _iterator21.n()).done) {
3996
- _context25.next = 20;
4041
+ _context26.next = 20;
3997
4042
  break;
3998
4043
  }
3999
- return _context25.delegateYield(_loop3(), "t0", 16);
4044
+ return _context26.delegateYield(_loop3(), "t0", 16);
4000
4045
  case 16:
4001
- if (!_context25.t0) {
4002
- _context25.next = 18;
4046
+ if (!_context26.t0) {
4047
+ _context26.next = 18;
4003
4048
  break;
4004
4049
  }
4005
- return _context25.abrupt("continue", 18);
4050
+ return _context26.abrupt("continue", 18);
4006
4051
  case 18:
4007
- _context25.next = 14;
4052
+ _context26.next = 14;
4008
4053
  break;
4009
4054
  case 20:
4010
- _context25.next = 25;
4055
+ _context26.next = 25;
4011
4056
  break;
4012
4057
  case 22:
4013
- _context25.prev = 22;
4014
- _context25.t1 = _context25["catch"](11);
4015
- _iterator21.e(_context25.t1);
4058
+ _context26.prev = 22;
4059
+ _context26.t1 = _context26["catch"](11);
4060
+ _iterator21.e(_context26.t1);
4016
4061
  case 25:
4017
- _context25.prev = 25;
4062
+ _context26.prev = 25;
4018
4063
  _iterator21.f();
4019
- return _context25.finish(25);
4064
+ return _context26.finish(25);
4020
4065
  case 28:
4021
4066
  if (linkedBookingUidsToRemove.size > 0) {
4022
4067
  // 删除主预约商品时,同步移除挂在同一 booking_uid 下的加时商品,避免残留孤儿行。
@@ -4027,17 +4072,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4027
4072
  return !(isAddTimeProduct && lineBookingUid !== undefined && lineBookingUid !== null && linkedBookingUidsToRemove.has(String(lineBookingUid)));
4028
4073
  });
4029
4074
  }
4030
- _context25.next = 31;
4075
+ _context26.next = 31;
4031
4076
  return this.finalizeAfterProductsMutation(tempOrder);
4032
4077
  case 31:
4033
- return _context25.abrupt("return", tempOrder.products);
4078
+ return _context26.abrupt("return", tempOrder.products);
4034
4079
  case 32:
4035
4080
  case "end":
4036
- return _context25.stop();
4081
+ return _context26.stop();
4037
4082
  }
4038
- }, _callee22, this, [[11, 22, 25, 28]]);
4083
+ }, _callee23, this, [[11, 22, 25, 28]]);
4039
4084
  }));
4040
- function removeProductsFromOrder(_x26) {
4085
+ function removeProductsFromOrder(_x27) {
4041
4086
  return _removeProductsFromOrder.apply(this, arguments);
4042
4087
  }
4043
4088
  return removeProductsFromOrder;
@@ -4045,18 +4090,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4045
4090
  }, {
4046
4091
  key: "removeProductFromOrder",
4047
4092
  value: function () {
4048
- var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(identity) {
4049
- return _regeneratorRuntime().wrap(function _callee23$(_context26) {
4050
- while (1) switch (_context26.prev = _context26.next) {
4093
+ var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(identity) {
4094
+ return _regeneratorRuntime().wrap(function _callee24$(_context27) {
4095
+ while (1) switch (_context27.prev = _context27.next) {
4051
4096
  case 0:
4052
- return _context26.abrupt("return", this.removeProductsFromOrder([identity]));
4097
+ return _context27.abrupt("return", this.removeProductsFromOrder([identity]));
4053
4098
  case 1:
4054
4099
  case "end":
4055
- return _context26.stop();
4100
+ return _context27.stop();
4056
4101
  }
4057
- }, _callee23, this);
4102
+ }, _callee24, this);
4058
4103
  }));
4059
- function removeProductFromOrder(_x27) {
4104
+ function removeProductFromOrder(_x28) {
4060
4105
  return _removeProductFromOrder.apply(this, arguments);
4061
4106
  }
4062
4107
  return removeProductFromOrder;
@@ -4068,10 +4113,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4068
4113
  }, {
4069
4114
  key: "clearOrderCartLines",
4070
4115
  value: (function () {
4071
- var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
4116
+ var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
4072
4117
  var tempOrder;
4073
- return _regeneratorRuntime().wrap(function _callee24$(_context27) {
4074
- while (1) switch (_context27.prev = _context27.next) {
4118
+ return _regeneratorRuntime().wrap(function _callee25$(_context28) {
4119
+ while (1) switch (_context28.prev = _context28.next) {
4075
4120
  case 0:
4076
4121
  tempOrder = this.ensureTempOrder();
4077
4122
  tempOrder.products = [];
@@ -4082,23 +4127,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4082
4127
  productsByUid: {}
4083
4128
  });
4084
4129
  }
4085
- _context27.next = 7;
4130
+ _context28.next = 7;
4086
4131
  return this.applyPromotion();
4087
4132
  case 7:
4088
4133
  this.applyDiscount();
4089
4134
  this.sanitizeTempOrderProducts(tempOrder);
4090
- _context27.next = 11;
4135
+ _context28.next = 11;
4091
4136
  return this.recalculateSummary({
4092
4137
  createIfMissing: true
4093
4138
  });
4094
4139
  case 11:
4095
4140
  this.persistTempOrder();
4096
- return _context27.abrupt("return", tempOrder);
4141
+ return _context28.abrupt("return", tempOrder);
4097
4142
  case 13:
4098
4143
  case "end":
4099
- return _context27.stop();
4144
+ return _context28.stop();
4100
4145
  }
4101
- }, _callee24, this);
4146
+ }, _callee25, this);
4102
4147
  }));
4103
4148
  function clearOrderCartLines() {
4104
4149
  return _clearOrderCartLines.apply(this, arguments);
@@ -4136,17 +4181,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4136
4181
  }, {
4137
4182
  key: "applyLocalPrintOrderNumbers",
4138
4183
  value: function () {
4139
- var _applyLocalPrintOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(order) {
4184
+ var _applyLocalPrintOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(order) {
4140
4185
  var tempOrder, shopOrderNumber, shopFullOrderNumber;
4141
- return _regeneratorRuntime().wrap(function _callee25$(_context28) {
4142
- while (1) switch (_context28.prev = _context28.next) {
4186
+ return _regeneratorRuntime().wrap(function _callee26$(_context29) {
4187
+ while (1) switch (_context29.prev = _context29.next) {
4143
4188
  case 0:
4144
4189
  tempOrder = this.ensureTempOrder();
4145
4190
  if (!(!order || _typeof(order) !== 'object')) {
4146
- _context28.next = 3;
4191
+ _context29.next = 3;
4147
4192
  break;
4148
4193
  }
4149
- return _context28.abrupt("return", tempOrder);
4194
+ return _context29.abrupt("return", tempOrder);
4150
4195
  case 3:
4151
4196
  shopOrderNumber = order.shop_order_number;
4152
4197
  shopFullOrderNumber = order.shop_full_order_number;
@@ -4157,17 +4202,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4157
4202
  tempOrder.shop_full_order_number = String(shopFullOrderNumber);
4158
4203
  }
4159
4204
  this.persistTempOrder();
4160
- _context28.next = 10;
4205
+ _context29.next = 10;
4161
4206
  return this.saveDraft();
4162
4207
  case 10:
4163
- return _context28.abrupt("return", tempOrder);
4208
+ return _context29.abrupt("return", tempOrder);
4164
4209
  case 11:
4165
4210
  case "end":
4166
- return _context28.stop();
4211
+ return _context29.stop();
4167
4212
  }
4168
- }, _callee25, this);
4213
+ }, _callee26, this);
4169
4214
  }));
4170
- function applyLocalPrintOrderNumbers(_x28) {
4215
+ function applyLocalPrintOrderNumbers(_x29) {
4171
4216
  return _applyLocalPrintOrderNumbers.apply(this, arguments);
4172
4217
  }
4173
4218
  return applyLocalPrintOrderNumbers;
@@ -4181,18 +4226,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4181
4226
  }, {
4182
4227
  key: "submitTempOrder",
4183
4228
  value: (function () {
4184
- var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(params) {
4185
- return _regeneratorRuntime().wrap(function _callee26$(_context29) {
4186
- while (1) switch (_context29.prev = _context29.next) {
4229
+ var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(params) {
4230
+ return _regeneratorRuntime().wrap(function _callee27$(_context30) {
4231
+ while (1) switch (_context30.prev = _context30.next) {
4187
4232
  case 0:
4188
- return _context29.abrupt("return", this.runSubmitTempOrder(params));
4233
+ return _context30.abrupt("return", this.runSubmitTempOrder(params));
4189
4234
  case 1:
4190
4235
  case "end":
4191
- return _context29.stop();
4236
+ return _context30.stop();
4192
4237
  }
4193
- }, _callee26, this);
4238
+ }, _callee27, this);
4194
4239
  }));
4195
- function submitTempOrder(_x29) {
4240
+ function submitTempOrder(_x30) {
4196
4241
  return _submitTempOrder.apply(this, arguments);
4197
4242
  }
4198
4243
  return submitTempOrder;
@@ -4200,20 +4245,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4200
4245
  }, {
4201
4246
  key: "submitTempOrderAsync",
4202
4247
  value: function () {
4203
- var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(params) {
4204
- return _regeneratorRuntime().wrap(function _callee27$(_context30) {
4205
- while (1) switch (_context30.prev = _context30.next) {
4248
+ var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
4249
+ return _regeneratorRuntime().wrap(function _callee28$(_context31) {
4250
+ while (1) switch (_context31.prev = _context31.next) {
4206
4251
  case 0:
4207
- return _context30.abrupt("return", this.runSubmitTempOrder(_objectSpread(_objectSpread({}, params), {}, {
4252
+ return _context31.abrupt("return", this.runSubmitTempOrder(_objectSpread(_objectSpread({}, params), {}, {
4208
4253
  syncMode: true
4209
4254
  })));
4210
4255
  case 1:
4211
4256
  case "end":
4212
- return _context30.stop();
4257
+ return _context31.stop();
4213
4258
  }
4214
- }, _callee27, this);
4259
+ }, _callee28, this);
4215
4260
  }));
4216
- function submitTempOrderAsync(_x30) {
4261
+ function submitTempOrderAsync(_x31) {
4217
4262
  return _submitTempOrderAsync.apply(this, arguments);
4218
4263
  }
4219
4264
  return submitTempOrderAsync;
@@ -4221,34 +4266,34 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4221
4266
  }, {
4222
4267
  key: "runSubmitTempOrder",
4223
4268
  value: function () {
4224
- var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
4269
+ var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
4225
4270
  var _params$cacheId2, _this$otherParams5, _ref71, _params$businessCode2, _this$otherParams6, _this$otherParams7;
4226
4271
  var tempOrder, latestSummary, effectiveCacheId, hasPaymentOverride, hasPaymentStatusOverride, hasSmallTicketDataFlagOverride, enhancePayload, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, submittedOrderId, resultRecord;
4227
- return _regeneratorRuntime().wrap(function _callee28$(_context31) {
4228
- while (1) switch (_context31.prev = _context31.next) {
4272
+ return _regeneratorRuntime().wrap(function _callee29$(_context32) {
4273
+ while (1) switch (_context32.prev = _context32.next) {
4229
4274
  case 0:
4230
4275
  tempOrder = this.ensureTempOrder();
4231
4276
  this.persistTempOrder();
4232
- _context31.next = 4;
4277
+ _context32.next = 4;
4233
4278
  return this.recalculateSummary({
4234
4279
  createIfMissing: true
4235
4280
  });
4236
4281
  case 4:
4237
- _context31.t1 = _context31.sent;
4238
- if (_context31.t1) {
4239
- _context31.next = 7;
4282
+ _context32.t1 = _context32.sent;
4283
+ if (_context32.t1) {
4284
+ _context32.next = 7;
4240
4285
  break;
4241
4286
  }
4242
- _context31.t1 = this.store.summary;
4287
+ _context32.t1 = this.store.summary;
4243
4288
  case 7:
4244
- _context31.t0 = _context31.t1;
4245
- if (_context31.t0) {
4246
- _context31.next = 10;
4289
+ _context32.t0 = _context32.t1;
4290
+ if (_context32.t0) {
4291
+ _context32.next = 10;
4247
4292
  break;
4248
4293
  }
4249
- _context31.t0 = createEmptySummary();
4294
+ _context32.t0 = createEmptySummary();
4250
4295
  case 10:
4251
- latestSummary = _context31.t0;
4296
+ latestSummary = _context32.t0;
4252
4297
  effectiveCacheId = (_params$cacheId2 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId2 !== void 0 ? _params$cacheId2 : this.cacheId;
4253
4298
  hasPaymentOverride = (params === null || params === void 0 ? void 0 : params.payments) !== undefined;
4254
4299
  hasPaymentStatusOverride = (params === null || params === void 0 ? void 0 : params.paymentStatus) !== undefined;
@@ -4282,10 +4327,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4282
4327
  if (!payload.created_at) {
4283
4328
  payload.created_at = dayjs().format('YYYY-MM-DD HH:mm:ss');
4284
4329
  }
4285
- _context31.next = 21;
4330
+ _context32.next = 21;
4286
4331
  return this.saveDraft();
4287
4332
  case 21:
4288
- _context31.prev = 21;
4333
+ _context32.prev = 21;
4289
4334
  this.logInfo('submitTempOrder calling sales checkout', {
4290
4335
  orderId: payload.order_id,
4291
4336
  externalSaleNumber: payload.external_sale_number,
@@ -4295,43 +4340,43 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4295
4340
  smallTicketDataFlag: payload.small_ticket_data_flag,
4296
4341
  syncMode: payload.sync_mode
4297
4342
  });
4298
- _context31.next = 25;
4343
+ _context32.next = 25;
4299
4344
  return this.submitSalesOrder({
4300
4345
  query: payload
4301
4346
  });
4302
4347
  case 25:
4303
- result = _context31.sent;
4304
- _context31.next = 38;
4348
+ result = _context32.sent;
4349
+ _context32.next = 38;
4305
4350
  break;
4306
4351
  case 28:
4307
- _context31.prev = 28;
4308
- _context31.t2 = _context31["catch"](21);
4309
- backendErrorResponse = this.extractSubmitErrorResponse(_context31.t2);
4352
+ _context32.prev = 28;
4353
+ _context32.t2 = _context32["catch"](21);
4354
+ backendErrorResponse = this.extractSubmitErrorResponse(_context32.t2);
4310
4355
  if (!backendErrorResponse) {
4311
- _context31.next = 35;
4356
+ _context32.next = 35;
4312
4357
  break;
4313
4358
  }
4314
4359
  this.store.syncState = 'failed';
4315
4360
  this.logSubmitBackendRejected(backendErrorResponse, payload);
4316
- return _context31.abrupt("return", backendErrorResponse);
4361
+ return _context32.abrupt("return", backendErrorResponse);
4317
4362
  case 35:
4318
4363
  this.store.syncState = 'failed';
4319
4364
  this.logError('submitTempOrder failed', {
4320
- error: _context31.t2 instanceof Error ? _context31.t2.message : String(_context31.t2),
4365
+ error: _context32.t2 instanceof Error ? _context32.t2.message : String(_context32.t2),
4321
4366
  orderId: payload.order_id,
4322
4367
  externalSaleNumber: payload.external_sale_number,
4323
4368
  paymentStatus: payload.payment_status,
4324
4369
  paymentsCount: ((_payload$payments2 = payload.payments) === null || _payload$payments2 === void 0 ? void 0 : _payload$payments2.length) || 0
4325
4370
  });
4326
- throw _context31.t2;
4371
+ throw _context32.t2;
4327
4372
  case 38:
4328
4373
  if (!this.isSubmitResponseRejected(result)) {
4329
- _context31.next = 42;
4374
+ _context32.next = 42;
4330
4375
  break;
4331
4376
  }
4332
4377
  this.store.syncState = 'failed';
4333
4378
  this.logSubmitBackendRejected(result, payload);
4334
- return _context31.abrupt("return", result);
4379
+ return _context32.abrupt("return", result);
4335
4380
  case 42:
4336
4381
  submittedOrderId = this.extractOrderIdFromSubmitResult(result);
4337
4382
  this.logInfo('runSubmitTempOrder: 提交成功', {
@@ -4340,15 +4385,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4340
4385
  tempOrder: tempOrder
4341
4386
  });
4342
4387
  if (!(submittedOrderId !== null && submittedOrderId !== undefined)) {
4343
- _context31.next = 51;
4388
+ _context32.next = 51;
4344
4389
  break;
4345
4390
  }
4346
4391
  tempOrder.order_id = submittedOrderId;
4347
4392
  resultRecord = result;
4348
- _context31.next = 49;
4393
+ _context32.next = 49;
4349
4394
  return this.markLocalOrderSynced(submittedOrderId, (resultRecord === null || resultRecord === void 0 ? void 0 : resultRecord.data) || resultRecord || {});
4350
4395
  case 49:
4351
- _context31.next = 52;
4396
+ _context32.next = 52;
4352
4397
  break;
4353
4398
  case 51:
4354
4399
  if (this.isLocalPendingSubmitResult(result)) {
@@ -4357,14 +4402,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4357
4402
  this.store.syncState = 'submitted';
4358
4403
  }
4359
4404
  case 52:
4360
- return _context31.abrupt("return", result);
4405
+ return _context32.abrupt("return", result);
4361
4406
  case 53:
4362
4407
  case "end":
4363
- return _context31.stop();
4408
+ return _context32.stop();
4364
4409
  }
4365
- }, _callee28, this, [[21, 28]]);
4410
+ }, _callee29, this, [[21, 28]]);
4366
4411
  }));
4367
- function runSubmitTempOrder(_x31) {
4412
+ function runSubmitTempOrder(_x32) {
4368
4413
  return _runSubmitTempOrder.apply(this, arguments);
4369
4414
  }
4370
4415
  return runSubmitTempOrder;
@@ -4372,10 +4417,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4372
4417
  }, {
4373
4418
  key: "markLocalOrderSynced",
4374
4419
  value: function () {
4375
- var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(orderId, remoteOrder) {
4420
+ var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(orderId, remoteOrder) {
4376
4421
  var tempOrder;
4377
- return _regeneratorRuntime().wrap(function _callee29$(_context32) {
4378
- while (1) switch (_context32.prev = _context32.next) {
4422
+ return _regeneratorRuntime().wrap(function _callee30$(_context33) {
4423
+ while (1) switch (_context33.prev = _context33.next) {
4379
4424
  case 0:
4380
4425
  tempOrder = this.ensureTempOrder();
4381
4426
  tempOrder.order_id = orderId;
@@ -4383,15 +4428,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4383
4428
  this.store.lastOrderInfo = remoteOrder;
4384
4429
  this.store.syncState = 'submitted';
4385
4430
  this.persistTempOrder();
4386
- _context32.next = 8;
4431
+ _context33.next = 8;
4387
4432
  return this.saveDraft();
4388
4433
  case 8:
4389
4434
  case "end":
4390
- return _context32.stop();
4435
+ return _context33.stop();
4391
4436
  }
4392
- }, _callee29, this);
4437
+ }, _callee30, this);
4393
4438
  }));
4394
- function markLocalOrderSynced(_x32, _x33) {
4439
+ function markLocalOrderSynced(_x33, _x34) {
4395
4440
  return _markLocalOrderSynced.apply(this, arguments);
4396
4441
  }
4397
4442
  return markLocalOrderSynced;
@@ -4434,10 +4479,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4434
4479
  value: function extractSubmitErrorResponse(error) {
4435
4480
  var _error$response,
4436
4481
  _error$response2,
4437
- _this23 = this;
4482
+ _this24 = this;
4438
4483
  var candidates = [error === null || error === void 0 || (_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.data, error === null || error === void 0 ? void 0 : error.data, error === null || error === void 0 || (_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.body, error === null || error === void 0 ? void 0 : error.body];
4439
4484
  return candidates.find(function (candidate) {
4440
- return _this23.isSubmitErrorResponse(candidate);
4485
+ return _this24.isSubmitErrorResponse(candidate);
4441
4486
  }) || null;
4442
4487
  }
4443
4488
  }, {
@@ -4464,10 +4509,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4464
4509
  }, {
4465
4510
  key: "syncPaymentsToOrder",
4466
4511
  value: function () {
4467
- var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(params) {
4512
+ var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
4468
4513
  var tempOrder, mappedPayments, paymentTotal, targetAmount, isFullyPaid, paymentStatus, paymentSyncIdempotencyToken, submitResult;
4469
- return _regeneratorRuntime().wrap(function _callee30$(_context33) {
4470
- while (1) switch (_context33.prev = _context33.next) {
4514
+ return _regeneratorRuntime().wrap(function _callee31$(_context34) {
4515
+ while (1) switch (_context34.prev = _context34.next) {
4471
4516
  case 0:
4472
4517
  tempOrder = this.ensureTempOrder();
4473
4518
  mappedPayments = mapPaymentItemsToOrderPayments(params.payments || []);
@@ -4478,28 +4523,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4478
4523
  tempOrder.payments = mappedPayments;
4479
4524
  tempOrder.payment_status = paymentStatus;
4480
4525
  this.persistTempOrder();
4481
- _context33.next = 11;
4526
+ _context34.next = 11;
4482
4527
  return this.saveDraft();
4483
4528
  case 11:
4484
4529
  if (params.submitWhenPaid) {
4485
- _context33.next = 13;
4530
+ _context34.next = 13;
4486
4531
  break;
4487
4532
  }
4488
- return _context33.abrupt("return", {
4533
+ return _context34.abrupt("return", {
4489
4534
  isFullyPaid: isFullyPaid
4490
4535
  });
4491
4536
  case 13:
4492
4537
  if (!(this.store.syncState === 'submitting')) {
4493
- _context33.next = 15;
4538
+ _context34.next = 15;
4494
4539
  break;
4495
4540
  }
4496
- return _context33.abrupt("return", {
4541
+ return _context34.abrupt("return", {
4497
4542
  isFullyPaid: isFullyPaid
4498
4543
  });
4499
4544
  case 15:
4500
4545
  this.store.syncState = 'submitting';
4501
4546
  paymentSyncIdempotencyToken = this.buildPaymentSyncIdempotencyToken(tempOrder, mappedPayments);
4502
- _context33.next = 19;
4547
+ _context34.next = 19;
4503
4548
  return this.submitTempOrder({
4504
4549
  payments: mappedPayments,
4505
4550
  paymentStatus: paymentStatus,
@@ -4514,18 +4559,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4514
4559
  }
4515
4560
  });
4516
4561
  case 19:
4517
- submitResult = _context33.sent;
4518
- return _context33.abrupt("return", {
4562
+ submitResult = _context34.sent;
4563
+ return _context34.abrupt("return", {
4519
4564
  isFullyPaid: isFullyPaid,
4520
4565
  submitResult: submitResult
4521
4566
  });
4522
4567
  case 21:
4523
4568
  case "end":
4524
- return _context33.stop();
4569
+ return _context34.stop();
4525
4570
  }
4526
- }, _callee30, this);
4571
+ }, _callee31, this);
4527
4572
  }));
4528
- function syncPaymentsToOrder(_x34) {
4573
+ function syncPaymentsToOrder(_x35) {
4529
4574
  return _syncPaymentsToOrder.apply(this, arguments);
4530
4575
  }
4531
4576
  return syncPaymentsToOrder;
@@ -4614,11 +4659,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4614
4659
  }, {
4615
4660
  key: "submitOrder",
4616
4661
  value: function () {
4617
- var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(order) {
4662
+ var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(order) {
4618
4663
  var _order$query$cartItem, _params$bookings, _params$relation_prod;
4619
4664
  var url, query, fetchUrl, params;
4620
- return _regeneratorRuntime().wrap(function _callee31$(_context34) {
4621
- while (1) switch (_context34.prev = _context34.next) {
4665
+ return _regeneratorRuntime().wrap(function _callee32$(_context35) {
4666
+ while (1) switch (_context35.prev = _context35.next) {
4622
4667
  case 0:
4623
4668
  this.logInfo('submitOrder called', {
4624
4669
  url: order.url,
@@ -4638,14 +4683,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4638
4683
  relationProductsCount: ((_params$relation_prod = params.relation_products) === null || _params$relation_prod === void 0 ? void 0 : _params$relation_prod.length) || 0,
4639
4684
  scheduleDate: params.schedule_date
4640
4685
  });
4641
- return _context34.abrupt("return", this.request.post(fetchUrl, params));
4686
+ return _context35.abrupt("return", this.request.post(fetchUrl, params));
4642
4687
  case 6:
4643
4688
  case "end":
4644
- return _context34.stop();
4689
+ return _context35.stop();
4645
4690
  }
4646
- }, _callee31, this);
4691
+ }, _callee32, this);
4647
4692
  }));
4648
- function submitOrder(_x35) {
4693
+ function submitOrder(_x36) {
4649
4694
  return _submitOrder.apply(this, arguments);
4650
4695
  }
4651
4696
  return submitOrder;
@@ -4653,13 +4698,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4653
4698
  }, {
4654
4699
  key: "cancelOrder",
4655
4700
  value: function () {
4656
- var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
4701
+ var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(params) {
4657
4702
  var payload;
4658
- return _regeneratorRuntime().wrap(function _callee32$(_context35) {
4659
- while (1) switch (_context35.prev = _context35.next) {
4703
+ return _regeneratorRuntime().wrap(function _callee33$(_context36) {
4704
+ while (1) switch (_context36.prev = _context36.next) {
4660
4705
  case 0:
4661
4706
  if (!(!Array.isArray(params.order_ids) || params.order_ids.length === 0)) {
4662
- _context35.next = 2;
4707
+ _context36.next = 2;
4663
4708
  break;
4664
4709
  }
4665
4710
  throw new Error('取消订单失败:order_ids 不能为空');
@@ -4675,16 +4720,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4675
4720
  method: 'PUT',
4676
4721
  orderIdsCount: params.order_ids.length
4677
4722
  });
4678
- return _context35.abrupt("return", this.request.put('/order/update-status', payload, {
4723
+ return _context36.abrupt("return", this.request.put('/order/update-status', payload, {
4679
4724
  isShopApi: true
4680
4725
  }));
4681
4726
  case 5:
4682
4727
  case "end":
4683
- return _context35.stop();
4728
+ return _context36.stop();
4684
4729
  }
4685
- }, _callee32, this);
4730
+ }, _callee33, this);
4686
4731
  }));
4687
- function cancelOrder(_x36) {
4732
+ function cancelOrder(_x37) {
4688
4733
  return _cancelOrder.apply(this, arguments);
4689
4734
  }
4690
4735
  return cancelOrder;
@@ -4692,19 +4737,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4692
4737
  }, {
4693
4738
  key: "changeBookingStatus",
4694
4739
  value: function () {
4695
- var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(params) {
4740
+ var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
4696
4741
  var url, payload;
4697
- return _regeneratorRuntime().wrap(function _callee33$(_context36) {
4698
- while (1) switch (_context36.prev = _context36.next) {
4742
+ return _regeneratorRuntime().wrap(function _callee34$(_context37) {
4743
+ while (1) switch (_context37.prev = _context37.next) {
4699
4744
  case 0:
4700
4745
  if (params.booking_id) {
4701
- _context36.next = 2;
4746
+ _context37.next = 2;
4702
4747
  break;
4703
4748
  }
4704
4749
  throw new Error('变更预约状态失败:booking_id 不能为空');
4705
4750
  case 2:
4706
4751
  if (params.appointment_status) {
4707
- _context36.next = 4;
4752
+ _context37.next = 4;
4708
4753
  break;
4709
4754
  }
4710
4755
  throw new Error('变更预约状态失败:appointment_status 不能为空');
@@ -4719,16 +4764,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4719
4764
  bookingId: params.booking_id,
4720
4765
  appointmentStatus: params.appointment_status
4721
4766
  });
4722
- return _context36.abrupt("return", this.request.put(url, payload, {
4767
+ return _context37.abrupt("return", this.request.put(url, payload, {
4723
4768
  isShopApi: true
4724
4769
  }));
4725
4770
  case 8:
4726
4771
  case "end":
4727
- return _context36.stop();
4772
+ return _context37.stop();
4728
4773
  }
4729
- }, _callee33, this);
4774
+ }, _callee34, this);
4730
4775
  }));
4731
- function changeBookingStatus(_x37) {
4776
+ function changeBookingStatus(_x38) {
4732
4777
  return _changeBookingStatus.apply(this, arguments);
4733
4778
  }
4734
4779
  return changeBookingStatus;
@@ -4746,11 +4791,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4746
4791
  }, {
4747
4792
  key: "createOrderByCheckout",
4748
4793
  value: (function () {
4749
- var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
4794
+ var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(params) {
4750
4795
  var _params$payments, _params$bookings2, _params$relation_prod2, _params$payments2, _params$payments3, _params$bookings3, _params$relation_prod3, _params$payments4;
4751
4796
  var onlineStorePaymentCodeList, _orderData$payments, _orderData$bookings, _orderData$relation_p, _orderData$payments2, _orderData$payments3, _orderData$bookings2, _orderData$relation_p2, _orderData$payments4, _orderData$payments5, _response$data, orderData, response;
4752
- return _regeneratorRuntime().wrap(function _callee34$(_context37) {
4753
- while (1) switch (_context37.prev = _context37.next) {
4797
+ return _regeneratorRuntime().wrap(function _callee35$(_context38) {
4798
+ while (1) switch (_context38.prev = _context38.next) {
4754
4799
  case 0:
4755
4800
  // 过滤掉由在线店铺下单的 payment 支付数据
4756
4801
  onlineStorePaymentCodeList = ['WXPAY', 'WECHAT', 'ALIPAY', 'APPLE_PAY', 'CREDIT_CARD_3DS', 'CREDIT_CARD_TOKEN', 'GOOGLE_PAY', 'GOOGLE_PAY_3DS', 'CREDIT_CARD'];
@@ -4784,7 +4829,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4784
4829
  relationProductsCount: ((_params$relation_prod3 = params.relation_products) === null || _params$relation_prod3 === void 0 ? void 0 : _params$relation_prod3.length) || 0,
4785
4830
  paymentsCount: ((_params$payments4 = params.payments) === null || _params$payments4 === void 0 ? void 0 : _params$payments4.length) || 0
4786
4831
  });
4787
- _context37.prev = 4;
4832
+ _context38.prev = 4;
4788
4833
  // 构建订单数据,设置默认值并允许 params 覆盖
4789
4834
  orderData = _objectSpread({
4790
4835
  sales_channel: 'my_pisel',
@@ -4846,13 +4891,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4846
4891
  hasOrderId: !!orderData.order_id,
4847
4892
  smallTicketDataFlag: orderData.small_ticket_data_flag
4848
4893
  });
4849
- _context37.next = 12;
4894
+ _context38.next = 12;
4850
4895
  return this.request.post('/order/checkout', orderData, {
4851
4896
  osServer: true,
4852
4897
  customToast: function customToast() {}
4853
4898
  });
4854
4899
  case 12:
4855
- response = _context37.sent;
4900
+ response = _context38.sent;
4856
4901
  this.logInfo('Order API called successfully', {
4857
4902
  response: response
4858
4903
  });
@@ -4860,22 +4905,22 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4860
4905
  success: !!response,
4861
4906
  hasOrderId: !!(response !== null && response !== void 0 && (_response$data = response.data) !== null && _response$data !== void 0 && _response$data.order_id || response !== null && response !== void 0 && response.order_id)
4862
4907
  });
4863
- return _context37.abrupt("return", response);
4908
+ return _context38.abrupt("return", response);
4864
4909
  case 18:
4865
- _context37.prev = 18;
4866
- _context37.t0 = _context37["catch"](4);
4867
- console.error('[Order] createOrderByCheckout 创建订单失败:', _context37.t0);
4910
+ _context38.prev = 18;
4911
+ _context38.t0 = _context38["catch"](4);
4912
+ console.error('[Order] createOrderByCheckout 创建订单失败:', _context38.t0);
4868
4913
  this.logInfo('Order API called failed', {
4869
- error: _context37.t0 instanceof Error ? _context37.t0.message : String(_context37.t0)
4914
+ error: _context38.t0 instanceof Error ? _context38.t0.message : String(_context38.t0)
4870
4915
  });
4871
- throw _context37.t0;
4916
+ throw _context38.t0;
4872
4917
  case 23:
4873
4918
  case "end":
4874
- return _context37.stop();
4919
+ return _context38.stop();
4875
4920
  }
4876
- }, _callee34, this, [[4, 18]]);
4921
+ }, _callee35, this, [[4, 18]]);
4877
4922
  }));
4878
- function createOrderByCheckout(_x38) {
4923
+ function createOrderByCheckout(_x39) {
4879
4924
  return _createOrderByCheckout.apply(this, arguments);
4880
4925
  }
4881
4926
  return createOrderByCheckout;
@@ -4883,24 +4928,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4883
4928
  }, {
4884
4929
  key: "submitSalesOrder",
4885
4930
  value: function () {
4886
- var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(params) {
4931
+ var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(params) {
4887
4932
  var url, query, fetchUrl;
4888
- return _regeneratorRuntime().wrap(function _callee35$(_context38) {
4889
- while (1) switch (_context38.prev = _context38.next) {
4933
+ return _regeneratorRuntime().wrap(function _callee36$(_context39) {
4934
+ while (1) switch (_context39.prev = _context39.next) {
4890
4935
  case 0:
4891
4936
  url = params.url, query = params.query;
4892
4937
  fetchUrl = url || '/order/sales/checkout';
4893
- return _context38.abrupt("return", this.request.post(fetchUrl, query, {
4938
+ return _context39.abrupt("return", this.request.post(fetchUrl, query, {
4894
4939
  osServer: true,
4895
4940
  customToast: function customToast() {}
4896
4941
  }));
4897
4942
  case 3:
4898
4943
  case "end":
4899
- return _context38.stop();
4944
+ return _context39.stop();
4900
4945
  }
4901
- }, _callee35, this);
4946
+ }, _callee36, this);
4902
4947
  }));
4903
- function submitSalesOrder(_x39) {
4948
+ function submitSalesOrder(_x40) {
4904
4949
  return _submitSalesOrder.apply(this, arguments);
4905
4950
  }
4906
4951
  return submitSalesOrder;
@@ -4914,37 +4959,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4914
4959
  }, {
4915
4960
  key: "sendCustomerPayLink",
4916
4961
  value: (function () {
4917
- var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(params) {
4962
+ var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(params) {
4918
4963
  var _params$emails;
4919
4964
  var orderIds;
4920
- return _regeneratorRuntime().wrap(function _callee36$(_context39) {
4921
- while (1) switch (_context39.prev = _context39.next) {
4965
+ return _regeneratorRuntime().wrap(function _callee37$(_context40) {
4966
+ while (1) switch (_context40.prev = _context40.next) {
4922
4967
  case 0:
4923
4968
  orderIds = params.order_ids || params.orderIds || [];
4924
4969
  if (orderIds.length) {
4925
- _context39.next = 3;
4970
+ _context40.next = 3;
4926
4971
  break;
4927
4972
  }
4928
4973
  throw new Error('发送支付链接前必须先提交本地订单并取得订单 ID');
4929
4974
  case 3:
4930
4975
  if ((_params$emails = params.emails) !== null && _params$emails !== void 0 && _params$emails.length) {
4931
- _context39.next = 5;
4976
+ _context40.next = 5;
4932
4977
  break;
4933
4978
  }
4934
4979
  throw new Error('发送支付链接需要至少一个邮箱');
4935
4980
  case 5:
4936
- return _context39.abrupt("return", this.request.post('/order/batch-email', {
4981
+ return _context40.abrupt("return", this.request.post('/order/batch-email', {
4937
4982
  order_ids: orderIds,
4938
4983
  notify_action: params.notify_action || 'order_payment_reminder',
4939
4984
  emails: params.emails
4940
4985
  }));
4941
4986
  case 6:
4942
4987
  case "end":
4943
- return _context39.stop();
4988
+ return _context40.stop();
4944
4989
  }
4945
- }, _callee36, this);
4990
+ }, _callee37, this);
4946
4991
  }));
4947
- function sendCustomerPayLink(_x40) {
4992
+ function sendCustomerPayLink(_x41) {
4948
4993
  return _sendCustomerPayLink.apply(this, arguments);
4949
4994
  }
4950
4995
  return sendCustomerPayLink;
@@ -4952,14 +4997,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4952
4997
  }, {
4953
4998
  key: "getSalesOrderByLookup",
4954
4999
  value: function () {
4955
- var _getSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(params) {
5000
+ var _getSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(params) {
4956
5001
  var lookup, res;
4957
- return _regeneratorRuntime().wrap(function _callee37$(_context40) {
4958
- while (1) switch (_context40.prev = _context40.next) {
5002
+ return _regeneratorRuntime().wrap(function _callee38$(_context41) {
5003
+ while (1) switch (_context41.prev = _context41.next) {
4959
5004
  case 0:
4960
5005
  lookup = params.lookup === undefined || params.lookup === null ? '' : String(params.lookup).trim();
4961
5006
  if (lookup) {
4962
- _context40.next = 3;
5007
+ _context41.next = 3;
4963
5008
  break;
4964
5009
  }
4965
5010
  throw new Error('加载销售详情需要 lookup');
@@ -4968,7 +5013,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4968
5013
  if (lookup.startsWith('LOCAL_')) {
4969
5014
  params.forceRemote = false;
4970
5015
  }
4971
- _context40.next = 6;
5016
+ _context41.next = 6;
4972
5017
  return this.request.get("/order/sales/".concat(encodeURIComponent(lookup)), _objectSpread({
4973
5018
  with: ['products', 'bookings', 'payments', 'customer', 'summary', 'contacts_info']
4974
5019
  }, params.forceRemote ? {
@@ -4977,18 +5022,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4977
5022
  osServer: true
4978
5023
  });
4979
5024
  case 6:
4980
- res = _context40.sent;
5025
+ res = _context41.sent;
4981
5026
  if (res.code === 200) {
4982
5027
  this.store.lastOrderInfo = res.data;
4983
5028
  }
4984
- return _context40.abrupt("return", res);
5029
+ return _context41.abrupt("return", res);
4985
5030
  case 9:
4986
5031
  case "end":
4987
- return _context40.stop();
5032
+ return _context41.stop();
4988
5033
  }
4989
- }, _callee37, this);
5034
+ }, _callee38, this);
4990
5035
  }));
4991
- function getSalesOrderByLookup(_x41) {
5036
+ function getSalesOrderByLookup(_x42) {
4992
5037
  return _getSalesOrderByLookup.apply(this, arguments);
4993
5038
  }
4994
5039
  return getSalesOrderByLookup;
@@ -5002,11 +5047,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5002
5047
  }, {
5003
5048
  key: "hydrateTempOrderFromRecord",
5004
5049
  value: (function () {
5005
- var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(record, options) {
5050
+ var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(record, options) {
5006
5051
  var _this$store$discount15;
5007
5052
  var raw, nextTempOrder, rawSummary, summarySurcharges, hydratedEditDiscounts, currentDiscounts, shouldSkipEmptyDiscountSync, _this$store$discount16, _this$store$discount17;
5008
- return _regeneratorRuntime().wrap(function _callee38$(_context41) {
5009
- while (1) switch (_context41.prev = _context41.next) {
5053
+ return _regeneratorRuntime().wrap(function _callee39$(_context42) {
5054
+ while (1) switch (_context42.prev = _context42.next) {
5010
5055
  case 0:
5011
5056
  raw = record && _typeof(record) === 'object' && record.data && record.order_id == null ? record.data : record || {};
5012
5057
  nextTempOrder = this.normalizeTempOrderForRuntime(raw);
@@ -5032,41 +5077,74 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5032
5077
  currentDiscounts = typeof ((_this$store$discount15 = this.store.discount) === null || _this$store$discount15 === void 0 ? void 0 : _this$store$discount15.getDiscountList) === 'function' ? this.store.discount.getDiscountList() || [] : [];
5033
5078
  shouldSkipEmptyDiscountSync = hydratedEditDiscounts.length === 0 && currentDiscounts.length === 0;
5034
5079
  if (shouldSkipEmptyDiscountSync) {
5035
- _context41.next = 16;
5080
+ _context42.next = 16;
5036
5081
  break;
5037
5082
  }
5038
- _context41.next = 14;
5083
+ _context42.next = 14;
5039
5084
  return (_this$store$discount16 = this.store.discount) === null || _this$store$discount16 === void 0 ? void 0 : _this$store$discount16.setOriginalDiscountList(hydratedEditDiscounts);
5040
5085
  case 14:
5041
- _context41.next = 16;
5086
+ _context42.next = 16;
5042
5087
  return (_this$store$discount17 = this.store.discount) === null || _this$store$discount17 === void 0 ? void 0 : _this$store$discount17.setDiscountList(hydratedEditDiscounts);
5043
5088
  case 16:
5044
5089
  if (!(options !== null && options !== void 0 && options.recalcOnHydrate)) {
5045
- _context41.next = 19;
5090
+ _context42.next = 19;
5046
5091
  break;
5047
5092
  }
5048
- _context41.next = 19;
5093
+ _context42.next = 19;
5049
5094
  return this.recalculateSummary({
5050
5095
  createIfMissing: false
5051
5096
  });
5052
5097
  case 19:
5053
5098
  this.persistTempOrder();
5054
- return _context41.abrupt("return", nextTempOrder);
5099
+ return _context42.abrupt("return", nextTempOrder);
5055
5100
  case 21:
5056
5101
  case "end":
5057
- return _context41.stop();
5102
+ return _context42.stop();
5058
5103
  }
5059
- }, _callee38, this);
5104
+ }, _callee39, this);
5060
5105
  }));
5061
- function hydrateTempOrderFromRecord(_x42, _x43) {
5106
+ function hydrateTempOrderFromRecord(_x43, _x44) {
5062
5107
  return _hydrateTempOrderFromRecord.apply(this, arguments);
5063
5108
  }
5064
5109
  return hydrateTempOrderFromRecord;
5065
- }())
5110
+ }()
5111
+ /**
5112
+ * 兼容后端详情将 holder 放在 metadata.holder 的历史形态,统一补到运行时展示路径。
5113
+ *
5114
+ * @example
5115
+ * this.normalizeHydratedBookingHolder({ metadata: { holder: { form_record: [1] } } });
5116
+ */
5117
+ )
5118
+ }, {
5119
+ key: "normalizeHydratedBookingHolder",
5120
+ value: function normalizeHydratedBookingHolder(booking) {
5121
+ var next = _objectSpread({}, booking || {});
5122
+ var metadata = next.metadata && _typeof(next.metadata) === 'object' && !Array.isArray(next.metadata) ? _objectSpread({}, next.metadata) : {};
5123
+ var metadataHolder = metadata.holder && _typeof(metadata.holder) === 'object' && !Array.isArray(metadata.holder) ? metadata.holder : null;
5124
+
5125
+ // 编辑详情接口可能只返回 metadata.holder;UI 与提交链路统一读取 booking.holder。
5126
+ if (!next.holder && metadataHolder) {
5127
+ next.holder = _objectSpread({}, metadataHolder);
5128
+ }
5129
+ var holder = next.holder && _typeof(next.holder) === 'object' && !Array.isArray(next.holder) ? next.holder : null;
5130
+ var holderRecords = Array.isArray(holder === null || holder === void 0 ? void 0 : holder.form_record) ? holder.form_record.filter(function (id) {
5131
+ return id !== undefined && id !== null && id !== '';
5132
+ }) : [];
5133
+ var hasMetadataHolderId = metadata.holder_id !== undefined && metadata.holder_id !== null && metadata.holder_id !== '' && (!Array.isArray(metadata.holder_id) || metadata.holder_id.length > 0);
5134
+
5135
+ // 卡片和编辑抽屉会从 holder_id 进入展示/表单回显,缺失时由 holder.form_record 补齐。
5136
+ if (!hasMetadataHolderId && holderRecords.length > 0) {
5137
+ metadata.holder_id = holderRecords;
5138
+ }
5139
+ if (Object.keys(metadata).length > 0) {
5140
+ next.metadata = metadata;
5141
+ }
5142
+ return next;
5143
+ }
5066
5144
  }, {
5067
5145
  key: "normalizeTempOrderForRuntime",
5068
5146
  value: function normalizeTempOrderForRuntime(raw, options) {
5069
- var _this24 = this;
5147
+ var _this25 = this;
5070
5148
  var nextTempOrder = _objectSpread(_objectSpread({}, this.createDefaultTempOrderInstance()), raw || {});
5071
5149
  // ES 列表详情使用 id 表示订单主键;OS 详情态统一依赖 order_id 驱动操作按钮。
5072
5150
  if ((nextTempOrder.order_id === undefined || nextTempOrder.order_id === null) && (raw === null || raw === void 0 ? void 0 : raw.id) !== undefined && (raw === null || raw === void 0 ? void 0 : raw.id) !== null) {
@@ -5089,12 +5167,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5089
5167
  nextTempOrder.holder = raw.holder && _typeof(raw.holder) === 'object' ? _objectSpread({}, raw.holder) : null;
5090
5168
  var rawProducts = Array.isArray(raw.products) ? raw.products : [];
5091
5169
  nextTempOrder.products = rawProducts.length > 0 ? rawProducts.map(function (p) {
5092
- return _this24.normalizeHydratedOrderProduct(p);
5170
+ return _this25.normalizeHydratedOrderProduct(p);
5093
5171
  }) : [];
5094
5172
  nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(function (b) {
5095
- return _objectSpread(_objectSpread({}, b || {}), {}, {
5096
- is_all: normalizeBookingIsAll(b || {}),
5097
- sub_type: normalizeBookingSubType(b || {})
5173
+ var booking = _this25.normalizeHydratedBookingHolder(b || {});
5174
+ return _objectSpread(_objectSpread({}, booking), {}, {
5175
+ is_all: normalizeBookingIsAll(booking),
5176
+ sub_type: normalizeBookingSubType(booking)
5098
5177
  });
5099
5178
  }) : [];
5100
5179
  nextTempOrder.payments = Array.isArray(raw.payments) ? raw.payments.map(function (p) {
@@ -5259,7 +5338,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5259
5338
  }, {
5260
5339
  key: "normalizeHydratedOrderProduct",
5261
5340
  value: function normalizeHydratedOrderProduct(product) {
5262
- var _this25 = this;
5341
+ var _this26 = this;
5263
5342
  var row = _objectSpread({}, product || {});
5264
5343
  if (row.num === undefined && row.product_quantity !== undefined) {
5265
5344
  row.num = row.product_quantity;
@@ -5267,7 +5346,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5267
5346
  var productSku = ensureProductSku(row);
5268
5347
  row.product_sku = _objectSpread(_objectSpread({}, productSku), {}, {
5269
5348
  option: normalizeProductSkuOptions(productSku.option.map(function (optionItem) {
5270
- return _this25.normalizeHydratedProductOptionItem(optionItem || {});
5349
+ return _this26.normalizeHydratedProductOptionItem(optionItem || {});
5271
5350
  }))
5272
5351
  });
5273
5352
  delete row["product_".concat('option', "_item")];
@@ -5298,25 +5377,25 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5298
5377
  }, {
5299
5378
  key: "getOrderInfo",
5300
5379
  value: function () {
5301
- var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(order_id) {
5380
+ var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(order_id) {
5302
5381
  var res;
5303
- return _regeneratorRuntime().wrap(function _callee39$(_context42) {
5304
- while (1) switch (_context42.prev = _context42.next) {
5382
+ return _regeneratorRuntime().wrap(function _callee40$(_context43) {
5383
+ while (1) switch (_context43.prev = _context43.next) {
5305
5384
  case 0:
5306
- _context42.next = 2;
5385
+ _context43.next = 2;
5307
5386
  return this.request.get("/order/sales/".concat(order_id), {
5308
5387
  with: ['products', 'bookings']
5309
5388
  });
5310
5389
  case 2:
5311
- res = _context42.sent;
5312
- return _context42.abrupt("return", res);
5390
+ res = _context43.sent;
5391
+ return _context43.abrupt("return", res);
5313
5392
  case 4:
5314
5393
  case "end":
5315
- return _context42.stop();
5394
+ return _context43.stop();
5316
5395
  }
5317
- }, _callee39, this);
5396
+ }, _callee40, this);
5318
5397
  }));
5319
- function getOrderInfo(_x44) {
5398
+ function getOrderInfo(_x45) {
5320
5399
  return _getOrderInfo.apply(this, arguments);
5321
5400
  }
5322
5401
  return getOrderInfo;