@pisell/pisellos 2.3.39 → 2.3.41
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/core/index.d.ts +2 -0
- package/dist/core/index.js +7 -0
- package/dist/model/strategy/adapter/promotion/adapter.d.ts +4 -0
- package/dist/model/strategy/adapter/promotion/adapter.js +23 -0
- package/dist/model/strategy/adapter/promotion/evaluator.d.ts +17 -0
- package/dist/model/strategy/adapter/promotion/evaluator.js +279 -6
- package/dist/model/strategy/adapter/promotion/examples.d.ts +86 -0
- package/dist/model/strategy/adapter/promotion/examples.js +99 -0
- package/dist/model/strategy/adapter/promotion/index.d.ts +1 -1
- package/dist/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/model/strategy/adapter/promotion/type.d.ts +90 -2
- package/dist/model/strategy/adapter/promotion/type.js +45 -0
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +5 -3
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +6 -3
- package/dist/modules/Discount/index.d.ts +0 -1
- package/dist/modules/Discount/index.js +11 -40
- package/dist/modules/Discount/types.d.ts +0 -1
- package/dist/modules/OpenData/index.d.ts +2 -0
- package/dist/modules/OpenData/index.js +10 -2
- package/dist/modules/Order/index.d.ts +29 -12
- package/dist/modules/Order/index.js +750 -509
- package/dist/modules/Order/payment-utils.d.ts +26 -0
- package/dist/modules/Order/payment-utils.js +225 -0
- package/dist/modules/Order/types.d.ts +33 -10
- package/dist/modules/Order/utils/orderCollectionIdentity.js +7 -2
- package/dist/modules/Order/utils.d.ts +0 -10
- package/dist/modules/Order/utils.js +13 -41
- package/dist/modules/Payment/index.d.ts +2 -0
- package/dist/modules/Payment/index.js +79 -50
- package/dist/modules/Payment/types.d.ts +99 -28
- package/dist/modules/Payment/types.js +20 -3
- package/dist/modules/Payment/walletpass.d.ts +25 -1
- package/dist/modules/Payment/walletpass.js +707 -157
- package/dist/modules/Product/types.d.ts +0 -1
- package/dist/modules/ProductList/index.js +14 -33
- package/dist/modules/Quotation/index.d.ts +1 -1
- package/dist/modules/Quotation/index.js +2 -2
- package/dist/modules/Rules/index.d.ts +1 -0
- package/dist/modules/Rules/index.js +89 -96
- package/dist/modules/SalesSummary/index.js +13 -12
- package/dist/modules/ScanOrderLogger/index.d.ts +0 -2
- package/dist/modules/ScanOrderLogger/index.js +2 -15
- package/dist/modules/ScanOrderLogger/providers/feishu.js +27 -45
- package/dist/modules/ScanOrderLogger/types.d.ts +0 -1
- package/dist/modules/Schedule/index.d.ts +1 -3
- package/dist/modules/Schedule/index.js +16 -21
- package/dist/modules/Summary/utils.js +13 -38
- package/dist/modules/index.d.ts +0 -2
- package/dist/modules/index.js +1 -3
- package/dist/plugins/window.d.ts +0 -1
- package/dist/server/index.d.ts +16 -14
- package/dist/server/index.js +1925 -1143
- package/dist/server/modules/order/index.d.ts +54 -4
- package/dist/server/modules/order/index.js +1600 -700
- 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 +109 -20
- package/dist/solution/BaseSales/index.js +1800 -480
- package/dist/solution/BaseSales/types.d.ts +52 -0
- package/dist/solution/BaseSales/types.js +2 -1
- package/dist/solution/BaseSales/utils/cartPromotion.d.ts +3 -1
- package/dist/solution/BaseSales/utils/cartPromotion.js +90 -31
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +6 -1
- package/dist/solution/BookingByStep/index.d.ts +2 -17
- package/dist/solution/BookingByStep/index.js +215 -294
- package/dist/solution/BookingByStep/types.d.ts +1 -2
- package/dist/solution/BookingByStep/types.js +1 -3
- package/dist/solution/BookingByStep/utils/capacity.js +1 -17
- package/dist/solution/BookingByStep/utils/timeslots.d.ts +1 -3
- package/dist/solution/BookingByStep/utils/timeslots.js +12 -19
- package/dist/solution/BookingTicket/index.d.ts +7 -3
- package/dist/solution/BookingTicket/index.js +132 -49
- package/dist/solution/BookingTicket/utils/addProductDecision.js +6 -0
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +8 -0
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +172 -82
- package/dist/solution/BookingTicket/utils/weighingProductSku.d.ts +5 -0
- package/dist/solution/BookingTicket/utils/weighingProductSku.js +45 -0
- package/dist/solution/Sales/index.d.ts +1 -0
- package/dist/solution/Sales/index.js +10 -2
- package/dist/solution/ScanOrder/index.d.ts +14 -26
- package/dist/solution/ScanOrder/index.js +756 -1148
- package/dist/solution/ScanOrder/types.d.ts +1 -21
- package/dist/solution/ScanOrder/utils.d.ts +0 -8
- package/dist/solution/ScanOrder/utils.js +25 -66
- package/dist/solution/ShopDiscount/index.d.ts +0 -1
- package/dist/solution/ShopDiscount/index.js +87 -125
- package/dist/solution/VenueBooking/index.d.ts +11 -39
- package/dist/solution/VenueBooking/index.js +860 -1176
- package/dist/solution/VenueBooking/types.d.ts +0 -3
- package/dist/solution/VenueBooking/utils/resource.js +0 -1
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
- package/dist/solution/VenueBooking/utils/slotMerge.js +5 -10
- package/dist/solution/index.d.ts +0 -1
- package/dist/solution/index.js +1 -2
- package/dist/types/index.d.ts +1 -1
- package/dist/utils/payment-number.d.ts +9 -0
- package/dist/utils/payment-number.js +69 -0
- package/lib/core/index.d.ts +2 -0
- package/lib/core/index.js +4 -0
- package/lib/model/strategy/adapter/promotion/adapter.d.ts +4 -0
- package/lib/model/strategy/adapter/promotion/adapter.js +20 -0
- package/lib/model/strategy/adapter/promotion/evaluator.d.ts +17 -0
- package/lib/model/strategy/adapter/promotion/evaluator.js +235 -0
- package/lib/model/strategy/adapter/promotion/examples.d.ts +86 -0
- package/lib/model/strategy/adapter/promotion/examples.js +91 -0
- package/lib/model/strategy/adapter/promotion/index.d.ts +1 -1
- package/lib/model/strategy/adapter/promotion/index.js +51 -0
- package/lib/model/strategy/adapter/promotion/type.d.ts +90 -2
- package/lib/model/strategy/adapter/promotion/type.js +2 -0
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +2 -1
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +2 -1
- package/lib/modules/Discount/index.d.ts +0 -1
- package/lib/modules/Discount/index.js +0 -9
- package/lib/modules/Discount/types.d.ts +0 -1
- package/lib/modules/OpenData/index.d.ts +2 -0
- package/lib/modules/OpenData/index.js +6 -1
- package/lib/modules/Order/index.d.ts +29 -12
- package/lib/modules/Order/index.js +196 -86
- package/lib/modules/Order/payment-utils.d.ts +26 -0
- package/lib/modules/Order/payment-utils.js +224 -0
- package/lib/modules/Order/types.d.ts +33 -10
- package/lib/modules/Order/utils/orderCollectionIdentity.js +3 -0
- package/lib/modules/Order/utils.d.ts +0 -10
- package/lib/modules/Order/utils.js +16 -40
- package/lib/modules/Payment/index.d.ts +2 -0
- package/lib/modules/Payment/index.js +34 -13
- package/lib/modules/Payment/types.d.ts +99 -28
- package/lib/modules/Payment/types.js +4 -3
- package/lib/modules/Payment/walletpass.d.ts +25 -1
- package/lib/modules/Payment/walletpass.js +470 -21
- package/lib/modules/Product/types.d.ts +0 -1
- package/lib/modules/ProductList/index.js +31 -40
- package/lib/modules/Quotation/index.d.ts +1 -1
- package/lib/modules/Quotation/index.js +2 -2
- package/lib/modules/Rules/index.d.ts +1 -0
- package/lib/modules/Rules/index.js +47 -40
- package/lib/modules/SalesSummary/index.js +7 -6
- package/lib/modules/ScanOrderLogger/index.d.ts +0 -2
- package/lib/modules/ScanOrderLogger/index.js +1 -13
- package/lib/modules/ScanOrderLogger/providers/feishu.js +6 -15
- package/lib/modules/ScanOrderLogger/types.d.ts +0 -1
- package/lib/modules/Schedule/index.d.ts +1 -3
- package/lib/modules/Schedule/index.js +8 -10
- package/lib/modules/Summary/utils.js +1 -21
- package/lib/modules/index.d.ts +0 -2
- package/lib/modules/index.js +1 -5
- package/lib/plugins/window.d.ts +0 -1
- package/lib/server/index.d.ts +16 -14
- package/lib/server/index.js +675 -83
- package/lib/server/modules/order/index.d.ts +54 -4
- package/lib/server/modules/order/index.js +679 -66
- package/lib/server/modules/order/types.d.ts +11 -3
- package/lib/solution/BaseSales/index.d.ts +109 -20
- package/lib/solution/BaseSales/index.js +883 -70
- package/lib/solution/BaseSales/types.d.ts +52 -0
- package/lib/solution/BaseSales/types.js +2 -1
- package/lib/solution/BaseSales/utils/cartPromotion.d.ts +3 -1
- package/lib/solution/BaseSales/utils/cartPromotion.js +63 -12
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +6 -1
- package/lib/solution/BookingByStep/index.d.ts +2 -17
- package/lib/solution/BookingByStep/index.js +18 -60
- package/lib/solution/BookingByStep/types.d.ts +1 -2
- package/lib/solution/BookingByStep/types.js +0 -5
- package/lib/solution/BookingByStep/utils/capacity.js +1 -20
- package/lib/solution/BookingByStep/utils/timeslots.d.ts +1 -3
- package/lib/solution/BookingByStep/utils/timeslots.js +11 -19
- package/lib/solution/BookingTicket/index.d.ts +7 -3
- package/lib/solution/BookingTicket/index.js +62 -9
- package/lib/solution/BookingTicket/utils/addProductDecision.js +4 -0
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +8 -0
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +36 -4
- package/lib/solution/BookingTicket/utils/weighingProductSku.d.ts +5 -0
- package/lib/solution/BookingTicket/utils/weighingProductSku.js +63 -0
- package/lib/solution/Sales/index.d.ts +1 -0
- package/lib/solution/Sales/index.js +5 -3
- package/lib/solution/ScanOrder/index.d.ts +14 -26
- package/lib/solution/ScanOrder/index.js +190 -449
- package/lib/solution/ScanOrder/types.d.ts +1 -21
- package/lib/solution/ScanOrder/utils.d.ts +0 -8
- package/lib/solution/ScanOrder/utils.js +0 -31
- package/lib/solution/ShopDiscount/index.d.ts +0 -1
- package/lib/solution/ShopDiscount/index.js +0 -14
- package/lib/solution/VenueBooking/index.d.ts +11 -39
- package/lib/solution/VenueBooking/index.js +123 -328
- package/lib/solution/VenueBooking/types.d.ts +0 -3
- package/lib/solution/VenueBooking/utils/resource.js +0 -1
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
- package/lib/solution/VenueBooking/utils/slotMerge.js +4 -6
- package/lib/solution/index.d.ts +0 -1
- package/lib/solution/index.js +1 -3
- package/lib/types/index.d.ts +1 -1
- package/lib/utils/payment-number.d.ts +9 -0
- package/lib/utils/payment-number.js +64 -0
- package/package.json +1 -1
- package/dist/modules/Holder/index.d.ts +0 -48
- package/dist/modules/Holder/index.js +0 -640
- package/dist/modules/Holder/types.d.ts +0 -123
- package/dist/modules/Holder/types.js +0 -1
- package/dist/modules/Holder/utils.d.ts +0 -13
- package/dist/modules/Holder/utils.js +0 -34
- package/dist/modules/ResourcePlanner/index.d.ts +0 -24
- package/dist/modules/ResourcePlanner/index.js +0 -181
- package/dist/modules/ResourcePlanner/planner.d.ts +0 -14
- package/dist/modules/ResourcePlanner/planner.js +0 -1069
- package/dist/modules/ResourcePlanner/types.d.ts +0 -227
- package/dist/modules/ResourcePlanner/types.js +0 -1
- package/dist/solution/UnifiedBookingSales/index.d.ts +0 -183
- package/dist/solution/UnifiedBookingSales/index.js +0 -1871
- package/dist/solution/UnifiedBookingSales/types.d.ts +0 -143
- package/dist/solution/UnifiedBookingSales/types.js +0 -11
- package/lib/modules/Holder/index.d.ts +0 -48
- package/lib/modules/Holder/index.js +0 -402
- package/lib/modules/Holder/types.d.ts +0 -123
- package/lib/modules/Holder/types.js +0 -17
- package/lib/modules/Holder/utils.d.ts +0 -13
- package/lib/modules/Holder/utils.js +0 -71
- package/lib/modules/ResourcePlanner/index.d.ts +0 -24
- package/lib/modules/ResourcePlanner/index.js +0 -148
- package/lib/modules/ResourcePlanner/planner.d.ts +0 -14
- package/lib/modules/ResourcePlanner/planner.js +0 -933
- package/lib/modules/ResourcePlanner/types.d.ts +0 -227
- package/lib/modules/ResourcePlanner/types.js +0 -17
- package/lib/solution/UnifiedBookingSales/index.d.ts +0 -183
- package/lib/solution/UnifiedBookingSales/index.js +0 -1076
- package/lib/solution/UnifiedBookingSales/types.d.ts +0 -143
- package/lib/solution/UnifiedBookingSales/types.js +0 -33
|
@@ -0,0 +1,224 @@
|
|
|
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
|
+
});
|
|
@@ -394,7 +394,6 @@ export interface CommitOrderParams {
|
|
|
394
394
|
type: 'virtual' | 'appointment_booking';
|
|
395
395
|
platform?: string;
|
|
396
396
|
extraData?: Record<string, any>;
|
|
397
|
-
business_code?: string;
|
|
398
397
|
};
|
|
399
398
|
}
|
|
400
399
|
export interface OrderSubmitBooking {
|
|
@@ -469,6 +468,8 @@ export interface SubmitSalesOrderParams {
|
|
|
469
468
|
export interface PaymentItemData {
|
|
470
469
|
/** 当前支付项的唯一 ID */
|
|
471
470
|
uuid: string;
|
|
471
|
+
/** 支付项稳定唯一号 */
|
|
472
|
+
payment_number?: string;
|
|
472
473
|
/** 当前支付方式付出去多少钱 */
|
|
473
474
|
amount: string;
|
|
474
475
|
/** 支付类型代码 */
|
|
@@ -491,13 +492,22 @@ export interface PaymentItemData {
|
|
|
491
492
|
export interface OrderPaymentMetadata {
|
|
492
493
|
rounding_rule?: Record<string, any>;
|
|
493
494
|
unique_payment_number?: string;
|
|
495
|
+
/** 刷卡机设备快照;OS 不解析内部字段,仅透传并持久化 */
|
|
496
|
+
card_reader_snapshot?: Record<string, unknown>;
|
|
494
497
|
shop_wallet_pass_id?: number | string;
|
|
495
498
|
actual_paid_amount?: number | string;
|
|
496
499
|
change_given_amount?: number | string;
|
|
500
|
+
transactions?: OrderPaymentTransaction[];
|
|
497
501
|
[key: string]: any;
|
|
498
502
|
}
|
|
503
|
+
export interface OrderPaymentTransaction {
|
|
504
|
+
number: string;
|
|
505
|
+
status: 'success' | 'fail';
|
|
506
|
+
}
|
|
499
507
|
export interface OrderPaymentData {
|
|
500
508
|
order_payment_id?: number | string;
|
|
509
|
+
/** 支付项稳定唯一号;历史支付项允许缺失 */
|
|
510
|
+
payment_number?: string;
|
|
501
511
|
amount: string;
|
|
502
512
|
code: string;
|
|
503
513
|
custom_payment_id: number;
|
|
@@ -524,6 +534,15 @@ export interface OrderPaymentData {
|
|
|
524
534
|
created_at?: string;
|
|
525
535
|
updated_at?: string;
|
|
526
536
|
}
|
|
537
|
+
export interface OrderPaymentUpdateOptions {
|
|
538
|
+
matchBy?: 'payment_number' | 'compat' | 'legacy';
|
|
539
|
+
}
|
|
540
|
+
export interface OrderPaymentUpdateResult {
|
|
541
|
+
updated: boolean;
|
|
542
|
+
payment: OrderPaymentData | null;
|
|
543
|
+
payments: OrderPaymentData[];
|
|
544
|
+
summary: OrderSummary | null;
|
|
545
|
+
}
|
|
527
546
|
export type OrderPaymentSource = PaymentItem | OrderPaymentData | Record<string, any>;
|
|
528
547
|
export interface MapOrderPaymentsOptions {
|
|
529
548
|
includeVoided?: boolean;
|
|
@@ -550,12 +569,6 @@ export interface SyncPaymentsToOrderParams {
|
|
|
550
569
|
payments: OrderPaymentSource[];
|
|
551
570
|
paymentStatus?: SubmitSalesOrderParams['query']['payment_status'];
|
|
552
571
|
submitWhenPaid?: boolean;
|
|
553
|
-
/**
|
|
554
|
-
* Whether the checkout should be queued as the local `sync_sales` task.
|
|
555
|
-
* Defaults to true to preserve the WebPOS retry path. Set to false when
|
|
556
|
-
* the caller must wait for the cloud checkout response before proceeding.
|
|
557
|
-
*/
|
|
558
|
-
checkoutSyncTaskEnabled?: boolean;
|
|
559
572
|
smallTicketDataFlag?: number;
|
|
560
573
|
businessCode?: string;
|
|
561
574
|
channel?: string;
|
|
@@ -680,6 +693,14 @@ export interface OrderModuleAPI {
|
|
|
680
693
|
channel?: string;
|
|
681
694
|
type?: string;
|
|
682
695
|
}) => OrderSubmitPayload;
|
|
696
|
+
saveTempOrderAsDraft: <T = any>(params?: {
|
|
697
|
+
cacheId?: string;
|
|
698
|
+
platform?: string;
|
|
699
|
+
businessCode?: string;
|
|
700
|
+
channel?: string;
|
|
701
|
+
type?: string;
|
|
702
|
+
enhancePayload?: SubmitPayloadEnhancer;
|
|
703
|
+
}) => Promise<T>;
|
|
683
704
|
applyLocalPrintOrderNumbers: (order?: Record<string, any> | null) => Promise<OrderTempOrder>;
|
|
684
705
|
getTempOrderNote: () => string;
|
|
685
706
|
updateTempOrderNote: {
|
|
@@ -710,8 +731,6 @@ export interface OrderModuleAPI {
|
|
|
710
731
|
setEnableTempOrderPersist: (enabled: boolean) => void;
|
|
711
732
|
/** 是否允许 saveDraft 写入 IndexedDB 草稿。 */
|
|
712
733
|
isTempOrderPersistEnabled: () => boolean;
|
|
713
|
-
/** 提交 tempOrder 变更并触发 `{moduleName}:changed` 事件 */
|
|
714
|
-
notifyTempOrderChanged: () => void;
|
|
715
734
|
submitTempOrder: <T = any>(params?: {
|
|
716
735
|
cacheId?: string;
|
|
717
736
|
platform?: string;
|
|
@@ -739,11 +758,15 @@ export interface OrderModuleAPI {
|
|
|
739
758
|
getOrderPayments: () => OrderPaymentData[];
|
|
740
759
|
setOrderPayments: (payments: OrderPaymentSource[]) => OrderPaymentData[];
|
|
741
760
|
addOrderPayment: (payment: OrderPaymentSource) => OrderPaymentData[];
|
|
742
|
-
|
|
761
|
+
addOrderPaymentAsync: (payment: OrderPaymentSource) => Promise<OrderPaymentData[]>;
|
|
762
|
+
updateOrderPayment: (paymentIdentity: string | number, updates: Partial<OrderPaymentData> & Record<string, any>, options?: OrderPaymentUpdateOptions) => Promise<OrderPaymentUpdateResult>;
|
|
743
763
|
deleteOrderPayment: (paymentIdentity: string | number) => OrderPaymentData[];
|
|
744
764
|
updateVoucherOrderPayments: (payments: OrderPaymentSource[], options?: {
|
|
745
765
|
status?: 'paid' | 'payment_pending';
|
|
746
766
|
}) => OrderPaymentData[];
|
|
767
|
+
updateVoucherOrderPaymentsAsync: (payments: OrderPaymentSource[], options?: {
|
|
768
|
+
status?: 'paid' | 'payment_pending';
|
|
769
|
+
}) => Promise<OrderPaymentData[]>;
|
|
747
770
|
confirmPendingVoucherPayments: (options?: {
|
|
748
771
|
persist?: boolean;
|
|
749
772
|
recalculateSummary?: boolean;
|
|
@@ -220,6 +220,9 @@ function normalizeOrderCollection(kind, items, options) {
|
|
|
220
220
|
const persistentId = getOrderCollectionPersistentId(kind, item);
|
|
221
221
|
let uid = getOrderCollectionUid(kind, item);
|
|
222
222
|
if (!uid) {
|
|
223
|
+
if (kind === "payment" && !isBlankOrderCollectionIdentity(item == null ? void 0 : item.payment_number)) {
|
|
224
|
+
continue;
|
|
225
|
+
}
|
|
223
226
|
uid = persistentId ? buildOrderCollectionFallbackUid(kind, persistentId) : allocateAnonymousUid(occupiedUids, createAnonymousUid);
|
|
224
227
|
item = setOrderCollectionUid(kind, item, uid);
|
|
225
228
|
result[index] = item;
|
|
@@ -15,7 +15,6 @@ export interface OrderProductsDepositSummary {
|
|
|
15
15
|
deposit_policy_ids: number[];
|
|
16
16
|
hasDeposit: boolean;
|
|
17
17
|
}
|
|
18
|
-
import type { WindowPlugin } from '../../plugins';
|
|
19
18
|
/**
|
|
20
19
|
* 把"含 option 的主商品单价"与 bundle 合成"单行 composite 单价"。
|
|
21
20
|
*
|
|
@@ -178,15 +177,6 @@ export declare const mergeRelationForms: (relationForms: {
|
|
|
178
177
|
form_id: number;
|
|
179
178
|
form_record_ids: number[];
|
|
180
179
|
}[];
|
|
181
|
-
export interface CartOrderHolder {
|
|
182
|
-
customer_id?: number;
|
|
183
|
-
form_id: number | string;
|
|
184
|
-
form_record: (number | string)[] | null;
|
|
185
|
-
}
|
|
186
|
-
/**
|
|
187
|
-
* 为购物车行补齐订单所需的 holder 信息(与 cartAccount 结构保持一致)
|
|
188
|
-
*/
|
|
189
|
-
export declare function ensureCartItemOriginHolder(cartItem: CartItem, window?: WindowPlugin): void;
|
|
190
180
|
export declare const getAllDiscountList: (cartItem: CartItem) => any;
|
|
191
181
|
export { createUuidV4 };
|
|
192
182
|
export declare function isTempOrder(data: any): data is OrderTempOrder;
|
|
@@ -36,9 +36,8 @@ __export(utils_exports, {
|
|
|
36
36
|
composeLinePrice: () => composeLinePrice,
|
|
37
37
|
createDefaultOrderRulesHooks: () => createDefaultOrderRulesHooks,
|
|
38
38
|
createDefaultTempOrder: () => createDefaultTempOrder,
|
|
39
|
-
createEmptySummary: () =>
|
|
39
|
+
createEmptySummary: () => import_utils2.createEmptySummary,
|
|
40
40
|
createUuidV4: () => import_orderCollectionIdentity.createUuidV4,
|
|
41
|
-
ensureCartItemOriginHolder: () => ensureCartItemOriginHolder,
|
|
42
41
|
ensureManualProductDiscountList: () => import_manualProductDiscount.ensureManualProductDiscountList,
|
|
43
42
|
ensureProductSku: () => ensureProductSku,
|
|
44
43
|
findManualProductDiscountItem: () => import_manualProductDiscount.findManualProductDiscountItem,
|
|
@@ -86,10 +85,9 @@ __export(utils_exports, {
|
|
|
86
85
|
module.exports = __toCommonJS(utils_exports);
|
|
87
86
|
var import_dayjs = __toESM(require("dayjs"));
|
|
88
87
|
var import_decimal = __toESM(require("decimal.js"));
|
|
89
|
-
var import_utils = require("
|
|
90
|
-
var import_utils2 = require("../../solution/ScanOrder/utils");
|
|
88
|
+
var import_utils = require("../../solution/ScanOrder/utils");
|
|
91
89
|
var import_orderCollectionIdentity = require("./utils/orderCollectionIdentity");
|
|
92
|
-
var
|
|
90
|
+
var import_utils2 = require("../../solution/ScanOrder/utils");
|
|
93
91
|
var import_manualProductDiscount = require("./utils/manualProductDiscount");
|
|
94
92
|
function composeLinePrice(params) {
|
|
95
93
|
const { mainPrice, bundle, useOriginalBundle } = params;
|
|
@@ -446,7 +444,12 @@ function resolveEffectivePerUnitDiscount(product) {
|
|
|
446
444
|
(sum, discount) => sum + Number((discount == null ? void 0 : discount.amount) || 0),
|
|
447
445
|
0
|
|
448
446
|
);
|
|
449
|
-
const hasPromoDiscountItem = discountList.some(
|
|
447
|
+
const hasPromoDiscountItem = discountList.some(
|
|
448
|
+
(item) => {
|
|
449
|
+
var _a, _b;
|
|
450
|
+
return (item == null ? void 0 : item.type) === "promotion" || (item == null ? void 0 : item.type) === "product" && ((_a = item == null ? void 0 : item.metadata) == null ? void 0 : _a.source) === "promotion" && ((_b = item == null ? void 0 : item.metadata) == null ? void 0 : _b.actionType) === "ITEM_REWARD";
|
|
451
|
+
}
|
|
452
|
+
);
|
|
450
453
|
if (hasPromoDiscountItem)
|
|
451
454
|
return fromList;
|
|
452
455
|
const metadata = (product == null ? void 0 : product.metadata) || {};
|
|
@@ -543,7 +546,7 @@ function createDefaultOrderRulesHooks() {
|
|
|
543
546
|
// 否则同 SKU 不同小料会在 calcDiscount 重组时互相覆盖。
|
|
544
547
|
// 不透明 identity 契约下,normalizeOrderProduct / hydrate 已保证唯一值存在;
|
|
545
548
|
// 留 fingerprint 分支仅作 Rules 单测里直接传裸 product 时的兜底。
|
|
546
|
-
_id: ((_a = product.metadata) == null ? void 0 : _a.unique_identification_number) ? `${product.product_id}_${product.product_variant_id}_${product.metadata.unique_identification_number}` : `${product.product_id}_${product.product_variant_id}_${(0,
|
|
549
|
+
_id: ((_a = product.metadata) == null ? void 0 : _a.unique_identification_number) ? `${product.product_id}_${product.product_variant_id}_${product.metadata.unique_identification_number}` : `${product.product_id}_${product.product_variant_id}_${(0, import_utils.buildProductLineFingerprint)(
|
|
547
550
|
getProductSkuOptions(product),
|
|
548
551
|
product.product_bundle
|
|
549
552
|
)}`,
|
|
@@ -635,34 +638,6 @@ var mergeRelationForms = (relationForms) => {
|
|
|
635
638
|
}, {})
|
|
636
639
|
).filter((item) => item.form_record_ids.length > 0);
|
|
637
640
|
};
|
|
638
|
-
function getCustomerIdFromStorage(window) {
|
|
639
|
-
var _a;
|
|
640
|
-
try {
|
|
641
|
-
const customer = JSON.parse(((_a = window == null ? void 0 : window.getLocalStorage) == null ? void 0 : _a.call(window, "customer")) || "{}");
|
|
642
|
-
const customerId = Number(customer == null ? void 0 : customer.id);
|
|
643
|
-
return Number.isFinite(customerId) && customerId > 0 ? customerId : void 0;
|
|
644
|
-
} catch {
|
|
645
|
-
return void 0;
|
|
646
|
-
}
|
|
647
|
-
}
|
|
648
|
-
function ensureCartItemOriginHolder(cartItem, window) {
|
|
649
|
-
var _a;
|
|
650
|
-
if ((_a = cartItem == null ? void 0 : cartItem._origin) == null ? void 0 : _a.holder) {
|
|
651
|
-
return;
|
|
652
|
-
}
|
|
653
|
-
const holderConfig = (0, import_utils.getProductHolderConfig)(
|
|
654
|
-
(cartItem == null ? void 0 : cartItem._productInit) ?? (cartItem == null ? void 0 : cartItem._productOrigin)
|
|
655
|
-
);
|
|
656
|
-
const formRecordId = cartItem == null ? void 0 : cartItem.holder_id;
|
|
657
|
-
if (!(holderConfig == null ? void 0 : holderConfig.resource_id) || formRecordId == null) {
|
|
658
|
-
return;
|
|
659
|
-
}
|
|
660
|
-
cartItem._origin.holder = {
|
|
661
|
-
customer_id: getCustomerIdFromStorage(window),
|
|
662
|
-
form_id: holderConfig.resource_id,
|
|
663
|
-
form_record: [formRecordId]
|
|
664
|
-
};
|
|
665
|
-
}
|
|
666
641
|
var getAllDiscountList = (cartItem) => {
|
|
667
642
|
var _a, _b, _c, _d;
|
|
668
643
|
let discountList = ((_b = (_a = cartItem == null ? void 0 : cartItem._origin) == null ? void 0 : _a.product) == null ? void 0 : _b.discount_list) || [];
|
|
@@ -995,6 +970,9 @@ function buildSubmitPayload(params) {
|
|
|
995
970
|
...tempOrderRest,
|
|
996
971
|
customer_id: tempOrder.customer_id ?? 1,
|
|
997
972
|
customer_name: tempOrder.customer_name || "Walk-In",
|
|
973
|
+
country_calling_code: String(tempOrder.country_calling_code ?? ""),
|
|
974
|
+
phone: String(tempOrder.phone ?? ""),
|
|
975
|
+
email: String(tempOrder.email ?? ""),
|
|
998
976
|
order_number: tempOrder.order_number ?? null,
|
|
999
977
|
shop_order_number: tempOrder.shop_order_number ?? null,
|
|
1000
978
|
shop_full_order_number: tempOrder.shop_full_order_number ?? null,
|
|
@@ -1025,7 +1003,7 @@ function buildSubmitPayload(params) {
|
|
|
1025
1003
|
// contacts: tempOrder.contacts || [],
|
|
1026
1004
|
contacts_info: tempOrder.contacts_info && !Array.isArray(tempOrder.contacts_info) ? tempOrder.contacts_info : null,
|
|
1027
1005
|
// holder: tempOrder.holder || null,
|
|
1028
|
-
summary: summary || tempOrder.summary || (0,
|
|
1006
|
+
summary: summary || tempOrder.summary || (0, import_utils.createEmptySummary)(),
|
|
1029
1007
|
metadata: (() => {
|
|
1030
1008
|
const {
|
|
1031
1009
|
collect_pax: _collectPax,
|
|
@@ -1050,9 +1028,7 @@ function mapPaymentItemToOrderPayment(paymentItem) {
|
|
|
1050
1028
|
const item = paymentItem;
|
|
1051
1029
|
const customPaymentId = item.custom_payment_id ?? item.id;
|
|
1052
1030
|
const metadata = item.metadata && typeof item.metadata === "object" ? { ...item.metadata } : {};
|
|
1053
|
-
|
|
1054
|
-
metadata.unique_payment_number = String(item.uuid);
|
|
1055
|
-
}
|
|
1031
|
+
const paymentNumber = item.payment_number;
|
|
1056
1032
|
const paymentMetadataKeys = [
|
|
1057
1033
|
"rounding_rule",
|
|
1058
1034
|
"shop_wallet_pass_id",
|
|
@@ -1069,6 +1045,7 @@ function mapPaymentItemToOrderPayment(paymentItem) {
|
|
|
1069
1045
|
const createdAt = item.created_at ?? timestamp;
|
|
1070
1046
|
return {
|
|
1071
1047
|
...item.order_payment_id !== void 0 ? { order_payment_id: item.order_payment_id } : {},
|
|
1048
|
+
...paymentNumber !== void 0 && paymentNumber !== null && paymentNumber !== "" ? { payment_number: String(paymentNumber) } : {},
|
|
1072
1049
|
amount: String(item.amount ?? "0.00"),
|
|
1073
1050
|
code: String(item.code || ""),
|
|
1074
1051
|
custom_payment_id: Number(customPaymentId ?? 0),
|
|
@@ -1275,7 +1252,6 @@ function indexOrderProductsByUid(products) {
|
|
|
1275
1252
|
createDefaultTempOrder,
|
|
1276
1253
|
createEmptySummary,
|
|
1277
1254
|
createUuidV4,
|
|
1278
|
-
ensureCartItemOriginHolder,
|
|
1279
1255
|
ensureManualProductDiscountList,
|
|
1280
1256
|
ensureProductSku,
|
|
1281
1257
|
findManualProductDiscountItem,
|
|
@@ -20,6 +20,7 @@ export declare class PaymentModule extends BaseModule implements Module, Payment
|
|
|
20
20
|
protected defaultVersion: string;
|
|
21
21
|
request: RequestPlugin;
|
|
22
22
|
private app;
|
|
23
|
+
private appPlugin;
|
|
23
24
|
private store;
|
|
24
25
|
window: WindowPlugin;
|
|
25
26
|
private dbManager;
|
|
@@ -40,6 +41,7 @@ export declare class PaymentModule extends BaseModule implements Module, Payment
|
|
|
40
41
|
* paymentModule.updateOtherParams({ fatherModule: 'bookingTicket' });
|
|
41
42
|
*/
|
|
42
43
|
updateOtherParams(params: Record<string, any>): void;
|
|
44
|
+
private getPaymentNumberAppData;
|
|
43
45
|
/**
|
|
44
46
|
* 记录信息日志
|
|
45
47
|
*/
|
|
@@ -31,6 +31,9 @@ var import_cash = require("./cash");
|
|
|
31
31
|
var import_eftpos = require("./eftpos");
|
|
32
32
|
var import_walletpass = require("./walletpass");
|
|
33
33
|
var import_decimal = require("decimal.js");
|
|
34
|
+
var import_payment_utils = require("../Order/payment-utils");
|
|
35
|
+
var import_utils2 = require("../Order/utils");
|
|
36
|
+
var import_payment_number = require("../../utils/payment-number");
|
|
34
37
|
__reExport(Payment_exports, require("./types"), module.exports);
|
|
35
38
|
function formatAmount(amount) {
|
|
36
39
|
try {
|
|
@@ -112,15 +115,15 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
|
|
|
112
115
|
this.store = options.store;
|
|
113
116
|
this.otherParams = options.otherParams || {};
|
|
114
117
|
this.request = core.getPlugin("request");
|
|
115
|
-
|
|
118
|
+
this.appPlugin = core.getPlugin("app");
|
|
116
119
|
this.window = core.getPlugin("window");
|
|
117
120
|
if (!this.request) {
|
|
118
121
|
throw new Error("支付模块需要 request 插件支持");
|
|
119
122
|
}
|
|
120
|
-
if (!appPlugin) {
|
|
123
|
+
if (!this.appPlugin) {
|
|
121
124
|
throw new Error("支付模块需要 app 插件支持");
|
|
122
125
|
}
|
|
123
|
-
this.app = appPlugin.getApp();
|
|
126
|
+
this.app = this.appPlugin.getApp();
|
|
124
127
|
this.dbManager = this.app.dbManager;
|
|
125
128
|
this.logger = this.app.logger;
|
|
126
129
|
this.registerNetworkHandlers();
|
|
@@ -136,6 +139,14 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
|
|
|
136
139
|
updateOtherParams(params) {
|
|
137
140
|
this.otherParams = params || {};
|
|
138
141
|
}
|
|
142
|
+
getPaymentNumberAppData(key) {
|
|
143
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
144
|
+
const getData = (_b = (_a = this.appPlugin) == null ? void 0 : _a.getData) == null ? void 0 : _b.call(_a);
|
|
145
|
+
if (typeof getData === "function")
|
|
146
|
+
return getData(key);
|
|
147
|
+
const coreData = (_g = (_e = (_d = (_c = this.app) == null ? void 0 : _c.models) == null ? void 0 : _d.getStore) == null ? void 0 : (_f = _e.call(_d)).getDataByModel) == null ? void 0 : _g.call(_f, "core", "core");
|
|
148
|
+
return coreData == null ? void 0 : coreData[key];
|
|
149
|
+
}
|
|
139
150
|
/**
|
|
140
151
|
* 记录信息日志
|
|
141
152
|
*/
|
|
@@ -521,15 +532,20 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
|
|
|
521
532
|
});
|
|
522
533
|
throw new Error(warningMessage);
|
|
523
534
|
}
|
|
524
|
-
|
|
525
|
-
if ((_a = paymentItem.metadata) == null ? void 0 : _a.unique_payment_number) {
|
|
526
|
-
paymentUuid = paymentItem.metadata.unique_payment_number;
|
|
527
|
-
} else {
|
|
528
|
-
paymentUuid = (0, import_utils.getUniqueId)("payment_");
|
|
529
|
-
}
|
|
535
|
+
const paymentUuid = paymentItem.uuid || ((_a = paymentItem.metadata) == null ? void 0 : _a.unique_payment_number) || (0, import_utils.getUniqueId)("payment_");
|
|
530
536
|
const currentTime = formatDateTime(/* @__PURE__ */ new Date());
|
|
537
|
+
const hasPaymentNumber = String(paymentItem.payment_number || "").trim() !== "";
|
|
538
|
+
const paymentNumberDevicePrefix = hasPaymentNumber ? "LOCAL" : await (0, import_payment_number.resolvePaymentNumberDevicePrefix)(
|
|
539
|
+
(key) => this.getPaymentNumberAppData(key)
|
|
540
|
+
);
|
|
541
|
+
const paymentNumber = (0, import_payment_utils.ensureOrderPaymentNumber)(
|
|
542
|
+
paymentItem,
|
|
543
|
+
paymentNumberDevicePrefix,
|
|
544
|
+
import_utils2.createUuidV4
|
|
545
|
+
).payment_number;
|
|
531
546
|
const newPaymentItem = {
|
|
532
547
|
uuid: paymentUuid,
|
|
548
|
+
payment_number: paymentNumber,
|
|
533
549
|
custom_payment_id: normalizeCustomPaymentId(paymentItem),
|
|
534
550
|
name: paymentItem.name,
|
|
535
551
|
code: paymentItem.code,
|
|
@@ -549,10 +565,8 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
|
|
|
549
565
|
updated_at: currentTime,
|
|
550
566
|
// 更新时间
|
|
551
567
|
metadata: {
|
|
552
|
-
...paymentItem.metadata
|
|
568
|
+
...paymentItem.metadata
|
|
553
569
|
// 保留传入的所有 metadata 字段
|
|
554
|
-
unique_payment_number: paymentUuid
|
|
555
|
-
// 设置唯一支付号为支付项的 uuid
|
|
556
570
|
}
|
|
557
571
|
};
|
|
558
572
|
order.payment.push(newPaymentItem);
|
|
@@ -767,6 +781,12 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
|
|
|
767
781
|
if ("amount" in formattedParams && formattedParams.amount !== void 0) {
|
|
768
782
|
formattedParams.amount = formatAmount(formattedParams.amount);
|
|
769
783
|
}
|
|
784
|
+
if (formattedParams.metadata && typeof formattedParams.metadata === "object") {
|
|
785
|
+
formattedParams.metadata = {
|
|
786
|
+
...paymentItem.metadata || {},
|
|
787
|
+
...formattedParams.metadata
|
|
788
|
+
};
|
|
789
|
+
}
|
|
770
790
|
Object.assign(paymentItem, formattedParams);
|
|
771
791
|
this.recalculateOrderAmount(order);
|
|
772
792
|
await this.dbManager.update("order", order);
|
|
@@ -824,6 +844,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
|
|
|
824
844
|
const paymentData = {
|
|
825
845
|
payments: order.payment.map((payment) => ({
|
|
826
846
|
uuid: payment.uuid,
|
|
847
|
+
payment_number: payment.payment_number,
|
|
827
848
|
amount: payment.amount,
|
|
828
849
|
code: payment.code,
|
|
829
850
|
custom_payment_id: payment.custom_payment_id,
|
|
@@ -1067,7 +1088,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
|
|
|
1067
1088
|
roundedValue = this.standardRound(baseValue, true);
|
|
1068
1089
|
break;
|
|
1069
1090
|
case import_types.RoundingRule.StandardDown:
|
|
1070
|
-
case "
|
|
1091
|
+
case "standard_rounding_midpoint_down":
|
|
1071
1092
|
roundedValue = this.standardRound(baseValue, false);
|
|
1072
1093
|
break;
|
|
1073
1094
|
case import_types.RoundingRule.AlwaysUp:
|