@pisell/pisellos 2.1.170 → 2.1.172
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/index.d.ts +1 -1
- package/dist/index.js +1 -3
- package/dist/model/strategy/adapter/index.d.ts +0 -4
- package/dist/model/strategy/adapter/index.js +1 -5
- package/dist/model/strategy/adapter/promotion/evaluator.js +99 -26
- package/dist/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +2 -0
- package/dist/model/strategy/adapter/walletPass/evaluator.js +61 -8
- package/dist/model/strategy/adapter/walletPass/locales.js +12 -3
- package/dist/model/strategy/engine.d.ts +18 -5
- package/dist/model/strategy/engine.js +145 -45
- package/dist/model/strategy/type.d.ts +17 -0
- package/dist/model/strategy/type.js +4 -0
- package/dist/modules/Cart/types.d.ts +2 -0
- package/dist/modules/Cart/utils/cartProduct.js +56 -25
- package/dist/modules/Cart/utils/changePrice.js +9 -16
- package/dist/modules/Discount/index.d.ts +4 -13
- package/dist/modules/Discount/index.js +12 -124
- package/dist/modules/Discount/types.d.ts +18 -13
- package/dist/modules/Order/index.d.ts +1 -67
- package/dist/modules/Order/index.js +30 -918
- package/dist/modules/Order/types.d.ts +12 -176
- package/dist/modules/Order/types.js +0 -2
- package/dist/modules/Order/utils.d.ts +0 -118
- package/dist/modules/Order/utils.js +2 -586
- package/dist/modules/Payment/index.d.ts +2 -1
- package/dist/modules/Payment/index.js +10 -7
- package/dist/modules/Payment/utils.js +3 -0
- package/dist/modules/Payment/walletpass.d.ts +23 -0
- package/dist/modules/Payment/walletpass.js +191 -95
- package/dist/modules/Product/utils.js +2 -2
- package/dist/modules/ProductList/index.d.ts +2 -4
- package/dist/modules/ProductList/index.js +12 -24
- package/dist/modules/Rules/index.d.ts +9 -5
- package/dist/modules/Rules/index.js +669 -173
- package/dist/modules/Rules/types.d.ts +2 -0
- package/dist/modules/Schedule/getDateIsInSchedule.js +18 -16
- package/dist/modules/Schedule/utils.d.ts +1 -1
- package/dist/modules/Summary/types.d.ts +2 -0
- package/dist/modules/Summary/utils.d.ts +9 -3
- package/dist/modules/Summary/utils.js +57 -67
- package/dist/modules/index.d.ts +0 -4
- package/dist/modules/index.js +1 -5
- package/dist/plugins/window.d.ts +2 -0
- package/dist/solution/BookingByStep/index.d.ts +3 -2
- package/dist/solution/BookingByStep/index.js +43 -46
- package/dist/solution/BookingByStep/types.d.ts +1 -3
- package/dist/solution/BookingByStep/types.js +1 -5
- package/dist/solution/BookingByStep/utils/timeslots.d.ts +1 -3
- package/dist/solution/BookingByStep/utils/timeslots.js +12 -19
- package/dist/solution/Checkout/index.js +2 -0
- package/dist/solution/ShopDiscount/index.d.ts +2 -3
- package/dist/solution/ShopDiscount/index.js +60 -62
- package/dist/solution/ShopDiscount/types.d.ts +1 -1
- package/dist/solution/ShopDiscount/types.js +2 -1
- package/dist/solution/ShopDiscount/utils.js +26 -12
- package/dist/solution/index.d.ts +0 -2
- package/dist/solution/index.js +1 -3
- package/lib/index.d.ts +1 -1
- package/lib/index.js +3 -4
- package/lib/model/strategy/adapter/index.d.ts +0 -4
- package/lib/model/strategy/adapter/index.js +2 -13
- package/lib/model/strategy/adapter/promotion/evaluator.js +57 -8
- package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +2 -0
- package/lib/model/strategy/adapter/walletPass/evaluator.js +34 -3
- package/lib/model/strategy/adapter/walletPass/locales.js +12 -3
- package/lib/model/strategy/engine.d.ts +18 -5
- package/lib/model/strategy/engine.js +85 -21
- package/lib/model/strategy/type.d.ts +17 -0
- package/lib/modules/Cart/types.d.ts +2 -0
- package/lib/modules/Cart/utils/cartProduct.js +39 -12
- package/lib/modules/Cart/utils/changePrice.js +9 -13
- package/lib/modules/Discount/index.d.ts +4 -13
- package/lib/modules/Discount/index.js +5 -76
- package/lib/modules/Discount/types.d.ts +18 -13
- package/lib/modules/Order/index.d.ts +1 -67
- package/lib/modules/Order/index.js +1 -525
- package/lib/modules/Order/types.d.ts +12 -176
- package/lib/modules/Order/utils.d.ts +0 -118
- package/lib/modules/Order/utils.js +2 -483
- package/lib/modules/Payment/index.d.ts +2 -1
- package/lib/modules/Payment/index.js +1 -0
- package/lib/modules/Payment/utils.js +3 -0
- package/lib/modules/Payment/walletpass.d.ts +23 -0
- package/lib/modules/Payment/walletpass.js +94 -17
- package/lib/modules/Product/utils.js +2 -2
- package/lib/modules/ProductList/index.d.ts +2 -4
- package/lib/modules/ProductList/index.js +39 -46
- package/lib/modules/Rules/index.d.ts +9 -5
- package/lib/modules/Rules/index.js +776 -292
- package/lib/modules/Rules/types.d.ts +2 -0
- package/lib/modules/Schedule/getDateIsInSchedule.js +11 -13
- package/lib/modules/Schedule/utils.d.ts +1 -1
- package/lib/modules/Summary/types.d.ts +2 -0
- package/lib/modules/Summary/utils.d.ts +9 -3
- package/lib/modules/Summary/utils.js +34 -45
- package/lib/modules/index.d.ts +0 -4
- package/lib/modules/index.js +1 -9
- package/lib/plugins/window.d.ts +2 -0
- package/lib/solution/BookingByStep/index.d.ts +3 -2
- package/lib/solution/BookingByStep/index.js +4 -6
- package/lib/solution/BookingByStep/types.d.ts +1 -3
- package/lib/solution/BookingByStep/types.js +0 -10
- package/lib/solution/BookingByStep/utils/timeslots.d.ts +1 -3
- package/lib/solution/BookingByStep/utils/timeslots.js +11 -19
- package/lib/solution/Checkout/index.js +2 -0
- package/lib/solution/ShopDiscount/index.d.ts +2 -3
- package/lib/solution/ShopDiscount/index.js +27 -22
- package/lib/solution/ShopDiscount/types.d.ts +1 -1
- package/lib/solution/ShopDiscount/utils.js +10 -6
- package/lib/solution/index.d.ts +0 -2
- package/lib/solution/index.js +1 -5
- package/package.json +2 -2
- package/dist/apis/picoding.d.ts +0 -0
- package/dist/apis/picoding.js +0 -1
- package/dist/model/strategy/adapter/dataVariant/adapter.d.ts +0 -50
- package/dist/model/strategy/adapter/dataVariant/adapter.js +0 -167
- package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +0 -89
- package/dist/model/strategy/adapter/dataVariant/evaluator.js +0 -867
- package/dist/model/strategy/adapter/dataVariant/examples.d.ts +0 -39
- package/dist/model/strategy/adapter/dataVariant/examples.js +0 -277
- package/dist/model/strategy/adapter/dataVariant/index.d.ts +0 -4
- package/dist/model/strategy/adapter/dataVariant/index.js +0 -4
- package/dist/model/strategy/adapter/dataVariant/type.d.ts +0 -149
- package/dist/model/strategy/adapter/dataVariant/type.js +0 -54
- package/dist/modules/OpenData/index.d.ts +0 -24
- package/dist/modules/OpenData/index.js +0 -173
- package/dist/modules/OpenData/types.d.ts +0 -73
- package/dist/modules/OpenData/types.js +0 -1
- package/dist/modules/OpenData/utils.d.ts +0 -2
- package/dist/modules/OpenData/utils.js +0 -75
- package/dist/modules/Quotation/index.d.ts +0 -48
- package/dist/modules/Quotation/index.js +0 -248
- package/dist/modules/Quotation/types.d.ts +0 -42
- package/dist/modules/Quotation/types.js +0 -1
- package/dist/modules/SalesSummary/index.d.ts +0 -63
- package/dist/modules/SalesSummary/index.js +0 -174
- package/dist/modules/SalesSummary/types.d.ts +0 -60
- package/dist/modules/SalesSummary/types.js +0 -1
- package/dist/modules/SalesSummary/utils.d.ts +0 -30
- package/dist/modules/SalesSummary/utils.js +0 -480
- package/dist/modules/ScanOrderLogger/index.d.ts +0 -23
- package/dist/modules/ScanOrderLogger/index.js +0 -174
- package/dist/modules/ScanOrderLogger/providers/feishu.d.ts +0 -2
- package/dist/modules/ScanOrderLogger/providers/feishu.js +0 -221
- package/dist/modules/ScanOrderLogger/providers/grafana.d.ts +0 -2
- package/dist/modules/ScanOrderLogger/providers/grafana.js +0 -50
- package/dist/modules/ScanOrderLogger/types.d.ts +0 -53
- package/dist/modules/ScanOrderLogger/types.js +0 -1
- package/dist/solution/ScanOrder/index.d.ts +0 -158
- package/dist/solution/ScanOrder/index.js +0 -3474
- package/dist/solution/ScanOrder/types.d.ts +0 -306
- package/dist/solution/ScanOrder/types.js +0 -35
- package/dist/solution/ScanOrder/utils.d.ts +0 -172
- package/dist/solution/ScanOrder/utils.js +0 -796
- package/dist/solution/VenueBooking/index.d.ts +0 -252
- package/dist/solution/VenueBooking/index.js +0 -3769
- package/dist/solution/VenueBooking/sales-section-4-annotated.json +0 -343
- package/dist/solution/VenueBooking/types.d.ts +0 -156
- package/dist/solution/VenueBooking/types.js +0 -22
- package/dist/solution/VenueBooking/utils/dateSummary.d.ts +0 -11
- package/dist/solution/VenueBooking/utils/dateSummary.js +0 -91
- package/dist/solution/VenueBooking/utils/resource.d.ts +0 -14
- package/dist/solution/VenueBooking/utils/resource.js +0 -131
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +0 -32
- package/dist/solution/VenueBooking/utils/slotMerge.js +0 -233
- package/dist/solution/VenueBooking/utils/smartPricing.d.ts +0 -71
- package/dist/solution/VenueBooking/utils/smartPricing.js +0 -302
- package/dist/solution/VenueBooking/utils/timeSlot.d.ts +0 -34
- package/dist/solution/VenueBooking/utils/timeSlot.js +0 -458
- package/dist/solution/VenueBooking/utils.d.ts +0 -1
- package/dist/solution/VenueBooking/utils.js +0 -1
- package/lib/apis/picoding.d.ts +0 -0
- package/lib/apis/picoding.js +0 -0
- package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +0 -50
- package/lib/model/strategy/adapter/dataVariant/adapter.js +0 -149
- package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +0 -89
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +0 -666
- package/lib/model/strategy/adapter/dataVariant/examples.d.ts +0 -39
- package/lib/model/strategy/adapter/dataVariant/examples.js +0 -293
- package/lib/model/strategy/adapter/dataVariant/index.d.ts +0 -4
- package/lib/model/strategy/adapter/dataVariant/index.js +0 -38
- package/lib/model/strategy/adapter/dataVariant/type.d.ts +0 -149
- package/lib/model/strategy/adapter/dataVariant/type.js +0 -31
- package/lib/modules/OpenData/index.d.ts +0 -24
- package/lib/modules/OpenData/index.js +0 -119
- package/lib/modules/OpenData/types.d.ts +0 -73
- package/lib/modules/OpenData/types.js +0 -17
- package/lib/modules/OpenData/utils.d.ts +0 -2
- package/lib/modules/OpenData/utils.js +0 -111
- package/lib/modules/Quotation/index.d.ts +0 -48
- package/lib/modules/Quotation/index.js +0 -152
- package/lib/modules/Quotation/types.d.ts +0 -42
- package/lib/modules/Quotation/types.js +0 -17
- package/lib/modules/SalesSummary/index.d.ts +0 -63
- package/lib/modules/SalesSummary/index.js +0 -105
- package/lib/modules/SalesSummary/types.d.ts +0 -60
- package/lib/modules/SalesSummary/types.js +0 -17
- package/lib/modules/SalesSummary/utils.d.ts +0 -30
- package/lib/modules/SalesSummary/utils.js +0 -420
- package/lib/modules/ScanOrderLogger/index.d.ts +0 -23
- package/lib/modules/ScanOrderLogger/index.js +0 -147
- package/lib/modules/ScanOrderLogger/providers/feishu.d.ts +0 -2
- package/lib/modules/ScanOrderLogger/providers/feishu.js +0 -157
- package/lib/modules/ScanOrderLogger/providers/grafana.d.ts +0 -2
- package/lib/modules/ScanOrderLogger/providers/grafana.js +0 -52
- package/lib/modules/ScanOrderLogger/types.d.ts +0 -53
- package/lib/modules/ScanOrderLogger/types.js +0 -17
- package/lib/solution/ScanOrder/index.d.ts +0 -158
- package/lib/solution/ScanOrder/index.js +0 -2135
- package/lib/solution/ScanOrder/types.d.ts +0 -306
- package/lib/solution/ScanOrder/types.js +0 -36
- package/lib/solution/ScanOrder/utils.d.ts +0 -172
- package/lib/solution/ScanOrder/utils.js +0 -658
- package/lib/solution/VenueBooking/index.d.ts +0 -252
- package/lib/solution/VenueBooking/index.js +0 -2204
- package/lib/solution/VenueBooking/sales-section-4-annotated.json +0 -343
- package/lib/solution/VenueBooking/types.d.ts +0 -156
- package/lib/solution/VenueBooking/types.js +0 -45
- package/lib/solution/VenueBooking/utils/dateSummary.d.ts +0 -11
- package/lib/solution/VenueBooking/utils/dateSummary.js +0 -105
- package/lib/solution/VenueBooking/utils/resource.d.ts +0 -14
- package/lib/solution/VenueBooking/utils/resource.js +0 -92
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +0 -32
- package/lib/solution/VenueBooking/utils/slotMerge.js +0 -236
- package/lib/solution/VenueBooking/utils/smartPricing.d.ts +0 -71
- package/lib/solution/VenueBooking/utils/smartPricing.js +0 -225
- package/lib/solution/VenueBooking/utils/timeSlot.d.ts +0 -34
- package/lib/solution/VenueBooking/utils/timeSlot.js +0 -343
- package/lib/solution/VenueBooking/utils.d.ts +0 -1
- package/lib/solution/VenueBooking/utils.js +0 -69
|
@@ -57,7 +57,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
57
57
|
currentBookingTime: "",
|
|
58
58
|
filteredDiscountList: [],
|
|
59
59
|
bookingSubject: undefined,
|
|
60
|
-
|
|
60
|
+
orderTotalAmount: 0
|
|
61
61
|
};
|
|
62
62
|
return _this;
|
|
63
63
|
}
|
|
@@ -289,7 +289,14 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
289
289
|
return _setCustomer.apply(this, arguments);
|
|
290
290
|
}
|
|
291
291
|
return setCustomer;
|
|
292
|
-
}()
|
|
292
|
+
}()
|
|
293
|
+
}, {
|
|
294
|
+
key: "setOriginTotalAmount",
|
|
295
|
+
value: function setOriginTotalAmount(amount) {
|
|
296
|
+
this.store.orderTotalAmount = amount;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
// 设置holders
|
|
293
300
|
}, {
|
|
294
301
|
key: "setHolders",
|
|
295
302
|
value: function setHolders(holders) {
|
|
@@ -300,11 +307,6 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
300
307
|
value: function setBookingSubject(bookingSubject) {
|
|
301
308
|
this.store.bookingSubject = bookingSubject;
|
|
302
309
|
}
|
|
303
|
-
}, {
|
|
304
|
-
key: "setOrderId",
|
|
305
|
-
value: function setOrderId(id) {
|
|
306
|
-
this.store.orderId = id;
|
|
307
|
-
}
|
|
308
310
|
|
|
309
311
|
// 计算优惠券
|
|
310
312
|
}, {
|
|
@@ -322,6 +324,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
322
324
|
var _ref = rulesModule.calcDiscount({
|
|
323
325
|
productList: productList,
|
|
324
326
|
discountList: this.getDiscountList(),
|
|
327
|
+
orderTotalAmount: this.store.orderTotalAmount || 0,
|
|
325
328
|
holders: this.store.holders || [],
|
|
326
329
|
isFormSubject: ((_this$store$bookingSu = this.store.bookingSubject) === null || _this$store$bookingSu === void 0 ? void 0 : _this$store$bookingSu.type) === 'form'
|
|
327
330
|
}, options) || {
|
|
@@ -434,32 +437,25 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
434
437
|
key: "scanCode",
|
|
435
438
|
value: function () {
|
|
436
439
|
var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(code, customerId) {
|
|
437
|
-
var _this$store$discount4, _this$store$bookingSu2,
|
|
440
|
+
var _this$store$discount4, _this$store$bookingSu2, resultDiscountList, rulesModule, withScanList, currentSelectedDiscountList, _ref2, newProductList, newDiscountList, isAvailable, unavailableReason, _this$options$otherPa6;
|
|
438
441
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
439
442
|
while (1) switch (_context6.prev = _context6.next) {
|
|
440
443
|
case 0:
|
|
441
444
|
_context6.prev = 0;
|
|
442
445
|
_context6.next = 3;
|
|
443
|
-
return (_this$store$discount4 = this.store.discount) === null || _this$store$discount4 === void 0 ? void 0 : _this$store$discount4.batchSearch(code,
|
|
444
|
-
customerId: customerId,
|
|
445
|
-
orderId: this.store.orderId
|
|
446
|
-
});
|
|
446
|
+
return (_this$store$discount4 = this.store.discount) === null || _this$store$discount4 === void 0 ? void 0 : _this$store$discount4.batchSearch(code, customerId);
|
|
447
447
|
case 3:
|
|
448
448
|
_context6.t0 = _context6.sent;
|
|
449
449
|
if (_context6.t0) {
|
|
450
450
|
_context6.next = 6;
|
|
451
451
|
break;
|
|
452
452
|
}
|
|
453
|
-
_context6.t0 =
|
|
454
|
-
discountList: [],
|
|
455
|
-
unavailableReasonKey: null
|
|
456
|
-
};
|
|
453
|
+
_context6.t0 = [];
|
|
457
454
|
case 6:
|
|
458
|
-
|
|
459
|
-
resultDiscountList = resultDiscountWithReason.discountList, unavailableReasonKey = resultDiscountWithReason.unavailableReasonKey;
|
|
455
|
+
resultDiscountList = _context6.t0;
|
|
460
456
|
rulesModule = this.store.rules;
|
|
461
457
|
if (rulesModule) {
|
|
462
|
-
_context6.next =
|
|
458
|
+
_context6.next = 10;
|
|
463
459
|
break;
|
|
464
460
|
}
|
|
465
461
|
return _context6.abrupt("return", {
|
|
@@ -469,19 +465,18 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
469
465
|
discountList: this.getDiscountList(),
|
|
470
466
|
unavailableReason: UnavailableReason.Unknown
|
|
471
467
|
});
|
|
472
|
-
case
|
|
468
|
+
case 10:
|
|
473
469
|
if (resultDiscountList.length) {
|
|
474
|
-
_context6.next =
|
|
470
|
+
_context6.next = 12;
|
|
475
471
|
break;
|
|
476
472
|
}
|
|
477
473
|
return _context6.abrupt("return", {
|
|
478
474
|
type: "server",
|
|
479
475
|
isAvailable: false,
|
|
480
476
|
productList: this.store.productList || [],
|
|
481
|
-
discountList: this.getDiscountList()
|
|
482
|
-
unavailableReasonKey: unavailableReasonKey
|
|
477
|
+
discountList: this.getDiscountList()
|
|
483
478
|
});
|
|
484
|
-
case
|
|
479
|
+
case 12:
|
|
485
480
|
withScanList = resultDiscountList.map(function (item) {
|
|
486
481
|
return _objectSpread(_objectSpread({}, item), {}, {
|
|
487
482
|
isScan: true
|
|
@@ -495,7 +490,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
495
490
|
return m.id === n.id;
|
|
496
491
|
});
|
|
497
492
|
}))) {
|
|
498
|
-
_context6.next =
|
|
493
|
+
_context6.next = 16;
|
|
499
494
|
break;
|
|
500
495
|
}
|
|
501
496
|
return _context6.abrupt("return", {
|
|
@@ -504,11 +499,12 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
504
499
|
productList: this.store.productList || [],
|
|
505
500
|
discountList: this.getDiscountList()
|
|
506
501
|
});
|
|
507
|
-
case
|
|
502
|
+
case 16:
|
|
508
503
|
_ref2 = rulesModule.isDiscountListAvailable({
|
|
509
504
|
productList: this.store.productList || [],
|
|
510
505
|
oldDiscountList: this.getDiscountList(),
|
|
511
506
|
newDiscountList: withScanList,
|
|
507
|
+
orderTotalAmount: this.store.orderTotalAmount || 0,
|
|
512
508
|
holders: this.store.holders || [],
|
|
513
509
|
isFormSubject: ((_this$store$bookingSu2 = this.store.bookingSubject) === null || _this$store$bookingSu2 === void 0 ? void 0 : _this$store$bookingSu2.type) === 'form'
|
|
514
510
|
}) || {
|
|
@@ -517,19 +513,19 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
517
513
|
discountList: this.getDiscountList()
|
|
518
514
|
}, newProductList = _ref2.productList, newDiscountList = _ref2.discountList, isAvailable = _ref2.isAvailable, unavailableReason = _ref2.unavailableReason;
|
|
519
515
|
if (!isAvailable) {
|
|
520
|
-
_context6.next =
|
|
516
|
+
_context6.next = 24;
|
|
521
517
|
break;
|
|
522
518
|
}
|
|
523
519
|
this.setDiscountList(newDiscountList || []);
|
|
524
520
|
this.store.originalDiscountList = newDiscountList || [];
|
|
525
521
|
this.setProductList(newProductList || []);
|
|
526
522
|
if (!(this.isWalkIn() && resultDiscountList.length && ((_this$options$otherPa6 = this.options.otherParams) === null || _this$options$otherPa6 === void 0 ? void 0 : _this$options$otherPa6.platform) === 'shop')) {
|
|
527
|
-
_context6.next =
|
|
523
|
+
_context6.next = 24;
|
|
528
524
|
break;
|
|
529
525
|
}
|
|
530
|
-
_context6.next =
|
|
526
|
+
_context6.next = 24;
|
|
531
527
|
return this.getCustomerWallet(resultDiscountList[0].customer_id);
|
|
532
|
-
case
|
|
528
|
+
case 24:
|
|
533
529
|
return _context6.abrupt("return", {
|
|
534
530
|
type: "clientCalc",
|
|
535
531
|
isAvailable: isAvailable || false,
|
|
@@ -537,8 +533,8 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
537
533
|
discountList: newDiscountList || this.getDiscountList(),
|
|
538
534
|
unavailableReason: unavailableReason
|
|
539
535
|
});
|
|
540
|
-
case
|
|
541
|
-
_context6.prev =
|
|
536
|
+
case 27:
|
|
537
|
+
_context6.prev = 27;
|
|
542
538
|
_context6.t1 = _context6["catch"](0);
|
|
543
539
|
console.error('[ShopDiscount] 扫码出错:', _context6.t1);
|
|
544
540
|
return _context6.abrupt("return", {
|
|
@@ -548,11 +544,11 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
548
544
|
discountList: this.getDiscountList(),
|
|
549
545
|
unavailableReason: UnavailableReason.Unknown
|
|
550
546
|
});
|
|
551
|
-
case
|
|
547
|
+
case 31:
|
|
552
548
|
case "end":
|
|
553
549
|
return _context6.stop();
|
|
554
550
|
}
|
|
555
|
-
}, _callee6, this, [[0,
|
|
551
|
+
}, _callee6, this, [[0, 27]]);
|
|
556
552
|
}));
|
|
557
553
|
function scanCode(_x5, _x6) {
|
|
558
554
|
return _scanCode.apply(this, arguments);
|
|
@@ -622,21 +618,27 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
622
618
|
return n.id === (((_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.resource_id) || discount.id);
|
|
623
619
|
});
|
|
624
620
|
if (index !== -1) {
|
|
625
|
-
var _discount$metadata;
|
|
621
|
+
var _editModeDiscountList, _discount$metadata, _discount$metadata2;
|
|
626
622
|
editModeDiscountList[index] = _objectSpread(_objectSpread({}, editModeDiscountList[index]), {}, {
|
|
623
|
+
metadata: _objectSpread(_objectSpread({}, discount.metadata || {}), {}, {
|
|
624
|
+
num: ((editModeDiscountList === null || editModeDiscountList === void 0 || (_editModeDiscountList = editModeDiscountList[index]) === null || _editModeDiscountList === void 0 || (_editModeDiscountList = _editModeDiscountList.metadata) === null || _editModeDiscountList === void 0 ? void 0 : _editModeDiscountList.num) || 1) + (((_discount$metadata = discount.metadata) === null || _discount$metadata === void 0 ? void 0 : _discount$metadata.num) || 1)
|
|
625
|
+
}),
|
|
627
626
|
amount: new Decimal(discount.amount || 0).plus(new Decimal(editModeDiscountList[index].amount || 0)).toNumber(),
|
|
628
|
-
savedAmount: new Decimal(discount.amount || 0).times((product === null || product === void 0 ? void 0 : product.quantity) || (product === null || product === void 0 ? void 0 : product.num) || 1).plus((discount === null || discount === void 0 || (_discount$
|
|
627
|
+
savedAmount: new Decimal(discount.amount || 0).times((product === null || product === void 0 ? void 0 : product.quantity) || (product === null || product === void 0 ? void 0 : product.num) || 1).plus((discount === null || discount === void 0 || (_discount$metadata2 = discount.metadata) === null || _discount$metadata2 === void 0 ? void 0 : _discount$metadata2.product_discount_difference) || 0).plus(new Decimal(editModeDiscountList[index].savedAmount || 0)).toNumber()
|
|
629
628
|
});
|
|
630
629
|
} else {
|
|
631
|
-
var _discount$
|
|
630
|
+
var _discount$metadata3, _discount$metadata4, _discount$discount2, _discount$discount3, _discount$discount4;
|
|
632
631
|
if (discount.type && !discount.tag) {
|
|
633
632
|
discount.tag = discount.type;
|
|
634
633
|
}
|
|
635
634
|
editModeDiscountList.push(_objectSpread(_objectSpread({}, discount), {}, {
|
|
635
|
+
metadata: _objectSpread(_objectSpread({}, discount.metadata || {}), {}, {
|
|
636
|
+
num: ((_discount$metadata3 = discount.metadata) === null || _discount$metadata3 === void 0 ? void 0 : _discount$metadata3.num) || 1
|
|
637
|
+
}),
|
|
636
638
|
name: discount.name || discount.discount.title.auto,
|
|
637
639
|
isEditMode: true,
|
|
638
640
|
limited_relation_product_data: {},
|
|
639
|
-
savedAmount: new Decimal(discount.amount || 0).times((product === null || product === void 0 ? void 0 : product.quantity) || (product === null || product === void 0 ? void 0 : product.num) || 1).plus((discount === null || discount === void 0 || (_discount$
|
|
641
|
+
savedAmount: new Decimal(discount.amount || 0).times((product === null || product === void 0 ? void 0 : product.quantity) || (product === null || product === void 0 ? void 0 : product.num) || 1).plus((discount === null || discount === void 0 || (_discount$metadata4 = discount.metadata) === null || _discount$metadata4 === void 0 ? void 0 : _discount$metadata4.product_discount_difference) || 0).toNumber(),
|
|
640
642
|
isAvailable: true,
|
|
641
643
|
id: ((_discount$discount2 = discount.discount) === null || _discount$discount2 === void 0 ? void 0 : _discount$discount2.resource_id) || discount.id,
|
|
642
644
|
format_title: ((_discount$discount3 = discount.discount) === null || _discount$discount3 === void 0 ? void 0 : _discount$discount3.title) || discount.format_title,
|
|
@@ -783,69 +785,65 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
783
785
|
key: "loadPrepareConfig",
|
|
784
786
|
value: function () {
|
|
785
787
|
var _loadPrepareConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(params) {
|
|
786
|
-
var _this$getCustomer2, _this$store$discount8, _this$getDiscountList, _this$store$discount9, _this$store$productLi2,
|
|
788
|
+
var _this$getCustomer2, _this$store$discount8, _this$getDiscountList, _this$store$discount9, _this$store$productLi2, customerId, goodPassList, scanDiscount, scanDiscountIds, newGoodPassList, newDiscountList, filteredDiscountList, _result3;
|
|
787
789
|
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
788
790
|
while (1) switch (_context10.prev = _context10.next) {
|
|
789
791
|
case 0:
|
|
790
792
|
_context10.prev = 0;
|
|
791
|
-
orderId = this.store.orderId;
|
|
792
793
|
customerId = params.customerId || ((_this$getCustomer2 = this.getCustomer()) === null || _this$getCustomer2 === void 0 ? void 0 : _this$getCustomer2.id); // if (customerId === 1 || !customerId) {
|
|
793
794
|
// return
|
|
794
795
|
// }
|
|
795
|
-
_context10.next =
|
|
796
|
-
return (_this$store$discount8 = this.store.discount) === null || _this$store$discount8 === void 0 ? void 0 : _this$store$discount8.loadPrepareConfig(
|
|
796
|
+
_context10.next = 4;
|
|
797
|
+
return (_this$store$discount8 = this.store.discount) === null || _this$store$discount8 === void 0 ? void 0 : _this$store$discount8.loadPrepareConfig({
|
|
797
798
|
customer_id: customerId,
|
|
798
|
-
action:
|
|
799
|
+
action: 'create',
|
|
799
800
|
with_good_pass: 1,
|
|
800
801
|
with_discount_card: 1,
|
|
801
802
|
with_wallet_pass_holder: 1,
|
|
802
803
|
request_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
803
|
-
}
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
case 5:
|
|
807
|
-
prepareConfig = _context10.sent;
|
|
808
|
-
goodPassList = (prepareConfig === null || prepareConfig === void 0 ? void 0 : prepareConfig.discountList) || [];
|
|
804
|
+
});
|
|
805
|
+
case 4:
|
|
806
|
+
goodPassList = _context10.sent;
|
|
809
807
|
scanDiscount = (_this$getDiscountList = this.getDiscountList()) === null || _this$getDiscountList === void 0 ? void 0 : _this$getDiscountList.filter(function (item) {
|
|
810
808
|
return item.isScan;
|
|
811
809
|
}); // goodPassList 里可能有 scanDiscount 重合的部分,goodPassList 需要剔除
|
|
812
810
|
scanDiscountIds = scanDiscount.map(function (n) {
|
|
813
811
|
return n.id;
|
|
814
812
|
});
|
|
815
|
-
newGoodPassList = goodPassList.filter(function (n) {
|
|
813
|
+
newGoodPassList = goodPassList === null || goodPassList === void 0 ? void 0 : goodPassList.filter(function (n) {
|
|
816
814
|
return !scanDiscountIds.includes(n.id);
|
|
817
815
|
});
|
|
818
816
|
newDiscountList = [].concat(_toConsumableArray(scanDiscount), _toConsumableArray(newGoodPassList || [])); // 存储原始优惠券列表
|
|
819
817
|
this.store.originalDiscountList = newDiscountList;
|
|
820
|
-
_context10.next =
|
|
818
|
+
_context10.next = 12;
|
|
821
819
|
return (_this$store$discount9 = this.store.discount) === null || _this$store$discount9 === void 0 ? void 0 : _this$store$discount9.setOriginalDiscountList(newDiscountList);
|
|
822
|
-
case
|
|
820
|
+
case 12:
|
|
823
821
|
// 根据当前预约时间过滤优惠券列表
|
|
824
822
|
filteredDiscountList = this.filterDiscountListByBookingTime(newDiscountList, this.store.currentBookingTime);
|
|
825
823
|
this.store.filteredDiscountList = filteredDiscountList;
|
|
826
824
|
this.setDiscountList(filteredDiscountList || []);
|
|
827
825
|
if (!((_this$store$productLi2 = this.store.productList) !== null && _this$store$productLi2 !== void 0 && _this$store$productLi2.length)) {
|
|
828
|
-
_context10.next =
|
|
826
|
+
_context10.next = 19;
|
|
829
827
|
break;
|
|
830
828
|
}
|
|
831
829
|
_result3 = this.calcDiscount(this.store.productList);
|
|
832
|
-
_context10.next =
|
|
830
|
+
_context10.next = 19;
|
|
833
831
|
return this.core.effects.emit("".concat(this.name, ":onLoadPrepareCalcResult"), _result3);
|
|
832
|
+
case 19:
|
|
833
|
+
_context10.next = 21;
|
|
834
|
+
return this.core.effects.emit("".concat(this.name, ":onLoadDiscountList"), newDiscountList);
|
|
834
835
|
case 21:
|
|
835
|
-
_context10.next =
|
|
836
|
-
return this.core.effects.emit("".concat(this.name, ":onLoadDiscountList"), filteredDiscountList);
|
|
837
|
-
case 23:
|
|
838
|
-
_context10.next = 28;
|
|
836
|
+
_context10.next = 26;
|
|
839
837
|
break;
|
|
840
|
-
case
|
|
841
|
-
_context10.prev =
|
|
838
|
+
case 23:
|
|
839
|
+
_context10.prev = 23;
|
|
842
840
|
_context10.t0 = _context10["catch"](0);
|
|
843
841
|
console.error('[ShopDiscount] 加载准备配置出错:', _context10.t0);
|
|
844
|
-
case
|
|
842
|
+
case 26:
|
|
845
843
|
case "end":
|
|
846
844
|
return _context10.stop();
|
|
847
845
|
}
|
|
848
|
-
}, _callee10, this, [[0,
|
|
846
|
+
}, _callee10, this, [[0, 23]]);
|
|
849
847
|
}));
|
|
850
848
|
function loadPrepareConfig(_x10) {
|
|
851
849
|
return _loadPrepareConfig.apply(this, arguments);
|
|
@@ -23,6 +23,7 @@ export interface ShopDiscountState {
|
|
|
23
23
|
discount: DiscountModule | null;
|
|
24
24
|
rules: RulesModule | null;
|
|
25
25
|
productList: Record<string, any>[];
|
|
26
|
+
orderTotalAmount?: number;
|
|
26
27
|
holders?: {
|
|
27
28
|
form_record_id: number;
|
|
28
29
|
form_id?: number;
|
|
@@ -35,7 +36,6 @@ export interface ShopDiscountState {
|
|
|
35
36
|
type?: 'form' | 'customer';
|
|
36
37
|
[key: string]: any;
|
|
37
38
|
};
|
|
38
|
-
orderId?: number;
|
|
39
39
|
}
|
|
40
40
|
export interface SetDiscountSelectedParams {
|
|
41
41
|
discountId: number;
|
|
@@ -8,4 +8,5 @@ export var ShopDiscountHooks = /*#__PURE__*/function (ShopDiscountHooks) {
|
|
|
8
8
|
ShopDiscountHooks["onRulesListChange"] = "shopDiscount:onRulesListChange";
|
|
9
9
|
ShopDiscountHooks["onLoadPrepareCalcResult"] = "shopDiscount:onLoadPrepareCalcResult";
|
|
10
10
|
return ShopDiscountHooks;
|
|
11
|
-
}({});
|
|
11
|
+
}({});
|
|
12
|
+
;
|
|
@@ -40,23 +40,37 @@ export var isAllNormalProduct = function isAllNormalProduct(items) {
|
|
|
40
40
|
* @returns
|
|
41
41
|
*/
|
|
42
42
|
export var getDiscountAmount = function getDiscountAmount(discount, total, price) {
|
|
43
|
-
var
|
|
43
|
+
var discountedPrice = 0;
|
|
44
|
+
|
|
44
45
|
// 商品券
|
|
45
46
|
if (discount.tag === 'good_pass') {
|
|
46
|
-
|
|
47
|
+
discountedPrice = new Decimal(price).minus(new Decimal(price || 0)).toNumber();
|
|
48
|
+
} else {
|
|
49
|
+
var _discount$metadata;
|
|
50
|
+
// 判断是否是固定金额
|
|
51
|
+
var isFixedAmount = (discount === null || discount === void 0 || (_discount$metadata = discount.metadata) === null || _discount$metadata === void 0 ? void 0 : _discount$metadata.discount_card_type) === 'fixed_amount';
|
|
52
|
+
|
|
53
|
+
// 固定金额 小于0时返回0
|
|
54
|
+
if (isFixedAmount) {
|
|
55
|
+
discountedPrice = Math.max(new Decimal(price).minus(new Decimal(discount.par_value || 0)).toNumber(), 0);
|
|
56
|
+
} else {
|
|
57
|
+
// 百分比:根据折扣卡金额计算
|
|
58
|
+
discountedPrice = new Decimal(100).minus(discount.par_value || 0).div(100).mul(new Decimal(price)).toNumber();
|
|
59
|
+
}
|
|
47
60
|
}
|
|
48
61
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
62
|
+
/*
|
|
63
|
+
// 🔥 如果有 maxDeductionAmount 限制,确保折扣金额不超过限制
|
|
64
|
+
if (discount.config?.maxDeductionAmount) {
|
|
65
|
+
const actualDiscountAmount = new Decimal(price).minus(discountedPrice).toNumber();
|
|
66
|
+
if (actualDiscountAmount > discount.config.maxDeductionAmount) {
|
|
67
|
+
// 折扣金额超过限制,重新计算折扣后价格
|
|
68
|
+
discountedPrice = new Decimal(price).minus(discount.config.maxDeductionAmount).toNumber();
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
*/
|
|
57
72
|
|
|
58
|
-
|
|
59
|
-
return new Decimal(100).minus(discount.par_value || 0).div(100).mul(new Decimal(price)).toNumber();
|
|
73
|
+
return discountedPrice;
|
|
60
74
|
};
|
|
61
75
|
export var getDiscountListAmountTotal = function getDiscountListAmountTotal(discount) {
|
|
62
76
|
return discount.reduce(function (acc, cur) {
|
package/dist/solution/index.d.ts
CHANGED
package/dist/solution/index.js
CHANGED
package/lib/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export * from './types';
|
|
|
6
6
|
export * from './modules';
|
|
7
7
|
export * from './plugins';
|
|
8
8
|
export * from './solution';
|
|
9
|
+
export * from './model';
|
|
9
10
|
export { PisellOSCore } from './core';
|
|
10
|
-
export { DataVariantEvaluator } from './model/strategy/adapter/dataVariant/evaluator';
|
|
11
11
|
import PisellOSCore from './core';
|
|
12
12
|
export default PisellOSCore;
|
package/lib/index.js
CHANGED
|
@@ -30,7 +30,6 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var src_exports = {};
|
|
32
32
|
__export(src_exports, {
|
|
33
|
-
DataVariantEvaluator: () => import_evaluator.DataVariantEvaluator,
|
|
34
33
|
PisellOSCore: () => import_core.PisellOSCore,
|
|
35
34
|
default: () => src_default
|
|
36
35
|
});
|
|
@@ -39,16 +38,16 @@ __reExport(src_exports, require("./types"), module.exports);
|
|
|
39
38
|
__reExport(src_exports, require("./modules"), module.exports);
|
|
40
39
|
__reExport(src_exports, require("./plugins"), module.exports);
|
|
41
40
|
__reExport(src_exports, require("./solution"), module.exports);
|
|
41
|
+
__reExport(src_exports, require("./model"), module.exports);
|
|
42
42
|
var import_core = require("./core");
|
|
43
|
-
var import_evaluator = require("./model/strategy/adapter/dataVariant/evaluator");
|
|
44
43
|
var import_core2 = __toESM(require("./core"));
|
|
45
44
|
var src_default = import_core2.default;
|
|
46
45
|
// Annotate the CommonJS export names for ESM import in node:
|
|
47
46
|
0 && (module.exports = {
|
|
48
|
-
DataVariantEvaluator,
|
|
49
47
|
PisellOSCore,
|
|
50
48
|
...require("./types"),
|
|
51
49
|
...require("./modules"),
|
|
52
50
|
...require("./plugins"),
|
|
53
|
-
...require("./solution")
|
|
51
|
+
...require("./solution"),
|
|
52
|
+
...require("./model")
|
|
54
53
|
});
|
|
@@ -5,7 +5,3 @@ export { PromotionEvaluator } from './promotion/evaluator';
|
|
|
5
5
|
export { PromotionAdapter } from './promotion/adapter';
|
|
6
6
|
export { ItemRuleEvaluator } from './itemRule/evaluator';
|
|
7
7
|
export { ItemRuleAdapter } from './itemRule/adapter';
|
|
8
|
-
export { DataVariantEvaluator } from './dataVariant/evaluator';
|
|
9
|
-
export { DataVariantAdapter } from './dataVariant/adapter';
|
|
10
|
-
export { runDataVariantDemo } from './dataVariant/examples';
|
|
11
|
-
export * from './dataVariant/type';
|
|
@@ -30,15 +30,12 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/model/strategy/adapter/index.ts
|
|
31
31
|
var adapter_exports = {};
|
|
32
32
|
__export(adapter_exports, {
|
|
33
|
-
DataVariantAdapter: () => import_adapter3.DataVariantAdapter,
|
|
34
|
-
DataVariantEvaluator: () => import_evaluator4.DataVariantEvaluator,
|
|
35
33
|
ItemRuleAdapter: () => import_adapter2.ItemRuleAdapter,
|
|
36
34
|
ItemRuleEvaluator: () => import_evaluator3.ItemRuleEvaluator,
|
|
37
35
|
PromotionAdapter: () => import_adapter.PromotionAdapter,
|
|
38
36
|
PromotionEvaluator: () => import_evaluator2.PromotionEvaluator,
|
|
39
37
|
WalletPassAdapter: () => import_walletPass.default,
|
|
40
|
-
WalletPassEvaluator: () => import_evaluator.WalletPassEvaluator
|
|
41
|
-
runDataVariantDemo: () => import_examples.runDataVariantDemo
|
|
38
|
+
WalletPassEvaluator: () => import_evaluator.WalletPassEvaluator
|
|
42
39
|
});
|
|
43
40
|
module.exports = __toCommonJS(adapter_exports);
|
|
44
41
|
__reExport(adapter_exports, require("./type"), module.exports);
|
|
@@ -48,21 +45,13 @@ var import_evaluator2 = require("./promotion/evaluator");
|
|
|
48
45
|
var import_adapter = require("./promotion/adapter");
|
|
49
46
|
var import_evaluator3 = require("./itemRule/evaluator");
|
|
50
47
|
var import_adapter2 = require("./itemRule/adapter");
|
|
51
|
-
var import_evaluator4 = require("./dataVariant/evaluator");
|
|
52
|
-
var import_adapter3 = require("./dataVariant/adapter");
|
|
53
|
-
var import_examples = require("./dataVariant/examples");
|
|
54
|
-
__reExport(adapter_exports, require("./dataVariant/type"), module.exports);
|
|
55
48
|
// Annotate the CommonJS export names for ESM import in node:
|
|
56
49
|
0 && (module.exports = {
|
|
57
|
-
DataVariantAdapter,
|
|
58
|
-
DataVariantEvaluator,
|
|
59
50
|
ItemRuleAdapter,
|
|
60
51
|
ItemRuleEvaluator,
|
|
61
52
|
PromotionAdapter,
|
|
62
53
|
PromotionEvaluator,
|
|
63
54
|
WalletPassAdapter,
|
|
64
55
|
WalletPassEvaluator,
|
|
65
|
-
|
|
66
|
-
...require("./type"),
|
|
67
|
-
...require("./dataVariant/type")
|
|
56
|
+
...require("./type")
|
|
68
57
|
});
|
|
@@ -512,14 +512,21 @@ var PromotionEvaluator = class {
|
|
|
512
512
|
unitProducts.push({
|
|
513
513
|
product,
|
|
514
514
|
price: product.price,
|
|
515
|
-
productId: product.id
|
|
515
|
+
productId: product.id,
|
|
516
|
+
sourceAvailableQty: availableQty
|
|
516
517
|
});
|
|
517
518
|
}
|
|
518
519
|
}
|
|
519
520
|
if (unitProducts.length === 0) {
|
|
520
521
|
return { products: [], originalAmount: 0, finalAmount: 0 };
|
|
521
522
|
}
|
|
522
|
-
unitProducts.sort((a, b) =>
|
|
523
|
+
unitProducts.sort((a, b) => {
|
|
524
|
+
const aIsMultiple = a.sourceAvailableQty > 0 && a.sourceAvailableQty % x === 0 ? 1 : 0;
|
|
525
|
+
const bIsMultiple = b.sourceAvailableQty > 0 && b.sourceAvailableQty % x === 0 ? 1 : 0;
|
|
526
|
+
if (aIsMultiple !== bIsMultiple)
|
|
527
|
+
return bIsMultiple - aIsMultiple;
|
|
528
|
+
return b.price - a.price;
|
|
529
|
+
});
|
|
523
530
|
const totalUnits = unitProducts.length;
|
|
524
531
|
const groupCount = cumulative ? Math.floor(totalUnits / x) : totalUnits >= x ? 1 : 0;
|
|
525
532
|
const promotionUnits = groupCount * x;
|
|
@@ -573,7 +580,9 @@ var PromotionEvaluator = class {
|
|
|
573
580
|
(sum, p) => sum.plus(p),
|
|
574
581
|
new import_decimal.default(0)
|
|
575
582
|
);
|
|
576
|
-
const
|
|
583
|
+
const productOriginalAmount = new import_decimal.default(product.price).mul(promoQty);
|
|
584
|
+
const actualTotal = import_decimal.default.min(totalAllocated, productOriginalAmount);
|
|
585
|
+
const finalPricePerUnit = this.formatPrice(actualTotal.div(promoQty));
|
|
577
586
|
result.push({
|
|
578
587
|
...product,
|
|
579
588
|
quantity: promoQty,
|
|
@@ -584,9 +593,8 @@ var PromotionEvaluator = class {
|
|
|
584
593
|
isSplit: false,
|
|
585
594
|
matchedBundleIndex
|
|
586
595
|
});
|
|
587
|
-
const productOriginalAmount = new import_decimal.default(product.price).mul(promoQty);
|
|
588
596
|
originalAmount = originalAmount.plus(productOriginalAmount);
|
|
589
|
-
finalAmount = finalAmount.plus(
|
|
597
|
+
finalAmount = finalAmount.plus(actualTotal);
|
|
590
598
|
} else if (promoQty === 0 && remainingQty > 0) {
|
|
591
599
|
result.push({
|
|
592
600
|
...product,
|
|
@@ -605,7 +613,9 @@ var PromotionEvaluator = class {
|
|
|
605
613
|
(sum, p) => sum.plus(p),
|
|
606
614
|
new import_decimal.default(0)
|
|
607
615
|
);
|
|
608
|
-
const
|
|
616
|
+
const promoOriginalAmount = new import_decimal.default(product.price).mul(promoQty);
|
|
617
|
+
const actualTotal = import_decimal.default.min(totalAllocated, promoOriginalAmount);
|
|
618
|
+
const finalPricePerUnit = this.formatPrice(actualTotal.div(promoQty));
|
|
609
619
|
result.push({
|
|
610
620
|
...product,
|
|
611
621
|
id: this.generateRandomId(),
|
|
@@ -618,9 +628,8 @@ var PromotionEvaluator = class {
|
|
|
618
628
|
matchedBundleIndex,
|
|
619
629
|
isSplit: true
|
|
620
630
|
});
|
|
621
|
-
const promoOriginalAmount = new import_decimal.default(product.price).mul(promoQty);
|
|
622
631
|
originalAmount = originalAmount.plus(promoOriginalAmount);
|
|
623
|
-
finalAmount = finalAmount.plus(
|
|
632
|
+
finalAmount = finalAmount.plus(actualTotal);
|
|
624
633
|
result.push({
|
|
625
634
|
...product,
|
|
626
635
|
quantity: remainingQty,
|
|
@@ -636,6 +645,46 @@ var PromotionEvaluator = class {
|
|
|
636
645
|
}
|
|
637
646
|
processedQuantityMap.set(key, processedQty + availableQty);
|
|
638
647
|
}
|
|
648
|
+
if (groupCount > 0) {
|
|
649
|
+
const expectedPromoTotal = new import_decimal.default(groupPrice).mul(groupCount);
|
|
650
|
+
const promoItems = result.filter((p) => p.inPromotion);
|
|
651
|
+
let actualPromoTotal = new import_decimal.default(0);
|
|
652
|
+
for (const p of promoItems) {
|
|
653
|
+
actualPromoTotal = actualPromoTotal.plus(
|
|
654
|
+
new import_decimal.default(p.finalPrice).mul(p.quantity)
|
|
655
|
+
);
|
|
656
|
+
}
|
|
657
|
+
const roundingDiff = actualPromoTotal.minus(expectedPromoTotal);
|
|
658
|
+
if (!roundingDiff.eq(0)) {
|
|
659
|
+
const adjustTarget = promoItems.find((p) => p.quantity === 1);
|
|
660
|
+
if (adjustTarget) {
|
|
661
|
+
adjustTarget.finalPrice = this.formatPrice(
|
|
662
|
+
new import_decimal.default(adjustTarget.finalPrice).minus(roundingDiff)
|
|
663
|
+
);
|
|
664
|
+
} else if (promoItems.length > 0) {
|
|
665
|
+
const lastPromo = promoItems[promoItems.length - 1];
|
|
666
|
+
const adjustedUnitPrice = this.formatPrice(
|
|
667
|
+
new import_decimal.default(lastPromo.finalPrice).minus(roundingDiff)
|
|
668
|
+
);
|
|
669
|
+
lastPromo.quantity -= 1;
|
|
670
|
+
lastPromo.isSplit = true;
|
|
671
|
+
result.push({
|
|
672
|
+
...lastPromo,
|
|
673
|
+
id: this.generateRandomId(),
|
|
674
|
+
originalId: lastPromo.originalId || lastPromo.id,
|
|
675
|
+
quantity: 1,
|
|
676
|
+
finalPrice: adjustedUnitPrice,
|
|
677
|
+
isSplit: true
|
|
678
|
+
});
|
|
679
|
+
}
|
|
680
|
+
finalAmount = new import_decimal.default(0);
|
|
681
|
+
for (const p of result) {
|
|
682
|
+
finalAmount = finalAmount.plus(
|
|
683
|
+
new import_decimal.default(p.finalPrice).mul(p.quantity)
|
|
684
|
+
);
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
}
|
|
639
688
|
return {
|
|
640
689
|
products: result,
|
|
641
690
|
originalAmount: originalAmount.toNumber(),
|
|
@@ -8,10 +8,12 @@ export declare class WalletPassEvaluator {
|
|
|
8
8
|
private engine;
|
|
9
9
|
private strategyConfigs;
|
|
10
10
|
private locale;
|
|
11
|
+
private otherParams;
|
|
11
12
|
constructor();
|
|
12
13
|
setStrategyConfigs(strategyConfigs: StrategyConfig[]): void;
|
|
13
14
|
getStrategyConfigs(): StrategyConfig[];
|
|
14
15
|
setLocale(locale: string): void;
|
|
16
|
+
setOtherParams(otherParams: any): void;
|
|
15
17
|
getText(key: string): string;
|
|
16
18
|
/**
|
|
17
19
|
* 搜索券的格式
|