@pisell/private-materials 6.12.160 → 6.12.161

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 (72) hide show
  1. package/build/lowcode/assets-daily.json +11 -11
  2. package/build/lowcode/assets-dev.json +2 -2
  3. package/build/lowcode/assets-prod.json +11 -11
  4. package/build/lowcode/meta.js +1 -1
  5. package/build/lowcode/preview.js +1 -1
  6. package/build/lowcode/render/default/view.js +18 -18
  7. package/build/lowcode/view.js +18 -18
  8. package/es/components/bigSale/components/BookingFloatingPanel/useBookingPanelController.js +1 -0
  9. package/es/components/bigSale/components/TimeBar/index.js +1 -0
  10. package/es/components/bigSale/dialog.js +1 -0
  11. package/es/components/bigSale/hooks/useBigSaleContext.js +1 -0
  12. package/es/components/bigSale/hooks/useSelectFloorMapResourceForBigSale.js +1 -0
  13. package/es/components/bigSale/index.js +3 -2
  14. package/es/components/bigSale/templates/Kiosk/index.js +1 -0
  15. package/es/components/sharedSecondaryBigSale/SharedSecondaryBigSaleReceiver.js +1 -0
  16. package/es/index.js +2 -0
  17. package/es/plus/pisellReservation/data/bookingToReservationTables.js +1 -1
  18. package/es/plus/pisellReservation/floorMap/floorPlanApi.js +1 -1
  19. package/es/plus/pisellReservation/floorMap/reservationMock.js +1 -1
  20. package/es/plus/pisellReservation/index.js +17 -0
  21. package/es/plus/saleDetail/Base.js +1 -0
  22. package/es/plus/saleDetail/components/CartItems/Editable/index.js +1 -0
  23. package/es/plus/saleDetail/components/Client/hooks/useClientSelectorProps.js +1 -0
  24. package/es/plus/saleDetail/components/DetailActions/index.js +1 -0
  25. package/es/plus/saleDetail/components/SummaryFinancialSections/index.js +1 -0
  26. package/es/plus/saleDetail/index.js +1 -0
  27. package/es/plus/saleDetail/tmpl/B/components/Dish/index.js +1 -0
  28. package/es/plus/saleDetail/tmpl/B/index.js +1 -0
  29. package/es/plus/salesSdk/context/SalesSdkCartContext.js +25 -12
  30. package/es/plus/salesSdk/context/SalesSdkProvider.js +9 -5
  31. package/es/plus/salesSdk/hosts/BookingEditHostRenderer.js +12 -7
  32. package/es/plus/salesSdk/index.js +51 -0
  33. package/es/plus/salesSdk/utils/addProductWithFlowDebounced.js +1 -1
  34. package/es/plus/salesSdk/utils/bookingDate.js +1 -1
  35. package/es/plus/salesSdk/utils/customerAuthGate.js +1 -1
  36. package/es/plus/salesSdk/utils/enrichCartLineHolderDisplay.js +1 -1
  37. package/es/plus/salesSdk/utils/resolvePreviousService.js +28 -0
  38. package/es/plus/skuOptionsSelection/components/NormalCard/index.js +18 -12
  39. package/es/plus/skuOptionsSelection/docs/skuOptionsSelection.$tab-dev.md +66 -2
  40. package/es/plus/skuOptionsSelection/types.d.ts +50 -1
  41. package/es/plus/skuOptionsSelection/utils/normalizers.js +17 -0
  42. package/es/plus/skuOptionsSelection/utils/transformOptionGroup.js +17 -7
  43. package/es/plus/skuOptionsSelection/utils/transformSelectorValueToValue.js +89 -15
  44. package/es/plus/skuOptionsSelection/utils/transformValueToSelectorValue.js +31 -19
  45. package/es/pro/Login2.0/AuthModal.d.ts +1 -1
  46. package/es/pro/Login2.0/index.d.ts +2 -1
  47. package/es/pro/Login2.0/shared/types.d.ts +1 -1
  48. package/es/pro/Selector/Selector.js +11 -6
  49. package/es/pro/Selector/hooks/useSelectionController.js +54 -61
  50. package/es/pro/Selector/locales.js +10 -0
  51. package/es/pro/Selector/types.d.ts +5 -0
  52. package/es/pro/skuDetailModal/types.d.ts +1 -0
  53. package/lib/components/bigSale/index.js +2 -2
  54. package/lib/plus/saleDetail/components/CartItems/Editable/index.js +1 -0
  55. package/lib/plus/salesSdk/context/SalesSdkCartContext.js +25 -12
  56. package/lib/plus/salesSdk/context/SalesSdkProvider.js +9 -5
  57. package/lib/plus/salesSdk/hosts/BookingEditHostRenderer.js +12 -7
  58. package/lib/plus/salesSdk/utils/resolvePreviousService.js +30 -0
  59. package/lib/plus/skuOptionsSelection/components/NormalCard/index.js +18 -12
  60. package/lib/plus/skuOptionsSelection/docs/skuOptionsSelection.$tab-dev.md +66 -2
  61. package/lib/plus/skuOptionsSelection/types.d.ts +50 -1
  62. package/lib/plus/skuOptionsSelection/utils/normalizers.js +19 -0
  63. package/lib/plus/skuOptionsSelection/utils/transformOptionGroup.js +17 -7
  64. package/lib/plus/skuOptionsSelection/utils/transformSelectorValueToValue.js +89 -15
  65. package/lib/plus/skuOptionsSelection/utils/transformValueToSelectorValue.js +31 -19
  66. package/lib/pro/Selector/Selector.js +11 -6
  67. package/lib/pro/Selector/hooks/useSelectionController.js +54 -61
  68. package/lib/pro/Selector/locales.js +10 -0
  69. package/lib/pro/Selector/types.d.ts +5 -0
  70. package/lib/pro/skuDetailModal/types.d.ts +1 -0
  71. package/package.json +4 -4
  72. package/es/private-materials/lowcode/authmodal/meta.d.ts +0 -1
@@ -6,7 +6,7 @@ import React, { useMemo } from "react";
6
6
  import Decimal from "decimal.js";
7
7
  //#region src/plus/skuOptionsSelection/components/NormalCard/index.tsx
8
8
  const NormalCard = (props) => {
9
- var _props$dataSource;
9
+ var _props$dataSource2;
10
10
  const { _key: uniqueKey, ruleConfig, _original, disabled, selected } = (props === null || props === void 0 ? void 0 : props.dataSource) || {};
11
11
  const { cover, title, name, product_subtitle, price, price_type, add_price } = _original || {};
12
12
  const symbol = useStore_default((s) => s.symbol);
@@ -22,20 +22,25 @@ const NormalCard = (props) => {
22
22
  };
23
23
  const renderNumberSelector = () => {
24
24
  if (!(props === null || props === void 0 ? void 0 : props.numberSelector) || typeof (props === null || props === void 0 ? void 0 : props.numberSelector) !== "object") return null;
25
- return React.cloneElement(props === null || props === void 0 ? void 0 : props.numberSelector, { onChange: (v) => {
26
- var _props$actions;
25
+ return React.cloneElement(props === null || props === void 0 ? void 0 : props.numberSelector, { onChange: (v, meta) => {
26
+ var _props$dataSource, _props$actions;
27
+ const itemMin = Math.max(1, Number((ruleConfig === null || ruleConfig === void 0 ? void 0 : ruleConfig.min) || 0));
28
+ const currentQuantity = Number((props === null || props === void 0 || (_props$dataSource = props.dataSource) === null || _props$dataSource === void 0 ? void 0 : _props$dataSource.quantity) || 0);
29
+ let nextQuantity = v;
30
+ if ((meta === null || meta === void 0 ? void 0 : meta.action) === "increase" && currentQuantity <= 0) nextQuantity = itemMin;
31
+ else if ((meta === null || meta === void 0 ? void 0 : meta.action) === "decrease" && itemMin > 1 && currentQuantity === itemMin && v < itemMin) nextQuantity = 0;
27
32
  const _price = add_price !== void 0 && add_price !== null ? add_price : price;
28
33
  const priceType = price_type === "markdown" ? -1 : 1;
29
- const totalPrice = new Decimal(_price).times(new Decimal(v)).times(priceType).toNumber();
34
+ const totalPrice = new Decimal(_price).times(new Decimal(nextQuantity)).times(priceType).toNumber();
30
35
  const newOriginal = _objectSpread2(_objectSpread2({}, _original), {}, {
31
- quantity: v,
32
- num: v,
36
+ quantity: nextQuantity,
37
+ num: nextQuantity,
33
38
  price: _price,
34
39
  original_price: _price,
35
40
  original_total: _price
36
41
  });
37
42
  props === null || props === void 0 || (_props$actions = props.actions) === null || _props$actions === void 0 || _props$actions.update(uniqueKey, {
38
- quantity: v,
43
+ quantity: nextQuantity,
39
44
  data: newOriginal,
40
45
  totalPrice
41
46
  });
@@ -62,17 +67,18 @@ const NormalCard = (props) => {
62
67
  var _props$actions3;
63
68
  const _price = add_price !== void 0 && add_price !== null ? add_price : price;
64
69
  const priceType = price_type === "markdown" ? -1 : 1;
70
+ const initialQuantity = Math.max(1, Number((ruleConfig === null || ruleConfig === void 0 ? void 0 : ruleConfig.min) || 0));
65
71
  const newOriginal = _objectSpread2(_objectSpread2({}, _original), {}, {
66
- quantity: 1,
67
- num: 1,
72
+ quantity: initialQuantity,
73
+ num: initialQuantity,
68
74
  price: _price,
69
75
  original_price: _price,
70
76
  original_total: _price
71
77
  });
72
78
  props === null || props === void 0 || (_props$actions3 = props.actions) === null || _props$actions3 === void 0 || _props$actions3.update(uniqueKey, {
73
- quantity: 1,
79
+ quantity: initialQuantity,
74
80
  data: newOriginal,
75
- totalPrice: new Decimal(_price).times(priceType).toNumber()
81
+ totalPrice: new Decimal(_price).times(initialQuantity).times(priceType).toNumber()
76
82
  });
77
83
  }
78
84
  };
@@ -99,7 +105,7 @@ const NormalCard = (props) => {
99
105
  } }))),
100
106
  onClick: handleChange,
101
107
  skuCardConfig,
102
- skuDisabled: (props === null || props === void 0 || (_props$dataSource = props.dataSource) === null || _props$dataSource === void 0 || (_props$dataSource = _props$dataSource._extra) === null || _props$dataSource === void 0 ? void 0 : _props$dataSource.disabled) === true
108
+ skuDisabled: (props === null || props === void 0 || (_props$dataSource2 = props.dataSource) === null || _props$dataSource2 === void 0 || (_props$dataSource2 = _props$dataSource2._extra) === null || _props$dataSource2 === void 0 ? void 0 : _props$dataSource2.disabled) === true
103
109
  });
104
110
  };
105
111
  //#endregion
@@ -15,7 +15,7 @@ category: plus
15
15
  ## 2. 版本
16
16
 
17
17
  **当前版本**: `1.0.0`
18
- **最后更新**: 2025-11-19
18
+ **最后更新**: 2026-08-12
19
19
 
20
20
  ## 3. 相关文档
21
21
 
@@ -51,6 +51,10 @@ SKUOptionsSelection
51
51
 
52
52
  ```typescript
53
53
  export interface DataSource {
54
+ /** 商品id */
55
+ id?: number;
56
+ /** 生产编码 */
57
+ production_code?: string;
54
58
  /** 单规格组数据 */
55
59
  option_group?: Array<OptionGroupItem>;
56
60
  /** 组合规格组装后的数据 */
@@ -58,7 +62,17 @@ export interface DataSource {
58
62
  /** 组合规格组数据 */
59
63
  variant_group?: Array<VariantGroupItem>;
60
64
  /** 套餐商品组数据 */
61
- bundle_group?: Array<BundleItem>;
65
+ bundle_group?: Array<BundleGroupItem>;
66
+ }
67
+
68
+ export interface OptionGroupMetadata {
69
+ advanced_settings_enabled?: 0 | 1;
70
+ option_types_config?: {
71
+ min?: number;
72
+ max?: number;
73
+ [key: string]: unknown;
74
+ };
75
+ [key: string]: unknown;
62
76
  }
63
77
 
64
78
  /**
@@ -88,6 +102,8 @@ export interface OptionGroupItem {
88
102
  max_quantity?: number;
89
103
  /** 最小选择数量 */
90
104
  min_quantity?: number;
105
+ /** 高级设置元数据 */
106
+ metadata?: OptionGroupMetadata;
91
107
  /** 单规格组名称 */
92
108
  name?: string;
93
109
  /** 单规格组下规格数据 */
@@ -133,6 +149,8 @@ export interface OptionItem {
133
149
  is_enabled?: 0 | 1;
134
150
  /** 最大选择数量 */
135
151
  max_quantity?: number;
152
+ /** 最小选择数量 */
153
+ min_quantity?: number;
136
154
  /** 规格名称 */
137
155
  name?: string;
138
156
  /** 规格组id */
@@ -141,6 +159,8 @@ export interface OptionItem {
141
159
  original_price?: string;
142
160
  /** 商品id */
143
161
  product_id?: number;
162
+ /** 生产编码 */
163
+ production_code?: string;
144
164
  /** 店铺id */
145
165
  shop_id?: number;
146
166
  /** 排序 */
@@ -268,6 +288,8 @@ export interface VariantProductItem {
268
288
  price?: string;
269
289
  /** 商品id */
270
290
  product_id?: number;
291
+ /** 生产编码 */
292
+ production_code?: string;
271
293
  /** 折扣类型 */
272
294
  rebate_type?: string;
273
295
  /** 折扣值 */
@@ -350,6 +372,8 @@ export interface BundleItem {
350
372
  price_type_ext?: '' | 'product_price';
351
373
  /** 商品id */
352
374
  product_id?: number;
375
+ /** 生产编码 */
376
+ production_code?: string;
353
377
  /** 商品价格 */
354
378
  product_price?: string;
355
379
  /** 商品副标题 */
@@ -370,6 +394,8 @@ export interface SkuValue {
370
394
  product_variant_id: number;
371
395
  /** 多规格商品选项字符串 */
372
396
  product_option_string?: string;
397
+ /** 当前商品或组合规格商品的生产编码 */
398
+ production_code?: string;
373
399
  /** 套餐商品组数据 */
374
400
  bundle: Array<any>;
375
401
  /** 单规格组数据 */
@@ -666,6 +692,44 @@ const App = () => {
666
692
  />
667
693
  ```
668
694
 
695
+ ### 6.7 Option 高级限制与 Production Code
696
+
697
+ 多选 Option Group 在 `metadata.advanced_settings_enabled=1` 时支持种类数限制:
698
+
699
+ ```typescript
700
+ {
701
+ is_multiple: 1,
702
+ min_quantity: 1, // 总份数下限
703
+ max_quantity: 4, // 总份数上限,0 表示不限
704
+ metadata: {
705
+ advanced_settings_enabled: 1,
706
+ option_types_config: {
707
+ min: 1, // 最少种类数,0 表示不限
708
+ max: 2, // 最多种类数,0 表示不限
709
+ },
710
+ },
711
+ option_item: [
712
+ {
713
+ id: 1,
714
+ min_quantity: 2, // 选择该项后的最少份数
715
+ max_quantity: 0, // 单项份数不限
716
+ production_code: 'OPTION-1',
717
+ },
718
+ ],
719
+ }
720
+ ```
721
+
722
+ 达到最多种类数后,组件只禁用尚未选择的 Option Item;已选项仍可在总份数和单项规则允许的范围内调整。Item `min_quantity` 仅对已选项生效,首次选择会从该最小数量开始。
723
+
724
+ `getTransformValues()` 和 `onChange` 输出会明确携带以下编码:
725
+
726
+ - `production_code`:Product 或当前 Variant 编码。
727
+ - `option[*].production_code`:Option Item 编码。
728
+ - `bundle[*].production_code`:Bundle Item 编码。
729
+ - `bundle[*].option[*].production_code`:套餐嵌套 Option Item 编码。
730
+
731
+ 显式空字符串表示“无编码”,不会回退到 Product 或其他节点编码。
732
+
669
733
  ## 7. 注意事项
670
734
 
671
735
  1. **数据格式**:确保传入的 `dataSource` 和 `value` 格式正确,否则可能导致组件渲染异常
@@ -90,6 +90,10 @@ interface IProps {
90
90
  };
91
91
  }
92
92
  interface DataSource {
93
+ /** 商品id */
94
+ id?: number;
95
+ /** 生产编码 */
96
+ production_code?: string;
93
97
  /** 单规格组数据 */
94
98
  option_group?: Array<OptionGroupItem>;
95
99
  /** 组合规格组装后的数据 */
@@ -97,7 +101,19 @@ interface DataSource {
97
101
  /** 组合规格组数据 */
98
102
  variant_group?: Array<VariantGroupItem>;
99
103
  /** 套餐商品组数据 */
100
- bundle_group?: Array<BundleItem>;
104
+ bundle_group?: Array<BundleGroupItem>;
105
+ }
106
+ interface OptionGroupMetadata {
107
+ /** 是否启用高级设置 */
108
+ advanced_settings_enabled?: 0 | 1;
109
+ /** Option 种类数限制 */
110
+ option_types_config?: {
111
+ min?: number;
112
+ max?: number;
113
+ [key: string]: unknown;
114
+ };
115
+ /** 保留后端返回的其他元数据 */
116
+ [key: string]: unknown;
101
117
  }
102
118
  /**
103
119
  * 单规格组数据
@@ -125,6 +141,8 @@ interface OptionGroupItem {
125
141
  max_quantity?: number;
126
142
  /** 最小选择数量 */
127
143
  min_quantity?: number;
144
+ /** 高级设置元数据 */
145
+ metadata?: OptionGroupMetadata;
128
146
  /** 单规格组名称 */
129
147
  name?: string;
130
148
  /** 单规格组下规格数据 */
@@ -168,6 +186,8 @@ interface OptionItem {
168
186
  is_enabled?: 0 | 1;
169
187
  /** 最大选择数量 */
170
188
  max_quantity?: number;
189
+ /** 最小选择数量 */
190
+ min_quantity?: number;
171
191
  /** 规格名称 */
172
192
  name?: string;
173
193
  /** 规格组id */
@@ -176,6 +196,8 @@ interface OptionItem {
176
196
  original_price?: string;
177
197
  /** 商品id */
178
198
  product_id?: number;
199
+ /** 生产编码 */
200
+ production_code?: string;
179
201
  /** 店铺id */
180
202
  shop_id?: number;
181
203
  /** 排序 */
@@ -297,6 +319,8 @@ interface VariantProductItem {
297
319
  price?: string;
298
320
  /** 商品id */
299
321
  product_id?: number;
322
+ /** 生产编码 */
323
+ production_code?: string;
300
324
  /** 折扣类型 */
301
325
  rebate_type?: string;
302
326
  /** 折扣值 */
@@ -312,6 +336,27 @@ interface VariantProductItem {
312
336
  /** 重量值 */
313
337
  weight_value?: string;
314
338
  }
339
+ /**
340
+ * 套餐商品组数据
341
+ */
342
+ interface BundleGroupItem {
343
+ /** 店铺id */
344
+ shop_id?: number;
345
+ /** 排序 */
346
+ sort?: number;
347
+ /** 套餐id */
348
+ id?: number;
349
+ /** 最大选择数量 */
350
+ max_quantity?: number;
351
+ /** 最小选择数量 */
352
+ min_quantity?: number;
353
+ /** 套餐名称 */
354
+ name?: string;
355
+ /** 商品id */
356
+ product_id?: number;
357
+ /** 套餐商品组数据 */
358
+ bundle_item?: Array<BundleItem>;
359
+ }
315
360
  /**
316
361
  * 套餐商品组下选项数据
317
362
  */
@@ -354,6 +399,8 @@ interface BundleItem {
354
399
  price_type_ext?: '' | 'product_price';
355
400
  /** 商品id */
356
401
  product_id?: number;
402
+ /** 生产编码 */
403
+ production_code?: string;
357
404
  /** 商品价格 */
358
405
  product_price?: string;
359
406
  /** 商品副标题 */
@@ -373,6 +420,8 @@ interface SkuValue {
373
420
  product_variant_id: number;
374
421
  /** 多规格商品选项字符串 */
375
422
  product_option_string?: string;
423
+ /** 当前商品或组合规格商品的生产编码 */
424
+ production_code?: string;
376
425
  /** 套餐商品组数据 */
377
426
  bundle: Array<any>;
378
427
  /** 价格 */
@@ -0,0 +1,17 @@
1
+ //#region src/plus/skuOptionsSelection/utils/normalizers.ts
2
+ const normalizeNonNegativeInteger = (value, fallback = 0) => {
3
+ const normalizedFallback = Math.max(0, Math.trunc(Number(fallback) || 0));
4
+ if (value === null || value === void 0 || typeof value === "string" && value.trim() === "") return normalizedFallback;
5
+ const normalizedValue = Number(value);
6
+ if (!Number.isFinite(normalizedValue)) return normalizedFallback;
7
+ return Math.max(0, Math.trunc(normalizedValue));
8
+ };
9
+ const hasOwnProductionCode = (value) => !!value && typeof value === "object" && Object.prototype.hasOwnProperty.call(value, "production_code");
10
+ const normalizeProductionCode = (value) => value === null || value === void 0 ? "" : String(value).trim();
11
+ const resolveProductionCode = (snapshotValue, currentValue) => {
12
+ if (hasOwnProductionCode(snapshotValue)) return normalizeProductionCode(snapshotValue.production_code);
13
+ if (hasOwnProductionCode(currentValue)) return normalizeProductionCode(currentValue.production_code);
14
+ return "";
15
+ };
16
+ //#endregion
17
+ export { hasOwnProductionCode, normalizeNonNegativeInteger, resolveProductionCode };
@@ -3,6 +3,7 @@ import store from "../store/store.js";
3
3
  import NormalCard from "../components/NormalCard/index.js";
4
4
  import TitleExtra from "../components/TitleExtra/index.js";
5
5
  import { checkSkuDisabled, checkSkuStockCanSell } from "./checkSkuStatus.js";
6
+ import { normalizeNonNegativeInteger } from "./normalizers.js";
6
7
  import React from "react";
7
8
  //#region src/plus/skuOptionsSelection/utils/transformOptionGroup.tsx
8
9
  const transformOptionGroup = (optionGroup, translationOriginal) => {
@@ -11,11 +12,19 @@ const transformOptionGroup = (optionGroup, translationOriginal) => {
11
12
  const getDisplayText = (value) => typeof value === "string" ? value : (translationOriginal === null || translationOriginal === void 0 ? void 0 : translationOriginal(value)) || "";
12
13
  const selectorLayout = ((_store$getState$custo = store.getState().customConfig) === null || _store$getState$custo === void 0 ? void 0 : _store$getState$custo.selectorLayout) || null;
13
14
  return optionGroup.map((item) => {
14
- var _item$option_item, _item$name;
15
+ var _item$metadata, _item$metadata2, _item$metadata3, _item$option_item, _item$name;
16
+ const isMultiple = (item === null || item === void 0 ? void 0 : item.is_multiple) == 1;
17
+ const groupMin = normalizeNonNegativeInteger(item === null || item === void 0 ? void 0 : item.min_quantity, 0);
18
+ const groupMax = normalizeNonNegativeInteger(item === null || item === void 0 ? void 0 : item.max_quantity, 0);
19
+ const advancedEnabled = isMultiple && (item === null || item === void 0 || (_item$metadata = item.metadata) === null || _item$metadata === void 0 ? void 0 : _item$metadata.advanced_settings_enabled) === 1;
20
+ const minTypes = advancedEnabled ? normalizeNonNegativeInteger(item === null || item === void 0 || (_item$metadata2 = item.metadata) === null || _item$metadata2 === void 0 || (_item$metadata2 = _item$metadata2.option_types_config) === null || _item$metadata2 === void 0 ? void 0 : _item$metadata2.min, 0) : 0;
21
+ const maxTypes = advancedEnabled ? normalizeNonNegativeInteger(item === null || item === void 0 || (_item$metadata3 = item.metadata) === null || _item$metadata3 === void 0 || (_item$metadata3 = _item$metadata3.option_types_config) === null || _item$metadata3 === void 0 ? void 0 : _item$metadata3.max, 0) : 0;
15
22
  const selectorOptionsDataSource = item === null || item === void 0 || (_item$option_item = item.option_item) === null || _item$option_item === void 0 ? void 0 : _item$option_item.map((optionItem) => {
16
23
  var _optionItem$name;
17
24
  const { canSell, hasStock } = checkSkuStockCanSell(optionItem);
18
25
  const disabled = checkSkuDisabled(optionItem, canSell);
26
+ const itemMin = normalizeNonNegativeInteger(optionItem === null || optionItem === void 0 ? void 0 : optionItem.min_quantity, 0);
27
+ const itemMax = normalizeNonNegativeInteger(optionItem === null || optionItem === void 0 ? void 0 : optionItem.max_quantity, 1);
19
28
  return {
20
29
  _original: _objectSpread2(_objectSpread2({}, optionItem || {}), {}, { product_option_item_id: optionItem === null || optionItem === void 0 ? void 0 : optionItem.id }),
21
30
  id: optionItem === null || optionItem === void 0 ? void 0 : optionItem.id,
@@ -23,8 +32,8 @@ const transformOptionGroup = (optionGroup, translationOriginal) => {
23
32
  value: optionItem === null || optionItem === void 0 ? void 0 : optionItem.id,
24
33
  disabled,
25
34
  ruleConfig: {
26
- min: optionItem === null || optionItem === void 0 ? void 0 : optionItem.min_quantity,
27
- max: optionItem === null || optionItem === void 0 ? void 0 : optionItem.max_quantity,
35
+ min: itemMin,
36
+ max: itemMax,
28
37
  autoValidate: true
29
38
  },
30
39
  _extra: {
@@ -34,7 +43,6 @@ const transformOptionGroup = (optionGroup, translationOriginal) => {
34
43
  }
35
44
  };
36
45
  });
37
- const isMultiple = (item === null || item === void 0 ? void 0 : item.is_multiple) == 1;
38
46
  const selectorDataSource = {
39
47
  id: item.id,
40
48
  title: getDisplayText((_item$name = item === null || item === void 0 ? void 0 : item.name) !== null && _item$name !== void 0 ? _item$name : item === null || item === void 0 ? void 0 : item.title),
@@ -47,10 +55,12 @@ const transformOptionGroup = (optionGroup, translationOriginal) => {
47
55
  dataSource: selectorOptionsDataSource || [],
48
56
  disabled: (item === null || item === void 0 ? void 0 : item.is_enabled) === 0,
49
57
  ruleConfig: {
50
- min: isMultiple ? item === null || item === void 0 ? void 0 : item.min_quantity : void 0,
51
- max: isMultiple ? Number(item === null || item === void 0 ? void 0 : item.max_quantity) == 0 ? void 0 : item === null || item === void 0 ? void 0 : item.max_quantity : void 0,
58
+ min: isMultiple ? groupMin : void 0,
59
+ max: isMultiple && groupMax > 0 ? groupMax : void 0,
60
+ minTypes: isMultiple && minTypes > 0 ? minTypes : void 0,
61
+ maxTypes: isMultiple && maxTypes > 0 ? maxTypes : void 0,
52
62
  autoValidate: true,
53
- required: isMultiple ? Number((item === null || item === void 0 ? void 0 : item.min_quantity) || 0) > 0 : (item === null || item === void 0 ? void 0 : item.required) === 1
63
+ required: isMultiple ? groupMin > 0 || minTypes > 0 : (item === null || item === void 0 ? void 0 : item.required) === 1
54
64
  },
55
65
  headerProps: { renderExtra: (props) => {
56
66
  return /* @__PURE__ */ React.createElement(TitleExtra, props || {});
@@ -1,9 +1,45 @@
1
1
  import { _objectSpread2 } from "../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js";
2
2
  import { _objectWithoutProperties } from "../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectWithoutProperties.js";
3
3
  import store from "../store/store.js";
4
+ import { hasOwnProductionCode, resolveProductionCode } from "./normalizers.js";
4
5
  import Decimal from "decimal.js";
5
6
  //#region src/plus/skuOptionsSelection/utils/transformSelectorValueToValue.ts
6
7
  const _excluded = ["_data"];
8
+ const isSameNodeId = (left, right) => left !== null && left !== void 0 && right !== null && right !== void 0 && String(left) === String(right);
9
+ const getOptionItemId = (value) => {
10
+ var _value$id;
11
+ return (_value$id = value === null || value === void 0 ? void 0 : value.id) !== null && _value$id !== void 0 ? _value$id : value === null || value === void 0 ? void 0 : value.product_option_item_id;
12
+ };
13
+ const getBundleItemId = (value) => {
14
+ var _value$id2;
15
+ return (_value$id2 = value === null || value === void 0 ? void 0 : value.id) !== null && _value$id2 !== void 0 ? _value$id2 : value === null || value === void 0 ? void 0 : value.bundle_id;
16
+ };
17
+ const getBundleGroupId = (value) => {
18
+ var _value$group_id;
19
+ return (_value$group_id = value === null || value === void 0 ? void 0 : value.group_id) !== null && _value$group_id !== void 0 ? _value$group_id : value === null || value === void 0 ? void 0 : value.bundle_group_id;
20
+ };
21
+ const createOutputOption = (params) => {
22
+ var _ref, _ref2, _selectorItem$quantit, _selectorItem$value, _currentGroup$id, _currentGroup$option_, _currentOptionItem$id;
23
+ const { selectorItem, optionGroupId, currentOptionGroups = [], snapshotOptions = [] } = params;
24
+ const itemData = (selectorItem === null || selectorItem === void 0 ? void 0 : selectorItem.data) || {};
25
+ const quantity = Number((_ref = (_ref2 = (_selectorItem$quantit = selectorItem === null || selectorItem === void 0 ? void 0 : selectorItem.quantity) !== null && _selectorItem$quantit !== void 0 ? _selectorItem$quantit : itemData === null || itemData === void 0 ? void 0 : itemData.quantity) !== null && _ref2 !== void 0 ? _ref2 : itemData === null || itemData === void 0 ? void 0 : itemData.num) !== null && _ref !== void 0 ? _ref : 0);
26
+ if (!(quantity > 0)) return null;
27
+ const optionItemId = (_selectorItem$value = selectorItem === null || selectorItem === void 0 ? void 0 : selectorItem.value) !== null && _selectorItem$value !== void 0 ? _selectorItem$value : getOptionItemId(itemData);
28
+ const requestedGroupId = optionGroupId !== null && optionGroupId !== void 0 ? optionGroupId : itemData === null || itemData === void 0 ? void 0 : itemData.option_group_id;
29
+ const currentGroup = currentOptionGroups.find((group) => isSameNodeId(group === null || group === void 0 ? void 0 : group.id, requestedGroupId));
30
+ const resolvedGroupId = (_currentGroup$id = currentGroup === null || currentGroup === void 0 ? void 0 : currentGroup.id) !== null && _currentGroup$id !== void 0 ? _currentGroup$id : requestedGroupId;
31
+ const currentOptionItem = currentGroup === null || currentGroup === void 0 || (_currentGroup$option_ = currentGroup.option_item) === null || _currentGroup$option_ === void 0 ? void 0 : _currentGroup$option_.find((item) => isSameNodeId(item === null || item === void 0 ? void 0 : item.id, optionItemId));
32
+ const resolvedOptionItemId = (_currentOptionItem$id = currentOptionItem === null || currentOptionItem === void 0 ? void 0 : currentOptionItem.id) !== null && _currentOptionItem$id !== void 0 ? _currentOptionItem$id : optionItemId;
33
+ const snapshotOption = snapshotOptions.find((item) => isSameNodeId(getOptionItemId(item), optionItemId) && ((item === null || item === void 0 ? void 0 : item.option_group_id) === null || (item === null || item === void 0 ? void 0 : item.option_group_id) === void 0 || isSameNodeId(item === null || item === void 0 ? void 0 : item.option_group_id, resolvedGroupId)));
34
+ return _objectSpread2(_objectSpread2({}, itemData), {}, {
35
+ id: resolvedOptionItemId,
36
+ product_option_item_id: resolvedOptionItemId,
37
+ option_group_id: resolvedGroupId,
38
+ production_code: currentOptionItem ? resolveProductionCode(snapshotOption, currentOptionItem) : "",
39
+ quantity,
40
+ num: quantity
41
+ });
42
+ };
7
43
  /**
8
44
  * 将SelectorValue转换为Value
9
45
  */
@@ -11,6 +47,8 @@ const transformSelectorValueToValue = (selectorValue) => {
11
47
  var _dataSource$bundle_gr, _dataSource$option_gr, _dataSource$variant_g;
12
48
  if (!selectorValue) return {};
13
49
  const dataSource = store.getState().dataSource;
50
+ const originalValue = store.getState().value;
51
+ let selectedVariant = null;
14
52
  const transformValue = {
15
53
  bundle: [],
16
54
  option: [],
@@ -25,37 +63,65 @@ const transformSelectorValueToValue = (selectorValue) => {
25
63
  const groupItemValue = selectorValue === null || selectorValue === void 0 ? void 0 : selectorValue[groupId];
26
64
  if (!groupId || !groupItemValue) return;
27
65
  (Array.isArray(groupItemValue) ? groupItemValue : [groupItemValue]).forEach((item) => {
28
- const _ref = (item === null || item === void 0 ? void 0 : item.data) || {}, { _data } = _ref, rest = _objectWithoutProperties(_ref, _excluded);
66
+ var _item$value, _bundleGroupItem$bund;
67
+ const bundleItemId = (_item$value = item === null || item === void 0 ? void 0 : item.value) !== null && _item$value !== void 0 ? _item$value : getBundleItemId(item === null || item === void 0 ? void 0 : item.data);
68
+ const currentBundleItem = bundleGroupItem === null || bundleGroupItem === void 0 || (_bundleGroupItem$bund = bundleGroupItem.bundle_item) === null || _bundleGroupItem$bund === void 0 ? void 0 : _bundleGroupItem$bund.find((bundleItem) => isSameNodeId(bundleItem === null || bundleItem === void 0 ? void 0 : bundleItem.id, bundleItemId));
69
+ const bundleSnapshots = ((originalValue === null || originalValue === void 0 ? void 0 : originalValue.bundle) || []).filter((bundleItem) => isSameNodeId(getBundleItemId(bundleItem), bundleItemId) && (getBundleGroupId(bundleItem) === null || getBundleGroupId(bundleItem) === void 0 || isSameNodeId(getBundleGroupId(bundleItem), groupId)));
70
+ const bundleSnapshot = bundleSnapshots.find((bundleItem) => hasOwnProductionCode(bundleItem));
71
+ const _ref3 = (item === null || item === void 0 ? void 0 : item.data) || {}, { _data } = _ref3, rest = _objectWithoutProperties(_ref3, _excluded);
29
72
  if (_data) _data === null || _data === void 0 || _data.forEach((_item) => {
30
73
  if (_item === null || _item === void 0 ? void 0 : _item.data) {
31
- let _newData = _objectSpread2(_objectSpread2({}, rest), {}, { option: [] });
74
+ const bundleQuantity = Number((_item === null || _item === void 0 ? void 0 : _item.quantity) || 0);
75
+ if (!(bundleQuantity > 0)) return;
76
+ let _newData = _objectSpread2(_objectSpread2({}, rest), {}, {
77
+ option: [],
78
+ production_code: currentBundleItem ? resolveProductionCode(bundleSnapshot, currentBundleItem) : ""
79
+ });
32
80
  let totalPrice = new Decimal(0);
33
81
  Object.keys(_item === null || _item === void 0 ? void 0 : _item.data).forEach((key) => {
34
82
  var _item$data;
35
83
  const _itemDataItem = _item === null || _item === void 0 || (_item$data = _item.data) === null || _item$data === void 0 ? void 0 : _item$data[key];
36
84
  if (Array.isArray(_itemDataItem)) _itemDataItem.forEach((_itemDataItem_item) => {
37
- var _itemDataItem_item$da;
85
+ const outputOption = createOutputOption({
86
+ selectorItem: _itemDataItem_item,
87
+ optionGroupId: key,
88
+ currentOptionGroups: (currentBundleItem === null || currentBundleItem === void 0 ? void 0 : currentBundleItem.option_group) || [],
89
+ snapshotOptions: bundleSnapshots.flatMap((bundleItem) => (bundleItem === null || bundleItem === void 0 ? void 0 : bundleItem.option) || [])
90
+ });
91
+ if (!outputOption) return;
38
92
  totalPrice = totalPrice.plus(new Decimal((_itemDataItem_item === null || _itemDataItem_item === void 0 ? void 0 : _itemDataItem_item.totalPrice) || 0));
39
- _newData.option.push(_objectSpread2(_objectSpread2({}, (_itemDataItem_item === null || _itemDataItem_item === void 0 ? void 0 : _itemDataItem_item.data) || {}), {}, { product_option_item_id: _itemDataItem_item === null || _itemDataItem_item === void 0 || (_itemDataItem_item$da = _itemDataItem_item.data) === null || _itemDataItem_item$da === void 0 ? void 0 : _itemDataItem_item$da.id }));
93
+ _newData.option.push(outputOption);
40
94
  });
41
95
  else {
42
- var _itemDataItem$data;
96
+ const outputOption = createOutputOption({
97
+ selectorItem: _itemDataItem,
98
+ optionGroupId: key,
99
+ currentOptionGroups: (currentBundleItem === null || currentBundleItem === void 0 ? void 0 : currentBundleItem.option_group) || [],
100
+ snapshotOptions: bundleSnapshots.flatMap((bundleItem) => (bundleItem === null || bundleItem === void 0 ? void 0 : bundleItem.option) || [])
101
+ });
102
+ if (!outputOption) return;
43
103
  totalPrice = totalPrice.plus(new Decimal((_itemDataItem === null || _itemDataItem === void 0 ? void 0 : _itemDataItem.totalPrice) || 0));
44
- _newData.option.push(_objectSpread2(_objectSpread2({}, (_itemDataItem === null || _itemDataItem === void 0 ? void 0 : _itemDataItem.data) || {}), {}, { product_option_item_id: _itemDataItem === null || _itemDataItem === void 0 || (_itemDataItem$data = _itemDataItem.data) === null || _itemDataItem$data === void 0 ? void 0 : _itemDataItem$data.id }));
104
+ _newData.option.push(outputOption);
45
105
  }
46
106
  });
47
107
  const _restPricePrefix = (rest === null || rest === void 0 ? void 0 : rest.price_type) === "markdown" ? -1 : 1;
48
108
  _newData.price = totalPrice.plus(new Decimal((rest === null || rest === void 0 ? void 0 : rest.price) || 0).times(_restPricePrefix)).toString();
49
109
  _newData.original_price = _newData === null || _newData === void 0 ? void 0 : _newData.price;
50
110
  _newData.original_total = _newData === null || _newData === void 0 ? void 0 : _newData.price;
51
- _newData.quantity = (_item === null || _item === void 0 ? void 0 : _item.quantity) || 0;
52
- _newData.num = (_item === null || _item === void 0 ? void 0 : _item.quantity) || 0;
111
+ _newData.quantity = bundleQuantity;
112
+ _newData.num = bundleQuantity;
53
113
  _newData._bundle_product_id = _newData === null || _newData === void 0 ? void 0 : _newData.bundle_product_id;
54
114
  transformValue.bundle.push(_newData);
55
115
  }
56
116
  });
57
117
  else {
118
+ var _ref4, _ref5, _item$quantity;
58
119
  const _newData = _objectSpread2({}, (item === null || item === void 0 ? void 0 : item.data) || {});
120
+ const bundleQuantity = Number((_ref4 = (_ref5 = (_item$quantity = item === null || item === void 0 ? void 0 : item.quantity) !== null && _item$quantity !== void 0 ? _item$quantity : _newData === null || _newData === void 0 ? void 0 : _newData.quantity) !== null && _ref5 !== void 0 ? _ref5 : _newData === null || _newData === void 0 ? void 0 : _newData.num) !== null && _ref4 !== void 0 ? _ref4 : 0);
121
+ if (!(bundleQuantity > 0)) return;
122
+ _newData.production_code = currentBundleItem ? resolveProductionCode(bundleSnapshot, currentBundleItem) : "";
123
+ _newData.quantity = bundleQuantity;
124
+ _newData.num = bundleQuantity;
59
125
  const _pricePrefix = (_newData === null || _newData === void 0 ? void 0 : _newData.price_type) === "markdown" ? -1 : 1;
60
126
  _newData.price = new Decimal((_newData === null || _newData === void 0 ? void 0 : _newData.price) || 0).times(_pricePrefix).toString();
61
127
  _newData.original_price = _newData === null || _newData === void 0 ? void 0 : _newData.price;
@@ -77,8 +143,13 @@ const transformSelectorValueToValue = (selectorValue) => {
77
143
  else _groupItemValue = [groupItemValue];
78
144
  _groupItemValue === null || _groupItemValue === void 0 || _groupItemValue.forEach((item) => {
79
145
  if (item === null || item === void 0 ? void 0 : item.data) {
80
- var _item$data2;
81
- transformValue.option.push(_objectSpread2(_objectSpread2({}, (item === null || item === void 0 ? void 0 : item.data) || {}), {}, { product_option_item_id: item === null || item === void 0 || (_item$data2 = item.data) === null || _item$data2 === void 0 ? void 0 : _item$data2.id }));
146
+ const outputOption = createOutputOption({
147
+ selectorItem: item,
148
+ optionGroupId: groupId,
149
+ currentOptionGroups: (dataSource === null || dataSource === void 0 ? void 0 : dataSource.option_group) || [],
150
+ snapshotOptions: (originalValue === null || originalValue === void 0 ? void 0 : originalValue.option) || []
151
+ });
152
+ if (outputOption) transformValue.option.push(outputOption);
82
153
  }
83
154
  });
84
155
  });
@@ -96,9 +167,9 @@ const transformSelectorValueToValue = (selectorValue) => {
96
167
  else _groupItemValue = [groupItemValue];
97
168
  _groupItemValue === null || _groupItemValue === void 0 || _groupItemValue.forEach((item) => {
98
169
  if (item === null || item === void 0 ? void 0 : item.data) {
99
- var _item$data3, _item$data4, _item$data5;
100
- selectedVariantIds.push(`${item === null || item === void 0 || (_item$data3 = item.data) === null || _item$data3 === void 0 ? void 0 : _item$data3.variant_group_id}:${item === null || item === void 0 || (_item$data4 = item.data) === null || _item$data4 === void 0 ? void 0 : _item$data4.id}`);
101
- selectedVariantOptionString.push(`${variantGroupItem === null || variantGroupItem === void 0 ? void 0 : variantGroupItem.name}:${item === null || item === void 0 || (_item$data5 = item.data) === null || _item$data5 === void 0 ? void 0 : _item$data5.name}`);
170
+ var _item$data2, _item$data3, _item$data4;
171
+ selectedVariantIds.push(`${item === null || item === void 0 || (_item$data2 = item.data) === null || _item$data2 === void 0 ? void 0 : _item$data2.variant_group_id}:${item === null || item === void 0 || (_item$data3 = item.data) === null || _item$data3 === void 0 ? void 0 : _item$data3.id}`);
172
+ selectedVariantOptionString.push(`${variantGroupItem === null || variantGroupItem === void 0 ? void 0 : variantGroupItem.name}:${item === null || item === void 0 || (_item$data4 = item.data) === null || _item$data4 === void 0 ? void 0 : _item$data4.name}`);
102
173
  }
103
174
  });
104
175
  });
@@ -110,12 +181,15 @@ const transformSelectorValueToValue = (selectorValue) => {
110
181
  return selectedVariantIds.every((idItem) => ids.includes(idItem));
111
182
  });
112
183
  if (filteredVariant === null || filteredVariant === void 0 ? void 0 : filteredVariant.length) {
113
- var _filteredVariant$;
114
- transformValue.product_variant_id = (_filteredVariant$ = filteredVariant[0]) === null || _filteredVariant$ === void 0 ? void 0 : _filteredVariant$.id;
184
+ selectedVariant = filteredVariant[0];
185
+ transformValue.product_variant_id = selectedVariant === null || selectedVariant === void 0 ? void 0 : selectedVariant.id;
115
186
  transformValue.product_option_string = selectedVariantOptionString.join(", ");
116
187
  }
117
188
  }
118
189
  }
190
+ if (selectedVariant) transformValue.production_code = resolveProductionCode(isSameNodeId(originalValue === null || originalValue === void 0 ? void 0 : originalValue.product_variant_id, selectedVariant === null || selectedVariant === void 0 ? void 0 : selectedVariant.id) ? originalValue : void 0, selectedVariant);
191
+ else transformValue.production_code = resolveProductionCode((originalValue === null || originalValue === void 0 ? void 0 : originalValue.product_variant_id) === null || (originalValue === null || originalValue === void 0 ? void 0 : originalValue.product_variant_id) === void 0 || Number(originalValue === null || originalValue === void 0 ? void 0 : originalValue.product_variant_id) === 0 ? originalValue : void 0, dataSource);
192
+ console.log("transformSelectorValueToValue>>>>>", transformValue);
119
193
  return transformValue;
120
194
  };
121
195
  //#endregion