@pisell/private-materials 6.3.77 → 6.3.79

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 (139) hide show
  1. package/build/lowcode/assets-daily.json +11 -11
  2. package/build/lowcode/assets-dev.json +2 -2
  3. package/build/lowcode/assets-prod.json +11 -11
  4. package/build/lowcode/meta.js +1 -1
  5. package/build/lowcode/render/default/view.css +1 -1
  6. package/build/lowcode/render/default/view.js +1 -1
  7. package/build/lowcode/view.css +1 -1
  8. package/build/lowcode/view.js +1 -1
  9. package/es/components/Sales/Cart/index.d.ts +1 -1
  10. package/es/components/Sales/Cart/index.js +18 -3
  11. package/es/components/Sales/Cart/utils.d.ts +68 -0
  12. package/es/components/Sales/Checkout/utils.js +57 -1
  13. package/es/components/Sales/Summary/index.d.ts +2 -0
  14. package/es/components/Sales/Summary/index.js +7 -2
  15. package/es/components/Sales/Summary/utils.d.ts +10 -3
  16. package/es/components/Sales/Summary/utils.js +57 -10
  17. package/es/components/appointmentBooking/components/Cart/Item/index.js +62 -4
  18. package/es/components/appointmentBooking/components/Deposit/index.d.ts +5 -1
  19. package/es/components/appointmentBooking/components/Deposit/index.js +9 -4
  20. package/es/components/appointmentBooking/components/TimeSlicing/components/SelectDateOS.d.ts +0 -1
  21. package/es/components/appointmentBooking/locales.d.ts +366 -0
  22. package/es/components/booking/info/date/index.d.ts +0 -1
  23. package/es/components/booking/info/service2/utils.d.ts +1 -0
  24. package/es/components/booking/info/service2/utils.js +4 -4
  25. package/es/components/eftposPay/component/fail/failCustom.d.ts +0 -1
  26. package/es/components/eftposPay/locales.d.ts +330 -0
  27. package/es/components/eftposPay/pay.d.ts +0 -1
  28. package/es/components/eventBooking/components/Provider/Cart/Deposit/index.d.ts +4 -1
  29. package/es/components/eventBooking/components/Provider/Cart/Deposit/index.js +4 -1
  30. package/es/components/eventBooking/components/Provider/Cart/Item/index.js +79 -6
  31. package/es/components/eventBooking/components/Provider/Cart/Item/index.less +7 -6
  32. package/es/components/eventBooking/components/Provider/Cart/index.js +2 -7
  33. package/es/components/eventBooking/components/Provider/Content/index.d.ts +0 -1
  34. package/es/components/eventBooking/components/Provider/Content/index.less +1 -1
  35. package/es/components/eventBooking/components/Provider/Event/index.d.ts +0 -1
  36. package/es/components/eventBooking/components/Provider/Footer/index.d.ts +0 -1
  37. package/es/components/eventBooking/components/Provider/Header/index.d.ts +0 -1
  38. package/es/components/eventBooking/components/Provider/Information/index.d.ts +0 -1
  39. package/es/components/eventBooking/components/Provider/Resource/index.d.ts +0 -1
  40. package/es/components/eventBooking/components/Provider/SelectHolderModal.d.ts +0 -1
  41. package/es/components/eventBooking/components/Voucher/components/locales.d.ts +39 -0
  42. package/es/components/eventBooking/components/Voucher/index.js +1 -1
  43. package/es/components/eventBooking/components/bookingDetailModal/components/BookingOptions.d.ts +0 -1
  44. package/es/components/eventBooking/components/bookingDetailModal/components/Resource.d.ts +0 -1
  45. package/es/components/eventBooking/components/bookingDetailModal/components/Schedule.d.ts +0 -1
  46. package/es/components/index.d.ts +1 -2
  47. package/es/components/index.js +1 -2
  48. package/es/components/pay/toC/PaymentMethods/BankDeposit/index.js +1 -3
  49. package/es/components/subTotal/index.d.ts +2 -0
  50. package/es/components/subTotal/index.js +42 -20
  51. package/es/components/systemSettings/registry/components/docs/images/image-1.png +0 -0
  52. package/es/components/systemSettings/registry/components/docs/images/image-2.png +0 -0
  53. package/es/components/systemSettings/registry/components/docs/images/image-3.png +0 -0
  54. package/es/components/systemSettings/registry/components/docs/images/image-4.png +0 -0
  55. package/es/components/systemSettings/registry/components/docs/images/image-5.png +0 -0
  56. package/es/components/systemSettings/registry/components/docs/images/image-6.png +0 -0
  57. package/es/components/systemSettings/registry/components/docs/images/image-7.png +0 -0
  58. package/es/components/systemSettings/registry/components/docs/images/image-8.png +0 -0
  59. package/es/components/systemSettings/registry/components/docs/images/image.png +0 -0
  60. package/es/plus/productSelect/ProductList/gridComponents.d.ts +44 -0
  61. package/es/plus/skuOptionsSelection/components/NormalCard/index.d.ts +0 -1
  62. package/es/plus/skuOptionsSelection/components/OptionsCard/OptionItemCard.d.ts +0 -1
  63. package/es/plus/skuOptionsSelection/components/OptionsModal/index.d.ts +0 -1
  64. package/es/plus/skuOptionsSelection/types.d.ts +429 -0
  65. package/es/plus/skuOptionsSelection/utils/transformSelectorValueToValue.d.ts +4 -0
  66. package/es/plus/skuOptionsSelection/utils/transformValueToSelectorValue.d.ts +4 -0
  67. package/es/pro/NumericStepper/index.d.ts +43 -0
  68. package/es/pro/Selector/components/Card/index.d.ts +57 -0
  69. package/es/pro/Selector/components/Indicator/index.d.ts +19 -0
  70. package/es/pro/Selector/components/LayoutContainer/index.d.ts +16 -0
  71. package/es/pro/Selector/demo.d.ts +0 -1
  72. package/es/pro/Selector/hooks/usePresetProps.d.ts +24 -0
  73. package/es/pro/Selector/types.d.ts +173 -0
  74. package/lib/components/Sales/Cart/index.d.ts +1 -1
  75. package/lib/components/Sales/Cart/index.js +20 -7
  76. package/lib/components/Sales/Cart/utils.d.ts +68 -0
  77. package/lib/components/Sales/Checkout/utils.js +64 -1
  78. package/lib/components/Sales/Summary/index.d.ts +2 -0
  79. package/lib/components/Sales/Summary/index.js +8 -2
  80. package/lib/components/Sales/Summary/utils.d.ts +10 -3
  81. package/lib/components/Sales/Summary/utils.js +38 -13
  82. package/lib/components/appointmentBooking/components/Cart/Item/index.js +52 -4
  83. package/lib/components/appointmentBooking/components/Deposit/index.d.ts +5 -1
  84. package/lib/components/appointmentBooking/components/Deposit/index.js +7 -4
  85. package/lib/components/appointmentBooking/components/TimeSlicing/components/SelectDateOS.d.ts +0 -1
  86. package/lib/components/appointmentBooking/locales.d.ts +366 -0
  87. package/lib/components/booking/info/date/index.d.ts +0 -1
  88. package/lib/components/booking/info/service2/utils.d.ts +1 -0
  89. package/lib/components/booking/info/service2/utils.js +4 -4
  90. package/lib/components/eftposPay/component/fail/failCustom.d.ts +0 -1
  91. package/lib/components/eftposPay/locales.d.ts +330 -0
  92. package/lib/components/eftposPay/pay.d.ts +0 -1
  93. package/lib/components/eventBooking/components/Provider/Cart/Deposit/index.d.ts +4 -1
  94. package/lib/components/eventBooking/components/Provider/Cart/Deposit/index.js +3 -1
  95. package/lib/components/eventBooking/components/Provider/Cart/Item/index.js +77 -5
  96. package/lib/components/eventBooking/components/Provider/Cart/Item/index.less +7 -6
  97. package/lib/components/eventBooking/components/Provider/Cart/index.js +2 -2
  98. package/lib/components/eventBooking/components/Provider/Content/index.d.ts +0 -1
  99. package/lib/components/eventBooking/components/Provider/Content/index.less +1 -1
  100. package/lib/components/eventBooking/components/Provider/Event/index.d.ts +0 -1
  101. package/lib/components/eventBooking/components/Provider/Footer/index.d.ts +0 -1
  102. package/lib/components/eventBooking/components/Provider/Header/index.d.ts +0 -1
  103. package/lib/components/eventBooking/components/Provider/Information/index.d.ts +0 -1
  104. package/lib/components/eventBooking/components/Provider/Resource/index.d.ts +0 -1
  105. package/lib/components/eventBooking/components/Provider/SelectHolderModal.d.ts +0 -1
  106. package/lib/components/eventBooking/components/Voucher/components/locales.d.ts +39 -0
  107. package/lib/components/eventBooking/components/Voucher/index.js +1 -1
  108. package/lib/components/eventBooking/components/bookingDetailModal/components/BookingOptions.d.ts +0 -1
  109. package/lib/components/eventBooking/components/bookingDetailModal/components/Resource.d.ts +0 -1
  110. package/lib/components/eventBooking/components/bookingDetailModal/components/Schedule.d.ts +0 -1
  111. package/lib/components/index.d.ts +1 -2
  112. package/lib/components/index.js +0 -3
  113. package/lib/components/pay/toC/PaymentMethods/BankDeposit/index.js +1 -1
  114. package/lib/components/subTotal/index.d.ts +2 -0
  115. package/lib/components/subTotal/index.js +34 -20
  116. package/lib/components/systemSettings/registry/components/docs/images/image-1.png +0 -0
  117. package/lib/components/systemSettings/registry/components/docs/images/image-2.png +0 -0
  118. package/lib/components/systemSettings/registry/components/docs/images/image-3.png +0 -0
  119. package/lib/components/systemSettings/registry/components/docs/images/image-4.png +0 -0
  120. package/lib/components/systemSettings/registry/components/docs/images/image-5.png +0 -0
  121. package/lib/components/systemSettings/registry/components/docs/images/image-6.png +0 -0
  122. package/lib/components/systemSettings/registry/components/docs/images/image-7.png +0 -0
  123. package/lib/components/systemSettings/registry/components/docs/images/image-8.png +0 -0
  124. package/lib/components/systemSettings/registry/components/docs/images/image.png +0 -0
  125. package/lib/plus/productSelect/ProductList/gridComponents.d.ts +44 -0
  126. package/lib/plus/skuOptionsSelection/components/NormalCard/index.d.ts +0 -1
  127. package/lib/plus/skuOptionsSelection/components/OptionsCard/OptionItemCard.d.ts +0 -1
  128. package/lib/plus/skuOptionsSelection/components/OptionsModal/index.d.ts +0 -1
  129. package/lib/plus/skuOptionsSelection/types.d.ts +429 -0
  130. package/lib/plus/skuOptionsSelection/utils/transformSelectorValueToValue.d.ts +4 -0
  131. package/lib/plus/skuOptionsSelection/utils/transformValueToSelectorValue.d.ts +4 -0
  132. package/lib/pro/NumericStepper/index.d.ts +43 -0
  133. package/lib/pro/Selector/components/Card/index.d.ts +57 -0
  134. package/lib/pro/Selector/components/Indicator/index.d.ts +19 -0
  135. package/lib/pro/Selector/components/LayoutContainer/index.d.ts +16 -0
  136. package/lib/pro/Selector/demo.d.ts +0 -1
  137. package/lib/pro/Selector/hooks/usePresetProps.d.ts +24 -0
  138. package/lib/pro/Selector/types.d.ts +173 -0
  139. package/package.json +3 -3
@@ -0,0 +1,173 @@
1
+ /// <reference types="react" />
2
+ export interface ExprRule {
3
+ [key: string]: any;
4
+ }
5
+ export interface RuleConfig {
6
+ autoValidate?: boolean;
7
+ required?: 0 | 1;
8
+ min?: number;
9
+ max?: number;
10
+ mutex?: Array<Array<OptionKey>>;
11
+ customValidator?: (value: SelectionValue) => Promise<void>;
12
+ }
13
+ export interface GroupItem {
14
+ id?: number;
15
+ title?: string;
16
+ mode?: 'single' | 'multiple';
17
+ valueType?: 'primitive' | 'object';
18
+ preserve?: boolean;
19
+ fieldNames?: {
20
+ label?: string;
21
+ value?: string;
22
+ cover?: string;
23
+ };
24
+ ruleConfig?: RuleConfig;
25
+ dataSource?: OptionItem[];
26
+ }
27
+ export interface OptionItem {
28
+ id?: number;
29
+ title?: string;
30
+ label?: string;
31
+ value?: OptionKey;
32
+ cover?: string;
33
+ groups?: GroupItem[];
34
+ disabled?: boolean;
35
+ ruleConfig?: {
36
+ min?: number;
37
+ max?: number;
38
+ };
39
+ [key: string]: any;
40
+ }
41
+ export declare type OptionKey = number | string;
42
+ /** 原始值类型:单选时为id,多选时为id[] */
43
+ export declare type SelectionValuePrimitive<T = OptionKey> = T | T[];
44
+ /** 复杂对象值类型:包含id、数量等额外信息 */
45
+ export interface SelectionValueObject<T = OptionKey> {
46
+ value?: T;
47
+ quantity?: number;
48
+ [key: string]: any;
49
+ }
50
+ /** 单选值类型 */
51
+ export declare type SelectionValueSingle<T = OptionKey> = T | SelectionValueObject<T>;
52
+ /** 多选值类型 */
53
+ export declare type SelectionValueMultiple<T = OptionKey> = T[] | SelectionValueObject<T>[];
54
+ /** 选择器值类型 */
55
+ export declare type SelectionValue<T = OptionKey> = SelectionValueSingle<T> | SelectionValueMultiple<T>;
56
+ export declare type RenderItemProps = {
57
+ dataSource: OptionItem;
58
+ actions: any;
59
+ optionItemValue?: any;
60
+ indicator: React.ReactNode;
61
+ numberSelector: React.ReactNode;
62
+ values: any;
63
+ quantityInfo: {
64
+ maxReached: boolean;
65
+ remainingCount: number;
66
+ selectedCount: number;
67
+ };
68
+ };
69
+ export declare type ItemProps = {
70
+ layout?: 'vertical' | 'horizontal';
71
+ renderContent?: (props: {
72
+ dataSource: OptionItem;
73
+ }) => React.ReactNode;
74
+ styles?: {
75
+ [key: string]: React.CSSProperties;
76
+ };
77
+ [key: string]: any;
78
+ };
79
+ export declare type LayoutType = 'antdGrid' | 'custom';
80
+ export declare type LayoutConfig = {
81
+ type?: LayoutType;
82
+ className?: string;
83
+ containerStyle?: React.CSSProperties;
84
+ columns?: number;
85
+ gutter?: number | object | Array<number>;
86
+ align?: 'top' | 'middle' | 'bottom' | 'stretch';
87
+ justify?: 'start' | 'end' | 'center' | 'space-between' | 'space-around';
88
+ wrap?: boolean;
89
+ colConfig?: {
90
+ [key: string]: any;
91
+ };
92
+ };
93
+ export interface PresetConfig {
94
+ variant?: '1' | '2' | '3' | '4' | '5';
95
+ }
96
+ export declare type ItemLayout = 'vertical' | 'horizontal';
97
+ export declare type SelectorVariant = 'default' | 'select' | 'card' | 'media';
98
+ export declare type HeaderProps = {
99
+ visible?: boolean;
100
+ style?: React.CSSProperties;
101
+ title?: {
102
+ visible?: boolean;
103
+ text?: React.ReactNode;
104
+ style?: React.CSSProperties;
105
+ };
106
+ icon?: {
107
+ visible?: boolean;
108
+ icon?: React.ReactNode;
109
+ style?: React.CSSProperties;
110
+ };
111
+ tip?: {
112
+ visible?: boolean;
113
+ text?: React.ReactNode;
114
+ style?: React.CSSProperties;
115
+ };
116
+ renderExtra?: (props: {
117
+ dataSource: OptionItem;
118
+ values: SelectionValue;
119
+ }) => React.ReactNode;
120
+ };
121
+ export interface SelectorProps<T = OptionKey> extends GroupItem {
122
+ className?: string;
123
+ value?: SelectionValue<T>;
124
+ defaultValue?: SelectionValue<T>;
125
+ onChange?: (value: SelectionValue<T>) => void;
126
+ onClear?: () => void;
127
+ disabled?: boolean;
128
+ variant?: SelectorVariant;
129
+ itemLayout?: ItemLayout;
130
+ preset?: PresetConfig;
131
+ layout?: LayoutConfig;
132
+ renderItem?: (props: RenderItemProps) => React.ReactNode;
133
+ itemProps?: ItemProps;
134
+ indicatorProps?: {
135
+ show?: boolean;
136
+ variant?: 'outlined' | 'filled';
137
+ render?: (props: {
138
+ option: OptionItem;
139
+ selected: boolean;
140
+ disabled: boolean;
141
+ actions: any;
142
+ }) => React.ReactNode;
143
+ [key: string]: any;
144
+ };
145
+ showStepper?: true | false | 'auto';
146
+ stepperProps?: {
147
+ size?: 'small' | 'middle' | 'large';
148
+ shape?: 'round' | 'square';
149
+ };
150
+ style?: React.CSSProperties;
151
+ /**
152
+ * @deprecated
153
+ */
154
+ titleProps?: HeaderProps;
155
+ headerProps?: HeaderProps;
156
+ }
157
+ export interface SelectorGroupProps {
158
+ allowedValuesPolicy?: 'relaxed' | 'strict';
159
+ className?: string;
160
+ customScrollParent?: HTMLElement | string;
161
+ dataSource: GroupItem[];
162
+ defaultValue?: Record<string, SelectionValue>;
163
+ linkageRules?: ExprRule[] | Record<string, any>;
164
+ onChange?: (values: Record<string, SelectionValue>) => void;
165
+ preserve?: boolean;
166
+ tabProps?: {
167
+ visible?: boolean;
168
+ };
169
+ style?: React.CSSProperties;
170
+ value?: Record<string, SelectionValue>;
171
+ scrollToFirstError?: boolean;
172
+ [key: string]: any;
173
+ }
@@ -13,7 +13,7 @@ interface CartContextType {
13
13
  createCartItemFromEvent: (eventItem: any) => CartItem;
14
14
  createCartItemFromHolder: (holderItem: any) => CartItem;
15
15
  addToCart: () => void;
16
- updateCartItem: (cartItem: CartItem) => CartItem;
16
+ updateCartItem: (cartItem: CartItem, updateType?: 'deposit') => CartItem;
17
17
  deleteCartItem: (cartItem: CartItem) => void;
18
18
  clickCartItem: (cartItem: CartItem) => void;
19
19
  updateCurrentCartItem: (cartItem: Partial<CartItem>) => void;
@@ -241,10 +241,7 @@ var CartProvider = ({ children }) => {
241
241
  const endDateInfo = (_g = (_f = eventItem == null ? void 0 : eventItem.eventDetail) == null ? void 0 : _f.selectDate) == null ? void 0 : _g.endDateInfo;
242
242
  const endTime = (_j = (_i = (_h = endDateInfo == null ? void 0 : endDateInfo.times) == null ? void 0 : _h.slice(-1)) == null ? void 0 : _i[0]) == null ? void 0 : _j.end_at;
243
243
  const num = 1;
244
- const { price, totalPrice, originTotal, is_charge_tax } = (0, import_utils3.handleProductInfo)(
245
- eventDetail,
246
- num
247
- );
244
+ const { price, totalPrice, originTotal, is_charge_tax } = (0, import_utils3.handleProductInfo)(eventDetail, num);
248
245
  const transformProduct = (_temp) => {
249
246
  var _a2;
250
247
  if (!((_a2 = _temp == null ? void 0 : _temp.variant) == null ? void 0 : _a2.length)) {
@@ -305,6 +302,7 @@ var CartProvider = ({ children }) => {
305
302
  event_unique_identifier: _id
306
303
  // 传递给接口用于商品可用性检测的比对
307
304
  },
305
+ _eventDetail: eventDetail,
308
306
  _productDetail: eventDetail.productDetail,
309
307
  _productOrigin: transformProduct(
310
308
  ((_p = eventDetail == null ? void 0 : eventDetail.productDetail) == null ? void 0 : _p.origin) || bookingOptionData
@@ -337,9 +335,24 @@ var CartProvider = ({ children }) => {
337
335
  });
338
336
  }
339
337
  };
340
- const updateCartItem = (cartItem) => {
341
- const newCartItems = getCurrentData().cartData.cartItems.map(
342
- (item) => item._id === cartItem._id ? cartItem : item
338
+ const updateCartItem = (cartItem, updateType) => {
339
+ var _a, _b, _c;
340
+ let newCartItems = (_c = (_b = (_a = getCurrentData()) == null ? void 0 : _a.cartData) == null ? void 0 : _b.cartItems) == null ? void 0 : _c.map(
341
+ (item) => {
342
+ if (item._id === cartItem._id) {
343
+ const _tempCartItem = { ...cartItem || {} };
344
+ if (updateType === "deposit") {
345
+ const eventDetail = _tempCartItem == null ? void 0 : _tempCartItem._eventDetail;
346
+ if (eventDetail) {
347
+ const num = (_tempCartItem == null ? void 0 : _tempCartItem.num) || 1;
348
+ const deposit = (0, import_utils3.handleProductDeposit)(_tempCartItem, eventDetail, num);
349
+ _tempCartItem.deposit = deposit;
350
+ }
351
+ }
352
+ return _tempCartItem;
353
+ }
354
+ return item;
355
+ }
343
356
  );
344
357
  setCartData({
345
358
  cartItems: newCartItems
@@ -0,0 +1,68 @@
1
+ import Decimal from 'decimal.js';
2
+ import { ICalculatePriceParams } from './types';
3
+ export declare const handleProductInfo: (eventDetail: any, num: number) => {
4
+ price: number;
5
+ totalPrice: number;
6
+ originTotal: any;
7
+ is_charge_tax: any;
8
+ };
9
+ /**
10
+ * 获取商品价格
11
+ */
12
+ export declare const getPrice: (params: ICalculatePriceParams) => number;
13
+ /**
14
+ * 获取商品总价
15
+ * @description 当前总价计算基于商品数量为1
16
+ * @param item 商品
17
+ * @returns 商品总价
18
+ */
19
+ export declare const getTotalPrice: (params: ICalculatePriceParams) => number;
20
+ /**
21
+ * 获取商品原始总价
22
+ * @description 当前总价计算基于商品数量为1
23
+ * @param item 商品
24
+ * @returns 商品原始总价
25
+ */
26
+ export declare const getOriginTotalPrice: (params: ICalculatePriceParams) => number | undefined;
27
+ export declare const handleCartItemOrigin: (cartItem: any, eventDetail: any) => any;
28
+ export declare const formatBundleToOrigin: (bundle: any) => any;
29
+ export declare const formatOptionsToOrigin: (options: any) => any;
30
+ export declare const handleProductDeposit: (cartItem: any, eventDetail: any, num: number) => {
31
+ total: number;
32
+ protocols: any;
33
+ } | null;
34
+ /**
35
+ * 获取商品定金
36
+ * @description 定金基于商品售价来算,最终乘商品数量
37
+ * 1、如果套餐主商品有定金规则,则定金为:(套餐商品总售价 * 定金百分比 + 定金固定金额)* 商品数量
38
+ * 2、如果套餐主商品没有定金规则,子商品有定金规则,则定金为:(套餐子商品售价 * 套餐子商品定金百分比 + 套餐子商品定金固定金额)* 商品数量,最终将所有子商品定金相加
39
+ * 3、普通商品/单规格商品/组合规则商品,定金规则:(商品总售价 * 定金百分比 + 定金固定金额)* 商品数量
40
+ * @param params 参数
41
+ * @returns 商品定金
42
+ */
43
+ export declare const getProductDeposit: (params: {
44
+ cartItem: any;
45
+ product: any;
46
+ bundle?: any;
47
+ options?: any;
48
+ num?: number;
49
+ }) => {
50
+ total: number;
51
+ protocols: any;
52
+ } | null;
53
+ /**
54
+ * 计算商品定金
55
+ * @param params 参数
56
+ * @returns 商品定金
57
+ */
58
+ export declare const calculateProductDeposit: (params: {
59
+ depositData: {
60
+ deposit_fixed?: string;
61
+ deposit_percentage?: string;
62
+ };
63
+ total: string | number;
64
+ num: number;
65
+ }) => {
66
+ result: boolean;
67
+ depositTotal: Decimal;
68
+ };
@@ -1,6 +1,8 @@
1
+ var __create = Object.create;
1
2
  var __defProp = Object.defineProperty;
2
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
4
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
7
  var __export = (target, all) => {
6
8
  for (var name in all)
@@ -14,6 +16,14 @@ var __copyProps = (to, from, except, desc) => {
14
16
  }
15
17
  return to;
16
18
  };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
17
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
28
 
19
29
  // src/components/Sales/Checkout/utils.ts
@@ -25,6 +35,7 @@ __export(utils_exports, {
25
35
  getFormParams: () => getFormParams
26
36
  });
27
37
  module.exports = __toCommonJS(utils_exports);
38
+ var import_decimal = __toESM(require("decimal.js"));
28
39
  var formatProductOption = (option) => {
29
40
  if (!option) {
30
41
  return [];
@@ -57,10 +68,62 @@ var formatProductBundle = (bundle) => {
57
68
  var formatBookings = (list) => {
58
69
  let bookings = [];
59
70
  bookings = list.map((item) => {
60
- return item._originData;
71
+ var _a, _b, _c;
72
+ const newOriginData = { ...item._originData || {} };
73
+ const product = (newOriginData == null ? void 0 : newOriginData.product) || {};
74
+ const discount_list = product == null ? void 0 : product.discount_list;
75
+ const main_product_discount = discount_list == null ? void 0 : discount_list.filter(
76
+ (d) => {
77
+ var _a2;
78
+ return !((_a2 = d.metadata) == null ? void 0 : _a2.custom_product_bundle_map_id);
79
+ }
80
+ );
81
+ if (main_product_discount == null ? void 0 : main_product_discount.length) {
82
+ product.metadata = {
83
+ product_discount_difference: handleProductDiscountDifference([
84
+ main_product_discount
85
+ ])
86
+ };
87
+ }
88
+ console.log("main_product_discount", main_product_discount);
89
+ if ((_a = product == null ? void 0 : product.product_bundle) == null ? void 0 : _a.length) {
90
+ product.product_bundle = (_c = (_b = product == null ? void 0 : product.product_bundle) == null ? void 0 : _b.map) == null ? void 0 : _c.call(_b, (v) => {
91
+ var _a2, _b2, _c2, _d;
92
+ const bundle_item_discount = [];
93
+ (_b2 = (_a2 = item == null ? void 0 : item.selectedBundle) == null ? void 0 : _a2.forEach) == null ? void 0 : _b2.call(_a2, (s) => {
94
+ if ((s == null ? void 0 : s.id) === (v == null ? void 0 : v.bundle_id) && (s == null ? void 0 : s.group_id) === (v == null ? void 0 : v.bundle_group_id) && (s == null ? void 0 : s._bundle_product_id) === (v == null ? void 0 : v.bundle_product_id)) {
95
+ bundle_item_discount.push(...(s == null ? void 0 : s.discount_list) || []);
96
+ }
97
+ });
98
+ console.log("bundle_item_discount", bundle_item_discount);
99
+ const newBundleItem = { ...v || {} };
100
+ if (bundle_item_discount == null ? void 0 : bundle_item_discount.length) {
101
+ newBundleItem.metadata = {
102
+ custom_product_bundle_map_id: (_d = (_c2 = bundle_item_discount == null ? void 0 : bundle_item_discount[0]) == null ? void 0 : _c2.metadata) == null ? void 0 : _d.custom_product_bundle_map_id,
103
+ product_discount_difference: handleProductDiscountDifference(bundle_item_discount)
104
+ };
105
+ }
106
+ return newBundleItem;
107
+ });
108
+ }
109
+ newOriginData.product = product;
110
+ return newOriginData;
61
111
  });
112
+ console.log("bookings>>>>", bookings);
62
113
  return bookings;
63
114
  };
115
+ var handleProductDiscountDifference = (discount_list) => {
116
+ const product_discount_difference = discount_list == null ? void 0 : discount_list.reduce(
117
+ (pre, cur) => {
118
+ var _a;
119
+ return pre.plus(
120
+ new import_decimal.default(((_a = cur == null ? void 0 : cur.metadata) == null ? void 0 : _a.product_discount_difference) || 0)
121
+ );
122
+ },
123
+ new import_decimal.default(0)
124
+ );
125
+ return product_discount_difference.toNumber();
126
+ };
64
127
  var formatValues = (params) => {
65
128
  var _a, _b;
66
129
  const { state, otherValue, platform, excludeDisabled, extra } = params;
@@ -7,6 +7,8 @@ interface SummaryContextType {
7
7
  taxTitle?: string;
8
8
  totalTaxFee?: string;
9
9
  isPriceIncludeTax?: 0 | 1;
10
+ taxRate?: number;
11
+ surcharge?: any;
10
12
  deposit?: {
11
13
  total: string;
12
14
  protocols: any[];
@@ -40,6 +40,7 @@ var import_Cart = require("../Cart");
40
40
  var import_utils = require("./utils");
41
41
  var import_Init = require("../Init");
42
42
  var import_serve = require("./serve");
43
+ var import_useEngineContext = require("../../../hooks/useEngineContext");
43
44
  var defaultState = {};
44
45
  var SummaryContext = (0, import_react.createContext)(
45
46
  void 0
@@ -47,15 +48,18 @@ var SummaryContext = (0, import_react.createContext)(
47
48
  var SummaryProvider = ({
48
49
  children
49
50
  }) => {
51
+ const pisellos = (0, import_useEngineContext.usePisellOS)();
50
52
  const { cartData } = (0, import_Cart.useCart)();
51
53
  const { initData } = (0, import_Init.useInit)();
52
54
  const [isAgreeDepositPolicy, setIsAgreeDepositPolicy] = (0, import_react.useState)(false);
55
+ const summaryModule = pisellos.getModule("summary");
53
56
  const summaryData = (0, import_react.useMemo)(() => {
54
57
  return (0, import_utils.calculatePriceDetails)(
55
58
  (initData == null ? void 0 : initData.shop) || {},
56
- cartData.cartItems
59
+ cartData.cartItems,
60
+ summaryModule
57
61
  );
58
- }, [cartData.cartItems, initData == null ? void 0 : initData.shop]);
62
+ }, [cartData.cartItems, initData == null ? void 0 : initData.shop, summaryModule]);
59
63
  const contextValue = {
60
64
  // 商品总价
61
65
  subtotal: summaryData.subtotal,
@@ -64,6 +68,8 @@ var SummaryProvider = ({
64
68
  taxTitle: summaryData.taxTitle,
65
69
  totalTaxFee: summaryData.totalTaxFee,
66
70
  isPriceIncludeTax: summaryData.isPriceIncludeTax,
71
+ taxRate: summaryData.taxRate,
72
+ surcharge: summaryData.surcharge,
67
73
  deposit: summaryData.deposit,
68
74
  isAgreeDepositPolicy,
69
75
  setIsAgreeDepositPolicy,
@@ -1,4 +1,3 @@
1
- import Decimal from 'decimal.js';
2
1
  interface CartItem {
3
2
  price: number | string;
4
3
  quantity?: number;
@@ -10,6 +9,8 @@ interface PriceDetail {
10
9
  taxTitle?: string;
11
10
  totalTaxFee?: string;
12
11
  isPriceIncludeTax?: 0 | 1;
12
+ taxRate?: number;
13
+ surcharge?: any;
13
14
  deposit?: {
14
15
  total: string;
15
16
  protocols: any[];
@@ -22,6 +23,12 @@ interface PriceDetail {
22
23
  * @returns 商品总价字符串,保留2位小数
23
24
  */
24
25
  export declare const calculateSubtotal: (items: CartItem[]) => string;
26
+ /**
27
+ * @description: 将购物车数据格式化成summaryModule需要的格式
28
+ * @param {any} items 购物车数据
29
+ * @return {*}
30
+ */
31
+ export declare const formatCartsToSummaryModule: (items: any[]) => any[];
25
32
  /**
26
33
  * @title: 单个商品的税费
27
34
  * @description:
@@ -30,14 +37,14 @@ export declare const calculateSubtotal: (items: CartItem[]) => string;
30
37
  * @return {*}
31
38
  * @Author: xiangfeng.xue
32
39
  */
33
- export declare const calculateTaxFee: (shopInfo: any, items: CartItem[]) => Decimal | "0.00";
40
+ export declare const calculateTaxFee: (shopInfo: any, items: CartItem[], summaryModule: any) => any;
34
41
  /**
35
42
  * 计算所有价格明细
36
43
  * @param items - 购物车商品数组
37
44
  * @param options - 其他费用配置
38
45
  * @returns 价格明细对象
39
46
  */
40
- export declare const calculatePriceDetails: (shopInfo: any, items: CartItem[]) => PriceDetail;
47
+ export declare const calculatePriceDetails: (shopInfo: any, items: CartItem[], summaryModule: any) => PriceDetail;
41
48
  /**
42
49
  * @title: 计算定金
43
50
  * @param items - 购物车商品数组
@@ -32,7 +32,8 @@ __export(utils_exports, {
32
32
  calculateDeposit: () => calculateDeposit,
33
33
  calculatePriceDetails: () => calculatePriceDetails,
34
34
  calculateSubtotal: () => calculateSubtotal,
35
- calculateTaxFee: () => calculateTaxFee
35
+ calculateTaxFee: () => calculateTaxFee,
36
+ formatCartsToSummaryModule: () => formatCartsToSummaryModule
36
37
  });
37
38
  module.exports = __toCommonJS(utils_exports);
38
39
  var import_decimal = __toESM(require("decimal.js"));
@@ -45,25 +46,46 @@ var calculateSubtotal = (items) => {
45
46
  }, new import_decimal.default(0));
46
47
  return subtotal.toFixed(2);
47
48
  };
48
- var calculateTaxFee = (shopInfo, items) => {
49
+ var formatCartsToSummaryModule = (items) => {
50
+ if (!Array.isArray(items) || !(items == null ? void 0 : items.length)) return [];
51
+ return items.map((item) => {
52
+ const { selectedBundle, selectedOptions, ...rest } = item;
53
+ return {
54
+ ...rest,
55
+ bundle: selectedBundle || [],
56
+ option: selectedOptions || []
57
+ };
58
+ });
59
+ };
60
+ var calculateTaxFee = (shopInfo, items, summaryModule) => {
49
61
  if (!(items == null ? void 0 : items.length)) {
50
62
  return "0.00";
51
63
  }
52
64
  const { is_price_include_tax, tax_rate } = shopInfo || {};
53
65
  console.log("shopInfo>>>", is_price_include_tax, tax_rate);
54
- const totalTaxFee = items.reduce((sum, item) => {
55
- const price = new import_decimal.default(item.total || 0);
56
- const taxRate = new import_decimal.default(tax_rate || 0).div(100);
57
- const productTaxRate = price.times(taxRate).times((item == null ? void 0 : item.is_charge_tax) || 0).div(taxRate.times(is_price_include_tax || 0).plus(1));
58
- return sum.plus(productTaxRate);
59
- }, new import_decimal.default(0));
66
+ const subtotal = new import_decimal.default(calculateSubtotal(items));
67
+ const totalTax = summaryModule.getTaxforUtils(
68
+ items,
69
+ {
70
+ tax_rate: Number(tax_rate),
71
+ is_price_include_tax: Number(is_price_include_tax || 0)
72
+ },
73
+ subtotal
74
+ );
75
+ const totalTaxFee = totalTax == null ? void 0 : totalTax.tax;
60
76
  return totalTaxFee;
61
77
  };
62
- var calculatePriceDetails = (shopInfo, items) => {
78
+ var calculatePriceDetails = (shopInfo, items, summaryModule) => {
63
79
  const subtotal = new import_decimal.default(calculateSubtotal(items));
64
- const totalTaxFee = new import_decimal.default(calculateTaxFee(shopInfo, items));
65
- console.log("totalTaxFee", totalTaxFee.toFixed(2));
66
- const total = (shopInfo == null ? void 0 : shopInfo.is_price_include_tax) ? subtotal : subtotal.plus(totalTaxFee);
80
+ const _carts = formatCartsToSummaryModule(items);
81
+ const surcharge = summaryModule.getSurchargeforUtils(_carts);
82
+ const surchargeFee = new import_decimal.default((surcharge == null ? void 0 : surcharge.surchargeAmount) || 0);
83
+ const totalTaxFee = new import_decimal.default(
84
+ calculateTaxFee(shopInfo, _carts, summaryModule)
85
+ );
86
+ const taxRate = new import_decimal.default((shopInfo == null ? void 0 : shopInfo.tax_rate) || 0).div(100);
87
+ let total = (shopInfo == null ? void 0 : shopInfo.is_price_include_tax) ? subtotal : subtotal.plus(totalTaxFee);
88
+ total = total.plus(surchargeFee);
67
89
  const deposit = calculateDeposit(items);
68
90
  return {
69
91
  subtotal: subtotal.toFixed(2),
@@ -71,6 +93,8 @@ var calculatePriceDetails = (shopInfo, items) => {
71
93
  taxTitle: shopInfo == null ? void 0 : shopInfo.tax_title,
72
94
  totalTaxFee: totalTaxFee.toFixed(2),
73
95
  isPriceIncludeTax: shopInfo == null ? void 0 : shopInfo.is_price_include_tax,
96
+ taxRate: taxRate.toNumber(),
97
+ surcharge,
74
98
  deposit
75
99
  };
76
100
  };
@@ -104,5 +128,6 @@ var calculateDeposit = (items) => {
104
128
  calculateDeposit,
105
129
  calculatePriceDetails,
106
130
  calculateSubtotal,
107
- calculateTaxFee
131
+ calculateTaxFee,
132
+ formatCartsToSummaryModule
108
133
  });
@@ -36,12 +36,12 @@ var import_react = __toESM(require("react"));
36
36
  var import_utils = require("@pisell/utils");
37
37
  var import_shoppingCart = __toESM(require("../../../../shoppingCart"));
38
38
  var import_ContinueButton = __toESM(require("../ContinueButton"));
39
+ var import__ = require("../../../../../index");
39
40
  var import_hooks = require("../../../hooks");
40
41
  var import_context = require("../../../context");
41
42
  var import_hooks2 = require("../../../hooks");
42
43
  var import_utils2 = require("../../../utils");
43
44
  var import_Voucher = __toESM(require("../../Voucher"));
44
- var import_Total = __toESM(require("./Total"));
45
45
  var import_Deposit = __toESM(require("../../Deposit"));
46
46
  var import_utils3 = require("../utils");
47
47
  var import_index = require("./index.less");
@@ -64,8 +64,8 @@ var CartItem = ({ onNext, renderContactInfo }) => {
64
64
  const { isFormSubject, bookingSubject, isRetailTemplate } = (0, import_hooks2.useAppointmentBookingSetting)();
65
65
  const { isLogin } = (0, import_hooks2.useAppointmentBookingLogin)();
66
66
  const utils = (0, import_hooks2.contextUtils)();
67
- const { businessUtils } = utils;
68
- const { deposit } = summary;
67
+ const { businessUtils, translation } = utils;
68
+ const { taxTitle, totalTaxFee, isPriceIncludeTax, total, deposit } = summary;
69
69
  const currentUser = (0, import_react.useMemo)(() => {
70
70
  return (0, import_utils2.formatCurrentUser)(utils) || {};
71
71
  }, []);
@@ -178,6 +178,47 @@ var CartItem = ({ onNext, renderContactInfo }) => {
178
178
  return carts;
179
179
  }
180
180
  }, [carts, currentSelectedResources, currentStepParams == null ? void 0 : currentStepParams.key, isErrorHolder]);
181
+ const subTotalList = (0, import_react.useMemo)(() => {
182
+ const hideDeposit = (carts == null ? void 0 : carts.length) === 0 || !(deposit == null ? void 0 : deposit.hasDeposit);
183
+ const surcharge = ((summary == null ? void 0 : summary.surcharge) || []).map(
184
+ (d, index) => {
185
+ return {
186
+ key: `custom_surcharge_${index}`,
187
+ label: translation(d == null ? void 0 : d.name),
188
+ value: d.amount
189
+ };
190
+ }
191
+ );
192
+ return [
193
+ {
194
+ key: "deposit",
195
+ value: deposit == null ? void 0 : deposit.total,
196
+ label: import_utils.locales.getText("pisell2.appointment.deposit"),
197
+ hidden: hideDeposit
198
+ },
199
+ {
200
+ key: "sub_total",
201
+ value: summary == null ? void 0 : summary.subtotal
202
+ },
203
+ ...surcharge,
204
+ {
205
+ key: "tax",
206
+ value: totalTaxFee,
207
+ hidden: Number(totalTaxFee) <= 0,
208
+ tax: {
209
+ rate: Number((summary == null ? void 0 : summary.taxRate) / 100),
210
+ is_price_include_tax: isPriceIncludeTax,
211
+ title: taxTitle
212
+ }
213
+ },
214
+ {
215
+ key: "custom_total",
216
+ value: total,
217
+ label: import_utils.locales.getText("pisell2.event.total"),
218
+ bold: !!hideDeposit
219
+ }
220
+ ];
221
+ }, [total, summary, carts == null ? void 0 : carts.length]);
181
222
  return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(
182
223
  "div",
183
224
  {
@@ -209,7 +250,14 @@ var CartItem = ({ onNext, renderContactInfo }) => {
209
250
  onChange: (e, type, key) => handleClickCard(e, type, key)
210
251
  }
211
252
  )),
212
- /* @__PURE__ */ import_react.default.createElement("div", { className: "appointment-footer" }, hasGoodPassApp || hasDiscountCardApp ? /* @__PURE__ */ import_react.default.createElement(import_Voucher.default, { currentUser, products: carts }) : null, /* @__PURE__ */ import_react.default.createElement(import_Total.default, null), (carts == null ? void 0 : carts.length) > 0 && (deposit == null ? void 0 : deposit.hasDeposit) ? /* @__PURE__ */ import_react.default.createElement(import_Deposit.default, null) : null, /* @__PURE__ */ import_react.default.createElement(import_ContinueButton.default, { onNext }))
253
+ /* @__PURE__ */ import_react.default.createElement("div", { className: "appointment-footer" }, hasGoodPassApp || hasDiscountCardApp ? /* @__PURE__ */ import_react.default.createElement(import_Voucher.default, { currentUser, products: carts }) : null, /* @__PURE__ */ import_react.default.createElement(
254
+ import__.SubTotal,
255
+ {
256
+ list: subTotalList,
257
+ style: { padding: 0 },
258
+ children: !!((carts == null ? void 0 : carts.length) > 0 && (deposit == null ? void 0 : deposit.hasDeposit)) ? /* @__PURE__ */ import_react.default.createElement(import_Deposit.default, { showTitle: false }) : null
259
+ }
260
+ ), /* @__PURE__ */ import_react.default.createElement(import_ContinueButton.default, { onNext }))
213
261
  ));
214
262
  };
215
263
  var Item_default = CartItem;
@@ -1,9 +1,13 @@
1
1
  import './index.less';
2
+ interface DepositProps {
3
+ showTitle?: boolean;
4
+ }
2
5
  export declare const DepositContent: (props: {
3
6
  isAgreeDepositPolicy: boolean;
4
7
  setIsAgreeDepositPolicy: (value: boolean) => void;
5
8
  deposit: any;
6
9
  depositProtocolRequest?: any;
10
+ showTitle?: boolean | undefined;
7
11
  }) => JSX.Element;
8
- declare const Deposit: () => JSX.Element;
12
+ declare const Deposit: (props: DepositProps) => JSX.Element;
9
13
  export default Deposit;