@pisell/pisellos 0.10.95 → 0.10.97
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/modules/OpenData/index.d.ts +3 -0
- package/dist/modules/OpenData/index.js +160 -84
- package/dist/modules/Order/index.d.ts +1 -1
- package/dist/server/index.d.ts +3 -0
- package/dist/server/index.js +857 -598
- package/dist/server/modules/order/index.d.ts +1 -0
- package/dist/server/modules/order/index.js +51 -51
- package/dist/solution/BookingByStep/index.d.ts +2 -2
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/BookingTicket/utils/redeemArrival.d.ts +16 -16
- package/dist/solution/Sales/index.d.ts +2 -1
- package/dist/solution/Sales/index.js +123 -49
- package/dist/solution/Sales/types.d.ts +6 -0
- package/dist/solution/Sales/types.js +2 -0
- package/lib/model/strategy/adapter/promotion/index.js +46 -1
- package/lib/modules/OpenData/index.d.ts +3 -0
- package/lib/modules/OpenData/index.js +51 -18
- package/lib/modules/Order/index.d.ts +1 -1
- package/lib/server/index.d.ts +3 -0
- package/lib/server/index.js +155 -18
- package/lib/server/modules/order/index.d.ts +1 -0
- package/lib/server/modules/order/index.js +4 -3
- package/lib/solution/BookingByStep/index.d.ts +2 -2
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/BookingTicket/utils/redeemArrival.d.ts +16 -16
- package/lib/solution/Sales/index.d.ts +2 -1
- package/lib/solution/Sales/index.js +28 -1
- package/lib/solution/Sales/types.d.ts +6 -0
- package/lib/solution/Sales/types.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// 导出评估器
|
|
2
|
+
export { PromotionEvaluator } from "./evaluator";
|
|
3
|
+
|
|
4
|
+
// 导出适配器
|
|
5
|
+
export { PromotionAdapter } from "./adapter";
|
|
6
|
+
export { default } from "./adapter";
|
|
7
|
+
|
|
8
|
+
// 导出策略配置示例常量
|
|
9
|
+
export { X_ITEMS_FOR_Y_PRICE_STRATEGY, BUY_X_GET_Y_FREE_STRATEGY, ITEM_REWARD_STRATEGY } from "./examples";
|
|
@@ -32,6 +32,9 @@ export declare class OpenDataModule extends BaseModule implements Module {
|
|
|
32
32
|
updateOtherParams(params: Record<string, any>): void;
|
|
33
33
|
private shouldSkipInvoiceTemplateDocument;
|
|
34
34
|
fetchOpenData(params: OpenDataFetchParams): Promise<OpenDataConfig>;
|
|
35
|
+
private requestOpenData;
|
|
36
|
+
/** Cloud orders must resolve their own channel's template before printing. */
|
|
37
|
+
loadCloudInvoiceTemplate(target: string): Promise<InvoiceTemplateSettings>;
|
|
35
38
|
getOpenData(): OpenDataConfig | null;
|
|
36
39
|
getInvoiceLayoutConfig(): InvoiceLayoutConfig;
|
|
37
40
|
getInvoiceTemplateSettings(): InvoiceTemplateSettings;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
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; }
|
|
2
|
+
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; }
|
|
1
3
|
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; }
|
|
2
4
|
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); } }
|
|
3
5
|
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); }); }; }
|
|
@@ -141,46 +143,25 @@ export var OpenDataModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
141
143
|
key: "fetchOpenData",
|
|
142
144
|
value: function () {
|
|
143
145
|
var _fetchOpenData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params) {
|
|
144
|
-
var
|
|
145
|
-
var fetchRevision, getData, shopId, tenantId, headers, response, data, resolvedInvoiceTemplate;
|
|
146
|
+
var fetchRevision, response, data, resolvedInvoiceTemplate;
|
|
146
147
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
147
148
|
while (1) switch (_context2.prev = _context2.next) {
|
|
148
149
|
case 0:
|
|
149
150
|
fetchRevision = ++this.fetchRevision;
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
_context2.next = 5;
|
|
154
|
-
break;
|
|
155
|
-
}
|
|
156
|
-
throw new Error('[OpenDataModule] 无法获取 shop_id');
|
|
157
|
-
case 5:
|
|
158
|
-
tenantId = getData === null || getData === void 0 ? void 0 : getData('tenant_id');
|
|
159
|
-
headers = {};
|
|
160
|
-
if (tenantId) headers['Tenant-Id'] = String(tenantId);
|
|
161
|
-
_context2.next = 10;
|
|
162
|
-
return this.request.post("/open/my-pisell/".concat(shopId, "/setting"), {
|
|
163
|
-
scope: params.scope,
|
|
164
|
-
target: params.target,
|
|
165
|
-
section_code: params.section_code
|
|
166
|
-
}, {
|
|
167
|
-
pisell2: true,
|
|
168
|
-
isPisell2: true,
|
|
169
|
-
prefix: false,
|
|
170
|
-
headers: headers
|
|
171
|
-
});
|
|
172
|
-
case 10:
|
|
151
|
+
_context2.next = 3;
|
|
152
|
+
return this.requestOpenData(params);
|
|
153
|
+
case 3:
|
|
173
154
|
response = _context2.sent;
|
|
174
155
|
if (!((response === null || response === void 0 ? void 0 : response.status) === false)) {
|
|
175
|
-
_context2.next =
|
|
156
|
+
_context2.next = 6;
|
|
176
157
|
break;
|
|
177
158
|
}
|
|
178
159
|
throw new Error((response === null || response === void 0 ? void 0 : response.message) || '获取 OpenData 配置失败');
|
|
179
|
-
case
|
|
160
|
+
case 6:
|
|
180
161
|
data = (response === null || response === void 0 ? void 0 : response.data) || {};
|
|
181
|
-
_context2.next =
|
|
162
|
+
_context2.next = 9;
|
|
182
163
|
return this.resolveInvoiceTemplateSettings(data, params.target);
|
|
183
|
-
case
|
|
164
|
+
case 9:
|
|
184
165
|
resolvedInvoiceTemplate = _context2.sent;
|
|
185
166
|
// clearCache() 或后续请求发生后,旧响应不得复活已失效的 target 配置。
|
|
186
167
|
if (fetchRevision === this.fetchRevision) {
|
|
@@ -189,7 +170,7 @@ export var OpenDataModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
189
170
|
this.commitInvoiceTemplateSettings(params.target, resolvedInvoiceTemplate);
|
|
190
171
|
}
|
|
191
172
|
return _context2.abrupt("return", data);
|
|
192
|
-
case
|
|
173
|
+
case 12:
|
|
193
174
|
case "end":
|
|
194
175
|
return _context2.stop();
|
|
195
176
|
}
|
|
@@ -200,6 +181,88 @@ export var OpenDataModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
200
181
|
}
|
|
201
182
|
return fetchOpenData;
|
|
202
183
|
}()
|
|
184
|
+
}, {
|
|
185
|
+
key: "requestOpenData",
|
|
186
|
+
value: function requestOpenData(params) {
|
|
187
|
+
var _this$appPlugin, _this$appPlugin$getDa;
|
|
188
|
+
var background = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
189
|
+
var getData = (_this$appPlugin = this.appPlugin) === null || _this$appPlugin === void 0 || (_this$appPlugin$getDa = _this$appPlugin.getData) === null || _this$appPlugin$getDa === void 0 ? void 0 : _this$appPlugin$getDa.call(_this$appPlugin);
|
|
190
|
+
var shopId = getData === null || getData === void 0 ? void 0 : getData('shop_id');
|
|
191
|
+
var tenantId = getData === null || getData === void 0 ? void 0 : getData('tenant_id');
|
|
192
|
+
if (!shopId) throw new Error('[OpenDataModule] 无法获取 shop_id');
|
|
193
|
+
return this.request.post("/open/my-pisell/".concat(encodeURIComponent(String(shopId)), "/setting"), {
|
|
194
|
+
scope: params.scope,
|
|
195
|
+
target: params.target,
|
|
196
|
+
section_code: params.section_code
|
|
197
|
+
}, _objectSpread({
|
|
198
|
+
pisell2: true,
|
|
199
|
+
isPisell2: true,
|
|
200
|
+
prefix: false,
|
|
201
|
+
headers: tenantId ? {
|
|
202
|
+
'Tenant-Id': String(tenantId)
|
|
203
|
+
} : {}
|
|
204
|
+
}, background ? {
|
|
205
|
+
customToast: function customToast() {},
|
|
206
|
+
manualErrorHandling: true,
|
|
207
|
+
skipErrorHandler: true
|
|
208
|
+
} : {}));
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/** Cloud orders must resolve their own channel's template before printing. */
|
|
212
|
+
}, {
|
|
213
|
+
key: "loadCloudInvoiceTemplate",
|
|
214
|
+
value: (function () {
|
|
215
|
+
var _loadCloudInvoiceTemplate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(target) {
|
|
216
|
+
var response, raw, documentId;
|
|
217
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
218
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
219
|
+
case 0:
|
|
220
|
+
_context3.next = 2;
|
|
221
|
+
return this.requestOpenData({
|
|
222
|
+
scope: 'board',
|
|
223
|
+
target: target,
|
|
224
|
+
section_code: ['documents']
|
|
225
|
+
}, true);
|
|
226
|
+
case 2:
|
|
227
|
+
response = _context3.sent;
|
|
228
|
+
if (!((response === null || response === void 0 ? void 0 : response.status) !== true || response.code !== 200 || !isRecord(response.data))) {
|
|
229
|
+
_context3.next = 5;
|
|
230
|
+
break;
|
|
231
|
+
}
|
|
232
|
+
throw new Error((response === null || response === void 0 ? void 0 : response.message) || 'Cloud Invoice settings unavailable');
|
|
233
|
+
case 5:
|
|
234
|
+
raw = response.data['documents.invoice_template'];
|
|
235
|
+
documentId = resolveInvoiceDocumentId(raw);
|
|
236
|
+
if (!documentId) {
|
|
237
|
+
_context3.next = 9;
|
|
238
|
+
break;
|
|
239
|
+
}
|
|
240
|
+
return _context3.abrupt("return", this.fetchInvoiceTemplateDocument(documentId, true));
|
|
241
|
+
case 9:
|
|
242
|
+
if (!(raw == null || typeof raw === 'string' && !raw.trim())) {
|
|
243
|
+
_context3.next = 11;
|
|
244
|
+
break;
|
|
245
|
+
}
|
|
246
|
+
return _context3.abrupt("return", getDefaultInvoiceTemplateSettings());
|
|
247
|
+
case 11:
|
|
248
|
+
if (!isLegacyInvoiceTemplate(raw)) {
|
|
249
|
+
_context3.next = 13;
|
|
250
|
+
break;
|
|
251
|
+
}
|
|
252
|
+
return _context3.abrupt("return", normalizeInvoiceTemplateSettings(response.data));
|
|
253
|
+
case 13:
|
|
254
|
+
throw new Error('Cloud Invoice template identifier is invalid');
|
|
255
|
+
case 14:
|
|
256
|
+
case "end":
|
|
257
|
+
return _context3.stop();
|
|
258
|
+
}
|
|
259
|
+
}, _callee3, this);
|
|
260
|
+
}));
|
|
261
|
+
function loadCloudInvoiceTemplate(_x4) {
|
|
262
|
+
return _loadCloudInvoiceTemplate.apply(this, arguments);
|
|
263
|
+
}
|
|
264
|
+
return loadCloudInvoiceTemplate;
|
|
265
|
+
}())
|
|
203
266
|
}, {
|
|
204
267
|
key: "getOpenData",
|
|
205
268
|
value: function getOpenData() {
|
|
@@ -236,10 +299,10 @@ export var OpenDataModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
236
299
|
}, {
|
|
237
300
|
key: "ensureInvoiceTemplateSettings",
|
|
238
301
|
value: function () {
|
|
239
|
-
var _ensureInvoiceTemplateSettings = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
302
|
+
var _ensureInvoiceTemplateSettings = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(target, openDataConfig) {
|
|
240
303
|
var normalizedTarget, config, fetchRevision, resolved;
|
|
241
|
-
return _regeneratorRuntime().wrap(function
|
|
242
|
-
while (1) switch (
|
|
304
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
305
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
243
306
|
case 0:
|
|
244
307
|
normalizedTarget = String(target || '').trim();
|
|
245
308
|
if (openDataConfig && openDataConfig !== this.store.data) {
|
|
@@ -252,31 +315,31 @@ export var OpenDataModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
252
315
|
}
|
|
253
316
|
config = this.store.data;
|
|
254
317
|
if (!(!normalizedTarget || !config)) {
|
|
255
|
-
|
|
318
|
+
_context4.next = 5;
|
|
256
319
|
break;
|
|
257
320
|
}
|
|
258
|
-
return
|
|
321
|
+
return _context4.abrupt("return", getDefaultInvoiceTemplateSettings());
|
|
259
322
|
case 5:
|
|
260
323
|
fetchRevision = this.fetchRevision;
|
|
261
|
-
|
|
324
|
+
_context4.next = 8;
|
|
262
325
|
return this.resolveInvoiceTemplateSettings(config, normalizedTarget);
|
|
263
326
|
case 8:
|
|
264
|
-
resolved =
|
|
327
|
+
resolved = _context4.sent;
|
|
265
328
|
if (!(fetchRevision !== this.fetchRevision || this.store.data !== config)) {
|
|
266
|
-
|
|
329
|
+
_context4.next = 11;
|
|
267
330
|
break;
|
|
268
331
|
}
|
|
269
|
-
return
|
|
332
|
+
return _context4.abrupt("return", getDefaultInvoiceTemplateSettings());
|
|
270
333
|
case 11:
|
|
271
334
|
this.commitInvoiceTemplateSettings(normalizedTarget, resolved);
|
|
272
|
-
return
|
|
335
|
+
return _context4.abrupt("return", normalizeRawInvoiceTemplateSettings(resolved.settings));
|
|
273
336
|
case 13:
|
|
274
337
|
case "end":
|
|
275
|
-
return
|
|
338
|
+
return _context4.stop();
|
|
276
339
|
}
|
|
277
|
-
},
|
|
340
|
+
}, _callee4, this);
|
|
278
341
|
}));
|
|
279
|
-
function ensureInvoiceTemplateSettings(
|
|
342
|
+
function ensureInvoiceTemplateSettings(_x5, _x6) {
|
|
280
343
|
return _ensureInvoiceTemplateSettings.apply(this, arguments);
|
|
281
344
|
}
|
|
282
345
|
return ensureInvoiceTemplateSettings;
|
|
@@ -292,17 +355,17 @@ export var OpenDataModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
292
355
|
}, {
|
|
293
356
|
key: "resolveInvoiceTemplateSettings",
|
|
294
357
|
value: function () {
|
|
295
|
-
var _resolveInvoiceTemplateSettings = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
358
|
+
var _resolveInvoiceTemplateSettings = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(config, target) {
|
|
296
359
|
var _this2 = this;
|
|
297
360
|
var rawTemplate, documentId, cacheKey, cachedSettings, request, cacheRevision;
|
|
298
|
-
return _regeneratorRuntime().wrap(function
|
|
299
|
-
while (1) switch (
|
|
361
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
362
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
300
363
|
case 0:
|
|
301
364
|
if (!this.shouldSkipInvoiceTemplateDocument()) {
|
|
302
|
-
|
|
365
|
+
_context5.next = 2;
|
|
303
366
|
break;
|
|
304
367
|
}
|
|
305
|
-
return
|
|
368
|
+
return _context5.abrupt("return", {
|
|
306
369
|
settings: getDefaultInvoiceTemplateSettings(),
|
|
307
370
|
documentId: null,
|
|
308
371
|
cacheKey: null
|
|
@@ -311,10 +374,10 @@ export var OpenDataModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
311
374
|
rawTemplate = config['documents.invoice_template'];
|
|
312
375
|
documentId = resolveInvoiceDocumentId(rawTemplate);
|
|
313
376
|
if (documentId) {
|
|
314
|
-
|
|
377
|
+
_context5.next = 6;
|
|
315
378
|
break;
|
|
316
379
|
}
|
|
317
|
-
return
|
|
380
|
+
return _context5.abrupt("return", {
|
|
318
381
|
settings: isLegacyInvoiceTemplate(rawTemplate) ? normalizeInvoiceTemplateSettings(config) : getDefaultInvoiceTemplateSettings(),
|
|
319
382
|
documentId: null,
|
|
320
383
|
cacheKey: null
|
|
@@ -322,10 +385,10 @@ export var OpenDataModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
322
385
|
case 6:
|
|
323
386
|
cacheKey = this.buildInvoiceTemplateCacheKey(target, documentId);
|
|
324
387
|
if (!(this.store.invoiceTemplateTarget === target && this.store.invoiceTemplateDocumentId === documentId && this.store.invoiceTemplateCacheKey === cacheKey && isRecord(this.store.invoiceTemplateSettings))) {
|
|
325
|
-
|
|
388
|
+
_context5.next = 9;
|
|
326
389
|
break;
|
|
327
390
|
}
|
|
328
|
-
return
|
|
391
|
+
return _context5.abrupt("return", {
|
|
329
392
|
settings: normalizeRawInvoiceTemplateSettings(this.store.invoiceTemplateSettings),
|
|
330
393
|
documentId: documentId,
|
|
331
394
|
cacheKey: cacheKey
|
|
@@ -333,10 +396,10 @@ export var OpenDataModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
333
396
|
case 9:
|
|
334
397
|
cachedSettings = this.invoiceTemplateDocumentCache.get(cacheKey);
|
|
335
398
|
if (!cachedSettings) {
|
|
336
|
-
|
|
399
|
+
_context5.next = 12;
|
|
337
400
|
break;
|
|
338
401
|
}
|
|
339
|
-
return
|
|
402
|
+
return _context5.abrupt("return", {
|
|
340
403
|
settings: normalizeRawInvoiceTemplateSettings(cachedSettings),
|
|
341
404
|
documentId: documentId,
|
|
342
405
|
cacheKey: cacheKey
|
|
@@ -361,24 +424,24 @@ export var OpenDataModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
361
424
|
});
|
|
362
425
|
this.invoiceTemplateDocumentInFlight.set(cacheKey, request);
|
|
363
426
|
}
|
|
364
|
-
|
|
427
|
+
_context5.next = 16;
|
|
365
428
|
return request;
|
|
366
429
|
case 16:
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
return
|
|
371
|
-
settings:
|
|
372
|
-
documentId:
|
|
373
|
-
cacheKey:
|
|
430
|
+
_context5.t0 = _context5.sent;
|
|
431
|
+
_context5.t1 = documentId;
|
|
432
|
+
_context5.t2 = cacheKey;
|
|
433
|
+
return _context5.abrupt("return", {
|
|
434
|
+
settings: _context5.t0,
|
|
435
|
+
documentId: _context5.t1,
|
|
436
|
+
cacheKey: _context5.t2
|
|
374
437
|
});
|
|
375
438
|
case 20:
|
|
376
439
|
case "end":
|
|
377
|
-
return
|
|
440
|
+
return _context5.stop();
|
|
378
441
|
}
|
|
379
|
-
},
|
|
442
|
+
}, _callee5, this);
|
|
380
443
|
}));
|
|
381
|
-
function resolveInvoiceTemplateSettings(
|
|
444
|
+
function resolveInvoiceTemplateSettings(_x7, _x8) {
|
|
382
445
|
return _resolveInvoiceTemplateSettings.apply(this, arguments);
|
|
383
446
|
}
|
|
384
447
|
return resolveInvoiceTemplateSettings;
|
|
@@ -393,49 +456,62 @@ export var OpenDataModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
393
456
|
}, {
|
|
394
457
|
key: "fetchInvoiceTemplateDocument",
|
|
395
458
|
value: function () {
|
|
396
|
-
var _fetchInvoiceTemplateDocument = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
397
|
-
var
|
|
398
|
-
|
|
399
|
-
|
|
459
|
+
var _fetchInvoiceTemplateDocument = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(documentId) {
|
|
460
|
+
var strict,
|
|
461
|
+
response,
|
|
462
|
+
document,
|
|
463
|
+
_args6 = arguments;
|
|
464
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
465
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
400
466
|
case 0:
|
|
401
|
-
|
|
402
|
-
|
|
467
|
+
strict = _args6.length > 1 && _args6[1] !== undefined ? _args6[1] : false;
|
|
468
|
+
_context6.next = 3;
|
|
469
|
+
return this.request.get("/document:get?filterByTk=".concat(encodeURIComponent(documentId)), {}, _objectSpread({
|
|
403
470
|
isNocobase: true,
|
|
404
471
|
prefix: false,
|
|
405
472
|
headers: {
|
|
406
473
|
'x-data-source': 'pisell2'
|
|
407
474
|
},
|
|
408
475
|
customToast: function customToast() {}
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
|
|
476
|
+
}, strict ? {
|
|
477
|
+
manualErrorHandling: true,
|
|
478
|
+
skipErrorHandler: true
|
|
479
|
+
} : {}));
|
|
480
|
+
case 3:
|
|
481
|
+
response = _context6.sent;
|
|
412
482
|
document = response === null || response === void 0 ? void 0 : response.data;
|
|
413
483
|
if (!(!document || resolveInvoiceDocumentId(document.id) !== documentId)) {
|
|
414
|
-
|
|
484
|
+
_context6.next = 7;
|
|
415
485
|
break;
|
|
416
486
|
}
|
|
417
487
|
throw new Error("Invoice Document ".concat(documentId, " \u8FD4\u56DE\u7684 ID \u4E0D\u5339\u914D"));
|
|
418
|
-
case
|
|
488
|
+
case 7:
|
|
419
489
|
if (!(document.deleted_at !== null && document.deleted_at !== undefined)) {
|
|
420
|
-
|
|
490
|
+
_context6.next = 9;
|
|
421
491
|
break;
|
|
422
492
|
}
|
|
423
493
|
throw new Error("Invoice Document ".concat(documentId, " \u5DF2\u88AB\u5220\u9664"));
|
|
424
|
-
case
|
|
494
|
+
case 9:
|
|
425
495
|
if (!(!isRecord(document.data) || !isRecord(document.data.template_settings))) {
|
|
426
|
-
|
|
496
|
+
_context6.next = 11;
|
|
427
497
|
break;
|
|
428
498
|
}
|
|
429
499
|
throw new Error("Invoice Document ".concat(documentId, " \u7F3A\u5C11 template_settings"));
|
|
430
|
-
case 10:
|
|
431
|
-
return _context5.abrupt("return", normalizeRawInvoiceTemplateSettings(document.data.template_settings));
|
|
432
500
|
case 11:
|
|
501
|
+
if (!(strict && (typeof document.data.template_settings.template !== 'string' || !document.data.template_settings.template.trim()))) {
|
|
502
|
+
_context6.next = 13;
|
|
503
|
+
break;
|
|
504
|
+
}
|
|
505
|
+
throw new Error("Invoice Document ".concat(documentId, " \u7F3A\u5C11 template"));
|
|
506
|
+
case 13:
|
|
507
|
+
return _context6.abrupt("return", normalizeRawInvoiceTemplateSettings(document.data.template_settings));
|
|
508
|
+
case 14:
|
|
433
509
|
case "end":
|
|
434
|
-
return
|
|
510
|
+
return _context6.stop();
|
|
435
511
|
}
|
|
436
|
-
},
|
|
512
|
+
}, _callee6, this);
|
|
437
513
|
}));
|
|
438
|
-
function fetchInvoiceTemplateDocument(
|
|
514
|
+
function fetchInvoiceTemplateDocument(_x9) {
|
|
439
515
|
return _fetchInvoiceTemplateDocument.apply(this, arguments);
|
|
440
516
|
}
|
|
441
517
|
return fetchInvoiceTemplateDocument;
|
|
@@ -640,7 +640,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
640
640
|
generateIdempotencyToken(): string;
|
|
641
641
|
syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
|
|
642
642
|
createOrder(params: CommitOrderParams['query']): {
|
|
643
|
-
type: "
|
|
643
|
+
type: "appointment_booking" | "virtual";
|
|
644
644
|
platform: string;
|
|
645
645
|
sales_channel: string;
|
|
646
646
|
order_sales_channel: string;
|
package/dist/server/index.d.ts
CHANGED
|
@@ -547,8 +547,11 @@ declare class Server {
|
|
|
547
547
|
private shouldLookupLocalPrintOrder;
|
|
548
548
|
private getLocalPrintOrderLookup;
|
|
549
549
|
private mergeLocalPrintOrderInput;
|
|
550
|
+
private loadCloudInvoiceOrder;
|
|
551
|
+
private handleCloudOrderInvoice;
|
|
550
552
|
private handleLocalPrintOrder;
|
|
551
553
|
private normalizeRequestedReceiptLocales;
|
|
554
|
+
private rebuildOrderReceipt;
|
|
552
555
|
private handleLocalOrderReceiptSnapshot;
|
|
553
556
|
private handleMachinecodeBatchMeta;
|
|
554
557
|
private resolveMachinecodeBatchMetadataLookup;
|