@pisell/pisellos 2.2.244 → 2.2.246
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/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 +148 -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 +277 -18
- package/dist/modules/Order/index.js +3581 -779
- 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 +1762 -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 +154 -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 +277 -18
- package/lib/modules/Order/index.js +2317 -337
- 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 +887 -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,35 @@
|
|
|
1
|
+
import type { BaseSalesOrderProduct } from '../../BaseSales';
|
|
2
|
+
import type { ISalesBooking } from '../../BaseSales/utils/parseSalesResponse';
|
|
3
|
+
export interface BuildAddTimeCurrentItemParams {
|
|
4
|
+
booking: ISalesBooking;
|
|
5
|
+
product: BaseSalesOrderProduct | null;
|
|
6
|
+
productsByUid?: Record<string, {
|
|
7
|
+
origin?: Record<string, any>;
|
|
8
|
+
}>;
|
|
9
|
+
}
|
|
10
|
+
export interface ResolveBookingCanAddTimeParams extends BuildAddTimeCurrentItemParams {
|
|
11
|
+
addTimeProducts?: any[];
|
|
12
|
+
bookingConfig?: Record<string, any> | null;
|
|
13
|
+
shopOpeningHours?: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* 从 booking 与其关联商品行构建旧 `isUsableProduct` 所需的当前商品快照。
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* const currentItem = buildAddTimeCurrentItem({ booking, product, productsByUid });
|
|
20
|
+
*/
|
|
21
|
+
export declare function buildAddTimeCurrentItem({ booking, product, productsByUid, }: BuildAddTimeCurrentItemParams): Record<string, any> | null;
|
|
22
|
+
/**
|
|
23
|
+
* 判断当前 booking 是否允许打开加时入口,保持与旧 ticketBooking 的商品适用规则一致。
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* const canAddTime = resolveBookingCanAddTime({ booking, product, addTimeProducts, bookingConfig });
|
|
27
|
+
*/
|
|
28
|
+
export declare function resolveBookingCanAddTime(params: ResolveBookingCanAddTimeParams): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* 判断一个加时商品是否适用于当前预约商品。
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* const usable = isUsableAddTimeProduct(addTime.add_time, currentItem, '23:59');
|
|
34
|
+
*/
|
|
35
|
+
export declare function isUsableAddTimeProduct(addTime: any, currentItem: Record<string, any> | null | undefined, shopOpeningHours?: string): boolean;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
+
import dayjs from 'dayjs';
|
|
8
|
+
import { intersectionBy } from 'lodash-es';
|
|
9
|
+
import { isMultiDayProduct } from "../../../modules/BookingContext/utils/serviceTimes";
|
|
10
|
+
import { getEndDate } from "../../../modules/BookingContext/utils/timeSlices";
|
|
11
|
+
/**
|
|
12
|
+
* 从 booking 与其关联商品行构建旧 `isUsableProduct` 所需的当前商品快照。
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* const currentItem = buildAddTimeCurrentItem({ booking, product, productsByUid });
|
|
16
|
+
*/
|
|
17
|
+
export function buildAddTimeCurrentItem(_ref) {
|
|
18
|
+
var _product$metadata, _productsByUid$String, _ref2, _product$product_id, _sourceProduct$id, _booking$product;
|
|
19
|
+
var booking = _ref.booking,
|
|
20
|
+
product = _ref.product,
|
|
21
|
+
productsByUid = _ref.productsByUid;
|
|
22
|
+
if (!booking || !product) return null;
|
|
23
|
+
var uid = (_product$metadata = product.metadata) === null || _product$metadata === void 0 ? void 0 : _product$metadata.unique_identification_number;
|
|
24
|
+
var origin = uid ? productsByUid === null || productsByUid === void 0 || (_productsByUid$String = productsByUid[String(uid)]) === null || _productsByUid$String === void 0 ? void 0 : _productsByUid$String.origin : undefined;
|
|
25
|
+
var sourceProduct = origin || booking.product || {};
|
|
26
|
+
var startAt = booking.start_date && booking.start_time ? "".concat(booking.start_date, " ").concat(booking.start_time) : booking.start_date;
|
|
27
|
+
var endAt = booking.end_date && booking.end_time ? "".concat(booking.end_date, " ").concat(booking.end_time) : booking.end_date;
|
|
28
|
+
return _objectSpread(_objectSpread(_objectSpread({}, sourceProduct), booking.product), {}, {
|
|
29
|
+
product_id: (_ref2 = (_product$product_id = product.product_id) !== null && _product$product_id !== void 0 ? _product$product_id : sourceProduct.product_id) !== null && _ref2 !== void 0 ? _ref2 : sourceProduct.id,
|
|
30
|
+
id: (_sourceProduct$id = sourceProduct.id) !== null && _sourceProduct$id !== void 0 ? _sourceProduct$id : product.product_id,
|
|
31
|
+
collection: sourceProduct.collection || ((_booking$product = booking.product) === null || _booking$product === void 0 ? void 0 : _booking$product.collection) || [],
|
|
32
|
+
duration: sourceProduct.duration || booking.duration,
|
|
33
|
+
_extend: _objectSpread(_objectSpread({}, sourceProduct._extend || {}), {}, {
|
|
34
|
+
startDate: startAt ? dayjs(startAt) : undefined,
|
|
35
|
+
endDate: endAt ? dayjs(endAt) : undefined,
|
|
36
|
+
start_date: booking.start_date,
|
|
37
|
+
end_date: booking.end_date,
|
|
38
|
+
start_time: booking.start_time,
|
|
39
|
+
end_time: booking.end_time,
|
|
40
|
+
sub_type: booking.sub_type
|
|
41
|
+
})
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* 判断当前 booking 是否允许打开加时入口,保持与旧 ticketBooking 的商品适用规则一致。
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* const canAddTime = resolveBookingCanAddTime({ booking, product, addTimeProducts, bookingConfig });
|
|
50
|
+
*/
|
|
51
|
+
export function resolveBookingCanAddTime(params) {
|
|
52
|
+
var _params$bookingConfig;
|
|
53
|
+
var quickTime = (_params$bookingConfig = params.bookingConfig) === null || _params$bookingConfig === void 0 || (_params$bookingConfig = _params$bookingConfig.config) === null || _params$bookingConfig === void 0 || (_params$bookingConfig = _params$bookingConfig.information_tab) === null || _params$bookingConfig === void 0 || (_params$bookingConfig = _params$bookingConfig.appointment_card) === null || _params$bookingConfig === void 0 ? void 0 : _params$bookingConfig.quick_time;
|
|
54
|
+
if (quickTime !== undefined && quickTime !== 1) return false;
|
|
55
|
+
var currentItem = buildAddTimeCurrentItem(params);
|
|
56
|
+
if (!currentItem || isMultiDayProduct(currentItem)) return false;
|
|
57
|
+
return (params.addTimeProducts || []).some(function (item) {
|
|
58
|
+
return isUsableAddTimeProduct(item === null || item === void 0 ? void 0 : item.add_time, currentItem, params.shopOpeningHours);
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* 判断一个加时商品是否适用于当前预约商品。
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* const usable = isUsableAddTimeProduct(addTime.add_time, currentItem, '23:59');
|
|
67
|
+
*/
|
|
68
|
+
export function isUsableAddTimeProduct(addTime, currentItem, shopOpeningHours) {
|
|
69
|
+
if (!addTime || !currentItem) return false;
|
|
70
|
+
if (addTime.additional_time_options === 'unlimited') {
|
|
71
|
+
var _currentItem$_extend, _currentItem$_extend2;
|
|
72
|
+
var startDate = dayjs((_currentItem$_extend = currentItem._extend) === null || _currentItem$_extend === void 0 ? void 0 : _currentItem$_extend.startDate);
|
|
73
|
+
var endDate = dayjs((_currentItem$_extend2 = currentItem._extend) === null || _currentItem$_extend2 === void 0 ? void 0 : _currentItem$_extend2.endDate);
|
|
74
|
+
if (!startDate.isValid() || !endDate.isValid()) return false;
|
|
75
|
+
var maxEndDate = getEndDate(startDate, 'flexible', '', shopOpeningHours);
|
|
76
|
+
if (endDate.isAfter(maxEndDate)) return false;
|
|
77
|
+
}
|
|
78
|
+
var relationProduct = addTime.relation_product || {};
|
|
79
|
+
var type = relationProduct.type;
|
|
80
|
+
var products = Array.isArray(relationProduct.products) ? relationProduct.products : [];
|
|
81
|
+
if (type === 'product_all') return true;
|
|
82
|
+
if (type === 'product_collection') {
|
|
83
|
+
return Boolean(intersectionBy(products.map(function (item) {
|
|
84
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
85
|
+
id: item.product_collection_id
|
|
86
|
+
});
|
|
87
|
+
}), currentItem.collection || [], 'id').length);
|
|
88
|
+
}
|
|
89
|
+
if (type === 'products') {
|
|
90
|
+
return products.some(function (item) {
|
|
91
|
+
return item.product_id == currentItem.product_id;
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
@@ -9,6 +9,21 @@
|
|
|
9
9
|
* 字段含义严格对齐既有协议(OrderTempOrder / parseSalesResponse),
|
|
10
10
|
* 不发明等价关系。
|
|
11
11
|
*/
|
|
12
|
+
/**
|
|
13
|
+
* 子预约状态机转移动作(POST /schedule/booking-transition/{schedule_event_id})。
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* await bookingTicket.transitionChildBooking({
|
|
17
|
+
* schedule_event_id: 301,
|
|
18
|
+
* action: 'confirm',
|
|
19
|
+
* });
|
|
20
|
+
*/
|
|
21
|
+
export type BookingTransitionAction = 'confirm' | 'reject' | 'arrive' | 'start' | 'complete' | 'cancel' | 'no_show' | 'reschedule';
|
|
22
|
+
/** 子预约状态转移入参 */
|
|
23
|
+
export interface TransitionChildBookingParams {
|
|
24
|
+
schedule_event_id: number | string;
|
|
25
|
+
action: BookingTransitionAction;
|
|
26
|
+
}
|
|
12
27
|
/**
|
|
13
28
|
* 从 tempOrder 解析用于调用 appointment-status 接口的 schedule id。
|
|
14
29
|
*
|
|
@@ -35,3 +50,28 @@ export declare function applyBookingsStatus(bookings: any[] | null | undefined,
|
|
|
35
50
|
* 长度不一致时按较短一方对齐(防御式编程,正常路径不会发生)。
|
|
36
51
|
*/
|
|
37
52
|
export declare function restoreBookingsStatus(bookings: any[] | null | undefined, previous: Array<string | undefined>): void;
|
|
53
|
+
/**
|
|
54
|
+
* 将状态机 action 解析为转移后的 `appointment_status`。
|
|
55
|
+
*
|
|
56
|
+
* `reschedule` 暂未在状态矩阵启用,返回 null 表示跳过乐观更新。
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* resolveStatusAfterTransition('confirm'); // 'confirmed'
|
|
60
|
+
*/
|
|
61
|
+
export declare function resolveStatusAfterTransition(action: BookingTransitionAction): string | null;
|
|
62
|
+
/**
|
|
63
|
+
* 在 bookings 中按 `schedule_event_id` 定位子预约并乐观写入 `appointment_status`。
|
|
64
|
+
*
|
|
65
|
+
* @returns 写入前的 status;未命中时返回 undefined(调用方跳过回滚)
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* const prev = applyChildBookingStatus(tempOrder.bookings, 301, 'confirmed');
|
|
69
|
+
*/
|
|
70
|
+
export declare function applyChildBookingStatus(bookings: any[] | null | undefined, scheduleEventId: number | string, status: string): string | undefined;
|
|
71
|
+
/**
|
|
72
|
+
* 撤销 applyChildBookingStatus 对单条子预约的乐观写入。
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* restoreChildBookingStatus(tempOrder.bookings, 301, prev);
|
|
76
|
+
*/
|
|
77
|
+
export declare function restoreChildBookingStatus(bookings: any[] | null | undefined, scheduleEventId: number | string, previous: string | undefined): void;
|
|
@@ -10,6 +10,18 @@
|
|
|
10
10
|
* 不发明等价关系。
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
+
/**
|
|
14
|
+
* 子预约状态机转移动作(POST /schedule/booking-transition/{schedule_event_id})。
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* await bookingTicket.transitionChildBooking({
|
|
18
|
+
* schedule_event_id: 301,
|
|
19
|
+
* action: 'confirm',
|
|
20
|
+
* });
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/** 子预约状态转移入参 */
|
|
24
|
+
|
|
13
25
|
/**
|
|
14
26
|
* 从 tempOrder 解析用于调用 appointment-status 接口的 schedule id。
|
|
15
27
|
*
|
|
@@ -63,4 +75,62 @@ export function restoreBookingsStatus(bookings, previous) {
|
|
|
63
75
|
var b = bookings[i];
|
|
64
76
|
if (b) b.appointment_status = previous[i];
|
|
65
77
|
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* 将状态机 action 解析为转移后的 `appointment_status`。
|
|
82
|
+
*
|
|
83
|
+
* `reschedule` 暂未在状态矩阵启用,返回 null 表示跳过乐观更新。
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* resolveStatusAfterTransition('confirm'); // 'confirmed'
|
|
87
|
+
*/
|
|
88
|
+
export function resolveStatusAfterTransition(action) {
|
|
89
|
+
var _map$action;
|
|
90
|
+
var map = {
|
|
91
|
+
confirm: 'confirmed',
|
|
92
|
+
reject: 'rejected',
|
|
93
|
+
arrive: 'arrived',
|
|
94
|
+
start: 'started',
|
|
95
|
+
complete: 'completed',
|
|
96
|
+
cancel: 'cancelled',
|
|
97
|
+
no_show: 'no_show',
|
|
98
|
+
reschedule: null
|
|
99
|
+
};
|
|
100
|
+
return (_map$action = map[action]) !== null && _map$action !== void 0 ? _map$action : null;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* 在 bookings 中按 `schedule_event_id` 定位子预约并乐观写入 `appointment_status`。
|
|
105
|
+
*
|
|
106
|
+
* @returns 写入前的 status;未命中时返回 undefined(调用方跳过回滚)
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* const prev = applyChildBookingStatus(tempOrder.bookings, 301, 'confirmed');
|
|
110
|
+
*/
|
|
111
|
+
export function applyChildBookingStatus(bookings, scheduleEventId, status) {
|
|
112
|
+
var _bookings$idx;
|
|
113
|
+
if (!Array.isArray(bookings)) return undefined;
|
|
114
|
+
var idx = bookings.findIndex(function (b) {
|
|
115
|
+
return b && String(b.schedule_event_id) === String(scheduleEventId);
|
|
116
|
+
});
|
|
117
|
+
if (idx === -1) return undefined;
|
|
118
|
+
var previous = (_bookings$idx = bookings[idx]) === null || _bookings$idx === void 0 ? void 0 : _bookings$idx.appointment_status;
|
|
119
|
+
bookings[idx].appointment_status = status;
|
|
120
|
+
return previous;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* 撤销 applyChildBookingStatus 对单条子预约的乐观写入。
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* restoreChildBookingStatus(tempOrder.bookings, 301, prev);
|
|
128
|
+
*/
|
|
129
|
+
export function restoreChildBookingStatus(bookings, scheduleEventId, previous) {
|
|
130
|
+
if (!Array.isArray(bookings) || previous === undefined) return;
|
|
131
|
+
var idx = bookings.findIndex(function (b) {
|
|
132
|
+
return b && String(b.schedule_event_id) === String(scheduleEventId);
|
|
133
|
+
});
|
|
134
|
+
if (idx === -1) return;
|
|
135
|
+
bookings[idx].appointment_status = previous;
|
|
66
136
|
}
|
|
@@ -2,6 +2,14 @@ import type { BaseSalesOrderProduct } from '../../BaseSales';
|
|
|
2
2
|
import type { ISalesBooking } from '../../BaseSales/utils/parseSalesResponse';
|
|
3
3
|
import type { BookingTicketCartView, BookingTicketCustomerView, ICustomer } from '../types';
|
|
4
4
|
import type { ScanOrderTempOrder } from '../../ScanOrder/types';
|
|
5
|
+
export interface BuildCartViewOptions {
|
|
6
|
+
addTimeProducts?: any[];
|
|
7
|
+
bookingConfig?: Record<string, any> | null;
|
|
8
|
+
productsByUid?: Record<string, {
|
|
9
|
+
origin?: Record<string, any>;
|
|
10
|
+
}>;
|
|
11
|
+
shopOpeningHours?: string;
|
|
12
|
+
}
|
|
5
13
|
/**
|
|
6
14
|
* 仅按 booking.product_uid 建索引,避免发明 booking 与商品行之间的其它等价关系。
|
|
7
15
|
*/
|
|
@@ -13,7 +21,7 @@ export declare function indexBookingsByProductUid(bookings: ISalesBooking[] | un
|
|
|
13
21
|
* 关联规则(1:1):booking.product_uid ↔ line.metadata.unique_identification_number;
|
|
14
22
|
* 同一 uid 已被更早的 booking 占用时,后续 booking 的 product 为 null。
|
|
15
23
|
*/
|
|
16
|
-
export declare function buildCartView(lines: BaseSalesOrderProduct[] | undefined | null, bookings: ISalesBooking[] | undefined | null): BookingTicketCartView;
|
|
24
|
+
export declare function buildCartView(lines: BaseSalesOrderProduct[] | undefined | null, bookings: ISalesBooking[] | undefined | null, options?: BuildCartViewOptions): BookingTicketCartView;
|
|
17
25
|
export declare function isWalkInCustomer(customer: Pick<ICustomer, 'id'> | null | undefined): boolean;
|
|
18
26
|
/**
|
|
19
27
|
* selected 优先,缺失时回退 tempOrder.customer_*,统一输出 UI 客户视图。
|
|
@@ -4,6 +4,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
4
4
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
5
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
6
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
+
import { resolveBookingCanAddTime } from "./addTimeAvailability";
|
|
7
8
|
/**
|
|
8
9
|
* 仅按 booking.product_uid 建索引,避免发明 booking 与商品行之间的其它等价关系。
|
|
9
10
|
*/
|
|
@@ -33,6 +34,69 @@ function indexProductsByUid(lines) {
|
|
|
33
34
|
}, {});
|
|
34
35
|
}
|
|
35
36
|
|
|
37
|
+
/**
|
|
38
|
+
* 读取 booking 的协议唯一值。
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* const uid = getBookingUid(booking);
|
|
42
|
+
*/
|
|
43
|
+
function getBookingUid(booking) {
|
|
44
|
+
var _booking$metadata;
|
|
45
|
+
var uid = booking === null || booking === void 0 || (_booking$metadata = booking.metadata) === null || _booking$metadata === void 0 ? void 0 : _booking$metadata.unique_identification_number;
|
|
46
|
+
return uid === undefined || uid === null ? '' : String(uid);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* 读取商品行绑定的 booking 唯一值。
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* const bookingUid = getProductBookingUid(product);
|
|
54
|
+
*/
|
|
55
|
+
function getProductBookingUid(line) {
|
|
56
|
+
var _booking_uid, _line$metadata2;
|
|
57
|
+
var uid = (_booking_uid = line === null || line === void 0 ? void 0 : line.booking_uid) !== null && _booking_uid !== void 0 ? _booking_uid : line === null || line === void 0 || (_line$metadata2 = line.metadata) === null || _line$metadata2 === void 0 ? void 0 : _line$metadata2.booking_uid;
|
|
58
|
+
return uid === undefined || uid === null ? '' : String(uid);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* 判断商品行是否为加时商品行。
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* isAddTimeProductLine({ metadata: { product_add_schedule_time: 30 } } as any);
|
|
66
|
+
*/
|
|
67
|
+
function isAddTimeProductLine(line) {
|
|
68
|
+
var _line$metadata3, _line$metadata4;
|
|
69
|
+
return (line === null || line === void 0 || (_line$metadata3 = line.metadata) === null || _line$metadata3 === void 0 ? void 0 : _line$metadata3.product_add_schedule_time) !== undefined && (line === null || line === void 0 || (_line$metadata4 = line.metadata) === null || _line$metadata4 === void 0 ? void 0 : _line$metadata4.product_add_schedule_time) !== null;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* 将加时商品按 booking_uid 建索引。
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* const map = indexAddTimeProductsByBookingUid(products);
|
|
77
|
+
*/
|
|
78
|
+
function indexAddTimeProductsByBookingUid(lines) {
|
|
79
|
+
return lines.reduce(function (acc, line) {
|
|
80
|
+
if (!isAddTimeProductLine(line)) return acc;
|
|
81
|
+
var bookingUid = getProductBookingUid(line);
|
|
82
|
+
if (!bookingUid) return acc;
|
|
83
|
+
if (!acc[bookingUid]) acc[bookingUid] = [];
|
|
84
|
+
acc[bookingUid].push(line);
|
|
85
|
+
return acc;
|
|
86
|
+
}, {});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* 判断商品行是否是促销赠品行。
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* isGiftProductLine({ metadata: { _giftInfo: {} } } as any); // true
|
|
94
|
+
*/
|
|
95
|
+
function isGiftProductLine(line) {
|
|
96
|
+
var _line$metadata5;
|
|
97
|
+
return Boolean(line === null || line === void 0 || (_line$metadata5 = line.metadata) === null || _line$metadata5 === void 0 ? void 0 : _line$metadata5._giftInfo);
|
|
98
|
+
}
|
|
99
|
+
|
|
36
100
|
/**
|
|
37
101
|
* 构建购物车 UI 视图:bookings 平铺附带关联商品;items 仅含未关联 booking 的商品行。
|
|
38
102
|
*
|
|
@@ -41,34 +105,57 @@ function indexProductsByUid(lines) {
|
|
|
41
105
|
* 同一 uid 已被更早的 booking 占用时,后续 booking 的 product 为 null。
|
|
42
106
|
*/
|
|
43
107
|
export function buildCartView(lines, bookings) {
|
|
108
|
+
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
44
109
|
var productLines = Array.isArray(lines) ? lines : [];
|
|
45
110
|
var bookingList = Array.isArray(bookings) ? bookings : [];
|
|
46
111
|
var linesByUid = indexProductsByUid(productLines);
|
|
112
|
+
var addTimeLinesByBookingUid = indexAddTimeProductsByBookingUid(productLines);
|
|
47
113
|
var claimedUids = new Set();
|
|
114
|
+
var claimedAddTimeLines = new Set();
|
|
48
115
|
var cartBookings = bookingList.filter(function (booking) {
|
|
49
116
|
return booking.parent_id !== 0;
|
|
50
|
-
}).
|
|
117
|
+
}).reduce(function (acc, booking) {
|
|
51
118
|
var uid = booking === null || booking === void 0 ? void 0 : booking.product_uid;
|
|
119
|
+
var bookingUid = getBookingUid(booking);
|
|
52
120
|
var product = null;
|
|
53
121
|
if (uid !== undefined && uid !== null && uid !== '') {
|
|
54
122
|
var key = String(uid);
|
|
55
123
|
if (!claimedUids.has(key)) {
|
|
56
124
|
var line = linesByUid[key];
|
|
125
|
+
// 赠品预约只作为提交数据保留,不在购物车顶部预约卡片区展示。
|
|
126
|
+
if (isGiftProductLine(line)) return acc;
|
|
57
127
|
if (line) {
|
|
58
128
|
claimedUids.add(key);
|
|
59
129
|
product = line;
|
|
60
130
|
}
|
|
61
131
|
}
|
|
62
132
|
}
|
|
63
|
-
|
|
133
|
+
var addTimeProduct = bookingUid ? addTimeLinesByBookingUid[bookingUid] || [] : [];
|
|
134
|
+
addTimeProduct.forEach(function (line) {
|
|
135
|
+
return claimedAddTimeLines.add(line);
|
|
136
|
+
});
|
|
137
|
+
acc.push(_objectSpread(_objectSpread({}, booking), {}, {
|
|
64
138
|
_extend: {
|
|
65
|
-
product: product
|
|
139
|
+
product: product,
|
|
140
|
+
addTimeProduct: addTimeProduct,
|
|
141
|
+
canAddTime: resolveBookingCanAddTime({
|
|
142
|
+
booking: booking,
|
|
143
|
+
product: product,
|
|
144
|
+
addTimeProducts: options.addTimeProducts,
|
|
145
|
+
bookingConfig: options.bookingConfig,
|
|
146
|
+
productsByUid: options.productsByUid,
|
|
147
|
+
shopOpeningHours: options.shopOpeningHours
|
|
148
|
+
})
|
|
66
149
|
}
|
|
67
|
-
});
|
|
68
|
-
|
|
150
|
+
}));
|
|
151
|
+
return acc;
|
|
152
|
+
}, []);
|
|
69
153
|
var items = productLines.filter(function (line) {
|
|
70
|
-
var _line$
|
|
71
|
-
|
|
154
|
+
var _line$metadata6;
|
|
155
|
+
// 促销赠品行仅通过主商品 Gift 行展示,不在 items 单独占一行(对齐 legacy `isGift: !!_giftInfo`)
|
|
156
|
+
if (isGiftProductLine(line)) return false;
|
|
157
|
+
if (claimedAddTimeLines.has(line)) return false;
|
|
158
|
+
var uid = (_line$metadata6 = line.metadata) === null || _line$metadata6 === void 0 ? void 0 : _line$metadata6.unique_identification_number;
|
|
72
159
|
if (uid === undefined || uid === null || uid === '') return true;
|
|
73
160
|
return !claimedUids.has(String(uid));
|
|
74
161
|
});
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
declare let data: ({
|
|
2
|
+
id: number;
|
|
3
|
+
title: string;
|
|
4
|
+
price: number;
|
|
5
|
+
minMinutes: number;
|
|
6
|
+
maxMinutes: number;
|
|
7
|
+
unitMinutes: number;
|
|
8
|
+
unlimited: boolean;
|
|
9
|
+
_originalProduct: {
|
|
10
|
+
id: number;
|
|
11
|
+
extension_id: number;
|
|
12
|
+
extension_type: string;
|
|
13
|
+
shop_id: number;
|
|
14
|
+
title: string;
|
|
15
|
+
slug: string;
|
|
16
|
+
status: string;
|
|
17
|
+
stock_quantity: number;
|
|
18
|
+
sales_quantity: number;
|
|
19
|
+
sum_stock: number;
|
|
20
|
+
price: string;
|
|
21
|
+
original_price: string;
|
|
22
|
+
cost_price: string;
|
|
23
|
+
cover: string;
|
|
24
|
+
channel_application: string[];
|
|
25
|
+
is_track: number;
|
|
26
|
+
over_sold: number;
|
|
27
|
+
is_gst: number;
|
|
28
|
+
code: string;
|
|
29
|
+
barcode: string;
|
|
30
|
+
is_delivery: number;
|
|
31
|
+
weight_unit: string;
|
|
32
|
+
weight_value: string;
|
|
33
|
+
type: string;
|
|
34
|
+
unit: string;
|
|
35
|
+
sort: number;
|
|
36
|
+
subtitle: string;
|
|
37
|
+
minimum_markup_price: string;
|
|
38
|
+
is_bundle: number;
|
|
39
|
+
description: string;
|
|
40
|
+
open_sold_weight: number;
|
|
41
|
+
unit_value: number;
|
|
42
|
+
is_variant: number;
|
|
43
|
+
variant_count: number;
|
|
44
|
+
add_time: {
|
|
45
|
+
unit_duration: number;
|
|
46
|
+
min_add_time: number;
|
|
47
|
+
max_add_time: number;
|
|
48
|
+
calculate_type: string;
|
|
49
|
+
relation_product: {
|
|
50
|
+
type: string;
|
|
51
|
+
products: never[];
|
|
52
|
+
};
|
|
53
|
+
additional_time_options?: undefined;
|
|
54
|
+
};
|
|
55
|
+
shelf_product_datas: never[];
|
|
56
|
+
step_value: number;
|
|
57
|
+
min_num_unit: number;
|
|
58
|
+
is_charge_tax: number;
|
|
59
|
+
base_price: string;
|
|
60
|
+
variant: never[];
|
|
61
|
+
};
|
|
62
|
+
} | {
|
|
63
|
+
id: number;
|
|
64
|
+
title: string;
|
|
65
|
+
price: number;
|
|
66
|
+
minMinutes: number;
|
|
67
|
+
maxMinutes: number;
|
|
68
|
+
unitMinutes: number;
|
|
69
|
+
unlimited: boolean;
|
|
70
|
+
_originalProduct: {
|
|
71
|
+
id: number;
|
|
72
|
+
extension_id: number;
|
|
73
|
+
extension_type: string;
|
|
74
|
+
shop_id: number;
|
|
75
|
+
title: string;
|
|
76
|
+
slug: string;
|
|
77
|
+
status: string;
|
|
78
|
+
stock_quantity: number;
|
|
79
|
+
sales_quantity: number;
|
|
80
|
+
sum_stock: number;
|
|
81
|
+
price: string;
|
|
82
|
+
original_price: string;
|
|
83
|
+
cost_price: string;
|
|
84
|
+
cover: string;
|
|
85
|
+
channel_application: string[];
|
|
86
|
+
is_track: number;
|
|
87
|
+
over_sold: number;
|
|
88
|
+
is_gst: number;
|
|
89
|
+
code: string;
|
|
90
|
+
barcode: string;
|
|
91
|
+
is_delivery: number;
|
|
92
|
+
weight_unit: string;
|
|
93
|
+
weight_value: string;
|
|
94
|
+
type: string;
|
|
95
|
+
unit: string;
|
|
96
|
+
sort: number;
|
|
97
|
+
subtitle: string;
|
|
98
|
+
minimum_markup_price: string;
|
|
99
|
+
is_bundle: number;
|
|
100
|
+
description: string;
|
|
101
|
+
open_sold_weight: number;
|
|
102
|
+
unit_value: number;
|
|
103
|
+
is_variant: number;
|
|
104
|
+
variant_count: number;
|
|
105
|
+
add_time: {
|
|
106
|
+
additional_time_options: string;
|
|
107
|
+
unit_duration: number;
|
|
108
|
+
min_add_time: number;
|
|
109
|
+
max_add_time: number;
|
|
110
|
+
calculate_type: string;
|
|
111
|
+
relation_product: {
|
|
112
|
+
type: string;
|
|
113
|
+
products: never[];
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
shelf_product_datas: never[];
|
|
117
|
+
step_value: number;
|
|
118
|
+
min_num_unit: number;
|
|
119
|
+
is_charge_tax: number;
|
|
120
|
+
base_price: string;
|
|
121
|
+
variant: never[];
|
|
122
|
+
};
|
|
123
|
+
})[];
|