@pisell/pisellos 2.2.190 → 2.2.192
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/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +2 -1
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +2 -7
- package/dist/modules/Cart/utils/cartProduct.js +13 -2
- package/dist/modules/Order/index.d.ts +1 -3
- package/dist/modules/Order/index.js +69 -95
- package/dist/modules/Order/types.d.ts +9 -6
- package/dist/modules/Order/utils.d.ts +9 -2
- package/dist/modules/Order/utils.js +36 -13
- package/dist/modules/SalesSummary/types.d.ts +3 -1
- package/dist/modules/SalesSummary/utils.js +7 -3
- package/dist/server/modules/order/index.d.ts +60 -7
- package/dist/server/modules/order/index.js +670 -178
- package/dist/server/modules/order/types.d.ts +0 -2
- package/dist/server/modules/products/index.d.ts +33 -6
- package/dist/server/modules/products/index.js +528 -231
- package/dist/solution/BaseSales/index.js +13 -7
- package/dist/solution/BaseSales/types.d.ts +8 -5
- package/dist/solution/BaseSales/types.js +2 -3
- package/dist/solution/BaseSales/utils/cartPromotion.js +7 -7
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +1 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +16 -13
- package/dist/solution/BaseSales/utils.d.ts +1 -1
- package/dist/solution/BaseSales/utils.js +22 -19
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/ScanOrder/index.js +7 -5
- package/dist/solution/ScanOrder/types.d.ts +8 -5
- package/dist/solution/ScanOrder/types.js +2 -3
- package/dist/solution/ScanOrder/utils.d.ts +1 -1
- package/dist/solution/ScanOrder/utils.js +26 -23
- package/dist/solution/VenueBooking/index.js +5 -3
- package/dist/solution/VenueBooking/sales-section-4-annotated.json +0 -2
- package/lib/model/strategy/adapter/promotion/index.js +0 -49
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +2 -1
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +2 -1
- package/lib/modules/Cart/utils/cartProduct.js +9 -2
- package/lib/modules/Order/index.d.ts +1 -3
- package/lib/modules/Order/index.js +45 -58
- package/lib/modules/Order/types.d.ts +9 -6
- package/lib/modules/Order/utils.d.ts +9 -2
- package/lib/modules/Order/utils.js +41 -10
- package/lib/modules/SalesSummary/types.d.ts +3 -1
- package/lib/modules/SalesSummary/utils.js +5 -3
- package/lib/server/modules/order/index.d.ts +60 -7
- package/lib/server/modules/order/index.js +350 -40
- package/lib/server/modules/order/types.d.ts +0 -2
- package/lib/server/modules/products/index.d.ts +33 -6
- package/lib/server/modules/products/index.js +159 -30
- package/lib/solution/BaseSales/index.js +14 -5
- package/lib/solution/BaseSales/types.d.ts +8 -5
- package/lib/solution/BaseSales/utils/cartPromotion.js +6 -6
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +1 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +21 -14
- package/lib/solution/BaseSales/utils.d.ts +1 -1
- package/lib/solution/BaseSales/utils.js +11 -7
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/ScanOrder/index.js +4 -4
- package/lib/solution/ScanOrder/types.d.ts +8 -5
- package/lib/solution/ScanOrder/utils.d.ts +1 -1
- package/lib/solution/ScanOrder/utils.js +12 -8
- package/lib/solution/VenueBooking/index.js +2 -2
- package/lib/solution/VenueBooking/sales-section-4-annotated.json +0 -2
- package/package.json +1 -1
- package/dist/solution/Checkout/appointmentDemo.json +0 -1
- package/lib/solution/Checkout/appointmentDemo.json +0 -1
|
@@ -31,7 +31,7 @@ import { BaseSalesHookNames } from "./types";
|
|
|
31
31
|
import { OrderModule } from "../../modules/Order";
|
|
32
32
|
import Decimal from 'decimal.js';
|
|
33
33
|
import { createModule } from "../BookingByStep/types";
|
|
34
|
-
import { composeLinePrice, createUuidV4, sumOptionUnitPrice } from "../../modules/Order/utils";
|
|
34
|
+
import { composeLinePrice, createUuidV4, ensureProductSku, getProductSkuOptions, sumOptionUnitPrice } from "../../modules/Order/utils";
|
|
35
35
|
import dayjs from 'dayjs';
|
|
36
36
|
export * from "./types";
|
|
37
37
|
import { QuotationModule } from "../../modules/Quotation";
|
|
@@ -342,7 +342,6 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
342
342
|
_product$num,
|
|
343
343
|
_ref8,
|
|
344
344
|
_product$quantity,
|
|
345
|
-
_product$product_opti,
|
|
346
345
|
_product$metadata;
|
|
347
346
|
if (!authoritativeProduct) return product;
|
|
348
347
|
var selectedBundles = Array.isArray(product.product_bundle) ? product.product_bundle : [];
|
|
@@ -365,7 +364,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
365
364
|
product_variant_id: (_ref6 = (_product$product_vari = product.product_variant_id) !== null && _product$product_vari !== void 0 ? _product$product_vari : authoritativeProduct.product_variant_id) !== null && _ref6 !== void 0 ? _ref6 : 0,
|
|
366
365
|
num: (_ref7 = (_product$num = product.num) !== null && _product$num !== void 0 ? _product$num : product.quantity) !== null && _ref7 !== void 0 ? _ref7 : authoritativeProduct.num,
|
|
367
366
|
quantity: (_ref8 = (_product$quantity = product.quantity) !== null && _product$quantity !== void 0 ? _product$quantity : product.num) !== null && _ref8 !== void 0 ? _ref8 : authoritativeProduct.quantity,
|
|
368
|
-
|
|
367
|
+
product_sku: function () {
|
|
368
|
+
var authoritativeSku = ensureProductSku(authoritativeProduct);
|
|
369
|
+
var productSku = ensureProductSku(product);
|
|
370
|
+
var hasProductSku = product.product_sku && _typeof(product.product_sku) === 'object';
|
|
371
|
+
return _objectSpread(_objectSpread(_objectSpread({}, authoritativeSku), productSku), {}, {
|
|
372
|
+
option: hasProductSku ? productSku.option : authoritativeSku.option
|
|
373
|
+
});
|
|
374
|
+
}(),
|
|
369
375
|
product_bundle: productBundle,
|
|
370
376
|
metadata: (_product$metadata = product.metadata) !== null && _product$metadata !== void 0 ? _product$metadata : authoritativeProduct.metadata
|
|
371
377
|
});
|
|
@@ -1319,7 +1325,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1319
1325
|
totalPerUnitDiscount = (product.discount_list || []).reduce(function (sum, pd) {
|
|
1320
1326
|
return sum + Number(pd.amount || 0);
|
|
1321
1327
|
}, 0);
|
|
1322
|
-
optionSum = sumOptionUnitPrice(product
|
|
1328
|
+
optionSum = sumOptionUnitPrice(getProductSkuOptions(product));
|
|
1323
1329
|
sourcePrice = (_product$metadata$sou = (_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4.source_product_price) !== null && _product$metadata$sou !== void 0 ? _product$metadata$sou : ((_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.main_product_original_price) != null ? new Decimal(Number(product.metadata.main_product_original_price) || 0).minus(optionSum).toFixed(2) : (_product$original_pri = product.original_price) !== null && _product$original_pri !== void 0 ? _product$original_pri : '0';
|
|
1324
1330
|
newSourceSellingPrice = new Decimal(Number(sourcePrice) || 0).minus(totalPerUnitDiscount).toDecimalPlaces(2).toString();
|
|
1325
1331
|
newMainSellingPrice = new Decimal(Number(newSourceSellingPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
|
|
@@ -1635,7 +1641,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1635
1641
|
totalPerUnitDiscount = (product.discount_list || []).reduce(function (sum, pd) {
|
|
1636
1642
|
return sum + (pd.amount || 0);
|
|
1637
1643
|
}, 0); // TODO 这块逻辑需要拿掉
|
|
1638
|
-
optionSum = sumOptionUnitPrice(product
|
|
1644
|
+
optionSum = sumOptionUnitPrice(getProductSkuOptions(product));
|
|
1639
1645
|
sourcePrice = (_product$metadata$sou2 = (_product$metadata8 = product.metadata) === null || _product$metadata8 === void 0 ? void 0 : _product$metadata8.source_product_price) !== null && _product$metadata$sou2 !== void 0 ? _product$metadata$sou2 : ((_product$metadata9 = product.metadata) === null || _product$metadata9 === void 0 ? void 0 : _product$metadata9.main_product_original_price) != null ? new Decimal(Number(product.metadata.main_product_original_price) || 0).minus(optionSum).toFixed(2) : (_product$original_pri2 = product.original_price) !== null && _product$original_pri2 !== void 0 ? _product$original_pri2 : '0';
|
|
1640
1646
|
newSourceSellingPrice = new Decimal(Number(sourcePrice) || 0).minus(totalPerUnitDiscount).toDecimalPlaces(2).toString();
|
|
1641
1647
|
newMainSellingPrice = new Decimal(Number(newSourceSellingPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
|
|
@@ -2448,8 +2454,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2448
2454
|
if (identity.unique_identification_number !== undefined) {
|
|
2449
2455
|
params.unique_identification_number = identity.unique_identification_number;
|
|
2450
2456
|
}
|
|
2451
|
-
if (identity.
|
|
2452
|
-
params.
|
|
2457
|
+
if (identity.product_sku !== undefined) {
|
|
2458
|
+
params.product_sku = identity.product_sku;
|
|
2453
2459
|
}
|
|
2454
2460
|
if (identity.product_bundle !== undefined) params.product_bundle = identity.product_bundle;
|
|
2455
2461
|
_context27.next = 7;
|
|
@@ -41,16 +41,20 @@ export interface BaseSalesOrderProductIdentity {
|
|
|
41
41
|
identity_key?: string;
|
|
42
42
|
unique_identification_number?: string;
|
|
43
43
|
/** 参与合并/匹配;与 remove 通配语义见 isSkuOnlyDeleteIdentity */
|
|
44
|
-
|
|
44
|
+
product_sku?: BaseSalesProductSku;
|
|
45
45
|
product_bundle?: any[];
|
|
46
46
|
}
|
|
47
|
+
export interface BaseSalesProductSku {
|
|
48
|
+
option: any[];
|
|
49
|
+
[key: string]: any;
|
|
50
|
+
}
|
|
47
51
|
export interface BaseSalesUpdateOrderProductQuantityParams extends BaseSalesOrderProductIdentity {
|
|
48
52
|
num: number;
|
|
49
53
|
}
|
|
50
54
|
export interface BaseSalesOrderProduct extends BaseSalesOrderProductIdentity {
|
|
51
55
|
order_detail_id: number | null;
|
|
52
56
|
num: number;
|
|
53
|
-
|
|
57
|
+
product_sku: BaseSalesProductSku;
|
|
54
58
|
/**
|
|
55
59
|
* 券后 **行 composite 单价** = `metadata.main_product_selling_price`
|
|
56
60
|
* + Σ((bundle.bundle_selling_price ?? bundle.price) × (bundle.num ?? 1))
|
|
@@ -96,9 +100,8 @@ export interface BaseSalesOrderProduct extends BaseSalesOrderProductIdentity {
|
|
|
96
100
|
* 出站 payload 版本的商品行。
|
|
97
101
|
*
|
|
98
102
|
* 与 tempOrder 内部 `BaseSalesOrderProduct` 的字段差异:
|
|
99
|
-
* - `
|
|
100
|
-
*
|
|
101
|
-
* (后端 checkout 协议;丢弃 `price` 等运行时辅助字段)。
|
|
103
|
+
* - `product_sku.option[*]`:内部直接维护统一 Sales 协议字段;
|
|
104
|
+
* 提交时仅规范 `add_price`,保留传入/恢复得到的展示字段。
|
|
102
105
|
* - `product_bundle[*].option[*]`:同上重命名规则。
|
|
103
106
|
*
|
|
104
107
|
* 运行时(UI 显示、加购合并、指纹、持久化)与提交边界统一消费字段名
|
|
@@ -19,9 +19,8 @@ export function createBaseSalesHook(moduleName, hookName) {
|
|
|
19
19
|
* 出站 payload 版本的商品行。
|
|
20
20
|
*
|
|
21
21
|
* 与 tempOrder 内部 `BaseSalesOrderProduct` 的字段差异:
|
|
22
|
-
* - `
|
|
23
|
-
*
|
|
24
|
-
* (后端 checkout 协议;丢弃 `price` 等运行时辅助字段)。
|
|
22
|
+
* - `product_sku.option[*]`:内部直接维护统一 Sales 协议字段;
|
|
23
|
+
* 提交时仅规范 `add_price`,保留传入/恢复得到的展示字段。
|
|
25
24
|
* - `product_bundle[*].option[*]`:同上重命名规则。
|
|
26
25
|
*
|
|
27
26
|
* 运行时(UI 显示、加购合并、指纹、持久化)与提交边界统一消费字段名
|
|
@@ -20,7 +20,7 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToAr
|
|
|
20
20
|
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; }
|
|
21
21
|
import Decimal from 'decimal.js';
|
|
22
22
|
import { cloneDeep } from 'lodash-es';
|
|
23
|
-
import { composeLinePrice,
|
|
23
|
+
import { composeLinePrice, createUuidV4, getProductSkuOptions, sumOptionUnitPrice } from "../../../modules/Order/utils";
|
|
24
24
|
import { buildProductLineFingerprint, getSafeProductNum } from "../../ScanOrder/utils";
|
|
25
25
|
|
|
26
26
|
/**
|
|
@@ -78,7 +78,7 @@ import { buildProductLineFingerprint, getSafeProductNum } from "../../ScanOrder/
|
|
|
78
78
|
export function getOrderProductBasePrice(product) {
|
|
79
79
|
var _ref, _product$original_pri;
|
|
80
80
|
var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
|
|
81
|
-
var optionSum = sumOptionUnitPrice(product
|
|
81
|
+
var optionSum = sumOptionUnitPrice(getProductSkuOptions(product)).toNumber();
|
|
82
82
|
if (metadata.source_product_price !== undefined) {
|
|
83
83
|
var _v = Number(metadata.source_product_price);
|
|
84
84
|
return Number.isFinite(_v) ? _v : 0;
|
|
@@ -104,7 +104,7 @@ export function getOrderProductBasePrice(product) {
|
|
|
104
104
|
export function getOrderProductOriginalPriceForPromotion(product) {
|
|
105
105
|
var _metadata$_promotion;
|
|
106
106
|
var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
|
|
107
|
-
var optionSum = sumOptionUnitPrice(product
|
|
107
|
+
var optionSum = sumOptionUnitPrice(getProductSkuOptions(product)).toNumber();
|
|
108
108
|
if (metadata.main_product_original_price !== undefined && metadata.main_product_original_price !== null && metadata.main_product_original_price !== '') {
|
|
109
109
|
var v = Number(metadata.main_product_original_price) - optionSum;
|
|
110
110
|
if (Number.isFinite(v) && v >= 0) return v;
|
|
@@ -160,7 +160,7 @@ var BUY_X_GET_Y_FREE = 'BUY_X_GET_Y_FREE';
|
|
|
160
160
|
*/
|
|
161
161
|
function applyPromoUnitPriceToLine(item, input) {
|
|
162
162
|
var metadata = item.metadata || (item.metadata = {});
|
|
163
|
-
var optionSum = sumOptionUnitPrice(item
|
|
163
|
+
var optionSum = sumOptionUnitPrice(getProductSkuOptions(item)).toNumber();
|
|
164
164
|
var promoUnitPrice = new Decimal(Number(input.promoUnitPrice) || 0).toDecimalPlaces(2).toFixed(2);
|
|
165
165
|
var mainSelling = new Decimal(Number(promoUnitPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
|
|
166
166
|
var catalogSource = new Decimal(input.originalBasePrice).toDecimalPlaces(2).toFixed(2);
|
|
@@ -241,7 +241,7 @@ export function mergeIdenticalPromotionCartLines(products) {
|
|
|
241
241
|
merged.push(line);
|
|
242
242
|
continue;
|
|
243
243
|
}
|
|
244
|
-
var fingerprint = buildProductLineFingerprint(line
|
|
244
|
+
var fingerprint = buildProductLineFingerprint(getProductSkuOptions(line), line.product_bundle);
|
|
245
245
|
var unitPrice = String((_ref2 = (_line$metadata$source = (_line$metadata2 = line.metadata) === null || _line$metadata2 === void 0 ? void 0 : _line$metadata2.source_product_price) !== null && _line$metadata$source !== void 0 ? _line$metadata$source : line.selling_price) !== null && _ref2 !== void 0 ? _ref2 : '');
|
|
246
246
|
var promoUnitPrice = String((_ref3 = (_promotion$finalPrice = promotion.finalPrice) !== null && _promotion$finalPrice !== void 0 ? _promotion$finalPrice : (_line$metadata3 = line.metadata) === null || _line$metadata3 === void 0 ? void 0 : _line$metadata3.main_product_selling_price) !== null && _ref3 !== void 0 ? _ref3 : '');
|
|
247
247
|
var bookingUid = (_line$booking_uid = line === null || line === void 0 ? void 0 : line.booking_uid) !== null && _line$booking_uid !== void 0 ? _line$booking_uid : line === null || line === void 0 || (_line$metadata4 = line.metadata) === null || _line$metadata4 === void 0 ? void 0 : _line$metadata4.booking_uid;
|
|
@@ -452,7 +452,7 @@ function getProductBundleForEvaluator(product) {
|
|
|
452
452
|
*/
|
|
453
453
|
export function buildConsolidateKeyForPromotion(item) {
|
|
454
454
|
var _item$booking_uid, _item$metadata, _item$order_detail_id, _item$product_variant3;
|
|
455
|
-
var fingerprint = buildProductLineFingerprint(item
|
|
455
|
+
var fingerprint = buildProductLineFingerprint(getProductSkuOptions(item), item.product_bundle);
|
|
456
456
|
var bookingUid = (_item$booking_uid = item === null || item === void 0 ? void 0 : item.booking_uid) !== null && _item$booking_uid !== void 0 ? _item$booking_uid : item === null || item === void 0 || (_item$metadata = item.metadata) === null || _item$metadata === void 0 ? void 0 : _item$metadata.booking_uid;
|
|
457
457
|
var orderDetailId = (_item$order_detail_id = item === null || item === void 0 ? void 0 : item.order_detail_id) !== null && _item$order_detail_id !== void 0 ? _item$order_detail_id : item === null || item === void 0 ? void 0 : item.orderDetailId;
|
|
458
458
|
if (orderDetailId !== undefined && orderDetailId !== null && orderDetailId !== '') {
|
|
@@ -1225,7 +1225,7 @@ export function processCartPromotion(list, evaluator, options) {
|
|
|
1225
1225
|
});
|
|
1226
1226
|
} else {
|
|
1227
1227
|
// 撤销上一轮促销:还原 selling_price 到 main_product_original_price 派生值
|
|
1228
|
-
var optionSum = sumOptionUnitPrice(newItem
|
|
1228
|
+
var optionSum = sumOptionUnitPrice(getProductSkuOptions(newItem)).toNumber();
|
|
1229
1229
|
var sourceRestore = new Decimal(originalBasePrice).toDecimalPlaces(2).toFixed(2);
|
|
1230
1230
|
var mainRestore = new Decimal(Number(sourceRestore) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
|
|
1231
1231
|
metadata.source_product_price = sourceRestore;
|
|
@@ -23,6 +23,7 @@ export interface BaseProductDetailPayload {
|
|
|
23
23
|
option?: BaseProductDetailOptionItem[];
|
|
24
24
|
options?: BaseProductDetailOptionItem[];
|
|
25
25
|
product_option_item?: BaseProductDetailOptionItem[];
|
|
26
|
+
product_sku?: Record<string, any>;
|
|
26
27
|
bundle?: BaseProductDetailBundleItem[];
|
|
27
28
|
product_bundle?: BaseProductDetailBundleItem[];
|
|
28
29
|
unique?: string;
|
|
@@ -4,7 +4,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
4
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
5
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
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
|
-
import { composeLinePrice, sumOptionUnitPrice } from "../../../modules/Order/utils";
|
|
7
|
+
import { composeLinePrice, normalizeProductSkuOptions, sumOptionUnitPrice } from "../../../modules/Order/utils";
|
|
8
8
|
import { buildManualProductDiscountItem, mergeManualProductDiscountIntoList, resolveManualDiscountOriginTotal, resolveManualDiscountReasonFromSources, shouldBuildManualProductDiscount } from "../../../modules/Order/utils/manualProductDiscount";
|
|
9
9
|
function toNumber(value) {
|
|
10
10
|
var fallback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
@@ -33,15 +33,16 @@ function toPriceString(value) {
|
|
|
33
33
|
function normalizeOptionItems(optionItems) {
|
|
34
34
|
if (!Array.isArray(optionItems)) return [];
|
|
35
35
|
return optionItems.map(function (optionItem) {
|
|
36
|
-
var _ref, _optionItem$price, _optionItem$num;
|
|
37
|
-
var optionGroupItemId = toNumber(optionItem === null || optionItem === void 0 ? void 0 : optionItem.id);
|
|
36
|
+
var _optionItem$option_gr, _ref, _optionItem$price, _optionItem$num;
|
|
37
|
+
var optionGroupItemId = toNumber((_optionItem$option_gr = optionItem === null || optionItem === void 0 ? void 0 : optionItem.option_group_item_id) !== null && _optionItem$option_gr !== void 0 ? _optionItem$option_gr : optionItem === null || optionItem === void 0 ? void 0 : optionItem.id);
|
|
38
38
|
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;
|
|
39
|
-
return {
|
|
39
|
+
return _objectSpread(_objectSpread({}, optionItem), {}, {
|
|
40
40
|
option_group_item_id: optionGroupItemId,
|
|
41
41
|
option_group_id: toNumber(optionItem === null || optionItem === void 0 ? void 0 : optionItem.option_group_id),
|
|
42
42
|
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),
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
add_price: toNumber(price, 0),
|
|
44
|
+
price: undefined
|
|
45
|
+
});
|
|
45
46
|
});
|
|
46
47
|
}
|
|
47
48
|
function normalizeBundleItems(bundleItems) {
|
|
@@ -76,7 +77,7 @@ function findVariantById(origin, variantId) {
|
|
|
76
77
|
* 注意:这里不生成 identity,缺省时由 OrderModule 自动补齐。
|
|
77
78
|
*/
|
|
78
79
|
export function transformBaseProductToOrderProduct(params) {
|
|
79
|
-
var _ref10, _ref11, _ref12, _payload$product_id, _ref13, _ref14, _payload$product_vari, _payload$_origin, _payload$_origin2, _ref15, _findVariantById, _ref16, _ref17, _ref18, _ref19, _ref20, _ref21, _ref22, _payload$price, _ref23, _payload$line_total, _payload$_extend, _ref24, _payload$
|
|
80
|
+
var _ref10, _ref11, _ref12, _payload$product_id, _ref13, _ref14, _payload$product_vari, _payload$_origin, _payload$_origin2, _ref15, _findVariantById, _ref16, _ref17, _ref18, _ref19, _ref20, _ref21, _ref22, _payload$price, _ref23, _payload$line_total, _payload$_extend, _ref24, _ref25, _payload$product_sku$, _payload$product_sku, _payload$bundle, _payload$quantity, _payload$_extend2, _extend, _extend2, _ref26, _ref27, _origin$base_price, _ref28, _ref29, _payload$line_total2, _payload$_extend3, _payload$_extend4, _extend3, _payload$_extend5, _payload$_extend6, _ref30, _ref31, _payload$tax_fee, _ref32, _ref33, _payload$is_charge_ta;
|
|
80
81
|
var payload = params.payload,
|
|
81
82
|
_params$fallbackProdu = params.fallbackProductId,
|
|
82
83
|
fallbackProductId = _params$fallbackProdu === void 0 ? null : _params$fallbackProdu;
|
|
@@ -91,7 +92,7 @@ export function transformBaseProductToOrderProduct(params) {
|
|
|
91
92
|
var sourceProductPrice = toPriceString((_ref16 = (_ref17 = (_ref18 = (_ref19 = (_ref20 = (_ref21 = (_ref22 = (_payload$price = payload.price) !== null && _payload$price !== void 0 ? _payload$price : payload.selling_price) !== null && _ref22 !== void 0 ? _ref22 : matchedVariant === null || matchedVariant === void 0 ? void 0 : matchedVariant.price) !== null && _ref21 !== void 0 ? _ref21 : matchedVariant === null || matchedVariant === void 0 ? void 0 : matchedVariant.base_price) !== null && _ref20 !== void 0 ? _ref20 : origin === null || origin === void 0 ? void 0 : origin.price) !== null && _ref19 !== void 0 ? _ref19 : origin === null || origin === void 0 ? void 0 : origin.base_price) !== null && _ref18 !== void 0 ? _ref18 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.price) !== null && _ref17 !== void 0 ? _ref17 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.selling_price) !== null && _ref16 !== void 0 ? _ref16 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.base_price, '0.00');
|
|
92
93
|
var lineCompositeTotal = toPriceString((_ref23 = (_payload$line_total = payload.line_total) !== null && _payload$line_total !== void 0 ? _payload$line_total : payload.total) !== null && _ref23 !== void 0 ? _ref23 : (_payload$_extend = payload._extend) === null || _payload$_extend === void 0 ? void 0 : _payload$_extend.total, sourceProductPrice);
|
|
93
94
|
var hasPriceOverride = payload.price_override !== undefined && payload.price_override !== null && payload.price_override !== '';
|
|
94
|
-
var productOptionItem = normalizeOptionItems((_ref24 = (_payload$
|
|
95
|
+
var productOptionItem = normalizeProductSkuOptions(normalizeOptionItems((_ref24 = (_ref25 = (_payload$product_sku$ = (_payload$product_sku = payload.product_sku) === null || _payload$product_sku === void 0 ? void 0 : _payload$product_sku.option) !== null && _payload$product_sku$ !== void 0 ? _payload$product_sku$ : payload.option) !== null && _ref25 !== void 0 ? _ref25 : payload.options) !== null && _ref24 !== void 0 ? _ref24 : payload.product_option_item));
|
|
95
96
|
var productBundle = normalizeBundleItems((_payload$bundle = payload.bundle) !== null && _payload$bundle !== void 0 ? _payload$bundle : payload.product_bundle, hasPriceOverride);
|
|
96
97
|
// `payload.unique` 是业务侧商品/票务标识,可能在连续加同一商品时重复;
|
|
97
98
|
// 行级唯一值只接受显式协议字段,缺省交给 OrderModule 生成。
|
|
@@ -102,10 +103,10 @@ export function transformBaseProductToOrderProduct(params) {
|
|
|
102
103
|
extendOriginTotal: (_payload$_extend2 = payload._extend) === null || _payload$_extend2 === void 0 ? void 0 : _payload$_extend2.origin_total,
|
|
103
104
|
originExtendOriginTotal: origin === null || origin === void 0 || (_extend = origin._extend) === null || _extend === void 0 ? void 0 : _extend.origin_total,
|
|
104
105
|
sourceExtendOriginTotal: sourceProduct === null || sourceProduct === void 0 || (_extend2 = sourceProduct._extend) === null || _extend2 === void 0 ? void 0 : _extend2.origin_total,
|
|
105
|
-
catalogUnitPrice: (
|
|
106
|
+
catalogUnitPrice: (_ref26 = (_ref27 = (_origin$base_price = origin === null || origin === void 0 ? void 0 : origin.base_price) !== null && _origin$base_price !== void 0 ? _origin$base_price : origin === null || origin === void 0 ? void 0 : origin.price) !== null && _ref27 !== void 0 ? _ref27 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.base_price) !== null && _ref26 !== void 0 ? _ref26 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.price,
|
|
106
107
|
quantity: resolvedQuantity
|
|
107
108
|
});
|
|
108
|
-
var sellingTotal = Number((
|
|
109
|
+
var sellingTotal = Number((_ref28 = (_ref29 = (_payload$line_total2 = payload.line_total) !== null && _payload$line_total2 !== void 0 ? _payload$line_total2 : payload.total) !== null && _ref29 !== void 0 ? _ref29 : (_payload$_extend3 = payload._extend) === null || _payload$_extend3 === void 0 ? void 0 : _payload$_extend3.total) !== null && _ref28 !== void 0 ? _ref28 : lineCompositeTotal);
|
|
109
110
|
var discountReason = resolveManualDiscountReasonFromSources({
|
|
110
111
|
discountReason: payload.discount_reason,
|
|
111
112
|
extendDiscountReason: (_payload$_extend4 = payload._extend) === null || _payload$_extend4 === void 0 ? void 0 : _payload$_extend4.discount_reason,
|
|
@@ -163,14 +164,16 @@ export function transformBaseProductToOrderProduct(params) {
|
|
|
163
164
|
product_variant_id: productVariantId,
|
|
164
165
|
unique_identification_number: uniqueIdentificationNumber ? String(uniqueIdentificationNumber) : undefined,
|
|
165
166
|
num: resolvedQuantity,
|
|
166
|
-
|
|
167
|
+
product_sku: _objectSpread(_objectSpread({}, payload.product_sku && _typeof(payload.product_sku) === 'object' ? payload.product_sku : {}), {}, {
|
|
168
|
+
option: productOptionItem
|
|
169
|
+
}),
|
|
167
170
|
product_bundle: productBundle,
|
|
168
171
|
discount_list: manualDiscountList,
|
|
169
172
|
// 折后行价由 normalizeOrderProduct 按 main + bundle 合成;手动改价时 bundle 已为分摊后单价
|
|
170
173
|
selling_price: lineCompositeTotal,
|
|
171
174
|
original_price: lineOriginalPrice,
|
|
172
|
-
tax_fee: toPriceString((
|
|
173
|
-
is_charge_tax: toNumber((
|
|
175
|
+
tax_fee: toPriceString((_ref30 = (_ref31 = (_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 && _ref31 !== void 0 ? _ref31 : origin === null || origin === void 0 ? void 0 : origin.tax_fee) !== null && _ref30 !== void 0 ? _ref30 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.tax_fee, '0.00'),
|
|
176
|
+
is_charge_tax: toNumber((_ref32 = (_ref33 = (_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 && _ref33 !== void 0 ? _ref33 : origin === null || origin === void 0 ? void 0 : origin.is_charge_tax) !== null && _ref32 !== void 0 ? _ref32 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.is_charge_tax, 0),
|
|
174
177
|
metadata: metadata,
|
|
175
178
|
note: payload.note != null ? String(payload.note) : '',
|
|
176
179
|
_origin: _objectSpread(_objectSpread({}, sourceProduct || {}), {}, {
|
|
@@ -12,7 +12,7 @@ export declare function buildProductLineFingerprint(productOptionItem?: unknown,
|
|
|
12
12
|
export declare function getSafeProductNum(num?: number): number;
|
|
13
13
|
/**
|
|
14
14
|
* removeProductFromOrder 仅传 SKU 时的通配 identity(对象上未声明选项键)。
|
|
15
|
-
* 与显式 `
|
|
15
|
+
* 与显式 `product_sku: { option: [] }` 区分:后者只匹配「无选项」行。
|
|
16
16
|
*/
|
|
17
17
|
export declare function isSkuOnlyDeleteIdentity(x: BaseSalesOrderProductIdentity): boolean;
|
|
18
18
|
/**
|
|
@@ -5,7 +5,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
5
5
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
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
7
|
import Decimal from 'decimal.js';
|
|
8
|
-
import { composeLinePrice, createUuidV4, resolveManualOverrideLineOriginalPrice, sumOptionUnitPrice } from "../../modules/Order/utils";
|
|
8
|
+
import { composeLinePrice, createUuidV4, ensureProductSku, normalizeProductSkuOptions, resolveManualOverrideLineOriginalPrice, sumOptionUnitPrice } from "../../modules/Order/utils";
|
|
9
9
|
import { ensureManualProductDiscountList } from "../../modules/Order/utils/manualProductDiscount";
|
|
10
10
|
|
|
11
11
|
/**
|
|
@@ -39,12 +39,12 @@ export function createEmptySummary() {
|
|
|
39
39
|
export function buildProductLineFingerprint(productOptionItem, productBundle) {
|
|
40
40
|
var optArr = Array.isArray(productOptionItem) ? productOptionItem : [];
|
|
41
41
|
var normalizedOpts = optArr.map(function (item) {
|
|
42
|
-
var _item$
|
|
42
|
+
var _ref, _item$add_price;
|
|
43
43
|
return {
|
|
44
44
|
option_group_item_id: Number(item === null || item === void 0 ? void 0 : item.option_group_item_id) || 0,
|
|
45
45
|
option_group_id: Number(item === null || item === void 0 ? void 0 : item.option_group_id) || 0,
|
|
46
46
|
num: typeof (item === null || item === void 0 ? void 0 : item.num) === 'number' && !Number.isNaN(item.num) ? Math.max(1, Math.floor(item.num)) : 1,
|
|
47
|
-
price: String((_item$
|
|
47
|
+
price: String((_ref = (_item$add_price = item === null || item === void 0 ? void 0 : item.add_price) !== null && _item$add_price !== void 0 ? _item$add_price : item === null || item === void 0 ? void 0 : item.price) !== null && _ref !== void 0 ? _ref : '')
|
|
48
48
|
};
|
|
49
49
|
}).sort(function (p, q) {
|
|
50
50
|
if (p.option_group_item_id !== q.option_group_item_id) {
|
|
@@ -56,9 +56,9 @@ export function buildProductLineFingerprint(productOptionItem, productBundle) {
|
|
|
56
56
|
});
|
|
57
57
|
var bundleArr = Array.isArray(productBundle) ? productBundle : [];
|
|
58
58
|
var normalizedBundles = bundleArr.map(function (item) {
|
|
59
|
-
var
|
|
59
|
+
var _ref2, _item$bundle_id;
|
|
60
60
|
return {
|
|
61
|
-
bundle_id: Number((
|
|
61
|
+
bundle_id: Number((_ref2 = (_item$bundle_id = item === null || item === void 0 ? void 0 : item.bundle_id) !== null && _item$bundle_id !== void 0 ? _item$bundle_id : item === null || item === void 0 ? void 0 : item.id) !== null && _ref2 !== void 0 ? _ref2 : 0) || 0,
|
|
62
62
|
product_id: Number(item === null || item === void 0 ? void 0 : item.product_id) || 0,
|
|
63
63
|
num: typeof (item === null || item === void 0 ? void 0 : item.num) === 'number' && !Number.isNaN(item.num) ? Math.max(1, Math.floor(item.num)) : 1
|
|
64
64
|
};
|
|
@@ -77,11 +77,11 @@ export function getSafeProductNum(num) {
|
|
|
77
77
|
|
|
78
78
|
/**
|
|
79
79
|
* removeProductFromOrder 仅传 SKU 时的通配 identity(对象上未声明选项键)。
|
|
80
|
-
* 与显式 `
|
|
80
|
+
* 与显式 `product_sku: { option: [] }` 区分:后者只匹配「无选项」行。
|
|
81
81
|
*/
|
|
82
82
|
export function isSkuOnlyDeleteIdentity(x) {
|
|
83
83
|
if (x.identity_key) return false;
|
|
84
|
-
return !('
|
|
84
|
+
return !('product_sku' in x) && !('product_bundle' in x);
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
/**
|
|
@@ -107,7 +107,7 @@ export function isSkuOnlyDeleteIdentity(x) {
|
|
|
107
107
|
* - 因此多次 normalize 不会重复叠加 option/bundle。
|
|
108
108
|
*/
|
|
109
109
|
export function normalizeOrderProduct(product) {
|
|
110
|
-
var _product$metadata, _metadata$origin, _metadata$origin2, _variantList$find, _product$is_charge_ta;
|
|
110
|
+
var _product$metadata, _metadata$origin, _product$product_sku, _metadata$origin2, _variantList$find, _product$is_charge_ta;
|
|
111
111
|
var metadata = _objectSpread({}, product.metadata || {});
|
|
112
112
|
// 不透明 identity 契约:每条订单行必须带 identity_key。
|
|
113
113
|
// 调用方未传时由 SDK 自动生成 UUID,后续 update/remove 只做严格比对,避免猜测合成 key。
|
|
@@ -119,9 +119,9 @@ export function normalizeOrderProduct(product) {
|
|
|
119
119
|
if (priceOverride !== undefined && priceOverride !== null && priceOverride !== '' && Array.isArray(originOtherBundle) && originOtherBundle.length > 0) {
|
|
120
120
|
var priceById = new Map();
|
|
121
121
|
originOtherBundle.forEach(function (item) {
|
|
122
|
-
var _item$
|
|
122
|
+
var _item$price;
|
|
123
123
|
if ((item === null || item === void 0 ? void 0 : item.id) == null) return;
|
|
124
|
-
var unit = (_item$
|
|
124
|
+
var unit = (_item$price = item.price) !== null && _item$price !== void 0 ? _item$price : item.bundle_selling_price;
|
|
125
125
|
if (unit === undefined || unit === null) return;
|
|
126
126
|
priceById.set(String(item.id), String(unit));
|
|
127
127
|
});
|
|
@@ -136,19 +136,22 @@ export function normalizeOrderProduct(product) {
|
|
|
136
136
|
});
|
|
137
137
|
}
|
|
138
138
|
var normalizedBundle = bundleInput.map(function (item) {
|
|
139
|
-
var _item$bundle_id2, _item$bundle_product_, _item$bundle_group_id,
|
|
139
|
+
var _item$bundle_id2, _item$bundle_product_, _item$bundle_group_id, _ref3, _item$bundle_selling_, _ref4, _ref5, _item$price2, _ref6, _item$price_type, _ref7, _item$price_type_ext;
|
|
140
140
|
return _objectSpread(_objectSpread({}, item), {}, {
|
|
141
141
|
bundle_id: (_item$bundle_id2 = item.bundle_id) !== null && _item$bundle_id2 !== void 0 ? _item$bundle_id2 : item.id,
|
|
142
142
|
bundle_product_id: (_item$bundle_product_ = item.bundle_product_id) !== null && _item$bundle_product_ !== void 0 ? _item$bundle_product_ : item._bundle_product_id,
|
|
143
143
|
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,
|
|
144
|
-
bundle_selling_price: (
|
|
145
|
-
price: (
|
|
146
|
-
price_type: (
|
|
147
|
-
price_type_ext: (
|
|
144
|
+
bundle_selling_price: (_ref3 = (_item$bundle_selling_ = item.bundle_selling_price) !== null && _item$bundle_selling_ !== void 0 ? _item$bundle_selling_ : item.price) !== null && _ref3 !== void 0 ? _ref3 : '0.00',
|
|
145
|
+
price: (_ref4 = (_ref5 = (_item$price2 = item.price) !== null && _item$price2 !== void 0 ? _item$price2 : item.custom_price) !== null && _ref5 !== void 0 ? _ref5 : item.bundle_selling_price) !== null && _ref4 !== void 0 ? _ref4 : '0.00',
|
|
146
|
+
price_type: (_ref6 = (_item$price_type = item.price_type) !== null && _item$price_type !== void 0 ? _item$price_type : item.custom_price_type) !== null && _ref6 !== void 0 ? _ref6 : '',
|
|
147
|
+
price_type_ext: (_ref7 = (_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 && _ref7 !== void 0 ? _ref7 : ''
|
|
148
148
|
});
|
|
149
149
|
});
|
|
150
|
-
var normalizedOptions = product.
|
|
150
|
+
var normalizedOptions = normalizeProductSkuOptions((_product$product_sku = product.product_sku) === null || _product$product_sku === void 0 ? void 0 : _product$product_sku.option);
|
|
151
151
|
var optionSum = sumOptionUnitPrice(normalizedOptions);
|
|
152
|
+
var productSku = _objectSpread(_objectSpread({}, ensureProductSku(product)), {}, {
|
|
153
|
+
option: normalizedOptions
|
|
154
|
+
});
|
|
152
155
|
|
|
153
156
|
// 1) 解析 source_product_price。
|
|
154
157
|
// 优先级:
|
|
@@ -164,7 +167,7 @@ export function normalizeOrderProduct(product) {
|
|
|
164
167
|
var variantPrice = Array.isArray(variantList) ? (_variantList$find = variantList.find(function (v) {
|
|
165
168
|
return Number(v === null || v === void 0 ? void 0 : v.id) === variantId;
|
|
166
169
|
})) === null || _variantList$find === void 0 ? void 0 : _variantList$find.price : undefined;
|
|
167
|
-
var resolvedSource = function (_product$_origin, _product$_origin2,
|
|
170
|
+
var resolvedSource = function (_product$_origin, _product$_origin2, _ref8, _product$original_pri) {
|
|
168
171
|
if (metadata.source_product_price !== undefined) {
|
|
169
172
|
return String(metadata.source_product_price);
|
|
170
173
|
}
|
|
@@ -182,7 +185,7 @@ export function normalizeOrderProduct(product) {
|
|
|
182
185
|
if (!isV2 && metadata.main_product_original_price !== undefined) {
|
|
183
186
|
return String(metadata.main_product_original_price);
|
|
184
187
|
}
|
|
185
|
-
return (
|
|
188
|
+
return (_ref8 = (_product$original_pri = product.original_price) !== null && _product$original_pri !== void 0 ? _product$original_pri : product.selling_price) !== null && _ref8 !== void 0 ? _ref8 : '0.00';
|
|
186
189
|
}();
|
|
187
190
|
|
|
188
191
|
// 2) 派生 main_product_original_price(含 option、不含折扣)
|
|
@@ -247,7 +250,7 @@ export function normalizeOrderProduct(product) {
|
|
|
247
250
|
product_id: product.product_id,
|
|
248
251
|
num: getSafeProductNum(product.num),
|
|
249
252
|
product_variant_id: product.product_variant_id,
|
|
250
|
-
|
|
253
|
+
product_sku: productSku,
|
|
251
254
|
selling_price: composedSellingPrice,
|
|
252
255
|
original_price: finalOriginalPrice,
|
|
253
256
|
tax_fee: product.tax_fee || '0.00',
|
|
@@ -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 |
|
|
314
|
+
weekNum: 0 | 2 | 1 | 5 | 3 | 4 | 6;
|
|
315
315
|
}[]>;
|
|
316
316
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
317
317
|
private getScheduleDataByIds;
|
|
@@ -279,7 +279,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
279
279
|
* 获取当前的客户搜索条件
|
|
280
280
|
* @returns 当前搜索条件
|
|
281
281
|
*/
|
|
282
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
282
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
|
|
283
283
|
/**
|
|
284
284
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
285
285
|
* @returns 客户状态
|
|
@@ -37,7 +37,7 @@ import { createModule } from "../BookingByStep/types";
|
|
|
37
37
|
import { ProductList } from "../../modules/ProductList";
|
|
38
38
|
import { ScheduleModule } from "../../modules/Schedule";
|
|
39
39
|
import { getDateIsInSchedule } from "../../modules/Schedule/getDateIsInSchedule";
|
|
40
|
-
import { composeLinePrice, createUuidV4, normalizeSubmitCollectPaxValue, sumOptionUnitPrice } from "../../modules/Order/utils";
|
|
40
|
+
import { composeLinePrice, createUuidV4, getProductSkuOptions, normalizeSubmitCollectPaxValue, sumOptionUnitPrice } from "../../modules/Order/utils";
|
|
41
41
|
import dayjs from 'dayjs';
|
|
42
42
|
import { ItemRuleEvaluator } from "../../model/strategy/adapter/itemRule";
|
|
43
43
|
export * from "./types";
|
|
@@ -1198,7 +1198,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1198
1198
|
totalPerUnitDiscount = (product.discount_list || []).reduce(function (sum, pd) {
|
|
1199
1199
|
return sum + (pd.amount || 0);
|
|
1200
1200
|
}, 0);
|
|
1201
|
-
optionSum = sumOptionUnitPrice(product
|
|
1201
|
+
optionSum = sumOptionUnitPrice(getProductSkuOptions(product));
|
|
1202
1202
|
sourcePrice = (_product$metadata$sou = (_product$metadata = product.metadata) === null || _product$metadata === void 0 ? void 0 : _product$metadata.source_product_price) !== null && _product$metadata$sou !== void 0 ? _product$metadata$sou : ((_product$metadata2 = product.metadata) === null || _product$metadata2 === void 0 ? void 0 : _product$metadata2.main_product_original_price) != null ? new Decimal(Number(product.metadata.main_product_original_price) || 0).minus(optionSum).toFixed(2) : (_product$original_pri = product.original_price) !== null && _product$original_pri !== void 0 ? _product$original_pri : '0';
|
|
1203
1203
|
newSourceSellingPrice = new Decimal(Number(sourcePrice) || 0).minus(totalPerUnitDiscount).toDecimalPlaces(2).toString();
|
|
1204
1204
|
newMainSellingPrice = new Decimal(Number(newSourceSellingPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
|
|
@@ -1426,7 +1426,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1426
1426
|
original_price: originalPrice,
|
|
1427
1427
|
payment_price: sellingPrice,
|
|
1428
1428
|
is_charge_tax: (_ruleProduct$is_gst = ruleProduct.is_gst) !== null && _ruleProduct$is_gst !== void 0 ? _ruleProduct$is_gst : 0,
|
|
1429
|
-
|
|
1429
|
+
product_sku: {
|
|
1430
|
+
option: []
|
|
1431
|
+
},
|
|
1430
1432
|
discount_list: [],
|
|
1431
1433
|
product_bundle: [],
|
|
1432
1434
|
booking_uid: bookingUuid,
|
|
@@ -1632,8 +1634,8 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1632
1634
|
}
|
|
1633
1635
|
};
|
|
1634
1636
|
if (identity.identity_key !== undefined) params.identity_key = identity.identity_key;
|
|
1635
|
-
if (identity.
|
|
1636
|
-
params.
|
|
1637
|
+
if (identity.product_sku !== undefined) {
|
|
1638
|
+
params.product_sku = identity.product_sku;
|
|
1637
1639
|
}
|
|
1638
1640
|
if (identity.product_bundle !== undefined) params.product_bundle = identity.product_bundle;
|
|
1639
1641
|
_context20.next = 8;
|
|
@@ -33,13 +33,17 @@ export interface ScanOrderOrderProductIdentity {
|
|
|
33
33
|
identity_key?: string;
|
|
34
34
|
unique_identification_number?: string;
|
|
35
35
|
/** 参与合并/匹配;与 remove 通配语义见 isSkuOnlyDeleteIdentity */
|
|
36
|
-
|
|
36
|
+
product_sku?: ScanOrderProductSku;
|
|
37
37
|
product_bundle?: any[];
|
|
38
38
|
}
|
|
39
|
+
export interface ScanOrderProductSku {
|
|
40
|
+
option: any[];
|
|
41
|
+
[key: string]: any;
|
|
42
|
+
}
|
|
39
43
|
export interface ScanOrderOrderProduct extends ScanOrderOrderProductIdentity {
|
|
40
44
|
order_detail_id: number | null;
|
|
41
45
|
num: number;
|
|
42
|
-
|
|
46
|
+
product_sku: ScanOrderProductSku;
|
|
43
47
|
/**
|
|
44
48
|
* 券后 **行 composite 单价** = `metadata.main_product_selling_price`
|
|
45
49
|
* + Σ((bundle.bundle_selling_price ?? bundle.price) × (bundle.num ?? 1))
|
|
@@ -85,9 +89,8 @@ export interface ScanOrderOrderProduct extends ScanOrderOrderProductIdentity {
|
|
|
85
89
|
* 出站 payload 版本的商品行。
|
|
86
90
|
*
|
|
87
91
|
* 与 tempOrder 内部 `ScanOrderOrderProduct` 的字段差异:
|
|
88
|
-
* - `
|
|
89
|
-
*
|
|
90
|
-
* (后端 checkout 协议;丢弃 `price` 等运行时辅助字段)。
|
|
92
|
+
* - `product_sku.option[*]`:内部直接维护统一 Sales 协议字段;
|
|
93
|
+
* 提交时仅规范 `add_price`,保留传入/恢复得到的展示字段。
|
|
91
94
|
* - `product_bundle[*].option[*]`:同上重命名规则。
|
|
92
95
|
*
|
|
93
96
|
* 运行时(UI 显示、加购合并、指纹、持久化)与提交边界统一消费字段名
|
|
@@ -14,9 +14,8 @@ export var ScanOrderHooks = /*#__PURE__*/function (ScanOrderHooks) {
|
|
|
14
14
|
* 出站 payload 版本的商品行。
|
|
15
15
|
*
|
|
16
16
|
* 与 tempOrder 内部 `ScanOrderOrderProduct` 的字段差异:
|
|
17
|
-
* - `
|
|
18
|
-
*
|
|
19
|
-
* (后端 checkout 协议;丢弃 `price` 等运行时辅助字段)。
|
|
17
|
+
* - `product_sku.option[*]`:内部直接维护统一 Sales 协议字段;
|
|
18
|
+
* 提交时仅规范 `add_price`,保留传入/恢复得到的展示字段。
|
|
20
19
|
* - `product_bundle[*].option[*]`:同上重命名规则。
|
|
21
20
|
*
|
|
22
21
|
* 运行时(UI 显示、加购合并、指纹、持久化)与提交边界统一消费字段名
|
|
@@ -88,7 +88,7 @@ export declare function attachItemRuleLimitsToTopLevelProducts<T>(productList: T
|
|
|
88
88
|
export declare function buildProductLineFingerprint(productOptionItem?: unknown, productBundle?: unknown): string;
|
|
89
89
|
/**
|
|
90
90
|
* removeProductFromOrder 仅传 SKU 时的通配 identity(对象上未声明选项键)。
|
|
91
|
-
* 与显式 `
|
|
91
|
+
* 与显式 `product_sku: { option: [] }` 区分:后者只匹配「无选项」行。
|
|
92
92
|
*/
|
|
93
93
|
export declare function isSkuOnlyDeleteIdentity(x: ScanOrderOrderProductIdentity): boolean;
|
|
94
94
|
/**
|