@pisell/private-materials 6.3.111 → 6.3.113

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 (111) 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/index.js +1 -1
  5. package/build/lowcode/meta.js +1 -1
  6. package/build/lowcode/preview.js +4 -4
  7. package/build/lowcode/render/default/view.js +4 -4
  8. package/build/lowcode/view.js +4 -4
  9. package/es/components/booking/addons/model.d.ts +10 -1
  10. package/es/components/booking/components/footer/utils.js +4 -4
  11. package/es/components/booking/forms/model.d.ts +10 -1
  12. package/es/components/booking/forms/sendModal/useSendModal.d.ts +0 -1
  13. package/es/components/booking/info/clientVariant/hooks/useIsLowSpeedNetwork.d.ts +0 -1
  14. package/es/components/booking/info/hooks/useInfoHolder.d.ts +0 -1
  15. package/es/components/booking/info/model.d.ts +10 -1
  16. package/es/components/booking/info/service/addService/utils.d.ts +1 -1
  17. package/es/components/booking/info2/service/addService/utils.d.ts +1 -1
  18. package/es/components/booking/info2/service/editService/index.js +36 -6
  19. package/es/components/booking/info2/service/editService/utils.d.ts +15 -0
  20. package/es/components/booking/info2/service/editService/utils.js +76 -0
  21. package/es/components/booking/model.d.ts +9 -1
  22. package/es/components/booking/notes/model.d.ts +10 -1
  23. package/es/components/booking/payments/model.d.ts +10 -1
  24. package/es/components/booking/utils.d.ts +2 -2
  25. package/es/components/eftpos/hooks.d.ts +0 -1
  26. package/es/components/eftposPay/amount.d.ts +1 -1
  27. package/es/components/eftposPay/device.d.ts +1 -1
  28. package/es/components/eftposPay/hooks.d.ts +1 -1
  29. package/es/components/eftposPay/store/index.d.ts +4 -4
  30. package/es/components/eftposPay/tyro/hooks.d.ts +0 -1
  31. package/es/components/eventBooking/components/ErrorTip/index.d.ts +0 -1
  32. package/es/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/CalenDateStatus/index.d.ts +0 -1
  33. package/es/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/CalenDateWeek/CallToBook/index.d.ts +0 -1
  34. package/es/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/CalenDateWeek/WeekItem/index.d.ts +0 -1
  35. package/es/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/CalenDateWeek/index.d.ts +0 -1
  36. package/es/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/Item/DayItem/index.d.ts +0 -1
  37. package/es/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/Item/index.d.ts +0 -1
  38. package/es/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/Status/index.d.ts +0 -1
  39. package/es/components/pay/toC/PaymentMethods/StripePay/Stripe/Finish/index.d.ts +0 -1
  40. package/es/components/pay/toC/PaymentMethods/StripePay/Stripe/StripeSDK/index.d.ts +0 -1
  41. package/es/components/pay/toC/PaymentMethods/StripePay/Stripe/components/PageLoading/index.d.ts +0 -1
  42. package/es/components/pay/toC/PaymentMethods/WalletPass/index.d.ts +5 -0
  43. package/es/components/pay/toC/PaymentMethods/WalletPass/index.js +165 -142
  44. package/es/components/pay/toC/PaymentMethods/WalletPass/serve.d.ts +6 -0
  45. package/es/components/pay/toC/PaymentMethods/WalletPass/utils.js +3 -3
  46. package/es/components/pay/toC/WalletPassBlock/index.js +3 -1
  47. package/es/components/pay/toC/index.js +65 -31
  48. package/es/components/pay/toC/model.d.ts +10 -1
  49. package/es/components/pay/toC/serve.d.ts +18 -0
  50. package/es/components/pay/toC/serve.js +42 -15
  51. package/es/components/pay/toC/utils.d.ts +2 -2
  52. package/es/components/pay/toC/utils.js +4 -0
  53. package/es/components/schedules/model.d.ts +9 -1
  54. package/es/components/shoppingCart/components/Empty/index.d.ts +0 -1
  55. package/es/hooks/usePaymentLogger.d.ts +0 -1
  56. package/es/plus/pisellSalesManagement/config/booking.d.ts +6 -7
  57. package/es/plus/selectHolder/components/ErrorTip/index.d.ts +0 -1
  58. package/es/plus/walletEditor/components/ImageUpload/index.d.ts +1 -1
  59. package/es/pro/Selector/Selector.d.ts +1 -1
  60. package/lib/components/booking/addons/model.d.ts +10 -1
  61. package/lib/components/booking/components/footer/utils.js +2 -2
  62. package/lib/components/booking/forms/model.d.ts +10 -1
  63. package/lib/components/booking/forms/sendModal/useSendModal.d.ts +0 -1
  64. package/lib/components/booking/info/clientVariant/hooks/useIsLowSpeedNetwork.d.ts +0 -1
  65. package/lib/components/booking/info/hooks/useInfoHolder.d.ts +0 -1
  66. package/lib/components/booking/info/model.d.ts +10 -1
  67. package/lib/components/booking/info/service/addService/utils.d.ts +1 -1
  68. package/lib/components/booking/info2/service/addService/utils.d.ts +1 -1
  69. package/lib/components/booking/info2/service/editService/index.js +24 -1
  70. package/lib/components/booking/info2/service/editService/utils.d.ts +15 -0
  71. package/lib/components/booking/info2/service/editService/utils.js +38 -2
  72. package/lib/components/booking/model.d.ts +9 -1
  73. package/lib/components/booking/notes/model.d.ts +10 -1
  74. package/lib/components/booking/payments/model.d.ts +10 -1
  75. package/lib/components/booking/utils.d.ts +2 -2
  76. package/lib/components/eftpos/hooks.d.ts +0 -1
  77. package/lib/components/eftposPay/amount.d.ts +1 -1
  78. package/lib/components/eftposPay/device.d.ts +1 -1
  79. package/lib/components/eftposPay/hooks.d.ts +1 -1
  80. package/lib/components/eftposPay/store/index.d.ts +4 -4
  81. package/lib/components/eftposPay/tyro/hooks.d.ts +0 -1
  82. package/lib/components/eventBooking/components/ErrorTip/index.d.ts +0 -1
  83. package/lib/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/CalenDateStatus/index.d.ts +0 -1
  84. package/lib/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/CalenDateWeek/CallToBook/index.d.ts +0 -1
  85. package/lib/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/CalenDateWeek/WeekItem/index.d.ts +0 -1
  86. package/lib/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/CalenDateWeek/index.d.ts +0 -1
  87. package/lib/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/Item/DayItem/index.d.ts +0 -1
  88. package/lib/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/Item/index.d.ts +0 -1
  89. package/lib/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/Status/index.d.ts +0 -1
  90. package/lib/components/pay/toC/PaymentMethods/StripePay/Stripe/Finish/index.d.ts +0 -1
  91. package/lib/components/pay/toC/PaymentMethods/StripePay/Stripe/StripeSDK/index.d.ts +0 -1
  92. package/lib/components/pay/toC/PaymentMethods/StripePay/Stripe/components/PageLoading/index.d.ts +0 -1
  93. package/lib/components/pay/toC/PaymentMethods/WalletPass/index.d.ts +5 -0
  94. package/lib/components/pay/toC/PaymentMethods/WalletPass/index.js +90 -100
  95. package/lib/components/pay/toC/PaymentMethods/WalletPass/serve.d.ts +6 -0
  96. package/lib/components/pay/toC/PaymentMethods/WalletPass/utils.js +2 -2
  97. package/lib/components/pay/toC/WalletPassBlock/index.js +3 -1
  98. package/lib/components/pay/toC/index.js +52 -19
  99. package/lib/components/pay/toC/model.d.ts +10 -1
  100. package/lib/components/pay/toC/serve.d.ts +18 -0
  101. package/lib/components/pay/toC/serve.js +6 -0
  102. package/lib/components/pay/toC/utils.d.ts +2 -2
  103. package/lib/components/pay/toC/utils.js +6 -2
  104. package/lib/components/schedules/model.d.ts +9 -1
  105. package/lib/components/shoppingCart/components/Empty/index.d.ts +0 -1
  106. package/lib/hooks/usePaymentLogger.d.ts +0 -1
  107. package/lib/plus/pisellSalesManagement/config/booking.d.ts +6 -7
  108. package/lib/plus/selectHolder/components/ErrorTip/index.d.ts +0 -1
  109. package/lib/plus/walletEditor/components/ImageUpload/index.d.ts +1 -1
  110. package/lib/pro/Selector/Selector.d.ts +1 -1
  111. package/package.json +4 -4
@@ -52,6 +52,8 @@ var import_materials = require("@pisell/materials");
52
52
  var import_utils5 = require("../../../info/utils");
53
53
  var import_utils6 = require("../../../info/service2/utils");
54
54
  var import_utils7 = require("../../../../ticketBooking/utils");
55
+ var import_decimal = require("decimal.js");
56
+ var import_utils8 = require("./utils");
55
57
  var submitLock = false;
56
58
  var Info = (_, ref) => {
57
59
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I;
@@ -165,7 +167,7 @@ var Info = (_, ref) => {
165
167
  form.setFieldsValue({ discount });
166
168
  };
167
169
  const onFinish = (values) => {
168
- var _a2, _b2;
170
+ var _a2, _b2, _c2, _d2, _e2;
169
171
  let isSuccess = (_a2 = resourcesRef.current) == null ? void 0 : _a2.check();
170
172
  if (isShowTimeAndResource && !isSuccess) {
171
173
  return;
@@ -193,6 +195,23 @@ var Info = (_, ref) => {
193
195
  const { startDate, endDate } = (0, import_utils3.getServiceTimes)({ _extend });
194
196
  _extend.startDate = startDate;
195
197
  _extend.endDate = endDate;
198
+ if (isChangeTotal.current) {
199
+ const discountRatio = new import_decimal.Decimal(values.total).div(_item._extend.origin_total);
200
+ const bundles2 = ((_c2 = _extend == null ? void 0 : _extend.other) == null ? void 0 : _c2.bundle) || [];
201
+ let childProductsTotal = new import_decimal.Decimal(0);
202
+ if (bundles2.length > 0) {
203
+ bundles2.forEach((bundle) => {
204
+ const discountedPrice = new import_decimal.Decimal(bundle.original_price).mul(discountRatio).toDecimalPlaces(2, import_decimal.Decimal.ROUND_HALF_UP);
205
+ bundle.bundle_selling_price = discountedPrice.toNumber();
206
+ childProductsTotal = childProductsTotal.add(
207
+ discountedPrice.mul(bundle.quantity)
208
+ );
209
+ });
210
+ }
211
+ const mainProductTotal = new import_decimal.Decimal(values.total).sub(childProductsTotal);
212
+ const mainProductQuantity = ((_d2 = _extend.other) == null ? void 0 : _d2.quantity) || _extend.quantity || 1;
213
+ _extend.main_product_selling_price = mainProductTotal.div(mainProductQuantity).toNumber();
214
+ }
196
215
  if (_extend.bundle_edit !== void 0) {
197
216
  _extend.bundle_edit = 1;
198
217
  }
@@ -200,6 +219,10 @@ var Info = (_, ref) => {
200
219
  _item._time = (/* @__PURE__ */ new Date()).getTime();
201
220
  _item._serviceKey = (0, import_utils7.genServiceKey)(_item);
202
221
  let _id = _item == null ? void 0 : _item._id;
222
+ _item = (0, import_utils8.setProductPrice)(_item, {
223
+ newTotal: values.total,
224
+ origin_total: (_e2 = _item._extend) == null ? void 0 : _e2.origin_total
225
+ });
203
226
  if (!_list.some((d) => d._id === _id)) {
204
227
  const detail = (0, import_utils7.addService)(_list, _item, state);
205
228
  _list = detail.list;
@@ -11,3 +11,18 @@ export declare const getAutoAllocationStorage: (id: string | number) => any;
11
11
  export declare const setAutoAllocationStorage: (data: {
12
12
  [key: string]: boolean;
13
13
  }) => void;
14
+ /**
15
+ * 手动折扣后给商品价格和子商品价格重新计算
16
+ *
17
+ * 计算逻辑:
18
+ * 1. 子商品(bundle + option)按折扣比例计算,直接截取两位小数(不四舍五入)
19
+ * 2. 主商品价格 = newTotal - 所有子商品价格总和(确保总价精确等于 newTotal)
20
+ *
21
+ * @param cacheItem - 缓存的商品项
22
+ * @param newTotal - 折扣后的新总价
23
+ * @param origin_total - 原始总价
24
+ */
25
+ export declare const setProductPrice: (cacheItem: any, { newTotal, origin_total }: {
26
+ newTotal: number;
27
+ origin_total: number;
28
+ }) => any;
@@ -20,10 +20,14 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  var utils_exports = {};
21
21
  __export(utils_exports, {
22
22
  getAutoAllocationStorage: () => getAutoAllocationStorage,
23
- setAutoAllocationStorage: () => setAutoAllocationStorage
23
+ setAutoAllocationStorage: () => setAutoAllocationStorage,
24
+ setProductPrice: () => setProductPrice
24
25
  });
25
26
  module.exports = __toCommonJS(utils_exports);
26
27
  var import_utils = require("@pisell/utils");
28
+ var import_utils2 = require("../addService/utils");
29
+ var import_decimal = require("decimal.js");
30
+ var import_utils3 = require("@pisell/utils");
27
31
  var getAutoAllocationStorage = (id) => {
28
32
  const value = localStorage.getItem("resource-auto-allocation");
29
33
  if (value) {
@@ -41,8 +45,40 @@ var setAutoAllocationStorage = (data) => {
41
45
  localStorage.setItem("resource-auto-allocation", JSON.stringify({ ...data }));
42
46
  }
43
47
  };
48
+ var setProductPrice = (cacheItem, { newTotal, origin_total }) => {
49
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
50
+ if (((_a = cacheItem == null ? void 0 : cacheItem.discount_list) == null ? void 0 : _a.length) && ((cacheItem == null ? void 0 : cacheItem.discount_list) || []).some((item) => ["good_pass", "discount_card", "product_discount_card"].includes(
51
+ item.type
52
+ ))) {
53
+ return cacheItem;
54
+ }
55
+ if (cacheItem.discount_amount) {
56
+ return cacheItem;
57
+ }
58
+ const discountRatio = new import_decimal.Decimal(newTotal).div(new import_decimal.Decimal(origin_total));
59
+ let subTotal = new import_decimal.Decimal(0);
60
+ if (((_b = cacheItem._extend.other) == null ? void 0 : _b.bundle) && (0, import_utils3.isArr)((_c = cacheItem._extend.other) == null ? void 0 : _c.bundle)) {
61
+ (_e = (_d = cacheItem._extend.other) == null ? void 0 : _d.bundle) == null ? void 0 : _e.forEach((bundle) => {
62
+ const newPrice = new import_decimal.Decimal(bundle.original_price || bundle.price).mul(discountRatio).toDecimalPlaces(2, import_decimal.Decimal.ROUND_DOWN).toNumber();
63
+ const quantity = bundle.num ?? bundle.quantity ?? 1;
64
+ subTotal = subTotal.add(new import_decimal.Decimal(newPrice).mul(quantity));
65
+ bundle.price = newPrice;
66
+ });
67
+ }
68
+ if (((_f = cacheItem._extend.other) == null ? void 0 : _f.option) && (0, import_utils3.isArr)((_g = cacheItem._extend.other) == null ? void 0 : _g.option)) {
69
+ (_i = (_h = cacheItem._extend.other) == null ? void 0 : _h.option) == null ? void 0 : _i.forEach((option) => {
70
+ const newPrice = new import_decimal.Decimal(option.price).mul(discountRatio).toDecimalPlaces(2, import_decimal.Decimal.ROUND_DOWN).toNumber();
71
+ const quantity = option.num ?? option.quantity ?? 1;
72
+ subTotal = subTotal.add(new import_decimal.Decimal(newPrice).mul(quantity));
73
+ option.price = newPrice;
74
+ });
75
+ }
76
+ cacheItem._extend.price = new import_decimal.Decimal(newTotal).sub(subTotal).toNumber();
77
+ return cacheItem;
78
+ };
44
79
  // Annotate the CommonJS export names for ESM import in node:
45
80
  0 && (module.exports = {
46
81
  getAutoAllocationStorage,
47
- setAutoAllocationStorage
82
+ setAutoAllocationStorage,
83
+ setProductPrice
48
84
  });
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  export interface FormState {
2
3
  amountSymbol: string;
3
4
  apis: {
@@ -109,4 +110,11 @@ export declare const walkInData: {
109
110
  id: number;
110
111
  nickname: string;
111
112
  };
112
- export declare const Provider: any, Context: any;
113
+ export declare const Provider: (ComponentUi: any) => any, Context: import("react").Context<{
114
+ state: FormState;
115
+ } & {
116
+ dispatch: (params: {
117
+ type: string;
118
+ payload: any;
119
+ }) => void;
120
+ }>;
@@ -1 +1,10 @@
1
- export declare const Provider: any, Context: any;
1
+ /// <reference types="react" />
2
+ import { FormState } from "../model";
3
+ export declare const Provider: (ComponentUi: any) => any, Context: import("react").Context<{
4
+ state: FormState;
5
+ } & {
6
+ dispatch: (params: {
7
+ type: string;
8
+ payload: any;
9
+ }) => void;
10
+ }>;
@@ -1 +1,10 @@
1
- export declare const Provider: any, Context: any;
1
+ /// <reference types="react" />
2
+ import { FormState } from "../model";
3
+ export declare const Provider: (ComponentUi: any) => any, Context: import("react").Context<{
4
+ state: FormState;
5
+ } & {
6
+ dispatch: (params: {
7
+ type: string;
8
+ payload: any;
9
+ }) => void;
10
+ }>;
@@ -166,10 +166,10 @@ export declare const getProductTotalPrice: (item: any) => number;
166
166
  export declare const getDuration: (duration: number | {
167
167
  type: string;
168
168
  value: number;
169
- }) => number | {
169
+ }) => number | "flexible" | {
170
170
  type: string;
171
171
  value: number;
172
- } | "flexible";
172
+ };
173
173
  export declare const isWalkIn: (customer_id?: number | string) => boolean;
174
174
  export declare const getIsEdit: (state: any) => boolean;
175
175
  export {};
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { Eftpos } from './const';
3
2
  /**
4
3
  * @title: tyro 设备连接
@@ -9,7 +9,7 @@ import { PosProps } from './const';
9
9
  */
10
10
  declare const _default: ({ className, onChange, onClose, formatAmount, isMobile, net, client }: {
11
11
  className?: string | undefined;
12
- onChange?: ((status: "success" | "page" | "fail" | "print" | "mark_tx_processed", params?: string | {
12
+ onChange?: ((status: "success" | "page" | "print" | "fail" | "mark_tx_processed", params?: string | {
13
13
  [keys: string]: unknown;
14
14
  } | undefined, other?: any) => void) | undefined;
15
15
  onClose: () => void;
@@ -11,7 +11,7 @@ import './device.less';
11
11
  declare const _default: ({ api, onChange, onClose, className, device_number, isMobile, net, client, formatAmount, }: {
12
12
  api: PayProps['api'];
13
13
  className?: string | undefined;
14
- onChange?: ((status: "success" | "page" | "fail" | "print" | "mark_tx_processed", params?: string | {
14
+ onChange?: ((status: "success" | "page" | "print" | "fail" | "mark_tx_processed", params?: string | {
15
15
  [keys: string]: unknown;
16
16
  } | undefined, other?: any) => void) | undefined;
17
17
  onClose: () => void;
@@ -19,7 +19,7 @@ export declare const useStoreRef: <T extends {
19
19
  readonly netRef: React.MutableRefObject<boolean | undefined>;
20
20
  readonly symbolRef: React.MutableRefObject<string>;
21
21
  readonly amountRef: React.MutableRefObject<string | number>;
22
- readonly eftposRef: React.MutableRefObject<"payo" | "tyro" | "windcave" | "stripe" | "linkly">;
22
+ readonly eftposRef: React.MutableRefObject<"stripe" | "payo" | "tyro" | "windcave" | "linkly">;
23
23
  readonly clientRef: React.MutableRefObject<ClientEnum>;
24
24
  readonly dataRef: React.MutableRefObject<import("./store").State>;
25
25
  };
@@ -197,7 +197,7 @@ export declare const updateComponent: (component: string, render?: boolean) => {
197
197
  } | {
198
198
  readonly type: "step";
199
199
  readonly render: boolean;
200
- readonly component?: undefined;
200
+ component?: undefined;
201
201
  };
202
202
  };
203
203
  /**
@@ -297,10 +297,10 @@ export declare const backUpFree: (payload: Partial<State>) => {
297
297
  name?: string | undefined;
298
298
  symbol?: string | undefined;
299
299
  amount?: string | number | undefined;
300
- mode?: "pay" | "fullPay" | "refund" | "query" | undefined;
300
+ mode?: "refund" | "pay" | "fullPay" | "query" | undefined;
301
301
  order_id?: string | number | undefined;
302
- eftpos?: "payo" | "tyro" | "windcave" | "stripe" | "linkly" | undefined;
303
- action?: "pay" | "amount" | "deviceList" | undefined;
302
+ eftpos?: "stripe" | "payo" | "tyro" | "windcave" | "linkly" | undefined;
303
+ action?: "amount" | "pay" | "deviceList" | undefined;
304
304
  key?: number | undefined;
305
305
  step?: number | undefined;
306
306
  title?: string | undefined;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  /**
3
2
  * @title: 获取 Tyro 资源
4
3
  * @description:
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import './index.less';
3
2
  declare const ErrorTip: ({ text }: any) => import("react").JSX.Element;
4
3
  export default ErrorTip;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import './index.less';
3
2
  declare const Status: (props: any) => import("react").JSX.Element;
4
3
  export default Status;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  declare type CallToBookProps = {
3
2
  show: boolean;
4
3
  type: string;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import './index.less';
3
2
  declare const WeekItem: (props: any) => import("react").JSX.Element;
4
3
  export default WeekItem;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import './index.less';
3
2
  declare type CalenDateWeekProps = {
4
3
  currentDate: string;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import './index.less';
3
2
  declare const DayItem: (props: any) => import("react").JSX.Element;
4
3
  export default DayItem;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import './index.less';
3
2
  import { CalendarItemProps } from '../../../../../type';
4
3
  declare const Item: (props: CalendarItemProps) => import("react").JSX.Element;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import './index.less';
3
2
  declare const Status: (props: any) => import("react").JSX.Element;
4
3
  export default Status;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  declare const StripePayment: () => import("react").JSX.Element;
3
2
  export default StripePayment;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  declare const StripeSDK: ({ public_key, client_secret, children, lang, }: {
3
2
  public_key: string;
4
3
  client_secret?: string | undefined;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  declare const PageLoading: () => import("react").JSX.Element;
3
2
  export default PageLoading;
@@ -15,11 +15,16 @@ export interface WalletPassProps {
15
15
  walletPass: {
16
16
  cards: WalletPassDataType[];
17
17
  amount: number;
18
+ recommended?: WalletPassDataType[];
19
+ transformList?: WalletPassDataType[];
20
+ noApplicableVoucher?: WalletPassDataType[];
18
21
  };
19
22
  walletSetting: {
20
23
  name: string;
21
24
  popup_status: 0 | 1;
22
25
  };
26
+ orderDetail: any;
27
+ total_amount: number;
23
28
  }
24
29
  declare const _default: React.MemoExoticComponent<React.ForwardRefExoticComponent<WalletPassProps & React.RefAttributes<WalletPassRef>>>;
25
30
  export default _default;
@@ -47,10 +47,14 @@ var import_index = require("./index.less");
47
47
  var import_useEngineContext = __toESM(require("../../../../../hooks/useEngineContext"));
48
48
  var { Amount } = import_materials.PisellText;
49
49
  var WalletPass = (0, import_react.forwardRef)((props, ref) => {
50
- var _a, _b, _c, _d, _e;
51
- const { onWalletPassChange, walletPass, walletSetting } = props;
50
+ var _a, _b, _c, _d, _e, _f;
51
+ const { onWalletPassChange, walletPass, walletSetting, orderDetail, total_amount } = props;
52
52
  const context = (0, import_useEngineContext.default)();
53
- const isWalletCode = (_d = (_c = (_b = (_a = context == null ? void 0 : context.appHelper) == null ? void 0 : _a.utils) == null ? void 0 : _b.businessUtils) == null ? void 0 : _c.getAppByModal) == null ? void 0 : _d.call(_c, "wallet");
53
+ const { walletPassEvaluator } = ((_a = context == null ? void 0 : context.appHelper) == null ? void 0 : _a.utils) || {};
54
+ const { detail } = orderDetail;
55
+ const isWalletCode = (_e = (_d = (_c = (_b = context == null ? void 0 : context.appHelper) == null ? void 0 : _b.utils) == null ? void 0 : _c.businessUtils) == null ? void 0 : _d.getAppByModal) == null ? void 0 : _e.call(_d, "wallet");
56
+ const { cards: recommended, transformList, noApplicableVoucher } = walletPass;
57
+ const [selectedVoucherIds, setSelectedVoucherIds] = (0, import_react.useState)([]);
54
58
  const [currentWalletPass, setCurrentWalletPass] = (0, import_react.useState)(walletPass);
55
59
  const [loading, setLoading] = (0, import_react.useState)(false);
56
60
  const [open, setOpen] = (0, import_react.useState)(false);
@@ -63,78 +67,69 @@ var WalletPass = (0, import_react.forwardRef)((props, ref) => {
63
67
  details: []
64
68
  });
65
69
  const isAutoSelect = (0, import_react.useRef)(false);
66
- const listRef = (0, import_react.useRef)(null);
67
70
  const searchValRef = (0, import_react.useRef)(null);
68
71
  const pinVerifyModalRef = (0, import_react.useRef)(null);
69
- const { cards: walletPassSelectCards, amount } = currentWalletPass || {};
70
- const [currentCustomerWalletPass, otherCustomerWalletPass] = (0, import_react.useMemo)(() => {
71
- const current = [];
72
- const other = [];
73
- (walletPassSelectCards || []).forEach((item) => {
74
- if (item.customer_id === (order == null ? void 0 : order.customer_id)) {
75
- current.push(item);
72
+ const allVouchersForCalculation = (0, import_react.useMemo)(() => {
73
+ return [...transformList || [], ...addList || []];
74
+ }, [transformList, addList]);
75
+ const selectedVouchers = (0, import_react.useMemo)(() => {
76
+ return selectedVoucherIds.map((id) => allVouchersForCalculation.find((v) => v.id === id)).filter(Boolean);
77
+ }, [selectedVoucherIds, allVouchersForCalculation]);
78
+ const { displayVouchers, displayOtherVouchers, selectedWithDetails, totalDeduction } = (0, import_react.useMemo)(() => {
79
+ if (!walletPassEvaluator || !allVouchersForCalculation.length || !(order == null ? void 0 : order.total_amount)) {
80
+ return {
81
+ displayVouchers: [...transformList || [], ...noApplicableVoucher || []],
82
+ displayOtherVouchers: addList || [],
83
+ selectedWithDetails: [],
84
+ totalDeduction: 0
85
+ };
86
+ }
87
+ if (selectedVouchers.length === 0) {
88
+ return {
89
+ displayVouchers: [...transformList || [], ...noApplicableVoucher || []],
90
+ displayOtherVouchers: addList || [],
91
+ selectedWithDetails: [],
92
+ totalDeduction: 0
93
+ };
94
+ }
95
+ const result = walletPassEvaluator.recalculateVouchers(
96
+ allVouchersForCalculation,
97
+ selectedVouchers,
98
+ order.total_amount,
99
+ detail || []
100
+ );
101
+ const currentCustomerVouchers = [];
102
+ const otherCustomerVouchers = [];
103
+ result.allWithUpdatedStatus.forEach((voucher) => {
104
+ if (voucher.customer_id === (order == null ? void 0 : order.customer_id)) {
105
+ currentCustomerVouchers.push(voucher);
76
106
  } else {
77
- other.push(item);
107
+ otherCustomerVouchers.push(voucher);
78
108
  }
79
109
  });
80
- return [current, other];
81
- }, [walletPassSelectCards, order == null ? void 0 : order.customer_id]);
110
+ return {
111
+ displayVouchers: [...currentCustomerVouchers, ...noApplicableVoucher || []],
112
+ displayOtherVouchers: otherCustomerVouchers,
113
+ selectedWithDetails: result.selectedWithDetails,
114
+ totalDeduction: result.selectedWithDetails.reduce((sum, v) => sum + (v.actualDeduction || 0), 0)
115
+ };
116
+ }, [selectedVouchers, allVouchersForCalculation, transformList, addList, noApplicableVoucher, order == null ? void 0 : order.total_amount, order == null ? void 0 : order.customer_id, detail, walletPassEvaluator]);
82
117
  const prepare_payments = (0, import_react.useMemo)(() => {
83
118
  return (0, import_utils3.formatWalletPassList2PreparePayments)(
84
119
  (0, import_utils.uniqueByKey)(
85
- (walletPassSelectCards || []).concat(searchSelectData.details),
120
+ (selectedWithDetails || []).concat(searchSelectData.details),
86
121
  "id"
87
122
  )
88
123
  );
89
- }, [walletPassSelectCards, searchSelectData]);
124
+ }, [selectedWithDetails, searchSelectData]);
90
125
  const selectValue = (0, import_react.useMemo)(() => {
91
- return (walletPassSelectCards == null ? void 0 : walletPassSelectCards.map((item) => item.id)) || [];
92
- }, [walletPassSelectCards]);
93
- const otherCustomerWalletPassList = (0, import_react.useMemo)(() => {
94
- return (0, import_utils2.formatMachineCodeServer2CardList)(addList, selectValue);
95
- }, [addList, selectValue]);
96
- const other_exact_codes = (0, import_react.useMemo)(() => {
97
- const codes = [];
98
- addList.forEach((item) => {
99
- if (!selectValue.includes(item.id)) {
100
- codes.push(item.code);
101
- }
102
- });
103
- return codes;
104
- }, [addList, selectValue]);
105
- const refreshList = (0, import_ahooks.useMemoizedFn)(() => {
106
- var _a2, _b2;
107
- if ((order == null ? void 0 : order.order_id) && (order == null ? void 0 : order.customer_id)) {
108
- (_b2 = listRef.current) == null ? void 0 : _b2.init(
109
- {
110
- order_id: order.order_id,
111
- available: 2,
112
- prepare_payments,
113
- filter_prepare_wallet_pass: 1,
114
- sale_channel: ((_a2 = order._order) == null ? void 0 : _a2.sale_channel) || "online-store",
115
- other_exact_codes
116
- },
117
- // 已选择的卡片接口中不会返回,所以追加进入列表
118
- (val) => {
119
- const idMap = val.reduce((pre, cur) => {
120
- return {
121
- ...pre,
122
- [cur.id]: cur
123
- };
124
- }, {});
125
- setAddList((prevState) => {
126
- return prevState.map((item) => {
127
- if (idMap[item.id]) {
128
- return idMap[item.id];
129
- }
130
- return item;
131
- });
132
- });
133
- return [...currentCustomerWalletPass || [], ...val];
134
- }
135
- );
126
+ return selectedVoucherIds;
127
+ }, [selectedVoucherIds]);
128
+ (0, import_react.useEffect)(() => {
129
+ if (recommended && recommended.length > 0) {
130
+ setSelectedVoucherIds(recommended.map((v) => v.id));
136
131
  }
137
- });
132
+ }, [recommended]);
138
133
  (0, import_react.useEffect)(() => {
139
134
  if ((order == null ? void 0 : order.order_id) && searchValRef.current) {
140
135
  searchList(searchValRef.current, true);
@@ -145,16 +140,16 @@ var WalletPass = (0, import_react.forwardRef)((props, ref) => {
145
140
  setOrder(res);
146
141
  setOpen(true);
147
142
  setCurrentWalletPass(walletPass);
148
- setTimeout(() => {
149
- refreshList();
150
- });
143
+ if (recommended && recommended.length > 0) {
144
+ setSelectedVoucherIds(recommended.map((v) => v.id));
145
+ }
151
146
  };
152
147
  const searchList = async ({ code, customer_pin_key }, isSelectChange) => {
153
148
  var _a2;
154
149
  if (!(order == null ? void 0 : order.order_id)) return;
155
150
  setLoading(true);
156
151
  try {
157
- const result = await (0, import_serve.searchMachineCodeList)({
152
+ const baseResult = await (0, import_serve.searchMachineCodeList)({
158
153
  order_id: order.order_id,
159
154
  code,
160
155
  prepare_payments,
@@ -162,7 +157,7 @@ var WalletPass = (0, import_react.forwardRef)((props, ref) => {
162
157
  sale_channel: ((_a2 = order._order) == null ? void 0 : _a2.sale_channel) || "online-store",
163
158
  customer_pin_key
164
159
  });
165
- if (!result) {
160
+ if (!baseResult) {
166
161
  if (!isSelectChange) {
167
162
  (0, import_materials.PisellToast)({
168
163
  content: import_utils.locales.getText("tocPay.text.walletSearchEmpty")
@@ -173,6 +168,11 @@ var WalletPass = (0, import_react.forwardRef)((props, ref) => {
173
168
  if (isSelectChange && !searchValRef.current) {
174
169
  return;
175
170
  }
171
+ let result = walletPassEvaluator.searchVoucherFormat({
172
+ vouchers: baseResult,
173
+ orderTotalAmount: order.total_amount,
174
+ products: detail
175
+ });
176
176
  setSearchData(
177
177
  (0, import_utils2.formatMachineCodeServer2CardList)(
178
178
  [...searchSelectData.details, ...result],
@@ -235,23 +235,23 @@ var WalletPass = (0, import_react.forwardRef)((props, ref) => {
235
235
  });
236
236
  };
237
237
  const handleSelectOk = () => {
238
- changeWalletPass(
239
- (0, import_utils.uniqueByKey)(
240
- [
241
- ...walletPassSelectCards || [],
242
- ...searchSelectData.details
243
- ],
244
- "id"
245
- )
238
+ const otherCustomerSearchVouchers = searchSelectData.details.filter(
239
+ (item) => item.customer_id !== (order == null ? void 0 : order.customer_id)
246
240
  );
247
241
  setAddList((prevState) => {
248
242
  return (0, import_utils.uniqueByKey)(
249
- [...prevState, ...searchSelectData.details],
243
+ [...prevState, ...otherCustomerSearchVouchers],
250
244
  "id"
251
- ).filter(
252
- (item) => !(order == null ? void 0 : order.customer_id) || item.customer_id !== (order == null ? void 0 : order.customer_id)
253
245
  );
254
246
  });
247
+ const newSelectedIds = (0, import_utils.uniqueByKey)(
248
+ [
249
+ ...selectedWithDetails || [],
250
+ ...searchSelectData.details
251
+ ],
252
+ "id"
253
+ ).map((v) => v.id);
254
+ setSelectedVoucherIds(newSelectedIds);
255
255
  handleSearchModalClose();
256
256
  };
257
257
  const handleAddChange = (0, import_ahooks.useMemoizedFn)(
@@ -263,26 +263,15 @@ var WalletPass = (0, import_react.forwardRef)((props, ref) => {
263
263
  });
264
264
  }
265
265
  );
266
- const changeWalletPass = (cards) => {
267
- setCurrentWalletPass == null ? void 0 : setCurrentWalletPass({
268
- cards,
269
- amount: (0, import_utils3.calcWalletPassListAmount)(cards)
270
- });
271
- setTimeout(() => {
272
- refreshList();
273
- });
274
- };
275
266
  const handleSelectChange = (val, details, type) => {
276
- let cards = details.map((item) => item.originData);
277
- if (type === "other") {
278
- cards = currentCustomerWalletPass.concat(cards);
279
- } else if (type === "current") {
280
- cards = otherCustomerWalletPass.concat(cards);
281
- }
282
- changeWalletPass(cards);
267
+ setSelectedVoucherIds(val);
283
268
  };
284
269
  const handleRedeem = () => {
285
- onWalletPassChange == null ? void 0 : onWalletPassChange(currentWalletPass);
270
+ onWalletPassChange == null ? void 0 : onWalletPassChange({
271
+ ...currentWalletPass,
272
+ cards: selectedWithDetails,
273
+ amount: totalDeduction
274
+ });
286
275
  setOpen(false);
287
276
  };
288
277
  const handleWalletClose = () => {
@@ -307,16 +296,16 @@ var WalletPass = (0, import_react.forwardRef)((props, ref) => {
307
296
  onCancel: () => handleWalletClose(),
308
297
  cancelVisible: false,
309
298
  destroyOnClose: true,
310
- okText: /* @__PURE__ */ import_react.default.createElement("div", null, import_utils.locales.getText("tocPay.text.redeem"), " ", /* @__PURE__ */ import_react.default.createElement(Amount, { value: amount })),
299
+ okText: /* @__PURE__ */ import_react.default.createElement("div", null, import_utils.locales.getText("tocPay.text.redeem"), " ", /* @__PURE__ */ import_react.default.createElement(Amount, { value: totalDeduction })),
311
300
  onOk: handleRedeem
312
301
  },
313
302
  /* @__PURE__ */ import_react.default.createElement("div", { className: "", style: { marginTop: 24 } }, /* @__PURE__ */ import_react.default.createElement(import_MultiModeSearch.default, { onChange: handleSearch }), /* @__PURE__ */ import_react.default.createElement("div", { className: "wallet-pass-modal-multi-selection-available" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "wallet-pass-modal-multi-selection-available-title" }, /* @__PURE__ */ import_react.default.createElement(import_icons.InfoCircleOutlined, { className: "wallet-pass-modal-multi-selection-available-title-icon" }), import_utils.locales.getText("tocPay.text.multipleSelectionAvailable")), /* @__PURE__ */ import_react.default.createElement("div", { className: "wallet-pass-modal-multi-selection-available-desc" }, import_utils.locales.getText(
314
303
  "tocPay.text.youCanSelectMultipleWalletPassesToCombineForPayment"
315
- )(walletSetting.name))), otherCustomerWalletPassList.length > 0 && /* @__PURE__ */ import_react.default.createElement(
304
+ )(walletSetting.name))), displayOtherVouchers.length > 0 && /* @__PURE__ */ import_react.default.createElement(
316
305
  import_List.default,
317
306
  {
318
307
  walletSetting,
319
- data: otherCustomerWalletPassList,
308
+ data: (0, import_utils2.formatMachineCodeServer2CardList)(displayOtherVouchers, selectValue),
320
309
  title: import_utils.locales.getText("tocPay.text.couponCodesAdded"),
321
310
  onChange: handleOtherChange,
322
311
  value: selectValue,
@@ -329,9 +318,10 @@ var WalletPass = (0, import_react.forwardRef)((props, ref) => {
329
318
  walletSetting,
330
319
  title: walletSetting.name,
331
320
  onChange: handleCurrentChange,
332
- ref: listRef,
321
+ data: (0, import_utils2.formatMachineCodeServer2CardList)(displayVouchers, selectValue),
333
322
  value: selectValue,
334
323
  onLoadingChange: setLoading,
324
+ loading,
335
325
  customer_id: order == null ? void 0 : order.customer_id
336
326
  }
337
327
  ))
@@ -347,7 +337,7 @@ var WalletPass = (0, import_react.forwardRef)((props, ref) => {
347
337
  okText: import_utils.locales.getText("tocPay.text.select"),
348
338
  onOk: handleSelectOk,
349
339
  okButtonProps: {
350
- disabled: ((_e = searchSelectData.ids) == null ? void 0 : _e.length) === 0
340
+ disabled: ((_f = searchSelectData.ids) == null ? void 0 : _f.length) === 0
351
341
  }
352
342
  },
353
343
  /* @__PURE__ */ import_react.default.createElement("div", { className: "", style: { marginTop: 24 } }, /* @__PURE__ */ import_react.default.createElement(