@pisell/pisellos 0.10.88 → 0.10.90

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.
@@ -412,11 +412,44 @@ function getOrderProductDeposit(product, runtimeOrigin) {
412
412
  num: num
413
413
  });
414
414
  if (result.result) {
415
+ var _product$metadata, _product$metadata2;
415
416
  depositTotal = result.depositTotal;
416
417
  protocolIds.push.apply(protocolIds, _toConsumableArray(getDepositPolicyIds({
417
418
  self_deposit_policy_ids: depositData.self_deposit_policy_ids
418
419
  })));
419
420
  hasDeposit = true;
421
+
422
+ // 主商品金额不包含 markup/product_price 这类独立计价子商品。
423
+ // 以前父规则命中后直接跳过子项,导致“父价 0 + 子票 70 × 10”即使
424
+ // 子票已命中 50% 定金规则,仍算出 0;应累加子项自己的定金规则。
425
+ // 普通加价/减价子项已计入主价,不能重复收取。未拆分主价的旧订单行
426
+ // selling_price 可能包含整个套餐,继续沿用原口径,避免重复计费。
427
+ var hasSeparateMainPrice = ((_product$metadata = product.metadata) === null || _product$metadata === void 0 ? void 0 : _product$metadata.main_product_attached_bundle_payment_price) != null || ((_product$metadata2 = product.metadata) === null || _product$metadata2 === void 0 ? void 0 : _product$metadata2.main_product_selling_price) != null;
428
+ if (hasSeparateMainPrice && Array.isArray(product.product_bundle)) {
429
+ var _iterator3 = _createForOfIteratorHelper(product.product_bundle),
430
+ _step3;
431
+ try {
432
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
433
+ var _ref10, _bundleProduct$bundle, _bundleProduct$num;
434
+ var bundleProduct = _step3.value;
435
+ if (bundleProduct.price_type !== 'markup' || bundleProduct.price_type_ext !== 'product_price') continue;
436
+ var bundleDepositData = bundleProduct.custom_deposit_data;
437
+ var bundleResult = handleOrderProductDeposit({
438
+ depositData: bundleDepositData,
439
+ // payment 是已分摊折扣的子商品单价;子项数量和套餐数量各乘一次。
440
+ total: (_ref10 = (_bundleProduct$bundle = bundleProduct.bundle_payment_price) !== null && _bundleProduct$bundle !== void 0 ? _bundleProduct$bundle : bundleProduct.bundle_selling_price) !== null && _ref10 !== void 0 ? _ref10 : bundleProduct.price,
441
+ num: getSafeOrderProductNum((_bundleProduct$num = bundleProduct.num) !== null && _bundleProduct$num !== void 0 ? _bundleProduct$num : bundleProduct.quantity) * num
442
+ });
443
+ if (!bundleResult.result) continue;
444
+ depositTotal = depositTotal.plus(bundleResult.depositTotal);
445
+ protocolIds.push.apply(protocolIds, _toConsumableArray(getDepositPolicyIds(bundleDepositData)));
446
+ }
447
+ } catch (err) {
448
+ _iterator3.e(err);
449
+ } finally {
450
+ _iterator3.f();
451
+ }
452
+ }
420
453
  }
421
454
  } else {
422
455
  var _depositProduct$produ;
@@ -479,36 +512,36 @@ export function calculateOrderProductsDeposit() {
479
512
  var protocolMap = new Map();
480
513
  var total = new Decimal(0);
481
514
  var hasDeposit = false;
482
- var _iterator3 = _createForOfIteratorHelper(products || []),
483
- _step3;
515
+ var _iterator4 = _createForOfIteratorHelper(products || []),
516
+ _step4;
484
517
  try {
485
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
486
- var _product$metadata, _options$productsByUi;
487
- var product = _step3.value;
488
- var productUid = (_product$metadata = product.metadata) === null || _product$metadata === void 0 ? void 0 : _product$metadata.unique_identification_number;
518
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
519
+ var _product$metadata3, _options$productsByUi;
520
+ var product = _step4.value;
521
+ var productUid = (_product$metadata3 = product.metadata) === null || _product$metadata3 === void 0 ? void 0 : _product$metadata3.unique_identification_number;
489
522
  var runtimeOrigin = productUid ? options === null || options === void 0 || (_options$productsByUi = options.productsByUid) === null || _options$productsByUi === void 0 || (_options$productsByUi = _options$productsByUi[productUid]) === null || _options$productsByUi === void 0 ? void 0 : _options$productsByUi.origin : undefined;
490
523
  var deposit = getOrderProductDeposit(product, runtimeOrigin);
491
524
  product.deposit = deposit;
492
525
  if (!(deposit !== null && deposit !== void 0 && deposit.total) || Number(deposit.total) <= 0) continue;
493
526
  total = total.plus(deposit.total);
494
- var _iterator4 = _createForOfIteratorHelper(deposit.protocols || []),
495
- _step4;
527
+ var _iterator5 = _createForOfIteratorHelper(deposit.protocols || []),
528
+ _step5;
496
529
  try {
497
- for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
498
- var protocol = _step4.value;
530
+ for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
531
+ var protocol = _step5.value;
499
532
  if (!protocolMap.has(protocol.id)) protocolMap.set(protocol.id, protocol);
500
533
  }
501
534
  } catch (err) {
502
- _iterator4.e(err);
535
+ _iterator5.e(err);
503
536
  } finally {
504
- _iterator4.f();
537
+ _iterator5.f();
505
538
  }
506
539
  hasDeposit = true;
507
540
  }
508
541
  } catch (err) {
509
- _iterator3.e(err);
542
+ _iterator4.e(err);
510
543
  } finally {
511
- _iterator3.f();
544
+ _iterator4.f();
512
545
  }
513
546
  var roundedTotal = total.toDecimalPlaces(2, Decimal.ROUND_HALF_UP);
514
547
  var protocols = _toConsumableArray(protocolMap.values());
@@ -544,12 +577,12 @@ export function isMarkdownBundle(bundle) {
544
577
  * - markup(加价)/原价子商品:维持 `+(bundle_selling_price ?? price)`,行为不变。
545
578
  */
546
579
  export function getBundleSignedUnit(bundle, options) {
547
- var _options$useOriginal, _ref16, _bundle$original_pric2, _bundle$bundle_sellin;
580
+ var _options$useOriginal, _ref17, _bundle$original_pric2, _bundle$bundle_sellin;
548
581
  if (!bundle || _typeof(bundle) !== 'object') return new Decimal(0);
549
582
  var useOriginal = (_options$useOriginal = options === null || options === void 0 ? void 0 : options.useOriginal) !== null && _options$useOriginal !== void 0 ? _options$useOriginal : false;
550
583
  if (isMarkdownBundle(bundle)) {
551
- var _ref10, _ref11, _ref12, _bundle$original_pric, _ref13, _ref14, _ref15, _bundle$custom_price;
552
- var catalog = useOriginal ? (_ref10 = (_ref11 = (_ref12 = (_bundle$original_pric = bundle.original_price) !== null && _bundle$original_pric !== void 0 ? _bundle$original_pric : bundle.product_price) !== null && _ref12 !== void 0 ? _ref12 : bundle.custom_price) !== null && _ref11 !== void 0 ? _ref11 : bundle.base_price) !== null && _ref10 !== void 0 ? _ref10 : bundle.price : (_ref13 = (_ref14 = (_ref15 = (_bundle$custom_price = bundle.custom_price) !== null && _bundle$custom_price !== void 0 ? _bundle$custom_price : bundle.product_price) !== null && _ref15 !== void 0 ? _ref15 : bundle.original_price) !== null && _ref14 !== void 0 ? _ref14 : bundle.base_price) !== null && _ref13 !== void 0 ? _ref13 : bundle.price;
584
+ var _ref11, _ref12, _ref13, _bundle$original_pric, _ref14, _ref15, _ref16, _bundle$custom_price;
585
+ var catalog = useOriginal ? (_ref11 = (_ref12 = (_ref13 = (_bundle$original_pric = bundle.original_price) !== null && _bundle$original_pric !== void 0 ? _bundle$original_pric : bundle.product_price) !== null && _ref13 !== void 0 ? _ref13 : bundle.custom_price) !== null && _ref12 !== void 0 ? _ref12 : bundle.base_price) !== null && _ref11 !== void 0 ? _ref11 : bundle.price : (_ref14 = (_ref15 = (_ref16 = (_bundle$custom_price = bundle.custom_price) !== null && _bundle$custom_price !== void 0 ? _bundle$custom_price : bundle.product_price) !== null && _ref16 !== void 0 ? _ref16 : bundle.original_price) !== null && _ref15 !== void 0 ? _ref15 : bundle.base_price) !== null && _ref14 !== void 0 ? _ref14 : bundle.price;
553
586
  if (catalog !== undefined && catalog !== null && catalog !== '') {
554
587
  var raw = new Decimal(Number(catalog) || 0);
555
588
  // 负值表示价格已是「带符号净额」(如 cart/changePrice 产出的 -3.7),直接取用不再扣 option,
@@ -560,7 +593,7 @@ export function getBundleSignedUnit(bundle, options) {
560
593
  // 仅剩净额(无毛价)兜底:直接取负,不再扣 option
561
594
  return new Decimal(Number(bundle.bundle_selling_price) || 0).abs().negated();
562
595
  }
563
- var rawPrice = useOriginal ? (_ref16 = (_bundle$original_pric2 = bundle.original_price) !== null && _bundle$original_pric2 !== void 0 ? _bundle$original_pric2 : bundle.product_price) !== null && _ref16 !== void 0 ? _ref16 : bundle.price : (_bundle$bundle_sellin = bundle.bundle_selling_price) !== null && _bundle$bundle_sellin !== void 0 ? _bundle$bundle_sellin : bundle.price;
596
+ var rawPrice = useOriginal ? (_ref17 = (_bundle$original_pric2 = bundle.original_price) !== null && _bundle$original_pric2 !== void 0 ? _bundle$original_pric2 : bundle.product_price) !== null && _ref17 !== void 0 ? _ref17 : bundle.price : (_bundle$bundle_sellin = bundle.bundle_selling_price) !== null && _bundle$bundle_sellin !== void 0 ? _bundle$bundle_sellin : bundle.price;
564
597
  return new Decimal(Number(rawPrice) || 0);
565
598
  }
566
599
 
@@ -684,19 +717,19 @@ function ensureSubmitDiscountIdentity(discount) {
684
717
  }
685
718
  function collectSubmitProductDiscountList(product) {
686
719
  var submitDiscountList = Array.isArray(product === null || product === void 0 ? void 0 : product.discount_list) ? _toConsumableArray(product.discount_list) : [];
687
- var _iterator5 = _createForOfIteratorHelper((product === null || product === void 0 ? void 0 : product.product_bundle) || []),
688
- _step5;
720
+ var _iterator6 = _createForOfIteratorHelper((product === null || product === void 0 ? void 0 : product.product_bundle) || []),
721
+ _step6;
689
722
  try {
690
- for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
691
- var bundle = _step5.value;
723
+ for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
724
+ var bundle = _step6.value;
692
725
  if (!bundle || _typeof(bundle) !== 'object') continue;
693
726
  var bundleMapId = resolveSubmitBundleMapId(bundle);
694
727
  var bundleDiscountList = Array.isArray(bundle.discount_list) ? bundle.discount_list : [];
695
- var _iterator6 = _createForOfIteratorHelper(bundleDiscountList),
696
- _step6;
728
+ var _iterator7 = _createForOfIteratorHelper(bundleDiscountList),
729
+ _step7;
697
730
  try {
698
- for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
699
- var discount = _step6.value;
731
+ for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
732
+ var discount = _step7.value;
700
733
  if (!discount || _typeof(discount) !== 'object') continue;
701
734
  var discountMetadata = discount.metadata && _typeof(discount.metadata) === 'object' ? discount.metadata : {};
702
735
  var discountMapId = discountMetadata.custom_product_bundle_map_id !== undefined && discountMetadata.custom_product_bundle_map_id !== null && discountMetadata.custom_product_bundle_map_id !== '' ? discountMetadata.custom_product_bundle_map_id : bundleMapId;
@@ -707,15 +740,15 @@ function collectSubmitProductDiscountList(product) {
707
740
  } : {}));
708
741
  }
709
742
  } catch (err) {
710
- _iterator6.e(err);
743
+ _iterator7.e(err);
711
744
  } finally {
712
- _iterator6.f();
745
+ _iterator7.f();
713
746
  }
714
747
  }
715
748
  } catch (err) {
716
- _iterator5.e(err);
749
+ _iterator6.e(err);
717
750
  } finally {
718
- _iterator5.f();
751
+ _iterator6.f();
719
752
  }
720
753
  return normalizeOrderProductDiscountList(submitDiscountList.map(ensureSubmitDiscountIdentity));
721
754
  }
@@ -792,26 +825,26 @@ export function resolveEffectivePerUnitDiscount(product) {
792
825
  }
793
826
  export function createDefaultOrderRulesHooks(getBookings, getHolderRelations) {
794
827
  var getProductStartDate = function getProductStartDate(product) {
795
- var _ref17, _product$metadata$uni, _product$metadata2, _ref18, _product$booking_uid, _product$metadata3, _product$metadata4, _product$metadata5, _product$metadata6;
796
- var productUid = String((_ref17 = (_product$metadata$uni = (_product$metadata2 = product.metadata) === null || _product$metadata2 === void 0 ? void 0 : _product$metadata2.unique_identification_number) !== null && _product$metadata$uni !== void 0 ? _product$metadata$uni : product.unique_identification_number) !== null && _ref17 !== void 0 ? _ref17 : '');
797
- var bookingUid = String((_ref18 = (_product$booking_uid = product.booking_uid) !== null && _product$booking_uid !== void 0 ? _product$booking_uid : (_product$metadata3 = product.metadata) === null || _product$metadata3 === void 0 ? void 0 : _product$metadata3.booking_uid) !== null && _ref18 !== void 0 ? _ref18 : '');
828
+ var _ref18, _product$metadata$uni, _product$metadata4, _ref19, _product$booking_uid, _product$metadata5, _product$metadata6, _product$metadata7, _product$metadata8;
829
+ var productUid = String((_ref18 = (_product$metadata$uni = (_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4.unique_identification_number) !== null && _product$metadata$uni !== void 0 ? _product$metadata$uni : product.unique_identification_number) !== null && _ref18 !== void 0 ? _ref18 : '');
830
+ var bookingUid = String((_ref19 = (_product$booking_uid = product.booking_uid) !== null && _product$booking_uid !== void 0 ? _product$booking_uid : (_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.booking_uid) !== null && _ref19 !== void 0 ? _ref19 : '');
798
831
  // 每次读取当前 bookings,覆盖改期、订单回显以及直接调用 Rules 的选券入口。
799
832
  var bookings = (getBookings === null || getBookings === void 0 ? void 0 : getBookings()) || [];
800
833
  var booking = bookings.find(function (item) {
801
- var _ref19, _item$product_uid, _item$metadata3;
802
- return productUid && String((_ref19 = (_item$product_uid = item === null || item === void 0 ? void 0 : item.product_uid) !== null && _item$product_uid !== void 0 ? _item$product_uid : item === null || item === void 0 || (_item$metadata3 = item.metadata) === null || _item$metadata3 === void 0 ? void 0 : _item$metadata3.product_uid) !== null && _ref19 !== void 0 ? _ref19 : '') === productUid;
834
+ var _ref20, _item$product_uid, _item$metadata3;
835
+ return productUid && String((_ref20 = (_item$product_uid = item === null || item === void 0 ? void 0 : item.product_uid) !== null && _item$product_uid !== void 0 ? _item$product_uid : item === null || item === void 0 || (_item$metadata3 = item.metadata) === null || _item$metadata3 === void 0 ? void 0 : _item$metadata3.product_uid) !== null && _ref20 !== void 0 ? _ref20 : '') === productUid;
803
836
  }) || bookings.find(function (item) {
804
- var _ref20, _item$metadata$unique, _item$metadata4;
805
- return bookingUid && String((_ref20 = (_item$metadata$unique = item === null || item === void 0 || (_item$metadata4 = item.metadata) === null || _item$metadata4 === void 0 ? void 0 : _item$metadata4.unique_identification_number) !== null && _item$metadata$unique !== void 0 ? _item$metadata$unique : item === null || item === void 0 ? void 0 : item.booking_uid) !== null && _ref20 !== void 0 ? _ref20 : '') === bookingUid;
837
+ var _ref21, _item$metadata$unique, _item$metadata4;
838
+ return bookingUid && String((_ref21 = (_item$metadata$unique = item === null || item === void 0 || (_item$metadata4 = item.metadata) === null || _item$metadata4 === void 0 ? void 0 : _item$metadata4.unique_identification_number) !== null && _item$metadata$unique !== void 0 ? _item$metadata$unique : item === null || item === void 0 ? void 0 : item.booking_uid) !== null && _ref21 !== void 0 ? _ref21 : '') === bookingUid;
806
839
  });
807
840
  if (booking) {
808
841
  // 严格解析并保留 Invalid Date,让公共时间校验拒绝缺失/非法时间,避免回退到当前时间。
809
842
  return dayjs("".concat(booking.start_date, " ").concat(booking.start_time), ['YYYY-MM-DD HH:mm', 'YYYY-MM-DD HH:mm:ss', 'YYYY-MM-DD H:mm', 'YYYY-MM-DD H:mm:ss'], true);
810
843
  }
811
- if (getBookings && (bookingUid || product.booking_id || (_product$metadata4 = product.metadata) !== null && _product$metadata4 !== void 0 && _product$metadata4.booking_id)) {
844
+ if (getBookings && (bookingUid || product.booking_id || (_product$metadata6 = product.metadata) !== null && _product$metadata6 !== void 0 && _product$metadata6.booking_id)) {
812
845
  return dayjs('');
813
846
  }
814
- var legacyStartDate = ((_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.start_date) || ((_product$metadata6 = product.metadata) === null || _product$metadata6 === void 0 ? void 0 : _product$metadata6.startDate);
847
+ var legacyStartDate = ((_product$metadata7 = product.metadata) === null || _product$metadata7 === void 0 ? void 0 : _product$metadata7.start_date) || ((_product$metadata8 = product.metadata) === null || _product$metadata8 === void 0 ? void 0 : _product$metadata8.startDate);
815
848
  return legacyStartDate ? dayjs(legacyStartDate) : undefined;
816
849
  };
817
850
  var toUnitPriceString = function toUnitPriceString(totalLike, num) {
@@ -828,8 +861,8 @@ export function createDefaultOrderRulesHooks(getBookings, getHolderRelations) {
828
861
  }, new Decimal(0));
829
862
  };
830
863
  var getBundleIdentity = function getBundleIdentity(bundle) {
831
- var _ref21, _bundle$bundle_id, _ref22, _ref23, _bundle$bundle_produc, _ref24, _ref25, _bundle$bundle_varian, _ref26, _bundle$bundle_group_;
832
- return [(_ref21 = (_bundle$bundle_id = bundle.bundle_id) !== null && _bundle$bundle_id !== void 0 ? _bundle$bundle_id : bundle.id) !== null && _ref21 !== void 0 ? _ref21 : '', (_ref22 = (_ref23 = (_bundle$bundle_produc = bundle.bundle_product_id) !== null && _bundle$bundle_produc !== void 0 ? _bundle$bundle_produc : bundle._bundle_product_id) !== null && _ref23 !== void 0 ? _ref23 : bundle.product_id) !== null && _ref22 !== void 0 ? _ref22 : '', (_ref24 = (_ref25 = (_bundle$bundle_varian = bundle.bundle_variant_id) !== null && _bundle$bundle_varian !== void 0 ? _bundle$bundle_varian : bundle.variant_id) !== null && _ref25 !== void 0 ? _ref25 : bundle.product_variant_id) !== null && _ref24 !== void 0 ? _ref24 : 0, (_ref26 = (_bundle$bundle_group_ = bundle.bundle_group_id) !== null && _bundle$bundle_group_ !== void 0 ? _bundle$bundle_group_ : bundle.group_id) !== null && _ref26 !== void 0 ? _ref26 : ''].join('|');
864
+ var _ref22, _bundle$bundle_id, _ref23, _ref24, _bundle$bundle_produc, _ref25, _ref26, _bundle$bundle_varian, _ref27, _bundle$bundle_group_;
865
+ return [(_ref22 = (_bundle$bundle_id = bundle.bundle_id) !== null && _bundle$bundle_id !== void 0 ? _bundle$bundle_id : bundle.id) !== null && _ref22 !== void 0 ? _ref22 : '', (_ref23 = (_ref24 = (_bundle$bundle_produc = bundle.bundle_product_id) !== null && _bundle$bundle_produc !== void 0 ? _bundle$bundle_produc : bundle._bundle_product_id) !== null && _ref24 !== void 0 ? _ref24 : bundle.product_id) !== null && _ref23 !== void 0 ? _ref23 : '', (_ref25 = (_ref26 = (_bundle$bundle_varian = bundle.bundle_variant_id) !== null && _bundle$bundle_varian !== void 0 ? _bundle$bundle_varian : bundle.variant_id) !== null && _ref26 !== void 0 ? _ref26 : bundle.product_variant_id) !== null && _ref25 !== void 0 ? _ref25 : 0, (_ref27 = (_bundle$bundle_group_ = bundle.bundle_group_id) !== null && _bundle$bundle_group_ !== void 0 ? _bundle$bundle_group_ : bundle.group_id) !== null && _ref27 !== void 0 ? _ref27 : ''].join('|');
833
866
  };
834
867
  var mergeRulesBundlePrices = function mergeRulesBundlePrices(currentBundle, rulesBundle) {
835
868
  if (!Array.isArray(rulesBundle)) return rulesBundle;
@@ -839,7 +872,7 @@ export function createDefaultOrderRulesHooks(getBookings, getHolderRelations) {
839
872
  currentByIdentity.set(getBundleIdentity(bundle), bundle);
840
873
  });
841
874
  return rulesBundle.map(function (bundle) {
842
- var _bundle$price_type_ex2, _ref27, _ref28, _current$price, _ref29, _ref30, _ref31, _current$original_pri;
875
+ var _bundle$price_type_ex2, _ref28, _ref29, _current$price, _ref30, _ref31, _ref32, _current$original_pri;
843
876
  if (!bundle || _typeof(bundle) !== 'object') return bundle;
844
877
  var current = currentByIdentity.get(getBundleIdentity(bundle));
845
878
  if (!current) return bundle;
@@ -848,8 +881,8 @@ export function createDefaultOrderRulesHooks(getBookings, getHolderRelations) {
848
881
  } : {});
849
882
  var isProductPriceBundle = ((_bundle$price_type_ex2 = bundle.price_type_ext) !== null && _bundle$price_type_ex2 !== void 0 ? _bundle$price_type_ex2 : current.price_type_ext) === 'product_price';
850
883
  if (!isProductPriceBundle) return bundleWithDisplayFields;
851
- var sourcePrice = (_ref27 = (_ref28 = (_current$price = current.price) !== null && _current$price !== void 0 ? _current$price : current.custom_price) !== null && _ref28 !== void 0 ? _ref28 : current.original_price) !== null && _ref27 !== void 0 ? _ref27 : current.bundle_selling_price;
852
- var originalPrice = (_ref29 = (_ref30 = (_ref31 = (_current$original_pri = current.original_price) !== null && _current$original_pri !== void 0 ? _current$original_pri : current.product_price) !== null && _ref31 !== void 0 ? _ref31 : current.price) !== null && _ref30 !== void 0 ? _ref30 : current.custom_price) !== null && _ref29 !== void 0 ? _ref29 : sourcePrice;
884
+ var sourcePrice = (_ref28 = (_ref29 = (_current$price = current.price) !== null && _current$price !== void 0 ? _current$price : current.custom_price) !== null && _ref29 !== void 0 ? _ref29 : current.original_price) !== null && _ref28 !== void 0 ? _ref28 : current.bundle_selling_price;
885
+ var originalPrice = (_ref30 = (_ref31 = (_ref32 = (_current$original_pri = current.original_price) !== null && _current$original_pri !== void 0 ? _current$original_pri : current.product_price) !== null && _ref32 !== void 0 ? _ref32 : current.price) !== null && _ref31 !== void 0 ? _ref31 : current.custom_price) !== null && _ref30 !== void 0 ? _ref30 : sourcePrice;
853
886
  return _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, bundleWithDisplayFields), sourcePrice !== undefined ? {
854
887
  price: sourcePrice
855
888
  } : {}), originalPrice !== undefined ? {
@@ -861,7 +894,7 @@ export function createDefaultOrderRulesHooks(getBookings, getHolderRelations) {
861
894
  };
862
895
  return {
863
896
  getProduct: function getProduct(product) {
864
- var _product$metadata7, _product$metadata8, _product$metadata9, _metadataAny$_promoti;
897
+ var _product$metadata9, _product$metadata10, _product$metadata11, _metadataAny$_promoti;
865
898
  // source_product_price 是权威源;兜底链:source → mainSelling − options(反推)→ 行 selling_price
866
899
  var metadataAny = product.metadata || {};
867
900
  var productOptions = getProductSkuOptions(product);
@@ -890,7 +923,7 @@ export function createDefaultOrderRulesHooks(getBookings, getHolderRelations) {
890
923
  // 否则同 SKU 不同小料会在 calcDiscount 重组时互相覆盖。
891
924
  // 不透明 identity 契约下,normalizeOrderProduct / hydrate 已保证唯一值存在;
892
925
  // 留 fingerprint 分支仅作 Rules 单测里直接传裸 product 时的兜底。
893
- _id: (_product$metadata7 = product.metadata) !== null && _product$metadata7 !== void 0 && _product$metadata7.unique_identification_number ? "".concat(product.product_id, "_").concat(product.product_variant_id, "_").concat(product.metadata.unique_identification_number) : "".concat(product.product_id, "_").concat(product.product_variant_id, "_").concat(buildProductLineFingerprint(getProductSkuOptions(product), product.product_bundle)),
926
+ _id: (_product$metadata9 = product.metadata) !== null && _product$metadata9 !== void 0 && _product$metadata9.unique_identification_number ? "".concat(product.product_id, "_").concat(product.product_variant_id, "_").concat(product.metadata.unique_identification_number) : "".concat(product.product_id, "_").concat(product.product_variant_id, "_").concat(buildProductLineFingerprint(getProductSkuOptions(product), product.product_bundle)),
894
927
  // Rules 内部 getProductTotalPrice / getProductOriginTotalPrice 会各自再叠加 bundle + option,
895
928
  // 所以这里必须喂 source-level(不含 option、不含 bundle、不含折扣)单价,避免双加 option。
896
929
  price: sourcePrice,
@@ -908,12 +941,12 @@ export function createDefaultOrderRulesHooks(getBookings, getHolderRelations) {
908
941
  price: option.add_price
909
942
  });
910
943
  }),
911
- booking_id: ((_product$metadata8 = product.metadata) === null || _product$metadata8 === void 0 ? void 0 : _product$metadata8.booking_id) || null,
944
+ booking_id: ((_product$metadata10 = product.metadata) === null || _product$metadata10 === void 0 ? void 0 : _product$metadata10.booking_id) || null,
912
945
  isClient: false,
913
946
  // 勿写死 false:否则 Rules 不会走 total≠origin_total 的手动价推断,
914
947
  // 无券时会把 bundle 价还原成 original_price(手动改价套餐会从 20 回到 30)。
915
948
  isManualDiscount: resolveRulesManualDiscountFlag(metadataAny),
916
- holder_id: hasProductBooking(product) || !getHolderRelations ? (_product$metadata9 = product.metadata) === null || _product$metadata9 === void 0 ? void 0 : _product$metadata9.holder_id : getProductHolderRelations({
949
+ holder_id: hasProductBooking(product) || !getHolderRelations ? (_product$metadata11 = product.metadata) === null || _product$metadata11 === void 0 ? void 0 : _product$metadata11.holder_id : getProductHolderRelations({
917
950
  holder_relations: getHolderRelations()
918
951
  }, product).filter(function (relation) {
919
952
  return relation.holder_type === 'form';
@@ -927,10 +960,10 @@ export function createDefaultOrderRulesHooks(getBookings, getHolderRelations) {
927
960
  };
928
961
  },
929
962
  setProduct: function setProduct(product, values) {
930
- var _ref32, _values$quantity, _ref33, _metadataAny$source_p, _values$discount_list, _product$product_sku, _values$quantity2;
931
- var nextNum = Number((_ref32 = (_values$quantity = values.quantity) !== null && _values$quantity !== void 0 ? _values$quantity : product.num) !== null && _ref32 !== void 0 ? _ref32 : 1) || 1;
963
+ var _ref33, _values$quantity, _ref34, _metadataAny$source_p, _values$discount_list, _product$product_sku, _values$quantity2;
964
+ var nextNum = Number((_ref33 = (_values$quantity = values.quantity) !== null && _values$quantity !== void 0 ? _values$quantity : product.num) !== null && _ref33 !== void 0 ? _ref33 : 1) || 1;
932
965
  var metadataAny = product.metadata || {};
933
- var existedSource = (_ref33 = (_metadataAny$source_p = metadataAny.source_product_price) !== null && _metadataAny$source_p !== void 0 ? _metadataAny$source_p : product.selling_price) !== null && _ref33 !== void 0 ? _ref33 : '0';
966
+ var existedSource = (_ref34 = (_metadataAny$source_p = metadataAny.source_product_price) !== null && _metadataAny$source_p !== void 0 ? _metadataAny$source_p : product.selling_price) !== null && _ref34 !== void 0 ? _ref34 : '0';
934
967
  var nextOptions = getProductSkuOptions(product);
935
968
  var optionSum = sumOptionUnitPrice(nextOptions);
936
969
  var nextDiscountList = (_values$discount_list = values.discount_list) !== null && _values$discount_list !== void 0 ? _values$discount_list : product.discount_list;
@@ -1143,7 +1176,7 @@ function formatSubmitBundleItems(bundle) {
1143
1176
  var formatOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1144
1177
  if (!Array.isArray(bundle)) return [];
1145
1178
  return bundle.map(function (b) {
1146
- var _ref34, _rawBundle$price, _rawBundle$surcharge_, _rawBundle$num, _rawBundle$is_charge_, _rawBundle$bundle_var, _rawBundle$quantity, _rawBundle$extension_, _rawBundle$extension_2, _ref35, _rawBundle$price_type, _ref36, _rawBundle$price_type2, _rawBundle$bundle_gro, _rawBundle$bundle_id, _rawBundle$bundle_pro;
1179
+ var _ref35, _rawBundle$price, _rawBundle$surcharge_, _rawBundle$num, _rawBundle$is_charge_, _rawBundle$bundle_var, _rawBundle$quantity, _rawBundle$extension_, _rawBundle$extension_2, _ref36, _rawBundle$price_type, _ref37, _rawBundle$price_type2, _rawBundle$bundle_gro, _rawBundle$bundle_id, _rawBundle$bundle_pro;
1147
1180
  var rawBundle = b && _typeof(b) === 'object' ? b : {};
1148
1181
  var existedMetadata = rawBundle.metadata && _typeof(rawBundle.metadata) === 'object' ? rawBundle.metadata : {};
1149
1182
  var _customProductBundleMapId = existedMetadata.custom_product_bundle_map_id,
@@ -1154,7 +1187,7 @@ function formatSubmitBundleItems(bundle) {
1154
1187
  var sellingPrice = formatOptions.virtualSettlementMode ? '0.00' : getBundleSellingMagnitude(rawBundle).toFixed(2);
1155
1188
  // payment 价由整单折扣均摊层产出;缺省(无折扣)时与 selling 净额同义。
1156
1189
  var paymentPrice = formatOptions.virtualSettlementMode ? '0.00' : rawBundle.bundle_payment_price !== undefined && rawBundle.bundle_payment_price !== null && rawBundle.bundle_payment_price !== '' ? toMoneyString(rawBundle.bundle_payment_price) : sellingPrice;
1157
- var priceValue = formatOptions.virtualSettlementMode ? 0 : (_ref34 = (_rawBundle$price = rawBundle.price) !== null && _rawBundle$price !== void 0 ? _rawBundle$price : rawBundle.custom_price) !== null && _ref34 !== void 0 ? _ref34 : rawBundle.bundle_selling_price;
1190
+ var priceValue = formatOptions.virtualSettlementMode ? 0 : (_ref35 = (_rawBundle$price = rawBundle.price) !== null && _rawBundle$price !== void 0 ? _rawBundle$price : rawBundle.custom_price) !== null && _ref35 !== void 0 ? _ref35 : rawBundle.bundle_selling_price;
1158
1191
  var relationSurchargeIds = Array.isArray(rawBundle.relation_surcharge_ids) ? rawBundle.relation_surcharge_ids : Array.isArray(existedMetadata.relation_surcharge_ids) ? existedMetadata.relation_surcharge_ids : [];
1159
1192
  var surchargeFee = toMoneyString((_rawBundle$surcharge_ = rawBundle.surcharge_fee) !== null && _rawBundle$surcharge_ !== void 0 ? _rawBundle$surcharge_ : existedMetadata.surcharge_fee);
1160
1193
  var productDiscountDifference = toBundleNumber(existedMetadata.product_discount_difference, 0);
@@ -1173,8 +1206,8 @@ function formatSubmitBundleItems(bundle) {
1173
1206
  extension_id: (_rawBundle$extension_ = rawBundle.extension_id) !== null && _rawBundle$extension_ !== void 0 ? _rawBundle$extension_ : 0,
1174
1207
  extension_type: (_rawBundle$extension_2 = rawBundle.extension_type) !== null && _rawBundle$extension_2 !== void 0 ? _rawBundle$extension_2 : 'normal',
1175
1208
  price: priceValue,
1176
- price_type: (_ref35 = (_rawBundle$price_type = rawBundle.price_type) !== null && _rawBundle$price_type !== void 0 ? _rawBundle$price_type : rawBundle.custom_price_type) !== null && _ref35 !== void 0 ? _ref35 : '',
1177
- price_type_ext: (_ref36 = (_rawBundle$price_type2 = rawBundle.price_type_ext) !== null && _rawBundle$price_type2 !== void 0 ? _rawBundle$price_type2 : rawBundle.custom_price_type_ext) !== null && _ref36 !== void 0 ? _ref36 : '',
1209
+ price_type: (_ref36 = (_rawBundle$price_type = rawBundle.price_type) !== null && _rawBundle$price_type !== void 0 ? _rawBundle$price_type : rawBundle.custom_price_type) !== null && _ref36 !== void 0 ? _ref36 : '',
1210
+ price_type_ext: (_ref37 = (_rawBundle$price_type2 = rawBundle.price_type_ext) !== null && _rawBundle$price_type2 !== void 0 ? _rawBundle$price_type2 : rawBundle.custom_price_type_ext) !== null && _ref37 !== void 0 ? _ref37 : '',
1178
1211
  bundle_selling_price: sellingPrice,
1179
1212
  bundle_payment_price: paymentPrice,
1180
1213
  option: formatSubmitOptionItems(rawBundle.option, formatOptions),
@@ -1210,11 +1243,11 @@ function formatSubmitBundleItems(bundle) {
1210
1243
  * 法币仅做字段/metadata 裁剪;虚拟币在出站前再次执行零加价与固定单价断言。
1211
1244
  */
1212
1245
  function normalizeSubmitProduct(product) {
1213
- var _ref38, _submitProduct$bundle, _rawMetadata$product_, _rawMetadata$selected, _rawMetadata$selected2, _submitProduct$produc, _submitProduct$paymen;
1246
+ var _ref39, _submitProduct$bundle, _rawMetadata$product_, _rawMetadata$selected, _rawMetadata$selected2, _submitProduct$produc, _submitProduct$paymen;
1214
1247
  var formatOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1215
- var _ref37 = product,
1216
- _runtimeUid = _ref37.unique_identification_number,
1217
- submitProduct = _objectWithoutProperties(_ref37, _excluded2);
1248
+ var _ref38 = product,
1249
+ _runtimeUid = _ref38.unique_identification_number,
1250
+ submitProduct = _objectWithoutProperties(_ref38, _excluded2);
1218
1251
  var num = submitProduct.num,
1219
1252
  _productExtend = submitProduct._extend,
1220
1253
  _productSurchargeFee = submitProduct.surcharge_fee,
@@ -1232,7 +1265,7 @@ function normalizeSubmitProduct(product) {
1232
1265
  // 兼容历史 BigSale 编辑链路:bundle_edit 曾被写入 metadata,
1233
1266
  // 出站时需提升到商品顶层;套餐未编辑时也必须显式提交 0。
1234
1267
  var hasProductBundle = Array.isArray(submitProduct.product_bundle) && submitProduct.product_bundle.length > 0;
1235
- var bundleEdit = (_ref38 = (_submitProduct$bundle = submitProduct.bundle_edit) !== null && _submitProduct$bundle !== void 0 ? _submitProduct$bundle : rawMetadata.bundle_edit) !== null && _ref38 !== void 0 ? _ref38 : hasProductBundle ? 0 : undefined;
1268
+ var bundleEdit = (_ref39 = (_submitProduct$bundle = submitProduct.bundle_edit) !== null && _submitProduct$bundle !== void 0 ? _submitProduct$bundle : rawMetadata.bundle_edit) !== null && _ref39 !== void 0 ? _ref39 : hasProductBundle ? 0 : undefined;
1236
1269
  var cleanMetadata = {};
1237
1270
  if (rawMetadata.unique_identification_number) {
1238
1271
  cleanMetadata.unique_identification_number = rawMetadata.unique_identification_number;
@@ -1309,19 +1342,19 @@ export function redeemEventKey(value) {
1309
1342
  export function restoreRedeemVoucherTimes(order, vouchers) {
1310
1343
  if (!Array.isArray(vouchers) || !vouchers.length) return vouchers;
1311
1344
  var markedBookings = new Map();
1312
- var _iterator7 = _createForOfIteratorHelper(order.bookings || []),
1313
- _step7;
1345
+ var _iterator8 = _createForOfIteratorHelper(order.bookings || []),
1346
+ _step8;
1314
1347
  try {
1315
- for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
1348
+ for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
1316
1349
  var _booking$metadata;
1317
- var booking = _step7.value;
1350
+ var booking = _step8.value;
1318
1351
  var event = redeemEventKey(booking === null || booking === void 0 ? void 0 : booking.schedule_event_id);
1319
1352
  if (event && Number((_booking$metadata = booking.metadata) === null || _booking$metadata === void 0 ? void 0 : _booking$metadata.is_change_by_redeem) === 1) markedBookings.set(event, booking);
1320
1353
  }
1321
1354
  } catch (err) {
1322
- _iterator7.e(err);
1355
+ _iterator8.e(err);
1323
1356
  } finally {
1324
- _iterator7.f();
1357
+ _iterator8.f();
1325
1358
  }
1326
1359
  if (!markedBookings.size) return vouchers;
1327
1360
  var restored = vouchers;
@@ -1337,10 +1370,10 @@ export function restoreRedeemVoucherTimes(order, vouchers) {
1337
1370
  }), booking.end_date && {
1338
1371
  expire_date: booking.end_date
1339
1372
  });
1340
- var timeChanged = Object.entries(times).some(function (_ref39) {
1341
- var _ref40 = _slicedToArray(_ref39, 2),
1342
- key = _ref40[0],
1343
- value = _ref40[1];
1373
+ var timeChanged = Object.entries(times).some(function (_ref40) {
1374
+ var _ref41 = _slicedToArray(_ref40, 2),
1375
+ key = _ref41[0],
1376
+ value = _ref41[1];
1344
1377
  return voucher[key] !== value;
1345
1378
  });
1346
1379
  if (!timeChanged) return;
@@ -1363,19 +1396,19 @@ export function normalizeBookingSubType(booking) {
1363
1396
  export function normalizeSubmitBooking(booking) {
1364
1397
  var rawMetadata = booking.metadata || {};
1365
1398
  var cleanMetadata = {};
1366
- var _iterator8 = _createForOfIteratorHelper(SUBMIT_BOOKING_METADATA_WHITELIST),
1367
- _step8;
1399
+ var _iterator9 = _createForOfIteratorHelper(SUBMIT_BOOKING_METADATA_WHITELIST),
1400
+ _step9;
1368
1401
  try {
1369
- for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
1370
- var key = _step8.value;
1402
+ for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
1403
+ var key = _step9.value;
1371
1404
  if (rawMetadata[key] !== undefined) {
1372
1405
  cleanMetadata[key] = rawMetadata[key];
1373
1406
  }
1374
1407
  }
1375
1408
  } catch (err) {
1376
- _iterator8.e(err);
1409
+ _iterator9.e(err);
1377
1410
  } finally {
1378
- _iterator8.f();
1411
+ _iterator9.f();
1379
1412
  }
1380
1413
  if (cleanMetadata.holder_id === undefined && !isFulfillmentTimingBooking(booking)) {
1381
1414
  cleanMetadata.holder_id = null;
@@ -1525,7 +1558,7 @@ export function resolveSubmitOrderType(params) {
1525
1558
  return 'virtual';
1526
1559
  }
1527
1560
  export function buildSubmitPayload(params) {
1528
- var _tempOrder$metadata2, _tempOrder$customer_i, _tempOrder$country_ca, _tempOrder$phone, _tempOrder$email, _tempOrder$order_numb, _tempOrder$shop_order, _tempOrder$shop_full_, _ref42, _tempOrder$is_price_i, _tempOrder$is_deposit, _tempOrder$_extend, _enhancedPayload$summ;
1561
+ var _tempOrder$metadata2, _tempOrder$customer_i, _tempOrder$country_ca, _tempOrder$phone, _tempOrder$email, _tempOrder$order_numb, _tempOrder$shop_order, _tempOrder$shop_full_, _ref43, _tempOrder$is_price_i, _tempOrder$is_deposit, _tempOrder$_extend, _enhancedPayload$summ;
1529
1562
  var tempOrder = params.tempOrder,
1530
1563
  cacheId = params.cacheId,
1531
1564
  _params$now = params.now,
@@ -1540,29 +1573,29 @@ export function buildSubmitPayload(params) {
1540
1573
  var scheduleDate = tempOrder.schedule_date || tempOrder.created_at || formatDateTime(now);
1541
1574
  var bookingUuid = createUuidV4();
1542
1575
  var virtualSettlementMode = ((_tempOrder$metadata2 = tempOrder.metadata) === null || _tempOrder$metadata2 === void 0 || (_tempOrder$metadata2 = _tempOrder$metadata2.currency_settlement_config) === null || _tempOrder$metadata2 === void 0 ? void 0 : _tempOrder$metadata2.settlement_type) === 'virtual_currency';
1543
- var _ref41 = tempOrder,
1544
- _extend = _ref41._extend,
1545
- _relationId = _ref41.relation_id,
1546
- _tableFormId = _ref41.table_form_id,
1547
- _resourceId = _ref41.resource_id,
1548
- _summary = _ref41.summary,
1549
- _lastOrderInfo = _ref41.lastOrderInfo,
1550
- _paidAmount = _ref41.paid_amount,
1551
- _shopId = _ref41.shop_id,
1552
- _shopNote = _ref41.shop_note,
1553
- _shopServiceType = _ref41.shop_service_type,
1554
- _startTime = _ref41.start_time,
1555
- _customer = _ref41.customer,
1556
- _discountList = _ref41.discount_list,
1557
- _orderMetaList = _ref41.order_meta_list,
1558
- _rootTaxFee = _ref41.tax_fee,
1559
- _totalAmount = _ref41.total_amount,
1560
- _totalRefundAmount = _ref41.total_refund_amount,
1561
- _createDate = _ref41.create_date,
1562
- _holderId = _ref41.holder_id,
1563
- _paymentStatus = _ref41.payment_status,
1564
- _notes = _ref41.notes,
1565
- tempOrderRest = _objectWithoutProperties(_ref41, _excluded4);
1576
+ var _ref42 = tempOrder,
1577
+ _extend = _ref42._extend,
1578
+ _relationId = _ref42.relation_id,
1579
+ _tableFormId = _ref42.table_form_id,
1580
+ _resourceId = _ref42.resource_id,
1581
+ _summary = _ref42.summary,
1582
+ _lastOrderInfo = _ref42.lastOrderInfo,
1583
+ _paidAmount = _ref42.paid_amount,
1584
+ _shopId = _ref42.shop_id,
1585
+ _shopNote = _ref42.shop_note,
1586
+ _shopServiceType = _ref42.shop_service_type,
1587
+ _startTime = _ref42.start_time,
1588
+ _customer = _ref42.customer,
1589
+ _discountList = _ref42.discount_list,
1590
+ _orderMetaList = _ref42.order_meta_list,
1591
+ _rootTaxFee = _ref42.tax_fee,
1592
+ _totalAmount = _ref42.total_amount,
1593
+ _totalRefundAmount = _ref42.total_refund_amount,
1594
+ _createDate = _ref42.create_date,
1595
+ _holderId = _ref42.holder_id,
1596
+ _paymentStatus = _ref42.payment_status,
1597
+ _notes = _ref42.notes,
1598
+ tempOrderRest = _objectWithoutProperties(_ref42, _excluded4);
1566
1599
  var resolvedBusinessCode = businessCode !== null && businessCode !== void 0 ? businessCode : tempOrder.business_code;
1567
1600
  var normalizedOrderMetaList = normalizeOrderMetaList(tempOrder.order_meta_list);
1568
1601
  var submitType = resolveSubmitOrderType({
@@ -1589,7 +1622,7 @@ export function buildSubmitPayload(params) {
1589
1622
  type: submitType,
1590
1623
  business_code: resolvedBusinessCode,
1591
1624
  sales_channel: tempOrder.sales_channel || 'my_pisel',
1592
- order_sales_channel: (_ref42 = channel !== null && channel !== void 0 ? channel : tempOrder.order_sales_channel) !== null && _ref42 !== void 0 ? _ref42 : 'online_store',
1625
+ order_sales_channel: (_ref43 = channel !== null && channel !== void 0 ? channel : tempOrder.order_sales_channel) !== null && _ref43 !== void 0 ? _ref43 : 'online_store',
1593
1626
  status: tempOrder.status || 'normal'
1594
1627
  }, params.includePaymentStatus !== false ? {
1595
1628
  payment_status: tempOrder.payment_status || 'payment_processing'
@@ -1617,13 +1650,13 @@ export function buildSubmitPayload(params) {
1617
1650
  // holder: tempOrder.holder || null,
1618
1651
  summary: summary || tempOrder.summary || createEmptySummary(),
1619
1652
  metadata: function () {
1620
- var _ref43 = tempOrder.metadata || {},
1621
- _collectPax = _ref43.collect_pax,
1622
- _tableOccupancyDuration = _ref43.table_occupancy_duration,
1623
- _cartSettlementKey = _ref43.cart_settlement_key,
1624
- _cartSettlementSnapshot = _ref43.cart_settlement_snapshot,
1625
- _legalCurrencySnapshot = _ref43.legal_currency_snapshot,
1626
- rest = _objectWithoutProperties(_ref43, _excluded5);
1653
+ var _ref44 = tempOrder.metadata || {},
1654
+ _collectPax = _ref44.collect_pax,
1655
+ _tableOccupancyDuration = _ref44.table_occupancy_duration,
1656
+ _cartSettlementKey = _ref44.cart_settlement_key,
1657
+ _cartSettlementSnapshot = _ref44.cart_settlement_snapshot,
1658
+ _legalCurrencySnapshot = _ref44.legal_currency_snapshot,
1659
+ rest = _objectWithoutProperties(_ref44, _excluded5);
1627
1660
  return _objectSpread({}, rest);
1628
1661
  }()
1629
1662
  }, (_tempOrder$_extend = tempOrder._extend) !== null && _tempOrder$_extend !== void 0 && (_tempOrder$_extend = _tempOrder$_extend.salesNotesState) !== null && _tempOrder$_extend !== void 0 && _tempOrder$_extend.dirty ? {
@@ -1781,25 +1814,25 @@ export function clearTempOrderHolderAssignments(tempOrder) {
1781
1814
  changed = true;
1782
1815
  }
1783
1816
  };
1784
- var _iterator9 = _createForOfIteratorHelper(tempOrder.products || []),
1785
- _step9;
1817
+ var _iterator10 = _createForOfIteratorHelper(tempOrder.products || []),
1818
+ _step10;
1786
1819
  try {
1787
- for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
1788
- var product = _step9.value;
1820
+ for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
1821
+ var product = _step10.value;
1789
1822
  if (product.metadata && _typeof(product.metadata) === 'object') {
1790
1823
  clearHolder(product.metadata);
1791
1824
  }
1792
1825
  }
1793
1826
  } catch (err) {
1794
- _iterator9.e(err);
1827
+ _iterator10.e(err);
1795
1828
  } finally {
1796
- _iterator9.f();
1829
+ _iterator10.f();
1797
1830
  }
1798
- var _iterator10 = _createForOfIteratorHelper(tempOrder.bookings || []),
1799
- _step10;
1831
+ var _iterator11 = _createForOfIteratorHelper(tempOrder.bookings || []),
1832
+ _step11;
1800
1833
  try {
1801
- for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
1802
- var booking = _step10.value;
1834
+ for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
1835
+ var booking = _step11.value;
1803
1836
  var bookingRecord = booking;
1804
1837
  if (booking.metadata && _typeof(booking.metadata) === 'object') {
1805
1838
  resetHolderField(booking.metadata);
@@ -1810,9 +1843,9 @@ export function clearTempOrderHolderAssignments(tempOrder) {
1810
1843
  }
1811
1844
  }
1812
1845
  } catch (err) {
1813
- _iterator10.e(err);
1846
+ _iterator11.e(err);
1814
1847
  } finally {
1815
- _iterator10.f();
1848
+ _iterator11.f();
1816
1849
  }
1817
1850
  var productsByUid = (_tempOrder$_extend2 = tempOrder._extend) === null || _tempOrder$_extend2 === void 0 ? void 0 : _tempOrder$_extend2.productsByUid;
1818
1851
  if (productsByUid && _typeof(productsByUid) === 'object') {
@@ -1840,9 +1873,9 @@ export function clearTempOrderHolderAssignments(tempOrder) {
1840
1873
  * getOrderProductLineUid({ metadata: { unique_identification_number: 'line-1' } }); // 'line-1'
1841
1874
  */
1842
1875
  export function getOrderProductLineUid(product) {
1843
- var _product$metadata$uni2, _product$metadata10;
1876
+ var _product$metadata$uni2, _product$metadata12;
1844
1877
  if (!product || _typeof(product) !== 'object') return null;
1845
- var uid = (_product$metadata$uni2 = (_product$metadata10 = product.metadata) === null || _product$metadata10 === void 0 ? void 0 : _product$metadata10.unique_identification_number) !== null && _product$metadata$uni2 !== void 0 ? _product$metadata$uni2 : product.unique_identification_number;
1878
+ var uid = (_product$metadata$uni2 = (_product$metadata12 = product.metadata) === null || _product$metadata12 === void 0 ? void 0 : _product$metadata12.unique_identification_number) !== null && _product$metadata$uni2 !== void 0 ? _product$metadata$uni2 : product.unique_identification_number;
1846
1879
  if (uid === undefined || uid === null || uid === '') return null;
1847
1880
  return String(uid);
1848
1881
  }
@@ -1853,8 +1886,8 @@ export function getRuntimeProductOrigin(tempOrder, product) {
1853
1886
  return tempOrder._extend.productsByUid[uid].origin;
1854
1887
  }
1855
1888
  var matchedProduct = ((tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.products) || []).find(function (item) {
1856
- var _ref44, _item$product_id, _ref45, _product$product_id;
1857
- return item === product || getOrderProductLineUid(item) === uid || String((_ref44 = (_item$product_id = item === null || item === void 0 ? void 0 : item.product_id) !== null && _item$product_id !== void 0 ? _item$product_id : item === null || item === void 0 ? void 0 : item.id) !== null && _ref44 !== void 0 ? _ref44 : '') === String((_ref45 = (_product$product_id = product === null || product === void 0 ? void 0 : product.product_id) !== null && _product$product_id !== void 0 ? _product$product_id : product === null || product === void 0 ? void 0 : product.id) !== null && _ref45 !== void 0 ? _ref45 : '');
1889
+ var _ref45, _item$product_id, _ref46, _product$product_id;
1890
+ return item === product || getOrderProductLineUid(item) === uid || String((_ref45 = (_item$product_id = item === null || item === void 0 ? void 0 : item.product_id) !== null && _item$product_id !== void 0 ? _item$product_id : item === null || item === void 0 ? void 0 : item.id) !== null && _ref45 !== void 0 ? _ref45 : '') === String((_ref46 = (_product$product_id = product === null || product === void 0 ? void 0 : product.product_id) !== null && _product$product_id !== void 0 ? _product$product_id : product === null || product === void 0 ? void 0 : product.id) !== null && _ref46 !== void 0 ? _ref46 : '');
1858
1891
  });
1859
1892
  var matchedUid = matchedProduct ? getOrderProductLineUid(matchedProduct) : '';
1860
1893
  return matchedUid ? (tempOrder === null || tempOrder === void 0 || (_tempOrder$_extend4 = tempOrder._extend) === null || _tempOrder$_extend4 === void 0 || (_tempOrder$_extend4 = _tempOrder$_extend4.productsByUid) === null || _tempOrder$_extend4 === void 0 || (_tempOrder$_extend4 = _tempOrder$_extend4[matchedUid]) === null || _tempOrder$_extend4 === void 0 ? void 0 : _tempOrder$_extend4.origin) || null : null;
@@ -326,7 +326,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
326
326
  date: string;
327
327
  status: string;
328
328
  week: string;
329
- weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
329
+ weekNum: 0 | 2 | 1 | 6 | 4 | 5 | 3;
330
330
  }[]>;
331
331
  submitTimeSlot(timeSlots: TimeSliceItem): void;
332
332
  private getScheduleDataByIds;
@@ -24,28 +24,27 @@ export declare function buildArrivalCheckoutQuery(order: OrderTempOrder, summary
24
24
  products: import("../../../modules/Order/types").OrderSubmitProduct[];
25
25
  notes?: import("../../../modules/Order/types").SalesNote[] | undefined;
26
26
  summary?: import("../../../modules/Order/types").OrderSummary | undefined;
27
- status: string;
28
27
  metadata: Record<string, any>;
29
- business_code?: string | undefined;
30
- customer_id: number | null;
31
28
  type: string;
32
- holder: Record<string, any> | null;
33
- email: string;
34
- phone: string;
35
29
  note: string;
30
+ holder: Record<string, any> | null;
36
31
  relation_forms: any[];
37
32
  holder_relations?: import("../../../modules/Order/types").OrderHolderRelation[] | undefined;
38
- country_calling_code: string;
39
- contacts_info: Record<string, any> | null;
40
33
  order_id: number | null;
41
34
  external_sale_number: string;
42
35
  order_number: string | null;
43
36
  shop_order_number: string | null;
44
37
  shop_full_order_number: string | null;
38
+ business_code?: string | undefined;
45
39
  sales_channel: string;
46
40
  order_sales_channel: string;
41
+ status: string;
47
42
  shipping_status: string;
43
+ customer_id: number | null;
48
44
  customer_name: string;
45
+ country_calling_code: string;
46
+ phone: string;
47
+ email: string;
49
48
  is_price_include_tax: number;
50
49
  tax_title: string;
51
50
  tax_country_code: string;
@@ -62,6 +61,7 @@ export declare function buildArrivalCheckoutQuery(order: OrderTempOrder, summary
62
61
  schedule_date: string;
63
62
  bookings: any[];
64
63
  payments: any[];
64
+ contacts_info: Record<string, any> | null;
65
65
  order_meta_list?: import("../../../modules/Order/types").OrderMetaList | undefined;
66
66
  refunds?: any[] | undefined;
67
67
  surcharges: any[];
@@ -503,6 +503,28 @@ function getOrderProductDeposit(product, runtimeOrigin) {
503
503
  self_deposit_policy_ids: depositData.self_deposit_policy_ids
504
504
  }));
505
505
  hasDeposit = true;
506
+
507
+ // 主商品金额不包含 markup/product_price 这类独立计价子商品。
508
+ // 以前父规则命中后直接跳过子项,导致“父价 0 + 子票 70 × 10”即使
509
+ // 子票已命中 50% 定金规则,仍算出 0;应累加子项自己的定金规则。
510
+ // 普通加价/减价子项已计入主价,不能重复收取。未拆分主价的旧订单行
511
+ // selling_price 可能包含整个套餐,继续沿用原口径,避免重复计费。
512
+ const hasSeparateMainPrice = product.metadata?.main_product_attached_bundle_payment_price != null || product.metadata?.main_product_selling_price != null;
513
+ if (hasSeparateMainPrice && Array.isArray(product.product_bundle)) {
514
+ for (const bundleProduct of product.product_bundle) {
515
+ if (bundleProduct.price_type !== 'markup' || bundleProduct.price_type_ext !== 'product_price') continue;
516
+ const bundleDepositData = bundleProduct.custom_deposit_data;
517
+ const bundleResult = handleOrderProductDeposit({
518
+ depositData: bundleDepositData,
519
+ // payment 是已分摊折扣的子商品单价;子项数量和套餐数量各乘一次。
520
+ total: bundleProduct.bundle_payment_price ?? bundleProduct.bundle_selling_price ?? bundleProduct.price,
521
+ num: getSafeOrderProductNum(bundleProduct.num ?? bundleProduct.quantity) * num
522
+ });
523
+ if (!bundleResult.result) continue;
524
+ depositTotal = depositTotal.plus(bundleResult.depositTotal);
525
+ protocolIds.push(...getDepositPolicyIds(bundleDepositData));
526
+ }
527
+ }
506
528
  }
507
529
  } else {
508
530
  const productVariantId = depositProduct.product_variant_id ?? product.product_variant_id;
@@ -326,7 +326,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
326
326
  date: string;
327
327
  status: string;
328
328
  week: string;
329
- weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
329
+ weekNum: 0 | 2 | 1 | 6 | 4 | 5 | 3;
330
330
  }[]>;
331
331
  submitTimeSlot(timeSlots: TimeSliceItem): void;
332
332
  private getScheduleDataByIds;
@@ -24,28 +24,27 @@ export declare function buildArrivalCheckoutQuery(order: OrderTempOrder, summary
24
24
  products: import("../../../modules/Order/types").OrderSubmitProduct[];
25
25
  notes?: import("../../../modules/Order/types").SalesNote[] | undefined;
26
26
  summary?: import("../../../modules/Order/types").OrderSummary | undefined;
27
- status: string;
28
27
  metadata: Record<string, any>;
29
- business_code?: string | undefined;
30
- customer_id: number | null;
31
28
  type: string;
32
- holder: Record<string, any> | null;
33
- email: string;
34
- phone: string;
35
29
  note: string;
30
+ holder: Record<string, any> | null;
36
31
  relation_forms: any[];
37
32
  holder_relations?: import("../../../modules/Order/types").OrderHolderRelation[] | undefined;
38
- country_calling_code: string;
39
- contacts_info: Record<string, any> | null;
40
33
  order_id: number | null;
41
34
  external_sale_number: string;
42
35
  order_number: string | null;
43
36
  shop_order_number: string | null;
44
37
  shop_full_order_number: string | null;
38
+ business_code?: string | undefined;
45
39
  sales_channel: string;
46
40
  order_sales_channel: string;
41
+ status: string;
47
42
  shipping_status: string;
43
+ customer_id: number | null;
48
44
  customer_name: string;
45
+ country_calling_code: string;
46
+ phone: string;
47
+ email: string;
49
48
  is_price_include_tax: number;
50
49
  tax_title: string;
51
50
  tax_country_code: string;
@@ -62,6 +61,7 @@ export declare function buildArrivalCheckoutQuery(order: OrderTempOrder, summary
62
61
  schedule_date: string;
63
62
  bookings: any[];
64
63
  payments: any[];
64
+ contacts_info: Record<string, any> | null;
65
65
  order_meta_list?: import("../../../modules/Order/types").OrderMetaList | undefined;
66
66
  refunds?: any[] | undefined;
67
67
  surcharges: any[];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "0.10.88",
4
+ "version": "0.10.90",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",