@pisell/pisellos 2.2.273 → 2.2.274
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/core/index.d.ts +0 -2
- package/dist/core/index.js +0 -7
- package/dist/model/strategy/adapter/promotion/adapter.d.ts +0 -4
- package/dist/model/strategy/adapter/promotion/adapter.js +0 -23
- package/dist/model/strategy/adapter/promotion/evaluator.d.ts +0 -17
- package/dist/model/strategy/adapter/promotion/evaluator.js +6 -279
- package/dist/model/strategy/adapter/promotion/examples.d.ts +0 -86
- package/dist/model/strategy/adapter/promotion/examples.js +0 -99
- package/dist/model/strategy/adapter/promotion/index.d.ts +1 -1
- package/dist/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/model/strategy/adapter/promotion/type.d.ts +2 -90
- package/dist/model/strategy/adapter/promotion/type.js +0 -45
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +12 -10
- package/dist/modules/OpenData/index.d.ts +0 -2
- package/dist/modules/OpenData/index.js +0 -8
- package/dist/modules/Order/index.d.ts +13 -32
- package/dist/modules/Order/index.js +555 -771
- package/dist/modules/Order/types.d.ts +22 -36
- package/dist/modules/Order/types.js +11 -0
- package/dist/modules/Order/utils/orderCollectionIdentity.js +2 -7
- package/dist/modules/Order/utils.js +6 -10
- package/dist/modules/Payment/index.d.ts +0 -2
- package/dist/modules/Payment/index.js +50 -79
- package/dist/modules/Payment/types.d.ts +27 -29
- package/dist/modules/Payment/types.js +3 -5
- package/dist/modules/Rules/index.d.ts +0 -1
- package/dist/modules/Rules/index.js +39 -55
- package/dist/modules/SalesSummary/utils.js +7 -1
- package/dist/server/index.d.ts +0 -16
- package/dist/server/index.js +1036 -1933
- package/dist/server/modules/order/index.d.ts +4 -54
- package/dist/server/modules/order/index.js +695 -1595
- package/dist/server/modules/order/types.d.ts +3 -11
- package/dist/server/modules/order/types.js +1 -1
- package/dist/solution/BaseSales/index.d.ts +25 -59
- package/dist/solution/BaseSales/index.js +490 -767
- package/dist/solution/BaseSales/utils/cartPromotion.d.ts +1 -3
- package/dist/solution/BaseSales/utils/cartPromotion.js +36 -93
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -6
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +5 -21
- package/dist/solution/BookingTicket/index.js +49 -126
- package/dist/solution/BookingTicket/types.d.ts +3 -0
- package/dist/solution/BookingTicket/utils/cartView.js +44 -32
- package/dist/solution/Sales/index.d.ts +0 -1
- package/dist/solution/Sales/index.js +2 -10
- package/dist/solution/ScanOrder/index.js +20 -31
- package/dist/solution/VenueBooking/index.js +19 -30
- package/dist/types/index.d.ts +0 -1
- package/lib/core/index.d.ts +0 -2
- package/lib/core/index.js +0 -4
- package/lib/model/strategy/adapter/promotion/adapter.d.ts +0 -4
- package/lib/model/strategy/adapter/promotion/adapter.js +0 -20
- package/lib/model/strategy/adapter/promotion/evaluator.d.ts +0 -17
- package/lib/model/strategy/adapter/promotion/evaluator.js +0 -235
- package/lib/model/strategy/adapter/promotion/examples.d.ts +0 -86
- package/lib/model/strategy/adapter/promotion/examples.js +0 -91
- package/lib/model/strategy/adapter/promotion/index.d.ts +1 -1
- package/lib/model/strategy/adapter/promotion/index.js +0 -2
- package/lib/model/strategy/adapter/promotion/type.d.ts +2 -90
- package/lib/model/strategy/adapter/promotion/type.js +0 -2
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +3 -1
- package/lib/modules/OpenData/index.d.ts +0 -2
- package/lib/modules/OpenData/index.js +0 -5
- package/lib/modules/Order/index.d.ts +13 -32
- package/lib/modules/Order/index.js +142 -201
- package/lib/modules/Order/types.d.ts +22 -36
- package/lib/modules/Order/utils/orderCollectionIdentity.js +0 -3
- package/lib/modules/Order/utils.js +4 -11
- package/lib/modules/Payment/index.d.ts +0 -2
- package/lib/modules/Payment/index.js +13 -34
- package/lib/modules/Payment/types.d.ts +27 -29
- package/lib/modules/Payment/types.js +3 -3
- package/lib/modules/Rules/index.d.ts +0 -1
- package/lib/modules/Rules/index.js +22 -41
- package/lib/modules/SalesSummary/utils.js +5 -1
- package/lib/server/index.d.ts +0 -16
- package/lib/server/index.js +18 -670
- package/lib/server/modules/order/index.d.ts +4 -54
- package/lib/server/modules/order/index.js +66 -679
- package/lib/server/modules/order/types.d.ts +3 -11
- package/lib/solution/BaseSales/index.d.ts +25 -59
- package/lib/solution/BaseSales/index.js +79 -246
- package/lib/solution/BaseSales/utils/cartPromotion.d.ts +1 -3
- package/lib/solution/BaseSales/utils/cartPromotion.js +17 -65
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -6
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +5 -21
- package/lib/solution/BookingTicket/index.js +8 -59
- package/lib/solution/BookingTicket/types.d.ts +3 -0
- package/lib/solution/BookingTicket/utils/cartView.js +43 -30
- package/lib/solution/Sales/index.d.ts +0 -1
- package/lib/solution/Sales/index.js +3 -5
- package/lib/solution/ScanOrder/index.js +0 -8
- package/lib/solution/VenueBooking/index.js +0 -8
- package/lib/types/index.d.ts +0 -1
- package/package.json +1 -1
- package/dist/modules/Order/payment-utils.d.ts +0 -26
- package/dist/modules/Order/payment-utils.js +0 -225
- package/dist/utils/payment-number.d.ts +0 -9
- package/dist/utils/payment-number.js +0 -69
- package/lib/modules/Order/payment-utils.d.ts +0 -26
- package/lib/modules/Order/payment-utils.js +0 -224
- package/lib/utils/payment-number.d.ts +0 -9
- package/lib/utils/payment-number.js +0 -64
|
@@ -40,8 +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_payment_utils = require("../../modules/Order/payment-utils");
|
|
44
|
-
var import_payment_number = require("../../utils/payment-number");
|
|
45
43
|
var import_orderCollectionIdentity = require("../../modules/Order/utils/orderCollectionIdentity");
|
|
46
44
|
var import_dayjs = __toESM(require("dayjs"));
|
|
47
45
|
__reExport(BaseSales_exports, require("./types"), module.exports);
|
|
@@ -79,11 +77,6 @@ function isBaseSalesHistoricalDiscountEntry(discount) {
|
|
|
79
77
|
(discount == null ? void 0 : discount.isEditMode) || (discount == null ? void 0 : discount.isDisabled) || (discount == null ? void 0 : discount.order_discount_id) != null
|
|
80
78
|
);
|
|
81
79
|
}
|
|
82
|
-
function getBaseSalesUniqueArrayMetadataKey(key) {
|
|
83
|
-
if (key === "products" || key === "bookings")
|
|
84
|
-
return "unique_identification_number";
|
|
85
|
-
return null;
|
|
86
|
-
}
|
|
87
80
|
var BASE_SALES_PERSISTENT_ID_FIELD_BY_KIND = {
|
|
88
81
|
product: "order_detail_id",
|
|
89
82
|
booking: "schedule_event_id",
|
|
@@ -157,15 +150,6 @@ function mergeBaseSalesCollectionItem(kind, currentItem, incomingItem, uidRemaps
|
|
|
157
150
|
return kind === "product" ? mergeBaseSalesProductSnapshotFields(currentItem, mergedItem) : mergedItem;
|
|
158
151
|
}
|
|
159
152
|
function mergeBaseSalesOrderCollection(kind, currentValue, incomingValue, strategy, uidRemaps) {
|
|
160
|
-
if (kind === "payment") {
|
|
161
|
-
return (0, import_payment_utils.mergeOrderPaymentListsByIdentity)(
|
|
162
|
-
currentValue,
|
|
163
|
-
incomingValue,
|
|
164
|
-
strategy === "preserve-local" ? { preserveUnmatchedExisting: true } : {
|
|
165
|
-
preserveUnmatchedExistingWhen: (payment) => (0, import_payment_utils.isIdentifiedPendingOrderPayment)(payment) || !(0, import_orderCollectionIdentity.getOrderCollectionPersistentId)("payment", payment)
|
|
166
|
-
}
|
|
167
|
-
);
|
|
168
|
-
}
|
|
169
153
|
const currentItems = (0, import_orderCollectionIdentity.normalizeOrderCollection)(kind, currentValue, {
|
|
170
154
|
ensureUid: false
|
|
171
155
|
}).items;
|
|
@@ -225,35 +209,6 @@ function normalizeBaseSalesRecordCollections(sourceRecord, options) {
|
|
|
225
209
|
}
|
|
226
210
|
return normalizedRecord;
|
|
227
211
|
}
|
|
228
|
-
function getBaseSalesMetadataUid(item, metadataKey) {
|
|
229
|
-
var _a;
|
|
230
|
-
const uid = ((_a = item == null ? void 0 : item.metadata) == null ? void 0 : _a[metadataKey]) ?? (item == null ? void 0 : item[metadataKey]);
|
|
231
|
-
if (uid === void 0 || uid === null || uid === "")
|
|
232
|
-
return null;
|
|
233
|
-
return String(uid);
|
|
234
|
-
}
|
|
235
|
-
function mergeBaseSalesUniqueArray(currentValue, loadedValue, metadataKey) {
|
|
236
|
-
const result = [];
|
|
237
|
-
const indexByUid = /* @__PURE__ */ new Map();
|
|
238
|
-
const appendOrReplaceByUid = (item) => {
|
|
239
|
-
const clonedItem = (0, import_lodash_es.cloneDeep)(item);
|
|
240
|
-
const uid = getBaseSalesMetadataUid(clonedItem, metadataKey);
|
|
241
|
-
if (!uid) {
|
|
242
|
-
result.push(clonedItem);
|
|
243
|
-
return;
|
|
244
|
-
}
|
|
245
|
-
const existingIndex = indexByUid.get(uid);
|
|
246
|
-
if (existingIndex !== void 0) {
|
|
247
|
-
result[existingIndex] = clonedItem;
|
|
248
|
-
return;
|
|
249
|
-
}
|
|
250
|
-
indexByUid.set(uid, result.length);
|
|
251
|
-
result.push(clonedItem);
|
|
252
|
-
};
|
|
253
|
-
currentValue.forEach(appendOrReplaceByUid);
|
|
254
|
-
loadedValue.forEach(appendOrReplaceByUid);
|
|
255
|
-
return result;
|
|
256
|
-
}
|
|
257
212
|
function mergeSalesDetailRecordWithTempOrder(currentTempOrder, loadedRecord, strategy) {
|
|
258
213
|
const normalizedLoadedRecord = normalizeBaseSalesRecordCollections(
|
|
259
214
|
loadedRecord || {},
|
|
@@ -282,15 +237,6 @@ function mergeSalesDetailRecordWithTempOrder(currentTempOrder, loadedRecord, str
|
|
|
282
237
|
);
|
|
283
238
|
}
|
|
284
239
|
if (Array.isArray(currentValue) && Array.isArray(loadedValue)) {
|
|
285
|
-
if (key === "payments" || key === "payment") {
|
|
286
|
-
return (0, import_payment_utils.mergeOrderPaymentListsByIdentity)(currentValue, loadedValue, {
|
|
287
|
-
preserveUnmatchedExisting: true
|
|
288
|
-
});
|
|
289
|
-
}
|
|
290
|
-
const metadataKey = getBaseSalesUniqueArrayMetadataKey(key);
|
|
291
|
-
if (metadataKey) {
|
|
292
|
-
return mergeBaseSalesUniqueArray(currentValue, loadedValue, metadataKey);
|
|
293
|
-
}
|
|
294
240
|
return [
|
|
295
241
|
...(0, import_lodash_es.cloneDeep)(currentValue),
|
|
296
242
|
...(0, import_lodash_es.cloneDeep)(loadedValue)
|
|
@@ -309,18 +255,6 @@ function mergeSalesDetailRecordWithTempOrder(currentTempOrder, loadedRecord, str
|
|
|
309
255
|
(0, import_orderCollectionIdentity.applyOrderCollectionUidRemaps)(mergedRecord, uidRemaps)
|
|
310
256
|
);
|
|
311
257
|
}
|
|
312
|
-
function filterPendingPaymentsFromLoadedSalesDetail(sourceRecord) {
|
|
313
|
-
if (!sourceRecord || typeof sourceRecord !== "object")
|
|
314
|
-
return sourceRecord;
|
|
315
|
-
const record = { ...sourceRecord };
|
|
316
|
-
if (Array.isArray(sourceRecord.payments)) {
|
|
317
|
-
record.payments = sourceRecord.payments.filter((payment) => !(0, import_payment_utils.isPendingOrderPayment)(payment));
|
|
318
|
-
}
|
|
319
|
-
if (Array.isArray(sourceRecord.payment)) {
|
|
320
|
-
record.payment = sourceRecord.payment.filter((payment) => !(0, import_payment_utils.isPendingOrderPayment)(payment));
|
|
321
|
-
}
|
|
322
|
-
return record;
|
|
323
|
-
}
|
|
324
258
|
var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
325
259
|
constructor(name, version) {
|
|
326
260
|
super(name, version);
|
|
@@ -332,11 +266,6 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
332
266
|
order: void 0
|
|
333
267
|
};
|
|
334
268
|
this.otherParams = {};
|
|
335
|
-
/**
|
|
336
|
-
* 由已在初始化阶段解析过设备短号的业务解决方案写入。
|
|
337
|
-
* 未设置时,支付编号仍按原逻辑实时读取设备信息。
|
|
338
|
-
*/
|
|
339
|
-
this.paymentNumberDevicePrefix = null;
|
|
340
269
|
// 当前缓存中已加载的最新 SalesDetail;只读 getter 走它对外暴露详情数据。
|
|
341
270
|
this.currentSalesDetail = null;
|
|
342
271
|
this.discountConfigCacheKey = null;
|
|
@@ -619,6 +548,36 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
619
548
|
return null;
|
|
620
549
|
return productId;
|
|
621
550
|
}
|
|
551
|
+
/**
|
|
552
|
+
* Change Time / customer reprice 必须沿用商品列表的渠道口径。
|
|
553
|
+
* SalesSdk Provider 通常将渠道存为 platform,因此不能只读取 otherParams.channel。
|
|
554
|
+
*/
|
|
555
|
+
getPriceQueryChannel(channel) {
|
|
556
|
+
var _a, _b, _c;
|
|
557
|
+
const strategyContext = ((_a = this.otherParams) == null ? void 0 : _a.strategy_context) && typeof this.otherParams.strategy_context === "object" ? this.otherParams.strategy_context : {};
|
|
558
|
+
const value = channel ?? strategyContext.channel ?? ((_b = this.otherParams) == null ? void 0 : _b.channel) ?? ((_c = this.otherParams) == null ? void 0 : _c.platform);
|
|
559
|
+
if (value === void 0 || value === null || String(value).trim() === "") {
|
|
560
|
+
return void 0;
|
|
561
|
+
}
|
|
562
|
+
return String(value).trim();
|
|
563
|
+
}
|
|
564
|
+
/**
|
|
565
|
+
* /product/query 的智能定价评估只读取 strategy_context;
|
|
566
|
+
* application_code 仅作为接口兼容字段,不能替代 channel / business_code。
|
|
567
|
+
*/
|
|
568
|
+
getPriceQueryStrategyContext(channel) {
|
|
569
|
+
var _a, _b, _c;
|
|
570
|
+
const inherited = ((_a = this.otherParams) == null ? void 0 : _a.strategy_context) && typeof this.otherParams.strategy_context === "object" ? this.otherParams.strategy_context : {};
|
|
571
|
+
const strategyContext = { ...inherited };
|
|
572
|
+
const resolvedChannel = this.getPriceQueryChannel(channel);
|
|
573
|
+
const businessCode = strategyContext.business_code ?? ((_b = this.otherParams) == null ? void 0 : _b.businessCode) ?? ((_c = this.otherParams) == null ? void 0 : _c.business_code);
|
|
574
|
+
if (resolvedChannel)
|
|
575
|
+
strategyContext.channel = resolvedChannel;
|
|
576
|
+
if (businessCode !== void 0 && businessCode !== null && String(businessCode).trim() !== "") {
|
|
577
|
+
strategyContext.business_code = String(businessCode).trim();
|
|
578
|
+
}
|
|
579
|
+
return strategyContext;
|
|
580
|
+
}
|
|
622
581
|
getPriceQuerySchedule(params) {
|
|
623
582
|
const booking = params.booking || {};
|
|
624
583
|
if (typeof booking.start_date === "string" && booking.start_date.trim()) {
|
|
@@ -646,13 +605,15 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
646
605
|
};
|
|
647
606
|
}
|
|
648
607
|
async loadProductsForPriceQuery(params) {
|
|
649
|
-
var _a
|
|
608
|
+
var _a;
|
|
650
609
|
const ids = Array.from(new Set(
|
|
651
610
|
params.ids.filter((id) => Number.isFinite(id))
|
|
652
611
|
));
|
|
653
612
|
const productsById = /* @__PURE__ */ new Map();
|
|
654
613
|
if (!ids.length || !this.request)
|
|
655
614
|
return productsById;
|
|
615
|
+
const channel = this.getPriceQueryChannel(params.channel);
|
|
616
|
+
const strategyContext = this.getPriceQueryStrategyContext(channel);
|
|
656
617
|
try {
|
|
657
618
|
const response = await this.request.post("/product/query", {
|
|
658
619
|
ids,
|
|
@@ -664,13 +625,14 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
664
625
|
customer_id: params.customerId,
|
|
665
626
|
schedule_date: params.schedule.schedule_date,
|
|
666
627
|
schedule_datetime: params.schedule.schedule_datetime,
|
|
667
|
-
application_code:
|
|
628
|
+
application_code: channel,
|
|
629
|
+
...Object.keys(strategyContext).length ? { strategy_context: strategyContext } : {}
|
|
668
630
|
}, {
|
|
669
631
|
osServer: true,
|
|
670
632
|
customToast: () => {
|
|
671
633
|
}
|
|
672
634
|
});
|
|
673
|
-
const list = ((
|
|
635
|
+
const list = ((_a = response == null ? void 0 : response.data) == null ? void 0 : _a.list) || (response == null ? void 0 : response.list) || [];
|
|
674
636
|
if (!Array.isArray(list))
|
|
675
637
|
return productsById;
|
|
676
638
|
list.forEach((item) => {
|
|
@@ -867,27 +829,6 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
867
829
|
const coreData = (_f = (_d = (_c = app == null ? void 0 : app.models) == null ? void 0 : _c.getStore) == null ? void 0 : (_e = _d.call(_c)).getDataByModel) == null ? void 0 : _f.call(_e, "core", "core");
|
|
868
830
|
return coreData == null ? void 0 : coreData[key];
|
|
869
831
|
}
|
|
870
|
-
/**
|
|
871
|
-
* 复用业务解决方案初始化时已解析的支付设备短号。
|
|
872
|
-
* 空值会清除缓存,使后续支付恢复实时读取设备信息的兼容路径。
|
|
873
|
-
*/
|
|
874
|
-
setPaymentNumberDevicePrefix(prefix) {
|
|
875
|
-
const normalized = String(prefix ?? "").trim();
|
|
876
|
-
this.paymentNumberDevicePrefix = normalized || null;
|
|
877
|
-
}
|
|
878
|
-
getPaymentNumberDevicePrefixSync() {
|
|
879
|
-
if (!this.appPlugin)
|
|
880
|
-
return "LOCAL";
|
|
881
|
-
return (0, import_payment_number.resolvePaymentNumberDevicePrefixFromDeviceId)((key) => this.getAppData(key));
|
|
882
|
-
}
|
|
883
|
-
getPaymentNumberDevicePrefixAsync() {
|
|
884
|
-
if (!this.appPlugin)
|
|
885
|
-
return Promise.resolve("LOCAL");
|
|
886
|
-
if (this.paymentNumberDevicePrefix) {
|
|
887
|
-
return Promise.resolve(this.paymentNumberDevicePrefix);
|
|
888
|
-
}
|
|
889
|
-
return (0, import_payment_number.resolvePaymentNumberDevicePrefix)((key) => this.getAppData(key));
|
|
890
|
-
}
|
|
891
832
|
syncAppDataToTempOrder(tempOrder) {
|
|
892
833
|
const isPriceIncludeTax = this.getAppData("is_price_include_tax");
|
|
893
834
|
const taxCountryCode = this.getAppData("tax_country_code");
|
|
@@ -928,7 +869,6 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
928
869
|
var _a, _b;
|
|
929
870
|
this.core = core;
|
|
930
871
|
this.initializeOptions = options || {};
|
|
931
|
-
this.paymentNumberDevicePrefix = null;
|
|
932
872
|
this.otherParams = options.otherParams || {};
|
|
933
873
|
this.cacheId = (_a = this.otherParams) == null ? void 0 : _a.cacheId;
|
|
934
874
|
this.reusedSharedSubModuleNames.clear();
|
|
@@ -990,7 +930,6 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
990
930
|
}
|
|
991
931
|
});
|
|
992
932
|
this.currentSalesDetail = null;
|
|
993
|
-
this.paymentNumberDevicePrefix = null;
|
|
994
933
|
this.queuedServerOrderChanges = [];
|
|
995
934
|
this.salesDetailLoadSequence += 1;
|
|
996
935
|
await this.core.effects.emit(`${this.name}:onDestroy`, {});
|
|
@@ -1024,16 +963,13 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1024
963
|
const message = loadedRecord && (loadedRecord.message || loadedRecord.msg) || `加载销售详情失败: ${lookup}`;
|
|
1025
964
|
throw new Error(message);
|
|
1026
965
|
}
|
|
1027
|
-
const remoteRecord =
|
|
1028
|
-
preloadedSalesDetail ?? loadedRecord.data
|
|
1029
|
-
);
|
|
966
|
+
const remoteRecord = preloadedSalesDetail ?? loadedRecord.data;
|
|
1030
967
|
const currentTempOrder = params.merge ? this.store.order.getTempOrder() : null;
|
|
1031
|
-
const
|
|
968
|
+
const record = params.merge ? mergeSalesDetailRecordWithTempOrder(
|
|
1032
969
|
currentTempOrder,
|
|
1033
970
|
remoteRecord,
|
|
1034
971
|
"preserve-local"
|
|
1035
972
|
) : remoteRecord;
|
|
1036
|
-
const record = filterPendingPaymentsFromLoadedSalesDetail(mergedRecord);
|
|
1037
973
|
return await this.hydrateLatestLoadedSalesDetail(record, loadSequence);
|
|
1038
974
|
} finally {
|
|
1039
975
|
this.salesDetailLoadInFlightCount = Math.max(
|
|
@@ -1107,10 +1043,10 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1107
1043
|
const result = ((_a = this.store.order) == null ? void 0 : _a.getTempOrder()) || null;
|
|
1108
1044
|
return result;
|
|
1109
1045
|
}
|
|
1110
|
-
async replaceTempOrder(tempOrder) {
|
|
1046
|
+
async replaceTempOrder(tempOrder, options) {
|
|
1111
1047
|
if (!this.store.order)
|
|
1112
1048
|
throw new Error("order 模块未初始化");
|
|
1113
|
-
const nextTempOrder = await this.store.order.replaceTempOrder(tempOrder);
|
|
1049
|
+
const nextTempOrder = await this.store.order.replaceTempOrder(tempOrder, options);
|
|
1114
1050
|
await this.effectsEmit("onTempOrderReplaced", { tempOrder: nextTempOrder });
|
|
1115
1051
|
return nextTempOrder;
|
|
1116
1052
|
}
|
|
@@ -1824,20 +1760,6 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1824
1760
|
};
|
|
1825
1761
|
return this.store.order.submitTempOrder(submitParams);
|
|
1826
1762
|
}
|
|
1827
|
-
async saveSalesOrderDraft(params) {
|
|
1828
|
-
var _a, _b, _c, _d;
|
|
1829
|
-
if (!this.store.order) {
|
|
1830
|
-
throw new Error("BaseSales 解决方案需要 order 模块支持");
|
|
1831
|
-
}
|
|
1832
|
-
return this.store.order.saveTempOrderAsDraft({
|
|
1833
|
-
cacheId: this.cacheId,
|
|
1834
|
-
platform: (params == null ? void 0 : params.platform) ?? ((_a = this.otherParams) == null ? void 0 : _a.platform),
|
|
1835
|
-
businessCode: (params == null ? void 0 : params.businessCode) || ((_b = this.otherParams) == null ? void 0 : _b.businessCode) || ((_c = this.otherParams) == null ? void 0 : _c.business_code),
|
|
1836
|
-
channel: (params == null ? void 0 : params.channel) ?? this.getSubmitOrderSalesChannel(),
|
|
1837
|
-
type: (params == null ? void 0 : params.type) ?? ((_d = this.otherParams) == null ? void 0 : _d.type),
|
|
1838
|
-
...(params == null ? void 0 : params.enhancePayload) !== void 0 ? { enhancePayload: params.enhancePayload } : {}
|
|
1839
|
-
});
|
|
1840
|
-
}
|
|
1841
1763
|
async submitTempOrderAsync(params) {
|
|
1842
1764
|
var _a, _b, _c, _d;
|
|
1843
1765
|
if (!this.store.order) {
|
|
@@ -2038,29 +1960,8 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
2038
1960
|
}
|
|
2039
1961
|
}
|
|
2040
1962
|
}
|
|
2041
|
-
/**
|
|
2042
|
-
* 同步兼容入口。无法等待 IoT 短号时,按调用当下的 device_id 或 LOCAL 生成。
|
|
2043
|
-
*/
|
|
1963
|
+
/** 追加单个支付项到当前订单。 */
|
|
2044
1964
|
addOrderPayment(payment) {
|
|
2045
|
-
const hasPaymentNumber = String(
|
|
2046
|
-
payment.payment_number || ""
|
|
2047
|
-
).trim() !== "";
|
|
2048
|
-
return this.addOrderPaymentWithDevicePrefix(
|
|
2049
|
-
payment,
|
|
2050
|
-
hasPaymentNumber ? "LOCAL" : this.getPaymentNumberDevicePrefixSync()
|
|
2051
|
-
);
|
|
2052
|
-
}
|
|
2053
|
-
/**
|
|
2054
|
-
* 创建新支付项时优先使用业务解决方案初始化阶段缓存的设备短号;
|
|
2055
|
-
* 未缓存的通用 BaseSales 保持实时读取设备信息的兼容语义。
|
|
2056
|
-
*/
|
|
2057
|
-
async addOrderPaymentAsync(payment) {
|
|
2058
|
-
const paymentRecord = payment;
|
|
2059
|
-
const hasPaymentNumber = String(paymentRecord.payment_number || "").trim() !== "";
|
|
2060
|
-
const devicePrefix = hasPaymentNumber ? "LOCAL" : await this.getPaymentNumberDevicePrefixAsync();
|
|
2061
|
-
return this.addOrderPaymentWithDevicePrefix(payment, devicePrefix);
|
|
2062
|
-
}
|
|
2063
|
-
addOrderPaymentWithDevicePrefix(payment, devicePrefix) {
|
|
2064
1965
|
var _a;
|
|
2065
1966
|
if (!this.store.order)
|
|
2066
1967
|
throw new Error("order 模块未初始化");
|
|
@@ -2077,26 +1978,21 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
2077
1978
|
if (shopWalletPassId !== void 0 && shopWalletPassId !== null) {
|
|
2078
1979
|
metadata.shop_wallet_pass_id = shopWalletPassId;
|
|
2079
1980
|
}
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
import_utils.createUuidV4
|
|
2084
|
-
);
|
|
1981
|
+
if (!metadata.unique_payment_number) {
|
|
1982
|
+
metadata.unique_payment_number = (0, import_utils.createUuidV4)();
|
|
1983
|
+
}
|
|
2085
1984
|
const paymentTimestamp = (0, import_dayjs.default)().format("YYYY-MM-DD HH:mm:ss");
|
|
2086
1985
|
const paymentTime = paymentRecord.payment_time ?? paymentTimestamp;
|
|
2087
1986
|
const createdAt = paymentRecord.created_at ?? paymentTimestamp;
|
|
2088
1987
|
const serviceCharge = paymentRecord.service_charge && typeof paymentRecord.service_charge === "object" ? paymentRecord.service_charge : null;
|
|
2089
1988
|
const calculatedServiceFee = serviceCharge ? new import_decimal.default(paymentRecord.origin_amount ?? paymentRecord.amount ?? 0).times(serviceCharge.percentage || 0).plus(serviceCharge.amount || 0).toDecimalPlaces(2).toFixed(2) : void 0;
|
|
2090
1989
|
const payments = this.store.order.addOrderPayment({
|
|
2091
|
-
...
|
|
1990
|
+
...paymentRecord,
|
|
2092
1991
|
...calculatedServiceFee !== void 0 ? { service_fee: calculatedServiceFee } : {},
|
|
2093
1992
|
metadata,
|
|
2094
1993
|
payment_time: paymentTime,
|
|
2095
1994
|
created_at: createdAt
|
|
2096
1995
|
});
|
|
2097
|
-
if (paymentRecord.status === "payment_pending") {
|
|
2098
|
-
return payments;
|
|
2099
|
-
}
|
|
2100
1996
|
const amountSnapshot = this.store.order.getOrderAmountSnapshot();
|
|
2101
1997
|
const syncState = this.store.order.getOrderSyncState();
|
|
2102
1998
|
if (amountSnapshot) {
|
|
@@ -2118,73 +2014,10 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
2118
2014
|
return payments;
|
|
2119
2015
|
}
|
|
2120
2016
|
/** 更新当前订单中的指定支付项。 */
|
|
2121
|
-
|
|
2122
|
-
var _a, _b, _c;
|
|
2017
|
+
updateOrderPayment(paymentIdentity, updates) {
|
|
2123
2018
|
if (!this.store.order)
|
|
2124
2019
|
throw new Error("order 模块未初始化");
|
|
2125
|
-
|
|
2126
|
-
const previousMatch = (0, import_payment_utils.resolveOrderPaymentIdentity)(
|
|
2127
|
-
this.store.order.getOrderPayments(),
|
|
2128
|
-
paymentIdentity,
|
|
2129
|
-
matchMode
|
|
2130
|
-
);
|
|
2131
|
-
const previousPayment = previousMatch == null ? void 0 : previousMatch.payment;
|
|
2132
|
-
if ((previousPayment == null ? void 0 : previousPayment.status) === "paid" && !options.applyUpdatesWhenPaid) {
|
|
2133
|
-
const currentPayments = this.store.order.getOrderPayments();
|
|
2134
|
-
let syncResult2;
|
|
2135
|
-
if (options.submitWhenPaid && options.forceSubmitIfPaid) {
|
|
2136
|
-
syncResult2 = await this.syncPaymentsToOrder({
|
|
2137
|
-
payments: currentPayments,
|
|
2138
|
-
paymentStatus: this.getPaymentStatusForSync(currentPayments),
|
|
2139
|
-
submitWhenPaid: true,
|
|
2140
|
-
smallTicketDataFlag: options.smallTicketDataFlag ?? 1
|
|
2141
|
-
});
|
|
2142
|
-
}
|
|
2143
|
-
return {
|
|
2144
|
-
updated: false,
|
|
2145
|
-
payment: previousPayment,
|
|
2146
|
-
payments: currentPayments,
|
|
2147
|
-
summary: ((_a = this.store.order.getOrderAmountSnapshot()) == null ? void 0 : _a.summary) || null,
|
|
2148
|
-
...syncResult2 !== void 0 ? { syncResult: syncResult2 } : {}
|
|
2149
|
-
};
|
|
2150
|
-
}
|
|
2151
|
-
const result = await this.store.order.updateOrderPayment(paymentIdentity, updates, {
|
|
2152
|
-
matchBy: matchMode
|
|
2153
|
-
});
|
|
2154
|
-
let draftResult;
|
|
2155
|
-
let draftError;
|
|
2156
|
-
if (options.persistDraft !== false) {
|
|
2157
|
-
try {
|
|
2158
|
-
draftResult = await this.saveSalesOrderDraft();
|
|
2159
|
-
} catch (error) {
|
|
2160
|
-
draftError = error;
|
|
2161
|
-
this.logError("updateOrderPayment: 保存支付草稿失败", {
|
|
2162
|
-
paymentIdentity,
|
|
2163
|
-
error: error instanceof Error ? error.message : String(error)
|
|
2164
|
-
});
|
|
2165
|
-
if (!options.submitWhenPaid)
|
|
2166
|
-
throw error;
|
|
2167
|
-
}
|
|
2168
|
-
}
|
|
2169
|
-
const becamePaid = (previousPayment == null ? void 0 : previousPayment.status) !== "paid" && ((_b = result.payment) == null ? void 0 : _b.status) === "paid";
|
|
2170
|
-
const shouldSubmit = Boolean(
|
|
2171
|
-
options.submitWhenPaid && ((_c = result.payment) == null ? void 0 : _c.status) === "paid" && (becamePaid || options.forceSubmitIfPaid)
|
|
2172
|
-
);
|
|
2173
|
-
let syncResult;
|
|
2174
|
-
if (shouldSubmit) {
|
|
2175
|
-
syncResult = await this.syncPaymentsToOrder({
|
|
2176
|
-
payments: result.payments,
|
|
2177
|
-
paymentStatus: this.getPaymentStatusForSync(result.payments),
|
|
2178
|
-
submitWhenPaid: true,
|
|
2179
|
-
smallTicketDataFlag: options.smallTicketDataFlag ?? 1
|
|
2180
|
-
});
|
|
2181
|
-
}
|
|
2182
|
-
return {
|
|
2183
|
-
...result,
|
|
2184
|
-
...draftResult !== void 0 ? { draftResult } : {},
|
|
2185
|
-
...draftError !== void 0 ? { draftError } : {},
|
|
2186
|
-
...syncResult !== void 0 ? { syncResult } : {}
|
|
2187
|
-
};
|
|
2020
|
+
return this.store.order.updateOrderPayment(paymentIdentity, updates);
|
|
2188
2021
|
}
|
|
2189
2022
|
/** 删除当前订单中的指定支付项。 */
|
|
2190
2023
|
deleteOrderPayment(paymentIdentity) {
|
|
@@ -2198,11 +2031,6 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
2198
2031
|
throw new Error("order 模块未初始化");
|
|
2199
2032
|
return this.store.order.updateVoucherOrderPayments(payments, options);
|
|
2200
2033
|
}
|
|
2201
|
-
async updateVoucherOrderPaymentsAsync(payments, options) {
|
|
2202
|
-
if (!this.store.order)
|
|
2203
|
-
throw new Error("order 模块未初始化");
|
|
2204
|
-
return this.store.order.updateVoucherOrderPaymentsAsync(payments, options);
|
|
2205
|
-
}
|
|
2206
2034
|
confirmPendingVoucherPayments() {
|
|
2207
2035
|
if (!this.store.order)
|
|
2208
2036
|
throw new Error("order 模块未初始化");
|
|
@@ -2349,28 +2177,33 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
2349
2177
|
getPaymentMethods() {
|
|
2350
2178
|
return [...this.paymentMethodsCache];
|
|
2351
2179
|
}
|
|
2352
|
-
/**
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2180
|
+
/**
|
|
2181
|
+
* 按当前店铺的现金舍入配置计算金额,供现金支付 UI 使用。
|
|
2182
|
+
*
|
|
2183
|
+
* 舍入开关取自 CASHMANUAL 支付方式;舍入规则取自
|
|
2184
|
+
* otherParams.order_rounding_setting,金额算法统一由 PaymentModule 维护。
|
|
2185
|
+
*/
|
|
2186
|
+
async roundAmount(params) {
|
|
2187
|
+
var _a, _b, _c;
|
|
2188
|
+
const amount = params.amount;
|
|
2189
|
+
const cashManualPayment = this.paymentMethodsCache.find(
|
|
2190
|
+
(paymentMethod) => paymentMethod.code === "CASHMANUAL"
|
|
2191
|
+
);
|
|
2192
|
+
if (!((_a = cashManualPayment == null ? void 0 : cashManualPayment.metadata) == null ? void 0 : _a.order_rounding_switch)) {
|
|
2193
|
+
return {
|
|
2194
|
+
originalAmount: amount.toString(),
|
|
2195
|
+
roundedAmount: amount.toString(),
|
|
2196
|
+
roundingDifference: "0.00"
|
|
2197
|
+
};
|
|
2367
2198
|
}
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2199
|
+
if (!this.payment) {
|
|
2200
|
+
throw new Error("payment 模块未初始化");
|
|
2201
|
+
}
|
|
2202
|
+
return this.payment.roundAmountAsync(
|
|
2203
|
+
amount,
|
|
2204
|
+
(_b = this.otherParams.order_rounding_setting) == null ? void 0 : _b.interval,
|
|
2205
|
+
(_c = this.otherParams.order_rounding_setting) == null ? void 0 : _c.type
|
|
2206
|
+
);
|
|
2374
2207
|
}
|
|
2375
2208
|
/**
|
|
2376
2209
|
* 发送支付链接。
|
|
@@ -2540,11 +2373,11 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
2540
2373
|
});
|
|
2541
2374
|
});
|
|
2542
2375
|
}
|
|
2543
|
-
async addProductToOrder(product, booking) {
|
|
2376
|
+
async addProductToOrder(product, booking, options) {
|
|
2544
2377
|
try {
|
|
2545
2378
|
if (!this.store.order)
|
|
2546
2379
|
throw new Error("order 模块未初始化");
|
|
2547
|
-
const products = await this.store.order.addProductToOrder(product, booking);
|
|
2380
|
+
const products = await this.store.order.addProductToOrder(product, booking, options);
|
|
2548
2381
|
return products;
|
|
2549
2382
|
} catch (error) {
|
|
2550
2383
|
throw error;
|
|
@@ -2620,17 +2453,17 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
2620
2453
|
* @example
|
|
2621
2454
|
* await baseSales.removeProductsFromOrder([identityA, identityB]);
|
|
2622
2455
|
*/
|
|
2623
|
-
async removeProductsFromOrder(identities) {
|
|
2456
|
+
async removeProductsFromOrder(identities, options) {
|
|
2624
2457
|
try {
|
|
2625
2458
|
if (!this.store.order)
|
|
2626
2459
|
throw new Error("order 模块未初始化");
|
|
2627
|
-
return await this.store.order.removeProductsFromOrder(identities);
|
|
2460
|
+
return await this.store.order.removeProductsFromOrder(identities, options);
|
|
2628
2461
|
} catch (error) {
|
|
2629
2462
|
throw error;
|
|
2630
2463
|
}
|
|
2631
2464
|
}
|
|
2632
|
-
async removeProductFromOrder(identity) {
|
|
2633
|
-
return this.removeProductsFromOrder([identity]);
|
|
2465
|
+
async removeProductFromOrder(identity, options) {
|
|
2466
|
+
return this.removeProductsFromOrder([identity], options);
|
|
2634
2467
|
}
|
|
2635
2468
|
// ─── 促销/赠品 透传(迁移自 booking usePromotion) ────────────────
|
|
2636
2469
|
/**
|
|
@@ -78,7 +78,6 @@ export interface CartPromotionEvaluator {
|
|
|
78
78
|
}>;
|
|
79
79
|
hasApplicableStrategy: boolean;
|
|
80
80
|
}>;
|
|
81
|
-
getStrategyConfigs?: () => unknown[];
|
|
82
81
|
}
|
|
83
82
|
/** 单个赠品减量项 */
|
|
84
83
|
export interface GiftReduceItem {
|
|
@@ -268,8 +267,7 @@ export declare function appendPromotionTags<T extends Record<string, any>>(produ
|
|
|
268
267
|
* 处理购物车的促销计算与赠品差异化。
|
|
269
268
|
*
|
|
270
269
|
* 流程:
|
|
271
|
-
* 1. 分离 main / gift / edit-product
|
|
272
|
-
* 配置 ITEM_REWARD 时,编辑态商品也参与商品奖励重算)
|
|
270
|
+
* 1. 分离 main / gift / edit-product 三类(带 `booking_id` 的编辑态商品不参与促销)
|
|
273
271
|
* 2. 转 PromotionProduct 喂评估器 → 拿到 `evaluateCartWithPricing` 与 `getProductsApplicableStrategies`
|
|
274
272
|
* 3. 把 PricedProduct 映射回 OrderProduct 形态:
|
|
275
273
|
* - 参与促销的,写 `metadata._promotion` + 调整 `selling_price` / `main_product_selling_price`
|