@pisell/pisellos 0.10.78 → 0.10.80
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/promotion/evaluator.js +5 -4
- package/dist/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/modules/Discount/types.d.ts +4 -0
- package/dist/modules/Order/index.js +77 -49
- package/dist/modules/Order/types.d.ts +2 -0
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/Rules/index.d.ts +3 -10
- package/dist/modules/Rules/index.js +164 -82
- package/dist/modules/Rules/promotionSelection.d.ts +14 -0
- package/dist/modules/Rules/promotionSelection.js +390 -0
- package/dist/modules/Rules/types.d.ts +9 -0
- package/dist/solution/BaseSales/index.js +41 -21
- package/dist/solution/BaseSales/utils/cartPromotion.js +5 -2
- package/dist/solution/BookingByStep/index.d.ts +2 -2
- package/dist/solution/BookingTicket/index.d.ts +13 -1
- package/lib/model/strategy/adapter/promotion/evaluator.js +5 -4
- package/lib/model/strategy/adapter/promotion/index.js +1 -46
- package/lib/modules/Discount/types.d.ts +4 -0
- package/lib/modules/Order/index.js +24 -4
- package/lib/modules/Order/types.d.ts +2 -0
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/Rules/index.d.ts +3 -10
- package/lib/modules/Rules/index.js +62 -22
- package/lib/modules/Rules/promotionSelection.d.ts +14 -0
- package/lib/modules/Rules/promotionSelection.js +230 -0
- package/lib/modules/Rules/types.d.ts +9 -0
- package/lib/solution/BaseSales/index.js +19 -5
- package/lib/solution/BaseSales/utils/cartPromotion.js +5 -2
- package/lib/solution/BookingByStep/index.d.ts +2 -2
- package/lib/solution/BookingTicket/index.d.ts +13 -1
- package/package.json +1 -1
|
@@ -26,6 +26,7 @@ var _pickupTiming = require("../../modules/Order/pickupTiming");
|
|
|
26
26
|
var _pickupTiming2 = require("./pickupTiming");
|
|
27
27
|
var _holderRelations = require("../../modules/Order/holderRelations");
|
|
28
28
|
var _contactInfo = require("../../modules/OpenData/contactInfo");
|
|
29
|
+
var _promotionSelection = require("../../modules/Rules/promotionSelection");
|
|
29
30
|
var _decimal = _interopRequireDefault(require("decimal.js"));
|
|
30
31
|
var _lodashEs = require("lodash-es");
|
|
31
32
|
var _types2 = require("../BookingByStep/types");
|
|
@@ -2181,17 +2182,25 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
2181
2182
|
return {
|
|
2182
2183
|
...discount,
|
|
2183
2184
|
isSelected: false,
|
|
2184
|
-
isManualSelect: true
|
|
2185
|
+
isManualSelect: true,
|
|
2186
|
+
promotionSelection: currentDiscount.promotionSelection,
|
|
2187
|
+
promotionSelectionStrategyIds: currentDiscount.promotionSelectionStrategyIds
|
|
2185
2188
|
};
|
|
2186
2189
|
}
|
|
2187
2190
|
if (currentDiscount.isSelected) {
|
|
2188
2191
|
return {
|
|
2189
2192
|
...discount,
|
|
2190
2193
|
isSelected: true,
|
|
2191
|
-
isManualSelect: false
|
|
2194
|
+
isManualSelect: false,
|
|
2195
|
+
promotionSelection: currentDiscount.promotionSelection,
|
|
2196
|
+
promotionSelectionStrategyIds: currentDiscount.promotionSelectionStrategyIds
|
|
2192
2197
|
};
|
|
2193
2198
|
}
|
|
2194
|
-
return
|
|
2199
|
+
return currentDiscount.promotionSelection ? {
|
|
2200
|
+
...discount,
|
|
2201
|
+
promotionSelection: currentDiscount.promotionSelection,
|
|
2202
|
+
promotionSelectionStrategyIds: currentDiscount.promotionSelectionStrategyIds
|
|
2203
|
+
} : discount;
|
|
2195
2204
|
});
|
|
2196
2205
|
}
|
|
2197
2206
|
resolveDiscountConfigCustomerId(tempOrder) {
|
|
@@ -2388,6 +2397,7 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
2388
2397
|
}
|
|
2389
2398
|
async bestDiscount(cb) {
|
|
2390
2399
|
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
2400
|
+
this.hasManualDiscountSelection = false;
|
|
2391
2401
|
const tempOrder = this.store.order.ensureTempOrder();
|
|
2392
2402
|
if (this.isActiveVirtualSettlementOrder(tempOrder)) {
|
|
2393
2403
|
const result = {
|
|
@@ -2552,8 +2562,10 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
2552
2562
|
nextDiscountList = result.discountList;
|
|
2553
2563
|
if (!params.isSelected) {
|
|
2554
2564
|
const beforeSelectedIds = new Set(updated.filter(d => d.isSelected).map(d => d.id));
|
|
2565
|
+
// Rules 已对促销组完成互斥报价,不能再移除其选中的卡而留下已取消的促销。
|
|
2566
|
+
const promotionCardIds = new Set((result.productList || []).filter(product => (0, _promotionSelection.getExclusivePromotion)(product)?.excludedByDiscountCard).flatMap(product => (product.discount_list || []).filter(_promotionSelection.isPromotionDiscountCard).map(discount => String(discount.discount?.resource_id ?? discount.id))));
|
|
2555
2567
|
for (const d of nextDiscountList) {
|
|
2556
|
-
if (d.isSelected && !beforeSelectedIds.has(d.id)) {
|
|
2568
|
+
if (d.isSelected && !beforeSelectedIds.has(d.id) && !promotionCardIds.has(String(d.id))) {
|
|
2557
2569
|
d.isSelected = false;
|
|
2558
2570
|
d.isManualSelect = true;
|
|
2559
2571
|
d.appliedProductDetails = [];
|
|
@@ -2564,6 +2576,8 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
2564
2576
|
}
|
|
2565
2577
|
const selectedResourceIds = new Set(nextDiscountList.filter(d => d.isSelected).map(d => d.id));
|
|
2566
2578
|
const filterSelectedDiscountDetails = discountList => (discountList || []).filter(pd => {
|
|
2579
|
+
// 互斥计算保留/恢复的系统促销没有钱包 resource_id,不能按已选卡列表移除。
|
|
2580
|
+
if (pd.type === 'promotion' || pd.type === 'product' && pd.metadata?.source === 'promotion') return true;
|
|
2567
2581
|
const rid = pd.discount?.resource_id ?? pd.id;
|
|
2568
2582
|
return rid != null && selectedResourceIds.has(rid);
|
|
2569
2583
|
});
|
|
@@ -2590,7 +2604,7 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
2590
2604
|
|
|
2591
2605
|
// 券作用于 source(不含 option、不含 bundle);算出新 source 折后价后补回 options
|
|
2592
2606
|
// 写入含 option 的 main_product_selling_price,再合成 composite 回写 selling_price。
|
|
2593
|
-
const totalPerUnitDiscount = (product.discount_list || []).reduce((sum, pd) => sum + (pd.amount || 0), 0);
|
|
2607
|
+
const totalPerUnitDiscount = (product.discount_list || []).reduce((sum, pd) => sum + Number(pd.amount || 0), 0);
|
|
2594
2608
|
// TODO 这块逻辑需要拿掉
|
|
2595
2609
|
const optionSum = (0, _utils.sumOptionUnitPrice)((0, _utils.getProductSkuOptions)(product));
|
|
2596
2610
|
const sourcePrice = product.metadata?.source_product_price ?? (product.metadata?.main_product_original_price != null ? new _decimal.default(Number(product.metadata.main_product_original_price) || 0).minus(optionSum).toFixed(2) : product.original_price ?? '0');
|
|
@@ -245,7 +245,10 @@ function resolveXItemsExpectedUnitPrice(promotion, sourceCartNum) {
|
|
|
245
245
|
const y = Number(detail?.price);
|
|
246
246
|
if (!Number.isFinite(x) || x <= 0 || !Number.isFinite(y)) return undefined;
|
|
247
247
|
if (sourceCartNum < x) return undefined;
|
|
248
|
-
|
|
248
|
+
const originalPrice = Number(promotion?.originalPrice);
|
|
249
|
+
const expectedUnit = new _decimal.default(y).div(x);
|
|
250
|
+
// 归并拆分行时沿用评估器的原价上限,避免重新按 Y / X 把原价抬高。
|
|
251
|
+
return (Number.isFinite(originalPrice) && originalPrice >= 0 ? _decimal.default.min(expectedUnit, originalPrice) : expectedUnit).toDecimalPlaces(2).toNumber();
|
|
249
252
|
}
|
|
250
253
|
|
|
251
254
|
/**
|
|
@@ -756,7 +759,7 @@ function calculateUnfulfilledPromotions(processedProducts, applicableStrategiesR
|
|
|
756
759
|
for (let i = 0; i < processedProducts.length; i++) {
|
|
757
760
|
const product = processedProducts[i];
|
|
758
761
|
const promotion = product?.metadata?._promotion;
|
|
759
|
-
if (!promotion || promotion.inPromotion !== false) continue;
|
|
762
|
+
if (!promotion || promotion.inPromotion !== false || promotion.excludedByDiscountCard) continue;
|
|
760
763
|
const strategyId = promotion.strategyId;
|
|
761
764
|
if (!strategyId) continue;
|
|
762
765
|
const lookupUid = String(product?._originalProductUid ?? product?.metadata?.unique_identification_number ?? '');
|
|
@@ -326,7 +326,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
326
326
|
date: string;
|
|
327
327
|
status: string;
|
|
328
328
|
week: string;
|
|
329
|
-
weekNum: 0 | 2 | 1 |
|
|
329
|
+
weekNum: 0 | 2 | 1 | 6 | 4 | 5 | 3;
|
|
330
330
|
}[]>;
|
|
331
331
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
332
332
|
private getScheduleDataByIds;
|
|
@@ -373,7 +373,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
373
373
|
};
|
|
374
374
|
setOtherData(key: string, value: any): void;
|
|
375
375
|
getOtherData(key: string): any;
|
|
376
|
-
getProductTypeById(id: number): Promise<"
|
|
376
|
+
getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
|
|
377
377
|
/**
|
|
378
378
|
* 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
|
|
379
379
|
*
|
|
@@ -479,7 +479,19 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
479
479
|
* 加车两阶段主决策(规格弹窗 / 资源编辑 / 直接加车)。
|
|
480
480
|
* 与 ticketBooking `handleSelectProduct` + `handleBooking4Service` 等价。
|
|
481
481
|
*/
|
|
482
|
-
decideAddProduct(item: any, options?: Partial<AddProductDecideContext>):
|
|
482
|
+
decideAddProduct(item: any, options?: Partial<AddProductDecideContext>): {
|
|
483
|
+
action: "reloadCatalog";
|
|
484
|
+
} | {
|
|
485
|
+
action: "add";
|
|
486
|
+
cacheItem: any;
|
|
487
|
+
} | {
|
|
488
|
+
action: "requiresDetail";
|
|
489
|
+
payload: AddProductRequiresDetailPayload;
|
|
490
|
+
} | {
|
|
491
|
+
action: "requiresBookingEdit";
|
|
492
|
+
cacheItem: any;
|
|
493
|
+
payload: import("./utils/addProductDecision").AddProductRequiresBookingEditPayload;
|
|
494
|
+
};
|
|
483
495
|
/** 规格弹窗 callback 后的第二段决策。 */
|
|
484
496
|
decideAfterDetail(cacheItem: any, options?: Partial<AddProductDecideContext>): import("./utils/addProductDecision").AddProductDecision;
|
|
485
497
|
/**
|