@pisell/pisellos 2.3.126 → 2.3.128
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 -0
- package/dist/modules/Order/index.js +118 -59
- package/dist/modules/Order/utils/weighedProduct.d.ts +12 -0
- package/dist/modules/Order/utils/weighedProduct.js +94 -0
- package/dist/modules/Order/utils.js +6 -4
- package/dist/modules/Rules/index.js +4 -2
- package/dist/modules/Rules/types.d.ts +2 -0
- package/dist/server/utils/small-ticket.js +1 -1
- package/dist/solution/BaseSales/index.d.ts +2 -2
- package/dist/solution/BaseSales/index.js +75 -39
- package/dist/solution/BaseSales/types.d.ts +5 -1
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +40 -25
- package/dist/solution/BaseSales/utils.js +3 -2
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/ScanOrder/utils.js +3 -2
- package/lib/modules/Order/index.d.ts +1 -0
- package/lib/modules/Order/index.js +71 -11
- package/lib/modules/Order/utils/weighedProduct.d.ts +12 -0
- package/lib/modules/Order/utils/weighedProduct.js +89 -0
- package/lib/modules/Order/utils.js +3 -2
- package/lib/modules/Rules/index.js +4 -2
- package/lib/modules/Rules/types.d.ts +2 -0
- package/lib/server/utils/small-ticket.js +1 -1
- package/lib/solution/BaseSales/index.d.ts +2 -2
- package/lib/solution/BaseSales/index.js +15 -6
- package/lib/solution/BaseSales/types.d.ts +5 -1
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +24 -9
- package/lib/solution/BaseSales/utils.js +2 -1
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/ScanOrder/utils.js +2 -1
- package/package.json +1 -1
|
@@ -8,6 +8,7 @@ var _BaseModule = require("../BaseModule");
|
|
|
8
8
|
var _types = require("./types");
|
|
9
9
|
var _utils = require("./utils");
|
|
10
10
|
var _utils2 = require("../Product/utils");
|
|
11
|
+
var _weighedProduct = require("./utils/weighedProduct");
|
|
11
12
|
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
12
13
|
var _osPrivatePayload = require("../../utils/os-private-payload");
|
|
13
14
|
var _salesNotes = require("./salesNotes");
|
|
@@ -685,7 +686,8 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
685
686
|
isFormSubject: product => (0, _utils.resolveIsFormSubject)(tempOrder, product),
|
|
686
687
|
orderTotalAmount: Number(this.store.summary?.total_amount || 0)
|
|
687
688
|
}, {
|
|
688
|
-
reapplyBookingDiscountProductUids: options?.reapplyBookingDiscountProductUids
|
|
689
|
+
reapplyBookingDiscountProductUids: options?.reapplyBookingDiscountProductUids,
|
|
690
|
+
reapplyWeighedDiscountProductUids: options?.reapplyWeighedDiscountProductUids
|
|
689
691
|
});
|
|
690
692
|
if (result?.productList) {
|
|
691
693
|
const previousProductsByUid = (0, _utils.indexOrderProductsByUid)(tempOrder.products);
|
|
@@ -3685,7 +3687,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
3685
3687
|
};
|
|
3686
3688
|
});
|
|
3687
3689
|
}
|
|
3688
|
-
applyOrderProductUpdateToTempOrder(tempOrder, params) {
|
|
3690
|
+
applyOrderProductUpdateToTempOrder(tempOrder, params, reapplyWeighedDiscountProductUids) {
|
|
3689
3691
|
const {
|
|
3690
3692
|
product_id,
|
|
3691
3693
|
product_variant_id,
|
|
@@ -3758,7 +3760,8 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
3758
3760
|
const previousLineFingerprint = (0, _utils3.buildProductLineFingerprint)((0, _utils.getProductSkuOptions)(targetProduct), targetProduct.product_bundle);
|
|
3759
3761
|
const nextLineFingerprint = (0, _utils3.buildProductLineFingerprint)((0, _utils.getProductSkuOptions)(nextProduct), nextProduct.product_bundle);
|
|
3760
3762
|
const callerChangesVariant = Number(product_variant_id || 0) !== Number(targetProduct.product_variant_id || 0);
|
|
3761
|
-
const
|
|
3763
|
+
const callerChangesWeighing = (0, _weighedProduct.getWeighedProductPriceFingerprint)(targetProduct.product_sku) !== (0, _weighedProduct.getWeighedProductPriceFingerprint)(nextProduct.product_sku);
|
|
3764
|
+
const callerChangesLineConfiguration = callerChangesVariant || callerChangesWeighing || previousLineFingerprint !== nextLineFingerprint;
|
|
3762
3765
|
const isPersistedOrderLine = targetProduct.order_detail_id !== undefined && targetProduct.order_detail_id !== null;
|
|
3763
3766
|
const callerChangesDiscountList = Array.isArray(updates?.discount_list) && updates.discount_list.length > 0 && !isSameDiscountList(updates.discount_list, targetProduct.discount_list);
|
|
3764
3767
|
const callerUpdatesManualPrice = updates?.metadata?.price_override !== undefined || updates?.metadata?.is_manual_discount !== undefined || updates?.metadata?.product_discount_reason !== undefined || callerChangesDiscountList;
|
|
@@ -3774,6 +3777,23 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
3774
3777
|
};
|
|
3775
3778
|
return hasChangedPrice(updates.selling_price, targetProduct.selling_price) || hasChangedPrice(updates.original_price, targetProduct.original_price);
|
|
3776
3779
|
})();
|
|
3780
|
+
const weighedSourcePrice = callerChangesWeighing ? (0, _weighedProduct.resolveWeighedSourcePrice)(nextProduct.product_sku) : undefined;
|
|
3781
|
+
const hasResolvedWeighedPrice = weighedSourcePrice !== undefined;
|
|
3782
|
+
if (hasResolvedWeighedPrice && !callerUpdatesSourcePrice) {
|
|
3783
|
+
const nextMainOriginal = new _decimal.default(weighedSourcePrice).plus((0, _utils.sumOptionUnitPrice)((0, _utils.getProductSkuOptions)(nextProduct)));
|
|
3784
|
+
const previousMainOriginal = new _decimal.default(targetProduct.metadata?.main_product_original_price ?? targetProduct.original_price ?? 0);
|
|
3785
|
+
const previousMainSelling = new _decimal.default(targetProduct.metadata?.main_product_selling_price ?? targetProduct.selling_price ?? 0);
|
|
3786
|
+
// A manual final price remains fixed; other legacy discounts keep their amount
|
|
3787
|
+
// until Rules reapplies the currently selected wallet discount below.
|
|
3788
|
+
const nextMainSelling = isManualProductDiscountProduct(nextProduct) ? previousMainSelling : nextMainOriginal.minus(previousMainOriginal.minus(previousMainSelling));
|
|
3789
|
+
nextProduct.metadata = {
|
|
3790
|
+
...nextProduct.metadata,
|
|
3791
|
+
source_product_price: weighedSourcePrice,
|
|
3792
|
+
main_product_original_price: callerUpdatesMainOriginalPrice ? nextProduct.metadata.main_product_original_price : nextMainOriginal.toFixed(2),
|
|
3793
|
+
main_product_selling_price: callerUpdatesMainSellingPrice ? nextProduct.metadata.main_product_selling_price : _decimal.default.max(0, nextMainSelling).toFixed(2),
|
|
3794
|
+
price_schema_version: 2
|
|
3795
|
+
};
|
|
3796
|
+
}
|
|
3777
3797
|
if (isPersistedOrderLine && !callerChangesLineConfiguration && !callerUpdatesManualPrice && !callerAllowsBookingReprice) {
|
|
3778
3798
|
nextProduct.selling_price = targetProduct.selling_price;
|
|
3779
3799
|
nextProduct.original_price = targetProduct.original_price;
|
|
@@ -3790,17 +3810,17 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
3790
3810
|
// 新配置只传了 source 时,不能把未传的 main_product_* 从旧行继承下来。
|
|
3791
3811
|
// 以新 source + 新 option 重建券前价;券后价未显式提供时保留旧主商品折扣额。
|
|
3792
3812
|
const previousMainOriginal = new _decimal.default(Number(targetProduct.metadata?.main_product_original_price) || 0);
|
|
3793
|
-
const previousMainSelling = new _decimal.default(Number(targetProduct.metadata?.main_product_selling_price
|
|
3813
|
+
const previousMainSelling = new _decimal.default(Number(targetProduct.metadata?.main_product_selling_price ?? previousMainOriginal.toNumber()));
|
|
3794
3814
|
const preservedDiscount = previousMainOriginal.minus(previousMainSelling);
|
|
3795
3815
|
const nextMainOriginal = new _decimal.default(Number(updates.metadata.source_product_price) || 0).plus((0, _utils.sumOptionUnitPrice)((0, _utils.getProductSkuOptions)(nextProduct)));
|
|
3796
3816
|
nextProduct.metadata = {
|
|
3797
3817
|
...(nextProduct.metadata || {}),
|
|
3798
3818
|
source_product_price: String(updates.metadata.source_product_price),
|
|
3799
3819
|
main_product_original_price: callerUpdatesMainOriginalPrice ? String(updates.metadata.main_product_original_price) : nextMainOriginal.toDecimalPlaces(2).toFixed(2),
|
|
3800
|
-
main_product_selling_price: callerUpdatesMainSellingPrice ? String(updates.metadata.main_product_selling_price) : nextMainOriginal.minus(preservedDiscount).toDecimalPlaces(2).toFixed(2),
|
|
3820
|
+
main_product_selling_price: callerUpdatesMainSellingPrice ? String(updates.metadata.main_product_selling_price) : hasResolvedWeighedPrice && isManualProductDiscountProduct(nextProduct) ? previousMainSelling.toFixed(2) : nextMainOriginal.minus(preservedDiscount).toDecimalPlaces(2).toFixed(2),
|
|
3801
3821
|
price_schema_version: 2
|
|
3802
3822
|
};
|
|
3803
|
-
} else if (callerChangesVariant && !callerUpdatesTopPrice && !callerUpdatesMainMeta) {
|
|
3823
|
+
} else if (callerChangesVariant && !hasResolvedWeighedPrice && !callerUpdatesTopPrice && !callerUpdatesMainMeta) {
|
|
3804
3824
|
// variant 已变化但 caller 没有显式报价时,旧 v2 metadata 不能继续充当权威价格源。
|
|
3805
3825
|
// 清理后由 normalize 优先读取 metadata.origin.variant 中新 variant 的目录价;
|
|
3806
3826
|
// 顶层 original/selling 的旧差额仍会作为 legacy discount 迁移到新价格。
|
|
@@ -3812,7 +3832,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
3812
3832
|
delete nextProduct.metadata.main_product_selling_price;
|
|
3813
3833
|
delete nextProduct.metadata.main_product_original_price;
|
|
3814
3834
|
delete nextProduct.metadata.price_schema_version;
|
|
3815
|
-
} else if (callerChangesLineConfiguration && !callerUpdatesTopPrice && !callerUpdatesMainMeta) {
|
|
3835
|
+
} else if (callerChangesLineConfiguration && !hasResolvedWeighedPrice && !callerUpdatesTopPrice && !callerUpdatesMainMeta) {
|
|
3816
3836
|
// 仅 option / bundle 变化时,保留历史 source 和主商品折扣金额,
|
|
3817
3837
|
// 但必须让 original 与 selling 一起随新的 option 金额移动。
|
|
3818
3838
|
const previousOptionSum = (0, _utils.sumOptionUnitPrice)((0, _utils.getProductSkuOptions)(targetProduct));
|
|
@@ -3829,7 +3849,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
3829
3849
|
main_product_selling_price: nextMainOriginal.minus(preservedDiscount).toDecimalPlaces(2).toFixed(2),
|
|
3830
3850
|
price_schema_version: 2
|
|
3831
3851
|
};
|
|
3832
|
-
} else if (callerUpdatesTopPrice && !callerUpdatesMainMeta) {
|
|
3852
|
+
} else if (callerUpdatesTopPrice && !callerUpdatesMainMeta && !hasResolvedWeighedPrice) {
|
|
3833
3853
|
const existedMeta = nextProduct.metadata || {};
|
|
3834
3854
|
nextProduct.metadata = {
|
|
3835
3855
|
...existedMeta
|
|
@@ -3839,6 +3859,37 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
3839
3859
|
delete nextProduct.metadata.main_product_original_price;
|
|
3840
3860
|
delete nextProduct.metadata.price_schema_version;
|
|
3841
3861
|
}
|
|
3862
|
+
if (callerChangesLineConfiguration && (0, _weighedProduct.resolveWeighedSourcePrice)(nextProduct.product_sku) !== undefined && nextProduct.metadata.main_product_original_price != null && nextProduct.metadata.main_product_selling_price != null && isManualProductDiscountProduct(nextProduct)) {
|
|
3863
|
+
const originalPrice = (0, _utils.composeLinePrice)({
|
|
3864
|
+
mainPrice: nextProduct.metadata.main_product_original_price,
|
|
3865
|
+
bundle: (0, _weighedProduct.withOriginalBundleOptionPrices)(nextProduct.product_bundle),
|
|
3866
|
+
useOriginalBundle: true
|
|
3867
|
+
});
|
|
3868
|
+
const sellingPrice = (0, _utils.composeLinePrice)({
|
|
3869
|
+
mainPrice: nextProduct.metadata.main_product_selling_price,
|
|
3870
|
+
bundle: nextProduct.product_bundle
|
|
3871
|
+
});
|
|
3872
|
+
const previousManualDiscount = (0, _manualProductDiscount.findManualProductDiscountItem)(nextProduct.discount_list);
|
|
3873
|
+
nextProduct.original_price = originalPrice;
|
|
3874
|
+
nextProduct.metadata = {
|
|
3875
|
+
...nextProduct.metadata,
|
|
3876
|
+
origin: {
|
|
3877
|
+
...nextProduct.metadata.origin,
|
|
3878
|
+
_extend: {
|
|
3879
|
+
...nextProduct.metadata.origin?._extend,
|
|
3880
|
+
origin_total: Number(originalPrice)
|
|
3881
|
+
}
|
|
3882
|
+
}
|
|
3883
|
+
};
|
|
3884
|
+
nextProduct.discount_list = (0, _manualProductDiscount.mergeManualProductDiscountIntoList)(nextProduct.discount_list, (0, _manualProductDiscount.buildManualProductDiscountItem)({
|
|
3885
|
+
originTotal: Number(originalPrice),
|
|
3886
|
+
sellingTotal: Number(sellingPrice),
|
|
3887
|
+
quantity: nextProduct.num,
|
|
3888
|
+
message: previousManualDiscount?.discount.message,
|
|
3889
|
+
discountway: previousManualDiscount?.discount.discountway,
|
|
3890
|
+
discount_per: previousManualDiscount?.discount.discount_per
|
|
3891
|
+
}));
|
|
3892
|
+
}
|
|
3842
3893
|
// normalizeOrderProduct 幂等:v2 metadata 存在 → 保留 main_product_* 折扣重算 composite;
|
|
3843
3894
|
// 否则 → 把顶层 selling_price 视作 source,派生 main_product_* 并写 price_schema_version: 2。
|
|
3844
3895
|
let normalizedProduct = this.normalizeVirtualSettlementProductIfEnabled((0, _utils.mergeOrderProductDisplayFields)(nextProduct, (0, _utils3.normalizeOrderProduct)(nextProduct)));
|
|
@@ -3876,6 +3927,10 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
3876
3927
|
};
|
|
3877
3928
|
tempOrder.bookings = [...(tempOrder.bookings || []), linked.booking];
|
|
3878
3929
|
}
|
|
3930
|
+
if (callerChangesWeighing && !isManualProductDiscountProduct(normalizedProduct)) {
|
|
3931
|
+
const uid = normalizedProduct.metadata?.unique_identification_number;
|
|
3932
|
+
if (uid) reapplyWeighedDiscountProductUids?.push(String(uid));
|
|
3933
|
+
}
|
|
3879
3934
|
tempOrder.products[productIndex] = normalizedProduct;
|
|
3880
3935
|
this.syncTempOrderHolderFromBookings(tempOrder);
|
|
3881
3936
|
this.captureProductRuntime(tempOrder, updates, tempOrder.products[productIndex], tempOrder.products[productIndex].metadata?.unique_identification_number);
|
|
@@ -3883,9 +3938,11 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
3883
3938
|
}
|
|
3884
3939
|
async updateOrderProduct(params) {
|
|
3885
3940
|
const tempOrder = this.ensureTempOrder();
|
|
3886
|
-
const
|
|
3941
|
+
const reapplyWeighedDiscountProductUids = [];
|
|
3942
|
+
const updatedProductUid = this.applyOrderProductUpdateToTempOrder(tempOrder, params, reapplyWeighedDiscountProductUids);
|
|
3887
3943
|
const promotionPayload = await this.evaluatePromotion();
|
|
3888
3944
|
this.applyDiscount({
|
|
3945
|
+
reapplyWeighedDiscountProductUids,
|
|
3889
3946
|
reapplyBookingDiscountProductUids: params.allow_booking_discount_reapply && updatedProductUid ? [String(updatedProductUid)] : undefined
|
|
3890
3947
|
});
|
|
3891
3948
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
@@ -3904,8 +3961,9 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
3904
3961
|
if (!paramsList.length) {
|
|
3905
3962
|
return tempOrder.products;
|
|
3906
3963
|
}
|
|
3964
|
+
const reapplyWeighedDiscountProductUids = [];
|
|
3907
3965
|
const reapplyBookingDiscountProductUids = paramsList.reduce((acc, params) => {
|
|
3908
|
-
const updatedProductUid = this.applyOrderProductUpdateToTempOrder(tempOrder, params);
|
|
3966
|
+
const updatedProductUid = this.applyOrderProductUpdateToTempOrder(tempOrder, params, reapplyWeighedDiscountProductUids);
|
|
3909
3967
|
// 批量改预约时间时,延迟到最后一次折扣计算里统一恢复已选预约折扣卡。
|
|
3910
3968
|
if (params.allow_booking_discount_reapply && updatedProductUid) {
|
|
3911
3969
|
acc.push(String(updatedProductUid));
|
|
@@ -3913,6 +3971,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
3913
3971
|
return acc;
|
|
3914
3972
|
}, []);
|
|
3915
3973
|
await this.finalizeAfterProductsMutation(tempOrder, {
|
|
3974
|
+
reapplyWeighedDiscountProductUids,
|
|
3916
3975
|
reapplyBookingDiscountProductUids: reapplyBookingDiscountProductUids.length ? reapplyBookingDiscountProductUids : undefined
|
|
3917
3976
|
});
|
|
3918
3977
|
this.logInfo('updateOrderProduct success', {
|
|
@@ -4044,7 +4103,8 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
4044
4103
|
this.syncTempOrderHolderFromBookings(tempOrder);
|
|
4045
4104
|
const promotionPayload = await this.evaluatePromotion();
|
|
4046
4105
|
this.applyDiscount({
|
|
4047
|
-
reapplyBookingDiscountProductUids: options?.reapplyBookingDiscountProductUids
|
|
4106
|
+
reapplyBookingDiscountProductUids: options?.reapplyBookingDiscountProductUids,
|
|
4107
|
+
reapplyWeighedDiscountProductUids: options?.reapplyWeighedDiscountProductUids
|
|
4048
4108
|
});
|
|
4049
4109
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
4050
4110
|
await this.recalculateSummary({
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Only pricing/measurement fields participate; display and option data do not. */
|
|
2
|
+
export declare function getWeighedProductPriceFingerprint(sku?: Record<string, any>): string;
|
|
3
|
+
/**
|
|
4
|
+
* A weighed line's source is the amount for its net weight, never its catalog unit price.
|
|
5
|
+
* Persisted SKU measurements and the full catalog snapshot take priority over runtime
|
|
6
|
+
* _extend.weighing, which can survive repricing with an obsolete total_amount.
|
|
7
|
+
*/
|
|
8
|
+
export declare function resolveWeighedSourcePrice(sku?: Record<string, any>, weighing?: Record<string, any>): string | undefined;
|
|
9
|
+
/** Original bundle totals must use the nested options before manual distribution. */
|
|
10
|
+
export declare function withOriginalBundleOptionPrices(bundles?: Array<Record<string, any>>): {
|
|
11
|
+
option: any;
|
|
12
|
+
}[] | undefined;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getWeighedProductPriceFingerprint = getWeighedProductPriceFingerprint;
|
|
7
|
+
exports.resolveWeighedSourcePrice = resolveWeighedSourcePrice;
|
|
8
|
+
exports.withOriginalBundleOptionPrices = withOriginalBundleOptionPrices;
|
|
9
|
+
var _decimal = _interopRequireDefault(require("decimal.js"));
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
const UNIT_GRAMS = {
|
|
12
|
+
kg: '1000',
|
|
13
|
+
KILOGRAMS: '1000',
|
|
14
|
+
g: '1',
|
|
15
|
+
GRAMS: '1',
|
|
16
|
+
lb: '453.59237',
|
|
17
|
+
POUNDS: '453.59237',
|
|
18
|
+
oz: '28.349523125',
|
|
19
|
+
OUNCES: '28.349523125'
|
|
20
|
+
};
|
|
21
|
+
function nonNegative(value) {
|
|
22
|
+
if (value === null || value === undefined || value === '') return undefined;
|
|
23
|
+
try {
|
|
24
|
+
const result = new _decimal.default(value);
|
|
25
|
+
return result.isFinite() && result.gte(0) ? result : undefined;
|
|
26
|
+
} catch {
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function numericKey(value) {
|
|
31
|
+
return nonNegative(value)?.toString();
|
|
32
|
+
}
|
|
33
|
+
function unitKey(value) {
|
|
34
|
+
return UNIT_GRAMS[String(value)] || (value == null ? undefined : String(value));
|
|
35
|
+
}
|
|
36
|
+
function snapshotKey(snapshot) {
|
|
37
|
+
return [numericKey(snapshot?.price), unitKey(snapshot?.unit), numericKey(snapshot?.unit_value ?? 1)];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Only pricing/measurement fields participate; display and option data do not. */
|
|
41
|
+
function getWeighedProductPriceFingerprint(sku) {
|
|
42
|
+
if (Number(sku?.open_sold_weight) !== 1) return 'unweighed';
|
|
43
|
+
return JSON.stringify([1, numericKey(sku?.net_weight), unitKey(sku?.unit), numericKey(sku?.unit_price), numericKey(sku?.unit_weight ?? 1), snapshotKey(sku?.unit_data_snapshot)]);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* A weighed line's source is the amount for its net weight, never its catalog unit price.
|
|
48
|
+
* Persisted SKU measurements and the full catalog snapshot take priority over runtime
|
|
49
|
+
* _extend.weighing, which can survive repricing with an obsolete total_amount.
|
|
50
|
+
*/
|
|
51
|
+
function resolveWeighedSourcePrice(sku, weighing) {
|
|
52
|
+
if (sku?.open_sold_weight != null && Number(sku.open_sold_weight) !== 1) return undefined;
|
|
53
|
+
if (Number(sku?.open_sold_weight) !== 1 && !weighing) return undefined;
|
|
54
|
+
const hasSkuMeasurement = sku?.net_weight !== undefined && sku?.net_weight !== null;
|
|
55
|
+
const measurement = hasSkuMeasurement ? sku : weighing;
|
|
56
|
+
const netWeight = nonNegative(measurement?.net_weight);
|
|
57
|
+
if (netWeight === undefined) return undefined;
|
|
58
|
+
const snapshot = hasSkuMeasurement ? sku?.unit_data_snapshot : weighing?.scalePriceProduct;
|
|
59
|
+
const snapshotPrice = nonNegative(snapshot?.price);
|
|
60
|
+
const snapshotUnits = nonNegative(snapshot?.unit_value ?? 1);
|
|
61
|
+
const sourceGrams = UNIT_GRAMS[String(snapshot?.unit)];
|
|
62
|
+
const targetGrams = UNIT_GRAMS[String(measurement?.unit)];
|
|
63
|
+
if (snapshotPrice && snapshotUnits?.gt(0) && sourceGrams && targetGrams) {
|
|
64
|
+
return snapshotPrice.mul(netWeight).mul(targetGrams).div(sourceGrams).div(snapshotUnits).toFixed(2);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Legacy callers may only retain the native scale's amount. Do not let an old
|
|
68
|
+
// amount overwrite a changed SKU measurement, unit price, or pricing snapshot.
|
|
69
|
+
const runtimeAmount = nonNegative(weighing?.total_amount);
|
|
70
|
+
const runtimeMatchesSku = !hasSkuMeasurement || numericKey(weighing?.net_weight) === numericKey(sku?.net_weight) && unitKey(weighing?.unit) === unitKey(sku?.unit) && numericKey(weighing?.unit_price) === numericKey(sku?.unit_price) && numericKey(weighing?.unit_weight ?? 1) === numericKey(sku?.unit_weight ?? 1) && JSON.stringify(snapshotKey(weighing?.scalePriceProduct)) === JSON.stringify(snapshotKey(sku?.unit_data_snapshot));
|
|
71
|
+
if (runtimeAmount && runtimeMatchesSku) return runtimeAmount.toFixed(2);
|
|
72
|
+
|
|
73
|
+
// Older persisted orders have only a rounded per-scale-unit price.
|
|
74
|
+
const unitPrice = nonNegative(measurement?.unit_price);
|
|
75
|
+
const unitWeight = nonNegative(measurement?.unit_weight ?? 1);
|
|
76
|
+
if (!unitPrice || !unitWeight?.gt(0)) return undefined;
|
|
77
|
+
return netWeight.div(unitWeight).mul(unitPrice).toFixed(2);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** Original bundle totals must use the nested options before manual distribution. */
|
|
81
|
+
function withOriginalBundleOptionPrices(bundles) {
|
|
82
|
+
return bundles?.map(bundle => ({
|
|
83
|
+
...bundle,
|
|
84
|
+
option: bundle.option?.map(option => ({
|
|
85
|
+
...option,
|
|
86
|
+
add_price: option.original_price ?? option.add_price ?? option.price
|
|
87
|
+
}))
|
|
88
|
+
}));
|
|
89
|
+
}
|
|
@@ -130,11 +130,12 @@ Object.defineProperty(exports, "syncManualProductDiscountProductNum", {
|
|
|
130
130
|
});
|
|
131
131
|
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
132
132
|
var _decimal = _interopRequireDefault(require("decimal.js"));
|
|
133
|
+
var _weighedProduct = require("./utils/weighedProduct");
|
|
134
|
+
var _manualProductDiscount = require("./utils/manualProductDiscount");
|
|
133
135
|
var _utils = require("../Holder/utils");
|
|
134
136
|
var _utils2 = require("../../solution/ScanOrder/utils");
|
|
135
137
|
var _orderCollectionIdentity = require("./utils/orderCollectionIdentity");
|
|
136
138
|
var _salesNotes = require("./salesNotes");
|
|
137
|
-
var _manualProductDiscount = require("./utils/manualProductDiscount");
|
|
138
139
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
139
140
|
const POINT_CARD_SNAPSHOT_TAG = 'point_card';
|
|
140
141
|
const VIRTUAL_CURRENCY_SNAPSHOT_TAG = 'virtual_currency';
|
|
@@ -920,7 +921,7 @@ function createDefaultOrderRulesHooks() {
|
|
|
920
921
|
});
|
|
921
922
|
const composedOriginalPrice = composeLinePrice({
|
|
922
923
|
mainPrice: nextMainOriginalPrice,
|
|
923
|
-
bundle: nextBundle,
|
|
924
|
+
bundle: Number(product.product_sku?.open_sold_weight) === 1 && (0, _manualProductDiscount.hasManualProductDiscountFlag)(metadataAny) ? (0, _weighedProduct.withOriginalBundleOptionPrices)(nextBundle) : nextBundle,
|
|
924
925
|
useOriginalBundle: true
|
|
925
926
|
});
|
|
926
927
|
const finalOriginalPrice = resolveManualOverrideLineOriginalPrice({
|
|
@@ -211,7 +211,8 @@ class RulesModule extends _BaseModule.BaseModule {
|
|
|
211
211
|
// 识别出来是不是在编辑的界面里又新增了商品
|
|
212
212
|
// 这种情况下,如果有可用的优惠券,也会自动勾选上
|
|
213
213
|
const isEditModeAddNewProduct = productList.find(n => n.booking_id) && productList.find(n => !n.booking_id);
|
|
214
|
-
const
|
|
214
|
+
const reapplyWeighedDiscountProductUids = new Set((options?.reapplyWeighedDiscountProductUids || []).map(String));
|
|
215
|
+
const reapplyBookingDiscountProductUids = new Set([...(options?.reapplyBookingDiscountProductUids || []), ...reapplyWeighedDiscountProductUids].filter(uid => uid !== undefined && uid !== null && uid !== '').map(String));
|
|
215
216
|
const getOriginProductUid = originProduct => {
|
|
216
217
|
const uid = originProduct?.metadata?.unique_identification_number ?? originProduct?.unique_identification_number;
|
|
217
218
|
if (uid === undefined || uid === null || uid === '') return undefined;
|
|
@@ -915,7 +916,8 @@ class RulesModule extends _BaseModule.BaseModule {
|
|
|
915
916
|
});
|
|
916
917
|
|
|
917
918
|
// 已持久化且已有钱包券/折扣卡的商品行跳过,保留后端历史折扣结果。
|
|
918
|
-
|
|
919
|
+
const isReweighedProduct = reapplyWeighedDiscountProductUids.has(getOriginProductUid(originProduct) || '');
|
|
920
|
+
if (isPersistedProduct && hasExistingWalletDiscount && !isReweighedProduct) {
|
|
919
921
|
if (flatItem.type === 'main') {
|
|
920
922
|
processedProductsMap.set(product._id, [originProduct]);
|
|
921
923
|
}
|
|
@@ -31,6 +31,8 @@ export interface RulesCalcDiscountOptions {
|
|
|
31
31
|
scan?: boolean;
|
|
32
32
|
/** Change time 重报价目标行:允许已选编辑态折扣卡重新应用到这些 booking 商品。 */
|
|
33
33
|
reapplyBookingDiscountProductUids?: string[];
|
|
34
|
+
/** Reweighed order lines only: reapply selected wallet discounts against their new amount. */
|
|
35
|
+
reapplyWeighedDiscountProductUids?: string[];
|
|
34
36
|
}
|
|
35
37
|
export interface RulesModuleAPI {
|
|
36
38
|
setRulesList: (rulesList: Rules[]) => Promise<void>;
|
|
@@ -952,7 +952,7 @@ function resolveVariantItem(group, itemPositionId) {
|
|
|
952
952
|
}
|
|
953
953
|
function getProductTitleSource(source, locale) {
|
|
954
954
|
if (!source || typeof source !== 'object') return '';
|
|
955
|
-
return resolveTitleValue(source.product_title, locale) || resolveTitleValue(source.title_i18n, locale) || resolveTitleValue(source.title, locale) || resolveTitleValue(source.name, locale);
|
|
955
|
+
return resolveTitleValue(source.product_title, locale) || resolveTitleValue(source.title_i18n, locale) || resolveTitleValue(source.title, locale) || resolveTitleValue(source.name_i18n, locale) || resolveTitleValue(source.name, locale);
|
|
956
956
|
}
|
|
957
957
|
function getBundleProductTitleSource(source, locale) {
|
|
958
958
|
if (!source || typeof source !== 'object') return '';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Module, ModuleOptions, PisellCore } from '../../types';
|
|
2
2
|
import { BaseModule } from '../../modules/BaseModule';
|
|
3
|
-
import { BaseSalesOrderProduct, BaseSalesOrderProductIdentity, BaseSalesPaymentStatus, BaseSalesUpdateOrderProductQuantityParams, BaseSalesCalculateProductBookingPriceParams, BaseSalesPriceRecalculationContextChange, BaseSalesProductBookingPriceResult, BaseSalesQuotationCustomerScopeInfo, BaseSalesScanCodeResult, BaseSalesCashPaymentConfig, BaseSalesPayCashParams, BaseSalesPayCashResult, BaseSalesCommitPaymentMethodParams, BaseSalesCommitPaymentMethodResult, BaseSalesConfirmWalletPaymentResult } from './types';
|
|
3
|
+
import { BaseSalesOrderProduct, BaseSalesOrderProductIdentity, BaseSalesPaymentStatus, BaseSalesUpdateOrderProductQuantityParams, BaseSalesCalculateProductBookingPriceParams, BaseSalesPriceRecalculationContextChange, BaseSalesProductBookingPriceResult, BaseSalesQuotationCustomerScopeInfo, BaseSalesScanCodeResult, BaseSalesCashPaymentOptions, BaseSalesCashPaymentConfig, BaseSalesPayCashParams, BaseSalesPayCashResult, BaseSalesCommitPaymentMethodParams, BaseSalesCommitPaymentMethodResult, BaseSalesConfirmWalletPaymentResult } from './types';
|
|
4
4
|
import { OrderModule } from '../../modules/Order';
|
|
5
5
|
import type { AddProductBookingInput, AddProductToOrderOptions, LoadSalesDetailParams, OrderPaymentData, OrderPaymentUpdateOptions, OrderPaymentUpdateResult, OrderPaymentSource, SendCustomerPayLinkParams, SyncPaymentsToOrderParams, SyncPaymentsToOrderResult, UpdateTempOrderCustomerInput, UpdateOrderBookingParams, UpdateOrderProductParams, OrderTempOrder, OrderSummary, OrderPromotionEvaluator, OrderGiftSelectResolver, OrderUnfulfilledPromotion, OrderLastGiftActions, RemoveProductsFromOrderOptions, ReplaceTempOrderOptions, SalesNote, SalesNotesMutationSnapshot, SetSalesNoteInput, PickupReferenceMode, ShopServiceData, ShopServiceType } from '../../modules/Order/types';
|
|
6
6
|
import type { SubmitPayloadEnhancer } from '../../modules/Order/utils';
|
|
@@ -450,7 +450,7 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
450
450
|
private findCashPaymentMethod;
|
|
451
451
|
private getPendingWalletPaymentAmount;
|
|
452
452
|
/** 读取现金 action 所需的支付方式、待付金额和快捷金额。 */
|
|
453
|
-
getCashPaymentConfig(): Promise<BaseSalesCashPaymentConfig>;
|
|
453
|
+
getCashPaymentConfig(options?: BaseSalesCashPaymentOptions): Promise<BaseSalesCashPaymentConfig>;
|
|
454
454
|
/**
|
|
455
455
|
* 确认足额覆盖订单的 pending Wallet 支付并提交订单。
|
|
456
456
|
*
|
|
@@ -3353,10 +3353,14 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
3353
3353
|
getPaymentMethods() {
|
|
3354
3354
|
return [...this.paymentMethodsCache];
|
|
3355
3355
|
}
|
|
3356
|
-
findCashPaymentMethod(paymentMethods) {
|
|
3356
|
+
findCashPaymentMethod(paymentMethods, paymentMethodId) {
|
|
3357
3357
|
return paymentMethods.find(method => {
|
|
3358
|
+
if (method?.enabled === false || method?.enable === false) return false;
|
|
3358
3359
|
const identifiers = [method?.code, method?.type, method?.tag].map(value => String(value || '').toUpperCase());
|
|
3359
|
-
|
|
3360
|
+
const isDefaultCash = identifiers.includes('CASHMANUAL');
|
|
3361
|
+
if (paymentMethodId === undefined) return isDefaultCash;
|
|
3362
|
+
const isCustomCash = String(method?.type || '').trim().toLowerCase() === 'custom' && [method?.name, method?.nameEn].some(name => typeof name === 'string' && /现金|現金|cash/i.test(name));
|
|
3363
|
+
return String(method?.id) === String(paymentMethodId) && (isDefaultCash || isCustomCash);
|
|
3360
3364
|
});
|
|
3361
3365
|
}
|
|
3362
3366
|
getPendingWalletPaymentAmount(payments = this.store.order?.getOrderPayments?.() || []) {
|
|
@@ -3373,13 +3377,16 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
3373
3377
|
}
|
|
3374
3378
|
|
|
3375
3379
|
/** 读取现金 action 所需的支付方式、待付金额和快捷金额。 */
|
|
3376
|
-
async getCashPaymentConfig() {
|
|
3380
|
+
async getCashPaymentConfig(options = {}) {
|
|
3377
3381
|
if (!this.store.payment) throw new Error('payment 模块未初始化');
|
|
3378
3382
|
let paymentMethods = this.getPaymentMethods();
|
|
3379
|
-
let paymentMethod = this.findCashPaymentMethod(paymentMethods);
|
|
3383
|
+
let paymentMethod = this.findCashPaymentMethod(paymentMethods, options.paymentMethodId);
|
|
3380
3384
|
if (!paymentMethod) {
|
|
3381
3385
|
paymentMethods = await this.getPaymentMethodsAsync();
|
|
3382
|
-
paymentMethod = this.findCashPaymentMethod(paymentMethods);
|
|
3386
|
+
paymentMethod = this.findCashPaymentMethod(paymentMethods, options.paymentMethodId);
|
|
3387
|
+
}
|
|
3388
|
+
if (!paymentMethod && options.paymentMethodId !== undefined) {
|
|
3389
|
+
throw new Error(`未找到可用的现金支付方式:${options.paymentMethodId}`);
|
|
3383
3390
|
}
|
|
3384
3391
|
const amountSnapshot = this.store.order?.getOrderAmountSnapshot?.();
|
|
3385
3392
|
const pendingWalletAmount = this.getPendingWalletPaymentAmount();
|
|
@@ -3477,7 +3484,9 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
3477
3484
|
if (!Number.isFinite(amount) || amount <= 0) {
|
|
3478
3485
|
throw new Error('现金支付金额必须大于 0');
|
|
3479
3486
|
}
|
|
3480
|
-
const config = await this.getCashPaymentConfig()
|
|
3487
|
+
const config = params.paymentMethodId === undefined ? await this.getCashPaymentConfig() : await this.getCashPaymentConfig({
|
|
3488
|
+
paymentMethodId: params.paymentMethodId
|
|
3489
|
+
});
|
|
3481
3490
|
const paymentMethod = config.paymentMethod;
|
|
3482
3491
|
if (!paymentMethod) throw new Error('未找到可用的 CASHMANUAL 支付方式');
|
|
3483
3492
|
if (config.amountDue <= 0) throw new Error('当前订单没有待支付金额');
|
|
@@ -23,13 +23,17 @@ export type BaseSalesHookName = typeof BaseSalesHookNames[keyof typeof BaseSales
|
|
|
23
23
|
export declare function createBaseSalesHook(moduleName: string, hookName: BaseSalesHookName): string;
|
|
24
24
|
export type BaseSalesStatus = 'idle' | 'initializing' | 'ready' | 'error';
|
|
25
25
|
export type BaseSalesPaymentStatus = 'paid' | 'partially_paid' | 'unpaid' | 'payment_processing' | string;
|
|
26
|
+
export interface BaseSalesCashPaymentOptions {
|
|
27
|
+
/** 指定现金支付方式;省略时使用默认 CASHMANUAL。 */
|
|
28
|
+
paymentMethodId?: number | string;
|
|
29
|
+
}
|
|
26
30
|
export interface BaseSalesCashPaymentConfig {
|
|
27
31
|
available: boolean;
|
|
28
32
|
paymentMethod?: PaymentMethod;
|
|
29
33
|
amountDue: number;
|
|
30
34
|
recommendedAmounts: number[];
|
|
31
35
|
}
|
|
32
|
-
export interface BaseSalesPayCashParams {
|
|
36
|
+
export interface BaseSalesPayCashParams extends BaseSalesCashPaymentOptions {
|
|
33
37
|
/** 实际计入订单的现金支付金额(部分支付时小于待付金额)。 */
|
|
34
38
|
amount: number;
|
|
35
39
|
/** 顾客实际交付现金;可大于 amount。 */
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.transformBaseProductToOrderProduct = transformBaseProductToOrderProduct;
|
|
7
|
+
var _weighedProduct = require("../../../modules/Order/utils/weighedProduct");
|
|
7
8
|
var _utils = require("../../../modules/Order/utils");
|
|
8
9
|
var _manualProductDiscount = require("../../../modules/Order/utils/manualProductDiscount");
|
|
9
10
|
function toNumber(value, fallback = 0) {
|
|
@@ -65,11 +66,11 @@ function appendDataVariantIds(base, ...values) {
|
|
|
65
66
|
}
|
|
66
67
|
return Array.isArray(base) || result.length ? result : undefined;
|
|
67
68
|
}
|
|
68
|
-
function normalizeOptionItems(optionItems) {
|
|
69
|
+
function normalizeOptionItems(optionItems, useOriginalPrice = false) {
|
|
69
70
|
if (!Array.isArray(optionItems)) return [];
|
|
70
71
|
return optionItems.map(optionItem => {
|
|
71
72
|
const optionGroupItemId = toNumber(optionItem?.option_group_item_id ?? optionItem?.id);
|
|
72
|
-
const price = optionItem?.price ?? optionItem?.add_price ?? 0;
|
|
73
|
+
const price = (useOriginalPrice ? optionItem?.original_price : undefined) ?? optionItem?.price ?? optionItem?.add_price ?? 0;
|
|
73
74
|
return {
|
|
74
75
|
...optionItem,
|
|
75
76
|
option_group_item_id: optionGroupItemId,
|
|
@@ -80,10 +81,12 @@ function normalizeOptionItems(optionItems) {
|
|
|
80
81
|
};
|
|
81
82
|
});
|
|
82
83
|
}
|
|
83
|
-
function normalizeBundleItems(bundleItems, preferPriceField = false) {
|
|
84
|
+
function normalizeBundleItems(bundleItems, preferPriceField = false, preferBundleSellingPrice = false) {
|
|
84
85
|
if (!Array.isArray(bundleItems)) return [];
|
|
85
86
|
return bundleItems.map(bundleItem => {
|
|
86
|
-
|
|
87
|
+
// Weighed manual prices distribute the bundle base and nested options separately.
|
|
88
|
+
// Its explicit selling amount already includes those options.
|
|
89
|
+
const unitSelling = preferPriceField && !preferBundleSellingPrice ? bundleItem.price ?? bundleItem.bundle_selling_price ?? bundleItem.custom_price ?? bundleItem.product_price ?? '0' : bundleItem.bundle_selling_price ?? bundleItem.price ?? bundleItem.custom_price ?? bundleItem.product_price ?? '0';
|
|
87
90
|
const unitStr = toPriceString(unitSelling, '0.00');
|
|
88
91
|
const num = toSafePositiveInt(bundleItem?.num ?? bundleItem?.quantity, 1);
|
|
89
92
|
const magnitudeSource = {
|
|
@@ -147,19 +150,25 @@ function transformBaseProductToOrderProduct(params) {
|
|
|
147
150
|
const productionCode = normalizeProductionCode(Object.prototype.hasOwnProperty.call(payload, 'production_code') ? payload.production_code : productVariantId > 0 ? matchedVariant?.production_code : origin?.production_code ?? sourceProduct?.production_code);
|
|
148
151
|
const hasPriceOverride = payload.price_override !== undefined && payload.price_override !== null && payload.price_override !== '';
|
|
149
152
|
// 手动改价后 payload.price 是分摊后的主商品售价,不能再作为券前 source。
|
|
150
|
-
//
|
|
153
|
+
// 称重商品使用改价前净重金额;其它商品从商品/variant 快照读取目录价。
|
|
154
|
+
// 售价仍由 line_total - bundle 推导。
|
|
151
155
|
const catalogSourcePrice = matchedVariant?.price ?? matchedVariant?.base_price ?? origin?.price ?? origin?.base_price ?? sourceProduct?.price ?? sourceProduct?.selling_price ?? sourceProduct?.base_price;
|
|
152
|
-
const
|
|
156
|
+
const weighedSourcePrice = (0, _weighedProduct.resolveWeighedSourcePrice)(payload.product_sku ?? origin.product_sku, payload._extend?.weighing ?? origin._extend?.weighing);
|
|
157
|
+
const sourceProductPrice = toPriceString(weighedSourcePrice ?? (hasPriceOverride ? catalogSourcePrice ?? payload.price ?? payload.selling_price : payload.price ?? payload.selling_price ?? catalogSourcePrice), '0.00');
|
|
153
158
|
const explicitLineTotal = payload.line_total ?? payload.total ?? payload._extend?.total;
|
|
154
159
|
const hasExplicitLineTotal = Number.isFinite(Number(explicitLineTotal));
|
|
155
160
|
const lineCompositeTotal = toPriceString(explicitLineTotal, sourceProductPrice);
|
|
156
|
-
const productOptionItem = (0, _utils.normalizeProductSkuOptions)(normalizeOptionItems(payload.product_sku?.option ?? payload.option ?? payload.options ?? payload.product_option_item));
|
|
157
|
-
const productBundle = normalizeBundleItems(payload.bundle ?? payload.product_bundle, hasPriceOverride);
|
|
161
|
+
const productOptionItem = (0, _utils.normalizeProductSkuOptions)(normalizeOptionItems(payload.product_sku?.option ?? payload.option ?? payload.options ?? payload.product_option_item, hasPriceOverride || weighedSourcePrice !== undefined));
|
|
162
|
+
const productBundle = normalizeBundleItems(payload.bundle ?? payload.product_bundle, hasPriceOverride, hasPriceOverride && weighedSourcePrice !== undefined);
|
|
158
163
|
// `payload.unique` 是业务侧商品/票务标识,可能在连续加同一商品时重复;
|
|
159
164
|
// 行级唯一值只接受显式协议字段,缺省交给 OrderModule 生成。
|
|
160
165
|
const uniqueIdentificationNumber = payload.unique_identification_number;
|
|
161
166
|
const resolvedQuantity = toSafePositiveInt(payload.quantity ?? payload.num, 1);
|
|
162
|
-
const originTotal = (0,
|
|
167
|
+
const originTotal = weighedSourcePrice !== undefined ? Number((0, _utils.composeLinePrice)({
|
|
168
|
+
mainPrice: Number(weighedSourcePrice) + (0, _utils.sumOptionUnitPrice)(productOptionItem).toNumber(),
|
|
169
|
+
bundle: hasPriceOverride ? (0, _weighedProduct.withOriginalBundleOptionPrices)(productBundle) : productBundle,
|
|
170
|
+
useOriginalBundle: true
|
|
171
|
+
})) : (0, _manualProductDiscount.resolveManualDiscountOriginTotal)({
|
|
163
172
|
originTotal: payload.origin_total,
|
|
164
173
|
extendOriginTotal: payload._extend?.origin_total,
|
|
165
174
|
originExtendOriginTotal: origin?._extend?.origin_total,
|
|
@@ -260,6 +269,12 @@ function transformBaseProductToOrderProduct(params) {
|
|
|
260
269
|
product_cover: firstNonBlank(matchedVariant?.cover, sourceProduct?.cover),
|
|
261
270
|
_origin: {
|
|
262
271
|
...(sourceProduct || {}),
|
|
272
|
+
...(weighedSourcePrice !== undefined && hasPriceOverride ? {
|
|
273
|
+
_extend: {
|
|
274
|
+
...sourceProduct?._extend,
|
|
275
|
+
origin_total: originTotal
|
|
276
|
+
}
|
|
277
|
+
} : {}),
|
|
263
278
|
callbackData: payload
|
|
264
279
|
}
|
|
265
280
|
};
|
|
@@ -8,6 +8,7 @@ exports.createEmptySummary = createEmptySummary;
|
|
|
8
8
|
exports.getSafeProductNum = getSafeProductNum;
|
|
9
9
|
exports.isSkuOnlyDeleteIdentity = isSkuOnlyDeleteIdentity;
|
|
10
10
|
exports.normalizeOrderProduct = normalizeOrderProduct;
|
|
11
|
+
var _weighedProduct = require("../../modules/Order/utils/weighedProduct");
|
|
11
12
|
var _decimal = _interopRequireDefault(require("decimal.js"));
|
|
12
13
|
var _utils = require("../../modules/Order/utils");
|
|
13
14
|
var _manualProductDiscount = require("../../modules/Order/utils/manualProductDiscount");
|
|
@@ -237,7 +238,7 @@ function normalizeOrderProduct(product) {
|
|
|
237
238
|
});
|
|
238
239
|
const composedOriginalPrice = (0, _utils.composeLinePrice)({
|
|
239
240
|
mainPrice: mainOriginalStr,
|
|
240
|
-
bundle: normalizedBundle,
|
|
241
|
+
bundle: Number(productSku.open_sold_weight) === 1 && (0, _manualProductDiscount.hasManualProductDiscountFlag)(metadata) ? (0, _weighedProduct.withOriginalBundleOptionPrices)(normalizedBundle) : normalizedBundle,
|
|
241
242
|
useOriginalBundle: true
|
|
242
243
|
});
|
|
243
244
|
const finalOriginalPrice = (0, _utils.resolveManualOverrideLineOriginalPrice)({
|
|
@@ -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 |
|
|
329
|
+
weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
|
|
330
330
|
}[]>;
|
|
331
331
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
332
332
|
private getScheduleDataByIds;
|
|
@@ -34,6 +34,7 @@ exports.toNonNegativeInt = toNonNegativeInt;
|
|
|
34
34
|
exports.toNonNegativeNumber = toNonNegativeNumber;
|
|
35
35
|
exports.toPositiveString = toPositiveString;
|
|
36
36
|
exports.toPriceString = toPriceString;
|
|
37
|
+
var _weighedProduct = require("../../modules/Order/utils/weighedProduct");
|
|
37
38
|
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
38
39
|
var _decimal = _interopRequireDefault(require("decimal.js"));
|
|
39
40
|
var _utils = require("../../modules/Order/utils");
|
|
@@ -612,7 +613,7 @@ function normalizeOrderProduct(product) {
|
|
|
612
613
|
});
|
|
613
614
|
const composedOriginalPrice = (0, _utils.composeLinePrice)({
|
|
614
615
|
mainPrice: mainOriginalStr,
|
|
615
|
-
bundle: normalizedBundle,
|
|
616
|
+
bundle: Number(productSku.open_sold_weight) === 1 && (0, _manualProductDiscount.hasManualProductDiscountFlag)(metadata) ? (0, _weighedProduct.withOriginalBundleOptionPrices)(normalizedBundle) : normalizedBundle,
|
|
616
617
|
useOriginalBundle: true
|
|
617
618
|
});
|
|
618
619
|
const finalOriginalPrice = (0, _utils.resolveManualOverrideLineOriginalPrice)({
|