@pisell/pisellos 2.3.64 → 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
  }
@@ -1243,7 +1243,8 @@ var Server = /*#__PURE__*/function () {
1243
1243
  checkoutData: checkoutData,
1244
1244
  order: printableOrder,
1245
1245
  response: null,
1246
- requireFullyPaid: false
1246
+ requireFullyPaid: false,
1247
+ isManualPrint: true
1247
1248
  });
1248
1249
  case 27:
1249
1250
  printResult = _context19.sent;
@@ -5952,9 +5953,7 @@ var Server = /*#__PURE__*/function () {
5952
5953
  checkoutData: checkoutData,
5953
5954
  order: pendingOrder,
5954
5955
  response: pendingResult,
5955
- requireFullyPaid: true,
5956
- // 自动小票固定使用 print_all 的收据类型 0,不随订单 type 改成券/手环类型 99。
5957
- isManualPrint: true
5956
+ requireFullyPaid: true
5958
5957
  });
5959
5958
  case 18:
5960
5959
  _context60.next = 20;
@@ -6040,9 +6039,8 @@ var Server = /*#__PURE__*/function () {
6040
6039
  checkoutData: syncResult.checkoutData,
6041
6040
  order: syncedOrder,
6042
6041
  response: syncResult.normalizedResponse,
6043
- requireFullyPaid: true,
6042
+ requireFullyPaid: true
6044
6043
  // print_all 的 type=0 是收据打印;不要沿用同步成功后的券/手环打印 type=99。
6045
- isManualPrint: true
6046
6044
  });
6047
6045
  case 16:
6048
6046
  return _context61.abrupt("return", response);
@@ -619,7 +619,8 @@ function formatBundlePrice(bundle, currencySymbol) {
619
619
  var _ref33, _ref34, _bundle$bundle_sellin;
620
620
  var value = (_ref33 = (_ref34 = (_bundle$bundle_sellin = bundle.bundle_selling_price) !== null && _bundle$bundle_sellin !== void 0 ? _bundle$bundle_sellin : bundle.bundle_sum_price) !== null && _ref34 !== void 0 ? _ref34 : bundle.price) !== null && _ref33 !== void 0 ? _ref33 : 0;
621
621
  var amount = new Decimal(toMoneyNumber(value));
622
- var isNegative = bundle.price_type === 'markdown' || bundle.price_type === 'markup' && bundle.price_type_ext === 'product_price';
622
+ // 套餐价格协议:只有 markdown 是减价;加价与商品原价都保持正数。
623
+ var isNegative = bundle.price_type === 'markdown';
623
624
  if (isNegative) return "-".concat(currencySymbol).concat(amount.abs().toFixed(2));
624
625
  return formatMoney(amount, currencySymbol);
625
626
  }
@@ -326,7 +326,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
326
326
  date: string;
327
327
  status: string;
328
328
  week: string;
329
- weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
329
+ weekNum: 0 | 1 | 2 | 3 | 4 | 5 | 6;
330
330
  }[]>;
331
331
  submitTimeSlot(timeSlots: TimeSliceItem): void;
332
332
  private getScheduleDataByIds;
@@ -0,0 +1,51 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/model/strategy/adapter/promotion/index.ts
30
+ var promotion_exports = {};
31
+ __export(promotion_exports, {
32
+ BUY_X_GET_Y_FREE_STRATEGY: () => import_examples.BUY_X_GET_Y_FREE_STRATEGY,
33
+ ITEM_REWARD_STRATEGY: () => import_examples.ITEM_REWARD_STRATEGY,
34
+ PromotionAdapter: () => import_adapter.PromotionAdapter,
35
+ PromotionEvaluator: () => import_evaluator.PromotionEvaluator,
36
+ X_ITEMS_FOR_Y_PRICE_STRATEGY: () => import_examples.X_ITEMS_FOR_Y_PRICE_STRATEGY,
37
+ default: () => import_adapter2.default
38
+ });
39
+ module.exports = __toCommonJS(promotion_exports);
40
+ var import_evaluator = require("./evaluator");
41
+ var import_adapter = require("./adapter");
42
+ var import_adapter2 = __toESM(require("./adapter"));
43
+ var import_examples = require("./examples");
44
+ // Annotate the CommonJS export names for ESM import in node:
45
+ 0 && (module.exports = {
46
+ BUY_X_GET_Y_FREE_STRATEGY,
47
+ ITEM_REWARD_STRATEGY,
48
+ PromotionAdapter,
49
+ PromotionEvaluator,
50
+ X_ITEMS_FOR_Y_PRICE_STRATEGY
51
+ });
@@ -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);
@@ -795,7 +795,8 @@ var Server = class {
795
795
  checkoutData,
796
796
  order: printableOrder,
797
797
  response: null,
798
- requireFullyPaid: false
798
+ requireFullyPaid: false,
799
+ isManualPrint: true
799
800
  });
800
801
  return {
801
802
  code: 200,
@@ -3855,9 +3856,7 @@ var Server = class {
3855
3856
  checkoutData,
3856
3857
  order: pendingOrder,
3857
3858
  response: pendingResult,
3858
- requireFullyPaid: true,
3859
- // 自动小票固定使用 print_all 的收据类型 0,不随订单 type 改成券/手环类型 99。
3860
- isManualPrint: true
3859
+ requireFullyPaid: true
3861
3860
  });
3862
3861
  }
3863
3862
  await this.dispatchCheckoutSyncTask({
@@ -3915,9 +3914,8 @@ var Server = class {
3915
3914
  checkoutData: syncResult.checkoutData,
3916
3915
  order: syncedOrder,
3917
3916
  response: syncResult.normalizedResponse,
3918
- requireFullyPaid: true,
3917
+ requireFullyPaid: true
3919
3918
  // print_all 的 type=0 是收据打印;不要沿用同步成功后的券/手环打印 type=99。
3920
- isManualPrint: true
3921
3919
  });
3922
3920
  }
3923
3921
  return response;
@@ -562,7 +562,7 @@ function buildOptionTitleSuffix(options) {
562
562
  function formatBundlePrice(bundle, currencySymbol) {
563
563
  const value = bundle.bundle_selling_price ?? bundle.bundle_sum_price ?? bundle.price ?? 0;
564
564
  const amount = new import_decimal.default(toMoneyNumber(value));
565
- const isNegative = bundle.price_type === "markdown" || bundle.price_type === "markup" && bundle.price_type_ext === "product_price";
565
+ const isNegative = bundle.price_type === "markdown";
566
566
  if (isNegative)
567
567
  return `-${currencySymbol}${amount.abs().toFixed(2)}`;
568
568
  return formatMoney(amount, currencySymbol);
@@ -326,7 +326,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
326
326
  date: string;
327
327
  status: string;
328
328
  week: string;
329
- weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
329
+ weekNum: 0 | 1 | 2 | 3 | 4 | 5 | 6;
330
330
  }[]>;
331
331
  submitTimeSlot(timeSlots: TimeSliceItem): void;
332
332
  private getScheduleDataByIds;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.3.64",
4
+ "version": "2.3.66",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",