@pisell/pisellos 2.2.107 → 2.2.109

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.
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
49
49
  getCategories(): ProductCategory[];
50
50
  setOtherParams(key: string, value: any): void;
51
51
  getOtherParams(): any;
52
- getProductType(): "normal" | "duration" | "session";
52
+ getProductType(): "duration" | "session" | "normal";
53
53
  }
@@ -34,6 +34,7 @@ export declare class ProductList extends BaseModule implements Module {
34
34
  }): Promise<any>;
35
35
  getProducts(): Promise<ProductData[]>;
36
36
  getProduct(id: number): Promise<ProductData | undefined>;
37
+ getProductByIds(ids: number[]): Promise<ProductData[] | undefined>;
37
38
  addProduct(products: ProductData[]): Promise<void>;
38
39
  selectProducts(products: ProductData[]): Promise<void>;
39
40
  /**
@@ -243,12 +243,38 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
243
243
  return getProduct;
244
244
  }()
245
245
  }, {
246
- key: "addProduct",
246
+ key: "getProductByIds",
247
247
  value: function () {
248
- var _addProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(products) {
249
- var _this2 = this;
248
+ var _getProductByIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(ids) {
249
+ var products;
250
250
  return _regeneratorRuntime().wrap(function _callee7$(_context7) {
251
251
  while (1) switch (_context7.prev = _context7.next) {
252
+ case 0:
253
+ _context7.next = 2;
254
+ return this.core.effects.emit("".concat(this.name, ":onGetProductByIds"), this.store.list);
255
+ case 2:
256
+ products = this.store.list.filter(function (product) {
257
+ return ids.includes(product.id);
258
+ });
259
+ return _context7.abrupt("return", products);
260
+ case 4:
261
+ case "end":
262
+ return _context7.stop();
263
+ }
264
+ }, _callee7, this);
265
+ }));
266
+ function getProductByIds(_x9) {
267
+ return _getProductByIds.apply(this, arguments);
268
+ }
269
+ return getProductByIds;
270
+ }()
271
+ }, {
272
+ key: "addProduct",
273
+ value: function () {
274
+ var _addProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(products) {
275
+ var _this2 = this;
276
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
277
+ while (1) switch (_context8.prev = _context8.next) {
252
278
  case 0:
253
279
  // list 需要根据 id 去重
254
280
  if (!this.store.list) {
@@ -271,11 +297,11 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
271
297
  this.core.effects.emit("".concat(this.name, ":changed"), this.store.list);
272
298
  case 4:
273
299
  case "end":
274
- return _context7.stop();
300
+ return _context8.stop();
275
301
  }
276
- }, _callee7, this);
302
+ }, _callee8, this);
277
303
  }));
278
- function addProduct(_x9) {
304
+ function addProduct(_x10) {
279
305
  return _addProduct.apply(this, arguments);
280
306
  }
281
307
  return addProduct;
@@ -283,18 +309,18 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
283
309
  }, {
284
310
  key: "selectProducts",
285
311
  value: function () {
286
- var _selectProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(products) {
287
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
288
- while (1) switch (_context8.prev = _context8.next) {
312
+ var _selectProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(products) {
313
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
314
+ while (1) switch (_context9.prev = _context9.next) {
289
315
  case 0:
290
316
  this.store.selectProducts = products;
291
317
  case 1:
292
318
  case "end":
293
- return _context8.stop();
319
+ return _context9.stop();
294
320
  }
295
- }, _callee8, this);
321
+ }, _callee9, this);
296
322
  }));
297
- function selectProducts(_x10) {
323
+ function selectProducts(_x11) {
298
324
  return _selectProducts.apply(this, arguments);
299
325
  }
300
326
  return selectProducts;
@@ -39,6 +39,11 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
39
39
  * @returns 商品列表
40
40
  */
41
41
  getProducts(): Promise<ProductData[]>;
42
+ /**
43
+ * 通过 ids 获取商品列表(不加载到模块中)
44
+ * @returns 商品列表
45
+ */
46
+ getProductByIds(ids: number[]): Promise<ProductData[] | undefined>;
42
47
  /**
43
48
  * 获取日程时间段点
44
49
  * @param params 参数
@@ -216,6 +216,30 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseModule) {
216
216
  }
217
217
  return getProducts;
218
218
  }()
219
+ /**
220
+ * 通过 ids 获取商品列表(不加载到模块中)
221
+ * @returns 商品列表
222
+ */
223
+ )
224
+ }, {
225
+ key: "getProductByIds",
226
+ value: (function () {
227
+ var _getProductByIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(ids) {
228
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
229
+ while (1) switch (_context4.prev = _context4.next) {
230
+ case 0:
231
+ return _context4.abrupt("return", this.store.products.getProductByIds(ids));
232
+ case 1:
233
+ case "end":
234
+ return _context4.stop();
235
+ }
236
+ }, _callee4, this);
237
+ }));
238
+ function getProductByIds(_x3) {
239
+ return _getProductByIds.apply(this, arguments);
240
+ }
241
+ return getProductByIds;
242
+ }()
219
243
  /**
220
244
  * 获取日程时间段点
221
245
  * @param params 参数
@@ -225,27 +249,27 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseModule) {
225
249
  }, {
226
250
  key: "getScheduleTimePoints",
227
251
  value: (function () {
228
- var _getScheduleTimePoints = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(params) {
252
+ var _getScheduleTimePoints = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(params) {
229
253
  var result;
230
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
231
- while (1) switch (_context4.prev = _context4.next) {
254
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
255
+ while (1) switch (_context5.prev = _context5.next) {
232
256
  case 0:
233
- _context4.next = 2;
257
+ _context5.next = 2;
234
258
  return this.request.post('/menu/schedule-time-points', {
235
259
  menu_list_ids: params.menu_list_ids
236
260
  }, {
237
261
  osServer: true
238
262
  });
239
263
  case 2:
240
- result = _context4.sent;
241
- return _context4.abrupt("return", result.data || []);
264
+ result = _context5.sent;
265
+ return _context5.abrupt("return", result.data || []);
242
266
  case 4:
243
267
  case "end":
244
- return _context4.stop();
268
+ return _context5.stop();
245
269
  }
246
- }, _callee4, this);
270
+ }, _callee5, this);
247
271
  }));
248
- function getScheduleTimePoints(_x3) {
272
+ function getScheduleTimePoints(_x4) {
249
273
  return _getScheduleTimePoints.apply(this, arguments);
250
274
  }
251
275
  return getScheduleTimePoints;
@@ -259,30 +283,30 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseModule) {
259
283
  }, {
260
284
  key: "getCustomerList",
261
285
  value: (function () {
262
- var _getCustomerList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
286
+ var _getCustomerList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
263
287
  var params,
264
288
  _result2,
265
- _args5 = arguments;
266
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
267
- while (1) switch (_context5.prev = _context5.next) {
289
+ _args6 = arguments;
290
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
291
+ while (1) switch (_context6.prev = _context6.next) {
268
292
  case 0:
269
- params = _args5.length > 0 && _args5[0] !== undefined ? _args5[0] : {};
270
- _context5.prev = 1;
271
- _context5.next = 4;
293
+ params = _args6.length > 0 && _args6[0] !== undefined ? _args6[0] : {};
294
+ _context6.prev = 1;
295
+ _context6.next = 4;
272
296
  return this.store.customer.getCustomerList(params);
273
297
  case 4:
274
- _result2 = _context5.sent;
275
- return _context5.abrupt("return", _result2);
298
+ _result2 = _context6.sent;
299
+ return _context6.abrupt("return", _result2);
276
300
  case 8:
277
- _context5.prev = 8;
278
- _context5.t0 = _context5["catch"](1);
279
- console.error('Failed to get customer list:', _context5.t0);
280
- throw _context5.t0;
301
+ _context6.prev = 8;
302
+ _context6.t0 = _context6["catch"](1);
303
+ console.error('Failed to get customer list:', _context6.t0);
304
+ throw _context6.t0;
281
305
  case 12:
282
306
  case "end":
283
- return _context5.stop();
307
+ return _context6.stop();
284
308
  }
285
- }, _callee5, this, [[1, 8]]);
309
+ }, _callee6, this, [[1, 8]]);
286
310
  }));
287
311
  function getCustomerList() {
288
312
  return _getCustomerList.apply(this, arguments);
@@ -409,29 +433,29 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseModule) {
409
433
  }, {
410
434
  key: "changeCustomerPage",
411
435
  value: (function () {
412
- var _changeCustomerPage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(page, pageSize) {
436
+ var _changeCustomerPage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(page, pageSize) {
413
437
  var _result3;
414
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
415
- while (1) switch (_context6.prev = _context6.next) {
438
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
439
+ while (1) switch (_context7.prev = _context7.next) {
416
440
  case 0:
417
- _context6.prev = 0;
418
- _context6.next = 3;
441
+ _context7.prev = 0;
442
+ _context7.next = 3;
419
443
  return this.store.customer.changeCustomerPage(page, pageSize);
420
444
  case 3:
421
- _result3 = _context6.sent;
422
- return _context6.abrupt("return", _result3);
445
+ _result3 = _context7.sent;
446
+ return _context7.abrupt("return", _result3);
423
447
  case 7:
424
- _context6.prev = 7;
425
- _context6.t0 = _context6["catch"](0);
426
- console.error('Failed to change customer page:', _context6.t0);
427
- throw _context6.t0;
448
+ _context7.prev = 7;
449
+ _context7.t0 = _context7["catch"](0);
450
+ console.error('Failed to change customer page:', _context7.t0);
451
+ throw _context7.t0;
428
452
  case 11:
429
453
  case "end":
430
- return _context6.stop();
454
+ return _context7.stop();
431
455
  }
432
- }, _callee6, this, [[0, 7]]);
456
+ }, _callee7, this, [[0, 7]]);
433
457
  }));
434
- function changeCustomerPage(_x4, _x5) {
458
+ function changeCustomerPage(_x5, _x6) {
435
459
  return _changeCustomerPage.apply(this, arguments);
436
460
  }
437
461
  return changeCustomerPage;
@@ -444,28 +468,28 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseModule) {
444
468
  }, {
445
469
  key: "loadMoreCustomers",
446
470
  value: (function () {
447
- var _loadMoreCustomers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
471
+ var _loadMoreCustomers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
448
472
  var _result4;
449
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
450
- while (1) switch (_context7.prev = _context7.next) {
473
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
474
+ while (1) switch (_context8.prev = _context8.next) {
451
475
  case 0:
452
- _context7.prev = 0;
453
- _context7.next = 3;
476
+ _context8.prev = 0;
477
+ _context8.next = 3;
454
478
  return this.store.customer.loadMoreCustomers();
455
479
  case 3:
456
- _result4 = _context7.sent;
480
+ _result4 = _context8.sent;
457
481
  this.core.effects.emit("".concat(this.name, ":onCustomerListUpdate"), _result4);
458
- return _context7.abrupt("return", _result4);
482
+ return _context8.abrupt("return", _result4);
459
483
  case 8:
460
- _context7.prev = 8;
461
- _context7.t0 = _context7["catch"](0);
462
- console.error('Failed to load more customers:', _context7.t0);
463
- throw _context7.t0;
484
+ _context8.prev = 8;
485
+ _context8.t0 = _context8["catch"](0);
486
+ console.error('Failed to load more customers:', _context8.t0);
487
+ throw _context8.t0;
464
488
  case 12:
465
489
  case "end":
466
- return _context7.stop();
490
+ return _context8.stop();
467
491
  }
468
- }, _callee7, this, [[0, 8]]);
492
+ }, _callee8, this, [[0, 8]]);
469
493
  }));
470
494
  function loadMoreCustomers() {
471
495
  return _loadMoreCustomers.apply(this, arguments);
@@ -481,31 +505,31 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseModule) {
481
505
  }, {
482
506
  key: "resetAndLoadCustomers",
483
507
  value: (function () {
484
- var _resetAndLoadCustomers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
508
+ var _resetAndLoadCustomers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
485
509
  var params,
486
510
  _result5,
487
- _args8 = arguments;
488
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
489
- while (1) switch (_context8.prev = _context8.next) {
511
+ _args9 = arguments;
512
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
513
+ while (1) switch (_context9.prev = _context9.next) {
490
514
  case 0:
491
- params = _args8.length > 0 && _args8[0] !== undefined ? _args8[0] : {};
492
- _context8.prev = 1;
493
- _context8.next = 4;
515
+ params = _args9.length > 0 && _args9[0] !== undefined ? _args9[0] : {};
516
+ _context9.prev = 1;
517
+ _context9.next = 4;
494
518
  return this.store.customer.resetAndLoadCustomers(params);
495
519
  case 4:
496
- _result5 = _context8.sent;
520
+ _result5 = _context9.sent;
497
521
  this.core.effects.emit("".concat(this.name, ":onCustomerListReset"), _result5);
498
- return _context8.abrupt("return", _result5);
522
+ return _context9.abrupt("return", _result5);
499
523
  case 9:
500
- _context8.prev = 9;
501
- _context8.t0 = _context8["catch"](1);
502
- console.error('Failed to reset and load customers:', _context8.t0);
503
- throw _context8.t0;
524
+ _context9.prev = 9;
525
+ _context9.t0 = _context9["catch"](1);
526
+ console.error('Failed to reset and load customers:', _context9.t0);
527
+ throw _context9.t0;
504
528
  case 13:
505
529
  case "end":
506
- return _context8.stop();
530
+ return _context9.stop();
507
531
  }
508
- }, _callee8, this, [[1, 9]]);
532
+ }, _callee9, this, [[1, 9]]);
509
533
  }));
510
534
  function resetAndLoadCustomers() {
511
535
  return _resetAndLoadCustomers.apply(this, arguments);
@@ -667,15 +691,15 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseModule) {
667
691
  }, {
668
692
  key: "setOtherParams",
669
693
  value: (function () {
670
- var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(params) {
694
+ var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(params) {
671
695
  var _ref,
672
696
  _ref$cover,
673
697
  cover,
674
- _args9 = arguments;
675
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
676
- while (1) switch (_context9.prev = _context9.next) {
698
+ _args10 = arguments;
699
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
700
+ while (1) switch (_context10.prev = _context10.next) {
677
701
  case 0:
678
- _ref = _args9.length > 1 && _args9[1] !== undefined ? _args9[1] : {}, _ref$cover = _ref.cover, cover = _ref$cover === void 0 ? false : _ref$cover;
702
+ _ref = _args10.length > 1 && _args10[1] !== undefined ? _args10[1] : {}, _ref$cover = _ref.cover, cover = _ref$cover === void 0 ? false : _ref$cover;
679
703
  if (cover) {
680
704
  this.otherParams = params;
681
705
  } else {
@@ -683,11 +707,11 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseModule) {
683
707
  }
684
708
  case 2:
685
709
  case "end":
686
- return _context9.stop();
710
+ return _context10.stop();
687
711
  }
688
- }, _callee9, this);
712
+ }, _callee10, this);
689
713
  }));
690
- function setOtherParams(_x6) {
714
+ function setOtherParams(_x7) {
691
715
  return _setOtherParams.apply(this, arguments);
692
716
  }
693
717
  return setOtherParams;
@@ -700,16 +724,16 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseModule) {
700
724
  }, {
701
725
  key: "getOtherParams",
702
726
  value: (function () {
703
- var _getOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
704
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
705
- while (1) switch (_context10.prev = _context10.next) {
727
+ var _getOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
728
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
729
+ while (1) switch (_context11.prev = _context11.next) {
706
730
  case 0:
707
- return _context10.abrupt("return", this.otherParams);
731
+ return _context11.abrupt("return", this.otherParams);
708
732
  case 1:
709
733
  case "end":
710
- return _context10.stop();
734
+ return _context11.stop();
711
735
  }
712
- }, _callee10, this);
736
+ }, _callee11, this);
713
737
  }));
714
738
  function getOtherParams() {
715
739
  return _getOtherParams.apply(this, arguments);
@@ -2748,7 +2748,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2748
2748
  key: "processCashPaymentItem",
2749
2749
  value: (function () {
2750
2750
  var _processCashPaymentItem = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(paymentItem) {
2751
- var cashPayment, remainingAmountStr, remainingAmount, cashAmount, changeAmount, processedPaymentItem;
2751
+ var cashPayment, remainingAmountStr, remainingAmount, cashAmount, roundingAmount, chargeAmount, changeAmount, processedPaymentItem;
2752
2752
  return _regeneratorRuntime().wrap(function _callee28$(_context28) {
2753
2753
  while (1) switch (_context28.prev = _context28.next) {
2754
2754
  case 0:
@@ -2766,41 +2766,35 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2766
2766
  case 6:
2767
2767
  remainingAmountStr = _context28.sent;
2768
2768
  remainingAmount = new Decimal(remainingAmountStr);
2769
- cashAmount = new Decimal(String(paymentItem.amount)); // 如果现金金额小于等于剩余待付金额,无需找零
2769
+ cashAmount = new Decimal(String(paymentItem.amount));
2770
+ roundingAmount = new Decimal(String(paymentItem.rounding_amount || '0')); // 如果现金金额小于等于剩余待付金额,无需找零
2770
2771
  if (!cashAmount.lte(remainingAmount)) {
2771
- _context28.next = 11;
2772
+ _context28.next = 12;
2772
2773
  break;
2773
2774
  }
2774
2775
  return _context28.abrupt("return", paymentItem);
2775
- case 11:
2776
- // 使用 Decimal.js 安全计算找零金额
2777
- changeAmount = cashAmount.sub(remainingAmount); // 如果还有 rounding_amount 的配置,要判断是否和 changeAmount 相等
2778
- if (!(Number(paymentItem.rounding_amount) > 0)) {
2779
- _context28.next = 18;
2780
- break;
2781
- }
2782
- if (!(Number(paymentItem.rounding_amount) === changeAmount.toNumber())) {
2783
- _context28.next = 17;
2776
+ case 12:
2777
+ // 超付场景使用 rounding 回算应收金额(兼容 UI 已做抹零 + 允许超付)
2778
+ chargeAmount = Decimal.max(remainingAmount.add(roundingAmount), new Decimal(0));
2779
+ if (!cashAmount.lte(chargeAmount)) {
2780
+ _context28.next = 15;
2784
2781
  break;
2785
2782
  }
2786
2783
  return _context28.abrupt("return", paymentItem);
2787
- case 17:
2788
- // 如果不等于,则remainingAmount需要加上 rounding_amount,避免这里被改为未舍入金额
2789
- remainingAmount = remainingAmount.add(new Decimal(paymentItem.rounding_amount || '0'));
2790
- case 18:
2791
- // 创建包含找零信息的支付项
2784
+ case 15:
2785
+ changeAmount = cashAmount.sub(chargeAmount); // 创建包含找零信息的支付项
2792
2786
  processedPaymentItem = _objectSpread(_objectSpread({}, paymentItem), {}, {
2793
- amount: remainingAmount.toFixed(2),
2794
- // 将 amount 设置为剩余待付金额,保留2位小数
2787
+ amount: chargeAmount.toFixed(2),
2795
2788
  metadata: _objectSpread(_objectSpread({}, paymentItem.metadata), {}, {
2796
2789
  actual_paid_amount: cashAmount.toNumber(),
2797
- // 实付金额
2798
- change_given_amount: changeAmount.toNumber() // 找零金额
2790
+ change_given_amount: changeAmount.toNumber()
2799
2791
  })
2800
2792
  });
2801
2793
  this.logInfo('Cash payment with change processed', {
2802
2794
  originalAmount: cashAmount.toFixed(2),
2803
- chargedAmount: remainingAmount.toFixed(2),
2795
+ remainingAmount: remainingAmount.toFixed(2),
2796
+ roundingAmount: roundingAmount.toFixed(2),
2797
+ chargedAmount: chargeAmount.toFixed(2),
2804
2798
  changeAmount: changeAmount.toFixed(2),
2805
2799
  paymentCode: paymentItem.code,
2806
2800
  paymentType: paymentItem.type,
@@ -2808,21 +2802,23 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2808
2802
  decimalPrecisionCheck: {
2809
2803
  cashAmountPrecise: cashAmount.toString(),
2810
2804
  remainingAmountPrecise: remainingAmount.toString(),
2805
+ roundingAmountPrecise: roundingAmount.toString(),
2806
+ chargeAmountPrecise: chargeAmount.toString(),
2811
2807
  changeAmountPrecise: changeAmount.toString()
2812
2808
  }
2813
2809
  });
2814
2810
  return _context28.abrupt("return", processedPaymentItem);
2815
- case 23:
2816
- _context28.prev = 23;
2811
+ case 21:
2812
+ _context28.prev = 21;
2817
2813
  _context28.t0 = _context28["catch"](3);
2818
2814
  this.logError('处理现金支付项时出错:', _context28.t0);
2819
2815
  // 出错时返回原始支付项,避免中断支付流程
2820
2816
  return _context28.abrupt("return", paymentItem);
2821
- case 27:
2817
+ case 25:
2822
2818
  case "end":
2823
2819
  return _context28.stop();
2824
2820
  }
2825
- }, _callee28, this, [[3, 23]]);
2821
+ }, _callee28, this, [[3, 21]]);
2826
2822
  }));
2827
2823
  function processCashPaymentItem(_x27) {
2828
2824
  return _processCashPaymentItem.apply(this, arguments);
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
49
49
  getCategories(): ProductCategory[];
50
50
  setOtherParams(key: string, value: any): void;
51
51
  getOtherParams(): any;
52
- getProductType(): "normal" | "duration" | "session";
52
+ getProductType(): "duration" | "session" | "normal";
53
53
  }
@@ -34,6 +34,7 @@ export declare class ProductList extends BaseModule implements Module {
34
34
  }): Promise<any>;
35
35
  getProducts(): Promise<ProductData[]>;
36
36
  getProduct(id: number): Promise<ProductData | undefined>;
37
+ getProductByIds(ids: number[]): Promise<ProductData[] | undefined>;
37
38
  addProduct(products: ProductData[]): Promise<void>;
38
39
  selectProducts(products: ProductData[]): Promise<void>;
39
40
  /**
@@ -139,6 +139,14 @@ var ProductList = class extends import_BaseModule.BaseModule {
139
139
  const product = this.store.list.find((product2) => product2.id === id);
140
140
  return product ? (0, import_lodash_es.cloneDeep)(product) : void 0;
141
141
  }
142
+ async getProductByIds(ids) {
143
+ await this.core.effects.emit(
144
+ `${this.name}:onGetProductByIds`,
145
+ this.store.list
146
+ );
147
+ const products = this.store.list.filter((product) => ids.includes(product.id));
148
+ return products;
149
+ }
142
150
  async addProduct(products) {
143
151
  if (!this.store.list) {
144
152
  this.store.list = [];
@@ -39,6 +39,11 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
39
39
  * @returns 商品列表
40
40
  */
41
41
  getProducts(): Promise<ProductData[]>;
42
+ /**
43
+ * 通过 ids 获取商品列表(不加载到模块中)
44
+ * @returns 商品列表
45
+ */
46
+ getProductByIds(ids: number[]): Promise<ProductData[] | undefined>;
42
47
  /**
43
48
  * 获取日程时间段点
44
49
  * @param params 参数
@@ -143,6 +143,13 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
143
143
  async getProducts() {
144
144
  return this.store.products.getProducts();
145
145
  }
146
+ /**
147
+ * 通过 ids 获取商品列表(不加载到模块中)
148
+ * @returns 商品列表
149
+ */
150
+ async getProductByIds(ids) {
151
+ return this.store.products.getProductByIds(ids);
152
+ }
146
153
  /**
147
154
  * 获取日程时间段点
148
155
  * @param params 参数
@@ -1835,36 +1835,34 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
1835
1835
  }
1836
1836
  try {
1837
1837
  const remainingAmountStr = await this.calculateRemainingAmountAsync();
1838
- let remainingAmount = new import_decimal.default(remainingAmountStr);
1838
+ const remainingAmount = new import_decimal.default(remainingAmountStr);
1839
1839
  const cashAmount = new import_decimal.default(String(paymentItem.amount));
1840
+ const roundingAmount = new import_decimal.default(String(paymentItem.rounding_amount || "0"));
1840
1841
  if (cashAmount.lte(remainingAmount)) {
1841
1842
  return paymentItem;
1842
1843
  }
1843
- const changeAmount = cashAmount.sub(remainingAmount);
1844
- if (Number(paymentItem.rounding_amount) > 0) {
1845
- if (Number(paymentItem.rounding_amount) === changeAmount.toNumber()) {
1846
- return paymentItem;
1847
- } else {
1848
- remainingAmount = remainingAmount.add(
1849
- new import_decimal.default(paymentItem.rounding_amount || "0")
1850
- );
1851
- }
1844
+ const chargeAmount = import_decimal.default.max(
1845
+ remainingAmount.add(roundingAmount),
1846
+ new import_decimal.default(0)
1847
+ );
1848
+ if (cashAmount.lte(chargeAmount)) {
1849
+ return paymentItem;
1852
1850
  }
1851
+ const changeAmount = cashAmount.sub(chargeAmount);
1853
1852
  const processedPaymentItem = {
1854
1853
  ...paymentItem,
1855
- amount: remainingAmount.toFixed(2),
1856
- // 将 amount 设置为剩余待付金额,保留2位小数
1854
+ amount: chargeAmount.toFixed(2),
1857
1855
  metadata: {
1858
1856
  ...paymentItem.metadata,
1859
1857
  actual_paid_amount: cashAmount.toNumber(),
1860
- // 实付金额
1861
1858
  change_given_amount: changeAmount.toNumber()
1862
- // 找零金额
1863
1859
  }
1864
1860
  };
1865
1861
  this.logInfo("Cash payment with change processed", {
1866
1862
  originalAmount: cashAmount.toFixed(2),
1867
- chargedAmount: remainingAmount.toFixed(2),
1863
+ remainingAmount: remainingAmount.toFixed(2),
1864
+ roundingAmount: roundingAmount.toFixed(2),
1865
+ chargedAmount: chargeAmount.toFixed(2),
1868
1866
  changeAmount: changeAmount.toFixed(2),
1869
1867
  paymentCode: paymentItem.code,
1870
1868
  paymentType: paymentItem.type,
@@ -1872,6 +1870,8 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
1872
1870
  decimalPrecisionCheck: {
1873
1871
  cashAmountPrecise: cashAmount.toString(),
1874
1872
  remainingAmountPrecise: remainingAmount.toString(),
1873
+ roundingAmountPrecise: roundingAmount.toString(),
1874
+ chargeAmountPrecise: chargeAmount.toString(),
1875
1875
  changeAmountPrecise: changeAmount.toString()
1876
1876
  }
1877
1877
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.2.107",
4
+ "version": "2.2.109",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",