@pisell/pisellos 2.2.171 → 2.2.173

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 (160) hide show
  1. package/dist/model/strategy/adapter/promotion/index.js +9 -0
  2. package/dist/modules/BookingContext/index.d.ts +37 -0
  3. package/dist/modules/BookingContext/index.js +436 -0
  4. package/dist/modules/BookingContext/types.d.ts +102 -0
  5. package/dist/modules/BookingContext/types.js +51 -0
  6. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +16 -0
  7. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +193 -0
  8. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
  9. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +137 -0
  10. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +75 -0
  11. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +215 -0
  12. package/dist/modules/BookingContext/utils/flexible.d.ts +28 -0
  13. package/dist/modules/BookingContext/utils/flexible.js +56 -0
  14. package/dist/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
  15. package/dist/modules/BookingContext/utils/formatResourceList.js +38 -0
  16. package/dist/modules/BookingContext/utils/index.d.ts +11 -0
  17. package/dist/modules/BookingContext/utils/index.js +11 -0
  18. package/dist/modules/BookingContext/utils/noResource.d.ts +13 -0
  19. package/dist/modules/BookingContext/utils/noResource.js +77 -0
  20. package/dist/modules/BookingContext/utils/productExtend.d.ts +72 -0
  21. package/dist/modules/BookingContext/utils/productExtend.js +339 -0
  22. package/dist/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
  23. package/dist/modules/BookingContext/utils/resourceErrors.js +74 -0
  24. package/dist/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
  25. package/dist/modules/BookingContext/utils/resourceSelection.js +24 -0
  26. package/dist/modules/BookingContext/utils/resources.d.ts +80 -0
  27. package/dist/modules/BookingContext/utils/resources.js +486 -0
  28. package/dist/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
  29. package/dist/modules/BookingContext/utils/serviceTimes.js +151 -0
  30. package/dist/modules/BookingContext/utils/timeSlices.d.ts +42 -0
  31. package/dist/modules/BookingContext/utils/timeSlices.js +100 -0
  32. package/dist/modules/Customer/index.d.ts +6 -0
  33. package/dist/modules/Customer/index.js +129 -83
  34. package/dist/modules/Customer/types.d.ts +2 -0
  35. package/dist/modules/Discount/index.d.ts +2 -4
  36. package/dist/modules/Discount/index.js +8 -93
  37. package/dist/modules/Discount/types.d.ts +1 -7
  38. package/dist/modules/Order/index.d.ts +33 -17
  39. package/dist/modules/Order/index.js +757 -395
  40. package/dist/modules/Order/types.d.ts +58 -17
  41. package/dist/modules/Order/types.js +2 -0
  42. package/dist/modules/Order/utils/manualProductDiscount.d.ts +106 -0
  43. package/dist/modules/Order/utils/manualProductDiscount.js +212 -0
  44. package/dist/modules/Order/utils.d.ts +39 -1
  45. package/dist/modules/Order/utils.js +219 -31
  46. package/dist/modules/Quotation/index.js +16 -5
  47. package/dist/modules/Rules/index.d.ts +4 -0
  48. package/dist/modules/Rules/index.js +26 -10
  49. package/dist/modules/SalesSummary/index.js +4 -2
  50. package/dist/modules/Schedule/index.js +6 -2
  51. package/dist/modules/index.d.ts +1 -0
  52. package/dist/modules/index.js +2 -1
  53. package/dist/server/index.js +10 -6
  54. package/dist/server/modules/order/utils/filterOrders.js +20 -6
  55. package/dist/server/modules/products/index.js +113 -94
  56. package/dist/server/modules/schedule/index.js +13 -6
  57. package/dist/solution/BaseSales/index.d.ts +53 -7
  58. package/dist/solution/BaseSales/index.js +1160 -339
  59. package/dist/solution/BaseSales/types.d.ts +67 -1
  60. package/dist/solution/BaseSales/types.js +3 -1
  61. package/dist/solution/BaseSales/utils/quotationPrice.d.ts +7 -0
  62. package/dist/solution/BaseSales/utils/quotationPrice.js +237 -0
  63. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +65 -15
  64. package/dist/solution/BaseSales/utils.js +46 -8
  65. package/dist/solution/BookingByStep/index.d.ts +1 -1
  66. package/dist/solution/BookingTicket/index.d.ts +134 -2
  67. package/dist/solution/BookingTicket/index.js +776 -175
  68. package/dist/solution/BookingTicket/types.d.ts +2 -0
  69. package/dist/solution/BookingTicket/types.js +3 -0
  70. package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +113 -0
  71. package/dist/solution/BookingTicket/utils/addProductDecision.js +346 -0
  72. package/dist/solution/ScanOrder/index.d.ts +9 -3
  73. package/dist/solution/ScanOrder/index.js +231 -128
  74. package/dist/solution/ScanOrder/utils.js +46 -8
  75. package/dist/solution/ShopDiscount/index.d.ts +0 -1
  76. package/dist/solution/ShopDiscount/index.js +18 -23
  77. package/dist/solution/VenueBooking/index.d.ts +5 -9
  78. package/dist/solution/VenueBooking/index.js +103 -55
  79. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +4 -0
  80. package/dist/solution/VenueBooking/utils/slotMerge.js +10 -0
  81. package/lib/model/strategy/adapter/promotion/index.js +49 -0
  82. package/lib/modules/BookingContext/index.d.ts +37 -0
  83. package/lib/modules/BookingContext/index.js +297 -0
  84. package/lib/modules/BookingContext/types.d.ts +102 -0
  85. package/lib/modules/BookingContext/types.js +34 -0
  86. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +16 -0
  87. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +207 -0
  88. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
  89. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +141 -0
  90. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +75 -0
  91. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +198 -0
  92. package/lib/modules/BookingContext/utils/flexible.d.ts +28 -0
  93. package/lib/modules/BookingContext/utils/flexible.js +80 -0
  94. package/lib/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
  95. package/lib/modules/BookingContext/utils/formatResourceList.js +50 -0
  96. package/lib/modules/BookingContext/utils/index.d.ts +11 -0
  97. package/lib/modules/BookingContext/utils/index.js +43 -0
  98. package/lib/modules/BookingContext/utils/noResource.d.ts +13 -0
  99. package/lib/modules/BookingContext/utils/noResource.js +90 -0
  100. package/lib/modules/BookingContext/utils/productExtend.d.ts +72 -0
  101. package/lib/modules/BookingContext/utils/productExtend.js +283 -0
  102. package/lib/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
  103. package/lib/modules/BookingContext/utils/resourceErrors.js +80 -0
  104. package/lib/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
  105. package/lib/modules/BookingContext/utils/resourceSelection.js +46 -0
  106. package/lib/modules/BookingContext/utils/resources.d.ts +80 -0
  107. package/lib/modules/BookingContext/utils/resources.js +377 -0
  108. package/lib/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
  109. package/lib/modules/BookingContext/utils/serviceTimes.js +162 -0
  110. package/lib/modules/BookingContext/utils/timeSlices.d.ts +42 -0
  111. package/lib/modules/BookingContext/utils/timeSlices.js +124 -0
  112. package/lib/modules/Customer/index.d.ts +6 -0
  113. package/lib/modules/Customer/index.js +26 -11
  114. package/lib/modules/Customer/types.d.ts +2 -0
  115. package/lib/modules/Discount/index.d.ts +2 -4
  116. package/lib/modules/Discount/index.js +8 -63
  117. package/lib/modules/Discount/types.d.ts +1 -7
  118. package/lib/modules/Order/index.d.ts +33 -17
  119. package/lib/modules/Order/index.js +402 -148
  120. package/lib/modules/Order/types.d.ts +58 -17
  121. package/lib/modules/Order/utils/manualProductDiscount.d.ts +106 -0
  122. package/lib/modules/Order/utils/manualProductDiscount.js +207 -0
  123. package/lib/modules/Order/utils.d.ts +39 -1
  124. package/lib/modules/Order/utils.js +197 -22
  125. package/lib/modules/Quotation/index.js +17 -6
  126. package/lib/modules/Rules/index.d.ts +4 -0
  127. package/lib/modules/Rules/index.js +22 -14
  128. package/lib/modules/SalesSummary/index.js +4 -2
  129. package/lib/modules/Schedule/index.js +3 -1
  130. package/lib/modules/index.d.ts +1 -0
  131. package/lib/modules/index.js +3 -1
  132. package/lib/server/index.js +2 -0
  133. package/lib/server/modules/order/utils/filterOrders.js +12 -4
  134. package/lib/server/modules/products/index.js +23 -12
  135. package/lib/server/modules/schedule/index.js +2 -1
  136. package/lib/solution/BaseSales/index.d.ts +53 -7
  137. package/lib/solution/BaseSales/index.js +527 -20
  138. package/lib/solution/BaseSales/types.d.ts +67 -1
  139. package/lib/solution/BaseSales/types.js +3 -1
  140. package/lib/solution/BaseSales/utils/quotationPrice.d.ts +7 -0
  141. package/lib/solution/BaseSales/utils/quotationPrice.js +277 -0
  142. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +70 -11
  143. package/lib/solution/BaseSales/utils.js +46 -6
  144. package/lib/solution/BookingByStep/index.d.ts +1 -1
  145. package/lib/solution/BookingTicket/index.d.ts +134 -2
  146. package/lib/solution/BookingTicket/index.js +349 -8
  147. package/lib/solution/BookingTicket/types.d.ts +2 -0
  148. package/lib/solution/BookingTicket/types.js +6 -0
  149. package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +113 -0
  150. package/lib/solution/BookingTicket/utils/addProductDecision.js +318 -0
  151. package/lib/solution/ScanOrder/index.d.ts +9 -3
  152. package/lib/solution/ScanOrder/index.js +147 -66
  153. package/lib/solution/ScanOrder/utils.js +46 -6
  154. package/lib/solution/ShopDiscount/index.d.ts +0 -1
  155. package/lib/solution/ShopDiscount/index.js +2 -4
  156. package/lib/solution/VenueBooking/index.d.ts +5 -9
  157. package/lib/solution/VenueBooking/index.js +50 -14
  158. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +4 -0
  159. package/lib/solution/VenueBooking/utils/slotMerge.js +10 -0
  160. package/package.json +2 -2
@@ -0,0 +1,80 @@
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/flexible.ts
20
+ var flexible_exports = {};
21
+ __export(flexible_exports, {
22
+ flexibleObj: () => flexibleObj,
23
+ getDurationValue: () => getDurationValue,
24
+ isProductFlexibleDuration: () => isProductFlexibleDuration
25
+ });
26
+ module.exports = __toCommonJS(flexible_exports);
27
+ var PREFIX = "flexible_";
28
+ var flexibleObj = {
29
+ create(num) {
30
+ return `${PREFIX}${num}`;
31
+ },
32
+ getValue(str) {
33
+ if (typeof str === "string" && flexibleObj.isFlexible(str)) {
34
+ return Number(str.replace(PREFIX, ""));
35
+ }
36
+ return Number(str);
37
+ },
38
+ isFlexible(str) {
39
+ if (typeof str !== "string")
40
+ return false;
41
+ return str.indexOf(PREFIX) > -1;
42
+ },
43
+ add(current, duration) {
44
+ if (flexibleObj.isFlexible(current)) {
45
+ return flexibleObj.create(flexibleObj.getValue(current) + duration);
46
+ }
47
+ return Number(current) + duration;
48
+ }
49
+ };
50
+ function isProductFlexibleDuration(duration) {
51
+ return Boolean(
52
+ duration && typeof duration === "object" && duration.type === "flexible"
53
+ );
54
+ }
55
+ function getDurationValue(duration) {
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";
63
+ return Number(duration);
64
+ }
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;
72
+ }
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
+ });
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 将 `/schedule/resource/list` 原始数组格式化为 `list + listMap`。
3
+ * 逻辑与 info2 [`getFormatResourceListAndMap`] 对齐:追加无资源占位行、按 id 建 map。
4
+ */
5
+ export declare function formatResourceListAndMap(data: any[] | null | undefined, _bookingIds?: number[]): {
6
+ list: any[];
7
+ listMap: Record<string, any>;
8
+ };
@@ -0,0 +1,50 @@
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/formatResourceList.ts
20
+ var formatResourceList_exports = {};
21
+ __export(formatResourceList_exports, {
22
+ formatResourceListAndMap: () => formatResourceListAndMap
23
+ });
24
+ module.exports = __toCommonJS(formatResourceList_exports);
25
+ var import_noResource = require("./noResource");
26
+ function formatResourceListAndMap(data, _bookingIds = []) {
27
+ const resourceList = (Array.isArray(data) ? data : []).concat([(0, import_noResource.getNoResource2)({})]);
28
+ const map = resourceList.reduce((prev, item) => {
29
+ if ((item == null ? void 0 : item.id) !== void 0 && (item == null ? void 0 : item.id) !== null) {
30
+ prev[String(item.id)] = item;
31
+ }
32
+ return prev;
33
+ }, {});
34
+ const getCapacity = (item) => item.capacity;
35
+ const list = resourceList.map((item) => {
36
+ const newItem = {
37
+ ...item,
38
+ capacity: getCapacity(item)
39
+ };
40
+ if (newItem.id !== void 0 && newItem.id !== null) {
41
+ map[String(newItem.id)] = newItem;
42
+ }
43
+ return newItem;
44
+ });
45
+ return { list, listMap: map };
46
+ }
47
+ // Annotate the CommonJS export names for ESM import in node:
48
+ 0 && (module.exports = {
49
+ formatResourceListAndMap
50
+ });
@@ -0,0 +1,11 @@
1
+ export * from './flexible';
2
+ export * from './serviceTimes';
3
+ export * from './timeSlices';
4
+ export * from './noResource';
5
+ export * from './resources';
6
+ export * from './resourceSelection';
7
+ export * from './resourceErrors';
8
+ export * from './productExtend';
9
+ export * from './cacheItemToBookingInput';
10
+ export * from './buildCacheItemFromOrderLine';
11
+ export * from './buildNormalProductCacheItemFromOrderLine';
@@ -0,0 +1,43 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from === "object" || typeof from === "function") {
7
+ for (let key of __getOwnPropNames(from))
8
+ if (!__hasOwnProp.call(to, key) && key !== except)
9
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
+ }
11
+ return to;
12
+ };
13
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+
16
+ // src/modules/BookingContext/utils/index.ts
17
+ var utils_exports = {};
18
+ module.exports = __toCommonJS(utils_exports);
19
+ __reExport(utils_exports, require("./flexible"), module.exports);
20
+ __reExport(utils_exports, require("./serviceTimes"), module.exports);
21
+ __reExport(utils_exports, require("./timeSlices"), module.exports);
22
+ __reExport(utils_exports, require("./noResource"), module.exports);
23
+ __reExport(utils_exports, require("./resources"), module.exports);
24
+ __reExport(utils_exports, require("./resourceSelection"), module.exports);
25
+ __reExport(utils_exports, require("./resourceErrors"), module.exports);
26
+ __reExport(utils_exports, require("./productExtend"), module.exports);
27
+ __reExport(utils_exports, require("./cacheItemToBookingInput"), module.exports);
28
+ __reExport(utils_exports, require("./buildCacheItemFromOrderLine"), module.exports);
29
+ __reExport(utils_exports, require("./buildNormalProductCacheItemFromOrderLine"), module.exports);
30
+ // Annotate the CommonJS export names for ESM import in node:
31
+ 0 && (module.exports = {
32
+ ...require("./flexible"),
33
+ ...require("./serviceTimes"),
34
+ ...require("./timeSlices"),
35
+ ...require("./noResource"),
36
+ ...require("./resources"),
37
+ ...require("./resourceSelection"),
38
+ ...require("./resourceErrors"),
39
+ ...require("./productExtend"),
40
+ ...require("./cacheItemToBookingInput"),
41
+ ...require("./buildCacheItemFromOrderLine"),
42
+ ...require("./buildNormalProductCacheItemFromOrderLine")
43
+ });
@@ -0,0 +1,13 @@
1
+ /**
2
+ * 「无资源」占位资源行的数据骨架。
3
+ *
4
+ * 与 info2 [`booking/mock.ts#getNoResource2`] 一比一对齐,区别仅在于:
5
+ * - `main_field / room_name / labelText` 三个 i18n 文案字段在 OS 这边**置空**,
6
+ * 调用方(UI)在 `id === 0` 时自行渲染本地化的「无资源 / No resource」。
7
+ *
8
+ * 用途:`getResourceByIds` 在拼装 `optional_resource` 列表时,会在末尾 concat 一行此占位,
9
+ * 让用户能选择「不指定资源」。
10
+ */
11
+ export declare function getNoResource2(other?: {
12
+ form_id?: number | string;
13
+ } & Record<string, any>): any;
@@ -0,0 +1,90 @@
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
+ });
@@ -0,0 +1,72 @@
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 };
@@ -0,0 +1,283 @@
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
+ });