@pisell/pisellos 2.3.1 → 2.3.2
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 +9 -0
- package/dist/modules/Order/index.js +448 -369
- package/dist/modules/Order/types.d.ts +2 -0
- package/dist/modules/Quotation/index.d.ts +16 -2
- package/dist/modules/Quotation/index.js +71 -38
- package/dist/modules/Quotation/types.d.ts +14 -0
- package/dist/modules/SalesSummary/index.d.ts +1 -0
- package/dist/modules/SalesSummary/index.js +7 -4
- package/dist/modules/Schedule/index.d.ts +4 -0
- package/dist/modules/Schedule/index.js +31 -1
- package/dist/modules/Schedule/types.d.ts +2 -0
- package/dist/server/index.js +13 -12
- package/dist/server/modules/products/index.d.ts +4 -0
- package/dist/server/modules/products/index.js +76 -45
- package/dist/server/modules/quotation/index.d.ts +39 -0
- package/dist/server/modules/quotation/index.js +278 -66
- package/dist/server/modules/schedule/index.d.ts +2 -0
- package/dist/server/modules/schedule/index.js +10 -2
- package/dist/solution/BaseSales/index.d.ts +10 -1
- package/dist/solution/BaseSales/index.js +825 -528
- package/dist/solution/BaseSales/types.d.ts +7 -0
- package/dist/solution/BaseSales/utils/quotationPrice.d.ts +12 -1
- package/dist/solution/BaseSales/utils/quotationPrice.js +16 -3
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/lib/modules/Order/index.d.ts +9 -0
- package/lib/modules/Order/index.js +48 -7
- package/lib/modules/Order/types.d.ts +2 -0
- package/lib/modules/Quotation/index.d.ts +16 -2
- package/lib/modules/Quotation/index.js +49 -13
- package/lib/modules/Quotation/types.d.ts +14 -0
- package/lib/modules/SalesSummary/index.d.ts +1 -0
- package/lib/modules/SalesSummary/index.js +4 -3
- package/lib/modules/Schedule/index.d.ts +4 -0
- package/lib/modules/Schedule/index.js +21 -0
- package/lib/modules/Schedule/types.d.ts +2 -0
- package/lib/server/index.js +1 -1
- package/lib/server/modules/products/index.d.ts +4 -0
- package/lib/server/modules/products/index.js +43 -19
- package/lib/server/modules/quotation/index.d.ts +39 -0
- package/lib/server/modules/quotation/index.js +179 -1
- package/lib/server/modules/schedule/index.d.ts +2 -0
- package/lib/server/modules/schedule/index.js +8 -1
- package/lib/solution/BaseSales/index.d.ts +10 -1
- package/lib/solution/BaseSales/index.js +218 -19
- package/lib/solution/BaseSales/types.d.ts +7 -0
- package/lib/solution/BaseSales/utils/quotationPrice.d.ts +12 -1
- package/lib/solution/BaseSales/utils/quotationPrice.js +15 -3
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -154,6 +154,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
154
154
|
this.currentSalesDetail = null;
|
|
155
155
|
this.discountConfigCacheKey = null;
|
|
156
156
|
this.hasManualDiscountSelection = false;
|
|
157
|
+
this.reusedSharedSubModuleNames = /* @__PURE__ */ new Set();
|
|
157
158
|
this.paymentMethodsCache = [];
|
|
158
159
|
}
|
|
159
160
|
/**
|
|
@@ -163,6 +164,23 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
163
164
|
getRegisteredModuleNames() {
|
|
164
165
|
return ["products", "order", "salesSummary", "schedule", "payment", "quotation"];
|
|
165
166
|
}
|
|
167
|
+
getReusableSharedSubModule(moduleName) {
|
|
168
|
+
var _a;
|
|
169
|
+
if (moduleName !== "schedule" && moduleName !== "quotation")
|
|
170
|
+
return null;
|
|
171
|
+
return ((_a = this.core) == null ? void 0 : _a.getModule(moduleName)) || null;
|
|
172
|
+
}
|
|
173
|
+
isScheduleListLoaded(scheduleModule) {
|
|
174
|
+
if (!scheduleModule)
|
|
175
|
+
return false;
|
|
176
|
+
if (typeof scheduleModule.isScheduleListLoaded === "function") {
|
|
177
|
+
return scheduleModule.isScheduleListLoaded();
|
|
178
|
+
}
|
|
179
|
+
if (typeof scheduleModule.getScheduleList === "function") {
|
|
180
|
+
return Array.isArray(scheduleModule.getScheduleList());
|
|
181
|
+
}
|
|
182
|
+
return false;
|
|
183
|
+
}
|
|
166
184
|
/**
|
|
167
185
|
* 记录信息日志
|
|
168
186
|
*/
|
|
@@ -242,13 +260,32 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
242
260
|
return void 0;
|
|
243
261
|
return customerId;
|
|
244
262
|
}
|
|
263
|
+
normalizePriceContextCustomerId(customerId) {
|
|
264
|
+
if (customerId === void 0 || customerId === null || customerId === "")
|
|
265
|
+
return null;
|
|
266
|
+
return String(customerId);
|
|
267
|
+
}
|
|
245
268
|
applyQuotationScheduleResolver(quotation) {
|
|
246
269
|
const scheduleModule = this.store.schedule;
|
|
247
270
|
if (!scheduleModule)
|
|
248
271
|
return;
|
|
272
|
+
const scheduleById = /* @__PURE__ */ new Map();
|
|
273
|
+
const scheduleList = typeof scheduleModule.getScheduleList === "function" ? scheduleModule.getScheduleList() : [];
|
|
274
|
+
if (Array.isArray(scheduleList)) {
|
|
275
|
+
scheduleList.forEach((schedule) => {
|
|
276
|
+
if ((schedule == null ? void 0 : schedule.id) !== void 0 && (schedule == null ? void 0 : schedule.id) !== null) {
|
|
277
|
+
scheduleById.set(String(schedule.id), schedule);
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
}
|
|
249
281
|
quotation.setScheduleResolver((id) => {
|
|
250
|
-
var _a;
|
|
251
|
-
const
|
|
282
|
+
var _a, _b;
|
|
283
|
+
const scheduleId = String(id);
|
|
284
|
+
if (scheduleById.has(scheduleId))
|
|
285
|
+
return scheduleById.get(scheduleId);
|
|
286
|
+
const schedules = ((_a = scheduleModule.getScheduleListByIds) == null ? void 0 : _a.call(scheduleModule, [id])) || ((_b = scheduleModule.getScheduleByIds) == null ? void 0 : _b.call(scheduleModule, [id])) || [];
|
|
287
|
+
if (schedules[0])
|
|
288
|
+
scheduleById.set(scheduleId, schedules[0]);
|
|
252
289
|
return schedules[0];
|
|
253
290
|
});
|
|
254
291
|
}
|
|
@@ -294,24 +331,25 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
294
331
|
schedule_datetime: now.format("YYYY-MM-DD HH:mm:ss")
|
|
295
332
|
};
|
|
296
333
|
}
|
|
297
|
-
async
|
|
334
|
+
async loadProductsForPriceQuery(params) {
|
|
298
335
|
var _a, _b;
|
|
299
|
-
const
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
336
|
+
const ids = Array.from(new Set(
|
|
337
|
+
params.ids.filter((id) => Number.isFinite(id))
|
|
338
|
+
));
|
|
339
|
+
const productsById = /* @__PURE__ */ new Map();
|
|
340
|
+
if (!ids.length || !this.request)
|
|
341
|
+
return productsById;
|
|
304
342
|
try {
|
|
305
343
|
const response = await this.request.post("/product/query", {
|
|
306
|
-
ids
|
|
344
|
+
ids,
|
|
307
345
|
open_quotation: 1,
|
|
308
346
|
open_bundle: 1,
|
|
309
347
|
status: "published",
|
|
310
348
|
num: 1,
|
|
311
349
|
skip: 1,
|
|
312
|
-
customer_id: customerId,
|
|
313
|
-
schedule_date: schedule.schedule_date,
|
|
314
|
-
schedule_datetime: schedule.schedule_datetime,
|
|
350
|
+
customer_id: params.customerId,
|
|
351
|
+
schedule_date: params.schedule.schedule_date,
|
|
352
|
+
schedule_datetime: params.schedule.schedule_datetime,
|
|
315
353
|
application_code: params.channel || ((_a = this.otherParams) == null ? void 0 : _a.channel)
|
|
316
354
|
}, {
|
|
317
355
|
osServer: true,
|
|
@@ -320,16 +358,35 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
320
358
|
});
|
|
321
359
|
const list = ((_b = response == null ? void 0 : response.data) == null ? void 0 : _b.list) || (response == null ? void 0 : response.list) || [];
|
|
322
360
|
if (!Array.isArray(list))
|
|
323
|
-
return
|
|
324
|
-
|
|
361
|
+
return productsById;
|
|
362
|
+
list.forEach((item) => {
|
|
363
|
+
const productId = Number((item == null ? void 0 : item.id) ?? (item == null ? void 0 : item.product_id));
|
|
364
|
+
if (Number.isFinite(productId))
|
|
365
|
+
productsById.set(productId, item);
|
|
366
|
+
});
|
|
367
|
+
return productsById;
|
|
325
368
|
} catch (error) {
|
|
326
|
-
this.logWarning("
|
|
327
|
-
|
|
369
|
+
this.logWarning("loadProductsForPriceQuery: 商品批量重查失败,使用入参 fallback", {
|
|
370
|
+
ids,
|
|
328
371
|
error: error instanceof Error ? error.message : String(error)
|
|
329
372
|
});
|
|
330
|
-
return
|
|
373
|
+
return productsById;
|
|
331
374
|
}
|
|
332
375
|
}
|
|
376
|
+
async loadProductForPriceQuery(params, customerId) {
|
|
377
|
+
const product = params.product || {};
|
|
378
|
+
const productId = this.getPriceQueryProductId(product);
|
|
379
|
+
if (productId === null || !this.request)
|
|
380
|
+
return null;
|
|
381
|
+
const schedule = this.getPriceQuerySchedule(params);
|
|
382
|
+
const productsById = await this.loadProductsForPriceQuery({
|
|
383
|
+
ids: [productId],
|
|
384
|
+
schedule,
|
|
385
|
+
customerId,
|
|
386
|
+
channel: params.channel
|
|
387
|
+
});
|
|
388
|
+
return productsById.get(productId) || null;
|
|
389
|
+
}
|
|
333
390
|
getAuthoritativeBundleItems(product) {
|
|
334
391
|
if (Array.isArray(product == null ? void 0 : product.product_bundle))
|
|
335
392
|
return product.product_bundle;
|
|
@@ -455,7 +512,10 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
455
512
|
async syncOtherParamsToSubModules(changedParams, { cover = false } = {}) {
|
|
456
513
|
const nextSubModuleOtherParams = this.buildSubModuleOtherParams();
|
|
457
514
|
await Promise.all(
|
|
458
|
-
Object.
|
|
515
|
+
Object.entries(this.store).map(async ([moduleName, subModule]) => {
|
|
516
|
+
if (this.reusedSharedSubModuleNames.has(moduleName)) {
|
|
517
|
+
return;
|
|
518
|
+
}
|
|
459
519
|
const targetModule = subModule;
|
|
460
520
|
if (!targetModule || typeof targetModule.updateOtherParams !== "function") {
|
|
461
521
|
return;
|
|
@@ -535,6 +595,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
535
595
|
this.initializeOptions = options || {};
|
|
536
596
|
this.otherParams = options.otherParams || {};
|
|
537
597
|
this.cacheId = (_a = this.otherParams) == null ? void 0 : _a.cacheId;
|
|
598
|
+
this.reusedSharedSubModuleNames.clear();
|
|
538
599
|
this.window = core.getPlugin("window");
|
|
539
600
|
this.request = core.getPlugin("request");
|
|
540
601
|
this.appPlugin = core.getPlugin("app");
|
|
@@ -546,6 +607,12 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
546
607
|
const targetCacheData = this.readSessionCacheData();
|
|
547
608
|
const moduleNames = this.getRegisteredModuleNames();
|
|
548
609
|
moduleNames.forEach((step) => {
|
|
610
|
+
const reusedModule = this.getReusableSharedSubModule(step);
|
|
611
|
+
if (reusedModule) {
|
|
612
|
+
this.store[step] = reusedModule;
|
|
613
|
+
this.reusedSharedSubModuleNames.add(step);
|
|
614
|
+
return;
|
|
615
|
+
}
|
|
549
616
|
const targetModule = this.createSubModule(step);
|
|
550
617
|
if (!targetModule) {
|
|
551
618
|
throw new Error(`模块 ${step} 不存在`);
|
|
@@ -558,7 +625,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
558
625
|
otherParams: this.buildSubModuleOtherParams()
|
|
559
626
|
});
|
|
560
627
|
});
|
|
561
|
-
if (this.store.schedule) {
|
|
628
|
+
if (this.store.schedule && !this.isScheduleListLoaded(this.store.schedule)) {
|
|
562
629
|
await this.store.schedule.loadAllSchedule();
|
|
563
630
|
}
|
|
564
631
|
if (this.store.order && typeof ((_b = this.otherParams) == null ? void 0 : _b.enableTempOrderPersist) === "boolean") {
|
|
@@ -571,6 +638,8 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
571
638
|
}
|
|
572
639
|
async destroy() {
|
|
573
640
|
Object.keys(this.store).forEach((key) => {
|
|
641
|
+
if (this.reusedSharedSubModuleNames.has(key))
|
|
642
|
+
return;
|
|
574
643
|
const sub = this.store[key];
|
|
575
644
|
if (sub && typeof sub.destroy === "function") {
|
|
576
645
|
try {
|
|
@@ -1719,6 +1788,126 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1719
1788
|
quotation
|
|
1720
1789
|
});
|
|
1721
1790
|
}
|
|
1791
|
+
getQuotationCustomerScopeInfo() {
|
|
1792
|
+
const quotation = this.store.quotation;
|
|
1793
|
+
if (quotation && typeof quotation.getQuotationCustomerScopeInfo === "function") {
|
|
1794
|
+
return quotation.getQuotationCustomerScopeInfo();
|
|
1795
|
+
}
|
|
1796
|
+
const list = typeof (quotation == null ? void 0 : quotation.getQuotationList) === "function" ? quotation.getQuotationList() : [];
|
|
1797
|
+
const customerById = /* @__PURE__ */ new Map();
|
|
1798
|
+
const quotationScopes = (Array.isArray(list) ? list : []).filter((item) => Array.isArray(item == null ? void 0 : item.customer) && item.customer.length > 0).map((item) => {
|
|
1799
|
+
const localSeen = /* @__PURE__ */ new Set();
|
|
1800
|
+
const customers = item.customer.filter((customer) => {
|
|
1801
|
+
const customerId = this.normalizePriceContextCustomerId(customer == null ? void 0 : customer.id);
|
|
1802
|
+
if (!customerId || localSeen.has(customerId))
|
|
1803
|
+
return false;
|
|
1804
|
+
localSeen.add(customerId);
|
|
1805
|
+
if (!customerById.has(customerId))
|
|
1806
|
+
customerById.set(customerId, customer);
|
|
1807
|
+
return true;
|
|
1808
|
+
});
|
|
1809
|
+
return {
|
|
1810
|
+
quotationId: item.id,
|
|
1811
|
+
quotationName: item.name,
|
|
1812
|
+
customerIds: customers.map((customer) => String(customer.id)),
|
|
1813
|
+
customers
|
|
1814
|
+
};
|
|
1815
|
+
});
|
|
1816
|
+
return {
|
|
1817
|
+
quotationCount: Array.isArray(list) ? list.length : 0,
|
|
1818
|
+
hasCustomerScopedQuotations: quotationScopes.length > 0,
|
|
1819
|
+
allQuotationsCustomerScoped: Array.isArray(list) && list.length > 0 && quotationScopes.length === list.length,
|
|
1820
|
+
customerIds: Array.from(customerById.keys()),
|
|
1821
|
+
customers: Array.from(customerById.values()),
|
|
1822
|
+
quotationScopes
|
|
1823
|
+
};
|
|
1824
|
+
}
|
|
1825
|
+
shouldRecalculateProductBookingPricesForContextChange(params) {
|
|
1826
|
+
const scopeInfo = this.getQuotationCustomerScopeInfo();
|
|
1827
|
+
const scopedCustomerIds = new Set(scopeInfo.customerIds.map((id) => String(id)));
|
|
1828
|
+
const previousCustomerId = this.normalizePriceContextCustomerId(params.previousCustomerId);
|
|
1829
|
+
const nextCustomerId = this.normalizePriceContextCustomerId(params.nextCustomerId);
|
|
1830
|
+
const previousInScope = previousCustomerId ? scopedCustomerIds.has(previousCustomerId) : false;
|
|
1831
|
+
const nextInScope = nextCustomerId ? scopedCustomerIds.has(nextCustomerId) : false;
|
|
1832
|
+
let shouldRecalculate = false;
|
|
1833
|
+
if (scopeInfo.hasCustomerScopedQuotations) {
|
|
1834
|
+
if (previousInScope) {
|
|
1835
|
+
shouldRecalculate = true;
|
|
1836
|
+
} else if (!previousCustomerId && !nextInScope) {
|
|
1837
|
+
shouldRecalculate = false;
|
|
1838
|
+
} else {
|
|
1839
|
+
shouldRecalculate = nextInScope;
|
|
1840
|
+
}
|
|
1841
|
+
}
|
|
1842
|
+
return shouldRecalculate;
|
|
1843
|
+
}
|
|
1844
|
+
async calculateProductBookingPrices(paramsList) {
|
|
1845
|
+
var _a, _b;
|
|
1846
|
+
if (!paramsList.length)
|
|
1847
|
+
return [];
|
|
1848
|
+
const quotation = this.store.quotation;
|
|
1849
|
+
const customerId = ((_a = paramsList[0]) == null ? void 0 : _a.customer_id) ?? this.getCurrentOrderCustomerId();
|
|
1850
|
+
const productMapsByGroup = /* @__PURE__ */ new Map();
|
|
1851
|
+
const groups = /* @__PURE__ */ new Map();
|
|
1852
|
+
paramsList.forEach((params) => {
|
|
1853
|
+
var _a2;
|
|
1854
|
+
const product = params.product || {};
|
|
1855
|
+
const productId = this.getPriceQueryProductId(product);
|
|
1856
|
+
if (productId === null)
|
|
1857
|
+
return;
|
|
1858
|
+
const schedule = this.getPriceQuerySchedule(params);
|
|
1859
|
+
const channel = params.channel || ((_a2 = this.otherParams) == null ? void 0 : _a2.channel);
|
|
1860
|
+
const groupKey = [
|
|
1861
|
+
schedule.schedule_date,
|
|
1862
|
+
schedule.schedule_datetime,
|
|
1863
|
+
channel || ""
|
|
1864
|
+
].join("|");
|
|
1865
|
+
const group = groups.get(groupKey) || {
|
|
1866
|
+
ids: /* @__PURE__ */ new Set(),
|
|
1867
|
+
schedule,
|
|
1868
|
+
channel
|
|
1869
|
+
};
|
|
1870
|
+
group.ids.add(productId);
|
|
1871
|
+
groups.set(groupKey, group);
|
|
1872
|
+
});
|
|
1873
|
+
await Promise.all(
|
|
1874
|
+
Array.from(groups.entries()).map(async ([groupKey, group]) => {
|
|
1875
|
+
const productsById = await this.loadProductsForPriceQuery({
|
|
1876
|
+
ids: Array.from(group.ids),
|
|
1877
|
+
schedule: group.schedule,
|
|
1878
|
+
customerId,
|
|
1879
|
+
channel: group.channel
|
|
1880
|
+
});
|
|
1881
|
+
productMapsByGroup.set(groupKey, productsById);
|
|
1882
|
+
})
|
|
1883
|
+
);
|
|
1884
|
+
await this.loadQuotationForPriceQuery({
|
|
1885
|
+
quotation,
|
|
1886
|
+
customer_id: customerId,
|
|
1887
|
+
channel: (_b = paramsList[0]) == null ? void 0 : _b.channel
|
|
1888
|
+
});
|
|
1889
|
+
return paramsList.map((params) => {
|
|
1890
|
+
var _a2, _b2;
|
|
1891
|
+
const productInput = params.product || {};
|
|
1892
|
+
const productId = this.getPriceQueryProductId(productInput);
|
|
1893
|
+
const schedule = this.getPriceQuerySchedule(params);
|
|
1894
|
+
const channel = params.channel || ((_a2 = this.otherParams) == null ? void 0 : _a2.channel);
|
|
1895
|
+
const groupKey = [
|
|
1896
|
+
schedule.schedule_date,
|
|
1897
|
+
schedule.schedule_datetime,
|
|
1898
|
+
channel || ""
|
|
1899
|
+
].join("|");
|
|
1900
|
+
const authoritativeProduct = productId === null ? null : ((_b2 = productMapsByGroup.get(groupKey)) == null ? void 0 : _b2.get(productId)) || null;
|
|
1901
|
+
const product = this.mergeProductForPriceQuery(productInput, authoritativeProduct);
|
|
1902
|
+
return (0, import_quotationPrice.calculateBaseSalesProductBookingPrice)({
|
|
1903
|
+
...params,
|
|
1904
|
+
product,
|
|
1905
|
+
fallback_price: authoritativeProduct ? void 0 : params.fallback_price,
|
|
1906
|
+
customer_id: customerId,
|
|
1907
|
+
quotation
|
|
1908
|
+
});
|
|
1909
|
+
});
|
|
1910
|
+
}
|
|
1722
1911
|
async addProductToOrder(product, booking) {
|
|
1723
1912
|
try {
|
|
1724
1913
|
if (!this.store.order)
|
|
@@ -1739,6 +1928,16 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1739
1928
|
throw error;
|
|
1740
1929
|
}
|
|
1741
1930
|
}
|
|
1931
|
+
async updateOrderProducts(paramsList) {
|
|
1932
|
+
try {
|
|
1933
|
+
if (!this.store.order)
|
|
1934
|
+
throw new Error("order 模块未初始化");
|
|
1935
|
+
const products = await this.store.order.updateOrderProducts(paramsList);
|
|
1936
|
+
return products;
|
|
1937
|
+
} catch (error) {
|
|
1938
|
+
throw error;
|
|
1939
|
+
}
|
|
1940
|
+
}
|
|
1742
1941
|
async updateOrderProductQuantity(params) {
|
|
1743
1942
|
try {
|
|
1744
1943
|
if (!this.store.order)
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { OrderModule, ProductList, QuotationModule, SalesSummaryModule, ScanOrderLoggerModule as BaseSalesLoggerModule, ScheduleModule } from '../../modules';
|
|
2
2
|
import type { ScanOrderLogInput as BaseSalesLogInput, ScanOrderLoggerProviderConfig as BaseSalesLoggerProviderConfig, ScanOrderLoggerProviderType as BaseSalesLoggerProviderType } from '../../modules/ScanOrderLogger/types';
|
|
3
3
|
import type { QuantityCheckResult, QuantityLimitResult } from '../../model/strategy/adapter/itemRule';
|
|
4
|
+
import type { QuotationCustomerScopeInfo } from '../../modules/Quotation/types';
|
|
4
5
|
/**
|
|
5
6
|
* BaseSales 流程 hook 后缀。
|
|
6
7
|
* 完整事件名应由当前模块名动态拼接,避免多个实例共享固定事件 key。
|
|
@@ -278,6 +279,12 @@ export interface BaseSalesProductBookingPriceResult {
|
|
|
278
279
|
segments: BaseSalesProductBookingPriceSegment[];
|
|
279
280
|
product_bundle?: BaseSalesBundleProductBookingPriceResult[];
|
|
280
281
|
}
|
|
282
|
+
export type BaseSalesQuotationCustomerScopeInfo = QuotationCustomerScopeInfo;
|
|
283
|
+
export interface BaseSalesPriceRecalculationContextChange {
|
|
284
|
+
previousCustomerId?: number | string | null;
|
|
285
|
+
nextCustomerId?: number | string | null;
|
|
286
|
+
[key: string]: any;
|
|
287
|
+
}
|
|
281
288
|
export type BaseSalesAvailabilityMode = 'idle' | 'shop_closed' | 'submit_disabled' | 'resource_busy' | 'additional_order_with_code' | 'additional_order';
|
|
282
289
|
export interface BaseSalesTableFormRecord {
|
|
283
290
|
policy?: string | null;
|
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
import type { QuotationModule } from '../../../modules/Quotation';
|
|
2
2
|
import type { BaseSalesCalculateProductBookingPriceParams, BaseSalesProductBookingPriceResult } from '../types';
|
|
3
3
|
interface BuildBaseSalesQuotationPriceParams extends BaseSalesCalculateProductBookingPriceParams {
|
|
4
|
-
quotation?: Pick<QuotationModule, 'getPriceForProduct' | 'getQuotationShelfId'>
|
|
4
|
+
quotation?: (Pick<QuotationModule, 'getPriceForProduct' | 'getQuotationShelfId'> & {
|
|
5
|
+
getQuotationMatchForProduct?: (params: {
|
|
6
|
+
productId: number;
|
|
7
|
+
variantId?: number;
|
|
8
|
+
datetime: string;
|
|
9
|
+
channel?: string;
|
|
10
|
+
customer_id?: number | string;
|
|
11
|
+
}) => {
|
|
12
|
+
price: string | null;
|
|
13
|
+
quotationShelfId: number;
|
|
14
|
+
} | null;
|
|
15
|
+
}) | null;
|
|
5
16
|
}
|
|
6
17
|
export declare function calculateBaseSalesProductBookingPrice(params: BuildBaseSalesQuotationPriceParams): BaseSalesProductBookingPriceResult;
|
|
7
18
|
export {};
|
|
@@ -161,19 +161,28 @@ function formatTimePoint(datetime) {
|
|
|
161
161
|
}
|
|
162
162
|
function buildPriceSegment(params) {
|
|
163
163
|
const timePoint = formatTimePoint(params.segment.start);
|
|
164
|
-
const
|
|
164
|
+
const match = params.quotation && params.productId !== null && params.quotation.getQuotationMatchForProduct ? params.quotation.getQuotationMatchForProduct({
|
|
165
165
|
productId: params.productId,
|
|
166
166
|
variantId: params.variantId,
|
|
167
167
|
datetime: timePoint,
|
|
168
|
+
channel: params.channel,
|
|
169
|
+
customer_id: params.customerId
|
|
170
|
+
}) : null;
|
|
171
|
+
const quotedPrice = match ? match.price : params.quotation && params.productId !== null ? params.quotation.getPriceForProduct({
|
|
172
|
+
productId: params.productId,
|
|
173
|
+
variantId: params.variantId,
|
|
174
|
+
datetime: timePoint,
|
|
175
|
+
channel: params.channel,
|
|
168
176
|
customer_id: params.customerId
|
|
169
177
|
}) : null;
|
|
170
178
|
const unitPrice = toPriceString(quotedPrice ?? params.fallbackPrice);
|
|
171
|
-
const quotationShelfId = quotedPrice !== null
|
|
179
|
+
const quotationShelfId = quotedPrice !== null ? (match == null ? void 0 : match.quotationShelfId) ?? (params.quotation && params.productId !== null ? params.quotation.getQuotationShelfId({
|
|
172
180
|
productId: params.productId,
|
|
173
181
|
variantId: params.variantId,
|
|
174
182
|
datetime: timePoint,
|
|
183
|
+
channel: params.channel,
|
|
175
184
|
customer_id: params.customerId
|
|
176
|
-
}) : 0;
|
|
185
|
+
}) : 0) : 0;
|
|
177
186
|
return {
|
|
178
187
|
start_datetime: timePoint,
|
|
179
188
|
end_datetime: params.segment.end ? formatTimePoint(params.segment.end) : void 0,
|
|
@@ -192,6 +201,7 @@ function calculatePriceForProduct(params) {
|
|
|
192
201
|
productId: params.productId,
|
|
193
202
|
variantId: params.variantId,
|
|
194
203
|
customerId: params.customerId,
|
|
204
|
+
channel: params.channel,
|
|
195
205
|
fallbackPrice: params.fallbackPrice,
|
|
196
206
|
segment
|
|
197
207
|
}));
|
|
@@ -222,6 +232,7 @@ function calculateBundlePrices(params, segments) {
|
|
|
222
232
|
productId,
|
|
223
233
|
variantId,
|
|
224
234
|
customerId: params.customer_id,
|
|
235
|
+
channel: params.channel,
|
|
225
236
|
quantity,
|
|
226
237
|
fallbackPrice: getBundleFallbackPrice(bundle),
|
|
227
238
|
segments
|
|
@@ -253,6 +264,7 @@ function calculateBaseSalesProductBookingPrice(params) {
|
|
|
253
264
|
productId,
|
|
254
265
|
variantId,
|
|
255
266
|
customerId: params.customer_id,
|
|
267
|
+
channel: params.channel,
|
|
256
268
|
quantity: productQuantity,
|
|
257
269
|
fallbackPrice,
|
|
258
270
|
segments: timeSegments
|
|
@@ -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 | 2 | 1 | 6 | 3 | 4 | 5;
|
|
315
315
|
}[]>;
|
|
316
316
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
317
317
|
private getScheduleDataByIds;
|