@pisell/pisellos 2.3.38 → 2.3.40

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 (229) hide show
  1. package/dist/core/index.d.ts +0 -2
  2. package/dist/core/index.js +0 -7
  3. package/dist/model/strategy/adapter/promotion/adapter.d.ts +0 -4
  4. package/dist/model/strategy/adapter/promotion/adapter.js +0 -23
  5. package/dist/model/strategy/adapter/promotion/evaluator.d.ts +0 -17
  6. package/dist/model/strategy/adapter/promotion/evaluator.js +6 -279
  7. package/dist/model/strategy/adapter/promotion/examples.d.ts +0 -86
  8. package/dist/model/strategy/adapter/promotion/examples.js +0 -99
  9. package/dist/model/strategy/adapter/promotion/index.d.ts +1 -1
  10. package/dist/model/strategy/adapter/promotion/type.d.ts +2 -90
  11. package/dist/model/strategy/adapter/promotion/type.js +0 -45
  12. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +3 -5
  13. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +3 -6
  14. package/dist/modules/Discount/index.d.ts +1 -0
  15. package/dist/modules/Discount/index.js +40 -11
  16. package/dist/modules/Discount/types.d.ts +1 -0
  17. package/dist/modules/Holder/index.d.ts +48 -0
  18. package/dist/modules/Holder/index.js +640 -0
  19. package/dist/modules/Holder/types.d.ts +123 -0
  20. package/dist/modules/Holder/types.js +1 -0
  21. package/dist/modules/Holder/utils.d.ts +13 -0
  22. package/dist/modules/Holder/utils.js +34 -0
  23. package/dist/modules/OpenData/index.d.ts +0 -2
  24. package/dist/modules/OpenData/index.js +2 -10
  25. package/dist/modules/Order/index.d.ts +11 -28
  26. package/dist/modules/Order/index.js +509 -750
  27. package/dist/modules/Order/types.d.ts +10 -33
  28. package/dist/modules/Order/utils/orderCollectionIdentity.js +2 -7
  29. package/dist/modules/Order/utils.d.ts +10 -0
  30. package/dist/modules/Order/utils.js +41 -13
  31. package/dist/modules/Payment/index.d.ts +0 -2
  32. package/dist/modules/Payment/index.js +50 -79
  33. package/dist/modules/Payment/types.d.ts +28 -99
  34. package/dist/modules/Payment/types.js +3 -20
  35. package/dist/modules/Payment/walletpass.d.ts +1 -25
  36. package/dist/modules/Payment/walletpass.js +157 -707
  37. package/dist/modules/Product/types.d.ts +1 -0
  38. package/dist/modules/ProductList/index.js +33 -14
  39. package/dist/modules/Quotation/index.d.ts +1 -1
  40. package/dist/modules/Quotation/index.js +2 -2
  41. package/dist/modules/ResourcePlanner/index.d.ts +24 -0
  42. package/dist/modules/ResourcePlanner/index.js +181 -0
  43. package/dist/modules/ResourcePlanner/planner.d.ts +14 -0
  44. package/dist/modules/ResourcePlanner/planner.js +1069 -0
  45. package/dist/modules/ResourcePlanner/types.d.ts +227 -0
  46. package/dist/modules/ResourcePlanner/types.js +1 -0
  47. package/dist/modules/Rules/index.d.ts +0 -1
  48. package/dist/modules/Rules/index.js +96 -89
  49. package/dist/modules/SalesSummary/index.js +12 -13
  50. package/dist/modules/ScanOrderLogger/index.d.ts +2 -0
  51. package/dist/modules/ScanOrderLogger/index.js +15 -2
  52. package/dist/modules/ScanOrderLogger/providers/feishu.js +45 -27
  53. package/dist/modules/ScanOrderLogger/types.d.ts +1 -0
  54. package/dist/modules/Schedule/index.d.ts +3 -1
  55. package/dist/modules/Schedule/index.js +21 -16
  56. package/dist/modules/Summary/utils.js +38 -13
  57. package/dist/modules/index.d.ts +2 -0
  58. package/dist/modules/index.js +3 -1
  59. package/dist/plugins/window.d.ts +1 -0
  60. package/dist/server/index.d.ts +14 -16
  61. package/dist/server/index.js +1148 -1930
  62. package/dist/server/modules/order/index.d.ts +4 -54
  63. package/dist/server/modules/order/index.js +695 -1595
  64. package/dist/server/modules/order/types.d.ts +3 -11
  65. package/dist/server/modules/order/types.js +1 -1
  66. package/dist/solution/BaseSales/index.d.ts +20 -109
  67. package/dist/solution/BaseSales/index.js +481 -1797
  68. package/dist/solution/BaseSales/types.d.ts +0 -52
  69. package/dist/solution/BaseSales/types.js +1 -2
  70. package/dist/solution/BaseSales/utils/cartPromotion.d.ts +1 -3
  71. package/dist/solution/BaseSales/utils/cartPromotion.js +31 -90
  72. package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -6
  73. package/dist/solution/BookingByStep/index.d.ts +17 -2
  74. package/dist/solution/BookingByStep/index.js +294 -215
  75. package/dist/solution/BookingByStep/types.d.ts +2 -1
  76. package/dist/solution/BookingByStep/types.js +3 -1
  77. package/dist/solution/BookingByStep/utils/capacity.js +17 -1
  78. package/dist/solution/BookingByStep/utils/timeslots.d.ts +3 -1
  79. package/dist/solution/BookingByStep/utils/timeslots.js +19 -12
  80. package/dist/solution/BookingTicket/index.d.ts +4 -8
  81. package/dist/solution/BookingTicket/index.js +51 -134
  82. package/dist/solution/BookingTicket/utils/addProductDecision.js +0 -6
  83. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +0 -8
  84. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +82 -172
  85. package/dist/solution/BookingTicket/utils/scan/handleScan.d.ts +3 -1
  86. package/dist/solution/BookingTicket/utils/scan/handleScan.js +10 -2
  87. package/dist/solution/Sales/index.d.ts +0 -1
  88. package/dist/solution/Sales/index.js +2 -10
  89. package/dist/solution/ScanOrder/index.d.ts +26 -14
  90. package/dist/solution/ScanOrder/index.js +1148 -756
  91. package/dist/solution/ScanOrder/types.d.ts +21 -1
  92. package/dist/solution/ScanOrder/utils.d.ts +8 -0
  93. package/dist/solution/ScanOrder/utils.js +66 -25
  94. package/dist/solution/ShopDiscount/index.d.ts +1 -0
  95. package/dist/solution/ShopDiscount/index.js +125 -87
  96. package/dist/solution/UnifiedBookingSales/index.d.ts +183 -0
  97. package/dist/solution/UnifiedBookingSales/index.js +1871 -0
  98. package/dist/solution/UnifiedBookingSales/types.d.ts +143 -0
  99. package/dist/solution/UnifiedBookingSales/types.js +11 -0
  100. package/dist/solution/VenueBooking/index.d.ts +39 -11
  101. package/dist/solution/VenueBooking/index.js +1176 -860
  102. package/dist/solution/VenueBooking/types.d.ts +3 -0
  103. package/dist/solution/VenueBooking/utils/resource.js +1 -0
  104. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
  105. package/dist/solution/VenueBooking/utils/slotMerge.js +10 -5
  106. package/dist/solution/index.d.ts +1 -0
  107. package/dist/solution/index.js +2 -1
  108. package/dist/types/index.d.ts +1 -1
  109. package/lib/core/index.d.ts +0 -2
  110. package/lib/core/index.js +0 -4
  111. package/lib/model/strategy/adapter/promotion/adapter.d.ts +0 -4
  112. package/lib/model/strategy/adapter/promotion/adapter.js +0 -20
  113. package/lib/model/strategy/adapter/promotion/evaluator.d.ts +0 -17
  114. package/lib/model/strategy/adapter/promotion/evaluator.js +0 -235
  115. package/lib/model/strategy/adapter/promotion/examples.d.ts +0 -86
  116. package/lib/model/strategy/adapter/promotion/examples.js +0 -91
  117. package/lib/model/strategy/adapter/promotion/index.d.ts +1 -1
  118. package/lib/model/strategy/adapter/promotion/index.js +0 -2
  119. package/lib/model/strategy/adapter/promotion/type.d.ts +2 -90
  120. package/lib/model/strategy/adapter/promotion/type.js +0 -2
  121. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +1 -2
  122. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +1 -2
  123. package/lib/modules/Discount/index.d.ts +1 -0
  124. package/lib/modules/Discount/index.js +9 -0
  125. package/lib/modules/Discount/types.d.ts +1 -0
  126. package/lib/modules/Holder/index.d.ts +48 -0
  127. package/lib/modules/Holder/index.js +402 -0
  128. package/lib/modules/Holder/types.d.ts +123 -0
  129. package/lib/modules/Holder/types.js +17 -0
  130. package/lib/modules/Holder/utils.d.ts +13 -0
  131. package/lib/modules/Holder/utils.js +71 -0
  132. package/lib/modules/OpenData/index.d.ts +0 -2
  133. package/lib/modules/OpenData/index.js +1 -6
  134. package/lib/modules/Order/index.d.ts +11 -28
  135. package/lib/modules/Order/index.js +86 -196
  136. package/lib/modules/Order/types.d.ts +10 -33
  137. package/lib/modules/Order/utils/orderCollectionIdentity.js +0 -3
  138. package/lib/modules/Order/utils.d.ts +10 -0
  139. package/lib/modules/Order/utils.js +40 -16
  140. package/lib/modules/Payment/index.d.ts +0 -2
  141. package/lib/modules/Payment/index.js +13 -34
  142. package/lib/modules/Payment/types.d.ts +28 -99
  143. package/lib/modules/Payment/types.js +3 -4
  144. package/lib/modules/Payment/walletpass.d.ts +1 -25
  145. package/lib/modules/Payment/walletpass.js +21 -470
  146. package/lib/modules/Product/types.d.ts +1 -0
  147. package/lib/modules/ProductList/index.js +40 -31
  148. package/lib/modules/Quotation/index.d.ts +1 -1
  149. package/lib/modules/Quotation/index.js +2 -2
  150. package/lib/modules/ResourcePlanner/index.d.ts +24 -0
  151. package/lib/modules/ResourcePlanner/index.js +148 -0
  152. package/lib/modules/ResourcePlanner/planner.d.ts +14 -0
  153. package/lib/modules/ResourcePlanner/planner.js +933 -0
  154. package/lib/modules/ResourcePlanner/types.d.ts +227 -0
  155. package/lib/modules/ResourcePlanner/types.js +17 -0
  156. package/lib/modules/Rules/index.d.ts +0 -1
  157. package/lib/modules/Rules/index.js +40 -47
  158. package/lib/modules/SalesSummary/index.js +6 -7
  159. package/lib/modules/ScanOrderLogger/index.d.ts +2 -0
  160. package/lib/modules/ScanOrderLogger/index.js +13 -1
  161. package/lib/modules/ScanOrderLogger/providers/feishu.js +15 -6
  162. package/lib/modules/ScanOrderLogger/types.d.ts +1 -0
  163. package/lib/modules/Schedule/index.d.ts +3 -1
  164. package/lib/modules/Schedule/index.js +10 -8
  165. package/lib/modules/Summary/utils.js +21 -1
  166. package/lib/modules/index.d.ts +2 -0
  167. package/lib/modules/index.js +5 -1
  168. package/lib/plugins/window.d.ts +1 -0
  169. package/lib/server/index.d.ts +14 -16
  170. package/lib/server/index.js +83 -675
  171. package/lib/server/modules/order/index.d.ts +4 -54
  172. package/lib/server/modules/order/index.js +66 -679
  173. package/lib/server/modules/order/types.d.ts +3 -11
  174. package/lib/solution/BaseSales/index.d.ts +20 -109
  175. package/lib/solution/BaseSales/index.js +70 -881
  176. package/lib/solution/BaseSales/types.d.ts +0 -52
  177. package/lib/solution/BaseSales/types.js +1 -2
  178. package/lib/solution/BaseSales/utils/cartPromotion.d.ts +1 -3
  179. package/lib/solution/BaseSales/utils/cartPromotion.js +12 -63
  180. package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -6
  181. package/lib/solution/BookingByStep/index.d.ts +17 -2
  182. package/lib/solution/BookingByStep/index.js +60 -18
  183. package/lib/solution/BookingByStep/types.d.ts +2 -1
  184. package/lib/solution/BookingByStep/types.js +5 -0
  185. package/lib/solution/BookingByStep/utils/capacity.js +20 -1
  186. package/lib/solution/BookingByStep/utils/timeslots.d.ts +3 -1
  187. package/lib/solution/BookingByStep/utils/timeslots.js +19 -11
  188. package/lib/solution/BookingTicket/index.d.ts +4 -8
  189. package/lib/solution/BookingTicket/index.js +19 -64
  190. package/lib/solution/BookingTicket/utils/addProductDecision.js +0 -4
  191. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +0 -8
  192. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +4 -36
  193. package/lib/solution/BookingTicket/utils/scan/handleScan.d.ts +3 -1
  194. package/lib/solution/BookingTicket/utils/scan/handleScan.js +2 -2
  195. package/lib/solution/Sales/index.d.ts +0 -1
  196. package/lib/solution/Sales/index.js +3 -5
  197. package/lib/solution/ScanOrder/index.d.ts +26 -14
  198. package/lib/solution/ScanOrder/index.js +449 -190
  199. package/lib/solution/ScanOrder/types.d.ts +21 -1
  200. package/lib/solution/ScanOrder/utils.d.ts +8 -0
  201. package/lib/solution/ScanOrder/utils.js +31 -0
  202. package/lib/solution/ShopDiscount/index.d.ts +1 -0
  203. package/lib/solution/ShopDiscount/index.js +14 -0
  204. package/lib/solution/UnifiedBookingSales/index.d.ts +183 -0
  205. package/lib/solution/UnifiedBookingSales/index.js +1076 -0
  206. package/lib/solution/UnifiedBookingSales/types.d.ts +143 -0
  207. package/lib/solution/UnifiedBookingSales/types.js +33 -0
  208. package/lib/solution/VenueBooking/index.d.ts +39 -11
  209. package/lib/solution/VenueBooking/index.js +328 -123
  210. package/lib/solution/VenueBooking/types.d.ts +3 -0
  211. package/lib/solution/VenueBooking/utils/resource.js +1 -0
  212. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
  213. package/lib/solution/VenueBooking/utils/slotMerge.js +6 -4
  214. package/lib/solution/index.d.ts +1 -0
  215. package/lib/solution/index.js +3 -1
  216. package/lib/types/index.d.ts +1 -1
  217. package/package.json +1 -1
  218. package/dist/modules/Order/payment-utils.d.ts +0 -26
  219. package/dist/modules/Order/payment-utils.js +0 -225
  220. package/dist/solution/BookingTicket/utils/weighingProductSku.d.ts +0 -5
  221. package/dist/solution/BookingTicket/utils/weighingProductSku.js +0 -45
  222. package/dist/utils/payment-number.d.ts +0 -9
  223. package/dist/utils/payment-number.js +0 -69
  224. package/lib/modules/Order/payment-utils.d.ts +0 -26
  225. package/lib/modules/Order/payment-utils.js +0 -224
  226. package/lib/solution/BookingTicket/utils/weighingProductSku.d.ts +0 -5
  227. package/lib/solution/BookingTicket/utils/weighingProductSku.js +0 -63
  228. package/lib/utils/payment-number.d.ts +0 -9
  229. package/lib/utils/payment-number.js +0 -64
@@ -1,5 +1,6 @@
1
1
  import { OrderModule, ProductList, SalesSummaryModule, ScanOrderLogInput, ScanOrderLoggerModule, ScanOrderLoggerProviderConfig, ScanOrderLoggerProviderType, DateModule, ScheduleModule, QuotationModule, OpenDataModule } from '../../modules';
2
2
  import type { QuantityCheckResult, QuantityLimitResult } from '../../model/strategy/adapter/itemRule';
3
+ import { HolderModule } from '../../modules/Holder';
3
4
  export type { ScanOrderOrderProductIdentity, ScanOrderOrderProduct, ScanOrderSubmitProduct, ScanOrderSummary, ScanOrderTempOrder, ScanOrderSubmitPayload, } from '../ScanOrder/types';
4
5
  export declare enum VenueBookingHooks {
5
6
  onInited = "venueBooking:onInited",
@@ -96,6 +97,7 @@ export interface VenueResourceRawData {
96
97
  export interface ResourceProductMapping {
97
98
  productId: number;
98
99
  productTitle: string;
100
+ formName?: string;
99
101
  resourceName: string;
100
102
  formId: number | string;
101
103
  price: string;
@@ -144,6 +146,7 @@ export interface VenueBookingState {
144
146
  passed: boolean | null;
145
147
  failures: QuantityCheckResult[];
146
148
  };
149
+ holder?: HolderModule;
147
150
  }
148
151
  export interface VenueBookingLoggerRuntimeConfig {
149
152
  provider?: ScanOrderLoggerProviderType;
@@ -93,6 +93,7 @@ export function buildResourceProductMap(products) {
93
93
  var mapping = {
94
94
  productId: product.id,
95
95
  productTitle: product.title,
96
+ formName: resource.title,
96
97
  resourceName: resource.title,
97
98
  formId: resource.id,
98
99
  price: product.price || '0.00',
@@ -12,10 +12,6 @@ export declare function buildPriceBreakdown(params: {
12
12
  }) => number;
13
13
  };
14
14
  }): PriceBreakdownEntry[];
15
- export declare function buildVenueResourceMetadata(params: {
16
- mapping: ResourceProductMapping;
17
- rawResource: VenueResourceRawData | undefined;
18
- }): Record<string, any>;
19
15
  export interface BuildVenueBookingParams {
20
16
  group: MergedSlotGroup;
21
17
  resourceId: number | string;
@@ -29,6 +25,10 @@ export interface BuildVenueBookingParams {
29
25
  */
30
26
  childResources?: VenueResourceRawData[];
31
27
  }
28
+ export declare function buildVenueResourceMetadata(params: {
29
+ mapping: ResourceProductMapping;
30
+ rawResource: VenueResourceRawData | undefined;
31
+ }): Record<string, any>;
32
32
  export declare function buildVenueBookingEntry(params: BuildVenueBookingParams): Record<string, any>;
33
33
  /**
34
34
  * 从一条已合并的订单商品还原出独立的时段列表。
@@ -90,13 +90,15 @@ export function buildPriceBreakdown(params) {
90
90
  return entries;
91
91
  }
92
92
  export function buildVenueResourceMetadata(params) {
93
- var _rawResource$form_nam, _ref, _rawResource$main_fie, _rawResource$combined;
93
+ var _mapping$formName, _rawResource$main_fie;
94
94
  var mapping = params.mapping,
95
95
  rawResource = params.rawResource;
96
+ var combined = rawResource === null || rawResource === void 0 ? void 0 : rawResource.combined_resource;
97
+ var isCombined = !!(combined && combined.status === 1 && Array.isArray(combined.resource_ids));
96
98
  return {
97
- form_name: (_rawResource$form_nam = rawResource === null || rawResource === void 0 ? void 0 : rawResource.form_name) !== null && _rawResource$form_nam !== void 0 ? _rawResource$form_nam : '',
98
- resource_name: (_ref = (_rawResource$main_fie = rawResource === null || rawResource === void 0 ? void 0 : rawResource.main_field) !== null && _rawResource$main_fie !== void 0 ? _rawResource$main_fie : mapping.resourceName) !== null && _ref !== void 0 ? _ref : '',
99
- combined_resource: (_rawResource$combined = rawResource === null || rawResource === void 0 ? void 0 : rawResource.combined_resource) !== null && _rawResource$combined !== void 0 ? _rawResource$combined : null
99
+ form_name: (_mapping$formName = mapping.formName) !== null && _mapping$formName !== void 0 ? _mapping$formName : mapping.resourceName,
100
+ resource_name: (_rawResource$main_fie = rawResource === null || rawResource === void 0 ? void 0 : rawResource.main_field) !== null && _rawResource$main_fie !== void 0 ? _rawResource$main_fie : mapping.resourceName,
101
+ combined_resource: isCombined ? combined : null
100
102
  };
101
103
  }
102
104
  export function buildVenueBookingEntry(params) {
@@ -119,7 +121,10 @@ export function buildVenueBookingEntry(params) {
119
121
  form_id: (_rawResource$form_id = rawResource === null || rawResource === void 0 ? void 0 : rawResource.form_id) !== null && _rawResource$form_id !== void 0 ? _rawResource$form_id : mapping.formId,
120
122
  relation_id: resourceId,
121
123
  capacity: 1,
122
- metadata: {}
124
+ metadata: buildVenueResourceMetadata({
125
+ mapping: mapping,
126
+ rawResource: rawResource
127
+ })
123
128
  };
124
129
  if (childResources && childResources.length) {
125
130
  resourceEntry.children = childResources.map(function (child) {
@@ -8,3 +8,4 @@ export * from './Sales';
8
8
  export * from './ScanOrder';
9
9
  export * from './BaseSales';
10
10
  export * from './VenueBooking';
11
+ export * from './UnifiedBookingSales';
@@ -7,4 +7,5 @@ export * from "./Checkout";
7
7
  export * from "./Sales";
8
8
  export * from "./ScanOrder";
9
9
  export * from "./BaseSales";
10
- export * from "./VenueBooking";
10
+ export * from "./VenueBooking";
11
+ export * from "./UnifiedBookingSales";
@@ -6,6 +6,7 @@ export interface Plugin {
6
6
  version: string;
7
7
  initialize: () => Promise<void> | void;
8
8
  destroy?: () => Promise<void> | void;
9
+ getLocalStorage?: (key: string) => string | null;
9
10
  }
10
11
  export interface PluginOptions {
11
12
  dependencies?: string[];
@@ -47,7 +48,6 @@ export interface PisellCore {
47
48
  getModule: <T extends Module>(name: string) => T | null;
48
49
  getModuleExports: <T = any>(name: string) => T | null;
49
50
  hasModule: (name: string) => boolean;
50
- getModuleNames: () => string[];
51
51
  effects: {
52
52
  on: (event: string, callback: (payload: any) => void) => () => void;
53
53
  once: (event: string, callback: (payload: any) => void) => () => void;
@@ -28,8 +28,6 @@ declare class PisellOSCore implements PisellCore {
28
28
  getModule<T extends Module>(name: string): T | null;
29
29
  getModuleExports<T = any>(name: string): T | null;
30
30
  hasModule(name: string): boolean;
31
- /** 返回当前已注册模块名,供宿主在切换店铺等生命周期中定向清理运行态。 */
32
- getModuleNames(): string[];
33
31
  destroy(): Promise<void>;
34
32
  setContext(ctx: Partial<BusinessContext>): void;
35
33
  /**
package/lib/core/index.js CHANGED
@@ -210,10 +210,6 @@ var PisellOSCore = class {
210
210
  hasModule(name) {
211
211
  return this.modules.has(name);
212
212
  }
213
- /** 返回当前已注册模块名,供宿主在切换店铺等生命周期中定向清理运行态。 */
214
- getModuleNames() {
215
- return Array.from(this.modules.keys());
216
- }
217
213
  // 销毁方法
218
214
  async destroy() {
219
215
  for (const [name, module2] of this.modules.entries()) {
@@ -48,10 +48,6 @@ export declare class PromotionAdapter implements BusinessAdapter {
48
48
  * 解析 买X送Y Action
49
49
  */
50
50
  private parseBuyXGetYFreeAction;
51
- /**
52
- * 解析 商品奖励 Action
53
- */
54
- private parseItemRewardAction;
55
51
  /**
56
52
  * 获取适用的商品列表
57
53
  *
@@ -134,8 +134,6 @@ var PromotionAdapter = class {
134
134
  return this.parseXItemsForYPriceAction(action);
135
135
  case import_type.PROMOTION_ACTION_TYPES.BUY_X_GET_Y_FREE:
136
136
  return this.parseBuyXGetYFreeAction(action);
137
- case import_type.PROMOTION_ACTION_TYPES.ITEM_REWARD:
138
- return this.parseItemRewardAction(action);
139
137
  default:
140
138
  return void 0;
141
139
  }
@@ -169,24 +167,6 @@ var PromotionAdapter = class {
169
167
  giftProducts: config.giftProducts || []
170
168
  };
171
169
  }
172
- /**
173
- * 解析 商品奖励 Action
174
- */
175
- parseItemRewardAction(action) {
176
- const value = action.value || {};
177
- const config = action.config || {};
178
- return {
179
- type: import_type.PROMOTION_ACTION_TYPES.ITEM_REWARD,
180
- rewardMethod: value.rewardMethod || "free",
181
- rewardValue: Number(value.rewardValue || 0),
182
- quantityRule: value.quantityRule || "per_condition_quantity",
183
- triggerQuantity: Number(value.triggerQuantity || 1),
184
- rewardQuantity: Number(value.rewardQuantity || 1),
185
- maxRewardQuantity: value.maxRewardQuantity === void 0 || value.maxRewardQuantity === null ? void 0 : Number(value.maxRewardQuantity),
186
- rewardTargets: Array.isArray(config.rewardTargets) ? config.rewardTargets : [],
187
- targetSelection: config.targetSelection || "consumer_best"
188
- };
189
- }
190
170
  /**
191
171
  * 获取适用的商品列表
192
172
  *
@@ -169,21 +169,6 @@ export declare class PromotionEvaluator {
169
169
  * 支持 bundle 子商品的数量计算(主商品数量 × 子商品数量)
170
170
  */
171
171
  private processBuyXGetYFree;
172
- /**
173
- * 处理 商品奖励 促销
174
- *
175
- * 1. 使用 group.products 统计触发条件商品数量
176
- * 2. 按 quantityRule 计算最多奖励的目标商品数量
177
- * 3. 在全购物车商品中筛选 rewardTargets
178
- * 4. 按消费者最优(可节省金额从高到低)选择目标单位
179
- * 5. 对目标商品拆分并写入 finalPrice,触发商品本身不改价
180
- */
181
- private processItemReward;
182
- private normalizePositiveInteger;
183
- private getAvailablePromotionQuantity;
184
- private buildItemRewardTargetUnits;
185
- private resolveItemRewardFinalPrice;
186
- private resolveItemRewardLimit;
187
172
  /**
188
173
  * 获取未参与任何促销的商品
189
174
  */
@@ -209,8 +194,6 @@ export declare class PromotionEvaluator {
209
194
  * 检查商品是否在策略的适用范围内
210
195
  */
211
196
  private isProductInStrategy;
212
- private shouldSkipStrategyForProduct;
213
- private hasActionType;
214
197
  /**
215
198
  * 查找商品匹配规则
216
199
  */
@@ -133,9 +133,6 @@ var PromotionEvaluator = class {
133
133
  for (const product of products) {
134
134
  const applicablePromotions = [];
135
135
  for (const config of configs) {
136
- if (this.shouldSkipStrategyForProduct(product, config)) {
137
- continue;
138
- }
139
136
  const matchInfo = this.getProductMatchInfo(product, config);
140
137
  if (!matchInfo.isMatch) {
141
138
  continue;
@@ -299,16 +296,6 @@ var PromotionEvaluator = class {
299
296
  if (result.giftInfo) {
300
297
  gifts.push(result.giftInfo);
301
298
  }
302
- } else if (actionType === import_type.PROMOTION_ACTION_TYPES.ITEM_REWARD) {
303
- const result = this.processItemReward(
304
- group,
305
- processedQuantityMap,
306
- products,
307
- matchedBundleIndexMap
308
- );
309
- pricedProducts.push(...result.products);
310
- totalOriginalAmount = totalOriginalAmount.plus(result.originalAmount);
311
- totalFinalAmount = totalFinalAmount.plus(result.finalAmount);
312
299
  }
313
300
  }
314
301
  const remainingProducts = this.getRemainingProducts(
@@ -392,9 +379,6 @@ var PromotionEvaluator = class {
392
379
  for (const product of products) {
393
380
  const applicableStrategies = [];
394
381
  for (const config of configs) {
395
- if (this.shouldSkipStrategyForProduct(product, config)) {
396
- continue;
397
- }
398
382
  let contextProduct = product;
399
383
  if (!matchVariant) {
400
384
  const productMatchRule = this.findProductMatchRule(config);
@@ -471,9 +455,6 @@ var PromotionEvaluator = class {
471
455
  } else if (actionType === "X_ITEMS_FOR_Y_PRICE") {
472
456
  const detail = actionDetail;
473
457
  requiredQuantity = detail.x || 0;
474
- } else if (actionType === "ITEM_REWARD") {
475
- const detail = actionDetail;
476
- requiredQuantity = detail.triggerQuantity || 1;
477
458
  }
478
459
  const productMatchRule = this.findProductMatchRule(config);
479
460
  const eligibleProducts = (productMatchRule == null ? void 0 : productMatchRule.value) || [];
@@ -787,213 +768,6 @@ var PromotionEvaluator = class {
787
768
  giftInfo
788
769
  };
789
770
  }
790
- /**
791
- * 处理 商品奖励 促销
792
- *
793
- * 1. 使用 group.products 统计触发条件商品数量
794
- * 2. 按 quantityRule 计算最多奖励的目标商品数量
795
- * 3. 在全购物车商品中筛选 rewardTargets
796
- * 4. 按消费者最优(可节省金额从高到低)选择目标单位
797
- * 5. 对目标商品拆分并写入 finalPrice,触发商品本身不改价
798
- */
799
- processItemReward(group, processedQuantityMap, allProducts, matchedBundleIndexMap) {
800
- const {
801
- strategyId,
802
- strategyMetadata,
803
- actionDetail,
804
- products: triggerProducts
805
- } = group;
806
- const detail = actionDetail;
807
- const triggerQuantity = this.normalizePositiveInteger(detail.triggerQuantity, 1);
808
- const rewardQuantity = this.normalizePositiveInteger(detail.rewardQuantity, 1);
809
- const conditionQuantity = this.getAvailablePromotionQuantity(
810
- triggerProducts,
811
- processedQuantityMap,
812
- matchedBundleIndexMap
813
- );
814
- if (conditionQuantity < triggerQuantity) {
815
- return { products: [], originalAmount: 0, finalAmount: 0 };
816
- }
817
- const targetProducts = allProducts.filter(
818
- (product) => this.isProductMatch(product, detail.rewardTargets || [])
819
- );
820
- const targetUnitCandidates = this.buildItemRewardTargetUnits(
821
- targetProducts,
822
- processedQuantityMap,
823
- detail
824
- );
825
- if (targetUnitCandidates.length === 0) {
826
- return { products: [], originalAmount: 0, finalAmount: 0 };
827
- }
828
- const rewardLimit = this.resolveItemRewardLimit(
829
- detail,
830
- conditionQuantity,
831
- triggerQuantity,
832
- rewardQuantity,
833
- targetUnitCandidates.length
834
- );
835
- if (rewardLimit <= 0) {
836
- return { products: [], originalAmount: 0, finalAmount: 0 };
837
- }
838
- const selectedUnits = [...targetUnitCandidates].sort((a, b) => {
839
- const discountDiff = b.discountAmount.minus(a.discountAmount).toNumber();
840
- if (discountDiff !== 0)
841
- return discountDiff;
842
- return b.originalPrice.minus(a.originalPrice).toNumber();
843
- }).slice(0, rewardLimit);
844
- const selectedByProductId = /* @__PURE__ */ new Map();
845
- for (const unit of selectedUnits) {
846
- const existing = selectedByProductId.get(unit.product.id);
847
- if (existing) {
848
- existing.quantity += 1;
849
- } else {
850
- selectedByProductId.set(unit.product.id, {
851
- quantity: 1,
852
- finalPrice: unit.finalPrice,
853
- originalPrice: unit.originalPrice
854
- });
855
- }
856
- }
857
- const result = [];
858
- let originalAmount = new import_decimal.default(0);
859
- let finalAmount = new import_decimal.default(0);
860
- for (const product of targetProducts) {
861
- const key = this.getProductKey(product);
862
- const processedQty = processedQuantityMap.get(key) || 0;
863
- const availableQty = product.quantity - processedQty;
864
- if (availableQty <= 0)
865
- continue;
866
- const selected = selectedByProductId.get(product.id);
867
- const selectedQty = (selected == null ? void 0 : selected.quantity) || 0;
868
- const remainingQty = availableQty - selectedQty;
869
- if (selectedQty <= 0)
870
- continue;
871
- if (selectedQty > 0) {
872
- result.push({
873
- ...product,
874
- id: selectedQty === availableQty ? product.id : this.generateRandomId(),
875
- originalId: product.id,
876
- quantity: selectedQty,
877
- finalPrice: this.formatPrice(selected.finalPrice),
878
- strategyId,
879
- strategyMetadata,
880
- inPromotion: true,
881
- isSplit: selectedQty !== product.quantity
882
- });
883
- originalAmount = originalAmount.plus(
884
- selected.originalPrice.mul(selectedQty)
885
- );
886
- finalAmount = finalAmount.plus(selected.finalPrice.mul(selectedQty));
887
- }
888
- if (remainingQty > 0) {
889
- result.push({
890
- ...product,
891
- quantity: remainingQty,
892
- finalPrice: this.formatPrice(product.price),
893
- strategyId: void 0,
894
- strategyMetadata: void 0,
895
- inPromotion: false,
896
- isSplit: selectedQty > 0
897
- });
898
- const remainingAmount = new import_decimal.default(product.price).mul(remainingQty);
899
- originalAmount = originalAmount.plus(remainingAmount);
900
- finalAmount = finalAmount.plus(remainingAmount);
901
- }
902
- processedQuantityMap.set(key, processedQty + availableQty);
903
- }
904
- return {
905
- products: result,
906
- originalAmount: originalAmount.toNumber(),
907
- finalAmount: finalAmount.toNumber()
908
- };
909
- }
910
- normalizePositiveInteger(value, fallback) {
911
- const n = Math.floor(Number(value));
912
- return Number.isFinite(n) && n > 0 ? n : fallback;
913
- }
914
- getAvailablePromotionQuantity(products, processedQuantityMap, matchedBundleIndexMap) {
915
- let total = 0;
916
- for (const product of products) {
917
- const key = this.getProductKey(product);
918
- const processedQty = processedQuantityMap.get(key) || 0;
919
- const availableQty = product.quantity - processedQty;
920
- if (availableQty <= 0)
921
- continue;
922
- const matchedBundleIndex = matchedBundleIndexMap == null ? void 0 : matchedBundleIndexMap.get(product.id);
923
- if (matchedBundleIndex !== void 0 && product.bundle) {
924
- const bundleItem = product.bundle[matchedBundleIndex];
925
- total += availableQty * ((bundleItem == null ? void 0 : bundleItem.quantity) || 1);
926
- } else {
927
- total += availableQty;
928
- }
929
- }
930
- return total;
931
- }
932
- buildItemRewardTargetUnits(products, processedQuantityMap, detail) {
933
- const units = [];
934
- for (const product of products) {
935
- const key = this.getProductKey(product);
936
- const processedQty = processedQuantityMap.get(key) || 0;
937
- const availableQty = product.quantity - processedQty;
938
- if (availableQty <= 0)
939
- continue;
940
- const originalPrice = new import_decimal.default(product.price || 0);
941
- const finalPrice = this.resolveItemRewardFinalPrice(originalPrice, detail);
942
- const discountAmount = originalPrice.minus(finalPrice);
943
- if (discountAmount.lte(0))
944
- continue;
945
- for (let i = 0; i < availableQty; i++) {
946
- units.push({
947
- product,
948
- originalPrice,
949
- finalPrice,
950
- discountAmount
951
- });
952
- }
953
- }
954
- return units;
955
- }
956
- resolveItemRewardFinalPrice(originalPrice, detail) {
957
- const rewardValue = new import_decimal.default(Number(detail.rewardValue) || 0);
958
- let finalPrice;
959
- switch (detail.rewardMethod) {
960
- case "percent_off": {
961
- const percent = import_decimal.default.min(100, import_decimal.default.max(0, rewardValue));
962
- finalPrice = originalPrice.mul(new import_decimal.default(100).minus(percent)).div(100);
963
- break;
964
- }
965
- case "amount_off":
966
- finalPrice = originalPrice.minus(import_decimal.default.max(0, rewardValue));
967
- break;
968
- case "fixed_price":
969
- finalPrice = import_decimal.default.max(0, rewardValue);
970
- break;
971
- case "free":
972
- default:
973
- finalPrice = new import_decimal.default(0);
974
- break;
975
- }
976
- return import_decimal.default.max(0, import_decimal.default.min(originalPrice, finalPrice)).toDecimalPlaces(2, import_decimal.default.ROUND_HALF_UP);
977
- }
978
- resolveItemRewardLimit(detail, conditionQuantity, triggerQuantity, rewardQuantity, targetUnitCount) {
979
- let limit = 0;
980
- switch (detail.quantityRule) {
981
- case "all_targets":
982
- limit = targetUnitCount;
983
- break;
984
- case "max_per_order":
985
- limit = this.normalizePositiveInteger(
986
- detail.maxRewardQuantity ?? detail.rewardQuantity,
987
- rewardQuantity
988
- );
989
- break;
990
- case "per_condition_quantity":
991
- default:
992
- limit = Math.floor(conditionQuantity / triggerQuantity) * rewardQuantity;
993
- break;
994
- }
995
- return Math.min(Math.max(0, limit), targetUnitCount);
996
- }
997
771
  /**
998
772
  * 获取未参与任何促销的商品
999
773
  */
@@ -1065,17 +839,8 @@ var PromotionEvaluator = class {
1065
839
  * 检查商品是否在策略的适用范围内
1066
840
  */
1067
841
  isProductInStrategy(product, config) {
1068
- if (this.shouldSkipStrategyForProduct(product, config)) {
1069
- return false;
1070
- }
1071
842
  return this.getProductMatchInfo(product, config).isMatch;
1072
843
  }
1073
- shouldSkipStrategyForProduct(product, config) {
1074
- return Boolean(product._promotionOnlyForItemReward) && !this.hasActionType(config, import_type.PROMOTION_ACTION_TYPES.ITEM_REWARD);
1075
- }
1076
- hasActionType(config, actionType) {
1077
- return (config.actions || []).some((action) => (action == null ? void 0 : action.type) === actionType);
1078
- }
1079
844
  /**
1080
845
  * 查找商品匹配规则
1081
846
  */
@@ -136,89 +136,3 @@ export declare const BUY_X_GET_Y_FREE_STRATEGY: {
136
136
  };
137
137
  }[];
138
138
  };
139
- /**
140
- * ITEM_REWARD 策略配置示例:儿童票触发婴儿票免费
141
- *
142
- * 业务规则:
143
- * - 条件商品:儿童票(conditions.rules.productIdAndVariantId)
144
- * - 奖励商品:购物车/订单内已经存在的婴儿票(actions[0].config.rewardTargets)
145
- * - 本 action 不自动新增婴儿票;每次购物车变更后由统一促销链路重算
146
- *
147
- * 字段说明:
148
- * - type: "ITEM_REWARD" 表示商品奖励 action
149
- * - target: "product" 表示本期只奖励商品行
150
- * - config.rewardTargets: 奖励对象数组,支持 { product_id, product_variant_id }
151
- * - config.targetSelection: "consumer_best" 表示目标商品超额时选择节省金额最高的商品
152
- * - value.rewardMethod:
153
- * - "free": 目标商品最终价为 0
154
- * - "percent_off": 百分比折扣,rewardValue 为 0-100
155
- * - "amount_off": 每个目标商品固定减免 rewardValue
156
- * - "fixed_price": 目标商品最终单价为 rewardValue
157
- * - value.quantityRule:
158
- * - "per_condition_quantity": 每满足 triggerQuantity 个条件商品,奖励 rewardQuantity 个目标商品
159
- * - "all_targets": 满足条件后奖励全部目标商品
160
- * - "max_per_order": 满足条件后每单最多奖励 maxRewardQuantity 个目标商品
161
- */
162
- export declare const ITEM_REWARD_STRATEGY: {
163
- metadata: {
164
- id: string;
165
- name: {
166
- en: string;
167
- 'zh-CN': string;
168
- 'zh-HK': string;
169
- };
170
- type: string;
171
- custom: {
172
- display: {
173
- product_card: {
174
- text: {
175
- en: string;
176
- 'zh-CN': string;
177
- 'zh-HK': string;
178
- };
179
- type: string;
180
- };
181
- };
182
- };
183
- };
184
- conditions: {
185
- operator: string;
186
- rules: ({
187
- type: string;
188
- field: string;
189
- value: string;
190
- operator: string;
191
- } | {
192
- type: string;
193
- field: string;
194
- value: {
195
- product_id: number;
196
- product_variant_id: number;
197
- }[];
198
- operator: string;
199
- })[];
200
- actionIds: string[];
201
- };
202
- actions: {
203
- id: string;
204
- type: string;
205
- value: {
206
- rewardMethod: string;
207
- rewardValue: number;
208
- quantityRule: string;
209
- triggerQuantity: number;
210
- rewardQuantity: number;
211
- maxRewardQuantity: number;
212
- };
213
- valueType: string;
214
- target: string;
215
- priority: number;
216
- config: {
217
- rewardTargets: {
218
- product_id: number;
219
- product_variant_id: number;
220
- }[];
221
- targetSelection: string;
222
- };
223
- }[];
224
- };