@pisell/pisellos 2.2.164 → 2.2.165
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/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +45 -15
- package/dist/modules/Order/index.d.ts +10 -3
- package/dist/modules/Order/index.js +272 -142
- package/dist/modules/Order/types.d.ts +14 -2
- package/dist/modules/Order/types.js +2 -0
- package/dist/modules/Order/utils.d.ts +10 -0
- package/dist/modules/Order/utils.js +67 -15
- package/dist/server/index.js +1 -0
- package/dist/solution/BaseSales/index.d.ts +9 -1
- package/dist/solution/BaseSales/index.js +369 -240
- package/dist/solution/BaseSales/types.d.ts +3 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +33 -14
- package/dist/solution/BaseSales/utils.js +36 -7
- package/dist/solution/BookingTicket/index.d.ts +3 -0
- package/dist/solution/BookingTicket/index.js +155 -86
- package/dist/solution/BookingTicket/utils/addProductDecision.js +19 -11
- package/dist/solution/ScanOrder/utils.js +36 -7
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +35 -9
- package/lib/modules/Order/index.d.ts +10 -3
- package/lib/modules/Order/index.js +104 -4
- package/lib/modules/Order/types.d.ts +14 -2
- package/lib/modules/Order/utils.d.ts +10 -0
- package/lib/modules/Order/utils.js +58 -9
- package/lib/server/index.js +1 -0
- package/lib/solution/BaseSales/index.d.ts +9 -1
- package/lib/solution/BaseSales/index.js +65 -3
- package/lib/solution/BaseSales/types.d.ts +3 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +31 -10
- package/lib/solution/BaseSales/utils.js +37 -5
- package/lib/solution/BookingTicket/index.d.ts +3 -0
- package/lib/solution/BookingTicket/index.js +48 -6
- package/lib/solution/BookingTicket/utils/addProductDecision.js +16 -8
- package/lib/solution/ScanOrder/utils.js +37 -5
- package/package.json +1 -1
|
@@ -212,7 +212,7 @@ export function buildRequiresDetailPayload(item, ctx) {
|
|
|
212
212
|
* 这里只补 `_extend.start_date / quantity / other` 等运行态字段;后续走 getProductExtend 才会补齐资源 / 时间。
|
|
213
213
|
*/
|
|
214
214
|
export function buildCacheItemFromCartDetail(item, ctx) {
|
|
215
|
-
var _item$id, _item$_extend$price, _item$_extend;
|
|
215
|
+
var _item$id, _ref, _ctx$quantity, _item$_extend$price, _item$_extend;
|
|
216
216
|
var cartDetailValue = item.cartDetailValue || {};
|
|
217
217
|
var other = JSON.parse(JSON.stringify(cartDetailValue || {}));
|
|
218
218
|
other.session = cartDetailValue.session;
|
|
@@ -220,7 +220,8 @@ export function buildCacheItemFromCartDetail(item, ctx) {
|
|
|
220
220
|
var resolvedId = (_item$id = item.id) !== null && _item$id !== void 0 ? _item$id : item.product_id;
|
|
221
221
|
var extend = applySessionTimesToExtend(item, {
|
|
222
222
|
start_date: (ctx === null || ctx === void 0 ? void 0 : ctx.date) || undefined,
|
|
223
|
-
|
|
223
|
+
/** 列表连点 / 防抖合并时以 ctx.quantity 为准,避免 cartDetailValue 默认 1 盖掉合并数量 */
|
|
224
|
+
quantity: (_ref = (_ctx$quantity = ctx === null || ctx === void 0 ? void 0 : ctx.quantity) !== null && _ctx$quantity !== void 0 ? _ctx$quantity : cartDetailValue === null || cartDetailValue === void 0 ? void 0 : cartDetailValue.quantity) !== null && _ref !== void 0 ? _ref : 1,
|
|
224
225
|
product_name: item.title,
|
|
225
226
|
other: other,
|
|
226
227
|
isNormalProduct: !isBookingProduct(item),
|
|
@@ -242,7 +243,7 @@ export function buildCacheItemFromCartDetail(item, ctx) {
|
|
|
242
243
|
* 与 info2 `addService.tsx#handleSelectProduct.callback` 内的拼装等价(剥 pricing)。
|
|
243
244
|
*/
|
|
244
245
|
export function buildCacheItemFromDetail(item, detailResult, ctx) {
|
|
245
|
-
var _detailResult$e, _currentItem$id, _detail$extension_typ, _detailResult$e2, _detailResult$e3;
|
|
246
|
+
var _detailResult$e, _currentItem$id, _detail$extension_typ, _ref2, _ctx$quantity2, _detailResult$e2, _detailResult$e3;
|
|
246
247
|
var _currentItem = detailResult.detail || item;
|
|
247
248
|
var _detail = _currentItem;
|
|
248
249
|
var other = JSON.parse(JSON.stringify(detailResult.e || {}));
|
|
@@ -253,7 +254,7 @@ export function buildCacheItemFromDetail(item, detailResult, ctx) {
|
|
|
253
254
|
});
|
|
254
255
|
var extend = applySessionTimesToExtend(mergedItem, {
|
|
255
256
|
start_date: (ctx === null || ctx === void 0 ? void 0 : ctx.date) || undefined,
|
|
256
|
-
quantity: ((
|
|
257
|
+
quantity: (_ref2 = (_ctx$quantity2 = ctx === null || ctx === void 0 ? void 0 : ctx.quantity) !== null && _ctx$quantity2 !== void 0 ? _ctx$quantity2 : (_detailResult$e2 = detailResult.e) === null || _detailResult$e2 === void 0 ? void 0 : _detailResult$e2.quantity) !== null && _ref2 !== void 0 ? _ref2 : 1,
|
|
257
258
|
price: _detail === null || _detail === void 0 ? void 0 : _detail.price,
|
|
258
259
|
product_name: _currentItem.title,
|
|
259
260
|
other: other,
|
|
@@ -306,21 +307,28 @@ export function transformDetailToProductAndBooking(cacheItem, ctx) {
|
|
|
306
307
|
* 把 cacheItem._extend.other 中的字段 + 顶层运行态拼成 `BaseProductDetailPayload`。
|
|
307
308
|
*/
|
|
308
309
|
function buildBasePayloadFromCacheItem(cacheItem, ctx) {
|
|
309
|
-
var _cacheItem$_extend,
|
|
310
|
+
var _cacheItem$_extend, _cacheItem$_extend$qu, _cacheItem$_extend2, _cacheItem$product_id, _cacheItem$id, _ref3, _other$product_varian, _extend$skuValue, _extend$_skuValue, _extend$price, _extend$price2;
|
|
310
311
|
var other = (cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend = cacheItem._extend) === null || _cacheItem$_extend === void 0 ? void 0 : _cacheItem$_extend.other) || {};
|
|
311
|
-
var quantity = (
|
|
312
|
+
var quantity = (ctx === null || ctx === void 0 ? void 0 : ctx.quantity) != null && ctx.quantity > 0 ? ctx.quantity : (_cacheItem$_extend$qu = cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend2 = cacheItem._extend) === null || _cacheItem$_extend2 === void 0 ? void 0 : _cacheItem$_extend2.quantity) !== null && _cacheItem$_extend$qu !== void 0 ? _cacheItem$_extend$qu : 1;
|
|
312
313
|
var resolvedPid = (_cacheItem$product_id = cacheItem === null || cacheItem === void 0 ? void 0 : cacheItem.product_id) !== null && _cacheItem$product_id !== void 0 ? _cacheItem$product_id : cacheItem === null || cacheItem === void 0 ? void 0 : cacheItem.id;
|
|
314
|
+
var extend = (cacheItem === null || cacheItem === void 0 ? void 0 : cacheItem._extend) || {};
|
|
313
315
|
return {
|
|
314
316
|
id: (_cacheItem$id = cacheItem === null || cacheItem === void 0 ? void 0 : cacheItem.id) !== null && _cacheItem$id !== void 0 ? _cacheItem$id : cacheItem === null || cacheItem === void 0 ? void 0 : cacheItem.product_id,
|
|
315
317
|
product_id: resolvedPid,
|
|
316
|
-
variant_id: (
|
|
318
|
+
variant_id: (_ref3 = (_other$product_varian = other === null || other === void 0 ? void 0 : other.product_variant_id) !== null && _other$product_varian !== void 0 ? _other$product_varian : other === null || other === void 0 ? void 0 : other.variant_id) !== null && _ref3 !== void 0 ? _ref3 : 0,
|
|
317
319
|
quantity: quantity,
|
|
318
320
|
option: (other === null || other === void 0 ? void 0 : other.option) || [],
|
|
319
|
-
bundle: (other === null || other === void 0 ? void 0 : other.bundle) || [],
|
|
321
|
+
bundle: (other === null || other === void 0 ? void 0 : other.bundle) || (extend === null || extend === void 0 || (_extend$skuValue = extend.skuValue) === null || _extend$skuValue === void 0 ? void 0 : _extend$skuValue.bundle) || (extend === null || extend === void 0 || (_extend$_skuValue = extend._skuValue) === null || _extend$_skuValue === void 0 ? void 0 : _extend$_skuValue.bundle) || [],
|
|
320
322
|
unique: other === null || other === void 0 ? void 0 : other.unique,
|
|
321
323
|
session: other === null || other === void 0 ? void 0 : other.session,
|
|
322
|
-
note:
|
|
323
|
-
price: (
|
|
324
|
-
selling_price: (
|
|
324
|
+
note: extend === null || extend === void 0 ? void 0 : extend.note,
|
|
325
|
+
price: (_extend$price = extend === null || extend === void 0 ? void 0 : extend.price) !== null && _extend$price !== void 0 ? _extend$price : cacheItem === null || cacheItem === void 0 ? void 0 : cacheItem.price,
|
|
326
|
+
selling_price: (_extend$price2 = extend === null || extend === void 0 ? void 0 : extend.price) !== null && _extend$price2 !== void 0 ? _extend$price2 : cacheItem === null || cacheItem === void 0 ? void 0 : cacheItem.price,
|
|
327
|
+
line_total: extend === null || extend === void 0 ? void 0 : extend.total,
|
|
328
|
+
total: extend === null || extend === void 0 ? void 0 : extend.total,
|
|
329
|
+
origin_total: extend === null || extend === void 0 ? void 0 : extend.origin_total,
|
|
330
|
+
price_override: extend === null || extend === void 0 ? void 0 : extend.priceOverride,
|
|
331
|
+
bundle_edit: extend === null || extend === void 0 ? void 0 : extend.bundle_edit,
|
|
332
|
+
_extend: extend
|
|
325
333
|
};
|
|
326
334
|
}
|
|
@@ -13,7 +13,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
13
13
|
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; }
|
|
14
14
|
import dayjs from 'dayjs';
|
|
15
15
|
import Decimal from 'decimal.js';
|
|
16
|
-
import { composeLinePrice, createUuidV4, sumOptionUnitPrice } from "../../modules/Order/utils";
|
|
16
|
+
import { composeLinePrice, createUuidV4, resolveManualOverrideLineOriginalPrice, sumOptionUnitPrice } from "../../modules/Order/utils";
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* 构建金额全为 0 的空 summary。
|
|
@@ -480,17 +480,42 @@ export function getProductIdentityIndex(products, identity) {
|
|
|
480
480
|
* - 因此多次 normalize 不会重复叠加 option/bundle。
|
|
481
481
|
*/
|
|
482
482
|
export function normalizeOrderProduct(product) {
|
|
483
|
-
var _product$metadata, _metadata$origin, _variantList$find, _product$is_charge_ta;
|
|
483
|
+
var _product$metadata, _metadata$origin, _metadata$origin2, _variantList$find, _product$is_charge_ta;
|
|
484
484
|
var metadata = _objectSpread({}, product.metadata || {});
|
|
485
485
|
// 不透明 identity 契约:每条订单行必须带 identity_key。
|
|
486
486
|
// 调用方未传时由 SDK 自动生成 UUID,后续 update/remove 只做严格比对,避免猜测合成 key。
|
|
487
487
|
var resolvedIdentityKey = (_product$metadata = product.metadata) !== null && _product$metadata !== void 0 && _product$metadata.unique_identification_number ? String(product.metadata.unique_identification_number) : product.unique_identification_number && String(product.unique_identification_number).length > 0 ? String(product.unique_identification_number) : product.identity_key && String(product.identity_key).length > 0 ? String(product.identity_key) : createUuidV4();
|
|
488
488
|
metadata.unique_identification_number = resolvedIdentityKey;
|
|
489
|
-
var
|
|
490
|
-
|
|
489
|
+
var priceOverride = metadata.price_override;
|
|
490
|
+
var originOtherBundle = (_metadata$origin = metadata.origin) === null || _metadata$origin === void 0 || (_metadata$origin = _metadata$origin._extend) === null || _metadata$origin === void 0 || (_metadata$origin = _metadata$origin.other) === null || _metadata$origin === void 0 ? void 0 : _metadata$origin.bundle;
|
|
491
|
+
var bundleInput = product.product_bundle || [];
|
|
492
|
+
if (priceOverride !== undefined && priceOverride !== null && priceOverride !== '' && Array.isArray(originOtherBundle) && originOtherBundle.length > 0) {
|
|
493
|
+
var priceById = new Map();
|
|
494
|
+
originOtherBundle.forEach(function (item) {
|
|
495
|
+
var _item$price2;
|
|
496
|
+
if ((item === null || item === void 0 ? void 0 : item.id) == null) return;
|
|
497
|
+
var unit = (_item$price2 = item.price) !== null && _item$price2 !== void 0 ? _item$price2 : item.bundle_selling_price;
|
|
498
|
+
if (unit === undefined || unit === null) return;
|
|
499
|
+
priceById.set(String(item.id), String(unit));
|
|
500
|
+
});
|
|
501
|
+
var base = Array.isArray(bundleInput) && bundleInput.length > 0 ? bundleInput : originOtherBundle;
|
|
502
|
+
bundleInput = base.map(function (item) {
|
|
503
|
+
var unit = priceById.get(String(item === null || item === void 0 ? void 0 : item.id));
|
|
504
|
+
if (unit === undefined) return item;
|
|
505
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
506
|
+
price: unit,
|
|
507
|
+
bundle_selling_price: unit
|
|
508
|
+
});
|
|
509
|
+
});
|
|
510
|
+
}
|
|
511
|
+
var normalizedBundle = bundleInput.map(function (item) {
|
|
512
|
+
var _item$bundle_id2, _item$bundle_product_, _item$bundle_group_id, _ref4, _item$bundle_selling_, _ref5, _ref6, _item$price3, _ref7, _item$price_type, _ref8, _item$price_type_ext;
|
|
491
513
|
return _objectSpread(_objectSpread({}, item), {}, {
|
|
514
|
+
bundle_id: (_item$bundle_id2 = item.bundle_id) !== null && _item$bundle_id2 !== void 0 ? _item$bundle_id2 : item.id,
|
|
515
|
+
bundle_product_id: (_item$bundle_product_ = item.bundle_product_id) !== null && _item$bundle_product_ !== void 0 ? _item$bundle_product_ : item._bundle_product_id,
|
|
516
|
+
bundle_group_id: (_item$bundle_group_id = item.bundle_group_id) !== null && _item$bundle_group_id !== void 0 ? _item$bundle_group_id : item.group_id,
|
|
492
517
|
bundle_selling_price: (_ref4 = (_item$bundle_selling_ = item.bundle_selling_price) !== null && _item$bundle_selling_ !== void 0 ? _item$bundle_selling_ : item.price) !== null && _ref4 !== void 0 ? _ref4 : '0.00',
|
|
493
|
-
price: (_ref5 = (_ref6 = (_item$
|
|
518
|
+
price: (_ref5 = (_ref6 = (_item$price3 = item.price) !== null && _item$price3 !== void 0 ? _item$price3 : item.custom_price) !== null && _ref6 !== void 0 ? _ref6 : item.bundle_selling_price) !== null && _ref5 !== void 0 ? _ref5 : '0.00',
|
|
494
519
|
price_type: (_ref7 = (_item$price_type = item.price_type) !== null && _item$price_type !== void 0 ? _item$price_type : item.custom_price_type) !== null && _ref7 !== void 0 ? _ref7 : '',
|
|
495
520
|
price_type_ext: (_ref8 = (_item$price_type_ext = item.price_type_ext) !== null && _item$price_type_ext !== void 0 ? _item$price_type_ext : item.custom_price_type_ext) !== null && _ref8 !== void 0 ? _ref8 : ''
|
|
496
521
|
});
|
|
@@ -508,7 +533,7 @@ export function normalizeOrderProduct(product) {
|
|
|
508
533
|
// 6) 入参 selling_price(最末兜底,新添加路径 caller 只给 selling_price)
|
|
509
534
|
var isV2 = metadata.price_schema_version === 2 || metadata.price_schema_version === '2';
|
|
510
535
|
var variantId = Number(product.product_variant_id || 0);
|
|
511
|
-
var variantList = variantId ? metadata === null || metadata === void 0 || (_metadata$
|
|
536
|
+
var variantList = variantId ? metadata === null || metadata === void 0 || (_metadata$origin2 = metadata.origin) === null || _metadata$origin2 === void 0 ? void 0 : _metadata$origin2.variant : null;
|
|
512
537
|
var variantPrice = Array.isArray(variantList) ? (_variantList$find = variantList.find(function (v) {
|
|
513
538
|
return Number(v === null || v === void 0 ? void 0 : v.id) === variantId;
|
|
514
539
|
})) === null || _variantList$find === void 0 ? void 0 : _variantList$find.price : undefined;
|
|
@@ -578,6 +603,10 @@ export function normalizeOrderProduct(product) {
|
|
|
578
603
|
bundle: normalizedBundle,
|
|
579
604
|
useOriginalBundle: true
|
|
580
605
|
});
|
|
606
|
+
var finalOriginalPrice = resolveManualOverrideLineOriginalPrice({
|
|
607
|
+
num: product.num,
|
|
608
|
+
metadata: metadata
|
|
609
|
+
}, composedOriginalPrice);
|
|
581
610
|
return {
|
|
582
611
|
order_detail_id: product.order_detail_id || null,
|
|
583
612
|
product_id: product.product_id,
|
|
@@ -585,7 +614,7 @@ export function normalizeOrderProduct(product) {
|
|
|
585
614
|
product_variant_id: product.product_variant_id,
|
|
586
615
|
product_option_item: normalizedOptions,
|
|
587
616
|
selling_price: composedSellingPrice,
|
|
588
|
-
original_price:
|
|
617
|
+
original_price: finalOriginalPrice,
|
|
589
618
|
tax_fee: product.tax_fee || '0.00',
|
|
590
619
|
is_charge_tax: (_product$is_charge_ta = product.is_charge_tax) !== null && _product$is_charge_ta !== void 0 ? _product$is_charge_ta : 0,
|
|
591
620
|
discount_list: product.discount_list || [],
|
|
@@ -57,8 +57,23 @@ function resolveSourceProductPrice(product, sourceProduct) {
|
|
|
57
57
|
}
|
|
58
58
|
return Number(product.selling_price ?? 0);
|
|
59
59
|
}
|
|
60
|
+
function mapOrderBundleToOtherBundle(bundle) {
|
|
61
|
+
return bundle.map((item) => {
|
|
62
|
+
const catalogOriginal = item.original_price ?? item.product_price ?? item.price ?? item.bundle_selling_price;
|
|
63
|
+
const selling = item.bundle_selling_price ?? item.price ?? catalogOriginal;
|
|
64
|
+
const { bundle_selling_price: _omitBundleSelling, ...rest } = item;
|
|
65
|
+
return {
|
|
66
|
+
...rest,
|
|
67
|
+
price: selling,
|
|
68
|
+
original_price: catalogOriginal,
|
|
69
|
+
original_total: item.original_total ?? catalogOriginal,
|
|
70
|
+
num: item.num ?? item.quantity ?? 1,
|
|
71
|
+
quantity: item.quantity ?? item.num ?? 1
|
|
72
|
+
};
|
|
73
|
+
});
|
|
74
|
+
}
|
|
60
75
|
function buildNormalProductCacheItemFromOrderLine(input) {
|
|
61
|
-
var _a;
|
|
76
|
+
var _a, _b, _c, _d;
|
|
62
77
|
const { product, sourceProduct } = input;
|
|
63
78
|
const resolvedId = product.product_id ?? (sourceProduct == null ? void 0 : sourceProduct.id);
|
|
64
79
|
const sourcePrice = resolveSourceProductPrice(product, sourceProduct);
|
|
@@ -66,33 +81,44 @@ function buildNormalProductCacheItemFromOrderLine(input) {
|
|
|
66
81
|
const original = Number(product.original_price ?? selling);
|
|
67
82
|
const uid = (_a = product.metadata) == null ? void 0 : _a.unique_identification_number;
|
|
68
83
|
const option = Array.isArray(product.product_option_item) ? [...product.product_option_item] : [];
|
|
69
|
-
const bundle =
|
|
84
|
+
const bundle = mapOrderBundleToOtherBundle(
|
|
85
|
+
Array.isArray(product.product_bundle) ? product.product_bundle : []
|
|
86
|
+
);
|
|
87
|
+
const originExtend = (_c = (_b = product.metadata) == null ? void 0 : _b.origin) == null ? void 0 : _c._extend;
|
|
70
88
|
const other = {
|
|
71
89
|
product_id: resolvedId,
|
|
72
90
|
product_variant_id: product.product_variant_id ?? 0,
|
|
73
91
|
option,
|
|
74
|
-
bundle,
|
|
92
|
+
bundle: ((_d = originExtend == null ? void 0 : originExtend.other) == null ? void 0 : _d.bundle) ? JSON.parse(JSON.stringify(originExtend.other.bundle)) : bundle,
|
|
75
93
|
quantity: product.num ?? 1
|
|
76
94
|
};
|
|
77
95
|
const skuValue = {
|
|
78
96
|
product_id: resolvedId,
|
|
79
97
|
product_variant_id: product.product_variant_id ?? 0,
|
|
80
|
-
option,
|
|
81
|
-
bundle
|
|
98
|
+
option: other.option,
|
|
99
|
+
bundle: other.bundle
|
|
82
100
|
};
|
|
83
101
|
const extend = {
|
|
84
102
|
quantity: product.num ?? 1,
|
|
85
103
|
product_name: (sourceProduct == null ? void 0 : sourceProduct.title) ?? "",
|
|
86
104
|
note: product.note ?? "",
|
|
87
105
|
// v2:_extend.price 为主商品 source 价;行 composite 用 total / origin_total 展示
|
|
88
|
-
price: sourcePrice,
|
|
89
|
-
total: selling,
|
|
90
|
-
origin_total: original,
|
|
106
|
+
price: (originExtend == null ? void 0 : originExtend.price) ?? sourcePrice,
|
|
107
|
+
total: (originExtend == null ? void 0 : originExtend.total) ?? selling,
|
|
108
|
+
origin_total: (originExtend == null ? void 0 : originExtend.origin_total) ?? original,
|
|
91
109
|
other,
|
|
92
110
|
skuValue: JSON.parse(JSON.stringify(skuValue)),
|
|
93
111
|
_skuValue: JSON.parse(JSON.stringify(skuValue)),
|
|
94
|
-
isNormalProduct: true
|
|
112
|
+
isNormalProduct: true,
|
|
113
|
+
...(originExtend == null ? void 0 : originExtend.priceOverride) !== void 0 ? { priceOverride: originExtend.priceOverride } : {},
|
|
114
|
+
...(originExtend == null ? void 0 : originExtend.bundle_edit) !== void 0 ? { bundle_edit: originExtend.bundle_edit } : {}
|
|
95
115
|
};
|
|
116
|
+
if ((originExtend == null ? void 0 : originExtend.skuValue) || (originExtend == null ? void 0 : originExtend._skuValue)) {
|
|
117
|
+
extend.skuValue = JSON.parse(
|
|
118
|
+
JSON.stringify(originExtend.skuValue || originExtend._skuValue)
|
|
119
|
+
);
|
|
120
|
+
extend._skuValue = JSON.parse(JSON.stringify(extend.skuValue));
|
|
121
|
+
}
|
|
96
122
|
return {
|
|
97
123
|
...sourceProduct || {},
|
|
98
124
|
id: resolvedId,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Module, PisellCore, ModuleOptions } from '../../types';
|
|
2
2
|
import { BaseModule } from '../BaseModule';
|
|
3
|
-
import { OrderModuleAPI, CommitOrderParams, UpdateOrderBookingParams, UpdateOrderProductParams, CheckoutOrderParams, CancelOrderParams, ChangeBookingStatusParams } from './types';
|
|
3
|
+
import { OrderModuleAPI, CommitOrderParams, UpdateOrderBookingParams, UpdateOrderProductParams, UpdateOrderProductQuantityParams, CheckoutOrderParams, CancelOrderParams, ChangeBookingStatusParams } from './types';
|
|
4
4
|
import { CartItem } from '../Cart/types';
|
|
5
5
|
import { type SubmitPayloadEnhancer } from './utils';
|
|
6
6
|
import type { OrderAmountSnapshot, AddProductBookingInput, OrderIdentitySnapshot, OrderPaymentSource, OrderSnapshot, OrderSyncState, SyncPaymentsToOrderParams, SyncPaymentsToOrderResult, SubmitSalesOrderParams, OrderProduct, OrderProductIdentity, OrderSummary, OrderTempOrder, OrderPaymentData, SendCustomerPayLinkParams, UpdateTempOrderCustomerInput, OrderCustomerPatch, OrderCustomerView, ReplaceTempOrderOptions } from './types';
|
|
@@ -72,6 +72,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
72
72
|
getLocalOrderByOrderNumber(orderNumber: string): Promise<Record<string, any> | null>;
|
|
73
73
|
getLocalOrderByExternalSaleNumber(externalSaleNumber: string): Promise<Record<string, any> | null>;
|
|
74
74
|
saveDraft(): Promise<void>;
|
|
75
|
+
private saveDraftInBackground;
|
|
75
76
|
private hydrateTempOrderFromLocalRecord;
|
|
76
77
|
private extractOrderIdFromSubmitResult;
|
|
77
78
|
private calculatePaymentTotal;
|
|
@@ -103,7 +104,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
103
104
|
updateTempOrderNote(note: string): string;
|
|
104
105
|
updateTempOrderNote(note: string, sync: true): Promise<string>;
|
|
105
106
|
updateTempOrderNote(note: string, sync: boolean): string | Promise<string>;
|
|
106
|
-
|
|
107
|
+
syncTempOrderNoteToRemote(orderId: number | string, note: string): Promise<string>;
|
|
107
108
|
getTempOrderNote(): string;
|
|
108
109
|
updateTempOrderShopDiscount(amount: string | number): string;
|
|
109
110
|
updateTempOrderBuzzer(buzzer: string): string;
|
|
@@ -157,8 +158,14 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
157
158
|
addProductToOrder(product: Partial<OrderProduct> & OrderProductIdentity, booking?: AddProductBookingInput): Promise<OrderProduct[]>;
|
|
158
159
|
private hasGoodPassDiscount;
|
|
159
160
|
updateOrderProduct(params: UpdateOrderProductParams): Promise<OrderProduct[]>;
|
|
161
|
+
updateOrderProductQuantity(params: UpdateOrderProductQuantityParams): Promise<OrderProduct[]>;
|
|
160
162
|
updateOrderBooking(params: UpdateOrderBookingParams): any[];
|
|
161
163
|
removeProductFromOrder(identity: OrderProductIdentity): Promise<OrderProduct[]>;
|
|
164
|
+
/**
|
|
165
|
+
* 仅清空购物车行(products / bookings / discount_list),不重置整单。
|
|
166
|
+
* 用于「仅清空商品」;客户、备注、支付等协议字段保持不变。
|
|
167
|
+
*/
|
|
168
|
+
clearOrderCartLines(): Promise<OrderTempOrder>;
|
|
162
169
|
/**
|
|
163
170
|
* 提交当前 Sales tempOrder。
|
|
164
171
|
*
|
|
@@ -235,4 +242,4 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
235
242
|
getLastOrderInfo(): Record<string, any> | undefined;
|
|
236
243
|
getOrderInfo(order_id: number): Promise<any>;
|
|
237
244
|
}
|
|
238
|
-
export type { UpdateOrderBookingParams, UpdateOrderProductParams } from './types';
|
|
245
|
+
export type { UpdateOrderBookingParams, UpdateOrderProductParams, UpdateOrderProductQuantityParams, } from './types';
|
|
@@ -495,6 +495,9 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
495
495
|
});
|
|
496
496
|
}
|
|
497
497
|
}
|
|
498
|
+
saveDraftInBackground() {
|
|
499
|
+
void this.saveDraft();
|
|
500
|
+
}
|
|
498
501
|
async hydrateTempOrderFromLocalRecord(record) {
|
|
499
502
|
return this.hydrateTempOrderFromRecord(record);
|
|
500
503
|
}
|
|
@@ -911,11 +914,12 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
911
914
|
extend.customerSnapshot = (0, import_lodash_es.cloneDeep)(snapshot);
|
|
912
915
|
}
|
|
913
916
|
this.persistTempOrder();
|
|
917
|
+
this.saveDraftInBackground();
|
|
914
918
|
this.emitOrderCustomerChange();
|
|
915
919
|
}
|
|
916
920
|
getOrderCustomer() {
|
|
917
921
|
const tempOrder = this.store.tempOrder;
|
|
918
|
-
if (!tempOrder || tempOrder.customer_id
|
|
922
|
+
if (!tempOrder || !tempOrder.customer_id) {
|
|
919
923
|
return null;
|
|
920
924
|
}
|
|
921
925
|
return {
|
|
@@ -933,7 +937,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
933
937
|
}
|
|
934
938
|
clearOrderCustomer() {
|
|
935
939
|
const tempOrder = this.ensureTempOrder();
|
|
936
|
-
tempOrder.customer_id =
|
|
940
|
+
tempOrder.customer_id = 0;
|
|
937
941
|
tempOrder.customer_name = "";
|
|
938
942
|
tempOrder.country_calling_code = "";
|
|
939
943
|
tempOrder.phone = "";
|
|
@@ -941,6 +945,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
941
945
|
if (tempOrder._extend)
|
|
942
946
|
delete tempOrder._extend.customerSnapshot;
|
|
943
947
|
this.persistTempOrder();
|
|
948
|
+
this.saveDraftInBackground();
|
|
944
949
|
this.core.effects.emit(import_types.OrderHooks.OnOrderCustomerChange, null);
|
|
945
950
|
}
|
|
946
951
|
emitOrderCustomerChange() {
|
|
@@ -1206,6 +1211,9 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
1206
1211
|
};
|
|
1207
1212
|
if (unique_identification_number !== void 0) {
|
|
1208
1213
|
identityLookup.unique_identification_number = unique_identification_number;
|
|
1214
|
+
if (identity_key === void 0) {
|
|
1215
|
+
identityLookup.identity_key = unique_identification_number;
|
|
1216
|
+
}
|
|
1209
1217
|
}
|
|
1210
1218
|
if (identity_key !== void 0) {
|
|
1211
1219
|
identityLookup.identity_key = identity_key;
|
|
@@ -1214,7 +1222,19 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
1214
1222
|
identityLookup.product_option_item = product_option_item;
|
|
1215
1223
|
if (product_bundle !== void 0)
|
|
1216
1224
|
identityLookup.product_bundle = product_bundle;
|
|
1217
|
-
|
|
1225
|
+
let productIndex = -1;
|
|
1226
|
+
if (unique_identification_number !== void 0) {
|
|
1227
|
+
const targetUid = String(unique_identification_number);
|
|
1228
|
+
productIndex = tempOrder.products.findIndex((item) => {
|
|
1229
|
+
var _a2;
|
|
1230
|
+
return String(
|
|
1231
|
+
((_a2 = item.metadata) == null ? void 0 : _a2.unique_identification_number) || item.unique_identification_number || ""
|
|
1232
|
+
) === targetUid;
|
|
1233
|
+
});
|
|
1234
|
+
}
|
|
1235
|
+
if (productIndex === -1) {
|
|
1236
|
+
productIndex = (0, import_utils3.getProductIdentityIndex)(tempOrder.products, identityLookup);
|
|
1237
|
+
}
|
|
1218
1238
|
if (productIndex === -1) {
|
|
1219
1239
|
throw new Error("[Order] 目标商品不存在,无法更新");
|
|
1220
1240
|
}
|
|
@@ -1281,6 +1301,65 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
1281
1301
|
this.persistTempOrder();
|
|
1282
1302
|
return tempOrder.products;
|
|
1283
1303
|
}
|
|
1304
|
+
async updateOrderProductQuantity(params) {
|
|
1305
|
+
var _a;
|
|
1306
|
+
const {
|
|
1307
|
+
product_id,
|
|
1308
|
+
product_variant_id,
|
|
1309
|
+
num,
|
|
1310
|
+
unique_identification_number,
|
|
1311
|
+
identity_key,
|
|
1312
|
+
product_option_item,
|
|
1313
|
+
product_bundle
|
|
1314
|
+
} = params;
|
|
1315
|
+
const tempOrder = this.ensureTempOrder();
|
|
1316
|
+
const identityLookup = {
|
|
1317
|
+
product_id,
|
|
1318
|
+
product_variant_id
|
|
1319
|
+
};
|
|
1320
|
+
if (unique_identification_number !== void 0) {
|
|
1321
|
+
identityLookup.unique_identification_number = unique_identification_number;
|
|
1322
|
+
if (identity_key === void 0) {
|
|
1323
|
+
identityLookup.identity_key = unique_identification_number;
|
|
1324
|
+
}
|
|
1325
|
+
}
|
|
1326
|
+
if (identity_key !== void 0)
|
|
1327
|
+
identityLookup.identity_key = identity_key;
|
|
1328
|
+
if (product_option_item !== void 0)
|
|
1329
|
+
identityLookup.product_option_item = product_option_item;
|
|
1330
|
+
if (product_bundle !== void 0)
|
|
1331
|
+
identityLookup.product_bundle = product_bundle;
|
|
1332
|
+
let productIndex = -1;
|
|
1333
|
+
if (unique_identification_number !== void 0) {
|
|
1334
|
+
const targetUid = String(unique_identification_number);
|
|
1335
|
+
productIndex = tempOrder.products.findIndex((item) => {
|
|
1336
|
+
var _a2;
|
|
1337
|
+
return String(
|
|
1338
|
+
((_a2 = item.metadata) == null ? void 0 : _a2.unique_identification_number) || item.unique_identification_number || ""
|
|
1339
|
+
) === targetUid;
|
|
1340
|
+
});
|
|
1341
|
+
}
|
|
1342
|
+
if (productIndex === -1) {
|
|
1343
|
+
productIndex = (0, import_utils3.getProductIdentityIndex)(tempOrder.products, identityLookup);
|
|
1344
|
+
}
|
|
1345
|
+
if (productIndex === -1) {
|
|
1346
|
+
throw new Error("[Order] 目标商品不存在,无法更新数量");
|
|
1347
|
+
}
|
|
1348
|
+
const targetProduct = tempOrder.products[productIndex];
|
|
1349
|
+
const normalizedProduct = (0, import_utils3.normalizeOrderProduct)({
|
|
1350
|
+
...targetProduct,
|
|
1351
|
+
num: (0, import_utils3.getSafeProductNum)(num),
|
|
1352
|
+
metadata: {
|
|
1353
|
+
...targetProduct.metadata || {},
|
|
1354
|
+
unique_identification_number: ((_a = targetProduct.metadata) == null ? void 0 : _a.unique_identification_number) || unique_identification_number
|
|
1355
|
+
}
|
|
1356
|
+
});
|
|
1357
|
+
tempOrder.products[productIndex] = normalizedProduct;
|
|
1358
|
+
this.applyDiscount();
|
|
1359
|
+
await this.recalculateSummary({ createIfMissing: true });
|
|
1360
|
+
this.persistTempOrder();
|
|
1361
|
+
return tempOrder.products;
|
|
1362
|
+
}
|
|
1284
1363
|
updateOrderBooking(params) {
|
|
1285
1364
|
const { unique_identification_number, updates } = params;
|
|
1286
1365
|
const tempOrder = this.ensureTempOrder();
|
|
@@ -1325,6 +1404,26 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
1325
1404
|
this.persistTempOrder();
|
|
1326
1405
|
return tempOrder.products;
|
|
1327
1406
|
}
|
|
1407
|
+
/**
|
|
1408
|
+
* 仅清空购物车行(products / bookings / discount_list),不重置整单。
|
|
1409
|
+
* 用于「仅清空商品」;客户、备注、支付等协议字段保持不变。
|
|
1410
|
+
*/
|
|
1411
|
+
async clearOrderCartLines() {
|
|
1412
|
+
const tempOrder = this.ensureTempOrder();
|
|
1413
|
+
tempOrder.products = [];
|
|
1414
|
+
tempOrder.bookings = [];
|
|
1415
|
+
tempOrder.discount_list = [];
|
|
1416
|
+
if (tempOrder._extend && typeof tempOrder._extend === "object") {
|
|
1417
|
+
tempOrder._extend = {
|
|
1418
|
+
...tempOrder._extend,
|
|
1419
|
+
productsByUid: {}
|
|
1420
|
+
};
|
|
1421
|
+
}
|
|
1422
|
+
this.applyDiscount();
|
|
1423
|
+
await this.recalculateSummary({ createIfMissing: true });
|
|
1424
|
+
this.persistTempOrder();
|
|
1425
|
+
return tempOrder;
|
|
1426
|
+
}
|
|
1328
1427
|
// ─── TempOrder: 提交 ───
|
|
1329
1428
|
/**
|
|
1330
1429
|
* 提交当前 Sales tempOrder。
|
|
@@ -1468,7 +1567,8 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
1468
1567
|
const submitResult = await this.submitTempOrder({
|
|
1469
1568
|
payments: mappedPayments,
|
|
1470
1569
|
paymentStatus: params.paymentStatus || "paid",
|
|
1471
|
-
smallTicketDataFlag: params.smallTicketDataFlag
|
|
1570
|
+
smallTicketDataFlag: params.smallTicketDataFlag,
|
|
1571
|
+
channel: params.channel
|
|
1472
1572
|
});
|
|
1473
1573
|
return { isFullyPaid, submitResult };
|
|
1474
1574
|
}
|
|
@@ -107,7 +107,7 @@ export interface OrderTempOrder {
|
|
|
107
107
|
shop_order_number: string | null;
|
|
108
108
|
shop_full_order_number: string | null;
|
|
109
109
|
type: string;
|
|
110
|
-
business_code
|
|
110
|
+
business_code?: string;
|
|
111
111
|
platform: string;
|
|
112
112
|
sales_channel: string;
|
|
113
113
|
order_sales_channel: string;
|
|
@@ -193,6 +193,11 @@ export interface UpdateOrderProductParams {
|
|
|
193
193
|
product_bundle?: any[];
|
|
194
194
|
booking?: AddProductBookingInput;
|
|
195
195
|
}
|
|
196
|
+
/** 仅更新购物车行数量;行定位语义与 updateOrderProduct / removeProductFromOrder 保持一致 */
|
|
197
|
+
export interface UpdateOrderProductQuantityParams extends OrderProductIdentity {
|
|
198
|
+
num: number;
|
|
199
|
+
identity_key?: string;
|
|
200
|
+
}
|
|
196
201
|
export interface UpdateOrderBookingParams {
|
|
197
202
|
unique_identification_number: string;
|
|
198
203
|
updates: AddProductBookingInput;
|
|
@@ -251,7 +256,7 @@ export interface SubmitSalesOrderParams {
|
|
|
251
256
|
shop_order_number: string | null;
|
|
252
257
|
shop_full_order_number: string | null;
|
|
253
258
|
type: string;
|
|
254
|
-
business_code
|
|
259
|
+
business_code?: string;
|
|
255
260
|
platform: string;
|
|
256
261
|
request_unique_idempotency_token?: string;
|
|
257
262
|
sales_channel: string;
|
|
@@ -362,6 +367,7 @@ export interface SyncPaymentsToOrderParams {
|
|
|
362
367
|
paymentStatus?: SubmitSalesOrderParams['query']['payment_status'];
|
|
363
368
|
submitWhenPaid?: boolean;
|
|
364
369
|
smallTicketDataFlag?: number;
|
|
370
|
+
channel?: string;
|
|
365
371
|
}
|
|
366
372
|
export interface SyncPaymentsToOrderResult<T = any> {
|
|
367
373
|
isFullyPaid: boolean;
|
|
@@ -482,8 +488,14 @@ export interface OrderModuleAPI {
|
|
|
482
488
|
updateTempOrderContactsInfo: (contactsInfo: Record<string, any> | null) => Record<string, any> | null;
|
|
483
489
|
addProductToOrder: (product: Partial<OrderProduct> & OrderProductIdentity, booking?: AddProductBookingInput) => Promise<OrderProduct[]>;
|
|
484
490
|
updateOrderProduct: (params: UpdateOrderProductParams) => Promise<OrderProduct[]>;
|
|
491
|
+
updateOrderProductQuantity: (params: UpdateOrderProductQuantityParams) => Promise<OrderProduct[]>;
|
|
485
492
|
updateOrderBooking: (params: UpdateOrderBookingParams) => any[];
|
|
486
493
|
removeProductFromOrder: (identity: OrderProductIdentity) => Promise<OrderProduct[]>;
|
|
494
|
+
/**
|
|
495
|
+
* 仅清空购物车行:products / bookings / discount_list(保留客户、备注、支付等其它 tempOrder 字段)。
|
|
496
|
+
* 内部会 applyDiscount + recalculateSummary + persist。
|
|
497
|
+
*/
|
|
498
|
+
clearOrderCartLines: () => Promise<OrderTempOrder>;
|
|
487
499
|
persistTempOrder: () => void;
|
|
488
500
|
submitTempOrder: <T = any>(params?: {
|
|
489
501
|
cacheId?: string;
|
|
@@ -65,6 +65,16 @@ export declare function sumOptionUnitPrice(options?: Array<{
|
|
|
65
65
|
*
|
|
66
66
|
* 导出为纯函数方便单测直接驱动钩子,不依赖 OrderModule 实例。
|
|
67
67
|
*/
|
|
68
|
+
/** Rules calcDiscount 用手动价标记;undefined 表示交给 Rules 用 total/origin_total 推断 */
|
|
69
|
+
export declare function resolveRulesManualDiscountFlag(metadata: Record<string, any> | null | undefined): boolean | undefined;
|
|
70
|
+
/**
|
|
71
|
+
* 手动改价(price_override)时行级 original_price:
|
|
72
|
+
* 购物车划线价应对齐改价前的 origin_total(如 40),而非 bundle 子项 catalog 原价合成的 30。
|
|
73
|
+
*/
|
|
74
|
+
export declare function resolveManualOverrideLineOriginalPrice(params: {
|
|
75
|
+
num?: number;
|
|
76
|
+
metadata?: Record<string, any> | null;
|
|
77
|
+
}, fallbackCompositeOriginal: string): string;
|
|
68
78
|
export declare function createDefaultOrderRulesHooks(): RulesParamsHooks;
|
|
69
79
|
/**
|
|
70
80
|
* 通过 session 类商品的开始时间结束时间生成商品的时长
|