@pisell/pisellos 2.2.190 → 2.2.192
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +2 -1
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +2 -7
- package/dist/modules/Cart/utils/cartProduct.js +13 -2
- package/dist/modules/Order/index.d.ts +1 -3
- package/dist/modules/Order/index.js +69 -95
- package/dist/modules/Order/types.d.ts +9 -6
- package/dist/modules/Order/utils.d.ts +9 -2
- package/dist/modules/Order/utils.js +36 -13
- package/dist/modules/SalesSummary/types.d.ts +3 -1
- package/dist/modules/SalesSummary/utils.js +7 -3
- package/dist/server/modules/order/index.d.ts +60 -7
- package/dist/server/modules/order/index.js +670 -178
- package/dist/server/modules/order/types.d.ts +0 -2
- package/dist/server/modules/products/index.d.ts +33 -6
- package/dist/server/modules/products/index.js +528 -231
- package/dist/solution/BaseSales/index.js +13 -7
- package/dist/solution/BaseSales/types.d.ts +8 -5
- package/dist/solution/BaseSales/types.js +2 -3
- package/dist/solution/BaseSales/utils/cartPromotion.js +7 -7
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +1 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +16 -13
- package/dist/solution/BaseSales/utils.d.ts +1 -1
- package/dist/solution/BaseSales/utils.js +22 -19
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/ScanOrder/index.js +7 -5
- package/dist/solution/ScanOrder/types.d.ts +8 -5
- package/dist/solution/ScanOrder/types.js +2 -3
- package/dist/solution/ScanOrder/utils.d.ts +1 -1
- package/dist/solution/ScanOrder/utils.js +26 -23
- package/dist/solution/VenueBooking/index.js +5 -3
- package/dist/solution/VenueBooking/sales-section-4-annotated.json +0 -2
- package/lib/model/strategy/adapter/promotion/index.js +0 -49
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +2 -1
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +2 -1
- package/lib/modules/Cart/utils/cartProduct.js +9 -2
- package/lib/modules/Order/index.d.ts +1 -3
- package/lib/modules/Order/index.js +45 -58
- package/lib/modules/Order/types.d.ts +9 -6
- package/lib/modules/Order/utils.d.ts +9 -2
- package/lib/modules/Order/utils.js +41 -10
- package/lib/modules/SalesSummary/types.d.ts +3 -1
- package/lib/modules/SalesSummary/utils.js +5 -3
- package/lib/server/modules/order/index.d.ts +60 -7
- package/lib/server/modules/order/index.js +350 -40
- package/lib/server/modules/order/types.d.ts +0 -2
- package/lib/server/modules/products/index.d.ts +33 -6
- package/lib/server/modules/products/index.js +159 -30
- package/lib/solution/BaseSales/index.js +14 -5
- package/lib/solution/BaseSales/types.d.ts +8 -5
- package/lib/solution/BaseSales/utils/cartPromotion.js +6 -6
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +1 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +21 -14
- package/lib/solution/BaseSales/utils.d.ts +1 -1
- package/lib/solution/BaseSales/utils.js +11 -7
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/ScanOrder/index.js +4 -4
- package/lib/solution/ScanOrder/types.d.ts +8 -5
- package/lib/solution/ScanOrder/utils.d.ts +1 -1
- package/lib/solution/ScanOrder/utils.js +12 -8
- package/lib/solution/VenueBooking/index.js +2 -2
- package/lib/solution/VenueBooking/sales-section-4-annotated.json +0 -2
- package/package.json +1 -1
- package/dist/solution/Checkout/appointmentDemo.json +0 -1
- package/lib/solution/Checkout/appointmentDemo.json +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
var _excluded = ["unique_identification_number"],
|
|
2
|
-
_excluded2 = ["num", "
|
|
2
|
+
_excluded2 = ["num", "surcharge_fee", "discount_amount", "discount_type", "discountway", "product_discount_reason", "discount_per"],
|
|
3
3
|
_excluded3 = ["_extend", "relation_id", "table_form_id", "resource_id", "summary", "lastOrderInfo", "paid_amount", "shop_id", "shop_note", "shop_service_type", "start_time", "customer", "discount_list", "tax_fee", "total_amount", "total_refund_amount", "create_date", "holder_id"],
|
|
4
4
|
_excluded4 = ["collect_pax", "table_occupancy_duration"];
|
|
5
5
|
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; }
|
|
@@ -8,12 +8,12 @@ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableTo
|
|
|
8
8
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
9
9
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
10
10
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
11
|
+
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); }
|
|
11
12
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
12
13
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
13
14
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
14
15
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
15
16
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
16
|
-
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); }
|
|
17
17
|
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; } } }; }
|
|
18
18
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
19
19
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
@@ -59,9 +59,30 @@ export function composeLinePrice(params) {
|
|
|
59
59
|
}
|
|
60
60
|
return total.toDecimalPlaces(2).toFixed(2);
|
|
61
61
|
}
|
|
62
|
+
export function normalizeProductSkuOptions(options) {
|
|
63
|
+
if (!Array.isArray(options)) return [];
|
|
64
|
+
return options.map(function (option) {
|
|
65
|
+
var _normalized$add_price;
|
|
66
|
+
var normalized = _objectSpread({}, option && _typeof(option) === 'object' ? option : {});
|
|
67
|
+
var addPrice = (_normalized$add_price = normalized.add_price) !== null && _normalized$add_price !== void 0 ? _normalized$add_price : normalized.price;
|
|
68
|
+
if (addPrice !== undefined) normalized.add_price = addPrice;
|
|
69
|
+
delete normalized.price;
|
|
70
|
+
return normalized;
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
export function ensureProductSku(product) {
|
|
74
|
+
var rawSku = product !== null && product !== void 0 && product.product_sku && _typeof(product.product_sku) === 'object' ? product.product_sku : {};
|
|
75
|
+
return _objectSpread(_objectSpread({}, rawSku), {}, {
|
|
76
|
+
option: normalizeProductSkuOptions(rawSku.option)
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
export function getProductSkuOptions(product) {
|
|
80
|
+
return ensureProductSku(product).option;
|
|
81
|
+
}
|
|
62
82
|
|
|
63
83
|
/**
|
|
64
|
-
* 计算 option 单价合计:Σ(option.
|
|
84
|
+
* 计算 option 单价合计:Σ(option.add_price × option.num)。
|
|
85
|
+
* 兼容入参仍带旧 `price` 的调用方,但运行时归一化后只维护 `add_price`。
|
|
65
86
|
* 在新语义 v2 下,main_product_original_price = source_product_price + 本函数结果。
|
|
66
87
|
*/
|
|
67
88
|
export function sumOptionUnitPrice(options) {
|
|
@@ -71,8 +92,9 @@ export function sumOptionUnitPrice(options) {
|
|
|
71
92
|
_step2;
|
|
72
93
|
try {
|
|
73
94
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
95
|
+
var _opt$add_price;
|
|
74
96
|
var opt = _step2.value;
|
|
75
|
-
var price = new Decimal(Number(opt === null || opt === void 0 ? void 0 : opt.price) || 0);
|
|
97
|
+
var price = new Decimal(Number((_opt$add_price = opt === null || opt === void 0 ? void 0 : opt.add_price) !== null && _opt$add_price !== void 0 ? _opt$add_price : opt === null || opt === void 0 ? void 0 : opt.price) || 0);
|
|
76
98
|
var num = new Decimal(Number(opt === null || opt === void 0 ? void 0 : opt.num) || 0);
|
|
77
99
|
total = total.plus(price.times(num));
|
|
78
100
|
}
|
|
@@ -218,7 +240,7 @@ export function resolveEffectivePerUnitDiscount(product) {
|
|
|
218
240
|
});
|
|
219
241
|
if (hasPromoDiscountItem) return fromList;
|
|
220
242
|
var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
|
|
221
|
-
var optionSum = sumOptionUnitPrice(product
|
|
243
|
+
var optionSum = sumOptionUnitPrice(getProductSkuOptions(product)).toNumber();
|
|
222
244
|
|
|
223
245
|
// applyPromotion 写价后、Rules 剥离 promotion discount 的兜底
|
|
224
246
|
if (metadata.source_product_price != null && metadata.main_product_selling_price != null) {
|
|
@@ -274,7 +296,7 @@ export function createDefaultOrderRulesHooks() {
|
|
|
274
296
|
var _product$metadata, _product$metadata2, _product$metadata3, _product$metadata4, _product$metadata5, _metadataAny$_promoti;
|
|
275
297
|
// source_product_price 是权威源;兜底链:source → mainSelling − options(反推)→ 行 selling_price
|
|
276
298
|
var metadataAny = product.metadata || {};
|
|
277
|
-
var optionSum = sumOptionUnitPrice(product
|
|
299
|
+
var optionSum = sumOptionUnitPrice(getProductSkuOptions(product));
|
|
278
300
|
var sourcePrice;
|
|
279
301
|
if (metadataAny.source_product_price !== undefined) {
|
|
280
302
|
sourcePrice = String(metadataAny.source_product_price);
|
|
@@ -298,7 +320,7 @@ export function createDefaultOrderRulesHooks() {
|
|
|
298
320
|
// 否则同 SKU 不同小料会在 calcDiscount 重组时互相覆盖。
|
|
299
321
|
// 不透明 identity 契约下,normalizeOrderProduct / hydrate 已保证唯一值存在;
|
|
300
322
|
// 留 fingerprint 分支仅作 Rules 单测里直接传裸 product 时的兜底。
|
|
301
|
-
_id: (_product$metadata = product.metadata) !== null && _product$metadata !== void 0 && _product$metadata.unique_identification_number ? "".concat(product.product_id, "_").concat(product.product_variant_id, "_").concat(product.metadata.unique_identification_number) : "".concat(product.product_id, "_").concat(product.product_variant_id, "_").concat(buildProductLineFingerprint(product
|
|
323
|
+
_id: (_product$metadata = product.metadata) !== null && _product$metadata !== void 0 && _product$metadata.unique_identification_number ? "".concat(product.product_id, "_").concat(product.product_variant_id, "_").concat(product.metadata.unique_identification_number) : "".concat(product.product_id, "_").concat(product.product_variant_id, "_").concat(buildProductLineFingerprint(getProductSkuOptions(product), product.product_bundle)),
|
|
302
324
|
// Rules 内部 getProductTotalPrice / getProductOriginTotalPrice 会各自再叠加 bundle + option,
|
|
303
325
|
// 所以这里必须喂 source-level(不含 option、不含 bundle、不含折扣)单价,避免双加 option。
|
|
304
326
|
price: sourcePrice,
|
|
@@ -327,7 +349,7 @@ export function createDefaultOrderRulesHooks() {
|
|
|
327
349
|
var nextNum = Number((_ref14 = (_values$quantity = values.quantity) !== null && _values$quantity !== void 0 ? _values$quantity : product.num) !== null && _ref14 !== void 0 ? _ref14 : 1) || 1;
|
|
328
350
|
var metadataAny = product.metadata || {};
|
|
329
351
|
var existedSource = (_ref15 = (_metadataAny$source_p = metadataAny.source_product_price) !== null && _metadataAny$source_p !== void 0 ? _metadataAny$source_p : product.selling_price) !== null && _ref15 !== void 0 ? _ref15 : '0';
|
|
330
|
-
var nextOptions = product
|
|
352
|
+
var nextOptions = getProductSkuOptions(product);
|
|
331
353
|
var optionSum = sumOptionUnitPrice(nextOptions);
|
|
332
354
|
|
|
333
355
|
// Rules 返回的 main_product_selling_price / price / total 均为 source-level。
|
|
@@ -472,13 +494,14 @@ function formatSubmitOptionItems(options) {
|
|
|
472
494
|
if (!Array.isArray(options)) return [];
|
|
473
495
|
return options.map(function (d) {
|
|
474
496
|
var _d$add_price;
|
|
475
|
-
var option = {
|
|
497
|
+
var option = _objectSpread(_objectSpread({}, d && _typeof(d) === 'object' ? d : {}), {}, {
|
|
476
498
|
num: d === null || d === void 0 ? void 0 : d.num,
|
|
477
499
|
option_group_item_id: d === null || d === void 0 ? void 0 : d.option_group_item_id,
|
|
478
500
|
option_group_id: d === null || d === void 0 ? void 0 : d.option_group_id
|
|
479
|
-
};
|
|
501
|
+
});
|
|
480
502
|
var addPrice = (_d$add_price = d === null || d === void 0 ? void 0 : d.add_price) !== null && _d$add_price !== void 0 ? _d$add_price : d === null || d === void 0 ? void 0 : d.price;
|
|
481
503
|
if (addPrice !== undefined) option.add_price = String(addPrice);
|
|
504
|
+
delete option.price;
|
|
482
505
|
return option;
|
|
483
506
|
});
|
|
484
507
|
}
|
|
@@ -553,7 +576,6 @@ function normalizeSubmitProduct(product) {
|
|
|
553
576
|
_runtimeUid = _ref19.unique_identification_number,
|
|
554
577
|
submitProduct = _objectWithoutProperties(_ref19, _excluded);
|
|
555
578
|
var num = submitProduct.num,
|
|
556
|
-
productOptionItem = submitProduct.product_option_item,
|
|
557
579
|
_productSurchargeFee = submitProduct.surcharge_fee,
|
|
558
580
|
_deprecatedDiscountAmount = submitProduct.discount_amount,
|
|
559
581
|
_deprecatedDiscountType = submitProduct.discount_type,
|
|
@@ -561,6 +583,7 @@ function normalizeSubmitProduct(product) {
|
|
|
561
583
|
_deprecatedProductDiscountReason = submitProduct.product_discount_reason,
|
|
562
584
|
_deprecatedDiscountPer = submitProduct.discount_per,
|
|
563
585
|
productRest = _objectWithoutProperties(submitProduct, _excluded2);
|
|
586
|
+
delete productRest["product_".concat('option', "_item")];
|
|
564
587
|
var rawMetadata = submitProduct.metadata || {};
|
|
565
588
|
var bookingUid = rawMetadata.booking_uid;
|
|
566
589
|
var cleanMetadata = {};
|
|
@@ -582,7 +605,7 @@ function normalizeSubmitProduct(product) {
|
|
|
582
605
|
cleanMetadata.is_rule = rawMetadata.is_rule;
|
|
583
606
|
}
|
|
584
607
|
var productSku = _objectSpread(_objectSpread({}, submitProduct.product_sku && _typeof(submitProduct.product_sku) === 'object' ? submitProduct.product_sku : {}), {}, {
|
|
585
|
-
option: formatSubmitOptionItems(
|
|
608
|
+
option: formatSubmitOptionItems((_submitProduct$produc = submitProduct.product_sku) === null || _submitProduct$produc === void 0 ? void 0 : _submitProduct$produc.option)
|
|
586
609
|
});
|
|
587
610
|
return _objectSpread(_objectSpread(_objectSpread({}, productRest), bookingUid ? {
|
|
588
611
|
booking_uid: bookingUid
|
|
@@ -1017,7 +1040,7 @@ export function isEmptyOrderProductDisplayValue(value) {
|
|
|
1017
1040
|
*/
|
|
1018
1041
|
export function mergeOrderProductDisplayFields(previous, next) {
|
|
1019
1042
|
var merged = _objectSpread({}, next);
|
|
1020
|
-
var displayFields = ['product_title', 'product_name', 'product_cover', 'cover', 'variant_title', 'product_sku'];
|
|
1043
|
+
var displayFields = ['product_title', 'product_name', 'product_cover', 'cover', 'variant_title', 'product_sku', 'payment_price'];
|
|
1021
1044
|
displayFields.forEach(function (field) {
|
|
1022
1045
|
if (isEmptyOrderProductDisplayValue(merged[field]) && !isEmptyOrderProductDisplayValue(previous[field])) {
|
|
1023
1046
|
merged[field] = previous[field];
|
|
@@ -8,7 +8,9 @@ export interface SalesSummaryProduct {
|
|
|
8
8
|
original_price: string;
|
|
9
9
|
tax_fee: string;
|
|
10
10
|
is_charge_tax?: number;
|
|
11
|
-
|
|
11
|
+
product_sku?: Record<string, any> & {
|
|
12
|
+
option?: any[];
|
|
13
|
+
};
|
|
12
14
|
discount_list?: any[];
|
|
13
15
|
product_bundle?: any[];
|
|
14
16
|
metadata?: Record<string, any>;
|
|
@@ -8,6 +8,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
|
8
8
|
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); }
|
|
9
9
|
import Decimal from 'decimal.js';
|
|
10
10
|
import { getSurcharge, getSurchargeAmount } from "../Summary/utils";
|
|
11
|
+
import { getProductSkuOptions } from "../Order/utils";
|
|
11
12
|
function toDecimal(value) {
|
|
12
13
|
return new Decimal(value || 0);
|
|
13
14
|
}
|
|
@@ -53,6 +54,7 @@ function buildSurchargeServiceItems(products) {
|
|
|
53
54
|
var _product$is_charge_ta, _product$metadata5, _product$metadata6;
|
|
54
55
|
var quantity = getSafeNum(product.num);
|
|
55
56
|
var unitTotal = getUnitPaymentTotal(product);
|
|
57
|
+
var options = getProductSkuOptions(product);
|
|
56
58
|
return {
|
|
57
59
|
id: product.product_id,
|
|
58
60
|
num: quantity,
|
|
@@ -64,12 +66,14 @@ function buildSurchargeServiceItems(products) {
|
|
|
64
66
|
product: {
|
|
65
67
|
discount_list: product.discount_list || [],
|
|
66
68
|
product_bundle: product.product_bundle || [],
|
|
67
|
-
|
|
69
|
+
product_sku: product.product_sku || {
|
|
70
|
+
option: options
|
|
71
|
+
}
|
|
68
72
|
}
|
|
69
73
|
},
|
|
70
74
|
bundle: product.product_bundle || [],
|
|
71
|
-
option:
|
|
72
|
-
options:
|
|
75
|
+
option: options,
|
|
76
|
+
options: options,
|
|
73
77
|
relation_details: [],
|
|
74
78
|
metadata: product.metadata || {},
|
|
75
79
|
start_date: ((_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.start_date) || '',
|
|
@@ -18,7 +18,10 @@ export declare class OrderModule extends BaseModule implements Module {
|
|
|
18
18
|
private resourceIdIndex;
|
|
19
19
|
private logger;
|
|
20
20
|
private storage;
|
|
21
|
-
private orderSQLiteSaveQueue;
|
|
21
|
+
private orderSQLiteSaveQueue; /** 按 storageKey 记录最近一次 SQLite 写入来源与时间,用于去重 */
|
|
22
|
+
private recentSqliteWriteByStorageKey;
|
|
23
|
+
/** 最近一次 SSE 全量拉取完成时间 */
|
|
24
|
+
private lastServerFullFetchAtMs;
|
|
22
25
|
constructor(name?: string, version?: string);
|
|
23
26
|
initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
|
|
24
27
|
/**
|
|
@@ -33,6 +36,35 @@ export declare class OrderModule extends BaseModule implements Module {
|
|
|
33
36
|
* @param metadata 日志元数据
|
|
34
37
|
*/
|
|
35
38
|
private logError;
|
|
39
|
+
/**
|
|
40
|
+
* 记录订单最近一次 SQLite 写入,供 pubsub 回声去重使用。
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* this.recordRecentSqliteWrite('upsertOrdersFromRemote', orders)
|
|
44
|
+
*/
|
|
45
|
+
private recordRecentSqliteWrite;
|
|
46
|
+
/**
|
|
47
|
+
* 过滤 pubsub 触发的冗余 SQLite patch(业务 API 刚写入过的 update 回声)。
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* const { toWrite, skipped } = this.filterRedundantPatchOrders('pubsub.bodyUpsert', orders, mergeActions)
|
|
51
|
+
*/
|
|
52
|
+
private filterRedundantPatchOrders;
|
|
53
|
+
/**
|
|
54
|
+
* 过滤 pubsub HTTP 增量拉取 ids:本地刚由业务 API 写入的单可跳过 HTTP。
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* const ids = this.filterRedundantHttpRefreshIds([99331, 99332])
|
|
58
|
+
*/
|
|
59
|
+
private filterRedundantHttpRefreshIds;
|
|
60
|
+
/**
|
|
61
|
+
* 解析 pubsub 消息会走哪条同步分支,便于对照为何触发 HTTP 重拉或 body 直写。
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* this.resolveSyncMessageRoute(msg)
|
|
65
|
+
* // => { route: 'httpRefresh.batchIds', ... }
|
|
66
|
+
*/
|
|
67
|
+
private resolveSyncMessageRoute;
|
|
36
68
|
private getOrderSyncThrottleMs;
|
|
37
69
|
preload(): Promise<void>;
|
|
38
70
|
getOrders(): OrderData[];
|
|
@@ -120,6 +152,14 @@ export declare class OrderModule extends BaseModule implements Module {
|
|
|
120
152
|
private normalizeOrderSyncPayload;
|
|
121
153
|
private uniqueOrderIds;
|
|
122
154
|
private getIdKey;
|
|
155
|
+
/**
|
|
156
|
+
* 解析订单 SQLite 主键,规则与宿主 OrderDataSource.getOrderStorageKey 一致。
|
|
157
|
+
*
|
|
158
|
+
* @example
|
|
159
|
+
* const key = this.getOrderStorageKey({ order_id: 1001, external_sale_number: 'S-1001' })
|
|
160
|
+
* // => 'S-1001'
|
|
161
|
+
*/
|
|
162
|
+
private getOrderStorageKey;
|
|
123
163
|
/**
|
|
124
164
|
* 当前订单拉取窗口:
|
|
125
165
|
* - 优先使用 createdAtQuery.sales_time_between(已按营业日边界初始化)
|
|
@@ -132,22 +172,35 @@ export declare class OrderModule extends BaseModule implements Module {
|
|
|
132
172
|
private setStorageItem;
|
|
133
173
|
private loadOrdersFromSQLite;
|
|
134
174
|
/**
|
|
135
|
-
* 串行执行订单 SQLite
|
|
175
|
+
* 串行执行订单 SQLite 写入任务,避免快照替换与增量 upsert 并发交错。
|
|
136
176
|
*
|
|
137
177
|
* @example
|
|
138
178
|
* await this.runInOrderSQLiteSaveQueue(async () => {
|
|
139
|
-
* await this.dbManager.
|
|
140
|
-
* await this.dbManager.bulkAdd(INDEXDB_STORE_NAME, orders)
|
|
179
|
+
* await this.dbManager.bulkUpdate(INDEXDB_STORE_NAME, orders)
|
|
141
180
|
* })
|
|
142
181
|
*/
|
|
143
182
|
private runInOrderSQLiteSaveQueue;
|
|
144
183
|
/**
|
|
145
|
-
*
|
|
184
|
+
* 批量增量 upsert 订单到 SQLite,不清空表;用于 pubsub / HTTP 增量合并。
|
|
185
|
+
*
|
|
186
|
+
* @example
|
|
187
|
+
* await this.patchOrdersInSQLite(freshOrders)
|
|
188
|
+
*/
|
|
189
|
+
private patchOrdersInSQLite;
|
|
190
|
+
/**
|
|
191
|
+
* 单条 upsert 订单到 SQLite;用于 overwriteExistingOrder 等单条覆盖场景。
|
|
192
|
+
*
|
|
193
|
+
* @example
|
|
194
|
+
* await this.updateOrderInSQLite(freshOrder)
|
|
195
|
+
*/
|
|
196
|
+
private updateOrderInSQLite;
|
|
197
|
+
/**
|
|
198
|
+
* 全量快照替换 orders 表(clear + bulkAdd),用于 SSE 全量拉取与营业日窗口裁剪。
|
|
146
199
|
*
|
|
147
200
|
* @example
|
|
148
|
-
* await this.
|
|
201
|
+
* await this.replaceOrdersSnapshotInSQLite(orderList)
|
|
149
202
|
*/
|
|
150
|
-
private
|
|
203
|
+
private replaceOrdersSnapshotInSQLite;
|
|
151
204
|
/**
|
|
152
205
|
* 清空订单模块的内存数据和本地 SQLite 订单表。
|
|
153
206
|
*
|