@pisell/pisellos 0.10.90 → 0.10.93
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/model/strategy/adapter/itemRule/adapter.d.ts +3 -1
- package/dist/model/strategy/adapter/itemRule/adapter.js +74 -7
- package/dist/model/strategy/adapter/itemRule/evaluator.d.ts +3 -1
- package/dist/model/strategy/adapter/itemRule/evaluator.js +13 -0
- package/dist/model/strategy/adapter/itemRule/type.d.ts +40 -1
- package/dist/model/strategy/adapter/itemRule/type.js +10 -0
- package/dist/model/strategy/adapter/promotion/evaluator.d.ts +2 -1
- package/dist/model/strategy/adapter/promotion/evaluator.js +103 -112
- package/dist/modules/BookingContext/utils/calendarBooking.d.ts +15 -0
- package/dist/modules/BookingContext/utils/calendarBooking.js +207 -0
- package/dist/modules/BookingContext/utils/index.d.ts +1 -0
- package/dist/modules/BookingContext/utils/index.js +1 -0
- package/dist/modules/BookingContext/utils/productExtend.d.ts +21 -0
- package/dist/modules/BookingContext/utils/productExtend.js +132 -33
- package/dist/modules/BookingContext/utils/resources.js +1 -1
- package/dist/modules/Cart/index.js +4 -3
- package/dist/modules/Cart/types.d.ts +2 -0
- package/dist/modules/Cart/utils/cartProduct.d.ts +3 -1
- package/dist/modules/Cart/utils/cartProduct.js +59 -32
- package/dist/modules/Date/index.d.ts +1 -1
- package/dist/modules/Date/index.js +60 -14
- package/dist/modules/Date/types.d.ts +5 -0
- package/dist/modules/OpenData/salesSettings.js +1 -1
- package/dist/modules/OpenData/types.d.ts +9 -0
- package/dist/modules/OpenData/utils.d.ts +1 -1
- package/dist/modules/OpenData/utils.js +3 -2
- package/dist/modules/Order/index.d.ts +22 -7
- package/dist/modules/Order/index.js +1565 -1161
- package/dist/modules/Order/localEftposState.d.ts +13 -0
- package/dist/modules/Order/localEftposState.js +39 -0
- package/dist/modules/Order/types.d.ts +33 -11
- package/dist/modules/Order/types.js +2 -2
- package/dist/modules/Order/unpaidAmountGap.d.ts +6 -0
- package/dist/modules/Order/unpaidAmountGap.js +72 -0
- package/dist/modules/Order/utils.d.ts +4 -1
- package/dist/modules/Order/utils.js +75 -52
- package/dist/modules/Payment/walletpass.js +32 -6
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/Product/types.d.ts +16 -0
- package/dist/modules/ProductList/index.js +1 -1
- package/dist/modules/ResourcePlanner/planner.d.ts +2 -0
- package/dist/modules/ResourcePlanner/planner.js +383 -24
- package/dist/modules/ResourcePlanner/types.d.ts +42 -0
- package/dist/modules/Rules/index.js +86 -54
- package/dist/modules/Schedule/index.d.ts +7 -1
- package/dist/modules/Schedule/index.js +155 -39
- package/dist/modules/Schedule/types.d.ts +2 -0
- package/dist/modules/bookingReadValidation.d.ts +6 -0
- package/dist/modules/bookingReadValidation.js +72 -0
- package/dist/plugins/request.d.ts +2 -0
- package/dist/server/index.d.ts +9 -0
- package/dist/server/index.js +1928 -1462
- package/dist/server/modules/form/index.d.ts +19 -0
- package/dist/server/modules/form/index.js +205 -0
- package/dist/server/modules/form/types.d.ts +13 -0
- package/dist/server/modules/form/types.js +3 -0
- package/dist/server/modules/index.d.ts +3 -0
- package/dist/server/modules/index.js +4 -0
- package/dist/server/modules/order/index.d.ts +21 -0
- package/dist/server/modules/order/index.js +1399 -831
- package/dist/server/modules/order/types.d.ts +3 -0
- package/dist/server/modules/order/utils/filterOrders.js +20 -0
- package/dist/server/modules/products/index.d.ts +28 -7
- package/dist/server/modules/products/index.js +1295 -769
- package/dist/server/modules/products/replication.d.ts +8 -0
- package/dist/server/modules/products/replication.js +69 -0
- package/dist/server/modules/products/types.d.ts +12 -1
- package/dist/server/modules/products/types.js +4 -0
- package/dist/shared/receipt/customerInvoiceLanguages.d.ts +1 -1
- package/dist/shared/receipt/customerInvoiceLanguages.js +5 -3
- package/dist/shared/receipt/small-ticket.d.ts +1 -0
- package/dist/shared/receipt/small-ticket.js +58 -26
- package/dist/shared/receipt/templateVisibility.d.ts +3 -0
- package/dist/shared/receipt/templateVisibility.js +6 -2
- package/dist/solution/BaseSales/fulfillmentItemRules.d.ts +27 -0
- package/dist/solution/BaseSales/fulfillmentItemRules.js +750 -0
- package/dist/solution/BaseSales/index.d.ts +22 -6
- package/dist/solution/BaseSales/index.js +1881 -1347
- package/dist/solution/BaseSales/pickupTiming.d.ts +4 -0
- package/dist/solution/BaseSales/pickupTiming.js +35 -8
- package/dist/solution/BaseSales/types.d.ts +4 -0
- package/dist/solution/BaseSales/types.js +1 -0
- package/dist/solution/BaseSales/utils/posDurationPricing.d.ts +21 -0
- package/dist/solution/BaseSales/utils/posDurationPricing.js +174 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +2 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +8 -8
- package/dist/solution/BookingByStep/index.d.ts +20 -4
- package/dist/solution/BookingByStep/index.js +681 -361
- package/dist/solution/BookingByStep/utils/resources.d.ts +10 -0
- package/dist/solution/BookingByStep/utils/resources.js +117 -76
- package/dist/solution/BookingTicket/index.d.ts +10 -0
- package/dist/solution/BookingTicket/index.js +686 -598
- package/dist/solution/BookingTicket/types.d.ts +1 -1
- package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +2 -1
- package/dist/solution/BookingTicket/utils/addProductDecision.js +35 -8
- package/dist/solution/BookingTicket/utils/redeemArrival.d.ts +8 -8
- package/dist/solution/BookingTicket/utils/resolveUniqueCartDetail.d.ts +8 -0
- package/dist/solution/BookingTicket/utils/resolveUniqueCartDetail.js +188 -0
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +58 -94
- package/dist/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.d.ts +1 -3
- package/dist/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.js +33 -62
- package/dist/solution/OrderInvoicePreview/index.js +4 -3
- package/dist/solution/Sales/index.js +1 -1
- package/dist/solution/ScanOrder/index.d.ts +2 -0
- package/dist/solution/ScanOrder/index.js +230 -97
- package/dist/solution/ScanOrder/menuAvailability.d.ts +24 -0
- package/dist/solution/ScanOrder/menuAvailability.js +363 -0
- package/dist/solution/ScanOrder/types.d.ts +3 -0
- package/dist/solution/UnifiedBookingSales/index.d.ts +42 -10
- package/dist/solution/UnifiedBookingSales/index.js +2493 -1496
- package/dist/solution/UnifiedBookingSales/salesSettings.js +1 -1
- package/dist/solution/UnifiedBookingSales/types.d.ts +20 -5
- package/dist/utils/pos-receipt-auto-print.d.ts +4 -0
- package/dist/utils/pos-receipt-auto-print.js +14 -0
- package/lib/model/strategy/adapter/itemRule/adapter.d.ts +3 -1
- package/lib/model/strategy/adapter/itemRule/adapter.js +54 -4
- package/lib/model/strategy/adapter/itemRule/evaluator.d.ts +3 -1
- package/lib/model/strategy/adapter/itemRule/evaluator.js +9 -0
- package/lib/model/strategy/adapter/itemRule/type.d.ts +40 -1
- package/lib/model/strategy/adapter/itemRule/type.js +10 -0
- package/lib/model/strategy/adapter/promotion/evaluator.d.ts +2 -1
- package/lib/model/strategy/adapter/promotion/evaluator.js +22 -21
- package/lib/modules/BookingContext/utils/calendarBooking.d.ts +15 -0
- package/lib/modules/BookingContext/utils/calendarBooking.js +156 -0
- package/lib/modules/BookingContext/utils/index.d.ts +1 -0
- package/lib/modules/BookingContext/utils/index.js +11 -0
- package/lib/modules/BookingContext/utils/productExtend.d.ts +21 -0
- package/lib/modules/BookingContext/utils/productExtend.js +104 -5
- package/lib/modules/BookingContext/utils/resources.js +1 -1
- package/lib/modules/Cart/index.js +4 -2
- package/lib/modules/Cart/types.d.ts +2 -0
- package/lib/modules/Cart/utils/cartProduct.d.ts +3 -1
- package/lib/modules/Cart/utils/cartProduct.js +39 -20
- package/lib/modules/Date/index.d.ts +1 -1
- package/lib/modules/Date/index.js +28 -5
- package/lib/modules/Date/types.d.ts +5 -0
- package/lib/modules/OpenData/salesSettings.js +1 -1
- package/lib/modules/OpenData/types.d.ts +9 -0
- package/lib/modules/OpenData/utils.d.ts +1 -1
- package/lib/modules/OpenData/utils.js +3 -2
- package/lib/modules/Order/index.d.ts +22 -7
- package/lib/modules/Order/index.js +457 -174
- package/lib/modules/Order/localEftposState.d.ts +13 -0
- package/lib/modules/Order/localEftposState.js +44 -0
- package/lib/modules/Order/types.d.ts +33 -11
- package/lib/modules/Order/types.js +2 -2
- package/lib/modules/Order/unpaidAmountGap.d.ts +6 -0
- package/lib/modules/Order/unpaidAmountGap.js +60 -0
- package/lib/modules/Order/utils.d.ts +4 -1
- package/lib/modules/Order/utils.js +29 -3
- package/lib/modules/Payment/walletpass.js +23 -1
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/Product/types.d.ts +16 -0
- package/lib/modules/ProductList/index.js +1 -1
- package/lib/modules/ResourcePlanner/planner.d.ts +2 -0
- package/lib/modules/ResourcePlanner/planner.js +299 -9
- package/lib/modules/ResourcePlanner/types.d.ts +42 -0
- package/lib/modules/Rules/index.js +32 -3
- package/lib/modules/Schedule/index.d.ts +7 -1
- package/lib/modules/Schedule/index.js +68 -4
- package/lib/modules/Schedule/types.d.ts +2 -0
- package/lib/modules/bookingReadValidation.d.ts +6 -0
- package/lib/modules/bookingReadValidation.js +56 -0
- package/lib/plugins/request.d.ts +2 -0
- package/lib/server/index.d.ts +9 -0
- package/lib/server/index.js +279 -30
- package/lib/server/modules/form/index.d.ts +19 -0
- package/lib/server/modules/form/index.js +73 -0
- package/lib/server/modules/form/types.d.ts +13 -0
- package/lib/server/modules/form/types.js +9 -0
- package/lib/server/modules/index.d.ts +3 -0
- package/lib/server/modules/index.js +15 -1
- package/lib/server/modules/order/index.d.ts +21 -0
- package/lib/server/modules/order/index.js +344 -35
- package/lib/server/modules/order/types.d.ts +3 -0
- package/lib/server/modules/order/utils/filterOrders.js +18 -0
- package/lib/server/modules/products/index.d.ts +28 -7
- package/lib/server/modules/products/index.js +224 -62
- package/lib/server/modules/products/replication.d.ts +8 -0
- package/lib/server/modules/products/replication.js +30 -0
- package/lib/server/modules/products/types.d.ts +12 -1
- package/lib/server/modules/products/types.js +3 -0
- package/lib/shared/receipt/customerInvoiceLanguages.d.ts +1 -1
- package/lib/shared/receipt/customerInvoiceLanguages.js +5 -3
- package/lib/shared/receipt/small-ticket.d.ts +1 -0
- package/lib/shared/receipt/small-ticket.js +53 -25
- package/lib/shared/receipt/templateVisibility.d.ts +3 -0
- package/lib/shared/receipt/templateVisibility.js +6 -2
- package/lib/solution/BaseSales/fulfillmentItemRules.d.ts +27 -0
- package/lib/solution/BaseSales/fulfillmentItemRules.js +259 -0
- package/lib/solution/BaseSales/index.d.ts +22 -6
- package/lib/solution/BaseSales/index.js +347 -59
- package/lib/solution/BaseSales/pickupTiming.d.ts +4 -0
- package/lib/solution/BaseSales/pickupTiming.js +24 -3
- package/lib/solution/BaseSales/types.d.ts +4 -0
- package/lib/solution/BaseSales/types.js +1 -0
- package/lib/solution/BaseSales/utils/posDurationPricing.d.ts +21 -0
- package/lib/solution/BaseSales/utils/posDurationPricing.js +133 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +2 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +1 -1
- package/lib/solution/BookingByStep/index.d.ts +20 -4
- package/lib/solution/BookingByStep/index.js +229 -17
- package/lib/solution/BookingByStep/utils/resources.d.ts +10 -0
- package/lib/solution/BookingByStep/utils/resources.js +25 -15
- package/lib/solution/BookingTicket/index.d.ts +10 -0
- package/lib/solution/BookingTicket/index.js +57 -6
- package/lib/solution/BookingTicket/types.d.ts +1 -1
- package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +2 -1
- package/lib/solution/BookingTicket/utils/addProductDecision.js +34 -4
- package/lib/solution/BookingTicket/utils/redeemArrival.d.ts +8 -8
- package/lib/solution/BookingTicket/utils/resolveUniqueCartDetail.d.ts +8 -0
- package/lib/solution/BookingTicket/utils/resolveUniqueCartDetail.js +136 -0
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +2 -14
- package/lib/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.d.ts +1 -3
- package/lib/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.js +17 -34
- package/lib/solution/OrderInvoicePreview/index.js +1 -0
- package/lib/solution/Sales/index.js +1 -1
- package/lib/solution/ScanOrder/index.d.ts +2 -0
- package/lib/solution/ScanOrder/index.js +131 -22
- package/lib/solution/ScanOrder/menuAvailability.d.ts +24 -0
- package/lib/solution/ScanOrder/menuAvailability.js +203 -0
- package/lib/solution/ScanOrder/types.d.ts +3 -0
- package/lib/solution/UnifiedBookingSales/index.d.ts +42 -10
- package/lib/solution/UnifiedBookingSales/index.js +717 -144
- package/lib/solution/UnifiedBookingSales/salesSettings.js +1 -1
- package/lib/solution/UnifiedBookingSales/types.d.ts +20 -5
- package/lib/utils/pos-receipt-auto-print.d.ts +4 -0
- package/lib/utils/pos-receipt-auto-print.js +13 -0
- package/package.json +1 -1
|
@@ -92,6 +92,9 @@ export interface AvailabilityProduct {
|
|
|
92
92
|
raw?: Record<string, any>;
|
|
93
93
|
}
|
|
94
94
|
export interface AvailabilityResourceWindow extends AvailabilityAbsoluteRange {
|
|
95
|
+
/** Original business day and opening anchor, before coverage clipping. */
|
|
96
|
+
businessDate?: string;
|
|
97
|
+
openingAnchorAt?: string;
|
|
95
98
|
source?: string;
|
|
96
99
|
raw?: Record<string, any>;
|
|
97
100
|
}
|
|
@@ -101,10 +104,15 @@ export interface AvailabilityOperatingHoursSnapshot {
|
|
|
101
104
|
scheduleIds: AvailabilityId[];
|
|
102
105
|
missingScheduleIds: AvailabilityId[];
|
|
103
106
|
windows: AvailabilityResourceWindow[];
|
|
107
|
+
/** Complete business cycles; lunch gaps remain in windows, not in this envelope. */
|
|
108
|
+
businessPeriods?: AvailabilityBusinessPeriod[];
|
|
104
109
|
/** Schedule windows omitted only because their date is excluded. POS may use
|
|
105
110
|
* these to surface an unavailable, manually selectable candidate. */
|
|
106
111
|
excludedWindows?: AvailabilityResourceWindow[];
|
|
107
112
|
}
|
|
113
|
+
export interface AvailabilityBusinessPeriod extends AvailabilityAbsoluteRange {
|
|
114
|
+
businessDate: string;
|
|
115
|
+
}
|
|
108
116
|
export interface AvailabilityResource {
|
|
109
117
|
id: AvailabilityId;
|
|
110
118
|
formId?: AvailabilityId;
|
|
@@ -212,6 +220,17 @@ export interface ProductTimeRange extends AvailabilityDisplayRange {
|
|
|
212
220
|
bookingEndAt: string;
|
|
213
221
|
scheduleRefs: AvailabilityScheduleRef[];
|
|
214
222
|
primaryScheduleRef?: AvailabilityScheduleRef;
|
|
223
|
+
/** Business-day label. date/startAt keep the actual calendar date. */
|
|
224
|
+
businessDate?: string;
|
|
225
|
+
}
|
|
226
|
+
export interface UnavailableCurrentTime {
|
|
227
|
+
productId: AvailabilityId;
|
|
228
|
+
startAt: string;
|
|
229
|
+
date: string;
|
|
230
|
+
businessDate: string;
|
|
231
|
+
startTime: string;
|
|
232
|
+
status: 'unavailable';
|
|
233
|
+
reasonCodes: string[];
|
|
215
234
|
}
|
|
216
235
|
export interface ProductTimeRangeGroup {
|
|
217
236
|
productId: AvailabilityId;
|
|
@@ -221,6 +240,8 @@ export interface ProductTimeRangeGroup {
|
|
|
221
240
|
/** 单日查询对应营业窗口的最终结束时刻,不受资源排班是否为空影响。 */
|
|
222
241
|
operatingEndAt?: string;
|
|
223
242
|
ranges: ProductTimeRange[];
|
|
243
|
+
/** A display-only current item when flexible duration has no valid end. Never submit it. */
|
|
244
|
+
unavailableCurrentTime?: UnavailableCurrentTime;
|
|
224
245
|
}
|
|
225
246
|
export interface AvailabilityAssignment extends AvailabilityAbsoluteRange {
|
|
226
247
|
productId: AvailabilityId;
|
|
@@ -242,6 +263,19 @@ export interface GetProductTimeRangesRequest {
|
|
|
242
263
|
partySize?: number;
|
|
243
264
|
durationMinutesByProductId?: Record<string, number>;
|
|
244
265
|
durationStartTimesByProductId?: Record<string, string[]>;
|
|
266
|
+
/** Explicit POS manual interval. Endpoints are absolute datetimes, not business-day HH:mm. */
|
|
267
|
+
requestedRangesByProductId?: Record<string, {
|
|
268
|
+
startAt: string;
|
|
269
|
+
endAt: string;
|
|
270
|
+
}>;
|
|
271
|
+
/** Restore only the exact remembered start; recompute the end from current product/windows. */
|
|
272
|
+
rememberedStartAtByProductId?: Record<string, string>;
|
|
273
|
+
/** Order-scoped v2 memory preserves the complete actual booking interval. */
|
|
274
|
+
rememberedTimeByProductId?: Record<string, AvailabilityAbsoluteRange>;
|
|
275
|
+
/** Required by the POS facade before accepting v2 remembered intervals. */
|
|
276
|
+
orderSessionId?: string;
|
|
277
|
+
/** Edit only: preserve the full actual start plus an explicit durationMinutesByProductId. */
|
|
278
|
+
editingStartAtByProductId?: Record<string, string>;
|
|
245
279
|
/**
|
|
246
280
|
* POS 手工输入时间的兼容开关:只为明确请求的 start time 补候选,
|
|
247
281
|
* 不改变常规候选列表仍按营业时间生成的规则。
|
|
@@ -250,6 +284,12 @@ export interface GetProductTimeRangesRequest {
|
|
|
250
284
|
}
|
|
251
285
|
export interface GetProductTimeRangesRuntimeOptions {
|
|
252
286
|
evaluatedAt?: string;
|
|
287
|
+
/** Enabled by the POS/Kiosk facade only; other consumers retain their existing grid. */
|
|
288
|
+
useDurationTimeGrid?: boolean;
|
|
289
|
+
/** Automatic remembered selection must not use POS opening-minute cutoff exceptions. */
|
|
290
|
+
enforceSaleCutoff?: boolean;
|
|
291
|
+
/** Internal POS capability, validated against the current order session by the facade. */
|
|
292
|
+
rememberedTimeByProductId?: Record<string, AvailabilityAbsoluteRange>;
|
|
253
293
|
/**
|
|
254
294
|
* Internal POS capability: fixed-duration candidates start from the stable
|
|
255
295
|
* context anchor's current minute instead of rounding up to ten minutes, and
|
|
@@ -265,6 +305,8 @@ export interface GetProductTimeRangesRuntimeOptions {
|
|
|
265
305
|
* disabled.
|
|
266
306
|
*/
|
|
267
307
|
allowSessionCustomRanges?: boolean;
|
|
308
|
+
/** Internal POS manual capability; automatic/remembered selections must leave this disabled. */
|
|
309
|
+
allowRequestedRanges?: boolean;
|
|
268
310
|
/**
|
|
269
311
|
* Internal POS capability: materialize candidates whose schedule date was
|
|
270
312
|
* explicitly excluded, while availability evaluation keeps them unavailable.
|
|
@@ -1222,6 +1222,40 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1222
1222
|
|
|
1223
1223
|
// 记录已应用优惠券的商品信息
|
|
1224
1224
|
var appliedDiscountProducts = new Map();
|
|
1225
|
+
var hasPayableOptions = function hasPayableOptions(product) {
|
|
1226
|
+
return (product.options || []).reduce(function (total, option) {
|
|
1227
|
+
var _ref14, _ref15, _ref16, _option$_original_pri, _ref17, _option$num;
|
|
1228
|
+
var unitPrice = Number((_ref14 = (_ref15 = (_ref16 = (_option$_original_pri = option._original_price) !== null && _option$_original_pri !== void 0 ? _option$_original_pri : option._original_add_price) !== null && _ref16 !== void 0 ? _ref16 : option.price) !== null && _ref15 !== void 0 ? _ref15 : option.add_price) !== null && _ref14 !== void 0 ? _ref14 : 0);
|
|
1229
|
+
var quantity = Number((_ref17 = (_option$num = option.num) !== null && _option$num !== void 0 ? _option$num : option.quantity) !== null && _ref17 !== void 0 ? _ref17 : 1);
|
|
1230
|
+
if (!Number.isFinite(unitPrice) || !Number.isFinite(quantity) || quantity <= 0) {
|
|
1231
|
+
return total;
|
|
1232
|
+
}
|
|
1233
|
+
return total.plus(new Decimal(unitPrice).mul(quantity));
|
|
1234
|
+
}, new Decimal(0)).greaterThan(0);
|
|
1235
|
+
};
|
|
1236
|
+
|
|
1237
|
+
// 只排除赠品主项的零可抵扣金额;收费 option 和独立 bundle 保持原有规则。
|
|
1238
|
+
var isGiftWithoutDeductibleAmount = function isGiftWithoutDeductibleAmount(flatItem, discount) {
|
|
1239
|
+
var _flatItem$originProdu, _discount$config4;
|
|
1240
|
+
if (flatItem.type !== 'main' || !((_flatItem$originProdu = flatItem.originProduct) !== null && _flatItem$originProdu !== void 0 && (_flatItem$originProdu = _flatItem$originProdu.metadata) !== null && _flatItem$originProdu !== void 0 && _flatItem$originProdu._giftInfo) || Number(flatItem.price || 0) > 0) return false;
|
|
1241
|
+
return !((_discount$config4 = discount.config) !== null && _discount$config4 !== void 0 && _discount$config4.deductOptionPrice) || !hasPayableOptions(flatItem.product);
|
|
1242
|
+
};
|
|
1243
|
+
|
|
1244
|
+
// 可用性和实际应用共用金额判断;零基础价商品可按策略抵扣收费 option。
|
|
1245
|
+
var isDiscountCardPriceAvailable = function isDiscountCardPriceAvailable(flatItem, discount) {
|
|
1246
|
+
var _product$discount_lis2, _discount$config5;
|
|
1247
|
+
var product = flatItem.type === 'main' ? flatItem.product : flatItem.bundleItem;
|
|
1248
|
+
if (!(Number(flatItem.price) <= 0 || !flatItem.price) || (_product$discount_lis2 = product.discount_list) !== null && _product$discount_lis2 !== void 0 && _product$discount_lis2.some(function (item) {
|
|
1249
|
+
var _item$discount2;
|
|
1250
|
+
return ((_item$discount2 = item.discount) === null || _item$discount2 === void 0 ? void 0 : _item$discount2.resource_id) === discount.id;
|
|
1251
|
+
})) {
|
|
1252
|
+
return true;
|
|
1253
|
+
}
|
|
1254
|
+
if (flatItem.type !== 'main' || Number(flatItem.price) !== 0 || !['discount_card', 'product_discount_card'].includes(discount.tag || discount.type || '') || !((_discount$config5 = discount.config) !== null && _discount$config5 !== void 0 && _discount$config5.deductOptionPrice) || isOrderLevelFixedAmountDiscount(discount)) {
|
|
1255
|
+
return false;
|
|
1256
|
+
}
|
|
1257
|
+
return hasPayableOptions(product);
|
|
1258
|
+
};
|
|
1225
1259
|
|
|
1226
1260
|
// 首先遍历所有商品和所有优惠券,确定每个优惠券的适用范围,包括isSelected为false的优惠券
|
|
1227
1261
|
// 🔥 使用扁平化后的列表,包含主商品和bundle子商品
|
|
@@ -1250,7 +1284,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1250
1284
|
}
|
|
1251
1285
|
var isItemRewardProductDiscount = _this5.isItemRewardProductDiscount(product);
|
|
1252
1286
|
addModeDiscount.forEach(function (discount) {
|
|
1253
|
-
var _product6, _product7, _product8, _product9, _flatItem$bundleItem3, _flatItem$bundleItem4, _discount$
|
|
1287
|
+
var _product6, _product7, _product8, _product9, _flatItem$bundleItem3, _flatItem$bundleItem4, _discount$config6;
|
|
1254
1288
|
var limitedData = discount === null || discount === void 0 ? void 0 : discount.limited_relation_product_data;
|
|
1255
1289
|
// 拿到discount配置的holder信息 product信息 product.holder 加在 isLimitedProduct
|
|
1256
1290
|
var _tempVar = (flatItem === null || flatItem === void 0 ? void 0 : flatItem.type) === 'bundle' ? flatItem === null || flatItem === void 0 ? void 0 : flatItem.parentProduct : flatItem === null || flatItem === void 0 ? void 0 : flatItem.product;
|
|
@@ -1281,7 +1315,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1281
1315
|
}
|
|
1282
1316
|
|
|
1283
1317
|
// 判断优惠券是否适用于该商品
|
|
1284
|
-
if (isAvailableProduct && !isItemRewardProductDiscount && isLimitedProduct && timeLimit && isBundleAvailable && (_discount$
|
|
1318
|
+
if (isAvailableProduct && !isItemRewardProductDiscount && !isGiftWithoutDeductibleAmount(flatItem, discount) && isLimitedProduct && timeLimit && isBundleAvailable && (_discount$config6 = discount.config) !== null && _discount$config6 !== void 0 && _discount$config6.isAvailable && (isFullCoveragePass(discount) || isDiscountCardPriceAvailable(flatItem, discount)) && (!isEntitlementPass(discount) || getRemainingEntitlementUses(discount, 0, 1) > 0)) {
|
|
1285
1319
|
var _discountApplicabilit, _discount$metadata4, _discount$metadata5, _discount$metadata6;
|
|
1286
1320
|
// 记录此优惠券适用的商品
|
|
1287
1321
|
(_discountApplicabilit = discountApplicability.get(discount.id)) === null || _discountApplicabilit === void 0 || _discountApplicabilit.push(product.id);
|
|
@@ -1335,20 +1369,20 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1335
1369
|
};
|
|
1336
1370
|
var optionDiscountAmount = 0;
|
|
1337
1371
|
var discountedOptions = options.map(function (option) {
|
|
1338
|
-
var
|
|
1372
|
+
var _ref18, _ref19, _option$_original_pri2, _ref20, _option$num2, _rest$price, _option$_original_pri3;
|
|
1339
1373
|
// 折前单价:优先 price,缺失再 add_price;已写回折后价时用 _original_price(或旧字段 _original_add_price)
|
|
1340
|
-
var rawUnit = (
|
|
1374
|
+
var rawUnit = (_ref18 = (_ref19 = (_option$_original_pri2 = option._original_price) !== null && _option$_original_pri2 !== void 0 ? _option$_original_pri2 : option._original_add_price) !== null && _ref19 !== void 0 ? _ref19 : option.price) !== null && _ref18 !== void 0 ? _ref18 : option.add_price;
|
|
1341
1375
|
var baseUnitNum = Number(rawUnit !== null && rawUnit !== void 0 ? rawUnit : 0);
|
|
1342
1376
|
if (baseUnitNum <= 0) return option;
|
|
1343
1377
|
var discountedPrice = getDiscountAmount(discount, baseUnitNum, baseUnitNum);
|
|
1344
|
-
var optQty = Number((
|
|
1378
|
+
var optQty = Number((_ref20 = (_option$num2 = option.num) !== null && _option$num2 !== void 0 ? _option$num2 : option.quantity) !== null && _ref20 !== void 0 ? _ref20 : 1);
|
|
1345
1379
|
optionDiscountAmount = new Decimal(optionDiscountAmount).plus(new Decimal(baseUnitNum).minus(discountedPrice).mul(optQty)).toNumber();
|
|
1346
1380
|
var _original_add_price = option._original_add_price,
|
|
1347
1381
|
rest = _objectWithoutProperties(option, _excluded);
|
|
1348
1382
|
var tmpl = (_rest$price = rest.price) !== null && _rest$price !== void 0 ? _rest$price : rest.add_price;
|
|
1349
1383
|
var nextPrice = typeof tmpl === 'string' ? String(discountedPrice) : discountedPrice;
|
|
1350
1384
|
return _objectSpread(_objectSpread({}, rest), {}, {
|
|
1351
|
-
_original_price: (_option$
|
|
1385
|
+
_original_price: (_option$_original_pri3 = option._original_price) !== null && _option$_original_pri3 !== void 0 ? _option$_original_pri3 : _original_add_price !== undefined ? _original_add_price : rawUnit,
|
|
1352
1386
|
price: nextPrice
|
|
1353
1387
|
});
|
|
1354
1388
|
});
|
|
@@ -1375,9 +1409,9 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1375
1409
|
var getOptionTotal = function getOptionTotal(options) {
|
|
1376
1410
|
if (!(options !== null && options !== void 0 && options.length)) return 0;
|
|
1377
1411
|
return options.reduce(function (sum, opt) {
|
|
1378
|
-
var
|
|
1379
|
-
var unit = Number((
|
|
1380
|
-
var n = Number((
|
|
1412
|
+
var _ref21, _opt$price, _ref22, _opt$num;
|
|
1413
|
+
var unit = Number((_ref21 = (_opt$price = opt.price) !== null && _opt$price !== void 0 ? _opt$price : opt.add_price) !== null && _ref21 !== void 0 ? _ref21 : 0);
|
|
1414
|
+
var n = Number((_ref22 = (_opt$num = opt.num) !== null && _opt$num !== void 0 ? _opt$num : opt.quantity) !== null && _ref22 !== void 0 ? _ref22 : 1);
|
|
1381
1415
|
return new Decimal(sum).plus(new Decimal(unit).mul(n)).toNumber();
|
|
1382
1416
|
}, 0);
|
|
1383
1417
|
};
|
|
@@ -1385,7 +1419,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1385
1419
|
// 然后再处理应用哪些优惠券,此时只考虑filteredDiscountList中的优惠券
|
|
1386
1420
|
// 🔥 使用扁平化后的列表进行处理
|
|
1387
1421
|
sortedFlattenedList.forEach(function (flatItem, index) {
|
|
1388
|
-
var _product10, _originProduct, _originProduct2, _originProduct3, _product$
|
|
1422
|
+
var _product10, _originProduct, _originProduct2, _originProduct3, _product$discount_lis3, _product11;
|
|
1389
1423
|
// 获取商品数据
|
|
1390
1424
|
var product, originProduct;
|
|
1391
1425
|
if (flatItem.type === 'main') {
|
|
@@ -1410,7 +1444,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1410
1444
|
originProduct = flatItem.originProduct;
|
|
1411
1445
|
}
|
|
1412
1446
|
var isPersistedProduct = ((_product10 = product) === null || _product10 === void 0 ? void 0 : _product10.booking_id) || ((_originProduct = originProduct) === null || _originProduct === void 0 ? void 0 : _originProduct.order_detail_id) || ((_originProduct2 = originProduct) === null || _originProduct2 === void 0 ? void 0 : _originProduct2.orderDetailId) || ((_originProduct3 = originProduct) === null || _originProduct3 === void 0 ? void 0 : _originProduct3.booking_id);
|
|
1413
|
-
var hasExistingWalletDiscount = ((_product$
|
|
1447
|
+
var hasExistingWalletDiscount = ((_product$discount_lis3 = product.discount_list) === null || _product$discount_lis3 === void 0 ? void 0 : _product$discount_lis3.length) && ((_product11 = product) === null || _product11 === void 0 || (_product11 = _product11.discount_list) === null || _product11 === void 0 ? void 0 : _product11.every(function (discount) {
|
|
1414
1448
|
var _discount$id, _discount$discount4;
|
|
1415
1449
|
var discountIdentity = (_discount$id = discount.id) !== null && _discount$id !== void 0 ? _discount$id : (_discount$discount4 = discount.discount) === null || _discount$discount4 === void 0 ? void 0 : _discount$discount4.resource_id;
|
|
1416
1450
|
var discountType = discount.tag || discount.type;
|
|
@@ -1431,7 +1465,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1431
1465
|
|
|
1432
1466
|
// 找到适用于此商品的所有优惠券,仅考虑isSelected不为false的优惠券
|
|
1433
1467
|
var applicableDiscounts = sortedDiscountList.filter(function (discount) {
|
|
1434
|
-
var _product$
|
|
1468
|
+
var _product$discount_lis4;
|
|
1469
|
+
if (isGiftWithoutDeductibleAmount(flatItem, discount)) return false;
|
|
1435
1470
|
if (_this5.discountScope && !_this5.discountScope(originProduct, discount)) return false;
|
|
1436
1471
|
if (_this5.isItemRewardProductDiscount(product)) return false;
|
|
1437
1472
|
if (isCardBlockedByPromotion(flatItem, discount)) return false;
|
|
@@ -1445,22 +1480,19 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1445
1480
|
if (!discount.isSelected) return false;
|
|
1446
1481
|
}
|
|
1447
1482
|
if (['entitlement_pass', 'good_pass', 'discount_card', 'product_discount_card'].includes(discountType !== null && discountType !== void 0 ? discountType : '') && !isReapplyEditModeDiscountForProduct) {
|
|
1448
|
-
var _discount$
|
|
1483
|
+
var _discount$config7;
|
|
1449
1484
|
// 如果策略检查后没有config,说明不可用
|
|
1450
|
-
if (discount.config === undefined || !(discount !== null && discount !== void 0 && (_discount$
|
|
1485
|
+
if (discount.config === undefined || !(discount !== null && discount !== void 0 && (_discount$config7 = discount.config) !== null && _discount$config7 !== void 0 && _discount$config7.isAvailable)) {
|
|
1451
1486
|
return false;
|
|
1452
1487
|
}
|
|
1453
1488
|
}
|
|
1454
1489
|
|
|
1455
1490
|
// 如果商品价格为 0,其实不需要使用任何优惠券,直接 return true
|
|
1456
1491
|
// 全额抵扣卡在主商品价格为 0 时不可用。
|
|
1457
|
-
if ((Number(product.price) <= 0 || !product.price) && !((_product$
|
|
1492
|
+
if ((Number(product.price) <= 0 || !product.price) && !((_product$discount_lis4 = product.discount_list) !== null && _product$discount_lis4 !== void 0 && _product$discount_lis4.length) && isFullCoveragePass(discount)) return false;
|
|
1458
1493
|
|
|
1459
|
-
//
|
|
1460
|
-
if ((
|
|
1461
|
-
var _n$discount;
|
|
1462
|
-
return ((_n$discount = n.discount) === null || _n$discount === void 0 ? void 0 : _n$discount.resource_id) === discount.id;
|
|
1463
|
-
})) && !isFullCoveragePass(discount)) return false;
|
|
1494
|
+
// 基础价和策略允许抵扣的 option 都无金额时,折扣卡不可用。
|
|
1495
|
+
if (!isFullCoveragePass(discount) && !isDiscountCardPriceAvailable(flatItem, discount)) return false;
|
|
1464
1496
|
// good_pass 保持一张实例只使用一次。
|
|
1465
1497
|
if ((discount.tag || discount.type) === 'good_pass' && usedDiscounts.get(discount.id)) {
|
|
1466
1498
|
return false;
|
|
@@ -1472,8 +1504,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1472
1504
|
|
|
1473
1505
|
// 🔥 检查 maxUsagePerOrder 限制:同一 product_id 的商品券使用数量不能超过配置值
|
|
1474
1506
|
if (isFullCoveragePass(discount)) {
|
|
1475
|
-
var _discount$
|
|
1476
|
-
var maxUsagePerOrder = (_discount$
|
|
1507
|
+
var _discount$config8;
|
|
1508
|
+
var maxUsagePerOrder = (_discount$config8 = discount.config) === null || _discount$config8 === void 0 ? void 0 : _discount$config8.maxUsagePerOrder;
|
|
1477
1509
|
if (maxUsagePerOrder && maxUsagePerOrder > 0) {
|
|
1478
1510
|
var currentUsedCount = usedProductIdCounts.get(discount.product_id) || 0;
|
|
1479
1511
|
if (currentUsedCount >= maxUsagePerOrder) {
|
|
@@ -1559,8 +1591,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1559
1591
|
isManualDiscount = typeof product.isManualDiscount === 'boolean' ? product.isManualDiscount : ((_product$discount_lis5 = product.discount_list) === null || _product$discount_lis5 === void 0 ? void 0 : _product$discount_lis5.some(function (item) {
|
|
1560
1592
|
return item.type === 'product';
|
|
1561
1593
|
})) || product.total != product.origin_total && (product.bundle || []).every(function (item) {
|
|
1562
|
-
var
|
|
1563
|
-
return !((
|
|
1594
|
+
var _ref23;
|
|
1595
|
+
return !((_ref23 = item.discount_list || []) !== null && _ref23 !== void 0 && _ref23.length);
|
|
1564
1596
|
}) && (!((_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) {
|
|
1565
1597
|
return item.type === 'product';
|
|
1566
1598
|
})));
|
|
@@ -1576,8 +1608,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1576
1608
|
isManualDiscount = typeof parentProduct.isManualDiscount === 'boolean' ? parentProduct.isManualDiscount : ((_parentProduct$discou = parentProduct.discount_list) === null || _parentProduct$discou === void 0 ? void 0 : _parentProduct$discou.some(function (item) {
|
|
1577
1609
|
return item.type === 'product';
|
|
1578
1610
|
})) || parentProduct.total != parentProduct.origin_total && (parentProduct.bundle || []).every(function (item) {
|
|
1579
|
-
var
|
|
1580
|
-
return !((
|
|
1611
|
+
var _ref24;
|
|
1612
|
+
return !((_ref24 = item.discount_list || []) !== null && _ref24 !== void 0 && _ref24.length);
|
|
1581
1613
|
}) && (!((_parentProduct$discou2 = parentProduct.discount_list) !== null && _parentProduct$discou2 !== void 0 && _parentProduct$discou2.length) || (parentProduct === null || parentProduct === void 0 || (_parentProduct$discou3 = parentProduct.discount_list) === null || _parentProduct$discou3 === void 0 || (_parentProduct$discou4 = _parentProduct$discou3.every) === null || _parentProduct$discou4 === void 0 ? void 0 : _parentProduct$discou4.call(_parentProduct$discou3, function (item) {
|
|
1582
1614
|
return item.type === 'product';
|
|
1583
1615
|
})));
|
|
@@ -1589,8 +1621,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1589
1621
|
var _product$discount_lis7;
|
|
1590
1622
|
// 主商品:检查自己的 discount_list
|
|
1591
1623
|
if (flatItem.type === 'main' && (_product$discount_lis7 = product.discount_list) !== null && _product$discount_lis7 !== void 0 && _product$discount_lis7.some(function (item) {
|
|
1592
|
-
var _item$
|
|
1593
|
-
return ((_item$
|
|
1624
|
+
var _item$discount3;
|
|
1625
|
+
return ((_item$discount3 = item.discount) === null || _item$discount3 === void 0 ? void 0 : _item$discount3.resource_id) === options.discountId;
|
|
1594
1626
|
})) {
|
|
1595
1627
|
isManualDiscount = false;
|
|
1596
1628
|
}
|
|
@@ -1598,11 +1630,11 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1598
1630
|
if (flatItem.type === 'bundle') {
|
|
1599
1631
|
var _product$discount_lis8, _flatItem$parentProdu7;
|
|
1600
1632
|
if ((_product$discount_lis8 = product.discount_list) !== null && _product$discount_lis8 !== void 0 && _product$discount_lis8.some(function (item) {
|
|
1601
|
-
var _item$discount3;
|
|
1602
|
-
return ((_item$discount3 = item.discount) === null || _item$discount3 === void 0 ? void 0 : _item$discount3.resource_id) === options.discountId;
|
|
1603
|
-
}) || (_flatItem$parentProdu7 = flatItem.parentProduct) !== null && _flatItem$parentProdu7 !== void 0 && (_flatItem$parentProdu7 = _flatItem$parentProdu7.discount_list) !== null && _flatItem$parentProdu7 !== void 0 && _flatItem$parentProdu7.some(function (item) {
|
|
1604
1633
|
var _item$discount4;
|
|
1605
1634
|
return ((_item$discount4 = item.discount) === null || _item$discount4 === void 0 ? void 0 : _item$discount4.resource_id) === options.discountId;
|
|
1635
|
+
}) || (_flatItem$parentProdu7 = flatItem.parentProduct) !== null && _flatItem$parentProdu7 !== void 0 && (_flatItem$parentProdu7 = _flatItem$parentProdu7.discount_list) !== null && _flatItem$parentProdu7 !== void 0 && _flatItem$parentProdu7.some(function (item) {
|
|
1636
|
+
var _item$discount5;
|
|
1637
|
+
return ((_item$discount5 = item.discount) === null || _item$discount5 === void 0 ? void 0 : _item$discount5.resource_id) === options.discountId;
|
|
1606
1638
|
})) {
|
|
1607
1639
|
isManualDiscount = false;
|
|
1608
1640
|
}
|
|
@@ -1614,8 +1646,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1614
1646
|
if (flatItem.type === 'main' && (_product$discount_lis9 = product.discount_list) !== null && _product$discount_lis9 !== void 0 && _product$discount_lis9.some(function (item) {
|
|
1615
1647
|
var _options$selectedList2;
|
|
1616
1648
|
return options === null || options === void 0 || (_options$selectedList2 = options.selectedList) === null || _options$selectedList2 === void 0 ? void 0 : _options$selectedList2.some(function (n) {
|
|
1617
|
-
var _item$
|
|
1618
|
-
return n.discountId === ((_item$
|
|
1649
|
+
var _item$discount6;
|
|
1650
|
+
return n.discountId === ((_item$discount6 = item.discount) === null || _item$discount6 === void 0 ? void 0 : _item$discount6.resource_id);
|
|
1619
1651
|
});
|
|
1620
1652
|
})) {
|
|
1621
1653
|
isManualDiscount = false;
|
|
@@ -1626,14 +1658,14 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1626
1658
|
if ((_product$discount_lis10 = product.discount_list) !== null && _product$discount_lis10 !== void 0 && _product$discount_lis10.some(function (item) {
|
|
1627
1659
|
var _options$selectedList3;
|
|
1628
1660
|
return options === null || options === void 0 || (_options$selectedList3 = options.selectedList) === null || _options$selectedList3 === void 0 ? void 0 : _options$selectedList3.some(function (n) {
|
|
1629
|
-
var _item$
|
|
1630
|
-
return n.discountId === ((_item$
|
|
1661
|
+
var _item$discount7;
|
|
1662
|
+
return n.discountId === ((_item$discount7 = item.discount) === null || _item$discount7 === void 0 ? void 0 : _item$discount7.resource_id);
|
|
1631
1663
|
});
|
|
1632
1664
|
}) || (_flatItem$parentProdu8 = flatItem.parentProduct) !== null && _flatItem$parentProdu8 !== void 0 && (_flatItem$parentProdu8 = _flatItem$parentProdu8.discount_list) !== null && _flatItem$parentProdu8 !== void 0 && _flatItem$parentProdu8.some(function (item) {
|
|
1633
1665
|
var _options$selectedList4;
|
|
1634
1666
|
return options === null || options === void 0 || (_options$selectedList4 = options.selectedList) === null || _options$selectedList4 === void 0 ? void 0 : _options$selectedList4.some(function (n) {
|
|
1635
|
-
var _item$
|
|
1636
|
-
return n.discountId === ((_item$
|
|
1667
|
+
var _item$discount8;
|
|
1668
|
+
return n.discountId === ((_item$discount8 = item.discount) === null || _item$discount8 === void 0 ? void 0 : _item$discount8.resource_id);
|
|
1637
1669
|
});
|
|
1638
1670
|
})) {
|
|
1639
1671
|
isManualDiscount = false;
|
|
@@ -1670,8 +1702,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1670
1702
|
discount_list: isManualDiscount ? _this5.resolveDiscountListForManualOverride(product.discount_list) : _this5.filterDiscountListByType(product.discount_list, 'promotion')
|
|
1671
1703
|
}))]);
|
|
1672
1704
|
} else {
|
|
1673
|
-
var
|
|
1674
|
-
var total = product.inPromotion ? (
|
|
1705
|
+
var _ref25, _product$_promotion$f, _product13, _product$origin_total;
|
|
1706
|
+
var total = product.inPromotion ? (_ref25 = (_product$_promotion$f = (_product13 = product) === null || _product13 === void 0 || (_product13 = _product13._promotion) === null || _product13 === void 0 ? void 0 : _product13.finalPrice) !== null && _product$_promotion$f !== void 0 ? _product$_promotion$f : product.origin_total) !== null && _ref25 !== void 0 ? _ref25 : product.total : (_product$origin_total = product.origin_total) !== null && _product$origin_total !== void 0 ? _product$origin_total : product.total;
|
|
1675
1707
|
var main_product_selling_price = product.price;
|
|
1676
1708
|
if ((product.discount_list || []).some(function (item) {
|
|
1677
1709
|
return item.type === 'promotion';
|
|
@@ -2378,7 +2410,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2378
2410
|
} else {
|
|
2379
2411
|
// 🔥 没有子商品被拆分,使用原有逻辑
|
|
2380
2412
|
mainProductArr.forEach(function (mainProduct) {
|
|
2381
|
-
var
|
|
2413
|
+
var _ref27, _mainProductData$main, _mainProductData$disc, _mainProductData$disc2, _mainProductData$disc3;
|
|
2382
2414
|
var mainProductData = _this5.hooks.getProduct(mainProduct);
|
|
2383
2415
|
|
|
2384
2416
|
// 重组bundle
|
|
@@ -2393,9 +2425,9 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2393
2425
|
} else {
|
|
2394
2426
|
// 🔥 关键:拆分后的bundle item
|
|
2395
2427
|
processedBundleItems.forEach(function (item) {
|
|
2396
|
-
var _item$price,
|
|
2428
|
+
var _item$price, _ref26, _item$bundle_selling_;
|
|
2397
2429
|
var nextBundlePrice = (_item$price = item.price) !== null && _item$price !== void 0 ? _item$price : bundleItem.price;
|
|
2398
|
-
var nextBundleSellingPrice = (
|
|
2430
|
+
var nextBundleSellingPrice = (_ref26 = (_item$bundle_selling_ = item.bundle_selling_price) !== null && _item$bundle_selling_ !== void 0 ? _item$bundle_selling_ : item.price) !== null && _ref26 !== void 0 ? _ref26 : bundleItem.bundle_selling_price;
|
|
2399
2431
|
// 🔥 更新 discount_list 中的 num,使其与拆分后的 item.num 一致
|
|
2400
2432
|
var updatedDiscountList = (item.discount_list || []).map(function (discount) {
|
|
2401
2433
|
var _discount$metadata11;
|
|
@@ -2422,7 +2454,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2422
2454
|
|
|
2423
2455
|
// 主商品已经在前面的 setProduct 中应用过折扣;这里只替换 bundle,
|
|
2424
2456
|
// 避免把主商品 discount_list 再扣一次。
|
|
2425
|
-
var mainSellingPrice = (
|
|
2457
|
+
var mainSellingPrice = (_ref27 = (_mainProductData$main = mainProductData.main_product_selling_price) !== null && _mainProductData$main !== void 0 ? _mainProductData$main : mainProductData.price) !== null && _ref27 !== void 0 ? _ref27 : 0;
|
|
2426
2458
|
var newTotal = Number(mainSellingPrice || 0);
|
|
2427
2459
|
var newOriginTotal = Number(mainProductData.original_price || mainProductData.price || 0);
|
|
2428
2460
|
|
|
@@ -2626,7 +2658,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2626
2658
|
}, {
|
|
2627
2659
|
key: "checkPackageSubItemUsageRules",
|
|
2628
2660
|
value: function checkPackageSubItemUsageRules(discount, flatItem) {
|
|
2629
|
-
var _flatItem$product, _flatItem$
|
|
2661
|
+
var _flatItem$product, _flatItem$originProdu2, _flatItem$parentProdu10;
|
|
2630
2662
|
var limitedData = discount.limited_relation_product_data;
|
|
2631
2663
|
var usageRules = limitedData === null || limitedData === void 0 ? void 0 : limitedData.package_sub_item_usage_rules;
|
|
2632
2664
|
var rules = ['original_price'].concat(_toConsumableArray((usageRules === null || usageRules === void 0 ? void 0 : usageRules.rules) || []));
|
|
@@ -2638,20 +2670,20 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2638
2670
|
var ruleType = usageRules.type;
|
|
2639
2671
|
// 套餐适用范围配置
|
|
2640
2672
|
var packageScope = usageRules === null || usageRules === void 0 ? void 0 : usageRules.package_scope;
|
|
2641
|
-
var
|
|
2642
|
-
|
|
2643
|
-
scopeType =
|
|
2644
|
-
|
|
2645
|
-
exclude_bundle_product_ids =
|
|
2646
|
-
|
|
2647
|
-
include_bundle_product_ids =
|
|
2648
|
-
|
|
2649
|
-
filter =
|
|
2673
|
+
var _ref28 = packageScope || {},
|
|
2674
|
+
_ref28$type = _ref28.type,
|
|
2675
|
+
scopeType = _ref28$type === void 0 ? 'product_all' : _ref28$type,
|
|
2676
|
+
_ref28$exclude_bundle = _ref28.exclude_bundle_product_ids,
|
|
2677
|
+
exclude_bundle_product_ids = _ref28$exclude_bundle === void 0 ? [] : _ref28$exclude_bundle,
|
|
2678
|
+
_ref28$include_bundle = _ref28.include_bundle_product_ids,
|
|
2679
|
+
include_bundle_product_ids = _ref28$include_bundle === void 0 ? [] : _ref28$include_bundle,
|
|
2680
|
+
_ref28$filter = _ref28.filter,
|
|
2681
|
+
filter = _ref28$filter === void 0 ? 0 : _ref28$filter;
|
|
2650
2682
|
var isMainProduct = flatItem.type === 'main'; // 单独购买
|
|
2651
2683
|
var isBundleItem = flatItem.type === 'bundle'; // 套餐中购买
|
|
2652
2684
|
var bundleMainProductId = (_flatItem$product = flatItem.product) === null || _flatItem$product === void 0 ? void 0 : _flatItem$product.product_id;
|
|
2653
2685
|
// 主商品id
|
|
2654
|
-
var mainProductId = (flatItem === null || flatItem === void 0 || (_flatItem$
|
|
2686
|
+
var mainProductId = (flatItem === null || flatItem === void 0 || (_flatItem$originProdu2 = flatItem.originProduct) === null || _flatItem$originProdu2 === void 0 || (_flatItem$originProdu2 = _flatItem$originProdu2._productOrigin) === null || _flatItem$originProdu2 === void 0 ? void 0 : _flatItem$originProdu2.id) || (flatItem === null || flatItem === void 0 || (_flatItem$parentProdu10 = flatItem.parentProduct) === null || _flatItem$parentProdu10 === void 0 ? void 0 : _flatItem$parentProdu10.id) || 0;
|
|
2655
2687
|
|
|
2656
2688
|
// 主商品直接可用
|
|
2657
2689
|
if (isMainProduct) {
|
|
@@ -14,6 +14,9 @@ export declare class ScheduleModule extends BaseModule implements Module, Schedu
|
|
|
14
14
|
private scheduleListRequestVersion;
|
|
15
15
|
private scheduleCatalogScope;
|
|
16
16
|
private otherParams;
|
|
17
|
+
private catalogVersion;
|
|
18
|
+
private destroyed;
|
|
19
|
+
private availabilityRequestVersion;
|
|
17
20
|
constructor(name?: string, version?: string);
|
|
18
21
|
initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
|
|
19
22
|
/**
|
|
@@ -34,12 +37,15 @@ export declare class ScheduleModule extends BaseModule implements Module, Schedu
|
|
|
34
37
|
loadAllSchedule(options?: {
|
|
35
38
|
useCache?: boolean;
|
|
36
39
|
}): Promise<void>;
|
|
40
|
+
getScheduleCatalogVersion(): number;
|
|
41
|
+
/** Resolve only after the current scope has a successful catalog. */
|
|
42
|
+
ensureScheduleReady(): Promise<void>;
|
|
37
43
|
private loadScheduleCatalog;
|
|
38
44
|
setScheduleList(list: ScheduleItem[]): void;
|
|
39
45
|
private syncScheduleMap;
|
|
40
46
|
getScheduleList(): ScheduleItem[];
|
|
41
47
|
isScheduleListLoaded(): boolean;
|
|
42
|
-
loadScheduleAvailableDate({ startDate, endDate, custom_page_id, channel, }: LoadScheduleAvailableDateParams): Promise<import("../Date/types").ITime[]>;
|
|
48
|
+
loadScheduleAvailableDate({ startDate, endDate, custom_page_id, channel, assertCurrent, }: LoadScheduleAvailableDateParams): Promise<import("../Date/types").ITime[]>;
|
|
43
49
|
getScheduleListByIds(ids: number[]): ScheduleItem[];
|
|
44
50
|
setAvailabilityScheduleDateList(list: ScheduleAvailabilityDateItem[]): void;
|
|
45
51
|
getAvailabilityScheduleDateList(): ScheduleAvailabilityDateItem[];
|