@pisell/pisellos 2.2.125 → 2.2.126
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/core/index.js +1 -0
- package/dist/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/server/index.d.ts +11 -0
- package/dist/server/index.js +551 -362
- package/dist/server/modules/order/index.d.ts +7 -0
- package/dist/server/modules/order/index.js +221 -151
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/lib/core/index.js +1 -0
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/server/index.d.ts +11 -0
- package/lib/server/index.js +116 -0
- package/lib/server/modules/order/index.d.ts +7 -0
- package/lib/server/modules/order/index.js +34 -0
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -136,7 +136,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
|
|
|
136
136
|
* 获取当前的客户搜索条件
|
|
137
137
|
* @returns 当前搜索条件
|
|
138
138
|
*/
|
|
139
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
139
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
|
|
140
140
|
/**
|
|
141
141
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
142
142
|
* @returns 客户状态
|
package/lib/core/index.js
CHANGED
|
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
|
|
|
49
49
|
getCategories(): ProductCategory[];
|
|
50
50
|
setOtherParams(key: string, value: any): void;
|
|
51
51
|
getOtherParams(): any;
|
|
52
|
-
getProductType(): "
|
|
52
|
+
getProductType(): "normal" | "duration" | "session";
|
|
53
53
|
}
|
package/lib/server/index.d.ts
CHANGED
|
@@ -254,6 +254,17 @@ declare class Server {
|
|
|
254
254
|
* 转发到资源模块去
|
|
255
255
|
*/
|
|
256
256
|
private handleResourceList;
|
|
257
|
+
/**
|
|
258
|
+
* 代理刷新单个本地订单:
|
|
259
|
+
* - 入参:order_id(data 或 url query)
|
|
260
|
+
* - 流程:本地存在性校验 → 调后端 /order/sales/{id}?with[]=... → 覆盖本地 → 落 SQLite → emit onOrdersChanged
|
|
261
|
+
* - 监听级联:onOrdersChanged 触发订单/预约/bookingRemoteCache 三路订阅者推送
|
|
262
|
+
*/
|
|
263
|
+
private handleUpdateLocalOrder;
|
|
264
|
+
/**
|
|
265
|
+
* 从 url 中解析指定 query 参数,兼容相对路径与绝对路径
|
|
266
|
+
*/
|
|
267
|
+
private extractQueryParam;
|
|
257
268
|
/**
|
|
258
269
|
* 从 url 或路由 path 解析 pathname(不含 query,去掉末尾 /)
|
|
259
270
|
*/
|
package/lib/server/index.js
CHANGED
|
@@ -313,6 +313,86 @@ var Server = class {
|
|
|
313
313
|
status: true
|
|
314
314
|
};
|
|
315
315
|
};
|
|
316
|
+
/**
|
|
317
|
+
* 代理刷新单个本地订单:
|
|
318
|
+
* - 入参:order_id(data 或 url query)
|
|
319
|
+
* - 流程:本地存在性校验 → 调后端 /order/sales/{id}?with[]=... → 覆盖本地 → 落 SQLite → emit onOrdersChanged
|
|
320
|
+
* - 监听级联:onOrdersChanged 触发订单/预约/bookingRemoteCache 三路订阅者推送
|
|
321
|
+
*/
|
|
322
|
+
this.handleUpdateLocalOrder = async ({ url, data }) => {
|
|
323
|
+
var _a;
|
|
324
|
+
const rawOrderId = (data && typeof data === "object" ? data.order_id : void 0) ?? this.extractQueryParam(url, "order_id");
|
|
325
|
+
const orderId = rawOrderId === void 0 || rawOrderId === null || rawOrderId === "" ? null : String(rawOrderId).trim();
|
|
326
|
+
this.logInfo("handleUpdateLocalOrder: 开始处理", { url, orderId });
|
|
327
|
+
if (!orderId) {
|
|
328
|
+
this.logWarning("handleUpdateLocalOrder: order_id 缺失", { url, data });
|
|
329
|
+
return { code: 400, status: false, message: "order_id 缺失", data: null };
|
|
330
|
+
}
|
|
331
|
+
if (!this.order) {
|
|
332
|
+
this.logError("handleUpdateLocalOrder: Order 模块未注册");
|
|
333
|
+
return { code: 500, status: false, message: "Order 模块未注册", data: null };
|
|
334
|
+
}
|
|
335
|
+
if (!this.order.getOrderByOrderId(orderId)) {
|
|
336
|
+
this.logInfo("handleUpdateLocalOrder: 本地不存在该订单,忽略", { orderId });
|
|
337
|
+
return {
|
|
338
|
+
code: 200,
|
|
339
|
+
status: true,
|
|
340
|
+
message: "本地无此订单,已忽略",
|
|
341
|
+
data: { overwritten: false }
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
if (!((_a = this.app) == null ? void 0 : _a.request)) {
|
|
345
|
+
this.logError("handleUpdateLocalOrder: app.request 不可用");
|
|
346
|
+
return { code: 500, status: false, message: "app.request 不可用", data: null };
|
|
347
|
+
}
|
|
348
|
+
const backendPath = `/shop/order/sales/${encodeURIComponent(
|
|
349
|
+
orderId
|
|
350
|
+
)}?with%5B%5D=products&with%5B%5D=scheduleEvents&with%5B%5D=customer`;
|
|
351
|
+
try {
|
|
352
|
+
const response = await this.app.request.get(backendPath, void 0, {
|
|
353
|
+
isShopApi: true
|
|
354
|
+
});
|
|
355
|
+
const fresh = (response == null ? void 0 : response.data) ?? response;
|
|
356
|
+
if (!fresh || typeof fresh !== "object" || fresh.order_id == null) {
|
|
357
|
+
this.logError("handleUpdateLocalOrder: 后端返回订单为空", {
|
|
358
|
+
orderId,
|
|
359
|
+
backendPath
|
|
360
|
+
});
|
|
361
|
+
return {
|
|
362
|
+
code: 500,
|
|
363
|
+
status: false,
|
|
364
|
+
message: "后端返回订单为空",
|
|
365
|
+
data: null
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
const { overwritten } = await this.order.overwriteExistingOrder(
|
|
369
|
+
fresh
|
|
370
|
+
);
|
|
371
|
+
this.logInfo("handleUpdateLocalOrder: 覆盖完成", {
|
|
372
|
+
orderId,
|
|
373
|
+
overwritten
|
|
374
|
+
});
|
|
375
|
+
return {
|
|
376
|
+
code: 200,
|
|
377
|
+
status: true,
|
|
378
|
+
message: "",
|
|
379
|
+
data: { overwritten, order_id: orderId }
|
|
380
|
+
};
|
|
381
|
+
} catch (error) {
|
|
382
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
383
|
+
this.logError("handleUpdateLocalOrder: 请求失败", {
|
|
384
|
+
orderId,
|
|
385
|
+
backendPath,
|
|
386
|
+
error: errorMessage
|
|
387
|
+
});
|
|
388
|
+
return {
|
|
389
|
+
code: 500,
|
|
390
|
+
status: false,
|
|
391
|
+
message: errorMessage,
|
|
392
|
+
data: null
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
};
|
|
316
396
|
/**
|
|
317
397
|
* GET /shop/schedule/floor-plan* 前缀路由:读本地 store;支持 subscriberId + callback 订阅更新
|
|
318
398
|
*/
|
|
@@ -958,6 +1038,11 @@ var Server = class {
|
|
|
958
1038
|
method: "get",
|
|
959
1039
|
path: "/shop/form/resource/page",
|
|
960
1040
|
handler: this.handleResourceList.bind(this)
|
|
1041
|
+
},
|
|
1042
|
+
{
|
|
1043
|
+
method: "get",
|
|
1044
|
+
path: "/update/localOrder",
|
|
1045
|
+
handler: this.handleUpdateLocalOrder.bind(this)
|
|
961
1046
|
}
|
|
962
1047
|
]);
|
|
963
1048
|
this.registerPrefixRoutes([
|
|
@@ -1420,6 +1505,37 @@ var Server = class {
|
|
|
1420
1505
|
};
|
|
1421
1506
|
}
|
|
1422
1507
|
}
|
|
1508
|
+
/**
|
|
1509
|
+
* 从 url 中解析指定 query 参数,兼容相对路径与绝对路径
|
|
1510
|
+
*/
|
|
1511
|
+
extractQueryParam(url, key) {
|
|
1512
|
+
if (!url)
|
|
1513
|
+
return null;
|
|
1514
|
+
try {
|
|
1515
|
+
const target = url.startsWith("http") ? new URL(url) : new URL(url, "http://placeholder.local");
|
|
1516
|
+
const value = target.searchParams.get(key);
|
|
1517
|
+
return value ?? null;
|
|
1518
|
+
} catch {
|
|
1519
|
+
const queryIndex = url.indexOf("?");
|
|
1520
|
+
if (queryIndex < 0)
|
|
1521
|
+
return null;
|
|
1522
|
+
const query = url.slice(queryIndex + 1);
|
|
1523
|
+
for (const pair of query.split("&")) {
|
|
1524
|
+
if (!pair)
|
|
1525
|
+
continue;
|
|
1526
|
+
const [rawKey, rawValue = ""] = pair.split("=");
|
|
1527
|
+
try {
|
|
1528
|
+
if (decodeURIComponent(rawKey) === key) {
|
|
1529
|
+
return decodeURIComponent(rawValue);
|
|
1530
|
+
}
|
|
1531
|
+
} catch {
|
|
1532
|
+
if (rawKey === key)
|
|
1533
|
+
return rawValue;
|
|
1534
|
+
}
|
|
1535
|
+
}
|
|
1536
|
+
return null;
|
|
1537
|
+
}
|
|
1538
|
+
}
|
|
1423
1539
|
/**
|
|
1424
1540
|
* 从 url 或路由 path 解析 pathname(不含 query,去掉末尾 /)
|
|
1425
1541
|
*/
|
|
@@ -40,6 +40,13 @@ export declare class OrderModule extends BaseModule implements Module {
|
|
|
40
40
|
getOrderByOrderId(orderId: OrderId): OrderData | undefined;
|
|
41
41
|
loadOrdersByServer(): Promise<OrderData[]>;
|
|
42
42
|
getOrdersByResourceId(resourceId: string | number): OrderData[];
|
|
43
|
+
/**
|
|
44
|
+
* 仅覆盖本地已存在的订单;不存在则直接跳过,不落库、不 emit。
|
|
45
|
+
* 适用于"按 order_id 主动刷新本地订单详情"的代理场景。
|
|
46
|
+
*/
|
|
47
|
+
overwriteExistingOrder(fresh: OrderData): Promise<{
|
|
48
|
+
overwritten: boolean;
|
|
49
|
+
}>;
|
|
43
50
|
/**
|
|
44
51
|
* 通过 SSE 按自定义 query 拉取订单(支持 select/with 精简字段)
|
|
45
52
|
*/
|
|
@@ -218,6 +218,40 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
218
218
|
const ids = this.resourceIdIndex.get(String(resourceId)) || [];
|
|
219
219
|
return ids.map((id) => this.store.map.get(id)).filter((order) => !!order);
|
|
220
220
|
}
|
|
221
|
+
/**
|
|
222
|
+
* 仅覆盖本地已存在的订单;不存在则直接跳过,不落库、不 emit。
|
|
223
|
+
* 适用于"按 order_id 主动刷新本地订单详情"的代理场景。
|
|
224
|
+
*/
|
|
225
|
+
async overwriteExistingOrder(fresh) {
|
|
226
|
+
const orderId = fresh == null ? void 0 : fresh.order_id;
|
|
227
|
+
if (orderId === void 0 || orderId === null) {
|
|
228
|
+
this.logError("overwriteExistingOrder-入参缺少 order_id");
|
|
229
|
+
return { overwritten: false };
|
|
230
|
+
}
|
|
231
|
+
const key = this.getIdKey(orderId);
|
|
232
|
+
if (!this.store.map.has(key)) {
|
|
233
|
+
this.logInfo("overwriteExistingOrder-本地不存在该订单,跳过", { orderId });
|
|
234
|
+
return { overwritten: false };
|
|
235
|
+
}
|
|
236
|
+
this.logInfo("overwriteExistingOrder-开始覆盖", {
|
|
237
|
+
orderId,
|
|
238
|
+
storeOrderCountBefore: this.store.list.length
|
|
239
|
+
});
|
|
240
|
+
this.store.list = this.store.list.map((order) => {
|
|
241
|
+
const id = order == null ? void 0 : order.order_id;
|
|
242
|
+
if (id === void 0 || id === null)
|
|
243
|
+
return order;
|
|
244
|
+
return this.getIdKey(id) === key ? fresh : order;
|
|
245
|
+
});
|
|
246
|
+
this.syncOrdersMap();
|
|
247
|
+
await this.saveOrdersToSQLite(this.store.list);
|
|
248
|
+
this.logInfo("overwriteExistingOrder-结束", {
|
|
249
|
+
orderId,
|
|
250
|
+
storeOrderCountAfter: this.store.list.length
|
|
251
|
+
});
|
|
252
|
+
await this.core.effects.emit(import_types.OrderHooks.onOrdersChanged, this.store.list);
|
|
253
|
+
return { overwritten: true };
|
|
254
|
+
}
|
|
221
255
|
/**
|
|
222
256
|
* 通过 SSE 按自定义 query 拉取订单(支持 select/with 精简字段)
|
|
223
257
|
*/
|
|
@@ -136,7 +136,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
|
|
|
136
136
|
* 获取当前的客户搜索条件
|
|
137
137
|
* @returns 当前搜索条件
|
|
138
138
|
*/
|
|
139
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
139
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
|
|
140
140
|
/**
|
|
141
141
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
142
142
|
* @returns 客户状态
|