@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,242 +1,222 @@
|
|
|
1
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
2
28
|
|
|
3
|
-
|
|
4
|
-
|
|
29
|
+
// src/modules/BookingContext/utils/cacheItemToBookingInput.ts
|
|
30
|
+
var cacheItemToBookingInput_exports = {};
|
|
31
|
+
__export(cacheItemToBookingInput_exports, {
|
|
32
|
+
cacheItemToBookingInput: () => cacheItemToBookingInput
|
|
5
33
|
});
|
|
6
|
-
exports
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
-
/**
|
|
13
|
-
* 把 info2 `cacheItem` 转换为 OS `addProductToOrder(product, booking)` 所需的 booking 入参。
|
|
14
|
-
*
|
|
15
|
-
* 协议严格对齐 `pisell_os/src/modules/Order/TEMP_ORDER_FIELDS_SUMMARY.md` 的 Bookings 章节:
|
|
16
|
-
* - 顶层只允许出现:schedule_event_id / appointment_status / start_date / start_time / end_date /
|
|
17
|
-
* end_time / select_date / duration / sub_type / like_status / number / resources / relation_forms /
|
|
18
|
-
* holder / metadata / is_all / schedule_id / relation_id / form_id / relation_type / product_uid
|
|
19
|
-
* - bookings[] 不允许出现 `_extend`
|
|
20
|
-
* - bookings[].metadata 走白名单:unique_identification_number / collect_pax / capacity / holder_id / resource_select_type
|
|
21
|
-
* - bookings[].resources[] 只接受协议白名单:form_id / relation_type / relation_id / capacity / like_status / metadata / children
|
|
22
|
-
*
|
|
23
|
-
* `product_uid` / `metadata.unique_identification_number` 不在这里生成:
|
|
24
|
-
* OS `addProductToOrder` 内的 `createLinkedProductAndBooking` 会在最终一步统一改写,
|
|
25
|
-
* 保证商品行 uid 与 booking root 唯一值始终对齐。
|
|
26
|
-
*
|
|
27
|
-
* 复杂 multi-day 展开(createBookingItemsByGroup / concatBookings)首版**不支持**,
|
|
28
|
-
* 由 UI 在 `cart.confirmDetail` 之外通过辅助 API 处理。
|
|
29
|
-
*/
|
|
30
|
-
|
|
31
|
-
/** custom / package 人数维度快照,与 info2 `_extend.capacity` / `metadata.capacity` 对齐。 */
|
|
32
|
-
|
|
33
|
-
/** 将 UI `_extend.capacity[]` 规范化为 booking.metadata.capacity。 */
|
|
34
|
+
module.exports = __toCommonJS(cacheItemToBookingInput_exports);
|
|
35
|
+
var import_dayjs = __toESM(require("dayjs"));
|
|
36
|
+
var import_serviceTimes = require("./serviceTimes");
|
|
37
|
+
var import_resources = require("./resources");
|
|
38
|
+
var import_flexible = require("./flexible");
|
|
34
39
|
function normalizeExtendCapacityForMetadata(capacity) {
|
|
35
|
-
if (!Array.isArray(capacity) || capacity.length === 0)
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
if (item
|
|
40
|
+
if (!Array.isArray(capacity) || capacity.length === 0)
|
|
41
|
+
return void 0;
|
|
42
|
+
const normalized = capacity.map((item) => {
|
|
43
|
+
if (!item || typeof item !== "object")
|
|
44
|
+
return null;
|
|
45
|
+
if (item.id === void 0 || item.id === null)
|
|
46
|
+
return null;
|
|
39
47
|
const row = {
|
|
40
48
|
id: item.id,
|
|
41
49
|
value: Number(item.value ?? 0)
|
|
42
50
|
};
|
|
43
|
-
if (item.name !==
|
|
51
|
+
if (item.name !== void 0)
|
|
52
|
+
row.name = item.name;
|
|
44
53
|
return row;
|
|
45
|
-
}).filter(item => item != null);
|
|
46
|
-
return normalized.length > 0 ? normalized :
|
|
54
|
+
}).filter((item) => item != null);
|
|
55
|
+
return normalized.length > 0 ? normalized : void 0;
|
|
47
56
|
}
|
|
48
57
|
function safeFormat(value, fmt) {
|
|
49
|
-
if (value ===
|
|
50
|
-
|
|
51
|
-
|
|
58
|
+
if (value === void 0 || value === null)
|
|
59
|
+
return void 0;
|
|
60
|
+
const d = (0, import_dayjs.default)(value);
|
|
61
|
+
if (!d.isValid())
|
|
62
|
+
return void 0;
|
|
52
63
|
return d.format(fmt);
|
|
53
64
|
}
|
|
54
|
-
|
|
55
|
-
/** booking 协议 start_time / end_time:统一 HH:mm(不带秒)。 */
|
|
56
65
|
function normalizeTimeString(value) {
|
|
57
|
-
if (value ===
|
|
58
|
-
|
|
66
|
+
if (value === void 0 || value === null)
|
|
67
|
+
return void 0;
|
|
68
|
+
if (typeof value === "string") {
|
|
59
69
|
const t = value.trim();
|
|
60
70
|
const hhmmFromHhmmss = t.match(/^(\d{1,2}:\d{2}):\d{2}$/);
|
|
61
|
-
if (hhmmFromHhmmss)
|
|
62
|
-
|
|
71
|
+
if (hhmmFromHhmmss)
|
|
72
|
+
return hhmmFromHhmmss[1];
|
|
73
|
+
if (/^\d{1,2}:\d{2}$/.test(t))
|
|
74
|
+
return t;
|
|
63
75
|
}
|
|
64
|
-
const d = (0,
|
|
65
|
-
if (d.isValid())
|
|
66
|
-
|
|
76
|
+
const d = (0, import_dayjs.default)(value);
|
|
77
|
+
if (d.isValid())
|
|
78
|
+
return d.format("HH:mm");
|
|
79
|
+
return void 0;
|
|
67
80
|
}
|
|
68
81
|
function resolveDurationMinutes(value) {
|
|
69
|
-
if (typeof value ===
|
|
70
|
-
|
|
71
|
-
if (
|
|
82
|
+
if (typeof value === "number" && Number.isFinite(value))
|
|
83
|
+
return value;
|
|
84
|
+
if (typeof value !== "string")
|
|
85
|
+
return void 0;
|
|
86
|
+
if (import_flexible.flexibleObj.isFlexible(value))
|
|
87
|
+
return import_flexible.flexibleObj.getValue(value);
|
|
72
88
|
const n = Number(value);
|
|
73
|
-
return Number.isNaN(n) ?
|
|
89
|
+
return Number.isNaN(n) ? void 0 : n;
|
|
74
90
|
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* 将组合资源子项收敛为 checkout resources 协议。
|
|
78
|
-
*
|
|
79
|
-
* resourcesOriginMap 中的子资源是 UI 运行态结构,通常只有 id / main_field / form_id,
|
|
80
|
-
* 不保证携带后端必填的 relation_type。这里不能原样透传,否则会触发
|
|
81
|
-
* `bookings.*.resources.*.children.*.relation_type` 校验错误。
|
|
82
|
-
*/
|
|
83
91
|
function normalizeChildResource(child, parentFormId) {
|
|
84
92
|
const item = {
|
|
85
|
-
form_id: child
|
|
86
|
-
relation_type: child
|
|
87
|
-
relation_id: child
|
|
88
|
-
capacity: child
|
|
89
|
-
like_status: child
|
|
93
|
+
form_id: (child == null ? void 0 : child.form_id) ?? parentFormId,
|
|
94
|
+
relation_type: (child == null ? void 0 : child.relation_type) || "form",
|
|
95
|
+
relation_id: (child == null ? void 0 : child.relation_id) ?? (child == null ? void 0 : child.id),
|
|
96
|
+
capacity: child == null ? void 0 : child.capacity,
|
|
97
|
+
like_status: (child == null ? void 0 : child.like_status) || "common"
|
|
90
98
|
};
|
|
91
|
-
if (child
|
|
92
|
-
item.metadata = {
|
|
93
|
-
...child.metadata
|
|
94
|
-
};
|
|
99
|
+
if ((child == null ? void 0 : child.metadata) !== void 0) {
|
|
100
|
+
item.metadata = { ...child.metadata };
|
|
95
101
|
}
|
|
96
|
-
if (Array.isArray(child
|
|
97
|
-
item.children = child.children.map(
|
|
102
|
+
if (Array.isArray(child == null ? void 0 : child.children)) {
|
|
103
|
+
item.children = child.children.map(
|
|
104
|
+
(nestedChild) => normalizeChildResource(nestedChild, item.form_id)
|
|
105
|
+
);
|
|
98
106
|
}
|
|
99
107
|
return item;
|
|
100
108
|
}
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* cacheItem._extend.resource 形如 `{ [form_id]: [{ relation_id, form_id, like_status, metadata, children }] }`。
|
|
104
|
-
* 这里扁平化为符合协议的 resources[] 数组;id=0 的「无资源」占位行**保留**(与 info2 业务等价;协议 `relation_id=0` 合法)。
|
|
105
|
-
*
|
|
106
|
-
* 顶层 resources[].capacity 与 info2 `checkResourcesFormat` 一致:Σ capacity[].value(不含 quantity)。
|
|
107
|
-
*/
|
|
108
109
|
function flattenResources(cacheItem) {
|
|
109
|
-
|
|
110
|
-
const
|
|
110
|
+
var _a;
|
|
111
|
+
const resourceMap = ((_a = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _a.resource) || {};
|
|
112
|
+
const topLevelCapacity = (0, import_resources.getSumCapacity)(cacheItem, false);
|
|
111
113
|
const result = [];
|
|
112
|
-
Object.values(resourceMap).forEach(arr => {
|
|
113
|
-
if (!Array.isArray(arr))
|
|
114
|
-
|
|
114
|
+
Object.values(resourceMap).forEach((arr) => {
|
|
115
|
+
if (!Array.isArray(arr))
|
|
116
|
+
return;
|
|
117
|
+
arr.forEach((r) => {
|
|
115
118
|
const item = {
|
|
116
|
-
form_id: r
|
|
117
|
-
relation_type: r
|
|
118
|
-
relation_id: r
|
|
119
|
+
form_id: r == null ? void 0 : r.form_id,
|
|
120
|
+
relation_type: (r == null ? void 0 : r.relation_type) || "form",
|
|
121
|
+
relation_id: r == null ? void 0 : r.relation_id,
|
|
119
122
|
capacity: topLevelCapacity
|
|
120
123
|
};
|
|
121
|
-
item.like_status = r
|
|
122
|
-
if (r
|
|
123
|
-
|
|
124
|
-
item.metadata = {
|
|
125
|
-
...r.metadata
|
|
126
|
-
};
|
|
124
|
+
item.like_status = (r == null ? void 0 : r.like_status) || "common";
|
|
125
|
+
if ((r == null ? void 0 : r.metadata) !== void 0) {
|
|
126
|
+
item.metadata = { ...r.metadata };
|
|
127
127
|
}
|
|
128
|
-
if (Array.isArray(r
|
|
129
|
-
item.children = r.children.map(
|
|
128
|
+
if (Array.isArray(r == null ? void 0 : r.children)) {
|
|
129
|
+
item.children = r.children.map(
|
|
130
|
+
(child) => normalizeChildResource(child, item.form_id)
|
|
131
|
+
);
|
|
130
132
|
}
|
|
131
133
|
result.push(item);
|
|
132
134
|
});
|
|
133
135
|
});
|
|
134
136
|
return result;
|
|
135
137
|
}
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* 从 cacheItem 中派生 metadata.resource_select_type;优先级:
|
|
139
|
-
* 1. cacheItem._data.resources[0].select_type.type
|
|
140
|
-
* 2. cacheItem.product_resource.resources[0].select_type.type
|
|
141
|
-
* 3. 默认 undefined(由 OS / 后端兜底)。
|
|
142
|
-
*/
|
|
143
138
|
function deriveResourceSelectType(cacheItem) {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
139
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
140
|
+
const localFirst = (_d = (_c = (_b = (_a = cacheItem == null ? void 0 : cacheItem._data) == null ? void 0 : _a.resources) == null ? void 0 : _b[0]) == null ? void 0 : _c.select_type) == null ? void 0 : _d.type;
|
|
141
|
+
if (localFirst)
|
|
142
|
+
return localFirst;
|
|
143
|
+
const productFirst = (_h = (_g = (_f = (_e = cacheItem == null ? void 0 : cacheItem.product_resource) == null ? void 0 : _e.resources) == null ? void 0 : _f[0]) == null ? void 0 : _g.select_type) == null ? void 0 : _h.type;
|
|
144
|
+
if (productFirst)
|
|
145
|
+
return productFirst;
|
|
146
|
+
return void 0;
|
|
149
147
|
}
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* 主入口。
|
|
153
|
-
*/
|
|
154
148
|
function cacheItemToBookingInput(cacheItem, options) {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
}
|
|
159
|
-
};
|
|
149
|
+
var _a, _b;
|
|
150
|
+
if (!cacheItem)
|
|
151
|
+
return { metadata: { holder_id: null } };
|
|
160
152
|
const ext = cacheItem._extend || {};
|
|
161
|
-
const isMultiDay = (0,
|
|
162
|
-
const isSession = (0,
|
|
153
|
+
const isMultiDay = (0, import_serviceTimes.isMultiDayProduct)(cacheItem) || ext.is_all === 1 || ext.sub_type === "days";
|
|
154
|
+
const isSession = (0, import_serviceTimes.isSessionProduct)(cacheItem);
|
|
163
155
|
const result = {};
|
|
164
|
-
|
|
165
|
-
// ──── 日期 / 时间 ───────────────────────────────────────────────
|
|
166
|
-
if (isSession && ext?.other?.session) {
|
|
156
|
+
if (isSession && ((_a = ext == null ? void 0 : ext.other) == null ? void 0 : _a.session)) {
|
|
167
157
|
const session = ext.other.session;
|
|
168
|
-
|
|
169
|
-
result.
|
|
170
|
-
result.
|
|
171
|
-
result.
|
|
172
|
-
result.end_time = normalizeTimeString(ext.end_time) || normalizeTimeString(session.end_time) || safeFormat(session.end_at, 'HH:mm');
|
|
158
|
+
result.start_date = safeFormat(ext.start_date || ext.startDate || session.start_at, "YYYY-MM-DD");
|
|
159
|
+
result.start_time = normalizeTimeString(ext.start_time) || normalizeTimeString(session.start_time) || safeFormat(session.start_at, "HH:mm");
|
|
160
|
+
result.end_date = safeFormat(ext.end_date || ext.endDate || session.end_at, "YYYY-MM-DD");
|
|
161
|
+
result.end_time = normalizeTimeString(ext.end_time) || normalizeTimeString(session.end_time) || safeFormat(session.end_at, "HH:mm");
|
|
173
162
|
} else {
|
|
174
|
-
result.start_date = safeFormat(ext.start_date || ext.startDate,
|
|
175
|
-
result.start_time = normalizeTimeString(ext.start_time) || safeFormat(ext.startDate,
|
|
176
|
-
result.end_date = safeFormat(ext.end_date || ext.endDate,
|
|
177
|
-
result.end_time = normalizeTimeString(ext.end_time) || safeFormat(ext.endDate,
|
|
163
|
+
result.start_date = safeFormat(ext.start_date || ext.startDate, "YYYY-MM-DD");
|
|
164
|
+
result.start_time = normalizeTimeString(ext.start_time) || safeFormat(ext.startDate, "HH:mm");
|
|
165
|
+
result.end_date = safeFormat(ext.end_date || ext.endDate, "YYYY-MM-DD");
|
|
166
|
+
result.end_time = normalizeTimeString(ext.end_time) || safeFormat(ext.endDate, "HH:mm");
|
|
178
167
|
}
|
|
179
|
-
|
|
180
|
-
// ──── duration / sub_type / is_all ──────────────────────────────
|
|
181
168
|
if (isMultiDay) {
|
|
182
169
|
result.is_all = 1;
|
|
183
|
-
result.sub_type =
|
|
184
|
-
result.duration = Number(ext.duration) || (0,
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
if (result.start_time && (!result.end_time || result.end_time === '00:00')) {
|
|
170
|
+
result.sub_type = "days";
|
|
171
|
+
result.duration = Number(ext.duration) || (0, import_serviceTimes.getDays)(cacheItem, "days");
|
|
172
|
+
if (result.start_date)
|
|
173
|
+
result.select_date = result.start_date;
|
|
174
|
+
if (result.start_time && (!result.end_time || result.end_time === "00:00")) {
|
|
189
175
|
result.end_time = result.start_time;
|
|
190
176
|
}
|
|
191
177
|
} else {
|
|
192
178
|
result.is_all = 0;
|
|
193
|
-
result.sub_type = ext.sub_type ||
|
|
179
|
+
result.sub_type = ext.sub_type || "minutes";
|
|
194
180
|
const duration = resolveDurationMinutes(ext.duration);
|
|
195
|
-
if (duration !==
|
|
181
|
+
if (duration !== void 0)
|
|
182
|
+
result.duration = duration;
|
|
196
183
|
}
|
|
197
|
-
|
|
198
|
-
// ──── number(人数/容量占用) ───────────────────────────────────
|
|
199
|
-
result.number = (0, _resources.getSumCapacity)(cacheItem, true);
|
|
200
|
-
|
|
201
|
-
// ──── resources ─────────────────────────────────────────────────
|
|
184
|
+
result.number = (0, import_resources.getSumCapacity)(cacheItem, true);
|
|
202
185
|
result.resources = flattenResources(cacheItem);
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
if (ext.
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
if (cacheItem.schedule_event_id !== undefined) {
|
|
186
|
+
if (ext.holder !== void 0)
|
|
187
|
+
result.holder = ext.holder;
|
|
188
|
+
if (Array.isArray(ext.relation_forms))
|
|
189
|
+
result.relation_forms = ext.relation_forms;
|
|
190
|
+
result.like_status = ext.like_status || "common";
|
|
191
|
+
if (cacheItem.schedule_event_id !== void 0) {
|
|
210
192
|
result.schedule_event_id = cacheItem.schedule_event_id;
|
|
211
193
|
}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
const metadata = {
|
|
215
|
-
holder_id: null
|
|
216
|
-
};
|
|
217
|
-
if (ext.holder_id !== undefined && ext.holder_id !== null) {
|
|
194
|
+
const metadata = { holder_id: null };
|
|
195
|
+
if (ext.holder_id !== void 0 && ext.holder_id !== null) {
|
|
218
196
|
metadata.holder_id = ext.holder_id;
|
|
219
197
|
}
|
|
220
|
-
if (ext.holder !==
|
|
198
|
+
if (ext.holder !== void 0) {
|
|
221
199
|
metadata.holder = ext.holder;
|
|
222
200
|
}
|
|
223
|
-
if (ext.collect_pax !==
|
|
224
|
-
|
|
201
|
+
if (ext.collect_pax !== void 0)
|
|
202
|
+
metadata.collect_pax = ext.collect_pax;
|
|
225
203
|
const extendCapacity = normalizeExtendCapacityForMetadata(ext.capacity);
|
|
226
204
|
if (extendCapacity) {
|
|
227
205
|
metadata.capacity = extendCapacity;
|
|
228
|
-
} else if (ext.capacity_snapshot !==
|
|
206
|
+
} else if (ext.capacity_snapshot !== void 0) {
|
|
229
207
|
metadata.capacity = ext.capacity_snapshot;
|
|
230
208
|
}
|
|
231
|
-
const selectType = deriveResourceSelectType(cacheItem) || options
|
|
232
|
-
if (selectType)
|
|
233
|
-
|
|
209
|
+
const selectType = deriveResourceSelectType(cacheItem) || ((_b = options == null ? void 0 : options.bookingConfig) == null ? void 0 : _b.resource_select_type);
|
|
210
|
+
if (selectType)
|
|
211
|
+
metadata.resource_select_type = selectType;
|
|
234
212
|
result.metadata = metadata;
|
|
235
|
-
|
|
236
|
-
// ──── booking root 占位字段(与 TEMP_ORDER_FIELDS_SUMMARY 一致) ──
|
|
237
213
|
result.schedule_id = 0;
|
|
238
214
|
result.relation_id = 0;
|
|
239
215
|
result.form_id = 0;
|
|
240
|
-
result.relation_type =
|
|
216
|
+
result.relation_type = "";
|
|
241
217
|
return result;
|
|
242
|
-
}
|
|
218
|
+
}
|
|
219
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
220
|
+
0 && (module.exports = {
|
|
221
|
+
cacheItemToBookingInput
|
|
222
|
+
});
|
|
@@ -1,31 +1,43 @@
|
|
|
1
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
2
18
|
|
|
3
|
-
|
|
4
|
-
|
|
19
|
+
// src/modules/BookingContext/utils/flexible.ts
|
|
20
|
+
var flexible_exports = {};
|
|
21
|
+
__export(flexible_exports, {
|
|
22
|
+
flexibleObj: () => flexibleObj,
|
|
23
|
+
getDurationValue: () => getDurationValue,
|
|
24
|
+
isProductFlexibleDuration: () => isProductFlexibleDuration
|
|
5
25
|
});
|
|
6
|
-
exports
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* 灵活时长(flexible duration)协议工具。
|
|
11
|
-
*
|
|
12
|
-
* info2 用 `flexible_<minutes>` 字符串前缀标记"灵活时长",对外用同名 API 暴露 create / getValue / isFlexible / add。
|
|
13
|
-
* OS 这边一比一搬运,无外部依赖。
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
const PREFIX = 'flexible_';
|
|
17
|
-
const flexibleObj = exports.flexibleObj = {
|
|
26
|
+
module.exports = __toCommonJS(flexible_exports);
|
|
27
|
+
var PREFIX = "flexible_";
|
|
28
|
+
var flexibleObj = {
|
|
18
29
|
create(num) {
|
|
19
30
|
return `${PREFIX}${num}`;
|
|
20
31
|
},
|
|
21
32
|
getValue(str) {
|
|
22
|
-
if (typeof str ===
|
|
23
|
-
return Number(str.replace(PREFIX,
|
|
33
|
+
if (typeof str === "string" && flexibleObj.isFlexible(str)) {
|
|
34
|
+
return Number(str.replace(PREFIX, ""));
|
|
24
35
|
}
|
|
25
36
|
return Number(str);
|
|
26
37
|
},
|
|
27
38
|
isFlexible(str) {
|
|
28
|
-
if (typeof str !==
|
|
39
|
+
if (typeof str !== "string")
|
|
40
|
+
return false;
|
|
29
41
|
return str.indexOf(PREFIX) > -1;
|
|
30
42
|
},
|
|
31
43
|
add(current, duration) {
|
|
@@ -35,29 +47,34 @@ const flexibleObj = exports.flexibleObj = {
|
|
|
35
47
|
return Number(current) + duration;
|
|
36
48
|
}
|
|
37
49
|
};
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* 取 duration 数值(兼容 number / { type, value } / 灵活时长字符串)。
|
|
41
|
-
* 与 info2 `getDuration` 行为等价。
|
|
42
|
-
*/
|
|
43
|
-
/**
|
|
44
|
-
* 商品定义是否为「灵活时长」类型(仅看 product.duration 对象,不把 flexible_423 字符串当类型)。
|
|
45
|
-
* 与 info2 `getDuration({ type: 'flexible' }) === 'flexible'` 判定对齐。
|
|
46
|
-
*/
|
|
47
50
|
function isProductFlexibleDuration(duration) {
|
|
48
|
-
return Boolean(
|
|
51
|
+
return Boolean(
|
|
52
|
+
duration && typeof duration === "object" && duration.type === "flexible"
|
|
53
|
+
);
|
|
49
54
|
}
|
|
50
55
|
function getDurationValue(duration) {
|
|
51
|
-
if (duration ===
|
|
52
|
-
|
|
53
|
-
if (typeof duration ===
|
|
54
|
-
|
|
56
|
+
if (duration === void 0 || duration === null)
|
|
57
|
+
return void 0;
|
|
58
|
+
if (typeof duration === "number")
|
|
59
|
+
return duration;
|
|
60
|
+
if (typeof duration === "string") {
|
|
61
|
+
if (flexibleObj.isFlexible(duration))
|
|
62
|
+
return "flexible";
|
|
55
63
|
return Number(duration);
|
|
56
64
|
}
|
|
57
|
-
if (typeof duration ===
|
|
58
|
-
if (duration.type ===
|
|
59
|
-
|
|
60
|
-
if (duration.type ===
|
|
65
|
+
if (typeof duration === "object") {
|
|
66
|
+
if (duration.type === "minutes")
|
|
67
|
+
return duration.value;
|
|
68
|
+
if (duration.type === "flexible")
|
|
69
|
+
return "flexible";
|
|
70
|
+
if (duration.type === "days")
|
|
71
|
+
return duration.value;
|
|
61
72
|
}
|
|
62
|
-
return
|
|
63
|
-
}
|
|
73
|
+
return void 0;
|
|
74
|
+
}
|
|
75
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
76
|
+
0 && (module.exports = {
|
|
77
|
+
flexibleObj,
|
|
78
|
+
getDurationValue,
|
|
79
|
+
isProductFlexibleDuration
|
|
80
|
+
});
|
|
@@ -1,35 +1,50 @@
|
|
|
1
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
2
18
|
|
|
3
|
-
|
|
4
|
-
|
|
19
|
+
// src/modules/BookingContext/utils/formatResourceList.ts
|
|
20
|
+
var formatResourceList_exports = {};
|
|
21
|
+
__export(formatResourceList_exports, {
|
|
22
|
+
formatResourceListAndMap: () => formatResourceListAndMap
|
|
5
23
|
});
|
|
6
|
-
exports
|
|
7
|
-
var
|
|
8
|
-
/**
|
|
9
|
-
* 将 `/schedule/resource/list` 原始数组格式化为 `list + listMap`。
|
|
10
|
-
* 逻辑与 info2 [`getFormatResourceListAndMap`] 对齐:追加无资源占位行、按 id 建 map。
|
|
11
|
-
*/
|
|
24
|
+
module.exports = __toCommonJS(formatResourceList_exports);
|
|
25
|
+
var import_noResource = require("./noResource");
|
|
12
26
|
function formatResourceListAndMap(data, _bookingIds = []) {
|
|
13
|
-
const resourceList = (Array.isArray(data) ? data : []).concat([(0,
|
|
27
|
+
const resourceList = (Array.isArray(data) ? data : []).concat([(0, import_noResource.getNoResource2)({})]);
|
|
14
28
|
const map = resourceList.reduce((prev, item) => {
|
|
15
|
-
if (item
|
|
29
|
+
if ((item == null ? void 0 : item.id) !== void 0 && (item == null ? void 0 : item.id) !== null) {
|
|
16
30
|
prev[String(item.id)] = item;
|
|
17
31
|
}
|
|
18
32
|
return prev;
|
|
19
33
|
}, {});
|
|
20
|
-
const getCapacity = item => item.capacity;
|
|
21
|
-
const list = resourceList.map(item => {
|
|
34
|
+
const getCapacity = (item) => item.capacity;
|
|
35
|
+
const list = resourceList.map((item) => {
|
|
22
36
|
const newItem = {
|
|
23
37
|
...item,
|
|
24
38
|
capacity: getCapacity(item)
|
|
25
39
|
};
|
|
26
|
-
if (newItem.id !==
|
|
40
|
+
if (newItem.id !== void 0 && newItem.id !== null) {
|
|
27
41
|
map[String(newItem.id)] = newItem;
|
|
28
42
|
}
|
|
29
43
|
return newItem;
|
|
30
44
|
});
|
|
31
|
-
return {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
45
|
+
return { list, listMap: map };
|
|
46
|
+
}
|
|
47
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
48
|
+
0 && (module.exports = {
|
|
49
|
+
formatResourceListAndMap
|
|
50
|
+
});
|