@pisell/pisellos 2.2.198 → 2.2.200
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 +7 -3
- package/dist/modules/Cart/utils/cartProduct.js +11 -1
- package/dist/modules/Cart/utils/changePrice.js +11 -11
- package/dist/modules/Order/index.js +155 -104
- package/dist/modules/Order/types.d.ts +1 -0
- package/dist/modules/Order/utils.d.ts +33 -2
- package/dist/modules/Order/utils.js +112 -55
- package/dist/modules/SalesSummary/utils.js +97 -63
- package/dist/server/index.d.ts +3 -0
- package/dist/server/index.js +294 -190
- package/dist/server/modules/order/index.d.ts +8 -0
- package/dist/server/modules/order/index.js +536 -317
- package/dist/server/modules/order/types.d.ts +2 -0
- package/dist/solution/BaseSales/index.js +2 -1
- package/dist/solution/BaseSales/types.d.ts +1 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +19 -4
- package/dist/solution/BookingTicket/index.d.ts +23 -0
- package/dist/solution/BookingTicket/index.js +291 -196
- package/dist/solution/BookingTicket/utils/bookingStatus.d.ts +40 -0
- package/dist/solution/BookingTicket/utils/bookingStatus.js +70 -0
- package/dist/solution/ScanOrder/types.d.ts +1 -0
- package/dist/solution/ScanOrder/utils.js +26 -9
- package/dist/solution/VenueBooking/index.js +2 -1
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +4 -1
- package/lib/modules/Cart/utils/cartProduct.js +11 -1
- package/lib/modules/Cart/utils/changePrice.js +12 -20
- package/lib/modules/Order/index.js +58 -6
- package/lib/modules/Order/types.d.ts +1 -0
- package/lib/modules/Order/utils.d.ts +33 -2
- package/lib/modules/Order/utils.js +44 -9
- package/lib/modules/SalesSummary/utils.js +41 -44
- package/lib/server/index.d.ts +3 -0
- package/lib/server/index.js +82 -3
- package/lib/server/modules/order/index.d.ts +8 -0
- package/lib/server/modules/order/index.js +106 -4
- package/lib/server/modules/order/types.d.ts +2 -0
- package/lib/solution/BaseSales/index.js +2 -1
- package/lib/solution/BaseSales/types.d.ts +1 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +15 -1
- package/lib/solution/BookingTicket/index.d.ts +23 -0
- package/lib/solution/BookingTicket/index.js +60 -0
- package/lib/solution/BookingTicket/utils/bookingStatus.d.ts +40 -0
- package/lib/solution/BookingTicket/utils/bookingStatus.js +44 -2
- package/lib/solution/ScanOrder/types.d.ts +1 -0
- package/lib/solution/ScanOrder/utils.js +28 -10
- package/lib/solution/VenueBooking/index.js +2 -1
- package/package.json +1 -1
|
@@ -61,10 +61,14 @@ function mapOrderBundleToOtherBundle(bundle) {
|
|
|
61
61
|
var selling = (_ref3 = (_item$bundle_selling_ = item.bundle_selling_price) !== null && _item$bundle_selling_ !== void 0 ? _item$bundle_selling_ : item.price) !== null && _ref3 !== void 0 ? _ref3 : catalogOriginal;
|
|
62
62
|
var _omitBundleSelling = item.bundle_selling_price,
|
|
63
63
|
rest = _objectWithoutProperties(item, _excluded);
|
|
64
|
-
|
|
64
|
+
var isMarkupOrMarkdown = (item.price_type === 'markdown' || item.price_type === 'markup') && (item.price_type_ext === '' || item.price_type_ext === undefined || item.price_type_ext === null);
|
|
65
|
+
if (isMarkupOrMarkdown) delete rest.original_total;
|
|
66
|
+
return _objectSpread(_objectSpread(_objectSpread({}, rest), {}, {
|
|
65
67
|
price: selling,
|
|
66
|
-
original_price: catalogOriginal
|
|
67
|
-
|
|
68
|
+
original_price: catalogOriginal
|
|
69
|
+
}, isMarkupOrMarkdown ? {} : {
|
|
70
|
+
original_total: (_item$original_total = item.original_total) !== null && _item$original_total !== void 0 ? _item$original_total : catalogOriginal
|
|
71
|
+
}), {}, {
|
|
68
72
|
num: (_ref4 = (_item$num = item.num) !== null && _item$num !== void 0 ? _item$num : item.quantity) !== null && _ref4 !== void 0 ? _ref4 : 1,
|
|
69
73
|
quantity: (_ref5 = (_item$quantity = item.quantity) !== null && _item$quantity !== void 0 ? _item$quantity : item.num) !== null && _ref5 !== void 0 ? _ref5 : 1
|
|
70
74
|
});
|
|
@@ -14,6 +14,7 @@ import Decimal from 'decimal.js';
|
|
|
14
14
|
import { isNormalProduct } from "../../Product/utils";
|
|
15
15
|
import { getDiscountAmount } from "../../../solution/ShopDiscount/utils";
|
|
16
16
|
import { calcDiscountListDifference } from "../../Summary/utils";
|
|
17
|
+
import { getBundleSellingMagnitude } from "../../Order/utils";
|
|
17
18
|
|
|
18
19
|
/** 与 Rules / ShopDiscount 一致的折扣入参,用于主价与 option 单价 */
|
|
19
20
|
var toDiscountPayload = function toDiscountPayload(discountItem) {
|
|
@@ -374,6 +375,7 @@ export var formatBundle = function formatBundle(bundle) {
|
|
|
374
375
|
export var formatBundleToOrigin = function formatBundleToOrigin(bundle) {
|
|
375
376
|
if (!(bundle !== null && bundle !== void 0 && bundle.length)) return [];
|
|
376
377
|
return bundle.map(function (d) {
|
|
378
|
+
var _d$price, _d$price_type, _d$price_type_ext;
|
|
377
379
|
var getBundleValueByKey = function getBundleValueByKey(key) {
|
|
378
380
|
var _d$originBundleItem;
|
|
379
381
|
return (d === null || d === void 0 ? void 0 : d[key]) || (d === null || d === void 0 || (_d$originBundleItem = d.originBundleItem) === null || _d$originBundleItem === void 0 ? void 0 : _d$originBundleItem[key]);
|
|
@@ -382,6 +384,14 @@ export var formatBundleToOrigin = function formatBundleToOrigin(bundle) {
|
|
|
382
384
|
var _cur$metadata2;
|
|
383
385
|
return pre + ((cur === null || cur === void 0 || (_cur$metadata2 = cur.metadata) === null || _cur$metadata2 === void 0 ? void 0 : _cur$metadata2.product_discount_difference) || 0);
|
|
384
386
|
}, 0);
|
|
387
|
+
var normalizedBundle = _objectSpread(_objectSpread({}, d), {}, {
|
|
388
|
+
// 计算 markdown 净额时只传真实毛价;若仅有 bundle_selling_price,则由 helper 当历史净额兜底。
|
|
389
|
+
price: (_d$price = d === null || d === void 0 ? void 0 : d.price) !== null && _d$price !== void 0 ? _d$price : d === null || d === void 0 ? void 0 : d.custom_price,
|
|
390
|
+
bundle_selling_price: d === null || d === void 0 ? void 0 : d.bundle_selling_price,
|
|
391
|
+
price_type: (_d$price_type = d === null || d === void 0 ? void 0 : d.price_type) !== null && _d$price_type !== void 0 ? _d$price_type : d === null || d === void 0 ? void 0 : d.custom_price_type,
|
|
392
|
+
price_type_ext: (_d$price_type_ext = d === null || d === void 0 ? void 0 : d.price_type_ext) !== null && _d$price_type_ext !== void 0 ? _d$price_type_ext : d === null || d === void 0 ? void 0 : d.custom_price_type_ext,
|
|
393
|
+
option: getBundleValueByKey('option')
|
|
394
|
+
});
|
|
385
395
|
return {
|
|
386
396
|
bundle_group_id: getBundleValueByKey('group_id'),
|
|
387
397
|
bundle_id: d.id,
|
|
@@ -392,7 +402,7 @@ export var formatBundleToOrigin = function formatBundleToOrigin(bundle) {
|
|
|
392
402
|
extension_type: getBundleValueByKey('extension_type'),
|
|
393
403
|
option: formatOptionsToOrigin(getBundleValueByKey('option')),
|
|
394
404
|
discount_list: d.discount_list,
|
|
395
|
-
"bundle_selling_price":
|
|
405
|
+
"bundle_selling_price": getBundleSellingMagnitude(normalizedBundle).toFixed(2),
|
|
396
406
|
"custom_price": d === null || d === void 0 ? void 0 : d.price,
|
|
397
407
|
metadata: {
|
|
398
408
|
custom_product_bundle_map_id: d._id,
|
|
@@ -10,7 +10,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
10
10
|
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; }
|
|
11
11
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
12
12
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
13
|
-
import
|
|
13
|
+
import { getBundleSellingMagnitude } from "../../Order/utils";
|
|
14
14
|
export function updateAllCartItemPrice(_x, _x2, _x3, _x4, _x5) {
|
|
15
15
|
return _updateAllCartItemPrice.apply(this, arguments);
|
|
16
16
|
}
|
|
@@ -54,18 +54,18 @@ function _updateAllCartItemPrice() {
|
|
|
54
54
|
var targetBundleItem = targetBundle.bundle_item.find(function (m) {
|
|
55
55
|
return m.id === n.id;
|
|
56
56
|
});
|
|
57
|
-
if (targetBundleItem.price_type === 'markdown') {
|
|
58
|
-
targetBundleItem.price = new Decimal(targetBundleItem.price || 0).mul(-1).toNumber();
|
|
59
|
-
}
|
|
60
|
-
// 如果有选择 option,还需要加上 option 的价格
|
|
61
|
-
if (n.option) {
|
|
62
|
-
targetBundleItem.price = new Decimal(targetBundleItem.price || 0).add(n.option.reduce(function (pre, cur) {
|
|
63
|
-
return pre + new Decimal(cur.price || 0).mul(cur.num || 1).toNumber();
|
|
64
|
-
}, 0)).toNumber();
|
|
65
|
-
}
|
|
66
57
|
if (targetBundleItem) {
|
|
67
|
-
|
|
58
|
+
var normalizedBundle = _objectSpread(_objectSpread({}, n), {}, {
|
|
68
59
|
price: targetBundleItem.price,
|
|
60
|
+
custom_price: targetBundleItem.price,
|
|
61
|
+
price_type: targetBundleItem.price_type,
|
|
62
|
+
price_type_ext: targetBundleItem.price_type_ext
|
|
63
|
+
});
|
|
64
|
+
var bundleSellingPrice = getBundleSellingMagnitude(normalizedBundle).toFixed(2);
|
|
65
|
+
return _objectSpread(_objectSpread({}, n), {}, {
|
|
66
|
+
custom_price: targetBundleItem.price,
|
|
67
|
+
price: targetBundleItem.price_type === 'markdown' ? bundleSellingPrice : targetBundleItem.price,
|
|
68
|
+
bundle_selling_price: bundleSellingPrice,
|
|
69
69
|
base_price: targetBundleItem.base_price
|
|
70
70
|
});
|
|
71
71
|
}
|
|
@@ -1291,6 +1291,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1291
1291
|
key: "syncSummaryProductMetadata",
|
|
1292
1292
|
value: function syncSummaryProductMetadata(products) {
|
|
1293
1293
|
var moneyKeys = ['main_product_attached_bundle_surcharge_fee', 'main_product_attached_bundle_tax_fee', 'surcharge_rounding_remainder', 'tax_fee_rounding_remainder'];
|
|
1294
|
+
// 整单折扣均摊层产出的 payment 维度字段,直接由计算层写入 metadata,
|
|
1295
|
+
// 这里需把它们一并回写到商品 metadata 以便持久化/出站。
|
|
1296
|
+
var metadataMoneyKeys = ['main_product_attached_bundle_selling_price', 'main_product_attached_bundle_payment_price'];
|
|
1294
1297
|
var _iterator8 = _createForOfIteratorHelper(products || []),
|
|
1295
1298
|
_step8;
|
|
1296
1299
|
try {
|
|
@@ -1314,17 +1317,39 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1314
1317
|
} finally {
|
|
1315
1318
|
_iterator9.f();
|
|
1316
1319
|
}
|
|
1320
|
+
var _iterator10 = _createForOfIteratorHelper(metadataMoneyKeys),
|
|
1321
|
+
_step10;
|
|
1322
|
+
try {
|
|
1323
|
+
for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
|
|
1324
|
+
var _key = _step10.value;
|
|
1325
|
+
var _value = this.formatSummaryMetadataMoney(metadata[_key]);
|
|
1326
|
+
if (_value === undefined) continue;
|
|
1327
|
+
metadata[_key] = _value;
|
|
1328
|
+
hasMetadataPatch = true;
|
|
1329
|
+
}
|
|
1330
|
+
} catch (err) {
|
|
1331
|
+
_iterator10.e(err);
|
|
1332
|
+
} finally {
|
|
1333
|
+
_iterator10.f();
|
|
1334
|
+
}
|
|
1335
|
+
if (metadata.average_discount_amount_rate !== undefined) {
|
|
1336
|
+
hasMetadataPatch = true;
|
|
1337
|
+
}
|
|
1317
1338
|
if (Array.isArray(productRecord.relation_surcharge_ids)) {
|
|
1318
1339
|
metadata.relation_surcharge_ids = productRecord.relation_surcharge_ids;
|
|
1319
1340
|
hasMetadataPatch = true;
|
|
1320
1341
|
}
|
|
1342
|
+
var productPaymentPrice = this.formatSummaryMetadataMoney(productRecord.payment_price);
|
|
1343
|
+
if (productPaymentPrice !== undefined) {
|
|
1344
|
+
productRecord.payment_price = productPaymentPrice;
|
|
1345
|
+
}
|
|
1321
1346
|
if (hasMetadataPatch) productRecord.metadata = metadata;
|
|
1322
1347
|
if (!Array.isArray(productRecord.product_bundle)) continue;
|
|
1323
|
-
var
|
|
1324
|
-
|
|
1348
|
+
var _iterator11 = _createForOfIteratorHelper(productRecord.product_bundle),
|
|
1349
|
+
_step11;
|
|
1325
1350
|
try {
|
|
1326
|
-
for (
|
|
1327
|
-
var bundle =
|
|
1351
|
+
for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
|
|
1352
|
+
var bundle = _step11.value;
|
|
1328
1353
|
var bundleRecord = bundle;
|
|
1329
1354
|
var bundleMetadata = bundleRecord.metadata && _typeof(bundleRecord.metadata) === 'object' ? _objectSpread({}, bundleRecord.metadata) : {};
|
|
1330
1355
|
var hasBundleMetadataPatch = false;
|
|
@@ -1333,6 +1358,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1333
1358
|
bundleMetadata.surcharge_fee = bundleSurchargeFee;
|
|
1334
1359
|
hasBundleMetadataPatch = true;
|
|
1335
1360
|
}
|
|
1361
|
+
var bundlePaymentPrice = this.formatSummaryMetadataMoney(bundleRecord.bundle_payment_price);
|
|
1362
|
+
if (bundlePaymentPrice !== undefined) {
|
|
1363
|
+
bundleRecord.bundle_payment_price = bundlePaymentPrice;
|
|
1364
|
+
}
|
|
1336
1365
|
if (Array.isArray(bundleRecord.relation_surcharge_ids)) {
|
|
1337
1366
|
bundleMetadata.relation_surcharge_ids = bundleRecord.relation_surcharge_ids;
|
|
1338
1367
|
hasBundleMetadataPatch = true;
|
|
@@ -1340,9 +1369,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1340
1369
|
if (hasBundleMetadataPatch) bundleRecord.metadata = bundleMetadata;
|
|
1341
1370
|
}
|
|
1342
1371
|
} catch (err) {
|
|
1343
|
-
|
|
1372
|
+
_iterator11.e(err);
|
|
1344
1373
|
} finally {
|
|
1345
|
-
|
|
1374
|
+
_iterator11.f();
|
|
1346
1375
|
}
|
|
1347
1376
|
}
|
|
1348
1377
|
} catch (err) {
|
|
@@ -1615,82 +1644,82 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1615
1644
|
value: function clearPersistedAmountFieldsForFullRecalc(products) {
|
|
1616
1645
|
var moneyKeys = ['surcharge_fee', 'main_product_attached_bundle_surcharge_fee', 'surcharge_rounding_remainder', 'main_product_attached_bundle_tax_fee', 'tax_fee', 'original_tax_fee', 'tax_fee_rounding_remainder', 'original_tax_fee_rounding_remainder'];
|
|
1617
1646
|
var metadataMoneyKeys = ['main_product_attached_bundle_surcharge_fee', 'surcharge_rounding_remainder', 'main_product_attached_bundle_tax_fee', 'tax_fee_rounding_remainder'];
|
|
1618
|
-
var
|
|
1619
|
-
|
|
1647
|
+
var _iterator12 = _createForOfIteratorHelper(products || []),
|
|
1648
|
+
_step12;
|
|
1620
1649
|
try {
|
|
1621
|
-
for (
|
|
1622
|
-
var product =
|
|
1650
|
+
for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
|
|
1651
|
+
var product = _step12.value;
|
|
1623
1652
|
var record = product;
|
|
1624
|
-
var
|
|
1625
|
-
|
|
1653
|
+
var _iterator13 = _createForOfIteratorHelper(moneyKeys),
|
|
1654
|
+
_step13;
|
|
1626
1655
|
try {
|
|
1627
|
-
for (
|
|
1628
|
-
var
|
|
1629
|
-
delete record[
|
|
1656
|
+
for (_iterator13.s(); !(_step13 = _iterator13.n()).done;) {
|
|
1657
|
+
var _key2 = _step13.value;
|
|
1658
|
+
delete record[_key2];
|
|
1630
1659
|
}
|
|
1631
1660
|
} catch (err) {
|
|
1632
|
-
|
|
1661
|
+
_iterator13.e(err);
|
|
1633
1662
|
} finally {
|
|
1634
|
-
|
|
1663
|
+
_iterator13.f();
|
|
1635
1664
|
}
|
|
1636
1665
|
if (record.metadata && _typeof(record.metadata) === 'object') {
|
|
1637
1666
|
record.metadata = _objectSpread({}, record.metadata);
|
|
1638
|
-
var
|
|
1639
|
-
|
|
1667
|
+
var _iterator14 = _createForOfIteratorHelper(metadataMoneyKeys),
|
|
1668
|
+
_step14;
|
|
1640
1669
|
try {
|
|
1641
|
-
for (
|
|
1642
|
-
var key =
|
|
1670
|
+
for (_iterator14.s(); !(_step14 = _iterator14.n()).done;) {
|
|
1671
|
+
var key = _step14.value;
|
|
1643
1672
|
delete record.metadata[key];
|
|
1644
1673
|
}
|
|
1645
1674
|
} catch (err) {
|
|
1646
|
-
|
|
1675
|
+
_iterator14.e(err);
|
|
1647
1676
|
} finally {
|
|
1648
|
-
|
|
1677
|
+
_iterator14.f();
|
|
1649
1678
|
}
|
|
1650
1679
|
}
|
|
1651
|
-
var
|
|
1652
|
-
|
|
1680
|
+
var _iterator15 = _createForOfIteratorHelper(record.product_bundle || []),
|
|
1681
|
+
_step15;
|
|
1653
1682
|
try {
|
|
1654
|
-
for (
|
|
1655
|
-
var bundle =
|
|
1656
|
-
var
|
|
1657
|
-
|
|
1683
|
+
for (_iterator15.s(); !(_step15 = _iterator15.n()).done;) {
|
|
1684
|
+
var bundle = _step15.value;
|
|
1685
|
+
var _iterator16 = _createForOfIteratorHelper(moneyKeys),
|
|
1686
|
+
_step16;
|
|
1658
1687
|
try {
|
|
1659
|
-
for (
|
|
1660
|
-
var
|
|
1661
|
-
delete bundle[
|
|
1688
|
+
for (_iterator16.s(); !(_step16 = _iterator16.n()).done;) {
|
|
1689
|
+
var _key4 = _step16.value;
|
|
1690
|
+
delete bundle[_key4];
|
|
1662
1691
|
}
|
|
1663
1692
|
} catch (err) {
|
|
1664
|
-
|
|
1693
|
+
_iterator16.e(err);
|
|
1665
1694
|
} finally {
|
|
1666
|
-
|
|
1695
|
+
_iterator16.f();
|
|
1667
1696
|
}
|
|
1668
1697
|
if (bundle.metadata && _typeof(bundle.metadata) === 'object') {
|
|
1669
1698
|
bundle.metadata = _objectSpread({}, bundle.metadata);
|
|
1670
|
-
var
|
|
1671
|
-
|
|
1699
|
+
var _iterator17 = _createForOfIteratorHelper(metadataMoneyKeys),
|
|
1700
|
+
_step17;
|
|
1672
1701
|
try {
|
|
1673
|
-
for (
|
|
1674
|
-
var
|
|
1675
|
-
delete bundle.metadata[
|
|
1702
|
+
for (_iterator17.s(); !(_step17 = _iterator17.n()).done;) {
|
|
1703
|
+
var _key3 = _step17.value;
|
|
1704
|
+
delete bundle.metadata[_key3];
|
|
1676
1705
|
}
|
|
1677
1706
|
} catch (err) {
|
|
1678
|
-
|
|
1707
|
+
_iterator17.e(err);
|
|
1679
1708
|
} finally {
|
|
1680
|
-
|
|
1709
|
+
_iterator17.f();
|
|
1681
1710
|
}
|
|
1682
1711
|
}
|
|
1683
1712
|
}
|
|
1684
1713
|
} catch (err) {
|
|
1685
|
-
|
|
1714
|
+
_iterator15.e(err);
|
|
1686
1715
|
} finally {
|
|
1687
|
-
|
|
1716
|
+
_iterator15.f();
|
|
1688
1717
|
}
|
|
1689
1718
|
}
|
|
1690
1719
|
} catch (err) {
|
|
1691
|
-
|
|
1720
|
+
_iterator12.e(err);
|
|
1692
1721
|
} finally {
|
|
1693
|
-
|
|
1722
|
+
_iterator12.f();
|
|
1694
1723
|
}
|
|
1695
1724
|
}
|
|
1696
1725
|
}, {
|
|
@@ -2562,21 +2591,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2562
2591
|
value: function updateVoucherOrderPayments(payments) {
|
|
2563
2592
|
var _this15 = this;
|
|
2564
2593
|
var tempOrder = this.ensureTempOrder();
|
|
2594
|
+
var isVoucherPayment = function isVoucherPayment(payment) {
|
|
2595
|
+
return payment.voucher_id !== undefined && Number(payment.voucher_id) !== 0;
|
|
2596
|
+
};
|
|
2597
|
+
var hasSyncedOrderPayment = function hasSyncedOrderPayment(payment) {
|
|
2598
|
+
return payment.order_payment_id !== undefined && payment.order_payment_id !== null;
|
|
2599
|
+
};
|
|
2565
2600
|
var mappedVouchers = mapPaymentItemsToOrderPayments(payments.map(function (payment) {
|
|
2566
2601
|
return _this15.normalizePaymentSource(payment, {
|
|
2567
2602
|
defaultPaid: true
|
|
2568
2603
|
});
|
|
2569
2604
|
})).filter(function (payment) {
|
|
2570
|
-
return
|
|
2605
|
+
return isVoucherPayment(payment);
|
|
2571
2606
|
});
|
|
2572
2607
|
var nonVoucherPayments = (tempOrder.payments || []).filter(function (payment) {
|
|
2573
|
-
return
|
|
2608
|
+
return !isVoucherPayment(payment);
|
|
2609
|
+
});
|
|
2610
|
+
var syncedVoucherPayments = (tempOrder.payments || []).filter(function (payment) {
|
|
2611
|
+
return isVoucherPayment(payment) && hasSyncedOrderPayment(payment);
|
|
2612
|
+
});
|
|
2613
|
+
var syncedVoucherPaymentIds = new Set(syncedVoucherPayments.map(function (payment) {
|
|
2614
|
+
return String(payment.order_payment_id);
|
|
2615
|
+
}));
|
|
2616
|
+
var replaceableVouchers = mappedVouchers.filter(function (payment) {
|
|
2617
|
+
if (!hasSyncedOrderPayment(payment)) return true;
|
|
2618
|
+
return !syncedVoucherPaymentIds.has(String(payment.order_payment_id));
|
|
2574
2619
|
});
|
|
2575
2620
|
var cappedVouchers = this.capVoucherPaymentsByRemainingAmount({
|
|
2576
|
-
vouchers:
|
|
2577
|
-
nonVoucherPayments: nonVoucherPayments
|
|
2621
|
+
vouchers: replaceableVouchers,
|
|
2622
|
+
nonVoucherPayments: [].concat(_toConsumableArray(nonVoucherPayments), _toConsumableArray(syncedVoucherPayments))
|
|
2578
2623
|
});
|
|
2579
|
-
tempOrder.payments = [].concat(_toConsumableArray(nonVoucherPayments), _toConsumableArray(cappedVouchers));
|
|
2624
|
+
tempOrder.payments = [].concat(_toConsumableArray(nonVoucherPayments), _toConsumableArray(syncedVoucherPayments), _toConsumableArray(cappedVouchers));
|
|
2580
2625
|
this.updateTempOrderPaymentStatus(tempOrder);
|
|
2581
2626
|
this.persistTempOrder();
|
|
2582
2627
|
void this.recalculateSummary({
|
|
@@ -3857,14 +3902,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3857
3902
|
value: (function () {
|
|
3858
3903
|
var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(record, options) {
|
|
3859
3904
|
var _this$store$discount13, _this$store$discount14;
|
|
3860
|
-
var raw, nextTempOrder, hydratedEditDiscounts;
|
|
3905
|
+
var raw, nextTempOrder, rawSummary, summarySurcharges, hydratedEditDiscounts;
|
|
3861
3906
|
return _regeneratorRuntime().wrap(function _callee29$(_context31) {
|
|
3862
3907
|
while (1) switch (_context31.prev = _context31.next) {
|
|
3863
3908
|
case 0:
|
|
3864
3909
|
raw = record && _typeof(record) === 'object' && record.data && record.order_id == null ? record.data : record || {};
|
|
3865
3910
|
nextTempOrder = this.normalizeTempOrderForRuntime(raw);
|
|
3911
|
+
rawSummary = raw.summary && _typeof(raw.summary) === 'object' ? raw.summary : {};
|
|
3912
|
+
summarySurcharges = Array.isArray(rawSummary.surcharges) ? rawSummary.surcharges.map(function (s) {
|
|
3913
|
+
return _objectSpread({}, s || {});
|
|
3914
|
+
}) : cloneDeep(nextTempOrder.surcharges || []);
|
|
3866
3915
|
this.store.tempOrder = nextTempOrder;
|
|
3867
|
-
this.store.summary =
|
|
3916
|
+
this.store.summary = _objectSpread(_objectSpread(_objectSpread({}, createEmptySummary()), rawSummary), {}, {
|
|
3917
|
+
surcharges: summarySurcharges
|
|
3918
|
+
});
|
|
3868
3919
|
nextTempOrder._extend = _objectSpread(_objectSpread({}, nextTempOrder._extend || {}), {}, {
|
|
3869
3920
|
originalSalesSnapshot: {
|
|
3870
3921
|
summary: cloneDeep(this.store.summary),
|
|
@@ -3876,24 +3927,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3876
3927
|
});
|
|
3877
3928
|
this.store.lastOrderInfo = raw.lastOrderInfo || raw;
|
|
3878
3929
|
hydratedEditDiscounts = this.collectHydratedEditDiscounts(nextTempOrder.products);
|
|
3879
|
-
_context31.next = 9;
|
|
3880
|
-
return (_this$store$discount13 = this.store.discount) === null || _this$store$discount13 === void 0 ? void 0 : _this$store$discount13.setOriginalDiscountList(hydratedEditDiscounts);
|
|
3881
|
-
case 9:
|
|
3882
3930
|
_context31.next = 11;
|
|
3883
|
-
return (_this$store$
|
|
3931
|
+
return (_this$store$discount13 = this.store.discount) === null || _this$store$discount13 === void 0 ? void 0 : _this$store$discount13.setOriginalDiscountList(hydratedEditDiscounts);
|
|
3884
3932
|
case 11:
|
|
3933
|
+
_context31.next = 13;
|
|
3934
|
+
return (_this$store$discount14 = this.store.discount) === null || _this$store$discount14 === void 0 ? void 0 : _this$store$discount14.setDiscountList(hydratedEditDiscounts);
|
|
3935
|
+
case 13:
|
|
3885
3936
|
if (!(options !== null && options !== void 0 && options.recalcOnHydrate)) {
|
|
3886
|
-
_context31.next =
|
|
3937
|
+
_context31.next = 16;
|
|
3887
3938
|
break;
|
|
3888
3939
|
}
|
|
3889
|
-
_context31.next =
|
|
3940
|
+
_context31.next = 16;
|
|
3890
3941
|
return this.recalculateSummary({
|
|
3891
3942
|
createIfMissing: false
|
|
3892
3943
|
});
|
|
3893
|
-
case
|
|
3944
|
+
case 16:
|
|
3894
3945
|
this.persistTempOrder();
|
|
3895
3946
|
return _context31.abrupt("return", nextTempOrder);
|
|
3896
|
-
case
|
|
3947
|
+
case 18:
|
|
3897
3948
|
case "end":
|
|
3898
3949
|
return _context31.stop();
|
|
3899
3950
|
}
|
|
@@ -3954,14 +4005,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3954
4005
|
};
|
|
3955
4006
|
var tempOrderExtend = nextTempOrder._extend;
|
|
3956
4007
|
var productsByUid = tempOrderExtend.productsByUid || {};
|
|
3957
|
-
var
|
|
3958
|
-
|
|
4008
|
+
var _iterator18 = _createForOfIteratorHelper(nextTempOrder.products.entries()),
|
|
4009
|
+
_step18;
|
|
3959
4010
|
try {
|
|
3960
|
-
for (
|
|
4011
|
+
for (_iterator18.s(); !(_step18 = _iterator18.n()).done;) {
|
|
3961
4012
|
var _product$metadata7, _ref64, _ref65, _existed$origin, _rawProduct$metadata;
|
|
3962
|
-
var
|
|
3963
|
-
index =
|
|
3964
|
-
product =
|
|
4013
|
+
var _step18$value = _slicedToArray(_step18.value, 2),
|
|
4014
|
+
index = _step18$value[0],
|
|
4015
|
+
product = _step18$value[1];
|
|
3965
4016
|
var uid = (_product$metadata7 = product.metadata) === null || _product$metadata7 === void 0 ? void 0 : _product$metadata7.unique_identification_number;
|
|
3966
4017
|
if (!uid) continue;
|
|
3967
4018
|
var existed = productsByUid[uid] && _typeof(productsByUid[uid]) === 'object' ? productsByUid[uid] : {};
|
|
@@ -3982,9 +4033,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3982
4033
|
});
|
|
3983
4034
|
}
|
|
3984
4035
|
} catch (err) {
|
|
3985
|
-
|
|
4036
|
+
_iterator18.e(err);
|
|
3986
4037
|
} finally {
|
|
3987
|
-
|
|
4038
|
+
_iterator18.f();
|
|
3988
4039
|
}
|
|
3989
4040
|
tempOrderExtend.productsByUid = productsByUid;
|
|
3990
4041
|
if ((options === null || options === void 0 ? void 0 : options.ensureIdentity) !== false) {
|
|
@@ -4015,18 +4066,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4015
4066
|
var segments = [];
|
|
4016
4067
|
var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
|
|
4017
4068
|
if (Array.isArray(sku.variant)) {
|
|
4018
|
-
var
|
|
4019
|
-
|
|
4069
|
+
var _iterator19 = _createForOfIteratorHelper(sku.variant),
|
|
4070
|
+
_step19;
|
|
4020
4071
|
try {
|
|
4021
|
-
for (
|
|
4022
|
-
var variant =
|
|
4072
|
+
for (_iterator19.s(); !(_step19 = _iterator19.n()).done;) {
|
|
4073
|
+
var variant = _step19.value;
|
|
4023
4074
|
var segment = this.formatHydratedNamePair(variant === null || variant === void 0 ? void 0 : variant.group, variant === null || variant === void 0 ? void 0 : variant.item);
|
|
4024
4075
|
if (segment) segments.push(segment);
|
|
4025
4076
|
}
|
|
4026
4077
|
} catch (err) {
|
|
4027
|
-
|
|
4078
|
+
_iterator19.e(err);
|
|
4028
4079
|
} finally {
|
|
4029
|
-
|
|
4080
|
+
_iterator19.f();
|
|
4030
4081
|
}
|
|
4031
4082
|
}
|
|
4032
4083
|
return segments.join(', ');
|
|
@@ -4128,67 +4179,67 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4128
4179
|
var amount = new Decimal(discount.amount || 0).times(qty).plus(((_discount$metadata = discount.metadata) === null || _discount$metadata === void 0 ? void 0 : _discount$metadata.product_discount_difference) || 0);
|
|
4129
4180
|
savedMap.set(discountKey, (savedMap.get(discountKey) || new Decimal(0)).plus(amount));
|
|
4130
4181
|
};
|
|
4131
|
-
var
|
|
4132
|
-
|
|
4182
|
+
var _iterator20 = _createForOfIteratorHelper(productList),
|
|
4183
|
+
_step20;
|
|
4133
4184
|
try {
|
|
4134
|
-
for (
|
|
4135
|
-
var product =
|
|
4185
|
+
for (_iterator20.s(); !(_step20 = _iterator20.n()).done;) {
|
|
4186
|
+
var product = _step20.value;
|
|
4136
4187
|
var qty = product.num || 1;
|
|
4137
|
-
var
|
|
4138
|
-
|
|
4188
|
+
var _iterator22 = _createForOfIteratorHelper(product.discount_list || []),
|
|
4189
|
+
_step22;
|
|
4139
4190
|
try {
|
|
4140
|
-
for (
|
|
4141
|
-
var pd =
|
|
4191
|
+
for (_iterator22.s(); !(_step22 = _iterator22.n()).done;) {
|
|
4192
|
+
var pd = _step22.value;
|
|
4142
4193
|
addDiscountAmount(pd, qty);
|
|
4143
4194
|
}
|
|
4144
4195
|
} catch (err) {
|
|
4145
|
-
|
|
4196
|
+
_iterator22.e(err);
|
|
4146
4197
|
} finally {
|
|
4147
|
-
|
|
4198
|
+
_iterator22.f();
|
|
4148
4199
|
}
|
|
4149
|
-
var
|
|
4150
|
-
|
|
4200
|
+
var _iterator23 = _createForOfIteratorHelper(product.product_bundle || []),
|
|
4201
|
+
_step23;
|
|
4151
4202
|
try {
|
|
4152
|
-
for (
|
|
4203
|
+
for (_iterator23.s(); !(_step23 = _iterator23.n()).done;) {
|
|
4153
4204
|
var _ref68, _bundle$num3;
|
|
4154
|
-
var bundle =
|
|
4205
|
+
var bundle = _step23.value;
|
|
4155
4206
|
var bundleQty = new Decimal(Number(qty) || 1).times(Number((_ref68 = (_bundle$num3 = bundle === null || bundle === void 0 ? void 0 : bundle.num) !== null && _bundle$num3 !== void 0 ? _bundle$num3 : bundle === null || bundle === void 0 ? void 0 : bundle.quantity) !== null && _ref68 !== void 0 ? _ref68 : 1) || 1).toNumber();
|
|
4156
|
-
var
|
|
4157
|
-
|
|
4207
|
+
var _iterator24 = _createForOfIteratorHelper((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []),
|
|
4208
|
+
_step24;
|
|
4158
4209
|
try {
|
|
4159
|
-
for (
|
|
4160
|
-
var _pd =
|
|
4210
|
+
for (_iterator24.s(); !(_step24 = _iterator24.n()).done;) {
|
|
4211
|
+
var _pd = _step24.value;
|
|
4161
4212
|
addDiscountAmount(_pd, bundleQty);
|
|
4162
4213
|
}
|
|
4163
4214
|
} catch (err) {
|
|
4164
|
-
|
|
4215
|
+
_iterator24.e(err);
|
|
4165
4216
|
} finally {
|
|
4166
|
-
|
|
4217
|
+
_iterator24.f();
|
|
4167
4218
|
}
|
|
4168
4219
|
}
|
|
4169
4220
|
} catch (err) {
|
|
4170
|
-
|
|
4221
|
+
_iterator23.e(err);
|
|
4171
4222
|
} finally {
|
|
4172
|
-
|
|
4223
|
+
_iterator23.f();
|
|
4173
4224
|
}
|
|
4174
4225
|
}
|
|
4175
4226
|
} catch (err) {
|
|
4176
|
-
|
|
4227
|
+
_iterator20.e(err);
|
|
4177
4228
|
} finally {
|
|
4178
|
-
|
|
4229
|
+
_iterator20.f();
|
|
4179
4230
|
}
|
|
4180
|
-
var
|
|
4181
|
-
|
|
4231
|
+
var _iterator21 = _createForOfIteratorHelper(discountList),
|
|
4232
|
+
_step21;
|
|
4182
4233
|
try {
|
|
4183
|
-
for (
|
|
4184
|
-
var d =
|
|
4234
|
+
for (_iterator21.s(); !(_step21 = _iterator21.n()).done;) {
|
|
4235
|
+
var d = _step21.value;
|
|
4185
4236
|
var key = d.id;
|
|
4186
4237
|
d.savedAmount = d.isSelected && key != null && savedMap.has(key) ? savedMap.get(key).toNumber() : 0;
|
|
4187
4238
|
}
|
|
4188
4239
|
} catch (err) {
|
|
4189
|
-
|
|
4240
|
+
_iterator21.e(err);
|
|
4190
4241
|
} finally {
|
|
4191
|
-
|
|
4242
|
+
_iterator21.f();
|
|
4192
4243
|
}
|
|
4193
4244
|
}
|
|
4194
4245
|
}]);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Decimal from 'decimal.js';
|
|
2
|
-
import { CartItem } from "../Cart";
|
|
2
|
+
import type { CartItem } from "../Cart";
|
|
3
3
|
import type { OrderProductDiscountItem, OrderSubmitPayload, OrderSubmitProduct, OrderSummary, OrderTempOrder } from './types';
|
|
4
4
|
import type { RulesParamsHooks } from '../Rules/types';
|
|
5
5
|
import type { MapOrderPaymentsOptions, OrderPaymentData, OrderPaymentSource } from './types';
|
|
@@ -21,10 +21,20 @@ export declare function composeLinePrice(params: {
|
|
|
21
21
|
bundle?: Array<{
|
|
22
22
|
bundle_selling_price?: any;
|
|
23
23
|
price?: any;
|
|
24
|
+
custom_price?: any;
|
|
24
25
|
num?: any;
|
|
25
26
|
quantity?: any;
|
|
26
27
|
original_price?: any;
|
|
27
28
|
product_price?: any;
|
|
29
|
+
price_type?: any;
|
|
30
|
+
price_type_ext?: any;
|
|
31
|
+
custom_price_type?: any;
|
|
32
|
+
custom_price_type_ext?: any;
|
|
33
|
+
option?: Array<{
|
|
34
|
+
add_price?: any;
|
|
35
|
+
price?: any;
|
|
36
|
+
num?: any;
|
|
37
|
+
}>;
|
|
28
38
|
}> | null;
|
|
29
39
|
useOriginalBundle?: boolean;
|
|
30
40
|
}): string;
|
|
@@ -43,6 +53,27 @@ export declare function sumOptionUnitPrice(options?: Array<{
|
|
|
43
53
|
price?: any;
|
|
44
54
|
num?: any;
|
|
45
55
|
}> | null): Decimal;
|
|
56
|
+
/**
|
|
57
|
+
* 判定套餐子商品是否为 markdown(减价)类型。
|
|
58
|
+
* 与后端口径一致:price_type='markdown' 且 price_type_ext 非 'product_price'(原价子商品)。
|
|
59
|
+
*/
|
|
60
|
+
export declare function isMarkdownBundle(bundle: Record<string, any> | null | undefined): boolean;
|
|
61
|
+
/**
|
|
62
|
+
* 套餐子商品对「行价」的带符号单位贡献(与后端 markdown 口径对齐)。
|
|
63
|
+
*
|
|
64
|
+
* - markdown(减价):净额 = |catalog 毛价| − Σ(option.add_price×num),**取负**(行内减)。
|
|
65
|
+
* catalog 毛价优先 `price`/`custom_price`(避免读已落净额的 `bundle_selling_price` 造成 option 二次扣减);
|
|
66
|
+
* 仅当毛价缺失(历史/hydrate 仅剩净额)时退回 `bundle_selling_price`,且此时不再扣 option。
|
|
67
|
+
* - markup(加价)/原价子商品:维持 `+(bundle_selling_price ?? price)`,行为不变。
|
|
68
|
+
*/
|
|
69
|
+
export declare function getBundleSignedUnit(bundle: Record<string, any> | null | undefined, options?: {
|
|
70
|
+
useOriginal?: boolean;
|
|
71
|
+
}): Decimal;
|
|
72
|
+
/**
|
|
73
|
+
* 套餐子商品 `bundle_selling_price` 的存储净额(正值幅度)。
|
|
74
|
+
* markdown 取净额绝对值(3.70);markup/原价维持原值。
|
|
75
|
+
*/
|
|
76
|
+
export declare function getBundleSellingMagnitude(bundle: Record<string, any> | null | undefined): Decimal;
|
|
46
77
|
/**
|
|
47
78
|
* OrderModule 默认 Rules 钩子工厂。
|
|
48
79
|
*
|
|
@@ -55,7 +86,7 @@ export declare function sumOptionUnitPrice(options?: Array<{
|
|
|
55
86
|
* 不含折扣。**权威源**。
|
|
56
87
|
* - `metadata.main_product_original_price` = source + Σ(option.price × option.num)(含 option、不含折扣)。
|
|
57
88
|
* - `metadata.main_product_selling_price` = main_original − 主商品券 per-unit amount(含 option、含折扣)。
|
|
58
|
-
* - `payment_price`:出站 payload
|
|
89
|
+
* - `payment_price`:出站 payload 中为行 composite 已减整单折扣均摊价(无折扣时与 `selling_price` 同义)。
|
|
59
90
|
*
|
|
60
91
|
* Rules 钩子契约(hook_adapt 方案,Rules 内部保持不变):
|
|
61
92
|
* - `getProduct.price` / `getProduct.original_price` 回传 **source-level 主价**
|