@pisell/pisellos 0.0.255 → 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.
@@ -31,19 +31,19 @@ export declare class PaymentModule extends BaseModule implements Module, Payment
31
31
  /**
32
32
  * 记录信息日志
33
33
  */
34
- private logInfo;
34
+ logInfo(title: string, metadata?: any): void;
35
35
  /**
36
36
  * 记录警告日志
37
37
  */
38
- private logWarning;
38
+ logWarning(title: string, metadata?: any): void;
39
39
  /**
40
40
  * 记录错误日志
41
41
  */
42
- private logError;
42
+ logError(title: string, error?: any, metadata?: any): void;
43
43
  /**
44
44
  * 记录调试日志
45
45
  */
46
- private logDebug;
46
+ logDebug(title: string, metadata?: any): void;
47
47
  /**
48
48
  * 网络恢复以后,尝试执行队列
49
49
  *
@@ -42,7 +42,9 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
42
42
  try {
43
43
  this.paymentModule.core.effects.emit(hook, data);
44
44
  } catch (error) {
45
- console.error('[WalletPass] 发送事件失败:', hook, error);
45
+ this.paymentModule.logError('[WalletPass] 发送事件失败', error, {
46
+ hook: hook
47
+ });
46
48
  }
47
49
  }
48
50
 
@@ -53,6 +55,7 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
53
55
  }, {
54
56
  key: "generateWalletParams",
55
57
  value: function generateWalletParams(businessData) {
58
+ var _walletParams$product;
56
59
  var customer_id = businessData.customer_id,
57
60
  amountInfo = businessData.amountInfo,
58
61
  products = businessData.products,
@@ -77,7 +80,13 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
77
80
 
78
81
  // 存储生成的参数到模块中
79
82
  this.walletParams = walletParams;
80
- console.log('[WalletPass] 钱包默认参数已生成并存储:', walletParams);
83
+ this.paymentModule.logInfo('[WalletPass] 钱包默认参数已生成并存储', {
84
+ customer_id: walletParams.customer_id,
85
+ order_expect_amount: walletParams.order_expect_amount,
86
+ order_product_amount: walletParams.order_product_amount,
87
+ order_wait_pay_amount: walletParams.order_wait_pay_amount,
88
+ products_count: ((_walletParams$product = walletParams.products) === null || _walletParams$product === void 0 ? void 0 : _walletParams$product.length) || 0
89
+ });
81
90
  return walletParams;
82
91
  }
83
92
 
@@ -99,7 +108,7 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
99
108
  key: "clearStoredWalletParams",
100
109
  value: function clearStoredWalletParams() {
101
110
  this.walletParams = null;
102
- console.log('[WalletPass] 已存储的钱包参数已清理');
111
+ this.paymentModule.logInfo('[WalletPass] 已存储的钱包参数已清理');
103
112
  }
104
113
 
105
114
  /**
@@ -110,8 +119,8 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
110
119
  key: "initializeWalletDataFromBusinessAsync",
111
120
  value: (function () {
112
121
  var _initializeWalletDataFromBusinessAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(businessData) {
113
- var _businessData$amountI, _businessData$amountI2;
114
- var startTime, walletParams, result, endTime, duration, _endTime, _duration;
122
+ var _businessData$amountI, _businessData$amountI2, _businessData$amountI3, _businessData$amountI4, _businessData$product;
123
+ var startTime, walletParams, _result$walletRecomme, _result$userIdentific, result, endTime, duration, _businessData$amountI5, _endTime, _duration;
115
124
  return _regeneratorRuntime().wrap(function _callee$(_context) {
116
125
  while (1) switch (_context.prev = _context.next) {
117
126
  case 0:
@@ -131,10 +140,17 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
131
140
  businessData: businessData,
132
141
  startTime: startTime
133
142
  });
134
- _context.prev = 5;
135
- _context.next = 8;
143
+ this.paymentModule.logInfo('[WalletPass] 开始从业务数据初始化钱包数据', {
144
+ customer_id: businessData.customer_id,
145
+ totalAmount: (_businessData$amountI3 = businessData.amountInfo) === null || _businessData$amountI3 === void 0 ? void 0 : _businessData$amountI3.totalAmount,
146
+ subTotal: (_businessData$amountI4 = businessData.amountInfo) === null || _businessData$amountI4 === void 0 ? void 0 : _businessData$amountI4.subTotal,
147
+ order_wait_pay_amount: businessData.order_wait_pay_amount,
148
+ products_count: ((_businessData$product = businessData.products) === null || _businessData$product === void 0 ? void 0 : _businessData$product.length) || 0
149
+ });
150
+ _context.prev = 6;
151
+ _context.next = 9;
136
152
  return this.initializeWalletDataAsync(walletParams);
137
- case 8:
153
+ case 9:
138
154
  result = _context.sent;
139
155
  endTime = Date.now();
140
156
  duration = endTime - startTime; // 发送初始化完成事件
@@ -145,11 +161,15 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
145
161
  endTime: endTime,
146
162
  duration: duration
147
163
  });
148
- console.log("[WalletPass] \u4ECE\u4E1A\u52A1\u6570\u636E\u521D\u59CB\u5316\u94B1\u5305\u6570\u636E\u6210\u529F\uFF0C\u8017\u65F6: ".concat(duration, "ms"));
164
+ this.paymentModule.logInfo("[WalletPass] \u4ECE\u4E1A\u52A1\u6570\u636E\u521D\u59CB\u5316\u94B1\u5305\u6570\u636E\u6210\u529F", {
165
+ duration: "".concat(duration, "ms"),
166
+ walletRecommendList_count: ((_result$walletRecomme = result.walletRecommendList) === null || _result$walletRecomme === void 0 ? void 0 : _result$walletRecomme.length) || 0,
167
+ userIdentificationCodes_count: ((_result$userIdentific = result.userIdentificationCodes) === null || _result$userIdentific === void 0 ? void 0 : _result$userIdentific.length) || 0
168
+ });
149
169
  return _context.abrupt("return", result);
150
- case 16:
151
- _context.prev = 16;
152
- _context.t0 = _context["catch"](5);
170
+ case 17:
171
+ _context.prev = 17;
172
+ _context.t0 = _context["catch"](6);
153
173
  _endTime = Date.now();
154
174
  _duration = _endTime - startTime; // 发送初始化失败事件
155
175
  this.emitEvent(WalletPassHooks.OnWalletInitializationFailed, {
@@ -159,13 +179,17 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
159
179
  endTime: _endTime,
160
180
  duration: _duration
161
181
  });
162
- console.error("[WalletPass] \u4ECE\u4E1A\u52A1\u6570\u636E\u521D\u59CB\u5316\u94B1\u5305\u6570\u636E\u5931\u8D25\uFF0C\u8017\u65F6: ".concat(_duration, "ms"), _context.t0);
182
+ this.paymentModule.logError("[WalletPass] \u4ECE\u4E1A\u52A1\u6570\u636E\u521D\u59CB\u5316\u94B1\u5305\u6570\u636E\u5931\u8D25", _context.t0, {
183
+ duration: "".concat(_duration, "ms"),
184
+ customer_id: businessData.customer_id,
185
+ totalAmount: (_businessData$amountI5 = businessData.amountInfo) === null || _businessData$amountI5 === void 0 ? void 0 : _businessData$amountI5.totalAmount
186
+ });
163
187
  throw _context.t0;
164
- case 23:
188
+ case 24:
165
189
  case "end":
166
190
  return _context.stop();
167
191
  }
168
- }, _callee, this, [[5, 16]]);
192
+ }, _callee, this, [[6, 17]]);
169
193
  }));
170
194
  function initializeWalletDataFromBusinessAsync(_x) {
171
195
  return _initializeWalletDataFromBusinessAsync.apply(this, arguments);
@@ -208,7 +232,10 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
208
232
  case 11:
209
233
  _context2.prev = 11;
210
234
  _context2.t0 = _context2["catch"](0);
211
- console.error('[WalletPass] 初始化钱包数据失败:', _context2.t0);
235
+ this.paymentModule.logError('[WalletPass] 初始化钱包数据失败', _context2.t0, {
236
+ customer_id: baseParams.customer_id,
237
+ order_expect_amount: baseParams.order_expect_amount
238
+ });
212
239
  throw _context2.t0;
213
240
  case 15:
214
241
  case "end":
@@ -230,10 +257,15 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
230
257
  while (1) switch (_context3.prev = _context3.next) {
231
258
  case 0:
232
259
  _context3.prev = 0;
233
- _context3.next = 3;
260
+ this.paymentModule.logInfo('[WalletPass] 开始获取钱包推荐列表', {
261
+ customer_id: params.customer_id,
262
+ order_expect_amount: params.order_expect_amount,
263
+ sale_channel: params.sale_channel
264
+ });
265
+ _context3.next = 4;
234
266
  return this.paymentModule.request.post('/machinecode/prepare/deduction/recommend', params // 将 params 作为请求体数据
235
267
  );
236
- case 3:
268
+ case 4:
237
269
  response = _context3.sent;
238
270
  this.walletRecommendList = (response === null || response === void 0 ? void 0 : response.data) || [];
239
271
 
@@ -241,19 +273,33 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
241
273
  this.emitEvent(WalletPassHooks.OnWalletRecommendListUpdated, {
242
274
  walletRecommendList: this.walletRecommendList
243
275
  });
244
- console.log('[WalletPass] 钱包推荐列表已更新:', this.walletRecommendList.length, '项');
276
+ this.paymentModule.logInfo('[WalletPass] 钱包推荐列表已更新', {
277
+ count: this.walletRecommendList.length,
278
+ items: this.walletRecommendList.map(function (item) {
279
+ return {
280
+ voucher_id: item.voucher_id,
281
+ name: item.name,
282
+ amount: item.amount,
283
+ tag: item.tag
284
+ };
285
+ })
286
+ });
245
287
  return _context3.abrupt("return", this.walletRecommendList);
246
- case 10:
247
- _context3.prev = 10;
288
+ case 11:
289
+ _context3.prev = 11;
248
290
  _context3.t0 = _context3["catch"](0);
249
- console.error('获取钱包推荐列表失败:', _context3.t0);
291
+ this.paymentModule.logError('[WalletPass] 获取钱包推荐列表失败', _context3.t0, {
292
+ customer_id: params.customer_id,
293
+ order_expect_amount: params.order_expect_amount,
294
+ sale_channel: params.sale_channel
295
+ });
250
296
  // throw error;
251
297
  return _context3.abrupt("return", []);
252
- case 14:
298
+ case 15:
253
299
  case "end":
254
300
  return _context3.stop();
255
301
  }
256
- }, _callee3, this, [[0, 10]]);
302
+ }, _callee3, this, [[0, 11]]);
257
303
  }));
258
304
  function getWalletPassRecommendListAsync(_x3) {
259
305
  return _getWalletPassRecommendListAsync.apply(this, arguments);
@@ -269,15 +315,21 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
269
315
  key: "getUserIdentificationCodeListAsync",
270
316
  value: function () {
271
317
  var _getUserIdentificationCodeListAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(params) {
272
- var newParams, response, sortedData;
318
+ var _newParams$prepare_pa, newParams, response, sortedData;
273
319
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
274
320
  while (1) switch (_context4.prev = _context4.next) {
275
321
  case 0:
276
322
  _context4.prev = 0;
277
323
  newParams = _objectSpread(_objectSpread({}, this.walletParams), params);
278
- _context4.next = 4;
324
+ this.paymentModule.logInfo('[WalletPass] 开始获取用户识别码列表', {
325
+ customer_id: newParams.customer_id,
326
+ available: newParams.available,
327
+ prepare_payments_count: ((_newParams$prepare_pa = newParams.prepare_payments) === null || _newParams$prepare_pa === void 0 ? void 0 : _newParams$prepare_pa.length) || 0,
328
+ filter_prepare_wallet_pass: newParams.filter_prepare_wallet_pass
329
+ });
330
+ _context4.next = 5;
279
331
  return this.paymentModule.request.post('/machinecode/prepare/deduction', newParams);
280
- case 4:
332
+ case 5:
281
333
  response = _context4.sent;
282
334
  // 对获取到的数据进行排序,将错误码为 500100、500200、500300 的项目排到最后
283
335
  sortedData = sortUserIdentificationCodeList((response === null || response === void 0 ? void 0 : response.data) || []);
@@ -287,18 +339,30 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
287
339
  this.emitEvent(WalletPassHooks.OnUserIdentificationCodesUpdated, {
288
340
  userIdentificationCodes: this.userIdentificationCodes
289
341
  });
290
- console.log('[WalletPass] 用户识别码列表已更新:', this.userIdentificationCodes.length, '项');
342
+ this.paymentModule.logInfo('[WalletPass] 用户识别码列表已更新', {
343
+ count: this.userIdentificationCodes.length,
344
+ sorted_items: this.userIdentificationCodes.slice(0, 5).map(function (item) {
345
+ return {
346
+ code: item.code,
347
+ error_code: item.error_code,
348
+ error_msg: item.error_msg
349
+ };
350
+ })
351
+ });
291
352
  return _context4.abrupt("return", this.userIdentificationCodes);
292
- case 12:
293
- _context4.prev = 12;
353
+ case 13:
354
+ _context4.prev = 13;
294
355
  _context4.t0 = _context4["catch"](0);
295
- console.error('获取用户识别码列表失败:', _context4.t0);
356
+ this.paymentModule.logError('[WalletPass] 获取用户识别码列表失败', _context4.t0, {
357
+ customer_id: params.customer_id,
358
+ available: params.available
359
+ });
296
360
  return _context4.abrupt("return", []);
297
- case 16:
361
+ case 17:
298
362
  case "end":
299
363
  return _context4.stop();
300
364
  }
301
- }, _callee4, this, [[0, 12]]);
365
+ }, _callee4, this, [[0, 13]]);
302
366
  }));
303
367
  function getUserIdentificationCodeListAsync(_x4) {
304
368
  return _getUserIdentificationCodeListAsync.apply(this, arguments);
@@ -334,12 +398,19 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
334
398
  case 0:
335
399
  config = _args5.length > 1 && _args5[1] !== undefined ? _args5[1] : {};
336
400
  _context5.prev = 1;
337
- code = params.code; // 检查识别码是否为9位且前3位为"000"
401
+ code = params.code;
402
+ this.paymentModule.logInfo('[WalletPass] 开始搜索识别码', {
403
+ code: code,
404
+ code_length: code.length,
405
+ noCache: config.noCache || false
406
+ });
407
+
408
+ // 检查识别码是否为9位且前3位为"000"
338
409
  // const isWalletCode = code.length === 9 && code.startsWith('000');
339
410
  // 测试环境先使用 WL
340
411
  isWalletCode = code.startsWith('WL');
341
412
  if (!isWalletCode) {
342
- _context5.next = 11;
413
+ _context5.next = 14;
343
414
  break;
344
415
  }
345
416
  // 钱包识别码直接调用专门接口,不缓存,直接返回
@@ -348,16 +419,26 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
348
419
  with_customer: 1,
349
420
  with: ['wallet']
350
421
  };
351
- _context5.next = 8;
422
+ this.paymentModule.logInfo('[WalletPass] 搜索钱包识别码', {
423
+ code: code,
424
+ with_customer: walletDetailParams.with_customer,
425
+ with: walletDetailParams.with
426
+ });
427
+ _context5.next = 10;
352
428
  return this.paymentModule.request.post('/wallet/detail/search', walletDetailParams);
353
- case 8:
429
+ case 10:
354
430
  _response = _context5.sent;
355
431
  _searchResults = (_response === null || _response === void 0 ? void 0 : _response.data) || [];
432
+ this.paymentModule.logInfo('[WalletPass] 钱包识别码搜索完成', {
433
+ code: code,
434
+ results_count: _searchResults.length,
435
+ type: 'walletCode'
436
+ });
356
437
  return _context5.abrupt("return", {
357
438
  type: 'walletCode',
358
439
  data: _searchResults
359
440
  });
360
- case 11:
441
+ case 14:
361
442
  // 合并钱包参数和搜索参数
362
443
  baseWalletParams = this.walletParams; // 构建完整的搜索参数,包含钱包扣款推荐的所有参数
363
444
  searchParams = {
@@ -374,20 +455,26 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
374
455
  // 搜索特有参数
375
456
  code: params.code
376
457
  };
377
- _context5.next = 15;
458
+ this.paymentModule.logInfo('[WalletPass] 搜索普通识别码', {
459
+ code: searchParams.code,
460
+ customer_id: searchParams.customer_id,
461
+ order_expect_amount: searchParams.order_expect_amount,
462
+ multiple: searchParams.multiple
463
+ });
464
+ _context5.next = 19;
378
465
  return this.paymentModule.request.post('/machinecode/prepare/deduction/search', searchParams);
379
- case 15:
466
+ case 19:
380
467
  response = _context5.sent;
381
468
  searchResults = (response === null || response === void 0 ? void 0 : response.data) || [];
382
469
  if (!config.noCache) {
383
- _context5.next = 19;
470
+ _context5.next = 23;
384
471
  break;
385
472
  }
386
473
  return _context5.abrupt("return", {
387
474
  type: 'normalCode',
388
475
  data: searchResults
389
476
  });
390
- case 19:
477
+ case 23:
391
478
  // 将搜索结果存储到缓存数组中
392
479
  if (searchResults.length > 0) {
393
480
  // 避免重复存储相同的识别码
@@ -407,20 +494,30 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
407
494
  cachedSearchResults: _toConsumableArray(this.searchResults),
408
495
  searchParams: params
409
496
  });
497
+ this.paymentModule.logInfo('[WalletPass] 普通识别码搜索完成', {
498
+ code: params.code,
499
+ results_count: searchResults.length,
500
+ cached_results_count: this.searchResults.length,
501
+ type: 'normalCode'
502
+ });
410
503
  return _context5.abrupt("return", {
411
504
  type: 'normalCode',
412
505
  data: searchResults
413
506
  });
414
- case 24:
415
- _context5.prev = 24;
507
+ case 29:
508
+ _context5.prev = 29;
416
509
  _context5.t0 = _context5["catch"](1);
417
- console.error('[WalletPass] 搜索识别码信息失败:', _context5.t0);
510
+ this.paymentModule.logError('[WalletPass] 搜索识别码信息失败', _context5.t0, {
511
+ code: params.code,
512
+ customer_id: params.customer_id,
513
+ order_expect_amount: params.order_expect_amount
514
+ });
418
515
  throw _context5.t0;
419
- case 28:
516
+ case 33:
420
517
  case "end":
421
518
  return _context5.stop();
422
519
  }
423
- }, _callee5, this, [[1, 24]]);
520
+ }, _callee5, this, [[1, 29]]);
424
521
  }));
425
522
  function searchIdentificationCodeAsync(_x5) {
426
523
  return _searchIdentificationCodeAsync.apply(this, arguments);
@@ -435,16 +532,26 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
435
532
  return _regeneratorRuntime().wrap(function _callee6$(_context6) {
436
533
  while (1) switch (_context6.prev = _context6.next) {
437
534
  case 0:
438
- _context6.next = 2;
535
+ this.paymentModule.logInfo('[WalletPass] 开始处理钱包支付', {
536
+ amount: amount,
537
+ orderUuid: orderUuid,
538
+ voucherId: voucherId || 'none'
539
+ });
540
+ _context6.next = 3;
439
541
  return this.paymentModule.getWalletPaymentMethod();
440
- case 2:
542
+ case 3:
441
543
  walletMethod = _context6.sent;
442
544
  if (walletMethod) {
443
- _context6.next = 5;
545
+ _context6.next = 7;
444
546
  break;
445
547
  }
548
+ this.paymentModule.logError('[WalletPass] 钱包支付方式未找到', null, {
549
+ amount: amount,
550
+ orderUuid: orderUuid,
551
+ voucherId: voucherId
552
+ });
446
553
  throw new Error('钱包支付方式未找到');
447
- case 5:
554
+ case 7:
448
555
  paymentItem = {
449
556
  amount: amount.toString(),
450
557
  code: walletMethod.code,
@@ -453,9 +560,16 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
453
560
  type: walletMethod.type,
454
561
  voucher_id: voucherId || ''
455
562
  };
456
- _context6.next = 8;
563
+ _context6.next = 10;
457
564
  return this.paymentModule.addPaymentItemAsync(orderUuid, paymentItem);
458
- case 8:
565
+ case 10:
566
+ this.paymentModule.logInfo('[WalletPass] 钱包支付处理完成', {
567
+ amount: amount,
568
+ orderUuid: orderUuid,
569
+ voucherId: voucherId || 'none',
570
+ payment_method: walletMethod.name
571
+ });
572
+ case 11:
459
573
  case "end":
460
574
  return _context6.stop();
461
575
  }
@@ -515,7 +629,7 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
515
629
  this.emitEvent(WalletPassHooks.OnWalletRecommendListCleared, {
516
630
  clearedTypes: ['walletRecommendList']
517
631
  });
518
- console.log('[WalletPass] 钱包推荐列表已清除');
632
+ this.paymentModule.logInfo('[WalletPass] 钱包推荐列表已清除');
519
633
  }
520
634
 
521
635
  /**
@@ -530,7 +644,7 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
530
644
  this.emitEvent(WalletPassHooks.OnUserIdentificationCodesCleared, {
531
645
  clearedTypes: ['userIdentificationCodes']
532
646
  });
533
- console.log('[WalletPass] 用户识别码列表已清除');
647
+ this.paymentModule.logInfo('[WalletPass] 用户识别码列表已清除');
534
648
  }
535
649
 
536
650
  /**
@@ -560,7 +674,7 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
560
674
  key: "clearSearchResults",
561
675
  value: function clearSearchResults() {
562
676
  this.searchResults = [];
563
- console.log('[WalletPass] 搜索结果缓存已清除');
677
+ this.paymentModule.logInfo('[WalletPass] 搜索结果缓存已清除');
564
678
  }
565
679
 
566
680
  /**
@@ -578,7 +692,9 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
578
692
  this.emitEvent(WalletPassHooks.OnWalletCacheCleared, {
579
693
  clearedTypes: ['all']
580
694
  });
581
- console.log('[WalletPass] 所有缓存数据已清除(包括钱包参数和搜索结果)');
695
+ this.paymentModule.logInfo('[WalletPass] 所有缓存数据已清除', {
696
+ cleared_types: ['walletRecommendList', 'userIdentificationCodes', 'searchResults', 'walletParams']
697
+ });
582
698
  }
583
699
  }]);
584
700
  return WalletPassPaymentImpl;
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
49
49
  getCategories(): ProductCategory[];
50
50
  setOtherParams(key: string, value: any): void;
51
51
  getOtherParams(): any;
52
- getProductType(): "duration" | "session" | "normal";
52
+ getProductType(): "normal" | "duration" | "session";
53
53
  }
@@ -314,7 +314,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
314
314
  }[];
315
315
  setOtherData(key: string, value: any): void;
316
316
  getOtherData(key: string): any;
317
- getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
317
+ getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
318
318
  /**
319
319
  * 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
320
320
  *
@@ -111,7 +111,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
111
111
  * 获取当前的客户搜索条件
112
112
  * @returns 当前搜索条件
113
113
  */
114
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
114
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
115
115
  /**
116
116
  * 获取客户列表状态(包含滚动加载相关状态)
117
117
  * @returns 客户状态
@@ -31,19 +31,19 @@ export declare class PaymentModule extends BaseModule implements Module, Payment
31
31
  /**
32
32
  * 记录信息日志
33
33
  */
34
- private logInfo;
34
+ logInfo(title: string, metadata?: any): void;
35
35
  /**
36
36
  * 记录警告日志
37
37
  */
38
- private logWarning;
38
+ logWarning(title: string, metadata?: any): void;
39
39
  /**
40
40
  * 记录错误日志
41
41
  */
42
- private logError;
42
+ logError(title: string, error?: any, metadata?: any): void;
43
43
  /**
44
44
  * 记录调试日志
45
45
  */
46
- private logDebug;
46
+ logDebug(title: string, metadata?: any): void;
47
47
  /**
48
48
  * 网络恢复以后,尝试执行队列
49
49
  *
@@ -40,7 +40,7 @@ var WalletPassPaymentImpl = class {
40
40
  try {
41
41
  this.paymentModule.core.effects.emit(hook, data);
42
42
  } catch (error) {
43
- console.error("[WalletPass] 发送事件失败:", hook, error);
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
- console.log("[WalletPass] 钱包默认参数已生成并存储:", walletParams);
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
- console.log("[WalletPass] 已存储的钱包参数已清理");
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
- console.log(`[WalletPass] 从业务数据初始化钱包数据成功,耗时: ${duration}ms`);
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
- console.error(`[WalletPass] 从业务数据初始化钱包数据失败,耗时: ${duration}ms`, error);
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
- console.error("[WalletPass] 初始化钱包数据失败:", error);
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
- console.log(
167
- "[WalletPass] 钱包推荐列表已更新:",
168
- this.walletRecommendList.length,
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
- console.error("获取钱包推荐列表失败:", error);
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
- console.log(
196
- "[WalletPass] 用户识别码列表已更新:",
197
- this.userIdentificationCodes.length,
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
- console.error("获取用户识别码列表失败:", error);
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
- console.error("[WalletPass] 搜索识别码信息失败:", error);
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
- console.log("[WalletPass] 钱包推荐列表已清除");
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
- console.log("[WalletPass] 用户识别码列表已清除");
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
- console.log("[WalletPass] 搜索结果缓存已清除");
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
- console.log("[WalletPass] 所有缓存数据已清除(包括钱包参数和搜索结果)");
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:
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
49
49
  getCategories(): ProductCategory[];
50
50
  setOtherParams(key: string, value: any): void;
51
51
  getOtherParams(): any;
52
- getProductType(): "duration" | "session" | "normal";
52
+ getProductType(): "normal" | "duration" | "session";
53
53
  }
@@ -314,7 +314,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
314
314
  }[];
315
315
  setOtherData(key: string, value: any): void;
316
316
  getOtherData(key: string): any;
317
- getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
317
+ getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
318
318
  /**
319
319
  * 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
320
320
  *
@@ -111,7 +111,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
111
111
  * 获取当前的客户搜索条件
112
112
  * @returns 当前搜索条件
113
113
  */
114
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
114
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
115
115
  /**
116
116
  * 获取客户列表状态(包含滚动加载相关状态)
117
117
  * @returns 客户状态
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "0.0.255",
4
+ "version": "0.0.256",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",