@pisell/pisellos 0.0.214 → 0.0.215
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/core/index.js +2 -1
- package/dist/effects/index.d.ts +4 -3
- package/dist/effects/index.js +15 -6
- package/dist/modules/AccountList/index.d.ts +7 -1
- package/dist/modules/AccountList/index.js +81 -14
- package/dist/modules/AccountList/types.d.ts +28 -0
- package/dist/modules/AccountList/types.js +8 -0
- package/dist/modules/Customer/constants.d.ts +7 -0
- package/dist/modules/Customer/constants.js +12 -0
- package/dist/modules/Customer/index.d.ts +89 -0
- package/dist/modules/Customer/index.js +439 -0
- package/dist/modules/Customer/types.d.ts +130 -0
- package/dist/modules/Customer/types.js +39 -0
- package/dist/modules/ProductList/index.d.ts +6 -1
- package/dist/modules/ProductList/index.js +8 -4
- package/dist/modules/Rules/index.js +7 -5
- package/dist/modules/Rules/types.d.ts +1 -0
- package/dist/modules/index.d.ts +1 -0
- package/dist/modules/index.js +1 -0
- package/dist/plugins/window.d.ts +1 -0
- package/dist/solution/BookingByStep/index.js +8 -15
- package/dist/solution/BookingTicket/index.d.ts +127 -0
- package/dist/solution/BookingTicket/index.js +494 -0
- package/dist/solution/BookingTicket/types.d.ts +66 -0
- package/dist/solution/BookingTicket/types.js +41 -0
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.d.ts +22 -0
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +147 -0
- package/dist/solution/BookingTicket/utils/scan/handleScan.d.ts +19 -0
- package/dist/solution/BookingTicket/utils/scan/handleScan.js +138 -0
- package/dist/solution/BookingTicket/utils/scan/index.d.ts +51 -0
- package/dist/solution/BookingTicket/utils/scan/index.js +189 -0
- package/dist/solution/ShopDiscount/index.js +4 -2
- package/dist/solution/index.d.ts +1 -0
- package/dist/solution/index.js +1 -0
- package/dist/types/index.d.ts +3 -1
- package/dist/utils/task.d.ts +31 -0
- package/dist/utils/task.js +150 -0
- package/dist/utils/watch.d.ts +102 -0
- package/dist/utils/watch.js +294 -0
- package/lib/core/index.js +1 -1
- package/lib/effects/index.d.ts +4 -3
- package/lib/effects/index.js +4 -1
- package/lib/modules/AccountList/index.d.ts +7 -1
- package/lib/modules/AccountList/index.js +27 -0
- package/lib/modules/AccountList/types.d.ts +28 -0
- package/lib/modules/Customer/constants.d.ts +7 -0
- package/lib/modules/Customer/constants.js +39 -0
- package/lib/modules/Customer/index.d.ts +89 -0
- package/lib/modules/Customer/index.js +304 -0
- package/lib/modules/Customer/types.d.ts +130 -0
- package/lib/modules/Customer/types.js +35 -0
- package/lib/modules/ProductList/index.d.ts +6 -1
- package/lib/modules/ProductList/index.js +12 -3
- package/lib/modules/Rules/index.js +4 -3
- package/lib/modules/Rules/types.d.ts +1 -0
- package/lib/modules/index.d.ts +1 -0
- package/lib/modules/index.js +2 -0
- package/lib/plugins/window.d.ts +1 -0
- package/lib/solution/BookingByStep/index.js +0 -7
- package/lib/solution/BookingTicket/index.d.ts +127 -0
- package/lib/solution/BookingTicket/index.js +291 -0
- package/lib/solution/BookingTicket/types.d.ts +66 -0
- package/lib/solution/BookingTicket/types.js +70 -0
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.d.ts +22 -0
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +97 -0
- package/lib/solution/BookingTicket/utils/scan/handleScan.d.ts +19 -0
- package/lib/solution/BookingTicket/utils/scan/handleScan.js +95 -0
- package/lib/solution/BookingTicket/utils/scan/index.d.ts +51 -0
- package/lib/solution/BookingTicket/utils/scan/index.js +153 -0
- package/lib/solution/ShopDiscount/index.js +2 -1
- package/lib/solution/index.d.ts +1 -0
- package/lib/solution/index.js +2 -0
- package/lib/types/index.d.ts +3 -1
- package/lib/utils/task.d.ts +31 -0
- package/lib/utils/task.js +84 -0
- package/lib/utils/watch.d.ts +102 -0
- package/lib/utils/watch.js +217 -0
- package/package.json +1 -1
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { RequestPlugin } from '../../../../plugins';
|
|
2
|
+
/**
|
|
3
|
+
* 搜索通用识别码
|
|
4
|
+
*/
|
|
5
|
+
export declare const searchWalletPass: (request: RequestPlugin, code: string) => Promise<{
|
|
6
|
+
searchType: string;
|
|
7
|
+
response: any;
|
|
8
|
+
}>;
|
|
9
|
+
/**
|
|
10
|
+
* 搜索钱包
|
|
11
|
+
*/
|
|
12
|
+
export declare const searchWallet: (request: RequestPlugin, code: string) => Promise<{
|
|
13
|
+
searchType: string;
|
|
14
|
+
response: any;
|
|
15
|
+
}>;
|
|
16
|
+
/**
|
|
17
|
+
* 搜索商品
|
|
18
|
+
*/
|
|
19
|
+
export declare const searchProduct: (request: RequestPlugin, code: string) => Promise<{
|
|
20
|
+
searchType: string;
|
|
21
|
+
response: any;
|
|
22
|
+
}>;
|
|
@@ -0,0 +1,97 @@
|
|
|
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/solution/BookingTicket/utils/scan/cloudSearch.ts
|
|
20
|
+
var cloudSearch_exports = {};
|
|
21
|
+
__export(cloudSearch_exports, {
|
|
22
|
+
searchProduct: () => searchProduct,
|
|
23
|
+
searchWallet: () => searchWallet,
|
|
24
|
+
searchWalletPass: () => searchWalletPass
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(cloudSearch_exports);
|
|
27
|
+
var searchWalletPass = async (request, code) => {
|
|
28
|
+
const params = {
|
|
29
|
+
code,
|
|
30
|
+
translate_flag: 1,
|
|
31
|
+
// 翻译识别码名称 0:不翻译 1:翻译
|
|
32
|
+
relation_product: 1,
|
|
33
|
+
// 组装关联商品: 0不处理 1处理
|
|
34
|
+
tags: [
|
|
35
|
+
"point_card",
|
|
36
|
+
// 积分卡
|
|
37
|
+
"gift_card",
|
|
38
|
+
// 充值卡
|
|
39
|
+
"product_voucher",
|
|
40
|
+
// 代金券
|
|
41
|
+
"product_discount_card",
|
|
42
|
+
// 折扣卡
|
|
43
|
+
"good_pass",
|
|
44
|
+
// 商品券
|
|
45
|
+
"session_ticket",
|
|
46
|
+
// 场次票
|
|
47
|
+
"appointment_ticket"
|
|
48
|
+
// 预约类门票
|
|
49
|
+
]
|
|
50
|
+
};
|
|
51
|
+
try {
|
|
52
|
+
const res = await (request == null ? void 0 : request.get(
|
|
53
|
+
"/machinecode/batch-search",
|
|
54
|
+
params
|
|
55
|
+
));
|
|
56
|
+
if ((res == null ? void 0 : res.code) == 200 && !!(res == null ? void 0 : res.data)) {
|
|
57
|
+
return { searchType: "walletPass", response: res };
|
|
58
|
+
}
|
|
59
|
+
throw new Error("没有找到对应的识别码");
|
|
60
|
+
} catch (error) {
|
|
61
|
+
throw error;
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
var searchWallet = async (request, code) => {
|
|
65
|
+
const params = { code };
|
|
66
|
+
try {
|
|
67
|
+
const res = await (request == null ? void 0 : request.post(
|
|
68
|
+
"/wallet/detail/search",
|
|
69
|
+
params
|
|
70
|
+
));
|
|
71
|
+
if ((res == null ? void 0 : res.code) == 200 && !!(res == null ? void 0 : res.data)) {
|
|
72
|
+
return { searchType: "wallet", response: res };
|
|
73
|
+
}
|
|
74
|
+
throw new Error("没有找到对应的识别码");
|
|
75
|
+
} catch (error) {
|
|
76
|
+
throw error;
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
var searchProduct = async (request, code) => {
|
|
80
|
+
var _a, _b;
|
|
81
|
+
const params = { search: code };
|
|
82
|
+
try {
|
|
83
|
+
const res = await (request == null ? void 0 : request.get("/product/list", params));
|
|
84
|
+
if ((res == null ? void 0 : res.code) == 200 && ((_b = (_a = res == null ? void 0 : res.data) == null ? void 0 : _a.list) == null ? void 0 : _b.length) > 0) {
|
|
85
|
+
return { searchType: "product", response: res };
|
|
86
|
+
}
|
|
87
|
+
throw new Error("没有找到对应的识别码");
|
|
88
|
+
} catch (error) {
|
|
89
|
+
throw error;
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
93
|
+
0 && (module.exports = {
|
|
94
|
+
searchProduct,
|
|
95
|
+
searchWallet,
|
|
96
|
+
searchWalletPass
|
|
97
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { RequestPlugin } from '../../../../plugins';
|
|
2
|
+
/**
|
|
3
|
+
* 处理全局扫码
|
|
4
|
+
* @param request 请求插件
|
|
5
|
+
* @returns 处理结果
|
|
6
|
+
*/
|
|
7
|
+
export declare const handleGlobalScan: (request: RequestPlugin) => (scanResult: {
|
|
8
|
+
type: string;
|
|
9
|
+
value: string;
|
|
10
|
+
}) => Promise<any>;
|
|
11
|
+
/**
|
|
12
|
+
* 处理客户扫码
|
|
13
|
+
* @param request 请求插件
|
|
14
|
+
* @returns 处理结果
|
|
15
|
+
*/
|
|
16
|
+
export declare const handleCustomerScan: (request: RequestPlugin) => (scanResult: {
|
|
17
|
+
type: string;
|
|
18
|
+
value: string;
|
|
19
|
+
}) => Promise<any>;
|
|
@@ -0,0 +1,95 @@
|
|
|
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/solution/BookingTicket/utils/scan/handleScan.ts
|
|
20
|
+
var handleScan_exports = {};
|
|
21
|
+
__export(handleScan_exports, {
|
|
22
|
+
handleCustomerScan: () => handleCustomerScan,
|
|
23
|
+
handleGlobalScan: () => handleGlobalScan
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(handleScan_exports);
|
|
26
|
+
var import_cloudSearch = require("./cloudSearch");
|
|
27
|
+
var promiseAny = async (promises) => {
|
|
28
|
+
if (promises.length === 0) {
|
|
29
|
+
throw new Error("No promises provided");
|
|
30
|
+
}
|
|
31
|
+
const errors = [];
|
|
32
|
+
let completedCount = 0;
|
|
33
|
+
return new Promise((resolve, reject) => {
|
|
34
|
+
promises.forEach((promise, index) => {
|
|
35
|
+
promise.then((result) => {
|
|
36
|
+
resolve(result);
|
|
37
|
+
}).catch((error) => {
|
|
38
|
+
errors[index] = error;
|
|
39
|
+
completedCount++;
|
|
40
|
+
if (completedCount === promises.length) {
|
|
41
|
+
const errorMessage = `All promises were rejected. Errors: ${errors.map((e) => e.message).join(", ")}`;
|
|
42
|
+
const combinedError = new Error(errorMessage);
|
|
43
|
+
combinedError.errors = errors;
|
|
44
|
+
reject(combinedError);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
var handleGlobalScan = (request) => {
|
|
51
|
+
return async (scanResult) => {
|
|
52
|
+
const { value } = scanResult || {};
|
|
53
|
+
let requestList = [];
|
|
54
|
+
if (value.startsWith("WL")) {
|
|
55
|
+
requestList = [(0, import_cloudSearch.searchWallet)(request, value)];
|
|
56
|
+
} else {
|
|
57
|
+
requestList = [
|
|
58
|
+
(0, import_cloudSearch.searchWalletPass)(request, value),
|
|
59
|
+
(0, import_cloudSearch.searchWallet)(request, value),
|
|
60
|
+
(0, import_cloudSearch.searchProduct)(request, value)
|
|
61
|
+
];
|
|
62
|
+
}
|
|
63
|
+
try {
|
|
64
|
+
const result = await promiseAny(requestList);
|
|
65
|
+
return result;
|
|
66
|
+
} catch (error) {
|
|
67
|
+
throw error;
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
var handleCustomerScan = (request) => {
|
|
72
|
+
return async (scanResult) => {
|
|
73
|
+
const { value } = scanResult || {};
|
|
74
|
+
let requestList = [];
|
|
75
|
+
if (value.startsWith("WL")) {
|
|
76
|
+
requestList = [(0, import_cloudSearch.searchWallet)(request, value)];
|
|
77
|
+
} else {
|
|
78
|
+
requestList = [
|
|
79
|
+
(0, import_cloudSearch.searchWalletPass)(request, value),
|
|
80
|
+
(0, import_cloudSearch.searchWallet)(request, value)
|
|
81
|
+
];
|
|
82
|
+
}
|
|
83
|
+
try {
|
|
84
|
+
const result = await Promise.race(requestList);
|
|
85
|
+
return result;
|
|
86
|
+
} catch (error) {
|
|
87
|
+
throw error;
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
92
|
+
0 && (module.exports = {
|
|
93
|
+
handleCustomerScan,
|
|
94
|
+
handleGlobalScan
|
|
95
|
+
});
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { WatchEventItem } from '../../../../utils/watch';
|
|
2
|
+
import { BookingTicketImpl } from '../../index';
|
|
3
|
+
import Tasks from '../../../../utils/task';
|
|
4
|
+
interface ScanResult {
|
|
5
|
+
type: string;
|
|
6
|
+
value: string;
|
|
7
|
+
}
|
|
8
|
+
export declare class Scan {
|
|
9
|
+
private solution;
|
|
10
|
+
private watchKey;
|
|
11
|
+
private listenerConfig;
|
|
12
|
+
constructor(solution: BookingTicketImpl, watchKey: string);
|
|
13
|
+
/**
|
|
14
|
+
* 添加扫码信息监听
|
|
15
|
+
* @param watchKey 监听的key
|
|
16
|
+
* @param event 事件
|
|
17
|
+
*/
|
|
18
|
+
addListener(event: WatchEventItem, callback?: (result: ScanResult) => Promise<any>): {
|
|
19
|
+
remove: () => void;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* 移除扫码信息监听
|
|
23
|
+
* @param watchKey 监听的key
|
|
24
|
+
* @param event 事件
|
|
25
|
+
*/
|
|
26
|
+
removeListener(event: WatchEventItem): void;
|
|
27
|
+
/**
|
|
28
|
+
* 处理扫码事件
|
|
29
|
+
* @param eventKey 事件key
|
|
30
|
+
* @param value 扫码结果
|
|
31
|
+
*/
|
|
32
|
+
handleScan(value: {
|
|
33
|
+
type: string;
|
|
34
|
+
value: string;
|
|
35
|
+
}): void;
|
|
36
|
+
/**
|
|
37
|
+
* 获取监听配置
|
|
38
|
+
* @param eventKey 事件key
|
|
39
|
+
* @returns 监听配置
|
|
40
|
+
*/
|
|
41
|
+
getListenerConfig(eventKey: string): {
|
|
42
|
+
callback?: ((result: ScanResult) => Promise<any>) | undefined;
|
|
43
|
+
task: Tasks;
|
|
44
|
+
} | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* 处理扫码结果
|
|
47
|
+
* @param args 参数
|
|
48
|
+
*/
|
|
49
|
+
handleScanResultFn(...args: any[]): Promise<void>;
|
|
50
|
+
}
|
|
51
|
+
export {};
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/solution/BookingTicket/utils/scan/index.ts
|
|
30
|
+
var scan_exports = {};
|
|
31
|
+
__export(scan_exports, {
|
|
32
|
+
Scan: () => Scan
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(scan_exports);
|
|
35
|
+
var import_watch = __toESM(require("../../../../utils/watch"));
|
|
36
|
+
var import_task = __toESM(require("../../../../utils/task"));
|
|
37
|
+
var Scan = class {
|
|
38
|
+
constructor(solution, watchKey) {
|
|
39
|
+
this.listenerConfig = /* @__PURE__ */ new Map();
|
|
40
|
+
var _a, _b, _c, _d, _e, _f;
|
|
41
|
+
this.solution = solution;
|
|
42
|
+
this.watchKey = watchKey;
|
|
43
|
+
console.log(
|
|
44
|
+
"this.solution?.window?.interaction",
|
|
45
|
+
(_a = solution == null ? void 0 : solution.window) == null ? void 0 : _a.interaction
|
|
46
|
+
);
|
|
47
|
+
(_f = (_e = (_d = (_c = (_b = this.solution) == null ? void 0 : _b.window) == null ? void 0 : _c.interaction) == null ? void 0 : _d.utils) == null ? void 0 : _e.mountFunction) == null ? void 0 : _f.call(
|
|
48
|
+
_e,
|
|
49
|
+
"global",
|
|
50
|
+
"nativeScannerResult",
|
|
51
|
+
(strVal) => {
|
|
52
|
+
try {
|
|
53
|
+
const result = JSON.parse(strVal);
|
|
54
|
+
console.log("nativeScannerResult>>>>>>>", result);
|
|
55
|
+
this.handleScan(result);
|
|
56
|
+
} catch (err) {
|
|
57
|
+
console.error(err);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* 添加扫码信息监听
|
|
64
|
+
* @param watchKey 监听的key
|
|
65
|
+
* @param event 事件
|
|
66
|
+
*/
|
|
67
|
+
addListener(event, callback) {
|
|
68
|
+
import_watch.default.subscribe(this.watchKey, event);
|
|
69
|
+
const task = new import_task.default();
|
|
70
|
+
task.addAction(
|
|
71
|
+
event.key,
|
|
72
|
+
(...args) => this.handleScanResultFn(event.key, ...args)
|
|
73
|
+
);
|
|
74
|
+
this.listenerConfig.set(event.key, { callback, task });
|
|
75
|
+
return {
|
|
76
|
+
remove: () => {
|
|
77
|
+
this.removeListener(event);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* 移除扫码信息监听
|
|
83
|
+
* @param watchKey 监听的key
|
|
84
|
+
* @param event 事件
|
|
85
|
+
*/
|
|
86
|
+
removeListener(event) {
|
|
87
|
+
var _a;
|
|
88
|
+
import_watch.default.unsubscribe(this.watchKey, event);
|
|
89
|
+
(_a = this.listenerConfig.get(event.key)) == null ? void 0 : _a.task.clear();
|
|
90
|
+
this.listenerConfig.delete(event.key);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* 处理扫码事件
|
|
94
|
+
* @param eventKey 事件key
|
|
95
|
+
* @param value 扫码结果
|
|
96
|
+
*/
|
|
97
|
+
handleScan(value) {
|
|
98
|
+
const lastEnableEventKey = import_watch.default.getLastEnableEventKey(this.watchKey);
|
|
99
|
+
if (lastEnableEventKey) {
|
|
100
|
+
const listenerConfig = this.listenerConfig.get(lastEnableEventKey);
|
|
101
|
+
if (listenerConfig) {
|
|
102
|
+
listenerConfig.task.addTask({
|
|
103
|
+
type: lastEnableEventKey,
|
|
104
|
+
actionParams: {
|
|
105
|
+
scanResult: value
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* 获取监听配置
|
|
113
|
+
* @param eventKey 事件key
|
|
114
|
+
* @returns 监听配置
|
|
115
|
+
*/
|
|
116
|
+
getListenerConfig(eventKey) {
|
|
117
|
+
var _a;
|
|
118
|
+
return (_a = this.listenerConfig) == null ? void 0 : _a.get(eventKey);
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* 处理扫码结果
|
|
122
|
+
* @param args 参数
|
|
123
|
+
*/
|
|
124
|
+
async handleScanResultFn(...args) {
|
|
125
|
+
var _a;
|
|
126
|
+
const [eventKey, other] = args;
|
|
127
|
+
const { type, value } = (other == null ? void 0 : other.scanResult) || {};
|
|
128
|
+
const listenerCallback = (_a = this.getListenerConfig(eventKey)) == null ? void 0 : _a.callback;
|
|
129
|
+
if (listenerCallback) {
|
|
130
|
+
try {
|
|
131
|
+
const result = await listenerCallback({ type, value });
|
|
132
|
+
import_watch.default.publishByEventKey(this.watchKey, eventKey, {
|
|
133
|
+
type: eventKey,
|
|
134
|
+
status: "success",
|
|
135
|
+
scanType: type,
|
|
136
|
+
scanCode: value,
|
|
137
|
+
result
|
|
138
|
+
});
|
|
139
|
+
} catch (error) {
|
|
140
|
+
import_watch.default.publishByEventKey(this.watchKey, eventKey, {
|
|
141
|
+
type: eventKey,
|
|
142
|
+
status: "failed",
|
|
143
|
+
scanType: type,
|
|
144
|
+
scanCode: value
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
151
|
+
0 && (module.exports = {
|
|
152
|
+
Scan
|
|
153
|
+
});
|
|
@@ -38,6 +38,7 @@ var import_types = require("./types");
|
|
|
38
38
|
var import_Discount = require("../../modules/Discount");
|
|
39
39
|
var import_Rules = require("../../modules/Rules");
|
|
40
40
|
var import_decimal = __toESM(require("decimal.js"));
|
|
41
|
+
var import_lodash_es = require("lodash-es");
|
|
41
42
|
var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
42
43
|
constructor(name, version) {
|
|
43
44
|
super(name, version);
|
|
@@ -337,7 +338,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
337
338
|
var _a2;
|
|
338
339
|
const targetProduct = productList.find((n) => n.id === id);
|
|
339
340
|
const product = (_a2 = this.hooks) == null ? void 0 : _a2.getProduct(targetProduct);
|
|
340
|
-
return Number(product == null ? void 0 : product.total)
|
|
341
|
+
return Number(product == null ? void 0 : product.total) <= 0 && (Number(product == null ? void 0 : product.origin_total) <= 0 || !(product == null ? void 0 : product.origin_total)) || (0, import_lodash_es.isBoolean)(product == null ? void 0 : product.vouchersApplicable) && !(product == null ? void 0 : product.vouchersApplicable);
|
|
341
342
|
};
|
|
342
343
|
const allUsedProductIds = newDiscountList.map((n) => {
|
|
343
344
|
var _a2;
|
package/lib/solution/index.d.ts
CHANGED
package/lib/solution/index.js
CHANGED
|
@@ -18,10 +18,12 @@ var solution_exports = {};
|
|
|
18
18
|
module.exports = __toCommonJS(solution_exports);
|
|
19
19
|
__reExport(solution_exports, require("./BuyTickets"), module.exports);
|
|
20
20
|
__reExport(solution_exports, require("./BookingByStep"), module.exports);
|
|
21
|
+
__reExport(solution_exports, require("./BookingTicket"), module.exports);
|
|
21
22
|
__reExport(solution_exports, require("./ShopDiscount"), module.exports);
|
|
22
23
|
// Annotate the CommonJS export names for ESM import in node:
|
|
23
24
|
0 && (module.exports = {
|
|
24
25
|
...require("./BuyTickets"),
|
|
25
26
|
...require("./BookingByStep"),
|
|
27
|
+
...require("./BookingTicket"),
|
|
26
28
|
...require("./ShopDiscount")
|
|
27
29
|
});
|
package/lib/types/index.d.ts
CHANGED
|
@@ -38,7 +38,9 @@ export interface PisellCore {
|
|
|
38
38
|
getModuleExports: <T = any>(name: string) => T | null;
|
|
39
39
|
hasModule: (name: string) => boolean;
|
|
40
40
|
effects: {
|
|
41
|
-
on: (event: string, callback: (payload: any) => void) => void;
|
|
41
|
+
on: (event: string, callback: (payload: any) => void) => () => void;
|
|
42
|
+
once: (event: string, callback: (payload: any) => void) => () => void;
|
|
43
|
+
off: (event: string, callback: (payload: any) => void) => void;
|
|
42
44
|
emit: (event: string, payload: any, value?: any) => Promise<{
|
|
43
45
|
status: boolean;
|
|
44
46
|
data: any;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
type Action = (...args: any[]) => Promise<any>;
|
|
2
|
+
type Task = {
|
|
3
|
+
type: string;
|
|
4
|
+
actionParams?: Record<string, any>;
|
|
5
|
+
};
|
|
6
|
+
declare class Tasks {
|
|
7
|
+
private actions;
|
|
8
|
+
private taskQueue;
|
|
9
|
+
isRunning: boolean;
|
|
10
|
+
constructor(actions?: Map<string, Action>);
|
|
11
|
+
/**
|
|
12
|
+
* 清空任务队列
|
|
13
|
+
*/
|
|
14
|
+
clear(): void;
|
|
15
|
+
/**
|
|
16
|
+
* 添加action
|
|
17
|
+
* @param name action名称
|
|
18
|
+
* @param action action函数
|
|
19
|
+
*/
|
|
20
|
+
addAction(name: string, action: Action): void;
|
|
21
|
+
/**
|
|
22
|
+
* 添加任务
|
|
23
|
+
* @param task 任务
|
|
24
|
+
*/
|
|
25
|
+
addTask(task: Task): void;
|
|
26
|
+
/**
|
|
27
|
+
* 执行任务
|
|
28
|
+
*/
|
|
29
|
+
run(): Promise<void>;
|
|
30
|
+
}
|
|
31
|
+
export default Tasks;
|
|
@@ -0,0 +1,84 @@
|
|
|
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/utils/task.ts
|
|
20
|
+
var task_exports = {};
|
|
21
|
+
__export(task_exports, {
|
|
22
|
+
default: () => task_default
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(task_exports);
|
|
25
|
+
var Tasks = class {
|
|
26
|
+
constructor(actions) {
|
|
27
|
+
this.actions = /* @__PURE__ */ new Map();
|
|
28
|
+
this.taskQueue = [];
|
|
29
|
+
this.isRunning = false;
|
|
30
|
+
if (actions) {
|
|
31
|
+
this.actions = actions;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* 清空任务队列
|
|
36
|
+
*/
|
|
37
|
+
clear() {
|
|
38
|
+
this.actions.clear();
|
|
39
|
+
this.taskQueue = [];
|
|
40
|
+
this.isRunning = false;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* 添加action
|
|
44
|
+
* @param name action名称
|
|
45
|
+
* @param action action函数
|
|
46
|
+
*/
|
|
47
|
+
addAction(name, action) {
|
|
48
|
+
this.actions.set(name, action);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* 添加任务
|
|
52
|
+
* @param task 任务
|
|
53
|
+
*/
|
|
54
|
+
addTask(task) {
|
|
55
|
+
this.taskQueue.push(task);
|
|
56
|
+
this.run();
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* 执行任务
|
|
60
|
+
*/
|
|
61
|
+
async run() {
|
|
62
|
+
if (this.isRunning) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (this.taskQueue.length === 0) {
|
|
66
|
+
this.isRunning = false;
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
this.isRunning = true;
|
|
70
|
+
while (this.taskQueue.length > 0) {
|
|
71
|
+
const task = this.taskQueue.shift();
|
|
72
|
+
if (!task) {
|
|
73
|
+
this.isRunning = false;
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const action = this.actions.get(task.type);
|
|
77
|
+
if (action) {
|
|
78
|
+
await action((task == null ? void 0 : task.actionParams) || {});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
this.isRunning = false;
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
var task_default = Tasks;
|