@pisell/private-materials 6.6.73 → 6.6.74

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.
@@ -52,6 +52,20 @@ import { useShopDiscountModule } from "../../../../ticketBooking/hooks/pisellos/
52
52
  import DiscountChangeModal from "./DiscountChangeModal";
53
53
  import Decimal from "decimal.js";
54
54
  var submitLock = false;
55
+
56
+ /**
57
+ * 判断 list 项是否与当前编辑项为同一条已存在预约(_id 失配时的 fallback)
58
+ * 仅当 booking_id、order_detail_id 均有效时成立,避免新建预约误匹配
59
+ */
60
+ var isSameBookingServiceItem = function isSameBookingServiceItem(listItem, editItem) {
61
+ var _editItem$_extend, _listItem$_extend;
62
+ var bookingId = editItem === null || editItem === void 0 ? void 0 : editItem.booking_id;
63
+ var orderDetailId = editItem === null || editItem === void 0 || (_editItem$_extend = editItem._extend) === null || _editItem$_extend === void 0 ? void 0 : _editItem$_extend.order_detail_id;
64
+ if (!bookingId || !orderDetailId) {
65
+ return false;
66
+ }
67
+ return (listItem === null || listItem === void 0 ? void 0 : listItem.booking_id) === bookingId && (listItem === null || listItem === void 0 || (_listItem$_extend = listItem._extend) === null || _listItem$_extend === void 0 ? void 0 : _listItem$_extend.order_detail_id) === orderDetailId;
68
+ };
55
69
  var Info = function Info(_, ref) {
56
70
  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;
57
71
  var _Form$useForm = Form.useForm(),
@@ -437,22 +451,44 @@ var Info = function Info(_, ref) {
437
451
  newTotal: values.total,
438
452
  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
439
453
  });
440
- // 判断是新增还是编辑
441
- if (!_list.some(function (d) {
454
+ // 判断是新增还是编辑:优先 _id;失配时用 booking_id + order_detail_id fallback 并去重
455
+ var matchById = _list.some(function (d) {
442
456
  return d._id === _id;
443
- })) {
444
- var detail = addService(_list, _item, state);
445
- _list = detail.list;
446
- } else {
447
- // 手动改价时移除优惠券使用
457
+ });
458
+ var matchByBooking = !matchById && _list.some(function (d) {
459
+ return isSameBookingServiceItem(d, _item);
460
+ });
461
+ if (matchById || matchByBooking) {
448
462
  if (isChangeTotal.current) {
449
463
  _item = deleteDiscountList(_item);
450
464
  }
451
- _list = _list.map(function (d) {
452
- return d._id === _id ? _objectSpread(_objectSpread({}, _item), {}, {
453
- new: 0
454
- }) : d;
455
- });
465
+ if (matchById) {
466
+ _list = _list.map(function (d) {
467
+ return d._id === _id ? _objectSpread(_objectSpread({}, _item), {}, {
468
+ new: 0
469
+ }) : d;
470
+ });
471
+ } else {
472
+ // fallback:合并同预约重复项,沿用 list 内 _id 避免再次失配
473
+ var replaced = false;
474
+ _list = _list.reduce(function (acc, d) {
475
+ if (isSameBookingServiceItem(d, _item)) {
476
+ if (!replaced) {
477
+ acc.push(_objectSpread(_objectSpread({}, _item), {}, {
478
+ new: 0,
479
+ _id: d._id
480
+ }));
481
+ replaced = true;
482
+ }
483
+ } else {
484
+ acc.push(d);
485
+ }
486
+ return acc;
487
+ }, []);
488
+ }
489
+ } else {
490
+ var detail = addService(_list, _item, state);
491
+ _list = detail.list;
456
492
  }
457
493
  }
458
494
  deleteCacheParams();
@@ -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<"stripe" | "tyro" | "windcave" | "mx51" | "payo" | "linkly" | "huifu">;
22
+ readonly eftposRef: React.MutableRefObject<"stripe" | "tyro" | "mx51" | "payo" | "windcave" | "linkly" | "huifu">;
23
23
  readonly clientRef: React.MutableRefObject<ClientEnum>;
24
24
  readonly dataRef: React.MutableRefObject<import("./store").State>;
25
25
  };
@@ -299,8 +299,8 @@ export declare const backUpFree: (payload: Partial<State>) => {
299
299
  amount?: string | number | undefined;
300
300
  mode?: "pay" | "refund" | "fullPay" | "query" | undefined;
301
301
  order_id?: string | number | undefined;
302
- eftpos?: "stripe" | "tyro" | "windcave" | "mx51" | "payo" | "linkly" | "huifu" | undefined;
303
- action?: "amount" | "pay" | "deviceList" | undefined;
302
+ eftpos?: "stripe" | "tyro" | "mx51" | "payo" | "windcave" | "linkly" | "huifu" | undefined;
303
+ action?: "pay" | "amount" | "deviceList" | undefined;
304
304
  key?: number | undefined;
305
305
  step?: number | undefined;
306
306
  title?: string | undefined;
@@ -65,6 +65,15 @@ var import_useShopDiscountModule = require("../../../../ticketBooking/hooks/pise
65
65
  var import_DiscountChangeModal = __toESM(require("./DiscountChangeModal"));
66
66
  var import_decimal = __toESM(require("decimal.js"));
67
67
  var submitLock = false;
68
+ var isSameBookingServiceItem = (listItem, editItem) => {
69
+ var _a, _b;
70
+ const bookingId = editItem == null ? void 0 : editItem.booking_id;
71
+ const orderDetailId = (_a = editItem == null ? void 0 : editItem._extend) == null ? void 0 : _a.order_detail_id;
72
+ if (!bookingId || !orderDetailId) {
73
+ return false;
74
+ }
75
+ return (listItem == null ? void 0 : listItem.booking_id) === bookingId && ((_b = listItem == null ? void 0 : listItem._extend) == null ? void 0 : _b.order_detail_id) === orderDetailId;
76
+ };
68
77
  var Info = (_, ref) => {
69
78
  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, _J, _K;
70
79
  const [form] = import_antd.Form.useForm();
@@ -330,14 +339,31 @@ var Info = (_, ref) => {
330
339
  newTotal: values.total,
331
340
  origin_total: origin_total ?? ((_o2 = _item._extend) == null ? void 0 : _o2.origin_total)
332
341
  });
333
- if (!_list.some((d) => d._id === _id)) {
334
- const detail = (0, import_utils3.addService)(_list, _item, state);
335
- _list = detail.list;
336
- } else {
342
+ const matchById = _list.some((d) => d._id === _id);
343
+ const matchByBooking = !matchById && _list.some((d) => isSameBookingServiceItem(d, _item));
344
+ if (matchById || matchByBooking) {
337
345
  if (isChangeTotal.current) {
338
346
  _item = deleteDiscountList(_item);
339
347
  }
340
- _list = _list.map((d) => d._id === _id ? { ..._item, new: 0 } : d);
348
+ if (matchById) {
349
+ _list = _list.map((d) => d._id === _id ? { ..._item, new: 0 } : d);
350
+ } else {
351
+ let replaced = false;
352
+ _list = _list.reduce((acc, d) => {
353
+ if (isSameBookingServiceItem(d, _item)) {
354
+ if (!replaced) {
355
+ acc.push({ ..._item, new: 0, _id: d._id });
356
+ replaced = true;
357
+ }
358
+ } else {
359
+ acc.push(d);
360
+ }
361
+ return acc;
362
+ }, []);
363
+ }
364
+ } else {
365
+ const detail = (0, import_utils3.addService)(_list, _item, state);
366
+ _list = detail.list;
341
367
  }
342
368
  }
343
369
  (0, import_utils6.deleteCacheParams)();
@@ -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<"stripe" | "tyro" | "windcave" | "mx51" | "payo" | "linkly" | "huifu">;
22
+ readonly eftposRef: React.MutableRefObject<"stripe" | "tyro" | "mx51" | "payo" | "windcave" | "linkly" | "huifu">;
23
23
  readonly clientRef: React.MutableRefObject<ClientEnum>;
24
24
  readonly dataRef: React.MutableRefObject<import("./store").State>;
25
25
  };
@@ -299,8 +299,8 @@ export declare const backUpFree: (payload: Partial<State>) => {
299
299
  amount?: string | number | undefined;
300
300
  mode?: "pay" | "refund" | "fullPay" | "query" | undefined;
301
301
  order_id?: string | number | undefined;
302
- eftpos?: "stripe" | "tyro" | "windcave" | "mx51" | "payo" | "linkly" | "huifu" | undefined;
303
- action?: "amount" | "pay" | "deviceList" | undefined;
302
+ eftpos?: "stripe" | "tyro" | "mx51" | "payo" | "windcave" | "linkly" | "huifu" | undefined;
303
+ action?: "pay" | "amount" | "deviceList" | undefined;
304
304
  key?: number | undefined;
305
305
  step?: number | undefined;
306
306
  title?: string | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pisell/private-materials",
3
- "version": "6.6.73",
3
+ "version": "6.6.74",
4
4
  "main": "./lib/index.js",
5
5
  "module": "./es/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -61,10 +61,10 @@
61
61
  "styled-components": "^6.0.0-rc.3",
62
62
  "@react-spring/web": "^9.6.1",
63
63
  "@use-gesture/react": "^10.3.1",
64
- "@pisell/utils": "3.0.2",
65
64
  "@pisell/materials": "6.6.17",
66
65
  "@pisell/date-picker": "3.0.7",
67
- "@pisell/icon": "0.0.11"
66
+ "@pisell/icon": "0.0.11",
67
+ "@pisell/utils": "3.0.2"
68
68
  },
69
69
  "peerDependencies": {
70
70
  "react": "^18.0.0",