@pisell/pisellos 2.2.169 → 2.2.171

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.
Files changed (146) hide show
  1. package/dist/modules/Customer/index.d.ts +0 -6
  2. package/dist/modules/Customer/index.js +83 -129
  3. package/dist/modules/Customer/types.d.ts +0 -2
  4. package/dist/modules/Discount/index.d.ts +4 -2
  5. package/dist/modules/Discount/index.js +93 -8
  6. package/dist/modules/Discount/types.d.ts +7 -1
  7. package/dist/modules/Order/index.d.ts +16 -28
  8. package/dist/modules/Order/index.js +322 -695
  9. package/dist/modules/Order/types.d.ts +14 -49
  10. package/dist/modules/Order/types.js +0 -2
  11. package/dist/modules/Order/utils.d.ts +0 -17
  12. package/dist/modules/Order/utils.js +26 -96
  13. package/dist/modules/Rules/index.d.ts +0 -4
  14. package/dist/modules/Rules/index.js +10 -26
  15. package/dist/modules/SalesSummary/index.js +2 -4
  16. package/dist/modules/index.d.ts +0 -1
  17. package/dist/modules/index.js +1 -2
  18. package/dist/server/modules/order/utils/filterOrders.js +6 -20
  19. package/dist/solution/BaseSales/index.d.ts +7 -46
  20. package/dist/solution/BaseSales/index.js +315 -1009
  21. package/dist/solution/BaseSales/types.d.ts +1 -53
  22. package/dist/solution/BaseSales/types.js +1 -3
  23. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +15 -65
  24. package/dist/solution/BaseSales/utils.js +8 -46
  25. package/dist/solution/BookingTicket/index.d.ts +2 -134
  26. package/dist/solution/BookingTicket/index.js +175 -768
  27. package/dist/solution/BookingTicket/types.d.ts +0 -2
  28. package/dist/solution/BookingTicket/types.js +0 -3
  29. package/dist/solution/ScanOrder/index.d.ts +3 -9
  30. package/dist/solution/ScanOrder/index.js +128 -231
  31. package/dist/solution/ScanOrder/utils.js +8 -46
  32. package/dist/solution/ShopDiscount/index.d.ts +1 -0
  33. package/dist/solution/ShopDiscount/index.js +23 -18
  34. package/dist/solution/VenueBooking/index.d.ts +9 -5
  35. package/dist/solution/VenueBooking/index.js +55 -103
  36. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +0 -4
  37. package/dist/solution/VenueBooking/utils/slotMerge.js +0 -10
  38. package/lib/modules/Customer/index.d.ts +0 -6
  39. package/lib/modules/Customer/index.js +11 -26
  40. package/lib/modules/Customer/types.d.ts +0 -2
  41. package/lib/modules/Discount/index.d.ts +4 -2
  42. package/lib/modules/Discount/index.js +63 -8
  43. package/lib/modules/Discount/types.d.ts +7 -1
  44. package/lib/modules/Order/index.d.ts +16 -28
  45. package/lib/modules/Order/index.js +84 -336
  46. package/lib/modules/Order/types.d.ts +14 -49
  47. package/lib/modules/Order/utils.d.ts +0 -17
  48. package/lib/modules/Order/utils.js +18 -104
  49. package/lib/modules/Rules/index.d.ts +0 -4
  50. package/lib/modules/Rules/index.js +14 -22
  51. package/lib/modules/SalesSummary/index.js +2 -4
  52. package/lib/modules/index.d.ts +0 -1
  53. package/lib/modules/index.js +1 -3
  54. package/lib/server/modules/order/utils/filterOrders.js +4 -12
  55. package/lib/solution/BaseSales/index.d.ts +7 -46
  56. package/lib/solution/BaseSales/index.js +20 -434
  57. package/lib/solution/BaseSales/types.d.ts +1 -53
  58. package/lib/solution/BaseSales/types.js +1 -3
  59. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +11 -70
  60. package/lib/solution/BaseSales/utils.js +6 -46
  61. package/lib/solution/BookingTicket/index.d.ts +2 -134
  62. package/lib/solution/BookingTicket/index.js +8 -341
  63. package/lib/solution/BookingTicket/types.d.ts +0 -2
  64. package/lib/solution/BookingTicket/types.js +0 -6
  65. package/lib/solution/ScanOrder/index.d.ts +3 -9
  66. package/lib/solution/ScanOrder/index.js +66 -147
  67. package/lib/solution/ScanOrder/utils.js +6 -46
  68. package/lib/solution/ShopDiscount/index.d.ts +1 -0
  69. package/lib/solution/ShopDiscount/index.js +4 -2
  70. package/lib/solution/VenueBooking/index.d.ts +9 -5
  71. package/lib/solution/VenueBooking/index.js +14 -50
  72. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +0 -4
  73. package/lib/solution/VenueBooking/utils/slotMerge.js +0 -10
  74. package/package.json +2 -2
  75. package/dist/modules/BookingContext/index.d.ts +0 -37
  76. package/dist/modules/BookingContext/index.js +0 -436
  77. package/dist/modules/BookingContext/types.d.ts +0 -102
  78. package/dist/modules/BookingContext/types.js +0 -51
  79. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +0 -16
  80. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +0 -193
  81. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +0 -8
  82. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +0 -137
  83. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +0 -75
  84. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +0 -215
  85. package/dist/modules/BookingContext/utils/flexible.d.ts +0 -28
  86. package/dist/modules/BookingContext/utils/flexible.js +0 -56
  87. package/dist/modules/BookingContext/utils/formatResourceList.d.ts +0 -8
  88. package/dist/modules/BookingContext/utils/formatResourceList.js +0 -38
  89. package/dist/modules/BookingContext/utils/index.d.ts +0 -11
  90. package/dist/modules/BookingContext/utils/index.js +0 -11
  91. package/dist/modules/BookingContext/utils/noResource.d.ts +0 -13
  92. package/dist/modules/BookingContext/utils/noResource.js +0 -77
  93. package/dist/modules/BookingContext/utils/productExtend.d.ts +0 -72
  94. package/dist/modules/BookingContext/utils/productExtend.js +0 -339
  95. package/dist/modules/BookingContext/utils/resourceErrors.d.ts +0 -41
  96. package/dist/modules/BookingContext/utils/resourceErrors.js +0 -74
  97. package/dist/modules/BookingContext/utils/resourceSelection.d.ts +0 -7
  98. package/dist/modules/BookingContext/utils/resourceSelection.js +0 -24
  99. package/dist/modules/BookingContext/utils/resources.d.ts +0 -80
  100. package/dist/modules/BookingContext/utils/resources.js +0 -486
  101. package/dist/modules/BookingContext/utils/serviceTimes.d.ts +0 -55
  102. package/dist/modules/BookingContext/utils/serviceTimes.js +0 -151
  103. package/dist/modules/BookingContext/utils/timeSlices.d.ts +0 -42
  104. package/dist/modules/BookingContext/utils/timeSlices.js +0 -100
  105. package/dist/modules/Order/utils/manualProductDiscount.d.ts +0 -106
  106. package/dist/modules/Order/utils/manualProductDiscount.js +0 -212
  107. package/dist/solution/BaseSales/utils/quotationPrice.d.ts +0 -7
  108. package/dist/solution/BaseSales/utils/quotationPrice.js +0 -159
  109. package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +0 -113
  110. package/dist/solution/BookingTicket/utils/addProductDecision.js +0 -346
  111. package/lib/modules/BookingContext/index.d.ts +0 -37
  112. package/lib/modules/BookingContext/index.js +0 -297
  113. package/lib/modules/BookingContext/types.d.ts +0 -102
  114. package/lib/modules/BookingContext/types.js +0 -34
  115. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +0 -16
  116. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +0 -207
  117. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +0 -8
  118. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +0 -141
  119. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +0 -75
  120. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +0 -198
  121. package/lib/modules/BookingContext/utils/flexible.d.ts +0 -28
  122. package/lib/modules/BookingContext/utils/flexible.js +0 -80
  123. package/lib/modules/BookingContext/utils/formatResourceList.d.ts +0 -8
  124. package/lib/modules/BookingContext/utils/formatResourceList.js +0 -50
  125. package/lib/modules/BookingContext/utils/index.d.ts +0 -11
  126. package/lib/modules/BookingContext/utils/index.js +0 -43
  127. package/lib/modules/BookingContext/utils/noResource.d.ts +0 -13
  128. package/lib/modules/BookingContext/utils/noResource.js +0 -90
  129. package/lib/modules/BookingContext/utils/productExtend.d.ts +0 -72
  130. package/lib/modules/BookingContext/utils/productExtend.js +0 -283
  131. package/lib/modules/BookingContext/utils/resourceErrors.d.ts +0 -41
  132. package/lib/modules/BookingContext/utils/resourceErrors.js +0 -80
  133. package/lib/modules/BookingContext/utils/resourceSelection.d.ts +0 -7
  134. package/lib/modules/BookingContext/utils/resourceSelection.js +0 -46
  135. package/lib/modules/BookingContext/utils/resources.d.ts +0 -80
  136. package/lib/modules/BookingContext/utils/resources.js +0 -377
  137. package/lib/modules/BookingContext/utils/serviceTimes.d.ts +0 -55
  138. package/lib/modules/BookingContext/utils/serviceTimes.js +0 -162
  139. package/lib/modules/BookingContext/utils/timeSlices.d.ts +0 -42
  140. package/lib/modules/BookingContext/utils/timeSlices.js +0 -124
  141. package/lib/modules/Order/utils/manualProductDiscount.d.ts +0 -106
  142. package/lib/modules/Order/utils/manualProductDiscount.js +0 -207
  143. package/lib/solution/BaseSales/utils/quotationPrice.d.ts +0 -7
  144. package/lib/solution/BaseSales/utils/quotationPrice.js +0 -201
  145. package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +0 -113
  146. package/lib/solution/BookingTicket/utils/addProductDecision.js +0 -318
@@ -1,90 +0,0 @@
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);
18
-
19
- // src/modules/BookingContext/utils/noResource.ts
20
- var noResource_exports = {};
21
- __export(noResource_exports, {
22
- getNoResource2: () => getNoResource2
23
- });
24
- module.exports = __toCommonJS(noResource_exports);
25
- function getNoResource2(other) {
26
- return {
27
- form_tag: null,
28
- policy: 148,
29
- partyroom_package: { type: "product_all" },
30
- sort: "2",
31
- status: "active",
32
- description: "",
33
- media: "",
34
- main_field: "",
35
- subtitle: "",
36
- room_name: "",
37
- labelText: "",
38
- form_record_id: 0,
39
- item_type: "resources",
40
- form_id: 0,
41
- id: 0,
42
- form_resource_sort: 0,
43
- form_title: "",
44
- capacity: 999999,
45
- form: {
46
- id: 0,
47
- shop_id: 0,
48
- title: "",
49
- navigation_display: 1,
50
- button: "",
51
- describe: "",
52
- status: "published",
53
- resource_sort: 0,
54
- code: "resources",
55
- type: "manual",
56
- version: 1,
57
- setting: null,
58
- created_at: "2000-01-01 00:00:00",
59
- updated_at: "2000-01-01 00:00:00"
60
- },
61
- times: [
62
- {
63
- keys: "noResource2-placeholder",
64
- schedule_id: 0,
65
- item_type: "resources",
66
- item_id: 0,
67
- start_date: "2000-01-01",
68
- end_date: "2300-01-01",
69
- start_time: "00:00",
70
- end_time: "23:59",
71
- is_all: 1,
72
- max_participants_type: "custom-limit",
73
- max_participants_limit: 0,
74
- relation_type: "form",
75
- start_at: "2000-01-01 00:00",
76
- end_at: "2300-01-05 23:59",
77
- is_blocked: 0,
78
- blocked_times: [],
79
- order_event_count: 0,
80
- unique: "noResource2-unique",
81
- event_list: []
82
- }
83
- ],
84
- ...other || {}
85
- };
86
- }
87
- // Annotate the CommonJS export names for ESM import in node:
88
- 0 && (module.exports = {
89
- getNoResource2
90
- });
@@ -1,72 +0,0 @@
1
- import { getSumCapacity } from './resources';
2
- import { TimeSlicesResult, TimeSlice, DurationSlice } from './timeSlices';
3
- /**
4
- * 上下文(与 info2 state.bookingConfig / state.service / state.date 一一对应)。
5
- *
6
- * 设计原则:所有助手函数都通过 context 显式拿数据,**不读 mini-redux**,
7
- * 让 OS 这层完全可在 Node 单测下运行(dayjs 在 Node 也是纯函数)。
8
- */
9
- export interface BookingCalcContext {
10
- /** 来自 `/core/board/management/config` 的整套配置;常用路径见 sliceTimeSlices / appointmentTimingPreference。 */
11
- bookingConfig?: any;
12
- /** 资源 origin map(id → resource origin)。 */
13
- resourcesOriginMap?: Record<string, any>;
14
- /** 资源全集列表(display_scope=all 时用)。 */
15
- resourcesOrigin?: any[];
16
- /** 当前选择的日期(dayjs 或 string)。 */
17
- date?: any;
18
- /** 上一个服务行(getServiceStartTimeAndEndTime 拼接续接 start_time 用)。可缺省。 */
19
- previousService?: any;
20
- /** 日历选中的资源 id(替代 info2 sessionStorage.serviceParams.resource_id)。 */
21
- resourceIdFromCalendar?: number;
22
- /** 资源自动分派开关(替代 info2 localStorage 'resource-auto-allocation');默认全开。 */
23
- isAutoAllocationOn?: (formId: any) => boolean;
24
- /** 当前预设开始时间(替代 info2 sessionStorage.serviceParams.start_date 取 HH:mm)。 */
25
- presetStartTime?: string;
26
- /** 店铺打烊时间(替代 info2 localStorage shopOpeningHours),默认 23:59。 */
27
- shopOpeningHours?: string;
28
- }
29
- /** 从 BookingContext.date 提取 HH:mm(仅当日期带有效时分时)。 */
30
- export declare function derivePresetStartTimeFromDate(date: any): string | undefined;
31
- /**
32
- * 时间切片对象(含灵活时长选项)。与 info2 `getTimeObj` 等价。
33
- */
34
- export declare function getTimeObj(params: {
35
- cacheItem: any;
36
- useStartTime?: string;
37
- useDuration?: number | string;
38
- ctx: BookingCalcContext;
39
- }): TimeSlicesResult & {
40
- timeSlices: TimeSlice[];
41
- durationSlicesBasedOnTime: DurationSlice[];
42
- };
43
- /**
44
- * 计算商品行 _extend(包含 start_time / endDate / duration / start_date / end_date / sub_type 等)。
45
- * 与 info2 `utilsByBooking.ts#getServiceStartTimeAndEndTime` 等价;显著差异:
46
- * - 不读 `state.service.value` / `mini-redux`,由 ctx.previousService 显式注入。
47
- * - 不读 `sessionStorage.serviceParams`,由 ctx.presetStartTime / ctx.resourceIdFromCalendar 注入。
48
- * - cacheItem.isCustomItem → 直接返回 `{ duration: null }`。
49
- */
50
- export declare function getServiceStartTimeAndEndTime(params: {
51
- cacheItem: any;
52
- timeObj: TimeSlicesResult;
53
- ctx: BookingCalcContext;
54
- }): any;
55
- /**
56
- * 综合:把 cacheItem 拼装出完整的 _extend / _data(资源 / 容量 / timeObj),并标记 autoClose。
57
- * 与 info2 `service/addService/utils.tsx#getProductExtend` 等价;剥 React `console.time` / JSX。
58
- *
59
- * 入参 ctx 必须至少给:bookingConfig / resourcesOriginMap / resourcesOrigin / date。
60
- */
61
- export declare function getProductExtend(params: {
62
- cacheItem: any;
63
- ctx: BookingCalcContext;
64
- isDisabledTime?: boolean;
65
- }): any;
66
- /**
67
- * 是否可自动关闭弹窗(不需要用户进 EditService 抽屉)。
68
- * 与 info2 `service/addService/utils.tsx#getIsAutoClose` 等价;
69
- * `getAutoAllocationStorage` 抽象为入参 `isAutoAllocationOn(formId)`。
70
- */
71
- export declare function getIsAutoClose(cacheItem: any, isAutoAllocationOn: (formId: any) => boolean): boolean;
72
- export { getSumCapacity };
@@ -1,283 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
-
29
- // src/modules/BookingContext/utils/productExtend.ts
30
- var productExtend_exports = {};
31
- __export(productExtend_exports, {
32
- derivePresetStartTimeFromDate: () => derivePresetStartTimeFromDate,
33
- getIsAutoClose: () => getIsAutoClose,
34
- getProductExtend: () => getProductExtend,
35
- getServiceStartTimeAndEndTime: () => getServiceStartTimeAndEndTime,
36
- getSumCapacity: () => import_resources.getSumCapacity,
37
- getTimeObj: () => getTimeObj
38
- });
39
- module.exports = __toCommonJS(productExtend_exports);
40
- var import_dayjs = __toESM(require("dayjs"));
41
- var import_resources = require("./resources");
42
- var import_resourceSelection = require("./resourceSelection");
43
- var import_serviceTimes = require("./serviceTimes");
44
- var import_timeSlices = require("./timeSlices");
45
- var import_flexible = require("./flexible");
46
- function derivePresetStartTimeFromDate(date) {
47
- if (date == null)
48
- return void 0;
49
- const d = (0, import_dayjs.default)(date);
50
- if (!d.isValid())
51
- return void 0;
52
- const hhmm = d.format("HH:mm");
53
- if (hhmm === "00:00")
54
- return void 0;
55
- return hhmm;
56
- }
57
- function getAppointmentTimingPreference(ctx) {
58
- var _a, _b, _c;
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";
60
- }
61
- function getFlexibleOption(params) {
62
- var _a, _b, _c, _d, _e;
63
- const { cacheItem, useStartTime } = params;
64
- const duration = (0, import_flexible.getDurationValue)(cacheItem == null ? void 0 : cacheItem.duration);
65
- if (duration !== "flexible")
66
- return null;
67
- const startDate = (0, import_dayjs.default)(
68
- `${(0, import_dayjs.default)((_a = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _a.start_date).format("YYYY-MM-DD")} ${useStartTime || ((_b = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _b.start_time) || "00:00"}`
69
- );
70
- const usable = (0, import_resources.getUsableTime)(cacheItem);
71
- const usableEndAt = ((_d = (_c = usable == null ? void 0 : usable._extend) == null ? void 0 : _c.usableTime) == null ? void 0 : _d.end_at) ? (0, import_dayjs.default)(usable._extend.usableTime.end_at) : null;
72
- const endDate = (0, import_timeSlices.getEndDate)(
73
- startDate,
74
- "flexible",
75
- usableEndAt,
76
- (_e = params.ctx) == null ? void 0 : _e.shopOpeningHours
77
- );
78
- const timeValue = endDate.diff(startDate, "minute");
79
- return { label: String(timeValue), value: import_flexible.flexibleObj.create(timeValue) };
80
- }
81
- function getTimeObj(params) {
82
- var _a, _b, _c;
83
- const { cacheItem, useStartTime, useDuration, ctx } = params;
84
- const isMultiDay = (0, import_serviceTimes.isMultiDayProduct)(cacheItem);
85
- const flexibleOption = getFlexibleOption({ cacheItem, useStartTime, ctx });
86
- const baseSlices = (0, import_timeSlices.sliceDayIntoFiveMinutes)(
87
- (_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,
88
- isMultiDay
89
- );
90
- const timeSlices = [...baseSlices.timeSlices];
91
- const durationSlicesBasedOnTime = [...baseSlices.durationSlicesBasedOnTime];
92
- if (flexibleOption) {
93
- durationSlicesBasedOnTime.unshift(flexibleOption);
94
- }
95
- if (useDuration && !durationSlicesBasedOnTime.some((d) => d.value === useDuration)) {
96
- durationSlicesBasedOnTime.unshift({
97
- label: String(useDuration),
98
- value: useDuration
99
- });
100
- }
101
- return { timeSlices, durationSlicesBasedOnTime };
102
- }
103
- function getServiceStartTimeAndEndTime(params) {
104
- var _a, _b, _c, _d, _e;
105
- const { cacheItem, timeObj, ctx } = params;
106
- if (cacheItem == null ? void 0 : cacheItem.isCustomItem) {
107
- return { duration: null };
108
- }
109
- const appointmentTimingPreference = getAppointmentTimingPreference(ctx);
110
- const lastServer = ctx.previousService || null;
111
- const resolveDuration = () => {
112
- var _a2;
113
- if ((0, import_serviceTimes.isMultiDayProduct)(cacheItem))
114
- return (0, import_serviceTimes.getDays)(cacheItem, "days");
115
- return (0, import_timeSlices.findNextDuration)(cacheItem.duration, timeObj.durationSlicesBasedOnTime, (_a2 = cacheItem == null ? void 0 : cacheItem.duration) == null ? void 0 : _a2.value);
116
- };
117
- let _extend = { duration: resolveDuration() };
118
- if (lastServer) {
119
- const lastStart = (_a = lastServer._extend) == null ? void 0 : _a.startDate;
120
- const lastEnd = (_b = lastServer._extend) == null ? void 0 : _b.endDate;
121
- if (appointmentTimingPreference === "parallel") {
122
- _extend.start_time = (0, import_dayjs.default)(lastStart).format("HH:mm");
123
- } else if ((0, import_dayjs.default)(lastEnd).isAfter((0, import_dayjs.default)(lastStart), "day")) {
124
- _extend.start_time = (_c = timeObj.timeSlices[timeObj.timeSlices.length - 1]) == null ? void 0 : _c.value;
125
- } else {
126
- _extend.start_time = lastEnd ? (0, import_dayjs.default)(lastEnd).format("HH:mm") : (0, import_dayjs.default)().format("HH:mm");
127
- }
128
- } else {
129
- const presetStartTime = ctx.presetStartTime;
130
- if (presetStartTime && presetStartTime !== "00:00") {
131
- _extend.start_time = presetStartTime;
132
- } else if (cacheItem.currentDefaultTime) {
133
- _extend.start_time = cacheItem.currentDefaultTime;
134
- } else {
135
- _extend.start_time = (0, import_dayjs.default)().format("HH:mm");
136
- }
137
- }
138
- _extend = { ..._extend, ...cacheItem._extend };
139
- const { startDate, endDate } = (0, import_serviceTimes.getServiceTimes)({ ...cacheItem, _extend });
140
- _extend.startDate = startDate;
141
- _extend.endDate = endDate;
142
- if ((0, import_serviceTimes.isMultiDayProduct)(cacheItem)) {
143
- _extend.start_time = _extend.start_time || startDate.format("HH:mm");
144
- _extend.end_time = _extend.end_time || endDate.format("HH:mm");
145
- _extend.start_date = _extend.start_date ?? startDate;
146
- _extend.end_date = _extend.end_date ?? endDate;
147
- }
148
- const session = (_e = (_d = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _d.other) == null ? void 0 : _e.session;
149
- if ((0, import_serviceTimes.isSessionProduct)(cacheItem) && session) {
150
- const baseDate = ctx.date ? (0, import_dayjs.default)(ctx.date) : (0, import_dayjs.default)();
151
- const startAt = (0, import_dayjs.default)(`${baseDate.format("YYYY-MM-DD")} ${(0, import_dayjs.default)(session.start_at).format("HH:mm:ss")}`);
152
- const endAt = (0, import_dayjs.default)(`${baseDate.format("YYYY-MM-DD")} ${(0, import_dayjs.default)(session.end_at).format("HH:mm:ss")}`);
153
- _extend.start_date = startAt;
154
- _extend.startDate = startAt;
155
- _extend.start_time = session.start_time;
156
- _extend.end_date = endAt;
157
- _extend.endDate = endAt;
158
- _extend.end_time = session.end_time;
159
- _extend.duration = (0, import_serviceTimes.getDays)({ _extend }, "minutes");
160
- }
161
- return _extend;
162
- }
163
- function getProductExtend(params) {
164
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
165
- const { cacheItem, ctx, isDisabledTime } = params;
166
- const isNew = cacheItem.new || !((_a = cacheItem._extend) == null ? void 0 : _a.endDate);
167
- const _cacheItem = { ...cacheItem };
168
- const resourcesOriginMap = ctx.resourcesOriginMap || {};
169
- _cacheItem._data = {};
170
- if ((0, import_serviceTimes.isMultiDayProduct)(cacheItem)) {
171
- _cacheItem._extend = _cacheItem._extend || {};
172
- _cacheItem._extend.holder_id = ((_b = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _b.holder_id) || [];
173
- _cacheItem._extend.sub_type = "days";
174
- }
175
- if (isNew) {
176
- _cacheItem._data.timeObj = getTimeObj({ cacheItem, ctx });
177
- _cacheItem._extend = getServiceStartTimeAndEndTime({
178
- cacheItem,
179
- timeObj: _cacheItem._data.timeObj,
180
- ctx
181
- });
182
- _cacheItem._data.capacitys = cacheItem.capacity;
183
- _cacheItem._data.resourcesOrigin = (0, import_resources.getResourceByIds)(resourcesOriginMap, cacheItem, {
184
- resourceTab: (_d = (_c = ctx == null ? void 0 : ctx.bookingConfig) == null ? void 0 : _c.config) == null ? void 0 : _d.resource_tab,
185
- resourcesOrigin: ctx.resourcesOrigin || []
186
- });
187
- _cacheItem._extend.capacity = (0, import_resources.setDefaultCapacitys)({
188
- capacitys: _cacheItem._data.capacitys,
189
- cacheItem: _cacheItem
190
- });
191
- const { list, maps } = (0, import_resources.formatResources)({
192
- cacheItem: _cacheItem,
193
- resourcesOrigin: _cacheItem._data.resourcesOrigin
194
- });
195
- _cacheItem._data.resources = list;
196
- _cacheItem._data.resourceMaps = maps;
197
- _cacheItem._extend.resource = (0, import_resources.setDefaultResource)({
198
- cacheItem: _cacheItem,
199
- resources: _cacheItem._data.resources,
200
- resourceIdFromCalendar: ctx.resourceIdFromCalendar,
201
- isAutoAllocationOn: ctx.isAutoAllocationOn
202
- });
203
- if ((0, import_flexible.isProductFlexibleDuration)(_cacheItem == null ? void 0 : _cacheItem.duration)) {
204
- _cacheItem._data.timeObj = getTimeObj({
205
- cacheItem: _cacheItem,
206
- useStartTime: _cacheItem._extend.start_time,
207
- ctx
208
- });
209
- _cacheItem._extend.duration = (_g = (_f = (_e = _cacheItem._data.timeObj) == null ? void 0 : _e.durationSlicesBasedOnTime) == null ? void 0 : _f[0]) == null ? void 0 : _g.value;
210
- const { endDate } = (0, import_serviceTimes.getServiceTimes)(_cacheItem);
211
- _cacheItem._extend.endDate = endDate;
212
- }
213
- _cacheItem.autoClose = getIsAutoClose(_cacheItem, ctx.isAutoAllocationOn || (() => true));
214
- if (_cacheItem._extend.bundle_edit !== void 0) {
215
- _cacheItem._extend.bundle_edit = 1;
216
- }
217
- if (!isDisabledTime) {
218
- _cacheItem._time = (/* @__PURE__ */ new Date()).getTime();
219
- }
220
- } else {
221
- if (!_cacheItem._data.capacitys) {
222
- _cacheItem._data.capacitys = cacheItem.capacity;
223
- }
224
- if (!_cacheItem._data.resourcesOrigin) {
225
- const extraResources = [];
226
- if (Array.isArray((_h = _cacheItem._extend) == null ? void 0 : _h.event_resources)) {
227
- _cacheItem._extend.event_resources.forEach((er) => {
228
- extraResources.push({ form_id: er.form_id, id: er.relation_id });
229
- });
230
- }
231
- _cacheItem._data.resourcesOrigin = (0, import_resources.getResourceByIds)(resourcesOriginMap, cacheItem, {
232
- extraResources,
233
- resourceTab: (_j = (_i = ctx == null ? void 0 : ctx.bookingConfig) == null ? void 0 : _i.config) == null ? void 0 : _j.resource_tab,
234
- resourcesOrigin: ctx.resourcesOrigin || []
235
- });
236
- }
237
- if (!_cacheItem._data.resources) {
238
- const { list, maps } = (0, import_resources.formatResources)({
239
- cacheItem: _cacheItem,
240
- resourcesOrigin: _cacheItem._data.resourcesOrigin
241
- });
242
- _cacheItem._data.resources = list;
243
- _cacheItem._data.resourceMaps = maps;
244
- }
245
- _cacheItem._data.timeObj = getTimeObj({
246
- cacheItem: _cacheItem,
247
- useStartTime: (_k = _cacheItem._extend) == null ? void 0 : _k.start_time,
248
- ctx
249
- });
250
- }
251
- return _cacheItem;
252
- }
253
- function getIsAutoClose(cacheItem, isAutoAllocationOn) {
254
- var _a, _b, _c, _d, _e;
255
- if ((0, import_resourceSelection.productNeedsResourceExtend)(cacheItem) && !(0, import_resourceSelection.hasActualResourceSelection)(cacheItem)) {
256
- return false;
257
- }
258
- if (((_b = (_a = cacheItem._data) == null ? void 0 : _a.capacitys) == null ? void 0 : _b.type) !== "custom") {
259
- const resources = ((_c = cacheItem == null ? void 0 : cacheItem._data) == null ? void 0 : _c.resources) || [];
260
- if (resources.length === 1) {
261
- const first = resources[0];
262
- if (((_d = first.select_type) == null ? void 0 : _d.type) === "single" && (first.default_resource || []).length > 0) {
263
- return true;
264
- }
265
- }
266
- }
267
- const entries = Object.entries(((_e = cacheItem._extend) == null ? void 0 : _e.resource) || {});
268
- if (entries.length === 0) {
269
- return !(0, import_resourceSelection.productNeedsResourceExtend)(cacheItem);
270
- }
271
- return entries.every(
272
- ([key, value]) => isAutoAllocationOn(key) && Array.isArray(value) && value.length > 0
273
- );
274
- }
275
- // Annotate the CommonJS export names for ESM import in node:
276
- 0 && (module.exports = {
277
- derivePresetStartTimeFromDate,
278
- getIsAutoClose,
279
- getProductExtend,
280
- getServiceStartTimeAndEndTime,
281
- getSumCapacity,
282
- getTimeObj
283
- });
@@ -1,41 +0,0 @@
1
- /**
2
- * 结构化的「资源不可用」原因(替代 info2 `getErrorList` 输出的 i18n 文案 + type 字段)。
3
- *
4
- * 与 info2 type 字段映射:
5
- * - `no_product` ↔ type='products'
6
- * - `time_out_of_range` ↔ type='time'
7
- * - `count_out_of_range` ↔ type='limit'
8
- * - `resource_unbound` ↔ type='unbound'
9
- *
10
- * OS 这边不耦合 i18n 文案,UI 拿到 reason + params 后自行渲染(参考 docs/SDK 中给出的 i18n key 对照表)。
11
- */
12
- export type ResourceUnavailableReason = 'no_product' | 'time_out_of_range' | 'count_out_of_range' | 'resource_unbound';
13
- export interface ResourceError {
14
- reason: ResourceUnavailableReason;
15
- params: {
16
- /** 资源名(time / limit 用)。 */
17
- labelText?: string;
18
- /** 起始时间(time / limit 用,格式 'hh:mm A')。 */
19
- startText?: string;
20
- /** 结束时间(time / limit 用,格式 'hh:mm A')。 */
21
- endText?: string;
22
- /**
23
- * 结束时间是否跨到第二天。UI 收到 true 时可在 endText 前加 'tomorrow' / '明天' 前缀。
24
- * 与 info2 旧实现「endText = locales.getText('pisell1.text.tomorrow') + endText」等价。
25
- */
26
- isCrossDay?: boolean;
27
- };
28
- }
29
- /**
30
- * 替代 info2 `utilsByBooking.ts#getErrorList`,输出结构化错误。
31
- *
32
- * 行为对齐:
33
- * 1. cacheItem 没有 id → `no_product`(与 info2 `!cacheItem?.id` 分支等价)。
34
- * 2. 资源 null / 无 _extend → 返回 []。
35
- * 3. resource.usable=false 时:
36
- * - 没有 _extend.usableTime → `time_out_of_range`
37
- * - 有 usableTime 但 `_extend.isCountRange=false` → `count_out_of_range`
38
- * 4. resource.unbound=true → 追加 `resource_unbound`。
39
- * 5. 不再耦合 `_data.resourceMaps[form_id].type === 'single'` 判断(与 info2 实际未使用此变量一致)。
40
- */
41
- export declare function getResourceErrors(resource: any, cacheItem: any): ResourceError[];
@@ -1,80 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
-
29
- // src/modules/BookingContext/utils/resourceErrors.ts
30
- var resourceErrors_exports = {};
31
- __export(resourceErrors_exports, {
32
- getResourceErrors: () => getResourceErrors
33
- });
34
- module.exports = __toCommonJS(resourceErrors_exports);
35
- var import_dayjs = __toESM(require("dayjs"));
36
- var import_serviceTimes = require("./serviceTimes");
37
- function getResourceErrors(resource, cacheItem) {
38
- var _a, _b, _c, _d;
39
- if (!(cacheItem == null ? void 0 : cacheItem.id)) {
40
- return [{ reason: "no_product", params: {} }];
41
- }
42
- if (!resource)
43
- return [];
44
- const list = [];
45
- if (!resource.usable) {
46
- const { startDate, endDate } = (0, import_serviceTimes.getServiceTimes)(cacheItem);
47
- const startText = startDate.format("hh:mm A");
48
- const endText = endDate.format("hh:mm A");
49
- const isCrossDay = (0, import_dayjs.default)(endDate).isAfter(startDate, "day");
50
- if (!((_a = resource._extend) == null ? void 0 : _a.usableTime)) {
51
- list.push({
52
- reason: "time_out_of_range",
53
- params: {
54
- labelText: resource.labelText,
55
- startText,
56
- endText,
57
- isCrossDay
58
- }
59
- });
60
- } else if (!((_d = (_c = (_b = resource._extend) == null ? void 0 : _b.usableTime) == null ? void 0 : _c._extend) == null ? void 0 : _d.isCountRange)) {
61
- list.push({
62
- reason: "count_out_of_range",
63
- params: {
64
- labelText: resource.labelText,
65
- startText,
66
- endText,
67
- isCrossDay
68
- }
69
- });
70
- }
71
- }
72
- if (resource.unbound) {
73
- list.push({ reason: "resource_unbound", params: {} });
74
- }
75
- return list;
76
- }
77
- // Annotate the CommonJS export names for ESM import in node:
78
- 0 && (module.exports = {
79
- getResourceErrors
80
- });
@@ -1,7 +0,0 @@
1
- /**
2
- * 预约商品资源是否「需要补齐 / 已选中」——供 getProductExtend 门禁与 getIsAutoClose 共用。
3
- */
4
- /** 商品是否挂了生效的资源表单(product_resource.resources status=1)。 */
5
- export declare function productNeedsResourceExtend(cacheItem: any): boolean;
6
- /** `_extend.resource` 是否至少有一类表单选中了具体资源。 */
7
- export declare function hasActualResourceSelection(cacheItem: any): boolean;
@@ -1,46 +0,0 @@
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);
18
-
19
- // src/modules/BookingContext/utils/resourceSelection.ts
20
- var resourceSelection_exports = {};
21
- __export(resourceSelection_exports, {
22
- hasActualResourceSelection: () => hasActualResourceSelection,
23
- productNeedsResourceExtend: () => productNeedsResourceExtend
24
- });
25
- module.exports = __toCommonJS(resourceSelection_exports);
26
- function productNeedsResourceExtend(cacheItem) {
27
- var _a;
28
- const forms = (_a = cacheItem == null ? void 0 : cacheItem.product_resource) == null ? void 0 : _a.resources;
29
- if (!Array.isArray(forms))
30
- return false;
31
- return forms.some((d) => Number(d == null ? void 0 : d.status) === 1);
32
- }
33
- function hasActualResourceSelection(cacheItem) {
34
- var _a;
35
- const resource = (_a = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _a.resource;
36
- if (!resource || typeof resource !== "object")
37
- return false;
38
- return Object.values(resource).some(
39
- (rows) => Array.isArray(rows) && rows.length > 0
40
- );
41
- }
42
- // Annotate the CommonJS export names for ESM import in node:
43
- 0 && (module.exports = {
44
- hasActualResourceSelection,
45
- productNeedsResourceExtend
46
- });