@pisell/pisellos 2.3.74 → 2.3.75
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 +6 -10
- package/dist/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/model/strategy/adapter/walletPass/example.js +3 -26
- package/dist/model/strategy/strategy-example.js +5 -19
- package/dist/modules/Cart/index.js +0 -3
- package/dist/modules/Cart/utils/cartProduct.js +0 -1
- package/dist/modules/Date/index.js +1 -5
- package/dist/modules/Discount/index.js +2 -4
- package/dist/modules/OpenData/index.js +0 -2
- package/dist/modules/Order/index.js +36 -64
- package/dist/modules/Payment/index.js +97 -162
- package/dist/modules/Rules/index.js +1 -4
- package/dist/modules/Schedule/index.js +0 -1
- package/dist/modules/Schedule/utils.js +0 -1
- package/dist/modules/Step/index.js +0 -1
- package/dist/plugins/request.js +1 -4
- package/dist/plugins/window.js +2 -6
- package/dist/server/index.js +97 -129
- package/dist/server/modules/menu/index.js +32 -41
- package/dist/server/modules/order/index.js +2 -4
- package/dist/server/modules/products/index.js +24 -42
- package/dist/server/modules/quotation/index.js +29 -38
- package/dist/server/modules/resource/index.js +3 -4
- package/dist/server/modules/schedule/index.js +27 -35
- package/dist/server/utils/product.js +0 -1
- package/dist/solution/BaseSales/index.js +38 -41
- package/dist/solution/BookingByStep/index.js +7 -59
- package/dist/solution/BookingByStep/utils/capacity.js +1 -11
- package/dist/solution/BookingByStep/utils/resources.js +1 -3
- package/dist/solution/BookingByStep/utils/timeslots.js +2 -43
- package/dist/solution/BookingTicket/index.js +0 -2
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +6 -7
- package/dist/solution/BookingTicket/utils/scan/handleScan.js +25 -31
- package/dist/solution/BookingTicket/utils/scan/index.js +6 -10
- package/dist/solution/BuyTickets/index.js +9 -12
- package/dist/solution/Checkout/index.js +177 -252
- package/dist/solution/Checkout/utils/index.js +4 -16
- package/dist/solution/RegisterAndLogin/index.js +30 -76
- package/dist/solution/ScanOrder/index.js +50 -60
- package/dist/solution/ShopDiscount/index.js +2 -7
- package/dist/solution/VenueBooking/index.js +45 -55
- package/dist/utils/task.js +15 -18
- package/dist/utils/watch.js +0 -1
- package/lib/apis/picoding.js +2 -0
- package/lib/core/index.js +134 -134
- package/lib/effects/index.js +46 -57
- package/lib/index.js +82 -49
- package/lib/model/index.js +14 -21
- package/lib/model/strategy/adapter/dataVariant/adapter.js +38 -50
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +162 -236
- package/lib/model/strategy/adapter/dataVariant/examples.js +229 -237
- package/lib/model/strategy/adapter/dataVariant/index.js +39 -34
- package/lib/model/strategy/adapter/dataVariant/type.js +57 -28
- package/lib/model/strategy/adapter/index.js +100 -64
- package/lib/model/strategy/adapter/itemRule/adapter.js +156 -144
- package/lib/model/strategy/adapter/itemRule/evaluator.js +36 -48
- package/lib/model/strategy/adapter/itemRule/examples.js +295 -225
- package/lib/model/strategy/adapter/itemRule/index.js +83 -57
- package/lib/model/strategy/adapter/itemRule/type.js +97 -36
- package/lib/model/strategy/adapter/promotion/adapter.js +91 -69
- package/lib/model/strategy/adapter/promotion/evaluator.js +444 -310
- package/lib/model/strategy/adapter/promotion/examples.js +222 -234
- package/lib/model/strategy/adapter/promotion/index.js +1 -0
- package/lib/model/strategy/adapter/promotion/type.js +243 -36
- package/lib/model/strategy/adapter/type.js +4 -16
- package/lib/model/strategy/adapter/walletPass/evaluator.js +180 -150
- package/lib/model/strategy/adapter/walletPass/example.js +217 -190
- package/lib/model/strategy/adapter/walletPass/index.js +75 -51
- package/lib/model/strategy/adapter/walletPass/locales.js +36 -58
- package/lib/model/strategy/adapter/walletPass/type.js +4 -16
- package/lib/model/strategy/adapter/walletPass/utils.js +588 -378
- package/lib/model/strategy/engine.js +270 -168
- package/lib/model/strategy/index.js +49 -34
- package/lib/model/strategy/strategy-example.js +243 -239
- package/lib/model/strategy/type.js +100 -40
- package/lib/modules/Account/index.js +39 -53
- package/lib/modules/Account/types.js +20 -33
- package/lib/modules/AccountList/index.js +116 -154
- package/lib/modules/AccountList/types.js +30 -31
- package/lib/modules/AccountList/utils.js +18 -30
- package/lib/modules/BaseModule.js +23 -42
- package/lib/modules/BookingContext/index.js +158 -136
- package/lib/modules/BookingContext/types.js +46 -32
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +138 -146
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +78 -83
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +170 -150
- package/lib/modules/BookingContext/utils/flexible.js +38 -55
- package/lib/modules/BookingContext/utils/formatResourceList.js +19 -34
- package/lib/modules/BookingContext/utils/index.js +124 -41
- package/lib/modules/BookingContext/utils/noResource.js +58 -70
- package/lib/modules/BookingContext/utils/orderLineDisplay.js +14 -41
- package/lib/modules/BookingContext/utils/productExtend.js +202 -155
- package/lib/modules/BookingContext/utils/resourceErrors.js +53 -53
- package/lib/modules/BookingContext/utils/resourceSelection.js +19 -41
- package/lib/modules/BookingContext/utils/resources.js +209 -167
- package/lib/modules/BookingContext/utils/serviceTimes.js +115 -116
- package/lib/modules/BookingContext/utils/timeSlices.js +76 -86
- package/lib/modules/Cart/index.js +170 -124
- package/lib/modules/Cart/types.js +46 -51
- package/lib/modules/Cart/utils/cartAccount.js +40 -39
- package/lib/modules/Cart/utils/cartDate.js +56 -61
- package/lib/modules/Cart/utils/cartDiscount.js +28 -33
- package/lib/modules/Cart/utils/cartNote.js +27 -32
- package/lib/modules/Cart/utils/cartProduct.js +321 -251
- package/lib/modules/Cart/utils/cartRelationForms.js +29 -35
- package/lib/modules/Cart/utils/cartResource.js +70 -78
- package/lib/modules/Cart/utils/changePrice.js +22 -50
- package/lib/modules/Cart/utils/index.js +106 -48
- package/lib/modules/Customer/constants.js +13 -34
- package/lib/modules/Customer/index.js +235 -172
- package/lib/modules/Customer/types.js +38 -35
- package/lib/modules/Date/index.js +116 -115
- package/lib/modules/Date/types.js +16 -28
- package/lib/modules/Date/utils.js +174 -123
- package/lib/modules/Discount/index.js +122 -127
- package/lib/modules/Discount/types.js +9 -31
- package/lib/modules/Guests/index.js +30 -56
- package/lib/modules/Guests/types.js +23 -33
- package/lib/modules/Holder/index.js +209 -189
- package/lib/modules/Holder/types.js +4 -16
- package/lib/modules/Holder/utils.js +20 -49
- package/lib/modules/OpenData/index.js +70 -76
- package/lib/modules/OpenData/types.js +4 -16
- package/lib/modules/OpenData/utils.js +44 -78
- package/lib/modules/Order/index.js +1713 -2118
- package/lib/modules/Order/payment-utils.js +77 -120
- package/lib/modules/Order/types.js +88 -35
- package/lib/modules/Order/utils/bundleDiscountHydration.js +41 -74
- package/lib/modules/Order/utils/discountProductLineIdentity.js +142 -100
- package/lib/modules/Order/utils/manualProductDiscount.js +124 -123
- package/lib/modules/Order/utils/orderCollectionIdentity.js +184 -244
- package/lib/modules/Order/utils.js +814 -647
- package/lib/modules/Payment/cash.js +20 -33
- package/lib/modules/Payment/cashRecommendationAlgorithm.js +145 -76
- package/lib/modules/Payment/eftpos.js +16 -30
- package/lib/modules/Payment/index.js +532 -399
- package/lib/modules/Payment/mx51.js +1 -0
- package/lib/modules/Payment/types.js +230 -108
- package/lib/modules/Payment/utils.js +52 -51
- package/lib/modules/Payment/walletpass.js +485 -660
- package/lib/modules/Product/index.js +51 -46
- package/lib/modules/Product/types.js +4 -16
- package/lib/modules/Product/utils.js +32 -33
- package/lib/modules/ProductList/index.js +113 -123
- package/lib/modules/ProductList/types.js +9 -31
- package/lib/modules/Quotation/index.js +81 -118
- package/lib/modules/Quotation/types.js +4 -16
- package/lib/modules/Resource/index.js +27 -59
- package/lib/modules/Resource/types.js +22 -32
- package/lib/modules/Resource/utils.js +30 -38
- package/lib/modules/ResourcePlanner/index.js +25 -23
- package/lib/modules/ResourcePlanner/localClock.js +54 -119
- package/lib/modules/ResourcePlanner/planner.js +589 -770
- package/lib/modules/ResourcePlanner/types.js +10 -29
- package/lib/modules/Rules/index.js +1218 -959
- package/lib/modules/Rules/types.js +17 -40
- package/lib/modules/SalesSummary/index.js +85 -90
- package/lib/modules/SalesSummary/types.js +4 -16
- package/lib/modules/SalesSummary/utils.js +355 -430
- package/lib/modules/ScanOrderLogger/index.js +59 -79
- package/lib/modules/ScanOrderLogger/providers/feishu.js +54 -78
- package/lib/modules/ScanOrderLogger/providers/grafana.js +13 -36
- package/lib/modules/ScanOrderLogger/types.js +4 -16
- package/lib/modules/Schedule/getDateIsInSchedule.js +334 -163
- package/lib/modules/Schedule/index.js +100 -114
- package/lib/modules/Schedule/type.js +4 -16
- package/lib/modules/Schedule/types.js +4 -16
- package/lib/modules/Schedule/utils.js +433 -291
- package/lib/modules/Step/index.js +40 -52
- package/lib/modules/Step/tyeps.js +4 -16
- package/lib/modules/Summary/index.js +66 -71
- package/lib/modules/Summary/types.js +4 -16
- package/lib/modules/Summary/utils.js +773 -418
- package/lib/modules/SurchargeList/index.js +46 -60
- package/lib/modules/SurchargeList/types.js +4 -16
- package/lib/modules/index.js +245 -63
- package/lib/plugins/app.js +4 -16
- package/lib/plugins/index.js +36 -25
- package/lib/plugins/request.js +137 -126
- package/lib/plugins/shopStore.js +4 -16
- package/lib/plugins/user.js +4 -16
- package/lib/plugins/window.js +171 -179
- package/lib/server/index.js +3050 -2665
- package/lib/server/modules/floor-plan/index.js +118 -134
- package/lib/server/modules/floor-plan/types.js +15 -30
- package/lib/server/modules/index.js +106 -68
- package/lib/server/modules/menu/index.js +142 -122
- package/lib/server/modules/menu/types.js +18 -31
- package/lib/server/modules/order/index.js +784 -1002
- package/lib/server/modules/order/types.js +122 -33
- package/lib/server/modules/order/utils/filterBookings.js +219 -194
- package/lib/server/modules/order/utils/filterOrders.js +118 -92
- package/lib/server/modules/payment/index.js +59 -83
- package/lib/server/modules/payment/types.js +4 -16
- package/lib/server/modules/products/index.js +583 -471
- package/lib/server/modules/products/types.js +44 -34
- package/lib/server/modules/quotation/index.js +137 -172
- package/lib/server/modules/quotation/types.js +21 -31
- package/lib/server/modules/resource/index.js +220 -186
- package/lib/server/modules/resource/types.js +42 -33
- package/lib/server/modules/schedule/index.js +135 -123
- package/lib/server/modules/schedule/types.js +14 -21
- package/lib/server/modules/schedule/utils.js +334 -163
- package/lib/server/types.js +4 -16
- package/lib/server/utils/index.js +25 -23
- package/lib/server/utils/product.js +196 -139
- package/lib/server/utils/schedule.js +34 -41
- package/lib/server/utils/small-ticket.js +479 -456
- package/lib/server/utils/time.js +40 -49
- package/lib/solution/BaseSales/index.js +1186 -1410
- package/lib/solution/BaseSales/types.js +42 -38
- package/lib/solution/BaseSales/utils/cartPromotion.js +642 -498
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +85 -105
- package/lib/solution/BaseSales/utils/quotationPrice.js +56 -114
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +108 -145
- package/lib/solution/BaseSales/utils.js +158 -143
- package/lib/solution/BookingByStep/index.js +1527 -1340
- package/lib/solution/BookingByStep/types.js +40 -99
- package/lib/solution/BookingByStep/utils/capacity.js +192 -160
- package/lib/solution/BookingByStep/utils/products.js +42 -52
- package/lib/solution/BookingByStep/utils/resources.js +527 -330
- package/lib/solution/BookingByStep/utils/stock.js +65 -44
- package/lib/solution/BookingByStep/utils/timeslots.js +129 -131
- package/lib/solution/BookingTicket/index.js +607 -522
- package/lib/solution/BookingTicket/types.js +99 -77
- package/lib/solution/BookingTicket/utils/addProductDecision.js +226 -189
- package/lib/solution/BookingTicket/utils/addTimeAvailability.js +58 -89
- package/lib/solution/BookingTicket/utils/bookingStatus.js +107 -78
- package/lib/solution/BookingTicket/utils/cartView.js +114 -99
- package/lib/solution/BookingTicket/utils/exampleData.js +185 -0
- package/lib/solution/BookingTicket/utils/orderCustomer.js +18 -41
- package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.js +219 -86
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +168 -116
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +79 -91
- package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +54 -41
- package/lib/solution/BookingTicket/utils/scan/handleScan.js +84 -81
- package/lib/solution/BookingTicket/utils/scan/index.js +98 -104
- package/lib/solution/BookingTicket/utils/scan/scanCache.js +90 -43
- package/lib/solution/BookingTicket/utils/scan/scanProductValues.js +52 -64
- package/lib/solution/BookingTicket/utils/sessionCatalogStale.js +56 -58
- package/lib/solution/BookingTicket/utils/weighingProductSku.js +34 -48
- package/lib/solution/BuyTickets/index.js +67 -70
- package/lib/solution/BuyTickets/types.js +22 -38
- package/lib/solution/Checkout/index.js +1451 -1158
- package/lib/solution/Checkout/types.js +91 -61
- package/lib/solution/Checkout/utils/index.js +228 -156
- package/lib/solution/PlaceOrder/index.js +55 -0
- package/lib/solution/RegisterAndLogin/config.js +493 -460
- package/lib/solution/RegisterAndLogin/index.js +633 -630
- package/lib/solution/RegisterAndLogin/types.js +189 -76
- package/lib/solution/RegisterAndLogin/utils.js +183 -125
- package/lib/solution/Sales/index.js +328 -324
- package/lib/solution/Sales/types.js +27 -33
- package/lib/solution/ScanOrder/index.js +832 -864
- package/lib/solution/ScanOrder/types.js +33 -34
- package/lib/solution/ScanOrder/utils.js +409 -374
- package/lib/solution/ShopDiscount/index.js +226 -232
- package/lib/solution/ShopDiscount/types.js +15 -37
- package/lib/solution/ShopDiscount/utils.js +300 -172
- package/lib/solution/UnifiedBookingSales/index.js +1035 -1201
- package/lib/solution/UnifiedBookingSales/remoteOccupancyCache.js +99 -159
- package/lib/solution/UnifiedBookingSales/types.js +10 -32
- package/lib/solution/VenueBooking/index.js +811 -879
- package/lib/solution/VenueBooking/types.js +19 -39
- package/lib/solution/VenueBooking/utils/dateSummary.js +27 -56
- package/lib/solution/VenueBooking/utils/resource.js +31 -54
- package/lib/solution/VenueBooking/utils/slotMerge.js +94 -107
- package/lib/solution/VenueBooking/utils/timeSlot.js +132 -132
- package/lib/solution/VenueBooking/utils.js +130 -67
- package/lib/solution/index.js +124 -41
- package/lib/store/createStore.js +32 -29
- package/lib/types/index.js +4 -16
- package/lib/utils/payment-number.js +26 -46
- package/lib/utils/task.js +36 -36
- package/lib/utils/watch.js +81 -47
- package/package.json +2 -1
|
@@ -1,222 +1,269 @@
|
|
|
1
|
-
|
|
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);
|
|
1
|
+
"use strict";
|
|
28
2
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.derivePresetStartTimeFromDate = derivePresetStartTimeFromDate;
|
|
7
|
+
exports.getIsAutoClose = getIsAutoClose;
|
|
8
|
+
exports.getProductExtend = getProductExtend;
|
|
9
|
+
exports.getServiceStartTimeAndEndTime = getServiceStartTimeAndEndTime;
|
|
10
|
+
Object.defineProperty(exports, "getSumCapacity", {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _resources.getSumCapacity;
|
|
14
|
+
}
|
|
38
15
|
});
|
|
39
|
-
|
|
40
|
-
var
|
|
41
|
-
var
|
|
42
|
-
var
|
|
43
|
-
var
|
|
44
|
-
var
|
|
45
|
-
var
|
|
16
|
+
exports.getTimeObj = getTimeObj;
|
|
17
|
+
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
18
|
+
var _resources = require("./resources");
|
|
19
|
+
var _resourceSelection = require("./resourceSelection");
|
|
20
|
+
var _serviceTimes = require("./serviceTimes");
|
|
21
|
+
var _timeSlices = require("./timeSlices");
|
|
22
|
+
var _flexible = require("./flexible");
|
|
23
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
24
|
+
/**
|
|
25
|
+
* 上下文(与 info2 state.bookingConfig / state.service / state.date 一一对应)。
|
|
26
|
+
*
|
|
27
|
+
* 设计原则:所有助手函数都通过 context 显式拿数据,**不读 mini-redux**,
|
|
28
|
+
* 让 OS 这层完全可在 Node 单测下运行(dayjs 在 Node 也是纯函数)。
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
/** 从 BookingContext.date 提取 HH:mm(仅当日期带有效时分时)。 */
|
|
46
32
|
function derivePresetStartTimeFromDate(date) {
|
|
47
|
-
if (date == null)
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const hhmm = d.format("HH:mm");
|
|
53
|
-
if (hhmm === "00:00")
|
|
54
|
-
return void 0;
|
|
33
|
+
if (date == null) return undefined;
|
|
34
|
+
const d = (0, _dayjs.default)(date);
|
|
35
|
+
if (!d.isValid()) return undefined;
|
|
36
|
+
const hhmm = d.format('HH:mm');
|
|
37
|
+
if (hhmm === '00:00') return undefined;
|
|
55
38
|
return hhmm;
|
|
56
39
|
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* 取预约时间偏好(sequential / parallel);默认 sequential。
|
|
43
|
+
*/
|
|
57
44
|
function getAppointmentTimingPreference(ctx) {
|
|
58
|
-
|
|
59
|
-
return ((_c = (_b = (_a = ctx == null ? void 0 : ctx.bookingConfig) == null ? void 0 : _a.config) == null ? void 0 : _b.information_tab) == null ? void 0 : _c.appointment_timing_preference) || "sequential";
|
|
45
|
+
return ctx?.bookingConfig?.config?.information_tab?.appointment_timing_preference || 'sequential';
|
|
60
46
|
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* 灵活时长选项(cacheItem.duration.type === 'flexible' 时)。
|
|
50
|
+
*/
|
|
61
51
|
function getFlexibleOption(params) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
);
|
|
70
|
-
const
|
|
71
|
-
const
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
);
|
|
78
|
-
const timeValue = endDate.diff(startDate, "minute");
|
|
79
|
-
return { label: String(timeValue), value: import_flexible.flexibleObj.create(timeValue) };
|
|
52
|
+
const {
|
|
53
|
+
cacheItem,
|
|
54
|
+
useStartTime
|
|
55
|
+
} = params;
|
|
56
|
+
const duration = (0, _flexible.getDurationValue)(cacheItem?.duration);
|
|
57
|
+
if (duration !== 'flexible') return null;
|
|
58
|
+
const startDate = (0, _dayjs.default)(`${(0, _dayjs.default)(cacheItem?._extend?.start_date).format('YYYY-MM-DD')} ${useStartTime || cacheItem?._extend?.start_time || '00:00'}`);
|
|
59
|
+
const usable = (0, _resources.getUsableTime)(cacheItem);
|
|
60
|
+
const usableEndAt = usable?._extend?.usableTime?.end_at ? (0, _dayjs.default)(usable._extend.usableTime.end_at) : null;
|
|
61
|
+
const endDate = (0, _timeSlices.getEndDate)(startDate, 'flexible', usableEndAt, params.ctx?.shopOpeningHours);
|
|
62
|
+
const timeValue = endDate.diff(startDate, 'minute');
|
|
63
|
+
return {
|
|
64
|
+
label: String(timeValue),
|
|
65
|
+
value: _flexible.flexibleObj.create(timeValue)
|
|
66
|
+
};
|
|
80
67
|
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* 时间切片对象(含灵活时长选项)。与 info2 `getTimeObj` 等价。
|
|
71
|
+
*/
|
|
81
72
|
function getTimeObj(params) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
73
|
+
const {
|
|
74
|
+
cacheItem,
|
|
75
|
+
useStartTime,
|
|
76
|
+
useDuration,
|
|
77
|
+
ctx
|
|
78
|
+
} = params;
|
|
79
|
+
const isMultiDay = (0, _serviceTimes.isMultiDayProduct)(cacheItem);
|
|
80
|
+
const flexibleOption = getFlexibleOption({
|
|
81
|
+
cacheItem,
|
|
82
|
+
useStartTime,
|
|
83
|
+
ctx
|
|
84
|
+
});
|
|
86
85
|
const {
|
|
87
86
|
timeSlices,
|
|
88
87
|
durationSlicesBasedOnTime
|
|
89
|
-
} = (0,
|
|
90
|
-
(_c = (_b = (_a = ctx == null ? void 0 : ctx.bookingConfig) == null ? void 0 : _a.config) == null ? void 0 : _b.basic) == null ? void 0 : _c.service_time,
|
|
91
|
-
isMultiDay
|
|
92
|
-
);
|
|
88
|
+
} = (0, _timeSlices.sliceDayIntoFiveMinutes)(ctx?.bookingConfig?.config?.basic?.service_time, isMultiDay);
|
|
93
89
|
if (flexibleOption) {
|
|
94
90
|
durationSlicesBasedOnTime.unshift(flexibleOption);
|
|
95
91
|
}
|
|
96
|
-
if (useDuration && !durationSlicesBasedOnTime.some(
|
|
92
|
+
if (useDuration && !durationSlicesBasedOnTime.some(d => d.value === useDuration)) {
|
|
97
93
|
durationSlicesBasedOnTime.unshift({
|
|
98
94
|
label: String(useDuration),
|
|
99
95
|
value: useDuration
|
|
100
96
|
});
|
|
101
97
|
}
|
|
102
|
-
return {
|
|
98
|
+
return {
|
|
99
|
+
timeSlices,
|
|
100
|
+
durationSlicesBasedOnTime
|
|
101
|
+
};
|
|
103
102
|
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* 计算商品行 _extend(包含 start_time / endDate / duration / start_date / end_date / sub_type 等)。
|
|
106
|
+
* 与 info2 `utilsByBooking.ts#getServiceStartTimeAndEndTime` 等价;显著差异:
|
|
107
|
+
* - 不读 `state.service.value` / `mini-redux`,由 ctx.previousService 显式注入。
|
|
108
|
+
* - 不读 `sessionStorage.serviceParams`,由 ctx.presetStartTime / ctx.resourceIdFromCalendar 注入。
|
|
109
|
+
* - cacheItem.isCustomItem → 直接返回 `{ duration: null }`。
|
|
110
|
+
*/
|
|
104
111
|
function getServiceStartTimeAndEndTime(params) {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
112
|
+
const {
|
|
113
|
+
cacheItem,
|
|
114
|
+
timeObj,
|
|
115
|
+
ctx
|
|
116
|
+
} = params;
|
|
117
|
+
if (cacheItem?.isCustomItem) {
|
|
118
|
+
return {
|
|
119
|
+
duration: null
|
|
120
|
+
};
|
|
109
121
|
}
|
|
110
122
|
const appointmentTimingPreference = getAppointmentTimingPreference(ctx);
|
|
111
123
|
const lastServer = ctx.previousService || null;
|
|
112
124
|
const resolveDuration = () => {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
125
|
+
if ((0, _serviceTimes.isMultiDayProduct)(cacheItem)) return (0, _serviceTimes.getDays)(cacheItem, 'days');
|
|
126
|
+
return (0, _timeSlices.findNextDuration)(cacheItem.duration, timeObj.durationSlicesBasedOnTime, cacheItem?.duration?.value);
|
|
127
|
+
};
|
|
128
|
+
let _extend = {
|
|
129
|
+
duration: resolveDuration()
|
|
117
130
|
};
|
|
118
|
-
let _extend = { duration: resolveDuration() };
|
|
119
131
|
if (lastServer) {
|
|
120
|
-
const lastStart =
|
|
121
|
-
const lastEnd =
|
|
122
|
-
if (appointmentTimingPreference ===
|
|
123
|
-
_extend.start_time = (0,
|
|
124
|
-
} else if ((0,
|
|
125
|
-
_extend.start_time =
|
|
132
|
+
const lastStart = lastServer._extend?.startDate;
|
|
133
|
+
const lastEnd = lastServer._extend?.endDate;
|
|
134
|
+
if (appointmentTimingPreference === 'parallel') {
|
|
135
|
+
_extend.start_time = (0, _dayjs.default)(lastStart).format('HH:mm');
|
|
136
|
+
} else if ((0, _dayjs.default)(lastEnd).isAfter((0, _dayjs.default)(lastStart), 'day')) {
|
|
137
|
+
_extend.start_time = timeObj.timeSlices[timeObj.timeSlices.length - 1]?.value;
|
|
126
138
|
} else {
|
|
127
|
-
_extend.start_time = lastEnd ? (0,
|
|
139
|
+
_extend.start_time = lastEnd ? (0, _dayjs.default)(lastEnd).format('HH:mm') : (0, _dayjs.default)().format('HH:mm');
|
|
128
140
|
}
|
|
129
141
|
} else {
|
|
130
142
|
const presetStartTime = ctx.presetStartTime;
|
|
131
|
-
|
|
143
|
+
// 与 info2 getServiceStartTimeAndEndTime 一致:日历/顶部日期带 HH:mm 时原样使用,
|
|
144
|
+
// 不做 findNextSlice 栅格对齐(否则 01:47 会被抬到 01:50)。
|
|
145
|
+
if (presetStartTime && presetStartTime !== '00:00') {
|
|
132
146
|
_extend.start_time = presetStartTime;
|
|
133
147
|
} else if (cacheItem.currentDefaultTime) {
|
|
134
148
|
_extend.start_time = cacheItem.currentDefaultTime;
|
|
135
149
|
} else {
|
|
136
|
-
_extend.start_time = (0,
|
|
150
|
+
_extend.start_time = (0, _dayjs.default)().format('HH:mm');
|
|
137
151
|
}
|
|
138
152
|
}
|
|
139
|
-
_extend = {
|
|
140
|
-
|
|
153
|
+
_extend = {
|
|
154
|
+
..._extend,
|
|
155
|
+
...cacheItem._extend
|
|
156
|
+
};
|
|
157
|
+
const {
|
|
158
|
+
startDate,
|
|
159
|
+
endDate
|
|
160
|
+
} = (0, _serviceTimes.getServiceTimes)({
|
|
161
|
+
...cacheItem,
|
|
162
|
+
_extend
|
|
163
|
+
});
|
|
141
164
|
_extend.startDate = startDate;
|
|
142
165
|
_extend.endDate = endDate;
|
|
143
|
-
if ((0,
|
|
144
|
-
_extend.start_time = _extend.start_time || startDate.format(
|
|
145
|
-
_extend.end_time = _extend.end_time || endDate.format(
|
|
166
|
+
if ((0, _serviceTimes.isMultiDayProduct)(cacheItem)) {
|
|
167
|
+
_extend.start_time = _extend.start_time || startDate.format('HH:mm');
|
|
168
|
+
_extend.end_time = _extend.end_time || endDate.format('HH:mm');
|
|
146
169
|
_extend.start_date = _extend.start_date ?? startDate;
|
|
147
170
|
_extend.end_date = _extend.end_date ?? endDate;
|
|
148
171
|
}
|
|
149
|
-
const session =
|
|
150
|
-
if ((0,
|
|
151
|
-
const baseDate = ctx.date ? (0,
|
|
152
|
-
const startAt = (0,
|
|
153
|
-
const endAt = (0,
|
|
172
|
+
const session = cacheItem?._extend?.other?.session;
|
|
173
|
+
if ((0, _serviceTimes.isSessionProduct)(cacheItem) && session) {
|
|
174
|
+
const baseDate = ctx.date ? (0, _dayjs.default)(ctx.date) : (0, _dayjs.default)();
|
|
175
|
+
const startAt = (0, _dayjs.default)(`${baseDate.format('YYYY-MM-DD')} ${(0, _dayjs.default)(session.start_at).format('HH:mm:ss')}`);
|
|
176
|
+
const endAt = (0, _dayjs.default)(`${baseDate.format('YYYY-MM-DD')} ${(0, _dayjs.default)(session.end_at).format('HH:mm:ss')}`);
|
|
154
177
|
_extend.start_date = startAt;
|
|
155
178
|
_extend.startDate = startAt;
|
|
156
179
|
_extend.start_time = session.start_time;
|
|
157
180
|
_extend.end_date = endAt;
|
|
158
181
|
_extend.endDate = endAt;
|
|
159
182
|
_extend.end_time = session.end_time;
|
|
160
|
-
_extend.duration = (0,
|
|
183
|
+
_extend.duration = (0, _serviceTimes.getDays)({
|
|
184
|
+
_extend
|
|
185
|
+
}, 'minutes');
|
|
161
186
|
}
|
|
162
187
|
return _extend;
|
|
163
188
|
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* 综合:把 cacheItem 拼装出完整的 _extend / _data(资源 / 容量 / timeObj),并标记 autoClose。
|
|
192
|
+
* 与 info2 `service/addService/utils.tsx#getProductExtend` 等价;剥 React `console.time` / JSX。
|
|
193
|
+
*
|
|
194
|
+
* 入参 ctx 必须至少给:bookingConfig / resourcesOriginMap / resourcesOrigin / date。
|
|
195
|
+
*/
|
|
164
196
|
function getProductExtend(params) {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
197
|
+
const {
|
|
198
|
+
cacheItem,
|
|
199
|
+
ctx,
|
|
200
|
+
isDisabledTime
|
|
201
|
+
} = params;
|
|
202
|
+
const isNew = cacheItem.new || !cacheItem._extend?.endDate;
|
|
203
|
+
const _cacheItem = {
|
|
204
|
+
...cacheItem
|
|
205
|
+
};
|
|
169
206
|
const resourcesOriginMap = ctx.resourcesOriginMap || {};
|
|
170
207
|
_cacheItem._data = {};
|
|
171
|
-
if ((0,
|
|
208
|
+
if ((0, _serviceTimes.isMultiDayProduct)(cacheItem)) {
|
|
172
209
|
_cacheItem._extend = _cacheItem._extend || {};
|
|
173
|
-
_cacheItem._extend.holder_id =
|
|
174
|
-
_cacheItem._extend.sub_type =
|
|
210
|
+
_cacheItem._extend.holder_id = cacheItem?._extend?.holder_id || [];
|
|
211
|
+
_cacheItem._extend.sub_type = 'days';
|
|
175
212
|
}
|
|
176
213
|
if (isNew) {
|
|
177
|
-
_cacheItem._data.timeObj = getTimeObj({
|
|
214
|
+
_cacheItem._data.timeObj = getTimeObj({
|
|
215
|
+
cacheItem,
|
|
216
|
+
ctx
|
|
217
|
+
});
|
|
178
218
|
_cacheItem._extend = getServiceStartTimeAndEndTime({
|
|
179
219
|
cacheItem,
|
|
180
220
|
timeObj: _cacheItem._data.timeObj,
|
|
181
221
|
ctx
|
|
182
222
|
});
|
|
183
223
|
_cacheItem._data.capacitys = cacheItem.capacity;
|
|
184
|
-
_cacheItem._data.resourcesOrigin = (0,
|
|
185
|
-
resourceTab:
|
|
224
|
+
_cacheItem._data.resourcesOrigin = (0, _resources.getResourceByIds)(resourcesOriginMap, cacheItem, {
|
|
225
|
+
resourceTab: ctx?.bookingConfig?.config?.resource_tab,
|
|
186
226
|
resourcesOrigin: ctx.resourcesOrigin || []
|
|
187
227
|
});
|
|
188
|
-
_cacheItem._extend.capacity = (0,
|
|
228
|
+
_cacheItem._extend.capacity = (0, _resources.setDefaultCapacitys)({
|
|
189
229
|
capacitys: _cacheItem._data.capacitys,
|
|
190
230
|
cacheItem: _cacheItem
|
|
191
231
|
});
|
|
192
|
-
const {
|
|
232
|
+
const {
|
|
233
|
+
list,
|
|
234
|
+
maps
|
|
235
|
+
} = (0, _resources.formatResources)({
|
|
193
236
|
cacheItem: _cacheItem,
|
|
194
237
|
resourcesOrigin: _cacheItem._data.resourcesOrigin
|
|
195
238
|
});
|
|
196
239
|
_cacheItem._data.resources = list;
|
|
197
240
|
_cacheItem._data.resourceMaps = maps;
|
|
198
|
-
_cacheItem._extend.resource = (0,
|
|
241
|
+
_cacheItem._extend.resource = (0, _resources.setDefaultResource)({
|
|
199
242
|
cacheItem: _cacheItem,
|
|
200
243
|
resources: _cacheItem._data.resources,
|
|
201
244
|
resourceIdFromCalendar: ctx.resourceIdFromCalendar,
|
|
202
245
|
isAutoAllocationOn: ctx.isAutoAllocationOn
|
|
203
246
|
});
|
|
204
|
-
|
|
247
|
+
|
|
248
|
+
// 灵活时长二次计算(资源默认选中后,按 usableTime 重算 flexible 分钟数)
|
|
249
|
+
if ((0, _flexible.isProductFlexibleDuration)(_cacheItem?.duration)) {
|
|
205
250
|
_cacheItem._data.timeObj = getTimeObj({
|
|
206
251
|
cacheItem: _cacheItem,
|
|
207
252
|
useStartTime: _cacheItem._extend.start_time,
|
|
208
253
|
ctx
|
|
209
254
|
});
|
|
210
|
-
_cacheItem._extend.duration =
|
|
211
|
-
const {
|
|
255
|
+
_cacheItem._extend.duration = _cacheItem._data.timeObj?.durationSlicesBasedOnTime?.[0]?.value;
|
|
256
|
+
const {
|
|
257
|
+
endDate
|
|
258
|
+
} = (0, _serviceTimes.getServiceTimes)(_cacheItem);
|
|
212
259
|
_cacheItem._extend.endDate = endDate;
|
|
213
260
|
}
|
|
214
261
|
_cacheItem.autoClose = getIsAutoClose(_cacheItem, ctx.isAutoAllocationOn || (() => true));
|
|
215
|
-
if (_cacheItem._extend.bundle_edit !==
|
|
262
|
+
if (_cacheItem._extend.bundle_edit !== undefined) {
|
|
216
263
|
_cacheItem._extend.bundle_edit = 1;
|
|
217
264
|
}
|
|
218
265
|
if (!isDisabledTime) {
|
|
219
|
-
_cacheItem._time =
|
|
266
|
+
_cacheItem._time = new Date().getTime();
|
|
220
267
|
}
|
|
221
268
|
} else {
|
|
222
269
|
if (!_cacheItem._data.capacitys) {
|
|
@@ -224,19 +271,25 @@ function getProductExtend(params) {
|
|
|
224
271
|
}
|
|
225
272
|
if (!_cacheItem._data.resourcesOrigin) {
|
|
226
273
|
const extraResources = [];
|
|
227
|
-
if (Array.isArray(
|
|
228
|
-
_cacheItem._extend.event_resources.forEach(
|
|
229
|
-
extraResources.push({
|
|
274
|
+
if (Array.isArray(_cacheItem._extend?.event_resources)) {
|
|
275
|
+
_cacheItem._extend.event_resources.forEach(er => {
|
|
276
|
+
extraResources.push({
|
|
277
|
+
form_id: er.form_id,
|
|
278
|
+
id: er.relation_id
|
|
279
|
+
});
|
|
230
280
|
});
|
|
231
281
|
}
|
|
232
|
-
_cacheItem._data.resourcesOrigin = (0,
|
|
282
|
+
_cacheItem._data.resourcesOrigin = (0, _resources.getResourceByIds)(resourcesOriginMap, cacheItem, {
|
|
233
283
|
extraResources,
|
|
234
|
-
resourceTab:
|
|
284
|
+
resourceTab: ctx?.bookingConfig?.config?.resource_tab,
|
|
235
285
|
resourcesOrigin: ctx.resourcesOrigin || []
|
|
236
286
|
});
|
|
237
287
|
}
|
|
238
288
|
if (!_cacheItem._data.resources) {
|
|
239
|
-
const {
|
|
289
|
+
const {
|
|
290
|
+
list,
|
|
291
|
+
maps
|
|
292
|
+
} = (0, _resources.formatResources)({
|
|
240
293
|
cacheItem: _cacheItem,
|
|
241
294
|
resourcesOrigin: _cacheItem._data.resourcesOrigin
|
|
242
295
|
});
|
|
@@ -245,40 +298,34 @@ function getProductExtend(params) {
|
|
|
245
298
|
}
|
|
246
299
|
_cacheItem._data.timeObj = getTimeObj({
|
|
247
300
|
cacheItem: _cacheItem,
|
|
248
|
-
useStartTime:
|
|
301
|
+
useStartTime: _cacheItem._extend?.start_time,
|
|
249
302
|
ctx
|
|
250
303
|
});
|
|
251
304
|
}
|
|
252
305
|
return _cacheItem;
|
|
253
306
|
}
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* 是否可自动关闭弹窗(不需要用户进 EditService 抽屉)。
|
|
310
|
+
* 与 info2 `service/addService/utils.tsx#getIsAutoClose` 等价;
|
|
311
|
+
* `getAutoAllocationStorage` 抽象为入参 `isAutoAllocationOn(formId)`。
|
|
312
|
+
*/
|
|
254
313
|
function getIsAutoClose(cacheItem, isAutoAllocationOn) {
|
|
255
|
-
|
|
256
|
-
if ((0, import_resourceSelection.productNeedsResourceExtend)(cacheItem) && !(0, import_resourceSelection.hasActualResourceSelection)(cacheItem)) {
|
|
314
|
+
if ((0, _resourceSelection.productNeedsResourceExtend)(cacheItem) && !(0, _resourceSelection.hasActualResourceSelection)(cacheItem)) {
|
|
257
315
|
return false;
|
|
258
316
|
}
|
|
259
|
-
if (
|
|
260
|
-
const resources =
|
|
317
|
+
if (cacheItem._data?.capacitys?.type !== 'custom') {
|
|
318
|
+
const resources = cacheItem?._data?.resources || [];
|
|
261
319
|
if (resources.length === 1) {
|
|
262
320
|
const first = resources[0];
|
|
263
|
-
if (
|
|
321
|
+
if (first.select_type?.type === 'single' && (first.default_resource || []).length > 0) {
|
|
264
322
|
return true;
|
|
265
323
|
}
|
|
266
324
|
}
|
|
267
325
|
}
|
|
268
|
-
const entries = Object.entries(
|
|
326
|
+
const entries = Object.entries(cacheItem._extend?.resource || {});
|
|
269
327
|
if (entries.length === 0) {
|
|
270
|
-
return !(0,
|
|
328
|
+
return !(0, _resourceSelection.productNeedsResourceExtend)(cacheItem);
|
|
271
329
|
}
|
|
272
|
-
return entries.every(
|
|
273
|
-
|
|
274
|
-
);
|
|
275
|
-
}
|
|
276
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
277
|
-
0 && (module.exports = {
|
|
278
|
-
derivePresetStartTimeFromDate,
|
|
279
|
-
getIsAutoClose,
|
|
280
|
-
getProductExtend,
|
|
281
|
-
getServiceStartTimeAndEndTime,
|
|
282
|
-
getSumCapacity,
|
|
283
|
-
getTimeObj
|
|
284
|
-
});
|
|
330
|
+
return entries.every(([key, value]) => isAutoAllocationOn(key) && Array.isArray(value) && value.length > 0);
|
|
331
|
+
}
|
|
@@ -1,55 +1,56 @@
|
|
|
1
|
-
|
|
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);
|
|
1
|
+
"use strict";
|
|
28
2
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
__export(resourceErrors_exports, {
|
|
32
|
-
getResourceErrors: () => getResourceErrors
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
33
5
|
});
|
|
34
|
-
|
|
35
|
-
var
|
|
36
|
-
var
|
|
6
|
+
exports.getResourceErrors = getResourceErrors;
|
|
7
|
+
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
8
|
+
var _serviceTimes = require("./serviceTimes");
|
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
+
/**
|
|
11
|
+
* 结构化的「资源不可用」原因(替代 info2 `getErrorList` 输出的 i18n 文案 + type 字段)。
|
|
12
|
+
*
|
|
13
|
+
* 与 info2 type 字段映射:
|
|
14
|
+
* - `no_product` ↔ type='products'
|
|
15
|
+
* - `time_out_of_range` ↔ type='time'
|
|
16
|
+
* - `count_out_of_range` ↔ type='limit'
|
|
17
|
+
* - `resource_unbound` ↔ type='unbound'
|
|
18
|
+
*
|
|
19
|
+
* OS 这边不耦合 i18n 文案,UI 拿到 reason + params 后自行渲染(参考 docs/SDK 中给出的 i18n key 对照表)。
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* 替代 info2 `utilsByBooking.ts#getErrorList`,输出结构化错误。
|
|
24
|
+
*
|
|
25
|
+
* 行为对齐:
|
|
26
|
+
* 1. cacheItem 没有 id → `no_product`(与 info2 `!cacheItem?.id` 分支等价)。
|
|
27
|
+
* 2. 资源 null / 无 _extend → 返回 []。
|
|
28
|
+
* 3. resource.usable=false 时:
|
|
29
|
+
* - 没有 _extend.usableTime → `time_out_of_range`
|
|
30
|
+
* - 有 usableTime 但 `_extend.isCountRange=false` → `count_out_of_range`
|
|
31
|
+
* 4. resource.unbound=true → 追加 `resource_unbound`。
|
|
32
|
+
* 5. 不再耦合 `_data.resourceMaps[form_id].type === 'single'` 判断(与 info2 实际未使用此变量一致)。
|
|
33
|
+
*/
|
|
37
34
|
function getResourceErrors(resource, cacheItem) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
35
|
+
if (!cacheItem?.id) {
|
|
36
|
+
return [{
|
|
37
|
+
reason: 'no_product',
|
|
38
|
+
params: {}
|
|
39
|
+
}];
|
|
41
40
|
}
|
|
42
|
-
if (!resource)
|
|
43
|
-
return [];
|
|
41
|
+
if (!resource) return [];
|
|
44
42
|
const list = [];
|
|
45
43
|
if (!resource.usable) {
|
|
46
|
-
const {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
44
|
+
const {
|
|
45
|
+
startDate,
|
|
46
|
+
endDate
|
|
47
|
+
} = (0, _serviceTimes.getServiceTimes)(cacheItem);
|
|
48
|
+
const startText = startDate.format('hh:mm A');
|
|
49
|
+
const endText = endDate.format('hh:mm A');
|
|
50
|
+
const isCrossDay = (0, _dayjs.default)(endDate).isAfter(startDate, 'day');
|
|
51
|
+
if (!resource._extend?.usableTime) {
|
|
51
52
|
list.push({
|
|
52
|
-
reason:
|
|
53
|
+
reason: 'time_out_of_range',
|
|
53
54
|
params: {
|
|
54
55
|
labelText: resource.labelText,
|
|
55
56
|
startText,
|
|
@@ -57,9 +58,9 @@ function getResourceErrors(resource, cacheItem) {
|
|
|
57
58
|
isCrossDay
|
|
58
59
|
}
|
|
59
60
|
});
|
|
60
|
-
} else if (!
|
|
61
|
+
} else if (!resource._extend?.usableTime?._extend?.isCountRange) {
|
|
61
62
|
list.push({
|
|
62
|
-
reason:
|
|
63
|
+
reason: 'count_out_of_range',
|
|
63
64
|
params: {
|
|
64
65
|
labelText: resource.labelText,
|
|
65
66
|
startText,
|
|
@@ -70,11 +71,10 @@ function getResourceErrors(resource, cacheItem) {
|
|
|
70
71
|
}
|
|
71
72
|
}
|
|
72
73
|
if (resource.unbound) {
|
|
73
|
-
list.push({
|
|
74
|
+
list.push({
|
|
75
|
+
reason: 'resource_unbound',
|
|
76
|
+
params: {}
|
|
77
|
+
});
|
|
74
78
|
}
|
|
75
79
|
return list;
|
|
76
|
-
}
|
|
77
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
78
|
-
0 && (module.exports = {
|
|
79
|
-
getResourceErrors
|
|
80
|
-
});
|
|
80
|
+
}
|