@pisell/pisellos 2.3.164 → 2.3.166
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/evaluator.js +89 -104
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +3 -1
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +28 -4
- package/dist/modules/Holder/utils.d.ts +2 -0
- package/dist/modules/Holder/utils.js +32 -2
- package/dist/modules/OpenData/contactInfo.d.ts +20 -0
- package/dist/modules/OpenData/contactInfo.js +70 -0
- package/dist/modules/OpenData/index.d.ts +1 -0
- package/dist/modules/OpenData/index.js +1 -0
- package/dist/modules/OpenData/types.d.ts +9 -0
- package/dist/modules/Order/holderRelations.d.ts +14 -0
- package/dist/modules/Order/holderRelations.js +154 -0
- package/dist/modules/Order/index.d.ts +1 -1
- package/dist/modules/Order/index.js +89 -44
- package/dist/modules/Order/types.d.ts +19 -1
- package/dist/modules/Order/types.js +2 -0
- package/dist/modules/Order/utils/discountProductLineIdentity.d.ts +1 -1
- package/dist/modules/Order/utils/discountProductLineIdentity.js +142 -7
- package/dist/modules/Order/utils/orderCollectionIdentity.js +24 -10
- package/dist/modules/Order/utils.d.ts +1 -1
- package/dist/modules/Order/utils.js +35 -9
- package/dist/modules/Rules/index.js +62 -61
- package/dist/server/index.js +18 -12
- package/dist/server/modules/order/index.d.ts +4 -0
- package/dist/server/modules/order/index.js +255 -190
- package/dist/server/modules/order/types.d.ts +3 -0
- package/dist/server/modules/products/index.js +3 -2
- package/dist/shared/receipt/small-ticket.js +17 -6
- package/dist/shared/sales/loadSalesOrderSnapshot.js +1 -1
- package/dist/solution/BaseSales/index.d.ts +4 -0
- package/dist/solution/BaseSales/index.js +1116 -935
- package/dist/solution/BaseSales/types.d.ts +2 -1
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +3 -1
- package/dist/solution/BaseSales/utils/parseSalesResponse.js +7 -3
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +14 -4
- package/dist/solution/BookingTicket/index.d.ts +15 -1
- package/dist/solution/BookingTicket/index.js +784 -501
- package/dist/solution/UnifiedBookingSales/index.js +1 -1
- package/lib/model/strategy/adapter/promotion/evaluator.js +9 -14
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +3 -1
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +17 -1
- package/lib/modules/Holder/utils.d.ts +2 -0
- package/lib/modules/Holder/utils.js +27 -1
- package/lib/modules/OpenData/contactInfo.d.ts +20 -0
- package/lib/modules/OpenData/contactInfo.js +56 -0
- package/lib/modules/OpenData/index.d.ts +1 -0
- package/lib/modules/OpenData/index.js +12 -0
- package/lib/modules/OpenData/types.d.ts +9 -0
- package/lib/modules/Order/holderRelations.d.ts +14 -0
- package/lib/modules/Order/holderRelations.js +98 -0
- package/lib/modules/Order/index.d.ts +1 -1
- package/lib/modules/Order/index.js +44 -12
- package/lib/modules/Order/types.d.ts +19 -1
- package/lib/modules/Order/types.js +1 -0
- package/lib/modules/Order/utils/discountProductLineIdentity.d.ts +1 -1
- package/lib/modules/Order/utils/discountProductLineIdentity.js +51 -2
- package/lib/modules/Order/utils/orderCollectionIdentity.js +5 -0
- package/lib/modules/Order/utils.d.ts +1 -1
- package/lib/modules/Order/utils.js +27 -6
- package/lib/modules/Rules/index.js +2 -1
- package/lib/server/index.js +6 -0
- package/lib/server/modules/order/index.d.ts +4 -0
- package/lib/server/modules/order/index.js +46 -4
- package/lib/server/modules/order/types.d.ts +3 -0
- package/lib/server/modules/products/index.js +2 -1
- package/lib/shared/receipt/small-ticket.js +15 -7
- package/lib/shared/sales/loadSalesOrderSnapshot.js +1 -1
- package/lib/solution/BaseSales/index.d.ts +4 -0
- package/lib/solution/BaseSales/index.js +68 -2
- package/lib/solution/BaseSales/types.d.ts +2 -1
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +3 -1
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +4 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +16 -8
- package/lib/solution/BookingTicket/index.d.ts +15 -1
- package/lib/solution/BookingTicket/index.js +132 -3
- package/lib/solution/UnifiedBookingSales/index.js +1 -1
- package/package.json +1 -1
|
@@ -38,6 +38,7 @@ import { BaseModule } from "../BaseModule";
|
|
|
38
38
|
import { UnavailableReason } from "./types";
|
|
39
39
|
import { uniqueById, getDiscountAmount, getDiscountListAmountTotal, getDiscountListAmount, filterDiscountListByBookingTime, getDiscountTimeUnavailableReason } from "../../solution/ShopDiscount/utils";
|
|
40
40
|
import { getProductOriginTotalPrice, getProductTotalPrice } from "../Cart/utils";
|
|
41
|
+
import { resolveProductHolderConfig } from "../Holder/utils";
|
|
41
42
|
import Decimal from 'decimal.js';
|
|
42
43
|
import { cloneDeep, isBoolean } from 'lodash-es';
|
|
43
44
|
import dayjs from 'dayjs';
|
|
@@ -136,12 +137,12 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
136
137
|
}, {
|
|
137
138
|
key: "checkHolderMatch",
|
|
138
139
|
value: function checkHolderMatch(discount, product, holderSource, holders) {
|
|
139
|
-
var _discount$holder
|
|
140
|
+
var _discount$holder;
|
|
140
141
|
// 非表单类型 holder 视为匹配
|
|
141
142
|
if (((_discount$holder = discount.holder) === null || _discount$holder === void 0 ? void 0 : _discount$holder.holder_type) !== 'form') return true;
|
|
142
143
|
|
|
143
144
|
// getProduct 会裁剪商品字段,从原始商品读取配置,套餐子项沿用父商品。
|
|
144
|
-
var holderConfig = (
|
|
145
|
+
var holderConfig = resolveProductHolderConfig(holderSource);
|
|
145
146
|
var holderStatus = holderConfig === null || holderConfig === void 0 ? void 0 : holderConfig.status;
|
|
146
147
|
var holderEnabled = holderStatus === true || ['enable', '1'].includes(String(holderStatus).trim().toLowerCase());
|
|
147
148
|
if (!holderEnabled || (holderConfig === null || holderConfig === void 0 ? void 0 : holderConfig.resource_id) === undefined || (holderConfig === null || holderConfig === void 0 ? void 0 : holderConfig.resource_id) === null || (holderConfig === null || holderConfig === void 0 ? void 0 : holderConfig.resource_id) === '') {
|
|
@@ -161,14 +162,14 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
161
162
|
// 判断discountList 是否可以对当前productList生效
|
|
162
163
|
}, {
|
|
163
164
|
key: "isDiscountListAvailable",
|
|
164
|
-
value: function isDiscountListAvailable(
|
|
165
|
+
value: function isDiscountListAvailable(_ref) {
|
|
165
166
|
var _this2 = this;
|
|
166
|
-
var oldDiscountList =
|
|
167
|
-
newDiscountList =
|
|
168
|
-
productList =
|
|
169
|
-
orderTotalAmount =
|
|
170
|
-
holders =
|
|
171
|
-
isFormSubject =
|
|
167
|
+
var oldDiscountList = _ref.oldDiscountList,
|
|
168
|
+
newDiscountList = _ref.newDiscountList,
|
|
169
|
+
productList = _ref.productList,
|
|
170
|
+
orderTotalAmount = _ref.orderTotalAmount,
|
|
171
|
+
holders = _ref.holders,
|
|
172
|
+
isFormSubject = _ref.isFormSubject;
|
|
172
173
|
// 首先检查是否有新的优惠券可应用
|
|
173
174
|
if (!newDiscountList || newDiscountList.length === 0) {
|
|
174
175
|
return {
|
|
@@ -367,14 +368,14 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
367
368
|
}
|
|
368
369
|
}, {
|
|
369
370
|
key: "calcDiscount",
|
|
370
|
-
value: function calcDiscount(
|
|
371
|
+
value: function calcDiscount(_ref2, options) {
|
|
371
372
|
var _options$selectedList,
|
|
372
373
|
_this4 = this;
|
|
373
|
-
var discountList =
|
|
374
|
-
productList =
|
|
375
|
-
holders =
|
|
376
|
-
isFormSubject =
|
|
377
|
-
orderTotalAmount =
|
|
374
|
+
var discountList = _ref2.discountList,
|
|
375
|
+
productList = _ref2.productList,
|
|
376
|
+
holders = _ref2.holders,
|
|
377
|
+
isFormSubject = _ref2.isFormSubject,
|
|
378
|
+
orderTotalAmount = _ref2.orderTotalAmount;
|
|
378
379
|
var preferredEntitlementPassIds = new Set(((options === null || options === void 0 ? void 0 : options.preferredEntitlementPassIds) || []).map(String));
|
|
379
380
|
var resolveIsFormSubject = function resolveIsFormSubject(product) {
|
|
380
381
|
return typeof isFormSubject === 'function' ? Boolean(isFormSubject(product)) : Boolean(isFormSubject);
|
|
@@ -488,7 +489,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
488
489
|
// 2. 展开 bundle 子商品
|
|
489
490
|
if (product.bundle && Array.isArray(product.bundle) && product.bundle.length > 0) {
|
|
490
491
|
product.bundle.forEach(function (bundleItem, bundleIndex) {
|
|
491
|
-
var
|
|
492
|
+
var _ref3, _bundleItem$bundle_pr;
|
|
492
493
|
flattened.push({
|
|
493
494
|
type: 'bundle',
|
|
494
495
|
originProduct: originProduct,
|
|
@@ -500,7 +501,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
500
501
|
// 新增商品运行态通常带 _bundle_product_id;订单 hydrate 后只有
|
|
501
502
|
// bundle_product_id。Change time 必须兼容两种结构,否则 bundle
|
|
502
503
|
// 子项无法命中折扣卡的 limited_relation_product_data.product_ids。
|
|
503
|
-
id: (
|
|
504
|
+
id: (_ref3 = (_bundleItem$bundle_pr = bundleItem.bundle_product_id) !== null && _bundleItem$bundle_pr !== void 0 ? _bundleItem$bundle_pr : bundleItem._bundle_product_id) !== null && _ref3 !== void 0 ? _ref3 : bundleItem.product_id,
|
|
504
505
|
_id: "".concat(product._id, "_bundle_").concat(bundleIndex),
|
|
505
506
|
parentId: product._id,
|
|
506
507
|
num: bundleItem.num || 1,
|
|
@@ -660,10 +661,10 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
660
661
|
|
|
661
662
|
// 对扁平化后的列表按价格降序排序(用于应用优惠券时优先选择高价商品)
|
|
662
663
|
var sortedFlattenedList = flattenedList.sort(function (a, b) {
|
|
663
|
-
var
|
|
664
|
+
var _ref4, _a$original_price, _ref5, _b$original_price;
|
|
664
665
|
// 子商品优先使用 original_price,主商品使用 price
|
|
665
|
-
var priceA = new Decimal(a.type === 'bundle' ? (
|
|
666
|
-
var priceB = new Decimal(b.type === 'bundle' ? (
|
|
666
|
+
var priceA = new Decimal(a.type === 'bundle' ? (_ref4 = (_a$original_price = a.original_price) !== null && _a$original_price !== void 0 ? _a$original_price : a.price) !== null && _ref4 !== void 0 ? _ref4 : '0' : a.price || '0');
|
|
667
|
+
var priceB = new Decimal(b.type === 'bundle' ? (_ref5 = (_b$original_price = b.original_price) !== null && _b$original_price !== void 0 ? _b$original_price : b.price) !== null && _ref5 !== void 0 ? _ref5 : '0' : b.price || '0');
|
|
667
668
|
if (priceA.equals(priceB)) {
|
|
668
669
|
// 价格相同时,主商品优先
|
|
669
670
|
if (a.type !== b.type) {
|
|
@@ -797,13 +798,13 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
797
798
|
var buildFullCoveragePassUsageGroups = function buildFullCoveragePassUsageGroups(discounts, requestedCount) {
|
|
798
799
|
var _firstGoodPass$config;
|
|
799
800
|
var groups = [];
|
|
800
|
-
var pendingUsedDiscounts = new Set(Array.from(usedDiscounts.entries()).filter(function (
|
|
801
|
-
var
|
|
802
|
-
used =
|
|
801
|
+
var pendingUsedDiscounts = new Set(Array.from(usedDiscounts.entries()).filter(function (_ref6) {
|
|
802
|
+
var _ref7 = _slicedToArray(_ref6, 2),
|
|
803
|
+
used = _ref7[1];
|
|
803
804
|
return used;
|
|
804
|
-
}).map(function (
|
|
805
|
-
var
|
|
806
|
-
discountId =
|
|
805
|
+
}).map(function (_ref8) {
|
|
806
|
+
var _ref9 = _slicedToArray(_ref8, 1),
|
|
807
|
+
discountId = _ref9[0];
|
|
807
808
|
return discountId;
|
|
808
809
|
}));
|
|
809
810
|
var pendingEntitlementCounts = new Map(entitlementUsageCounts);
|
|
@@ -878,7 +879,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
878
879
|
_step6;
|
|
879
880
|
try {
|
|
880
881
|
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
881
|
-
var _detail$discount$reso, _detail$discount, _detail$discount$prod, _detail$discount2, _detail$metadata$cust, _detail$metadata, _detail$discount3,
|
|
882
|
+
var _detail$discount$reso, _detail$discount, _detail$discount$prod, _detail$discount2, _detail$metadata$cust, _detail$metadata, _detail$discount3, _ref10, _detail$metadata$num, _detail$metadata2, _ref11, _existed$metadata$num, _existed$metadata;
|
|
882
883
|
var detail = _step6.value;
|
|
883
884
|
if (!isEntitlementPass(detail)) {
|
|
884
885
|
mergedDetails.push(detail);
|
|
@@ -890,7 +891,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
890
891
|
continue;
|
|
891
892
|
}
|
|
892
893
|
var key = [resourceId, (_detail$discount$prod = detail === null || detail === void 0 || (_detail$discount2 = detail.discount) === null || _detail$discount2 === void 0 ? void 0 : _detail$discount2.product_id) !== null && _detail$discount$prod !== void 0 ? _detail$discount$prod : '', (_detail$metadata$cust = detail === null || detail === void 0 || (_detail$metadata = detail.metadata) === null || _detail$metadata === void 0 ? void 0 : _detail$metadata.custom_product_bundle_map_id) !== null && _detail$metadata$cust !== void 0 ? _detail$metadata$cust : '', toComparableNumber(detail === null || detail === void 0 ? void 0 : detail.amount), toComparableNumber(detail === null || detail === void 0 || (_detail$discount3 = detail.discount) === null || _detail$discount3 === void 0 ? void 0 : _detail$discount3.fixed_amount)].join('|');
|
|
893
|
-
var rawUsageCount = Number((
|
|
894
|
+
var rawUsageCount = Number((_ref10 = (_detail$metadata$num = detail === null || detail === void 0 || (_detail$metadata2 = detail.metadata) === null || _detail$metadata2 === void 0 ? void 0 : _detail$metadata2.num) !== null && _detail$metadata$num !== void 0 ? _detail$metadata$num : detail === null || detail === void 0 ? void 0 : detail._num) !== null && _ref10 !== void 0 ? _ref10 : 1);
|
|
894
895
|
var usageCount = Number.isFinite(rawUsageCount) && rawUsageCount > 0 ? rawUsageCount : 1;
|
|
895
896
|
var mergedIndex = mergedIndexByKey.get(key);
|
|
896
897
|
if (mergedIndex === undefined) {
|
|
@@ -904,7 +905,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
904
905
|
continue;
|
|
905
906
|
}
|
|
906
907
|
var existed = mergedDetails[mergedIndex];
|
|
907
|
-
var existedUsageCount = Number((
|
|
908
|
+
var existedUsageCount = Number((_ref11 = (_existed$metadata$num = existed === null || existed === void 0 || (_existed$metadata = existed.metadata) === null || _existed$metadata === void 0 ? void 0 : _existed$metadata.num) !== null && _existed$metadata$num !== void 0 ? _existed$metadata$num : existed === null || existed === void 0 ? void 0 : existed._num) !== null && _ref11 !== void 0 ? _ref11 : 1);
|
|
908
909
|
var totalUsageCount = existedUsageCount + usageCount;
|
|
909
910
|
mergedDetails[mergedIndex] = _objectSpread(_objectSpread({}, existed), {}, {
|
|
910
911
|
metadata: _objectSpread(_objectSpread({}, (existed === null || existed === void 0 ? void 0 : existed.metadata) || {}), {}, {
|
|
@@ -1071,7 +1072,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1071
1072
|
// 收集该折扣卡适用的商品(排除被其他专属折扣卡占用的商品)
|
|
1072
1073
|
var applicableProducts = [];
|
|
1073
1074
|
sortedFlattenedList.forEach(function (flatItem) {
|
|
1074
|
-
var _flatItem$parentProdu2, _flatItem$parentProdu3, _product$price,
|
|
1075
|
+
var _flatItem$parentProdu2, _flatItem$parentProdu3, _product$price, _ref12, _flatItem$original_pr;
|
|
1075
1076
|
// 🔥 检查该商品是否被其他专属折扣卡占用
|
|
1076
1077
|
var occupyingDiscountId = occupiedItems.get(flatItem._id);
|
|
1077
1078
|
if (occupyingDiscountId !== undefined && occupyingDiscountId !== discount.id) {
|
|
@@ -1099,7 +1100,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1099
1100
|
|
|
1100
1101
|
// 对于主商品:使用 price
|
|
1101
1102
|
// 对于子商品:优先使用 flatItem.original_price,否则使用 flatItem.price
|
|
1102
|
-
var originalAmount = flatItem.type === 'main' ? Number((_product$price = product.price) !== null && _product$price !== void 0 ? _product$price : 0) : Number((
|
|
1103
|
+
var originalAmount = flatItem.type === 'main' ? Number((_product$price = product.price) !== null && _product$price !== void 0 ? _product$price : 0) : Number((_ref12 = (_flatItem$original_pr = flatItem.original_price) !== null && _flatItem$original_pr !== void 0 ? _flatItem$original_pr : flatItem.price) !== null && _ref12 !== void 0 ? _ref12 : 0);
|
|
1103
1104
|
|
|
1104
1105
|
// 传递 parentQuantity 用于差值处理时判断是否是真正的"数量为1"
|
|
1105
1106
|
var productData = {
|
|
@@ -1143,9 +1144,9 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1143
1144
|
return false;
|
|
1144
1145
|
}
|
|
1145
1146
|
return (product.options || []).reduce(function (total, option) {
|
|
1146
|
-
var
|
|
1147
|
-
var unitPrice = Number((
|
|
1148
|
-
var quantity = Number((
|
|
1147
|
+
var _ref13, _ref14, _ref15, _option$_original_pri, _ref16, _option$num;
|
|
1148
|
+
var unitPrice = Number((_ref13 = (_ref14 = (_ref15 = (_option$_original_pri = option._original_price) !== null && _option$_original_pri !== void 0 ? _option$_original_pri : option._original_add_price) !== null && _ref15 !== void 0 ? _ref15 : option.price) !== null && _ref14 !== void 0 ? _ref14 : option.add_price) !== null && _ref13 !== void 0 ? _ref13 : 0);
|
|
1149
|
+
var quantity = Number((_ref16 = (_option$num = option.num) !== null && _option$num !== void 0 ? _option$num : option.quantity) !== null && _ref16 !== void 0 ? _ref16 : 1);
|
|
1149
1150
|
if (!Number.isFinite(unitPrice) || !Number.isFinite(quantity) || quantity <= 0) {
|
|
1150
1151
|
return total;
|
|
1151
1152
|
}
|
|
@@ -1261,13 +1262,13 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1261
1262
|
};
|
|
1262
1263
|
var optionDiscountAmount = 0;
|
|
1263
1264
|
var discountedOptions = options.map(function (option) {
|
|
1264
|
-
var
|
|
1265
|
+
var _ref17, _ref18, _option$_original_pri2, _ref19, _option$num2, _rest$price, _option$_original_pri3;
|
|
1265
1266
|
// 折前单价:优先 price,缺失再 add_price;已写回折后价时用 _original_price(或旧字段 _original_add_price)
|
|
1266
|
-
var rawUnit = (
|
|
1267
|
+
var rawUnit = (_ref17 = (_ref18 = (_option$_original_pri2 = option._original_price) !== null && _option$_original_pri2 !== void 0 ? _option$_original_pri2 : option._original_add_price) !== null && _ref18 !== void 0 ? _ref18 : option.price) !== null && _ref17 !== void 0 ? _ref17 : option.add_price;
|
|
1267
1268
|
var baseUnitNum = Number(rawUnit !== null && rawUnit !== void 0 ? rawUnit : 0);
|
|
1268
1269
|
if (baseUnitNum <= 0) return option;
|
|
1269
1270
|
var discountedPrice = getDiscountAmount(discount, baseUnitNum, baseUnitNum);
|
|
1270
|
-
var optQty = Number((
|
|
1271
|
+
var optQty = Number((_ref19 = (_option$num2 = option.num) !== null && _option$num2 !== void 0 ? _option$num2 : option.quantity) !== null && _ref19 !== void 0 ? _ref19 : 1);
|
|
1271
1272
|
optionDiscountAmount = new Decimal(optionDiscountAmount).plus(new Decimal(baseUnitNum).minus(discountedPrice).mul(optQty)).toNumber();
|
|
1272
1273
|
var _original_add_price = option._original_add_price,
|
|
1273
1274
|
rest = _objectWithoutProperties(option, _excluded);
|
|
@@ -1301,9 +1302,9 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1301
1302
|
var getOptionTotal = function getOptionTotal(options) {
|
|
1302
1303
|
if (!(options !== null && options !== void 0 && options.length)) return 0;
|
|
1303
1304
|
return options.reduce(function (sum, opt) {
|
|
1304
|
-
var
|
|
1305
|
-
var unit = Number((
|
|
1306
|
-
var n = Number((
|
|
1305
|
+
var _ref20, _opt$price, _ref21, _opt$num;
|
|
1306
|
+
var unit = Number((_ref20 = (_opt$price = opt.price) !== null && _opt$price !== void 0 ? _opt$price : opt.add_price) !== null && _ref20 !== void 0 ? _ref20 : 0);
|
|
1307
|
+
var n = Number((_ref21 = (_opt$num = opt.num) !== null && _opt$num !== void 0 ? _opt$num : opt.quantity) !== null && _ref21 !== void 0 ? _ref21 : 1);
|
|
1307
1308
|
return new Decimal(sum).plus(new Decimal(unit).mul(n)).toNumber();
|
|
1308
1309
|
}, 0);
|
|
1309
1310
|
};
|
|
@@ -1452,8 +1453,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1452
1453
|
var appliedWalletDiscountIds = new Set((product.discount_list || []).filter(function (item) {
|
|
1453
1454
|
return ['entitlement_pass', 'discount_card', 'product_discount_card'].includes((item === null || item === void 0 ? void 0 : item.tag) || (item === null || item === void 0 ? void 0 : item.type));
|
|
1454
1455
|
}).map(function (item) {
|
|
1455
|
-
var
|
|
1456
|
-
return (
|
|
1456
|
+
var _ref22, _item$discount$resour, _item$discount2;
|
|
1457
|
+
return (_ref22 = (_item$discount$resour = item === null || item === void 0 || (_item$discount2 = item.discount) === null || _item$discount2 === void 0 ? void 0 : _item$discount2.resource_id) !== null && _item$discount$resour !== void 0 ? _item$discount$resour : item === null || item === void 0 ? void 0 : item.resource_id) !== null && _ref22 !== void 0 ? _ref22 : item === null || item === void 0 ? void 0 : item.id;
|
|
1457
1458
|
}).filter(function (id) {
|
|
1458
1459
|
return id !== undefined && id !== null;
|
|
1459
1460
|
}).map(String));
|
|
@@ -1493,8 +1494,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1493
1494
|
isManualDiscount = typeof product.isManualDiscount === 'boolean' ? product.isManualDiscount : ((_product$discount_lis5 = product.discount_list) === null || _product$discount_lis5 === void 0 ? void 0 : _product$discount_lis5.some(function (item) {
|
|
1494
1495
|
return item.type === 'product';
|
|
1495
1496
|
})) || product.total != product.origin_total && (product.bundle || []).every(function (item) {
|
|
1496
|
-
var
|
|
1497
|
-
return !((
|
|
1497
|
+
var _ref23;
|
|
1498
|
+
return !((_ref23 = item.discount_list || []) !== null && _ref23 !== void 0 && _ref23.length);
|
|
1498
1499
|
}) && (!((_product$discount_lis6 = product.discount_list) !== null && _product$discount_lis6 !== void 0 && _product$discount_lis6.length) || ((_product11 = product) === null || _product11 === void 0 || (_product11 = _product11.discount_list) === null || _product11 === void 0 || (_product11$every = _product11.every) === null || _product11$every === void 0 ? void 0 : _product11$every.call(_product11, function (item) {
|
|
1499
1500
|
return item.type === 'product';
|
|
1500
1501
|
})));
|
|
@@ -1510,8 +1511,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1510
1511
|
isManualDiscount = typeof parentProduct.isManualDiscount === 'boolean' ? parentProduct.isManualDiscount : ((_parentProduct$discou = parentProduct.discount_list) === null || _parentProduct$discou === void 0 ? void 0 : _parentProduct$discou.some(function (item) {
|
|
1511
1512
|
return item.type === 'product';
|
|
1512
1513
|
})) || parentProduct.total != parentProduct.origin_total && (parentProduct.bundle || []).every(function (item) {
|
|
1513
|
-
var
|
|
1514
|
-
return !((
|
|
1514
|
+
var _ref24;
|
|
1515
|
+
return !((_ref24 = item.discount_list || []) !== null && _ref24 !== void 0 && _ref24.length);
|
|
1515
1516
|
}) && (!((_parentProduct$discou2 = parentProduct.discount_list) !== null && _parentProduct$discou2 !== void 0 && _parentProduct$discou2.length) || (parentProduct === null || parentProduct === void 0 || (_parentProduct$discou3 = parentProduct.discount_list) === null || _parentProduct$discou3 === void 0 || (_parentProduct$discou4 = _parentProduct$discou3.every) === null || _parentProduct$discou4 === void 0 ? void 0 : _parentProduct$discou4.call(_parentProduct$discou3, function (item) {
|
|
1516
1517
|
return item.type === 'product';
|
|
1517
1518
|
})));
|
|
@@ -1604,8 +1605,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1604
1605
|
discount_list: isManualDiscount ? _this4.resolveDiscountListForManualOverride(product.discount_list) : _this4.filterDiscountListByType(product.discount_list, 'promotion')
|
|
1605
1606
|
}))]);
|
|
1606
1607
|
} else {
|
|
1607
|
-
var
|
|
1608
|
-
var total = product.inPromotion ? (
|
|
1608
|
+
var _ref25, _product$_promotion$f, _product12, _product$origin_total;
|
|
1609
|
+
var total = product.inPromotion ? (_ref25 = (_product$_promotion$f = (_product12 = product) === null || _product12 === void 0 || (_product12 = _product12._promotion) === null || _product12 === void 0 ? void 0 : _product12.finalPrice) !== null && _product$_promotion$f !== void 0 ? _product$_promotion$f : product.origin_total) !== null && _ref25 !== void 0 ? _ref25 : product.total : (_product$origin_total = product.origin_total) !== null && _product$origin_total !== void 0 ? _product$origin_total : product.total;
|
|
1609
1610
|
var main_product_selling_price = product.price;
|
|
1610
1611
|
if ((product.discount_list || []).some(function (item) {
|
|
1611
1612
|
return item.type === 'promotion';
|
|
@@ -2308,7 +2309,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2308
2309
|
} else {
|
|
2309
2310
|
// 🔥 没有子商品被拆分,使用原有逻辑
|
|
2310
2311
|
mainProductArr.forEach(function (mainProduct) {
|
|
2311
|
-
var
|
|
2312
|
+
var _ref27, _mainProductData$main, _mainProductData$disc, _mainProductData$disc2, _mainProductData$disc3;
|
|
2312
2313
|
var mainProductData = _this4.hooks.getProduct(mainProduct);
|
|
2313
2314
|
|
|
2314
2315
|
// 重组bundle
|
|
@@ -2323,9 +2324,9 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2323
2324
|
} else {
|
|
2324
2325
|
// 🔥 关键:拆分后的bundle item
|
|
2325
2326
|
processedBundleItems.forEach(function (item) {
|
|
2326
|
-
var _item$price,
|
|
2327
|
+
var _item$price, _ref26, _item$bundle_selling_;
|
|
2327
2328
|
var nextBundlePrice = (_item$price = item.price) !== null && _item$price !== void 0 ? _item$price : bundleItem.price;
|
|
2328
|
-
var nextBundleSellingPrice = (
|
|
2329
|
+
var nextBundleSellingPrice = (_ref26 = (_item$bundle_selling_ = item.bundle_selling_price) !== null && _item$bundle_selling_ !== void 0 ? _item$bundle_selling_ : item.price) !== null && _ref26 !== void 0 ? _ref26 : bundleItem.bundle_selling_price;
|
|
2329
2330
|
// 🔥 更新 discount_list 中的 num,使其与拆分后的 item.num 一致
|
|
2330
2331
|
var updatedDiscountList = (item.discount_list || []).map(function (discount) {
|
|
2331
2332
|
var _discount$metadata11;
|
|
@@ -2352,7 +2353,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2352
2353
|
|
|
2353
2354
|
// 主商品已经在前面的 setProduct 中应用过折扣;这里只替换 bundle,
|
|
2354
2355
|
// 避免把主商品 discount_list 再扣一次。
|
|
2355
|
-
var mainSellingPrice = (
|
|
2356
|
+
var mainSellingPrice = (_ref27 = (_mainProductData$main = mainProductData.main_product_selling_price) !== null && _mainProductData$main !== void 0 ? _mainProductData$main : mainProductData.price) !== null && _ref27 !== void 0 ? _ref27 : 0;
|
|
2356
2357
|
var newTotal = Number(mainSellingPrice || 0);
|
|
2357
2358
|
var newOriginTotal = Number(mainProductData.original_price || mainProductData.price || 0);
|
|
2358
2359
|
|
|
@@ -2568,15 +2569,15 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2568
2569
|
var ruleType = usageRules.type;
|
|
2569
2570
|
// 套餐适用范围配置
|
|
2570
2571
|
var packageScope = usageRules === null || usageRules === void 0 ? void 0 : usageRules.package_scope;
|
|
2571
|
-
var
|
|
2572
|
-
|
|
2573
|
-
scopeType =
|
|
2574
|
-
|
|
2575
|
-
exclude_bundle_product_ids =
|
|
2576
|
-
|
|
2577
|
-
include_bundle_product_ids =
|
|
2578
|
-
|
|
2579
|
-
filter =
|
|
2572
|
+
var _ref28 = packageScope || {},
|
|
2573
|
+
_ref28$type = _ref28.type,
|
|
2574
|
+
scopeType = _ref28$type === void 0 ? 'product_all' : _ref28$type,
|
|
2575
|
+
_ref28$exclude_bundle = _ref28.exclude_bundle_product_ids,
|
|
2576
|
+
exclude_bundle_product_ids = _ref28$exclude_bundle === void 0 ? [] : _ref28$exclude_bundle,
|
|
2577
|
+
_ref28$include_bundle = _ref28.include_bundle_product_ids,
|
|
2578
|
+
include_bundle_product_ids = _ref28$include_bundle === void 0 ? [] : _ref28$include_bundle,
|
|
2579
|
+
_ref28$filter = _ref28.filter,
|
|
2580
|
+
filter = _ref28$filter === void 0 ? 0 : _ref28$filter;
|
|
2580
2581
|
var isMainProduct = flatItem.type === 'main'; // 单独购买
|
|
2581
2582
|
var isBundleItem = flatItem.type === 'bundle'; // 套餐中购买
|
|
2582
2583
|
var bundleMainProductId = (_flatItem$product = flatItem.product) === null || _flatItem$product === void 0 ? void 0 : _flatItem$product.product_id;
|
package/dist/server/index.js
CHANGED
|
@@ -2925,7 +2925,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
2925
2925
|
backendPath = params.backendPath, checkoutData = params.checkoutData, externalSaleNumber = params.externalSaleNumber, fresh = params.fresh, title = params.title, persistCheckoutDataWithResponse = params.persistCheckoutDataWithResponse;
|
|
2926
2926
|
shouldMergeRemoteOrder = fresh ? this.isMergeableCheckoutOrder(fresh, externalSaleNumber) : false;
|
|
2927
2927
|
if (!(this.order && fresh && (shouldMergeRemoteOrder || persistCheckoutDataWithResponse))) {
|
|
2928
|
-
_context36.next =
|
|
2928
|
+
_context36.next = 10;
|
|
2929
2929
|
break;
|
|
2930
2930
|
}
|
|
2931
2931
|
syncedOrder = persistCheckoutDataWithResponse ? _objectSpread(_objectSpread(_objectSpread({}, checkoutData), this.mergeCheckoutSyncPayments(checkoutData, fresh, title)), {}, {
|
|
@@ -2937,9 +2937,12 @@ var Server = /*#__PURE__*/function () {
|
|
|
2937
2937
|
need_sync: 0,
|
|
2938
2938
|
is_draft_order: 0
|
|
2939
2939
|
});
|
|
2940
|
-
|
|
2940
|
+
if (!Array.isArray(fresh.holder_relations) && Array.isArray(checkoutData === null || checkoutData === void 0 ? void 0 : checkoutData.holder_relations)) {
|
|
2941
|
+
syncedOrder.holder_relations = cloneDeep(checkoutData.holder_relations);
|
|
2942
|
+
}
|
|
2943
|
+
_context36.next = 7;
|
|
2941
2944
|
return this.order.upsertOrdersFromRemote([syncedOrder], 'checkoutSync');
|
|
2942
|
-
case
|
|
2945
|
+
case 7:
|
|
2943
2946
|
this.logInfo("".concat(title, ": sync_sales \u5B8C\u6574\u8BA2\u5355\u5DF2\u540C\u6B65\u5230\u672C\u5730"), {
|
|
2944
2947
|
order_id: fresh.order_id,
|
|
2945
2948
|
external_sale_number: syncedOrder.external_sale_number,
|
|
@@ -2947,20 +2950,20 @@ var Server = /*#__PURE__*/function () {
|
|
|
2947
2950
|
mergedRemoteOrder: shouldMergeRemoteOrder,
|
|
2948
2951
|
persistedCheckoutDataWithResponse: persistCheckoutDataWithResponse
|
|
2949
2952
|
});
|
|
2950
|
-
_context36.next =
|
|
2953
|
+
_context36.next = 20;
|
|
2951
2954
|
break;
|
|
2952
|
-
case
|
|
2955
|
+
case 10:
|
|
2953
2956
|
if (!(this.order && externalSaleNumber && typeof this.order.markOrderSyncedByExternalSaleNumber === 'function')) {
|
|
2954
|
-
_context36.next =
|
|
2957
|
+
_context36.next = 19;
|
|
2955
2958
|
break;
|
|
2956
2959
|
}
|
|
2957
2960
|
patch = this.buildCheckoutSyncSuccessPatch(fresh);
|
|
2958
|
-
_context36.next =
|
|
2961
|
+
_context36.next = 14;
|
|
2959
2962
|
return this.order.markOrderSyncedByExternalSaleNumber({
|
|
2960
2963
|
externalSaleNumber: externalSaleNumber,
|
|
2961
2964
|
patch: patch
|
|
2962
2965
|
});
|
|
2963
|
-
case
|
|
2966
|
+
case 14:
|
|
2964
2967
|
result = _context36.sent;
|
|
2965
2968
|
syncedOrder = (result === null || result === void 0 ? void 0 : result.order) || _objectSpread(_objectSpread(_objectSpread({}, checkoutData), patch), {}, {
|
|
2966
2969
|
external_sale_number: externalSaleNumber,
|
|
@@ -2973,17 +2976,17 @@ var Server = /*#__PURE__*/function () {
|
|
|
2973
2976
|
hasRemoteOrder: !!fresh,
|
|
2974
2977
|
mergedRemoteOrder: false
|
|
2975
2978
|
});
|
|
2976
|
-
_context36.next =
|
|
2979
|
+
_context36.next = 20;
|
|
2977
2980
|
break;
|
|
2978
|
-
case
|
|
2981
|
+
case 19:
|
|
2979
2982
|
this.logWarning("".concat(title, ": sync_sales Order \u6A21\u5757\u672A\u6CE8\u518C"), {
|
|
2980
2983
|
backendPath: backendPath,
|
|
2981
2984
|
external_sale_number: externalSaleNumber,
|
|
2982
2985
|
order_id: fresh === null || fresh === void 0 ? void 0 : fresh.order_id
|
|
2983
2986
|
});
|
|
2984
|
-
case 19:
|
|
2985
|
-
return _context36.abrupt("return", syncedOrder);
|
|
2986
2987
|
case 20:
|
|
2988
|
+
return _context36.abrupt("return", syncedOrder);
|
|
2989
|
+
case 21:
|
|
2987
2990
|
case "end":
|
|
2988
2991
|
return _context36.stop();
|
|
2989
2992
|
}
|
|
@@ -8178,6 +8181,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
8178
8181
|
if (fresh.order_number !== undefined && fresh.order_number !== null) {
|
|
8179
8182
|
patch.order_number = fresh.order_number;
|
|
8180
8183
|
}
|
|
8184
|
+
if (Array.isArray(fresh.holder_relations)) {
|
|
8185
|
+
patch.holder_relations = cloneDeep(fresh.holder_relations);
|
|
8186
|
+
}
|
|
8181
8187
|
return patch;
|
|
8182
8188
|
}
|
|
8183
8189
|
}, {
|
|
@@ -326,6 +326,10 @@ export declare class OrderModule extends BaseModule implements Module {
|
|
|
326
326
|
private getIdentifiedPendingPayments;
|
|
327
327
|
private shouldProtectLocalOrderFromRemoteSnapshot;
|
|
328
328
|
private getUnmatchedIdentifiedPendingPayments;
|
|
329
|
+
/** 关系数组是完整快照,不能拼接或按商品子项生成 UID;扩展字段整体保留。 */
|
|
330
|
+
private applyHolderRelationsSnapshot;
|
|
331
|
+
/** 全量拉取缺少关系字段时,仍保留同一订单已有的关系快照。 */
|
|
332
|
+
private preserveOmittedHolderRelations;
|
|
329
333
|
private mergeOrderRecords;
|
|
330
334
|
private summarizeDuplicateOrders;
|
|
331
335
|
private logDuplicateOrders;
|