@pisell/pisellos 2.2.262 → 2.2.264
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/index.d.ts +0 -4
- package/dist/model/strategy/adapter/index.js +1 -5
- package/dist/model/strategy/adapter/promotion/adapter.d.ts +4 -0
- package/dist/model/strategy/adapter/promotion/adapter.js +23 -0
- package/dist/model/strategy/adapter/promotion/evaluator.d.ts +17 -0
- package/dist/model/strategy/adapter/promotion/evaluator.js +279 -6
- package/dist/model/strategy/adapter/promotion/examples.d.ts +86 -0
- package/dist/model/strategy/adapter/promotion/examples.js +99 -0
- package/dist/model/strategy/adapter/promotion/index.d.ts +1 -1
- package/dist/model/strategy/adapter/promotion/type.d.ts +90 -2
- package/dist/model/strategy/adapter/promotion/type.js +45 -0
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +10 -16
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +1 -2
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +1 -1
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +1 -32
- package/dist/modules/Discount/index.d.ts +2 -5
- package/dist/modules/Discount/index.js +7 -30
- package/dist/modules/Discount/types.d.ts +0 -4
- package/dist/modules/Order/index.d.ts +2 -14
- package/dist/modules/Order/index.js +736 -1035
- package/dist/modules/Order/types.d.ts +0 -16
- package/dist/modules/Order/utils.d.ts +3 -4
- package/dist/modules/Order/utils.js +61 -54
- package/dist/modules/Product/types.d.ts +0 -22
- package/dist/modules/ProductList/index.d.ts +1 -1
- package/dist/modules/ProductList/index.js +2 -4
- package/dist/modules/ProductList/types.d.ts +0 -2
- package/dist/modules/Rules/index.d.ts +9 -2
- package/dist/modules/Rules/index.js +43 -69
- package/dist/modules/Rules/types.d.ts +1 -10
- package/dist/server/index.d.ts +0 -55
- package/dist/server/index.js +742 -1161
- package/dist/server/modules/order/index.d.ts +4 -10
- package/dist/server/modules/order/index.js +399 -404
- package/dist/server/modules/order/types.d.ts +0 -4
- package/dist/server/modules/products/index.d.ts +8 -31
- package/dist/server/modules/products/index.js +390 -549
- package/dist/server/modules/products/types.d.ts +0 -18
- package/dist/solution/BaseSales/index.d.ts +1 -21
- package/dist/solution/BaseSales/index.js +789 -1136
- package/dist/solution/BaseSales/types.d.ts +1 -6
- package/dist/solution/BaseSales/types.js +1 -1
- package/dist/solution/BaseSales/utils/cartPromotion.d.ts +3 -1
- package/dist/solution/BaseSales/utils/cartPromotion.js +97 -50
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +3 -3
- package/dist/solution/BaseSales/utils/parseSalesResponse.js +8 -6
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +1 -14
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.js +25 -59
- package/dist/solution/BookingTicket/types.d.ts +0 -2
- package/dist/solution/ScanOrder/index.js +31 -20
- package/dist/solution/ShopDiscount/index.js +14 -15
- package/dist/solution/VenueBooking/index.js +30 -19
- package/lib/model/strategy/adapter/index.d.ts +0 -4
- package/lib/model/strategy/adapter/index.js +2 -13
- package/lib/model/strategy/adapter/promotion/adapter.d.ts +4 -0
- package/lib/model/strategy/adapter/promotion/adapter.js +20 -0
- package/lib/model/strategy/adapter/promotion/evaluator.d.ts +17 -0
- package/lib/model/strategy/adapter/promotion/evaluator.js +235 -0
- package/lib/model/strategy/adapter/promotion/examples.d.ts +86 -0
- package/lib/model/strategy/adapter/promotion/examples.js +91 -0
- package/lib/model/strategy/adapter/promotion/index.d.ts +1 -1
- package/lib/model/strategy/adapter/promotion/index.js +51 -0
- package/lib/model/strategy/adapter/promotion/type.d.ts +90 -2
- package/lib/model/strategy/adapter/promotion/type.js +2 -0
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +0 -5
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +0 -1
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +1 -1
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +2 -23
- package/lib/modules/Discount/index.d.ts +2 -5
- package/lib/modules/Discount/index.js +3 -23
- package/lib/modules/Discount/types.d.ts +0 -4
- package/lib/modules/Order/index.d.ts +2 -14
- package/lib/modules/Order/index.js +60 -326
- package/lib/modules/Order/types.d.ts +0 -16
- package/lib/modules/Order/utils.d.ts +3 -4
- package/lib/modules/Order/utils.js +23 -22
- package/lib/modules/Product/types.d.ts +0 -22
- package/lib/modules/ProductList/index.d.ts +1 -1
- package/lib/modules/ProductList/index.js +2 -4
- package/lib/modules/ProductList/types.d.ts +0 -2
- package/lib/modules/Rules/index.d.ts +9 -2
- package/lib/modules/Rules/index.js +29 -61
- package/lib/modules/Rules/types.d.ts +1 -10
- package/lib/server/index.d.ts +0 -55
- package/lib/server/index.js +31 -327
- package/lib/server/modules/order/index.d.ts +4 -10
- package/lib/server/modules/order/index.js +139 -198
- package/lib/server/modules/order/types.d.ts +0 -4
- package/lib/server/modules/products/index.d.ts +8 -31
- package/lib/server/modules/products/index.js +35 -134
- package/lib/server/modules/products/types.d.ts +0 -18
- package/lib/solution/BaseSales/index.d.ts +1 -21
- package/lib/solution/BaseSales/index.js +72 -313
- package/lib/solution/BaseSales/types.d.ts +1 -6
- package/lib/solution/BaseSales/utils/cartPromotion.d.ts +3 -1
- package/lib/solution/BaseSales/utils/cartPromotion.js +64 -25
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +3 -3
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +5 -4
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +0 -8
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.js +8 -33
- package/lib/solution/BookingTicket/types.d.ts +0 -2
- package/lib/solution/ScanOrder/index.js +8 -0
- package/lib/solution/ShopDiscount/index.js +1 -2
- package/lib/solution/VenueBooking/index.js +8 -0
- package/package.json +1 -1
- package/dist/model/strategy/adapter/dataVariant/adapter.d.ts +0 -50
- package/dist/model/strategy/adapter/dataVariant/adapter.js +0 -167
- package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +0 -89
- package/dist/model/strategy/adapter/dataVariant/evaluator.js +0 -780
- package/dist/model/strategy/adapter/dataVariant/examples.d.ts +0 -39
- package/dist/model/strategy/adapter/dataVariant/examples.js +0 -277
- package/dist/model/strategy/adapter/dataVariant/index.d.ts +0 -4
- package/dist/model/strategy/adapter/dataVariant/index.js +0 -4
- package/dist/model/strategy/adapter/dataVariant/type.d.ts +0 -148
- package/dist/model/strategy/adapter/dataVariant/type.js +0 -54
- package/dist/modules/Order/utils/orderCollectionIdentity.d.ts +0 -53
- package/dist/modules/Order/utils/orderCollectionIdentity.js +0 -405
- package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +0 -50
- package/lib/model/strategy/adapter/dataVariant/adapter.js +0 -149
- package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +0 -89
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +0 -583
- package/lib/model/strategy/adapter/dataVariant/examples.d.ts +0 -39
- package/lib/model/strategy/adapter/dataVariant/examples.js +0 -293
- package/lib/model/strategy/adapter/dataVariant/index.d.ts +0 -4
- package/lib/model/strategy/adapter/dataVariant/index.js +0 -38
- package/lib/model/strategy/adapter/dataVariant/type.d.ts +0 -148
- package/lib/model/strategy/adapter/dataVariant/type.js +0 -31
- package/lib/modules/Order/utils/orderCollectionIdentity.d.ts +0 -53
- package/lib/modules/Order/utils/orderCollectionIdentity.js +0 -415
|
@@ -1,405 +0,0 @@
|
|
|
1
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
2
|
-
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."); }
|
|
3
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
4
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
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
|
-
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); }
|
|
7
|
-
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; }
|
|
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
|
-
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; }
|
|
10
|
-
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; }
|
|
11
|
-
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; }
|
|
12
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
13
|
-
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); }
|
|
14
|
-
import { cloneDeep } from 'lodash-es';
|
|
15
|
-
var IDENTITY_CONFIG = {
|
|
16
|
-
product: {
|
|
17
|
-
persistentIdField: 'order_detail_id',
|
|
18
|
-
uidField: 'unique_identification_number',
|
|
19
|
-
fallbackPrefix: 'os-fallback:product:order-detail'
|
|
20
|
-
},
|
|
21
|
-
booking: {
|
|
22
|
-
persistentIdField: 'schedule_event_id',
|
|
23
|
-
uidField: 'unique_identification_number',
|
|
24
|
-
fallbackPrefix: 'os-fallback:booking:schedule-event'
|
|
25
|
-
},
|
|
26
|
-
payment: {
|
|
27
|
-
persistentIdField: 'order_payment_id',
|
|
28
|
-
uidField: 'unique_payment_number',
|
|
29
|
-
fallbackPrefix: 'os-fallback:payment:order-payment'
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
export function createUuidV4() {
|
|
33
|
-
var template = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx';
|
|
34
|
-
return template.replace(/[xy]/g, function (char) {
|
|
35
|
-
var randomValue = Math.floor(Math.random() * 16);
|
|
36
|
-
var value = char === 'x' ? randomValue : randomValue & 0x3 | 0x8;
|
|
37
|
-
return value.toString(16);
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
export function isBlankOrderCollectionIdentity(value) {
|
|
41
|
-
return value === undefined || value === null || value === '';
|
|
42
|
-
}
|
|
43
|
-
export function getOrderCollectionPersistentId(kind, item) {
|
|
44
|
-
var record = item;
|
|
45
|
-
if (!record) return null;
|
|
46
|
-
var value = record[IDENTITY_CONFIG[kind].persistentIdField];
|
|
47
|
-
if (isBlankOrderCollectionIdentity(value)) return null;
|
|
48
|
-
return String(value);
|
|
49
|
-
}
|
|
50
|
-
export function getOrderCollectionUid(kind, item) {
|
|
51
|
-
var _record$metadata;
|
|
52
|
-
var record = item;
|
|
53
|
-
if (!record) return null;
|
|
54
|
-
var uidField = IDENTITY_CONFIG[kind].uidField;
|
|
55
|
-
var metadataValue = (_record$metadata = record.metadata) === null || _record$metadata === void 0 ? void 0 : _record$metadata[uidField];
|
|
56
|
-
if (!isBlankOrderCollectionIdentity(metadataValue)) return String(metadataValue);
|
|
57
|
-
var topLevelValue = record[uidField];
|
|
58
|
-
if (isBlankOrderCollectionIdentity(topLevelValue)) return null;
|
|
59
|
-
return String(topLevelValue);
|
|
60
|
-
}
|
|
61
|
-
export function buildOrderCollectionFallbackUid(kind, persistentId) {
|
|
62
|
-
return "".concat(IDENTITY_CONFIG[kind].fallbackPrefix, ":").concat(String(persistentId));
|
|
63
|
-
}
|
|
64
|
-
export function getOrderCollectionReferenceUid(kind, item) {
|
|
65
|
-
var uid = getOrderCollectionUid(kind, item);
|
|
66
|
-
if (uid) return uid;
|
|
67
|
-
var persistentId = getOrderCollectionPersistentId(kind, item);
|
|
68
|
-
return persistentId ? buildOrderCollectionFallbackUid(kind, persistentId) : null;
|
|
69
|
-
}
|
|
70
|
-
export function setOrderCollectionUid(kind, item, uid) {
|
|
71
|
-
var record = cloneDeep(item || {});
|
|
72
|
-
var uidField = IDENTITY_CONFIG[kind].uidField;
|
|
73
|
-
record.metadata = _objectSpread(_objectSpread({}, record.metadata && _typeof(record.metadata) === 'object' ? record.metadata : {}), {}, _defineProperty({}, uidField, uid));
|
|
74
|
-
delete record[uidField];
|
|
75
|
-
return record;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* 持久化行 ID 是服务端事实主键;只有至少一侧尚未持久化时,才允许用 runtime UID 对齐。
|
|
80
|
-
*/
|
|
81
|
-
export function isSameOrderCollectionItem(kind, left, right) {
|
|
82
|
-
var leftPersistentId = getOrderCollectionPersistentId(kind, left);
|
|
83
|
-
var rightPersistentId = getOrderCollectionPersistentId(kind, right);
|
|
84
|
-
if (leftPersistentId && rightPersistentId) {
|
|
85
|
-
return leftPersistentId === rightPersistentId;
|
|
86
|
-
}
|
|
87
|
-
var leftUid = getOrderCollectionUid(kind, left);
|
|
88
|
-
var rightUid = getOrderCollectionUid(kind, right);
|
|
89
|
-
return Boolean(leftUid && rightUid && leftUid === rightUid);
|
|
90
|
-
}
|
|
91
|
-
export function mergeOrderCollectionItems(kind, currentItem, incomingItem, options) {
|
|
92
|
-
var _options$createAnonym;
|
|
93
|
-
var current = cloneDeep(currentItem || {});
|
|
94
|
-
var incoming = cloneDeep(incomingItem || {});
|
|
95
|
-
var persistentIdField = IDENTITY_CONFIG[kind].persistentIdField;
|
|
96
|
-
var currentPersistentIdValue = current[persistentIdField];
|
|
97
|
-
var incomingPersistentIdValue = incoming[persistentIdField];
|
|
98
|
-
var incomingUid = getOrderCollectionUid(kind, incoming);
|
|
99
|
-
var currentUid = getOrderCollectionUid(kind, current);
|
|
100
|
-
var persistentId = getOrderCollectionPersistentId(kind, incoming) || getOrderCollectionPersistentId(kind, current);
|
|
101
|
-
var merged = _objectSpread(_objectSpread(_objectSpread({}, current), incoming), {}, {
|
|
102
|
-
metadata: _objectSpread(_objectSpread({}, current.metadata && _typeof(current.metadata) === 'object' ? current.metadata : {}), incoming.metadata && _typeof(incoming.metadata) === 'object' ? incoming.metadata : {})
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
// UID 对齐允许一侧尚未持久化,但稀疏 incoming 的 null/空值不能擦掉已存在行 ID。
|
|
106
|
-
if (!isBlankOrderCollectionIdentity(incomingPersistentIdValue)) {
|
|
107
|
-
merged[persistentIdField] = incomingPersistentIdValue;
|
|
108
|
-
} else if (!isBlankOrderCollectionIdentity(currentPersistentIdValue)) {
|
|
109
|
-
merged[persistentIdField] = currentPersistentIdValue;
|
|
110
|
-
}
|
|
111
|
-
var incomingUidIsDerived = Boolean(incomingUid && persistentId && (incomingUid === buildOrderCollectionFallbackUid(kind, persistentId) || incomingUid.startsWith("".concat(buildOrderCollectionFallbackUid(kind, persistentId), ":conflict:"))));
|
|
112
|
-
var uid = (incomingUid && !incomingUidIsDerived ? incomingUid : null) || currentUid || incomingUid || ((options === null || options === void 0 ? void 0 : options.ensureUid) === false ? null : persistentId ? buildOrderCollectionFallbackUid(kind, persistentId) : (options === null || options === void 0 || (_options$createAnonym = options.createAnonymousUid) === null || _options$createAnonym === void 0 ? void 0 : _options$createAnonym.call(options)) || createUuidV4());
|
|
113
|
-
return uid ? setOrderCollectionUid(kind, merged, uid) : merged;
|
|
114
|
-
}
|
|
115
|
-
function createEmptyIdentityStats() {
|
|
116
|
-
return {
|
|
117
|
-
backfilledUidCount: 0,
|
|
118
|
-
collapsedDuplicateCount: 0,
|
|
119
|
-
uidConflictCount: 0,
|
|
120
|
-
anonymousRowCount: 0
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
function allocateAnonymousUid(occupiedUids, createAnonymousUid) {
|
|
124
|
-
var uid = createAnonymousUid();
|
|
125
|
-
while (occupiedUids.has(uid)) uid = createAnonymousUid();
|
|
126
|
-
return uid;
|
|
127
|
-
}
|
|
128
|
-
function allocatePersistentConflictUid(kind, persistentId, occupiedUids) {
|
|
129
|
-
var fallbackUid = buildOrderCollectionFallbackUid(kind, persistentId);
|
|
130
|
-
if (!occupiedUids.has(fallbackUid)) return fallbackUid;
|
|
131
|
-
|
|
132
|
-
// 极端情况下其它行可能把本行 fallback 当作显式 UID 使用;继续派生稳定后缀,
|
|
133
|
-
// 避免修复冲突后仍留下重复 UID。规范化结果一旦持久化,后续读取保持幂等。
|
|
134
|
-
var suffix = 1;
|
|
135
|
-
var candidate = "".concat(fallbackUid, ":conflict:").concat(suffix);
|
|
136
|
-
while (occupiedUids.has(candidate)) {
|
|
137
|
-
suffix += 1;
|
|
138
|
-
candidate = "".concat(fallbackUid, ":conflict:").concat(suffix);
|
|
139
|
-
}
|
|
140
|
-
return candidate;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* 规范化单一数组:强身份重复时保留首次位置、用最后一条业务字段覆盖,并统一补 UID。
|
|
145
|
-
*/
|
|
146
|
-
export function normalizeOrderCollection(kind, items, options) {
|
|
147
|
-
var stats = createEmptyIdentityStats();
|
|
148
|
-
var uidRemaps = [];
|
|
149
|
-
var result = [];
|
|
150
|
-
var ensureUid = (options === null || options === void 0 ? void 0 : options.ensureUid) !== false;
|
|
151
|
-
var createAnonymousUid = (options === null || options === void 0 ? void 0 : options.createAnonymousUid) || createUuidV4;
|
|
152
|
-
var _iterator = _createForOfIteratorHelper(items || []),
|
|
153
|
-
_step;
|
|
154
|
-
try {
|
|
155
|
-
var _loop = function _loop() {
|
|
156
|
-
var rawItem = _step.value;
|
|
157
|
-
var item = cloneDeep(rawItem);
|
|
158
|
-
var existingIndex = result.findIndex(function (existing) {
|
|
159
|
-
return isSameOrderCollectionItem(kind, existing, item);
|
|
160
|
-
});
|
|
161
|
-
if (existingIndex === -1) {
|
|
162
|
-
result.push(item);
|
|
163
|
-
return 1; // continue
|
|
164
|
-
}
|
|
165
|
-
var previousReferenceUid = getOrderCollectionReferenceUid(kind, result[existingIndex]);
|
|
166
|
-
var incomingReferenceUid = getOrderCollectionReferenceUid(kind, item);
|
|
167
|
-
result[existingIndex] = mergeOrderCollectionItems(kind, result[existingIndex], item, {
|
|
168
|
-
ensureUid: false
|
|
169
|
-
});
|
|
170
|
-
var nextUid = getOrderCollectionUid(kind, result[existingIndex]);
|
|
171
|
-
if (nextUid) {
|
|
172
|
-
var _iterator2 = _createForOfIteratorHelper(new Set([previousReferenceUid, incomingReferenceUid])),
|
|
173
|
-
_step2;
|
|
174
|
-
try {
|
|
175
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
176
|
-
var from = _step2.value;
|
|
177
|
-
if (!from || from === nextUid) continue;
|
|
178
|
-
uidRemaps.push({
|
|
179
|
-
kind: kind,
|
|
180
|
-
from: from,
|
|
181
|
-
to: nextUid,
|
|
182
|
-
persistentId: getOrderCollectionPersistentId(kind, result[existingIndex])
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
} catch (err) {
|
|
186
|
-
_iterator2.e(err);
|
|
187
|
-
} finally {
|
|
188
|
-
_iterator2.f();
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
stats.collapsedDuplicateCount += 1;
|
|
192
|
-
};
|
|
193
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
194
|
-
if (_loop()) continue;
|
|
195
|
-
}
|
|
196
|
-
} catch (err) {
|
|
197
|
-
_iterator.e(err);
|
|
198
|
-
} finally {
|
|
199
|
-
_iterator.f();
|
|
200
|
-
}
|
|
201
|
-
if (!ensureUid) return {
|
|
202
|
-
items: result,
|
|
203
|
-
stats: stats,
|
|
204
|
-
uidRemaps: uidRemaps
|
|
205
|
-
};
|
|
206
|
-
var occupiedUids = new Set();
|
|
207
|
-
for (var index = 0; index < result.length; index += 1) {
|
|
208
|
-
var item = result[index];
|
|
209
|
-
var persistentId = getOrderCollectionPersistentId(kind, item);
|
|
210
|
-
var uid = getOrderCollectionUid(kind, item);
|
|
211
|
-
if (!uid) {
|
|
212
|
-
uid = persistentId ? buildOrderCollectionFallbackUid(kind, persistentId) : allocateAnonymousUid(occupiedUids, createAnonymousUid);
|
|
213
|
-
item = setOrderCollectionUid(kind, item, uid);
|
|
214
|
-
result[index] = item;
|
|
215
|
-
stats.backfilledUidCount += 1;
|
|
216
|
-
if (!persistentId) stats.anonymousRowCount += 1;
|
|
217
|
-
}
|
|
218
|
-
if (occupiedUids.has(uid)) {
|
|
219
|
-
var _item, _item2, _item3, _item4;
|
|
220
|
-
var replacementUid = persistentId ? allocatePersistentConflictUid(kind, persistentId, occupiedUids) : allocateAnonymousUid(occupiedUids, createAnonymousUid);
|
|
221
|
-
result[index] = setOrderCollectionUid(kind, item, replacementUid);
|
|
222
|
-
uidRemaps.push({
|
|
223
|
-
kind: kind,
|
|
224
|
-
from: uid,
|
|
225
|
-
to: replacementUid,
|
|
226
|
-
persistentId: persistentId,
|
|
227
|
-
scope: 'linked-owner',
|
|
228
|
-
referenceOwnerUid: kind === 'product' ? String(((_item = item) === null || _item === void 0 ? void 0 : _item.booking_uid) || ((_item2 = item) === null || _item2 === void 0 || (_item2 = _item2.metadata) === null || _item2 === void 0 ? void 0 : _item2.booking_uid) || '') || null : kind === 'booking' ? String(((_item3 = item) === null || _item3 === void 0 ? void 0 : _item3.product_uid) || ((_item4 = item) === null || _item4 === void 0 || (_item4 = _item4.metadata) === null || _item4 === void 0 ? void 0 : _item4.product_uid) || '') || null : null
|
|
229
|
-
});
|
|
230
|
-
uid = replacementUid;
|
|
231
|
-
stats.uidConflictCount += 1;
|
|
232
|
-
}
|
|
233
|
-
occupiedUids.add(uid);
|
|
234
|
-
}
|
|
235
|
-
return {
|
|
236
|
-
items: result,
|
|
237
|
-
stats: stats,
|
|
238
|
-
uidRemaps: uidRemaps
|
|
239
|
-
};
|
|
240
|
-
}
|
|
241
|
-
export function applyOrderCollectionUidRemaps(sourceOrder, uidRemaps) {
|
|
242
|
-
if (!uidRemaps.length) return sourceOrder;
|
|
243
|
-
var order = cloneDeep(sourceOrder);
|
|
244
|
-
var hasAmbiguousLinkedOwner = function hasAmbiguousLinkedOwner(remap) {
|
|
245
|
-
if (remap.scope !== 'linked-owner' || !remap.referenceOwnerUid) return false;
|
|
246
|
-
var ownerKind = remap.kind === 'product' ? 'booking' : remap.kind === 'booking' ? 'product' : null;
|
|
247
|
-
if (!ownerKind) return false;
|
|
248
|
-
return uidRemaps.some(function (candidate) {
|
|
249
|
-
return candidate.scope === 'linked-owner' && candidate.kind === ownerKind && candidate.from === remap.referenceOwnerUid;
|
|
250
|
-
});
|
|
251
|
-
};
|
|
252
|
-
var _iterator3 = _createForOfIteratorHelper(uidRemaps),
|
|
253
|
-
_step3;
|
|
254
|
-
try {
|
|
255
|
-
var _loop2 = function _loop2() {
|
|
256
|
-
var remap = _step3.value;
|
|
257
|
-
if (remap.from === remap.to) return 0; // continue
|
|
258
|
-
var linkedOwnerIsAmbiguous = hasAmbiguousLinkedOwner(remap);
|
|
259
|
-
if (remap.kind === 'product') {
|
|
260
|
-
var _order$_extend;
|
|
261
|
-
var _iterator4 = _createForOfIteratorHelper(order.bookings || []),
|
|
262
|
-
_step4;
|
|
263
|
-
try {
|
|
264
|
-
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
265
|
-
var _booking$metadata;
|
|
266
|
-
var booking = _step4.value;
|
|
267
|
-
if (remap.scope === 'linked-owner' && (linkedOwnerIsAmbiguous || getOrderCollectionUid('booking', booking) !== remap.referenceOwnerUid)) {
|
|
268
|
-
continue;
|
|
269
|
-
}
|
|
270
|
-
if (String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === remap.from) {
|
|
271
|
-
booking.product_uid = remap.to;
|
|
272
|
-
}
|
|
273
|
-
if (String((booking === null || booking === void 0 || (_booking$metadata = booking.metadata) === null || _booking$metadata === void 0 ? void 0 : _booking$metadata.product_uid) || '') === remap.from) {
|
|
274
|
-
booking.metadata = _objectSpread(_objectSpread({}, booking.metadata || {}), {}, {
|
|
275
|
-
product_uid: remap.to
|
|
276
|
-
});
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
// 冲突 UID 仍由第一条持有;赠品父引用缺少可用的持久化行定位时不能全局改写。
|
|
280
|
-
} catch (err) {
|
|
281
|
-
_iterator4.e(err);
|
|
282
|
-
} finally {
|
|
283
|
-
_iterator4.f();
|
|
284
|
-
}
|
|
285
|
-
if (remap.scope !== 'linked-owner') {
|
|
286
|
-
var _iterator5 = _createForOfIteratorHelper(order.products || []),
|
|
287
|
-
_step5;
|
|
288
|
-
try {
|
|
289
|
-
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
290
|
-
var _product$metadata, _product$metadata2;
|
|
291
|
-
var product = _step5.value;
|
|
292
|
-
if (String((product === null || product === void 0 || (_product$metadata = product.metadata) === null || _product$metadata === void 0 ? void 0 : _product$metadata.parent_unique_identification_number) || '') === remap.from) {
|
|
293
|
-
product.metadata = _objectSpread(_objectSpread({}, product.metadata || {}), {}, {
|
|
294
|
-
parent_unique_identification_number: remap.to
|
|
295
|
-
});
|
|
296
|
-
}
|
|
297
|
-
var giftInfo = product === null || product === void 0 || (_product$metadata2 = product.metadata) === null || _product$metadata2 === void 0 ? void 0 : _product$metadata2._giftInfo;
|
|
298
|
-
if (giftInfo && _typeof(giftInfo) === 'object') {
|
|
299
|
-
var sourceProductIds = Array.isArray(giftInfo.sourceProductIds) ? giftInfo.sourceProductIds.map(function (uid) {
|
|
300
|
-
return String(uid) === remap.from ? remap.to : uid;
|
|
301
|
-
}) : giftInfo.sourceProductIds;
|
|
302
|
-
var sourceProductId = String(giftInfo.sourceProductId || '') === remap.from ? remap.to : giftInfo.sourceProductId;
|
|
303
|
-
product.metadata = _objectSpread(_objectSpread({}, product.metadata || {}), {}, {
|
|
304
|
-
_giftInfo: _objectSpread(_objectSpread(_objectSpread({}, giftInfo), sourceProductIds !== undefined ? {
|
|
305
|
-
sourceProductIds: sourceProductIds
|
|
306
|
-
} : {}), sourceProductId !== undefined ? {
|
|
307
|
-
sourceProductId: sourceProductId
|
|
308
|
-
} : {})
|
|
309
|
-
});
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
} catch (err) {
|
|
313
|
-
_iterator5.e(err);
|
|
314
|
-
} finally {
|
|
315
|
-
_iterator5.f();
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
var productsByUid = (_order$_extend = order._extend) === null || _order$_extend === void 0 ? void 0 : _order$_extend.productsByUid;
|
|
319
|
-
var cachedProduct = productsByUid === null || productsByUid === void 0 ? void 0 : productsByUid[remap.from];
|
|
320
|
-
var cachedPersistentId = getOrderCollectionPersistentId('product', (cachedProduct === null || cachedProduct === void 0 ? void 0 : cachedProduct.origin) || cachedProduct);
|
|
321
|
-
if (productsByUid && remap.scope === 'linked-owner') {
|
|
322
|
-
var retainedProduct = (order.products || []).find(function (product) {
|
|
323
|
-
return getOrderCollectionUid('product', product) === remap.from;
|
|
324
|
-
});
|
|
325
|
-
var remappedProduct = (order.products || []).find(function (product) {
|
|
326
|
-
return getOrderCollectionUid('product', product) === remap.to;
|
|
327
|
-
});
|
|
328
|
-
if (cachedProduct && remap.persistentId && cachedPersistentId === remap.persistentId) {
|
|
329
|
-
productsByUid[remap.to] = _objectSpread(_objectSpread({}, cachedProduct || {}), productsByUid[remap.to] || {});
|
|
330
|
-
if (retainedProduct) {
|
|
331
|
-
productsByUid[remap.from] = _objectSpread(_objectSpread({}, cachedProduct || {}), {}, {
|
|
332
|
-
origin: cloneDeep(retainedProduct)
|
|
333
|
-
});
|
|
334
|
-
}
|
|
335
|
-
} else if (remappedProduct && !productsByUid[remap.to]) {
|
|
336
|
-
productsByUid[remap.to] = {
|
|
337
|
-
origin: cloneDeep(remappedProduct)
|
|
338
|
-
};
|
|
339
|
-
}
|
|
340
|
-
return 0; // continue
|
|
341
|
-
}
|
|
342
|
-
if (cachedProduct && remap.scope !== 'linked-owner') {
|
|
343
|
-
productsByUid[remap.to] = _objectSpread(_objectSpread({}, cachedProduct || {}), productsByUid[remap.to] || {});
|
|
344
|
-
delete productsByUid[remap.from];
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
if (remap.kind === 'booking') {
|
|
348
|
-
var _iterator6 = _createForOfIteratorHelper(order.products || []),
|
|
349
|
-
_step6;
|
|
350
|
-
try {
|
|
351
|
-
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
352
|
-
var _product$metadata3;
|
|
353
|
-
var _product = _step6.value;
|
|
354
|
-
if (remap.scope === 'linked-owner' && (linkedOwnerIsAmbiguous || getOrderCollectionUid('product', _product) !== remap.referenceOwnerUid)) {
|
|
355
|
-
continue;
|
|
356
|
-
}
|
|
357
|
-
if (String((_product === null || _product === void 0 ? void 0 : _product.booking_uid) || '') === remap.from) {
|
|
358
|
-
_product.booking_uid = remap.to;
|
|
359
|
-
}
|
|
360
|
-
if (String((_product === null || _product === void 0 || (_product$metadata3 = _product.metadata) === null || _product$metadata3 === void 0 ? void 0 : _product$metadata3.booking_uid) || '') === remap.from) {
|
|
361
|
-
_product.metadata = _objectSpread(_objectSpread({}, _product.metadata || {}), {}, {
|
|
362
|
-
booking_uid: remap.to
|
|
363
|
-
});
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
} catch (err) {
|
|
367
|
-
_iterator6.e(err);
|
|
368
|
-
} finally {
|
|
369
|
-
_iterator6.f();
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
},
|
|
373
|
-
_ret;
|
|
374
|
-
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
375
|
-
_ret = _loop2();
|
|
376
|
-
if (_ret === 0) continue;
|
|
377
|
-
}
|
|
378
|
-
} catch (err) {
|
|
379
|
-
_iterator3.e(err);
|
|
380
|
-
} finally {
|
|
381
|
-
_iterator3.f();
|
|
382
|
-
}
|
|
383
|
-
return order;
|
|
384
|
-
}
|
|
385
|
-
export function normalizeOrderCollections(sourceOrder, options) {
|
|
386
|
-
var order = cloneDeep(sourceOrder || {});
|
|
387
|
-
var orderRecord = order;
|
|
388
|
-
var productResult = normalizeOrderCollection('product', Array.isArray(orderRecord.products) ? orderRecord.products : [], options);
|
|
389
|
-
var bookingResult = normalizeOrderCollection('booking', Array.isArray(orderRecord.bookings) ? orderRecord.bookings : [], options);
|
|
390
|
-
var paymentResult = normalizeOrderCollection('payment', Array.isArray(orderRecord.payments) ? orderRecord.payments : [], options);
|
|
391
|
-
if (Array.isArray(orderRecord.products)) orderRecord.products = productResult.items;
|
|
392
|
-
if (Array.isArray(orderRecord.bookings)) orderRecord.bookings = bookingResult.items;
|
|
393
|
-
if (Array.isArray(orderRecord.payments)) orderRecord.payments = paymentResult.items;
|
|
394
|
-
var uidRemaps = [].concat(_toConsumableArray(productResult.uidRemaps), _toConsumableArray(bookingResult.uidRemaps), _toConsumableArray(paymentResult.uidRemaps));
|
|
395
|
-
order = applyOrderCollectionUidRemaps(order, uidRemaps);
|
|
396
|
-
return {
|
|
397
|
-
order: order,
|
|
398
|
-
stats: {
|
|
399
|
-
product: productResult.stats,
|
|
400
|
-
booking: bookingResult.stats,
|
|
401
|
-
payment: paymentResult.stats
|
|
402
|
-
},
|
|
403
|
-
uidRemaps: uidRemaps
|
|
404
|
-
};
|
|
405
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import type { EvaluationResult, RuntimeContext } from '../../type';
|
|
2
|
-
import type { BusinessAdapter } from '../type';
|
|
3
|
-
import type { DataVariantBusinessData, DataVariantProduct } from './type';
|
|
4
|
-
/**
|
|
5
|
-
* Data Variant 适配器。
|
|
6
|
-
*
|
|
7
|
-
* 负责把智能定价运行态数据转换为 StrategyEngine 能识别的 attributes。
|
|
8
|
-
*/
|
|
9
|
-
export declare class DataVariantAdapter implements BusinessAdapter {
|
|
10
|
-
name: string;
|
|
11
|
-
version: string;
|
|
12
|
-
/**
|
|
13
|
-
* 准备批量全局上下文。
|
|
14
|
-
*
|
|
15
|
-
* 这里只放不依赖单个商品的字段,用于预计算 schedule/channel/orderType 等条件。
|
|
16
|
-
*/
|
|
17
|
-
prepareContext(businessData: DataVariantBusinessData): RuntimeContext;
|
|
18
|
-
/**
|
|
19
|
-
* 准备全局预计算上下文。
|
|
20
|
-
*/
|
|
21
|
-
prepareGlobalContext(businessData: DataVariantBusinessData): RuntimeContext;
|
|
22
|
-
/**
|
|
23
|
-
* 准备单商品上下文。
|
|
24
|
-
*
|
|
25
|
-
* 商品级条件只在当前商品 data_variants 引用到对应规则后才评估。
|
|
26
|
-
*/
|
|
27
|
-
prepareProductContext(businessData: DataVariantBusinessData, product: DataVariantProduct): RuntimeContext;
|
|
28
|
-
transformResult(result: EvaluationResult): EvaluationResult;
|
|
29
|
-
formatConfig(result: EvaluationResult, businessData?: DataVariantBusinessData): {
|
|
30
|
-
result: EvaluationResult;
|
|
31
|
-
businessData?: DataVariantBusinessData;
|
|
32
|
-
};
|
|
33
|
-
/**
|
|
34
|
-
* 构建 menu_match 使用的轻量商品对象。
|
|
35
|
-
*
|
|
36
|
-
* collection_ids 来自商品 collection 字段,避免 operator 读取复杂商品对象。
|
|
37
|
-
*/
|
|
38
|
-
buildProductValue(product: DataVariantProduct): {
|
|
39
|
-
id: number;
|
|
40
|
-
product_variant_id: number;
|
|
41
|
-
collection_ids: number[];
|
|
42
|
-
};
|
|
43
|
-
private toNumber;
|
|
44
|
-
/**
|
|
45
|
-
* 归一化客户 id:无效值返回 undefined,有效值统一为 number。
|
|
46
|
-
*/
|
|
47
|
-
private normalizeCustomerId;
|
|
48
|
-
private normalizeNumberArray;
|
|
49
|
-
}
|
|
50
|
-
export default DataVariantAdapter;
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
|
|
19
|
-
// src/model/strategy/adapter/dataVariant/adapter.ts
|
|
20
|
-
var adapter_exports = {};
|
|
21
|
-
__export(adapter_exports, {
|
|
22
|
-
DataVariantAdapter: () => DataVariantAdapter,
|
|
23
|
-
default: () => adapter_default
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(adapter_exports);
|
|
26
|
-
var DataVariantAdapter = class {
|
|
27
|
-
constructor() {
|
|
28
|
-
this.name = "DataVariantAdapter";
|
|
29
|
-
this.version = "1.0.0";
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* 准备批量全局上下文。
|
|
33
|
-
*
|
|
34
|
-
* 这里只放不依赖单个商品的字段,用于预计算 schedule/channel/orderType 等条件。
|
|
35
|
-
*/
|
|
36
|
-
prepareContext(businessData) {
|
|
37
|
-
return this.prepareGlobalContext(businessData);
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* 准备全局预计算上下文。
|
|
41
|
-
*/
|
|
42
|
-
prepareGlobalContext(businessData) {
|
|
43
|
-
const {
|
|
44
|
-
products,
|
|
45
|
-
scheduleDateTime,
|
|
46
|
-
channel,
|
|
47
|
-
orderType,
|
|
48
|
-
businessCode,
|
|
49
|
-
customerId,
|
|
50
|
-
availableWalletIds,
|
|
51
|
-
custom
|
|
52
|
-
} = businessData;
|
|
53
|
-
const normalizedCustomerId = this.normalizeCustomerId(customerId);
|
|
54
|
-
const normalizedAvailableWalletIds = this.normalizeNumberArray(availableWalletIds ?? (custom == null ? void 0 : custom.available_wallet_ids));
|
|
55
|
-
const resolvedBusinessCode = businessCode || (custom == null ? void 0 : custom.business_code) || (custom == null ? void 0 : custom.businessCode) || "";
|
|
56
|
-
return {
|
|
57
|
-
entities: {
|
|
58
|
-
products
|
|
59
|
-
},
|
|
60
|
-
attributes: {
|
|
61
|
-
...custom,
|
|
62
|
-
schedule: scheduleDateTime || "",
|
|
63
|
-
channel: channel || (custom == null ? void 0 : custom.channel) || "",
|
|
64
|
-
orderType: orderType || (custom == null ? void 0 : custom.orderType) || (custom == null ? void 0 : custom.order_type) || "",
|
|
65
|
-
// snake_case 与策略配置 field 对齐;customerId 保留兼容旧配置
|
|
66
|
-
customer_id: normalizedCustomerId,
|
|
67
|
-
customerId: normalizedCustomerId,
|
|
68
|
-
available_wallet_ids: normalizedAvailableWalletIds,
|
|
69
|
-
availableWalletIds: normalizedAvailableWalletIds,
|
|
70
|
-
business_code: resolvedBusinessCode
|
|
71
|
-
},
|
|
72
|
-
metadata: {
|
|
73
|
-
timestamp: Date.now()
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* 准备单商品上下文。
|
|
79
|
-
*
|
|
80
|
-
* 商品级条件只在当前商品 data_variants 引用到对应规则后才评估。
|
|
81
|
-
*/
|
|
82
|
-
prepareProductContext(businessData, product) {
|
|
83
|
-
const base = this.prepareGlobalContext(businessData);
|
|
84
|
-
const productValue = this.buildProductValue(product);
|
|
85
|
-
return {
|
|
86
|
-
...base,
|
|
87
|
-
entities: {
|
|
88
|
-
...base.entities,
|
|
89
|
-
currentProduct: product
|
|
90
|
-
},
|
|
91
|
-
attributes: {
|
|
92
|
-
...base.attributes,
|
|
93
|
-
product: productValue,
|
|
94
|
-
productIdAndVariantId: {
|
|
95
|
-
product_id: productValue.id,
|
|
96
|
-
product_variant_id: productValue.product_variant_id
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
transformResult(result) {
|
|
102
|
-
return result;
|
|
103
|
-
}
|
|
104
|
-
formatConfig(result, businessData) {
|
|
105
|
-
return { result, businessData };
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* 构建 menu_match 使用的轻量商品对象。
|
|
109
|
-
*
|
|
110
|
-
* collection_ids 来自商品 collection 字段,避免 operator 读取复杂商品对象。
|
|
111
|
-
*/
|
|
112
|
-
buildProductValue(product) {
|
|
113
|
-
const productId = this.toNumber(product.id ?? product.product_id);
|
|
114
|
-
const variantId = this.toNumber(
|
|
115
|
-
product.product_variant_id ?? product.variant_id
|
|
116
|
-
);
|
|
117
|
-
const collectionIds = Array.isArray(product.collection) ? product.collection.map((item) => this.toNumber(item == null ? void 0 : item.id)).filter((id) => id > 0) : [];
|
|
118
|
-
return {
|
|
119
|
-
id: productId,
|
|
120
|
-
product_variant_id: variantId,
|
|
121
|
-
collection_ids: collectionIds
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
toNumber(value) {
|
|
125
|
-
const parsed = Number(value);
|
|
126
|
-
return Number.isFinite(parsed) ? parsed : 0;
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* 归一化客户 id:无效值返回 undefined,有效值统一为 number。
|
|
130
|
-
*/
|
|
131
|
-
normalizeCustomerId(value) {
|
|
132
|
-
if (value === void 0 || value === null || value === "") {
|
|
133
|
-
return void 0;
|
|
134
|
-
}
|
|
135
|
-
const parsed = Number(value);
|
|
136
|
-
return Number.isFinite(parsed) && parsed > 0 ? parsed : void 0;
|
|
137
|
-
}
|
|
138
|
-
normalizeNumberArray(value) {
|
|
139
|
-
if (!Array.isArray(value))
|
|
140
|
-
return [];
|
|
141
|
-
const ids = value.map((item) => Number(item)).filter((item) => Number.isFinite(item) && item > 0);
|
|
142
|
-
return Array.from(new Set(ids));
|
|
143
|
-
}
|
|
144
|
-
};
|
|
145
|
-
var adapter_default = DataVariantAdapter;
|
|
146
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
147
|
-
0 && (module.exports = {
|
|
148
|
-
DataVariantAdapter
|
|
149
|
-
});
|