@pisell/pisellos 1.0.78 → 1.0.80

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 (32) hide show
  1. package/dist/modules/Cart/utils/cartProduct.js +11 -11
  2. package/dist/modules/Discount/index.js +1 -1
  3. package/dist/modules/Product/index.d.ts +1 -1
  4. package/dist/modules/Rules/index.js +8 -5
  5. package/dist/plugins/request.d.ts +1 -0
  6. package/dist/solution/RegisterAndLogin/config.d.ts +87 -0
  7. package/dist/solution/RegisterAndLogin/config.js +794 -0
  8. package/dist/solution/RegisterAndLogin/index.d.ts +189 -0
  9. package/dist/solution/RegisterAndLogin/index.js +2667 -0
  10. package/dist/solution/RegisterAndLogin/types.d.ts +445 -0
  11. package/dist/solution/RegisterAndLogin/types.js +231 -0
  12. package/dist/solution/RegisterAndLogin/utils.d.ts +95 -0
  13. package/dist/solution/RegisterAndLogin/utils.js +322 -0
  14. package/dist/solution/index.d.ts +1 -0
  15. package/dist/solution/index.js +2 -1
  16. package/lib/modules/Cart/utils/cartProduct.js +8 -10
  17. package/lib/modules/Discount/index.js +1 -1
  18. package/lib/modules/Product/index.d.ts +1 -1
  19. package/lib/modules/Rules/index.js +6 -5
  20. package/lib/plugins/request.d.ts +1 -0
  21. package/lib/solution/BookingTicket/index.js +6 -0
  22. package/lib/solution/RegisterAndLogin/config.d.ts +87 -0
  23. package/lib/solution/RegisterAndLogin/config.js +596 -0
  24. package/lib/solution/RegisterAndLogin/index.d.ts +189 -0
  25. package/lib/solution/RegisterAndLogin/index.js +1593 -0
  26. package/lib/solution/RegisterAndLogin/types.d.ts +445 -0
  27. package/lib/solution/RegisterAndLogin/types.js +78 -0
  28. package/lib/solution/RegisterAndLogin/utils.d.ts +95 -0
  29. package/lib/solution/RegisterAndLogin/utils.js +279 -0
  30. package/lib/solution/index.d.ts +1 -0
  31. package/lib/solution/index.js +3 -1
  32. package/package.json +1 -1
@@ -178,18 +178,18 @@ export var getProductTotalPrice = function getProductTotalPrice(params) {
178
178
  // 如果商品有折扣,则计算折扣
179
179
  if (discounts !== null && discounts !== void 0 && discounts.length) {
180
180
  discounts.forEach(function (currentValue) {
181
+ var _currentValue$discoun;
181
182
  // 不是商品券则代表折扣卡,计算打折后的价格
182
183
  // 一个商品折扣卡只能存在于一张
183
- if (currentValue.type !== 'good_pass') {
184
- var _currentValue$discoun;
185
- price = getDiscountAmount({
186
- tag: currentValue.type,
187
- par_value: currentValue.discount.percent,
188
- metadata: {
189
- discount_card_type: currentValue === null || currentValue === void 0 || (_currentValue$discoun = currentValue.discount) === null || _currentValue$discoun === void 0 ? void 0 : _currentValue$discoun.discount_card_type
190
- }
191
- }, price, price);
192
- }
184
+ // if (currentValue.type !== 'good_pass') {
185
+ price = getDiscountAmount({
186
+ tag: currentValue.type,
187
+ par_value: currentValue.discount.percent,
188
+ metadata: {
189
+ discount_card_type: currentValue === null || currentValue === void 0 || (_currentValue$discoun = currentValue.discount) === null || _currentValue$discoun === void 0 ? void 0 : _currentValue$discoun.discount_card_type
190
+ }
191
+ }, price, price);
192
+ // }
193
193
  });
194
194
  }
195
195
  if (bundle !== null && bundle !== void 0 && bundle.length) {
@@ -204,7 +204,7 @@ export var getProductTotalPrice = function getProductTotalPrice(params) {
204
204
  return accumulator + Number(currentValue.price) * Number(currentValue.num);
205
205
  }, price);
206
206
  }
207
- return price;
207
+ return Math.max(0, price);
208
208
  };
209
209
 
210
210
  /**
@@ -268,7 +268,7 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
268
268
  }
269
269
  if (discount.appliedProductDetails) {
270
270
  return discount.appliedProductDetails.reduce(function (total, product) {
271
- var price = new Decimal((product === null || product === void 0 ? void 0 : product.amount) || 0).mul((product === null || product === void 0 ? void 0 : product.num) || 1);
271
+ var price = new Decimal((product === null || product === void 0 ? void 0 : product.amount) || 0);
272
272
  return new Decimal(total).plus(price).toNumber();
273
273
  }, 0);
274
274
  }
@@ -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
  }
@@ -411,8 +411,11 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
411
411
  return discount.id && ['good_pass', 'discount_card', 'product_discount_card'].includes(discount.tag || discount.type);
412
412
  })) : !(flatItem !== null && flatItem !== void 0 && flatItem.booking_id && flatItem !== null && flatItem !== void 0 && (_flatItem$bundleItem = flatItem.bundleItem) !== null && _flatItem$bundleItem !== void 0 && (_flatItem$bundleItem = _flatItem$bundleItem.metadata) !== null && _flatItem$bundleItem !== void 0 && _flatItem$bundleItem.custom_product_bundle_map_id);
413
413
 
414
+ // 套餐是否可用判断
415
+ var isBundleAvailable = _this3.checkPackageSubItemUsageRules(discount, flatItem);
416
+
414
417
  // 判断优惠券是否适用于该商品
415
- if (isAvailableProduct && isLimitedProduct) {
418
+ if (isAvailableProduct && isLimitedProduct && isBundleAvailable) {
416
419
  var _discountApplicabilit, _discount$metadata;
417
420
  // 记录此优惠券适用的商品
418
421
  (_discountApplicabilit = discountApplicability.get(discount.id)) === null || _discountApplicabilit === void 0 || _discountApplicabilit.push(product.id);
@@ -421,7 +424,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
421
424
  var applicableProducts = discountApplicableProducts.get(discount.id) || [];
422
425
  var discountType = discount.tag || discount.type;
423
426
  var productData = {
424
- amount: product.price,
427
+ amount: product.price * (product.num || 1),
425
428
  type: discountType,
426
429
  tag: discountType,
427
430
  discount: {
@@ -649,7 +652,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
649
652
  // 计算使用折扣卡/商品券以后,单个商品的总 total
650
653
  var targetProductTotal = getDiscountAmount(_selectedDiscount, product.price, product.price);
651
654
  var discountDetail = {
652
- amount: new Decimal(product.price).minus(new Decimal(targetProductTotal)).toNumber(),
655
+ amount: new Decimal(product.price).minus(new Decimal(targetProductTotal)).toNumber() * (product.num || 1),
653
656
  type: _selectedDiscount.tag === 'product_discount_card' ? 'discount_card' : _selectedDiscount.tag,
654
657
  discount: {
655
658
  discount_card_type: _selectedDiscount === null || _selectedDiscount === void 0 || (_selectedDiscount$met = _selectedDiscount.metadata) === null || _selectedDiscount$met === void 0 ? void 0 : _selectedDiscount$met.discount_card_type,
@@ -772,7 +775,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
772
775
  // 🔥 使用当前的 _id 作为唯一标识
773
776
  var _uniqueId = flatItem._id;
774
777
  var _discountDetail2 = {
775
- amount: new Decimal(_productOriginTotal).minus(_targetProductTotal).toNumber(),
778
+ amount: new Decimal(_productOriginTotal).minus(_targetProductTotal).toNumber() * (product.num || 1),
776
779
  type: _selectedDiscount3.tag === 'product_discount_card' ? 'discount_card' : _selectedDiscount3.tag,
777
780
  discount: {
778
781
  discount_card_type: _selectedDiscount3 === null || _selectedDiscount3 === void 0 || (_selectedDiscount3$me = _selectedDiscount3.metadata) === null || _selectedDiscount3$me === void 0 ? void 0 : _selectedDiscount3$me.discount_card_type,
@@ -797,7 +800,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
797
800
  appliedDiscountProducts.set(_selectedDiscount3.id, _appliedProducts2);
798
801
  processedItems.push(_objectSpread(_objectSpread({}, flatItem), {}, {
799
802
  total: _targetProductTotal,
800
- price: new Decimal(_productOriginTotal || 0).minus(_discountDetail2.amount).toNumber(),
803
+ price: new Decimal(_productOriginTotal || 0).minus(_discountDetail2.discount.fixed_amount).toNumber(),
801
804
  discount_list: [_discountDetail2],
802
805
  processed: true
803
806
  }));
@@ -49,6 +49,7 @@ export interface RequestOptions {
49
49
  responseType?: 'json' | 'text' | 'arraybuffer' | 'blob';
50
50
  withCredentials?: boolean;
51
51
  useCache?: boolean;
52
+ customToast?: () => void;
52
53
  }
53
54
  /**
54
55
  * 响应接口
@@ -0,0 +1,87 @@
1
+ /**
2
+ * 注册登录解决方案配置
3
+ * 根据不同渠道配置不同的接口地址和参数
4
+ */
5
+ /**
6
+ * API 配置接口
7
+ */
8
+ export interface ApiConfig {
9
+ url: string;
10
+ method: 'GET' | 'POST' | 'PUT' | 'DELETE';
11
+ transformParams?: (params: any) => any;
12
+ transformResponse?: (response: any) => any;
13
+ options?: Record<string, any>;
14
+ }
15
+ /**
16
+ * 渠道配置接口
17
+ */
18
+ export interface ChannelConfig {
19
+ sendEmailVerificationCode: ApiConfig;
20
+ sendEmailLoginCode: ApiConfig;
21
+ sendSmsRegisterCode: ApiConfig;
22
+ sendEmailRegisterLink: ApiConfig;
23
+ verifyEmailRegistrationLink: ApiConfig;
24
+ emailPasswordLogin: ApiConfig;
25
+ emailCodeRegister: ApiConfig;
26
+ phoneCodeRegister: ApiConfig;
27
+ resendEmailRegisterLink: ApiConfig;
28
+ checkEmailLinkCode: ApiConfig;
29
+ sendSmsLoginCode: ApiConfig;
30
+ phoneCodeLogin: ApiConfig;
31
+ guestLogin: ApiConfig;
32
+ checkEmailExists: ApiConfig;
33
+ checkEmailCode: ApiConfig;
34
+ checkMobileCode: ApiConfig;
35
+ phonePasswordLogin: ApiConfig;
36
+ sendPasswordResetEmail: ApiConfig;
37
+ sendPasswordResetSms: ApiConfig;
38
+ sendResetPasswordLink: ApiConfig;
39
+ checkResetPasswordCode: ApiConfig;
40
+ resetPasswordByCode: ApiConfig;
41
+ resetPasswordByEmail: ApiConfig;
42
+ resetPasswordByPhone: ApiConfig;
43
+ verifyCode: ApiConfig;
44
+ register: ApiConfig;
45
+ login: ApiConfig;
46
+ oauthLogin: ApiConfig;
47
+ validateToken: ApiConfig;
48
+ logout: ApiConfig;
49
+ getCountries: ApiConfig;
50
+ facebookLogin: ApiConfig;
51
+ appleLogin: ApiConfig;
52
+ }
53
+ /**
54
+ * 渠道配置映射
55
+ */
56
+ export declare const channelConfigMap: Record<string, ChannelConfig>;
57
+ /**
58
+ * 获取渠道配置
59
+ */
60
+ export declare function getChannelConfig(channel: string): ChannelConfig;
61
+ /**
62
+ * API 调用器类
63
+ * 负责根据配置执行 API 调用
64
+ */
65
+ export declare class ApiCaller {
66
+ private request;
67
+ private config;
68
+ constructor(request: {
69
+ get: <T = any>(url: string, data?: any, options?: any) => Promise<T>;
70
+ post: <T = any>(url: string, data?: any, options?: any) => Promise<T>;
71
+ put: <T = any>(url: string, data?: any, options?: any) => Promise<T>;
72
+ delete: <T = any>(url: string, options?: any) => Promise<T>;
73
+ }, config: ChannelConfig);
74
+ /**
75
+ * 执行 API 调用
76
+ */
77
+ call<T = any>(apiName: keyof ChannelConfig, params?: any, additionalOptions?: any): Promise<T>;
78
+ }
79
+ /**
80
+ * 创建 API 调用器
81
+ */
82
+ export declare function createApiCaller(request: {
83
+ get: <T = any>(url: string, data?: any, options?: any) => Promise<T>;
84
+ post: <T = any>(url: string, data?: any, options?: any) => Promise<T>;
85
+ put: <T = any>(url: string, data?: any, options?: any) => Promise<T>;
86
+ delete: <T = any>(url: string, options?: any) => Promise<T>;
87
+ }, channel: string): ApiCaller;