@pisell/pisellos 2.1.85 → 2.1.87
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 +0 -1
- package/dist/index.js +0 -1
- package/dist/modules/Cart/types.d.ts +0 -2
- package/dist/modules/Cart/utils/cartProduct.js +0 -11
- package/dist/modules/Cart/utils/changePrice.js +6 -0
- package/dist/modules/Discount/index.d.ts +1 -0
- package/dist/modules/Discount/index.js +2 -1
- package/dist/modules/Discount/types.d.ts +0 -15
- package/dist/modules/Payment/index.d.ts +1 -2
- package/dist/modules/Payment/index.js +7 -10
- package/dist/modules/Payment/utils.js +0 -3
- package/dist/modules/Payment/walletpass.d.ts +0 -23
- package/dist/modules/Payment/walletpass.js +95 -191
- package/dist/modules/Rules/index.d.ts +2 -7
- package/dist/modules/Rules/index.js +19 -141
- package/dist/modules/Rules/types.d.ts +0 -1
- package/dist/modules/Schedule/getDateIsInSchedule.d.ts +32 -0
- package/dist/modules/Schedule/getDateIsInSchedule.js +747 -0
- package/dist/modules/Schedule/index.d.ts +1 -1
- package/dist/modules/Schedule/index.js +2 -0
- package/dist/modules/Summary/index.js +47 -5
- package/dist/modules/Summary/types.d.ts +0 -2
- package/dist/modules/Summary/utils.d.ts +1 -7
- package/dist/modules/Summary/utils.js +23 -33
- package/dist/plugins/window.d.ts +0 -2
- package/dist/solution/BookingByStep/index.d.ts +0 -1
- package/dist/solution/BookingByStep/index.js +84 -35
- package/dist/solution/Checkout/index.js +0 -2
- package/dist/solution/ShopDiscount/index.d.ts +0 -1
- package/dist/solution/ShopDiscount/index.js +3 -12
- package/dist/solution/ShopDiscount/types.d.ts +0 -1
- package/lib/index.d.ts +0 -1
- package/lib/index.js +1 -3
- package/lib/modules/Cart/types.d.ts +0 -2
- package/lib/modules/Cart/utils/cartProduct.js +0 -9
- package/lib/modules/Cart/utils/changePrice.js +5 -0
- package/lib/modules/Discount/index.d.ts +1 -0
- package/lib/modules/Discount/index.js +2 -1
- package/lib/modules/Discount/types.d.ts +0 -15
- package/lib/modules/Payment/index.d.ts +1 -2
- package/lib/modules/Payment/index.js +0 -1
- package/lib/modules/Payment/utils.js +0 -3
- package/lib/modules/Payment/walletpass.d.ts +0 -23
- package/lib/modules/Payment/walletpass.js +17 -94
- package/lib/modules/Rules/index.d.ts +2 -7
- package/lib/modules/Rules/index.js +149 -285
- package/lib/modules/Rules/types.d.ts +0 -1
- package/lib/modules/Schedule/getDateIsInSchedule.d.ts +32 -0
- package/lib/modules/Schedule/getDateIsInSchedule.js +451 -0
- package/lib/modules/Schedule/index.d.ts +1 -1
- package/lib/modules/Schedule/index.js +2 -0
- package/lib/modules/Summary/index.js +22 -9
- package/lib/modules/Summary/types.d.ts +0 -2
- package/lib/modules/Summary/utils.d.ts +1 -7
- package/lib/modules/Summary/utils.js +22 -28
- package/lib/plugins/window.d.ts +0 -2
- package/lib/solution/BookingByStep/index.d.ts +0 -1
- package/lib/solution/BookingByStep/index.js +34 -3
- package/lib/solution/Checkout/index.js +0 -2
- package/lib/solution/ShopDiscount/index.d.ts +0 -1
- package/lib/solution/ShopDiscount/index.js +2 -7
- package/lib/solution/ShopDiscount/types.d.ts +0 -1
- package/package.json +1 -1
- package/dist/model/index.d.ts +0 -1
- package/dist/model/index.js +0 -1
- package/dist/model/strategy/adapter/index.d.ts +0 -3
- package/dist/model/strategy/adapter/index.js +0 -4
- package/dist/model/strategy/adapter/type.d.ts +0 -28
- package/dist/model/strategy/adapter/type.js +0 -1
- package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +0 -84
- package/dist/model/strategy/adapter/walletPass/evaluator.js +0 -497
- package/dist/model/strategy/adapter/walletPass/example.d.ts +0 -4
- package/dist/model/strategy/adapter/walletPass/example.js +0 -258
- package/dist/model/strategy/adapter/walletPass/index.d.ts +0 -32
- package/dist/model/strategy/adapter/walletPass/index.js +0 -182
- package/dist/model/strategy/adapter/walletPass/locales.d.ts +0 -1
- package/dist/model/strategy/adapter/walletPass/locales.js +0 -23
- package/dist/model/strategy/adapter/walletPass/type.d.ts +0 -168
- package/dist/model/strategy/adapter/walletPass/type.js +0 -1
- package/dist/model/strategy/adapter/walletPass/utils.d.ts +0 -76
- package/dist/model/strategy/adapter/walletPass/utils.js +0 -1043
- package/dist/model/strategy/index.d.ts +0 -94
- package/dist/model/strategy/index.js +0 -551
- package/dist/model/strategy/strategy-example.d.ts +0 -5
- package/dist/model/strategy/strategy-example.js +0 -331
- package/dist/model/strategy/type.d.ts +0 -228
- package/dist/model/strategy/type.js +0 -94
- package/lib/model/index.d.ts +0 -1
- package/lib/model/index.js +0 -23
- package/lib/model/strategy/adapter/index.d.ts +0 -3
- package/lib/model/strategy/adapter/index.js +0 -45
- package/lib/model/strategy/adapter/type.d.ts +0 -28
- package/lib/model/strategy/adapter/type.js +0 -17
- package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +0 -84
- package/lib/model/strategy/adapter/walletPass/evaluator.js +0 -421
- package/lib/model/strategy/adapter/walletPass/example.d.ts +0 -4
- package/lib/model/strategy/adapter/walletPass/example.js +0 -207
- package/lib/model/strategy/adapter/walletPass/index.d.ts +0 -32
- package/lib/model/strategy/adapter/walletPass/index.js +0 -142
- package/lib/model/strategy/adapter/walletPass/locales.d.ts +0 -1
- package/lib/model/strategy/adapter/walletPass/locales.js +0 -51
- package/lib/model/strategy/adapter/walletPass/type.d.ts +0 -168
- package/lib/model/strategy/adapter/walletPass/type.js +0 -17
- package/lib/model/strategy/adapter/walletPass/utils.d.ts +0 -76
- package/lib/model/strategy/adapter/walletPass/utils.js +0 -704
- package/lib/model/strategy/index.d.ts +0 -94
- package/lib/model/strategy/index.js +0 -413
- package/lib/model/strategy/strategy-example.d.ts +0 -5
- package/lib/model/strategy/strategy-example.js +0 -318
- package/lib/model/strategy/type.d.ts +0 -228
- package/lib/model/strategy/type.js +0 -44
|
@@ -31,7 +31,6 @@ var utils_exports = {};
|
|
|
31
31
|
__export(utils_exports, {
|
|
32
32
|
calcDiscountListDifference: () => calcDiscountListDifference,
|
|
33
33
|
calculateDeposit: () => calculateDeposit,
|
|
34
|
-
calculateOriginSubtotal: () => calculateOriginSubtotal,
|
|
35
34
|
calculatePriceDetails: () => calculatePriceDetails,
|
|
36
35
|
calculateSubtotal: () => calculateSubtotal,
|
|
37
36
|
calculateTaxFee: () => calculateTaxFee,
|
|
@@ -43,11 +42,12 @@ __export(utils_exports, {
|
|
|
43
42
|
});
|
|
44
43
|
module.exports = __toCommonJS(utils_exports);
|
|
45
44
|
var import_decimal = __toESM(require("decimal.js"));
|
|
46
|
-
var
|
|
45
|
+
var import_utils = require("../Product/utils");
|
|
46
|
+
var import_dayjs = __toESM(require("dayjs"));
|
|
47
|
+
var calculatePriceDetails = (shopInfo, items, isInScheduleByDate, surchargeList, scheduleById) => {
|
|
47
48
|
const subtotal = new import_decimal.default(calculateSubtotal(items));
|
|
48
|
-
const subOriginTotal = new import_decimal.default(calculateOriginSubtotal(items));
|
|
49
49
|
const totalTaxFee = new import_decimal.default(calculateTaxFee(shopInfo, items));
|
|
50
|
-
const surcharge = getSurcharge({ service: items, addons: [], bookingDetail: null, bookingId: void 0 }, { isEdit: false, isInScheduleByDate, surcharge_list: surchargeList, scheduleById
|
|
50
|
+
const surcharge = getSurcharge({ service: items, addons: [], bookingDetail: null, bookingId: void 0 }, { isEdit: false, isInScheduleByDate, surcharge_list: surchargeList, scheduleById });
|
|
51
51
|
const surchargeAmount = new import_decimal.default(getSurchargeAmount({ bookingDetail: null, bookingId: void 0 }, surcharge, { isEdit: false }));
|
|
52
52
|
const { tax, originTax } = getTax({ service: items, bookingDetail: null, bookingId: void 0 }, {
|
|
53
53
|
computed: {
|
|
@@ -59,12 +59,10 @@ var calculatePriceDetails = (shopInfo, items, isInScheduleByDate, surchargeList)
|
|
|
59
59
|
is_price_include_tax: shopInfo == null ? void 0 : shopInfo.is_price_include_tax
|
|
60
60
|
});
|
|
61
61
|
const total = (shopInfo == null ? void 0 : shopInfo.is_price_include_tax) ? subtotal.plus(surchargeAmount) : subtotal.plus(tax).plus(surchargeAmount);
|
|
62
|
-
const originTotal = (shopInfo == null ? void 0 : shopInfo.is_price_include_tax) ? subOriginTotal : subOriginTotal.plus(totalTaxFee);
|
|
63
62
|
const deposit = calculateDeposit(items);
|
|
64
63
|
return {
|
|
65
64
|
subtotal: subtotal.toFixed(2),
|
|
66
65
|
total: total.toFixed(2),
|
|
67
|
-
originTotal: originTotal.toFixed(2),
|
|
68
66
|
taxTitle: shopInfo == null ? void 0 : shopInfo.tax_title,
|
|
69
67
|
taxRate: shopInfo == null ? void 0 : shopInfo.tax_rate,
|
|
70
68
|
totalTaxFee: tax,
|
|
@@ -362,16 +360,6 @@ var calculateSubtotal = (items) => {
|
|
|
362
360
|
}, new import_decimal.default(0));
|
|
363
361
|
return subtotal.toFixed(2);
|
|
364
362
|
};
|
|
365
|
-
var calculateOriginSubtotal = (items) => {
|
|
366
|
-
if (!(items == null ? void 0 : items.length)) {
|
|
367
|
-
return "0.00";
|
|
368
|
-
}
|
|
369
|
-
const subtotal = items.reduce((sum, item) => {
|
|
370
|
-
const cartItemTotalPrice = new import_decimal.default(item.summaryOriginTotal || 0);
|
|
371
|
-
return sum.plus(cartItemTotalPrice);
|
|
372
|
-
}, new import_decimal.default(0));
|
|
373
|
-
return subtotal.toFixed(2);
|
|
374
|
-
};
|
|
375
363
|
var calculateTaxFee = (shopInfo, items) => {
|
|
376
364
|
if (!(items == null ? void 0 : items.length)) {
|
|
377
365
|
return "0.00";
|
|
@@ -456,9 +444,7 @@ var getMainProductTotal = (item) => {
|
|
|
456
444
|
}
|
|
457
445
|
for (let bundleItem of (item == null ? void 0 : item.bundle) || []) {
|
|
458
446
|
if (getBundleItemIsMarkupOrDiscountPrice(bundleItem)) {
|
|
459
|
-
const
|
|
460
|
-
const bundleItemPrice = new import_decimal.default(bundleItem.bundle_selling_price ?? bundleItem.price ?? 0);
|
|
461
|
-
const bundleItemTotal = bundleItemPrice.minus(discountAmount);
|
|
447
|
+
const bundleItemTotal = new import_decimal.default(bundleItem.bundle_selling_price ?? bundleItem.price ?? 0);
|
|
462
448
|
total = total.add(bundleItemTotal);
|
|
463
449
|
}
|
|
464
450
|
}
|
|
@@ -522,8 +508,17 @@ var isProductMatchSurchargeCondition = (item, options) => {
|
|
|
522
508
|
return isProductMatch && isScheduleMatch;
|
|
523
509
|
};
|
|
524
510
|
var getSurcharge = ({ service, addons, bookingDetail, bookingId }, options) => {
|
|
525
|
-
var _a, _b, _c;
|
|
511
|
+
var _a, _b, _c, _d;
|
|
526
512
|
const { isEdit, isInScheduleByDate, surcharge_list, scheduleById } = options;
|
|
513
|
+
const firstAppointmentCartItem = (_a = service.filter(
|
|
514
|
+
(n) => !(0, import_utils.isNormalProduct)(n._productOrigin)
|
|
515
|
+
)) == null ? void 0 : _a[0];
|
|
516
|
+
let startDate = "";
|
|
517
|
+
if (firstAppointmentCartItem) {
|
|
518
|
+
startDate = firstAppointmentCartItem.start_date + " " + firstAppointmentCartItem.start_time + ":00";
|
|
519
|
+
} else {
|
|
520
|
+
startDate = (0, import_dayjs.default)().format("YYYY-MM-DD HH:mm:ss");
|
|
521
|
+
}
|
|
527
522
|
if (!isEdit && bookingId) {
|
|
528
523
|
if (Array.isArray(bookingDetail == null ? void 0 : bookingDetail.surcharge)) {
|
|
529
524
|
return ((bookingDetail == null ? void 0 : bookingDetail.surcharge) || []).filter((d) => Number(d.amount) > 0).map(
|
|
@@ -570,7 +565,7 @@ var getSurcharge = ({ service, addons, bookingDetail, bookingId }, options) => {
|
|
|
570
565
|
if (isProductMatchSurchargeCondition(
|
|
571
566
|
{
|
|
572
567
|
isCustomItem: item.isCustomItem,
|
|
573
|
-
startDate
|
|
568
|
+
startDate,
|
|
574
569
|
product_id: item.id
|
|
575
570
|
},
|
|
576
571
|
{
|
|
@@ -602,7 +597,7 @@ var getSurcharge = ({ service, addons, bookingDetail, bookingId }, options) => {
|
|
|
602
597
|
if (getBundleItemIsOriginalPrice(bundleItem) && isProductMatchSurchargeCondition(
|
|
603
598
|
{
|
|
604
599
|
isCustomItem: false,
|
|
605
|
-
startDate
|
|
600
|
+
startDate,
|
|
606
601
|
product_id: bundleItem._bundle_product_id
|
|
607
602
|
},
|
|
608
603
|
{
|
|
@@ -628,7 +623,7 @@ var getSurcharge = ({ service, addons, bookingDetail, bookingId }, options) => {
|
|
|
628
623
|
if (isProductMatchSurchargeCondition(
|
|
629
624
|
{
|
|
630
625
|
isCustomItem: false,
|
|
631
|
-
startDate
|
|
626
|
+
startDate,
|
|
632
627
|
product_id: relationDetail.product_id
|
|
633
628
|
},
|
|
634
629
|
{
|
|
@@ -640,7 +635,7 @@ var getSurcharge = ({ service, addons, bookingDetail, bookingId }, options) => {
|
|
|
640
635
|
matchedItems.push({
|
|
641
636
|
isMain: false,
|
|
642
637
|
total: Number(
|
|
643
|
-
(relationDetail == null ? void 0 : relationDetail.price) || ((
|
|
638
|
+
(relationDetail == null ? void 0 : relationDetail.price) || ((_b = relationDetail == null ? void 0 : relationDetail.metadata) == null ? void 0 : _b.main_product_attached_bundle_selling_price)
|
|
644
639
|
),
|
|
645
640
|
quantity: relationDetail.num || relationDetail.quantity || 1,
|
|
646
641
|
item: relationDetail,
|
|
@@ -653,7 +648,7 @@ var getSurcharge = ({ service, addons, bookingDetail, bookingId }, options) => {
|
|
|
653
648
|
}
|
|
654
649
|
if (Array.isArray(addons == null ? void 0 : addons.value)) {
|
|
655
650
|
for (let item of addons.value) {
|
|
656
|
-
if (isProductMatchSurchargeCondition(item, {
|
|
651
|
+
if (isProductMatchSurchargeCondition({ ...item, startDate }, {
|
|
657
652
|
surchargeConfig,
|
|
658
653
|
scheduleById: scheduleById || {},
|
|
659
654
|
isInScheduleByDate
|
|
@@ -714,13 +709,13 @@ var getSurcharge = ({ service, addons, bookingDetail, bookingId }, options) => {
|
|
|
714
709
|
const surchargeFee = originSurchargeFee.plus(itemSurcharge).plus(fixedSurcharge).toDecimalPlaces(2, import_decimal.default.ROUND_DOWN).toNumber();
|
|
715
710
|
productTotalSurcharge = productTotalSurcharge.plus(new import_decimal.default(surchargeFee).times(itemQuantity).toNumber());
|
|
716
711
|
item.item.surcharge_fee = surchargeFee;
|
|
717
|
-
item.item.relation_surcharge_ids = [...((
|
|
712
|
+
item.item.relation_surcharge_ids = [...((_c = item.item) == null ? void 0 : _c.relation_surcharge_ids) || [], id];
|
|
718
713
|
} else {
|
|
719
714
|
const originSurchargeFee = new import_decimal.default(item.item.surcharge_fee || 0);
|
|
720
715
|
const surchargeFee = originSurchargeFee.plus(itemSurcharge).plus(fixedSurcharge).toDecimalPlaces(2, import_decimal.default.ROUND_DOWN).toNumber();
|
|
721
716
|
productTotalSurcharge = productTotalSurcharge.plus(new import_decimal.default(surchargeFee).times(itemQuantity).toNumber());
|
|
722
717
|
item.item.surcharge_fee = surchargeFee;
|
|
723
|
-
item.item.relation_surcharge_ids = [...((
|
|
718
|
+
item.item.relation_surcharge_ids = [...((_d = item.item) == null ? void 0 : _d.relation_surcharge_ids) || [], id];
|
|
724
719
|
}
|
|
725
720
|
}
|
|
726
721
|
if (isLast && configTotal.minus(productTotalSurcharge).gt(0)) {
|
|
@@ -790,7 +785,6 @@ function resetItemsSurchargeSideEffects({ service, addons }) {
|
|
|
790
785
|
0 && (module.exports = {
|
|
791
786
|
calcDiscountListDifference,
|
|
792
787
|
calculateDeposit,
|
|
793
|
-
calculateOriginSubtotal,
|
|
794
788
|
calculatePriceDetails,
|
|
795
789
|
calculateSubtotal,
|
|
796
790
|
calculateTaxFee,
|
package/lib/plugins/window.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { WalletPassEvaluator } from '../model';
|
|
2
1
|
import { Plugin } from '../types';
|
|
3
2
|
/**
|
|
4
3
|
* WindowPlugin 接口定义
|
|
@@ -15,7 +14,6 @@ export interface WindowPlugin extends Plugin {
|
|
|
15
14
|
document: Partial<Document>;
|
|
16
15
|
history: History;
|
|
17
16
|
interaction?: any;
|
|
18
|
-
getWalletPassEvaluator?: () => WalletPassEvaluator;
|
|
19
17
|
}
|
|
20
18
|
/**
|
|
21
19
|
* 简单的 Storage 接口实现
|
|
@@ -144,7 +144,6 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
144
144
|
getSummary(): Promise<{
|
|
145
145
|
subtotal: string | number;
|
|
146
146
|
total: string | number;
|
|
147
|
-
originTotal: string | number;
|
|
148
147
|
taxTitle?: string | undefined;
|
|
149
148
|
totalTaxFee?: string | number | undefined;
|
|
150
149
|
isPriceIncludeTax?: 0 | 1 | undefined;
|
|
@@ -1766,6 +1766,28 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1766
1766
|
newResources.forEach((resource) => {
|
|
1767
1767
|
var _a3, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
1768
1768
|
if (((_b2 = (_a3 = item._productOrigin) == null ? void 0 : _a3.duration) == null ? void 0 : _b2.type) === "flexible") {
|
|
1769
|
+
let getEarliestBlockedStartTime = function({
|
|
1770
|
+
currentStartTime: currentStartTime2,
|
|
1771
|
+
times
|
|
1772
|
+
}) {
|
|
1773
|
+
const currentStart = (0, import_dayjs.default)(currentStartTime2);
|
|
1774
|
+
let earliestBlockStart;
|
|
1775
|
+
for (const time of times || []) {
|
|
1776
|
+
for (const event of time.event_list || []) {
|
|
1777
|
+
const eventStart = (0, import_dayjs.default)(event.start_at);
|
|
1778
|
+
const eventEnd = (0, import_dayjs.default)(event.end_at);
|
|
1779
|
+
if (eventStart.isBefore(currentStart) && eventEnd.isAfter(currentStart)) {
|
|
1780
|
+
return currentStart.format("YYYY-MM-DD HH:mm");
|
|
1781
|
+
}
|
|
1782
|
+
if (eventStart.isAfter(currentStart)) {
|
|
1783
|
+
if (!earliestBlockStart || eventStart.isBefore(earliestBlockStart)) {
|
|
1784
|
+
earliestBlockStart = eventStart;
|
|
1785
|
+
}
|
|
1786
|
+
}
|
|
1787
|
+
}
|
|
1788
|
+
}
|
|
1789
|
+
return earliestBlockStart == null ? void 0 : earliestBlockStart.format("YYYY-MM-DD HH:mm");
|
|
1790
|
+
};
|
|
1769
1791
|
item.duration = {
|
|
1770
1792
|
type: "minutes",
|
|
1771
1793
|
value: 10
|
|
@@ -1780,13 +1802,22 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1780
1802
|
},
|
|
1781
1803
|
targetResourceTimes[0]
|
|
1782
1804
|
);
|
|
1805
|
+
const earliestBlockedStartTime = getEarliestBlockedStartTime({
|
|
1806
|
+
currentStartTime,
|
|
1807
|
+
times: targetResourceTimes
|
|
1808
|
+
});
|
|
1783
1809
|
const resourceDate = (0, import_dayjs.default)(resourcesEndTime.end_at).format(
|
|
1784
1810
|
"YYYY-MM-DD"
|
|
1785
1811
|
);
|
|
1786
1812
|
const operatingBoundaryDateTime = `${resourceDate} ${operating_day_boundary.type === "start_time" ? "23:59" : operating_day_boundary.time}`;
|
|
1787
|
-
const
|
|
1788
|
-
|
|
1789
|
-
|
|
1813
|
+
const endTimeCandidates = [
|
|
1814
|
+
resourcesEndTime.end_at,
|
|
1815
|
+
operatingBoundaryDateTime,
|
|
1816
|
+
...earliestBlockedStartTime ? [earliestBlockedStartTime] : []
|
|
1817
|
+
];
|
|
1818
|
+
const endTime = endTimeCandidates.reduce((earliest, value) => {
|
|
1819
|
+
return (0, import_dayjs.default)(value).isBefore((0, import_dayjs.default)(earliest)) ? value : earliest;
|
|
1820
|
+
}, endTimeCandidates[0]);
|
|
1790
1821
|
let formattedEndTime;
|
|
1791
1822
|
if (typeof endTime === "string" && endTime.includes(":") && !endTime.includes(" ") && !endTime.includes("T")) {
|
|
1792
1823
|
const currentDate = timeSlots.start_at.format("YYYY-MM-DD");
|
|
@@ -222,7 +222,6 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
222
222
|
product_id: item.product_id,
|
|
223
223
|
product_variant_id: item.product_variant_id,
|
|
224
224
|
quantity: item.num,
|
|
225
|
-
is_price_include_tax: item.is_price_include_tax,
|
|
226
225
|
// 商品是否含税:1;0
|
|
227
226
|
is_charge_tax: item.is_charge_tax ?? 0,
|
|
228
227
|
// 若商品不含税,计算得到的税费,单位(元)
|
|
@@ -247,7 +246,6 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
247
246
|
},
|
|
248
247
|
product_bundle: item.product_bundle.map((bundle) => {
|
|
249
248
|
return {
|
|
250
|
-
is_price_include_tax: item.is_price_include_tax,
|
|
251
249
|
bundle_id: bundle.bundle_id,
|
|
252
250
|
bundle_product_id: bundle.bundle_product_id,
|
|
253
251
|
bundle_variant_id: bundle.bundle_variant_id,
|
|
@@ -22,7 +22,6 @@ export declare class ShopDiscountImpl extends BaseModule implements Module {
|
|
|
22
22
|
getCurrentBookingTime(): string | null;
|
|
23
23
|
private filterDiscountListByBookingTime;
|
|
24
24
|
setCustomer(customer: Customer): Promise<void>;
|
|
25
|
-
setOriginTotalAmount(amount: number): void;
|
|
26
25
|
setHolders(holders: {
|
|
27
26
|
form_record_id: number;
|
|
28
27
|
}[]): void;
|
|
@@ -56,7 +56,6 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
56
56
|
originalDiscountList: [],
|
|
57
57
|
currentBookingTime: "",
|
|
58
58
|
filteredDiscountList: [],
|
|
59
|
-
orderTotalAmount: 0,
|
|
60
59
|
bookingSubject: void 0
|
|
61
60
|
};
|
|
62
61
|
}
|
|
@@ -195,9 +194,6 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
195
194
|
);
|
|
196
195
|
}
|
|
197
196
|
}
|
|
198
|
-
setOriginTotalAmount(amount) {
|
|
199
|
-
this.store.orderTotalAmount = amount;
|
|
200
|
-
}
|
|
201
197
|
// 设置holders
|
|
202
198
|
setHolders(holders) {
|
|
203
199
|
this.store.holders = holders;
|
|
@@ -218,7 +214,6 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
218
214
|
productList,
|
|
219
215
|
discountList: this.getDiscountList(),
|
|
220
216
|
holders: this.store.holders || [],
|
|
221
|
-
orderTotalAmount: this.store.orderTotalAmount || 0,
|
|
222
217
|
isFormSubject: ((_a = this.store.bookingSubject) == null ? void 0 : _a.type) === "form"
|
|
223
218
|
},
|
|
224
219
|
options
|
|
@@ -312,7 +307,6 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
312
307
|
oldDiscountList: this.getDiscountList(),
|
|
313
308
|
newDiscountList: withScanList,
|
|
314
309
|
holders: this.store.holders || [],
|
|
315
|
-
orderTotalAmount: this.store.orderTotalAmount || 0,
|
|
316
310
|
isFormSubject: ((_b = this.store.bookingSubject) == null ? void 0 : _b.type) === "form"
|
|
317
311
|
}) || {
|
|
318
312
|
isAvailable: false,
|
|
@@ -501,7 +495,8 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
501
495
|
action: "create",
|
|
502
496
|
with_good_pass: 1,
|
|
503
497
|
with_discount_card: 1,
|
|
504
|
-
with_wallet_pass_holder: 1
|
|
498
|
+
with_wallet_pass_holder: 1,
|
|
499
|
+
request_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
505
500
|
}));
|
|
506
501
|
const scanDiscount = (_c = this.getDiscountList()) == null ? void 0 : _c.filter(
|
|
507
502
|
(item) => item.isScan
|
package/package.json
CHANGED
package/dist/model/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './strategy';
|
package/dist/model/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./strategy";
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { EvaluationResult, RuntimeContext } from '../type';
|
|
2
|
-
export interface BusinessAdapter {
|
|
3
|
-
/**
|
|
4
|
-
* 适配器名称
|
|
5
|
-
*/
|
|
6
|
-
name: string;
|
|
7
|
-
/**
|
|
8
|
-
* 适配器版本
|
|
9
|
-
*/
|
|
10
|
-
version: string;
|
|
11
|
-
/**
|
|
12
|
-
* 准备运行时上下文
|
|
13
|
-
* 将业务数据转换为策略引擎可识别的上下文
|
|
14
|
-
*/
|
|
15
|
-
prepareContext(businessData: any): RuntimeContext;
|
|
16
|
-
/**
|
|
17
|
-
* 转换执行结果
|
|
18
|
-
* 将策略引擎的通用结果转换为业务层需要的格式
|
|
19
|
-
*/
|
|
20
|
-
transformResult(result: EvaluationResult, businessData?: any): any;
|
|
21
|
-
/**
|
|
22
|
-
* 根据业务数据重新格式化配置
|
|
23
|
-
*/
|
|
24
|
-
formatConfig(result: EvaluationResult, businessData?: any): {
|
|
25
|
-
result: EvaluationResult;
|
|
26
|
-
businessData?: any;
|
|
27
|
-
};
|
|
28
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { StrategyConfig } from '../../type';
|
|
2
|
-
import { Voucher, Product, VoucherEvaluationResult, EvaluatorInput } from './type';
|
|
3
|
-
/**
|
|
4
|
-
* Wallet Pass 评估器
|
|
5
|
-
* 用于评估哪些 voucher 可以在当前订单中使用
|
|
6
|
-
*/
|
|
7
|
-
export declare class WalletPassEvaluator {
|
|
8
|
-
private engine;
|
|
9
|
-
private strategyConfigs;
|
|
10
|
-
private locale;
|
|
11
|
-
constructor();
|
|
12
|
-
setStrategyConfigs(strategyConfigs: StrategyConfig[]): void;
|
|
13
|
-
getStrategyConfigs(): StrategyConfig[];
|
|
14
|
-
setLocale(locale: string): void;
|
|
15
|
-
getText(key: string): string;
|
|
16
|
-
/**
|
|
17
|
-
* 搜索券的格式
|
|
18
|
-
* @param input 输入
|
|
19
|
-
* @returns 返回搜索券的格式
|
|
20
|
-
*/
|
|
21
|
-
searchVoucherFormat(input: EvaluatorInput): Voucher[];
|
|
22
|
-
/**
|
|
23
|
-
* 评估可用的 vouchers
|
|
24
|
-
*/
|
|
25
|
-
evaluate(input: EvaluatorInput): VoucherEvaluationResult[];
|
|
26
|
-
/** 检查代金券/折扣卡是否可用 并返回config */
|
|
27
|
-
checkVoucherAvailability(input: EvaluatorInput): {
|
|
28
|
-
isAvailable: boolean;
|
|
29
|
-
config: {
|
|
30
|
-
[x: string]: any;
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
/**
|
|
34
|
-
* 获取推荐券
|
|
35
|
-
* @param input 输入
|
|
36
|
-
* @returns 返回推荐券列表
|
|
37
|
-
*/
|
|
38
|
-
getRecommendedVouchers(input: EvaluatorInput): {
|
|
39
|
-
recommendedAmount: any;
|
|
40
|
-
recommended: any[];
|
|
41
|
-
transformList: any[];
|
|
42
|
-
noApplicableVoucher: Voucher[];
|
|
43
|
-
};
|
|
44
|
-
enhanceWithReason(voucher: any): any;
|
|
45
|
-
/**
|
|
46
|
-
* 优惠券处理函数
|
|
47
|
-
* @param applicableVouchers 可用的券列表
|
|
48
|
-
* @param orderTotalAmount 订单总金额
|
|
49
|
-
* @param products 订单商品列表
|
|
50
|
-
* @returns 返回推荐券列表和全部列表,每个券包含 _available_max_amount 和 _unified_available_status
|
|
51
|
-
*/
|
|
52
|
-
processVouchers(vouchers: Voucher[], orderTotalAmount: number, products: Product[]): {
|
|
53
|
-
recommended: any[];
|
|
54
|
-
transformList: any[];
|
|
55
|
-
};
|
|
56
|
-
/**
|
|
57
|
-
* 重新计算优惠券状态(基于已选券的增量计算)
|
|
58
|
-
* @param allVouchers 所有原始券列表
|
|
59
|
-
* @param selectedVouchers 已选中的券列表(按选中顺序)
|
|
60
|
-
* @param orderTotalAmount 订单总金额
|
|
61
|
-
* @param products 订单商品列表
|
|
62
|
-
* @returns 返回更新后的所有券列表和已选券的详细抵扣信息
|
|
63
|
-
*/
|
|
64
|
-
recalculateVouchers(allVouchers: any[], selectedVouchers: any[], orderTotalAmount: number, products: any[]): {
|
|
65
|
-
allWithUpdatedStatus: any[];
|
|
66
|
-
selectedWithDetails: any[];
|
|
67
|
-
};
|
|
68
|
-
/**
|
|
69
|
-
* 查找适用于指定 voucher 的策略配置
|
|
70
|
-
*/
|
|
71
|
-
private findApplicableStrategies;
|
|
72
|
-
/**
|
|
73
|
-
* 检查策略中是否包含指定的 voucher ID
|
|
74
|
-
*/
|
|
75
|
-
private checkVoucherInStrategy;
|
|
76
|
-
/**
|
|
77
|
-
* 递归检查条件组中是否包含 voucher ID
|
|
78
|
-
*/
|
|
79
|
-
private checkVoucherInConditionGroup;
|
|
80
|
-
/**
|
|
81
|
-
* 计算适用商品的总金额和数量
|
|
82
|
-
*/
|
|
83
|
-
private calculateApplicableProducts;
|
|
84
|
-
}
|