@pisell/pisellos 2.3.209 → 2.3.210
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.
- package/dist/modules/Order/index.d.ts +1 -1
- package/dist/modules/Order/utils.js +149 -116
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/solution/BookingByStep/index.d.ts +2 -2
- package/lib/modules/Order/index.d.ts +1 -1
- package/lib/modules/Order/utils.js +22 -0
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/solution/BookingByStep/index.d.ts +2 -2
- package/package.json +1 -1
|
@@ -640,7 +640,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
640
640
|
generateIdempotencyToken(): string;
|
|
641
641
|
syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
|
|
642
642
|
createOrder(params: CommitOrderParams['query']): {
|
|
643
|
-
type: "
|
|
643
|
+
type: "appointment_booking" | "virtual";
|
|
644
644
|
platform: string;
|
|
645
645
|
sales_channel: string;
|
|
646
646
|
order_sales_channel: string;
|
|
@@ -420,11 +420,44 @@ function getOrderProductDeposit(product, runtimeOrigin) {
|
|
|
420
420
|
num: num
|
|
421
421
|
});
|
|
422
422
|
if (result.result) {
|
|
423
|
+
var _product$metadata, _product$metadata2;
|
|
423
424
|
depositTotal = result.depositTotal;
|
|
424
425
|
protocolIds.push.apply(protocolIds, _toConsumableArray(getDepositPolicyIds({
|
|
425
426
|
self_deposit_policy_ids: depositData.self_deposit_policy_ids
|
|
426
427
|
})));
|
|
427
428
|
hasDeposit = true;
|
|
429
|
+
|
|
430
|
+
// 主商品金额不包含 markup/product_price 这类独立计价子商品。
|
|
431
|
+
// 以前父规则命中后直接跳过子项,导致“父价 0 + 子票 70 × 10”即使
|
|
432
|
+
// 子票已命中 50% 定金规则,仍算出 0;应累加子项自己的定金规则。
|
|
433
|
+
// 普通加价/减价子项已计入主价,不能重复收取。未拆分主价的旧订单行
|
|
434
|
+
// selling_price 可能包含整个套餐,继续沿用原口径,避免重复计费。
|
|
435
|
+
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;
|
|
436
|
+
if (hasSeparateMainPrice && Array.isArray(product.product_bundle)) {
|
|
437
|
+
var _iterator3 = _createForOfIteratorHelper(product.product_bundle),
|
|
438
|
+
_step3;
|
|
439
|
+
try {
|
|
440
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
441
|
+
var _ref10, _bundleProduct$bundle, _bundleProduct$num;
|
|
442
|
+
var bundleProduct = _step3.value;
|
|
443
|
+
if (bundleProduct.price_type !== 'markup' || bundleProduct.price_type_ext !== 'product_price') continue;
|
|
444
|
+
var bundleDepositData = bundleProduct.custom_deposit_data;
|
|
445
|
+
var bundleResult = handleOrderProductDeposit({
|
|
446
|
+
depositData: bundleDepositData,
|
|
447
|
+
// payment 是已分摊折扣的子商品单价;子项数量和套餐数量各乘一次。
|
|
448
|
+
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,
|
|
449
|
+
num: getSafeOrderProductNum((_bundleProduct$num = bundleProduct.num) !== null && _bundleProduct$num !== void 0 ? _bundleProduct$num : bundleProduct.quantity) * num
|
|
450
|
+
});
|
|
451
|
+
if (!bundleResult.result) continue;
|
|
452
|
+
depositTotal = depositTotal.plus(bundleResult.depositTotal);
|
|
453
|
+
protocolIds.push.apply(protocolIds, _toConsumableArray(getDepositPolicyIds(bundleDepositData)));
|
|
454
|
+
}
|
|
455
|
+
} catch (err) {
|
|
456
|
+
_iterator3.e(err);
|
|
457
|
+
} finally {
|
|
458
|
+
_iterator3.f();
|
|
459
|
+
}
|
|
460
|
+
}
|
|
428
461
|
}
|
|
429
462
|
} else {
|
|
430
463
|
var _depositProduct$produ;
|
|
@@ -487,36 +520,36 @@ export function calculateOrderProductsDeposit() {
|
|
|
487
520
|
var protocolMap = new Map();
|
|
488
521
|
var total = new Decimal(0);
|
|
489
522
|
var hasDeposit = false;
|
|
490
|
-
var
|
|
491
|
-
|
|
523
|
+
var _iterator4 = _createForOfIteratorHelper(products || []),
|
|
524
|
+
_step4;
|
|
492
525
|
try {
|
|
493
|
-
for (
|
|
494
|
-
var _product$
|
|
495
|
-
var product =
|
|
496
|
-
var productUid = (_product$
|
|
526
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
527
|
+
var _product$metadata3, _options$productsByUi;
|
|
528
|
+
var product = _step4.value;
|
|
529
|
+
var productUid = (_product$metadata3 = product.metadata) === null || _product$metadata3 === void 0 ? void 0 : _product$metadata3.unique_identification_number;
|
|
497
530
|
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;
|
|
498
531
|
var deposit = getOrderProductDeposit(product, runtimeOrigin);
|
|
499
532
|
product.deposit = deposit;
|
|
500
533
|
if (!(deposit !== null && deposit !== void 0 && deposit.total) || Number(deposit.total) <= 0) continue;
|
|
501
534
|
total = total.plus(deposit.total);
|
|
502
|
-
var
|
|
503
|
-
|
|
535
|
+
var _iterator5 = _createForOfIteratorHelper(deposit.protocols || []),
|
|
536
|
+
_step5;
|
|
504
537
|
try {
|
|
505
|
-
for (
|
|
506
|
-
var protocol =
|
|
538
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
539
|
+
var protocol = _step5.value;
|
|
507
540
|
if (!protocolMap.has(protocol.id)) protocolMap.set(protocol.id, protocol);
|
|
508
541
|
}
|
|
509
542
|
} catch (err) {
|
|
510
|
-
|
|
543
|
+
_iterator5.e(err);
|
|
511
544
|
} finally {
|
|
512
|
-
|
|
545
|
+
_iterator5.f();
|
|
513
546
|
}
|
|
514
547
|
hasDeposit = true;
|
|
515
548
|
}
|
|
516
549
|
} catch (err) {
|
|
517
|
-
|
|
550
|
+
_iterator4.e(err);
|
|
518
551
|
} finally {
|
|
519
|
-
|
|
552
|
+
_iterator4.f();
|
|
520
553
|
}
|
|
521
554
|
var roundedTotal = total.toDecimalPlaces(2, Decimal.ROUND_HALF_UP);
|
|
522
555
|
var protocols = _toConsumableArray(protocolMap.values());
|
|
@@ -552,12 +585,12 @@ export function isMarkdownBundle(bundle) {
|
|
|
552
585
|
* - markup(加价)/原价子商品:维持 `+(bundle_selling_price ?? price)`,行为不变。
|
|
553
586
|
*/
|
|
554
587
|
export function getBundleSignedUnit(bundle, options) {
|
|
555
|
-
var _options$useOriginal,
|
|
588
|
+
var _options$useOriginal, _ref17, _bundle$original_pric2, _bundle$bundle_sellin;
|
|
556
589
|
if (!bundle || _typeof(bundle) !== 'object') return new Decimal(0);
|
|
557
590
|
var useOriginal = (_options$useOriginal = options === null || options === void 0 ? void 0 : options.useOriginal) !== null && _options$useOriginal !== void 0 ? _options$useOriginal : false;
|
|
558
591
|
if (isMarkdownBundle(bundle)) {
|
|
559
|
-
var
|
|
560
|
-
var catalog = useOriginal ? (
|
|
592
|
+
var _ref11, _ref12, _ref13, _bundle$original_pric, _ref14, _ref15, _ref16, _bundle$custom_price;
|
|
593
|
+
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;
|
|
561
594
|
if (catalog !== undefined && catalog !== null && catalog !== '') {
|
|
562
595
|
var raw = new Decimal(Number(catalog) || 0);
|
|
563
596
|
// 负值表示价格已是「带符号净额」(如 cart/changePrice 产出的 -3.7),直接取用不再扣 option,
|
|
@@ -568,7 +601,7 @@ export function getBundleSignedUnit(bundle, options) {
|
|
|
568
601
|
// 仅剩净额(无毛价)兜底:直接取负,不再扣 option
|
|
569
602
|
return new Decimal(Number(bundle.bundle_selling_price) || 0).abs().negated();
|
|
570
603
|
}
|
|
571
|
-
var rawPrice = useOriginal ? (
|
|
604
|
+
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;
|
|
572
605
|
return new Decimal(Number(rawPrice) || 0);
|
|
573
606
|
}
|
|
574
607
|
|
|
@@ -694,19 +727,19 @@ function ensureSubmitDiscountIdentity(discount) {
|
|
|
694
727
|
}
|
|
695
728
|
function collectSubmitProductDiscountList(product) {
|
|
696
729
|
var submitDiscountList = Array.isArray(product === null || product === void 0 ? void 0 : product.discount_list) ? _toConsumableArray(product.discount_list) : [];
|
|
697
|
-
var
|
|
698
|
-
|
|
730
|
+
var _iterator6 = _createForOfIteratorHelper((product === null || product === void 0 ? void 0 : product.product_bundle) || []),
|
|
731
|
+
_step6;
|
|
699
732
|
try {
|
|
700
|
-
for (
|
|
701
|
-
var bundle =
|
|
733
|
+
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
734
|
+
var bundle = _step6.value;
|
|
702
735
|
if (!bundle || _typeof(bundle) !== 'object') continue;
|
|
703
736
|
var bundleMapId = resolveSubmitBundleMapId(bundle);
|
|
704
737
|
var bundleDiscountList = Array.isArray(bundle.discount_list) ? bundle.discount_list : [];
|
|
705
|
-
var
|
|
706
|
-
|
|
738
|
+
var _iterator7 = _createForOfIteratorHelper(bundleDiscountList),
|
|
739
|
+
_step7;
|
|
707
740
|
try {
|
|
708
|
-
for (
|
|
709
|
-
var discount =
|
|
741
|
+
for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
|
|
742
|
+
var discount = _step7.value;
|
|
710
743
|
if (!discount || _typeof(discount) !== 'object') continue;
|
|
711
744
|
var discountMetadata = discount.metadata && _typeof(discount.metadata) === 'object' ? discount.metadata : {};
|
|
712
745
|
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;
|
|
@@ -717,15 +750,15 @@ function collectSubmitProductDiscountList(product) {
|
|
|
717
750
|
} : {}));
|
|
718
751
|
}
|
|
719
752
|
} catch (err) {
|
|
720
|
-
|
|
753
|
+
_iterator7.e(err);
|
|
721
754
|
} finally {
|
|
722
|
-
|
|
755
|
+
_iterator7.f();
|
|
723
756
|
}
|
|
724
757
|
}
|
|
725
758
|
} catch (err) {
|
|
726
|
-
|
|
759
|
+
_iterator6.e(err);
|
|
727
760
|
} finally {
|
|
728
|
-
|
|
761
|
+
_iterator6.f();
|
|
729
762
|
}
|
|
730
763
|
return normalizeOrderProductDiscountList(submitDiscountList.map(ensureSubmitDiscountIdentity));
|
|
731
764
|
}
|
|
@@ -802,26 +835,26 @@ export function resolveEffectivePerUnitDiscount(product) {
|
|
|
802
835
|
}
|
|
803
836
|
export function createDefaultOrderRulesHooks(getBookings, getHolderRelations) {
|
|
804
837
|
var getProductStartDate = function getProductStartDate(product) {
|
|
805
|
-
var
|
|
806
|
-
var productUid = String((
|
|
807
|
-
var bookingUid = String((
|
|
838
|
+
var _ref18, _product$metadata$uni, _product$metadata4, _ref19, _product$booking_uid, _product$metadata5, _product$metadata6, _product$metadata7, _product$metadata8;
|
|
839
|
+
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 : '');
|
|
840
|
+
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 : '');
|
|
808
841
|
// 每次读取当前 bookings,覆盖改期、订单回显以及直接调用 Rules 的选券入口。
|
|
809
842
|
var bookings = (getBookings === null || getBookings === void 0 ? void 0 : getBookings()) || [];
|
|
810
843
|
var booking = bookings.find(function (item) {
|
|
811
|
-
var
|
|
812
|
-
return productUid && String((
|
|
844
|
+
var _ref20, _item$product_uid, _item$metadata3;
|
|
845
|
+
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;
|
|
813
846
|
}) || bookings.find(function (item) {
|
|
814
|
-
var
|
|
815
|
-
return bookingUid && String((
|
|
847
|
+
var _ref21, _item$metadata$unique, _item$metadata4;
|
|
848
|
+
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;
|
|
816
849
|
});
|
|
817
850
|
if (booking) {
|
|
818
851
|
// 严格解析并保留 Invalid Date,让公共时间校验拒绝缺失/非法时间,避免回退到当前时间。
|
|
819
852
|
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);
|
|
820
853
|
}
|
|
821
|
-
if (getBookings && (bookingUid || product.booking_id || (_product$
|
|
854
|
+
if (getBookings && (bookingUid || product.booking_id || (_product$metadata6 = product.metadata) !== null && _product$metadata6 !== void 0 && _product$metadata6.booking_id)) {
|
|
822
855
|
return dayjs('');
|
|
823
856
|
}
|
|
824
|
-
var legacyStartDate = ((_product$
|
|
857
|
+
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);
|
|
825
858
|
return legacyStartDate ? dayjs(legacyStartDate) : undefined;
|
|
826
859
|
};
|
|
827
860
|
var toUnitPriceString = function toUnitPriceString(totalLike, num) {
|
|
@@ -838,8 +871,8 @@ export function createDefaultOrderRulesHooks(getBookings, getHolderRelations) {
|
|
|
838
871
|
}, new Decimal(0));
|
|
839
872
|
};
|
|
840
873
|
var getBundleIdentity = function getBundleIdentity(bundle) {
|
|
841
|
-
var
|
|
842
|
-
return [(
|
|
874
|
+
var _ref22, _bundle$bundle_id, _ref23, _ref24, _bundle$bundle_produc, _ref25, _ref26, _bundle$bundle_varian, _ref27, _bundle$bundle_group_;
|
|
875
|
+
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('|');
|
|
843
876
|
};
|
|
844
877
|
var mergeRulesBundlePrices = function mergeRulesBundlePrices(currentBundle, rulesBundle) {
|
|
845
878
|
if (!Array.isArray(rulesBundle)) return rulesBundle;
|
|
@@ -849,7 +882,7 @@ export function createDefaultOrderRulesHooks(getBookings, getHolderRelations) {
|
|
|
849
882
|
currentByIdentity.set(getBundleIdentity(bundle), bundle);
|
|
850
883
|
});
|
|
851
884
|
return rulesBundle.map(function (bundle) {
|
|
852
|
-
var _bundle$price_type_ex2,
|
|
885
|
+
var _bundle$price_type_ex2, _ref28, _ref29, _current$price, _ref30, _ref31, _ref32, _current$original_pri;
|
|
853
886
|
if (!bundle || _typeof(bundle) !== 'object') return bundle;
|
|
854
887
|
var current = currentByIdentity.get(getBundleIdentity(bundle));
|
|
855
888
|
if (!current) return bundle;
|
|
@@ -858,8 +891,8 @@ export function createDefaultOrderRulesHooks(getBookings, getHolderRelations) {
|
|
|
858
891
|
} : {});
|
|
859
892
|
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';
|
|
860
893
|
if (!isProductPriceBundle) return bundleWithDisplayFields;
|
|
861
|
-
var sourcePrice = (
|
|
862
|
-
var originalPrice = (
|
|
894
|
+
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;
|
|
895
|
+
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;
|
|
863
896
|
return _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, bundleWithDisplayFields), sourcePrice !== undefined ? {
|
|
864
897
|
price: sourcePrice
|
|
865
898
|
} : {}), originalPrice !== undefined ? {
|
|
@@ -871,7 +904,7 @@ export function createDefaultOrderRulesHooks(getBookings, getHolderRelations) {
|
|
|
871
904
|
};
|
|
872
905
|
return {
|
|
873
906
|
getProduct: function getProduct(product) {
|
|
874
|
-
var _product$
|
|
907
|
+
var _product$metadata9, _product$metadata10, _product$metadata11, _metadataAny$_promoti;
|
|
875
908
|
// source_product_price 是权威源;兜底链:source → mainSelling − options(反推)→ 行 selling_price
|
|
876
909
|
var metadataAny = product.metadata || {};
|
|
877
910
|
var productOptions = getProductSkuOptions(product);
|
|
@@ -900,7 +933,7 @@ export function createDefaultOrderRulesHooks(getBookings, getHolderRelations) {
|
|
|
900
933
|
// 否则同 SKU 不同小料会在 calcDiscount 重组时互相覆盖。
|
|
901
934
|
// 不透明 identity 契约下,normalizeOrderProduct / hydrate 已保证唯一值存在;
|
|
902
935
|
// 留 fingerprint 分支仅作 Rules 单测里直接传裸 product 时的兜底。
|
|
903
|
-
_id: (_product$
|
|
936
|
+
_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)),
|
|
904
937
|
// Rules 内部 getProductTotalPrice / getProductOriginTotalPrice 会各自再叠加 bundle + option,
|
|
905
938
|
// 所以这里必须喂 source-level(不含 option、不含 bundle、不含折扣)单价,避免双加 option。
|
|
906
939
|
// 赠品基础价不再参与卡券;source 元数据保留原价,供后续与赠送优惠相抵。
|
|
@@ -919,12 +952,12 @@ export function createDefaultOrderRulesHooks(getBookings, getHolderRelations) {
|
|
|
919
952
|
price: option.add_price
|
|
920
953
|
});
|
|
921
954
|
}),
|
|
922
|
-
booking_id: ((_product$
|
|
955
|
+
booking_id: ((_product$metadata10 = product.metadata) === null || _product$metadata10 === void 0 ? void 0 : _product$metadata10.booking_id) || null,
|
|
923
956
|
isClient: false,
|
|
924
957
|
// 勿写死 false:否则 Rules 不会走 total≠origin_total 的手动价推断,
|
|
925
958
|
// 无券时会把 bundle 价还原成 original_price(手动改价套餐会从 20 回到 30)。
|
|
926
959
|
isManualDiscount: resolveRulesManualDiscountFlag(metadataAny),
|
|
927
|
-
holder_id: hasProductBooking(product) || !getHolderRelations ? (_product$
|
|
960
|
+
holder_id: hasProductBooking(product) || !getHolderRelations ? (_product$metadata11 = product.metadata) === null || _product$metadata11 === void 0 ? void 0 : _product$metadata11.holder_id : getProductHolderRelations({
|
|
928
961
|
holder_relations: getHolderRelations()
|
|
929
962
|
}, product).filter(function (relation) {
|
|
930
963
|
return relation.holder_type === 'form';
|
|
@@ -938,10 +971,10 @@ export function createDefaultOrderRulesHooks(getBookings, getHolderRelations) {
|
|
|
938
971
|
};
|
|
939
972
|
},
|
|
940
973
|
setProduct: function setProduct(product, values) {
|
|
941
|
-
var
|
|
942
|
-
var nextNum = Number((
|
|
974
|
+
var _ref33, _values$quantity, _ref34, _metadataAny$source_p, _values$discount_list, _product$product_sku, _values$quantity2;
|
|
975
|
+
var nextNum = Number((_ref33 = (_values$quantity = values.quantity) !== null && _values$quantity !== void 0 ? _values$quantity : product.num) !== null && _ref33 !== void 0 ? _ref33 : 1) || 1;
|
|
943
976
|
var metadataAny = product.metadata || {};
|
|
944
|
-
var existedSource = (
|
|
977
|
+
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';
|
|
945
978
|
var nextOptions = getProductSkuOptions(product);
|
|
946
979
|
var optionSum = sumOptionUnitPrice(nextOptions);
|
|
947
980
|
var nextDiscountList = (_values$discount_list = values.discount_list) !== null && _values$discount_list !== void 0 ? _values$discount_list : product.discount_list;
|
|
@@ -1119,10 +1152,10 @@ function formatSubmitOptionItems(options) {
|
|
|
1119
1152
|
var formatOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1120
1153
|
if (!Array.isArray(options)) return [];
|
|
1121
1154
|
return options.map(function (d) {
|
|
1122
|
-
var
|
|
1155
|
+
var _ref35, _d$option_group_item_, _d$add_price;
|
|
1123
1156
|
var option = _objectSpread(_objectSpread({}, d && _typeof(d) === 'object' ? d : {}), {}, {
|
|
1124
1157
|
num: d === null || d === void 0 ? void 0 : d.num,
|
|
1125
|
-
option_group_item_id: (
|
|
1158
|
+
option_group_item_id: (_ref35 = (_d$option_group_item_ = d === null || d === void 0 ? void 0 : d.option_group_item_id) !== null && _d$option_group_item_ !== void 0 ? _d$option_group_item_ : d === null || d === void 0 ? void 0 : d.product_option_item_id) !== null && _ref35 !== void 0 ? _ref35 : d === null || d === void 0 ? void 0 : d.id,
|
|
1126
1159
|
option_group_id: d === null || d === void 0 ? void 0 : d.option_group_id
|
|
1127
1160
|
});
|
|
1128
1161
|
var productionCode = normalizeSubmitProductionCode(d === null || d === void 0 ? void 0 : d.production_code);
|
|
@@ -1155,7 +1188,7 @@ function formatSubmitBundleItems(bundle) {
|
|
|
1155
1188
|
var formatOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1156
1189
|
if (!Array.isArray(bundle)) return [];
|
|
1157
1190
|
return bundle.map(function (b) {
|
|
1158
|
-
var
|
|
1191
|
+
var _ref36, _rawBundle$price, _rawBundle$surcharge_, _rawBundle$num, _rawBundle$is_charge_, _rawBundle$bundle_var, _rawBundle$quantity, _rawBundle$extension_, _rawBundle$extension_2, _ref37, _rawBundle$price_type, _ref38, _rawBundle$price_type2, _rawBundle$bundle_gro, _rawBundle$bundle_id, _rawBundle$bundle_pro;
|
|
1159
1192
|
var rawBundle = b && _typeof(b) === 'object' ? b : {};
|
|
1160
1193
|
var existedMetadata = rawBundle.metadata && _typeof(rawBundle.metadata) === 'object' ? rawBundle.metadata : {};
|
|
1161
1194
|
var _customProductBundleMapId = existedMetadata.custom_product_bundle_map_id,
|
|
@@ -1166,7 +1199,7 @@ function formatSubmitBundleItems(bundle) {
|
|
|
1166
1199
|
var sellingPrice = formatOptions.virtualSettlementMode ? '0.00' : getBundleSellingMagnitude(rawBundle).toFixed(2);
|
|
1167
1200
|
// payment 价由整单折扣均摊层产出;缺省(无折扣)时与 selling 净额同义。
|
|
1168
1201
|
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;
|
|
1169
|
-
var priceValue = formatOptions.virtualSettlementMode ? 0 : (
|
|
1202
|
+
var priceValue = formatOptions.virtualSettlementMode ? 0 : (_ref36 = (_rawBundle$price = rawBundle.price) !== null && _rawBundle$price !== void 0 ? _rawBundle$price : rawBundle.custom_price) !== null && _ref36 !== void 0 ? _ref36 : rawBundle.bundle_selling_price;
|
|
1170
1203
|
var relationSurchargeIds = Array.isArray(rawBundle.relation_surcharge_ids) ? rawBundle.relation_surcharge_ids : Array.isArray(existedMetadata.relation_surcharge_ids) ? existedMetadata.relation_surcharge_ids : [];
|
|
1171
1204
|
var surchargeFee = toMoneyString((_rawBundle$surcharge_ = rawBundle.surcharge_fee) !== null && _rawBundle$surcharge_ !== void 0 ? _rawBundle$surcharge_ : existedMetadata.surcharge_fee);
|
|
1172
1205
|
var productDiscountDifference = toBundleNumber(existedMetadata.product_discount_difference, 0);
|
|
@@ -1185,8 +1218,8 @@ function formatSubmitBundleItems(bundle) {
|
|
|
1185
1218
|
extension_id: (_rawBundle$extension_ = rawBundle.extension_id) !== null && _rawBundle$extension_ !== void 0 ? _rawBundle$extension_ : 0,
|
|
1186
1219
|
extension_type: (_rawBundle$extension_2 = rawBundle.extension_type) !== null && _rawBundle$extension_2 !== void 0 ? _rawBundle$extension_2 : 'normal',
|
|
1187
1220
|
price: priceValue,
|
|
1188
|
-
price_type: (
|
|
1189
|
-
price_type_ext: (
|
|
1221
|
+
price_type: (_ref37 = (_rawBundle$price_type = rawBundle.price_type) !== null && _rawBundle$price_type !== void 0 ? _rawBundle$price_type : rawBundle.custom_price_type) !== null && _ref37 !== void 0 ? _ref37 : '',
|
|
1222
|
+
price_type_ext: (_ref38 = (_rawBundle$price_type2 = rawBundle.price_type_ext) !== null && _rawBundle$price_type2 !== void 0 ? _rawBundle$price_type2 : rawBundle.custom_price_type_ext) !== null && _ref38 !== void 0 ? _ref38 : '',
|
|
1190
1223
|
bundle_selling_price: sellingPrice,
|
|
1191
1224
|
bundle_payment_price: paymentPrice,
|
|
1192
1225
|
option: formatSubmitOptionItems(rawBundle.option, formatOptions),
|
|
@@ -1222,11 +1255,11 @@ function formatSubmitBundleItems(bundle) {
|
|
|
1222
1255
|
* 法币仅做字段/metadata 裁剪;虚拟币在出站前再次执行零加价与固定单价断言。
|
|
1223
1256
|
*/
|
|
1224
1257
|
function normalizeSubmitProduct(product) {
|
|
1225
|
-
var
|
|
1258
|
+
var _ref40, _submitProduct$bundle, _rawMetadata$pricing_, _rawMetadata$product_, _rawMetadata$selected, _rawMetadata$selected2, _submitProduct$produc, _submitProduct$paymen;
|
|
1226
1259
|
var formatOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1227
|
-
var
|
|
1228
|
-
_runtimeUid =
|
|
1229
|
-
submitProduct = _objectWithoutProperties(
|
|
1260
|
+
var _ref39 = product,
|
|
1261
|
+
_runtimeUid = _ref39.unique_identification_number,
|
|
1262
|
+
submitProduct = _objectWithoutProperties(_ref39, _excluded2);
|
|
1230
1263
|
var num = submitProduct.num,
|
|
1231
1264
|
_productExtend = submitProduct._extend,
|
|
1232
1265
|
_productSurchargeFee = submitProduct.surcharge_fee,
|
|
@@ -1244,7 +1277,7 @@ function normalizeSubmitProduct(product) {
|
|
|
1244
1277
|
// 兼容历史 BigSale 编辑链路:bundle_edit 曾被写入 metadata,
|
|
1245
1278
|
// 出站时需提升到商品顶层;套餐未编辑时也必须显式提交 0。
|
|
1246
1279
|
var hasProductBundle = Array.isArray(submitProduct.product_bundle) && submitProduct.product_bundle.length > 0;
|
|
1247
|
-
var bundleEdit = (
|
|
1280
|
+
var bundleEdit = (_ref40 = (_submitProduct$bundle = submitProduct.bundle_edit) !== null && _submitProduct$bundle !== void 0 ? _submitProduct$bundle : rawMetadata.bundle_edit) !== null && _ref40 !== void 0 ? _ref40 : hasProductBundle ? 0 : undefined;
|
|
1248
1281
|
var cleanMetadata = {};
|
|
1249
1282
|
if (rawMetadata.unique_identification_number) {
|
|
1250
1283
|
cleanMetadata.unique_identification_number = rawMetadata.unique_identification_number;
|
|
@@ -1334,19 +1367,19 @@ export function normalizeBookingSubType(booking) {
|
|
|
1334
1367
|
export function normalizeSubmitBooking(booking) {
|
|
1335
1368
|
var rawMetadata = booking.metadata || {};
|
|
1336
1369
|
var cleanMetadata = {};
|
|
1337
|
-
var
|
|
1338
|
-
|
|
1370
|
+
var _iterator8 = _createForOfIteratorHelper(SUBMIT_BOOKING_METADATA_WHITELIST),
|
|
1371
|
+
_step8;
|
|
1339
1372
|
try {
|
|
1340
|
-
for (
|
|
1341
|
-
var key =
|
|
1373
|
+
for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
|
|
1374
|
+
var key = _step8.value;
|
|
1342
1375
|
if (rawMetadata[key] !== undefined) {
|
|
1343
1376
|
cleanMetadata[key] = rawMetadata[key];
|
|
1344
1377
|
}
|
|
1345
1378
|
}
|
|
1346
1379
|
} catch (err) {
|
|
1347
|
-
|
|
1380
|
+
_iterator8.e(err);
|
|
1348
1381
|
} finally {
|
|
1349
|
-
|
|
1382
|
+
_iterator8.f();
|
|
1350
1383
|
}
|
|
1351
1384
|
if (cleanMetadata.holder_id === undefined && !isFulfillmentTimingBooking(booking)) {
|
|
1352
1385
|
cleanMetadata.holder_id = null;
|
|
@@ -1496,7 +1529,7 @@ export function resolveSubmitOrderType(params) {
|
|
|
1496
1529
|
return 'virtual';
|
|
1497
1530
|
}
|
|
1498
1531
|
export function buildSubmitPayload(params) {
|
|
1499
|
-
var _tempOrder$metadata2, _tempOrder$customer_i, _tempOrder$country_ca, _tempOrder$phone, _tempOrder$email, _tempOrder$order_numb, _tempOrder$shop_order, _tempOrder$shop_full_,
|
|
1532
|
+
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;
|
|
1500
1533
|
var tempOrder = params.tempOrder,
|
|
1501
1534
|
cacheId = params.cacheId,
|
|
1502
1535
|
_params$now = params.now,
|
|
@@ -1511,29 +1544,29 @@ export function buildSubmitPayload(params) {
|
|
|
1511
1544
|
var scheduleDate = tempOrder.schedule_date || tempOrder.created_at || formatDateTime(now);
|
|
1512
1545
|
var bookingUuid = createUuidV4();
|
|
1513
1546
|
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';
|
|
1514
|
-
var
|
|
1515
|
-
_extend =
|
|
1516
|
-
_relationId =
|
|
1517
|
-
_tableFormId =
|
|
1518
|
-
_resourceId =
|
|
1519
|
-
_summary =
|
|
1520
|
-
_lastOrderInfo =
|
|
1521
|
-
_paidAmount =
|
|
1522
|
-
_shopId =
|
|
1523
|
-
_shopNote =
|
|
1524
|
-
_shopServiceType =
|
|
1525
|
-
_startTime =
|
|
1526
|
-
_customer =
|
|
1527
|
-
_discountList =
|
|
1528
|
-
_orderMetaList =
|
|
1529
|
-
_rootTaxFee =
|
|
1530
|
-
_totalAmount =
|
|
1531
|
-
_totalRefundAmount =
|
|
1532
|
-
_createDate =
|
|
1533
|
-
_holderId =
|
|
1534
|
-
_paymentStatus =
|
|
1535
|
-
_notes =
|
|
1536
|
-
tempOrderRest = _objectWithoutProperties(
|
|
1547
|
+
var _ref41 = tempOrder,
|
|
1548
|
+
_extend = _ref41._extend,
|
|
1549
|
+
_relationId = _ref41.relation_id,
|
|
1550
|
+
_tableFormId = _ref41.table_form_id,
|
|
1551
|
+
_resourceId = _ref41.resource_id,
|
|
1552
|
+
_summary = _ref41.summary,
|
|
1553
|
+
_lastOrderInfo = _ref41.lastOrderInfo,
|
|
1554
|
+
_paidAmount = _ref41.paid_amount,
|
|
1555
|
+
_shopId = _ref41.shop_id,
|
|
1556
|
+
_shopNote = _ref41.shop_note,
|
|
1557
|
+
_shopServiceType = _ref41.shop_service_type,
|
|
1558
|
+
_startTime = _ref41.start_time,
|
|
1559
|
+
_customer = _ref41.customer,
|
|
1560
|
+
_discountList = _ref41.discount_list,
|
|
1561
|
+
_orderMetaList = _ref41.order_meta_list,
|
|
1562
|
+
_rootTaxFee = _ref41.tax_fee,
|
|
1563
|
+
_totalAmount = _ref41.total_amount,
|
|
1564
|
+
_totalRefundAmount = _ref41.total_refund_amount,
|
|
1565
|
+
_createDate = _ref41.create_date,
|
|
1566
|
+
_holderId = _ref41.holder_id,
|
|
1567
|
+
_paymentStatus = _ref41.payment_status,
|
|
1568
|
+
_notes = _ref41.notes,
|
|
1569
|
+
tempOrderRest = _objectWithoutProperties(_ref41, _excluded4);
|
|
1537
1570
|
var resolvedBusinessCode = businessCode !== null && businessCode !== void 0 ? businessCode : tempOrder.business_code;
|
|
1538
1571
|
var normalizedOrderMetaList = normalizeOrderMetaList(tempOrder.order_meta_list);
|
|
1539
1572
|
var submitType = resolveSubmitOrderType({
|
|
@@ -1560,7 +1593,7 @@ export function buildSubmitPayload(params) {
|
|
|
1560
1593
|
type: submitType,
|
|
1561
1594
|
business_code: resolvedBusinessCode,
|
|
1562
1595
|
sales_channel: tempOrder.sales_channel || 'my_pisel',
|
|
1563
|
-
order_sales_channel: (
|
|
1596
|
+
order_sales_channel: (_ref42 = channel !== null && channel !== void 0 ? channel : tempOrder.order_sales_channel) !== null && _ref42 !== void 0 ? _ref42 : 'online_store',
|
|
1564
1597
|
status: tempOrder.status || 'normal'
|
|
1565
1598
|
}, params.includePaymentStatus !== false ? {
|
|
1566
1599
|
payment_status: tempOrder.payment_status || 'payment_processing'
|
|
@@ -1588,13 +1621,13 @@ export function buildSubmitPayload(params) {
|
|
|
1588
1621
|
// holder: tempOrder.holder || null,
|
|
1589
1622
|
summary: summary || tempOrder.summary || createEmptySummary(),
|
|
1590
1623
|
metadata: function () {
|
|
1591
|
-
var
|
|
1592
|
-
_collectPax =
|
|
1593
|
-
_tableOccupancyDuration =
|
|
1594
|
-
_cartSettlementKey =
|
|
1595
|
-
_cartSettlementSnapshot =
|
|
1596
|
-
_legalCurrencySnapshot =
|
|
1597
|
-
rest = _objectWithoutProperties(
|
|
1624
|
+
var _ref43 = tempOrder.metadata || {},
|
|
1625
|
+
_collectPax = _ref43.collect_pax,
|
|
1626
|
+
_tableOccupancyDuration = _ref43.table_occupancy_duration,
|
|
1627
|
+
_cartSettlementKey = _ref43.cart_settlement_key,
|
|
1628
|
+
_cartSettlementSnapshot = _ref43.cart_settlement_snapshot,
|
|
1629
|
+
_legalCurrencySnapshot = _ref43.legal_currency_snapshot,
|
|
1630
|
+
rest = _objectWithoutProperties(_ref43, _excluded5);
|
|
1598
1631
|
return _objectSpread({}, rest);
|
|
1599
1632
|
}()
|
|
1600
1633
|
}, (_tempOrder$_extend = tempOrder._extend) !== null && _tempOrder$_extend !== void 0 && (_tempOrder$_extend = _tempOrder$_extend.salesNotesState) !== null && _tempOrder$_extend !== void 0 && _tempOrder$_extend.dirty ? {
|
|
@@ -1752,25 +1785,25 @@ export function clearTempOrderHolderAssignments(tempOrder) {
|
|
|
1752
1785
|
changed = true;
|
|
1753
1786
|
}
|
|
1754
1787
|
};
|
|
1755
|
-
var
|
|
1756
|
-
|
|
1788
|
+
var _iterator9 = _createForOfIteratorHelper(tempOrder.products || []),
|
|
1789
|
+
_step9;
|
|
1757
1790
|
try {
|
|
1758
|
-
for (
|
|
1759
|
-
var product =
|
|
1791
|
+
for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
|
|
1792
|
+
var product = _step9.value;
|
|
1760
1793
|
if (product.metadata && _typeof(product.metadata) === 'object') {
|
|
1761
1794
|
clearHolder(product.metadata);
|
|
1762
1795
|
}
|
|
1763
1796
|
}
|
|
1764
1797
|
} catch (err) {
|
|
1765
|
-
|
|
1798
|
+
_iterator9.e(err);
|
|
1766
1799
|
} finally {
|
|
1767
|
-
|
|
1800
|
+
_iterator9.f();
|
|
1768
1801
|
}
|
|
1769
|
-
var
|
|
1770
|
-
|
|
1802
|
+
var _iterator10 = _createForOfIteratorHelper(tempOrder.bookings || []),
|
|
1803
|
+
_step10;
|
|
1771
1804
|
try {
|
|
1772
|
-
for (
|
|
1773
|
-
var booking =
|
|
1805
|
+
for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
|
|
1806
|
+
var booking = _step10.value;
|
|
1774
1807
|
var bookingRecord = booking;
|
|
1775
1808
|
if (booking.metadata && _typeof(booking.metadata) === 'object') {
|
|
1776
1809
|
resetHolderField(booking.metadata);
|
|
@@ -1781,9 +1814,9 @@ export function clearTempOrderHolderAssignments(tempOrder) {
|
|
|
1781
1814
|
}
|
|
1782
1815
|
}
|
|
1783
1816
|
} catch (err) {
|
|
1784
|
-
|
|
1817
|
+
_iterator10.e(err);
|
|
1785
1818
|
} finally {
|
|
1786
|
-
|
|
1819
|
+
_iterator10.f();
|
|
1787
1820
|
}
|
|
1788
1821
|
var productsByUid = (_tempOrder$_extend2 = tempOrder._extend) === null || _tempOrder$_extend2 === void 0 ? void 0 : _tempOrder$_extend2.productsByUid;
|
|
1789
1822
|
if (productsByUid && _typeof(productsByUid) === 'object') {
|
|
@@ -1811,9 +1844,9 @@ export function clearTempOrderHolderAssignments(tempOrder) {
|
|
|
1811
1844
|
* getOrderProductLineUid({ metadata: { unique_identification_number: 'line-1' } }); // 'line-1'
|
|
1812
1845
|
*/
|
|
1813
1846
|
export function getOrderProductLineUid(product) {
|
|
1814
|
-
var _product$metadata$uni2, _product$
|
|
1847
|
+
var _product$metadata$uni2, _product$metadata12;
|
|
1815
1848
|
if (!product || _typeof(product) !== 'object') return null;
|
|
1816
|
-
var uid = (_product$metadata$uni2 = (_product$
|
|
1849
|
+
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;
|
|
1817
1850
|
if (uid === undefined || uid === null || uid === '') return null;
|
|
1818
1851
|
return String(uid);
|
|
1819
1852
|
}
|
|
@@ -1824,8 +1857,8 @@ export function getRuntimeProductOrigin(tempOrder, product) {
|
|
|
1824
1857
|
return tempOrder._extend.productsByUid[uid].origin;
|
|
1825
1858
|
}
|
|
1826
1859
|
var matchedProduct = ((tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.products) || []).find(function (item) {
|
|
1827
|
-
var
|
|
1828
|
-
return item === product || getOrderProductLineUid(item) === uid || String((
|
|
1860
|
+
var _ref44, _item$product_id, _ref45, _product$product_id;
|
|
1861
|
+
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 : '');
|
|
1829
1862
|
});
|
|
1830
1863
|
var matchedUid = matchedProduct ? getOrderProductLineUid(matchedProduct) : '';
|
|
1831
1864
|
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;
|
|
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
|
|
|
49
49
|
getCategories(): ProductCategory[];
|
|
50
50
|
setOtherParams(key: string, value: any): void;
|
|
51
51
|
getOtherParams(): any;
|
|
52
|
-
getProductType(): "normal" | "
|
|
52
|
+
getProductType(): "normal" | "duration" | "session";
|
|
53
53
|
}
|
|
@@ -342,7 +342,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
342
342
|
date: string;
|
|
343
343
|
status: string;
|
|
344
344
|
week: string;
|
|
345
|
-
weekNum: 0 | 2 | 1 |
|
|
345
|
+
weekNum: 0 | 2 | 1 | 6 | 4 | 5 | 3;
|
|
346
346
|
}[]>;
|
|
347
347
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
348
348
|
private getScheduleDataByIds;
|
|
@@ -389,7 +389,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
389
389
|
};
|
|
390
390
|
setOtherData(key: string, value: any): void;
|
|
391
391
|
getOtherData(key: string): any;
|
|
392
|
-
getProductTypeById(id: number): Promise<"normal" | "
|
|
392
|
+
getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
|
|
393
393
|
/**
|
|
394
394
|
* 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
|
|
395
395
|
*
|
|
@@ -640,7 +640,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
640
640
|
generateIdempotencyToken(): string;
|
|
641
641
|
syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
|
|
642
642
|
createOrder(params: CommitOrderParams['query']): {
|
|
643
|
-
type: "
|
|
643
|
+
type: "appointment_booking" | "virtual";
|
|
644
644
|
platform: string;
|
|
645
645
|
sales_channel: string;
|
|
646
646
|
order_sales_channel: string;
|
|
@@ -510,6 +510,28 @@ function getOrderProductDeposit(product, runtimeOrigin) {
|
|
|
510
510
|
self_deposit_policy_ids: depositData.self_deposit_policy_ids
|
|
511
511
|
}));
|
|
512
512
|
hasDeposit = true;
|
|
513
|
+
|
|
514
|
+
// 主商品金额不包含 markup/product_price 这类独立计价子商品。
|
|
515
|
+
// 以前父规则命中后直接跳过子项,导致“父价 0 + 子票 70 × 10”即使
|
|
516
|
+
// 子票已命中 50% 定金规则,仍算出 0;应累加子项自己的定金规则。
|
|
517
|
+
// 普通加价/减价子项已计入主价,不能重复收取。未拆分主价的旧订单行
|
|
518
|
+
// selling_price 可能包含整个套餐,继续沿用原口径,避免重复计费。
|
|
519
|
+
const hasSeparateMainPrice = product.metadata?.main_product_attached_bundle_payment_price != null || product.metadata?.main_product_selling_price != null;
|
|
520
|
+
if (hasSeparateMainPrice && Array.isArray(product.product_bundle)) {
|
|
521
|
+
for (const bundleProduct of product.product_bundle) {
|
|
522
|
+
if (bundleProduct.price_type !== 'markup' || bundleProduct.price_type_ext !== 'product_price') continue;
|
|
523
|
+
const bundleDepositData = bundleProduct.custom_deposit_data;
|
|
524
|
+
const bundleResult = handleOrderProductDeposit({
|
|
525
|
+
depositData: bundleDepositData,
|
|
526
|
+
// payment 是已分摊折扣的子商品单价;子项数量和套餐数量各乘一次。
|
|
527
|
+
total: bundleProduct.bundle_payment_price ?? bundleProduct.bundle_selling_price ?? bundleProduct.price,
|
|
528
|
+
num: getSafeOrderProductNum(bundleProduct.num ?? bundleProduct.quantity) * num
|
|
529
|
+
});
|
|
530
|
+
if (!bundleResult.result) continue;
|
|
531
|
+
depositTotal = depositTotal.plus(bundleResult.depositTotal);
|
|
532
|
+
protocolIds.push(...getDepositPolicyIds(bundleDepositData));
|
|
533
|
+
}
|
|
534
|
+
}
|
|
513
535
|
}
|
|
514
536
|
} else {
|
|
515
537
|
const productVariantId = depositProduct.product_variant_id ?? product.product_variant_id;
|
|
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
|
|
|
49
49
|
getCategories(): ProductCategory[];
|
|
50
50
|
setOtherParams(key: string, value: any): void;
|
|
51
51
|
getOtherParams(): any;
|
|
52
|
-
getProductType(): "normal" | "
|
|
52
|
+
getProductType(): "normal" | "duration" | "session";
|
|
53
53
|
}
|
|
@@ -342,7 +342,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
342
342
|
date: string;
|
|
343
343
|
status: string;
|
|
344
344
|
week: string;
|
|
345
|
-
weekNum: 0 | 2 | 1 |
|
|
345
|
+
weekNum: 0 | 2 | 1 | 6 | 4 | 5 | 3;
|
|
346
346
|
}[]>;
|
|
347
347
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
348
348
|
private getScheduleDataByIds;
|
|
@@ -389,7 +389,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
389
389
|
};
|
|
390
390
|
setOtherData(key: string, value: any): void;
|
|
391
391
|
getOtherData(key: string): any;
|
|
392
|
-
getProductTypeById(id: number): Promise<"normal" | "
|
|
392
|
+
getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
|
|
393
393
|
/**
|
|
394
394
|
* 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
|
|
395
395
|
*
|