@pisell/pisellos 2.3.127 → 2.3.129
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 +2 -1
- package/dist/modules/Order/index.js +117 -58
- 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/BookingTicket/index.d.ts +1 -1
- package/dist/solution/ScanOrder/utils.js +3 -2
- package/lib/model/strategy/adapter/promotion/index.js +1 -46
- package/lib/modules/Order/index.d.ts +2 -1
- package/lib/modules/Order/index.js +70 -10
- 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/BookingTicket/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 _availability = require("../Discount/availability");
|
|
13
14
|
var _osPrivatePayload = require("../../utils/os-private-payload");
|
|
@@ -803,6 +804,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
803
804
|
orderTotalAmount: Number(this.store.summary?.total_amount || 0)
|
|
804
805
|
}, {
|
|
805
806
|
reapplyBookingDiscountProductUids: options?.reapplyBookingDiscountProductUids,
|
|
807
|
+
reapplyWeighedDiscountProductUids: options?.reapplyWeighedDiscountProductUids,
|
|
806
808
|
preferredEntitlementPassIds: options?.preferredEntitlementPassIds
|
|
807
809
|
});
|
|
808
810
|
if (result?.productList) {
|
|
@@ -3857,7 +3859,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
3857
3859
|
};
|
|
3858
3860
|
});
|
|
3859
3861
|
}
|
|
3860
|
-
applyOrderProductUpdateToTempOrder(tempOrder, params) {
|
|
3862
|
+
applyOrderProductUpdateToTempOrder(tempOrder, params, reapplyWeighedDiscountProductUids) {
|
|
3861
3863
|
const {
|
|
3862
3864
|
product_id,
|
|
3863
3865
|
product_variant_id,
|
|
@@ -3930,7 +3932,8 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
3930
3932
|
const previousLineFingerprint = (0, _utils3.buildProductLineFingerprint)((0, _utils.getProductSkuOptions)(targetProduct), targetProduct.product_bundle);
|
|
3931
3933
|
const nextLineFingerprint = (0, _utils3.buildProductLineFingerprint)((0, _utils.getProductSkuOptions)(nextProduct), nextProduct.product_bundle);
|
|
3932
3934
|
const callerChangesVariant = Number(product_variant_id || 0) !== Number(targetProduct.product_variant_id || 0);
|
|
3933
|
-
const
|
|
3935
|
+
const callerChangesWeighing = (0, _weighedProduct.getWeighedProductPriceFingerprint)(targetProduct.product_sku) !== (0, _weighedProduct.getWeighedProductPriceFingerprint)(nextProduct.product_sku);
|
|
3936
|
+
const callerChangesLineConfiguration = callerChangesVariant || callerChangesWeighing || previousLineFingerprint !== nextLineFingerprint;
|
|
3934
3937
|
const isPersistedOrderLine = targetProduct.order_detail_id !== undefined && targetProduct.order_detail_id !== null;
|
|
3935
3938
|
const callerChangesDiscountList = Array.isArray(updates?.discount_list) && updates.discount_list.length > 0 && !isSameDiscountList(updates.discount_list, targetProduct.discount_list);
|
|
3936
3939
|
const callerUpdatesManualPrice = updates?.metadata?.price_override !== undefined || updates?.metadata?.is_manual_discount !== undefined || updates?.metadata?.product_discount_reason !== undefined || callerChangesDiscountList;
|
|
@@ -3946,6 +3949,23 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
3946
3949
|
};
|
|
3947
3950
|
return hasChangedPrice(updates.selling_price, targetProduct.selling_price) || hasChangedPrice(updates.original_price, targetProduct.original_price);
|
|
3948
3951
|
})();
|
|
3952
|
+
const weighedSourcePrice = callerChangesWeighing ? (0, _weighedProduct.resolveWeighedSourcePrice)(nextProduct.product_sku) : undefined;
|
|
3953
|
+
const hasResolvedWeighedPrice = weighedSourcePrice !== undefined;
|
|
3954
|
+
if (hasResolvedWeighedPrice && !callerUpdatesSourcePrice) {
|
|
3955
|
+
const nextMainOriginal = new _decimal.default(weighedSourcePrice).plus((0, _utils.sumOptionUnitPrice)((0, _utils.getProductSkuOptions)(nextProduct)));
|
|
3956
|
+
const previousMainOriginal = new _decimal.default(targetProduct.metadata?.main_product_original_price ?? targetProduct.original_price ?? 0);
|
|
3957
|
+
const previousMainSelling = new _decimal.default(targetProduct.metadata?.main_product_selling_price ?? targetProduct.selling_price ?? 0);
|
|
3958
|
+
// A manual final price remains fixed; other legacy discounts keep their amount
|
|
3959
|
+
// until Rules reapplies the currently selected wallet discount below.
|
|
3960
|
+
const nextMainSelling = isManualProductDiscountProduct(nextProduct) ? previousMainSelling : nextMainOriginal.minus(previousMainOriginal.minus(previousMainSelling));
|
|
3961
|
+
nextProduct.metadata = {
|
|
3962
|
+
...nextProduct.metadata,
|
|
3963
|
+
source_product_price: weighedSourcePrice,
|
|
3964
|
+
main_product_original_price: callerUpdatesMainOriginalPrice ? nextProduct.metadata.main_product_original_price : nextMainOriginal.toFixed(2),
|
|
3965
|
+
main_product_selling_price: callerUpdatesMainSellingPrice ? nextProduct.metadata.main_product_selling_price : _decimal.default.max(0, nextMainSelling).toFixed(2),
|
|
3966
|
+
price_schema_version: 2
|
|
3967
|
+
};
|
|
3968
|
+
}
|
|
3949
3969
|
if (isPersistedOrderLine && !callerChangesLineConfiguration && !callerUpdatesManualPrice && !callerAllowsBookingReprice) {
|
|
3950
3970
|
nextProduct.selling_price = targetProduct.selling_price;
|
|
3951
3971
|
nextProduct.original_price = targetProduct.original_price;
|
|
@@ -3962,17 +3982,17 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
3962
3982
|
// 新配置只传了 source 时,不能把未传的 main_product_* 从旧行继承下来。
|
|
3963
3983
|
// 以新 source + 新 option 重建券前价;券后价未显式提供时保留旧主商品折扣额。
|
|
3964
3984
|
const previousMainOriginal = new _decimal.default(Number(targetProduct.metadata?.main_product_original_price) || 0);
|
|
3965
|
-
const previousMainSelling = new _decimal.default(Number(targetProduct.metadata?.main_product_selling_price
|
|
3985
|
+
const previousMainSelling = new _decimal.default(Number(targetProduct.metadata?.main_product_selling_price ?? previousMainOriginal.toNumber()));
|
|
3966
3986
|
const preservedDiscount = previousMainOriginal.minus(previousMainSelling);
|
|
3967
3987
|
const nextMainOriginal = new _decimal.default(Number(updates.metadata.source_product_price) || 0).plus((0, _utils.sumOptionUnitPrice)((0, _utils.getProductSkuOptions)(nextProduct)));
|
|
3968
3988
|
nextProduct.metadata = {
|
|
3969
3989
|
...(nextProduct.metadata || {}),
|
|
3970
3990
|
source_product_price: String(updates.metadata.source_product_price),
|
|
3971
3991
|
main_product_original_price: callerUpdatesMainOriginalPrice ? String(updates.metadata.main_product_original_price) : nextMainOriginal.toDecimalPlaces(2).toFixed(2),
|
|
3972
|
-
main_product_selling_price: callerUpdatesMainSellingPrice ? String(updates.metadata.main_product_selling_price) : nextMainOriginal.minus(preservedDiscount).toDecimalPlaces(2).toFixed(2),
|
|
3992
|
+
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),
|
|
3973
3993
|
price_schema_version: 2
|
|
3974
3994
|
};
|
|
3975
|
-
} else if (callerChangesVariant && !callerUpdatesTopPrice && !callerUpdatesMainMeta) {
|
|
3995
|
+
} else if (callerChangesVariant && !hasResolvedWeighedPrice && !callerUpdatesTopPrice && !callerUpdatesMainMeta) {
|
|
3976
3996
|
// variant 已变化但 caller 没有显式报价时,旧 v2 metadata 不能继续充当权威价格源。
|
|
3977
3997
|
// 清理后由 normalize 优先读取 metadata.origin.variant 中新 variant 的目录价;
|
|
3978
3998
|
// 顶层 original/selling 的旧差额仍会作为 legacy discount 迁移到新价格。
|
|
@@ -3984,7 +4004,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
3984
4004
|
delete nextProduct.metadata.main_product_selling_price;
|
|
3985
4005
|
delete nextProduct.metadata.main_product_original_price;
|
|
3986
4006
|
delete nextProduct.metadata.price_schema_version;
|
|
3987
|
-
} else if (callerChangesLineConfiguration && !callerUpdatesTopPrice && !callerUpdatesMainMeta) {
|
|
4007
|
+
} else if (callerChangesLineConfiguration && !hasResolvedWeighedPrice && !callerUpdatesTopPrice && !callerUpdatesMainMeta) {
|
|
3988
4008
|
// 仅 option / bundle 变化时,保留历史 source 和主商品折扣金额,
|
|
3989
4009
|
// 但必须让 original 与 selling 一起随新的 option 金额移动。
|
|
3990
4010
|
const previousOptionSum = (0, _utils.sumOptionUnitPrice)((0, _utils.getProductSkuOptions)(targetProduct));
|
|
@@ -4001,7 +4021,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
4001
4021
|
main_product_selling_price: nextMainOriginal.minus(preservedDiscount).toDecimalPlaces(2).toFixed(2),
|
|
4002
4022
|
price_schema_version: 2
|
|
4003
4023
|
};
|
|
4004
|
-
} else if (callerUpdatesTopPrice && !callerUpdatesMainMeta) {
|
|
4024
|
+
} else if (callerUpdatesTopPrice && !callerUpdatesMainMeta && !hasResolvedWeighedPrice) {
|
|
4005
4025
|
const existedMeta = nextProduct.metadata || {};
|
|
4006
4026
|
nextProduct.metadata = {
|
|
4007
4027
|
...existedMeta
|
|
@@ -4011,6 +4031,37 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
4011
4031
|
delete nextProduct.metadata.main_product_original_price;
|
|
4012
4032
|
delete nextProduct.metadata.price_schema_version;
|
|
4013
4033
|
}
|
|
4034
|
+
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)) {
|
|
4035
|
+
const originalPrice = (0, _utils.composeLinePrice)({
|
|
4036
|
+
mainPrice: nextProduct.metadata.main_product_original_price,
|
|
4037
|
+
bundle: (0, _weighedProduct.withOriginalBundleOptionPrices)(nextProduct.product_bundle),
|
|
4038
|
+
useOriginalBundle: true
|
|
4039
|
+
});
|
|
4040
|
+
const sellingPrice = (0, _utils.composeLinePrice)({
|
|
4041
|
+
mainPrice: nextProduct.metadata.main_product_selling_price,
|
|
4042
|
+
bundle: nextProduct.product_bundle
|
|
4043
|
+
});
|
|
4044
|
+
const previousManualDiscount = (0, _manualProductDiscount.findManualProductDiscountItem)(nextProduct.discount_list);
|
|
4045
|
+
nextProduct.original_price = originalPrice;
|
|
4046
|
+
nextProduct.metadata = {
|
|
4047
|
+
...nextProduct.metadata,
|
|
4048
|
+
origin: {
|
|
4049
|
+
...nextProduct.metadata.origin,
|
|
4050
|
+
_extend: {
|
|
4051
|
+
...nextProduct.metadata.origin?._extend,
|
|
4052
|
+
origin_total: Number(originalPrice)
|
|
4053
|
+
}
|
|
4054
|
+
}
|
|
4055
|
+
};
|
|
4056
|
+
nextProduct.discount_list = (0, _manualProductDiscount.mergeManualProductDiscountIntoList)(nextProduct.discount_list, (0, _manualProductDiscount.buildManualProductDiscountItem)({
|
|
4057
|
+
originTotal: Number(originalPrice),
|
|
4058
|
+
sellingTotal: Number(sellingPrice),
|
|
4059
|
+
quantity: nextProduct.num,
|
|
4060
|
+
message: previousManualDiscount?.discount.message,
|
|
4061
|
+
discountway: previousManualDiscount?.discount.discountway,
|
|
4062
|
+
discount_per: previousManualDiscount?.discount.discount_per
|
|
4063
|
+
}));
|
|
4064
|
+
}
|
|
4014
4065
|
// normalizeOrderProduct 幂等:v2 metadata 存在 → 保留 main_product_* 折扣重算 composite;
|
|
4015
4066
|
// 否则 → 把顶层 selling_price 视作 source,派生 main_product_* 并写 price_schema_version: 2。
|
|
4016
4067
|
let normalizedProduct = this.normalizeVirtualSettlementProductIfEnabled((0, _utils.mergeOrderProductDisplayFields)(nextProduct, (0, _utils3.normalizeOrderProduct)(nextProduct)));
|
|
@@ -4048,6 +4099,10 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
4048
4099
|
};
|
|
4049
4100
|
tempOrder.bookings = [...(tempOrder.bookings || []), linked.booking];
|
|
4050
4101
|
}
|
|
4102
|
+
if (callerChangesWeighing && !isManualProductDiscountProduct(normalizedProduct)) {
|
|
4103
|
+
const uid = normalizedProduct.metadata?.unique_identification_number;
|
|
4104
|
+
if (uid) reapplyWeighedDiscountProductUids?.push(String(uid));
|
|
4105
|
+
}
|
|
4051
4106
|
tempOrder.products[productIndex] = normalizedProduct;
|
|
4052
4107
|
this.syncTempOrderHolderFromBookings(tempOrder);
|
|
4053
4108
|
this.captureProductRuntime(tempOrder, updates, tempOrder.products[productIndex], tempOrder.products[productIndex].metadata?.unique_identification_number);
|
|
@@ -4055,9 +4110,11 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
4055
4110
|
}
|
|
4056
4111
|
async updateOrderProduct(params) {
|
|
4057
4112
|
const tempOrder = this.ensureTempOrder();
|
|
4058
|
-
const
|
|
4113
|
+
const reapplyWeighedDiscountProductUids = [];
|
|
4114
|
+
const updatedProductUid = this.applyOrderProductUpdateToTempOrder(tempOrder, params, reapplyWeighedDiscountProductUids);
|
|
4059
4115
|
const promotionPayload = await this.evaluatePromotion();
|
|
4060
4116
|
this.applyDiscount({
|
|
4117
|
+
reapplyWeighedDiscountProductUids,
|
|
4061
4118
|
reapplyBookingDiscountProductUids: params.allow_booking_discount_reapply && updatedProductUid ? [String(updatedProductUid)] : undefined
|
|
4062
4119
|
});
|
|
4063
4120
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
@@ -4076,8 +4133,9 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
4076
4133
|
if (!paramsList.length) {
|
|
4077
4134
|
return tempOrder.products;
|
|
4078
4135
|
}
|
|
4136
|
+
const reapplyWeighedDiscountProductUids = [];
|
|
4079
4137
|
const reapplyBookingDiscountProductUids = paramsList.reduce((acc, params) => {
|
|
4080
|
-
const updatedProductUid = this.applyOrderProductUpdateToTempOrder(tempOrder, params);
|
|
4138
|
+
const updatedProductUid = this.applyOrderProductUpdateToTempOrder(tempOrder, params, reapplyWeighedDiscountProductUids);
|
|
4081
4139
|
// 批量改预约时间时,延迟到最后一次折扣计算里统一恢复已选预约折扣卡。
|
|
4082
4140
|
if (params.allow_booking_discount_reapply && updatedProductUid) {
|
|
4083
4141
|
acc.push(String(updatedProductUid));
|
|
@@ -4085,6 +4143,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
4085
4143
|
return acc;
|
|
4086
4144
|
}, []);
|
|
4087
4145
|
await this.finalizeAfterProductsMutation(tempOrder, {
|
|
4146
|
+
reapplyWeighedDiscountProductUids,
|
|
4088
4147
|
reapplyBookingDiscountProductUids: reapplyBookingDiscountProductUids.length ? reapplyBookingDiscountProductUids : undefined
|
|
4089
4148
|
});
|
|
4090
4149
|
this.logInfo('updateOrderProduct success', {
|
|
@@ -4217,7 +4276,8 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
4217
4276
|
this.syncTempOrderHolderFromBookings(tempOrder);
|
|
4218
4277
|
const promotionPayload = await this.evaluatePromotion();
|
|
4219
4278
|
this.applyDiscount({
|
|
4220
|
-
reapplyBookingDiscountProductUids: options?.reapplyBookingDiscountProductUids
|
|
4279
|
+
reapplyBookingDiscountProductUids: options?.reapplyBookingDiscountProductUids,
|
|
4280
|
+
reapplyWeighedDiscountProductUids: options?.reapplyWeighedDiscountProductUids
|
|
4221
4281
|
});
|
|
4222
4282
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
4223
4283
|
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
|
+
}
|
|
@@ -131,11 +131,12 @@ Object.defineProperty(exports, "syncManualProductDiscountProductNum", {
|
|
|
131
131
|
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
132
132
|
var _customParseFormat = _interopRequireDefault(require("dayjs/plugin/customParseFormat"));
|
|
133
133
|
var _decimal = _interopRequireDefault(require("decimal.js"));
|
|
134
|
+
var _weighedProduct = require("./utils/weighedProduct");
|
|
135
|
+
var _manualProductDiscount = require("./utils/manualProductDiscount");
|
|
134
136
|
var _utils = require("../Holder/utils");
|
|
135
137
|
var _utils2 = require("../../solution/ScanOrder/utils");
|
|
136
138
|
var _orderCollectionIdentity = require("./utils/orderCollectionIdentity");
|
|
137
139
|
var _salesNotes = require("./salesNotes");
|
|
138
|
-
var _manualProductDiscount = require("./utils/manualProductDiscount");
|
|
139
140
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
140
141
|
_dayjs.default.extend(_customParseFormat.default);
|
|
141
142
|
const POINT_CARD_SNAPSHOT_TAG = 'point_card';
|
|
@@ -956,7 +957,7 @@ function createDefaultOrderRulesHooks(getBookings) {
|
|
|
956
957
|
});
|
|
957
958
|
const composedOriginalPrice = composeLinePrice({
|
|
958
959
|
mainPrice: nextMainOriginalPrice,
|
|
959
|
-
bundle: nextBundle,
|
|
960
|
+
bundle: Number(product.product_sku?.open_sold_weight) === 1 && (0, _manualProductDiscount.hasManualProductDiscountFlag)(metadataAny) ? (0, _weighedProduct.withOriginalBundleOptionPrices)(nextBundle) : nextBundle,
|
|
960
961
|
useOriginalBundle: true
|
|
961
962
|
});
|
|
962
963
|
const finalOriginalPrice = resolveManualOverrideLineOriginalPrice({
|
|
@@ -225,7 +225,8 @@ class RulesModule extends _BaseModule.BaseModule {
|
|
|
225
225
|
// 识别出来是不是在编辑的界面里又新增了商品
|
|
226
226
|
// 这种情况下,如果有可用的优惠券,也会自动勾选上
|
|
227
227
|
const isEditModeAddNewProduct = productList.find(n => n.booking_id) && productList.find(n => !n.booking_id);
|
|
228
|
-
const
|
|
228
|
+
const reapplyWeighedDiscountProductUids = new Set((options?.reapplyWeighedDiscountProductUids || []).map(String));
|
|
229
|
+
const reapplyBookingDiscountProductUids = new Set([...(options?.reapplyBookingDiscountProductUids || []), ...reapplyWeighedDiscountProductUids].filter(uid => uid !== undefined && uid !== null && uid !== '').map(String));
|
|
229
230
|
const getOriginProductUid = originProduct => {
|
|
230
231
|
const uid = originProduct?.metadata?.unique_identification_number ?? originProduct?.unique_identification_number;
|
|
231
232
|
if (uid === undefined || uid === null || uid === '') return undefined;
|
|
@@ -1079,7 +1080,8 @@ class RulesModule extends _BaseModule.BaseModule {
|
|
|
1079
1080
|
});
|
|
1080
1081
|
|
|
1081
1082
|
// 已持久化且已有钱包券/折扣卡的商品行跳过,保留后端历史折扣结果。
|
|
1082
|
-
|
|
1083
|
+
const isReweighedProduct = reapplyWeighedDiscountProductUids.has(getOriginProductUid(originProduct) || '');
|
|
1084
|
+
if (isPersistedProduct && hasExistingWalletDiscount && !isReweighedProduct) {
|
|
1083
1085
|
if (flatItem.type === 'main') {
|
|
1084
1086
|
processedProductsMap.set(product._id, [originProduct]);
|
|
1085
1087
|
}
|
|
@@ -35,6 +35,8 @@ export interface RulesCalcDiscountOptions {
|
|
|
35
35
|
preserveEntitlementSelection?: boolean;
|
|
36
36
|
/** Change time 重报价目标行:允许已选编辑态折扣卡重新应用到这些 booking 商品。 */
|
|
37
37
|
reapplyBookingDiscountProductUids?: string[];
|
|
38
|
+
/** Reweighed order lines only: reapply selected wallet discounts against their new amount. */
|
|
39
|
+
reapplyWeighedDiscountProductUids?: string[];
|
|
38
40
|
}
|
|
39
41
|
export interface RulesModuleAPI {
|
|
40
42
|
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';
|
|
@@ -451,7 +451,7 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
451
451
|
private findCashPaymentMethod;
|
|
452
452
|
private getPendingWalletPaymentAmount;
|
|
453
453
|
/** 读取现金 action 所需的支付方式、待付金额和快捷金额。 */
|
|
454
|
-
getCashPaymentConfig(): Promise<BaseSalesCashPaymentConfig>;
|
|
454
|
+
getCashPaymentConfig(options?: BaseSalesCashPaymentOptions): Promise<BaseSalesCashPaymentConfig>;
|
|
455
455
|
/**
|
|
456
456
|
* 确认足额覆盖订单的 pending Wallet 支付并提交订单。
|
|
457
457
|
*
|
|
@@ -3356,10 +3356,14 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
3356
3356
|
getPaymentMethods() {
|
|
3357
3357
|
return [...this.paymentMethodsCache];
|
|
3358
3358
|
}
|
|
3359
|
-
findCashPaymentMethod(paymentMethods) {
|
|
3359
|
+
findCashPaymentMethod(paymentMethods, paymentMethodId) {
|
|
3360
3360
|
return paymentMethods.find(method => {
|
|
3361
|
+
if (method?.enabled === false || method?.enable === false) return false;
|
|
3361
3362
|
const identifiers = [method?.code, method?.type, method?.tag].map(value => String(value || '').toUpperCase());
|
|
3362
|
-
|
|
3363
|
+
const isDefaultCash = identifiers.includes('CASHMANUAL');
|
|
3364
|
+
if (paymentMethodId === undefined) return isDefaultCash;
|
|
3365
|
+
const isCustomCash = String(method?.type || '').trim().toLowerCase() === 'custom' && [method?.name, method?.nameEn].some(name => typeof name === 'string' && /现金|現金|cash/i.test(name));
|
|
3366
|
+
return String(method?.id) === String(paymentMethodId) && (isDefaultCash || isCustomCash);
|
|
3363
3367
|
});
|
|
3364
3368
|
}
|
|
3365
3369
|
getPendingWalletPaymentAmount(payments = this.store.order?.getOrderPayments?.() || []) {
|
|
@@ -3376,13 +3380,16 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
3376
3380
|
}
|
|
3377
3381
|
|
|
3378
3382
|
/** 读取现金 action 所需的支付方式、待付金额和快捷金额。 */
|
|
3379
|
-
async getCashPaymentConfig() {
|
|
3383
|
+
async getCashPaymentConfig(options = {}) {
|
|
3380
3384
|
if (!this.store.payment) throw new Error('payment 模块未初始化');
|
|
3381
3385
|
let paymentMethods = this.getPaymentMethods();
|
|
3382
|
-
let paymentMethod = this.findCashPaymentMethod(paymentMethods);
|
|
3386
|
+
let paymentMethod = this.findCashPaymentMethod(paymentMethods, options.paymentMethodId);
|
|
3383
3387
|
if (!paymentMethod) {
|
|
3384
3388
|
paymentMethods = await this.getPaymentMethodsAsync();
|
|
3385
|
-
paymentMethod = this.findCashPaymentMethod(paymentMethods);
|
|
3389
|
+
paymentMethod = this.findCashPaymentMethod(paymentMethods, options.paymentMethodId);
|
|
3390
|
+
}
|
|
3391
|
+
if (!paymentMethod && options.paymentMethodId !== undefined) {
|
|
3392
|
+
throw new Error(`未找到可用的现金支付方式:${options.paymentMethodId}`);
|
|
3386
3393
|
}
|
|
3387
3394
|
const amountSnapshot = this.store.order?.getOrderAmountSnapshot?.();
|
|
3388
3395
|
const pendingWalletAmount = this.getPendingWalletPaymentAmount();
|
|
@@ -3480,7 +3487,9 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
3480
3487
|
if (!Number.isFinite(amount) || amount <= 0) {
|
|
3481
3488
|
throw new Error('现金支付金额必须大于 0');
|
|
3482
3489
|
}
|
|
3483
|
-
const config = await this.getCashPaymentConfig()
|
|
3490
|
+
const config = params.paymentMethodId === undefined ? await this.getCashPaymentConfig() : await this.getCashPaymentConfig({
|
|
3491
|
+
paymentMethodId: params.paymentMethodId
|
|
3492
|
+
});
|
|
3484
3493
|
const paymentMethod = config.paymentMethod;
|
|
3485
3494
|
if (!paymentMethod) throw new Error('未找到可用的 CASHMANUAL 支付方式');
|
|
3486
3495
|
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 |
|
|
329
|
+
weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
|
|
330
330
|
}[]>;
|
|
331
331
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
332
332
|
private getScheduleDataByIds;
|
|
@@ -346,7 +346,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
346
346
|
* 获取当前的客户搜索条件
|
|
347
347
|
* @returns 当前搜索条件
|
|
348
348
|
*/
|
|
349
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
349
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
|
|
350
350
|
/**
|
|
351
351
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
352
352
|
* @returns 客户状态
|
|
@@ -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)({
|