@pisell/private-materials 6.12.267 → 6.12.268

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.
@@ -3,6 +3,7 @@ import { _objectSpread2 } from "../../../../_virtual/_@oxc-project_runtime@0.122
3
3
  import { _asyncToGenerator } from "../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js";
4
4
  import index from "../../../../plus/productSelect/index.js";
5
5
  import { transformProductDetailToOrderProduct } from "../../../scanOrder/utils/transformProductDetail.js";
6
+ import { getVenueBookingProductIdentity, getVenueBookingProductUid } from "../../utils/orderProductIdentity.js";
6
7
  import { useVenueBookingContext } from "../../context.js";
7
8
  import React, { useEffect, useRef } from "react";
8
9
  import { Modal } from "antd";
@@ -20,6 +21,10 @@ function Addons() {
20
21
  const { utils } = useEngineContext().appHelper || {};
21
22
  const { runModuleAction, refreshViewModel, viewModel, goToStep } = useVenueBookingContext();
22
23
  const productList = viewModel.addonProductList || [];
24
+ const addonCartItems = (Array.isArray(viewModel.cartItems) ? viewModel.cartItems : []).filter((cartItem) => {
25
+ var _cartItem$metadata;
26
+ return !(cartItem === null || cartItem === void 0 || (_cartItem$metadata = cartItem.metadata) === null || _cartItem$metadata === void 0 ? void 0 : _cartItem$metadata.venue_booking);
27
+ });
23
28
  const scrollRef = useRef(null);
24
29
  const isMobileView = isMobile();
25
30
  const maxHeight = window.innerHeight - 100;
@@ -68,20 +73,15 @@ function Addons() {
68
73
  }();
69
74
  const removeOrderProduct = function() {
70
75
  var _ref3 = _asyncToGenerator(function* (params) {
71
- const { product_id, product_variant_id, identity_key, sourceData } = params;
76
+ const { identity, sourceData } = params;
72
77
  try {
73
- yield runModuleAction("removeProductFromOrder", _objectSpread2({
74
- product_id,
75
- product_variant_id
76
- }, identity_key ? { identity_key } : {}));
78
+ yield runModuleAction("removeProductFromOrder", identity);
77
79
  yield refreshViewModel();
78
80
  } catch (error) {
79
81
  console.error("[venueBooking] removeProductFromOrder failed", {
80
82
  error,
81
83
  sourceData,
82
- product_id,
83
- product_variant_id,
84
- identity_key
84
+ identity
85
85
  });
86
86
  }
87
87
  });
@@ -91,21 +91,16 @@ function Addons() {
91
91
  }();
92
92
  const updateOrderProduct = function() {
93
93
  var _ref4 = _asyncToGenerator(function* (params) {
94
- const { product_id, product_variant_id, identity_key, updates, sourceData } = params;
94
+ const { identity, num, sourceData } = params;
95
95
  try {
96
- yield runModuleAction("updateProductInOrder", _objectSpread2(_objectSpread2({
97
- product_id,
98
- product_variant_id
99
- }, identity_key ? { identity_key } : {}), {}, { updates }));
96
+ yield runModuleAction("updateOrderProduct", _objectSpread2(_objectSpread2({}, identity), {}, { updates: { num } }));
100
97
  yield refreshViewModel();
101
98
  } catch (error) {
102
- console.error("[venueBooking] updateProductInOrder failed", {
99
+ console.error("[venueBooking] updateOrderProduct failed", {
103
100
  error,
104
101
  sourceData,
105
- product_id,
106
- product_variant_id,
107
- identity_key,
108
- updates
102
+ identity,
103
+ num
109
104
  });
110
105
  }
111
106
  });
@@ -123,7 +118,7 @@ function Addons() {
123
118
  var _ref7 = _asyncToGenerator(function* (item, clickType, meta) {
124
119
  const sourceItem = (meta === null || meta === void 0 ? void 0 : meta.product) || item;
125
120
  if ((meta === null || meta === void 0 ? void 0 : meta.intent) === "quantity") {
126
- var _item$option, _item$bundle, _item$price, _item$product_id, _ref5, _meta$quantity, _orderProduct$product, _orderProduct$product4;
121
+ var _item$option, _item$bundle, _item$price, _item$product_id, _ref5, _meta$quantity, _orderProduct$product;
127
122
  const quantityData = _objectSpread2(_objectSpread2({}, item), {}, {
128
123
  quantity: item === null || item === void 0 ? void 0 : item.num,
129
124
  option: (_item$option = item === null || item === void 0 ? void 0 : item.option) !== null && _item$option !== void 0 ? _item$option : item === null || item === void 0 ? void 0 : item.product_option_item,
@@ -150,17 +145,36 @@ function Addons() {
150
145
  return;
151
146
  }
152
147
  const normalizedQuantity = Number.isNaN(nextQuantity) ? 0 : Math.max(0, Math.floor(nextQuantity));
153
- const existedCartItem = (Array.isArray(viewModel === null || viewModel === void 0 ? void 0 : viewModel.cartItems) ? viewModel.cartItems : []).find((cartItem) => {
154
- var _cartItem$product_id, _orderProduct$product2, _cartItem$product_var;
155
- return String((_cartItem$product_id = cartItem === null || cartItem === void 0 ? void 0 : cartItem.product_id) !== null && _cartItem$product_id !== void 0 ? _cartItem$product_id : null) === String((_orderProduct$product2 = orderProduct === null || orderProduct === void 0 ? void 0 : orderProduct.product_id) !== null && _orderProduct$product2 !== void 0 ? _orderProduct$product2 : null) && Number((_cartItem$product_var = cartItem === null || cartItem === void 0 ? void 0 : cartItem.product_variant_id) !== null && _cartItem$product_var !== void 0 ? _cartItem$product_var : 0) === productVariantId;
148
+ const productCartItems = addonCartItems.filter((cartItem) => {
149
+ var _cartItem$product_id, _orderProduct$product2;
150
+ return String((_cartItem$product_id = cartItem === null || cartItem === void 0 ? void 0 : cartItem.product_id) !== null && _cartItem$product_id !== void 0 ? _cartItem$product_id : null) === String((_orderProduct$product2 = orderProduct === null || orderProduct === void 0 ? void 0 : orderProduct.product_id) !== null && _orderProduct$product2 !== void 0 ? _orderProduct$product2 : null);
151
+ });
152
+ const matchedCartItems = productCartItems.filter((cartItem) => {
153
+ var _cartItem$product_var;
154
+ return Number((_cartItem$product_var = cartItem === null || cartItem === void 0 ? void 0 : cartItem.product_variant_id) !== null && _cartItem$product_var !== void 0 ? _cartItem$product_var : 0) === productVariantId;
156
155
  });
157
- const existedIdentityKey = typeof (existedCartItem === null || existedCartItem === void 0 ? void 0 : existedCartItem.identity_key) === "string" && existedCartItem.identity_key.length > 0 ? existedCartItem.identity_key : void 0;
156
+ const eventUid = getVenueBookingProductUid(item);
157
+ const uidMatchedItems = eventUid ? matchedCartItems.filter((cartItem) => getVenueBookingProductUid(cartItem) === eventUid) : matchedCartItems;
158
+ if (productCartItems.length > 1 || eventUid && uidMatchedItems.length !== 1) {
159
+ console.warn("[venueBooking] quantity action skipped: ambiguous or stale order line", {
160
+ mode: eventUid ? "uid" : "sku",
161
+ eventUid,
162
+ product_id: orderProduct.product_id,
163
+ product_variant_id: productVariantId,
164
+ matchedLineCount: productCartItems.length
165
+ });
166
+ return;
167
+ }
168
+ const existedCartItem = uidMatchedItems[0];
169
+ const existedIdentity = existedCartItem ? getVenueBookingProductIdentity(existedCartItem) : null;
170
+ if (existedCartItem && !existedIdentity) {
171
+ console.warn("[venueBooking] quantity action skipped: missing order line UID", { item: existedCartItem });
172
+ return;
173
+ }
158
174
  if (normalizedQuantity <= 0) {
159
- var _orderProduct$product3;
175
+ if (!existedIdentity) return;
160
176
  yield removeOrderProduct({
161
- product_id: (_orderProduct$product3 = orderProduct === null || orderProduct === void 0 ? void 0 : orderProduct.product_id) !== null && _orderProduct$product3 !== void 0 ? _orderProduct$product3 : null,
162
- product_variant_id: productVariantId,
163
- identity_key: existedIdentityKey,
177
+ identity: existedIdentity,
164
178
  sourceData: quantityData
165
179
  });
166
180
  return;
@@ -172,14 +186,10 @@ function Addons() {
172
186
  });
173
187
  return;
174
188
  }
189
+ if (!existedIdentity) return;
175
190
  yield updateOrderProduct({
176
- product_id: (_orderProduct$product4 = orderProduct === null || orderProduct === void 0 ? void 0 : orderProduct.product_id) !== null && _orderProduct$product4 !== void 0 ? _orderProduct$product4 : null,
177
- product_variant_id: productVariantId,
178
- identity_key: existedIdentityKey,
179
- updates: {
180
- num: normalizedQuantity,
181
- _origin: orderProduct === null || orderProduct === void 0 ? void 0 : orderProduct._origin
182
- },
191
+ identity: existedIdentity,
192
+ num: normalizedQuantity,
183
193
  sourceData: quantityData
184
194
  });
185
195
  } else utils === null || utils === void 0 || utils.action({
@@ -237,7 +247,7 @@ function Addons() {
237
247
  customScrollParent: ((_scrollRef$current = scrollRef.current) === null || _scrollRef$current === void 0 ? void 0 : _scrollRef$current.getScrollContainer()) || "",
238
248
  hideCategoryWhenOne: true,
239
249
  version: "v2",
240
- value: (viewModel === null || viewModel === void 0 ? void 0 : viewModel.cartItems) || [],
250
+ value: addonCartItems,
241
251
  productListSetting: {
242
252
  imgWidth: 80,
243
253
  imgHeight: 80
@@ -3,6 +3,7 @@ import { _objectSpread2 } from "../../../../_virtual/_@oxc-project_runtime@0.122
3
3
  import { _asyncToGenerator } from "../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js";
4
4
  import shoppingCart from "../../../shoppingCart/index.js";
5
5
  import SubTotal from "../../../subTotal/index.js";
6
+ import { getVenueBookingProductIdentity } from "../../utils/orderProductIdentity.js";
6
7
  import { useVenueBookingContext } from "../../context.js";
7
8
  import VoucherCard from "../Voucher/index.js";
8
9
  import VenueDeposit from "../Deposit/index.js";
@@ -20,7 +21,7 @@ import "./index.less";
20
21
  function Cart(props) {
21
22
  var _engineContext$appHel, _engineContext$appHel2, _engineContext$appHel3, _engineContext$engine, _businessUtils$getApp, _businessUtils$getApp2, _ref, _ref2, _ref3, _summary$total_amount, _summary$deposit3;
22
23
  const { open, onCancel, onNext, items, summary, embedded = false, confirmLoading = false, extraContent } = props;
23
- const { currentStep, runModuleAction, refreshViewModel, venueBookingModule, isAgreeDepositPolicy, setIsAgreeDepositPolicy } = useVenueBookingContext();
24
+ const { currentStep, runModuleAction, refreshViewModel, refreshTimeSlotGrid, venueBookingModule, isAgreeDepositPolicy, setIsAgreeDepositPolicy } = useVenueBookingContext();
24
25
  const engineContext = useEngineContext();
25
26
  const businessUtils = engineContext === null || engineContext === void 0 || (_engineContext$appHel = engineContext.appHelper) === null || _engineContext$appHel === void 0 || (_engineContext$appHel = _engineContext$appHel.utils) === null || _engineContext$appHel === void 0 ? void 0 : _engineContext$appHel.businessUtils;
26
27
  const symbol = String((engineContext === null || engineContext === void 0 || (_engineContext$appHel2 = engineContext.appHelper) === null || _engineContext$appHel2 === void 0 || (_engineContext$appHel2 = _engineContext$appHel2.utils) === null || _engineContext$appHel2 === void 0 || (_engineContext$appHel3 = _engineContext$appHel2.getSymbolic) === null || _engineContext$appHel3 === void 0 ? void 0 : _engineContext$appHel3.call(_engineContext$appHel2)) || "$");
@@ -104,14 +105,14 @@ function Cart(props) {
104
105
  * 调用 OS 模块 removeProductFromOrder 后刷新 viewModel
105
106
  */
106
107
  const isVenueBookingCartItem = (target) => {
108
+ var _target$metadata;
107
109
  if (!target || typeof target !== "object") return false;
110
+ if ((_target$metadata = target.metadata) === null || _target$metadata === void 0 ? void 0 : _target$metadata.venue_booking) return true;
108
111
  if ((target === null || target === void 0 ? void 0 : target.start_date) && (target === null || target === void 0 ? void 0 : target.end_date)) return true;
109
- if (String((target === null || target === void 0 ? void 0 : target.identity_key) || "").startsWith("venue:")) return true;
110
112
  return false;
111
113
  };
112
114
  const handleCartChange = function() {
113
- var _ref6 = _asyncToGenerator(function* (item, type, sourceItem) {
114
- var _ref5, _targetItem$product_i, _targetItem$product_v;
115
+ var _ref5 = _asyncToGenerator(function* (item, type, sourceItem) {
115
116
  if (type !== "delete") return;
116
117
  const targetItem = sourceItem && typeof sourceItem === "object" ? sourceItem : item;
117
118
  if (currentStep !== "select-venue" && isVenueBookingCartItem(targetItem)) {
@@ -121,20 +122,14 @@ function Cart(props) {
121
122
  });
122
123
  return;
123
124
  }
124
- const productId = (_ref5 = (_targetItem$product_i = targetItem === null || targetItem === void 0 ? void 0 : targetItem.product_id) !== null && _targetItem$product_i !== void 0 ? _targetItem$product_i : targetItem === null || targetItem === void 0 ? void 0 : targetItem.id) !== null && _ref5 !== void 0 ? _ref5 : null;
125
- const productVariantId = Number((_targetItem$product_v = targetItem === null || targetItem === void 0 ? void 0 : targetItem.product_variant_id) !== null && _targetItem$product_v !== void 0 ? _targetItem$product_v : 0);
126
- const identityKey = targetItem === null || targetItem === void 0 ? void 0 : targetItem.identity_key;
127
- if (productId === null && Number.isNaN(productVariantId)) return;
128
- if (typeof identityKey !== "string" || identityKey.length === 0) {
129
- console.error("[venueBooking] removeProductFromOrder skipped: missing identity_key", { item: targetItem });
125
+ const identity = getVenueBookingProductIdentity(targetItem);
126
+ if (!identity) {
127
+ console.error("[venueBooking] removeProductFromOrder skipped: missing product UID", { item: targetItem });
130
128
  return;
131
129
  }
132
130
  try {
133
- yield runModuleAction("removeProductFromOrder", {
134
- product_id: productId,
135
- product_variant_id: Number.isNaN(productVariantId) ? 0 : productVariantId,
136
- identity_key: identityKey
137
- });
131
+ yield runModuleAction("removeProductFromOrder", identity);
132
+ refreshTimeSlotGrid();
138
133
  yield refreshViewModel();
139
134
  } catch (error) {
140
135
  console.error("[venueBooking] removeProductFromOrder failed", {
@@ -144,7 +139,7 @@ function Cart(props) {
144
139
  }
145
140
  });
146
141
  return function handleCartChange(_x, _x2, _x3) {
147
- return _ref6.apply(this, arguments);
142
+ return _ref5.apply(this, arguments);
148
143
  };
149
144
  }();
150
145
  useEffect(() => {
@@ -1,7 +1,9 @@
1
1
  import useEngineContext, { usePisellOS } from "../../hooks/useEngineContext.js";
2
+ import { _objectSpread2 } from "../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js";
2
3
  import { _asyncToGenerator } from "../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js";
3
4
  import useSalesUserLogin from "../../hooks/useSalesUserLogin.js";
4
5
  import { toShoppingCartProducts } from "../scanOrder/utils/toShoppingCartProducts.js";
6
+ import { getVenueBookingProductUid } from "./utils/orderProductIdentity.js";
5
7
  import { useRef } from "react";
6
8
  //#region src/components/venueBooking/hooks.ts
7
9
  /**
@@ -199,12 +201,22 @@ function createVenueBookingViewModel(_x10) {
199
201
  function _createVenueBookingViewModel() {
200
202
  _createVenueBookingViewModel = _asyncToGenerator(function* (module) {
201
203
  const summaryByGetter = typeof (module === null || module === void 0 ? void 0 : module.getSummary) === "function" ? yield module.getSummary() : null;
202
- const orderProducts = callModuleGetter(module, "getOrderProducts", []);
204
+ const rawOrderProducts = callModuleGetter(module, "getOrderProducts", []);
205
+ const orderProducts = Array.isArray(rawOrderProducts) ? rawOrderProducts : [];
203
206
  const tempOrder = callModuleGetter(module, "getTempOrder", null);
204
- const amountSymbol = (tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.currency_symbol) || "$";
205
207
  const cartItems = toShoppingCartProducts({
206
- orderProducts: Array.isArray(orderProducts) ? orderProducts : [],
207
- amountSymbol
208
+ orderProducts,
209
+ amountSymbol: (tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.currency_symbol) || "$"
210
+ }).map((item, index) => {
211
+ const product = orderProducts[index];
212
+ const uid = getVenueBookingProductUid(product);
213
+ return _objectSpread2(_objectSpread2({}, item), {}, {
214
+ metadata: product.metadata,
215
+ product_sku: product.product_sku,
216
+ unique_identification_number: uid,
217
+ _id: uid !== null && uid !== void 0 ? uid : item._id,
218
+ rowKey: uid !== null && uid !== void 0 ? uid : item.rowKey
219
+ });
208
220
  });
209
221
  const summary = (summaryByGetter && typeof summaryByGetter === "object" ? summaryByGetter : null) || (tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.summary) || {};
210
222
  return {
@@ -0,0 +1,15 @@
1
+ import { pickIdentity } from "../../../plus/salesSdk/utils/identity.js";
2
+ //#region src/components/venueBooking/utils/orderProductIdentity.ts
3
+ /** VenueBooking 删改必须定位具体订单行,不能退回只按商品/SKU 匹配。 */
4
+ function getVenueBookingProductIdentity(line) {
5
+ if (!line || typeof line !== "object") return null;
6
+ const identity = pickIdentity(line);
7
+ if (typeof identity.unique_identification_number !== "string" || identity.unique_identification_number.length === 0) return null;
8
+ return identity;
9
+ }
10
+ function getVenueBookingProductUid(line) {
11
+ var _getVenueBookingProdu;
12
+ return (_getVenueBookingProdu = getVenueBookingProductIdentity(line)) === null || _getVenueBookingProdu === void 0 ? void 0 : _getVenueBookingProdu.unique_identification_number;
13
+ }
14
+ //#endregion
15
+ export { getVenueBookingProductIdentity, getVenueBookingProductUid };
@@ -1,10 +1,10 @@
1
1
  import { _objectSpread2 } from "../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js";
2
2
  import dayjs from "dayjs";
3
- import timezone from "dayjs/plugin/timezone";
4
- import utc from "dayjs/plugin/utc";
3
+ import timezonePlugin from "dayjs/plugin/timezone";
4
+ import utcPlugin from "dayjs/plugin/utc";
5
5
  //#region src/plus/saasDevice/devicePasscodes/model.ts
6
- dayjs.extend(utc);
7
- dayjs.extend(timezone);
6
+ dayjs.extend(utcPlugin);
7
+ dayjs.extend(timezonePlugin);
8
8
  const INITIAL_DEVICE_PASSCODE_STATE = {
9
9
  deviceIds: [],
10
10
  devicesById: {}
@@ -6,12 +6,12 @@ import React, { useCallback, useEffect, useMemo, useRef } from "react";
6
6
  import { locales } from "@pisell/utils";
7
7
  import { Button, PisellEmpty, PisellModal, PisellStatisticList, Skeleton, Timeline, usePisellConfig } from "@pisell/materials";
8
8
  import { useRequest } from "ahooks";
9
- import timezone from "dayjs/plugin/timezone";
10
- import utc from "dayjs/plugin/utc";
9
+ import timezonePlugin from "dayjs/plugin/timezone";
10
+ import utcPlugin from "dayjs/plugin/utc";
11
11
  import "./index.less";
12
12
  //#region src/plus/walletPassGallery/components/timelineSection/index.tsx
13
- dayjs.extend(timezone);
14
- dayjs.extend(utc);
13
+ dayjs.extend(timezonePlugin);
14
+ dayjs.extend(utcPlugin);
15
15
  const stateTimeUnix = 1723255863;
16
16
  const POLL_INTERVAL = 2e3;
17
17
  const POLL_MAX_TIMES = 5;
@@ -4,6 +4,7 @@ const require_objectSpread2 = require("../../../../_virtual/_@oxc-project_runtim
4
4
  const require_asyncToGenerator = require("../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js");
5
5
  const require_index = require("../../../../plus/productSelect/index.js");
6
6
  const require_transformProductDetail = require("../../../scanOrder/utils/transformProductDetail.js");
7
+ const require_orderProductIdentity = require("../../utils/orderProductIdentity.js");
7
8
  const require_context = require("../../context.js");
8
9
  let react = require("react");
9
10
  react = require_runtime.__toESM(react);
@@ -22,6 +23,10 @@ function Addons() {
22
23
  const { utils } = require_useEngineContext.default().appHelper || {};
23
24
  const { runModuleAction, refreshViewModel, viewModel, goToStep } = require_context.useVenueBookingContext();
24
25
  const productList = viewModel.addonProductList || [];
26
+ const addonCartItems = (Array.isArray(viewModel.cartItems) ? viewModel.cartItems : []).filter((cartItem) => {
27
+ var _cartItem$metadata;
28
+ return !(cartItem === null || cartItem === void 0 || (_cartItem$metadata = cartItem.metadata) === null || _cartItem$metadata === void 0 ? void 0 : _cartItem$metadata.venue_booking);
29
+ });
25
30
  const scrollRef = (0, react.useRef)(null);
26
31
  const isMobileView = (0, _pisell_utils.isMobile)();
27
32
  const maxHeight = window.innerHeight - 100;
@@ -70,20 +75,15 @@ function Addons() {
70
75
  }();
71
76
  const removeOrderProduct = function() {
72
77
  var _ref3 = require_asyncToGenerator._asyncToGenerator(function* (params) {
73
- const { product_id, product_variant_id, identity_key, sourceData } = params;
78
+ const { identity, sourceData } = params;
74
79
  try {
75
- yield runModuleAction("removeProductFromOrder", require_objectSpread2._objectSpread2({
76
- product_id,
77
- product_variant_id
78
- }, identity_key ? { identity_key } : {}));
80
+ yield runModuleAction("removeProductFromOrder", identity);
79
81
  yield refreshViewModel();
80
82
  } catch (error) {
81
83
  console.error("[venueBooking] removeProductFromOrder failed", {
82
84
  error,
83
85
  sourceData,
84
- product_id,
85
- product_variant_id,
86
- identity_key
86
+ identity
87
87
  });
88
88
  }
89
89
  });
@@ -93,21 +93,16 @@ function Addons() {
93
93
  }();
94
94
  const updateOrderProduct = function() {
95
95
  var _ref4 = require_asyncToGenerator._asyncToGenerator(function* (params) {
96
- const { product_id, product_variant_id, identity_key, updates, sourceData } = params;
96
+ const { identity, num, sourceData } = params;
97
97
  try {
98
- yield runModuleAction("updateProductInOrder", require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({
99
- product_id,
100
- product_variant_id
101
- }, identity_key ? { identity_key } : {}), {}, { updates }));
98
+ yield runModuleAction("updateOrderProduct", require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, identity), {}, { updates: { num } }));
102
99
  yield refreshViewModel();
103
100
  } catch (error) {
104
- console.error("[venueBooking] updateProductInOrder failed", {
101
+ console.error("[venueBooking] updateOrderProduct failed", {
105
102
  error,
106
103
  sourceData,
107
- product_id,
108
- product_variant_id,
109
- identity_key,
110
- updates
104
+ identity,
105
+ num
111
106
  });
112
107
  }
113
108
  });
@@ -125,7 +120,7 @@ function Addons() {
125
120
  var _ref7 = require_asyncToGenerator._asyncToGenerator(function* (item, clickType, meta) {
126
121
  const sourceItem = (meta === null || meta === void 0 ? void 0 : meta.product) || item;
127
122
  if ((meta === null || meta === void 0 ? void 0 : meta.intent) === "quantity") {
128
- var _item$option, _item$bundle, _item$price, _item$product_id, _ref5, _meta$quantity, _orderProduct$product, _orderProduct$product4;
123
+ var _item$option, _item$bundle, _item$price, _item$product_id, _ref5, _meta$quantity, _orderProduct$product;
129
124
  const quantityData = require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, item), {}, {
130
125
  quantity: item === null || item === void 0 ? void 0 : item.num,
131
126
  option: (_item$option = item === null || item === void 0 ? void 0 : item.option) !== null && _item$option !== void 0 ? _item$option : item === null || item === void 0 ? void 0 : item.product_option_item,
@@ -152,17 +147,36 @@ function Addons() {
152
147
  return;
153
148
  }
154
149
  const normalizedQuantity = Number.isNaN(nextQuantity) ? 0 : Math.max(0, Math.floor(nextQuantity));
155
- const existedCartItem = (Array.isArray(viewModel === null || viewModel === void 0 ? void 0 : viewModel.cartItems) ? viewModel.cartItems : []).find((cartItem) => {
156
- var _cartItem$product_id, _orderProduct$product2, _cartItem$product_var;
157
- return String((_cartItem$product_id = cartItem === null || cartItem === void 0 ? void 0 : cartItem.product_id) !== null && _cartItem$product_id !== void 0 ? _cartItem$product_id : null) === String((_orderProduct$product2 = orderProduct === null || orderProduct === void 0 ? void 0 : orderProduct.product_id) !== null && _orderProduct$product2 !== void 0 ? _orderProduct$product2 : null) && Number((_cartItem$product_var = cartItem === null || cartItem === void 0 ? void 0 : cartItem.product_variant_id) !== null && _cartItem$product_var !== void 0 ? _cartItem$product_var : 0) === productVariantId;
150
+ const productCartItems = addonCartItems.filter((cartItem) => {
151
+ var _cartItem$product_id, _orderProduct$product2;
152
+ return String((_cartItem$product_id = cartItem === null || cartItem === void 0 ? void 0 : cartItem.product_id) !== null && _cartItem$product_id !== void 0 ? _cartItem$product_id : null) === String((_orderProduct$product2 = orderProduct === null || orderProduct === void 0 ? void 0 : orderProduct.product_id) !== null && _orderProduct$product2 !== void 0 ? _orderProduct$product2 : null);
153
+ });
154
+ const matchedCartItems = productCartItems.filter((cartItem) => {
155
+ var _cartItem$product_var;
156
+ return Number((_cartItem$product_var = cartItem === null || cartItem === void 0 ? void 0 : cartItem.product_variant_id) !== null && _cartItem$product_var !== void 0 ? _cartItem$product_var : 0) === productVariantId;
158
157
  });
159
- const existedIdentityKey = typeof (existedCartItem === null || existedCartItem === void 0 ? void 0 : existedCartItem.identity_key) === "string" && existedCartItem.identity_key.length > 0 ? existedCartItem.identity_key : void 0;
158
+ const eventUid = require_orderProductIdentity.getVenueBookingProductUid(item);
159
+ const uidMatchedItems = eventUid ? matchedCartItems.filter((cartItem) => require_orderProductIdentity.getVenueBookingProductUid(cartItem) === eventUid) : matchedCartItems;
160
+ if (productCartItems.length > 1 || eventUid && uidMatchedItems.length !== 1) {
161
+ console.warn("[venueBooking] quantity action skipped: ambiguous or stale order line", {
162
+ mode: eventUid ? "uid" : "sku",
163
+ eventUid,
164
+ product_id: orderProduct.product_id,
165
+ product_variant_id: productVariantId,
166
+ matchedLineCount: productCartItems.length
167
+ });
168
+ return;
169
+ }
170
+ const existedCartItem = uidMatchedItems[0];
171
+ const existedIdentity = existedCartItem ? require_orderProductIdentity.getVenueBookingProductIdentity(existedCartItem) : null;
172
+ if (existedCartItem && !existedIdentity) {
173
+ console.warn("[venueBooking] quantity action skipped: missing order line UID", { item: existedCartItem });
174
+ return;
175
+ }
160
176
  if (normalizedQuantity <= 0) {
161
- var _orderProduct$product3;
177
+ if (!existedIdentity) return;
162
178
  yield removeOrderProduct({
163
- product_id: (_orderProduct$product3 = orderProduct === null || orderProduct === void 0 ? void 0 : orderProduct.product_id) !== null && _orderProduct$product3 !== void 0 ? _orderProduct$product3 : null,
164
- product_variant_id: productVariantId,
165
- identity_key: existedIdentityKey,
179
+ identity: existedIdentity,
166
180
  sourceData: quantityData
167
181
  });
168
182
  return;
@@ -174,14 +188,10 @@ function Addons() {
174
188
  });
175
189
  return;
176
190
  }
191
+ if (!existedIdentity) return;
177
192
  yield updateOrderProduct({
178
- product_id: (_orderProduct$product4 = orderProduct === null || orderProduct === void 0 ? void 0 : orderProduct.product_id) !== null && _orderProduct$product4 !== void 0 ? _orderProduct$product4 : null,
179
- product_variant_id: productVariantId,
180
- identity_key: existedIdentityKey,
181
- updates: {
182
- num: normalizedQuantity,
183
- _origin: orderProduct === null || orderProduct === void 0 ? void 0 : orderProduct._origin
184
- },
193
+ identity: existedIdentity,
194
+ num: normalizedQuantity,
185
195
  sourceData: quantityData
186
196
  });
187
197
  } else utils === null || utils === void 0 || utils.action({
@@ -239,7 +249,7 @@ function Addons() {
239
249
  customScrollParent: ((_scrollRef$current = scrollRef.current) === null || _scrollRef$current === void 0 ? void 0 : _scrollRef$current.getScrollContainer()) || "",
240
250
  hideCategoryWhenOne: true,
241
251
  version: "v2",
242
- value: (viewModel === null || viewModel === void 0 ? void 0 : viewModel.cartItems) || [],
252
+ value: addonCartItems,
243
253
  productListSetting: {
244
254
  imgWidth: 80,
245
255
  imgHeight: 80
@@ -4,6 +4,7 @@ const require_objectSpread2 = require("../../../../_virtual/_@oxc-project_runtim
4
4
  const require_asyncToGenerator = require("../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js");
5
5
  const require_index = require("../../../shoppingCart/index.js");
6
6
  const require_index$1 = require("../../../subTotal/index.js");
7
+ const require_orderProductIdentity = require("../../utils/orderProductIdentity.js");
7
8
  const require_context = require("../../context.js");
8
9
  const require_index$2 = require("../Voucher/index.js");
9
10
  const require_index$3 = require("../Deposit/index.js");
@@ -22,7 +23,7 @@ require("./index.less");
22
23
  function Cart(props) {
23
24
  var _engineContext$appHel, _engineContext$appHel2, _engineContext$appHel3, _engineContext$engine, _businessUtils$getApp, _businessUtils$getApp2, _ref, _ref2, _ref3, _summary$total_amount, _summary$deposit3;
24
25
  const { open, onCancel, onNext, items, summary, embedded = false, confirmLoading = false, extraContent } = props;
25
- const { currentStep, runModuleAction, refreshViewModel, venueBookingModule, isAgreeDepositPolicy, setIsAgreeDepositPolicy } = require_context.useVenueBookingContext();
26
+ const { currentStep, runModuleAction, refreshViewModel, refreshTimeSlotGrid, venueBookingModule, isAgreeDepositPolicy, setIsAgreeDepositPolicy } = require_context.useVenueBookingContext();
26
27
  const engineContext = require_useEngineContext.default();
27
28
  const businessUtils = engineContext === null || engineContext === void 0 || (_engineContext$appHel = engineContext.appHelper) === null || _engineContext$appHel === void 0 || (_engineContext$appHel = _engineContext$appHel.utils) === null || _engineContext$appHel === void 0 ? void 0 : _engineContext$appHel.businessUtils;
28
29
  const symbol = String((engineContext === null || engineContext === void 0 || (_engineContext$appHel2 = engineContext.appHelper) === null || _engineContext$appHel2 === void 0 || (_engineContext$appHel2 = _engineContext$appHel2.utils) === null || _engineContext$appHel2 === void 0 || (_engineContext$appHel3 = _engineContext$appHel2.getSymbolic) === null || _engineContext$appHel3 === void 0 ? void 0 : _engineContext$appHel3.call(_engineContext$appHel2)) || "$");
@@ -106,14 +107,14 @@ function Cart(props) {
106
107
  * 调用 OS 模块 removeProductFromOrder 后刷新 viewModel
107
108
  */
108
109
  const isVenueBookingCartItem = (target) => {
110
+ var _target$metadata;
109
111
  if (!target || typeof target !== "object") return false;
112
+ if ((_target$metadata = target.metadata) === null || _target$metadata === void 0 ? void 0 : _target$metadata.venue_booking) return true;
110
113
  if ((target === null || target === void 0 ? void 0 : target.start_date) && (target === null || target === void 0 ? void 0 : target.end_date)) return true;
111
- if (String((target === null || target === void 0 ? void 0 : target.identity_key) || "").startsWith("venue:")) return true;
112
114
  return false;
113
115
  };
114
116
  const handleCartChange = function() {
115
- var _ref6 = require_asyncToGenerator._asyncToGenerator(function* (item, type, sourceItem) {
116
- var _ref5, _targetItem$product_i, _targetItem$product_v;
117
+ var _ref5 = require_asyncToGenerator._asyncToGenerator(function* (item, type, sourceItem) {
117
118
  if (type !== "delete") return;
118
119
  const targetItem = sourceItem && typeof sourceItem === "object" ? sourceItem : item;
119
120
  if (currentStep !== "select-venue" && isVenueBookingCartItem(targetItem)) {
@@ -123,20 +124,14 @@ function Cart(props) {
123
124
  });
124
125
  return;
125
126
  }
126
- const productId = (_ref5 = (_targetItem$product_i = targetItem === null || targetItem === void 0 ? void 0 : targetItem.product_id) !== null && _targetItem$product_i !== void 0 ? _targetItem$product_i : targetItem === null || targetItem === void 0 ? void 0 : targetItem.id) !== null && _ref5 !== void 0 ? _ref5 : null;
127
- const productVariantId = Number((_targetItem$product_v = targetItem === null || targetItem === void 0 ? void 0 : targetItem.product_variant_id) !== null && _targetItem$product_v !== void 0 ? _targetItem$product_v : 0);
128
- const identityKey = targetItem === null || targetItem === void 0 ? void 0 : targetItem.identity_key;
129
- if (productId === null && Number.isNaN(productVariantId)) return;
130
- if (typeof identityKey !== "string" || identityKey.length === 0) {
131
- console.error("[venueBooking] removeProductFromOrder skipped: missing identity_key", { item: targetItem });
127
+ const identity = require_orderProductIdentity.getVenueBookingProductIdentity(targetItem);
128
+ if (!identity) {
129
+ console.error("[venueBooking] removeProductFromOrder skipped: missing product UID", { item: targetItem });
132
130
  return;
133
131
  }
134
132
  try {
135
- yield runModuleAction("removeProductFromOrder", {
136
- product_id: productId,
137
- product_variant_id: Number.isNaN(productVariantId) ? 0 : productVariantId,
138
- identity_key: identityKey
139
- });
133
+ yield runModuleAction("removeProductFromOrder", identity);
134
+ refreshTimeSlotGrid();
140
135
  yield refreshViewModel();
141
136
  } catch (error) {
142
137
  console.error("[venueBooking] removeProductFromOrder failed", {
@@ -146,7 +141,7 @@ function Cart(props) {
146
141
  }
147
142
  });
148
143
  return function handleCartChange(_x, _x2, _x3) {
149
- return _ref6.apply(this, arguments);
144
+ return _ref5.apply(this, arguments);
150
145
  };
151
146
  }();
152
147
  (0, react.useEffect)(() => {
@@ -1,8 +1,10 @@
1
1
  require("../../_virtual/_rolldown/runtime.js");
2
2
  const require_useEngineContext = require("../../hooks/useEngineContext.js");
3
+ const require_objectSpread2 = require("../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
3
4
  const require_asyncToGenerator = require("../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js");
4
5
  const require_useSalesUserLogin = require("../../hooks/useSalesUserLogin.js");
5
6
  const require_toShoppingCartProducts = require("../scanOrder/utils/toShoppingCartProducts.js");
7
+ const require_orderProductIdentity = require("./utils/orderProductIdentity.js");
6
8
  let react = require("react");
7
9
  //#region src/components/venueBooking/hooks.ts
8
10
  /**
@@ -200,12 +202,22 @@ function createVenueBookingViewModel(_x10) {
200
202
  function _createVenueBookingViewModel() {
201
203
  _createVenueBookingViewModel = require_asyncToGenerator._asyncToGenerator(function* (module) {
202
204
  const summaryByGetter = typeof (module === null || module === void 0 ? void 0 : module.getSummary) === "function" ? yield module.getSummary() : null;
203
- const orderProducts = callModuleGetter(module, "getOrderProducts", []);
205
+ const rawOrderProducts = callModuleGetter(module, "getOrderProducts", []);
206
+ const orderProducts = Array.isArray(rawOrderProducts) ? rawOrderProducts : [];
204
207
  const tempOrder = callModuleGetter(module, "getTempOrder", null);
205
- const amountSymbol = (tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.currency_symbol) || "$";
206
208
  const cartItems = require_toShoppingCartProducts.toShoppingCartProducts({
207
- orderProducts: Array.isArray(orderProducts) ? orderProducts : [],
208
- amountSymbol
209
+ orderProducts,
210
+ amountSymbol: (tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.currency_symbol) || "$"
211
+ }).map((item, index) => {
212
+ const product = orderProducts[index];
213
+ const uid = require_orderProductIdentity.getVenueBookingProductUid(product);
214
+ return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, item), {}, {
215
+ metadata: product.metadata,
216
+ product_sku: product.product_sku,
217
+ unique_identification_number: uid,
218
+ _id: uid !== null && uid !== void 0 ? uid : item._id,
219
+ rowKey: uid !== null && uid !== void 0 ? uid : item.rowKey
220
+ });
209
221
  });
210
222
  const summary = (summaryByGetter && typeof summaryByGetter === "object" ? summaryByGetter : null) || (tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.summary) || {};
211
223
  return {
@@ -0,0 +1,16 @@
1
+ const require_identity = require("../../../plus/salesSdk/utils/identity.js");
2
+ //#region src/components/venueBooking/utils/orderProductIdentity.ts
3
+ /** VenueBooking 删改必须定位具体订单行,不能退回只按商品/SKU 匹配。 */
4
+ function getVenueBookingProductIdentity(line) {
5
+ if (!line || typeof line !== "object") return null;
6
+ const identity = require_identity.pickIdentity(line);
7
+ if (typeof identity.unique_identification_number !== "string" || identity.unique_identification_number.length === 0) return null;
8
+ return identity;
9
+ }
10
+ function getVenueBookingProductUid(line) {
11
+ var _getVenueBookingProdu;
12
+ return (_getVenueBookingProdu = getVenueBookingProductIdentity(line)) === null || _getVenueBookingProdu === void 0 ? void 0 : _getVenueBookingProdu.unique_identification_number;
13
+ }
14
+ //#endregion
15
+ exports.getVenueBookingProductIdentity = getVenueBookingProductIdentity;
16
+ exports.getVenueBookingProductUid = getVenueBookingProductUid;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pisell/private-materials",
3
- "version": "6.12.267",
3
+ "version": "6.12.268",
4
4
  "main": "./lib/index.js",
5
5
  "module": "./es/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -72,10 +72,10 @@
72
72
  "styled-components": "^6.0.0-rc.3",
73
73
  "use-sync-external-store": "^1.6.0",
74
74
  "@pisell/pi-payment-sdk": "0.0.3",
75
- "@pisell/materials": "6.12.74",
76
- "@pisell/date-picker": "3.0.12",
77
75
  "@pisell/icon": "0.0.11",
78
- "@pisell/utils": "3.0.7"
76
+ "@pisell/utils": "3.0.7",
77
+ "@pisell/materials": "6.12.74",
78
+ "@pisell/date-picker": "3.0.12"
79
79
  },
80
80
  "peerDependencies": {
81
81
  "react": "^18.0.0",