@pisell/pisellos 2.1.36 → 2.2.1
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/core/index.d.ts +8 -1
- package/dist/core/index.js +116 -42
- package/dist/effects/index.d.ts +1 -0
- package/dist/effects/index.js +29 -6
- package/dist/modules/Account/index.js +2 -3
- package/dist/modules/BaseModule.d.ts +3 -0
- package/dist/modules/BaseModule.js +15 -0
- package/dist/modules/Customer/index.js +9 -10
- package/dist/modules/Customer/types.d.ts +2 -2
- package/dist/modules/Customer/types.js +2 -2
- package/dist/modules/Discount/index.js +1 -1
- package/dist/modules/Guests/index.js +9 -9
- package/dist/modules/Order/index.js +1 -1
- package/dist/modules/Payment/index.js +63 -73
- package/dist/modules/Payment/walletpass.js +4 -1
- package/dist/modules/Product/types.d.ts +19 -0
- package/dist/modules/ProductList/index.js +5 -14
- package/dist/modules/Resource/index.js +1 -1
- package/dist/modules/Rules/index.js +2 -3
- package/dist/modules/Schedule/types.d.ts +2 -0
- package/dist/plugins/request.d.ts +1 -0
- package/dist/server/index.d.ts +152 -0
- package/dist/server/index.js +946 -0
- package/dist/server/modules/index.d.ts +16 -0
- package/dist/server/modules/index.js +21 -0
- package/dist/server/modules/menu/index.d.ts +63 -0
- package/dist/server/modules/menu/index.js +476 -0
- package/dist/server/modules/menu/types.d.ts +68 -0
- package/dist/server/modules/menu/types.js +16 -0
- package/dist/server/modules/products/index.d.ts +141 -0
- package/dist/server/modules/products/index.js +768 -0
- package/dist/server/modules/products/types.d.ts +94 -0
- package/dist/server/modules/products/types.js +43 -0
- package/dist/server/modules/quotation/index.d.ts +47 -0
- package/dist/server/modules/quotation/index.js +367 -0
- package/dist/server/modules/quotation/types.d.ts +50 -0
- package/dist/server/modules/quotation/types.js +20 -0
- package/dist/server/modules/schedule/index.d.ts +62 -0
- package/dist/server/modules/schedule/index.js +431 -0
- package/dist/server/modules/schedule/types.d.ts +1 -0
- package/dist/server/modules/schedule/types.js +2 -0
- package/dist/server/modules/schedule/utils.d.ts +32 -0
- package/dist/server/modules/schedule/utils.js +747 -0
- package/dist/server/types.d.ts +64 -0
- package/dist/server/types.js +1 -0
- package/dist/server/utils/index.d.ts +5 -0
- package/dist/server/utils/index.js +6 -0
- package/dist/server/utils/product.d.ts +18 -0
- package/dist/server/utils/product.js +339 -0
- package/dist/server/utils/schedule.d.ts +14 -0
- package/dist/server/utils/schedule.js +108 -0
- package/dist/server/utils/time.d.ts +18 -0
- package/dist/server/utils/time.js +53 -0
- package/dist/solution/BookingByStep/index.d.ts +0 -16
- package/dist/solution/BookingByStep/index.js +57 -508
- package/dist/solution/BookingByStep/utils/capacity.d.ts +2 -7
- package/dist/solution/BookingByStep/utils/capacity.js +8 -24
- package/dist/solution/BookingTicket/index.d.ts +12 -0
- package/dist/solution/BookingTicket/index.js +122 -79
- package/dist/solution/BookingTicket/utils/scan/index.d.ts +4 -0
- package/dist/solution/BookingTicket/utils/scan/index.js +25 -16
- package/dist/solution/BuyTickets/index.js +7 -8
- package/dist/solution/Checkout/index.d.ts +1 -46
- package/dist/solution/Checkout/index.js +530 -850
- package/dist/solution/ShopDiscount/index.js +9 -10
- package/dist/types/index.d.ts +27 -0
- package/lib/core/index.d.ts +8 -1
- package/lib/core/index.js +48 -1
- package/lib/effects/index.d.ts +1 -0
- package/lib/effects/index.js +13 -0
- package/lib/modules/Account/index.js +2 -3
- package/lib/modules/BaseModule.d.ts +3 -0
- package/lib/modules/BaseModule.js +9 -0
- package/lib/modules/Customer/index.js +9 -10
- package/lib/modules/Customer/types.d.ts +2 -2
- package/lib/modules/Customer/types.js +2 -2
- package/lib/modules/Discount/index.js +1 -1
- package/lib/modules/Guests/index.js +9 -9
- package/lib/modules/Order/index.js +1 -1
- package/lib/modules/Payment/index.js +56 -43
- package/lib/modules/Payment/walletpass.js +3 -1
- package/lib/modules/Product/types.d.ts +19 -0
- package/lib/modules/ProductList/index.js +4 -13
- package/lib/modules/Resource/index.js +1 -1
- package/lib/modules/Rules/index.js +2 -3
- package/lib/modules/Schedule/types.d.ts +2 -0
- package/lib/plugins/request.d.ts +1 -0
- package/lib/server/index.d.ts +152 -0
- package/lib/server/index.js +555 -0
- package/lib/server/modules/index.d.ts +16 -0
- package/lib/server/modules/index.js +47 -0
- package/lib/server/modules/menu/index.d.ts +63 -0
- package/lib/server/modules/menu/index.js +234 -0
- package/lib/server/modules/menu/types.d.ts +68 -0
- package/lib/server/modules/menu/types.js +33 -0
- package/lib/server/modules/products/index.d.ts +141 -0
- package/lib/server/modules/products/index.js +434 -0
- package/lib/server/modules/products/types.d.ts +94 -0
- package/lib/server/modules/products/types.js +35 -0
- package/lib/server/modules/quotation/index.d.ts +47 -0
- package/lib/server/modules/quotation/index.js +177 -0
- package/lib/server/modules/quotation/types.d.ts +50 -0
- package/lib/server/modules/quotation/types.js +33 -0
- package/lib/server/modules/schedule/index.d.ts +62 -0
- package/lib/server/modules/schedule/index.js +231 -0
- package/lib/server/modules/schedule/types.d.ts +1 -0
- package/lib/server/modules/schedule/types.js +23 -0
- package/lib/server/modules/schedule/utils.d.ts +32 -0
- package/lib/server/modules/schedule/utils.js +451 -0
- package/lib/server/types.d.ts +64 -0
- package/lib/server/types.js +17 -0
- package/lib/server/utils/index.d.ts +5 -0
- package/lib/server/utils/index.js +25 -0
- package/lib/server/utils/product.d.ts +18 -0
- package/lib/server/utils/product.js +262 -0
- package/lib/server/utils/schedule.d.ts +14 -0
- package/lib/server/utils/schedule.js +88 -0
- package/lib/server/utils/time.d.ts +18 -0
- package/lib/server/utils/time.js +70 -0
- package/lib/solution/BookingByStep/index.d.ts +0 -16
- package/lib/solution/BookingByStep/index.js +44 -316
- package/lib/solution/BookingByStep/utils/capacity.d.ts +2 -7
- package/lib/solution/BookingByStep/utils/capacity.js +8 -21
- package/lib/solution/BookingTicket/index.d.ts +12 -0
- package/lib/solution/BookingTicket/index.js +25 -6
- package/lib/solution/BookingTicket/utils/scan/index.d.ts +4 -0
- package/lib/solution/BookingTicket/utils/scan/index.js +7 -1
- package/lib/solution/BuyTickets/index.js +7 -8
- package/lib/solution/Checkout/index.d.ts +1 -46
- package/lib/solution/Checkout/index.js +92 -289
- package/lib/solution/ShopDiscount/index.js +10 -11
- package/lib/types/index.d.ts +27 -0
- package/package.json +2 -2
|
@@ -0,0 +1,262 @@
|
|
|
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/server/utils/product.ts
|
|
30
|
+
var product_exports = {};
|
|
31
|
+
__export(product_exports, {
|
|
32
|
+
applyDetailValueToProducts: () => applyDetailValueToProducts,
|
|
33
|
+
applyPriceDataToProducts: () => applyPriceDataToProducts,
|
|
34
|
+
getIsSessionProduct: () => getIsSessionProduct
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(product_exports);
|
|
37
|
+
var import_decimal = __toESM(require("decimal.js"));
|
|
38
|
+
var import_utils = require("../modules/schedule/utils");
|
|
39
|
+
var import_utils2 = require("../../modules/Cart/utils");
|
|
40
|
+
function buildPriceIndexMap(priceData) {
|
|
41
|
+
const priceMap = new Map(
|
|
42
|
+
priceData.map((p) => [p.id, p])
|
|
43
|
+
);
|
|
44
|
+
const variantMap = /* @__PURE__ */ new Map();
|
|
45
|
+
priceData.forEach((p) => {
|
|
46
|
+
if (p.variant && p.variant.length > 0) {
|
|
47
|
+
const variantById = new Map(p.variant.map((v) => [v.id, v]));
|
|
48
|
+
variantMap.set(p.id, variantById);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
const bundleMap = /* @__PURE__ */ new Map();
|
|
52
|
+
priceData.forEach((p) => {
|
|
53
|
+
if (p.bundle_group && p.bundle_group.length > 0) {
|
|
54
|
+
const groupMap = /* @__PURE__ */ new Map();
|
|
55
|
+
p.bundle_group.forEach((bg) => {
|
|
56
|
+
const itemMap = new Map(bg.bundle_item.map((bi) => [bi.id, bi]));
|
|
57
|
+
groupMap.set(bg.id, itemMap);
|
|
58
|
+
});
|
|
59
|
+
bundleMap.set(p.id, groupMap);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
return { priceMap, variantMap, bundleMap };
|
|
63
|
+
}
|
|
64
|
+
function applyPriceDataToProducts(products, priceData) {
|
|
65
|
+
if (!priceData || priceData.length === 0) {
|
|
66
|
+
console.log("[applyPriceDataToProducts] 没有价格数据,返回原商品");
|
|
67
|
+
return products;
|
|
68
|
+
}
|
|
69
|
+
const { priceMap, variantMap, bundleMap } = buildPriceIndexMap(priceData);
|
|
70
|
+
console.log(
|
|
71
|
+
`[applyPriceDataToProducts] 已构建价格索引,共 ${priceMap.size} 个商品价格`
|
|
72
|
+
);
|
|
73
|
+
const updatedProducts = products.map((product) => {
|
|
74
|
+
const priceInfo = priceMap.get(product.id);
|
|
75
|
+
if (!priceInfo) {
|
|
76
|
+
return product;
|
|
77
|
+
}
|
|
78
|
+
const updatedProduct = { ...product };
|
|
79
|
+
updatedProduct.price = priceInfo.price;
|
|
80
|
+
updatedProduct.base_price = priceInfo.base_price;
|
|
81
|
+
if (updatedProduct.variant && updatedProduct.variant.length > 0) {
|
|
82
|
+
const productVariantMap = variantMap.get(product.id);
|
|
83
|
+
if (productVariantMap) {
|
|
84
|
+
updatedProduct.variant = updatedProduct.variant.map((v) => {
|
|
85
|
+
const priceVariant = productVariantMap.get(v.id);
|
|
86
|
+
if (priceVariant) {
|
|
87
|
+
return {
|
|
88
|
+
...v,
|
|
89
|
+
price: String(priceVariant.price),
|
|
90
|
+
base_price: String(priceVariant.base_price)
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
return v;
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
if (updatedProduct.bundle_groups && updatedProduct.bundle_groups.length > 0) {
|
|
98
|
+
const productBundleMap = bundleMap.get(product.id);
|
|
99
|
+
if (productBundleMap) {
|
|
100
|
+
updatedProduct.bundle_groups = updatedProduct.bundle_groups.map(
|
|
101
|
+
(bg) => {
|
|
102
|
+
const groupItemMap = productBundleMap.get(bg.id);
|
|
103
|
+
if (!groupItemMap)
|
|
104
|
+
return bg;
|
|
105
|
+
return {
|
|
106
|
+
...bg,
|
|
107
|
+
bundle_item: bg.bundle_item.map((bi) => {
|
|
108
|
+
const priceBi = groupItemMap.get(bi.id);
|
|
109
|
+
if (priceBi) {
|
|
110
|
+
let price = priceBi.price;
|
|
111
|
+
if (priceBi.price_type === "markdown") {
|
|
112
|
+
price = new import_decimal.default(price || 0).mul(-1).toNumber();
|
|
113
|
+
}
|
|
114
|
+
return {
|
|
115
|
+
...bi,
|
|
116
|
+
price: String(price),
|
|
117
|
+
base_price: String(priceBi.base_price)
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
return bi;
|
|
121
|
+
})
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return updatedProduct;
|
|
128
|
+
});
|
|
129
|
+
console.log(
|
|
130
|
+
`[applyPriceDataToProducts] 已应用价格到 ${updatedProducts.length} 个商品`
|
|
131
|
+
);
|
|
132
|
+
return updatedProducts;
|
|
133
|
+
}
|
|
134
|
+
var getIsSessionProduct = (product) => {
|
|
135
|
+
return ["session_product", "session_ticket"].includes(product.extension_type);
|
|
136
|
+
};
|
|
137
|
+
var getIsOpenDetailModal = (product, context) => {
|
|
138
|
+
const isBundleProduct = product.bundle_group_count > 0;
|
|
139
|
+
const isOptionProduct = product.option_group_count > 0;
|
|
140
|
+
const isVariantProduct = product.is_variant > 0;
|
|
141
|
+
const isSessionProduct = getIsSessionProduct(product);
|
|
142
|
+
let scheduleTimeSlots = [];
|
|
143
|
+
if (isSessionProduct && product["schedule.ids"] && context.scheduleModule) {
|
|
144
|
+
const scheduleIds = product["schedule.ids"];
|
|
145
|
+
const productSchedules = context.scheduleModule.getScheduleByIds(scheduleIds);
|
|
146
|
+
scheduleTimeSlots = (0, import_utils.getScheduleStartEndTimePoints)(
|
|
147
|
+
context.schedule_date,
|
|
148
|
+
productSchedules
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
const isOpenDetailModal = isBundleProduct || isOptionProduct || isVariantProduct || scheduleTimeSlots.length > 1;
|
|
152
|
+
return {
|
|
153
|
+
isOpenDetailModal,
|
|
154
|
+
scheduleTimeSlots
|
|
155
|
+
};
|
|
156
|
+
};
|
|
157
|
+
var formatDataKey = (data) => {
|
|
158
|
+
var _a, _b, _c, _d;
|
|
159
|
+
const _data = {
|
|
160
|
+
...data
|
|
161
|
+
};
|
|
162
|
+
let key = `${_data.product_id}`;
|
|
163
|
+
let rowKey = key;
|
|
164
|
+
if (_data.product_variant_id) {
|
|
165
|
+
let str = `_${_data.product_variant_id}`;
|
|
166
|
+
key += str;
|
|
167
|
+
rowKey += str;
|
|
168
|
+
}
|
|
169
|
+
if ((_a = _data == null ? void 0 : _data.option) == null ? void 0 : _a.length) {
|
|
170
|
+
for (const item of _data.option) {
|
|
171
|
+
let str = `_${item.option_group_id}_${item.product_option_item_id}`;
|
|
172
|
+
key += str;
|
|
173
|
+
rowKey += `${str}_${item.quantity || item.num}`;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
if ((_b = _data == null ? void 0 : _data.bundle) == null ? void 0 : _b.length) {
|
|
177
|
+
for (const item of _data.bundle) {
|
|
178
|
+
let str = `_${item.group_id}_${item.bundle_product_id}`;
|
|
179
|
+
key += str;
|
|
180
|
+
rowKey += `${str}_${item.quantity || item.num}`;
|
|
181
|
+
if (item == null ? void 0 : item.option) {
|
|
182
|
+
for (const opt of item.option) {
|
|
183
|
+
let str2 = `_${opt.option_group_id}_${opt.product_option_item_id}`;
|
|
184
|
+
key += str2;
|
|
185
|
+
rowKey += `${str2}_${opt.quantity || opt.num}`;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
if (_data == null ? void 0 : _data.session) {
|
|
191
|
+
let str = `_${(_c = _data == null ? void 0 : _data.session) == null ? void 0 : _c.key}`;
|
|
192
|
+
key += str;
|
|
193
|
+
rowKey += str;
|
|
194
|
+
}
|
|
195
|
+
if (_data == null ? void 0 : _data.schedule) {
|
|
196
|
+
let str = `_${(_d = _data == null ? void 0 : _data.schedule) == null ? void 0 : _d.key}`;
|
|
197
|
+
key += str;
|
|
198
|
+
rowKey += str;
|
|
199
|
+
}
|
|
200
|
+
_data.key = key;
|
|
201
|
+
_data.rowKey = rowKey;
|
|
202
|
+
return _data;
|
|
203
|
+
};
|
|
204
|
+
var genCartDetailValue = (product, scheduleTimeSlots) => {
|
|
205
|
+
const params = {
|
|
206
|
+
product_id: product == null ? void 0 : product.id,
|
|
207
|
+
option: [],
|
|
208
|
+
bundle: [],
|
|
209
|
+
product_variant_id: 0,
|
|
210
|
+
quantity: 1,
|
|
211
|
+
unique: (0, import_utils2.getUniqueId)(),
|
|
212
|
+
session: null
|
|
213
|
+
};
|
|
214
|
+
if (scheduleTimeSlots.length) {
|
|
215
|
+
params.session = scheduleTimeSlots.map((item) => ({
|
|
216
|
+
...item,
|
|
217
|
+
unique: (0, import_utils2.getUniqueId)()
|
|
218
|
+
}))[0];
|
|
219
|
+
}
|
|
220
|
+
if (product == null ? void 0 : product.service_times) {
|
|
221
|
+
params.service_times = product == null ? void 0 : product.service_times;
|
|
222
|
+
}
|
|
223
|
+
if (product == null ? void 0 : product.machine_code) {
|
|
224
|
+
params.machine_code = product.machine_code;
|
|
225
|
+
}
|
|
226
|
+
if (product == null ? void 0 : product["schedule.ids"]) {
|
|
227
|
+
params.schedule_id = product["schedule.ids"];
|
|
228
|
+
}
|
|
229
|
+
if (product == null ? void 0 : product.policy) {
|
|
230
|
+
params.policy_id = product == null ? void 0 : product.policy;
|
|
231
|
+
}
|
|
232
|
+
if (product == null ? void 0 : product.duration) {
|
|
233
|
+
params.duration = product.duration;
|
|
234
|
+
}
|
|
235
|
+
return formatDataKey(params);
|
|
236
|
+
};
|
|
237
|
+
function applyDetailValueToProducts(products, context) {
|
|
238
|
+
const newProducts = products.map((product) => {
|
|
239
|
+
const { isOpenDetailModal, scheduleTimeSlots } = getIsOpenDetailModal(
|
|
240
|
+
product,
|
|
241
|
+
context
|
|
242
|
+
);
|
|
243
|
+
let cartDetailValue = null;
|
|
244
|
+
if (!isOpenDetailModal) {
|
|
245
|
+
cartDetailValue = genCartDetailValue(product, scheduleTimeSlots);
|
|
246
|
+
}
|
|
247
|
+
return {
|
|
248
|
+
...product,
|
|
249
|
+
// 是否打开详情弹窗
|
|
250
|
+
isOpenDetailModal,
|
|
251
|
+
// 购物车详情值
|
|
252
|
+
cartDetailValue
|
|
253
|
+
};
|
|
254
|
+
});
|
|
255
|
+
return newProducts;
|
|
256
|
+
}
|
|
257
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
258
|
+
0 && (module.exports = {
|
|
259
|
+
applyDetailValueToProducts,
|
|
260
|
+
applyPriceDataToProducts,
|
|
261
|
+
getIsSessionProduct
|
|
262
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ScheduleItem } from '../../modules/Schedule/types';
|
|
2
|
+
import type { MenuData } from '../modules/menu/types';
|
|
3
|
+
/**
|
|
4
|
+
* 从餐牌列表中提取所有 schedule IDs
|
|
5
|
+
* @param menus 餐牌列表
|
|
6
|
+
* @returns 去重后的日程ID数组
|
|
7
|
+
*/
|
|
8
|
+
export declare function extractScheduleIdsFromMenus(menus: MenuData[]): number[];
|
|
9
|
+
/**
|
|
10
|
+
* 从日程列表中提取所有时间点
|
|
11
|
+
* @param schedules 日程列表
|
|
12
|
+
* @returns 排序后的时间点数组,格式为 ["10:00", "12:00", "14:00", "18:00"]
|
|
13
|
+
*/
|
|
14
|
+
export declare function extractTimePointsFromSchedules(schedules: ScheduleItem[]): string[];
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/server/utils/schedule.ts
|
|
20
|
+
var schedule_exports = {};
|
|
21
|
+
__export(schedule_exports, {
|
|
22
|
+
extractScheduleIdsFromMenus: () => extractScheduleIdsFromMenus,
|
|
23
|
+
extractTimePointsFromSchedules: () => extractTimePointsFromSchedules
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(schedule_exports);
|
|
26
|
+
var import_time = require("./time");
|
|
27
|
+
function extractScheduleIdsFromMenus(menus) {
|
|
28
|
+
const scheduleIds = menus.reduce((ids, menu) => {
|
|
29
|
+
if (menu.schedule && Array.isArray(menu.schedule)) {
|
|
30
|
+
return [...ids, ...menu.schedule];
|
|
31
|
+
}
|
|
32
|
+
return ids;
|
|
33
|
+
}, []);
|
|
34
|
+
return Array.from(new Set(scheduleIds));
|
|
35
|
+
}
|
|
36
|
+
function extractTimePointsFromSchedules(schedules) {
|
|
37
|
+
const timePointsSet = /* @__PURE__ */ new Set();
|
|
38
|
+
for (const schedule of schedules) {
|
|
39
|
+
switch (schedule.type) {
|
|
40
|
+
case "standard":
|
|
41
|
+
if (schedule.start_time) {
|
|
42
|
+
const startTime = (0, import_time.extractTimeFromDateTime)(schedule.start_time);
|
|
43
|
+
if (startTime)
|
|
44
|
+
timePointsSet.add(startTime);
|
|
45
|
+
}
|
|
46
|
+
if (schedule.end_time) {
|
|
47
|
+
const endTime = (0, import_time.extractTimeFromDateTime)(schedule.end_time);
|
|
48
|
+
if (endTime)
|
|
49
|
+
timePointsSet.add(endTime);
|
|
50
|
+
}
|
|
51
|
+
break;
|
|
52
|
+
case "time-slots":
|
|
53
|
+
if (schedule.time_slot && Array.isArray(schedule.time_slot)) {
|
|
54
|
+
for (const slot of schedule.time_slot) {
|
|
55
|
+
if (slot.start_time) {
|
|
56
|
+
timePointsSet.add(slot.start_time);
|
|
57
|
+
}
|
|
58
|
+
if (slot.end_time) {
|
|
59
|
+
timePointsSet.add(slot.end_time);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
break;
|
|
64
|
+
case "designation":
|
|
65
|
+
if (schedule.designation) {
|
|
66
|
+
const designations = Array.isArray(schedule.designation) ? schedule.designation : [schedule.designation];
|
|
67
|
+
for (const des of designations) {
|
|
68
|
+
if (des.start_time) {
|
|
69
|
+
timePointsSet.add(des.start_time);
|
|
70
|
+
}
|
|
71
|
+
if (des.end_time) {
|
|
72
|
+
timePointsSet.add(des.end_time);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
break;
|
|
77
|
+
default:
|
|
78
|
+
console.warn(`[ScheduleUtils] 未知的日程类型: ${schedule.type}`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
const timePoints = Array.from(timePointsSet);
|
|
82
|
+
return (0, import_time.sortTimePoints)(timePoints);
|
|
83
|
+
}
|
|
84
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
85
|
+
0 && (module.exports = {
|
|
86
|
+
extractScheduleIdsFromMenus,
|
|
87
|
+
extractTimePointsFromSchedules
|
|
88
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 从日期时间字符串中提取时间部分
|
|
3
|
+
* @param dateTime 日期时间字符串,格式如 "2024-01-01 10:00:00"
|
|
4
|
+
* @returns 时间字符串,格式如 "10:00"
|
|
5
|
+
*/
|
|
6
|
+
export declare function extractTimeFromDateTime(dateTime: string): string | null;
|
|
7
|
+
/**
|
|
8
|
+
* 将时间字符串转换为分钟数(用于排序)
|
|
9
|
+
* @param timeStr 时间字符串,格式如 "10:00" 或 "14:30"
|
|
10
|
+
* @returns 从00:00开始的分钟数
|
|
11
|
+
*/
|
|
12
|
+
export declare function timeStringToMinutes(timeStr: string): number;
|
|
13
|
+
/**
|
|
14
|
+
* 对时间点数组进行排序
|
|
15
|
+
* @param timePoints 时间点数组
|
|
16
|
+
* @returns 排序后的时间点数组
|
|
17
|
+
*/
|
|
18
|
+
export declare function sortTimePoints(timePoints: string[]): string[];
|
|
@@ -0,0 +1,70 @@
|
|
|
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/server/utils/time.ts
|
|
30
|
+
var time_exports = {};
|
|
31
|
+
__export(time_exports, {
|
|
32
|
+
extractTimeFromDateTime: () => extractTimeFromDateTime,
|
|
33
|
+
sortTimePoints: () => sortTimePoints,
|
|
34
|
+
timeStringToMinutes: () => timeStringToMinutes
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(time_exports);
|
|
37
|
+
var import_dayjs = __toESM(require("dayjs"));
|
|
38
|
+
function extractTimeFromDateTime(dateTime) {
|
|
39
|
+
if (!dateTime)
|
|
40
|
+
return null;
|
|
41
|
+
const date = (0, import_dayjs.default)(dateTime);
|
|
42
|
+
if (!date.isValid()) {
|
|
43
|
+
console.warn(`[TimeUtils] 无效的日期时间格式: ${dateTime}`);
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
return date.format("HH:mm");
|
|
47
|
+
}
|
|
48
|
+
function timeStringToMinutes(timeStr) {
|
|
49
|
+
if (!timeStr)
|
|
50
|
+
return 0;
|
|
51
|
+
const date = (0, import_dayjs.default)(`2000-01-01 ${timeStr}`, "YYYY-MM-DD HH:mm");
|
|
52
|
+
if (!date.isValid()) {
|
|
53
|
+
console.warn(`[TimeUtils] 无效的时间格式: ${timeStr}`);
|
|
54
|
+
return 0;
|
|
55
|
+
}
|
|
56
|
+
return date.hour() * 60 + date.minute();
|
|
57
|
+
}
|
|
58
|
+
function sortTimePoints(timePoints) {
|
|
59
|
+
return timePoints.sort((a, b) => {
|
|
60
|
+
const timeA = timeStringToMinutes(a);
|
|
61
|
+
const timeB = timeStringToMinutes(b);
|
|
62
|
+
return timeA - timeB;
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
66
|
+
0 && (module.exports = {
|
|
67
|
+
extractTimeFromDateTime,
|
|
68
|
+
sortTimePoints,
|
|
69
|
+
timeStringToMinutes
|
|
70
|
+
});
|
|
@@ -324,22 +324,6 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
324
324
|
success: boolean;
|
|
325
325
|
minAvailableCount: number;
|
|
326
326
|
};
|
|
327
|
-
/**
|
|
328
|
-
* 将 ProductData 转换为 CartItem,但不添加到购物车
|
|
329
|
-
* 参考 addProductToCart 方法的实现
|
|
330
|
-
*/
|
|
331
|
-
private convertProductToCartItem;
|
|
332
|
-
checkMaxDurationCapacityForDetailNums({ product, date, account, }: {
|
|
333
|
-
product: ProductData;
|
|
334
|
-
date?: {
|
|
335
|
-
startTime: string;
|
|
336
|
-
endTime: string;
|
|
337
|
-
} | null;
|
|
338
|
-
account?: Account | null;
|
|
339
|
-
}): {
|
|
340
|
-
success: boolean;
|
|
341
|
-
minAvailableCount: number;
|
|
342
|
-
};
|
|
343
327
|
setOtherData(key: string, value: any): void;
|
|
344
328
|
getOtherData(key: string): any;
|
|
345
329
|
getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
|