@pisell/pisellos 0.0.516 → 0.0.518
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/Cart/utils/cartProduct.js +1 -1
- package/dist/modules/Order/index.d.ts +1 -1
- package/dist/modules/Order/utils.js +16 -13
- package/dist/modules/ProductList/index.js +2 -1
- package/dist/modules/Quotation/index.d.ts +1 -1
- package/dist/modules/Quotation/index.js +2 -2
- package/dist/modules/Rules/index.js +1 -0
- package/dist/modules/ScanOrderLogger/index.d.ts +2 -0
- package/dist/modules/ScanOrderLogger/index.js +15 -2
- package/dist/modules/ScanOrderLogger/providers/feishu.js +45 -27
- package/dist/modules/ScanOrderLogger/types.d.ts +1 -0
- package/dist/solution/BookingByStep/index.d.ts +2 -2
- package/dist/solution/BookingByStep/index.js +2 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/ScanOrder/index.d.ts +7 -1
- package/dist/solution/ScanOrder/index.js +207 -97
- package/dist/solution/ScanOrder/utils.js +5 -5
- package/dist/solution/VenueBooking/index.d.ts +2 -0
- package/dist/solution/VenueBooking/index.js +94 -42
- package/dist/solution/VenueBooking/types.d.ts +1 -0
- package/dist/solution/VenueBooking/utils/resource.js +1 -0
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +4 -0
- package/dist/solution/VenueBooking/utils/slotMerge.js +16 -1
- package/lib/modules/Cart/utils/cartProduct.js +1 -1
- package/lib/modules/Order/index.d.ts +1 -1
- package/lib/modules/Order/utils.js +2 -13
- package/lib/modules/ProductList/index.js +2 -1
- package/lib/modules/Quotation/index.d.ts +1 -1
- package/lib/modules/Quotation/index.js +2 -2
- package/lib/modules/Rules/index.js +1 -0
- package/lib/modules/ScanOrderLogger/index.d.ts +2 -0
- package/lib/modules/ScanOrderLogger/index.js +13 -1
- package/lib/modules/ScanOrderLogger/providers/feishu.js +15 -6
- package/lib/modules/ScanOrderLogger/types.d.ts +1 -0
- package/lib/solution/BookingByStep/index.d.ts +2 -2
- package/lib/solution/BookingByStep/index.js +2 -2
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/ScanOrder/index.d.ts +7 -1
- package/lib/solution/ScanOrder/index.js +114 -28
- package/lib/solution/ScanOrder/utils.js +2 -2
- package/lib/solution/VenueBooking/index.d.ts +2 -0
- package/lib/solution/VenueBooking/index.js +45 -7
- package/lib/solution/VenueBooking/types.d.ts +1 -0
- package/lib/solution/VenueBooking/utils/resource.js +1 -0
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +4 -0
- package/lib/solution/VenueBooking/utils/slotMerge.js +13 -1
- package/package.json +1 -1
|
@@ -131,7 +131,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
|
|
|
131
131
|
* 获取当前的客户搜索条件
|
|
132
132
|
* @returns 当前搜索条件
|
|
133
133
|
*/
|
|
134
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
134
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
|
|
135
135
|
/**
|
|
136
136
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
137
137
|
* @returns 客户状态
|
|
@@ -5,6 +5,7 @@ import type { UpdateProductInOrderParams } from '../../modules/Order/types';
|
|
|
5
5
|
import type { Discount } from '../../modules/Discount/types';
|
|
6
6
|
import { type CartItemSummary, type PaxInfo, type QuantityCheckResult, type QuantityLimitResult } from '../../model/strategy/adapter/itemRule';
|
|
7
7
|
import type { StrategyConfig } from '../../model/strategy/type';
|
|
8
|
+
import type { ProductData } from '../../modules/Product/types';
|
|
8
9
|
export * from './types';
|
|
9
10
|
interface ScanOrderItemRuleRuntimeConfig {
|
|
10
11
|
strategyConfigs?: StrategyConfig[];
|
|
@@ -36,11 +37,14 @@ export declare class ScanOrderImpl extends BaseModule implements Module {
|
|
|
36
37
|
private customerLoginRefreshIdInFlight;
|
|
37
38
|
private static readonly PISELL1_LOGIN_SUCCESS;
|
|
38
39
|
private getScanOrderLoggerContext;
|
|
40
|
+
private safeStringify;
|
|
41
|
+
private pickErrorMessage;
|
|
39
42
|
private serializeError;
|
|
40
43
|
private addScanOrderLog;
|
|
41
44
|
private logMethodStart;
|
|
42
45
|
private logMethodSuccess;
|
|
43
46
|
private logMethodError;
|
|
47
|
+
private assertProductListLoaded;
|
|
44
48
|
addLog(params: ScanOrderAddLogParams): Promise<void>;
|
|
45
49
|
private normalizeCustomerId;
|
|
46
50
|
private resolveCustomerIdFromLoginPayload;
|
|
@@ -86,6 +90,8 @@ export declare class ScanOrderImpl extends BaseModule implements Module {
|
|
|
86
90
|
onCustomerLogin(params: {
|
|
87
91
|
customerId: number;
|
|
88
92
|
}): Promise<void>;
|
|
93
|
+
private findReservationRuleResource;
|
|
94
|
+
private buildScanOrderResourceMetadata;
|
|
89
95
|
private buildSubmitPayloadEnhancer;
|
|
90
96
|
submitScanOrder<T = any>(): Promise<T>;
|
|
91
97
|
addProductToOrder(product: Partial<ScanOrderOrderProduct> & ScanOrderOrderProductIdentity): Promise<ScanOrderOrderProduct[]>;
|
|
@@ -120,7 +126,7 @@ export declare class ScanOrderImpl extends BaseModule implements Module {
|
|
|
120
126
|
orderAmount: number;
|
|
121
127
|
orderItems: any[];
|
|
122
128
|
}>;
|
|
123
|
-
getProductList(): Promise<
|
|
129
|
+
getProductList(): Promise<ProductData[]>;
|
|
124
130
|
getOtherParams(): Record<string, any>;
|
|
125
131
|
setOtherParams(params: Record<string, any>, { cover }?: {
|
|
126
132
|
cover?: boolean;
|
|
@@ -89,13 +89,45 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
|
89
89
|
moduleName: "scanOrder"
|
|
90
90
|
};
|
|
91
91
|
}
|
|
92
|
+
safeStringify(value) {
|
|
93
|
+
try {
|
|
94
|
+
return JSON.stringify(value);
|
|
95
|
+
} catch {
|
|
96
|
+
return void 0;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
pickErrorMessage(error) {
|
|
100
|
+
var _a, _b, _c, _d;
|
|
101
|
+
const candidates = [
|
|
102
|
+
error.message,
|
|
103
|
+
(_a = error.data) == null ? void 0 : _a.message,
|
|
104
|
+
(_c = (_b = error.response) == null ? void 0 : _b.data) == null ? void 0 : _c.message,
|
|
105
|
+
(_d = error.error) == null ? void 0 : _d.message
|
|
106
|
+
];
|
|
107
|
+
for (const candidate of candidates) {
|
|
108
|
+
if (typeof candidate === "string" && candidate.trim())
|
|
109
|
+
return candidate;
|
|
110
|
+
}
|
|
111
|
+
return void 0;
|
|
112
|
+
}
|
|
92
113
|
serializeError(error) {
|
|
93
114
|
if (error instanceof Error) {
|
|
94
|
-
return
|
|
115
|
+
return {
|
|
95
116
|
name: error.name,
|
|
96
117
|
message: error.message,
|
|
97
118
|
stack: error.stack
|
|
98
|
-
}
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
if (error && typeof error === "object") {
|
|
122
|
+
const raw = error;
|
|
123
|
+
const message = this.pickErrorMessage(raw) || this.safeStringify(raw) || String(error);
|
|
124
|
+
return {
|
|
125
|
+
...typeof raw.name === "string" ? { name: raw.name } : {},
|
|
126
|
+
message,
|
|
127
|
+
..."code" in raw ? { code: raw.code } : {},
|
|
128
|
+
..."status" in raw ? { status: raw.status } : {},
|
|
129
|
+
...this.safeStringify(raw) ? { raw: this.safeStringify(raw) } : {}
|
|
130
|
+
};
|
|
99
131
|
}
|
|
100
132
|
return {
|
|
101
133
|
message: String(error)
|
|
@@ -155,6 +187,14 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
|
155
187
|
}
|
|
156
188
|
});
|
|
157
189
|
}
|
|
190
|
+
assertProductListLoaded(method, result, payload = {}) {
|
|
191
|
+
if (Array.isArray(result))
|
|
192
|
+
return result;
|
|
193
|
+
const error = result instanceof Error ? result : new Error("商品列表接口返回异常");
|
|
194
|
+
this.logMethodError(method, error, payload);
|
|
195
|
+
error.__scanOrderLogged = true;
|
|
196
|
+
throw error;
|
|
197
|
+
}
|
|
158
198
|
async addLog(params) {
|
|
159
199
|
await this.addScanOrderLog({
|
|
160
200
|
...params,
|
|
@@ -324,7 +364,8 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
|
324
364
|
const loggerProvider = ((_c2 = this.otherParams) == null ? void 0 : _c2.scanOrderLoggerProvider) || "feishu";
|
|
325
365
|
const loggerConfig = ((_d2 = this.otherParams) == null ? void 0 : _d2.scanOrderLoggerConfig) || {
|
|
326
366
|
feishu: {
|
|
327
|
-
webhook: "https://open.feishu.cn/open-apis/bot/v2/hook/216b3fe6-af98-424e-8706-f0471241a7ed"
|
|
367
|
+
webhook: "https://open.feishu.cn/open-apis/bot/v2/hook/216b3fe6-af98-424e-8706-f0471241a7ed",
|
|
368
|
+
errorHook: "https://open.feishu.cn/open-apis/bot/v2/hook/015b7c2a-dd3c-4c30-9898-ef0f5253111f"
|
|
328
369
|
}
|
|
329
370
|
};
|
|
330
371
|
this.core.registerModule(targetModule, {
|
|
@@ -746,6 +787,34 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
|
746
787
|
throw error;
|
|
747
788
|
}
|
|
748
789
|
}
|
|
790
|
+
findReservationRuleResource(formId) {
|
|
791
|
+
var _a;
|
|
792
|
+
if (formId == null)
|
|
793
|
+
return void 0;
|
|
794
|
+
const numericFormId = Number(formId);
|
|
795
|
+
if (!Number.isFinite(numericFormId) || numericFormId <= 0)
|
|
796
|
+
return void 0;
|
|
797
|
+
for (const product of this.enabledReservationRuleProducts) {
|
|
798
|
+
const resources = (_a = product == null ? void 0 : product.product_resource) == null ? void 0 : _a.resources;
|
|
799
|
+
if (!Array.isArray(resources))
|
|
800
|
+
continue;
|
|
801
|
+
const matched = resources.find((resource) => Number(resource == null ? void 0 : resource.id) === numericFormId);
|
|
802
|
+
if (matched)
|
|
803
|
+
return matched;
|
|
804
|
+
}
|
|
805
|
+
return void 0;
|
|
806
|
+
}
|
|
807
|
+
buildScanOrderResourceMetadata(params) {
|
|
808
|
+
const { resourceState, resourceName } = params;
|
|
809
|
+
const ruleResource = this.findReservationRuleResource(resourceState.tableFormId);
|
|
810
|
+
const combined = ruleResource == null ? void 0 : ruleResource.combined_resource;
|
|
811
|
+
const isCombined = !!(combined && combined.status === 1 && Array.isArray(combined.resource_ids));
|
|
812
|
+
return {
|
|
813
|
+
form_name: (ruleResource == null ? void 0 : ruleResource.title) ?? "",
|
|
814
|
+
resource_name: resourceName,
|
|
815
|
+
combined_resource: isCombined ? combined : null
|
|
816
|
+
};
|
|
817
|
+
}
|
|
749
818
|
// ScanOrder 提交 payload enhancer:
|
|
750
819
|
// - 给所有 booking 注入 appointment_status: 'started'(扫码点餐语义)
|
|
751
820
|
// - 给所有 booking 的 metadata 注入 resource_select_type(来自预约规则商品的 resource.type)
|
|
@@ -785,7 +854,10 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
|
785
854
|
form_id: resourceState.tableFormId,
|
|
786
855
|
relation_id: resourceState.relationId ?? resourceId,
|
|
787
856
|
capacity: resolveResourceCapacity(),
|
|
788
|
-
metadata: {
|
|
857
|
+
metadata: this.buildScanOrderResourceMetadata({
|
|
858
|
+
resourceState,
|
|
859
|
+
resourceName: mainField
|
|
860
|
+
})
|
|
789
861
|
} : void 0;
|
|
790
862
|
const ruleProductUid = ruleProduct ? (0, import_utils2.createUuidV4)() : void 0;
|
|
791
863
|
const rawCollectPax = (_b = tempOrder.metadata) == null ? void 0 : _b.collect_pax;
|
|
@@ -1426,14 +1498,17 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
|
1426
1498
|
// 通过 resource_id + 店铺配置
|
|
1427
1499
|
// hasOrderId 表示 url 上是否有 orderid,如果是的话,后续的流程会走加单
|
|
1428
1500
|
async checkResourceAvailable(resourceId, hasOrderId) {
|
|
1429
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
1501
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
1430
1502
|
this.logMethodStart("checkResourceAvailable", {
|
|
1431
1503
|
resourceId
|
|
1432
1504
|
});
|
|
1433
1505
|
try {
|
|
1434
|
-
const
|
|
1506
|
+
const businessCode = String(((_a = this.otherParams) == null ? void 0 : _a.businessCode) ?? "").trim();
|
|
1507
|
+
const channel = String(((_b = this.otherParams) == null ? void 0 : _b.channel) ?? "").trim();
|
|
1508
|
+
const openDataTarget = businessCode && channel ? `${businessCode}+${channel}` : "dine_in+scan_to_order";
|
|
1509
|
+
const openData = await ((_d = (_c = this.otherParams) == null ? void 0 : _c.getOpenData) == null ? void 0 : _d.call(_c, {
|
|
1435
1510
|
scope: "board",
|
|
1436
|
-
target:
|
|
1511
|
+
target: openDataTarget,
|
|
1437
1512
|
section_code: ["basic", "fulfillment", "reservation", "sale", "menu", "availability", "workflow"]
|
|
1438
1513
|
}));
|
|
1439
1514
|
if ((openData == null ? void 0 : openData.status) === false) {
|
|
@@ -1524,13 +1599,13 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
|
1524
1599
|
}
|
|
1525
1600
|
} else {
|
|
1526
1601
|
this.enabledReservationRuleProducts = [];
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1602
|
+
const error = loaded instanceof Error ? loaded : new Error("预约规则商品列表接口返回异常");
|
|
1603
|
+
this.logMethodError("loadReservationRuleProducts", error, {
|
|
1604
|
+
resourceId,
|
|
1605
|
+
reservationLinkIds,
|
|
1606
|
+
scheduleDate,
|
|
1607
|
+
scheduleDatetime,
|
|
1608
|
+
cacheId: this.cacheId
|
|
1534
1609
|
});
|
|
1535
1610
|
}
|
|
1536
1611
|
}
|
|
@@ -1560,16 +1635,16 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
|
1560
1635
|
table_form_id: resourceState.tableFormId,
|
|
1561
1636
|
deskmate_valid: resourceState.deskmate_valid,
|
|
1562
1637
|
table_form_record: resourceState.table_form_record,
|
|
1563
|
-
policy: (
|
|
1564
|
-
partyroom_booking: (
|
|
1638
|
+
policy: (_e = occupyDetail == null ? void 0 : occupyDetail.form_record) == null ? void 0 : _e.policy,
|
|
1639
|
+
partyroom_booking: (_f = occupyDetail == null ? void 0 : occupyDetail.form_record) == null ? void 0 : _f.partyroom_booking,
|
|
1565
1640
|
...this.store.resource.requestEntryPax !== void 0 ? { requestEntryPax: this.store.resource.requestEntryPax } : {},
|
|
1566
1641
|
...this.store.resource.requestPaxMin !== void 0 ? { requestPaxMin: this.store.resource.requestPaxMin } : {},
|
|
1567
1642
|
...this.store.resource.requestPaxMax !== void 0 ? { requestPaxMax: this.store.resource.requestPaxMax } : {}
|
|
1568
1643
|
};
|
|
1569
|
-
tempOrder.relation_id = resourceId || ((
|
|
1644
|
+
tempOrder.relation_id = resourceId || ((_g = this.otherParams) == null ? void 0 : _g.relation_id);
|
|
1570
1645
|
tempOrder.table_form_id = resourceState.tableFormId;
|
|
1571
1646
|
tempOrder.resource_id = resourceId;
|
|
1572
|
-
(
|
|
1647
|
+
(_h = this.store.order) == null ? void 0 : _h.persistTempOrder();
|
|
1573
1648
|
if (availabilityInfo.mode === "idle") {
|
|
1574
1649
|
await this.addNewOrder();
|
|
1575
1650
|
}
|
|
@@ -1577,16 +1652,16 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
|
1577
1652
|
tempOrder.order_id = resourceState.lastOrderId;
|
|
1578
1653
|
}
|
|
1579
1654
|
if (tempOrder.order_id) {
|
|
1580
|
-
const res = await ((
|
|
1581
|
-
const entryPaxNumber = (
|
|
1655
|
+
const res = await ((_i = this.store.order) == null ? void 0 : _i.getOrderInfoByRemote(tempOrder.order_id));
|
|
1656
|
+
const entryPaxNumber = (_m = (_l = (_k = (_j = res == null ? void 0 : res.data) == null ? void 0 : _j.bookings) == null ? void 0 : _k.find((p) => {
|
|
1582
1657
|
var _a2;
|
|
1583
1658
|
return (_a2 = p.metadata) == null ? void 0 : _a2.collect_pax;
|
|
1584
|
-
})) == null ? void 0 :
|
|
1659
|
+
})) == null ? void 0 : _l.metadata) == null ? void 0 : _m.collect_pax;
|
|
1585
1660
|
if (entryPaxNumber) {
|
|
1586
1661
|
await this.setEntryPaxNumber(entryPaxNumber);
|
|
1587
1662
|
}
|
|
1588
1663
|
}
|
|
1589
|
-
const lastOrderInfo = (
|
|
1664
|
+
const lastOrderInfo = (_o = (_n = this.store.order) == null ? void 0 : _n.getLastOrderInfo) == null ? void 0 : _o.call(_n);
|
|
1590
1665
|
const historicalItems = hasOrderId && Array.isArray(lastOrderInfo == null ? void 0 : lastOrderInfo.products) ? lastOrderInfo.products.reduce((acc, p) => {
|
|
1591
1666
|
if (typeof (p == null ? void 0 : p.product_id) !== "number")
|
|
1592
1667
|
return acc;
|
|
@@ -1598,7 +1673,7 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
|
1598
1673
|
return acc;
|
|
1599
1674
|
}, []) : [];
|
|
1600
1675
|
await this.setItemRuleRuntimeConfig({
|
|
1601
|
-
serviceType: (
|
|
1676
|
+
serviceType: (_p = this.otherParams) == null ? void 0 : _p.businessCode,
|
|
1602
1677
|
submissionIndex: hasOrderId ? 1 : 0,
|
|
1603
1678
|
historicalItems
|
|
1604
1679
|
});
|
|
@@ -1646,18 +1721,24 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
|
1646
1721
|
}
|
|
1647
1722
|
// 获取商品列表
|
|
1648
1723
|
async getProductList() {
|
|
1649
|
-
var _a, _b
|
|
1724
|
+
var _a, _b;
|
|
1650
1725
|
this.logMethodStart("getProductList");
|
|
1651
1726
|
const menu_list_ids = ((_b = (_a = this.otherParams) == null ? void 0 : _a.dineInConfig) == null ? void 0 : _b["menu.associated_menus"].map((n) => Number(n.value))) || [];
|
|
1652
1727
|
try {
|
|
1653
|
-
|
|
1728
|
+
if (!this.store.products)
|
|
1729
|
+
throw new Error("products 模块未初始化");
|
|
1730
|
+
const res = await this.store.products.loadProducts({
|
|
1654
1731
|
menu_list_ids,
|
|
1655
1732
|
cacheId: this.cacheId,
|
|
1656
1733
|
schedule_date: (0, import_dayjs.default)().format("YYYY-MM-DD"),
|
|
1657
1734
|
schedule_datetime: (0, import_dayjs.default)().format("YYYY-MM-DD HH:mm:ss")
|
|
1658
|
-
})
|
|
1735
|
+
});
|
|
1736
|
+
const productList = this.assertProductListLoaded("getProductList", res, {
|
|
1737
|
+
menu_list_ids,
|
|
1738
|
+
cacheId: this.cacheId
|
|
1739
|
+
});
|
|
1659
1740
|
const formattedRes = (0, import_utils.attachItemRuleLimitsToTopLevelProducts)(
|
|
1660
|
-
|
|
1741
|
+
productList,
|
|
1661
1742
|
this.store.itemRuleQuantityLimits || []
|
|
1662
1743
|
);
|
|
1663
1744
|
this.logMethodSuccess("getProductList", {
|
|
@@ -1665,7 +1746,12 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
|
1665
1746
|
});
|
|
1666
1747
|
return formattedRes;
|
|
1667
1748
|
} catch (error) {
|
|
1668
|
-
|
|
1749
|
+
if (!(error == null ? void 0 : error.__scanOrderLogged)) {
|
|
1750
|
+
this.logMethodError("getProductList", error, {
|
|
1751
|
+
menu_list_ids,
|
|
1752
|
+
cacheId: this.cacheId
|
|
1753
|
+
});
|
|
1754
|
+
}
|
|
1669
1755
|
throw error;
|
|
1670
1756
|
}
|
|
1671
1757
|
}
|
|
@@ -408,8 +408,8 @@ function normalizeOrderProduct(product) {
|
|
|
408
408
|
}
|
|
409
409
|
const normalizedBundle = (product.product_bundle || []).map((item) => ({
|
|
410
410
|
...item,
|
|
411
|
-
bundle_selling_price: item.bundle_selling_price ?? item.price ?? "0.00"
|
|
412
|
-
custom_price: item.custom_price ?? item.bundle_selling_price ?? item.price ??
|
|
411
|
+
bundle_selling_price: item.bundle_selling_price ?? item.price ?? "0.00"
|
|
412
|
+
// custom_price: item.custom_price ?? item.bundle_selling_price ?? item.price ?? '0.00',
|
|
413
413
|
}));
|
|
414
414
|
const normalizedOptions = product.product_option_item || [];
|
|
415
415
|
const optionSum = (0, import_utils.sumOptionUnitPrice)(normalizedOptions);
|
|
@@ -41,6 +41,8 @@ export declare class VenueBookingImpl extends BaseModule implements Module {
|
|
|
41
41
|
private loadOpenDataConfigInFlight;
|
|
42
42
|
private static readonly OPEN_DATA_CACHE_TTL;
|
|
43
43
|
private getLoggerContext;
|
|
44
|
+
private safeStringify;
|
|
45
|
+
private pickErrorMessage;
|
|
44
46
|
private serializeError;
|
|
45
47
|
private addVenueBookingLog;
|
|
46
48
|
private logMethodStart;
|
|
@@ -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
|
};
|
|
@@ -345,7 +377,10 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
345
377
|
} : {};
|
|
346
378
|
const loggerProvider = ((_c2 = this.otherParams) == null ? void 0 : _c2.loggerProvider) || "feishu";
|
|
347
379
|
const loggerConfig = ((_d2 = this.otherParams) == null ? void 0 : _d2.loggerConfig) || {
|
|
348
|
-
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
|
+
}
|
|
349
384
|
};
|
|
350
385
|
this.core.registerModule(targetModule, {
|
|
351
386
|
initialState,
|
|
@@ -523,8 +558,10 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
523
558
|
throw new Error("venueProducts 模块未初始化");
|
|
524
559
|
if (!this.store.addonProducts)
|
|
525
560
|
throw new Error("addonProducts 模块未初始化");
|
|
561
|
+
await this.loadOpenDataConfig();
|
|
526
562
|
const associatedMenus = ((_b = (_a = this.otherParams) == null ? void 0 : _a.openData) == null ? void 0 : _b["menu.associated_menus"]) || [];
|
|
527
563
|
if (!associatedMenus.length) {
|
|
564
|
+
this.logMethodError("loadAllProducts", new Error("未获取到餐牌配置(menu.associated_menus),请检查 OpenData 配置"));
|
|
528
565
|
throw new Error("未获取到餐牌配置(menu.associated_menus),请检查 OpenData 配置");
|
|
529
566
|
}
|
|
530
567
|
const menuListIds = associatedMenus.map((n) => Number(n.value));
|
|
@@ -988,7 +1025,7 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
988
1025
|
form_id: (rawResource == null ? void 0 : rawResource.form_id) ?? mapping.formId,
|
|
989
1026
|
relation_id: resourceId,
|
|
990
1027
|
capacity: 1,
|
|
991
|
-
metadata: {}
|
|
1028
|
+
metadata: (0, import_slotMerge.buildVenueResourceMetadata)({ mapping, rawResource })
|
|
992
1029
|
};
|
|
993
1030
|
if (childRawResources && childRawResources.length) {
|
|
994
1031
|
resourceEntry.children = childRawResources.map((child) => ({
|
|
@@ -1529,18 +1566,19 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
1529
1566
|
return cachedData;
|
|
1530
1567
|
}
|
|
1531
1568
|
if (this.loadOpenDataConfigInFlight)
|
|
1532
|
-
return this.loadOpenDataConfigInFlight;
|
|
1569
|
+
return await this.loadOpenDataConfigInFlight;
|
|
1533
1570
|
this.loadOpenDataConfigInFlight = this.store.openData.fetchOpenData({
|
|
1534
1571
|
scope: "board",
|
|
1535
1572
|
target: "venue_booking+online_store",
|
|
1536
1573
|
section_code: [...OPEN_DATA_SECTION_CODES]
|
|
1537
|
-
})
|
|
1574
|
+
});
|
|
1575
|
+
try {
|
|
1576
|
+
const openDataConfig = await this.loadOpenDataConfigInFlight;
|
|
1538
1577
|
this.otherParams.openData = openDataConfig;
|
|
1539
1578
|
return openDataConfig;
|
|
1540
|
-
}
|
|
1579
|
+
} finally {
|
|
1541
1580
|
this.loadOpenDataConfigInFlight = null;
|
|
1542
|
-
}
|
|
1543
|
-
return this.loadOpenDataConfigInFlight;
|
|
1581
|
+
}
|
|
1544
1582
|
}
|
|
1545
1583
|
async loadRuntimeConfigs() {
|
|
1546
1584
|
await this.loadOpenDataConfig();
|
|
@@ -25,6 +25,10 @@ export interface BuildVenueBookingParams {
|
|
|
25
25
|
*/
|
|
26
26
|
childResources?: VenueResourceRawData[];
|
|
27
27
|
}
|
|
28
|
+
export declare function buildVenueResourceMetadata(params: {
|
|
29
|
+
mapping: ResourceProductMapping;
|
|
30
|
+
rawResource: VenueResourceRawData | undefined;
|
|
31
|
+
}): Record<string, any>;
|
|
28
32
|
export declare function buildVenueBookingEntry(params: BuildVenueBookingParams): Record<string, any>;
|
|
29
33
|
/**
|
|
30
34
|
* 从一条已合并的订单商品还原出独立的时段列表。
|
|
@@ -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,16 @@ function buildPriceBreakdown(params) {
|
|
|
106
107
|
}
|
|
107
108
|
return entries;
|
|
108
109
|
}
|
|
110
|
+
function buildVenueResourceMetadata(params) {
|
|
111
|
+
const { mapping, rawResource } = params;
|
|
112
|
+
const combined = rawResource == null ? void 0 : rawResource.combined_resource;
|
|
113
|
+
const isCombined = !!(combined && combined.status === 1 && Array.isArray(combined.resource_ids));
|
|
114
|
+
return {
|
|
115
|
+
form_name: mapping.formName ?? mapping.resourceName,
|
|
116
|
+
resource_name: (rawResource == null ? void 0 : rawResource.main_field) ?? mapping.resourceName,
|
|
117
|
+
combined_resource: isCombined ? combined : null
|
|
118
|
+
};
|
|
119
|
+
}
|
|
109
120
|
function buildVenueBookingEntry(params) {
|
|
110
121
|
const { group, resourceId, mapping, rawResource, bookingUuid, productUid, childResources } = params;
|
|
111
122
|
const startMoment = (0, import_dayjs.default)(group.startTime, "YYYY-MM-DD HH:mm");
|
|
@@ -119,7 +130,7 @@ function buildVenueBookingEntry(params) {
|
|
|
119
130
|
form_id: (rawResource == null ? void 0 : rawResource.form_id) ?? mapping.formId,
|
|
120
131
|
relation_id: resourceId,
|
|
121
132
|
capacity: 1,
|
|
122
|
-
metadata: {}
|
|
133
|
+
metadata: buildVenueResourceMetadata({ mapping, rawResource })
|
|
123
134
|
};
|
|
124
135
|
if (childResources && childResources.length) {
|
|
125
136
|
resourceEntry.children = childResources.map((child) => ({
|
|
@@ -220,6 +231,7 @@ function expandMergedSlotToIndividual(product, slotDurationMinutes) {
|
|
|
220
231
|
buildPriceBreakdown,
|
|
221
232
|
buildVenueBookingEntry,
|
|
222
233
|
buildVenueIdentityKey,
|
|
234
|
+
buildVenueResourceMetadata,
|
|
223
235
|
expandMergedSlotToIndividual,
|
|
224
236
|
mergeConsecutiveSlots
|
|
225
237
|
});
|