@pisell/pisellos 2.2.204 → 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/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/modules/Order/index.js +9 -3
- 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 +6 -1
- package/dist/solution/BaseSales/index.js +67 -18
- 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.js +5 -1
- 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 +6 -1
- package/lib/solution/BaseSales/index.js +51 -5
- 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
|
@@ -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() {
|
|
@@ -1226,7 +1257,8 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1226
1257
|
getOrderPayments() {
|
|
1227
1258
|
if (!this.store.order)
|
|
1228
1259
|
return [];
|
|
1229
|
-
|
|
1260
|
+
const payments = this.store.order.getOrderPayments();
|
|
1261
|
+
return this.hydrateOrderPaymentNames(payments);
|
|
1230
1262
|
}
|
|
1231
1263
|
/** 覆盖当前订单支付项,内部由 OrderModule 清洗为 Sales 协议字段。 */
|
|
1232
1264
|
setOrderPayments(payments) {
|
|
@@ -1408,11 +1440,25 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1408
1440
|
}
|
|
1409
1441
|
/** 获取可用支付方式列表,供 PaymentModal 渲染支付选项。 */
|
|
1410
1442
|
async getPaymentMethodsAsync() {
|
|
1411
|
-
|
|
1412
|
-
|
|
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();
|
|
1413
1457
|
}
|
|
1414
|
-
|
|
1415
|
-
|
|
1458
|
+
}
|
|
1459
|
+
/** 同步读取初始化时缓存的支付方式列表。 */
|
|
1460
|
+
getPaymentMethods() {
|
|
1461
|
+
return [...this.paymentMethodsCache];
|
|
1416
1462
|
}
|
|
1417
1463
|
/** 轻量舍入能力,供现金支付 UI 计算 rounding_amount。 */
|
|
1418
1464
|
roundAmount(params) {
|
|
@@ -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;
|