@pisell/pisellos 3.0.90 → 3.0.92

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 (240) hide show
  1. package/dist/apis/picoding.d.ts +0 -0
  2. package/dist/apis/picoding.js +1 -0
  3. package/dist/model/index.d.ts +1 -0
  4. package/dist/model/index.js +1 -0
  5. package/dist/model/strategy/adapter/index.d.ts +7 -0
  6. package/dist/model/strategy/adapter/index.js +7 -0
  7. package/dist/model/strategy/adapter/itemRule/adapter.d.ts +67 -0
  8. package/dist/model/strategy/adapter/itemRule/adapter.js +483 -0
  9. package/dist/model/strategy/adapter/itemRule/evaluator.d.ts +43 -0
  10. package/dist/model/strategy/adapter/itemRule/evaluator.js +169 -0
  11. package/dist/model/strategy/adapter/itemRule/examples.d.ts +79 -0
  12. package/dist/model/strategy/adapter/itemRule/examples.js +382 -0
  13. package/dist/model/strategy/adapter/itemRule/index.d.ts +5 -0
  14. package/dist/model/strategy/adapter/itemRule/index.js +5 -0
  15. package/dist/model/strategy/adapter/itemRule/type.d.ts +225 -0
  16. package/dist/model/strategy/adapter/itemRule/type.js +101 -0
  17. package/dist/model/strategy/adapter/promotion/adapter.d.ts +66 -0
  18. package/dist/model/strategy/adapter/promotion/adapter.js +271 -0
  19. package/dist/model/strategy/adapter/promotion/evaluator.d.ts +213 -0
  20. package/dist/model/strategy/adapter/promotion/evaluator.js +1206 -0
  21. package/dist/model/strategy/adapter/promotion/examples.d.ts +138 -0
  22. package/dist/model/strategy/adapter/promotion/examples.js +166 -0
  23. package/dist/model/strategy/adapter/promotion/index.d.ts +4 -0
  24. package/dist/model/strategy/adapter/promotion/index.js +9 -0
  25. package/dist/model/strategy/adapter/promotion/type.d.ts +447 -0
  26. package/dist/model/strategy/adapter/promotion/type.js +209 -0
  27. package/dist/model/strategy/adapter/type.d.ts +28 -0
  28. package/dist/model/strategy/adapter/type.js +1 -0
  29. package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +84 -0
  30. package/dist/model/strategy/adapter/walletPass/evaluator.js +502 -0
  31. package/dist/model/strategy/adapter/walletPass/example.d.ts +4 -0
  32. package/dist/model/strategy/adapter/walletPass/example.js +258 -0
  33. package/dist/model/strategy/adapter/walletPass/index.d.ts +32 -0
  34. package/dist/model/strategy/adapter/walletPass/index.js +182 -0
  35. package/dist/model/strategy/adapter/walletPass/locales.d.ts +1 -0
  36. package/dist/model/strategy/adapter/walletPass/locales.js +26 -0
  37. package/dist/model/strategy/adapter/walletPass/type.d.ts +187 -0
  38. package/dist/model/strategy/adapter/walletPass/type.js +1 -0
  39. package/dist/model/strategy/adapter/walletPass/utils.d.ts +50 -0
  40. package/dist/model/strategy/adapter/walletPass/utils.js +1104 -0
  41. package/dist/model/strategy/engine.d.ts +106 -0
  42. package/dist/model/strategy/engine.js +611 -0
  43. package/dist/model/strategy/index.d.ts +3 -0
  44. package/dist/model/strategy/index.js +8 -0
  45. package/dist/model/strategy/strategy-example.d.ts +5 -0
  46. package/dist/model/strategy/strategy-example.js +331 -0
  47. package/dist/model/strategy/type.d.ts +228 -0
  48. package/dist/model/strategy/type.js +94 -0
  49. package/dist/modules/Cart/utils/cartProduct.js +1 -0
  50. package/dist/modules/Discount/index.d.ts +4 -2
  51. package/dist/modules/Discount/index.js +90 -3
  52. package/dist/modules/Discount/types.d.ts +6 -0
  53. package/dist/modules/OpenData/index.d.ts +24 -0
  54. package/dist/modules/OpenData/index.js +173 -0
  55. package/dist/modules/OpenData/types.d.ts +73 -0
  56. package/dist/modules/OpenData/types.js +1 -0
  57. package/dist/modules/OpenData/utils.d.ts +2 -0
  58. package/dist/modules/OpenData/utils.js +75 -0
  59. package/dist/modules/Order/index.d.ts +66 -1
  60. package/dist/modules/Order/index.js +884 -10
  61. package/dist/modules/Order/types.d.ts +174 -12
  62. package/dist/modules/Order/types.js +2 -0
  63. package/dist/modules/Order/utils.d.ts +118 -0
  64. package/dist/modules/Order/utils.js +586 -2
  65. package/dist/modules/Product/utils.js +2 -2
  66. package/dist/modules/ProductList/index.d.ts +3 -1
  67. package/dist/modules/ProductList/index.js +26 -11
  68. package/dist/modules/Quotation/index.d.ts +48 -0
  69. package/dist/modules/Quotation/index.js +248 -0
  70. package/dist/modules/Quotation/types.d.ts +42 -0
  71. package/dist/modules/Quotation/types.js +1 -0
  72. package/dist/modules/Rules/index.js +17 -18
  73. package/dist/modules/SalesSummary/index.d.ts +63 -0
  74. package/dist/modules/SalesSummary/index.js +174 -0
  75. package/dist/modules/SalesSummary/types.d.ts +60 -0
  76. package/dist/modules/SalesSummary/types.js +1 -0
  77. package/dist/modules/SalesSummary/utils.d.ts +30 -0
  78. package/dist/modules/SalesSummary/utils.js +480 -0
  79. package/dist/modules/ScanOrderLogger/index.d.ts +23 -0
  80. package/dist/modules/ScanOrderLogger/index.js +174 -0
  81. package/dist/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
  82. package/dist/modules/ScanOrderLogger/providers/feishu.js +221 -0
  83. package/dist/modules/ScanOrderLogger/providers/grafana.d.ts +2 -0
  84. package/dist/modules/ScanOrderLogger/providers/grafana.js +50 -0
  85. package/dist/modules/ScanOrderLogger/types.d.ts +53 -0
  86. package/dist/modules/ScanOrderLogger/types.js +1 -0
  87. package/dist/modules/Schedule/getDateIsInSchedule.js +11 -18
  88. package/dist/modules/Schedule/utils.d.ts +1 -1
  89. package/dist/modules/Summary/utils.d.ts +3 -3
  90. package/dist/modules/Summary/utils.js +41 -31
  91. package/dist/modules/index.d.ts +4 -0
  92. package/dist/modules/index.js +5 -1
  93. package/dist/solution/BookingByStep/index.d.ts +2 -2
  94. package/dist/solution/BookingByStep/types.d.ts +3 -1
  95. package/dist/solution/BookingByStep/types.js +5 -1
  96. package/dist/solution/ScanOrder/index.d.ts +158 -0
  97. package/dist/solution/ScanOrder/index.js +3474 -0
  98. package/dist/solution/ScanOrder/types.d.ts +306 -0
  99. package/dist/solution/ScanOrder/types.js +35 -0
  100. package/dist/solution/ScanOrder/utils.d.ts +172 -0
  101. package/dist/solution/ScanOrder/utils.js +796 -0
  102. package/dist/solution/ShopDiscount/index.d.ts +1 -0
  103. package/dist/solution/ShopDiscount/index.js +23 -18
  104. package/dist/solution/VenueBooking/index.d.ts +201 -0
  105. package/dist/solution/VenueBooking/index.js +3472 -0
  106. package/dist/solution/VenueBooking/sales-section-4-annotated.json +343 -0
  107. package/dist/solution/VenueBooking/types.d.ts +154 -0
  108. package/dist/solution/VenueBooking/types.js +21 -0
  109. package/dist/solution/VenueBooking/utils/dateSummary.d.ts +11 -0
  110. package/dist/solution/VenueBooking/utils/dateSummary.js +104 -0
  111. package/dist/solution/VenueBooking/utils/resource.d.ts +14 -0
  112. package/dist/solution/VenueBooking/utils/resource.js +131 -0
  113. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +38 -0
  114. package/dist/solution/VenueBooking/utils/slotMerge.js +239 -0
  115. package/dist/solution/VenueBooking/utils/timeSlot.d.ts +32 -0
  116. package/dist/solution/VenueBooking/utils/timeSlot.js +453 -0
  117. package/dist/solution/VenueBooking/utils.d.ts +1 -0
  118. package/dist/solution/VenueBooking/utils.js +1 -0
  119. package/dist/solution/index.d.ts +2 -0
  120. package/dist/solution/index.js +3 -1
  121. package/lib/apis/picoding.d.ts +0 -0
  122. package/lib/apis/picoding.js +0 -0
  123. package/lib/model/index.d.ts +1 -0
  124. package/lib/model/index.js +23 -0
  125. package/lib/model/strategy/adapter/index.d.ts +7 -0
  126. package/lib/model/strategy/adapter/index.js +57 -0
  127. package/lib/model/strategy/adapter/itemRule/adapter.d.ts +67 -0
  128. package/lib/model/strategy/adapter/itemRule/adapter.js +377 -0
  129. package/lib/model/strategy/adapter/itemRule/evaluator.d.ts +43 -0
  130. package/lib/model/strategy/adapter/itemRule/evaluator.js +124 -0
  131. package/lib/model/strategy/adapter/itemRule/examples.d.ts +79 -0
  132. package/lib/model/strategy/adapter/itemRule/examples.js +316 -0
  133. package/lib/model/strategy/adapter/itemRule/index.d.ts +5 -0
  134. package/lib/model/strategy/adapter/itemRule/index.js +60 -0
  135. package/lib/model/strategy/adapter/itemRule/type.d.ts +225 -0
  136. package/lib/model/strategy/adapter/itemRule/type.js +46 -0
  137. package/lib/model/strategy/adapter/promotion/adapter.d.ts +66 -0
  138. package/lib/model/strategy/adapter/promotion/adapter.js +217 -0
  139. package/lib/model/strategy/adapter/promotion/evaluator.d.ts +213 -0
  140. package/lib/model/strategy/adapter/promotion/evaluator.js +844 -0
  141. package/lib/model/strategy/adapter/promotion/examples.d.ts +138 -0
  142. package/lib/model/strategy/adapter/promotion/examples.js +192 -0
  143. package/lib/model/strategy/adapter/promotion/index.d.ts +4 -0
  144. package/lib/model/strategy/adapter/promotion/index.js +0 -0
  145. package/lib/model/strategy/adapter/promotion/type.d.ts +447 -0
  146. package/lib/model/strategy/adapter/promotion/type.js +51 -0
  147. package/lib/model/strategy/adapter/type.d.ts +28 -0
  148. package/lib/model/strategy/adapter/type.js +17 -0
  149. package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +84 -0
  150. package/lib/model/strategy/adapter/walletPass/evaluator.js +424 -0
  151. package/lib/model/strategy/adapter/walletPass/example.d.ts +4 -0
  152. package/lib/model/strategy/adapter/walletPass/example.js +207 -0
  153. package/lib/model/strategy/adapter/walletPass/index.d.ts +32 -0
  154. package/lib/model/strategy/adapter/walletPass/index.js +142 -0
  155. package/lib/model/strategy/adapter/walletPass/locales.d.ts +1 -0
  156. package/lib/model/strategy/adapter/walletPass/locales.js +54 -0
  157. package/lib/model/strategy/adapter/walletPass/type.d.ts +187 -0
  158. package/lib/model/strategy/adapter/walletPass/type.js +17 -0
  159. package/lib/model/strategy/adapter/walletPass/utils.d.ts +50 -0
  160. package/lib/model/strategy/adapter/walletPass/utils.js +791 -0
  161. package/lib/model/strategy/engine.d.ts +106 -0
  162. package/lib/model/strategy/engine.js +450 -0
  163. package/lib/model/strategy/index.d.ts +3 -0
  164. package/lib/model/strategy/index.js +38 -0
  165. package/lib/model/strategy/strategy-example.d.ts +5 -0
  166. package/lib/model/strategy/strategy-example.js +318 -0
  167. package/lib/model/strategy/type.d.ts +228 -0
  168. package/lib/model/strategy/type.js +44 -0
  169. package/lib/modules/Cart/utils/cartProduct.js +1 -0
  170. package/lib/modules/Discount/index.d.ts +4 -2
  171. package/lib/modules/Discount/index.js +60 -2
  172. package/lib/modules/Discount/types.d.ts +6 -0
  173. package/lib/modules/OpenData/index.d.ts +24 -0
  174. package/lib/modules/OpenData/index.js +119 -0
  175. package/lib/modules/OpenData/types.d.ts +73 -0
  176. package/lib/modules/OpenData/types.js +17 -0
  177. package/lib/modules/OpenData/utils.d.ts +2 -0
  178. package/lib/modules/OpenData/utils.js +111 -0
  179. package/lib/modules/Order/index.d.ts +66 -1
  180. package/lib/modules/Order/index.js +525 -0
  181. package/lib/modules/Order/types.d.ts +174 -12
  182. package/lib/modules/Order/utils.d.ts +118 -0
  183. package/lib/modules/Order/utils.js +483 -2
  184. package/lib/modules/Product/utils.js +2 -2
  185. package/lib/modules/ProductList/index.d.ts +3 -1
  186. package/lib/modules/ProductList/index.js +51 -34
  187. package/lib/modules/Quotation/index.d.ts +48 -0
  188. package/lib/modules/Quotation/index.js +152 -0
  189. package/lib/modules/Quotation/types.d.ts +42 -0
  190. package/lib/modules/Quotation/types.js +17 -0
  191. package/lib/modules/Rules/index.js +17 -18
  192. package/lib/modules/SalesSummary/index.d.ts +63 -0
  193. package/lib/modules/SalesSummary/index.js +105 -0
  194. package/lib/modules/SalesSummary/types.d.ts +60 -0
  195. package/lib/modules/SalesSummary/types.js +17 -0
  196. package/lib/modules/SalesSummary/utils.d.ts +30 -0
  197. package/lib/modules/SalesSummary/utils.js +420 -0
  198. package/lib/modules/ScanOrderLogger/index.d.ts +23 -0
  199. package/lib/modules/ScanOrderLogger/index.js +147 -0
  200. package/lib/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
  201. package/lib/modules/ScanOrderLogger/providers/feishu.js +157 -0
  202. package/lib/modules/ScanOrderLogger/providers/grafana.d.ts +2 -0
  203. package/lib/modules/ScanOrderLogger/providers/grafana.js +52 -0
  204. package/lib/modules/ScanOrderLogger/types.d.ts +53 -0
  205. package/lib/modules/ScanOrderLogger/types.js +17 -0
  206. package/lib/modules/Schedule/getDateIsInSchedule.js +9 -11
  207. package/lib/modules/Schedule/utils.d.ts +1 -1
  208. package/lib/modules/Summary/utils.d.ts +3 -3
  209. package/lib/modules/Summary/utils.js +22 -16
  210. package/lib/modules/index.d.ts +4 -0
  211. package/lib/modules/index.js +9 -1
  212. package/lib/solution/BookingByStep/index.d.ts +2 -2
  213. package/lib/solution/BookingByStep/types.d.ts +3 -1
  214. package/lib/solution/BookingByStep/types.js +10 -0
  215. package/lib/solution/ScanOrder/index.d.ts +158 -0
  216. package/lib/solution/ScanOrder/index.js +2135 -0
  217. package/lib/solution/ScanOrder/types.d.ts +306 -0
  218. package/lib/solution/ScanOrder/types.js +36 -0
  219. package/lib/solution/ScanOrder/utils.d.ts +172 -0
  220. package/lib/solution/ScanOrder/utils.js +658 -0
  221. package/lib/solution/ShopDiscount/index.d.ts +1 -0
  222. package/lib/solution/ShopDiscount/index.js +4 -2
  223. package/lib/solution/VenueBooking/index.d.ts +201 -0
  224. package/lib/solution/VenueBooking/index.js +1937 -0
  225. package/lib/solution/VenueBooking/sales-section-4-annotated.json +343 -0
  226. package/lib/solution/VenueBooking/types.d.ts +154 -0
  227. package/lib/solution/VenueBooking/types.js +44 -0
  228. package/lib/solution/VenueBooking/utils/dateSummary.d.ts +11 -0
  229. package/lib/solution/VenueBooking/utils/dateSummary.js +110 -0
  230. package/lib/solution/VenueBooking/utils/resource.d.ts +14 -0
  231. package/lib/solution/VenueBooking/utils/resource.js +92 -0
  232. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +38 -0
  233. package/lib/solution/VenueBooking/utils/slotMerge.js +237 -0
  234. package/lib/solution/VenueBooking/utils/timeSlot.d.ts +32 -0
  235. package/lib/solution/VenueBooking/utils/timeSlot.js +339 -0
  236. package/lib/solution/VenueBooking/utils.d.ts +1 -0
  237. package/lib/solution/VenueBooking/utils.js +69 -0
  238. package/lib/solution/index.d.ts +2 -0
  239. package/lib/solution/index.js +5 -1
  240. package/package.json +1 -1
@@ -0,0 +1,14 @@
1
+ import type { ProductData } from '../../../modules/Product/types';
2
+ import type { ResourceProductMapping } from '../types';
3
+ /**
4
+ * 从商品列表里抽取所有 resource_id:
5
+ * - 商品绑定的 default_resource / optional_resource
6
+ * - 以及这些资源上声明的 combined_resource.resource_ids(若可从 product_resource 读取)
7
+ * 用于一次性拉到子资源数据,判定组合资源的可用性。
8
+ */
9
+ export declare function extractResourceIds(products: ProductData[]): number[];
10
+ /**
11
+ * 每个 resourceId 可以被多个商品共享(同一场地关联多种运动商品)。
12
+ * Map 的 value 改为 ResourceProductMapping[],按商品出现顺序保留。
13
+ */
14
+ export declare function buildResourceProductMap(products: ProductData[]): Map<number | string, ResourceProductMapping[]>;
@@ -0,0 +1,92 @@
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/solution/VenueBooking/utils/resource.ts
20
+ var resource_exports = {};
21
+ __export(resource_exports, {
22
+ buildResourceProductMap: () => buildResourceProductMap,
23
+ extractResourceIds: () => extractResourceIds
24
+ });
25
+ module.exports = __toCommonJS(resource_exports);
26
+ function extractResourceIds(products) {
27
+ var _a;
28
+ const ids = /* @__PURE__ */ new Set();
29
+ for (const product of products) {
30
+ const resources = (_a = product.product_resource) == null ? void 0 : _a.resources;
31
+ if (!Array.isArray(resources))
32
+ continue;
33
+ for (const resource of resources) {
34
+ if (resource.status !== 1)
35
+ continue;
36
+ const defaultRes = resource.default_resource || [];
37
+ const optionalRes = resource.optional_resource || [];
38
+ for (const id of [...defaultRes, ...optionalRes]) {
39
+ if (typeof id === "number" && id > 0)
40
+ ids.add(id);
41
+ }
42
+ const combined = resource.combined_resource;
43
+ if (combined && combined.status === 1 && Array.isArray(combined.resource_ids)) {
44
+ for (const id of combined.resource_ids) {
45
+ if (typeof id === "number" && id > 0)
46
+ ids.add(id);
47
+ }
48
+ }
49
+ }
50
+ }
51
+ return Array.from(ids);
52
+ }
53
+ function buildResourceProductMap(products) {
54
+ var _a;
55
+ const map = /* @__PURE__ */ new Map();
56
+ for (const product of products) {
57
+ const resources = (_a = product.product_resource) == null ? void 0 : _a.resources;
58
+ if (!Array.isArray(resources))
59
+ continue;
60
+ for (const resource of resources) {
61
+ if (resource.status !== 1)
62
+ continue;
63
+ const allResourceIds = [
64
+ ...resource.default_resource || [],
65
+ ...resource.optional_resource || []
66
+ ];
67
+ for (const resId of allResourceIds) {
68
+ const existing = map.get(resId);
69
+ const mapping = {
70
+ productId: product.id,
71
+ productTitle: product.title,
72
+ formName: resource.title,
73
+ resourceName: resource.title,
74
+ formId: resource.id,
75
+ price: product.price || "0.00",
76
+ resourceType: resource.type || "single"
77
+ };
78
+ if (!existing) {
79
+ map.set(resId, [mapping]);
80
+ } else if (!existing.some((m) => m.productId === mapping.productId)) {
81
+ existing.push(mapping);
82
+ }
83
+ }
84
+ }
85
+ }
86
+ return map;
87
+ }
88
+ // Annotate the CommonJS export names for ESM import in node:
89
+ 0 && (module.exports = {
90
+ buildResourceProductMap,
91
+ extractResourceIds
92
+ });
@@ -0,0 +1,38 @@
1
+ import type { VenueSlotSelection, MergedSlotGroup, PriceBreakdownEntry, ResourceProductMapping, VenueResourceRawData } from '../types';
2
+ import type { ScanOrderOrderProduct } from '../../ScanOrder/types';
3
+ export declare function buildVenueIdentityKey(resourceId: number | string, groupIndex: number): string;
4
+ export declare function mergeConsecutiveSlots(slots: VenueSlotSelection[]): MergedSlotGroup[];
5
+ export declare function buildPriceBreakdown(params: {
6
+ group: MergedSlotGroup;
7
+ productId: number;
8
+ quotation?: {
9
+ getQuotationShelfId: (p: {
10
+ productId: number;
11
+ datetime: string;
12
+ }) => number;
13
+ };
14
+ }): PriceBreakdownEntry[];
15
+ export interface BuildVenueBookingParams {
16
+ group: MergedSlotGroup;
17
+ resourceId: number | string;
18
+ mapping: ResourceProductMapping;
19
+ rawResource: VenueResourceRawData | undefined;
20
+ bookingUuid: string;
21
+ productUid: string;
22
+ /**
23
+ * 若当前 resource 是组合资源(combined_resource.status === 1),传入其子资源的原始数据,
24
+ * 将作为 resources[0].children 写入 booking,结构与父 resource 保持一致。
25
+ */
26
+ childResources?: VenueResourceRawData[];
27
+ }
28
+ export declare function buildVenueResourceMetadata(params: {
29
+ mapping: ResourceProductMapping;
30
+ rawResource: VenueResourceRawData | undefined;
31
+ }): Record<string, any>;
32
+ export declare function buildVenueBookingEntry(params: BuildVenueBookingParams): Record<string, any>;
33
+ /**
34
+ * 从一条已合并的订单商品还原出独立的时段列表。
35
+ * 优先使用 metadata.price_breakdown 还原每个时段的精确价格,
36
+ * 回退到按 selling_price / slot_count 均分。
37
+ */
38
+ export declare function expandMergedSlotToIndividual(product: ScanOrderOrderProduct, slotDurationMinutes: number): VenueSlotSelection[];
@@ -0,0 +1,237 @@
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/solution/VenueBooking/utils/slotMerge.ts
30
+ var slotMerge_exports = {};
31
+ __export(slotMerge_exports, {
32
+ buildPriceBreakdown: () => buildPriceBreakdown,
33
+ buildVenueBookingEntry: () => buildVenueBookingEntry,
34
+ buildVenueIdentityKey: () => buildVenueIdentityKey,
35
+ buildVenueResourceMetadata: () => buildVenueResourceMetadata,
36
+ expandMergedSlotToIndividual: () => expandMergedSlotToIndividual,
37
+ mergeConsecutiveSlots: () => mergeConsecutiveSlots
38
+ });
39
+ module.exports = __toCommonJS(slotMerge_exports);
40
+ var import_decimal = __toESM(require("decimal.js"));
41
+ var import_dayjs = __toESM(require("dayjs"));
42
+ var import_utils = require("../../../modules/Order/utils");
43
+ function buildVenueIdentityKey(resourceId, groupIndex) {
44
+ return `venue:${resourceId}:${groupIndex}:${(0, import_utils.createUuidV4)()}`;
45
+ }
46
+ function mergeConsecutiveSlots(slots) {
47
+ if (!slots.length)
48
+ return [];
49
+ const sorted = [...slots].sort((a, b) => a.startTime.localeCompare(b.startTime));
50
+ const groups = [];
51
+ let currentSlots = [sorted[0]];
52
+ let currentStart = sorted[0].startTime;
53
+ let currentEnd = sorted[0].endTime;
54
+ let totalPrice = new import_decimal.default(sorted[0].price || "0");
55
+ for (let i = 1; i < sorted.length; i++) {
56
+ const slot = sorted[i];
57
+ if (slot.startTime === currentEnd) {
58
+ currentEnd = slot.endTime;
59
+ totalPrice = totalPrice.add(new import_decimal.default(slot.price || "0"));
60
+ currentSlots.push(slot);
61
+ } else {
62
+ groups.push({
63
+ startTime: currentStart,
64
+ endTime: currentEnd,
65
+ totalPrice: totalPrice.toFixed(2),
66
+ slotCount: currentSlots.length,
67
+ slots: currentSlots
68
+ });
69
+ currentSlots = [slot];
70
+ currentStart = slot.startTime;
71
+ currentEnd = slot.endTime;
72
+ totalPrice = new import_decimal.default(slot.price || "0");
73
+ }
74
+ }
75
+ groups.push({
76
+ startTime: currentStart,
77
+ endTime: currentEnd,
78
+ totalPrice: totalPrice.toFixed(2),
79
+ slotCount: currentSlots.length,
80
+ slots: currentSlots
81
+ });
82
+ return groups;
83
+ }
84
+ function buildPriceBreakdown(params) {
85
+ const { group, productId, quotation } = params;
86
+ if (!group.slots.length)
87
+ return [];
88
+ const entries = [];
89
+ for (const slot of group.slots) {
90
+ const unitPrice = Number(slot.price || "0");
91
+ const shelfId = quotation ? quotation.getQuotationShelfId({ productId, datetime: slot.startTime }) : 0;
92
+ const startHm = (0, import_dayjs.default)(slot.startTime, "YYYY-MM-DD HH:mm").format("YYYY-MM-DD HH:mm");
93
+ const endHm = (0, import_dayjs.default)(slot.endTime, "YYYY-MM-DD HH:mm").format("YYYY-MM-DD HH:mm");
94
+ const last = entries[entries.length - 1];
95
+ if (last && last.unit_price === unitPrice && last.quotation_shelf_id === shelfId && last.end_time === startHm) {
96
+ last.end_time = endHm;
97
+ last.quantity += 1;
98
+ } else {
99
+ entries.push({
100
+ start_time: startHm,
101
+ end_time: endHm,
102
+ unit_price: unitPrice,
103
+ quotation_shelf_id: shelfId,
104
+ quantity: 1
105
+ });
106
+ }
107
+ }
108
+ return entries;
109
+ }
110
+ function buildVenueResourceMetadata(params) {
111
+ const { mapping, rawResource } = params;
112
+ const combined = rawResource == null ? void 0 : rawResource.combined_resource;
113
+ const isCombined = !!(combined && combined.status === 1 && Array.isArray(combined.resource_ids));
114
+ return {
115
+ form_name: mapping.formName ?? mapping.resourceName,
116
+ resource_name: (rawResource == null ? void 0 : rawResource.main_field) ?? mapping.resourceName,
117
+ combined_resource: isCombined ? combined : null
118
+ };
119
+ }
120
+ function buildVenueBookingEntry(params) {
121
+ const { group, resourceId, mapping, rawResource, bookingUuid, productUid, childResources } = params;
122
+ const startMoment = (0, import_dayjs.default)(group.startTime, "YYYY-MM-DD HH:mm");
123
+ const endMoment = (0, import_dayjs.default)(group.endTime, "YYYY-MM-DD HH:mm");
124
+ const duration = endMoment.diff(startMoment, "minute");
125
+ const resourceEntry = {
126
+ relation_type: "form",
127
+ like_status: "common",
128
+ id: resourceId,
129
+ main_field: mapping.resourceName,
130
+ form_id: (rawResource == null ? void 0 : rawResource.form_id) ?? mapping.formId,
131
+ relation_id: resourceId,
132
+ capacity: 1,
133
+ metadata: buildVenueResourceMetadata({ mapping, rawResource })
134
+ };
135
+ if (childResources && childResources.length) {
136
+ resourceEntry.children = childResources.map((child) => ({
137
+ relation_type: "form",
138
+ like_status: "common",
139
+ id: child.resourceId,
140
+ main_field: child.main_field || "",
141
+ form_id: child.form_id ?? child.formId,
142
+ relation_id: child.resourceId,
143
+ capacity: child.capacity ?? 1,
144
+ metadata: {}
145
+ }));
146
+ }
147
+ return {
148
+ schedule_event_id: null,
149
+ appointment_status: "new",
150
+ start_date: startMoment.format("YYYY-MM-DD"),
151
+ start_time: startMoment.format("HH:mm"),
152
+ end_date: endMoment.format("YYYY-MM-DD"),
153
+ end_time: endMoment.format("HH:mm"),
154
+ select_date: startMoment.format("YYYY-MM-DD"),
155
+ duration,
156
+ sub_type: "minutes",
157
+ like_status: "common",
158
+ number: 1,
159
+ is_all: false,
160
+ schedule_id: 0,
161
+ product_uid: productUid,
162
+ resources: [resourceEntry],
163
+ relation_products: [],
164
+ relation_forms: [],
165
+ holder: null,
166
+ metadata: {
167
+ unique_identification_number: bookingUuid,
168
+ venue_booking: true,
169
+ resource_id: resourceId,
170
+ product_id: mapping.productId
171
+ }
172
+ };
173
+ }
174
+ function expandMergedSlotToIndividual(product, slotDurationMinutes) {
175
+ const meta = product.metadata || {};
176
+ const resourceId = meta.resource_id;
177
+ if (resourceId == null)
178
+ return [];
179
+ const startTime = meta.start_time;
180
+ const endTime = meta.end_time;
181
+ if (!startTime || !endTime)
182
+ return [];
183
+ const productId = Number(product.product_id);
184
+ const breakdown = meta.price_breakdown;
185
+ const result = [];
186
+ let cursor = (0, import_dayjs.default)(startTime, "YYYY-MM-DD HH:mm");
187
+ const end = (0, import_dayjs.default)(endTime, "YYYY-MM-DD HH:mm");
188
+ if (breakdown == null ? void 0 : breakdown.length) {
189
+ const priceMap = /* @__PURE__ */ new Map();
190
+ for (const entry of breakdown) {
191
+ let entryCursor = (0, import_dayjs.default)(entry.start_time, "YYYY-MM-DD HH:mm");
192
+ const entryEnd = (0, import_dayjs.default)(entry.end_time, "YYYY-MM-DD HH:mm");
193
+ while (entryCursor.isBefore(entryEnd)) {
194
+ priceMap.set(entryCursor.format("HH:mm"), entry.unit_price);
195
+ entryCursor = entryCursor.add(slotDurationMinutes, "minute");
196
+ }
197
+ }
198
+ while (cursor.isBefore(end)) {
199
+ const slotEnd = cursor.add(slotDurationMinutes, "minute");
200
+ const hm = cursor.format("HH:mm");
201
+ const price = priceMap.get(hm) ?? 0;
202
+ result.push({
203
+ resourceId,
204
+ productId,
205
+ startTime: cursor.format("YYYY-MM-DD HH:mm"),
206
+ endTime: slotEnd.format("YYYY-MM-DD HH:mm"),
207
+ price: new import_decimal.default(price).toFixed(2)
208
+ });
209
+ cursor = slotEnd;
210
+ }
211
+ } else {
212
+ const slotCount = meta.slot_count || 1;
213
+ const totalPrice = new import_decimal.default(product.selling_price || "0");
214
+ const perSlotPrice = slotCount > 0 ? totalPrice.div(slotCount).toFixed(2) : totalPrice.toFixed(2);
215
+ while (cursor.isBefore(end)) {
216
+ const slotEnd = cursor.add(slotDurationMinutes, "minute");
217
+ result.push({
218
+ resourceId,
219
+ productId,
220
+ startTime: cursor.format("YYYY-MM-DD HH:mm"),
221
+ endTime: slotEnd.format("YYYY-MM-DD HH:mm"),
222
+ price: perSlotPrice
223
+ });
224
+ cursor = slotEnd;
225
+ }
226
+ }
227
+ return result;
228
+ }
229
+ // Annotate the CommonJS export names for ESM import in node:
230
+ 0 && (module.exports = {
231
+ buildPriceBreakdown,
232
+ buildVenueBookingEntry,
233
+ buildVenueIdentityKey,
234
+ buildVenueResourceMetadata,
235
+ expandMergedSlotToIndividual,
236
+ mergeConsecutiveSlots
237
+ });
@@ -0,0 +1,32 @@
1
+ import dayjs from 'dayjs';
2
+ import type { VenueBookingSlotConfig, VenueResourceRawData, VenueTimeSlotGrid, ResourceProductMapping } from '../types';
3
+ export declare function isBusinessHoursCrossDay(config: VenueBookingSlotConfig): boolean;
4
+ export declare function generateTimeLabels(config: VenueBookingSlotConfig): string[];
5
+ export declare function isSlotOccupied(slotStart: dayjs.Dayjs, slotEnd: dayjs.Dayjs, occupiedTimes: Array<{
6
+ start_at: string;
7
+ end_at: string;
8
+ }>): boolean;
9
+ interface SlotEvent {
10
+ start_at: string;
11
+ end_at: string;
12
+ pax: number;
13
+ }
14
+ export declare function collectEventsForDate(resource: VenueResourceRawData, date: string, config: VenueBookingSlotConfig): SlotEvent[];
15
+ export declare function computeSlotStatus(params: {
16
+ slotStart: dayjs.Dayjs;
17
+ slotEnd: dayjs.Dayjs;
18
+ events: SlotEvent[];
19
+ resourceType: 'single' | 'multiple' | 'capacity';
20
+ capacity: number;
21
+ }): {
22
+ status: 'available' | 'occupied' | 'partially_occupied';
23
+ remainingCapacity: number;
24
+ };
25
+ export declare function buildTimeSlotGrid(params: {
26
+ date: string;
27
+ config: VenueBookingSlotConfig;
28
+ rawResources: VenueResourceRawData[];
29
+ resourceProductMap: Map<number | string, ResourceProductMapping[]>;
30
+ quotationPriceMap?: Map<string, string | null>;
31
+ }): VenueTimeSlotGrid;
32
+ export {};