@pisell/private-materials 6.3.139 → 6.3.140
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.
- package/build/lowcode/assets-daily.json +11 -11
- package/build/lowcode/assets-dev.json +2 -2
- package/build/lowcode/assets-prod.json +11 -11
- package/build/lowcode/index.js +1 -1
- package/build/lowcode/meta.js +1 -1
- package/build/lowcode/preview.js +5 -5
- package/build/lowcode/render/default/view.css +1 -1
- package/build/lowcode/render/default/view.js +7 -7
- package/build/lowcode/view.css +1 -1
- package/build/lowcode/view.js +6 -6
- package/es/components/scanOrder/components/Cart/index.js +127 -56
- package/es/components/scanOrder/components/Cart/index.less +11 -5
- package/es/components/scanOrder/components/Check/index.js +85 -80
- package/es/components/scanOrder/components/Content/index.js +345 -162
- package/es/components/scanOrder/components/Menu/index.d.ts +11 -0
- package/es/components/scanOrder/components/Menu/index.js +140 -169
- package/es/components/scanOrder/components/Voucher/index.d.ts +8 -0
- package/es/components/scanOrder/components/Voucher/index.js +250 -0
- package/es/components/scanOrder/context.js +38 -13
- package/es/components/scanOrder/hooks.js +4 -1
- package/es/components/scanOrder/locales.d.ts +65 -0
- package/es/components/scanOrder/locales.js +65 -0
- package/es/components/scanOrder/types.d.ts +10 -0
- package/es/components/scanOrder/utils/toShoppingCartProducts.d.ts +1 -0
- package/es/components/scanOrder/utils/toShoppingCartProducts.js +137 -9
- package/es/components/scanOrder/utils/transformProductDetail.js +21 -4
- package/es/components/venueBooking/components/Addons/index.js +42 -33
- package/es/components/venueBooking/components/Cart/index.js +26 -14
- package/lib/components/scanOrder/components/Cart/index.js +79 -24
- package/lib/components/scanOrder/components/Cart/index.less +11 -5
- package/lib/components/scanOrder/components/Check/index.js +28 -23
- package/lib/components/scanOrder/components/Content/index.js +132 -42
- package/lib/components/scanOrder/components/Menu/index.d.ts +11 -0
- package/lib/components/scanOrder/components/Menu/index.js +23 -36
- package/lib/components/scanOrder/components/Voucher/index.d.ts +8 -0
- package/lib/components/scanOrder/components/Voucher/index.js +162 -0
- package/lib/components/scanOrder/context.js +21 -10
- package/lib/components/scanOrder/hooks.js +4 -1
- package/lib/components/scanOrder/locales.d.ts +65 -0
- package/lib/components/scanOrder/locales.js +65 -0
- package/lib/components/scanOrder/types.d.ts +10 -0
- package/lib/components/scanOrder/utils/toShoppingCartProducts.d.ts +1 -0
- package/lib/components/scanOrder/utils/toShoppingCartProducts.js +88 -6
- package/lib/components/scanOrder/utils/transformProductDetail.js +10 -3
- package/lib/components/venueBooking/components/Addons/index.js +15 -8
- package/lib/components/venueBooking/components/Cart/index.js +8 -2
- package/package.json +1 -1
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
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; }
|
|
2
|
+
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; }
|
|
3
|
+
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; }
|
|
4
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
5
|
+
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); }
|
|
6
|
+
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); }
|
|
7
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
8
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
9
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
1
10
|
function toNumber(value) {
|
|
2
11
|
var fallback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
3
12
|
var parsedValue = Number(value);
|
|
@@ -52,13 +61,117 @@ function normalizeOptions(product) {
|
|
|
52
61
|
};
|
|
53
62
|
});
|
|
54
63
|
}
|
|
64
|
+
|
|
65
|
+
/** 与 getDisplayName 一致:优先 metadata 上的完整商品快照 */
|
|
66
|
+
function getProductOriginRich(product) {
|
|
67
|
+
var _product$metadata2, _product$_origin4;
|
|
68
|
+
return (product === null || product === void 0 || (_product$metadata2 = product.metadata) === null || _product$metadata2 === void 0 ? void 0 : _product$metadata2.origin) || (product === null || product === void 0 || (_product$_origin4 = product._origin) === null || _product$_origin4 === void 0 || (_product$_origin4 = _product$_origin4.callbackData) === null || _product$_origin4 === void 0 ? void 0 : _product$_origin4.origin) || {};
|
|
69
|
+
}
|
|
70
|
+
function findVariantGroupById(groups, groupId) {
|
|
71
|
+
return groups.find(function (g) {
|
|
72
|
+
return Number(g === null || g === void 0 ? void 0 : g.id) === Number(groupId);
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
function findVariantItemDisplayName(variantGroup, variantItemId) {
|
|
76
|
+
var _ref, _found$name;
|
|
77
|
+
var items = Array.isArray(variantGroup === null || variantGroup === void 0 ? void 0 : variantGroup.variant_item) ? variantGroup.variant_item : [];
|
|
78
|
+
var found = items.find(function (it) {
|
|
79
|
+
return Number(it === null || it === void 0 ? void 0 : it.id) === Number(variantItemId);
|
|
80
|
+
});
|
|
81
|
+
var raw = (_ref = (_found$name = found === null || found === void 0 ? void 0 : found.name) !== null && _found$name !== void 0 ? _found$name : typeof (found === null || found === void 0 ? void 0 : found.title) === 'string' ? found.title : found === null || found === void 0 ? void 0 : found.title) !== null && _ref !== void 0 ? _ref : '';
|
|
82
|
+
return String(raw !== null && raw !== void 0 ? raw : '').trim();
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* 按 sku_ids(如 "7006:19533" 或 "g1:i1_g2:i2")与 variant_group 拼「组名: 选项名」,与选品器 transformSelectorValueToValue 风格一致(", " 连接)。
|
|
87
|
+
*/
|
|
88
|
+
function buildVariantStringFromSkuIds(origin, skuIdsRaw) {
|
|
89
|
+
var groups = Array.isArray(origin === null || origin === void 0 ? void 0 : origin.variant_group) ? origin.variant_group : [];
|
|
90
|
+
var parts = [];
|
|
91
|
+
var segments = String(skuIdsRaw || '').split('_').map(function (s) {
|
|
92
|
+
return s.trim();
|
|
93
|
+
}).filter(Boolean);
|
|
94
|
+
var _iterator = _createForOfIteratorHelper(segments),
|
|
95
|
+
_step;
|
|
96
|
+
try {
|
|
97
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
98
|
+
var _vg$name;
|
|
99
|
+
var seg = _step.value;
|
|
100
|
+
var colonIdx = seg.indexOf(':');
|
|
101
|
+
if (colonIdx <= 0) continue;
|
|
102
|
+
var groupId = Number(seg.slice(0, colonIdx));
|
|
103
|
+
var itemId = Number(seg.slice(colonIdx + 1));
|
|
104
|
+
if (Number.isNaN(groupId) || Number.isNaN(itemId)) continue;
|
|
105
|
+
var vg = findVariantGroupById(groups, groupId);
|
|
106
|
+
if (!vg) continue;
|
|
107
|
+
var groupName = String((_vg$name = vg === null || vg === void 0 ? void 0 : vg.name) !== null && _vg$name !== void 0 ? _vg$name : '').trim();
|
|
108
|
+
var itemName = findVariantItemDisplayName(vg, itemId);
|
|
109
|
+
if (groupName && itemName) parts.push("".concat(groupName, ": ").concat(itemName));else if (itemName) parts.push(itemName);else if (groupName) parts.push(groupName);
|
|
110
|
+
}
|
|
111
|
+
} catch (err) {
|
|
112
|
+
_iterator.e(err);
|
|
113
|
+
} finally {
|
|
114
|
+
_iterator.f();
|
|
115
|
+
}
|
|
116
|
+
return parts.join(', ');
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** sku_ids 解析失败时用 variant 的 name/title 与 variant_group.position_id 对齐 */
|
|
120
|
+
function fallbackVariantLabelFromTitles(origin, variantRow) {
|
|
121
|
+
var groups = Array.isArray(origin === null || origin === void 0 ? void 0 : origin.variant_group) ? origin.variant_group : [];
|
|
122
|
+
var nameObj = (variantRow === null || variantRow === void 0 ? void 0 : variantRow.name) || (variantRow === null || variantRow === void 0 ? void 0 : variantRow.title);
|
|
123
|
+
if (!nameObj || _typeof(nameObj) !== 'object') return '';
|
|
124
|
+
var parts = [];
|
|
125
|
+
var _iterator2 = _createForOfIteratorHelper(groups),
|
|
126
|
+
_step2;
|
|
127
|
+
try {
|
|
128
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
129
|
+
var _String, _g$name;
|
|
130
|
+
var g = _step2.value;
|
|
131
|
+
var pid = g === null || g === void 0 ? void 0 : g.position_id;
|
|
132
|
+
if (pid == null) continue;
|
|
133
|
+
var val = (_String = nameObj[String(pid)]) !== null && _String !== void 0 ? _String : nameObj[pid];
|
|
134
|
+
if (val == null || val === '') continue;
|
|
135
|
+
var groupName = String((_g$name = g === null || g === void 0 ? void 0 : g.name) !== null && _g$name !== void 0 ? _g$name : '').trim();
|
|
136
|
+
var itemLabel = String(val).trim();
|
|
137
|
+
if (groupName && itemLabel) parts.push("".concat(groupName, ": ").concat(itemLabel));else if (itemLabel) parts.push(itemLabel);
|
|
138
|
+
}
|
|
139
|
+
} catch (err) {
|
|
140
|
+
_iterator2.e(err);
|
|
141
|
+
} finally {
|
|
142
|
+
_iterator2.f();
|
|
143
|
+
}
|
|
144
|
+
if (parts.length) return parts.join(', ');
|
|
145
|
+
var vals = Object.values(nameObj).filter(function (v) {
|
|
146
|
+
return v != null && String(v).trim() !== '';
|
|
147
|
+
});
|
|
148
|
+
return vals.map(function (v) {
|
|
149
|
+
return String(v).trim();
|
|
150
|
+
}).join(' / ');
|
|
151
|
+
}
|
|
152
|
+
function getVariantProductOptionString(product) {
|
|
153
|
+
var variantId = product === null || product === void 0 ? void 0 : product.product_variant_id;
|
|
154
|
+
if (variantId == null || variantId === '' || Number(variantId) <= 0) return '';
|
|
155
|
+
var origin = getProductOriginRich(product);
|
|
156
|
+
var variants = Array.isArray(origin === null || origin === void 0 ? void 0 : origin.variant) ? origin.variant : [];
|
|
157
|
+
var matched = variants.find(function (v) {
|
|
158
|
+
return Number(v === null || v === void 0 ? void 0 : v.id) === Number(variantId);
|
|
159
|
+
});
|
|
160
|
+
if (!matched) return '';
|
|
161
|
+
var skuIds = matched === null || matched === void 0 ? void 0 : matched.sku_ids;
|
|
162
|
+
if (skuIds != null && String(skuIds).trim() !== '') {
|
|
163
|
+
var fromSku = buildVariantStringFromSkuIds(origin, String(skuIds));
|
|
164
|
+
if (fromSku) return fromSku;
|
|
165
|
+
}
|
|
166
|
+
return fallbackVariantLabelFromTitles(origin, matched);
|
|
167
|
+
}
|
|
55
168
|
function normalizeBundles(product) {
|
|
56
|
-
var _product$
|
|
57
|
-
var callbackData = (product === null || product === void 0 || (_product$
|
|
169
|
+
var _product$_origin5;
|
|
170
|
+
var callbackData = (product === null || product === void 0 || (_product$_origin5 = product._origin) === null || _product$_origin5 === void 0 ? void 0 : _product$_origin5.callbackData) || {};
|
|
58
171
|
var sourceBundles = Array.isArray(callbackData === null || callbackData === void 0 ? void 0 : callbackData.bundle) ? callbackData.bundle : (product === null || product === void 0 ? void 0 : product.product_bundle) || [];
|
|
59
172
|
return sourceBundles.map(function (bundleItem, bundleIndex) {
|
|
60
|
-
var
|
|
61
|
-
var bundlePrice = toNumber((
|
|
173
|
+
var _ref2, _bundleItem$price, _bundleItem$id;
|
|
174
|
+
var bundlePrice = toNumber((_ref2 = (_bundleItem$price = bundleItem === null || bundleItem === void 0 ? void 0 : bundleItem.price) !== null && _bundleItem$price !== void 0 ? _bundleItem$price : bundleItem === null || bundleItem === void 0 ? void 0 : bundleItem.product_price) !== null && _ref2 !== void 0 ? _ref2 : bundleItem === null || bundleItem === void 0 ? void 0 : bundleItem.custom_price, 0);
|
|
62
175
|
var bundleNum = toSafeNum(bundleItem === null || bundleItem === void 0 ? void 0 : bundleItem.num);
|
|
63
176
|
var bundleOptions = Array.isArray(bundleItem === null || bundleItem === void 0 ? void 0 : bundleItem.option) ? bundleItem.option : [];
|
|
64
177
|
return {
|
|
@@ -90,17 +203,24 @@ export function toShoppingCartProducts(params) {
|
|
|
90
203
|
amountSymbol = _params$amountSymbol === void 0 ? '$' : _params$amountSymbol;
|
|
91
204
|
if (!Array.isArray(orderProducts)) return [];
|
|
92
205
|
return orderProducts.map(function (productItem, index) {
|
|
93
|
-
var _productItem$_origin, _productItem$
|
|
206
|
+
var _productItem$_origin, _productItem$product_, _productItem$metadata;
|
|
94
207
|
var productNum = toSafeNum(productItem === null || productItem === void 0 ? void 0 : productItem.num);
|
|
95
208
|
var unitPrice = getUnitPrice(productItem);
|
|
96
|
-
var
|
|
97
|
-
|
|
209
|
+
var callbackData = (productItem === null || productItem === void 0 || (_productItem$_origin = productItem._origin) === null || _productItem$_origin === void 0 ? void 0 : _productItem$_origin.callbackData) || {};
|
|
210
|
+
// 不透明 identity 契约:rowKey / _id 直接复用 SDK 回灌的 identity_key;
|
|
211
|
+
// 仅当(升级路径或非常规调用)identity_key 缺失时退到 SKU + index 兜底。
|
|
212
|
+
var identityKey = typeof (productItem === null || productItem === void 0 ? void 0 : productItem.identity_key) === 'string' && productItem.identity_key.length > 0 ? productItem.identity_key : undefined;
|
|
213
|
+
var rowKey = identityKey !== null && identityKey !== void 0 ? identityKey : "".concat((_productItem$product_ = productItem.product_id) !== null && _productItem$product_ !== void 0 ? _productItem$product_ : 'p', "_").concat(productItem.product_variant_id, "_").concat(index);
|
|
214
|
+
var fromCallbackOptionString = typeof (callbackData === null || callbackData === void 0 ? void 0 : callbackData.product_option_string) === 'string' ? callbackData.product_option_string.trim() : '';
|
|
215
|
+
var productOptionString = fromCallbackOptionString || getVariantProductOptionString(productItem) || undefined;
|
|
216
|
+
var base = _objectSpread({
|
|
98
217
|
_id: rowKey,
|
|
99
218
|
rowKey: rowKey,
|
|
100
|
-
identity_key:
|
|
219
|
+
identity_key: identityKey,
|
|
101
220
|
id: productItem.product_id,
|
|
102
221
|
product_id: productItem.product_id,
|
|
103
222
|
product_variant_id: productItem.product_variant_id,
|
|
223
|
+
note: (productItem === null || productItem === void 0 ? void 0 : productItem.note) != null ? String(productItem.note) : '',
|
|
104
224
|
name: getDisplayName(productItem),
|
|
105
225
|
image: getDisplayImage(productItem),
|
|
106
226
|
num: productNum,
|
|
@@ -112,7 +232,15 @@ export function toShoppingCartProducts(params) {
|
|
|
112
232
|
bundle: normalizeBundles(productItem),
|
|
113
233
|
_origin: productItem === null || productItem === void 0 ? void 0 : productItem._origin,
|
|
114
234
|
isNormalProduct: true
|
|
115
|
-
}
|
|
235
|
+
}, productOptionString ? {
|
|
236
|
+
product_option_string: productOptionString
|
|
237
|
+
} : {});
|
|
238
|
+
if (Array.isArray(productItem.product_option_item) && productItem.product_option_item.length) {
|
|
239
|
+
base.product_option_item = productItem.product_option_item;
|
|
240
|
+
}
|
|
241
|
+
if (Array.isArray(productItem.product_bundle) && productItem.product_bundle.length) {
|
|
242
|
+
base.product_bundle = productItem.product_bundle;
|
|
243
|
+
}
|
|
116
244
|
if (productItem !== null && productItem !== void 0 && (_productItem$metadata = productItem.metadata) !== null && _productItem$metadata !== void 0 && _productItem$metadata.venue_booking) {
|
|
117
245
|
var _origin$resources2;
|
|
118
246
|
var origin = productItem._origin || {};
|
|
@@ -49,8 +49,21 @@ function normalizeBundleItems(bundleItems) {
|
|
|
49
49
|
});
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* 在商品 origin 数据中按 variant_id 命中对应的规格行,用于取「规格级」字段(price / base_price / is_charge_tax 等)。
|
|
55
|
+
* 主商品字段仅作为无规格或无法命中时的兜底,避免把主商品价误当成规格价写入订单行。
|
|
56
|
+
*/
|
|
57
|
+
function findVariantById(origin, variantId) {
|
|
58
|
+
if (!origin || !variantId || variantId <= 0) return null;
|
|
59
|
+
var variants = Array.isArray(origin === null || origin === void 0 ? void 0 : origin.variant) ? origin.variant : [];
|
|
60
|
+
var matched = variants.find(function (v) {
|
|
61
|
+
return Number(v === null || v === void 0 ? void 0 : v.id) === variantId;
|
|
62
|
+
});
|
|
63
|
+
return matched || null;
|
|
64
|
+
}
|
|
52
65
|
export function transformProductDetailToOrderProduct(params) {
|
|
53
|
-
var _ref, _ref2, _payload$product_id, _ref3, _payload$product_vari, _payload$_origin, _ref4, _ref5, _ref6, _ref7, _payload$price,
|
|
66
|
+
var _ref, _ref2, _payload$product_id, _ref3, _payload$product_vari, _payload$_origin, _findVariantById, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9, _payload$price, _ref10, _ref11, _payload$tax_fee, _ref12, _ref13, _payload$is_charge_ta, _payload$quantity, _payload$option, _payload$bundle;
|
|
54
67
|
var payload = params.payload,
|
|
55
68
|
_params$fallbackProdu = params.fallbackProductId,
|
|
56
69
|
fallbackProductId = _params$fallbackProdu === void 0 ? null : _params$fallbackProdu,
|
|
@@ -61,13 +74,17 @@ export function transformProductDetailToOrderProduct(params) {
|
|
|
61
74
|
if (productId === null) return null;
|
|
62
75
|
var productVariantId = toNumber((_ref3 = (_payload$product_vari = payload.product_variant_id) !== null && _payload$product_vari !== void 0 ? _payload$product_vari : payload.variant_id) !== null && _ref3 !== void 0 ? _ref3 : sourceItem === null || sourceItem === void 0 ? void 0 : sourceItem.product_variant_id, 0);
|
|
63
76
|
var callbackOrigin = (payload === null || payload === void 0 ? void 0 : payload.origin) || (payload === null || payload === void 0 || (_payload$_origin = payload._origin) === null || _payload$_origin === void 0 ? void 0 : _payload$_origin.sourceItem) || (payload === null || payload === void 0 ? void 0 : payload._origin) || {};
|
|
64
|
-
|
|
77
|
+
// 规格商品的价格、税率等字段必须以 variant 行为准;主商品上的 price 只是「起售价/默认价」。
|
|
78
|
+
// productDetail 弹窗回调 payload 里通常不会带 price,如果不做 variant 查找,
|
|
79
|
+
// 就会退到 callbackOrigin.price(主商品价),导致加购价格错位。
|
|
80
|
+
var matchedVariant = (_findVariantById = findVariantById(callbackOrigin, productVariantId)) !== null && _findVariantById !== void 0 ? _findVariantById : findVariantById(sourceItem, productVariantId);
|
|
81
|
+
var sellingPrice = toPriceString((_ref4 = (_ref5 = (_ref6 = (_ref7 = (_ref8 = (_ref9 = (_payload$price = payload === null || payload === void 0 ? void 0 : payload.price) !== null && _payload$price !== void 0 ? _payload$price : payload === null || payload === void 0 ? void 0 : payload.selling_price) !== null && _ref9 !== void 0 ? _ref9 : matchedVariant === null || matchedVariant === void 0 ? void 0 : matchedVariant.price) !== null && _ref8 !== void 0 ? _ref8 : matchedVariant === null || matchedVariant === void 0 ? void 0 : matchedVariant.base_price) !== null && _ref7 !== void 0 ? _ref7 : callbackOrigin === null || callbackOrigin === void 0 ? void 0 : callbackOrigin.price) !== null && _ref6 !== void 0 ? _ref6 : sourceItem === null || sourceItem === void 0 ? void 0 : sourceItem.price) !== null && _ref5 !== void 0 ? _ref5 : sourceItem === null || sourceItem === void 0 ? void 0 : sourceItem.selling_price) !== null && _ref4 !== void 0 ? _ref4 : sourceItem === null || sourceItem === void 0 ? void 0 : sourceItem.base_price, '0.00');
|
|
65
82
|
// 入口不引入后台划线价(payload/source.original_price 可能承载 UI 划线展示用的原价)。
|
|
66
83
|
// 订单域 original_price 语义为「券前店铺售价」,初次加购恒等于 selling_price;
|
|
67
84
|
// 券应用后由 SDK Rules 引擎维护差异。
|
|
68
85
|
var originalPrice = sellingPrice;
|
|
69
|
-
var taxFee = toPriceString((
|
|
70
|
-
var isChargeTax = toNumber((
|
|
86
|
+
var taxFee = toPriceString((_ref10 = (_ref11 = (_payload$tax_fee = payload === null || payload === void 0 ? void 0 : payload.tax_fee) !== null && _payload$tax_fee !== void 0 ? _payload$tax_fee : matchedVariant === null || matchedVariant === void 0 ? void 0 : matchedVariant.tax_fee) !== null && _ref11 !== void 0 ? _ref11 : callbackOrigin === null || callbackOrigin === void 0 ? void 0 : callbackOrigin.tax_fee) !== null && _ref10 !== void 0 ? _ref10 : sourceItem === null || sourceItem === void 0 ? void 0 : sourceItem.tax_fee, '0.00');
|
|
87
|
+
var isChargeTax = toNumber((_ref12 = (_ref13 = (_payload$is_charge_ta = payload === null || payload === void 0 ? void 0 : 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 && _ref13 !== void 0 ? _ref13 : callbackOrigin === null || callbackOrigin === void 0 ? void 0 : callbackOrigin.is_charge_tax) !== null && _ref12 !== void 0 ? _ref12 : sourceItem === null || sourceItem === void 0 ? void 0 : sourceItem.is_charge_tax, 0);
|
|
71
88
|
return {
|
|
72
89
|
product_id: productId,
|
|
73
90
|
product_variant_id: productVariantId,
|
|
@@ -131,17 +131,19 @@ export default function Addons() {
|
|
|
131
131
|
// ── 从订单移除商品 ──
|
|
132
132
|
var removeOrderProduct = /*#__PURE__*/function () {
|
|
133
133
|
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
|
|
134
|
-
var product_id, product_variant_id, sourceData;
|
|
134
|
+
var product_id, product_variant_id, identity_key, sourceData;
|
|
135
135
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
136
136
|
while (1) switch (_context3.prev = _context3.next) {
|
|
137
137
|
case 0:
|
|
138
|
-
product_id = params.product_id, product_variant_id = params.product_variant_id, sourceData = params.sourceData;
|
|
138
|
+
product_id = params.product_id, product_variant_id = params.product_variant_id, identity_key = params.identity_key, sourceData = params.sourceData;
|
|
139
139
|
_context3.prev = 1;
|
|
140
140
|
_context3.next = 4;
|
|
141
|
-
return runModuleAction('removeProductFromOrder', {
|
|
141
|
+
return runModuleAction('removeProductFromOrder', _objectSpread({
|
|
142
142
|
product_id: product_id,
|
|
143
143
|
product_variant_id: product_variant_id
|
|
144
|
-
}
|
|
144
|
+
}, identity_key ? {
|
|
145
|
+
identity_key: identity_key
|
|
146
|
+
} : {}));
|
|
145
147
|
case 4:
|
|
146
148
|
_context3.next = 6;
|
|
147
149
|
return refreshViewModel();
|
|
@@ -155,7 +157,8 @@ export default function Addons() {
|
|
|
155
157
|
error: _context3.t0,
|
|
156
158
|
sourceData: sourceData,
|
|
157
159
|
product_id: product_id,
|
|
158
|
-
product_variant_id: product_variant_id
|
|
160
|
+
product_variant_id: product_variant_id,
|
|
161
|
+
identity_key: identity_key
|
|
159
162
|
});
|
|
160
163
|
case 11:
|
|
161
164
|
case "end":
|
|
@@ -171,18 +174,21 @@ export default function Addons() {
|
|
|
171
174
|
// ── 更新订单中商品数量 ──
|
|
172
175
|
var updateOrderProduct = /*#__PURE__*/function () {
|
|
173
176
|
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(params) {
|
|
174
|
-
var product_id, product_variant_id, updates, sourceData;
|
|
177
|
+
var product_id, product_variant_id, identity_key, updates, sourceData;
|
|
175
178
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
176
179
|
while (1) switch (_context4.prev = _context4.next) {
|
|
177
180
|
case 0:
|
|
178
|
-
product_id = params.product_id, product_variant_id = params.product_variant_id, updates = params.updates, sourceData = params.sourceData;
|
|
181
|
+
product_id = params.product_id, product_variant_id = params.product_variant_id, identity_key = params.identity_key, updates = params.updates, sourceData = params.sourceData;
|
|
179
182
|
_context4.prev = 1;
|
|
180
183
|
_context4.next = 4;
|
|
181
|
-
return runModuleAction('updateProductInOrder', {
|
|
184
|
+
return runModuleAction('updateProductInOrder', _objectSpread(_objectSpread({
|
|
182
185
|
product_id: product_id,
|
|
183
|
-
product_variant_id: product_variant_id
|
|
186
|
+
product_variant_id: product_variant_id
|
|
187
|
+
}, identity_key ? {
|
|
188
|
+
identity_key: identity_key
|
|
189
|
+
} : {}), {}, {
|
|
184
190
|
updates: updates
|
|
185
|
-
});
|
|
191
|
+
}));
|
|
186
192
|
case 4:
|
|
187
193
|
_context4.next = 6;
|
|
188
194
|
return refreshViewModel();
|
|
@@ -197,6 +203,7 @@ export default function Addons() {
|
|
|
197
203
|
sourceData: sourceData,
|
|
198
204
|
product_id: product_id,
|
|
199
205
|
product_variant_id: product_variant_id,
|
|
206
|
+
identity_key: identity_key,
|
|
200
207
|
updates: updates
|
|
201
208
|
});
|
|
202
209
|
case 11:
|
|
@@ -218,13 +225,13 @@ export default function Addons() {
|
|
|
218
225
|
*/
|
|
219
226
|
var handleSelectProduct = /*#__PURE__*/function () {
|
|
220
227
|
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(item, clickType, meta) {
|
|
221
|
-
var sourceItem, _item$option, _item$bundle, _item$price, _item$product_id, _ref7, _meta$quantity, _orderProduct$product, _orderProduct$product4, quantityData, orderProduct, nextQuantity, productVariantId, normalizedQuantity,
|
|
228
|
+
var sourceItem, _item$option, _item$bundle, _item$price, _item$product_id, _ref7, _meta$quantity, _orderProduct$product, _orderProduct$product4, quantityData, orderProduct, nextQuantity, productVariantId, normalizedQuantity, cartItems, existedCartItem, existedIdentityKey, _orderProduct$product3;
|
|
222
229
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
223
230
|
while (1) switch (_context6.prev = _context6.next) {
|
|
224
231
|
case 0:
|
|
225
232
|
sourceItem = (meta === null || meta === void 0 ? void 0 : meta.product) || item;
|
|
226
233
|
if (!((meta === null || meta === void 0 ? void 0 : meta.intent) === 'quantity')) {
|
|
227
|
-
_context6.next =
|
|
234
|
+
_context6.next = 28;
|
|
228
235
|
break;
|
|
229
236
|
}
|
|
230
237
|
// ── 数量变更模式 ──
|
|
@@ -259,54 +266,56 @@ export default function Addons() {
|
|
|
259
266
|
});
|
|
260
267
|
return _context6.abrupt("return");
|
|
261
268
|
case 12:
|
|
262
|
-
normalizedQuantity = Number.isNaN(nextQuantity) ? 0 : Math.max(0, Math.floor(nextQuantity)); //
|
|
269
|
+
normalizedQuantity = Number.isNaN(nextQuantity) ? 0 : Math.max(0, Math.floor(nextQuantity)); // 检查购物车中是否已存在该商品(优先取 SDK 回灌的 identity_key 做精确删改)
|
|
270
|
+
cartItems = Array.isArray(viewModel === null || viewModel === void 0 ? void 0 : viewModel.cartItems) ? viewModel.cartItems : [];
|
|
271
|
+
existedCartItem = cartItems.find(function (cartItem) {
|
|
272
|
+
var _cartItem$product_id, _orderProduct$product2, _cartItem$product_var;
|
|
273
|
+
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;
|
|
274
|
+
});
|
|
275
|
+
existedIdentityKey = typeof (existedCartItem === null || existedCartItem === void 0 ? void 0 : existedCartItem.identity_key) === 'string' && existedCartItem.identity_key.length > 0 ? existedCartItem.identity_key : undefined; // 数量为 0 → 移除商品
|
|
263
276
|
if (!(normalizedQuantity <= 0)) {
|
|
264
|
-
_context6.next =
|
|
277
|
+
_context6.next = 20;
|
|
265
278
|
break;
|
|
266
279
|
}
|
|
267
|
-
_context6.next =
|
|
280
|
+
_context6.next = 19;
|
|
268
281
|
return removeOrderProduct({
|
|
269
|
-
product_id: (_orderProduct$
|
|
282
|
+
product_id: (_orderProduct$product3 = orderProduct === null || orderProduct === void 0 ? void 0 : orderProduct.product_id) !== null && _orderProduct$product3 !== void 0 ? _orderProduct$product3 : null,
|
|
270
283
|
product_variant_id: productVariantId,
|
|
284
|
+
identity_key: existedIdentityKey,
|
|
271
285
|
sourceData: quantityData
|
|
272
286
|
});
|
|
273
|
-
case
|
|
287
|
+
case 19:
|
|
274
288
|
return _context6.abrupt("return");
|
|
275
|
-
case
|
|
276
|
-
// 检查购物车中是否已存在该商品
|
|
277
|
-
cartItems = Array.isArray(viewModel === null || viewModel === void 0 ? void 0 : viewModel.cartItems) ? viewModel.cartItems : [];
|
|
278
|
-
existedCartItem = cartItems.find(function (cartItem) {
|
|
279
|
-
var _cartItem$product_id, _orderProduct$product3, _cartItem$product_var;
|
|
280
|
-
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$product3 = orderProduct === null || orderProduct === void 0 ? void 0 : orderProduct.product_id) !== null && _orderProduct$product3 !== void 0 ? _orderProduct$product3 : 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;
|
|
281
|
-
}); // 不存在 → 新增;已存在 → 更新数量
|
|
289
|
+
case 20:
|
|
282
290
|
if (existedCartItem) {
|
|
283
|
-
_context6.next =
|
|
291
|
+
_context6.next = 24;
|
|
284
292
|
break;
|
|
285
293
|
}
|
|
286
|
-
_context6.next =
|
|
294
|
+
_context6.next = 23;
|
|
287
295
|
return addOrderProduct({
|
|
288
296
|
orderProduct: _objectSpread(_objectSpread({}, orderProduct), {}, {
|
|
289
297
|
num: normalizedQuantity
|
|
290
298
|
}),
|
|
291
299
|
sourceData: quantityData
|
|
292
300
|
});
|
|
293
|
-
case 22:
|
|
294
|
-
return _context6.abrupt("return");
|
|
295
301
|
case 23:
|
|
296
|
-
_context6.
|
|
302
|
+
return _context6.abrupt("return");
|
|
303
|
+
case 24:
|
|
304
|
+
_context6.next = 26;
|
|
297
305
|
return updateOrderProduct({
|
|
298
306
|
product_id: (_orderProduct$product4 = orderProduct === null || orderProduct === void 0 ? void 0 : orderProduct.product_id) !== null && _orderProduct$product4 !== void 0 ? _orderProduct$product4 : null,
|
|
299
307
|
product_variant_id: productVariantId,
|
|
308
|
+
identity_key: existedIdentityKey,
|
|
300
309
|
updates: {
|
|
301
310
|
num: normalizedQuantity,
|
|
302
311
|
_origin: orderProduct === null || orderProduct === void 0 ? void 0 : orderProduct._origin
|
|
303
312
|
},
|
|
304
313
|
sourceData: quantityData
|
|
305
314
|
});
|
|
306
|
-
case
|
|
307
|
-
_context6.next =
|
|
315
|
+
case 26:
|
|
316
|
+
_context6.next = 29;
|
|
308
317
|
break;
|
|
309
|
-
case
|
|
318
|
+
case 28:
|
|
310
319
|
// ── 打开商品详情弹窗 ──
|
|
311
320
|
utils === null || utils === void 0 || utils.action({
|
|
312
321
|
type: 'pisell1.productDetail',
|
|
@@ -362,7 +371,7 @@ export default function Addons() {
|
|
|
362
371
|
return callback;
|
|
363
372
|
}()
|
|
364
373
|
});
|
|
365
|
-
case
|
|
374
|
+
case 29:
|
|
366
375
|
case "end":
|
|
367
376
|
return _context6.stop();
|
|
368
377
|
}
|
|
@@ -147,7 +147,10 @@ export default function Cart(props) {
|
|
|
147
147
|
var isVenueBookingCartItem = function isVenueBookingCartItem(target) {
|
|
148
148
|
if (!target || _typeof(target) !== 'object') return false;
|
|
149
149
|
if (target !== null && target !== void 0 && target.start_date && target !== null && target !== void 0 && target.end_date) return true;
|
|
150
|
-
|
|
150
|
+
|
|
151
|
+
// 不透明 identity 契约下,venueBooking 行的 identity_key 形如 `venue:<resourceId>:<groupIndex>:<uuid>`,
|
|
152
|
+
// 仅依据 SDK 回灌的 identity_key 判断;不再回退 rowKey / _id。
|
|
153
|
+
var identity = String((target === null || target === void 0 ? void 0 : target.identity_key) || '');
|
|
151
154
|
if (identity.startsWith('venue:')) return true;
|
|
152
155
|
return false;
|
|
153
156
|
};
|
|
@@ -176,39 +179,48 @@ export default function Cart(props) {
|
|
|
176
179
|
return _context.abrupt("return");
|
|
177
180
|
case 6:
|
|
178
181
|
productId = (_ref6 = (_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 && _ref6 !== void 0 ? _ref6 : null;
|
|
179
|
-
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);
|
|
180
|
-
identityKey =
|
|
182
|
+
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); // 不透明 identity 契约:删除只信任 SDK 回灌的 identity_key,禁用 rowKey 回退。
|
|
183
|
+
identityKey = targetItem === null || targetItem === void 0 ? void 0 : targetItem.identity_key;
|
|
181
184
|
if (!(productId === null && Number.isNaN(productVariantId))) {
|
|
182
185
|
_context.next = 11;
|
|
183
186
|
break;
|
|
184
187
|
}
|
|
185
188
|
return _context.abrupt("return");
|
|
186
189
|
case 11:
|
|
187
|
-
|
|
188
|
-
|
|
190
|
+
if (!(typeof identityKey !== 'string' || identityKey.length === 0)) {
|
|
191
|
+
_context.next = 14;
|
|
192
|
+
break;
|
|
193
|
+
}
|
|
194
|
+
console.error('[venueBooking] removeProductFromOrder skipped: missing identity_key', {
|
|
195
|
+
item: targetItem
|
|
196
|
+
});
|
|
197
|
+
return _context.abrupt("return");
|
|
198
|
+
case 14:
|
|
199
|
+
_context.prev = 14;
|
|
200
|
+
_context.next = 17;
|
|
189
201
|
return runModuleAction('removeProductFromOrder', {
|
|
190
202
|
product_id: productId,
|
|
191
203
|
product_variant_id: Number.isNaN(productVariantId) ? 0 : productVariantId,
|
|
192
204
|
identity_key: identityKey
|
|
193
205
|
});
|
|
194
|
-
case
|
|
195
|
-
_context.next =
|
|
206
|
+
case 17:
|
|
207
|
+
_context.next = 19;
|
|
196
208
|
return refreshViewModel();
|
|
197
|
-
case
|
|
198
|
-
_context.next =
|
|
209
|
+
case 19:
|
|
210
|
+
_context.next = 24;
|
|
199
211
|
break;
|
|
200
|
-
case
|
|
201
|
-
_context.prev =
|
|
202
|
-
_context.t0 = _context["catch"](
|
|
212
|
+
case 21:
|
|
213
|
+
_context.prev = 21;
|
|
214
|
+
_context.t0 = _context["catch"](14);
|
|
203
215
|
console.error('[venueBooking] removeProductFromOrder failed', {
|
|
204
216
|
error: _context.t0,
|
|
205
217
|
item: targetItem
|
|
206
218
|
});
|
|
207
|
-
case
|
|
219
|
+
case 24:
|
|
208
220
|
case "end":
|
|
209
221
|
return _context.stop();
|
|
210
222
|
}
|
|
211
|
-
}, _callee, null, [[
|
|
223
|
+
}, _callee, null, [[14, 21]]);
|
|
212
224
|
}));
|
|
213
225
|
return function handleCartChange(_x, _x2, _x3) {
|
|
214
226
|
return _ref5.apply(this, arguments);
|