@pisell/pisellos 2.0.65 → 2.0.67
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/modules/Rules/index.js +20 -9
- package/dist/solution/BookingTicket/index.d.ts +13 -1
- package/dist/solution/BookingTicket/index.js +29 -0
- package/dist/solution/BookingTicket/utils/scan/index.d.ts +30 -8
- package/dist/solution/BookingTicket/utils/scan/index.js +139 -55
- package/dist/utils/task.d.ts +10 -1
- package/dist/utils/task.js +61 -40
- package/dist/utils/watch.d.ts +1 -1
- package/dist/utils/watch.js +1 -1
- package/lib/modules/Rules/index.js +16 -9
- package/lib/solution/BookingTicket/index.d.ts +13 -1
- package/lib/solution/BookingTicket/index.js +19 -0
- package/lib/solution/BookingTicket/utils/scan/index.d.ts +30 -8
- package/lib/solution/BookingTicket/utils/scan/index.js +97 -36
- package/lib/utils/task.d.ts +10 -1
- package/lib/utils/task.js +28 -3
- package/lib/utils/watch.d.ts +1 -1
- package/lib/utils/watch.js +1 -1
- package/package.json +1 -1
|
@@ -297,19 +297,25 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
297
297
|
|
|
298
298
|
// 记录可抵扣的商品详情
|
|
299
299
|
var applicableProducts = discountApplicableProducts.get(discount.id) || [];
|
|
300
|
-
|
|
300
|
+
var discountType = discount.tag || discount.type;
|
|
301
|
+
var productData = {
|
|
301
302
|
amount: product.price,
|
|
302
|
-
type:
|
|
303
|
-
tag:
|
|
303
|
+
type: discountType,
|
|
304
|
+
tag: discountType,
|
|
304
305
|
discount: {
|
|
305
306
|
resource_id: discount.id,
|
|
306
307
|
title: discount.format_title,
|
|
307
308
|
original_amount: product.origin_total,
|
|
308
309
|
pre_value: discount.par_value,
|
|
309
310
|
product_id: originProduct.id
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
|
|
311
|
+
}
|
|
312
|
+
};
|
|
313
|
+
|
|
314
|
+
// 如果 discount.tag 或者 discount.type 是 good_pass,则不需要添加 num 属性
|
|
315
|
+
if (discountType !== 'good_pass') {
|
|
316
|
+
productData.num = product.num || 1;
|
|
317
|
+
}
|
|
318
|
+
applicableProducts.push(productData);
|
|
313
319
|
discountApplicableProducts.set(discount.id, applicableProducts);
|
|
314
320
|
}
|
|
315
321
|
});
|
|
@@ -451,18 +457,23 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
451
457
|
|
|
452
458
|
// 计算使用折扣卡/商品券以后,单个商品的总 total
|
|
453
459
|
var targetProductTotal = _selectedDiscount.tag === 'good_pass' ? new Decimal(productOriginTotal).minus(new Decimal(product.price || 0)).toNumber() : new Decimal(100).minus(_selectedDiscount.par_value || 0).div(100).mul(new Decimal(productOriginTotal)).toNumber();
|
|
460
|
+
var discountType = _selectedDiscount.tag === 'product_discount_card' ? 'discount_card' : _selectedDiscount.tag;
|
|
454
461
|
var discountDetail = {
|
|
455
462
|
amount: new Decimal(productOriginTotal).minus(new Decimal(targetProductTotal)).toNumber(),
|
|
456
|
-
type:
|
|
463
|
+
type: discountType,
|
|
457
464
|
discount: {
|
|
458
465
|
resource_id: _selectedDiscount.id,
|
|
459
466
|
title: _selectedDiscount.format_title,
|
|
460
467
|
original_amount: productOriginTotal,
|
|
461
468
|
product_id: originProduct.id,
|
|
462
469
|
percent: _selectedDiscount.par_value
|
|
463
|
-
}
|
|
464
|
-
num: product.num || 1
|
|
470
|
+
}
|
|
465
471
|
};
|
|
472
|
+
|
|
473
|
+
// 如果 discount.tag 或者 discount.type 是 good_pass,则不需要添加 num 属性
|
|
474
|
+
if ((_selectedDiscount.tag || _selectedDiscount.type) !== 'good_pass') {
|
|
475
|
+
discountDetail.num = product.num || 1;
|
|
476
|
+
}
|
|
466
477
|
appliedProducts.push(discountDetail);
|
|
467
478
|
appliedDiscountProducts.set(_selectedDiscount.id, appliedProducts);
|
|
468
479
|
|
|
@@ -111,7 +111,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
|
|
|
111
111
|
* 获取当前的客户搜索条件
|
|
112
112
|
* @returns 当前搜索条件
|
|
113
113
|
*/
|
|
114
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
114
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
|
|
115
115
|
/**
|
|
116
116
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
117
117
|
* @returns 客户状态
|
|
@@ -138,6 +138,18 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
|
|
|
138
138
|
activateCamera(data?: {
|
|
139
139
|
[key: string]: any;
|
|
140
140
|
}): void;
|
|
141
|
+
/**
|
|
142
|
+
* 禁用所有扫描监听
|
|
143
|
+
*/
|
|
144
|
+
disableAllScanListeners(): void;
|
|
145
|
+
/**
|
|
146
|
+
* 启用所有扫描监听
|
|
147
|
+
*/
|
|
148
|
+
enableAllScanListeners(): void;
|
|
149
|
+
/**
|
|
150
|
+
* 清空所有扫描监听对应的任务执行队列
|
|
151
|
+
*/
|
|
152
|
+
clearAllScanListenersTaskQueue(): void;
|
|
141
153
|
/**
|
|
142
154
|
* 设置其他参数
|
|
143
155
|
* @param params 参数
|
|
@@ -552,6 +552,33 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
552
552
|
});
|
|
553
553
|
}
|
|
554
554
|
|
|
555
|
+
/**
|
|
556
|
+
* 禁用所有扫描监听
|
|
557
|
+
*/
|
|
558
|
+
}, {
|
|
559
|
+
key: "disableAllScanListeners",
|
|
560
|
+
value: function disableAllScanListeners() {
|
|
561
|
+
this.scan.disableAllListeners();
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
/**
|
|
565
|
+
* 启用所有扫描监听
|
|
566
|
+
*/
|
|
567
|
+
}, {
|
|
568
|
+
key: "enableAllScanListeners",
|
|
569
|
+
value: function enableAllScanListeners() {
|
|
570
|
+
this.scan.enableAllListeners();
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
/**
|
|
574
|
+
* 清空所有扫描监听对应的任务执行队列
|
|
575
|
+
*/
|
|
576
|
+
}, {
|
|
577
|
+
key: "clearAllScanListenersTaskQueue",
|
|
578
|
+
value: function clearAllScanListenersTaskQueue() {
|
|
579
|
+
this.scan.clearTaskQueue();
|
|
580
|
+
}
|
|
581
|
+
|
|
555
582
|
/**
|
|
556
583
|
* 设置其他参数
|
|
557
584
|
* @param params 参数
|
|
@@ -624,6 +651,8 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
624
651
|
(_this$store$order = this.store.order) === null || _this$store$order === void 0 || _this$store$order.destroy();
|
|
625
652
|
this.core.effects.offByModuleDestroy(this.name);
|
|
626
653
|
this.core.unregisterModule(this);
|
|
654
|
+
// 清除所有的监听
|
|
655
|
+
this.scan.removeAllListeners();
|
|
627
656
|
// 清除scan数据内存缓存
|
|
628
657
|
scanCache.clear();
|
|
629
658
|
}
|
|
@@ -18,6 +18,20 @@ export default class Scan {
|
|
|
18
18
|
private watchKey;
|
|
19
19
|
private listenerConfig;
|
|
20
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;
|
|
21
35
|
/**
|
|
22
36
|
* 添加扫码信息监听
|
|
23
37
|
* @param watchKey 监听的key
|
|
@@ -33,14 +47,22 @@ export default class Scan {
|
|
|
33
47
|
*/
|
|
34
48
|
removeListener(event: WatchEventItem): void;
|
|
35
49
|
/**
|
|
36
|
-
*
|
|
50
|
+
* 移除所有监听
|
|
51
|
+
*/
|
|
52
|
+
removeAllListeners(): void;
|
|
53
|
+
/**
|
|
54
|
+
* 启用所有监听
|
|
55
|
+
*/
|
|
56
|
+
enableAllListeners(): void;
|
|
57
|
+
/**
|
|
58
|
+
* 禁用所有监听,并清空任务执行队列
|
|
59
|
+
*/
|
|
60
|
+
disableAllListeners(): void;
|
|
61
|
+
/**
|
|
62
|
+
* 清空监听对应的任务执行队列,不传入eventKey则清空所有监听对应的任务执行队列
|
|
37
63
|
* @param eventKey 事件key
|
|
38
|
-
* @param value 扫码结果
|
|
39
64
|
*/
|
|
40
|
-
|
|
41
|
-
type: string;
|
|
42
|
-
value: string;
|
|
43
|
-
}): void;
|
|
65
|
+
clearTaskQueue(eventKey?: string): void;
|
|
44
66
|
/**
|
|
45
67
|
* 获取监听配置
|
|
46
68
|
* @param eventKey 事件key
|
|
@@ -51,9 +73,9 @@ export default class Scan {
|
|
|
51
73
|
task: Tasks;
|
|
52
74
|
} | undefined;
|
|
53
75
|
/**
|
|
54
|
-
*
|
|
76
|
+
* 扫码任务执行函数
|
|
55
77
|
* @param args 参数
|
|
56
78
|
*/
|
|
57
|
-
|
|
79
|
+
scanTaskAction(...args: any[]): Promise<void>;
|
|
58
80
|
}
|
|
59
81
|
export {};
|
|
@@ -41,11 +41,45 @@ var Scan = /*#__PURE__*/function () {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
|
-
*
|
|
45
|
-
* @param
|
|
46
|
-
* @param
|
|
44
|
+
* 处理扫码事件
|
|
45
|
+
* @param eventKey 事件key
|
|
46
|
+
* @param value 扫码结果
|
|
47
47
|
*/
|
|
48
48
|
_createClass(Scan, [{
|
|
49
|
+
key: "handleScan",
|
|
50
|
+
value: function handleScan(result) {
|
|
51
|
+
var lastEnableEventKey = watch.getLastEnableEventKey(this.watchKey);
|
|
52
|
+
if (lastEnableEventKey) {
|
|
53
|
+
var listenerConfig = this.listenerConfig.get(lastEnableEventKey);
|
|
54
|
+
if (listenerConfig) {
|
|
55
|
+
listenerConfig.task.addTask({
|
|
56
|
+
uuid: this.generateUuid(),
|
|
57
|
+
type: lastEnableEventKey,
|
|
58
|
+
actionParams: {
|
|
59
|
+
scanResult: result
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* 生成uuid
|
|
68
|
+
* @returns uuid
|
|
69
|
+
*/
|
|
70
|
+
}, {
|
|
71
|
+
key: "generateUuid",
|
|
72
|
+
value: function generateUuid() {
|
|
73
|
+
// 需要加入时间戳,避免重复
|
|
74
|
+
return Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15) + Date.now().toString(36);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* 添加扫码信息监听
|
|
79
|
+
* @param watchKey 监听的key
|
|
80
|
+
* @param event 事件
|
|
81
|
+
*/
|
|
82
|
+
}, {
|
|
49
83
|
key: "addListener",
|
|
50
84
|
value: function addListener(event, scanCallback) {
|
|
51
85
|
var _this2 = this;
|
|
@@ -57,7 +91,7 @@ var Scan = /*#__PURE__*/function () {
|
|
|
57
91
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
58
92
|
args[_key] = arguments[_key];
|
|
59
93
|
}
|
|
60
|
-
return _this2.
|
|
94
|
+
return _this2.scanTaskAction.apply(_this2, [event.key].concat(args));
|
|
61
95
|
});
|
|
62
96
|
|
|
63
97
|
// 创建监听配置
|
|
@@ -82,29 +116,66 @@ var Scan = /*#__PURE__*/function () {
|
|
|
82
116
|
value: function removeListener(event) {
|
|
83
117
|
var _this$listenerConfig$;
|
|
84
118
|
watch.unsubscribe(this.watchKey, event);
|
|
85
|
-
(_this$listenerConfig$ = this.listenerConfig.get(event.key)) === null || _this$listenerConfig$ === void 0 || _this$listenerConfig$.task
|
|
119
|
+
(_this$listenerConfig$ = this.listenerConfig.get(event.key)) === null || _this$listenerConfig$ === void 0 || (_this$listenerConfig$ = _this$listenerConfig$.task) === null || _this$listenerConfig$ === void 0 || _this$listenerConfig$.clear();
|
|
86
120
|
this.listenerConfig.delete(event.key);
|
|
87
121
|
}
|
|
88
122
|
|
|
89
123
|
/**
|
|
90
|
-
*
|
|
124
|
+
* 移除所有监听
|
|
125
|
+
*/
|
|
126
|
+
}, {
|
|
127
|
+
key: "removeAllListeners",
|
|
128
|
+
value: function removeAllListeners() {
|
|
129
|
+
var _this$listenerConfig, _this$listenerConfig$2, _this$listenerConfig2, _this$listenerConfig3;
|
|
130
|
+
watch.clearEvent(this.watchKey);
|
|
131
|
+
(_this$listenerConfig = this.listenerConfig) === null || _this$listenerConfig === void 0 || (_this$listenerConfig$2 = _this$listenerConfig.forEach) === null || _this$listenerConfig$2 === void 0 || _this$listenerConfig$2.call(_this$listenerConfig, function (item) {
|
|
132
|
+
var _item$task;
|
|
133
|
+
item === null || item === void 0 || (_item$task = item.task) === null || _item$task === void 0 || _item$task.clear();
|
|
134
|
+
});
|
|
135
|
+
(_this$listenerConfig2 = this.listenerConfig) === null || _this$listenerConfig2 === void 0 || (_this$listenerConfig3 = _this$listenerConfig2.clear) === null || _this$listenerConfig3 === void 0 || _this$listenerConfig3.call(_this$listenerConfig2);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* 启用所有监听
|
|
140
|
+
*/
|
|
141
|
+
}, {
|
|
142
|
+
key: "enableAllListeners",
|
|
143
|
+
value: function enableAllListeners() {
|
|
144
|
+
watch.enableAllEventByWatchKey(this.watchKey);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* 禁用所有监听,并清空任务执行队列
|
|
149
|
+
*/
|
|
150
|
+
}, {
|
|
151
|
+
key: "disableAllListeners",
|
|
152
|
+
value: function disableAllListeners() {
|
|
153
|
+
var _this$listenerConfig4, _this$listenerConfig5;
|
|
154
|
+
watch.disabledAllEventByWatchKey(this.watchKey);
|
|
155
|
+
// 清空任务
|
|
156
|
+
(_this$listenerConfig4 = this.listenerConfig) === null || _this$listenerConfig4 === void 0 || (_this$listenerConfig5 = _this$listenerConfig4.forEach) === null || _this$listenerConfig5 === void 0 || _this$listenerConfig5.call(_this$listenerConfig4, function (item) {
|
|
157
|
+
var _item$task2;
|
|
158
|
+
item === null || item === void 0 || (_item$task2 = item.task) === null || _item$task2 === void 0 || _item$task2.clearTaskQueue();
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* 清空监听对应的任务执行队列,不传入eventKey则清空所有监听对应的任务执行队列
|
|
91
164
|
* @param eventKey 事件key
|
|
92
|
-
* @param value 扫码结果
|
|
93
165
|
*/
|
|
94
166
|
}, {
|
|
95
|
-
key: "
|
|
96
|
-
value: function
|
|
97
|
-
|
|
98
|
-
if (
|
|
99
|
-
var listenerConfig
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}
|
|
167
|
+
key: "clearTaskQueue",
|
|
168
|
+
value: function clearTaskQueue(eventKey) {
|
|
169
|
+
console.log('clearTaskQueue>>>>>>>', eventKey);
|
|
170
|
+
if (eventKey) {
|
|
171
|
+
var _this$listenerConfig$3;
|
|
172
|
+
(_this$listenerConfig$3 = this.listenerConfig.get(eventKey)) === null || _this$listenerConfig$3 === void 0 || _this$listenerConfig$3.task.clearTaskQueue();
|
|
173
|
+
} else {
|
|
174
|
+
var _this$listenerConfig6, _this$listenerConfig7;
|
|
175
|
+
(_this$listenerConfig6 = this.listenerConfig) === null || _this$listenerConfig6 === void 0 || (_this$listenerConfig7 = _this$listenerConfig6.forEach) === null || _this$listenerConfig7 === void 0 || _this$listenerConfig7.call(_this$listenerConfig6, function (item) {
|
|
176
|
+
var _item$task3;
|
|
177
|
+
item === null || item === void 0 || (_item$task3 = item.task) === null || _item$task3 === void 0 || _item$task3.clearTaskQueue();
|
|
178
|
+
});
|
|
108
179
|
}
|
|
109
180
|
}
|
|
110
181
|
|
|
@@ -116,19 +187,18 @@ var Scan = /*#__PURE__*/function () {
|
|
|
116
187
|
}, {
|
|
117
188
|
key: "getListenerConfig",
|
|
118
189
|
value: function getListenerConfig(eventKey) {
|
|
119
|
-
var _this$
|
|
120
|
-
return (_this$
|
|
190
|
+
var _this$listenerConfig8;
|
|
191
|
+
return (_this$listenerConfig8 = this.listenerConfig) === null || _this$listenerConfig8 === void 0 ? void 0 : _this$listenerConfig8.get(eventKey);
|
|
121
192
|
}
|
|
122
193
|
|
|
123
194
|
/**
|
|
124
|
-
*
|
|
195
|
+
* 扫码任务执行函数
|
|
125
196
|
* @param args 参数
|
|
126
197
|
*/
|
|
127
198
|
}, {
|
|
128
|
-
key: "
|
|
199
|
+
key: "scanTaskAction",
|
|
129
200
|
value: (function () {
|
|
130
|
-
var
|
|
131
|
-
var _this$getListenerConf;
|
|
201
|
+
var _scanTaskAction = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
132
202
|
var _len2,
|
|
133
203
|
args,
|
|
134
204
|
_key2,
|
|
@@ -138,7 +208,10 @@ var Scan = /*#__PURE__*/function () {
|
|
|
138
208
|
type,
|
|
139
209
|
value,
|
|
140
210
|
data,
|
|
211
|
+
taskItemUuid,
|
|
212
|
+
_ref2,
|
|
141
213
|
scanCallback,
|
|
214
|
+
task,
|
|
142
215
|
_result2,
|
|
143
216
|
_args = arguments;
|
|
144
217
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
@@ -149,51 +222,62 @@ var Scan = /*#__PURE__*/function () {
|
|
|
149
222
|
}
|
|
150
223
|
eventKey = args[0], other = args[1];
|
|
151
224
|
_ref = (other === null || other === void 0 ? void 0 : other.scanResult) || {}, type = _ref.type, value = _ref.value, data = _ref.data;
|
|
152
|
-
|
|
225
|
+
taskItemUuid = other === null || other === void 0 ? void 0 : other.uuid;
|
|
226
|
+
_ref2 = this.getListenerConfig(eventKey) || {}, scanCallback = _ref2.scanCallback, task = _ref2.task;
|
|
153
227
|
if (!scanCallback) {
|
|
154
|
-
_context.next =
|
|
228
|
+
_context.next = 18;
|
|
155
229
|
break;
|
|
156
230
|
}
|
|
157
|
-
_context.prev =
|
|
158
|
-
_context.next =
|
|
231
|
+
_context.prev = 6;
|
|
232
|
+
_context.next = 9;
|
|
159
233
|
return scanCallback({
|
|
160
234
|
type: type,
|
|
161
235
|
value: value
|
|
162
236
|
});
|
|
163
|
-
case
|
|
237
|
+
case 9:
|
|
164
238
|
_result2 = _context.sent;
|
|
165
239
|
console.log("".concat(eventKey, "_result>>>>>>>"), _result2);
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
240
|
+
// 如果任务存在,则发布结果
|
|
241
|
+
if (taskItemUuid && task !== null && task !== void 0 && task.isTaskExist(taskItemUuid)) {
|
|
242
|
+
watch.publishByEventKey(this.watchKey, eventKey, {
|
|
243
|
+
type: eventKey,
|
|
244
|
+
status: 'success',
|
|
245
|
+
scanType: type,
|
|
246
|
+
scanCode: value,
|
|
247
|
+
scanData: data,
|
|
248
|
+
result: _result2
|
|
249
|
+
});
|
|
250
|
+
} else {
|
|
251
|
+
console.warn("".concat(eventKey, "_result_task_not_exist>>>>>>>"), task);
|
|
252
|
+
}
|
|
253
|
+
_context.next = 18;
|
|
175
254
|
break;
|
|
176
|
-
case
|
|
177
|
-
_context.prev =
|
|
178
|
-
_context.t0 = _context["catch"](
|
|
255
|
+
case 14:
|
|
256
|
+
_context.prev = 14;
|
|
257
|
+
_context.t0 = _context["catch"](6);
|
|
179
258
|
console.log("".concat(eventKey, "_result_error>>>>>>>"), _context.t0);
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
259
|
+
// 如果任务存在,则发布结果
|
|
260
|
+
if (taskItemUuid && task !== null && task !== void 0 && task.isTaskExist(taskItemUuid)) {
|
|
261
|
+
watch.publishByEventKey(this.watchKey, eventKey, {
|
|
262
|
+
type: eventKey,
|
|
263
|
+
status: 'failed',
|
|
264
|
+
scanType: type,
|
|
265
|
+
scanCode: value,
|
|
266
|
+
scanData: data
|
|
267
|
+
});
|
|
268
|
+
} else {
|
|
269
|
+
console.warn("".concat(eventKey, "_result_error_task_not_exist>>>>>>>"), task);
|
|
270
|
+
}
|
|
271
|
+
case 18:
|
|
188
272
|
case "end":
|
|
189
273
|
return _context.stop();
|
|
190
274
|
}
|
|
191
|
-
}, _callee, this, [[
|
|
275
|
+
}, _callee, this, [[6, 14]]);
|
|
192
276
|
}));
|
|
193
|
-
function
|
|
194
|
-
return
|
|
277
|
+
function scanTaskAction() {
|
|
278
|
+
return _scanTaskAction.apply(this, arguments);
|
|
195
279
|
}
|
|
196
|
-
return
|
|
280
|
+
return scanTaskAction;
|
|
197
281
|
}())
|
|
198
282
|
}]);
|
|
199
283
|
return Scan;
|
package/dist/utils/task.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
type Action = (...args: any[]) => Promise<any>;
|
|
2
2
|
type Task = {
|
|
3
|
+
uuid: string;
|
|
3
4
|
type: string;
|
|
4
5
|
actionParams?: Record<string, any>;
|
|
5
6
|
};
|
|
@@ -9,9 +10,13 @@ declare class Tasks {
|
|
|
9
10
|
isRunning: boolean;
|
|
10
11
|
constructor(actions?: Map<string, Action>);
|
|
11
12
|
/**
|
|
12
|
-
*
|
|
13
|
+
* 清空所有任务
|
|
13
14
|
*/
|
|
14
15
|
clear(): void;
|
|
16
|
+
/**
|
|
17
|
+
* 清空任务执行队列
|
|
18
|
+
*/
|
|
19
|
+
clearTaskQueue(): void;
|
|
15
20
|
/**
|
|
16
21
|
* 添加action
|
|
17
22
|
* @param name action名称
|
|
@@ -27,5 +32,9 @@ declare class Tasks {
|
|
|
27
32
|
* 执行任务
|
|
28
33
|
*/
|
|
29
34
|
run(): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* 判定当前的任务是否依然存在
|
|
37
|
+
*/
|
|
38
|
+
isTaskExist(uuid: string): boolean;
|
|
30
39
|
}
|
|
31
40
|
export default Tasks;
|
package/dist/utils/task.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
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
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 ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
3
5
|
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
6
|
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
7
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
@@ -20,7 +22,7 @@ var Tasks = /*#__PURE__*/function () {
|
|
|
20
22
|
}
|
|
21
23
|
|
|
22
24
|
/**
|
|
23
|
-
*
|
|
25
|
+
* 清空所有任务
|
|
24
26
|
*/
|
|
25
27
|
_createClass(Tasks, [{
|
|
26
28
|
key: "clear",
|
|
@@ -30,6 +32,16 @@ var Tasks = /*#__PURE__*/function () {
|
|
|
30
32
|
this.isRunning = false;
|
|
31
33
|
}
|
|
32
34
|
|
|
35
|
+
/**
|
|
36
|
+
* 清空任务执行队列
|
|
37
|
+
*/
|
|
38
|
+
}, {
|
|
39
|
+
key: "clearTaskQueue",
|
|
40
|
+
value: function clearTaskQueue() {
|
|
41
|
+
this.taskQueue = [];
|
|
42
|
+
this.isRunning = false;
|
|
43
|
+
}
|
|
44
|
+
|
|
33
45
|
/**
|
|
34
46
|
* 添加action
|
|
35
47
|
* @param name action名称
|
|
@@ -60,7 +72,7 @@ var Tasks = /*#__PURE__*/function () {
|
|
|
60
72
|
key: "run",
|
|
61
73
|
value: (function () {
|
|
62
74
|
var _run = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
63
|
-
var task, action;
|
|
75
|
+
var _this$taskQueue, task, action, _task, _task2;
|
|
64
76
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
65
77
|
while (1) switch (_context.prev = _context.next) {
|
|
66
78
|
case 0:
|
|
@@ -82,11 +94,11 @@ var Tasks = /*#__PURE__*/function () {
|
|
|
82
94
|
// 遍历任务队列
|
|
83
95
|
case 6:
|
|
84
96
|
if (!(this.taskQueue.length > 0)) {
|
|
85
|
-
_context.next =
|
|
97
|
+
_context.next = 32;
|
|
86
98
|
break;
|
|
87
99
|
}
|
|
88
|
-
//
|
|
89
|
-
task = this.taskQueue
|
|
100
|
+
// 获取任务,但是不删除
|
|
101
|
+
task = (_this$taskQueue = this.taskQueue) === null || _this$taskQueue === void 0 ? void 0 : _this$taskQueue[0]; // 如果没有任务则直接结束
|
|
90
102
|
if (task) {
|
|
91
103
|
_context.next = 11;
|
|
92
104
|
break;
|
|
@@ -97,54 +109,63 @@ var Tasks = /*#__PURE__*/function () {
|
|
|
97
109
|
// 获取任务对应的action
|
|
98
110
|
action = this.actions.get(task.type); // 如果找到对应的action,则执行
|
|
99
111
|
if (!action) {
|
|
100
|
-
_context.next =
|
|
112
|
+
_context.next = 28;
|
|
101
113
|
break;
|
|
102
114
|
}
|
|
103
|
-
_context.
|
|
104
|
-
|
|
105
|
-
|
|
115
|
+
_context.prev = 13;
|
|
116
|
+
_context.next = 16;
|
|
117
|
+
return action(_objectSpread(_objectSpread({}, (task === null || task === void 0 ? void 0 : task.actionParams) || {}), {}, {
|
|
118
|
+
uuid: task === null || task === void 0 ? void 0 : task.uuid
|
|
119
|
+
}));
|
|
120
|
+
case 16:
|
|
121
|
+
console.log('task_success>>>>>>>', task);
|
|
122
|
+
_context.next = 22;
|
|
123
|
+
break;
|
|
124
|
+
case 19:
|
|
125
|
+
_context.prev = 19;
|
|
126
|
+
_context.t0 = _context["catch"](13);
|
|
127
|
+
console.error('task_error>>>>>>>', _context.t0);
|
|
128
|
+
case 22:
|
|
129
|
+
_context.prev = 22;
|
|
130
|
+
// 将任务删除
|
|
131
|
+
_task = this.taskQueue.shift();
|
|
132
|
+
console.log('task_shift>>>>>>>', _task);
|
|
133
|
+
return _context.finish(22);
|
|
134
|
+
case 26:
|
|
135
|
+
_context.next = 30;
|
|
136
|
+
break;
|
|
137
|
+
case 28:
|
|
138
|
+
// 如果找不到对应的action,则删除任务
|
|
139
|
+
_task2 = this.taskQueue.shift();
|
|
140
|
+
console.log('task_action_not_found>>>>>>>', _task2);
|
|
141
|
+
case 30:
|
|
106
142
|
_context.next = 6;
|
|
107
143
|
break;
|
|
108
|
-
case
|
|
144
|
+
case 32:
|
|
109
145
|
this.isRunning = false;
|
|
110
|
-
case
|
|
146
|
+
case 33:
|
|
111
147
|
case "end":
|
|
112
148
|
return _context.stop();
|
|
113
149
|
}
|
|
114
|
-
}, _callee, this);
|
|
150
|
+
}, _callee, this, [[13, 19, 22, 26]]);
|
|
115
151
|
}));
|
|
116
152
|
function run() {
|
|
117
153
|
return _run.apply(this, arguments);
|
|
118
154
|
}
|
|
119
155
|
return run;
|
|
120
|
-
}()
|
|
156
|
+
}()
|
|
157
|
+
/**
|
|
158
|
+
* 判定当前的任务是否依然存在
|
|
159
|
+
*/
|
|
160
|
+
)
|
|
161
|
+
}, {
|
|
162
|
+
key: "isTaskExist",
|
|
163
|
+
value: function isTaskExist(uuid) {
|
|
164
|
+
return this.taskQueue.some(function (task) {
|
|
165
|
+
return (task === null || task === void 0 ? void 0 : task.uuid) === uuid;
|
|
166
|
+
});
|
|
167
|
+
}
|
|
121
168
|
}]);
|
|
122
169
|
return Tasks;
|
|
123
170
|
}();
|
|
124
|
-
export default Tasks;
|
|
125
|
-
|
|
126
|
-
// const tasks = new Tasks(new Map([
|
|
127
|
-
// ['查询客户', async () => {
|
|
128
|
-
// console.log('action1');
|
|
129
|
-
// // 1. 获取东西
|
|
130
|
-
// }],
|
|
131
|
-
// ['action2', async () => {
|
|
132
|
-
// console.log('action2');
|
|
133
|
-
// }],
|
|
134
|
-
// ]));
|
|
135
|
-
|
|
136
|
-
// const fn = (str: string) => {
|
|
137
|
-
|
|
138
|
-
// if (str === '查询客户') {
|
|
139
|
-
// tasks.addTask({ type: '查询客户' });
|
|
140
|
-
// }
|
|
141
|
-
// if (str === '查询客户') {
|
|
142
|
-
// tasks.addTask({ type: '查询客户' });
|
|
143
|
-
// }
|
|
144
|
-
// if (str === '查询客户') {
|
|
145
|
-
// tasks.addTask({ type: '查询客户' });
|
|
146
|
-
// }
|
|
147
|
-
// if (str === '查询客户') {
|
|
148
|
-
// tasks.addTask({ type: '查询客户' });
|
|
149
|
-
// }
|
|
150
|
-
// }
|
|
171
|
+
export default Tasks;
|
package/dist/utils/watch.d.ts
CHANGED
package/dist/utils/watch.js
CHANGED
|
@@ -189,19 +189,23 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
189
189
|
if (isAvailableProduct && isLimitedProduct) {
|
|
190
190
|
(_c = discountApplicability.get(discount.id)) == null ? void 0 : _c.push(product.id);
|
|
191
191
|
const applicableProducts = discountApplicableProducts.get(discount.id) || [];
|
|
192
|
-
|
|
192
|
+
const discountType = discount.tag || discount.type;
|
|
193
|
+
const productData = {
|
|
193
194
|
amount: product.price,
|
|
194
|
-
type:
|
|
195
|
-
tag:
|
|
195
|
+
type: discountType,
|
|
196
|
+
tag: discountType,
|
|
196
197
|
discount: {
|
|
197
198
|
resource_id: discount.id,
|
|
198
199
|
title: discount.format_title,
|
|
199
200
|
original_amount: product.origin_total,
|
|
200
201
|
pre_value: discount.par_value,
|
|
201
202
|
product_id: originProduct.id
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
if (discountType !== "good_pass") {
|
|
206
|
+
productData.num = product.num || 1;
|
|
207
|
+
}
|
|
208
|
+
applicableProducts.push(productData);
|
|
205
209
|
discountApplicableProducts.set(discount.id, applicableProducts);
|
|
206
210
|
}
|
|
207
211
|
});
|
|
@@ -310,18 +314,21 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
310
314
|
productOriginTotal = product.total;
|
|
311
315
|
}
|
|
312
316
|
const targetProductTotal = selectedDiscount2.tag === "good_pass" ? new import_decimal.default(productOriginTotal).minus(new import_decimal.default(product.price || 0)).toNumber() : new import_decimal.default(100).minus(selectedDiscount2.par_value || 0).div(100).mul(new import_decimal.default(productOriginTotal)).toNumber();
|
|
317
|
+
const discountType = selectedDiscount2.tag === "product_discount_card" ? "discount_card" : selectedDiscount2.tag;
|
|
313
318
|
const discountDetail = {
|
|
314
319
|
amount: new import_decimal.default(productOriginTotal).minus(new import_decimal.default(targetProductTotal)).toNumber(),
|
|
315
|
-
type:
|
|
320
|
+
type: discountType,
|
|
316
321
|
discount: {
|
|
317
322
|
resource_id: selectedDiscount2.id,
|
|
318
323
|
title: selectedDiscount2.format_title,
|
|
319
324
|
original_amount: productOriginTotal,
|
|
320
325
|
product_id: originProduct.id,
|
|
321
326
|
percent: selectedDiscount2.par_value
|
|
322
|
-
}
|
|
323
|
-
num: product.num || 1
|
|
327
|
+
}
|
|
324
328
|
};
|
|
329
|
+
if ((selectedDiscount2.tag || selectedDiscount2.type) !== "good_pass") {
|
|
330
|
+
discountDetail.num = product.num || 1;
|
|
331
|
+
}
|
|
325
332
|
appliedProducts.push(discountDetail);
|
|
326
333
|
appliedDiscountProducts.set(selectedDiscount2.id, appliedProducts);
|
|
327
334
|
if (product.isClient) {
|
|
@@ -111,7 +111,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
|
|
|
111
111
|
* 获取当前的客户搜索条件
|
|
112
112
|
* @returns 当前搜索条件
|
|
113
113
|
*/
|
|
114
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
114
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
|
|
115
115
|
/**
|
|
116
116
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
117
117
|
* @returns 客户状态
|
|
@@ -138,6 +138,18 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
|
|
|
138
138
|
activateCamera(data?: {
|
|
139
139
|
[key: string]: any;
|
|
140
140
|
}): void;
|
|
141
|
+
/**
|
|
142
|
+
* 禁用所有扫描监听
|
|
143
|
+
*/
|
|
144
|
+
disableAllScanListeners(): void;
|
|
145
|
+
/**
|
|
146
|
+
* 启用所有扫描监听
|
|
147
|
+
*/
|
|
148
|
+
enableAllScanListeners(): void;
|
|
149
|
+
/**
|
|
150
|
+
* 清空所有扫描监听对应的任务执行队列
|
|
151
|
+
*/
|
|
152
|
+
clearAllScanListenersTaskQueue(): void;
|
|
141
153
|
/**
|
|
142
154
|
* 设置其他参数
|
|
143
155
|
* @param params 参数
|
|
@@ -338,6 +338,24 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
|
|
|
338
338
|
data
|
|
339
339
|
});
|
|
340
340
|
}
|
|
341
|
+
/**
|
|
342
|
+
* 禁用所有扫描监听
|
|
343
|
+
*/
|
|
344
|
+
disableAllScanListeners() {
|
|
345
|
+
this.scan.disableAllListeners();
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* 启用所有扫描监听
|
|
349
|
+
*/
|
|
350
|
+
enableAllScanListeners() {
|
|
351
|
+
this.scan.enableAllListeners();
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* 清空所有扫描监听对应的任务执行队列
|
|
355
|
+
*/
|
|
356
|
+
clearAllScanListenersTaskQueue() {
|
|
357
|
+
this.scan.clearTaskQueue();
|
|
358
|
+
}
|
|
341
359
|
/**
|
|
342
360
|
* 设置其他参数
|
|
343
361
|
* @param params 参数
|
|
@@ -369,6 +387,7 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
|
|
|
369
387
|
(_e = this.store.order) == null ? void 0 : _e.destroy();
|
|
370
388
|
this.core.effects.offByModuleDestroy(this.name);
|
|
371
389
|
this.core.unregisterModule(this);
|
|
390
|
+
this.scan.removeAllListeners();
|
|
372
391
|
import_scanCache.default.clear();
|
|
373
392
|
}
|
|
374
393
|
};
|
|
@@ -18,6 +18,20 @@ export default class Scan {
|
|
|
18
18
|
private watchKey;
|
|
19
19
|
private listenerConfig;
|
|
20
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;
|
|
21
35
|
/**
|
|
22
36
|
* 添加扫码信息监听
|
|
23
37
|
* @param watchKey 监听的key
|
|
@@ -33,14 +47,22 @@ export default class Scan {
|
|
|
33
47
|
*/
|
|
34
48
|
removeListener(event: WatchEventItem): void;
|
|
35
49
|
/**
|
|
36
|
-
*
|
|
50
|
+
* 移除所有监听
|
|
51
|
+
*/
|
|
52
|
+
removeAllListeners(): void;
|
|
53
|
+
/**
|
|
54
|
+
* 启用所有监听
|
|
55
|
+
*/
|
|
56
|
+
enableAllListeners(): void;
|
|
57
|
+
/**
|
|
58
|
+
* 禁用所有监听,并清空任务执行队列
|
|
59
|
+
*/
|
|
60
|
+
disableAllListeners(): void;
|
|
61
|
+
/**
|
|
62
|
+
* 清空监听对应的任务执行队列,不传入eventKey则清空所有监听对应的任务执行队列
|
|
37
63
|
* @param eventKey 事件key
|
|
38
|
-
* @param value 扫码结果
|
|
39
64
|
*/
|
|
40
|
-
|
|
41
|
-
type: string;
|
|
42
|
-
value: string;
|
|
43
|
-
}): void;
|
|
65
|
+
clearTaskQueue(eventKey?: string): void;
|
|
44
66
|
/**
|
|
45
67
|
* 获取监听配置
|
|
46
68
|
* @param eventKey 事件key
|
|
@@ -51,9 +73,9 @@ export default class Scan {
|
|
|
51
73
|
task: Tasks;
|
|
52
74
|
} | undefined;
|
|
53
75
|
/**
|
|
54
|
-
*
|
|
76
|
+
* 扫码任务执行函数
|
|
55
77
|
* @param args 参数
|
|
56
78
|
*/
|
|
57
|
-
|
|
79
|
+
scanTaskAction(...args: any[]): Promise<void>;
|
|
58
80
|
}
|
|
59
81
|
export {};
|
|
@@ -55,6 +55,33 @@ var Scan = class {
|
|
|
55
55
|
}
|
|
56
56
|
);
|
|
57
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* 处理扫码事件
|
|
60
|
+
* @param eventKey 事件key
|
|
61
|
+
* @param value 扫码结果
|
|
62
|
+
*/
|
|
63
|
+
handleScan(result) {
|
|
64
|
+
const lastEnableEventKey = import_watch.default.getLastEnableEventKey(this.watchKey);
|
|
65
|
+
if (lastEnableEventKey) {
|
|
66
|
+
const listenerConfig = this.listenerConfig.get(lastEnableEventKey);
|
|
67
|
+
if (listenerConfig) {
|
|
68
|
+
listenerConfig.task.addTask({
|
|
69
|
+
uuid: this.generateUuid(),
|
|
70
|
+
type: lastEnableEventKey,
|
|
71
|
+
actionParams: {
|
|
72
|
+
scanResult: result
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* 生成uuid
|
|
80
|
+
* @returns uuid
|
|
81
|
+
*/
|
|
82
|
+
generateUuid() {
|
|
83
|
+
return Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15) + Date.now().toString(36);
|
|
84
|
+
}
|
|
58
85
|
/**
|
|
59
86
|
* 添加扫码信息监听
|
|
60
87
|
* @param watchKey 监听的key
|
|
@@ -65,7 +92,7 @@ var Scan = class {
|
|
|
65
92
|
const task = new import_task.default();
|
|
66
93
|
task.addAction(
|
|
67
94
|
event.key,
|
|
68
|
-
(...args) => this.
|
|
95
|
+
(...args) => this.scanTaskAction(event.key, ...args)
|
|
69
96
|
);
|
|
70
97
|
this.listenerConfig.set(event.key, { scanCallback, task });
|
|
71
98
|
return {
|
|
@@ -80,28 +107,54 @@ var Scan = class {
|
|
|
80
107
|
* @param event 事件
|
|
81
108
|
*/
|
|
82
109
|
removeListener(event) {
|
|
83
|
-
var _a;
|
|
110
|
+
var _a, _b;
|
|
84
111
|
import_watch.default.unsubscribe(this.watchKey, event);
|
|
85
|
-
(_a = this.listenerConfig.get(event.key)) == null ? void 0 : _a.task.clear();
|
|
112
|
+
(_b = (_a = this.listenerConfig.get(event.key)) == null ? void 0 : _a.task) == null ? void 0 : _b.clear();
|
|
86
113
|
this.listenerConfig.delete(event.key);
|
|
87
114
|
}
|
|
88
115
|
/**
|
|
89
|
-
*
|
|
116
|
+
* 移除所有监听
|
|
117
|
+
*/
|
|
118
|
+
removeAllListeners() {
|
|
119
|
+
var _a, _b, _c, _d;
|
|
120
|
+
import_watch.default.clearEvent(this.watchKey);
|
|
121
|
+
(_b = (_a = this.listenerConfig) == null ? void 0 : _a.forEach) == null ? void 0 : _b.call(_a, (item) => {
|
|
122
|
+
var _a2;
|
|
123
|
+
(_a2 = item == null ? void 0 : item.task) == null ? void 0 : _a2.clear();
|
|
124
|
+
});
|
|
125
|
+
(_d = (_c = this.listenerConfig) == null ? void 0 : _c.clear) == null ? void 0 : _d.call(_c);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* 启用所有监听
|
|
129
|
+
*/
|
|
130
|
+
enableAllListeners() {
|
|
131
|
+
import_watch.default.enableAllEventByWatchKey(this.watchKey);
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* 禁用所有监听,并清空任务执行队列
|
|
135
|
+
*/
|
|
136
|
+
disableAllListeners() {
|
|
137
|
+
var _a, _b;
|
|
138
|
+
import_watch.default.disabledAllEventByWatchKey(this.watchKey);
|
|
139
|
+
(_b = (_a = this.listenerConfig) == null ? void 0 : _a.forEach) == null ? void 0 : _b.call(_a, (item) => {
|
|
140
|
+
var _a2;
|
|
141
|
+
(_a2 = item == null ? void 0 : item.task) == null ? void 0 : _a2.clearTaskQueue();
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* 清空监听对应的任务执行队列,不传入eventKey则清空所有监听对应的任务执行队列
|
|
90
146
|
* @param eventKey 事件key
|
|
91
|
-
* @param value 扫码结果
|
|
92
147
|
*/
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
});
|
|
104
|
-
}
|
|
148
|
+
clearTaskQueue(eventKey) {
|
|
149
|
+
var _a, _b, _c;
|
|
150
|
+
console.log("clearTaskQueue>>>>>>>", eventKey);
|
|
151
|
+
if (eventKey) {
|
|
152
|
+
(_a = this.listenerConfig.get(eventKey)) == null ? void 0 : _a.task.clearTaskQueue();
|
|
153
|
+
} else {
|
|
154
|
+
(_c = (_b = this.listenerConfig) == null ? void 0 : _b.forEach) == null ? void 0 : _c.call(_b, (item) => {
|
|
155
|
+
var _a2;
|
|
156
|
+
(_a2 = item == null ? void 0 : item.task) == null ? void 0 : _a2.clearTaskQueue();
|
|
157
|
+
});
|
|
105
158
|
}
|
|
106
159
|
}
|
|
107
160
|
/**
|
|
@@ -114,35 +167,43 @@ var Scan = class {
|
|
|
114
167
|
return (_a = this.listenerConfig) == null ? void 0 : _a.get(eventKey);
|
|
115
168
|
}
|
|
116
169
|
/**
|
|
117
|
-
*
|
|
170
|
+
* 扫码任务执行函数
|
|
118
171
|
* @param args 参数
|
|
119
172
|
*/
|
|
120
|
-
async
|
|
121
|
-
var _a;
|
|
173
|
+
async scanTaskAction(...args) {
|
|
122
174
|
const [eventKey, other] = args;
|
|
123
175
|
const { type, value, data } = (other == null ? void 0 : other.scanResult) || {};
|
|
124
|
-
const
|
|
176
|
+
const taskItemUuid = other == null ? void 0 : other.uuid;
|
|
177
|
+
const { scanCallback, task } = this.getListenerConfig(eventKey) || {};
|
|
125
178
|
if (scanCallback) {
|
|
126
179
|
try {
|
|
127
180
|
const result = await scanCallback({ type, value });
|
|
128
181
|
console.log(`${eventKey}_result>>>>>>>`, result);
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
182
|
+
if (taskItemUuid && (task == null ? void 0 : task.isTaskExist(taskItemUuid))) {
|
|
183
|
+
import_watch.default.publishByEventKey(this.watchKey, eventKey, {
|
|
184
|
+
type: eventKey,
|
|
185
|
+
status: "success",
|
|
186
|
+
scanType: type,
|
|
187
|
+
scanCode: value,
|
|
188
|
+
scanData: data,
|
|
189
|
+
result
|
|
190
|
+
});
|
|
191
|
+
} else {
|
|
192
|
+
console.warn(`${eventKey}_result_task_not_exist>>>>>>>`, task);
|
|
193
|
+
}
|
|
137
194
|
} catch (error) {
|
|
138
195
|
console.log(`${eventKey}_result_error>>>>>>>`, error);
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
196
|
+
if (taskItemUuid && (task == null ? void 0 : task.isTaskExist(taskItemUuid))) {
|
|
197
|
+
import_watch.default.publishByEventKey(this.watchKey, eventKey, {
|
|
198
|
+
type: eventKey,
|
|
199
|
+
status: "failed",
|
|
200
|
+
scanType: type,
|
|
201
|
+
scanCode: value,
|
|
202
|
+
scanData: data
|
|
203
|
+
});
|
|
204
|
+
} else {
|
|
205
|
+
console.warn(`${eventKey}_result_error_task_not_exist>>>>>>>`, task);
|
|
206
|
+
}
|
|
146
207
|
}
|
|
147
208
|
}
|
|
148
209
|
}
|
package/lib/utils/task.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
type Action = (...args: any[]) => Promise<any>;
|
|
2
2
|
type Task = {
|
|
3
|
+
uuid: string;
|
|
3
4
|
type: string;
|
|
4
5
|
actionParams?: Record<string, any>;
|
|
5
6
|
};
|
|
@@ -9,9 +10,13 @@ declare class Tasks {
|
|
|
9
10
|
isRunning: boolean;
|
|
10
11
|
constructor(actions?: Map<string, Action>);
|
|
11
12
|
/**
|
|
12
|
-
*
|
|
13
|
+
* 清空所有任务
|
|
13
14
|
*/
|
|
14
15
|
clear(): void;
|
|
16
|
+
/**
|
|
17
|
+
* 清空任务执行队列
|
|
18
|
+
*/
|
|
19
|
+
clearTaskQueue(): void;
|
|
15
20
|
/**
|
|
16
21
|
* 添加action
|
|
17
22
|
* @param name action名称
|
|
@@ -27,5 +32,9 @@ declare class Tasks {
|
|
|
27
32
|
* 执行任务
|
|
28
33
|
*/
|
|
29
34
|
run(): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* 判定当前的任务是否依然存在
|
|
37
|
+
*/
|
|
38
|
+
isTaskExist(uuid: string): boolean;
|
|
30
39
|
}
|
|
31
40
|
export default Tasks;
|
package/lib/utils/task.js
CHANGED
|
@@ -32,13 +32,20 @@ var Tasks = class {
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
/**
|
|
35
|
-
*
|
|
35
|
+
* 清空所有任务
|
|
36
36
|
*/
|
|
37
37
|
clear() {
|
|
38
38
|
this.actions.clear();
|
|
39
39
|
this.taskQueue = [];
|
|
40
40
|
this.isRunning = false;
|
|
41
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* 清空任务执行队列
|
|
44
|
+
*/
|
|
45
|
+
clearTaskQueue() {
|
|
46
|
+
this.taskQueue = [];
|
|
47
|
+
this.isRunning = false;
|
|
48
|
+
}
|
|
42
49
|
/**
|
|
43
50
|
* 添加action
|
|
44
51
|
* @param name action名称
|
|
@@ -59,6 +66,7 @@ var Tasks = class {
|
|
|
59
66
|
* 执行任务
|
|
60
67
|
*/
|
|
61
68
|
async run() {
|
|
69
|
+
var _a;
|
|
62
70
|
if (this.isRunning) {
|
|
63
71
|
return;
|
|
64
72
|
}
|
|
@@ -68,17 +76,34 @@ var Tasks = class {
|
|
|
68
76
|
}
|
|
69
77
|
this.isRunning = true;
|
|
70
78
|
while (this.taskQueue.length > 0) {
|
|
71
|
-
const task = this.taskQueue
|
|
79
|
+
const task = (_a = this.taskQueue) == null ? void 0 : _a[0];
|
|
72
80
|
if (!task) {
|
|
73
81
|
this.isRunning = false;
|
|
74
82
|
return;
|
|
75
83
|
}
|
|
76
84
|
const action = this.actions.get(task.type);
|
|
77
85
|
if (action) {
|
|
78
|
-
|
|
86
|
+
try {
|
|
87
|
+
await action({ ...(task == null ? void 0 : task.actionParams) || {}, uuid: task == null ? void 0 : task.uuid });
|
|
88
|
+
console.log("task_success>>>>>>>", task);
|
|
89
|
+
} catch (error) {
|
|
90
|
+
console.error("task_error>>>>>>>", error);
|
|
91
|
+
} finally {
|
|
92
|
+
const _task = this.taskQueue.shift();
|
|
93
|
+
console.log("task_shift>>>>>>>", _task);
|
|
94
|
+
}
|
|
95
|
+
} else {
|
|
96
|
+
const _task = this.taskQueue.shift();
|
|
97
|
+
console.log("task_action_not_found>>>>>>>", _task);
|
|
79
98
|
}
|
|
80
99
|
}
|
|
81
100
|
this.isRunning = false;
|
|
82
101
|
}
|
|
102
|
+
/**
|
|
103
|
+
* 判定当前的任务是否依然存在
|
|
104
|
+
*/
|
|
105
|
+
isTaskExist(uuid) {
|
|
106
|
+
return this.taskQueue.some((task) => (task == null ? void 0 : task.uuid) === uuid);
|
|
107
|
+
}
|
|
83
108
|
};
|
|
84
109
|
var task_default = Tasks;
|
package/lib/utils/watch.d.ts
CHANGED
package/lib/utils/watch.js
CHANGED