@pisell/pisellos 0.0.207 → 0.0.209

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 (58) hide show
  1. package/dist/effects/index.d.ts +1 -1
  2. package/dist/modules/Cart/index.d.ts +1 -0
  3. package/dist/modules/Cart/index.js +42 -14
  4. package/dist/modules/Cart/utils/changePrice.d.ts +1 -1
  5. package/dist/modules/Cart/utils/changePrice.js +8 -3
  6. package/dist/modules/Order/index.js +2 -2
  7. package/dist/modules/Rules/index.js +5 -5
  8. package/dist/modules/Rules/types.d.ts +1 -1
  9. package/dist/modules/Schedule/type.d.ts +7 -7
  10. package/dist/modules/Schedule/types.d.ts +9 -9
  11. package/dist/solution/BookingByStep/index.d.ts +1 -0
  12. package/dist/solution/BookingByStep/index.js +10 -5
  13. package/dist/solution/BookingByStep/utils/resources.d.ts +1 -1
  14. package/dist/solution/ShopDiscount/types.d.ts +1 -1
  15. package/dist/types/index.d.ts +1 -1
  16. package/lib/core/index.js +28 -27
  17. package/lib/effects/index.d.ts +1 -1
  18. package/lib/effects/index.js +7 -3
  19. package/lib/modules/Account/index.js +10 -9
  20. package/lib/modules/AccountList/index.js +11 -14
  21. package/lib/modules/BaseModule.js +3 -6
  22. package/lib/modules/Cart/index.d.ts +1 -0
  23. package/lib/modules/Cart/index.js +19 -14
  24. package/lib/modules/Cart/utils/cartProduct.js +6 -3
  25. package/lib/modules/Cart/utils/changePrice.d.ts +1 -1
  26. package/lib/modules/Cart/utils/changePrice.js +5 -1
  27. package/lib/modules/Date/index.js +4 -8
  28. package/lib/modules/Date/types.js +0 -1
  29. package/lib/modules/Discount/index.js +6 -11
  30. package/lib/modules/Guests/index.js +15 -10
  31. package/lib/modules/Order/index.js +4 -6
  32. package/lib/modules/Payment/cash.js +1 -1
  33. package/lib/modules/Payment/eftpos.js +1 -1
  34. package/lib/modules/Payment/index.js +86 -98
  35. package/lib/modules/Payment/wallet.js +1 -1
  36. package/lib/modules/Product/index.js +5 -6
  37. package/lib/modules/ProductList/index.js +4 -5
  38. package/lib/modules/Resource/index.js +12 -8
  39. package/lib/modules/Rules/index.js +17 -14
  40. package/lib/modules/Rules/types.d.ts +1 -1
  41. package/lib/modules/Schedule/index.js +5 -8
  42. package/lib/modules/Schedule/type.d.ts +7 -7
  43. package/lib/modules/Schedule/types.d.ts +9 -9
  44. package/lib/modules/Schedule/utils.js +4 -2
  45. package/lib/modules/Step/index.js +4 -7
  46. package/lib/modules/Summary/index.js +4 -9
  47. package/lib/plugins/request.js +33 -34
  48. package/lib/plugins/window.js +113 -101
  49. package/lib/solution/BookingByStep/index.d.ts +1 -0
  50. package/lib/solution/BookingByStep/index.js +79 -53
  51. package/lib/solution/BookingByStep/utils/resources.d.ts +1 -1
  52. package/lib/solution/BookingByStep/utils/resources.js +8 -4
  53. package/lib/solution/BookingByStep/utils/timeslots.js +12 -6
  54. package/lib/solution/BuyTickets/index.js +15 -15
  55. package/lib/solution/ShopDiscount/index.js +11 -15
  56. package/lib/solution/ShopDiscount/types.d.ts +1 -1
  57. package/lib/types/index.d.ts +1 -1
  58. package/package.json +1 -1
@@ -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
  }
@@ -53,23 +53,11 @@ function generateRequestUniqueId() {
53
53
  const randomDigits = Math.floor(Math.random() * 9e3) + 1e3;
54
54
  return `${year}${month}${day}${hour}${minute}${second}${millisecond}${randomDigits}`;
55
55
  }
56
- var PaymentModule = class _PaymentModule 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
- // 支付方式实例
68
- cash;
69
- eftpos;
70
- wallet;
56
+ var PaymentModule = class extends import_BaseModule.BaseModule {
71
57
  constructor(name, version) {
72
58
  super(name, version);
59
+ this.defaultName = "pay";
60
+ this.defaultVersion = "1.0.0";
73
61
  this.cash = new import_cash.CashPaymentImpl(this);
74
62
  this.eftpos = new import_eftpos.EftposPaymentImpl(this);
75
63
  this.wallet = new import_wallet.WalletPaymentImpl(this);
@@ -80,10 +68,10 @@ var PaymentModule = class _PaymentModule extends import_BaseModule.BaseModule {
80
68
  this.request = core.getPlugin("request");
81
69
  const appPlugin = core.getPlugin("app");
82
70
  if (!this.request) {
83
- throw new Error("\u652F\u4ED8\u6A21\u5757\u9700\u8981 request \u63D2\u4EF6\u652F\u6301");
71
+ throw new Error("支付模块需要 request 插件支持");
84
72
  }
85
73
  if (!appPlugin) {
86
- throw new Error("\u652F\u4ED8\u6A21\u5757\u9700\u8981 app \u63D2\u4EF6\u652F\u6301");
74
+ throw new Error("支付模块需要 app 插件支持");
87
75
  }
88
76
  this.app = appPlugin.getApp();
89
77
  this.dbManager = this.app.dbManager;
@@ -91,7 +79,7 @@ var PaymentModule = class _PaymentModule extends import_BaseModule.BaseModule {
91
79
  await this.ensurePaymentTables();
92
80
  this.registerTaskHandlers();
93
81
  this.registerNetworkHandlers();
94
- console.log("[PaymentModule] \u521D\u59CB\u5316\u5B8C\u6210");
82
+ console.log("[PaymentModule] 初始化完成");
95
83
  this.logInfo("PaymentModule initialized successfully");
96
84
  }
97
85
  /**
@@ -158,7 +146,7 @@ var PaymentModule = class _PaymentModule extends import_BaseModule.BaseModule {
158
146
  const network = this.app.plugins.get("network");
159
147
  this.logInfo("Registering network status listener");
160
148
  network == null ? void 0 : network.addListener("networkStatusChange", async (status) => {
161
- console.log("\u7F51\u7EDC\u72B6\u6001:", status.connected);
149
+ console.log("网络状态:", status.connected);
162
150
  this.logInfo("Network status changed", {
163
151
  connected: status.connected,
164
152
  previousStatus: status.previousStatus
@@ -182,7 +170,7 @@ var PaymentModule = class _PaymentModule extends import_BaseModule.BaseModule {
182
170
  try {
183
171
  cachedMethods = await this.dbManager.getAll("pay_method");
184
172
  } catch (dbError) {
185
- console.warn("[PaymentModule] pay_method \u8868\u4E0D\u5B58\u5728\uFF0C\u5C06\u4ECE\u670D\u52A1\u5668\u83B7\u53D6\u6570\u636E");
173
+ console.warn("[PaymentModule] pay_method 表不存在,将从服务器获取数据");
186
174
  }
187
175
  const hasCache = cachedMethods.length > 0;
188
176
  if (hasCache) {
@@ -196,7 +184,7 @@ var PaymentModule = class _PaymentModule extends import_BaseModule.BaseModule {
196
184
  await this.dbManager.update("pay_method", method);
197
185
  }
198
186
  } catch (dbError) {
199
- console.warn("[PaymentModule] \u65E0\u6CD5\u7F13\u5B58\u652F\u4ED8\u65B9\u5F0F\uFF0Cpay_method \u8868\u4E0D\u5B58\u5728");
187
+ console.warn("[PaymentModule] 无法缓存支付方式,pay_method 表不存在");
200
188
  }
201
189
  await this.core.effects.emit(
202
190
  import_types.PaymentHooks.OnPaymentMethodsLoaded,
@@ -208,7 +196,7 @@ var PaymentModule = class _PaymentModule extends import_BaseModule.BaseModule {
208
196
  });
209
197
  return payMethods;
210
198
  } catch (error) {
211
- console.error("[PaymentModule] \u83B7\u53D6\u652F\u4ED8\u65B9\u5F0F\u5217\u8868\u5931\u8D25", error);
199
+ console.error("[PaymentModule] 获取支付方式列表失败", error);
212
200
  this.logError("getPayMethodListAsync failed", error);
213
201
  return [];
214
202
  }
@@ -221,7 +209,7 @@ var PaymentModule = class _PaymentModule extends import_BaseModule.BaseModule {
221
209
  cachedMethodsCount: cachedMethods.length
222
210
  });
223
211
  try {
224
- console.log("[PaymentModule] \u540E\u53F0\u5237\u65B0\u652F\u4ED8\u65B9\u5F0F\u5217\u8868...");
212
+ console.log("[PaymentModule] 后台刷新支付方式列表...");
225
213
  const response = await this.request.get("/pay/custom-payment/available");
226
214
  const newPayMethods = response.data || [];
227
215
  const hasChanges = this.hasPaymentMethodsChanged(
@@ -229,7 +217,7 @@ var PaymentModule = class _PaymentModule extends import_BaseModule.BaseModule {
229
217
  newPayMethods
230
218
  );
231
219
  if (hasChanges) {
232
- console.log("[PaymentModule] \u652F\u4ED8\u65B9\u5F0F\u5217\u8868\u5DF2\u66F4\u65B0");
220
+ console.log("[PaymentModule] 支付方式列表已更新");
233
221
  this.logInfo("Payment methods updated in background", {
234
222
  oldCount: cachedMethods.length,
235
223
  newCount: newPayMethods.length
@@ -242,7 +230,7 @@ var PaymentModule = class _PaymentModule extends import_BaseModule.BaseModule {
242
230
  await this.dbManager.update("pay_method", method);
243
231
  }
244
232
  } catch (dbError) {
245
- console.warn("[PaymentModule] \u65E0\u6CD5\u66F4\u65B0\u652F\u4ED8\u65B9\u5F0F\u7F13\u5B58", dbError);
233
+ console.warn("[PaymentModule] 无法更新支付方式缓存", dbError);
246
234
  }
247
235
  const eventData = {
248
236
  oldMethods: cachedMethods,
@@ -253,10 +241,10 @@ var PaymentModule = class _PaymentModule extends import_BaseModule.BaseModule {
253
241
  eventData
254
242
  );
255
243
  } else {
256
- console.log("[PaymentModule] \u652F\u4ED8\u65B9\u5F0F\u5217\u8868\u65E0\u53D8\u5316");
244
+ console.log("[PaymentModule] 支付方式列表无变化");
257
245
  }
258
246
  } catch (error) {
259
- console.error("[PaymentModule] \u540E\u53F0\u5237\u65B0\u652F\u4ED8\u65B9\u5F0F\u5931\u8D25", error);
247
+ console.error("[PaymentModule] 后台刷新支付方式失败", error);
260
248
  }
261
249
  }
262
250
  /**
@@ -287,7 +275,7 @@ var PaymentModule = class _PaymentModule extends import_BaseModule.BaseModule {
287
275
  try {
288
276
  return await this.dbManager.getAll("order");
289
277
  } catch (error) {
290
- console.error("[PaymentModule] \u83B7\u53D6\u8BA2\u5355\u5217\u8868\u5931\u8D25", error);
278
+ console.error("[PaymentModule] 获取订单列表失败", error);
291
279
  return [];
292
280
  }
293
281
  }
@@ -298,7 +286,7 @@ var PaymentModule = class _PaymentModule extends import_BaseModule.BaseModule {
298
286
  try {
299
287
  return await this.dbManager.get("order", orderUuid);
300
288
  } catch (error) {
301
- console.error("[PaymentModule] \u83B7\u53D6\u8BA2\u5355\u5931\u8D25", error);
289
+ console.error("[PaymentModule] 获取订单失败", error);
302
290
  return null;
303
291
  }
304
292
  }
@@ -317,7 +305,7 @@ var PaymentModule = class _PaymentModule extends import_BaseModule.BaseModule {
317
305
  );
318
306
  if (existingOrder) {
319
307
  console.log(
320
- `[PaymentModule] \u53D1\u73B0\u91CD\u590D\u8BA2\u5355 ID: ${params.order_info.order_id}\uFF0C\u66F4\u65B0\u73B0\u6709\u8BA2\u5355`
308
+ `[PaymentModule] 发现重复订单 ID: ${params.order_info.order_id},更新现有订单`
321
309
  );
322
310
  const originalOrder = { ...existingOrder };
323
311
  existingOrder.order_info = params.order_info;
@@ -359,7 +347,7 @@ var PaymentModule = class _PaymentModule extends import_BaseModule.BaseModule {
359
347
  return newOrder;
360
348
  }
361
349
  } catch (error) {
362
- console.error("[PaymentModule] \u6DFB\u52A0\u8BA2\u5355\u5931\u8D25", error);
350
+ console.error("[PaymentModule] 添加订单失败", error);
363
351
  this.logError("pushOrderAsync failed", error, {
364
352
  orderId: params.order_info.order_id
365
353
  });
@@ -381,7 +369,7 @@ var PaymentModule = class _PaymentModule extends import_BaseModule.BaseModule {
381
369
  });
382
370
  }
383
371
  } catch (error) {
384
- console.error("[PaymentModule] \u5220\u9664\u8BA2\u5355\u5931\u8D25", error);
372
+ console.error("[PaymentModule] 删除订单失败", error);
385
373
  throw error;
386
374
  }
387
375
  }
@@ -402,7 +390,7 @@ var PaymentModule = class _PaymentModule extends import_BaseModule.BaseModule {
402
390
  });
403
391
  }
404
392
  } catch (error) {
405
- console.error("[PaymentModule] \u66F4\u65B0\u8BA2\u5355\u5931\u8D25", error);
393
+ console.error("[PaymentModule] 更新订单失败", error);
406
394
  throw error;
407
395
  }
408
396
  }
@@ -428,7 +416,7 @@ var PaymentModule = class _PaymentModule extends import_BaseModule.BaseModule {
428
416
  try {
429
417
  const order = await this.dbManager.get("order", orderUuid);
430
418
  if (!order) {
431
- throw new Error("\u8BA2\u5355\u4E0D\u5B58\u5728");
419
+ throw new Error("订单不存在");
432
420
  }
433
421
  const newPaymentItem = {
434
422
  ...paymentItem,
@@ -455,7 +443,7 @@ var PaymentModule = class _PaymentModule extends import_BaseModule.BaseModule {
455
443
  newExpectAmount: order.expect_amount
456
444
  });
457
445
  } catch (error) {
458
- console.error("[PaymentModule] \u6DFB\u52A0\u652F\u4ED8\u9879\u5931\u8D25", error);
446
+ console.error("[PaymentModule] 添加支付项失败", error);
459
447
  this.logError("pushPaymentAsync failed", error, {
460
448
  orderUuid,
461
449
  paymentItem
@@ -471,7 +459,7 @@ var PaymentModule = class _PaymentModule extends import_BaseModule.BaseModule {
471
459
  try {
472
460
  const order = await this.dbManager.get("order", orderUuid);
473
461
  if (!order) {
474
- throw new Error("\u8BA2\u5355\u4E0D\u5B58\u5728");
462
+ throw new Error("订单不存在");
475
463
  }
476
464
  const index = order.payment.findIndex(
477
465
  (payment) => payment.uuid === paymentUuid
@@ -491,7 +479,7 @@ var PaymentModule = class _PaymentModule extends import_BaseModule.BaseModule {
491
479
  });
492
480
  }
493
481
  } catch (error) {
494
- console.error("[PaymentModule] \u5220\u9664\u652F\u4ED8\u9879\u5931\u8D25", error);
482
+ console.error("[PaymentModule] 删除支付项失败", error);
495
483
  throw error;
496
484
  }
497
485
  }
@@ -502,7 +490,7 @@ var PaymentModule = class _PaymentModule extends import_BaseModule.BaseModule {
502
490
  try {
503
491
  const order = await this.dbManager.get("order", orderUuid);
504
492
  if (!order) {
505
- throw new Error("\u8BA2\u5355\u4E0D\u5B58\u5728");
493
+ throw new Error("订单不存在");
506
494
  }
507
495
  const paymentItem = order.payment.find(
508
496
  (payment) => payment.uuid === paymentUuid
@@ -526,7 +514,7 @@ var PaymentModule = class _PaymentModule extends import_BaseModule.BaseModule {
526
514
  });
527
515
  }
528
516
  } catch (error) {
529
- console.error("[PaymentModule] \u66F4\u65B0\u652F\u4ED8\u9879\u5931\u8D25", error);
517
+ console.error("[PaymentModule] 更新支付项失败", error);
530
518
  throw error;
531
519
  }
532
520
  }
@@ -568,7 +556,7 @@ var PaymentModule = class _PaymentModule extends import_BaseModule.BaseModule {
568
556
  return { status: "failed" };
569
557
  }
570
558
  } catch (error) {
571
- console.error("[PaymentModule] \u63D0\u4EA4\u652F\u4ED8\u5931\u8D25", error);
559
+ console.error("[PaymentModule] 提交支付失败", error);
572
560
  this.logError("submitPayAsync failed", error, { orderUuid });
573
561
  return { status: "failed" };
574
562
  }
@@ -590,18 +578,18 @@ var PaymentModule = class _PaymentModule extends import_BaseModule.BaseModule {
590
578
  if (totalPaidAmount.gte(orderTotalAmount)) {
591
579
  order.payment_status = import_types.PaymentStatus.Finished;
592
580
  console.log(
593
- `[PaymentModule] \u8BA2\u5355 ${order.uuid} \u652F\u4ED8\u5B8C\u6210\uFF0C\u91D1\u989D: ${totalPaidAmount.toString()}/${orderTotalAmount.toString()}`
581
+ `[PaymentModule] 订单 ${order.uuid} 支付完成,金额: ${totalPaidAmount.toString()}/${orderTotalAmount.toString()}`
594
582
  );
595
583
  } else {
596
584
  order.payment_status = import_types.PaymentStatus.PartiallyPaid;
597
585
  console.log(
598
- `[PaymentModule] \u8BA2\u5355 ${order.uuid} \u90E8\u5206\u652F\u4ED8\uFF0C\u91D1\u989D: ${totalPaidAmount.toString()}/${orderTotalAmount.toString()}`
586
+ `[PaymentModule] 订单 ${order.uuid} 部分支付,金额: ${totalPaidAmount.toString()}/${orderTotalAmount.toString()}`
599
587
  );
600
588
  }
601
589
  paymentData.payment_status = order.payment_status === import_types.PaymentStatus.Finished ? "paid" : "partially_paid";
602
590
  await this.dbManager.update("order", order);
603
591
  if (paymentData.payments.length === 0) {
604
- console.log(`[PaymentModule] \u8BA2\u5355 ${order.uuid} \u652F\u4ED8\u5217\u8868\u4E3A\u7A7A\uFF0C\u8DF3\u8FC7\u961F\u5217\u63A8\u9001`);
592
+ console.log(`[PaymentModule] 订单 ${order.uuid} 支付列表为空,跳过队列推送`);
605
593
  this.logWarning("Empty payment queue submission", {
606
594
  orderUuid: order.uuid,
607
595
  orderId: order.order_info.order_id
@@ -615,7 +603,7 @@ var PaymentModule = class _PaymentModule extends import_BaseModule.BaseModule {
615
603
  order
616
604
  });
617
605
  } catch (error) {
618
- console.error(`[PaymentModule] \u8BA2\u5355 ${order.uuid} \u652F\u4ED8\u63D0\u4EA4\u5931\u8D25`, error);
606
+ console.error(`[PaymentModule] 订单 ${order.uuid} 支付提交失败`, error);
619
607
  throw error;
620
608
  }
621
609
  }
@@ -624,7 +612,7 @@ var PaymentModule = class _PaymentModule extends import_BaseModule.BaseModule {
624
612
  */
625
613
  async addToSyncQueue(order, paymentData) {
626
614
  try {
627
- console.log(`[PaymentModule] \u8BA2\u5355 ${order.uuid} \u5DF2\u6DFB\u52A0\u5230\u540C\u6B65\u961F\u5217`);
615
+ console.log(`[PaymentModule] 订单 ${order.uuid} 已添加到同步队列`);
628
616
  if (this.app.tasksManager) {
629
617
  this.app.tasksManager.addTask({
630
618
  module: "payment",
@@ -644,12 +632,12 @@ var PaymentModule = class _PaymentModule extends import_BaseModule.BaseModule {
644
632
  }
645
633
  ]
646
634
  });
647
- console.log(`[PaymentModule] \u8BA2\u5355 ${order.uuid} \u540C\u6B65\u4EFB\u52A1\u5DF2\u6DFB\u52A0\u5230\u961F\u5217`);
635
+ console.log(`[PaymentModule] 订单 ${order.uuid} 同步任务已添加到队列`);
648
636
  } else {
649
- console.warn("[PaymentModule] TasksManager \u672A\u521D\u59CB\u5316\uFF0C\u65E0\u6CD5\u6DFB\u52A0\u540C\u6B65\u4EFB\u52A1");
637
+ console.warn("[PaymentModule] TasksManager 未初始化,无法添加同步任务");
650
638
  }
651
639
  } catch (error) {
652
- console.error("[PaymentModule] \u6DFB\u52A0\u540C\u6B65\u4EFB\u52A1\u5931\u8D25", error);
640
+ console.error("[PaymentModule] 添加同步任务失败", error);
653
641
  }
654
642
  }
655
643
  /**
@@ -658,7 +646,7 @@ var PaymentModule = class _PaymentModule extends import_BaseModule.BaseModule {
658
646
  async getRemainingOrderAmountAsync(orderUuid) {
659
647
  const order = await this.getOrderByUuidAsync(orderUuid);
660
648
  if (!order) {
661
- throw new Error("\u8BA2\u5355\u4E0D\u5B58\u5728");
649
+ throw new Error("订单不存在");
662
650
  }
663
651
  return new import_decimal.Decimal(order.expect_amount).toNumber();
664
652
  }
@@ -668,7 +656,7 @@ var PaymentModule = class _PaymentModule extends import_BaseModule.BaseModule {
668
656
  async getRemainingOrderAmountWithInputAsync(inputAmount, orderUuid) {
669
657
  const order = await this.getOrderByUuidAsync(orderUuid);
670
658
  if (!order) {
671
- throw new Error("\u8BA2\u5355\u4E0D\u5B58\u5728");
659
+ throw new Error("订单不存在");
672
660
  }
673
661
  if (inputAmount === null || inputAmount === void 0) {
674
662
  return new import_decimal.Decimal(order.expect_amount).toNumber();
@@ -681,7 +669,7 @@ var PaymentModule = class _PaymentModule extends import_BaseModule.BaseModule {
681
669
  if (typeof inputAmount === "number") {
682
670
  if (isNaN(inputAmount) || !isFinite(inputAmount)) {
683
671
  console.warn(
684
- `[PaymentModule] \u8F93\u5165\u91D1\u989D\u4E0D\u662F\u6709\u6548\u6570\u5B57: ${inputAmount}\uFF0C\u8FD4\u56DE\u539F\u59CB\u5F85\u4ED8\u91D1\u989D`
672
+ `[PaymentModule] 输入金额不是有效数字: ${inputAmount},返回原始待付金额`
685
673
  );
686
674
  return new import_decimal.Decimal(order.expect_amount).toNumber();
687
675
  }
@@ -691,7 +679,7 @@ var PaymentModule = class _PaymentModule extends import_BaseModule.BaseModule {
691
679
  return new import_decimal.Decimal(order.expect_amount).minus(inputDecimal).toNumber();
692
680
  } catch (error) {
693
681
  console.warn(
694
- `[PaymentModule] \u8F93\u5165\u91D1\u989D\u683C\u5F0F\u65E0\u6548: ${inputAmount}\uFF0C\u8FD4\u56DE\u539F\u59CB\u5F85\u4ED8\u91D1\u989D`
682
+ `[PaymentModule] 输入金额格式无效: ${inputAmount},返回原始待付金额`
695
683
  );
696
684
  return new import_decimal.Decimal(order.expect_amount).toNumber();
697
685
  }
@@ -718,7 +706,7 @@ var PaymentModule = class _PaymentModule extends import_BaseModule.BaseModule {
718
706
  (method) => method.code === import_types.PaymentMethodType.Cash
719
707
  ) || null;
720
708
  } catch (error) {
721
- console.error("[PaymentModule] \u83B7\u53D6\u73B0\u91D1\u652F\u4ED8\u65B9\u5F0F\u5931\u8D25", error);
709
+ console.error("[PaymentModule] 获取现金支付方式失败", error);
722
710
  return null;
723
711
  }
724
712
  }
@@ -732,7 +720,7 @@ var PaymentModule = class _PaymentModule extends import_BaseModule.BaseModule {
732
720
  (method) => method.code === import_types.PaymentMethodType.Eftpos
733
721
  ) || null;
734
722
  } catch (error) {
735
- console.error("[PaymentModule] \u83B7\u53D6Eftpos\u652F\u4ED8\u65B9\u5F0F\u5931\u8D25", error);
723
+ console.error("[PaymentModule] 获取Eftpos支付方式失败", error);
736
724
  return null;
737
725
  }
738
726
  }
@@ -746,7 +734,7 @@ var PaymentModule = class _PaymentModule extends import_BaseModule.BaseModule {
746
734
  (method) => method.code === import_types.PaymentMethodType.Wallet
747
735
  ) || null;
748
736
  } catch (error) {
749
- console.error("[PaymentModule] \u83B7\u53D6\u94B1\u5305\u652F\u4ED8\u65B9\u5F0F\u5931\u8D25", error);
737
+ console.error("[PaymentModule] 获取钱包支付方式失败", error);
750
738
  return null;
751
739
  }
752
740
  }
@@ -757,12 +745,12 @@ var PaymentModule = class _PaymentModule extends import_BaseModule.BaseModule {
757
745
  if (this.app.tasksManager) {
758
746
  this.app.tasksManager.addTaskFunction(
759
747
  "syncPayment",
760
- _PaymentModule.syncPaymentTask
748
+ PaymentModule.syncPaymentTask
761
749
  );
762
- console.log("[PaymentModule] \u4EFB\u52A1\u5904\u7406\u51FD\u6570\u5DF2\u6CE8\u518C");
750
+ console.log("[PaymentModule] 任务处理函数已注册");
763
751
  } else {
764
752
  console.warn(
765
- "[PaymentModule] TasksManager \u672A\u521D\u59CB\u5316\uFF0C\u65E0\u6CD5\u6CE8\u518C\u4EFB\u52A1\u5904\u7406\u51FD\u6570"
753
+ "[PaymentModule] TasksManager 未初始化,无法注册任务处理函数"
766
754
  );
767
755
  }
768
756
  }
@@ -773,7 +761,7 @@ var PaymentModule = class _PaymentModule extends import_BaseModule.BaseModule {
773
761
  static async syncPaymentTask(payload) {
774
762
  var _a, _b, _c, _d, _e, _f;
775
763
  const { orderUuid, orderId, paymentData, core } = payload.task.payload;
776
- console.log(`[PaymentModule] \u5F00\u59CB\u540E\u53F0\u540C\u6B65\u652F\u4ED8\uFF0C\u8BA2\u5355ID: ${orderId}`);
764
+ console.log(`[PaymentModule] 开始后台同步支付,订单ID: ${orderId}`);
777
765
  paymentData.request_unique = generateRequestUniqueId();
778
766
  const app = window.app;
779
767
  const logger = app == null ? void 0 : app.logger;
@@ -789,15 +777,15 @@ var PaymentModule = class _PaymentModule extends import_BaseModule.BaseModule {
789
777
  });
790
778
  }
791
779
  if (!app) {
792
- throw new Error("App \u5B9E\u4F8B\u672A\u627E\u5230");
780
+ throw new Error("App 实例未找到");
793
781
  }
794
782
  const request = app.request;
795
783
  if (!request) {
796
- throw new Error("Request \u63D2\u4EF6\u672A\u627E\u5230");
784
+ throw new Error("Request 插件未找到");
797
785
  }
798
786
  const dbManager = app.dbManager;
799
787
  if (!dbManager) {
800
- throw new Error("DBManager \u672A\u627E\u5230");
788
+ throw new Error("DBManager 未找到");
801
789
  }
802
790
  try {
803
791
  const requestRes = await request.post(
@@ -813,16 +801,16 @@ var PaymentModule = class _PaymentModule extends import_BaseModule.BaseModule {
813
801
  delete payment.syncError;
814
802
  });
815
803
  await dbManager.update("order", order);
816
- console.log(`[PaymentModule] \u8BA2\u5355 ${orderUuid} \u540C\u6B65\u72B6\u6001\u5DF2\u66F4\u65B0`);
804
+ console.log(`[PaymentModule] 订单 ${orderUuid} 同步状态已更新`);
817
805
  }
818
- console.log(`[PaymentModule] \u8BA2\u5355 ${orderUuid} \u540E\u53F0\u540C\u6B65\u6210\u529F`);
806
+ console.log(`[PaymentModule] 订单 ${orderUuid} 后台同步成功`);
819
807
  await core.effects.emit("payment:onPaymentSyncSuccess", {
820
808
  orderUuid,
821
809
  orderId,
822
810
  timestamp: Date.now()
823
811
  });
824
812
  console.log(
825
- `[PaymentModule] \u5DF2\u901A\u8FC7 effects \u901A\u77E5\u524D\u7AEF\u8BA2\u5355 ${orderUuid} \u540C\u6B65\u6210\u529F`
813
+ `[PaymentModule] 已通过 effects 通知前端订单 ${orderUuid} 同步成功`
826
814
  );
827
815
  if (logger) {
828
816
  logger.addLog({
@@ -833,18 +821,18 @@ var PaymentModule = class _PaymentModule extends import_BaseModule.BaseModule {
833
821
  }
834
822
  return { status: "success", orderUuid, orderId };
835
823
  } else {
836
- console.log(`[PaymentModule] \u63A5\u53E3\u8FD4\u56DE\u5931\u8D25\uFF0C\u8BA2\u5355 ${orderUuid} \u540C\u6B65\u5931\u8D25`);
837
- const businessError = new Error(requestRes.message || "\u63A5\u53E3\u8FD4\u56DE\u5931\u8D25");
824
+ console.log(`[PaymentModule] 接口返回失败,订单 ${orderUuid} 同步失败`);
825
+ const businessError = new Error(requestRes.message || "接口返回失败");
838
826
  businessError.response = { status: 200 };
839
827
  businessError.isBusinessError = true;
840
828
  businessError.responseData = requestRes;
841
829
  throw businessError;
842
830
  }
843
831
  } catch (error) {
844
- console.error("[PaymentModule] \u540E\u53F0\u540C\u6B65\u5931\u8D25:", error);
845
- const isNetworkError = !error.response && !error.status && (error.code === "NETWORK_ERROR" || error.code === "ERR_NETWORK" || error.code === "ECONNREFUSED" || error.code === "ENOTFOUND" || error.code === "ETIMEDOUT" || ((_a = error.message) == null ? void 0 : _a.includes("\u7F51\u7EDC")) || ((_b = error.message) == null ? void 0 : _b.includes("network")) || ((_c = error.message) == null ? void 0 : _c.includes("fetch")));
832
+ console.error("[PaymentModule] 后台同步失败:", error);
833
+ const isNetworkError = !error.response && !error.status && (error.code === "NETWORK_ERROR" || error.code === "ERR_NETWORK" || error.code === "ECONNREFUSED" || error.code === "ENOTFOUND" || error.code === "ETIMEDOUT" || ((_a = error.message) == null ? void 0 : _a.includes("网络")) || ((_b = error.message) == null ? void 0 : _b.includes("network")) || ((_c = error.message) == null ? void 0 : _c.includes("fetch")));
846
834
  if (isNetworkError) {
847
- console.log(`[PaymentModule] \u7F51\u7EDC\u9519\u8BEF\uFF0C\u8BA2\u5355 ${orderUuid} \u5C06\u91CD\u8BD5\u540C\u6B65`);
835
+ console.log(`[PaymentModule] 网络错误,订单 ${orderUuid} 将重试同步`);
848
836
  if (logger) {
849
837
  logger.addLog({
850
838
  type: "warning",
@@ -860,29 +848,29 @@ var PaymentModule = class _PaymentModule extends import_BaseModule.BaseModule {
860
848
  throw error;
861
849
  } else {
862
850
  console.log(
863
- `[PaymentModule] \u4E1A\u52A1\u9519\u8BEF\uFF0C\u8BA2\u5355 ${orderUuid} \u540C\u6B65\u5931\u8D25\uFF0C\u901A\u77E5\u524D\u7AEF`
851
+ `[PaymentModule] 业务错误,订单 ${orderUuid} 同步失败,通知前端`
864
852
  );
865
853
  try {
866
854
  if (core && core.effects) {
867
855
  const errorData = {
868
856
  orderUuid,
869
857
  orderId,
870
- error: error.message || "\u4E1A\u52A1\u9519\u8BEF",
858
+ error: error.message || "业务错误",
871
859
  errorCode: error.code,
872
860
  statusCode: ((_d = error.response) == null ? void 0 : _d.status) || error.status,
873
861
  timestamp: Date.now()
874
862
  };
875
863
  if (error.isBusinessError && error.responseData) {
876
- errorData.error = error.responseData.message || error.message || "\u63A5\u53E3\u8FD4\u56DE\u5931\u8D25";
864
+ errorData.error = error.responseData.message || error.message || "接口返回失败";
877
865
  errorData.responseData = error.responseData;
878
866
  }
879
867
  await core.effects.emit("payment:onPaymentSyncError", errorData);
880
868
  console.log(
881
- `[PaymentModule] \u5DF2\u901A\u8FC7 effects \u901A\u77E5\u524D\u7AEF\u8BA2\u5355 ${orderUuid} \u540C\u6B65\u9519\u8BEF`
869
+ `[PaymentModule] 已通过 effects 通知前端订单 ${orderUuid} 同步错误`
882
870
  );
883
871
  } else {
884
872
  console.warn(
885
- `[PaymentModule] \u65E0\u6CD5\u83B7\u53D6 core \u5B9E\u4F8B\uFF0C\u65E0\u6CD5\u901A\u77E5\u524D\u7AEF\u9519\u8BEF`
873
+ `[PaymentModule] 无法获取 core 实例,无法通知前端错误`
886
874
  );
887
875
  }
888
876
  if (logger) {
@@ -900,7 +888,7 @@ var PaymentModule = class _PaymentModule extends import_BaseModule.BaseModule {
900
888
  });
901
889
  }
902
890
  } catch (notifyError) {
903
- console.error(`[PaymentModule] \u901A\u77E5\u524D\u7AEF\u540C\u6B65\u9519\u8BEF\u5931\u8D25:`, notifyError);
891
+ console.error(`[PaymentModule] 通知前端同步错误失败:`, notifyError);
904
892
  if (logger) {
905
893
  logger.addLog({
906
894
  type: "error",
@@ -920,14 +908,14 @@ var PaymentModule = class _PaymentModule extends import_BaseModule.BaseModule {
920
908
  });
921
909
  await dbManager.update("order", order);
922
910
  console.log(
923
- `[PaymentModule] \u8BA2\u5355 ${orderUuid} \u4E1A\u52A1\u9519\u8BEF\uFF0C\u5DF2\u6807\u8BB0\u4E3A\u5DF2\u540C\u6B65`
911
+ `[PaymentModule] 订单 ${orderUuid} 业务错误,已标记为已同步`
924
912
  );
925
913
  }
926
914
  return {
927
915
  status: "completed_with_error",
928
916
  orderUuid,
929
917
  orderId,
930
- error: error.message || "\u4E1A\u52A1\u9519\u8BEF",
918
+ error: error.message || "业务错误",
931
919
  statusCode: ((_f = error.response) == null ? void 0 : _f.status) || error.status
932
920
  };
933
921
  }
@@ -941,7 +929,7 @@ var PaymentModule = class _PaymentModule extends import_BaseModule.BaseModule {
941
929
  await this.dbManager.getAll("pay_method");
942
930
  } catch (error) {
943
931
  console.warn(
944
- "[PaymentModule] pay_method \u8868\u4E0D\u5B58\u5728\uFF0C\u8BF7\u5728\u6570\u636E\u5E93\u914D\u7F6E\u4E2D\u6DFB\u52A0\u4EE5\u4E0B\u914D\u7F6E\uFF1A"
932
+ "[PaymentModule] pay_method 表不存在,请在数据库配置中添加以下配置:"
945
933
  );
946
934
  console.warn('{ name: "pay_method", keyPath: "id" }');
947
935
  }
@@ -949,7 +937,7 @@ var PaymentModule = class _PaymentModule extends import_BaseModule.BaseModule {
949
937
  await this.dbManager.getAll("order");
950
938
  } catch (error) {
951
939
  console.warn(
952
- "[PaymentModule] order \u8868\u4E0D\u5B58\u5728\uFF0C\u8BF7\u5728\u6570\u636E\u5E93\u914D\u7F6E\u4E2D\u6DFB\u52A0\u4EE5\u4E0B\u914D\u7F6E\uFF1A"
940
+ "[PaymentModule] order 表不存在,请在数据库配置中添加以下配置:"
953
941
  );
954
942
  console.warn('{ name: "order", keyPath: "uuid" }');
955
943
  }
@@ -964,7 +952,7 @@ var PaymentModule = class _PaymentModule extends import_BaseModule.BaseModule {
964
952
  (order) => order.payment_status === import_types.PaymentStatus.PartiallyPaid
965
953
  );
966
954
  } catch (error) {
967
- console.error("[PaymentModule] \u83B7\u53D6\u90E8\u5206\u652F\u4ED8\u8BA2\u5355\u5931\u8D25", error);
955
+ console.error("[PaymentModule] 获取部分支付订单失败", error);
968
956
  return [];
969
957
  }
970
958
  }
@@ -978,7 +966,7 @@ var PaymentModule = class _PaymentModule extends import_BaseModule.BaseModule {
978
966
  return (order.payment_status === import_types.PaymentStatus.Finished || order.payment_status === import_types.PaymentStatus.PartiallyPaid) && order.payment.some((payment) => !payment.isSynced);
979
967
  });
980
968
  } catch (error) {
981
- console.error("[PaymentModule] \u83B7\u53D6\u672A\u540C\u6B65\u8BA2\u5355\u5931\u8D25", error);
969
+ console.error("[PaymentModule] 获取未同步订单失败", error);
982
970
  return [];
983
971
  }
984
972
  }
@@ -996,10 +984,10 @@ var PaymentModule = class _PaymentModule extends import_BaseModule.BaseModule {
996
984
  await this.deleteOrderAsync(order.uuid);
997
985
  }
998
986
  console.log(
999
- `[PaymentModule] \u6E05\u7406\u4E86 ${finishedAndSyncedOrders.length} \u4E2A\u5DF2\u5B8C\u6210\u4E14\u5DF2\u540C\u6B65\u7684\u8BA2\u5355`
987
+ `[PaymentModule] 清理了 ${finishedAndSyncedOrders.length} 个已完成且已同步的订单`
1000
988
  );
1001
989
  } catch (error) {
1002
- console.error("[PaymentModule] \u6E05\u7406\u5DF2\u5B8C\u6210\u8BA2\u5355\u5931\u8D25", error);
990
+ console.error("[PaymentModule] 清理已完成订单失败", error);
1003
991
  }
1004
992
  }
1005
993
  /**
@@ -1021,7 +1009,7 @@ var PaymentModule = class _PaymentModule extends import_BaseModule.BaseModule {
1021
1009
  try {
1022
1010
  if (!this.app.tasksManager) {
1023
1011
  console.warn(
1024
- "[PaymentModule] TasksManager \u672A\u521D\u59CB\u5316\uFF0C\u65E0\u6CD5\u91CD\u65B0\u6392\u961F\u672A\u540C\u6B65\u8BA2\u5355"
1012
+ "[PaymentModule] TasksManager 未初始化,无法重新排队未同步订单"
1025
1013
  );
1026
1014
  this.logWarning(
1027
1015
  "TasksManager not initialized, cannot requeue unsynced orders"
@@ -1030,12 +1018,12 @@ var PaymentModule = class _PaymentModule extends import_BaseModule.BaseModule {
1030
1018
  }
1031
1019
  const unsyncedOrders = await this.getUnsyncedOrdersAsync();
1032
1020
  if (unsyncedOrders.length === 0) {
1033
- console.log("[PaymentModule] \u6CA1\u6709\u53D1\u73B0\u672A\u540C\u6B65\u7684\u8BA2\u5355");
1021
+ console.log("[PaymentModule] 没有发现未同步的订单");
1034
1022
  this.logInfo("No unsynced orders found");
1035
1023
  return 0;
1036
1024
  }
1037
1025
  console.log(
1038
- `[PaymentModule] \u53D1\u73B0 ${unsyncedOrders.length} \u4E2A\u672A\u540C\u6B65\u7684\u8BA2\u5355\uFF0C\u5F00\u59CB\u91CD\u65B0\u52A0\u5165\u4EFB\u52A1\u961F\u5217`
1026
+ `[PaymentModule] 发现 ${unsyncedOrders.length} 个未同步的订单,开始重新加入任务队列`
1039
1027
  );
1040
1028
  this.logInfo("Found unsynced orders, adding to sync queue", {
1041
1029
  unsyncedCount: unsyncedOrders.length,
@@ -1049,7 +1037,7 @@ var PaymentModule = class _PaymentModule extends import_BaseModule.BaseModule {
1049
1037
  }
1050
1038
  }
1051
1039
  console.log(
1052
- `[PaymentModule] \u6210\u529F\u91CD\u65B0\u52A0\u5165 ${requeuedCount} \u4E2A\u8BA2\u5355\u5230\u4EFB\u52A1\u961F\u5217`
1040
+ `[PaymentModule] 成功重新加入 ${requeuedCount} 个订单到任务队列`
1053
1041
  );
1054
1042
  this.logInfo("Successfully requeued unsynced orders", {
1055
1043
  requeuedCount,
@@ -1057,7 +1045,7 @@ var PaymentModule = class _PaymentModule extends import_BaseModule.BaseModule {
1057
1045
  });
1058
1046
  return requeuedCount;
1059
1047
  } catch (error) {
1060
- console.error("[PaymentModule] \u91CD\u65B0\u6392\u961F\u672A\u540C\u6B65\u8BA2\u5355\u5931\u8D25", error);
1048
+ console.error("[PaymentModule] 重新排队未同步订单失败", error);
1061
1049
  this.logError("recheckAndRequeueUnsyncedOrders failed", error);
1062
1050
  return 0;
1063
1051
  }
@@ -1085,7 +1073,7 @@ var PaymentModule = class _PaymentModule extends import_BaseModule.BaseModule {
1085
1073
  this.logInfo("Starting runPaymentSyncQueue");
1086
1074
  try {
1087
1075
  if (!this.app.tasksManager) {
1088
- console.warn("[PaymentModule] TasksManager \u672A\u521D\u59CB\u5316\uFF0C\u65E0\u6CD5\u6267\u884C\u540C\u6B65\u961F\u5217");
1076
+ console.warn("[PaymentModule] TasksManager 未初始化,无法执行同步队列");
1089
1077
  this.logWarning("TasksManager not initialized, cannot run sync queue");
1090
1078
  return;
1091
1079
  }
@@ -1094,15 +1082,15 @@ var PaymentModule = class _PaymentModule extends import_BaseModule.BaseModule {
1094
1082
  queueId: "payment_sync"
1095
1083
  });
1096
1084
  if (!(queue == null ? void 0 : queue.length)) {
1097
- console.log("[PaymentModule] \u652F\u4ED8\u540C\u6B65\u961F\u5217\u65E0\u5185\u5BB9\uFF0C\u4E0D\u6267\u884C");
1085
+ console.log("[PaymentModule] 支付同步队列无内容,不执行");
1098
1086
  return;
1099
1087
  }
1100
- console.log("[PaymentModule] \u5F00\u59CB\u6267\u884C\u652F\u4ED8\u540C\u6B65\u961F\u5217");
1088
+ console.log("[PaymentModule] 开始执行支付同步队列");
1101
1089
  await this.app.tasksManager.run({
1102
1090
  module: "payment",
1103
1091
  queueId: "payment_sync",
1104
1092
  callback: () => {
1105
- console.log("[PaymentModule] \u652F\u4ED8\u540C\u6B65\u961F\u5217\u6267\u884C\u5B8C\u6210");
1093
+ console.log("[PaymentModule] 支付同步队列执行完成");
1106
1094
  if (this.logger) {
1107
1095
  this.logger.addLog({
1108
1096
  type: "info",
@@ -1114,7 +1102,7 @@ var PaymentModule = class _PaymentModule extends import_BaseModule.BaseModule {
1114
1102
  });
1115
1103
  this.logInfo("runPaymentSyncQueue completed successfully");
1116
1104
  } catch (error) {
1117
- console.error("[PaymentModule] \u6267\u884C\u652F\u4ED8\u540C\u6B65\u961F\u5217\u5931\u8D25", error);
1105
+ console.error("[PaymentModule] 执行支付同步队列失败", error);
1118
1106
  this.logError("runPaymentSyncQueue failed", error);
1119
1107
  }
1120
1108
  }
@@ -1139,12 +1127,12 @@ var PaymentModule = class _PaymentModule extends import_BaseModule.BaseModule {
1139
1127
  const taskExists = existingQueue == null ? void 0 : existingQueue.some((task) => task.id === taskId);
1140
1128
  if (taskExists) {
1141
1129
  console.log(
1142
- `[PaymentModule] \u4EFB\u52A1 ${taskId} \u5DF2\u5B58\u5728\u4E8E\u961F\u5217\u4E2D\uFF0C\u8DF3\u8FC7\u91CD\u590D\u6DFB\u52A0`
1130
+ `[PaymentModule] 任务 ${taskId} 已存在于队列中,跳过重复添加`
1143
1131
  );
1144
1132
  return false;
1145
1133
  }
1146
1134
  await this.addToSyncQueue(order, paymentData);
1147
- console.log(`[PaymentModule] \u8BA2\u5355 ${order.uuid} \u5DF2\u91CD\u65B0\u6DFB\u52A0\u5230\u540C\u6B65\u961F\u5217`);
1135
+ console.log(`[PaymentModule] 订单 ${order.uuid} 已重新添加到同步队列`);
1148
1136
  this.logInfo("Order re-added to sync queue", {
1149
1137
  orderUuid: order.uuid,
1150
1138
  orderId: order.order_info.order_id,
@@ -1154,7 +1142,7 @@ var PaymentModule = class _PaymentModule extends import_BaseModule.BaseModule {
1154
1142
  return true;
1155
1143
  } catch (error) {
1156
1144
  console.error(
1157
- `[PaymentModule] \u91CD\u65B0\u6DFB\u52A0\u8BA2\u5355 ${order.uuid} \u5230\u540C\u6B65\u961F\u5217\u5931\u8D25`,
1145
+ `[PaymentModule] 重新添加订单 ${order.uuid} 到同步队列失败`,
1158
1146
  error
1159
1147
  );
1160
1148
  this.logError("Failed to re-add order to sync queue", error, {
@@ -29,7 +29,7 @@ var WalletPaymentImpl = class {
29
29
  async processWalletPayment(amount, orderUuid, voucherId) {
30
30
  const walletMethod = await this.paymentModule.getWalletPaymentMethod();
31
31
  if (!walletMethod) {
32
- throw new Error("\u94B1\u5305\u652F\u4ED8\u65B9\u5F0F\u672A\u627E\u5230");
32
+ throw new Error("钱包支付方式未找到");
33
33
  }
34
34
  const paymentItem = {
35
35
  amount: amount.toString(),