@pisell/pisellos 0.0.493 → 0.0.495
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/modules/Cart/utils/cartProduct.js +1 -0
- package/dist/modules/Order/index.d.ts +5 -0
- package/dist/modules/Order/index.js +70 -5
- package/dist/modules/Order/utils.js +12 -2
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/Quotation/index.d.ts +8 -0
- package/dist/modules/Quotation/index.js +46 -13
- package/dist/modules/Schedule/getDateIsInSchedule.js +11 -18
- package/dist/solution/BookingByStep/index.d.ts +2 -2
- package/dist/solution/ScanOrder/utils.js +22 -3
- package/dist/solution/VenueBooking/index.d.ts +8 -9
- package/dist/solution/VenueBooking/index.js +614 -567
- package/dist/solution/VenueBooking/types.d.ts +7 -0
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +13 -2
- package/dist/solution/VenueBooking/utils/slotMerge.js +92 -15
- package/lib/modules/Cart/utils/cartProduct.js +1 -0
- package/lib/modules/Order/index.d.ts +5 -0
- package/lib/modules/Order/index.js +37 -1
- package/lib/modules/Order/utils.js +13 -0
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/Quotation/index.d.ts +8 -0
- package/lib/modules/Quotation/index.js +27 -6
- package/lib/modules/Schedule/getDateIsInSchedule.js +9 -11
- package/lib/solution/BookingByStep/index.d.ts +2 -2
- package/lib/solution/ScanOrder/utils.js +20 -3
- package/lib/solution/VenueBooking/index.d.ts +8 -9
- package/lib/solution/VenueBooking/index.js +82 -71
- package/lib/solution/VenueBooking/types.d.ts +7 -0
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +13 -2
- package/lib/solution/VenueBooking/utils/slotMerge.js +67 -13
- package/package.json +1 -1
|
@@ -50,6 +50,7 @@ var import_timeSlot = require("./utils/timeSlot");
|
|
|
50
50
|
var import_dateSummary = require("./utils/dateSummary");
|
|
51
51
|
var import_slotMerge = require("./utils/slotMerge");
|
|
52
52
|
var import_utils2 = require("../../modules/Order/utils");
|
|
53
|
+
var import_Order = require("../../modules/Order");
|
|
53
54
|
var import_types4 = require("../RegisterAndLogin/types");
|
|
54
55
|
__reExport(VenueBooking_exports, require("./types"), module.exports);
|
|
55
56
|
var OPEN_DATA_SECTION_CODES = [
|
|
@@ -59,7 +60,8 @@ var OPEN_DATA_SECTION_CODES = [
|
|
|
59
60
|
"sale",
|
|
60
61
|
"menu",
|
|
61
62
|
"availability",
|
|
62
|
-
"workflow"
|
|
63
|
+
"workflow",
|
|
64
|
+
"checkout"
|
|
63
65
|
];
|
|
64
66
|
function cloneCustomDepositData(customDepositData) {
|
|
65
67
|
if (!customDepositData || typeof customDepositData !== "object")
|
|
@@ -416,6 +418,10 @@ var VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
416
418
|
await ((_h = this.store.order) == null ? void 0 : _h.recalculateSummary({ createIfMissing: false }));
|
|
417
419
|
(_i = this.store.order) == null ? void 0 : _i.persistTempOrder();
|
|
418
420
|
await this.loadRuntimeConfigs();
|
|
421
|
+
if (this.store.schedule) {
|
|
422
|
+
await this.store.schedule.loadAllSchedule();
|
|
423
|
+
this.injectScheduleResolverToQuotation();
|
|
424
|
+
}
|
|
419
425
|
await this.refreshItemRuleQuantityLimits();
|
|
420
426
|
this.store.status = "ready";
|
|
421
427
|
console.log("[VenueBooking] 初始化完成");
|
|
@@ -491,52 +497,54 @@ var VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
491
497
|
return this.store.cartValidation || { passed: null, failures: [] };
|
|
492
498
|
}
|
|
493
499
|
// ─── 场地商品 & 附加商品 ───
|
|
494
|
-
async
|
|
495
|
-
|
|
500
|
+
async loadAllProducts() {
|
|
501
|
+
var _a, _b, _c;
|
|
502
|
+
this.logMethodStart("loadAllProducts");
|
|
496
503
|
try {
|
|
497
504
|
if (!this.store.venueProducts)
|
|
498
505
|
throw new Error("venueProducts 模块未初始化");
|
|
499
|
-
const res = await this.store.venueProducts.loadProducts({
|
|
500
|
-
product_ids: params.productIds,
|
|
501
|
-
cacheId: this.cacheId,
|
|
502
|
-
schedule_date: (0, import_dayjs.default)().format("YYYY-MM-DD"),
|
|
503
|
-
schedule_datetime: (0, import_dayjs.default)().format("YYYY-MM-DD HH:mm:ss")
|
|
504
|
-
});
|
|
505
|
-
const products = Array.isArray(res) ? res : [];
|
|
506
|
-
this.resourceProductMap = (0, import_resource.buildResourceProductMap)(products);
|
|
507
|
-
this.logMethodSuccess("loadVenueProducts", {
|
|
508
|
-
productCount: products.length,
|
|
509
|
-
resourceCount: this.resourceProductMap.size
|
|
510
|
-
});
|
|
511
|
-
return products;
|
|
512
|
-
} catch (error) {
|
|
513
|
-
this.logMethodError("loadVenueProducts", error);
|
|
514
|
-
throw error;
|
|
515
|
-
}
|
|
516
|
-
}
|
|
517
|
-
async loadAddonProducts(params) {
|
|
518
|
-
this.logMethodStart("loadAddonProducts");
|
|
519
|
-
try {
|
|
520
506
|
if (!this.store.addonProducts)
|
|
521
507
|
throw new Error("addonProducts 模块未初始化");
|
|
522
|
-
const
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
508
|
+
const associatedMenus = ((_b = (_a = this.otherParams) == null ? void 0 : _a.openData) == null ? void 0 : _b["menu.associated_menus"]) || [];
|
|
509
|
+
if (!associatedMenus.length) {
|
|
510
|
+
throw new Error("未获取到餐牌配置(menu.associated_menus),请检查 OpenData 配置");
|
|
511
|
+
}
|
|
512
|
+
const menuListIds = associatedMenus.map((n) => Number(n.value));
|
|
513
|
+
const allProducts = await this.store.venueProducts.loadProducts({
|
|
514
|
+
menu_list_ids: menuListIds,
|
|
526
515
|
cacheId: this.cacheId,
|
|
527
516
|
schedule_date: (0, import_dayjs.default)().format("YYYY-MM-DD"),
|
|
528
517
|
schedule_datetime: (0, import_dayjs.default)().format("YYYY-MM-DD HH:mm:ss")
|
|
529
518
|
});
|
|
530
|
-
const
|
|
531
|
-
|
|
532
|
-
|
|
519
|
+
const list = Array.isArray(allProducts) ? allProducts : [];
|
|
520
|
+
const venueList = list.filter((p) => p.duration != null);
|
|
521
|
+
const addonList = list.filter((p) => p.duration == null);
|
|
522
|
+
const venueStore = (_c = this.store.venueProducts) == null ? void 0 : _c.store;
|
|
523
|
+
if (venueStore) {
|
|
524
|
+
venueStore.list = venueList.slice().sort((a, b) => Number(b.sort) - Number(a.sort));
|
|
525
|
+
}
|
|
526
|
+
this.store.addonProducts.addProduct(addonList);
|
|
527
|
+
this.resourceProductMap = (0, import_resource.buildResourceProductMap)(venueList);
|
|
528
|
+
this.logMethodSuccess("loadAllProducts", {
|
|
529
|
+
total: list.length,
|
|
530
|
+
venueCount: venueList.length,
|
|
531
|
+
addonCount: addonList.length,
|
|
532
|
+
resourceCount: this.resourceProductMap.size
|
|
533
533
|
});
|
|
534
|
-
return
|
|
534
|
+
return { venueProducts: venueList, addonProducts: addonList };
|
|
535
535
|
} catch (error) {
|
|
536
|
-
this.logMethodError("
|
|
536
|
+
this.logMethodError("loadAllProducts", error);
|
|
537
537
|
throw error;
|
|
538
538
|
}
|
|
539
539
|
}
|
|
540
|
+
async loadVenueProducts() {
|
|
541
|
+
const result = await this.loadAllProducts();
|
|
542
|
+
return result.venueProducts;
|
|
543
|
+
}
|
|
544
|
+
async loadAddonProducts() {
|
|
545
|
+
const result = await this.loadAllProducts();
|
|
546
|
+
return result.addonProducts;
|
|
547
|
+
}
|
|
540
548
|
getVenueProducts() {
|
|
541
549
|
var _a, _b;
|
|
542
550
|
return ((_b = (_a = this.store.venueProducts) == null ? void 0 : _a.store) == null ? void 0 : _b.list) || [];
|
|
@@ -799,7 +807,12 @@ var VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
799
807
|
start_time: group.startTime,
|
|
800
808
|
end_time: group.endTime,
|
|
801
809
|
slot_count: group.slotCount,
|
|
802
|
-
booking_uid: bookingUuid
|
|
810
|
+
booking_uid: bookingUuid,
|
|
811
|
+
price_breakdown: (0, import_slotMerge.buildPriceBreakdown)({
|
|
812
|
+
group,
|
|
813
|
+
productId: mapping.productId,
|
|
814
|
+
quotation: this.store.quotation
|
|
815
|
+
})
|
|
803
816
|
},
|
|
804
817
|
_origin: {
|
|
805
818
|
name: mapping.productTitle,
|
|
@@ -830,7 +843,7 @@ var VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
830
843
|
main_field: mapping.resourceName,
|
|
831
844
|
form_id: (rawResource == null ? void 0 : rawResource.form_id) ?? mapping.formId,
|
|
832
845
|
relation_id: resourceId,
|
|
833
|
-
capacity:
|
|
846
|
+
capacity: 1,
|
|
834
847
|
metadata: {}
|
|
835
848
|
}],
|
|
836
849
|
schedule_id: 0,
|
|
@@ -878,12 +891,20 @@ var VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
878
891
|
if (!this.store.schedule)
|
|
879
892
|
throw new Error("schedule 模块未初始化");
|
|
880
893
|
await this.store.schedule.loadAllSchedule();
|
|
894
|
+
this.injectScheduleResolverToQuotation();
|
|
881
895
|
this.logMethodSuccess("loadSchedules");
|
|
882
896
|
} catch (error) {
|
|
883
897
|
this.logMethodError("loadSchedules", error);
|
|
884
898
|
throw error;
|
|
885
899
|
}
|
|
886
900
|
}
|
|
901
|
+
injectScheduleResolverToQuotation() {
|
|
902
|
+
if (this.store.quotation && this.store.schedule) {
|
|
903
|
+
this.store.quotation.setScheduleResolver(
|
|
904
|
+
(id) => this.store.schedule.getScheduleListByIds([id])[0]
|
|
905
|
+
);
|
|
906
|
+
}
|
|
907
|
+
}
|
|
887
908
|
getScheduleListByIds(ids) {
|
|
888
909
|
if (!this.store.schedule)
|
|
889
910
|
return [];
|
|
@@ -949,8 +970,12 @@ var VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
949
970
|
const merged = (0, import_slotMerge.mergeConsecutiveSlots)(updatedSlots);
|
|
950
971
|
if (merged.length === 1) {
|
|
951
972
|
product.selling_price = merged[0].totalPrice;
|
|
952
|
-
product.original_price = merged[0].totalPrice;
|
|
953
973
|
product.payment_price = merged[0].totalPrice;
|
|
974
|
+
product.metadata.price_breakdown = (0, import_slotMerge.buildPriceBreakdown)({
|
|
975
|
+
group: merged[0],
|
|
976
|
+
productId: mapping.productId,
|
|
977
|
+
quotation: this.store.quotation
|
|
978
|
+
});
|
|
954
979
|
}
|
|
955
980
|
} else if (product.product_id != null) {
|
|
956
981
|
const quotationPrice = this.store.quotation.getPriceForProduct({
|
|
@@ -960,7 +985,6 @@ var VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
960
985
|
});
|
|
961
986
|
if (quotationPrice !== null) {
|
|
962
987
|
product.selling_price = quotationPrice;
|
|
963
|
-
product.original_price = quotationPrice;
|
|
964
988
|
product.payment_price = quotationPrice;
|
|
965
989
|
}
|
|
966
990
|
}
|
|
@@ -1031,9 +1055,20 @@ var VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
1031
1055
|
}
|
|
1032
1056
|
if (result == null ? void 0 : result.discountList) {
|
|
1033
1057
|
nextDiscountList = result.discountList;
|
|
1034
|
-
|
|
1058
|
+
if (!params.isSelected) {
|
|
1059
|
+
const beforeSelectedIds = new Set(
|
|
1060
|
+
updated.filter((d) => d.isSelected).map((d) => d.id)
|
|
1061
|
+
);
|
|
1062
|
+
for (const d of nextDiscountList) {
|
|
1063
|
+
if (d.isSelected && !beforeSelectedIds.has(d.id)) {
|
|
1064
|
+
d.isSelected = false;
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1035
1068
|
}
|
|
1036
1069
|
}
|
|
1070
|
+
import_Order.OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
1071
|
+
await (discountModule == null ? void 0 : discountModule.setDiscountList(nextDiscountList));
|
|
1037
1072
|
tempOrder.discount_list = (nextDiscountList || []).filter((d) => d.isSelected);
|
|
1038
1073
|
const afterApplyTarget = this.store.order.getDiscountList().find((d) => d.id === params.discountId) || null;
|
|
1039
1074
|
await this.store.order.recalculateSummary({ createIfMissing: true });
|
|
@@ -1121,7 +1156,9 @@ var VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
1121
1156
|
});
|
|
1122
1157
|
if (quotationPrice !== null) {
|
|
1123
1158
|
product.selling_price = quotationPrice;
|
|
1124
|
-
product.original_price
|
|
1159
|
+
if (product.original_price == null) {
|
|
1160
|
+
product.original_price = quotationPrice;
|
|
1161
|
+
}
|
|
1125
1162
|
product.payment_price = quotationPrice;
|
|
1126
1163
|
}
|
|
1127
1164
|
}
|
|
@@ -1178,37 +1215,11 @@ var VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
1178
1215
|
}
|
|
1179
1216
|
}
|
|
1180
1217
|
async getProductList() {
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
cachedList,
|
|
1187
|
-
this.store.itemRuleQuantityLimits || []
|
|
1188
|
-
);
|
|
1189
|
-
this.logMethodSuccess("getProductList", { fromCache: true });
|
|
1190
|
-
return formattedRes;
|
|
1191
|
-
}
|
|
1192
|
-
const menuListIds = ((_c = this.otherParams) == null ? void 0 : _c.menuListIds) || ((_f = (_e = (_d = this.otherParams) == null ? void 0 : _d.dineInConfig) == null ? void 0 : _e["menu.associated_menus"]) == null ? void 0 : _f.map((n) => Number(n.value))) || [];
|
|
1193
|
-
try {
|
|
1194
|
-
const res = await ((_g = this.store.products) == null ? void 0 : _g.loadProducts({
|
|
1195
|
-
menu_list_ids: menuListIds,
|
|
1196
|
-
cacheId: this.cacheId,
|
|
1197
|
-
schedule_date: (0, import_dayjs.default)().format("YYYY-MM-DD"),
|
|
1198
|
-
schedule_datetime: (0, import_dayjs.default)().format("YYYY-MM-DD HH:mm:ss")
|
|
1199
|
-
}));
|
|
1200
|
-
const formattedRes = (0, import_utils.attachItemRuleLimitsToTopLevelProducts)(
|
|
1201
|
-
res,
|
|
1202
|
-
this.store.itemRuleQuantityLimits || []
|
|
1203
|
-
);
|
|
1204
|
-
this.logMethodSuccess("getProductList", {
|
|
1205
|
-
menuCount: menuListIds.length
|
|
1206
|
-
});
|
|
1207
|
-
return formattedRes;
|
|
1208
|
-
} catch (error) {
|
|
1209
|
-
this.logMethodError("getProductList", error);
|
|
1210
|
-
throw error;
|
|
1211
|
-
}
|
|
1218
|
+
const result = await this.loadAllProducts();
|
|
1219
|
+
return (0, import_utils.attachItemRuleLimitsToTopLevelProducts)(
|
|
1220
|
+
result.addonProducts,
|
|
1221
|
+
this.store.itemRuleQuantityLimits || []
|
|
1222
|
+
);
|
|
1212
1223
|
}
|
|
1213
1224
|
// ─── ItemRule 引擎 ───
|
|
1214
1225
|
async loadOpenDataConfig() {
|
|
@@ -1219,7 +1230,7 @@ var VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
1219
1230
|
target: "venue_booking+online_store",
|
|
1220
1231
|
section_code: [...OPEN_DATA_SECTION_CODES]
|
|
1221
1232
|
});
|
|
1222
|
-
this.otherParams.
|
|
1233
|
+
this.otherParams.openData = openDataConfig;
|
|
1223
1234
|
return openDataConfig;
|
|
1224
1235
|
}
|
|
1225
1236
|
async loadRuntimeConfigs() {
|
|
@@ -92,6 +92,13 @@ export interface MergedSlotGroup {
|
|
|
92
92
|
slotCount: number;
|
|
93
93
|
slots: VenueSlotSelection[];
|
|
94
94
|
}
|
|
95
|
+
export interface PriceBreakdownEntry {
|
|
96
|
+
start_time: string;
|
|
97
|
+
end_time: string;
|
|
98
|
+
unit_price: number;
|
|
99
|
+
quotation_shelf_id: number;
|
|
100
|
+
quantity: number;
|
|
101
|
+
}
|
|
95
102
|
export interface VenueBookingState {
|
|
96
103
|
entryContext: VenueBookingEntryContext | null;
|
|
97
104
|
status: VenueBookingStatus;
|
|
@@ -1,7 +1,17 @@
|
|
|
1
|
-
import type { VenueSlotSelection, MergedSlotGroup, ResourceProductMapping, VenueResourceRawData } from '../types';
|
|
1
|
+
import type { VenueSlotSelection, MergedSlotGroup, PriceBreakdownEntry, ResourceProductMapping, VenueResourceRawData } from '../types';
|
|
2
2
|
import type { ScanOrderOrderProduct } from '../../ScanOrder/types';
|
|
3
3
|
export declare function buildVenueIdentityKey(resourceId: number | string, groupIndex: number): string;
|
|
4
4
|
export declare function mergeConsecutiveSlots(slots: VenueSlotSelection[]): MergedSlotGroup[];
|
|
5
|
+
export declare function buildPriceBreakdown(params: {
|
|
6
|
+
group: MergedSlotGroup;
|
|
7
|
+
productId: number;
|
|
8
|
+
quotation?: {
|
|
9
|
+
getQuotationShelfId: (p: {
|
|
10
|
+
productId: number;
|
|
11
|
+
datetime: string;
|
|
12
|
+
}) => number;
|
|
13
|
+
};
|
|
14
|
+
}): PriceBreakdownEntry[];
|
|
5
15
|
export interface BuildVenueBookingParams {
|
|
6
16
|
group: MergedSlotGroup;
|
|
7
17
|
resourceId: number | string;
|
|
@@ -13,6 +23,7 @@ export interface BuildVenueBookingParams {
|
|
|
13
23
|
export declare function buildVenueBookingEntry(params: BuildVenueBookingParams): Record<string, any>;
|
|
14
24
|
/**
|
|
15
25
|
* 从一条已合并的订单商品还原出独立的时段列表。
|
|
16
|
-
*
|
|
26
|
+
* 优先使用 metadata.price_breakdown 还原每个时段的精确价格,
|
|
27
|
+
* 回退到按 selling_price / slot_count 均分。
|
|
17
28
|
*/
|
|
18
29
|
export declare function expandMergedSlotToIndividual(product: ScanOrderOrderProduct, slotDurationMinutes: number): VenueSlotSelection[];
|
|
@@ -29,6 +29,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
29
29
|
// src/solution/VenueBooking/utils/slotMerge.ts
|
|
30
30
|
var slotMerge_exports = {};
|
|
31
31
|
__export(slotMerge_exports, {
|
|
32
|
+
buildPriceBreakdown: () => buildPriceBreakdown,
|
|
32
33
|
buildVenueBookingEntry: () => buildVenueBookingEntry,
|
|
33
34
|
buildVenueIdentityKey: () => buildVenueIdentityKey,
|
|
34
35
|
expandMergedSlotToIndividual: () => expandMergedSlotToIndividual,
|
|
@@ -79,6 +80,32 @@ function mergeConsecutiveSlots(slots) {
|
|
|
79
80
|
});
|
|
80
81
|
return groups;
|
|
81
82
|
}
|
|
83
|
+
function buildPriceBreakdown(params) {
|
|
84
|
+
const { group, productId, quotation } = params;
|
|
85
|
+
if (!group.slots.length)
|
|
86
|
+
return [];
|
|
87
|
+
const entries = [];
|
|
88
|
+
for (const slot of group.slots) {
|
|
89
|
+
const unitPrice = Number(slot.price || "0");
|
|
90
|
+
const shelfId = quotation ? quotation.getQuotationShelfId({ productId, datetime: slot.startTime }) : 0;
|
|
91
|
+
const startHm = (0, import_dayjs.default)(slot.startTime, "YYYY-MM-DD HH:mm").format("HH:mm");
|
|
92
|
+
const endHm = (0, import_dayjs.default)(slot.endTime, "YYYY-MM-DD HH:mm").format("HH:mm");
|
|
93
|
+
const last = entries[entries.length - 1];
|
|
94
|
+
if (last && last.unit_price === unitPrice && last.quotation_shelf_id === shelfId && last.end_time === startHm) {
|
|
95
|
+
last.end_time = endHm;
|
|
96
|
+
last.quantity += 1;
|
|
97
|
+
} else {
|
|
98
|
+
entries.push({
|
|
99
|
+
start_time: startHm,
|
|
100
|
+
end_time: endHm,
|
|
101
|
+
unit_price: unitPrice,
|
|
102
|
+
quotation_shelf_id: shelfId,
|
|
103
|
+
quantity: 1
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return entries;
|
|
108
|
+
}
|
|
82
109
|
function buildVenueBookingEntry(params) {
|
|
83
110
|
const { group, resourceId, mapping, rawResource, bookingUuid, productUid } = params;
|
|
84
111
|
const startMoment = (0, import_dayjs.default)(group.startTime, "YYYY-MM-DD HH:mm");
|
|
@@ -106,7 +133,7 @@ function buildVenueBookingEntry(params) {
|
|
|
106
133
|
main_field: mapping.resourceName,
|
|
107
134
|
form_id: (rawResource == null ? void 0 : rawResource.form_id) ?? mapping.formId,
|
|
108
135
|
relation_id: resourceId,
|
|
109
|
-
capacity:
|
|
136
|
+
capacity: 1,
|
|
110
137
|
metadata: {}
|
|
111
138
|
}],
|
|
112
139
|
relation_products: [],
|
|
@@ -129,26 +156,53 @@ function expandMergedSlotToIndividual(product, slotDurationMinutes) {
|
|
|
129
156
|
const endTime = meta.end_time;
|
|
130
157
|
if (!startTime || !endTime)
|
|
131
158
|
return [];
|
|
132
|
-
const
|
|
133
|
-
const
|
|
134
|
-
const perSlotPrice = slotCount > 0 ? totalPrice.div(slotCount).toFixed(2) : totalPrice.toFixed(2);
|
|
159
|
+
const breakdown = meta.price_breakdown;
|
|
160
|
+
const datePrefix = (0, import_dayjs.default)(startTime, "YYYY-MM-DD HH:mm").format("YYYY-MM-DD");
|
|
135
161
|
const result = [];
|
|
136
162
|
let cursor = (0, import_dayjs.default)(startTime, "YYYY-MM-DD HH:mm");
|
|
137
163
|
const end = (0, import_dayjs.default)(endTime, "YYYY-MM-DD HH:mm");
|
|
138
|
-
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
164
|
+
if (breakdown == null ? void 0 : breakdown.length) {
|
|
165
|
+
const priceMap = /* @__PURE__ */ new Map();
|
|
166
|
+
for (const entry of breakdown) {
|
|
167
|
+
let entryCursor = (0, import_dayjs.default)(`${datePrefix} ${entry.start_time}`, "YYYY-MM-DD HH:mm");
|
|
168
|
+
const entryEnd = (0, import_dayjs.default)(`${datePrefix} ${entry.end_time}`, "YYYY-MM-DD HH:mm");
|
|
169
|
+
while (entryCursor.isBefore(entryEnd)) {
|
|
170
|
+
priceMap.set(entryCursor.format("HH:mm"), entry.unit_price);
|
|
171
|
+
entryCursor = entryCursor.add(slotDurationMinutes, "minute");
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
while (cursor.isBefore(end)) {
|
|
175
|
+
const slotEnd = cursor.add(slotDurationMinutes, "minute");
|
|
176
|
+
const hm = cursor.format("HH:mm");
|
|
177
|
+
const price = priceMap.get(hm) ?? 0;
|
|
178
|
+
result.push({
|
|
179
|
+
resourceId,
|
|
180
|
+
startTime: cursor.format("YYYY-MM-DD HH:mm"),
|
|
181
|
+
endTime: slotEnd.format("YYYY-MM-DD HH:mm"),
|
|
182
|
+
price: new import_decimal.default(price).toFixed(2)
|
|
183
|
+
});
|
|
184
|
+
cursor = slotEnd;
|
|
185
|
+
}
|
|
186
|
+
} else {
|
|
187
|
+
const slotCount = meta.slot_count || 1;
|
|
188
|
+
const totalPrice = new import_decimal.default(product.selling_price || "0");
|
|
189
|
+
const perSlotPrice = slotCount > 0 ? totalPrice.div(slotCount).toFixed(2) : totalPrice.toFixed(2);
|
|
190
|
+
while (cursor.isBefore(end)) {
|
|
191
|
+
const slotEnd = cursor.add(slotDurationMinutes, "minute");
|
|
192
|
+
result.push({
|
|
193
|
+
resourceId,
|
|
194
|
+
startTime: cursor.format("YYYY-MM-DD HH:mm"),
|
|
195
|
+
endTime: slotEnd.format("YYYY-MM-DD HH:mm"),
|
|
196
|
+
price: perSlotPrice
|
|
197
|
+
});
|
|
198
|
+
cursor = slotEnd;
|
|
199
|
+
}
|
|
147
200
|
}
|
|
148
201
|
return result;
|
|
149
202
|
}
|
|
150
203
|
// Annotate the CommonJS export names for ESM import in node:
|
|
151
204
|
0 && (module.exports = {
|
|
205
|
+
buildPriceBreakdown,
|
|
152
206
|
buildVenueBookingEntry,
|
|
153
207
|
buildVenueIdentityKey,
|
|
154
208
|
expandMergedSlotToIndividual,
|