@pisell/pisellos 2.3.37 → 2.3.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/modules/Discount/index.d.ts +1 -0
- package/dist/modules/Discount/index.js +40 -11
- package/dist/modules/Discount/types.d.ts +1 -0
- package/dist/modules/Holder/index.d.ts +48 -0
- package/dist/modules/Holder/index.js +640 -0
- package/dist/modules/Holder/types.d.ts +123 -0
- package/dist/modules/Holder/types.js +1 -0
- package/dist/modules/Holder/utils.d.ts +13 -0
- package/dist/modules/Holder/utils.js +34 -0
- package/dist/modules/OpenData/index.js +2 -2
- package/dist/modules/Order/index.d.ts +11 -28
- package/dist/modules/Order/index.js +513 -747
- package/dist/modules/Order/types.d.ts +10 -33
- package/dist/modules/Order/utils/orderCollectionIdentity.js +2 -7
- package/dist/modules/Order/utils.d.ts +10 -0
- package/dist/modules/Order/utils.js +40 -11
- package/dist/modules/Payment/index.d.ts +0 -2
- package/dist/modules/Payment/index.js +49 -78
- package/dist/modules/Payment/types.d.ts +24 -26
- package/dist/modules/Payment/types.js +0 -2
- package/dist/modules/Product/types.d.ts +1 -0
- package/dist/modules/ProductList/index.js +33 -14
- package/dist/modules/Quotation/index.d.ts +1 -1
- package/dist/modules/Quotation/index.js +2 -2
- package/dist/modules/ResourcePlanner/index.d.ts +24 -0
- package/dist/modules/ResourcePlanner/index.js +181 -0
- package/dist/modules/ResourcePlanner/planner.d.ts +14 -0
- package/dist/modules/ResourcePlanner/planner.js +1069 -0
- package/dist/modules/ResourcePlanner/types.d.ts +227 -0
- package/dist/modules/ResourcePlanner/types.js +1 -0
- package/dist/modules/Rules/index.js +48 -15
- package/dist/modules/SalesSummary/index.js +12 -13
- package/dist/modules/ScanOrderLogger/index.d.ts +2 -0
- package/dist/modules/ScanOrderLogger/index.js +15 -2
- package/dist/modules/ScanOrderLogger/providers/feishu.js +45 -27
- package/dist/modules/ScanOrderLogger/types.d.ts +1 -0
- package/dist/modules/Schedule/index.d.ts +3 -1
- package/dist/modules/Schedule/index.js +21 -16
- package/dist/modules/Summary/utils.js +38 -13
- package/dist/modules/index.d.ts +2 -0
- package/dist/modules/index.js +3 -1
- package/dist/plugins/window.d.ts +1 -0
- package/dist/server/index.d.ts +14 -16
- package/dist/server/index.js +1162 -1943
- package/dist/server/modules/order/index.d.ts +4 -49
- package/dist/server/modules/order/index.js +695 -1574
- package/dist/server/modules/order/types.d.ts +3 -11
- package/dist/server/modules/order/types.js +1 -1
- package/dist/solution/BaseSales/index.d.ts +10 -33
- package/dist/solution/BaseSales/index.js +385 -676
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -6
- package/dist/solution/BookingByStep/index.d.ts +17 -2
- package/dist/solution/BookingByStep/index.js +294 -215
- package/dist/solution/BookingByStep/types.d.ts +2 -1
- package/dist/solution/BookingByStep/types.js +3 -1
- package/dist/solution/BookingByStep/utils/capacity.js +17 -1
- package/dist/solution/BookingByStep/utils/timeslots.d.ts +3 -1
- package/dist/solution/BookingByStep/utils/timeslots.js +19 -12
- package/dist/solution/BookingTicket/index.js +1 -2
- package/dist/solution/Sales/index.d.ts +0 -1
- package/dist/solution/Sales/index.js +2 -10
- package/dist/solution/ScanOrder/index.d.ts +26 -14
- package/dist/solution/ScanOrder/index.js +1140 -737
- package/dist/solution/ScanOrder/types.d.ts +21 -1
- package/dist/solution/ScanOrder/utils.d.ts +8 -0
- package/dist/solution/ScanOrder/utils.js +66 -25
- package/dist/solution/ShopDiscount/index.d.ts +1 -0
- package/dist/solution/ShopDiscount/index.js +125 -87
- package/dist/solution/UnifiedBookingSales/index.d.ts +183 -0
- package/dist/solution/UnifiedBookingSales/index.js +1871 -0
- package/dist/solution/UnifiedBookingSales/types.d.ts +143 -0
- package/dist/solution/UnifiedBookingSales/types.js +11 -0
- package/dist/solution/VenueBooking/index.d.ts +39 -11
- package/dist/solution/VenueBooking/index.js +1177 -850
- package/dist/solution/VenueBooking/types.d.ts +3 -0
- package/dist/solution/VenueBooking/utils/resource.js +1 -0
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
- package/dist/solution/VenueBooking/utils/slotMerge.js +10 -5
- package/dist/solution/index.d.ts +1 -0
- package/dist/solution/index.js +2 -1
- package/dist/types/index.d.ts +1 -0
- package/lib/modules/Discount/index.d.ts +1 -0
- package/lib/modules/Discount/index.js +9 -0
- package/lib/modules/Discount/types.d.ts +1 -0
- package/lib/modules/Holder/index.d.ts +48 -0
- package/lib/modules/Holder/index.js +402 -0
- package/lib/modules/Holder/types.d.ts +123 -0
- package/lib/modules/Holder/types.js +17 -0
- package/lib/modules/Holder/utils.d.ts +13 -0
- package/lib/modules/Holder/utils.js +71 -0
- package/lib/modules/OpenData/index.js +1 -1
- package/lib/modules/Order/index.d.ts +11 -28
- package/lib/modules/Order/index.js +83 -187
- package/lib/modules/Order/types.d.ts +10 -33
- package/lib/modules/Order/utils/orderCollectionIdentity.js +0 -3
- package/lib/modules/Order/utils.d.ts +10 -0
- package/lib/modules/Order/utils.js +39 -10
- package/lib/modules/Payment/index.d.ts +0 -2
- package/lib/modules/Payment/index.js +12 -33
- package/lib/modules/Payment/types.d.ts +24 -26
- package/lib/modules/Product/types.d.ts +1 -0
- package/lib/modules/ProductList/index.js +40 -31
- package/lib/modules/Quotation/index.d.ts +1 -1
- package/lib/modules/Quotation/index.js +2 -2
- package/lib/modules/ResourcePlanner/index.d.ts +24 -0
- package/lib/modules/ResourcePlanner/index.js +148 -0
- package/lib/modules/ResourcePlanner/planner.d.ts +14 -0
- package/lib/modules/ResourcePlanner/planner.js +933 -0
- package/lib/modules/ResourcePlanner/types.d.ts +227 -0
- package/lib/modules/ResourcePlanner/types.js +17 -0
- package/lib/modules/Rules/index.js +34 -18
- package/lib/modules/SalesSummary/index.js +6 -7
- package/lib/modules/ScanOrderLogger/index.d.ts +2 -0
- package/lib/modules/ScanOrderLogger/index.js +13 -1
- package/lib/modules/ScanOrderLogger/providers/feishu.js +15 -6
- package/lib/modules/ScanOrderLogger/types.d.ts +1 -0
- package/lib/modules/Schedule/index.d.ts +3 -1
- package/lib/modules/Schedule/index.js +10 -8
- package/lib/modules/Summary/utils.js +21 -1
- package/lib/modules/index.d.ts +2 -0
- package/lib/modules/index.js +5 -1
- package/lib/plugins/window.d.ts +1 -0
- package/lib/server/index.d.ts +14 -16
- package/lib/server/index.js +88 -678
- package/lib/server/modules/order/index.d.ts +4 -49
- package/lib/server/modules/order/index.js +66 -657
- package/lib/server/modules/order/types.d.ts +3 -11
- package/lib/solution/BaseSales/index.d.ts +10 -33
- package/lib/solution/BaseSales/index.js +33 -201
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -6
- package/lib/solution/BookingByStep/index.d.ts +17 -2
- package/lib/solution/BookingByStep/index.js +60 -18
- package/lib/solution/BookingByStep/types.d.ts +2 -1
- package/lib/solution/BookingByStep/types.js +5 -0
- package/lib/solution/BookingByStep/utils/capacity.js +20 -1
- package/lib/solution/BookingByStep/utils/timeslots.d.ts +3 -1
- package/lib/solution/BookingByStep/utils/timeslots.js +19 -11
- package/lib/solution/BookingTicket/index.js +1 -2
- package/lib/solution/Sales/index.d.ts +0 -1
- package/lib/solution/Sales/index.js +3 -5
- package/lib/solution/ScanOrder/index.d.ts +26 -14
- package/lib/solution/ScanOrder/index.js +449 -182
- package/lib/solution/ScanOrder/types.d.ts +21 -1
- package/lib/solution/ScanOrder/utils.d.ts +8 -0
- package/lib/solution/ScanOrder/utils.js +31 -0
- package/lib/solution/ShopDiscount/index.d.ts +1 -0
- package/lib/solution/ShopDiscount/index.js +14 -0
- package/lib/solution/UnifiedBookingSales/index.d.ts +183 -0
- package/lib/solution/UnifiedBookingSales/index.js +1076 -0
- package/lib/solution/UnifiedBookingSales/types.d.ts +143 -0
- package/lib/solution/UnifiedBookingSales/types.js +33 -0
- package/lib/solution/VenueBooking/index.d.ts +39 -11
- package/lib/solution/VenueBooking/index.js +328 -115
- package/lib/solution/VenueBooking/types.d.ts +3 -0
- package/lib/solution/VenueBooking/utils/resource.js +1 -0
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
- package/lib/solution/VenueBooking/utils/slotMerge.js +6 -4
- package/lib/solution/index.d.ts +1 -0
- package/lib/solution/index.js +3 -1
- package/lib/types/index.d.ts +1 -0
- package/package.json +2 -2
- package/dist/modules/Order/payment-utils.d.ts +0 -26
- package/dist/modules/Order/payment-utils.js +0 -225
- package/dist/utils/payment-number.d.ts +0 -9
- package/dist/utils/payment-number.js +0 -69
- package/lib/modules/Order/payment-utils.d.ts +0 -26
- package/lib/modules/Order/payment-utils.js +0 -224
- package/lib/utils/payment-number.d.ts +0 -9
- package/lib/utils/payment-number.js +0 -64
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { OrderModule, ProductList, SalesSummaryModule, ScanOrderLogInput, ScanOrderLoggerModule, ScanOrderLoggerProviderConfig, ScanOrderLoggerProviderType, DateModule, ScheduleModule, QuotationModule, OpenDataModule } from '../../modules';
|
|
2
2
|
import type { QuantityCheckResult, QuantityLimitResult } from '../../model/strategy/adapter/itemRule';
|
|
3
|
+
import { HolderModule } from '../../modules/Holder';
|
|
3
4
|
export type { ScanOrderOrderProductIdentity, ScanOrderOrderProduct, ScanOrderSubmitProduct, ScanOrderSummary, ScanOrderTempOrder, ScanOrderSubmitPayload, } from '../ScanOrder/types';
|
|
4
5
|
export declare enum VenueBookingHooks {
|
|
5
6
|
onInited = "venueBooking:onInited",
|
|
@@ -96,6 +97,7 @@ export interface VenueResourceRawData {
|
|
|
96
97
|
export interface ResourceProductMapping {
|
|
97
98
|
productId: number;
|
|
98
99
|
productTitle: string;
|
|
100
|
+
formName?: string;
|
|
99
101
|
resourceName: string;
|
|
100
102
|
formId: number | string;
|
|
101
103
|
price: string;
|
|
@@ -144,6 +146,7 @@ export interface VenueBookingState {
|
|
|
144
146
|
passed: boolean | null;
|
|
145
147
|
failures: QuantityCheckResult[];
|
|
146
148
|
};
|
|
149
|
+
holder?: HolderModule;
|
|
147
150
|
}
|
|
148
151
|
export interface VenueBookingLoggerRuntimeConfig {
|
|
149
152
|
provider?: ScanOrderLoggerProviderType;
|
|
@@ -12,10 +12,6 @@ export declare function buildPriceBreakdown(params: {
|
|
|
12
12
|
}) => number;
|
|
13
13
|
};
|
|
14
14
|
}): PriceBreakdownEntry[];
|
|
15
|
-
export declare function buildVenueResourceMetadata(params: {
|
|
16
|
-
mapping: ResourceProductMapping;
|
|
17
|
-
rawResource: VenueResourceRawData | undefined;
|
|
18
|
-
}): Record<string, any>;
|
|
19
15
|
export interface BuildVenueBookingParams {
|
|
20
16
|
group: MergedSlotGroup;
|
|
21
17
|
resourceId: number | string;
|
|
@@ -29,6 +25,10 @@ export interface BuildVenueBookingParams {
|
|
|
29
25
|
*/
|
|
30
26
|
childResources?: VenueResourceRawData[];
|
|
31
27
|
}
|
|
28
|
+
export declare function buildVenueResourceMetadata(params: {
|
|
29
|
+
mapping: ResourceProductMapping;
|
|
30
|
+
rawResource: VenueResourceRawData | undefined;
|
|
31
|
+
}): Record<string, any>;
|
|
32
32
|
export declare function buildVenueBookingEntry(params: BuildVenueBookingParams): Record<string, any>;
|
|
33
33
|
/**
|
|
34
34
|
* 从一条已合并的订单商品还原出独立的时段列表。
|
|
@@ -109,10 +109,12 @@ function buildPriceBreakdown(params) {
|
|
|
109
109
|
}
|
|
110
110
|
function buildVenueResourceMetadata(params) {
|
|
111
111
|
const { mapping, rawResource } = params;
|
|
112
|
+
const combined = rawResource == null ? void 0 : rawResource.combined_resource;
|
|
113
|
+
const isCombined = !!(combined && combined.status === 1 && Array.isArray(combined.resource_ids));
|
|
112
114
|
return {
|
|
113
|
-
form_name:
|
|
114
|
-
resource_name: (rawResource == null ? void 0 : rawResource.main_field) ?? mapping.resourceName
|
|
115
|
-
combined_resource:
|
|
115
|
+
form_name: mapping.formName ?? mapping.resourceName,
|
|
116
|
+
resource_name: (rawResource == null ? void 0 : rawResource.main_field) ?? mapping.resourceName,
|
|
117
|
+
combined_resource: isCombined ? combined : null
|
|
116
118
|
};
|
|
117
119
|
}
|
|
118
120
|
function buildVenueBookingEntry(params) {
|
|
@@ -128,7 +130,7 @@ function buildVenueBookingEntry(params) {
|
|
|
128
130
|
form_id: (rawResource == null ? void 0 : rawResource.form_id) ?? mapping.formId,
|
|
129
131
|
relation_id: resourceId,
|
|
130
132
|
capacity: 1,
|
|
131
|
-
metadata: {}
|
|
133
|
+
metadata: buildVenueResourceMetadata({ mapping, rawResource })
|
|
132
134
|
};
|
|
133
135
|
if (childResources && childResources.length) {
|
|
134
136
|
resourceEntry.children = childResources.map((child) => ({
|
package/lib/solution/index.d.ts
CHANGED
package/lib/solution/index.js
CHANGED
|
@@ -26,6 +26,7 @@ __reExport(solution_exports, require("./Sales"), module.exports);
|
|
|
26
26
|
__reExport(solution_exports, require("./ScanOrder"), module.exports);
|
|
27
27
|
__reExport(solution_exports, require("./BaseSales"), module.exports);
|
|
28
28
|
__reExport(solution_exports, require("./VenueBooking"), module.exports);
|
|
29
|
+
__reExport(solution_exports, require("./UnifiedBookingSales"), module.exports);
|
|
29
30
|
// Annotate the CommonJS export names for ESM import in node:
|
|
30
31
|
0 && (module.exports = {
|
|
31
32
|
...require("./BuyTickets"),
|
|
@@ -37,5 +38,6 @@ __reExport(solution_exports, require("./VenueBooking"), module.exports);
|
|
|
37
38
|
...require("./Sales"),
|
|
38
39
|
...require("./ScanOrder"),
|
|
39
40
|
...require("./BaseSales"),
|
|
40
|
-
...require("./VenueBooking")
|
|
41
|
+
...require("./VenueBooking"),
|
|
42
|
+
...require("./UnifiedBookingSales")
|
|
41
43
|
});
|
package/lib/types/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"private": false,
|
|
3
3
|
"name": "@pisell/pisellos",
|
|
4
|
-
"version": "2.3.
|
|
4
|
+
"version": "2.3.39",
|
|
5
5
|
"description": "一个可扩展的前端模块化SDK框架,支持插件系统",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"format": "prettier --write \"src/**/*.{ts,tsx,js,jsx,json,md}\"",
|
|
19
19
|
"changeset": "changeset",
|
|
20
20
|
"version": "changeset version",
|
|
21
|
-
"release": "changeset publish
|
|
21
|
+
"release": "changeset publish && npm run sync && git push",
|
|
22
22
|
"example": "npx parcel-bundler examples/index.html",
|
|
23
23
|
"docs": "typedoc --out docs src/index.ts",
|
|
24
24
|
"sync": "node sync.js",
|
|
@@ -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[];
|