@pisell/pisellos 0.0.569 → 0.10.2
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/core/index.js +10 -6
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -3
- package/dist/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/model/strategy/adapter/walletPass/evaluator.js +7 -5
- package/dist/model/strategy/adapter/walletPass/example.js +26 -3
- package/dist/model/strategy/adapter/walletPass/index.js +5 -5
- package/dist/model/strategy/adapter/walletPass/type.d.ts +0 -3
- package/dist/model/strategy/adapter/walletPass/utils.d.ts +0 -26
- package/dist/model/strategy/adapter/walletPass/utils.js +17 -92
- package/dist/model/strategy/strategy-example.js +19 -5
- package/dist/modules/BaseModule.d.ts +1 -1
- package/dist/modules/BaseModule.js +8 -10
- package/dist/modules/Cart/index.js +3 -0
- package/dist/modules/Cart/utils/cartProduct.js +1 -0
- package/dist/modules/Cart/utils/cartResource.js +0 -2
- package/dist/modules/Cart/utils/changePrice.js +9 -16
- package/dist/modules/Date/index.js +5 -1
- package/dist/modules/Discount/index.d.ts +0 -1
- package/dist/modules/Discount/index.js +7 -22
- package/dist/modules/Discount/types.d.ts +0 -1
- package/dist/modules/OpenData/index.js +2 -0
- package/dist/modules/Order/index.js +70 -40
- package/dist/modules/Payment/index.js +162 -97
- package/dist/modules/Payment/types.d.ts +4 -8
- package/dist/modules/Payment/walletpass.d.ts +0 -2
- package/dist/modules/Payment/walletpass.js +5 -4
- package/dist/modules/ProductList/index.d.ts +1 -1
- package/dist/modules/ProductList/index.js +3 -12
- package/dist/modules/ProductList/types.d.ts +0 -1
- package/dist/modules/Rules/index.js +126 -427
- package/dist/modules/SalesSummary/utils.js +1 -2
- package/dist/modules/Schedule/getDateIsInSchedule.js +0 -5
- package/dist/modules/Schedule/index.js +1 -0
- package/dist/modules/Schedule/utils.js +1 -0
- package/dist/modules/Step/index.js +1 -0
- package/dist/modules/Summary/utils.js +22 -43
- package/dist/plugins/request.js +4 -1
- package/dist/plugins/window.js +6 -2
- package/dist/server/index.js +129 -97
- package/dist/server/modules/menu/index.js +41 -32
- package/dist/server/modules/order/index.js +4 -2
- package/dist/server/modules/products/index.js +42 -24
- package/dist/server/modules/quotation/index.js +38 -29
- package/dist/server/modules/resource/index.js +4 -3
- package/dist/server/modules/schedule/index.js +35 -27
- package/dist/server/utils/product.js +1 -0
- package/dist/solution/BaseSales/index.js +41 -38
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingByStep/index.js +60 -11
- package/dist/solution/BookingByStep/utils/capacity.js +11 -1
- package/dist/solution/BookingByStep/utils/resources.js +3 -1
- package/dist/solution/BookingByStep/utils/timeslots.js +43 -2
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.js +2 -0
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +7 -6
- package/dist/solution/BookingTicket/utils/scan/handleScan.js +31 -25
- package/dist/solution/BookingTicket/utils/scan/index.js +10 -6
- package/dist/solution/BuyTickets/index.js +12 -9
- package/dist/solution/Checkout/index.js +252 -177
- package/dist/solution/Checkout/utils/index.js +16 -4
- package/dist/solution/RegisterAndLogin/index.js +76 -30
- package/dist/solution/ScanOrder/index.js +60 -50
- package/dist/solution/ShopDiscount/index.js +14 -15
- package/dist/solution/ShopDiscount/types.d.ts +4 -5
- package/dist/solution/ShopDiscount/utils.d.ts +0 -9
- package/dist/solution/ShopDiscount/utils.js +0 -9
- package/dist/solution/VenueBooking/index.d.ts +3 -31
- package/dist/solution/VenueBooking/index.js +496 -651
- package/dist/solution/VenueBooking/types.d.ts +1 -3
- package/dist/solution/VenueBooking/types.js +0 -1
- package/dist/solution/VenueBooking/utils/dateSummary.d.ts +2 -2
- package/dist/solution/VenueBooking/utils/dateSummary.js +25 -12
- package/dist/solution/VenueBooking/utils/timeSlot.d.ts +0 -2
- package/dist/solution/VenueBooking/utils/timeSlot.js +4 -9
- package/dist/types/index.d.ts +1 -1
- package/dist/utils/task.js +18 -15
- package/dist/utils/watch.js +1 -0
- package/lib/apis/picoding.js +0 -2
- package/lib/core/index.js +132 -130
- package/lib/effects/index.js +57 -46
- package/lib/index.d.ts +0 -1
- package/lib/index.js +50 -92
- package/lib/model/index.js +21 -14
- package/lib/model/strategy/adapter/dataVariant/adapter.js +50 -38
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +236 -162
- package/lib/model/strategy/adapter/dataVariant/examples.js +237 -229
- package/lib/model/strategy/adapter/dataVariant/index.js +34 -39
- package/lib/model/strategy/adapter/dataVariant/type.js +28 -57
- package/lib/model/strategy/adapter/index.js +64 -100
- package/lib/model/strategy/adapter/itemRule/adapter.js +144 -156
- package/lib/model/strategy/adapter/itemRule/evaluator.js +48 -36
- package/lib/model/strategy/adapter/itemRule/examples.js +225 -295
- package/lib/model/strategy/adapter/itemRule/index.js +57 -83
- package/lib/model/strategy/adapter/itemRule/type.js +36 -97
- package/lib/model/strategy/adapter/promotion/adapter.js +63 -84
- package/lib/model/strategy/adapter/promotion/evaluator.js +231 -381
- package/lib/model/strategy/adapter/promotion/examples.js +159 -139
- package/lib/model/strategy/adapter/promotion/index.js +49 -1
- package/lib/model/strategy/adapter/promotion/type.js +35 -199
- package/lib/model/strategy/adapter/type.js +16 -4
- package/lib/model/strategy/adapter/walletPass/evaluator.js +152 -180
- package/lib/model/strategy/adapter/walletPass/example.js +190 -217
- package/lib/model/strategy/adapter/walletPass/index.js +51 -75
- package/lib/model/strategy/adapter/walletPass/locales.js +58 -36
- package/lib/model/strategy/adapter/walletPass/type.d.ts +0 -3
- package/lib/model/strategy/adapter/walletPass/type.js +16 -4
- package/lib/model/strategy/adapter/walletPass/utils.d.ts +0 -26
- package/lib/model/strategy/adapter/walletPass/utils.js +383 -678
- package/lib/model/strategy/engine.js +168 -270
- package/lib/model/strategy/index.js +34 -49
- package/lib/model/strategy/strategy-example.js +239 -243
- package/lib/model/strategy/type.js +40 -100
- package/lib/modules/Account/index.js +53 -39
- package/lib/modules/Account/types.js +33 -20
- package/lib/modules/AccountList/index.js +154 -116
- package/lib/modules/AccountList/types.js +31 -30
- package/lib/modules/AccountList/utils.js +30 -18
- package/lib/modules/BaseModule.d.ts +1 -1
- package/lib/modules/BaseModule.js +46 -25
- package/lib/modules/BookingContext/index.js +136 -158
- package/lib/modules/BookingContext/types.js +32 -46
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +143 -131
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +82 -75
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +150 -170
- package/lib/modules/BookingContext/utils/flexible.js +55 -38
- package/lib/modules/BookingContext/utils/formatResourceList.js +34 -19
- package/lib/modules/BookingContext/utils/index.js +41 -124
- package/lib/modules/BookingContext/utils/noResource.js +70 -58
- package/lib/modules/BookingContext/utils/orderLineDisplay.js +41 -14
- package/lib/modules/BookingContext/utils/productExtend.js +155 -202
- package/lib/modules/BookingContext/utils/resourceErrors.js +53 -53
- package/lib/modules/BookingContext/utils/resourceSelection.js +41 -19
- package/lib/modules/BookingContext/utils/resources.js +167 -209
- package/lib/modules/BookingContext/utils/serviceTimes.js +116 -115
- package/lib/modules/BookingContext/utils/timeSlices.js +80 -70
- package/lib/modules/Cart/index.js +124 -170
- package/lib/modules/Cart/types.js +51 -46
- package/lib/modules/Cart/utils/cartAccount.js +39 -40
- package/lib/modules/Cart/utils/cartDate.js +61 -56
- package/lib/modules/Cart/utils/cartDiscount.js +33 -28
- package/lib/modules/Cart/utils/cartNote.js +32 -27
- package/lib/modules/Cart/utils/cartProduct.js +251 -321
- package/lib/modules/Cart/utils/cartRelationForms.js +35 -29
- package/lib/modules/Cart/utils/cartResource.js +78 -72
- package/lib/modules/Cart/utils/changePrice.js +50 -28
- package/lib/modules/Cart/utils/index.js +48 -106
- package/lib/modules/Customer/constants.js +34 -13
- package/lib/modules/Customer/index.js +169 -232
- package/lib/modules/Customer/types.js +35 -38
- package/lib/modules/Date/index.js +115 -116
- package/lib/modules/Date/types.js +28 -16
- package/lib/modules/Date/utils.js +123 -174
- package/lib/modules/Discount/index.d.ts +0 -1
- package/lib/modules/Discount/index.js +128 -130
- package/lib/modules/Discount/types.d.ts +0 -1
- package/lib/modules/Discount/types.js +31 -9
- package/lib/modules/Guests/index.js +56 -30
- package/lib/modules/Guests/types.js +33 -23
- package/lib/modules/Holder/index.js +189 -209
- package/lib/modules/Holder/types.js +16 -4
- package/lib/modules/Holder/utils.js +49 -20
- package/lib/modules/OpenData/index.js +76 -69
- package/lib/modules/OpenData/types.js +16 -4
- package/lib/modules/OpenData/utils.js +78 -44
- package/lib/modules/Order/index.js +1909 -1572
- package/lib/modules/Order/types.js +35 -78
- package/lib/modules/Order/utils/bundleDiscountHydration.js +74 -41
- package/lib/modules/Order/utils/manualProductDiscount.js +123 -124
- package/lib/modules/Order/utils/orderCollectionIdentity.js +210 -148
- package/lib/modules/Order/utils.js +634 -799
- package/lib/modules/Payment/cash.js +33 -20
- package/lib/modules/Payment/cashRecommendationAlgorithm.js +76 -145
- package/lib/modules/Payment/eftpos.js +30 -16
- package/lib/modules/Payment/index.js +378 -518
- package/lib/modules/Payment/mx51.js +0 -1
- package/lib/modules/Payment/types.d.ts +4 -8
- package/lib/modules/Payment/types.js +107 -216
- package/lib/modules/Payment/utils.js +48 -51
- package/lib/modules/Payment/walletpass.d.ts +0 -2
- package/lib/modules/Payment/walletpass.js +211 -226
- package/lib/modules/Product/index.js +46 -51
- package/lib/modules/Product/types.js +16 -4
- package/lib/modules/Product/utils.js +33 -32
- package/lib/modules/ProductList/index.d.ts +1 -1
- package/lib/modules/ProductList/index.js +117 -117
- package/lib/modules/ProductList/types.d.ts +0 -1
- package/lib/modules/ProductList/types.js +31 -9
- package/lib/modules/Quotation/index.js +100 -66
- package/lib/modules/Quotation/types.js +16 -4
- package/lib/modules/Resource/index.js +59 -27
- package/lib/modules/Resource/types.js +32 -22
- package/lib/modules/Resource/utils.js +38 -30
- package/lib/modules/ResourcePlanner/index.js +61 -60
- package/lib/modules/ResourcePlanner/planner.js +384 -346
- package/lib/modules/ResourcePlanner/types.js +16 -4
- package/lib/modules/Rules/index.js +903 -1475
- package/lib/modules/Rules/types.js +40 -17
- package/lib/modules/SalesSummary/index.js +90 -85
- package/lib/modules/SalesSummary/types.js +16 -4
- package/lib/modules/SalesSummary/utils.js +427 -351
- package/lib/modules/ScanOrderLogger/index.js +79 -59
- package/lib/modules/ScanOrderLogger/providers/feishu.js +78 -54
- package/lib/modules/ScanOrderLogger/providers/grafana.js +36 -13
- package/lib/modules/ScanOrderLogger/types.js +16 -4
- package/lib/modules/Schedule/getDateIsInSchedule.js +163 -339
- package/lib/modules/Schedule/index.js +114 -100
- package/lib/modules/Schedule/type.js +16 -4
- package/lib/modules/Schedule/types.js +16 -4
- package/lib/modules/Schedule/utils.js +291 -433
- package/lib/modules/Step/index.js +52 -40
- package/lib/modules/Step/tyeps.js +16 -4
- package/lib/modules/Summary/index.js +71 -66
- package/lib/modules/Summary/types.js +16 -4
- package/lib/modules/Summary/utils.js +418 -791
- package/lib/modules/SurchargeList/index.js +60 -46
- package/lib/modules/SurchargeList/types.js +16 -4
- package/lib/modules/index.js +63 -245
- package/lib/plugins/app.js +16 -4
- package/lib/plugins/index.js +25 -36
- package/lib/plugins/request.js +126 -137
- package/lib/plugins/shopStore.js +16 -4
- package/lib/plugins/user.js +16 -4
- package/lib/plugins/window.js +179 -171
- package/lib/server/index.js +2337 -2675
- package/lib/server/modules/floor-plan/index.js +123 -102
- package/lib/server/modules/floor-plan/types.js +30 -15
- package/lib/server/modules/index.js +68 -106
- package/lib/server/modules/menu/index.js +122 -146
- package/lib/server/modules/menu/types.js +31 -18
- package/lib/server/modules/order/index.js +642 -567
- package/lib/server/modules/order/types.js +32 -117
- package/lib/server/modules/order/utils/filterBookings.js +194 -219
- package/lib/server/modules/order/utils/filterOrders.js +92 -118
- package/lib/server/modules/payment/index.js +83 -59
- package/lib/server/modules/payment/types.js +16 -4
- package/lib/server/modules/products/index.js +459 -575
- package/lib/server/modules/products/types.js +34 -44
- package/lib/server/modules/quotation/index.js +172 -137
- package/lib/server/modules/quotation/types.js +31 -21
- package/lib/server/modules/resource/index.js +184 -213
- package/lib/server/modules/resource/types.js +33 -42
- package/lib/server/modules/schedule/index.js +123 -135
- package/lib/server/modules/schedule/types.js +21 -14
- package/lib/server/modules/schedule/utils.js +163 -334
- package/lib/server/types.js +16 -4
- package/lib/server/utils/index.js +23 -25
- package/lib/server/utils/product.js +139 -196
- package/lib/server/utils/schedule.js +41 -34
- package/lib/server/utils/small-ticket.js +456 -478
- package/lib/server/utils/time.js +49 -40
- package/lib/solution/BaseSales/index.js +1016 -850
- package/lib/solution/BaseSales/types.js +37 -41
- package/lib/solution/BaseSales/utils/cartPromotion.js +460 -611
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +105 -85
- package/lib/solution/BaseSales/utils/quotationPrice.js +114 -56
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +143 -102
- package/lib/solution/BaseSales/utils.js +140 -155
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingByStep/index.js +1340 -1530
- package/lib/solution/BookingByStep/types.js +99 -40
- package/lib/solution/BookingByStep/utils/capacity.js +160 -192
- package/lib/solution/BookingByStep/utils/products.js +52 -42
- package/lib/solution/BookingByStep/utils/resources.js +330 -527
- package/lib/solution/BookingByStep/utils/stock.js +44 -65
- package/lib/solution/BookingByStep/utils/timeslots.js +131 -129
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.js +459 -543
- package/lib/solution/BookingTicket/types.js +77 -99
- package/lib/solution/BookingTicket/utils/addProductDecision.js +184 -219
- package/lib/solution/BookingTicket/utils/addTimeAvailability.js +89 -58
- package/lib/solution/BookingTicket/utils/bookingStatus.js +78 -107
- package/lib/solution/BookingTicket/utils/cartView.js +94 -110
- package/lib/solution/BookingTicket/utils/exampleData.js +0 -185
- package/lib/solution/BookingTicket/utils/orderCustomer.js +41 -18
- package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.js +86 -219
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +93 -144
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +91 -79
- package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +41 -54
- package/lib/solution/BookingTicket/utils/scan/handleScan.js +81 -84
- package/lib/solution/BookingTicket/utils/scan/index.js +104 -98
- package/lib/solution/BookingTicket/utils/scan/scanCache.js +43 -90
- package/lib/solution/BookingTicket/utils/scan/scanProductValues.js +64 -52
- package/lib/solution/BookingTicket/utils/sessionCatalogStale.js +58 -56
- package/lib/solution/BuyTickets/index.js +70 -67
- package/lib/solution/BuyTickets/types.js +38 -22
- package/lib/solution/Checkout/index.js +1158 -1451
- package/lib/solution/Checkout/types.js +61 -91
- package/lib/solution/Checkout/utils/index.js +156 -228
- package/lib/solution/PlaceOrder/index.js +0 -55
- package/lib/solution/RegisterAndLogin/config.js +460 -493
- package/lib/solution/RegisterAndLogin/index.js +630 -633
- package/lib/solution/RegisterAndLogin/types.js +76 -189
- package/lib/solution/RegisterAndLogin/utils.js +125 -183
- package/lib/solution/Sales/index.js +320 -317
- package/lib/solution/Sales/types.js +33 -27
- package/lib/solution/ScanOrder/index.js +862 -831
- package/lib/solution/ScanOrder/types.js +34 -33
- package/lib/solution/ScanOrder/utils.js +371 -406
- package/lib/solution/ShopDiscount/index.js +233 -235
- package/lib/solution/ShopDiscount/types.d.ts +4 -5
- package/lib/solution/ShopDiscount/types.js +37 -15
- package/lib/solution/ShopDiscount/utils.d.ts +0 -9
- package/lib/solution/ShopDiscount/utils.js +172 -309
- package/lib/solution/UnifiedBookingSales/index.js +405 -379
- package/lib/solution/UnifiedBookingSales/types.js +31 -12
- package/lib/solution/VenueBooking/index.d.ts +3 -31
- package/lib/solution/VenueBooking/index.js +916 -967
- package/lib/solution/VenueBooking/types.d.ts +1 -3
- package/lib/solution/VenueBooking/types.js +39 -20
- package/lib/solution/VenueBooking/utils/dateSummary.d.ts +2 -2
- package/lib/solution/VenueBooking/utils/dateSummary.js +62 -25
- package/lib/solution/VenueBooking/utils/resource.js +54 -31
- package/lib/solution/VenueBooking/utils/slotMerge.js +107 -94
- package/lib/solution/VenueBooking/utils/timeSlot.d.ts +0 -2
- package/lib/solution/VenueBooking/utils/timeSlot.js +133 -138
- package/lib/solution/VenueBooking/utils.js +67 -130
- package/lib/solution/index.js +41 -124
- package/lib/store/createStore.js +29 -32
- package/lib/types/index.d.ts +1 -1
- package/lib/types/index.js +16 -4
- package/lib/utils/task.js +36 -36
- package/lib/utils/watch.js +47 -81
- package/package.json +2 -4
- package/dist/solution/VenueBooking/utils/smartPricing.d.ts +0 -70
- package/dist/solution/VenueBooking/utils/smartPricing.js +0 -233
- package/lib/solution/VenueBooking/utils/smartPricing.d.ts +0 -70
- package/lib/solution/VenueBooking/utils/smartPricing.js +0 -192
|
@@ -1,71 +1,78 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
collectPlannerResourceIds: true,
|
|
11
|
-
buildBookingFromAssignment: true,
|
|
12
|
-
buildBookingFromAssignments: true,
|
|
13
|
-
buildPlannerLineIdentity: true,
|
|
14
|
-
UnifiedBookingSalesImpl: true,
|
|
15
|
-
UnifiedBookingSales: true
|
|
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 });
|
|
16
10
|
};
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
var
|
|
26
|
-
var
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
get: function () {
|
|
36
|
-
return _types[key];
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
var _BookingTicket = require("../BookingTicket");
|
|
41
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
42
|
-
// import { BaseSalesImpl } from '../BaseSales';
|
|
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 __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
43
29
|
|
|
44
|
-
|
|
45
|
-
|
|
30
|
+
// src/solution/UnifiedBookingSales/index.ts
|
|
31
|
+
var UnifiedBookingSales_exports = {};
|
|
32
|
+
__export(UnifiedBookingSales_exports, {
|
|
33
|
+
UnifiedBookingSales: () => UnifiedBookingSales,
|
|
34
|
+
UnifiedBookingSalesImpl: () => UnifiedBookingSalesImpl,
|
|
35
|
+
buildBookingFromAssignment: () => buildBookingFromAssignment,
|
|
36
|
+
buildBookingFromAssignments: () => buildBookingFromAssignments,
|
|
37
|
+
buildPlannerDiscountResult: () => buildPlannerDiscountResult,
|
|
38
|
+
buildPlannerLineIdentity: () => buildPlannerLineIdentity,
|
|
39
|
+
buildPlannerResourcesFromV2: () => buildPlannerResourcesFromV2,
|
|
40
|
+
collectPlannerResourceIds: () => collectPlannerResourceIds,
|
|
41
|
+
normalizeProductForPlanner: () => normalizeProductForPlanner
|
|
42
|
+
});
|
|
43
|
+
module.exports = __toCommonJS(UnifiedBookingSales_exports);
|
|
44
|
+
var import_dayjs = __toESM(require("dayjs"));
|
|
45
|
+
var import_modules = require("../../modules");
|
|
46
|
+
var import_getDateIsInSchedule = require("../../modules/Schedule/getDateIsInSchedule");
|
|
47
|
+
var import_types = require("./types");
|
|
48
|
+
var import_BookingTicket = require("../BookingTicket");
|
|
49
|
+
__reExport(UnifiedBookingSales_exports, require("./types"), module.exports);
|
|
50
|
+
var OPEN_DATA_SECTION_CODES = ["sale", "reservation", "fulfillment", "menu", "workflow"];
|
|
51
|
+
var OPEN_DATA_CACHE_TTL = 5 * 60 * 1e3;
|
|
46
52
|
function pickLocalizedText(value) {
|
|
47
|
-
if (!value)
|
|
48
|
-
|
|
49
|
-
if (typeof value ===
|
|
53
|
+
if (!value)
|
|
54
|
+
return void 0;
|
|
55
|
+
if (typeof value === "string")
|
|
56
|
+
return value;
|
|
57
|
+
if (typeof value === "object") {
|
|
50
58
|
return value.en || value.zh || value.default || Object.values(value)[0];
|
|
51
59
|
}
|
|
52
60
|
return String(value);
|
|
53
61
|
}
|
|
54
62
|
function resolvePlannerDiscountId(discount) {
|
|
55
|
-
|
|
63
|
+
var _a;
|
|
64
|
+
return ((_a = discount.discount) == null ? void 0 : _a.resource_id) ?? discount.resource_id ?? discount.id;
|
|
56
65
|
}
|
|
57
66
|
function resolvePlannerDiscountTitle(discount) {
|
|
58
|
-
|
|
67
|
+
var _a;
|
|
68
|
+
return pickLocalizedText(
|
|
69
|
+
discount.name || discount.format_title || ((_a = discount.discount) == null ? void 0 : _a.title) || discount.title
|
|
70
|
+
);
|
|
59
71
|
}
|
|
60
72
|
function isPlannerDiscountAvailable(discount) {
|
|
61
|
-
|
|
73
|
+
var _a;
|
|
74
|
+
return discount.isDisabled !== true && discount.isAvailable !== false && ((_a = discount.config) == null ? void 0 : _a.isAvailable) !== false;
|
|
62
75
|
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Converts Rules/Order discount internals into a small UI-facing diagnostic. The result keeps
|
|
66
|
-
* candidate-card state separate from line-level applications: a selected card is not proof that
|
|
67
|
-
* it actually discounted a planner product.
|
|
68
|
-
*/
|
|
69
76
|
function buildPlannerDiscountResult(params) {
|
|
70
77
|
const {
|
|
71
78
|
customerId,
|
|
@@ -79,34 +86,39 @@ function buildPlannerDiscountResult(params) {
|
|
|
79
86
|
} = params;
|
|
80
87
|
const items = (discountList || []).reduce((result, discount) => {
|
|
81
88
|
const id = resolvePlannerDiscountId(discount);
|
|
82
|
-
if (id !==
|
|
89
|
+
if (id !== void 0 && id !== null) {
|
|
83
90
|
result.push({
|
|
84
91
|
id,
|
|
85
92
|
name: resolvePlannerDiscountTitle(discount),
|
|
86
93
|
type: discount.tag || discount.type,
|
|
87
94
|
available: isPlannerDiscountAvailable(discount),
|
|
88
95
|
selected: discount.isSelected === true,
|
|
89
|
-
savedAmount: Number(discount.savedAmount || 0) ||
|
|
96
|
+
savedAmount: Number(discount.savedAmount || 0) || void 0,
|
|
90
97
|
unavailableReason: discount.unavailableReason || discount.reason
|
|
91
98
|
});
|
|
92
99
|
}
|
|
93
100
|
return result;
|
|
94
101
|
}, []);
|
|
95
|
-
const discountNameById = new Map(items.map(item => [String(item.id), item.name]));
|
|
102
|
+
const discountNameById = new Map(items.map((item) => [String(item.id), item.name]));
|
|
96
103
|
const applications = [];
|
|
97
|
-
(products || []).forEach(product => {
|
|
98
|
-
const productDiscounts = [
|
|
99
|
-
|
|
104
|
+
(products || []).forEach((product) => {
|
|
105
|
+
const productDiscounts = [
|
|
106
|
+
...Array.isArray(product.discount_list) ? product.discount_list : [],
|
|
107
|
+
...Array.isArray(product.product_bundle) ? product.product_bundle.flatMap((bundle) => (bundle == null ? void 0 : bundle.discount_list) || []) : []
|
|
108
|
+
];
|
|
109
|
+
productDiscounts.forEach((discount) => {
|
|
110
|
+
var _a;
|
|
100
111
|
const type = discount.tag || discount.type;
|
|
101
|
-
if (![
|
|
112
|
+
if (!["good_pass", "discount_card", "product_discount_card"].includes(type))
|
|
113
|
+
return;
|
|
102
114
|
const discountId = resolvePlannerDiscountId(discount);
|
|
103
115
|
applications.push({
|
|
104
116
|
discountId,
|
|
105
|
-
discountName: discountId ===
|
|
117
|
+
discountName: discountId === void 0 ? void 0 : discountNameById.get(String(discountId)),
|
|
106
118
|
discountType: type,
|
|
107
119
|
productId: product.product_id ?? product.id,
|
|
108
120
|
productTitle: pickLocalizedText(product.title || product.name || product.product_title),
|
|
109
|
-
productUid: product.metadata
|
|
121
|
+
productUid: ((_a = product.metadata) == null ? void 0 : _a.unique_identification_number) || product.unique_identification_number,
|
|
110
122
|
amount: Number(discount.amount || 0)
|
|
111
123
|
});
|
|
112
124
|
});
|
|
@@ -115,134 +127,145 @@ function buildPlannerDiscountResult(params) {
|
|
|
115
127
|
status,
|
|
116
128
|
customerId,
|
|
117
129
|
preferredDiscountFound,
|
|
118
|
-
preferredDiscountApplied: preferredDiscountId ===
|
|
119
|
-
availableDiscounts: items.filter(item => item.available),
|
|
120
|
-
selectedDiscounts: items.filter(item => item.selected),
|
|
130
|
+
preferredDiscountApplied: preferredDiscountId === void 0 || preferredDiscountId === null ? void 0 : items.some((item) => String(item.id) === String(preferredDiscountId) && item.selected) && applications.some((item) => String(item.discountId) === String(preferredDiscountId)),
|
|
131
|
+
availableDiscounts: items.filter((item) => item.available),
|
|
132
|
+
selectedDiscounts: items.filter((item) => item.selected),
|
|
121
133
|
applications,
|
|
122
134
|
summaryBefore,
|
|
123
135
|
summaryAfter
|
|
124
136
|
};
|
|
125
137
|
}
|
|
126
138
|
function toNumberId(value) {
|
|
127
|
-
if (value ===
|
|
139
|
+
if (value === void 0 || value === null || value === "")
|
|
140
|
+
return void 0;
|
|
128
141
|
const parsed = Number(value);
|
|
129
142
|
return Number.isFinite(parsed) ? parsed : String(value);
|
|
130
143
|
}
|
|
131
|
-
|
|
132
|
-
/** Maps several legacy product shapes into the Planner's small, stable vocabulary. */
|
|
133
144
|
function resolveProductKind(product) {
|
|
134
|
-
|
|
135
|
-
if (
|
|
136
|
-
|
|
137
|
-
if (
|
|
138
|
-
|
|
145
|
+
var _a, _b, _c;
|
|
146
|
+
if (product.duration)
|
|
147
|
+
return "duration";
|
|
148
|
+
if (["session_product", "session_ticket"].includes(product.extension_type))
|
|
149
|
+
return "session";
|
|
150
|
+
if (((_a = product.cartDetailValue) == null ? void 0 : _a.session) || ((_c = (_b = product._extend) == null ? void 0 : _b.other) == null ? void 0 : _c.session))
|
|
151
|
+
return "session";
|
|
152
|
+
if (Array.isArray(product["schedule.ids"]) && product["schedule.ids"].length > 0)
|
|
153
|
+
return "session";
|
|
154
|
+
return "normal";
|
|
139
155
|
}
|
|
140
156
|
function normalizeSchedule(product) {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
end_at: session.end_at
|
|
146
|
-
}];
|
|
157
|
+
var _a, _b, _c;
|
|
158
|
+
const session = ((_a = product.cartDetailValue) == null ? void 0 : _a.session) || ((_c = (_b = product._extend) == null ? void 0 : _b.other) == null ? void 0 : _c.session) || product.session;
|
|
159
|
+
if ((session == null ? void 0 : session.start_at) && (session == null ? void 0 : session.end_at)) {
|
|
160
|
+
return [{ start_at: session.start_at, end_at: session.end_at }];
|
|
147
161
|
}
|
|
148
162
|
const schedules = product.schedules || product.schedule || product._schedule;
|
|
149
163
|
if (Array.isArray(schedules)) {
|
|
150
|
-
return schedules.map(item => ({
|
|
164
|
+
return schedules.map((item) => ({
|
|
151
165
|
start_at: item.start_at || item.start || item.start_time,
|
|
152
166
|
end_at: item.end_at || item.end || item.end_time
|
|
153
|
-
})).filter(item => item.start_at && item.end_at);
|
|
167
|
+
})).filter((item) => item.start_at && item.end_at);
|
|
154
168
|
}
|
|
155
169
|
return [];
|
|
156
170
|
}
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* Preserves form ownership while flattening default/optional resource ids.
|
|
160
|
-
* `formId` must survive because the order API requires it under booking.resources[].
|
|
161
|
-
*/
|
|
162
171
|
function normalizeRequirements(product) {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
+
var _a;
|
|
173
|
+
const resources = (_a = product.product_resource) == null ? void 0 : _a.resources;
|
|
174
|
+
if (!Array.isArray(resources))
|
|
175
|
+
return [];
|
|
176
|
+
return resources.filter((resource) => (resource == null ? void 0 : resource.status) !== 0).map((resource) => {
|
|
177
|
+
var _a2, _b;
|
|
178
|
+
return {
|
|
179
|
+
formId: toNumberId(resource.id),
|
|
180
|
+
resourceIds: [
|
|
181
|
+
...Array.isArray(resource.default_resource) ? resource.default_resource : [],
|
|
182
|
+
...Array.isArray(resource.optional_resource) ? resource.optional_resource : []
|
|
183
|
+
].map((id) => toNumberId(id)).filter((id) => id !== void 0),
|
|
184
|
+
resourceType: resource.type || ((_a2 = resource.select_type) == null ? void 0 : _a2.type) || "single",
|
|
185
|
+
required: resource.status === 1,
|
|
186
|
+
capacityRequired: Number(((_b = product.capacity) == null ? void 0 : _b.default) || product.capacity || 1) || 1
|
|
187
|
+
};
|
|
188
|
+
});
|
|
172
189
|
}
|
|
173
|
-
|
|
174
|
-
/** Converts a ProductList record into the pure input shape consumed by ResourcePlanner. */
|
|
175
190
|
function normalizeProductForPlanner(product) {
|
|
191
|
+
var _a, _b;
|
|
176
192
|
const raw = product;
|
|
177
193
|
const kind = resolveProductKind(raw);
|
|
178
194
|
return {
|
|
179
195
|
id: raw.id ?? raw.product_id,
|
|
180
196
|
title: pickLocalizedText(raw.title || raw.name || raw.product_title),
|
|
181
197
|
kind,
|
|
182
|
-
durationMinutes: Number(raw.duration
|
|
198
|
+
durationMinutes: Number(((_a = raw.duration) == null ? void 0 : _a.value) || raw.duration || raw.service_duration || 30) || 30,
|
|
183
199
|
schedule: normalizeSchedule(raw),
|
|
184
200
|
resourceRequirements: normalizeRequirements(raw),
|
|
185
|
-
capacityRequired: Number(raw.capacity
|
|
201
|
+
capacityRequired: Number(((_b = raw.capacity) == null ? void 0 : _b.default) || raw.capacity || 1) || 1,
|
|
186
202
|
quantity: Number(raw.num || raw.quantity || 1) || 1,
|
|
187
203
|
price: raw.price ?? raw.selling_price ?? raw.base_price,
|
|
188
204
|
raw
|
|
189
205
|
};
|
|
190
206
|
}
|
|
191
207
|
function normalizeResourceType(value) {
|
|
192
|
-
if (value ===
|
|
193
|
-
|
|
208
|
+
if (value === "multiple" || value === "capacity")
|
|
209
|
+
return value;
|
|
210
|
+
return "single";
|
|
194
211
|
}
|
|
195
212
|
function normalizeResource(raw) {
|
|
213
|
+
var _a, _b;
|
|
196
214
|
const id = raw.resourceId ?? raw.resource_id ?? raw.id;
|
|
197
|
-
if (id ===
|
|
198
|
-
|
|
215
|
+
if (id === void 0 || id === null || id === "")
|
|
216
|
+
return null;
|
|
217
|
+
const combinedResourceIds = (_a = raw.combined_resource) == null ? void 0 : _a.resource_ids;
|
|
199
218
|
return {
|
|
200
219
|
id,
|
|
201
220
|
formId: raw.formId ?? raw.form_id ?? raw.resource_form_id,
|
|
202
221
|
name: raw.resourceName || raw.main_field || raw.name || raw.title,
|
|
203
|
-
resourceType: normalizeResourceType(raw.type || raw.resourceType || raw.select_type
|
|
222
|
+
resourceType: normalizeResourceType(raw.type || raw.resourceType || ((_b = raw.select_type) == null ? void 0 : _b.type)),
|
|
204
223
|
capacity: Number(raw.capacity || raw.max_capacity || 1) || 1,
|
|
205
224
|
times: Array.isArray(raw.times) ? raw.times : [],
|
|
206
|
-
childResourceIds: Array.isArray(combinedResourceIds) ? combinedResourceIds :
|
|
225
|
+
childResourceIds: Array.isArray(combinedResourceIds) ? combinedResourceIds : void 0,
|
|
207
226
|
raw
|
|
208
227
|
};
|
|
209
228
|
}
|
|
210
229
|
function normalizeScheduleIds(raw) {
|
|
211
230
|
const ids = raw.schedule ?? raw.schedule_ids ?? raw.scheduleIds ?? [];
|
|
212
|
-
return (Array.isArray(ids) ? ids : [ids]).map(id => toNumberId(id)).filter(id => id !==
|
|
231
|
+
return (Array.isArray(ids) ? ids : [ids]).map((id) => toNumberId(id)).filter((id) => id !== void 0);
|
|
213
232
|
}
|
|
214
233
|
function collectRawScheduleIds(rawResources) {
|
|
215
|
-
const ids = new Map();
|
|
216
|
-
(rawResources || []).forEach(resource => {
|
|
217
|
-
normalizeScheduleIds(resource).forEach(id => {
|
|
234
|
+
const ids = /* @__PURE__ */ new Map();
|
|
235
|
+
(rawResources || []).forEach((resource) => {
|
|
236
|
+
normalizeScheduleIds(resource).forEach((id) => {
|
|
218
237
|
ids.set(String(id), id);
|
|
219
238
|
});
|
|
220
239
|
});
|
|
221
240
|
return Array.from(ids.values());
|
|
222
241
|
}
|
|
223
242
|
function scheduleListHasIds(scheduleList, scheduleIds) {
|
|
224
|
-
if (!scheduleIds.length)
|
|
225
|
-
|
|
226
|
-
|
|
243
|
+
if (!scheduleIds.length)
|
|
244
|
+
return true;
|
|
245
|
+
const existingIds = new Set((scheduleList || []).map((schedule) => String(schedule.id)));
|
|
246
|
+
return scheduleIds.every((id) => existingIds.has(String(id)));
|
|
227
247
|
}
|
|
228
248
|
function dateRangeDays(dateRange) {
|
|
229
|
-
if (!dateRange
|
|
249
|
+
if (!(dateRange == null ? void 0 : dateRange.start) || !(dateRange == null ? void 0 : dateRange.end))
|
|
250
|
+
return [];
|
|
230
251
|
const dates = [];
|
|
231
|
-
let cursor = (0,
|
|
232
|
-
const end = (0,
|
|
233
|
-
if (!cursor.isValid() || !end.isValid() || end.isBefore(cursor,
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
cursor
|
|
252
|
+
let cursor = (0, import_dayjs.default)(dateRange.start);
|
|
253
|
+
const end = (0, import_dayjs.default)(dateRange.end);
|
|
254
|
+
if (!cursor.isValid() || !end.isValid() || end.isBefore(cursor, "day"))
|
|
255
|
+
return dates;
|
|
256
|
+
while (cursor.isSame(end, "day") || cursor.isBefore(end, "day")) {
|
|
257
|
+
dates.push(cursor.format("YYYY-MM-DD"));
|
|
258
|
+
cursor = cursor.add(1, "day");
|
|
237
259
|
}
|
|
238
260
|
return dates;
|
|
239
261
|
}
|
|
240
262
|
function normalizePlannerEvent(rawEvent, resourceId) {
|
|
241
263
|
const startAt = rawEvent.start_at ?? rawEvent.startAt ?? rawEvent.start_time ?? rawEvent.startTime;
|
|
242
264
|
const endAt = rawEvent.end_at ?? rawEvent.endAt ?? rawEvent.end_time ?? rawEvent.endTime;
|
|
243
|
-
if (!startAt || !endAt)
|
|
265
|
+
if (!startAt || !endAt)
|
|
266
|
+
return null;
|
|
244
267
|
const rawSource = rawEvent.source;
|
|
245
|
-
const source = rawSource ===
|
|
268
|
+
const source = rawSource === "remote" || rawSource === "cart" || rawSource === "selection" ? rawSource : "remote";
|
|
246
269
|
return {
|
|
247
270
|
...rawEvent,
|
|
248
271
|
resourceId,
|
|
@@ -258,63 +281,59 @@ function normalizeResourceV2(raw) {
|
|
|
258
281
|
...raw,
|
|
259
282
|
times: []
|
|
260
283
|
});
|
|
261
|
-
if (!normalized)
|
|
284
|
+
if (!normalized)
|
|
285
|
+
return null;
|
|
262
286
|
return normalized;
|
|
263
287
|
}
|
|
264
288
|
function buildResourceWindowFallbackTimes(params) {
|
|
265
|
-
const {
|
|
266
|
-
raw,
|
|
267
|
-
dates,
|
|
268
|
-
scheduleIds
|
|
269
|
-
} = params;
|
|
289
|
+
const { raw, dates, scheduleIds } = params;
|
|
270
290
|
const rawStart = raw.start_time || raw.start_at || raw.startTime;
|
|
271
291
|
const rawEnd = raw.end_time || raw.end_at || raw.endTime;
|
|
272
|
-
if (!rawStart || !rawEnd)
|
|
273
|
-
|
|
274
|
-
const
|
|
292
|
+
if (!rawStart || !rawEnd)
|
|
293
|
+
return [];
|
|
294
|
+
const startBoundary = (0, import_dayjs.default)(rawStart);
|
|
295
|
+
const endBoundary = (0, import_dayjs.default)(rawEnd);
|
|
275
296
|
if (!startBoundary.isValid() || !endBoundary.isValid() || !endBoundary.isAfter(startBoundary)) {
|
|
276
297
|
return [];
|
|
277
298
|
}
|
|
278
|
-
return dates.flatMap(date => {
|
|
279
|
-
const dayStart = (0,
|
|
280
|
-
const dayEnd = (0,
|
|
299
|
+
return dates.flatMap((date) => {
|
|
300
|
+
const dayStart = (0, import_dayjs.default)(`${date} 00:00:00`);
|
|
301
|
+
const dayEnd = (0, import_dayjs.default)(`${date} 23:59:59`);
|
|
281
302
|
const start = startBoundary.isAfter(dayStart) ? startBoundary : dayStart;
|
|
282
303
|
const end = endBoundary.isBefore(dayEnd) ? endBoundary : dayEnd;
|
|
283
|
-
if (!end.isAfter(start))
|
|
304
|
+
if (!end.isAfter(start))
|
|
305
|
+
return [];
|
|
284
306
|
return [{
|
|
285
|
-
start_at: start.format(
|
|
286
|
-
end_at: end.format(
|
|
307
|
+
start_at: start.format("YYYY-MM-DD HH:mm:ss"),
|
|
308
|
+
end_at: end.format("YYYY-MM-DD HH:mm:ss"),
|
|
287
309
|
schedule_ids: scheduleIds,
|
|
288
|
-
source:
|
|
310
|
+
source: "resource_window_fallback"
|
|
289
311
|
}];
|
|
290
312
|
});
|
|
291
313
|
}
|
|
292
|
-
|
|
293
|
-
/**
|
|
294
|
-
* Materializes resource work windows locally from v2's schedule ids, then keeps its flat
|
|
295
|
-
* event_list as planner events. This deliberately avoids the older API's times -> event_list
|
|
296
|
-
* response nesting and lets one resource response serve any requested date range.
|
|
297
|
-
*/
|
|
298
314
|
function buildPlannerResourcesFromV2(params) {
|
|
299
|
-
const scheduleMap = new Map(
|
|
315
|
+
const scheduleMap = new Map(
|
|
316
|
+
(params.scheduleList || []).map((schedule) => [String(schedule.id), schedule])
|
|
317
|
+
);
|
|
300
318
|
const dates = dateRangeDays(params.dateRange);
|
|
301
319
|
const externalEvents = [];
|
|
302
|
-
const resources = (params.rawResources || []).map(raw => {
|
|
320
|
+
const resources = (params.rawResources || []).map((raw) => {
|
|
303
321
|
const resource = normalizeResourceV2(raw);
|
|
304
|
-
if (!resource)
|
|
322
|
+
if (!resource)
|
|
323
|
+
return null;
|
|
305
324
|
const scheduleIds = normalizeScheduleIds(raw);
|
|
306
|
-
const schedules = scheduleIds.map(id => scheduleMap.get(String(id))).filter(Boolean);
|
|
307
|
-
const matchedScheduleIds = new Set(schedules.map(schedule => String(schedule.id)));
|
|
308
|
-
const missingScheduleIds = scheduleIds.filter(id => !matchedScheduleIds.has(String(id)));
|
|
325
|
+
const schedules = scheduleIds.map((id) => scheduleMap.get(String(id))).filter(Boolean);
|
|
326
|
+
const matchedScheduleIds = new Set(schedules.map((schedule) => String(schedule.id)));
|
|
327
|
+
const missingScheduleIds = scheduleIds.filter((id) => !matchedScheduleIds.has(String(id)));
|
|
309
328
|
if (missingScheduleIds.length > 0) {
|
|
310
329
|
resource.raw = {
|
|
311
|
-
...
|
|
330
|
+
...resource.raw || raw,
|
|
312
331
|
_plannerMissingScheduleIds: missingScheduleIds
|
|
313
332
|
};
|
|
314
333
|
}
|
|
315
|
-
resource.times = dates.flatMap(date => (0,
|
|
316
|
-
start_at: (0,
|
|
317
|
-
end_at: (0,
|
|
334
|
+
resource.times = dates.flatMap((date) => (0, import_getDateIsInSchedule.getScheduleStartEndTimePoints)(date, schedules).map((slot) => ({
|
|
335
|
+
start_at: (0, import_dayjs.default)(slot.start_at).format("YYYY-MM-DD HH:mm:ss"),
|
|
336
|
+
end_at: (0, import_dayjs.default)(slot.end_at).format("YYYY-MM-DD HH:mm:ss"),
|
|
318
337
|
schedule_ids: scheduleIds
|
|
319
338
|
})));
|
|
320
339
|
if (resource.times.length === 0 && missingScheduleIds.length > 0) {
|
|
@@ -325,80 +344,72 @@ function buildPlannerResourcesFromV2(params) {
|
|
|
325
344
|
});
|
|
326
345
|
}
|
|
327
346
|
const eventList = Array.isArray(raw.event_list) ? raw.event_list : [];
|
|
328
|
-
eventList.forEach(event => {
|
|
347
|
+
eventList.forEach((event) => {
|
|
329
348
|
const normalizedEvent = normalizePlannerEvent(event, resource.id);
|
|
330
|
-
if (normalizedEvent)
|
|
349
|
+
if (normalizedEvent)
|
|
350
|
+
externalEvents.push(normalizedEvent);
|
|
331
351
|
});
|
|
332
352
|
return resource;
|
|
333
|
-
}).filter(resource => resource !== null);
|
|
353
|
+
}).filter((resource) => resource !== null);
|
|
334
354
|
return {
|
|
335
355
|
resources,
|
|
336
356
|
externalEvents
|
|
337
357
|
};
|
|
338
358
|
}
|
|
339
|
-
|
|
340
|
-
/** Combines URL-locked resources with every resource referenced by the selected products. */
|
|
341
359
|
function collectPlannerResourceIds(products, explicitResourceIds = []) {
|
|
342
|
-
const ids = new Map();
|
|
343
|
-
const add = value => {
|
|
344
|
-
if (value ===
|
|
360
|
+
const ids = /* @__PURE__ */ new Map();
|
|
361
|
+
const add = (value) => {
|
|
362
|
+
if (value === void 0 || value === null || value === "")
|
|
363
|
+
return;
|
|
345
364
|
ids.set(String(value), value);
|
|
346
365
|
};
|
|
347
366
|
explicitResourceIds.forEach(add);
|
|
348
|
-
products.forEach(product => {
|
|
349
|
-
|
|
350
|
-
|
|
367
|
+
products.forEach((product) => {
|
|
368
|
+
var _a;
|
|
369
|
+
(_a = product.resourceRequirements) == null ? void 0 : _a.forEach((requirement) => {
|
|
370
|
+
var _a2;
|
|
371
|
+
(_a2 = requirement.resourceIds) == null ? void 0 : _a2.forEach(add);
|
|
351
372
|
});
|
|
352
373
|
});
|
|
353
374
|
return Array.from(ids.values());
|
|
354
375
|
}
|
|
355
376
|
function samePlannerId(left, right) {
|
|
356
|
-
if (left ===
|
|
377
|
+
if (left === void 0 || right === void 0)
|
|
378
|
+
return false;
|
|
357
379
|
return String(left) === String(right);
|
|
358
380
|
}
|
|
359
381
|
function findRequirementForAssignment(product, assignment) {
|
|
360
382
|
const requirements = product.resourceRequirements || [];
|
|
361
|
-
return requirements.find(requirement => (requirement.resourceIds || []).some(id => samePlannerId(id, assignment.resourceId))) || (requirements.length === 1 ? requirements[0] :
|
|
383
|
+
return requirements.find((requirement) => (requirement.resourceIds || []).some((id) => samePlannerId(id, assignment.resourceId))) || (requirements.length === 1 ? requirements[0] : void 0) || requirements.find((requirement) => requirement.required) || requirements[0];
|
|
362
384
|
}
|
|
363
|
-
|
|
364
|
-
/** Convenience wrapper for the usual one-resource booking case. */
|
|
365
385
|
function buildBookingFromAssignment(params) {
|
|
366
386
|
return buildBookingFromAssignments({
|
|
367
387
|
assignments: [params.assignment],
|
|
368
388
|
product: params.product
|
|
369
389
|
});
|
|
370
390
|
}
|
|
371
|
-
|
|
372
|
-
/**
|
|
373
|
-
* Converts all resources needed by one product/time interval into the one booking expected by
|
|
374
|
-
* OrderModule. Callers must group assignments before this function so a multi-form booking does
|
|
375
|
-
* not become several competing bookings.
|
|
376
|
-
*/
|
|
377
391
|
function buildBookingFromAssignments(params) {
|
|
378
|
-
const {
|
|
379
|
-
assignments,
|
|
380
|
-
product
|
|
381
|
-
} = params;
|
|
392
|
+
const { assignments, product } = params;
|
|
382
393
|
const firstAssignment = assignments[0];
|
|
383
|
-
const start = (0,
|
|
384
|
-
const end = (0,
|
|
394
|
+
const start = (0, import_dayjs.default)(firstAssignment.start_at);
|
|
395
|
+
const end = (0, import_dayjs.default)(firstAssignment.end_at);
|
|
385
396
|
return {
|
|
386
|
-
start_date: start.format(
|
|
387
|
-
start_time: start.format(
|
|
388
|
-
end_date: end.format(
|
|
389
|
-
end_time: end.format(
|
|
390
|
-
duration: Math.max(1, end.diff(start,
|
|
391
|
-
like_status:
|
|
397
|
+
start_date: start.format("YYYY-MM-DD"),
|
|
398
|
+
start_time: start.format("HH:mm"),
|
|
399
|
+
end_date: end.format("YYYY-MM-DD"),
|
|
400
|
+
end_time: end.format("HH:mm"),
|
|
401
|
+
duration: Math.max(1, end.diff(start, "minute")),
|
|
402
|
+
like_status: "common",
|
|
392
403
|
schedule_id: 0,
|
|
393
|
-
resources: assignments.map(assignment => {
|
|
404
|
+
resources: assignments.map((assignment) => {
|
|
394
405
|
const requirement = findRequirementForAssignment(product, assignment);
|
|
395
406
|
return {
|
|
396
407
|
id: assignment.resourceId,
|
|
397
408
|
resource_id: assignment.resourceId,
|
|
398
|
-
form_id: requirement
|
|
399
|
-
relation_type:
|
|
409
|
+
form_id: requirement == null ? void 0 : requirement.formId,
|
|
410
|
+
relation_type: "form",
|
|
400
411
|
relation_id: assignment.resourceId,
|
|
401
|
-
like_status:
|
|
412
|
+
like_status: "common",
|
|
402
413
|
capacity: assignment.capacityRequired || product.capacityRequired || 1
|
|
403
414
|
};
|
|
404
415
|
}),
|
|
@@ -409,66 +420,70 @@ function buildBookingFromAssignments(params) {
|
|
|
409
420
|
};
|
|
410
421
|
}
|
|
411
422
|
function buildAssignmentGroupKey(assignment) {
|
|
412
|
-
return [
|
|
423
|
+
return [
|
|
424
|
+
assignment.productId,
|
|
425
|
+
assignment.start_at,
|
|
426
|
+
assignment.end_at
|
|
427
|
+
].join(":");
|
|
413
428
|
}
|
|
414
|
-
|
|
415
|
-
/** Builds the exact identity BaseSales needs to remove only this solution's order lines. */
|
|
416
429
|
function buildPlannerLineIdentity(product) {
|
|
430
|
+
var _a;
|
|
417
431
|
return {
|
|
418
432
|
product_id: product.product_id,
|
|
419
433
|
product_variant_id: product.product_variant_id ?? 0,
|
|
420
|
-
unique_identification_number: product.metadata
|
|
434
|
+
unique_identification_number: ((_a = product.metadata) == null ? void 0 : _a.unique_identification_number) || product.unique_identification_number,
|
|
421
435
|
product_sku: product.product_sku,
|
|
422
436
|
product_bundle: product.product_bundle
|
|
423
437
|
};
|
|
424
438
|
}
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
439
|
+
var UnifiedBookingSalesImpl = class extends import_BookingTicket.BookingTicket {
|
|
440
|
+
constructor() {
|
|
441
|
+
super(...arguments);
|
|
442
|
+
this.defaultName = "unifiedBookingSales";
|
|
443
|
+
this.defaultVersion = "1.0.0";
|
|
444
|
+
this.store = {};
|
|
445
|
+
this.unifiedProductCatalog = [];
|
|
446
|
+
this.openDataTarget = null;
|
|
447
|
+
this.loadOpenDataInFlight = null;
|
|
448
|
+
this.loadOpenDataInFlightTarget = null;
|
|
449
|
+
}
|
|
434
450
|
/**
|
|
435
451
|
* Kiosk 不能把已收款订单留在本地等待重试:默认直接等待云端 checkout。
|
|
436
452
|
* 兼容仍需要 WebPOS 待同步模式的入口可显式传 checkoutSyncTaskEnabled: true。
|
|
437
453
|
*/
|
|
438
454
|
shouldUseCheckoutSyncTask() {
|
|
439
|
-
|
|
440
|
-
|
|
455
|
+
var _a;
|
|
456
|
+
const configured = (_a = this.otherParams) == null ? void 0 : _a.checkoutSyncTaskEnabled;
|
|
457
|
+
return typeof configured === "boolean" ? configured : false;
|
|
441
458
|
}
|
|
442
|
-
|
|
443
459
|
/** UnifiedBookingSales 的真实结账默认请求收据数据,供云端确认后再本地打印。 */
|
|
444
460
|
getDefaultCheckoutSmallTicketDataFlag() {
|
|
445
461
|
return 1;
|
|
446
462
|
}
|
|
447
463
|
getRegisteredModuleNames() {
|
|
448
|
-
return [...super.getRegisteredModuleNames(),
|
|
464
|
+
return [...super.getRegisteredModuleNames(), "resourcePlanner", "openData"];
|
|
449
465
|
}
|
|
450
466
|
createSubModule(moduleName) {
|
|
451
|
-
if (moduleName ===
|
|
452
|
-
return new
|
|
467
|
+
if (moduleName === "resourcePlanner") {
|
|
468
|
+
return new import_modules.ResourcePlannerModule(`${this.name}_resourcePlanner`);
|
|
453
469
|
}
|
|
454
|
-
if (moduleName ===
|
|
455
|
-
return new
|
|
470
|
+
if (moduleName === "openData") {
|
|
471
|
+
return new import_modules.OpenDataModule(`${this.name}_openData`);
|
|
456
472
|
}
|
|
457
473
|
return super.createSubModule(moduleName);
|
|
458
474
|
}
|
|
459
|
-
|
|
460
475
|
/**
|
|
461
476
|
* Loads OpenData without borrowing BookingTicket. Cache ownership is tied to the exact
|
|
462
477
|
* business/channel target so a reused solution instance cannot leak another entry's menus.
|
|
463
478
|
*/
|
|
464
479
|
async loadOpenData(params) {
|
|
465
480
|
if (!this.store.openData) {
|
|
466
|
-
throw new Error(
|
|
481
|
+
throw new Error("[UnifiedBookingSales] openData 模块未初始化");
|
|
467
482
|
}
|
|
468
|
-
const businessCode = String(params.businessCode ||
|
|
469
|
-
const channel = String(params.channel ||
|
|
483
|
+
const businessCode = String(params.businessCode || "").trim();
|
|
484
|
+
const channel = String(params.channel || "").trim();
|
|
470
485
|
if (!businessCode || !channel) {
|
|
471
|
-
throw new Error(
|
|
486
|
+
throw new Error("[UnifiedBookingSales] OpenData 需要 businessCode 与 channel");
|
|
472
487
|
}
|
|
473
488
|
const target = `${businessCode}+${channel}`;
|
|
474
489
|
const cachedData = this.store.openData.getOpenData();
|
|
@@ -485,7 +500,7 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
485
500
|
}
|
|
486
501
|
this.loadOpenDataInFlightTarget = target;
|
|
487
502
|
this.loadOpenDataInFlight = this.store.openData.fetchOpenData({
|
|
488
|
-
scope:
|
|
503
|
+
scope: "board",
|
|
489
504
|
target,
|
|
490
505
|
section_code: [...OPEN_DATA_SECTION_CODES]
|
|
491
506
|
});
|
|
@@ -502,19 +517,20 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
502
517
|
}
|
|
503
518
|
}
|
|
504
519
|
async getOpenData() {
|
|
505
|
-
|
|
520
|
+
var _a;
|
|
521
|
+
return ((_a = this.store.openData) == null ? void 0 : _a.getOpenData()) || null;
|
|
506
522
|
}
|
|
507
|
-
|
|
508
523
|
/**
|
|
509
524
|
* Loads the product catalog used by both UI and Planner. Schedule data is requested with each
|
|
510
525
|
* product because session products carry their fixed intervals there.
|
|
511
526
|
*/
|
|
512
527
|
async loadProducts(params = {}, options) {
|
|
513
|
-
if (!this.store.products)
|
|
514
|
-
|
|
515
|
-
const
|
|
528
|
+
if (!this.store.products)
|
|
529
|
+
throw new Error("[UnifiedBookingSales] products 模块未初始化");
|
|
530
|
+
const schedule_date = params.schedule_date || (0, import_dayjs.default)().format("YYYY-MM-DD");
|
|
531
|
+
const schedule_datetime = params.schedule_datetime || `${schedule_date} ${(0, import_dayjs.default)().format("HH:mm:ss")}`;
|
|
516
532
|
const result = await this.store.products.loadProducts({
|
|
517
|
-
with_count: [
|
|
533
|
+
with_count: ["bundleGroup", "optionGroup"],
|
|
518
534
|
with_schedule: 1,
|
|
519
535
|
...params,
|
|
520
536
|
schedule_date,
|
|
@@ -525,19 +541,19 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
525
541
|
await this.core.effects.emit(`${this.name}:onProductsLoaded`, result);
|
|
526
542
|
return result;
|
|
527
543
|
}
|
|
528
|
-
|
|
529
544
|
/** Date-first entry point. It delegates protocol details and cache ownership to ScheduleModule. */
|
|
530
545
|
async loadScheduleAvailableDate(params) {
|
|
531
|
-
if (!this.store.schedule)
|
|
546
|
+
if (!this.store.schedule)
|
|
547
|
+
throw new Error("[UnifiedBookingSales] schedule 模块未初始化");
|
|
532
548
|
return this.store.schedule.loadScheduleAvailableDate(params);
|
|
533
549
|
}
|
|
534
|
-
|
|
535
550
|
/**
|
|
536
551
|
* Implements the date-first product pool: the chosen date's product ids plus globally sellable
|
|
537
552
|
* other_product_ids. If a batch product query is unexpectedly empty, retry one id at a time so
|
|
538
553
|
* a partial backend incompatibility does not hide the entire date's catalog.
|
|
539
554
|
*/
|
|
540
555
|
async loadProductsByScheduleDate(params) {
|
|
556
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
541
557
|
const {
|
|
542
558
|
date,
|
|
543
559
|
custom_page_id,
|
|
@@ -545,10 +561,11 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
545
561
|
product_ids,
|
|
546
562
|
...productLoadParams
|
|
547
563
|
} = params;
|
|
548
|
-
if (!this.store.schedule)
|
|
549
|
-
|
|
550
|
-
const
|
|
551
|
-
const
|
|
564
|
+
if (!this.store.schedule)
|
|
565
|
+
throw new Error("[UnifiedBookingSales] schedule 模块未初始化");
|
|
566
|
+
const cachedDates = ((_b = (_a = this.store.schedule).getAvailabilityScheduleDateList) == null ? void 0 : _b.call(_a)) || [];
|
|
567
|
+
const hasCachedDate = cachedDates.some((item) => item.date === date);
|
|
568
|
+
const hasOtherProducts = (((_d = (_c = this.store.schedule).getOtherProductsIds) == null ? void 0 : _d.call(_c)) || []).length > 0;
|
|
552
569
|
if (!hasCachedDate && !hasOtherProducts) {
|
|
553
570
|
await this.loadScheduleAvailableDate({
|
|
554
571
|
startDate: date,
|
|
@@ -557,9 +574,12 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
557
574
|
channel
|
|
558
575
|
});
|
|
559
576
|
}
|
|
560
|
-
const scheduleDate = this.store.schedule.getAvailabilityScheduleDateList
|
|
561
|
-
const productIdFilter = product_ids
|
|
562
|
-
const availableProductIds = [
|
|
577
|
+
const scheduleDate = (_g = (_f = (_e = this.store.schedule).getAvailabilityScheduleDateList) == null ? void 0 : _f.call(_e)) == null ? void 0 : _g.find((item) => item.date === date);
|
|
578
|
+
const productIdFilter = (product_ids == null ? void 0 : product_ids.length) ? new Set(product_ids.map((id) => String(id))) : null;
|
|
579
|
+
const availableProductIds = [
|
|
580
|
+
...(scheduleDate == null ? void 0 : scheduleDate.product_ids) || [],
|
|
581
|
+
...((_i = (_h = this.store.schedule).getOtherProductsIds) == null ? void 0 : _i.call(_h)) || []
|
|
582
|
+
].filter((id, index, self) => self.indexOf(id) === index).filter((id) => !productIdFilter || productIdFilter.has(String(id)));
|
|
563
583
|
if (!availableProductIds.length) {
|
|
564
584
|
this.unifiedProductCatalog = [];
|
|
565
585
|
await this.core.effects.emit(`${this.name}:onProductsLoaded`, []);
|
|
@@ -570,7 +590,8 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
570
590
|
product_ids: availableProductIds,
|
|
571
591
|
schedule_date: date
|
|
572
592
|
});
|
|
573
|
-
if (products.length || availableProductIds.length <= 1)
|
|
593
|
+
if (products.length || availableProductIds.length <= 1)
|
|
594
|
+
return products;
|
|
574
595
|
const fallbackProducts = [];
|
|
575
596
|
for (const productId of availableProductIds) {
|
|
576
597
|
const result = await this.loadProducts({
|
|
@@ -578,9 +599,9 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
578
599
|
product_ids: [productId],
|
|
579
600
|
schedule_date: date
|
|
580
601
|
});
|
|
581
|
-
result.forEach(product => {
|
|
582
|
-
const id = product
|
|
583
|
-
if (!fallbackProducts.some(item => String(item
|
|
602
|
+
result.forEach((product) => {
|
|
603
|
+
const id = (product == null ? void 0 : product.id) ?? (product == null ? void 0 : product.product_id);
|
|
604
|
+
if (!fallbackProducts.some((item) => String((item == null ? void 0 : item.id) ?? (item == null ? void 0 : item.product_id)) === String(id))) {
|
|
584
605
|
fallbackProducts.push(product);
|
|
585
606
|
}
|
|
586
607
|
});
|
|
@@ -589,14 +610,10 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
589
610
|
await this.core.effects.emit(`${this.name}:onProductsLoaded`, fallbackProducts);
|
|
590
611
|
return fallbackProducts;
|
|
591
612
|
}
|
|
592
|
-
|
|
593
613
|
/** Returns a copy so UI consumers cannot accidentally mutate the solution's product cache. */
|
|
594
614
|
getProductCatalog() {
|
|
595
|
-
return {
|
|
596
|
-
products: [...this.unifiedProductCatalog]
|
|
597
|
-
};
|
|
615
|
+
return { products: [...this.unifiedProductCatalog] };
|
|
598
616
|
}
|
|
599
|
-
|
|
600
617
|
/**
|
|
601
618
|
* Read-only compatibility view for salesSdk skins. It reconnects a booking to its product but
|
|
602
619
|
* must not be used to mutate tempOrder; all writes go through BaseSales / planner APIs.
|
|
@@ -604,20 +621,21 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
604
621
|
getCart() {
|
|
605
622
|
const tempOrder = this.getTempOrder();
|
|
606
623
|
const salesDetail = this.getSalesOrder();
|
|
607
|
-
const items = tempOrder
|
|
608
|
-
const bookings = salesDetail
|
|
624
|
+
const items = (tempOrder == null ? void 0 : tempOrder.products) || [];
|
|
625
|
+
const bookings = (salesDetail == null ? void 0 : salesDetail.bookings) || (tempOrder == null ? void 0 : tempOrder.bookings) || [];
|
|
609
626
|
return {
|
|
610
627
|
items,
|
|
611
|
-
bookings: bookings.map(booking => {
|
|
612
|
-
const productUid = booking
|
|
613
|
-
const product = productUid ? items.find(item => {
|
|
614
|
-
|
|
615
|
-
|
|
628
|
+
bookings: bookings.map((booking) => {
|
|
629
|
+
const productUid = booking == null ? void 0 : booking.product_uid;
|
|
630
|
+
const product = productUid ? items.find((item) => {
|
|
631
|
+
var _a;
|
|
632
|
+
const uid = ((_a = item == null ? void 0 : item.metadata) == null ? void 0 : _a.unique_identification_number) || (item == null ? void 0 : item.unique_identification_number);
|
|
633
|
+
return String(uid || "") === String(productUid);
|
|
616
634
|
}) || null : null;
|
|
617
635
|
return {
|
|
618
636
|
...booking,
|
|
619
637
|
_extend: {
|
|
620
|
-
...(booking
|
|
638
|
+
...(booking == null ? void 0 : booking._extend) || {},
|
|
621
639
|
product,
|
|
622
640
|
addTimeProduct: [],
|
|
623
641
|
canAddTime: false
|
|
@@ -626,7 +644,6 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
626
644
|
})
|
|
627
645
|
};
|
|
628
646
|
}
|
|
629
|
-
|
|
630
647
|
/**
|
|
631
648
|
* Loads the current customer's product coupons and discount cards after planner lines exist,
|
|
632
649
|
* then optionally lets the existing Rules engine select the best valid combination. This is a
|
|
@@ -634,7 +651,7 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
634
651
|
*/
|
|
635
652
|
async applyPlannerDiscounts(params = {}) {
|
|
636
653
|
const tempOrder = this.getTempOrder();
|
|
637
|
-
const requestedCustomerId = params.customerId ?? tempOrder
|
|
654
|
+
const requestedCustomerId = params.customerId ?? (tempOrder == null ? void 0 : tempOrder.customer_id);
|
|
638
655
|
const parsedCustomerId = Number(requestedCustomerId);
|
|
639
656
|
const customerId = Number.isFinite(parsedCustomerId) && parsedCustomerId > 1 ? parsedCustomerId : null;
|
|
640
657
|
const summaryBefore = await this.getSummary();
|
|
@@ -642,39 +659,31 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
642
659
|
return buildPlannerDiscountResult({
|
|
643
660
|
customerId: null,
|
|
644
661
|
discountList: this.getDiscountList(),
|
|
645
|
-
products: tempOrder
|
|
662
|
+
products: (tempOrder == null ? void 0 : tempOrder.products) || [],
|
|
646
663
|
summaryBefore,
|
|
647
664
|
summaryAfter: summaryBefore,
|
|
648
|
-
status:
|
|
665
|
+
status: "no_customer"
|
|
649
666
|
});
|
|
650
667
|
}
|
|
651
|
-
await this.loadDiscountConfig({
|
|
652
|
-
customerId,
|
|
653
|
-
action: 'create'
|
|
654
|
-
});
|
|
668
|
+
await this.loadDiscountConfig({ customerId, action: "create" });
|
|
655
669
|
const preferredDiscountId = params.preferredDiscountId;
|
|
656
|
-
const preferredDiscount = preferredDiscountId ===
|
|
670
|
+
const preferredDiscount = preferredDiscountId === void 0 || preferredDiscountId === null ? void 0 : this.getDiscountList().find((discount) => String(resolvePlannerDiscountId(discount) ?? "") === String(preferredDiscountId));
|
|
657
671
|
if (preferredDiscount) {
|
|
658
|
-
// A requested card is an explicit UI choice, not a best-effort preference. Clear prior
|
|
659
|
-
// automatic selections first; otherwise Rules may keep the old selected card and silently
|
|
660
|
-
// apply it instead of the card the customer clicked.
|
|
661
672
|
const preferredId = resolvePlannerDiscountId(preferredDiscount);
|
|
662
|
-
const selectedOtherDiscounts = this.getDiscountList().filter(discount => discount.isSelected === true && String(resolvePlannerDiscountId(discount) ??
|
|
673
|
+
const selectedOtherDiscounts = this.getDiscountList().filter((discount) => discount.isSelected === true && String(resolvePlannerDiscountId(discount) ?? "") !== String(preferredId));
|
|
663
674
|
for (const discount of selectedOtherDiscounts) {
|
|
664
675
|
const discountId = Number(resolvePlannerDiscountId(discount));
|
|
665
676
|
if (Number.isFinite(discountId)) {
|
|
666
|
-
await this.setDiscountSelected({
|
|
667
|
-
discountId,
|
|
668
|
-
isSelected: false
|
|
669
|
-
});
|
|
677
|
+
await this.setDiscountSelected({ discountId, isSelected: false });
|
|
670
678
|
}
|
|
671
679
|
}
|
|
672
680
|
await this.setDiscountSelected({
|
|
673
681
|
discountId: Number(preferredId),
|
|
674
682
|
isSelected: true
|
|
675
683
|
});
|
|
676
|
-
} else if (preferredDiscountId ===
|
|
677
|
-
if (params.applyBestDiscount !== false)
|
|
684
|
+
} else if (preferredDiscountId === void 0 || preferredDiscountId === null) {
|
|
685
|
+
if (params.applyBestDiscount !== false)
|
|
686
|
+
await this.bestDiscount();
|
|
678
687
|
} else if (params.applyBestDiscount !== false) {
|
|
679
688
|
await this.bestDiscount();
|
|
680
689
|
}
|
|
@@ -682,19 +691,18 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
682
691
|
return buildPlannerDiscountResult({
|
|
683
692
|
customerId,
|
|
684
693
|
discountList: this.getDiscountList(),
|
|
685
|
-
products: nextTempOrder
|
|
694
|
+
products: (nextTempOrder == null ? void 0 : nextTempOrder.products) || [],
|
|
686
695
|
summaryBefore,
|
|
687
696
|
summaryAfter: await this.getSummary(),
|
|
688
|
-
status: params.applyBestDiscount === false && !preferredDiscount ?
|
|
697
|
+
status: params.applyBestDiscount === false && !preferredDiscount ? "loaded" : "applied",
|
|
689
698
|
preferredDiscountId,
|
|
690
|
-
preferredDiscountFound: preferredDiscountId ===
|
|
699
|
+
preferredDiscountFound: preferredDiscountId === void 0 || preferredDiscountId === null ? void 0 : Boolean(preferredDiscount)
|
|
691
700
|
});
|
|
692
701
|
}
|
|
693
|
-
|
|
694
702
|
/** ResourcePlanner is a required child module; fail early instead of producing partial availability. */
|
|
695
703
|
getPlanner() {
|
|
696
704
|
if (!this.store.resourcePlanner) {
|
|
697
|
-
throw new Error(
|
|
705
|
+
throw new Error("[UnifiedBookingSales] resourcePlanner 模块未初始化");
|
|
698
706
|
}
|
|
699
707
|
return this.store.resourcePlanner;
|
|
700
708
|
}
|
|
@@ -702,162 +710,169 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
702
710
|
const orderProduct = this.transformBaseProductToOrderProduct({
|
|
703
711
|
payload: {
|
|
704
712
|
...sourceProduct,
|
|
705
|
-
id: sourceProduct.id ?? product
|
|
706
|
-
product_id: sourceProduct.product_id ?? sourceProduct.id ?? product
|
|
707
|
-
quantity: sourceProduct.quantity ?? sourceProduct.num ?? product
|
|
708
|
-
price: sourceProduct.price ?? product
|
|
709
|
-
selling_price: sourceProduct.selling_price ?? sourceProduct.price ?? product
|
|
713
|
+
id: sourceProduct.id ?? (product == null ? void 0 : product.id),
|
|
714
|
+
product_id: sourceProduct.product_id ?? sourceProduct.id ?? (product == null ? void 0 : product.id),
|
|
715
|
+
quantity: sourceProduct.quantity ?? sourceProduct.num ?? (product == null ? void 0 : product.quantity) ?? 1,
|
|
716
|
+
price: sourceProduct.price ?? (product == null ? void 0 : product.price),
|
|
717
|
+
selling_price: sourceProduct.selling_price ?? sourceProduct.price ?? (product == null ? void 0 : product.price),
|
|
710
718
|
metadata: {
|
|
711
|
-
...
|
|
719
|
+
...sourceProduct.metadata || {},
|
|
712
720
|
[ownershipKey]: true
|
|
713
721
|
}
|
|
714
722
|
},
|
|
715
723
|
sourceProduct
|
|
716
724
|
});
|
|
717
|
-
if (orderProduct && typeof orderProduct ===
|
|
718
|
-
// BaseSales may rebuild metadata from its price source. Stamp ownership after that transform
|
|
719
|
-
// so each UnifiedBookingSales entry point can replace only its own temporary lines.
|
|
725
|
+
if (orderProduct && typeof orderProduct === "object") {
|
|
720
726
|
orderProduct.metadata = {
|
|
721
|
-
...
|
|
727
|
+
...orderProduct.metadata || {},
|
|
722
728
|
[ownershipKey]: true
|
|
723
729
|
};
|
|
724
730
|
}
|
|
725
731
|
return orderProduct;
|
|
726
732
|
}
|
|
727
|
-
|
|
728
733
|
/** Replacing a staged selection is idempotent and never removes unrelated cart lines. */
|
|
729
734
|
async removeExistingStagedLines(ownershipKey) {
|
|
730
|
-
|
|
735
|
+
var _a;
|
|
736
|
+
const existingLines = (((_a = this.getTempOrder()) == null ? void 0 : _a.products) || []).filter((product) => {
|
|
737
|
+
var _a2;
|
|
738
|
+
return ((_a2 = product == null ? void 0 : product.metadata) == null ? void 0 : _a2[ownershipKey]) === true;
|
|
739
|
+
});
|
|
731
740
|
if (existingLines.length > 0) {
|
|
732
741
|
await this.removeProductsFromOrder(existingLines.map(buildPlannerLineIdentity));
|
|
733
742
|
}
|
|
734
743
|
}
|
|
735
744
|
async stageProducts(params, ownershipKey) {
|
|
745
|
+
var _a;
|
|
736
746
|
const productIds = params.productIds || [];
|
|
737
|
-
if (!productIds.length)
|
|
738
|
-
|
|
747
|
+
if (!productIds.length)
|
|
748
|
+
return this.getTempOrder();
|
|
749
|
+
if ((_a = params.rawProducts) == null ? void 0 : _a.length) {
|
|
739
750
|
this.unifiedProductCatalog = params.rawProducts;
|
|
740
751
|
} else {
|
|
741
|
-
const existingIds = new Set((this.unifiedProductCatalog || []).map(product => String(product.id ?? product.product_id)));
|
|
742
|
-
const missingIds = productIds.filter(id => !existingIds.has(String(id)));
|
|
752
|
+
const existingIds = new Set((this.unifiedProductCatalog || []).map((product) => String(product.id ?? product.product_id)));
|
|
753
|
+
const missingIds = productIds.filter((id) => !existingIds.has(String(id)));
|
|
743
754
|
if (missingIds.length || params.productLoadParams) {
|
|
744
755
|
await this.loadProducts({
|
|
745
|
-
...
|
|
756
|
+
...params.productLoadParams || {},
|
|
746
757
|
product_ids: productIds.map(Number).filter(Number.isFinite)
|
|
747
758
|
});
|
|
748
759
|
}
|
|
749
760
|
}
|
|
750
761
|
await this.removeExistingStagedLines(ownershipKey);
|
|
751
|
-
const productIdSet = new Set(productIds.map(id => String(id)));
|
|
752
|
-
const selectedProducts = (this.unifiedProductCatalog || []).filter(product => productIdSet.has(String(product.id ?? product.product_id)));
|
|
762
|
+
const productIdSet = new Set(productIds.map((id) => String(id)));
|
|
763
|
+
const selectedProducts = (this.unifiedProductCatalog || []).filter((product) => productIdSet.has(String(product.id ?? product.product_id)));
|
|
753
764
|
for (const sourceProduct of selectedProducts) {
|
|
754
765
|
const productInput = this.buildUnifiedOrderProduct(sourceProduct, ownershipKey);
|
|
755
|
-
if (productInput)
|
|
766
|
+
if (productInput)
|
|
767
|
+
await this.addProductToOrder(productInput);
|
|
756
768
|
}
|
|
757
769
|
return this.getTempOrder();
|
|
758
770
|
}
|
|
759
|
-
|
|
760
771
|
/**
|
|
761
772
|
* Adds the current product choice to an otherwise clean planner cart without creating bookings.
|
|
762
773
|
* This separates "what the customer wants" from the later time/resource confirmation step.
|
|
763
774
|
*/
|
|
764
775
|
async stagePlannerProducts(params) {
|
|
765
|
-
return this.stageProducts(params,
|
|
776
|
+
return this.stageProducts(params, "unified_booking_sales");
|
|
766
777
|
}
|
|
767
|
-
|
|
768
778
|
/**
|
|
769
779
|
* Adds ordinary retail products without asking ResourcePlanner for booking facts.
|
|
770
780
|
* Its staged lines have separate ownership so planner and retail skins can coexist safely.
|
|
771
781
|
*/
|
|
772
782
|
async stageRetailProducts(params) {
|
|
773
|
-
return this.stageProducts(params,
|
|
783
|
+
return this.stageProducts(params, "unified_booking_sales_retail");
|
|
774
784
|
}
|
|
775
|
-
|
|
776
785
|
/**
|
|
777
786
|
* Adds one retail line without replacing the cart's existing retail selection.
|
|
778
787
|
* This is intentionally separate from stageRetailProducts(), whose contract is
|
|
779
788
|
* "replace the staged selection" for demo and wizard-like callers.
|
|
780
789
|
*/
|
|
781
790
|
async addRetailProduct(params) {
|
|
791
|
+
var _a, _b;
|
|
782
792
|
const quantity = Math.floor(Number(params.quantity ?? 1));
|
|
783
793
|
if (!Number.isFinite(quantity) || quantity <= 0) {
|
|
784
|
-
throw new Error(
|
|
794
|
+
throw new Error("[UnifiedBookingSales] retail 商品数量必须大于 0");
|
|
785
795
|
}
|
|
786
|
-
const productId = params.productId ?? params.product
|
|
796
|
+
const productId = params.productId ?? ((_a = params.product) == null ? void 0 : _a.id) ?? ((_b = params.product) == null ? void 0 : _b.product_id);
|
|
787
797
|
let sourceProduct = params.product;
|
|
788
|
-
if (!sourceProduct && productId !==
|
|
789
|
-
sourceProduct = this.unifiedProductCatalog.find(
|
|
798
|
+
if (!sourceProduct && productId !== void 0 && productId !== null) {
|
|
799
|
+
sourceProduct = this.unifiedProductCatalog.find(
|
|
800
|
+
(product) => String(product.id ?? product.product_id) === String(productId)
|
|
801
|
+
);
|
|
790
802
|
}
|
|
791
|
-
if (!sourceProduct && productId !==
|
|
803
|
+
if (!sourceProduct && productId !== void 0 && productId !== null) {
|
|
792
804
|
const products = await this.loadProducts({
|
|
793
|
-
...
|
|
805
|
+
...params.productLoadParams || {},
|
|
794
806
|
product_ids: [Number(productId)].filter(Number.isFinite)
|
|
795
807
|
});
|
|
796
|
-
sourceProduct = products.find(
|
|
808
|
+
sourceProduct = products.find(
|
|
809
|
+
(product) => String(product.id ?? product.product_id) === String(productId)
|
|
810
|
+
);
|
|
797
811
|
}
|
|
798
812
|
if (!sourceProduct) {
|
|
799
|
-
throw new Error(`[UnifiedBookingSales] 未找到零售商品 ${String(productId ??
|
|
813
|
+
throw new Error(`[UnifiedBookingSales] 未找到零售商品 ${String(productId ?? "")}`.trim());
|
|
800
814
|
}
|
|
801
|
-
const orderProduct = this.buildUnifiedOrderProduct(
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
815
|
+
const orderProduct = this.buildUnifiedOrderProduct(
|
|
816
|
+
{
|
|
817
|
+
...sourceProduct,
|
|
818
|
+
quantity
|
|
819
|
+
},
|
|
820
|
+
"unified_booking_sales_retail"
|
|
821
|
+
);
|
|
805
822
|
if (!orderProduct) {
|
|
806
|
-
throw new Error(
|
|
823
|
+
throw new Error("[UnifiedBookingSales] 无法生成零售商品订单行");
|
|
807
824
|
}
|
|
808
825
|
return this.addProductToOrder(orderProduct);
|
|
809
826
|
}
|
|
810
|
-
|
|
811
827
|
/** Normalizes caller-provided products or loads the catalog before any resource request is made. */
|
|
812
828
|
async loadPlannerProducts(params) {
|
|
813
|
-
|
|
814
|
-
if (params.
|
|
815
|
-
|
|
829
|
+
var _a, _b, _c, _d, _e, _f;
|
|
830
|
+
if ((_b = (_a = params.context) == null ? void 0 : _a.products) == null ? void 0 : _b.length)
|
|
831
|
+
return params.context.products;
|
|
832
|
+
if ((_c = params.rawProducts) == null ? void 0 : _c.length)
|
|
833
|
+
return params.rawProducts.map(normalizeProductForPlanner);
|
|
834
|
+
const productIds = params.productIds || ((_d = params.productLoadParams) == null ? void 0 : _d.product_ids) || [];
|
|
816
835
|
if (productIds.length > 0 || params.productLoadParams) {
|
|
817
836
|
await this.loadProducts({
|
|
818
|
-
...
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
...(params.productLoadParams || {}),
|
|
822
|
-
product_ids: productIds.length ? productIds.map(Number).filter(Number.isFinite) : params.productLoadParams?.product_ids
|
|
837
|
+
...params.date ? { schedule_date: params.date } : {},
|
|
838
|
+
...params.productLoadParams || {},
|
|
839
|
+
product_ids: productIds.length ? productIds.map(Number).filter(Number.isFinite) : (_e = params.productLoadParams) == null ? void 0 : _e.product_ids
|
|
823
840
|
});
|
|
824
841
|
}
|
|
825
|
-
return (this.getProductCatalog
|
|
842
|
+
return (((_f = this.getProductCatalog) == null ? void 0 : _f.call(this).products) || []).map(normalizeProductForPlanner);
|
|
826
843
|
}
|
|
827
|
-
|
|
828
844
|
/** Loads the reusable store-level schedule catalog on demand. */
|
|
829
845
|
async ensurePlannerSchedulesLoaded() {
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
846
|
+
var _a, _b, _c, _d, _e, _f;
|
|
847
|
+
if (!this.store.schedule)
|
|
848
|
+
throw new Error("[UnifiedBookingSales] schedule 模块未初始化");
|
|
849
|
+
const scheduleList = ((_b = (_a = this.store.schedule).getScheduleList) == null ? void 0 : _b.call(_a)) || [];
|
|
850
|
+
if (!((_d = (_c = this.store.schedule).isScheduleListLoaded) == null ? void 0 : _d.call(_c)) || scheduleList.length === 0) {
|
|
833
851
|
await this.store.schedule.loadAllSchedule();
|
|
834
852
|
}
|
|
835
|
-
return this.store.schedule.getScheduleList
|
|
853
|
+
return ((_f = (_e = this.store.schedule).getScheduleList) == null ? void 0 : _f.call(_e)) || [];
|
|
836
854
|
}
|
|
837
|
-
|
|
838
855
|
/**
|
|
839
856
|
* v2 resources reference schedule ids rather than expanded work times. Refresh once when the
|
|
840
857
|
* cached schedule catalog cannot materialize all referenced ids.
|
|
841
858
|
*/
|
|
842
859
|
async ensurePlannerSchedulesForResources(rawResources) {
|
|
860
|
+
var _a, _b;
|
|
843
861
|
let scheduleList = await this.ensurePlannerSchedulesLoaded();
|
|
844
862
|
const scheduleIds = collectRawScheduleIds(rawResources);
|
|
845
863
|
if (!scheduleListHasIds(scheduleList, scheduleIds)) {
|
|
846
|
-
await this.store.schedule.loadAllSchedule({
|
|
847
|
-
|
|
848
|
-
});
|
|
849
|
-
scheduleList = this.store.schedule.getScheduleList?.() || [];
|
|
864
|
+
await this.store.schedule.loadAllSchedule({ useCache: false });
|
|
865
|
+
scheduleList = ((_b = (_a = this.store.schedule).getScheduleList) == null ? void 0 : _b.call(_a)) || [];
|
|
850
866
|
}
|
|
851
867
|
return scheduleList;
|
|
852
868
|
}
|
|
853
|
-
|
|
854
869
|
/**
|
|
855
870
|
* Fetches resource metadata plus flat occupied events. Work windows are intentionally derived
|
|
856
871
|
* locally in buildPlannerResourcesFromV2 from /schedule, rather than requested from the legacy
|
|
857
872
|
* resource dates endpoint.
|
|
858
873
|
*/
|
|
859
874
|
async fetchPlannerResourcesV2(params) {
|
|
860
|
-
const response = await this.request.get(
|
|
875
|
+
const response = await this.request.get("/schedule/resource/list/v2", {
|
|
861
876
|
start_date: params.dateRange.start,
|
|
862
877
|
end_date: params.dateRange.end,
|
|
863
878
|
resource_ids: params.resourceIds,
|
|
@@ -865,34 +880,36 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
865
880
|
}, {
|
|
866
881
|
useCache: false
|
|
867
882
|
});
|
|
868
|
-
const data = response
|
|
869
|
-
if (Array.isArray(data))
|
|
870
|
-
|
|
883
|
+
const data = response == null ? void 0 : response.data;
|
|
884
|
+
if (Array.isArray(data))
|
|
885
|
+
return data;
|
|
886
|
+
if (Array.isArray(data == null ? void 0 : data.list))
|
|
887
|
+
return data.list;
|
|
871
888
|
return [];
|
|
872
889
|
}
|
|
873
|
-
|
|
874
890
|
/**
|
|
875
891
|
* Resolves the Planner context in precedence order: explicit normalized context, test raw data,
|
|
876
892
|
* then the v2 resource API inferred from selected product requirements and any URL lock.
|
|
877
893
|
*/
|
|
878
894
|
async loadPlannerResources(params, products = []) {
|
|
879
|
-
|
|
895
|
+
var _a, _b, _c, _d, _e, _f;
|
|
896
|
+
if ((_b = (_a = params.context) == null ? void 0 : _a.resources) == null ? void 0 : _b.length) {
|
|
880
897
|
return {
|
|
881
898
|
resources: params.context.resources,
|
|
882
899
|
externalEvents: params.context.externalEvents || []
|
|
883
900
|
};
|
|
884
901
|
}
|
|
885
|
-
if (params.rawResources
|
|
902
|
+
if ((_c = params.rawResources) == null ? void 0 : _c.length) {
|
|
886
903
|
return {
|
|
887
|
-
resources: params.rawResources.map(normalizeResource).filter(resource => resource !== null),
|
|
888
|
-
externalEvents: params.context
|
|
904
|
+
resources: params.rawResources.map(normalizeResource).filter((resource) => resource !== null),
|
|
905
|
+
externalEvents: ((_d = params.context) == null ? void 0 : _d.externalEvents) || []
|
|
889
906
|
};
|
|
890
907
|
}
|
|
891
908
|
const resourceIds = collectPlannerResourceIds(products, params.resourceIds || []);
|
|
892
909
|
if (!params.useResourceDateApi || !params.dateRange || resourceIds.length === 0) {
|
|
893
910
|
return {
|
|
894
911
|
resources: [],
|
|
895
|
-
externalEvents: params.context
|
|
912
|
+
externalEvents: ((_e = params.context) == null ? void 0 : _e.externalEvents) || []
|
|
896
913
|
};
|
|
897
914
|
}
|
|
898
915
|
const rawResources = await this.fetchPlannerResourcesV2({
|
|
@@ -907,10 +924,12 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
907
924
|
});
|
|
908
925
|
return {
|
|
909
926
|
resources: materialized.resources,
|
|
910
|
-
externalEvents: [
|
|
927
|
+
externalEvents: [
|
|
928
|
+
...((_f = params.context) == null ? void 0 : _f.externalEvents) || [],
|
|
929
|
+
...materialized.externalEvents
|
|
930
|
+
]
|
|
911
931
|
};
|
|
912
932
|
}
|
|
913
|
-
|
|
914
933
|
/**
|
|
915
934
|
* Boundary between IO and pure planning. Once this returns, all later availability/slot calls
|
|
916
935
|
* operate on the ResourcePlanner snapshot and do not issue resource requests themselves.
|
|
@@ -919,7 +938,7 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
919
938
|
const products = await this.loadPlannerProducts(params);
|
|
920
939
|
const plannerResources = await this.loadPlannerResources(params, products);
|
|
921
940
|
const context = {
|
|
922
|
-
...
|
|
941
|
+
...params.context || {},
|
|
923
942
|
products,
|
|
924
943
|
resources: plannerResources.resources,
|
|
925
944
|
externalEvents: plannerResources.externalEvents
|
|
@@ -933,25 +952,21 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
933
952
|
endTime: params.endTime,
|
|
934
953
|
resourceIds: params.resourceIds || []
|
|
935
954
|
});
|
|
936
|
-
await this.core.effects.emit(`${this.name}:${
|
|
955
|
+
await this.core.effects.emit(`${this.name}:${import_types.UnifiedBookingSalesHooks.onPlannerContextLoaded}`, snapshot);
|
|
937
956
|
return this.getPlanner().getSnapshot();
|
|
938
957
|
}
|
|
939
|
-
|
|
940
958
|
/** Returns cells, date summaries and a derived grid; cells are continuous ranges, not UI slots. */
|
|
941
959
|
async queryPlannerAvailability(query = {}) {
|
|
942
960
|
return this.getPlanner().queryAvailability(query);
|
|
943
961
|
}
|
|
944
|
-
|
|
945
962
|
/** Turns compatible availability ranges into user-selectable intervals and ready-to-commit assignments. */
|
|
946
963
|
resolveAssignableSlots(query = {}) {
|
|
947
964
|
return this.getPlanner().resolveAssignableSlots(query);
|
|
948
965
|
}
|
|
949
|
-
|
|
950
966
|
/** Stores a UI choice only. It is deliberately side-effect free with respect to tempOrder. */
|
|
951
967
|
setPlannerSelection(patch) {
|
|
952
968
|
return this.getPlanner().setSelectionPatch(patch);
|
|
953
969
|
}
|
|
954
|
-
|
|
955
970
|
/**
|
|
956
971
|
* Legacy-friendly automatic assignment for already fixed intervals. Duration products without a
|
|
957
972
|
* start time intentionally remain unresolved; callers offering a picker should use slots.
|
|
@@ -959,21 +974,18 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
959
974
|
async autoAssignPlanner(query = {}) {
|
|
960
975
|
const result = this.getPlanner().autoAssign(query);
|
|
961
976
|
if (result.conflicts.length) {
|
|
962
|
-
console.warn(
|
|
977
|
+
console.warn("[UnifiedBookingSales] autoAssignPlanner 存在未分配项", result.conflicts);
|
|
963
978
|
}
|
|
964
979
|
return this.getPlanner().getSnapshot();
|
|
965
980
|
}
|
|
966
|
-
|
|
967
981
|
/** Rechecks remote events, capacity and conflicts among the current selection before committing. */
|
|
968
982
|
validatePlannerSelection() {
|
|
969
983
|
return this.getPlanner().validateSelection();
|
|
970
984
|
}
|
|
971
|
-
|
|
972
985
|
/** Read-only snapshot for UI diagnostics and progressive flow steps. */
|
|
973
986
|
getPlannerSnapshot() {
|
|
974
987
|
return this.getPlanner().getSnapshot();
|
|
975
988
|
}
|
|
976
|
-
|
|
977
989
|
/**
|
|
978
990
|
* Validates then writes assignments to tempOrder. Real order submission is opt-in so UI callers
|
|
979
991
|
* can safely preview the cart; pass submitAfterCommit only after an explicit confirmation.
|
|
@@ -983,9 +995,7 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
983
995
|
this.setPlannerSelection(params.selection);
|
|
984
996
|
}
|
|
985
997
|
if (params.assignments) {
|
|
986
|
-
this.setPlannerSelection({
|
|
987
|
-
assignments: params.assignments
|
|
988
|
-
});
|
|
998
|
+
this.setPlannerSelection({ assignments: params.assignments });
|
|
989
999
|
}
|
|
990
1000
|
const snapshot = this.getPlannerSnapshot();
|
|
991
1001
|
const assignments = snapshot.selection.assignments || [];
|
|
@@ -996,8 +1006,8 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
996
1006
|
validation: {
|
|
997
1007
|
ok: false,
|
|
998
1008
|
conflicts: [{
|
|
999
|
-
type:
|
|
1000
|
-
message:
|
|
1009
|
+
type: "missing_assignment",
|
|
1010
|
+
message: "没有可提交的 planner assignment,请先执行 autoAssignPlanner 或传入 assignments"
|
|
1001
1011
|
}]
|
|
1002
1012
|
}
|
|
1003
1013
|
};
|
|
@@ -1010,23 +1020,27 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
1010
1020
|
validation
|
|
1011
1021
|
};
|
|
1012
1022
|
}
|
|
1013
|
-
const productsById = new Map(
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1023
|
+
const productsById = new Map(
|
|
1024
|
+
snapshot.context.products.map((product) => [String(product.id), product])
|
|
1025
|
+
);
|
|
1026
|
+
await this.removeExistingStagedLines("unified_booking_sales");
|
|
1027
|
+
const assignmentGroups = /* @__PURE__ */ new Map();
|
|
1028
|
+
assignments.forEach((assignment) => {
|
|
1017
1029
|
const key = buildAssignmentGroupKey(assignment);
|
|
1018
|
-
assignmentGroups.set(key, [...
|
|
1030
|
+
assignmentGroups.set(key, [...assignmentGroups.get(key) || [], assignment]);
|
|
1019
1031
|
});
|
|
1020
1032
|
for (const groupAssignments of assignmentGroups.values()) {
|
|
1021
1033
|
const product = productsById.get(String(groupAssignments[0].productId));
|
|
1022
|
-
if (!product)
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1034
|
+
if (!product)
|
|
1035
|
+
continue;
|
|
1036
|
+
const sourceProduct = product.raw || { id: product.id, title: product.title, price: product.price };
|
|
1037
|
+
const productInput = this.buildUnifiedOrderProduct(
|
|
1038
|
+
sourceProduct,
|
|
1039
|
+
"unified_booking_sales",
|
|
1040
|
+
product
|
|
1041
|
+
);
|
|
1042
|
+
if (!productInput)
|
|
1043
|
+
continue;
|
|
1030
1044
|
await this.addProductToOrder(productInput, buildBookingFromAssignments({
|
|
1031
1045
|
assignments: groupAssignments,
|
|
1032
1046
|
product
|
|
@@ -1042,9 +1056,21 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
1042
1056
|
validation,
|
|
1043
1057
|
submitResult
|
|
1044
1058
|
};
|
|
1045
|
-
await this.core.effects.emit(`${this.name}:${
|
|
1059
|
+
await this.core.effects.emit(`${this.name}:${import_types.UnifiedBookingSalesHooks.onPlannerCommitted}`, result);
|
|
1046
1060
|
return result;
|
|
1047
1061
|
}
|
|
1048
|
-
}
|
|
1049
|
-
|
|
1050
|
-
|
|
1062
|
+
};
|
|
1063
|
+
var UnifiedBookingSales = UnifiedBookingSalesImpl;
|
|
1064
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
1065
|
+
0 && (module.exports = {
|
|
1066
|
+
UnifiedBookingSales,
|
|
1067
|
+
UnifiedBookingSalesImpl,
|
|
1068
|
+
buildBookingFromAssignment,
|
|
1069
|
+
buildBookingFromAssignments,
|
|
1070
|
+
buildPlannerDiscountResult,
|
|
1071
|
+
buildPlannerLineIdentity,
|
|
1072
|
+
buildPlannerResourcesFromV2,
|
|
1073
|
+
collectPlannerResourceIds,
|
|
1074
|
+
normalizeProductForPlanner,
|
|
1075
|
+
...require("./types")
|
|
1076
|
+
});
|