@pisell/pisellos 2.2.148 → 2.2.149
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/apis/picoding.d.ts +0 -0
- package/dist/apis/picoding.js +1 -0
- package/dist/model/strategy/adapter/index.d.ts +2 -0
- package/dist/model/strategy/adapter/index.js +3 -1
- package/dist/model/strategy/adapter/itemRule/adapter.d.ts +67 -0
- package/dist/model/strategy/adapter/itemRule/adapter.js +483 -0
- package/dist/model/strategy/adapter/itemRule/evaluator.d.ts +43 -0
- package/dist/model/strategy/adapter/itemRule/evaluator.js +169 -0
- package/dist/model/strategy/adapter/itemRule/examples.d.ts +79 -0
- package/dist/model/strategy/adapter/itemRule/examples.js +382 -0
- package/dist/model/strategy/adapter/itemRule/index.d.ts +5 -0
- package/dist/model/strategy/adapter/itemRule/index.js +5 -0
- package/dist/model/strategy/adapter/itemRule/type.d.ts +225 -0
- package/dist/model/strategy/adapter/itemRule/type.js +101 -0
- package/dist/modules/Cart/types.d.ts +2 -0
- package/dist/modules/Cart/utils/cartProduct.js +22 -1
- package/dist/modules/Cart/utils/changePrice.js +6 -0
- package/dist/modules/Date/index.d.ts +1 -1
- package/dist/modules/Date/index.js +16 -8
- package/dist/modules/Date/types.d.ts +3 -1
- package/dist/modules/OpenData/index.d.ts +24 -0
- package/dist/modules/OpenData/index.js +173 -0
- package/dist/modules/OpenData/types.d.ts +73 -0
- package/dist/modules/OpenData/types.js +1 -0
- package/dist/modules/OpenData/utils.d.ts +2 -0
- package/dist/modules/OpenData/utils.js +75 -0
- package/dist/modules/Order/index.d.ts +171 -1
- package/dist/modules/Order/index.js +2052 -112
- package/dist/modules/Order/types.d.ts +441 -20
- package/dist/modules/Order/types.js +23 -0
- package/dist/modules/Order/utils.d.ts +120 -0
- package/dist/modules/Order/utils.js +653 -2
- package/dist/modules/Product/utils.js +2 -2
- package/dist/modules/ProductList/index.js +2 -1
- package/dist/modules/Quotation/index.d.ts +8 -1
- package/dist/modules/Quotation/index.js +40 -10
- package/dist/modules/Quotation/types.d.ts +5 -0
- package/dist/modules/Rules/index.d.ts +3 -1
- package/dist/modules/Rules/index.js +136 -50
- package/dist/modules/Rules/types.d.ts +6 -0
- package/dist/modules/Rules/types.js +8 -0
- package/dist/modules/SalesSummary/index.d.ts +70 -0
- package/dist/modules/SalesSummary/index.js +175 -0
- package/dist/modules/SalesSummary/types.d.ts +64 -0
- package/dist/modules/SalesSummary/types.js +1 -0
- package/dist/modules/SalesSummary/utils.d.ts +34 -0
- package/dist/modules/SalesSummary/utils.js +488 -0
- package/dist/modules/ScanOrderLogger/index.d.ts +21 -0
- package/dist/modules/ScanOrderLogger/index.js +161 -0
- package/dist/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
- package/dist/modules/ScanOrderLogger/providers/feishu.js +203 -0
- package/dist/modules/ScanOrderLogger/providers/grafana.d.ts +2 -0
- package/dist/modules/ScanOrderLogger/providers/grafana.js +50 -0
- package/dist/modules/ScanOrderLogger/types.d.ts +52 -0
- package/dist/modules/ScanOrderLogger/types.js +1 -0
- package/dist/modules/Schedule/getDateIsInSchedule.js +7 -7
- package/dist/modules/Schedule/index.d.ts +4 -13
- package/dist/modules/Schedule/index.js +6 -23
- package/dist/modules/Schedule/utils.d.ts +1 -1
- package/dist/modules/Summary/index.d.ts +3 -0
- package/dist/modules/Summary/index.js +134 -15
- package/dist/modules/Summary/types.d.ts +7 -0
- package/dist/modules/Summary/utils.d.ts +104 -1
- package/dist/modules/Summary/utils.js +1116 -13
- package/dist/modules/index.d.ts +4 -0
- package/dist/modules/index.js +5 -1
- package/dist/server/index.d.ts +41 -4
- package/dist/server/index.js +900 -405
- package/dist/server/modules/order/index.d.ts +10 -2
- package/dist/server/modules/order/index.js +246 -193
- package/dist/server/modules/products/index.d.ts +26 -0
- package/dist/server/modules/products/index.js +618 -338
- package/dist/server/modules/products/types.d.ts +5 -1
- package/dist/solution/BaseSales/index.d.ts +175 -0
- package/dist/solution/BaseSales/index.js +1293 -0
- package/dist/solution/BaseSales/types.d.ts +305 -0
- package/dist/solution/BaseSales/types.js +38 -0
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +143 -0
- package/dist/solution/BaseSales/utils/parseSalesResponse.js +159 -0
- package/dist/solution/BaseSales/utils.d.ts +40 -0
- package/dist/solution/BaseSales/utils.js +222 -0
- package/dist/solution/BookingByStep/index.d.ts +14 -0
- package/dist/solution/BookingByStep/index.js +699 -212
- package/dist/solution/BookingByStep/types.d.ts +3 -1
- package/dist/solution/BookingByStep/types.js +5 -1
- package/dist/solution/BookingByStep/utils/capacity.js +1 -1
- package/dist/solution/BookingByStep/utils/resources.js +6 -1
- package/dist/solution/BookingTicket/index.d.ts +113 -15
- package/dist/solution/BookingTicket/index.js +534 -196
- package/dist/solution/BookingTicket/types.d.ts +69 -6
- package/dist/solution/BookingTicket/types.js +40 -9
- package/dist/solution/BookingTicket/utils/bookingStatus.d.ts +37 -0
- package/dist/solution/BookingTicket/utils/bookingStatus.js +66 -0
- package/dist/solution/BookingTicket/utils/cartView.d.ts +26 -0
- package/dist/solution/BookingTicket/utils/cartView.js +84 -0
- package/dist/solution/Sales/index.d.ts +1 -0
- package/dist/solution/Sales/index.js +1 -0
- package/dist/solution/ScanOrder/index.d.ts +146 -0
- package/dist/solution/ScanOrder/index.js +3029 -0
- package/dist/solution/ScanOrder/types.d.ts +305 -0
- package/dist/solution/ScanOrder/types.js +35 -0
- package/dist/solution/ScanOrder/utils.d.ts +167 -0
- package/dist/solution/ScanOrder/utils.js +768 -0
- package/dist/solution/ShopDiscount/index.d.ts +2 -0
- package/dist/solution/ShopDiscount/index.js +9 -5
- package/dist/solution/ShopDiscount/types.d.ts +4 -0
- package/dist/solution/VenueBooking/index.d.ts +197 -0
- package/dist/solution/VenueBooking/index.js +3411 -0
- package/dist/solution/VenueBooking/sales-section-4-annotated.json +343 -0
- package/dist/solution/VenueBooking/types.d.ts +153 -0
- package/dist/solution/VenueBooking/types.js +21 -0
- package/dist/solution/VenueBooking/utils/dateSummary.d.ts +11 -0
- package/dist/solution/VenueBooking/utils/dateSummary.js +104 -0
- package/dist/solution/VenueBooking/utils/resource.d.ts +14 -0
- package/dist/solution/VenueBooking/utils/resource.js +130 -0
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +34 -0
- package/dist/solution/VenueBooking/utils/slotMerge.js +224 -0
- package/dist/solution/VenueBooking/utils/timeSlot.d.ts +32 -0
- package/dist/solution/VenueBooking/utils/timeSlot.js +453 -0
- package/dist/solution/VenueBooking/utils.d.ts +1 -0
- package/dist/solution/VenueBooking/utils.js +1 -0
- package/dist/solution/index.d.ts +3 -0
- package/dist/solution/index.js +4 -1
- package/lib/apis/picoding.d.ts +0 -0
- package/lib/apis/picoding.js +0 -0
- package/lib/model/strategy/adapter/index.d.ts +2 -0
- package/lib/model/strategy/adapter/index.js +6 -0
- package/lib/model/strategy/adapter/itemRule/adapter.d.ts +67 -0
- package/lib/model/strategy/adapter/itemRule/adapter.js +377 -0
- package/lib/model/strategy/adapter/itemRule/evaluator.d.ts +43 -0
- package/lib/model/strategy/adapter/itemRule/evaluator.js +124 -0
- package/lib/model/strategy/adapter/itemRule/examples.d.ts +79 -0
- package/lib/model/strategy/adapter/itemRule/examples.js +316 -0
- package/lib/model/strategy/adapter/itemRule/index.d.ts +5 -0
- package/lib/model/strategy/adapter/itemRule/index.js +60 -0
- package/lib/model/strategy/adapter/itemRule/type.d.ts +225 -0
- package/lib/model/strategy/adapter/itemRule/type.js +46 -0
- package/lib/model/strategy/adapter/promotion/index.js +49 -0
- package/lib/modules/Cart/types.d.ts +2 -0
- package/lib/modules/Cart/utils/cartProduct.js +17 -1
- package/lib/modules/Cart/utils/changePrice.js +5 -0
- package/lib/modules/Date/index.d.ts +1 -1
- package/lib/modules/Date/index.js +7 -1
- package/lib/modules/Date/types.d.ts +3 -1
- package/lib/modules/OpenData/index.d.ts +24 -0
- package/lib/modules/OpenData/index.js +119 -0
- package/lib/modules/OpenData/types.d.ts +73 -0
- package/lib/modules/OpenData/types.js +17 -0
- package/lib/modules/OpenData/utils.d.ts +2 -0
- package/lib/modules/OpenData/utils.js +111 -0
- package/lib/modules/Order/index.d.ts +171 -1
- package/lib/modules/Order/index.js +1396 -5
- package/lib/modules/Order/types.d.ts +441 -20
- package/lib/modules/Order/types.js +1 -0
- package/lib/modules/Order/utils.d.ts +120 -0
- package/lib/modules/Order/utils.js +562 -2
- package/lib/modules/Product/utils.js +2 -2
- package/lib/modules/ProductList/index.js +2 -1
- package/lib/modules/Quotation/index.d.ts +8 -1
- package/lib/modules/Quotation/index.js +33 -4
- package/lib/modules/Quotation/types.d.ts +5 -0
- package/lib/modules/Rules/index.d.ts +3 -1
- package/lib/modules/Rules/index.js +46 -6
- package/lib/modules/Rules/types.d.ts +6 -0
- package/lib/modules/Rules/types.js +11 -2
- package/lib/modules/SalesSummary/index.d.ts +70 -0
- package/lib/modules/SalesSummary/index.js +106 -0
- package/lib/modules/SalesSummary/types.d.ts +64 -0
- package/lib/modules/SalesSummary/types.js +17 -0
- package/lib/modules/SalesSummary/utils.d.ts +34 -0
- package/lib/modules/SalesSummary/utils.js +430 -0
- package/lib/modules/ScanOrderLogger/index.d.ts +21 -0
- package/lib/modules/ScanOrderLogger/index.js +135 -0
- package/lib/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
- package/lib/modules/ScanOrderLogger/providers/feishu.js +148 -0
- package/lib/modules/ScanOrderLogger/providers/grafana.d.ts +2 -0
- package/lib/modules/ScanOrderLogger/providers/grafana.js +52 -0
- package/lib/modules/ScanOrderLogger/types.d.ts +52 -0
- package/lib/modules/ScanOrderLogger/types.js +17 -0
- package/lib/modules/Schedule/getDateIsInSchedule.js +5 -5
- package/lib/modules/Schedule/index.d.ts +4 -13
- package/lib/modules/Schedule/index.js +4 -15
- package/lib/modules/Schedule/utils.d.ts +1 -1
- package/lib/modules/Summary/index.d.ts +3 -0
- package/lib/modules/Summary/index.js +61 -2
- package/lib/modules/Summary/types.d.ts +7 -0
- package/lib/modules/Summary/utils.d.ts +104 -1
- package/lib/modules/Summary/utils.js +659 -8
- package/lib/modules/index.d.ts +4 -0
- package/lib/modules/index.js +9 -1
- package/lib/server/index.d.ts +41 -4
- package/lib/server/index.js +272 -10
- package/lib/server/modules/order/index.d.ts +10 -2
- package/lib/server/modules/order/index.js +26 -1
- package/lib/server/modules/products/index.d.ts +26 -0
- package/lib/server/modules/products/index.js +174 -22
- package/lib/server/modules/products/types.d.ts +5 -1
- package/lib/solution/BaseSales/index.d.ts +175 -0
- package/lib/solution/BaseSales/index.js +655 -0
- package/lib/solution/BaseSales/types.d.ts +305 -0
- package/lib/solution/BaseSales/types.js +40 -0
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +143 -0
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +160 -0
- package/lib/solution/BaseSales/utils.d.ts +40 -0
- package/lib/solution/BaseSales/utils.js +200 -0
- package/lib/solution/BookingByStep/index.d.ts +14 -0
- package/lib/solution/BookingByStep/index.js +469 -91
- package/lib/solution/BookingByStep/types.d.ts +3 -1
- package/lib/solution/BookingByStep/types.js +10 -0
- package/lib/solution/BookingByStep/utils/capacity.js +1 -1
- package/lib/solution/BookingByStep/utils/resources.js +5 -2
- package/lib/solution/BookingTicket/index.d.ts +113 -15
- package/lib/solution/BookingTicket/index.js +253 -61
- package/lib/solution/BookingTicket/types.d.ts +69 -6
- package/lib/solution/BookingTicket/types.js +16 -14
- package/lib/solution/BookingTicket/utils/bookingStatus.d.ts +37 -0
- package/lib/solution/BookingTicket/utils/bookingStatus.js +65 -0
- package/lib/solution/BookingTicket/utils/cartView.d.ts +26 -0
- package/lib/solution/BookingTicket/utils/cartView.js +103 -0
- package/lib/solution/Sales/index.d.ts +1 -0
- package/lib/solution/ScanOrder/index.d.ts +146 -0
- package/lib/solution/ScanOrder/index.js +1820 -0
- package/lib/solution/ScanOrder/types.d.ts +305 -0
- package/lib/solution/ScanOrder/types.js +36 -0
- package/lib/solution/ScanOrder/utils.d.ts +167 -0
- package/lib/solution/ScanOrder/utils.js +639 -0
- package/lib/solution/ShopDiscount/index.d.ts +2 -0
- package/lib/solution/ShopDiscount/index.js +9 -4
- package/lib/solution/ShopDiscount/types.d.ts +4 -0
- package/lib/solution/VenueBooking/index.d.ts +197 -0
- package/lib/solution/VenueBooking/index.js +1892 -0
- package/lib/solution/VenueBooking/sales-section-4-annotated.json +343 -0
- package/lib/solution/VenueBooking/types.d.ts +153 -0
- package/lib/solution/VenueBooking/types.js +44 -0
- package/lib/solution/VenueBooking/utils/dateSummary.d.ts +11 -0
- package/lib/solution/VenueBooking/utils/dateSummary.js +110 -0
- package/lib/solution/VenueBooking/utils/resource.d.ts +14 -0
- package/lib/solution/VenueBooking/utils/resource.js +91 -0
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +34 -0
- package/lib/solution/VenueBooking/utils/slotMerge.js +225 -0
- package/lib/solution/VenueBooking/utils/timeSlot.d.ts +32 -0
- package/lib/solution/VenueBooking/utils/timeSlot.js +339 -0
- package/lib/solution/VenueBooking/utils.d.ts +1 -0
- package/lib/solution/VenueBooking/utils.js +69 -0
- package/lib/solution/index.d.ts +3 -0
- package/lib/solution/index.js +7 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ProductList, CartModule, ProductData, AccountModule, AccountListModule, DateModule, GuestListModule, OrderModule, PaymentModule, ResourceListModule, StepModule, SummaryModule, ScheduleModule } from '../../modules';
|
|
1
|
+
import { ProductList, CartModule, ProductData, AccountModule, AccountListModule, DateModule, GuestListModule, OrderModule, PaymentModule, ResourceListModule, StepModule, SummaryModule, SalesSummaryModule, ScheduleModule, ScanOrderLoggerModule } from '../../modules';
|
|
2
2
|
export interface BookingByStepState {
|
|
3
3
|
cart: CartModule;
|
|
4
4
|
summary: SummaryModule;
|
|
@@ -14,6 +14,8 @@ export interface BookingByStepState {
|
|
|
14
14
|
currentProduct?: ProductData;
|
|
15
15
|
currentProductMeta?: Record<string, any>;
|
|
16
16
|
schedule: ScheduleModule;
|
|
17
|
+
salesSummary?: SalesSummaryModule;
|
|
18
|
+
scanOrderLogger?: ScanOrderLoggerModule;
|
|
17
19
|
}
|
|
18
20
|
export declare function createModule<T extends keyof BookingByStepState>(moduleName: T, solutionName: string, name?: string, version?: string): BookingByStepState[T];
|
|
19
21
|
export declare enum BookingByStepHooks {
|
|
@@ -36,6 +36,11 @@ function createModule(moduleName, solutionName, name, version) {
|
|
|
36
36
|
`${solutionName}_${name || moduleName}`,
|
|
37
37
|
version
|
|
38
38
|
);
|
|
39
|
+
case "salesSummary":
|
|
40
|
+
return new import_modules.SalesSummaryModule(
|
|
41
|
+
`${solutionName}_${name || moduleName}`,
|
|
42
|
+
version
|
|
43
|
+
);
|
|
39
44
|
case "step":
|
|
40
45
|
return new import_modules.StepModule(
|
|
41
46
|
`${solutionName}_${name || moduleName}`,
|
|
@@ -71,6 +76,11 @@ function createModule(moduleName, solutionName, name, version) {
|
|
|
71
76
|
`${solutionName}_${name || moduleName}`,
|
|
72
77
|
version
|
|
73
78
|
);
|
|
79
|
+
case "scanOrderLogger":
|
|
80
|
+
return new import_modules.ScanOrderLoggerModule(
|
|
81
|
+
`${solutionName}_${name || moduleName}`,
|
|
82
|
+
version
|
|
83
|
+
);
|
|
74
84
|
default:
|
|
75
85
|
throw new Error(`Unknown module type: ${moduleName}`);
|
|
76
86
|
}
|
|
@@ -230,7 +230,7 @@ function checkTimeSlotCapacity(timeSlotStart, timeSlotEnd, cartItems, allResourc
|
|
|
230
230
|
let totalAvailableCapacity = 0;
|
|
231
231
|
resourcesInType.forEach((resource) => {
|
|
232
232
|
const availableTimes = resource.times.filter((time) => {
|
|
233
|
-
return !(0, import_dayjs.default)(time.start_at).isAfter((0, import_dayjs.default)(timeSlotStart), "minute") && !(0, import_dayjs.default)(time.end_at).isBefore((0, import_dayjs.default)(timeSlotEnd), "minute") || (0, import_dayjs.default)(time.start_at).isBefore((0, import_dayjs.default)(timeSlotEnd), "minute") && (0, import_dayjs.default)(time.end_at).isAfter((0, import_dayjs.default)(timeSlotStart), "minute");
|
|
233
|
+
return !(0, import_dayjs.default)(time.start_at).isAfter((0, import_dayjs.default)(timeSlotStart), "minute") && !(0, import_dayjs.default)(time.end_at).isBefore((0, import_dayjs.default)(timeSlotEnd), "minute") || resource.onlyComputed && (0, import_dayjs.default)(time.start_at).isBefore((0, import_dayjs.default)(timeSlotEnd), "minute") && (0, import_dayjs.default)(time.end_at).isAfter((0, import_dayjs.default)(timeSlotStart), "minute");
|
|
234
234
|
});
|
|
235
235
|
if (availableTimes.length > 0) {
|
|
236
236
|
totalAvailableCapacity += resource.capacity || 0;
|
|
@@ -298,7 +298,7 @@ var getResourcesByProduct = (resourcesMap, resources, selectedResources, capacit
|
|
|
298
298
|
const latestTime = d.times.reduce((latest, current) => {
|
|
299
299
|
return (0, import_dayjs.default)(current.end_at).isAfter((0, import_dayjs.default)(latest.end_at)) ? current : latest;
|
|
300
300
|
}, d.times[0]);
|
|
301
|
-
return (0, import_dayjs.default)(latestTime.end_at).isAfter((0, import_dayjs.default)());
|
|
301
|
+
return (0, import_dayjs.default)(latestTime.end_at).isAfter((0, import_dayjs.default)()) && d.capacity >= capacity;
|
|
302
302
|
});
|
|
303
303
|
item.form_id = form_id;
|
|
304
304
|
acc.push(item);
|
|
@@ -353,7 +353,10 @@ var getTimeSlicesByResource = ({
|
|
|
353
353
|
});
|
|
354
354
|
times.forEach((time) => {
|
|
355
355
|
const startTime = (0, import_dayjs.default)(`${time.start_at}`);
|
|
356
|
-
|
|
356
|
+
let endTime = (0, import_dayjs.default)(`${time.end_at}`);
|
|
357
|
+
if (endTime.isAfter((0, import_dayjs.default)(currentDate).endOf("day"))) {
|
|
358
|
+
endTime = (0, import_dayjs.default)(currentDate).endOf("day");
|
|
359
|
+
}
|
|
357
360
|
let currentStart = startTime;
|
|
358
361
|
while (true) {
|
|
359
362
|
const currentEnd = currentStart.add(duration, "minute");
|
|
@@ -1,21 +1,66 @@
|
|
|
1
|
-
import { Module, PisellCore } from '../../types';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
1
|
+
import { Module, ModuleOptions, PisellCore } from '../../types';
|
|
2
|
+
import { BookingTicketCartView, BookingTicketCustomerView, BookingTicketProductCatalogView, BookingTicketState, IGetCustomerListParams, ICustomer, ILoadProductsParams, ILoadProductDetailParams, IScanResult } from './types';
|
|
3
|
+
import type { ProductData } from '../../modules';
|
|
4
|
+
import type { OrderCustomerView, OrderCustomerPatch } from '../../modules/Order/types';
|
|
5
|
+
import { BaseSalesImpl } from '../BaseSales';
|
|
6
|
+
import type { ISalesDetail } from '../BaseSales/utils/parseSalesResponse';
|
|
7
|
+
import type { LoadSalesDetailParams } from '../../modules/Order/types';
|
|
8
|
+
export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
7
9
|
protected defaultName: string;
|
|
8
10
|
protected defaultVersion: string;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* 子类覆盖 store 类型为 BookingTicket 子模块清单(在父类基础上追加 customer)。
|
|
13
|
+
* 父类按 `getRegisteredModuleNames` 注入成员到该 store。
|
|
14
|
+
*/
|
|
15
|
+
protected store: BookingTicketState;
|
|
12
16
|
private shopStore;
|
|
13
|
-
private store;
|
|
14
|
-
private otherParams;
|
|
15
|
-
private cacheId;
|
|
16
17
|
private platform;
|
|
17
18
|
private scan;
|
|
18
|
-
|
|
19
|
+
private productCatalog;
|
|
20
|
+
/**
|
|
21
|
+
* 在 BaseSales 默认模块清单(products/order/salesSummary/schedule)基础上追加 customer。
|
|
22
|
+
*/
|
|
23
|
+
protected getRegisteredModuleNames(): readonly string[];
|
|
24
|
+
/**
|
|
25
|
+
* 业务侧子模块工厂:BookingTicket 自带的 createBookingTicketModule 优先匹配;
|
|
26
|
+
* 未识别的模块名(如 BookingByStep 公共类型)回退到父类工厂。
|
|
27
|
+
*/
|
|
28
|
+
protected createSubModule(moduleName: string): Module | null;
|
|
29
|
+
initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* 加载销售详情,并在父类基础上把 customer 信息装配到 CustomerModule。
|
|
32
|
+
*
|
|
33
|
+
* 业务上 ticketBooking 进入「编辑/查看」时需要 active customer 状态,因此从
|
|
34
|
+
* sales.customer / sales.header / tempOrder 顶层字段中拼装 ICustomer 后调 setSelectedCustomer,
|
|
35
|
+
* 让现有 setActiveCustomer / getActiveCustomer 调用方零成本拿到详情态客户。
|
|
36
|
+
*/
|
|
37
|
+
loadSalesDetail(orderIdOrParams: number | string | LoadSalesDetailParams): Promise<ISalesDetail>;
|
|
38
|
+
/**
|
|
39
|
+
* 更新当前预约的 appointment_status。
|
|
40
|
+
*
|
|
41
|
+
* 数据源:从 OrderModule.tempOrder 内部读取,调用方无需传 orderId / scheduleId。
|
|
42
|
+
* schedule id 解析优先级:
|
|
43
|
+
* 1. `tempOrder.metadata.appointment_booking_parent_schedule_id`
|
|
44
|
+
* 2. `tempOrder.bookings` 中 `parent_id === 0` 的 `schedule_event_id`
|
|
45
|
+
*
|
|
46
|
+
* 流程:先乐观更新本地 bookings 的 appointment_status,再调 PUT 接口,
|
|
47
|
+
* 接口成功后强制刷新销售详情;任一步失败都回滚本地状态并抛错。
|
|
48
|
+
*
|
|
49
|
+
* @param status 目标状态(如 'confirmed')
|
|
50
|
+
* @returns 接口返回的 data
|
|
51
|
+
*/
|
|
52
|
+
setBookingStatus(status: string): Promise<any>;
|
|
53
|
+
/**
|
|
54
|
+
* 基于当前 tempOrder.order_id 强制从远端重新拉取销售详情。
|
|
55
|
+
*
|
|
56
|
+
* 适用场景:在 BookingTicket 内执行了「修改服务端订单状态」的动作(如改预约状态、
|
|
57
|
+
* 改下单客户、改商品行等)后,统一刷新本地销售详情,保证 UI 与服务端一致。
|
|
58
|
+
*
|
|
59
|
+
* 约束:调用前必须已有 tempOrder 且 order_id 存在,否则视为非法调用并抛错。
|
|
60
|
+
*
|
|
61
|
+
* @returns loadSalesDetail 的返回值
|
|
62
|
+
*/
|
|
63
|
+
refreshSalesDetail(): Promise<ISalesDetail>;
|
|
19
64
|
/**
|
|
20
65
|
* 获取商品列表
|
|
21
66
|
* @param params 包含 schedule_date 的参数
|
|
@@ -25,6 +70,14 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
|
|
|
25
70
|
callback?: (result: any) => void;
|
|
26
71
|
subscriberId?: string;
|
|
27
72
|
}): Promise<any>;
|
|
73
|
+
/**
|
|
74
|
+
* 按预约时间加载单个商品详情。
|
|
75
|
+
* 价格仍由 server products 的报价单桥接统一计算,避免 solution 实例重复请求报价单。
|
|
76
|
+
*/
|
|
77
|
+
loadProductDetail(params: ILoadProductDetailParams, options?: {
|
|
78
|
+
callback?: (result: any) => void;
|
|
79
|
+
subscriberId?: string;
|
|
80
|
+
}): Promise<ProductData | undefined>;
|
|
28
81
|
/**
|
|
29
82
|
* 取消商品查询订阅
|
|
30
83
|
* @param subscriberId 订阅时传入的 subscriberId
|
|
@@ -39,6 +92,26 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
|
|
|
39
92
|
* @returns 商品列表
|
|
40
93
|
*/
|
|
41
94
|
getProducts(): Promise<ProductData[]>;
|
|
95
|
+
/**
|
|
96
|
+
* 获取当前已加载的商品池 UI 视图。
|
|
97
|
+
*
|
|
98
|
+
* ProductList.getProducts 是异步 API;BookingTicket 维护最近一次 loadProducts 结果,
|
|
99
|
+
* 供 UI 同步 getter 使用。未加载时返回空列表。
|
|
100
|
+
*/
|
|
101
|
+
getProductCatalog(): BookingTicketProductCatalogView;
|
|
102
|
+
/**
|
|
103
|
+
* 获取购物车 UI 视图。
|
|
104
|
+
*
|
|
105
|
+
* tempOrder 仍是 checkout 协议对象;本方法只输出 UI 直接消费的数据,
|
|
106
|
+
* 商品行展示字段在 Solution 层合并,避免 UI 直接读取 tempOrder 原始结构。
|
|
107
|
+
*/
|
|
108
|
+
getCart(): BookingTicketCartView;
|
|
109
|
+
/**
|
|
110
|
+
* 获取客户 UI 视图。
|
|
111
|
+
*
|
|
112
|
+
* 优先使用 CustomerModule 的 selected customer;缺失时回退到 tempOrder 顶层客户字段。
|
|
113
|
+
*/
|
|
114
|
+
getCustomer(): BookingTicketCustomerView | null;
|
|
42
115
|
/**
|
|
43
116
|
* 通过 ids 获取商品列表(不加载到模块中)
|
|
44
117
|
* @returns 商品列表
|
|
@@ -93,6 +166,30 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
|
|
|
93
166
|
* @param customer 要添加的客户信息
|
|
94
167
|
*/
|
|
95
168
|
addCustomerToFirst(customer: ICustomer): void;
|
|
169
|
+
/**
|
|
170
|
+
* 设置当前下单客户。
|
|
171
|
+
*
|
|
172
|
+
* @param patch tempOrder 协议字段(customer_id 必填,其余缺省视为清空)
|
|
173
|
+
* @param snapshot UI 富字段快照;undefined 不动;null 清空;ICustomer 写入
|
|
174
|
+
*
|
|
175
|
+
* 同时透传 OrderModule 内部 emit 的 `order:onOrderCustomerChange` 之外,
|
|
176
|
+
* 在 BookingTicket 命名空间也 emit 一次,方便上层统一从 Solution 订阅。
|
|
177
|
+
*/
|
|
178
|
+
setOrderCustomer(patch: OrderCustomerPatch | null, snapshot?: ICustomer | null): void;
|
|
179
|
+
/**
|
|
180
|
+
* 读取 tempOrder 上的下单客户协议字段;customer_id 缺失时返回 null。
|
|
181
|
+
*/
|
|
182
|
+
getOrderCustomer(): OrderCustomerView | null;
|
|
183
|
+
/**
|
|
184
|
+
* 读取 tempOrder._extend.customerSnapshot 中的完整客户对象。
|
|
185
|
+
*/
|
|
186
|
+
getOrderCustomerSnapshot(): ICustomer | null;
|
|
187
|
+
/**
|
|
188
|
+
* 清空下单客户(协议字段 + snapshot)。
|
|
189
|
+
*/
|
|
190
|
+
clearOrderCustomer(): void;
|
|
191
|
+
/** 内部:基于 OrderModule 当前状态构造一份 OrderCustomerChangePayload。 */
|
|
192
|
+
private buildOrderCustomerPayload;
|
|
96
193
|
/**
|
|
97
194
|
* 获取客户分页信息
|
|
98
195
|
* @returns 分页信息
|
|
@@ -197,9 +294,10 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
|
|
|
197
294
|
*/
|
|
198
295
|
getOtherParams(): Promise<Record<string, any>>;
|
|
199
296
|
/**
|
|
200
|
-
*
|
|
297
|
+
* 销毁模块:先调用父类(销毁所有 store 内子模块 + emit destroy + super.destroy()),
|
|
298
|
+
* 再清理 BookingTicket 自有资源(scan 监听 + scan 内存缓存)。
|
|
201
299
|
*/
|
|
202
|
-
destroy(): void
|
|
300
|
+
destroy(): Promise<void>;
|
|
203
301
|
}
|
|
204
302
|
export * from './types';
|
|
205
303
|
export { BookingTicketImpl as BookingTicket };
|
|
@@ -34,72 +34,159 @@ __export(BookingTicket_exports, {
|
|
|
34
34
|
BookingTicketImpl: () => BookingTicketImpl
|
|
35
35
|
});
|
|
36
36
|
module.exports = __toCommonJS(BookingTicket_exports);
|
|
37
|
-
var import_BaseModule = require("../../modules/BaseModule");
|
|
38
37
|
var import_types = require("./types");
|
|
38
|
+
var import_BaseSales = require("../BaseSales");
|
|
39
39
|
var import_scan = __toESM(require("./utils/scan"));
|
|
40
40
|
var import_handleScan = require("./utils/scan/handleScan");
|
|
41
41
|
var import_scanCache = __toESM(require("./utils/scan/scanCache"));
|
|
42
|
+
var import_cartView = require("./utils/cartView");
|
|
43
|
+
var import_bookingStatus = require("./utils/bookingStatus");
|
|
42
44
|
__reExport(BookingTicket_exports, require("./types"), module.exports);
|
|
43
|
-
var BookingTicketImpl = class extends
|
|
45
|
+
var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
44
46
|
constructor() {
|
|
45
47
|
super(...arguments);
|
|
46
48
|
this.defaultName = "bookingTicket";
|
|
47
49
|
this.defaultVersion = "1.0.0";
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
this.
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
50
|
+
/**
|
|
51
|
+
* 子类覆盖 store 类型为 BookingTicket 子模块清单(在父类基础上追加 customer)。
|
|
52
|
+
* 父类按 `getRegisteredModuleNames` 注入成员到该 store。
|
|
53
|
+
*/
|
|
54
|
+
this.store = {};
|
|
55
|
+
this.productCatalog = [];
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* 在 BaseSales 默认模块清单(products/order/salesSummary/schedule)基础上追加 customer。
|
|
59
|
+
*/
|
|
60
|
+
getRegisteredModuleNames() {
|
|
61
|
+
return [...super.getRegisteredModuleNames(), "customer"];
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* 业务侧子模块工厂:BookingTicket 自带的 createBookingTicketModule 优先匹配;
|
|
65
|
+
* 未识别的模块名(如 BookingByStep 公共类型)回退到父类工厂。
|
|
66
|
+
*/
|
|
67
|
+
createSubModule(moduleName) {
|
|
68
|
+
const localModule = (0, import_types.createBookingTicketModule)(
|
|
69
|
+
moduleName,
|
|
70
|
+
this.name
|
|
71
|
+
);
|
|
72
|
+
if (localModule)
|
|
73
|
+
return localModule;
|
|
74
|
+
return super.createSubModule(moduleName);
|
|
75
|
+
}
|
|
76
|
+
async initialize(core, options = {}) {
|
|
77
|
+
var _a;
|
|
78
|
+
this.scan = new import_scan.default(this, "BOOKING_TICKET_SCAN");
|
|
59
79
|
this.shopStore = core.getPlugin("shopStore");
|
|
80
|
+
if (!this.shopStore) {
|
|
81
|
+
throw new Error("bookingTicket解决方案需要 shopStore 插件支持");
|
|
82
|
+
}
|
|
83
|
+
await super.initialize(core, options);
|
|
60
84
|
if (!this.request) {
|
|
61
85
|
throw new Error("bookingTicket解决方案需要 request 插件支持");
|
|
62
86
|
}
|
|
63
|
-
|
|
64
|
-
|
|
87
|
+
this.platform = (_a = this.otherParams) == null ? void 0 : _a.platform;
|
|
88
|
+
console.log("[BookingTicket] 初始化完成");
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* 加载销售详情,并在父类基础上把 customer 信息装配到 CustomerModule。
|
|
92
|
+
*
|
|
93
|
+
* 业务上 ticketBooking 进入「编辑/查看」时需要 active customer 状态,因此从
|
|
94
|
+
* sales.customer / sales.header / tempOrder 顶层字段中拼装 ICustomer 后调 setSelectedCustomer,
|
|
95
|
+
* 让现有 setActiveCustomer / getActiveCustomer 调用方零成本拿到详情态客户。
|
|
96
|
+
*/
|
|
97
|
+
async loadSalesDetail(orderIdOrParams) {
|
|
98
|
+
const sales = await super.loadSalesDetail(orderIdOrParams);
|
|
99
|
+
console.log(sales, "1234sales");
|
|
100
|
+
const customerModule = this.store.customer;
|
|
101
|
+
const detailCustomer = sales == null ? void 0 : sales.customer;
|
|
102
|
+
if (customerModule && detailCustomer) {
|
|
103
|
+
const { id: detailCustomerId, ...detailCustomerRest } = detailCustomer ?? {};
|
|
104
|
+
const rawId = detailCustomerId ?? "";
|
|
105
|
+
const customer = {
|
|
106
|
+
...detailCustomerRest,
|
|
107
|
+
id: rawId == null ? "" : rawId,
|
|
108
|
+
name: (detailCustomer == null ? void 0 : detailCustomer.name) ?? "",
|
|
109
|
+
phone: detailCustomer == null ? void 0 : detailCustomer.phone,
|
|
110
|
+
email: detailCustomer == null ? void 0 : detailCustomer.email,
|
|
111
|
+
country_calling_code: detailCustomer == null ? void 0 : detailCustomer.country_calling_code
|
|
112
|
+
};
|
|
113
|
+
customerModule.setSelectedCustomer(customer);
|
|
114
|
+
this.setOrderCustomer(customer, detailCustomer);
|
|
65
115
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
116
|
+
return sales;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* 更新当前预约的 appointment_status。
|
|
120
|
+
*
|
|
121
|
+
* 数据源:从 OrderModule.tempOrder 内部读取,调用方无需传 orderId / scheduleId。
|
|
122
|
+
* schedule id 解析优先级:
|
|
123
|
+
* 1. `tempOrder.metadata.appointment_booking_parent_schedule_id`
|
|
124
|
+
* 2. `tempOrder.bookings` 中 `parent_id === 0` 的 `schedule_event_id`
|
|
125
|
+
*
|
|
126
|
+
* 流程:先乐观更新本地 bookings 的 appointment_status,再调 PUT 接口,
|
|
127
|
+
* 接口成功后强制刷新销售详情;任一步失败都回滚本地状态并抛错。
|
|
128
|
+
*
|
|
129
|
+
* @param status 目标状态(如 'confirmed')
|
|
130
|
+
* @returns 接口返回的 data
|
|
131
|
+
*/
|
|
132
|
+
async setBookingStatus(status) {
|
|
133
|
+
var _a, _b;
|
|
134
|
+
const tempOrder = (_b = (_a = this.store.order) == null ? void 0 : _a.getTempOrder) == null ? void 0 : _b.call(_a);
|
|
135
|
+
if (!tempOrder) {
|
|
136
|
+
throw new Error("setBookingStatus: tempOrder 未加载");
|
|
76
137
|
}
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
"
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
|
|
138
|
+
const orderId = tempOrder.order_id;
|
|
139
|
+
if (orderId === void 0 || orderId === null) {
|
|
140
|
+
throw new Error("setBookingStatus: tempOrder.order_id 缺失");
|
|
141
|
+
}
|
|
142
|
+
const scheduleId = (0, import_bookingStatus.resolveScheduleId)(tempOrder);
|
|
143
|
+
if (scheduleId === null) {
|
|
144
|
+
throw new Error(
|
|
145
|
+
"setBookingStatus: 无法解析 schedule id(metadata 与 root booking 均缺失)"
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
const bookings = Array.isArray(tempOrder.bookings) ? tempOrder.bookings : [];
|
|
149
|
+
const previous = (0, import_bookingStatus.applyBookingsStatus)(bookings, status);
|
|
150
|
+
try {
|
|
151
|
+
const res = await this.request.put(
|
|
152
|
+
`/schedule/booking/appointment-status/${scheduleId}`,
|
|
153
|
+
{ appointment_status: status }
|
|
154
|
+
);
|
|
155
|
+
await this.refreshSalesDetail();
|
|
156
|
+
this.core.effects.emit(`${this.name}:onBookingStatusChange`, {
|
|
157
|
+
orderId,
|
|
158
|
+
status
|
|
159
|
+
});
|
|
160
|
+
return (res == null ? void 0 : res.data) ?? res;
|
|
161
|
+
} catch (error) {
|
|
162
|
+
(0, import_bookingStatus.restoreBookingsStatus)(bookings, previous);
|
|
163
|
+
throw error;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* 基于当前 tempOrder.order_id 强制从远端重新拉取销售详情。
|
|
168
|
+
*
|
|
169
|
+
* 适用场景:在 BookingTicket 内执行了「修改服务端订单状态」的动作(如改预约状态、
|
|
170
|
+
* 改下单客户、改商品行等)后,统一刷新本地销售详情,保证 UI 与服务端一致。
|
|
171
|
+
*
|
|
172
|
+
* 约束:调用前必须已有 tempOrder 且 order_id 存在,否则视为非法调用并抛错。
|
|
173
|
+
*
|
|
174
|
+
* @returns loadSalesDetail 的返回值
|
|
175
|
+
*/
|
|
176
|
+
async refreshSalesDetail() {
|
|
177
|
+
var _a, _b;
|
|
178
|
+
const tempOrder = (_b = (_a = this.store.order) == null ? void 0 : _a.getTempOrder) == null ? void 0 : _b.call(_a);
|
|
179
|
+
if (!tempOrder) {
|
|
180
|
+
throw new Error("refreshSalesDetail: tempOrder 未加载");
|
|
181
|
+
}
|
|
182
|
+
const orderId = tempOrder.order_id;
|
|
183
|
+
if (orderId === void 0 || orderId === null) {
|
|
184
|
+
throw new Error("refreshSalesDetail: tempOrder.order_id 缺失");
|
|
185
|
+
}
|
|
186
|
+
return this.loadSalesDetail({
|
|
187
|
+
orderId: Number(orderId),
|
|
188
|
+
forceRemote: true
|
|
101
189
|
});
|
|
102
|
-
this.core.effects.emit(`${this.name}:onInited`, {});
|
|
103
190
|
}
|
|
104
191
|
/**
|
|
105
192
|
* 获取商品列表
|
|
@@ -115,6 +202,7 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
|
|
|
115
202
|
...params,
|
|
116
203
|
cacheId: this.cacheId
|
|
117
204
|
}, options);
|
|
205
|
+
this.productCatalog = Array.isArray(result) ? [...result] : [];
|
|
118
206
|
this.core.effects.emit(`${this.name}:onProductsLoaded`, result);
|
|
119
207
|
return result;
|
|
120
208
|
} catch (error) {
|
|
@@ -122,6 +210,20 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
|
|
|
122
210
|
throw error;
|
|
123
211
|
}
|
|
124
212
|
}
|
|
213
|
+
/**
|
|
214
|
+
* 按预约时间加载单个商品详情。
|
|
215
|
+
* 价格仍由 server products 的报价单桥接统一计算,避免 solution 实例重复请求报价单。
|
|
216
|
+
*/
|
|
217
|
+
async loadProductDetail(params, options) {
|
|
218
|
+
const { product_id, ...queryParams } = params;
|
|
219
|
+
const products = await this.loadProducts({
|
|
220
|
+
...queryParams,
|
|
221
|
+
product_ids: [product_id]
|
|
222
|
+
}, options);
|
|
223
|
+
return products.find(
|
|
224
|
+
(product) => Number(product.id) === Number(product_id)
|
|
225
|
+
);
|
|
226
|
+
}
|
|
125
227
|
/**
|
|
126
228
|
* 取消商品查询订阅
|
|
127
229
|
* @param subscriberId 订阅时传入的 subscriberId
|
|
@@ -143,6 +245,48 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
|
|
|
143
245
|
async getProducts() {
|
|
144
246
|
return this.store.products.getProducts();
|
|
145
247
|
}
|
|
248
|
+
/**
|
|
249
|
+
* 获取当前已加载的商品池 UI 视图。
|
|
250
|
+
*
|
|
251
|
+
* ProductList.getProducts 是异步 API;BookingTicket 维护最近一次 loadProducts 结果,
|
|
252
|
+
* 供 UI 同步 getter 使用。未加载时返回空列表。
|
|
253
|
+
*/
|
|
254
|
+
getProductCatalog() {
|
|
255
|
+
return {
|
|
256
|
+
products: [...this.productCatalog]
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* 获取购物车 UI 视图。
|
|
261
|
+
*
|
|
262
|
+
* tempOrder 仍是 checkout 协议对象;本方法只输出 UI 直接消费的数据,
|
|
263
|
+
* 商品行展示字段在 Solution 层合并,避免 UI 直接读取 tempOrder 原始结构。
|
|
264
|
+
*/
|
|
265
|
+
getCart() {
|
|
266
|
+
var _a;
|
|
267
|
+
const tempOrder = ((_a = this.store.order) == null ? void 0 : _a.getTempOrder()) ?? null;
|
|
268
|
+
const salesDetail = this.getSalesOrder();
|
|
269
|
+
const bookings = (salesDetail == null ? void 0 : salesDetail.bookings) ?? ((tempOrder == null ? void 0 : tempOrder.bookings) || []);
|
|
270
|
+
const salesDetailBookingMap = salesDetail == null ? void 0 : salesDetail.bookingsByProductUid;
|
|
271
|
+
const bookingsByProductUid = salesDetailBookingMap && Object.keys(salesDetailBookingMap).length > 0 ? salesDetailBookingMap : (0, import_cartView.indexBookingsByProductUid)(bookings);
|
|
272
|
+
return {
|
|
273
|
+
items: (0, import_cartView.buildCartItemViews)((tempOrder == null ? void 0 : tempOrder.products) || [], {
|
|
274
|
+
bookingDetailMap: bookingsByProductUid,
|
|
275
|
+
productsCatalog: this.productCatalog
|
|
276
|
+
})
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* 获取客户 UI 视图。
|
|
281
|
+
*
|
|
282
|
+
* 优先使用 CustomerModule 的 selected customer;缺失时回退到 tempOrder 顶层客户字段。
|
|
283
|
+
*/
|
|
284
|
+
getCustomer() {
|
|
285
|
+
var _a, _b, _c, _d;
|
|
286
|
+
const selected = ((_b = (_a = this.store.customer) == null ? void 0 : _a.getSelectedCustomer) == null ? void 0 : _b.call(_a)) ?? null;
|
|
287
|
+
const tempOrder = ((_d = (_c = this.store.order) == null ? void 0 : _c.getTempOrder) == null ? void 0 : _d.call(_c)) ?? null;
|
|
288
|
+
return (0, import_cartView.buildCustomerView)(selected, tempOrder);
|
|
289
|
+
}
|
|
146
290
|
/**
|
|
147
291
|
* 通过 ids 获取商品列表(不加载到模块中)
|
|
148
292
|
* @returns 商品列表
|
|
@@ -235,6 +379,55 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
|
|
|
235
379
|
addCustomerToFirst(customer) {
|
|
236
380
|
this.store.customer.addCustomerToFirst(customer);
|
|
237
381
|
}
|
|
382
|
+
// ─── 下单客户(基于 OrderModule.tempOrder,单一真源)───
|
|
383
|
+
// 与老的 setActiveCustomer/getActiveCustomer 解耦:
|
|
384
|
+
// - 老路:写入 CustomerModule.selectedCustomer(保留兼容,存量调用方不动)
|
|
385
|
+
// - 新路:写入 tempOrder 的 customer 协议字段 + _extend.customerSnapshot
|
|
386
|
+
// 新业务(如 SalesSdk)应优先使用本组方法。
|
|
387
|
+
/**
|
|
388
|
+
* 设置当前下单客户。
|
|
389
|
+
*
|
|
390
|
+
* @param patch tempOrder 协议字段(customer_id 必填,其余缺省视为清空)
|
|
391
|
+
* @param snapshot UI 富字段快照;undefined 不动;null 清空;ICustomer 写入
|
|
392
|
+
*
|
|
393
|
+
* 同时透传 OrderModule 内部 emit 的 `order:onOrderCustomerChange` 之外,
|
|
394
|
+
* 在 BookingTicket 命名空间也 emit 一次,方便上层统一从 Solution 订阅。
|
|
395
|
+
*/
|
|
396
|
+
setOrderCustomer(patch, snapshot) {
|
|
397
|
+
this.store.order.setOrderCustomer(patch, snapshot);
|
|
398
|
+
const next = this.buildOrderCustomerPayload();
|
|
399
|
+
console.log("setOrderCustomer1234", patch, snapshot, next);
|
|
400
|
+
this.core.effects.emit(`${this.name}:onOrderCustomerChange`, next);
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* 读取 tempOrder 上的下单客户协议字段;customer_id 缺失时返回 null。
|
|
404
|
+
*/
|
|
405
|
+
getOrderCustomer() {
|
|
406
|
+
return this.store.order.getOrderCustomer();
|
|
407
|
+
}
|
|
408
|
+
/**
|
|
409
|
+
* 读取 tempOrder._extend.customerSnapshot 中的完整客户对象。
|
|
410
|
+
*/
|
|
411
|
+
getOrderCustomerSnapshot() {
|
|
412
|
+
return this.store.order.getOrderCustomerSnapshot();
|
|
413
|
+
}
|
|
414
|
+
/**
|
|
415
|
+
* 清空下单客户(协议字段 + snapshot)。
|
|
416
|
+
*/
|
|
417
|
+
clearOrderCustomer() {
|
|
418
|
+
this.store.order.clearOrderCustomer();
|
|
419
|
+
this.core.effects.emit(`${this.name}:onOrderCustomerChange`, null);
|
|
420
|
+
}
|
|
421
|
+
/** 内部:基于 OrderModule 当前状态构造一份 OrderCustomerChangePayload。 */
|
|
422
|
+
buildOrderCustomerPayload() {
|
|
423
|
+
const patch = this.store.order.getOrderCustomer();
|
|
424
|
+
if (!patch)
|
|
425
|
+
return null;
|
|
426
|
+
return {
|
|
427
|
+
patch,
|
|
428
|
+
snapshot: this.store.order.getOrderCustomerSnapshot()
|
|
429
|
+
};
|
|
430
|
+
}
|
|
238
431
|
/**
|
|
239
432
|
* 获取客户分页信息
|
|
240
433
|
* @returns 分页信息
|
|
@@ -431,18 +624,17 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
|
|
|
431
624
|
return this.otherParams;
|
|
432
625
|
}
|
|
433
626
|
/**
|
|
434
|
-
*
|
|
627
|
+
* 销毁模块:先调用父类(销毁所有 store 内子模块 + emit destroy + super.destroy()),
|
|
628
|
+
* 再清理 BookingTicket 自有资源(scan 监听 + scan 内存缓存)。
|
|
435
629
|
*/
|
|
436
|
-
destroy() {
|
|
437
|
-
var _a
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
this.core.unregisterModule(this);
|
|
445
|
-
this.scan.removeAllListeners();
|
|
630
|
+
async destroy() {
|
|
631
|
+
var _a;
|
|
632
|
+
await super.destroy();
|
|
633
|
+
try {
|
|
634
|
+
(_a = this.scan) == null ? void 0 : _a.removeAllListeners();
|
|
635
|
+
} catch (error) {
|
|
636
|
+
console.warn("[BookingTicket] scan removeAllListeners 失败", error);
|
|
637
|
+
}
|
|
446
638
|
import_scanCache.default.clear();
|
|
447
639
|
}
|
|
448
640
|
};
|