@pisell/pisellos 2.3.29 → 2.3.31
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 +27 -8
- package/dist/modules/Order/index.js +736 -473
- 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.js +4 -4
- 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/server/index.d.ts +14 -0
- package/dist/server/index.js +1850 -1024
- package/dist/server/modules/order/index.d.ts +40 -3
- package/dist/server/modules/order/index.js +1200 -501
- 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 +33 -3
- package/dist/solution/BaseSales/index.js +609 -322
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +6 -1
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -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/model/strategy/adapter/promotion/index.js +0 -49
- package/lib/modules/Order/index.d.ts +27 -8
- package/lib/modules/Order/index.js +180 -60
- 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.js +2 -3
- 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/server/index.d.ts +14 -0
- package/lib/server/index.js +604 -8
- package/lib/server/modules/order/index.d.ts +40 -3
- package/lib/server/modules/order/index.js +434 -31
- package/lib/server/modules/order/types.d.ts +11 -3
- package/lib/solution/BaseSales/index.d.ts +33 -3
- package/lib/solution/BaseSales/index.js +167 -7
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +6 -1
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +1 -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
|
@@ -1020,9 +1020,7 @@ function mapPaymentItemToOrderPayment(paymentItem) {
|
|
|
1020
1020
|
const item = paymentItem;
|
|
1021
1021
|
const customPaymentId = item.custom_payment_id ?? item.id;
|
|
1022
1022
|
const metadata = item.metadata && typeof item.metadata === "object" ? { ...item.metadata } : {};
|
|
1023
|
-
|
|
1024
|
-
metadata.unique_payment_number = String(item.uuid);
|
|
1025
|
-
}
|
|
1023
|
+
const paymentNumber = item.payment_number;
|
|
1026
1024
|
const paymentMetadataKeys = [
|
|
1027
1025
|
"rounding_rule",
|
|
1028
1026
|
"shop_wallet_pass_id",
|
|
@@ -1039,6 +1037,7 @@ function mapPaymentItemToOrderPayment(paymentItem) {
|
|
|
1039
1037
|
const createdAt = item.created_at ?? timestamp;
|
|
1040
1038
|
return {
|
|
1041
1039
|
...item.order_payment_id !== void 0 ? { order_payment_id: item.order_payment_id } : {},
|
|
1040
|
+
...paymentNumber !== void 0 && paymentNumber !== null && paymentNumber !== "" ? { payment_number: String(paymentNumber) } : {},
|
|
1042
1041
|
amount: String(item.amount ?? "0.00"),
|
|
1043
1042
|
code: String(item.code || ""),
|
|
1044
1043
|
custom_payment_id: Number(customPaymentId ?? 0),
|
|
@@ -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,
|
|
@@ -87,12 +87,30 @@ export interface PaymentMethod {
|
|
|
87
87
|
/** 其他配置信息 */
|
|
88
88
|
[key: string]: any;
|
|
89
89
|
}
|
|
90
|
+
/** 支付项扩展元数据 */
|
|
91
|
+
export interface PaymentItemMetadata {
|
|
92
|
+
/** 钱箱 ID */
|
|
93
|
+
shop_wallet_pass_id?: string;
|
|
94
|
+
/** 三方支付交易流水号 */
|
|
95
|
+
unique_payment_number?: string;
|
|
96
|
+
/** 刷卡机设备快照;PaymentModule 不解析内部字段 */
|
|
97
|
+
card_reader_snapshot?: Record<string, unknown>;
|
|
98
|
+
/** rounding 规则 */
|
|
99
|
+
rounding_rule?: any;
|
|
100
|
+
/** 实付金额(现金支付时的实际给出金额) */
|
|
101
|
+
actual_paid_amount?: number;
|
|
102
|
+
/** 找零金额(现金支付时的找零金额) */
|
|
103
|
+
change_given_amount?: number;
|
|
104
|
+
[key: string]: unknown;
|
|
105
|
+
}
|
|
90
106
|
/**
|
|
91
107
|
* 支付项
|
|
92
108
|
*/
|
|
93
109
|
export interface PaymentItem {
|
|
94
110
|
/** 当前支付项的唯一 ID */
|
|
95
111
|
uuid: string;
|
|
112
|
+
/** 支付项稳定唯一号 */
|
|
113
|
+
payment_number?: string;
|
|
96
114
|
/** 当前支付方式付出去多少钱 */
|
|
97
115
|
amount: string;
|
|
98
116
|
/** 支付类型,跟支付列表上对应的支付方式保持一致 */
|
|
@@ -110,18 +128,7 @@ export interface PaymentItem {
|
|
|
110
128
|
/** Wallet Pass 本次使用值 */
|
|
111
129
|
wallet_pass_use_value?: string | number | null;
|
|
112
130
|
/** 拓展参数字段 */
|
|
113
|
-
metadata?:
|
|
114
|
-
/** 钱箱 ID */
|
|
115
|
-
shop_wallet_pass_id?: string;
|
|
116
|
-
/** 唯一支付号 */
|
|
117
|
-
unique_payment_number?: string;
|
|
118
|
-
/** rouding规则 */
|
|
119
|
-
rounding_rule?: any;
|
|
120
|
-
/** 实付金额(现金支付时的实际给出金额) */
|
|
121
|
-
actual_paid_amount?: number;
|
|
122
|
-
/** 找零金额(现金支付时的找零金额) */
|
|
123
|
-
change_given_amount?: number;
|
|
124
|
-
};
|
|
131
|
+
metadata?: PaymentItemMetadata;
|
|
125
132
|
/** rouding金额 */
|
|
126
133
|
rounding_amount?: string;
|
|
127
134
|
/** 三方支付手续费 */
|
|
@@ -228,6 +235,10 @@ export interface UpdateOrderParams {
|
|
|
228
235
|
* 支付项输入类型(允许 amount 为数字)
|
|
229
236
|
*/
|
|
230
237
|
export interface PaymentItemInput {
|
|
238
|
+
/** 调用方已有的支付项运行态 UUID;存在时复用为 payment_number 的唯一号段 */
|
|
239
|
+
uuid?: string;
|
|
240
|
+
/** 支付项稳定唯一号 */
|
|
241
|
+
payment_number?: string;
|
|
231
242
|
/** 当前支付方式付出去多少钱 */
|
|
232
243
|
amount: string | number;
|
|
233
244
|
/** 支付类型,跟支付列表上对应的支付方式保持一致 */
|
|
@@ -256,18 +267,7 @@ export interface PaymentItemInput {
|
|
|
256
267
|
/** 订单支付类型 */
|
|
257
268
|
order_payment_type?: 'normal' | 'deposit';
|
|
258
269
|
/** 扩展参数字段 */
|
|
259
|
-
metadata?:
|
|
260
|
-
/** 钱箱 ID */
|
|
261
|
-
shop_wallet_pass_id?: string;
|
|
262
|
-
/** 唯一支付号 */
|
|
263
|
-
unique_payment_number?: string;
|
|
264
|
-
/** rounding规则 */
|
|
265
|
-
rounding_rule?: any;
|
|
266
|
-
/** 实付金额(现金支付时的实际给出金额) */
|
|
267
|
-
actual_paid_amount?: number;
|
|
268
|
-
/** 找零金额(现金支付时的找零金额) */
|
|
269
|
-
change_given_amount?: number;
|
|
270
|
-
};
|
|
270
|
+
metadata?: PaymentItemMetadata;
|
|
271
271
|
/** 支付项创建时间 (格式: YYYY-MM-DD HH:mm:ss, 可选,不传则自动生成) */
|
|
272
272
|
created_at?: string;
|
|
273
273
|
/** 支付项更新时间 (格式: YYYY-MM-DD HH:mm:ss, 可选,不传则自动生成) */
|
|
@@ -302,6 +302,8 @@ export interface PaymentUpdateFields {
|
|
|
302
302
|
voucher_id?: string;
|
|
303
303
|
/** 该支付项是否已经同步给后端服务器(只有网络请求成功后才为true) */
|
|
304
304
|
isSynced?: boolean;
|
|
305
|
+
/** 支付项扩展元数据;更新时与原 metadata 浅合并 */
|
|
306
|
+
metadata?: PaymentItemMetadata;
|
|
305
307
|
/** 同步错误信息(业务错误时记录错误信息,用于区分"未同步"和"同步失败") */
|
|
306
308
|
syncError?: {
|
|
307
309
|
error: string;
|
package/lib/server/index.d.ts
CHANGED
|
@@ -57,6 +57,7 @@ declare class Server {
|
|
|
57
57
|
private readonly BOOKING_REMOTE_CACHE_MAX_ENTRIES;
|
|
58
58
|
private salesSearchSubscribers;
|
|
59
59
|
private deviceTaskActionsRegistered;
|
|
60
|
+
private localPaymentUpdateQueues;
|
|
60
61
|
private floorPlanQuerySubscribers;
|
|
61
62
|
private moduleRegistry;
|
|
62
63
|
constructor(core: PisellCore);
|
|
@@ -453,6 +454,18 @@ declare class Server {
|
|
|
453
454
|
*/
|
|
454
455
|
private handleUpdateLocalOrder;
|
|
455
456
|
private handleOrderSalesCheckout;
|
|
457
|
+
private handleOrderSalesDraft;
|
|
458
|
+
private createLocalPaymentOperationId;
|
|
459
|
+
private buildLocalPaymentOrderLogContext;
|
|
460
|
+
private isValidLocalPaymentDecimal;
|
|
461
|
+
private getInvalidLocalPaymentSurchargeFields;
|
|
462
|
+
private buildLocalPaymentSurchargeUpdate;
|
|
463
|
+
private handleGetLocalPayment;
|
|
464
|
+
private handleUpdateLocalPayment;
|
|
465
|
+
private runLocalPaymentUpdateInQueue;
|
|
466
|
+
private processLocalPaymentUpdate;
|
|
467
|
+
private processSuccessfulLocalPayment;
|
|
468
|
+
private sanitizeLocalRecoveryOrder;
|
|
456
469
|
private handleOrderCheckout;
|
|
457
470
|
private getDeviceTaskPlugin;
|
|
458
471
|
private getIdGeneratorPlugin;
|
|
@@ -480,6 +493,7 @@ declare class Server {
|
|
|
480
493
|
private syncMachinecodeRedeemStatusToLocalOrder;
|
|
481
494
|
private handleOrderCheckoutSubmit;
|
|
482
495
|
private handleSyncCheckoutSubmit;
|
|
496
|
+
private handleOrderDraftSubmit;
|
|
483
497
|
private handlePendingSyncCheckoutOrder;
|
|
484
498
|
private buildPendingSyncCheckoutOrder;
|
|
485
499
|
private shouldBuildSmallTicketData;
|