@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
|
@@ -40,7 +40,6 @@ var import_decimal = __toESM(require("decimal.js"));
|
|
|
40
40
|
var import_lodash_es = require("lodash-es");
|
|
41
41
|
var import_types2 = require("../BookingByStep/types");
|
|
42
42
|
var import_utils = require("../../modules/Order/utils");
|
|
43
|
-
var import_orderCollectionIdentity = require("../../modules/Order/utils/orderCollectionIdentity");
|
|
44
43
|
var import_dayjs = __toESM(require("dayjs"));
|
|
45
44
|
__reExport(BaseSales_exports, require("./types"), module.exports);
|
|
46
45
|
var import_Quotation = require("../../modules/Quotation");
|
|
@@ -77,18 +76,11 @@ function isBaseSalesHistoricalDiscountEntry(discount) {
|
|
|
77
76
|
(discount == null ? void 0 : discount.isEditMode) || (discount == null ? void 0 : discount.isDisabled) || (discount == null ? void 0 : discount.order_discount_id) != null
|
|
78
77
|
);
|
|
79
78
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
payment: "order_payment_id"
|
|
84
|
-
};
|
|
85
|
-
function getBaseSalesOrderCollectionKind(key) {
|
|
86
|
-
if (key === "products")
|
|
87
|
-
return "product";
|
|
88
|
-
if (key === "bookings")
|
|
89
|
-
return "booking";
|
|
79
|
+
function getBaseSalesUniqueArrayMetadataKey(key) {
|
|
80
|
+
if (key === "products" || key === "bookings")
|
|
81
|
+
return "unique_identification_number";
|
|
90
82
|
if (key === "payments" || key === "payment")
|
|
91
|
-
return "
|
|
83
|
+
return "unique_payment_number";
|
|
92
84
|
return null;
|
|
93
85
|
}
|
|
94
86
|
function isSameBaseSalesOrderRecord(left, right) {
|
|
@@ -103,140 +95,47 @@ function isSameBaseSalesOrderRecord(left, right) {
|
|
|
103
95
|
(value) => value !== void 0 && value !== null && value !== "" && leftIdentities.has(String(value))
|
|
104
96
|
);
|
|
105
97
|
}
|
|
106
|
-
function
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
if (isBaseSalesBlankValue(mergedItem.product_cover) && !isBaseSalesBlankValue(currentItem == null ? void 0 : currentItem.product_cover)) {
|
|
113
|
-
mergedItem.product_cover = currentItem.product_cover;
|
|
114
|
-
}
|
|
115
|
-
const currentHolderConfig = (_a = currentItem == null ? void 0 : currentItem.metadata) == null ? void 0 : _a.holder_config;
|
|
116
|
-
if ((((_b = mergedItem.metadata) == null ? void 0 : _b.holder_config) === void 0 || ((_c = mergedItem.metadata) == null ? void 0 : _c.holder_config) === null) && currentHolderConfig !== void 0 && currentHolderConfig !== null) {
|
|
117
|
-
mergedItem.metadata = {
|
|
118
|
-
...mergedItem.metadata || {},
|
|
119
|
-
holder_config: currentHolderConfig
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
return mergedItem;
|
|
98
|
+
function getBaseSalesMetadataUid(item, metadataKey) {
|
|
99
|
+
var _a;
|
|
100
|
+
const uid = ((_a = item == null ? void 0 : item.metadata) == null ? void 0 : _a[metadataKey]) ?? (item == null ? void 0 : item[metadataKey]);
|
|
101
|
+
if (uid === void 0 || uid === null || uid === "")
|
|
102
|
+
return null;
|
|
103
|
+
return String(uid);
|
|
123
104
|
}
|
|
124
|
-
function
|
|
125
|
-
const
|
|
126
|
-
const
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
if (mergedUid) {
|
|
134
|
-
for (const from of /* @__PURE__ */ new Set([currentReferenceUid, incomingReferenceUid])) {
|
|
135
|
-
if (!from || from === mergedUid)
|
|
136
|
-
continue;
|
|
137
|
-
uidRemaps.push({
|
|
138
|
-
kind,
|
|
139
|
-
from,
|
|
140
|
-
to: mergedUid,
|
|
141
|
-
persistentId: (0, import_orderCollectionIdentity.getOrderCollectionPersistentId)(kind, incomingItem) || (0, import_orderCollectionIdentity.getOrderCollectionPersistentId)(kind, currentItem)
|
|
142
|
-
});
|
|
105
|
+
function mergeBaseSalesUniqueArray(currentValue, loadedValue, metadataKey) {
|
|
106
|
+
const result = [];
|
|
107
|
+
const indexByUid = /* @__PURE__ */ new Map();
|
|
108
|
+
const appendOrReplaceByUid = (item) => {
|
|
109
|
+
const clonedItem = (0, import_lodash_es.cloneDeep)(item);
|
|
110
|
+
const uid = getBaseSalesMetadataUid(clonedItem, metadataKey);
|
|
111
|
+
if (!uid) {
|
|
112
|
+
result.push(clonedItem);
|
|
113
|
+
return;
|
|
143
114
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
if (isBaseSalesBlankValue(mergedItem[persistentIdField]) && !isBaseSalesBlankValue(identityMergedItem[persistentIdField])) {
|
|
148
|
-
mergedItem[persistentIdField] = identityMergedItem[persistentIdField];
|
|
149
|
-
}
|
|
150
|
-
return kind === "product" ? mergeBaseSalesProductSnapshotFields(currentItem, mergedItem) : mergedItem;
|
|
151
|
-
}
|
|
152
|
-
function mergeBaseSalesOrderCollection(kind, currentValue, incomingValue, strategy, uidRemaps) {
|
|
153
|
-
const currentItems = (0, import_orderCollectionIdentity.normalizeOrderCollection)(kind, currentValue, {
|
|
154
|
-
ensureUid: false
|
|
155
|
-
}).items;
|
|
156
|
-
const incomingItems = (0, import_orderCollectionIdentity.normalizeOrderCollection)(kind, incomingValue, {
|
|
157
|
-
ensureUid: false
|
|
158
|
-
}).items;
|
|
159
|
-
if (strategy === "authoritative-incoming") {
|
|
160
|
-
const result2 = (0, import_lodash_es.cloneDeep)(incomingItems);
|
|
161
|
-
currentItems.forEach((currentItem) => {
|
|
162
|
-
const incomingIndex = result2.findIndex(
|
|
163
|
-
(incomingItem) => (0, import_orderCollectionIdentity.isSameOrderCollectionItem)(kind, currentItem, incomingItem)
|
|
164
|
-
);
|
|
165
|
-
if (incomingIndex !== -1) {
|
|
166
|
-
result2[incomingIndex] = mergeBaseSalesCollectionItem(
|
|
167
|
-
kind,
|
|
168
|
-
currentItem,
|
|
169
|
-
result2[incomingIndex],
|
|
170
|
-
uidRemaps
|
|
171
|
-
);
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
if (!(0, import_orderCollectionIdentity.getOrderCollectionPersistentId)(kind, currentItem)) {
|
|
175
|
-
result2.push((0, import_lodash_es.cloneDeep)(currentItem));
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
-
return result2;
|
|
179
|
-
}
|
|
180
|
-
const result = (0, import_lodash_es.cloneDeep)(currentItems);
|
|
181
|
-
incomingItems.forEach((incomingItem) => {
|
|
182
|
-
const currentIndex = result.findIndex(
|
|
183
|
-
(currentItem) => (0, import_orderCollectionIdentity.isSameOrderCollectionItem)(kind, currentItem, incomingItem)
|
|
184
|
-
);
|
|
185
|
-
if (currentIndex !== -1) {
|
|
186
|
-
result[currentIndex] = mergeBaseSalesCollectionItem(
|
|
187
|
-
kind,
|
|
188
|
-
result[currentIndex],
|
|
189
|
-
incomingItem,
|
|
190
|
-
uidRemaps
|
|
191
|
-
);
|
|
115
|
+
const existingIndex = indexByUid.get(uid);
|
|
116
|
+
if (existingIndex !== void 0) {
|
|
117
|
+
result[existingIndex] = clonedItem;
|
|
192
118
|
return;
|
|
193
119
|
}
|
|
194
|
-
|
|
195
|
-
|
|
120
|
+
indexByUid.set(uid, result.length);
|
|
121
|
+
result.push(clonedItem);
|
|
122
|
+
};
|
|
123
|
+
currentValue.forEach(appendOrReplaceByUid);
|
|
124
|
+
loadedValue.forEach(appendOrReplaceByUid);
|
|
196
125
|
return result;
|
|
197
126
|
}
|
|
198
|
-
function
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
options
|
|
202
|
-
).order;
|
|
203
|
-
if (Array.isArray(normalizedRecord.payment)) {
|
|
204
|
-
normalizedRecord.payment = (0, import_orderCollectionIdentity.normalizeOrderCollection)(
|
|
205
|
-
"payment",
|
|
206
|
-
normalizedRecord.payment,
|
|
207
|
-
options
|
|
208
|
-
).items;
|
|
209
|
-
}
|
|
210
|
-
return normalizedRecord;
|
|
211
|
-
}
|
|
212
|
-
function mergeSalesDetailRecordWithTempOrder(currentTempOrder, loadedRecord, strategy) {
|
|
213
|
-
const normalizedLoadedRecord = normalizeBaseSalesRecordCollections(
|
|
214
|
-
loadedRecord || {},
|
|
215
|
-
{ ensureUid: false }
|
|
216
|
-
);
|
|
217
|
-
if (!currentTempOrder) {
|
|
218
|
-
return normalizeBaseSalesRecordCollections(normalizedLoadedRecord);
|
|
219
|
-
}
|
|
220
|
-
const normalizedCurrentTempOrder = normalizeBaseSalesRecordCollections(
|
|
221
|
-
currentTempOrder,
|
|
222
|
-
{ ensureUid: false }
|
|
223
|
-
);
|
|
224
|
-
const uidRemaps = [];
|
|
127
|
+
function mergeSalesDetailRecordWithTempOrder(currentTempOrder, loadedRecord) {
|
|
128
|
+
if (!currentTempOrder)
|
|
129
|
+
return loadedRecord;
|
|
225
130
|
const mergedRecord = (0, import_lodash_es.mergeWith)(
|
|
226
|
-
|
|
227
|
-
|
|
131
|
+
(0, import_lodash_es.cloneDeep)(currentTempOrder),
|
|
132
|
+
(0, import_lodash_es.cloneDeep)(loadedRecord || {}),
|
|
228
133
|
(currentValue, loadedValue, key) => {
|
|
229
|
-
const collectionKind = getBaseSalesOrderCollectionKind(key);
|
|
230
|
-
if (collectionKind && Array.isArray(loadedValue)) {
|
|
231
|
-
return mergeBaseSalesOrderCollection(
|
|
232
|
-
collectionKind,
|
|
233
|
-
Array.isArray(currentValue) ? currentValue : [],
|
|
234
|
-
loadedValue,
|
|
235
|
-
strategy,
|
|
236
|
-
uidRemaps
|
|
237
|
-
);
|
|
238
|
-
}
|
|
239
134
|
if (Array.isArray(currentValue) && Array.isArray(loadedValue)) {
|
|
135
|
+
const metadataKey = getBaseSalesUniqueArrayMetadataKey(key);
|
|
136
|
+
if (metadataKey) {
|
|
137
|
+
return mergeBaseSalesUniqueArray(currentValue, loadedValue, metadataKey);
|
|
138
|
+
}
|
|
240
139
|
return [
|
|
241
140
|
...(0, import_lodash_es.cloneDeep)(currentValue),
|
|
242
141
|
...(0, import_lodash_es.cloneDeep)(loadedValue)
|
|
@@ -251,9 +150,7 @@ function mergeSalesDetailRecordWithTempOrder(currentTempOrder, loadedRecord, str
|
|
|
251
150
|
}
|
|
252
151
|
);
|
|
253
152
|
delete mergedRecord.request_unique_idempotency_token;
|
|
254
|
-
return
|
|
255
|
-
(0, import_orderCollectionIdentity.applyOrderCollectionUidRemaps)(mergedRecord, uidRemaps)
|
|
256
|
-
);
|
|
153
|
+
return mergedRecord;
|
|
257
154
|
}
|
|
258
155
|
var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
259
156
|
constructor(name, version) {
|
|
@@ -275,13 +172,9 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
275
172
|
this.queuedAutoPaymentSync = false;
|
|
276
173
|
this.autoPaymentSyncFlushing = false;
|
|
277
174
|
this.autoPaymentSyncTimer = null;
|
|
278
|
-
this.
|
|
279
|
-
this.salesDetailLoadSequence = 0;
|
|
280
|
-
this.salesDetailHydrateQueue = Promise.resolve();
|
|
175
|
+
this.salesDetailLoadInFlight = false;
|
|
281
176
|
this.serverOrderChangeUnsubscribe = null;
|
|
282
177
|
this.serverOrderChangeHydrateInFlight = null;
|
|
283
|
-
this.queuedServerOrderChanges = [];
|
|
284
|
-
this.serverOrderChangeSyncEnabled = false;
|
|
285
178
|
}
|
|
286
179
|
/**
|
|
287
180
|
* 子类可覆盖此方法以追加/收敛要注册的子模块。
|
|
@@ -355,59 +248,19 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
355
248
|
].filter(Boolean);
|
|
356
249
|
return currentRecords.some((record) => isSameBaseSalesOrderRecord(record, order));
|
|
357
250
|
}
|
|
358
|
-
setServerOrderChangeSyncEnabled(enabled) {
|
|
359
|
-
this.serverOrderChangeSyncEnabled = enabled;
|
|
360
|
-
if (!enabled)
|
|
361
|
-
this.queuedServerOrderChanges = [];
|
|
362
|
-
}
|
|
363
|
-
queueLatestServerOrderChange(order) {
|
|
364
|
-
const snapshot = (0, import_lodash_es.cloneDeep)(order);
|
|
365
|
-
const existingIndex = this.queuedServerOrderChanges.findIndex(
|
|
366
|
-
(queued) => isSameBaseSalesOrderRecord(queued, snapshot)
|
|
367
|
-
);
|
|
368
|
-
if (existingIndex >= 0) {
|
|
369
|
-
this.queuedServerOrderChanges[existingIndex] = snapshot;
|
|
370
|
-
return;
|
|
371
|
-
}
|
|
372
|
-
this.queuedServerOrderChanges.push(snapshot);
|
|
373
|
-
}
|
|
374
|
-
async drainQueuedServerOrderChanges() {
|
|
375
|
-
if (!this.serverOrderChangeSyncEnabled || this.salesDetailLoadInFlightCount > 0 || this.serverOrderChangeHydrateInFlight || this.queuedServerOrderChanges.length === 0)
|
|
376
|
-
return;
|
|
377
|
-
const changedOrders = this.queuedServerOrderChanges;
|
|
378
|
-
this.queuedServerOrderChanges = [];
|
|
379
|
-
await this.syncCurrentSalesDetailFromServerOrderChange({ changedOrders });
|
|
380
|
-
}
|
|
381
251
|
async syncCurrentSalesDetailFromServerOrderChange(payload) {
|
|
382
252
|
const changedOrders = Array.isArray(payload) ? payload : Array.isArray(payload == null ? void 0 : payload.changedOrders) ? payload.changedOrders : (payload == null ? void 0 : payload.data) && typeof payload.data === "object" ? [payload.data] : [];
|
|
383
|
-
if (
|
|
253
|
+
if (this.salesDetailLoadInFlight || this.serverOrderChangeHydrateInFlight)
|
|
384
254
|
return;
|
|
385
|
-
if (this.salesDetailLoadInFlightCount > 0) {
|
|
386
|
-
changedOrders.forEach(
|
|
387
|
-
(order) => this.queueLatestServerOrderChange(order)
|
|
388
|
-
);
|
|
389
|
-
return;
|
|
390
|
-
}
|
|
391
255
|
const changedOrder = changedOrders.find(
|
|
392
256
|
(order) => this.isCurrentSalesOrderRecord(order)
|
|
393
257
|
);
|
|
394
258
|
if (!changedOrder)
|
|
395
259
|
return;
|
|
396
|
-
if (this.serverOrderChangeHydrateInFlight) {
|
|
397
|
-
this.queueLatestServerOrderChange(changedOrder);
|
|
398
|
-
return;
|
|
399
|
-
}
|
|
400
260
|
if (!this.store.order)
|
|
401
261
|
return;
|
|
402
262
|
this.serverOrderChangeHydrateInFlight = (async () => {
|
|
403
|
-
|
|
404
|
-
const currentTempOrder = (_b = (_a = this.store.order).getTempOrder) == null ? void 0 : _b.call(_a);
|
|
405
|
-
const record = mergeSalesDetailRecordWithTempOrder(
|
|
406
|
-
currentTempOrder,
|
|
407
|
-
changedOrder,
|
|
408
|
-
"authoritative-incoming"
|
|
409
|
-
);
|
|
410
|
-
const sales = await this.store.order.hydrateTempOrderFromRecord(record, {
|
|
263
|
+
const sales = await this.store.order.hydrateTempOrderFromRecord(changedOrder, {
|
|
411
264
|
recalcOnHydrate: false
|
|
412
265
|
});
|
|
413
266
|
this.currentSalesDetail = sales;
|
|
@@ -417,7 +270,6 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
417
270
|
await this.serverOrderChangeHydrateInFlight;
|
|
418
271
|
} finally {
|
|
419
272
|
this.serverOrderChangeHydrateInFlight = null;
|
|
420
|
-
await this.drainQueuedServerOrderChanges();
|
|
421
273
|
}
|
|
422
274
|
}
|
|
423
275
|
registerServerOrderChangeSync() {
|
|
@@ -427,42 +279,13 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
427
279
|
if (!effects || typeof effects.on !== "function")
|
|
428
280
|
return;
|
|
429
281
|
this.serverOrderChangeUnsubscribe = effects.on(SERVER_ORDER_CHANGED_EVENT, (payload) => {
|
|
430
|
-
|
|
282
|
+
void this.syncCurrentSalesDetailFromServerOrderChange(payload).catch((error) => {
|
|
431
283
|
this.logError("sync sales detail from server order change failed", {
|
|
432
284
|
error: error instanceof Error ? error.message : String(error)
|
|
433
285
|
});
|
|
434
286
|
});
|
|
435
287
|
});
|
|
436
288
|
}
|
|
437
|
-
async hydrateLatestLoadedSalesDetail(record, loadSequence) {
|
|
438
|
-
let hydratedSales = null;
|
|
439
|
-
let skippedBeforeHydrate = false;
|
|
440
|
-
const hydrateTask = async () => {
|
|
441
|
-
if (loadSequence !== this.salesDetailLoadSequence) {
|
|
442
|
-
skippedBeforeHydrate = true;
|
|
443
|
-
return;
|
|
444
|
-
}
|
|
445
|
-
if (!this.store.order)
|
|
446
|
-
throw new Error("order 模块未初始化");
|
|
447
|
-
const sales = await this.store.order.hydrateTempOrderFromRecord(record, {
|
|
448
|
-
recalcOnHydrate: false
|
|
449
|
-
});
|
|
450
|
-
hydratedSales = sales;
|
|
451
|
-
if (loadSequence !== this.salesDetailLoadSequence)
|
|
452
|
-
return;
|
|
453
|
-
this.currentSalesDetail = sales;
|
|
454
|
-
await this.core.effects.emit(`${this.name}:onSalesOrderLoaded`, { sales });
|
|
455
|
-
};
|
|
456
|
-
const queuedTask = this.salesDetailHydrateQueue.then(hydrateTask, hydrateTask);
|
|
457
|
-
this.salesDetailHydrateQueue = queuedTask.then(
|
|
458
|
-
() => void 0,
|
|
459
|
-
() => void 0
|
|
460
|
-
);
|
|
461
|
-
await queuedTask;
|
|
462
|
-
if (skippedBeforeHydrate)
|
|
463
|
-
return record;
|
|
464
|
-
return hydratedSales || this.currentSalesDetail || record;
|
|
465
|
-
}
|
|
466
289
|
hydrateOrderPaymentNames(payments) {
|
|
467
290
|
if (!payments.length)
|
|
468
291
|
return [];
|
|
@@ -897,8 +720,6 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
897
720
|
}
|
|
898
721
|
});
|
|
899
722
|
this.currentSalesDetail = null;
|
|
900
|
-
this.queuedServerOrderChanges = [];
|
|
901
|
-
this.salesDetailLoadSequence += 1;
|
|
902
723
|
await this.core.effects.emit(`${this.name}:onDestroy`, {});
|
|
903
724
|
super.destroy();
|
|
904
725
|
}
|
|
@@ -912,8 +733,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
912
733
|
async loadSalesDetail(orderIdOrParams) {
|
|
913
734
|
if (!this.store.order)
|
|
914
735
|
throw new Error("order 模块未初始化");
|
|
915
|
-
|
|
916
|
-
this.salesDetailLoadInFlightCount += 1;
|
|
736
|
+
this.salesDetailLoadInFlight = true;
|
|
917
737
|
try {
|
|
918
738
|
const params = typeof orderIdOrParams === "object" ? orderIdOrParams : { orderId: orderIdOrParams };
|
|
919
739
|
const externalSaleNumber = params.externalSaleNumber || params.external_sale_number;
|
|
@@ -932,26 +752,15 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
932
752
|
}
|
|
933
753
|
const remoteRecord = preloadedSalesDetail ?? loadedRecord.data;
|
|
934
754
|
const currentTempOrder = params.merge ? this.store.order.getTempOrder() : null;
|
|
935
|
-
const record = params.merge ? mergeSalesDetailRecordWithTempOrder(
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
755
|
+
const record = params.merge ? mergeSalesDetailRecordWithTempOrder(currentTempOrder, remoteRecord) : remoteRecord;
|
|
756
|
+
const sales = await this.store.order.hydrateTempOrderFromRecord(record, {
|
|
757
|
+
recalcOnHydrate: false
|
|
758
|
+
});
|
|
759
|
+
this.currentSalesDetail = sales;
|
|
760
|
+
await this.core.effects.emit(`${this.name}:onSalesOrderLoaded`, { sales });
|
|
761
|
+
return sales;
|
|
941
762
|
} finally {
|
|
942
|
-
this.
|
|
943
|
-
0,
|
|
944
|
-
this.salesDetailLoadInFlightCount - 1
|
|
945
|
-
);
|
|
946
|
-
if (this.salesDetailLoadInFlightCount === 0) {
|
|
947
|
-
try {
|
|
948
|
-
await this.drainQueuedServerOrderChanges();
|
|
949
|
-
} catch (error) {
|
|
950
|
-
this.logError("drain queued server order changes failed", {
|
|
951
|
-
error: error instanceof Error ? error.message : String(error)
|
|
952
|
-
});
|
|
953
|
-
}
|
|
954
|
-
}
|
|
763
|
+
this.salesDetailLoadInFlight = false;
|
|
955
764
|
}
|
|
956
765
|
}
|
|
957
766
|
/** 获取当前已加载的销售详情(只读快照)。未加载过则返回 null。 */
|
|
@@ -1285,7 +1094,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1285
1094
|
});
|
|
1286
1095
|
}
|
|
1287
1096
|
async loadDiscountConfig(params) {
|
|
1288
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
|
|
1097
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
|
|
1289
1098
|
if (!this.store.order)
|
|
1290
1099
|
throw new Error("order 模块未初始化");
|
|
1291
1100
|
const tempOrder = this.store.order.ensureTempOrder();
|
|
@@ -1323,8 +1132,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1323
1132
|
if (hasManualDiscountSelection && currentDiscountList.length) {
|
|
1324
1133
|
return {
|
|
1325
1134
|
productList: tempOrder.products || [],
|
|
1326
|
-
discountList: currentDiscountList
|
|
1327
|
-
availableWalletIds: this.getAvailableWalletIds()
|
|
1135
|
+
discountList: currentDiscountList
|
|
1328
1136
|
};
|
|
1329
1137
|
}
|
|
1330
1138
|
let nextDiscountList = this.mergeHistoricalDiscountList(
|
|
@@ -1353,17 +1161,17 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1353
1161
|
});
|
|
1354
1162
|
return {
|
|
1355
1163
|
productList: tempOrder.products || [],
|
|
1356
|
-
discountList: nextDiscountList
|
|
1357
|
-
availableWalletIds: this.getAvailableWalletIds()
|
|
1164
|
+
discountList: nextDiscountList
|
|
1358
1165
|
};
|
|
1359
1166
|
}
|
|
1360
1167
|
if (rulesModule) {
|
|
1361
|
-
const
|
|
1168
|
+
const holders = ((_l = tempOrder.holder) == null ? void 0 : _l.form_record) || [];
|
|
1169
|
+
const orderTotalAmount = Number(((_m = orderStore.summary) == null ? void 0 : _m.total_amount) || 0);
|
|
1362
1170
|
console.log("[BaseSales.applyDiscountConfig.calcDiscount]");
|
|
1363
1171
|
const result = rulesModule.calcDiscount({
|
|
1364
1172
|
productList: tempOrder.products,
|
|
1365
1173
|
discountList: nextDiscountList,
|
|
1366
|
-
holders
|
|
1174
|
+
holders,
|
|
1367
1175
|
isFormSubject: (product) => (0, import_utils.resolveIsFormSubject)(tempOrder, product),
|
|
1368
1176
|
orderTotalAmount
|
|
1369
1177
|
}) || { productList: tempOrder.products, discountList: nextDiscountList };
|
|
@@ -1374,8 +1182,8 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1374
1182
|
);
|
|
1375
1183
|
}
|
|
1376
1184
|
for (const product of tempOrder.products || []) {
|
|
1377
|
-
const productUid = (
|
|
1378
|
-
const runtimeOrigin = productUid ? (
|
|
1185
|
+
const productUid = (_n = product.metadata) == null ? void 0 : _n.unique_identification_number;
|
|
1186
|
+
const runtimeOrigin = productUid ? (_q = (_p = (_o = tempOrder._extend) == null ? void 0 : _o.productsByUid) == null ? void 0 : _p[productUid]) == null ? void 0 : _q.origin : void 0;
|
|
1379
1187
|
if ((runtimeOrigin == null ? void 0 : runtimeOrigin.isManualDiscount) || isBaseSalesManualProductDiscountProduct(product))
|
|
1380
1188
|
continue;
|
|
1381
1189
|
const totalPerUnitDiscount = (product.discount_list || []).reduce(
|
|
@@ -1383,7 +1191,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1383
1191
|
0
|
|
1384
1192
|
);
|
|
1385
1193
|
const optionSum = (0, import_utils.sumOptionUnitPrice)((0, import_utils.getProductSkuOptions)(product));
|
|
1386
|
-
const sourcePrice = ((
|
|
1194
|
+
const sourcePrice = ((_r = product.metadata) == null ? void 0 : _r.source_product_price) ?? (((_s = product.metadata) == null ? void 0 : _s.main_product_original_price) != null ? new import_decimal.default(Number(product.metadata.main_product_original_price) || 0).minus(optionSum).toFixed(2) : product.original_price ?? "0");
|
|
1387
1195
|
const newSourceSellingPrice = new import_decimal.default(Number(sourcePrice) || 0).minus(totalPerUnitDiscount).toDecimalPlaces(2).toString();
|
|
1388
1196
|
const newMainSellingPrice = new import_decimal.default(Number(newSourceSellingPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
|
|
1389
1197
|
if (product.metadata) {
|
|
@@ -1415,18 +1223,11 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1415
1223
|
});
|
|
1416
1224
|
return {
|
|
1417
1225
|
productList: tempOrder.products || [],
|
|
1418
|
-
discountList: nextDiscountList
|
|
1419
|
-
availableWalletIds: this.getAvailableWalletIds()
|
|
1226
|
+
discountList: nextDiscountList
|
|
1420
1227
|
};
|
|
1421
1228
|
}
|
|
1422
|
-
getAvailableWalletIds() {
|
|
1423
|
-
var _a;
|
|
1424
|
-
if (!((_a = this.store.order) == null ? void 0 : _a.getAvailableWalletIds))
|
|
1425
|
-
return [];
|
|
1426
|
-
return this.store.order.getAvailableWalletIds();
|
|
1427
|
-
}
|
|
1428
1229
|
async bestDiscount(cb) {
|
|
1429
|
-
var _a, _b, _c;
|
|
1230
|
+
var _a, _b, _c, _d;
|
|
1430
1231
|
if (!this.store.order)
|
|
1431
1232
|
throw new Error("order 模块未初始化");
|
|
1432
1233
|
const tempOrder = this.store.order.ensureTempOrder();
|
|
@@ -1445,12 +1246,13 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1445
1246
|
};
|
|
1446
1247
|
await (discountModule == null ? void 0 : discountModule.setDiscountList(nextDiscountList));
|
|
1447
1248
|
if (rulesModule) {
|
|
1448
|
-
const
|
|
1249
|
+
const holders = ((_c = tempOrder.holder) == null ? void 0 : _c.form_record) || [];
|
|
1250
|
+
const orderTotalAmount = Number(((_d = orderStore.summary) == null ? void 0 : _d.total_amount) || 0);
|
|
1449
1251
|
console.log("[BaseSales.bestDiscount.calcDiscount]");
|
|
1450
1252
|
result = rulesModule.calcDiscount({
|
|
1451
1253
|
productList: tempOrder.products,
|
|
1452
1254
|
discountList: nextDiscountList,
|
|
1453
|
-
holders
|
|
1255
|
+
holders,
|
|
1454
1256
|
isFormSubject: (product) => (0, import_utils.resolveIsFormSubject)(tempOrder, product),
|
|
1455
1257
|
orderTotalAmount
|
|
1456
1258
|
}) || result;
|
|
@@ -1476,12 +1278,6 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1476
1278
|
}
|
|
1477
1279
|
await this.store.order.recalculateSummary({ createIfMissing: true });
|
|
1478
1280
|
this.store.order.persistTempOrder();
|
|
1479
|
-
await this.effectsEmit("onDiscountApplied", {
|
|
1480
|
-
productList: tempOrder.products || [],
|
|
1481
|
-
discountList: nextDiscountList,
|
|
1482
|
-
selectedDiscountList: tempOrder.discount_list || [],
|
|
1483
|
-
tempOrder
|
|
1484
|
-
});
|
|
1485
1281
|
cb == null ? void 0 : cb(result);
|
|
1486
1282
|
return result;
|
|
1487
1283
|
}
|
|
@@ -1490,30 +1286,6 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1490
1286
|
return [];
|
|
1491
1287
|
return this.store.order.getDiscountList();
|
|
1492
1288
|
}
|
|
1493
|
-
/** 读取 Discount 模块原始券列表(未经过 bookingTime 等过滤)。 */
|
|
1494
|
-
getOriginalDiscountList() {
|
|
1495
|
-
var _a, _b;
|
|
1496
|
-
if (!this.store.order)
|
|
1497
|
-
return [];
|
|
1498
|
-
const discountModule = (_a = this.store.order.store) == null ? void 0 : _a.discount;
|
|
1499
|
-
return ((_b = discountModule == null ? void 0 : discountModule.getOriginalDiscountList) == null ? void 0 : _b.call(discountModule)) || [];
|
|
1500
|
-
}
|
|
1501
|
-
/**
|
|
1502
|
-
* 同步写入 Discount 模块的 discountList / originalDiscountList。
|
|
1503
|
-
* 供 Holder 补全等场景在 OS store 层更新 machinecode holder 字段。
|
|
1504
|
-
*/
|
|
1505
|
-
async replaceDiscountStoreLists(params) {
|
|
1506
|
-
var _a;
|
|
1507
|
-
if (!this.store.order)
|
|
1508
|
-
throw new Error("order 模块未初始化");
|
|
1509
|
-
const discountModule = (_a = this.store.order.store) == null ? void 0 : _a.discount;
|
|
1510
|
-
if (!discountModule)
|
|
1511
|
-
return;
|
|
1512
|
-
if (params.originalDiscountList) {
|
|
1513
|
-
await discountModule.setOriginalDiscountList(params.originalDiscountList);
|
|
1514
|
-
}
|
|
1515
|
-
await discountModule.setDiscountList(params.discountList);
|
|
1516
|
-
}
|
|
1517
1289
|
async scanPromotionCode(code, customerId) {
|
|
1518
1290
|
try {
|
|
1519
1291
|
if (!this.store.order)
|
|
@@ -1522,19 +1294,11 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1522
1294
|
if (raw.isAvailable) {
|
|
1523
1295
|
await this.store.order.recalculateSummary({ createIfMissing: true });
|
|
1524
1296
|
this.store.order.persistTempOrder();
|
|
1525
|
-
const tempOrder = this.store.order.ensureTempOrder();
|
|
1526
|
-
await this.effectsEmit("onDiscountApplied", {
|
|
1527
|
-
productList: tempOrder.products || [],
|
|
1528
|
-
discountList: this.store.order.getDiscountList(),
|
|
1529
|
-
selectedDiscountList: tempOrder.discount_list || [],
|
|
1530
|
-
tempOrder
|
|
1531
|
-
});
|
|
1532
1297
|
}
|
|
1533
1298
|
return {
|
|
1534
1299
|
isAvailable: raw.isAvailable,
|
|
1535
1300
|
type: raw.type,
|
|
1536
|
-
unavailableReason: raw.unavailableReason
|
|
1537
|
-
scannedDiscountList: raw.scannedDiscountList
|
|
1301
|
+
unavailableReason: raw.unavailableReason
|
|
1538
1302
|
};
|
|
1539
1303
|
} catch (error) {
|
|
1540
1304
|
throw error;
|
|
@@ -1542,7 +1306,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1542
1306
|
}
|
|
1543
1307
|
// TODO 需要优化,这段逻辑太长了,里面应该有些历史遗留问题
|
|
1544
1308
|
async setDiscountSelected(params) {
|
|
1545
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
1309
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1546
1310
|
try {
|
|
1547
1311
|
if (!this.store.order)
|
|
1548
1312
|
throw new Error("order 模块未初始化");
|
|
@@ -1559,16 +1323,17 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1559
1323
|
const orderStore = this.store.order.store || {};
|
|
1560
1324
|
const discountModule = orderStore.discount;
|
|
1561
1325
|
const rulesModule = orderStore.rules;
|
|
1326
|
+
const holders = ((_a = tempOrder.holder) == null ? void 0 : _a.form_record) || [];
|
|
1562
1327
|
let nextDiscountList = updated;
|
|
1563
1328
|
await (discountModule == null ? void 0 : discountModule.setDiscountList(updated));
|
|
1564
1329
|
if (rulesModule) {
|
|
1565
|
-
const orderTotalAmount = Number(((
|
|
1330
|
+
const orderTotalAmount = Number(((_b = orderStore.summary) == null ? void 0 : _b.total_amount) || 0);
|
|
1566
1331
|
console.log("[BaseSales.setDiscountSelected.calcDiscount]");
|
|
1567
1332
|
const result = rulesModule.calcDiscount(
|
|
1568
1333
|
{
|
|
1569
1334
|
productList: tempOrder.products,
|
|
1570
1335
|
discountList: updated,
|
|
1571
|
-
holders
|
|
1336
|
+
holders,
|
|
1572
1337
|
isFormSubject: (product) => (0, import_utils.resolveIsFormSubject)(tempOrder, product),
|
|
1573
1338
|
orderTotalAmount
|
|
1574
1339
|
},
|
|
@@ -1608,8 +1373,8 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1608
1373
|
return rid != null && selectedResourceIds.has(rid);
|
|
1609
1374
|
});
|
|
1610
1375
|
for (const product of tempOrder.products) {
|
|
1611
|
-
const productUid = (
|
|
1612
|
-
const runtimeOrigin = productUid ? (
|
|
1376
|
+
const productUid = (_c = product.metadata) == null ? void 0 : _c.unique_identification_number;
|
|
1377
|
+
const runtimeOrigin = productUid ? (_f = (_e = (_d = tempOrder._extend) == null ? void 0 : _d.productsByUid) == null ? void 0 : _e[productUid]) == null ? void 0 : _f.origin : void 0;
|
|
1613
1378
|
if ((runtimeOrigin == null ? void 0 : runtimeOrigin.isManualDiscount) || isBaseSalesManualProductDiscountProduct(product))
|
|
1614
1379
|
continue;
|
|
1615
1380
|
product.discount_list = filterSelectedDiscountDetails(product.discount_list);
|
|
@@ -1633,7 +1398,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1633
1398
|
0
|
|
1634
1399
|
);
|
|
1635
1400
|
const optionSum = (0, import_utils.sumOptionUnitPrice)((0, import_utils.getProductSkuOptions)(product));
|
|
1636
|
-
const sourcePrice = ((
|
|
1401
|
+
const sourcePrice = ((_g = product.metadata) == null ? void 0 : _g.source_product_price) ?? (((_h = product.metadata) == null ? void 0 : _h.main_product_original_price) != null ? new import_decimal.default(Number(product.metadata.main_product_original_price) || 0).minus(optionSum).toFixed(2) : product.original_price ?? "0");
|
|
1637
1402
|
const newSourceSellingPrice = new import_decimal.default(Number(sourcePrice) || 0).minus(totalPerUnitDiscount).toDecimalPlaces(2).toString();
|
|
1638
1403
|
const newMainSellingPrice = new import_decimal.default(Number(newSourceSellingPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
|
|
1639
1404
|
if (product.metadata) {
|
|
@@ -1687,12 +1452,6 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1687
1452
|
}
|
|
1688
1453
|
await this.store.order.recalculateSummary({ createIfMissing: true });
|
|
1689
1454
|
this.store.order.persistTempOrder();
|
|
1690
|
-
await this.effectsEmit("onDiscountApplied", {
|
|
1691
|
-
productList: tempOrder.products || [],
|
|
1692
|
-
discountList: result.discountList || [],
|
|
1693
|
-
selectedDiscountList: tempOrder.discount_list || [],
|
|
1694
|
-
tempOrder
|
|
1695
|
-
});
|
|
1696
1455
|
} catch (error) {
|
|
1697
1456
|
throw error;
|
|
1698
1457
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { Discount } from '../../modules/Discount/types';
|
|
2
1
|
import { OrderModule, ProductList, QuotationModule, SalesSummaryModule, ScanOrderLoggerModule as BaseSalesLoggerModule, ScheduleModule } from '../../modules';
|
|
3
2
|
import type { ScanOrderLogInput as BaseSalesLogInput, ScanOrderLoggerProviderConfig as BaseSalesLoggerProviderConfig, ScanOrderLoggerProviderType as BaseSalesLoggerProviderType } from '../../modules/ScanOrderLogger/types';
|
|
4
3
|
import type { QuantityCheckResult, QuantityLimitResult } from '../../model/strategy/adapter/itemRule';
|
|
@@ -86,8 +85,6 @@ export interface BaseSalesOrderProduct extends BaseSalesOrderProductIdentity {
|
|
|
86
85
|
booking_uid?: string;
|
|
87
86
|
/** 多语言商品标题快照,随 tempOrder 提交到 checkout。 */
|
|
88
87
|
product_title?: BaseSalesLocalizedText;
|
|
89
|
-
/** 商品封面图快照,随 tempOrder 提交到 checkout。 */
|
|
90
|
-
product_cover?: string;
|
|
91
88
|
/**
|
|
92
89
|
* 行级扩展 metadata。价格相关的权威字段:
|
|
93
90
|
*
|
|
@@ -384,11 +381,9 @@ export interface BaseSalesLoggerRuntimeConfig {
|
|
|
384
381
|
}
|
|
385
382
|
export interface BaseSalesAddLogParams extends BaseSalesLogInput {
|
|
386
383
|
}
|
|
387
|
-
/** BaseSales.scanPromotionCode
|
|
384
|
+
/** BaseSales.scanPromotionCode 对外的轻量结果(不含 discountList,UI 在 resolve 后调 getDiscountList) */
|
|
388
385
|
export interface BaseSalesScanCodeResult {
|
|
389
386
|
isAvailable: boolean;
|
|
390
387
|
type?: 'server' | string;
|
|
391
388
|
unavailableReason?: 'time_limit' | string;
|
|
392
|
-
/** batchSearch 原始结果;isAvailable=false 时 discountList 可能未写入 store,Holder 补全需读此字段 */
|
|
393
|
-
scannedDiscountList?: Discount[];
|
|
394
389
|
}
|
|
@@ -78,6 +78,7 @@ export interface CartPromotionEvaluator {
|
|
|
78
78
|
}>;
|
|
79
79
|
hasApplicableStrategy: boolean;
|
|
80
80
|
}>;
|
|
81
|
+
getStrategyConfigs?: () => unknown[];
|
|
81
82
|
}
|
|
82
83
|
/** 单个赠品减量项 */
|
|
83
84
|
export interface GiftReduceItem {
|
|
@@ -267,7 +268,8 @@ export declare function appendPromotionTags<T extends Record<string, any>>(produ
|
|
|
267
268
|
* 处理购物车的促销计算与赠品差异化。
|
|
268
269
|
*
|
|
269
270
|
* 流程:
|
|
270
|
-
* 1. 分离 main / gift / edit-product
|
|
271
|
+
* 1. 分离 main / gift / edit-product 三类(普通促销下带 `booking_id` 的编辑态商品不参与;
|
|
272
|
+
* 配置 ITEM_REWARD 时,编辑态商品也参与商品奖励重算)
|
|
271
273
|
* 2. 转 PromotionProduct 喂评估器 → 拿到 `evaluateCartWithPricing` 与 `getProductsApplicableStrategies`
|
|
272
274
|
* 3. 把 PricedProduct 映射回 OrderProduct 形态:
|
|
273
275
|
* - 参与促销的,写 `metadata._promotion` + 调整 `selling_price` / `main_product_selling_price`
|