@pisell/pisellos 2.2.266 → 2.2.267

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 (93) hide show
  1. package/dist/model/strategy/adapter/promotion/adapter.d.ts +0 -4
  2. package/dist/model/strategy/adapter/promotion/adapter.js +0 -23
  3. package/dist/model/strategy/adapter/promotion/evaluator.d.ts +0 -17
  4. package/dist/model/strategy/adapter/promotion/evaluator.js +6 -279
  5. package/dist/model/strategy/adapter/promotion/examples.d.ts +0 -86
  6. package/dist/model/strategy/adapter/promotion/examples.js +0 -99
  7. package/dist/model/strategy/adapter/promotion/index.d.ts +1 -1
  8. package/dist/model/strategy/adapter/promotion/type.d.ts +2 -90
  9. package/dist/model/strategy/adapter/promotion/type.js +0 -45
  10. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +5 -3
  11. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +6 -3
  12. package/dist/modules/Order/index.d.ts +8 -27
  13. package/dist/modules/Order/index.js +493 -753
  14. package/dist/modules/Order/types.d.ts +1 -33
  15. package/dist/modules/Order/utils/orderCollectionIdentity.js +2 -7
  16. package/dist/modules/Order/utils.js +6 -10
  17. package/dist/modules/Payment/index.d.ts +0 -2
  18. package/dist/modules/Payment/index.js +50 -79
  19. package/dist/modules/Payment/types.d.ts +27 -29
  20. package/dist/modules/Payment/types.js +3 -5
  21. package/dist/modules/Rules/index.d.ts +0 -1
  22. package/dist/modules/Rules/index.js +14 -34
  23. package/dist/server/index.d.ts +0 -16
  24. package/dist/server/index.js +1036 -1933
  25. package/dist/server/modules/order/index.d.ts +4 -49
  26. package/dist/server/modules/order/index.js +695 -1574
  27. package/dist/server/modules/order/types.d.ts +3 -11
  28. package/dist/server/modules/order/types.js +1 -1
  29. package/dist/solution/BaseSales/index.d.ts +11 -55
  30. package/dist/solution/BaseSales/index.js +396 -711
  31. package/dist/solution/BaseSales/utils/cartPromotion.d.ts +1 -3
  32. package/dist/solution/BaseSales/utils/cartPromotion.js +36 -93
  33. package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -6
  34. package/dist/solution/BookingTicket/index.d.ts +1 -1
  35. package/dist/solution/BookingTicket/index.js +29 -35
  36. package/dist/solution/BookingTicket/utils/addProductDecision.js +6 -0
  37. package/dist/solution/BookingTicket/utils/weighingProductSku.d.ts +5 -0
  38. package/dist/solution/BookingTicket/utils/weighingProductSku.js +45 -0
  39. package/dist/solution/Sales/index.d.ts +0 -1
  40. package/dist/solution/Sales/index.js +2 -10
  41. package/dist/solution/ScanOrder/index.js +20 -31
  42. package/dist/solution/VenueBooking/index.js +19 -30
  43. package/lib/model/strategy/adapter/promotion/adapter.d.ts +0 -4
  44. package/lib/model/strategy/adapter/promotion/adapter.js +0 -20
  45. package/lib/model/strategy/adapter/promotion/evaluator.d.ts +0 -17
  46. package/lib/model/strategy/adapter/promotion/evaluator.js +0 -235
  47. package/lib/model/strategy/adapter/promotion/examples.d.ts +0 -86
  48. package/lib/model/strategy/adapter/promotion/examples.js +0 -91
  49. package/lib/model/strategy/adapter/promotion/index.d.ts +1 -1
  50. package/lib/model/strategy/adapter/promotion/index.js +0 -51
  51. package/lib/model/strategy/adapter/promotion/type.d.ts +2 -90
  52. package/lib/model/strategy/adapter/promotion/type.js +0 -2
  53. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +2 -1
  54. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +2 -1
  55. package/lib/modules/Order/index.d.ts +8 -27
  56. package/lib/modules/Order/index.js +72 -193
  57. package/lib/modules/Order/types.d.ts +1 -33
  58. package/lib/modules/Order/utils/orderCollectionIdentity.js +0 -3
  59. package/lib/modules/Order/utils.js +4 -11
  60. package/lib/modules/Payment/index.d.ts +0 -2
  61. package/lib/modules/Payment/index.js +13 -34
  62. package/lib/modules/Payment/types.d.ts +27 -29
  63. package/lib/modules/Payment/types.js +3 -3
  64. package/lib/modules/Rules/index.d.ts +0 -1
  65. package/lib/modules/Rules/index.js +4 -23
  66. package/lib/server/index.d.ts +0 -16
  67. package/lib/server/index.js +18 -670
  68. package/lib/server/modules/order/index.d.ts +4 -49
  69. package/lib/server/modules/order/index.js +66 -657
  70. package/lib/server/modules/order/types.d.ts +3 -11
  71. package/lib/solution/BaseSales/index.d.ts +11 -55
  72. package/lib/solution/BaseSales/index.js +35 -235
  73. package/lib/solution/BaseSales/utils/cartPromotion.d.ts +1 -3
  74. package/lib/solution/BaseSales/utils/cartPromotion.js +17 -65
  75. package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -6
  76. package/lib/solution/BookingTicket/index.d.ts +1 -1
  77. package/lib/solution/BookingTicket/index.js +3 -6
  78. package/lib/solution/BookingTicket/utils/addProductDecision.js +4 -0
  79. package/lib/solution/BookingTicket/utils/weighingProductSku.d.ts +5 -0
  80. package/lib/solution/BookingTicket/utils/weighingProductSku.js +63 -0
  81. package/lib/solution/Sales/index.d.ts +0 -1
  82. package/lib/solution/Sales/index.js +3 -5
  83. package/lib/solution/ScanOrder/index.js +0 -8
  84. package/lib/solution/VenueBooking/index.js +0 -8
  85. package/package.json +2 -2
  86. package/dist/modules/Order/payment-utils.d.ts +0 -26
  87. package/dist/modules/Order/payment-utils.js +0 -225
  88. package/dist/utils/payment-number.d.ts +0 -9
  89. package/dist/utils/payment-number.js +0 -69
  90. package/lib/modules/Order/payment-utils.d.ts +0 -26
  91. package/lib/modules/Order/payment-utils.js +0 -224
  92. package/lib/utils/payment-number.d.ts +0 -9
  93. package/lib/utils/payment-number.js +0 -64
@@ -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[];
@@ -1,224 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/modules/Order/payment-utils.ts
20
- var payment_utils_exports = {};
21
- __export(payment_utils_exports, {
22
- ensureOrderPaymentNumber: () => ensureOrderPaymentNumber,
23
- getOrderPaymentIdentityKeys: () => getOrderPaymentIdentityKeys,
24
- hasOrderPaymentIdentityOverlap: () => hasOrderPaymentIdentityOverlap,
25
- isIdentifiedPendingOrderPayment: () => isIdentifiedPendingOrderPayment,
26
- isPendingOrderPayment: () => isPendingOrderPayment,
27
- mergeOrderPaymentListsByIdentity: () => mergeOrderPaymentListsByIdentity,
28
- mergeOrderPaymentRecord: () => mergeOrderPaymentRecord,
29
- mergeOrderPaymentSnapshot: () => mergeOrderPaymentSnapshot,
30
- mergeOrderPaymentTransactions: () => mergeOrderPaymentTransactions,
31
- resolveOrderPaymentIdentity: () => resolveOrderPaymentIdentity
32
- });
33
- module.exports = __toCommonJS(payment_utils_exports);
34
- var PAYMENT_IDENTITY_TYPES = [
35
- "payment_number",
36
- "order_payment_id",
37
- "unique_payment_number"
38
- ];
39
- function normalizePaymentIdentityValue(value) {
40
- if (value === void 0 || value === null || value === "")
41
- return null;
42
- return String(value);
43
- }
44
- function getPaymentIdentityValue(payment, type) {
45
- var _a;
46
- if (type === "unique_payment_number") {
47
- return (_a = payment == null ? void 0 : payment.metadata) == null ? void 0 : _a.unique_payment_number;
48
- }
49
- return payment == null ? void 0 : payment[type];
50
- }
51
- function getOrderPaymentIdentityKeys(payment) {
52
- const record = payment;
53
- if (!record)
54
- return [];
55
- return PAYMENT_IDENTITY_TYPES.flatMap((type) => {
56
- const value = normalizePaymentIdentityValue(getPaymentIdentityValue(record, type));
57
- return value === null ? [] : [`${type}:${value}`];
58
- });
59
- }
60
- function isPendingOrderPayment(payment) {
61
- const record = payment;
62
- return String((record == null ? void 0 : record.status) || "").toLowerCase() === "payment_pending";
63
- }
64
- function isIdentifiedPendingOrderPayment(payment) {
65
- return isPendingOrderPayment(payment) && getOrderPaymentIdentityKeys(payment).length > 0;
66
- }
67
- function hasOrderPaymentIdentityOverlap(left, right) {
68
- const leftKeys = new Set(getOrderPaymentIdentityKeys(left));
69
- if (leftKeys.size === 0)
70
- return false;
71
- return getOrderPaymentIdentityKeys(right).some((key) => leftKeys.has(key));
72
- }
73
- function resolveOrderPaymentIdentity(payments, identity, mode = "payment_number") {
74
- const target = String(identity);
75
- const identityTypes = mode === "payment_number" ? ["payment_number"] : PAYMENT_IDENTITY_TYPES;
76
- const matchesByIndex = /* @__PURE__ */ new Map();
77
- for (const type of identityTypes) {
78
- (payments || []).forEach((payment, index) => {
79
- const value = normalizePaymentIdentityValue(getPaymentIdentityValue(payment, type));
80
- if (value === target && !matchesByIndex.has(index)) {
81
- matchesByIndex.set(index, { index, payment, matchedBy: type });
82
- }
83
- });
84
- }
85
- const matches = [...matchesByIndex.values()];
86
- if (matches.length > 1) {
87
- throw new Error(`支付项身份存在歧义: ${target}`);
88
- }
89
- return matches[0] || null;
90
- }
91
- function ensureOrderPaymentNumber(payment, devicePrefix, createPaymentNumber) {
92
- const existing = normalizePaymentIdentityValue(payment.payment_number);
93
- if (existing)
94
- return { ...payment, payment_number: existing };
95
- const uuid = normalizePaymentIdentityValue(payment.uuid) || createPaymentNumber();
96
- const prefix = normalizePaymentIdentityValue(devicePrefix) || "LOCAL";
97
- return { ...payment, payment_number: `${prefix}_${uuid}` };
98
- }
99
- function mergeOrderPaymentTransactions(current, incoming) {
100
- const records = /* @__PURE__ */ new Map();
101
- const append = (value) => {
102
- if (!Array.isArray(value))
103
- return;
104
- value.forEach((item) => {
105
- const number = item && typeof item === "object" ? String(item.number || "") : "";
106
- const status = item && typeof item === "object" ? item.status : void 0;
107
- if (!number || status !== "success" && status !== "fail")
108
- return;
109
- const previous = records.get(number);
110
- if ((previous == null ? void 0 : previous.status) === "success" && status === "fail")
111
- return;
112
- records.set(number, { number, status });
113
- });
114
- };
115
- append(current);
116
- append(incoming);
117
- return [...records.values()];
118
- }
119
- function mergeOrderPaymentRecord(payment, updates) {
120
- const currentMetadata = payment.metadata || {};
121
- const incomingMetadata = updates.metadata || {};
122
- const transactions = mergeOrderPaymentTransactions(
123
- currentMetadata.transactions,
124
- incomingMetadata.transactions
125
- );
126
- const currentPaid = payment.status === "paid";
127
- const nextStatus = currentPaid && updates.status !== "paid" ? "paid" : updates.status ?? payment.status;
128
- return {
129
- ...payment,
130
- ...updates,
131
- status: nextStatus,
132
- updated_at: updates.updated_at ?? payment.updated_at,
133
- metadata: {
134
- ...currentMetadata,
135
- ...incomingMetadata,
136
- ...transactions.length > 0 || Array.isArray(incomingMetadata.transactions) ? { transactions } : {}
137
- }
138
- };
139
- }
140
- function mergeOrderPaymentSnapshot(current, incoming) {
141
- const currentMetadata = current.metadata || {};
142
- const incomingMetadata = incoming.metadata || {};
143
- const currentUniquePaymentNumber = normalizePaymentIdentityValue(
144
- currentMetadata.unique_payment_number
145
- );
146
- const incomingUniquePaymentNumber = normalizePaymentIdentityValue(
147
- incomingMetadata.unique_payment_number
148
- );
149
- const incomingOrderPaymentId = normalizePaymentIdentityValue(
150
- incoming.order_payment_id
151
- );
152
- const incomingFallbackPrefix = incomingOrderPaymentId ? `os-fallback:payment:order-payment:${incomingOrderPaymentId}` : null;
153
- const incomingUsesDerivedUniquePaymentNumber = Boolean(
154
- incomingUniquePaymentNumber && incomingFallbackPrefix && (incomingUniquePaymentNumber === incomingFallbackPrefix || incomingUniquePaymentNumber.startsWith(`${incomingFallbackPrefix}:conflict:`))
155
- );
156
- const transactions = mergeOrderPaymentTransactions(
157
- currentMetadata.transactions,
158
- incomingMetadata.transactions
159
- );
160
- return {
161
- ...current,
162
- ...incoming,
163
- order_payment_id: normalizePaymentIdentityValue(incoming.order_payment_id) !== null ? incoming.order_payment_id : current.order_payment_id,
164
- payment_number: incoming.payment_number || current.payment_number,
165
- metadata: {
166
- ...currentMetadata,
167
- ...incomingMetadata,
168
- ...incomingUsesDerivedUniquePaymentNumber && currentUniquePaymentNumber ? { unique_payment_number: currentUniquePaymentNumber } : {},
169
- ...transactions.length > 0 ? { transactions } : {}
170
- }
171
- };
172
- }
173
- function compactOrderPaymentList(payments) {
174
- const result = [];
175
- for (const payment of payments) {
176
- const matchingIndexes = result.flatMap((existing, index) => hasOrderPaymentIdentityOverlap(existing, payment) ? [index] : []);
177
- if (matchingIndexes.length === 0) {
178
- result.push(mergeOrderPaymentSnapshot({}, payment));
179
- continue;
180
- }
181
- const firstIndex = matchingIndexes[0];
182
- let merged = result[firstIndex];
183
- for (const index of matchingIndexes.slice(1)) {
184
- merged = mergeOrderPaymentSnapshot(merged, result[index]);
185
- }
186
- result[firstIndex] = mergeOrderPaymentSnapshot(merged, payment);
187
- for (const index of matchingIndexes.slice(1).sort((a, b) => b - a)) {
188
- result.splice(index, 1);
189
- }
190
- }
191
- return result;
192
- }
193
- function mergeOrderPaymentListsByIdentity(existing, incoming, options = {}) {
194
- const existingList = compactOrderPaymentList([...existing || []]);
195
- const incomingList = compactOrderPaymentList([...incoming || []]);
196
- if (options.preserveUnmatchedExisting) {
197
- return compactOrderPaymentList([...existingList, ...incomingList]);
198
- }
199
- const mergedIncoming = incomingList.map((incomingPayment) => {
200
- const matchingExisting = existingList.filter((existingPayment) => hasOrderPaymentIdentityOverlap(existingPayment, incomingPayment));
201
- return matchingExisting.reduce(
202
- (merged, existingPayment) => mergeOrderPaymentSnapshot(existingPayment, merged),
203
- incomingPayment
204
- );
205
- });
206
- const preservedExisting = options.preserveUnmatchedExistingWhen ? existingList.filter((existingPayment) => {
207
- var _a;
208
- return !incomingList.some((incomingPayment) => hasOrderPaymentIdentityOverlap(existingPayment, incomingPayment)) && ((_a = options.preserveUnmatchedExistingWhen) == null ? void 0 : _a.call(options, existingPayment));
209
- }) : [];
210
- return compactOrderPaymentList([...mergedIncoming, ...preservedExisting]);
211
- }
212
- // Annotate the CommonJS export names for ESM import in node:
213
- 0 && (module.exports = {
214
- ensureOrderPaymentNumber,
215
- getOrderPaymentIdentityKeys,
216
- hasOrderPaymentIdentityOverlap,
217
- isIdentifiedPendingOrderPayment,
218
- isPendingOrderPayment,
219
- mergeOrderPaymentListsByIdentity,
220
- mergeOrderPaymentRecord,
221
- mergeOrderPaymentSnapshot,
222
- mergeOrderPaymentTransactions,
223
- resolveOrderPaymentIdentity
224
- });
@@ -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,64 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/utils/payment-number.ts
20
- var payment_number_exports = {};
21
- __export(payment_number_exports, {
22
- resolvePaymentNumberDevicePrefix: () => resolvePaymentNumberDevicePrefix,
23
- resolvePaymentNumberDevicePrefixFromDeviceId: () => resolvePaymentNumberDevicePrefixFromDeviceId
24
- });
25
- module.exports = __toCommonJS(payment_number_exports);
26
- function normalizeNonEmptyString(value) {
27
- if (value === void 0 || value === null)
28
- return null;
29
- if (typeof value !== "string" && typeof value !== "number")
30
- return null;
31
- if (typeof value === "number" && !Number.isFinite(value))
32
- return null;
33
- const normalized = String(value).trim();
34
- return normalized || null;
35
- }
36
- function resolvePaymentNumberDevicePrefixFromDeviceId(getAppData) {
37
- try {
38
- const deviceId = normalizeNonEmptyString(getAppData("device_id"));
39
- if (deviceId && deviceId !== "0")
40
- return deviceId.slice(-2);
41
- } catch {
42
- }
43
- return "LOCAL";
44
- }
45
- async function resolvePaymentNumberDevicePrefix(getAppData) {
46
- try {
47
- const getAsyncIotDeviceInfo = getAppData("async_iot_device_info");
48
- if (typeof getAsyncIotDeviceInfo === "function") {
49
- const info = await getAsyncIotDeviceInfo();
50
- const shortNumber = normalizeNonEmptyString(
51
- info == null ? void 0 : info.short_number
52
- );
53
- if (shortNumber && shortNumber !== "0")
54
- return shortNumber;
55
- }
56
- } catch {
57
- }
58
- return resolvePaymentNumberDevicePrefixFromDeviceId(getAppData);
59
- }
60
- // Annotate the CommonJS export names for ESM import in node:
61
- 0 && (module.exports = {
62
- resolvePaymentNumberDevicePrefix,
63
- resolvePaymentNumberDevicePrefixFromDeviceId
64
- });