@pisell/pisellos 0.0.254 → 0.0.256
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/Date/index.d.ts +17 -0
- package/dist/modules/Date/index.js +92 -4
- package/dist/modules/Order/index.js +11 -2
- package/dist/modules/Payment/index.d.ts +4 -4
- package/dist/modules/Payment/index.js +12 -4
- package/dist/modules/Payment/types.d.ts +8 -0
- package/dist/modules/Payment/walletpass.js +173 -57
- package/dist/solution/Checkout/index.d.ts +15 -0
- package/dist/solution/Checkout/index.js +478 -341
- package/lib/modules/Date/index.d.ts +17 -0
- package/lib/modules/Date/index.js +64 -0
- package/lib/modules/Order/index.js +6 -1
- package/lib/modules/Payment/index.d.ts +4 -4
- package/lib/modules/Payment/index.js +11 -2
- package/lib/modules/Payment/types.d.ts +8 -0
- package/lib/modules/Payment/walletpass.js +124 -24
- package/lib/solution/Checkout/index.d.ts +15 -0
- package/lib/solution/Checkout/index.js +104 -11
- package/package.json +1 -1
|
@@ -17,6 +17,23 @@ export declare class DateModule extends BaseModule implements Module, DateModule
|
|
|
17
17
|
getDateList(): ITime[];
|
|
18
18
|
setDateList(dateList: ITime[]): void;
|
|
19
19
|
fetchResourceDates(params: IGetAvailableTimeListParams): Promise<any>;
|
|
20
|
+
/**
|
|
21
|
+
* 将时间向上取整到下一个10分钟整数
|
|
22
|
+
*
|
|
23
|
+
* @param time dayjs 时间对象
|
|
24
|
+
* @returns 向上取整后的时间字符串 (YYYY-MM-DD HH:mm 格式)
|
|
25
|
+
*/
|
|
26
|
+
private roundUpToNext10Minutes;
|
|
27
|
+
/**
|
|
28
|
+
* 校正资源时间段数据
|
|
29
|
+
*
|
|
30
|
+
* 如果时间段的 start_at 早于资源的 start_time,将其同步为 start_time 的下一个10分钟整数
|
|
31
|
+
* 如果修正后 end_at 也早于修正后的 start_time,则删除该时间段
|
|
32
|
+
*
|
|
33
|
+
* @param resourcesData 资源数据数组
|
|
34
|
+
* @returns 校正后的资源数据数组
|
|
35
|
+
*/
|
|
36
|
+
private correctResourceTimeSlots;
|
|
20
37
|
getResourceAvailableTimeList(params: IGetAvailableTimeListParams): Promise<ITime[]>;
|
|
21
38
|
clearDateRange(): void;
|
|
22
39
|
storeChange(): void;
|
|
@@ -32,6 +32,7 @@ __export(Date_exports, {
|
|
|
32
32
|
DateModule: () => DateModule
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(Date_exports);
|
|
35
|
+
var import_dayjs = __toESM(require("dayjs"));
|
|
35
36
|
var import_BaseModule = require("../BaseModule");
|
|
36
37
|
var import_utils = require("./utils");
|
|
37
38
|
var import_cloneDeep = __toESM(require("lodash-es/cloneDeep"));
|
|
@@ -138,11 +139,74 @@ var DateModule = class extends import_BaseModule.BaseModule {
|
|
|
138
139
|
}, {
|
|
139
140
|
useCache
|
|
140
141
|
});
|
|
142
|
+
if ((res == null ? void 0 : res.data) && Array.isArray(res.data)) {
|
|
143
|
+
res.data = this.correctResourceTimeSlots(res.data);
|
|
144
|
+
}
|
|
141
145
|
return res;
|
|
142
146
|
} catch (error) {
|
|
143
147
|
console.error(error);
|
|
144
148
|
}
|
|
145
149
|
}
|
|
150
|
+
/**
|
|
151
|
+
* 将时间向上取整到下一个10分钟整数
|
|
152
|
+
*
|
|
153
|
+
* @param time dayjs 时间对象
|
|
154
|
+
* @returns 向上取整后的时间字符串 (YYYY-MM-DD HH:mm 格式)
|
|
155
|
+
*/
|
|
156
|
+
roundUpToNext10Minutes(time) {
|
|
157
|
+
const minutes = time.minute();
|
|
158
|
+
const remainder = minutes % 10;
|
|
159
|
+
if (remainder === 0) {
|
|
160
|
+
return time.format("YYYY-MM-DD HH:mm");
|
|
161
|
+
} else {
|
|
162
|
+
const minutesToAdd = 10 - remainder;
|
|
163
|
+
const roundedTime = time.add(minutesToAdd, "minute");
|
|
164
|
+
return roundedTime.format("YYYY-MM-DD HH:mm");
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* 校正资源时间段数据
|
|
169
|
+
*
|
|
170
|
+
* 如果时间段的 start_at 早于资源的 start_time,将其同步为 start_time 的下一个10分钟整数
|
|
171
|
+
* 如果修正后 end_at 也早于修正后的 start_time,则删除该时间段
|
|
172
|
+
*
|
|
173
|
+
* @param resourcesData 资源数据数组
|
|
174
|
+
* @returns 校正后的资源数据数组
|
|
175
|
+
*/
|
|
176
|
+
correctResourceTimeSlots(resourcesData) {
|
|
177
|
+
return resourcesData.map((resource) => {
|
|
178
|
+
if (!resource.times || !Array.isArray(resource.times) || !resource.start_time) {
|
|
179
|
+
return resource;
|
|
180
|
+
}
|
|
181
|
+
const resourceStartTime = (0, import_dayjs.default)(resource.start_time);
|
|
182
|
+
const correctedTimes = resource.times.map((timeSlot) => {
|
|
183
|
+
if (!timeSlot.start_at || !timeSlot.end_at) {
|
|
184
|
+
return timeSlot;
|
|
185
|
+
}
|
|
186
|
+
const startAt = (0, import_dayjs.default)(timeSlot.start_at);
|
|
187
|
+
const endAt = (0, import_dayjs.default)(timeSlot.end_at);
|
|
188
|
+
if (startAt.isBefore(resourceStartTime)) {
|
|
189
|
+
const roundedStartTime = this.roundUpToNext10Minutes(resourceStartTime);
|
|
190
|
+
const roundedStartTimeDayjs = (0, import_dayjs.default)(roundedStartTime);
|
|
191
|
+
console.log(`[DateModule] 修正时间段开始时间: ${timeSlot.start_at} -> ${roundedStartTime} (资源ID: ${resource.id}, 原始start_time: ${resource.start_time})`);
|
|
192
|
+
const correctedTimeSlot = {
|
|
193
|
+
...timeSlot,
|
|
194
|
+
start_at: roundedStartTime
|
|
195
|
+
};
|
|
196
|
+
if (endAt.isBefore(roundedStartTimeDayjs)) {
|
|
197
|
+
console.log(`[DateModule] 时间段无效,将被删除: ${timeSlot.start_at} - ${timeSlot.end_at} (资源ID: ${resource.id}, 修正后start_time: ${roundedStartTime})`);
|
|
198
|
+
return null;
|
|
199
|
+
}
|
|
200
|
+
return correctedTimeSlot;
|
|
201
|
+
}
|
|
202
|
+
return timeSlot;
|
|
203
|
+
}).filter((timeSlot) => timeSlot !== null);
|
|
204
|
+
return {
|
|
205
|
+
...resource,
|
|
206
|
+
times: correctedTimes
|
|
207
|
+
};
|
|
208
|
+
});
|
|
209
|
+
}
|
|
146
210
|
async getResourceAvailableTimeList(params) {
|
|
147
211
|
var _a;
|
|
148
212
|
const { query, rules, type } = params;
|
|
@@ -47,7 +47,12 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
47
47
|
this.core = core;
|
|
48
48
|
this.store = options.store;
|
|
49
49
|
this.request = this.core.getPlugin("request");
|
|
50
|
-
|
|
50
|
+
const appPlugin = this.core.getPlugin("app");
|
|
51
|
+
if (!appPlugin) {
|
|
52
|
+
throw new Error("Order 模块需要 app 插件支持");
|
|
53
|
+
}
|
|
54
|
+
const app = appPlugin.getApp();
|
|
55
|
+
this.logger = app.logger;
|
|
51
56
|
this.logInfo("OrderModule initialized successfully");
|
|
52
57
|
}
|
|
53
58
|
/**
|
|
@@ -31,19 +31,19 @@ export declare class PaymentModule extends BaseModule implements Module, Payment
|
|
|
31
31
|
/**
|
|
32
32
|
* 记录信息日志
|
|
33
33
|
*/
|
|
34
|
-
|
|
34
|
+
logInfo(title: string, metadata?: any): void;
|
|
35
35
|
/**
|
|
36
36
|
* 记录警告日志
|
|
37
37
|
*/
|
|
38
|
-
|
|
38
|
+
logWarning(title: string, metadata?: any): void;
|
|
39
39
|
/**
|
|
40
40
|
* 记录错误日志
|
|
41
41
|
*/
|
|
42
|
-
|
|
42
|
+
logError(title: string, error?: any, metadata?: any): void;
|
|
43
43
|
/**
|
|
44
44
|
* 记录调试日志
|
|
45
45
|
*/
|
|
46
|
-
|
|
46
|
+
logDebug(title: string, metadata?: any): void;
|
|
47
47
|
/**
|
|
48
48
|
* 网络恢复以后,尝试执行队列
|
|
49
49
|
*
|
|
@@ -504,7 +504,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
|
|
|
504
504
|
* 为某个订单添加支付项(新方法)
|
|
505
505
|
*/
|
|
506
506
|
async addPaymentItemAsync(orderUuid, paymentItem) {
|
|
507
|
-
var _a;
|
|
507
|
+
var _a, _b, _c;
|
|
508
508
|
this.logInfo("Starting addPaymentItemAsync", {
|
|
509
509
|
orderUuid,
|
|
510
510
|
paymentAmount: paymentItem.amount,
|
|
@@ -532,6 +532,8 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
|
|
|
532
532
|
order_payment_type: paymentItem.order_payment_type || "normal",
|
|
533
533
|
// 默认为正常支付
|
|
534
534
|
metadata: {
|
|
535
|
+
...paymentItem.metadata,
|
|
536
|
+
// 保留传入的所有 metadata 字段
|
|
535
537
|
unique_payment_number: paymentUuid
|
|
536
538
|
// 设置唯一支付号为支付项的 uuid
|
|
537
539
|
}
|
|
@@ -547,7 +549,14 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
|
|
|
547
549
|
orderUuid,
|
|
548
550
|
paymentUuid: newPaymentItem.uuid,
|
|
549
551
|
uniquePaymentNumber: (_a = newPaymentItem.metadata) == null ? void 0 : _a.unique_payment_number,
|
|
550
|
-
newExpectAmount: order.expect_amount
|
|
552
|
+
newExpectAmount: order.expect_amount,
|
|
553
|
+
paymentAmount: newPaymentItem.amount,
|
|
554
|
+
paymentCode: newPaymentItem.code,
|
|
555
|
+
orderPaymentType: newPaymentItem.order_payment_type,
|
|
556
|
+
metadataFields: Object.keys(newPaymentItem.metadata || {}),
|
|
557
|
+
// 现金支付找零信息
|
|
558
|
+
actualPaidAmount: (_b = newPaymentItem.metadata) == null ? void 0 : _b.actual_paid_amount,
|
|
559
|
+
changeGivenAmount: (_c = newPaymentItem.metadata) == null ? void 0 : _c.change_given_amount
|
|
551
560
|
});
|
|
552
561
|
} catch (error) {
|
|
553
562
|
console.error("[PaymentModule] 添加支付项失败", error);
|
|
@@ -111,6 +111,10 @@ export interface PaymentItem {
|
|
|
111
111
|
unique_payment_number?: string;
|
|
112
112
|
/** rouding规则 */
|
|
113
113
|
rounding_rule?: any;
|
|
114
|
+
/** 实付金额(现金支付时的实际给出金额) */
|
|
115
|
+
actual_paid_amount?: number;
|
|
116
|
+
/** 找零金额(现金支付时的找零金额) */
|
|
117
|
+
change_given_amount?: number;
|
|
114
118
|
};
|
|
115
119
|
/** rouding金额 */
|
|
116
120
|
rounding_amount?: string;
|
|
@@ -230,6 +234,10 @@ export interface PaymentItemInput {
|
|
|
230
234
|
unique_payment_number?: string;
|
|
231
235
|
/** rounding规则 */
|
|
232
236
|
rounding_rule?: any;
|
|
237
|
+
/** 实付金额(现金支付时的实际给出金额) */
|
|
238
|
+
actual_paid_amount?: number;
|
|
239
|
+
/** 找零金额(现金支付时的找零金额) */
|
|
240
|
+
change_given_amount?: number;
|
|
233
241
|
};
|
|
234
242
|
}
|
|
235
243
|
/**
|
|
@@ -40,7 +40,7 @@ var WalletPassPaymentImpl = class {
|
|
|
40
40
|
try {
|
|
41
41
|
this.paymentModule.core.effects.emit(hook, data);
|
|
42
42
|
} catch (error) {
|
|
43
|
-
|
|
43
|
+
this.paymentModule.logError("[WalletPass] 发送事件失败", error, { hook });
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
/**
|
|
@@ -48,6 +48,7 @@ var WalletPassPaymentImpl = class {
|
|
|
48
48
|
* 根据业务数据生成标准的钱包API参数,并存储在模块中
|
|
49
49
|
*/
|
|
50
50
|
generateWalletParams(businessData) {
|
|
51
|
+
var _a;
|
|
51
52
|
const { customer_id, amountInfo, products, order_wait_pay_amount } = businessData;
|
|
52
53
|
const totalAmount = Number(amountInfo.totalAmount);
|
|
53
54
|
const subTotal = Number(amountInfo.subTotal);
|
|
@@ -65,7 +66,13 @@ var WalletPassPaymentImpl = class {
|
|
|
65
66
|
prepare_payments: []
|
|
66
67
|
};
|
|
67
68
|
this.walletParams = walletParams;
|
|
68
|
-
|
|
69
|
+
this.paymentModule.logInfo("[WalletPass] 钱包默认参数已生成并存储", {
|
|
70
|
+
customer_id: walletParams.customer_id,
|
|
71
|
+
order_expect_amount: walletParams.order_expect_amount,
|
|
72
|
+
order_product_amount: walletParams.order_product_amount,
|
|
73
|
+
order_wait_pay_amount: walletParams.order_wait_pay_amount,
|
|
74
|
+
products_count: ((_a = walletParams.products) == null ? void 0 : _a.length) || 0
|
|
75
|
+
});
|
|
69
76
|
return walletParams;
|
|
70
77
|
}
|
|
71
78
|
/**
|
|
@@ -81,14 +88,14 @@ var WalletPassPaymentImpl = class {
|
|
|
81
88
|
*/
|
|
82
89
|
clearStoredWalletParams() {
|
|
83
90
|
this.walletParams = null;
|
|
84
|
-
|
|
91
|
+
this.paymentModule.logInfo("[WalletPass] 已存储的钱包参数已清理");
|
|
85
92
|
}
|
|
86
93
|
/**
|
|
87
94
|
* 从业务数据初始化钱包数据
|
|
88
95
|
* 内部生成参数,然后调用标准的初始化流程
|
|
89
96
|
*/
|
|
90
97
|
async initializeWalletDataFromBusinessAsync(businessData) {
|
|
91
|
-
var _a, _b;
|
|
98
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
92
99
|
const startTime = Date.now();
|
|
93
100
|
const walletParams = this.generateWalletParams(businessData);
|
|
94
101
|
if (Number(((_a = businessData == null ? void 0 : businessData.amountInfo) == null ? void 0 : _a.totalAmount) || 0) < 0 || Number(((_b = businessData == null ? void 0 : businessData.amountInfo) == null ? void 0 : _b.subTotal) || 0) < 0) {
|
|
@@ -101,6 +108,13 @@ var WalletPassPaymentImpl = class {
|
|
|
101
108
|
businessData,
|
|
102
109
|
startTime
|
|
103
110
|
});
|
|
111
|
+
this.paymentModule.logInfo("[WalletPass] 开始从业务数据初始化钱包数据", {
|
|
112
|
+
customer_id: businessData.customer_id,
|
|
113
|
+
totalAmount: (_c = businessData.amountInfo) == null ? void 0 : _c.totalAmount,
|
|
114
|
+
subTotal: (_d = businessData.amountInfo) == null ? void 0 : _d.subTotal,
|
|
115
|
+
order_wait_pay_amount: businessData.order_wait_pay_amount,
|
|
116
|
+
products_count: ((_e = businessData.products) == null ? void 0 : _e.length) || 0
|
|
117
|
+
});
|
|
104
118
|
try {
|
|
105
119
|
const result = await this.initializeWalletDataAsync(walletParams);
|
|
106
120
|
const endTime = Date.now();
|
|
@@ -112,7 +126,11 @@ var WalletPassPaymentImpl = class {
|
|
|
112
126
|
endTime,
|
|
113
127
|
duration
|
|
114
128
|
});
|
|
115
|
-
|
|
129
|
+
this.paymentModule.logInfo(`[WalletPass] 从业务数据初始化钱包数据成功`, {
|
|
130
|
+
duration: `${duration}ms`,
|
|
131
|
+
walletRecommendList_count: ((_f = result.walletRecommendList) == null ? void 0 : _f.length) || 0,
|
|
132
|
+
userIdentificationCodes_count: ((_g = result.userIdentificationCodes) == null ? void 0 : _g.length) || 0
|
|
133
|
+
});
|
|
116
134
|
return result;
|
|
117
135
|
} catch (error) {
|
|
118
136
|
const endTime = Date.now();
|
|
@@ -124,7 +142,11 @@ var WalletPassPaymentImpl = class {
|
|
|
124
142
|
endTime,
|
|
125
143
|
duration
|
|
126
144
|
});
|
|
127
|
-
|
|
145
|
+
this.paymentModule.logError(`[WalletPass] 从业务数据初始化钱包数据失败`, error, {
|
|
146
|
+
duration: `${duration}ms`,
|
|
147
|
+
customer_id: businessData.customer_id,
|
|
148
|
+
totalAmount: (_h = businessData.amountInfo) == null ? void 0 : _h.totalAmount
|
|
149
|
+
});
|
|
128
150
|
throw error;
|
|
129
151
|
}
|
|
130
152
|
}
|
|
@@ -148,12 +170,20 @@ var WalletPassPaymentImpl = class {
|
|
|
148
170
|
userIdentificationCodes
|
|
149
171
|
};
|
|
150
172
|
} catch (error) {
|
|
151
|
-
|
|
173
|
+
this.paymentModule.logError("[WalletPass] 初始化钱包数据失败", error, {
|
|
174
|
+
customer_id: baseParams.customer_id,
|
|
175
|
+
order_expect_amount: baseParams.order_expect_amount
|
|
176
|
+
});
|
|
152
177
|
throw error;
|
|
153
178
|
}
|
|
154
179
|
}
|
|
155
180
|
async getWalletPassRecommendListAsync(params) {
|
|
156
181
|
try {
|
|
182
|
+
this.paymentModule.logInfo("[WalletPass] 开始获取钱包推荐列表", {
|
|
183
|
+
customer_id: params.customer_id,
|
|
184
|
+
order_expect_amount: params.order_expect_amount,
|
|
185
|
+
sale_channel: params.sale_channel
|
|
186
|
+
});
|
|
157
187
|
const response = await this.paymentModule.request.post(
|
|
158
188
|
"/machinecode/prepare/deduction/recommend",
|
|
159
189
|
params
|
|
@@ -163,14 +193,22 @@ var WalletPassPaymentImpl = class {
|
|
|
163
193
|
this.emitEvent(import_types.WalletPassHooks.OnWalletRecommendListUpdated, {
|
|
164
194
|
walletRecommendList: this.walletRecommendList
|
|
165
195
|
});
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
this.walletRecommendList.
|
|
169
|
-
|
|
170
|
-
|
|
196
|
+
this.paymentModule.logInfo("[WalletPass] 钱包推荐列表已更新", {
|
|
197
|
+
count: this.walletRecommendList.length,
|
|
198
|
+
items: this.walletRecommendList.map((item) => ({
|
|
199
|
+
voucher_id: item.voucher_id,
|
|
200
|
+
name: item.name,
|
|
201
|
+
amount: item.amount,
|
|
202
|
+
tag: item.tag
|
|
203
|
+
}))
|
|
204
|
+
});
|
|
171
205
|
return this.walletRecommendList;
|
|
172
206
|
} catch (error) {
|
|
173
|
-
|
|
207
|
+
this.paymentModule.logError("[WalletPass] 获取钱包推荐列表失败", error, {
|
|
208
|
+
customer_id: params.customer_id,
|
|
209
|
+
order_expect_amount: params.order_expect_amount,
|
|
210
|
+
sale_channel: params.sale_channel
|
|
211
|
+
});
|
|
174
212
|
return [];
|
|
175
213
|
}
|
|
176
214
|
}
|
|
@@ -178,11 +216,18 @@ var WalletPassPaymentImpl = class {
|
|
|
178
216
|
return (0, import_utils.formatWalletPassList2PreparePayments)(list);
|
|
179
217
|
}
|
|
180
218
|
async getUserIdentificationCodeListAsync(params) {
|
|
219
|
+
var _a;
|
|
181
220
|
try {
|
|
182
221
|
const newParams = {
|
|
183
222
|
...this.walletParams,
|
|
184
223
|
...params
|
|
185
224
|
};
|
|
225
|
+
this.paymentModule.logInfo("[WalletPass] 开始获取用户识别码列表", {
|
|
226
|
+
customer_id: newParams.customer_id,
|
|
227
|
+
available: newParams.available,
|
|
228
|
+
prepare_payments_count: ((_a = newParams.prepare_payments) == null ? void 0 : _a.length) || 0,
|
|
229
|
+
filter_prepare_wallet_pass: newParams.filter_prepare_wallet_pass
|
|
230
|
+
});
|
|
186
231
|
const response = await this.paymentModule.request.post(
|
|
187
232
|
"/machinecode/prepare/deduction",
|
|
188
233
|
newParams
|
|
@@ -192,14 +237,20 @@ var WalletPassPaymentImpl = class {
|
|
|
192
237
|
this.emitEvent(import_types.WalletPassHooks.OnUserIdentificationCodesUpdated, {
|
|
193
238
|
userIdentificationCodes: this.userIdentificationCodes
|
|
194
239
|
});
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
this.userIdentificationCodes.
|
|
198
|
-
|
|
199
|
-
|
|
240
|
+
this.paymentModule.logInfo("[WalletPass] 用户识别码列表已更新", {
|
|
241
|
+
count: this.userIdentificationCodes.length,
|
|
242
|
+
sorted_items: this.userIdentificationCodes.slice(0, 5).map((item) => ({
|
|
243
|
+
code: item.code,
|
|
244
|
+
error_code: item.error_code,
|
|
245
|
+
error_msg: item.error_msg
|
|
246
|
+
}))
|
|
247
|
+
});
|
|
200
248
|
return this.userIdentificationCodes;
|
|
201
249
|
} catch (error) {
|
|
202
|
-
|
|
250
|
+
this.paymentModule.logError("[WalletPass] 获取用户识别码列表失败", error, {
|
|
251
|
+
customer_id: params.customer_id,
|
|
252
|
+
available: params.available
|
|
253
|
+
});
|
|
203
254
|
return [];
|
|
204
255
|
}
|
|
205
256
|
}
|
|
@@ -212,6 +263,11 @@ var WalletPassPaymentImpl = class {
|
|
|
212
263
|
async searchIdentificationCodeAsync(params, config = {}) {
|
|
213
264
|
try {
|
|
214
265
|
const { code } = params;
|
|
266
|
+
this.paymentModule.logInfo("[WalletPass] 开始搜索识别码", {
|
|
267
|
+
code,
|
|
268
|
+
code_length: code.length,
|
|
269
|
+
noCache: config.noCache || false
|
|
270
|
+
});
|
|
215
271
|
const isWalletCode = code.startsWith("WL");
|
|
216
272
|
if (isWalletCode) {
|
|
217
273
|
const walletDetailParams = {
|
|
@@ -219,11 +275,21 @@ var WalletPassPaymentImpl = class {
|
|
|
219
275
|
with_customer: 1,
|
|
220
276
|
with: ["wallet"]
|
|
221
277
|
};
|
|
278
|
+
this.paymentModule.logInfo("[WalletPass] 搜索钱包识别码", {
|
|
279
|
+
code,
|
|
280
|
+
with_customer: walletDetailParams.with_customer,
|
|
281
|
+
with: walletDetailParams.with
|
|
282
|
+
});
|
|
222
283
|
const response2 = await this.paymentModule.request.post(
|
|
223
284
|
"/wallet/detail/search",
|
|
224
285
|
walletDetailParams
|
|
225
286
|
);
|
|
226
287
|
const searchResults2 = (response2 == null ? void 0 : response2.data) || [];
|
|
288
|
+
this.paymentModule.logInfo("[WalletPass] 钱包识别码搜索完成", {
|
|
289
|
+
code,
|
|
290
|
+
results_count: searchResults2.length,
|
|
291
|
+
type: "walletCode"
|
|
292
|
+
});
|
|
227
293
|
return {
|
|
228
294
|
type: "walletCode",
|
|
229
295
|
data: searchResults2
|
|
@@ -244,6 +310,12 @@ var WalletPassPaymentImpl = class {
|
|
|
244
310
|
// 搜索特有参数
|
|
245
311
|
code: params.code
|
|
246
312
|
};
|
|
313
|
+
this.paymentModule.logInfo("[WalletPass] 搜索普通识别码", {
|
|
314
|
+
code: searchParams.code,
|
|
315
|
+
customer_id: searchParams.customer_id,
|
|
316
|
+
order_expect_amount: searchParams.order_expect_amount,
|
|
317
|
+
multiple: searchParams.multiple
|
|
318
|
+
});
|
|
247
319
|
const response = await this.paymentModule.request.post(
|
|
248
320
|
"/machinecode/prepare/deduction/search",
|
|
249
321
|
searchParams
|
|
@@ -270,18 +342,38 @@ var WalletPassPaymentImpl = class {
|
|
|
270
342
|
cachedSearchResults: [...this.searchResults],
|
|
271
343
|
searchParams: params
|
|
272
344
|
});
|
|
345
|
+
this.paymentModule.logInfo("[WalletPass] 普通识别码搜索完成", {
|
|
346
|
+
code: params.code,
|
|
347
|
+
results_count: searchResults.length,
|
|
348
|
+
cached_results_count: this.searchResults.length,
|
|
349
|
+
type: "normalCode"
|
|
350
|
+
});
|
|
273
351
|
return {
|
|
274
352
|
type: "normalCode",
|
|
275
353
|
data: searchResults
|
|
276
354
|
};
|
|
277
355
|
} catch (error) {
|
|
278
|
-
|
|
356
|
+
this.paymentModule.logError("[WalletPass] 搜索识别码信息失败", error, {
|
|
357
|
+
code: params.code,
|
|
358
|
+
customer_id: params.customer_id,
|
|
359
|
+
order_expect_amount: params.order_expect_amount
|
|
360
|
+
});
|
|
279
361
|
throw error;
|
|
280
362
|
}
|
|
281
363
|
}
|
|
282
364
|
async processWalletPayment(amount, orderUuid, voucherId) {
|
|
365
|
+
this.paymentModule.logInfo("[WalletPass] 开始处理钱包支付", {
|
|
366
|
+
amount,
|
|
367
|
+
orderUuid,
|
|
368
|
+
voucherId: voucherId || "none"
|
|
369
|
+
});
|
|
283
370
|
const walletMethod = await this.paymentModule.getWalletPaymentMethod();
|
|
284
371
|
if (!walletMethod) {
|
|
372
|
+
this.paymentModule.logError("[WalletPass] 钱包支付方式未找到", null, {
|
|
373
|
+
amount,
|
|
374
|
+
orderUuid,
|
|
375
|
+
voucherId
|
|
376
|
+
});
|
|
285
377
|
throw new Error("钱包支付方式未找到");
|
|
286
378
|
}
|
|
287
379
|
const paymentItem = {
|
|
@@ -293,6 +385,12 @@ var WalletPassPaymentImpl = class {
|
|
|
293
385
|
voucher_id: voucherId || ""
|
|
294
386
|
};
|
|
295
387
|
await this.paymentModule.addPaymentItemAsync(orderUuid, paymentItem);
|
|
388
|
+
this.paymentModule.logInfo("[WalletPass] 钱包支付处理完成", {
|
|
389
|
+
amount,
|
|
390
|
+
orderUuid,
|
|
391
|
+
voucherId: voucherId || "none",
|
|
392
|
+
payment_method: walletMethod.name
|
|
393
|
+
});
|
|
296
394
|
}
|
|
297
395
|
async getWalletBalance(voucherId) {
|
|
298
396
|
return 0;
|
|
@@ -317,7 +415,7 @@ var WalletPassPaymentImpl = class {
|
|
|
317
415
|
this.emitEvent(import_types.WalletPassHooks.OnWalletRecommendListCleared, {
|
|
318
416
|
clearedTypes: ["walletRecommendList"]
|
|
319
417
|
});
|
|
320
|
-
|
|
418
|
+
this.paymentModule.logInfo("[WalletPass] 钱包推荐列表已清除");
|
|
321
419
|
}
|
|
322
420
|
/**
|
|
323
421
|
* 清除用户识别码列表
|
|
@@ -327,7 +425,7 @@ var WalletPassPaymentImpl = class {
|
|
|
327
425
|
this.emitEvent(import_types.WalletPassHooks.OnUserIdentificationCodesCleared, {
|
|
328
426
|
clearedTypes: ["userIdentificationCodes"]
|
|
329
427
|
});
|
|
330
|
-
|
|
428
|
+
this.paymentModule.logInfo("[WalletPass] 用户识别码列表已清除");
|
|
331
429
|
}
|
|
332
430
|
/**
|
|
333
431
|
* 获取缓存的搜索结果列表
|
|
@@ -346,7 +444,7 @@ var WalletPassPaymentImpl = class {
|
|
|
346
444
|
*/
|
|
347
445
|
clearSearchResults() {
|
|
348
446
|
this.searchResults = [];
|
|
349
|
-
|
|
447
|
+
this.paymentModule.logInfo("[WalletPass] 搜索结果缓存已清除");
|
|
350
448
|
}
|
|
351
449
|
/**
|
|
352
450
|
* 清除所有缓存数据
|
|
@@ -359,7 +457,9 @@ var WalletPassPaymentImpl = class {
|
|
|
359
457
|
this.emitEvent(import_types.WalletPassHooks.OnWalletCacheCleared, {
|
|
360
458
|
clearedTypes: ["all"]
|
|
361
459
|
});
|
|
362
|
-
|
|
460
|
+
this.paymentModule.logInfo("[WalletPass] 所有缓存数据已清除", {
|
|
461
|
+
cleared_types: ["walletRecommendList", "userIdentificationCodes", "searchResults", "walletParams"]
|
|
462
|
+
});
|
|
363
463
|
}
|
|
364
464
|
};
|
|
365
465
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -379,6 +379,21 @@ export declare class CheckoutImpl extends BaseModule implements Module, Checkout
|
|
|
379
379
|
* 验证结账参数
|
|
380
380
|
*/
|
|
381
381
|
private validateCheckoutParams;
|
|
382
|
+
/**
|
|
383
|
+
* 处理现金支付项的找零逻辑
|
|
384
|
+
*
|
|
385
|
+
* @param paymentItem 原始支付项
|
|
386
|
+
* @returns 处理后的支付项(包含找零信息)
|
|
387
|
+
*/
|
|
388
|
+
private processCashPaymentItem;
|
|
389
|
+
/**
|
|
390
|
+
* 判断是否为现金支付
|
|
391
|
+
*
|
|
392
|
+
* @param paymentCode 支付代码
|
|
393
|
+
* @param paymentType 支付类型
|
|
394
|
+
* @returns 是否为现金支付
|
|
395
|
+
*/
|
|
396
|
+
private isCashPayment;
|
|
382
397
|
/**
|
|
383
398
|
* 预加载支付方式(在初始化时调用)
|
|
384
399
|
*/
|