@pisell/pisellos 2.2.172 → 2.2.174
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/Order/index.d.ts +6 -21
- package/dist/modules/Order/index.js +56 -103
- package/dist/modules/Order/types.d.ts +3 -2
- package/dist/modules/Order/utils.d.ts +16 -0
- package/dist/modules/Order/utils.js +82 -2
- package/dist/modules/Quotation/index.d.ts +0 -1
- package/dist/modules/Quotation/index.js +8 -17
- package/dist/server/modules/products/index.d.ts +1 -1
- package/dist/server/modules/products/index.js +128 -112
- package/dist/solution/BaseSales/index.d.ts +4 -16
- package/dist/solution/BaseSales/index.js +178 -104
- package/dist/solution/BaseSales/types.d.ts +14 -0
- package/dist/solution/BaseSales/utils/quotationPrice.js +95 -17
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +4 -2
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.js +10 -2
- package/lib/model/strategy/adapter/promotion/index.js +49 -0
- package/lib/modules/Order/index.d.ts +6 -21
- package/lib/modules/Order/index.js +55 -100
- package/lib/modules/Order/types.d.ts +3 -2
- package/lib/modules/Order/utils.d.ts +16 -0
- package/lib/modules/Order/utils.js +54 -2
- package/lib/modules/Quotation/index.d.ts +0 -1
- package/lib/modules/Quotation/index.js +1 -9
- package/lib/server/modules/products/index.d.ts +1 -1
- package/lib/server/modules/products/index.js +26 -15
- package/lib/solution/BaseSales/index.d.ts +4 -16
- package/lib/solution/BaseSales/index.js +71 -35
- package/lib/solution/BaseSales/types.d.ts +14 -0
- package/lib/solution/BaseSales/utils/quotationPrice.js +90 -14
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +1 -1
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.js +8 -0
- package/package.json +1 -1
|
@@ -99,6 +99,29 @@ function getFallbackPrice(params) {
|
|
|
99
99
|
function getProductQuantity(product) {
|
|
100
100
|
return toPositiveInt(product.num ?? product.quantity, 1);
|
|
101
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
|
+
}
|
|
102
125
|
function shouldSplitByDuration(duration, start, end) {
|
|
103
126
|
if (!duration)
|
|
104
127
|
return false;
|
|
@@ -162,37 +185,90 @@ function buildPriceSegment(params) {
|
|
|
162
185
|
source: quotedPrice !== null ? "quotation" : "fallback"
|
|
163
186
|
};
|
|
164
187
|
}
|
|
165
|
-
function
|
|
188
|
+
function calculatePriceForProduct(params) {
|
|
166
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) {
|
|
167
245
|
const product = params.product || {};
|
|
168
246
|
const productId = getProductId(product);
|
|
169
247
|
const variantId = getProductVariantId(product);
|
|
170
248
|
const productQuantity = getProductQuantity(product);
|
|
171
249
|
const fallbackPrice = getFallbackPrice(params);
|
|
172
|
-
const
|
|
250
|
+
const timeSegments = buildTimeSegments(params);
|
|
251
|
+
const price = calculatePriceForProduct({
|
|
173
252
|
quotation: params.quotation,
|
|
174
253
|
productId,
|
|
175
254
|
variantId,
|
|
176
255
|
customerId: params.customer_id,
|
|
256
|
+
quantity: productQuantity,
|
|
177
257
|
fallbackPrice,
|
|
178
|
-
|
|
179
|
-
})
|
|
180
|
-
const
|
|
181
|
-
(total, segment) => total.plus(segment.total_price),
|
|
182
|
-
new import_decimal.default(0)
|
|
183
|
-
);
|
|
184
|
-
const totalPrice = unitPrice.times(productQuantity);
|
|
185
|
-
const quotationShelfId = ((_a = segments.find((segment) => segment.quotation_shelf_id)) == null ? void 0 : _a.quotation_shelf_id) || 0;
|
|
258
|
+
segments: timeSegments
|
|
259
|
+
});
|
|
260
|
+
const bundlePrices = calculateBundlePrices(params, timeSegments);
|
|
186
261
|
return {
|
|
187
262
|
product_id: productId,
|
|
188
263
|
product_variant_id: variantId ?? 0,
|
|
189
264
|
customer_id: params.customer_id,
|
|
190
|
-
unit_price: unitPrice.toDecimalPlaces(2).toFixed(2),
|
|
191
|
-
total_price: totalPrice.toDecimalPlaces(2).toFixed(2),
|
|
265
|
+
unit_price: price.unitPrice.toDecimalPlaces(2).toFixed(2),
|
|
266
|
+
total_price: price.totalPrice.toDecimalPlaces(2).toFixed(2),
|
|
192
267
|
quantity: productQuantity,
|
|
193
268
|
duration: params.duration,
|
|
194
|
-
quotation_shelf_id: quotationShelfId,
|
|
195
|
-
segments
|
|
269
|
+
quotation_shelf_id: price.quotationShelfId,
|
|
270
|
+
segments: price.segments,
|
|
271
|
+
...bundlePrices ? { product_bundle: bundlePrices } : {}
|
|
196
272
|
};
|
|
197
273
|
}
|
|
198
274
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -124,7 +124,7 @@ function transformBaseProductToOrderProduct(params) {
|
|
|
124
124
|
payload.bundle ?? payload.product_bundle,
|
|
125
125
|
hasPriceOverride
|
|
126
126
|
);
|
|
127
|
-
const uniqueIdentificationNumber = payload.unique_identification_number
|
|
127
|
+
const uniqueIdentificationNumber = payload.unique_identification_number;
|
|
128
128
|
const resolvedQuantity = toSafePositiveInt(payload.quantity ?? payload.num, 1);
|
|
129
129
|
const originTotal = (0, import_manualProductDiscount.resolveManualDiscountOriginTotal)({
|
|
130
130
|
originTotal: payload.origin_total,
|
|
@@ -311,7 +311,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
311
311
|
date: string;
|
|
312
312
|
status: string;
|
|
313
313
|
week: string;
|
|
314
|
-
weekNum: 0 |
|
|
314
|
+
weekNum: 0 | 1 | 2 | 6 | 3 | 5 | 4;
|
|
315
315
|
}[]>;
|
|
316
316
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
317
317
|
private getScheduleDataByIds;
|
|
@@ -482,11 +482,17 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
|
482
482
|
* 在 BookingTicket 命名空间也 emit 一次,方便上层统一从 Solution 订阅。
|
|
483
483
|
*/
|
|
484
484
|
setOrderCustomer(customer) {
|
|
485
|
+
var _a;
|
|
485
486
|
if (!customer) {
|
|
486
487
|
this.clearOrderCustomer();
|
|
487
488
|
return;
|
|
488
489
|
}
|
|
490
|
+
const previousCustomerId = (_a = this.store.order.getOrderCustomer()) == null ? void 0 : _a.customer_id;
|
|
489
491
|
const patch = (0, import_orderCustomer.formatOrderCustomerPatch)(customer);
|
|
492
|
+
if (Number(previousCustomerId || 0) !== Number(patch.customer_id || 0)) {
|
|
493
|
+
this.discountConfigCacheKey = null;
|
|
494
|
+
this.hasManualDiscountSelection = false;
|
|
495
|
+
}
|
|
490
496
|
this.store.order.setOrderCustomer(patch, customer);
|
|
491
497
|
const next = this.buildOrderCustomerPayload();
|
|
492
498
|
this.core.effects.emit(`${this.name}:onOrderCustomerChange`, next);
|
|
@@ -510,6 +516,8 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
|
510
516
|
clearOrderCustomer() {
|
|
511
517
|
var _a, _b;
|
|
512
518
|
this.store.order.clearOrderCustomer();
|
|
519
|
+
this.discountConfigCacheKey = null;
|
|
520
|
+
this.hasManualDiscountSelection = false;
|
|
513
521
|
const orderStore = this.store.order.store || {};
|
|
514
522
|
const discountModule = orderStore.discount;
|
|
515
523
|
void ((_a = discountModule == null ? void 0 : discountModule.setOriginalDiscountList) == null ? void 0 : _a.call(discountModule, []));
|