@pisell/pisellos 2.3.38 → 2.3.39

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 (225) 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 +3 -7
  81. package/dist/solution/BookingTicket/index.js +49 -132
  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/Sales/index.d.ts +0 -1
  86. package/dist/solution/Sales/index.js +2 -10
  87. package/dist/solution/ScanOrder/index.d.ts +26 -14
  88. package/dist/solution/ScanOrder/index.js +1148 -756
  89. package/dist/solution/ScanOrder/types.d.ts +21 -1
  90. package/dist/solution/ScanOrder/utils.d.ts +8 -0
  91. package/dist/solution/ScanOrder/utils.js +66 -25
  92. package/dist/solution/ShopDiscount/index.d.ts +1 -0
  93. package/dist/solution/ShopDiscount/index.js +125 -87
  94. package/dist/solution/UnifiedBookingSales/index.d.ts +183 -0
  95. package/dist/solution/UnifiedBookingSales/index.js +1871 -0
  96. package/dist/solution/UnifiedBookingSales/types.d.ts +143 -0
  97. package/dist/solution/UnifiedBookingSales/types.js +11 -0
  98. package/dist/solution/VenueBooking/index.d.ts +39 -11
  99. package/dist/solution/VenueBooking/index.js +1176 -860
  100. package/dist/solution/VenueBooking/types.d.ts +3 -0
  101. package/dist/solution/VenueBooking/utils/resource.js +1 -0
  102. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
  103. package/dist/solution/VenueBooking/utils/slotMerge.js +10 -5
  104. package/dist/solution/index.d.ts +1 -0
  105. package/dist/solution/index.js +2 -1
  106. package/dist/types/index.d.ts +1 -1
  107. package/lib/core/index.d.ts +0 -2
  108. package/lib/core/index.js +0 -4
  109. package/lib/model/strategy/adapter/promotion/adapter.d.ts +0 -4
  110. package/lib/model/strategy/adapter/promotion/adapter.js +0 -20
  111. package/lib/model/strategy/adapter/promotion/evaluator.d.ts +0 -17
  112. package/lib/model/strategy/adapter/promotion/evaluator.js +0 -235
  113. package/lib/model/strategy/adapter/promotion/examples.d.ts +0 -86
  114. package/lib/model/strategy/adapter/promotion/examples.js +0 -91
  115. package/lib/model/strategy/adapter/promotion/index.d.ts +1 -1
  116. package/lib/model/strategy/adapter/promotion/index.js +0 -51
  117. package/lib/model/strategy/adapter/promotion/type.d.ts +2 -90
  118. package/lib/model/strategy/adapter/promotion/type.js +0 -2
  119. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +1 -2
  120. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +1 -2
  121. package/lib/modules/Discount/index.d.ts +1 -0
  122. package/lib/modules/Discount/index.js +9 -0
  123. package/lib/modules/Discount/types.d.ts +1 -0
  124. package/lib/modules/Holder/index.d.ts +48 -0
  125. package/lib/modules/Holder/index.js +402 -0
  126. package/lib/modules/Holder/types.d.ts +123 -0
  127. package/lib/modules/Holder/types.js +17 -0
  128. package/lib/modules/Holder/utils.d.ts +13 -0
  129. package/lib/modules/Holder/utils.js +71 -0
  130. package/lib/modules/OpenData/index.d.ts +0 -2
  131. package/lib/modules/OpenData/index.js +1 -6
  132. package/lib/modules/Order/index.d.ts +11 -28
  133. package/lib/modules/Order/index.js +86 -196
  134. package/lib/modules/Order/types.d.ts +10 -33
  135. package/lib/modules/Order/utils/orderCollectionIdentity.js +0 -3
  136. package/lib/modules/Order/utils.d.ts +10 -0
  137. package/lib/modules/Order/utils.js +40 -16
  138. package/lib/modules/Payment/index.d.ts +0 -2
  139. package/lib/modules/Payment/index.js +13 -34
  140. package/lib/modules/Payment/types.d.ts +28 -99
  141. package/lib/modules/Payment/types.js +3 -4
  142. package/lib/modules/Payment/walletpass.d.ts +1 -25
  143. package/lib/modules/Payment/walletpass.js +21 -470
  144. package/lib/modules/Product/types.d.ts +1 -0
  145. package/lib/modules/ProductList/index.js +40 -31
  146. package/lib/modules/Quotation/index.d.ts +1 -1
  147. package/lib/modules/Quotation/index.js +2 -2
  148. package/lib/modules/ResourcePlanner/index.d.ts +24 -0
  149. package/lib/modules/ResourcePlanner/index.js +148 -0
  150. package/lib/modules/ResourcePlanner/planner.d.ts +14 -0
  151. package/lib/modules/ResourcePlanner/planner.js +933 -0
  152. package/lib/modules/ResourcePlanner/types.d.ts +227 -0
  153. package/lib/modules/ResourcePlanner/types.js +17 -0
  154. package/lib/modules/Rules/index.d.ts +0 -1
  155. package/lib/modules/Rules/index.js +40 -47
  156. package/lib/modules/SalesSummary/index.js +6 -7
  157. package/lib/modules/ScanOrderLogger/index.d.ts +2 -0
  158. package/lib/modules/ScanOrderLogger/index.js +13 -1
  159. package/lib/modules/ScanOrderLogger/providers/feishu.js +15 -6
  160. package/lib/modules/ScanOrderLogger/types.d.ts +1 -0
  161. package/lib/modules/Schedule/index.d.ts +3 -1
  162. package/lib/modules/Schedule/index.js +10 -8
  163. package/lib/modules/Summary/utils.js +21 -1
  164. package/lib/modules/index.d.ts +2 -0
  165. package/lib/modules/index.js +5 -1
  166. package/lib/plugins/window.d.ts +1 -0
  167. package/lib/server/index.d.ts +14 -16
  168. package/lib/server/index.js +83 -675
  169. package/lib/server/modules/order/index.d.ts +4 -54
  170. package/lib/server/modules/order/index.js +66 -679
  171. package/lib/server/modules/order/types.d.ts +3 -11
  172. package/lib/solution/BaseSales/index.d.ts +20 -109
  173. package/lib/solution/BaseSales/index.js +70 -881
  174. package/lib/solution/BaseSales/types.d.ts +0 -52
  175. package/lib/solution/BaseSales/types.js +1 -2
  176. package/lib/solution/BaseSales/utils/cartPromotion.d.ts +1 -3
  177. package/lib/solution/BaseSales/utils/cartPromotion.js +12 -63
  178. package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -6
  179. package/lib/solution/BookingByStep/index.d.ts +17 -2
  180. package/lib/solution/BookingByStep/index.js +60 -18
  181. package/lib/solution/BookingByStep/types.d.ts +2 -1
  182. package/lib/solution/BookingByStep/types.js +5 -0
  183. package/lib/solution/BookingByStep/utils/capacity.js +20 -1
  184. package/lib/solution/BookingByStep/utils/timeslots.d.ts +3 -1
  185. package/lib/solution/BookingByStep/utils/timeslots.js +19 -11
  186. package/lib/solution/BookingTicket/index.d.ts +3 -7
  187. package/lib/solution/BookingTicket/index.js +9 -62
  188. package/lib/solution/BookingTicket/utils/addProductDecision.js +0 -4
  189. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +0 -8
  190. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +4 -36
  191. package/lib/solution/Sales/index.d.ts +0 -1
  192. package/lib/solution/Sales/index.js +3 -5
  193. package/lib/solution/ScanOrder/index.d.ts +26 -14
  194. package/lib/solution/ScanOrder/index.js +449 -190
  195. package/lib/solution/ScanOrder/types.d.ts +21 -1
  196. package/lib/solution/ScanOrder/utils.d.ts +8 -0
  197. package/lib/solution/ScanOrder/utils.js +31 -0
  198. package/lib/solution/ShopDiscount/index.d.ts +1 -0
  199. package/lib/solution/ShopDiscount/index.js +14 -0
  200. package/lib/solution/UnifiedBookingSales/index.d.ts +183 -0
  201. package/lib/solution/UnifiedBookingSales/index.js +1076 -0
  202. package/lib/solution/UnifiedBookingSales/types.d.ts +143 -0
  203. package/lib/solution/UnifiedBookingSales/types.js +33 -0
  204. package/lib/solution/VenueBooking/index.d.ts +39 -11
  205. package/lib/solution/VenueBooking/index.js +328 -123
  206. package/lib/solution/VenueBooking/types.d.ts +3 -0
  207. package/lib/solution/VenueBooking/utils/resource.js +1 -0
  208. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
  209. package/lib/solution/VenueBooking/utils/slotMerge.js +6 -4
  210. package/lib/solution/index.d.ts +1 -0
  211. package/lib/solution/index.js +3 -1
  212. package/lib/types/index.d.ts +1 -1
  213. package/package.json +1 -1
  214. package/dist/modules/Order/payment-utils.d.ts +0 -26
  215. package/dist/modules/Order/payment-utils.js +0 -225
  216. package/dist/solution/BookingTicket/utils/weighingProductSku.d.ts +0 -5
  217. package/dist/solution/BookingTicket/utils/weighingProductSku.js +0 -45
  218. package/dist/utils/payment-number.d.ts +0 -9
  219. package/dist/utils/payment-number.js +0 -69
  220. package/lib/modules/Order/payment-utils.d.ts +0 -26
  221. package/lib/modules/Order/payment-utils.js +0 -224
  222. package/lib/solution/BookingTicket/utils/weighingProductSku.d.ts +0 -5
  223. package/lib/solution/BookingTicket/utils/weighingProductSku.js +0 -63
  224. package/lib/utils/payment-number.d.ts +0 -9
  225. 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;
@@ -69,6 +69,7 @@ function buildResourceProductMap(products) {
69
69
  const mapping = {
70
70
  productId: product.id,
71
71
  productTitle: product.title,
72
+ formName: resource.title,
72
73
  resourceName: resource.title,
73
74
  formId: resource.id,
74
75
  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
  * 从一条已合并的订单商品还原出独立的时段列表。
@@ -109,10 +109,12 @@ function buildPriceBreakdown(params) {
109
109
  }
110
110
  function buildVenueResourceMetadata(params) {
111
111
  const { mapping, rawResource } = params;
112
+ const combined = rawResource == null ? void 0 : rawResource.combined_resource;
113
+ const isCombined = !!(combined && combined.status === 1 && Array.isArray(combined.resource_ids));
112
114
  return {
113
- form_name: (rawResource == null ? void 0 : rawResource.form_name) ?? "",
114
- resource_name: (rawResource == null ? void 0 : rawResource.main_field) ?? mapping.resourceName ?? "",
115
- combined_resource: (rawResource == null ? void 0 : rawResource.combined_resource) ?? null
115
+ form_name: mapping.formName ?? mapping.resourceName,
116
+ resource_name: (rawResource == null ? void 0 : rawResource.main_field) ?? mapping.resourceName,
117
+ combined_resource: isCombined ? combined : null
116
118
  };
117
119
  }
118
120
  function buildVenueBookingEntry(params) {
@@ -128,7 +130,7 @@ function buildVenueBookingEntry(params) {
128
130
  form_id: (rawResource == null ? void 0 : rawResource.form_id) ?? mapping.formId,
129
131
  relation_id: resourceId,
130
132
  capacity: 1,
131
- metadata: {}
133
+ metadata: buildVenueResourceMetadata({ mapping, rawResource })
132
134
  };
133
135
  if (childResources && childResources.length) {
134
136
  resourceEntry.children = childResources.map((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';
@@ -26,6 +26,7 @@ __reExport(solution_exports, require("./Sales"), module.exports);
26
26
  __reExport(solution_exports, require("./ScanOrder"), module.exports);
27
27
  __reExport(solution_exports, require("./BaseSales"), module.exports);
28
28
  __reExport(solution_exports, require("./VenueBooking"), module.exports);
29
+ __reExport(solution_exports, require("./UnifiedBookingSales"), module.exports);
29
30
  // Annotate the CommonJS export names for ESM import in node:
30
31
  0 && (module.exports = {
31
32
  ...require("./BuyTickets"),
@@ -37,5 +38,6 @@ __reExport(solution_exports, require("./VenueBooking"), module.exports);
37
38
  ...require("./Sales"),
38
39
  ...require("./ScanOrder"),
39
40
  ...require("./BaseSales"),
40
- ...require("./VenueBooking")
41
+ ...require("./VenueBooking"),
42
+ ...require("./UnifiedBookingSales")
41
43
  });
@@ -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;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.3.38",
4
+ "version": "2.3.39",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -1,26 +0,0 @@
1
- export type OrderPaymentTransactionStatus = 'success' | 'fail';
2
- export interface OrderPaymentTransaction {
3
- number: string;
4
- status: OrderPaymentTransactionStatus;
5
- }
6
- export type OrderPaymentIdentityType = 'order_payment_id' | 'payment_number' | 'unique_payment_number';
7
- export interface OrderPaymentIdentityMatch<T> {
8
- index: number;
9
- payment: T;
10
- matchedBy: OrderPaymentIdentityType;
11
- }
12
- export declare function getOrderPaymentIdentityKeys(payment: unknown): string[];
13
- export declare function isPendingOrderPayment(payment: unknown): boolean;
14
- export declare function isIdentifiedPendingOrderPayment(payment: unknown): boolean;
15
- export declare function hasOrderPaymentIdentityOverlap(left: unknown, right: unknown): boolean;
16
- export declare function resolveOrderPaymentIdentity<T extends Record<string, any>>(payments: T[] | null | undefined, identity: string | number, mode?: 'payment_number' | 'compat'): OrderPaymentIdentityMatch<T> | null;
17
- export declare function ensureOrderPaymentNumber<T extends Record<string, any>>(payment: T, devicePrefix: string, createPaymentNumber: () => string): T & {
18
- payment_number: string;
19
- };
20
- export declare function mergeOrderPaymentTransactions(current: unknown, incoming: unknown): OrderPaymentTransaction[];
21
- export declare function mergeOrderPaymentRecord<T extends Record<string, any>>(payment: T, updates: Record<string, any>): T;
22
- export declare function mergeOrderPaymentSnapshot<T extends Record<string, any>>(current: T, incoming: T): T;
23
- export declare function mergeOrderPaymentListsByIdentity<T extends Record<string, any>>(existing: T[] | null | undefined, incoming: T[] | null | undefined, options?: {
24
- preserveUnmatchedExisting?: boolean;
25
- preserveUnmatchedExistingWhen?: (payment: T) => boolean;
26
- }): T[];
@@ -1,225 +0,0 @@
1
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
8
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
9
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
10
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
11
- function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
12
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
13
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
14
- var PAYMENT_IDENTITY_TYPES = ['payment_number', 'order_payment_id', 'unique_payment_number'];
15
- function normalizePaymentIdentityValue(value) {
16
- if (value === undefined || value === null || value === '') return null;
17
- return String(value);
18
- }
19
- function getPaymentIdentityValue(payment, type) {
20
- if (type === 'unique_payment_number') {
21
- var _payment$metadata;
22
- return payment === null || payment === void 0 || (_payment$metadata = payment.metadata) === null || _payment$metadata === void 0 ? void 0 : _payment$metadata.unique_payment_number;
23
- }
24
- return payment === null || payment === void 0 ? void 0 : payment[type];
25
- }
26
- export function getOrderPaymentIdentityKeys(payment) {
27
- var record = payment;
28
- if (!record) return [];
29
- return PAYMENT_IDENTITY_TYPES.flatMap(function (type) {
30
- var value = normalizePaymentIdentityValue(getPaymentIdentityValue(record, type));
31
- return value === null ? [] : ["".concat(type, ":").concat(value)];
32
- });
33
- }
34
- export function isPendingOrderPayment(payment) {
35
- var record = payment;
36
- return String((record === null || record === void 0 ? void 0 : record.status) || '').toLowerCase() === 'payment_pending';
37
- }
38
- export function isIdentifiedPendingOrderPayment(payment) {
39
- return isPendingOrderPayment(payment) && getOrderPaymentIdentityKeys(payment).length > 0;
40
- }
41
- export function hasOrderPaymentIdentityOverlap(left, right) {
42
- var leftKeys = new Set(getOrderPaymentIdentityKeys(left));
43
- if (leftKeys.size === 0) return false;
44
- return getOrderPaymentIdentityKeys(right).some(function (key) {
45
- return leftKeys.has(key);
46
- });
47
- }
48
- export function resolveOrderPaymentIdentity(payments, identity) {
49
- var mode = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'payment_number';
50
- var target = String(identity);
51
- var identityTypes = mode === 'payment_number' ? ['payment_number'] : PAYMENT_IDENTITY_TYPES;
52
- var matchesByIndex = new Map();
53
- var _iterator = _createForOfIteratorHelper(identityTypes),
54
- _step;
55
- try {
56
- var _loop = function _loop() {
57
- var type = _step.value;
58
- (payments || []).forEach(function (payment, index) {
59
- var value = normalizePaymentIdentityValue(getPaymentIdentityValue(payment, type));
60
- if (value === target && !matchesByIndex.has(index)) {
61
- matchesByIndex.set(index, {
62
- index: index,
63
- payment: payment,
64
- matchedBy: type
65
- });
66
- }
67
- });
68
- };
69
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
70
- _loop();
71
- }
72
- } catch (err) {
73
- _iterator.e(err);
74
- } finally {
75
- _iterator.f();
76
- }
77
- var matches = _toConsumableArray(matchesByIndex.values());
78
- if (matches.length > 1) {
79
- throw new Error("\u652F\u4ED8\u9879\u8EAB\u4EFD\u5B58\u5728\u6B67\u4E49: ".concat(target));
80
- }
81
- return matches[0] || null;
82
- }
83
- export function ensureOrderPaymentNumber(payment, devicePrefix, createPaymentNumber) {
84
- var existing = normalizePaymentIdentityValue(payment.payment_number);
85
- if (existing) return _objectSpread(_objectSpread({}, payment), {}, {
86
- payment_number: existing
87
- });
88
- var uuid = normalizePaymentIdentityValue(payment.uuid) || createPaymentNumber();
89
- var prefix = normalizePaymentIdentityValue(devicePrefix) || 'LOCAL';
90
- // TODO: 使用 ID Generator 替换当前 UUID 段生成器。
91
- return _objectSpread(_objectSpread({}, payment), {}, {
92
- payment_number: "".concat(prefix, "_").concat(uuid)
93
- });
94
- }
95
- export function mergeOrderPaymentTransactions(current, incoming) {
96
- var records = new Map();
97
- var append = function append(value) {
98
- if (!Array.isArray(value)) return;
99
- value.forEach(function (item) {
100
- var number = item && _typeof(item) === 'object' ? String(item.number || '') : '';
101
- var status = item && _typeof(item) === 'object' ? item.status : undefined;
102
- if (!number || status !== 'success' && status !== 'fail') return;
103
- var previous = records.get(number);
104
- if ((previous === null || previous === void 0 ? void 0 : previous.status) === 'success' && status === 'fail') return;
105
- records.set(number, {
106
- number: number,
107
- status: status
108
- });
109
- });
110
- };
111
- append(current);
112
- append(incoming);
113
- return _toConsumableArray(records.values());
114
- }
115
- export function mergeOrderPaymentRecord(payment, updates) {
116
- var _updates$status, _updates$updated_at;
117
- var currentMetadata = payment.metadata || {};
118
- var incomingMetadata = updates.metadata || {};
119
- var transactions = mergeOrderPaymentTransactions(currentMetadata.transactions, incomingMetadata.transactions);
120
- var currentPaid = payment.status === 'paid';
121
- var nextStatus = currentPaid && updates.status !== 'paid' ? 'paid' : (_updates$status = updates.status) !== null && _updates$status !== void 0 ? _updates$status : payment.status;
122
- return _objectSpread(_objectSpread(_objectSpread({}, payment), updates), {}, {
123
- status: nextStatus,
124
- updated_at: (_updates$updated_at = updates.updated_at) !== null && _updates$updated_at !== void 0 ? _updates$updated_at : payment.updated_at,
125
- metadata: _objectSpread(_objectSpread(_objectSpread({}, currentMetadata), incomingMetadata), transactions.length > 0 || Array.isArray(incomingMetadata.transactions) ? {
126
- transactions: transactions
127
- } : {})
128
- });
129
- }
130
- export function mergeOrderPaymentSnapshot(current, incoming) {
131
- var currentMetadata = current.metadata || {};
132
- var incomingMetadata = incoming.metadata || {};
133
- var currentUniquePaymentNumber = normalizePaymentIdentityValue(currentMetadata.unique_payment_number);
134
- var incomingUniquePaymentNumber = normalizePaymentIdentityValue(incomingMetadata.unique_payment_number);
135
- var incomingOrderPaymentId = normalizePaymentIdentityValue(incoming.order_payment_id);
136
- var incomingFallbackPrefix = incomingOrderPaymentId ? "os-fallback:payment:order-payment:".concat(incomingOrderPaymentId) : null;
137
- var incomingUsesDerivedUniquePaymentNumber = Boolean(incomingUniquePaymentNumber && incomingFallbackPrefix && (incomingUniquePaymentNumber === incomingFallbackPrefix || incomingUniquePaymentNumber.startsWith("".concat(incomingFallbackPrefix, ":conflict:"))));
138
- var transactions = mergeOrderPaymentTransactions(currentMetadata.transactions, incomingMetadata.transactions);
139
- return _objectSpread(_objectSpread(_objectSpread({}, current), incoming), {}, {
140
- order_payment_id: normalizePaymentIdentityValue(incoming.order_payment_id) !== null ? incoming.order_payment_id : current.order_payment_id,
141
- payment_number: incoming.payment_number || current.payment_number,
142
- metadata: _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, currentMetadata), incomingMetadata), incomingUsesDerivedUniquePaymentNumber && currentUniquePaymentNumber ? {
143
- unique_payment_number: currentUniquePaymentNumber
144
- } : {}), transactions.length > 0 ? {
145
- transactions: transactions
146
- } : {})
147
- });
148
- }
149
- function compactOrderPaymentList(payments) {
150
- var result = [];
151
- var _iterator2 = _createForOfIteratorHelper(payments),
152
- _step2;
153
- try {
154
- var _loop2 = function _loop2() {
155
- var payment = _step2.value;
156
- var matchingIndexes = result.flatMap(function (existing, index) {
157
- return hasOrderPaymentIdentityOverlap(existing, payment) ? [index] : [];
158
- });
159
- if (matchingIndexes.length === 0) {
160
- result.push(mergeOrderPaymentSnapshot({}, payment));
161
- return 1; // continue
162
- }
163
- var firstIndex = matchingIndexes[0];
164
- var merged = result[firstIndex];
165
- var _iterator3 = _createForOfIteratorHelper(matchingIndexes.slice(1)),
166
- _step3;
167
- try {
168
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
169
- var index = _step3.value;
170
- merged = mergeOrderPaymentSnapshot(merged, result[index]);
171
- }
172
- } catch (err) {
173
- _iterator3.e(err);
174
- } finally {
175
- _iterator3.f();
176
- }
177
- result[firstIndex] = mergeOrderPaymentSnapshot(merged, payment);
178
- var _iterator4 = _createForOfIteratorHelper(matchingIndexes.slice(1).sort(function (a, b) {
179
- return b - a;
180
- })),
181
- _step4;
182
- try {
183
- for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
184
- var _index = _step4.value;
185
- result.splice(_index, 1);
186
- }
187
- } catch (err) {
188
- _iterator4.e(err);
189
- } finally {
190
- _iterator4.f();
191
- }
192
- };
193
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
194
- if (_loop2()) continue;
195
- }
196
- } catch (err) {
197
- _iterator2.e(err);
198
- } finally {
199
- _iterator2.f();
200
- }
201
- return result;
202
- }
203
- export function mergeOrderPaymentListsByIdentity(existing, incoming) {
204
- var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
205
- var existingList = compactOrderPaymentList(_toConsumableArray(existing || []));
206
- var incomingList = compactOrderPaymentList(_toConsumableArray(incoming || []));
207
- if (options.preserveUnmatchedExisting) {
208
- return compactOrderPaymentList([].concat(_toConsumableArray(existingList), _toConsumableArray(incomingList)));
209
- }
210
- var mergedIncoming = incomingList.map(function (incomingPayment) {
211
- var matchingExisting = existingList.filter(function (existingPayment) {
212
- return hasOrderPaymentIdentityOverlap(existingPayment, incomingPayment);
213
- });
214
- return matchingExisting.reduce(function (merged, existingPayment) {
215
- return mergeOrderPaymentSnapshot(existingPayment, merged);
216
- }, incomingPayment);
217
- });
218
- var preservedExisting = options.preserveUnmatchedExistingWhen ? existingList.filter(function (existingPayment) {
219
- var _options$preserveUnma;
220
- return !incomingList.some(function (incomingPayment) {
221
- return hasOrderPaymentIdentityOverlap(existingPayment, incomingPayment);
222
- }) && ((_options$preserveUnma = options.preserveUnmatchedExistingWhen) === null || _options$preserveUnma === void 0 ? void 0 : _options$preserveUnma.call(options, existingPayment));
223
- }) : [];
224
- return compactOrderPaymentList([].concat(_toConsumableArray(mergedIncoming), _toConsumableArray(preservedExisting)));
225
- }
@@ -1,5 +0,0 @@
1
- /**
2
- * 将规格弹窗的称重结果写入订单行权威字段 product_sku。
3
- * 商品目录已有的 SKU 字段会保留,本次称重结果只覆盖运行态称重字段。
4
- */
5
- export declare function buildProductSkuFromCacheItem(cacheItem: Record<string, any> | null | undefined): Record<string, any> | undefined;
@@ -1,45 +0,0 @@
1
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
2
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
3
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
5
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
6
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
7
- var WEIGHT_UNIT_MAP = {
8
- KILOGRAMS: 'kg',
9
- GRAMS: 'g',
10
- POUNDS: 'lb',
11
- OUNCES: 'oz'
12
- };
13
- function isRecord(value) {
14
- return Boolean(value) && _typeof(value) === 'object' && !Array.isArray(value);
15
- }
16
-
17
- /**
18
- * 将规格弹窗的称重结果写入订单行权威字段 product_sku。
19
- * 商品目录已有的 SKU 字段会保留,本次称重结果只覆盖运行态称重字段。
20
- */
21
- export function buildProductSkuFromCacheItem(cacheItem) {
22
- var _cacheItem$_extend, _cacheItem$_extend2, _weighing$unit_weight, _weighing$tare$label, _weighing$tare, _weighing$tare$value, _weighing$tare2, _weighing$weight, _weighing$net_weight;
23
- var currentSku = isRecord(cacheItem === null || cacheItem === void 0 ? void 0 : cacheItem.product_sku) ? cacheItem.product_sku : undefined;
24
- var weighing = isRecord(cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend = cacheItem._extend) === null || _cacheItem$_extend === void 0 ? void 0 : _cacheItem$_extend.weighing) ? cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend2 = cacheItem._extend) === null || _cacheItem$_extend2 === void 0 ? void 0 : _cacheItem$_extend2.weighing : undefined;
25
- var hasRuntimeWeighingSku = Number((currentSku === null || currentSku === void 0 ? void 0 : currentSku.open_sold_weight) || 0) === 1 && ((currentSku === null || currentSku === void 0 ? void 0 : currentSku.weight) !== undefined || (currentSku === null || currentSku === void 0 ? void 0 : currentSku.net_weight) !== undefined || (currentSku === null || currentSku === void 0 ? void 0 : currentSku.weight_source) !== undefined);
26
- var isWeighingSku = Number((currentSku === null || currentSku === void 0 ? void 0 : currentSku.open_sold_weight) || 0) === 1;
27
-
28
- // 普通商品维持旧转换行为,不把目录侧完整 SKU 引入订单行。
29
- if (!isWeighingSku && !weighing) return undefined;
30
- // 新版 SkuDetailModal 已直接生成 product_sku;_extend.weighing 只作为旧调用方回退。
31
- if (hasRuntimeWeighingSku) return _objectSpread({}, currentSku);
32
- if (!weighing) return currentSku ? _objectSpread({}, currentSku) : undefined;
33
- return _objectSpread(_objectSpread({}, currentSku || {}), {}, {
34
- open_sold_weight: 1,
35
- unit_data_snapshot: weighing.scalePriceProduct,
36
- unit: WEIGHT_UNIT_MAP[String(weighing.unit)] || weighing.unit,
37
- unit_weight: (_weighing$unit_weight = weighing.unit_weight) !== null && _weighing$unit_weight !== void 0 ? _weighing$unit_weight : '1.000',
38
- unit_price: weighing.unit_price,
39
- weight_source: weighing.mode,
40
- tare_name: (_weighing$tare$label = (_weighing$tare = weighing.tare) === null || _weighing$tare === void 0 ? void 0 : _weighing$tare.label) !== null && _weighing$tare$label !== void 0 ? _weighing$tare$label : '',
41
- tare_weight: (_weighing$tare$value = (_weighing$tare2 = weighing.tare) === null || _weighing$tare2 === void 0 ? void 0 : _weighing$tare2.value) !== null && _weighing$tare$value !== void 0 ? _weighing$tare$value : 0,
42
- weight: (_weighing$weight = weighing.weight) !== null && _weighing$weight !== void 0 ? _weighing$weight : 0,
43
- net_weight: (_weighing$net_weight = weighing.net_weight) !== null && _weighing$net_weight !== void 0 ? _weighing$net_weight : 0
44
- });
45
- }
@@ -1,9 +0,0 @@
1
- export type PaymentNumberAppDataGetter = (key: string) => unknown;
2
- /**
3
- * Resolve the synchronous fallback without caching runtime device data.
4
- */
5
- export declare function resolvePaymentNumberDevicePrefixFromDeviceId(getAppData: PaymentNumberAppDataGetter): string;
6
- /**
7
- * Resolve the latest device segment when a new payment number is generated.
8
- */
9
- export declare function resolvePaymentNumberDevicePrefix(getAppData: PaymentNumberAppDataGetter): Promise<string>;
@@ -1,69 +0,0 @@
1
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
3
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
4
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
5
- function normalizeNonEmptyString(value) {
6
- if (value === undefined || value === null) return null;
7
- if (typeof value !== 'string' && typeof value !== 'number') return null;
8
- if (typeof value === 'number' && !Number.isFinite(value)) return null;
9
- var normalized = String(value).trim();
10
- return normalized || null;
11
- }
12
-
13
- /**
14
- * Resolve the synchronous fallback without caching runtime device data.
15
- */
16
- export function resolvePaymentNumberDevicePrefixFromDeviceId(getAppData) {
17
- try {
18
- var deviceId = normalizeNonEmptyString(getAppData('device_id'));
19
- if (deviceId && deviceId !== '0') return deviceId.slice(-2);
20
- } catch (_unused) {
21
- // The stable LOCAL prefix is the final fallback.
22
- }
23
- return 'LOCAL';
24
- }
25
-
26
- /**
27
- * Resolve the latest device segment when a new payment number is generated.
28
- */
29
- export function resolvePaymentNumberDevicePrefix(_x) {
30
- return _resolvePaymentNumberDevicePrefix.apply(this, arguments);
31
- }
32
- function _resolvePaymentNumberDevicePrefix() {
33
- _resolvePaymentNumberDevicePrefix = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(getAppData) {
34
- var getAsyncIotDeviceInfo, info, shortNumber;
35
- return _regeneratorRuntime().wrap(function _callee$(_context) {
36
- while (1) switch (_context.prev = _context.next) {
37
- case 0:
38
- _context.prev = 0;
39
- getAsyncIotDeviceInfo = getAppData('async_iot_device_info');
40
- if (!(typeof getAsyncIotDeviceInfo === 'function')) {
41
- _context.next = 9;
42
- break;
43
- }
44
- _context.next = 5;
45
- return getAsyncIotDeviceInfo();
46
- case 5:
47
- info = _context.sent;
48
- shortNumber = normalizeNonEmptyString(info === null || info === void 0 ? void 0 : info.short_number);
49
- if (!(shortNumber && shortNumber !== '0')) {
50
- _context.next = 9;
51
- break;
52
- }
53
- return _context.abrupt("return", shortNumber);
54
- case 9:
55
- _context.next = 13;
56
- break;
57
- case 11:
58
- _context.prev = 11;
59
- _context.t0 = _context["catch"](0);
60
- case 13:
61
- return _context.abrupt("return", resolvePaymentNumberDevicePrefixFromDeviceId(getAppData));
62
- case 14:
63
- case "end":
64
- return _context.stop();
65
- }
66
- }, _callee, null, [[0, 11]]);
67
- }));
68
- return _resolvePaymentNumberDevicePrefix.apply(this, arguments);
69
- }
@@ -1,26 +0,0 @@
1
- export type OrderPaymentTransactionStatus = 'success' | 'fail';
2
- export interface OrderPaymentTransaction {
3
- number: string;
4
- status: OrderPaymentTransactionStatus;
5
- }
6
- export type OrderPaymentIdentityType = 'order_payment_id' | 'payment_number' | 'unique_payment_number';
7
- export interface OrderPaymentIdentityMatch<T> {
8
- index: number;
9
- payment: T;
10
- matchedBy: OrderPaymentIdentityType;
11
- }
12
- export declare function getOrderPaymentIdentityKeys(payment: unknown): string[];
13
- export declare function isPendingOrderPayment(payment: unknown): boolean;
14
- export declare function isIdentifiedPendingOrderPayment(payment: unknown): boolean;
15
- export declare function hasOrderPaymentIdentityOverlap(left: unknown, right: unknown): boolean;
16
- export declare function resolveOrderPaymentIdentity<T extends Record<string, any>>(payments: T[] | null | undefined, identity: string | number, mode?: 'payment_number' | 'compat'): OrderPaymentIdentityMatch<T> | null;
17
- export declare function ensureOrderPaymentNumber<T extends Record<string, any>>(payment: T, devicePrefix: string, createPaymentNumber: () => string): T & {
18
- payment_number: string;
19
- };
20
- export declare function mergeOrderPaymentTransactions(current: unknown, incoming: unknown): OrderPaymentTransaction[];
21
- export declare function mergeOrderPaymentRecord<T extends Record<string, any>>(payment: T, updates: Record<string, any>): T;
22
- export declare function mergeOrderPaymentSnapshot<T extends Record<string, any>>(current: T, incoming: T): T;
23
- export declare function mergeOrderPaymentListsByIdentity<T extends Record<string, any>>(existing: T[] | null | undefined, incoming: T[] | null | undefined, options?: {
24
- preserveUnmatchedExisting?: boolean;
25
- preserveUnmatchedExistingWhen?: (payment: T) => boolean;
26
- }): T[];