@pisell/pisellos 0.0.300 → 0.0.301

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.
@@ -674,7 +674,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
674
674
  value: (function () {
675
675
  var _updateLocalOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(params) {
676
676
  var _params$orderData6, _params$orderData7, _params$cartSummary2, _params$totalInfo5, _params$totalInfo6, _params$totalInfo7, _params$totalInfo8;
677
- var validation, amountInfo, customerInfo, allOrders, existingOrder, _updated$payment, totalAmount, activePayments, paidAmount, remaining, updated, created;
677
+ var validation, amountInfo, customerInfo, allOrders, existingOrder, _updated$payment, totalAmount, activePayments, paidAmount, remaining, _isNeedDeposit, updated, isNeedDeposit, created;
678
678
  return _regeneratorRuntime().wrap(function _callee10$(_context10) {
679
679
  while (1) switch (_context10.prev = _context10.next) {
680
680
  case 0:
@@ -727,7 +727,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
727
727
  return String(o.id) === String(params.orderId) || String(o.order_id) === String(params.orderId);
728
728
  });
729
729
  if (!existingOrder) {
730
- _context10.next = 39;
730
+ _context10.next = 40;
731
731
  break;
732
732
  }
733
733
  // 基于现有支付项计算新的 expect_amount
@@ -740,12 +740,13 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
740
740
  var rounding = new Decimal(p.rounding_amount || '0').abs();
741
741
  return sum.plus(amt).plus(rounding);
742
742
  }, new Decimal(0));
743
- remaining = Decimal.max(0, totalAmount.minus(paidAmount)).toFixed(2); // 更新到支付模块(使用 uuid,不修改 payment 列表)
744
- _context10.next = 26;
743
+ remaining = Decimal.max(0, totalAmount.minus(paidAmount)).toFixed(2); // 计算是否需要支付定金,如果需要默认切换到定金模式,以及记录定金总金额,并把当前默认待付金额调整为定金总金额
744
+ _isNeedDeposit = this.checkIsNeedDepositAsync(params.orderData.bookings, params.orderData.relation_products); // 更新到支付模块(使用 uuid,不修改 payment 列表)
745
+ _context10.next = 27;
745
746
  return this.payment.updateOrderAsync(existingOrder.uuid, {
746
747
  total_amount: amountInfo.totalAmount,
747
- is_deposit: params.orderData.is_deposit || 0,
748
- deposit_amount: amountInfo.depositAmount || '0.00',
748
+ is_deposit: _isNeedDeposit.hasDeposit ? 1 : 0,
749
+ deposit_amount: _isNeedDeposit.total ? _isNeedDeposit.total.toString() : '0.00',
749
750
  expect_amount: remaining,
750
751
  order_info: {
751
752
  original_order_data: params.orderData,
@@ -758,21 +759,21 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
758
759
  amount_breakdown: amountInfo
759
760
  }
760
761
  });
761
- case 26:
762
- _context10.next = 28;
762
+ case 27:
763
+ _context10.next = 29;
763
764
  return this.payment.getPaymentOrderByUuidAsync(existingOrder.uuid);
764
- case 28:
765
+ case 29:
765
766
  updated = _context10.sent;
766
767
  if (updated) {
767
- _context10.next = 31;
768
+ _context10.next = 32;
768
769
  break;
769
770
  }
770
771
  throw createCheckoutError(CheckoutErrorType.UnknownError, '订单更新失败');
771
- case 31:
772
+ case 32:
772
773
  this.store.currentOrder = updated;
773
- _context10.next = 34;
774
+ _context10.next = 35;
774
775
  return this.updateStateAmountToRemaining(false);
775
- case 34:
776
+ case 35:
776
777
  this.logInfo('本地订单更新成功(保留支付项):', {
777
778
  orderId: params.orderId,
778
779
  uuid: updated.uuid,
@@ -782,23 +783,25 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
782
783
  });
783
784
 
784
785
  // 事件通知(复用创建事件,便于上层监听刷新)
785
- _context10.next = 37;
786
+ _context10.next = 38;
786
787
  return this.core.effects.emit(CheckoutHooks.OnOrderCreated, {
787
788
  order: updated,
788
789
  timestamp: Date.now()
789
790
  });
790
- case 37:
791
+ case 38:
791
792
  this.initWalletData({
792
793
  order_wait_pay_amount: Number(updated.expect_amount)
793
794
  });
794
795
  return _context10.abrupt("return", updated);
795
- case 39:
796
- _context10.next = 41;
796
+ case 40:
797
+ // 计算是否需要支付定金,如果需要默认切换到定金模式,以及记录定金总金额,并把当前默认待付金额调整为定金总金额
798
+ isNeedDeposit = this.checkIsNeedDepositAsync(params.orderData.bookings, params.orderData.relation_products); // 没找到现有订单时,回退为创建逻辑(用于异常兜底)
799
+ _context10.next = 43;
797
800
  return this.payment.createPaymentOrderAsync({
798
801
  order_id: String(params.orderId),
799
802
  total_amount: amountInfo.totalAmount,
800
- is_deposit: params.orderData.is_deposit || 0,
801
- deposit_amount: amountInfo.depositAmount || '0.00',
803
+ is_deposit: isNeedDeposit.hasDeposit ? 1 : 0,
804
+ deposit_amount: isNeedDeposit.total ? isNeedDeposit.total.toString() : '0.00',
802
805
  order_info: {
803
806
  original_order_data: params.orderData,
804
807
  cart_summary: params.cartSummary,
@@ -810,15 +813,15 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
810
813
  amount_breakdown: amountInfo
811
814
  }
812
815
  });
813
- case 41:
816
+ case 43:
814
817
  created = _context10.sent;
815
818
  this.store.currentOrder = created;
816
- _context10.next = 45;
819
+ _context10.next = 47;
817
820
  return this.updateStateAmountToRemaining();
818
- case 45:
821
+ case 47:
819
822
  this.initWalletData();
820
823
  return _context10.abrupt("return", created);
821
- case 47:
824
+ case 49:
822
825
  case "end":
823
826
  return _context10.stop();
824
827
  }
@@ -480,10 +480,14 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
480
480
  const remaining = import_decimal.default.max(0, totalAmount.minus(paidAmount)).toFixed(
481
481
  2
482
482
  );
483
+ const isNeedDeposit2 = this.checkIsNeedDepositAsync(
484
+ params.orderData.bookings,
485
+ params.orderData.relation_products
486
+ );
483
487
  await this.payment.updateOrderAsync(existingOrder.uuid, {
484
488
  total_amount: amountInfo.totalAmount,
485
- is_deposit: params.orderData.is_deposit || 0,
486
- deposit_amount: amountInfo.depositAmount || "0.00",
489
+ is_deposit: isNeedDeposit2.hasDeposit ? 1 : 0,
490
+ deposit_amount: isNeedDeposit2.total ? isNeedDeposit2.total.toString() : "0.00",
487
491
  expect_amount: remaining,
488
492
  order_info: {
489
493
  original_order_data: params.orderData,
@@ -522,11 +526,15 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
522
526
  });
523
527
  return updated;
524
528
  }
529
+ const isNeedDeposit = this.checkIsNeedDepositAsync(
530
+ params.orderData.bookings,
531
+ params.orderData.relation_products
532
+ );
525
533
  const created = await this.payment.createPaymentOrderAsync({
526
534
  order_id: String(params.orderId),
527
535
  total_amount: amountInfo.totalAmount,
528
- is_deposit: params.orderData.is_deposit || 0,
529
- deposit_amount: amountInfo.depositAmount || "0.00",
536
+ is_deposit: isNeedDeposit.hasDeposit ? 1 : 0,
537
+ deposit_amount: isNeedDeposit.total ? isNeedDeposit.total.toString() : "0.00",
530
538
  order_info: {
531
539
  original_order_data: params.orderData,
532
540
  cart_summary: params.cartSummary,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "0.0.300",
4
+ "version": "0.0.301",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",