@pisell/pisellos 2.1.125 → 2.1.127
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/model/strategy/adapter/itemRule/adapter.d.ts +8 -0
- package/dist/model/strategy/adapter/itemRule/adapter.js +52 -8
- package/dist/model/strategy/adapter/itemRule/examples.d.ts +15 -0
- package/dist/model/strategy/adapter/itemRule/examples.js +68 -1
- package/dist/model/strategy/adapter/itemRule/index.d.ts +1 -1
- package/dist/model/strategy/adapter/itemRule/index.js +1 -1
- package/dist/model/strategy/adapter/itemRule/type.d.ts +20 -1
- package/dist/modules/Order/index.d.ts +1 -1
- package/dist/modules/Order/index.js +6 -40
- package/dist/modules/Order/utils.d.ts +24 -0
- package/dist/modules/Order/utils.js +87 -11
- package/dist/modules/SalesSummary/types.d.ts +2 -1
- package/dist/modules/SalesSummary/utils.js +10 -10
- package/dist/modules/Schedule/utils.d.ts +1 -1
- package/dist/solution/ScanOrder/index.d.ts +5 -0
- package/dist/solution/ScanOrder/index.js +205 -64
- package/dist/solution/ScanOrder/types.d.ts +19 -5
- package/dist/solution/ScanOrder/utils.d.ts +15 -0
- package/dist/solution/ScanOrder/utils.js +142 -62
- package/dist/solution/VenueBooking/index.d.ts +4 -0
- package/dist/solution/VenueBooking/index.js +219 -141
- package/dist/solution/VenueBooking/utils/dateSummary.d.ts +1 -0
- package/dist/solution/VenueBooking/utils/dateSummary.js +6 -4
- package/lib/model/strategy/adapter/itemRule/adapter.d.ts +8 -0
- package/lib/model/strategy/adapter/itemRule/adapter.js +41 -2
- package/lib/model/strategy/adapter/itemRule/examples.d.ts +15 -0
- package/lib/model/strategy/adapter/itemRule/examples.js +47 -0
- package/lib/model/strategy/adapter/itemRule/index.d.ts +1 -1
- package/lib/model/strategy/adapter/itemRule/index.js +2 -0
- package/lib/model/strategy/adapter/itemRule/type.d.ts +20 -1
- package/lib/model/strategy/adapter/promotion/index.js +49 -0
- package/lib/modules/Order/index.d.ts +1 -1
- package/lib/modules/Order/index.js +4 -37
- package/lib/modules/Order/utils.d.ts +24 -0
- package/lib/modules/Order/utils.js +65 -4
- package/lib/modules/SalesSummary/types.d.ts +2 -1
- package/lib/modules/SalesSummary/utils.js +2 -2
- package/lib/modules/Schedule/utils.d.ts +1 -1
- package/lib/solution/ScanOrder/index.d.ts +5 -0
- package/lib/solution/ScanOrder/index.js +94 -18
- package/lib/solution/ScanOrder/types.d.ts +19 -5
- package/lib/solution/ScanOrder/utils.d.ts +15 -0
- package/lib/solution/ScanOrder/utils.js +86 -19
- package/lib/solution/VenueBooking/index.d.ts +4 -0
- package/lib/solution/VenueBooking/index.js +85 -25
- package/lib/solution/VenueBooking/utils/dateSummary.d.ts +1 -0
- package/lib/solution/VenueBooking/utils/dateSummary.js +13 -4
- package/package.json +1 -1
|
@@ -40,6 +40,7 @@ var import_types2 = require("../BookingByStep/types");
|
|
|
40
40
|
var import_ProductList = require("../../modules/ProductList");
|
|
41
41
|
var import_Date = require("../../modules/Date");
|
|
42
42
|
var import_Schedule = require("../../modules/Schedule");
|
|
43
|
+
var import_utils2 = require("../../modules/Schedule/utils");
|
|
43
44
|
var import_Quotation = require("../../modules/Quotation");
|
|
44
45
|
var import_OpenData = require("../../modules/OpenData");
|
|
45
46
|
var import_types3 = require("../../modules/Account/types");
|
|
@@ -49,7 +50,7 @@ var import_resource = require("./utils/resource");
|
|
|
49
50
|
var import_timeSlot = require("./utils/timeSlot");
|
|
50
51
|
var import_dateSummary = require("./utils/dateSummary");
|
|
51
52
|
var import_slotMerge = require("./utils/slotMerge");
|
|
52
|
-
var
|
|
53
|
+
var import_utils3 = require("../../modules/Order/utils");
|
|
53
54
|
var import_Order = require("../../modules/Order");
|
|
54
55
|
var import_types4 = require("../RegisterAndLogin/types");
|
|
55
56
|
var import_decimal = __toESM(require("decimal.js"));
|
|
@@ -96,6 +97,7 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
96
97
|
}
|
|
97
98
|
};
|
|
98
99
|
this.otherParams = {};
|
|
100
|
+
this.baseSlotConfig = { ...import_types.DEFAULT_SLOT_CONFIG };
|
|
99
101
|
this.itemRuleEvaluator = new import_itemRule.ItemRuleEvaluator();
|
|
100
102
|
this.itemRuleConfigs = [];
|
|
101
103
|
this.itemRuleConfigsPromise = null;
|
|
@@ -301,10 +303,11 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
301
303
|
this.store.status = "initializing";
|
|
302
304
|
this.store.error = null;
|
|
303
305
|
this.store.rawResourceData = [];
|
|
304
|
-
this.
|
|
306
|
+
this.baseSlotConfig = {
|
|
305
307
|
...import_types.DEFAULT_SLOT_CONFIG,
|
|
306
308
|
...((_b = options.otherParams) == null ? void 0 : _b.slotConfig) || {}
|
|
307
309
|
};
|
|
310
|
+
this.store.slotConfig = { ...this.baseSlotConfig };
|
|
308
311
|
this.otherParams = options.otherParams || {};
|
|
309
312
|
this.cacheId = (_c = this.otherParams) == null ? void 0 : _c.cacheId;
|
|
310
313
|
this.itemRuleRuntimeConfig = ((_d = this.otherParams) == null ? void 0 : _d.venueBookingItemRule) || ((_e = this.otherParams) == null ? void 0 : _e.itemRule) || {};
|
|
@@ -645,27 +648,87 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
645
648
|
}
|
|
646
649
|
}
|
|
647
650
|
// ─── 日期概览 & 时间槽矩阵(纯计算,不发请求) ───
|
|
651
|
+
getOperatingHoursScheduleIds() {
|
|
652
|
+
var _a, _b;
|
|
653
|
+
const openData = this.otherParams.openData || ((_b = (_a = this.store.openData) == null ? void 0 : _a.getOpenData) == null ? void 0 : _b.call(_a)) || null;
|
|
654
|
+
const rawIds = openData == null ? void 0 : openData["availability.operating_hours"];
|
|
655
|
+
if (!Array.isArray(rawIds))
|
|
656
|
+
return [];
|
|
657
|
+
return [...new Set(
|
|
658
|
+
rawIds.map((id) => Number(id)).filter((id) => Number.isFinite(id) && id > 0).map((id) => Math.floor(id))
|
|
659
|
+
)];
|
|
660
|
+
}
|
|
661
|
+
resolveSlotConfigForDate(date) {
|
|
662
|
+
var _a;
|
|
663
|
+
const nextSlotConfig = { ...this.baseSlotConfig };
|
|
664
|
+
if (!date || !this.store.schedule)
|
|
665
|
+
return nextSlotConfig;
|
|
666
|
+
const operatingHoursScheduleIds = this.getOperatingHoursScheduleIds();
|
|
667
|
+
if (!operatingHoursScheduleIds.length)
|
|
668
|
+
return nextSlotConfig;
|
|
669
|
+
const scheduleList = this.store.schedule.getScheduleListByIds(
|
|
670
|
+
operatingHoursScheduleIds
|
|
671
|
+
);
|
|
672
|
+
if (!scheduleList.length)
|
|
673
|
+
return nextSlotConfig;
|
|
674
|
+
const timeRangeMap = (0, import_utils2.calcMinTimeMaxTimeBySchedules)(
|
|
675
|
+
scheduleList,
|
|
676
|
+
void 0,
|
|
677
|
+
date
|
|
678
|
+
);
|
|
679
|
+
let earliestStart = null;
|
|
680
|
+
let latestEnd = null;
|
|
681
|
+
for (const schedule of scheduleList) {
|
|
682
|
+
const dateRangeList = ((_a = timeRangeMap == null ? void 0 : timeRangeMap[schedule.id]) == null ? void 0 : _a.dateRangeFormat) || [];
|
|
683
|
+
for (const range of dateRangeList) {
|
|
684
|
+
const start = (0, import_dayjs.default)(range == null ? void 0 : range.start);
|
|
685
|
+
const end = (0, import_dayjs.default)(range == null ? void 0 : range.end);
|
|
686
|
+
if (!start.isValid() || !end.isValid())
|
|
687
|
+
continue;
|
|
688
|
+
if (!earliestStart || start.isBefore(earliestStart)) {
|
|
689
|
+
earliestStart = start;
|
|
690
|
+
}
|
|
691
|
+
if (!latestEnd || end.isAfter(latestEnd)) {
|
|
692
|
+
latestEnd = end;
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
if (!earliestStart || !latestEnd)
|
|
697
|
+
return nextSlotConfig;
|
|
698
|
+
return {
|
|
699
|
+
...nextSlotConfig,
|
|
700
|
+
businessStartTime: earliestStart.format("HH:mm"),
|
|
701
|
+
businessEndTime: latestEnd.format("HH:mm")
|
|
702
|
+
};
|
|
703
|
+
}
|
|
704
|
+
syncOperatingHoursToSlotConfig(date) {
|
|
705
|
+
const resolvedSlotConfig = this.resolveSlotConfigForDate(date);
|
|
706
|
+
this.store.slotConfig = resolvedSlotConfig;
|
|
707
|
+
return resolvedSlotConfig;
|
|
708
|
+
}
|
|
648
709
|
getDateRangeSummary(params) {
|
|
649
710
|
return (0, import_dateSummary.buildDateRangeSummary)({
|
|
650
711
|
startDate: params.startDate,
|
|
651
712
|
endDate: params.endDate,
|
|
652
|
-
config: this.
|
|
713
|
+
config: this.baseSlotConfig,
|
|
653
714
|
rawResources: this.store.rawResourceData,
|
|
654
715
|
resourceProductMap: this.resourceProductMap,
|
|
655
|
-
quotationModule: this.store.quotation
|
|
716
|
+
quotationModule: this.store.quotation,
|
|
717
|
+
resolveConfig: (date) => this.resolveSlotConfigForDate(date)
|
|
656
718
|
});
|
|
657
719
|
}
|
|
658
720
|
getTimeSlotGrid(date) {
|
|
721
|
+
const resolvedSlotConfig = this.syncOperatingHoursToSlotConfig(date);
|
|
659
722
|
let quotationPriceMap;
|
|
660
723
|
if (this.store.quotation) {
|
|
661
724
|
const productIds = [...new Set([...this.resourceProductMap.values()].map((m) => m.productId))];
|
|
662
|
-
const timeLabels = (0, import_timeSlot.generateTimeLabels)(
|
|
725
|
+
const timeLabels = (0, import_timeSlot.generateTimeLabels)(resolvedSlotConfig);
|
|
663
726
|
const timePoints = timeLabels.map((label) => `${date} ${label}`);
|
|
664
727
|
quotationPriceMap = this.store.quotation.buildProductPriceMap({ productIds, timePoints });
|
|
665
728
|
}
|
|
666
729
|
return (0, import_timeSlot.buildTimeSlotGrid)({
|
|
667
730
|
date,
|
|
668
|
-
config:
|
|
731
|
+
config: resolvedSlotConfig,
|
|
669
732
|
rawResources: this.store.rawResourceData,
|
|
670
733
|
resourceProductMap: this.resourceProductMap,
|
|
671
734
|
quotationPriceMap
|
|
@@ -800,7 +863,7 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
800
863
|
for (let i = 0; i < merged.length; i++) {
|
|
801
864
|
const group = merged[i];
|
|
802
865
|
const identityKey = (0, import_slotMerge.buildVenueIdentityKey)(resourceId, i);
|
|
803
|
-
const bookingUuid = (0,
|
|
866
|
+
const bookingUuid = (0, import_utils3.createUuidV4)();
|
|
804
867
|
const startMoment = (0, import_dayjs.default)(group.startTime, "YYYY-MM-DD HH:mm");
|
|
805
868
|
const endMoment = (0, import_dayjs.default)(group.endTime, "YYYY-MM-DD HH:mm");
|
|
806
869
|
const duration = endMoment.diff(startMoment, "minute");
|
|
@@ -813,7 +876,6 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
813
876
|
num: 1,
|
|
814
877
|
selling_price: group.totalPrice,
|
|
815
878
|
original_price: group.totalPrice,
|
|
816
|
-
payment_price: group.totalPrice,
|
|
817
879
|
is_charge_tax: (venueProduct == null ? void 0 : venueProduct.is_charge_tax) ?? 0,
|
|
818
880
|
metadata: {
|
|
819
881
|
venue_booking: true,
|
|
@@ -892,10 +954,13 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
892
954
|
}
|
|
893
955
|
// ─── 配置 ───
|
|
894
956
|
setSlotConfig(config) {
|
|
895
|
-
this.
|
|
896
|
-
...this.
|
|
957
|
+
this.baseSlotConfig = {
|
|
958
|
+
...this.baseSlotConfig,
|
|
897
959
|
...config
|
|
898
960
|
};
|
|
961
|
+
this.store.slotConfig = {
|
|
962
|
+
...this.baseSlotConfig
|
|
963
|
+
};
|
|
899
964
|
}
|
|
900
965
|
getSlotConfig() {
|
|
901
966
|
return { ...this.store.slotConfig };
|
|
@@ -986,7 +1051,7 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
986
1051
|
const merged = (0, import_slotMerge.mergeConsecutiveSlots)(updatedSlots);
|
|
987
1052
|
if (merged.length === 1) {
|
|
988
1053
|
product.selling_price = merged[0].totalPrice;
|
|
989
|
-
product.
|
|
1054
|
+
product.original_price = merged[0].totalPrice;
|
|
990
1055
|
product.metadata.price_breakdown = (0, import_slotMerge.buildPriceBreakdown)({
|
|
991
1056
|
group: merged[0],
|
|
992
1057
|
productId: mapping.productId,
|
|
@@ -1001,7 +1066,7 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
1001
1066
|
});
|
|
1002
1067
|
if (quotationPrice !== null) {
|
|
1003
1068
|
product.selling_price = quotationPrice;
|
|
1004
|
-
product.
|
|
1069
|
+
product.original_price = quotationPrice;
|
|
1005
1070
|
}
|
|
1006
1071
|
}
|
|
1007
1072
|
}
|
|
@@ -1096,15 +1161,14 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
1096
1161
|
return rid != null && selectedResourceIds.has(rid);
|
|
1097
1162
|
});
|
|
1098
1163
|
if (product.discount_list.length < before) {
|
|
1099
|
-
const
|
|
1164
|
+
const totalPerUnitDiscount = product.discount_list.reduce(
|
|
1100
1165
|
(sum, pd) => sum + (pd.amount || 0),
|
|
1101
1166
|
0
|
|
1102
1167
|
);
|
|
1103
|
-
const
|
|
1104
|
-
|
|
1105
|
-
product.payment_price = paymentStr;
|
|
1168
|
+
const newSellingPrice = new import_decimal.default(product.original_price || product.selling_price || 0).minus(totalPerUnitDiscount).toDecimalPlaces(2).toString();
|
|
1169
|
+
product.selling_price = newSellingPrice;
|
|
1106
1170
|
if (product.metadata) {
|
|
1107
|
-
product.metadata.main_product_selling_price =
|
|
1171
|
+
product.metadata.main_product_selling_price = newSellingPrice;
|
|
1108
1172
|
}
|
|
1109
1173
|
}
|
|
1110
1174
|
}
|
|
@@ -1201,10 +1265,9 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
1201
1265
|
});
|
|
1202
1266
|
if (quotationPrice !== null) {
|
|
1203
1267
|
product.selling_price = quotationPrice;
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
product.payment_price = quotationPrice;
|
|
1268
|
+
product.original_price = quotationPrice;
|
|
1269
|
+
} else if (product.selling_price != null) {
|
|
1270
|
+
product.original_price = product.selling_price;
|
|
1208
1271
|
}
|
|
1209
1272
|
}
|
|
1210
1273
|
const products = await this.store.order.addProductToOrder(product);
|
|
@@ -1449,16 +1512,13 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
1449
1512
|
});
|
|
1450
1513
|
if (productIndex === -1) {
|
|
1451
1514
|
const sellingPrice = (0, import_utils.toPriceString)((sourceItem == null ? void 0 : sourceItem.price) ?? (sourceItem == null ? void 0 : sourceItem.selling_price), "0.00");
|
|
1452
|
-
const originalPrice = (0, import_utils.toPriceString)((sourceItem == null ? void 0 : sourceItem.original_price) ?? (sourceItem == null ? void 0 : sourceItem.price) ?? sellingPrice, sellingPrice);
|
|
1453
|
-
const paymentPrice = (0, import_utils.toPriceString)((sourceItem == null ? void 0 : sourceItem.payment_price) ?? (sourceItem == null ? void 0 : sourceItem.price) ?? sellingPrice, sellingPrice);
|
|
1454
1515
|
tempOrder.products.push(
|
|
1455
1516
|
(0, import_utils.normalizeOrderProduct)({
|
|
1456
1517
|
product_id: productId,
|
|
1457
1518
|
product_variant_id: productVariantId,
|
|
1458
1519
|
num: targetQuantity,
|
|
1459
1520
|
selling_price: sellingPrice,
|
|
1460
|
-
original_price:
|
|
1461
|
-
payment_price: paymentPrice,
|
|
1521
|
+
original_price: sellingPrice,
|
|
1462
1522
|
metadata: { item_rule_prefill: true, item_rule_id: prefillItem.ruleId },
|
|
1463
1523
|
_origin: { ...sourceItem || {}, item_rule_prefill: true, item_rule_id: prefillItem.ruleId }
|
|
1464
1524
|
})
|
|
@@ -7,4 +7,5 @@ export declare function buildDateRangeSummary(params: {
|
|
|
7
7
|
rawResources: VenueResourceRawData[];
|
|
8
8
|
resourceProductMap: Map<number | string, ResourceProductMapping>;
|
|
9
9
|
quotationModule?: QuotationModule;
|
|
10
|
+
resolveConfig?: (date: string) => VenueBookingSlotConfig;
|
|
10
11
|
}): VenueDateSummaryItem[];
|
|
@@ -35,22 +35,31 @@ module.exports = __toCommonJS(dateSummary_exports);
|
|
|
35
35
|
var import_dayjs = __toESM(require("dayjs"));
|
|
36
36
|
var import_timeSlot = require("./timeSlot");
|
|
37
37
|
function buildDateRangeSummary(params) {
|
|
38
|
-
const {
|
|
38
|
+
const {
|
|
39
|
+
startDate,
|
|
40
|
+
endDate,
|
|
41
|
+
config,
|
|
42
|
+
rawResources,
|
|
43
|
+
resourceProductMap,
|
|
44
|
+
quotationModule,
|
|
45
|
+
resolveConfig
|
|
46
|
+
} = params;
|
|
39
47
|
const result = [];
|
|
40
48
|
const productIds = quotationModule ? [...new Set([...resourceProductMap.values()].map((m) => m.productId))] : [];
|
|
41
49
|
let cursor = (0, import_dayjs.default)(startDate);
|
|
42
50
|
const end = (0, import_dayjs.default)(endDate);
|
|
43
51
|
while (!cursor.isAfter(end)) {
|
|
44
52
|
const date = cursor.format("YYYY-MM-DD");
|
|
53
|
+
const effectiveConfig = (resolveConfig == null ? void 0 : resolveConfig(date)) || config;
|
|
45
54
|
let quotationPriceMap;
|
|
46
55
|
if (quotationModule && productIds.length) {
|
|
47
|
-
const timeLabels = (0, import_timeSlot.generateTimeLabels)(
|
|
56
|
+
const timeLabels = (0, import_timeSlot.generateTimeLabels)(effectiveConfig);
|
|
48
57
|
const timePoints = timeLabels.map((label) => `${date} ${label}`);
|
|
49
58
|
quotationPriceMap = quotationModule.buildProductPriceMap({ productIds, timePoints });
|
|
50
59
|
}
|
|
51
60
|
const grid = (0, import_timeSlot.buildTimeSlotGrid)({
|
|
52
61
|
date,
|
|
53
|
-
config,
|
|
62
|
+
config: effectiveConfig,
|
|
54
63
|
rawResources,
|
|
55
64
|
resourceProductMap,
|
|
56
65
|
quotationPriceMap
|
|
@@ -79,7 +88,7 @@ function buildDateRangeSummary(params) {
|
|
|
79
88
|
status = "unavailable";
|
|
80
89
|
} else if (availableSlots === 0) {
|
|
81
90
|
status = "sold_out";
|
|
82
|
-
} else if ((totalSlots - availableSlots) / totalSlots >=
|
|
91
|
+
} else if ((totalSlots - availableSlots) / totalSlots >= effectiveConfig.fewLeftThreshold) {
|
|
83
92
|
status = "few_left";
|
|
84
93
|
} else {
|
|
85
94
|
status = "available";
|