@pisell/pisellos 0.0.379 → 0.0.385

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.
@@ -14,6 +14,13 @@ import { StrategyEngine } from "../../index";
14
14
  import { processVouchers as _processVouchers, recalculateVouchers as _recalculateVouchers, getApplicableProductIds, getMainProductPrice, getBundleItemPrice, getProductQuantity, getBundleItemIsOriginalPrice } from "./utils";
15
15
  import { locales } from "./locales";
16
16
  import Decimal from 'decimal.js';
17
+ var defaultStrategyMetadataCustom = {
18
+ maxDeductionAmount: 99999,
19
+ maxUsagePerOrder: 0,
20
+ allowCrossProduct: true,
21
+ applicableProductLimit: 0,
22
+ deductTaxAndFee: true
23
+ };
17
24
 
18
25
  /**
19
26
  * Wallet Pass 评估器
@@ -68,7 +75,9 @@ export var WalletPassEvaluator = /*#__PURE__*/function () {
68
75
  config: _objectSpread({}, item === null || item === void 0 || (_item$strategyResult = item.strategyResult) === null || _item$strategyResult === void 0 ? void 0 : _item$strategyResult.config.metadata.custom)
69
76
  });
70
77
  } else {
78
+ var _item$strategyResult2;
71
79
  return _objectSpread(_objectSpread({}, item.voucher), {}, {
80
+ config: _objectSpread({}, item === null || item === void 0 || (_item$strategyResult2 = item.strategyResult) === null || _item$strategyResult2 === void 0 ? void 0 : _item$strategyResult2.config.metadata.custom),
72
81
  reason: item.reason,
73
82
  reasonCode: item.reasonCode
74
83
  });
@@ -111,8 +120,15 @@ export var WalletPassEvaluator = /*#__PURE__*/function () {
111
120
  maxDeduction: 0,
112
121
  deductTaxAndFee: true,
113
122
  applicableProductIds: [],
114
- reason: "",
115
- reasonCode: ""
123
+ reason: '',
124
+ reasonCode: '',
125
+ strategyResult: {
126
+ config: {
127
+ metadata: {
128
+ custom: _objectSpread({}, defaultStrategyMetadataCustom)
129
+ }
130
+ }
131
+ }
116
132
  });
117
133
  continue;
118
134
  }
@@ -177,11 +193,11 @@ export var WalletPassEvaluator = /*#__PURE__*/function () {
177
193
  // 可以根据具体的 code 映射到不同的原因
178
194
  // 例如:如果是金额不足、使用次数限制等
179
195
  var codeMapping = {
180
- 'INSUFFICIENT_AMOUNT': 'not_meet_the_required_conditions',
181
- 'USAGE_LIMIT_EXCEEDED': 'usage_limit_reached',
182
- 'CHANNEL_NOT_ALLOWED': 'not_available_for_this_channel',
183
- 'ORDER_TYPE_NOT_ALLOWED': 'not_valid_for_this_order_type',
184
- 'DEDUCTION_LIMIT_EXCEEDED': 'exceeds_the_maximum_deduction_limit'
196
+ INSUFFICIENT_AMOUNT: 'not_meet_the_required_conditions',
197
+ USAGE_LIMIT_EXCEEDED: 'usage_limit_reached',
198
+ CHANNEL_NOT_ALLOWED: 'not_available_for_this_channel',
199
+ ORDER_TYPE_NOT_ALLOWED: 'not_valid_for_this_order_type',
200
+ DEDUCTION_LIMIT_EXCEEDED: 'exceeds_the_maximum_deduction_limit'
185
201
  };
186
202
  reasonCode = codeMapping[evaluationResult.code] || 'not_meet_the_required_conditions';
187
203
  }
@@ -244,22 +260,15 @@ export var WalletPassEvaluator = /*#__PURE__*/function () {
244
260
  noApplicableVoucher.push(voucher);
245
261
  }
246
262
  });
247
- debugger;
248
263
  var results = this.evaluate(_objectSpread(_objectSpread({}, input), {}, {
249
264
  vouchers: applicableVoucher
250
265
  }));
251
266
  var newVouchers = [];
252
267
  results.forEach(function (item) {
253
268
  if (item.isApplicable) {
254
- var _item$strategyResult2;
269
+ var _item$strategyResult3;
255
270
  newVouchers.push(_objectSpread(_objectSpread({}, item.voucher), {}, {
256
- config: _objectSpread({
257
- maxDeductionAmount: 99999,
258
- maxUsagePerOrder: 0,
259
- allowCrossProduct: true,
260
- applicableProductLimit: 0,
261
- deductTaxAndFee: true
262
- }, (item === null || item === void 0 || (_item$strategyResult2 = item.strategyResult) === null || _item$strategyResult2 === void 0 || (_item$strategyResult2 = _item$strategyResult2.config) === null || _item$strategyResult2 === void 0 || (_item$strategyResult2 = _item$strategyResult2.metadata) === null || _item$strategyResult2 === void 0 ? void 0 : _item$strategyResult2.custom) || {})
271
+ config: _objectSpread(_objectSpread({}, defaultStrategyMetadataCustom), (item === null || item === void 0 || (_item$strategyResult3 = item.strategyResult) === null || _item$strategyResult3 === void 0 || (_item$strategyResult3 = _item$strategyResult3.config) === null || _item$strategyResult3 === void 0 || (_item$strategyResult3 = _item$strategyResult3.metadata) === null || _item$strategyResult3 === void 0 ? void 0 : _item$strategyResult3.custom) || {})
263
272
  }));
264
273
  } else {
265
274
  // 不可用的券,添加原因信息
@@ -803,7 +803,7 @@ export function recalculateVouchers(allVouchers, selectedVouchers, orderTotalAmo
803
803
  * @returns 商品价格
804
804
  */
805
805
  export var getMainProductPrice = function getMainProductPrice(product, isDeductTaxAndFee) {
806
- var _product$metadata, _product$metadata2, _product$metadata3;
806
+ var _product$metadata, _product$metadata2, _product$metadata3, _product$metadata4;
807
807
  var mainProductPrice = new Decimal((product === null || product === void 0 ? void 0 : product.main_product_selling_price) || ((_product$metadata = product.metadata) === null || _product$metadata === void 0 ? void 0 : _product$metadata.main_product_selling_price) || 0);
808
808
  var _iterator6 = _createForOfIteratorHelper((product === null || product === void 0 ? void 0 : product.product_bundle) || []),
809
809
  _step6;
@@ -827,7 +827,7 @@ export var getMainProductPrice = function getMainProductPrice(product, isDeductT
827
827
  }
828
828
  var taxFee = new Decimal((product === null || product === void 0 ? void 0 : product.tax_fee) || (product === null || product === void 0 || (_product$metadata2 = product.metadata) === null || _product$metadata2 === void 0 ? void 0 : _product$metadata2.main_product_attached_bundle_tax_fee) || 0);
829
829
  // 附加费
830
- var surchargeFee = new Decimal((product === null || product === void 0 || (_product$metadata3 = product.metadata) === null || _product$metadata3 === void 0 ? void 0 : _product$metadata3.main_product_attached_bundle_surcharge_fee) || 0);
830
+ var surchargeFee = new Decimal((product === null || product === void 0 || (_product$metadata3 = product.metadata) === null || _product$metadata3 === void 0 ? void 0 : _product$metadata3.main_product_attached_bundle_surcharge_fee) || 0).add((product === null || product === void 0 || (_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4.surcharge_rounding_remainder) || 0);
831
831
 
832
832
  // 税费附加费总额
833
833
  var taxAndFeeTotal = taxFee.add(surchargeFee);
@@ -43,6 +43,21 @@ function formatAmount(amount) {
43
43
  }
44
44
  }
45
45
 
46
+ /**
47
+ * 格式化日期时间为字符串
48
+ * 格式: YYYY-MM-DD HH:mm:ss
49
+ * 示例: 2025-12-10 16:14:50
50
+ */
51
+ function formatDateTime(date) {
52
+ var year = date.getFullYear();
53
+ var month = String(date.getMonth() + 1).padStart(2, '0');
54
+ var day = String(date.getDate()).padStart(2, '0');
55
+ var hours = String(date.getHours()).padStart(2, '0');
56
+ var minutes = String(date.getMinutes()).padStart(2, '0');
57
+ var seconds = String(date.getSeconds()).padStart(2, '0');
58
+ return "".concat(year, "-").concat(month, "-").concat(day, " ").concat(hours, ":").concat(minutes, ":").concat(seconds);
59
+ }
60
+
46
61
  /**
47
62
  * 生成请求唯一ID
48
63
  * 格式: 年月日时分秒毫秒+4位随机数
@@ -665,7 +680,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
665
680
  value: (function () {
666
681
  var _createPaymentOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(params) {
667
682
  var _this3 = this;
668
- var newOrder, dbAddStartTime, dbAddDuration;
683
+ var newOrder, currentTime, dbAddStartTime, dbAddDuration;
669
684
  return _regeneratorRuntime().wrap(function _callee7$(_context7) {
670
685
  while (1) switch (_context7.prev = _context7.next) {
671
686
  case 0:
@@ -725,11 +740,15 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
725
740
  deposit_amount: params.deposit_amount || '0.00'
726
741
  }; // 🔧 新增: 处理云端已存在的支付项
727
742
  if (params.existPayment && params.existPayment.length > 0) {
743
+ currentTime = formatDateTime(new Date());
728
744
  newOrder.payment = params.existPayment.map(function (payment) {
729
745
  return _objectSpread(_objectSpread({}, payment), {}, {
730
746
  isSynced: true,
731
747
  // 标记为已同步
732
- status: payment.status || 'active'
748
+ status: payment.status || 'active',
749
+ // 如果云端支付项已有时间戳,则保留;否则使用当前时间
750
+ created_at: payment.created_at || currentTime,
751
+ updated_at: payment.updated_at || currentTime
733
752
  });
734
753
  });
735
754
 
@@ -745,7 +764,9 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
745
764
  uuid: p.uuid,
746
765
  code: p.code,
747
766
  amount: p.amount,
748
- status: p.status
767
+ status: p.status,
768
+ created_at: p.created_at,
769
+ updated_at: p.updated_at
749
770
  };
750
771
  })
751
772
  });
@@ -1085,7 +1106,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1085
1106
  key: "addPaymentItemAsync",
1086
1107
  value: (function () {
1087
1108
  var _addPaymentItemAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(orderUuid, paymentItem) {
1088
- var _paymentItem$metadata, _newPaymentItem$metad, _newPaymentItem$metad2, _newPaymentItem$metad3, order, expectAmount, paidDepositAmount, expectedDepositAmount, warningMessage, paymentUuid, newPaymentItem;
1109
+ var _paymentItem$metadata, _newPaymentItem$metad, _newPaymentItem$metad2, _newPaymentItem$metad3, order, expectAmount, paidDepositAmount, expectedDepositAmount, warningMessage, paymentUuid, currentTime, newPaymentItem;
1089
1110
  return _regeneratorRuntime().wrap(function _callee13$(_context13) {
1090
1111
  while (1) switch (_context13.prev = _context13.next) {
1091
1112
  case 0:
@@ -1146,6 +1167,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1146
1167
  } else {
1147
1168
  paymentUuid = getUniqueId('payment_');
1148
1169
  }
1170
+ currentTime = formatDateTime(new Date());
1149
1171
  newPaymentItem = {
1150
1172
  uuid: paymentUuid,
1151
1173
  id: paymentItem.id || 0,
@@ -1160,6 +1182,10 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1160
1182
  // 新支付项默认为活跃状态
1161
1183
  order_payment_type: paymentItem.order_payment_type || 'normal',
1162
1184
  // 默认为正常支付
1185
+ created_at: currentTime,
1186
+ // 创建时间
1187
+ updated_at: currentTime,
1188
+ // 更新时间
1163
1189
  metadata: _objectSpread(_objectSpread({}, paymentItem.metadata), {}, {
1164
1190
  // 保留传入的所有 metadata 字段
1165
1191
  unique_payment_number: paymentUuid // 设置唯一支付号为支付项的 uuid
@@ -1171,9 +1197,9 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1171
1197
  orderUuid: orderUuid,
1172
1198
  order: order
1173
1199
  });
1174
- _context13.next = 24;
1200
+ _context13.next = 25;
1175
1201
  return this.dbManager.update('order', order, true);
1176
- case 24:
1202
+ case 25:
1177
1203
  this.logInfo('更新订单支付项完成', {
1178
1204
  orderUuid: orderUuid
1179
1205
  });
@@ -1194,10 +1220,10 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1194
1220
  actualPaidAmount: (_newPaymentItem$metad2 = newPaymentItem.metadata) === null || _newPaymentItem$metad2 === void 0 ? void 0 : _newPaymentItem$metad2.actual_paid_amount,
1195
1221
  changeGivenAmount: (_newPaymentItem$metad3 = newPaymentItem.metadata) === null || _newPaymentItem$metad3 === void 0 ? void 0 : _newPaymentItem$metad3.change_given_amount
1196
1222
  });
1197
- _context13.next = 34;
1223
+ _context13.next = 35;
1198
1224
  break;
1199
- case 29:
1200
- _context13.prev = 29;
1225
+ case 30:
1226
+ _context13.prev = 30;
1201
1227
  _context13.t0 = _context13["catch"](1);
1202
1228
  console.error('[PaymentModule] 添加支付项失败', _context13.t0);
1203
1229
  this.logError('addPaymentItemAsync failed', _context13.t0, {
@@ -1205,11 +1231,11 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1205
1231
  paymentItem: paymentItem
1206
1232
  });
1207
1233
  throw _context13.t0;
1208
- case 34:
1234
+ case 35:
1209
1235
  case "end":
1210
1236
  return _context13.stop();
1211
1237
  }
1212
- }, _callee13, this, [[1, 29]]);
1238
+ }, _callee13, this, [[1, 30]]);
1213
1239
  }));
1214
1240
  function addPaymentItemAsync(_x14, _x15) {
1215
1241
  return _addPaymentItemAsync.apply(this, arguments);
@@ -138,6 +138,10 @@ export interface PaymentItem {
138
138
  statusCode?: number;
139
139
  timestamp: number;
140
140
  };
141
+ /** 支付项创建时间 (格式: YYYY-MM-DD HH:mm:ss) */
142
+ created_at?: string;
143
+ /** 支付项更新时间 (格式: YYYY-MM-DD HH:mm:ss) */
144
+ updated_at?: string;
141
145
  }
142
146
  /**
143
147
  * 订单信息
@@ -250,6 +254,10 @@ export interface PaymentItemInput {
250
254
  /** 找零金额(现金支付时的找零金额) */
251
255
  change_given_amount?: number;
252
256
  };
257
+ /** 支付项创建时间 (格式: YYYY-MM-DD HH:mm:ss, 可选,不传则自动生成) */
258
+ created_at?: string;
259
+ /** 支付项更新时间 (格式: YYYY-MM-DD HH:mm:ss, 可选,不传则自动生成) */
260
+ updated_at?: string;
253
261
  }
254
262
  /**
255
263
  * 推送支付项参数
@@ -166,14 +166,9 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
166
166
  products_count: ((_businessData$product = businessData.products) === null || _businessData$product === void 0 ? void 0 : _businessData$product.length) || 0
167
167
  });
168
168
  _context.prev = 6;
169
- // 生成钱包API参数
170
- // const walletParams = this.generateWalletParams(businessData);
171
-
172
- debugger;
173
- // 调用标准的初始化流程
174
- _context.next = 10;
169
+ _context.next = 9;
175
170
  return this.initializeWalletDataAsync(walletParams);
176
- case 10:
171
+ case 9:
177
172
  result = _context.sent;
178
173
  endTime = Date.now();
179
174
  duration = endTime - startTime; // 发送初始化完成事件
@@ -190,8 +185,8 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
190
185
  userIdentificationCodes_count: ((_result$userIdentific = result.userIdentificationCodes) === null || _result$userIdentific === void 0 ? void 0 : _result$userIdentific.length) || 0
191
186
  });
192
187
  return _context.abrupt("return", result);
193
- case 18:
194
- _context.prev = 18;
188
+ case 17:
189
+ _context.prev = 17;
195
190
  _context.t0 = _context["catch"](6);
196
191
  _endTime = Date.now();
197
192
  _duration = _endTime - startTime; // 发送初始化失败事件
@@ -208,11 +203,11 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
208
203
  totalAmount: (_businessData$amountI5 = businessData.amountInfo) === null || _businessData$amountI5 === void 0 ? void 0 : _businessData$amountI5.totalAmount
209
204
  });
210
205
  throw _context.t0;
211
- case 25:
206
+ case 24:
212
207
  case "end":
213
208
  return _context.stop();
214
209
  }
215
- }, _callee, this, [[6, 18]]);
210
+ }, _callee, this, [[6, 17]]);
216
211
  }));
217
212
  function initializeWalletDataFromBusinessAsync(_x) {
218
213
  return _initializeWalletDataFromBusinessAsync.apply(this, arguments);
@@ -1110,7 +1110,6 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1110
1110
 
1111
1111
  // 检查是否有bundle子商品需要重组
1112
1112
  var hasBundle = product.bundle && Array.isArray(product.bundle) && product.bundle.length > 0;
1113
- debugger;
1114
1113
  if (!hasBundle) {
1115
1114
  // 没有bundle,直接使用主商品处理结果
1116
1115
  result.push.apply(result, _toConsumableArray(mainProductArr));
@@ -1461,7 +1460,6 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1461
1460
 
1462
1461
  // 根据是否有适用商品决定isAvailable
1463
1462
  var isAvailable = applicableProducts.length > 0;
1464
- debugger;
1465
1463
 
1466
1464
  // 如果此优惠券被明确设置为不选中,保持其状态,但正确设置isAvailable
1467
1465
  if (typeof discount.isSelected === 'boolean' && discount.isSelected === false && discount.isManualSelect) {
@@ -36,6 +36,13 @@ var import__ = require("../../index");
36
36
  var import_utils = require("./utils");
37
37
  var import_locales = require("./locales");
38
38
  var import_decimal = __toESM(require("decimal.js"));
39
+ var defaultStrategyMetadataCustom = {
40
+ maxDeductionAmount: 99999,
41
+ maxUsagePerOrder: 0,
42
+ allowCrossProduct: true,
43
+ applicableProductLimit: 0,
44
+ deductTaxAndFee: true
45
+ };
39
46
  var WalletPassEvaluator = class {
40
47
  constructor() {
41
48
  this.strategyConfigs = [];
@@ -66,7 +73,7 @@ var WalletPassEvaluator = class {
66
73
  searchVoucherFormat(input) {
67
74
  const results = this.evaluate(input);
68
75
  return results.map((item) => {
69
- var _a;
76
+ var _a, _b;
70
77
  if (item.isApplicable) {
71
78
  return {
72
79
  ...item.voucher,
@@ -77,6 +84,9 @@ var WalletPassEvaluator = class {
77
84
  } else {
78
85
  return {
79
86
  ...item.voucher,
87
+ config: {
88
+ ...(_b = item == null ? void 0 : item.strategyResult) == null ? void 0 : _b.config.metadata.custom
89
+ },
80
90
  reason: item.reason,
81
91
  reasonCode: item.reasonCode
82
92
  };
@@ -105,13 +115,26 @@ var WalletPassEvaluator = class {
105
115
  deductTaxAndFee: true,
106
116
  applicableProductIds: [],
107
117
  reason: "",
108
- reasonCode: ""
118
+ reasonCode: "",
119
+ strategyResult: {
120
+ config: {
121
+ metadata: {
122
+ custom: {
123
+ ...defaultStrategyMetadataCustom
124
+ }
125
+ }
126
+ }
127
+ }
109
128
  });
110
129
  continue;
111
130
  }
112
131
  const strategy = applicableStrategies[0];
113
132
  const applicableProductIds = (0, import_utils.getApplicableProductIds)(voucher);
114
- const { applicableTotal, applicableCount } = this.calculateApplicableProducts(products, applicableProductIds, ((_b = (_a = strategy == null ? void 0 : strategy.metadata) == null ? void 0 : _a.custom) == null ? void 0 : _b.deductTaxAndFee) ?? true);
133
+ const { applicableTotal, applicableCount } = this.calculateApplicableProducts(
134
+ products,
135
+ applicableProductIds,
136
+ ((_b = (_a = strategy == null ? void 0 : strategy.metadata) == null ? void 0 : _a.custom) == null ? void 0 : _b.deductTaxAndFee) ?? true
137
+ );
115
138
  const context = {
116
139
  entities: {
117
140
  voucher,
@@ -151,11 +174,11 @@ var WalletPassEvaluator = class {
151
174
  let reasonCode = "not_meet_the_required_conditions";
152
175
  if (evaluationResult.code) {
153
176
  const codeMapping = {
154
- "INSUFFICIENT_AMOUNT": "not_meet_the_required_conditions",
155
- "USAGE_LIMIT_EXCEEDED": "usage_limit_reached",
156
- "CHANNEL_NOT_ALLOWED": "not_available_for_this_channel",
157
- "ORDER_TYPE_NOT_ALLOWED": "not_valid_for_this_order_type",
158
- "DEDUCTION_LIMIT_EXCEEDED": "exceeds_the_maximum_deduction_limit"
177
+ INSUFFICIENT_AMOUNT: "not_meet_the_required_conditions",
178
+ USAGE_LIMIT_EXCEEDED: "usage_limit_reached",
179
+ CHANNEL_NOT_ALLOWED: "not_available_for_this_channel",
180
+ ORDER_TYPE_NOT_ALLOWED: "not_valid_for_this_order_type",
181
+ DEDUCTION_LIMIT_EXCEEDED: "exceeds_the_maximum_deduction_limit"
159
182
  };
160
183
  reasonCode = codeMapping[evaluationResult.code] || "not_meet_the_required_conditions";
161
184
  }
@@ -203,7 +226,6 @@ var WalletPassEvaluator = class {
203
226
  noApplicableVoucher.push(voucher);
204
227
  }
205
228
  });
206
- debugger;
207
229
  const results = this.evaluate({
208
230
  ...input,
209
231
  vouchers: applicableVoucher
@@ -215,11 +237,7 @@ var WalletPassEvaluator = class {
215
237
  newVouchers.push({
216
238
  ...item.voucher,
217
239
  config: {
218
- maxDeductionAmount: 99999,
219
- maxUsagePerOrder: 0,
220
- allowCrossProduct: true,
221
- applicableProductLimit: 0,
222
- deductTaxAndFee: true,
240
+ ...defaultStrategyMetadataCustom,
223
241
  ...((_c = (_b = (_a = item == null ? void 0 : item.strategyResult) == null ? void 0 : _a.config) == null ? void 0 : _b.metadata) == null ? void 0 : _c.custom) || {}
224
242
  }
225
243
  });
@@ -232,7 +250,11 @@ var WalletPassEvaluator = class {
232
250
  });
233
251
  }
234
252
  });
235
- const { recommended, transformList } = this.processVouchers(newVouchers, orderTotalAmount, products);
253
+ const { recommended, transformList } = this.processVouchers(
254
+ newVouchers,
255
+ orderTotalAmount,
256
+ products
257
+ );
236
258
  const recommendedAmount = recommended.reduce((sum, item) => {
237
259
  return new import_decimal.default(sum).add(item._available_max_amount || 0).toNumber();
238
260
  }, 0);
@@ -266,8 +288,12 @@ var WalletPassEvaluator = class {
266
288
  processVouchers(vouchers, orderTotalAmount, products) {
267
289
  const result = (0, import_utils.processVouchers)(vouchers, orderTotalAmount, products);
268
290
  return {
269
- recommended: result.recommended.map((item) => this.enhanceWithReason(item)),
270
- transformList: result.transformList.map((item) => this.enhanceWithReason(item))
291
+ recommended: result.recommended.map(
292
+ (item) => this.enhanceWithReason(item)
293
+ ),
294
+ transformList: result.transformList.map(
295
+ (item) => this.enhanceWithReason(item)
296
+ )
271
297
  };
272
298
  }
273
299
  /**
@@ -286,8 +312,12 @@ var WalletPassEvaluator = class {
286
312
  products
287
313
  );
288
314
  return {
289
- allWithUpdatedStatus: result.allWithUpdatedStatus.map((item) => this.enhanceWithReason(item)),
290
- selectedWithDetails: result.selectedWithDetails.map((item) => this.enhanceWithReason(item))
315
+ allWithUpdatedStatus: result.allWithUpdatedStatus.map(
316
+ (item) => this.enhanceWithReason(item)
317
+ ),
318
+ selectedWithDetails: result.selectedWithDetails.map(
319
+ (item) => this.enhanceWithReason(item)
320
+ )
291
321
  };
292
322
  }
293
323
  /**
@@ -370,7 +400,11 @@ var WalletPassEvaluator = class {
370
400
  const isBundleItemApplicable = applicableProductIds === null || applicableProductIds.includes(bundleItem.bundle_product_id);
371
401
  if (isBundleItemApplicable) {
372
402
  const bundleItemQuantity = bundleItem.num * productQuantity;
373
- total += (0, import_utils.getBundleItemPrice)(bundleItem, productQuantity, deductTaxAndFee);
403
+ total += (0, import_utils.getBundleItemPrice)(
404
+ bundleItem,
405
+ productQuantity,
406
+ deductTaxAndFee
407
+ );
374
408
  count += bundleItemQuantity;
375
409
  }
376
410
  }
@@ -547,7 +547,7 @@ function recalculateVouchers(allVouchers, selectedVouchers, orderTotalAmount, pr
547
547
  };
548
548
  }
549
549
  var getMainProductPrice = (product, isDeductTaxAndFee) => {
550
- var _a, _b, _c;
550
+ var _a, _b, _c, _d;
551
551
  let mainProductPrice = new import_decimal.default((product == null ? void 0 : product.main_product_selling_price) || ((_a = product.metadata) == null ? void 0 : _a.main_product_selling_price) || 0);
552
552
  for (let bundleItem of (product == null ? void 0 : product.product_bundle) || []) {
553
553
  if (getBundleItemIsMarkupOrDiscountPrice(bundleItem)) {
@@ -556,7 +556,7 @@ var getMainProductPrice = (product, isDeductTaxAndFee) => {
556
556
  }
557
557
  }
558
558
  const taxFee = new import_decimal.default((product == null ? void 0 : product.tax_fee) || ((_b = product == null ? void 0 : product.metadata) == null ? void 0 : _b.main_product_attached_bundle_tax_fee) || 0);
559
- const surchargeFee = new import_decimal.default(((_c = product == null ? void 0 : product.metadata) == null ? void 0 : _c.main_product_attached_bundle_surcharge_fee) || 0);
559
+ const surchargeFee = new import_decimal.default(((_c = product == null ? void 0 : product.metadata) == null ? void 0 : _c.main_product_attached_bundle_surcharge_fee) || 0).add(((_d = product == null ? void 0 : product.metadata) == null ? void 0 : _d.surcharge_rounding_remainder) || 0);
560
560
  const taxAndFeeTotal = taxFee.add(surchargeFee);
561
561
  if (isDeductTaxAndFee) {
562
562
  mainProductPrice = mainProductPrice.add(taxAndFeeTotal);
@@ -41,6 +41,15 @@ function formatAmount(amount) {
41
41
  return "0.00";
42
42
  }
43
43
  }
44
+ function formatDateTime(date) {
45
+ const year = date.getFullYear();
46
+ const month = String(date.getMonth() + 1).padStart(2, "0");
47
+ const day = String(date.getDate()).padStart(2, "0");
48
+ const hours = String(date.getHours()).padStart(2, "0");
49
+ const minutes = String(date.getMinutes()).padStart(2, "0");
50
+ const seconds = String(date.getSeconds()).padStart(2, "0");
51
+ return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
52
+ }
44
53
  function generateRequestUniqueId() {
45
54
  const now = /* @__PURE__ */ new Date();
46
55
  const year = now.getFullYear();
@@ -339,11 +348,15 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
339
348
  deposit_amount: params.deposit_amount || "0.00"
340
349
  };
341
350
  if (params.existPayment && params.existPayment.length > 0) {
351
+ const currentTime = formatDateTime(/* @__PURE__ */ new Date());
342
352
  newOrder.payment = params.existPayment.map((payment) => ({
343
353
  ...payment,
344
354
  isSynced: true,
345
355
  // 标记为已同步
346
- status: payment.status || "active"
356
+ status: payment.status || "active",
357
+ // 如果云端支付项已有时间戳,则保留;否则使用当前时间
358
+ created_at: payment.created_at || currentTime,
359
+ updated_at: payment.updated_at || currentTime
347
360
  }));
348
361
  this.recalculateOrderAmount(newOrder);
349
362
  this.logInfo("创建订单时包含云端支付项", {
@@ -355,7 +368,9 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
355
368
  uuid: p.uuid,
356
369
  code: p.code,
357
370
  amount: p.amount,
358
- status: p.status
371
+ status: p.status,
372
+ created_at: p.created_at,
373
+ updated_at: p.updated_at
359
374
  }))
360
375
  });
361
376
  }
@@ -573,6 +588,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
573
588
  } else {
574
589
  paymentUuid = (0, import_utils.getUniqueId)("payment_");
575
590
  }
591
+ const currentTime = formatDateTime(/* @__PURE__ */ new Date());
576
592
  const newPaymentItem = {
577
593
  uuid: paymentUuid,
578
594
  id: paymentItem.id || 0,
@@ -587,6 +603,10 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
587
603
  // 新支付项默认为活跃状态
588
604
  order_payment_type: paymentItem.order_payment_type || "normal",
589
605
  // 默认为正常支付
606
+ created_at: currentTime,
607
+ // 创建时间
608
+ updated_at: currentTime,
609
+ // 更新时间
590
610
  metadata: {
591
611
  ...paymentItem.metadata,
592
612
  // 保留传入的所有 metadata 字段
@@ -138,6 +138,10 @@ export interface PaymentItem {
138
138
  statusCode?: number;
139
139
  timestamp: number;
140
140
  };
141
+ /** 支付项创建时间 (格式: YYYY-MM-DD HH:mm:ss) */
142
+ created_at?: string;
143
+ /** 支付项更新时间 (格式: YYYY-MM-DD HH:mm:ss) */
144
+ updated_at?: string;
141
145
  }
142
146
  /**
143
147
  * 订单信息
@@ -250,6 +254,10 @@ export interface PaymentItemInput {
250
254
  /** 找零金额(现金支付时的找零金额) */
251
255
  change_given_amount?: number;
252
256
  };
257
+ /** 支付项创建时间 (格式: YYYY-MM-DD HH:mm:ss, 可选,不传则自动生成) */
258
+ created_at?: string;
259
+ /** 支付项更新时间 (格式: YYYY-MM-DD HH:mm:ss, 可选,不传则自动生成) */
260
+ updated_at?: string;
253
261
  }
254
262
  /**
255
263
  * 推送支付项参数
@@ -136,7 +136,6 @@ var WalletPassPaymentImpl = class {
136
136
  products_count: ((_e = businessData.products) == null ? void 0 : _e.length) || 0
137
137
  });
138
138
  try {
139
- debugger;
140
139
  const result = await this.initializeWalletDataAsync(walletParams);
141
140
  const endTime = Date.now();
142
141
  const duration = endTime - startTime;
@@ -909,7 +909,6 @@ var RulesModule = class extends import_BaseModule.BaseModule {
909
909
  return;
910
910
  }
911
911
  const hasBundle = product.bundle && Array.isArray(product.bundle) && product.bundle.length > 0;
912
- debugger;
913
912
  if (!hasBundle) {
914
913
  result.push(...mainProductArr);
915
914
  } else {
@@ -1227,7 +1226,6 @@ var RulesModule = class extends import_BaseModule.BaseModule {
1227
1226
  const applicableProductDetails = discountApplicableProducts.get(discount.id) || [];
1228
1227
  const appliedProductDetails = appliedDiscountProducts.get(discount.id) || [];
1229
1228
  const isAvailable = applicableProducts.length > 0;
1230
- debugger;
1231
1229
  if (typeof discount.isSelected === "boolean" && discount.isSelected === false && discount.isManualSelect) {
1232
1230
  return {
1233
1231
  ...discount,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "0.0.379",
4
+ "version": "0.0.385",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",