@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.
@@ -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;
@@ -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
  */