@pisell/pisellos 0.10.20 → 0.10.22
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 +0 -9
- package/dist/modules/BookingContext/index.d.ts +3 -0
- package/dist/modules/BookingContext/index.js +42 -13
- package/dist/modules/BookingContext/types.d.ts +4 -4
- package/dist/modules/BookingContext/types.js +3 -3
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +10 -7
- package/dist/modules/OpenData/index.d.ts +10 -1
- package/dist/modules/OpenData/index.js +268 -14
- package/dist/modules/OpenData/types.d.ts +14 -1
- package/dist/modules/OpenData/utils.d.ts +1 -0
- package/dist/modules/OpenData/utils.js +8 -5
- package/dist/modules/Order/index.d.ts +6 -1
- package/dist/modules/Order/index.js +148 -84
- package/dist/modules/ProductList/clientDataVariants.d.ts +50 -0
- package/dist/modules/ProductList/clientDataVariants.js +216 -0
- package/dist/modules/ProductList/index.d.ts +14 -13
- package/dist/modules/ProductList/index.js +105 -77
- package/dist/modules/Quotation/index.d.ts +16 -0
- package/dist/modules/Quotation/index.js +240 -27
- package/dist/modules/ResourcePlanner/planner.d.ts +2 -2
- package/dist/modules/ResourcePlanner/planner.js +88 -21
- package/dist/modules/ResourcePlanner/types.d.ts +12 -0
- package/dist/modules/Rules/index.d.ts +5 -0
- package/dist/modules/Rules/index.js +27 -12
- package/dist/plugins/request.d.ts +2 -1
- package/dist/plugins/request.js +4 -2
- package/dist/server/index.js +33 -16
- package/dist/solution/BaseSales/index.d.ts +16 -1
- package/dist/solution/BaseSales/index.js +690 -349
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +14 -2
- package/dist/solution/BookingTicket/index.js +25 -18
- package/dist/solution/Sales/index.js +29 -22
- package/dist/solution/UnifiedBookingSales/index.d.ts +1 -1
- package/dist/solution/UnifiedBookingSales/index.js +315 -99
- package/dist/solution/UnifiedBookingSales/types.d.ts +4 -0
- package/dist/solution/VenueBooking/index.d.ts +2 -0
- package/dist/solution/VenueBooking/index.js +542 -494
- package/dist/solution/VenueBooking/utils/dateSummary.d.ts +1 -0
- package/dist/solution/VenueBooking/utils/dateSummary.js +3 -1
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +2 -0
- package/dist/solution/VenueBooking/utils/slotMerge.js +3 -1
- package/dist/utils/platform.d.ts +8 -0
- package/dist/utils/platform.js +15 -0
- package/lib/modules/BookingContext/index.d.ts +3 -0
- package/lib/modules/BookingContext/index.js +35 -8
- package/lib/modules/BookingContext/types.d.ts +4 -4
- package/lib/modules/BookingContext/types.js +3 -3
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +4 -0
- package/lib/modules/OpenData/index.d.ts +10 -1
- package/lib/modules/OpenData/index.js +162 -2
- package/lib/modules/OpenData/types.d.ts +14 -1
- package/lib/modules/OpenData/utils.d.ts +1 -0
- package/lib/modules/OpenData/utils.js +9 -5
- package/lib/modules/Order/index.d.ts +6 -1
- package/lib/modules/Order/index.js +65 -8
- package/lib/modules/ProductList/clientDataVariants.d.ts +50 -0
- package/lib/modules/ProductList/clientDataVariants.js +204 -0
- package/lib/modules/ProductList/index.d.ts +14 -13
- package/lib/modules/ProductList/index.js +77 -58
- package/lib/modules/Quotation/index.d.ts +16 -0
- package/lib/modules/Quotation/index.js +112 -9
- package/lib/modules/ResourcePlanner/planner.d.ts +2 -2
- package/lib/modules/ResourcePlanner/planner.js +80 -20
- package/lib/modules/ResourcePlanner/types.d.ts +12 -0
- package/lib/modules/Rules/index.d.ts +5 -0
- package/lib/modules/Rules/index.js +20 -11
- package/lib/plugins/request.d.ts +2 -1
- package/lib/plugins/request.js +3 -2
- package/lib/server/index.js +16 -1
- package/lib/solution/BaseSales/index.d.ts +16 -1
- package/lib/solution/BaseSales/index.js +314 -66
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +14 -2
- package/lib/solution/BookingTicket/index.js +3 -0
- package/lib/solution/Sales/index.js +3 -0
- package/lib/solution/UnifiedBookingSales/index.d.ts +1 -1
- package/lib/solution/UnifiedBookingSales/index.js +228 -20
- package/lib/solution/UnifiedBookingSales/types.d.ts +4 -0
- package/lib/solution/VenueBooking/index.d.ts +2 -0
- package/lib/solution/VenueBooking/index.js +28 -8
- package/lib/solution/VenueBooking/utils/dateSummary.d.ts +1 -0
- package/lib/solution/VenueBooking/utils/dateSummary.js +3 -1
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +2 -0
- package/lib/solution/VenueBooking/utils/slotMerge.js +3 -1
- package/lib/utils/platform.d.ts +8 -0
- package/lib/utils/platform.js +22 -0
- package/package.json +1 -1
|
@@ -1,4 +1,3 @@
|
|
|
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
1
|
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
2
|
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
3
|
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); }); }; }
|
|
@@ -15,10 +14,30 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
|
|
|
15
14
|
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; }
|
|
16
15
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
17
16
|
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); }
|
|
17
|
+
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); }
|
|
18
18
|
import { BaseModule } from "../BaseModule";
|
|
19
|
-
import { computeAvailability,
|
|
19
|
+
import { computeAvailability, getDefaultInvoiceTemplateSettings, normalizeInvoiceLayoutFromTemplateSettings, normalizeInvoiceTemplateSettings, normalizeRawInvoiceTemplateSettings } from "./utils";
|
|
20
20
|
export * from "./types";
|
|
21
|
-
export { computeAvailability, getDefaultInvoiceLayoutConfig, getDefaultInvoiceTemplateSettings, normalizeInvoiceLayoutConfig, normalizeInvoiceTemplateSettings, normalizeRawInvoiceTemplateSettings, resolveInvoiceReceiptLocales } from "./utils";
|
|
21
|
+
export { computeAvailability, getDefaultInvoiceLayoutConfig, getDefaultInvoiceTemplateSettings, normalizeInvoiceLayoutConfig, normalizeInvoiceLayoutFromTemplateSettings, normalizeInvoiceTemplateSettings, normalizeRawInvoiceTemplateSettings, resolveInvoiceReceiptLocales } from "./utils";
|
|
22
|
+
function isRecord(value) {
|
|
23
|
+
return !!value && _typeof(value) === 'object' && !Array.isArray(value);
|
|
24
|
+
}
|
|
25
|
+
function resolveInvoiceDocumentId(value) {
|
|
26
|
+
if (typeof value === 'number') {
|
|
27
|
+
return Number.isSafeInteger(value) && value > 0 ? String(value) : null;
|
|
28
|
+
}
|
|
29
|
+
if (typeof value !== 'string') return null;
|
|
30
|
+
var normalized = value.trim();
|
|
31
|
+
if (!/^\d+$/.test(normalized)) return null;
|
|
32
|
+
var numericId = Number(normalized);
|
|
33
|
+
return Number.isSafeInteger(numericId) && numericId > 0 ? String(numericId) : null;
|
|
34
|
+
}
|
|
35
|
+
function isLegacyInvoiceTemplate(value) {
|
|
36
|
+
if (typeof value !== 'string' || value.trim().length === 0) return false;
|
|
37
|
+
var normalized = value.trim();
|
|
38
|
+
var numericLike = /^[+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?$/i;
|
|
39
|
+
return !numericLike.test(normalized);
|
|
40
|
+
}
|
|
22
41
|
export var OpenDataModule = /*#__PURE__*/function (_BaseModule) {
|
|
23
42
|
_inherits(OpenDataModule, _BaseModule);
|
|
24
43
|
var _super = _createSuper(OpenDataModule);
|
|
@@ -37,6 +56,9 @@ export var OpenDataModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
37
56
|
_defineProperty(_assertThisInitialized(_this), "fatherModule", void 0);
|
|
38
57
|
_defineProperty(_assertThisInitialized(_this), "otherParams", {});
|
|
39
58
|
_defineProperty(_assertThisInitialized(_this), "fetchRevision", 0);
|
|
59
|
+
_defineProperty(_assertThisInitialized(_this), "invoiceTemplateCacheRevision", 0);
|
|
60
|
+
_defineProperty(_assertThisInitialized(_this), "invoiceTemplateDocumentCache", new Map());
|
|
61
|
+
_defineProperty(_assertThisInitialized(_this), "invoiceTemplateDocumentInFlight", new Map());
|
|
40
62
|
return _this;
|
|
41
63
|
}
|
|
42
64
|
_createClass(OpenDataModule, [{
|
|
@@ -52,6 +74,12 @@ export var OpenDataModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
52
74
|
this.store = options.store;
|
|
53
75
|
this.store.data = (_options$initialState = (_options$initialState2 = options.initialState) === null || _options$initialState2 === void 0 ? void 0 : _options$initialState2.data) !== null && _options$initialState !== void 0 ? _options$initialState : null;
|
|
54
76
|
this.store.lastFetchedAt = (_options$initialState3 = (_options$initialState4 = options.initialState) === null || _options$initialState4 === void 0 ? void 0 : _options$initialState4.lastFetchedAt) !== null && _options$initialState3 !== void 0 ? _options$initialState3 : null;
|
|
77
|
+
// Document 解析结果只在当前模块实例内复用。页面刷新后即使恢复了原始
|
|
78
|
+
// OpenData,也必须重新查询一次 NocoBase,以取得当前模板内容。
|
|
79
|
+
this.store.invoiceTemplateSettings = null;
|
|
80
|
+
this.store.invoiceTemplateTarget = null;
|
|
81
|
+
this.store.invoiceTemplateDocumentId = null;
|
|
82
|
+
this.store.invoiceTemplateCacheKey = null;
|
|
55
83
|
this.otherParams = options.otherParams || {};
|
|
56
84
|
if (this.otherParams.cacheId) {
|
|
57
85
|
this.openCache = (_this$otherParams$ope = this.otherParams.openCache) !== null && _this$otherParams$ope !== void 0 ? _this$otherParams$ope : false;
|
|
@@ -64,17 +92,17 @@ export var OpenDataModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
64
92
|
this.window = core.getPlugin('window');
|
|
65
93
|
this.appPlugin = core.getPlugin('app');
|
|
66
94
|
if (this.request) {
|
|
67
|
-
_context.next =
|
|
95
|
+
_context.next = 16;
|
|
68
96
|
break;
|
|
69
97
|
}
|
|
70
98
|
throw new Error('OpenDataModule 需要 request 插件支持');
|
|
71
|
-
case
|
|
99
|
+
case 16:
|
|
72
100
|
if (this.window) {
|
|
73
|
-
_context.next =
|
|
101
|
+
_context.next = 18;
|
|
74
102
|
break;
|
|
75
103
|
}
|
|
76
104
|
throw new Error('OpenDataModule 需要 window 插件支持');
|
|
77
|
-
case
|
|
105
|
+
case 18:
|
|
78
106
|
case "end":
|
|
79
107
|
return _context.stop();
|
|
80
108
|
}
|
|
@@ -105,7 +133,7 @@ export var OpenDataModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
105
133
|
value: function () {
|
|
106
134
|
var _fetchOpenData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params) {
|
|
107
135
|
var _this$appPlugin, _this$appPlugin$getDa;
|
|
108
|
-
var fetchRevision, getData, shopId, tenantId, headers, response, data;
|
|
136
|
+
var fetchRevision, getData, shopId, tenantId, headers, response, data, resolvedInvoiceTemplate;
|
|
109
137
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
110
138
|
while (1) switch (_context2.prev = _context2.next) {
|
|
111
139
|
case 0:
|
|
@@ -140,13 +168,19 @@ export var OpenDataModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
140
168
|
}
|
|
141
169
|
throw new Error((response === null || response === void 0 ? void 0 : response.message) || '获取 OpenData 配置失败');
|
|
142
170
|
case 13:
|
|
143
|
-
data = (response === null || response === void 0 ? void 0 : response.data) || {};
|
|
171
|
+
data = (response === null || response === void 0 ? void 0 : response.data) || {};
|
|
172
|
+
_context2.next = 16;
|
|
173
|
+
return this.resolveInvoiceTemplateSettings(data, params.target);
|
|
174
|
+
case 16:
|
|
175
|
+
resolvedInvoiceTemplate = _context2.sent;
|
|
176
|
+
// clearCache() 或后续请求发生后,旧响应不得复活已失效的 target 配置。
|
|
144
177
|
if (fetchRevision === this.fetchRevision) {
|
|
145
178
|
this.store.data = data;
|
|
146
179
|
this.store.lastFetchedAt = Date.now();
|
|
180
|
+
this.commitInvoiceTemplateSettings(params.target, resolvedInvoiceTemplate);
|
|
147
181
|
}
|
|
148
182
|
return _context2.abrupt("return", data);
|
|
149
|
-
case
|
|
183
|
+
case 19:
|
|
150
184
|
case "end":
|
|
151
185
|
return _context2.stop();
|
|
152
186
|
}
|
|
@@ -165,12 +199,225 @@ export var OpenDataModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
165
199
|
}, {
|
|
166
200
|
key: "getInvoiceLayoutConfig",
|
|
167
201
|
value: function getInvoiceLayoutConfig() {
|
|
168
|
-
return
|
|
202
|
+
return normalizeInvoiceLayoutFromTemplateSettings(this.getInvoiceTemplateSettings());
|
|
169
203
|
}
|
|
170
204
|
}, {
|
|
171
205
|
key: "getInvoiceTemplateSettings",
|
|
172
206
|
value: function getInvoiceTemplateSettings() {
|
|
173
|
-
|
|
207
|
+
var _this$store$data2;
|
|
208
|
+
if (isRecord(this.store.invoiceTemplateSettings)) {
|
|
209
|
+
var _this$store$data;
|
|
210
|
+
var documentId = resolveInvoiceDocumentId((_this$store$data = this.store.data) === null || _this$store$data === void 0 ? void 0 : _this$store$data['documents.invoice_template']);
|
|
211
|
+
if (documentId) {
|
|
212
|
+
var target = this.store.invoiceTemplateTarget;
|
|
213
|
+
if (!target || this.store.invoiceTemplateCacheKey !== this.buildInvoiceTemplateCacheKey(target, documentId)) {
|
|
214
|
+
return getDefaultInvoiceTemplateSettings();
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
return normalizeRawInvoiceTemplateSettings(this.store.invoiceTemplateSettings);
|
|
218
|
+
}
|
|
219
|
+
if (isLegacyInvoiceTemplate((_this$store$data2 = this.store.data) === null || _this$store$data2 === void 0 ? void 0 : _this$store$data2['documents.invoice_template'])) {
|
|
220
|
+
return normalizeInvoiceTemplateSettings(this.store.data);
|
|
221
|
+
}
|
|
222
|
+
return getDefaultInvoiceTemplateSettings();
|
|
223
|
+
}
|
|
224
|
+
}, {
|
|
225
|
+
key: "ensureInvoiceTemplateSettings",
|
|
226
|
+
value: function () {
|
|
227
|
+
var _ensureInvoiceTemplateSettings = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(target) {
|
|
228
|
+
var normalizedTarget, config, fetchRevision, resolved;
|
|
229
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
230
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
231
|
+
case 0:
|
|
232
|
+
normalizedTarget = String(target || '').trim();
|
|
233
|
+
config = this.store.data;
|
|
234
|
+
if (!(!normalizedTarget || !config)) {
|
|
235
|
+
_context3.next = 4;
|
|
236
|
+
break;
|
|
237
|
+
}
|
|
238
|
+
return _context3.abrupt("return", getDefaultInvoiceTemplateSettings());
|
|
239
|
+
case 4:
|
|
240
|
+
fetchRevision = this.fetchRevision;
|
|
241
|
+
_context3.next = 7;
|
|
242
|
+
return this.resolveInvoiceTemplateSettings(config, normalizedTarget);
|
|
243
|
+
case 7:
|
|
244
|
+
resolved = _context3.sent;
|
|
245
|
+
if (!(fetchRevision !== this.fetchRevision || this.store.data !== config)) {
|
|
246
|
+
_context3.next = 10;
|
|
247
|
+
break;
|
|
248
|
+
}
|
|
249
|
+
return _context3.abrupt("return", getDefaultInvoiceTemplateSettings());
|
|
250
|
+
case 10:
|
|
251
|
+
this.commitInvoiceTemplateSettings(normalizedTarget, resolved);
|
|
252
|
+
return _context3.abrupt("return", normalizeRawInvoiceTemplateSettings(resolved.settings));
|
|
253
|
+
case 12:
|
|
254
|
+
case "end":
|
|
255
|
+
return _context3.stop();
|
|
256
|
+
}
|
|
257
|
+
}, _callee3, this);
|
|
258
|
+
}));
|
|
259
|
+
function ensureInvoiceTemplateSettings(_x4) {
|
|
260
|
+
return _ensureInvoiceTemplateSettings.apply(this, arguments);
|
|
261
|
+
}
|
|
262
|
+
return ensureInvoiceTemplateSettings;
|
|
263
|
+
}()
|
|
264
|
+
}, {
|
|
265
|
+
key: "commitInvoiceTemplateSettings",
|
|
266
|
+
value: function commitInvoiceTemplateSettings(target, resolved) {
|
|
267
|
+
this.store.invoiceTemplateSettings = normalizeRawInvoiceTemplateSettings(resolved.settings);
|
|
268
|
+
this.store.invoiceTemplateTarget = target;
|
|
269
|
+
this.store.invoiceTemplateDocumentId = resolved.documentId;
|
|
270
|
+
this.store.invoiceTemplateCacheKey = resolved.cacheKey;
|
|
271
|
+
}
|
|
272
|
+
}, {
|
|
273
|
+
key: "resolveInvoiceTemplateSettings",
|
|
274
|
+
value: function () {
|
|
275
|
+
var _resolveInvoiceTemplateSettings = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(config, target) {
|
|
276
|
+
var _this2 = this;
|
|
277
|
+
var rawTemplate, documentId, cacheKey, cachedSettings, request, cacheRevision;
|
|
278
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
279
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
280
|
+
case 0:
|
|
281
|
+
rawTemplate = config['documents.invoice_template'];
|
|
282
|
+
documentId = resolveInvoiceDocumentId(rawTemplate);
|
|
283
|
+
if (documentId) {
|
|
284
|
+
_context4.next = 4;
|
|
285
|
+
break;
|
|
286
|
+
}
|
|
287
|
+
return _context4.abrupt("return", {
|
|
288
|
+
settings: isLegacyInvoiceTemplate(rawTemplate) ? normalizeInvoiceTemplateSettings(config) : getDefaultInvoiceTemplateSettings(),
|
|
289
|
+
documentId: null,
|
|
290
|
+
cacheKey: null
|
|
291
|
+
});
|
|
292
|
+
case 4:
|
|
293
|
+
cacheKey = this.buildInvoiceTemplateCacheKey(target, documentId);
|
|
294
|
+
if (!(this.store.invoiceTemplateTarget === target && this.store.invoiceTemplateDocumentId === documentId && this.store.invoiceTemplateCacheKey === cacheKey && isRecord(this.store.invoiceTemplateSettings))) {
|
|
295
|
+
_context4.next = 7;
|
|
296
|
+
break;
|
|
297
|
+
}
|
|
298
|
+
return _context4.abrupt("return", {
|
|
299
|
+
settings: normalizeRawInvoiceTemplateSettings(this.store.invoiceTemplateSettings),
|
|
300
|
+
documentId: documentId,
|
|
301
|
+
cacheKey: cacheKey
|
|
302
|
+
});
|
|
303
|
+
case 7:
|
|
304
|
+
cachedSettings = this.invoiceTemplateDocumentCache.get(cacheKey);
|
|
305
|
+
if (!cachedSettings) {
|
|
306
|
+
_context4.next = 10;
|
|
307
|
+
break;
|
|
308
|
+
}
|
|
309
|
+
return _context4.abrupt("return", {
|
|
310
|
+
settings: normalizeRawInvoiceTemplateSettings(cachedSettings),
|
|
311
|
+
documentId: documentId,
|
|
312
|
+
cacheKey: cacheKey
|
|
313
|
+
});
|
|
314
|
+
case 10:
|
|
315
|
+
request = this.invoiceTemplateDocumentInFlight.get(cacheKey);
|
|
316
|
+
if (!request) {
|
|
317
|
+
cacheRevision = this.invoiceTemplateCacheRevision;
|
|
318
|
+
request = this.fetchInvoiceTemplateDocument(documentId).catch(function (error) {
|
|
319
|
+
_this2.logInvoiceTemplateDocumentFallback(error, target, documentId);
|
|
320
|
+
return getDefaultInvoiceTemplateSettings();
|
|
321
|
+
}).then(function (settings) {
|
|
322
|
+
var normalized = normalizeRawInvoiceTemplateSettings(settings);
|
|
323
|
+
if (cacheRevision === _this2.invoiceTemplateCacheRevision) {
|
|
324
|
+
_this2.invoiceTemplateDocumentCache.set(cacheKey, normalized);
|
|
325
|
+
}
|
|
326
|
+
return normalized;
|
|
327
|
+
}).finally(function () {
|
|
328
|
+
if (_this2.invoiceTemplateDocumentInFlight.get(cacheKey) === request) {
|
|
329
|
+
_this2.invoiceTemplateDocumentInFlight.delete(cacheKey);
|
|
330
|
+
}
|
|
331
|
+
});
|
|
332
|
+
this.invoiceTemplateDocumentInFlight.set(cacheKey, request);
|
|
333
|
+
}
|
|
334
|
+
_context4.next = 14;
|
|
335
|
+
return request;
|
|
336
|
+
case 14:
|
|
337
|
+
_context4.t0 = _context4.sent;
|
|
338
|
+
_context4.t1 = documentId;
|
|
339
|
+
_context4.t2 = cacheKey;
|
|
340
|
+
return _context4.abrupt("return", {
|
|
341
|
+
settings: _context4.t0,
|
|
342
|
+
documentId: _context4.t1,
|
|
343
|
+
cacheKey: _context4.t2
|
|
344
|
+
});
|
|
345
|
+
case 18:
|
|
346
|
+
case "end":
|
|
347
|
+
return _context4.stop();
|
|
348
|
+
}
|
|
349
|
+
}, _callee4, this);
|
|
350
|
+
}));
|
|
351
|
+
function resolveInvoiceTemplateSettings(_x5, _x6) {
|
|
352
|
+
return _resolveInvoiceTemplateSettings.apply(this, arguments);
|
|
353
|
+
}
|
|
354
|
+
return resolveInvoiceTemplateSettings;
|
|
355
|
+
}()
|
|
356
|
+
}, {
|
|
357
|
+
key: "buildInvoiceTemplateCacheKey",
|
|
358
|
+
value: function buildInvoiceTemplateCacheKey(target, documentId) {
|
|
359
|
+
var _this$appPlugin2, _this$appPlugin2$getD, _getData, _getData2;
|
|
360
|
+
var getData = (_this$appPlugin2 = this.appPlugin) === null || _this$appPlugin2 === void 0 || (_this$appPlugin2$getD = _this$appPlugin2.getData) === null || _this$appPlugin2$getD === void 0 ? void 0 : _this$appPlugin2$getD.call(_this$appPlugin2);
|
|
361
|
+
return JSON.stringify([(_getData = getData === null || getData === void 0 ? void 0 : getData('tenant_id')) !== null && _getData !== void 0 ? _getData : null, (_getData2 = getData === null || getData === void 0 ? void 0 : getData('shop_id')) !== null && _getData2 !== void 0 ? _getData2 : null, target, documentId]);
|
|
362
|
+
}
|
|
363
|
+
}, {
|
|
364
|
+
key: "fetchInvoiceTemplateDocument",
|
|
365
|
+
value: function () {
|
|
366
|
+
var _fetchInvoiceTemplateDocument = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(documentId) {
|
|
367
|
+
var response, document;
|
|
368
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
369
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
370
|
+
case 0:
|
|
371
|
+
_context5.next = 2;
|
|
372
|
+
return this.request.get("/document:get?filterByTk=".concat(encodeURIComponent(documentId)), {}, {
|
|
373
|
+
isNocobase: true,
|
|
374
|
+
prefix: false,
|
|
375
|
+
headers: {
|
|
376
|
+
'x-data-source': 'pisell2'
|
|
377
|
+
},
|
|
378
|
+
customToast: function customToast() {}
|
|
379
|
+
});
|
|
380
|
+
case 2:
|
|
381
|
+
response = _context5.sent;
|
|
382
|
+
document = response === null || response === void 0 ? void 0 : response.data;
|
|
383
|
+
if (!(!document || resolveInvoiceDocumentId(document.id) !== documentId)) {
|
|
384
|
+
_context5.next = 6;
|
|
385
|
+
break;
|
|
386
|
+
}
|
|
387
|
+
throw new Error("Invoice Document ".concat(documentId, " \u8FD4\u56DE\u7684 ID \u4E0D\u5339\u914D"));
|
|
388
|
+
case 6:
|
|
389
|
+
if (!(document.deleted_at !== null && document.deleted_at !== undefined)) {
|
|
390
|
+
_context5.next = 8;
|
|
391
|
+
break;
|
|
392
|
+
}
|
|
393
|
+
throw new Error("Invoice Document ".concat(documentId, " \u5DF2\u88AB\u5220\u9664"));
|
|
394
|
+
case 8:
|
|
395
|
+
if (!(!isRecord(document.data) || !isRecord(document.data.template_settings))) {
|
|
396
|
+
_context5.next = 10;
|
|
397
|
+
break;
|
|
398
|
+
}
|
|
399
|
+
throw new Error("Invoice Document ".concat(documentId, " \u7F3A\u5C11 template_settings"));
|
|
400
|
+
case 10:
|
|
401
|
+
return _context5.abrupt("return", normalizeRawInvoiceTemplateSettings(document.data.template_settings));
|
|
402
|
+
case 11:
|
|
403
|
+
case "end":
|
|
404
|
+
return _context5.stop();
|
|
405
|
+
}
|
|
406
|
+
}, _callee5, this);
|
|
407
|
+
}));
|
|
408
|
+
function fetchInvoiceTemplateDocument(_x7) {
|
|
409
|
+
return _fetchInvoiceTemplateDocument.apply(this, arguments);
|
|
410
|
+
}
|
|
411
|
+
return fetchInvoiceTemplateDocument;
|
|
412
|
+
}()
|
|
413
|
+
}, {
|
|
414
|
+
key: "logInvoiceTemplateDocumentFallback",
|
|
415
|
+
value: function logInvoiceTemplateDocumentFallback(error, target, documentId) {
|
|
416
|
+
console.warn('[OpenDataModule] Invoice Document 加载失败,使用 DEFAULT', {
|
|
417
|
+
target: target,
|
|
418
|
+
documentId: documentId,
|
|
419
|
+
message: error instanceof Error ? error.message : String(error)
|
|
420
|
+
});
|
|
174
421
|
}
|
|
175
422
|
}, {
|
|
176
423
|
key: "getLastFetchedAt",
|
|
@@ -184,14 +431,21 @@ export var OpenDataModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
184
431
|
key: "clearCache",
|
|
185
432
|
value: function clearCache() {
|
|
186
433
|
this.fetchRevision += 1;
|
|
434
|
+
this.invoiceTemplateCacheRevision += 1;
|
|
435
|
+
this.invoiceTemplateDocumentCache.clear();
|
|
436
|
+
this.invoiceTemplateDocumentInFlight.clear();
|
|
187
437
|
this.store.data = null;
|
|
188
438
|
this.store.lastFetchedAt = null;
|
|
439
|
+
this.store.invoiceTemplateSettings = null;
|
|
440
|
+
this.store.invoiceTemplateTarget = null;
|
|
441
|
+
this.store.invoiceTemplateDocumentId = null;
|
|
442
|
+
this.store.invoiceTemplateCacheKey = null;
|
|
189
443
|
}
|
|
190
444
|
}, {
|
|
191
445
|
key: "checkAvailability",
|
|
192
446
|
value: function checkAvailability(scheduleModule) {
|
|
193
|
-
var _this$store$
|
|
194
|
-
var scheduleList = scheduleModule ? scheduleModule === null || scheduleModule === void 0 ? void 0 : scheduleModule.getScheduleListByIds(((_this$store$
|
|
447
|
+
var _this$store$data3;
|
|
448
|
+
var scheduleList = scheduleModule ? scheduleModule === null || scheduleModule === void 0 ? void 0 : scheduleModule.getScheduleListByIds(((_this$store$data3 = this.store.data) === null || _this$store$data3 === void 0 ? void 0 : _this$store$data3['availability.operating_hours']) || []) : undefined;
|
|
195
449
|
return computeAvailability({
|
|
196
450
|
config: this.store.data,
|
|
197
451
|
scheduleList: scheduleList
|
|
@@ -32,6 +32,15 @@ export interface InvoiceTemplateSettings {
|
|
|
32
32
|
modules: InvoiceTemplateModuleConfig[];
|
|
33
33
|
[key: string]: unknown;
|
|
34
34
|
}
|
|
35
|
+
export interface InvoiceDocumentResponse {
|
|
36
|
+
data?: {
|
|
37
|
+
id?: number | string;
|
|
38
|
+
deleted_at?: string | null;
|
|
39
|
+
data?: {
|
|
40
|
+
template_settings?: unknown;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
}
|
|
35
44
|
export type RawInvoiceEditConfig = string | {
|
|
36
45
|
language?: unknown;
|
|
37
46
|
modules?: unknown;
|
|
@@ -79,7 +88,7 @@ export interface OpenDataConfig {
|
|
|
79
88
|
label: string;
|
|
80
89
|
value: number;
|
|
81
90
|
}>;
|
|
82
|
-
'documents.invoice_template'?: string;
|
|
91
|
+
'documents.invoice_template'?: string | number;
|
|
83
92
|
'documents.invoice_edit'?: RawInvoiceEditConfig;
|
|
84
93
|
/** @deprecated 仅保留旧调用方的类型兼容,Invoice 读取逻辑不再消费该字段。 */
|
|
85
94
|
'documents.invoice'?: RawInvoiceLayoutConfig;
|
|
@@ -92,6 +101,10 @@ export interface OpenDataConfig {
|
|
|
92
101
|
export interface OpenDataState {
|
|
93
102
|
data: OpenDataConfig | null;
|
|
94
103
|
lastFetchedAt: number | null;
|
|
104
|
+
invoiceTemplateSettings?: InvoiceTemplateSettings | null;
|
|
105
|
+
invoiceTemplateTarget?: string | null;
|
|
106
|
+
invoiceTemplateDocumentId?: string | null;
|
|
107
|
+
invoiceTemplateCacheKey?: string | null;
|
|
95
108
|
}
|
|
96
109
|
export interface OpenDataFetchParams {
|
|
97
110
|
scope: string;
|
|
@@ -14,6 +14,7 @@ export declare function normalizeRawInvoiceTemplateSettings(value: unknown): Inv
|
|
|
14
14
|
* 从 OpenData Documents section 的两个扁平字段中构造 Native Invoice 配置。
|
|
15
15
|
*/
|
|
16
16
|
export declare function normalizeInvoiceTemplateSettings(config: OpenDataConfig | null | undefined): InvoiceTemplateSettings;
|
|
17
|
+
export declare function normalizeInvoiceLayoutFromTemplateSettings(settings: InvoiceTemplateSettings | null | undefined): InvoiceLayoutConfig;
|
|
17
18
|
/**
|
|
18
19
|
* 将 invoice_edit.modules 原样投影为 Web Invoice 使用的 module 字段。
|
|
19
20
|
*/
|
|
@@ -125,16 +125,19 @@ export function normalizeInvoiceTemplateSettings(config) {
|
|
|
125
125
|
template: normalizeInvoiceTemplate(config === null || config === void 0 ? void 0 : config['documents.invoice_template'])
|
|
126
126
|
}));
|
|
127
127
|
}
|
|
128
|
+
export function normalizeInvoiceLayoutFromTemplateSettings(settings) {
|
|
129
|
+
var modules = normalizeRawInvoiceTemplateSettings(settings).modules;
|
|
130
|
+
if (modules.length === 0) return getDefaultInvoiceLayoutConfig();
|
|
131
|
+
return {
|
|
132
|
+
module: modules
|
|
133
|
+
};
|
|
134
|
+
}
|
|
128
135
|
|
|
129
136
|
/**
|
|
130
137
|
* 将 invoice_edit.modules 原样投影为 Web Invoice 使用的 module 字段。
|
|
131
138
|
*/
|
|
132
139
|
export function normalizeInvoiceLayoutConfig(config) {
|
|
133
|
-
|
|
134
|
-
if (modules.length === 0) return getDefaultInvoiceLayoutConfig();
|
|
135
|
-
return {
|
|
136
|
-
module: modules
|
|
137
|
-
};
|
|
140
|
+
return normalizeInvoiceLayoutFromTemplateSettings(normalizeInvoiceTemplateSettings(config));
|
|
138
141
|
}
|
|
139
142
|
function toBoolean(value) {
|
|
140
143
|
if (typeof value === 'boolean') return value;
|
|
@@ -415,6 +415,11 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
415
415
|
* if (pending) await pending;
|
|
416
416
|
*/
|
|
417
417
|
private appendProductLineToTempOrder;
|
|
418
|
+
/**
|
|
419
|
+
* booking 数量拆行时,若 Holder 数量与拆行数严格一致,则按下标分配。
|
|
420
|
+
* 数量不一致时保持旧数据,避免猜测 Holder 与商品份数的对应关系。
|
|
421
|
+
*/
|
|
422
|
+
private createSplitBookingLine;
|
|
418
423
|
/**
|
|
419
424
|
* 添加商品行。带 booking 时强制独立行;num>1 时拆成多条 num=1 的 product+booking(对齐 BookingByStep / ticketBooking addService)。
|
|
420
425
|
*
|
|
@@ -528,7 +533,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
528
533
|
generateIdempotencyToken(): string;
|
|
529
534
|
syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
|
|
530
535
|
createOrder(params: CommitOrderParams['query']): {
|
|
531
|
-
type: "
|
|
536
|
+
type: "appointment_booking" | "virtual";
|
|
532
537
|
platform: string;
|
|
533
538
|
sales_channel: string;
|
|
534
539
|
order_sales_channel: string;
|