@pisell/pisellos 2.3.20 → 2.3.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/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +16 -10
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +2 -1
- package/dist/modules/Order/index.js +17 -7
- package/dist/modules/Order/types.d.ts +1 -0
- package/dist/modules/Order/utils.js +16 -4
- package/dist/server/index.d.ts +5 -0
- package/dist/server/index.js +428 -255
- package/dist/server/modules/order/types.d.ts +4 -0
- package/dist/server/modules/products/index.d.ts +5 -1
- package/dist/server/modules/products/index.js +383 -315
- package/dist/server/modules/products/types.d.ts +4 -0
- package/dist/solution/BaseSales/index.d.ts +10 -0
- package/dist/solution/BaseSales/index.js +503 -428
- package/dist/solution/BaseSales/types.d.ts +6 -1
- package/dist/solution/BaseSales/types.js +1 -1
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +14 -1
- package/dist/solution/BookingTicket/index.js +42 -24
- package/lib/model/strategy/adapter/promotion/index.js +49 -0
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +5 -0
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +1 -0
- package/lib/modules/Order/index.js +22 -7
- package/lib/modules/Order/types.d.ts +1 -0
- package/lib/modules/Order/utils.js +17 -3
- package/lib/server/index.d.ts +5 -0
- package/lib/server/index.js +121 -2
- package/lib/server/modules/order/types.d.ts +4 -0
- package/lib/server/modules/products/index.d.ts +5 -1
- package/lib/server/modules/products/index.js +20 -0
- package/lib/server/modules/products/types.d.ts +4 -0
- package/lib/solution/BaseSales/index.d.ts +10 -0
- package/lib/solution/BaseSales/index.js +66 -23
- package/lib/solution/BaseSales/types.d.ts +6 -1
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +8 -0
- package/lib/solution/BookingTicket/index.js +15 -7
- package/package.json +1 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Discount } from '../../modules/Discount/types';
|
|
1
2
|
import { OrderModule, ProductList, QuotationModule, SalesSummaryModule, ScanOrderLoggerModule as BaseSalesLoggerModule, ScheduleModule } from '../../modules';
|
|
2
3
|
import type { ScanOrderLogInput as BaseSalesLogInput, ScanOrderLoggerProviderConfig as BaseSalesLoggerProviderConfig, ScanOrderLoggerProviderType as BaseSalesLoggerProviderType } from '../../modules/ScanOrderLogger/types';
|
|
3
4
|
import type { QuantityCheckResult, QuantityLimitResult } from '../../model/strategy/adapter/itemRule';
|
|
@@ -85,6 +86,8 @@ export interface BaseSalesOrderProduct extends BaseSalesOrderProductIdentity {
|
|
|
85
86
|
booking_uid?: string;
|
|
86
87
|
/** 多语言商品标题快照,随 tempOrder 提交到 checkout。 */
|
|
87
88
|
product_title?: BaseSalesLocalizedText;
|
|
89
|
+
/** 商品封面图快照,随 tempOrder 提交到 checkout。 */
|
|
90
|
+
product_cover?: string;
|
|
88
91
|
/**
|
|
89
92
|
* 行级扩展 metadata。价格相关的权威字段:
|
|
90
93
|
*
|
|
@@ -381,9 +384,11 @@ export interface BaseSalesLoggerRuntimeConfig {
|
|
|
381
384
|
}
|
|
382
385
|
export interface BaseSalesAddLogParams extends BaseSalesLogInput {
|
|
383
386
|
}
|
|
384
|
-
/** BaseSales.scanPromotionCode
|
|
387
|
+
/** BaseSales.scanPromotionCode 对外的轻量结果(UI 可用 getDiscountList 或 scannedDiscountList 补 Holder) */
|
|
385
388
|
export interface BaseSalesScanCodeResult {
|
|
386
389
|
isAvailable: boolean;
|
|
387
390
|
type?: 'server' | string;
|
|
388
391
|
unavailableReason?: 'time_limit' | string;
|
|
392
|
+
/** batchSearch 原始结果;isAvailable=false 时 discountList 可能未写入 store,Holder 补全需读此字段 */
|
|
393
|
+
scannedDiscountList?: Discount[];
|
|
389
394
|
}
|
|
@@ -37,4 +37,4 @@ export function createBaseSalesHook(moduleName, hookName) {
|
|
|
37
37
|
|
|
38
38
|
/** `/order/resource/occupy-detail` 单条 `occupy_details[i]` */
|
|
39
39
|
|
|
40
|
-
/** BaseSales.scanPromotionCode
|
|
40
|
+
/** BaseSales.scanPromotionCode 对外的轻量结果(UI 可用 getDiscountList 或 scannedDiscountList 补 Holder) */
|
|
@@ -30,6 +30,17 @@ function toPriceString(value) {
|
|
|
30
30
|
if (!Number.isFinite(parsedValue)) return fallback;
|
|
31
31
|
return parsedValue.toFixed(2);
|
|
32
32
|
}
|
|
33
|
+
function isBlankValue(value) {
|
|
34
|
+
return value === undefined || value === null || typeof value === 'string' && value.trim() === '';
|
|
35
|
+
}
|
|
36
|
+
function firstNonBlank() {
|
|
37
|
+
for (var _len = arguments.length, values = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
38
|
+
values[_key] = arguments[_key];
|
|
39
|
+
}
|
|
40
|
+
return values.find(function (value) {
|
|
41
|
+
return !isBlankValue(value);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
33
44
|
function normalizeOptionItems(optionItems) {
|
|
34
45
|
if (!Array.isArray(optionItems)) return [];
|
|
35
46
|
return optionItems.map(function (optionItem) {
|
|
@@ -166,7 +177,8 @@ export function transformBaseProductToOrderProduct(params) {
|
|
|
166
177
|
source_product_price: sourceProductPrice,
|
|
167
178
|
main_product_selling_price: mainProductSellingPrice,
|
|
168
179
|
main_product_original_price: mainProductOriginalPrice,
|
|
169
|
-
price_schema_version: 2
|
|
180
|
+
price_schema_version: 2,
|
|
181
|
+
holder_config: sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.holder_config
|
|
170
182
|
}, hasPriceOverride ? {
|
|
171
183
|
price_override: String(payload.price_override),
|
|
172
184
|
is_manual_discount: 1
|
|
@@ -198,6 +210,7 @@ export function transformBaseProductToOrderProduct(params) {
|
|
|
198
210
|
metadata: metadata,
|
|
199
211
|
note: payload.note != null ? String(payload.note) : '',
|
|
200
212
|
product_title: productTitle,
|
|
213
|
+
product_cover: firstNonBlank(matchedVariant === null || matchedVariant === void 0 ? void 0 : matchedVariant.cover, sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.cover),
|
|
201
214
|
_origin: _objectSpread(_objectSpread({}, sourceProduct || {}), {}, {
|
|
202
215
|
callbackData: payload
|
|
203
216
|
})
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
var _excluded = ["id"],
|
|
2
2
|
_excluded2 = ["product_id"],
|
|
3
3
|
_excluded3 = ["product_id"];
|
|
4
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
5
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
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
6
6
|
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; }
|
|
7
7
|
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; }
|
|
8
8
|
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; }
|
|
@@ -549,7 +549,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
549
549
|
key: "scanPromotionCode",
|
|
550
550
|
value: function () {
|
|
551
551
|
var _scanPromotionCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(code, customerId) {
|
|
552
|
-
var raw;
|
|
552
|
+
var raw, scannedList, extractedCustomerId, hasOrderCustomer;
|
|
553
553
|
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
554
554
|
while (1) switch (_context7.prev = _context7.next) {
|
|
555
555
|
case 0:
|
|
@@ -563,26 +563,34 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
563
563
|
return this.store.order.scanCode(code, customerId);
|
|
564
564
|
case 4:
|
|
565
565
|
raw = _context7.sent;
|
|
566
|
-
|
|
566
|
+
scannedList = raw.scannedDiscountList || [];
|
|
567
|
+
extractedCustomerId = this.getDiscountCustomerId(scannedList);
|
|
568
|
+
hasOrderCustomer = Boolean(this.store.order.getOrderCustomer()); // 缺 Holder 等场景 isAvailable=false,但仍需把 Pass 归属客户带入订单,供 Holder 弹窗使用。
|
|
569
|
+
if (!(!hasOrderCustomer && extractedCustomerId)) {
|
|
567
570
|
_context7.next = 11;
|
|
568
571
|
break;
|
|
569
572
|
}
|
|
570
|
-
_context7.next =
|
|
571
|
-
return this.hydrateOrderCustomerFromScanDiscounts(
|
|
572
|
-
case
|
|
573
|
-
|
|
573
|
+
_context7.next = 11;
|
|
574
|
+
return this.hydrateOrderCustomerFromScanDiscounts(scannedList);
|
|
575
|
+
case 11:
|
|
576
|
+
if (!raw.isAvailable) {
|
|
577
|
+
_context7.next = 15;
|
|
578
|
+
break;
|
|
579
|
+
}
|
|
580
|
+
_context7.next = 14;
|
|
574
581
|
return this.store.order.recalculateSummary({
|
|
575
582
|
createIfMissing: true
|
|
576
583
|
});
|
|
577
|
-
case
|
|
584
|
+
case 14:
|
|
578
585
|
this.store.order.persistTempOrder();
|
|
579
|
-
case
|
|
586
|
+
case 15:
|
|
580
587
|
return _context7.abrupt("return", {
|
|
581
588
|
isAvailable: raw.isAvailable,
|
|
582
589
|
type: raw.type,
|
|
583
|
-
unavailableReason: raw.unavailableReason
|
|
590
|
+
unavailableReason: raw.unavailableReason,
|
|
591
|
+
scannedDiscountList: raw.scannedDiscountList
|
|
584
592
|
});
|
|
585
|
-
case
|
|
593
|
+
case 16:
|
|
586
594
|
case "end":
|
|
587
595
|
return _context7.stop();
|
|
588
596
|
}
|
|
@@ -641,12 +649,22 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
641
649
|
}, {
|
|
642
650
|
key: "getDiscountCustomerId",
|
|
643
651
|
value: function getDiscountCustomerId(discounts) {
|
|
644
|
-
var
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
652
|
+
var _iterator = _createForOfIteratorHelper(discounts),
|
|
653
|
+
_step;
|
|
654
|
+
try {
|
|
655
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
656
|
+
var item = _step.value;
|
|
657
|
+
var topLevelId = Number(item.customer_id);
|
|
658
|
+
if (Number.isFinite(topLevelId) && topLevelId > 0) {
|
|
659
|
+
return topLevelId;
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
} catch (err) {
|
|
663
|
+
_iterator.e(err);
|
|
664
|
+
} finally {
|
|
665
|
+
_iterator.f();
|
|
666
|
+
}
|
|
667
|
+
return null;
|
|
650
668
|
}
|
|
651
669
|
}, {
|
|
652
670
|
key: "resolveCustomerByDiscountCustomerId",
|
|
@@ -2468,7 +2486,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
2468
2486
|
var _addAddTimeProductsToBooking = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(input) {
|
|
2469
2487
|
var _this7 = this,
|
|
2470
2488
|
_input$bookingPatch;
|
|
2471
|
-
var bookingUid, orderLines, coveredMinutes, bookingTimePatch, result,
|
|
2489
|
+
var bookingUid, orderLines, coveredMinutes, bookingTimePatch, result, _iterator2, _step2, line;
|
|
2472
2490
|
return _regeneratorRuntime().wrap(function _callee30$(_context30) {
|
|
2473
2491
|
while (1) switch (_context30.prev = _context30.next) {
|
|
2474
2492
|
case 0:
|
|
@@ -2508,15 +2526,15 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
2508
2526
|
}));
|
|
2509
2527
|
case 11:
|
|
2510
2528
|
result = [];
|
|
2511
|
-
|
|
2529
|
+
_iterator2 = _createForOfIteratorHelper(orderLines);
|
|
2512
2530
|
_context30.prev = 13;
|
|
2513
|
-
|
|
2531
|
+
_iterator2.s();
|
|
2514
2532
|
case 15:
|
|
2515
|
-
if ((
|
|
2533
|
+
if ((_step2 = _iterator2.n()).done) {
|
|
2516
2534
|
_context30.next = 29;
|
|
2517
2535
|
break;
|
|
2518
2536
|
}
|
|
2519
|
-
line =
|
|
2537
|
+
line = _step2.value;
|
|
2520
2538
|
_context30.t0 = result.splice;
|
|
2521
2539
|
_context30.t1 = result;
|
|
2522
2540
|
_context30.t2 = [0, result.length];
|
|
@@ -2537,10 +2555,10 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
2537
2555
|
case 31:
|
|
2538
2556
|
_context30.prev = 31;
|
|
2539
2557
|
_context30.t7 = _context30["catch"](13);
|
|
2540
|
-
|
|
2558
|
+
_iterator2.e(_context30.t7);
|
|
2541
2559
|
case 34:
|
|
2542
2560
|
_context30.prev = 34;
|
|
2543
|
-
|
|
2561
|
+
_iterator2.f();
|
|
2544
2562
|
return _context30.finish(34);
|
|
2545
2563
|
case 37:
|
|
2546
2564
|
return _context30.abrupt("return", result);
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/model/strategy/adapter/promotion/index.ts
|
|
30
|
+
var promotion_exports = {};
|
|
31
|
+
__export(promotion_exports, {
|
|
32
|
+
BUY_X_GET_Y_FREE_STRATEGY: () => import_examples.BUY_X_GET_Y_FREE_STRATEGY,
|
|
33
|
+
PromotionAdapter: () => import_adapter.PromotionAdapter,
|
|
34
|
+
PromotionEvaluator: () => import_evaluator.PromotionEvaluator,
|
|
35
|
+
X_ITEMS_FOR_Y_PRICE_STRATEGY: () => import_examples.X_ITEMS_FOR_Y_PRICE_STRATEGY,
|
|
36
|
+
default: () => import_adapter2.default
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(promotion_exports);
|
|
39
|
+
var import_evaluator = require("./evaluator");
|
|
40
|
+
var import_adapter = require("./adapter");
|
|
41
|
+
var import_adapter2 = __toESM(require("./adapter"));
|
|
42
|
+
var import_examples = require("./examples");
|
|
43
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
44
|
+
0 && (module.exports = {
|
|
45
|
+
BUY_X_GET_Y_FREE_STRATEGY,
|
|
46
|
+
PromotionAdapter,
|
|
47
|
+
PromotionEvaluator,
|
|
48
|
+
X_ITEMS_FOR_Y_PRICE_STRATEGY
|
|
49
|
+
});
|
|
@@ -136,6 +136,9 @@ function resolveProductTitle(product, booking, sourceProduct) {
|
|
|
136
136
|
const metadata = product.metadata || {};
|
|
137
137
|
return (sourceProduct == null ? void 0 : sourceProduct.title) ?? (sourceProduct == null ? void 0 : sourceProduct.name) ?? metadata.product_title ?? metadata.product_name ?? ((_a = booking == null ? void 0 : booking.product) == null ? void 0 : _a.title) ?? ((_b = booking == null ? void 0 : booking.detail) == null ? void 0 : _b.product_title) ?? "";
|
|
138
138
|
}
|
|
139
|
+
function resolveProductCover(product, booking, sourceProduct) {
|
|
140
|
+
return (sourceProduct == null ? void 0 : sourceProduct.cover) ?? product.product_cover ?? "";
|
|
141
|
+
}
|
|
139
142
|
function resolveMainProductPrice(product, fallback) {
|
|
140
143
|
const metadata = product.metadata || {};
|
|
141
144
|
const value = metadata.main_product_original_price ?? metadata.source_product_price;
|
|
@@ -195,6 +198,7 @@ function buildCacheItemFromOrderLine(input) {
|
|
|
195
198
|
const capacity = resolveCapacityFromBooking(booking);
|
|
196
199
|
const holderId = ((_a = booking.metadata) == null ? void 0 : _a.holder_id) ?? booking.holder_id;
|
|
197
200
|
const productTitle = resolveProductTitle(product, booking, sourceProduct);
|
|
201
|
+
const productCover = resolveProductCover(product, booking, sourceProduct);
|
|
198
202
|
const productOptionString = (0, import_orderLineDisplay.buildProductOptionStringFromOrderLine)(product);
|
|
199
203
|
const other = {
|
|
200
204
|
product_variant_id: product.product_variant_id ?? 0,
|
|
@@ -214,6 +218,7 @@ function buildCacheItemFromOrderLine(input) {
|
|
|
214
218
|
sub_type: booking.sub_type,
|
|
215
219
|
quantity: product.num ?? 1,
|
|
216
220
|
product_name: productTitle,
|
|
221
|
+
product_cover: productCover,
|
|
217
222
|
note: product.note ?? ((_b = booking == null ? void 0 : booking.detail) == null ? void 0 : _b.note) ?? "",
|
|
218
223
|
price: mainProductPrice,
|
|
219
224
|
total: selling,
|
|
@@ -136,6 +136,7 @@ function buildNormalProductCacheItemFromOrderLine(input) {
|
|
|
136
136
|
product_id: resolvedId,
|
|
137
137
|
_id: uid,
|
|
138
138
|
title: (sourceProduct == null ? void 0 : sourceProduct.title) ?? product.product_title ?? "",
|
|
139
|
+
cover: (sourceProduct == null ? void 0 : sourceProduct.cover) ?? product.product_cover ?? "",
|
|
139
140
|
price: (sourceProduct == null ? void 0 : sourceProduct.price) ?? sourcePrice,
|
|
140
141
|
selling_price: product.selling_price,
|
|
141
142
|
original_price: product.original_price,
|
|
@@ -547,7 +547,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
547
547
|
};
|
|
548
548
|
}
|
|
549
549
|
applyDiscount(options) {
|
|
550
|
-
var _a, _b, _c
|
|
550
|
+
var _a, _b, _c;
|
|
551
551
|
const tempOrder = this.store.tempOrder;
|
|
552
552
|
if (!tempOrder)
|
|
553
553
|
return;
|
|
@@ -560,13 +560,12 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
560
560
|
const rulesModule = this.store.rules;
|
|
561
561
|
if (!rulesModule)
|
|
562
562
|
return;
|
|
563
|
-
const holders = ((_b = tempOrder.holder) == null ? void 0 : _b.form_record) || [];
|
|
564
563
|
const result = rulesModule.calcDiscount({
|
|
565
564
|
productList: tempOrder.products,
|
|
566
565
|
discountList,
|
|
567
|
-
holders,
|
|
566
|
+
holders: [],
|
|
568
567
|
isFormSubject: (product) => (0, import_utils.resolveIsFormSubject)(tempOrder, product),
|
|
569
|
-
orderTotalAmount: Number(((
|
|
568
|
+
orderTotalAmount: Number(((_b = this.store.summary) == null ? void 0 : _b.total_amount) || 0)
|
|
570
569
|
}, {
|
|
571
570
|
reapplyBookingDiscountProductUids: options == null ? void 0 : options.reapplyBookingDiscountProductUids
|
|
572
571
|
});
|
|
@@ -597,7 +596,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
597
596
|
result.productList || tempOrder.products,
|
|
598
597
|
result.discountList
|
|
599
598
|
);
|
|
600
|
-
(
|
|
599
|
+
(_c = this.store.discount) == null ? void 0 : _c.setDiscountList(result.discountList);
|
|
601
600
|
}
|
|
602
601
|
this.hasActiveCustomerBoundDiscount = (tempOrder.products || []).some(
|
|
603
602
|
(product) => this.productHasCustomerBoundDiscount(product)
|
|
@@ -1489,6 +1488,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
1489
1488
|
}
|
|
1490
1489
|
restoreOriginalSnapshotIfProductsUnchanged(tempOrder, snapshot) {
|
|
1491
1490
|
const currentFingerprint = this.buildOrderProductsFingerprint(tempOrder.products);
|
|
1491
|
+
const manualDepositOverride = this.getManualDepositOverride(tempOrder);
|
|
1492
1492
|
if (currentFingerprint !== snapshot.productFingerprint) {
|
|
1493
1493
|
const currentStructuralFingerprint = this.buildOrderProductsStructuralFingerprint(tempOrder.products);
|
|
1494
1494
|
const snapshotStructuralFingerprint = this.buildOrderProductsStructuralFingerprint(
|
|
@@ -1497,11 +1497,24 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
1497
1497
|
if (currentStructuralFingerprint !== snapshotStructuralFingerprint)
|
|
1498
1498
|
return null;
|
|
1499
1499
|
}
|
|
1500
|
-
|
|
1500
|
+
let summary = {
|
|
1501
1501
|
...(0, import_utils.createEmptySummary)(),
|
|
1502
1502
|
...(0, import_lodash_es.cloneDeep)(snapshot.summary || {})
|
|
1503
1503
|
};
|
|
1504
|
-
|
|
1504
|
+
const shouldUseManualDepositOverride = Boolean(
|
|
1505
|
+
manualDepositOverride && manualDepositOverride.productStructuralFingerprint === this.buildOrderProductsStructuralFingerprint(tempOrder.products)
|
|
1506
|
+
);
|
|
1507
|
+
if (shouldUseManualDepositOverride) {
|
|
1508
|
+
summary = this.applyDepositAmountToSummary(
|
|
1509
|
+
tempOrder,
|
|
1510
|
+
summary,
|
|
1511
|
+
manualDepositOverride.amount
|
|
1512
|
+
);
|
|
1513
|
+
} else if (manualDepositOverride) {
|
|
1514
|
+
this.clearManualDepositOverride(tempOrder);
|
|
1515
|
+
}
|
|
1516
|
+
const isPayableAmountUnchanged = this.isSnapshotPayableAmountUnchanged(tempOrder, snapshot, summary);
|
|
1517
|
+
if (!isPayableAmountUnchanged)
|
|
1505
1518
|
return null;
|
|
1506
1519
|
if (Array.isArray(snapshot.products)) {
|
|
1507
1520
|
tempOrder.products = (0, import_lodash_es.cloneDeep)(snapshot.products);
|
|
@@ -2973,6 +2986,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
2973
2986
|
return bundle;
|
|
2974
2987
|
return {
|
|
2975
2988
|
...bundle,
|
|
2989
|
+
...(bundle.cover === void 0 || bundle.cover === null || bundle.cover === "") && previous.cover !== void 0 && previous.cover !== null && previous.cover !== "" ? { cover: previous.cover } : {},
|
|
2976
2990
|
price: previous.price,
|
|
2977
2991
|
custom_price: previous.custom_price,
|
|
2978
2992
|
bundle_payment_price: previous.bundle_payment_price,
|
|
@@ -4221,6 +4235,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
4221
4235
|
if (!existingIdentity) {
|
|
4222
4236
|
row.metadata.unique_identification_number = (0, import_utils.createUuidV4)();
|
|
4223
4237
|
}
|
|
4238
|
+
row.metadata.is_edit_for_runtime = true;
|
|
4224
4239
|
const normalized = (0, import_utils3.normalizeOrderProduct)(row);
|
|
4225
4240
|
normalized.discount_list = (0, import_utils.normalizeOrderProductDiscountList)(
|
|
4226
4241
|
normalized.discount_list
|
|
@@ -495,13 +495,17 @@ function createDefaultOrderRulesHooks() {
|
|
|
495
495
|
const current = currentByIdentity.get(getBundleIdentity(bundle));
|
|
496
496
|
if (!current)
|
|
497
497
|
return bundle;
|
|
498
|
+
const bundleWithDisplayFields = {
|
|
499
|
+
...bundle,
|
|
500
|
+
...isEmptyOrderProductDisplayValue(bundle.cover) && !isEmptyOrderProductDisplayValue(current.cover) ? { cover: current.cover } : {}
|
|
501
|
+
};
|
|
498
502
|
const isProductPriceBundle = (bundle.price_type_ext ?? current.price_type_ext) === "product_price";
|
|
499
503
|
if (!isProductPriceBundle)
|
|
500
|
-
return
|
|
504
|
+
return bundleWithDisplayFields;
|
|
501
505
|
const sourcePrice = current.price ?? current.custom_price ?? current.original_price ?? current.bundle_selling_price;
|
|
502
506
|
const originalPrice = current.original_price ?? current.product_price ?? current.price ?? current.custom_price ?? sourcePrice;
|
|
503
507
|
return {
|
|
504
|
-
...
|
|
508
|
+
...bundleWithDisplayFields,
|
|
505
509
|
...sourcePrice !== void 0 ? { price: sourcePrice } : {},
|
|
506
510
|
...originalPrice !== void 0 ? { original_price: originalPrice } : {},
|
|
507
511
|
...current.original_total !== void 0 ? { original_total: current.original_total } : {}
|
|
@@ -745,6 +749,7 @@ function formatSubmitBundleItems(bundle) {
|
|
|
745
749
|
bundle_group_id: (rawBundle == null ? void 0 : rawBundle.bundle_group_id) ?? (rawBundle == null ? void 0 : rawBundle.group_id),
|
|
746
750
|
bundle_id: (rawBundle == null ? void 0 : rawBundle.bundle_id) ?? (rawBundle == null ? void 0 : rawBundle.id),
|
|
747
751
|
bundle_product_id: (rawBundle == null ? void 0 : rawBundle.bundle_product_id) ?? (rawBundle == null ? void 0 : rawBundle._bundle_product_id),
|
|
752
|
+
cover: rawBundle.cover,
|
|
748
753
|
metadata: {
|
|
749
754
|
...submitMetadata,
|
|
750
755
|
...hasSubmitBundleDiscounts && bundleMapId !== void 0 ? { custom_product_bundle_map_id: bundleMapId } : {},
|
|
@@ -803,6 +808,9 @@ function normalizeSubmitProduct(product) {
|
|
|
803
808
|
if (rawMetadata.is_rule !== void 0) {
|
|
804
809
|
cleanMetadata.is_rule = rawMetadata.is_rule;
|
|
805
810
|
}
|
|
811
|
+
if (rawMetadata.holder_config !== void 0) {
|
|
812
|
+
cleanMetadata.holder_config = rawMetadata.holder_config;
|
|
813
|
+
}
|
|
806
814
|
const productSku = {
|
|
807
815
|
...submitProduct.product_sku && typeof submitProduct.product_sku === "object" ? submitProduct.product_sku : {},
|
|
808
816
|
option: formatSubmitOptionItems((_a = submitProduct.product_sku) == null ? void 0 : _a.option)
|
|
@@ -1159,11 +1167,16 @@ function isHolderConfigRequired(holderConfig) {
|
|
|
1159
1167
|
return Number(holderConfig.required) === 1;
|
|
1160
1168
|
}
|
|
1161
1169
|
function productRequiresFormSubject(tempOrder, product) {
|
|
1170
|
+
var _a, _b;
|
|
1171
|
+
const _orderProduct = (_a = tempOrder == null ? void 0 : tempOrder.products) == null ? void 0 : _a.find((item) => {
|
|
1172
|
+
return item.metadata.unique_identification_number === product._id || item.product_id === product.id;
|
|
1173
|
+
});
|
|
1162
1174
|
const runtimeOrigin = getRuntimeProductOrigin(tempOrder, product);
|
|
1163
|
-
return isHolderConfigRequired(
|
|
1175
|
+
return isHolderConfigRequired((_b = _orderProduct == null ? void 0 : _orderProduct.metadata) == null ? void 0 : _b.holder_config) || isHolderConfigRequired(runtimeOrigin == null ? void 0 : runtimeOrigin.holder_config) || isHolderConfigRequired(product == null ? void 0 : product.holder_config);
|
|
1164
1176
|
}
|
|
1165
1177
|
function resolveIsFormSubject(tempOrder, product) {
|
|
1166
1178
|
var _a;
|
|
1179
|
+
debugger;
|
|
1167
1180
|
if (((_a = tempOrder == null ? void 0 : tempOrder.holder) == null ? void 0 : _a.type) === "form")
|
|
1168
1181
|
return true;
|
|
1169
1182
|
if (product)
|
|
@@ -1192,6 +1205,7 @@ function mergeOrderProductDisplayFields(previous, next) {
|
|
|
1192
1205
|
"product_name",
|
|
1193
1206
|
"product_cover",
|
|
1194
1207
|
"cover",
|
|
1208
|
+
"product_cover",
|
|
1195
1209
|
"variant_title",
|
|
1196
1210
|
"product_sku",
|
|
1197
1211
|
"payment_price"
|
package/lib/server/index.d.ts
CHANGED
|
@@ -445,6 +445,11 @@ declare class Server {
|
|
|
445
445
|
private sumPaidOrderPayments;
|
|
446
446
|
private toAmountNumber;
|
|
447
447
|
private buildSmallTicketProductMap;
|
|
448
|
+
private collectSalesDetailProductIds;
|
|
449
|
+
private buildSalesDetailProductSnapshotMap;
|
|
450
|
+
private withProductCatalogSnapshots;
|
|
451
|
+
private withBundleCatalogSnapshots;
|
|
452
|
+
private withSalesDetailProductSnapshots;
|
|
448
453
|
private withPendingSyncProductTitles;
|
|
449
454
|
private buildProductTitleSnapshot;
|
|
450
455
|
private getProductTitleSnapshotCurrentLocale;
|
package/lib/server/index.js
CHANGED
|
@@ -769,12 +769,13 @@ var Server = class {
|
|
|
769
769
|
if (!this.shouldForceRemoteSalesDetail(data)) {
|
|
770
770
|
const localOrder = await this.order.getLocalOrderByLookup(lookup);
|
|
771
771
|
if (localOrder) {
|
|
772
|
+
const enrichedOrder = await this.withSalesDetailProductSnapshots(localOrder);
|
|
772
773
|
this.logInfo("handleOrderSalesDetail: 命中本地订单", { lookup });
|
|
773
774
|
return {
|
|
774
775
|
code: 200,
|
|
775
776
|
status: true,
|
|
776
777
|
message: "",
|
|
777
|
-
data:
|
|
778
|
+
data: enrichedOrder
|
|
778
779
|
};
|
|
779
780
|
}
|
|
780
781
|
}
|
|
@@ -821,11 +822,12 @@ var Server = class {
|
|
|
821
822
|
};
|
|
822
823
|
}
|
|
823
824
|
this.logInfo("handleOrderSalesDetail: 远端订单已同步到本地", { lookup });
|
|
825
|
+
const enrichedOrder = await this.withSalesDetailProductSnapshots(savedOrder);
|
|
824
826
|
return {
|
|
825
827
|
code: 200,
|
|
826
828
|
status: true,
|
|
827
829
|
message: "",
|
|
828
|
-
data:
|
|
830
|
+
data: enrichedOrder
|
|
829
831
|
};
|
|
830
832
|
} catch (error) {
|
|
831
833
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
@@ -3231,6 +3233,123 @@ var Server = class {
|
|
|
3231
3233
|
return map;
|
|
3232
3234
|
}, {});
|
|
3233
3235
|
}
|
|
3236
|
+
collectSalesDetailProductIds(order) {
|
|
3237
|
+
const products = Array.isArray(order == null ? void 0 : order.products) ? order.products : [];
|
|
3238
|
+
const productIds = /* @__PURE__ */ new Set();
|
|
3239
|
+
const addProductId = (rawProductId) => {
|
|
3240
|
+
if (rawProductId === void 0 || rawProductId === null || rawProductId === "")
|
|
3241
|
+
return;
|
|
3242
|
+
const productId = Number(rawProductId);
|
|
3243
|
+
if (Number.isFinite(productId))
|
|
3244
|
+
productIds.add(productId);
|
|
3245
|
+
};
|
|
3246
|
+
products.forEach((product) => {
|
|
3247
|
+
addProductId((product == null ? void 0 : product.product_id) ?? (product == null ? void 0 : product.id));
|
|
3248
|
+
if (Array.isArray(product == null ? void 0 : product.product_bundle)) {
|
|
3249
|
+
product.product_bundle.forEach((bundle) => {
|
|
3250
|
+
addProductId((bundle == null ? void 0 : bundle.bundle_product_id) ?? (bundle == null ? void 0 : bundle._bundle_product_id) ?? (bundle == null ? void 0 : bundle.product_id));
|
|
3251
|
+
});
|
|
3252
|
+
}
|
|
3253
|
+
});
|
|
3254
|
+
return Array.from(productIds);
|
|
3255
|
+
}
|
|
3256
|
+
async buildSalesDetailProductSnapshotMap(order) {
|
|
3257
|
+
var _a;
|
|
3258
|
+
const productIds = this.collectSalesDetailProductIds(order);
|
|
3259
|
+
const getSnapshots = (_a = this.products) == null ? void 0 : _a.getProductSnapshotsByIds;
|
|
3260
|
+
if (!productIds.length || typeof getSnapshots !== "function")
|
|
3261
|
+
return {};
|
|
3262
|
+
try {
|
|
3263
|
+
return await getSnapshots.call(this.products, productIds);
|
|
3264
|
+
} catch (error) {
|
|
3265
|
+
this.logWarning("buildSalesDetailProductSnapshotMap: 查询本地商品快照失败", {
|
|
3266
|
+
product_ids: productIds,
|
|
3267
|
+
error: error instanceof Error ? error.message : String(error)
|
|
3268
|
+
});
|
|
3269
|
+
return {};
|
|
3270
|
+
}
|
|
3271
|
+
}
|
|
3272
|
+
withProductCatalogSnapshots(product, snapshotMap) {
|
|
3273
|
+
if (!product || typeof product !== "object")
|
|
3274
|
+
return product;
|
|
3275
|
+
const rawProductId = (product == null ? void 0 : product.product_id) ?? (product == null ? void 0 : product.id);
|
|
3276
|
+
if (rawProductId === void 0 || rawProductId === null || rawProductId === "")
|
|
3277
|
+
return product;
|
|
3278
|
+
const productId = Number(rawProductId);
|
|
3279
|
+
if (!Number.isFinite(productId))
|
|
3280
|
+
return product;
|
|
3281
|
+
const snapshot = snapshotMap[String(productId)];
|
|
3282
|
+
if (!snapshot)
|
|
3283
|
+
return product;
|
|
3284
|
+
const shouldFillCover = (product.product_cover === void 0 || product.product_cover === null || product.product_cover === "") && snapshot.cover !== void 0 && snapshot.cover !== null && snapshot.cover !== "";
|
|
3285
|
+
const metadata = product.metadata && typeof product.metadata === "object" ? product.metadata : {};
|
|
3286
|
+
const shouldFillHolderConfig = (metadata.holder_config === void 0 || metadata.holder_config === null) && snapshot.holder_config !== void 0 && snapshot.holder_config !== null;
|
|
3287
|
+
if (!shouldFillCover && !shouldFillHolderConfig)
|
|
3288
|
+
return product;
|
|
3289
|
+
return {
|
|
3290
|
+
...product,
|
|
3291
|
+
...shouldFillCover ? { product_cover: snapshot.cover } : {},
|
|
3292
|
+
...shouldFillHolderConfig ? {
|
|
3293
|
+
metadata: {
|
|
3294
|
+
...metadata,
|
|
3295
|
+
holder_config: snapshot.holder_config
|
|
3296
|
+
}
|
|
3297
|
+
} : {}
|
|
3298
|
+
};
|
|
3299
|
+
}
|
|
3300
|
+
withBundleCatalogSnapshots(product, snapshotMap) {
|
|
3301
|
+
if (!Array.isArray(product == null ? void 0 : product.product_bundle))
|
|
3302
|
+
return product;
|
|
3303
|
+
let hasChanged = false;
|
|
3304
|
+
const productBundle = product.product_bundle.map((bundle) => {
|
|
3305
|
+
if (!bundle || typeof bundle !== "object")
|
|
3306
|
+
return bundle;
|
|
3307
|
+
const rawProductId = (bundle == null ? void 0 : bundle.bundle_product_id) ?? (bundle == null ? void 0 : bundle._bundle_product_id) ?? (bundle == null ? void 0 : bundle.product_id);
|
|
3308
|
+
if (rawProductId === void 0 || rawProductId === null || rawProductId === "")
|
|
3309
|
+
return bundle;
|
|
3310
|
+
const productId = Number(rawProductId);
|
|
3311
|
+
if (!Number.isFinite(productId))
|
|
3312
|
+
return bundle;
|
|
3313
|
+
const snapshot = snapshotMap[String(productId)];
|
|
3314
|
+
const shouldFillCover = (bundle.cover === void 0 || bundle.cover === null || bundle.cover === "") && (snapshot == null ? void 0 : snapshot.cover) !== void 0 && snapshot.cover !== null && snapshot.cover !== "";
|
|
3315
|
+
if (!shouldFillCover)
|
|
3316
|
+
return bundle;
|
|
3317
|
+
hasChanged = true;
|
|
3318
|
+
return {
|
|
3319
|
+
...bundle,
|
|
3320
|
+
cover: snapshot.cover
|
|
3321
|
+
};
|
|
3322
|
+
});
|
|
3323
|
+
if (!hasChanged)
|
|
3324
|
+
return product;
|
|
3325
|
+
return {
|
|
3326
|
+
...product,
|
|
3327
|
+
product_bundle: productBundle
|
|
3328
|
+
};
|
|
3329
|
+
}
|
|
3330
|
+
async withSalesDetailProductSnapshots(order) {
|
|
3331
|
+
const products = Array.isArray(order == null ? void 0 : order.products) ? order.products : null;
|
|
3332
|
+
if (!(products == null ? void 0 : products.length))
|
|
3333
|
+
return order;
|
|
3334
|
+
const snapshotMap = await this.buildSalesDetailProductSnapshotMap(order);
|
|
3335
|
+
if (!Object.keys(snapshotMap).length)
|
|
3336
|
+
return order;
|
|
3337
|
+
let hasChanged = false;
|
|
3338
|
+
const enrichedProducts = products.map((product) => {
|
|
3339
|
+
const productWithBundleSnapshots = this.withBundleCatalogSnapshots(product, snapshotMap);
|
|
3340
|
+
const nextProduct = this.withProductCatalogSnapshots(productWithBundleSnapshots, snapshotMap);
|
|
3341
|
+
if (nextProduct !== product)
|
|
3342
|
+
hasChanged = true;
|
|
3343
|
+
return nextProduct;
|
|
3344
|
+
});
|
|
3345
|
+
if (!hasChanged)
|
|
3346
|
+
return order;
|
|
3347
|
+
const enrichedOrder = {
|
|
3348
|
+
...order,
|
|
3349
|
+
products: enrichedProducts
|
|
3350
|
+
};
|
|
3351
|
+
return enrichedOrder;
|
|
3352
|
+
}
|
|
3234
3353
|
withPendingSyncProductTitles(order, productMap) {
|
|
3235
3354
|
const products = Array.isArray(order.products) ? order.products : null;
|
|
3236
3355
|
if (!(products == null ? void 0 : products.length))
|
|
@@ -63,6 +63,8 @@ export interface OrderProductBundleItem {
|
|
|
63
63
|
bundle_group_id?: number;
|
|
64
64
|
/** 套餐商品 ID */
|
|
65
65
|
bundle_id?: number;
|
|
66
|
+
/** 套餐子商品封面图 */
|
|
67
|
+
cover?: string | null;
|
|
66
68
|
/** 套餐商品规格 ID */
|
|
67
69
|
bundle_variant_id?: number;
|
|
68
70
|
/** 数量 */
|
|
@@ -104,6 +106,8 @@ export interface OrderProductLineItem {
|
|
|
104
106
|
num: number;
|
|
105
107
|
/** 商品标题快照;本地待同步订单会补齐为多语言对象。 */
|
|
106
108
|
product_title?: OrderProductTitleSnapshot | string | null;
|
|
109
|
+
/** 商品封面图 */
|
|
110
|
+
product_cover?: string | null;
|
|
107
111
|
/** 多规格 ID。来源:Detail.product_variant_id */
|
|
108
112
|
product_variant_id?: number;
|
|
109
113
|
/**
|