@pisell/pisellos 2.2.250 → 2.2.251
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 +9 -0
- package/dist/modules/Order/index.d.ts +1 -1
- package/dist/modules/Order/index.js +22 -21
- package/dist/modules/Order/types.d.ts +5 -0
- package/dist/server/index.d.ts +21 -0
- package/dist/server/index.js +29 -3
- package/dist/server/modules/order/index.js +1 -1
- package/dist/server/modules/order/types.d.ts +3 -0
- package/dist/server/modules/order/utils/filterBookings.js +8 -1
- package/dist/server/utils/small-ticket.d.ts +0 -1
- package/dist/server/utils/small-ticket.js +12 -15
- package/dist/solution/BaseSales/index.js +42 -30
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.js +3 -4
- 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 +5 -6
- package/lib/modules/Order/types.d.ts +5 -0
- package/lib/server/index.d.ts +21 -0
- package/lib/server/index.js +22 -1
- package/lib/server/modules/order/index.js +10 -1
- package/lib/server/modules/order/types.d.ts +3 -0
- package/lib/server/modules/order/utils/filterBookings.js +6 -1
- package/lib/server/utils/small-ticket.d.ts +0 -1
- package/lib/server/utils/small-ticket.js +3 -6
- package/lib/solution/BaseSales/index.js +11 -7
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.js +0 -1
- package/package.json +1 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// 导出评估器
|
|
2
|
+
export { PromotionEvaluator } from "./evaluator";
|
|
3
|
+
|
|
4
|
+
// 导出适配器
|
|
5
|
+
export { PromotionAdapter } from "./adapter";
|
|
6
|
+
export { default } from "./adapter";
|
|
7
|
+
|
|
8
|
+
// 导出策略配置示例常量
|
|
9
|
+
export { X_ITEMS_FOR_Y_PRICE_STRATEGY, BUY_X_GET_Y_FREE_STRATEGY } from "./examples";
|
|
@@ -429,7 +429,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
429
429
|
generateIdempotencyToken(): string;
|
|
430
430
|
syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
|
|
431
431
|
createOrder(params: CommitOrderParams['query']): {
|
|
432
|
-
type: "
|
|
432
|
+
type: "appointment_booking" | "virtual";
|
|
433
433
|
platform: string;
|
|
434
434
|
sales_channel: string;
|
|
435
435
|
order_sales_channel: string;
|
|
@@ -1369,15 +1369,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1369
1369
|
if (normalizedStatus !== 'refunded' && normalizedStatus !== 'partially_refunded') {
|
|
1370
1370
|
return false;
|
|
1371
1371
|
}
|
|
1372
|
-
if (params.refundAmount.lte(0)) return false;
|
|
1373
1372
|
if (params.previousSummary) {
|
|
1374
1373
|
var previousTargetAmount = this.calculatePaymentTargetAmount(params.tempOrder, params.previousSummary, params.netPaymentTotal);
|
|
1375
1374
|
if (!previousTargetAmount.eq(params.targetAmount)) return false;
|
|
1376
1375
|
}
|
|
1377
|
-
|
|
1378
|
-
return params.refundAmount.gte(params.paymentTotal);
|
|
1379
|
-
}
|
|
1380
|
-
return params.netPaymentTotal.gte(params.targetAmount);
|
|
1376
|
+
return true;
|
|
1381
1377
|
}
|
|
1382
1378
|
}, {
|
|
1383
1379
|
key: "resolveWalletPassUseValue",
|
|
@@ -3418,45 +3414,46 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3418
3414
|
while (1) switch (_context19.prev = _context19.next) {
|
|
3419
3415
|
case 0:
|
|
3420
3416
|
tempOrder = this.ensureTempOrder();
|
|
3417
|
+
debugger;
|
|
3421
3418
|
if (!booking) {
|
|
3422
|
-
_context19.next =
|
|
3419
|
+
_context19.next = 19;
|
|
3423
3420
|
break;
|
|
3424
3421
|
}
|
|
3425
3422
|
productRecord = product;
|
|
3426
3423
|
splitCount = getSafeProductNum((_ref60 = (_productRecord$num = productRecord.num) !== null && _productRecord$num !== void 0 ? _productRecord$num : productRecord.product_quantity) !== null && _ref60 !== void 0 ? _ref60 : 1);
|
|
3427
3424
|
if (!(splitCount > 1)) {
|
|
3428
|
-
_context19.next =
|
|
3425
|
+
_context19.next = 19;
|
|
3429
3426
|
break;
|
|
3430
3427
|
}
|
|
3431
3428
|
i = 0;
|
|
3432
|
-
case
|
|
3429
|
+
case 7:
|
|
3433
3430
|
if (!(i < splitCount)) {
|
|
3434
|
-
_context19.next =
|
|
3431
|
+
_context19.next = 16;
|
|
3435
3432
|
break;
|
|
3436
3433
|
}
|
|
3437
3434
|
singleLine = cloneDeep(productRecord);
|
|
3438
3435
|
singleLine.num = 1;
|
|
3439
3436
|
delete singleLine.product_quantity;
|
|
3440
|
-
_context19.next =
|
|
3437
|
+
_context19.next = 13;
|
|
3441
3438
|
return this.appendProductLineToTempOrder(tempOrder, singleLine, cloneDeep(booking));
|
|
3442
|
-
case
|
|
3439
|
+
case 13:
|
|
3443
3440
|
i += 1;
|
|
3444
|
-
_context19.next =
|
|
3441
|
+
_context19.next = 7;
|
|
3445
3442
|
break;
|
|
3446
|
-
case
|
|
3447
|
-
_context19.next =
|
|
3443
|
+
case 16:
|
|
3444
|
+
_context19.next = 18;
|
|
3448
3445
|
return this.finalizeProductOrderMutation(tempOrder);
|
|
3449
|
-
case 17:
|
|
3450
|
-
return _context19.abrupt("return", tempOrder.products);
|
|
3451
3446
|
case 18:
|
|
3452
|
-
_context19.
|
|
3447
|
+
return _context19.abrupt("return", tempOrder.products);
|
|
3448
|
+
case 19:
|
|
3449
|
+
_context19.next = 21;
|
|
3453
3450
|
return this.appendProductLineToTempOrder(tempOrder, product, booking);
|
|
3454
|
-
case
|
|
3455
|
-
_context19.next =
|
|
3451
|
+
case 21:
|
|
3452
|
+
_context19.next = 23;
|
|
3456
3453
|
return this.finalizeProductOrderMutation(tempOrder);
|
|
3457
|
-
case 22:
|
|
3458
|
-
return _context19.abrupt("return", tempOrder.products);
|
|
3459
3454
|
case 23:
|
|
3455
|
+
return _context19.abrupt("return", tempOrder.products);
|
|
3456
|
+
case 24:
|
|
3460
3457
|
case "end":
|
|
3461
3458
|
return _context19.stop();
|
|
3462
3459
|
}
|
|
@@ -5068,6 +5065,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5068
5065
|
value: function normalizeTempOrderForRuntime(raw, options) {
|
|
5069
5066
|
var _this24 = this;
|
|
5070
5067
|
var nextTempOrder = _objectSpread(_objectSpread({}, this.createDefaultTempOrderInstance()), raw || {});
|
|
5068
|
+
// ES 列表详情使用 id 表示订单主键;OS 详情态统一依赖 order_id 驱动操作按钮。
|
|
5069
|
+
if ((nextTempOrder.order_id === undefined || nextTempOrder.order_id === null) && (raw === null || raw === void 0 ? void 0 : raw.id) !== undefined && (raw === null || raw === void 0 ? void 0 : raw.id) !== null) {
|
|
5070
|
+
nextTempOrder.order_id = raw.id;
|
|
5071
|
+
}
|
|
5071
5072
|
delete nextTempOrder.summary;
|
|
5072
5073
|
delete nextTempOrder.lastOrderInfo;
|
|
5073
5074
|
delete nextTempOrder.discount_list;
|
|
@@ -518,6 +518,11 @@ export interface LoadSalesDetailParams {
|
|
|
518
518
|
orderNumber?: string;
|
|
519
519
|
externalSaleNumber?: string;
|
|
520
520
|
external_sale_number?: string;
|
|
521
|
+
/**
|
|
522
|
+
* 已由调用方查询到的销售详情记录。
|
|
523
|
+
* 存在时 loadSalesDetail 会跳过远端 lookup,直接复用 hydrate 后半段逻辑。
|
|
524
|
+
*/
|
|
525
|
+
preloadedSalesDetail?: Record<string, any>;
|
|
521
526
|
forceRemote?: boolean;
|
|
522
527
|
merge?: boolean;
|
|
523
528
|
}
|
package/dist/server/index.d.ts
CHANGED
|
@@ -9,6 +9,20 @@ import { PisellCore, ServerModuleConfig, InitializeServerOptions } from '../type
|
|
|
9
9
|
import type { RouteHandler, HttpMethod, RouteDefinition, Router, ModuleRegistryConfig, RequestSetting } from './types';
|
|
10
10
|
import { OrderModule } from './modules/order';
|
|
11
11
|
export type { RouteHandler, HttpMethod, RouteDefinition, Router, ModuleRegistryConfig, };
|
|
12
|
+
/** Server 运行时诊断快照,用于排查订阅者是否持续增长。 */
|
|
13
|
+
export interface ServerDiagnosticsSnapshot {
|
|
14
|
+
subscribers: {
|
|
15
|
+
productQuerySubscribers: number;
|
|
16
|
+
orderQuerySubscribers: number;
|
|
17
|
+
bookingQuerySubscribers: number;
|
|
18
|
+
bookingRemoteQuerySubscribers: number;
|
|
19
|
+
salesSearchSubscribers: number;
|
|
20
|
+
floorPlanQuerySubscribers: number;
|
|
21
|
+
};
|
|
22
|
+
caches: {
|
|
23
|
+
bookingRemoteCache: number;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
12
26
|
/**
|
|
13
27
|
* Server 类
|
|
14
28
|
* 用于注册和管理服务端模块
|
|
@@ -44,6 +58,13 @@ declare class Server {
|
|
|
44
58
|
private floorPlanQuerySubscribers;
|
|
45
59
|
private moduleRegistry;
|
|
46
60
|
constructor(core: PisellCore);
|
|
61
|
+
/**
|
|
62
|
+
* 获取 Server 内部订阅者和缓存数量快照。
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* const snapshot = pisellos.server?.getDiagnosticsSnapshot?.();
|
|
66
|
+
*/
|
|
67
|
+
getDiagnosticsSnapshot(): ServerDiagnosticsSnapshot;
|
|
47
68
|
/**
|
|
48
69
|
* 注册路由
|
|
49
70
|
* @param routes 路由定义数组
|
package/dist/server/index.js
CHANGED
|
@@ -49,6 +49,8 @@ import { buildSmallTicketData, hasSmallTicketData } from "./utils/small-ticket";
|
|
|
49
49
|
|
|
50
50
|
/** 非当天(远端)预约查询订阅者 */
|
|
51
51
|
|
|
52
|
+
/** Server 运行时诊断快照,用于排查订阅者是否持续增长。 */
|
|
53
|
+
|
|
52
54
|
/** 平面图 GET 查询订阅者(列表 / id 详情 / code 详情) */
|
|
53
55
|
|
|
54
56
|
var PRODUCT_TITLE_SNAPSHOT_KEYS = ['en', 'ja', 'pt', 'auto', 'zh-CN', 'zh-HK', 'kitchen', 'original'];
|
|
@@ -1236,7 +1238,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
1236
1238
|
url = _ref44.url, data = _ref44.data, config = _ref44.config, routePath = _ref44.path;
|
|
1237
1239
|
base = '/shop/schedule/floor-plan';
|
|
1238
1240
|
path = _this.parseRequestPath(url, routePath);
|
|
1239
|
-
if (!(path === "".concat(base, "/unsubscribe"))) {
|
|
1241
|
+
if (!(path === "".concat(base, "/unsubscribe") || path === "".concat(base, "/code/unsubscribe"))) {
|
|
1240
1242
|
_context18.next = 7;
|
|
1241
1243
|
break;
|
|
1242
1244
|
}
|
|
@@ -1477,10 +1479,34 @@ var Server = /*#__PURE__*/function () {
|
|
|
1477
1479
|
}
|
|
1478
1480
|
|
|
1479
1481
|
/**
|
|
1480
|
-
*
|
|
1481
|
-
*
|
|
1482
|
+
* 获取 Server 内部订阅者和缓存数量快照。
|
|
1483
|
+
*
|
|
1484
|
+
* @example
|
|
1485
|
+
* const snapshot = pisellos.server?.getDiagnosticsSnapshot?.();
|
|
1482
1486
|
*/
|
|
1483
1487
|
_createClass(Server, [{
|
|
1488
|
+
key: "getDiagnosticsSnapshot",
|
|
1489
|
+
value: function getDiagnosticsSnapshot() {
|
|
1490
|
+
return {
|
|
1491
|
+
subscribers: {
|
|
1492
|
+
productQuerySubscribers: this.productQuerySubscribers.size,
|
|
1493
|
+
orderQuerySubscribers: this.orderQuerySubscribers.size,
|
|
1494
|
+
bookingQuerySubscribers: this.bookingQuerySubscribers.size,
|
|
1495
|
+
bookingRemoteQuerySubscribers: this.bookingRemoteQuerySubscribers.size,
|
|
1496
|
+
salesSearchSubscribers: this.salesSearchSubscribers.size,
|
|
1497
|
+
floorPlanQuerySubscribers: this.floorPlanQuerySubscribers.size
|
|
1498
|
+
},
|
|
1499
|
+
caches: {
|
|
1500
|
+
bookingRemoteCache: this.bookingRemoteCache.size
|
|
1501
|
+
}
|
|
1502
|
+
};
|
|
1503
|
+
}
|
|
1504
|
+
|
|
1505
|
+
/**
|
|
1506
|
+
* 注册路由
|
|
1507
|
+
* @param routes 路由定义数组
|
|
1508
|
+
*/
|
|
1509
|
+
}, {
|
|
1484
1510
|
key: "registerRoutes",
|
|
1485
1511
|
value: function registerRoutes(routes) {
|
|
1486
1512
|
var _this2 = this;
|
|
@@ -2037,7 +2037,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2037
2037
|
var secondary = preferred === existing ? incoming : existing;
|
|
2038
2038
|
var merged = _objectSpread(_objectSpread({}, secondary), preferred);
|
|
2039
2039
|
var fieldsToPreserve = ['order_id', 'external_sale_number', 'order_number', 'shop_order_number', 'shop_full_order_number'];
|
|
2040
|
-
var incomingPatchFields = ['payment_status', 'status', 'shipping_status', 'updated_at', 'shop_discount', 'summary', 'products', 'bookings'];
|
|
2040
|
+
var incomingPatchFields = ['payment_status', 'status', 'shipping_status', 'updated_at', 'shop_discount', 'summary', 'products', 'bookings', 'note', 'customer_id', 'customer_name', 'customer', 'holder', 'contacts_info', 'phone', 'email', 'relation_forms'];
|
|
2041
2041
|
var mergedRecord = merged;
|
|
2042
2042
|
var preferredRecord = preferred;
|
|
2043
2043
|
var secondaryRecord = secondary;
|
|
@@ -458,7 +458,10 @@ export interface OrderFilters {
|
|
|
458
458
|
* 预约展开列表筛选条件(订单级条件匹配 booking.order.*,预约级匹配 booking 自身)
|
|
459
459
|
*/
|
|
460
460
|
export interface BookingFilters {
|
|
461
|
+
/** RecordBoard 通用搜索字段(单数),用于本地预约过滤 */
|
|
461
462
|
keyword?: string;
|
|
463
|
+
/** `/shop/schedule/booking` 后端协议搜索字段(复数),OS Server 需兼容 */
|
|
464
|
+
keywords?: string;
|
|
462
465
|
order_by?: string;
|
|
463
466
|
order_payment_status?: string[];
|
|
464
467
|
order_status?: string[];
|
|
@@ -97,9 +97,16 @@ function parseNumberRange(range) {
|
|
|
97
97
|
// 供 matchOrder、matchBooking 复用,避免重复计算
|
|
98
98
|
// ─────────────────────────────────────────────────────────────────
|
|
99
99
|
|
|
100
|
+
/** 预约列表搜索兼容前端通用 `keyword` 与后端协议 `keywords` 两种字段 */
|
|
101
|
+
function resolveBookingKeyword(f) {
|
|
102
|
+
var _f$keyword;
|
|
103
|
+
var keyword = (_f$keyword = f.keyword) !== null && _f$keyword !== void 0 ? _f$keyword : f.keywords;
|
|
104
|
+
return typeof keyword === 'string' ? keyword.trim() : '';
|
|
105
|
+
}
|
|
100
106
|
function prepareFilters(f) {
|
|
101
107
|
var _f$order_payment_stat, _f$order_status, _f$order_sales_channe, _f$payment_method, _f$appointment_status, _f$form_record_ids;
|
|
102
108
|
var hasCustomerId = f.customer_id !== undefined && f.customer_id !== null;
|
|
109
|
+
var keyword = resolveBookingKeyword(f);
|
|
103
110
|
return {
|
|
104
111
|
orderPaymentStatusSet: (_f$order_payment_stat = f.order_payment_status) !== null && _f$order_payment_stat !== void 0 && _f$order_payment_stat.length ? new Set(f.order_payment_status) : null,
|
|
105
112
|
orderStatusSet: (_f$order_status = f.order_status) !== null && _f$order_status !== void 0 && _f$order_status.length ? new Set(f.order_status) : null,
|
|
@@ -116,7 +123,7 @@ function prepareFilters(f) {
|
|
|
116
123
|
updatedAtRange: parseDateRange(f.updated_at_between),
|
|
117
124
|
numberRange: parseNumberRange(f.number_between),
|
|
118
125
|
totalAmountRange: Array.isArray(f.total_amount_between) && f.total_amount_between.length === 2 ? f.total_amount_between : null,
|
|
119
|
-
keywordLower:
|
|
126
|
+
keywordLower: keyword ? keyword.toLowerCase() : '',
|
|
120
127
|
afterExecutionTimeMs: function () {
|
|
121
128
|
var raw = f.after_execution_time;
|
|
122
129
|
if (raw === undefined || raw === null || raw === '') return null;
|
|
@@ -213,22 +213,14 @@ function buildProducts(order, locale, productMap) {
|
|
|
213
213
|
quantity: quantity,
|
|
214
214
|
originalPrice: originalPrice
|
|
215
215
|
});
|
|
216
|
-
|
|
217
|
-
product: product,
|
|
218
|
-
locale: locale,
|
|
219
|
-
currencySymbol: currencySymbol,
|
|
220
|
-
quantity: quantity
|
|
221
|
-
});
|
|
222
|
-
return _objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
216
|
+
return _objectSpread(_objectSpread(_objectSpread({
|
|
223
217
|
product_title: productTitle,
|
|
224
218
|
product_quantity: quantity,
|
|
225
219
|
selling_price: formatMoney(sellingPrice, currencySymbol),
|
|
226
220
|
original_price: formatMoney(originalPrice, currencySymbol),
|
|
227
221
|
total_original_price: formatMoney(new Decimal(toMoneyNumber(originalPrice)).mul(quantity), currencySymbol),
|
|
228
222
|
extension_list: extensionList
|
|
229
|
-
},
|
|
230
|
-
discount_list: discountList
|
|
231
|
-
} : {}), options.length ? {
|
|
223
|
+
}, options.length ? {
|
|
232
224
|
options: options
|
|
233
225
|
} : {}), resolvedVariant ? {
|
|
234
226
|
variant: resolvedVariant
|
|
@@ -249,12 +241,10 @@ function normalizeProductDiscounts(params) {
|
|
|
249
241
|
var title = resolveDiscountTitleWithPercent(discount, locale);
|
|
250
242
|
var amount = (_ref8 = (_discount$amount = discount.amount) !== null && _discount$amount !== void 0 ? _discount$amount : discount.value) !== null && _ref8 !== void 0 ? _ref8 : discount.discount_amount;
|
|
251
243
|
var formattedAmount = formatNegativeMoney(new Decimal(toMoneyNumber(amount)).mul(quantity), currencySymbol);
|
|
252
|
-
return
|
|
244
|
+
return {
|
|
253
245
|
item: title,
|
|
254
|
-
name: title,
|
|
255
|
-
title: title,
|
|
256
246
|
value: formattedAmount
|
|
257
|
-
}
|
|
247
|
+
};
|
|
258
248
|
});
|
|
259
249
|
}
|
|
260
250
|
function buildProductExtensionList(params) {
|
|
@@ -263,6 +253,12 @@ function buildProductExtensionList(params) {
|
|
|
263
253
|
currencySymbol = params.currencySymbol,
|
|
264
254
|
quantity = params.quantity,
|
|
265
255
|
originalPrice = params.originalPrice;
|
|
256
|
+
var discountList = normalizeProductDiscounts({
|
|
257
|
+
product: product,
|
|
258
|
+
locale: locale,
|
|
259
|
+
currencySymbol: currencySymbol,
|
|
260
|
+
quantity: quantity
|
|
261
|
+
});
|
|
266
262
|
var extensionList = [].concat(_toConsumableArray(buildProductOpenWeightRows({
|
|
267
263
|
product: product,
|
|
268
264
|
locale: locale,
|
|
@@ -275,7 +271,8 @@ function buildProductExtensionList(params) {
|
|
|
275
271
|
}),
|
|
276
272
|
value: ''
|
|
277
273
|
}] : []));
|
|
278
|
-
|
|
274
|
+
var productExtensionList = extensionList.length ? extensionList : normalizeArray(product.extension_list);
|
|
275
|
+
return [].concat(_toConsumableArray(productExtensionList), _toConsumableArray(discountList));
|
|
279
276
|
}
|
|
280
277
|
function buildProductOpenWeightRows(params) {
|
|
281
278
|
var _productSku$unit, _productSku$net_weigh, _productSku$unit_pric;
|
|
@@ -786,8 +786,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
786
786
|
key: "loadSalesDetail",
|
|
787
787
|
value: (function () {
|
|
788
788
|
var _loadSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(orderIdOrParams) {
|
|
789
|
-
var _ref11, _params$orderId;
|
|
790
|
-
var params, externalSaleNumber, lookup,
|
|
789
|
+
var _ref11, _ref12, _ref13, _ref14, _params$orderId;
|
|
790
|
+
var params, externalSaleNumber, preloadedSalesDetail, lookup, loadedRecord, message, remoteRecord, currentTempOrder, record, sales;
|
|
791
791
|
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
792
792
|
while (1) switch (_context7.prev = _context7.next) {
|
|
793
793
|
case 0:
|
|
@@ -801,43 +801,55 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
801
801
|
orderId: orderIdOrParams
|
|
802
802
|
};
|
|
803
803
|
externalSaleNumber = params.externalSaleNumber || params.external_sale_number;
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
804
|
+
preloadedSalesDetail = params.preloadedSalesDetail;
|
|
805
|
+
lookup = (_ref11 = (_ref12 = (_ref13 = (_ref14 = (_params$orderId = params.orderId) !== null && _params$orderId !== void 0 ? _params$orderId : externalSaleNumber) !== null && _ref14 !== void 0 ? _ref14 : params.orderNumber) !== null && _ref13 !== void 0 ? _ref13 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.order_id) !== null && _ref12 !== void 0 ? _ref12 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.external_sale_number) !== null && _ref11 !== void 0 ? _ref11 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.order_number;
|
|
806
|
+
if (!(!preloadedSalesDetail && (lookup === undefined || lookup === null || lookup === ''))) {
|
|
807
|
+
_context7.next = 8;
|
|
807
808
|
break;
|
|
808
809
|
}
|
|
809
810
|
throw new Error('加载销售详情需要 orderId、externalSaleNumber 或 orderNumber');
|
|
810
|
-
case
|
|
811
|
-
|
|
811
|
+
case 8:
|
|
812
|
+
if (!(preloadedSalesDetail !== null && preloadedSalesDetail !== void 0)) {
|
|
813
|
+
_context7.next = 12;
|
|
814
|
+
break;
|
|
815
|
+
}
|
|
816
|
+
_context7.t0 = preloadedSalesDetail;
|
|
817
|
+
_context7.next = 15;
|
|
818
|
+
break;
|
|
819
|
+
case 12:
|
|
820
|
+
_context7.next = 14;
|
|
812
821
|
return this.store.order.getSalesOrderByLookup({
|
|
813
822
|
lookup: lookup,
|
|
814
823
|
forceRemote: params.forceRemote
|
|
815
824
|
});
|
|
816
|
-
case
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
825
|
+
case 14:
|
|
826
|
+
_context7.t0 = _context7.sent;
|
|
827
|
+
case 15:
|
|
828
|
+
loadedRecord = _context7.t0;
|
|
829
|
+
if (!(!preloadedSalesDetail && (!loadedRecord || loadedRecord.code !== 200))) {
|
|
830
|
+
_context7.next = 19;
|
|
820
831
|
break;
|
|
821
832
|
}
|
|
822
|
-
message =
|
|
833
|
+
message = loadedRecord && (loadedRecord.message || loadedRecord.msg) || "\u52A0\u8F7D\u9500\u552E\u8BE6\u60C5\u5931\u8D25: ".concat(lookup);
|
|
823
834
|
throw new Error(message);
|
|
824
|
-
case
|
|
835
|
+
case 19:
|
|
836
|
+
remoteRecord = preloadedSalesDetail !== null && preloadedSalesDetail !== void 0 ? preloadedSalesDetail : loadedRecord.data;
|
|
825
837
|
currentTempOrder = params.merge ? this.store.order.getTempOrder() : null;
|
|
826
|
-
record = params.merge ? mergeSalesDetailRecordWithTempOrder(currentTempOrder,
|
|
827
|
-
_context7.next =
|
|
838
|
+
record = params.merge ? mergeSalesDetailRecordWithTempOrder(currentTempOrder, remoteRecord) : remoteRecord;
|
|
839
|
+
_context7.next = 24;
|
|
828
840
|
return this.store.order.hydrateTempOrderFromRecord(record, {
|
|
829
841
|
recalcOnHydrate: false
|
|
830
842
|
});
|
|
831
|
-
case
|
|
843
|
+
case 24:
|
|
832
844
|
sales = _context7.sent;
|
|
833
845
|
this.currentSalesDetail = sales;
|
|
834
|
-
_context7.next =
|
|
846
|
+
_context7.next = 28;
|
|
835
847
|
return this.core.effects.emit("".concat(this.name, ":onSalesOrderLoaded"), {
|
|
836
848
|
sales: sales
|
|
837
849
|
});
|
|
838
|
-
case
|
|
850
|
+
case 28:
|
|
839
851
|
return _context7.abrupt("return", sales);
|
|
840
|
-
case
|
|
852
|
+
case 29:
|
|
841
853
|
case "end":
|
|
842
854
|
return _context7.stop();
|
|
843
855
|
}
|
|
@@ -2149,7 +2161,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2149
2161
|
key: "syncPaymentsToOrder",
|
|
2150
2162
|
value: function () {
|
|
2151
2163
|
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(params) {
|
|
2152
|
-
var
|
|
2164
|
+
var _ref15, _params$businessCode, _this$otherParams18, _this$otherParams19, _params$channel;
|
|
2153
2165
|
var businessCode, channel, syncParams, syncState, payments, syncResult;
|
|
2154
2166
|
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
2155
2167
|
while (1) switch (_context23.prev = _context23.next) {
|
|
@@ -2160,7 +2172,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2160
2172
|
}
|
|
2161
2173
|
throw new Error('order 模块未初始化');
|
|
2162
2174
|
case 2:
|
|
2163
|
-
businessCode = (
|
|
2175
|
+
businessCode = (_ref15 = (_params$businessCode = params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams18 = this.otherParams) === null || _this$otherParams18 === void 0 ? void 0 : _this$otherParams18.businessCode) !== null && _ref15 !== void 0 ? _ref15 : (_this$otherParams19 = this.otherParams) === null || _this$otherParams19 === void 0 ? void 0 : _this$otherParams19.business_code;
|
|
2164
2176
|
channel = (_params$channel = params.channel) !== null && _params$channel !== void 0 ? _params$channel : this.getSubmitOrderSalesChannel();
|
|
2165
2177
|
syncParams = _objectSpread(_objectSpread(_objectSpread({}, params), businessCode !== undefined ? {
|
|
2166
2178
|
businessCode: businessCode
|
|
@@ -2247,7 +2259,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2247
2259
|
var _this$otherParams20,
|
|
2248
2260
|
_paymentRecord$paymen,
|
|
2249
2261
|
_paymentRecord$create,
|
|
2250
|
-
|
|
2262
|
+
_ref16,
|
|
2251
2263
|
_paymentRecord$origin,
|
|
2252
2264
|
_this7 = this;
|
|
2253
2265
|
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
@@ -2271,7 +2283,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2271
2283
|
var paymentTime = (_paymentRecord$paymen = paymentRecord.payment_time) !== null && _paymentRecord$paymen !== void 0 ? _paymentRecord$paymen : paymentTimestamp;
|
|
2272
2284
|
var createdAt = (_paymentRecord$create = paymentRecord.created_at) !== null && _paymentRecord$create !== void 0 ? _paymentRecord$create : paymentTimestamp;
|
|
2273
2285
|
var serviceCharge = paymentRecord.service_charge && _typeof(paymentRecord.service_charge) === 'object' ? paymentRecord.service_charge : null;
|
|
2274
|
-
var calculatedServiceFee = serviceCharge ? new Decimal((
|
|
2286
|
+
var calculatedServiceFee = serviceCharge ? new Decimal((_ref16 = (_paymentRecord$origin = paymentRecord.origin_amount) !== null && _paymentRecord$origin !== void 0 ? _paymentRecord$origin : paymentRecord.amount) !== null && _ref16 !== void 0 ? _ref16 : 0).times(serviceCharge.percentage || 0).plus(serviceCharge.amount || 0).toDecimalPlaces(2).toFixed(2) : undefined;
|
|
2275
2287
|
var payments = this.store.order.addOrderPayment(_objectSpread(_objectSpread(_objectSpread({}, paymentRecord), calculatedServiceFee !== undefined ? {
|
|
2276
2288
|
service_fee: calculatedServiceFee
|
|
2277
2289
|
} : {}), {}, {
|
|
@@ -2382,7 +2394,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2382
2394
|
key: "initWalletData",
|
|
2383
2395
|
value: function () {
|
|
2384
2396
|
var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(params) {
|
|
2385
|
-
var _params$order_wait_pa,
|
|
2397
|
+
var _params$order_wait_pa, _ref17, _tempOrder$is_price_i;
|
|
2386
2398
|
var snapshot, tempOrder, amount, walletBusinessData, result;
|
|
2387
2399
|
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
2388
2400
|
while (1) switch (_context24.prev = _context24.next) {
|
|
@@ -2425,7 +2437,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2425
2437
|
},
|
|
2426
2438
|
products: this.getWalletProductList(),
|
|
2427
2439
|
order_wait_pay_amount: (_params$order_wait_pa = params === null || params === void 0 ? void 0 : params.order_wait_pay_amount) !== null && _params$order_wait_pa !== void 0 ? _params$order_wait_pa : Number(amount.amountGap || 0),
|
|
2428
|
-
is_price_include_tax: (
|
|
2440
|
+
is_price_include_tax: (_ref17 = (_tempOrder$is_price_i = tempOrder.is_price_include_tax) !== null && _tempOrder$is_price_i !== void 0 ? _tempOrder$is_price_i : this.otherParams.is_price_include_tax) !== null && _ref17 !== void 0 ? _ref17 : 1
|
|
2429
2441
|
}, snapshot.identity.orderId ? {
|
|
2430
2442
|
payment_order_id: String(snapshot.identity.orderId)
|
|
2431
2443
|
} : {});
|
|
@@ -2556,7 +2568,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2556
2568
|
key: "sendCustomerPayLink",
|
|
2557
2569
|
value: (function () {
|
|
2558
2570
|
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(params) {
|
|
2559
|
-
var orderIds,
|
|
2571
|
+
var orderIds, _ref18, _ref19, _submitResult$data$or, _submitResult$data, _submitResult$data2, submitResult, orderId;
|
|
2560
2572
|
return _regeneratorRuntime().wrap(function _callee26$(_context26) {
|
|
2561
2573
|
while (1) switch (_context26.prev = _context26.next) {
|
|
2562
2574
|
case 0:
|
|
@@ -2577,7 +2589,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2577
2589
|
});
|
|
2578
2590
|
case 6:
|
|
2579
2591
|
submitResult = _context26.sent;
|
|
2580
|
-
orderId = (
|
|
2592
|
+
orderId = (_ref18 = (_ref19 = (_submitResult$data$or = submitResult === null || submitResult === void 0 || (_submitResult$data = submitResult.data) === null || _submitResult$data === void 0 ? void 0 : _submitResult$data.order_id) !== null && _submitResult$data$or !== void 0 ? _submitResult$data$or : submitResult === null || submitResult === void 0 ? void 0 : submitResult.order_id) !== null && _ref19 !== void 0 ? _ref19 : submitResult === null || submitResult === void 0 || (_submitResult$data2 = submitResult.data) === null || _submitResult$data2 === void 0 ? void 0 : _submitResult$data2.id) !== null && _ref18 !== void 0 ? _ref18 : submitResult === null || submitResult === void 0 ? void 0 : submitResult.id;
|
|
2581
2593
|
if (orderId) {
|
|
2582
2594
|
_context26.next = 10;
|
|
2583
2595
|
break;
|
|
@@ -3003,14 +3015,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3003
3015
|
value: function () {
|
|
3004
3016
|
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(params) {
|
|
3005
3017
|
var _this$otherParams22;
|
|
3006
|
-
var
|
|
3007
|
-
|
|
3018
|
+
var _ref20,
|
|
3019
|
+
_ref20$cover,
|
|
3008
3020
|
cover,
|
|
3009
3021
|
_args36 = arguments;
|
|
3010
3022
|
return _regeneratorRuntime().wrap(function _callee36$(_context36) {
|
|
3011
3023
|
while (1) switch (_context36.prev = _context36.next) {
|
|
3012
3024
|
case 0:
|
|
3013
|
-
|
|
3025
|
+
_ref20 = _args36.length > 1 && _args36[1] !== undefined ? _args36[1] : {}, _ref20$cover = _ref20.cover, cover = _ref20$cover === void 0 ? false : _ref20$cover;
|
|
3014
3026
|
if (cover) {
|
|
3015
3027
|
this.otherParams = _objectSpread({}, params);
|
|
3016
3028
|
} else {
|
|
@@ -311,7 +311,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
311
311
|
date: string;
|
|
312
312
|
status: string;
|
|
313
313
|
week: string;
|
|
314
|
-
weekNum: 0 | 2 | 1 |
|
|
314
|
+
weekNum: 0 | 2 | 1 | 5 | 3 | 4 | 6;
|
|
315
315
|
}[]>;
|
|
316
316
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
317
317
|
private getScheduleDataByIds;
|
|
@@ -502,10 +502,9 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
502
502
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
503
503
|
while (1) switch (_context6.prev = _context6.next) {
|
|
504
504
|
case 0:
|
|
505
|
-
|
|
506
|
-
_context6.next = 3;
|
|
505
|
+
_context6.next = 2;
|
|
507
506
|
return _get(_getPrototypeOf(BookingTicketImpl.prototype), "loadSalesDetail", this).call(this, orderIdOrParams);
|
|
508
|
-
case
|
|
507
|
+
case 2:
|
|
509
508
|
sales = _context6.sent;
|
|
510
509
|
customerModule = this.store.customer;
|
|
511
510
|
detailCustomer = sales === null || sales === void 0 ? void 0 : sales.customer;
|
|
@@ -534,7 +533,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
534
533
|
// await this.store.order.saveDraft();
|
|
535
534
|
}
|
|
536
535
|
return _context6.abrupt("return", sales);
|
|
537
|
-
case
|
|
536
|
+
case 11:
|
|
538
537
|
case "end":
|
|
539
538
|
return _context6.stop();
|
|
540
539
|
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/model/strategy/adapter/promotion/index.ts
|
|
30
|
+
var promotion_exports = {};
|
|
31
|
+
__export(promotion_exports, {
|
|
32
|
+
BUY_X_GET_Y_FREE_STRATEGY: () => import_examples.BUY_X_GET_Y_FREE_STRATEGY,
|
|
33
|
+
PromotionAdapter: () => import_adapter.PromotionAdapter,
|
|
34
|
+
PromotionEvaluator: () => import_evaluator.PromotionEvaluator,
|
|
35
|
+
X_ITEMS_FOR_Y_PRICE_STRATEGY: () => import_examples.X_ITEMS_FOR_Y_PRICE_STRATEGY,
|
|
36
|
+
default: () => import_adapter2.default
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(promotion_exports);
|
|
39
|
+
var import_evaluator = require("./evaluator");
|
|
40
|
+
var import_adapter = require("./adapter");
|
|
41
|
+
var import_adapter2 = __toESM(require("./adapter"));
|
|
42
|
+
var import_examples = require("./examples");
|
|
43
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
44
|
+
0 && (module.exports = {
|
|
45
|
+
BUY_X_GET_Y_FREE_STRATEGY,
|
|
46
|
+
PromotionAdapter,
|
|
47
|
+
PromotionEvaluator,
|
|
48
|
+
X_ITEMS_FOR_Y_PRICE_STRATEGY
|
|
49
|
+
});
|
|
@@ -429,7 +429,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
429
429
|
generateIdempotencyToken(): string;
|
|
430
430
|
syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
|
|
431
431
|
createOrder(params: CommitOrderParams['query']): {
|
|
432
|
-
type: "
|
|
432
|
+
type: "appointment_booking" | "virtual";
|
|
433
433
|
platform: string;
|
|
434
434
|
sales_channel: string;
|
|
435
435
|
order_sales_channel: string;
|
|
@@ -934,8 +934,6 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
934
934
|
if (normalizedStatus !== "refunded" && normalizedStatus !== "partially_refunded") {
|
|
935
935
|
return false;
|
|
936
936
|
}
|
|
937
|
-
if (params.refundAmount.lte(0))
|
|
938
|
-
return false;
|
|
939
937
|
if (params.previousSummary) {
|
|
940
938
|
const previousTargetAmount = this.calculatePaymentTargetAmount(
|
|
941
939
|
params.tempOrder,
|
|
@@ -945,10 +943,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
945
943
|
if (!previousTargetAmount.eq(params.targetAmount))
|
|
946
944
|
return false;
|
|
947
945
|
}
|
|
948
|
-
|
|
949
|
-
return params.refundAmount.gte(params.paymentTotal);
|
|
950
|
-
}
|
|
951
|
-
return params.netPaymentTotal.gte(params.targetAmount);
|
|
946
|
+
return true;
|
|
952
947
|
}
|
|
953
948
|
resolveWalletPassUseValue(payment, amount) {
|
|
954
949
|
const usageUnit = payment.wallet_pass_usage_unit && typeof payment.wallet_pass_usage_unit === "object" ? payment.wallet_pass_usage_unit : null;
|
|
@@ -2563,6 +2558,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
2563
2558
|
*/
|
|
2564
2559
|
async addProductToOrder(product, booking) {
|
|
2565
2560
|
const tempOrder = this.ensureTempOrder();
|
|
2561
|
+
debugger;
|
|
2566
2562
|
if (booking) {
|
|
2567
2563
|
const productRecord = product;
|
|
2568
2564
|
const splitCount = (0, import_utils3.getSafeProductNum)(
|
|
@@ -3641,6 +3637,9 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
3641
3637
|
...this.createDefaultTempOrderInstance(),
|
|
3642
3638
|
...raw || {}
|
|
3643
3639
|
};
|
|
3640
|
+
if ((nextTempOrder.order_id === void 0 || nextTempOrder.order_id === null) && (raw == null ? void 0 : raw.id) !== void 0 && (raw == null ? void 0 : raw.id) !== null) {
|
|
3641
|
+
nextTempOrder.order_id = raw.id;
|
|
3642
|
+
}
|
|
3644
3643
|
delete nextTempOrder.summary;
|
|
3645
3644
|
delete nextTempOrder.lastOrderInfo;
|
|
3646
3645
|
delete nextTempOrder.discount_list;
|
|
@@ -518,6 +518,11 @@ export interface LoadSalesDetailParams {
|
|
|
518
518
|
orderNumber?: string;
|
|
519
519
|
externalSaleNumber?: string;
|
|
520
520
|
external_sale_number?: string;
|
|
521
|
+
/**
|
|
522
|
+
* 已由调用方查询到的销售详情记录。
|
|
523
|
+
* 存在时 loadSalesDetail 会跳过远端 lookup,直接复用 hydrate 后半段逻辑。
|
|
524
|
+
*/
|
|
525
|
+
preloadedSalesDetail?: Record<string, any>;
|
|
521
526
|
forceRemote?: boolean;
|
|
522
527
|
merge?: boolean;
|
|
523
528
|
}
|
package/lib/server/index.d.ts
CHANGED
|
@@ -9,6 +9,20 @@ import { PisellCore, ServerModuleConfig, InitializeServerOptions } from '../type
|
|
|
9
9
|
import type { RouteHandler, HttpMethod, RouteDefinition, Router, ModuleRegistryConfig, RequestSetting } from './types';
|
|
10
10
|
import { OrderModule } from './modules/order';
|
|
11
11
|
export type { RouteHandler, HttpMethod, RouteDefinition, Router, ModuleRegistryConfig, };
|
|
12
|
+
/** Server 运行时诊断快照,用于排查订阅者是否持续增长。 */
|
|
13
|
+
export interface ServerDiagnosticsSnapshot {
|
|
14
|
+
subscribers: {
|
|
15
|
+
productQuerySubscribers: number;
|
|
16
|
+
orderQuerySubscribers: number;
|
|
17
|
+
bookingQuerySubscribers: number;
|
|
18
|
+
bookingRemoteQuerySubscribers: number;
|
|
19
|
+
salesSearchSubscribers: number;
|
|
20
|
+
floorPlanQuerySubscribers: number;
|
|
21
|
+
};
|
|
22
|
+
caches: {
|
|
23
|
+
bookingRemoteCache: number;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
12
26
|
/**
|
|
13
27
|
* Server 类
|
|
14
28
|
* 用于注册和管理服务端模块
|
|
@@ -44,6 +58,13 @@ declare class Server {
|
|
|
44
58
|
private floorPlanQuerySubscribers;
|
|
45
59
|
private moduleRegistry;
|
|
46
60
|
constructor(core: PisellCore);
|
|
61
|
+
/**
|
|
62
|
+
* 获取 Server 内部订阅者和缓存数量快照。
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* const snapshot = pisellos.server?.getDiagnosticsSnapshot?.();
|
|
66
|
+
*/
|
|
67
|
+
getDiagnosticsSnapshot(): ServerDiagnosticsSnapshot;
|
|
47
68
|
/**
|
|
48
69
|
* 注册路由
|
|
49
70
|
* @param routes 路由定义数组
|
package/lib/server/index.js
CHANGED
|
@@ -756,7 +756,7 @@ var Server = class {
|
|
|
756
756
|
this.handleFloorPlanGet = async ({ url, data, config, path: routePath }) => {
|
|
757
757
|
const base = "/shop/schedule/floor-plan";
|
|
758
758
|
const path = this.parseRequestPath(url, routePath);
|
|
759
|
-
if (path === `${base}/unsubscribe`) {
|
|
759
|
+
if (path === `${base}/unsubscribe` || path === `${base}/code/unsubscribe`) {
|
|
760
760
|
const subscriberId2 = data == null ? void 0 : data.subscriberId;
|
|
761
761
|
if (subscriberId2) {
|
|
762
762
|
this.floorPlanQuerySubscribers.delete(subscriberId2);
|
|
@@ -905,6 +905,27 @@ var Server = class {
|
|
|
905
905
|
hasLogger: !!this.logger
|
|
906
906
|
});
|
|
907
907
|
}
|
|
908
|
+
/**
|
|
909
|
+
* 获取 Server 内部订阅者和缓存数量快照。
|
|
910
|
+
*
|
|
911
|
+
* @example
|
|
912
|
+
* const snapshot = pisellos.server?.getDiagnosticsSnapshot?.();
|
|
913
|
+
*/
|
|
914
|
+
getDiagnosticsSnapshot() {
|
|
915
|
+
return {
|
|
916
|
+
subscribers: {
|
|
917
|
+
productQuerySubscribers: this.productQuerySubscribers.size,
|
|
918
|
+
orderQuerySubscribers: this.orderQuerySubscribers.size,
|
|
919
|
+
bookingQuerySubscribers: this.bookingQuerySubscribers.size,
|
|
920
|
+
bookingRemoteQuerySubscribers: this.bookingRemoteQuerySubscribers.size,
|
|
921
|
+
salesSearchSubscribers: this.salesSearchSubscribers.size,
|
|
922
|
+
floorPlanQuerySubscribers: this.floorPlanQuerySubscribers.size
|
|
923
|
+
},
|
|
924
|
+
caches: {
|
|
925
|
+
bookingRemoteCache: this.bookingRemoteCache.size
|
|
926
|
+
}
|
|
927
|
+
};
|
|
928
|
+
}
|
|
908
929
|
/**
|
|
909
930
|
* 注册路由
|
|
910
931
|
* @param routes 路由定义数组
|
|
@@ -1256,7 +1256,16 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
1256
1256
|
"shop_discount",
|
|
1257
1257
|
"summary",
|
|
1258
1258
|
"products",
|
|
1259
|
-
"bookings"
|
|
1259
|
+
"bookings",
|
|
1260
|
+
"note",
|
|
1261
|
+
"customer_id",
|
|
1262
|
+
"customer_name",
|
|
1263
|
+
"customer",
|
|
1264
|
+
"holder",
|
|
1265
|
+
"contacts_info",
|
|
1266
|
+
"phone",
|
|
1267
|
+
"email",
|
|
1268
|
+
"relation_forms"
|
|
1260
1269
|
];
|
|
1261
1270
|
const mergedRecord = merged;
|
|
1262
1271
|
const preferredRecord = preferred;
|
|
@@ -458,7 +458,10 @@ export interface OrderFilters {
|
|
|
458
458
|
* 预约展开列表筛选条件(订单级条件匹配 booking.order.*,预约级匹配 booking 自身)
|
|
459
459
|
*/
|
|
460
460
|
export interface BookingFilters {
|
|
461
|
+
/** RecordBoard 通用搜索字段(单数),用于本地预约过滤 */
|
|
461
462
|
keyword?: string;
|
|
463
|
+
/** `/shop/schedule/booking` 后端协议搜索字段(复数),OS Server 需兼容 */
|
|
464
|
+
keywords?: string;
|
|
462
465
|
order_by?: string;
|
|
463
466
|
order_payment_status?: string[];
|
|
464
467
|
order_status?: string[];
|
|
@@ -104,9 +104,14 @@ function parseNumberRange(range) {
|
|
|
104
104
|
return null;
|
|
105
105
|
return [min, max];
|
|
106
106
|
}
|
|
107
|
+
function resolveBookingKeyword(f) {
|
|
108
|
+
const keyword = f.keyword ?? f.keywords;
|
|
109
|
+
return typeof keyword === "string" ? keyword.trim() : "";
|
|
110
|
+
}
|
|
107
111
|
function prepareFilters(f) {
|
|
108
112
|
var _a, _b, _c, _d, _e, _f;
|
|
109
113
|
const hasCustomerId = f.customer_id !== void 0 && f.customer_id !== null;
|
|
114
|
+
const keyword = resolveBookingKeyword(f);
|
|
110
115
|
return {
|
|
111
116
|
orderPaymentStatusSet: ((_a = f.order_payment_status) == null ? void 0 : _a.length) ? new Set(f.order_payment_status) : null,
|
|
112
117
|
orderStatusSet: ((_b = f.order_status) == null ? void 0 : _b.length) ? new Set(f.order_status) : null,
|
|
@@ -123,7 +128,7 @@ function prepareFilters(f) {
|
|
|
123
128
|
updatedAtRange: parseDateRange(f.updated_at_between),
|
|
124
129
|
numberRange: parseNumberRange(f.number_between),
|
|
125
130
|
totalAmountRange: Array.isArray(f.total_amount_between) && f.total_amount_between.length === 2 ? f.total_amount_between : null,
|
|
126
|
-
keywordLower:
|
|
131
|
+
keywordLower: keyword ? keyword.toLowerCase() : "",
|
|
127
132
|
afterExecutionTimeMs: (() => {
|
|
128
133
|
const raw = f.after_execution_time;
|
|
129
134
|
if (raw === void 0 || raw === null || raw === "")
|
|
@@ -200,7 +200,6 @@ function buildProducts(order, locale, productMap) {
|
|
|
200
200
|
quantity,
|
|
201
201
|
originalPrice
|
|
202
202
|
});
|
|
203
|
-
const discountList = normalizeProductDiscounts({ product, locale, currencySymbol, quantity });
|
|
204
203
|
return {
|
|
205
204
|
product_title: productTitle,
|
|
206
205
|
product_quantity: quantity,
|
|
@@ -208,7 +207,6 @@ function buildProducts(order, locale, productMap) {
|
|
|
208
207
|
original_price: formatMoney(originalPrice, currencySymbol),
|
|
209
208
|
total_original_price: formatMoney(new import_decimal.default(toMoneyNumber(originalPrice)).mul(quantity), currencySymbol),
|
|
210
209
|
extension_list: extensionList,
|
|
211
|
-
...discountList.length ? { discount_list: discountList } : {},
|
|
212
210
|
...options.length ? { options } : {},
|
|
213
211
|
...resolvedVariant ? { variant: resolvedVariant } : {},
|
|
214
212
|
...Array.isArray(product.combinations) ? { combinations: product.combinations } : combinations.length ? { combinations } : {}
|
|
@@ -222,16 +220,14 @@ function normalizeProductDiscounts(params) {
|
|
|
222
220
|
const amount = discount.amount ?? discount.value ?? discount.discount_amount;
|
|
223
221
|
const formattedAmount = formatNegativeMoney(new import_decimal.default(toMoneyNumber(amount)).mul(quantity), currencySymbol);
|
|
224
222
|
return {
|
|
225
|
-
...discount,
|
|
226
223
|
item: title,
|
|
227
|
-
name: title,
|
|
228
|
-
title,
|
|
229
224
|
value: formattedAmount
|
|
230
225
|
};
|
|
231
226
|
});
|
|
232
227
|
}
|
|
233
228
|
function buildProductExtensionList(params) {
|
|
234
229
|
const { product, locale, currencySymbol, quantity, originalPrice } = params;
|
|
230
|
+
const discountList = normalizeProductDiscounts({ product, locale, currencySymbol, quantity });
|
|
235
231
|
const extensionList = [
|
|
236
232
|
...buildProductOpenWeightRows({ product, locale, currencySymbol }),
|
|
237
233
|
...quantity > 1 ? [{
|
|
@@ -239,7 +235,8 @@ function buildProductExtensionList(params) {
|
|
|
239
235
|
value: ""
|
|
240
236
|
}] : []
|
|
241
237
|
];
|
|
242
|
-
|
|
238
|
+
const productExtensionList = extensionList.length ? extensionList : normalizeArray(product.extension_list);
|
|
239
|
+
return [...productExtensionList, ...discountList];
|
|
243
240
|
}
|
|
244
241
|
function buildProductOpenWeightRows(params) {
|
|
245
242
|
const { product, locale, currencySymbol } = params;
|
|
@@ -596,21 +596,25 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
596
596
|
throw new Error("order 模块未初始化");
|
|
597
597
|
const params = typeof orderIdOrParams === "object" ? orderIdOrParams : { orderId: orderIdOrParams };
|
|
598
598
|
const externalSaleNumber = params.externalSaleNumber || params.external_sale_number;
|
|
599
|
-
const
|
|
600
|
-
|
|
599
|
+
const preloadedSalesDetail = params.preloadedSalesDetail;
|
|
600
|
+
const lookup = params.orderId ?? externalSaleNumber ?? params.orderNumber ?? (preloadedSalesDetail == null ? void 0 : preloadedSalesDetail.order_id) ?? (preloadedSalesDetail == null ? void 0 : preloadedSalesDetail.external_sale_number) ?? (preloadedSalesDetail == null ? void 0 : preloadedSalesDetail.order_number);
|
|
601
|
+
if (!preloadedSalesDetail && (lookup === void 0 || lookup === null || lookup === "")) {
|
|
601
602
|
throw new Error("加载销售详情需要 orderId、externalSaleNumber 或 orderNumber");
|
|
602
603
|
}
|
|
603
|
-
const
|
|
604
|
+
const loadedRecord = preloadedSalesDetail ?? await this.store.order.getSalesOrderByLookup({
|
|
604
605
|
lookup,
|
|
605
606
|
forceRemote: params.forceRemote
|
|
606
607
|
});
|
|
607
|
-
if (!
|
|
608
|
-
const message =
|
|
608
|
+
if (!preloadedSalesDetail && (!loadedRecord || loadedRecord.code !== 200)) {
|
|
609
|
+
const message = loadedRecord && (loadedRecord.message || loadedRecord.msg) || `加载销售详情失败: ${lookup}`;
|
|
609
610
|
throw new Error(message);
|
|
610
611
|
}
|
|
612
|
+
const remoteRecord = preloadedSalesDetail ?? loadedRecord.data;
|
|
611
613
|
const currentTempOrder = params.merge ? this.store.order.getTempOrder() : null;
|
|
612
|
-
const record = params.merge ? mergeSalesDetailRecordWithTempOrder(currentTempOrder,
|
|
613
|
-
const sales = await this.store.order.hydrateTempOrderFromRecord(record, {
|
|
614
|
+
const record = params.merge ? mergeSalesDetailRecordWithTempOrder(currentTempOrder, remoteRecord) : remoteRecord;
|
|
615
|
+
const sales = await this.store.order.hydrateTempOrderFromRecord(record, {
|
|
616
|
+
recalcOnHydrate: false
|
|
617
|
+
});
|
|
614
618
|
this.currentSalesDetail = sales;
|
|
615
619
|
await this.core.effects.emit(`${this.name}:onSalesOrderLoaded`, { sales });
|
|
616
620
|
return sales;
|
|
@@ -311,7 +311,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
311
311
|
date: string;
|
|
312
312
|
status: string;
|
|
313
313
|
week: string;
|
|
314
|
-
weekNum: 0 | 2 | 1 |
|
|
314
|
+
weekNum: 0 | 2 | 1 | 5 | 3 | 4 | 6;
|
|
315
315
|
}[]>;
|
|
316
316
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
317
317
|
private getScheduleDataByIds;
|
|
@@ -307,7 +307,6 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
|
307
307
|
* 让现有 setActiveCustomer / getActiveCustomer 调用方零成本拿到详情态客户。
|
|
308
308
|
*/
|
|
309
309
|
async loadSalesDetail(orderIdOrParams) {
|
|
310
|
-
debugger;
|
|
311
310
|
const sales = await super.loadSalesDetail(orderIdOrParams);
|
|
312
311
|
const customerModule = this.store.customer;
|
|
313
312
|
const detailCustomer = sales == null ? void 0 : sales.customer;
|