@pisell/pisellos 0.10.54 → 0.10.56
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/modules/BusinessAvailability/index.d.ts +30 -0
- package/dist/modules/BusinessAvailability/index.js +204 -0
- package/dist/modules/OpenData/types.d.ts +2 -0
- package/dist/modules/Order/index.d.ts +4 -1
- package/dist/modules/Order/index.js +315 -241
- package/dist/modules/Order/types.d.ts +8 -0
- package/dist/plugins/request.d.ts +4 -0
- package/dist/shared/receipt/loadCustomerInvoiceLayout.d.ts +22 -0
- package/dist/shared/receipt/loadCustomerInvoiceLayout.js +142 -0
- package/dist/solution/BaseSales/index.d.ts +4 -15
- package/dist/solution/BaseSales/index.js +131 -86
- package/dist/solution/BaseSales/types.d.ts +11 -0
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.js +41 -13
- package/dist/solution/OrderInvoicePreview/index.js +6 -6
- package/dist/solution/UnifiedBookingSales/businessAvailability.d.ts +27 -0
- package/dist/solution/UnifiedBookingSales/businessAvailability.js +292 -0
- package/dist/solution/UnifiedBookingSales/index.d.ts +11 -0
- package/dist/solution/UnifiedBookingSales/index.js +154 -75
- package/dist/solution/UnifiedBookingSales/types.d.ts +2 -0
- package/lib/model/strategy/adapter/promotion/index.js +1 -46
- package/lib/modules/BusinessAvailability/index.d.ts +30 -0
- package/lib/modules/BusinessAvailability/index.js +146 -0
- package/lib/modules/OpenData/types.d.ts +2 -0
- package/lib/modules/Order/index.d.ts +4 -1
- package/lib/modules/Order/index.js +62 -6
- package/lib/modules/Order/types.d.ts +8 -0
- package/lib/plugins/request.d.ts +4 -0
- package/lib/shared/receipt/loadCustomerInvoiceLayout.d.ts +22 -0
- package/lib/shared/receipt/loadCustomerInvoiceLayout.js +86 -0
- package/lib/solution/BaseSales/index.d.ts +4 -15
- package/lib/solution/BaseSales/index.js +45 -24
- package/lib/solution/BaseSales/types.d.ts +11 -0
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.js +37 -4
- package/lib/solution/OrderInvoicePreview/index.js +2 -4
- package/lib/solution/UnifiedBookingSales/businessAvailability.d.ts +27 -0
- package/lib/solution/UnifiedBookingSales/businessAvailability.js +138 -0
- package/lib/solution/UnifiedBookingSales/index.d.ts +11 -0
- package/lib/solution/UnifiedBookingSales/index.js +54 -0
- package/lib/solution/UnifiedBookingSales/types.d.ts +2 -0
- package/package.json +1 -1
|
@@ -517,7 +517,15 @@ export type OrderProductMergeDecisionResult = boolean | {
|
|
|
517
517
|
reason?: string;
|
|
518
518
|
[key: string]: any;
|
|
519
519
|
};
|
|
520
|
+
export interface OrderCartIntentCommitContext {
|
|
521
|
+
action: 'add_product' | 'update_product' | 'increase_quantity' | 'scan_promotion';
|
|
522
|
+
tempOrder: OrderTempOrder | null;
|
|
523
|
+
}
|
|
520
524
|
export interface OrderHooksConfig {
|
|
525
|
+
/** Optional customer-order guard; called synchronously before the first cart write. */
|
|
526
|
+
beforeCartIntentCommit?: (context: OrderCartIntentCommitContext) => void;
|
|
527
|
+
/** Captures tenant/business runtime identity for asynchronous cart intents. */
|
|
528
|
+
getCartIntentScope?: () => unknown;
|
|
521
529
|
onBeforeMergeProductToOrder?: (context: OrderProductMergeDecisionContext) => OrderProductMergeDecisionResult | Promise<OrderProductMergeDecisionResult>;
|
|
522
530
|
}
|
|
523
531
|
/**
|
|
@@ -56,6 +56,10 @@ export interface CacheProps {
|
|
|
56
56
|
* 请求配置
|
|
57
57
|
*/
|
|
58
58
|
export interface RequestOptions {
|
|
59
|
+
/** Customer-only, credential-free GET /open/document/{id} on picoding. */
|
|
60
|
+
publicInvoiceDocument?: boolean;
|
|
61
|
+
/** Route through the host's configured picoding environment. */
|
|
62
|
+
pisell2?: boolean;
|
|
59
63
|
/** Let the caller handle read-only preview failures without host navigation/toasts. */
|
|
60
64
|
manualErrorHandling?: boolean;
|
|
61
65
|
skipErrorHandler?: boolean;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { RequestPlugin } from '../../plugins/request';
|
|
2
|
+
import { type InvoiceLayoutConfig } from '../../modules/OpenData';
|
|
3
|
+
export interface PublicInvoiceDocumentResponse {
|
|
4
|
+
status: boolean;
|
|
5
|
+
code: number;
|
|
6
|
+
message?: string;
|
|
7
|
+
data: {
|
|
8
|
+
id: number;
|
|
9
|
+
data?: {
|
|
10
|
+
template_settings?: unknown;
|
|
11
|
+
} | null;
|
|
12
|
+
} | null;
|
|
13
|
+
}
|
|
14
|
+
interface TemplateScope {
|
|
15
|
+
tenantId: string | number;
|
|
16
|
+
shopId: string | number;
|
|
17
|
+
identity: string;
|
|
18
|
+
businessCode: string;
|
|
19
|
+
channel: string;
|
|
20
|
+
}
|
|
21
|
+
export declare function loadCustomerInvoiceLayout(request: RequestPlugin, scope: TemplateScope): Promise<InvoiceLayoutConfig>;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,142 @@
|
|
|
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; }
|
|
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); } }
|
|
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); }); }; }
|
|
4
|
+
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); }
|
|
5
|
+
import { getDefaultInvoiceLayoutConfig, normalizeInvoiceLayoutFromTemplateSettings, normalizeInvoiceTemplateSettings, normalizeRawInvoiceTemplateSettings } from "../../modules/OpenData";
|
|
6
|
+
// Page-runtime caches: also retain DEFAULT on failure, without automatic retries.
|
|
7
|
+
var caches = new WeakMap();
|
|
8
|
+
var isRecord = function isRecord(value) {
|
|
9
|
+
return !!value && _typeof(value) === 'object' && !Array.isArray(value);
|
|
10
|
+
};
|
|
11
|
+
function documentId(value) {
|
|
12
|
+
if (typeof value !== 'string' && typeof value !== 'number') return null;
|
|
13
|
+
var text = String(value).trim();
|
|
14
|
+
if (!/^\d+$/.test(text)) return null;
|
|
15
|
+
var id = Number(text);
|
|
16
|
+
return Number.isSafeInteger(id) && id > 0 ? String(id) : null;
|
|
17
|
+
}
|
|
18
|
+
export function loadCustomerInvoiceLayout(request, scope) {
|
|
19
|
+
var cache = caches.get(request);
|
|
20
|
+
if (!cache) {
|
|
21
|
+
cache = {
|
|
22
|
+
scopes: new Map(),
|
|
23
|
+
documents: new Map()
|
|
24
|
+
};
|
|
25
|
+
caches.set(request, cache);
|
|
26
|
+
}
|
|
27
|
+
var target = "".concat(scope.businessCode, "+").concat(scope.channel);
|
|
28
|
+
var key = JSON.stringify([scope.tenantId, scope.shopId, scope.identity, scope.businessCode, scope.channel]);
|
|
29
|
+
var cached = cache.scopes.get(key);
|
|
30
|
+
if (cached) return cached;
|
|
31
|
+
var id = null;
|
|
32
|
+
var task = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
33
|
+
var response, config, raw, numericLike, docKey, pending, expectedId;
|
|
34
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
35
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
36
|
+
case 0:
|
|
37
|
+
_context2.next = 2;
|
|
38
|
+
return request.post("/open/my-pisell/".concat(encodeURIComponent(String(scope.shopId)), "/setting"), {
|
|
39
|
+
scope: 'board',
|
|
40
|
+
target: target,
|
|
41
|
+
section_code: ['documents']
|
|
42
|
+
}, {
|
|
43
|
+
pisell2: true,
|
|
44
|
+
prefix: false,
|
|
45
|
+
headers: scope.tenantId ? {
|
|
46
|
+
'Tenant-Id': String(scope.tenantId)
|
|
47
|
+
} : {},
|
|
48
|
+
manualErrorHandling: true,
|
|
49
|
+
skipErrorHandler: true,
|
|
50
|
+
timeout: 15000
|
|
51
|
+
});
|
|
52
|
+
case 2:
|
|
53
|
+
response = _context2.sent;
|
|
54
|
+
if (!((response === null || response === void 0 ? void 0 : response.status) !== true || response.code !== 200 || !isRecord(response.data))) {
|
|
55
|
+
_context2.next = 5;
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
throw new Error((response === null || response === void 0 ? void 0 : response.message) || 'Invoice OpenData is unavailable');
|
|
59
|
+
case 5:
|
|
60
|
+
config = response.data;
|
|
61
|
+
raw = config['documents.invoice_template'];
|
|
62
|
+
id = documentId(raw);
|
|
63
|
+
if (id) {
|
|
64
|
+
_context2.next = 11;
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
// Preserve the existing non-numeric legacy template / invoice_edit contract.
|
|
68
|
+
numericLike = /^[+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?$/i;
|
|
69
|
+
return _context2.abrupt("return", typeof raw === 'string' && raw.trim() && !numericLike.test(raw.trim()) ? normalizeInvoiceLayoutFromTemplateSettings(normalizeInvoiceTemplateSettings(config)) : getDefaultInvoiceLayoutConfig());
|
|
70
|
+
case 11:
|
|
71
|
+
docKey = JSON.stringify([key, id]);
|
|
72
|
+
pending = cache.documents.get(docKey);
|
|
73
|
+
if (!pending) {
|
|
74
|
+
expectedId = id;
|
|
75
|
+
pending = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
76
|
+
var result, doc, settings;
|
|
77
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
78
|
+
while (1) switch (_context.prev = _context.next) {
|
|
79
|
+
case 0:
|
|
80
|
+
_context.next = 2;
|
|
81
|
+
return request.get("/open/document/".concat(expectedId), {}, {
|
|
82
|
+
publicInvoiceDocument: true
|
|
83
|
+
});
|
|
84
|
+
case 2:
|
|
85
|
+
result = _context.sent;
|
|
86
|
+
if (!((result === null || result === void 0 ? void 0 : result.status) !== true || result.code !== 200)) {
|
|
87
|
+
_context.next = 5;
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
throw new Error((result === null || result === void 0 ? void 0 : result.message) || 'Invoice Document request failed');
|
|
91
|
+
case 5:
|
|
92
|
+
doc = result.data;
|
|
93
|
+
if (!(!doc || documentId(doc.id) !== expectedId)) {
|
|
94
|
+
_context.next = 8;
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
throw new Error('Invoice Document is unavailable or its ID does not match');
|
|
98
|
+
case 8:
|
|
99
|
+
if (!(!isRecord(doc.data) || !isRecord(doc.data.template_settings))) {
|
|
100
|
+
_context.next = 10;
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
throw new Error('Invoice Document has no template_settings');
|
|
104
|
+
case 10:
|
|
105
|
+
settings = normalizeRawInvoiceTemplateSettings(doc.data.template_settings);
|
|
106
|
+
if (!(settings.modules.length === 0)) {
|
|
107
|
+
_context.next = 13;
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
throw new Error('Invoice Document has no usable template modules');
|
|
111
|
+
case 13:
|
|
112
|
+
return _context.abrupt("return", normalizeInvoiceLayoutFromTemplateSettings(settings));
|
|
113
|
+
case 14:
|
|
114
|
+
case "end":
|
|
115
|
+
return _context.stop();
|
|
116
|
+
}
|
|
117
|
+
}, _callee);
|
|
118
|
+
}))().catch(function (error) {
|
|
119
|
+
return fallback(error, target, expectedId);
|
|
120
|
+
});
|
|
121
|
+
cache.documents.set(docKey, pending);
|
|
122
|
+
}
|
|
123
|
+
return _context2.abrupt("return", pending);
|
|
124
|
+
case 15:
|
|
125
|
+
case "end":
|
|
126
|
+
return _context2.stop();
|
|
127
|
+
}
|
|
128
|
+
}, _callee2);
|
|
129
|
+
}))().catch(function (error) {
|
|
130
|
+
return fallback(error, target, id);
|
|
131
|
+
});
|
|
132
|
+
cache.scopes.set(key, task);
|
|
133
|
+
return task;
|
|
134
|
+
}
|
|
135
|
+
function fallback(error, target, id) {
|
|
136
|
+
console.warn('[OrderInvoicePreview] Template unavailable; using DEFAULT', {
|
|
137
|
+
target: target,
|
|
138
|
+
documentId: id,
|
|
139
|
+
message: error instanceof Error ? error.message : 'Template request failed'
|
|
140
|
+
});
|
|
141
|
+
return getDefaultInvoiceLayoutConfig();
|
|
142
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Module, ModuleOptions, PisellCore } from '../../types';
|
|
2
2
|
import { BaseModule } from '../../modules/BaseModule';
|
|
3
|
-
import { BaseSalesOrderProduct, BaseSalesOrderProductIdentity, BaseSalesPaymentStatus, BaseSalesUpdateOrderProductQuantityParams, BaseSalesCalculateProductBookingPriceParams, BaseSalesPriceRecalculationContextChange, BaseSalesProductBookingPriceResult, BaseSalesQuotationCustomerScopeInfo, BaseSalesScanCodeResult, BaseSalesCashPaymentConfig, BaseSalesPayCashParams, BaseSalesPayCashResult, BaseSalesCommitPaymentMethodParams, BaseSalesCommitPaymentMethodResult, BaseSalesConfirmWalletPaymentResult } from './types';
|
|
3
|
+
import { BaseSalesOrderProduct, BaseSalesOrderProductIdentity, BaseSalesPaymentStatus, BaseSalesSubmitSalesOrderParams, BaseSalesUpdateOrderProductQuantityParams, BaseSalesCalculateProductBookingPriceParams, BaseSalesPriceRecalculationContextChange, BaseSalesProductBookingPriceResult, BaseSalesQuotationCustomerScopeInfo, BaseSalesScanCodeResult, BaseSalesCashPaymentConfig, BaseSalesPayCashParams, BaseSalesPayCashResult, BaseSalesCommitPaymentMethodParams, BaseSalesCommitPaymentMethodResult, BaseSalesConfirmWalletPaymentResult } from './types';
|
|
4
4
|
import { OrderModule } from '../../modules/Order';
|
|
5
5
|
import { type PickupTimingBookingInput } from '../../modules/Order/pickupTiming';
|
|
6
6
|
import type { PickupTimingAvailability, PickupTimingSelection, PickupTimingValidationResult } from '../../modules/FulfillmentTiming';
|
|
@@ -337,13 +337,8 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
337
337
|
productList?: Record<string, any>[];
|
|
338
338
|
discountList?: Discount[];
|
|
339
339
|
}): Promise<void>;
|
|
340
|
-
submitScanOrder<T = any>(params?:
|
|
341
|
-
|
|
342
|
-
paymentStatus?: BaseSalesPaymentStatus;
|
|
343
|
-
smallTicketDataFlag?: number;
|
|
344
|
-
confirmPendingVoucherPayments?: boolean;
|
|
345
|
-
enhancePayload?: SubmitPayloadEnhancer;
|
|
346
|
-
}): Promise<T>;
|
|
340
|
+
submitScanOrder<T = any>(params?: BaseSalesSubmitSalesOrderParams): Promise<T>;
|
|
341
|
+
private buildVirtualSettlementOrderData;
|
|
347
342
|
private buildVirtualSettlementSubmitData;
|
|
348
343
|
/**
|
|
349
344
|
* 提交当前 Sales 订单。
|
|
@@ -351,13 +346,7 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
351
346
|
* PaymentModal 场景通过 smallTicketDataFlag=1 请求 B 端小票数据;
|
|
352
347
|
* payments 会交给 OrderModule 统一映射为 Sales 协议支付项。
|
|
353
348
|
*/
|
|
354
|
-
submitSalesOrder<T = any>(params?:
|
|
355
|
-
payments?: OrderPaymentSource[];
|
|
356
|
-
paymentStatus?: BaseSalesPaymentStatus;
|
|
357
|
-
smallTicketDataFlag?: number;
|
|
358
|
-
confirmPendingVoucherPayments?: boolean;
|
|
359
|
-
enhancePayload?: SubmitPayloadEnhancer;
|
|
360
|
-
}): Promise<T>;
|
|
349
|
+
submitSalesOrder<T = any>(params?: BaseSalesSubmitSalesOrderParams): Promise<T>;
|
|
361
350
|
saveSalesOrderDraft<T = any>(params?: {
|
|
362
351
|
platform?: string;
|
|
363
352
|
businessCode?: string;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
var _excluded = ["payment_status"];
|
|
2
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
3
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
1
4
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
5
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
6
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
@@ -3918,92 +3921,91 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3918
3921
|
}
|
|
3919
3922
|
return submitScanOrder;
|
|
3920
3923
|
}()
|
|
3924
|
+
}, {
|
|
3925
|
+
key: "buildVirtualSettlementOrderData",
|
|
3926
|
+
value: function buildVirtualSettlementOrderData() {
|
|
3927
|
+
var _tempOrder$metadata$c, _tempOrder$metadata2;
|
|
3928
|
+
if (!this.store.order) return null;
|
|
3929
|
+
var tempOrder = this.store.order.getTempOrder();
|
|
3930
|
+
if (!this.isActiveVirtualSettlementOrder(tempOrder)) return null;
|
|
3931
|
+
var snapshot = getTempOrderSettlementSnapshot(tempOrder);
|
|
3932
|
+
var currencyProductId = Number((_tempOrder$metadata$c = tempOrder === null || tempOrder === void 0 || (_tempOrder$metadata2 = tempOrder.metadata) === null || _tempOrder$metadata2 === void 0 || (_tempOrder$metadata2 = _tempOrder$metadata2.currency_settlement_config) === null || _tempOrder$metadata2 === void 0 || (_tempOrder$metadata2 = _tempOrder$metadata2.settlement_ids) === null || _tempOrder$metadata2 === void 0 ? void 0 : _tempOrder$metadata2[0]) !== null && _tempOrder$metadata$c !== void 0 ? _tempOrder$metadata$c : snapshot === null || snapshot === void 0 ? void 0 : snapshot.currency_product_id);
|
|
3933
|
+
if (!snapshot || !Number.isFinite(currencyProductId) || currencyProductId <= 0) {
|
|
3934
|
+
throw new Error('Virtual currency settlement configuration is invalid.');
|
|
3935
|
+
}
|
|
3936
|
+
return {
|
|
3937
|
+
snapshot: snapshot,
|
|
3938
|
+
currencyProductId: currencyProductId,
|
|
3939
|
+
currencyCode: String((tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.currency_code) || ''),
|
|
3940
|
+
currencySymbol: String((tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.currency_symbol) || ''),
|
|
3941
|
+
currencyFormat: String((tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.currency_format) || 'symbol_first')
|
|
3942
|
+
};
|
|
3943
|
+
}
|
|
3921
3944
|
}, {
|
|
3922
3945
|
key: "buildVirtualSettlementSubmitData",
|
|
3923
3946
|
value: function () {
|
|
3924
3947
|
var _buildVirtualSettlementSubmitData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {
|
|
3925
|
-
var
|
|
3926
|
-
var tempOrder, snapshot, currencyProductId, summary, amount, customerId, asset, currencyCode, currencySymbol, currencyFormat, balance, amountText, paymentNumber, payment, _paymentMethod$custom, paymentMethods, paymentMethod;
|
|
3948
|
+
var settlement, tempOrder, currencyProductId, summary, amount, customerId, asset, balance, amountText, paymentNumber, payment, _paymentMethod$custom, paymentMethods, paymentMethod;
|
|
3927
3949
|
return _regeneratorRuntime().wrap(function _callee33$(_context33) {
|
|
3928
3950
|
while (1) switch (_context33.prev = _context33.next) {
|
|
3929
3951
|
case 0:
|
|
3930
|
-
|
|
3931
|
-
|
|
3952
|
+
settlement = this.buildVirtualSettlementOrderData();
|
|
3953
|
+
if (!(!settlement || !this.store.order)) {
|
|
3954
|
+
_context33.next = 3;
|
|
3932
3955
|
break;
|
|
3933
3956
|
}
|
|
3934
3957
|
return _context33.abrupt("return", null);
|
|
3935
|
-
case
|
|
3958
|
+
case 3:
|
|
3936
3959
|
tempOrder = this.store.order.getTempOrder();
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
break;
|
|
3940
|
-
}
|
|
3941
|
-
return _context33.abrupt("return", null);
|
|
3942
|
-
case 5:
|
|
3943
|
-
snapshot = getTempOrderSettlementSnapshot(tempOrder);
|
|
3944
|
-
currencyProductId = Number((_tempOrder$metadata$c = tempOrder === null || tempOrder === void 0 || (_tempOrder$metadata2 = tempOrder.metadata) === null || _tempOrder$metadata2 === void 0 || (_tempOrder$metadata2 = _tempOrder$metadata2.currency_settlement_config) === null || _tempOrder$metadata2 === void 0 || (_tempOrder$metadata2 = _tempOrder$metadata2.settlement_ids) === null || _tempOrder$metadata2 === void 0 ? void 0 : _tempOrder$metadata2[0]) !== null && _tempOrder$metadata$c !== void 0 ? _tempOrder$metadata$c : snapshot === null || snapshot === void 0 ? void 0 : snapshot.currency_product_id);
|
|
3945
|
-
if (!(!snapshot || !Number.isFinite(currencyProductId) || currencyProductId <= 0)) {
|
|
3946
|
-
_context33.next = 9;
|
|
3947
|
-
break;
|
|
3948
|
-
}
|
|
3949
|
-
throw new Error('Virtual currency settlement configuration is invalid.');
|
|
3950
|
-
case 9:
|
|
3951
|
-
_context33.next = 11;
|
|
3960
|
+
currencyProductId = settlement.currencyProductId;
|
|
3961
|
+
_context33.next = 7;
|
|
3952
3962
|
return this.store.order.recalculateSummary({
|
|
3953
3963
|
createIfMissing: true
|
|
3954
3964
|
});
|
|
3955
|
-
case
|
|
3965
|
+
case 7:
|
|
3956
3966
|
summary = _context33.sent;
|
|
3957
3967
|
amount = new Decimal((summary === null || summary === void 0 ? void 0 : summary.total_amount) || 0).toDecimalPlaces(2);
|
|
3958
3968
|
customerId = Number((tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.customer_id) || 0);
|
|
3959
3969
|
if (!(amount.gt(0) && customerId > 0 && customerId !== 1)) {
|
|
3960
|
-
_context33.next =
|
|
3970
|
+
_context33.next = 13;
|
|
3961
3971
|
break;
|
|
3962
3972
|
}
|
|
3963
|
-
_context33.next =
|
|
3973
|
+
_context33.next = 13;
|
|
3964
3974
|
return this.store.order.loadDiscountConfig({
|
|
3965
3975
|
customerId: customerId,
|
|
3966
3976
|
action: tempOrder !== null && tempOrder !== void 0 && tempOrder.order_id ? 'edit' : 'create',
|
|
3967
3977
|
orderId: Number(tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.order_id) || undefined,
|
|
3968
3978
|
apply: false
|
|
3969
3979
|
});
|
|
3970
|
-
case
|
|
3980
|
+
case 13:
|
|
3971
3981
|
asset = this.store.order.getVirtualCurrencyList().find(function (item) {
|
|
3972
3982
|
return Number(item === null || item === void 0 ? void 0 : item.product_id) === currencyProductId;
|
|
3973
3983
|
});
|
|
3974
|
-
currencyCode = String((tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.currency_code) || '');
|
|
3975
|
-
currencySymbol = String((tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.currency_symbol) || '');
|
|
3976
|
-
currencyFormat = String((tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.currency_format) || 'symbol_first');
|
|
3977
3984
|
if (!amount.lte(0)) {
|
|
3978
|
-
_context33.next =
|
|
3985
|
+
_context33.next = 16;
|
|
3979
3986
|
break;
|
|
3980
3987
|
}
|
|
3981
|
-
return _context33.abrupt("return", {
|
|
3982
|
-
payments: []
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
currencyCode: currencyCode,
|
|
3986
|
-
currencySymbol: currencySymbol,
|
|
3987
|
-
currencyFormat: currencyFormat
|
|
3988
|
-
});
|
|
3989
|
-
case 23:
|
|
3988
|
+
return _context33.abrupt("return", _objectSpread(_objectSpread({}, settlement), {}, {
|
|
3989
|
+
payments: []
|
|
3990
|
+
}));
|
|
3991
|
+
case 16:
|
|
3990
3992
|
if (asset) {
|
|
3991
|
-
_context33.next =
|
|
3993
|
+
_context33.next = 18;
|
|
3992
3994
|
break;
|
|
3993
3995
|
}
|
|
3994
3996
|
throw new Error('No matching virtual currency card is available.');
|
|
3995
|
-
case
|
|
3997
|
+
case 18:
|
|
3996
3998
|
balance = new Decimal(asset.balance || 0);
|
|
3997
3999
|
if (!balance.lt(amount)) {
|
|
3998
|
-
_context33.next =
|
|
4000
|
+
_context33.next = 21;
|
|
3999
4001
|
break;
|
|
4000
4002
|
}
|
|
4001
4003
|
throw new Error('Insufficient virtual currency balance.');
|
|
4002
|
-
case
|
|
4004
|
+
case 21:
|
|
4003
4005
|
amountText = amount.toFixed(2);
|
|
4004
4006
|
paymentNumber = "LOCAL_".concat(createUuidV4());
|
|
4005
4007
|
if (!this.store.order.isOnlineStorePlatform()) {
|
|
4006
|
-
_context33.next =
|
|
4008
|
+
_context33.next = 27;
|
|
4007
4009
|
break;
|
|
4008
4010
|
}
|
|
4009
4011
|
payment = {
|
|
@@ -4020,22 +4022,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4020
4022
|
},
|
|
4021
4023
|
wallet_pass_use_value: amountText
|
|
4022
4024
|
};
|
|
4023
|
-
_context33.next =
|
|
4025
|
+
_context33.next = 34;
|
|
4024
4026
|
break;
|
|
4025
|
-
case
|
|
4026
|
-
_context33.next =
|
|
4027
|
+
case 27:
|
|
4028
|
+
_context33.next = 29;
|
|
4027
4029
|
return this.getPaymentMethodsAsync();
|
|
4028
|
-
case
|
|
4030
|
+
case 29:
|
|
4029
4031
|
paymentMethods = _context33.sent;
|
|
4030
4032
|
paymentMethod = paymentMethods.find(function (method) {
|
|
4031
4033
|
return String(method.code || '').toUpperCase() === 'PRODUCTVOUCHER';
|
|
4032
4034
|
});
|
|
4033
4035
|
if (paymentMethod) {
|
|
4034
|
-
_context33.next =
|
|
4036
|
+
_context33.next = 33;
|
|
4035
4037
|
break;
|
|
4036
4038
|
}
|
|
4037
4039
|
throw new Error('PRODUCTVOUCHER payment method is unavailable.');
|
|
4038
|
-
case
|
|
4040
|
+
case 33:
|
|
4039
4041
|
payment = {
|
|
4040
4042
|
payment_number: paymentNumber,
|
|
4041
4043
|
amount: amountText,
|
|
@@ -4054,16 +4056,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4054
4056
|
wallet_pass_use_value: amountText,
|
|
4055
4057
|
metadata: {}
|
|
4056
4058
|
};
|
|
4057
|
-
case
|
|
4058
|
-
return _context33.abrupt("return", {
|
|
4059
|
-
payments: [payment]
|
|
4060
|
-
|
|
4061
|
-
|
|
4062
|
-
currencyCode: currencyCode,
|
|
4063
|
-
currencySymbol: currencySymbol,
|
|
4064
|
-
currencyFormat: currencyFormat
|
|
4065
|
-
});
|
|
4066
|
-
case 42:
|
|
4059
|
+
case 34:
|
|
4060
|
+
return _context33.abrupt("return", _objectSpread(_objectSpread({}, settlement), {}, {
|
|
4061
|
+
payments: [payment]
|
|
4062
|
+
}));
|
|
4063
|
+
case 35:
|
|
4067
4064
|
case "end":
|
|
4068
4065
|
return _context33.stop();
|
|
4069
4066
|
}
|
|
@@ -4085,7 +4082,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4085
4082
|
value: (function () {
|
|
4086
4083
|
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
|
|
4087
4084
|
var _params$smallTicketDa, _this$otherParams18, _this$otherParams19, _this$otherParams20, _this$otherParams21;
|
|
4088
|
-
var virtualSettlement, inferredPaymentStatus, smallTicketDataFlag, virtualSettlementEnhancePayload, enhancePayload, submitParams;
|
|
4085
|
+
var isDeferredPayment, virtualPaymentSettlement, virtualSettlement, inferredPaymentStatus, smallTicketDataFlag, virtualSettlementEnhancePayload, configuredEnhancePayload, enhancePayload, submitParams;
|
|
4089
4086
|
return _regeneratorRuntime().wrap(function _callee34$(_context34) {
|
|
4090
4087
|
while (1) switch (_context34.prev = _context34.next) {
|
|
4091
4088
|
case 0:
|
|
@@ -4104,12 +4101,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4104
4101
|
freeze: true
|
|
4105
4102
|
});
|
|
4106
4103
|
case 5:
|
|
4107
|
-
|
|
4104
|
+
isDeferredPayment = (params === null || params === void 0 ? void 0 : params.paymentExecution) === 'deferred';
|
|
4105
|
+
if (!isDeferredPayment) {
|
|
4106
|
+
_context34.next = 10;
|
|
4107
|
+
break;
|
|
4108
|
+
}
|
|
4109
|
+
_context34.t0 = null;
|
|
4110
|
+
_context34.next = 13;
|
|
4111
|
+
break;
|
|
4112
|
+
case 10:
|
|
4113
|
+
_context34.next = 12;
|
|
4108
4114
|
return this.buildVirtualSettlementSubmitData();
|
|
4109
|
-
case
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
|
-
|
|
4115
|
+
case 12:
|
|
4116
|
+
_context34.t0 = _context34.sent;
|
|
4117
|
+
case 13:
|
|
4118
|
+
virtualPaymentSettlement = _context34.t0;
|
|
4119
|
+
virtualSettlement = isDeferredPayment ? this.buildVirtualSettlementOrderData() : virtualPaymentSettlement; // this.store.order.persistTempOrder();
|
|
4120
|
+
inferredPaymentStatus = isDeferredPayment ? undefined : this.getSubmitPaymentStatus(params === null || params === void 0 ? void 0 : params.paymentStatus);
|
|
4113
4121
|
smallTicketDataFlag = (_params$smallTicketDa = params === null || params === void 0 ? void 0 : params.smallTicketDataFlag) !== null && _params$smallTicketDa !== void 0 ? _params$smallTicketDa : this.getDefaultCheckoutSmallTicketDataFlag();
|
|
4114
4122
|
virtualSettlementEnhancePayload = virtualSettlement ? function (payload, ctx) {
|
|
4115
4123
|
var _callerPayload$metada, _currencySettlementCo;
|
|
@@ -4128,7 +4136,16 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4128
4136
|
currency_format: virtualSettlement.currencyFormat
|
|
4129
4137
|
});
|
|
4130
4138
|
} : params === null || params === void 0 ? void 0 : params.enhancePayload;
|
|
4131
|
-
|
|
4139
|
+
configuredEnhancePayload = this.buildSubmitPayloadEnhancerWithOpenDataConfig(virtualSettlementEnhancePayload); // Apply this last so neither a stale draft status nor a caller enhancer can
|
|
4140
|
+
// turn deferred submission into payment. The live wallet selection is untouched.
|
|
4141
|
+
enhancePayload = isDeferredPayment ? function (payload, ctx) {
|
|
4142
|
+
var enhancedPayload = configuredEnhancePayload ? configuredEnhancePayload(payload, ctx) : payload;
|
|
4143
|
+
var _paymentStatus = enhancedPayload.payment_status,
|
|
4144
|
+
orderPayload = _objectWithoutProperties(enhancedPayload, _excluded);
|
|
4145
|
+
return _objectSpread(_objectSpread({}, orderPayload), {}, {
|
|
4146
|
+
payments: []
|
|
4147
|
+
});
|
|
4148
|
+
} : configuredEnhancePayload;
|
|
4132
4149
|
submitParams = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
4133
4150
|
cacheId: this.cacheId,
|
|
4134
4151
|
platform: (_this$otherParams18 = this.otherParams) === null || _this$otherParams18 === void 0 ? void 0 : _this$otherParams18.platform,
|
|
@@ -4136,15 +4153,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4136
4153
|
channel: this.getSubmitOrderSalesChannel(),
|
|
4137
4154
|
type: (_this$otherParams21 = this.otherParams) === null || _this$otherParams21 === void 0 ? void 0 : _this$otherParams21.type,
|
|
4138
4155
|
request_unique_idempotency_token: this.store.order.generateIdempotencyToken()
|
|
4139
|
-
},
|
|
4140
|
-
payments:
|
|
4156
|
+
}, isDeferredPayment ? {
|
|
4157
|
+
payments: []
|
|
4158
|
+
} : virtualPaymentSettlement ? {
|
|
4159
|
+
payments: virtualPaymentSettlement.payments
|
|
4141
4160
|
} : (params === null || params === void 0 ? void 0 : params.payments) !== undefined ? {
|
|
4142
4161
|
payments: params.payments
|
|
4143
4162
|
} : {}), inferredPaymentStatus !== undefined ? {
|
|
4144
4163
|
paymentStatus: inferredPaymentStatus
|
|
4145
4164
|
} : {}), smallTicketDataFlag !== undefined ? {
|
|
4146
4165
|
smallTicketDataFlag: smallTicketDataFlag
|
|
4147
|
-
} : {}), virtualSettlement ? {
|
|
4166
|
+
} : {}), isDeferredPayment || virtualSettlement ? {
|
|
4148
4167
|
confirmPendingVoucherPayments: false
|
|
4149
4168
|
} : (params === null || params === void 0 ? void 0 : params.confirmPendingVoucherPayments) !== undefined ? {
|
|
4150
4169
|
confirmPendingVoucherPayments: params.confirmPendingVoucherPayments
|
|
@@ -4152,7 +4171,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4152
4171
|
enhancePayload: enhancePayload
|
|
4153
4172
|
} : {});
|
|
4154
4173
|
return _context34.abrupt("return", this.shouldUseCheckoutSyncTask() ? this.store.order.submitTempOrder(submitParams) : this.store.order.submitTempOrderAsync(submitParams));
|
|
4155
|
-
case
|
|
4174
|
+
case 22:
|
|
4156
4175
|
case "end":
|
|
4157
4176
|
return _context34.stop();
|
|
4158
4177
|
}
|
|
@@ -6460,20 +6479,33 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
6460
6479
|
}
|
|
6461
6480
|
throw new Error('order 模块未初始化');
|
|
6462
6481
|
case 3:
|
|
6463
|
-
|
|
6464
|
-
|
|
6465
|
-
|
|
6466
|
-
|
|
6467
|
-
|
|
6482
|
+
if (!(options === undefined)) {
|
|
6483
|
+
_context62.next = 9;
|
|
6484
|
+
break;
|
|
6485
|
+
}
|
|
6486
|
+
_context62.next = 6;
|
|
6487
|
+
return this.store.order.addProductToOrder(product, booking);
|
|
6488
|
+
case 6:
|
|
6489
|
+
_context62.t0 = _context62.sent;
|
|
6490
|
+
_context62.next = 12;
|
|
6491
|
+
break;
|
|
6468
6492
|
case 9:
|
|
6469
|
-
_context62.
|
|
6470
|
-
|
|
6471
|
-
|
|
6493
|
+
_context62.next = 11;
|
|
6494
|
+
return this.store.order.addProductToOrder(product, booking, options);
|
|
6495
|
+
case 11:
|
|
6496
|
+
_context62.t0 = _context62.sent;
|
|
6472
6497
|
case 12:
|
|
6498
|
+
products = _context62.t0;
|
|
6499
|
+
return _context62.abrupt("return", products);
|
|
6500
|
+
case 16:
|
|
6501
|
+
_context62.prev = 16;
|
|
6502
|
+
_context62.t1 = _context62["catch"](0);
|
|
6503
|
+
throw _context62.t1;
|
|
6504
|
+
case 19:
|
|
6473
6505
|
case "end":
|
|
6474
6506
|
return _context62.stop();
|
|
6475
6507
|
}
|
|
6476
|
-
}, _callee62, this, [[0,
|
|
6508
|
+
}, _callee62, this, [[0, 16]]);
|
|
6477
6509
|
}));
|
|
6478
6510
|
function addProductToOrder(_x51, _x52, _x53) {
|
|
6479
6511
|
return _addProductToOrder.apply(this, arguments);
|
|
@@ -6664,19 +6696,32 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
6664
6696
|
}
|
|
6665
6697
|
throw new Error('order 模块未初始化');
|
|
6666
6698
|
case 3:
|
|
6667
|
-
|
|
6699
|
+
if (!(options === undefined)) {
|
|
6700
|
+
_context67.next = 9;
|
|
6701
|
+
break;
|
|
6702
|
+
}
|
|
6703
|
+
_context67.next = 6;
|
|
6704
|
+
return this.store.order.removeProductsFromOrder(identities);
|
|
6705
|
+
case 6:
|
|
6706
|
+
_context67.t0 = _context67.sent;
|
|
6707
|
+
_context67.next = 12;
|
|
6708
|
+
break;
|
|
6709
|
+
case 9:
|
|
6710
|
+
_context67.next = 11;
|
|
6668
6711
|
return this.store.order.removeProductsFromOrder(identities, options);
|
|
6669
|
-
case 5:
|
|
6670
|
-
return _context67.abrupt("return", _context67.sent);
|
|
6671
|
-
case 8:
|
|
6672
|
-
_context67.prev = 8;
|
|
6673
|
-
_context67.t0 = _context67["catch"](0);
|
|
6674
|
-
throw _context67.t0;
|
|
6675
6712
|
case 11:
|
|
6713
|
+
_context67.t0 = _context67.sent;
|
|
6714
|
+
case 12:
|
|
6715
|
+
return _context67.abrupt("return", _context67.t0);
|
|
6716
|
+
case 15:
|
|
6717
|
+
_context67.prev = 15;
|
|
6718
|
+
_context67.t1 = _context67["catch"](0);
|
|
6719
|
+
throw _context67.t1;
|
|
6720
|
+
case 18:
|
|
6676
6721
|
case "end":
|
|
6677
6722
|
return _context67.stop();
|
|
6678
6723
|
}
|
|
6679
|
-
}, _callee67, this, [[0,
|
|
6724
|
+
}, _callee67, this, [[0, 15]]);
|
|
6680
6725
|
}));
|
|
6681
6726
|
function removeProductsFromOrder(_x59, _x60) {
|
|
6682
6727
|
return _removeProductsFromOrder.apply(this, arguments);
|
|
@@ -4,6 +4,8 @@ import type { ScanOrderLogInput as BaseSalesLogInput, ScanOrderLoggerProviderCon
|
|
|
4
4
|
import type { QuantityCheckResult, QuantityLimitResult } from '../../model/strategy/adapter/itemRule';
|
|
5
5
|
import type { QuotationCustomerScopeInfo } from '../../modules/Quotation/types';
|
|
6
6
|
import type { PaymentMethod } from '../../modules/Payment/types';
|
|
7
|
+
import type { OrderPaymentSource } from '../../modules/Order/types';
|
|
8
|
+
import type { SubmitPayloadEnhancer } from '../../modules/Order/utils';
|
|
7
9
|
/**
|
|
8
10
|
* BaseSales 流程 hook 后缀。
|
|
9
11
|
* 完整事件名应由当前模块名动态拼接,避免多个实例共享固定事件 key。
|
|
@@ -23,6 +25,15 @@ export type BaseSalesHookName = typeof BaseSalesHookNames[keyof typeof BaseSales
|
|
|
23
25
|
export declare function createBaseSalesHook(moduleName: string, hookName: BaseSalesHookName): string;
|
|
24
26
|
export type BaseSalesStatus = 'idle' | 'initializing' | 'ready' | 'error';
|
|
25
27
|
export type BaseSalesPaymentStatus = 'paid' | 'partially_paid' | 'unpaid' | 'payment_processing' | string;
|
|
28
|
+
export interface BaseSalesSubmitSalesOrderParams {
|
|
29
|
+
payments?: OrderPaymentSource[];
|
|
30
|
+
paymentStatus?: BaseSalesPaymentStatus;
|
|
31
|
+
smallTicketDataFlag?: number;
|
|
32
|
+
confirmPendingVoucherPayments?: boolean;
|
|
33
|
+
enhancePayload?: SubmitPayloadEnhancer;
|
|
34
|
+
/** Create the order without executing payment; payment status comes from the server. */
|
|
35
|
+
paymentExecution?: 'deferred';
|
|
36
|
+
}
|
|
26
37
|
export interface BaseSalesCashPaymentConfig {
|
|
27
38
|
available: boolean;
|
|
28
39
|
paymentMethod?: PaymentMethod;
|