@pisell/pisellos 3.0.56 → 3.0.57
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/Cart/index.js +1 -1
- package/dist/modules/Cart/utils/changePrice.d.ts +2 -2
- package/dist/modules/Cart/utils/changePrice.js +1 -1
- package/dist/modules/Customer/constants.d.ts +7 -0
- package/dist/modules/Customer/constants.js +12 -0
- package/dist/modules/Customer/index.d.ts +122 -0
- package/dist/modules/Customer/index.js +697 -0
- package/dist/modules/Customer/types.d.ts +146 -0
- package/dist/modules/Customer/types.js +41 -0
- package/dist/modules/Payment/cash.d.ts +11 -0
- package/dist/modules/Payment/cash.js +78 -0
- package/dist/modules/Payment/eftpos.d.ts +11 -0
- package/dist/modules/Payment/eftpos.js +80 -0
- package/dist/modules/Payment/index.d.ts +273 -9
- package/dist/modules/Payment/index.js +2525 -109
- package/dist/modules/Payment/types.d.ts +382 -30
- package/dist/modules/Payment/types.js +116 -14
- package/dist/modules/Payment/wallet.d.ts +11 -0
- package/dist/modules/Payment/wallet.js +78 -0
- package/dist/modules/Payment/walletpass.d.ts +0 -0
- package/dist/modules/Payment/walletpass.js +0 -0
- package/dist/modules/ProductList/index.d.ts +13 -3
- package/dist/modules/ProductList/index.js +52 -42
- package/dist/modules/ProductList/types.d.ts +0 -1
- package/dist/modules/Rules/index.js +27 -14
- 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/app-types/app/app.d.ts +83 -0
- package/dist/plugins/app-types/app/const.d.ts +4 -0
- package/dist/plugins/app-types/app/index.d.ts +14 -0
- package/dist/plugins/app-types/applicationManager/application.d.ts +50 -0
- package/dist/plugins/app-types/applicationManager/index.d.ts +13 -0
- package/dist/plugins/app-types/config.d.ts +3 -0
- package/dist/plugins/app-types/cookie/index.d.ts +13 -0
- package/dist/plugins/app-types/data/index.d.ts +8 -0
- package/dist/plugins/app-types/history/config.d.ts +24 -0
- package/dist/plugins/app-types/history/index.d.ts +20 -0
- package/dist/plugins/app-types/history/type.d.ts +2 -0
- package/dist/plugins/app-types/hooks/index.d.ts +12 -0
- package/dist/plugins/app-types/hooks/useDelayedValue/index.d.ts +2 -0
- package/dist/plugins/app-types/hooks/useDispatch/index.d.ts +2 -0
- package/dist/plugins/app-types/hooks/useLowCode/index.d.ts +13 -0
- package/dist/plugins/app-types/hooks/useStore/index.d.ts +6 -0
- package/dist/plugins/app-types/index.d.ts +6 -0
- package/dist/plugins/app-types/indexDB/index.d.ts +178 -0
- package/dist/plugins/app-types/locales/en.d.ts +3 -0
- package/dist/plugins/app-types/locales/index.d.ts +37 -0
- package/dist/plugins/app-types/locales/original.d.ts +3 -0
- package/dist/plugins/app-types/locales/type.d.ts +19 -0
- package/dist/plugins/app-types/locales/zh-CN.d.ts +3 -0
- package/dist/plugins/app-types/locales/zh-HK.d.ts +3 -0
- package/dist/plugins/app-types/logger/feishu.d.ts +11 -0
- package/dist/plugins/app-types/logger/index.d.ts +122 -0
- package/dist/plugins/app-types/menuManager/hooks.d.ts +17 -0
- package/dist/plugins/app-types/menuManager/index.d.ts +28 -0
- package/dist/plugins/app-types/models/global.d.ts +32 -0
- package/dist/plugins/app-types/models/index.d.ts +45 -0
- package/dist/plugins/app-types/models/type.d.ts +2 -0
- package/dist/plugins/app-types/package.json +15 -0
- package/dist/plugins/app-types/plugin/index.d.ts +0 -0
- package/dist/plugins/app-types/pubsub/example.d.ts +5 -0
- package/dist/plugins/app-types/pubsub/index.d.ts +63 -0
- package/dist/plugins/app-types/request/cache.d.ts +46 -0
- package/dist/plugins/app-types/request/cancelToken.d.ts +38 -0
- package/dist/plugins/app-types/request/config.d.ts +3 -0
- package/dist/plugins/app-types/request/constants.d.ts +2 -0
- package/dist/plugins/app-types/request/index.d.ts +24 -0
- package/dist/plugins/app-types/request/pisell2Request.d.ts +6 -0
- package/dist/plugins/app-types/request/type.d.ts +41 -0
- package/dist/plugins/app-types/request/utils.d.ts +46 -0
- package/dist/plugins/app-types/routes/config.d.ts +7 -0
- package/dist/plugins/app-types/routes/index.d.ts +28 -0
- package/dist/plugins/app-types/socket/components/SocketMonitorPage.d.ts +6 -0
- package/dist/plugins/app-types/socket/components/index.d.ts +2 -0
- package/dist/plugins/app-types/socket/constants.d.ts +33 -0
- package/dist/plugins/app-types/socket/events.d.ts +31 -0
- package/dist/plugins/app-types/socket/heartbeat.d.ts +66 -0
- package/dist/plugins/app-types/socket/index.d.ts +61 -0
- package/dist/plugins/app-types/socket/monitor.d.ts +169 -0
- package/dist/plugins/app-types/socket/reconnect.d.ts +61 -0
- package/dist/plugins/app-types/socket/socket.d.ts +129 -0
- package/dist/plugins/app-types/socket/types.d.ts +85 -0
- package/dist/plugins/app-types/storage/index.d.ts +17 -0
- package/dist/plugins/app-types/tasks/index.d.ts +77 -0
- package/dist/plugins/app-types/tasks/type.d.ts +62 -0
- package/dist/plugins/app-types/tasks/useTasks.d.ts +5 -0
- package/dist/plugins/app-types/type.d.ts +2 -0
- package/dist/plugins/app-types/variables/VariablesProvider.d.ts +7 -0
- package/dist/plugins/app-types/variables/config.d.ts +3 -0
- package/dist/plugins/app-types/variables/index.d.ts +6 -0
- package/dist/plugins/app-types/variables/type.d.ts +2 -0
- package/dist/plugins/app-types/website/index.d.ts +6 -0
- package/dist/plugins/app.d.ts +8 -0
- package/dist/plugins/app.js +1 -0
- package/dist/plugins/window.d.ts +1 -0
- package/dist/solution/BookingByStep/index.js +59 -35
- package/dist/solution/BookingByStep/types.d.ts +3 -2
- package/dist/solution/BookingTicket/index.d.ts +172 -0
- package/dist/solution/BookingTicket/index.js +665 -0
- package/dist/solution/BookingTicket/types.d.ts +68 -0
- package/dist/solution/BookingTicket/types.js +43 -0
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.d.ts +22 -0
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +159 -0
- package/dist/solution/BookingTicket/utils/scan/handleScan.d.ts +16 -0
- package/dist/solution/BookingTicket/utils/scan/handleScan.js +174 -0
- package/dist/solution/BookingTicket/utils/scan/index.d.ts +81 -0
- package/dist/solution/BookingTicket/utils/scan/index.js +285 -0
- package/dist/solution/BookingTicket/utils/scan/scanCache.d.ts +78 -0
- package/dist/solution/BookingTicket/utils/scan/scanCache.js +305 -0
- package/dist/solution/BuyTickets/index.d.ts +2 -2
- package/dist/solution/BuyTickets/index.js +1 -1
- package/dist/solution/Checkout/appointmentDemo.json +1 -0
- package/dist/solution/Checkout/index.d.ts +181 -0
- package/dist/solution/Checkout/index.js +1596 -0
- package/dist/solution/Checkout/types.d.ts +550 -0
- package/dist/solution/Checkout/types.js +132 -0
- package/dist/solution/Checkout/utils/index.d.ts +73 -0
- package/dist/solution/Checkout/utils/index.js +371 -0
- package/dist/solution/ShopDiscount/index.js +4 -2
- package/dist/solution/index.d.ts +2 -0
- package/dist/solution/index.js +3 -1
- package/dist/types/index.d.ts +3 -1
- package/dist/utils/task.d.ts +40 -0
- package/dist/utils/task.js +171 -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/Cart/index.js +1 -1
- package/lib/modules/Cart/utils/changePrice.d.ts +2 -2
- package/lib/modules/Cart/utils/changePrice.js +1 -1
- package/lib/modules/Customer/constants.d.ts +7 -0
- package/lib/modules/Customer/constants.js +39 -0
- package/lib/modules/Customer/index.d.ts +122 -0
- package/lib/modules/Customer/index.js +440 -0
- package/lib/modules/Customer/types.d.ts +146 -0
- package/lib/modules/Customer/types.js +37 -0
- package/lib/modules/Payment/cash.d.ts +11 -0
- package/lib/modules/Payment/cash.js +51 -0
- package/lib/modules/Payment/eftpos.d.ts +11 -0
- package/lib/modules/Payment/eftpos.js +51 -0
- package/lib/modules/Payment/index.d.ts +273 -9
- package/lib/modules/Payment/index.js +1285 -50
- package/lib/modules/Payment/types.d.ts +382 -30
- package/lib/modules/Payment/types.js +41 -6
- package/lib/modules/Payment/wallet.d.ts +11 -0
- package/lib/modules/Payment/wallet.js +51 -0
- package/lib/modules/Payment/walletpass.d.ts +0 -0
- package/lib/modules/Payment/walletpass.js +0 -0
- package/lib/modules/ProductList/index.d.ts +13 -3
- package/lib/modules/ProductList/index.js +37 -26
- package/lib/modules/ProductList/types.d.ts +0 -1
- package/lib/modules/Rules/index.js +20 -12
- 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/app-types/app/app.d.ts +83 -0
- package/lib/plugins/app-types/app/const.d.ts +4 -0
- package/lib/plugins/app-types/app/index.d.ts +14 -0
- package/lib/plugins/app-types/applicationManager/application.d.ts +50 -0
- package/lib/plugins/app-types/applicationManager/index.d.ts +13 -0
- package/lib/plugins/app-types/config.d.ts +3 -0
- package/lib/plugins/app-types/cookie/index.d.ts +13 -0
- package/lib/plugins/app-types/data/index.d.ts +8 -0
- package/lib/plugins/app-types/history/config.d.ts +24 -0
- package/lib/plugins/app-types/history/index.d.ts +20 -0
- package/lib/plugins/app-types/history/type.d.ts +2 -0
- package/lib/plugins/app-types/hooks/index.d.ts +12 -0
- package/lib/plugins/app-types/hooks/useDelayedValue/index.d.ts +2 -0
- package/lib/plugins/app-types/hooks/useDispatch/index.d.ts +2 -0
- package/lib/plugins/app-types/hooks/useLowCode/index.d.ts +13 -0
- package/lib/plugins/app-types/hooks/useStore/index.d.ts +6 -0
- package/lib/plugins/app-types/index.d.ts +6 -0
- package/lib/plugins/app-types/indexDB/index.d.ts +178 -0
- package/lib/plugins/app-types/locales/en.d.ts +3 -0
- package/lib/plugins/app-types/locales/index.d.ts +37 -0
- package/lib/plugins/app-types/locales/original.d.ts +3 -0
- package/lib/plugins/app-types/locales/type.d.ts +19 -0
- package/lib/plugins/app-types/locales/zh-CN.d.ts +3 -0
- package/lib/plugins/app-types/locales/zh-HK.d.ts +3 -0
- package/lib/plugins/app-types/logger/feishu.d.ts +11 -0
- package/lib/plugins/app-types/logger/index.d.ts +122 -0
- package/lib/plugins/app-types/menuManager/hooks.d.ts +17 -0
- package/lib/plugins/app-types/menuManager/index.d.ts +28 -0
- package/lib/plugins/app-types/models/global.d.ts +32 -0
- package/lib/plugins/app-types/models/index.d.ts +45 -0
- package/lib/plugins/app-types/models/type.d.ts +2 -0
- package/lib/plugins/app-types/package.json +15 -0
- package/lib/plugins/app-types/plugin/index.d.ts +0 -0
- package/lib/plugins/app-types/pubsub/example.d.ts +5 -0
- package/lib/plugins/app-types/pubsub/index.d.ts +63 -0
- package/lib/plugins/app-types/request/cache.d.ts +46 -0
- package/lib/plugins/app-types/request/cancelToken.d.ts +38 -0
- package/lib/plugins/app-types/request/config.d.ts +3 -0
- package/lib/plugins/app-types/request/constants.d.ts +2 -0
- package/lib/plugins/app-types/request/index.d.ts +24 -0
- package/lib/plugins/app-types/request/pisell2Request.d.ts +6 -0
- package/lib/plugins/app-types/request/type.d.ts +41 -0
- package/lib/plugins/app-types/request/utils.d.ts +46 -0
- package/lib/plugins/app-types/routes/config.d.ts +7 -0
- package/lib/plugins/app-types/routes/index.d.ts +28 -0
- package/lib/plugins/app-types/socket/components/SocketMonitorPage.d.ts +6 -0
- package/lib/plugins/app-types/socket/components/index.d.ts +2 -0
- package/lib/plugins/app-types/socket/constants.d.ts +33 -0
- package/lib/plugins/app-types/socket/events.d.ts +31 -0
- package/lib/plugins/app-types/socket/heartbeat.d.ts +66 -0
- package/lib/plugins/app-types/socket/index.d.ts +61 -0
- package/lib/plugins/app-types/socket/monitor.d.ts +169 -0
- package/lib/plugins/app-types/socket/reconnect.d.ts +61 -0
- package/lib/plugins/app-types/socket/socket.d.ts +129 -0
- package/lib/plugins/app-types/socket/types.d.ts +85 -0
- package/lib/plugins/app-types/storage/index.d.ts +17 -0
- package/lib/plugins/app-types/tasks/index.d.ts +77 -0
- package/lib/plugins/app-types/tasks/type.d.ts +62 -0
- package/lib/plugins/app-types/tasks/useTasks.d.ts +5 -0
- package/lib/plugins/app-types/type.d.ts +2 -0
- package/lib/plugins/app-types/variables/VariablesProvider.d.ts +7 -0
- package/lib/plugins/app-types/variables/config.d.ts +3 -0
- package/lib/plugins/app-types/variables/index.d.ts +6 -0
- package/lib/plugins/app-types/variables/type.d.ts +2 -0
- package/lib/plugins/app-types/website/index.d.ts +6 -0
- package/lib/plugins/app.d.ts +8 -0
- package/lib/plugins/app.js +17 -0
- package/lib/plugins/window.d.ts +1 -0
- package/lib/solution/BookingByStep/index.js +40 -29
- package/lib/solution/BookingByStep/types.d.ts +3 -2
- package/lib/solution/BookingTicket/index.d.ts +172 -0
- package/lib/solution/BookingTicket/index.js +399 -0
- package/lib/solution/BookingTicket/types.d.ts +68 -0
- package/lib/solution/BookingTicket/types.js +72 -0
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.d.ts +22 -0
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +117 -0
- package/lib/solution/BookingTicket/utils/scan/handleScan.d.ts +16 -0
- package/lib/solution/BookingTicket/utils/scan/handleScan.js +125 -0
- package/lib/solution/BookingTicket/utils/scan/index.d.ts +81 -0
- package/lib/solution/BookingTicket/utils/scan/index.js +210 -0
- package/lib/solution/BookingTicket/utils/scan/scanCache.d.ts +78 -0
- package/lib/solution/BookingTicket/utils/scan/scanCache.js +231 -0
- package/lib/solution/BuyTickets/index.d.ts +2 -2
- package/lib/solution/BuyTickets/index.js +1 -1
- package/lib/solution/Checkout/appointmentDemo.json +1 -0
- package/lib/solution/Checkout/index.d.ts +181 -0
- package/lib/solution/Checkout/index.js +864 -0
- package/lib/solution/Checkout/types.d.ts +550 -0
- package/lib/solution/Checkout/types.js +75 -0
- package/lib/solution/Checkout/utils/index.d.ts +73 -0
- package/lib/solution/Checkout/utils/index.js +266 -0
- package/lib/solution/ShopDiscount/index.js +2 -1
- package/lib/solution/index.d.ts +2 -0
- package/lib/solution/index.js +5 -1
- package/lib/types/index.d.ts +3 -1
- package/lib/utils/task.d.ts +40 -0
- package/lib/utils/task.js +109 -0
- package/lib/utils/watch.d.ts +102 -0
- package/lib/utils/watch.js +217 -0
- package/package.json +4 -2
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { ProductList, CartModule, AccountListModule, OrderModule } from '../../modules';
|
|
2
|
+
import { CustomerModule } from '../../modules/Customer';
|
|
3
|
+
export interface BookingTicketState {
|
|
4
|
+
cart: CartModule;
|
|
5
|
+
products: ProductList;
|
|
6
|
+
accountList: AccountListModule;
|
|
7
|
+
customer: CustomerModule;
|
|
8
|
+
order: OrderModule;
|
|
9
|
+
}
|
|
10
|
+
export declare function createModule<T extends keyof BookingTicketState>(moduleName: T, solutionName: string, name?: string, version?: string): BookingTicketState[T];
|
|
11
|
+
export declare enum BookingTicketHooks {
|
|
12
|
+
onInited = "bookingTicket:onInited",
|
|
13
|
+
onDestroy = "bookingTicket:onDestroy",
|
|
14
|
+
onProductsLoaded = "bookingTicket:onProductsLoaded",
|
|
15
|
+
onCustomerSelected = "bookingTicket:onCustomerSelected",
|
|
16
|
+
onCustomerListUpdate = "bookingTicket:onCustomerListUpdate",
|
|
17
|
+
onCustomerListReset = "bookingTicket:onCustomerListReset"
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* 获取客户列表的参数
|
|
21
|
+
*/
|
|
22
|
+
export interface IGetCustomerListParams {
|
|
23
|
+
/** 页码 */
|
|
24
|
+
skip?: number;
|
|
25
|
+
/** 每页数量 */
|
|
26
|
+
num?: number;
|
|
27
|
+
/** 搜索关键词 */
|
|
28
|
+
search?: string;
|
|
29
|
+
/** 其他筛选参数 */
|
|
30
|
+
[key: string]: any;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* 客户信息
|
|
34
|
+
*/
|
|
35
|
+
export interface ICustomer {
|
|
36
|
+
/** 客户ID */
|
|
37
|
+
id: string | number;
|
|
38
|
+
/** 客户姓名 */
|
|
39
|
+
name: string;
|
|
40
|
+
/** 客户电话 */
|
|
41
|
+
phone?: string;
|
|
42
|
+
/** 客户邮箱 */
|
|
43
|
+
email?: string;
|
|
44
|
+
/** 其他客户信息 */
|
|
45
|
+
[key: string]: any;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* 加载商品列表的参数
|
|
49
|
+
*/
|
|
50
|
+
export interface ILoadProductsParams {
|
|
51
|
+
/** 日期 格式:YYYY-MM-DD */
|
|
52
|
+
schedule_date?: string;
|
|
53
|
+
/** 客户ID */
|
|
54
|
+
customer_id?: number;
|
|
55
|
+
/** 餐牌列表ID */
|
|
56
|
+
menu_list_ids?: number[];
|
|
57
|
+
/** 时间 格式:YYYY-MM-DD HH:mm:ss*/
|
|
58
|
+
schedule_datetime?: string;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* 扫描结果
|
|
62
|
+
*/
|
|
63
|
+
export interface IScanResult {
|
|
64
|
+
status: 'success' | 'fail';
|
|
65
|
+
scanType: string;
|
|
66
|
+
scanCode: string;
|
|
67
|
+
result: any;
|
|
68
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ProductList, CartModule, AccountListModule, OrderModule } from "../../modules";
|
|
2
|
+
import { CustomerModule } from "../../modules/Customer";
|
|
3
|
+
export function createModule(moduleName, solutionName, name, version) {
|
|
4
|
+
switch (moduleName) {
|
|
5
|
+
case 'cart':
|
|
6
|
+
return new CartModule("".concat(solutionName, "_").concat(name || moduleName), version);
|
|
7
|
+
case 'products':
|
|
8
|
+
return new ProductList("".concat(solutionName, "_").concat(name || moduleName), version);
|
|
9
|
+
case 'accountList':
|
|
10
|
+
return new AccountListModule("".concat(solutionName, "_").concat(name || moduleName), version);
|
|
11
|
+
case 'customer':
|
|
12
|
+
return new CustomerModule("".concat(solutionName, "_").concat(name || moduleName), version);
|
|
13
|
+
case 'order':
|
|
14
|
+
return new OrderModule("".concat(solutionName, "_").concat(name || moduleName), version);
|
|
15
|
+
default:
|
|
16
|
+
throw new Error("Unknown module type: ".concat(moduleName));
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export var BookingTicketHooks = /*#__PURE__*/function (BookingTicketHooks) {
|
|
20
|
+
BookingTicketHooks["onInited"] = "bookingTicket:onInited";
|
|
21
|
+
BookingTicketHooks["onDestroy"] = "bookingTicket:onDestroy";
|
|
22
|
+
BookingTicketHooks["onProductsLoaded"] = "bookingTicket:onProductsLoaded";
|
|
23
|
+
BookingTicketHooks["onCustomerSelected"] = "bookingTicket:onCustomerSelected";
|
|
24
|
+
BookingTicketHooks["onCustomerListUpdate"] = "bookingTicket:onCustomerListUpdate";
|
|
25
|
+
BookingTicketHooks["onCustomerListReset"] = "bookingTicket:onCustomerListReset";
|
|
26
|
+
return BookingTicketHooks;
|
|
27
|
+
}({});
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* 获取客户列表的参数
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* 客户信息
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* 加载商品列表的参数
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* 扫描结果
|
|
43
|
+
*/
|
|
@@ -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,159 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
3
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
4
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
5
|
+
/**
|
|
6
|
+
* 搜索通用识别码
|
|
7
|
+
*/
|
|
8
|
+
export var searchWalletPass = /*#__PURE__*/function () {
|
|
9
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(request, code) {
|
|
10
|
+
var params, res;
|
|
11
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
12
|
+
while (1) switch (_context.prev = _context.next) {
|
|
13
|
+
case 0:
|
|
14
|
+
params = {
|
|
15
|
+
code: code,
|
|
16
|
+
translate_flag: 1,
|
|
17
|
+
// 翻译识别码名称 0:不翻译 1:翻译
|
|
18
|
+
relation_product: 1,
|
|
19
|
+
// 组装关联商品: 0不处理 1处理
|
|
20
|
+
with: ['customer'],
|
|
21
|
+
tags: ['point_card',
|
|
22
|
+
// 积分卡
|
|
23
|
+
'gift_card',
|
|
24
|
+
// 充值卡
|
|
25
|
+
'product_voucher',
|
|
26
|
+
// 代金券
|
|
27
|
+
'product_discount_card',
|
|
28
|
+
// 折扣卡
|
|
29
|
+
'good_pass',
|
|
30
|
+
// 商品券
|
|
31
|
+
'session_ticket',
|
|
32
|
+
// 场次票
|
|
33
|
+
'appointment_ticket' // 预约类门票
|
|
34
|
+
]
|
|
35
|
+
};
|
|
36
|
+
_context.prev = 1;
|
|
37
|
+
_context.next = 4;
|
|
38
|
+
return request === null || request === void 0 ? void 0 : request.get('/machinecode/batch-search', params);
|
|
39
|
+
case 4:
|
|
40
|
+
res = _context.sent;
|
|
41
|
+
if (!((res === null || res === void 0 ? void 0 : res.code) == 200 && !!(res !== null && res !== void 0 && res.data))) {
|
|
42
|
+
_context.next = 7;
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
return _context.abrupt("return", {
|
|
46
|
+
searchType: 'walletPass',
|
|
47
|
+
response: res
|
|
48
|
+
});
|
|
49
|
+
case 7:
|
|
50
|
+
throw new Error('没有找到对应的识别码');
|
|
51
|
+
case 10:
|
|
52
|
+
_context.prev = 10;
|
|
53
|
+
_context.t0 = _context["catch"](1);
|
|
54
|
+
throw _context.t0;
|
|
55
|
+
case 13:
|
|
56
|
+
case "end":
|
|
57
|
+
return _context.stop();
|
|
58
|
+
}
|
|
59
|
+
}, _callee, null, [[1, 10]]);
|
|
60
|
+
}));
|
|
61
|
+
return function searchWalletPass(_x, _x2) {
|
|
62
|
+
return _ref.apply(this, arguments);
|
|
63
|
+
};
|
|
64
|
+
}();
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* 搜索钱包
|
|
68
|
+
*/
|
|
69
|
+
export var searchWallet = /*#__PURE__*/function () {
|
|
70
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(request, code) {
|
|
71
|
+
var params, res;
|
|
72
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
73
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
74
|
+
case 0:
|
|
75
|
+
params = {
|
|
76
|
+
code: code,
|
|
77
|
+
with_customer: 1
|
|
78
|
+
};
|
|
79
|
+
_context2.prev = 1;
|
|
80
|
+
_context2.next = 4;
|
|
81
|
+
return request === null || request === void 0 ? void 0 : request.post('/wallet/detail/search', params);
|
|
82
|
+
case 4:
|
|
83
|
+
res = _context2.sent;
|
|
84
|
+
if (!((res === null || res === void 0 ? void 0 : res.code) == 200 && !!(res !== null && res !== void 0 && res.data))) {
|
|
85
|
+
_context2.next = 7;
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
return _context2.abrupt("return", {
|
|
89
|
+
searchType: 'wallet',
|
|
90
|
+
response: res
|
|
91
|
+
});
|
|
92
|
+
case 7:
|
|
93
|
+
throw new Error('没有找到对应的识别码');
|
|
94
|
+
case 10:
|
|
95
|
+
_context2.prev = 10;
|
|
96
|
+
_context2.t0 = _context2["catch"](1);
|
|
97
|
+
throw _context2.t0;
|
|
98
|
+
case 13:
|
|
99
|
+
case "end":
|
|
100
|
+
return _context2.stop();
|
|
101
|
+
}
|
|
102
|
+
}, _callee2, null, [[1, 10]]);
|
|
103
|
+
}));
|
|
104
|
+
return function searchWallet(_x3, _x4) {
|
|
105
|
+
return _ref2.apply(this, arguments);
|
|
106
|
+
};
|
|
107
|
+
}();
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* 搜索商品
|
|
111
|
+
*/
|
|
112
|
+
export var searchProduct = /*#__PURE__*/function () {
|
|
113
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(request, code) {
|
|
114
|
+
var params, _res$data, res;
|
|
115
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
116
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
117
|
+
case 0:
|
|
118
|
+
params = {
|
|
119
|
+
exact_search: code,
|
|
120
|
+
open_bundle: 0,
|
|
121
|
+
// 套餐子信息
|
|
122
|
+
open_quotation: 1,
|
|
123
|
+
// 报价单
|
|
124
|
+
skip: 1,
|
|
125
|
+
num: 20,
|
|
126
|
+
status: 'published',
|
|
127
|
+
with: ['variantGroup'],
|
|
128
|
+
with_count: ['bundleGroup', 'optionGroup'],
|
|
129
|
+
exclude_extension_type: ['product_party', 'product_event', 'product_series_event', 'product_package_ticket', 'ticket', 'event_item']
|
|
130
|
+
};
|
|
131
|
+
_context3.prev = 1;
|
|
132
|
+
_context3.next = 4;
|
|
133
|
+
return request === null || request === void 0 ? void 0 : request.post('/product/query', params);
|
|
134
|
+
case 4:
|
|
135
|
+
res = _context3.sent;
|
|
136
|
+
if (!((res === null || res === void 0 ? void 0 : res.code) == 200 && (res === null || res === void 0 || (_res$data = res.data) === null || _res$data === void 0 || (_res$data = _res$data.list) === null || _res$data === void 0 ? void 0 : _res$data.length) > 0)) {
|
|
137
|
+
_context3.next = 7;
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
return _context3.abrupt("return", {
|
|
141
|
+
searchType: 'product',
|
|
142
|
+
response: res
|
|
143
|
+
});
|
|
144
|
+
case 7:
|
|
145
|
+
throw new Error('没有找到对应的识别码');
|
|
146
|
+
case 10:
|
|
147
|
+
_context3.prev = 10;
|
|
148
|
+
_context3.t0 = _context3["catch"](1);
|
|
149
|
+
throw _context3.t0;
|
|
150
|
+
case 13:
|
|
151
|
+
case "end":
|
|
152
|
+
return _context3.stop();
|
|
153
|
+
}
|
|
154
|
+
}, _callee3, null, [[1, 10]]);
|
|
155
|
+
}));
|
|
156
|
+
return function searchProduct(_x5, _x6) {
|
|
157
|
+
return _ref3.apply(this, arguments);
|
|
158
|
+
};
|
|
159
|
+
}();
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { RequestPlugin } from '../../../../plugins';
|
|
2
|
+
/**
|
|
3
|
+
* 处理全局扫码
|
|
4
|
+
* @param request 请求插件
|
|
5
|
+
* @returns 处理结果
|
|
6
|
+
*/
|
|
7
|
+
export declare const handleGlobalScan: (request: RequestPlugin, localSearch: (v: string) => any[]) => (scanResult: {
|
|
8
|
+
type: string;
|
|
9
|
+
value: string;
|
|
10
|
+
}) => Promise<any>;
|
|
11
|
+
/**
|
|
12
|
+
* 处理客户扫码
|
|
13
|
+
* @param request 请求插件
|
|
14
|
+
* @returns 处理结果
|
|
15
|
+
*/
|
|
16
|
+
export declare const handleCustomerScan: () => () => Promise<{}>;
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
3
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
4
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
5
|
+
import { searchWalletPass, searchWallet, searchProduct } from "./cloudSearch";
|
|
6
|
+
import scanCache from "./scanCache";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Promise.any 的替代实现
|
|
10
|
+
* 返回第一个成功解析的 Promise,如果所有 Promise 都失败则抛出错误
|
|
11
|
+
* @param promises Promise 数组
|
|
12
|
+
* @returns 第一个成功的结果
|
|
13
|
+
*/
|
|
14
|
+
var promiseAny = /*#__PURE__*/function () {
|
|
15
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(promises) {
|
|
16
|
+
var errors, completedCount;
|
|
17
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
18
|
+
while (1) switch (_context.prev = _context.next) {
|
|
19
|
+
case 0:
|
|
20
|
+
if (!(promises.length === 0)) {
|
|
21
|
+
_context.next = 2;
|
|
22
|
+
break;
|
|
23
|
+
}
|
|
24
|
+
throw new Error('No promises provided');
|
|
25
|
+
case 2:
|
|
26
|
+
errors = [];
|
|
27
|
+
completedCount = 0;
|
|
28
|
+
return _context.abrupt("return", new Promise(function (resolve, reject) {
|
|
29
|
+
promises.forEach(function (promise, index) {
|
|
30
|
+
promise.then(function (result) {
|
|
31
|
+
resolve(result);
|
|
32
|
+
}).catch(function (error) {
|
|
33
|
+
errors[index] = error;
|
|
34
|
+
completedCount++;
|
|
35
|
+
|
|
36
|
+
// 如果所有 Promise 都失败了,抛出包含所有错误的错误
|
|
37
|
+
if (completedCount === promises.length) {
|
|
38
|
+
var errorMessage = "All promises were rejected. Errors: ".concat(errors.map(function (e) {
|
|
39
|
+
return e.message;
|
|
40
|
+
}).join(', '));
|
|
41
|
+
var combinedError = new Error(errorMessage);
|
|
42
|
+
combinedError.errors = errors;
|
|
43
|
+
reject(combinedError);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
}));
|
|
48
|
+
case 5:
|
|
49
|
+
case "end":
|
|
50
|
+
return _context.stop();
|
|
51
|
+
}
|
|
52
|
+
}, _callee);
|
|
53
|
+
}));
|
|
54
|
+
return function promiseAny(_x) {
|
|
55
|
+
return _ref.apply(this, arguments);
|
|
56
|
+
};
|
|
57
|
+
}();
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* 处理扫码
|
|
61
|
+
* @param getRequestList 获取请求列表
|
|
62
|
+
* @returns 处理结果
|
|
63
|
+
*/
|
|
64
|
+
var handleScanFn = function handleScanFn(getRequestList, localSearch) {
|
|
65
|
+
return /*#__PURE__*/function () {
|
|
66
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(scanResult) {
|
|
67
|
+
var _ref3, value, localResult, result, requestList, _result;
|
|
68
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
69
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
70
|
+
case 0:
|
|
71
|
+
_ref3 = scanResult || {}, value = _ref3.value; // 本地解析识别码
|
|
72
|
+
_context2.prev = 1;
|
|
73
|
+
localResult = localSearch === null || localSearch === void 0 ? void 0 : localSearch(value);
|
|
74
|
+
if (!((localResult === null || localResult === void 0 ? void 0 : localResult.length) > 0)) {
|
|
75
|
+
_context2.next = 8;
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
console.log('本地搜索到数据>>>>>>>', localResult);
|
|
79
|
+
return _context2.abrupt("return", {
|
|
80
|
+
searchType: 'local_product',
|
|
81
|
+
response: {
|
|
82
|
+
data: {
|
|
83
|
+
list: localResult
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
case 8:
|
|
88
|
+
console.log('本地搜索无数据>>>>>>>');
|
|
89
|
+
case 9:
|
|
90
|
+
_context2.next = 14;
|
|
91
|
+
break;
|
|
92
|
+
case 11:
|
|
93
|
+
_context2.prev = 11;
|
|
94
|
+
_context2.t0 = _context2["catch"](1);
|
|
95
|
+
console.error('本地搜索到数据失败>>>>>>>', _context2.t0);
|
|
96
|
+
case 14:
|
|
97
|
+
_context2.prev = 14;
|
|
98
|
+
if (!scanCache.has(value)) {
|
|
99
|
+
_context2.next = 21;
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
result = scanCache.get(value);
|
|
103
|
+
console.log('缓存中搜索到数据>>>>>>>', result);
|
|
104
|
+
return _context2.abrupt("return", result);
|
|
105
|
+
case 21:
|
|
106
|
+
console.log('缓存中无数据>>>>>>>');
|
|
107
|
+
case 22:
|
|
108
|
+
_context2.next = 27;
|
|
109
|
+
break;
|
|
110
|
+
case 24:
|
|
111
|
+
_context2.prev = 24;
|
|
112
|
+
_context2.t1 = _context2["catch"](14);
|
|
113
|
+
console.error('缓存中搜索数据失败>>>>>>>', _context2.t1);
|
|
114
|
+
case 27:
|
|
115
|
+
requestList = (getRequestList === null || getRequestList === void 0 ? void 0 : getRequestList(value)) || [];
|
|
116
|
+
if (!(requestList.length === 0)) {
|
|
117
|
+
_context2.next = 30;
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
throw new Error('requestList is empty');
|
|
121
|
+
case 30:
|
|
122
|
+
_context2.prev = 30;
|
|
123
|
+
_context2.next = 33;
|
|
124
|
+
return promiseAny(requestList);
|
|
125
|
+
case 33:
|
|
126
|
+
_result = _context2.sent;
|
|
127
|
+
// 将结果缓存
|
|
128
|
+
scanCache.set(value, _result);
|
|
129
|
+
return _context2.abrupt("return", _result);
|
|
130
|
+
case 38:
|
|
131
|
+
_context2.prev = 38;
|
|
132
|
+
_context2.t2 = _context2["catch"](30);
|
|
133
|
+
throw _context2.t2;
|
|
134
|
+
case 41:
|
|
135
|
+
case "end":
|
|
136
|
+
return _context2.stop();
|
|
137
|
+
}
|
|
138
|
+
}, _callee2, null, [[1, 11], [14, 24], [30, 38]]);
|
|
139
|
+
}));
|
|
140
|
+
return function (_x2) {
|
|
141
|
+
return _ref2.apply(this, arguments);
|
|
142
|
+
};
|
|
143
|
+
}();
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* 处理全局扫码
|
|
148
|
+
* @param request 请求插件
|
|
149
|
+
* @returns 处理结果
|
|
150
|
+
*/
|
|
151
|
+
export var handleGlobalScan = function handleGlobalScan(request, localSearch) {
|
|
152
|
+
var getRequestList = function getRequestList(value) {
|
|
153
|
+
var requestList = [];
|
|
154
|
+
// 如果value是已WL开头的,则认为是钱包识别码
|
|
155
|
+
if (value.startsWith('WL')) {
|
|
156
|
+
requestList = [searchWallet(request, value)];
|
|
157
|
+
} else {
|
|
158
|
+
requestList = [searchWalletPass(request, value), searchWallet(request, value), searchProduct(request, value)];
|
|
159
|
+
}
|
|
160
|
+
return requestList;
|
|
161
|
+
};
|
|
162
|
+
return handleScanFn(getRequestList, localSearch);
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* 处理客户扫码
|
|
167
|
+
* @param request 请求插件
|
|
168
|
+
* @returns 处理结果
|
|
169
|
+
*/
|
|
170
|
+
export var handleCustomerScan = function handleCustomerScan() {
|
|
171
|
+
return function () {
|
|
172
|
+
return Promise.resolve({});
|
|
173
|
+
};
|
|
174
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { WatchEventItem } from '../../../../utils/watch';
|
|
2
|
+
import { BookingTicketImpl } from '../../index';
|
|
3
|
+
import Tasks from '../../../../utils/task';
|
|
4
|
+
interface ScanResult {
|
|
5
|
+
type: ScanResultType;
|
|
6
|
+
value: string;
|
|
7
|
+
data?: {
|
|
8
|
+
[key: string]: any;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
declare enum ScanResultType {
|
|
12
|
+
Scanner = "scanner",
|
|
13
|
+
NFC = "nfc",
|
|
14
|
+
NativeScanner = "nativeScanner"
|
|
15
|
+
}
|
|
16
|
+
export default class Scan {
|
|
17
|
+
private solution;
|
|
18
|
+
private watchKey;
|
|
19
|
+
private listenerConfig;
|
|
20
|
+
constructor(solution: BookingTicketImpl, watchKey: string);
|
|
21
|
+
/**
|
|
22
|
+
* 处理扫码事件
|
|
23
|
+
* @param eventKey 事件key
|
|
24
|
+
* @param value 扫码结果
|
|
25
|
+
*/
|
|
26
|
+
handleScan(result: {
|
|
27
|
+
type: string;
|
|
28
|
+
value: string;
|
|
29
|
+
}): void;
|
|
30
|
+
/**
|
|
31
|
+
* 生成uuid
|
|
32
|
+
* @returns uuid
|
|
33
|
+
*/
|
|
34
|
+
generateUuid(): string;
|
|
35
|
+
/**
|
|
36
|
+
* 添加扫码信息监听
|
|
37
|
+
* @param watchKey 监听的key
|
|
38
|
+
* @param event 事件
|
|
39
|
+
*/
|
|
40
|
+
addListener(event: WatchEventItem, scanCallback?: (result: ScanResult) => Promise<any>): {
|
|
41
|
+
remove: () => void;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* 移除扫码信息监听
|
|
45
|
+
* @param watchKey 监听的key
|
|
46
|
+
* @param event 事件
|
|
47
|
+
*/
|
|
48
|
+
removeListener(event: WatchEventItem): void;
|
|
49
|
+
/**
|
|
50
|
+
* 移除所有监听
|
|
51
|
+
*/
|
|
52
|
+
removeAllListeners(): void;
|
|
53
|
+
/**
|
|
54
|
+
* 启用所有监听
|
|
55
|
+
*/
|
|
56
|
+
enableAllListeners(): void;
|
|
57
|
+
/**
|
|
58
|
+
* 禁用所有监听,并清空任务执行队列
|
|
59
|
+
*/
|
|
60
|
+
disableAllListeners(): void;
|
|
61
|
+
/**
|
|
62
|
+
* 清空监听对应的任务执行队列,不传入eventKey则清空所有监听对应的任务执行队列
|
|
63
|
+
* @param eventKey 事件key
|
|
64
|
+
*/
|
|
65
|
+
clearTaskQueue(eventKey?: string): void;
|
|
66
|
+
/**
|
|
67
|
+
* 获取监听配置
|
|
68
|
+
* @param eventKey 事件key
|
|
69
|
+
* @returns 监听配置
|
|
70
|
+
*/
|
|
71
|
+
getListenerConfig(eventKey: string): {
|
|
72
|
+
scanCallback?: ((result: ScanResult) => Promise<any>) | undefined;
|
|
73
|
+
task: Tasks;
|
|
74
|
+
} | undefined;
|
|
75
|
+
/**
|
|
76
|
+
* 扫码任务执行函数
|
|
77
|
+
* @param args 参数
|
|
78
|
+
*/
|
|
79
|
+
scanTaskAction(...args: any[]): Promise<void>;
|
|
80
|
+
}
|
|
81
|
+
export {};
|