@pisell/pisellos 2.1.166 → 2.1.168
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 +0 -1
- package/dist/index.js +0 -3
- package/dist/model/strategy/adapter/index.d.ts +0 -4
- package/dist/model/strategy/adapter/index.js +1 -5
- package/dist/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/modules/Cart/utils/changePrice.js +16 -9
- package/dist/modules/Discount/index.d.ts +2 -5
- package/dist/modules/Discount/index.js +1 -21
- package/dist/modules/Discount/types.d.ts +0 -4
- package/dist/modules/Order/index.d.ts +0 -1
- package/dist/modules/Order/index.js +6 -18
- package/dist/modules/Order/types.d.ts +0 -2
- package/dist/modules/ProductList/index.d.ts +1 -3
- package/dist/modules/ProductList/index.js +11 -22
- package/dist/modules/Schedule/getDateIsInSchedule.js +0 -5
- package/dist/solution/BookingByStep/index.d.ts +2 -2
- package/dist/solution/ScanOrder/index.js +1 -1
- package/dist/solution/ShopDiscount/index.js +15 -16
- package/dist/solution/VenueBooking/index.d.ts +3 -40
- package/dist/solution/VenueBooking/index.js +261 -394
- package/dist/solution/VenueBooking/types.d.ts +1 -3
- package/dist/solution/VenueBooking/types.js +0 -1
- package/dist/solution/VenueBooking/utils/dateSummary.d.ts +2 -2
- package/dist/solution/VenueBooking/utils/dateSummary.js +25 -12
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +6 -0
- package/dist/solution/VenueBooking/utils/slotMerge.js +9 -3
- package/dist/solution/VenueBooking/utils/timeSlot.d.ts +0 -2
- package/dist/solution/VenueBooking/utils/timeSlot.js +4 -9
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -3
- package/lib/model/strategy/adapter/index.d.ts +0 -4
- package/lib/model/strategy/adapter/index.js +2 -13
- package/lib/model/strategy/adapter/promotion/index.js +0 -49
- package/lib/modules/Cart/utils/changePrice.js +13 -9
- package/lib/modules/Discount/index.d.ts +2 -5
- package/lib/modules/Discount/index.js +1 -11
- package/lib/modules/Discount/types.d.ts +0 -4
- package/lib/modules/Order/index.d.ts +0 -1
- package/lib/modules/Order/index.js +1 -11
- package/lib/modules/Order/types.d.ts +0 -2
- package/lib/modules/ProductList/index.d.ts +1 -3
- package/lib/modules/ProductList/index.js +39 -45
- package/lib/modules/Schedule/getDateIsInSchedule.js +0 -4
- package/lib/solution/BookingByStep/index.d.ts +2 -2
- package/lib/solution/ScanOrder/index.js +1 -1
- package/lib/solution/ShopDiscount/index.js +2 -3
- package/lib/solution/VenueBooking/index.d.ts +3 -40
- package/lib/solution/VenueBooking/index.js +111 -257
- package/lib/solution/VenueBooking/types.d.ts +1 -3
- package/lib/solution/VenueBooking/types.js +0 -1
- package/lib/solution/VenueBooking/utils/dateSummary.d.ts +2 -2
- package/lib/solution/VenueBooking/utils/dateSummary.js +10 -5
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +6 -0
- package/lib/solution/VenueBooking/utils/slotMerge.js +4 -3
- package/lib/solution/VenueBooking/utils/timeSlot.d.ts +0 -2
- package/lib/solution/VenueBooking/utils/timeSlot.js +3 -7
- package/package.json +1 -1
- package/dist/model/strategy/adapter/dataVariant/adapter.d.ts +0 -50
- package/dist/model/strategy/adapter/dataVariant/adapter.js +0 -167
- package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +0 -89
- package/dist/model/strategy/adapter/dataVariant/evaluator.js +0 -780
- package/dist/model/strategy/adapter/dataVariant/examples.d.ts +0 -39
- package/dist/model/strategy/adapter/dataVariant/examples.js +0 -277
- package/dist/model/strategy/adapter/dataVariant/index.d.ts +0 -4
- package/dist/model/strategy/adapter/dataVariant/index.js +0 -4
- package/dist/model/strategy/adapter/dataVariant/type.d.ts +0 -148
- package/dist/model/strategy/adapter/dataVariant/type.js +0 -54
- package/dist/solution/VenueBooking/utils/smartPricing.d.ts +0 -70
- package/dist/solution/VenueBooking/utils/smartPricing.js +0 -233
- package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +0 -50
- package/lib/model/strategy/adapter/dataVariant/adapter.js +0 -149
- package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +0 -89
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +0 -583
- package/lib/model/strategy/adapter/dataVariant/examples.d.ts +0 -39
- package/lib/model/strategy/adapter/dataVariant/examples.js +0 -293
- package/lib/model/strategy/adapter/dataVariant/index.d.ts +0 -4
- package/lib/model/strategy/adapter/dataVariant/index.js +0 -38
- package/lib/model/strategy/adapter/dataVariant/type.d.ts +0 -148
- package/lib/model/strategy/adapter/dataVariant/type.js +0 -31
- package/lib/solution/VenueBooking/utils/smartPricing.d.ts +0 -70
- package/lib/solution/VenueBooking/utils/smartPricing.js +0 -180
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
|
|
29
|
-
// src/solution/VenueBooking/utils/smartPricing.ts
|
|
30
|
-
var smartPricing_exports = {};
|
|
31
|
-
__export(smartPricing_exports, {
|
|
32
|
-
buildDataVariantBusinessData: () => buildDataVariantBusinessData,
|
|
33
|
-
buildEvaluationDatetimes: () => buildEvaluationDatetimes,
|
|
34
|
-
buildSlotPriceMapByScheduleSegments: () => buildSlotPriceMapByScheduleSegments,
|
|
35
|
-
buildSlotStartDatetime: () => buildSlotStartDatetime,
|
|
36
|
-
extractProductPrice: () => extractProductPrice,
|
|
37
|
-
findSegmentEvalDatetime: () => findSegmentEvalDatetime,
|
|
38
|
-
formatProductsWithDataVariant: () => formatProductsWithDataVariant,
|
|
39
|
-
getPriceForProductAtDatetime: () => getPriceForProductAtDatetime,
|
|
40
|
-
getSlotPriceFromMap: () => getSlotPriceFromMap
|
|
41
|
-
});
|
|
42
|
-
module.exports = __toCommonJS(smartPricing_exports);
|
|
43
|
-
var import_dayjs = __toESM(require("dayjs"));
|
|
44
|
-
var import_timeSlot = require("./timeSlot");
|
|
45
|
-
function extractProductPrice(product) {
|
|
46
|
-
const price = (product == null ? void 0 : product.price) ?? (product == null ? void 0 : product.selling_price);
|
|
47
|
-
if (price == null || price === "")
|
|
48
|
-
return null;
|
|
49
|
-
return String(price);
|
|
50
|
-
}
|
|
51
|
-
function buildDataVariantBusinessData(products, context, scheduleDateTime) {
|
|
52
|
-
const strategyContext = context.strategy_context || {};
|
|
53
|
-
return {
|
|
54
|
-
products,
|
|
55
|
-
strategyConfigs: context.strategyConfigs,
|
|
56
|
-
scheduleDateTime,
|
|
57
|
-
scheduleList: context.scheduleList || [],
|
|
58
|
-
menuList: context.menuList || [],
|
|
59
|
-
customerId: context.customerId,
|
|
60
|
-
availableWalletIds: context.availableWalletIds ?? strategyContext.available_wallet_ids ?? strategyContext.availableWalletIds,
|
|
61
|
-
channel: context.channel ?? strategyContext.channel,
|
|
62
|
-
orderType: context.orderType ?? strategyContext.orderType ?? strategyContext.order_type,
|
|
63
|
-
businessCode: context.businessCode ?? strategyContext.business_code ?? strategyContext.businessCode,
|
|
64
|
-
custom: strategyContext
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
function formatProductsWithDataVariant(products, context, scheduleDateTime) {
|
|
68
|
-
const evaluator = context.evaluator;
|
|
69
|
-
if (!evaluator || typeof evaluator.resolveProducts !== "function") {
|
|
70
|
-
console.warn("[VenueBooking][smartPricing] dataVariantEvaluator 未注入,跳过智能定价格式化");
|
|
71
|
-
return products;
|
|
72
|
-
}
|
|
73
|
-
const resolvedAt = scheduleDateTime || (0, import_dayjs.default)().format("YYYY-MM-DD HH:mm:ss");
|
|
74
|
-
const businessData = buildDataVariantBusinessData(products, context, resolvedAt);
|
|
75
|
-
const result = evaluator.resolveProducts(businessData);
|
|
76
|
-
return Array.isArray(result == null ? void 0 : result.products) ? result.products : products;
|
|
77
|
-
}
|
|
78
|
-
function buildEvaluationDatetimes(params) {
|
|
79
|
-
const { date, config, scheduleTimePoints } = params;
|
|
80
|
-
const crossDay = (0, import_timeSlot.isBusinessHoursCrossDay)(config);
|
|
81
|
-
const businessStartHour = Number(config.businessStartTime.split(":")[0]);
|
|
82
|
-
const evalSet = /* @__PURE__ */ new Set();
|
|
83
|
-
evalSet.add(`${date} ${config.businessStartTime}`);
|
|
84
|
-
for (const timePoint of scheduleTimePoints) {
|
|
85
|
-
const hour = Number(timePoint.split(":")[0]);
|
|
86
|
-
const pointDate = crossDay && hour < businessStartHour ? (0, import_dayjs.default)(date).add(1, "day").format("YYYY-MM-DD") : date;
|
|
87
|
-
evalSet.add(`${pointDate} ${timePoint}`);
|
|
88
|
-
}
|
|
89
|
-
return Array.from(evalSet).sort((a, b) => {
|
|
90
|
-
const aMs = (0, import_dayjs.default)(a, ["YYYY-MM-DD HH:mm:ss", "YYYY-MM-DD HH:mm"]).valueOf();
|
|
91
|
-
const bMs = (0, import_dayjs.default)(b, ["YYYY-MM-DD HH:mm:ss", "YYYY-MM-DD HH:mm"]).valueOf();
|
|
92
|
-
return aMs - bMs;
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
function findSegmentEvalDatetime(slotDatetime, evalDatetimes) {
|
|
96
|
-
if (!evalDatetimes.length)
|
|
97
|
-
return slotDatetime;
|
|
98
|
-
const slotMs = (0, import_dayjs.default)(slotDatetime, ["YYYY-MM-DD HH:mm:ss", "YYYY-MM-DD HH:mm"]).valueOf();
|
|
99
|
-
let chosen = evalDatetimes[0];
|
|
100
|
-
for (const evalDt of evalDatetimes) {
|
|
101
|
-
const evalMs = (0, import_dayjs.default)(evalDt, ["YYYY-MM-DD HH:mm:ss", "YYYY-MM-DD HH:mm"]).valueOf();
|
|
102
|
-
if (evalMs <= slotMs) {
|
|
103
|
-
chosen = evalDt;
|
|
104
|
-
} else {
|
|
105
|
-
break;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
return chosen;
|
|
109
|
-
}
|
|
110
|
-
function buildSlotStartDatetime(date, label, config) {
|
|
111
|
-
const crossDay = (0, import_timeSlot.isBusinessHoursCrossDay)(config);
|
|
112
|
-
const businessStartHour = Number(config.businessStartTime.split(":")[0]);
|
|
113
|
-
const hour = Number(label.split(":")[0]);
|
|
114
|
-
const slotDate = crossDay && hour < businessStartHour ? (0, import_dayjs.default)(date).add(1, "day").format("YYYY-MM-DD") : date;
|
|
115
|
-
return (0, import_dayjs.default)(`${slotDate} ${label}`).format("YYYY-MM-DD HH:mm");
|
|
116
|
-
}
|
|
117
|
-
function buildSlotPriceMapByScheduleSegments(params) {
|
|
118
|
-
const { products, productIds, date, timeLabels, config, context } = params;
|
|
119
|
-
const map = /* @__PURE__ */ new Map();
|
|
120
|
-
if (!productIds.length || !timeLabels.length)
|
|
121
|
-
return map;
|
|
122
|
-
const evaluator = context.evaluator;
|
|
123
|
-
if (!evaluator || typeof evaluator.resolveProducts !== "function") {
|
|
124
|
-
return map;
|
|
125
|
-
}
|
|
126
|
-
const strategyConfigs = context.strategyConfigs || (typeof evaluator.getStrategyConfigs === "function" ? evaluator.getStrategyConfigs() : []);
|
|
127
|
-
const scheduleTimePoints = typeof evaluator.buildScheduleTimePoints === "function" ? evaluator.buildScheduleTimePoints(strategyConfigs, context.scheduleList || []) : [];
|
|
128
|
-
const evalDatetimes = buildEvaluationDatetimes({ date, config, scheduleTimePoints });
|
|
129
|
-
const priceCache = /* @__PURE__ */ new Map();
|
|
130
|
-
for (const evalDt of evalDatetimes) {
|
|
131
|
-
const resolved = formatProductsWithDataVariant(products, context, evalDt);
|
|
132
|
-
const priceByProductId = /* @__PURE__ */ new Map();
|
|
133
|
-
for (const product of resolved) {
|
|
134
|
-
const productId = Number(product.id);
|
|
135
|
-
if (!Number.isFinite(productId))
|
|
136
|
-
continue;
|
|
137
|
-
priceByProductId.set(productId, extractProductPrice(product));
|
|
138
|
-
}
|
|
139
|
-
priceCache.set(evalDt, priceByProductId);
|
|
140
|
-
}
|
|
141
|
-
for (const label of timeLabels) {
|
|
142
|
-
const slotStart = buildSlotStartDatetime(date, label, config);
|
|
143
|
-
const segmentEvalDt = findSegmentEvalDatetime(slotStart, evalDatetimes);
|
|
144
|
-
const priceByProductId = priceCache.get(segmentEvalDt);
|
|
145
|
-
for (const productId of productIds) {
|
|
146
|
-
const key = `${productId}:${slotStart}`;
|
|
147
|
-
const price = (priceByProductId == null ? void 0 : priceByProductId.get(productId)) ?? null;
|
|
148
|
-
if (price !== null) {
|
|
149
|
-
map.set(key, price);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
return map;
|
|
154
|
-
}
|
|
155
|
-
function getPriceForProductAtDatetime(params) {
|
|
156
|
-
const { products, context, productId, datetime, fallbackPrice } = params;
|
|
157
|
-
const resolved = formatProductsWithDataVariant(products, context, datetime);
|
|
158
|
-
const product = resolved.find((item) => Number(item.id) === Number(productId));
|
|
159
|
-
return extractProductPrice(product || {}) ?? fallbackPrice ?? "0.00";
|
|
160
|
-
}
|
|
161
|
-
function getSlotPriceFromMap(params) {
|
|
162
|
-
const { slotPriceMap, productId, slotStartTime, fallbackPrice } = params;
|
|
163
|
-
const key = `${productId}:${slotStartTime}`;
|
|
164
|
-
const mapped = slotPriceMap.get(key);
|
|
165
|
-
if (mapped != null)
|
|
166
|
-
return mapped;
|
|
167
|
-
return fallbackPrice ?? "0.00";
|
|
168
|
-
}
|
|
169
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
170
|
-
0 && (module.exports = {
|
|
171
|
-
buildDataVariantBusinessData,
|
|
172
|
-
buildEvaluationDatetimes,
|
|
173
|
-
buildSlotPriceMapByScheduleSegments,
|
|
174
|
-
buildSlotStartDatetime,
|
|
175
|
-
extractProductPrice,
|
|
176
|
-
findSegmentEvalDatetime,
|
|
177
|
-
formatProductsWithDataVariant,
|
|
178
|
-
getPriceForProductAtDatetime,
|
|
179
|
-
getSlotPriceFromMap
|
|
180
|
-
});
|