@pisell/pisellos 2.3.16 → 2.3.18
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/Order/index.d.ts +4 -1
- package/dist/modules/Order/index.js +135 -75
- package/dist/modules/SalesSummary/index.d.ts +7 -3
- package/dist/modules/SalesSummary/index.js +67 -39
- package/dist/modules/SalesSummary/types.d.ts +1 -0
- package/dist/modules/SalesSummary/utils.js +2 -1
- package/dist/modules/SurchargeList/index.d.ts +6 -4
- package/dist/modules/SurchargeList/index.js +62 -39
- package/dist/modules/SurchargeList/types.d.ts +6 -2
- package/dist/solution/BaseSales/index.js +11 -8
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +2 -1
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +2 -14
- package/lib/modules/Order/index.d.ts +4 -1
- package/lib/modules/Order/index.js +62 -7
- package/lib/modules/SalesSummary/index.d.ts +7 -3
- package/lib/modules/SalesSummary/index.js +28 -11
- package/lib/modules/SalesSummary/types.d.ts +1 -0
- package/lib/modules/SalesSummary/utils.js +2 -0
- package/lib/modules/SurchargeList/index.d.ts +6 -4
- package/lib/modules/SurchargeList/index.js +41 -21
- package/lib/modules/SurchargeList/types.d.ts +6 -2
- package/lib/solution/BaseSales/index.js +7 -5
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +2 -1
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +2 -14
- package/package.json +1 -1
|
@@ -544,6 +544,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
544
544
|
const tempOrder = this.store.tempOrder;
|
|
545
545
|
if (!tempOrder)
|
|
546
546
|
return;
|
|
547
|
+
this.syncLinkedBookingHoldersToProducts(tempOrder);
|
|
547
548
|
delete tempOrder.discount_list;
|
|
548
549
|
const discountList = ((_a = this.store.discount) == null ? void 0 : _a.getDiscountList()) || [];
|
|
549
550
|
const shouldSkipDiscountCalculation = this.shouldSkipDiscountCalculation(tempOrder);
|
|
@@ -1469,10 +1470,15 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
1469
1470
|
});
|
|
1470
1471
|
return currentAmountGap === snapshotAmountGap;
|
|
1471
1472
|
}
|
|
1472
|
-
|
|
1473
|
-
const
|
|
1474
|
-
|
|
1475
|
-
|
|
1473
|
+
hasShopDiscountChangedFromSnapshot(tempOrder, snapshot) {
|
|
1474
|
+
const snapshotSummary = snapshot.summary && typeof snapshot.summary === "object" ? snapshot.summary : {};
|
|
1475
|
+
const snapshotShopDiscount = snapshot.shop_discount ?? snapshotSummary.shop_discount;
|
|
1476
|
+
if (snapshotShopDiscount === void 0 || snapshotShopDiscount === null || snapshotShopDiscount === "") {
|
|
1477
|
+
return !new import_decimal.default(tempOrder.shop_discount || 0).equals(0);
|
|
1478
|
+
}
|
|
1479
|
+
return !new import_decimal.default(tempOrder.shop_discount || 0).equals(snapshotShopDiscount || 0);
|
|
1480
|
+
}
|
|
1481
|
+
restoreOriginalSnapshotIfProductsUnchanged(tempOrder, snapshot) {
|
|
1476
1482
|
const currentFingerprint = this.buildOrderProductsFingerprint(tempOrder.products);
|
|
1477
1483
|
if (currentFingerprint !== snapshot.productFingerprint) {
|
|
1478
1484
|
const currentStructuralFingerprint = this.buildOrderProductsStructuralFingerprint(tempOrder.products);
|
|
@@ -1787,6 +1793,47 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
1787
1793
|
const records = Array.isArray(source) ? source : [source];
|
|
1788
1794
|
return records.filter((record) => record !== void 0 && record !== null && record !== "");
|
|
1789
1795
|
}
|
|
1796
|
+
setProductHolderFromBooking(product, booking) {
|
|
1797
|
+
if (!product || !booking)
|
|
1798
|
+
return;
|
|
1799
|
+
const holderRecords = this.collectBookingHolderRecords(booking);
|
|
1800
|
+
if (!product.metadata || typeof product.metadata !== "object") {
|
|
1801
|
+
product.metadata = {};
|
|
1802
|
+
}
|
|
1803
|
+
product.metadata.holder_id = holderRecords.length > 0 ? holderRecords : null;
|
|
1804
|
+
}
|
|
1805
|
+
syncLinkedBookingHoldersToProducts(tempOrder) {
|
|
1806
|
+
const bookings = tempOrder.bookings || [];
|
|
1807
|
+
const products = tempOrder.products || [];
|
|
1808
|
+
if (!bookings.length || !products.length)
|
|
1809
|
+
return;
|
|
1810
|
+
const bookingByProductUid = /* @__PURE__ */ new Map();
|
|
1811
|
+
const bookingByBookingUid = /* @__PURE__ */ new Map();
|
|
1812
|
+
bookings.forEach((booking) => {
|
|
1813
|
+
var _a, _b;
|
|
1814
|
+
if (!booking || typeof booking !== "object")
|
|
1815
|
+
return;
|
|
1816
|
+
const productUid = booking.product_uid || ((_a = booking.metadata) == null ? void 0 : _a.product_uid);
|
|
1817
|
+
if (productUid !== void 0 && productUid !== null && String(productUid) !== "") {
|
|
1818
|
+
bookingByProductUid.set(String(productUid), booking);
|
|
1819
|
+
}
|
|
1820
|
+
const bookingUid = ((_b = booking.metadata) == null ? void 0 : _b.unique_identification_number) || booking.booking_uid;
|
|
1821
|
+
if (bookingUid !== void 0 && bookingUid !== null && String(bookingUid) !== "") {
|
|
1822
|
+
bookingByBookingUid.set(String(bookingUid), booking);
|
|
1823
|
+
}
|
|
1824
|
+
});
|
|
1825
|
+
products.forEach((product) => {
|
|
1826
|
+
var _a, _b;
|
|
1827
|
+
if (!product || typeof product !== "object")
|
|
1828
|
+
return;
|
|
1829
|
+
const productUid = ((_a = product.metadata) == null ? void 0 : _a.unique_identification_number) || product.unique_identification_number;
|
|
1830
|
+
const bookingUid = product.booking_uid || ((_b = product.metadata) == null ? void 0 : _b.booking_uid);
|
|
1831
|
+
const linkedBooking = (productUid !== void 0 && productUid !== null && String(productUid) !== "" ? bookingByProductUid.get(String(productUid)) : void 0) || (bookingUid !== void 0 && bookingUid !== null && String(bookingUid) !== "" ? bookingByBookingUid.get(String(bookingUid)) : void 0);
|
|
1832
|
+
if (linkedBooking) {
|
|
1833
|
+
this.setProductHolderFromBooking(product, linkedBooking);
|
|
1834
|
+
}
|
|
1835
|
+
});
|
|
1836
|
+
}
|
|
1790
1837
|
/**
|
|
1791
1838
|
* 按 form_record 顺序读取 booking holder 的主字段名称。
|
|
1792
1839
|
*
|
|
@@ -1866,6 +1913,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
1866
1913
|
if (nextHolder || hasHolderSource || bookings.length === 0) {
|
|
1867
1914
|
tempOrder.holder = nextHolder;
|
|
1868
1915
|
}
|
|
1916
|
+
this.syncLinkedBookingHoldersToProducts(tempOrder);
|
|
1869
1917
|
}
|
|
1870
1918
|
getBookingUniqueIdentificationNumber(booking) {
|
|
1871
1919
|
var _a;
|
|
@@ -1931,14 +1979,18 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
1931
1979
|
return this.applyLastOrderDepositSnapshot(tempOrder, nextSummary);
|
|
1932
1980
|
}
|
|
1933
1981
|
async recalculateSummary(options) {
|
|
1982
|
+
var _a;
|
|
1934
1983
|
const tempOrder = (options == null ? void 0 : options.createIfMissing) ? this.ensureTempOrder() : this.store.tempOrder;
|
|
1935
1984
|
if (!tempOrder)
|
|
1936
1985
|
return null;
|
|
1937
1986
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
1938
|
-
const
|
|
1987
|
+
const originalSnapshot = this.getOriginalSalesSnapshot(tempOrder);
|
|
1988
|
+
const hasShopDiscountChanged = originalSnapshot ? this.hasShopDiscountChangedFromSnapshot(tempOrder, originalSnapshot) : false;
|
|
1989
|
+
const shouldReuseOriginalSnapshot = originalSnapshot && !hasShopDiscountChanged;
|
|
1990
|
+
const snapshotSummary = shouldReuseOriginalSnapshot ? this.restoreOriginalSnapshotIfProductsUnchanged(tempOrder, originalSnapshot) : null;
|
|
1939
1991
|
if (snapshotSummary)
|
|
1940
1992
|
return snapshotSummary;
|
|
1941
|
-
const shouldFullRecalculateFromSnapshot = Boolean(
|
|
1993
|
+
const shouldFullRecalculateFromSnapshot = Boolean(originalSnapshot);
|
|
1942
1994
|
const summaryProducts = shouldFullRecalculateFromSnapshot ? (0, import_lodash_es.cloneDeep)(tempOrder.products || []) : tempOrder.products;
|
|
1943
1995
|
if (shouldFullRecalculateFromSnapshot) {
|
|
1944
1996
|
this.clearPersistedAmountFieldsForFullRecalc(summaryProducts || []);
|
|
@@ -1985,7 +2037,8 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
1985
2037
|
const salesSummaryResult = await salesSummary.getSummary({
|
|
1986
2038
|
products: summaryProducts,
|
|
1987
2039
|
isPriceIncludeTax: tempOrder.is_price_include_tax,
|
|
1988
|
-
shopDiscount: tempOrder.shop_discount
|
|
2040
|
+
shopDiscount: tempOrder.shop_discount,
|
|
2041
|
+
...((_a = this.otherParams) == null ? void 0 : _a.channel) ? { channel: this.otherParams.channel } : {}
|
|
1989
2042
|
});
|
|
1990
2043
|
if (shouldFullRecalculateFromSnapshot) {
|
|
1991
2044
|
tempOrder.products = summaryProducts;
|
|
@@ -3904,6 +3957,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
3904
3957
|
products: (0, import_lodash_es.cloneDeep)(nextTempOrder.products || []),
|
|
3905
3958
|
payments: (0, import_lodash_es.cloneDeep)(nextTempOrder.payments || []),
|
|
3906
3959
|
surcharges: (0, import_lodash_es.cloneDeep)(nextTempOrder.surcharges || []),
|
|
3960
|
+
shop_discount: nextTempOrder.shop_discount || "0.00",
|
|
3907
3961
|
productFingerprint: this.buildOrderProductsFingerprint(nextTempOrder.products || [])
|
|
3908
3962
|
}
|
|
3909
3963
|
};
|
|
@@ -4069,6 +4123,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
4069
4123
|
product.booking_uid = linkedBookingUid;
|
|
4070
4124
|
product.metadata.booking_uid = linkedBookingUid;
|
|
4071
4125
|
});
|
|
4126
|
+
this.syncLinkedBookingHoldersToProducts(tempOrder);
|
|
4072
4127
|
}
|
|
4073
4128
|
pickHydratedDisplayText(value) {
|
|
4074
4129
|
if (value === void 0 || value === null)
|
|
@@ -9,16 +9,19 @@ export declare class SalesSummaryModule extends BaseModule implements Module, Sa
|
|
|
9
9
|
private store;
|
|
10
10
|
private request;
|
|
11
11
|
private surchargeListModuleName;
|
|
12
|
+
private otherParams;
|
|
13
|
+
private surchargeListChannel;
|
|
12
14
|
constructor(name?: string, version?: string);
|
|
13
15
|
initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
|
|
14
16
|
/**
|
|
15
|
-
* 更新父级解决方案透传的运行态参数,并在 surcharge
|
|
17
|
+
* 更新父级解决方案透传的运行态参数,并在 surcharge 模块名或渠道变化时刷新附加费列表。
|
|
16
18
|
*
|
|
17
19
|
* @example
|
|
18
|
-
* await salesSummaryModule.updateOtherParams({ surchargeListModuleName: 'custom_surchargeList' });
|
|
20
|
+
* await salesSummaryModule.updateOtherParams({ channel: 'pos', surchargeListModuleName: 'custom_surchargeList' });
|
|
19
21
|
*/
|
|
20
22
|
updateOtherParams(params: Record<string, any>): Promise<void>;
|
|
21
|
-
|
|
23
|
+
private resolveChannel;
|
|
24
|
+
getSurchargeList(channel?: string): Promise<void>;
|
|
22
25
|
private getAppData;
|
|
23
26
|
private getTaxConfig;
|
|
24
27
|
getSummary(params: {
|
|
@@ -26,6 +29,7 @@ export declare class SalesSummaryModule extends BaseModule implements Module, Sa
|
|
|
26
29
|
isPriceIncludeTax?: number;
|
|
27
30
|
taxRate?: number;
|
|
28
31
|
shopDiscount?: string | number;
|
|
32
|
+
channel?: string;
|
|
29
33
|
}): Promise<{
|
|
30
34
|
tax_title: string;
|
|
31
35
|
tax_rate: number | undefined;
|
|
@@ -33,12 +33,15 @@ var salesSummaryDataKeys = {
|
|
|
33
33
|
taxTitle: "tax_title",
|
|
34
34
|
taxCountryCode: "tax_country_code"
|
|
35
35
|
};
|
|
36
|
+
var DEFAULT_SURCHARGE_CHANNEL = "online-store";
|
|
36
37
|
var SalesSummaryModule = class extends import_BaseModule.BaseModule {
|
|
37
38
|
constructor(name, version) {
|
|
38
39
|
super(name, version);
|
|
39
40
|
this.defaultName = "salesSummary";
|
|
40
41
|
this.defaultVersion = "1.0.0";
|
|
41
42
|
this.surchargeListModuleName = "surchargeList";
|
|
43
|
+
this.otherParams = {};
|
|
44
|
+
this.surchargeListChannel = DEFAULT_SURCHARGE_CHANNEL;
|
|
42
45
|
}
|
|
43
46
|
async initialize(core, options) {
|
|
44
47
|
var _a, _b, _c;
|
|
@@ -46,9 +49,10 @@ var SalesSummaryModule = class extends import_BaseModule.BaseModule {
|
|
|
46
49
|
this.store = options.store;
|
|
47
50
|
this.appPlugin = this.core.getPlugin("app");
|
|
48
51
|
this.request = this.core.getPlugin("request");
|
|
52
|
+
this.otherParams = options.otherParams || {};
|
|
49
53
|
this.store.surchargeList = ((_a = options.initialState) == null ? void 0 : _a.surchargeList) || [];
|
|
50
54
|
this.store.summary = ((_b = options.initialState) == null ? void 0 : _b.summary) || (0, import_utils.createEmptySalesSummary)();
|
|
51
|
-
this.surchargeListModuleName = ((_c =
|
|
55
|
+
this.surchargeListModuleName = ((_c = this.otherParams) == null ? void 0 : _c.surchargeListModuleName) || "surchargeList";
|
|
52
56
|
if (!this.appPlugin) {
|
|
53
57
|
throw new Error("SalesSummaryModule 需要 app 插件支持");
|
|
54
58
|
}
|
|
@@ -58,41 +62,50 @@ var SalesSummaryModule = class extends import_BaseModule.BaseModule {
|
|
|
58
62
|
await this.getSurchargeList();
|
|
59
63
|
}
|
|
60
64
|
/**
|
|
61
|
-
* 更新父级解决方案透传的运行态参数,并在 surcharge
|
|
65
|
+
* 更新父级解决方案透传的运行态参数,并在 surcharge 模块名或渠道变化时刷新附加费列表。
|
|
62
66
|
*
|
|
63
67
|
* @example
|
|
64
|
-
* await salesSummaryModule.updateOtherParams({ surchargeListModuleName: 'custom_surchargeList' });
|
|
68
|
+
* await salesSummaryModule.updateOtherParams({ channel: 'pos', surchargeListModuleName: 'custom_surchargeList' });
|
|
65
69
|
*/
|
|
66
70
|
async updateOtherParams(params) {
|
|
71
|
+
const previousChannel = this.resolveChannel();
|
|
67
72
|
const nextSurchargeListModuleName = (params == null ? void 0 : params.surchargeListModuleName) || "surchargeList";
|
|
68
|
-
|
|
69
|
-
|
|
73
|
+
const nextChannel = this.resolveChannel(params);
|
|
74
|
+
const shouldReload = nextSurchargeListModuleName !== this.surchargeListModuleName || nextChannel !== previousChannel;
|
|
75
|
+
this.otherParams = params || {};
|
|
70
76
|
this.surchargeListModuleName = nextSurchargeListModuleName;
|
|
71
|
-
|
|
77
|
+
if (shouldReload) {
|
|
78
|
+
await this.getSurchargeList(nextChannel);
|
|
79
|
+
}
|
|
72
80
|
}
|
|
73
|
-
|
|
81
|
+
resolveChannel(params = this.otherParams) {
|
|
82
|
+
return (params == null ? void 0 : params.channel) || DEFAULT_SURCHARGE_CHANNEL;
|
|
83
|
+
}
|
|
84
|
+
async getSurchargeList(channel = this.resolveChannel()) {
|
|
74
85
|
try {
|
|
75
86
|
const surchargeListModule = this.core.getModule(
|
|
76
87
|
this.surchargeListModuleName
|
|
77
88
|
);
|
|
78
89
|
if (surchargeListModule == null ? void 0 : surchargeListModule.getSurchargeList) {
|
|
79
|
-
this.store.surchargeList = await surchargeListModule.getSurchargeList();
|
|
90
|
+
this.store.surchargeList = await surchargeListModule.getSurchargeList({ channel });
|
|
91
|
+
this.surchargeListChannel = channel;
|
|
80
92
|
return;
|
|
81
93
|
}
|
|
82
94
|
const surchargeList = await this.request.get(
|
|
83
95
|
"/order/custom-surcharge/available/v2",
|
|
84
96
|
{
|
|
85
|
-
|
|
86
|
-
channel: "online-store",
|
|
97
|
+
channel,
|
|
87
98
|
is_assemble_product_data: 1,
|
|
88
99
|
is_assemble_schedule_data: 1,
|
|
89
100
|
with: ["relationSchedule"]
|
|
90
101
|
}
|
|
91
102
|
);
|
|
92
103
|
this.store.surchargeList = (surchargeList == null ? void 0 : surchargeList.data) || [];
|
|
104
|
+
this.surchargeListChannel = channel;
|
|
93
105
|
} catch (error) {
|
|
94
106
|
console.warn("[SalesSummaryModule] 加载附加费配置失败", error);
|
|
95
107
|
this.store.surchargeList = [];
|
|
108
|
+
this.surchargeListChannel = channel;
|
|
96
109
|
}
|
|
97
110
|
}
|
|
98
111
|
getAppData(key) {
|
|
@@ -114,7 +127,11 @@ var SalesSummaryModule = class extends import_BaseModule.BaseModule {
|
|
|
114
127
|
}
|
|
115
128
|
async getSummary(params) {
|
|
116
129
|
var _a, _b;
|
|
117
|
-
const { products = [], isPriceIncludeTax, taxRate, shopDiscount } = params;
|
|
130
|
+
const { products = [], isPriceIncludeTax, taxRate, shopDiscount, channel } = params;
|
|
131
|
+
const summaryChannel = channel || this.resolveChannel();
|
|
132
|
+
if (summaryChannel !== this.surchargeListChannel) {
|
|
133
|
+
await this.getSurchargeList(summaryChannel);
|
|
134
|
+
}
|
|
118
135
|
const taxConfig = this.getTaxConfig();
|
|
119
136
|
const summarySchedule = this.core.getModule(
|
|
120
137
|
`${this.name.split("_")[0]}_schedule`
|
|
@@ -308,6 +308,8 @@ function getFallbackAllProductSurchargeIds(surchargeList) {
|
|
|
308
308
|
return ids;
|
|
309
309
|
if (Number(config.is_all ?? 0) !== 1)
|
|
310
310
|
return ids;
|
|
311
|
+
if (Number(config.open_schedule ?? 0) === 1 && config.schedule_type !== "all")
|
|
312
|
+
return ids;
|
|
311
313
|
ids.push(id);
|
|
312
314
|
return ids;
|
|
313
315
|
}, []);
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import { Module, ModuleOptions, PisellCore } from '../../types';
|
|
2
2
|
import { BaseModule } from '../BaseModule';
|
|
3
|
-
import { SurchargeListItem, SurchargeListModuleAPI } from './types';
|
|
3
|
+
import { SurchargeListItem, SurchargeListModuleAPI, SurchargeListQuery } from './types';
|
|
4
4
|
export * from './types';
|
|
5
5
|
export declare class SurchargeListModule extends BaseModule implements Module, SurchargeListModuleAPI {
|
|
6
6
|
protected defaultName: string;
|
|
7
7
|
protected defaultVersion: string;
|
|
8
8
|
private request;
|
|
9
9
|
private store;
|
|
10
|
-
private
|
|
10
|
+
private loadingPromises;
|
|
11
|
+
private requestVersion;
|
|
11
12
|
constructor(name?: string, version?: string);
|
|
12
13
|
initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
private resolveChannel;
|
|
15
|
+
getSurchargeList(query?: SurchargeListQuery): Promise<SurchargeListItem[]>;
|
|
16
|
+
refreshSurchargeList(query?: SurchargeListQuery): Promise<SurchargeListItem[]>;
|
|
15
17
|
private loadSurchargeList;
|
|
16
18
|
}
|
|
@@ -25,15 +25,17 @@ __export(SurchargeList_exports, {
|
|
|
25
25
|
module.exports = __toCommonJS(SurchargeList_exports);
|
|
26
26
|
var import_BaseModule = require("../BaseModule");
|
|
27
27
|
__reExport(SurchargeList_exports, require("./types"), module.exports);
|
|
28
|
+
var DEFAULT_SURCHARGE_CHANNEL = "online-store";
|
|
28
29
|
var SurchargeListModule = class extends import_BaseModule.BaseModule {
|
|
29
30
|
constructor(name, version) {
|
|
30
31
|
super(name, version);
|
|
31
32
|
this.defaultName = "surchargeList";
|
|
32
33
|
this.defaultVersion = "1.0.0";
|
|
33
|
-
this.
|
|
34
|
+
this.loadingPromises = /* @__PURE__ */ new Map();
|
|
35
|
+
this.requestVersion = 0;
|
|
34
36
|
}
|
|
35
37
|
async initialize(core, options) {
|
|
36
|
-
var _a, _b, _c;
|
|
38
|
+
var _a, _b, _c, _d, _e;
|
|
37
39
|
this.core = core;
|
|
38
40
|
this.store = options.store;
|
|
39
41
|
this.request = this.core.getPlugin("request");
|
|
@@ -41,44 +43,62 @@ var SurchargeListModule = class extends import_BaseModule.BaseModule {
|
|
|
41
43
|
(_a = options.initialState) == null ? void 0 : _a.surchargeList
|
|
42
44
|
);
|
|
43
45
|
this.store.surchargeList = hasInitialSurchargeList ? (_b = options.initialState) == null ? void 0 : _b.surchargeList : [];
|
|
44
|
-
this.store.
|
|
46
|
+
this.store.channel = ((_c = options.initialState) == null ? void 0 : _c.channel) || ((_d = options.otherParams) == null ? void 0 : _d.channel) || DEFAULT_SURCHARGE_CHANNEL;
|
|
47
|
+
this.store.isLoaded = Boolean((_e = options.initialState) == null ? void 0 : _e.isLoaded) || hasInitialSurchargeList;
|
|
45
48
|
if (!this.request) {
|
|
46
49
|
throw new Error("SurchargeListModule 需要 request 插件支持");
|
|
47
50
|
}
|
|
48
51
|
}
|
|
49
|
-
|
|
50
|
-
|
|
52
|
+
resolveChannel(query) {
|
|
53
|
+
return (query == null ? void 0 : query.channel) || DEFAULT_SURCHARGE_CHANNEL;
|
|
54
|
+
}
|
|
55
|
+
async getSurchargeList(query) {
|
|
56
|
+
const channel = this.resolveChannel(query);
|
|
57
|
+
if (this.store.isLoaded && this.store.channel === channel) {
|
|
51
58
|
return this.store.surchargeList;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
59
|
+
}
|
|
60
|
+
const loadingPromise = this.loadingPromises.get(channel);
|
|
61
|
+
if (loadingPromise)
|
|
62
|
+
return loadingPromise;
|
|
63
|
+
const nextPromise = this.loadSurchargeList(channel);
|
|
64
|
+
this.loadingPromises.set(channel, nextPromise);
|
|
65
|
+
return nextPromise;
|
|
56
66
|
}
|
|
57
|
-
async refreshSurchargeList() {
|
|
58
|
-
|
|
59
|
-
|
|
67
|
+
async refreshSurchargeList(query) {
|
|
68
|
+
const channel = this.resolveChannel(query);
|
|
69
|
+
const nextPromise = this.loadSurchargeList(channel);
|
|
70
|
+
this.loadingPromises.set(channel, nextPromise);
|
|
71
|
+
return nextPromise;
|
|
60
72
|
}
|
|
61
|
-
async loadSurchargeList() {
|
|
73
|
+
async loadSurchargeList(channel) {
|
|
74
|
+
const currentRequestVersion = ++this.requestVersion;
|
|
62
75
|
try {
|
|
63
76
|
const surchargeList = await this.request.get(
|
|
64
77
|
"/order/custom-surcharge/available/v2",
|
|
65
78
|
{
|
|
66
|
-
channel
|
|
79
|
+
channel,
|
|
67
80
|
is_assemble_product_data: 1,
|
|
68
81
|
is_assemble_schedule_data: 1,
|
|
69
82
|
with: ["relationSchedule"]
|
|
70
83
|
}
|
|
71
84
|
);
|
|
72
|
-
|
|
73
|
-
this.
|
|
74
|
-
|
|
85
|
+
const nextSurchargeList = (surchargeList == null ? void 0 : surchargeList.data) || [];
|
|
86
|
+
if (currentRequestVersion === this.requestVersion) {
|
|
87
|
+
this.store.surchargeList = nextSurchargeList;
|
|
88
|
+
this.store.channel = channel;
|
|
89
|
+
this.store.isLoaded = true;
|
|
90
|
+
}
|
|
91
|
+
return nextSurchargeList;
|
|
75
92
|
} catch (error) {
|
|
76
93
|
console.warn("[SurchargeListModule] 加载附加费配置失败", error);
|
|
77
|
-
this.
|
|
78
|
-
|
|
79
|
-
|
|
94
|
+
if (currentRequestVersion === this.requestVersion) {
|
|
95
|
+
this.store.surchargeList = [];
|
|
96
|
+
this.store.channel = channel;
|
|
97
|
+
this.store.isLoaded = true;
|
|
98
|
+
}
|
|
99
|
+
return [];
|
|
80
100
|
} finally {
|
|
81
|
-
this.
|
|
101
|
+
this.loadingPromises.delete(channel);
|
|
82
102
|
}
|
|
83
103
|
}
|
|
84
104
|
};
|
|
@@ -4,8 +4,12 @@ export interface SurchargeListItem {
|
|
|
4
4
|
export interface SurchargeListState {
|
|
5
5
|
surchargeList: SurchargeListItem[];
|
|
6
6
|
isLoaded: boolean;
|
|
7
|
+
channel?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface SurchargeListQuery {
|
|
10
|
+
channel?: string;
|
|
7
11
|
}
|
|
8
12
|
export interface SurchargeListModuleAPI {
|
|
9
|
-
getSurchargeList(): Promise<SurchargeListItem[]>;
|
|
10
|
-
refreshSurchargeList(): Promise<SurchargeListItem[]>;
|
|
13
|
+
getSurchargeList(query?: SurchargeListQuery): Promise<SurchargeListItem[]>;
|
|
14
|
+
refreshSurchargeList(query?: SurchargeListQuery): Promise<SurchargeListItem[]>;
|
|
11
15
|
}
|
|
@@ -1696,15 +1696,17 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1696
1696
|
return this.store.order.discardPendingVoucherPayments();
|
|
1697
1697
|
}
|
|
1698
1698
|
getWalletProductList() {
|
|
1699
|
-
var _a, _b
|
|
1699
|
+
var _a, _b;
|
|
1700
1700
|
const tempOrder = (_a = this.store.order) == null ? void 0 : _a.getTempOrder();
|
|
1701
1701
|
if (!((_b = tempOrder == null ? void 0 : tempOrder.products) == null ? void 0 : _b.length))
|
|
1702
1702
|
return [];
|
|
1703
|
-
const
|
|
1704
|
-
const walletProducts = products.map((product) => {
|
|
1703
|
+
const walletProducts = tempOrder == null ? void 0 : tempOrder.products.map((product) => {
|
|
1705
1704
|
const metadata = product.metadata || {};
|
|
1705
|
+
const rawHolderId = product.holder_id ?? metadata.holder_id;
|
|
1706
|
+
const holderIdValue = Array.isArray(rawHolderId) ? rawHolderId[0] : rawHolderId;
|
|
1707
|
+
const holder_id = Number.isInteger(Number(holderIdValue)) ? Number(holderIdValue) : void 0;
|
|
1706
1708
|
return {
|
|
1707
|
-
product_id: product.product_id,
|
|
1709
|
+
product_id: product.product_id || 0,
|
|
1708
1710
|
product_variant_id: String(product.product_variant_id ?? ""),
|
|
1709
1711
|
quantity: product.num || 1,
|
|
1710
1712
|
is_price_include_tax: tempOrder.is_price_include_tax,
|
|
@@ -1712,7 +1714,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1712
1714
|
tax_fee: product.tax_fee,
|
|
1713
1715
|
selling_price: Number(product.selling_price || 0),
|
|
1714
1716
|
discount_list: product.discount_list || [],
|
|
1715
|
-
holder_id
|
|
1717
|
+
holder_id,
|
|
1716
1718
|
original_price: product.original_price,
|
|
1717
1719
|
main_product_original_price: metadata.main_product_original_price ?? product.original_price,
|
|
1718
1720
|
main_product_selling_price: metadata.main_product_selling_price ?? product.selling_price,
|
|
@@ -88,7 +88,8 @@ function normalizeBundleItems(bundleItems, preferPriceField = false) {
|
|
|
88
88
|
price: bundleItem.price ?? unitStr,
|
|
89
89
|
bundle_selling_price: unitStr,
|
|
90
90
|
original_price: bundleItem.original_price ?? bundleItem.product_price ?? bundleItem.price ?? unitStr,
|
|
91
|
-
option: normalizeOptionItems(bundleItem == null ? void 0 : bundleItem.option)
|
|
91
|
+
option: normalizeOptionItems(bundleItem == null ? void 0 : bundleItem.option),
|
|
92
|
+
discount_list: preferPriceField ? [] : bundleItem.discount_list
|
|
92
93
|
};
|
|
93
94
|
normalizedItem.bundle_selling_price = (0, import_utils.getBundleSellingMagnitude)(magnitudeSource).toFixed(2);
|
|
94
95
|
if ((normalizedItem.price_type ?? normalizedItem.custom_price_type) === "markdown" && (normalizedItem.price_type_ext === "" || normalizedItem.price_type_ext === void 0 || normalizedItem.price_type_ext === null)) {
|
|
@@ -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 | 3 | 4 | 5 | 6;
|
|
315
315
|
}[]>;
|
|
316
316
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
317
317
|
private getScheduleDataByIds;
|
|
@@ -322,7 +322,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
322
322
|
* 获取当前的客户搜索条件
|
|
323
323
|
* @returns 当前搜索条件
|
|
324
324
|
*/
|
|
325
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
325
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
|
|
326
326
|
/**
|
|
327
327
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
328
328
|
* @returns 客户状态
|
|
@@ -441,19 +441,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
441
441
|
* 加车两阶段主决策(规格弹窗 / 资源编辑 / 直接加车)。
|
|
442
442
|
* 与 ticketBooking `handleSelectProduct` + `handleBooking4Service` 等价。
|
|
443
443
|
*/
|
|
444
|
-
decideAddProduct(item: any, options?: Partial<AddProductDecideContext>):
|
|
445
|
-
action: "reloadCatalog";
|
|
446
|
-
} | {
|
|
447
|
-
action: "add";
|
|
448
|
-
cacheItem: any;
|
|
449
|
-
} | {
|
|
450
|
-
action: "requiresDetail";
|
|
451
|
-
payload: AddProductRequiresDetailPayload;
|
|
452
|
-
} | {
|
|
453
|
-
action: "requiresBookingEdit";
|
|
454
|
-
cacheItem: any;
|
|
455
|
-
payload: import("./utils/addProductDecision").AddProductRequiresBookingEditPayload;
|
|
456
|
-
};
|
|
444
|
+
decideAddProduct(item: any, options?: Partial<AddProductDecideContext>): import("./utils/addProductDecision").AddProductDecision;
|
|
457
445
|
/** 规格弹窗 callback 后的第二段决策。 */
|
|
458
446
|
decideAfterDetail(cacheItem: any, options?: Partial<AddProductDecideContext>): import("./utils/addProductDecision").AddProductDecision;
|
|
459
447
|
/**
|