@pisell/pisellos 2.2.53 → 2.2.55

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.
@@ -2018,9 +2018,6 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
2018
2018
  var roundingAmount = new Decimal(payment.rounding_amount || 0);
2019
2019
  // 如果当前支付项有服务费,还需要减去服务费
2020
2020
  var effectiveAmount = paymentAmount.plus(roundingAmount.isNegative() ? roundingAmount.abs() : 0);
2021
- if (payment.service_fee) {
2022
- effectiveAmount = effectiveAmount.minus(new Decimal(payment.service_fee));
2023
- }
2024
2021
  return sum.plus(effectiveAmount);
2025
2022
  } catch (error) {
2026
2023
  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"));
@@ -144,8 +144,6 @@ export interface PaymentItem {
144
144
  created_at?: string;
145
145
  /** 支付项更新时间 (格式: YYYY-MM-DD HH:mm:ss) */
146
146
  updated_at?: string;
147
- /** 三方支付手续费,正常来说只有编辑订单后端会给 */
148
- service_fee?: string;
149
147
  }
150
148
  /**
151
149
  * 订单信息
@@ -123,7 +123,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
123
123
  * 获取当前的客户搜索条件
124
124
  * @returns 当前搜索条件
125
125
  */
126
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
126
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
127
127
  /**
128
128
  * 获取客户列表状态(包含滚动加载相关状态)
129
129
  * @returns 客户状态
@@ -760,6 +760,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
760
760
  return _regeneratorRuntime().wrap(function _callee10$(_context10) {
761
761
  while (1) switch (_context10.prev = _context10.next) {
762
762
  case 0:
763
+ this.payment.wallet.clearAllCache();
763
764
  this.logInfo('updateLocalOrderAsync called', {
764
765
  orderId: params.orderId,
765
766
  orderDataType: (_params$orderData6 = params.orderData) === null || _params$orderData6 === void 0 ? void 0 : _params$orderData6.type,
@@ -771,11 +772,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
771
772
  // 基础校验
772
773
  validation = validateLocalOrderData(params.orderData);
773
774
  if (validation.valid) {
774
- _context10.next = 4;
775
+ _context10.next = 5;
775
776
  break;
776
777
  }
777
778
  throw createCheckoutError(CheckoutErrorType.ValidationFailed, "\u8BA2\u5355\u6570\u636E\u9A8C\u8BC1\u5931\u8D25: ".concat(validation.errors.join(', ')));
778
- case 4:
779
+ case 5:
779
780
  // 计算金额
780
781
  amountInfo = extractAmountFromCartSummary(params.cartSummary); // 规范化补充字段
781
782
  params.orderData.created_at = formatDateTime(new Date());
@@ -801,19 +802,19 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
801
802
  }
802
803
 
803
804
  // 保留原有支付项:通过 orderId 找到现有订单(按 id 或 order_id 匹配)
804
- _context10.next = 17;
805
+ _context10.next = 18;
805
806
  return this.payment.getOrderListAsync();
806
- case 17:
807
+ case 18:
807
808
  allOrders = _context10.sent;
808
809
  existingOrder = allOrders.find(function (o) {
809
810
  return String(o.id) === String(params.orderId) || String(o.order_id) === String(params.orderId);
810
811
  });
811
812
  if (!existingOrder) {
812
- _context10.next = 71;
813
+ _context10.next = 72;
813
814
  break;
814
815
  }
815
816
  if (!(params.existPayment && params.existPayment.length > 0)) {
816
- _context10.next = 47;
817
+ _context10.next = 48;
817
818
  break;
818
819
  }
819
820
  this.logInfo('检测到云端支付项,将替换本地订单的支付项列表', {
@@ -837,7 +838,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
837
838
  });
838
839
  }); // 计算是否需要支付定金
839
840
  _isNeedDeposit = this.checkIsNeedDepositAsync(params.orderData.bookings, params.orderData.relation_products); // 更新订单,替换支付项列表
840
- _context10.next = 28;
841
+ _context10.next = 29;
841
842
  return this.payment.updateOrderAsync(existingOrder.uuid, {
842
843
  total_amount: amountInfo.totalAmount,
843
844
  is_deposit: _isNeedDeposit.hasDeposit ? 1 : 0,
@@ -855,21 +856,21 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
855
856
  amount_breakdown: amountInfo
856
857
  }
857
858
  });
858
- case 28:
859
- _context10.next = 30;
859
+ case 29:
860
+ _context10.next = 31;
860
861
  return this.payment.getPaymentOrderByUuidAsync(existingOrder.uuid);
861
- case 30:
862
+ case 31:
862
863
  _updated = _context10.sent;
863
864
  if (_updated) {
864
- _context10.next = 33;
865
+ _context10.next = 34;
865
866
  break;
866
867
  }
867
868
  throw createCheckoutError(CheckoutErrorType.UnknownError, '订单更新失败');
868
- case 33:
869
+ case 34:
869
870
  this.store.currentOrder = _updated;
870
- _context10.next = 36;
871
+ _context10.next = 37;
871
872
  return this.updateStateAmountToRemaining(false);
872
- case 36:
873
+ case 37:
873
874
  this.logInfo('本地订单更新成功(已替换云端支付项):', {
874
875
  orderId: params.orderId,
875
876
  uuid: _updated.uuid,
@@ -880,12 +881,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
880
881
  });
881
882
 
882
883
  // 事件通知
883
- _context10.next = 39;
884
+ _context10.next = 40;
884
885
  return this.core.effects.emit("".concat(this.name, ":onOrderCreated"), {
885
886
  order: _updated,
886
887
  timestamp: Date.now()
887
888
  });
888
- case 39:
889
+ case 40:
889
890
  // 计算已同步的支付金额
890
891
  syncedPayments = _updated.payment.filter(function (p) {
891
892
  return p.isSynced && p.status !== 'voided';
@@ -893,9 +894,6 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
893
894
  _syncedAmount = syncedPayments.reduce(function (sum, p) {
894
895
  var amt = new Decimal(p.amount || '0');
895
896
  var rounding = new Decimal(Number(p.rounding_amount) > 0 ? 0 : p.rounding_amount || '0').abs();
896
- if (p.service_fee) {
897
- amt = amt.minus(new Decimal(p.service_fee));
898
- }
899
897
  return sum.plus(amt).plus(rounding);
900
898
  }, new Decimal(0));
901
899
  _totalAmount = new Decimal(amountInfo.totalAmount || '0');
@@ -908,7 +906,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
908
906
  order_wait_pay_amount: Number(_depositDiffAmount) > 0 ? Number(_depositDiffAmount) : Number(_remainingExpectAmount)
909
907
  });
910
908
  return _context10.abrupt("return", _updated);
911
- case 47:
909
+ case 48:
912
910
  // 原有逻辑:保留现有支付项
913
911
  totalAmount = new Decimal(amountInfo.totalAmount || '0');
914
912
  activePayments = (existingOrder.payment || []).filter(function (p) {
@@ -921,7 +919,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
921
919
  }, new Decimal(0));
922
920
  remaining = Decimal.max(0, totalAmount.minus(paidAmount)).toFixed(2); // 计算是否需要支付定金,如果需要默认切换到定金模式,以及记录定金总金额,并把当前默认待付金额调整为定金总金额
923
921
  _isNeedDeposit2 = this.checkIsNeedDepositAsync(params.orderData.bookings, params.orderData.relation_products); // 更新到支付模块(使用 uuid,不修改 payment 列表)
924
- _context10.next = 54;
922
+ _context10.next = 55;
925
923
  return this.payment.updateOrderAsync(existingOrder.uuid, {
926
924
  total_amount: amountInfo.totalAmount,
927
925
  is_deposit: _isNeedDeposit2.hasDeposit ? 1 : 0,
@@ -938,21 +936,21 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
938
936
  amount_breakdown: amountInfo
939
937
  }
940
938
  });
941
- case 54:
942
- _context10.next = 56;
939
+ case 55:
940
+ _context10.next = 57;
943
941
  return this.payment.getPaymentOrderByUuidAsync(existingOrder.uuid);
944
- case 56:
942
+ case 57:
945
943
  updated = _context10.sent;
946
944
  if (updated) {
947
- _context10.next = 59;
945
+ _context10.next = 60;
948
946
  break;
949
947
  }
950
948
  throw createCheckoutError(CheckoutErrorType.UnknownError, '订单更新失败');
951
- case 59:
949
+ case 60:
952
950
  this.store.currentOrder = updated;
953
- _context10.next = 62;
951
+ _context10.next = 63;
954
952
  return this.updateStateAmountToRemaining(false);
955
- case 62:
953
+ case 63:
956
954
  this.logInfo('本地订单更新成功(保留支付项):', {
957
955
  orderId: params.orderId,
958
956
  uuid: updated.uuid,
@@ -962,12 +960,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
962
960
  });
963
961
 
964
962
  // 事件通知(复用创建事件,便于上层监听刷新)
965
- _context10.next = 65;
963
+ _context10.next = 66;
966
964
  return this.core.effects.emit("".concat(this.name, ":onOrderCreated"), {
967
965
  order: updated,
968
966
  timestamp: Date.now()
969
967
  });
970
- case 65:
968
+ case 66:
971
969
  // 需要减去已经同步给后端的支付过的钱
972
970
  syncedAmount = activePayments.reduce(function (sum, p) {
973
971
  var amt = new Decimal(p.amount || '0');
@@ -983,10 +981,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
983
981
  order_wait_pay_amount: Number(depositDiffAmount) > 0 ? Number(depositDiffAmount) : Number(remainingExpectAmount)
984
982
  });
985
983
  return _context10.abrupt("return", updated);
986
- case 71:
984
+ case 72:
987
985
  // 计算是否需要支付定金,如果需要默认切换到定金模式,以及记录定金总金额,并把当前默认待付金额调整为定金总金额
988
986
  isNeedDeposit = this.checkIsNeedDepositAsync(params.orderData.bookings, params.orderData.relation_products); // 没找到现有订单时,回退为创建逻辑(用于异常兜底)
989
- _context10.next = 74;
987
+ _context10.next = 75;
990
988
  return this.payment.createPaymentOrderAsync({
991
989
  order_id: String(params.orderId),
992
990
  total_amount: amountInfo.totalAmount,
@@ -1005,7 +1003,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1005
1003
  amount_breakdown: amountInfo
1006
1004
  }
1007
1005
  });
1008
- case 74:
1006
+ case 75:
1009
1007
  created = _context10.sent;
1010
1008
  this.store.currentOrder = created;
1011
1009
 
@@ -1041,7 +1039,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1041
1039
  this.initWalletData();
1042
1040
  }
1043
1041
  return _context10.abrupt("return", created);
1044
- case 78:
1042
+ case 79:
1045
1043
  case "end":
1046
1044
  return _context10.stop();
1047
1045
  }
@@ -3137,9 +3135,6 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3137
3135
  // 当 rounding_amount 为负数时,表示抹掉的金额,应该按绝对值加到实际支付中
3138
3136
  // 例如:amount=15, rounding_amount=-0.2,实际相当于支付了15.2(抹掉了0.2元的零头)
3139
3137
  var effectiveAmount = amount.add(roundingAmount.isNegative() ? roundingAmount.abs() : 0);
3140
- if (payment.service_fee) {
3141
- effectiveAmount = effectiveAmount.minus(new Decimal(payment.service_fee));
3142
- }
3143
3138
  return sum.add(effectiveAmount);
3144
3139
  }, new Decimal(0));
3145
3140
  return paidAmount.toFixed(2);
@@ -1030,10 +1030,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
1030
1030
  }
1031
1031
  const paymentAmount = new import_decimal.Decimal(payment.amount || 0);
1032
1032
  const roundingAmount = new import_decimal.Decimal(payment.rounding_amount || 0);
1033
- let effectiveAmount = paymentAmount.plus(roundingAmount.isNegative() ? roundingAmount.abs() : 0);
1034
- if (payment.service_fee) {
1035
- effectiveAmount = effectiveAmount.minus(new import_decimal.Decimal(payment.service_fee));
1036
- }
1033
+ const effectiveAmount = paymentAmount.plus(roundingAmount.isNegative() ? roundingAmount.abs() : 0);
1037
1034
  return sum.plus(effectiveAmount);
1038
1035
  } catch (error) {
1039
1036
  console.warn(`[PaymentModule] 无效的支付金额: amount=${payment.amount}, rounding_amount=${payment.rounding_amount},跳过计算`);
@@ -144,8 +144,6 @@ export interface PaymentItem {
144
144
  created_at?: string;
145
145
  /** 支付项更新时间 (格式: YYYY-MM-DD HH:mm:ss) */
146
146
  updated_at?: string;
147
- /** 三方支付手续费,正常来说只有编辑订单后端会给 */
148
- service_fee?: string;
149
147
  }
150
148
  /**
151
149
  * 订单信息
@@ -123,7 +123,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
123
123
  * 获取当前的客户搜索条件
124
124
  * @returns 当前搜索条件
125
125
  */
126
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
126
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
127
127
  /**
128
128
  * 获取客户列表状态(包含滚动加载相关状态)
129
129
  * @returns 客户状态
@@ -507,6 +507,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
507
507
  */
508
508
  async updateLocalOrderAsync(params) {
509
509
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
510
+ this.payment.wallet.clearAllCache();
510
511
  this.logInfo("updateLocalOrderAsync called", {
511
512
  orderId: params.orderId,
512
513
  orderDataType: (_a = params.orderData) == null ? void 0 : _a.type,
@@ -607,9 +608,6 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
607
608
  const syncedAmount2 = syncedPayments.reduce((sum, p) => {
608
609
  let amt = new import_decimal.default(p.amount || "0");
609
610
  const rounding = new import_decimal.default(Number(p.rounding_amount) > 0 ? 0 : p.rounding_amount || "0").abs();
610
- if (p.service_fee) {
611
- amt = amt.minus(new import_decimal.default(p.service_fee));
612
- }
613
611
  return sum.plus(amt).plus(rounding);
614
612
  }, new import_decimal.default(0));
615
613
  const totalAmount2 = new import_decimal.default(amountInfo.totalAmount || "0");
@@ -2033,10 +2031,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
2033
2031
  const paidAmount = payments.filter((payment) => payment.status !== "voided").reduce((sum, payment) => {
2034
2032
  const amount = new import_decimal.default(payment.amount || "0");
2035
2033
  const roundingAmount = new import_decimal.default(payment.rounding_amount || "0");
2036
- let effectiveAmount = amount.add(roundingAmount.isNegative() ? roundingAmount.abs() : 0);
2037
- if (payment.service_fee) {
2038
- effectiveAmount = effectiveAmount.minus(new import_decimal.default(payment.service_fee));
2039
- }
2034
+ const effectiveAmount = amount.add(roundingAmount.isNegative() ? roundingAmount.abs() : 0);
2040
2035
  return sum.add(effectiveAmount);
2041
2036
  }, new import_decimal.default(0));
2042
2037
  return paidAmount.toFixed(2);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.2.53",
4
+ "version": "2.2.55",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",