@pisell/pisellos 1.0.9 → 1.0.11

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.
@@ -107,6 +107,18 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
107
107
  };
108
108
  }
109
109
 
110
+ // 编辑商品已有商品券
111
+ if (productList.every(function (item) {
112
+ var _item$discount_list;
113
+ return item.booking_id && (((_item$discount_list = item.discount_list) === null || _item$discount_list === void 0 ? void 0 : _item$discount_list.length) || item.price == 0);
114
+ })) {
115
+ return {
116
+ isAvailable: false,
117
+ discountList: oldDiscountList,
118
+ productList: productList
119
+ };
120
+ }
121
+
110
122
  // 合并新旧折扣列表,并计算折扣结果
111
123
  var mergedDiscountList = uniqueById(uniqueById([].concat(_toConsumableArray(oldDiscountList), _toConsumableArray(newDiscountList))), 'product_id');
112
124
  var result = this.calcDiscount({
@@ -149,6 +161,15 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
149
161
  var _this3 = this;
150
162
  var discountList = _ref2.discountList,
151
163
  productList = _ref2.productList;
164
+ // debugger
165
+
166
+ // 识别出来是不是在编辑的界面里又新增了商品
167
+ // 这种情况下,如果有可用的优惠券,也会自动勾选上
168
+ var isEditModeAddNewProduct = productList.find(function (n) {
169
+ return n.booking_id;
170
+ }) && productList.find(function (n) {
171
+ return !n.booking_id;
172
+ });
152
173
  var editModeDiscount = [];
153
174
  var addModeDiscount = [];
154
175
  discountList.forEach(function (discount) {
@@ -242,7 +263,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
242
263
 
243
264
  // 编辑的商品 使用了优惠券不可用
244
265
  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);
266
+ return discount.id && ['good_pass', 'discount_card', 'product_discount_card'].includes(discount.tag || discount.type);
246
267
  }));
247
268
 
248
269
  // 判断优惠券是否适用于该商品
@@ -255,7 +276,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
255
276
  var applicableProducts = discountApplicableProducts.get(discount.id) || [];
256
277
  applicableProducts.push({
257
278
  amount: product.price,
258
- type: discount.tag,
279
+ type: discount.tag || discount.type,
280
+ tag: discount.tag || discount.type,
259
281
  discount: {
260
282
  resource_id: discount.id,
261
283
  title: discount.format_title,
@@ -275,7 +297,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
275
297
  var _product$discount_lis3, _product$discount_lis4, _product$discount_lis5, _product$discount_lis6, _product$discount_lis7;
276
298
  var product = _this3.hooks.getProduct(originProduct);
277
299
  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);
300
+ return discount.id && ['good_pass', 'discount_card', 'product_discount_card'].includes(discount.tag || discount.type);
279
301
  })) {
280
302
  processedProductsMap.set(product._id, originProduct);
281
303
  return;
@@ -287,7 +309,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
287
309
  if (Number(product.price) === 0 || !product.price) return false;
288
310
  // 如果优惠券已被使用,则跳过
289
311
  var targetUsedDiscounts = usedDiscounts.get(discount.id);
290
- if (targetUsedDiscounts && discount.tag === 'good_pass') return false;
312
+ if (targetUsedDiscounts && (discount.tag || discount.type) === 'good_pass') return false;
291
313
  var limitedData = discount.limited_relation_product_data;
292
314
 
293
315
  // 判断优惠券是否适用于该商品
@@ -323,6 +345,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
323
345
  bundle: product.bundle,
324
346
  options: product.options
325
347
  }),
348
+ variant: originProduct._productInit.variant,
349
+ original_price: originProduct._productInit.original_price,
326
350
  total: getProductTotalPrice({
327
351
  product: {
328
352
  price: product.price
@@ -344,7 +368,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
344
368
  }
345
369
  return;
346
370
  }
347
- if (applicableDiscounts.length && product.booking_id && typeof selectedDiscount.isManualSelect === 'undefined' && !(options !== null && options !== void 0 && options.scan)) {
371
+ if (applicableDiscounts.length && product.booking_id && typeof selectedDiscount.isManualSelect === 'undefined' && !(options !== null && options !== void 0 && options.scan) && !isEditModeAddNewProduct) {
348
372
  return;
349
373
  }
350
374
 
@@ -355,12 +379,12 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
355
379
  var appliedProducts = appliedDiscountProducts.get(selectedDiscount.id) || [];
356
380
  var targetProductPrice = selectedDiscount.tag === 'good_pass' ? '0' : new Decimal(100).minus(selectedDiscount.par_value || 0).div(100).mul(new Decimal(product.price || 0)).toFixed(2);
357
381
  var discountDetail = {
358
- amount: selectedDiscount.tag === 'product_discount_card' ? new Decimal(product.price || 0).minus(new Decimal(targetProductPrice)).toNumber() : product.price,
382
+ amount: selectedDiscount.tag === 'good_pass' ? product.price : new Decimal(product.price || 0).minus(new Decimal(targetProductPrice)).toNumber(),
359
383
  type: selectedDiscount.tag === 'product_discount_card' ? 'discount_card' : selectedDiscount.tag,
360
384
  discount: {
361
385
  resource_id: selectedDiscount.id,
362
386
  title: selectedDiscount.format_title,
363
- original_amount: product.price,
387
+ original_amount: product.origin_total || product.price,
364
388
  product_id: originProduct.id,
365
389
  percent: selectedDiscount.par_value
366
390
  },
@@ -372,6 +396,15 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
372
396
  // 记录应用了优惠券的商品
373
397
  // 后续更新价格改为 getProductTotalPrice getProductOriginTotalPrice逻辑
374
398
  if (product.isClient) {
399
+ var _originProduct$_produ;
400
+ var variant = (_originProduct$_produ = originProduct._productOrigin.variant) === null || _originProduct$_produ === void 0 ? void 0 : _originProduct$_produ.map(function (n) {
401
+ if (n.id === originProduct._productOrigin.product_variant_id) {
402
+ n.original_price = n.price;
403
+ var _targetProductPrice = selectedDiscount.tag === 'good_pass' ? '0' : new Decimal(100).minus(selectedDiscount.par_value || 0).div(100).mul(new Decimal(n.price || 0)).toFixed(2);
404
+ n.price = _targetProductPrice;
405
+ }
406
+ return n;
407
+ });
375
408
  processedProductsMap.set(product._id, _this3.hooks.setProduct(originProduct, {
376
409
  discount_list: [discountDetail],
377
410
  price: new Decimal(targetProductPrice).toNumber(),
@@ -382,6 +415,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
382
415
  bundle: product.bundle,
383
416
  options: product.options
384
417
  }),
418
+ variant: variant,
419
+ original_price: new Decimal(product.price).toNumber(),
385
420
  total: getProductTotalPrice({
386
421
  product: {
387
422
  price: targetProductPrice
@@ -415,6 +450,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
415
450
  bundle: product.bundle,
416
451
  options: product.options
417
452
  }),
453
+ variant: originProduct._productInit.variant,
454
+ original_price: originProduct._productInit.original_price,
418
455
  total: getProductTotalPrice({
419
456
  product: {
420
457
  price: product.price
@@ -46,6 +46,8 @@ export interface RulesParamsHooks {
46
46
  discount_list: any[];
47
47
  origin_total?: number;
48
48
  price?: number;
49
+ variant?: any[];
50
+ original_price?: number;
49
51
  }) => Record<string, any>;
50
52
  }
51
53
  export {};
@@ -232,7 +232,7 @@ export var ScheduleModule = /*#__PURE__*/function (_BaseModule) {
232
232
  cacheId: this.cacheId,
233
233
  fatherModule: this.fatherModule,
234
234
  store: store,
235
- cacheKey: ['scheduleList', 'availabilityDateList']
235
+ cacheKey: ['scheduleList', 'availabilityDateList', 'otherProductsIds']
236
236
  });
237
237
  }
238
238
  }
@@ -38,6 +38,7 @@ export declare class ShopDiscountImpl extends BaseModule implements Module {
38
38
  isAvailable: boolean;
39
39
  productList: Record<string, any>[];
40
40
  discountList: Discount[];
41
+ type: "server" | "clientCalc";
41
42
  }>;
42
43
  calcDiscountApplicableProductTotalPrice(discount: Discount): number | undefined;
43
44
  private getCustomer;
@@ -327,11 +327,23 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
327
327
  break;
328
328
  }
329
329
  return _context5.abrupt("return", {
330
+ type: "clientCalc",
330
331
  isAvailable: false,
331
332
  productList: this.store.productList || [],
332
333
  discountList: this.getDiscountList()
333
334
  });
334
335
  case 10:
336
+ if (resultDiscountList.length) {
337
+ _context5.next = 12;
338
+ break;
339
+ }
340
+ return _context5.abrupt("return", {
341
+ type: "server",
342
+ isAvailable: false,
343
+ productList: this.store.productList || [],
344
+ discountList: this.getDiscountList()
345
+ });
346
+ case 12:
335
347
  withScanList = resultDiscountList.map(function (item) {
336
348
  return _objectSpread(_objectSpread({}, item), {}, {
337
349
  isScan: true
@@ -347,37 +359,39 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
347
359
  discountList: this.getDiscountList()
348
360
  }, newProductList = _ref3.productList, newDiscountList = _ref3.discountList, isAvailable = _ref3.isAvailable;
349
361
  if (!isAvailable) {
350
- _context5.next = 18;
362
+ _context5.next = 20;
351
363
  break;
352
364
  }
353
365
  this.setDiscountList(newDiscountList || []);
354
366
  this.setProductList(newProductList || []);
355
367
  if (!(this.isWalkIn() && resultDiscountList.length && ((_this$options$otherPa6 = this.options.otherParams) === null || _this$options$otherPa6 === void 0 ? void 0 : _this$options$otherPa6.platform) === 'shop')) {
356
- _context5.next = 18;
368
+ _context5.next = 20;
357
369
  break;
358
370
  }
359
- _context5.next = 18;
371
+ _context5.next = 20;
360
372
  return this.getCustomerWallet(resultDiscountList[0].customer_id);
361
- case 18:
373
+ case 20:
362
374
  return _context5.abrupt("return", {
375
+ type: "clientCalc",
363
376
  isAvailable: isAvailable || false,
364
377
  productList: newProductList || this.store.productList || [],
365
378
  discountList: newDiscountList || this.getDiscountList()
366
379
  });
367
- case 21:
368
- _context5.prev = 21;
380
+ case 23:
381
+ _context5.prev = 23;
369
382
  _context5.t1 = _context5["catch"](0);
370
383
  console.error('[ShopDiscount] 扫码出错:', _context5.t1);
371
384
  return _context5.abrupt("return", {
385
+ type: "clientCalc",
372
386
  isAvailable: false,
373
387
  productList: this.store.productList || [],
374
388
  discountList: this.getDiscountList()
375
389
  });
376
- case 25:
390
+ case 27:
377
391
  case "end":
378
392
  return _context5.stop();
379
393
  }
380
- }, _callee5, this, [[0, 21]]);
394
+ }, _callee5, this, [[0, 23]]);
381
395
  }));
382
396
  function scanCode(_x4) {
383
397
  return _scanCode.apply(this, arguments);
@@ -484,10 +498,18 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
484
498
  }).flat();
485
499
  newDiscountList.forEach(function (item) {
486
500
  var _item$applicableProdu;
487
- var isAllProductUsed = (_item$applicableProdu = item.applicableProductIds) === null || _item$applicableProdu === void 0 ? void 0 : _item$applicableProdu.every(function (id) {
488
- return allUsedProductIds === null || allUsedProductIds === void 0 ? void 0 : allUsedProductIds.includes(id);
501
+ var isProductFree = function isProductFree(id) {
502
+ var _this3$hooks2;
503
+ var targetProduct = productList.find(function (n) {
504
+ return n.id === id;
505
+ });
506
+ var product = (_this3$hooks2 = _this3.hooks) === null || _this3$hooks2 === void 0 ? void 0 : _this3$hooks2.getProduct(targetProduct);
507
+ return Number(product === null || product === void 0 ? void 0 : product.price) === 0;
508
+ };
509
+ var isAllProductUsedOrFree = (_item$applicableProdu = item.applicableProductIds) === null || _item$applicableProdu === void 0 ? void 0 : _item$applicableProdu.every(function (id) {
510
+ return (allUsedProductIds === null || allUsedProductIds === void 0 ? void 0 : allUsedProductIds.includes(id)) || isProductFree(id);
489
511
  });
490
- if (!item.isSelected && isAllProductUsed) {
512
+ if (!item.isSelected && isAllProductUsedOrFree) {
491
513
  item.isDisabledForProductUsed = true;
492
514
  } else {
493
515
  item.isDisabledForProductUsed = false;
@@ -69,6 +69,16 @@ var RulesModule = class extends import_BaseModule.BaseModule {
69
69
  productList
70
70
  };
71
71
  }
72
+ if (productList.every((item) => {
73
+ var _a;
74
+ return item.booking_id && (((_a = item.discount_list) == null ? void 0 : _a.length) || item.price == 0);
75
+ })) {
76
+ return {
77
+ isAvailable: false,
78
+ discountList: oldDiscountList,
79
+ productList
80
+ };
81
+ }
72
82
  const mergedDiscountList = (0, import_utils.uniqueById)((0, import_utils.uniqueById)([
73
83
  ...oldDiscountList,
74
84
  ...newDiscountList
@@ -105,6 +115,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
105
115
  discountList,
106
116
  productList
107
117
  }, options) {
118
+ const isEditModeAddNewProduct = productList.find((n) => n.booking_id) && productList.find((n) => !n.booking_id);
108
119
  const editModeDiscount = [];
109
120
  const addModeDiscount = [];
110
121
  discountList.forEach((discount) => {
@@ -164,13 +175,14 @@ var RulesModule = class extends import_BaseModule.BaseModule {
164
175
  var _a, _b, _c;
165
176
  const limitedData = discount == null ? void 0 : discount.limited_relation_product_data;
166
177
  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))));
178
+ 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
179
  if (isAvailableProduct && isLimitedProduct) {
169
180
  (_c = discountApplicability.get(discount.id)) == null ? void 0 : _c.push(product.id);
170
181
  const applicableProducts = discountApplicableProducts.get(discount.id) || [];
171
182
  applicableProducts.push({
172
183
  amount: product.price,
173
- type: discount.tag,
184
+ type: discount.tag || discount.type,
185
+ tag: discount.tag || discount.type,
174
186
  discount: {
175
187
  resource_id: discount.id,
176
188
  title: discount.format_title,
@@ -185,9 +197,9 @@ var RulesModule = class extends import_BaseModule.BaseModule {
185
197
  });
186
198
  });
187
199
  sortedProductList.forEach((originProduct) => {
188
- var _a, _b, _c, _d, _e;
200
+ var _a, _b, _c, _d, _e, _f;
189
201
  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)))) {
202
+ 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
203
  processedProductsMap.set(product._id, originProduct);
192
204
  return;
193
205
  }
@@ -195,7 +207,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
195
207
  if (Number(product.price) === 0 || !product.price)
196
208
  return false;
197
209
  const targetUsedDiscounts = usedDiscounts.get(discount.id);
198
- if (targetUsedDiscounts && discount.tag === "good_pass")
210
+ if (targetUsedDiscounts && (discount.tag || discount.type) === "good_pass")
199
211
  return false;
200
212
  const limitedData = discount.limited_relation_product_data;
201
213
  if (limitedData.type === "product_all") {
@@ -223,6 +235,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
223
235
  bundle: product.bundle,
224
236
  options: product.options
225
237
  }),
238
+ variant: originProduct._productInit.variant,
239
+ original_price: originProduct._productInit.original_price,
226
240
  total: (0, import_utils2.getProductTotalPrice)({
227
241
  product: {
228
242
  price: product.price
@@ -249,19 +263,19 @@ var RulesModule = class extends import_BaseModule.BaseModule {
249
263
  }
250
264
  return;
251
265
  }
252
- if (applicableDiscounts.length && product.booking_id && typeof selectedDiscount.isManualSelect === "undefined" && !(options == null ? void 0 : options.scan)) {
266
+ if (applicableDiscounts.length && product.booking_id && typeof selectedDiscount.isManualSelect === "undefined" && !(options == null ? void 0 : options.scan) && !isEditModeAddNewProduct) {
253
267
  return;
254
268
  }
255
269
  usedDiscounts.set(selectedDiscount.id, true);
256
270
  const appliedProducts = appliedDiscountProducts.get(selectedDiscount.id) || [];
257
271
  const targetProductPrice = selectedDiscount.tag === "good_pass" ? "0" : new import_decimal.default(100).minus(selectedDiscount.par_value || 0).div(100).mul(new import_decimal.default(product.price || 0)).toFixed(2);
258
272
  const discountDetail = {
259
- amount: selectedDiscount.tag === "product_discount_card" ? new import_decimal.default(product.price || 0).minus(new import_decimal.default(targetProductPrice)).toNumber() : product.price,
273
+ amount: selectedDiscount.tag === "good_pass" ? product.price : new import_decimal.default(product.price || 0).minus(new import_decimal.default(targetProductPrice)).toNumber(),
260
274
  type: selectedDiscount.tag === "product_discount_card" ? "discount_card" : selectedDiscount.tag,
261
275
  discount: {
262
276
  resource_id: selectedDiscount.id,
263
277
  title: selectedDiscount.format_title,
264
- original_amount: product.price,
278
+ original_amount: product.origin_total || product.price,
265
279
  product_id: originProduct.id,
266
280
  percent: selectedDiscount.par_value
267
281
  },
@@ -270,6 +284,14 @@ var RulesModule = class extends import_BaseModule.BaseModule {
270
284
  appliedProducts.push(discountDetail);
271
285
  appliedDiscountProducts.set(selectedDiscount.id, appliedProducts);
272
286
  if (product.isClient) {
287
+ const variant = (_f = originProduct._productOrigin.variant) == null ? void 0 : _f.map((n) => {
288
+ if (n.id === originProduct._productOrigin.product_variant_id) {
289
+ n.original_price = n.price;
290
+ const targetProductPrice2 = selectedDiscount.tag === "good_pass" ? "0" : new import_decimal.default(100).minus(selectedDiscount.par_value || 0).div(100).mul(new import_decimal.default(n.price || 0)).toFixed(2);
291
+ n.price = targetProductPrice2;
292
+ }
293
+ return n;
294
+ });
273
295
  processedProductsMap.set(
274
296
  product._id,
275
297
  this.hooks.setProduct(originProduct, {
@@ -282,6 +304,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
282
304
  bundle: product.bundle,
283
305
  options: product.options
284
306
  }),
307
+ variant,
308
+ original_price: new import_decimal.default(product.price).toNumber(),
285
309
  total: (0, import_utils2.getProductTotalPrice)({
286
310
  product: {
287
311
  price: targetProductPrice
@@ -317,6 +341,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
317
341
  bundle: product.bundle,
318
342
  options: product.options
319
343
  }),
344
+ variant: originProduct._productInit.variant,
345
+ original_price: originProduct._productInit.original_price,
320
346
  total: (0, import_utils2.getProductTotalPrice)({
321
347
  product: {
322
348
  price: product.price
@@ -46,6 +46,8 @@ export interface RulesParamsHooks {
46
46
  discount_list: any[];
47
47
  origin_total?: number;
48
48
  price?: number;
49
+ variant?: any[];
50
+ original_price?: number;
49
51
  }) => Record<string, any>;
50
52
  }
51
53
  export {};
@@ -154,7 +154,7 @@ var ScheduleModule = class extends import_BaseModule.BaseModule {
154
154
  cacheId: this.cacheId,
155
155
  fatherModule: this.fatherModule,
156
156
  store,
157
- cacheKey: ["scheduleList", "availabilityDateList"]
157
+ cacheKey: ["scheduleList", "availabilityDateList", "otherProductsIds"]
158
158
  });
159
159
  }
160
160
  }
@@ -38,6 +38,7 @@ export declare class ShopDiscountImpl extends BaseModule implements Module {
38
38
  isAvailable: boolean;
39
39
  productList: Record<string, any>[];
40
40
  discountList: Discount[];
41
+ type: "server" | "clientCalc";
41
42
  }>;
42
43
  calcDiscountApplicableProductTotalPrice(discount: Discount): number | undefined;
43
44
  private getCustomer;
@@ -205,6 +205,15 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
205
205
  const rulesModule = this.store.rules;
206
206
  if (!rulesModule) {
207
207
  return {
208
+ type: "clientCalc",
209
+ isAvailable: false,
210
+ productList: this.store.productList || [],
211
+ discountList: this.getDiscountList()
212
+ };
213
+ }
214
+ if (!resultDiscountList.length) {
215
+ return {
216
+ type: "server",
208
217
  isAvailable: false,
209
218
  productList: this.store.productList || [],
210
219
  discountList: this.getDiscountList()
@@ -239,6 +248,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
239
248
  }
240
249
  }
241
250
  return {
251
+ type: "clientCalc",
242
252
  isAvailable: isAvailable || false,
243
253
  productList: newProductList || this.store.productList || [],
244
254
  discountList: newDiscountList || this.getDiscountList()
@@ -246,6 +256,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
246
256
  } catch (error) {
247
257
  console.error("[ShopDiscount] 扫码出错:", error);
248
258
  return {
259
+ type: "clientCalc",
249
260
  isAvailable: false,
250
261
  productList: this.store.productList || [],
251
262
  discountList: this.getDiscountList()
@@ -331,10 +342,16 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
331
342
  }).flat();
332
343
  newDiscountList.forEach((item) => {
333
344
  var _a2;
334
- const isAllProductUsed = (_a2 = item.applicableProductIds) == null ? void 0 : _a2.every((id) => {
335
- return allUsedProductIds == null ? void 0 : allUsedProductIds.includes(id);
345
+ const isProductFree = (id) => {
346
+ var _a3;
347
+ const targetProduct = productList.find((n) => n.id === id);
348
+ const product = (_a3 = this.hooks) == null ? void 0 : _a3.getProduct(targetProduct);
349
+ return Number(product == null ? void 0 : product.price) === 0;
350
+ };
351
+ const isAllProductUsedOrFree = (_a2 = item.applicableProductIds) == null ? void 0 : _a2.every((id) => {
352
+ return (allUsedProductIds == null ? void 0 : allUsedProductIds.includes(id)) || isProductFree(id);
336
353
  });
337
- if (!item.isSelected && isAllProductUsed) {
354
+ if (!item.isSelected && isAllProductUsedOrFree) {
338
355
  item.isDisabledForProductUsed = true;
339
356
  } else {
340
357
  item.isDisabledForProductUsed = false;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "1.0.9",
4
+ "version": "1.0.11",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",