@pisell/pisellos 1.0.8 → 1.0.10

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.
@@ -242,7 +242,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
242
242
 
243
243
  // 编辑的商品 使用了优惠券不可用
244
244
  var isAvailableProduct = !(product !== null && product !== void 0 && product.booking_id && product !== null && product !== void 0 && (_product$discount_lis = product.discount_list) !== null && _product$discount_lis !== void 0 && _product$discount_lis.length && product !== null && product !== void 0 && (_product$discount_lis2 = product.discount_list) !== null && _product$discount_lis2 !== void 0 && _product$discount_lis2.every(function (discount) {
245
- return discount.id && ['good_pass', 'discount_card', 'product_discount_card'].includes(discount.tag);
245
+ return discount.id && ['good_pass', 'discount_card', 'product_discount_card'].includes(discount.tag || discount.type);
246
246
  }));
247
247
 
248
248
  // 判断优惠券是否适用于该商品
@@ -255,7 +255,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
255
255
  var applicableProducts = discountApplicableProducts.get(discount.id) || [];
256
256
  applicableProducts.push({
257
257
  amount: product.price,
258
- type: discount.tag,
258
+ type: discount.tag || discount.type,
259
+ tag: discount.tag || discount.type,
259
260
  discount: {
260
261
  resource_id: discount.id,
261
262
  title: discount.format_title,
@@ -275,7 +276,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
275
276
  var _product$discount_lis3, _product$discount_lis4, _product$discount_lis5, _product$discount_lis6, _product$discount_lis7;
276
277
  var product = _this3.hooks.getProduct(originProduct);
277
278
  if (product !== null && product !== void 0 && product.booking_id && (_product$discount_lis3 = product.discount_list) !== null && _product$discount_lis3 !== void 0 && _product$discount_lis3.length && product !== null && product !== void 0 && (_product$discount_lis4 = product.discount_list) !== null && _product$discount_lis4 !== void 0 && _product$discount_lis4.every(function (discount) {
278
- return discount.id && ['good_pass', 'discount_card', 'product_discount_card'].includes(discount.tag);
279
+ return discount.id && ['good_pass', 'discount_card', 'product_discount_card'].includes(discount.tag || discount.type);
279
280
  })) {
280
281
  processedProductsMap.set(product._id, originProduct);
281
282
  return;
@@ -287,7 +288,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
287
288
  if (Number(product.price) === 0 || !product.price) return false;
288
289
  // 如果优惠券已被使用,则跳过
289
290
  var targetUsedDiscounts = usedDiscounts.get(discount.id);
290
- if (targetUsedDiscounts && discount.tag === 'good_pass') return false;
291
+ if (targetUsedDiscounts && (discount.tag || discount.type) === 'good_pass') return false;
291
292
  var limitedData = discount.limited_relation_product_data;
292
293
 
293
294
  // 判断优惠券是否适用于该商品
@@ -444,7 +444,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
444
444
  if (discount.id && ['good_pass', 'discount_card'].includes(discount.type)) {
445
445
  var index = editModeDiscountList.findIndex(function (n) {
446
446
  var _discount$discount;
447
- return n.id === ((_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.resource_id) || discount.id;
447
+ return n.id === (((_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.resource_id) || discount.id);
448
448
  });
449
449
  if (index !== -1) {
450
450
  editModeDiscountList[index] = _objectSpread(_objectSpread({}, editModeDiscountList[index]), {}, {
@@ -164,13 +164,14 @@ var RulesModule = class extends import_BaseModule.BaseModule {
164
164
  var _a, _b, _c;
165
165
  const limitedData = discount == null ? void 0 : discount.limited_relation_product_data;
166
166
  const isLimitedProduct = limitedData.type === "product_all" || limitedData.product_ids && limitedData.product_ids.includes(product.id);
167
- const isAvailableProduct = !((product == null ? void 0 : product.booking_id) && ((_a = product == null ? void 0 : product.discount_list) == null ? void 0 : _a.length) && ((_b = product == null ? void 0 : product.discount_list) == null ? void 0 : _b.every((discount2) => discount2.id && ["good_pass", "discount_card", "product_discount_card"].includes(discount2.tag))));
167
+ const isAvailableProduct = !((product == null ? void 0 : product.booking_id) && ((_a = product == null ? void 0 : product.discount_list) == null ? void 0 : _a.length) && ((_b = product == null ? void 0 : product.discount_list) == null ? void 0 : _b.every((discount2) => discount2.id && ["good_pass", "discount_card", "product_discount_card"].includes(discount2.tag || discount2.type))));
168
168
  if (isAvailableProduct && isLimitedProduct) {
169
169
  (_c = discountApplicability.get(discount.id)) == null ? void 0 : _c.push(product.id);
170
170
  const applicableProducts = discountApplicableProducts.get(discount.id) || [];
171
171
  applicableProducts.push({
172
172
  amount: product.price,
173
- type: discount.tag,
173
+ type: discount.tag || discount.type,
174
+ tag: discount.tag || discount.type,
174
175
  discount: {
175
176
  resource_id: discount.id,
176
177
  title: discount.format_title,
@@ -187,7 +188,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
187
188
  sortedProductList.forEach((originProduct) => {
188
189
  var _a, _b, _c, _d, _e;
189
190
  const product = this.hooks.getProduct(originProduct);
190
- if ((product == null ? void 0 : product.booking_id) && ((_a = product.discount_list) == null ? void 0 : _a.length) && ((_b = product == null ? void 0 : product.discount_list) == null ? void 0 : _b.every((discount) => discount.id && ["good_pass", "discount_card", "product_discount_card"].includes(discount.tag)))) {
191
+ if ((product == null ? void 0 : product.booking_id) && ((_a = product.discount_list) == null ? void 0 : _a.length) && ((_b = product == null ? void 0 : product.discount_list) == null ? void 0 : _b.every((discount) => discount.id && ["good_pass", "discount_card", "product_discount_card"].includes(discount.tag || discount.type)))) {
191
192
  processedProductsMap.set(product._id, originProduct);
192
193
  return;
193
194
  }
@@ -195,7 +196,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
195
196
  if (Number(product.price) === 0 || !product.price)
196
197
  return false;
197
198
  const targetUsedDiscounts = usedDiscounts.get(discount.id);
198
- if (targetUsedDiscounts && discount.tag === "good_pass")
199
+ if (targetUsedDiscounts && (discount.tag || discount.type) === "good_pass")
199
200
  return false;
200
201
  const limitedData = discount.limited_relation_product_data;
201
202
  if (limitedData.type === "product_all") {
@@ -289,7 +289,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
289
289
  if (discount.id && ["good_pass", "discount_card"].includes(discount.type)) {
290
290
  const index = editModeDiscountList.findIndex((n) => {
291
291
  var _a4;
292
- return n.id === ((_a4 = discount.discount) == null ? void 0 : _a4.resource_id) || discount.id;
292
+ return n.id === (((_a4 = discount.discount) == null ? void 0 : _a4.resource_id) || discount.id);
293
293
  });
294
294
  if (index !== -1) {
295
295
  editModeDiscountList[index] = {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "1.0.8",
4
+ "version": "1.0.10",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",