@pisell/pisellos 2.2.178 → 2.2.180
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/Customer/index.d.ts +0 -6
- package/dist/modules/Customer/index.js +83 -129
- package/dist/modules/Customer/types.d.ts +0 -2
- package/dist/modules/Discount/index.d.ts +4 -2
- package/dist/modules/Discount/index.js +93 -8
- package/dist/modules/Discount/types.d.ts +7 -1
- package/dist/modules/Order/index.d.ts +17 -87
- package/dist/modules/Order/index.js +501 -1357
- package/dist/modules/Order/types.d.ts +19 -198
- package/dist/modules/Order/types.js +0 -31
- package/dist/modules/Order/utils.d.ts +1 -50
- package/dist/modules/Order/utils.js +32 -261
- package/dist/modules/Quotation/index.d.ts +1 -0
- package/dist/modules/Quotation/index.js +21 -23
- package/dist/modules/Rules/index.d.ts +0 -4
- package/dist/modules/Rules/index.js +10 -26
- package/dist/modules/SalesSummary/index.js +2 -4
- package/dist/modules/SalesSummary/utils.js +7 -21
- package/dist/modules/Schedule/index.js +2 -6
- package/dist/modules/index.d.ts +0 -1
- package/dist/modules/index.js +1 -2
- package/dist/server/index.js +29 -87
- package/dist/server/modules/order/index.d.ts +0 -23
- package/dist/server/modules/order/index.js +46 -123
- package/dist/server/modules/order/types.d.ts +2 -0
- package/dist/server/modules/order/utils/filterOrders.js +6 -20
- package/dist/server/modules/products/index.d.ts +1 -1
- package/dist/server/modules/products/index.js +113 -130
- package/dist/server/modules/schedule/index.js +6 -13
- package/dist/solution/BaseSales/index.d.ts +7 -89
- package/dist/solution/BaseSales/index.js +375 -1494
- package/dist/solution/BaseSales/types.d.ts +1 -67
- package/dist/solution/BaseSales/types.js +1 -3
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -0
- package/dist/solution/BaseSales/utils/parseSalesResponse.js +1 -1
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +16 -68
- package/dist/solution/BaseSales/utils.js +8 -46
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -133
- package/dist/solution/BookingTicket/index.js +175 -780
- package/dist/solution/BookingTicket/types.d.ts +0 -2
- package/dist/solution/BookingTicket/types.js +0 -3
- package/dist/solution/BookingTicket/utils/cartView.js +2 -4
- package/dist/solution/ScanOrder/index.d.ts +3 -9
- package/dist/solution/ScanOrder/index.js +128 -231
- package/dist/solution/ScanOrder/utils.js +8 -46
- package/dist/solution/ShopDiscount/index.d.ts +1 -0
- package/dist/solution/ShopDiscount/index.js +23 -18
- package/dist/solution/VenueBooking/index.d.ts +9 -5
- package/dist/solution/VenueBooking/index.js +55 -103
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +0 -4
- package/dist/solution/VenueBooking/utils/slotMerge.js +0 -10
- package/lib/model/strategy/adapter/promotion/index.js +0 -49
- package/lib/modules/Customer/index.d.ts +0 -6
- package/lib/modules/Customer/index.js +11 -26
- package/lib/modules/Customer/types.d.ts +0 -2
- package/lib/modules/Discount/index.d.ts +4 -2
- package/lib/modules/Discount/index.js +63 -8
- package/lib/modules/Discount/types.d.ts +7 -1
- package/lib/modules/Order/index.d.ts +17 -87
- package/lib/modules/Order/index.js +150 -677
- package/lib/modules/Order/types.d.ts +19 -198
- package/lib/modules/Order/types.js +0 -1
- package/lib/modules/Order/utils.d.ts +1 -50
- package/lib/modules/Order/utils.js +22 -229
- package/lib/modules/Quotation/index.d.ts +1 -0
- package/lib/modules/Quotation/index.js +15 -18
- package/lib/modules/Rules/index.d.ts +0 -4
- package/lib/modules/Rules/index.js +14 -22
- package/lib/modules/SalesSummary/index.js +2 -4
- package/lib/modules/SalesSummary/utils.js +7 -21
- package/lib/modules/Schedule/index.js +1 -3
- package/lib/modules/index.d.ts +0 -1
- package/lib/modules/index.js +1 -3
- package/lib/server/index.js +4 -41
- package/lib/server/modules/order/index.d.ts +0 -23
- package/lib/server/modules/order/index.js +14 -46
- package/lib/server/modules/order/types.d.ts +2 -0
- package/lib/server/modules/order/utils/filterOrders.js +4 -12
- package/lib/server/modules/products/index.d.ts +1 -1
- package/lib/server/modules/products/index.js +20 -30
- package/lib/server/modules/schedule/index.js +1 -2
- package/lib/solution/BaseSales/index.d.ts +7 -89
- package/lib/solution/BaseSales/index.js +22 -736
- package/lib/solution/BaseSales/types.d.ts +1 -67
- package/lib/solution/BaseSales/types.js +1 -3
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -0
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +1 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +12 -71
- package/lib/solution/BaseSales/utils.js +6 -46
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +1 -133
- package/lib/solution/BookingTicket/index.js +8 -352
- package/lib/solution/BookingTicket/types.d.ts +0 -2
- package/lib/solution/BookingTicket/types.js +0 -6
- package/lib/solution/BookingTicket/utils/cartView.js +2 -4
- package/lib/solution/ScanOrder/index.d.ts +3 -9
- package/lib/solution/ScanOrder/index.js +66 -147
- package/lib/solution/ScanOrder/utils.js +6 -46
- package/lib/solution/ShopDiscount/index.d.ts +1 -0
- package/lib/solution/ShopDiscount/index.js +4 -2
- package/lib/solution/VenueBooking/index.d.ts +9 -5
- package/lib/solution/VenueBooking/index.js +14 -50
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +0 -4
- package/lib/solution/VenueBooking/utils/slotMerge.js +0 -10
- package/package.json +2 -2
- package/dist/modules/BookingContext/index.d.ts +0 -37
- package/dist/modules/BookingContext/index.js +0 -436
- package/dist/modules/BookingContext/types.d.ts +0 -102
- package/dist/modules/BookingContext/types.js +0 -51
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +0 -16
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +0 -193
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +0 -8
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +0 -137
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +0 -75
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +0 -215
- package/dist/modules/BookingContext/utils/flexible.d.ts +0 -28
- package/dist/modules/BookingContext/utils/flexible.js +0 -56
- package/dist/modules/BookingContext/utils/formatResourceList.d.ts +0 -8
- package/dist/modules/BookingContext/utils/formatResourceList.js +0 -38
- package/dist/modules/BookingContext/utils/index.d.ts +0 -11
- package/dist/modules/BookingContext/utils/index.js +0 -11
- package/dist/modules/BookingContext/utils/noResource.d.ts +0 -13
- package/dist/modules/BookingContext/utils/noResource.js +0 -77
- package/dist/modules/BookingContext/utils/productExtend.d.ts +0 -72
- package/dist/modules/BookingContext/utils/productExtend.js +0 -339
- package/dist/modules/BookingContext/utils/resourceErrors.d.ts +0 -41
- package/dist/modules/BookingContext/utils/resourceErrors.js +0 -74
- package/dist/modules/BookingContext/utils/resourceSelection.d.ts +0 -7
- package/dist/modules/BookingContext/utils/resourceSelection.js +0 -24
- package/dist/modules/BookingContext/utils/resources.d.ts +0 -80
- package/dist/modules/BookingContext/utils/resources.js +0 -486
- package/dist/modules/BookingContext/utils/serviceTimes.d.ts +0 -55
- package/dist/modules/BookingContext/utils/serviceTimes.js +0 -151
- package/dist/modules/BookingContext/utils/timeSlices.d.ts +0 -42
- package/dist/modules/BookingContext/utils/timeSlices.js +0 -100
- package/dist/modules/Order/utils/manualProductDiscount.d.ts +0 -106
- package/dist/modules/Order/utils/manualProductDiscount.js +0 -212
- package/dist/solution/BaseSales/utils/cartPromotion.d.ts +0 -275
- package/dist/solution/BaseSales/utils/cartPromotion.js +0 -1258
- package/dist/solution/BaseSales/utils/quotationPrice.d.ts +0 -7
- package/dist/solution/BaseSales/utils/quotationPrice.js +0 -237
- package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +0 -113
- package/dist/solution/BookingTicket/utils/addProductDecision.js +0 -346
- package/lib/modules/BookingContext/index.d.ts +0 -37
- package/lib/modules/BookingContext/index.js +0 -297
- package/lib/modules/BookingContext/types.d.ts +0 -102
- package/lib/modules/BookingContext/types.js +0 -34
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +0 -16
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +0 -207
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +0 -8
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +0 -141
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +0 -75
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +0 -198
- package/lib/modules/BookingContext/utils/flexible.d.ts +0 -28
- package/lib/modules/BookingContext/utils/flexible.js +0 -80
- package/lib/modules/BookingContext/utils/formatResourceList.d.ts +0 -8
- package/lib/modules/BookingContext/utils/formatResourceList.js +0 -50
- package/lib/modules/BookingContext/utils/index.d.ts +0 -11
- package/lib/modules/BookingContext/utils/index.js +0 -43
- package/lib/modules/BookingContext/utils/noResource.d.ts +0 -13
- package/lib/modules/BookingContext/utils/noResource.js +0 -90
- package/lib/modules/BookingContext/utils/productExtend.d.ts +0 -72
- package/lib/modules/BookingContext/utils/productExtend.js +0 -283
- package/lib/modules/BookingContext/utils/resourceErrors.d.ts +0 -41
- package/lib/modules/BookingContext/utils/resourceErrors.js +0 -80
- package/lib/modules/BookingContext/utils/resourceSelection.d.ts +0 -7
- package/lib/modules/BookingContext/utils/resourceSelection.js +0 -46
- package/lib/modules/BookingContext/utils/resources.d.ts +0 -80
- package/lib/modules/BookingContext/utils/resources.js +0 -377
- package/lib/modules/BookingContext/utils/serviceTimes.d.ts +0 -55
- package/lib/modules/BookingContext/utils/serviceTimes.js +0 -162
- package/lib/modules/BookingContext/utils/timeSlices.d.ts +0 -42
- package/lib/modules/BookingContext/utils/timeSlices.js +0 -124
- package/lib/modules/Order/utils/manualProductDiscount.d.ts +0 -106
- package/lib/modules/Order/utils/manualProductDiscount.js +0 -207
- package/lib/solution/BaseSales/utils/cartPromotion.d.ts +0 -275
- package/lib/solution/BaseSales/utils/cartPromotion.js +0 -836
- package/lib/solution/BaseSales/utils/quotationPrice.d.ts +0 -7
- package/lib/solution/BaseSales/utils/quotationPrice.js +0 -277
- package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +0 -113
- package/lib/solution/BookingTicket/utils/addProductDecision.js +0 -318
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { QuotationModule } from '../../../modules/Quotation';
|
|
2
|
-
import type { BaseSalesCalculateProductBookingPriceParams, BaseSalesProductBookingPriceResult } from '../types';
|
|
3
|
-
interface BuildBaseSalesQuotationPriceParams extends BaseSalesCalculateProductBookingPriceParams {
|
|
4
|
-
quotation?: Pick<QuotationModule, 'getPriceForProduct' | 'getQuotationShelfId'> | null;
|
|
5
|
-
}
|
|
6
|
-
export declare function calculateBaseSalesProductBookingPrice(params: BuildBaseSalesQuotationPriceParams): BaseSalesProductBookingPriceResult;
|
|
7
|
-
export {};
|
|
@@ -1,277 +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/BaseSales/utils/quotationPrice.ts
|
|
30
|
-
var quotationPrice_exports = {};
|
|
31
|
-
__export(quotationPrice_exports, {
|
|
32
|
-
calculateBaseSalesProductBookingPrice: () => calculateBaseSalesProductBookingPrice
|
|
33
|
-
});
|
|
34
|
-
module.exports = __toCommonJS(quotationPrice_exports);
|
|
35
|
-
var import_dayjs = __toESM(require("dayjs"));
|
|
36
|
-
var import_decimal = __toESM(require("decimal.js"));
|
|
37
|
-
function toFiniteNumber(value, fallback = 0) {
|
|
38
|
-
const parsedValue = Number(value);
|
|
39
|
-
if (!Number.isFinite(parsedValue))
|
|
40
|
-
return fallback;
|
|
41
|
-
return parsedValue;
|
|
42
|
-
}
|
|
43
|
-
function toPositiveInt(value, fallback = 1) {
|
|
44
|
-
const parsedValue = Math.floor(Number(value));
|
|
45
|
-
if (!Number.isFinite(parsedValue) || parsedValue < 1)
|
|
46
|
-
return fallback;
|
|
47
|
-
return parsedValue;
|
|
48
|
-
}
|
|
49
|
-
function toPriceString(value) {
|
|
50
|
-
return new import_decimal.default(Number(value) || 0).toDecimalPlaces(2).toFixed(2);
|
|
51
|
-
}
|
|
52
|
-
function normalizeDateTime(value) {
|
|
53
|
-
if (typeof value !== "string" || !value.trim())
|
|
54
|
-
return null;
|
|
55
|
-
const normalized = value.includes(":") ? value : `${value} 00:00:00`;
|
|
56
|
-
const datetime = (0, import_dayjs.default)(normalized);
|
|
57
|
-
if (!datetime.isValid())
|
|
58
|
-
return null;
|
|
59
|
-
return datetime;
|
|
60
|
-
}
|
|
61
|
-
function buildBookingDateTime(date, time) {
|
|
62
|
-
if (typeof date !== "string" || !date.trim())
|
|
63
|
-
return null;
|
|
64
|
-
const timeText = typeof time === "string" && time.trim() ? time.trim() : "00:00";
|
|
65
|
-
const datetime = (0, import_dayjs.default)(`${date.trim()} ${timeText}`);
|
|
66
|
-
if (!datetime.isValid())
|
|
67
|
-
return null;
|
|
68
|
-
return datetime;
|
|
69
|
-
}
|
|
70
|
-
function getDurationUnit(type) {
|
|
71
|
-
const normalizedType = String(type || "").toLowerCase();
|
|
72
|
-
if (normalizedType === "day" || normalizedType === "days")
|
|
73
|
-
return "day";
|
|
74
|
-
if (normalizedType === "minute" || normalizedType === "minutes")
|
|
75
|
-
return "minute";
|
|
76
|
-
return null;
|
|
77
|
-
}
|
|
78
|
-
function getProductId(product) {
|
|
79
|
-
const productId = toFiniteNumber(product.product_id ?? product.id, NaN);
|
|
80
|
-
if (!Number.isFinite(productId))
|
|
81
|
-
return null;
|
|
82
|
-
return productId;
|
|
83
|
-
}
|
|
84
|
-
function getProductVariantId(product) {
|
|
85
|
-
const variantId = toFiniteNumber(
|
|
86
|
-
product.product_variant_id ?? product.variant_id,
|
|
87
|
-
0
|
|
88
|
-
);
|
|
89
|
-
if (!Number.isFinite(variantId) || variantId <= 0)
|
|
90
|
-
return void 0;
|
|
91
|
-
return variantId;
|
|
92
|
-
}
|
|
93
|
-
function getFallbackPrice(params) {
|
|
94
|
-
const product = params.product || {};
|
|
95
|
-
return toPriceString(
|
|
96
|
-
params.fallback_price ?? product.price ?? product.selling_price ?? product.original_price ?? 0
|
|
97
|
-
);
|
|
98
|
-
}
|
|
99
|
-
function getProductQuantity(product) {
|
|
100
|
-
return toPositiveInt(product.num ?? product.quantity, 1);
|
|
101
|
-
}
|
|
102
|
-
function getBundleProductId(bundle) {
|
|
103
|
-
const productId = toFiniteNumber(
|
|
104
|
-
bundle.bundle_product_id ?? bundle._bundle_product_id,
|
|
105
|
-
NaN
|
|
106
|
-
);
|
|
107
|
-
if (!Number.isFinite(productId))
|
|
108
|
-
return null;
|
|
109
|
-
return productId;
|
|
110
|
-
}
|
|
111
|
-
function getBundleVariantId(bundle) {
|
|
112
|
-
const variantId = toFiniteNumber(
|
|
113
|
-
bundle.bundle_variant_id ?? bundle.variant_id,
|
|
114
|
-
0
|
|
115
|
-
);
|
|
116
|
-
if (!Number.isFinite(variantId) || variantId <= 0)
|
|
117
|
-
return void 0;
|
|
118
|
-
return variantId;
|
|
119
|
-
}
|
|
120
|
-
function getBundleFallbackPrice(bundle) {
|
|
121
|
-
return toPriceString(
|
|
122
|
-
bundle.bundle_selling_price ?? bundle.price ?? bundle.original_price ?? bundle.base_price ?? 0
|
|
123
|
-
);
|
|
124
|
-
}
|
|
125
|
-
function shouldSplitByDuration(duration, start, end) {
|
|
126
|
-
if (!duration)
|
|
127
|
-
return false;
|
|
128
|
-
if (!start || !end || !end.isAfter(start))
|
|
129
|
-
return false;
|
|
130
|
-
const unit = getDurationUnit(duration.type);
|
|
131
|
-
const value = toFiniteNumber(duration.value);
|
|
132
|
-
return !!unit && value > 0;
|
|
133
|
-
}
|
|
134
|
-
function buildTimeSegments(params) {
|
|
135
|
-
const booking = params.booking || {};
|
|
136
|
-
const explicitDatetime = normalizeDateTime(params.datetime);
|
|
137
|
-
const bookingStart = buildBookingDateTime(booking.start_date, booking.start_time);
|
|
138
|
-
const start = bookingStart || explicitDatetime || (0, import_dayjs.default)();
|
|
139
|
-
const bookingEnd = buildBookingDateTime(booking.end_date, booking.end_time);
|
|
140
|
-
if (!shouldSplitByDuration(params.duration, start, bookingEnd)) {
|
|
141
|
-
return [{ start }];
|
|
142
|
-
}
|
|
143
|
-
const unit = getDurationUnit(params.duration.type);
|
|
144
|
-
const value = toFiniteNumber(params.duration.value);
|
|
145
|
-
const segments = [];
|
|
146
|
-
let cursor = start;
|
|
147
|
-
let guard = 0;
|
|
148
|
-
while (cursor.isBefore(bookingEnd) && guard < 1e4) {
|
|
149
|
-
const next = cursor.add(value, unit);
|
|
150
|
-
segments.push({
|
|
151
|
-
start: cursor,
|
|
152
|
-
end: next.isBefore(bookingEnd) ? next : bookingEnd ?? void 0
|
|
153
|
-
});
|
|
154
|
-
cursor = next;
|
|
155
|
-
guard += 1;
|
|
156
|
-
}
|
|
157
|
-
return segments.length ? segments : [{ start }];
|
|
158
|
-
}
|
|
159
|
-
function formatTimePoint(datetime) {
|
|
160
|
-
return datetime.format("YYYY-MM-DD HH:mm:ss");
|
|
161
|
-
}
|
|
162
|
-
function buildPriceSegment(params) {
|
|
163
|
-
const timePoint = formatTimePoint(params.segment.start);
|
|
164
|
-
const quotedPrice = params.quotation && params.productId !== null ? params.quotation.getPriceForProduct({
|
|
165
|
-
productId: params.productId,
|
|
166
|
-
variantId: params.variantId,
|
|
167
|
-
datetime: timePoint,
|
|
168
|
-
customer_id: params.customerId
|
|
169
|
-
}) : null;
|
|
170
|
-
const unitPrice = toPriceString(quotedPrice ?? params.fallbackPrice);
|
|
171
|
-
const quotationShelfId = quotedPrice !== null && params.quotation && params.productId !== null ? params.quotation.getQuotationShelfId({
|
|
172
|
-
productId: params.productId,
|
|
173
|
-
variantId: params.variantId,
|
|
174
|
-
datetime: timePoint,
|
|
175
|
-
customer_id: params.customerId
|
|
176
|
-
}) : 0;
|
|
177
|
-
return {
|
|
178
|
-
start_datetime: timePoint,
|
|
179
|
-
end_datetime: params.segment.end ? formatTimePoint(params.segment.end) : void 0,
|
|
180
|
-
time_point: timePoint,
|
|
181
|
-
unit_price: unitPrice,
|
|
182
|
-
quantity: 1,
|
|
183
|
-
total_price: unitPrice,
|
|
184
|
-
quotation_shelf_id: quotationShelfId,
|
|
185
|
-
source: quotedPrice !== null ? "quotation" : "fallback"
|
|
186
|
-
};
|
|
187
|
-
}
|
|
188
|
-
function calculatePriceForProduct(params) {
|
|
189
|
-
var _a;
|
|
190
|
-
const segments = params.segments.map((segment) => buildPriceSegment({
|
|
191
|
-
quotation: params.quotation,
|
|
192
|
-
productId: params.productId,
|
|
193
|
-
variantId: params.variantId,
|
|
194
|
-
customerId: params.customerId,
|
|
195
|
-
fallbackPrice: params.fallbackPrice,
|
|
196
|
-
segment
|
|
197
|
-
}));
|
|
198
|
-
const unitPrice = segments.reduce(
|
|
199
|
-
(total, segment) => total.plus(segment.total_price),
|
|
200
|
-
new import_decimal.default(0)
|
|
201
|
-
);
|
|
202
|
-
const totalPrice = unitPrice.times(params.quantity);
|
|
203
|
-
const quotationShelfId = ((_a = segments.find((segment) => segment.quotation_shelf_id)) == null ? void 0 : _a.quotation_shelf_id) || 0;
|
|
204
|
-
return {
|
|
205
|
-
unitPrice,
|
|
206
|
-
totalPrice,
|
|
207
|
-
quotationShelfId,
|
|
208
|
-
segments
|
|
209
|
-
};
|
|
210
|
-
}
|
|
211
|
-
function calculateBundlePrices(params, segments) {
|
|
212
|
-
var _a;
|
|
213
|
-
const bundleList = ((_a = params.product) == null ? void 0 : _a.product_bundle) || [];
|
|
214
|
-
if (!bundleList.length)
|
|
215
|
-
return void 0;
|
|
216
|
-
return bundleList.map((bundle) => {
|
|
217
|
-
const productId = getBundleProductId(bundle);
|
|
218
|
-
const variantId = getBundleVariantId(bundle);
|
|
219
|
-
const quantity = getProductQuantity(bundle);
|
|
220
|
-
const price = calculatePriceForProduct({
|
|
221
|
-
quotation: params.quotation,
|
|
222
|
-
productId,
|
|
223
|
-
variantId,
|
|
224
|
-
customerId: params.customer_id,
|
|
225
|
-
quantity,
|
|
226
|
-
fallbackPrice: getBundleFallbackPrice(bundle),
|
|
227
|
-
segments
|
|
228
|
-
});
|
|
229
|
-
return {
|
|
230
|
-
bundle_id: bundle.bundle_id ?? bundle.id,
|
|
231
|
-
group_id: bundle.group_id,
|
|
232
|
-
bundle_group_id: bundle.bundle_group_id,
|
|
233
|
-
bundle_product_id: productId,
|
|
234
|
-
bundle_variant_id: variantId ?? 0,
|
|
235
|
-
unit_price: price.unitPrice.toDecimalPlaces(2).toFixed(2),
|
|
236
|
-
total_price: price.totalPrice.toDecimalPlaces(2).toFixed(2),
|
|
237
|
-
quantity,
|
|
238
|
-
quotation_shelf_id: price.quotationShelfId,
|
|
239
|
-
source: price.segments.some((segment) => segment.source === "quotation") ? "quotation" : "fallback",
|
|
240
|
-
segments: price.segments
|
|
241
|
-
};
|
|
242
|
-
});
|
|
243
|
-
}
|
|
244
|
-
function calculateBaseSalesProductBookingPrice(params) {
|
|
245
|
-
const product = params.product || {};
|
|
246
|
-
const productId = getProductId(product);
|
|
247
|
-
const variantId = getProductVariantId(product);
|
|
248
|
-
const productQuantity = getProductQuantity(product);
|
|
249
|
-
const fallbackPrice = getFallbackPrice(params);
|
|
250
|
-
const timeSegments = buildTimeSegments(params);
|
|
251
|
-
const price = calculatePriceForProduct({
|
|
252
|
-
quotation: params.quotation,
|
|
253
|
-
productId,
|
|
254
|
-
variantId,
|
|
255
|
-
customerId: params.customer_id,
|
|
256
|
-
quantity: productQuantity,
|
|
257
|
-
fallbackPrice,
|
|
258
|
-
segments: timeSegments
|
|
259
|
-
});
|
|
260
|
-
const bundlePrices = calculateBundlePrices(params, timeSegments);
|
|
261
|
-
return {
|
|
262
|
-
product_id: productId,
|
|
263
|
-
product_variant_id: variantId ?? 0,
|
|
264
|
-
customer_id: params.customer_id,
|
|
265
|
-
unit_price: price.unitPrice.toDecimalPlaces(2).toFixed(2),
|
|
266
|
-
total_price: price.totalPrice.toDecimalPlaces(2).toFixed(2),
|
|
267
|
-
quantity: productQuantity,
|
|
268
|
-
duration: params.duration,
|
|
269
|
-
quotation_shelf_id: price.quotationShelfId,
|
|
270
|
-
segments: price.segments,
|
|
271
|
-
...bundlePrices ? { product_bundle: bundlePrices } : {}
|
|
272
|
-
};
|
|
273
|
-
}
|
|
274
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
275
|
-
0 && (module.exports = {
|
|
276
|
-
calculateBaseSalesProductBookingPrice
|
|
277
|
-
});
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import { BookingCalcContext } from '../../../modules/BookingContext';
|
|
2
|
-
import type { ProductData } from '../../../modules/Product/types';
|
|
3
|
-
import type { OrderProduct, OrderProductIdentity, AddProductBookingInput } from '../../../modules/Order/types';
|
|
4
|
-
/**
|
|
5
|
-
* cart.addProduct 两阶段决策(与 ticketBooking `handleSelectProduct` 对齐):
|
|
6
|
-
*
|
|
7
|
-
* 1. `requiresDetail`:规格 / SKU / 套餐 / Session / 称重弹窗(门禁:`isOpenDetailModal` / `cartDetailValue` / `open_sold_weight`)
|
|
8
|
-
* 2. `requiresBookingEdit`:资源 / 时间编辑抽屉(门禁:`getIsAutoClose` on prepared cacheItem)
|
|
9
|
-
* 3. `add`:两关均通过,直接 transform + 加车
|
|
10
|
-
*/
|
|
11
|
-
export type AddProductDecision = {
|
|
12
|
-
action: 'add';
|
|
13
|
-
cacheItem: any;
|
|
14
|
-
} | {
|
|
15
|
-
action: 'requiresDetail';
|
|
16
|
-
payload: AddProductRequiresDetailPayload;
|
|
17
|
-
} | {
|
|
18
|
-
action: 'requiresBookingEdit';
|
|
19
|
-
cacheItem: any;
|
|
20
|
-
payload: AddProductRequiresBookingEditPayload;
|
|
21
|
-
};
|
|
22
|
-
/** 资源 / 时间编辑抽屉所需的最小 payload。 */
|
|
23
|
-
export interface AddProductRequiresBookingEditPayload {
|
|
24
|
-
cacheItem: any;
|
|
25
|
-
customerId?: number | string;
|
|
26
|
-
date: string | null;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* 加车主决策:对齐 `handleSelectProduct` 两段分支。
|
|
30
|
-
*/
|
|
31
|
-
export declare function decideAddProduct(item: any, ctx?: AddProductDecideContext): AddProductDecision;
|
|
32
|
-
/**
|
|
33
|
-
* 规格弹窗 callback 后的第二段决策(对齐 `handleBooking4Service` 内 `cacheItem.autoClose` 分支)。
|
|
34
|
-
*/
|
|
35
|
-
export declare function decideAfterDetail(cacheItem: any, ctx?: AddProductDecideContext): AddProductDecision;
|
|
36
|
-
/**
|
|
37
|
-
* @deprecated 请用 `decideAddProduct`;保留兼容:autoClose=true 仅表示可直接加车(action=add)。
|
|
38
|
-
*/
|
|
39
|
-
export interface AddProductRequiresDetailPayload {
|
|
40
|
-
item: ProductData | Record<string, any>;
|
|
41
|
-
/** UI 需展示的子弹窗开关。 */
|
|
42
|
-
showConfig: {
|
|
43
|
-
option: boolean;
|
|
44
|
-
session: boolean;
|
|
45
|
-
variant: boolean;
|
|
46
|
-
package: boolean;
|
|
47
|
-
number: boolean;
|
|
48
|
-
};
|
|
49
|
-
/** 仅 session 商品(且无 variant/option/package)→ true,UI 可只渲染 session 选择。 */
|
|
50
|
-
isOnlySession: boolean;
|
|
51
|
-
/** 0/1,与 info2 `getIsEject` 等价含义。 */
|
|
52
|
-
isEject: 0 | 1;
|
|
53
|
-
/** 当前选中客户 id(透传给 detail 弹窗用)。 */
|
|
54
|
-
customerId?: number | string;
|
|
55
|
-
/** 当前选择的日期。 */
|
|
56
|
-
date: string | null;
|
|
57
|
-
/** 透传完整商品数据,UI 渲染时直接用。 */
|
|
58
|
-
productData: ProductData | Record<string, any>;
|
|
59
|
-
}
|
|
60
|
-
export interface AddProductDecideContext extends BookingCalcContext {
|
|
61
|
-
type?: 'select' | 'detail';
|
|
62
|
-
quantity?: number;
|
|
63
|
-
customerId?: number | string;
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* 统一补齐预约商品的运行态字段。
|
|
67
|
-
*
|
|
68
|
-
* 新链路不再让决策和提交各自重建 cacheItem;这里作为唯一入口补齐
|
|
69
|
-
* `_extend.resource / capacity / startDate / endDate` 等后续 booking mapper 需要的字段。
|
|
70
|
-
*/
|
|
71
|
-
export declare function prepareBookingCacheItem(cacheItem: any, ctx?: AddProductDecideContext): any;
|
|
72
|
-
export declare function decideAutoClose(item: any, ctx?: AddProductDecideContext): {
|
|
73
|
-
autoClose: boolean;
|
|
74
|
-
cacheItem?: any;
|
|
75
|
-
};
|
|
76
|
-
/**
|
|
77
|
-
* 替代 info2 `getIsEject`:商品是否需要弹窗(含 type='detail' / option_group / bundle_group / variant / session / sold_by_weight)。
|
|
78
|
-
*/
|
|
79
|
-
export declare function getIsEject(item: any, type?: 'select' | 'detail'): 0 | 1;
|
|
80
|
-
/** 仅 session 商品(且没有 variant/option/package)。 */
|
|
81
|
-
export declare function getIsOnlySession(item: any): boolean;
|
|
82
|
-
/**
|
|
83
|
-
* 拼装 requiresDetail payload;showConfig 与 info2 弹窗内部判断一致。
|
|
84
|
-
*/
|
|
85
|
-
export declare function buildRequiresDetailPayload(item: any, ctx?: AddProductDecideContext): AddProductRequiresDetailPayload;
|
|
86
|
-
/**
|
|
87
|
-
* 用 item.cartDetailValue 拼装一个 cacheItem 雏形(与 info2 `handleDirectAddService` 等价路径)。
|
|
88
|
-
* 这里只补 `_extend.start_date / quantity / other` 等运行态字段;后续走 getProductExtend 才会补齐资源 / 时间。
|
|
89
|
-
*/
|
|
90
|
-
export declare function buildCacheItemFromCartDetail(item: any, ctx?: AddProductDecideContext): any;
|
|
91
|
-
/**
|
|
92
|
-
* 用 Info2 callback 的 (e, extension_type, detail) 拼装 cacheItem。
|
|
93
|
-
*
|
|
94
|
-
* 保留 detail._extend 中的 pricing / note(规格弹窗改价、备注等),
|
|
95
|
-
* 再叠加 session 时间、ctx.quantity 等运行态字段;other 以 callback `e` 为准。
|
|
96
|
-
*/
|
|
97
|
-
export declare function buildCacheItemFromDetail(item: any, detailResult: {
|
|
98
|
-
e: any;
|
|
99
|
-
extension_type?: any;
|
|
100
|
-
detail?: any;
|
|
101
|
-
}, ctx?: AddProductDecideContext): any;
|
|
102
|
-
/**
|
|
103
|
-
* `transformDetailToProductAndBooking`:把 cacheItem 拆成 OS `addProductToOrder` 所需的 `(product, booking)`。
|
|
104
|
-
*
|
|
105
|
-
* - `product` 走 `transformBaseProductToOrderProduct`(沿用 BaseSales 现有 mapper)。
|
|
106
|
-
* - `booking` 走 `cacheItemToBookingInput`(严格按 TEMP_ORDER_FIELDS_SUMMARY.md 协议)。
|
|
107
|
-
* - 普通商品(无 duration / 无 schedules)不产 booking,与 info2 一致。
|
|
108
|
-
*/
|
|
109
|
-
export declare function transformDetailToProductAndBooking(cacheItem: any, ctx?: AddProductDecideContext): {
|
|
110
|
-
product: Partial<OrderProduct> & OrderProductIdentity;
|
|
111
|
-
booking?: AddProductBookingInput;
|
|
112
|
-
cacheItem: any;
|
|
113
|
-
};
|