@pisell/pisellos 2.1.132 → 2.1.134

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.
@@ -19,7 +19,7 @@ interface PackageSubItemUsageRules {
19
19
  type: 'universal_discount' | 'package_exclusive' | 'single_item_promo' | 'custom_usage_rules';
20
20
  rules: ("original_price" | "markup_price")[];
21
21
  package_scope?: {
22
- type: 'all_packages' | 'specific_packages';
22
+ type: 'all_packages' | 'specific_packages' | 'product_all' | 'products';
23
23
  exclude_bundle_product_ids: number[];
24
24
  include_bundle_product_ids: number[];
25
25
  filter: 0 | 1;
@@ -202,7 +202,7 @@ export function createDefaultOrderRulesHooks() {
202
202
  num: (_values$quantity2 = values.quantity) !== null && _values$quantity2 !== void 0 ? _values$quantity2 : product.num,
203
203
  product_bundle: nextBundle,
204
204
  metadata: _objectSpread(_objectSpread({}, metadataAny), {}, {
205
- source_product_price: nextSourceSellingPrice,
205
+ source_product_price: nextSourceOriginalPrice,
206
206
  main_product_selling_price: nextMainSellingPrice,
207
207
  main_product_original_price: nextMainOriginalPrice,
208
208
  price_schema_version: 2
@@ -1882,8 +1882,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1882
1882
  // 套餐适用范围校验
1883
1883
  var isScopeValid = false;
1884
1884
 
1885
- // 排除套餐判断
1886
- if (scopeType === 'all_packages') {
1885
+ // 排除套餐判断, product_all值兼容旧数据
1886
+ if (scopeType === 'all_packages' || scopeType === 'product_all') {
1887
1887
  // 所有套餐可用
1888
1888
  if (!filter) {
1889
1889
  isScopeValid = true;
@@ -1892,8 +1892,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1892
1892
  }
1893
1893
  }
1894
1894
 
1895
- // 包含套餐判断
1896
- if (scopeType === 'specific_packages') {
1895
+ // 包含套餐判断, products值兼容旧数据
1896
+ if (scopeType === 'specific_packages' || scopeType === 'products') {
1897
1897
  isScopeValid = include_bundle_product_ids.includes(Number(mainProductId));
1898
1898
  }
1899
1899
 
@@ -2455,7 +2455,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
2455
2455
  key: "removeProductFromOrder",
2456
2456
  value: function () {
2457
2457
  var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(identity) {
2458
- var products;
2458
+ var _this$store$order$get3, _this$store$order6, _this$store$order$ens, _this$store$order7, _tempOrder$bookings, tempOrder, products, _tempOrder$bookings2, _tempOrder$bookings3, venueProductUids, venueBookingUids, _iterator15, _step15, _product$metadata6, _product$metadata7, product, beforeBookingCount, _this$store$order$per, _this$store$order8;
2459
2459
  return _regeneratorRuntime().wrap(function _callee27$(_context27) {
2460
2460
  while (1) switch (_context27.prev = _context27.next) {
2461
2461
  case 0:
@@ -2470,30 +2470,86 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
2470
2470
  }
2471
2471
  throw new Error('order 模块未初始化');
2472
2472
  case 4:
2473
- _context27.next = 6;
2473
+ tempOrder = ((_this$store$order$get3 = (_this$store$order6 = this.store.order).getTempOrder) === null || _this$store$order$get3 === void 0 ? void 0 : _this$store$order$get3.call(_this$store$order6)) || ((_this$store$order$ens = (_this$store$order7 = this.store.order).ensureTempOrder) === null || _this$store$order$ens === void 0 ? void 0 : _this$store$order$ens.call(_this$store$order7));
2474
+ _context27.next = 7;
2474
2475
  return this.store.order.removeProductFromOrder(identity);
2475
- case 6:
2476
+ case 7:
2476
2477
  products = _context27.sent;
2477
- _context27.next = 9;
2478
+ if (!(tempOrder !== null && tempOrder !== void 0 && (_tempOrder$bookings = tempOrder.bookings) !== null && _tempOrder$bookings !== void 0 && _tempOrder$bookings.length)) {
2479
+ _context27.next = 33;
2480
+ break;
2481
+ }
2482
+ venueProductUids = new Set();
2483
+ venueBookingUids = new Set();
2484
+ _iterator15 = _createForOfIteratorHelper(tempOrder.products || []);
2485
+ _context27.prev = 12;
2486
+ _iterator15.s();
2487
+ case 14:
2488
+ if ((_step15 = _iterator15.n()).done) {
2489
+ _context27.next = 22;
2490
+ break;
2491
+ }
2492
+ product = _step15.value;
2493
+ if (product !== null && product !== void 0 && (_product$metadata6 = product.metadata) !== null && _product$metadata6 !== void 0 && _product$metadata6.venue_booking) {
2494
+ _context27.next = 18;
2495
+ break;
2496
+ }
2497
+ return _context27.abrupt("continue", 20);
2498
+ case 18:
2499
+ if (product.identity_key) venueProductUids.add(String(product.identity_key));
2500
+ if ((_product$metadata7 = product.metadata) !== null && _product$metadata7 !== void 0 && _product$metadata7.booking_uid) {
2501
+ venueBookingUids.add(String(product.metadata.booking_uid));
2502
+ }
2503
+ case 20:
2504
+ _context27.next = 14;
2505
+ break;
2506
+ case 22:
2507
+ _context27.next = 27;
2508
+ break;
2509
+ case 24:
2510
+ _context27.prev = 24;
2511
+ _context27.t0 = _context27["catch"](12);
2512
+ _iterator15.e(_context27.t0);
2513
+ case 27:
2514
+ _context27.prev = 27;
2515
+ _iterator15.f();
2516
+ return _context27.finish(27);
2517
+ case 30:
2518
+ beforeBookingCount = ((_tempOrder$bookings2 = tempOrder.bookings) === null || _tempOrder$bookings2 === void 0 ? void 0 : _tempOrder$bookings2.length) || 0;
2519
+ tempOrder.bookings = (tempOrder.bookings || []).filter(function (booking) {
2520
+ var _booking$metadata, _booking$metadata2;
2521
+ if (!(booking !== null && booking !== void 0 && (_booking$metadata = booking.metadata) !== null && _booking$metadata !== void 0 && _booking$metadata.venue_booking)) return true;
2522
+ if (booking.product_uid) {
2523
+ return venueProductUids.has(String(booking.product_uid));
2524
+ }
2525
+ var bookingUid = (_booking$metadata2 = booking.metadata) === null || _booking$metadata2 === void 0 ? void 0 : _booking$metadata2.unique_identification_number;
2526
+ if (bookingUid) return venueBookingUids.has(String(bookingUid));
2527
+ return true;
2528
+ });
2529
+ if ((((_tempOrder$bookings3 = tempOrder.bookings) === null || _tempOrder$bookings3 === void 0 ? void 0 : _tempOrder$bookings3.length) || 0) !== beforeBookingCount) {
2530
+ (_this$store$order$per = (_this$store$order8 = this.store.order).persistTempOrder) === null || _this$store$order$per === void 0 || _this$store$order$per.call(_this$store$order8);
2531
+ }
2532
+ case 33:
2533
+ _context27.next = 35;
2478
2534
  return this.refreshItemRuleQuantityLimits();
2479
- case 9:
2480
- _context27.next = 11;
2535
+ case 35:
2536
+ _context27.next = 37;
2481
2537
  return this.refreshCartValidationPassed();
2482
- case 11:
2538
+ case 37:
2483
2539
  this.logMethodSuccess('removeProductFromOrder', {
2484
2540
  productCount: products.length
2485
2541
  });
2486
2542
  return _context27.abrupt("return", products);
2487
- case 15:
2488
- _context27.prev = 15;
2489
- _context27.t0 = _context27["catch"](1);
2490
- this.logMethodError('removeProductFromOrder', _context27.t0);
2491
- throw _context27.t0;
2492
- case 19:
2543
+ case 41:
2544
+ _context27.prev = 41;
2545
+ _context27.t1 = _context27["catch"](1);
2546
+ this.logMethodError('removeProductFromOrder', _context27.t1);
2547
+ throw _context27.t1;
2548
+ case 45:
2493
2549
  case "end":
2494
2550
  return _context27.stop();
2495
2551
  }
2496
- }, _callee27, this, [[1, 15]]);
2552
+ }, _callee27, this, [[1, 41], [12, 24, 27, 30]]);
2497
2553
  }));
2498
2554
  function removeProductFromOrder(_x18) {
2499
2555
  return _removeProductFromOrder.apply(this, arguments);
@@ -2697,17 +2753,17 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
2697
2753
  if (visited.has(value)) return;
2698
2754
  visited.add(value);
2699
2755
  if (Array.isArray(value)) {
2700
- var _iterator15 = _createForOfIteratorHelper(value),
2701
- _step15;
2756
+ var _iterator16 = _createForOfIteratorHelper(value),
2757
+ _step16;
2702
2758
  try {
2703
- for (_iterator15.s(); !(_step15 = _iterator15.n()).done;) {
2704
- var item = _step15.value;
2759
+ for (_iterator16.s(); !(_step16 = _iterator16.n()).done;) {
2760
+ var item = _step16.value;
2705
2761
  collectFromValue(item);
2706
2762
  }
2707
2763
  } catch (err) {
2708
- _iterator15.e(err);
2764
+ _iterator16.e(err);
2709
2765
  } finally {
2710
- _iterator15.f();
2766
+ _iterator16.f();
2711
2767
  }
2712
2768
  return;
2713
2769
  }
@@ -2862,7 +2918,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
2862
2918
  key: "applyPrefillByItemRule",
2863
2919
  value: function () {
2864
2920
  var _applyPrefillByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36() {
2865
- var strategyConfigs, businessData, prefillItems, productSourceMap, tempOrder, hasChanges, _iterator16, _step16, _prefillItem$product_, _targetProduct$_origi, prefillItem, productId, productVariantId, targetQuantity, sourceItem, productIndex, _sourceItem$price, sellingPrice, targetProduct, existedQuantity, delta, nextProduct;
2921
+ var strategyConfigs, businessData, prefillItems, productSourceMap, tempOrder, hasChanges, _iterator17, _step17, _prefillItem$product_, _targetProduct$_origi, prefillItem, productId, productVariantId, targetQuantity, sourceItem, productIndex, _sourceItem$price, sellingPrice, targetProduct, existedQuantity, delta, nextProduct;
2866
2922
  return _regeneratorRuntime().wrap(function _callee36$(_context36) {
2867
2923
  while (1) switch (_context36.prev = _context36.next) {
2868
2924
  case 0:
@@ -2907,15 +2963,15 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
2907
2963
  productSourceMap = _context36.sent;
2908
2964
  tempOrder = this.ensureTempOrder();
2909
2965
  hasChanges = false;
2910
- _iterator16 = _createForOfIteratorHelper(prefillItems);
2966
+ _iterator17 = _createForOfIteratorHelper(prefillItems);
2911
2967
  _context36.prev = 20;
2912
- _iterator16.s();
2968
+ _iterator17.s();
2913
2969
  case 22:
2914
- if ((_step16 = _iterator16.n()).done) {
2970
+ if ((_step17 = _iterator17.n()).done) {
2915
2971
  _context36.next = 45;
2916
2972
  break;
2917
2973
  }
2918
- prefillItem = _step16.value;
2974
+ prefillItem = _step17.value;
2919
2975
  productId = Number(prefillItem.product_id);
2920
2976
  productVariantId = Number((_prefillItem$product_ = prefillItem.product_variant_id) !== null && _prefillItem$product_ !== void 0 ? _prefillItem$product_ : 0);
2921
2977
  targetQuantity = toNonNegativeInt(prefillItem.quantity);
@@ -2984,10 +3040,10 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
2984
3040
  case 47:
2985
3041
  _context36.prev = 47;
2986
3042
  _context36.t0 = _context36["catch"](20);
2987
- _iterator16.e(_context36.t0);
3043
+ _iterator17.e(_context36.t0);
2988
3044
  case 50:
2989
3045
  _context36.prev = 50;
2990
- _iterator16.f();
3046
+ _iterator17.f();
2991
3047
  return _context36.finish(50);
2992
3048
  case 53:
2993
3049
  if (!hasChanges) {
@@ -1,49 +0,0 @@
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
- PromotionAdapter: () => import_adapter.PromotionAdapter,
34
- PromotionEvaluator: () => import_evaluator.PromotionEvaluator,
35
- X_ITEMS_FOR_Y_PRICE_STRATEGY: () => import_examples.X_ITEMS_FOR_Y_PRICE_STRATEGY,
36
- default: () => import_adapter2.default
37
- });
38
- module.exports = __toCommonJS(promotion_exports);
39
- var import_evaluator = require("./evaluator");
40
- var import_adapter = require("./adapter");
41
- var import_adapter2 = __toESM(require("./adapter"));
42
- var import_examples = require("./examples");
43
- // Annotate the CommonJS export names for ESM import in node:
44
- 0 && (module.exports = {
45
- BUY_X_GET_Y_FREE_STRATEGY,
46
- PromotionAdapter,
47
- PromotionEvaluator,
48
- X_ITEMS_FOR_Y_PRICE_STRATEGY
49
- });
@@ -19,7 +19,7 @@ interface PackageSubItemUsageRules {
19
19
  type: 'universal_discount' | 'package_exclusive' | 'single_item_promo' | 'custom_usage_rules';
20
20
  rules: ("original_price" | "markup_price")[];
21
21
  package_scope?: {
22
- type: 'all_packages' | 'specific_packages';
22
+ type: 'all_packages' | 'specific_packages' | 'product_all' | 'products';
23
23
  exclude_bundle_product_ids: number[];
24
24
  include_bundle_product_ids: number[];
25
25
  filter: 0 | 1;
@@ -166,7 +166,7 @@ function createDefaultOrderRulesHooks() {
166
166
  product_bundle: nextBundle,
167
167
  metadata: {
168
168
  ...metadataAny,
169
- source_product_price: nextSourceSellingPrice,
169
+ source_product_price: nextSourceOriginalPrice,
170
170
  main_product_selling_price: nextMainSellingPrice,
171
171
  main_product_original_price: nextMainOriginalPrice,
172
172
  price_schema_version: 2
@@ -1421,14 +1421,14 @@ var RulesModule = class extends import_BaseModule.BaseModule {
1421
1421
  const _isMarkupPrice = isMarkupPrice && rules.includes("markup_price");
1422
1422
  const isPriceValid = _isOriginalPrice || _isMarkupPrice;
1423
1423
  let isScopeValid = false;
1424
- if (scopeType === "all_packages") {
1424
+ if (scopeType === "all_packages" || scopeType === "product_all") {
1425
1425
  if (!filter) {
1426
1426
  isScopeValid = true;
1427
1427
  } else {
1428
1428
  isScopeValid = !exclude_bundle_product_ids.includes(Number(mainProductId));
1429
1429
  }
1430
1430
  }
1431
- if (scopeType === "specific_packages") {
1431
+ if (scopeType === "specific_packages" || scopeType === "products") {
1432
1432
  isScopeValid = include_bundle_product_ids.includes(Number(mainProductId));
1433
1433
  }
1434
1434
  if (isPriceValid && isScopeValid) {
@@ -1455,6 +1455,7 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
1455
1455
  }
1456
1456
  }
1457
1457
  async removeProductFromOrder(identity) {
1458
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
1458
1459
  this.logMethodStart("removeProductFromOrder", {
1459
1460
  product_id: identity.product_id,
1460
1461
  product_variant_id: identity.product_variant_id
@@ -1462,7 +1463,37 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
1462
1463
  try {
1463
1464
  if (!this.store.order)
1464
1465
  throw new Error("order 模块未初始化");
1466
+ const tempOrder = ((_b = (_a = this.store.order).getTempOrder) == null ? void 0 : _b.call(_a)) || ((_d = (_c = this.store.order).ensureTempOrder) == null ? void 0 : _d.call(_c));
1465
1467
  const products = await this.store.order.removeProductFromOrder(identity);
1468
+ if ((_e = tempOrder == null ? void 0 : tempOrder.bookings) == null ? void 0 : _e.length) {
1469
+ const venueProductUids = /* @__PURE__ */ new Set();
1470
+ const venueBookingUids = /* @__PURE__ */ new Set();
1471
+ for (const product of tempOrder.products || []) {
1472
+ if (!((_f = product == null ? void 0 : product.metadata) == null ? void 0 : _f.venue_booking))
1473
+ continue;
1474
+ if (product.identity_key)
1475
+ venueProductUids.add(String(product.identity_key));
1476
+ if ((_g = product.metadata) == null ? void 0 : _g.booking_uid) {
1477
+ venueBookingUids.add(String(product.metadata.booking_uid));
1478
+ }
1479
+ }
1480
+ const beforeBookingCount = ((_h = tempOrder.bookings) == null ? void 0 : _h.length) || 0;
1481
+ tempOrder.bookings = (tempOrder.bookings || []).filter((booking) => {
1482
+ var _a2, _b2;
1483
+ if (!((_a2 = booking == null ? void 0 : booking.metadata) == null ? void 0 : _a2.venue_booking))
1484
+ return true;
1485
+ if (booking.product_uid) {
1486
+ return venueProductUids.has(String(booking.product_uid));
1487
+ }
1488
+ const bookingUid = (_b2 = booking.metadata) == null ? void 0 : _b2.unique_identification_number;
1489
+ if (bookingUid)
1490
+ return venueBookingUids.has(String(bookingUid));
1491
+ return true;
1492
+ });
1493
+ if ((((_i = tempOrder.bookings) == null ? void 0 : _i.length) || 0) !== beforeBookingCount) {
1494
+ (_k = (_j = this.store.order).persistTempOrder) == null ? void 0 : _k.call(_j);
1495
+ }
1496
+ }
1466
1497
  await this.refreshItemRuleQuantityLimits();
1467
1498
  await this.refreshCartValidationPassed();
1468
1499
  this.logMethodSuccess("removeProductFromOrder", {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.1.132",
4
+ "version": "2.1.134",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",