@pisell/pisellos 0.0.213 → 0.0.215
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/index.js +2 -1
- package/dist/effects/index.d.ts +4 -3
- package/dist/effects/index.js +15 -6
- package/dist/modules/AccountList/index.d.ts +7 -1
- package/dist/modules/AccountList/index.js +81 -14
- package/dist/modules/AccountList/types.d.ts +28 -0
- package/dist/modules/AccountList/types.js +8 -0
- package/dist/modules/Customer/constants.d.ts +7 -0
- package/dist/modules/Customer/constants.js +12 -0
- package/dist/modules/Customer/index.d.ts +89 -0
- package/dist/modules/Customer/index.js +439 -0
- package/dist/modules/Customer/types.d.ts +130 -0
- package/dist/modules/Customer/types.js +39 -0
- package/dist/modules/ProductList/index.d.ts +6 -1
- package/dist/modules/ProductList/index.js +8 -4
- package/dist/modules/Rules/index.js +7 -5
- package/dist/modules/Rules/types.d.ts +1 -0
- package/dist/modules/Schedule/utils.js +7 -1
- package/dist/modules/index.d.ts +1 -0
- package/dist/modules/index.js +1 -0
- package/dist/plugins/window.d.ts +1 -0
- package/dist/solution/BookingByStep/index.js +8 -15
- package/dist/solution/BookingTicket/index.d.ts +127 -0
- package/dist/solution/BookingTicket/index.js +494 -0
- package/dist/solution/BookingTicket/types.d.ts +66 -0
- package/dist/solution/BookingTicket/types.js +41 -0
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.d.ts +22 -0
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +147 -0
- package/dist/solution/BookingTicket/utils/scan/handleScan.d.ts +19 -0
- package/dist/solution/BookingTicket/utils/scan/handleScan.js +138 -0
- package/dist/solution/BookingTicket/utils/scan/index.d.ts +51 -0
- package/dist/solution/BookingTicket/utils/scan/index.js +189 -0
- package/dist/solution/ShopDiscount/index.js +4 -2
- package/dist/solution/index.d.ts +1 -0
- package/dist/solution/index.js +1 -0
- package/dist/types/index.d.ts +3 -1
- package/dist/utils/task.d.ts +31 -0
- package/dist/utils/task.js +150 -0
- package/dist/utils/watch.d.ts +102 -0
- package/dist/utils/watch.js +294 -0
- package/lib/core/index.js +1 -1
- package/lib/effects/index.d.ts +4 -3
- package/lib/effects/index.js +4 -1
- package/lib/modules/AccountList/index.d.ts +7 -1
- package/lib/modules/AccountList/index.js +27 -0
- package/lib/modules/AccountList/types.d.ts +28 -0
- package/lib/modules/Customer/constants.d.ts +7 -0
- package/lib/modules/Customer/constants.js +39 -0
- package/lib/modules/Customer/index.d.ts +89 -0
- package/lib/modules/Customer/index.js +304 -0
- package/lib/modules/Customer/types.d.ts +130 -0
- package/lib/modules/Customer/types.js +35 -0
- package/lib/modules/ProductList/index.d.ts +6 -1
- package/lib/modules/ProductList/index.js +12 -3
- package/lib/modules/Rules/index.js +4 -3
- package/lib/modules/Rules/types.d.ts +1 -0
- package/lib/modules/Schedule/utils.js +8 -3
- package/lib/modules/index.d.ts +1 -0
- package/lib/modules/index.js +2 -0
- package/lib/plugins/window.d.ts +1 -0
- package/lib/solution/BookingByStep/index.js +0 -7
- package/lib/solution/BookingTicket/index.d.ts +127 -0
- package/lib/solution/BookingTicket/index.js +291 -0
- package/lib/solution/BookingTicket/types.d.ts +66 -0
- package/lib/solution/BookingTicket/types.js +70 -0
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.d.ts +22 -0
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +97 -0
- package/lib/solution/BookingTicket/utils/scan/handleScan.d.ts +19 -0
- package/lib/solution/BookingTicket/utils/scan/handleScan.js +95 -0
- package/lib/solution/BookingTicket/utils/scan/index.d.ts +51 -0
- package/lib/solution/BookingTicket/utils/scan/index.js +153 -0
- package/lib/solution/ShopDiscount/index.js +2 -1
- package/lib/solution/index.d.ts +1 -0
- package/lib/solution/index.js +2 -0
- package/lib/types/index.d.ts +3 -1
- package/lib/utils/task.d.ts +31 -0
- package/lib/utils/task.js +84 -0
- package/lib/utils/watch.d.ts +102 -0
- package/lib/utils/watch.js +217 -0
- package/package.json +1 -1
|
@@ -0,0 +1,147 @@
|
|
|
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
|
+
tags: ['point_card',
|
|
21
|
+
// 积分卡
|
|
22
|
+
'gift_card',
|
|
23
|
+
// 充值卡
|
|
24
|
+
'product_voucher',
|
|
25
|
+
// 代金券
|
|
26
|
+
'product_discount_card',
|
|
27
|
+
// 折扣卡
|
|
28
|
+
'good_pass',
|
|
29
|
+
// 商品券
|
|
30
|
+
'session_ticket',
|
|
31
|
+
// 场次票
|
|
32
|
+
'appointment_ticket' // 预约类门票
|
|
33
|
+
]
|
|
34
|
+
};
|
|
35
|
+
_context.prev = 1;
|
|
36
|
+
_context.next = 4;
|
|
37
|
+
return request === null || request === void 0 ? void 0 : request.get('/machinecode/batch-search', params);
|
|
38
|
+
case 4:
|
|
39
|
+
res = _context.sent;
|
|
40
|
+
if (!((res === null || res === void 0 ? void 0 : res.code) == 200 && !!(res !== null && res !== void 0 && res.data))) {
|
|
41
|
+
_context.next = 7;
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
return _context.abrupt("return", {
|
|
45
|
+
searchType: 'walletPass',
|
|
46
|
+
response: res
|
|
47
|
+
});
|
|
48
|
+
case 7:
|
|
49
|
+
throw new Error('没有找到对应的识别码');
|
|
50
|
+
case 10:
|
|
51
|
+
_context.prev = 10;
|
|
52
|
+
_context.t0 = _context["catch"](1);
|
|
53
|
+
throw _context.t0;
|
|
54
|
+
case 13:
|
|
55
|
+
case "end":
|
|
56
|
+
return _context.stop();
|
|
57
|
+
}
|
|
58
|
+
}, _callee, null, [[1, 10]]);
|
|
59
|
+
}));
|
|
60
|
+
return function searchWalletPass(_x, _x2) {
|
|
61
|
+
return _ref.apply(this, arguments);
|
|
62
|
+
};
|
|
63
|
+
}();
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* 搜索钱包
|
|
67
|
+
*/
|
|
68
|
+
export var searchWallet = /*#__PURE__*/function () {
|
|
69
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(request, code) {
|
|
70
|
+
var params, res;
|
|
71
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
72
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
73
|
+
case 0:
|
|
74
|
+
params = {
|
|
75
|
+
code: code
|
|
76
|
+
};
|
|
77
|
+
_context2.prev = 1;
|
|
78
|
+
_context2.next = 4;
|
|
79
|
+
return request === null || request === void 0 ? void 0 : request.post('/wallet/detail/search', params);
|
|
80
|
+
case 4:
|
|
81
|
+
res = _context2.sent;
|
|
82
|
+
if (!((res === null || res === void 0 ? void 0 : res.code) == 200 && !!(res !== null && res !== void 0 && res.data))) {
|
|
83
|
+
_context2.next = 7;
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
return _context2.abrupt("return", {
|
|
87
|
+
searchType: 'wallet',
|
|
88
|
+
response: res
|
|
89
|
+
});
|
|
90
|
+
case 7:
|
|
91
|
+
throw new Error('没有找到对应的识别码');
|
|
92
|
+
case 10:
|
|
93
|
+
_context2.prev = 10;
|
|
94
|
+
_context2.t0 = _context2["catch"](1);
|
|
95
|
+
throw _context2.t0;
|
|
96
|
+
case 13:
|
|
97
|
+
case "end":
|
|
98
|
+
return _context2.stop();
|
|
99
|
+
}
|
|
100
|
+
}, _callee2, null, [[1, 10]]);
|
|
101
|
+
}));
|
|
102
|
+
return function searchWallet(_x3, _x4) {
|
|
103
|
+
return _ref2.apply(this, arguments);
|
|
104
|
+
};
|
|
105
|
+
}();
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* 搜索商品
|
|
109
|
+
*/
|
|
110
|
+
export var searchProduct = /*#__PURE__*/function () {
|
|
111
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(request, code) {
|
|
112
|
+
var params, _res$data, res;
|
|
113
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
114
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
115
|
+
case 0:
|
|
116
|
+
params = {
|
|
117
|
+
search: code
|
|
118
|
+
};
|
|
119
|
+
_context3.prev = 1;
|
|
120
|
+
_context3.next = 4;
|
|
121
|
+
return request === null || request === void 0 ? void 0 : request.get('/product/list', params);
|
|
122
|
+
case 4:
|
|
123
|
+
res = _context3.sent;
|
|
124
|
+
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)) {
|
|
125
|
+
_context3.next = 7;
|
|
126
|
+
break;
|
|
127
|
+
}
|
|
128
|
+
return _context3.abrupt("return", {
|
|
129
|
+
searchType: 'product',
|
|
130
|
+
response: res
|
|
131
|
+
});
|
|
132
|
+
case 7:
|
|
133
|
+
throw new Error('没有找到对应的识别码');
|
|
134
|
+
case 10:
|
|
135
|
+
_context3.prev = 10;
|
|
136
|
+
_context3.t0 = _context3["catch"](1);
|
|
137
|
+
throw _context3.t0;
|
|
138
|
+
case 13:
|
|
139
|
+
case "end":
|
|
140
|
+
return _context3.stop();
|
|
141
|
+
}
|
|
142
|
+
}, _callee3, null, [[1, 10]]);
|
|
143
|
+
}));
|
|
144
|
+
return function searchProduct(_x5, _x6) {
|
|
145
|
+
return _ref3.apply(this, arguments);
|
|
146
|
+
};
|
|
147
|
+
}();
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { RequestPlugin } from '../../../../plugins';
|
|
2
|
+
/**
|
|
3
|
+
* 处理全局扫码
|
|
4
|
+
* @param request 请求插件
|
|
5
|
+
* @returns 处理结果
|
|
6
|
+
*/
|
|
7
|
+
export declare const handleGlobalScan: (request: RequestPlugin) => (scanResult: {
|
|
8
|
+
type: string;
|
|
9
|
+
value: string;
|
|
10
|
+
}) => Promise<any>;
|
|
11
|
+
/**
|
|
12
|
+
* 处理客户扫码
|
|
13
|
+
* @param request 请求插件
|
|
14
|
+
* @returns 处理结果
|
|
15
|
+
*/
|
|
16
|
+
export declare const handleCustomerScan: (request: RequestPlugin) => (scanResult: {
|
|
17
|
+
type: string;
|
|
18
|
+
value: string;
|
|
19
|
+
}) => Promise<any>;
|
|
@@ -0,0 +1,138 @@
|
|
|
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
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Promise.any 的替代实现
|
|
9
|
+
* 返回第一个成功解析的 Promise,如果所有 Promise 都失败则抛出错误
|
|
10
|
+
* @param promises Promise 数组
|
|
11
|
+
* @returns 第一个成功的结果
|
|
12
|
+
*/
|
|
13
|
+
var promiseAny = /*#__PURE__*/function () {
|
|
14
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(promises) {
|
|
15
|
+
var errors, completedCount;
|
|
16
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
17
|
+
while (1) switch (_context.prev = _context.next) {
|
|
18
|
+
case 0:
|
|
19
|
+
if (!(promises.length === 0)) {
|
|
20
|
+
_context.next = 2;
|
|
21
|
+
break;
|
|
22
|
+
}
|
|
23
|
+
throw new Error('No promises provided');
|
|
24
|
+
case 2:
|
|
25
|
+
errors = [];
|
|
26
|
+
completedCount = 0;
|
|
27
|
+
return _context.abrupt("return", new Promise(function (resolve, reject) {
|
|
28
|
+
promises.forEach(function (promise, index) {
|
|
29
|
+
promise.then(function (result) {
|
|
30
|
+
resolve(result);
|
|
31
|
+
}).catch(function (error) {
|
|
32
|
+
errors[index] = error;
|
|
33
|
+
completedCount++;
|
|
34
|
+
|
|
35
|
+
// 如果所有 Promise 都失败了,抛出包含所有错误的错误
|
|
36
|
+
if (completedCount === promises.length) {
|
|
37
|
+
var errorMessage = "All promises were rejected. Errors: ".concat(errors.map(function (e) {
|
|
38
|
+
return e.message;
|
|
39
|
+
}).join(', '));
|
|
40
|
+
var combinedError = new Error(errorMessage);
|
|
41
|
+
combinedError.errors = errors;
|
|
42
|
+
reject(combinedError);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
}));
|
|
47
|
+
case 5:
|
|
48
|
+
case "end":
|
|
49
|
+
return _context.stop();
|
|
50
|
+
}
|
|
51
|
+
}, _callee);
|
|
52
|
+
}));
|
|
53
|
+
return function promiseAny(_x) {
|
|
54
|
+
return _ref.apply(this, arguments);
|
|
55
|
+
};
|
|
56
|
+
}();
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* 处理全局扫码
|
|
60
|
+
* @param request 请求插件
|
|
61
|
+
* @returns 处理结果
|
|
62
|
+
*/
|
|
63
|
+
export var handleGlobalScan = function handleGlobalScan(request) {
|
|
64
|
+
return /*#__PURE__*/function () {
|
|
65
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(scanResult) {
|
|
66
|
+
var _ref3, value, requestList, result;
|
|
67
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
68
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
69
|
+
case 0:
|
|
70
|
+
_ref3 = scanResult || {}, value = _ref3.value; // TODO: 本地解析识别码
|
|
71
|
+
requestList = []; // 如果value是已WL开头的,则认为是钱包识别码
|
|
72
|
+
if (value.startsWith('WL')) {
|
|
73
|
+
requestList = [searchWallet(request, value)];
|
|
74
|
+
} else {
|
|
75
|
+
requestList = [searchWalletPass(request, value), searchWallet(request, value), searchProduct(request, value)];
|
|
76
|
+
}
|
|
77
|
+
_context2.prev = 3;
|
|
78
|
+
_context2.next = 6;
|
|
79
|
+
return promiseAny(requestList);
|
|
80
|
+
case 6:
|
|
81
|
+
result = _context2.sent;
|
|
82
|
+
return _context2.abrupt("return", result);
|
|
83
|
+
case 10:
|
|
84
|
+
_context2.prev = 10;
|
|
85
|
+
_context2.t0 = _context2["catch"](3);
|
|
86
|
+
throw _context2.t0;
|
|
87
|
+
case 13:
|
|
88
|
+
case "end":
|
|
89
|
+
return _context2.stop();
|
|
90
|
+
}
|
|
91
|
+
}, _callee2, null, [[3, 10]]);
|
|
92
|
+
}));
|
|
93
|
+
return function (_x2) {
|
|
94
|
+
return _ref2.apply(this, arguments);
|
|
95
|
+
};
|
|
96
|
+
}();
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* 处理客户扫码
|
|
101
|
+
* @param request 请求插件
|
|
102
|
+
* @returns 处理结果
|
|
103
|
+
*/
|
|
104
|
+
export var handleCustomerScan = function handleCustomerScan(request) {
|
|
105
|
+
return /*#__PURE__*/function () {
|
|
106
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(scanResult) {
|
|
107
|
+
var _ref5, value, requestList, result;
|
|
108
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
109
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
110
|
+
case 0:
|
|
111
|
+
_ref5 = scanResult || {}, value = _ref5.value; // TODO: 本地解析识别码
|
|
112
|
+
requestList = []; // 如果value是已WL开头的,则认为是钱包识别码
|
|
113
|
+
if (value.startsWith('WL')) {
|
|
114
|
+
requestList = [searchWallet(request, value)];
|
|
115
|
+
} else {
|
|
116
|
+
requestList = [searchWalletPass(request, value), searchWallet(request, value)];
|
|
117
|
+
}
|
|
118
|
+
_context3.prev = 3;
|
|
119
|
+
_context3.next = 6;
|
|
120
|
+
return Promise.race(requestList);
|
|
121
|
+
case 6:
|
|
122
|
+
result = _context3.sent;
|
|
123
|
+
return _context3.abrupt("return", result);
|
|
124
|
+
case 10:
|
|
125
|
+
_context3.prev = 10;
|
|
126
|
+
_context3.t0 = _context3["catch"](3);
|
|
127
|
+
throw _context3.t0;
|
|
128
|
+
case 13:
|
|
129
|
+
case "end":
|
|
130
|
+
return _context3.stop();
|
|
131
|
+
}
|
|
132
|
+
}, _callee3, null, [[3, 10]]);
|
|
133
|
+
}));
|
|
134
|
+
return function (_x3) {
|
|
135
|
+
return _ref4.apply(this, arguments);
|
|
136
|
+
};
|
|
137
|
+
}();
|
|
138
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { WatchEventItem } from '../../../../utils/watch';
|
|
2
|
+
import { BookingTicketImpl } from '../../index';
|
|
3
|
+
import Tasks from '../../../../utils/task';
|
|
4
|
+
interface ScanResult {
|
|
5
|
+
type: string;
|
|
6
|
+
value: string;
|
|
7
|
+
}
|
|
8
|
+
export declare class Scan {
|
|
9
|
+
private solution;
|
|
10
|
+
private watchKey;
|
|
11
|
+
private listenerConfig;
|
|
12
|
+
constructor(solution: BookingTicketImpl, watchKey: string);
|
|
13
|
+
/**
|
|
14
|
+
* 添加扫码信息监听
|
|
15
|
+
* @param watchKey 监听的key
|
|
16
|
+
* @param event 事件
|
|
17
|
+
*/
|
|
18
|
+
addListener(event: WatchEventItem, callback?: (result: ScanResult) => Promise<any>): {
|
|
19
|
+
remove: () => void;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* 移除扫码信息监听
|
|
23
|
+
* @param watchKey 监听的key
|
|
24
|
+
* @param event 事件
|
|
25
|
+
*/
|
|
26
|
+
removeListener(event: WatchEventItem): void;
|
|
27
|
+
/**
|
|
28
|
+
* 处理扫码事件
|
|
29
|
+
* @param eventKey 事件key
|
|
30
|
+
* @param value 扫码结果
|
|
31
|
+
*/
|
|
32
|
+
handleScan(value: {
|
|
33
|
+
type: string;
|
|
34
|
+
value: string;
|
|
35
|
+
}): void;
|
|
36
|
+
/**
|
|
37
|
+
* 获取监听配置
|
|
38
|
+
* @param eventKey 事件key
|
|
39
|
+
* @returns 监听配置
|
|
40
|
+
*/
|
|
41
|
+
getListenerConfig(eventKey: string): {
|
|
42
|
+
callback?: ((result: ScanResult) => Promise<any>) | undefined;
|
|
43
|
+
task: Tasks;
|
|
44
|
+
} | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* 处理扫码结果
|
|
47
|
+
* @param args 参数
|
|
48
|
+
*/
|
|
49
|
+
handleScanResultFn(...args: any[]): Promise<void>;
|
|
50
|
+
}
|
|
51
|
+
export {};
|
|
@@ -0,0 +1,189 @@
|
|
|
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
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
6
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
7
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
8
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
9
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
10
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
11
|
+
import watch from "../../../../utils/watch";
|
|
12
|
+
import Tasks from "../../../../utils/task";
|
|
13
|
+
export var Scan = /*#__PURE__*/function () {
|
|
14
|
+
function Scan(solution, watchKey) {
|
|
15
|
+
var _solution$window,
|
|
16
|
+
_this$solution,
|
|
17
|
+
_this$solution$mountF,
|
|
18
|
+
_this = this;
|
|
19
|
+
_classCallCheck(this, Scan);
|
|
20
|
+
_defineProperty(this, "solution", void 0);
|
|
21
|
+
_defineProperty(this, "watchKey", void 0);
|
|
22
|
+
_defineProperty(this, "listenerConfig", new Map());
|
|
23
|
+
this.solution = solution;
|
|
24
|
+
this.watchKey = watchKey;
|
|
25
|
+
console.log('this.solution?.window?.interaction', solution === null || solution === void 0 || (_solution$window = solution.window) === null || _solution$window === void 0 ? void 0 : _solution$window.interaction);
|
|
26
|
+
// 监听扫码结果
|
|
27
|
+
(_this$solution = this.solution) === null || _this$solution === void 0 || (_this$solution = _this$solution.window) === null || _this$solution === void 0 || (_this$solution = _this$solution.interaction) === null || _this$solution === void 0 || (_this$solution = _this$solution.utils) === null || _this$solution === void 0 || (_this$solution$mountF = _this$solution.mountFunction) === null || _this$solution$mountF === void 0 || _this$solution$mountF.call(_this$solution, 'global', 'nativeScannerResult', function (strVal) {
|
|
28
|
+
try {
|
|
29
|
+
var _result = JSON.parse(strVal);
|
|
30
|
+
console.log('nativeScannerResult>>>>>>>', _result);
|
|
31
|
+
_this.handleScan(_result);
|
|
32
|
+
} catch (err) {
|
|
33
|
+
console.error(err);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* 添加扫码信息监听
|
|
40
|
+
* @param watchKey 监听的key
|
|
41
|
+
* @param event 事件
|
|
42
|
+
*/
|
|
43
|
+
_createClass(Scan, [{
|
|
44
|
+
key: "addListener",
|
|
45
|
+
value: function addListener(event, callback) {
|
|
46
|
+
var _this2 = this;
|
|
47
|
+
// 订阅事件
|
|
48
|
+
watch.subscribe(this.watchKey, event);
|
|
49
|
+
// 创建任务
|
|
50
|
+
var task = new Tasks();
|
|
51
|
+
task.addAction(event.key, function () {
|
|
52
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
53
|
+
args[_key] = arguments[_key];
|
|
54
|
+
}
|
|
55
|
+
return _this2.handleScanResultFn.apply(_this2, [event.key].concat(args));
|
|
56
|
+
});
|
|
57
|
+
// 创建监听配置
|
|
58
|
+
this.listenerConfig.set(event.key, {
|
|
59
|
+
callback: callback,
|
|
60
|
+
task: task
|
|
61
|
+
});
|
|
62
|
+
return {
|
|
63
|
+
remove: function remove() {
|
|
64
|
+
_this2.removeListener(event);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* 移除扫码信息监听
|
|
71
|
+
* @param watchKey 监听的key
|
|
72
|
+
* @param event 事件
|
|
73
|
+
*/
|
|
74
|
+
}, {
|
|
75
|
+
key: "removeListener",
|
|
76
|
+
value: function removeListener(event) {
|
|
77
|
+
var _this$listenerConfig$;
|
|
78
|
+
watch.unsubscribe(this.watchKey, event);
|
|
79
|
+
(_this$listenerConfig$ = this.listenerConfig.get(event.key)) === null || _this$listenerConfig$ === void 0 || _this$listenerConfig$.task.clear();
|
|
80
|
+
this.listenerConfig.delete(event.key);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* 处理扫码事件
|
|
85
|
+
* @param eventKey 事件key
|
|
86
|
+
* @param value 扫码结果
|
|
87
|
+
*/
|
|
88
|
+
}, {
|
|
89
|
+
key: "handleScan",
|
|
90
|
+
value: function handleScan(value) {
|
|
91
|
+
var lastEnableEventKey = watch.getLastEnableEventKey(this.watchKey);
|
|
92
|
+
if (lastEnableEventKey) {
|
|
93
|
+
var listenerConfig = this.listenerConfig.get(lastEnableEventKey);
|
|
94
|
+
if (listenerConfig) {
|
|
95
|
+
listenerConfig.task.addTask({
|
|
96
|
+
type: lastEnableEventKey,
|
|
97
|
+
actionParams: {
|
|
98
|
+
scanResult: value
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* 获取监听配置
|
|
107
|
+
* @param eventKey 事件key
|
|
108
|
+
* @returns 监听配置
|
|
109
|
+
*/
|
|
110
|
+
}, {
|
|
111
|
+
key: "getListenerConfig",
|
|
112
|
+
value: function getListenerConfig(eventKey) {
|
|
113
|
+
var _this$listenerConfig;
|
|
114
|
+
return (_this$listenerConfig = this.listenerConfig) === null || _this$listenerConfig === void 0 ? void 0 : _this$listenerConfig.get(eventKey);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* 处理扫码结果
|
|
119
|
+
* @param args 参数
|
|
120
|
+
*/
|
|
121
|
+
}, {
|
|
122
|
+
key: "handleScanResultFn",
|
|
123
|
+
value: (function () {
|
|
124
|
+
var _handleScanResultFn = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
125
|
+
var _this$getListenerConf;
|
|
126
|
+
var _len2,
|
|
127
|
+
args,
|
|
128
|
+
_key2,
|
|
129
|
+
eventKey,
|
|
130
|
+
other,
|
|
131
|
+
_ref,
|
|
132
|
+
type,
|
|
133
|
+
value,
|
|
134
|
+
listenerCallback,
|
|
135
|
+
_result2,
|
|
136
|
+
_args = arguments;
|
|
137
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
138
|
+
while (1) switch (_context.prev = _context.next) {
|
|
139
|
+
case 0:
|
|
140
|
+
for (_len2 = _args.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
141
|
+
args[_key2] = _args[_key2];
|
|
142
|
+
}
|
|
143
|
+
eventKey = args[0], other = args[1];
|
|
144
|
+
_ref = (other === null || other === void 0 ? void 0 : other.scanResult) || {}, type = _ref.type, value = _ref.value;
|
|
145
|
+
listenerCallback = (_this$getListenerConf = this.getListenerConfig(eventKey)) === null || _this$getListenerConf === void 0 ? void 0 : _this$getListenerConf.callback;
|
|
146
|
+
if (!listenerCallback) {
|
|
147
|
+
_context.next = 15;
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
150
|
+
_context.prev = 5;
|
|
151
|
+
_context.next = 8;
|
|
152
|
+
return listenerCallback({
|
|
153
|
+
type: type,
|
|
154
|
+
value: value
|
|
155
|
+
});
|
|
156
|
+
case 8:
|
|
157
|
+
_result2 = _context.sent;
|
|
158
|
+
watch.publishByEventKey(this.watchKey, eventKey, {
|
|
159
|
+
type: eventKey,
|
|
160
|
+
status: 'success',
|
|
161
|
+
scanType: type,
|
|
162
|
+
scanCode: value,
|
|
163
|
+
result: _result2
|
|
164
|
+
});
|
|
165
|
+
_context.next = 15;
|
|
166
|
+
break;
|
|
167
|
+
case 12:
|
|
168
|
+
_context.prev = 12;
|
|
169
|
+
_context.t0 = _context["catch"](5);
|
|
170
|
+
watch.publishByEventKey(this.watchKey, eventKey, {
|
|
171
|
+
type: eventKey,
|
|
172
|
+
status: 'failed',
|
|
173
|
+
scanType: type,
|
|
174
|
+
scanCode: value
|
|
175
|
+
});
|
|
176
|
+
case 15:
|
|
177
|
+
case "end":
|
|
178
|
+
return _context.stop();
|
|
179
|
+
}
|
|
180
|
+
}, _callee, this, [[5, 12]]);
|
|
181
|
+
}));
|
|
182
|
+
function handleScanResultFn() {
|
|
183
|
+
return _handleScanResultFn.apply(this, arguments);
|
|
184
|
+
}
|
|
185
|
+
return handleScanResultFn;
|
|
186
|
+
}())
|
|
187
|
+
}]);
|
|
188
|
+
return Scan;
|
|
189
|
+
}();
|
|
@@ -29,6 +29,7 @@ import { ShopDiscountHooks } from "./types";
|
|
|
29
29
|
import { DiscountModule } from "../../modules/Discount";
|
|
30
30
|
import { RulesModule } from "../../modules/Rules";
|
|
31
31
|
import Decimal from 'decimal.js';
|
|
32
|
+
import { isBoolean } from 'lodash-es';
|
|
32
33
|
export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
33
34
|
_inherits(ShopDiscountImpl, _BaseModule);
|
|
34
35
|
var _super = _createSuper(ShopDiscountImpl);
|
|
@@ -495,8 +496,9 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
495
496
|
return n.id === id;
|
|
496
497
|
});
|
|
497
498
|
var product = (_this3$hooks2 = _this3.hooks) === null || _this3$hooks2 === void 0 ? void 0 : _this3$hooks2.getProduct(targetProduct);
|
|
498
|
-
// 如果 product.total
|
|
499
|
-
|
|
499
|
+
// 如果 product.total 是小于等于0有可能是她已经用过商品券或者折扣卡导致的,或者本身就是负数价格,所以此时还需要判断 origin_total 是否小于等于0
|
|
500
|
+
// 如果 product.vouchersApplicable是布尔值,并且是 false,也当做免费商品处理,此商品不可用优惠券或折扣卡
|
|
501
|
+
return Number(product === null || product === void 0 ? void 0 : product.total) <= 0 && (Number(product === null || product === void 0 ? void 0 : product.origin_total) <= 0 || !(product !== null && product !== void 0 && product.origin_total)) || isBoolean(product === null || product === void 0 ? void 0 : product.vouchersApplicable) && !(product !== null && product !== void 0 && product.vouchersApplicable);
|
|
500
502
|
};
|
|
501
503
|
var allUsedProductIds = newDiscountList.map(function (n) {
|
|
502
504
|
var _n$appliedProductDeta;
|
package/dist/solution/index.d.ts
CHANGED
package/dist/solution/index.js
CHANGED
package/dist/types/index.d.ts
CHANGED
|
@@ -38,7 +38,9 @@ export interface PisellCore {
|
|
|
38
38
|
getModuleExports: <T = any>(name: string) => T | null;
|
|
39
39
|
hasModule: (name: string) => boolean;
|
|
40
40
|
effects: {
|
|
41
|
-
on: (event: string, callback: (payload: any) => void) => void;
|
|
41
|
+
on: (event: string, callback: (payload: any) => void) => () => void;
|
|
42
|
+
once: (event: string, callback: (payload: any) => void) => () => void;
|
|
43
|
+
off: (event: string, callback: (payload: any) => void) => void;
|
|
42
44
|
emit: (event: string, payload: any, value?: any) => Promise<{
|
|
43
45
|
status: boolean;
|
|
44
46
|
data: any;
|