@pisell/pisellos 0.10.78 → 0.10.79
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 +5 -4
- package/dist/modules/Discount/types.d.ts +4 -0
- package/dist/modules/Order/index.js +27 -13
- package/dist/modules/Rules/index.d.ts +3 -10
- package/dist/modules/Rules/index.js +164 -82
- package/dist/modules/Rules/promotionSelection.d.ts +14 -0
- package/dist/modules/Rules/promotionSelection.js +390 -0
- package/dist/modules/Rules/types.d.ts +9 -0
- package/dist/solution/BaseSales/index.js +41 -21
- package/dist/solution/BaseSales/utils/cartPromotion.js +5 -2
- package/lib/model/strategy/adapter/promotion/evaluator.js +5 -4
- package/lib/model/strategy/adapter/promotion/index.js +1 -46
- package/lib/modules/Discount/types.d.ts +4 -0
- package/lib/modules/Order/index.js +11 -0
- package/lib/modules/Rules/index.d.ts +3 -10
- package/lib/modules/Rules/index.js +62 -22
- package/lib/modules/Rules/promotionSelection.d.ts +14 -0
- package/lib/modules/Rules/promotionSelection.js +230 -0
- package/lib/modules/Rules/types.d.ts +9 -0
- package/lib/solution/BaseSales/index.js +19 -5
- package/lib/solution/BaseSales/utils/cartPromotion.js +5 -2
- package/package.json +1 -1
|
@@ -807,6 +807,7 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
|
|
|
807
807
|
_iterator12.f();
|
|
808
808
|
}
|
|
809
809
|
var allocatedPricesByProductId = new Map();
|
|
810
|
+
var expectedPromoTotal = new Decimal(0);
|
|
810
811
|
for (var g = 0; g < groupCount; g++) {
|
|
811
812
|
var startIdx = g * x;
|
|
812
813
|
var endIdx = startIdx + x;
|
|
@@ -817,8 +818,9 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
|
|
|
817
818
|
return sum.plus(u.price);
|
|
818
819
|
}, new Decimal(0));
|
|
819
820
|
|
|
820
|
-
//
|
|
821
|
-
var groupPriceDecimal = new Decimal(groupPrice);
|
|
821
|
+
// 组价高于本组原价时保留原价,尾差目标也必须使用封顶后的实际组价。
|
|
822
|
+
var groupPriceDecimal = Decimal.min(new Decimal(groupPrice), groupOriginalTotal);
|
|
823
|
+
expectedPromoTotal = expectedPromoTotal.plus(groupPriceDecimal);
|
|
822
824
|
var allocatedSum = new Decimal(0);
|
|
823
825
|
for (var i = 0; i < groupUnits.length; i++) {
|
|
824
826
|
var unit = groupUnits[i];
|
|
@@ -926,14 +928,13 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
|
|
|
926
928
|
processedQuantityMap.set(_key, _processedQty + _availableQty);
|
|
927
929
|
}
|
|
928
930
|
|
|
929
|
-
// 8.
|
|
931
|
+
// 8. 尾差调整:只补实际组价的舍入差额,不将高于原价的组价补到某一件。
|
|
930
932
|
} catch (err) {
|
|
931
933
|
_iterator13.e(err);
|
|
932
934
|
} finally {
|
|
933
935
|
_iterator13.f();
|
|
934
936
|
}
|
|
935
937
|
if (groupCount > 0) {
|
|
936
|
-
var expectedPromoTotal = new Decimal(groupPrice).mul(groupCount);
|
|
937
938
|
var promoItems = result.filter(function (p) {
|
|
938
939
|
return p.inPromotion;
|
|
939
940
|
});
|
|
@@ -158,6 +158,10 @@ export interface Discount {
|
|
|
158
158
|
discount_calculation_mode: 'item_level' | 'order_level';
|
|
159
159
|
};
|
|
160
160
|
isManualSelect?: boolean;
|
|
161
|
+
/** X 件 Y 元互斥选择的手动意图;isSelected 只表示本次实际应用结果。 */
|
|
162
|
+
promotionSelection?: 'card' | 'promotion';
|
|
163
|
+
/** 记录手动操作影响的促销组,避免卡失效后普通重算丢失取消意图。 */
|
|
164
|
+
promotionSelectionStrategyIds?: string[];
|
|
161
165
|
isDisabled?: boolean;
|
|
162
166
|
isSelected?: boolean;
|
|
163
167
|
isAvailable?: boolean;
|
|
@@ -867,7 +867,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
867
867
|
_this$store$discount,
|
|
868
868
|
_this7 = this,
|
|
869
869
|
_this$store$tempOrder3;
|
|
870
|
-
var orderId, requestEpoch, requestOrderIdentityKey, prepareConfigResult, isCurrentRequest, discountList, _this$store$discount2, _this$store$discount3, _this$store$discount4, currentDiscountList, currentCommittedDiscounts, currentScanDiscounts, currentScanDiscountById, committedDiscountById, mergedCommittedDiscountIds, refreshedScanDiscountIds, runtimeDiscountIds, runtimeDiscounts, retainedCommittedDiscounts, retainedScanDiscounts, mergedDiscountList;
|
|
870
|
+
var orderId, requestEpoch, requestOrderIdentityKey, prepareConfigResult, isCurrentRequest, discountList, _this$store$discount2, _this$store$discount3, _this$store$discount4, currentDiscountList, currentPromotionSelections, currentCommittedDiscounts, currentScanDiscounts, currentScanDiscountById, committedDiscountById, mergedCommittedDiscountIds, refreshedScanDiscountIds, runtimeDiscountIds, runtimeDiscounts, retainedCommittedDiscounts, retainedScanDiscounts, mergedDiscountList;
|
|
871
871
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
872
872
|
while (1) switch (_context6.prev = _context6.next) {
|
|
873
873
|
case 0:
|
|
@@ -912,10 +912,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
912
912
|
});
|
|
913
913
|
}
|
|
914
914
|
if (!discountList) {
|
|
915
|
-
_context6.next =
|
|
915
|
+
_context6.next = 33;
|
|
916
916
|
break;
|
|
917
917
|
}
|
|
918
918
|
currentDiscountList = ((_this$store$discount2 = this.store.discount) === null || _this$store$discount2 === void 0 ? void 0 : _this$store$discount2.getDiscountList()) || [];
|
|
919
|
+
currentPromotionSelections = new Map(currentDiscountList.filter(function (discount) {
|
|
920
|
+
return !discount.isEditMode && discount.promotionSelection;
|
|
921
|
+
}).map(function (discount) {
|
|
922
|
+
return [String(discount.id), discount];
|
|
923
|
+
}));
|
|
919
924
|
currentCommittedDiscounts = currentDiscountList.filter(function (discount) {
|
|
920
925
|
var _discount$committedAp;
|
|
921
926
|
return (discount === null || discount === void 0 ? void 0 : discount.isEditMode) || (discount === null || discount === void 0 || (_discount$committedAp = discount.committedAppliedProductDetails) === null || _discount$committedAp === void 0 ? void 0 : _discount$committedAp.length);
|
|
@@ -958,6 +963,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
958
963
|
isManualSelect: (_currentScanDiscount$2 = currentScanDiscount.isManualSelect) !== null && _currentScanDiscount$2 !== void 0 ? _currentScanDiscount$2 : nextDiscount.isManualSelect
|
|
959
964
|
});
|
|
960
965
|
}
|
|
966
|
+
var currentSelection = currentPromotionSelections.get(String(discount.id));
|
|
967
|
+
if (currentSelection) {
|
|
968
|
+
nextDiscount = _objectSpread(_objectSpread({}, nextDiscount), {}, {
|
|
969
|
+
promotionSelection: currentSelection.promotionSelection,
|
|
970
|
+
promotionSelectionStrategyIds: currentSelection.promotionSelectionStrategyIds,
|
|
971
|
+
isManualSelect: currentSelection.isManualSelect,
|
|
972
|
+
isSelected: currentSelection.isSelected
|
|
973
|
+
});
|
|
974
|
+
}
|
|
961
975
|
return [nextDiscount];
|
|
962
976
|
});
|
|
963
977
|
retainedCommittedDiscounts = currentCommittedDiscounts.filter(function (discount) {
|
|
@@ -979,34 +993,34 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
979
993
|
});
|
|
980
994
|
mergedDiscountList = [].concat(_toConsumableArray(retainedCommittedDiscounts), _toConsumableArray(retainedScanDiscounts), _toConsumableArray(runtimeDiscounts));
|
|
981
995
|
if (isCurrentRequest()) {
|
|
982
|
-
_context6.next =
|
|
996
|
+
_context6.next = 27;
|
|
983
997
|
break;
|
|
984
998
|
}
|
|
985
999
|
return _context6.abrupt("return", this.getDiscountList());
|
|
986
|
-
case
|
|
987
|
-
_context6.next =
|
|
1000
|
+
case 27:
|
|
1001
|
+
_context6.next = 29;
|
|
988
1002
|
return (_this$store$discount3 = this.store.discount) === null || _this$store$discount3 === void 0 ? void 0 : _this$store$discount3.setOriginalDiscountList(mergedDiscountList);
|
|
989
|
-
case
|
|
1003
|
+
case 29:
|
|
990
1004
|
if (isCurrentRequest()) {
|
|
991
|
-
_context6.next =
|
|
1005
|
+
_context6.next = 31;
|
|
992
1006
|
break;
|
|
993
1007
|
}
|
|
994
1008
|
return _context6.abrupt("return", this.getDiscountList());
|
|
995
|
-
case
|
|
996
|
-
_context6.next =
|
|
1009
|
+
case 31:
|
|
1010
|
+
_context6.next = 33;
|
|
997
1011
|
return (_this$store$discount4 = this.store.discount) === null || _this$store$discount4 === void 0 ? void 0 : _this$store$discount4.setDiscountList(mergedDiscountList);
|
|
998
|
-
case
|
|
1012
|
+
case 33:
|
|
999
1013
|
if (isCurrentRequest()) {
|
|
1000
|
-
_context6.next =
|
|
1014
|
+
_context6.next = 35;
|
|
1001
1015
|
break;
|
|
1002
1016
|
}
|
|
1003
1017
|
return _context6.abrupt("return", this.getDiscountList());
|
|
1004
|
-
case
|
|
1018
|
+
case 35:
|
|
1005
1019
|
if (params.apply !== false && (_this$store$tempOrder3 = this.store.tempOrder) !== null && _this$store$tempOrder3 !== void 0 && (_this$store$tempOrder3 = _this$store$tempOrder3.products) !== null && _this$store$tempOrder3 !== void 0 && _this$store$tempOrder3.length) {
|
|
1006
1020
|
this.applyDiscount();
|
|
1007
1021
|
}
|
|
1008
1022
|
return _context6.abrupt("return", this.getDiscountList());
|
|
1009
|
-
case
|
|
1023
|
+
case 37:
|
|
1010
1024
|
case "end":
|
|
1011
1025
|
return _context6.stop();
|
|
1012
1026
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Module, PisellCore, ModuleOptions } from '../../types';
|
|
2
2
|
import { BaseModule } from '../BaseModule';
|
|
3
|
-
import { Rules, RulesModuleAPI, DiscountResult, RulesFormSubject, RulesCalcDiscountOptions, UnavailableReason } from './types';
|
|
3
|
+
import { Rules, RulesModuleAPI, DiscountResult, RulesFormSubject, RulesCalcDiscountOptions, RulesCalcDiscountParams, UnavailableReason } from './types';
|
|
4
4
|
import { Discount } from '../Discount/types';
|
|
5
5
|
import { WindowPlugin } from '../../plugins';
|
|
6
6
|
export declare class RulesModule extends BaseModule implements Module, RulesModuleAPI {
|
|
@@ -46,15 +46,8 @@ export declare class RulesModule extends BaseModule implements Module, RulesModu
|
|
|
46
46
|
resolveDiscountListForManualOverride(discountList: Discount[]): Discount[];
|
|
47
47
|
private isItemRewardProductDiscount;
|
|
48
48
|
private getUnavailableReason;
|
|
49
|
-
calcDiscount(
|
|
50
|
-
|
|
51
|
-
productList: any[];
|
|
52
|
-
holders: {
|
|
53
|
-
form_record_id: number;
|
|
54
|
-
}[];
|
|
55
|
-
isFormSubject: RulesFormSubject;
|
|
56
|
-
orderTotalAmount: number;
|
|
57
|
-
}, options?: RulesCalcDiscountOptions): DiscountResult;
|
|
49
|
+
calcDiscount(params: RulesCalcDiscountParams, options?: RulesCalcDiscountOptions): DiscountResult;
|
|
50
|
+
private calcDiscountCore;
|
|
58
51
|
/**
|
|
59
52
|
* 检查优惠是否符合 PackageSubItemUsageRules 配置
|
|
60
53
|
* @param discount 优惠券
|