@pisell/pisellos 2.2.12 → 2.2.14

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.
@@ -312,66 +312,67 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
312
312
  return _context3.abrupt("return", cachedMethods);
313
313
  case 16:
314
314
  _context3.next = 18;
315
- return this.request.get('/pay/custom-payment/available', {
316
- channel: 'pos'
317
- });
315
+ return this.request.get('/pay/custom-payment/all');
318
316
  case 18:
319
317
  response = _context3.sent;
318
+ response.data = response.data.filter(function (method) {
319
+ return method.status === 1 && method.disable === 0;
320
+ });
320
321
  payMethods = response.data || []; // 尝试缓存到 IndexDB
321
- _context3.prev = 20;
322
+ _context3.prev = 21;
322
323
  _iterator = _createForOfIteratorHelper(payMethods);
323
- _context3.prev = 22;
324
+ _context3.prev = 23;
324
325
  _iterator.s();
325
- case 24:
326
+ case 25:
326
327
  if ((_step = _iterator.n()).done) {
327
- _context3.next = 30;
328
+ _context3.next = 31;
328
329
  break;
329
330
  }
330
331
  method = _step.value;
331
- _context3.next = 28;
332
+ _context3.next = 29;
332
333
  return this.dbManager.update('pay_method', method);
333
- case 28:
334
- _context3.next = 24;
334
+ case 29:
335
+ _context3.next = 25;
335
336
  break;
336
- case 30:
337
- _context3.next = 35;
337
+ case 31:
338
+ _context3.next = 36;
338
339
  break;
339
- case 32:
340
- _context3.prev = 32;
341
- _context3.t1 = _context3["catch"](22);
340
+ case 33:
341
+ _context3.prev = 33;
342
+ _context3.t1 = _context3["catch"](23);
342
343
  _iterator.e(_context3.t1);
343
- case 35:
344
- _context3.prev = 35;
344
+ case 36:
345
+ _context3.prev = 36;
345
346
  _iterator.f();
346
- return _context3.finish(35);
347
- case 38:
348
- _context3.next = 43;
347
+ return _context3.finish(36);
348
+ case 39:
349
+ _context3.next = 44;
349
350
  break;
350
- case 40:
351
- _context3.prev = 40;
352
- _context3.t2 = _context3["catch"](20);
351
+ case 41:
352
+ _context3.prev = 41;
353
+ _context3.t2 = _context3["catch"](21);
353
354
  console.warn('[PaymentModule] 无法缓存支付方式,pay_method 表不存在');
354
- case 43:
355
- _context3.next = 45;
355
+ case 44:
356
+ _context3.next = 46;
356
357
  return this.core.effects.emit("".concat(this.name, ":onPaymentMethodsLoaded"), payMethods);
357
- case 45:
358
+ case 46:
358
359
  this.logInfo('getPayMethodListAsync completed successfully', {
359
360
  methodCount: payMethods.length,
360
361
  hasCache: cachedMethods.length > 0
361
362
  });
362
363
  return _context3.abrupt("return", payMethods);
363
- case 49:
364
- _context3.prev = 49;
364
+ case 50:
365
+ _context3.prev = 50;
365
366
  _context3.t3 = _context3["catch"](1);
366
367
  console.error('[PaymentModule] 获取支付方式列表失败', _context3.t3);
367
368
  this.logError('getPayMethodListAsync failed', _context3.t3);
368
369
  // 如果所有操作都失败,返回空数组
369
370
  return _context3.abrupt("return", []);
370
- case 54:
371
+ case 55:
371
372
  case "end":
372
373
  return _context3.stop();
373
374
  }
374
- }, _callee3, this, [[1, 49], [3, 9], [20, 40], [22, 32, 35, 38]]);
375
+ }, _callee3, this, [[1, 50], [3, 9], [21, 41], [23, 33, 36, 39]]);
375
376
  }));
376
377
  function getPayMethodListAsync() {
377
378
  return _getPayMethodListAsync.apply(this, arguments);
@@ -398,15 +399,16 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
398
399
 
399
400
  // 从服务器获取最新数据
400
401
  _context4.next = 5;
401
- return this.request.get('/pay/custom-payment/available', {
402
- channel: 'pos'
403
- });
402
+ return this.request.get('/pay/custom-payment/all');
404
403
  case 5:
405
404
  response = _context4.sent;
405
+ response.data = response.data.filter(function (method) {
406
+ return method.status === 1 && method.disable === 0;
407
+ });
406
408
  newPayMethods = response.data || []; // 检查是否有变化
407
409
  hasChanges = this.hasPaymentMethodsChanged(cachedMethods, newPayMethods);
408
410
  if (!hasChanges) {
409
- _context4.next = 56;
411
+ _context4.next = 57;
410
412
  break;
411
413
  }
412
414
  console.log('[PaymentModule] 支付方式列表已更新');
@@ -416,92 +418,92 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
416
418
  });
417
419
 
418
420
  // 更新缓存
419
- _context4.prev = 11;
421
+ _context4.prev = 12;
420
422
  // 先清除旧数据
421
423
  _iterator2 = _createForOfIteratorHelper(cachedMethods);
422
- _context4.prev = 13;
424
+ _context4.prev = 14;
423
425
  _iterator2.s();
424
- case 15:
426
+ case 16:
425
427
  if ((_step2 = _iterator2.n()).done) {
426
- _context4.next = 21;
428
+ _context4.next = 22;
427
429
  break;
428
430
  }
429
431
  method = _step2.value;
430
- _context4.next = 19;
432
+ _context4.next = 20;
431
433
  return this.dbManager.delete('pay_method', method.id);
432
- case 19:
433
- _context4.next = 15;
434
+ case 20:
435
+ _context4.next = 16;
434
436
  break;
435
- case 21:
436
- _context4.next = 26;
437
+ case 22:
438
+ _context4.next = 27;
437
439
  break;
438
- case 23:
439
- _context4.prev = 23;
440
- _context4.t0 = _context4["catch"](13);
440
+ case 24:
441
+ _context4.prev = 24;
442
+ _context4.t0 = _context4["catch"](14);
441
443
  _iterator2.e(_context4.t0);
442
- case 26:
443
- _context4.prev = 26;
444
+ case 27:
445
+ _context4.prev = 27;
444
446
  _iterator2.f();
445
- return _context4.finish(26);
446
- case 29:
447
+ return _context4.finish(27);
448
+ case 30:
447
449
  // 添加新数据
448
450
  _iterator3 = _createForOfIteratorHelper(newPayMethods);
449
- _context4.prev = 30;
451
+ _context4.prev = 31;
450
452
  _iterator3.s();
451
- case 32:
453
+ case 33:
452
454
  if ((_step3 = _iterator3.n()).done) {
453
- _context4.next = 38;
455
+ _context4.next = 39;
454
456
  break;
455
457
  }
456
458
  _method = _step3.value;
457
- _context4.next = 36;
459
+ _context4.next = 37;
458
460
  return this.dbManager.update('pay_method', _method);
459
- case 36:
460
- _context4.next = 32;
461
+ case 37:
462
+ _context4.next = 33;
461
463
  break;
462
- case 38:
463
- _context4.next = 43;
464
+ case 39:
465
+ _context4.next = 44;
464
466
  break;
465
- case 40:
466
- _context4.prev = 40;
467
- _context4.t1 = _context4["catch"](30);
467
+ case 41:
468
+ _context4.prev = 41;
469
+ _context4.t1 = _context4["catch"](31);
468
470
  _iterator3.e(_context4.t1);
469
- case 43:
470
- _context4.prev = 43;
471
+ case 44:
472
+ _context4.prev = 44;
471
473
  _iterator3.f();
472
- return _context4.finish(43);
473
- case 46:
474
- _context4.next = 51;
474
+ return _context4.finish(44);
475
+ case 47:
476
+ _context4.next = 52;
475
477
  break;
476
- case 48:
477
- _context4.prev = 48;
478
- _context4.t2 = _context4["catch"](11);
478
+ case 49:
479
+ _context4.prev = 49;
480
+ _context4.t2 = _context4["catch"](12);
479
481
  console.warn('[PaymentModule] 无法更新支付方式缓存', _context4.t2);
480
- case 51:
482
+ case 52:
481
483
  // 通知外部支付方式已变化
482
484
  eventData = {
483
485
  oldMethods: cachedMethods,
484
486
  newMethods: newPayMethods
485
487
  };
486
- _context4.next = 54;
488
+ _context4.next = 55;
487
489
  return this.core.effects.emit("".concat(this.name, ":onPaymentMethodsChanged"), eventData);
488
- case 54:
489
- _context4.next = 57;
490
+ case 55:
491
+ _context4.next = 58;
490
492
  break;
491
- case 56:
492
- console.log('[PaymentModule] 支付方式列表无变化');
493
493
  case 57:
494
- _context4.next = 62;
494
+ console.log('[PaymentModule] 支付方式列表无变化');
495
+ case 58:
496
+ _context4.next = 63;
495
497
  break;
496
- case 59:
497
- _context4.prev = 59;
498
+ case 60:
499
+ _context4.prev = 60;
498
500
  _context4.t3 = _context4["catch"](1);
499
501
  console.error('[PaymentModule] 后台刷新支付方式失败', _context4.t3);
500
- case 62:
502
+ case 63:
501
503
  case "end":
502
504
  return _context4.stop();
503
505
  }
504
- }, _callee4, this, [[1, 59], [11, 48], [13, 23, 26, 29], [30, 40, 43, 46]]);
506
+ }, _callee4, this, [[1, 60], [12, 49], [14, 24, 27, 30], [31, 41, 44, 47]]);
505
507
  }));
506
508
  function refreshPaymentMethodsInBackground(_x4) {
507
509
  return _refreshPaymentMethodsInBackground.apply(this, arguments);
@@ -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 客户状态
@@ -1443,7 +1443,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1443
1443
  key: "addPaymentItemAsync",
1444
1444
  value: (function () {
1445
1445
  var _addPaymentItemAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(paymentItem) {
1446
- var orderPaymentType, processedPaymentItem, metadata, paymentItemWithType, remainingAmount, _paymentItem$type, _paymentItem$code, isEftposPayment, _isCashPayment, isCustomePayment, syncResult;
1446
+ var orderPaymentType, processedPaymentItem, metadata, paymentItemWithType, remainingAmount, _paymentItem$type, _paymentItem$code, isEftposPayment, isCash, isCustomePayment, syncResult;
1447
1447
  return _regeneratorRuntime().wrap(function _callee16$(_context16) {
1448
1448
  while (1) switch (_context16.prev = _context16.next) {
1449
1449
  case 0:
@@ -1493,7 +1493,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1493
1493
  this.logInfo('订单金额还有待付的,同步 EFTPOS 支付');
1494
1494
  // 检查是否是 EFTPOS 支付,如果是则立即同步订单
1495
1495
  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'));
1496
- _isCashPayment = paymentItem.code === 'CASHMANUAL';
1496
+ isCash = isCashPayment(paymentItem);
1497
1497
  isCustomePayment = paymentItem.type === 'custom';
1498
1498
  this.logInfo('EFTPOS 支付检查:', {
1499
1499
  paymentCode: paymentItem.code,
@@ -1501,7 +1501,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1501
1501
  isEftposPayment: isEftposPayment,
1502
1502
  currentOrderSynced: this.store.isOrderSynced
1503
1503
  });
1504
- if (!(isEftposPayment || _isCashPayment || isCustomePayment)) {
1504
+ if (!(isEftposPayment || isCash || isCustomePayment)) {
1505
1505
  _context16.next = 39;
1506
1506
  break;
1507
1507
  }
@@ -2614,7 +2614,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2614
2614
  while (1) switch (_context28.prev = _context28.next) {
2615
2615
  case 0:
2616
2616
  // 检查是否是现金支付
2617
- cashPayment = isCashPayment(paymentItem.code, paymentItem.type);
2617
+ cashPayment = isCashPayment(paymentItem);
2618
2618
  if (cashPayment) {
2619
2619
  _context28.next = 3;
2620
2620
  break;
@@ -1,5 +1,6 @@
1
1
  import { CheckoutInitParams, CheckoutError, CheckoutErrorType, LocalOrderData, CartSummaryItem, ExtractedAmountInfo } from '../types';
2
2
  import { CartItem } from '../../../modules/Cart/types';
3
+ import { PaymentItemInput } from '../../../modules/Payment/types';
3
4
  /**
4
5
  * 验证结账数据
5
6
  */
@@ -118,4 +119,4 @@ export declare function shouldSyncOrderForPayment(paymentCode: string, paymentTy
118
119
  * @param paymentType 支付方式类型
119
120
  * @returns 是否为现金支付
120
121
  */
121
- export declare function isCashPayment(paymentCode?: string, paymentType?: string): boolean;
122
+ export declare function isCashPayment(paymentItem: PaymentItemInput): boolean;
@@ -499,13 +499,15 @@ export function shouldSyncOrderForPayment(paymentCode, paymentType) {
499
499
  * @param paymentType 支付方式类型
500
500
  * @returns 是否为现金支付
501
501
  */
502
- export function isCashPayment(paymentCode, paymentType) {
503
- var codeUpper = (paymentCode === null || paymentCode === void 0 ? void 0 : paymentCode.toUpperCase()) || '';
504
- var typeUpper = (paymentType === null || paymentType === void 0 ? void 0 : paymentType.toUpperCase()) || '';
502
+ export function isCashPayment(paymentItem) {
503
+ var _paymentItem$code, _paymentItem$type, _paymentItem$name;
504
+ var codeUpper = ((_paymentItem$code = paymentItem.code) === null || _paymentItem$code === void 0 ? void 0 : _paymentItem$code.toUpperCase()) || '';
505
+ var typeUpper = ((_paymentItem$type = paymentItem.type) === null || _paymentItem$type === void 0 ? void 0 : _paymentItem$type.toUpperCase()) || '';
506
+ var isNameCash = (_paymentItem$name = paymentItem.name) === null || _paymentItem$name === void 0 ? void 0 : _paymentItem$name.toLowerCase().includes('cash');
505
507
 
506
508
  // 现金支付识别规则
507
509
  var cashIdentifiers = ['CASH', 'CASHMANUAL', 'MANUAL'];
508
510
  return cashIdentifiers.some(function (identifier) {
509
511
  return codeUpper.includes(identifier) || typeUpper.includes(identifier);
510
- });
512
+ }) || isNameCash;
511
513
  }
@@ -192,7 +192,8 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
192
192
  this.refreshPaymentMethodsInBackground(cachedMethods);
193
193
  return cachedMethods;
194
194
  }
195
- const response = await this.request.get("/pay/custom-payment/available", { channel: "pos" });
195
+ const response = await this.request.get("/pay/custom-payment/all");
196
+ response.data = response.data.filter((method) => method.status === 1 && method.disable === 0);
196
197
  const payMethods = response.data || [];
197
198
  try {
198
199
  for (const method of payMethods) {
@@ -225,7 +226,8 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
225
226
  });
226
227
  try {
227
228
  console.log("[PaymentModule] 后台刷新支付方式列表...");
228
- const response = await this.request.get("/pay/custom-payment/available", { channel: "pos" });
229
+ const response = await this.request.get("/pay/custom-payment/all");
230
+ response.data = response.data.filter((method) => method.status === 1 && method.disable === 0);
229
231
  const newPayMethods = response.data || [];
230
232
  const hasChanges = this.hasPaymentMethodsChanged(
231
233
  cachedMethods,
@@ -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 客户状态
@@ -981,7 +981,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
981
981
  if (Number(remainingAmount) > 0) {
982
982
  this.logInfo("订单金额还有待付的,同步 EFTPOS 支付");
983
983
  const isEftposPayment = ((_a = paymentItem.type) == null ? void 0 : _a.toLowerCase()) === "eftpos" || ((_b = paymentItem.code) == null ? void 0 : _b.toUpperCase().includes("EFTPOS"));
984
- const isCashPayment2 = paymentItem.code === "CASHMANUAL";
984
+ const isCash = (0, import_utils.isCashPayment)(paymentItem);
985
985
  const isCustomePayment = paymentItem.type === "custom";
986
986
  this.logInfo("EFTPOS 支付检查:", {
987
987
  paymentCode: paymentItem.code,
@@ -989,7 +989,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
989
989
  isEftposPayment,
990
990
  currentOrderSynced: this.store.isOrderSynced
991
991
  });
992
- if (isEftposPayment || isCashPayment2 || isCustomePayment) {
992
+ if (isEftposPayment || isCash || isCustomePayment) {
993
993
  this.logInfo("检测到 EFTPOS 支付,立即同步订单到后端...");
994
994
  try {
995
995
  const syncResult = await this.syncOrderToBackendWithReturn(true);
@@ -1718,7 +1718,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
1718
1718
  * @returns 处理后的支付项(包含找零信息)
1719
1719
  */
1720
1720
  async processCashPaymentItem(paymentItem) {
1721
- const cashPayment = (0, import_utils.isCashPayment)(paymentItem.code, paymentItem.type);
1721
+ const cashPayment = (0, import_utils.isCashPayment)(paymentItem);
1722
1722
  if (!cashPayment) {
1723
1723
  return paymentItem;
1724
1724
  }
@@ -1,5 +1,6 @@
1
1
  import { CheckoutInitParams, CheckoutError, CheckoutErrorType, LocalOrderData, CartSummaryItem, ExtractedAmountInfo } from '../types';
2
2
  import { CartItem } from '../../../modules/Cart/types';
3
+ import { PaymentItemInput } from '../../../modules/Payment/types';
3
4
  /**
4
5
  * 验证结账数据
5
6
  */
@@ -118,4 +119,4 @@ export declare function shouldSyncOrderForPayment(paymentCode: string, paymentTy
118
119
  * @param paymentType 支付方式类型
119
120
  * @returns 是否为现金支付
120
121
  */
121
- export declare function isCashPayment(paymentCode?: string, paymentType?: string): boolean;
122
+ export declare function isCashPayment(paymentItem: PaymentItemInput): boolean;
@@ -326,13 +326,15 @@ function shouldSyncOrderForPayment(paymentCode, paymentType) {
326
326
  }
327
327
  return true;
328
328
  }
329
- function isCashPayment(paymentCode, paymentType) {
330
- const codeUpper = (paymentCode == null ? void 0 : paymentCode.toUpperCase()) || "";
331
- const typeUpper = (paymentType == null ? void 0 : paymentType.toUpperCase()) || "";
329
+ function isCashPayment(paymentItem) {
330
+ var _a, _b, _c;
331
+ const codeUpper = ((_a = paymentItem.code) == null ? void 0 : _a.toUpperCase()) || "";
332
+ const typeUpper = ((_b = paymentItem.type) == null ? void 0 : _b.toUpperCase()) || "";
333
+ const isNameCash = (_c = paymentItem.name) == null ? void 0 : _c.toLowerCase().includes("cash");
332
334
  const cashIdentifiers = ["CASH", "CASHMANUAL", "MANUAL"];
333
335
  return cashIdentifiers.some(
334
336
  (identifier) => codeUpper.includes(identifier) || typeUpper.includes(identifier)
335
- );
337
+ ) || isNameCash;
336
338
  }
337
339
  // Annotate the CommonJS export names for ESM import in node:
338
340
  0 && (module.exports = {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.2.12",
4
+ "version": "2.2.14",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",