@pisell/pisellos 2.2.277 → 2.2.800

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 (127) hide show
  1. package/dist/core/index.d.ts +0 -2
  2. package/dist/core/index.js +1 -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/index.js +0 -9
  11. package/dist/model/strategy/adapter/promotion/type.d.ts +2 -90
  12. package/dist/model/strategy/adapter/promotion/type.js +0 -45
  13. package/dist/model/strategy/adapter/walletPass/evaluator.js +2 -0
  14. package/dist/model/strategy/adapter/walletPass/type.d.ts +0 -5
  15. package/dist/model/strategy/adapter/walletPass/utils.js +26 -57
  16. package/dist/modules/OpenData/index.d.ts +0 -2
  17. package/dist/modules/OpenData/index.js +0 -8
  18. package/dist/modules/Order/index.d.ts +8 -28
  19. package/dist/modules/Order/index.js +496 -808
  20. package/dist/modules/Order/types.d.ts +1 -35
  21. package/dist/modules/Order/utils/orderCollectionIdentity.js +2 -7
  22. package/dist/modules/Order/utils.js +6 -10
  23. package/dist/modules/Payment/index.d.ts +0 -2
  24. package/dist/modules/Payment/index.js +49 -78
  25. package/dist/modules/Payment/types.d.ts +25 -106
  26. package/dist/modules/Payment/types.js +0 -17
  27. package/dist/modules/Payment/utils.js +1 -4
  28. package/dist/modules/Payment/walletpass.d.ts +1 -49
  29. package/dist/modules/Payment/walletpass.js +124 -1081
  30. package/dist/modules/Rules/index.d.ts +0 -3
  31. package/dist/modules/Rules/index.js +70 -100
  32. package/dist/server/index.d.ts +0 -25
  33. package/dist/server/index.js +1069 -2001
  34. package/dist/server/modules/index.d.ts +1 -1
  35. package/dist/server/modules/order/index.d.ts +4 -70
  36. package/dist/server/modules/order/index.js +728 -1816
  37. package/dist/server/modules/order/types.d.ts +3 -25
  38. package/dist/server/modules/order/types.js +1 -7
  39. package/dist/server/utils/small-ticket.js +2 -1
  40. package/dist/solution/BaseSales/index.d.ts +5 -109
  41. package/dist/solution/BaseSales/index.js +436 -1802
  42. package/dist/solution/BaseSales/types.d.ts +1 -55
  43. package/dist/solution/BaseSales/types.js +1 -2
  44. package/dist/solution/BaseSales/utils/cartPromotion.d.ts +1 -3
  45. package/dist/solution/BaseSales/utils/cartPromotion.js +31 -90
  46. package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -6
  47. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +4 -7
  48. package/dist/solution/BookingByStep/index.d.ts +1 -1
  49. package/dist/solution/BookingTicket/index.d.ts +5 -21
  50. package/dist/solution/BookingTicket/index.js +56 -139
  51. package/dist/solution/BookingTicket/types.d.ts +0 -1
  52. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +0 -8
  53. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +83 -173
  54. package/dist/solution/Sales/index.d.ts +0 -2
  55. package/dist/solution/Sales/index.js +4 -26
  56. package/dist/solution/ScanOrder/index.js +20 -31
  57. package/dist/solution/VenueBooking/index.d.ts +0 -1
  58. package/dist/solution/VenueBooking/index.js +19 -30
  59. package/dist/types/index.d.ts +0 -1
  60. package/lib/core/index.d.ts +0 -2
  61. package/lib/core/index.js +1 -4
  62. package/lib/model/strategy/adapter/promotion/adapter.d.ts +0 -4
  63. package/lib/model/strategy/adapter/promotion/adapter.js +0 -20
  64. package/lib/model/strategy/adapter/promotion/evaluator.d.ts +0 -17
  65. package/lib/model/strategy/adapter/promotion/evaluator.js +0 -235
  66. package/lib/model/strategy/adapter/promotion/examples.d.ts +0 -86
  67. package/lib/model/strategy/adapter/promotion/examples.js +0 -91
  68. package/lib/model/strategy/adapter/promotion/index.d.ts +1 -1
  69. package/lib/model/strategy/adapter/promotion/index.js +49 -0
  70. package/lib/model/strategy/adapter/promotion/type.d.ts +2 -90
  71. package/lib/model/strategy/adapter/promotion/type.js +0 -2
  72. package/lib/model/strategy/adapter/walletPass/evaluator.js +2 -0
  73. package/lib/model/strategy/adapter/walletPass/type.d.ts +0 -5
  74. package/lib/model/strategy/adapter/walletPass/utils.js +11 -62
  75. package/lib/modules/OpenData/index.d.ts +0 -2
  76. package/lib/modules/OpenData/index.js +0 -5
  77. package/lib/modules/Order/index.d.ts +8 -28
  78. package/lib/modules/Order/index.js +69 -231
  79. package/lib/modules/Order/types.d.ts +1 -35
  80. package/lib/modules/Order/utils/orderCollectionIdentity.js +0 -3
  81. package/lib/modules/Order/utils.js +4 -11
  82. package/lib/modules/Payment/index.d.ts +0 -2
  83. package/lib/modules/Payment/index.js +12 -33
  84. package/lib/modules/Payment/types.d.ts +25 -106
  85. package/lib/modules/Payment/types.js +0 -1
  86. package/lib/modules/Payment/utils.js +1 -5
  87. package/lib/modules/Payment/walletpass.d.ts +1 -49
  88. package/lib/modules/Payment/walletpass.js +22 -898
  89. package/lib/modules/Rules/index.d.ts +0 -3
  90. package/lib/modules/Rules/index.js +9 -38
  91. package/lib/server/index.d.ts +0 -25
  92. package/lib/server/index.js +31 -726
  93. package/lib/server/modules/index.d.ts +1 -1
  94. package/lib/server/modules/order/index.d.ts +4 -70
  95. package/lib/server/modules/order/index.js +69 -818
  96. package/lib/server/modules/order/types.d.ts +3 -25
  97. package/lib/server/modules/order/types.js +0 -1
  98. package/lib/server/utils/small-ticket.js +1 -1
  99. package/lib/solution/BaseSales/index.d.ts +5 -109
  100. package/lib/solution/BaseSales/index.js +27 -874
  101. package/lib/solution/BaseSales/types.d.ts +1 -55
  102. package/lib/solution/BaseSales/types.js +1 -2
  103. package/lib/solution/BaseSales/utils/cartPromotion.d.ts +1 -3
  104. package/lib/solution/BaseSales/utils/cartPromotion.js +12 -63
  105. package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -6
  106. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +3 -4
  107. package/lib/solution/BookingByStep/index.d.ts +1 -1
  108. package/lib/solution/BookingTicket/index.d.ts +5 -21
  109. package/lib/solution/BookingTicket/index.js +13 -64
  110. package/lib/solution/BookingTicket/types.d.ts +0 -1
  111. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +0 -8
  112. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +5 -37
  113. package/lib/solution/Sales/index.d.ts +0 -2
  114. package/lib/solution/Sales/index.js +6 -20
  115. package/lib/solution/ScanOrder/index.js +0 -8
  116. package/lib/solution/VenueBooking/index.d.ts +0 -1
  117. package/lib/solution/VenueBooking/index.js +0 -8
  118. package/lib/types/index.d.ts +0 -1
  119. package/package.json +1 -1
  120. package/dist/modules/Order/payment-utils.d.ts +0 -26
  121. package/dist/modules/Order/payment-utils.js +0 -225
  122. package/dist/utils/payment-number.d.ts +0 -9
  123. package/dist/utils/payment-number.js +0 -69
  124. package/lib/modules/Order/payment-utils.d.ts +0 -26
  125. package/lib/modules/Order/payment-utils.js +0 -224
  126. package/lib/utils/payment-number.d.ts +0 -9
  127. package/lib/utils/payment-number.js +0 -64
@@ -39,7 +39,6 @@ var import_dayjs = __toESM(require("dayjs"));
39
39
  var import_BaseModule = require("../../modules/BaseModule");
40
40
  var import_types = require("./types");
41
41
  __reExport(Sales_exports, require("./types"), module.exports);
42
- var UNPAID_PAYMENT_STATUSES = /* @__PURE__ */ new Set(["unpaid", "partially_paid", "payment_processing"]);
43
42
  var SalesImpl = class extends import_BaseModule.BaseModule {
44
43
  // LoggerManager 实例
45
44
  constructor(name, version) {
@@ -259,9 +258,6 @@ var SalesImpl = class extends import_BaseModule.BaseModule {
259
258
  var _a;
260
259
  return String(((_a = booking.order) == null ? void 0 : _a.payment_status) ?? "");
261
260
  }
262
- isUnpaidBooking(booking) {
263
- return UNPAID_PAYMENT_STATUSES.has(this.getBookingOrderPaymentStatus(booking));
264
- }
265
261
  countBookingOrders(bookings) {
266
262
  const orderIds = /* @__PURE__ */ new Set();
267
263
  bookings.forEach((booking) => {
@@ -316,9 +312,8 @@ var SalesImpl = class extends import_BaseModule.BaseModule {
316
312
  * 2) 若无 active,返回已超时且仍占用中的预约(允许并发多条)
317
313
  * 3) 若仍无,返回最近一组未来预约(同 start_time 的并发预约全部返回)
318
314
  * 4) 最后兜底返回一条(避免资源有历史预约时完全无反馈)
319
- * - includeAllFuture 时,保留选中预约并返回当天全部后续预约;仅详情接口启用。
320
315
  */
321
- pickBookingsForCurrentPoint(current, bookings, options = {}) {
316
+ pickBookingsForCurrentPoint(current, bookings) {
322
317
  if (bookings.length === 0)
323
318
  return [];
324
319
  const currentDayStart = current.startOf("day");
@@ -335,13 +330,6 @@ var SalesImpl = class extends import_BaseModule.BaseModule {
335
330
  const appendNextStartGroupIfNeeded = (selectedBookings) => {
336
331
  if (selectedBookings.length === 0)
337
332
  return selectedBookings;
338
- if (options.includeAllFuture) {
339
- const allFutureBookings = dayScopedBookings.filter((booking) => {
340
- const startAt = this.toBookingDateTime(booking.start_date, booking.start_time);
341
- return startAt.isValid() && startAt.isAfter(current);
342
- });
343
- return [...selectedBookings, ...allFutureBookings];
344
- }
345
333
  const shouldAppendNextGroup = selectedBookings.some(
346
334
  (booking) => booking.status === "reserved" || booking.status === "occupied"
347
335
  );
@@ -392,8 +380,6 @@ var SalesImpl = class extends import_BaseModule.BaseModule {
392
380
  return startAt.isValid() && startAt.isAfter(current) && startAt.isSame(current, "day");
393
381
  });
394
382
  if (upcoming.length > 0) {
395
- if (options.includeAllFuture)
396
- return upcoming;
397
383
  const firstStartAt = this.toBookingDateTime(upcoming[0].start_date, upcoming[0].start_time).valueOf();
398
384
  const upcomingStartGroup = upcoming.filter((booking) => {
399
385
  const startAt = this.toBookingDateTime(booking.start_date, booking.start_time);
@@ -645,11 +631,12 @@ var SalesImpl = class extends import_BaseModule.BaseModule {
645
631
  const completedBookingList = matchedBookingList.filter(
646
632
  (booking) => this.getBookingAppointmentStatus(booking) === "completed"
647
633
  );
648
- const unpaidBookingList = matchedBookingList.filter((booking) => this.isUnpaidBooking(booking));
634
+ const unpaidBookingList = matchedBookingList.filter(
635
+ (booking) => this.getBookingOrderPaymentStatus(booking) === "unpaid" || this.getBookingOrderPaymentStatus(booking) === "payment_processing"
636
+ );
649
637
  const bookings = this.pickBookingsForCurrentPoint(
650
638
  current,
651
- this.normalizeResourceBookings(current, deviceCurrent, matchedBookingList),
652
- { includeAllFuture: true }
639
+ this.normalizeResourceBookings(current, deviceCurrent, matchedBookingList)
653
640
  );
654
641
  const completedBookings = completedBookingList.map((booking) => {
655
642
  return {
@@ -665,8 +652,7 @@ var SalesImpl = class extends import_BaseModule.BaseModule {
665
652
  });
666
653
  const unpaidBookings = this.pickBookingsForCurrentPoint(
667
654
  current,
668
- this.normalizeResourceBookings(current, deviceCurrent, unpaidBookingList),
669
- { includeAllFuture: true }
655
+ this.normalizeResourceBookings(current, deviceCurrent, unpaidBookingList)
670
656
  );
671
657
  const orderCount = this.countBookingOrders(statsBookingList);
672
658
  const bookingCount = statsBookingList.length;
@@ -48,10 +48,6 @@ var import_utils2 = require("../../modules/Order/utils");
48
48
  var import_dayjs = __toESM(require("dayjs"));
49
49
  var import_itemRule = require("../../model/strategy/adapter/itemRule");
50
50
  __reExport(ScanOrder_exports, require("./types"), module.exports);
51
- function isItemRewardProductDiscount(discount) {
52
- var _a, _b;
53
- return (discount == null ? void 0 : discount.type) === "product" && ((_a = discount == null ? void 0 : discount.metadata) == null ? void 0 : _a.source) === "promotion" && ((_b = discount == null ? void 0 : discount.metadata) == null ? void 0 : _b.actionType) === "ITEM_REWARD";
54
- }
55
51
  var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
56
52
  constructor(name, version) {
57
53
  super(name, version);
@@ -746,10 +742,6 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
746
742
  for (const product of tempOrder.products) {
747
743
  if ((_c = product._origin) == null ? void 0 : _c.isManualDiscount)
748
744
  continue;
749
- if ((product.discount_list || []).some(isItemRewardProductDiscount)) {
750
- product.discount_list = (product.discount_list || []).filter(isItemRewardProductDiscount);
751
- continue;
752
- }
753
745
  product.discount_list = (product.discount_list || []).filter((pd) => {
754
746
  var _a2;
755
747
  const rid = ((_a2 = pd.discount) == null ? void 0 : _a2.resource_id) ?? pd.id;
@@ -152,7 +152,6 @@ export declare class VenueBookingImpl extends BaseModule implements Module {
152
152
  private recalculateOrderPricesFromQuotation;
153
153
  scanCode(code: string, customerId?: number): Promise<{
154
154
  isAvailable: boolean;
155
- isAccepted?: boolean | undefined;
156
155
  discountList: import("../../modules/Discount").Discount[];
157
156
  type: "server" | "clientCalc";
158
157
  unavailableReason?: import("../../modules/Rules/types").UnavailableReason | undefined;
@@ -65,10 +65,6 @@ var OPEN_DATA_SECTION_CODES = [
65
65
  "workflow",
66
66
  "checkout"
67
67
  ];
68
- function isItemRewardProductDiscount(discount) {
69
- var _a, _b;
70
- return (discount == null ? void 0 : discount.type) === "product" && ((_a = discount == null ? void 0 : discount.metadata) == null ? void 0 : _a.source) === "promotion" && ((_b = discount == null ? void 0 : discount.metadata) == null ? void 0 : _b.actionType) === "ITEM_REWARD";
71
- }
72
68
  function cloneCustomDepositData(customDepositData) {
73
69
  if (!customDepositData || typeof customDepositData !== "object")
74
70
  return void 0;
@@ -1343,10 +1339,6 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
1343
1339
  for (const product of tempOrder.products) {
1344
1340
  if ((_c = product._origin) == null ? void 0 : _c.isManualDiscount)
1345
1341
  continue;
1346
- if ((product.discount_list || []).some(isItemRewardProductDiscount)) {
1347
- product.discount_list = (product.discount_list || []).filter(isItemRewardProductDiscount);
1348
- continue;
1349
- }
1350
1342
  product.discount_list = (product.discount_list || []).filter((pd) => {
1351
1343
  var _a2;
1352
1344
  const rid = ((_a2 = pd.discount) == null ? void 0 : _a2.resource_id) ?? pd.id;
@@ -47,7 +47,6 @@ export interface PisellCore {
47
47
  getModule: <T extends Module>(name: string) => T | null;
48
48
  getModuleExports: <T = any>(name: string) => T | null;
49
49
  hasModule: (name: string) => boolean;
50
- getModuleNames: () => string[];
51
50
  effects: {
52
51
  on: (event: string, callback: (payload: any) => void) => () => void;
53
52
  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.2.277",
4
+ "version": "2.2.800",
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,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[];