@pisell/pisellos 2.1.13 → 2.1.15

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.
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
49
49
  getCategories(): ProductCategory[];
50
50
  setOtherParams(key: string, value: any): void;
51
51
  getOtherParams(): any;
52
- getProductType(): "normal" | "duration" | "session";
52
+ getProductType(): "duration" | "session" | "normal";
53
53
  }
@@ -329,6 +329,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
329
329
  tag: discountType,
330
330
  discount: {
331
331
  discount_card_type: discount === null || discount === void 0 || (_discount$metadata = discount.metadata) === null || _discount$metadata === void 0 ? void 0 : _discount$metadata.discount_card_type,
332
+ fixed_amount: product.price,
332
333
  resource_id: discount.id,
333
334
  title: discount.format_title,
334
335
  original_amount: product.origin_total,
@@ -349,7 +350,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
349
350
  console.log(sortedProductList, 'sortedProductListsortedProductList');
350
351
 
351
352
  // 然后再处理应用哪些优惠券,此时只考虑filteredDiscountList中的优惠券
352
- sortedProductList.forEach(function (originProduct, i) {
353
+ sortedProductList.forEach(function (originProduct, index) {
353
354
  var _product$discount_lis4, _product$discount_lis5, _product$discount_lis7, _product$discount_lis8, _product$discount_lis9, _product$discount_lis10, _product$discount_lis11;
354
355
  var product = _this3.hooks.getProduct(originProduct);
355
356
  if (product !== null && product !== void 0 && product.booking_id && (_product$discount_lis4 = product.discount_list) !== null && _product$discount_lis4 !== void 0 && _product$discount_lis4.length && product !== null && product !== void 0 && (_product$discount_lis5 = product.discount_list) !== null && _product$discount_lis5 !== void 0 && _product$discount_lis5.every(function (discount) {
@@ -441,7 +442,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
441
442
  }))]);
442
443
  } else {
443
444
  processedProductsMap.set(product._id, [_this3.hooks.setProduct(originProduct, _objectSpread(_objectSpread({}, isManualDiscount ? {} : {
444
- _id: product._id.split('___')[0] + '___' + i,
445
+ _id: product._id.split('___')[0] + '___' + index,
445
446
  total: product.origin_total || product.total,
446
447
  price: product.price
447
448
  }), {}, {
@@ -469,10 +470,10 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
469
470
  _id: product._id.split('___')[0]
470
471
  }));
471
472
  }
472
- for (var _i = 0; _i < splitCount; _i++) {
473
+ for (var i = 0; i < splitCount; i++) {
473
474
  var _product$discount_lis12, _originProduct$_produ, _selectedDiscount$met;
474
475
  // 如果用过折扣卡,也就不存在拆分的情况了,这里直接使用上面计算出来的折扣卡
475
- var _selectedDiscount = selectedDiscountCard || applicableDiscounts[_i];
476
+ var _selectedDiscount = selectedDiscountCard || applicableDiscounts[i];
476
477
  // 标记优惠券为已使用
477
478
  usedDiscounts.set(_selectedDiscount.id, true);
478
479
 
@@ -498,6 +499,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
498
499
  type: discountType,
499
500
  discount: {
500
501
  discount_card_type: _selectedDiscount === null || _selectedDiscount === void 0 || (_selectedDiscount$met = _selectedDiscount.metadata) === null || _selectedDiscount$met === void 0 ? void 0 : _selectedDiscount$met.discount_card_type,
502
+ fixed_amount: new Decimal(productOriginTotal).minus(new Decimal(targetProductTotal)).toNumber(),
501
503
  resource_id: _selectedDiscount.id,
502
504
  title: _selectedDiscount.format_title,
503
505
  original_amount: productOriginTotal,
@@ -534,7 +536,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
534
536
  } else {
535
537
  arr.push(_this3.hooks.setProduct(originProduct, {
536
538
  discount_list: [discountDetail],
537
- _id: product._id.split('___')[0] + "___" + _selectedDiscount.id,
539
+ _id: product._id.split('___')[0] + "___" + _selectedDiscount.id + index,
538
540
  price: _selectedDiscount.tag === 'good_pass' ? 0 : product.price,
539
541
  quantity: isNeedSplit ? 1 : product.quantity,
540
542
  total: targetProductTotal,
@@ -314,7 +314,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
314
314
  }[];
315
315
  setOtherData(key: string, value: any): void;
316
316
  getOtherData(key: string): any;
317
- getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
317
+ getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
318
318
  /**
319
319
  * 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
320
320
  *
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
49
49
  getCategories(): ProductCategory[];
50
50
  setOtherParams(key: string, value: any): void;
51
51
  getOtherParams(): any;
52
- getProductType(): "normal" | "duration" | "session";
52
+ getProductType(): "duration" | "session" | "normal";
53
53
  }
@@ -212,6 +212,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
212
212
  tag: discountType,
213
213
  discount: {
214
214
  discount_card_type: (_d = discount == null ? void 0 : discount.metadata) == null ? void 0 : _d.discount_card_type,
215
+ fixed_amount: product.price,
215
216
  resource_id: discount.id,
216
217
  title: discount.format_title,
217
218
  original_amount: product.origin_total,
@@ -228,7 +229,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
228
229
  });
229
230
  });
230
231
  console.log(sortedProductList, "sortedProductListsortedProductList");
231
- sortedProductList.forEach((originProduct, i) => {
232
+ sortedProductList.forEach((originProduct, index) => {
232
233
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
233
234
  const product = this.hooks.getProduct(originProduct);
234
235
  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)))) {
@@ -305,7 +306,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
305
306
  product._id,
306
307
  [this.hooks.setProduct(originProduct, {
307
308
  ...isManualDiscount ? {} : {
308
- _id: product._id.split("___")[0] + "___" + i,
309
+ _id: product._id.split("___")[0] + "___" + index,
309
310
  total: product.origin_total || product.total,
310
311
  price: product.price
311
312
  },
@@ -328,8 +329,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
328
329
  _id: product._id.split("___")[0]
329
330
  }));
330
331
  }
331
- for (let i2 = 0; i2 < splitCount; i2++) {
332
- const selectedDiscount2 = selectedDiscountCard || applicableDiscounts[i2];
332
+ for (let i = 0; i < splitCount; i++) {
333
+ const selectedDiscount2 = selectedDiscountCard || applicableDiscounts[i];
333
334
  usedDiscounts.set(selectedDiscount2.id, true);
334
335
  const appliedProducts = appliedDiscountProducts.get(selectedDiscount2.id) || [];
335
336
  let productOriginTotal = product.origin_total || product.total || 0;
@@ -346,6 +347,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
346
347
  type: discountType,
347
348
  discount: {
348
349
  discount_card_type: (_j = selectedDiscount2 == null ? void 0 : selectedDiscount2.metadata) == null ? void 0 : _j.discount_card_type,
350
+ fixed_amount: new import_decimal.default(productOriginTotal).minus(new import_decimal.default(targetProductTotal)).toNumber(),
349
351
  resource_id: selectedDiscount2.id,
350
352
  title: selectedDiscount2.format_title,
351
353
  original_amount: productOriginTotal,
@@ -377,7 +379,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
377
379
  } else {
378
380
  arr.push(this.hooks.setProduct(originProduct, {
379
381
  discount_list: [discountDetail],
380
- _id: product._id.split("___")[0] + "___" + selectedDiscount2.id,
382
+ _id: product._id.split("___")[0] + "___" + selectedDiscount2.id + index,
381
383
  price: selectedDiscount2.tag === "good_pass" ? 0 : product.price,
382
384
  quantity: isNeedSplit ? 1 : product.quantity,
383
385
  total: targetProductTotal,
@@ -314,7 +314,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
314
314
  }[];
315
315
  setOtherData(key: string, value: any): void;
316
316
  getOtherData(key: string): any;
317
- getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
317
+ getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
318
318
  /**
319
319
  * 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
320
320
  *
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.1.13",
4
+ "version": "2.1.15",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -69,4 +69,4 @@
69
69
  "publishConfig": {
70
70
  "access": "public"
71
71
  }
72
- }
72
+ }