@pisell/pisellos 2.2.192 → 2.2.193
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/walletPass/utils.js +7 -4
- package/dist/modules/Order/index.d.ts +12 -10
- package/dist/modules/Order/index.js +462 -571
- package/dist/modules/Order/types.d.ts +5 -5
- package/dist/modules/Order/utils.js +3 -3
- package/dist/modules/Payment/utils.js +2 -1
- package/dist/modules/SalesSummary/utils.js +1 -1
- package/dist/server/index.d.ts +8 -1
- package/dist/server/index.js +651 -464
- package/dist/server/modules/order/index.d.ts +3 -2
- package/dist/server/modules/order/index.js +68 -52
- package/dist/solution/BaseSales/index.d.ts +2 -1
- package/dist/solution/BaseSales/index.js +116 -122
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +0 -1
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/ScanOrder/index.js +3 -1
- package/lib/model/strategy/adapter/promotion/index.js +49 -0
- package/lib/model/strategy/adapter/walletPass/utils.js +3 -2
- package/lib/modules/Order/index.d.ts +12 -10
- package/lib/modules/Order/index.js +94 -118
- package/lib/modules/Order/types.d.ts +5 -5
- package/lib/modules/Order/utils.js +4 -4
- package/lib/modules/Payment/utils.js +2 -1
- package/lib/modules/SalesSummary/utils.js +1 -3
- package/lib/server/index.d.ts +8 -1
- package/lib/server/index.js +143 -24
- package/lib/server/modules/order/index.d.ts +3 -2
- package/lib/server/modules/order/index.js +25 -15
- package/lib/solution/BaseSales/index.d.ts +2 -1
- package/lib/solution/BaseSales/index.js +53 -16
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +0 -1
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/ScanOrder/index.js +3 -1
- package/package.json +1 -1
package/lib/server/index.js
CHANGED
|
@@ -452,34 +452,55 @@ var Server = class {
|
|
|
452
452
|
};
|
|
453
453
|
}
|
|
454
454
|
};
|
|
455
|
+
this.handleOrderSalesCheckout = async ({ data }) => {
|
|
456
|
+
return this.handleOrderCheckoutSubmit({
|
|
457
|
+
backendPath: "/shop/order/sales/checkout",
|
|
458
|
+
data,
|
|
459
|
+
title: "handleOrderSalesCheckout"
|
|
460
|
+
});
|
|
461
|
+
};
|
|
462
|
+
this.handleOrderCheckout = async ({ data }) => {
|
|
463
|
+
return this.handleOrderCheckoutSubmit({
|
|
464
|
+
backendPath: "/order/checkout",
|
|
465
|
+
data,
|
|
466
|
+
title: "handleOrderCheckout"
|
|
467
|
+
});
|
|
468
|
+
};
|
|
455
469
|
this.handleOrderSalesDetail = async ({ url, data, path }) => {
|
|
456
470
|
var _a;
|
|
457
471
|
const requestPath = this.parseRequestPath(url, path);
|
|
458
|
-
const
|
|
459
|
-
this.logInfo("handleOrderSalesDetail: 开始处理", { url, path: requestPath,
|
|
460
|
-
if (!
|
|
461
|
-
this.logWarning("handleOrderSalesDetail:
|
|
462
|
-
return { code: 400, status: false, message: "
|
|
472
|
+
const lookup = this.extractOrderSalesDetailLookup(requestPath);
|
|
473
|
+
this.logInfo("handleOrderSalesDetail: 开始处理", { url, path: requestPath, lookup });
|
|
474
|
+
if (!lookup) {
|
|
475
|
+
this.logWarning("handleOrderSalesDetail: lookup 缺失", { url, path: requestPath });
|
|
476
|
+
return { code: 400, status: false, message: "订单 lookup 缺失", data: null };
|
|
463
477
|
}
|
|
464
478
|
if (!this.order) {
|
|
465
479
|
this.logError("handleOrderSalesDetail: Order 模块未注册");
|
|
466
480
|
return { code: 500, status: false, message: "Order 模块未注册", data: null };
|
|
467
481
|
}
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
482
|
+
if (!this.shouldForceRemoteSalesDetail(data)) {
|
|
483
|
+
const localOrder = await this.order.getLocalOrderByLookup(lookup);
|
|
484
|
+
if (localOrder) {
|
|
485
|
+
this.logInfo("handleOrderSalesDetail: 命中本地订单", { lookup });
|
|
486
|
+
return {
|
|
487
|
+
code: 200,
|
|
488
|
+
status: true,
|
|
489
|
+
message: "",
|
|
490
|
+
data: localOrder
|
|
491
|
+
};
|
|
492
|
+
}
|
|
477
493
|
}
|
|
478
494
|
if (!((_a = this.app) == null ? void 0 : _a.request)) {
|
|
479
495
|
this.logError("handleOrderSalesDetail: app.request 不可用");
|
|
480
|
-
return {
|
|
496
|
+
return {
|
|
497
|
+
code: 500,
|
|
498
|
+
status: false,
|
|
499
|
+
message: "app.request 不可用",
|
|
500
|
+
data: null
|
|
501
|
+
};
|
|
481
502
|
}
|
|
482
|
-
const backendPath = this.buildOrderSalesDetailBackendPath(
|
|
503
|
+
const backendPath = this.buildOrderSalesDetailBackendPath(lookup, data);
|
|
483
504
|
try {
|
|
484
505
|
const response = await this.app.request.get(backendPath, {
|
|
485
506
|
lookup_mode: "multi"
|
|
@@ -491,7 +512,7 @@ var Server = class {
|
|
|
491
512
|
const fresh = (response == null ? void 0 : response.data) ?? response;
|
|
492
513
|
if (!fresh || typeof fresh !== "object" || fresh.order_id == null) {
|
|
493
514
|
this.logError("handleOrderSalesDetail: 后端返回订单为空", {
|
|
494
|
-
|
|
515
|
+
lookup,
|
|
495
516
|
backendPath
|
|
496
517
|
});
|
|
497
518
|
return {
|
|
@@ -502,9 +523,9 @@ var Server = class {
|
|
|
502
523
|
};
|
|
503
524
|
}
|
|
504
525
|
await this.order.upsertOrdersFromRemote([fresh]);
|
|
505
|
-
const savedOrder = await this.order.
|
|
526
|
+
const savedOrder = await this.order.getLocalOrderByLookup(lookup);
|
|
506
527
|
if (!savedOrder) {
|
|
507
|
-
this.logError("handleOrderSalesDetail: 订单写入后回读失败", {
|
|
528
|
+
this.logError("handleOrderSalesDetail: 订单写入后回读失败", { lookup });
|
|
508
529
|
return {
|
|
509
530
|
code: 500,
|
|
510
531
|
status: false,
|
|
@@ -512,7 +533,7 @@ var Server = class {
|
|
|
512
533
|
data: null
|
|
513
534
|
};
|
|
514
535
|
}
|
|
515
|
-
this.logInfo("handleOrderSalesDetail: 远端订单已同步到本地", {
|
|
536
|
+
this.logInfo("handleOrderSalesDetail: 远端订单已同步到本地", { lookup });
|
|
516
537
|
return {
|
|
517
538
|
code: 200,
|
|
518
539
|
status: true,
|
|
@@ -522,7 +543,7 @@ var Server = class {
|
|
|
522
543
|
} catch (error) {
|
|
523
544
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
524
545
|
this.logError("handleOrderSalesDetail: 请求失败", {
|
|
525
|
-
|
|
546
|
+
lookup,
|
|
526
547
|
backendPath,
|
|
527
548
|
error: errorMessage
|
|
528
549
|
});
|
|
@@ -1240,6 +1261,16 @@ var Server = class {
|
|
|
1240
1261
|
method: "get",
|
|
1241
1262
|
path: "/update/localOrder",
|
|
1242
1263
|
handler: this.handleUpdateLocalOrder.bind(this)
|
|
1264
|
+
},
|
|
1265
|
+
{
|
|
1266
|
+
method: "post",
|
|
1267
|
+
path: "/shop/order/sales/checkout",
|
|
1268
|
+
handler: this.handleOrderSalesCheckout.bind(this)
|
|
1269
|
+
},
|
|
1270
|
+
{
|
|
1271
|
+
method: "post",
|
|
1272
|
+
path: "/shop/order/checkout",
|
|
1273
|
+
handler: this.handleOrderCheckout.bind(this)
|
|
1243
1274
|
}
|
|
1244
1275
|
]);
|
|
1245
1276
|
this.registerPrefixRoutes([
|
|
@@ -1707,6 +1738,49 @@ var Server = class {
|
|
|
1707
1738
|
};
|
|
1708
1739
|
}
|
|
1709
1740
|
}
|
|
1741
|
+
async handleOrderCheckoutSubmit(params) {
|
|
1742
|
+
var _a;
|
|
1743
|
+
const { backendPath, data, title } = params;
|
|
1744
|
+
this.logInfo(`${title}: 开始处理`, {
|
|
1745
|
+
backendPath,
|
|
1746
|
+
order_id: data == null ? void 0 : data.order_id,
|
|
1747
|
+
external_sale_number: data == null ? void 0 : data.external_sale_number,
|
|
1748
|
+
order_number: data == null ? void 0 : data.order_number
|
|
1749
|
+
});
|
|
1750
|
+
if (!((_a = this.app) == null ? void 0 : _a.request)) {
|
|
1751
|
+
this.logError(`${title}: app.request 不可用`);
|
|
1752
|
+
return { code: 500, status: false, message: "app.request 不可用", data: null };
|
|
1753
|
+
}
|
|
1754
|
+
try {
|
|
1755
|
+
const response = await this.app.request.post(backendPath, data, {
|
|
1756
|
+
isShopApi: true,
|
|
1757
|
+
customToast: () => {
|
|
1758
|
+
}
|
|
1759
|
+
});
|
|
1760
|
+
const fresh = this.extractOrderDataFromCheckoutResponse(response);
|
|
1761
|
+
if (fresh && this.order) {
|
|
1762
|
+
await this.order.upsertOrdersFromRemote([fresh]);
|
|
1763
|
+
this.logInfo(`${title}: 订单已同步到本地`, {
|
|
1764
|
+
order_id: fresh.order_id,
|
|
1765
|
+
external_sale_number: fresh.external_sale_number,
|
|
1766
|
+
order_number: fresh.order_number
|
|
1767
|
+
});
|
|
1768
|
+
} else {
|
|
1769
|
+
this.logWarning(`${title}: checkout 返回未包含可同步订单`, {
|
|
1770
|
+
hasOrderModule: !!this.order,
|
|
1771
|
+
backendPath
|
|
1772
|
+
});
|
|
1773
|
+
}
|
|
1774
|
+
return this.normalizeCheckoutResponse(response);
|
|
1775
|
+
} catch (error) {
|
|
1776
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
1777
|
+
this.logError(`${title}: 请求失败`, { backendPath, error: errorMessage });
|
|
1778
|
+
const backendError = this.extractBackendErrorResponse(error);
|
|
1779
|
+
if (backendError)
|
|
1780
|
+
return backendError;
|
|
1781
|
+
return { code: 500, status: false, message: errorMessage, data: null };
|
|
1782
|
+
}
|
|
1783
|
+
}
|
|
1710
1784
|
/**
|
|
1711
1785
|
* 解析 order_ids 入参,兼容 url query / data 字段、字符串(csv) / 数组两种形态。
|
|
1712
1786
|
* 自动 trim、去空、按字符串去重,输出归一化后的字符串数组。
|
|
@@ -1859,12 +1933,15 @@ var Server = class {
|
|
|
1859
1933
|
return null;
|
|
1860
1934
|
}
|
|
1861
1935
|
}
|
|
1862
|
-
|
|
1936
|
+
extractOrderSalesDetailLookup(url) {
|
|
1863
1937
|
const path = this.parseRequestPath(url);
|
|
1864
1938
|
const match = path.match(/^\/shop\/order\/sales\/([^/?#]+)$/);
|
|
1865
1939
|
return (match == null ? void 0 : match[1]) ? decodeURIComponent(match[1]) : null;
|
|
1866
1940
|
}
|
|
1867
|
-
|
|
1941
|
+
shouldForceRemoteSalesDetail(data) {
|
|
1942
|
+
return (data == null ? void 0 : data.forceRemote) === true || (data == null ? void 0 : data.force_remote) === true;
|
|
1943
|
+
}
|
|
1944
|
+
buildOrderSalesDetailBackendPath(lookup, data) {
|
|
1868
1945
|
const rawWith = data && typeof data === "object" ? data.with : void 0;
|
|
1869
1946
|
const withFields = Array.isArray(rawWith) && rawWith.length > 0 ? rawWith : ["products", "scheduleEvents"];
|
|
1870
1947
|
const searchParams = new URLSearchParams();
|
|
@@ -1875,7 +1952,49 @@ var Server = class {
|
|
|
1875
1952
|
});
|
|
1876
1953
|
searchParams.append("lookup_mode", "multi");
|
|
1877
1954
|
const query = searchParams.toString();
|
|
1878
|
-
return `/shop/order/sales/${encodeURIComponent(
|
|
1955
|
+
return `/shop/order/sales/${encodeURIComponent(lookup)}${query ? `?${query}` : ""}`;
|
|
1956
|
+
}
|
|
1957
|
+
extractOrderDataFromCheckoutResponse(response) {
|
|
1958
|
+
var _a, _b;
|
|
1959
|
+
const candidates = [
|
|
1960
|
+
(_a = response == null ? void 0 : response.data) == null ? void 0 : _a.order,
|
|
1961
|
+
(_b = response == null ? void 0 : response.data) == null ? void 0 : _b.sales,
|
|
1962
|
+
response == null ? void 0 : response.data,
|
|
1963
|
+
response == null ? void 0 : response.order,
|
|
1964
|
+
response == null ? void 0 : response.sales,
|
|
1965
|
+
response
|
|
1966
|
+
];
|
|
1967
|
+
for (const candidate of candidates) {
|
|
1968
|
+
if (!candidate || typeof candidate !== "object")
|
|
1969
|
+
continue;
|
|
1970
|
+
if (candidate.order_id !== void 0 && candidate.order_id !== null) {
|
|
1971
|
+
return candidate;
|
|
1972
|
+
}
|
|
1973
|
+
}
|
|
1974
|
+
return null;
|
|
1975
|
+
}
|
|
1976
|
+
normalizeCheckoutResponse(response) {
|
|
1977
|
+
if (response && typeof response === "object" && (response.code !== void 0 || response.status !== void 0)) {
|
|
1978
|
+
return response;
|
|
1979
|
+
}
|
|
1980
|
+
return {
|
|
1981
|
+
code: 200,
|
|
1982
|
+
status: true,
|
|
1983
|
+
message: "",
|
|
1984
|
+
data: response
|
|
1985
|
+
};
|
|
1986
|
+
}
|
|
1987
|
+
extractBackendErrorResponse(error) {
|
|
1988
|
+
var _a, _b;
|
|
1989
|
+
const candidates = [
|
|
1990
|
+
(_a = error == null ? void 0 : error.response) == null ? void 0 : _a.data,
|
|
1991
|
+
error == null ? void 0 : error.data,
|
|
1992
|
+
(_b = error == null ? void 0 : error.response) == null ? void 0 : _b.body,
|
|
1993
|
+
error == null ? void 0 : error.body
|
|
1994
|
+
];
|
|
1995
|
+
return candidates.find(
|
|
1996
|
+
(candidate) => candidate && typeof candidate === "object"
|
|
1997
|
+
) || null;
|
|
1879
1998
|
}
|
|
1880
1999
|
/**
|
|
1881
2000
|
* 从 url 或路由 path 解析 pathname(不含 query,去掉末尾 /)
|
|
@@ -69,9 +69,9 @@ export declare class OrderModule extends BaseModule implements Module {
|
|
|
69
69
|
preload(): Promise<void>;
|
|
70
70
|
getOrders(): OrderData[];
|
|
71
71
|
getOrderById(id: OrderId): OrderData | undefined;
|
|
72
|
-
/** 按 order_id
|
|
72
|
+
/** 按 order_id 查询内存订单。 */
|
|
73
73
|
getOrderByOrderId(orderId: OrderId): OrderData | undefined;
|
|
74
|
-
|
|
74
|
+
getLocalOrderByLookup(lookup: OrderId): Promise<OrderData | null>;
|
|
75
75
|
loadOrdersByServer(): Promise<OrderData[]>;
|
|
76
76
|
/**
|
|
77
77
|
* 静默全量刷新:后台重新拉取全量 SSE 订单数据并更新本地
|
|
@@ -152,6 +152,7 @@ export declare class OrderModule extends BaseModule implements Module {
|
|
|
152
152
|
private normalizeOrderSyncPayload;
|
|
153
153
|
private uniqueOrderIds;
|
|
154
154
|
private getIdKey;
|
|
155
|
+
private isOrderLookupMatch;
|
|
155
156
|
/**
|
|
156
157
|
* 解析订单 SQLite 主键,规则与宿主 OrderDataSource.getOrderStorageKey 一致。
|
|
157
158
|
*
|
|
@@ -346,26 +346,20 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
346
346
|
getOrderById(id) {
|
|
347
347
|
return this.store.map.get(this.getIdKey(id));
|
|
348
348
|
}
|
|
349
|
-
/** 按 order_id
|
|
349
|
+
/** 按 order_id 查询内存订单。 */
|
|
350
350
|
getOrderByOrderId(orderId) {
|
|
351
351
|
return this.store.map.get(this.getIdKey(orderId));
|
|
352
352
|
}
|
|
353
|
-
async
|
|
354
|
-
const key = this.getIdKey(
|
|
355
|
-
const
|
|
356
|
-
if (
|
|
353
|
+
async getLocalOrderByLookup(lookup) {
|
|
354
|
+
const key = this.getIdKey(lookup);
|
|
355
|
+
const memoryOrderById = this.store.map.get(key);
|
|
356
|
+
if (memoryOrderById)
|
|
357
|
+
return memoryOrderById;
|
|
358
|
+
const memoryOrder = this.store.list.find((order) => this.isOrderLookupMatch(order, key));
|
|
359
|
+
if (memoryOrder)
|
|
357
360
|
return memoryOrder;
|
|
358
|
-
}
|
|
359
361
|
const orders = await this.loadOrdersFromSQLite();
|
|
360
|
-
const localOrder = orders.find((order) =>
|
|
361
|
-
const shopOrderNumber = order == null ? void 0 : order.shop_order_number;
|
|
362
|
-
if (shopOrderNumber && this.getIdKey(shopOrderNumber) === key)
|
|
363
|
-
return true;
|
|
364
|
-
const id = order == null ? void 0 : order.order_id;
|
|
365
|
-
if (id === void 0 || id === null)
|
|
366
|
-
return false;
|
|
367
|
-
return this.getIdKey(id) === key;
|
|
368
|
-
});
|
|
362
|
+
const localOrder = orders.find((order) => this.isOrderLookupMatch(order, key));
|
|
369
363
|
if (!localOrder)
|
|
370
364
|
return null;
|
|
371
365
|
this.store.list = orders;
|
|
@@ -862,6 +856,22 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
862
856
|
getIdKey(id) {
|
|
863
857
|
return String(id);
|
|
864
858
|
}
|
|
859
|
+
isOrderLookupMatch(order, lookupKey) {
|
|
860
|
+
if (!order || !lookupKey)
|
|
861
|
+
return false;
|
|
862
|
+
const candidates = [
|
|
863
|
+
order.order_id,
|
|
864
|
+
order.external_sale_number,
|
|
865
|
+
order.order_number,
|
|
866
|
+
order.shop_order_number,
|
|
867
|
+
order.shop_full_order_number
|
|
868
|
+
];
|
|
869
|
+
return candidates.some((value) => {
|
|
870
|
+
if (value === void 0 || value === null || value === "")
|
|
871
|
+
return false;
|
|
872
|
+
return this.getIdKey(value) === lookupKey;
|
|
873
|
+
});
|
|
874
|
+
}
|
|
865
875
|
/**
|
|
866
876
|
* 解析订单 SQLite 主键,规则与宿主 OrderDataSource.getOrderStorageKey 一致。
|
|
867
877
|
*
|
|
@@ -89,7 +89,7 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
89
89
|
destroy(): Promise<void>;
|
|
90
90
|
/**
|
|
91
91
|
* 加载销售订单到统一 tempOrder 工作区。
|
|
92
|
-
*
|
|
92
|
+
* 统一通过 OrderModule 的 sales detail lookup 加载订单详情。
|
|
93
93
|
*
|
|
94
94
|
* 子类可在 `super.loadSalesDetail` 之后基于返回的 `sales` 做业务侧装配
|
|
95
95
|
* (比如把 `sales.customer` 写入 CustomerModule、emit 业务 hook 等)。
|
|
@@ -140,6 +140,7 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
140
140
|
private getHistoricalProductDiscountList;
|
|
141
141
|
private isPersistedOrderProduct;
|
|
142
142
|
private mergeHistoricalDiscountList;
|
|
143
|
+
private shouldSkipAutoApplyFetchedDiscountsInEditMode;
|
|
143
144
|
private mergeCurrentDiscountSelectionState;
|
|
144
145
|
loadDiscountConfig(params?: {
|
|
145
146
|
customerId?: number;
|
|
@@ -429,7 +429,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
429
429
|
}
|
|
430
430
|
/**
|
|
431
431
|
* 加载销售订单到统一 tempOrder 工作区。
|
|
432
|
-
*
|
|
432
|
+
* 统一通过 OrderModule 的 sales detail lookup 加载订单详情。
|
|
433
433
|
*
|
|
434
434
|
* 子类可在 `super.loadSalesDetail` 之后基于返回的 `sales` 做业务侧装配
|
|
435
435
|
* (比如把 `sales.customer` 写入 CustomerModule、emit 业务 hook 等)。
|
|
@@ -439,25 +439,19 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
439
439
|
throw new Error("order 模块未初始化");
|
|
440
440
|
const params = typeof orderIdOrParams === "object" ? orderIdOrParams : { orderId: orderIdOrParams };
|
|
441
441
|
const externalSaleNumber = params.externalSaleNumber || params.external_sale_number;
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
const sales2 = await this.store.order.hydrateTempOrderFromRecord(localRecord, { recalcOnHydrate: false });
|
|
446
|
-
this.currentSalesDetail = sales2;
|
|
447
|
-
await this.core.effects.emit(`${this.name}:onSalesOrderLoaded`, { sales: sales2 });
|
|
448
|
-
return sales2;
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
if (params.orderId === void 0 || params.orderId === null) {
|
|
452
|
-
throw new Error("加载销售详情需要 orderId,或本地库中存在对应 externalSaleNumber/orderNumber");
|
|
442
|
+
const lookup = params.orderId ?? externalSaleNumber ?? params.orderNumber;
|
|
443
|
+
if (lookup === void 0 || lookup === null || lookup === "") {
|
|
444
|
+
throw new Error("加载销售详情需要 orderId、externalSaleNumber 或 orderNumber");
|
|
453
445
|
}
|
|
454
|
-
const res = await this.store.order.
|
|
446
|
+
const res = await this.store.order.getSalesOrderByLookup({
|
|
447
|
+
lookup,
|
|
448
|
+
forceRemote: params.forceRemote
|
|
449
|
+
});
|
|
455
450
|
if (!res || res.code !== 200) {
|
|
456
|
-
const message = res && (res.message || res.msg) || `加载销售详情失败: ${
|
|
451
|
+
const message = res && (res.message || res.msg) || `加载销售详情失败: ${lookup}`;
|
|
457
452
|
throw new Error(message);
|
|
458
453
|
}
|
|
459
454
|
const sales = await this.store.order.hydrateTempOrderFromRecord(res.data, { recalcOnHydrate: false });
|
|
460
|
-
await this.store.order.saveDraft();
|
|
461
455
|
this.currentSalesDetail = sales;
|
|
462
456
|
await this.core.effects.emit(`${this.name}:onSalesOrderLoaded`, { sales });
|
|
463
457
|
return sales;
|
|
@@ -733,6 +727,23 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
733
727
|
...(discountList || []).filter((discount) => !historyIds.has(discount.id))
|
|
734
728
|
];
|
|
735
729
|
}
|
|
730
|
+
shouldSkipAutoApplyFetchedDiscountsInEditMode(params) {
|
|
731
|
+
if (params.discountAction !== "edit")
|
|
732
|
+
return false;
|
|
733
|
+
if (!params.products.length)
|
|
734
|
+
return false;
|
|
735
|
+
const hasDraftProduct = params.products.some((product) => !this.isPersistedOrderProduct(product));
|
|
736
|
+
if (hasDraftProduct)
|
|
737
|
+
return false;
|
|
738
|
+
const hasSelectedDiscount = params.currentDiscountList.some(
|
|
739
|
+
(discount) => discount.isSelected || discount.isEditMode || discount.isManualSelect
|
|
740
|
+
);
|
|
741
|
+
if (hasSelectedDiscount)
|
|
742
|
+
return false;
|
|
743
|
+
return !params.nextDiscountList.some(
|
|
744
|
+
(discount) => discount.isSelected || discount.isEditMode || discount.isManualSelect
|
|
745
|
+
);
|
|
746
|
+
}
|
|
736
747
|
mergeCurrentDiscountSelectionState(discountList, currentDiscountList) {
|
|
737
748
|
if (!currentDiscountList.length)
|
|
738
749
|
return discountList;
|
|
@@ -811,6 +822,26 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
811
822
|
currentDiscountList
|
|
812
823
|
);
|
|
813
824
|
await (discountModule == null ? void 0 : discountModule.setDiscountList(nextDiscountList));
|
|
825
|
+
const shouldSkipAutoApplyFetchedDiscounts = this.shouldSkipAutoApplyFetchedDiscountsInEditMode({
|
|
826
|
+
discountAction,
|
|
827
|
+
products: tempOrder.products || [],
|
|
828
|
+
currentDiscountList,
|
|
829
|
+
nextDiscountList
|
|
830
|
+
});
|
|
831
|
+
if (shouldSkipAutoApplyFetchedDiscounts) {
|
|
832
|
+
const summary2 = await this.store.order.recalculateSummary({ createIfMissing: true });
|
|
833
|
+
this.store.order.persistTempOrder();
|
|
834
|
+
await this.effectsEmit("onDiscountApplied", {
|
|
835
|
+
productList: tempOrder.products || [],
|
|
836
|
+
discountList: nextDiscountList,
|
|
837
|
+
selectedDiscountList: tempOrder.discount_list || [],
|
|
838
|
+
tempOrder
|
|
839
|
+
});
|
|
840
|
+
return {
|
|
841
|
+
productList: tempOrder.products || [],
|
|
842
|
+
discountList: nextDiscountList
|
|
843
|
+
};
|
|
844
|
+
}
|
|
814
845
|
if (rulesModule) {
|
|
815
846
|
const holders = ((_l = tempOrder.holder) == null ? void 0 : _l.form_record_id) ? [{ form_record_id: tempOrder.holder.form_record_id }] : [];
|
|
816
847
|
const result = rulesModule.calcDiscount({
|
|
@@ -1173,8 +1204,14 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1173
1204
|
if (!this.store.order)
|
|
1174
1205
|
throw new Error("order 模块未初始化");
|
|
1175
1206
|
const paymentRecord = payment;
|
|
1207
|
+
const paymentAmount = new import_decimal.default(paymentRecord.amount || 0);
|
|
1208
|
+
if (paymentAmount.isZero()) {
|
|
1209
|
+
this.logWarning("addOrderPayment: 支付金额为 0,跳过添加支付项", {
|
|
1210
|
+
payment: paymentRecord
|
|
1211
|
+
});
|
|
1212
|
+
return this.store.order.getOrderPayments();
|
|
1213
|
+
}
|
|
1176
1214
|
const metadata = paymentRecord.metadata && typeof paymentRecord.metadata === "object" ? { ...paymentRecord.metadata } : {};
|
|
1177
|
-
debugger;
|
|
1178
1215
|
const shopWalletPassId = (_a = this.otherParams) == null ? void 0 : _a.shop_wallet_pass_id;
|
|
1179
1216
|
if (shopWalletPassId !== void 0 && shopWalletPassId !== null) {
|
|
1180
1217
|
metadata.shop_wallet_pass_id = shopWalletPassId;
|
|
@@ -180,7 +180,6 @@ function transformBaseProductToOrderProduct(params) {
|
|
|
180
180
|
duration: payload.duration,
|
|
181
181
|
policy_id: payload.policy_id,
|
|
182
182
|
source_shop_id: payload.source_shop_id,
|
|
183
|
-
origin,
|
|
184
183
|
source_product_price: sourceProductPrice,
|
|
185
184
|
main_product_selling_price: mainProductSellingPrice,
|
|
186
185
|
main_product_original_price: mainProductOriginalPrice,
|
|
@@ -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 |
|
|
314
|
+
weekNum: 0 | 1 | 2 | 6 | 3 | 5 | 4;
|
|
315
315
|
}[]>;
|
|
316
316
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
317
317
|
private getScheduleDataByIds;
|
|
@@ -279,7 +279,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
279
279
|
* 获取当前的客户搜索条件
|
|
280
280
|
* @returns 当前搜索条件
|
|
281
281
|
*/
|
|
282
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
282
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
|
|
283
283
|
/**
|
|
284
284
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
285
285
|
* @returns 客户状态
|
|
@@ -1654,7 +1654,9 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
|
1654
1654
|
tempOrder.order_id = resourceState.lastOrderId;
|
|
1655
1655
|
}
|
|
1656
1656
|
if (tempOrder.order_id) {
|
|
1657
|
-
const res = await ((_i = this.store.order) == null ? void 0 : _i.
|
|
1657
|
+
const res = await ((_i = this.store.order) == null ? void 0 : _i.getSalesOrderByLookup({
|
|
1658
|
+
lookup: tempOrder.order_id
|
|
1659
|
+
}));
|
|
1658
1660
|
const entryPaxNumber = (_m = (_l = (_k = (_j = res == null ? void 0 : res.data) == null ? void 0 : _j.bookings) == null ? void 0 : _k.find((p) => {
|
|
1659
1661
|
var _a2;
|
|
1660
1662
|
return (_a2 = p.metadata) == null ? void 0 : _a2.collect_pax;
|