@pisell/pisellos 2.3.65 → 2.3.66

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.
@@ -0,0 +1,9 @@
1
+ // 导出评估器
2
+ export { PromotionEvaluator } from "./evaluator";
3
+
4
+ // 导出适配器
5
+ export { PromotionAdapter } from "./adapter";
6
+ export { default } from "./adapter";
7
+
8
+ // 导出策略配置示例常量
9
+ export { X_ITEMS_FOR_Y_PRICE_STRATEGY, BUY_X_GET_Y_FREE_STRATEGY, ITEM_REWARD_STRATEGY } from "./examples";
@@ -5,15 +5,15 @@ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArra
5
5
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
6
6
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
7
7
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
8
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
9
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
10
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
8
11
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
9
12
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
10
13
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
11
14
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
12
15
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
13
16
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
14
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
15
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
16
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
17
17
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
18
18
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
19
19
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
@@ -104,6 +104,26 @@ function mergeWalletAssets() {
104
104
  });
105
105
  return merged;
106
106
  }
107
+
108
+ /**
109
+ * 聚合接口不保证 recalculate_list 顺序;派生抵扣额依赖选择顺序,
110
+ * 因此已选资产必须先恢复为 selectedIds 的顺序再进入策略计算。
111
+ */
112
+ function orderWalletAssetsByIds(assets, orderedIds) {
113
+ var assetByKey = new Map(assets.map(function (asset) {
114
+ return [getWalletAssetKey(asset), asset];
115
+ }));
116
+ var orderedKeys = new Set(orderedIds.map(function (id) {
117
+ return String(id);
118
+ }));
119
+ return [].concat(_toConsumableArray(orderedIds.map(function (id) {
120
+ return assetByKey.get(String(id));
121
+ }).filter(function (asset) {
122
+ return asset !== undefined;
123
+ })), _toConsumableArray(assets.filter(function (asset) {
124
+ return !orderedKeys.has(getWalletAssetKey(asset));
125
+ })));
126
+ }
107
127
  function createInitialWalletAssetsState() {
108
128
  return {
109
129
  status: 'idle',
@@ -668,7 +688,7 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
668
688
  value: (function () {
669
689
  var _aggregateRecalculateWalletAssetsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(businessData, selectedIds) {
670
690
  var _this$paymentModule$w7, _this$paymentModule$w8;
671
- var walletParams, customerId, requestParams, response, responseData, hasAggregateLists, recalculateList, customerWalletPassList, allList, walletPassEvaluator, evaluated, returnedSelectedKeys, authoritativeSelectedIds;
691
+ var walletParams, customerId, requestParams, response, responseData, hasAggregateLists, recalculateList, customerWalletPassList, orderedRecalculateList, allList, walletPassEvaluator, evaluated, returnedSelectedKeys, authoritativeSelectedIds;
672
692
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
673
693
  while (1) switch (_context4.prev = _context4.next) {
674
694
  case 0:
@@ -704,7 +724,8 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
704
724
  case 11:
705
725
  recalculateList = Array.isArray(responseData === null || responseData === void 0 ? void 0 : responseData.recalculate_list) ? responseData.recalculate_list : [];
706
726
  customerWalletPassList = Array.isArray(responseData === null || responseData === void 0 ? void 0 : responseData.customer_wallet_pass_list) ? responseData.customer_wallet_pass_list : [];
707
- allList = mergeWalletAssets(recalculateList, customerWalletPassList);
727
+ orderedRecalculateList = orderWalletAssetsByIds(recalculateList, selectedIds);
728
+ allList = mergeWalletAssets(orderedRecalculateList, customerWalletPassList);
708
729
  walletPassEvaluator = (_this$paymentModule$w7 = this.paymentModule.window) === null || _this$paymentModule$w7 === void 0 || (_this$paymentModule$w8 = _this$paymentModule$w7.getWalletPassEvaluator) === null || _this$paymentModule$w8 === void 0 ? void 0 : _this$paymentModule$w8.call(_this$paymentModule$w7);
709
730
  evaluated = walletPassEvaluator !== null && walletPassEvaluator !== void 0 && walletPassEvaluator.getRecommendedVouchers ? walletPassEvaluator.getRecommendedVouchers({
710
731
  orderTotalAmount: walletParams.order_wait_pay_amount,
@@ -748,7 +769,7 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
748
769
  products: walletParams.products || [],
749
770
  authoritativeSelectedIds: authoritativeSelectedIds
750
771
  });
751
- case 24:
772
+ case 25:
752
773
  case "end":
753
774
  return _context4.stop();
754
775
  }
@@ -5953,9 +5953,7 @@ var Server = /*#__PURE__*/function () {
5953
5953
  checkoutData: checkoutData,
5954
5954
  order: pendingOrder,
5955
5955
  response: pendingResult,
5956
- requireFullyPaid: true,
5957
- // 自动小票固定使用 print_all 的收据类型 0,不随订单 type 改成券/手环类型 99。
5958
- isManualPrint: true
5956
+ requireFullyPaid: true
5959
5957
  });
5960
5958
  case 18:
5961
5959
  _context60.next = 20;
@@ -109,6 +109,16 @@ function mergeWalletAssets(...groups) {
109
109
  });
110
110
  return merged;
111
111
  }
112
+ function orderWalletAssetsByIds(assets, orderedIds) {
113
+ const assetByKey = new Map(
114
+ assets.map((asset) => [getWalletAssetKey(asset), asset])
115
+ );
116
+ const orderedKeys = new Set(orderedIds.map((id) => String(id)));
117
+ return [
118
+ ...orderedIds.map((id) => assetByKey.get(String(id))).filter((asset) => asset !== void 0),
119
+ ...assets.filter((asset) => !orderedKeys.has(getWalletAssetKey(asset)))
120
+ ];
121
+ }
112
122
  function createInitialWalletAssetsState() {
113
123
  return {
114
124
  status: "idle",
@@ -605,8 +615,12 @@ var WalletPassPaymentImpl = class {
605
615
  const customerWalletPassList = Array.isArray(
606
616
  responseData == null ? void 0 : responseData.customer_wallet_pass_list
607
617
  ) ? responseData.customer_wallet_pass_list : [];
608
- const allList = mergeWalletAssets(
618
+ const orderedRecalculateList = orderWalletAssetsByIds(
609
619
  recalculateList,
620
+ selectedIds
621
+ );
622
+ const allList = mergeWalletAssets(
623
+ orderedRecalculateList,
610
624
  customerWalletPassList
611
625
  );
612
626
  const walletPassEvaluator = (_b = (_a = this.paymentModule.window) == null ? void 0 : _a.getWalletPassEvaluator) == null ? void 0 : _b.call(_a);
@@ -3856,9 +3856,7 @@ var Server = class {
3856
3856
  checkoutData,
3857
3857
  order: pendingOrder,
3858
3858
  response: pendingResult,
3859
- requireFullyPaid: true,
3860
- // 自动小票固定使用 print_all 的收据类型 0,不随订单 type 改成券/手环类型 99。
3861
- isManualPrint: true
3859
+ requireFullyPaid: true
3862
3860
  });
3863
3861
  }
3864
3862
  await this.dispatchCheckoutSyncTask({
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.3.65",
4
+ "version": "2.3.66",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",