@pisell/pisellos 2.3.28 → 2.3.30
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/Order/index.d.ts +32 -8
- package/dist/modules/Order/index.js +883 -521
- package/dist/modules/Order/payment-utils.d.ts +23 -0
- package/dist/modules/Order/payment-utils.js +203 -0
- package/dist/modules/Order/types.d.ts +33 -1
- package/dist/modules/Order/utils/orderCollectionIdentity.d.ts +53 -0
- package/dist/modules/Order/utils/orderCollectionIdentity.js +405 -0
- package/dist/modules/Order/utils.d.ts +2 -1
- package/dist/modules/Order/utils.js +6 -12
- package/dist/modules/Payment/index.d.ts +2 -0
- package/dist/modules/Payment/index.js +78 -49
- package/dist/modules/Payment/types.d.ts +26 -24
- package/dist/modules/Payment/types.js +2 -0
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/server/index.d.ts +14 -0
- package/dist/server/index.js +1826 -1000
- package/dist/server/modules/order/index.d.ts +47 -4
- package/dist/server/modules/order/index.js +1415 -711
- package/dist/server/modules/order/types.d.ts +11 -3
- package/dist/server/modules/order/types.js +1 -1
- package/dist/solution/BaseSales/index.d.ts +40 -4
- package/dist/solution/BaseSales/index.js +1268 -749
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +9 -4
- package/dist/solution/BaseSales/utils/parseSalesResponse.js +6 -8
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +13 -1
- package/dist/solution/BookingTicket/index.js +2 -1
- package/dist/utils/payment-number.d.ts +9 -0
- package/dist/utils/payment-number.js +69 -0
- package/lib/modules/Order/index.d.ts +32 -8
- package/lib/modules/Order/index.js +270 -64
- package/lib/modules/Order/payment-utils.d.ts +23 -0
- package/lib/modules/Order/payment-utils.js +193 -0
- package/lib/modules/Order/types.d.ts +33 -1
- package/lib/modules/Order/utils/orderCollectionIdentity.d.ts +53 -0
- package/lib/modules/Order/utils/orderCollectionIdentity.js +415 -0
- package/lib/modules/Order/utils.d.ts +2 -1
- package/lib/modules/Order/utils.js +6 -14
- package/lib/modules/Payment/index.d.ts +2 -0
- package/lib/modules/Payment/index.js +33 -12
- package/lib/modules/Payment/types.d.ts +26 -24
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/server/index.d.ts +14 -0
- package/lib/server/index.js +604 -8
- package/lib/server/modules/order/index.d.ts +47 -4
- package/lib/server/modules/order/index.js +578 -116
- package/lib/server/modules/order/types.d.ts +11 -3
- package/lib/solution/BaseSales/index.d.ts +40 -4
- package/lib/solution/BaseSales/index.js +363 -37
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +9 -4
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +4 -5
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +13 -1
- package/lib/solution/BookingTicket/index.js +2 -1
- package/lib/utils/payment-number.d.ts +9 -0
- package/lib/utils/payment-number.js +64 -0
- package/package.json +1 -1
|
@@ -0,0 +1,23 @@
|
|
|
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 hasOrderPaymentIdentityOverlap(left: unknown, right: unknown): boolean;
|
|
14
|
+
export declare function resolveOrderPaymentIdentity<T extends Record<string, any>>(payments: T[] | null | undefined, identity: string | number, mode?: 'payment_number' | 'compat'): OrderPaymentIdentityMatch<T> | null;
|
|
15
|
+
export declare function ensureOrderPaymentNumber<T extends Record<string, any>>(payment: T, devicePrefix: string, createPaymentNumber: () => string): T & {
|
|
16
|
+
payment_number: string;
|
|
17
|
+
};
|
|
18
|
+
export declare function mergeOrderPaymentTransactions(current: unknown, incoming: unknown): OrderPaymentTransaction[];
|
|
19
|
+
export declare function mergeOrderPaymentRecord<T extends Record<string, any>>(payment: T, updates: Record<string, any>): T;
|
|
20
|
+
export declare function mergeOrderPaymentSnapshot<T extends Record<string, any>>(current: T, incoming: T): T;
|
|
21
|
+
export declare function mergeOrderPaymentListsByIdentity<T extends Record<string, any>>(existing: T[] | null | undefined, incoming: T[] | null | undefined, options?: {
|
|
22
|
+
preserveUnmatchedExisting?: boolean;
|
|
23
|
+
}): T[];
|
|
@@ -0,0 +1,203 @@
|
|
|
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 hasOrderPaymentIdentityOverlap(left, right) {
|
|
35
|
+
var leftKeys = new Set(getOrderPaymentIdentityKeys(left));
|
|
36
|
+
if (leftKeys.size === 0) return false;
|
|
37
|
+
return getOrderPaymentIdentityKeys(right).some(function (key) {
|
|
38
|
+
return leftKeys.has(key);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
export function resolveOrderPaymentIdentity(payments, identity) {
|
|
42
|
+
var mode = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'payment_number';
|
|
43
|
+
var target = String(identity);
|
|
44
|
+
var identityTypes = mode === 'payment_number' ? ['payment_number'] : PAYMENT_IDENTITY_TYPES;
|
|
45
|
+
var matchesByIndex = new Map();
|
|
46
|
+
var _iterator = _createForOfIteratorHelper(identityTypes),
|
|
47
|
+
_step;
|
|
48
|
+
try {
|
|
49
|
+
var _loop = function _loop() {
|
|
50
|
+
var type = _step.value;
|
|
51
|
+
(payments || []).forEach(function (payment, index) {
|
|
52
|
+
var value = normalizePaymentIdentityValue(getPaymentIdentityValue(payment, type));
|
|
53
|
+
if (value === target && !matchesByIndex.has(index)) {
|
|
54
|
+
matchesByIndex.set(index, {
|
|
55
|
+
index: index,
|
|
56
|
+
payment: payment,
|
|
57
|
+
matchedBy: type
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
63
|
+
_loop();
|
|
64
|
+
}
|
|
65
|
+
} catch (err) {
|
|
66
|
+
_iterator.e(err);
|
|
67
|
+
} finally {
|
|
68
|
+
_iterator.f();
|
|
69
|
+
}
|
|
70
|
+
var matches = _toConsumableArray(matchesByIndex.values());
|
|
71
|
+
if (matches.length > 1) {
|
|
72
|
+
throw new Error("\u652F\u4ED8\u9879\u8EAB\u4EFD\u5B58\u5728\u6B67\u4E49: ".concat(target));
|
|
73
|
+
}
|
|
74
|
+
return matches[0] || null;
|
|
75
|
+
}
|
|
76
|
+
export function ensureOrderPaymentNumber(payment, devicePrefix, createPaymentNumber) {
|
|
77
|
+
var existing = normalizePaymentIdentityValue(payment.payment_number);
|
|
78
|
+
if (existing) return _objectSpread(_objectSpread({}, payment), {}, {
|
|
79
|
+
payment_number: existing
|
|
80
|
+
});
|
|
81
|
+
var uuid = normalizePaymentIdentityValue(payment.uuid) || createPaymentNumber();
|
|
82
|
+
var prefix = normalizePaymentIdentityValue(devicePrefix) || 'LOCAL';
|
|
83
|
+
// TODO: 使用 ID Generator 替换当前 UUID 段生成器。
|
|
84
|
+
return _objectSpread(_objectSpread({}, payment), {}, {
|
|
85
|
+
payment_number: "".concat(prefix, "_").concat(uuid)
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
export function mergeOrderPaymentTransactions(current, incoming) {
|
|
89
|
+
var records = new Map();
|
|
90
|
+
var append = function append(value) {
|
|
91
|
+
if (!Array.isArray(value)) return;
|
|
92
|
+
value.forEach(function (item) {
|
|
93
|
+
var number = item && _typeof(item) === 'object' ? String(item.number || '') : '';
|
|
94
|
+
var status = item && _typeof(item) === 'object' ? item.status : undefined;
|
|
95
|
+
if (!number || status !== 'success' && status !== 'fail') return;
|
|
96
|
+
var previous = records.get(number);
|
|
97
|
+
if ((previous === null || previous === void 0 ? void 0 : previous.status) === 'success' && status === 'fail') return;
|
|
98
|
+
records.set(number, {
|
|
99
|
+
number: number,
|
|
100
|
+
status: status
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
};
|
|
104
|
+
append(current);
|
|
105
|
+
append(incoming);
|
|
106
|
+
return _toConsumableArray(records.values());
|
|
107
|
+
}
|
|
108
|
+
export function mergeOrderPaymentRecord(payment, updates) {
|
|
109
|
+
var _updates$status, _updates$updated_at;
|
|
110
|
+
var currentMetadata = payment.metadata || {};
|
|
111
|
+
var incomingMetadata = updates.metadata || {};
|
|
112
|
+
var transactions = mergeOrderPaymentTransactions(currentMetadata.transactions, incomingMetadata.transactions);
|
|
113
|
+
var currentPaid = payment.status === 'paid';
|
|
114
|
+
var nextStatus = currentPaid && updates.status !== 'paid' ? 'paid' : (_updates$status = updates.status) !== null && _updates$status !== void 0 ? _updates$status : payment.status;
|
|
115
|
+
return _objectSpread(_objectSpread(_objectSpread({}, payment), updates), {}, {
|
|
116
|
+
status: nextStatus,
|
|
117
|
+
updated_at: (_updates$updated_at = updates.updated_at) !== null && _updates$updated_at !== void 0 ? _updates$updated_at : payment.updated_at,
|
|
118
|
+
metadata: _objectSpread(_objectSpread(_objectSpread({}, currentMetadata), incomingMetadata), transactions.length > 0 || Array.isArray(incomingMetadata.transactions) ? {
|
|
119
|
+
transactions: transactions
|
|
120
|
+
} : {})
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
export function mergeOrderPaymentSnapshot(current, incoming) {
|
|
124
|
+
var currentMetadata = current.metadata || {};
|
|
125
|
+
var incomingMetadata = incoming.metadata || {};
|
|
126
|
+
var transactions = mergeOrderPaymentTransactions(currentMetadata.transactions, incomingMetadata.transactions);
|
|
127
|
+
return _objectSpread(_objectSpread(_objectSpread({}, current), incoming), {}, {
|
|
128
|
+
payment_number: incoming.payment_number || current.payment_number,
|
|
129
|
+
metadata: _objectSpread(_objectSpread(_objectSpread({}, currentMetadata), incomingMetadata), transactions.length > 0 ? {
|
|
130
|
+
transactions: transactions
|
|
131
|
+
} : {})
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
function compactOrderPaymentList(payments) {
|
|
135
|
+
var result = [];
|
|
136
|
+
var _iterator2 = _createForOfIteratorHelper(payments),
|
|
137
|
+
_step2;
|
|
138
|
+
try {
|
|
139
|
+
var _loop2 = function _loop2() {
|
|
140
|
+
var payment = _step2.value;
|
|
141
|
+
var matchingIndexes = result.flatMap(function (existing, index) {
|
|
142
|
+
return hasOrderPaymentIdentityOverlap(existing, payment) ? [index] : [];
|
|
143
|
+
});
|
|
144
|
+
if (matchingIndexes.length === 0) {
|
|
145
|
+
result.push(mergeOrderPaymentSnapshot({}, payment));
|
|
146
|
+
return 1; // continue
|
|
147
|
+
}
|
|
148
|
+
var firstIndex = matchingIndexes[0];
|
|
149
|
+
var merged = result[firstIndex];
|
|
150
|
+
var _iterator3 = _createForOfIteratorHelper(matchingIndexes.slice(1)),
|
|
151
|
+
_step3;
|
|
152
|
+
try {
|
|
153
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
154
|
+
var index = _step3.value;
|
|
155
|
+
merged = mergeOrderPaymentSnapshot(merged, result[index]);
|
|
156
|
+
}
|
|
157
|
+
} catch (err) {
|
|
158
|
+
_iterator3.e(err);
|
|
159
|
+
} finally {
|
|
160
|
+
_iterator3.f();
|
|
161
|
+
}
|
|
162
|
+
result[firstIndex] = mergeOrderPaymentSnapshot(merged, payment);
|
|
163
|
+
var _iterator4 = _createForOfIteratorHelper(matchingIndexes.slice(1).sort(function (a, b) {
|
|
164
|
+
return b - a;
|
|
165
|
+
})),
|
|
166
|
+
_step4;
|
|
167
|
+
try {
|
|
168
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
169
|
+
var _index = _step4.value;
|
|
170
|
+
result.splice(_index, 1);
|
|
171
|
+
}
|
|
172
|
+
} catch (err) {
|
|
173
|
+
_iterator4.e(err);
|
|
174
|
+
} finally {
|
|
175
|
+
_iterator4.f();
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
179
|
+
if (_loop2()) continue;
|
|
180
|
+
}
|
|
181
|
+
} catch (err) {
|
|
182
|
+
_iterator2.e(err);
|
|
183
|
+
} finally {
|
|
184
|
+
_iterator2.f();
|
|
185
|
+
}
|
|
186
|
+
return result;
|
|
187
|
+
}
|
|
188
|
+
export function mergeOrderPaymentListsByIdentity(existing, incoming) {
|
|
189
|
+
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
190
|
+
var existingList = compactOrderPaymentList(_toConsumableArray(existing || []));
|
|
191
|
+
var incomingList = compactOrderPaymentList(_toConsumableArray(incoming || []));
|
|
192
|
+
if (options.preserveUnmatchedExisting) {
|
|
193
|
+
return compactOrderPaymentList([].concat(_toConsumableArray(existingList), _toConsumableArray(incomingList)));
|
|
194
|
+
}
|
|
195
|
+
return compactOrderPaymentList(incomingList.map(function (incomingPayment) {
|
|
196
|
+
var matchingExisting = existingList.filter(function (existingPayment) {
|
|
197
|
+
return hasOrderPaymentIdentityOverlap(existingPayment, incomingPayment);
|
|
198
|
+
});
|
|
199
|
+
return matchingExisting.reduce(function (merged, existingPayment) {
|
|
200
|
+
return mergeOrderPaymentSnapshot(existingPayment, merged);
|
|
201
|
+
}, incomingPayment);
|
|
202
|
+
}));
|
|
203
|
+
}
|
|
@@ -467,6 +467,8 @@ export interface SubmitSalesOrderParams {
|
|
|
467
467
|
export interface PaymentItemData {
|
|
468
468
|
/** 当前支付项的唯一 ID */
|
|
469
469
|
uuid: string;
|
|
470
|
+
/** 支付项稳定唯一号 */
|
|
471
|
+
payment_number?: string;
|
|
470
472
|
/** 当前支付方式付出去多少钱 */
|
|
471
473
|
amount: string;
|
|
472
474
|
/** 支付类型代码 */
|
|
@@ -489,13 +491,22 @@ export interface PaymentItemData {
|
|
|
489
491
|
export interface OrderPaymentMetadata {
|
|
490
492
|
rounding_rule?: Record<string, any>;
|
|
491
493
|
unique_payment_number?: string;
|
|
494
|
+
/** 刷卡机设备快照;OS 不解析内部字段,仅透传并持久化 */
|
|
495
|
+
card_reader_snapshot?: Record<string, unknown>;
|
|
492
496
|
shop_wallet_pass_id?: number | string;
|
|
493
497
|
actual_paid_amount?: number | string;
|
|
494
498
|
change_given_amount?: number | string;
|
|
499
|
+
transactions?: OrderPaymentTransaction[];
|
|
495
500
|
[key: string]: any;
|
|
496
501
|
}
|
|
502
|
+
export interface OrderPaymentTransaction {
|
|
503
|
+
number: string;
|
|
504
|
+
status: 'success' | 'fail';
|
|
505
|
+
}
|
|
497
506
|
export interface OrderPaymentData {
|
|
498
507
|
order_payment_id?: number | string;
|
|
508
|
+
/** 支付项稳定唯一号;历史支付项允许缺失 */
|
|
509
|
+
payment_number?: string;
|
|
499
510
|
amount: string;
|
|
500
511
|
code: string;
|
|
501
512
|
custom_payment_id: number;
|
|
@@ -522,6 +533,15 @@ export interface OrderPaymentData {
|
|
|
522
533
|
created_at?: string;
|
|
523
534
|
updated_at?: string;
|
|
524
535
|
}
|
|
536
|
+
export interface OrderPaymentUpdateOptions {
|
|
537
|
+
matchBy?: 'payment_number' | 'compat' | 'legacy';
|
|
538
|
+
}
|
|
539
|
+
export interface OrderPaymentUpdateResult {
|
|
540
|
+
updated: boolean;
|
|
541
|
+
payment: OrderPaymentData | null;
|
|
542
|
+
payments: OrderPaymentData[];
|
|
543
|
+
summary: OrderSummary | null;
|
|
544
|
+
}
|
|
525
545
|
export type OrderPaymentSource = PaymentItem | OrderPaymentData | Record<string, any>;
|
|
526
546
|
export interface MapOrderPaymentsOptions {
|
|
527
547
|
includeVoided?: boolean;
|
|
@@ -672,6 +692,14 @@ export interface OrderModuleAPI {
|
|
|
672
692
|
channel?: string;
|
|
673
693
|
type?: string;
|
|
674
694
|
}) => OrderSubmitPayload;
|
|
695
|
+
saveTempOrderAsDraft: <T = any>(params?: {
|
|
696
|
+
cacheId?: string;
|
|
697
|
+
platform?: string;
|
|
698
|
+
businessCode?: string;
|
|
699
|
+
channel?: string;
|
|
700
|
+
type?: string;
|
|
701
|
+
enhancePayload?: SubmitPayloadEnhancer;
|
|
702
|
+
}) => Promise<T>;
|
|
675
703
|
applyLocalPrintOrderNumbers: (order?: Record<string, any> | null) => Promise<OrderTempOrder>;
|
|
676
704
|
getTempOrderNote: () => string;
|
|
677
705
|
updateTempOrderNote: {
|
|
@@ -729,11 +757,15 @@ export interface OrderModuleAPI {
|
|
|
729
757
|
getOrderPayments: () => OrderPaymentData[];
|
|
730
758
|
setOrderPayments: (payments: OrderPaymentSource[]) => OrderPaymentData[];
|
|
731
759
|
addOrderPayment: (payment: OrderPaymentSource) => OrderPaymentData[];
|
|
732
|
-
|
|
760
|
+
addOrderPaymentAsync: (payment: OrderPaymentSource) => Promise<OrderPaymentData[]>;
|
|
761
|
+
updateOrderPayment: (paymentIdentity: string | number, updates: Partial<OrderPaymentData> & Record<string, any>, options?: OrderPaymentUpdateOptions) => Promise<OrderPaymentUpdateResult>;
|
|
733
762
|
deleteOrderPayment: (paymentIdentity: string | number) => OrderPaymentData[];
|
|
734
763
|
updateVoucherOrderPayments: (payments: OrderPaymentSource[], options?: {
|
|
735
764
|
status?: 'paid' | 'payment_pending';
|
|
736
765
|
}) => OrderPaymentData[];
|
|
766
|
+
updateVoucherOrderPaymentsAsync: (payments: OrderPaymentSource[], options?: {
|
|
767
|
+
status?: 'paid' | 'payment_pending';
|
|
768
|
+
}) => Promise<OrderPaymentData[]>;
|
|
737
769
|
confirmPendingVoucherPayments: (options?: {
|
|
738
770
|
persist?: boolean;
|
|
739
771
|
recalculateSummary?: boolean;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export type OrderCollectionKind = 'product' | 'booking' | 'payment';
|
|
2
|
+
export interface OrderCollectionIdentityStats {
|
|
3
|
+
backfilledUidCount: number;
|
|
4
|
+
collapsedDuplicateCount: number;
|
|
5
|
+
uidConflictCount: number;
|
|
6
|
+
anonymousRowCount: number;
|
|
7
|
+
}
|
|
8
|
+
export interface OrderCollectionUidRemap {
|
|
9
|
+
kind: OrderCollectionKind;
|
|
10
|
+
from: string;
|
|
11
|
+
to: string;
|
|
12
|
+
persistentId: string | null;
|
|
13
|
+
/** 默认全局迁移;UID 冲突时只能迁移能由另一侧 UID 明确定位的引用。 */
|
|
14
|
+
scope?: 'global' | 'linked-owner';
|
|
15
|
+
referenceOwnerUid?: string | null;
|
|
16
|
+
}
|
|
17
|
+
export interface NormalizeOrderCollectionResult<T> {
|
|
18
|
+
items: T[];
|
|
19
|
+
stats: OrderCollectionIdentityStats;
|
|
20
|
+
uidRemaps: OrderCollectionUidRemap[];
|
|
21
|
+
}
|
|
22
|
+
export interface NormalizeOrderCollectionsResult<T> {
|
|
23
|
+
order: T;
|
|
24
|
+
stats: Record<OrderCollectionKind, OrderCollectionIdentityStats>;
|
|
25
|
+
uidRemaps: OrderCollectionUidRemap[];
|
|
26
|
+
}
|
|
27
|
+
export declare function createUuidV4(): string;
|
|
28
|
+
export declare function isBlankOrderCollectionIdentity(value: unknown): boolean;
|
|
29
|
+
export declare function getOrderCollectionPersistentId(kind: OrderCollectionKind, item: unknown): string | null;
|
|
30
|
+
export declare function getOrderCollectionUid(kind: OrderCollectionKind, item: unknown): string | null;
|
|
31
|
+
export declare function buildOrderCollectionFallbackUid(kind: OrderCollectionKind, persistentId: string | number): string;
|
|
32
|
+
export declare function getOrderCollectionReferenceUid(kind: OrderCollectionKind, item: unknown): string | null;
|
|
33
|
+
export declare function setOrderCollectionUid<T>(kind: OrderCollectionKind, item: T, uid: string): T;
|
|
34
|
+
/**
|
|
35
|
+
* 持久化行 ID 是服务端事实主键;只有至少一侧尚未持久化时,才允许用 runtime UID 对齐。
|
|
36
|
+
*/
|
|
37
|
+
export declare function isSameOrderCollectionItem(kind: OrderCollectionKind, left: unknown, right: unknown): boolean;
|
|
38
|
+
export declare function mergeOrderCollectionItems<T>(kind: OrderCollectionKind, currentItem: T, incomingItem: T, options?: {
|
|
39
|
+
ensureUid?: boolean;
|
|
40
|
+
createAnonymousUid?: () => string;
|
|
41
|
+
}): T;
|
|
42
|
+
/**
|
|
43
|
+
* 规范化单一数组:强身份重复时保留首次位置、用最后一条业务字段覆盖,并统一补 UID。
|
|
44
|
+
*/
|
|
45
|
+
export declare function normalizeOrderCollection<T>(kind: OrderCollectionKind, items: T[] | null | undefined, options?: {
|
|
46
|
+
ensureUid?: boolean;
|
|
47
|
+
createAnonymousUid?: () => string;
|
|
48
|
+
}): NormalizeOrderCollectionResult<T>;
|
|
49
|
+
export declare function applyOrderCollectionUidRemaps<T extends Record<string, any>>(sourceOrder: T, uidRemaps: OrderCollectionUidRemap[]): T;
|
|
50
|
+
export declare function normalizeOrderCollections<T extends Record<string, any>>(sourceOrder: T, options?: {
|
|
51
|
+
ensureUid?: boolean;
|
|
52
|
+
createAnonymousUid?: () => string;
|
|
53
|
+
}): NormalizeOrderCollectionsResult<T>;
|