@pisell/pisellos 2.1.171 → 2.1.172

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 (230) hide show
  1. package/dist/index.d.ts +1 -1
  2. package/dist/index.js +1 -3
  3. package/dist/model/strategy/adapter/index.d.ts +0 -4
  4. package/dist/model/strategy/adapter/index.js +1 -5
  5. package/dist/model/strategy/adapter/promotion/evaluator.js +99 -26
  6. package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +2 -0
  7. package/dist/model/strategy/adapter/walletPass/evaluator.js +61 -8
  8. package/dist/model/strategy/adapter/walletPass/locales.js +12 -3
  9. package/dist/model/strategy/engine.d.ts +18 -5
  10. package/dist/model/strategy/engine.js +145 -45
  11. package/dist/model/strategy/type.d.ts +17 -0
  12. package/dist/model/strategy/type.js +4 -0
  13. package/dist/modules/Cart/types.d.ts +2 -0
  14. package/dist/modules/Cart/utils/cartProduct.js +56 -25
  15. package/dist/modules/Cart/utils/changePrice.js +9 -16
  16. package/dist/modules/Discount/index.d.ts +4 -13
  17. package/dist/modules/Discount/index.js +12 -124
  18. package/dist/modules/Discount/types.d.ts +18 -13
  19. package/dist/modules/Order/index.d.ts +1 -67
  20. package/dist/modules/Order/index.js +30 -918
  21. package/dist/modules/Order/types.d.ts +12 -176
  22. package/dist/modules/Order/types.js +0 -2
  23. package/dist/modules/Order/utils.d.ts +0 -118
  24. package/dist/modules/Order/utils.js +2 -586
  25. package/dist/modules/Payment/index.d.ts +2 -1
  26. package/dist/modules/Payment/index.js +10 -7
  27. package/dist/modules/Payment/utils.js +3 -0
  28. package/dist/modules/Payment/walletpass.d.ts +23 -0
  29. package/dist/modules/Payment/walletpass.js +191 -95
  30. package/dist/modules/Product/utils.js +2 -2
  31. package/dist/modules/ProductList/index.d.ts +2 -4
  32. package/dist/modules/ProductList/index.js +12 -24
  33. package/dist/modules/Rules/index.d.ts +9 -5
  34. package/dist/modules/Rules/index.js +669 -173
  35. package/dist/modules/Rules/types.d.ts +2 -0
  36. package/dist/modules/Schedule/getDateIsInSchedule.js +18 -16
  37. package/dist/modules/Schedule/utils.d.ts +1 -1
  38. package/dist/modules/Summary/types.d.ts +2 -0
  39. package/dist/modules/Summary/utils.d.ts +9 -3
  40. package/dist/modules/Summary/utils.js +57 -67
  41. package/dist/modules/index.d.ts +0 -4
  42. package/dist/modules/index.js +1 -5
  43. package/dist/plugins/window.d.ts +2 -0
  44. package/dist/solution/BookingByStep/index.d.ts +3 -2
  45. package/dist/solution/BookingByStep/index.js +43 -46
  46. package/dist/solution/BookingByStep/types.d.ts +1 -3
  47. package/dist/solution/BookingByStep/types.js +1 -5
  48. package/dist/solution/BookingByStep/utils/timeslots.d.ts +1 -3
  49. package/dist/solution/BookingByStep/utils/timeslots.js +12 -19
  50. package/dist/solution/Checkout/index.js +2 -0
  51. package/dist/solution/ShopDiscount/index.d.ts +2 -3
  52. package/dist/solution/ShopDiscount/index.js +60 -62
  53. package/dist/solution/ShopDiscount/types.d.ts +1 -1
  54. package/dist/solution/ShopDiscount/types.js +2 -1
  55. package/dist/solution/ShopDiscount/utils.js +26 -12
  56. package/dist/solution/index.d.ts +0 -2
  57. package/dist/solution/index.js +1 -3
  58. package/lib/index.d.ts +1 -1
  59. package/lib/index.js +3 -4
  60. package/lib/model/strategy/adapter/index.d.ts +0 -4
  61. package/lib/model/strategy/adapter/index.js +2 -13
  62. package/lib/model/strategy/adapter/promotion/evaluator.js +57 -8
  63. package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +2 -0
  64. package/lib/model/strategy/adapter/walletPass/evaluator.js +34 -3
  65. package/lib/model/strategy/adapter/walletPass/locales.js +12 -3
  66. package/lib/model/strategy/engine.d.ts +18 -5
  67. package/lib/model/strategy/engine.js +85 -21
  68. package/lib/model/strategy/type.d.ts +17 -0
  69. package/lib/modules/Cart/types.d.ts +2 -0
  70. package/lib/modules/Cart/utils/cartProduct.js +39 -12
  71. package/lib/modules/Cart/utils/changePrice.js +9 -13
  72. package/lib/modules/Discount/index.d.ts +4 -13
  73. package/lib/modules/Discount/index.js +5 -76
  74. package/lib/modules/Discount/types.d.ts +18 -13
  75. package/lib/modules/Order/index.d.ts +1 -67
  76. package/lib/modules/Order/index.js +1 -525
  77. package/lib/modules/Order/types.d.ts +12 -176
  78. package/lib/modules/Order/utils.d.ts +0 -118
  79. package/lib/modules/Order/utils.js +2 -483
  80. package/lib/modules/Payment/index.d.ts +2 -1
  81. package/lib/modules/Payment/index.js +1 -0
  82. package/lib/modules/Payment/utils.js +3 -0
  83. package/lib/modules/Payment/walletpass.d.ts +23 -0
  84. package/lib/modules/Payment/walletpass.js +94 -17
  85. package/lib/modules/Product/utils.js +2 -2
  86. package/lib/modules/ProductList/index.d.ts +2 -4
  87. package/lib/modules/ProductList/index.js +39 -46
  88. package/lib/modules/Rules/index.d.ts +9 -5
  89. package/lib/modules/Rules/index.js +776 -292
  90. package/lib/modules/Rules/types.d.ts +2 -0
  91. package/lib/modules/Schedule/getDateIsInSchedule.js +11 -13
  92. package/lib/modules/Schedule/utils.d.ts +1 -1
  93. package/lib/modules/Summary/types.d.ts +2 -0
  94. package/lib/modules/Summary/utils.d.ts +9 -3
  95. package/lib/modules/Summary/utils.js +34 -45
  96. package/lib/modules/index.d.ts +0 -4
  97. package/lib/modules/index.js +1 -9
  98. package/lib/plugins/window.d.ts +2 -0
  99. package/lib/solution/BookingByStep/index.d.ts +3 -2
  100. package/lib/solution/BookingByStep/index.js +4 -6
  101. package/lib/solution/BookingByStep/types.d.ts +1 -3
  102. package/lib/solution/BookingByStep/types.js +0 -10
  103. package/lib/solution/BookingByStep/utils/timeslots.d.ts +1 -3
  104. package/lib/solution/BookingByStep/utils/timeslots.js +11 -19
  105. package/lib/solution/Checkout/index.js +2 -0
  106. package/lib/solution/ShopDiscount/index.d.ts +2 -3
  107. package/lib/solution/ShopDiscount/index.js +27 -22
  108. package/lib/solution/ShopDiscount/types.d.ts +1 -1
  109. package/lib/solution/ShopDiscount/utils.js +10 -6
  110. package/lib/solution/index.d.ts +0 -2
  111. package/lib/solution/index.js +1 -5
  112. package/package.json +2 -2
  113. package/dist/apis/picoding.d.ts +0 -0
  114. package/dist/apis/picoding.js +0 -1
  115. package/dist/model/strategy/adapter/dataVariant/adapter.d.ts +0 -50
  116. package/dist/model/strategy/adapter/dataVariant/adapter.js +0 -167
  117. package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +0 -89
  118. package/dist/model/strategy/adapter/dataVariant/evaluator.js +0 -780
  119. package/dist/model/strategy/adapter/dataVariant/examples.d.ts +0 -39
  120. package/dist/model/strategy/adapter/dataVariant/examples.js +0 -277
  121. package/dist/model/strategy/adapter/dataVariant/index.d.ts +0 -4
  122. package/dist/model/strategy/adapter/dataVariant/index.js +0 -4
  123. package/dist/model/strategy/adapter/dataVariant/type.d.ts +0 -148
  124. package/dist/model/strategy/adapter/dataVariant/type.js +0 -54
  125. package/dist/modules/OpenData/index.d.ts +0 -24
  126. package/dist/modules/OpenData/index.js +0 -173
  127. package/dist/modules/OpenData/types.d.ts +0 -73
  128. package/dist/modules/OpenData/types.js +0 -1
  129. package/dist/modules/OpenData/utils.d.ts +0 -2
  130. package/dist/modules/OpenData/utils.js +0 -75
  131. package/dist/modules/Quotation/index.d.ts +0 -48
  132. package/dist/modules/Quotation/index.js +0 -248
  133. package/dist/modules/Quotation/types.d.ts +0 -42
  134. package/dist/modules/Quotation/types.js +0 -1
  135. package/dist/modules/SalesSummary/index.d.ts +0 -63
  136. package/dist/modules/SalesSummary/index.js +0 -174
  137. package/dist/modules/SalesSummary/types.d.ts +0 -60
  138. package/dist/modules/SalesSummary/types.js +0 -1
  139. package/dist/modules/SalesSummary/utils.d.ts +0 -30
  140. package/dist/modules/SalesSummary/utils.js +0 -480
  141. package/dist/modules/ScanOrderLogger/index.d.ts +0 -23
  142. package/dist/modules/ScanOrderLogger/index.js +0 -174
  143. package/dist/modules/ScanOrderLogger/providers/feishu.d.ts +0 -2
  144. package/dist/modules/ScanOrderLogger/providers/feishu.js +0 -221
  145. package/dist/modules/ScanOrderLogger/providers/grafana.d.ts +0 -2
  146. package/dist/modules/ScanOrderLogger/providers/grafana.js +0 -50
  147. package/dist/modules/ScanOrderLogger/types.d.ts +0 -53
  148. package/dist/modules/ScanOrderLogger/types.js +0 -1
  149. package/dist/solution/ScanOrder/index.d.ts +0 -158
  150. package/dist/solution/ScanOrder/index.js +0 -3474
  151. package/dist/solution/ScanOrder/types.d.ts +0 -306
  152. package/dist/solution/ScanOrder/types.js +0 -35
  153. package/dist/solution/ScanOrder/utils.d.ts +0 -172
  154. package/dist/solution/ScanOrder/utils.js +0 -796
  155. package/dist/solution/VenueBooking/index.d.ts +0 -262
  156. package/dist/solution/VenueBooking/index.js +0 -3991
  157. package/dist/solution/VenueBooking/sales-section-4-annotated.json +0 -343
  158. package/dist/solution/VenueBooking/types.d.ts +0 -156
  159. package/dist/solution/VenueBooking/types.js +0 -22
  160. package/dist/solution/VenueBooking/utils/dateSummary.d.ts +0 -11
  161. package/dist/solution/VenueBooking/utils/dateSummary.js +0 -91
  162. package/dist/solution/VenueBooking/utils/resource.d.ts +0 -14
  163. package/dist/solution/VenueBooking/utils/resource.js +0 -131
  164. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +0 -32
  165. package/dist/solution/VenueBooking/utils/slotMerge.js +0 -233
  166. package/dist/solution/VenueBooking/utils/smartPricing.d.ts +0 -70
  167. package/dist/solution/VenueBooking/utils/smartPricing.js +0 -233
  168. package/dist/solution/VenueBooking/utils/timeSlot.d.ts +0 -34
  169. package/dist/solution/VenueBooking/utils/timeSlot.js +0 -458
  170. package/dist/solution/VenueBooking/utils.d.ts +0 -1
  171. package/dist/solution/VenueBooking/utils.js +0 -1
  172. package/lib/apis/picoding.d.ts +0 -0
  173. package/lib/apis/picoding.js +0 -0
  174. package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +0 -50
  175. package/lib/model/strategy/adapter/dataVariant/adapter.js +0 -149
  176. package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +0 -89
  177. package/lib/model/strategy/adapter/dataVariant/evaluator.js +0 -583
  178. package/lib/model/strategy/adapter/dataVariant/examples.d.ts +0 -39
  179. package/lib/model/strategy/adapter/dataVariant/examples.js +0 -293
  180. package/lib/model/strategy/adapter/dataVariant/index.d.ts +0 -4
  181. package/lib/model/strategy/adapter/dataVariant/index.js +0 -38
  182. package/lib/model/strategy/adapter/dataVariant/type.d.ts +0 -148
  183. package/lib/model/strategy/adapter/dataVariant/type.js +0 -31
  184. package/lib/modules/OpenData/index.d.ts +0 -24
  185. package/lib/modules/OpenData/index.js +0 -119
  186. package/lib/modules/OpenData/types.d.ts +0 -73
  187. package/lib/modules/OpenData/types.js +0 -17
  188. package/lib/modules/OpenData/utils.d.ts +0 -2
  189. package/lib/modules/OpenData/utils.js +0 -111
  190. package/lib/modules/Quotation/index.d.ts +0 -48
  191. package/lib/modules/Quotation/index.js +0 -152
  192. package/lib/modules/Quotation/types.d.ts +0 -42
  193. package/lib/modules/Quotation/types.js +0 -17
  194. package/lib/modules/SalesSummary/index.d.ts +0 -63
  195. package/lib/modules/SalesSummary/index.js +0 -105
  196. package/lib/modules/SalesSummary/types.d.ts +0 -60
  197. package/lib/modules/SalesSummary/types.js +0 -17
  198. package/lib/modules/SalesSummary/utils.d.ts +0 -30
  199. package/lib/modules/SalesSummary/utils.js +0 -420
  200. package/lib/modules/ScanOrderLogger/index.d.ts +0 -23
  201. package/lib/modules/ScanOrderLogger/index.js +0 -147
  202. package/lib/modules/ScanOrderLogger/providers/feishu.d.ts +0 -2
  203. package/lib/modules/ScanOrderLogger/providers/feishu.js +0 -157
  204. package/lib/modules/ScanOrderLogger/providers/grafana.d.ts +0 -2
  205. package/lib/modules/ScanOrderLogger/providers/grafana.js +0 -52
  206. package/lib/modules/ScanOrderLogger/types.d.ts +0 -53
  207. package/lib/modules/ScanOrderLogger/types.js +0 -17
  208. package/lib/solution/ScanOrder/index.d.ts +0 -158
  209. package/lib/solution/ScanOrder/index.js +0 -2135
  210. package/lib/solution/ScanOrder/types.d.ts +0 -306
  211. package/lib/solution/ScanOrder/types.js +0 -36
  212. package/lib/solution/ScanOrder/utils.d.ts +0 -172
  213. package/lib/solution/ScanOrder/utils.js +0 -658
  214. package/lib/solution/VenueBooking/index.d.ts +0 -262
  215. package/lib/solution/VenueBooking/index.js +0 -2394
  216. package/lib/solution/VenueBooking/sales-section-4-annotated.json +0 -343
  217. package/lib/solution/VenueBooking/types.d.ts +0 -156
  218. package/lib/solution/VenueBooking/types.js +0 -45
  219. package/lib/solution/VenueBooking/utils/dateSummary.d.ts +0 -11
  220. package/lib/solution/VenueBooking/utils/dateSummary.js +0 -105
  221. package/lib/solution/VenueBooking/utils/resource.d.ts +0 -14
  222. package/lib/solution/VenueBooking/utils/resource.js +0 -92
  223. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +0 -32
  224. package/lib/solution/VenueBooking/utils/slotMerge.js +0 -236
  225. package/lib/solution/VenueBooking/utils/smartPricing.d.ts +0 -70
  226. package/lib/solution/VenueBooking/utils/smartPricing.js +0 -180
  227. package/lib/solution/VenueBooking/utils/timeSlot.d.ts +0 -34
  228. package/lib/solution/VenueBooking/utils/timeSlot.js +0 -343
  229. package/lib/solution/VenueBooking/utils.d.ts +0 -1
  230. package/lib/solution/VenueBooking/utils.js +0 -69
@@ -1,14 +0,0 @@
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[]>;
@@ -1,92 +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/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
- });
@@ -1,32 +0,0 @@
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
- }): PriceBreakdownEntry[];
9
- export interface BuildVenueBookingParams {
10
- group: MergedSlotGroup;
11
- resourceId: number | string;
12
- mapping: ResourceProductMapping;
13
- rawResource: VenueResourceRawData | undefined;
14
- bookingUuid: string;
15
- productUid: string;
16
- /**
17
- * 若当前 resource 是组合资源(combined_resource.status === 1),传入其子资源的原始数据,
18
- * 将作为 resources[0].children 写入 booking,结构与父 resource 保持一致。
19
- */
20
- childResources?: VenueResourceRawData[];
21
- }
22
- export declare function buildVenueResourceMetadata(params: {
23
- mapping: ResourceProductMapping;
24
- rawResource: VenueResourceRawData | undefined;
25
- }): Record<string, any>;
26
- export declare function buildVenueBookingEntry(params: BuildVenueBookingParams): Record<string, any>;
27
- /**
28
- * 从一条已合并的订单商品还原出独立的时段列表。
29
- * 优先使用 metadata.price_breakdown 还原每个时段的精确价格,
30
- * 回退到按 selling_price / slot_count 均分。
31
- */
32
- export declare function expandMergedSlotToIndividual(product: ScanOrderOrderProduct, slotDurationMinutes: number): VenueSlotSelection[];
@@ -1,236 +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/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 } = 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 startHm = (0, import_dayjs.default)(slot.startTime, "YYYY-MM-DD HH:mm").format("YYYY-MM-DD HH:mm");
92
- const endHm = (0, import_dayjs.default)(slot.endTime, "YYYY-MM-DD HH:mm").format("YYYY-MM-DD HH:mm");
93
- const last = entries[entries.length - 1];
94
- if (last && last.unit_price === unitPrice && last.quotation_shelf_id === 0 && last.end_time === startHm) {
95
- last.end_time = endHm;
96
- last.quantity += 1;
97
- } else {
98
- entries.push({
99
- start_time: startHm,
100
- end_time: endHm,
101
- unit_price: unitPrice,
102
- quotation_shelf_id: 0,
103
- quantity: 1
104
- });
105
- }
106
- }
107
- return entries;
108
- }
109
- function buildVenueResourceMetadata(params) {
110
- const { mapping, rawResource } = params;
111
- const combined = rawResource == null ? void 0 : rawResource.combined_resource;
112
- const isCombined = !!(combined && combined.status === 1 && Array.isArray(combined.resource_ids));
113
- return {
114
- form_name: mapping.formName ?? mapping.resourceName,
115
- resource_name: (rawResource == null ? void 0 : rawResource.main_field) ?? mapping.resourceName,
116
- combined_resource: isCombined ? combined : null
117
- };
118
- }
119
- function buildVenueBookingEntry(params) {
120
- const { group, resourceId, mapping, rawResource, bookingUuid, productUid, childResources } = params;
121
- const startMoment = (0, import_dayjs.default)(group.startTime, "YYYY-MM-DD HH:mm");
122
- const endMoment = (0, import_dayjs.default)(group.endTime, "YYYY-MM-DD HH:mm");
123
- const duration = endMoment.diff(startMoment, "minute");
124
- const resourceEntry = {
125
- relation_type: "form",
126
- like_status: "common",
127
- id: resourceId,
128
- main_field: mapping.resourceName,
129
- form_id: (rawResource == null ? void 0 : rawResource.form_id) ?? mapping.formId,
130
- relation_id: resourceId,
131
- capacity: 1,
132
- metadata: buildVenueResourceMetadata({ mapping, rawResource })
133
- };
134
- if (childResources && childResources.length) {
135
- resourceEntry.children = childResources.map((child) => ({
136
- relation_type: "form",
137
- like_status: "common",
138
- id: child.resourceId,
139
- main_field: child.main_field || "",
140
- form_id: child.form_id ?? child.formId,
141
- relation_id: child.resourceId,
142
- capacity: child.capacity ?? 1,
143
- metadata: {}
144
- }));
145
- }
146
- return {
147
- schedule_event_id: null,
148
- appointment_status: "new",
149
- start_date: startMoment.format("YYYY-MM-DD"),
150
- start_time: startMoment.format("HH:mm"),
151
- end_date: endMoment.format("YYYY-MM-DD"),
152
- end_time: endMoment.format("HH:mm"),
153
- select_date: startMoment.format("YYYY-MM-DD"),
154
- duration,
155
- sub_type: "minutes",
156
- like_status: "common",
157
- number: 1,
158
- is_all: false,
159
- schedule_id: 0,
160
- product_uid: productUid,
161
- resources: [resourceEntry],
162
- relation_products: [],
163
- relation_forms: [],
164
- holder: null,
165
- metadata: {
166
- unique_identification_number: bookingUuid,
167
- venue_booking: true,
168
- resource_id: resourceId,
169
- product_id: mapping.productId
170
- }
171
- };
172
- }
173
- function expandMergedSlotToIndividual(product, slotDurationMinutes) {
174
- const meta = product.metadata || {};
175
- const resourceId = meta.resource_id;
176
- if (resourceId == null)
177
- return [];
178
- const startTime = meta.start_time;
179
- const endTime = meta.end_time;
180
- if (!startTime || !endTime)
181
- return [];
182
- const productId = Number(product.product_id);
183
- const breakdown = meta.price_breakdown;
184
- const result = [];
185
- let cursor = (0, import_dayjs.default)(startTime, "YYYY-MM-DD HH:mm");
186
- const end = (0, import_dayjs.default)(endTime, "YYYY-MM-DD HH:mm");
187
- if (breakdown == null ? void 0 : breakdown.length) {
188
- const priceMap = /* @__PURE__ */ new Map();
189
- for (const entry of breakdown) {
190
- let entryCursor = (0, import_dayjs.default)(entry.start_time, "YYYY-MM-DD HH:mm");
191
- const entryEnd = (0, import_dayjs.default)(entry.end_time, "YYYY-MM-DD HH:mm");
192
- while (entryCursor.isBefore(entryEnd)) {
193
- priceMap.set(entryCursor.format("HH:mm"), entry.unit_price);
194
- entryCursor = entryCursor.add(slotDurationMinutes, "minute");
195
- }
196
- }
197
- while (cursor.isBefore(end)) {
198
- const slotEnd = cursor.add(slotDurationMinutes, "minute");
199
- const hm = cursor.format("HH:mm");
200
- const price = priceMap.get(hm) ?? 0;
201
- result.push({
202
- resourceId,
203
- productId,
204
- startTime: cursor.format("YYYY-MM-DD HH:mm"),
205
- endTime: slotEnd.format("YYYY-MM-DD HH:mm"),
206
- price: new import_decimal.default(price).toFixed(2)
207
- });
208
- cursor = slotEnd;
209
- }
210
- } else {
211
- const slotCount = meta.slot_count || 1;
212
- const totalPrice = new import_decimal.default(product.selling_price || "0");
213
- const perSlotPrice = slotCount > 0 ? totalPrice.div(slotCount).toFixed(2) : totalPrice.toFixed(2);
214
- while (cursor.isBefore(end)) {
215
- const slotEnd = cursor.add(slotDurationMinutes, "minute");
216
- result.push({
217
- resourceId,
218
- productId,
219
- startTime: cursor.format("YYYY-MM-DD HH:mm"),
220
- endTime: slotEnd.format("YYYY-MM-DD HH:mm"),
221
- price: perSlotPrice
222
- });
223
- cursor = slotEnd;
224
- }
225
- }
226
- return result;
227
- }
228
- // Annotate the CommonJS export names for ESM import in node:
229
- 0 && (module.exports = {
230
- buildPriceBreakdown,
231
- buildVenueBookingEntry,
232
- buildVenueIdentityKey,
233
- buildVenueResourceMetadata,
234
- expandMergedSlotToIndividual,
235
- mergeConsecutiveSlots
236
- });
@@ -1,70 +0,0 @@
1
- import type { ProductData } from '../../../modules/Product/types';
2
- import type { ScheduleItem } from '../../../modules/Schedule/types';
3
- import type { DataVariantBusinessData, DataVariantMenu, DataVariantProduct } from '../../../model/strategy/adapter/dataVariant/type';
4
- import type { DataVariantEvaluator } from '../../../model/strategy/adapter/dataVariant/evaluator';
5
- import type { StrategyConfig } from '../../../model/strategy/type';
6
- import type { VenueBookingSlotConfig } from '../types';
7
- /** VenueBooking 智能定价运行时上下文 */
8
- export interface VenueBookingSmartPricingContext {
9
- evaluator?: DataVariantEvaluator | null;
10
- scheduleList?: ScheduleItem[];
11
- menuList?: DataVariantMenu[];
12
- customerId?: number | string;
13
- availableWalletIds?: Array<number | string>;
14
- channel?: string;
15
- businessCode?: string;
16
- orderType?: string;
17
- strategy_context?: Record<string, any>;
18
- strategyConfigs?: StrategyConfig[];
19
- }
20
- /** 从商品上读取展示/算价用的 price 字段 */
21
- export declare function extractProductPrice(product: DataVariantProduct): string | null;
22
- /** 组装 DataVariant 评估入参,对齐 OS Server buildProductFormatterContext 语义 */
23
- export declare function buildDataVariantBusinessData(products: ProductData[], context: VenueBookingSmartPricingContext, scheduleDateTime: string): DataVariantBusinessData;
24
- /**
25
- * 对商品列表执行一次智能定价格式化(loadProducts 后使用)。
26
- * evaluator 未注入时原样返回并打 warning。
27
- */
28
- export declare function formatProductsWithDataVariant(products: ProductData[], context: VenueBookingSmartPricingContext, scheduleDateTime?: string): ProductData[];
29
- /**
30
- * 根据 schedule_time_points 与营业开始时间,构造当天需要评估的 datetime 列表(升序)。
31
- * 跨日营业时,早于营业开始小时的时间点归到次日。
32
- */
33
- export declare function buildEvaluationDatetimes(params: {
34
- date: string;
35
- config: VenueBookingSlotConfig;
36
- scheduleTimePoints: string[];
37
- }): string[];
38
- /** 找到 slot 时间所属分段的评估 datetime(max(evalDt <= slotDt)) */
39
- export declare function findSegmentEvalDatetime(slotDatetime: string, evalDatetimes: string[]): string;
40
- /** 将 slot 标签转为与 timeSlot 网格一致的 slotStart 字符串 */
41
- export declare function buildSlotStartDatetime(date: string, label: string, config: VenueBookingSlotConfig): string;
42
- /**
43
- * 按 schedule 分段批量 resolveProducts,输出与 quotation 相同 key 格式的 slot 价格 Map。
44
- * key: `${productId}:${slotStart}`,value: price | null
45
- */
46
- export declare function buildSlotPriceMapByScheduleSegments(params: {
47
- products: ProductData[];
48
- productIds: number[];
49
- date: string;
50
- timeLabels: string[];
51
- config: VenueBookingSlotConfig;
52
- context: VenueBookingSmartPricingContext;
53
- }): Map<string, string | null>;
54
- /**
55
- * 指定商品在某一 datetime 的智能定价(addon / 单点重算用)。
56
- */
57
- export declare function getPriceForProductAtDatetime(params: {
58
- products: ProductData[];
59
- context: VenueBookingSmartPricingContext;
60
- productId: number;
61
- datetime: string;
62
- fallbackPrice?: string;
63
- }): string;
64
- /** 从 slot 价格 Map 读取单价,找不到则回退 fallback */
65
- export declare function getSlotPriceFromMap(params: {
66
- slotPriceMap: Map<string, string | null>;
67
- productId: number;
68
- slotStartTime: string;
69
- fallbackPrice?: string;
70
- }): string;
@@ -1,180 +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/solution/VenueBooking/utils/smartPricing.ts
30
- var smartPricing_exports = {};
31
- __export(smartPricing_exports, {
32
- buildDataVariantBusinessData: () => buildDataVariantBusinessData,
33
- buildEvaluationDatetimes: () => buildEvaluationDatetimes,
34
- buildSlotPriceMapByScheduleSegments: () => buildSlotPriceMapByScheduleSegments,
35
- buildSlotStartDatetime: () => buildSlotStartDatetime,
36
- extractProductPrice: () => extractProductPrice,
37
- findSegmentEvalDatetime: () => findSegmentEvalDatetime,
38
- formatProductsWithDataVariant: () => formatProductsWithDataVariant,
39
- getPriceForProductAtDatetime: () => getPriceForProductAtDatetime,
40
- getSlotPriceFromMap: () => getSlotPriceFromMap
41
- });
42
- module.exports = __toCommonJS(smartPricing_exports);
43
- var import_dayjs = __toESM(require("dayjs"));
44
- var import_timeSlot = require("./timeSlot");
45
- function extractProductPrice(product) {
46
- const price = (product == null ? void 0 : product.price) ?? (product == null ? void 0 : product.selling_price);
47
- if (price == null || price === "")
48
- return null;
49
- return String(price);
50
- }
51
- function buildDataVariantBusinessData(products, context, scheduleDateTime) {
52
- const strategyContext = context.strategy_context || {};
53
- return {
54
- products,
55
- strategyConfigs: context.strategyConfigs,
56
- scheduleDateTime,
57
- scheduleList: context.scheduleList || [],
58
- menuList: context.menuList || [],
59
- customerId: context.customerId,
60
- availableWalletIds: context.availableWalletIds ?? strategyContext.available_wallet_ids ?? strategyContext.availableWalletIds,
61
- channel: context.channel ?? strategyContext.channel,
62
- orderType: context.orderType ?? strategyContext.orderType ?? strategyContext.order_type,
63
- businessCode: context.businessCode ?? strategyContext.business_code ?? strategyContext.businessCode,
64
- custom: strategyContext
65
- };
66
- }
67
- function formatProductsWithDataVariant(products, context, scheduleDateTime) {
68
- const evaluator = context.evaluator;
69
- if (!evaluator || typeof evaluator.resolveProducts !== "function") {
70
- console.warn("[VenueBooking][smartPricing] dataVariantEvaluator 未注入,跳过智能定价格式化");
71
- return products;
72
- }
73
- const resolvedAt = scheduleDateTime || (0, import_dayjs.default)().format("YYYY-MM-DD HH:mm:ss");
74
- const businessData = buildDataVariantBusinessData(products, context, resolvedAt);
75
- const result = evaluator.resolveProducts(businessData);
76
- return Array.isArray(result == null ? void 0 : result.products) ? result.products : products;
77
- }
78
- function buildEvaluationDatetimes(params) {
79
- const { date, config, scheduleTimePoints } = params;
80
- const crossDay = (0, import_timeSlot.isBusinessHoursCrossDay)(config);
81
- const businessStartHour = Number(config.businessStartTime.split(":")[0]);
82
- const evalSet = /* @__PURE__ */ new Set();
83
- evalSet.add(`${date} ${config.businessStartTime}`);
84
- for (const timePoint of scheduleTimePoints) {
85
- const hour = Number(timePoint.split(":")[0]);
86
- const pointDate = crossDay && hour < businessStartHour ? (0, import_dayjs.default)(date).add(1, "day").format("YYYY-MM-DD") : date;
87
- evalSet.add(`${pointDate} ${timePoint}`);
88
- }
89
- return Array.from(evalSet).sort((a, b) => {
90
- const aMs = (0, import_dayjs.default)(a, ["YYYY-MM-DD HH:mm:ss", "YYYY-MM-DD HH:mm"]).valueOf();
91
- const bMs = (0, import_dayjs.default)(b, ["YYYY-MM-DD HH:mm:ss", "YYYY-MM-DD HH:mm"]).valueOf();
92
- return aMs - bMs;
93
- });
94
- }
95
- function findSegmentEvalDatetime(slotDatetime, evalDatetimes) {
96
- if (!evalDatetimes.length)
97
- return slotDatetime;
98
- const slotMs = (0, import_dayjs.default)(slotDatetime, ["YYYY-MM-DD HH:mm:ss", "YYYY-MM-DD HH:mm"]).valueOf();
99
- let chosen = evalDatetimes[0];
100
- for (const evalDt of evalDatetimes) {
101
- const evalMs = (0, import_dayjs.default)(evalDt, ["YYYY-MM-DD HH:mm:ss", "YYYY-MM-DD HH:mm"]).valueOf();
102
- if (evalMs <= slotMs) {
103
- chosen = evalDt;
104
- } else {
105
- break;
106
- }
107
- }
108
- return chosen;
109
- }
110
- function buildSlotStartDatetime(date, label, config) {
111
- const crossDay = (0, import_timeSlot.isBusinessHoursCrossDay)(config);
112
- const businessStartHour = Number(config.businessStartTime.split(":")[0]);
113
- const hour = Number(label.split(":")[0]);
114
- const slotDate = crossDay && hour < businessStartHour ? (0, import_dayjs.default)(date).add(1, "day").format("YYYY-MM-DD") : date;
115
- return (0, import_dayjs.default)(`${slotDate} ${label}`).format("YYYY-MM-DD HH:mm");
116
- }
117
- function buildSlotPriceMapByScheduleSegments(params) {
118
- const { products, productIds, date, timeLabels, config, context } = params;
119
- const map = /* @__PURE__ */ new Map();
120
- if (!productIds.length || !timeLabels.length)
121
- return map;
122
- const evaluator = context.evaluator;
123
- if (!evaluator || typeof evaluator.resolveProducts !== "function") {
124
- return map;
125
- }
126
- const strategyConfigs = context.strategyConfigs || (typeof evaluator.getStrategyConfigs === "function" ? evaluator.getStrategyConfigs() : []);
127
- const scheduleTimePoints = typeof evaluator.buildScheduleTimePoints === "function" ? evaluator.buildScheduleTimePoints(strategyConfigs, context.scheduleList || []) : [];
128
- const evalDatetimes = buildEvaluationDatetimes({ date, config, scheduleTimePoints });
129
- const priceCache = /* @__PURE__ */ new Map();
130
- for (const evalDt of evalDatetimes) {
131
- const resolved = formatProductsWithDataVariant(products, context, evalDt);
132
- const priceByProductId = /* @__PURE__ */ new Map();
133
- for (const product of resolved) {
134
- const productId = Number(product.id);
135
- if (!Number.isFinite(productId))
136
- continue;
137
- priceByProductId.set(productId, extractProductPrice(product));
138
- }
139
- priceCache.set(evalDt, priceByProductId);
140
- }
141
- for (const label of timeLabels) {
142
- const slotStart = buildSlotStartDatetime(date, label, config);
143
- const segmentEvalDt = findSegmentEvalDatetime(slotStart, evalDatetimes);
144
- const priceByProductId = priceCache.get(segmentEvalDt);
145
- for (const productId of productIds) {
146
- const key = `${productId}:${slotStart}`;
147
- const price = (priceByProductId == null ? void 0 : priceByProductId.get(productId)) ?? null;
148
- if (price !== null) {
149
- map.set(key, price);
150
- }
151
- }
152
- }
153
- return map;
154
- }
155
- function getPriceForProductAtDatetime(params) {
156
- const { products, context, productId, datetime, fallbackPrice } = params;
157
- const resolved = formatProductsWithDataVariant(products, context, datetime);
158
- const product = resolved.find((item) => Number(item.id) === Number(productId));
159
- return extractProductPrice(product || {}) ?? fallbackPrice ?? "0.00";
160
- }
161
- function getSlotPriceFromMap(params) {
162
- const { slotPriceMap, productId, slotStartTime, fallbackPrice } = params;
163
- const key = `${productId}:${slotStartTime}`;
164
- const mapped = slotPriceMap.get(key);
165
- if (mapped != null)
166
- return mapped;
167
- return fallbackPrice ?? "0.00";
168
- }
169
- // Annotate the CommonJS export names for ESM import in node:
170
- 0 && (module.exports = {
171
- buildDataVariantBusinessData,
172
- buildEvaluationDatetimes,
173
- buildSlotPriceMapByScheduleSegments,
174
- buildSlotStartDatetime,
175
- extractProductPrice,
176
- findSegmentEvalDatetime,
177
- formatProductsWithDataVariant,
178
- getPriceForProductAtDatetime,
179
- getSlotPriceFromMap
180
- });
@@ -1,34 +0,0 @@
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
- /** @deprecated 使用 slotPriceMap */
31
- quotationPriceMap?: Map<string, string | null>;
32
- slotPriceMap?: Map<string, string | null>;
33
- }): VenueTimeSlotGrid;
34
- export {};