@pisell/pisellos 2.2.152 → 2.2.154

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 (92) hide show
  1. package/dist/core/index.js +1 -0
  2. package/dist/model/strategy/adapter/promotion/index.js +9 -0
  3. package/dist/modules/Cart/utils/cartProduct.js +1 -1
  4. package/dist/modules/Discount/index.d.ts +6 -2
  5. package/dist/modules/Discount/index.js +14 -8
  6. package/dist/modules/Order/index.d.ts +2 -0
  7. package/dist/modules/Order/index.js +234 -161
  8. package/dist/modules/Order/types.d.ts +19 -0
  9. package/dist/modules/Order/utils.js +7 -6
  10. package/dist/modules/Payment/index.d.ts +4 -0
  11. package/dist/modules/Payment/index.js +567 -505
  12. package/dist/modules/Payment/types.d.ts +29 -9
  13. package/dist/modules/SalesSummary/index.d.ts +7 -5
  14. package/dist/modules/SalesSummary/index.js +35 -11
  15. package/dist/plugins/app.d.ts +2 -0
  16. package/dist/server/index.d.ts +2 -5
  17. package/dist/server/index.js +58 -66
  18. package/dist/server/modules/index.d.ts +1 -1
  19. package/dist/server/modules/products/index.d.ts +12 -1
  20. package/dist/server/modules/products/index.js +169 -78
  21. package/dist/server/modules/products/types.d.ts +11 -0
  22. package/dist/server/modules/products/types.js +4 -0
  23. package/dist/server/utils/product.js +2 -2
  24. package/dist/solution/BaseSales/index.d.ts +26 -2
  25. package/dist/solution/BaseSales/index.js +342 -112
  26. package/dist/solution/BaseSales/types.d.ts +4 -4
  27. package/dist/solution/BaseSales/types.js +4 -4
  28. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +62 -0
  29. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +116 -0
  30. package/dist/solution/BaseSales/utils.js +3 -3
  31. package/dist/solution/BookingByStep/index.d.ts +1 -1
  32. package/dist/solution/BookingTicket/index.d.ts +11 -13
  33. package/dist/solution/BookingTicket/index.js +23 -37
  34. package/dist/solution/BookingTicket/types.d.ts +9 -6
  35. package/dist/solution/BookingTicket/types.js +6 -3
  36. package/dist/solution/BookingTicket/utils/cartView.d.ts +7 -12
  37. package/dist/solution/BookingTicket/utils/cartView.js +52 -14
  38. package/dist/solution/BookingTicket/utils/orderCustomer.d.ts +4 -0
  39. package/dist/solution/BookingTicket/utils/orderCustomer.js +31 -0
  40. package/dist/solution/Sales/index.d.ts +3 -0
  41. package/dist/solution/Sales/index.js +85 -43
  42. package/dist/solution/Sales/types.d.ts +3 -0
  43. package/dist/solution/ScanOrder/types.d.ts +4 -4
  44. package/dist/solution/ScanOrder/types.js +4 -4
  45. package/dist/solution/ScanOrder/utils.js +3 -3
  46. package/dist/solution/ShopDiscount/index.d.ts +2 -1
  47. package/dist/solution/ShopDiscount/index.js +32 -20
  48. package/dist/solution/ShopDiscount/types.d.ts +1 -0
  49. package/lib/core/index.js +1 -0
  50. package/lib/modules/Cart/utils/cartProduct.js +1 -1
  51. package/lib/modules/Discount/index.d.ts +6 -2
  52. package/lib/modules/Discount/index.js +3 -1
  53. package/lib/modules/Order/index.d.ts +2 -0
  54. package/lib/modules/Order/index.js +40 -8
  55. package/lib/modules/Order/types.d.ts +19 -0
  56. package/lib/modules/Order/utils.js +4 -2
  57. package/lib/modules/Payment/index.d.ts +4 -0
  58. package/lib/modules/Payment/index.js +26 -2
  59. package/lib/modules/Payment/types.d.ts +29 -9
  60. package/lib/modules/SalesSummary/index.d.ts +7 -5
  61. package/lib/modules/SalesSummary/index.js +29 -9
  62. package/lib/plugins/app.d.ts +2 -0
  63. package/lib/server/index.d.ts +2 -5
  64. package/lib/server/index.js +38 -58
  65. package/lib/server/modules/index.d.ts +1 -1
  66. package/lib/server/modules/products/index.d.ts +12 -1
  67. package/lib/server/modules/products/index.js +69 -9
  68. package/lib/server/modules/products/types.d.ts +11 -0
  69. package/lib/server/utils/product.js +2 -2
  70. package/lib/solution/BaseSales/index.d.ts +26 -2
  71. package/lib/solution/BaseSales/index.js +169 -3
  72. package/lib/solution/BaseSales/types.d.ts +4 -4
  73. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +62 -0
  74. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +155 -0
  75. package/lib/solution/BaseSales/utils.js +3 -3
  76. package/lib/solution/BookingByStep/index.d.ts +1 -1
  77. package/lib/solution/BookingTicket/index.d.ts +11 -13
  78. package/lib/solution/BookingTicket/index.js +17 -27
  79. package/lib/solution/BookingTicket/types.d.ts +9 -6
  80. package/lib/solution/BookingTicket/utils/cartView.d.ts +7 -12
  81. package/lib/solution/BookingTicket/utils/cartView.js +44 -18
  82. package/lib/solution/BookingTicket/utils/orderCustomer.d.ts +4 -0
  83. package/lib/solution/BookingTicket/utils/orderCustomer.js +58 -0
  84. package/lib/solution/Sales/index.d.ts +3 -0
  85. package/lib/solution/Sales/index.js +50 -15
  86. package/lib/solution/Sales/types.d.ts +3 -0
  87. package/lib/solution/ScanOrder/types.d.ts +4 -4
  88. package/lib/solution/ScanOrder/utils.js +3 -3
  89. package/lib/solution/ShopDiscount/index.d.ts +2 -1
  90. package/lib/solution/ShopDiscount/index.js +10 -4
  91. package/lib/solution/ShopDiscount/types.d.ts +1 -0
  92. package/package.json +1 -1
@@ -91,13 +91,13 @@ export interface BaseSalesOrderProduct extends BaseSalesOrderProductIdentity {
91
91
  * 出站 payload 版本的商品行。
92
92
  *
93
93
  * 与 tempOrder 内部 `BaseSalesOrderProduct` 的字段差异:
94
- * - `product_option_item[*]`:内部为 `{ product_option_item_id, option_group_id, num, price, ... }`,
95
- * 出站由 `normalizeSubmitProduct` 重命名为 `{ option_group_item_id, option_group_id, num }`
94
+ * - `product_option_item[*]`:内部为 `{ option_group_item_id, option_group_id, num, price, ... }`,
95
+ * 出站保留 `{ option_group_item_id, option_group_id, num }`
96
96
  * (后端 checkout 协议;丢弃 `price` 等运行时辅助字段)。
97
97
  * - `product_bundle[*].option[*]`:同上重命名规则。
98
98
  *
99
- * 运行时(UI 显示、加购合并、指纹、持久化)全部消费内部字段名 `product_option_item_id`,
100
- * 仅在 SDK 提交边界做一次出站映射,不影响 opaque identity 契约。
99
+ * 运行时(UI 显示、加购合并、指纹、持久化)与提交边界统一消费字段名
100
+ * `option_group_item_id`,保持 tempOrder 与后端协议一致。
101
101
  */
102
102
  export interface BaseSalesSubmitProduct extends Omit<BaseSalesOrderProduct, '_origin' | 'identity_key'> {
103
103
  /**
@@ -17,13 +17,13 @@ export function createBaseSalesHook(moduleName, hookName) {
17
17
  * 出站 payload 版本的商品行。
18
18
  *
19
19
  * 与 tempOrder 内部 `BaseSalesOrderProduct` 的字段差异:
20
- * - `product_option_item[*]`:内部为 `{ product_option_item_id, option_group_id, num, price, ... }`,
21
- * 出站由 `normalizeSubmitProduct` 重命名为 `{ option_group_item_id, option_group_id, num }`
20
+ * - `product_option_item[*]`:内部为 `{ option_group_item_id, option_group_id, num, price, ... }`,
21
+ * 出站保留 `{ option_group_item_id, option_group_id, num }`
22
22
  * (后端 checkout 协议;丢弃 `price` 等运行时辅助字段)。
23
23
  * - `product_bundle[*].option[*]`:同上重命名规则。
24
24
  *
25
- * 运行时(UI 显示、加购合并、指纹、持久化)全部消费内部字段名 `product_option_item_id`,
26
- * 仅在 SDK 提交边界做一次出站映射,不影响 opaque identity 契约。
25
+ * 运行时(UI 显示、加购合并、指纹、持久化)与提交边界统一消费字段名
26
+ * `option_group_item_id`,保持 tempOrder 与后端协议一致。
27
27
  */
28
28
 
29
29
  /**
@@ -0,0 +1,62 @@
1
+ import type { OrderProduct, OrderProductIdentity } from '../../../modules/Order/types';
2
+ import type { ProductData } from '../../../modules/Product/types';
3
+ export interface BaseProductDetailOptionItem {
4
+ option_group_item_id?: number | string;
5
+ option_group_id?: number | string;
6
+ num?: number | string;
7
+ quantity?: number | string;
8
+ price?: number | string;
9
+ add_price?: number | string;
10
+ [key: string]: any;
11
+ }
12
+ export interface BaseProductDetailBundleItem {
13
+ option?: BaseProductDetailOptionItem[];
14
+ [key: string]: any;
15
+ }
16
+ export interface BaseProductDetailPayload {
17
+ id?: number | string | null;
18
+ product_id?: number | string | null;
19
+ variant_id?: number | string | null;
20
+ product_variant_id?: number | string | null;
21
+ quantity?: number | string;
22
+ num?: number | string;
23
+ option?: BaseProductDetailOptionItem[];
24
+ options?: BaseProductDetailOptionItem[];
25
+ product_option_item?: BaseProductDetailOptionItem[];
26
+ bundle?: BaseProductDetailBundleItem[];
27
+ product_bundle?: BaseProductDetailBundleItem[];
28
+ unique?: string;
29
+ unique_identification_number?: string;
30
+ session?: any;
31
+ form?: any;
32
+ service_times?: any;
33
+ machine_code?: string;
34
+ schedule_id?: number[];
35
+ duration?: number;
36
+ policy_id?: number;
37
+ source_shop_id?: number;
38
+ origin?: Record<string, any>;
39
+ _origin?: Record<string, any>;
40
+ price?: number | string;
41
+ selling_price?: number | string;
42
+ original_price?: number | string;
43
+ tax_fee?: number | string;
44
+ is_charge_tax?: number;
45
+ note?: string;
46
+ [key: string]: any;
47
+ }
48
+ export interface TransformBaseProductToOrderProductParams {
49
+ payload: BaseProductDetailPayload;
50
+ fallbackProductId?: number | string | null;
51
+ sourceProduct?: ProductData | Record<string, any> | null;
52
+ sourceItem?: ProductData | Record<string, any> | null;
53
+ }
54
+ export type BaseProductOrderProductInput = Partial<OrderProduct> & OrderProductIdentity & {
55
+ _origin?: Record<string, any>;
56
+ };
57
+ /**
58
+ * 将商品列表原始数据 + 商品详情选择回调转换成 OrderModule.addProductToOrder 入参。
59
+ *
60
+ * 注意:这里不生成 identity,缺省时由 OrderModule 自动补齐。
61
+ */
62
+ export declare function transformBaseProductToOrderProduct(params: TransformBaseProductToOrderProductParams): BaseProductOrderProductInput | null;
@@ -0,0 +1,116 @@
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 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
+ 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
+ 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; }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
+ function toNumber(value) {
8
+ var fallback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
9
+ var parsedValue = Number(value);
10
+ if (!Number.isFinite(parsedValue)) return fallback;
11
+ return parsedValue;
12
+ }
13
+ function toProductId(value) {
14
+ if (value === null || value === undefined || value === '') return null;
15
+ var parsedValue = Number(value);
16
+ if (!Number.isFinite(parsedValue)) return null;
17
+ return parsedValue;
18
+ }
19
+ function toSafePositiveInt(value) {
20
+ var fallback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
21
+ var parsedValue = Math.floor(Number(value));
22
+ if (!Number.isFinite(parsedValue) || parsedValue < 1) return fallback;
23
+ return parsedValue;
24
+ }
25
+ function toPriceString(value) {
26
+ var fallback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '0.00';
27
+ var parsedValue = Number(value);
28
+ if (!Number.isFinite(parsedValue)) return fallback;
29
+ return parsedValue.toFixed(2);
30
+ }
31
+ function normalizeOptionItems(optionItems) {
32
+ if (!Array.isArray(optionItems)) return [];
33
+ return optionItems.map(function (optionItem) {
34
+ var _ref, _optionItem$price, _optionItem$num;
35
+ var optionGroupItemId = toNumber(optionItem === null || optionItem === void 0 ? void 0 : optionItem.option_group_item_id);
36
+ var price = (_ref = (_optionItem$price = optionItem === null || optionItem === void 0 ? void 0 : optionItem.price) !== null && _optionItem$price !== void 0 ? _optionItem$price : optionItem === null || optionItem === void 0 ? void 0 : optionItem.add_price) !== null && _ref !== void 0 ? _ref : 0;
37
+ return {
38
+ option_group_item_id: optionGroupItemId,
39
+ option_group_id: toNumber(optionItem === null || optionItem === void 0 ? void 0 : optionItem.option_group_id),
40
+ num: toSafePositiveInt((_optionItem$num = optionItem === null || optionItem === void 0 ? void 0 : optionItem.num) !== null && _optionItem$num !== void 0 ? _optionItem$num : optionItem === null || optionItem === void 0 ? void 0 : optionItem.quantity, 1),
41
+ price: toNumber(price, 0)
42
+ };
43
+ });
44
+ }
45
+ function normalizeBundleItems(bundleItems) {
46
+ if (!Array.isArray(bundleItems)) return [];
47
+ return bundleItems.map(function (bundleItem) {
48
+ return _objectSpread(_objectSpread({}, bundleItem), {}, {
49
+ option: normalizeOptionItems(bundleItem === null || bundleItem === void 0 ? void 0 : bundleItem.option)
50
+ });
51
+ });
52
+ }
53
+ function findVariantById(origin, variantId) {
54
+ if (!origin || !variantId || variantId <= 0) return null;
55
+ var variants = Array.isArray(origin === null || origin === void 0 ? void 0 : origin.variant) ? origin.variant : [];
56
+ return variants.find(function (variant) {
57
+ return Number(variant === null || variant === void 0 ? void 0 : variant.id) === variantId;
58
+ }) || null;
59
+ }
60
+
61
+ /**
62
+ * 将商品列表原始数据 + 商品详情选择回调转换成 OrderModule.addProductToOrder 入参。
63
+ *
64
+ * 注意:这里不生成 identity,缺省时由 OrderModule 自动补齐。
65
+ */
66
+ export function transformBaseProductToOrderProduct(params) {
67
+ var _ref2, _ref3, _ref4, _payload$product_id, _ref5, _ref6, _payload$product_vari, _payload$_origin, _payload$_origin2, _ref7, _findVariantById, _ref8, _ref9, _ref10, _ref11, _ref12, _ref13, _ref14, _payload$price, _ref15, _payload$option, _payload$bundle, _payload$unique_ident, _payload$quantity, _ref16, _ref17, _payload$tax_fee, _ref18, _ref19, _payload$is_charge_ta;
68
+ var payload = params.payload,
69
+ _params$fallbackProdu = params.fallbackProductId,
70
+ fallbackProductId = _params$fallbackProdu === void 0 ? null : _params$fallbackProdu;
71
+ if (!payload || _typeof(payload) !== 'object') return null;
72
+ var sourceProduct = params.sourceProduct || params.sourceItem || {};
73
+ var productId = toProductId((_ref2 = (_ref3 = (_ref4 = (_payload$product_id = payload.product_id) !== null && _payload$product_id !== void 0 ? _payload$product_id : payload.id) !== null && _ref4 !== void 0 ? _ref4 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.product_id) !== null && _ref3 !== void 0 ? _ref3 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.id) !== null && _ref2 !== void 0 ? _ref2 : fallbackProductId);
74
+ if (productId === null) return null;
75
+ var productVariantId = toNumber((_ref5 = (_ref6 = (_payload$product_vari = payload.product_variant_id) !== null && _payload$product_vari !== void 0 ? _payload$product_vari : payload.variant_id) !== null && _ref6 !== void 0 ? _ref6 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.product_variant_id) !== null && _ref5 !== void 0 ? _ref5 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.variant_id, 0);
76
+ var callbackOrigin = payload.origin || ((_payload$_origin = payload._origin) === null || _payload$_origin === void 0 ? void 0 : _payload$_origin.sourceProduct) || ((_payload$_origin2 = payload._origin) === null || _payload$_origin2 === void 0 ? void 0 : _payload$_origin2.sourceItem) || payload._origin || {};
77
+ var origin = _objectSpread(_objectSpread({}, sourceProduct || {}), callbackOrigin || {});
78
+ var matchedVariant = (_ref7 = (_findVariantById = findVariantById(callbackOrigin, productVariantId)) !== null && _findVariantById !== void 0 ? _findVariantById : findVariantById(sourceProduct, productVariantId)) !== null && _ref7 !== void 0 ? _ref7 : findVariantById(origin, productVariantId);
79
+ var sourceProductPrice = toPriceString((_ref8 = (_ref9 = (_ref10 = (_ref11 = (_ref12 = (_ref13 = (_ref14 = (_payload$price = payload.price) !== null && _payload$price !== void 0 ? _payload$price : payload.selling_price) !== null && _ref14 !== void 0 ? _ref14 : matchedVariant === null || matchedVariant === void 0 ? void 0 : matchedVariant.price) !== null && _ref13 !== void 0 ? _ref13 : matchedVariant === null || matchedVariant === void 0 ? void 0 : matchedVariant.base_price) !== null && _ref12 !== void 0 ? _ref12 : origin === null || origin === void 0 ? void 0 : origin.price) !== null && _ref11 !== void 0 ? _ref11 : origin === null || origin === void 0 ? void 0 : origin.base_price) !== null && _ref10 !== void 0 ? _ref10 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.price) !== null && _ref9 !== void 0 ? _ref9 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.selling_price) !== null && _ref8 !== void 0 ? _ref8 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.base_price, '0.00');
80
+ var productOptionItem = normalizeOptionItems((_ref15 = (_payload$option = payload.option) !== null && _payload$option !== void 0 ? _payload$option : payload.options) !== null && _ref15 !== void 0 ? _ref15 : payload.product_option_item);
81
+ var productBundle = normalizeBundleItems((_payload$bundle = payload.bundle) !== null && _payload$bundle !== void 0 ? _payload$bundle : payload.product_bundle);
82
+ var uniqueIdentificationNumber = (_payload$unique_ident = payload.unique_identification_number) !== null && _payload$unique_ident !== void 0 ? _payload$unique_ident : payload.unique;
83
+ var metadata = {
84
+ unique: payload.unique,
85
+ session: payload.session,
86
+ form: payload.form,
87
+ service_times: payload.service_times,
88
+ machine_code: payload.machine_code,
89
+ schedule_id: payload.schedule_id,
90
+ duration: payload.duration,
91
+ policy_id: payload.policy_id,
92
+ source_shop_id: payload.source_shop_id,
93
+ origin: origin,
94
+ source_product_price: sourceProductPrice
95
+ };
96
+ if (uniqueIdentificationNumber) {
97
+ metadata.unique_identification_number = String(uniqueIdentificationNumber);
98
+ }
99
+ return {
100
+ product_id: productId,
101
+ product_variant_id: productVariantId,
102
+ unique_identification_number: uniqueIdentificationNumber ? String(uniqueIdentificationNumber) : undefined,
103
+ num: toSafePositiveInt((_payload$quantity = payload.quantity) !== null && _payload$quantity !== void 0 ? _payload$quantity : payload.num, 1),
104
+ product_option_item: productOptionItem,
105
+ product_bundle: productBundle,
106
+ selling_price: sourceProductPrice,
107
+ original_price: sourceProductPrice,
108
+ tax_fee: toPriceString((_ref16 = (_ref17 = (_payload$tax_fee = payload.tax_fee) !== null && _payload$tax_fee !== void 0 ? _payload$tax_fee : matchedVariant === null || matchedVariant === void 0 ? void 0 : matchedVariant.tax_fee) !== null && _ref17 !== void 0 ? _ref17 : origin === null || origin === void 0 ? void 0 : origin.tax_fee) !== null && _ref16 !== void 0 ? _ref16 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.tax_fee, '0.00'),
109
+ is_charge_tax: toNumber((_ref18 = (_ref19 = (_payload$is_charge_ta = payload.is_charge_tax) !== null && _payload$is_charge_ta !== void 0 ? _payload$is_charge_ta : matchedVariant === null || matchedVariant === void 0 ? void 0 : matchedVariant.is_charge_tax) !== null && _ref19 !== void 0 ? _ref19 : origin === null || origin === void 0 ? void 0 : origin.is_charge_tax) !== null && _ref18 !== void 0 ? _ref18 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.is_charge_tax, 0),
110
+ metadata: metadata,
111
+ note: payload.note != null ? String(payload.note) : '',
112
+ _origin: _objectSpread(_objectSpread({}, sourceProduct || {}), {}, {
113
+ callbackData: payload
114
+ })
115
+ };
116
+ }
@@ -40,14 +40,14 @@ export function buildProductLineFingerprint(productOptionItem, productBundle) {
40
40
  var normalizedOpts = optArr.map(function (item) {
41
41
  var _item$price;
42
42
  return {
43
- product_option_item_id: Number(item === null || item === void 0 ? void 0 : item.product_option_item_id) || 0,
43
+ option_group_item_id: Number(item === null || item === void 0 ? void 0 : item.option_group_item_id) || 0,
44
44
  option_group_id: Number(item === null || item === void 0 ? void 0 : item.option_group_id) || 0,
45
45
  num: typeof (item === null || item === void 0 ? void 0 : item.num) === 'number' && !Number.isNaN(item.num) ? Math.max(1, Math.floor(item.num)) : 1,
46
46
  price: String((_item$price = item === null || item === void 0 ? void 0 : item.price) !== null && _item$price !== void 0 ? _item$price : '')
47
47
  };
48
48
  }).sort(function (p, q) {
49
- if (p.product_option_item_id !== q.product_option_item_id) {
50
- return p.product_option_item_id - q.product_option_item_id;
49
+ if (p.option_group_item_id !== q.option_group_item_id) {
50
+ return p.option_group_item_id - q.option_group_item_id;
51
51
  }
52
52
  if (p.option_group_id !== q.option_group_id) return p.option_group_id - q.option_group_id;
53
53
  if (p.num !== q.num) return p.num - q.num;
@@ -311,7 +311,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
311
311
  date: string;
312
312
  status: string;
313
313
  week: string;
314
- weekNum: 0 | 1 | 2 | 3 | 4 | 5 | 6;
314
+ weekNum: 0 | 2 | 1 | 5 | 3 | 4 | 6;
315
315
  }[]>;
316
316
  submitTimeSlot(timeSlots: TimeSliceItem): void;
317
317
  private getScheduleDataByIds;
@@ -1,7 +1,7 @@
1
1
  import { Module, ModuleOptions, PisellCore } from '../../types';
2
- import { BookingTicketCartView, BookingTicketCustomerView, BookingTicketProductCatalogView, BookingTicketState, IGetCustomerListParams, ICustomer, ILoadProductsParams, ILoadProductDetailParams, IScanResult } from './types';
2
+ import { BookingTicketCartView, BookingTicketProductCatalogView, BookingTicketState, IGetCustomerListParams, ICustomer, ILoadProductsParams, ILoadProductDetailParams, IScanResult } from './types';
3
3
  import type { ProductData } from '../../modules';
4
- import type { OrderCustomerView, OrderCustomerPatch } from '../../modules/Order/types';
4
+ import type { OrderCustomerView } from '../../modules/Order/types';
5
5
  import { BaseSalesImpl } from '../BaseSales';
6
6
  import type { ISalesDetail } from '../BaseSales/utils/parseSalesResponse';
7
7
  import type { LoadSalesDetailParams } from '../../modules/Order/types';
@@ -13,7 +13,6 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
13
13
  * 父类按 `getRegisteredModuleNames` 注入成员到该 store。
14
14
  */
15
15
  protected store: BookingTicketState;
16
- private shopStore;
17
16
  private platform;
18
17
  private scan;
19
18
  private productCatalog;
@@ -102,16 +101,13 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
102
101
  /**
103
102
  * 获取购物车 UI 视图。
104
103
  *
105
- * tempOrder 仍是 checkout 协议对象;本方法只输出 UI 直接消费的数据,
106
- * 商品行展示字段在 Solution 层合并,避免 UI 直接读取 tempOrder 原始结构。
104
+ * tempOrder 仍是 checkout 协议对象;商品行直接透传 products,bookings 附带关联商品。
107
105
  */
108
106
  getCart(): BookingTicketCartView;
109
107
  /**
110
- * 获取客户 UI 视图。
111
- *
112
- * 优先使用 CustomerModule 的 selected customer;缺失时回退到 tempOrder 顶层客户字段。
108
+ * 获取当前下单客户(与 OrderModule.tempOrder snapshot 一致)。
113
109
  */
114
- getCustomer(): BookingTicketCustomerView | null;
110
+ getCustomer(): ICustomer | null;
115
111
  /**
116
112
  * 通过 ids 获取商品列表(不加载到模块中)
117
113
  * @returns 商品列表
@@ -169,13 +165,15 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
169
165
  /**
170
166
  * 设置当前下单客户。
171
167
  *
172
- * @param patch tempOrder 协议字段(customer_id 必填,其余缺省视为清空)
173
- * @param snapshot UI 富字段快照;undefined 不动;null 清空;ICustomer 写入
168
+ * @param customer 完整客户对象;null 表示清空
169
+ *
170
+ * 内部将 customer 格式化为 tempOrder 协议字段后写入 OrderModule,
171
+ * 并以 customer 作为 snapshot 保存富字段。
174
172
  *
175
173
  * 同时透传 OrderModule 内部 emit 的 `order:onOrderCustomerChange` 之外,
176
174
  * 在 BookingTicket 命名空间也 emit 一次,方便上层统一从 Solution 订阅。
177
175
  */
178
- setOrderCustomer(patch: OrderCustomerPatch | null, snapshot?: ICustomer | null): void;
176
+ setOrderCustomer(customer: ICustomer | null): void;
179
177
  /**
180
178
  * 读取 tempOrder 上的下单客户协议字段;customer_id 缺失时返回 null。
181
179
  */
@@ -233,7 +231,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
233
231
  * 获取当前的客户搜索条件
234
232
  * @returns 当前搜索条件
235
233
  */
236
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
234
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
237
235
  /**
238
236
  * 获取客户列表状态(包含滚动加载相关状态)
239
237
  * @returns 客户状态
@@ -32,9 +32,10 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
32
32
  import { createBookingTicketModule } from "./types";
33
33
  import { BaseSalesImpl } from "../BaseSales";
34
34
  import Scan from "./utils/scan";
35
+ import { formatOrderCustomerPatch } from "./utils/orderCustomer";
35
36
  import { handleGlobalScan, handleCustomerScan, handleUniversalScan } from "./utils/scan/handleScan";
36
37
  import scanCache from "./utils/scan/scanCache";
37
- import { buildCartItemViews, buildCustomerView, indexBookingsByProductUid } from "./utils/cartView";
38
+ import { buildCartView } from "./utils/cartView";
38
39
  import { applyBookingsStatus, resolveScheduleId, restoreBookingsStatus } from "./utils/bookingStatus";
39
40
  export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
40
41
  _inherits(BookingTicketImpl, _BaseSalesImpl);
@@ -53,7 +54,6 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
53
54
  * 父类按 `getRegisteredModuleNames` 注入成员到该 store。
54
55
  */
55
56
  _defineProperty(_assertThisInitialized(_this), "store", {});
56
- _defineProperty(_assertThisInitialized(_this), "shopStore", void 0);
57
57
  _defineProperty(_assertThisInitialized(_this), "platform", void 0);
58
58
  _defineProperty(_assertThisInitialized(_this), "scan", void 0);
59
59
  _defineProperty(_assertThisInitialized(_this), "productCatalog", []);
@@ -92,25 +92,18 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
92
92
  case 0:
93
93
  options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
94
94
  this.scan = new Scan(this, 'BOOKING_TICKET_SCAN');
95
- this.shopStore = core.getPlugin('shopStore');
96
- if (this.shopStore) {
97
- _context.next = 5;
98
- break;
99
- }
100
- throw new Error('bookingTicket解决方案需要 shopStore 插件支持');
101
- case 5:
102
- _context.next = 7;
95
+ _context.next = 4;
103
96
  return _get(_getPrototypeOf(BookingTicketImpl.prototype), "initialize", this).call(this, core, options);
104
- case 7:
97
+ case 4:
105
98
  if (this.request) {
106
- _context.next = 9;
99
+ _context.next = 6;
107
100
  break;
108
101
  }
109
102
  throw new Error('bookingTicket解决方案需要 request 插件支持');
110
- case 9:
103
+ case 6:
111
104
  this.platform = (_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.platform;
112
105
  console.log('[BookingTicket] 初始化完成');
113
- case 11:
106
+ case 8:
114
107
  case "end":
115
108
  return _context.stop();
116
109
  }
@@ -154,7 +147,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
154
147
  country_calling_code: detailCustomer === null || detailCustomer === void 0 ? void 0 : detailCustomer.country_calling_code
155
148
  });
156
149
  customerModule.setSelectedCustomer(customer);
157
- this.setOrderCustomer(customer, detailCustomer);
150
+ this.setOrderCustomer(customer);
158
151
  }
159
152
  return _context2.abrupt("return", sales);
160
153
  case 8:
@@ -444,8 +437,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
444
437
  /**
445
438
  * 获取购物车 UI 视图。
446
439
  *
447
- * tempOrder 仍是 checkout 协议对象;本方法只输出 UI 直接消费的数据,
448
- * 商品行展示字段在 Solution 层合并,避免 UI 直接读取 tempOrder 原始结构。
440
+ * tempOrder 仍是 checkout 协议对象;商品行直接透传 products,bookings 附带关联商品。
449
441
  */
450
442
  }, {
451
443
  key: "getCart",
@@ -454,28 +446,16 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
454
446
  var tempOrder = (_this$store$order$get2 = (_this$store$order3 = this.store.order) === null || _this$store$order3 === void 0 ? void 0 : _this$store$order3.getTempOrder()) !== null && _this$store$order$get2 !== void 0 ? _this$store$order$get2 : null;
455
447
  var salesDetail = this.getSalesOrder();
456
448
  var bookings = (_salesDetail$bookings = salesDetail === null || salesDetail === void 0 ? void 0 : salesDetail.bookings) !== null && _salesDetail$bookings !== void 0 ? _salesDetail$bookings : (tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.bookings) || [];
457
- var salesDetailBookingMap = salesDetail === null || salesDetail === void 0 ? void 0 : salesDetail.bookingsByProductUid;
458
- var bookingsByProductUid = salesDetailBookingMap && Object.keys(salesDetailBookingMap).length > 0 ? salesDetailBookingMap : indexBookingsByProductUid(bookings);
459
- return {
460
- items: buildCartItemViews((tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.products) || [], {
461
- bookingDetailMap: bookingsByProductUid,
462
- productsCatalog: this.productCatalog
463
- })
464
- };
449
+ return buildCartView((tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.products) || [], bookings);
465
450
  }
466
451
 
467
452
  /**
468
- * 获取客户 UI 视图。
469
- *
470
- * 优先使用 CustomerModule 的 selected customer;缺失时回退到 tempOrder 顶层客户字段。
453
+ * 获取当前下单客户(与 OrderModule.tempOrder snapshot 一致)。
471
454
  */
472
455
  }, {
473
456
  key: "getCustomer",
474
457
  value: function getCustomer() {
475
- var _this$store$customer$, _this$store$customer, _this$store$customer$2, _this$store$order$get3, _this$store$order4, _this$store$order4$ge;
476
- var selected = (_this$store$customer$ = (_this$store$customer = this.store.customer) === null || _this$store$customer === void 0 || (_this$store$customer$2 = _this$store$customer.getSelectedCustomer) === null || _this$store$customer$2 === void 0 ? void 0 : _this$store$customer$2.call(_this$store$customer)) !== null && _this$store$customer$ !== void 0 ? _this$store$customer$ : null;
477
- var tempOrder = (_this$store$order$get3 = (_this$store$order4 = this.store.order) === null || _this$store$order4 === void 0 || (_this$store$order4$ge = _this$store$order4.getTempOrder) === null || _this$store$order4$ge === void 0 ? void 0 : _this$store$order4$ge.call(_this$store$order4)) !== null && _this$store$order$get3 !== void 0 ? _this$store$order$get3 : null;
478
- return buildCustomerView(selected, tempOrder);
458
+ return this.getOrderCustomerSnapshot();
479
459
  }
480
460
 
481
461
  /**
@@ -663,18 +643,24 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
663
643
  /**
664
644
  * 设置当前下单客户。
665
645
  *
666
- * @param patch tempOrder 协议字段(customer_id 必填,其余缺省视为清空)
667
- * @param snapshot UI 富字段快照;undefined 不动;null 清空;ICustomer 写入
646
+ * @param customer 完整客户对象;null 表示清空
647
+ *
648
+ * 内部将 customer 格式化为 tempOrder 协议字段后写入 OrderModule,
649
+ * 并以 customer 作为 snapshot 保存富字段。
668
650
  *
669
651
  * 同时透传 OrderModule 内部 emit 的 `order:onOrderCustomerChange` 之外,
670
652
  * 在 BookingTicket 命名空间也 emit 一次,方便上层统一从 Solution 订阅。
671
653
  */
672
654
  }, {
673
655
  key: "setOrderCustomer",
674
- value: function setOrderCustomer(patch, snapshot) {
675
- this.store.order.setOrderCustomer(patch, snapshot);
656
+ value: function setOrderCustomer(customer) {
657
+ if (!customer) {
658
+ this.clearOrderCustomer();
659
+ return;
660
+ }
661
+ var patch = formatOrderCustomerPatch(customer);
662
+ this.store.order.setOrderCustomer(patch, customer);
676
663
  var next = this.buildOrderCustomerPayload();
677
- console.log('setOrderCustomer1234', patch, snapshot, next);
678
664
  this.core.effects.emit("".concat(this.name, ":onOrderCustomerChange"), next);
679
665
  }
680
666
 
@@ -94,21 +94,24 @@ export interface IScanResult {
94
94
  result: any;
95
95
  }
96
96
  /**
97
- * BookingTicket 面向 UI 的购物车行视图。
97
+ * BookingTicket 面向 UI 的购物车商品行视图。
98
98
  *
99
- * tempOrder.products 仍保持 Sales checkout 协议结构;展示字段在 Solution 层合并后输出,
100
- * 避免 UI 直接读取 booking/detail/catalog 等原始来源。
99
+ * 直接透传 tempOrder.products 协议行,不做 Solution enrichment。
101
100
  */
102
- export interface BookingTicketCartItemView extends BaseSalesOrderProduct {
103
- /** UI 运行态扩展,不进入 tempOrder 提交协议。 */
101
+ export type BookingTicketCartItemView = BaseSalesOrderProduct;
102
+ /**
103
+ * BookingTicket 面向 UI 的 booking 行视图(平铺,附带关联商品)。
104
+ */
105
+ export interface BookingTicketCartBookingView extends ISalesBooking {
104
106
  _extend: {
105
- booking: ISalesBooking | null;
107
+ product: BookingTicketCartItemView | null;
106
108
  };
107
109
  }
108
110
  /**
109
111
  * BookingTicket 面向 UI 的购物车视图。
110
112
  */
111
113
  export interface BookingTicketCartView {
114
+ bookings: BookingTicketCartBookingView[];
112
115
  items: BookingTicketCartItemView[];
113
116
  }
114
117
  /**
@@ -55,10 +55,13 @@ export var BookingTicketHooks = /*#__PURE__*/function (BookingTicketHooks) {
55
55
  */
56
56
 
57
57
  /**
58
- * BookingTicket 面向 UI 的购物车行视图。
58
+ * BookingTicket 面向 UI 的购物车商品行视图。
59
59
  *
60
- * tempOrder.products 仍保持 Sales checkout 协议结构;展示字段在 Solution 层合并后输出,
61
- * 避免 UI 直接读取 booking/detail/catalog 等原始来源。
60
+ * 直接透传 tempOrder.products 协议行,不做 Solution enrichment。
61
+ */
62
+
63
+ /**
64
+ * BookingTicket 面向 UI 的 booking 行视图(平铺,附带关联商品)。
62
65
  */
63
66
 
64
67
  /**
@@ -1,24 +1,19 @@
1
1
  import type { BaseSalesOrderProduct } from '../../BaseSales';
2
2
  import type { ISalesBooking } from '../../BaseSales/utils/parseSalesResponse';
3
- import type { ProductData } from '../../../modules/Product/types';
4
- import type { BookingTicketCartItemView, BookingTicketCustomerView, ICustomer } from '../types';
3
+ import type { BookingTicketCartView, BookingTicketCustomerView, ICustomer } from '../types';
5
4
  import type { ScanOrderTempOrder } from '../../ScanOrder/types';
6
5
  /**
7
6
  * 仅按 booking.product_uid 建索引,避免发明 booking 与商品行之间的其它等价关系。
8
7
  */
9
8
  export declare function indexBookingsByProductUid(bookings: ISalesBooking[] | undefined | null): Record<string, ISalesBooking[]>;
10
9
  /**
11
- * 合并购物车行展示字段。协议字段仍来自 tempOrder.products,
12
- * 展示字段按 booking detail/product 优先,商品池 catalog 兜底。
10
+ * 构建购物车 UI 视图:bookings 平铺附带关联商品;items 仅含未关联 booking 的商品行。
11
+ *
12
+ * 商品行直接透传 tempOrder.products,不做 enrichment。
13
+ * 关联规则(1:1):booking.product_uid ↔ line.metadata.unique_identification_number;
14
+ * 同一 uid 已被更早的 booking 占用时,后续 booking 的 product 为 null。
13
15
  */
14
- export declare function buildCartItemView(line: BaseSalesOrderProduct, ctx: {
15
- bookingDetailMap?: Record<string, ISalesBooking[]>;
16
- productsCatalog: ProductData[];
17
- }): BookingTicketCartItemView;
18
- export declare function buildCartItemViews(lines: BaseSalesOrderProduct[] | undefined | null, ctx: {
19
- bookingDetailMap?: Record<string, ISalesBooking[]>;
20
- productsCatalog: ProductData[];
21
- }): BookingTicketCartItemView[];
16
+ export declare function buildCartView(lines: BaseSalesOrderProduct[] | undefined | null, bookings: ISalesBooking[] | undefined | null): BookingTicketCartView;
22
17
  export declare function isWalkInCustomer(customer: Pick<ICustomer, 'id'> | null | undefined): boolean;
23
18
  /**
24
19
  * selected 优先,缺失时回退 tempOrder.customer_*,统一输出 UI 客户视图。
@@ -20,24 +20,62 @@ export function indexBookingsByProductUid(bookings) {
20
20
  }
21
21
 
22
22
  /**
23
- * 合并购物车行展示字段。协议字段仍来自 tempOrder.products,
24
- * 展示字段按 booking detail/product 优先,商品池 catalog 兜底。
23
+ * 商品行按 unique_identification_number 建 1:1 索引(同 uid 多行时保留首行)。
25
24
  */
26
- export function buildCartItemView(line, ctx) {
27
- var _line$metadata, _ctx$bookingDetailMap;
28
- var productUid = (_line$metadata = line.metadata) === null || _line$metadata === void 0 ? void 0 : _line$metadata.unique_identification_number;
29
- var matched = productUid ? (_ctx$bookingDetailMap = ctx.bookingDetailMap) === null || _ctx$bookingDetailMap === void 0 || (_ctx$bookingDetailMap = _ctx$bookingDetailMap[String(productUid)]) === null || _ctx$bookingDetailMap === void 0 ? void 0 : _ctx$bookingDetailMap[0] : undefined;
30
- return _objectSpread(_objectSpread({}, line), {}, {
31
- _extend: {
32
- booking: matched !== null && matched !== void 0 ? matched : null
25
+ function indexProductsByUid(lines) {
26
+ return lines.reduce(function (acc, line) {
27
+ var _line$metadata;
28
+ var uid = (_line$metadata = line.metadata) === null || _line$metadata === void 0 ? void 0 : _line$metadata.unique_identification_number;
29
+ if (uid === undefined || uid === null || uid === '') return acc;
30
+ var key = String(uid);
31
+ if (!acc[key]) acc[key] = line;
32
+ return acc;
33
+ }, {});
34
+ }
35
+
36
+ /**
37
+ * 构建购物车 UI 视图:bookings 平铺附带关联商品;items 仅含未关联 booking 的商品行。
38
+ *
39
+ * 商品行直接透传 tempOrder.products,不做 enrichment。
40
+ * 关联规则(1:1):booking.product_uid ↔ line.metadata.unique_identification_number;
41
+ * 同一 uid 已被更早的 booking 占用时,后续 booking 的 product 为 null。
42
+ */
43
+ export function buildCartView(lines, bookings) {
44
+ var productLines = Array.isArray(lines) ? lines : [];
45
+ var bookingList = Array.isArray(bookings) ? bookings : [];
46
+ var linesByUid = indexProductsByUid(productLines);
47
+ var claimedUids = new Set();
48
+ var cartBookings = bookingList.filter(function (booking) {
49
+ return booking.parent_id !== 0;
50
+ }).map(function (booking) {
51
+ var uid = booking === null || booking === void 0 ? void 0 : booking.product_uid;
52
+ var product = null;
53
+ if (uid !== undefined && uid !== null && uid !== '') {
54
+ var key = String(uid);
55
+ if (!claimedUids.has(key)) {
56
+ var line = linesByUid[key];
57
+ if (line) {
58
+ claimedUids.add(key);
59
+ product = line;
60
+ }
61
+ }
33
62
  }
63
+ return _objectSpread(_objectSpread({}, booking), {}, {
64
+ _extend: {
65
+ product: product
66
+ }
67
+ });
34
68
  });
35
- }
36
- export function buildCartItemViews(lines, ctx) {
37
- if (!Array.isArray(lines) || lines.length === 0) return [];
38
- return lines.map(function (line) {
39
- return buildCartItemView(line, ctx);
69
+ var items = productLines.filter(function (line) {
70
+ var _line$metadata2;
71
+ var uid = (_line$metadata2 = line.metadata) === null || _line$metadata2 === void 0 ? void 0 : _line$metadata2.unique_identification_number;
72
+ if (uid === undefined || uid === null || uid === '') return true;
73
+ return !claimedUids.has(String(uid));
40
74
  });
75
+ return {
76
+ bookings: cartBookings,
77
+ items: items
78
+ };
41
79
  }
42
80
  export function isWalkInCustomer(customer) {
43
81
  if (!customer) return true;
@@ -0,0 +1,4 @@
1
+ import type { ICustomer } from '../types';
2
+ import type { OrderCustomerPatch } from '../../../modules/Order/types';
3
+ /** 将 ICustomer 格式化为写入 tempOrder 的协议字段。 */
4
+ export declare function formatOrderCustomerPatch(customer: ICustomer): OrderCustomerPatch;