@pisell/private-materials 6.6.32 → 6.6.34

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 (55) 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 +7 -7
  7. package/build/lowcode/render/default/view.css +1 -1
  8. package/build/lowcode/render/default/view.js +6 -6
  9. package/build/lowcode/view.css +1 -1
  10. package/build/lowcode/view.js +6 -6
  11. package/es/components/booking/addons/model.d.ts +1 -10
  12. package/es/components/booking/components/voucher/index.js +4 -6
  13. package/es/components/booking/components/voucher/utils.d.ts +1 -0
  14. package/es/components/booking/components/voucher/utils.js +8 -0
  15. package/es/components/booking/forms/model.d.ts +1 -10
  16. package/es/components/booking/info/model.d.ts +1 -10
  17. package/es/components/booking/info/service2/Group/utils.js +8 -6
  18. package/es/components/booking/info2/service/editService/DiscountChangeModal/index.d.ts +25 -0
  19. package/es/components/booking/info2/service/editService/DiscountChangeModal/index.js +61 -0
  20. package/es/components/booking/info2/service/editService/DiscountChangeModal/index.less +41 -0
  21. package/es/components/booking/info2/service/editService/index.js +144 -35
  22. package/es/components/booking/info2/service/editService/utils.d.ts +6 -0
  23. package/es/components/booking/info2/service/editService/utils.js +21 -0
  24. package/es/components/booking/locales.d.ts +36 -0
  25. package/es/components/booking/locales.js +42 -3
  26. package/es/components/booking/model.d.ts +1 -9
  27. package/es/components/booking/notes/model.d.ts +1 -10
  28. package/es/components/booking/payments/model.d.ts +1 -10
  29. package/es/components/eftposPay/hooks.d.ts +1 -1
  30. package/es/components/eftposPay/store/index.d.ts +2 -2
  31. package/es/components/pay/toC/model.d.ts +1 -9
  32. package/es/components/schedules/model.d.ts +1 -9
  33. package/lib/components/booking/addons/model.d.ts +1 -10
  34. package/lib/components/booking/components/voucher/index.js +3 -3
  35. package/lib/components/booking/components/voucher/utils.d.ts +1 -0
  36. package/lib/components/booking/components/voucher/utils.js +10 -2
  37. package/lib/components/booking/forms/model.d.ts +1 -10
  38. package/lib/components/booking/info/model.d.ts +1 -10
  39. package/lib/components/booking/info/service2/Group/utils.js +3 -2
  40. package/lib/components/booking/info2/service/editService/DiscountChangeModal/index.d.ts +25 -0
  41. package/lib/components/booking/info2/service/editService/DiscountChangeModal/index.js +64 -0
  42. package/lib/components/booking/info2/service/editService/DiscountChangeModal/index.less +41 -0
  43. package/lib/components/booking/info2/service/editService/index.js +95 -13
  44. package/lib/components/booking/info2/service/editService/utils.d.ts +6 -0
  45. package/lib/components/booking/info2/service/editService/utils.js +11 -0
  46. package/lib/components/booking/locales.d.ts +36 -0
  47. package/lib/components/booking/locales.js +42 -3
  48. package/lib/components/booking/model.d.ts +1 -9
  49. package/lib/components/booking/notes/model.d.ts +1 -10
  50. package/lib/components/booking/payments/model.d.ts +1 -10
  51. package/lib/components/eftposPay/hooks.d.ts +1 -1
  52. package/lib/components/eftposPay/store/index.d.ts +2 -2
  53. package/lib/components/pay/toC/model.d.ts +1 -9
  54. package/lib/components/schedules/model.d.ts +1 -9
  55. package/package.json +3 -3
@@ -1,10 +1 @@
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
+ export declare const Provider: any, Context: any;
@@ -27,7 +27,7 @@ import { PisellInput, PisellGoodPassCard, PisellToast } from '@pisell/materials'
27
27
  import { useIsBooking4Shop } from "../../hooks/useIsBooking4Shop";
28
28
  import "./index.less";
29
29
  import { useMemoizedFn, useDebounceFn, useDebounceEffect } from 'ahooks';
30
- import { getServiceAddons } from "./utils";
30
+ import { getServiceAddons, hasEveryBookingId } from "./utils";
31
31
  import { useActiveExecute, useCustomer } from "../../../ticketBooking/hooks/pisellos";
32
32
  import { getClientVariantClose } from "../../info/clientVariant/utils";
33
33
  import { useShopDiscountModule } from "../../../ticketBooking/hooks/pisellos/useShopDiscountModule";
@@ -178,7 +178,7 @@ var VoucherCard = function VoucherCard(props) {
178
178
  }, [state.addons.value]);
179
179
  var holdersMemo = useMemo(function () {
180
180
  if (isBooking4Shop) {
181
- var _state$pet;
181
+ var _state$pet, _shopDiscount$setHold;
182
182
  var list = [];
183
183
  if ((_state$pet = state.pet) !== null && _state$pet !== void 0 && _state$pet.value) {
184
184
  var entries = Object.entries(state.pet.value);
@@ -188,7 +188,7 @@ var VoucherCard = function VoucherCard(props) {
188
188
  list = entries[0][1];
189
189
  }
190
190
  }
191
- shopDiscount.setHolders(list);
191
+ shopDiscount === null || shopDiscount === void 0 || (_shopDiscount$setHold = shopDiscount.setHolders) === null || _shopDiscount$setHold === void 0 || _shopDiscount$setHold.call(shopDiscount, list);
192
192
  holderChangedRef.current = true;
193
193
  return list || [];
194
194
  }
@@ -200,9 +200,7 @@ var VoucherCard = function VoucherCard(props) {
200
200
  }, [state.bookingConfig]);
201
201
  var disabled = useMemo(function () {
202
202
  var _state$bookingDetail;
203
- if (['paid', 'partially_paid'].includes((_state$bookingDetail = state.bookingDetail) === null || _state$bookingDetail === void 0 ? void 0 : _state$bookingDetail.payment_status) && [].concat(_toConsumableArray(addonsMemo), _toConsumableArray(serviceMemo)).every(function (item) {
204
- return item.booking_id;
205
- })) {
203
+ if (['paid', 'partially_paid'].includes((_state$bookingDetail = state.bookingDetail) === null || _state$bookingDetail === void 0 ? void 0 : _state$bookingDetail.payment_status) && hasEveryBookingId([].concat(_toConsumableArray(state.addons.value || []), _toConsumableArray(state.service.value || [])))) {
206
204
  return true;
207
205
  }
208
206
  return false;
@@ -2,3 +2,4 @@ export declare const getServiceAddons: (list: any[]) => {
2
2
  serviceList: any[];
3
3
  addonsList: any[];
4
4
  };
5
+ export declare const hasEveryBookingId: (list: any[]) => boolean;
@@ -12,4 +12,12 @@ export var getServiceAddons = function getServiceAddons(list) {
12
12
  serviceList: serviceList,
13
13
  addonsList: addonsList
14
14
  };
15
+ };
16
+ export var hasEveryBookingId = function hasEveryBookingId(list) {
17
+ return list.every(function (item) {
18
+ var _item$_extend, _item$_extend$every;
19
+ return item.booking_id && ((_item$_extend = item._extend) === null || _item$_extend === void 0 || (_item$_extend = _item$_extend.other) === null || _item$_extend === void 0 || (_item$_extend = _item$_extend.bundle) === null || _item$_extend === void 0 || (_item$_extend$every = _item$_extend.every) === null || _item$_extend$every === void 0 ? void 0 : _item$_extend$every.call(_item$_extend, function (bundle) {
20
+ return bundle.booking_id;
21
+ }));
22
+ });
15
23
  };
@@ -1,10 +1 @@
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
+ export declare const Provider: any, Context: any;
@@ -1,14 +1,5 @@
1
- /// <reference types="react" />
2
- import { FormState } from '../model';
3
1
  export declare const walkInData: {
4
2
  id: number;
5
3
  nickname: string;
6
4
  };
7
- export declare const Provider: (ComponentUi: any) => any, Context: import("react").Context<{
8
- state: FormState;
9
- } & {
10
- dispatch: (params: {
11
- type: string;
12
- payload: any;
13
- }) => void;
14
- }>;
5
+ export declare const Provider: any, Context: any;
@@ -81,7 +81,7 @@ export var createBookingItemsByGroup = function createBookingItemsByGroup(item,
81
81
 
82
82
  // 根据时长 进行创建多个商品
83
83
  for (var i = 0; i < item._extend.duration; i++) {
84
- var _extend$multiDayPrice;
84
+ var _extend$multiDayPrice, _item$_extend;
85
85
  var _extend = _objectSpread({}, item._extend);
86
86
  var startDate = _extend.start_date.add(i, 'day');
87
87
  var endDate = _extend.start_date.add(i + 1, 'day');
@@ -105,8 +105,10 @@ export var createBookingItemsByGroup = function createBookingItemsByGroup(item,
105
105
  })
106
106
  });
107
107
  var totalPrice = getProductTotalPrice(cacheItem);
108
+ // 跨日预约原始价格从items中获取
109
+ var origin_total = (_item$_extend = item._extend) === null || _item$_extend === void 0 || (_item$_extend = _item$_extend.items) === null || _item$_extend === void 0 || (_item$_extend = _item$_extend[0]) === null || _item$_extend === void 0 || (_item$_extend = _item$_extend._extend) === null || _item$_extend === void 0 ? void 0 : _item$_extend.origin_total;
108
110
  cacheItem._extend.total = totalPrice;
109
- cacheItem._extend.origin_total = totalPrice;
111
+ cacheItem._extend.origin_total = origin_total !== null && origin_total !== void 0 ? origin_total : totalPrice;
110
112
  cacheItem._extend.items = undefined;
111
113
  cacheItem._serviceKey = genServiceKey(cacheItem);
112
114
  bookings.push(cacheItem);
@@ -131,8 +133,8 @@ export var isGroupBooking = function isGroupBooking(_id) {
131
133
  };
132
134
  export var getProductByGroupId = function getProductByGroupId(groupId, items) {
133
135
  return items.filter(function (item) {
134
- var _item$_extend;
135
- return ((_item$_extend = item._extend) === null || _item$_extend === void 0 ? void 0 : _item$_extend.groupId) === groupId;
136
+ var _item$_extend2;
137
+ return ((_item$_extend2 = item._extend) === null || _item$_extend2 === void 0 ? void 0 : _item$_extend2.groupId) === groupId;
136
138
  }).map(function (item) {
137
139
  return item._id;
138
140
  });
@@ -143,7 +145,7 @@ export var getGroupBooking = function getGroupBooking(groupId, items) {
143
145
  };
144
146
  export var filterItemByGroupId = function filterItemByGroupId(groupId, items) {
145
147
  return items.filter(function (item) {
146
- var _item$_extend2;
147
- return ((_item$_extend2 = item._extend) === null || _item$_extend2 === void 0 ? void 0 : _item$_extend2.groupId) !== groupId;
148
+ var _item$_extend3;
149
+ return ((_item$_extend3 = item._extend) === null || _item$_extend3 === void 0 ? void 0 : _item$_extend3.groupId) !== groupId;
148
150
  });
149
151
  };
@@ -0,0 +1,25 @@
1
+ import React from 'react';
2
+ import './index.less';
3
+ /**
4
+ * 折扣变更弹窗 Props
5
+ */
6
+ export interface DiscountChangeModalProps {
7
+ /** 弹窗是否可见 */
8
+ open: boolean;
9
+ /** 保留原折扣回调 */
10
+ onKeepOriginal?: () => void;
11
+ /** 延续折扣回调 */
12
+ onContinue?: () => void;
13
+ /** 移除折扣回调 */
14
+ onRemove?: () => void;
15
+ /** 取消回调 */
16
+ onCancel?: () => void;
17
+ }
18
+ /**
19
+ * 折扣变更弹窗组件
20
+ *
21
+ * @description 当订单中使用的商品折扣已失效时,弹出此弹窗让用户选择处理方式
22
+ * @author Pisell Team
23
+ */
24
+ declare const DiscountChangeModal: React.FC<DiscountChangeModalProps>;
25
+ export default DiscountChangeModal;
@@ -0,0 +1,61 @@
1
+ import React from 'react';
2
+ import { Button, Space } from 'antd';
3
+ import { PisellModal } from '@pisell/materials';
4
+ import { locales } from '@pisell/utils';
5
+ import "./index.less";
6
+
7
+ /**
8
+ * 折扣变更弹窗 Props
9
+ */
10
+
11
+ /**
12
+ * 折扣变更弹窗组件
13
+ *
14
+ * @description 当订单中使用的商品折扣已失效时,弹出此弹窗让用户选择处理方式
15
+ * @author Pisell Team
16
+ */
17
+ var DiscountChangeModal = function DiscountChangeModal(_ref) {
18
+ var open = _ref.open,
19
+ onKeepOriginal = _ref.onKeepOriginal,
20
+ onContinue = _ref.onContinue,
21
+ onRemove = _ref.onRemove,
22
+ onCancel = _ref.onCancel;
23
+ /**
24
+ * 渲染自定义底部按钮
25
+ */
26
+ var renderFooter = function renderFooter() {
27
+ return /*#__PURE__*/React.createElement("div", {
28
+ className: "discount-change-modal__footer"
29
+ }, /*#__PURE__*/React.createElement(Space, {
30
+ size: 12,
31
+ wrap: true
32
+ }, /*#__PURE__*/React.createElement(Button, {
33
+ type: "primary",
34
+ onClick: onContinue
35
+ }, locales.getText('pisell2.discount-change.continue')), /*#__PURE__*/React.createElement(Button, {
36
+ onClick: onRemove
37
+ }, locales.getText('pisell2.discount-change.remove')), /*#__PURE__*/React.createElement(Button, {
38
+ onClick: onCancel
39
+ }, locales.getText('pisell2.discount-change.cancel'))));
40
+ };
41
+ return /*#__PURE__*/React.createElement(PisellModal, {
42
+ open: open,
43
+ title: locales.getText('pisell2.discount-change.title'),
44
+ onCancel: onCancel,
45
+ footer: renderFooter(),
46
+ maskClosable: false,
47
+ width: 560,
48
+ destroyOnClose: true
49
+ }, /*#__PURE__*/React.createElement("div", {
50
+ className: "discount-change-modal__content"
51
+ }, /*#__PURE__*/React.createElement("p", {
52
+ className: "discount-change-modal__desc"
53
+ }, locales.getText('pisell2.discount-change.desc')), /*#__PURE__*/React.createElement("ul", {
54
+ className: "discount-change-modal__reasons"
55
+ }, /*#__PURE__*/React.createElement("li", null, locales.getText('pisell2.discount-change.reason'))), /*#__PURE__*/React.createElement("p", {
56
+ className: "discount-change-modal__desc"
57
+ }, locales.getText('pisell2.discount-change.options-title')), /*#__PURE__*/React.createElement("ul", {
58
+ className: "discount-change-modal__options"
59
+ }, /*#__PURE__*/React.createElement("li", null, /*#__PURE__*/React.createElement("strong", null, locales.getText('pisell2.discount-change.continue')), "\uFF1A", locales.getText('pisell2.discount-change.continue-desc')), /*#__PURE__*/React.createElement("li", null, /*#__PURE__*/React.createElement("strong", null, locales.getText('pisell2.discount-change.remove')), "\uFF1A", locales.getText('pisell2.discount-change.remove-desc')))));
60
+ };
61
+ export default DiscountChangeModal;
@@ -0,0 +1,41 @@
1
+ .discount-change-modal {
2
+ &__content {
3
+ padding: 8px 0;
4
+ }
5
+
6
+ &__desc {
7
+ margin-bottom: 8px;
8
+ color: var(--Gray-900, #101828);
9
+ font-size: 14px;
10
+ line-height: 1.6;
11
+ }
12
+
13
+ &__reasons,
14
+ &__options {
15
+ margin: 0 0 16px 0;
16
+ padding-left: 20px;
17
+ color: var(--Gray-600, #475467);
18
+ font-size: 14px;
19
+ line-height: 1.8;
20
+
21
+ li {
22
+ margin-bottom: 4px;
23
+ }
24
+
25
+ strong {
26
+ color: var(--Gray-900, #101828);
27
+ font-weight: 600;
28
+ }
29
+ }
30
+
31
+ &__options {
32
+ margin-bottom: 0;
33
+ }
34
+
35
+ &__footer {
36
+ display: flex;
37
+ justify-content: flex-end;
38
+ width: 100%;
39
+ }
40
+ }
41
+
@@ -27,7 +27,7 @@ import Duration from "../../../materiels/duration";
27
27
  import Capacity from "./Capacity";
28
28
  import Resources from "./Resources";
29
29
  import Holder from "./Holder";
30
- import { Input, Button, Row, Col, Form, InputNumber, DatePicker } from 'antd';
30
+ import { Input, Button, Row, Col, Form, InputNumber, DatePicker, message } from 'antd';
31
31
  import "./index.less";
32
32
  import CollapsibleList from "../../../components/collapsibleList";
33
33
  import { renderBundles } from "../../../components/collapsibleList/utils";
@@ -41,13 +41,15 @@ import { editSessionProduct } from "../../../info/utils";
41
41
  import { deleteCacheParams, getDays, getProductTotalPrice, getServiceTimes, isSessionProduct, isWalkIn } from "../../../utils";
42
42
  import { getErrorList, getIsNoSpecAndPackage } from "../../utilsByBooking";
43
43
  import { formatResources, getDurationProps, getFlexibleOption, getMultiDay, getTimeObj, setDefaultCapacitys } from "../addService/utils";
44
- import { setProductPrice } from "./utils";
44
+ import { getProductAllDiscountList, setProductPrice } from "./utils";
45
45
  import NoteModal from "../../../../../plus/noteModal";
46
46
  import { DiscountKeyboard } from "../../../../../pro/priceKeyboard";
47
47
  import EditTabs from "../../../info/service/editService/EditTabs";
48
48
  import BookingList from "../../../info/service/editService/BookingList";
49
49
  import dayjs from "dayjs";
50
50
  import { createBookingItemsByGroup, getGroupTotalPrice } from "../../../info/service2/Group/utils";
51
+ import { useShopDiscountModule } from "../../../../ticketBooking/hooks/pisellos/useShopDiscountModule";
52
+ import DiscountChangeModal from "./DiscountChangeModal";
51
53
  var submitLock = false;
52
54
  var Info = function Info(_, ref) {
53
55
  var _state$service4, _state$bookingConfig2, _state$bookingConfig3, _state$service$cacheI5, _state$service$cacheI7, _state$service6, _window$BaseMaterials, _state$service8, _state$service$cacheI12, _state$bookingConfig5, _state$service$cacheI13, _state$service$cacheI14, _state$service9, _state$service$resour2, _state$service$cacheI16, _state$service$cacheI17, _state$client2;
@@ -63,24 +65,34 @@ var Info = function Info(_, ref) {
63
65
  var useNote = Form.useWatch('note', form);
64
66
  var useStartDate = Form.useWatch('start_date', form);
65
67
  var useEndDate = Form.useWatch('end_date', form);
68
+ var shopDiscount = useShopDiscountModule();
69
+ var _useState = useState(false),
70
+ _useState2 = _slicedToArray(_useState, 2),
71
+ discountChangeModalOpen = _useState2[0],
72
+ setDiscountChangeModalOpen = _useState2[1];
66
73
  var _useContext = useContext(Context),
67
74
  state = _useContext.state,
68
75
  dispatch = _useContext.dispatch;
69
76
  var resourcesRef = useRef(null);
70
77
  var isChangeTotal = useRef(false);
71
- var _useState = useState(false),
72
- _useState2 = _slicedToArray(_useState, 2),
73
- noteModalOpen = _useState2[0],
74
- setNoteModalOpen = _useState2[1];
75
78
  var _useState3 = useState(false),
76
79
  _useState4 = _slicedToArray(_useState3, 2),
77
- open = _useState4[0],
78
- setOpen = _useState4[1];
79
- // 当前tab 跨日预约时展示tabs
80
- var _useState5 = useState('batch_edit'),
80
+ noteModalOpen = _useState4[0],
81
+ setNoteModalOpen = _useState4[1];
82
+ var _useState5 = useState(false),
81
83
  _useState6 = _slicedToArray(_useState5, 2),
82
- currentTab = _useState6[0],
83
- setCurrentTab = _useState6[1];
84
+ open = _useState6[0],
85
+ setOpen = _useState6[1];
86
+ // 当前tab 跨日预约时展示tabs
87
+ var _useState7 = useState('batch_edit'),
88
+ _useState8 = _slicedToArray(_useState7, 2),
89
+ currentTab = _useState8[0],
90
+ setCurrentTab = _useState8[1];
91
+ var valuesRef = useRef({});
92
+ var noInOriginalDiscountIdsRef = useRef([]);
93
+
94
+ /** 标记 handleEdit 是否执行过,用于判断保存时是否需要检查折扣变化 */
95
+ var isEditedRef = useRef(false);
84
96
  useEffect(function () {
85
97
  window.openBookingEditModal = function () {
86
98
  setOpen(true);
@@ -249,6 +261,41 @@ var Info = function Info(_, ref) {
249
261
  discount: discount
250
262
  });
251
263
  };
264
+ var onFinishBefore = function onFinishBefore(values) {
265
+ // 如果没有执行过 handleEdit,直接执行 onFinish
266
+ if (!isEditedRef.current) {
267
+ onFinish(values);
268
+ return;
269
+ }
270
+ valuesRef.current = values;
271
+ var originalDiscountList = shopDiscount.getDiscountList();
272
+ var productAllDiscountList = getProductAllDiscountList(state.service.cacheItem);
273
+
274
+ // 判断有些折扣不在原始折扣列表中
275
+ var noInOriginalDiscountList = productAllDiscountList.filter(function (item) {
276
+ return !originalDiscountList.some(function (d) {
277
+ var _item$discount;
278
+ return !d.isEditMode && d.id === (item === null || item === void 0 || (_item$discount = item.discount) === null || _item$discount === void 0 ? void 0 : _item$discount.resource_id);
279
+ });
280
+ });
281
+
282
+ // 判断是否有些折扣不在原始折扣列表中
283
+ var isSomeDiscountNotInOriginalDiscountList = noInOriginalDiscountList.length > 0;
284
+ if (isSomeDiscountNotInOriginalDiscountList) {
285
+ noInOriginalDiscountIdsRef.current = noInOriginalDiscountList.map(function (item) {
286
+ var _item$discount2;
287
+ return item === null || item === void 0 || (_item$discount2 = item.discount) === null || _item$discount2 === void 0 ? void 0 : _item$discount2.resource_id;
288
+ });
289
+ setDiscountChangeModalOpen(true);
290
+ } else {
291
+ var _cacheItem2 = _objectSpread({}, state.service.cacheItem);
292
+ _cacheItem2 = deleteDiscountList(_cacheItem2);
293
+ onFinish(values, _cacheItem2);
294
+ if (!!(productAllDiscountList !== null && productAllDiscountList !== void 0 && productAllDiscountList.length)) {
295
+ message.success(locales.getText('pisell2.text.edit-service-success'));
296
+ }
297
+ }
298
+ };
252
299
 
253
300
  /**
254
301
  * @title: 提交,
@@ -258,8 +305,8 @@ var Info = function Info(_, ref) {
258
305
  * @Author: zhiwei.Wang
259
306
  * @Date: 2024-01-09 14:04
260
307
  */
261
- var onFinish = function onFinish(values) {
262
- var _resourcesRef$current, _item$_extend, _item$_extend2, _item$_extend3, _item$_extend4, _item2, _item3, _state$service$cacheI3, _window$closeBookingE2, _window2;
308
+ var onFinish = function onFinish(values, cacheItem) {
309
+ var _resourcesRef$current, _item$_extend, _item$_extend2, _item$_extend3, _item$_extend4, _item2, _item3, _item$_extend5, _item$_extend6, _state$service$cacheI3, _window$closeBookingE2, _window2;
263
310
  var isSuccess = (_resourcesRef$current = resourcesRef.current) === null || _resourcesRef$current === void 0 ? void 0 : _resourcesRef$current.check();
264
311
  if (isShowTimeAndResource && !isSuccess) {
265
312
  return;
@@ -275,7 +322,7 @@ var Info = function Info(_, ref) {
275
322
  submitLock = false;
276
323
  }, 1500);
277
324
  var _list = _toConsumableArray(state.service.value);
278
- var _item = _objectSpread(_objectSpread({}, state.service.cacheItem), {}, {
325
+ var _item = _objectSpread(_objectSpread({}, cacheItem !== null && cacheItem !== void 0 ? cacheItem : state.service.cacheItem), {}, {
279
326
  autoClose: false
280
327
  });
281
328
  var _extend = _objectSpread(_objectSpread({}, _item._extend), {}, {
@@ -342,18 +389,22 @@ var Info = function Info(_, ref) {
342
389
  }
343
390
  var _id = (_item2 = _item) === null || _item2 === void 0 ? void 0 : _item2._id;
344
391
  var groupId = (_item3 = _item) === null || _item3 === void 0 || (_item3 = _item3._extend) === null || _item3 === void 0 ? void 0 : _item3.groupId;
392
+ var origin_total = (_item$_extend5 = _item._extend) === null || _item$_extend5 === void 0 || (_item$_extend5 = _item$_extend5.items) === null || _item$_extend5 === void 0 || (_item$_extend5 = _item$_extend5[0]) === null || _item$_extend5 === void 0 || (_item$_extend5 = _item$_extend5._extend) === null || _item$_extend5 === void 0 ? void 0 : _item$_extend5.origin_total;
393
+ _item = setProductPrice(_item, {
394
+ newTotal: values.total,
395
+ origin_total: origin_total !== null && origin_total !== void 0 ? origin_total : (_item$_extend6 = _item._extend) === null || _item$_extend6 === void 0 ? void 0 : _item$_extend6.origin_total
396
+ });
345
397
  if (groupId) {
398
+ // 手动改价时移除优惠券使用
399
+ if (isChangeTotal.current) {
400
+ _item = deleteDiscountList(_item);
401
+ }
346
402
  _list = _list.filter(function (d) {
347
403
  var _d$_extend;
348
404
  return ((_d$_extend = d._extend) === null || _d$_extend === void 0 ? void 0 : _d$_extend.groupId) !== groupId;
349
405
  });
350
406
  _list = _list.concat(createBookingItemsByGroup(_item, true));
351
407
  } else {
352
- var _item$_extend5;
353
- _item = setProductPrice(_item, {
354
- newTotal: values.total,
355
- origin_total: (_item$_extend5 = _item._extend) === null || _item$_extend5 === void 0 ? void 0 : _item$_extend5.origin_total
356
- });
357
408
  // 判断是新增还是编辑
358
409
  if (!_list.some(function (d) {
359
410
  return d._id === _id;
@@ -363,7 +414,7 @@ var Info = function Info(_, ref) {
363
414
  } else {
364
415
  // 手动改价时移除优惠券使用
365
416
  if (isChangeTotal.current) {
366
- delete _item.discount_list;
417
+ _item = deleteDiscountList(_item);
367
418
  }
368
419
  _list = _list.map(function (d) {
369
420
  return d._id === _id ? _objectSpread(_objectSpread({}, _item), {}, {
@@ -421,6 +472,8 @@ var Info = function Info(_, ref) {
421
472
  console.log('setEditDatasetEditData', _cacheItem, open);
422
473
  setCurrentTab('batch_edit');
423
474
  isChangeTotal.current = false;
475
+ // 重置编辑标记
476
+ isEditedRef.current = false;
424
477
  var cacheItem = _cacheItem || state.service.cacheItem;
425
478
  var values = cacheItem._extend;
426
479
  var startTime = performance.now();
@@ -579,11 +632,11 @@ var Info = function Info(_, ref) {
579
632
  var isSession = isSessionProduct(item);
580
633
  var sessionValue = {};
581
634
  if (isSession) {
582
- var _item$_extend6, _item$_extend7, _item$_extend8;
635
+ var _item$_extend7, _item$_extend8, _item$_extend9;
583
636
  sessionValue.startEndTime = {
584
- startDate: item === null || item === void 0 || (_item$_extend6 = item._extend) === null || _item$_extend6 === void 0 ? void 0 : _item$_extend6.start_date,
585
- endDate: item === null || item === void 0 || (_item$_extend7 = item._extend) === null || _item$_extend7 === void 0 ? void 0 : _item$_extend7.end_date,
586
- duration: item === null || item === void 0 || (_item$_extend8 = item._extend) === null || _item$_extend8 === void 0 ? void 0 : _item$_extend8.duration
637
+ startDate: item === null || item === void 0 || (_item$_extend7 = item._extend) === null || _item$_extend7 === void 0 ? void 0 : _item$_extend7.start_date,
638
+ endDate: item === null || item === void 0 || (_item$_extend8 = item._extend) === null || _item$_extend8 === void 0 ? void 0 : _item$_extend8.end_date,
639
+ duration: item === null || item === void 0 || (_item$_extend9 = item._extend) === null || _item$_extend9 === void 0 ? void 0 : _item$_extend9.duration
587
640
  };
588
641
  }
589
642
 
@@ -607,7 +660,9 @@ var Info = function Info(_, ref) {
607
660
  })
608
661
  },
609
662
  callback: function callback(e, extension_type, detail) {
610
- var _cacheItem$_extend;
663
+ var _cacheItem$_extend, _cacheItem$_extend2;
664
+ // 标记已执行过编辑操作
665
+ isEditedRef.current = true;
611
666
  var _detail = detail || item;
612
667
  var other = JSON.parse(JSON.stringify(e));
613
668
  other.session = e.session;
@@ -648,6 +703,9 @@ var Info = function Info(_, ref) {
648
703
 
649
704
  // 用于储存原价
650
705
  cacheItem._extend.origin_total = _total;
706
+ (((_cacheItem$_extend = cacheItem._extend) === null || _cacheItem$_extend === void 0 ? void 0 : _cacheItem$_extend.items) || []).forEach(function (item) {
707
+ return item._extend.origin_total = _total;
708
+ });
651
709
 
652
710
  // 覆盖商品
653
711
  dispatch({
@@ -660,7 +718,7 @@ var Info = function Info(_, ref) {
660
718
  // 更新表单内的商品价格
661
719
  form.setFieldsValue({
662
720
  total: _total,
663
- capacity: (_cacheItem$_extend = cacheItem._extend) === null || _cacheItem$_extend === void 0 ? void 0 : _cacheItem$_extend.capacity,
721
+ capacity: (_cacheItem$_extend2 = cacheItem._extend) === null || _cacheItem$_extend2 === void 0 ? void 0 : _cacheItem$_extend2.capacity,
664
722
  quantity: (e === null || e === void 0 ? void 0 : e.quantity) || (values === null || values === void 0 ? void 0 : values.quantity) || 1
665
723
  });
666
724
  }
@@ -993,10 +1051,10 @@ var Info = function Info(_, ref) {
993
1051
  }, [(_state$service$resour2 = state.service.resourcesOrigin) === null || _state$service$resour2 === void 0 ? void 0 : _state$service$resour2.length, isNormalProduct]);
994
1052
  console.log('render edit');
995
1053
  console.log(state.service.editModal && !((_state$service$cacheI16 = state.service.cacheItem) !== null && _state$service$cacheI16 !== void 0 && _state$service$cacheI16.autoClose), performance.now() - window.pp1, '打开商品1');
996
- var _useState7 = useState(false),
997
- _useState8 = _slicedToArray(_useState7, 2),
998
- val = _useState8[0],
999
- setVal = _useState8[1];
1054
+ var _useState9 = useState(false),
1055
+ _useState10 = _slicedToArray(_useState9, 2),
1056
+ val = _useState10[0],
1057
+ setVal = _useState10[1];
1000
1058
  useEffect(function () {
1001
1059
  if (isShowTimeAndResource) {
1002
1060
  setTimeout(function () {
@@ -1098,8 +1156,8 @@ var Info = function Info(_, ref) {
1098
1156
 
1099
1157
  // 计算时长
1100
1158
  if (changedValues !== null && changedValues !== void 0 && changedValues.start_date || changedValues !== null && changedValues !== void 0 && changedValues.end_date) {
1101
- var _cacheItem2 = getCurrentCacheItem();
1102
- var _duration = getDays(_cacheItem2, 'days');
1159
+ var _cacheItem3 = getCurrentCacheItem();
1160
+ var _duration = getDays(_cacheItem3, 'days');
1103
1161
  var start_date = (changedValues === null || changedValues === void 0 ? void 0 : changedValues.start_date) || useStartDate;
1104
1162
  var _end_date = (changedValues === null || changedValues === void 0 ? void 0 : changedValues.end_date) || useEndDate;
1105
1163
  updateMultiDay({
@@ -1113,6 +1171,51 @@ var Info = function Info(_, ref) {
1113
1171
  }
1114
1172
  }
1115
1173
  };
1174
+ var deleteDiscountList = function deleteDiscountList(cacheItem) {
1175
+ var _cacheItem$_extend$ot, _cacheItem$_extend$ot2;
1176
+ delete cacheItem.discount_list;
1177
+ (_cacheItem$_extend$ot = cacheItem._extend.other) === null || _cacheItem$_extend$ot === void 0 || (_cacheItem$_extend$ot = _cacheItem$_extend$ot.bundle) === null || _cacheItem$_extend$ot === void 0 || (_cacheItem$_extend$ot2 = _cacheItem$_extend$ot.forEach) === null || _cacheItem$_extend$ot2 === void 0 || _cacheItem$_extend$ot2.call(_cacheItem$_extend$ot, function (bundle) {
1178
+ bundle === null || bundle === void 0 || delete bundle.discount_list;
1179
+ bundle === null || bundle === void 0 || delete bundle.booking_id;
1180
+ bundle === null || bundle === void 0 || delete bundle.bundle_selling_price;
1181
+ bundle === null || bundle === void 0 || delete bundle.bundle_payment_price;
1182
+ });
1183
+ return cacheItem;
1184
+ };
1185
+ var handleKeepOriginal = function handleKeepOriginal() {
1186
+ setDiscountChangeModalOpen(false);
1187
+ };
1188
+ var handleContinue = /*#__PURE__*/function () {
1189
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
1190
+ var cacheItem;
1191
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
1192
+ while (1) switch (_context2.prev = _context2.next) {
1193
+ case 0:
1194
+ cacheItem = _objectSpread({}, state.service.cacheItem);
1195
+ cacheItem = deleteDiscountList(cacheItem);
1196
+ _context2.next = 4;
1197
+ return shopDiscount.batchSearchByProductIds(noInOriginalDiscountIdsRef.current);
1198
+ case 4:
1199
+ onFinish(valuesRef.current, cacheItem);
1200
+ setDiscountChangeModalOpen(false);
1201
+ case 6:
1202
+ case "end":
1203
+ return _context2.stop();
1204
+ }
1205
+ }, _callee2);
1206
+ }));
1207
+ return function handleContinue() {
1208
+ return _ref3.apply(this, arguments);
1209
+ };
1210
+ }();
1211
+ var handleRemove = function handleRemove() {
1212
+ setDiscountChangeModalOpen(false);
1213
+ var cacheItem = deleteDiscountList(_objectSpread({}, state.service.cacheItem));
1214
+ onFinish(valuesRef.current, cacheItem);
1215
+ };
1216
+ var handleCancel = function handleCancel() {
1217
+ setDiscountChangeModalOpen(false);
1218
+ };
1116
1219
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Drawer, {
1117
1220
  titleNoWrap: true
1118
1221
  //通过zIndex的方式控制 添加商品 和 编辑服务弹窗的上下层级
@@ -1139,7 +1242,7 @@ var Info = function Info(_, ref) {
1139
1242
  }, groupDom, /*#__PURE__*/React.createElement(Form, {
1140
1243
  layout: "vertical",
1141
1244
  form: form,
1142
- onFinish: onFinish,
1245
+ onFinish: onFinishBefore,
1143
1246
  onValuesChange: onValuesChange,
1144
1247
  style: {
1145
1248
  display: currentTab === 'batch_edit' ? 'block' : 'none'
@@ -1158,6 +1261,12 @@ var Info = function Info(_, ref) {
1158
1261
  onConfirm: handleNoteConfirm,
1159
1262
  onDelete: handleNoteDelete,
1160
1263
  onCancel: handleNoteCancel
1161
- }))), footer)));
1264
+ }))), footer)), /*#__PURE__*/React.createElement(DiscountChangeModal, {
1265
+ open: discountChangeModalOpen,
1266
+ onKeepOriginal: handleKeepOriginal,
1267
+ onContinue: handleContinue,
1268
+ onRemove: handleRemove,
1269
+ onCancel: handleCancel
1270
+ }));
1162
1271
  };
1163
1272
  export default /*#__PURE__*/forwardRef(Info);
@@ -26,3 +26,9 @@ export declare const setProductPrice: (cacheItem: any, { newTotal, origin_total
26
26
  newTotal: number;
27
27
  origin_total: number;
28
28
  }) => any;
29
+ /**
30
+ * 获取商品所有折扣列表 包含子商品
31
+ * @param cacheItem - 缓存的商品项
32
+ * @returns 折扣列表
33
+ */
34
+ export declare const getProductAllDiscountList: (cacheItem: any) => any;
@@ -1,4 +1,10 @@
1
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
3
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
5
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
6
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
7
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
2
8
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
9
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
10
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
@@ -17,6 +23,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
17
23
  import { isArr } from "@pisell/utils";
18
24
  import { isBoolean } from "@pisell/utils";
19
25
  import Decimal from "decimal.js";
26
+ import { getBundleDiscountList } from "../../../components/footer/utils";
20
27
  var isNewService = function isNewService(service) {
21
28
  return !service.new && service._extend.endDate;
22
29
  };
@@ -118,4 +125,18 @@ export var setProductPrice = function setProductPrice(cacheItem, _ref2) {
118
125
  // 主商品价格 = newTotal - 子商品总价(让主商品吸收精度误差,确保总价精确)
119
126
  cacheItem._extend.price = new Decimal(newTotal).sub(subTotal).toNumber();
120
127
  return cacheItem;
128
+ };
129
+
130
+ /**
131
+ * 获取商品所有折扣列表 包含子商品
132
+ * @param cacheItem - 缓存的商品项
133
+ * @returns 折扣列表
134
+ */
135
+ export var getProductAllDiscountList = function getProductAllDiscountList(cacheItem) {
136
+ var _cacheItem$_extend, _discountList;
137
+ var discountList = [];
138
+ discountList = cacheItem.discount_list || [];
139
+ var bundleDiscountList = getBundleDiscountList(((_cacheItem$_extend = cacheItem._extend) === null || _cacheItem$_extend === void 0 || (_cacheItem$_extend = _cacheItem$_extend.other) === null || _cacheItem$_extend === void 0 ? void 0 : _cacheItem$_extend.bundle) || []) || [];
140
+ (_discountList = discountList).push.apply(_discountList, _toConsumableArray(bundleDiscountList));
141
+ return discountList;
121
142
  };