@pisell/pisellos 2.1.74 → 2.1.75
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/Product/index.d.ts +1 -1
- package/dist/modules/Rules/index.d.ts +3 -1
- package/dist/modules/Rules/index.js +96 -12
- package/dist/modules/Rules/types.d.ts +6 -0
- package/dist/modules/Rules/types.js +8 -0
- package/dist/solution/BookingByStep/index.d.ts +2 -2
- package/dist/solution/BookingByStep/index.js +22 -4
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/ShopDiscount/index.d.ts +2 -0
- package/dist/solution/ShopDiscount/index.js +9 -5
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/Rules/index.d.ts +3 -1
- package/lib/modules/Rules/index.js +41 -2
- package/lib/modules/Rules/types.d.ts +6 -0
- package/lib/modules/Rules/types.js +11 -2
- package/lib/solution/BookingByStep/index.d.ts +2 -2
- package/lib/solution/BookingByStep/index.js +18 -4
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/ShopDiscount/index.d.ts +2 -0
- package/lib/solution/ShopDiscount/index.js +9 -4
- package/package.json +1 -1
|
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
|
|
|
49
49
|
getCategories(): ProductCategory[];
|
|
50
50
|
setOtherParams(key: string, value: any): void;
|
|
51
51
|
getOtherParams(): any;
|
|
52
|
-
getProductType(): "
|
|
52
|
+
getProductType(): "normal" | "duration" | "session";
|
|
53
53
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Module, PisellCore, ModuleOptions } from '../../types';
|
|
2
2
|
import { BaseModule } from '../BaseModule';
|
|
3
|
-
import { Rules, RulesModuleAPI, DiscountResult } from './types';
|
|
3
|
+
import { Rules, RulesModuleAPI, DiscountResult, UnavailableReason } from './types';
|
|
4
4
|
import { Discount } from "../Discount/types";
|
|
5
5
|
import { SetDiscountSelectedParams } from '../../solution/ShopDiscount/types';
|
|
6
6
|
export declare class RulesModule extends BaseModule implements Module, RulesModuleAPI {
|
|
@@ -25,7 +25,9 @@ export declare class RulesModule extends BaseModule implements Module, RulesModu
|
|
|
25
25
|
isAvailable: boolean;
|
|
26
26
|
discountList: Discount[];
|
|
27
27
|
productList: any[];
|
|
28
|
+
unavailableReason?: UnavailableReason;
|
|
28
29
|
};
|
|
30
|
+
private getUnavailableReason;
|
|
29
31
|
calcDiscount({ discountList, productList, holders, isFormSubject, }: {
|
|
30
32
|
discountList: Discount[];
|
|
31
33
|
productList: any[];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
2
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
3
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
4
5
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
5
6
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
6
7
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
@@ -24,6 +25,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
24
25
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
25
26
|
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); }
|
|
26
27
|
import { BaseModule } from "../BaseModule";
|
|
28
|
+
import { UnavailableReason } from "./types";
|
|
27
29
|
import { uniqueById, getDiscountAmount, getDiscountListAmountTotal, getDiscountListAmount, filterDiscountListByBookingTime, isOrderLevelFixedAmountDiscount, calculateOrderLevelDiscountAllocation } from "../../solution/ShopDiscount/utils";
|
|
28
30
|
import { getProductOriginTotalPrice, getProductTotalPrice } from "../Cart/utils";
|
|
29
31
|
import Decimal from 'decimal.js';
|
|
@@ -140,7 +142,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
140
142
|
return {
|
|
141
143
|
isAvailable: false,
|
|
142
144
|
discountList: oldDiscountList,
|
|
143
|
-
productList: productList
|
|
145
|
+
productList: productList,
|
|
146
|
+
unavailableReason: UnavailableReason.AlreadyUsed
|
|
144
147
|
};
|
|
145
148
|
}
|
|
146
149
|
|
|
@@ -185,12 +188,93 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
185
188
|
}
|
|
186
189
|
}
|
|
187
190
|
});
|
|
191
|
+
|
|
192
|
+
// 如果券不可用,判断不可用原因
|
|
193
|
+
var unavailableReason;
|
|
194
|
+
if (!hasApplicableDiscount) {
|
|
195
|
+
unavailableReason = this.getUnavailableReason(newDiscountList, productList);
|
|
196
|
+
}
|
|
188
197
|
return {
|
|
189
198
|
isAvailable: hasApplicableDiscount,
|
|
190
199
|
discountList: hasApplicableDiscount ? result.discountList : oldDiscountList,
|
|
191
|
-
productList: hasApplicableDiscount ? result.productList : productList
|
|
200
|
+
productList: hasApplicableDiscount ? result.productList : productList,
|
|
201
|
+
unavailableReason: unavailableReason
|
|
192
202
|
};
|
|
193
203
|
}
|
|
204
|
+
|
|
205
|
+
// 获取券不可用的原因
|
|
206
|
+
}, {
|
|
207
|
+
key: "getUnavailableReason",
|
|
208
|
+
value: function getUnavailableReason(discountList, productList) {
|
|
209
|
+
// 检查时间限制
|
|
210
|
+
var _iterator = _createForOfIteratorHelper(discountList),
|
|
211
|
+
_step;
|
|
212
|
+
try {
|
|
213
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
214
|
+
var discount = _step.value;
|
|
215
|
+
var _iterator3 = _createForOfIteratorHelper(productList),
|
|
216
|
+
_step3;
|
|
217
|
+
try {
|
|
218
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
219
|
+
var item = _step3.value;
|
|
220
|
+
var product = this.hooks.getProduct(item);
|
|
221
|
+
var bookingTime = ((product === null || product === void 0 ? void 0 : product.startDate) || dayjs()).format('YYYY-MM-DD HH:mm:ss');
|
|
222
|
+
var filteredList = filterDiscountListByBookingTime([discount], bookingTime);
|
|
223
|
+
if (filteredList.length === 0) {
|
|
224
|
+
return UnavailableReason.TimeLimit;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
} catch (err) {
|
|
228
|
+
_iterator3.e(err);
|
|
229
|
+
} finally {
|
|
230
|
+
_iterator3.f();
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// 检查商品适用性
|
|
235
|
+
} catch (err) {
|
|
236
|
+
_iterator.e(err);
|
|
237
|
+
} finally {
|
|
238
|
+
_iterator.f();
|
|
239
|
+
}
|
|
240
|
+
var _iterator2 = _createForOfIteratorHelper(discountList),
|
|
241
|
+
_step2;
|
|
242
|
+
try {
|
|
243
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
244
|
+
var _discount = _step2.value;
|
|
245
|
+
var limitedData = _discount.limited_relation_product_data;
|
|
246
|
+
var hasApplicableProduct = false;
|
|
247
|
+
var _iterator4 = _createForOfIteratorHelper(productList),
|
|
248
|
+
_step4;
|
|
249
|
+
try {
|
|
250
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
251
|
+
var _limitedData$product_;
|
|
252
|
+
var _item = _step4.value;
|
|
253
|
+
var _product = this.hooks.getProduct(_item);
|
|
254
|
+
if (limitedData.type === 'product_all') {
|
|
255
|
+
hasApplicableProduct = true;
|
|
256
|
+
break;
|
|
257
|
+
} else if ((_limitedData$product_ = limitedData.product_ids) !== null && _limitedData$product_ !== void 0 && _limitedData$product_.includes(_product.id)) {
|
|
258
|
+
hasApplicableProduct = true;
|
|
259
|
+
break;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
} catch (err) {
|
|
263
|
+
_iterator4.e(err);
|
|
264
|
+
} finally {
|
|
265
|
+
_iterator4.f();
|
|
266
|
+
}
|
|
267
|
+
if (!hasApplicableProduct) {
|
|
268
|
+
return UnavailableReason.ProductNotApplicable;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
} catch (err) {
|
|
272
|
+
_iterator2.e(err);
|
|
273
|
+
} finally {
|
|
274
|
+
_iterator2.f();
|
|
275
|
+
}
|
|
276
|
+
return UnavailableReason.Unknown;
|
|
277
|
+
}
|
|
194
278
|
}, {
|
|
195
279
|
key: "calcDiscount",
|
|
196
280
|
value: function calcDiscount(_ref2, options) {
|
|
@@ -489,7 +573,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
489
573
|
|
|
490
574
|
// 辅助函数:检查商品是否对某个折扣卡可用
|
|
491
575
|
var checkItemApplicableForDiscount = function checkItemApplicableForDiscount(flatItem, discount) {
|
|
492
|
-
var
|
|
576
|
+
var _product2, _product3, _product4, _flatItem$bundleItem, _flatItem$bundleItem2, _product5;
|
|
493
577
|
var product;
|
|
494
578
|
if (flatItem.type === 'main') {
|
|
495
579
|
product = flatItem.product;
|
|
@@ -508,7 +592,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
508
592
|
}
|
|
509
593
|
|
|
510
594
|
// 编辑的商品使用了优惠券不可用
|
|
511
|
-
var isAvailableProduct = flatItem.type === 'main' ? !((
|
|
595
|
+
var isAvailableProduct = flatItem.type === 'main' ? !((_product2 = product) !== null && _product2 !== void 0 && _product2.booking_id && (_product3 = product) !== null && _product3 !== void 0 && (_product3 = _product3.discount_list) !== null && _product3 !== void 0 && _product3.length && (_product4 = product) !== null && _product4 !== void 0 && (_product4 = _product4.discount_list) !== null && _product4 !== void 0 && _product4.every(function (d) {
|
|
512
596
|
return d.id && ['good_pass', 'discount_card', 'product_discount_card'].includes(d.tag || d.type);
|
|
513
597
|
})) : !(flatItem !== null && flatItem !== void 0 && flatItem.booking_id && !!(flatItem !== null && flatItem !== void 0 && (_flatItem$bundleItem = flatItem.bundleItem) !== null && _flatItem$bundleItem !== void 0 && (_flatItem$bundleItem = _flatItem$bundleItem.discount_list) !== null && _flatItem$bundleItem !== void 0 && _flatItem$bundleItem.length) && flatItem !== null && flatItem !== void 0 && (_flatItem$bundleItem2 = flatItem.bundleItem) !== null && _flatItem$bundleItem2 !== void 0 && (_flatItem$bundleItem2 = _flatItem$bundleItem2.discount_list) !== null && _flatItem$bundleItem2 !== void 0 && _flatItem$bundleItem2.every(function (d) {
|
|
514
598
|
return d.id;
|
|
@@ -529,7 +613,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
529
613
|
var limitedData = discount.limited_relation_product_data;
|
|
530
614
|
|
|
531
615
|
// 时间限制检查
|
|
532
|
-
var timeLimit = !!filterDiscountListByBookingTime([discount], (((
|
|
616
|
+
var timeLimit = !!filterDiscountListByBookingTime([discount], (((_product5 = product) === null || _product5 === void 0 ? void 0 : _product5.startDate) || dayjs()).format('YYYY-MM-DD HH:mm:ss')).length;
|
|
533
617
|
if (!timeLimit) {
|
|
534
618
|
return false;
|
|
535
619
|
}
|
|
@@ -694,7 +778,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
694
778
|
originProduct = flatItem.originProduct;
|
|
695
779
|
}
|
|
696
780
|
addModeDiscount.forEach(function (discount) {
|
|
697
|
-
var
|
|
781
|
+
var _product6, _product7, _product8, _product9, _flatItem$bundleItem3, _flatItem$bundleItem4;
|
|
698
782
|
var limitedData = discount === null || discount === void 0 ? void 0 : discount.limited_relation_product_data;
|
|
699
783
|
// 拿到discount配置的holder信息 product信息 product.holder 加在 isLimitedProduct
|
|
700
784
|
var _tempVar = (flatItem === null || flatItem === void 0 ? void 0 : flatItem.type) === 'bundle' ? flatItem === null || flatItem === void 0 ? void 0 : flatItem.parentProduct : flatItem === null || flatItem === void 0 ? void 0 : flatItem.product;
|
|
@@ -703,12 +787,12 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
703
787
|
holder_id: (_tempVar === null || _tempVar === void 0 ? void 0 : _tempVar.holder_id) || product.holder_id
|
|
704
788
|
}, holders);
|
|
705
789
|
var timeLimit = true;
|
|
706
|
-
timeLimit = !!filterDiscountListByBookingTime([discount], (((
|
|
790
|
+
timeLimit = !!filterDiscountListByBookingTime([discount], (((_product6 = product) === null || _product6 === void 0 ? void 0 : _product6.startDate) || dayjs()).format('YYYY-MM-DD HH:mm:ss')).length;
|
|
707
791
|
// 是符合折扣的商品
|
|
708
792
|
var isLimitedProduct = (limitedData.type === 'product_all' || limitedData.product_ids && limitedData.product_ids.includes(product.id)) && isHolderMatch;
|
|
709
793
|
|
|
710
794
|
// 编辑的商品 使用了优惠券不可用
|
|
711
|
-
var isAvailableProduct = flatItem.type === 'main' ? !((
|
|
795
|
+
var isAvailableProduct = flatItem.type === 'main' ? !((_product7 = product) !== null && _product7 !== void 0 && _product7.booking_id && (_product8 = product) !== null && _product8 !== void 0 && (_product8 = _product8.discount_list) !== null && _product8 !== void 0 && _product8.length && (_product9 = product) !== null && _product9 !== void 0 && (_product9 = _product9.discount_list) !== null && _product9 !== void 0 && _product9.every(function (discount) {
|
|
712
796
|
return discount.id && ['good_pass', 'discount_card', 'product_discount_card'].includes(discount.tag || discount.type);
|
|
713
797
|
})) : !(flatItem !== null && flatItem !== void 0 && flatItem.booking_id && !!(flatItem !== null && flatItem !== void 0 && (_flatItem$bundleItem3 = flatItem.bundleItem) !== null && _flatItem$bundleItem3 !== void 0 && (_flatItem$bundleItem3 = _flatItem$bundleItem3.discount_list) !== null && _flatItem$bundleItem3 !== void 0 && _flatItem$bundleItem3.length) && flatItem !== null && flatItem !== void 0 && (_flatItem$bundleItem4 = flatItem.bundleItem) !== null && _flatItem$bundleItem4 !== void 0 && (_flatItem$bundleItem4 = _flatItem$bundleItem4.discount_list) !== null && _flatItem$bundleItem4 !== void 0 && _flatItem$bundleItem4.every(function (discount) {
|
|
714
798
|
return discount.id;
|
|
@@ -760,7 +844,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
760
844
|
// 然后再处理应用哪些优惠券,此时只考虑filteredDiscountList中的优惠券
|
|
761
845
|
// 🔥 使用扁平化后的列表进行处理
|
|
762
846
|
sortedFlattenedList.forEach(function (flatItem, index) {
|
|
763
|
-
var
|
|
847
|
+
var _product10, _product$discount_lis2, _product11;
|
|
764
848
|
// 获取商品数据
|
|
765
849
|
var product, originProduct;
|
|
766
850
|
if (flatItem.type === 'main') {
|
|
@@ -786,7 +870,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
786
870
|
}
|
|
787
871
|
|
|
788
872
|
// 已有优惠的商品跳过
|
|
789
|
-
if ((
|
|
873
|
+
if ((_product10 = product) !== null && _product10 !== void 0 && _product10.booking_id && (_product$discount_lis2 = product.discount_list) !== null && _product$discount_lis2 !== void 0 && _product$discount_lis2.length && (_product11 = product) !== null && _product11 !== void 0 && (_product11 = _product11.discount_list) !== null && _product11 !== void 0 && _product11.every(function (discount) {
|
|
790
874
|
return discount.id && ['good_pass', 'discount_card', 'product_discount_card'].includes(discount.tag || discount.type);
|
|
791
875
|
})) {
|
|
792
876
|
if (flatItem.type === 'main') {
|
|
@@ -858,12 +942,12 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
858
942
|
// 如果是手动折扣,则不适用优惠券
|
|
859
943
|
var isManualDiscount = false;
|
|
860
944
|
if (flatItem.type === 'main') {
|
|
861
|
-
var _product$discount_lis5,
|
|
945
|
+
var _product$discount_lis5, _product12, _product12$every;
|
|
862
946
|
// 主商品:判断自身是否手动折扣
|
|
863
947
|
isManualDiscount = typeof product.isManualDiscount === 'boolean' ? product.isManualDiscount : product.total != product.origin_total && (product.bundle || []).every(function (item) {
|
|
864
948
|
var _ref6;
|
|
865
949
|
return !((_ref6 = item.discount_list || []) !== null && _ref6 !== void 0 && _ref6.length);
|
|
866
|
-
}) && (!((_product$discount_lis5 = product.discount_list) !== null && _product$discount_lis5 !== void 0 && _product$discount_lis5.length) || ((
|
|
950
|
+
}) && (!((_product$discount_lis5 = product.discount_list) !== null && _product$discount_lis5 !== void 0 && _product$discount_lis5.length) || ((_product12 = product) === null || _product12 === void 0 || (_product12 = _product12.discount_list) === null || _product12 === void 0 || (_product12$every = _product12.every) === null || _product12$every === void 0 ? void 0 : _product12$every.call(_product12, function (item) {
|
|
867
951
|
return item.type === 'product';
|
|
868
952
|
})));
|
|
869
953
|
} else {
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import { Discount } from '../Discount/types';
|
|
2
|
+
export declare enum UnavailableReason {
|
|
3
|
+
TimeLimit = "time_limit",
|
|
4
|
+
ProductNotApplicable = "product_not_applicable",
|
|
5
|
+
AlreadyUsed = "already_used",
|
|
6
|
+
Unknown = "unknown"
|
|
7
|
+
}
|
|
2
8
|
export declare enum RulesHooks {
|
|
3
9
|
OnRulesListChange = "rules:onRulesListChange",
|
|
4
10
|
OnDestroy = "rules:onDestroy"
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
// 券不可用原因枚举
|
|
2
|
+
export var UnavailableReason = /*#__PURE__*/function (UnavailableReason) {
|
|
3
|
+
UnavailableReason["TimeLimit"] = "time_limit";
|
|
4
|
+
UnavailableReason["ProductNotApplicable"] = "product_not_applicable";
|
|
5
|
+
UnavailableReason["AlreadyUsed"] = "already_used";
|
|
6
|
+
UnavailableReason["Unknown"] = "unknown";
|
|
7
|
+
return UnavailableReason;
|
|
8
|
+
}({});
|
|
1
9
|
export var RulesHooks = /*#__PURE__*/function (RulesHooks) {
|
|
2
10
|
RulesHooks["OnRulesListChange"] = "rules:onRulesListChange";
|
|
3
11
|
RulesHooks["OnDestroy"] = "rules:onDestroy";
|
|
@@ -307,7 +307,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
307
307
|
date: string;
|
|
308
308
|
status: string;
|
|
309
309
|
week: string;
|
|
310
|
-
weekNum: 0 |
|
|
310
|
+
weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
|
|
311
311
|
}[]>;
|
|
312
312
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
313
313
|
private getScheduleDataByIds;
|
|
@@ -354,7 +354,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
354
354
|
};
|
|
355
355
|
setOtherData(key: string, value: any): void;
|
|
356
356
|
getOtherData(key: string): any;
|
|
357
|
-
getProductTypeById(id: number): Promise<"
|
|
357
|
+
getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
|
|
358
358
|
/**
|
|
359
359
|
* 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
|
|
360
360
|
*
|
|
@@ -4256,12 +4256,28 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4256
4256
|
// 总量=每个资源在每个时间片内资源总量之和
|
|
4257
4257
|
var isAllResourceTypesUseable = true;
|
|
4258
4258
|
openResources.forEach(function (resource) {
|
|
4259
|
+
var _resource$renderList;
|
|
4259
4260
|
// if (!isAllResourceTypesUseable) return;
|
|
4260
4261
|
|
|
4261
4262
|
// 获取当前资源类型的资源列表
|
|
4262
4263
|
var currentResourcesList = allProductResources.filter(function (n) {
|
|
4263
4264
|
return n.form_id === resource.resource_type_id;
|
|
4264
4265
|
});
|
|
4266
|
+
// 如果resource.renderList里含有 onlyComputed 的数据,需要把 currentResourcesList 的数据也修正回来
|
|
4267
|
+
(_resource$renderList = resource.renderList) === null || _resource$renderList === void 0 || _resource$renderList.forEach(function (item) {
|
|
4268
|
+
if (item.onlyComputed) {
|
|
4269
|
+
var targetIndex = currentResourcesList.findIndex(function (n) {
|
|
4270
|
+
return n.id === item.id;
|
|
4271
|
+
});
|
|
4272
|
+
if (targetIndex && targetIndex !== -1) {
|
|
4273
|
+
currentResourcesList[targetIndex].onlyComputed = true;
|
|
4274
|
+
}
|
|
4275
|
+
}
|
|
4276
|
+
});
|
|
4277
|
+
// currentResourcesList 排序,onlyComputed 的资源排在前面先计算
|
|
4278
|
+
currentResourcesList.sort(function (a, b) {
|
|
4279
|
+
return a.onlyComputed ? -1 : 1;
|
|
4280
|
+
});
|
|
4265
4281
|
var isAnyResourceUseableInType = false;
|
|
4266
4282
|
currentResourcesList === null || currentResourcesList === void 0 || currentResourcesList.forEach(function (m) {
|
|
4267
4283
|
// 遍历所有资源的上工时间片
|
|
@@ -4275,10 +4291,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4275
4291
|
// 如果在这个区间的时间一个都没有,可以直接认为这个资源不可用
|
|
4276
4292
|
if (mTimes.length === 0) return;
|
|
4277
4293
|
// 如果资源可用则把他的容量纳入总计
|
|
4278
|
-
if (
|
|
4279
|
-
|
|
4280
|
-
|
|
4281
|
-
|
|
4294
|
+
if (!m.onlyComputed) {
|
|
4295
|
+
if (resource.type === 'multiple') {
|
|
4296
|
+
summaryCount += m.capacity;
|
|
4297
|
+
} else {
|
|
4298
|
+
summaryCount += 1;
|
|
4299
|
+
}
|
|
4282
4300
|
}
|
|
4283
4301
|
var isAnyTimeSliceUseable = false;
|
|
4284
4302
|
mTimes.forEach(function (childTiem) {
|
|
@@ -115,7 +115,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
|
|
|
115
115
|
* 获取当前的客户搜索条件
|
|
116
116
|
* @returns 当前搜索条件
|
|
117
117
|
*/
|
|
118
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
118
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
|
|
119
119
|
/**
|
|
120
120
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
121
121
|
* @returns 客户状态
|
|
@@ -2,6 +2,7 @@ import { Module, PisellCore } from '../../types';
|
|
|
2
2
|
import { BaseModule } from '../../modules/BaseModule';
|
|
3
3
|
import { Customer, SetDiscountSelectedParams } from './types';
|
|
4
4
|
import { Discount } from '../../modules/Discount/types';
|
|
5
|
+
import { UnavailableReason } from '../../modules/Rules/types';
|
|
5
6
|
export declare class ShopDiscountImpl extends BaseModule implements Module {
|
|
6
7
|
protected defaultName: string;
|
|
7
8
|
protected defaultVersion: string;
|
|
@@ -42,6 +43,7 @@ export declare class ShopDiscountImpl extends BaseModule implements Module {
|
|
|
42
43
|
productList: Record<string, any>[];
|
|
43
44
|
discountList: Discount[];
|
|
44
45
|
type: "server" | "clientCalc";
|
|
46
|
+
unavailableReason?: UnavailableReason;
|
|
45
47
|
}>;
|
|
46
48
|
calcDiscountApplicableProductTotalPrice(discount: Discount): number | undefined;
|
|
47
49
|
private getCustomer;
|
|
@@ -28,6 +28,7 @@ import { BaseModule } from "../../modules/BaseModule";
|
|
|
28
28
|
import { DiscountModule } from "../../modules/Discount";
|
|
29
29
|
import { RulesModule } from "../../modules/Rules";
|
|
30
30
|
import { filterDiscountListByBookingTime as _filterDiscountListByBookingTime, isAllNormalProduct } from "./utils";
|
|
31
|
+
import { UnavailableReason } from "../../modules/Rules/types";
|
|
31
32
|
import Decimal from 'decimal.js';
|
|
32
33
|
import { isBoolean } from 'lodash-es';
|
|
33
34
|
export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
@@ -389,7 +390,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
389
390
|
key: "scanCode",
|
|
390
391
|
value: function () {
|
|
391
392
|
var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(code, customerId) {
|
|
392
|
-
var _this$store$discount3, _this$store$bookingSu2, resultDiscountList, rulesModule, withScanList, currentSelectedDiscountList, _ref2, newProductList, newDiscountList, isAvailable, _this$options$otherPa6;
|
|
393
|
+
var _this$store$discount3, _this$store$bookingSu2, resultDiscountList, rulesModule, withScanList, currentSelectedDiscountList, _ref2, newProductList, newDiscountList, isAvailable, unavailableReason, _this$options$otherPa6;
|
|
393
394
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
394
395
|
while (1) switch (_context5.prev = _context5.next) {
|
|
395
396
|
case 0:
|
|
@@ -414,7 +415,8 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
414
415
|
type: "clientCalc",
|
|
415
416
|
isAvailable: false,
|
|
416
417
|
productList: this.store.productList || [],
|
|
417
|
-
discountList: this.getDiscountList()
|
|
418
|
+
discountList: this.getDiscountList(),
|
|
419
|
+
unavailableReason: UnavailableReason.Unknown
|
|
418
420
|
});
|
|
419
421
|
case 10:
|
|
420
422
|
if (resultDiscountList.length) {
|
|
@@ -461,7 +463,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
461
463
|
isAvailable: false,
|
|
462
464
|
productList: this.store.productList || [],
|
|
463
465
|
discountList: this.getDiscountList()
|
|
464
|
-
}, newProductList = _ref2.productList, newDiscountList = _ref2.discountList, isAvailable = _ref2.isAvailable;
|
|
466
|
+
}, newProductList = _ref2.productList, newDiscountList = _ref2.discountList, isAvailable = _ref2.isAvailable, unavailableReason = _ref2.unavailableReason;
|
|
465
467
|
if (!isAvailable) {
|
|
466
468
|
_context5.next = 24;
|
|
467
469
|
break;
|
|
@@ -480,7 +482,8 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
480
482
|
type: "clientCalc",
|
|
481
483
|
isAvailable: isAvailable || false,
|
|
482
484
|
productList: newProductList || this.store.productList || [],
|
|
483
|
-
discountList: newDiscountList || this.getDiscountList()
|
|
485
|
+
discountList: newDiscountList || this.getDiscountList(),
|
|
486
|
+
unavailableReason: unavailableReason
|
|
484
487
|
});
|
|
485
488
|
case 27:
|
|
486
489
|
_context5.prev = 27;
|
|
@@ -490,7 +493,8 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
490
493
|
type: "clientCalc",
|
|
491
494
|
isAvailable: false,
|
|
492
495
|
productList: this.store.productList || [],
|
|
493
|
-
discountList: this.getDiscountList()
|
|
496
|
+
discountList: this.getDiscountList(),
|
|
497
|
+
unavailableReason: UnavailableReason.Unknown
|
|
494
498
|
});
|
|
495
499
|
case 31:
|
|
496
500
|
case "end":
|
|
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
|
|
|
49
49
|
getCategories(): ProductCategory[];
|
|
50
50
|
setOtherParams(key: string, value: any): void;
|
|
51
51
|
getOtherParams(): any;
|
|
52
|
-
getProductType(): "
|
|
52
|
+
getProductType(): "normal" | "duration" | "session";
|
|
53
53
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Module, PisellCore, ModuleOptions } from '../../types';
|
|
2
2
|
import { BaseModule } from '../BaseModule';
|
|
3
|
-
import { Rules, RulesModuleAPI, DiscountResult } from './types';
|
|
3
|
+
import { Rules, RulesModuleAPI, DiscountResult, UnavailableReason } from './types';
|
|
4
4
|
import { Discount } from "../Discount/types";
|
|
5
5
|
import { SetDiscountSelectedParams } from '../../solution/ShopDiscount/types';
|
|
6
6
|
export declare class RulesModule extends BaseModule implements Module, RulesModuleAPI {
|
|
@@ -25,7 +25,9 @@ export declare class RulesModule extends BaseModule implements Module, RulesModu
|
|
|
25
25
|
isAvailable: boolean;
|
|
26
26
|
discountList: Discount[];
|
|
27
27
|
productList: any[];
|
|
28
|
+
unavailableReason?: UnavailableReason;
|
|
28
29
|
};
|
|
30
|
+
private getUnavailableReason;
|
|
29
31
|
calcDiscount({ discountList, productList, holders, isFormSubject, }: {
|
|
30
32
|
discountList: Discount[];
|
|
31
33
|
productList: any[];
|
|
@@ -33,6 +33,7 @@ __export(Rules_exports, {
|
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(Rules_exports);
|
|
35
35
|
var import_BaseModule = require("../BaseModule");
|
|
36
|
+
var import_types = require("./types");
|
|
36
37
|
var import_utils = require("../../solution/ShopDiscount/utils");
|
|
37
38
|
var import_utils2 = require("../Cart/utils");
|
|
38
39
|
var import_decimal = __toESM(require("decimal.js"));
|
|
@@ -93,7 +94,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
93
94
|
return {
|
|
94
95
|
isAvailable: false,
|
|
95
96
|
discountList: oldDiscountList,
|
|
96
|
-
productList
|
|
97
|
+
productList,
|
|
98
|
+
unavailableReason: import_types.UnavailableReason.AlreadyUsed
|
|
97
99
|
};
|
|
98
100
|
}
|
|
99
101
|
const filteredOldDiscountList = oldDiscountList.filter(
|
|
@@ -131,12 +133,49 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
131
133
|
}
|
|
132
134
|
}
|
|
133
135
|
});
|
|
136
|
+
let unavailableReason;
|
|
137
|
+
if (!hasApplicableDiscount) {
|
|
138
|
+
unavailableReason = this.getUnavailableReason(newDiscountList, productList);
|
|
139
|
+
}
|
|
134
140
|
return {
|
|
135
141
|
isAvailable: hasApplicableDiscount,
|
|
136
142
|
discountList: hasApplicableDiscount ? result.discountList : oldDiscountList,
|
|
137
|
-
productList: hasApplicableDiscount ? result.productList : productList
|
|
143
|
+
productList: hasApplicableDiscount ? result.productList : productList,
|
|
144
|
+
unavailableReason
|
|
138
145
|
};
|
|
139
146
|
}
|
|
147
|
+
// 获取券不可用的原因
|
|
148
|
+
getUnavailableReason(discountList, productList) {
|
|
149
|
+
var _a;
|
|
150
|
+
for (const discount of discountList) {
|
|
151
|
+
for (const item of productList) {
|
|
152
|
+
const product = this.hooks.getProduct(item);
|
|
153
|
+
const bookingTime = ((product == null ? void 0 : product.startDate) || (0, import_dayjs.default)()).format("YYYY-MM-DD HH:mm:ss");
|
|
154
|
+
const filteredList = (0, import_utils.filterDiscountListByBookingTime)([discount], bookingTime);
|
|
155
|
+
if (filteredList.length === 0) {
|
|
156
|
+
return import_types.UnavailableReason.TimeLimit;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
for (const discount of discountList) {
|
|
161
|
+
const limitedData = discount.limited_relation_product_data;
|
|
162
|
+
let hasApplicableProduct = false;
|
|
163
|
+
for (const item of productList) {
|
|
164
|
+
const product = this.hooks.getProduct(item);
|
|
165
|
+
if (limitedData.type === "product_all") {
|
|
166
|
+
hasApplicableProduct = true;
|
|
167
|
+
break;
|
|
168
|
+
} else if ((_a = limitedData.product_ids) == null ? void 0 : _a.includes(product.id)) {
|
|
169
|
+
hasApplicableProduct = true;
|
|
170
|
+
break;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
if (!hasApplicableProduct) {
|
|
174
|
+
return import_types.UnavailableReason.ProductNotApplicable;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return import_types.UnavailableReason.Unknown;
|
|
178
|
+
}
|
|
140
179
|
calcDiscount({
|
|
141
180
|
discountList,
|
|
142
181
|
productList,
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import { Discount } from '../Discount/types';
|
|
2
|
+
export declare enum UnavailableReason {
|
|
3
|
+
TimeLimit = "time_limit",
|
|
4
|
+
ProductNotApplicable = "product_not_applicable",
|
|
5
|
+
AlreadyUsed = "already_used",
|
|
6
|
+
Unknown = "unknown"
|
|
7
|
+
}
|
|
2
8
|
export declare enum RulesHooks {
|
|
3
9
|
OnRulesListChange = "rules:onRulesListChange",
|
|
4
10
|
OnDestroy = "rules:onDestroy"
|
|
@@ -19,9 +19,17 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
19
19
|
// src/modules/Rules/types.ts
|
|
20
20
|
var types_exports = {};
|
|
21
21
|
__export(types_exports, {
|
|
22
|
-
RulesHooks: () => RulesHooks
|
|
22
|
+
RulesHooks: () => RulesHooks,
|
|
23
|
+
UnavailableReason: () => UnavailableReason
|
|
23
24
|
});
|
|
24
25
|
module.exports = __toCommonJS(types_exports);
|
|
26
|
+
var UnavailableReason = /* @__PURE__ */ ((UnavailableReason2) => {
|
|
27
|
+
UnavailableReason2["TimeLimit"] = "time_limit";
|
|
28
|
+
UnavailableReason2["ProductNotApplicable"] = "product_not_applicable";
|
|
29
|
+
UnavailableReason2["AlreadyUsed"] = "already_used";
|
|
30
|
+
UnavailableReason2["Unknown"] = "unknown";
|
|
31
|
+
return UnavailableReason2;
|
|
32
|
+
})(UnavailableReason || {});
|
|
25
33
|
var RulesHooks = /* @__PURE__ */ ((RulesHooks2) => {
|
|
26
34
|
RulesHooks2["OnRulesListChange"] = "rules:onRulesListChange";
|
|
27
35
|
RulesHooks2["OnDestroy"] = "rules:onDestroy";
|
|
@@ -29,5 +37,6 @@ var RulesHooks = /* @__PURE__ */ ((RulesHooks2) => {
|
|
|
29
37
|
})(RulesHooks || {});
|
|
30
38
|
// Annotate the CommonJS export names for ESM import in node:
|
|
31
39
|
0 && (module.exports = {
|
|
32
|
-
RulesHooks
|
|
40
|
+
RulesHooks,
|
|
41
|
+
UnavailableReason
|
|
33
42
|
});
|
|
@@ -307,7 +307,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
307
307
|
date: string;
|
|
308
308
|
status: string;
|
|
309
309
|
week: string;
|
|
310
|
-
weekNum: 0 |
|
|
310
|
+
weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
|
|
311
311
|
}[]>;
|
|
312
312
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
313
313
|
private getScheduleDataByIds;
|
|
@@ -354,7 +354,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
354
354
|
};
|
|
355
355
|
setOtherData(key: string, value: any): void;
|
|
356
356
|
getOtherData(key: string): any;
|
|
357
|
-
getProductTypeById(id: number): Promise<"
|
|
357
|
+
getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
|
|
358
358
|
/**
|
|
359
359
|
* 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
|
|
360
360
|
*
|
|
@@ -2980,9 +2980,21 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2980
2980
|
const resourcesUseableMap = {};
|
|
2981
2981
|
let isAllResourceTypesUseable = true;
|
|
2982
2982
|
openResources.forEach((resource) => {
|
|
2983
|
+
var _a2;
|
|
2983
2984
|
const currentResourcesList = allProductResources.filter(
|
|
2984
2985
|
(n) => n.form_id === resource.resource_type_id
|
|
2985
2986
|
);
|
|
2987
|
+
(_a2 = resource.renderList) == null ? void 0 : _a2.forEach((item2) => {
|
|
2988
|
+
if (item2.onlyComputed) {
|
|
2989
|
+
const targetIndex = currentResourcesList.findIndex((n) => n.id === item2.id);
|
|
2990
|
+
if (targetIndex && targetIndex !== -1) {
|
|
2991
|
+
currentResourcesList[targetIndex].onlyComputed = true;
|
|
2992
|
+
}
|
|
2993
|
+
}
|
|
2994
|
+
});
|
|
2995
|
+
currentResourcesList.sort((a, b) => {
|
|
2996
|
+
return a.onlyComputed ? -1 : 1;
|
|
2997
|
+
});
|
|
2986
2998
|
let isAnyResourceUseableInType = false;
|
|
2987
2999
|
currentResourcesList == null ? void 0 : currentResourcesList.forEach((m) => {
|
|
2988
3000
|
const mTimes = m.times.filter((n) => {
|
|
@@ -2990,10 +3002,12 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2990
3002
|
});
|
|
2991
3003
|
if (mTimes.length === 0)
|
|
2992
3004
|
return;
|
|
2993
|
-
if (
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
3005
|
+
if (!m.onlyComputed) {
|
|
3006
|
+
if (resource.type === "multiple") {
|
|
3007
|
+
summaryCount += m.capacity;
|
|
3008
|
+
} else {
|
|
3009
|
+
summaryCount += 1;
|
|
3010
|
+
}
|
|
2997
3011
|
}
|
|
2998
3012
|
let isAnyTimeSliceUseable = false;
|
|
2999
3013
|
mTimes.forEach((childTiem) => {
|
|
@@ -115,7 +115,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
|
|
|
115
115
|
* 获取当前的客户搜索条件
|
|
116
116
|
* @returns 当前搜索条件
|
|
117
117
|
*/
|
|
118
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
118
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
|
|
119
119
|
/**
|
|
120
120
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
121
121
|
* @returns 客户状态
|
|
@@ -2,6 +2,7 @@ import { Module, PisellCore } from '../../types';
|
|
|
2
2
|
import { BaseModule } from '../../modules/BaseModule';
|
|
3
3
|
import { Customer, SetDiscountSelectedParams } from './types';
|
|
4
4
|
import { Discount } from '../../modules/Discount/types';
|
|
5
|
+
import { UnavailableReason } from '../../modules/Rules/types';
|
|
5
6
|
export declare class ShopDiscountImpl extends BaseModule implements Module {
|
|
6
7
|
protected defaultName: string;
|
|
7
8
|
protected defaultVersion: string;
|
|
@@ -42,6 +43,7 @@ export declare class ShopDiscountImpl extends BaseModule implements Module {
|
|
|
42
43
|
productList: Record<string, any>[];
|
|
43
44
|
discountList: Discount[];
|
|
44
45
|
type: "server" | "clientCalc";
|
|
46
|
+
unavailableReason?: UnavailableReason;
|
|
45
47
|
}>;
|
|
46
48
|
calcDiscountApplicableProductTotalPrice(discount: Discount): number | undefined;
|
|
47
49
|
private getCustomer;
|
|
@@ -37,6 +37,7 @@ var import_BaseModule = require("../../modules/BaseModule");
|
|
|
37
37
|
var import_Discount = require("../../modules/Discount");
|
|
38
38
|
var import_Rules = require("../../modules/Rules");
|
|
39
39
|
var import_utils = require("./utils");
|
|
40
|
+
var import_types = require("../../modules/Rules/types");
|
|
40
41
|
var import_decimal = __toESM(require("decimal.js"));
|
|
41
42
|
var import_lodash_es = require("lodash-es");
|
|
42
43
|
var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
@@ -269,7 +270,8 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
269
270
|
type: "clientCalc",
|
|
270
271
|
isAvailable: false,
|
|
271
272
|
productList: this.store.productList || [],
|
|
272
|
-
discountList: this.getDiscountList()
|
|
273
|
+
discountList: this.getDiscountList(),
|
|
274
|
+
unavailableReason: import_types.UnavailableReason.Unknown
|
|
273
275
|
};
|
|
274
276
|
}
|
|
275
277
|
if (!resultDiscountList.length) {
|
|
@@ -298,7 +300,8 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
298
300
|
const {
|
|
299
301
|
productList: newProductList,
|
|
300
302
|
discountList: newDiscountList,
|
|
301
|
-
isAvailable
|
|
303
|
+
isAvailable,
|
|
304
|
+
unavailableReason
|
|
302
305
|
} = rulesModule.isDiscountListAvailable({
|
|
303
306
|
productList: this.store.productList || [],
|
|
304
307
|
oldDiscountList: this.getDiscountList(),
|
|
@@ -324,7 +327,8 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
324
327
|
type: "clientCalc",
|
|
325
328
|
isAvailable: isAvailable || false,
|
|
326
329
|
productList: newProductList || this.store.productList || [],
|
|
327
|
-
discountList: newDiscountList || this.getDiscountList()
|
|
330
|
+
discountList: newDiscountList || this.getDiscountList(),
|
|
331
|
+
unavailableReason
|
|
328
332
|
};
|
|
329
333
|
} catch (error) {
|
|
330
334
|
console.error("[ShopDiscount] 扫码出错:", error);
|
|
@@ -332,7 +336,8 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
332
336
|
type: "clientCalc",
|
|
333
337
|
isAvailable: false,
|
|
334
338
|
productList: this.store.productList || [],
|
|
335
|
-
discountList: this.getDiscountList()
|
|
339
|
+
discountList: this.getDiscountList(),
|
|
340
|
+
unavailableReason: import_types.UnavailableReason.Unknown
|
|
336
341
|
};
|
|
337
342
|
}
|
|
338
343
|
}
|