@pisell/pisellos 2.2.314 → 2.2.316
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/index.d.ts +2 -0
- package/dist/index.js +3 -1
- 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.js +89 -104
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +3 -1
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +28 -4
- package/dist/modules/BookingContext/utils/productExtend.d.ts +7 -0
- package/dist/modules/BookingContext/utils/productExtend.js +62 -18
- package/dist/modules/BookingContext/utils/resources.js +1 -1
- package/dist/modules/BusinessAvailability/index.d.ts +30 -0
- package/dist/modules/BusinessAvailability/index.js +204 -0
- 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/FulfillmentTiming/index.d.ts +11 -0
- package/dist/modules/FulfillmentTiming/index.js +407 -0
- package/dist/modules/FulfillmentTiming/types.d.ts +67 -0
- package/dist/modules/FulfillmentTiming/types.js +1 -0
- package/dist/modules/Holder/utils.d.ts +2 -0
- package/dist/modules/Holder/utils.js +32 -2
- package/dist/modules/OpenData/contactInfo.d.ts +20 -0
- package/dist/modules/OpenData/contactInfo.js +70 -0
- package/dist/modules/OpenData/index.d.ts +1 -0
- package/dist/modules/OpenData/index.js +1 -0
- package/dist/modules/OpenData/types.d.ts +23 -0
- package/dist/modules/Order/holderRelations.d.ts +14 -0
- package/dist/modules/Order/holderRelations.js +154 -0
- package/dist/modules/Order/index.d.ts +16 -4
- package/dist/modules/Order/index.js +926 -511
- package/dist/modules/Order/localEftposState.d.ts +13 -0
- package/dist/modules/Order/localEftposState.js +39 -0
- package/dist/modules/Order/pickupTiming.d.ts +46 -0
- package/dist/modules/Order/pickupTiming.js +53 -0
- package/dist/modules/Order/types.d.ts +49 -3
- package/dist/modules/Order/types.js +2 -0
- package/dist/modules/Order/utils/discountProductLineIdentity.d.ts +1 -1
- package/dist/modules/Order/utils/discountProductLineIdentity.js +142 -7
- package/dist/modules/Order/utils/orderCollectionIdentity.js +24 -10
- package/dist/modules/Order/utils.d.ts +2 -1
- package/dist/modules/Order/utils.js +61 -17
- package/dist/modules/Payment/index.js +9 -10
- package/dist/modules/Product/types.d.ts +11 -0
- package/dist/modules/ProductList/index.js +1 -1
- package/dist/modules/ResourcePlanner/planner.d.ts +2 -0
- package/dist/modules/ResourcePlanner/planner.js +332 -23
- package/dist/modules/ResourcePlanner/types.d.ts +29 -0
- package/dist/modules/Rules/index.js +62 -61
- package/dist/modules/Schedule/index.d.ts +8 -0
- package/dist/modules/Schedule/index.js +141 -39
- package/dist/modules/index.d.ts +1 -0
- package/dist/modules/index.js +1 -0
- package/dist/plugins/request.d.ts +7 -0
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +1557 -1322
- 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 +19 -0
- package/dist/server/modules/order/index.js +1071 -774
- package/dist/server/modules/order/types.d.ts +4 -0
- package/dist/server/modules/products/index.d.ts +28 -7
- package/dist/server/modules/products/index.js +1297 -770
- 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/server/test.json +1 -1
- package/dist/server/utils/small-ticket.d.ts +1 -85
- package/dist/server/utils/small-ticket.js +2 -2542
- package/dist/shared/payment/loadPaymentMethods.d.ts +9 -0
- package/dist/shared/payment/loadPaymentMethods.js +66 -0
- package/dist/shared/receipt/customerInvoiceLanguages.d.ts +8 -0
- package/dist/shared/receipt/customerInvoiceLanguages.js +60 -0
- package/dist/shared/receipt/loadCustomerInvoiceLayout.d.ts +27 -0
- package/dist/shared/receipt/loadCustomerInvoiceLayout.js +184 -0
- package/dist/shared/receipt/small-ticket.d.ts +96 -0
- package/dist/shared/receipt/small-ticket.js +2763 -0
- package/dist/shared/receipt/templateVisibility.d.ts +26 -0
- package/dist/shared/receipt/templateVisibility.js +68 -0
- package/dist/shared/sales/loadSalesOrderSnapshot.d.ts +9 -0
- package/dist/shared/sales/loadSalesOrderSnapshot.js +21 -0
- package/dist/solution/BaseSales/fulfillmentItemRules.d.ts +27 -0
- package/dist/solution/BaseSales/fulfillmentItemRules.js +750 -0
- package/dist/solution/BaseSales/index.d.ts +43 -16
- package/dist/solution/BaseSales/index.js +2028 -1247
- package/dist/solution/BaseSales/pickupTiming.d.ts +47 -0
- package/dist/solution/BaseSales/pickupTiming.js +616 -0
- package/dist/solution/BaseSales/types.d.ts +12 -0
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +3 -1
- package/dist/solution/BaseSales/utils/parseSalesResponse.js +10 -3
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +14 -4
- package/dist/solution/BookingByStep/index.d.ts +4 -2
- package/dist/solution/BookingByStep/index.js +8 -3
- package/dist/solution/BookingTicket/index.d.ts +23 -3
- package/dist/solution/BookingTicket/index.js +867 -507
- package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +0 -1
- package/dist/solution/BookingTicket/utils/addProductDecision.js +1 -1
- package/dist/solution/BookingTicket/utils/cartView.js +3 -1
- package/dist/solution/OrderInvoicePreview/index.d.ts +66 -0
- package/dist/solution/OrderInvoicePreview/index.js +340 -0
- package/dist/solution/RegisterAndLogin/config.js +54 -11
- package/dist/solution/RegisterAndLogin/index.d.ts +2 -0
- package/dist/solution/RegisterAndLogin/index.js +1 -1
- package/dist/solution/RegisterAndLogin/utils.d.ts +12 -4
- package/dist/solution/RegisterAndLogin/utils.js +36 -16
- package/dist/solution/ScanOrder/index.js +65 -31
- package/dist/solution/ScanOrder/types.d.ts +3 -0
- package/dist/solution/UnifiedBookingSales/businessAvailability.d.ts +27 -0
- package/dist/solution/UnifiedBookingSales/businessAvailability.js +292 -0
- package/dist/solution/UnifiedBookingSales/index.d.ts +36 -4
- package/dist/solution/UnifiedBookingSales/index.js +1715 -906
- package/dist/solution/UnifiedBookingSales/types.d.ts +16 -2
- package/dist/solution/VenueBooking/index.d.ts +15 -2
- package/dist/solution/VenueBooking/index.js +1062 -785
- package/dist/solution/VenueBooking/types.d.ts +2 -1
- package/dist/solution/VenueBooking/types.js +1 -0
- package/dist/solution/VenueBooking/utils/dateSummary.d.ts +1 -0
- package/dist/solution/VenueBooking/utils/dateSummary.js +7 -4
- package/dist/solution/VenueBooking/utils/smartPricing.d.ts +71 -0
- package/dist/solution/VenueBooking/utils/smartPricing.js +273 -0
- package/dist/solution/VenueBooking/utils/timeSlot.d.ts +1 -0
- package/dist/solution/VenueBooking/utils/timeSlot.js +6 -3
- package/dist/solution/index.d.ts +1 -0
- package/dist/solution/index.js +2 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.js +21 -1
- 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.js +9 -14
- package/lib/model/strategy/adapter/promotion/index.js +46 -1
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +3 -1
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +17 -1
- package/lib/modules/BookingContext/utils/productExtend.d.ts +7 -0
- package/lib/modules/BookingContext/utils/productExtend.js +45 -2
- package/lib/modules/BookingContext/utils/resources.js +1 -1
- package/lib/modules/BusinessAvailability/index.d.ts +30 -0
- package/lib/modules/BusinessAvailability/index.js +146 -0
- 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/FulfillmentTiming/index.d.ts +11 -0
- package/lib/modules/FulfillmentTiming/index.js +359 -0
- package/lib/modules/FulfillmentTiming/types.d.ts +67 -0
- package/lib/modules/FulfillmentTiming/types.js +5 -0
- package/lib/modules/Holder/utils.d.ts +2 -0
- package/lib/modules/Holder/utils.js +27 -1
- package/lib/modules/OpenData/contactInfo.d.ts +20 -0
- package/lib/modules/OpenData/contactInfo.js +56 -0
- package/lib/modules/OpenData/index.d.ts +1 -0
- package/lib/modules/OpenData/index.js +12 -0
- package/lib/modules/OpenData/types.d.ts +23 -0
- package/lib/modules/Order/holderRelations.d.ts +14 -0
- package/lib/modules/Order/holderRelations.js +98 -0
- package/lib/modules/Order/index.d.ts +16 -4
- package/lib/modules/Order/index.js +284 -50
- package/lib/modules/Order/localEftposState.d.ts +13 -0
- package/lib/modules/Order/localEftposState.js +44 -0
- package/lib/modules/Order/pickupTiming.d.ts +46 -0
- package/lib/modules/Order/pickupTiming.js +61 -0
- package/lib/modules/Order/types.d.ts +49 -3
- package/lib/modules/Order/types.js +1 -0
- package/lib/modules/Order/utils/discountProductLineIdentity.d.ts +1 -1
- package/lib/modules/Order/utils/discountProductLineIdentity.js +51 -2
- package/lib/modules/Order/utils/orderCollectionIdentity.js +5 -0
- package/lib/modules/Order/utils.d.ts +2 -1
- package/lib/modules/Order/utils.js +49 -11
- package/lib/modules/Payment/index.js +3 -4
- package/lib/modules/Product/types.d.ts +11 -0
- package/lib/modules/ProductList/index.js +1 -1
- package/lib/modules/ResourcePlanner/planner.d.ts +2 -0
- package/lib/modules/ResourcePlanner/planner.js +252 -8
- package/lib/modules/ResourcePlanner/types.d.ts +29 -0
- package/lib/modules/Rules/index.js +2 -1
- package/lib/modules/Schedule/index.d.ts +8 -0
- package/lib/modules/Schedule/index.js +68 -12
- package/lib/modules/index.d.ts +1 -0
- package/lib/modules/index.js +11 -0
- package/lib/plugins/request.d.ts +7 -0
- package/lib/server/index.d.ts +1 -0
- package/lib/server/index.js +166 -39
- 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 +19 -0
- package/lib/server/modules/order/index.js +160 -7
- package/lib/server/modules/order/types.d.ts +4 -0
- package/lib/server/modules/products/index.d.ts +28 -7
- package/lib/server/modules/products/index.js +226 -63
- 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/server/test.json +1 -1
- package/lib/server/utils/small-ticket.d.ts +1 -85
- package/lib/server/utils/small-ticket.js +9 -2305
- package/lib/shared/payment/loadPaymentMethods.d.ts +9 -0
- package/lib/shared/payment/loadPaymentMethods.js +40 -0
- package/lib/shared/receipt/customerInvoiceLanguages.d.ts +8 -0
- package/lib/shared/receipt/customerInvoiceLanguages.js +58 -0
- package/lib/shared/receipt/loadCustomerInvoiceLayout.d.ts +27 -0
- package/lib/shared/receipt/loadCustomerInvoiceLayout.js +124 -0
- package/lib/shared/receipt/small-ticket.d.ts +96 -0
- package/lib/shared/receipt/small-ticket.js +2555 -0
- package/lib/shared/receipt/templateVisibility.d.ts +26 -0
- package/lib/shared/receipt/templateVisibility.js +67 -0
- package/lib/shared/sales/loadSalesOrderSnapshot.d.ts +9 -0
- package/lib/shared/sales/loadSalesOrderSnapshot.js +22 -0
- package/lib/solution/BaseSales/fulfillmentItemRules.d.ts +27 -0
- package/lib/solution/BaseSales/fulfillmentItemRules.js +259 -0
- package/lib/solution/BaseSales/index.d.ts +43 -16
- package/lib/solution/BaseSales/index.js +401 -33
- package/lib/solution/BaseSales/pickupTiming.d.ts +47 -0
- package/lib/solution/BaseSales/pickupTiming.js +290 -0
- package/lib/solution/BaseSales/types.d.ts +12 -0
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +3 -1
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +7 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +16 -8
- package/lib/solution/BookingByStep/index.d.ts +4 -2
- package/lib/solution/BookingByStep/index.js +7 -3
- package/lib/solution/BookingTicket/index.d.ts +23 -3
- package/lib/solution/BookingTicket/index.js +197 -9
- package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +0 -1
- package/lib/solution/BookingTicket/utils/addProductDecision.js +1 -1
- package/lib/solution/BookingTicket/utils/cartView.js +3 -1
- package/lib/solution/OrderInvoicePreview/index.d.ts +66 -0
- package/lib/solution/OrderInvoicePreview/index.js +246 -0
- package/lib/solution/RegisterAndLogin/config.js +57 -11
- package/lib/solution/RegisterAndLogin/index.d.ts +2 -0
- package/lib/solution/RegisterAndLogin/index.js +9 -1
- package/lib/solution/RegisterAndLogin/utils.d.ts +12 -4
- package/lib/solution/RegisterAndLogin/utils.js +24 -17
- package/lib/solution/ScanOrder/index.js +59 -20
- package/lib/solution/ScanOrder/types.d.ts +3 -0
- package/lib/solution/UnifiedBookingSales/businessAvailability.d.ts +27 -0
- package/lib/solution/UnifiedBookingSales/businessAvailability.js +138 -0
- package/lib/solution/UnifiedBookingSales/index.d.ts +36 -4
- package/lib/solution/UnifiedBookingSales/index.js +562 -75
- package/lib/solution/UnifiedBookingSales/types.d.ts +16 -2
- package/lib/solution/VenueBooking/index.d.ts +15 -2
- package/lib/solution/VenueBooking/index.js +243 -96
- package/lib/solution/VenueBooking/types.d.ts +2 -1
- package/lib/solution/VenueBooking/types.js +1 -0
- package/lib/solution/VenueBooking/utils/dateSummary.d.ts +1 -0
- package/lib/solution/VenueBooking/utils/dateSummary.js +7 -4
- package/lib/solution/VenueBooking/utils/smartPricing.d.ts +71 -0
- package/lib/solution/VenueBooking/utils/smartPricing.js +224 -0
- package/lib/solution/VenueBooking/utils/timeSlot.d.ts +1 -0
- package/lib/solution/VenueBooking/utils/timeSlot.js +5 -2
- package/lib/solution/index.d.ts +1 -0
- package/lib/solution/index.js +11 -0
- package/package.json +1 -1
|
@@ -7,7 +7,8 @@ export declare enum VenueBookingHooks {
|
|
|
7
7
|
onDestroy = "venueBooking:onDestroy",
|
|
8
8
|
onRetryInit = "venueBooking:onRetryInit",
|
|
9
9
|
onRefresh = "venueBooking:onRefresh",
|
|
10
|
-
onCartValidationChanged = "venueBooking:onCartValidationChanged"
|
|
10
|
+
onCartValidationChanged = "venueBooking:onCartValidationChanged",
|
|
11
|
+
onSmartPricingUpdated = "venueBooking:onSmartPricingUpdated"
|
|
11
12
|
}
|
|
12
13
|
export type VenueBookingStatus = 'idle' | 'initializing' | 'ready' | 'error';
|
|
13
14
|
export interface VenueBookingEntryContext {
|
|
@@ -4,6 +4,7 @@ export var VenueBookingHooks = /*#__PURE__*/function (VenueBookingHooks) {
|
|
|
4
4
|
VenueBookingHooks["onRetryInit"] = "venueBooking:onRetryInit";
|
|
5
5
|
VenueBookingHooks["onRefresh"] = "venueBooking:onRefresh";
|
|
6
6
|
VenueBookingHooks["onCartValidationChanged"] = "venueBooking:onCartValidationChanged";
|
|
7
|
+
VenueBookingHooks["onSmartPricingUpdated"] = "venueBooking:onSmartPricingUpdated";
|
|
7
8
|
return VenueBookingHooks;
|
|
8
9
|
}({});
|
|
9
10
|
|
|
@@ -9,4 +9,5 @@ export declare function buildDateRangeSummary(params: {
|
|
|
9
9
|
quotationModule?: QuotationModule;
|
|
10
10
|
channel?: string;
|
|
11
11
|
resolveConfig?: (date: string) => VenueBookingSlotConfig;
|
|
12
|
+
buildSlotPriceMap?: (date: string, config: VenueBookingSlotConfig, productIds: number[]) => Map<string, string | null>;
|
|
12
13
|
}): VenueDateSummaryItem[];
|
|
@@ -15,9 +15,10 @@ export function buildDateRangeSummary(params) {
|
|
|
15
15
|
resourceProductMap = params.resourceProductMap,
|
|
16
16
|
quotationModule = params.quotationModule,
|
|
17
17
|
channel = params.channel,
|
|
18
|
-
resolveConfig = params.resolveConfig
|
|
18
|
+
resolveConfig = params.resolveConfig,
|
|
19
|
+
buildSlotPriceMap = params.buildSlotPriceMap;
|
|
19
20
|
var result = [];
|
|
20
|
-
var productIds = quotationModule ? _toConsumableArray(new Set(_toConsumableArray(resourceProductMap.values()).flat().map(function (m) {
|
|
21
|
+
var productIds = buildSlotPriceMap || quotationModule ? _toConsumableArray(new Set(_toConsumableArray(resourceProductMap.values()).flat().map(function (m) {
|
|
21
22
|
return m.productId;
|
|
22
23
|
}))) : [];
|
|
23
24
|
var cursor = dayjs(startDate);
|
|
@@ -26,7 +27,8 @@ export function buildDateRangeSummary(params) {
|
|
|
26
27
|
var date = cursor.format('YYYY-MM-DD');
|
|
27
28
|
var effectiveConfig = (resolveConfig === null || resolveConfig === void 0 ? void 0 : resolveConfig(date)) || config;
|
|
28
29
|
var quotationPriceMap;
|
|
29
|
-
|
|
30
|
+
var slotPriceMap = buildSlotPriceMap === null || buildSlotPriceMap === void 0 ? void 0 : buildSlotPriceMap(date, effectiveConfig, productIds);
|
|
31
|
+
if (!slotPriceMap && quotationModule && productIds.length) {
|
|
30
32
|
var timeLabels = generateTimeLabels(effectiveConfig);
|
|
31
33
|
var timePoints = timeLabels.map(function (label) {
|
|
32
34
|
return "".concat(date, " ").concat(label);
|
|
@@ -42,7 +44,8 @@ export function buildDateRangeSummary(params) {
|
|
|
42
44
|
config: effectiveConfig,
|
|
43
45
|
rawResources: rawResources,
|
|
44
46
|
resourceProductMap: resourceProductMap,
|
|
45
|
-
quotationPriceMap: quotationPriceMap
|
|
47
|
+
quotationPriceMap: quotationPriceMap,
|
|
48
|
+
slotPriceMap: slotPriceMap
|
|
46
49
|
});
|
|
47
50
|
var totalSlots = 0;
|
|
48
51
|
var availableSlots = 0;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { ProductData } from '../../../modules/Product/types';
|
|
2
|
+
import type { ScheduleItem } from '../../../modules/Schedule/types';
|
|
3
|
+
import type { DataVariantBusinessData, DataVariantMenu, DataVariantProduct } from '../../../model/strategy/adapter/dataVariant/type';
|
|
4
|
+
import type { DataVariantEvaluator } from '../../../model/strategy/adapter/dataVariant/evaluator';
|
|
5
|
+
import type { StrategyConfig } from '../../../model/strategy/type';
|
|
6
|
+
import type { VenueBookingSlotConfig } from '../types';
|
|
7
|
+
/** VenueBooking 智能定价运行时上下文 */
|
|
8
|
+
export interface VenueBookingSmartPricingContext {
|
|
9
|
+
evaluator?: DataVariantEvaluator | null;
|
|
10
|
+
scheduleList?: ScheduleItem[];
|
|
11
|
+
menuList?: DataVariantMenu[];
|
|
12
|
+
customerId?: number | string;
|
|
13
|
+
availableWalletIds?: Array<number | string>;
|
|
14
|
+
channel?: string;
|
|
15
|
+
businessCode?: string;
|
|
16
|
+
orderType?: string;
|
|
17
|
+
strategy_context?: Record<string, any>;
|
|
18
|
+
strategyConfigs?: StrategyConfig[];
|
|
19
|
+
}
|
|
20
|
+
/** 从商品上读取展示/算价用的 price 字段 */
|
|
21
|
+
export declare function extractProductPrice(product: DataVariantProduct): string | null;
|
|
22
|
+
/** 组装 DataVariant 评估入参,对齐 OS Server buildProductFormatterContext 语义 */
|
|
23
|
+
export declare function buildDataVariantBusinessData(products: ProductData[], context: VenueBookingSmartPricingContext, scheduleDateTime: string): DataVariantBusinessData;
|
|
24
|
+
/**
|
|
25
|
+
* 对商品列表执行一次智能定价格式化(loadProducts 后使用)。
|
|
26
|
+
* evaluator 未注入时原样返回并打 warning。
|
|
27
|
+
*/
|
|
28
|
+
export declare function formatProductsWithDataVariant(products: ProductData[], context: VenueBookingSmartPricingContext, scheduleDateTime?: string): ProductData[];
|
|
29
|
+
/**
|
|
30
|
+
* 根据 schedule_time_points 与营业开始时间,构造当天需要评估的 datetime 列表(升序)。
|
|
31
|
+
* 跨日营业时,早于营业开始小时的时间点归到次日。
|
|
32
|
+
*/
|
|
33
|
+
export declare function buildEvaluationDatetimes(params: {
|
|
34
|
+
date: string;
|
|
35
|
+
config: VenueBookingSlotConfig;
|
|
36
|
+
scheduleTimePoints: string[];
|
|
37
|
+
}): string[];
|
|
38
|
+
/** 找到 slot 时间所属分段的评估 datetime(max(evalDt <= slotDt)) */
|
|
39
|
+
export declare function findSegmentEvalDatetime(slotDatetime: string, evalDatetimes: string[]): string;
|
|
40
|
+
/** 将 slot 标签转为与 timeSlot 网格一致的 slotStart 字符串 */
|
|
41
|
+
export declare function buildSlotStartDatetime(date: string, label: string, config: VenueBookingSlotConfig): string;
|
|
42
|
+
/**
|
|
43
|
+
* 按 schedule 分段批量 resolveProducts,输出与 quotation 相同 key 格式的 slot 价格 Map。
|
|
44
|
+
* key: `${productId}:${slotStart}`,value: price | null
|
|
45
|
+
*/
|
|
46
|
+
export declare function buildSlotPriceMapByScheduleSegments(params: {
|
|
47
|
+
products: ProductData[];
|
|
48
|
+
productIds: number[];
|
|
49
|
+
date: string;
|
|
50
|
+
timeLabels: string[];
|
|
51
|
+
config: VenueBookingSlotConfig;
|
|
52
|
+
context: VenueBookingSmartPricingContext;
|
|
53
|
+
}): Map<string, string | null>;
|
|
54
|
+
/**
|
|
55
|
+
* 指定商品在某一 datetime 的智能定价(addon / 单点重算用)。
|
|
56
|
+
*/
|
|
57
|
+
export declare function getPriceForProductAtDatetime(params: {
|
|
58
|
+
products: ProductData[];
|
|
59
|
+
context: VenueBookingSmartPricingContext;
|
|
60
|
+
productId: number;
|
|
61
|
+
variantId?: number;
|
|
62
|
+
datetime: string;
|
|
63
|
+
fallbackPrice?: string;
|
|
64
|
+
}): string;
|
|
65
|
+
/** 从 slot 价格 Map 读取单价,找不到则回退 fallback */
|
|
66
|
+
export declare function getSlotPriceFromMap(params: {
|
|
67
|
+
slotPriceMap: Map<string, string | null>;
|
|
68
|
+
productId: number;
|
|
69
|
+
slotStartTime: string;
|
|
70
|
+
fallbackPrice?: string;
|
|
71
|
+
}): string;
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
3
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
5
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
6
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
7
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
8
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
9
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
10
|
+
import dayjs from 'dayjs';
|
|
11
|
+
import { isBusinessHoursCrossDay } from "./timeSlot";
|
|
12
|
+
|
|
13
|
+
/** VenueBooking 智能定价运行时上下文 */
|
|
14
|
+
|
|
15
|
+
/** 从商品上读取展示/算价用的 price 字段 */
|
|
16
|
+
export function extractProductPrice(product) {
|
|
17
|
+
var _product$price;
|
|
18
|
+
var price = (_product$price = product === null || product === void 0 ? void 0 : product.price) !== null && _product$price !== void 0 ? _product$price : product === null || product === void 0 ? void 0 : product.selling_price;
|
|
19
|
+
if (price == null || price === '') return null;
|
|
20
|
+
return String(price);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** 组装 DataVariant 评估入参,对齐 OS Server buildProductFormatterContext 语义 */
|
|
24
|
+
export function buildDataVariantBusinessData(products, context, scheduleDateTime) {
|
|
25
|
+
var _ref, _context$availableWal, _context$channel, _ref2, _context$orderType, _ref3, _context$businessCode;
|
|
26
|
+
var strategyContext = context.strategy_context || {};
|
|
27
|
+
return {
|
|
28
|
+
products: products,
|
|
29
|
+
strategyConfigs: context.strategyConfigs,
|
|
30
|
+
scheduleDateTime: scheduleDateTime,
|
|
31
|
+
scheduleList: context.scheduleList || [],
|
|
32
|
+
menuList: context.menuList || [],
|
|
33
|
+
customerId: context.customerId,
|
|
34
|
+
availableWalletIds: (_ref = (_context$availableWal = context.availableWalletIds) !== null && _context$availableWal !== void 0 ? _context$availableWal : strategyContext.available_wallet_ids) !== null && _ref !== void 0 ? _ref : strategyContext.availableWalletIds,
|
|
35
|
+
channel: (_context$channel = context.channel) !== null && _context$channel !== void 0 ? _context$channel : strategyContext.channel,
|
|
36
|
+
orderType: (_ref2 = (_context$orderType = context.orderType) !== null && _context$orderType !== void 0 ? _context$orderType : strategyContext.orderType) !== null && _ref2 !== void 0 ? _ref2 : strategyContext.order_type,
|
|
37
|
+
businessCode: (_ref3 = (_context$businessCode = context.businessCode) !== null && _context$businessCode !== void 0 ? _context$businessCode : strategyContext.business_code) !== null && _ref3 !== void 0 ? _ref3 : strategyContext.businessCode,
|
|
38
|
+
custom: strategyContext
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* 对商品列表执行一次智能定价格式化(loadProducts 后使用)。
|
|
44
|
+
* evaluator 未注入时原样返回并打 warning。
|
|
45
|
+
*/
|
|
46
|
+
export function formatProductsWithDataVariant(products, context, scheduleDateTime) {
|
|
47
|
+
var evaluator = context.evaluator;
|
|
48
|
+
if (!evaluator || typeof evaluator.resolveProducts !== 'function') {
|
|
49
|
+
console.warn('[VenueBooking][smartPricing] dataVariantEvaluator 未注入,跳过智能定价格式化');
|
|
50
|
+
return products;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// 日程包含结束边界,向后偏移一秒评估,避免前一时段的定价规则覆盖当前时段。
|
|
54
|
+
// 仅调整规则匹配时间,预约时间和分段缓存 key 仍保留原值。
|
|
55
|
+
var resolvedAt = dayjs(scheduleDateTime || undefined).add(1, 'second').format('YYYY-MM-DD HH:mm:ss');
|
|
56
|
+
// 接口的命中 ID 对应商品查询时刻,不能用于另一个预约时段/客户。
|
|
57
|
+
// 仅处理本次评估副本,保留目录中的原始数据。
|
|
58
|
+
var pricingProducts = products.map(function (product) {
|
|
59
|
+
var _product$base_price;
|
|
60
|
+
var metadata = _objectSpread({}, product.metadata);
|
|
61
|
+
var hasResolvedVariants = Array.isArray(metadata.data_variant_ids);
|
|
62
|
+
delete metadata.data_variant_ids;
|
|
63
|
+
return _objectSpread(_objectSpread({}, product), {}, {
|
|
64
|
+
price: hasResolvedVariants ? (_product$base_price = product.base_price) !== null && _product$base_price !== void 0 ? _product$base_price : product.price : product.price,
|
|
65
|
+
metadata: metadata
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
var businessData = buildDataVariantBusinessData(pricingProducts, context, resolvedAt);
|
|
69
|
+
var result = evaluator.resolveProducts(businessData);
|
|
70
|
+
return Array.isArray(result === null || result === void 0 ? void 0 : result.products) ? result.products : products;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* 根据 schedule_time_points 与营业开始时间,构造当天需要评估的 datetime 列表(升序)。
|
|
75
|
+
* 跨日营业时,早于营业开始小时的时间点归到次日。
|
|
76
|
+
*/
|
|
77
|
+
export function buildEvaluationDatetimes(params) {
|
|
78
|
+
var date = params.date,
|
|
79
|
+
config = params.config,
|
|
80
|
+
scheduleTimePoints = params.scheduleTimePoints;
|
|
81
|
+
var crossDay = isBusinessHoursCrossDay(config);
|
|
82
|
+
var businessStartHour = Number(config.businessStartTime.split(':')[0]);
|
|
83
|
+
var evalSet = new Set();
|
|
84
|
+
evalSet.add("".concat(date, " ").concat(config.businessStartTime));
|
|
85
|
+
if (crossDay) {
|
|
86
|
+
// 即使规则没有显式 00:00 时间点,日期/星期变化也可能切换适用规则。
|
|
87
|
+
evalSet.add("".concat(dayjs(date).add(1, 'day').format('YYYY-MM-DD'), " 00:00"));
|
|
88
|
+
}
|
|
89
|
+
var _iterator = _createForOfIteratorHelper(scheduleTimePoints),
|
|
90
|
+
_step;
|
|
91
|
+
try {
|
|
92
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
93
|
+
var timePoint = _step.value;
|
|
94
|
+
var hour = Number(timePoint.split(':')[0]);
|
|
95
|
+
var pointDate = crossDay && hour < businessStartHour ? dayjs(date).add(1, 'day').format('YYYY-MM-DD') : date;
|
|
96
|
+
evalSet.add("".concat(pointDate, " ").concat(timePoint));
|
|
97
|
+
}
|
|
98
|
+
} catch (err) {
|
|
99
|
+
_iterator.e(err);
|
|
100
|
+
} finally {
|
|
101
|
+
_iterator.f();
|
|
102
|
+
}
|
|
103
|
+
return Array.from(evalSet).sort(function (a, b) {
|
|
104
|
+
var aMs = dayjs(a, ['YYYY-MM-DD HH:mm:ss', 'YYYY-MM-DD HH:mm']).valueOf();
|
|
105
|
+
var bMs = dayjs(b, ['YYYY-MM-DD HH:mm:ss', 'YYYY-MM-DD HH:mm']).valueOf();
|
|
106
|
+
return aMs - bMs;
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** 找到 slot 时间所属分段的评估 datetime(max(evalDt <= slotDt)) */
|
|
111
|
+
export function findSegmentEvalDatetime(slotDatetime, evalDatetimes) {
|
|
112
|
+
if (!evalDatetimes.length) return slotDatetime;
|
|
113
|
+
var slotMs = dayjs(slotDatetime, ['YYYY-MM-DD HH:mm:ss', 'YYYY-MM-DD HH:mm']).valueOf();
|
|
114
|
+
var chosen = evalDatetimes[0];
|
|
115
|
+
var _iterator2 = _createForOfIteratorHelper(evalDatetimes),
|
|
116
|
+
_step2;
|
|
117
|
+
try {
|
|
118
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
119
|
+
var evalDt = _step2.value;
|
|
120
|
+
var evalMs = dayjs(evalDt, ['YYYY-MM-DD HH:mm:ss', 'YYYY-MM-DD HH:mm']).valueOf();
|
|
121
|
+
if (evalMs <= slotMs) {
|
|
122
|
+
chosen = evalDt;
|
|
123
|
+
} else {
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
} catch (err) {
|
|
128
|
+
_iterator2.e(err);
|
|
129
|
+
} finally {
|
|
130
|
+
_iterator2.f();
|
|
131
|
+
}
|
|
132
|
+
return chosen;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/** 将 slot 标签转为与 timeSlot 网格一致的 slotStart 字符串 */
|
|
136
|
+
export function buildSlotStartDatetime(date, label, config) {
|
|
137
|
+
var crossDay = isBusinessHoursCrossDay(config);
|
|
138
|
+
var businessStartHour = Number(config.businessStartTime.split(':')[0]);
|
|
139
|
+
var hour = Number(label.split(':')[0]);
|
|
140
|
+
var slotDate = crossDay && hour < businessStartHour ? dayjs(date).add(1, 'day').format('YYYY-MM-DD') : date;
|
|
141
|
+
return dayjs("".concat(slotDate, " ").concat(label)).format('YYYY-MM-DD HH:mm');
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* 按 schedule 分段批量 resolveProducts,输出与 quotation 相同 key 格式的 slot 价格 Map。
|
|
146
|
+
* key: `${productId}:${slotStart}`,value: price | null
|
|
147
|
+
*/
|
|
148
|
+
export function buildSlotPriceMapByScheduleSegments(params) {
|
|
149
|
+
var products = params.products,
|
|
150
|
+
productIds = params.productIds,
|
|
151
|
+
date = params.date,
|
|
152
|
+
timeLabels = params.timeLabels,
|
|
153
|
+
config = params.config,
|
|
154
|
+
context = params.context;
|
|
155
|
+
var map = new Map();
|
|
156
|
+
if (!productIds.length || !timeLabels.length) return map;
|
|
157
|
+
var evaluator = context.evaluator;
|
|
158
|
+
if (!evaluator || typeof evaluator.resolveProducts !== 'function') return map;
|
|
159
|
+
var strategyConfigs = context.strategyConfigs || (typeof evaluator.getStrategyConfigs === 'function' ? evaluator.getStrategyConfigs() : []);
|
|
160
|
+
var scheduleTimePoints = typeof evaluator.buildScheduleTimePoints === 'function' ? evaluator.buildScheduleTimePoints(strategyConfigs, context.scheduleList || []) : [];
|
|
161
|
+
var evalDatetimes = buildEvaluationDatetimes({
|
|
162
|
+
date: date,
|
|
163
|
+
config: config,
|
|
164
|
+
scheduleTimePoints: scheduleTimePoints
|
|
165
|
+
});
|
|
166
|
+
var priceCache = new Map();
|
|
167
|
+
var _iterator3 = _createForOfIteratorHelper(evalDatetimes),
|
|
168
|
+
_step3;
|
|
169
|
+
try {
|
|
170
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
171
|
+
var evalDt = _step3.value;
|
|
172
|
+
var resolved = formatProductsWithDataVariant(products, context, evalDt);
|
|
173
|
+
var priceByProductId = new Map();
|
|
174
|
+
var _iterator5 = _createForOfIteratorHelper(resolved),
|
|
175
|
+
_step5;
|
|
176
|
+
try {
|
|
177
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
178
|
+
var product = _step5.value;
|
|
179
|
+
var productId = Number(product.id);
|
|
180
|
+
if (!Number.isFinite(productId)) continue;
|
|
181
|
+
priceByProductId.set(productId, extractProductPrice(product));
|
|
182
|
+
}
|
|
183
|
+
} catch (err) {
|
|
184
|
+
_iterator5.e(err);
|
|
185
|
+
} finally {
|
|
186
|
+
_iterator5.f();
|
|
187
|
+
}
|
|
188
|
+
priceCache.set(evalDt, priceByProductId);
|
|
189
|
+
}
|
|
190
|
+
} catch (err) {
|
|
191
|
+
_iterator3.e(err);
|
|
192
|
+
} finally {
|
|
193
|
+
_iterator3.f();
|
|
194
|
+
}
|
|
195
|
+
var _iterator4 = _createForOfIteratorHelper(timeLabels),
|
|
196
|
+
_step4;
|
|
197
|
+
try {
|
|
198
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
199
|
+
var label = _step4.value;
|
|
200
|
+
var slotStart = buildSlotStartDatetime(date, label, config);
|
|
201
|
+
var segmentEvalDt = findSegmentEvalDatetime(slotStart, evalDatetimes);
|
|
202
|
+
var _priceByProductId = priceCache.get(segmentEvalDt);
|
|
203
|
+
var _iterator6 = _createForOfIteratorHelper(productIds),
|
|
204
|
+
_step6;
|
|
205
|
+
try {
|
|
206
|
+
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
207
|
+
var _priceByProductId$get;
|
|
208
|
+
var _productId = _step6.value;
|
|
209
|
+
var key = "".concat(_productId, ":").concat(slotStart);
|
|
210
|
+
var price = (_priceByProductId$get = _priceByProductId === null || _priceByProductId === void 0 ? void 0 : _priceByProductId.get(_productId)) !== null && _priceByProductId$get !== void 0 ? _priceByProductId$get : null;
|
|
211
|
+
if (price !== null) {
|
|
212
|
+
map.set(key, price);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
} catch (err) {
|
|
216
|
+
_iterator6.e(err);
|
|
217
|
+
} finally {
|
|
218
|
+
_iterator6.f();
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
} catch (err) {
|
|
222
|
+
_iterator4.e(err);
|
|
223
|
+
} finally {
|
|
224
|
+
_iterator4.f();
|
|
225
|
+
}
|
|
226
|
+
return map;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* 指定商品在某一 datetime 的智能定价(addon / 单点重算用)。
|
|
231
|
+
*/
|
|
232
|
+
export function getPriceForProductAtDatetime(params) {
|
|
233
|
+
var _ref6, _extractProductPrice;
|
|
234
|
+
var products = params.products,
|
|
235
|
+
context = params.context,
|
|
236
|
+
productId = params.productId,
|
|
237
|
+
variantId = params.variantId,
|
|
238
|
+
datetime = params.datetime,
|
|
239
|
+
fallbackPrice = params.fallbackPrice;
|
|
240
|
+
var selectedProducts = products.filter(function (product) {
|
|
241
|
+
return Number(product.id) === Number(productId);
|
|
242
|
+
}).map(function (product) {
|
|
243
|
+
var _product$variant, _ref4, _variant$price, _ref5, _variant$base_price;
|
|
244
|
+
if (!variantId) return product;
|
|
245
|
+
var variant = (_product$variant = product.variant) === null || _product$variant === void 0 ? void 0 : _product$variant.find(function (item) {
|
|
246
|
+
return Number(item.id) === Number(variantId);
|
|
247
|
+
});
|
|
248
|
+
if (!variant) return product;
|
|
249
|
+
return _objectSpread(_objectSpread({}, product), {}, {
|
|
250
|
+
product_variant_id: variantId,
|
|
251
|
+
variant_id: variantId,
|
|
252
|
+
price: (_ref4 = (_variant$price = variant.price) !== null && _variant$price !== void 0 ? _variant$price : variant.base_price) !== null && _ref4 !== void 0 ? _ref4 : product.price,
|
|
253
|
+
base_price: (_ref5 = (_variant$base_price = variant.base_price) !== null && _variant$base_price !== void 0 ? _variant$base_price : variant.price) !== null && _ref5 !== void 0 ? _ref5 : product.base_price
|
|
254
|
+
});
|
|
255
|
+
});
|
|
256
|
+
var resolved = formatProductsWithDataVariant(selectedProducts, context, datetime);
|
|
257
|
+
var product = resolved.find(function (item) {
|
|
258
|
+
return Number(item.id) === Number(productId);
|
|
259
|
+
});
|
|
260
|
+
return (_ref6 = (_extractProductPrice = extractProductPrice(product || {})) !== null && _extractProductPrice !== void 0 ? _extractProductPrice : fallbackPrice) !== null && _ref6 !== void 0 ? _ref6 : '0.00';
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/** 从 slot 价格 Map 读取单价,找不到则回退 fallback */
|
|
264
|
+
export function getSlotPriceFromMap(params) {
|
|
265
|
+
var slotPriceMap = params.slotPriceMap,
|
|
266
|
+
productId = params.productId,
|
|
267
|
+
slotStartTime = params.slotStartTime,
|
|
268
|
+
fallbackPrice = params.fallbackPrice;
|
|
269
|
+
var key = "".concat(productId, ":").concat(slotStartTime);
|
|
270
|
+
var mapped = slotPriceMap.get(key);
|
|
271
|
+
if (mapped != null) return mapped;
|
|
272
|
+
return fallbackPrice !== null && fallbackPrice !== void 0 ? fallbackPrice : '0.00';
|
|
273
|
+
}
|
|
@@ -28,5 +28,6 @@ export declare function buildTimeSlotGrid(params: {
|
|
|
28
28
|
rawResources: VenueResourceRawData[];
|
|
29
29
|
resourceProductMap: Map<number | string, ResourceProductMapping[]>;
|
|
30
30
|
quotationPriceMap?: Map<string, string | null>;
|
|
31
|
+
slotPriceMap?: Map<string, string | null>;
|
|
31
32
|
}): VenueTimeSlotGrid;
|
|
32
33
|
export {};
|
|
@@ -230,6 +230,7 @@ function buildProductSlots(params) {
|
|
|
230
230
|
now = params.now,
|
|
231
231
|
crossDay = params.crossDay,
|
|
232
232
|
quotationPriceMap = params.quotationPriceMap,
|
|
233
|
+
slotPriceMap = params.slotPriceMap,
|
|
233
234
|
childRawResources = params.childRawResources,
|
|
234
235
|
childTimesCache = params.childTimesCache,
|
|
235
236
|
childEventsCache = params.childEventsCache,
|
|
@@ -239,7 +240,7 @@ function buildProductSlots(params) {
|
|
|
239
240
|
_step7;
|
|
240
241
|
try {
|
|
241
242
|
for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
|
|
242
|
-
var
|
|
243
|
+
var _get, _ref;
|
|
243
244
|
var label = _step7.value;
|
|
244
245
|
var _label$split$map = label.split(':').map(Number),
|
|
245
246
|
_label$split$map2 = _slicedToArray(_label$split$map, 1),
|
|
@@ -302,7 +303,7 @@ function buildProductSlots(params) {
|
|
|
302
303
|
startTime: slotStartStr,
|
|
303
304
|
endTime: slotEnd.format('YYYY-MM-DD HH:mm'),
|
|
304
305
|
status: status,
|
|
305
|
-
price: isBookable ? (
|
|
306
|
+
price: isBookable ? (_get = (_ref = slotPriceMap !== null && slotPriceMap !== void 0 ? slotPriceMap : quotationPriceMap) === null || _ref === void 0 ? void 0 : _ref.get("".concat(mapping.productId, ":").concat(slotStartStr))) !== null && _get !== void 0 ? _get : mapping.price : null,
|
|
306
307
|
resourceId: resource.resourceId,
|
|
307
308
|
resourceFormId: resource.formId,
|
|
308
309
|
capacity: status === 'past' || status === 'unavailable' ? null : resCapacity,
|
|
@@ -322,7 +323,8 @@ export function buildTimeSlotGrid(params) {
|
|
|
322
323
|
config = params.config,
|
|
323
324
|
rawResources = params.rawResources,
|
|
324
325
|
resourceProductMap = params.resourceProductMap,
|
|
325
|
-
quotationPriceMap = params.quotationPriceMap
|
|
326
|
+
quotationPriceMap = params.quotationPriceMap,
|
|
327
|
+
slotPriceMap = params.slotPriceMap;
|
|
326
328
|
var timeLabels = generateTimeLabels(config);
|
|
327
329
|
var now = dayjs();
|
|
328
330
|
var crossDay = isBusinessHoursCrossDay(config);
|
|
@@ -378,6 +380,7 @@ export function buildTimeSlotGrid(params) {
|
|
|
378
380
|
now: now,
|
|
379
381
|
crossDay: crossDay,
|
|
380
382
|
quotationPriceMap: quotationPriceMap,
|
|
383
|
+
slotPriceMap: slotPriceMap,
|
|
381
384
|
childRawResources: childRawResources,
|
|
382
385
|
childTimesCache: childTimesCache,
|
|
383
386
|
childEventsCache: childEventsCache,
|
package/dist/solution/index.d.ts
CHANGED
package/dist/solution/index.js
CHANGED
package/lib/index.d.ts
CHANGED
|
@@ -10,3 +10,5 @@ export * from './model';
|
|
|
10
10
|
export { PisellOSCore } from './core';
|
|
11
11
|
import PisellOSCore from './core';
|
|
12
12
|
export default PisellOSCore;
|
|
13
|
+
export * from './shared/receipt/small-ticket';
|
|
14
|
+
export { loadSalesOrderSnapshot } from './shared/sales/loadSalesOrderSnapshot';
|
package/lib/index.js
CHANGED
|
@@ -4,7 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
var _exportNames = {
|
|
7
|
-
PisellOSCore: true
|
|
7
|
+
PisellOSCore: true,
|
|
8
|
+
loadSalesOrderSnapshot: true
|
|
8
9
|
};
|
|
9
10
|
Object.defineProperty(exports, "PisellOSCore", {
|
|
10
11
|
enumerable: true,
|
|
@@ -13,6 +14,12 @@ Object.defineProperty(exports, "PisellOSCore", {
|
|
|
13
14
|
}
|
|
14
15
|
});
|
|
15
16
|
exports.default = void 0;
|
|
17
|
+
Object.defineProperty(exports, "loadSalesOrderSnapshot", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function () {
|
|
20
|
+
return _loadSalesOrderSnapshot.loadSalesOrderSnapshot;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
16
23
|
var _types = require("./types");
|
|
17
24
|
Object.keys(_types).forEach(function (key) {
|
|
18
25
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -74,6 +81,19 @@ Object.keys(_model).forEach(function (key) {
|
|
|
74
81
|
});
|
|
75
82
|
});
|
|
76
83
|
var _core = _interopRequireWildcard(require("./core"));
|
|
84
|
+
var _smallTicket = require("./shared/receipt/small-ticket");
|
|
85
|
+
Object.keys(_smallTicket).forEach(function (key) {
|
|
86
|
+
if (key === "default" || key === "__esModule") return;
|
|
87
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
88
|
+
if (key in exports && exports[key] === _smallTicket[key]) return;
|
|
89
|
+
Object.defineProperty(exports, key, {
|
|
90
|
+
enumerable: true,
|
|
91
|
+
get: function () {
|
|
92
|
+
return _smallTicket[key];
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
var _loadSalesOrderSnapshot = require("./shared/sales/loadSalesOrderSnapshot");
|
|
77
97
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
78
98
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
79
99
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { EvaluationResult, RuntimeContext, ActionEffect } from '../../type';
|
|
2
2
|
import type { BusinessAdapter } from '../type';
|
|
3
|
-
import { type ItemRuleBusinessData, type QuantityCheckResult, type PrefillItemResult, type QuantityLimitResult, type AllergyRequirement } from './type';
|
|
3
|
+
import { type ItemRuleBusinessData, type ItemRuleCartAction, type QuantityCheckResult, type PrefillItemResult, type QuantityLimitResult, type AllergyRequirement } from './type';
|
|
4
4
|
/**
|
|
5
5
|
* ItemRule 适配器
|
|
6
6
|
*
|
|
@@ -14,6 +14,7 @@ export declare class ItemRuleAdapter implements BusinessAdapter {
|
|
|
14
14
|
transformResult(result: EvaluationResult, businessData?: ItemRuleBusinessData): {
|
|
15
15
|
quantityChecks: QuantityCheckResult[];
|
|
16
16
|
prefillItems: PrefillItemResult[];
|
|
17
|
+
cartActions: ItemRuleCartAction[];
|
|
17
18
|
allergyRequirements: AllergyRequirement[];
|
|
18
19
|
};
|
|
19
20
|
private processAllergyCheck;
|
|
@@ -66,5 +67,6 @@ export declare class ItemRuleAdapter implements BusinessAdapter {
|
|
|
66
67
|
* 根据 quantityFrom 计算预填数量
|
|
67
68
|
*/
|
|
68
69
|
private resolvePrefillQuantity;
|
|
70
|
+
private processDeleteProduct;
|
|
69
71
|
}
|
|
70
72
|
export default ItemRuleAdapter;
|
|
@@ -50,11 +50,13 @@ class ItemRuleAdapter {
|
|
|
50
50
|
transformResult(result, businessData) {
|
|
51
51
|
const quantityChecks = [];
|
|
52
52
|
const prefillItems = [];
|
|
53
|
+
const cartActions = [];
|
|
53
54
|
const allergyRequirements = [];
|
|
54
55
|
if (!result.applicable || !businessData) {
|
|
55
56
|
return {
|
|
56
57
|
quantityChecks,
|
|
57
58
|
prefillItems,
|
|
59
|
+
cartActions,
|
|
58
60
|
allergyRequirements
|
|
59
61
|
};
|
|
60
62
|
}
|
|
@@ -66,7 +68,27 @@ class ItemRuleAdapter {
|
|
|
66
68
|
}
|
|
67
69
|
} else if (action.type === _type.ITEM_RULE_ACTION_TYPES.PREFILL_CART) {
|
|
68
70
|
const items = this.processPrefillCart(action, businessData);
|
|
69
|
-
prefillItems.push(...items);
|
|
71
|
+
prefillItems.push(...items.filter(item => item.quantity > 0));
|
|
72
|
+
if (items.length) {
|
|
73
|
+
cartActions.push({
|
|
74
|
+
type: _type.ITEM_RULE_ACTION_TYPES.PREFILL_CART,
|
|
75
|
+
strategyId: result.config.metadata.id,
|
|
76
|
+
ruleId: action.id,
|
|
77
|
+
priority: action.priority ?? 0,
|
|
78
|
+
products: items
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
} else if (action.type === _type.ITEM_RULE_ACTION_TYPES.DELETE_PRODUCT) {
|
|
82
|
+
const products = this.processDeleteProduct(action, businessData);
|
|
83
|
+
if (products.length) {
|
|
84
|
+
cartActions.push({
|
|
85
|
+
type: _type.ITEM_RULE_ACTION_TYPES.DELETE_PRODUCT,
|
|
86
|
+
strategyId: result.config.metadata.id,
|
|
87
|
+
ruleId: action.id,
|
|
88
|
+
priority: action.priority ?? 0,
|
|
89
|
+
products
|
|
90
|
+
});
|
|
91
|
+
}
|
|
70
92
|
} else if (action.type === _type.ITEM_RULE_ACTION_TYPES.ALLERGY_CHECK) {
|
|
71
93
|
const requirement = this.processAllergyCheck(action, result, businessData);
|
|
72
94
|
if (requirement) allergyRequirements.push(requirement);
|
|
@@ -75,6 +97,7 @@ class ItemRuleAdapter {
|
|
|
75
97
|
return {
|
|
76
98
|
quantityChecks,
|
|
77
99
|
prefillItems,
|
|
100
|
+
cartActions,
|
|
78
101
|
allergyRequirements
|
|
79
102
|
};
|
|
80
103
|
}
|
|
@@ -423,16 +446,24 @@ class ItemRuleAdapter {
|
|
|
423
446
|
|
|
424
447
|
processPrefillCart(action, businessData) {
|
|
425
448
|
const config = action.config;
|
|
426
|
-
if (!config?.products) return [];
|
|
449
|
+
if (!Array.isArray(config?.products)) return [];
|
|
450
|
+
if (config.scope !== businessData.executionScope) return [];
|
|
451
|
+
if (config.scope === 'set_handover' && action.target !== 'cart') return [];
|
|
427
452
|
const results = [];
|
|
428
453
|
for (const prefillProduct of config.products) {
|
|
429
454
|
const quantity = this.resolvePrefillQuantity(prefillProduct.quantityFrom, prefillProduct.quantity, businessData);
|
|
430
|
-
|
|
455
|
+
const shouldSyncZero = config.scope === 'set_handover' && prefillProduct.repeat_skip === true;
|
|
456
|
+
if (!Number.isFinite(quantity) || quantity < 0 || quantity === 0 && !shouldSyncZero) {
|
|
457
|
+
continue;
|
|
458
|
+
}
|
|
431
459
|
results.push({
|
|
432
460
|
ruleId: action.id,
|
|
433
461
|
product_id: prefillProduct.product_id,
|
|
434
462
|
product_variant_id: prefillProduct.product_variant_id,
|
|
435
|
-
quantity
|
|
463
|
+
quantity,
|
|
464
|
+
...(prefillProduct.repeat_skip !== undefined ? {
|
|
465
|
+
repeat_skip: prefillProduct.repeat_skip === true
|
|
466
|
+
} : {})
|
|
436
467
|
});
|
|
437
468
|
}
|
|
438
469
|
return results;
|
|
@@ -449,10 +480,29 @@ class ItemRuleAdapter {
|
|
|
449
480
|
return businessData.pax.adult;
|
|
450
481
|
case 'fixed':
|
|
451
482
|
return fixedValue ?? 0;
|
|
483
|
+
case 'main_product_number':
|
|
484
|
+
{
|
|
485
|
+
const mainProductNumber = businessData.mainProductNumber ?? 0;
|
|
486
|
+
return Number.isFinite(mainProductNumber) ? Math.max(0, mainProductNumber) : 0;
|
|
487
|
+
}
|
|
452
488
|
default:
|
|
453
489
|
return fixedValue ?? 0;
|
|
454
490
|
}
|
|
455
491
|
}
|
|
492
|
+
processDeleteProduct(action, businessData) {
|
|
493
|
+
const config = action.config;
|
|
494
|
+
if (action.target !== 'cart' || config?.scope !== 'set_handover' || config.scope !== businessData.executionScope || !Array.isArray(config.products)) {
|
|
495
|
+
return [];
|
|
496
|
+
}
|
|
497
|
+
const productIds = new Set();
|
|
498
|
+
for (const product of config.products) {
|
|
499
|
+
const productId = Number(product?.product_id);
|
|
500
|
+
if (Number.isInteger(productId) && productId > 0) productIds.add(productId);
|
|
501
|
+
}
|
|
502
|
+
return Array.from(productIds, product_id => ({
|
|
503
|
+
product_id
|
|
504
|
+
}));
|
|
505
|
+
}
|
|
456
506
|
}
|
|
457
507
|
exports.ItemRuleAdapter = ItemRuleAdapter;
|
|
458
508
|
var _default = exports.default = ItemRuleAdapter;
|