@pisell/pisellos 1.0.67 → 1.0.69

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 (32) hide show
  1. package/dist/modules/Cart/index.d.ts +1 -0
  2. package/dist/modules/Cart/index.js +1 -0
  3. package/dist/modules/Order/index.js +8 -13
  4. package/dist/modules/Payment/cashRecommendationAlgorithm.js +1 -1
  5. package/dist/modules/Payment/index.js +116 -84
  6. package/dist/modules/Payment/types.d.ts +21 -0
  7. package/dist/modules/Payment/walletpass.js +15 -9
  8. package/dist/modules/Product/index.d.ts +1 -1
  9. package/dist/modules/Rules/index.js +1 -1
  10. package/dist/solution/BookingTicket/index.d.ts +1 -1
  11. package/dist/solution/Checkout/index.d.ts +66 -2
  12. package/dist/solution/Checkout/index.js +1645 -882
  13. package/dist/solution/Checkout/types.d.ts +17 -0
  14. package/dist/solution/Checkout/types.js +4 -0
  15. package/dist/solution/ShopDiscount/index.d.ts +6 -1
  16. package/dist/solution/ShopDiscount/index.js +1 -0
  17. package/lib/modules/Cart/index.d.ts +1 -0
  18. package/lib/modules/Cart/index.js +4 -1
  19. package/lib/modules/Order/index.js +1 -4
  20. package/lib/modules/Payment/cashRecommendationAlgorithm.js +1 -1
  21. package/lib/modules/Payment/index.js +52 -48
  22. package/lib/modules/Payment/types.d.ts +21 -0
  23. package/lib/modules/Payment/walletpass.js +14 -8
  24. package/lib/modules/Product/index.d.ts +1 -1
  25. package/lib/modules/Rules/index.js +1 -1
  26. package/lib/solution/BookingTicket/index.d.ts +1 -1
  27. package/lib/solution/Checkout/index.d.ts +66 -2
  28. package/lib/solution/Checkout/index.js +596 -104
  29. package/lib/solution/Checkout/types.d.ts +17 -0
  30. package/lib/solution/ShopDiscount/index.d.ts +6 -1
  31. package/lib/solution/ShopDiscount/index.js +1 -0
  32. package/package.json +1 -1
@@ -3,6 +3,7 @@ import { BaseModule } from '../BaseModule';
3
3
  import { CartItem, CartModuleAPI, ECartItemCheckType, ECartItemInfoType, IAddItemParams, IUpdateItemParams } from './types';
4
4
  import { Account } from '../Account';
5
5
  export * from './types';
6
+ export { getProductDeposit } from './utils';
6
7
  /**
7
8
  * 购物车模块实现
8
9
  */
@@ -29,6 +29,7 @@ import { createCartItemOrigin, deleteHolderFromCartItem, deleteRelationFormsFrom
29
29
  import { cloneDeep } from 'lodash-es';
30
30
  import { isNormalProduct } from "../Product/utils";
31
31
  export * from "./types";
32
+ export { getProductDeposit } from "./utils";
32
33
 
33
34
  /**
34
35
  * 购物车模块实现
@@ -292,18 +292,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
292
292
  bookings: [],
293
293
  relation_products: [],
294
294
  relation_forms: [],
295
- payments: []
295
+ payments: [],
296
+ is_full_overwrite_flag: 1
296
297
  }, params);
297
298
  if ((_orderData$payments = orderData.payments) !== null && _orderData$payments !== void 0 && _orderData$payments.length) {
298
299
  orderData.small_ticket_data_flag = 1;
299
300
  }
300
301
 
301
- // 如果进来的order_id 是真实的,则不需要再传递 bookings 和 relation_products
302
- if (params.order_id) {
303
- orderData.bookings = [];
304
- orderData.relation_products = [];
305
- }
306
-
307
302
  // 兜底策略,如果是第一次下单,没有 order_id,且没有 schedule_date,则设置为当前时间
308
303
  if (!params.order_id && !orderData.schedule_date) {
309
304
  orderData.schedule_date = dayjs().format('YYYY-MM-DD HH:mm:ss');
@@ -350,9 +345,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
350
345
  });
351
346
 
352
347
  // 调用后端接口
353
- _context3.next = 11;
348
+ _context3.next = 10;
354
349
  return this.request.post('/order/checkout', orderData);
355
- case 11:
350
+ case 10:
356
351
  response = _context3.sent;
357
352
  this.logInfo('Order API called successfully', {
358
353
  response: response
@@ -362,19 +357,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
362
357
  hasOrderId: !!(response !== null && response !== void 0 && (_response$data = response.data) !== null && _response$data !== void 0 && _response$data.order_id || response !== null && response !== void 0 && response.order_id)
363
358
  });
364
359
  return _context3.abrupt("return", response);
365
- case 17:
366
- _context3.prev = 17;
360
+ case 16:
361
+ _context3.prev = 16;
367
362
  _context3.t0 = _context3["catch"](2);
368
363
  console.error('[Order] createOrderByCheckout 创建订单失败:', _context3.t0);
369
364
  this.logInfo('Order API called failed', {
370
365
  error: _context3.t0 instanceof Error ? _context3.t0.message : String(_context3.t0)
371
366
  });
372
367
  throw _context3.t0;
373
- case 22:
368
+ case 21:
374
369
  case "end":
375
370
  return _context3.stop();
376
371
  }
377
- }, _callee3, this, [[2, 17]]);
372
+ }, _callee3, this, [[2, 16]]);
378
373
  }));
379
374
  function createOrderByCheckout(_x4) {
380
375
  return _createOrderByCheckout.apply(this, arguments);
@@ -19,7 +19,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
19
19
  */
20
20
  export var CURRENCY_DENOMINATIONS = {
21
21
  // 美元
22
- 'USD': [100, 50, 20, 10, 5, 2, 1, 0.5, 0.25, 0.1, 0.05, 0.01],
22
+ 'USD': [100, 50, 20, 10, 5, 1, 0.5, 0.25, 0.1, 0.05, 0.01],
23
23
  // 人民币
24
24
  'CNY': [100, 50, 20, 10, 5, 1, 0.5, 0.1, 0.05, 0.01],
25
25
  'RMB': [100, 50, 20, 10, 5, 1, 0.5, 0.1, 0.05, 0.01],
@@ -131,6 +131,10 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
131
131
  return this.ensurePaymentTables();
132
132
  case 14:
133
133
  this.registerNetworkHandlers();
134
+
135
+ // // 预连接数据库
136
+ // this.dbManager.connect()
137
+
134
138
  console.log('[PaymentModule] 初始化完成');
135
139
  this.logInfo('PaymentModule initialized successfully');
136
140
  case 17:
@@ -657,7 +661,8 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
657
661
  key: "createPaymentOrderAsync",
658
662
  value: (function () {
659
663
  var _createPaymentOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(params) {
660
- var existingOrder, newOrder;
664
+ var _this3 = this;
665
+ var newOrder, dbAddStartTime, dbAddDuration;
661
666
  return _regeneratorRuntime().wrap(function _callee7$(_context7) {
662
667
  while (1) switch (_context7.prev = _context7.next) {
663
668
  case 0:
@@ -666,41 +671,41 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
666
671
  totalAmount: params.total_amount
667
672
  });
668
673
  _context7.prev = 1;
669
- _context7.next = 4;
670
- return this.dbManager.get('order', params.order_id);
671
- case 4:
672
- existingOrder = _context7.sent;
673
- this.logInfo('createPaymentOrderAsync existingOrder', {
674
- existingOrder: existingOrder
675
- });
674
+ // 检测是否有重复的 order_id
675
+ // console.time('createLocalOrderAsync: getExistingOrder')
676
+ // const existingOrder = await this.dbManager.get('order', params.order_id);
677
+ // const existingOrders = await this.dbManager.getAll('order');
676
678
  // const existingOrder = existingOrders.find(
677
679
  // (order: PaymentOrder) => String(order.id) === String(params.order_id),
678
680
  // );
679
- if (!existingOrder) {
680
- _context7.next = 20;
681
- break;
682
- }
683
- // 如果存在相同 order_id 的订单,更新该订单信息
684
- this.logInfo("createPaymentOrderAsync found duplicate order ID: ".concat(params.order_id, ", updating existing payment order"));
685
-
686
- // const originalOrder = { ...existingOrder };
687
- existingOrder.order_info = params.order_info;
688
- existingOrder.total_amount = params.total_amount;
689
- existingOrder.is_deposit = params.is_deposit || 0;
690
- existingOrder.deposit_amount = params.deposit_amount || '0.00';
691
-
692
- // 重新计算待付金额
693
- this.recalculateOrderAmount(existingOrder);
694
-
695
- // 更新到数据库
696
- _context7.next = 15;
697
- return this.dbManager.update('order', existingOrder);
698
- case 15:
699
- _context7.next = 17;
700
- return this.core.effects.emit(PaymentHooks.OnOrderUpdated, existingOrder);
701
- case 17:
702
- return _context7.abrupt("return", existingOrder);
703
- case 20:
681
+ // this.logInfo('createPaymentOrderAsync existingOrder', {
682
+ // existingOrder
683
+ // });
684
+ // console.timeEnd('createLocalOrderAsync: getExistingOrder')
685
+ // const existingOrder = existingOrders.find(
686
+ // (order: PaymentOrder) => String(order.id) === String(params.order_id),
687
+ // );
688
+ // if (existingOrder) {
689
+ // // 如果存在相同 order_id 的订单,更新该订单信息
690
+ // this.logInfo(
691
+ // `createPaymentOrderAsync found duplicate order ID: ${params.order_id}, updating existing payment order`,
692
+ // );
693
+ // // const originalOrder = { ...existingOrder };
694
+ // existingOrder.order_info = params.order_info;
695
+ // existingOrder.total_amount = params.total_amount;
696
+ // existingOrder.is_deposit = params.is_deposit || 0;
697
+ // existingOrder.deposit_amount = params.deposit_amount || '0.00';
698
+ // // 重新计算待付金额
699
+ // this.recalculateOrderAmount(existingOrder);
700
+ // // 更新到数据库
701
+ // await this.dbManager.update('order', existingOrder);
702
+ // // 触发更新事件
703
+ // this.core.effects.emit(
704
+ // `${this.name}:onOrderUpdated`,
705
+ // existingOrder,
706
+ // );
707
+ // return existingOrder;
708
+ // } else {
704
709
  // 创建新的支付订单
705
710
  newOrder = {
706
711
  uuid: getUniqueId('pay_order_'),
@@ -715,32 +720,37 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
715
720
  tax_fee: '0.00',
716
721
  is_deposit: params.is_deposit || 0,
717
722
  deposit_amount: params.deposit_amount || '0.00'
718
- };
719
- _context7.next = 23;
723
+ }; // 🚀 性能监控:记录数据库添加操作耗时
724
+ dbAddStartTime = Date.now();
725
+ _context7.next = 6;
720
726
  return this.dbManager.add('order', newOrder);
721
- case 23:
722
- this.core.effects.emit(PaymentHooks.OnOrderAdded, newOrder);
723
- this.logInfo('createPaymentOrderAsync completed - new payment order created', {
727
+ case 6:
728
+ dbAddDuration = Date.now() - dbAddStartTime;
729
+ this.logInfo('Database add operation completed', {
730
+ operation: 'dbManager.add',
731
+ table: 'order',
724
732
  orderUuid: newOrder.uuid,
725
- orderId: newOrder.id
733
+ orderId: newOrder.order_id,
734
+ duration: "".concat(dbAddDuration, "ms"),
735
+ performance: dbAddDuration > 100 ? 'slow' : dbAddDuration > 50 ? 'medium' : 'fast'
726
736
  });
737
+ setTimeout(function () {
738
+ _this3.core.effects.emit("".concat(_this3.name, ":onOrderAdded"), newOrder);
739
+ }, 0);
727
740
  return _context7.abrupt("return", newOrder);
728
- case 26:
729
- _context7.next = 33;
730
- break;
731
- case 28:
732
- _context7.prev = 28;
741
+ case 12:
742
+ _context7.prev = 12;
733
743
  _context7.t0 = _context7["catch"](1);
734
744
  console.error('[PaymentModule] 创建支付订单失败', _context7.t0);
735
745
  this.logError('createPaymentOrderAsync failed', _context7.t0, {
736
746
  orderId: params.order_id
737
747
  });
738
748
  throw _context7.t0;
739
- case 33:
749
+ case 17:
740
750
  case "end":
741
751
  return _context7.stop();
742
752
  }
743
- }, _callee7, this, [[1, 28]]);
753
+ }, _callee7, this, [[1, 12]]);
744
754
  }));
745
755
  function createPaymentOrderAsync(_x6) {
746
756
  return _createPaymentOrderAsync.apply(this, arguments);
@@ -812,35 +822,36 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
812
822
  case 3:
813
823
  order = _context9.sent;
814
824
  if (!order) {
815
- _context9.next = 12;
825
+ _context9.next = 13;
816
826
  break;
817
827
  }
818
828
  updatedOrder = _objectSpread(_objectSpread({}, order), params);
819
- _context9.next = 8;
829
+ this.recalculateOrderAmount(updatedOrder);
830
+ _context9.next = 9;
820
831
  return this.dbManager.update('order', updatedOrder);
821
- case 8:
822
- _context9.next = 10;
832
+ case 9:
833
+ _context9.next = 11;
823
834
  return this.core.effects.emit(PaymentHooks.OnOrderUpdated, updatedOrder);
824
- case 10:
825
- _context9.next = 12;
835
+ case 11:
836
+ _context9.next = 13;
826
837
  return this.core.effects.emit(PaymentHooks.OnOrderChanged, {
827
838
  action: 'update',
828
839
  order: updatedOrder,
829
840
  originalOrder: order
830
841
  });
831
- case 12:
832
- _context9.next = 18;
842
+ case 13:
843
+ _context9.next = 19;
833
844
  break;
834
- case 14:
835
- _context9.prev = 14;
845
+ case 15:
846
+ _context9.prev = 15;
836
847
  _context9.t0 = _context9["catch"](0);
837
848
  console.error('[PaymentModule] 更新订单失败', _context9.t0);
838
849
  throw _context9.t0;
839
- case 18:
850
+ case 19:
840
851
  case "end":
841
852
  return _context9.stop();
842
853
  }
843
- }, _callee9, this, [[0, 14]]);
854
+ }, _callee9, this, [[0, 15]]);
844
855
  }));
845
856
  function updateOrderAsync(_x8, _x9) {
846
857
  return _updateOrderAsync.apply(this, arguments);
@@ -1043,7 +1054,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1043
1054
  key: "addPaymentItemAsync",
1044
1055
  value: (function () {
1045
1056
  var _addPaymentItemAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(orderUuid, paymentItem) {
1046
- var _newPaymentItem$metad, _newPaymentItem$metad2, _newPaymentItem$metad3, order, expectAmount, warningMessage, paymentUuid, newPaymentItem;
1057
+ var _newPaymentItem$metad, _newPaymentItem$metad2, _newPaymentItem$metad3, order, expectAmount, paidDepositAmount, expectedDepositAmount, warningMessage, paymentUuid, newPaymentItem;
1047
1058
  return _regeneratorRuntime().wrap(function _callee13$(_context13) {
1048
1059
  while (1) switch (_context13.prev = _context13.next) {
1049
1060
  case 0:
@@ -1066,8 +1077,15 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1066
1077
  case 7:
1067
1078
  // 🔒 支付锁检查:如果订单待付金额已经为0,不允许继续添加支付项
1068
1079
  expectAmount = new Decimal(order.expect_amount);
1069
- if (!expectAmount.lte(0)) {
1070
- _context13.next = 13;
1080
+ paidDepositAmount = order.payment.reduce(function (sum, payment) {
1081
+ if (payment.order_payment_type === 'deposit' && payment.status !== 'voided') {
1082
+ return sum.plus(new Decimal(payment.amount));
1083
+ }
1084
+ return sum;
1085
+ }, new Decimal(0));
1086
+ expectedDepositAmount = new Decimal(order.deposit_amount || '0').sub(paidDepositAmount); // 有一种特殊情况,订单金额为 0,但是定金金额>0,且此时是定金状态的,允许添加支付项
1087
+ if (!(expectAmount.lte(0) && expectedDepositAmount.eq(0))) {
1088
+ _context13.next = 15;
1071
1089
  break;
1072
1090
  }
1073
1091
  warningMessage = "\u8BA2\u5355 ".concat(orderUuid, " \u5F85\u4ED8\u91D1\u989D\u5DF2\u4E3A0\uFF0C\u4E0D\u5141\u8BB8\u6DFB\u52A0\u65B0\u7684\u652F\u4ED8\u9879");
@@ -1084,7 +1102,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1084
1102
  paymentItem: paymentItem
1085
1103
  });
1086
1104
  throw new Error(warningMessage);
1087
- case 13:
1105
+ case 15:
1088
1106
  paymentUuid = getUniqueId('payment_');
1089
1107
  newPaymentItem = {
1090
1108
  uuid: paymentUuid,
@@ -1107,15 +1125,15 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1107
1125
  };
1108
1126
  order.payment.push(newPaymentItem);
1109
1127
  this.recalculateOrderAmount(order);
1110
- _context13.next = 19;
1111
- return this.dbManager.update('order', order);
1112
- case 19:
1113
1128
  _context13.next = 21;
1129
+ return this.dbManager.update('order', order);
1130
+ case 21:
1131
+ _context13.next = 23;
1114
1132
  return this.core.effects.emit(PaymentHooks.OnPaymentAdded, {
1115
1133
  orderUuid: orderUuid,
1116
1134
  payment: newPaymentItem
1117
1135
  });
1118
- case 21:
1136
+ case 23:
1119
1137
  this.logInfo('addPaymentItemAsync completed successfully', {
1120
1138
  orderUuid: orderUuid,
1121
1139
  paymentUuid: newPaymentItem.uuid,
@@ -1129,10 +1147,10 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1129
1147
  actualPaidAmount: (_newPaymentItem$metad2 = newPaymentItem.metadata) === null || _newPaymentItem$metad2 === void 0 ? void 0 : _newPaymentItem$metad2.actual_paid_amount,
1130
1148
  changeGivenAmount: (_newPaymentItem$metad3 = newPaymentItem.metadata) === null || _newPaymentItem$metad3 === void 0 ? void 0 : _newPaymentItem$metad3.change_given_amount
1131
1149
  });
1132
- _context13.next = 29;
1150
+ _context13.next = 31;
1133
1151
  break;
1134
- case 24:
1135
- _context13.prev = 24;
1152
+ case 26:
1153
+ _context13.prev = 26;
1136
1154
  _context13.t0 = _context13["catch"](1);
1137
1155
  console.error('[PaymentModule] 添加支付项失败', _context13.t0);
1138
1156
  this.logError('addPaymentItemAsync failed', _context13.t0, {
@@ -1140,11 +1158,11 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1140
1158
  paymentItem: paymentItem
1141
1159
  });
1142
1160
  throw _context13.t0;
1143
- case 29:
1161
+ case 31:
1144
1162
  case "end":
1145
1163
  return _context13.stop();
1146
1164
  }
1147
- }, _callee13, this, [[1, 24]]);
1165
+ }, _callee13, this, [[1, 26]]);
1148
1166
  }));
1149
1167
  function addPaymentItemAsync(_x14, _x15) {
1150
1168
  return _addPaymentItemAsync.apply(this, arguments);
@@ -1291,9 +1309,10 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1291
1309
  }
1292
1310
  throw new Error("\u8BA2\u5355\u4E0D\u5B58\u5728: ".concat(orderUuid));
1293
1311
  case 7:
1294
- // 1. 查找所有现有的代金券类支付项(带 voucher_id 且状态不是 voided
1312
+ // 1. 查找所有现有的代金券类支付项(带 voucher_id 且状态不是 voided)并且还没有同步给后端
1313
+ // 如果同步给了后端的voucher 不允许删除
1295
1314
  existingVoucherItems = order.payment.filter(function (payment) {
1296
- return payment.voucher_id && payment.status !== 'voided';
1315
+ return payment.voucher_id && payment.status !== 'voided' && !payment.isSynced;
1297
1316
  });
1298
1317
  console.log('[PaymentModule] 发现现有代金券支付项:', {
1299
1318
  orderUuid: orderUuid,
@@ -1303,7 +1322,8 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1303
1322
  uuid: item.uuid,
1304
1323
  code: item.code,
1305
1324
  amount: item.amount,
1306
- voucher_id: item.voucher_id
1325
+ voucher_id: item.voucher_id,
1326
+ isSynced: item.isSynced
1307
1327
  };
1308
1328
  })
1309
1329
  });
@@ -1798,14 +1818,15 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1798
1818
  // 例如:amount=15, rounding_amount=-0.2,有效支付=15.2(抹掉0.2元零头)
1799
1819
  var paymentAmount = new Decimal(payment.amount || 0);
1800
1820
  var roundingAmount = new Decimal(payment.rounding_amount || 0);
1801
- var effectiveAmount = paymentAmount.plus(roundingAmount.abs());
1821
+ var effectiveAmount = paymentAmount.plus(roundingAmount.isNegative() ? roundingAmount.abs() : 0);
1802
1822
  return sum.plus(effectiveAmount);
1803
1823
  } catch (error) {
1804
1824
  console.warn("[PaymentModule] \u65E0\u6548\u7684\u652F\u4ED8\u91D1\u989D: amount=".concat(payment.amount, ", rounding_amount=").concat(payment.rounding_amount, "\uFF0C\u8DF3\u8FC7\u8BA1\u7B97"));
1805
1825
  return sum;
1806
1826
  }
1807
1827
  }, new Decimal(0));
1808
- var remainingAmount = totalAmount.minus(paidAmount);
1828
+ // 如果是定金模式,则使用deposit_amount 去减已付款金额
1829
+ var remainingAmount = order.is_deposit === 1 ? new Decimal(order.deposit_amount).minus(paidAmount) : totalAmount.minus(paidAmount);
1809
1830
  order.expect_amount = Decimal.max(0, remainingAmount).toFixed(2);
1810
1831
  console.log("[PaymentModule] \u91CD\u65B0\u8BA1\u7B97\u8BA2\u5355\u91D1\u989D:", {
1811
1832
  orderUuid: order.uuid,
@@ -1825,7 +1846,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1825
1846
  code: p.code,
1826
1847
  amount: p.amount,
1827
1848
  rounding_amount: p.rounding_amount || '0.00',
1828
- effective_amount: new Decimal(p.amount || 0).plus(new Decimal(p.rounding_amount || 0).abs()).toFixed(2)
1849
+ effective_amount: new Decimal(p.amount || 0).plus(new Decimal(Number(p.rounding_amount) > 0 ? 0 : p.rounding_amount || 0).abs()).toFixed(2)
1829
1850
  };
1830
1851
  }),
1831
1852
  说明: '有效支付金额包含抹零计算(amount + |rounding_amount|)'
@@ -2035,7 +2056,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
2035
2056
  key: "roundAmountAsync",
2036
2057
  value: function () {
2037
2058
  var _roundAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(originalAmount, interval, rule) {
2038
- var amount, roundingInterval, supportedIntervals, intervalValue, baseValue, roundedValue, finalAmount, roundedAmountStr, originalAmountStr, roundingDifference, roundingDifferenceStr;
2059
+ var amount, roundingInterval, supportedIntervals, intervalValue, baseValue, roundedValue, finalAmount, originalAmountStr, roundedAmountStr, roundingDifference, roundingDifferenceStr;
2039
2060
  return _regeneratorRuntime().wrap(function _callee26$(_context26) {
2040
2061
  while (1) switch (_context26.prev = _context26.next) {
2041
2062
  case 0:
@@ -2083,8 +2104,19 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
2083
2104
  case 22:
2084
2105
  // 计算最终金额:roundedValue * interval
2085
2106
  finalAmount = roundedValue.mul(roundingInterval);
2086
- roundedAmountStr = finalAmount.toFixed(2);
2087
- originalAmountStr = amount.toFixed(2); // 计算舍入差额
2107
+ originalAmountStr = amount.toFixed(2); // 如果最终金额是 0 元,则不采用舍入金额,返回原始金额
2108
+ if (!finalAmount.eq(0)) {
2109
+ _context26.next = 27;
2110
+ break;
2111
+ }
2112
+ console.log("[PaymentModule] \u6700\u7EC8\u91D1\u989D\u4E3A0\uFF0C\u8FD4\u56DE\u539F\u59CB\u91D1\u989D: ".concat(originalAmountStr));
2113
+ return _context26.abrupt("return", {
2114
+ originalAmount: originalAmountStr,
2115
+ roundedAmount: originalAmountStr,
2116
+ roundingDifference: '0.00'
2117
+ });
2118
+ case 27:
2119
+ roundedAmountStr = finalAmount.toFixed(2); // 计算舍入差额
2088
2120
  roundingDifference = finalAmount.sub(amount);
2089
2121
  roundingDifferenceStr = roundingDifference.toFixed(2);
2090
2122
  console.log("[PaymentModule] \u820D\u5165\u7ED3\u679C - \u539F\u59CB\u91D1\u989D: ".concat(originalAmountStr, ", \u820D\u5165\u540E\u91D1\u989D: ").concat(roundedAmountStr, ", \u820D\u5165\u5DEE\u989D: ").concat(roundingDifferenceStr));
@@ -2093,16 +2125,16 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
2093
2125
  roundedAmount: roundedAmountStr,
2094
2126
  roundingDifference: roundingDifferenceStr
2095
2127
  });
2096
- case 31:
2097
- _context26.prev = 31;
2128
+ case 34:
2129
+ _context26.prev = 34;
2098
2130
  _context26.t1 = _context26["catch"](0);
2099
2131
  console.error('[PaymentModule] 金额舍入失败:', _context26.t1);
2100
2132
  throw new Error("\u91D1\u989D\u820D\u5165\u5931\u8D25: ".concat(_context26.t1 instanceof Error ? _context26.t1.message : String(_context26.t1)));
2101
- case 35:
2133
+ case 38:
2102
2134
  case "end":
2103
2135
  return _context26.stop();
2104
2136
  }
2105
- }, _callee26, this, [[0, 31]]);
2137
+ }, _callee26, this, [[0, 34]]);
2106
2138
  }));
2107
2139
  function roundAmountAsync(_x28, _x29, _x30) {
2108
2140
  return _roundAmountAsync.apply(this, arguments);
@@ -129,6 +129,15 @@ export interface PaymentItem {
129
129
  origin_amount?: string;
130
130
  /** 订单支付类型 */
131
131
  order_payment_type?: 'normal' | 'deposit';
132
+ /** 本支付项是否已成功同步到后端 */
133
+ isSynced?: boolean;
134
+ /** 最近一次同步失败信息(存在则代表同步失败过) */
135
+ syncError?: {
136
+ error: string;
137
+ errorCode?: string;
138
+ statusCode?: number;
139
+ timestamp: number;
140
+ };
132
141
  }
133
142
  /**
134
143
  * 订单信息
@@ -614,6 +623,8 @@ export interface WalletDeductionRecommendParams {
614
623
  amount: number;
615
624
  tag: string;
616
625
  }[];
626
+ /** 订单ID */
627
+ payment_order_id?: string;
617
628
  }
618
629
  /**
619
630
  * 钱包初始化业务数据接口
@@ -626,6 +637,10 @@ export interface WalletInitBusinessData {
626
637
  amountInfo: {
627
638
  totalAmount: string;
628
639
  subTotal: string;
640
+ /** 是否是定金订单 */
641
+ isDeposit?: number;
642
+ /** 定金金额 */
643
+ depositAmount?: string;
629
644
  };
630
645
  /** 商品列表 */
631
646
  products: {
@@ -635,6 +650,8 @@ export interface WalletInitBusinessData {
635
650
  selling_price: number;
636
651
  }[];
637
652
  order_wait_pay_amount?: number;
653
+ /** 订单ID */
654
+ payment_order_id?: string;
638
655
  }
639
656
  /**
640
657
  * 查询用户识别码列表请求参数
@@ -652,6 +669,8 @@ export interface UserIdentificationCodeParams extends WalletDeductionRecommendPa
652
669
  amount: number;
653
670
  tag: string;
654
671
  }[];
672
+ /** 订单ID */
673
+ payment_order_id?: string;
655
674
  }
656
675
  /**
657
676
  * 钱包推荐扣款响应数据
@@ -703,6 +722,8 @@ export interface UserIdentificationCodeItem {
703
722
  export interface SearchIdentificationCodeParams extends WalletDeductionRecommendParams {
704
723
  /** 识别码 */
705
724
  code: string;
725
+ /** 订单ID */
726
+ payment_order_id?: string;
706
727
  }
707
728
  /**
708
729
  * 搜索识别码响应数据
@@ -59,7 +59,8 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
59
59
  var customer_id = businessData.customer_id,
60
60
  amountInfo = businessData.amountInfo,
61
61
  products = businessData.products,
62
- order_wait_pay_amount = businessData.order_wait_pay_amount;
62
+ order_wait_pay_amount = businessData.order_wait_pay_amount,
63
+ payment_order_id = businessData.payment_order_id;
63
64
 
64
65
  // 转换金额为数字类型
65
66
  var totalAmount = Number(amountInfo.totalAmount);
@@ -72,10 +73,11 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
72
73
  // 订单小计金额
73
74
  order_product_amount: subTotal,
74
75
  // 订单待支付金额
75
- order_wait_pay_amount: order_wait_pay_amount || totalAmount,
76
+ order_wait_pay_amount: order_wait_pay_amount || (amountInfo !== null && amountInfo !== void 0 && amountInfo.isDeposit ? Number(amountInfo === null || amountInfo === void 0 ? void 0 : amountInfo.depositAmount) : totalAmount),
76
77
  // order_behavior_count_customer_id: 1,
77
78
  products: products,
78
- prepare_payments: []
79
+ prepare_payments: [],
80
+ payment_order_id: payment_order_id
79
81
  };
80
82
 
81
83
  // 存储生成的参数到模块中
@@ -252,7 +254,7 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
252
254
  key: "getWalletPassRecommendListAsync",
253
255
  value: function () {
254
256
  var _getWalletPassRecommendListAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
255
- var response;
257
+ var _this$walletParams, response;
256
258
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
257
259
  while (1) switch (_context3.prev = _context3.next) {
258
260
  case 0:
@@ -260,7 +262,8 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
260
262
  this.paymentModule.logInfo('[WalletPass] 开始获取钱包推荐列表', {
261
263
  customer_id: params.customer_id,
262
264
  order_expect_amount: params.order_expect_amount,
263
- sale_channel: params.sale_channel
265
+ sale_channel: params.sale_channel,
266
+ payment_order_id: (_this$walletParams = this.walletParams) === null || _this$walletParams === void 0 ? void 0 : _this$walletParams.payment_order_id
264
267
  });
265
268
  _context3.next = 4;
266
269
  return this.paymentModule.request.post('/machinecode/prepare/deduction/recommend', params // 将 params 作为请求体数据
@@ -315,7 +318,7 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
315
318
  key: "getUserIdentificationCodeListAsync",
316
319
  value: function () {
317
320
  var _getUserIdentificationCodeListAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(params) {
318
- var _newParams$prepare_pa, newParams, response, sortedData;
321
+ var _newParams$prepare_pa, _this$walletParams2, newParams, response, sortedData;
319
322
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
320
323
  while (1) switch (_context4.prev = _context4.next) {
321
324
  case 0:
@@ -325,7 +328,8 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
325
328
  customer_id: newParams.customer_id,
326
329
  available: newParams.available,
327
330
  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
331
+ filter_prepare_wallet_pass: newParams.filter_prepare_wallet_pass,
332
+ payment_order_id: (_this$walletParams2 = this.walletParams) === null || _this$walletParams2 === void 0 ? void 0 : _this$walletParams2.payment_order_id
329
333
  });
330
334
  _context4.next = 5;
331
335
  return this.paymentModule.request.post('/machinecode/prepare/deduction', newParams);
@@ -452,13 +456,15 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
452
456
  prepare_payments: params.prepare_payments || (baseWalletParams === null || baseWalletParams === void 0 ? void 0 : baseWalletParams.prepare_payments),
453
457
  multiple: 1,
454
458
  // 搜索特有参数
455
- code: params.code
459
+ code: params.code,
460
+ payment_order_id: baseWalletParams === null || baseWalletParams === void 0 ? void 0 : baseWalletParams.payment_order_id
456
461
  };
457
462
  this.paymentModule.logInfo('[WalletPass] 搜索普通识别码', {
458
463
  code: searchParams.code,
459
464
  customer_id: searchParams.customer_id,
460
465
  order_expect_amount: searchParams.order_expect_amount,
461
- multiple: searchParams.multiple
466
+ multiple: searchParams.multiple,
467
+ payment_order_id: baseWalletParams === null || baseWalletParams === void 0 ? void 0 : baseWalletParams.payment_order_id
462
468
  });
463
469
  _context5.next = 19;
464
470
  return this.paymentModule.request.post('/machinecode/prepare/deduction/search', searchParams);
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
49
49
  getCategories(): ProductCategory[];
50
50
  setOtherParams(key: string, value: any): void;
51
51
  getOtherParams(): any;
52
- getProductType(): "duration" | "session" | "normal";
52
+ getProductType(): "normal" | "duration" | "session";
53
53
  }
@@ -536,7 +536,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
536
536
  } else {
537
537
  arr.push(_this3.hooks.setProduct(originProduct, {
538
538
  discount_list: [discountDetail],
539
- _id: product._id.split('___')[0] + "___" + _selectedDiscount.id + index,
539
+ _id: product._id.split('___')[0] + "___" + _selectedDiscount.id + "___" + index,
540
540
  price: _selectedDiscount.tag === 'good_pass' ? 0 : product.price,
541
541
  quantity: isNeedSplit ? 1 : product.quantity,
542
542
  total: targetProductTotal,
@@ -111,7 +111,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
111
111
  * 获取当前的客户搜索条件
112
112
  * @returns 当前搜索条件
113
113
  */
114
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
114
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
115
115
  /**
116
116
  * 获取客户列表状态(包含滚动加载相关状态)
117
117
  * @returns 客户状态