@pisell/pisellos 2.3.187 → 2.3.190
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/BookingContext/utils/productExtend.d.ts +9 -1
- package/dist/modules/BookingContext/utils/productExtend.js +47 -13
- package/dist/modules/Order/index.d.ts +15 -5
- package/dist/modules/Order/index.js +1161 -921
- package/dist/modules/Order/types.d.ts +16 -4
- package/dist/modules/Order/utils.d.ts +1 -3
- package/dist/modules/Order/utils.js +2 -5
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/ResourcePlanner/planner.js +29 -2
- package/dist/modules/ResourcePlanner/types.d.ts +6 -0
- package/dist/modules/Rules/index.js +19 -30
- package/dist/solution/BaseSales/index.d.ts +4 -0
- package/dist/solution/BaseSales/index.js +204 -176
- package/dist/solution/BaseSales/types.d.ts +1 -0
- package/dist/solution/BaseSales/types.js +1 -0
- package/dist/solution/BookingByStep/index.d.ts +2 -2
- package/dist/solution/BookingByStep/index.js +8 -5
- package/dist/solution/BookingByStep/utils/resources.d.ts +10 -0
- package/dist/solution/BookingByStep/utils/resources.js +117 -76
- package/dist/solution/BookingTicket/index.js +52 -31
- package/dist/solution/UnifiedBookingSales/index.d.ts +3 -0
- package/dist/solution/UnifiedBookingSales/index.js +279 -204
- package/dist/solution/UnifiedBookingSales/types.d.ts +6 -1
- package/lib/modules/BookingContext/utils/productExtend.d.ts +9 -1
- package/lib/modules/BookingContext/utils/productExtend.js +38 -5
- package/lib/modules/Order/index.d.ts +15 -5
- package/lib/modules/Order/index.js +167 -21
- package/lib/modules/Order/types.d.ts +16 -4
- package/lib/modules/Order/utils.d.ts +1 -3
- package/lib/modules/Order/utils.js +2 -5
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/ResourcePlanner/planner.js +25 -1
- package/lib/modules/ResourcePlanner/types.d.ts +6 -0
- package/lib/modules/Rules/index.js +9 -19
- package/lib/solution/BaseSales/index.d.ts +4 -0
- package/lib/solution/BaseSales/index.js +14 -0
- package/lib/solution/BaseSales/types.d.ts +1 -0
- package/lib/solution/BaseSales/types.js +1 -0
- package/lib/solution/BookingByStep/index.d.ts +2 -2
- package/lib/solution/BookingByStep/index.js +8 -2
- package/lib/solution/BookingByStep/utils/resources.d.ts +10 -0
- package/lib/solution/BookingByStep/utils/resources.js +25 -15
- package/lib/solution/BookingTicket/index.js +8 -2
- package/lib/solution/UnifiedBookingSales/index.d.ts +3 -0
- package/lib/solution/UnifiedBookingSales/index.js +80 -15
- package/lib/solution/UnifiedBookingSales/types.d.ts +6 -1
- package/package.json +1 -1
|
@@ -449,6 +449,17 @@ export interface ReplaceTempOrderOptions {
|
|
|
449
449
|
recalculateSummary?: boolean;
|
|
450
450
|
persist?: boolean;
|
|
451
451
|
saveDraft?: boolean;
|
|
452
|
+
/** Internal same-order updates may explicitly retain an anonymous order's session. */
|
|
453
|
+
preserveOrderSessionId?: string;
|
|
454
|
+
}
|
|
455
|
+
export interface OrderSessionChangedPayload {
|
|
456
|
+
sessionId: string | null;
|
|
457
|
+
previousSessionId: string | null;
|
|
458
|
+
}
|
|
459
|
+
export interface HydrateTempOrderOptions {
|
|
460
|
+
recalcOnHydrate?: boolean;
|
|
461
|
+
source?: 'salesDetail' | 'mergedSalesDetail' | 'sessionStorage';
|
|
462
|
+
preserveOrderSessionId?: string;
|
|
452
463
|
}
|
|
453
464
|
export type AddProductBookingInput = Record<string, any>;
|
|
454
465
|
/**
|
|
@@ -869,6 +880,10 @@ export interface OrderModuleAPI {
|
|
|
869
880
|
salesSummaryModuleName?: string;
|
|
870
881
|
}) => void;
|
|
871
882
|
getTempOrder: () => OrderTempOrder | null;
|
|
883
|
+
/** Runtime-only identity; never part of an order or a persisted draft. */
|
|
884
|
+
getOrderSessionId: () => string | null;
|
|
885
|
+
/** Also rejects a session while an asynchronous order replacement is pending. */
|
|
886
|
+
isOrderSessionCurrent: (sessionId: string) => boolean;
|
|
872
887
|
ensureTempOrder: () => OrderTempOrder;
|
|
873
888
|
replaceTempOrder: (tempOrder: OrderTempOrder, options?: ReplaceTempOrderOptions) => Promise<OrderTempOrder>;
|
|
874
889
|
addNewOrder: () => Promise<OrderTempOrder>;
|
|
@@ -999,10 +1014,7 @@ export interface OrderModuleAPI {
|
|
|
999
1014
|
}) => OrderPaymentData[];
|
|
1000
1015
|
sendCustomerPayLink: <T = any>(params: SendCustomerPayLinkParams) => Promise<T>;
|
|
1001
1016
|
saveDraft: () => Promise<void>;
|
|
1002
|
-
hydrateTempOrderFromRecord: (record: Record<string, any>, options?:
|
|
1003
|
-
recalcOnHydrate?: boolean;
|
|
1004
|
-
source?: 'salesDetail' | 'mergedSalesDetail' | 'sessionStorage';
|
|
1005
|
-
}) => Promise<OrderTempOrder>;
|
|
1017
|
+
hydrateTempOrderFromRecord: (record: Record<string, any>, options?: HydrateTempOrderOptions) => Promise<OrderTempOrder>;
|
|
1006
1018
|
syncPaymentsToOrder: <T = any>(params: SyncPaymentsToOrderParams) => Promise<SyncPaymentsToOrderResult<T>>;
|
|
1007
1019
|
getSalesOrderByLookup: (params: SalesOrderLookupParams) => Promise<any>;
|
|
1008
1020
|
getLastOrderInfo: () => Record<string, any> | undefined;
|
|
@@ -128,9 +128,7 @@ export declare function getBundleSellingMagnitude(bundle: Record<string, any> |
|
|
|
128
128
|
*
|
|
129
129
|
* Rules 钩子契约(hook_adapt 方案,Rules 内部保持不变):
|
|
130
130
|
* - `getProduct.price` / `getProduct.original_price` 回传 **source-level 主价**
|
|
131
|
-
* (`metadata.source_product_price
|
|
132
|
-
* 赠品基础价已被赠送优惠抵扣,只有收费 option / bundle 继续按卡券规则计算。
|
|
133
|
-
* Rules 内部 `getProductTotalPrice` /
|
|
131
|
+
* (`metadata.source_product_price`)。Rules 内部 `getProductTotalPrice` /
|
|
134
132
|
* `getProductOriginTotalPrice` 会自行叠加 option + bundle,喂 source 可避免 option 双加。
|
|
135
133
|
* - `getProduct.total` = `selling_price × num`(行 composite × num),与 Rules 内部产出的
|
|
136
134
|
* total(source + option + bundle)对齐。
|
|
@@ -597,9 +597,7 @@ export function getBundleSellingMagnitude(bundle) {
|
|
|
597
597
|
*
|
|
598
598
|
* Rules 钩子契约(hook_adapt 方案,Rules 内部保持不变):
|
|
599
599
|
* - `getProduct.price` / `getProduct.original_price` 回传 **source-level 主价**
|
|
600
|
-
* (`metadata.source_product_price
|
|
601
|
-
* 赠品基础价已被赠送优惠抵扣,只有收费 option / bundle 继续按卡券规则计算。
|
|
602
|
-
* Rules 内部 `getProductTotalPrice` /
|
|
600
|
+
* (`metadata.source_product_price`)。Rules 内部 `getProductTotalPrice` /
|
|
603
601
|
* `getProductOriginTotalPrice` 会自行叠加 option + bundle,喂 source 可避免 option 双加。
|
|
604
602
|
* - `getProduct.total` = `selling_price × num`(行 composite × num),与 Rules 内部产出的
|
|
605
603
|
* total(source + option + bundle)对齐。
|
|
@@ -903,8 +901,7 @@ export function createDefaultOrderRulesHooks(getBookings, getHolderRelations) {
|
|
|
903
901
|
_id: (_product$metadata7 = product.metadata) !== null && _product$metadata7 !== void 0 && _product$metadata7.unique_identification_number ? "".concat(product.product_id, "_").concat(product.product_variant_id, "_").concat(product.metadata.unique_identification_number) : "".concat(product.product_id, "_").concat(product.product_variant_id, "_").concat(buildProductLineFingerprint(getProductSkuOptions(product), product.product_bundle)),
|
|
904
902
|
// Rules 内部 getProductTotalPrice / getProductOriginTotalPrice 会各自再叠加 bundle + option,
|
|
905
903
|
// 所以这里必须喂 source-level(不含 option、不含 bundle、不含折扣)单价,避免双加 option。
|
|
906
|
-
|
|
907
|
-
price: metadataAny._giftInfo ? '0.00' : sourcePrice,
|
|
904
|
+
price: sourcePrice,
|
|
908
905
|
// total / origin_total 使用 composite × num,跟 Rules 内部产出的 total 对齐(含 option + bundle)。
|
|
909
906
|
total: new Decimal(product.selling_price || 0).times(product.num || 1).toNumber(),
|
|
910
907
|
origin_total: new Decimal(product.original_price || product.selling_price || 0).times(product.num || 1).toNumber(),
|
|
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
|
|
|
49
49
|
getCategories(): ProductCategory[];
|
|
50
50
|
setOtherParams(key: string, value: any): void;
|
|
51
51
|
getOtherParams(): any;
|
|
52
|
-
getProductType(): "
|
|
52
|
+
getProductType(): "duration" | "normal" | "session";
|
|
53
53
|
}
|
|
@@ -243,6 +243,16 @@ function isCandidateFromExcludedScheduleDate(params) {
|
|
|
243
243
|
return getProductTimeRangeIdentity(range) === candidateIdentity;
|
|
244
244
|
});
|
|
245
245
|
}
|
|
246
|
+
function resolveRememberedDurationRange(product, value, timezoneName) {
|
|
247
|
+
if (value === undefined) return null;
|
|
248
|
+
var range = normalizeAbsoluteRange(value, timezoneName);
|
|
249
|
+
if (!range || range.end <= range.start) {
|
|
250
|
+
throw availabilityError('INVALID_TARGET_FILTER', '记忆时间必须包含有效且递增的开始和结束时间');
|
|
251
|
+
}
|
|
252
|
+
if (product.kind !== 'duration') return null;
|
|
253
|
+
if (!product.isFlexibleDuration && (!Number.isFinite(product.durationMinutes) || range.end - range.start !== Number(product.durationMinutes) * 60000)) return null;
|
|
254
|
+
return range;
|
|
255
|
+
}
|
|
246
256
|
function evaluateCandidateTimeGate(params) {
|
|
247
257
|
var projection = params.projection,
|
|
248
258
|
product = params.product,
|
|
@@ -314,6 +324,11 @@ function evaluateCandidateTimeGate(params) {
|
|
|
314
324
|
};
|
|
315
325
|
}
|
|
316
326
|
if (policy.type === 'before_start') {
|
|
327
|
+
var _evaluationContext$re;
|
|
328
|
+
var rememberedRange = resolveRememberedDurationRange(product, (_evaluationContext$re = evaluationContext.rememberedTimeByProductId) === null || _evaluationContext$re === void 0 ? void 0 : _evaluationContext$re[String(product.id)], timezoneName);
|
|
329
|
+
// Only the exact order-scoped interval may retain its start after this
|
|
330
|
+
// cutoff. The end/past and operating-window gates above still apply.
|
|
331
|
+
if ((rememberedRange === null || rememberedRange === void 0 ? void 0 : rememberedRange.start) === candidateRange.start && rememberedRange.end === candidateRange.end) return null;
|
|
317
332
|
// POS fixed-duration candidates use the context's stable opening-minute
|
|
318
333
|
// anchor. Keep that anchored range selectable while it is still active;
|
|
319
334
|
// otherwise a minute refresh turns it into 0 capacity and incorrectly
|
|
@@ -1172,7 +1187,7 @@ export function getDurationBusinessDate(projection, startAt) {
|
|
|
1172
1187
|
return (period === null || period === void 0 ? void 0 : period.businessDate) || startAt.slice(0, 10);
|
|
1173
1188
|
}
|
|
1174
1189
|
function getAlignedDurationRanges(params) {
|
|
1175
|
-
var _request$rememberedSt, _request$editingStart;
|
|
1190
|
+
var _request$rememberedSt, _request$rememberedTi, _request$editingStart;
|
|
1176
1191
|
var projection = params.projection,
|
|
1177
1192
|
product = params.product,
|
|
1178
1193
|
request = params.request,
|
|
@@ -1314,6 +1329,14 @@ function getAlignedDurationRanges(params) {
|
|
|
1314
1329
|
addRange(start, start + duration * 60000);
|
|
1315
1330
|
}
|
|
1316
1331
|
}
|
|
1332
|
+
var rememberedRange = resolveRememberedDurationRange(product, (_request$rememberedTi = request.rememberedTimeByProductId) === null || _request$rememberedTi === void 0 ? void 0 : _request$rememberedTi[String(product.id)], projection.meta.timezone);
|
|
1333
|
+
if (rememberedRange && baseRanges.some(function (range) {
|
|
1334
|
+
return contains(range, rememberedRange);
|
|
1335
|
+
})) {
|
|
1336
|
+
// Never extend a remembered flexible interval when the resource now has a
|
|
1337
|
+
// later closing time, or rebuild a fixed interval after its duration changed.
|
|
1338
|
+
addRange(rememberedRange.start, rememberedRange.end);
|
|
1339
|
+
}
|
|
1317
1340
|
var editingAt = (_request$editingStart = request.editingStartAtByProductId) === null || _request$editingStart === void 0 ? void 0 : _request$editingStart[String(product.id)];
|
|
1318
1341
|
if (editingAt !== undefined) {
|
|
1319
1342
|
var _request$durationMinu3;
|
|
@@ -1726,7 +1749,8 @@ function buildEvaluationContext(params) {
|
|
|
1726
1749
|
durationCandidateAnchorAtMs: Number.isFinite(durationCandidateAnchorAt) ? floorToMinute(durationCandidateAnchorAt) : null,
|
|
1727
1750
|
allowExcludedScheduleDateOverride: params.allowExcludedScheduleDateOverride === true,
|
|
1728
1751
|
useDurationTimeGrid: params.useDurationTimeGrid === true,
|
|
1729
|
-
enforceSaleCutoff: params.enforceSaleCutoff === true
|
|
1752
|
+
enforceSaleCutoff: params.enforceSaleCutoff === true,
|
|
1753
|
+
rememberedTimeByProductId: params.rememberedTimeByProductId
|
|
1730
1754
|
};
|
|
1731
1755
|
}
|
|
1732
1756
|
function summarizeStatuses(statuses) {
|
|
@@ -2216,6 +2240,7 @@ export function queryAvailabilityProjection(projection, request) {
|
|
|
2216
2240
|
resourceIds: request.resourceIds,
|
|
2217
2241
|
useDurationTimeGrid: runtimeOptions.useDurationTimeGrid,
|
|
2218
2242
|
enforceSaleCutoff: runtimeOptions.enforceSaleCutoff,
|
|
2243
|
+
rememberedTimeByProductId: runtimeOptions.rememberedTimeByProductId,
|
|
2219
2244
|
useExactDurationCandidateMinute: runtimeOptions.useExactDurationCandidateMinute,
|
|
2220
2245
|
allowExcludedScheduleDateOverride: runtimeOptions.allowExcludedScheduleDateOverride
|
|
2221
2246
|
});
|
|
@@ -2308,6 +2333,7 @@ export function queryAvailabilityProjection(projection, request) {
|
|
|
2308
2333
|
evaluatedAt: evaluatedAt,
|
|
2309
2334
|
useDurationTimeGrid: runtimeOptions.useDurationTimeGrid,
|
|
2310
2335
|
enforceSaleCutoff: runtimeOptions.enforceSaleCutoff,
|
|
2336
|
+
rememberedTimeByProductId: runtimeOptions.rememberedTimeByProductId,
|
|
2311
2337
|
useExactDurationCandidateMinute: runtimeOptions.useExactDurationCandidateMinute,
|
|
2312
2338
|
allowExcludedScheduleDateOverride: runtimeOptions.allowExcludedScheduleDateOverride
|
|
2313
2339
|
});
|
|
@@ -2542,6 +2568,7 @@ export function validateAvailabilitySelection(projection, params) {
|
|
|
2542
2568
|
requirementSelections: params.requirementSelections,
|
|
2543
2569
|
useDurationTimeGrid: runtimeOptions.useDurationTimeGrid,
|
|
2544
2570
|
enforceSaleCutoff: runtimeOptions.enforceSaleCutoff,
|
|
2571
|
+
rememberedTimeByProductId: runtimeOptions.rememberedTimeByProductId,
|
|
2545
2572
|
useExactDurationCandidateMinute: runtimeOptions.useExactDurationCandidateMinute,
|
|
2546
2573
|
allowExcludedScheduleDateOverride: runtimeOptions.allowExcludedScheduleDateOverride
|
|
2547
2574
|
})
|
|
@@ -265,6 +265,10 @@ export interface GetProductTimeRangesRequest {
|
|
|
265
265
|
durationStartTimesByProductId?: Record<string, string[]>;
|
|
266
266
|
/** Restore only the exact remembered start; recompute the end from current product/windows. */
|
|
267
267
|
rememberedStartAtByProductId?: Record<string, string>;
|
|
268
|
+
/** Order-scoped v2 memory preserves the complete actual booking interval. */
|
|
269
|
+
rememberedTimeByProductId?: Record<string, AvailabilityAbsoluteRange>;
|
|
270
|
+
/** Required by the POS facade before accepting v2 remembered intervals. */
|
|
271
|
+
orderSessionId?: string;
|
|
268
272
|
/** Edit only: preserve the full actual start plus an explicit durationMinutesByProductId. */
|
|
269
273
|
editingStartAtByProductId?: Record<string, string>;
|
|
270
274
|
/**
|
|
@@ -279,6 +283,8 @@ export interface GetProductTimeRangesRuntimeOptions {
|
|
|
279
283
|
useDurationTimeGrid?: boolean;
|
|
280
284
|
/** Automatic remembered selection must not use POS opening-minute cutoff exceptions. */
|
|
281
285
|
enforceSaleCutoff?: boolean;
|
|
286
|
+
/** Internal POS capability, validated against the current order session by the facade. */
|
|
287
|
+
rememberedTimeByProductId?: Record<string, AvailabilityAbsoluteRange>;
|
|
282
288
|
/**
|
|
283
289
|
* Internal POS capability: fixed-duration candidates start from the stable
|
|
284
290
|
* context anchor's current minute instead of rounding up to ten minutes, and
|
|
@@ -1222,28 +1222,10 @@ 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
1225
|
|
|
1244
1226
|
// 可用性和实际应用共用金额判断;零基础价商品可按策略抵扣收费 option。
|
|
1245
1227
|
var isDiscountCardPriceAvailable = function isDiscountCardPriceAvailable(flatItem, discount) {
|
|
1246
|
-
var _product$discount_lis2, _discount$
|
|
1228
|
+
var _product$discount_lis2, _discount$config4;
|
|
1247
1229
|
var product = flatItem.type === 'main' ? flatItem.product : flatItem.bundleItem;
|
|
1248
1230
|
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
1231
|
var _item$discount2;
|
|
@@ -1251,10 +1233,18 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1251
1233
|
})) {
|
|
1252
1234
|
return true;
|
|
1253
1235
|
}
|
|
1254
|
-
if (flatItem.type !== 'main' || Number(flatItem.price) !== 0 || !['discount_card', 'product_discount_card'].includes(discount.tag || discount.type || '') || !((_discount$
|
|
1236
|
+
if (flatItem.type !== 'main' || Number(flatItem.price) !== 0 || !['discount_card', 'product_discount_card'].includes(discount.tag || discount.type || '') || !((_discount$config4 = discount.config) !== null && _discount$config4 !== void 0 && _discount$config4.deductOptionPrice) || isOrderLevelFixedAmountDiscount(discount)) {
|
|
1255
1237
|
return false;
|
|
1256
1238
|
}
|
|
1257
|
-
return
|
|
1239
|
+
return (product.options || []).reduce(function (total, option) {
|
|
1240
|
+
var _ref14, _ref15, _ref16, _option$_original_pri, _ref17, _option$num;
|
|
1241
|
+
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);
|
|
1242
|
+
var quantity = Number((_ref17 = (_option$num = option.num) !== null && _option$num !== void 0 ? _option$num : option.quantity) !== null && _ref17 !== void 0 ? _ref17 : 1);
|
|
1243
|
+
if (!Number.isFinite(unitPrice) || !Number.isFinite(quantity) || quantity <= 0) {
|
|
1244
|
+
return total;
|
|
1245
|
+
}
|
|
1246
|
+
return total.plus(new Decimal(unitPrice).mul(quantity));
|
|
1247
|
+
}, new Decimal(0)).greaterThan(0);
|
|
1258
1248
|
};
|
|
1259
1249
|
|
|
1260
1250
|
// 首先遍历所有商品和所有优惠券,确定每个优惠券的适用范围,包括isSelected为false的优惠券
|
|
@@ -1284,7 +1274,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1284
1274
|
}
|
|
1285
1275
|
var isItemRewardProductDiscount = _this5.isItemRewardProductDiscount(product);
|
|
1286
1276
|
addModeDiscount.forEach(function (discount) {
|
|
1287
|
-
var _product6, _product7, _product8, _product9, _flatItem$bundleItem3, _flatItem$bundleItem4, _discount$
|
|
1277
|
+
var _product6, _product7, _product8, _product9, _flatItem$bundleItem3, _flatItem$bundleItem4, _discount$config5;
|
|
1288
1278
|
var limitedData = discount === null || discount === void 0 ? void 0 : discount.limited_relation_product_data;
|
|
1289
1279
|
// 拿到discount配置的holder信息 product信息 product.holder 加在 isLimitedProduct
|
|
1290
1280
|
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;
|
|
@@ -1315,7 +1305,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1315
1305
|
}
|
|
1316
1306
|
|
|
1317
1307
|
// 判断优惠券是否适用于该商品
|
|
1318
|
-
if (isAvailableProduct && !isItemRewardProductDiscount &&
|
|
1308
|
+
if (isAvailableProduct && !isItemRewardProductDiscount && isLimitedProduct && timeLimit && isBundleAvailable && (_discount$config5 = discount.config) !== null && _discount$config5 !== void 0 && _discount$config5.isAvailable && (isFullCoveragePass(discount) || isDiscountCardPriceAvailable(flatItem, discount)) && (!isEntitlementPass(discount) || getRemainingEntitlementUses(discount, 0, 1) > 0)) {
|
|
1319
1309
|
var _discountApplicabilit, _discount$metadata4, _discount$metadata5, _discount$metadata6;
|
|
1320
1310
|
// 记录此优惠券适用的商品
|
|
1321
1311
|
(_discountApplicabilit = discountApplicability.get(discount.id)) === null || _discountApplicabilit === void 0 || _discountApplicabilit.push(product.id);
|
|
@@ -1466,7 +1456,6 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1466
1456
|
// 找到适用于此商品的所有优惠券,仅考虑isSelected不为false的优惠券
|
|
1467
1457
|
var applicableDiscounts = sortedDiscountList.filter(function (discount) {
|
|
1468
1458
|
var _product$discount_lis4;
|
|
1469
|
-
if (isGiftWithoutDeductibleAmount(flatItem, discount)) return false;
|
|
1470
1459
|
if (_this5.discountScope && !_this5.discountScope(originProduct, discount)) return false;
|
|
1471
1460
|
if (_this5.isItemRewardProductDiscount(product)) return false;
|
|
1472
1461
|
if (isCardBlockedByPromotion(flatItem, discount)) return false;
|
|
@@ -1480,9 +1469,9 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1480
1469
|
if (!discount.isSelected) return false;
|
|
1481
1470
|
}
|
|
1482
1471
|
if (['entitlement_pass', 'good_pass', 'discount_card', 'product_discount_card'].includes(discountType !== null && discountType !== void 0 ? discountType : '') && !isReapplyEditModeDiscountForProduct) {
|
|
1483
|
-
var _discount$
|
|
1472
|
+
var _discount$config6;
|
|
1484
1473
|
// 如果策略检查后没有config,说明不可用
|
|
1485
|
-
if (discount.config === undefined || !(discount !== null && discount !== void 0 && (_discount$
|
|
1474
|
+
if (discount.config === undefined || !(discount !== null && discount !== void 0 && (_discount$config6 = discount.config) !== null && _discount$config6 !== void 0 && _discount$config6.isAvailable)) {
|
|
1486
1475
|
return false;
|
|
1487
1476
|
}
|
|
1488
1477
|
}
|
|
@@ -1504,8 +1493,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1504
1493
|
|
|
1505
1494
|
// 🔥 检查 maxUsagePerOrder 限制:同一 product_id 的商品券使用数量不能超过配置值
|
|
1506
1495
|
if (isFullCoveragePass(discount)) {
|
|
1507
|
-
var _discount$
|
|
1508
|
-
var maxUsagePerOrder = (_discount$
|
|
1496
|
+
var _discount$config7;
|
|
1497
|
+
var maxUsagePerOrder = (_discount$config7 = discount.config) === null || _discount$config7 === void 0 ? void 0 : _discount$config7.maxUsagePerOrder;
|
|
1509
1498
|
if (maxUsagePerOrder && maxUsagePerOrder > 0) {
|
|
1510
1499
|
var currentUsedCount = usedProductIdCounts.get(discount.product_id) || 0;
|
|
1511
1500
|
if (currentUsedCount >= maxUsagePerOrder) {
|
|
@@ -2658,7 +2647,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2658
2647
|
}, {
|
|
2659
2648
|
key: "checkPackageSubItemUsageRules",
|
|
2660
2649
|
value: function checkPackageSubItemUsageRules(discount, flatItem) {
|
|
2661
|
-
var _flatItem$product, _flatItem$
|
|
2650
|
+
var _flatItem$product, _flatItem$originProdu, _flatItem$parentProdu10;
|
|
2662
2651
|
var limitedData = discount.limited_relation_product_data;
|
|
2663
2652
|
var usageRules = limitedData === null || limitedData === void 0 ? void 0 : limitedData.package_sub_item_usage_rules;
|
|
2664
2653
|
var rules = ['original_price'].concat(_toConsumableArray((usageRules === null || usageRules === void 0 ? void 0 : usageRules.rules) || []));
|
|
@@ -2683,7 +2672,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2683
2672
|
var isBundleItem = flatItem.type === 'bundle'; // 套餐中购买
|
|
2684
2673
|
var bundleMainProductId = (_flatItem$product = flatItem.product) === null || _flatItem$product === void 0 ? void 0 : _flatItem$product.product_id;
|
|
2685
2674
|
// 主商品id
|
|
2686
|
-
var mainProductId = (flatItem === null || flatItem === void 0 || (_flatItem$
|
|
2675
|
+
var mainProductId = (flatItem === null || flatItem === void 0 || (_flatItem$originProdu = flatItem.originProduct) === null || _flatItem$originProdu === void 0 || (_flatItem$originProdu = _flatItem$originProdu._productOrigin) === null || _flatItem$originProdu === void 0 ? void 0 : _flatItem$originProdu.id) || (flatItem === null || flatItem === void 0 || (_flatItem$parentProdu10 = flatItem.parentProduct) === null || _flatItem$parentProdu10 === void 0 ? void 0 : _flatItem$parentProdu10.id) || 0;
|
|
2687
2676
|
|
|
2688
2677
|
// 主商品直接可用
|
|
2689
2678
|
if (isMainProduct) {
|
|
@@ -82,6 +82,7 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
82
82
|
private salesDetailHydrateQueue;
|
|
83
83
|
private serverOrderChangeUnsubscribe;
|
|
84
84
|
private paymentMethodsChangedUnsubscribe;
|
|
85
|
+
private orderSessionChangedUnsubscribe;
|
|
85
86
|
private serverOrderChangeHydrateInFlight;
|
|
86
87
|
private queuedServerOrderChanges;
|
|
87
88
|
private serverOrderChangeSyncEnabled;
|
|
@@ -116,6 +117,7 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
116
117
|
private syncCurrentSalesDetailFromServerOrderChange;
|
|
117
118
|
private registerServerOrderChangeSync;
|
|
118
119
|
private registerPaymentMethodsChangeSync;
|
|
120
|
+
private registerOrderSessionChangeSync;
|
|
119
121
|
private hydrateLatestLoadedSalesDetail;
|
|
120
122
|
private hydrateOrderPaymentNames;
|
|
121
123
|
get payment(): PaymentModule | undefined;
|
|
@@ -265,6 +267,8 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
265
267
|
/** 获取附加费用(运费/服务费/税费等)。 */
|
|
266
268
|
getSurcharges(): ISalesSurcharge[];
|
|
267
269
|
getTempOrder(): OrderTempOrder | null;
|
|
270
|
+
getOrderSessionId(): string | null;
|
|
271
|
+
isOrderSessionCurrent(sessionId: string): boolean;
|
|
268
272
|
replaceTempOrder(tempOrder: OrderTempOrder, options?: ReplaceTempOrderOptions): Promise<OrderTempOrder>;
|
|
269
273
|
getOrderIdentity(): import("../../modules/Order/types").OrderIdentitySnapshot | null;
|
|
270
274
|
getOrderSnapshot(): import("../../modules/Order/types").OrderSnapshot | null;
|