@pisell/pisellos 0.0.137 → 0.0.139

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.
@@ -559,7 +559,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
559
559
  key: "storeProduct",
560
560
  value: function () {
561
561
  var _storeProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(productData) {
562
- var activeAccount, _ref4, bundle, options, origin, product_variant_id, _ref4$quantity, quantity, rowKey, cartItems, targetCartItem, currentAccount, targetAccount, isSameAccount, product, addCartItem;
562
+ var activeAccount, _ref4, bundle, options, origin, product_variant_id, _ref4$quantity, quantity, rowKey, cartItems, currentAccount, targetCartItem, targetAccount, isSameAccount, product, addCartItem;
563
563
  return _regeneratorRuntime().wrap(function _callee7$(_context8) {
564
564
  while (1) switch (_context8.prev = _context8.next) {
565
565
  case 0:
@@ -572,11 +572,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
572
572
  _context8.next = 12;
573
573
  break;
574
574
  }
575
+ currentAccount = this.store.accountList.getActiveAccount();
575
576
  targetCartItem = cartItems.find(function (n) {
576
577
  var _n$_productOrigin;
577
- return ((_n$_productOrigin = n._productOrigin) === null || _n$_productOrigin === void 0 ? void 0 : _n$_productOrigin.rowKey) === rowKey;
578
+ return ((_n$_productOrigin = n._productOrigin) === null || _n$_productOrigin === void 0 ? void 0 : _n$_productOrigin.rowKey) === rowKey && n.holder_id === (currentAccount === null || currentAccount === void 0 ? void 0 : currentAccount.getId());
578
579
  });
579
- currentAccount = this.store.accountList.getActiveAccount();
580
580
  targetAccount = targetCartItem === null || targetCartItem === void 0 ? void 0 : targetCartItem.holder_id;
581
581
  isSameAccount = (currentAccount === null || currentAccount === void 0 ? void 0 : currentAccount.getId()) === targetAccount;
582
582
  if (!(targetCartItem && isNormalProduct(targetCartItem._productOrigin) && isSameAccount)) {
@@ -10,6 +10,7 @@ export declare class ShopDiscountImpl extends BaseModule implements Module {
10
10
  private window;
11
11
  private store;
12
12
  private options;
13
+ private hooks?;
13
14
  constructor(name?: string, version?: string);
14
15
  initialize(core: PisellCore, options: any): Promise<void>;
15
16
  destroy(): Promise<void>;
@@ -43,6 +43,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
43
43
  _defineProperty(_assertThisInitialized(_this), "window", void 0);
44
44
  _defineProperty(_assertThisInitialized(_this), "store", void 0);
45
45
  _defineProperty(_assertThisInitialized(_this), "options", {});
46
+ _defineProperty(_assertThisInitialized(_this), "hooks", void 0);
46
47
  _this.store = {
47
48
  customer: null,
48
49
  productList: [],
@@ -63,6 +64,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
63
64
  this.core = core;
64
65
  this.options = options;
65
66
  this.store = _objectSpread(_objectSpread({}, this.store), options.store || {});
67
+ this.hooks = options.hooks;
66
68
  console.log('[ShopDiscount] 初始化完成');
67
69
 
68
70
  // 获取依赖的插件
@@ -73,7 +75,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
73
75
 
74
76
  // 注册事件监听
75
77
  this.registerEventListeners();
76
- case 7:
78
+ case 8:
77
79
  case "end":
78
80
  return _context.stop();
79
81
  }
@@ -428,18 +430,21 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
428
430
  }, {
429
431
  key: "setDiscountList",
430
432
  value: function setDiscountList(discountList) {
431
- var _this$store$discount5;
433
+ var _this3 = this,
434
+ _this$store$discount5;
432
435
  var productList = this.store.productList || [];
433
436
  var editModeDiscountList = [];
434
437
  productList.forEach(function (item) {
435
438
  if (item.booking_id) {
439
+ var _this3$hooks;
440
+ var product = (_this3$hooks = _this3.hooks) === null || _this3$hooks === void 0 ? void 0 : _this3$hooks.getProduct(item);
436
441
  (item.discount_list || []).forEach(function (discount) {
437
442
  if (discount.id && ['good_pass', 'discount_card'].includes(discount.type)) {
438
443
  var _discount$discount, _discount$discount2, _discount$discount3;
439
444
  editModeDiscountList.push(_objectSpread(_objectSpread({}, discount), {}, {
440
445
  isEditMode: true,
441
446
  limited_relation_product_data: {},
442
- savedAmount: discount.amount,
447
+ savedAmount: discount.amount * ((product === null || product === void 0 ? void 0 : product.num) || 1),
443
448
  isAvailable: true,
444
449
  id: ((_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.resource_id) || discount.id,
445
450
  format_title: ((_discount$discount2 = discount.discount) === null || _discount$discount2 === void 0 ? void 0 : _discount$discount2.title) || discount.format_title,
@@ -347,11 +347,11 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
347
347
  const { bundle, options, origin, product_variant_id, quantity = 1, rowKey } = productData || {};
348
348
  const cartItems = this.store.cart.getItems();
349
349
  if (rowKey) {
350
+ const currentAccount = this.store.accountList.getActiveAccount();
350
351
  const targetCartItem = cartItems.find((n) => {
351
352
  var _a;
352
- return ((_a = n._productOrigin) == null ? void 0 : _a.rowKey) === rowKey;
353
+ return ((_a = n._productOrigin) == null ? void 0 : _a.rowKey) === rowKey && n.holder_id === (currentAccount == null ? void 0 : currentAccount.getId());
353
354
  });
354
- const currentAccount = this.store.accountList.getActiveAccount();
355
355
  const targetAccount = targetCartItem == null ? void 0 : targetCartItem.holder_id;
356
356
  const isSameAccount = (currentAccount == null ? void 0 : currentAccount.getId()) === targetAccount;
357
357
  if (targetCartItem && (0, import_utils4.isNormalProduct)(targetCartItem._productOrigin) && isSameAccount) {
@@ -10,6 +10,7 @@ export declare class ShopDiscountImpl extends BaseModule implements Module {
10
10
  private window;
11
11
  private store;
12
12
  private options;
13
+ private hooks?;
13
14
  constructor(name?: string, version?: string);
14
15
  initialize(core: PisellCore, options: any): Promise<void>;
15
16
  destroy(): Promise<void>;
@@ -46,6 +46,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
46
46
  this.core = core;
47
47
  this.options = options;
48
48
  this.store = { ...this.store, ...options.store || {} };
49
+ this.hooks = options.hooks;
49
50
  console.log("[ShopDiscount] 初始化完成");
50
51
  this.initializePlugins();
51
52
  this.registerDependentModules();
@@ -268,17 +269,19 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
268
269
  const productList = this.store.productList || [];
269
270
  const editModeDiscountList = [];
270
271
  productList.forEach((item) => {
272
+ var _a2;
271
273
  if (item.booking_id) {
274
+ const product = (_a2 = this.hooks) == null ? void 0 : _a2.getProduct(item);
272
275
  (item.discount_list || []).forEach((discount) => {
273
- var _a2, _b, _c;
276
+ var _a3, _b, _c;
274
277
  if (discount.id && ["good_pass", "discount_card"].includes(discount.type)) {
275
278
  editModeDiscountList.push({
276
279
  ...discount,
277
280
  isEditMode: true,
278
281
  limited_relation_product_data: {},
279
- savedAmount: discount.amount,
282
+ savedAmount: discount.amount * ((product == null ? void 0 : product.num) || 1),
280
283
  isAvailable: true,
281
- id: ((_a2 = discount.discount) == null ? void 0 : _a2.resource_id) || discount.id,
284
+ id: ((_a3 = discount.discount) == null ? void 0 : _a3.resource_id) || discount.id,
282
285
  format_title: ((_b = discount.discount) == null ? void 0 : _b.title) || discount.format_title,
283
286
  isDisabled: true,
284
287
  isSelected: true,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "0.0.137",
4
+ "version": "0.0.139",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",