@pisell/pisellos 2.2.178 → 2.2.180

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 (182) hide show
  1. package/dist/modules/Customer/index.d.ts +0 -6
  2. package/dist/modules/Customer/index.js +83 -129
  3. package/dist/modules/Customer/types.d.ts +0 -2
  4. package/dist/modules/Discount/index.d.ts +4 -2
  5. package/dist/modules/Discount/index.js +93 -8
  6. package/dist/modules/Discount/types.d.ts +7 -1
  7. package/dist/modules/Order/index.d.ts +17 -87
  8. package/dist/modules/Order/index.js +501 -1357
  9. package/dist/modules/Order/types.d.ts +19 -198
  10. package/dist/modules/Order/types.js +0 -31
  11. package/dist/modules/Order/utils.d.ts +1 -50
  12. package/dist/modules/Order/utils.js +32 -261
  13. package/dist/modules/Quotation/index.d.ts +1 -0
  14. package/dist/modules/Quotation/index.js +21 -23
  15. package/dist/modules/Rules/index.d.ts +0 -4
  16. package/dist/modules/Rules/index.js +10 -26
  17. package/dist/modules/SalesSummary/index.js +2 -4
  18. package/dist/modules/SalesSummary/utils.js +7 -21
  19. package/dist/modules/Schedule/index.js +2 -6
  20. package/dist/modules/index.d.ts +0 -1
  21. package/dist/modules/index.js +1 -2
  22. package/dist/server/index.js +29 -87
  23. package/dist/server/modules/order/index.d.ts +0 -23
  24. package/dist/server/modules/order/index.js +46 -123
  25. package/dist/server/modules/order/types.d.ts +2 -0
  26. package/dist/server/modules/order/utils/filterOrders.js +6 -20
  27. package/dist/server/modules/products/index.d.ts +1 -1
  28. package/dist/server/modules/products/index.js +113 -130
  29. package/dist/server/modules/schedule/index.js +6 -13
  30. package/dist/solution/BaseSales/index.d.ts +7 -89
  31. package/dist/solution/BaseSales/index.js +375 -1494
  32. package/dist/solution/BaseSales/types.d.ts +1 -67
  33. package/dist/solution/BaseSales/types.js +1 -3
  34. package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -0
  35. package/dist/solution/BaseSales/utils/parseSalesResponse.js +1 -1
  36. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +16 -68
  37. package/dist/solution/BaseSales/utils.js +8 -46
  38. package/dist/solution/BookingByStep/index.d.ts +1 -1
  39. package/dist/solution/BookingTicket/index.d.ts +1 -133
  40. package/dist/solution/BookingTicket/index.js +175 -780
  41. package/dist/solution/BookingTicket/types.d.ts +0 -2
  42. package/dist/solution/BookingTicket/types.js +0 -3
  43. package/dist/solution/BookingTicket/utils/cartView.js +2 -4
  44. package/dist/solution/ScanOrder/index.d.ts +3 -9
  45. package/dist/solution/ScanOrder/index.js +128 -231
  46. package/dist/solution/ScanOrder/utils.js +8 -46
  47. package/dist/solution/ShopDiscount/index.d.ts +1 -0
  48. package/dist/solution/ShopDiscount/index.js +23 -18
  49. package/dist/solution/VenueBooking/index.d.ts +9 -5
  50. package/dist/solution/VenueBooking/index.js +55 -103
  51. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +0 -4
  52. package/dist/solution/VenueBooking/utils/slotMerge.js +0 -10
  53. package/lib/model/strategy/adapter/promotion/index.js +0 -49
  54. package/lib/modules/Customer/index.d.ts +0 -6
  55. package/lib/modules/Customer/index.js +11 -26
  56. package/lib/modules/Customer/types.d.ts +0 -2
  57. package/lib/modules/Discount/index.d.ts +4 -2
  58. package/lib/modules/Discount/index.js +63 -8
  59. package/lib/modules/Discount/types.d.ts +7 -1
  60. package/lib/modules/Order/index.d.ts +17 -87
  61. package/lib/modules/Order/index.js +150 -677
  62. package/lib/modules/Order/types.d.ts +19 -198
  63. package/lib/modules/Order/types.js +0 -1
  64. package/lib/modules/Order/utils.d.ts +1 -50
  65. package/lib/modules/Order/utils.js +22 -229
  66. package/lib/modules/Quotation/index.d.ts +1 -0
  67. package/lib/modules/Quotation/index.js +15 -18
  68. package/lib/modules/Rules/index.d.ts +0 -4
  69. package/lib/modules/Rules/index.js +14 -22
  70. package/lib/modules/SalesSummary/index.js +2 -4
  71. package/lib/modules/SalesSummary/utils.js +7 -21
  72. package/lib/modules/Schedule/index.js +1 -3
  73. package/lib/modules/index.d.ts +0 -1
  74. package/lib/modules/index.js +1 -3
  75. package/lib/server/index.js +4 -41
  76. package/lib/server/modules/order/index.d.ts +0 -23
  77. package/lib/server/modules/order/index.js +14 -46
  78. package/lib/server/modules/order/types.d.ts +2 -0
  79. package/lib/server/modules/order/utils/filterOrders.js +4 -12
  80. package/lib/server/modules/products/index.d.ts +1 -1
  81. package/lib/server/modules/products/index.js +20 -30
  82. package/lib/server/modules/schedule/index.js +1 -2
  83. package/lib/solution/BaseSales/index.d.ts +7 -89
  84. package/lib/solution/BaseSales/index.js +22 -736
  85. package/lib/solution/BaseSales/types.d.ts +1 -67
  86. package/lib/solution/BaseSales/types.js +1 -3
  87. package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -0
  88. package/lib/solution/BaseSales/utils/parseSalesResponse.js +1 -0
  89. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +12 -71
  90. package/lib/solution/BaseSales/utils.js +6 -46
  91. package/lib/solution/BookingByStep/index.d.ts +1 -1
  92. package/lib/solution/BookingTicket/index.d.ts +1 -133
  93. package/lib/solution/BookingTicket/index.js +8 -352
  94. package/lib/solution/BookingTicket/types.d.ts +0 -2
  95. package/lib/solution/BookingTicket/types.js +0 -6
  96. package/lib/solution/BookingTicket/utils/cartView.js +2 -4
  97. package/lib/solution/ScanOrder/index.d.ts +3 -9
  98. package/lib/solution/ScanOrder/index.js +66 -147
  99. package/lib/solution/ScanOrder/utils.js +6 -46
  100. package/lib/solution/ShopDiscount/index.d.ts +1 -0
  101. package/lib/solution/ShopDiscount/index.js +4 -2
  102. package/lib/solution/VenueBooking/index.d.ts +9 -5
  103. package/lib/solution/VenueBooking/index.js +14 -50
  104. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +0 -4
  105. package/lib/solution/VenueBooking/utils/slotMerge.js +0 -10
  106. package/package.json +2 -2
  107. package/dist/modules/BookingContext/index.d.ts +0 -37
  108. package/dist/modules/BookingContext/index.js +0 -436
  109. package/dist/modules/BookingContext/types.d.ts +0 -102
  110. package/dist/modules/BookingContext/types.js +0 -51
  111. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +0 -16
  112. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +0 -193
  113. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +0 -8
  114. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +0 -137
  115. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +0 -75
  116. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +0 -215
  117. package/dist/modules/BookingContext/utils/flexible.d.ts +0 -28
  118. package/dist/modules/BookingContext/utils/flexible.js +0 -56
  119. package/dist/modules/BookingContext/utils/formatResourceList.d.ts +0 -8
  120. package/dist/modules/BookingContext/utils/formatResourceList.js +0 -38
  121. package/dist/modules/BookingContext/utils/index.d.ts +0 -11
  122. package/dist/modules/BookingContext/utils/index.js +0 -11
  123. package/dist/modules/BookingContext/utils/noResource.d.ts +0 -13
  124. package/dist/modules/BookingContext/utils/noResource.js +0 -77
  125. package/dist/modules/BookingContext/utils/productExtend.d.ts +0 -72
  126. package/dist/modules/BookingContext/utils/productExtend.js +0 -339
  127. package/dist/modules/BookingContext/utils/resourceErrors.d.ts +0 -41
  128. package/dist/modules/BookingContext/utils/resourceErrors.js +0 -74
  129. package/dist/modules/BookingContext/utils/resourceSelection.d.ts +0 -7
  130. package/dist/modules/BookingContext/utils/resourceSelection.js +0 -24
  131. package/dist/modules/BookingContext/utils/resources.d.ts +0 -80
  132. package/dist/modules/BookingContext/utils/resources.js +0 -486
  133. package/dist/modules/BookingContext/utils/serviceTimes.d.ts +0 -55
  134. package/dist/modules/BookingContext/utils/serviceTimes.js +0 -151
  135. package/dist/modules/BookingContext/utils/timeSlices.d.ts +0 -42
  136. package/dist/modules/BookingContext/utils/timeSlices.js +0 -100
  137. package/dist/modules/Order/utils/manualProductDiscount.d.ts +0 -106
  138. package/dist/modules/Order/utils/manualProductDiscount.js +0 -212
  139. package/dist/solution/BaseSales/utils/cartPromotion.d.ts +0 -275
  140. package/dist/solution/BaseSales/utils/cartPromotion.js +0 -1258
  141. package/dist/solution/BaseSales/utils/quotationPrice.d.ts +0 -7
  142. package/dist/solution/BaseSales/utils/quotationPrice.js +0 -237
  143. package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +0 -113
  144. package/dist/solution/BookingTicket/utils/addProductDecision.js +0 -346
  145. package/lib/modules/BookingContext/index.d.ts +0 -37
  146. package/lib/modules/BookingContext/index.js +0 -297
  147. package/lib/modules/BookingContext/types.d.ts +0 -102
  148. package/lib/modules/BookingContext/types.js +0 -34
  149. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +0 -16
  150. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +0 -207
  151. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +0 -8
  152. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +0 -141
  153. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +0 -75
  154. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +0 -198
  155. package/lib/modules/BookingContext/utils/flexible.d.ts +0 -28
  156. package/lib/modules/BookingContext/utils/flexible.js +0 -80
  157. package/lib/modules/BookingContext/utils/formatResourceList.d.ts +0 -8
  158. package/lib/modules/BookingContext/utils/formatResourceList.js +0 -50
  159. package/lib/modules/BookingContext/utils/index.d.ts +0 -11
  160. package/lib/modules/BookingContext/utils/index.js +0 -43
  161. package/lib/modules/BookingContext/utils/noResource.d.ts +0 -13
  162. package/lib/modules/BookingContext/utils/noResource.js +0 -90
  163. package/lib/modules/BookingContext/utils/productExtend.d.ts +0 -72
  164. package/lib/modules/BookingContext/utils/productExtend.js +0 -283
  165. package/lib/modules/BookingContext/utils/resourceErrors.d.ts +0 -41
  166. package/lib/modules/BookingContext/utils/resourceErrors.js +0 -80
  167. package/lib/modules/BookingContext/utils/resourceSelection.d.ts +0 -7
  168. package/lib/modules/BookingContext/utils/resourceSelection.js +0 -46
  169. package/lib/modules/BookingContext/utils/resources.d.ts +0 -80
  170. package/lib/modules/BookingContext/utils/resources.js +0 -377
  171. package/lib/modules/BookingContext/utils/serviceTimes.d.ts +0 -55
  172. package/lib/modules/BookingContext/utils/serviceTimes.js +0 -162
  173. package/lib/modules/BookingContext/utils/timeSlices.d.ts +0 -42
  174. package/lib/modules/BookingContext/utils/timeSlices.js +0 -124
  175. package/lib/modules/Order/utils/manualProductDiscount.d.ts +0 -106
  176. package/lib/modules/Order/utils/manualProductDiscount.js +0 -207
  177. package/lib/solution/BaseSales/utils/cartPromotion.d.ts +0 -275
  178. package/lib/solution/BaseSales/utils/cartPromotion.js +0 -836
  179. package/lib/solution/BaseSales/utils/quotationPrice.d.ts +0 -7
  180. package/lib/solution/BaseSales/utils/quotationPrice.js +0 -277
  181. package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +0 -113
  182. package/lib/solution/BookingTicket/utils/addProductDecision.js +0 -318
@@ -1,102 +0,0 @@
1
- /**
2
- * BookingContext 子模块:承载「预约 UI 上下文」三件套。
3
- *
4
- * - bookingConfig:来自 `/core/board/management/config` 的整套预约配置(service_time / resource_tab /
5
- * appointment_subject / subject_require / stock_setting / basic / capacity 等)。
6
- * - resourcesOrigin / resourcesOriginMap:来自 `/schedule/resource/list` 的资源全集,含 times / event_list /
7
- * combined_resource 等运行态信息,是 getResourceByIds / getResourceTimeIsUsable 的输入。
8
- * - date:当前选择的日期(dayjs 或 ISO 字符串,迁移后内部统一存原始 ISO 字符串,UI 可自行解析)。
9
- *
10
- * 设计原则(与 BookingTicket 现状对齐):
11
- * - 默认由 `loadBookingConfig` / `loadResources` 拉取并写入 store;也支持消费方 `set*` 直接灌入(复用 ticketBooking 已拉到的数据)。
12
- * - 所有读 API 返回浅克隆(数组)或原引用(map / config),避免 UI 写穿。
13
- */
14
- /** `loadBookingConfig` 入参,与 ticketBooking `getBookingConfig` 一致。 */
15
- export interface LoadBookingConfigParams {
16
- item_type?: string;
17
- sub_type?: string;
18
- source_type?: string;
19
- [key: string]: any;
20
- }
21
- /** `loadResources` 入参,与 info2 `getResourceList` 一致。 */
22
- export interface LoadBookingResourcesParams {
23
- /** 查询日期,`YYYY-MM-DD`;缺省用 store 内已 set 的 date,再缺省为当天。 */
24
- date?: string;
25
- /** 编辑态排除容量占用用的 booking id 列表。 */
26
- bookingIds?: number[];
27
- }
28
- /** `initBookingContext` 入参(BookingTicket 聚合入口)。 */
29
- export interface InitBookingContextParams {
30
- bookingConfigParams?: LoadBookingConfigParams;
31
- date?: BookingContextDateInput;
32
- /** 是否拉资源列表,默认 true。 */
33
- loadResources?: boolean;
34
- bookingIds?: number[];
35
- /** 为 true 时忽略内存命中,强制重新请求(默认 false)。 */
36
- forceRefresh?: boolean;
37
- }
38
- /**
39
- * 资源全集 map:key 为资源 id(数字),value 为资源原始对象,含 times / event_list 等运行态。
40
- * 这里只声明 Record 形态;具体字段保留 `any`,与 ticketBooking 现网传入的数据形状兼容。
41
- */
42
- export type BookingContextResource = Record<string, any>;
43
- export type BookingContextResourceMap = Record<string, BookingContextResource>;
44
- /**
45
- * 形参 booking_config(结构来自 `/core/board/management/config` 接口)。
46
- * OS 不强制 schema,保留 `Record<string, any>` 兼容现网;常用路径文档化在 SDK docs。
47
- */
48
- export type BookingContextConfig = Record<string, any>;
49
- /**
50
- * 日期入参:接受 dayjs 实例、ISO 字符串、Date 实例;内部统一 normalize 为 ISO 字符串保存。
51
- */
52
- export type BookingContextDateInput = string | Date | {
53
- format?: (fmt?: string) => string;
54
- } | null | undefined;
55
- /**
56
- * 内部 store 形态。`resourcesOriginMap` 由 `setResources` 派生,不允许外部直接 set。
57
- */
58
- export interface BookingContextState {
59
- bookingConfig: BookingContextConfig | null;
60
- resourcesOrigin: BookingContextResource[];
61
- resourcesOriginMap: BookingContextResourceMap;
62
- /**
63
- * 当前选择的日期,统一 ISO 字符串('YYYY-MM-DD HH:mm:ss' 或 'YYYY-MM-DD')。
64
- * UI 取出后可自行 dayjs 解析;OS 内的计算 helper 都接受 string,不做 dayjs 依赖。
65
- */
66
- date: string | null;
67
- }
68
- /**
69
- * BookingContextModule 对外 API(给 BookingTicket / SDK Provider 透传消费)。
70
- */
71
- export interface BookingContextModuleAPI {
72
- setBookingConfig(config: BookingContextConfig | null): void;
73
- getBookingConfig(): BookingContextConfig | null;
74
- setResources(resources: BookingContextResource[] | null | undefined): void;
75
- getResourcesOrigin(): BookingContextResource[];
76
- getResourcesOriginMap(): BookingContextResourceMap;
77
- setDate(date: BookingContextDateInput): void;
78
- getDate(): string | null;
79
- /** 当前 store 的浅克隆,调试 / 测试用。 */
80
- getState(): BookingContextState;
81
- /** 一键清空,destroy / 切租户场景用。 */
82
- clear(): void;
83
- /** 拉取 board config 并写入 store(`/core/board/management/config`)。 */
84
- loadBookingConfig(params?: LoadBookingConfigParams): Promise<BookingContextConfig | null>;
85
- /** 拉取资源全集并写入 store(`/schedule/resource/list`)。 */
86
- loadResources(params?: LoadBookingResourcesParams): Promise<BookingContextResource[]>;
87
- /**
88
- * 依次 setDate → loadBookingConfig → loadResources。
89
- * SalesSdkProvider 挂载时默认调用 BookingTicket.initBookingContext。
90
- */
91
- initBookingContext(params?: InitBookingContextParams): Promise<BookingContextState>;
92
- /** store 是否已具备与入参等价的 config / resources(无需再请求)。 */
93
- isBookingContextReady(params?: InitBookingContextParams): boolean;
94
- }
95
- /**
96
- * BookingContextModule 事件名常量(采用 `${this.name}:` 前缀,与现有模块一致)。
97
- */
98
- export declare enum BookingContextEvent {
99
- OnBookingConfigChange = "onBookingConfigChange",
100
- OnResourcesChange = "onResourcesChange",
101
- OnDateChange = "onDateChange"
102
- }
@@ -1,34 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/modules/BookingContext/types.ts
20
- var types_exports = {};
21
- __export(types_exports, {
22
- BookingContextEvent: () => BookingContextEvent
23
- });
24
- module.exports = __toCommonJS(types_exports);
25
- var BookingContextEvent = /* @__PURE__ */ ((BookingContextEvent2) => {
26
- BookingContextEvent2["OnBookingConfigChange"] = "onBookingConfigChange";
27
- BookingContextEvent2["OnResourcesChange"] = "onResourcesChange";
28
- BookingContextEvent2["OnDateChange"] = "onDateChange";
29
- return BookingContextEvent2;
30
- })(BookingContextEvent || {});
31
- // Annotate the CommonJS export names for ESM import in node:
32
- 0 && (module.exports = {
33
- BookingContextEvent
34
- });
@@ -1,16 +0,0 @@
1
- import type { OrderProduct } from '../../Order/types';
2
- export interface BuildCacheItemFromOrderLineInput {
3
- /** tempOrder.products 中的一行 */
4
- product: OrderProduct;
5
- /** 与该行 product_uid 关联的 tempOrder.bookings 项 */
6
- booking: Record<string, any>;
7
- /** 商品 catalog / 详情,用于 capacity、duration、product_resource 等模板字段 */
8
- sourceProduct?: Record<string, any> | null;
9
- }
10
- /**
11
- * 从已加车的 order line + booking 反查 editService 所需的 cacheItem。
12
- *
13
- * 与 `buildCacheItemFromCartDetail` / `buildCacheItemFromDetail` 正向拼装互逆(在 getProductExtend 之前调用)。
14
- * 调用方须传入与该行关联的 booking(通常 bookings[].product_uid === product.metadata.unique_identification_number)。
15
- */
16
- export declare function buildCacheItemFromOrderLine(input: BuildCacheItemFromOrderLineInput): Record<string, any>;
@@ -1,207 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
-
29
- // src/modules/BookingContext/utils/buildCacheItemFromOrderLine.ts
30
- var buildCacheItemFromOrderLine_exports = {};
31
- __export(buildCacheItemFromOrderLine_exports, {
32
- buildCacheItemFromOrderLine: () => buildCacheItemFromOrderLine
33
- });
34
- module.exports = __toCommonJS(buildCacheItemFromOrderLine_exports);
35
- var import_dayjs = __toESM(require("dayjs"));
36
- var import_manualProductDiscount = require("../../Order/utils/manualProductDiscount");
37
- function safeFormat(value, fmt) {
38
- if (value === void 0 || value === null)
39
- return void 0;
40
- const d = (0, import_dayjs.default)(value);
41
- if (!d.isValid())
42
- return void 0;
43
- return d.format(fmt);
44
- }
45
- function normalizeTimeString(value) {
46
- if (value === void 0 || value === null)
47
- return void 0;
48
- if (typeof value === "string") {
49
- const t = value.trim();
50
- const hhmmFromHhmmss = t.match(/^(\d{1,2}:\d{2}):\d{2}$/);
51
- if (hhmmFromHhmmss)
52
- return hhmmFromHhmmss[1];
53
- if (/^\d{1,2}:\d{2}$/.test(t))
54
- return t;
55
- }
56
- const d = (0, import_dayjs.default)(value);
57
- if (d.isValid())
58
- return d.format("HH:mm");
59
- return void 0;
60
- }
61
- function unflattenResourceMap(resources) {
62
- const map = {};
63
- if (!Array.isArray(resources))
64
- return map;
65
- resources.forEach((r) => {
66
- const formId = r == null ? void 0 : r.form_id;
67
- if (formId === void 0 || formId === null)
68
- return;
69
- const key = String(formId);
70
- if (!map[key])
71
- map[key] = [];
72
- map[key].push({
73
- form_id: formId,
74
- relation_id: r.relation_id,
75
- relation_type: r.relation_type || "form",
76
- like_status: r.like_status || "common",
77
- metadata: r.metadata ? { ...r.metadata } : void 0,
78
- children: r.children
79
- });
80
- });
81
- return map;
82
- }
83
- function resolveCapacityFromBooking(booking) {
84
- var _a;
85
- const metaCap = (_a = booking.metadata) == null ? void 0 : _a.capacity;
86
- if (Array.isArray(metaCap) && metaCap.length > 0) {
87
- return metaCap.map((item) => {
88
- if (!item || typeof item !== "object")
89
- return null;
90
- if (item.id === void 0 || item.id === null)
91
- return null;
92
- const row = {
93
- id: item.id,
94
- value: Number(item.value ?? 0)
95
- };
96
- if (item.name !== void 0)
97
- row.name = item.name;
98
- return row;
99
- }).filter((item) => item != null);
100
- }
101
- if (typeof metaCap === "number" && Number.isFinite(metaCap)) {
102
- return [{ id: 0, value: metaCap, name: "" }];
103
- }
104
- return [];
105
- }
106
- function resolveDurationForExtend(booking) {
107
- const duration = booking.duration;
108
- if (booking.sub_type === "days" || booking.is_all === 1) {
109
- return duration;
110
- }
111
- if (typeof duration === "number" && Number.isFinite(duration)) {
112
- return duration;
113
- }
114
- return duration;
115
- }
116
- function buildCacheItemFromOrderLine(input) {
117
- var _a, _b, _c, _d, _e, _f, _g, _h;
118
- const { product, booking, sourceProduct } = input;
119
- const resolvedId = product.product_id ?? (sourceProduct == null ? void 0 : sourceProduct.id);
120
- const selling = Number(product.selling_price ?? 0);
121
- const original = Number(product.original_price ?? selling);
122
- const startDate = safeFormat(booking.start_date, "YYYY-MM-DD");
123
- const endDate = safeFormat(booking.end_date, "YYYY-MM-DD");
124
- const startTime = normalizeTimeString(booking.start_time);
125
- const endTime = normalizeTimeString(booking.end_time);
126
- const resource = unflattenResourceMap(booking.resources);
127
- const capacity = resolveCapacityFromBooking(booking);
128
- const holderId = ((_a = booking.metadata) == null ? void 0 : _a.holder_id) ?? booking.holder_id;
129
- const other = {
130
- product_variant_id: product.product_variant_id ?? 0,
131
- option: Array.isArray(product.product_option_item) ? [...product.product_option_item] : [],
132
- bundle: Array.isArray(product.product_bundle) ? [...product.product_bundle] : []
133
- };
134
- const extend = {
135
- start_date: startDate ? (0, import_dayjs.default)(startDate) : void 0,
136
- end_date: endDate ? (0, import_dayjs.default)(endDate) : void 0,
137
- startDate: startDate ? (0, import_dayjs.default)(startDate) : void 0,
138
- endDate: endDate ? (0, import_dayjs.default)(endDate) : void 0,
139
- start_time: startTime,
140
- end_time: endTime,
141
- duration: resolveDurationForExtend(booking),
142
- sub_type: booking.sub_type,
143
- quantity: product.num ?? 1,
144
- product_name: (sourceProduct == null ? void 0 : sourceProduct.title) ?? ((_b = booking == null ? void 0 : booking.product) == null ? void 0 : _b.title) ?? ((_c = booking == null ? void 0 : booking.detail) == null ? void 0 : _c.product_title) ?? "",
145
- note: product.note ?? ((_d = booking == null ? void 0 : booking.detail) == null ? void 0 : _d.note) ?? "",
146
- price: selling,
147
- total: selling,
148
- origin_total: original,
149
- resource,
150
- capacity,
151
- holder_id: holderId,
152
- other,
153
- like_status: booking.like_status || "common",
154
- discount_reason: (0, import_manualProductDiscount.resolveManualDiscountMessage)(
155
- product.discount_list,
156
- (_e = product.metadata) == null ? void 0 : _e.product_discount_reason
157
- ) || void 0
158
- };
159
- const manualDiscount = (product.discount_list || []).find((d) => (d == null ? void 0 : d.type) === "product");
160
- if (manualDiscount && extend.origin_total === selling) {
161
- const manualAmount = Number(manualDiscount.amount ?? 0);
162
- if (Number.isFinite(manualAmount) && manualAmount > 0) {
163
- extend.origin_total = selling + manualAmount;
164
- }
165
- }
166
- if (((_f = product.metadata) == null ? void 0 : _f.price_override) != null || manualDiscount) {
167
- extend.priceOverride = selling;
168
- }
169
- if (booking.holder !== void 0) {
170
- extend.holder = booking.holder;
171
- }
172
- if (Array.isArray(booking.relation_forms)) {
173
- extend.relation_forms = booking.relation_forms;
174
- }
175
- const base = {
176
- ...sourceProduct || {},
177
- id: resolvedId,
178
- product_id: resolvedId,
179
- extension_type: (sourceProduct == null ? void 0 : sourceProduct.extension_type) ?? ((_g = booking == null ? void 0 : booking.product) == null ? void 0 : _g.extension_type) ?? (sourceProduct == null ? void 0 : sourceProduct.extension_type),
180
- title: (sourceProduct == null ? void 0 : sourceProduct.title) ?? ((_h = booking == null ? void 0 : booking.product) == null ? void 0 : _h.title),
181
- price: (sourceProduct == null ? void 0 : sourceProduct.price) ?? selling,
182
- selling_price: product.selling_price,
183
- original_price: product.original_price,
184
- _extend: extend,
185
- new: 0,
186
- autoClose: false,
187
- order_detail_id: product.order_detail_id ?? null,
188
- booking_id: booking.id ?? booking.booking_id ?? 0
189
- };
190
- if ((sourceProduct == null ? void 0 : sourceProduct.capacity) !== void 0) {
191
- base.capacity = sourceProduct.capacity;
192
- }
193
- if ((sourceProduct == null ? void 0 : sourceProduct.duration) !== void 0) {
194
- base.duration = sourceProduct.duration;
195
- }
196
- if ((sourceProduct == null ? void 0 : sourceProduct.product_resource) !== void 0) {
197
- base.product_resource = sourceProduct.product_resource;
198
- }
199
- if (booking.schedule_event_id !== void 0) {
200
- base.schedule_event_id = booking.schedule_event_id;
201
- }
202
- return base;
203
- }
204
- // Annotate the CommonJS export names for ESM import in node:
205
- 0 && (module.exports = {
206
- buildCacheItemFromOrderLine
207
- });
@@ -1,8 +0,0 @@
1
- import type { OrderProduct } from '../../Order/types';
2
- export interface BuildNormalProductCacheItemFromOrderLineInput {
3
- /** tempOrder.products 中的一行(普通商品,无关联 booking) */
4
- product: OrderProduct;
5
- /** 商品 catalog / 详情,用于 variant / option / bundle 模板字段 */
6
- sourceProduct?: Record<string, any> | null;
7
- }
8
- export declare function buildNormalProductCacheItemFromOrderLine(input: BuildNormalProductCacheItemFromOrderLineInput): Record<string, any>;
@@ -1,141 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.ts
20
- var buildNormalProductCacheItemFromOrderLine_exports = {};
21
- __export(buildNormalProductCacheItemFromOrderLine_exports, {
22
- buildNormalProductCacheItemFromOrderLine: () => buildNormalProductCacheItemFromOrderLine
23
- });
24
- module.exports = __toCommonJS(buildNormalProductCacheItemFromOrderLine_exports);
25
- function resolveSourceProductPrice(product, sourceProduct) {
26
- var _a, _b, _c;
27
- const metadata = product.metadata || {};
28
- if (metadata.source_product_price !== void 0 && metadata.source_product_price !== null) {
29
- const parsed = Number(metadata.source_product_price);
30
- if (Number.isFinite(parsed))
31
- return parsed;
32
- }
33
- const variantId = Number(product.product_variant_id || 0);
34
- if (variantId > 0) {
35
- const variantList = ((_a = metadata.origin) == null ? void 0 : _a.variant) ?? (sourceProduct == null ? void 0 : sourceProduct.variant);
36
- if (Array.isArray(variantList)) {
37
- const matched = variantList.find((v) => Number(v == null ? void 0 : v.id) === variantId);
38
- const variantPrice = (matched == null ? void 0 : matched.price) ?? (matched == null ? void 0 : matched.base_price);
39
- if (variantPrice !== void 0 && variantPrice !== null) {
40
- const parsed = Number(variantPrice);
41
- if (Number.isFinite(parsed))
42
- return parsed;
43
- }
44
- }
45
- }
46
- const catalogPrice = (sourceProduct == null ? void 0 : sourceProduct.price) ?? (sourceProduct == null ? void 0 : sourceProduct.base_price);
47
- if (catalogPrice !== void 0 && catalogPrice !== null) {
48
- const parsed = Number(catalogPrice);
49
- if (Number.isFinite(parsed))
50
- return parsed;
51
- }
52
- const originPrice = ((_b = metadata.origin) == null ? void 0 : _b.price) ?? ((_c = metadata.origin) == null ? void 0 : _c.base_price);
53
- if (originPrice !== void 0 && originPrice !== null) {
54
- const parsed = Number(originPrice);
55
- if (Number.isFinite(parsed))
56
- return parsed;
57
- }
58
- return Number(product.selling_price ?? 0);
59
- }
60
- function mapOrderBundleToOtherBundle(bundle) {
61
- return bundle.map((item) => {
62
- const catalogOriginal = item.original_price ?? item.product_price ?? item.price ?? item.bundle_selling_price;
63
- const selling = item.bundle_selling_price ?? item.price ?? catalogOriginal;
64
- const { bundle_selling_price: _omitBundleSelling, ...rest } = item;
65
- return {
66
- ...rest,
67
- price: selling,
68
- original_price: catalogOriginal,
69
- original_total: item.original_total ?? catalogOriginal,
70
- num: item.num ?? item.quantity ?? 1,
71
- quantity: item.quantity ?? item.num ?? 1
72
- };
73
- });
74
- }
75
- function buildNormalProductCacheItemFromOrderLine(input) {
76
- var _a, _b, _c, _d;
77
- const { product, sourceProduct } = input;
78
- const resolvedId = product.product_id ?? (sourceProduct == null ? void 0 : sourceProduct.id);
79
- const sourcePrice = resolveSourceProductPrice(product, sourceProduct);
80
- const selling = Number(product.selling_price ?? 0);
81
- const original = Number(product.original_price ?? selling);
82
- const uid = (_a = product.metadata) == null ? void 0 : _a.unique_identification_number;
83
- const option = Array.isArray(product.product_option_item) ? [...product.product_option_item] : [];
84
- const bundle = mapOrderBundleToOtherBundle(
85
- Array.isArray(product.product_bundle) ? product.product_bundle : []
86
- );
87
- const originExtend = (_c = (_b = product.metadata) == null ? void 0 : _b.origin) == null ? void 0 : _c._extend;
88
- const other = {
89
- product_id: resolvedId,
90
- product_variant_id: product.product_variant_id ?? 0,
91
- option,
92
- bundle: ((_d = originExtend == null ? void 0 : originExtend.other) == null ? void 0 : _d.bundle) ? JSON.parse(JSON.stringify(originExtend.other.bundle)) : bundle,
93
- quantity: product.num ?? 1
94
- };
95
- const skuValue = {
96
- product_id: resolvedId,
97
- product_variant_id: product.product_variant_id ?? 0,
98
- option: other.option,
99
- bundle: other.bundle
100
- };
101
- const extend = {
102
- quantity: product.num ?? 1,
103
- product_name: (sourceProduct == null ? void 0 : sourceProduct.title) ?? "",
104
- note: product.note ?? "",
105
- // v2:_extend.price 为主商品 source 价;行 composite 用 total / origin_total 展示
106
- price: (originExtend == null ? void 0 : originExtend.price) ?? sourcePrice,
107
- total: (originExtend == null ? void 0 : originExtend.total) ?? selling,
108
- origin_total: (originExtend == null ? void 0 : originExtend.origin_total) ?? original,
109
- other,
110
- skuValue: JSON.parse(JSON.stringify(skuValue)),
111
- _skuValue: JSON.parse(JSON.stringify(skuValue)),
112
- isNormalProduct: true,
113
- ...(originExtend == null ? void 0 : originExtend.priceOverride) !== void 0 ? { priceOverride: originExtend.priceOverride } : {},
114
- ...(originExtend == null ? void 0 : originExtend.bundle_edit) !== void 0 ? { bundle_edit: originExtend.bundle_edit } : {}
115
- };
116
- if ((originExtend == null ? void 0 : originExtend.skuValue) || (originExtend == null ? void 0 : originExtend._skuValue)) {
117
- extend.skuValue = JSON.parse(
118
- JSON.stringify(originExtend.skuValue || originExtend._skuValue)
119
- );
120
- extend._skuValue = JSON.parse(JSON.stringify(extend.skuValue));
121
- }
122
- return {
123
- ...sourceProduct || {},
124
- id: resolvedId,
125
- product_id: resolvedId,
126
- _id: uid,
127
- title: sourceProduct == null ? void 0 : sourceProduct.title,
128
- price: (sourceProduct == null ? void 0 : sourceProduct.price) ?? sourcePrice,
129
- selling_price: product.selling_price,
130
- original_price: product.original_price,
131
- note: product.note,
132
- order_detail_id: product.order_detail_id ?? null,
133
- new: 0,
134
- autoClose: true,
135
- _extend: extend
136
- };
137
- }
138
- // Annotate the CommonJS export names for ESM import in node:
139
- 0 && (module.exports = {
140
- buildNormalProductCacheItemFromOrderLine
141
- });
@@ -1,75 +0,0 @@
1
- /**
2
- * 把 info2 `cacheItem` 转换为 OS `addProductToOrder(product, booking)` 所需的 booking 入参。
3
- *
4
- * 协议严格对齐 `pisell_os/src/modules/Order/TEMP_ORDER_FIELDS_SUMMARY.md` 的 Bookings 章节:
5
- * - 顶层只允许出现:schedule_event_id / appointment_status / start_date / start_time / end_date /
6
- * end_time / select_date / duration / sub_type / like_status / number / resources / relation_forms /
7
- * holder / metadata / is_all / schedule_id / relation_id / form_id / relation_type / product_uid
8
- * - bookings[] 不允许出现 `_extend`
9
- * - bookings[].metadata 走白名单:unique_identification_number / collect_pax / capacity / holder_id / resource_select_type
10
- * - bookings[].resources[] 只接受协议白名单:form_id / relation_type / relation_id / capacity / like_status / metadata / children
11
- *
12
- * `product_uid` / `metadata.unique_identification_number` 不在这里生成:
13
- * OS `addProductToOrder` 内的 `createLinkedProductAndBooking` 会在最终一步统一改写,
14
- * 保证商品行 uid 与 booking root 唯一值始终对齐。
15
- *
16
- * 复杂 multi-day 展开(createBookingItemsByGroup / concatBookings)首版**不支持**,
17
- * 由 UI 在 `cart.confirmDetail` 之外通过辅助 API 处理。
18
- */
19
- export interface CacheItemToBookingInputOptions {
20
- /** booking config,用于推导 metadata.resource_select_type(默认从 cacheItem.\_data.resources[0].select_type.type 推断)。 */
21
- bookingConfig?: any;
22
- }
23
- export interface BookingInput {
24
- schedule_event_id?: number | string;
25
- start_date?: string;
26
- start_time?: string;
27
- end_date?: string;
28
- end_time?: string;
29
- select_date?: string;
30
- duration?: number;
31
- sub_type?: 'days' | 'minutes' | string;
32
- is_all?: 0 | 1;
33
- number?: number;
34
- holder?: any;
35
- like_status?: string;
36
- relation_forms?: any[];
37
- resources?: BookingResourceInput[];
38
- metadata?: BookingMetadataInput;
39
- schedule_id?: number | string;
40
- relation_id?: number | string;
41
- form_id?: number | string;
42
- relation_type?: string;
43
- }
44
- export interface BookingResourceInput {
45
- form_id?: number | string;
46
- relation_type?: string;
47
- relation_id?: number | string;
48
- capacity?: number;
49
- like_status?: string;
50
- metadata?: Record<string, any>;
51
- children?: any[];
52
- }
53
- /** custom / package 人数维度快照,与 info2 `_extend.capacity` / `metadata.capacity` 对齐。 */
54
- export interface BookingCapacityMetadataItem {
55
- id: string | number;
56
- value: number;
57
- name?: Record<string, any> | string;
58
- }
59
- export interface BookingMetadataInput {
60
- /** 由 OS createLinkedProductAndBooking 统一改写,这里不生成。 */
61
- unique_identification_number?: string;
62
- collect_pax?: number;
63
- /**
64
- * 资源容量快照:custom 多维度时为 `{ id, value, name? }[]`;
65
- * 仅总和场景可为 number(capacity_snapshot 兼容)。
66
- */
67
- capacity?: number | BookingCapacityMetadataItem[];
68
- /** 协议要求始终提交(即使为 null)。 */
69
- holder_id: any;
70
- resource_select_type?: 'single' | 'multiple' | string;
71
- }
72
- /**
73
- * 主入口。
74
- */
75
- export declare function cacheItemToBookingInput(cacheItem: any, options?: CacheItemToBookingInputOptions): BookingInput;