@pisell/pisellos 0.10.76 → 0.10.78

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 (212) hide show
  1. package/dist/apis/picoding.d.ts +0 -0
  2. package/dist/effects/index.d.ts +19 -0
  3. package/dist/model/strategy/adapter/dataVariant/adapter.d.ts +50 -0
  4. package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +105 -0
  5. package/dist/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
  6. package/dist/model/strategy/adapter/dataVariant/index.d.ts +4 -0
  7. package/dist/model/strategy/adapter/dataVariant/type.d.ts +173 -0
  8. package/dist/model/strategy/adapter/promotion/adapter.d.ts +70 -0
  9. package/dist/model/strategy/adapter/promotion/examples.d.ts +224 -0
  10. package/dist/model/strategy/adapter/promotion/index.js +0 -9
  11. package/dist/model/strategy/adapter/promotion/type.d.ts +535 -0
  12. package/dist/model/strategy/adapter/type.d.ts +28 -0
  13. package/dist/model/strategy/adapter/walletPass/index.d.ts +32 -0
  14. package/dist/model/strategy/adapter/walletPass/locales.d.ts +1 -0
  15. package/dist/model/strategy/adapter/walletPass/type.d.ts +192 -0
  16. package/dist/model/strategy/adapter/walletPass/utils.d.ts +50 -0
  17. package/dist/model/strategy/engine.d.ts +119 -0
  18. package/dist/model/strategy/type.d.ts +245 -0
  19. package/dist/modules/Account/types.d.ts +56 -0
  20. package/dist/modules/BookingContext/types.d.ts +104 -0
  21. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +76 -0
  22. package/dist/modules/BookingContext/utils/flexible.d.ts +28 -0
  23. package/dist/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
  24. package/dist/modules/BookingContext/utils/noResource.d.ts +13 -0
  25. package/dist/modules/BookingContext/utils/orderLineDisplay.d.ts +1 -0
  26. package/dist/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
  27. package/dist/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
  28. package/dist/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
  29. package/dist/modules/BookingContext/utils/timeSlices.d.ts +42 -0
  30. package/dist/modules/Customer/constants.d.ts +7 -0
  31. package/dist/modules/Date/types.d.ts +84 -0
  32. package/dist/modules/Date/utils.d.ts +36 -0
  33. package/dist/modules/FulfillmentTiming/index.d.ts +11 -0
  34. package/dist/modules/FulfillmentTiming/types.d.ts +67 -0
  35. package/dist/modules/Order/payment-utils.d.ts +26 -0
  36. package/dist/modules/Order/pickupTiming.d.ts +46 -0
  37. package/dist/modules/Order/utils/manualProductDiscount.d.ts +106 -0
  38. package/dist/modules/Order/utils/orderCollectionIdentity.d.ts +68 -0
  39. package/dist/modules/Order/utils/weighedProduct.d.ts +12 -0
  40. package/dist/modules/Payment/cashRecommendationAlgorithm.d.ts +21 -0
  41. package/dist/modules/Payment/mx51.d.ts +0 -0
  42. package/dist/modules/Payment/types.d.ts +943 -0
  43. package/dist/modules/Payment/utils.d.ts +19 -0
  44. package/dist/modules/Product/index.d.ts +1 -1
  45. package/dist/modules/ProductList/index.d.ts +2 -0
  46. package/dist/modules/ProductList/index.js +125 -39
  47. package/dist/modules/Quotation/types.d.ts +61 -0
  48. package/dist/modules/Resource/types.d.ts +50 -0
  49. package/dist/modules/Resource/utils.d.ts +23 -0
  50. package/dist/modules/ResourcePlanner/localClock.d.ts +33 -0
  51. package/dist/modules/ResourcePlanner/planner.js +5 -0
  52. package/dist/modules/SalesSummary/types.d.ts +69 -0
  53. package/dist/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
  54. package/dist/modules/ScanOrderLogger/providers/grafana.d.ts +2 -0
  55. package/dist/modules/ScanOrderLogger/types.d.ts +53 -0
  56. package/dist/modules/Schedule/getDateIsInSchedule.d.ts +32 -0
  57. package/dist/modules/Schedule/type.d.ts +157 -0
  58. package/dist/modules/Schedule/types.d.ts +201 -0
  59. package/dist/modules/Schedule/utils.d.ts +67 -0
  60. package/dist/modules/Step/tyeps.d.ts +20 -0
  61. package/dist/modules/SurchargeList/types.d.ts +15 -0
  62. package/dist/plugins/app.d.ts +10 -0
  63. package/dist/plugins/shopStore.d.ts +4 -0
  64. package/dist/plugins/user.d.ts +7 -0
  65. package/dist/server/modules/floor-plan/types.d.ts +43 -0
  66. package/dist/server/modules/menu/types.d.ts +68 -0
  67. package/dist/server/modules/payment/types.d.ts +9 -0
  68. package/dist/server/modules/quotation/types.d.ts +50 -0
  69. package/dist/server/modules/resource/types.d.ts +121 -0
  70. package/dist/server/modules/schedule/types.d.ts +1 -0
  71. package/dist/server/modules/schedule/utils.d.ts +32 -0
  72. package/dist/server/types.d.ts +66 -0
  73. package/dist/server/utils/index.d.ts +5 -0
  74. package/dist/server/utils/schedule.d.ts +14 -0
  75. package/dist/server/utils/time.d.ts +18 -0
  76. package/dist/solution/BaseSales/index.d.ts +12 -1
  77. package/dist/solution/BaseSales/index.js +275 -185
  78. package/dist/solution/BookingByStep/index.d.ts +2 -2
  79. package/dist/solution/BookingTicket/index.d.ts +1 -13
  80. package/dist/solution/BookingTicket/utils/bookingStatus.d.ts +77 -0
  81. package/dist/solution/BookingTicket/utils/exampleData.d.ts +123 -0
  82. package/dist/solution/BookingTicket/utils/resolveBestAddTimePlan.d.ts +185 -0
  83. package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +38 -0
  84. package/dist/solution/BookingTicket/utils/scan/scanCache.d.ts +78 -0
  85. package/dist/solution/BookingTicket/utils/scan/scanProductValues.d.ts +21 -0
  86. package/dist/solution/BookingTicket/utils/weighingProductSku.d.ts +5 -0
  87. package/dist/solution/PlaceOrder/index.d.ts +0 -0
  88. package/dist/solution/RegisterAndLogin/config.d.ts +93 -0
  89. package/dist/solution/RegisterAndLogin/types.d.ts +445 -0
  90. package/dist/solution/RegisterAndLogin/utils.d.ts +103 -0
  91. package/dist/solution/UnifiedBookingSales/index.d.ts +23 -1
  92. package/dist/solution/UnifiedBookingSales/index.js +1367 -646
  93. package/dist/solution/UnifiedBookingSales/remoteOccupancyCache.d.ts +2 -0
  94. package/dist/solution/UnifiedBookingSales/remoteOccupancyCache.js +4 -0
  95. package/dist/solution/UnifiedBookingSales/sessionResourceCache.d.ts +27 -0
  96. package/dist/solution/UnifiedBookingSales/sessionResourceCache.js +271 -0
  97. package/dist/solution/UnifiedBookingSales/types.d.ts +25 -0
  98. package/dist/solution/UnifiedBookingSales/types.js +2 -0
  99. package/dist/solution/UnifiedBookingSales/venueCatalogSession.d.ts +32 -0
  100. package/dist/solution/UnifiedBookingSales/venueCatalogSession.js +277 -0
  101. package/dist/store/createStore.d.ts +3 -0
  102. package/dist/types/index.d.ts +132 -0
  103. package/dist/utils/os-private-payload.d.ts +5 -0
  104. package/dist/utils/payment-number.d.ts +9 -0
  105. package/dist/utils/task.d.ts +40 -0
  106. package/dist/utils/watch.d.ts +102 -0
  107. package/lib/apis/picoding.d.ts +0 -0
  108. package/lib/effects/index.d.ts +19 -0
  109. package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +50 -0
  110. package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +105 -0
  111. package/lib/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
  112. package/lib/model/strategy/adapter/dataVariant/index.d.ts +4 -0
  113. package/lib/model/strategy/adapter/dataVariant/type.d.ts +173 -0
  114. package/lib/model/strategy/adapter/promotion/adapter.d.ts +70 -0
  115. package/lib/model/strategy/adapter/promotion/examples.d.ts +224 -0
  116. package/lib/model/strategy/adapter/promotion/type.d.ts +535 -0
  117. package/lib/model/strategy/adapter/type.d.ts +28 -0
  118. package/lib/model/strategy/adapter/walletPass/index.d.ts +32 -0
  119. package/lib/model/strategy/adapter/walletPass/locales.d.ts +1 -0
  120. package/lib/model/strategy/adapter/walletPass/type.d.ts +192 -0
  121. package/lib/model/strategy/adapter/walletPass/utils.d.ts +50 -0
  122. package/lib/model/strategy/engine.d.ts +119 -0
  123. package/lib/model/strategy/type.d.ts +245 -0
  124. package/lib/modules/Account/types.d.ts +56 -0
  125. package/lib/modules/BookingContext/types.d.ts +104 -0
  126. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +76 -0
  127. package/lib/modules/BookingContext/utils/flexible.d.ts +28 -0
  128. package/lib/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
  129. package/lib/modules/BookingContext/utils/noResource.d.ts +13 -0
  130. package/lib/modules/BookingContext/utils/orderLineDisplay.d.ts +1 -0
  131. package/lib/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
  132. package/lib/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
  133. package/lib/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
  134. package/lib/modules/BookingContext/utils/timeSlices.d.ts +42 -0
  135. package/lib/modules/Customer/constants.d.ts +7 -0
  136. package/lib/modules/Date/types.d.ts +84 -0
  137. package/lib/modules/Date/utils.d.ts +36 -0
  138. package/lib/modules/FulfillmentTiming/index.d.ts +11 -0
  139. package/lib/modules/FulfillmentTiming/types.d.ts +67 -0
  140. package/lib/modules/Order/payment-utils.d.ts +26 -0
  141. package/lib/modules/Order/pickupTiming.d.ts +46 -0
  142. package/lib/modules/Order/utils/manualProductDiscount.d.ts +106 -0
  143. package/lib/modules/Order/utils/orderCollectionIdentity.d.ts +68 -0
  144. package/lib/modules/Order/utils/weighedProduct.d.ts +12 -0
  145. package/lib/modules/Payment/cashRecommendationAlgorithm.d.ts +21 -0
  146. package/lib/modules/Payment/mx51.d.ts +0 -0
  147. package/lib/modules/Payment/types.d.ts +943 -0
  148. package/lib/modules/Payment/utils.d.ts +19 -0
  149. package/lib/modules/Product/index.d.ts +1 -1
  150. package/lib/modules/ProductList/index.d.ts +2 -0
  151. package/lib/modules/ProductList/index.js +56 -0
  152. package/lib/modules/Quotation/types.d.ts +61 -0
  153. package/lib/modules/Resource/types.d.ts +50 -0
  154. package/lib/modules/Resource/utils.d.ts +23 -0
  155. package/lib/modules/ResourcePlanner/localClock.d.ts +33 -0
  156. package/lib/modules/ResourcePlanner/planner.js +4 -0
  157. package/lib/modules/SalesSummary/types.d.ts +69 -0
  158. package/lib/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
  159. package/lib/modules/ScanOrderLogger/providers/grafana.d.ts +2 -0
  160. package/lib/modules/ScanOrderLogger/types.d.ts +53 -0
  161. package/lib/modules/Schedule/getDateIsInSchedule.d.ts +32 -0
  162. package/lib/modules/Schedule/type.d.ts +157 -0
  163. package/lib/modules/Schedule/types.d.ts +201 -0
  164. package/lib/modules/Schedule/utils.d.ts +67 -0
  165. package/lib/modules/Step/tyeps.d.ts +20 -0
  166. package/lib/modules/SurchargeList/types.d.ts +15 -0
  167. package/lib/plugins/app.d.ts +10 -0
  168. package/lib/plugins/shopStore.d.ts +4 -0
  169. package/lib/plugins/user.d.ts +7 -0
  170. package/lib/server/modules/floor-plan/types.d.ts +43 -0
  171. package/lib/server/modules/menu/types.d.ts +68 -0
  172. package/lib/server/modules/payment/types.d.ts +9 -0
  173. package/lib/server/modules/quotation/types.d.ts +50 -0
  174. package/lib/server/modules/resource/types.d.ts +121 -0
  175. package/lib/server/modules/schedule/types.d.ts +1 -0
  176. package/lib/server/modules/schedule/utils.d.ts +32 -0
  177. package/lib/server/types.d.ts +66 -0
  178. package/lib/server/utils/index.d.ts +5 -0
  179. package/lib/server/utils/schedule.d.ts +14 -0
  180. package/lib/server/utils/time.d.ts +18 -0
  181. package/lib/solution/BaseSales/index.d.ts +12 -1
  182. package/lib/solution/BaseSales/index.js +65 -0
  183. package/lib/solution/BookingByStep/index.d.ts +2 -2
  184. package/lib/solution/BookingTicket/index.d.ts +1 -13
  185. package/lib/solution/BookingTicket/utils/bookingStatus.d.ts +77 -0
  186. package/lib/solution/BookingTicket/utils/exampleData.d.ts +123 -0
  187. package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.d.ts +185 -0
  188. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +38 -0
  189. package/lib/solution/BookingTicket/utils/scan/scanCache.d.ts +78 -0
  190. package/lib/solution/BookingTicket/utils/scan/scanProductValues.d.ts +21 -0
  191. package/lib/solution/BookingTicket/utils/weighingProductSku.d.ts +5 -0
  192. package/lib/solution/PlaceOrder/index.d.ts +0 -0
  193. package/lib/solution/RegisterAndLogin/config.d.ts +93 -0
  194. package/lib/solution/RegisterAndLogin/types.d.ts +445 -0
  195. package/lib/solution/RegisterAndLogin/utils.d.ts +103 -0
  196. package/lib/solution/UnifiedBookingSales/index.d.ts +23 -1
  197. package/lib/solution/UnifiedBookingSales/index.js +399 -14
  198. package/lib/solution/UnifiedBookingSales/remoteOccupancyCache.d.ts +2 -0
  199. package/lib/solution/UnifiedBookingSales/remoteOccupancyCache.js +2 -0
  200. package/lib/solution/UnifiedBookingSales/sessionResourceCache.d.ts +27 -0
  201. package/lib/solution/UnifiedBookingSales/sessionResourceCache.js +199 -0
  202. package/lib/solution/UnifiedBookingSales/types.d.ts +25 -0
  203. package/lib/solution/UnifiedBookingSales/types.js +1 -0
  204. package/lib/solution/UnifiedBookingSales/venueCatalogSession.d.ts +32 -0
  205. package/lib/solution/UnifiedBookingSales/venueCatalogSession.js +151 -0
  206. package/lib/store/createStore.d.ts +3 -0
  207. package/lib/types/index.d.ts +132 -0
  208. package/lib/utils/os-private-payload.d.ts +5 -0
  209. package/lib/utils/payment-number.d.ts +9 -0
  210. package/lib/utils/task.d.ts +40 -0
  211. package/lib/utils/watch.d.ts +102 -0
  212. package/package.json +1 -1
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Server 类型定义
3
+ */
4
+ export type CacheType = 'memory' | 'storage' | 'indexDB';
5
+ export interface CacheProps {
6
+ key?: string;
7
+ type?: CacheType;
8
+ updateCache?: boolean;
9
+ cacheUpdateChange?: (data: any) => void;
10
+ }
11
+ export interface RequestSetting {
12
+ abort?: boolean;
13
+ headers?: any;
14
+ cache?: CacheProps;
15
+ signal?: any;
16
+ token?: string;
17
+ osServer?: boolean;
18
+ [key: string]: any;
19
+ }
20
+ /**
21
+ * 路由处理函数类型
22
+ */
23
+ export type RouteHandler = (params: {
24
+ url: string;
25
+ method: 'get' | 'post' | 'remove' | 'put';
26
+ data?: any;
27
+ config?: RequestSetting;
28
+ /** 路由路径(前缀匹配时由 handleRoute 注入,便于 handler 解析动态段) */
29
+ path?: string;
30
+ }) => Promise<any> | any;
31
+ /**
32
+ * HTTP 方法类型
33
+ */
34
+ export type HttpMethod = 'get' | 'post' | 'remove' | 'put';
35
+ /**
36
+ * 路由定义类型
37
+ */
38
+ export type RouteDefinition = {
39
+ method: HttpMethod;
40
+ path: string;
41
+ handler: RouteHandler;
42
+ };
43
+ /**
44
+ * Router 对象类型
45
+ */
46
+ export interface Router {
47
+ get: Record<string, RouteHandler>;
48
+ post: Record<string, RouteHandler>;
49
+ put: Record<string, RouteHandler>;
50
+ remove: Record<string, RouteHandler>;
51
+ }
52
+ /**
53
+ * 模块注册配置(内部使用)
54
+ */
55
+ export interface ModuleRegistryConfig {
56
+ /** 模块名称 */
57
+ name: string;
58
+ /** 模块类 */
59
+ moduleClass: any;
60
+ /** 模块完整名称(用于注册到 Core) */
61
+ moduleName: string;
62
+ /** 模块版本 */
63
+ version: string;
64
+ /** 默认 store 结构 */
65
+ defaultStore: Record<string, any>;
66
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Server 工具函数集合
3
+ */
4
+ export * from './time';
5
+ export * from './schedule';
@@ -0,0 +1,14 @@
1
+ import type { ScheduleItem } from '../../modules/Schedule/types';
2
+ import type { MenuData } from '../modules/menu/types';
3
+ /**
4
+ * 从餐牌列表中提取所有 schedule IDs
5
+ * @param menus 餐牌列表
6
+ * @returns 去重后的日程ID数组
7
+ */
8
+ export declare function extractScheduleIdsFromMenus(menus: MenuData[]): number[];
9
+ /**
10
+ * 从日程列表中提取所有时间点
11
+ * @param schedules 日程列表
12
+ * @returns 排序后的时间点数组,格式为 ["10:00", "12:00", "14:00", "18:00"]
13
+ */
14
+ export declare function extractTimePointsFromSchedules(schedules: ScheduleItem[]): string[];
@@ -0,0 +1,18 @@
1
+ /**
2
+ * 从日期时间字符串中提取时间部分
3
+ * @param dateTime 日期时间字符串,格式如 "2024-01-01 10:00:00"
4
+ * @returns 时间字符串,格式如 "10:00"
5
+ */
6
+ export declare function extractTimeFromDateTime(dateTime: string): string | null;
7
+ /**
8
+ * 将时间字符串转换为分钟数(用于排序)
9
+ * @param timeStr 时间字符串,格式如 "10:00" 或 "14:30"
10
+ * @returns 从00:00开始的分钟数
11
+ */
12
+ export declare function timeStringToMinutes(timeStr: string): number;
13
+ /**
14
+ * 对时间点数组进行排序
15
+ * @param timePoints 时间点数组
16
+ * @returns 排序后的时间点数组
17
+ */
18
+ export declare function sortTimePoints(timePoints: string[]): string[];
@@ -129,7 +129,7 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
129
129
  * /product/query 的智能定价评估只读取 strategy_context;
130
130
  * application_code 仅作为接口兼容字段,不能替代 channel / business_code。
131
131
  */
132
- private getPriceQueryStrategyContext;
132
+ protected getPriceQueryStrategyContext(channel?: string): Record<string, any>;
133
133
  /**
134
134
  * 子类可在商品重报价前准备客户维度的策略上下文,例如等待 Wallet/优惠资产加载。
135
135
  */
@@ -156,6 +156,12 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
156
156
  private prepareRawProductForPriceQuery;
157
157
  private resolveLocalProductForPriceQuery;
158
158
  private loadProductsForPriceQuery;
159
+ /** Opt-in subclasses may supply page-owned raw pools; ordinary sales keep remote fallback. */
160
+ protected isVenueCatalogLocalPricingActive(): boolean;
161
+ protected getVenueCatalogLocalPriceSource(_productId: number, _selectedProduct?: Record<string, any>): {
162
+ product: Record<string, any>;
163
+ menuList: Record<string, any>[];
164
+ } | undefined;
159
165
  private resolveProductsForPriceQuery;
160
166
  private getAuthoritativeBundleItems;
161
167
  private findAuthoritativeBundleItem;
@@ -523,6 +529,11 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
523
529
  submitBeforeSend?: boolean;
524
530
  }): Promise<T>;
525
531
  transformBaseProductToOrderProduct(params: TransformBaseProductToOrderProductParams): import("./utils/transformBaseProductToOrderProduct").BaseProductOrderProductInput | null;
532
+ /** Explicit pool source avoids races between two simultaneous Venue pricing contexts. */
533
+ protected calculateVenueCatalogProductBookingPrice(params: BaseSalesCalculateProductBookingPriceParams, source: {
534
+ product: Record<string, any>;
535
+ menuList: Record<string, any>[];
536
+ }): Promise<BaseSalesProductBookingPriceResult>;
526
537
  calculateProductBookingPrice(params: BaseSalesCalculateProductBookingPriceParams): Promise<BaseSalesProductBookingPriceResult>;
527
538
  getQuotationCustomerScopeInfo(): BaseSalesQuotationCustomerScopeInfo;
528
539
  private hasSmartPricingStrategies;
@@ -1042,6 +1042,9 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
1042
1042
  products: [preparedProduct],
1043
1043
  queryPayload: params.queryPayload,
1044
1044
  handledByOsServer: false,
1045
+ ...(params.menuList ? {
1046
+ menuList: params.menuList
1047
+ } : {}),
1045
1048
  ...(scheduleList ? {
1046
1049
  scheduleList
1047
1050
  } : {})
@@ -1097,6 +1100,14 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
1097
1100
  return productsById;
1098
1101
  }
1099
1102
  }
1103
+
1104
+ /** Opt-in subclasses may supply page-owned raw pools; ordinary sales keep remote fallback. */
1105
+ isVenueCatalogLocalPricingActive() {
1106
+ return false;
1107
+ }
1108
+ getVenueCatalogLocalPriceSource(_productId, _selectedProduct) {
1109
+ return undefined;
1110
+ }
1100
1111
  async resolveProductsForPriceQuery(params) {
1101
1112
  const selectedProducts = params.priceQueries.map(item => item.product || {});
1102
1113
  const productIds = selectedProducts.map(product => this.getPriceQueryProductId(product));
@@ -1104,6 +1115,30 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
1104
1115
  if (!ids.length) {
1105
1116
  return selectedProducts.map(() => null);
1106
1117
  }
1118
+
1119
+ // An explicitly active Venue pool owns all its product reads. Missing raw data
1120
+ // or rules must fail visibly; never silently spend a second list/detail request.
1121
+ if (this.isVenueCatalogLocalPricingActive()) {
1122
+ const queryPayload = this.buildPriceQueryPayload({
1123
+ ids,
1124
+ schedule: params.schedule,
1125
+ customerId: params.customerId,
1126
+ channel: params.channel
1127
+ });
1128
+ return selectedProducts.map((selectedProduct, index) => {
1129
+ const source = productIds[index] == null ? undefined : this.getVenueCatalogLocalPriceSource(productIds[index], selectedProduct);
1130
+ const resolved = source && this.resolveLocalProductForPriceQuery({
1131
+ selectedProduct,
1132
+ rawProduct: source.product,
1133
+ menuList: source.menuList,
1134
+ queryPayload
1135
+ });
1136
+ if (!resolved) throw Object.assign(new Error('The complete venue product or pricing rules are not ready. Reload the catalog before continuing.'), {
1137
+ code: 'VENUE_LOCAL_PRICE_UNAVAILABLE'
1138
+ });
1139
+ return resolved;
1140
+ });
1141
+ }
1107
1142
  const handledByOsServer = this.request ? (0, _clientDataVariants.isProductQueryHandledByOsServer)(this.core, this.request) : false;
1108
1143
  const canUseLocalFastPath = this.isCustomerUserPriceQuery() && !handledByOsServer;
1109
1144
  if (!canUseLocalFastPath) {
@@ -3987,6 +4022,36 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
3987
4022
  transformBaseProductToOrderProduct(params) {
3988
4023
  return (0, _transformBaseProductToOrderProduct.transformBaseProductToOrderProduct)(params);
3989
4024
  }
4025
+
4026
+ /** Explicit pool source avoids races between two simultaneous Venue pricing contexts. */
4027
+ async calculateVenueCatalogProductBookingPrice(params, source) {
4028
+ const customerId = params.customer_id ?? this.getCurrentOrderCustomerId();
4029
+ await this.prepareProductPriceQueryContext(customerId);
4030
+ const channel = this.getPriceQueryChannel(params.channel);
4031
+ const queryPayload = this.buildPriceQueryPayload({
4032
+ ids: [Number(source.product.id)],
4033
+ schedule: this.getPriceQuerySchedule(params),
4034
+ customerId,
4035
+ channel
4036
+ });
4037
+ const authoritativeProduct = this.resolveLocalProductForPriceQuery({
4038
+ selectedProduct: params.product,
4039
+ rawProduct: source.product,
4040
+ menuList: source.menuList,
4041
+ queryPayload
4042
+ });
4043
+ if (!authoritativeProduct) throw Object.assign(new Error('Complete product pricing rules are not ready. Please retry.'), {
4044
+ code: 'VENUE_LOCAL_PRICE_UNAVAILABLE'
4045
+ });
4046
+ return (0, _quotationPrice.calculateBaseSalesProductBookingPrice)({
4047
+ ...params,
4048
+ channel,
4049
+ customer_id: customerId,
4050
+ product: this.mergeProductForPriceQuery(params.product, authoritativeProduct),
4051
+ fallback_price: undefined,
4052
+ quotation: undefined
4053
+ });
4054
+ }
3990
4055
  async calculateProductBookingPrice(params) {
3991
4056
  const useCustomerUserPricing = this.isCustomerUserPriceQuery();
3992
4057
  const quotation = useCustomerUserPricing ? undefined : this.store.quotation;
@@ -326,7 +326,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
326
326
  date: string;
327
327
  status: string;
328
328
  week: string;
329
- weekNum: 0 | 2 | 1 | 6 | 4 | 5 | 3;
329
+ weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
330
330
  }[]>;
331
331
  submitTimeSlot(timeSlots: TimeSliceItem): void;
332
332
  private getScheduleDataByIds;
@@ -373,7 +373,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
373
373
  };
374
374
  setOtherData(key: string, value: any): void;
375
375
  getOtherData(key: string): any;
376
- getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
376
+ getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
377
377
  /**
378
378
  * 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
379
379
  *
@@ -479,19 +479,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
479
479
  * 加车两阶段主决策(规格弹窗 / 资源编辑 / 直接加车)。
480
480
  * 与 ticketBooking `handleSelectProduct` + `handleBooking4Service` 等价。
481
481
  */
482
- decideAddProduct(item: any, options?: Partial<AddProductDecideContext>): {
483
- action: "reloadCatalog";
484
- } | {
485
- action: "add";
486
- cacheItem: any;
487
- } | {
488
- action: "requiresDetail";
489
- payload: AddProductRequiresDetailPayload;
490
- } | {
491
- action: "requiresBookingEdit";
492
- cacheItem: any;
493
- payload: import("./utils/addProductDecision").AddProductRequiresBookingEditPayload;
494
- };
482
+ decideAddProduct(item: any, options?: Partial<AddProductDecideContext>): import("./utils/addProductDecision").AddProductDecision;
495
483
  /** 规格弹窗 callback 后的第二段决策。 */
496
484
  decideAfterDetail(cacheItem: any, options?: Partial<AddProductDecideContext>): import("./utils/addProductDecision").AddProductDecision;
497
485
  /**
@@ -0,0 +1,77 @@
1
+ /**
2
+ * BookingTicket - 预约状态相关纯函数。
3
+ *
4
+ * 该文件不持有任何运行时引用(无 request / store / effects),
5
+ * 只做字段解析与本地数组的原地写入/回滚,便于独立单测与未来其他
6
+ * booking 写操作(editBooking / cancelBooking 等)复用。
7
+ *
8
+ * 设计依据:参考 .cursor/rules/data-field-semantics.mdc,
9
+ * 字段含义严格对齐既有协议(OrderTempOrder / parseSalesResponse),
10
+ * 不发明等价关系。
11
+ */
12
+ /**
13
+ * 子预约状态机转移动作(POST /schedule/booking-transition/{schedule_event_id})。
14
+ *
15
+ * @example
16
+ * await bookingTicket.transitionChildBooking({
17
+ * schedule_event_id: 301,
18
+ * action: 'confirm',
19
+ * });
20
+ */
21
+ export type BookingTransitionAction = 'confirm' | 'reject' | 'arrive' | 'start' | 'complete' | 'cancel' | 'no_show' | 'reschedule';
22
+ /** 子预约状态转移入参 */
23
+ export interface TransitionChildBookingParams {
24
+ schedule_event_id: number | string;
25
+ action: BookingTransitionAction;
26
+ }
27
+ /**
28
+ * 从 tempOrder 解析用于调用 appointment-status 接口的 schedule id。
29
+ *
30
+ * 优先级:
31
+ * 1. `tempOrder.metadata.appointment_booking_parent_schedule_id`
32
+ * 2. `tempOrder.bookings` 中 `parent_id === 0` 的 `schedule_event_id`
33
+ *
34
+ * 都缺失时返回 null,由调用方决定如何抛错。
35
+ */
36
+ export declare function resolveScheduleId(tempOrder: {
37
+ bookings?: any[];
38
+ metadata?: Record<string, any> | null;
39
+ } | null | undefined): number | string | null;
40
+ /**
41
+ * 原地把所有 bookings 的 `appointment_status` 覆盖为新值,
42
+ * 返回原 status 数组用于回滚(顺序与 bookings 一一对应)。
43
+ *
44
+ * - 元素为 null/undefined 时跳过写入(但占位仍保留以保证回滚下标对齐)
45
+ * - 不会克隆 booking 对象,保持与 OrderModule.tempOrder 引用一致
46
+ */
47
+ export declare function applyBookingsStatus(bookings: any[] | null | undefined, status: string): Array<string | undefined>;
48
+ /**
49
+ * 把 applyBookingsStatus 的返回值原地写回,撤销乐观更新。
50
+ * 长度不一致时按较短一方对齐(防御式编程,正常路径不会发生)。
51
+ */
52
+ export declare function restoreBookingsStatus(bookings: any[] | null | undefined, previous: Array<string | undefined>): void;
53
+ /**
54
+ * 将状态机 action 解析为转移后的 `appointment_status`。
55
+ *
56
+ * `reschedule` 暂未在状态矩阵启用,返回 null 表示跳过乐观更新。
57
+ *
58
+ * @example
59
+ * resolveStatusAfterTransition('confirm'); // 'confirmed'
60
+ */
61
+ export declare function resolveStatusAfterTransition(action: BookingTransitionAction): string | null;
62
+ /**
63
+ * 在 bookings 中按 `schedule_event_id` 定位子预约并乐观写入 `appointment_status`。
64
+ *
65
+ * @returns 写入前的 status;未命中时返回 undefined(调用方跳过回滚)
66
+ *
67
+ * @example
68
+ * const prev = applyChildBookingStatus(tempOrder.bookings, 301, 'confirmed');
69
+ */
70
+ export declare function applyChildBookingStatus(bookings: any[] | null | undefined, scheduleEventId: number | string, status: string): string | undefined;
71
+ /**
72
+ * 撤销 applyChildBookingStatus 对单条子预约的乐观写入。
73
+ *
74
+ * @example
75
+ * restoreChildBookingStatus(tempOrder.bookings, 301, prev);
76
+ */
77
+ export declare function restoreChildBookingStatus(bookings: any[] | null | undefined, scheduleEventId: number | string, previous: string | undefined): void;
@@ -0,0 +1,123 @@
1
+ declare let data: ({
2
+ id: number;
3
+ title: string;
4
+ price: number;
5
+ minMinutes: number;
6
+ maxMinutes: number;
7
+ unitMinutes: number;
8
+ unlimited: boolean;
9
+ _originalProduct: {
10
+ id: number;
11
+ extension_id: number;
12
+ extension_type: string;
13
+ shop_id: number;
14
+ title: string;
15
+ slug: string;
16
+ status: string;
17
+ stock_quantity: number;
18
+ sales_quantity: number;
19
+ sum_stock: number;
20
+ price: string;
21
+ original_price: string;
22
+ cost_price: string;
23
+ cover: string;
24
+ channel_application: string[];
25
+ is_track: number;
26
+ over_sold: number;
27
+ is_gst: number;
28
+ code: string;
29
+ barcode: string;
30
+ is_delivery: number;
31
+ weight_unit: string;
32
+ weight_value: string;
33
+ type: string;
34
+ unit: string;
35
+ sort: number;
36
+ subtitle: string;
37
+ minimum_markup_price: string;
38
+ is_bundle: number;
39
+ description: string;
40
+ open_sold_weight: number;
41
+ unit_value: number;
42
+ is_variant: number;
43
+ variant_count: number;
44
+ add_time: {
45
+ unit_duration: number;
46
+ min_add_time: number;
47
+ max_add_time: number;
48
+ calculate_type: string;
49
+ relation_product: {
50
+ type: string;
51
+ products: never[];
52
+ };
53
+ additional_time_options?: undefined;
54
+ };
55
+ shelf_product_datas: never[];
56
+ step_value: number;
57
+ min_num_unit: number;
58
+ is_charge_tax: number;
59
+ base_price: string;
60
+ variant: never[];
61
+ };
62
+ } | {
63
+ id: number;
64
+ title: string;
65
+ price: number;
66
+ minMinutes: number;
67
+ maxMinutes: number;
68
+ unitMinutes: number;
69
+ unlimited: boolean;
70
+ _originalProduct: {
71
+ id: number;
72
+ extension_id: number;
73
+ extension_type: string;
74
+ shop_id: number;
75
+ title: string;
76
+ slug: string;
77
+ status: string;
78
+ stock_quantity: number;
79
+ sales_quantity: number;
80
+ sum_stock: number;
81
+ price: string;
82
+ original_price: string;
83
+ cost_price: string;
84
+ cover: string;
85
+ channel_application: string[];
86
+ is_track: number;
87
+ over_sold: number;
88
+ is_gst: number;
89
+ code: string;
90
+ barcode: string;
91
+ is_delivery: number;
92
+ weight_unit: string;
93
+ weight_value: string;
94
+ type: string;
95
+ unit: string;
96
+ sort: number;
97
+ subtitle: string;
98
+ minimum_markup_price: string;
99
+ is_bundle: number;
100
+ description: string;
101
+ open_sold_weight: number;
102
+ unit_value: number;
103
+ is_variant: number;
104
+ variant_count: number;
105
+ add_time: {
106
+ additional_time_options: string;
107
+ unit_duration: number;
108
+ min_add_time: number;
109
+ max_add_time: number;
110
+ calculate_type: string;
111
+ relation_product: {
112
+ type: string;
113
+ products: never[];
114
+ };
115
+ };
116
+ shelf_product_datas: never[];
117
+ step_value: number;
118
+ min_num_unit: number;
119
+ is_charge_tax: number;
120
+ base_price: string;
121
+ variant: never[];
122
+ };
123
+ })[];
@@ -0,0 +1,185 @@
1
+ /**
2
+ * 计算指定加时时长下的最优购买方案。
3
+ *
4
+ * 输入的商品结构来自旧版 booking addTimeModal 的加时商品配置映射:
5
+ * - `minMinutes`:该商品第一次可选择的最小时长。
6
+ * - `maxMinutes`:单次购买该商品可覆盖的最大时长。
7
+ * - `unitMinutes`:超过最小时长后,每次递增的时长切片。
8
+ * - `price`:每个 `unitMinutes` 切片的价格。
9
+ * - `unlimited`:固定价格商品,可覆盖任意目标时长。
10
+ *
11
+ * 算法流程:
12
+ *
13
+ * ```
14
+ * products
15
+ * |
16
+ * v
17
+ * 将每个普通商品展开成有限候选档位
18
+ * 商品 A: min=30, max=60, unit=10, price=10
19
+ * => 30m/$30, 40m/$40, 50m/$50, 60m/$60
20
+ * |
21
+ * v
22
+ * 单独加入 unlimited 候选
23
+ * unlimited 商品 => targetMinutes / 固定商品价格
24
+ * |
25
+ * v
26
+ * 按 covered minutes 做动态规划
27
+ * dp[minutes] = 正好覆盖 `minutes` 时的最低价候选组合
28
+ * |
29
+ * v
30
+ * 从所有 dp[minutes >= targetMinutes] 中挑选最优方案
31
+ * ```
32
+ *
33
+ * 候选档位生成刻意对齐旧版 addTimeModal:
34
+ * `totalPrice = minutes / unitMinutes * price`.
35
+ * 例如 `minMinutes=30`、`unitMinutes=10`、`price=10` 时:
36
+ * - 30 分钟 => 30 / 10 * 10 = 30
37
+ * - 60 分钟 => 60 / 10 * 10 = 60
38
+ *
39
+ * 目标时长不要求精确命中某个档位,只需要覆盖即可。例如目标是 51 分钟时,
40
+ * 60 分钟档位可以作为候选。动态规划也允许跨商品组合,例如商品 A 的 30m
41
+ * 加上商品 B 的 30m。最终方案按以下优先级比较:
42
+ * 1. 总价更低;
43
+ * 2. 超出时长更少,即 `coveredMinutes - targetMinutes` 更小;
44
+ * 3. 结果行数更少,让购买方案尽量简单。
45
+ *
46
+ * 典型匹配示例:
47
+ *
48
+ * 示例 1:精确命中,直接选择更便宜的商品。
49
+ * ```
50
+ * target = 30
51
+ * 商品 A: min=30, max=30, unit=30, price=10 => 30m/$10
52
+ * 商品 B: min=30, max=30, unit=30, price=8 => 30m/$8
53
+ * 结果:选择商品 B,coveredMinutes=30,totalPrice=8
54
+ * ```
55
+ *
56
+ * 示例 2:目标时长落在两个档位之间,向上选择可覆盖的档位。
57
+ * ```
58
+ * target = 51
59
+ * 商品 A: min=30, max=120, unit=10, price=10
60
+ * 候选:30m/$30, 40m/$40, 50m/$50, 60m/$60 ...
61
+ * 结果:50m 不足以覆盖 51m,因此选择 60m/$60
62
+ * ```
63
+ *
64
+ * 示例 3:不同商品都能覆盖同一目标时长,比较最终价格。
65
+ * ```
66
+ * target = 51
67
+ * 商品 A: min=30, max=120, unit=10, price=10 => 60m/$60
68
+ * 商品 B: min=30, max=120, unit=30, price=25 => 60m/$50
69
+ * 结果:两个方案都覆盖 60m,但商品 B 更便宜,所以选择商品 B
70
+ * ```
71
+ *
72
+ * 示例 4:允许跨商品组合,组合价更低时会选择组合。
73
+ * ```
74
+ * target = 90
75
+ * 商品 A: min=30, max=30, unit=30, price=5 => 30m/$5
76
+ * 商品 B: min=60, max=60, unit=60, price=8 => 60m/$8
77
+ * 商品 C: min=90, max=90, unit=90, price=20 => 90m/$20
78
+ * 结果:商品 A + 商品 B = 90m/$13,比商品 C 更便宜
79
+ * ```
80
+ *
81
+ * 示例 5:允许重复购买同一个候选档位。
82
+ * ```
83
+ * target = 90
84
+ * 商品 A: min=30, max=30, unit=30, price=5 => 30m/$5
85
+ * 结果:购买 3 份商品 A,coveredMinutes=90,totalPrice=15,
86
+ * lines 中会合并为一行:product_add_schedule_time=30,num=3
87
+ * ```
88
+ *
89
+ * 示例 6:unlimited 可以覆盖任意目标时长,并参与价格比较。
90
+ * ```
91
+ * target = 180
92
+ * 商品 A: min=30, max=120, unit=30, price=10
93
+ * 商品 B: unlimited=true, price=35
94
+ * 普通商品可以组合成 180m,例如 120m + 60m,总价 $60
95
+ * unlimited 商品固定 $35
96
+ * 结果:选择 unlimited 商品,coveredMinutes=180,totalPrice=35
97
+ * ```
98
+ *
99
+ * 示例 7:unlimited 不一定优先,普通商品更便宜时选择普通商品。
100
+ * ```
101
+ * target = 60
102
+ * 商品 A: min=30, max=60, unit=30, price=10 => 60m/$20
103
+ * 商品 B: unlimited=true, price=50
104
+ * 结果:选择商品 A 的 60m 档位
105
+ * ```
106
+ *
107
+ * 示例 8:价格相同,优先选择超出时长更少的方案。
108
+ * ```
109
+ * target = 51
110
+ * 商品 A: 60m/$20
111
+ * 商品 B: 90m/$20
112
+ * 结果:选择 60m,因为 overage=9,小于 90m 的 overage=39
113
+ * ```
114
+ *
115
+ * 示例 9:价格和覆盖时长都相同,优先选择结果行数更少的方案。
116
+ * ```
117
+ * target = 60
118
+ * 商品 A: 60m/$20
119
+ * 商品 B: 30m/$10
120
+ * 商品 C: 30m/$10
121
+ * 结果:商品 A 单行方案和 B+C 两行方案价格、时长相同,选择商品 A
122
+ * ```
123
+ *
124
+ * 示例 10:没有任何有效商品时返回 `NO_PRODUCTS`。
125
+ * ```
126
+ * target = 30
127
+ * products = []
128
+ * 结果:available=false,unavailableReason='NO_PRODUCTS'
129
+ * ```
130
+ *
131
+ * 示例 11:有商品但没有可用候选时返回 `NO_COVERAGE`。
132
+ * ```
133
+ * target = 30
134
+ * 商品 A: price=0,或 minMinutes 缺失/无效
135
+ * 结果:available=false,unavailableReason='NO_COVERAGE'
136
+ * ```
137
+ *
138
+ * 示例 12:目标时长小于等于 0 时无需购买。
139
+ * ```
140
+ * target = 0
141
+ * 结果:available=true,coveredMinutes=0,totalPrice=0,lines=[]
142
+ * ```
143
+ *
144
+ * 搜索边界:
145
+ * 有限档位只需要搜索到 `targetMinutes + maxFiniteCandidateMinutes`。
146
+ * 这里的 `maxFiniteCandidateMinutes` 是所有普通候选档位里的最大时长。
147
+ * 例如目标是 51 分钟,最大普通档位是 120 分钟,则只搜索到 171 分钟。
148
+ * 如果某个组合覆盖了 180 分钟,那么移除其中任意一个普通档位后,剩余时长
149
+ * 仍然有机会覆盖 51 分钟,而且价格一定不会更高,所以 180 分钟这个组合不
150
+ * 可能是最优解。
151
+ */
152
+ export interface AddTimeProduct {
153
+ id: string | number;
154
+ title?: string;
155
+ price: number;
156
+ minMinutes?: number;
157
+ maxMinutes?: number;
158
+ unitMinutes?: number;
159
+ unlimited?: boolean;
160
+ _originalProduct?: unknown;
161
+ }
162
+ export interface AddTimePlanLine {
163
+ product_id: string | number;
164
+ product_title?: string;
165
+ product_add_schedule_time: number;
166
+ num: number;
167
+ price: number;
168
+ _originalProduct?: unknown;
169
+ }
170
+ export interface AddTimePlan {
171
+ available: boolean;
172
+ unavailableReason?: 'NO_PRODUCTS' | 'NO_COVERAGE';
173
+ targetMinutes: number;
174
+ coveredMinutes: number;
175
+ totalPrice: number;
176
+ lines: AddTimePlanLine[];
177
+ }
178
+ interface AddTimeCandidate extends AddTimePlanLine {
179
+ totalPrice: number;
180
+ unlimited?: boolean;
181
+ }
182
+ export declare const ADD_TIME_UNIT_MINUTES: readonly [10, 15, 20, 30, 45, 60];
183
+ export declare function buildAddTimeCandidates(products: AddTimeProduct[]): AddTimeCandidate[];
184
+ export declare function resolveBestAddTimePlan(products: AddTimeProduct[], targetMinutes: number): AddTimePlan;
185
+ export {};