@pisell/pisellos 2.2.203 → 2.2.205
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 +38 -1
- package/dist/modules/Order/index.js +388 -224
- package/dist/modules/Order/types.d.ts +2 -0
- package/dist/modules/Payment/index.d.ts +0 -13
- package/dist/modules/Payment/index.js +449 -833
- package/dist/plugins/request.d.ts +1 -0
- package/dist/server/index.d.ts +6 -0
- package/dist/server/index.js +730 -619
- package/dist/server/modules/index.d.ts +2 -0
- package/dist/server/modules/index.js +2 -0
- package/dist/server/modules/payment/index.d.ts +28 -0
- package/dist/server/modules/payment/index.js +305 -0
- package/dist/server/modules/payment/types.d.ts +9 -0
- package/dist/server/modules/payment/types.js +1 -0
- package/dist/solution/BaseSales/index.d.ts +13 -1
- package/dist/solution/BaseSales/index.js +132 -60
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.js +1 -1
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +51 -52
- package/dist/solution/BookingTicket/utils/scan/index.d.ts +5 -0
- package/dist/solution/BookingTicket/utils/scan/index.js +20 -8
- package/lib/model/strategy/adapter/promotion/index.js +49 -0
- package/lib/modules/Order/index.d.ts +38 -1
- package/lib/modules/Order/index.js +94 -19
- package/lib/modules/Order/types.d.ts +2 -0
- package/lib/modules/Payment/index.d.ts +0 -13
- package/lib/modules/Payment/index.js +6 -149
- package/lib/plugins/request.d.ts +1 -0
- package/lib/server/index.d.ts +6 -0
- package/lib/server/index.js +46 -0
- package/lib/server/modules/index.d.ts +2 -0
- package/lib/server/modules/index.js +3 -0
- package/lib/server/modules/payment/index.d.ts +28 -0
- package/lib/server/modules/payment/index.js +192 -0
- package/lib/server/modules/payment/types.d.ts +9 -0
- package/lib/server/modules/payment/types.js +17 -0
- package/lib/solution/BaseSales/index.d.ts +13 -1
- package/lib/solution/BaseSales/index.js +62 -9
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.js +1 -1
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +1 -2
- package/lib/solution/BookingTicket/utils/scan/index.d.ts +5 -0
- package/lib/solution/BookingTicket/utils/scan/index.js +17 -3
- package/package.json +1 -1
package/lib/server/index.js
CHANGED
|
@@ -41,6 +41,7 @@ var import_schedule = require("./modules/schedule");
|
|
|
41
41
|
var import_resource = require("./modules/resource");
|
|
42
42
|
var import_floor_plan = require("./modules/floor-plan");
|
|
43
43
|
var import_types = require("./modules/floor-plan/types");
|
|
44
|
+
var import_payment = require("./modules/payment");
|
|
44
45
|
var import_schedule2 = require("./utils/schedule");
|
|
45
46
|
var import_types2 = require("./modules/products/types");
|
|
46
47
|
var import_product = require("./utils/product");
|
|
@@ -120,6 +121,15 @@ var Server = class {
|
|
|
120
121
|
list: []
|
|
121
122
|
}
|
|
122
123
|
},
|
|
124
|
+
payment: {
|
|
125
|
+
name: "payment",
|
|
126
|
+
moduleClass: import_payment.PaymentServerModule,
|
|
127
|
+
moduleName: "server_payment",
|
|
128
|
+
version: "1.0.0",
|
|
129
|
+
defaultStore: {
|
|
130
|
+
payMethods: []
|
|
131
|
+
}
|
|
132
|
+
},
|
|
123
133
|
resource: {
|
|
124
134
|
name: "resource",
|
|
125
135
|
moduleClass: import_resource.ResourceModule,
|
|
@@ -143,6 +153,18 @@ var Server = class {
|
|
|
143
153
|
}
|
|
144
154
|
}
|
|
145
155
|
};
|
|
156
|
+
this.handlePaymentMethods = async ({ data, config }) => {
|
|
157
|
+
debugger;
|
|
158
|
+
const payment = await this.getPaymentRouteModule();
|
|
159
|
+
const payMethods = await payment.getPayMethodListAsync({
|
|
160
|
+
shouldFilter: (data == null ? void 0 : data.filterPaymentMethods) === true || (config == null ? void 0 : config.filterPaymentMethods) === true
|
|
161
|
+
});
|
|
162
|
+
return {
|
|
163
|
+
code: 200,
|
|
164
|
+
status: true,
|
|
165
|
+
data: payMethods
|
|
166
|
+
};
|
|
167
|
+
};
|
|
146
168
|
/**
|
|
147
169
|
* 处理商品查询请求
|
|
148
170
|
* 存储订阅者信息,便于数据变更时推送最新结果
|
|
@@ -1262,6 +1284,11 @@ var Server = class {
|
|
|
1262
1284
|
path: "/update/localOrder",
|
|
1263
1285
|
handler: this.handleUpdateLocalOrder.bind(this)
|
|
1264
1286
|
},
|
|
1287
|
+
{
|
|
1288
|
+
method: "get",
|
|
1289
|
+
path: "/shop/pay/custom-payment/all",
|
|
1290
|
+
handler: this.handlePaymentMethods.bind(this)
|
|
1291
|
+
},
|
|
1265
1292
|
{
|
|
1266
1293
|
method: "post",
|
|
1267
1294
|
path: "/shop/order/sales/checkout",
|
|
@@ -1286,6 +1313,25 @@ var Server = class {
|
|
|
1286
1313
|
}
|
|
1287
1314
|
]);
|
|
1288
1315
|
}
|
|
1316
|
+
async getPaymentRouteModule() {
|
|
1317
|
+
if (this.payment)
|
|
1318
|
+
return this.payment;
|
|
1319
|
+
if (this.paymentRouteModule)
|
|
1320
|
+
return this.paymentRouteModule;
|
|
1321
|
+
if (this.paymentRouteModuleInFlight)
|
|
1322
|
+
return this.paymentRouteModuleInFlight;
|
|
1323
|
+
this.paymentRouteModuleInFlight = (async () => {
|
|
1324
|
+
const module2 = new import_payment.PaymentServerModule("server_payment_route", "1.0.0");
|
|
1325
|
+
await module2.initialize(this.core, {
|
|
1326
|
+
store: { payMethods: [] }
|
|
1327
|
+
});
|
|
1328
|
+
this.paymentRouteModule = module2;
|
|
1329
|
+
return module2;
|
|
1330
|
+
})().finally(() => {
|
|
1331
|
+
this.paymentRouteModuleInFlight = void 0;
|
|
1332
|
+
});
|
|
1333
|
+
return this.paymentRouteModuleInFlight;
|
|
1334
|
+
}
|
|
1289
1335
|
/**
|
|
1290
1336
|
* 根据 subscriberId 移除商品查询订阅者
|
|
1291
1337
|
*/
|
|
@@ -16,6 +16,8 @@ export type { ScheduleState, ScheduleItem } from './schedule/types';
|
|
|
16
16
|
export { OrderModule } from './order';
|
|
17
17
|
export type { OrderState, OrderData, OrderId, OrderSummary, OrderBookingItem, OrderProductLineItem, OrderPaymentItem, OrderSurchargeItem, OrderProductDiscountItem, OrderWithoutBookings, BookingData, OrderFilters, BookingFilters, OrderFilterResult, OrderFilterRejectDetail, OrderFilterRejectedEntry, BookingFilterResult, OrderModulePagedResult, } from './order/types';
|
|
18
18
|
export { OrderHooks } from './order/types';
|
|
19
|
+
export { PaymentServerModule } from './payment';
|
|
20
|
+
export type { PaymentMethod, PaymentMethodsChangedEventData, PaymentServerState } from './payment/types';
|
|
19
21
|
export { FloorPlanModule } from './floor-plan';
|
|
20
22
|
export type { FloorPlanItem, FloorPlanState, FloorPlanSyncMessage } from './floor-plan/types';
|
|
21
23
|
export { FloorPlanHooks } from './floor-plan/types';
|
|
@@ -25,6 +25,7 @@ __export(modules_exports, {
|
|
|
25
25
|
MenuModule: () => import_menu.MenuModule,
|
|
26
26
|
OrderHooks: () => import_types4.OrderHooks,
|
|
27
27
|
OrderModule: () => import_order.OrderModule,
|
|
28
|
+
PaymentServerModule: () => import_payment.PaymentServerModule,
|
|
28
29
|
ProductsHooks: () => import_types.ProductsHooks,
|
|
29
30
|
ProductsModule: () => import_products.ProductsModule,
|
|
30
31
|
QuotationHooks: () => import_types3.QuotationHooks,
|
|
@@ -44,6 +45,7 @@ var import_types3 = require("./quotation/types");
|
|
|
44
45
|
var import_schedule = require("./schedule");
|
|
45
46
|
var import_order = require("./order");
|
|
46
47
|
var import_types4 = require("./order/types");
|
|
48
|
+
var import_payment = require("./payment");
|
|
47
49
|
var import_floor_plan = require("./floor-plan");
|
|
48
50
|
var import_types5 = require("./floor-plan/types");
|
|
49
51
|
var import_resource = require("./resource");
|
|
@@ -56,6 +58,7 @@ var import_resource2 = require("./resource");
|
|
|
56
58
|
MenuModule,
|
|
57
59
|
OrderHooks,
|
|
58
60
|
OrderModule,
|
|
61
|
+
PaymentServerModule,
|
|
59
62
|
ProductsHooks,
|
|
60
63
|
ProductsModule,
|
|
61
64
|
QuotationHooks,
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Module, ModuleOptions, PisellCore } from '../../../types';
|
|
2
|
+
import { BaseModule } from '../../../modules/BaseModule';
|
|
3
|
+
import type { PaymentMethod } from './types';
|
|
4
|
+
export declare class PaymentServerModule extends BaseModule implements Module {
|
|
5
|
+
protected defaultName: string;
|
|
6
|
+
protected defaultVersion: string;
|
|
7
|
+
private request;
|
|
8
|
+
private app;
|
|
9
|
+
private logger;
|
|
10
|
+
private store;
|
|
11
|
+
private payMethodMemoryCache;
|
|
12
|
+
private payMethodListInFlight;
|
|
13
|
+
constructor(name?: string, version?: string);
|
|
14
|
+
initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
|
|
15
|
+
getPayMethodListAsync(options?: {
|
|
16
|
+
shouldFilter?: boolean;
|
|
17
|
+
}): Promise<PaymentMethod[]>;
|
|
18
|
+
clearPayMethodCache(): void;
|
|
19
|
+
private loadPayMethodListAsync;
|
|
20
|
+
private fetchRemotePayMethods;
|
|
21
|
+
private shouldFilterPayMethods;
|
|
22
|
+
private resolvePayMethods;
|
|
23
|
+
private filterPayMethods;
|
|
24
|
+
private setPayMethodCache;
|
|
25
|
+
private logInfo;
|
|
26
|
+
private logWarning;
|
|
27
|
+
private logError;
|
|
28
|
+
}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/server/modules/payment/index.ts
|
|
20
|
+
var payment_exports = {};
|
|
21
|
+
__export(payment_exports, {
|
|
22
|
+
PaymentServerModule: () => PaymentServerModule
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(payment_exports);
|
|
25
|
+
var import_BaseModule = require("../../../modules/BaseModule");
|
|
26
|
+
var WALLET_PASS_CODE = "WALLET_PASS";
|
|
27
|
+
var WALLET_DEPENDENT_CODES = /* @__PURE__ */ new Set(["PRODUCTVOUCHER", "GIFTCARD", "POINTCARD"]);
|
|
28
|
+
var PAYMENT_METHODS_LOADED_EVENT = "payment:onPaymentMethodsLoaded";
|
|
29
|
+
var PaymentServerModule = class extends import_BaseModule.BaseModule {
|
|
30
|
+
constructor(name, version) {
|
|
31
|
+
super(name || "payment", version);
|
|
32
|
+
this.defaultName = "payment";
|
|
33
|
+
this.defaultVersion = "1.0.0";
|
|
34
|
+
this.payMethodMemoryCache = null;
|
|
35
|
+
this.payMethodListInFlight = null;
|
|
36
|
+
}
|
|
37
|
+
async initialize(core, options) {
|
|
38
|
+
var _a, _b, _c;
|
|
39
|
+
this.core = core;
|
|
40
|
+
this.store = options == null ? void 0 : options.store;
|
|
41
|
+
if (!this.store)
|
|
42
|
+
this.store = { payMethods: [] };
|
|
43
|
+
if (!Array.isArray(this.store.payMethods))
|
|
44
|
+
this.store.payMethods = [];
|
|
45
|
+
this.request = core.getPlugin("request");
|
|
46
|
+
const appPlugin = core.getPlugin("app");
|
|
47
|
+
this.app = appPlugin == null ? void 0 : appPlugin.getApp();
|
|
48
|
+
this.logger = (_a = this.app) == null ? void 0 : _a.logger;
|
|
49
|
+
if (!this.request && !((_b = this.app) == null ? void 0 : _b.request)) {
|
|
50
|
+
throw new Error("PaymentServerModule 需要 request 插件或 app.request 支持");
|
|
51
|
+
}
|
|
52
|
+
this.logInfo("PaymentServerModule initialized successfully", {
|
|
53
|
+
hasAppRequest: !!((_c = this.app) == null ? void 0 : _c.request)
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
// getRoutes(): RouteDefinition[] {
|
|
57
|
+
// return [
|
|
58
|
+
// {
|
|
59
|
+
// method: 'get',
|
|
60
|
+
// path: '/pay/custom-payment/all',
|
|
61
|
+
// handler: async ({ data, config }) => {
|
|
62
|
+
// const payMethods = await this.getPayMethodListAsync({
|
|
63
|
+
// shouldFilter: this.shouldFilterPayMethods(data, config),
|
|
64
|
+
// });
|
|
65
|
+
// return {
|
|
66
|
+
// code: 200,
|
|
67
|
+
// status: true,
|
|
68
|
+
// data: payMethods,
|
|
69
|
+
// };
|
|
70
|
+
// },
|
|
71
|
+
// },
|
|
72
|
+
// ];
|
|
73
|
+
// }
|
|
74
|
+
async getPayMethodListAsync(options = {}) {
|
|
75
|
+
var _a;
|
|
76
|
+
this.logInfo("Starting getPayMethodListAsync");
|
|
77
|
+
if ((_a = this.payMethodMemoryCache) == null ? void 0 : _a.length) {
|
|
78
|
+
return this.resolvePayMethods(this.payMethodMemoryCache, options);
|
|
79
|
+
}
|
|
80
|
+
if (this.payMethodListInFlight) {
|
|
81
|
+
const payMethods2 = await this.payMethodListInFlight;
|
|
82
|
+
return this.resolvePayMethods(payMethods2, options);
|
|
83
|
+
}
|
|
84
|
+
this.payMethodListInFlight = this.loadPayMethodListAsync().finally(() => {
|
|
85
|
+
this.payMethodListInFlight = null;
|
|
86
|
+
});
|
|
87
|
+
const payMethods = await this.payMethodListInFlight;
|
|
88
|
+
return this.resolvePayMethods(payMethods, options);
|
|
89
|
+
}
|
|
90
|
+
clearPayMethodCache() {
|
|
91
|
+
this.payMethodMemoryCache = null;
|
|
92
|
+
this.store.payMethods = [];
|
|
93
|
+
}
|
|
94
|
+
async loadPayMethodListAsync() {
|
|
95
|
+
try {
|
|
96
|
+
const payMethods = await this.fetchRemotePayMethods();
|
|
97
|
+
this.setPayMethodCache(payMethods);
|
|
98
|
+
await this.core.effects.emit(PAYMENT_METHODS_LOADED_EVENT, payMethods);
|
|
99
|
+
this.logInfo("getPayMethodListAsync completed successfully", {
|
|
100
|
+
payMethods
|
|
101
|
+
});
|
|
102
|
+
return payMethods;
|
|
103
|
+
} catch (error) {
|
|
104
|
+
console.error("[PaymentServerModule] 获取支付方式列表失败", error);
|
|
105
|
+
this.logError("getPayMethodListAsync failed", error);
|
|
106
|
+
return [];
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
async fetchRemotePayMethods() {
|
|
110
|
+
var _a;
|
|
111
|
+
const requester = ((_a = this.app) == null ? void 0 : _a.request) || this.request;
|
|
112
|
+
const response = await requester.get("/shop/pay/custom-payment/all", void 0);
|
|
113
|
+
const payMethods = (response == null ? void 0 : response.data) || response || [];
|
|
114
|
+
return Array.isArray(payMethods) ? payMethods : [];
|
|
115
|
+
}
|
|
116
|
+
shouldFilterPayMethods(data, config) {
|
|
117
|
+
return (data == null ? void 0 : data.filterPaymentMethods) === true || (config == null ? void 0 : config.filterPaymentMethods) === true;
|
|
118
|
+
}
|
|
119
|
+
resolvePayMethods(payMethods, options) {
|
|
120
|
+
if (!options.shouldFilter)
|
|
121
|
+
return payMethods;
|
|
122
|
+
return this.filterPayMethods(payMethods);
|
|
123
|
+
}
|
|
124
|
+
filterPayMethods(payMethods) {
|
|
125
|
+
if (!Array.isArray(payMethods))
|
|
126
|
+
return [];
|
|
127
|
+
let availableMethods = payMethods.filter(
|
|
128
|
+
(method) => method.status === 1 && method.disable === 0
|
|
129
|
+
);
|
|
130
|
+
const walletPassMethod = availableMethods.find(
|
|
131
|
+
(method) => method.code === WALLET_PASS_CODE
|
|
132
|
+
);
|
|
133
|
+
if (!walletPassMethod) {
|
|
134
|
+
return availableMethods.filter(
|
|
135
|
+
(method) => !WALLET_DEPENDENT_CODES.has(method.code)
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
availableMethods = availableMethods.map((method) => {
|
|
139
|
+
if (!WALLET_DEPENDENT_CODES.has(method.code))
|
|
140
|
+
return method;
|
|
141
|
+
return {
|
|
142
|
+
...method,
|
|
143
|
+
channel_application: walletPassMethod.channel_application
|
|
144
|
+
};
|
|
145
|
+
});
|
|
146
|
+
return availableMethods;
|
|
147
|
+
}
|
|
148
|
+
setPayMethodCache(payMethods) {
|
|
149
|
+
this.payMethodMemoryCache = payMethods;
|
|
150
|
+
this.store.payMethods = payMethods;
|
|
151
|
+
}
|
|
152
|
+
logInfo(title, metadata) {
|
|
153
|
+
try {
|
|
154
|
+
if (this.logger) {
|
|
155
|
+
this.logger.addLog({
|
|
156
|
+
type: "info",
|
|
157
|
+
title: `[PaymentServerModule] ${title}`,
|
|
158
|
+
metadata: metadata || {}
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
} catch {
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
logWarning(title, metadata) {
|
|
165
|
+
try {
|
|
166
|
+
if (this.logger) {
|
|
167
|
+
this.logger.addLog({
|
|
168
|
+
type: "warning",
|
|
169
|
+
title: `[PaymentServerModule] ${title}`,
|
|
170
|
+
metadata: metadata || {}
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
} catch {
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
logError(title, metadata) {
|
|
177
|
+
try {
|
|
178
|
+
if (this.logger) {
|
|
179
|
+
this.logger.addLog({
|
|
180
|
+
type: "error",
|
|
181
|
+
title: `[PaymentServerModule] ${title}`,
|
|
182
|
+
metadata: metadata || {}
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
} catch {
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
190
|
+
0 && (module.exports = {
|
|
191
|
+
PaymentServerModule
|
|
192
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { PaymentMethod } from '../../../modules/Payment/types';
|
|
2
|
+
export interface PaymentServerState {
|
|
3
|
+
payMethods: PaymentMethod[];
|
|
4
|
+
}
|
|
5
|
+
export interface PaymentMethodsChangedEventData {
|
|
6
|
+
oldMethods: PaymentMethod[];
|
|
7
|
+
newMethods: PaymentMethod[];
|
|
8
|
+
}
|
|
9
|
+
export type { PaymentMethod };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
14
|
+
|
|
15
|
+
// src/server/modules/payment/types.ts
|
|
16
|
+
var types_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(types_exports);
|
|
@@ -9,6 +9,7 @@ import { RequestPlugin, WindowPlugin } from '../../plugins';
|
|
|
9
9
|
export * from './types';
|
|
10
10
|
import { ProductList } from '../../modules/ProductList';
|
|
11
11
|
import { PaymentModule } from '../../modules/Payment';
|
|
12
|
+
import type { PaymentMethod } from '../../modules/Payment/types';
|
|
12
13
|
import type { SalesSummaryModule } from '../../modules/SalesSummary';
|
|
13
14
|
import type { ScheduleModule } from '../../modules/Schedule';
|
|
14
15
|
import { QuotationModule } from '../../modules/Quotation';
|
|
@@ -41,6 +42,7 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
41
42
|
protected currentSalesDetail: ISalesDetail | null;
|
|
42
43
|
protected discountConfigCacheKey: string | null;
|
|
43
44
|
protected hasManualDiscountSelection: boolean;
|
|
45
|
+
private paymentMethodsCache;
|
|
44
46
|
constructor(name?: string, version?: string);
|
|
45
47
|
/**
|
|
46
48
|
* 子类可覆盖此方法以追加/收敛要注册的子模块。
|
|
@@ -59,6 +61,7 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
59
61
|
* 记录错误日志
|
|
60
62
|
*/
|
|
61
63
|
private logError;
|
|
64
|
+
private hydrateOrderPaymentNames;
|
|
62
65
|
get payment(): PaymentModule | undefined;
|
|
63
66
|
private getCurrentOrderCustomerId;
|
|
64
67
|
private applyQuotationScheduleResolver;
|
|
@@ -212,7 +215,9 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
212
215
|
email: string;
|
|
213
216
|
};
|
|
214
217
|
/** 获取可用支付方式列表,供 PaymentModal 渲染支付选项。 */
|
|
215
|
-
getPaymentMethodsAsync(): Promise<
|
|
218
|
+
getPaymentMethodsAsync(): Promise<PaymentMethod[]>;
|
|
219
|
+
/** 同步读取初始化时缓存的支付方式列表。 */
|
|
220
|
+
getPaymentMethods(): PaymentMethod[];
|
|
216
221
|
/** 轻量舍入能力,供现金支付 UI 计算 rounding_amount。 */
|
|
217
222
|
roundAmount(params: {
|
|
218
223
|
amount: string | number;
|
|
@@ -245,6 +250,13 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
245
250
|
* 多行同 SKU 时必须传入与删除/更新一致的 unique_identification_number。
|
|
246
251
|
*/
|
|
247
252
|
setOrderProductLineNote(identity: BaseSalesOrderProductIdentity, note: string): Promise<import("../../modules/Order/types").OrderProduct[]>;
|
|
253
|
+
/**
|
|
254
|
+
* 批量删除购物车行,末尾仅一次促销重算。
|
|
255
|
+
*
|
|
256
|
+
* @example
|
|
257
|
+
* await baseSales.removeProductsFromOrder([identityA, identityB]);
|
|
258
|
+
*/
|
|
259
|
+
removeProductsFromOrder(identities: BaseSalesOrderProductIdentity[]): Promise<import("../../modules/Order/types").OrderProduct[]>;
|
|
248
260
|
removeProductFromOrder(identity: BaseSalesOrderProductIdentity): Promise<import("../../modules/Order/types").OrderProduct[]>;
|
|
249
261
|
/**
|
|
250
262
|
* 注入促销评估器到底层 OrderModule。
|
|
@@ -84,6 +84,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
84
84
|
this.currentSalesDetail = null;
|
|
85
85
|
this.discountConfigCacheKey = null;
|
|
86
86
|
this.hasManualDiscountSelection = false;
|
|
87
|
+
this.paymentMethodsCache = [];
|
|
87
88
|
}
|
|
88
89
|
/**
|
|
89
90
|
* 子类可覆盖此方法以追加/收敛要注册的子模块。
|
|
@@ -131,6 +132,35 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
131
132
|
});
|
|
132
133
|
}
|
|
133
134
|
}
|
|
135
|
+
hydrateOrderPaymentNames(payments) {
|
|
136
|
+
if (!payments.length)
|
|
137
|
+
return [];
|
|
138
|
+
if (!this.paymentMethodsCache.length) {
|
|
139
|
+
return payments.map((payment) => ({ ...payment }));
|
|
140
|
+
}
|
|
141
|
+
const paymentMethodById = /* @__PURE__ */ new Map();
|
|
142
|
+
const paymentMethodByCode = /* @__PURE__ */ new Map();
|
|
143
|
+
this.paymentMethodsCache.forEach((method) => {
|
|
144
|
+
if ((method == null ? void 0 : method.id) !== void 0 && (method == null ? void 0 : method.id) !== null) {
|
|
145
|
+
paymentMethodById.set(String(method.id), method);
|
|
146
|
+
}
|
|
147
|
+
if (method == null ? void 0 : method.code) {
|
|
148
|
+
paymentMethodByCode.set(String(method.code), method);
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
return payments.map((payment) => {
|
|
152
|
+
const nextPayment = { ...payment };
|
|
153
|
+
if (nextPayment.name)
|
|
154
|
+
return nextPayment;
|
|
155
|
+
const paymentMethod = paymentMethodById.get(String(nextPayment.custom_payment_id)) || paymentMethodByCode.get(String(nextPayment.code));
|
|
156
|
+
if (!(paymentMethod == null ? void 0 : paymentMethod.name))
|
|
157
|
+
return nextPayment;
|
|
158
|
+
return {
|
|
159
|
+
...nextPayment,
|
|
160
|
+
name: paymentMethod.name
|
|
161
|
+
};
|
|
162
|
+
});
|
|
163
|
+
}
|
|
134
164
|
get payment() {
|
|
135
165
|
return this.store.payment;
|
|
136
166
|
}
|
|
@@ -435,6 +465,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
435
465
|
this.otherParams.enableTempOrderPersist
|
|
436
466
|
);
|
|
437
467
|
}
|
|
468
|
+
await this.getPaymentMethodsAsync();
|
|
438
469
|
this.core.effects.emit(`${this.name}:onInited`, {});
|
|
439
470
|
}
|
|
440
471
|
async destroy() {
|
|
@@ -1162,7 +1193,6 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1162
1193
|
...(params == null ? void 0 : params.smallTicketDataFlag) !== void 0 ? { smallTicketDataFlag: params.smallTicketDataFlag } : {},
|
|
1163
1194
|
...(params == null ? void 0 : params.enhancePayload) !== void 0 ? { enhancePayload: params.enhancePayload } : {}
|
|
1164
1195
|
};
|
|
1165
|
-
console.log(submitParams, "submitParams123");
|
|
1166
1196
|
return this.store.order.submitTempOrder(submitParams);
|
|
1167
1197
|
}
|
|
1168
1198
|
getSubmitPaymentStatus(paymentStatus) {
|
|
@@ -1227,7 +1257,8 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1227
1257
|
getOrderPayments() {
|
|
1228
1258
|
if (!this.store.order)
|
|
1229
1259
|
return [];
|
|
1230
|
-
|
|
1260
|
+
const payments = this.store.order.getOrderPayments();
|
|
1261
|
+
return this.hydrateOrderPaymentNames(payments);
|
|
1231
1262
|
}
|
|
1232
1263
|
/** 覆盖当前订单支付项,内部由 OrderModule 清洗为 Sales 协议字段。 */
|
|
1233
1264
|
setOrderPayments(payments) {
|
|
@@ -1409,11 +1440,25 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1409
1440
|
}
|
|
1410
1441
|
/** 获取可用支付方式列表,供 PaymentModal 渲染支付选项。 */
|
|
1411
1442
|
async getPaymentMethodsAsync() {
|
|
1412
|
-
|
|
1413
|
-
|
|
1443
|
+
try {
|
|
1444
|
+
const response = await this.request.get("/pay/custom-payment/all", {
|
|
1445
|
+
filterPaymentMethods: true
|
|
1446
|
+
}, {
|
|
1447
|
+
osServer: true
|
|
1448
|
+
});
|
|
1449
|
+
const paymentMethods = (response == null ? void 0 : response.data) || [];
|
|
1450
|
+
this.paymentMethodsCache = Array.isArray(paymentMethods) ? [...paymentMethods] : [];
|
|
1451
|
+
return this.getPaymentMethods();
|
|
1452
|
+
} catch (error) {
|
|
1453
|
+
this.logWarning("getPaymentMethodsAsync: 获取支付方式列表失败,使用缓存列表", {
|
|
1454
|
+
error: error instanceof Error ? error.message : String(error)
|
|
1455
|
+
});
|
|
1456
|
+
return this.getPaymentMethods();
|
|
1414
1457
|
}
|
|
1415
|
-
|
|
1416
|
-
|
|
1458
|
+
}
|
|
1459
|
+
/** 同步读取初始化时缓存的支付方式列表。 */
|
|
1460
|
+
getPaymentMethods() {
|
|
1461
|
+
return [...this.paymentMethodsCache];
|
|
1417
1462
|
}
|
|
1418
1463
|
/** 轻量舍入能力,供现金支付 UI 计算 rounding_amount。 */
|
|
1419
1464
|
roundAmount(params) {
|
|
@@ -1550,16 +1595,24 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1550
1595
|
throw error;
|
|
1551
1596
|
}
|
|
1552
1597
|
}
|
|
1553
|
-
|
|
1598
|
+
/**
|
|
1599
|
+
* 批量删除购物车行,末尾仅一次促销重算。
|
|
1600
|
+
*
|
|
1601
|
+
* @example
|
|
1602
|
+
* await baseSales.removeProductsFromOrder([identityA, identityB]);
|
|
1603
|
+
*/
|
|
1604
|
+
async removeProductsFromOrder(identities) {
|
|
1554
1605
|
try {
|
|
1555
1606
|
if (!this.store.order)
|
|
1556
1607
|
throw new Error("order 模块未初始化");
|
|
1557
|
-
|
|
1558
|
-
return products;
|
|
1608
|
+
return await this.store.order.removeProductsFromOrder(identities);
|
|
1559
1609
|
} catch (error) {
|
|
1560
1610
|
throw error;
|
|
1561
1611
|
}
|
|
1562
1612
|
}
|
|
1613
|
+
async removeProductFromOrder(identity) {
|
|
1614
|
+
return this.removeProductsFromOrder([identity]);
|
|
1615
|
+
}
|
|
1563
1616
|
// ─── 促销/赠品 透传(迁移自 booking usePromotion) ────────────────
|
|
1564
1617
|
/**
|
|
1565
1618
|
* 注入促销评估器到底层 OrderModule。
|
|
@@ -311,7 +311,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
311
311
|
date: string;
|
|
312
312
|
status: string;
|
|
313
313
|
week: string;
|
|
314
|
-
weekNum: 0 | 2 | 1 |
|
|
314
|
+
weekNum: 0 | 2 | 1 | 5 | 3 | 4 | 6;
|
|
315
315
|
}[]>;
|
|
316
316
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
317
317
|
private getScheduleDataByIds;
|
|
@@ -104,7 +104,7 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
|
104
104
|
}
|
|
105
105
|
async initialize(core, options = {}) {
|
|
106
106
|
var _a;
|
|
107
|
-
this.scan = new import_scan.default(this,
|
|
107
|
+
this.scan = new import_scan.default(this, `BOOKING_TICKET_SCAN:${this.name}`);
|
|
108
108
|
await super.initialize(core, options);
|
|
109
109
|
if (!this.request) {
|
|
110
110
|
throw new Error("bookingTicket解决方案需要 request 插件支持");
|
|
@@ -91,7 +91,6 @@ async function runAddProductDecision(host, catalogItem, decision, ctx, bridge) {
|
|
|
91
91
|
async function applyGlobalScan(host, formatted, bridge) {
|
|
92
92
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
93
93
|
const { searchType, data, scanCode } = formatted;
|
|
94
|
-
debugger;
|
|
95
94
|
if (searchType === "wallet") {
|
|
96
95
|
if (!data) {
|
|
97
96
|
(_a = bridge == null ? void 0 : bridge.onNotify) == null ? void 0 : _a.call(bridge, "fail", "pisell2.text.scan-global-failed");
|
|
@@ -157,7 +156,7 @@ async function applyGlobalScan(host, formatted, bridge) {
|
|
|
157
156
|
}
|
|
158
157
|
bridge.openOrder({
|
|
159
158
|
order_id: Number(orderId),
|
|
160
|
-
business_code: host.getBusinessCode()
|
|
159
|
+
business_code: (data == null ? void 0 : data.business_code) ?? host.getBusinessCode()
|
|
161
160
|
});
|
|
162
161
|
return { status: "pending", kind: "openOrder" };
|
|
163
162
|
}
|
|
@@ -14,12 +14,17 @@ declare enum ScanResultType {
|
|
|
14
14
|
NativeScanner = "nativeScanner"
|
|
15
15
|
}
|
|
16
16
|
export default class Scan {
|
|
17
|
+
private static scanInstances;
|
|
18
|
+
private static peripheralsListenerMounted;
|
|
17
19
|
private solution;
|
|
18
20
|
private watchKey;
|
|
19
21
|
private listenerConfig;
|
|
20
22
|
constructor(solution: BookingTicketImpl, watchKey: string);
|
|
21
23
|
/**
|
|
22
24
|
* 初始化外设扫码结果监听
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* scan.initPeripheralsListener();
|
|
23
28
|
*/
|
|
24
29
|
initPeripheralsListener(): void;
|
|
25
30
|
/**
|
|
@@ -34,17 +34,24 @@ __export(scan_exports, {
|
|
|
34
34
|
module.exports = __toCommonJS(scan_exports);
|
|
35
35
|
var import_watch = __toESM(require("../../../../utils/watch"));
|
|
36
36
|
var import_task = __toESM(require("../../../../utils/task"));
|
|
37
|
-
var
|
|
37
|
+
var _Scan = class {
|
|
38
38
|
constructor(solution, watchKey) {
|
|
39
39
|
this.listenerConfig = /* @__PURE__ */ new Map();
|
|
40
40
|
this.solution = solution;
|
|
41
41
|
this.watchKey = watchKey;
|
|
42
|
+
_Scan.scanInstances.add(this);
|
|
42
43
|
}
|
|
43
44
|
/**
|
|
44
45
|
* 初始化外设扫码结果监听
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* scan.initPeripheralsListener();
|
|
45
49
|
*/
|
|
46
50
|
initPeripheralsListener() {
|
|
47
51
|
var _a, _b, _c, _d, _e;
|
|
52
|
+
if (_Scan.peripheralsListenerMounted)
|
|
53
|
+
return;
|
|
54
|
+
_Scan.peripheralsListenerMounted = true;
|
|
48
55
|
(_e = (_d = (_c = (_b = (_a = this.solution) == null ? void 0 : _a.window) == null ? void 0 : _b.interaction) == null ? void 0 : _c.utils) == null ? void 0 : _d.mountFunction) == null ? void 0 : _e.call(
|
|
49
56
|
_d,
|
|
50
57
|
"global",
|
|
@@ -53,7 +60,9 @@ var Scan = class {
|
|
|
53
60
|
try {
|
|
54
61
|
const result = JSON.parse(strVal);
|
|
55
62
|
console.log("nativeScannerResult>>>>>>>", result);
|
|
56
|
-
|
|
63
|
+
_Scan.scanInstances.forEach((instance) => {
|
|
64
|
+
instance.handleScan(result);
|
|
65
|
+
});
|
|
57
66
|
} catch (err) {
|
|
58
67
|
console.error(err);
|
|
59
68
|
}
|
|
@@ -70,8 +79,9 @@ var Scan = class {
|
|
|
70
79
|
if (lastEnableEventKey) {
|
|
71
80
|
const listenerConfig = this.listenerConfig.get(lastEnableEventKey);
|
|
72
81
|
if (listenerConfig) {
|
|
82
|
+
const taskUuid = this.generateUuid();
|
|
73
83
|
listenerConfig.task.addTask({
|
|
74
|
-
uuid:
|
|
84
|
+
uuid: taskUuid,
|
|
75
85
|
type: lastEnableEventKey,
|
|
76
86
|
actionParams: {
|
|
77
87
|
scanResult: result
|
|
@@ -122,6 +132,7 @@ var Scan = class {
|
|
|
122
132
|
*/
|
|
123
133
|
removeAllListeners() {
|
|
124
134
|
var _a, _b, _c, _d;
|
|
135
|
+
_Scan.scanInstances.delete(this);
|
|
125
136
|
import_watch.default.clearEvent(this.watchKey);
|
|
126
137
|
(_b = (_a = this.listenerConfig) == null ? void 0 : _a.forEach) == null ? void 0 : _b.call(_a, (item) => {
|
|
127
138
|
var _a2;
|
|
@@ -213,3 +224,6 @@ var Scan = class {
|
|
|
213
224
|
}
|
|
214
225
|
}
|
|
215
226
|
};
|
|
227
|
+
var Scan = _Scan;
|
|
228
|
+
Scan.scanInstances = /* @__PURE__ */ new Set();
|
|
229
|
+
Scan.peripheralsListenerMounted = false;
|