@pisell/pisellos 2.2.244 → 2.2.245
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/model/strategy/adapter/promotion/evaluator.js +3 -2
- package/dist/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/model/strategy/adapter/walletPass/utils.js +7 -4
- package/dist/modules/BookingContext/index.d.ts +48 -0
- package/dist/modules/BookingContext/index.js +566 -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 +284 -0
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +145 -0
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +76 -0
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +218 -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/orderLineDisplay.d.ts +1 -0
- package/dist/modules/BookingContext/utils/orderLineDisplay.js +36 -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/Cart/utils/cartProduct.js +24 -3
- package/dist/modules/Cart/utils/changePrice.js +11 -11
- package/dist/modules/Customer/index.d.ts +20 -0
- package/dist/modules/Customer/index.js +172 -83
- package/dist/modules/Customer/types.d.ts +2 -0
- package/dist/modules/Discount/index.d.ts +1 -1
- package/dist/modules/Discount/index.js +13 -6
- package/dist/modules/Discount/types.d.ts +1 -0
- package/dist/modules/OpenData/index.d.ts +8 -0
- package/dist/modules/OpenData/index.js +37 -17
- package/dist/modules/Order/index.d.ts +275 -19
- package/dist/modules/Order/index.js +3493 -809
- package/dist/modules/Order/types.d.ts +286 -31
- package/dist/modules/Order/types.js +38 -0
- package/dist/modules/Order/utils/manualProductDiscount.d.ts +106 -0
- package/dist/modules/Order/utils/manualProductDiscount.js +210 -0
- package/dist/modules/Order/utils.d.ts +147 -5
- package/dist/modules/Order/utils.js +750 -104
- package/dist/modules/Payment/index.d.ts +10 -13
- package/dist/modules/Payment/index.js +467 -837
- package/dist/modules/Payment/types.d.ts +2 -0
- package/dist/modules/Payment/utils.js +2 -1
- package/dist/modules/Payment/walletpass.js +41 -25
- package/dist/modules/ProductList/index.d.ts +16 -12
- package/dist/modules/ProductList/index.js +133 -59
- package/dist/modules/ProductList/types.d.ts +14 -0
- package/dist/modules/Quotation/index.d.ts +0 -1
- package/dist/modules/Quotation/index.js +25 -22
- package/dist/modules/Rules/index.d.ts +4 -0
- package/dist/modules/Rules/index.js +97 -70
- package/dist/modules/Rules/types.d.ts +1 -0
- package/dist/modules/SalesSummary/index.d.ts +8 -25
- package/dist/modules/SalesSummary/index.js +86 -35
- package/dist/modules/SalesSummary/types.d.ts +4 -1
- package/dist/modules/SalesSummary/utils.d.ts +2 -25
- package/dist/modules/SalesSummary/utils.js +794 -162
- package/dist/modules/Schedule/index.d.ts +7 -0
- package/dist/modules/Schedule/index.js +24 -2
- package/dist/modules/Summary/index.js +4 -3
- package/dist/modules/SurchargeList/index.d.ts +16 -0
- package/dist/modules/SurchargeList/index.js +162 -0
- package/dist/modules/SurchargeList/types.d.ts +11 -0
- package/dist/modules/SurchargeList/types.js +1 -0
- package/dist/modules/index.d.ts +2 -0
- package/dist/modules/index.js +3 -1
- package/dist/plugins/request.d.ts +1 -0
- package/dist/server/index.d.ts +204 -1
- package/dist/server/index.js +3654 -922
- package/dist/server/modules/index.d.ts +2 -0
- package/dist/server/modules/index.js +2 -0
- package/dist/server/modules/order/index.d.ts +120 -3
- package/dist/server/modules/order/index.js +1758 -448
- package/dist/server/modules/order/types.d.ts +32 -3
- package/dist/server/modules/order/types.js +8 -0
- package/dist/server/modules/order/utils/filterBookings.js +26 -3
- package/dist/server/modules/order/utils/filterOrders.js +23 -8
- package/dist/server/modules/payment/index.d.ts +28 -0
- package/dist/server/modules/payment/index.js +305 -0
- package/dist/server/modules/payment/types.d.ts +9 -0
- package/dist/server/modules/payment/types.js +1 -0
- package/dist/server/modules/products/index.d.ts +34 -7
- package/dist/server/modules/products/index.js +631 -317
- package/dist/server/modules/resource/index.d.ts +2 -0
- package/dist/server/modules/resource/index.js +29 -3
- package/dist/server/modules/schedule/index.d.ts +4 -4
- package/dist/server/modules/schedule/index.js +111 -88
- package/dist/server/test.json +713 -0
- package/dist/server/utils/small-ticket.d.ts +71 -0
- package/dist/server/utils/small-ticket.js +840 -0
- package/dist/solution/BaseSales/index.d.ts +133 -10
- package/dist/solution/BaseSales/index.js +1950 -447
- package/dist/solution/BaseSales/types.d.ts +82 -6
- package/dist/solution/BaseSales/types.js +5 -4
- package/dist/solution/BaseSales/utils/cartPromotion.d.ts +287 -0
- package/dist/solution/BaseSales/utils/cartPromotion.js +1438 -0
- package/dist/solution/BaseSales/utils/quotationPrice.d.ts +7 -0
- package/dist/solution/BaseSales/utils/quotationPrice.js +237 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +1 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +105 -24
- package/dist/solution/BaseSales/utils.d.ts +1 -1
- package/dist/solution/BaseSales/utils.js +62 -21
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +271 -11
- package/dist/solution/BookingTicket/index.js +1777 -242
- package/dist/solution/BookingTicket/types.d.ts +118 -1
- package/dist/solution/BookingTicket/types.js +41 -2
- package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +117 -0
- package/dist/solution/BookingTicket/utils/addProductDecision.js +346 -0
- package/dist/solution/BookingTicket/utils/addTimeAvailability.d.ts +35 -0
- package/dist/solution/BookingTicket/utils/addTimeAvailability.js +95 -0
- package/dist/solution/BookingTicket/utils/bookingStatus.d.ts +40 -0
- package/dist/solution/BookingTicket/utils/bookingStatus.js +70 -0
- package/dist/solution/BookingTicket/utils/cartView.d.ts +9 -1
- package/dist/solution/BookingTicket/utils/cartView.js +94 -7
- package/dist/solution/BookingTicket/utils/exampleData.d.ts +123 -0
- package/dist/solution/BookingTicket/utils/exampleData.js +183 -0
- package/dist/solution/BookingTicket/utils/resolveBestAddTimePlan.d.ts +185 -0
- package/dist/solution/BookingTicket/utils/resolveBestAddTimePlan.js +438 -0
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +36 -0
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +400 -0
- package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +32 -0
- package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.js +56 -0
- package/dist/solution/BookingTicket/utils/scan/index.d.ts +5 -0
- package/dist/solution/BookingTicket/utils/scan/index.js +20 -8
- package/dist/solution/BookingTicket/utils/scan/scanProductValues.d.ts +21 -0
- package/dist/solution/BookingTicket/utils/scan/scanProductValues.js +150 -0
- package/dist/solution/BookingTicket/utils/sessionCatalogStale.d.ts +23 -0
- package/dist/solution/BookingTicket/utils/sessionCatalogStale.js +78 -0
- package/dist/solution/Checkout/index.d.ts +1 -0
- package/dist/solution/Checkout/index.js +10 -9
- package/dist/solution/RegisterAndLogin/config.js +2 -10
- package/dist/solution/ScanOrder/index.d.ts +9 -3
- package/dist/solution/ScanOrder/index.js +241 -134
- package/dist/solution/ScanOrder/types.d.ts +9 -5
- package/dist/solution/ScanOrder/types.js +2 -3
- package/dist/solution/ScanOrder/utils.d.ts +1 -1
- package/dist/solution/ScanOrder/utils.js +84 -22
- package/dist/solution/VenueBooking/index.d.ts +5 -2
- package/dist/solution/VenueBooking/index.js +110 -59
- package/dist/solution/VenueBooking/sales-section-4-annotated.json +0 -2
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +4 -0
- package/dist/solution/VenueBooking/utils/slotMerge.js +10 -0
- package/dist/types/index.d.ts +10 -0
- package/lib/model/strategy/adapter/promotion/evaluator.js +2 -1
- package/lib/model/strategy/adapter/promotion/index.js +49 -0
- package/lib/model/strategy/adapter/walletPass/utils.js +3 -2
- package/lib/modules/BookingContext/index.d.ts +48 -0
- package/lib/modules/BookingContext/index.js +368 -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 +276 -0
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +151 -0
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +76 -0
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +201 -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/orderLineDisplay.d.ts +1 -0
- package/lib/modules/BookingContext/utils/orderLineDisplay.js +56 -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/Cart/utils/cartProduct.js +20 -3
- package/lib/modules/Cart/utils/changePrice.js +12 -20
- package/lib/modules/Customer/index.d.ts +20 -0
- package/lib/modules/Customer/index.js +64 -11
- package/lib/modules/Customer/types.d.ts +2 -0
- package/lib/modules/Discount/index.d.ts +1 -1
- package/lib/modules/Discount/index.js +9 -1
- package/lib/modules/Discount/types.d.ts +1 -0
- package/lib/modules/OpenData/index.d.ts +8 -0
- package/lib/modules/OpenData/index.js +19 -5
- package/lib/modules/Order/index.d.ts +275 -19
- package/lib/modules/Order/index.js +2245 -336
- package/lib/modules/Order/types.d.ts +286 -31
- package/lib/modules/Order/types.js +1 -0
- package/lib/modules/Order/utils/manualProductDiscount.d.ts +106 -0
- package/lib/modules/Order/utils/manualProductDiscount.js +206 -0
- package/lib/modules/Order/utils.d.ts +147 -5
- package/lib/modules/Order/utils.js +615 -46
- package/lib/modules/Payment/index.d.ts +10 -13
- package/lib/modules/Payment/index.js +18 -150
- package/lib/modules/Payment/types.d.ts +2 -0
- package/lib/modules/Payment/utils.js +2 -1
- package/lib/modules/Payment/walletpass.js +16 -3
- package/lib/modules/ProductList/index.d.ts +16 -12
- package/lib/modules/ProductList/index.js +41 -4
- package/lib/modules/ProductList/types.d.ts +14 -0
- package/lib/modules/Quotation/index.d.ts +0 -1
- package/lib/modules/Quotation/index.js +19 -16
- package/lib/modules/Rules/index.d.ts +4 -0
- package/lib/modules/Rules/index.js +137 -120
- package/lib/modules/Rules/types.d.ts +1 -0
- package/lib/modules/SalesSummary/index.d.ts +8 -25
- package/lib/modules/SalesSummary/index.js +30 -4
- package/lib/modules/SalesSummary/types.d.ts +4 -1
- package/lib/modules/SalesSummary/utils.d.ts +2 -25
- package/lib/modules/SalesSummary/utils.js +645 -91
- package/lib/modules/Schedule/index.d.ts +7 -0
- package/lib/modules/Schedule/index.js +17 -1
- package/lib/modules/Summary/index.js +5 -4
- package/lib/modules/SurchargeList/index.d.ts +16 -0
- package/lib/modules/SurchargeList/index.js +89 -0
- package/lib/modules/SurchargeList/types.d.ts +11 -0
- package/lib/modules/SurchargeList/types.js +17 -0
- package/lib/modules/index.d.ts +2 -0
- package/lib/modules/index.js +5 -1
- package/lib/plugins/request.d.ts +1 -0
- package/lib/server/index.d.ts +204 -1
- package/lib/server/index.js +1891 -59
- package/lib/server/modules/index.d.ts +2 -0
- package/lib/server/modules/index.js +3 -0
- package/lib/server/modules/order/index.d.ts +120 -3
- package/lib/server/modules/order/index.js +883 -94
- package/lib/server/modules/order/types.d.ts +32 -3
- package/lib/server/modules/order/utils/filterBookings.js +24 -5
- package/lib/server/modules/order/utils/filterOrders.js +15 -6
- package/lib/server/modules/payment/index.d.ts +28 -0
- package/lib/server/modules/payment/index.js +192 -0
- package/lib/server/modules/payment/types.d.ts +9 -0
- package/lib/server/modules/payment/types.js +17 -0
- package/lib/server/modules/products/index.d.ts +34 -7
- package/lib/server/modules/products/index.js +189 -54
- package/lib/server/modules/resource/index.d.ts +2 -0
- package/lib/server/modules/resource/index.js +27 -3
- package/lib/server/modules/schedule/index.d.ts +4 -4
- package/lib/server/modules/schedule/index.js +47 -40
- package/lib/server/test.json +713 -0
- package/lib/server/utils/small-ticket.d.ts +71 -0
- package/lib/server/utils/small-ticket.js +800 -0
- package/lib/solution/BaseSales/index.d.ts +133 -10
- package/lib/solution/BaseSales/index.js +1111 -63
- package/lib/solution/BaseSales/types.d.ts +82 -6
- package/lib/solution/BaseSales/types.js +3 -1
- package/lib/solution/BaseSales/utils/cartPromotion.d.ts +287 -0
- package/lib/solution/BaseSales/utils/cartPromotion.js +992 -0
- package/lib/solution/BaseSales/utils/quotationPrice.d.ts +7 -0
- package/lib/solution/BaseSales/utils/quotationPrice.js +277 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +1 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +106 -18
- package/lib/solution/BaseSales/utils.d.ts +1 -1
- package/lib/solution/BaseSales/utils.js +54 -10
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +271 -11
- package/lib/solution/BookingTicket/index.js +922 -29
- package/lib/solution/BookingTicket/types.d.ts +118 -1
- package/lib/solution/BookingTicket/types.js +11 -0
- package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +117 -0
- package/lib/solution/BookingTicket/utils/addProductDecision.js +318 -0
- package/lib/solution/BookingTicket/utils/addTimeAvailability.d.ts +35 -0
- package/lib/solution/BookingTicket/utils/addTimeAvailability.js +125 -0
- package/lib/solution/BookingTicket/utils/bookingStatus.d.ts +40 -0
- package/lib/solution/BookingTicket/utils/bookingStatus.js +44 -2
- package/lib/solution/BookingTicket/utils/cartView.d.ts +9 -1
- package/lib/solution/BookingTicket/utils/cartView.js +61 -6
- package/lib/solution/BookingTicket/utils/exampleData.d.ts +123 -0
- package/lib/solution/BookingTicket/utils/exampleData.js +0 -0
- package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.d.ts +185 -0
- package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.js +254 -0
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +36 -0
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +169 -0
- package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +32 -0
- package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +51 -0
- package/lib/solution/BookingTicket/utils/scan/index.d.ts +5 -0
- package/lib/solution/BookingTicket/utils/scan/index.js +17 -3
- package/lib/solution/BookingTicket/utils/scan/scanProductValues.d.ts +21 -0
- package/lib/solution/BookingTicket/utils/scan/scanProductValues.js +127 -0
- package/lib/solution/BookingTicket/utils/sessionCatalogStale.d.ts +23 -0
- package/lib/solution/BookingTicket/utils/sessionCatalogStale.js +85 -0
- package/lib/solution/Checkout/index.d.ts +1 -0
- package/lib/solution/Checkout/index.js +1 -2
- package/lib/solution/RegisterAndLogin/config.js +2 -10
- package/lib/solution/ScanOrder/index.d.ts +9 -3
- package/lib/solution/ScanOrder/index.js +153 -70
- package/lib/solution/ScanOrder/types.d.ts +9 -5
- package/lib/solution/ScanOrder/utils.d.ts +1 -1
- package/lib/solution/ScanOrder/utils.js +83 -17
- package/lib/solution/VenueBooking/index.d.ts +5 -2
- package/lib/solution/VenueBooking/index.js +54 -17
- package/lib/solution/VenueBooking/sales-section-4-annotated.json +0 -2
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +4 -0
- package/lib/solution/VenueBooking/utils/slotMerge.js +10 -0
- package/lib/types/index.d.ts +10 -0
- package/package.json +1 -1
- package/dist/solution/Checkout/appointmentDemo.json +0 -1
- package/lib/solution/Checkout/appointmentDemo.json +0 -1
|
@@ -0,0 +1,7 @@
|
|
|
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 {};
|
|
@@ -0,0 +1,277 @@
|
|
|
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
|
+
});
|
|
@@ -23,6 +23,7 @@ export interface BaseProductDetailPayload {
|
|
|
23
23
|
option?: BaseProductDetailOptionItem[];
|
|
24
24
|
options?: BaseProductDetailOptionItem[];
|
|
25
25
|
product_option_item?: BaseProductDetailOptionItem[];
|
|
26
|
+
product_sku?: Record<string, any>;
|
|
26
27
|
bundle?: BaseProductDetailBundleItem[];
|
|
27
28
|
product_bundle?: BaseProductDetailBundleItem[];
|
|
28
29
|
unique?: string;
|
|
@@ -22,6 +22,8 @@ __export(transformBaseProductToOrderProduct_exports, {
|
|
|
22
22
|
transformBaseProductToOrderProduct: () => transformBaseProductToOrderProduct
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(transformBaseProductToOrderProduct_exports);
|
|
25
|
+
var import_utils = require("../../../modules/Order/utils");
|
|
26
|
+
var import_manualProductDiscount = require("../../../modules/Order/utils/manualProductDiscount");
|
|
25
27
|
function toNumber(value, fallback = 0) {
|
|
26
28
|
const parsedValue = Number(value);
|
|
27
29
|
if (!Number.isFinite(parsedValue))
|
|
@@ -52,23 +54,49 @@ function normalizeOptionItems(optionItems) {
|
|
|
52
54
|
if (!Array.isArray(optionItems))
|
|
53
55
|
return [];
|
|
54
56
|
return optionItems.map((optionItem) => {
|
|
55
|
-
const optionGroupItemId = toNumber(optionItem == null ? void 0 : optionItem.option_group_item_id);
|
|
57
|
+
const optionGroupItemId = toNumber((optionItem == null ? void 0 : optionItem.option_group_item_id) ?? (optionItem == null ? void 0 : optionItem.id));
|
|
56
58
|
const price = (optionItem == null ? void 0 : optionItem.price) ?? (optionItem == null ? void 0 : optionItem.add_price) ?? 0;
|
|
57
59
|
return {
|
|
60
|
+
...optionItem,
|
|
58
61
|
option_group_item_id: optionGroupItemId,
|
|
59
62
|
option_group_id: toNumber(optionItem == null ? void 0 : optionItem.option_group_id),
|
|
60
63
|
num: toSafePositiveInt((optionItem == null ? void 0 : optionItem.num) ?? (optionItem == null ? void 0 : optionItem.quantity), 1),
|
|
61
|
-
|
|
64
|
+
add_price: toNumber(price, 0),
|
|
65
|
+
price: void 0
|
|
62
66
|
};
|
|
63
67
|
});
|
|
64
68
|
}
|
|
65
|
-
function normalizeBundleItems(bundleItems) {
|
|
69
|
+
function normalizeBundleItems(bundleItems, preferPriceField = false) {
|
|
66
70
|
if (!Array.isArray(bundleItems))
|
|
67
71
|
return [];
|
|
68
|
-
return bundleItems.map((bundleItem) =>
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
+
return bundleItems.map((bundleItem) => {
|
|
73
|
+
const unitSelling = preferPriceField ? bundleItem.price ?? bundleItem.bundle_selling_price ?? bundleItem.custom_price ?? bundleItem.product_price ?? "0" : bundleItem.bundle_selling_price ?? bundleItem.price ?? bundleItem.custom_price ?? bundleItem.product_price ?? "0";
|
|
74
|
+
const unitStr = toPriceString(unitSelling, "0.00");
|
|
75
|
+
const num = toSafePositiveInt((bundleItem == null ? void 0 : bundleItem.num) ?? (bundleItem == null ? void 0 : bundleItem.quantity), 1);
|
|
76
|
+
const magnitudeSource = {
|
|
77
|
+
...bundleItem,
|
|
78
|
+
option: normalizeOptionItems(bundleItem == null ? void 0 : bundleItem.option),
|
|
79
|
+
bundle_selling_price: unitStr,
|
|
80
|
+
// 计算 markdown 净额时,只传真实毛价;仅有 bundle_selling_price 时按历史净额兜底。
|
|
81
|
+
price: bundleItem.price ?? bundleItem.custom_price
|
|
82
|
+
};
|
|
83
|
+
const normalizedItem = {
|
|
84
|
+
...bundleItem,
|
|
85
|
+
num,
|
|
86
|
+
quantity: (bundleItem == null ? void 0 : bundleItem.quantity) ?? num,
|
|
87
|
+
// price 保留毛价(markdown 仍为正),由 price_type 决定符号。
|
|
88
|
+
price: bundleItem.price ?? unitStr,
|
|
89
|
+
bundle_selling_price: unitStr,
|
|
90
|
+
original_price: bundleItem.original_price ?? bundleItem.product_price ?? bundleItem.price ?? unitStr,
|
|
91
|
+
option: normalizeOptionItems(bundleItem == null ? void 0 : bundleItem.option)
|
|
92
|
+
};
|
|
93
|
+
normalizedItem.bundle_selling_price = (0, import_utils.getBundleSellingMagnitude)(magnitudeSource).toFixed(2);
|
|
94
|
+
if ((normalizedItem.price_type ?? normalizedItem.custom_price_type) === "markdown" && (normalizedItem.price_type_ext === "" || normalizedItem.price_type_ext === void 0 || normalizedItem.price_type_ext === null)) {
|
|
95
|
+
normalizedItem.custom_price = normalizedItem.custom_price ?? normalizedItem.price;
|
|
96
|
+
normalizedItem.price = normalizedItem.bundle_selling_price;
|
|
97
|
+
}
|
|
98
|
+
return normalizedItem;
|
|
99
|
+
});
|
|
72
100
|
}
|
|
73
101
|
function findVariantById(origin, variantId) {
|
|
74
102
|
if (!origin || !variantId || variantId <= 0)
|
|
@@ -77,7 +105,7 @@ function findVariantById(origin, variantId) {
|
|
|
77
105
|
return variants.find((variant) => Number(variant == null ? void 0 : variant.id) === variantId) || null;
|
|
78
106
|
}
|
|
79
107
|
function transformBaseProductToOrderProduct(params) {
|
|
80
|
-
var _a, _b;
|
|
108
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
81
109
|
const { payload, fallbackProductId = null } = params;
|
|
82
110
|
if (!payload || typeof payload !== "object")
|
|
83
111
|
return null;
|
|
@@ -101,13 +129,61 @@ function transformBaseProductToOrderProduct(params) {
|
|
|
101
129
|
payload.price ?? payload.selling_price ?? (matchedVariant == null ? void 0 : matchedVariant.price) ?? (matchedVariant == null ? void 0 : matchedVariant.base_price) ?? (origin == null ? void 0 : origin.price) ?? (origin == null ? void 0 : origin.base_price) ?? (sourceProduct == null ? void 0 : sourceProduct.price) ?? (sourceProduct == null ? void 0 : sourceProduct.selling_price) ?? (sourceProduct == null ? void 0 : sourceProduct.base_price),
|
|
102
130
|
"0.00"
|
|
103
131
|
);
|
|
104
|
-
const
|
|
105
|
-
payload.
|
|
132
|
+
const lineCompositeTotal = toPriceString(
|
|
133
|
+
payload.line_total ?? payload.total ?? ((_c = payload._extend) == null ? void 0 : _c.total),
|
|
134
|
+
sourceProductPrice
|
|
135
|
+
);
|
|
136
|
+
const hasPriceOverride = payload.price_override !== void 0 && payload.price_override !== null && payload.price_override !== "";
|
|
137
|
+
const productOptionItem = (0, import_utils.normalizeProductSkuOptions)(
|
|
138
|
+
normalizeOptionItems(
|
|
139
|
+
((_d = payload.product_sku) == null ? void 0 : _d.option) ?? payload.option ?? payload.options ?? payload.product_option_item
|
|
140
|
+
)
|
|
106
141
|
);
|
|
107
142
|
const productBundle = normalizeBundleItems(
|
|
108
|
-
payload.bundle ?? payload.product_bundle
|
|
143
|
+
payload.bundle ?? payload.product_bundle,
|
|
144
|
+
hasPriceOverride
|
|
145
|
+
);
|
|
146
|
+
const uniqueIdentificationNumber = payload.unique_identification_number;
|
|
147
|
+
const resolvedQuantity = toSafePositiveInt(payload.quantity ?? payload.num, 1);
|
|
148
|
+
const originTotal = (0, import_manualProductDiscount.resolveManualDiscountOriginTotal)({
|
|
149
|
+
originTotal: payload.origin_total,
|
|
150
|
+
extendOriginTotal: (_e = payload._extend) == null ? void 0 : _e.origin_total,
|
|
151
|
+
originExtendOriginTotal: (_f = origin == null ? void 0 : origin._extend) == null ? void 0 : _f.origin_total,
|
|
152
|
+
sourceExtendOriginTotal: (_g = sourceProduct == null ? void 0 : sourceProduct._extend) == null ? void 0 : _g.origin_total,
|
|
153
|
+
catalogUnitPrice: (origin == null ? void 0 : origin.base_price) ?? (origin == null ? void 0 : origin.price) ?? (sourceProduct == null ? void 0 : sourceProduct.base_price) ?? (sourceProduct == null ? void 0 : sourceProduct.price),
|
|
154
|
+
quantity: resolvedQuantity
|
|
155
|
+
});
|
|
156
|
+
const sellingTotal = Number(
|
|
157
|
+
payload.line_total ?? payload.total ?? ((_h = payload._extend) == null ? void 0 : _h.total) ?? lineCompositeTotal
|
|
158
|
+
);
|
|
159
|
+
const discountReason = (0, import_manualProductDiscount.resolveManualDiscountReasonFromSources)({
|
|
160
|
+
discountReason: payload.discount_reason,
|
|
161
|
+
extendDiscountReason: (_i = payload._extend) == null ? void 0 : _i.discount_reason,
|
|
162
|
+
originExtendDiscountReason: (_j = origin == null ? void 0 : origin._extend) == null ? void 0 : _j.discount_reason
|
|
163
|
+
});
|
|
164
|
+
const lineOriginalPrice = hasPriceOverride && Number.isFinite(originTotal) ? toPriceString(originTotal) : lineCompositeTotal;
|
|
165
|
+
const manualDiscountList = (0, import_manualProductDiscount.shouldBuildManualProductDiscount)({
|
|
166
|
+
hasPriceOverride,
|
|
167
|
+
originTotal,
|
|
168
|
+
sellingTotal
|
|
169
|
+
}) ? (0, import_manualProductDiscount.mergeManualProductDiscountIntoList)(
|
|
170
|
+
payload.discount_list,
|
|
171
|
+
(0, import_manualProductDiscount.buildManualProductDiscountItem)({
|
|
172
|
+
originTotal: Number.isFinite(originTotal) ? originTotal : Number(lineOriginalPrice),
|
|
173
|
+
sellingTotal: Number.isFinite(sellingTotal) ? sellingTotal : Number(lineCompositeTotal),
|
|
174
|
+
quantity: resolvedQuantity,
|
|
175
|
+
message: discountReason,
|
|
176
|
+
discountway: (_k = payload._extend) == null ? void 0 : _k.discountway,
|
|
177
|
+
discount_per: (_l = payload._extend) == null ? void 0 : _l.discount_per
|
|
178
|
+
})
|
|
179
|
+
) : payload.discount_list || [];
|
|
180
|
+
const optionSum = (0, import_utils.sumOptionUnitPrice)(productOptionItem).toNumber();
|
|
181
|
+
const mainProductOriginalPrice = toPriceString(Number(sourceProductPrice) + optionSum);
|
|
182
|
+
const bundleOnlyComposite = (0, import_utils.composeLinePrice)({ mainPrice: 0, bundle: productBundle });
|
|
183
|
+
const derivedMainSelling = Number(lineCompositeTotal) - Number(bundleOnlyComposite);
|
|
184
|
+
const mainProductSellingPrice = toPriceString(
|
|
185
|
+
Number.isFinite(derivedMainSelling) && derivedMainSelling >= 0 ? derivedMainSelling : Number(mainProductOriginalPrice)
|
|
109
186
|
);
|
|
110
|
-
const uniqueIdentificationNumber = payload.unique_identification_number ?? payload.unique;
|
|
111
187
|
const metadata = {
|
|
112
188
|
unique: payload.unique,
|
|
113
189
|
session: payload.session,
|
|
@@ -118,8 +194,15 @@ function transformBaseProductToOrderProduct(params) {
|
|
|
118
194
|
duration: payload.duration,
|
|
119
195
|
policy_id: payload.policy_id,
|
|
120
196
|
source_shop_id: payload.source_shop_id,
|
|
121
|
-
|
|
122
|
-
|
|
197
|
+
source_product_price: sourceProductPrice,
|
|
198
|
+
main_product_selling_price: mainProductSellingPrice,
|
|
199
|
+
main_product_original_price: mainProductOriginalPrice,
|
|
200
|
+
price_schema_version: 2,
|
|
201
|
+
...hasPriceOverride ? {
|
|
202
|
+
price_override: String(payload.price_override),
|
|
203
|
+
is_manual_discount: 1
|
|
204
|
+
} : {},
|
|
205
|
+
...payload.bundle_edit !== void 0 ? { bundle_edit: payload.bundle_edit } : {}
|
|
123
206
|
};
|
|
124
207
|
if (uniqueIdentificationNumber) {
|
|
125
208
|
metadata.unique_identification_number = String(uniqueIdentificationNumber);
|
|
@@ -128,11 +211,16 @@ function transformBaseProductToOrderProduct(params) {
|
|
|
128
211
|
product_id: productId,
|
|
129
212
|
product_variant_id: productVariantId,
|
|
130
213
|
unique_identification_number: uniqueIdentificationNumber ? String(uniqueIdentificationNumber) : void 0,
|
|
131
|
-
num:
|
|
132
|
-
|
|
214
|
+
num: resolvedQuantity,
|
|
215
|
+
product_sku: {
|
|
216
|
+
...payload.product_sku && typeof payload.product_sku === "object" ? payload.product_sku : {},
|
|
217
|
+
option: productOptionItem
|
|
218
|
+
},
|
|
133
219
|
product_bundle: productBundle,
|
|
134
|
-
|
|
135
|
-
|
|
220
|
+
discount_list: manualDiscountList,
|
|
221
|
+
// 折后行价由 normalizeOrderProduct 按 main + bundle 合成;手动改价时 bundle 已为分摊后单价
|
|
222
|
+
selling_price: lineCompositeTotal,
|
|
223
|
+
original_price: lineOriginalPrice,
|
|
136
224
|
tax_fee: toPriceString(
|
|
137
225
|
payload.tax_fee ?? (matchedVariant == null ? void 0 : matchedVariant.tax_fee) ?? (origin == null ? void 0 : origin.tax_fee) ?? (sourceProduct == null ? void 0 : sourceProduct.tax_fee),
|
|
138
226
|
"0.00"
|
|
@@ -12,7 +12,7 @@ export declare function buildProductLineFingerprint(productOptionItem?: unknown,
|
|
|
12
12
|
export declare function getSafeProductNum(num?: number): number;
|
|
13
13
|
/**
|
|
14
14
|
* removeProductFromOrder 仅传 SKU 时的通配 identity(对象上未声明选项键)。
|
|
15
|
-
* 与显式 `
|
|
15
|
+
* 与显式 `product_sku: { option: [] }` 区分:后者只匹配「无选项」行。
|
|
16
16
|
*/
|
|
17
17
|
export declare function isSkuOnlyDeleteIdentity(x: BaseSalesOrderProductIdentity): boolean;
|
|
18
18
|
/**
|
|
@@ -38,6 +38,7 @@ __export(utils_exports, {
|
|
|
38
38
|
module.exports = __toCommonJS(utils_exports);
|
|
39
39
|
var import_decimal = __toESM(require("decimal.js"));
|
|
40
40
|
var import_utils = require("../../modules/Order/utils");
|
|
41
|
+
var import_manualProductDiscount = require("../../modules/Order/utils/manualProductDiscount");
|
|
41
42
|
function createEmptySummary() {
|
|
42
43
|
return {
|
|
43
44
|
product_quantity: 0,
|
|
@@ -64,7 +65,7 @@ function buildProductLineFingerprint(productOptionItem, productBundle) {
|
|
|
64
65
|
option_group_item_id: Number(item == null ? void 0 : item.option_group_item_id) || 0,
|
|
65
66
|
option_group_id: Number(item == null ? void 0 : item.option_group_id) || 0,
|
|
66
67
|
num: typeof (item == null ? void 0 : item.num) === "number" && !Number.isNaN(item.num) ? Math.max(1, Math.floor(item.num)) : 1,
|
|
67
|
-
price: String((item == null ? void 0 : item.price) ?? "")
|
|
68
|
+
price: String((item == null ? void 0 : item.add_price) ?? (item == null ? void 0 : item.price) ?? "")
|
|
68
69
|
})).sort((p, q) => {
|
|
69
70
|
if (p.option_group_item_id !== q.option_group_item_id) {
|
|
70
71
|
return p.option_group_item_id - q.option_group_item_id;
|
|
@@ -99,26 +100,58 @@ function getSafeProductNum(num) {
|
|
|
99
100
|
function isSkuOnlyDeleteIdentity(x) {
|
|
100
101
|
if (x.identity_key)
|
|
101
102
|
return false;
|
|
102
|
-
return !("
|
|
103
|
+
return !("product_sku" in x) && !("product_bundle" in x);
|
|
103
104
|
}
|
|
104
105
|
function normalizeOrderProduct(product) {
|
|
105
|
-
var _a, _b, _c;
|
|
106
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
106
107
|
const metadata = { ...product.metadata || {} };
|
|
107
108
|
const resolvedIdentityKey = ((_a = product.metadata) == null ? void 0 : _a.unique_identification_number) ? String(product.metadata.unique_identification_number) : product.unique_identification_number && String(product.unique_identification_number).length > 0 ? String(product.unique_identification_number) : product.identity_key && String(product.identity_key).length > 0 ? String(product.identity_key) : (0, import_utils.createUuidV4)();
|
|
108
109
|
metadata.unique_identification_number = resolvedIdentityKey;
|
|
109
|
-
const
|
|
110
|
+
const priceOverride = metadata.price_override;
|
|
111
|
+
const originOtherBundle = (_d = (_c = (_b = metadata.origin) == null ? void 0 : _b._extend) == null ? void 0 : _c.other) == null ? void 0 : _d.bundle;
|
|
112
|
+
let bundleInput = product.product_bundle || [];
|
|
113
|
+
if (priceOverride !== void 0 && priceOverride !== null && priceOverride !== "" && Array.isArray(originOtherBundle) && originOtherBundle.length > 0) {
|
|
114
|
+
const priceById = /* @__PURE__ */ new Map();
|
|
115
|
+
originOtherBundle.forEach((item) => {
|
|
116
|
+
if ((item == null ? void 0 : item.id) == null)
|
|
117
|
+
return;
|
|
118
|
+
const unit = item.price ?? item.bundle_selling_price;
|
|
119
|
+
if (unit === void 0 || unit === null)
|
|
120
|
+
return;
|
|
121
|
+
priceById.set(String(item.id), String(unit));
|
|
122
|
+
});
|
|
123
|
+
const base = Array.isArray(bundleInput) && bundleInput.length > 0 ? bundleInput : originOtherBundle;
|
|
124
|
+
bundleInput = base.map((item) => {
|
|
125
|
+
const unit = priceById.get(String(item == null ? void 0 : item.id));
|
|
126
|
+
if (unit === void 0)
|
|
127
|
+
return item;
|
|
128
|
+
return {
|
|
129
|
+
...item,
|
|
130
|
+
price: unit,
|
|
131
|
+
bundle_selling_price: unit
|
|
132
|
+
};
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
const normalizedBundle = bundleInput.map((item) => ({
|
|
110
136
|
...item,
|
|
137
|
+
bundle_id: item.bundle_id ?? item.id,
|
|
138
|
+
bundle_product_id: item.bundle_product_id ?? item._bundle_product_id,
|
|
139
|
+
bundle_group_id: item.bundle_group_id ?? item.group_id,
|
|
111
140
|
bundle_selling_price: item.bundle_selling_price ?? item.price ?? "0.00",
|
|
112
141
|
price: item.price ?? item.custom_price ?? item.bundle_selling_price ?? "0.00",
|
|
113
142
|
price_type: item.price_type ?? item.custom_price_type ?? "",
|
|
114
143
|
price_type_ext: item.price_type_ext ?? item.custom_price_type_ext ?? ""
|
|
115
144
|
}));
|
|
116
|
-
const normalizedOptions = product.
|
|
145
|
+
const normalizedOptions = (0, import_utils.normalizeProductSkuOptions)((_e = product.product_sku) == null ? void 0 : _e.option);
|
|
117
146
|
const optionSum = (0, import_utils.sumOptionUnitPrice)(normalizedOptions);
|
|
147
|
+
const productSku = {
|
|
148
|
+
...(0, import_utils.ensureProductSku)(product),
|
|
149
|
+
option: normalizedOptions
|
|
150
|
+
};
|
|
118
151
|
const isV2 = metadata.price_schema_version === 2 || metadata.price_schema_version === "2";
|
|
119
152
|
const variantId = Number(product.product_variant_id || 0);
|
|
120
|
-
const variantList = variantId ? (
|
|
121
|
-
const variantPrice = Array.isArray(variantList) ? (
|
|
153
|
+
const variantList = variantId ? (_f = metadata == null ? void 0 : metadata.origin) == null ? void 0 : _f.variant : null;
|
|
154
|
+
const variantPrice = Array.isArray(variantList) ? (_g = variantList.find((v) => Number(v == null ? void 0 : v.id) === variantId)) == null ? void 0 : _g.price : void 0;
|
|
122
155
|
const resolvedSource = (() => {
|
|
123
156
|
var _a2, _b2;
|
|
124
157
|
if (metadata.source_product_price !== void 0) {
|
|
@@ -174,17 +207,28 @@ function normalizeOrderProduct(product) {
|
|
|
174
207
|
bundle: normalizedBundle,
|
|
175
208
|
useOriginalBundle: true
|
|
176
209
|
});
|
|
210
|
+
const finalOriginalPrice = (0, import_utils.resolveManualOverrideLineOriginalPrice)(
|
|
211
|
+
{ num: product.num, metadata, lineOriginalPrice: product.original_price },
|
|
212
|
+
composedOriginalPrice
|
|
213
|
+
);
|
|
214
|
+
const discountList = (0, import_manualProductDiscount.ensureManualProductDiscountList)({
|
|
215
|
+
discountList: product.discount_list,
|
|
216
|
+
metadata,
|
|
217
|
+
originalPrice: finalOriginalPrice,
|
|
218
|
+
sellingPrice: composedSellingPrice,
|
|
219
|
+
quantity: getSafeProductNum(product.num)
|
|
220
|
+
});
|
|
177
221
|
return {
|
|
178
222
|
order_detail_id: product.order_detail_id || null,
|
|
179
223
|
product_id: product.product_id,
|
|
180
224
|
num: getSafeProductNum(product.num),
|
|
181
225
|
product_variant_id: product.product_variant_id,
|
|
182
|
-
|
|
226
|
+
product_sku: productSku,
|
|
183
227
|
selling_price: composedSellingPrice,
|
|
184
|
-
original_price:
|
|
228
|
+
original_price: finalOriginalPrice,
|
|
185
229
|
tax_fee: product.tax_fee || "0.00",
|
|
186
230
|
is_charge_tax: product.is_charge_tax ?? 0,
|
|
187
|
-
discount_list:
|
|
231
|
+
discount_list: discountList,
|
|
188
232
|
product_bundle: normalizedBundle,
|
|
189
233
|
metadata,
|
|
190
234
|
note: product.note != null ? String(product.note) : ""
|
|
@@ -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 | 2 | 1 | 5 | 3 |
|
|
314
|
+
weekNum: 0 | 2 | 1 | 5 | 3 | 6 | 4;
|
|
315
315
|
}[]>;
|
|
316
316
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
317
317
|
private getScheduleDataByIds;
|