@pisell/pisellos 2.1.100 → 2.1.101

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.
Files changed (80) hide show
  1. package/dist/effects/index.d.ts +2 -2
  2. package/dist/modules/Customer/types.d.ts +1 -1
  3. package/dist/modules/Payment/types.d.ts +7 -7
  4. package/dist/modules/Rules/types.d.ts +1 -1
  5. package/dist/modules/Schedule/getDateIsInSchedule.d.ts +1 -1
  6. package/dist/modules/Schedule/type.d.ts +7 -7
  7. package/dist/modules/Schedule/types.d.ts +9 -9
  8. package/dist/solution/BookingByStep/index.d.ts +1 -1
  9. package/dist/solution/BookingByStep/utils/resources.d.ts +1 -1
  10. package/dist/solution/ShopDiscount/types.d.ts +1 -1
  11. package/dist/solution/ShopDiscount/utils.d.ts +2 -2
  12. package/dist/types/index.d.ts +1 -1
  13. package/dist/utils/task.d.ts +2 -2
  14. package/dist/utils/watch.d.ts +2 -2
  15. package/lib/core/index.js +28 -27
  16. package/lib/effects/index.d.ts +2 -2
  17. package/lib/effects/index.js +7 -3
  18. package/lib/modules/Account/index.js +10 -9
  19. package/lib/modules/AccountList/index.js +11 -14
  20. package/lib/modules/BaseModule.js +3 -6
  21. package/lib/modules/Cart/index.js +9 -14
  22. package/lib/modules/Cart/utils/cartProduct.js +6 -3
  23. package/lib/modules/Customer/constants.js +1 -1
  24. package/lib/modules/Customer/index.js +15 -18
  25. package/lib/modules/Customer/types.d.ts +1 -1
  26. package/lib/modules/Date/index.js +6 -10
  27. package/lib/modules/Date/types.js +0 -1
  28. package/lib/modules/Discount/index.js +6 -11
  29. package/lib/modules/Guests/index.js +15 -10
  30. package/lib/modules/Order/index.js +7 -10
  31. package/lib/modules/Payment/cash.js +1 -1
  32. package/lib/modules/Payment/cashRecommendationAlgorithm.js +1 -1
  33. package/lib/modules/Payment/eftpos.js +1 -1
  34. package/lib/modules/Payment/index.js +73 -84
  35. package/lib/modules/Payment/types.d.ts +7 -7
  36. package/lib/modules/Payment/utils.js +6 -3
  37. package/lib/modules/Payment/walletpass.js +31 -31
  38. package/lib/modules/Product/index.js +5 -6
  39. package/lib/modules/ProductList/index.js +3 -5
  40. package/lib/modules/Resource/index.js +12 -8
  41. package/lib/modules/Rules/index.js +35 -21
  42. package/lib/modules/Rules/types.d.ts +1 -1
  43. package/lib/modules/Schedule/getDateIsInSchedule.d.ts +1 -1
  44. package/lib/modules/Schedule/index.js +5 -8
  45. package/lib/modules/Schedule/type.d.ts +7 -7
  46. package/lib/modules/Schedule/types.d.ts +9 -9
  47. package/lib/modules/Schedule/utils.js +4 -2
  48. package/lib/modules/Step/index.js +4 -7
  49. package/lib/modules/Summary/index.js +4 -9
  50. package/lib/modules/Summary/utils.js +16 -8
  51. package/lib/plugins/request.js +33 -34
  52. package/lib/plugins/window.js +113 -101
  53. package/lib/solution/BookingByStep/index.d.ts +1 -1
  54. package/lib/solution/BookingByStep/index.js +177 -110
  55. package/lib/solution/BookingByStep/utils/capacity.js +16 -11
  56. package/lib/solution/BookingByStep/utils/resources.d.ts +1 -1
  57. package/lib/solution/BookingByStep/utils/resources.js +8 -4
  58. package/lib/solution/BookingByStep/utils/stock.js +6 -3
  59. package/lib/solution/BookingByStep/utils/timeslots.js +27 -24
  60. package/lib/solution/BookingTicket/index.js +14 -19
  61. package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +3 -3
  62. package/lib/solution/BookingTicket/utils/scan/handleScan.js +6 -6
  63. package/lib/solution/BookingTicket/utils/scan/index.js +1 -3
  64. package/lib/solution/BookingTicket/utils/scan/scanCache.js +9 -10
  65. package/lib/solution/BuyTickets/index.js +15 -15
  66. package/lib/solution/Checkout/index.js +211 -216
  67. package/lib/solution/Checkout/utils/index.js +22 -18
  68. package/lib/solution/RegisterAndLogin/config.js +2 -2
  69. package/lib/solution/RegisterAndLogin/index.js +110 -114
  70. package/lib/solution/RegisterAndLogin/utils.js +9 -9
  71. package/lib/solution/ShopDiscount/index.js +13 -16
  72. package/lib/solution/ShopDiscount/types.d.ts +1 -1
  73. package/lib/solution/ShopDiscount/utils.d.ts +2 -2
  74. package/lib/solution/ShopDiscount/utils.js +2 -1
  75. package/lib/types/index.d.ts +1 -1
  76. package/lib/utils/task.d.ts +2 -2
  77. package/lib/utils/task.js +3 -3
  78. package/lib/utils/watch.d.ts +2 -2
  79. package/lib/utils/watch.js +7 -5
  80. package/package.json +17 -16
@@ -37,7 +37,7 @@ function formatAmount(amount) {
37
37
  const decimal = new import_decimal.Decimal(amount);
38
38
  return decimal.toFixed(2);
39
39
  } catch (error) {
40
- console.warn(`[PaymentModule] \u91D1\u989D\u683C\u5F0F\u5316\u5931\u8D25: ${amount}\uFF0C\u4F7F\u7528\u9ED8\u8BA4\u503C 0.00`);
40
+ console.warn(`[PaymentModule] 金额格式化失败: ${amount},使用默认值 0.00`);
41
41
  return "0.00";
42
42
  }
43
43
  }
@@ -54,23 +54,12 @@ function generateRequestUniqueId() {
54
54
  return `${year}${month}${day}${hour}${minute}${second}${millisecond}${randomDigits}`;
55
55
  }
56
56
  var PaymentModule = class extends import_BaseModule.BaseModule {
57
- defaultName = "pay";
58
- defaultVersion = "1.0.0";
59
- request;
60
- app;
61
- // App instance
62
- store;
63
- dbManager;
64
- // IndexDBManager 实例
65
- logger;
66
- // LoggerManager 实例
67
- otherParams = {};
68
- // 支付方式实例
69
- cash;
70
- eftpos;
71
- wallet;
72
57
  constructor(name, version) {
73
58
  super(name || "payment", version);
59
+ this.defaultName = "pay";
60
+ this.defaultVersion = "1.0.0";
61
+ // LoggerManager 实例
62
+ this.otherParams = {};
74
63
  this.cash = new import_cash.CashPaymentImpl(this);
75
64
  this.eftpos = new import_eftpos.EftposPaymentImpl(this);
76
65
  this.wallet = new import_walletpass.WalletPassPaymentImpl(this);
@@ -82,17 +71,17 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
82
71
  this.request = core.getPlugin("request");
83
72
  const appPlugin = core.getPlugin("app");
84
73
  if (!this.request) {
85
- throw new Error("\u652F\u4ED8\u6A21\u5757\u9700\u8981 request \u63D2\u4EF6\u652F\u6301");
74
+ throw new Error("支付模块需要 request 插件支持");
86
75
  }
87
76
  if (!appPlugin) {
88
- throw new Error("\u652F\u4ED8\u6A21\u5757\u9700\u8981 app \u63D2\u4EF6\u652F\u6301");
77
+ throw new Error("支付模块需要 app 插件支持");
89
78
  }
90
79
  this.app = appPlugin.getApp();
91
80
  this.dbManager = this.app.dbManager;
92
81
  this.logger = this.app.logger;
93
82
  await this.ensurePaymentTables();
94
83
  this.registerNetworkHandlers();
95
- console.log("[PaymentModule] \u521D\u59CB\u5316\u5B8C\u6210");
84
+ console.log("[PaymentModule] 初始化完成");
96
85
  this.logInfo("PaymentModule initialized successfully");
97
86
  }
98
87
  /**
@@ -167,7 +156,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
167
156
  const network = this.app.plugins.get("network");
168
157
  this.logInfo("Registering network status listener");
169
158
  network == null ? void 0 : network.addListener("networkStatusChange", async (status) => {
170
- console.log("\u7F51\u7EDC\u72B6\u6001:", status.connected);
159
+ console.log("网络状态:", status.connected);
171
160
  this.logInfo("Network status changed", {
172
161
  connected: status.connected,
173
162
  previousStatus: status.previousStatus
@@ -187,7 +176,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
187
176
  try {
188
177
  cachedMethods = await this.dbManager.getAll("pay_method");
189
178
  } catch (dbError) {
190
- console.warn("[PaymentModule] pay_method \u8868\u4E0D\u5B58\u5728\uFF0C\u5C06\u4ECE\u670D\u52A1\u5668\u83B7\u53D6\u6570\u636E");
179
+ console.warn("[PaymentModule] pay_method 表不存在,将从服务器获取数据");
191
180
  }
192
181
  const hasCache = cachedMethods.length > 0;
193
182
  if (hasCache) {
@@ -201,7 +190,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
201
190
  await this.dbManager.update("pay_method", method);
202
191
  }
203
192
  } catch (dbError) {
204
- console.warn("[PaymentModule] \u65E0\u6CD5\u7F13\u5B58\u652F\u4ED8\u65B9\u5F0F\uFF0Cpay_method \u8868\u4E0D\u5B58\u5728");
193
+ console.warn("[PaymentModule] 无法缓存支付方式,pay_method 表不存在");
205
194
  }
206
195
  await this.core.effects.emit(
207
196
  `${this.name}:onPaymentMethodsLoaded`,
@@ -213,7 +202,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
213
202
  });
214
203
  return payMethods;
215
204
  } catch (error) {
216
- console.error("[PaymentModule] \u83B7\u53D6\u652F\u4ED8\u65B9\u5F0F\u5217\u8868\u5931\u8D25", error);
205
+ console.error("[PaymentModule] 获取支付方式列表失败", error);
217
206
  this.logError("getPayMethodListAsync failed", error);
218
207
  return [];
219
208
  }
@@ -226,7 +215,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
226
215
  cachedMethodsCount: cachedMethods.length
227
216
  });
228
217
  try {
229
- console.log("[PaymentModule] \u540E\u53F0\u5237\u65B0\u652F\u4ED8\u65B9\u5F0F\u5217\u8868...");
218
+ console.log("[PaymentModule] 后台刷新支付方式列表...");
230
219
  const response = await this.request.get("/pay/custom-payment/available", { channel: "pos" });
231
220
  const newPayMethods = response.data || [];
232
221
  const hasChanges = this.hasPaymentMethodsChanged(
@@ -234,7 +223,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
234
223
  newPayMethods
235
224
  );
236
225
  if (hasChanges) {
237
- console.log("[PaymentModule] \u652F\u4ED8\u65B9\u5F0F\u5217\u8868\u5DF2\u66F4\u65B0");
226
+ console.log("[PaymentModule] 支付方式列表已更新");
238
227
  this.logInfo("Payment methods updated in background", {
239
228
  oldCount: cachedMethods.length,
240
229
  newCount: newPayMethods.length
@@ -247,7 +236,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
247
236
  await this.dbManager.update("pay_method", method);
248
237
  }
249
238
  } catch (dbError) {
250
- console.warn("[PaymentModule] \u65E0\u6CD5\u66F4\u65B0\u652F\u4ED8\u65B9\u5F0F\u7F13\u5B58", dbError);
239
+ console.warn("[PaymentModule] 无法更新支付方式缓存", dbError);
251
240
  }
252
241
  const eventData = {
253
242
  oldMethods: cachedMethods,
@@ -258,10 +247,10 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
258
247
  eventData
259
248
  );
260
249
  } else {
261
- console.log("[PaymentModule] \u652F\u4ED8\u65B9\u5F0F\u5217\u8868\u65E0\u53D8\u5316");
250
+ console.log("[PaymentModule] 支付方式列表无变化");
262
251
  }
263
252
  } catch (error) {
264
- console.error("[PaymentModule] \u540E\u53F0\u5237\u65B0\u652F\u4ED8\u65B9\u5F0F\u5931\u8D25", error);
253
+ console.error("[PaymentModule] 后台刷新支付方式失败", error);
265
254
  }
266
255
  }
267
256
  /**
@@ -280,7 +269,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
280
269
  return true;
281
270
  }
282
271
  if (oldMethod.code !== newMethod.code || oldMethod.name !== newMethod.name || oldMethod.type !== newMethod.type || oldMethod.description !== newMethod.description || oldMethod.status !== newMethod.status || oldMethod.disable !== newMethod.disable || oldMethod.is_surcharge !== newMethod.is_surcharge || oldMethod.fixed !== newMethod.fixed || oldMethod.percentage !== newMethod.percentage || oldMethod.enabled !== newMethod.enabled || JSON.stringify(oldMethod.channel_application || []) !== JSON.stringify(newMethod.channel_application || []) || JSON.stringify(oldMethod.companies || []) !== JSON.stringify(newMethod.companies || []) || JSON.stringify(oldMethod.metadata || {}) !== JSON.stringify(newMethod.metadata || {})) {
283
- console.log(`[PaymentModule] \u652F\u4ED8\u65B9\u5F0F ${newMethod.id} (${newMethod.code}) \u53D1\u751F\u53D8\u5316:`, {
272
+ console.log(`[PaymentModule] 支付方式 ${newMethod.id} (${newMethod.code}) 发生变化:`, {
284
273
  id: newMethod.id,
285
274
  changes: {
286
275
  code: oldMethod.code !== newMethod.code ? { old: oldMethod.code, new: newMethod.code } : void 0,
@@ -310,7 +299,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
310
299
  try {
311
300
  return await this.dbManager.getAll("order");
312
301
  } catch (error) {
313
- console.error("[PaymentModule] \u83B7\u53D6\u8BA2\u5355\u5217\u8868\u5931\u8D25", error);
302
+ console.error("[PaymentModule] 获取订单列表失败", error);
314
303
  return [];
315
304
  }
316
305
  }
@@ -321,7 +310,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
321
310
  try {
322
311
  return await this.dbManager.get("order", orderUuid, true);
323
312
  } catch (error) {
324
- console.error("[PaymentModule] \u83B7\u53D6\u652F\u4ED8\u8BA2\u5355\u5931\u8D25", error);
313
+ console.error("[PaymentModule] 获取支付订单失败", error);
325
314
  return null;
326
315
  }
327
316
  }
@@ -364,7 +353,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
364
353
  }, 0);
365
354
  return newOrder;
366
355
  } catch (error) {
367
- console.error("[PaymentModule] \u521B\u5EFA\u652F\u4ED8\u8BA2\u5355\u5931\u8D25", error);
356
+ console.error("[PaymentModule] 创建支付订单失败", error);
368
357
  this.logError("createPaymentOrderAsync failed", error, {
369
358
  orderId: params.order_id
370
359
  });
@@ -380,10 +369,10 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
380
369
  if (order) {
381
370
  await this.dbManager.delete("order", orderUuid);
382
371
  await this.core.effects.emit(`${this.name}:onOrderDeleted`, order);
383
- console.log("[PaymentModule] \u652F\u4ED8\u8BA2\u5355\u5220\u9664\u6210\u529F:", orderUuid);
372
+ console.log("[PaymentModule] 支付订单删除成功:", orderUuid);
384
373
  }
385
374
  } catch (error) {
386
- console.error("[PaymentModule] \u5220\u9664\u652F\u4ED8\u8BA2\u5355\u5931\u8D25", error);
375
+ console.error("[PaymentModule] 删除支付订单失败", error);
387
376
  throw error;
388
377
  }
389
378
  }
@@ -405,7 +394,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
405
394
  });
406
395
  }
407
396
  } catch (error) {
408
- console.error("[PaymentModule] \u66F4\u65B0\u8BA2\u5355\u5931\u8D25", error);
397
+ console.error("[PaymentModule] 更新订单失败", error);
409
398
  throw error;
410
399
  }
411
400
  }
@@ -439,7 +428,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
439
428
  newOrderId,
440
429
  existingOrderUuid: duplicateOrder.uuid
441
430
  });
442
- throw new Error(`\u8BA2\u5355ID ${newOrderId} \u5DF2\u5B58\u5728`);
431
+ throw new Error(`订单ID ${newOrderId} 已存在`);
443
432
  }
444
433
  const originalOrderId = existingOrder.id;
445
434
  const updatedOrder = {
@@ -471,10 +460,10 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
471
460
  originalOrderId,
472
461
  newOrderId
473
462
  });
474
- console.log(`[PaymentModule] \u8BA2\u5355ID\u66FF\u6362\u6210\u529F: ${originalOrderId} \u2192 ${newOrderId}`);
463
+ console.log(`[PaymentModule] 订单ID替换成功: ${originalOrderId} ${newOrderId}`);
475
464
  return updatedOrder;
476
465
  } catch (error) {
477
- console.error("[PaymentModule] \u66FF\u6362\u8BA2\u5355ID\u5931\u8D25", error);
466
+ console.error("[PaymentModule] 替换订单ID失败", error);
478
467
  this.logError("replaceOrderIdByUuidAsync failed", error, {
479
468
  orderUuid,
480
469
  newOrderId
@@ -521,11 +510,11 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
521
510
  orderPaymentType: paymentItem.order_payment_type
522
511
  });
523
512
  try {
524
- this.logInfo("\u51C6\u5907\u83B7\u53D6\u8BA2\u5355", {
513
+ this.logInfo("准备获取订单", {
525
514
  orderUuid
526
515
  });
527
516
  const order = await this.getPaymentOrderByUuidAsync(orderUuid);
528
- this.logInfo("\u83B7\u53D6\u8BA2\u5355\u4FE1\u606F\u6210\u529F", {
517
+ this.logInfo("获取订单信息成功", {
529
518
  orderUuid,
530
519
  order
531
520
  });
@@ -541,7 +530,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
541
530
  }, new import_decimal.Decimal(0));
542
531
  const expectedDepositAmount = new import_decimal.Decimal(order.deposit_amount || "0").sub(paidDepositAmount);
543
532
  if (expectAmount.lte(0) && expectedDepositAmount.eq(0)) {
544
- const warningMessage = `\u8BA2\u5355 ${orderUuid} \u5F85\u4ED8\u91D1\u989D\u5DF2\u4E3A0\uFF0C\u4E0D\u5141\u8BB8\u6DFB\u52A0\u65B0\u7684\u652F\u4ED8\u9879`;
533
+ const warningMessage = `订单 ${orderUuid} 待付金额已为0,不允许添加新的支付项`;
545
534
  console.warn("[PaymentModule] Payment lock triggered:", {
546
535
  orderUuid,
547
536
  expectAmount: order.expect_amount,
@@ -585,12 +574,12 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
585
574
  };
586
575
  order.payment.push(newPaymentItem);
587
576
  this.recalculateOrderAmount(order);
588
- this.logInfo("\u5F00\u59CB\u66F4\u65B0\u8BA2\u5355\u652F\u4ED8\u9879", {
577
+ this.logInfo("开始更新订单支付项", {
589
578
  orderUuid,
590
579
  order
591
580
  });
592
581
  await this.dbManager.update("order", order, true);
593
- this.logInfo("\u66F4\u65B0\u8BA2\u5355\u652F\u4ED8\u9879\u5B8C\u6210", {
582
+ this.logInfo("更新订单支付项完成", {
594
583
  orderUuid
595
584
  });
596
585
  this.core.effects.emit(`${this.name}:onPaymentAdded`, {
@@ -611,7 +600,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
611
600
  changeGivenAmount: (_d = newPaymentItem.metadata) == null ? void 0 : _d.change_given_amount
612
601
  });
613
602
  } catch (error) {
614
- console.error("[PaymentModule] \u6DFB\u52A0\u652F\u4ED8\u9879\u5931\u8D25", error);
603
+ console.error("[PaymentModule] 添加支付项失败", error);
615
604
  this.logError("addPaymentItemAsync failed", error, {
616
605
  orderUuid,
617
606
  paymentItem
@@ -627,22 +616,22 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
627
616
  try {
628
617
  const order = await this.dbManager.get("order", orderUuid);
629
618
  if (!order) {
630
- throw new Error("\u8BA2\u5355\u4E0D\u5B58\u5728");
619
+ throw new Error("订单不存在");
631
620
  }
632
621
  const paymentItem = order.payment.find(
633
622
  (payment) => payment.uuid === paymentUuid
634
623
  );
635
624
  if (!paymentItem) {
636
- throw new Error(`\u652F\u4ED8\u9879\u4E0D\u5B58\u5728: ${paymentUuid}`);
625
+ throw new Error(`支付项不存在: ${paymentUuid}`);
637
626
  }
638
627
  if (paymentItem.status === "voided") {
639
- console.warn(`[PaymentModule] \u652F\u4ED8\u9879 ${paymentUuid} \u5DF2\u7ECF\u88AB\u5220\u9664\uFF0C\u8DF3\u8FC7\u64CD\u4F5C`);
628
+ console.warn(`[PaymentModule] 支付项 ${paymentUuid} 已经被删除,跳过操作`);
640
629
  return;
641
630
  }
642
631
  paymentItem.status = "voided";
643
632
  paymentItem.origin_amount = paymentItem.amount;
644
633
  paymentItem.amount = "0.00";
645
- console.log(`[PaymentModule] \u652F\u4ED8\u9879\u6807\u8BB0\u4E3A\u5220\u9664:`, {
634
+ console.log(`[PaymentModule] 支付项标记为删除:`, {
646
635
  uuid: paymentItem.uuid,
647
636
  originalAmount: paymentItem.origin_amount,
648
637
  status: paymentItem.status
@@ -665,7 +654,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
665
654
  newExpectAmount: order.expect_amount
666
655
  });
667
656
  } catch (error) {
668
- console.error("[PaymentModule] \u5220\u9664\u652F\u4ED8\u9879\u5931\u8D25", error);
657
+ console.error("[PaymentModule] 删除支付项失败", error);
669
658
  this.logError("deletePaymentAsync failed", error, {
670
659
  orderUuid,
671
660
  paymentUuid
@@ -693,12 +682,12 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
693
682
  try {
694
683
  const order = await this.getPaymentOrderByUuidAsync(orderUuid);
695
684
  if (!order) {
696
- throw new Error(`\u8BA2\u5355\u4E0D\u5B58\u5728: ${orderUuid}`);
685
+ throw new Error(`订单不存在: ${orderUuid}`);
697
686
  }
698
687
  const existingVoucherItems = order.payment.filter(
699
688
  (payment) => payment.voucher_id && payment.status !== "voided" && !payment.isSynced
700
689
  );
701
- console.log("[PaymentModule] \u53D1\u73B0\u73B0\u6709\u4EE3\u91D1\u5238\u652F\u4ED8\u9879:", {
690
+ console.log("[PaymentModule] 发现现有代金券支付项:", {
702
691
  orderUuid,
703
692
  existingVoucherCount: existingVoucherItems.length,
704
693
  existingItems: existingVoucherItems.map((item) => ({
@@ -710,18 +699,18 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
710
699
  }))
711
700
  });
712
701
  for (const voucherItem of existingVoucherItems) {
713
- console.log(`[PaymentModule] \u5220\u9664\u73B0\u6709\u4EE3\u91D1\u5238\u652F\u4ED8\u9879: ${voucherItem.uuid}`);
702
+ console.log(`[PaymentModule] 删除现有代金券支付项: ${voucherItem.uuid}`);
714
703
  await this.deletePaymentAsync(orderUuid, voucherItem.uuid);
715
704
  }
716
- console.log("[PaymentModule] \u6DFB\u52A0\u65B0\u7684\u4EE3\u91D1\u5238\u652F\u4ED8\u9879:", {
705
+ console.log("[PaymentModule] 添加新的代金券支付项:", {
717
706
  orderUuid,
718
707
  newItemCount: voucherPaymentItems.length
719
708
  });
720
709
  for (const voucherItem of voucherPaymentItems) {
721
710
  if (!voucherItem.voucher_id) {
722
- throw new Error(`\u4EE3\u91D1\u5238\u652F\u4ED8\u9879\u7F3A\u5C11 voucher_id: ${JSON.stringify(voucherItem)}`);
711
+ throw new Error(`代金券支付项缺少 voucher_id: ${JSON.stringify(voucherItem)}`);
723
712
  }
724
- console.log(`[PaymentModule] \u6DFB\u52A0\u4EE3\u91D1\u5238\u652F\u4ED8\u9879:`, {
713
+ console.log(`[PaymentModule] 添加代金券支付项:`, {
725
714
  code: voucherItem.code,
726
715
  amount: voucherItem.amount,
727
716
  voucher_id: voucherItem.voucher_id,
@@ -743,7 +732,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
743
732
  finalExpectAmount: updatedOrder == null ? void 0 : updatedOrder.expect_amount
744
733
  });
745
734
  } catch (error) {
746
- console.error("[PaymentModule] \u6279\u91CF\u66F4\u65B0\u4EE3\u91D1\u5238\u652F\u4ED8\u9879\u5931\u8D25:", error);
735
+ console.error("[PaymentModule] 批量更新代金券支付项失败:", error);
747
736
  this.logError("updateVoucherPaymentItemsAsync failed", error, {
748
737
  orderUuid,
749
738
  voucherPaymentItems
@@ -758,7 +747,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
758
747
  try {
759
748
  const order = await this.dbManager.get("order", orderUuid);
760
749
  if (!order) {
761
- throw new Error("\u8BA2\u5355\u4E0D\u5B58\u5728");
750
+ throw new Error("订单不存在");
762
751
  }
763
752
  const paymentItem = order.payment.find(
764
753
  (payment) => payment.uuid === paymentUuid
@@ -782,7 +771,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
782
771
  });
783
772
  }
784
773
  } catch (error) {
785
- console.error("[PaymentModule] \u66F4\u65B0\u652F\u4ED8\u9879\u5931\u8D25", error);
774
+ console.error("[PaymentModule] 更新支付项失败", error);
786
775
  throw error;
787
776
  }
788
777
  }
@@ -812,7 +801,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
812
801
  });
813
802
  return result;
814
803
  } catch (error) {
815
- console.error("[PaymentModule] \u63D0\u4EA4\u652F\u4ED8\u5931\u8D25", error);
804
+ console.error("[PaymentModule] 提交支付失败", error);
816
805
  this.logError("submitPayAsync failed", error, { orderUuid });
817
806
  return { status: "failed" };
818
807
  }
@@ -845,18 +834,18 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
845
834
  if (totalPaidAmount.gte(orderTotalAmount)) {
846
835
  order.payment_status = import_types.PaymentStatus.Finished;
847
836
  console.log(
848
- `[PaymentModule] \u8BA2\u5355 ${order.uuid} \u652F\u4ED8\u5B8C\u6210\uFF0C\u91D1\u989D: ${totalPaidAmount.toString()}/${orderTotalAmount.toString()}`
837
+ `[PaymentModule] 订单 ${order.uuid} 支付完成,金额: ${totalPaidAmount.toString()}/${orderTotalAmount.toString()}`
849
838
  );
850
839
  } else {
851
840
  order.payment_status = import_types.PaymentStatus.PartiallyPaid;
852
841
  console.log(
853
- `[PaymentModule] \u8BA2\u5355 ${order.uuid} \u90E8\u5206\u652F\u4ED8\uFF0C\u91D1\u989D: ${totalPaidAmount.toString()}/${orderTotalAmount.toString()}`
842
+ `[PaymentModule] 订单 ${order.uuid} 部分支付,金额: ${totalPaidAmount.toString()}/${orderTotalAmount.toString()}`
854
843
  );
855
844
  }
856
845
  paymentData.payment_status = order.payment_status === import_types.PaymentStatus.Finished ? "paid" : "partially_paid";
857
846
  await this.dbManager.update("order", order);
858
847
  if (paymentData.payments.length === 0) {
859
- console.log(`[PaymentModule] \u8BA2\u5355 ${order.uuid} \u652F\u4ED8\u5217\u8868\u4E3A\u7A7A\uFF0C\u8DF3\u8FC7\u652F\u4ED8\u5904\u7406`);
848
+ console.log(`[PaymentModule] 订单 ${order.uuid} 支付列表为空,跳过支付处理`);
860
849
  this.logWarning("Empty payment list", {
861
850
  orderUuid: order.uuid,
862
851
  orderId: order.order_id
@@ -869,7 +858,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
869
858
  order
870
859
  });
871
860
  } catch (error) {
872
- console.error(`[PaymentModule] \u8BA2\u5355 ${order.uuid} \u652F\u4ED8\u63D0\u4EA4\u5931\u8D25`, error);
861
+ console.error(`[PaymentModule] 订单 ${order.uuid} 支付提交失败`, error);
873
862
  throw error;
874
863
  }
875
864
  }
@@ -879,7 +868,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
879
868
  async getRemainingOrderAmountAsync(orderUuid) {
880
869
  const order = await this.getPaymentOrderByUuidAsync(orderUuid);
881
870
  if (!order) {
882
- throw new Error("\u8BA2\u5355\u4E0D\u5B58\u5728");
871
+ throw new Error("订单不存在");
883
872
  }
884
873
  return new import_decimal.Decimal(order.expect_amount).toNumber();
885
874
  }
@@ -889,7 +878,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
889
878
  async getRemainingOrderAmountWithInputAsync(inputAmount, orderUuid) {
890
879
  const order = await this.getPaymentOrderByUuidAsync(orderUuid);
891
880
  if (!order) {
892
- throw new Error("\u8BA2\u5355\u4E0D\u5B58\u5728");
881
+ throw new Error("订单不存在");
893
882
  }
894
883
  if (inputAmount === null || inputAmount === void 0) {
895
884
  return new import_decimal.Decimal(order.expect_amount).toNumber();
@@ -902,7 +891,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
902
891
  if (typeof inputAmount === "number") {
903
892
  if (isNaN(inputAmount) || !isFinite(inputAmount)) {
904
893
  console.warn(
905
- `[PaymentModule] \u8F93\u5165\u91D1\u989D\u4E0D\u662F\u6709\u6548\u6570\u5B57: ${inputAmount}\uFF0C\u8FD4\u56DE\u539F\u59CB\u5F85\u4ED8\u91D1\u989D`
894
+ `[PaymentModule] 输入金额不是有效数字: ${inputAmount},返回原始待付金额`
906
895
  );
907
896
  return new import_decimal.Decimal(order.expect_amount).toNumber();
908
897
  }
@@ -912,7 +901,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
912
901
  return new import_decimal.Decimal(order.expect_amount).minus(inputDecimal).toNumber();
913
902
  } catch (error) {
914
903
  console.warn(
915
- `[PaymentModule] \u8F93\u5165\u91D1\u989D\u683C\u5F0F\u65E0\u6548: ${inputAmount}\uFF0C\u8FD4\u56DE\u539F\u59CB\u5F85\u4ED8\u91D1\u989D`
904
+ `[PaymentModule] 输入金额格式无效: ${inputAmount},返回原始待付金额`
916
905
  );
917
906
  return new import_decimal.Decimal(order.expect_amount).toNumber();
918
907
  }
@@ -933,7 +922,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
933
922
  const effectiveAmount = paymentAmount.plus(roundingAmount.isNegative() ? roundingAmount.abs() : 0);
934
923
  return sum.plus(effectiveAmount);
935
924
  } catch (error) {
936
- console.warn(`[PaymentModule] \u65E0\u6548\u7684\u652F\u4ED8\u91D1\u989D: amount=${payment.amount}, rounding_amount=${payment.rounding_amount}\uFF0C\u8DF3\u8FC7\u8BA1\u7B97`);
925
+ console.warn(`[PaymentModule] 无效的支付金额: amount=${payment.amount}, rounding_amount=${payment.rounding_amount},跳过计算`);
937
926
  return sum;
938
927
  }
939
928
  },
@@ -941,7 +930,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
941
930
  );
942
931
  const remainingAmount = order.is_deposit === 1 ? new import_decimal.Decimal(order.deposit_amount).minus(paidAmount) : totalAmount.minus(paidAmount);
943
932
  order.expect_amount = import_decimal.Decimal.max(0, remainingAmount).toFixed(2);
944
- console.log(`[PaymentModule] \u91CD\u65B0\u8BA1\u7B97\u8BA2\u5355\u91D1\u989D:`, {
933
+ console.log(`[PaymentModule] 重新计算订单金额:`, {
945
934
  orderUuid: order.uuid,
946
935
  totalAmount: order.total_amount,
947
936
  effectivePaidAmount: paidAmount.toFixed(2),
@@ -954,7 +943,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
954
943
  rounding_amount: p.rounding_amount || "0.00",
955
944
  effective_amount: new import_decimal.Decimal(p.amount || 0).plus(new import_decimal.Decimal(Number(p.rounding_amount) > 0 ? 0 : p.rounding_amount || 0).abs()).toFixed(2)
956
945
  })),
957
- \u8BF4\u660E: "\u6709\u6548\u652F\u4ED8\u91D1\u989D\u5305\u542B\u62B9\u96F6\u8BA1\u7B97\uFF08amount + |rounding_amount|\uFF09"
946
+ 说明: "有效支付金额包含抹零计算(amount + |rounding_amount|)"
958
947
  });
959
948
  }
960
949
  /**
@@ -967,7 +956,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
967
956
  (method) => method.code === import_types.PaymentMethodType.Cash
968
957
  ) || null;
969
958
  } catch (error) {
970
- console.error("[PaymentModule] \u83B7\u53D6\u73B0\u91D1\u652F\u4ED8\u65B9\u5F0F\u5931\u8D25", error);
959
+ console.error("[PaymentModule] 获取现金支付方式失败", error);
971
960
  return null;
972
961
  }
973
962
  }
@@ -981,7 +970,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
981
970
  (method) => method.code === import_types.PaymentMethodType.Eftpos
982
971
  ) || null;
983
972
  } catch (error) {
984
- console.error("[PaymentModule] \u83B7\u53D6Eftpos\u652F\u4ED8\u65B9\u5F0F\u5931\u8D25", error);
973
+ console.error("[PaymentModule] 获取Eftpos支付方式失败", error);
985
974
  return null;
986
975
  }
987
976
  }
@@ -995,7 +984,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
995
984
  (method) => method.code === import_types.PaymentMethodType.Wallet
996
985
  ) || null;
997
986
  } catch (error) {
998
- console.error("[PaymentModule] \u83B7\u53D6\u94B1\u5305\u652F\u4ED8\u65B9\u5F0F\u5931\u8D25", error);
987
+ console.error("[PaymentModule] 获取钱包支付方式失败", error);
999
988
  return null;
1000
989
  }
1001
990
  }
@@ -1007,7 +996,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
1007
996
  await this.dbManager.getAll("pay_method");
1008
997
  } catch (error) {
1009
998
  console.warn(
1010
- "[PaymentModule] pay_method \u8868\u4E0D\u5B58\u5728\uFF0C\u8BF7\u5728\u6570\u636E\u5E93\u914D\u7F6E\u4E2D\u6DFB\u52A0\u4EE5\u4E0B\u914D\u7F6E\uFF1A"
999
+ "[PaymentModule] pay_method 表不存在,请在数据库配置中添加以下配置:"
1011
1000
  );
1012
1001
  console.warn('{ name: "pay_method", keyPath: "id" }');
1013
1002
  }
@@ -1015,7 +1004,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
1015
1004
  await this.dbManager.getAll("order");
1016
1005
  } catch (error) {
1017
1006
  console.warn(
1018
- "[PaymentModule] order \u8868\u4E0D\u5B58\u5728\uFF0C\u8BF7\u5728\u6570\u636E\u5E93\u914D\u7F6E\u4E2D\u6DFB\u52A0\u4EE5\u4E0B\u914D\u7F6E\uFF1A"
1007
+ "[PaymentModule] order 表不存在,请在数据库配置中添加以下配置:"
1019
1008
  );
1020
1009
  console.warn('{ name: "order", keyPath: "uuid" }');
1021
1010
  }
@@ -1030,7 +1019,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
1030
1019
  (order) => order.payment_status === import_types.PaymentStatus.PartiallyPaid
1031
1020
  );
1032
1021
  } catch (error) {
1033
- console.error("[PaymentModule] \u83B7\u53D6\u90E8\u5206\u652F\u4ED8\u8BA2\u5355\u5931\u8D25", error);
1022
+ console.error("[PaymentModule] 获取部分支付订单失败", error);
1034
1023
  return [];
1035
1024
  }
1036
1025
  }
@@ -1050,15 +1039,15 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
1050
1039
  const amount = new import_decimal.Decimal(originalAmount);
1051
1040
  const roundingInterval = new import_decimal.Decimal(interval);
1052
1041
  if (roundingInterval.lte(0)) {
1053
- throw new Error("\u820D\u5165\u95F4\u9694\u5FC5\u987B\u5927\u4E8E 0");
1042
+ throw new Error("舍入间隔必须大于 0");
1054
1043
  }
1055
1044
  const supportedIntervals = [0.05, 0.1, 0.5, 1];
1056
1045
  const intervalValue = roundingInterval.toNumber();
1057
1046
  if (!supportedIntervals.includes(intervalValue)) {
1058
- console.warn(`[PaymentModule] \u4E0D\u652F\u6301\u7684\u820D\u5165\u95F4\u9694: ${intervalValue}, \u652F\u6301\u7684\u95F4\u9694: ${supportedIntervals.join(", ")}`);
1047
+ console.warn(`[PaymentModule] 不支持的舍入间隔: ${intervalValue}, 支持的间隔: ${supportedIntervals.join(", ")}`);
1059
1048
  }
1060
1049
  const baseValue = amount.div(roundingInterval);
1061
- console.log(`[PaymentModule] \u820D\u5165\u8BA1\u7B97 - \u539F\u59CB\u91D1\u989D: ${amount.toString()}, \u95F4\u9694: ${intervalValue}, \u57FA\u7840\u503C: ${baseValue.toString()}, \u89C4\u5219: ${rule}`);
1050
+ console.log(`[PaymentModule] 舍入计算 - 原始金额: ${amount.toString()}, 间隔: ${intervalValue}, 基础值: ${baseValue.toString()}, 规则: ${rule}`);
1062
1051
  let roundedValue;
1063
1052
  switch (rule) {
1064
1053
  case import_types.RoundingRule.Standard:
@@ -1078,12 +1067,12 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
1078
1067
  roundedValue = baseValue.floor();
1079
1068
  break;
1080
1069
  default:
1081
- throw new Error(`\u4E0D\u652F\u6301\u7684\u820D\u5165\u89C4\u5219: ${rule}`);
1070
+ throw new Error(`不支持的舍入规则: ${rule}`);
1082
1071
  }
1083
1072
  const finalAmount = roundedValue.mul(roundingInterval);
1084
1073
  const originalAmountStr = amount.toFixed(2);
1085
1074
  if (finalAmount.eq(0)) {
1086
- console.log(`[PaymentModule] \u6700\u7EC8\u91D1\u989D\u4E3A0\uFF0C\u8FD4\u56DE\u539F\u59CB\u91D1\u989D: ${originalAmountStr}`);
1075
+ console.log(`[PaymentModule] 最终金额为0,返回原始金额: ${originalAmountStr}`);
1087
1076
  return {
1088
1077
  originalAmount: originalAmountStr,
1089
1078
  roundedAmount: originalAmountStr,
@@ -1093,15 +1082,15 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
1093
1082
  const roundedAmountStr = finalAmount.toFixed(2);
1094
1083
  const roundingDifference = finalAmount.sub(amount);
1095
1084
  const roundingDifferenceStr = roundingDifference.toFixed(2);
1096
- console.log(`[PaymentModule] \u820D\u5165\u7ED3\u679C - \u539F\u59CB\u91D1\u989D: ${originalAmountStr}, \u820D\u5165\u540E\u91D1\u989D: ${roundedAmountStr}, \u820D\u5165\u5DEE\u989D: ${roundingDifferenceStr}`);
1085
+ console.log(`[PaymentModule] 舍入结果 - 原始金额: ${originalAmountStr}, 舍入后金额: ${roundedAmountStr}, 舍入差额: ${roundingDifferenceStr}`);
1097
1086
  return {
1098
1087
  originalAmount: originalAmountStr,
1099
1088
  roundedAmount: roundedAmountStr,
1100
1089
  roundingDifference: roundingDifferenceStr
1101
1090
  };
1102
1091
  } catch (error) {
1103
- console.error("[PaymentModule] \u91D1\u989D\u820D\u5165\u5931\u8D25:", error);
1104
- throw new Error(`\u91D1\u989D\u820D\u5165\u5931\u8D25: ${error instanceof Error ? error.message : String(error)}`);
1092
+ console.error("[PaymentModule] 金额舍入失败:", error);
1093
+ throw new Error(`金额舍入失败: ${error instanceof Error ? error.message : String(error)}`);
1105
1094
  }
1106
1095
  }
1107
1096
  /**
@@ -581,12 +581,12 @@ export declare enum PaymentHooks {
581
581
  OnOrderAmountChanged = "payment:onOrderAmountChanged",
582
582
  OnPaymentSyncError = "payment:onPaymentSyncError",
583
583
  OnPaymentSyncSuccess = "payment:onPaymentSyncSuccess",
584
- OnWalletRecommendListUpdated = 0,
585
- OnWalletRecommendListCleared = 0,
586
- OnUserIdentificationCodesUpdated = 0,
587
- OnUserIdentificationCodesCleared = 0,
588
- OnWalletCacheCleared = 0,
589
- OnSearchIdentificationCodeCompleted = 0
584
+ OnWalletRecommendListUpdated = "wallet:onWalletRecommendListUpdated",
585
+ OnWalletRecommendListCleared = "wallet:onWalletRecommendListCleared",
586
+ OnUserIdentificationCodesUpdated = "wallet:onUserIdentificationCodesUpdated",
587
+ OnUserIdentificationCodesCleared = "wallet:onUserIdentificationCodesCleared",
588
+ OnWalletCacheCleared = "wallet:onWalletCacheCleared",
589
+ OnSearchIdentificationCodeCompleted = "wallet:onSearchIdentificationCodeCompleted"
590
590
  }
591
591
  /**
592
592
  * 钱包推荐扣款请求参数
@@ -740,7 +740,7 @@ export interface SearchIdentificationCodeResponse {
740
740
  /**
741
741
  * 搜索识别码结果类型
742
742
  */
743
- export declare type SearchIdentificationCodeResult = {
743
+ export type SearchIdentificationCodeResult = {
744
744
  type: 'walletCode';
745
745
  data: SearchIdentificationCodeItem[];
746
746
  } | {
@@ -46,9 +46,12 @@ var sortUserIdentificationCodeList = (list) => {
46
46
  var _a;
47
47
  const errorCode = (_a = item.unified_error_code) == null ? void 0 : _a.toString();
48
48
  const availableStatus = item.unified_available_status;
49
- if (errorCode && middlePriorityErrorCodes.includes(errorCode)) return 2;
50
- if (availableStatus === 0) return 3;
51
- if (availableStatus === 1) return 1;
49
+ if (errorCode && middlePriorityErrorCodes.includes(errorCode))
50
+ return 2;
51
+ if (availableStatus === 0)
52
+ return 3;
53
+ if (availableStatus === 1)
54
+ return 1;
52
55
  return 0;
53
56
  };
54
57
  const aPriority = getPriority(a);