@pisell/pisellos 2.1.60 → 2.1.62

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.
Files changed (99) hide show
  1. package/dist/index.d.ts +0 -1
  2. package/dist/index.js +0 -1
  3. package/dist/modules/Cart/types.d.ts +0 -2
  4. package/dist/modules/Cart/utils/cartProduct.js +0 -11
  5. package/dist/modules/Customer/index.js +1 -1
  6. package/dist/modules/Discount/types.d.ts +0 -15
  7. package/dist/modules/Payment/index.d.ts +1 -2
  8. package/dist/modules/Payment/index.js +7 -10
  9. package/dist/modules/Payment/utils.js +0 -3
  10. package/dist/modules/Payment/walletpass.d.ts +0 -23
  11. package/dist/modules/Payment/walletpass.js +95 -191
  12. package/dist/modules/Rules/index.d.ts +3 -8
  13. package/dist/modules/Rules/index.js +36 -164
  14. package/dist/modules/Rules/types.d.ts +0 -1
  15. package/dist/modules/Summary/types.d.ts +0 -2
  16. package/dist/modules/Summary/utils.d.ts +0 -6
  17. package/dist/modules/Summary/utils.js +0 -21
  18. package/dist/plugins/window.d.ts +0 -2
  19. package/dist/solution/BookingByStep/index.d.ts +0 -1
  20. package/dist/solution/BookingTicket/index.d.ts +1 -1
  21. package/dist/solution/Checkout/index.js +0 -2
  22. package/dist/solution/ShopDiscount/index.d.ts +0 -1
  23. package/dist/solution/ShopDiscount/index.js +1 -11
  24. package/dist/solution/ShopDiscount/types.d.ts +0 -1
  25. package/dist/solution/ShopDiscount/utils.js +11 -26
  26. package/lib/index.d.ts +0 -1
  27. package/lib/index.js +1 -3
  28. package/lib/modules/Cart/types.d.ts +0 -2
  29. package/lib/modules/Cart/utils/cartProduct.js +0 -9
  30. package/lib/modules/Customer/index.js +1 -1
  31. package/lib/modules/Discount/types.d.ts +0 -15
  32. package/lib/modules/Payment/index.d.ts +1 -2
  33. package/lib/modules/Payment/index.js +0 -1
  34. package/lib/modules/Payment/utils.js +0 -3
  35. package/lib/modules/Payment/walletpass.d.ts +0 -23
  36. package/lib/modules/Payment/walletpass.js +17 -94
  37. package/lib/modules/Rules/index.d.ts +3 -8
  38. package/lib/modules/Rules/index.js +197 -375
  39. package/lib/modules/Rules/types.d.ts +0 -1
  40. package/lib/modules/Summary/types.d.ts +0 -2
  41. package/lib/modules/Summary/utils.d.ts +0 -6
  42. package/lib/modules/Summary/utils.js +0 -15
  43. package/lib/plugins/window.d.ts +0 -2
  44. package/lib/solution/BookingByStep/index.d.ts +0 -1
  45. package/lib/solution/BookingTicket/index.d.ts +1 -1
  46. package/lib/solution/Checkout/index.js +0 -2
  47. package/lib/solution/ShopDiscount/index.d.ts +0 -1
  48. package/lib/solution/ShopDiscount/index.js +0 -6
  49. package/lib/solution/ShopDiscount/types.d.ts +0 -1
  50. package/lib/solution/ShopDiscount/utils.js +6 -10
  51. package/package.json +1 -1
  52. package/dist/model/index.d.ts +0 -1
  53. package/dist/model/index.js +0 -1
  54. package/dist/model/strategy/adapter/index.d.ts +0 -3
  55. package/dist/model/strategy/adapter/index.js +0 -4
  56. package/dist/model/strategy/adapter/type.d.ts +0 -28
  57. package/dist/model/strategy/adapter/type.js +0 -1
  58. package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +0 -84
  59. package/dist/model/strategy/adapter/walletPass/evaluator.js +0 -496
  60. package/dist/model/strategy/adapter/walletPass/example.d.ts +0 -4
  61. package/dist/model/strategy/adapter/walletPass/example.js +0 -258
  62. package/dist/model/strategy/adapter/walletPass/index.d.ts +0 -32
  63. package/dist/model/strategy/adapter/walletPass/index.js +0 -182
  64. package/dist/model/strategy/adapter/walletPass/locales.d.ts +0 -1
  65. package/dist/model/strategy/adapter/walletPass/locales.js +0 -23
  66. package/dist/model/strategy/adapter/walletPass/type.d.ts +0 -163
  67. package/dist/model/strategy/adapter/walletPass/type.js +0 -1
  68. package/dist/model/strategy/adapter/walletPass/utils.d.ts +0 -50
  69. package/dist/model/strategy/adapter/walletPass/utils.js +0 -965
  70. package/dist/model/strategy/index.d.ts +0 -94
  71. package/dist/model/strategy/index.js +0 -551
  72. package/dist/model/strategy/strategy-example.d.ts +0 -5
  73. package/dist/model/strategy/strategy-example.js +0 -331
  74. package/dist/model/strategy/type.d.ts +0 -228
  75. package/dist/model/strategy/type.js +0 -94
  76. package/lib/model/index.d.ts +0 -1
  77. package/lib/model/index.js +0 -23
  78. package/lib/model/strategy/adapter/index.d.ts +0 -3
  79. package/lib/model/strategy/adapter/index.js +0 -45
  80. package/lib/model/strategy/adapter/type.d.ts +0 -28
  81. package/lib/model/strategy/adapter/type.js +0 -17
  82. package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +0 -84
  83. package/lib/model/strategy/adapter/walletPass/evaluator.js +0 -420
  84. package/lib/model/strategy/adapter/walletPass/example.d.ts +0 -4
  85. package/lib/model/strategy/adapter/walletPass/example.js +0 -207
  86. package/lib/model/strategy/adapter/walletPass/index.d.ts +0 -32
  87. package/lib/model/strategy/adapter/walletPass/index.js +0 -142
  88. package/lib/model/strategy/adapter/walletPass/locales.d.ts +0 -1
  89. package/lib/model/strategy/adapter/walletPass/locales.js +0 -51
  90. package/lib/model/strategy/adapter/walletPass/type.d.ts +0 -163
  91. package/lib/model/strategy/adapter/walletPass/type.js +0 -17
  92. package/lib/model/strategy/adapter/walletPass/utils.d.ts +0 -50
  93. package/lib/model/strategy/adapter/walletPass/utils.js +0 -660
  94. package/lib/model/strategy/index.d.ts +0 -94
  95. package/lib/model/strategy/index.js +0 -413
  96. package/lib/model/strategy/strategy-example.d.ts +0 -5
  97. package/lib/model/strategy/strategy-example.js +0 -318
  98. package/lib/model/strategy/type.d.ts +0 -228
  99. package/lib/model/strategy/type.js +0 -44
@@ -25,7 +25,6 @@ export interface RulesModuleAPI {
25
25
  holders: {
26
26
  form_record_id: number;
27
27
  }[];
28
- orderTotalAmount: number;
29
28
  isFormSubject: boolean;
30
29
  }) => DiscountResult;
31
30
  }
@@ -5,8 +5,6 @@ export interface ISummaryState {
5
5
  subtotal: string | number;
6
6
  /** 最终总价 */
7
7
  total: string | number;
8
- /** 最终原始价格 不包含折扣卡商品券折扣 */
9
- originTotal: string | number;
10
8
  /** 税率标题 */
11
9
  taxTitle?: string;
12
10
  /** 商品总费率 */
@@ -8,12 +8,6 @@ export declare const calculatePriceDetails: (shopInfo: any, items: CartItem[]) =
8
8
  * @returns 商品总价字符串,保留2位小数
9
9
  */
10
10
  export declare const calculateSubtotal: (items: CartItem[]) => string;
11
- /**
12
- * 计算商品小计(不含其他费用 不包含折扣卡商品券抵扣金额)
13
- * @param items - 购物车商品数组
14
- * @returns 商品总价字符串,保留2位小数
15
- */
16
- export declare const calculateOriginSubtotal: (items: CartItem[]) => string;
17
11
  /**
18
12
  * @title: 单个商品的税费
19
13
  * @description:
@@ -30,7 +30,6 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  var utils_exports = {};
31
31
  __export(utils_exports, {
32
32
  calculateDeposit: () => calculateDeposit,
33
- calculateOriginSubtotal: () => calculateOriginSubtotal,
34
33
  calculatePriceDetails: () => calculatePriceDetails,
35
34
  calculateSubtotal: () => calculateSubtotal,
36
35
  calculateTaxFee: () => calculateTaxFee
@@ -39,15 +38,12 @@ module.exports = __toCommonJS(utils_exports);
39
38
  var import_decimal = __toESM(require("decimal.js"));
40
39
  var calculatePriceDetails = (shopInfo, items) => {
41
40
  const subtotal = new import_decimal.default(calculateSubtotal(items));
42
- const subOriginTotal = new import_decimal.default(calculateOriginSubtotal(items));
43
41
  const totalTaxFee = new import_decimal.default(calculateTaxFee(shopInfo, items));
44
42
  const total = (shopInfo == null ? void 0 : shopInfo.is_price_include_tax) ? subtotal : subtotal.plus(totalTaxFee);
45
- const originTotal = (shopInfo == null ? void 0 : shopInfo.is_price_include_tax) ? subOriginTotal : subOriginTotal.plus(totalTaxFee);
46
43
  const deposit = calculateDeposit(items);
47
44
  return {
48
45
  subtotal: subtotal.toFixed(2),
49
46
  total: total.toFixed(2),
50
- originTotal: originTotal.toFixed(2),
51
47
  taxTitle: shopInfo == null ? void 0 : shopInfo.tax_title,
52
48
  totalTaxFee: totalTaxFee.toFixed(2),
53
49
  isPriceIncludeTax: shopInfo == null ? void 0 : shopInfo.is_price_include_tax,
@@ -64,16 +60,6 @@ var calculateSubtotal = (items) => {
64
60
  }, new import_decimal.default(0));
65
61
  return subtotal.toFixed(2);
66
62
  };
67
- var calculateOriginSubtotal = (items) => {
68
- if (!(items == null ? void 0 : items.length)) {
69
- return "0.00";
70
- }
71
- const subtotal = items.reduce((sum, item) => {
72
- const cartItemTotalPrice = new import_decimal.default(item.summaryOriginTotal || 0);
73
- return sum.plus(cartItemTotalPrice);
74
- }, new import_decimal.default(0));
75
- return subtotal.toFixed(2);
76
- };
77
63
  var calculateTaxFee = (shopInfo, items) => {
78
64
  if (!(items == null ? void 0 : items.length)) {
79
65
  return "0.00";
@@ -115,7 +101,6 @@ var calculateDeposit = (items) => {
115
101
  // Annotate the CommonJS export names for ESM import in node:
116
102
  0 && (module.exports = {
117
103
  calculateDeposit,
118
- calculateOriginSubtotal,
119
104
  calculatePriceDetails,
120
105
  calculateSubtotal,
121
106
  calculateTaxFee
@@ -1,4 +1,3 @@
1
- import { WalletPassEvaluator } from '../model';
2
1
  import { Plugin } from '../types';
3
2
  /**
4
3
  * WindowPlugin 接口定义
@@ -15,7 +14,6 @@ export interface WindowPlugin extends Plugin {
15
14
  document: Partial<Document>;
16
15
  history: History;
17
16
  interaction?: any;
18
- getWalletPassEvaluator?: () => WalletPassEvaluator;
19
17
  }
20
18
  /**
21
19
  * 简单的 Storage 接口实现
@@ -144,7 +144,6 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
144
144
  getSummary(): Promise<{
145
145
  subtotal: string | number;
146
146
  total: string | number;
147
- originTotal: string | number;
148
147
  taxTitle?: string | undefined;
149
148
  totalTaxFee?: string | number | undefined;
150
149
  isPriceIncludeTax?: 0 | 1 | undefined;
@@ -115,7 +115,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
115
115
  * 获取当前的客户搜索条件
116
116
  * @returns 当前搜索条件
117
117
  */
118
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
118
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
119
119
  /**
120
120
  * 获取客户列表状态(包含滚动加载相关状态)
121
121
  * @returns 客户状态
@@ -222,7 +222,6 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
222
222
  product_id: item.product_id,
223
223
  product_variant_id: item.product_variant_id,
224
224
  quantity: item.num,
225
- is_price_include_tax: item.is_price_include_tax,
226
225
  // 商品是否含税:1;0
227
226
  is_charge_tax: item.is_charge_tax ?? 0,
228
227
  // 若商品不含税,计算得到的税费,单位(元)
@@ -247,7 +246,6 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
247
246
  },
248
247
  product_bundle: item.product_bundle.map((bundle) => {
249
248
  return {
250
- is_price_include_tax: item.is_price_include_tax,
251
249
  bundle_id: bundle.bundle_id,
252
250
  bundle_product_id: bundle.bundle_product_id,
253
251
  bundle_variant_id: bundle.bundle_variant_id,
@@ -21,7 +21,6 @@ export declare class ShopDiscountImpl extends BaseModule implements Module {
21
21
  getCurrentBookingTime(): string | null;
22
22
  private filterDiscountListByBookingTime;
23
23
  setCustomer(customer: Customer): Promise<void>;
24
- setOriginTotalAmount(amount: number): void;
25
24
  setHolders(holders: {
26
25
  form_record_id: number;
27
26
  }[]): void;
@@ -55,7 +55,6 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
55
55
  originalDiscountList: [],
56
56
  currentBookingTime: "",
57
57
  filteredDiscountList: [],
58
- orderTotalAmount: 0,
59
58
  bookingSubject: void 0
60
59
  };
61
60
  }
@@ -194,9 +193,6 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
194
193
  );
195
194
  }
196
195
  }
197
- setOriginTotalAmount(amount) {
198
- this.store.orderTotalAmount = amount;
199
- }
200
196
  // 设置holders
201
197
  setHolders(holders) {
202
198
  this.store.holders = holders;
@@ -217,7 +213,6 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
217
213
  productList,
218
214
  discountList: this.getDiscountList(),
219
215
  holders: this.store.holders || [],
220
- orderTotalAmount: this.store.orderTotalAmount || 0,
221
216
  isFormSubject: ((_a = this.store.bookingSubject) == null ? void 0 : _a.type) === "form"
222
217
  },
223
218
  options
@@ -309,7 +304,6 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
309
304
  oldDiscountList: this.getDiscountList(),
310
305
  newDiscountList: withScanList,
311
306
  holders: this.store.holders || [],
312
- orderTotalAmount: this.store.orderTotalAmount || 0,
313
307
  isFormSubject: ((_b = this.store.bookingSubject) == null ? void 0 : _b.type) === "form"
314
308
  }) || {
315
309
  isAvailable: false,
@@ -31,7 +31,6 @@ export interface ShopDiscountState {
31
31
  originalDiscountList: Discount[];
32
32
  currentBookingTime: string | null;
33
33
  filteredDiscountList: Discount[];
34
- orderTotalAmount?: number;
35
34
  bookingSubject?: {
36
35
  type?: 'form' | 'customer';
37
36
  [key: string]: any;
@@ -54,18 +54,14 @@ var isAllNormalProduct = (items) => {
54
54
  };
55
55
  var getDiscountAmount = (discount, total, price) => {
56
56
  var _a;
57
- let discountedPrice = 0;
58
57
  if (discount.tag === "good_pass") {
59
- discountedPrice = new import_decimal.default(price).minus(new import_decimal.default(price || 0)).toNumber();
60
- } else {
61
- const isFixedAmount = ((_a = discount == null ? void 0 : discount.metadata) == null ? void 0 : _a.discount_card_type) === "fixed_amount";
62
- if (isFixedAmount) {
63
- discountedPrice = Math.max(new import_decimal.default(price).minus(new import_decimal.default(discount.par_value || 0)).toNumber(), 0);
64
- } else {
65
- discountedPrice = new import_decimal.default(100).minus(discount.par_value || 0).div(100).mul(new import_decimal.default(price)).toNumber();
66
- }
58
+ return new import_decimal.default(price).minus(new import_decimal.default(price || 0)).toNumber();
59
+ }
60
+ const isFixedAmount = ((_a = discount == null ? void 0 : discount.metadata) == null ? void 0 : _a.discount_card_type) === "fixed_amount";
61
+ if (isFixedAmount) {
62
+ return Math.max(new import_decimal.default(price).minus(new import_decimal.default(discount.par_value || 0)).toNumber(), 0);
67
63
  }
68
- return discountedPrice;
64
+ return new import_decimal.default(100).minus(discount.par_value || 0).div(100).mul(new import_decimal.default(price)).toNumber();
69
65
  };
70
66
  var getDiscountListAmountTotal = (discount) => {
71
67
  return discount.reduce((acc, cur) => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.1.60",
4
+ "version": "2.1.62",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -1 +0,0 @@
1
- export * from './strategy';
@@ -1 +0,0 @@
1
- export * from "./strategy";
@@ -1,3 +0,0 @@
1
- export * from './type';
2
- export { default as WalletPassAdapter } from './walletPass';
3
- export { WalletPassEvaluator } from './walletPass/evaluator';
@@ -1,4 +0,0 @@
1
- export * from "./type";
2
- export { default as WalletPassAdapter } from "./walletPass";
3
- export { WalletPassEvaluator } from "./walletPass/evaluator";
4
- // export * from './walletPass/type';
@@ -1,28 +0,0 @@
1
- import { EvaluationResult, RuntimeContext } from '../type';
2
- export interface BusinessAdapter {
3
- /**
4
- * 适配器名称
5
- */
6
- name: string;
7
- /**
8
- * 适配器版本
9
- */
10
- version: string;
11
- /**
12
- * 准备运行时上下文
13
- * 将业务数据转换为策略引擎可识别的上下文
14
- */
15
- prepareContext(businessData: any): RuntimeContext;
16
- /**
17
- * 转换执行结果
18
- * 将策略引擎的通用结果转换为业务层需要的格式
19
- */
20
- transformResult(result: EvaluationResult, businessData?: any): any;
21
- /**
22
- * 根据业务数据重新格式化配置
23
- */
24
- formatConfig(result: EvaluationResult, businessData?: any): {
25
- result: EvaluationResult;
26
- businessData?: any;
27
- };
28
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,84 +0,0 @@
1
- import { StrategyConfig } from '../../type';
2
- import { Voucher, Product, VoucherEvaluationResult, EvaluatorInput } from './type';
3
- /**
4
- * Wallet Pass 评估器
5
- * 用于评估哪些 voucher 可以在当前订单中使用
6
- */
7
- export declare class WalletPassEvaluator {
8
- private engine;
9
- private strategyConfigs;
10
- private locale;
11
- constructor();
12
- setStrategyConfigs(strategyConfigs: StrategyConfig[]): void;
13
- getStrategyConfigs(): StrategyConfig[];
14
- setLocale(locale: string): void;
15
- getText(key: string): string;
16
- /**
17
- * 搜索券的格式
18
- * @param input 输入
19
- * @returns 返回搜索券的格式
20
- */
21
- searchVoucherFormat(input: EvaluatorInput): Voucher[];
22
- /**
23
- * 评估可用的 vouchers
24
- */
25
- evaluate(input: EvaluatorInput): VoucherEvaluationResult[];
26
- /** 检查代金券/折扣卡是否可用 并返回config */
27
- checkVoucherAvailability(input: EvaluatorInput): {
28
- isAvailable: boolean;
29
- config: {
30
- [x: string]: any;
31
- };
32
- };
33
- /**
34
- * 获取推荐券
35
- * @param input 输入
36
- * @returns 返回推荐券列表
37
- */
38
- getRecommendedVouchers(input: EvaluatorInput): {
39
- recommendedAmount: any;
40
- recommended: any[];
41
- transformList: any[];
42
- noApplicableVoucher: Voucher[];
43
- };
44
- enhanceWithReason(voucher: any): any;
45
- /**
46
- * 优惠券处理函数
47
- * @param applicableVouchers 可用的券列表
48
- * @param orderTotalAmount 订单总金额
49
- * @param products 订单商品列表
50
- * @returns 返回推荐券列表和全部列表,每个券包含 _available_max_amount 和 _unified_available_status
51
- */
52
- processVouchers(vouchers: Voucher[], orderTotalAmount: number, products: Product[]): {
53
- recommended: any[];
54
- transformList: any[];
55
- };
56
- /**
57
- * 重新计算优惠券状态(基于已选券的增量计算)
58
- * @param allVouchers 所有原始券列表
59
- * @param selectedVouchers 已选中的券列表(按选中顺序)
60
- * @param orderTotalAmount 订单总金额
61
- * @param products 订单商品列表
62
- * @returns 返回更新后的所有券列表和已选券的详细抵扣信息
63
- */
64
- recalculateVouchers(allVouchers: any[], selectedVouchers: any[], orderTotalAmount: number, products: any[]): {
65
- allWithUpdatedStatus: any[];
66
- selectedWithDetails: any[];
67
- };
68
- /**
69
- * 查找适用于指定 voucher 的策略配置
70
- */
71
- private findApplicableStrategies;
72
- /**
73
- * 检查策略中是否包含指定的 voucher ID
74
- */
75
- private checkVoucherInStrategy;
76
- /**
77
- * 递归检查条件组中是否包含 voucher ID
78
- */
79
- private checkVoucherInConditionGroup;
80
- /**
81
- * 计算适用商品的总金额和数量
82
- */
83
- private calculateApplicableProducts;
84
- }