@pisell/pisellos 2.1.17 → 2.1.18

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.
@@ -267,6 +267,10 @@ export var DateModule = /*#__PURE__*/function (_BaseModule) {
267
267
  if (!resource.times || !Array.isArray(resource.times) || !resource.start_time) {
268
268
  return resource;
269
269
  }
270
+ // 如果resource.advanced 为 null 或者 resource.advanced.unit 为 0,则不进行修正
271
+ if (!resource.advanced || resource.advanced.unit === 0) {
272
+ return resource;
273
+ }
270
274
  var resourceStartTime = dayjs(resource.start_time);
271
275
 
272
276
  // 过滤和修正时间段
@@ -1264,7 +1264,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1264
1264
  key: "updateVoucherPaymentItemsAsync",
1265
1265
  value: (function () {
1266
1266
  var _updateVoucherPaymentItemsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(orderUuid, voucherPaymentItems) {
1267
- var order, expectAmount, warningMessage, existingVoucherItems, _iterator5, _step5, voucherItem, _iterator6, _step6, _voucherItem, updatedOrder;
1267
+ var order, existingVoucherItems, _iterator5, _step5, voucherItem, _iterator6, _step6, _voucherItem, updatedOrder;
1268
1268
  return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1269
1269
  while (1) switch (_context15.prev = _context15.next) {
1270
1270
  case 0:
@@ -1291,43 +1291,6 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1291
1291
  }
1292
1292
  throw new Error("\u8BA2\u5355\u4E0D\u5B58\u5728: ".concat(orderUuid));
1293
1293
  case 7:
1294
- // 🔒 订单状态检查:如果订单待付金额已经为0且尝试清空代金券(空数组),跳过操作
1295
- expectAmount = new Decimal(order.expect_amount);
1296
- if (!(expectAmount.lte(0) && voucherPaymentItems.length === 0)) {
1297
- _context15.next = 12;
1298
- break;
1299
- }
1300
- console.warn('[PaymentModule] Skipping voucher update - order already fully paid:', {
1301
- orderUuid: orderUuid,
1302
- expectAmount: order.expect_amount,
1303
- attemptedOperation: 'clear_vouchers',
1304
- reason: 'Order payment completed, no need to clear vouchers'
1305
- });
1306
- this.logInfo('updateVoucherPaymentItemsAsync skipped - order already paid', {
1307
- orderUuid: orderUuid,
1308
- expectAmount: order.expect_amount,
1309
- voucherCount: voucherPaymentItems.length
1310
- });
1311
- return _context15.abrupt("return");
1312
- case 12:
1313
- if (!(expectAmount.lte(0) && voucherPaymentItems.length > 0)) {
1314
- _context15.next = 17;
1315
- break;
1316
- }
1317
- warningMessage = "\u8BA2\u5355 ".concat(orderUuid, " \u5DF2\u5B8C\u6210\u652F\u4ED8\uFF0C\u4E0D\u5141\u8BB8\u6DFB\u52A0\u4EE3\u91D1\u5238\u652F\u4ED8\u9879");
1318
- console.warn('[PaymentModule] Voucher update blocked - order already fully paid:', {
1319
- orderUuid: orderUuid,
1320
- expectAmount: order.expect_amount,
1321
- attemptedVoucherCount: voucherPaymentItems.length,
1322
- reason: 'Order already fully paid'
1323
- });
1324
- this.logError('updateVoucherPaymentItemsAsync blocked', new Error(warningMessage), {
1325
- orderUuid: orderUuid,
1326
- expectAmount: order.expect_amount,
1327
- voucherPaymentItems: voucherPaymentItems
1328
- });
1329
- throw new Error(warningMessage);
1330
- case 17:
1331
1294
  // 1. 查找所有现有的代金券类支付项(带 voucher_id 且状态不是 voided)
1332
1295
  existingVoucherItems = order.payment.filter(function (payment) {
1333
1296
  return payment.voucher_id && payment.status !== 'voided';
@@ -1347,96 +1310,96 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1347
1310
 
1348
1311
  // 2. 删除所有现有的代金券支付项
1349
1312
  _iterator5 = _createForOfIteratorHelper(existingVoucherItems);
1350
- _context15.prev = 20;
1313
+ _context15.prev = 10;
1351
1314
  _iterator5.s();
1352
- case 22:
1315
+ case 12:
1353
1316
  if ((_step5 = _iterator5.n()).done) {
1354
- _context15.next = 29;
1317
+ _context15.next = 19;
1355
1318
  break;
1356
1319
  }
1357
1320
  voucherItem = _step5.value;
1358
1321
  console.log("[PaymentModule] \u5220\u9664\u73B0\u6709\u4EE3\u91D1\u5238\u652F\u4ED8\u9879: ".concat(voucherItem.uuid));
1359
- _context15.next = 27;
1322
+ _context15.next = 17;
1360
1323
  return this.deletePaymentAsync(orderUuid, voucherItem.uuid);
1361
- case 27:
1362
- _context15.next = 22;
1324
+ case 17:
1325
+ _context15.next = 12;
1363
1326
  break;
1364
- case 29:
1365
- _context15.next = 34;
1327
+ case 19:
1328
+ _context15.next = 24;
1366
1329
  break;
1367
- case 31:
1368
- _context15.prev = 31;
1369
- _context15.t0 = _context15["catch"](20);
1330
+ case 21:
1331
+ _context15.prev = 21;
1332
+ _context15.t0 = _context15["catch"](10);
1370
1333
  _iterator5.e(_context15.t0);
1371
- case 34:
1372
- _context15.prev = 34;
1334
+ case 24:
1335
+ _context15.prev = 24;
1373
1336
  _iterator5.f();
1374
- return _context15.finish(34);
1375
- case 37:
1337
+ return _context15.finish(24);
1338
+ case 27:
1376
1339
  // 3. 添加新的代金券支付项
1377
1340
  console.log('[PaymentModule] 添加新的代金券支付项:', {
1378
1341
  orderUuid: orderUuid,
1379
1342
  newItemCount: voucherPaymentItems.length
1380
1343
  });
1381
1344
  _iterator6 = _createForOfIteratorHelper(voucherPaymentItems);
1382
- _context15.prev = 39;
1345
+ _context15.prev = 29;
1383
1346
  _iterator6.s();
1384
- case 41:
1347
+ case 31:
1385
1348
  if ((_step6 = _iterator6.n()).done) {
1386
- _context15.next = 50;
1349
+ _context15.next = 40;
1387
1350
  break;
1388
1351
  }
1389
1352
  _voucherItem = _step6.value;
1390
1353
  if (_voucherItem.voucher_id) {
1391
- _context15.next = 45;
1354
+ _context15.next = 35;
1392
1355
  break;
1393
1356
  }
1394
1357
  throw new Error("\u4EE3\u91D1\u5238\u652F\u4ED8\u9879\u7F3A\u5C11 voucher_id: ".concat(JSON.stringify(_voucherItem)));
1395
- case 45:
1358
+ case 35:
1396
1359
  console.log("[PaymentModule] \u6DFB\u52A0\u4EE3\u91D1\u5238\u652F\u4ED8\u9879:", {
1397
1360
  code: _voucherItem.code,
1398
1361
  amount: _voucherItem.amount,
1399
1362
  voucher_id: _voucherItem.voucher_id,
1400
1363
  order_payment_type: _voucherItem.order_payment_type
1401
1364
  });
1402
- _context15.next = 48;
1365
+ _context15.next = 38;
1403
1366
  return this.addPaymentItemAsync(orderUuid, _voucherItem);
1404
- case 48:
1405
- _context15.next = 41;
1367
+ case 38:
1368
+ _context15.next = 31;
1406
1369
  break;
1407
- case 50:
1408
- _context15.next = 55;
1370
+ case 40:
1371
+ _context15.next = 45;
1409
1372
  break;
1410
- case 52:
1411
- _context15.prev = 52;
1412
- _context15.t1 = _context15["catch"](39);
1373
+ case 42:
1374
+ _context15.prev = 42;
1375
+ _context15.t1 = _context15["catch"](29);
1413
1376
  _iterator6.e(_context15.t1);
1414
- case 55:
1415
- _context15.prev = 55;
1377
+ case 45:
1378
+ _context15.prev = 45;
1416
1379
  _iterator6.f();
1417
- return _context15.finish(55);
1418
- case 58:
1419
- _context15.next = 60;
1380
+ return _context15.finish(45);
1381
+ case 48:
1382
+ _context15.next = 50;
1420
1383
  return this.getPaymentOrderByUuidAsync(orderUuid);
1421
- case 60:
1384
+ case 50:
1422
1385
  updatedOrder = _context15.sent;
1423
- _context15.next = 63;
1386
+ _context15.next = 53;
1424
1387
  return this.core.effects.emit(PaymentHooks.OnPaymentAdded, {
1425
1388
  orderUuid: orderUuid,
1426
1389
  order: updatedOrder,
1427
1390
  payment: null // 批量操作不提供单个支付项
1428
1391
  });
1429
- case 63:
1392
+ case 53:
1430
1393
  this.logInfo('updateVoucherPaymentItemsAsync completed successfully', {
1431
1394
  orderUuid: orderUuid,
1432
1395
  removedVoucherCount: existingVoucherItems.length,
1433
1396
  addedVoucherCount: voucherPaymentItems.length,
1434
1397
  finalExpectAmount: updatedOrder === null || updatedOrder === void 0 ? void 0 : updatedOrder.expect_amount
1435
1398
  });
1436
- _context15.next = 71;
1399
+ _context15.next = 61;
1437
1400
  break;
1438
- case 66:
1439
- _context15.prev = 66;
1401
+ case 56:
1402
+ _context15.prev = 56;
1440
1403
  _context15.t2 = _context15["catch"](1);
1441
1404
  console.error('[PaymentModule] 批量更新代金券支付项失败:', _context15.t2);
1442
1405
  this.logError('updateVoucherPaymentItemsAsync failed', _context15.t2, {
@@ -1444,11 +1407,11 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1444
1407
  voucherPaymentItems: voucherPaymentItems
1445
1408
  });
1446
1409
  throw _context15.t2;
1447
- case 71:
1410
+ case 61:
1448
1411
  case "end":
1449
1412
  return _context15.stop();
1450
1413
  }
1451
- }, _callee15, this, [[1, 66], [20, 31, 34, 37], [39, 52, 55, 58]]);
1414
+ }, _callee15, this, [[1, 56], [10, 21, 24, 27], [29, 42, 45, 48]]);
1452
1415
  }));
1453
1416
  function updateVoucherPaymentItemsAsync(_x18, _x19) {
1454
1417
  return _updateVoucherPaymentItemsAsync.apply(this, arguments);
@@ -1049,7 +1049,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1049
1049
  key: "addPaymentItemAsync",
1050
1050
  value: (function () {
1051
1051
  var _addPaymentItemAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(paymentItem) {
1052
- var orderPaymentType, processedPaymentItem, metadata, paymentItemWithType, remainingAmount, _paymentItem$type, _paymentItem$code, isEftposPayment, syncResult;
1052
+ var orderPaymentType, processedPaymentItem, metadata, paymentItemWithType, remainingAmount, _paymentItem$type, _paymentItem$code, isEftposPayment, _isCashPayment, isCustomePayment, syncResult;
1053
1053
  return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1054
1054
  while (1) switch (_context15.prev = _context15.next) {
1055
1055
  case 0:
@@ -1090,44 +1090,46 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1090
1090
  case 17:
1091
1091
  remainingAmount = _context15.sent;
1092
1092
  if (!(Number(remainingAmount) > 0)) {
1093
- _context15.next = 36;
1093
+ _context15.next = 38;
1094
1094
  break;
1095
1095
  }
1096
1096
  this.logInfo('订单金额还有待付的,同步 EFTPOS 支付');
1097
1097
  // 检查是否是 EFTPOS 支付,如果是则立即同步订单
1098
1098
  isEftposPayment = ((_paymentItem$type = paymentItem.type) === null || _paymentItem$type === void 0 ? void 0 : _paymentItem$type.toLowerCase()) === 'eftpos' || ((_paymentItem$code = paymentItem.code) === null || _paymentItem$code === void 0 ? void 0 : _paymentItem$code.toUpperCase().includes('EFTPOS'));
1099
+ _isCashPayment = paymentItem.code === 'CASHMANUAL';
1100
+ isCustomePayment = paymentItem.type === 'custom';
1099
1101
  this.logInfo('EFTPOS 支付检查:', {
1100
1102
  paymentCode: paymentItem.code,
1101
1103
  paymentType: paymentItem.type,
1102
1104
  isEftposPayment: isEftposPayment,
1103
1105
  currentOrderSynced: this.store.isOrderSynced
1104
1106
  });
1105
- if (!isEftposPayment) {
1106
- _context15.next = 36;
1107
+ if (!(isEftposPayment || _isCashPayment || isCustomePayment)) {
1108
+ _context15.next = 38;
1107
1109
  break;
1108
1110
  }
1109
1111
  this.logInfo('检测到 EFTPOS 支付,立即同步订单到后端...');
1110
- _context15.prev = 24;
1111
- _context15.next = 27;
1112
+ _context15.prev = 26;
1113
+ _context15.next = 29;
1112
1114
  return this.syncOrderToBackendWithReturn(true);
1113
- case 27:
1115
+ case 29:
1114
1116
  syncResult = _context15.sent;
1115
1117
  this.logInfo('EFTPOS 支付后订单同步完成 (已标记为手动同步):', {
1116
1118
  orderId: syncResult.orderId,
1117
1119
  isOrderSynced: this.store.isOrderSynced,
1118
1120
  backendResponse: syncResult.response
1119
1121
  });
1120
- _context15.next = 36;
1122
+ _context15.next = 38;
1121
1123
  break;
1122
- case 31:
1123
- _context15.prev = 31;
1124
- _context15.t0 = _context15["catch"](24);
1124
+ case 33:
1125
+ _context15.prev = 33;
1126
+ _context15.t0 = _context15["catch"](26);
1125
1127
  this.logError('EFTPOS 支付后订单同步失败:', _context15.t0);
1126
1128
  // 不抛出错误,避免影响支付流程,但记录错误
1127
- _context15.next = 36;
1128
- return this.handleError(new Error("EFTPOS \u652F\u4ED8\u540E\u8BA2\u5355\u540C\u6B65\u5931\u8D25: ".concat(_context15.t0 instanceof Error ? _context15.t0.message : String(_context15.t0))), CheckoutErrorType.OrderCreationFailed);
1129
- case 36:
1130
1129
  _context15.next = 38;
1130
+ return this.handleError(new Error("EFTPOS \u652F\u4ED8\u540E\u8BA2\u5355\u540C\u6B65\u5931\u8D25: ".concat(_context15.t0 instanceof Error ? _context15.t0.message : String(_context15.t0))), CheckoutErrorType.OrderCreationFailed);
1131
+ case 38:
1132
+ _context15.next = 40;
1131
1133
  return this.core.effects.emit(CheckoutHooks.OnPaymentItemAdded, {
1132
1134
  orderUuid: this.store.currentOrder.uuid,
1133
1135
  paymentMethodCode: paymentItem.code,
@@ -1135,22 +1137,22 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1135
1137
  amount: String(paymentItem.amount),
1136
1138
  timestamp: Date.now()
1137
1139
  });
1138
- case 38:
1139
- _context15.next = 46;
1140
- break;
1141
1140
  case 40:
1142
- _context15.prev = 40;
1141
+ _context15.next = 48;
1142
+ break;
1143
+ case 42:
1144
+ _context15.prev = 42;
1143
1145
  _context15.t1 = _context15["catch"](1);
1144
1146
  this.logError('添加支付项失败:', _context15.t1);
1145
- _context15.next = 45;
1147
+ _context15.next = 47;
1146
1148
  return this.handleError(_context15.t1, CheckoutErrorType.PaymentFailed);
1147
- case 45:
1149
+ case 47:
1148
1150
  throw _context15.t1;
1149
- case 46:
1151
+ case 48:
1150
1152
  case "end":
1151
1153
  return _context15.stop();
1152
1154
  }
1153
- }, _callee15, this, [[1, 40], [24, 31]]);
1155
+ }, _callee15, this, [[1, 42], [26, 33]]);
1154
1156
  }));
1155
1157
  function addPaymentItemAsync(_x14) {
1156
1158
  return _addPaymentItemAsync.apply(this, arguments);
@@ -1284,7 +1286,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1284
1286
  value: (function () {
1285
1287
  var _updateVoucherPaymentItemsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(voucherPaymentItems) {
1286
1288
  var _this3 = this;
1287
- var remainingAmount, remainingValue, orderPaymentType, voucherPaymentItemsWithType, currentOrderId, isCurrentOrderReal, updatedOrder;
1289
+ var remainingAmount, remainingValue, isOrderSynced, orderPaymentType, voucherPaymentItemsWithType, currentOrderId, isCurrentOrderReal, updatedOrder;
1288
1290
  return _regeneratorRuntime().wrap(function _callee17$(_context17) {
1289
1291
  while (1) switch (_context17.prev = _context17.next) {
1290
1292
  case 0:
@@ -1300,19 +1302,21 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1300
1302
  case 5:
1301
1303
  remainingAmount = _context17.sent;
1302
1304
  remainingValue = new Decimal(remainingAmount);
1303
- if (!remainingValue.lte(0)) {
1304
- _context17.next = 10;
1305
+ isOrderSynced = this.store.isOrderSynced;
1306
+ if (!(remainingValue.lte(0) && isOrderSynced && voucherPaymentItems.length === 0)) {
1307
+ _context17.next = 11;
1305
1308
  break;
1306
1309
  }
1307
- this.logInfo('订单已完成支付且修改代金券,跳过操作避免重复同步:', {
1310
+ this.logInfo('订单已同步且支付完成,跳过清空代金券操作避免重复同步:', {
1308
1311
  orderUuid: this.store.currentOrder.uuid,
1309
1312
  orderId: this.store.currentOrder.order_id,
1310
1313
  remainingAmount: remainingAmount,
1314
+ isOrderSynced: isOrderSynced,
1311
1315
  voucherPaymentItemsCount: voucherPaymentItems.length,
1312
- reason: 'Order payment completed, skip clear vouchers'
1316
+ reason: 'Order synced and payment completed, skip clear vouchers to avoid duplicate sync'
1313
1317
  });
1314
1318
  return _context17.abrupt("return");
1315
- case 10:
1319
+ case 11:
1316
1320
  this.logInfo('开始批量更新代金券支付项:', {
1317
1321
  voucherPaymentItems: voucherPaymentItems
1318
1322
  });
@@ -1334,15 +1338,15 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1334
1338
  metadata: metadata
1335
1339
  });
1336
1340
  }); // 调用 Payment 模块的批量更新方法
1337
- _context17.next = 15;
1341
+ _context17.next = 16;
1338
1342
  return this.payment.updateVoucherPaymentItemsAsync(this.store.currentOrder.uuid, voucherPaymentItemsWithType);
1339
- case 15:
1343
+ case 16:
1340
1344
  // 重新从Payment模块获取最新的订单数据,确保支付项同步
1341
1345
  currentOrderId = this.store.currentOrder.order_id; // 保存当前的订单ID
1342
1346
  isCurrentOrderReal = currentOrderId && !isVirtualOrderId(currentOrderId);
1343
- _context17.next = 19;
1347
+ _context17.next = 20;
1344
1348
  return this.payment.getPaymentOrderByUuidAsync(this.store.currentOrder.uuid);
1345
- case 19:
1349
+ case 20:
1346
1350
  updatedOrder = _context17.sent;
1347
1351
  if (updatedOrder) {
1348
1352
  // 如果当前订单ID是真实ID,但获取到的订单ID是虚拟ID,需要保护真实ID
@@ -1357,10 +1361,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1357
1361
  }
1358
1362
 
1359
1363
  // 更新 stateAmount 为剩余未支付金额
1360
- _context17.next = 23;
1364
+ _context17.next = 24;
1361
1365
  return this.updateStateAmountToRemaining();
1362
- case 23:
1363
- _context17.next = 25;
1366
+ case 24:
1367
+ _context17.next = 26;
1364
1368
  return this.core.effects.emit(CheckoutHooks.OnPaymentStarted, {
1365
1369
  orderUuid: this.store.currentOrder.uuid,
1366
1370
  paymentMethodCode: 'VOUCHER_BATCH',
@@ -1369,23 +1373,23 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1369
1373
  }, 0).toFixed(2),
1370
1374
  timestamp: Date.now()
1371
1375
  });
1372
- case 25:
1376
+ case 26:
1373
1377
  this.logInfo('代金券支付项批量更新成功');
1374
- _context17.next = 34;
1378
+ _context17.next = 35;
1375
1379
  break;
1376
- case 28:
1377
- _context17.prev = 28;
1380
+ case 29:
1381
+ _context17.prev = 29;
1378
1382
  _context17.t0 = _context17["catch"](0);
1379
1383
  this.logError('[Checkout] 批量更新代金券支付项失败:', _context17.t0);
1380
- _context17.next = 33;
1384
+ _context17.next = 34;
1381
1385
  return this.handleError(_context17.t0, CheckoutErrorType.PaymentFailed);
1382
- case 33:
1383
- throw _context17.t0;
1384
1386
  case 34:
1387
+ throw _context17.t0;
1388
+ case 35:
1385
1389
  case "end":
1386
1390
  return _context17.stop();
1387
1391
  }
1388
- }, _callee17, this, [[0, 28]]);
1392
+ }, _callee17, this, [[0, 29]]);
1389
1393
  }));
1390
1394
  function updateVoucherPaymentItemsAsync(_x16) {
1391
1395
  return _updateVoucherPaymentItemsAsync.apply(this, arguments);
@@ -178,6 +178,9 @@ var DateModule = class extends import_BaseModule.BaseModule {
178
178
  if (!resource.times || !Array.isArray(resource.times) || !resource.start_time) {
179
179
  return resource;
180
180
  }
181
+ if (!resource.advanced || resource.advanced.unit === 0) {
182
+ return resource;
183
+ }
181
184
  const resourceStartTime = (0, import_dayjs.default)(resource.start_time);
182
185
  const correctedTimes = resource.times.map((timeSlot) => {
183
186
  if (!timeSlot.start_at || !timeSlot.end_at) {
@@ -670,36 +670,6 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
670
670
  if (!order) {
671
671
  throw new Error(`订单不存在: ${orderUuid}`);
672
672
  }
673
- const expectAmount = new import_decimal.Decimal(order.expect_amount);
674
- if (expectAmount.lte(0) && voucherPaymentItems.length === 0) {
675
- console.warn("[PaymentModule] Skipping voucher update - order already fully paid:", {
676
- orderUuid,
677
- expectAmount: order.expect_amount,
678
- attemptedOperation: "clear_vouchers",
679
- reason: "Order payment completed, no need to clear vouchers"
680
- });
681
- this.logInfo("updateVoucherPaymentItemsAsync skipped - order already paid", {
682
- orderUuid,
683
- expectAmount: order.expect_amount,
684
- voucherCount: voucherPaymentItems.length
685
- });
686
- return;
687
- }
688
- if (expectAmount.lte(0) && voucherPaymentItems.length > 0) {
689
- const warningMessage = `订单 ${orderUuid} 已完成支付,不允许添加代金券支付项`;
690
- console.warn("[PaymentModule] Voucher update blocked - order already fully paid:", {
691
- orderUuid,
692
- expectAmount: order.expect_amount,
693
- attemptedVoucherCount: voucherPaymentItems.length,
694
- reason: "Order already fully paid"
695
- });
696
- this.logError("updateVoucherPaymentItemsAsync blocked", new Error(warningMessage), {
697
- orderUuid,
698
- expectAmount: order.expect_amount,
699
- voucherPaymentItems
700
- });
701
- throw new Error(warningMessage);
702
- }
703
673
  const existingVoucherItems = order.payment.filter(
704
674
  (payment) => payment.voucher_id && payment.status !== "voided"
705
675
  );
@@ -659,13 +659,15 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
659
659
  if (Number(remainingAmount) > 0) {
660
660
  this.logInfo("订单金额还有待付的,同步 EFTPOS 支付");
661
661
  const isEftposPayment = ((_a = paymentItem.type) == null ? void 0 : _a.toLowerCase()) === "eftpos" || ((_b = paymentItem.code) == null ? void 0 : _b.toUpperCase().includes("EFTPOS"));
662
+ const isCashPayment2 = paymentItem.code === "CASHMANUAL";
663
+ const isCustomePayment = paymentItem.type === "custom";
662
664
  this.logInfo("EFTPOS 支付检查:", {
663
665
  paymentCode: paymentItem.code,
664
666
  paymentType: paymentItem.type,
665
667
  isEftposPayment,
666
668
  currentOrderSynced: this.store.isOrderSynced
667
669
  });
668
- if (isEftposPayment) {
670
+ if (isEftposPayment || isCashPayment2 || isCustomePayment) {
669
671
  this.logInfo("检测到 EFTPOS 支付,立即同步订单到后端...");
670
672
  try {
671
673
  const syncResult = await this.syncOrderToBackendWithReturn(true);
@@ -794,13 +796,15 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
794
796
  }
795
797
  const remainingAmount = await this.calculateRemainingAmountAsync();
796
798
  const remainingValue = new import_decimal.default(remainingAmount);
797
- if (remainingValue.lte(0)) {
798
- this.logInfo("订单已完成支付且修改代金券,跳过操作避免重复同步:", {
799
+ const isOrderSynced = this.store.isOrderSynced;
800
+ if (remainingValue.lte(0) && isOrderSynced && voucherPaymentItems.length === 0) {
801
+ this.logInfo("订单已同步且支付完成,跳过清空代金券操作避免重复同步:", {
799
802
  orderUuid: this.store.currentOrder.uuid,
800
803
  orderId: this.store.currentOrder.order_id,
801
804
  remainingAmount,
805
+ isOrderSynced,
802
806
  voucherPaymentItemsCount: voucherPaymentItems.length,
803
- reason: "Order payment completed, skip clear vouchers"
807
+ reason: "Order synced and payment completed, skip clear vouchers to avoid duplicate sync"
804
808
  });
805
809
  return;
806
810
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.1.17",
4
+ "version": "2.1.18",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",