@pisell/pisellos 0.0.310 → 0.0.312

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.
@@ -128,7 +128,7 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
128
128
  case 0:
129
129
  startTime = Date.now();
130
130
  walletParams = this.generateWalletParams(businessData);
131
- if (!(Number((businessData === null || businessData === void 0 || (_businessData$amountI = businessData.amountInfo) === null || _businessData$amountI === void 0 ? void 0 : _businessData$amountI.totalAmount) || 0) < 0 || Number((businessData === null || businessData === void 0 || (_businessData$amountI2 = businessData.amountInfo) === null || _businessData$amountI2 === void 0 ? void 0 : _businessData$amountI2.subTotal) || 0) < 0 || [1, 0].includes(walletParams === null || walletParams === void 0 ? void 0 : walletParams.customer_id))) {
131
+ if (!(Number((businessData === null || businessData === void 0 || (_businessData$amountI = businessData.amountInfo) === null || _businessData$amountI === void 0 ? void 0 : _businessData$amountI.totalAmount) || 0) < 0 || Number((businessData === null || businessData === void 0 || (_businessData$amountI2 = businessData.amountInfo) === null || _businessData$amountI2 === void 0 ? void 0 : _businessData$amountI2.subTotal) || 0) < 0)) {
132
132
  _context.next = 4;
133
133
  break;
134
134
  }
@@ -326,7 +326,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
326
326
  };
327
327
  setOtherData(key: string, value: any): void;
328
328
  getOtherData(key: string): any;
329
- getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
329
+ getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
330
330
  /**
331
331
  * 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
332
332
  *
@@ -677,7 +677,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
677
677
  value: (function () {
678
678
  var _updateLocalOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(params) {
679
679
  var _params$orderData6, _params$orderData7, _params$cartSummary2, _params$totalInfo5, _params$totalInfo6, _params$totalInfo7, _params$totalInfo8;
680
- var validation, amountInfo, customerInfo, allOrders, existingOrder, _updated$payment, totalAmount, activePayments, paidAmount, remaining, _isNeedDeposit, updated, syncedAmount, remainingExpectAmount, isNeedDeposit, created;
680
+ var validation, amountInfo, customerInfo, allOrders, existingOrder, _updated$payment, totalAmount, activePayments, paidAmount, remaining, _isNeedDeposit, updated, syncedAmount, remainingExpectAmount, depositDiffAmount, isNeedDeposit, created;
681
681
  return _regeneratorRuntime().wrap(function _callee10$(_context10) {
682
682
  while (1) switch (_context10.prev = _context10.next) {
683
683
  case 0:
@@ -730,7 +730,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
730
730
  return String(o.id) === String(params.orderId) || String(o.order_id) === String(params.orderId);
731
731
  });
732
732
  if (!existingOrder) {
733
- _context10.next = 42;
733
+ _context10.next = 44;
734
734
  break;
735
735
  }
736
736
  // 基于现有支付项计算新的 expect_amount
@@ -798,15 +798,19 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
798
798
  var rounding = new Decimal(p.rounding_amount || '0').abs();
799
799
  return sum.plus(amt).plus(rounding);
800
800
  }, new Decimal(0));
801
- remainingExpectAmount = Decimal.max(0, totalAmount.minus(syncedAmount)).toFixed(2);
801
+ remainingExpectAmount = Decimal.max(0, totalAmount.minus(syncedAmount)).toFixed(2); // 要计算一个总价的差值和一个定金的差值,如果定金的差值>0,则需要使用定金的差值,否则使用总价的差值
802
+ depositDiffAmount = new Decimal(0).toFixed(2);
803
+ if (updated.is_deposit === 1) {
804
+ depositDiffAmount = new Decimal(updated.deposit_amount).minus(syncedAmount).toFixed(2);
805
+ }
802
806
  this.initWalletData({
803
- order_wait_pay_amount: Number(remainingExpectAmount)
807
+ order_wait_pay_amount: Number(depositDiffAmount) > 0 ? Number(depositDiffAmount) : Number(remainingExpectAmount)
804
808
  });
805
809
  return _context10.abrupt("return", updated);
806
- case 42:
810
+ case 44:
807
811
  // 计算是否需要支付定金,如果需要默认切换到定金模式,以及记录定金总金额,并把当前默认待付金额调整为定金总金额
808
812
  isNeedDeposit = this.checkIsNeedDepositAsync(params.orderData.bookings, params.orderData.relation_products); // 没找到现有订单时,回退为创建逻辑(用于异常兜底)
809
- _context10.next = 45;
813
+ _context10.next = 47;
810
814
  return this.payment.createPaymentOrderAsync({
811
815
  order_id: String(params.orderId),
812
816
  total_amount: amountInfo.totalAmount,
@@ -823,12 +827,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
823
827
  amount_breakdown: amountInfo
824
828
  }
825
829
  });
826
- case 45:
830
+ case 47:
827
831
  created = _context10.sent;
828
832
  this.store.currentOrder = created;
829
833
  this.initWalletData();
830
834
  return _context10.abrupt("return", created);
831
- case 49:
835
+ case 51:
832
836
  case "end":
833
837
  return _context10.stop();
834
838
  }
@@ -99,7 +99,7 @@ var WalletPassPaymentImpl = class {
99
99
  var _a, _b, _c, _d, _e, _f, _g, _h;
100
100
  const startTime = Date.now();
101
101
  const walletParams = this.generateWalletParams(businessData);
102
- if (Number(((_a = businessData == null ? void 0 : businessData.amountInfo) == null ? void 0 : _a.totalAmount) || 0) < 0 || Number(((_b = businessData == null ? void 0 : businessData.amountInfo) == null ? void 0 : _b.subTotal) || 0) < 0 || [1, 0].includes(walletParams == null ? void 0 : walletParams.customer_id)) {
102
+ if (Number(((_a = businessData == null ? void 0 : businessData.amountInfo) == null ? void 0 : _a.totalAmount) || 0) < 0 || Number(((_b = businessData == null ? void 0 : businessData.amountInfo) == null ? void 0 : _b.subTotal) || 0) < 0) {
103
103
  return {
104
104
  walletRecommendList: [],
105
105
  userIdentificationCodes: []
@@ -326,7 +326,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
326
326
  };
327
327
  setOtherData(key: string, value: any): void;
328
328
  getOtherData(key: string): any;
329
- getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
329
+ getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
330
330
  /**
331
331
  * 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
332
332
  *
@@ -530,8 +530,12 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
530
530
  const remainingExpectAmount = import_decimal.default.max(0, totalAmount.minus(syncedAmount)).toFixed(
531
531
  2
532
532
  );
533
+ let depositDiffAmount = new import_decimal.default(0).toFixed(2);
534
+ if (updated.is_deposit === 1) {
535
+ depositDiffAmount = new import_decimal.default(updated.deposit_amount).minus(syncedAmount).toFixed(2);
536
+ }
533
537
  this.initWalletData({
534
- order_wait_pay_amount: Number(remainingExpectAmount)
538
+ order_wait_pay_amount: Number(depositDiffAmount) > 0 ? Number(depositDiffAmount) : Number(remainingExpectAmount)
535
539
  });
536
540
  return updated;
537
541
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "0.0.310",
4
+ "version": "0.0.312",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",