@pisell/pisellos 2.2.272 → 2.2.274
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/core/index.d.ts +0 -2
- package/dist/core/index.js +0 -7
- package/dist/model/strategy/adapter/promotion/adapter.d.ts +0 -4
- package/dist/model/strategy/adapter/promotion/adapter.js +0 -23
- package/dist/model/strategy/adapter/promotion/evaluator.d.ts +0 -17
- package/dist/model/strategy/adapter/promotion/evaluator.js +6 -279
- package/dist/model/strategy/adapter/promotion/examples.d.ts +0 -86
- package/dist/model/strategy/adapter/promotion/examples.js +0 -99
- package/dist/model/strategy/adapter/promotion/index.d.ts +1 -1
- package/dist/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/model/strategy/adapter/promotion/type.d.ts +2 -90
- package/dist/model/strategy/adapter/promotion/type.js +0 -45
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +16 -12
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +6 -3
- package/dist/modules/OpenData/index.d.ts +0 -2
- package/dist/modules/OpenData/index.js +0 -8
- package/dist/modules/Order/index.d.ts +12 -31
- package/dist/modules/Order/index.js +562 -778
- package/dist/modules/Order/types.d.ts +22 -36
- package/dist/modules/Order/types.js +11 -0
- package/dist/modules/Order/utils/orderCollectionIdentity.js +2 -7
- package/dist/modules/Order/utils.js +6 -10
- package/dist/modules/Payment/index.d.ts +0 -2
- package/dist/modules/Payment/index.js +50 -79
- package/dist/modules/Payment/types.d.ts +27 -29
- package/dist/modules/Payment/types.js +3 -5
- package/dist/modules/Rules/index.d.ts +0 -1
- package/dist/modules/Rules/index.js +39 -55
- package/dist/modules/SalesSummary/utils.js +7 -1
- package/dist/server/index.d.ts +0 -16
- package/dist/server/index.js +1036 -1933
- package/dist/server/modules/order/index.d.ts +4 -49
- package/dist/server/modules/order/index.js +695 -1574
- package/dist/server/modules/order/types.d.ts +3 -11
- package/dist/server/modules/order/types.js +1 -1
- package/dist/solution/BaseSales/index.d.ts +25 -59
- package/dist/solution/BaseSales/index.js +490 -767
- package/dist/solution/BaseSales/utils/cartPromotion.d.ts +1 -3
- package/dist/solution/BaseSales/utils/cartPromotion.js +36 -93
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -6
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +5 -21
- package/dist/solution/BookingTicket/index.js +49 -126
- package/dist/solution/BookingTicket/types.d.ts +3 -0
- package/dist/solution/BookingTicket/utils/addProductDecision.js +6 -0
- package/dist/solution/BookingTicket/utils/cartView.js +44 -32
- package/dist/solution/BookingTicket/utils/weighingProductSku.d.ts +5 -0
- package/dist/solution/BookingTicket/utils/weighingProductSku.js +45 -0
- package/dist/solution/Sales/index.d.ts +0 -1
- package/dist/solution/Sales/index.js +2 -10
- package/dist/solution/ScanOrder/index.js +20 -31
- package/dist/solution/VenueBooking/index.js +19 -30
- package/dist/types/index.d.ts +0 -1
- package/lib/core/index.d.ts +0 -2
- package/lib/core/index.js +0 -4
- package/lib/model/strategy/adapter/promotion/adapter.d.ts +0 -4
- package/lib/model/strategy/adapter/promotion/adapter.js +0 -20
- package/lib/model/strategy/adapter/promotion/evaluator.d.ts +0 -17
- package/lib/model/strategy/adapter/promotion/evaluator.js +0 -235
- package/lib/model/strategy/adapter/promotion/examples.d.ts +0 -86
- package/lib/model/strategy/adapter/promotion/examples.js +0 -91
- package/lib/model/strategy/adapter/promotion/index.d.ts +1 -1
- package/lib/model/strategy/adapter/promotion/index.js +49 -0
- package/lib/model/strategy/adapter/promotion/type.d.ts +2 -90
- package/lib/model/strategy/adapter/promotion/type.js +0 -2
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +5 -2
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +2 -1
- package/lib/modules/OpenData/index.d.ts +0 -2
- package/lib/modules/OpenData/index.js +0 -5
- package/lib/modules/Order/index.d.ts +12 -31
- package/lib/modules/Order/index.js +142 -201
- package/lib/modules/Order/types.d.ts +22 -36
- package/lib/modules/Order/utils/orderCollectionIdentity.js +0 -3
- package/lib/modules/Order/utils.js +4 -11
- package/lib/modules/Payment/index.d.ts +0 -2
- package/lib/modules/Payment/index.js +13 -34
- package/lib/modules/Payment/types.d.ts +27 -29
- package/lib/modules/Payment/types.js +3 -3
- package/lib/modules/Rules/index.d.ts +0 -1
- package/lib/modules/Rules/index.js +22 -41
- package/lib/modules/SalesSummary/utils.js +5 -1
- package/lib/server/index.d.ts +0 -16
- package/lib/server/index.js +18 -670
- package/lib/server/modules/order/index.d.ts +4 -49
- package/lib/server/modules/order/index.js +66 -657
- package/lib/server/modules/order/types.d.ts +3 -11
- package/lib/solution/BaseSales/index.d.ts +25 -59
- package/lib/solution/BaseSales/index.js +79 -246
- package/lib/solution/BaseSales/utils/cartPromotion.d.ts +1 -3
- package/lib/solution/BaseSales/utils/cartPromotion.js +17 -65
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -6
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +5 -21
- package/lib/solution/BookingTicket/index.js +8 -59
- package/lib/solution/BookingTicket/types.d.ts +3 -0
- package/lib/solution/BookingTicket/utils/addProductDecision.js +4 -0
- package/lib/solution/BookingTicket/utils/cartView.js +43 -30
- package/lib/solution/BookingTicket/utils/weighingProductSku.d.ts +5 -0
- package/lib/solution/BookingTicket/utils/weighingProductSku.js +63 -0
- package/lib/solution/Sales/index.d.ts +0 -1
- package/lib/solution/Sales/index.js +3 -5
- package/lib/solution/ScanOrder/index.js +0 -8
- package/lib/solution/VenueBooking/index.js +0 -8
- package/lib/types/index.d.ts +0 -1
- package/package.json +1 -1
- package/dist/modules/Order/payment-utils.d.ts +0 -26
- package/dist/modules/Order/payment-utils.js +0 -225
- package/dist/utils/payment-number.d.ts +0 -9
- package/dist/utils/payment-number.js +0 -69
- package/lib/modules/Order/payment-utils.d.ts +0 -26
- package/lib/modules/Order/payment-utils.js +0 -224
- package/lib/utils/payment-number.d.ts +0 -9
- package/lib/utils/payment-number.js +0 -64
|
@@ -40,11 +40,11 @@ export declare enum RoundingRule {
|
|
|
40
40
|
/** 标准舍入(中点向上) */
|
|
41
41
|
Standard = "standard_rounding",
|
|
42
42
|
/** 标准舍入(中点向下) */
|
|
43
|
-
StandardDown = "
|
|
43
|
+
StandardDown = "standard_rounding_midpoint_down",
|
|
44
44
|
/** 总是向上舍入 */
|
|
45
|
-
AlwaysUp = "
|
|
45
|
+
AlwaysUp = "round_up",
|
|
46
46
|
/** 总是向下舍入 */
|
|
47
|
-
AlwaysDown = "
|
|
47
|
+
AlwaysDown = "round_down"
|
|
48
48
|
}
|
|
49
49
|
/**
|
|
50
50
|
* 舍入结果
|
|
@@ -87,30 +87,12 @@ export interface PaymentMethod {
|
|
|
87
87
|
/** 其他配置信息 */
|
|
88
88
|
[key: string]: any;
|
|
89
89
|
}
|
|
90
|
-
/** 支付项扩展元数据 */
|
|
91
|
-
export interface PaymentItemMetadata {
|
|
92
|
-
/** 钱箱 ID */
|
|
93
|
-
shop_wallet_pass_id?: string;
|
|
94
|
-
/** 三方支付交易流水号 */
|
|
95
|
-
unique_payment_number?: string;
|
|
96
|
-
/** 刷卡机设备快照;PaymentModule 不解析内部字段 */
|
|
97
|
-
card_reader_snapshot?: Record<string, unknown>;
|
|
98
|
-
/** rounding 规则 */
|
|
99
|
-
rounding_rule?: any;
|
|
100
|
-
/** 实付金额(现金支付时的实际给出金额) */
|
|
101
|
-
actual_paid_amount?: number;
|
|
102
|
-
/** 找零金额(现金支付时的找零金额) */
|
|
103
|
-
change_given_amount?: number;
|
|
104
|
-
[key: string]: unknown;
|
|
105
|
-
}
|
|
106
90
|
/**
|
|
107
91
|
* 支付项
|
|
108
92
|
*/
|
|
109
93
|
export interface PaymentItem {
|
|
110
94
|
/** 当前支付项的唯一 ID */
|
|
111
95
|
uuid: string;
|
|
112
|
-
/** 支付项稳定唯一号 */
|
|
113
|
-
payment_number?: string;
|
|
114
96
|
/** 当前支付方式付出去多少钱 */
|
|
115
97
|
amount: string;
|
|
116
98
|
/** 支付类型,跟支付列表上对应的支付方式保持一致 */
|
|
@@ -128,7 +110,18 @@ export interface PaymentItem {
|
|
|
128
110
|
/** Wallet Pass 本次使用值 */
|
|
129
111
|
wallet_pass_use_value?: string | number | null;
|
|
130
112
|
/** 拓展参数字段 */
|
|
131
|
-
metadata?:
|
|
113
|
+
metadata?: {
|
|
114
|
+
/** 钱箱 ID */
|
|
115
|
+
shop_wallet_pass_id?: string;
|
|
116
|
+
/** 唯一支付号 */
|
|
117
|
+
unique_payment_number?: string;
|
|
118
|
+
/** rouding规则 */
|
|
119
|
+
rounding_rule?: any;
|
|
120
|
+
/** 实付金额(现金支付时的实际给出金额) */
|
|
121
|
+
actual_paid_amount?: number;
|
|
122
|
+
/** 找零金额(现金支付时的找零金额) */
|
|
123
|
+
change_given_amount?: number;
|
|
124
|
+
};
|
|
132
125
|
/** rouding金额 */
|
|
133
126
|
rounding_amount?: string;
|
|
134
127
|
/** 三方支付手续费 */
|
|
@@ -235,10 +228,6 @@ export interface UpdateOrderParams {
|
|
|
235
228
|
* 支付项输入类型(允许 amount 为数字)
|
|
236
229
|
*/
|
|
237
230
|
export interface PaymentItemInput {
|
|
238
|
-
/** 调用方已有的支付项运行态 UUID;存在时复用为 payment_number 的唯一号段 */
|
|
239
|
-
uuid?: string;
|
|
240
|
-
/** 支付项稳定唯一号 */
|
|
241
|
-
payment_number?: string;
|
|
242
231
|
/** 当前支付方式付出去多少钱 */
|
|
243
232
|
amount: string | number;
|
|
244
233
|
/** 支付类型,跟支付列表上对应的支付方式保持一致 */
|
|
@@ -267,7 +256,18 @@ export interface PaymentItemInput {
|
|
|
267
256
|
/** 订单支付类型 */
|
|
268
257
|
order_payment_type?: 'normal' | 'deposit';
|
|
269
258
|
/** 扩展参数字段 */
|
|
270
|
-
metadata?:
|
|
259
|
+
metadata?: {
|
|
260
|
+
/** 钱箱 ID */
|
|
261
|
+
shop_wallet_pass_id?: string;
|
|
262
|
+
/** 唯一支付号 */
|
|
263
|
+
unique_payment_number?: string;
|
|
264
|
+
/** rounding规则 */
|
|
265
|
+
rounding_rule?: any;
|
|
266
|
+
/** 实付金额(现金支付时的实际给出金额) */
|
|
267
|
+
actual_paid_amount?: number;
|
|
268
|
+
/** 找零金额(现金支付时的找零金额) */
|
|
269
|
+
change_given_amount?: number;
|
|
270
|
+
};
|
|
271
271
|
/** 支付项创建时间 (格式: YYYY-MM-DD HH:mm:ss, 可选,不传则自动生成) */
|
|
272
272
|
created_at?: string;
|
|
273
273
|
/** 支付项更新时间 (格式: YYYY-MM-DD HH:mm:ss, 可选,不传则自动生成) */
|
|
@@ -302,8 +302,6 @@ export interface PaymentUpdateFields {
|
|
|
302
302
|
voucher_id?: string;
|
|
303
303
|
/** 该支付项是否已经同步给后端服务器(只有网络请求成功后才为true) */
|
|
304
304
|
isSynced?: boolean;
|
|
305
|
-
/** 支付项扩展元数据;更新时与原 metadata 浅合并 */
|
|
306
|
-
metadata?: PaymentItemMetadata;
|
|
307
305
|
/** 同步错误信息(业务错误时记录错误信息,用于区分"未同步"和"同步失败") */
|
|
308
306
|
syncError?: {
|
|
309
307
|
error: string;
|
|
@@ -40,9 +40,9 @@ export var TaskRunStatus = /*#__PURE__*/function (TaskRunStatus) {
|
|
|
40
40
|
*/
|
|
41
41
|
export var RoundingRule = /*#__PURE__*/function (RoundingRule) {
|
|
42
42
|
RoundingRule["Standard"] = "standard_rounding";
|
|
43
|
-
RoundingRule["StandardDown"] = "
|
|
44
|
-
RoundingRule["AlwaysUp"] = "
|
|
45
|
-
RoundingRule["AlwaysDown"] = "
|
|
43
|
+
RoundingRule["StandardDown"] = "standard_rounding_midpoint_down";
|
|
44
|
+
RoundingRule["AlwaysUp"] = "round_up";
|
|
45
|
+
RoundingRule["AlwaysDown"] = "round_down";
|
|
46
46
|
return RoundingRule;
|
|
47
47
|
}({});
|
|
48
48
|
|
|
@@ -65,8 +65,6 @@ export var RoundingInterval = /*#__PURE__*/function (RoundingInterval) {
|
|
|
65
65
|
* 支付方式信息
|
|
66
66
|
*/
|
|
67
67
|
|
|
68
|
-
/** 支付项扩展元数据 */
|
|
69
|
-
|
|
70
68
|
/**
|
|
71
69
|
* 支付项
|
|
72
70
|
*/
|
|
@@ -35,7 +35,6 @@ export declare class RulesModule extends BaseModule implements Module, RulesModu
|
|
|
35
35
|
excludeDiscountListByType(discountList: Discount[], type: string): Discount[];
|
|
36
36
|
/** 手动改价场景:去掉 promotion,保留 type=product 等行内折扣 */
|
|
37
37
|
resolveDiscountListForManualOverride(discountList: Discount[]): Discount[];
|
|
38
|
-
private isItemRewardProductDiscount;
|
|
39
38
|
private getUnavailableReason;
|
|
40
39
|
calcDiscount({ discountList, productList, holders, isFormSubject, orderTotalAmount }: {
|
|
41
40
|
discountList: Discount[];
|
|
@@ -241,17 +241,6 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
241
241
|
value: function resolveDiscountListForManualOverride(discountList) {
|
|
242
242
|
return this.excludeDiscountListByType(discountList, 'promotion');
|
|
243
243
|
}
|
|
244
|
-
}, {
|
|
245
|
-
key: "isItemRewardProductDiscount",
|
|
246
|
-
value: function isItemRewardProductDiscount(product) {
|
|
247
|
-
var _product$_promotion;
|
|
248
|
-
var discountList = Array.isArray(product === null || product === void 0 ? void 0 : product.discount_list) ? product.discount_list : [];
|
|
249
|
-
return (product === null || product === void 0 || (_product$_promotion = product._promotion) === null || _product$_promotion === void 0 ? void 0 : _product$_promotion.actionType) === 'ITEM_REWARD' && discountList.some(function (item) {
|
|
250
|
-
var _item$metadata, _item$metadata2;
|
|
251
|
-
return (item === null || item === void 0 ? void 0 : item.type) === 'product' && (item === null || item === void 0 || (_item$metadata = item.metadata) === null || _item$metadata === void 0 ? void 0 : _item$metadata.source) === 'promotion' && (item === null || item === void 0 || (_item$metadata2 = item.metadata) === null || _item$metadata2 === void 0 ? void 0 : _item$metadata2.actionType) === 'ITEM_REWARD';
|
|
252
|
-
});
|
|
253
|
-
}
|
|
254
|
-
|
|
255
244
|
// 获取券不可用的原因
|
|
256
245
|
}, {
|
|
257
246
|
key: "getUnavailableReason",
|
|
@@ -362,7 +351,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
362
351
|
var discountType = selectedDiscount.tag || selectedDiscount.type;
|
|
363
352
|
return selectedDiscount.isEditMode === true && selectedDiscount.isSelected === true && ['good_pass', 'discount_card', 'product_discount_card'].includes(discountType);
|
|
364
353
|
};
|
|
365
|
-
var
|
|
354
|
+
var resolveReapplyBookingDiscountPercent = function resolveReapplyBookingDiscountPercent(originProduct, selectedDiscount) {
|
|
366
355
|
var _discount2;
|
|
367
356
|
if (!shouldReapplyBookingDiscount(originProduct, selectedDiscount)) return undefined;
|
|
368
357
|
var discountType = (selectedDiscount === null || selectedDiscount === void 0 ? void 0 : selectedDiscount.tag) || (selectedDiscount === null || selectedDiscount === void 0 ? void 0 : selectedDiscount.type);
|
|
@@ -440,7 +429,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
440
429
|
// 2. 展开 bundle 子商品
|
|
441
430
|
if (product.bundle && Array.isArray(product.bundle) && product.bundle.length > 0) {
|
|
442
431
|
product.bundle.forEach(function (bundleItem, bundleIndex) {
|
|
443
|
-
var _ref3, _bundleItem$
|
|
432
|
+
var _ref3, _bundleItem$_bundle_p;
|
|
444
433
|
flattened.push({
|
|
445
434
|
type: 'bundle',
|
|
446
435
|
originProduct: originProduct,
|
|
@@ -449,7 +438,10 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
449
438
|
bundleIndex: bundleIndex,
|
|
450
439
|
// 虚拟商品属性
|
|
451
440
|
price: Number(bundleItem.price || 0),
|
|
452
|
-
|
|
441
|
+
// 新增商品运行态通常带 _bundle_product_id;订单 hydrate 后只有
|
|
442
|
+
// bundle_product_id。Change time 必须兼容两种结构,否则 bundle
|
|
443
|
+
// 子项无法命中折扣卡的 limited_relation_product_data.product_ids。
|
|
444
|
+
id: (_ref3 = (_bundleItem$_bundle_p = bundleItem._bundle_product_id) !== null && _bundleItem$_bundle_p !== void 0 ? _bundleItem$_bundle_p : bundleItem.bundle_product_id) !== null && _ref3 !== void 0 ? _ref3 : bundleItem.product_id,
|
|
453
445
|
_id: "".concat(product._id, "_bundle_").concat(bundleIndex),
|
|
454
446
|
parentId: product._id,
|
|
455
447
|
num: bundleItem.num || 1,
|
|
@@ -740,9 +732,6 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
740
732
|
startDate: (_flatItem$parentProdu = flatItem.parentProduct) === null || _flatItem$parentProdu === void 0 ? void 0 : _flatItem$parentProdu.startDate
|
|
741
733
|
};
|
|
742
734
|
}
|
|
743
|
-
if (_this3.isItemRewardProductDiscount(product)) {
|
|
744
|
-
return false;
|
|
745
|
-
}
|
|
746
735
|
|
|
747
736
|
// 编辑的商品使用了优惠券不可用
|
|
748
737
|
var isAvailableProduct = flatItem.type === 'main' ? !((_product2 = product) !== null && _product2 !== void 0 && _product2.booking_id && (_product3 = product) !== null && _product3 !== void 0 && (_product3 = _product3.discount_list) !== null && _product3 !== void 0 && _product3.length && (_product4 = product) !== null && _product4 !== void 0 && (_product4 = _product4.discount_list) !== null && _product4 !== void 0 && _product4.every(function (d) {
|
|
@@ -929,7 +918,6 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
929
918
|
};
|
|
930
919
|
originProduct = flatItem.originProduct;
|
|
931
920
|
}
|
|
932
|
-
var isItemRewardProductDiscount = _this3.isItemRewardProductDiscount(product);
|
|
933
921
|
addModeDiscount.forEach(function (discount) {
|
|
934
922
|
var _product6, _product7, _product8, _product9, _flatItem$bundleItem3, _flatItem$bundleItem4, _discount$config;
|
|
935
923
|
var limitedData = discount === null || discount === void 0 ? void 0 : discount.limited_relation_product_data;
|
|
@@ -955,7 +943,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
955
943
|
var isBundleAvailable = _this3.checkPackageSubItemUsageRules(discount, flatItem);
|
|
956
944
|
|
|
957
945
|
// 判断优惠券是否适用于该商品
|
|
958
|
-
if (isAvailableProduct &&
|
|
946
|
+
if (isAvailableProduct && isLimitedProduct && timeLimit && isBundleAvailable && (_discount$config = discount.config) !== null && _discount$config !== void 0 && _discount$config.isAvailable) {
|
|
959
947
|
var _discountApplicabilit, _discount$metadata4, _discount$metadata5;
|
|
960
948
|
// 记录此优惠券适用的商品
|
|
961
949
|
(_discountApplicabilit = discountApplicability.get(discount.id)) === null || _discountApplicabilit === void 0 || _discountApplicabilit.push(product.id);
|
|
@@ -1089,18 +1077,16 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1089
1077
|
if (isPersistedProduct && hasExistingWalletDiscount) {
|
|
1090
1078
|
if (flatItem.type === 'main') {
|
|
1091
1079
|
processedProductsMap.set(product._id, [originProduct]);
|
|
1092
|
-
} else {
|
|
1093
|
-
processedFlatItemsMap.set(flatItem._id, [_objectSpread(_objectSpread({}, flatItem), {}, {
|
|
1094
|
-
processed: true
|
|
1095
|
-
})]);
|
|
1096
1080
|
}
|
|
1081
|
+
// bundle 虚拟项没有携带完整的历史价格字段。这里不写入 processed map,
|
|
1082
|
+
// 重组阶段会直接保留原始 bundleItem,避免把 bundle_selling_price
|
|
1083
|
+
// 覆盖为未折扣的 price,导致已支付金额再次进入应付。
|
|
1097
1084
|
return;
|
|
1098
1085
|
}
|
|
1099
1086
|
|
|
1100
1087
|
// 找到适用于此商品的所有优惠券,仅考虑isSelected不为false的优惠券
|
|
1101
1088
|
var applicableDiscounts = sortedDiscountList.filter(function (discount) {
|
|
1102
1089
|
var _product$discount_lis3, _product$discount_lis4;
|
|
1103
|
-
if (_this3.isItemRewardProductDiscount(product)) return false;
|
|
1104
1090
|
// 🔥 检查策略可用性(针对 good_pass 和折扣卡)
|
|
1105
1091
|
var discountType = discount.tag || discount.type;
|
|
1106
1092
|
var currentOriginUid = getOriginProductUid(originProduct);
|
|
@@ -1178,23 +1164,16 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1178
1164
|
return false;
|
|
1179
1165
|
});
|
|
1180
1166
|
|
|
1181
|
-
//
|
|
1182
|
-
//
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
return String(discount.id) === String(options.discountId) && ['discount_card', 'product_discount_card'].includes(discountType);
|
|
1186
|
-
}) : undefined;
|
|
1187
|
-
|
|
1188
|
-
// 没有显式选择时保持现有行为:扫码且已选中的折扣卡优先,否则使用自动排序第一项。
|
|
1189
|
-
var scannedSelectedDiscountCard = applicableDiscounts.find(function (n) {
|
|
1167
|
+
// 选择第一个适用的优惠券(已经按过期时间排序)
|
|
1168
|
+
// 如果有 isScan 且 isSelected 的折扣卡,则优先选中,否则再选择第一个
|
|
1169
|
+
// 用于处理:先手动扫描了一张折扣卡,扫描完以后带入客户信息,但是之前那张折扣卡不是最优惠的情况
|
|
1170
|
+
var selectedDiscountCard = applicableDiscounts.find(function (n) {
|
|
1190
1171
|
return n.isScan && n.isSelected && (n.tag || n.type) !== 'good_pass';
|
|
1191
1172
|
});
|
|
1192
|
-
var selectedDiscountCard = explicitlySelectedDiscountCard || scannedSelectedDiscountCard;
|
|
1193
1173
|
var selectedDiscount = selectedDiscountCard || applicableDiscounts[0];
|
|
1194
1174
|
|
|
1195
1175
|
// 如果是手动折扣,则不适用优惠券
|
|
1196
1176
|
var isManualDiscount = false;
|
|
1197
|
-
var isItemRewardProductDiscount = false;
|
|
1198
1177
|
if (flatItem.type === 'main') {
|
|
1199
1178
|
var _product$discount_lis5, _product$discount_lis6, _product12, _product12$every;
|
|
1200
1179
|
// 主商品:判断自身是否手动折扣
|
|
@@ -1206,8 +1185,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1206
1185
|
}) && (!((_product$discount_lis6 = product.discount_list) !== null && _product$discount_lis6 !== void 0 && _product$discount_lis6.length) || ((_product12 = product) === null || _product12 === void 0 || (_product12 = _product12.discount_list) === null || _product12 === void 0 || (_product12$every = _product12.every) === null || _product12$every === void 0 ? void 0 : _product12$every.call(_product12, function (item) {
|
|
1207
1186
|
return item.type === 'product';
|
|
1208
1187
|
})));
|
|
1209
|
-
|
|
1210
|
-
if (product.inPromotion && !isItemRewardProductDiscount) {
|
|
1188
|
+
if (product.inPromotion) {
|
|
1211
1189
|
isManualDiscount = false;
|
|
1212
1190
|
}
|
|
1213
1191
|
} else {
|
|
@@ -1317,17 +1295,15 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1317
1295
|
var main_product_selling_price = product.price;
|
|
1318
1296
|
if ((product.discount_list || []).some(function (item) {
|
|
1319
1297
|
return item.type === 'promotion';
|
|
1320
|
-
}) ||
|
|
1298
|
+
}) || isBoolean(product.vouchersApplicable) && !product.vouchersApplicable) {
|
|
1321
1299
|
var _product$total, _product$main_product;
|
|
1322
1300
|
total = (_product$total = product.total) !== null && _product$total !== void 0 ? _product$total : product.origin_total;
|
|
1323
1301
|
main_product_selling_price = (_product$main_product = product.main_product_selling_price) !== null && _product$main_product !== void 0 ? _product$main_product : main_product_selling_price;
|
|
1324
1302
|
}
|
|
1325
|
-
processedProductsMap.set(product._id, [_this3.hooks.setProduct(originProduct, _objectSpread(_objectSpread({}, isManualDiscount ?
|
|
1303
|
+
processedProductsMap.set(product._id, [_this3.hooks.setProduct(originProduct, _objectSpread(_objectSpread({}, isManualDiscount ? {
|
|
1326
1304
|
price: product.price,
|
|
1327
|
-
main_product_selling_price:
|
|
1328
|
-
}
|
|
1329
|
-
total: total
|
|
1330
|
-
} : {}) : {
|
|
1305
|
+
main_product_selling_price: product.price
|
|
1306
|
+
} : {
|
|
1331
1307
|
_id: product._id.split('___')[0] + '___' + index,
|
|
1332
1308
|
total: total,
|
|
1333
1309
|
price: product.price,
|
|
@@ -1434,9 +1410,9 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1434
1410
|
amount = productAllocation.discountAmount;
|
|
1435
1411
|
productDiscountDifference = productAllocation.difference;
|
|
1436
1412
|
mainProductSellingPrice = Math.max(new Decimal(product.price).minus(amount).toNumber(), 0);
|
|
1437
|
-
} else if (
|
|
1413
|
+
} else if (resolveReapplyBookingDiscountPercent(originProduct, _selectedDiscount) !== undefined) {
|
|
1438
1414
|
// Change time 重套编辑态折扣卡时,历史 par_value 不是运行时折扣口径,优先使用后端快照里的 percent。
|
|
1439
|
-
var percent =
|
|
1415
|
+
var percent = resolveReapplyBookingDiscountPercent(originProduct, _selectedDiscount);
|
|
1440
1416
|
reapplyDiscountPercent = new Decimal(percent).toFixed(2);
|
|
1441
1417
|
mainProductSellingPrice = new Decimal(product.price || 0).mul(new Decimal(100).minus(percent)).div(100).toDecimalPlaces(2).toNumber();
|
|
1442
1418
|
amount = new Decimal(product.price).minus(mainProductSellingPrice).toNumber();
|
|
@@ -1602,7 +1578,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1602
1578
|
}));
|
|
1603
1579
|
}
|
|
1604
1580
|
} else {
|
|
1605
|
-
var _selectedDiscount3$me, _selectedDiscount3$me2, _flatItem$parentProdu9;
|
|
1581
|
+
var _selectedDiscount3$me, _selectedDiscount3$me2, _reapplyDiscountPerce2, _flatItem$parentProdu9;
|
|
1606
1582
|
// 折扣卡:不拆分数量,直接应用
|
|
1607
1583
|
var _selectedDiscount3 = selectedDiscountCard || applicableDiscounts[0];
|
|
1608
1584
|
usedDiscounts.set(_selectedDiscount3.id, true);
|
|
@@ -1620,11 +1596,19 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1620
1596
|
var targetProductTotal;
|
|
1621
1597
|
var fixedAmountPerItem;
|
|
1622
1598
|
var _productDiscountDifference;
|
|
1599
|
+
var _reapplyDiscountPercent;
|
|
1623
1600
|
if (_isOrderLevel && _productAllocation) {
|
|
1624
1601
|
// order_level:使用预计算的单价折扣金额(已经是单价,无需再除以数量)
|
|
1625
1602
|
fixedAmountPerItem = _productAllocation.discountAmount;
|
|
1626
1603
|
_productDiscountDifference = _productAllocation.difference;
|
|
1627
1604
|
targetProductTotal = Math.max(new Decimal(_productOriginTotal).minus(fixedAmountPerItem).toNumber(), 0);
|
|
1605
|
+
} else if (resolveReapplyBookingDiscountPercent(originProduct, _selectedDiscount3) !== undefined) {
|
|
1606
|
+
// hydrate 后 par_value 可能是余额/原值(例如 3500),百分比口径以
|
|
1607
|
+
// 后端折扣快照 discount.percent 为准,与主商品重套逻辑保持一致。
|
|
1608
|
+
var _percent = resolveReapplyBookingDiscountPercent(originProduct, _selectedDiscount3);
|
|
1609
|
+
_reapplyDiscountPercent = new Decimal(_percent).toFixed(2);
|
|
1610
|
+
targetProductTotal = new Decimal(_productOriginTotal).mul(new Decimal(100).minus(_percent)).div(100).toDecimalPlaces(2).toNumber();
|
|
1611
|
+
fixedAmountPerItem = new Decimal(_productOriginTotal).minus(targetProductTotal).toNumber();
|
|
1628
1612
|
} else {
|
|
1629
1613
|
// item_level 或其他类型:使用原有逻辑
|
|
1630
1614
|
targetProductTotal = getDiscountAmount(_selectedDiscount3, _productOriginTotal, _productOriginTotal);
|
|
@@ -1645,7 +1629,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1645
1629
|
title: _selectedDiscount3.format_title,
|
|
1646
1630
|
original_amount: product.original_price,
|
|
1647
1631
|
product_id: product.id || product.product_id,
|
|
1648
|
-
percent: _selectedDiscount3.par_value,
|
|
1632
|
+
percent: (_reapplyDiscountPerce2 = _reapplyDiscountPercent) !== null && _reapplyDiscountPerce2 !== void 0 ? _reapplyDiscountPerce2 : _selectedDiscount3.par_value,
|
|
1649
1633
|
discount_product_id: _selectedDiscount3.product_id
|
|
1650
1634
|
},
|
|
1651
1635
|
metadata: _objectSpread({
|
|
@@ -1776,11 +1760,11 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1776
1760
|
processedItems.forEach(function (item) {
|
|
1777
1761
|
// 🔥 更新 discount_list 中的 num,使其与拆分后的 item.num 一致
|
|
1778
1762
|
var updatedDiscountList = (item.discount_list || []).map(function (discount) {
|
|
1779
|
-
var _item$
|
|
1763
|
+
var _item$metadata;
|
|
1780
1764
|
return _objectSpread(_objectSpread({}, discount), {}, {
|
|
1781
1765
|
metadata: _objectSpread(_objectSpread({}, discount.metadata), {}, {
|
|
1782
1766
|
num: item.num,
|
|
1783
|
-
custom_product_bundle_map_id: (_item$
|
|
1767
|
+
custom_product_bundle_map_id: (_item$metadata = item.metadata) === null || _item$metadata === void 0 ? void 0 : _item$metadata.custom_product_bundle_map_id
|
|
1784
1768
|
})
|
|
1785
1769
|
// num: item.num, // 使用拆分后的 num
|
|
1786
1770
|
});
|
|
@@ -1799,11 +1783,11 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1799
1783
|
if (item.processed) {
|
|
1800
1784
|
// 🔥 同样需要更新 discount_list 中的 num
|
|
1801
1785
|
var _updatedDiscountList = (item.discount_list || []).map(function (discount) {
|
|
1802
|
-
var _item$
|
|
1786
|
+
var _item$metadata2;
|
|
1803
1787
|
return _objectSpread(_objectSpread({}, discount), {}, {
|
|
1804
1788
|
metadata: _objectSpread(_objectSpread({}, discount.metadata), {}, {
|
|
1805
1789
|
num: item.num,
|
|
1806
|
-
custom_product_bundle_map_id: (_item$
|
|
1790
|
+
custom_product_bundle_map_id: (_item$metadata2 = item.metadata) === null || _item$metadata2 === void 0 ? void 0 : _item$metadata2.custom_product_bundle_map_id
|
|
1807
1791
|
})
|
|
1808
1792
|
// num: item.num, // 使用当前的 num
|
|
1809
1793
|
});
|
|
@@ -1844,8 +1828,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1844
1828
|
|
|
1845
1829
|
// 🔥 使用更新后的列表计算折扣金额
|
|
1846
1830
|
var mainDiscountList = updatedMainDiscountList.filter(function (item) {
|
|
1847
|
-
var _item$
|
|
1848
|
-
return !(item !== null && item !== void 0 && (_item$
|
|
1831
|
+
var _item$metadata3;
|
|
1832
|
+
return !(item !== null && item !== void 0 && (_item$metadata3 = item.metadata) !== null && _item$metadata3 !== void 0 && _item$metadata3.custom_product_bundle_map_id);
|
|
1849
1833
|
});
|
|
1850
1834
|
if (mainDiscountList && mainDiscountList.length > 0) {
|
|
1851
1835
|
var _Decimal$minus$toNumb, _mainProductData$orig;
|
|
@@ -1918,8 +1902,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1918
1902
|
|
|
1919
1903
|
// 🔥 使用更新后的列表计算折扣金额
|
|
1920
1904
|
var mainDiscountListOriginal = updatedMainDiscountListOriginal.filter(function (item) {
|
|
1921
|
-
var _item$
|
|
1922
|
-
return !(item !== null && item !== void 0 && (_item$
|
|
1905
|
+
var _item$metadata4;
|
|
1906
|
+
return !(item !== null && item !== void 0 && (_item$metadata4 = item.metadata) !== null && _item$metadata4 !== void 0 && _item$metadata4.custom_product_bundle_map_id);
|
|
1923
1907
|
});
|
|
1924
1908
|
if (mainDiscountListOriginal && mainDiscountListOriginal.length > 0) {
|
|
1925
1909
|
var _Decimal$minus$toNumb2, _mainProductData$orig2;
|
|
@@ -87,7 +87,13 @@ function getUnitOriginalTotal(product) {
|
|
|
87
87
|
function isGeneratedVoucherProduct(product) {
|
|
88
88
|
var record = product;
|
|
89
89
|
var metadata = (record === null || record === void 0 ? void 0 : record.metadata) || {};
|
|
90
|
-
|
|
90
|
+
var isGeneratedChild = metadata.parent_order_detail_id !== undefined || metadata.gift_card_type !== undefined;
|
|
91
|
+
if (isGeneratedChild) return true;
|
|
92
|
+
|
|
93
|
+
// `product_voucher` 既可能是当前购物车生成的零价子券,也可能是独立售卖的
|
|
94
|
+
// gift card。已有 order_detail_id 且没有 parent 标记的是后者,必须继续计价。
|
|
95
|
+
var isPersisted = (record === null || record === void 0 ? void 0 : record.order_detail_id) !== undefined && (record === null || record === void 0 ? void 0 : record.order_detail_id) !== null;
|
|
96
|
+
return (record === null || record === void 0 ? void 0 : record.extension_type) === 'product_voucher' && !isPersisted;
|
|
91
97
|
}
|
|
92
98
|
function buildSurchargeServiceItems(products) {
|
|
93
99
|
return products.map(function (product) {
|
package/dist/server/index.d.ts
CHANGED
|
@@ -57,7 +57,6 @@ declare class Server {
|
|
|
57
57
|
private readonly BOOKING_REMOTE_CACHE_MAX_ENTRIES;
|
|
58
58
|
private salesSearchSubscribers;
|
|
59
59
|
private deviceTaskActionsRegistered;
|
|
60
|
-
private localPaymentUpdateQueues;
|
|
61
60
|
private floorPlanQuerySubscribers;
|
|
62
61
|
private moduleRegistry;
|
|
63
62
|
constructor(core: PisellCore);
|
|
@@ -121,8 +120,6 @@ declare class Server {
|
|
|
121
120
|
private handleSyncSalesTask;
|
|
122
121
|
private runCheckoutSync;
|
|
123
122
|
private omitCheckoutSyncMode;
|
|
124
|
-
private buildRemoteCheckoutData;
|
|
125
|
-
private mergeCheckoutSyncPayments;
|
|
126
123
|
private persistSyncedCheckoutOrder;
|
|
127
124
|
/**
|
|
128
125
|
* 将普通层 QuotationModule 的报价单计算能力桥接到 Server Products 模块。
|
|
@@ -456,18 +453,6 @@ declare class Server {
|
|
|
456
453
|
*/
|
|
457
454
|
private handleUpdateLocalOrder;
|
|
458
455
|
private handleOrderSalesCheckout;
|
|
459
|
-
private handleOrderSalesDraft;
|
|
460
|
-
private createLocalPaymentOperationId;
|
|
461
|
-
private buildLocalPaymentOrderLogContext;
|
|
462
|
-
private isValidLocalPaymentDecimal;
|
|
463
|
-
private getInvalidLocalPaymentSurchargeFields;
|
|
464
|
-
private buildLocalPaymentSurchargeUpdate;
|
|
465
|
-
private handleGetLocalPayment;
|
|
466
|
-
private handleUpdateLocalPayment;
|
|
467
|
-
private runLocalPaymentUpdateInQueue;
|
|
468
|
-
private processLocalPaymentUpdate;
|
|
469
|
-
private processSuccessfulLocalPayment;
|
|
470
|
-
private sanitizeLocalRecoveryOrder;
|
|
471
456
|
private handleOrderCheckout;
|
|
472
457
|
private getDeviceTaskPlugin;
|
|
473
458
|
private getIdGeneratorPlugin;
|
|
@@ -495,7 +480,6 @@ declare class Server {
|
|
|
495
480
|
private syncMachinecodeRedeemStatusToLocalOrder;
|
|
496
481
|
private handleOrderCheckoutSubmit;
|
|
497
482
|
private handleSyncCheckoutSubmit;
|
|
498
|
-
private handleOrderDraftSubmit;
|
|
499
483
|
private handlePendingSyncCheckoutOrder;
|
|
500
484
|
private buildPendingSyncCheckoutOrder;
|
|
501
485
|
private shouldBuildSmallTicketData;
|