@pisell/pisellos 2.2.171 → 2.2.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/modules/BookingContext/index.d.ts +37 -0
- package/dist/modules/BookingContext/index.js +436 -0
- package/dist/modules/BookingContext/types.d.ts +102 -0
- package/dist/modules/BookingContext/types.js +51 -0
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +16 -0
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +193 -0
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +137 -0
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +75 -0
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +215 -0
- package/dist/modules/BookingContext/utils/flexible.d.ts +28 -0
- package/dist/modules/BookingContext/utils/flexible.js +56 -0
- package/dist/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
- package/dist/modules/BookingContext/utils/formatResourceList.js +38 -0
- package/dist/modules/BookingContext/utils/index.d.ts +11 -0
- package/dist/modules/BookingContext/utils/index.js +11 -0
- package/dist/modules/BookingContext/utils/noResource.d.ts +13 -0
- package/dist/modules/BookingContext/utils/noResource.js +77 -0
- package/dist/modules/BookingContext/utils/productExtend.d.ts +72 -0
- package/dist/modules/BookingContext/utils/productExtend.js +339 -0
- package/dist/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
- package/dist/modules/BookingContext/utils/resourceErrors.js +74 -0
- package/dist/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
- package/dist/modules/BookingContext/utils/resourceSelection.js +24 -0
- package/dist/modules/BookingContext/utils/resources.d.ts +80 -0
- package/dist/modules/BookingContext/utils/resources.js +486 -0
- package/dist/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
- package/dist/modules/BookingContext/utils/serviceTimes.js +151 -0
- package/dist/modules/BookingContext/utils/timeSlices.d.ts +42 -0
- package/dist/modules/BookingContext/utils/timeSlices.js +100 -0
- package/dist/modules/Customer/index.d.ts +6 -0
- package/dist/modules/Customer/index.js +129 -83
- package/dist/modules/Customer/types.d.ts +2 -0
- package/dist/modules/Discount/index.d.ts +2 -4
- package/dist/modules/Discount/index.js +8 -93
- package/dist/modules/Discount/types.d.ts +1 -7
- package/dist/modules/Order/index.d.ts +47 -16
- package/dist/modules/Order/index.js +743 -334
- package/dist/modules/Order/types.d.ts +57 -17
- package/dist/modules/Order/types.js +2 -0
- package/dist/modules/Order/utils/manualProductDiscount.d.ts +106 -0
- package/dist/modules/Order/utils/manualProductDiscount.js +212 -0
- package/dist/modules/Order/utils.d.ts +23 -1
- package/dist/modules/Order/utils.js +139 -30
- package/dist/modules/Quotation/index.js +16 -5
- package/dist/modules/Rules/index.d.ts +4 -0
- package/dist/modules/Rules/index.js +26 -10
- package/dist/modules/SalesSummary/index.js +4 -2
- package/dist/modules/Schedule/index.js +6 -2
- package/dist/modules/index.d.ts +1 -0
- package/dist/modules/index.js +2 -1
- package/dist/server/index.js +10 -6
- package/dist/server/modules/order/utils/filterOrders.js +20 -6
- package/dist/server/modules/products/index.js +9 -8
- package/dist/server/modules/schedule/index.js +13 -6
- package/dist/solution/BaseSales/index.d.ts +65 -7
- package/dist/solution/BaseSales/index.js +1066 -315
- package/dist/solution/BaseSales/types.d.ts +53 -1
- package/dist/solution/BaseSales/types.js +3 -1
- package/dist/solution/BaseSales/utils/quotationPrice.d.ts +7 -0
- package/dist/solution/BaseSales/utils/quotationPrice.js +159 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +65 -15
- package/dist/solution/BaseSales/utils.js +46 -8
- package/dist/solution/BookingTicket/index.d.ts +134 -2
- package/dist/solution/BookingTicket/index.js +768 -175
- package/dist/solution/BookingTicket/types.d.ts +2 -0
- package/dist/solution/BookingTicket/types.js +3 -0
- package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +113 -0
- package/dist/solution/BookingTicket/utils/addProductDecision.js +346 -0
- package/dist/solution/ScanOrder/index.d.ts +9 -3
- package/dist/solution/ScanOrder/index.js +231 -128
- package/dist/solution/ScanOrder/utils.js +46 -8
- package/dist/solution/ShopDiscount/index.d.ts +0 -1
- package/dist/solution/ShopDiscount/index.js +18 -23
- package/dist/solution/VenueBooking/index.d.ts +5 -9
- package/dist/solution/VenueBooking/index.js +103 -55
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +4 -0
- package/dist/solution/VenueBooking/utils/slotMerge.js +10 -0
- package/lib/modules/BookingContext/index.d.ts +37 -0
- package/lib/modules/BookingContext/index.js +297 -0
- package/lib/modules/BookingContext/types.d.ts +102 -0
- package/lib/modules/BookingContext/types.js +34 -0
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +16 -0
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +207 -0
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +141 -0
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +75 -0
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +198 -0
- package/lib/modules/BookingContext/utils/flexible.d.ts +28 -0
- package/lib/modules/BookingContext/utils/flexible.js +80 -0
- package/lib/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
- package/lib/modules/BookingContext/utils/formatResourceList.js +50 -0
- package/lib/modules/BookingContext/utils/index.d.ts +11 -0
- package/lib/modules/BookingContext/utils/index.js +43 -0
- package/lib/modules/BookingContext/utils/noResource.d.ts +13 -0
- package/lib/modules/BookingContext/utils/noResource.js +90 -0
- package/lib/modules/BookingContext/utils/productExtend.d.ts +72 -0
- package/lib/modules/BookingContext/utils/productExtend.js +283 -0
- package/lib/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
- package/lib/modules/BookingContext/utils/resourceErrors.js +80 -0
- package/lib/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
- package/lib/modules/BookingContext/utils/resourceSelection.js +46 -0
- package/lib/modules/BookingContext/utils/resources.d.ts +80 -0
- package/lib/modules/BookingContext/utils/resources.js +377 -0
- package/lib/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
- package/lib/modules/BookingContext/utils/serviceTimes.js +162 -0
- package/lib/modules/BookingContext/utils/timeSlices.d.ts +42 -0
- package/lib/modules/BookingContext/utils/timeSlices.js +124 -0
- package/lib/modules/Customer/index.d.ts +6 -0
- package/lib/modules/Customer/index.js +26 -11
- package/lib/modules/Customer/types.d.ts +2 -0
- package/lib/modules/Discount/index.d.ts +2 -4
- package/lib/modules/Discount/index.js +8 -63
- package/lib/modules/Discount/types.d.ts +1 -7
- package/lib/modules/Order/index.d.ts +47 -16
- package/lib/modules/Order/index.js +389 -90
- package/lib/modules/Order/types.d.ts +57 -17
- package/lib/modules/Order/utils/manualProductDiscount.d.ts +106 -0
- package/lib/modules/Order/utils/manualProductDiscount.js +207 -0
- package/lib/modules/Order/utils.d.ts +23 -1
- package/lib/modules/Order/utils.js +145 -21
- package/lib/modules/Quotation/index.js +17 -6
- package/lib/modules/Rules/index.d.ts +4 -0
- package/lib/modules/Rules/index.js +22 -14
- package/lib/modules/SalesSummary/index.js +4 -2
- package/lib/modules/Schedule/index.js +3 -1
- package/lib/modules/index.d.ts +1 -0
- package/lib/modules/index.js +3 -1
- package/lib/server/index.js +2 -0
- package/lib/server/modules/order/utils/filterOrders.js +12 -4
- package/lib/server/modules/products/index.js +8 -9
- package/lib/server/modules/schedule/index.js +2 -1
- package/lib/solution/BaseSales/index.d.ts +65 -7
- package/lib/solution/BaseSales/index.js +492 -20
- package/lib/solution/BaseSales/types.d.ts +53 -1
- package/lib/solution/BaseSales/types.js +3 -1
- package/lib/solution/BaseSales/utils/quotationPrice.d.ts +7 -0
- package/lib/solution/BaseSales/utils/quotationPrice.js +201 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +70 -11
- package/lib/solution/BaseSales/utils.js +46 -6
- package/lib/solution/BookingTicket/index.d.ts +134 -2
- package/lib/solution/BookingTicket/index.js +341 -8
- package/lib/solution/BookingTicket/types.d.ts +2 -0
- package/lib/solution/BookingTicket/types.js +6 -0
- package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +113 -0
- package/lib/solution/BookingTicket/utils/addProductDecision.js +318 -0
- package/lib/solution/ScanOrder/index.d.ts +9 -3
- package/lib/solution/ScanOrder/index.js +147 -66
- package/lib/solution/ScanOrder/utils.js +46 -6
- package/lib/solution/ShopDiscount/index.d.ts +0 -1
- package/lib/solution/ShopDiscount/index.js +2 -4
- package/lib/solution/VenueBooking/index.d.ts +5 -9
- package/lib/solution/VenueBooking/index.js +50 -14
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +4 -0
- package/lib/solution/VenueBooking/utils/slotMerge.js +10 -0
- package/package.json +2 -2
|
@@ -118,6 +118,27 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
118
118
|
moduleName: "venueBooking"
|
|
119
119
|
};
|
|
120
120
|
}
|
|
121
|
+
safeStringify(value) {
|
|
122
|
+
try {
|
|
123
|
+
return JSON.stringify(value);
|
|
124
|
+
} catch {
|
|
125
|
+
return void 0;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
pickErrorMessage(error) {
|
|
129
|
+
var _a, _b, _c, _d;
|
|
130
|
+
const candidates = [
|
|
131
|
+
error.message,
|
|
132
|
+
(_a = error.data) == null ? void 0 : _a.message,
|
|
133
|
+
(_c = (_b = error.response) == null ? void 0 : _b.data) == null ? void 0 : _c.message,
|
|
134
|
+
(_d = error.error) == null ? void 0 : _d.message
|
|
135
|
+
];
|
|
136
|
+
for (const candidate of candidates) {
|
|
137
|
+
if (typeof candidate === "string" && candidate.trim())
|
|
138
|
+
return candidate;
|
|
139
|
+
}
|
|
140
|
+
return void 0;
|
|
141
|
+
}
|
|
121
142
|
serializeError(error) {
|
|
122
143
|
if (error instanceof Error) {
|
|
123
144
|
return {
|
|
@@ -126,6 +147,17 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
126
147
|
stack: error.stack
|
|
127
148
|
};
|
|
128
149
|
}
|
|
150
|
+
if (error && typeof error === "object") {
|
|
151
|
+
const raw = error;
|
|
152
|
+
const message = this.pickErrorMessage(raw) || this.safeStringify(raw) || String(error);
|
|
153
|
+
return {
|
|
154
|
+
...typeof raw.name === "string" ? { name: raw.name } : {},
|
|
155
|
+
message,
|
|
156
|
+
..."code" in raw ? { code: raw.code } : {},
|
|
157
|
+
..."status" in raw ? { status: raw.status } : {},
|
|
158
|
+
...this.safeStringify(raw) ? { raw: this.safeStringify(raw) } : {}
|
|
159
|
+
};
|
|
160
|
+
}
|
|
129
161
|
return {
|
|
130
162
|
message: String(error)
|
|
131
163
|
};
|
|
@@ -341,12 +373,14 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
341
373
|
if (targetModule) {
|
|
342
374
|
this.store[step] = targetModule;
|
|
343
375
|
const initialState = step === "salesSummary" ? {
|
|
344
|
-
// TODO(Order types): VenueBooking should read OrderState.summary instead of tempOrder.summary.
|
|
345
376
|
summary: ((_b2 = (_a2 = this.store.order) == null ? void 0 : _a2.getTempOrder()) == null ? void 0 : _b2.summary) || (0, import_utils.createEmptySummary)()
|
|
346
377
|
} : {};
|
|
347
378
|
const loggerProvider = ((_c2 = this.otherParams) == null ? void 0 : _c2.loggerProvider) || "feishu";
|
|
348
379
|
const loggerConfig = ((_d2 = this.otherParams) == null ? void 0 : _d2.loggerConfig) || {
|
|
349
|
-
feishu: {
|
|
380
|
+
feishu: {
|
|
381
|
+
webhook: "https://open.feishu.cn/open-apis/bot/v2/hook/8f069b14-9d39-4728-8f78-b56f393bfde8",
|
|
382
|
+
errorHook: "https://open.feishu.cn/open-apis/bot/v2/hook/bdefae5e-f233-4705-8688-946887d9543d"
|
|
383
|
+
}
|
|
350
384
|
};
|
|
351
385
|
this.core.registerModule(targetModule, {
|
|
352
386
|
initialState,
|
|
@@ -524,8 +558,10 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
524
558
|
throw new Error("venueProducts 模块未初始化");
|
|
525
559
|
if (!this.store.addonProducts)
|
|
526
560
|
throw new Error("addonProducts 模块未初始化");
|
|
561
|
+
await this.loadOpenDataConfig();
|
|
527
562
|
const associatedMenus = ((_b = (_a = this.otherParams) == null ? void 0 : _a.openData) == null ? void 0 : _b["menu.associated_menus"]) || [];
|
|
528
563
|
if (!associatedMenus.length) {
|
|
564
|
+
this.logMethodError("loadAllProducts", new Error("未获取到餐牌配置(menu.associated_menus),请检查 OpenData 配置"));
|
|
529
565
|
throw new Error("未获取到餐牌配置(menu.associated_menus),请检查 OpenData 配置");
|
|
530
566
|
}
|
|
531
567
|
const menuListIds = associatedMenus.map((n) => Number(n.value));
|
|
@@ -989,7 +1025,7 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
989
1025
|
form_id: (rawResource == null ? void 0 : rawResource.form_id) ?? mapping.formId,
|
|
990
1026
|
relation_id: resourceId,
|
|
991
1027
|
capacity: 1,
|
|
992
|
-
metadata: {}
|
|
1028
|
+
metadata: (0, import_slotMerge.buildVenueResourceMetadata)({ mapping, rawResource })
|
|
993
1029
|
};
|
|
994
1030
|
if (childRawResources && childRawResources.length) {
|
|
995
1031
|
resourceEntry.children = childRawResources.map((child) => ({
|
|
@@ -1435,23 +1471,23 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
1435
1471
|
throw error;
|
|
1436
1472
|
}
|
|
1437
1473
|
}
|
|
1438
|
-
async
|
|
1439
|
-
this.logMethodStart("
|
|
1474
|
+
async updateOrderProduct(params) {
|
|
1475
|
+
this.logMethodStart("updateOrderProduct", {
|
|
1440
1476
|
product_id: params.product_id,
|
|
1441
1477
|
product_variant_id: params.product_variant_id
|
|
1442
1478
|
});
|
|
1443
1479
|
try {
|
|
1444
1480
|
if (!this.store.order)
|
|
1445
1481
|
throw new Error("order 模块未初始化");
|
|
1446
|
-
const products = await this.store.order.
|
|
1482
|
+
const products = await this.store.order.updateOrderProduct(params);
|
|
1447
1483
|
await this.refreshItemRuleQuantityLimits();
|
|
1448
1484
|
await this.refreshCartValidationPassed();
|
|
1449
|
-
this.logMethodSuccess("
|
|
1485
|
+
this.logMethodSuccess("updateOrderProduct", {
|
|
1450
1486
|
productCount: products.length
|
|
1451
1487
|
});
|
|
1452
1488
|
return products;
|
|
1453
1489
|
} catch (error) {
|
|
1454
|
-
this.logMethodError("
|
|
1490
|
+
this.logMethodError("updateOrderProduct", error);
|
|
1455
1491
|
throw error;
|
|
1456
1492
|
}
|
|
1457
1493
|
}
|
|
@@ -1530,18 +1566,19 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
1530
1566
|
return cachedData;
|
|
1531
1567
|
}
|
|
1532
1568
|
if (this.loadOpenDataConfigInFlight)
|
|
1533
|
-
return this.loadOpenDataConfigInFlight;
|
|
1569
|
+
return await this.loadOpenDataConfigInFlight;
|
|
1534
1570
|
this.loadOpenDataConfigInFlight = this.store.openData.fetchOpenData({
|
|
1535
1571
|
scope: "board",
|
|
1536
1572
|
target: "venue_booking+online_store",
|
|
1537
1573
|
section_code: [...OPEN_DATA_SECTION_CODES]
|
|
1538
|
-
})
|
|
1574
|
+
});
|
|
1575
|
+
try {
|
|
1576
|
+
const openDataConfig = await this.loadOpenDataConfigInFlight;
|
|
1539
1577
|
this.otherParams.openData = openDataConfig;
|
|
1540
1578
|
return openDataConfig;
|
|
1541
|
-
}
|
|
1579
|
+
} finally {
|
|
1542
1580
|
this.loadOpenDataConfigInFlight = null;
|
|
1543
|
-
}
|
|
1544
|
-
return this.loadOpenDataConfigInFlight;
|
|
1581
|
+
}
|
|
1545
1582
|
}
|
|
1546
1583
|
async loadRuntimeConfigs() {
|
|
1547
1584
|
await this.loadOpenDataConfig();
|
|
@@ -1717,7 +1754,6 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
1717
1754
|
...targetProduct,
|
|
1718
1755
|
...delta > 0 ? { num: (0, import_utils.getSafeProductNum)(existedQuantity + delta) } : {},
|
|
1719
1756
|
metadata: { ...targetProduct.metadata || {}, item_rule_prefill: true, item_rule_id: prefillItem.ruleId },
|
|
1720
|
-
// TODO(Order types): migrate VenueBooking prefill origin runtime into tempOrder._extend.
|
|
1721
1757
|
_origin: sourceItem ? { ...targetProduct._origin || {}, ...sourceItem } : targetProduct._origin
|
|
1722
1758
|
};
|
|
1723
1759
|
if (delta > 0 || Boolean(
|
|
@@ -12,6 +12,10 @@ export declare function buildPriceBreakdown(params: {
|
|
|
12
12
|
}) => number;
|
|
13
13
|
};
|
|
14
14
|
}): PriceBreakdownEntry[];
|
|
15
|
+
export declare function buildVenueResourceMetadata(params: {
|
|
16
|
+
mapping: ResourceProductMapping;
|
|
17
|
+
rawResource: VenueResourceRawData | undefined;
|
|
18
|
+
}): Record<string, any>;
|
|
15
19
|
export interface BuildVenueBookingParams {
|
|
16
20
|
group: MergedSlotGroup;
|
|
17
21
|
resourceId: number | string;
|
|
@@ -32,6 +32,7 @@ __export(slotMerge_exports, {
|
|
|
32
32
|
buildPriceBreakdown: () => buildPriceBreakdown,
|
|
33
33
|
buildVenueBookingEntry: () => buildVenueBookingEntry,
|
|
34
34
|
buildVenueIdentityKey: () => buildVenueIdentityKey,
|
|
35
|
+
buildVenueResourceMetadata: () => buildVenueResourceMetadata,
|
|
35
36
|
expandMergedSlotToIndividual: () => expandMergedSlotToIndividual,
|
|
36
37
|
mergeConsecutiveSlots: () => mergeConsecutiveSlots
|
|
37
38
|
});
|
|
@@ -106,6 +107,14 @@ function buildPriceBreakdown(params) {
|
|
|
106
107
|
}
|
|
107
108
|
return entries;
|
|
108
109
|
}
|
|
110
|
+
function buildVenueResourceMetadata(params) {
|
|
111
|
+
const { mapping, rawResource } = params;
|
|
112
|
+
return {
|
|
113
|
+
form_name: (rawResource == null ? void 0 : rawResource.form_name) ?? "",
|
|
114
|
+
resource_name: (rawResource == null ? void 0 : rawResource.main_field) ?? mapping.resourceName ?? "",
|
|
115
|
+
combined_resource: (rawResource == null ? void 0 : rawResource.combined_resource) ?? null
|
|
116
|
+
};
|
|
117
|
+
}
|
|
109
118
|
function buildVenueBookingEntry(params) {
|
|
110
119
|
const { group, resourceId, mapping, rawResource, bookingUuid, productUid, childResources } = params;
|
|
111
120
|
const startMoment = (0, import_dayjs.default)(group.startTime, "YYYY-MM-DD HH:mm");
|
|
@@ -220,6 +229,7 @@ function expandMergedSlotToIndividual(product, slotDurationMinutes) {
|
|
|
220
229
|
buildPriceBreakdown,
|
|
221
230
|
buildVenueBookingEntry,
|
|
222
231
|
buildVenueIdentityKey,
|
|
232
|
+
buildVenueResourceMetadata,
|
|
223
233
|
expandMergedSlotToIndividual,
|
|
224
234
|
mergeConsecutiveSlots
|
|
225
235
|
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"private": false,
|
|
3
3
|
"name": "@pisell/pisellos",
|
|
4
|
-
"version": "2.2.
|
|
4
|
+
"version": "2.2.172",
|
|
5
5
|
"description": "一个可扩展的前端模块化SDK框架,支持插件系统",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"format": "prettier --write \"src/**/*.{ts,tsx,js,jsx,json,md}\"",
|
|
19
19
|
"changeset": "changeset",
|
|
20
20
|
"version": "changeset version",
|
|
21
|
-
"release": "changeset publish && npm run sync && git push",
|
|
21
|
+
"release": "changeset publish --registry=https://registry.npmjs.com/ && npm run sync && git push",
|
|
22
22
|
"example": "npx parcel-bundler examples/index.html",
|
|
23
23
|
"docs": "typedoc --out docs src/index.ts",
|
|
24
24
|
"sync": "node sync.js",
|