@pisell/pisellos 2.2.171 → 2.2.172
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/modules/BookingContext/index.d.ts +37 -0
- package/dist/modules/BookingContext/index.js +436 -0
- package/dist/modules/BookingContext/types.d.ts +102 -0
- package/dist/modules/BookingContext/types.js +51 -0
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +16 -0
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +193 -0
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +137 -0
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +75 -0
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +215 -0
- package/dist/modules/BookingContext/utils/flexible.d.ts +28 -0
- package/dist/modules/BookingContext/utils/flexible.js +56 -0
- package/dist/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
- package/dist/modules/BookingContext/utils/formatResourceList.js +38 -0
- package/dist/modules/BookingContext/utils/index.d.ts +11 -0
- package/dist/modules/BookingContext/utils/index.js +11 -0
- package/dist/modules/BookingContext/utils/noResource.d.ts +13 -0
- package/dist/modules/BookingContext/utils/noResource.js +77 -0
- package/dist/modules/BookingContext/utils/productExtend.d.ts +72 -0
- package/dist/modules/BookingContext/utils/productExtend.js +339 -0
- package/dist/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
- package/dist/modules/BookingContext/utils/resourceErrors.js +74 -0
- package/dist/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
- package/dist/modules/BookingContext/utils/resourceSelection.js +24 -0
- package/dist/modules/BookingContext/utils/resources.d.ts +80 -0
- package/dist/modules/BookingContext/utils/resources.js +486 -0
- package/dist/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
- package/dist/modules/BookingContext/utils/serviceTimes.js +151 -0
- package/dist/modules/BookingContext/utils/timeSlices.d.ts +42 -0
- package/dist/modules/BookingContext/utils/timeSlices.js +100 -0
- package/dist/modules/Customer/index.d.ts +6 -0
- package/dist/modules/Customer/index.js +129 -83
- package/dist/modules/Customer/types.d.ts +2 -0
- package/dist/modules/Discount/index.d.ts +2 -4
- package/dist/modules/Discount/index.js +8 -93
- package/dist/modules/Discount/types.d.ts +1 -7
- package/dist/modules/Order/index.d.ts +47 -16
- package/dist/modules/Order/index.js +743 -334
- package/dist/modules/Order/types.d.ts +57 -17
- package/dist/modules/Order/types.js +2 -0
- package/dist/modules/Order/utils/manualProductDiscount.d.ts +106 -0
- package/dist/modules/Order/utils/manualProductDiscount.js +212 -0
- package/dist/modules/Order/utils.d.ts +23 -1
- package/dist/modules/Order/utils.js +139 -30
- package/dist/modules/Quotation/index.js +16 -5
- package/dist/modules/Rules/index.d.ts +4 -0
- package/dist/modules/Rules/index.js +26 -10
- package/dist/modules/SalesSummary/index.js +4 -2
- package/dist/modules/Schedule/index.js +6 -2
- package/dist/modules/index.d.ts +1 -0
- package/dist/modules/index.js +2 -1
- package/dist/server/index.js +10 -6
- package/dist/server/modules/order/utils/filterOrders.js +20 -6
- package/dist/server/modules/products/index.js +9 -8
- package/dist/server/modules/schedule/index.js +13 -6
- package/dist/solution/BaseSales/index.d.ts +65 -7
- package/dist/solution/BaseSales/index.js +1066 -315
- package/dist/solution/BaseSales/types.d.ts +53 -1
- package/dist/solution/BaseSales/types.js +3 -1
- package/dist/solution/BaseSales/utils/quotationPrice.d.ts +7 -0
- package/dist/solution/BaseSales/utils/quotationPrice.js +159 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +65 -15
- package/dist/solution/BaseSales/utils.js +46 -8
- package/dist/solution/BookingTicket/index.d.ts +134 -2
- package/dist/solution/BookingTicket/index.js +768 -175
- package/dist/solution/BookingTicket/types.d.ts +2 -0
- package/dist/solution/BookingTicket/types.js +3 -0
- package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +113 -0
- package/dist/solution/BookingTicket/utils/addProductDecision.js +346 -0
- package/dist/solution/ScanOrder/index.d.ts +9 -3
- package/dist/solution/ScanOrder/index.js +231 -128
- package/dist/solution/ScanOrder/utils.js +46 -8
- package/dist/solution/ShopDiscount/index.d.ts +0 -1
- package/dist/solution/ShopDiscount/index.js +18 -23
- package/dist/solution/VenueBooking/index.d.ts +5 -9
- package/dist/solution/VenueBooking/index.js +103 -55
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +4 -0
- package/dist/solution/VenueBooking/utils/slotMerge.js +10 -0
- package/lib/modules/BookingContext/index.d.ts +37 -0
- package/lib/modules/BookingContext/index.js +297 -0
- package/lib/modules/BookingContext/types.d.ts +102 -0
- package/lib/modules/BookingContext/types.js +34 -0
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +16 -0
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +207 -0
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +141 -0
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +75 -0
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +198 -0
- package/lib/modules/BookingContext/utils/flexible.d.ts +28 -0
- package/lib/modules/BookingContext/utils/flexible.js +80 -0
- package/lib/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
- package/lib/modules/BookingContext/utils/formatResourceList.js +50 -0
- package/lib/modules/BookingContext/utils/index.d.ts +11 -0
- package/lib/modules/BookingContext/utils/index.js +43 -0
- package/lib/modules/BookingContext/utils/noResource.d.ts +13 -0
- package/lib/modules/BookingContext/utils/noResource.js +90 -0
- package/lib/modules/BookingContext/utils/productExtend.d.ts +72 -0
- package/lib/modules/BookingContext/utils/productExtend.js +283 -0
- package/lib/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
- package/lib/modules/BookingContext/utils/resourceErrors.js +80 -0
- package/lib/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
- package/lib/modules/BookingContext/utils/resourceSelection.js +46 -0
- package/lib/modules/BookingContext/utils/resources.d.ts +80 -0
- package/lib/modules/BookingContext/utils/resources.js +377 -0
- package/lib/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
- package/lib/modules/BookingContext/utils/serviceTimes.js +162 -0
- package/lib/modules/BookingContext/utils/timeSlices.d.ts +42 -0
- package/lib/modules/BookingContext/utils/timeSlices.js +124 -0
- package/lib/modules/Customer/index.d.ts +6 -0
- package/lib/modules/Customer/index.js +26 -11
- package/lib/modules/Customer/types.d.ts +2 -0
- package/lib/modules/Discount/index.d.ts +2 -4
- package/lib/modules/Discount/index.js +8 -63
- package/lib/modules/Discount/types.d.ts +1 -7
- package/lib/modules/Order/index.d.ts +47 -16
- package/lib/modules/Order/index.js +389 -90
- package/lib/modules/Order/types.d.ts +57 -17
- package/lib/modules/Order/utils/manualProductDiscount.d.ts +106 -0
- package/lib/modules/Order/utils/manualProductDiscount.js +207 -0
- package/lib/modules/Order/utils.d.ts +23 -1
- package/lib/modules/Order/utils.js +145 -21
- package/lib/modules/Quotation/index.js +17 -6
- package/lib/modules/Rules/index.d.ts +4 -0
- package/lib/modules/Rules/index.js +22 -14
- package/lib/modules/SalesSummary/index.js +4 -2
- package/lib/modules/Schedule/index.js +3 -1
- package/lib/modules/index.d.ts +1 -0
- package/lib/modules/index.js +3 -1
- package/lib/server/index.js +2 -0
- package/lib/server/modules/order/utils/filterOrders.js +12 -4
- package/lib/server/modules/products/index.js +8 -9
- package/lib/server/modules/schedule/index.js +2 -1
- package/lib/solution/BaseSales/index.d.ts +65 -7
- package/lib/solution/BaseSales/index.js +492 -20
- package/lib/solution/BaseSales/types.d.ts +53 -1
- package/lib/solution/BaseSales/types.js +3 -1
- package/lib/solution/BaseSales/utils/quotationPrice.d.ts +7 -0
- package/lib/solution/BaseSales/utils/quotationPrice.js +201 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +70 -11
- package/lib/solution/BaseSales/utils.js +46 -6
- package/lib/solution/BookingTicket/index.d.ts +134 -2
- package/lib/solution/BookingTicket/index.js +341 -8
- package/lib/solution/BookingTicket/types.d.ts +2 -0
- package/lib/solution/BookingTicket/types.js +6 -0
- package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +113 -0
- package/lib/solution/BookingTicket/utils/addProductDecision.js +318 -0
- package/lib/solution/ScanOrder/index.d.ts +9 -3
- package/lib/solution/ScanOrder/index.js +147 -66
- package/lib/solution/ScanOrder/utils.js +46 -6
- package/lib/solution/ShopDiscount/index.d.ts +0 -1
- package/lib/solution/ShopDiscount/index.js +2 -4
- package/lib/solution/VenueBooking/index.d.ts +5 -9
- package/lib/solution/VenueBooking/index.js +50 -14
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +4 -0
- package/lib/solution/VenueBooking/utils/slotMerge.js +10 -0
- package/package.json +2 -2
|
@@ -0,0 +1,207 @@
|
|
|
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/modules/BookingContext/utils/buildCacheItemFromOrderLine.ts
|
|
30
|
+
var buildCacheItemFromOrderLine_exports = {};
|
|
31
|
+
__export(buildCacheItemFromOrderLine_exports, {
|
|
32
|
+
buildCacheItemFromOrderLine: () => buildCacheItemFromOrderLine
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(buildCacheItemFromOrderLine_exports);
|
|
35
|
+
var import_dayjs = __toESM(require("dayjs"));
|
|
36
|
+
var import_manualProductDiscount = require("../../Order/utils/manualProductDiscount");
|
|
37
|
+
function safeFormat(value, fmt) {
|
|
38
|
+
if (value === void 0 || value === null)
|
|
39
|
+
return void 0;
|
|
40
|
+
const d = (0, import_dayjs.default)(value);
|
|
41
|
+
if (!d.isValid())
|
|
42
|
+
return void 0;
|
|
43
|
+
return d.format(fmt);
|
|
44
|
+
}
|
|
45
|
+
function normalizeTimeString(value) {
|
|
46
|
+
if (value === void 0 || value === null)
|
|
47
|
+
return void 0;
|
|
48
|
+
if (typeof value === "string") {
|
|
49
|
+
const t = value.trim();
|
|
50
|
+
const hhmmFromHhmmss = t.match(/^(\d{1,2}:\d{2}):\d{2}$/);
|
|
51
|
+
if (hhmmFromHhmmss)
|
|
52
|
+
return hhmmFromHhmmss[1];
|
|
53
|
+
if (/^\d{1,2}:\d{2}$/.test(t))
|
|
54
|
+
return t;
|
|
55
|
+
}
|
|
56
|
+
const d = (0, import_dayjs.default)(value);
|
|
57
|
+
if (d.isValid())
|
|
58
|
+
return d.format("HH:mm");
|
|
59
|
+
return void 0;
|
|
60
|
+
}
|
|
61
|
+
function unflattenResourceMap(resources) {
|
|
62
|
+
const map = {};
|
|
63
|
+
if (!Array.isArray(resources))
|
|
64
|
+
return map;
|
|
65
|
+
resources.forEach((r) => {
|
|
66
|
+
const formId = r == null ? void 0 : r.form_id;
|
|
67
|
+
if (formId === void 0 || formId === null)
|
|
68
|
+
return;
|
|
69
|
+
const key = String(formId);
|
|
70
|
+
if (!map[key])
|
|
71
|
+
map[key] = [];
|
|
72
|
+
map[key].push({
|
|
73
|
+
form_id: formId,
|
|
74
|
+
relation_id: r.relation_id,
|
|
75
|
+
relation_type: r.relation_type || "form",
|
|
76
|
+
like_status: r.like_status || "common",
|
|
77
|
+
metadata: r.metadata ? { ...r.metadata } : void 0,
|
|
78
|
+
children: r.children
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
return map;
|
|
82
|
+
}
|
|
83
|
+
function resolveCapacityFromBooking(booking) {
|
|
84
|
+
var _a;
|
|
85
|
+
const metaCap = (_a = booking.metadata) == null ? void 0 : _a.capacity;
|
|
86
|
+
if (Array.isArray(metaCap) && metaCap.length > 0) {
|
|
87
|
+
return metaCap.map((item) => {
|
|
88
|
+
if (!item || typeof item !== "object")
|
|
89
|
+
return null;
|
|
90
|
+
if (item.id === void 0 || item.id === null)
|
|
91
|
+
return null;
|
|
92
|
+
const row = {
|
|
93
|
+
id: item.id,
|
|
94
|
+
value: Number(item.value ?? 0)
|
|
95
|
+
};
|
|
96
|
+
if (item.name !== void 0)
|
|
97
|
+
row.name = item.name;
|
|
98
|
+
return row;
|
|
99
|
+
}).filter((item) => item != null);
|
|
100
|
+
}
|
|
101
|
+
if (typeof metaCap === "number" && Number.isFinite(metaCap)) {
|
|
102
|
+
return [{ id: 0, value: metaCap, name: "" }];
|
|
103
|
+
}
|
|
104
|
+
return [];
|
|
105
|
+
}
|
|
106
|
+
function resolveDurationForExtend(booking) {
|
|
107
|
+
const duration = booking.duration;
|
|
108
|
+
if (booking.sub_type === "days" || booking.is_all === 1) {
|
|
109
|
+
return duration;
|
|
110
|
+
}
|
|
111
|
+
if (typeof duration === "number" && Number.isFinite(duration)) {
|
|
112
|
+
return duration;
|
|
113
|
+
}
|
|
114
|
+
return duration;
|
|
115
|
+
}
|
|
116
|
+
function buildCacheItemFromOrderLine(input) {
|
|
117
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
118
|
+
const { product, booking, sourceProduct } = input;
|
|
119
|
+
const resolvedId = product.product_id ?? (sourceProduct == null ? void 0 : sourceProduct.id);
|
|
120
|
+
const selling = Number(product.selling_price ?? 0);
|
|
121
|
+
const original = Number(product.original_price ?? selling);
|
|
122
|
+
const startDate = safeFormat(booking.start_date, "YYYY-MM-DD");
|
|
123
|
+
const endDate = safeFormat(booking.end_date, "YYYY-MM-DD");
|
|
124
|
+
const startTime = normalizeTimeString(booking.start_time);
|
|
125
|
+
const endTime = normalizeTimeString(booking.end_time);
|
|
126
|
+
const resource = unflattenResourceMap(booking.resources);
|
|
127
|
+
const capacity = resolveCapacityFromBooking(booking);
|
|
128
|
+
const holderId = ((_a = booking.metadata) == null ? void 0 : _a.holder_id) ?? booking.holder_id;
|
|
129
|
+
const other = {
|
|
130
|
+
product_variant_id: product.product_variant_id ?? 0,
|
|
131
|
+
option: Array.isArray(product.product_option_item) ? [...product.product_option_item] : [],
|
|
132
|
+
bundle: Array.isArray(product.product_bundle) ? [...product.product_bundle] : []
|
|
133
|
+
};
|
|
134
|
+
const extend = {
|
|
135
|
+
start_date: startDate ? (0, import_dayjs.default)(startDate) : void 0,
|
|
136
|
+
end_date: endDate ? (0, import_dayjs.default)(endDate) : void 0,
|
|
137
|
+
startDate: startDate ? (0, import_dayjs.default)(startDate) : void 0,
|
|
138
|
+
endDate: endDate ? (0, import_dayjs.default)(endDate) : void 0,
|
|
139
|
+
start_time: startTime,
|
|
140
|
+
end_time: endTime,
|
|
141
|
+
duration: resolveDurationForExtend(booking),
|
|
142
|
+
sub_type: booking.sub_type,
|
|
143
|
+
quantity: product.num ?? 1,
|
|
144
|
+
product_name: (sourceProduct == null ? void 0 : sourceProduct.title) ?? ((_b = booking == null ? void 0 : booking.product) == null ? void 0 : _b.title) ?? ((_c = booking == null ? void 0 : booking.detail) == null ? void 0 : _c.product_title) ?? "",
|
|
145
|
+
note: product.note ?? ((_d = booking == null ? void 0 : booking.detail) == null ? void 0 : _d.note) ?? "",
|
|
146
|
+
price: selling,
|
|
147
|
+
total: selling,
|
|
148
|
+
origin_total: original,
|
|
149
|
+
resource,
|
|
150
|
+
capacity,
|
|
151
|
+
holder_id: holderId,
|
|
152
|
+
other,
|
|
153
|
+
like_status: booking.like_status || "common",
|
|
154
|
+
discount_reason: (0, import_manualProductDiscount.resolveManualDiscountMessage)(
|
|
155
|
+
product.discount_list,
|
|
156
|
+
(_e = product.metadata) == null ? void 0 : _e.product_discount_reason
|
|
157
|
+
) || void 0
|
|
158
|
+
};
|
|
159
|
+
const manualDiscount = (product.discount_list || []).find((d) => (d == null ? void 0 : d.type) === "product");
|
|
160
|
+
if (manualDiscount && extend.origin_total === selling) {
|
|
161
|
+
const manualAmount = Number(manualDiscount.amount ?? 0);
|
|
162
|
+
if (Number.isFinite(manualAmount) && manualAmount > 0) {
|
|
163
|
+
extend.origin_total = selling + manualAmount;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
if (((_f = product.metadata) == null ? void 0 : _f.price_override) != null || manualDiscount) {
|
|
167
|
+
extend.priceOverride = selling;
|
|
168
|
+
}
|
|
169
|
+
if (booking.holder !== void 0) {
|
|
170
|
+
extend.holder = booking.holder;
|
|
171
|
+
}
|
|
172
|
+
if (Array.isArray(booking.relation_forms)) {
|
|
173
|
+
extend.relation_forms = booking.relation_forms;
|
|
174
|
+
}
|
|
175
|
+
const base = {
|
|
176
|
+
...sourceProduct || {},
|
|
177
|
+
id: resolvedId,
|
|
178
|
+
product_id: resolvedId,
|
|
179
|
+
extension_type: (sourceProduct == null ? void 0 : sourceProduct.extension_type) ?? ((_g = booking == null ? void 0 : booking.product) == null ? void 0 : _g.extension_type) ?? (sourceProduct == null ? void 0 : sourceProduct.extension_type),
|
|
180
|
+
title: (sourceProduct == null ? void 0 : sourceProduct.title) ?? ((_h = booking == null ? void 0 : booking.product) == null ? void 0 : _h.title),
|
|
181
|
+
price: (sourceProduct == null ? void 0 : sourceProduct.price) ?? selling,
|
|
182
|
+
selling_price: product.selling_price,
|
|
183
|
+
original_price: product.original_price,
|
|
184
|
+
_extend: extend,
|
|
185
|
+
new: 0,
|
|
186
|
+
autoClose: false,
|
|
187
|
+
order_detail_id: product.order_detail_id ?? null,
|
|
188
|
+
booking_id: booking.id ?? booking.booking_id ?? 0
|
|
189
|
+
};
|
|
190
|
+
if ((sourceProduct == null ? void 0 : sourceProduct.capacity) !== void 0) {
|
|
191
|
+
base.capacity = sourceProduct.capacity;
|
|
192
|
+
}
|
|
193
|
+
if ((sourceProduct == null ? void 0 : sourceProduct.duration) !== void 0) {
|
|
194
|
+
base.duration = sourceProduct.duration;
|
|
195
|
+
}
|
|
196
|
+
if ((sourceProduct == null ? void 0 : sourceProduct.product_resource) !== void 0) {
|
|
197
|
+
base.product_resource = sourceProduct.product_resource;
|
|
198
|
+
}
|
|
199
|
+
if (booking.schedule_event_id !== void 0) {
|
|
200
|
+
base.schedule_event_id = booking.schedule_event_id;
|
|
201
|
+
}
|
|
202
|
+
return base;
|
|
203
|
+
}
|
|
204
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
205
|
+
0 && (module.exports = {
|
|
206
|
+
buildCacheItemFromOrderLine
|
|
207
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { OrderProduct } from '../../Order/types';
|
|
2
|
+
export interface BuildNormalProductCacheItemFromOrderLineInput {
|
|
3
|
+
/** tempOrder.products 中的一行(普通商品,无关联 booking) */
|
|
4
|
+
product: OrderProduct;
|
|
5
|
+
/** 商品 catalog / 详情,用于 variant / option / bundle 模板字段 */
|
|
6
|
+
sourceProduct?: Record<string, any> | null;
|
|
7
|
+
}
|
|
8
|
+
export declare function buildNormalProductCacheItemFromOrderLine(input: BuildNormalProductCacheItemFromOrderLineInput): Record<string, any>;
|
|
@@ -0,0 +1,141 @@
|
|
|
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/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.ts
|
|
20
|
+
var buildNormalProductCacheItemFromOrderLine_exports = {};
|
|
21
|
+
__export(buildNormalProductCacheItemFromOrderLine_exports, {
|
|
22
|
+
buildNormalProductCacheItemFromOrderLine: () => buildNormalProductCacheItemFromOrderLine
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(buildNormalProductCacheItemFromOrderLine_exports);
|
|
25
|
+
function resolveSourceProductPrice(product, sourceProduct) {
|
|
26
|
+
var _a, _b, _c;
|
|
27
|
+
const metadata = product.metadata || {};
|
|
28
|
+
if (metadata.source_product_price !== void 0 && metadata.source_product_price !== null) {
|
|
29
|
+
const parsed = Number(metadata.source_product_price);
|
|
30
|
+
if (Number.isFinite(parsed))
|
|
31
|
+
return parsed;
|
|
32
|
+
}
|
|
33
|
+
const variantId = Number(product.product_variant_id || 0);
|
|
34
|
+
if (variantId > 0) {
|
|
35
|
+
const variantList = ((_a = metadata.origin) == null ? void 0 : _a.variant) ?? (sourceProduct == null ? void 0 : sourceProduct.variant);
|
|
36
|
+
if (Array.isArray(variantList)) {
|
|
37
|
+
const matched = variantList.find((v) => Number(v == null ? void 0 : v.id) === variantId);
|
|
38
|
+
const variantPrice = (matched == null ? void 0 : matched.price) ?? (matched == null ? void 0 : matched.base_price);
|
|
39
|
+
if (variantPrice !== void 0 && variantPrice !== null) {
|
|
40
|
+
const parsed = Number(variantPrice);
|
|
41
|
+
if (Number.isFinite(parsed))
|
|
42
|
+
return parsed;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
const catalogPrice = (sourceProduct == null ? void 0 : sourceProduct.price) ?? (sourceProduct == null ? void 0 : sourceProduct.base_price);
|
|
47
|
+
if (catalogPrice !== void 0 && catalogPrice !== null) {
|
|
48
|
+
const parsed = Number(catalogPrice);
|
|
49
|
+
if (Number.isFinite(parsed))
|
|
50
|
+
return parsed;
|
|
51
|
+
}
|
|
52
|
+
const originPrice = ((_b = metadata.origin) == null ? void 0 : _b.price) ?? ((_c = metadata.origin) == null ? void 0 : _c.base_price);
|
|
53
|
+
if (originPrice !== void 0 && originPrice !== null) {
|
|
54
|
+
const parsed = Number(originPrice);
|
|
55
|
+
if (Number.isFinite(parsed))
|
|
56
|
+
return parsed;
|
|
57
|
+
}
|
|
58
|
+
return Number(product.selling_price ?? 0);
|
|
59
|
+
}
|
|
60
|
+
function mapOrderBundleToOtherBundle(bundle) {
|
|
61
|
+
return bundle.map((item) => {
|
|
62
|
+
const catalogOriginal = item.original_price ?? item.product_price ?? item.price ?? item.bundle_selling_price;
|
|
63
|
+
const selling = item.bundle_selling_price ?? item.price ?? catalogOriginal;
|
|
64
|
+
const { bundle_selling_price: _omitBundleSelling, ...rest } = item;
|
|
65
|
+
return {
|
|
66
|
+
...rest,
|
|
67
|
+
price: selling,
|
|
68
|
+
original_price: catalogOriginal,
|
|
69
|
+
original_total: item.original_total ?? catalogOriginal,
|
|
70
|
+
num: item.num ?? item.quantity ?? 1,
|
|
71
|
+
quantity: item.quantity ?? item.num ?? 1
|
|
72
|
+
};
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
function buildNormalProductCacheItemFromOrderLine(input) {
|
|
76
|
+
var _a, _b, _c, _d;
|
|
77
|
+
const { product, sourceProduct } = input;
|
|
78
|
+
const resolvedId = product.product_id ?? (sourceProduct == null ? void 0 : sourceProduct.id);
|
|
79
|
+
const sourcePrice = resolveSourceProductPrice(product, sourceProduct);
|
|
80
|
+
const selling = Number(product.selling_price ?? 0);
|
|
81
|
+
const original = Number(product.original_price ?? selling);
|
|
82
|
+
const uid = (_a = product.metadata) == null ? void 0 : _a.unique_identification_number;
|
|
83
|
+
const option = Array.isArray(product.product_option_item) ? [...product.product_option_item] : [];
|
|
84
|
+
const bundle = mapOrderBundleToOtherBundle(
|
|
85
|
+
Array.isArray(product.product_bundle) ? product.product_bundle : []
|
|
86
|
+
);
|
|
87
|
+
const originExtend = (_c = (_b = product.metadata) == null ? void 0 : _b.origin) == null ? void 0 : _c._extend;
|
|
88
|
+
const other = {
|
|
89
|
+
product_id: resolvedId,
|
|
90
|
+
product_variant_id: product.product_variant_id ?? 0,
|
|
91
|
+
option,
|
|
92
|
+
bundle: ((_d = originExtend == null ? void 0 : originExtend.other) == null ? void 0 : _d.bundle) ? JSON.parse(JSON.stringify(originExtend.other.bundle)) : bundle,
|
|
93
|
+
quantity: product.num ?? 1
|
|
94
|
+
};
|
|
95
|
+
const skuValue = {
|
|
96
|
+
product_id: resolvedId,
|
|
97
|
+
product_variant_id: product.product_variant_id ?? 0,
|
|
98
|
+
option: other.option,
|
|
99
|
+
bundle: other.bundle
|
|
100
|
+
};
|
|
101
|
+
const extend = {
|
|
102
|
+
quantity: product.num ?? 1,
|
|
103
|
+
product_name: (sourceProduct == null ? void 0 : sourceProduct.title) ?? "",
|
|
104
|
+
note: product.note ?? "",
|
|
105
|
+
// v2:_extend.price 为主商品 source 价;行 composite 用 total / origin_total 展示
|
|
106
|
+
price: (originExtend == null ? void 0 : originExtend.price) ?? sourcePrice,
|
|
107
|
+
total: (originExtend == null ? void 0 : originExtend.total) ?? selling,
|
|
108
|
+
origin_total: (originExtend == null ? void 0 : originExtend.origin_total) ?? original,
|
|
109
|
+
other,
|
|
110
|
+
skuValue: JSON.parse(JSON.stringify(skuValue)),
|
|
111
|
+
_skuValue: JSON.parse(JSON.stringify(skuValue)),
|
|
112
|
+
isNormalProduct: true,
|
|
113
|
+
...(originExtend == null ? void 0 : originExtend.priceOverride) !== void 0 ? { priceOverride: originExtend.priceOverride } : {},
|
|
114
|
+
...(originExtend == null ? void 0 : originExtend.bundle_edit) !== void 0 ? { bundle_edit: originExtend.bundle_edit } : {}
|
|
115
|
+
};
|
|
116
|
+
if ((originExtend == null ? void 0 : originExtend.skuValue) || (originExtend == null ? void 0 : originExtend._skuValue)) {
|
|
117
|
+
extend.skuValue = JSON.parse(
|
|
118
|
+
JSON.stringify(originExtend.skuValue || originExtend._skuValue)
|
|
119
|
+
);
|
|
120
|
+
extend._skuValue = JSON.parse(JSON.stringify(extend.skuValue));
|
|
121
|
+
}
|
|
122
|
+
return {
|
|
123
|
+
...sourceProduct || {},
|
|
124
|
+
id: resolvedId,
|
|
125
|
+
product_id: resolvedId,
|
|
126
|
+
_id: uid,
|
|
127
|
+
title: sourceProduct == null ? void 0 : sourceProduct.title,
|
|
128
|
+
price: (sourceProduct == null ? void 0 : sourceProduct.price) ?? sourcePrice,
|
|
129
|
+
selling_price: product.selling_price,
|
|
130
|
+
original_price: product.original_price,
|
|
131
|
+
note: product.note,
|
|
132
|
+
order_detail_id: product.order_detail_id ?? null,
|
|
133
|
+
new: 0,
|
|
134
|
+
autoClose: true,
|
|
135
|
+
_extend: extend
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
139
|
+
0 && (module.exports = {
|
|
140
|
+
buildNormalProductCacheItemFromOrderLine
|
|
141
|
+
});
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 把 info2 `cacheItem` 转换为 OS `addProductToOrder(product, booking)` 所需的 booking 入参。
|
|
3
|
+
*
|
|
4
|
+
* 协议严格对齐 `pisell_os/src/modules/Order/TEMP_ORDER_FIELDS_SUMMARY.md` 的 Bookings 章节:
|
|
5
|
+
* - 顶层只允许出现:schedule_event_id / appointment_status / start_date / start_time / end_date /
|
|
6
|
+
* end_time / select_date / duration / sub_type / like_status / number / resources / relation_forms /
|
|
7
|
+
* holder / metadata / is_all / schedule_id / relation_id / form_id / relation_type / product_uid
|
|
8
|
+
* - bookings[] 不允许出现 `_extend`
|
|
9
|
+
* - bookings[].metadata 走白名单:unique_identification_number / collect_pax / capacity / holder_id / resource_select_type
|
|
10
|
+
* - bookings[].resources[] 只接受协议白名单:form_id / relation_type / relation_id / capacity / like_status / metadata / children
|
|
11
|
+
*
|
|
12
|
+
* `product_uid` / `metadata.unique_identification_number` 不在这里生成:
|
|
13
|
+
* OS `addProductToOrder` 内的 `createLinkedProductAndBooking` 会在最终一步统一改写,
|
|
14
|
+
* 保证商品行 uid 与 booking root 唯一值始终对齐。
|
|
15
|
+
*
|
|
16
|
+
* 复杂 multi-day 展开(createBookingItemsByGroup / concatBookings)首版**不支持**,
|
|
17
|
+
* 由 UI 在 `cart.confirmDetail` 之外通过辅助 API 处理。
|
|
18
|
+
*/
|
|
19
|
+
export interface CacheItemToBookingInputOptions {
|
|
20
|
+
/** booking config,用于推导 metadata.resource_select_type(默认从 cacheItem.\_data.resources[0].select_type.type 推断)。 */
|
|
21
|
+
bookingConfig?: any;
|
|
22
|
+
}
|
|
23
|
+
export interface BookingInput {
|
|
24
|
+
schedule_event_id?: number | string;
|
|
25
|
+
start_date?: string;
|
|
26
|
+
start_time?: string;
|
|
27
|
+
end_date?: string;
|
|
28
|
+
end_time?: string;
|
|
29
|
+
select_date?: string;
|
|
30
|
+
duration?: number;
|
|
31
|
+
sub_type?: 'days' | 'minutes' | string;
|
|
32
|
+
is_all?: 0 | 1;
|
|
33
|
+
number?: number;
|
|
34
|
+
holder?: any;
|
|
35
|
+
like_status?: string;
|
|
36
|
+
relation_forms?: any[];
|
|
37
|
+
resources?: BookingResourceInput[];
|
|
38
|
+
metadata?: BookingMetadataInput;
|
|
39
|
+
schedule_id?: number | string;
|
|
40
|
+
relation_id?: number | string;
|
|
41
|
+
form_id?: number | string;
|
|
42
|
+
relation_type?: string;
|
|
43
|
+
}
|
|
44
|
+
export interface BookingResourceInput {
|
|
45
|
+
form_id?: number | string;
|
|
46
|
+
relation_type?: string;
|
|
47
|
+
relation_id?: number | string;
|
|
48
|
+
capacity?: number;
|
|
49
|
+
like_status?: string;
|
|
50
|
+
metadata?: Record<string, any>;
|
|
51
|
+
children?: any[];
|
|
52
|
+
}
|
|
53
|
+
/** custom / package 人数维度快照,与 info2 `_extend.capacity` / `metadata.capacity` 对齐。 */
|
|
54
|
+
export interface BookingCapacityMetadataItem {
|
|
55
|
+
id: string | number;
|
|
56
|
+
value: number;
|
|
57
|
+
name?: Record<string, any> | string;
|
|
58
|
+
}
|
|
59
|
+
export interface BookingMetadataInput {
|
|
60
|
+
/** 由 OS createLinkedProductAndBooking 统一改写,这里不生成。 */
|
|
61
|
+
unique_identification_number?: string;
|
|
62
|
+
collect_pax?: number;
|
|
63
|
+
/**
|
|
64
|
+
* 资源容量快照:custom 多维度时为 `{ id, value, name? }[]`;
|
|
65
|
+
* 仅总和场景可为 number(capacity_snapshot 兼容)。
|
|
66
|
+
*/
|
|
67
|
+
capacity?: number | BookingCapacityMetadataItem[];
|
|
68
|
+
/** 协议要求始终提交(即使为 null)。 */
|
|
69
|
+
holder_id: any;
|
|
70
|
+
resource_select_type?: 'single' | 'multiple' | string;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* 主入口。
|
|
74
|
+
*/
|
|
75
|
+
export declare function cacheItemToBookingInput(cacheItem: any, options?: CacheItemToBookingInputOptions): BookingInput;
|
|
@@ -0,0 +1,198 @@
|
|
|
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/modules/BookingContext/utils/cacheItemToBookingInput.ts
|
|
30
|
+
var cacheItemToBookingInput_exports = {};
|
|
31
|
+
__export(cacheItemToBookingInput_exports, {
|
|
32
|
+
cacheItemToBookingInput: () => cacheItemToBookingInput
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(cacheItemToBookingInput_exports);
|
|
35
|
+
var import_dayjs = __toESM(require("dayjs"));
|
|
36
|
+
var import_serviceTimes = require("./serviceTimes");
|
|
37
|
+
var import_resources = require("./resources");
|
|
38
|
+
var import_flexible = require("./flexible");
|
|
39
|
+
function normalizeExtendCapacityForMetadata(capacity) {
|
|
40
|
+
if (!Array.isArray(capacity) || capacity.length === 0)
|
|
41
|
+
return void 0;
|
|
42
|
+
const normalized = capacity.map((item) => {
|
|
43
|
+
if (!item || typeof item !== "object")
|
|
44
|
+
return null;
|
|
45
|
+
if (item.id === void 0 || item.id === null)
|
|
46
|
+
return null;
|
|
47
|
+
const row = {
|
|
48
|
+
id: item.id,
|
|
49
|
+
value: Number(item.value ?? 0)
|
|
50
|
+
};
|
|
51
|
+
if (item.name !== void 0)
|
|
52
|
+
row.name = item.name;
|
|
53
|
+
return row;
|
|
54
|
+
}).filter((item) => item != null);
|
|
55
|
+
return normalized.length > 0 ? normalized : void 0;
|
|
56
|
+
}
|
|
57
|
+
function safeFormat(value, fmt) {
|
|
58
|
+
if (value === void 0 || value === null)
|
|
59
|
+
return void 0;
|
|
60
|
+
const d = (0, import_dayjs.default)(value);
|
|
61
|
+
if (!d.isValid())
|
|
62
|
+
return void 0;
|
|
63
|
+
return d.format(fmt);
|
|
64
|
+
}
|
|
65
|
+
function normalizeTimeString(value) {
|
|
66
|
+
if (value === void 0 || value === null)
|
|
67
|
+
return void 0;
|
|
68
|
+
if (typeof value === "string") {
|
|
69
|
+
const t = value.trim();
|
|
70
|
+
const hhmmFromHhmmss = t.match(/^(\d{1,2}:\d{2}):\d{2}$/);
|
|
71
|
+
if (hhmmFromHhmmss)
|
|
72
|
+
return hhmmFromHhmmss[1];
|
|
73
|
+
if (/^\d{1,2}:\d{2}$/.test(t))
|
|
74
|
+
return t;
|
|
75
|
+
}
|
|
76
|
+
const d = (0, import_dayjs.default)(value);
|
|
77
|
+
if (d.isValid())
|
|
78
|
+
return d.format("HH:mm");
|
|
79
|
+
return void 0;
|
|
80
|
+
}
|
|
81
|
+
function resolveDurationMinutes(value) {
|
|
82
|
+
if (typeof value === "number" && Number.isFinite(value))
|
|
83
|
+
return value;
|
|
84
|
+
if (typeof value !== "string")
|
|
85
|
+
return void 0;
|
|
86
|
+
if (import_flexible.flexibleObj.isFlexible(value))
|
|
87
|
+
return import_flexible.flexibleObj.getValue(value);
|
|
88
|
+
const n = Number(value);
|
|
89
|
+
return Number.isNaN(n) ? void 0 : n;
|
|
90
|
+
}
|
|
91
|
+
function flattenResources(cacheItem) {
|
|
92
|
+
var _a;
|
|
93
|
+
const resourceMap = ((_a = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _a.resource) || {};
|
|
94
|
+
const topLevelCapacity = (0, import_resources.getSumCapacity)(cacheItem, false);
|
|
95
|
+
const result = [];
|
|
96
|
+
Object.values(resourceMap).forEach((arr) => {
|
|
97
|
+
if (!Array.isArray(arr))
|
|
98
|
+
return;
|
|
99
|
+
arr.forEach((r) => {
|
|
100
|
+
const item = {
|
|
101
|
+
form_id: r == null ? void 0 : r.form_id,
|
|
102
|
+
relation_type: (r == null ? void 0 : r.relation_type) || "form",
|
|
103
|
+
relation_id: r == null ? void 0 : r.relation_id,
|
|
104
|
+
capacity: topLevelCapacity
|
|
105
|
+
};
|
|
106
|
+
item.like_status = (r == null ? void 0 : r.like_status) || "common";
|
|
107
|
+
if ((r == null ? void 0 : r.metadata) !== void 0) {
|
|
108
|
+
item.metadata = { ...r.metadata };
|
|
109
|
+
}
|
|
110
|
+
if ((r == null ? void 0 : r.children) !== void 0)
|
|
111
|
+
item.children = r.children;
|
|
112
|
+
result.push(item);
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
return result;
|
|
116
|
+
}
|
|
117
|
+
function deriveResourceSelectType(cacheItem) {
|
|
118
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
119
|
+
const localFirst = (_d = (_c = (_b = (_a = cacheItem == null ? void 0 : cacheItem._data) == null ? void 0 : _a.resources) == null ? void 0 : _b[0]) == null ? void 0 : _c.select_type) == null ? void 0 : _d.type;
|
|
120
|
+
if (localFirst)
|
|
121
|
+
return localFirst;
|
|
122
|
+
const productFirst = (_h = (_g = (_f = (_e = cacheItem == null ? void 0 : cacheItem.product_resource) == null ? void 0 : _e.resources) == null ? void 0 : _f[0]) == null ? void 0 : _g.select_type) == null ? void 0 : _h.type;
|
|
123
|
+
if (productFirst)
|
|
124
|
+
return productFirst;
|
|
125
|
+
return void 0;
|
|
126
|
+
}
|
|
127
|
+
function cacheItemToBookingInput(cacheItem, options) {
|
|
128
|
+
var _a, _b;
|
|
129
|
+
if (!cacheItem)
|
|
130
|
+
return { metadata: { holder_id: null } };
|
|
131
|
+
const ext = cacheItem._extend || {};
|
|
132
|
+
const isMultiDay = (0, import_serviceTimes.isMultiDayProduct)(cacheItem) || ext.is_all === 1 || ext.sub_type === "days";
|
|
133
|
+
const isSession = (0, import_serviceTimes.isSessionProduct)(cacheItem);
|
|
134
|
+
const result = {};
|
|
135
|
+
if (isSession && ((_a = ext == null ? void 0 : ext.other) == null ? void 0 : _a.session)) {
|
|
136
|
+
const session = ext.other.session;
|
|
137
|
+
result.start_date = safeFormat(ext.start_date || ext.startDate || session.start_at, "YYYY-MM-DD");
|
|
138
|
+
result.start_time = normalizeTimeString(ext.start_time) || normalizeTimeString(session.start_time) || safeFormat(session.start_at, "HH:mm");
|
|
139
|
+
result.end_date = safeFormat(ext.end_date || ext.endDate || session.end_at, "YYYY-MM-DD");
|
|
140
|
+
result.end_time = normalizeTimeString(ext.end_time) || normalizeTimeString(session.end_time) || safeFormat(session.end_at, "HH:mm");
|
|
141
|
+
} else {
|
|
142
|
+
result.start_date = safeFormat(ext.start_date || ext.startDate, "YYYY-MM-DD");
|
|
143
|
+
result.start_time = normalizeTimeString(ext.start_time) || safeFormat(ext.startDate, "HH:mm");
|
|
144
|
+
result.end_date = safeFormat(ext.end_date || ext.endDate, "YYYY-MM-DD");
|
|
145
|
+
result.end_time = normalizeTimeString(ext.end_time) || safeFormat(ext.endDate, "HH:mm");
|
|
146
|
+
}
|
|
147
|
+
if (isMultiDay) {
|
|
148
|
+
result.is_all = 1;
|
|
149
|
+
result.sub_type = "days";
|
|
150
|
+
result.duration = Number(ext.duration) || (0, import_serviceTimes.getDays)(cacheItem, "days");
|
|
151
|
+
if (result.start_date)
|
|
152
|
+
result.select_date = result.start_date;
|
|
153
|
+
if (result.start_time && (!result.end_time || result.end_time === "00:00")) {
|
|
154
|
+
result.end_time = result.start_time;
|
|
155
|
+
}
|
|
156
|
+
} else {
|
|
157
|
+
result.is_all = 0;
|
|
158
|
+
result.sub_type = ext.sub_type || "minutes";
|
|
159
|
+
const duration = resolveDurationMinutes(ext.duration);
|
|
160
|
+
if (duration !== void 0)
|
|
161
|
+
result.duration = duration;
|
|
162
|
+
}
|
|
163
|
+
result.number = (0, import_resources.getSumCapacity)(cacheItem, true);
|
|
164
|
+
result.resources = flattenResources(cacheItem);
|
|
165
|
+
if (ext.holder !== void 0)
|
|
166
|
+
result.holder = ext.holder;
|
|
167
|
+
if (Array.isArray(ext.relation_forms))
|
|
168
|
+
result.relation_forms = ext.relation_forms;
|
|
169
|
+
result.like_status = ext.like_status || "common";
|
|
170
|
+
if (cacheItem.schedule_event_id !== void 0) {
|
|
171
|
+
result.schedule_event_id = cacheItem.schedule_event_id;
|
|
172
|
+
}
|
|
173
|
+
const metadata = { holder_id: null };
|
|
174
|
+
if (ext.holder_id !== void 0 && ext.holder_id !== null) {
|
|
175
|
+
metadata.holder_id = ext.holder_id;
|
|
176
|
+
}
|
|
177
|
+
if (ext.collect_pax !== void 0)
|
|
178
|
+
metadata.collect_pax = ext.collect_pax;
|
|
179
|
+
const extendCapacity = normalizeExtendCapacityForMetadata(ext.capacity);
|
|
180
|
+
if (extendCapacity) {
|
|
181
|
+
metadata.capacity = extendCapacity;
|
|
182
|
+
} else if (ext.capacity_snapshot !== void 0) {
|
|
183
|
+
metadata.capacity = ext.capacity_snapshot;
|
|
184
|
+
}
|
|
185
|
+
const selectType = deriveResourceSelectType(cacheItem) || ((_b = options == null ? void 0 : options.bookingConfig) == null ? void 0 : _b.resource_select_type);
|
|
186
|
+
if (selectType)
|
|
187
|
+
metadata.resource_select_type = selectType;
|
|
188
|
+
result.metadata = metadata;
|
|
189
|
+
result.schedule_id = 0;
|
|
190
|
+
result.relation_id = 0;
|
|
191
|
+
result.form_id = 0;
|
|
192
|
+
result.relation_type = "";
|
|
193
|
+
return result;
|
|
194
|
+
}
|
|
195
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
196
|
+
0 && (module.exports = {
|
|
197
|
+
cacheItemToBookingInput
|
|
198
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 灵活时长(flexible duration)协议工具。
|
|
3
|
+
*
|
|
4
|
+
* info2 用 `flexible_<minutes>` 字符串前缀标记"灵活时长",对外用同名 API 暴露 create / getValue / isFlexible / add。
|
|
5
|
+
* OS 这边一比一搬运,无外部依赖。
|
|
6
|
+
*/
|
|
7
|
+
export declare const flexibleObj: {
|
|
8
|
+
create(num: number): string;
|
|
9
|
+
getValue(str: string | number): number;
|
|
10
|
+
isFlexible(str: string | number | undefined | null): boolean;
|
|
11
|
+
add(current: number | string, duration: number): string | number;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* 取 duration 数值(兼容 number / { type, value } / 灵活时长字符串)。
|
|
15
|
+
* 与 info2 `getDuration` 行为等价。
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* 商品定义是否为「灵活时长」类型(仅看 product.duration 对象,不把 flexible_423 字符串当类型)。
|
|
19
|
+
* 与 info2 `getDuration({ type: 'flexible' }) === 'flexible'` 判定对齐。
|
|
20
|
+
*/
|
|
21
|
+
export declare function isProductFlexibleDuration(duration: number | string | {
|
|
22
|
+
type: string;
|
|
23
|
+
value: number;
|
|
24
|
+
} | undefined | null): boolean;
|
|
25
|
+
export declare function getDurationValue(duration: number | string | {
|
|
26
|
+
type: string;
|
|
27
|
+
value: number;
|
|
28
|
+
} | undefined | null): number | 'flexible' | undefined;
|