@pisell/pisellos 0.0.348 → 0.0.350

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.
@@ -1054,7 +1054,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1054
1054
  key: "addPaymentItemAsync",
1055
1055
  value: (function () {
1056
1056
  var _addPaymentItemAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(orderUuid, paymentItem) {
1057
- var _newPaymentItem$metad, _newPaymentItem$metad2, _newPaymentItem$metad3, order, expectAmount, paidDepositAmount, expectedDepositAmount, warningMessage, paymentUuid, newPaymentItem;
1057
+ var _paymentItem$metadata, _newPaymentItem$metad, _newPaymentItem$metad2, _newPaymentItem$metad3, order, expectAmount, paidDepositAmount, expectedDepositAmount, warningMessage, paymentUuid, newPaymentItem;
1058
1058
  return _regeneratorRuntime().wrap(function _callee13$(_context13) {
1059
1059
  while (1) switch (_context13.prev = _context13.next) {
1060
1060
  case 0:
@@ -1103,7 +1103,11 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1103
1103
  });
1104
1104
  throw new Error(warningMessage);
1105
1105
  case 15:
1106
- paymentUuid = getUniqueId('payment_');
1106
+ if ((_paymentItem$metadata = paymentItem.metadata) !== null && _paymentItem$metadata !== void 0 && _paymentItem$metadata.unique_payment_number) {
1107
+ paymentUuid = paymentItem.metadata.unique_payment_number;
1108
+ } else {
1109
+ paymentUuid = getUniqueId('payment_');
1110
+ }
1107
1111
  newPaymentItem = {
1108
1112
  uuid: paymentUuid,
1109
1113
  id: paymentItem.id || 0,
@@ -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
  }
@@ -404,7 +404,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
404
404
  key: "scanCode",
405
405
  value: function () {
406
406
  var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(code, customerId) {
407
- var _this$store$discount3, resultDiscountList, rulesModule, withScanList, _ref2, newProductList, newDiscountList, isAvailable, _this$options$otherPa6;
407
+ var _this$store$discount3, resultDiscountList, rulesModule, withScanList, currentSelectedDiscountList, _ref2, newProductList, newDiscountList, isAvailable, _this$options$otherPa6;
408
408
  return _regeneratorRuntime().wrap(function _callee7$(_context7) {
409
409
  while (1) switch (_context7.prev = _context7.next) {
410
410
  case 0:
@@ -447,7 +447,25 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
447
447
  return _objectSpread(_objectSpread({}, item), {}, {
448
448
  isScan: true
449
449
  });
450
+ }); // 如果扫回来的券当前有选中的,则不进行计算
451
+ currentSelectedDiscountList = this.getDiscountList().filter(function (n) {
452
+ return n.isSelected;
450
453
  });
454
+ if (!(currentSelectedDiscountList.length && currentSelectedDiscountList.some(function (n) {
455
+ return withScanList.some(function (m) {
456
+ return m.id === n.id;
457
+ });
458
+ }))) {
459
+ _context7.next = 16;
460
+ break;
461
+ }
462
+ return _context7.abrupt("return", {
463
+ type: "clientCalc",
464
+ isAvailable: true,
465
+ productList: this.store.productList || [],
466
+ discountList: this.getDiscountList()
467
+ });
468
+ case 16:
451
469
  _ref2 = rulesModule.isDiscountListAvailable({
452
470
  productList: this.store.productList || [],
453
471
  oldDiscountList: this.getDiscountList(),
@@ -458,27 +476,27 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
458
476
  discountList: this.getDiscountList()
459
477
  }, newProductList = _ref2.productList, newDiscountList = _ref2.discountList, isAvailable = _ref2.isAvailable;
460
478
  if (!isAvailable) {
461
- _context7.next = 21;
479
+ _context7.next = 24;
462
480
  break;
463
481
  }
464
482
  this.setDiscountList(newDiscountList || []);
465
483
  this.store.originalDiscountList = newDiscountList || [];
466
484
  this.setProductList(newProductList || []);
467
485
  if (!(this.isWalkIn() && resultDiscountList.length && ((_this$options$otherPa6 = this.options.otherParams) === null || _this$options$otherPa6 === void 0 ? void 0 : _this$options$otherPa6.platform) === 'shop')) {
468
- _context7.next = 21;
486
+ _context7.next = 24;
469
487
  break;
470
488
  }
471
- _context7.next = 21;
489
+ _context7.next = 24;
472
490
  return this.getCustomerWallet(resultDiscountList[0].customer_id);
473
- case 21:
491
+ case 24:
474
492
  return _context7.abrupt("return", {
475
493
  type: "clientCalc",
476
494
  isAvailable: isAvailable || false,
477
495
  productList: newProductList || this.store.productList || [],
478
496
  discountList: newDiscountList || this.getDiscountList()
479
497
  });
480
- case 24:
481
- _context7.prev = 24;
498
+ case 27:
499
+ _context7.prev = 27;
482
500
  _context7.t1 = _context7["catch"](0);
483
501
  console.error('[ShopDiscount] 扫码出错:', _context7.t1);
484
502
  return _context7.abrupt("return", {
@@ -487,11 +505,11 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
487
505
  productList: this.store.productList || [],
488
506
  discountList: this.getDiscountList()
489
507
  });
490
- case 28:
508
+ case 31:
491
509
  case "end":
492
510
  return _context7.stop();
493
511
  }
494
- }, _callee7, this, [[0, 24]]);
512
+ }, _callee7, this, [[0, 27]]);
495
513
  }));
496
514
  function scanCode(_x5, _x6) {
497
515
  return _scanCode.apply(this, arguments);
@@ -502,7 +502,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
502
502
  * 为某个订单添加支付项(新方法)
503
503
  */
504
504
  async addPaymentItemAsync(orderUuid, paymentItem) {
505
- var _a, _b, _c;
505
+ var _a, _b, _c, _d;
506
506
  this.logInfo("Starting addPaymentItemAsync", {
507
507
  orderUuid,
508
508
  paymentAmount: paymentItem.amount,
@@ -538,7 +538,12 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
538
538
  });
539
539
  throw new Error(warningMessage);
540
540
  }
541
- const paymentUuid = (0, import_utils.getUniqueId)("payment_");
541
+ let paymentUuid;
542
+ if ((_a = paymentItem.metadata) == null ? void 0 : _a.unique_payment_number) {
543
+ paymentUuid = paymentItem.metadata.unique_payment_number;
544
+ } else {
545
+ paymentUuid = (0, import_utils.getUniqueId)("payment_");
546
+ }
542
547
  const newPaymentItem = {
543
548
  uuid: paymentUuid,
544
549
  id: paymentItem.id || 0,
@@ -570,15 +575,15 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
570
575
  this.logInfo("addPaymentItemAsync completed successfully", {
571
576
  orderUuid,
572
577
  paymentUuid: newPaymentItem.uuid,
573
- uniquePaymentNumber: (_a = newPaymentItem.metadata) == null ? void 0 : _a.unique_payment_number,
578
+ uniquePaymentNumber: (_b = newPaymentItem.metadata) == null ? void 0 : _b.unique_payment_number,
574
579
  newExpectAmount: order.expect_amount,
575
580
  paymentAmount: newPaymentItem.amount,
576
581
  paymentCode: newPaymentItem.code,
577
582
  orderPaymentType: newPaymentItem.order_payment_type,
578
583
  metadataFields: Object.keys(newPaymentItem.metadata || {}),
579
584
  // 现金支付找零信息
580
- actualPaidAmount: (_b = newPaymentItem.metadata) == null ? void 0 : _b.actual_paid_amount,
581
- changeGivenAmount: (_c = newPaymentItem.metadata) == null ? void 0 : _c.change_given_amount
585
+ actualPaidAmount: (_c = newPaymentItem.metadata) == null ? void 0 : _c.actual_paid_amount,
586
+ changeGivenAmount: (_d = newPaymentItem.metadata) == null ? void 0 : _d.change_given_amount
582
587
  });
583
588
  } catch (error) {
584
589
  console.error("[PaymentModule] 添加支付项失败", error);
@@ -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
  }
@@ -270,6 +270,15 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
270
270
  isScan: true
271
271
  };
272
272
  });
273
+ const currentSelectedDiscountList = this.getDiscountList().filter((n) => n.isSelected);
274
+ if (currentSelectedDiscountList.length && currentSelectedDiscountList.some((n) => withScanList.some((m) => m.id === n.id))) {
275
+ return {
276
+ type: "clientCalc",
277
+ isAvailable: true,
278
+ productList: this.store.productList || [],
279
+ discountList: this.getDiscountList()
280
+ };
281
+ }
273
282
  const {
274
283
  productList: newProductList,
275
284
  discountList: newDiscountList,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "0.0.348",
4
+ "version": "0.0.350",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",