@pisell/pisellos 0.10.7 → 0.10.9
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.js +0 -1
- package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +18 -2
- package/dist/model/strategy/adapter/dataVariant/evaluator.js +287 -101
- package/dist/model/strategy/adapter/dataVariant/type.d.ts +25 -0
- package/dist/model/strategy/adapter/walletPass/evaluator.js +0 -2
- package/dist/model/strategy/adapter/walletPass/type.d.ts +5 -0
- package/dist/model/strategy/adapter/walletPass/utils.js +57 -26
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +18 -12
- package/dist/modules/BookingContext/utils/productExtend.js +5 -9
- package/dist/modules/BookingContext/utils/timeSlices.js +24 -3
- package/dist/modules/Customer/index.d.ts +4 -0
- package/dist/modules/Customer/index.js +91 -59
- package/dist/modules/Customer/types.d.ts +2 -0
- package/dist/modules/Discount/index.d.ts +2 -0
- package/dist/modules/Discount/index.js +38 -5
- package/dist/modules/Discount/types.d.ts +11 -0
- package/dist/modules/Order/index.d.ts +32 -6
- package/dist/modules/Order/index.js +1165 -819
- package/dist/modules/Order/types.d.ts +32 -4
- package/dist/modules/Order/types.js +11 -0
- package/dist/modules/Order/utils/discountProductLineIdentity.d.ts +45 -0
- package/dist/modules/Order/utils/discountProductLineIdentity.js +227 -0
- package/dist/modules/Order/utils/virtualSettlement.d.ts +56 -0
- package/dist/modules/Order/utils/virtualSettlement.js +271 -0
- package/dist/modules/Order/utils.js +89 -48
- package/dist/modules/Payment/types.d.ts +2 -0
- package/dist/modules/Payment/utils.js +4 -1
- package/dist/modules/Payment/walletpass.d.ts +11 -0
- package/dist/modules/Payment/walletpass.js +235 -60
- package/dist/modules/Product/types.d.ts +23 -0
- package/dist/modules/ProductList/index.d.ts +15 -2
- package/dist/modules/ProductList/index.js +92 -13
- package/dist/modules/Rules/index.js +125 -52
- package/dist/modules/SalesSummary/index.d.ts +1 -0
- package/dist/modules/SalesSummary/index.js +4 -3
- package/dist/modules/SalesSummary/types.d.ts +1 -0
- package/dist/modules/SalesSummary/utils.d.ts +1 -0
- package/dist/modules/SalesSummary/utils.js +28 -2
- package/dist/server/index.d.ts +15 -0
- package/dist/server/index.js +894 -781
- package/dist/server/modules/order/index.d.ts +2 -0
- package/dist/server/modules/order/index.js +261 -96
- package/dist/server/modules/order/types.d.ts +1 -1
- package/dist/server/utils/small-ticket.js +2 -1
- package/dist/solution/BaseSales/index.d.ts +41 -7
- package/dist/solution/BaseSales/index.js +1405 -974
- package/dist/solution/BaseSales/utils/cartPromotion.js +26 -3
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +1 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +79 -13
- package/dist/solution/BaseSales/utils.js +31 -20
- package/dist/solution/BookingByStep/index.d.ts +3 -3
- package/dist/solution/BookingTicket/index.d.ts +5 -1
- package/dist/solution/BookingTicket/index.js +221 -162
- package/dist/solution/BookingTicket/types.d.ts +3 -0
- package/dist/solution/BookingTicket/utils/addProductDecision.js +2 -1
- package/dist/solution/BookingTicket/utils/cartView.js +44 -32
- package/dist/solution/Sales/index.d.ts +1 -0
- package/dist/solution/Sales/index.js +16 -2
- package/dist/solution/ScanOrder/index.js +25 -64
- package/dist/solution/ScanOrder/utils.js +31 -20
- package/dist/solution/UnifiedBookingSales/index.d.ts +5 -4
- package/dist/solution/UnifiedBookingSales/index.js +51 -39
- package/lib/core/index.js +0 -1
- package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +18 -2
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +170 -7
- package/lib/model/strategy/adapter/dataVariant/type.d.ts +25 -0
- package/lib/model/strategy/adapter/walletPass/evaluator.js +0 -2
- package/lib/model/strategy/adapter/walletPass/type.d.ts +5 -0
- package/lib/model/strategy/adapter/walletPass/utils.js +62 -11
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +6 -1
- package/lib/modules/BookingContext/utils/productExtend.js +4 -3
- package/lib/modules/BookingContext/utils/timeSlices.js +18 -3
- package/lib/modules/Customer/index.d.ts +4 -0
- package/lib/modules/Customer/index.js +11 -0
- package/lib/modules/Customer/types.d.ts +2 -0
- package/lib/modules/Discount/index.d.ts +2 -0
- package/lib/modules/Discount/index.js +37 -3
- package/lib/modules/Discount/types.d.ts +11 -0
- package/lib/modules/Order/index.d.ts +32 -6
- package/lib/modules/Order/index.js +518 -148
- package/lib/modules/Order/types.d.ts +32 -4
- package/lib/modules/Order/utils/discountProductLineIdentity.d.ts +45 -0
- package/lib/modules/Order/utils/discountProductLineIdentity.js +170 -0
- package/lib/modules/Order/utils/virtualSettlement.d.ts +56 -0
- package/lib/modules/Order/utils/virtualSettlement.js +300 -0
- package/lib/modules/Order/utils.js +65 -21
- package/lib/modules/Payment/types.d.ts +2 -0
- package/lib/modules/Payment/utils.js +5 -1
- package/lib/modules/Payment/walletpass.d.ts +11 -0
- package/lib/modules/Payment/walletpass.js +198 -17
- package/lib/modules/Product/types.d.ts +23 -0
- package/lib/modules/ProductList/index.d.ts +15 -2
- package/lib/modules/ProductList/index.js +85 -3
- package/lib/modules/Rules/index.js +100 -20
- package/lib/modules/SalesSummary/index.d.ts +1 -0
- package/lib/modules/SalesSummary/index.js +10 -2
- package/lib/modules/SalesSummary/types.d.ts +1 -0
- package/lib/modules/SalesSummary/utils.d.ts +1 -0
- package/lib/modules/SalesSummary/utils.js +30 -2
- package/lib/server/index.d.ts +15 -0
- package/lib/server/index.js +105 -14
- package/lib/server/modules/order/index.d.ts +2 -0
- package/lib/server/modules/order/index.js +75 -5
- package/lib/server/modules/order/types.d.ts +1 -1
- package/lib/server/utils/small-ticket.js +1 -1
- package/lib/solution/BaseSales/index.d.ts +41 -7
- package/lib/solution/BaseSales/index.js +325 -39
- package/lib/solution/BaseSales/utils/cartPromotion.js +26 -2
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +1 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +62 -12
- package/lib/solution/BaseSales/utils.js +29 -18
- package/lib/solution/BookingByStep/index.d.ts +3 -3
- package/lib/solution/BookingTicket/index.d.ts +5 -1
- package/lib/solution/BookingTicket/index.js +31 -6
- package/lib/solution/BookingTicket/types.d.ts +3 -0
- package/lib/solution/BookingTicket/utils/addProductDecision.js +2 -1
- package/lib/solution/BookingTicket/utils/cartView.js +43 -30
- package/lib/solution/Sales/index.d.ts +1 -0
- package/lib/solution/Sales/index.js +15 -3
- package/lib/solution/ScanOrder/index.js +17 -54
- package/lib/solution/ScanOrder/utils.js +29 -18
- package/lib/solution/UnifiedBookingSales/index.d.ts +5 -4
- package/lib/solution/UnifiedBookingSales/index.js +35 -26
- package/package.json +1 -1
|
@@ -40,6 +40,7 @@ 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_virtualSettlement = require("../../modules/Order/utils/virtualSettlement");
|
|
43
44
|
var import_payment_utils = require("../../modules/Order/payment-utils");
|
|
44
45
|
var import_payment_number = require("../../utils/payment-number");
|
|
45
46
|
var import_orderCollectionIdentity = require("../../modules/Order/utils/orderCollectionIdentity");
|
|
@@ -73,8 +74,11 @@ function isRejectedSalesSubmitResult(result) {
|
|
|
73
74
|
return candidates.some((candidate) => {
|
|
74
75
|
if (!candidate || typeof candidate !== "object")
|
|
75
76
|
return false;
|
|
76
|
-
|
|
77
|
-
|
|
77
|
+
if (candidate.code !== void 0 && candidate.code !== 200 && candidate.code !== "200") {
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
const statusCode = Number(candidate.statusCode);
|
|
81
|
+
if (Number.isFinite(statusCode) && statusCode >= 400)
|
|
78
82
|
return true;
|
|
79
83
|
if (candidate.status === false || candidate.success === false || candidate.result === false) {
|
|
80
84
|
return true;
|
|
@@ -84,9 +88,9 @@ function isRejectedSalesSubmitResult(result) {
|
|
|
84
88
|
);
|
|
85
89
|
});
|
|
86
90
|
}
|
|
87
|
-
function getSalesSubmitErrorMessage(result) {
|
|
91
|
+
function getSalesSubmitErrorMessage(result, fallbackMessage) {
|
|
88
92
|
var _a, _b;
|
|
89
|
-
return (result == null ? void 0 : result.message) || (result == null ? void 0 : result.msg) || ((_a = result == null ? void 0 : result.data) == null ? void 0 : _a.message) || ((_b = result == null ? void 0 : result.data) == null ? void 0 : _b.msg) ||
|
|
93
|
+
return (result == null ? void 0 : result.message) || (result == null ? void 0 : result.msg) || ((_a = result == null ? void 0 : result.data) == null ? void 0 : _a.message) || ((_b = result == null ? void 0 : result.data) == null ? void 0 : _b.msg) || fallbackMessage;
|
|
90
94
|
}
|
|
91
95
|
function toWalletFundValue(value) {
|
|
92
96
|
try {
|
|
@@ -703,6 +707,52 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
703
707
|
return null;
|
|
704
708
|
return productId;
|
|
705
709
|
}
|
|
710
|
+
/**
|
|
711
|
+
* Change Time / customer reprice 必须沿用商品列表的渠道口径。
|
|
712
|
+
* SalesSdk Provider 通常将渠道存为 platform,因此不能只读取 otherParams.channel。
|
|
713
|
+
*/
|
|
714
|
+
getPriceQueryChannel(channel) {
|
|
715
|
+
var _a, _b, _c;
|
|
716
|
+
const strategyContext = ((_a = this.otherParams) == null ? void 0 : _a.strategy_context) && typeof this.otherParams.strategy_context === "object" ? this.otherParams.strategy_context : {};
|
|
717
|
+
const value = channel ?? strategyContext.channel ?? ((_b = this.otherParams) == null ? void 0 : _b.channel) ?? ((_c = this.otherParams) == null ? void 0 : _c.platform);
|
|
718
|
+
if (value === void 0 || value === null || String(value).trim() === "") {
|
|
719
|
+
return void 0;
|
|
720
|
+
}
|
|
721
|
+
return String(value).trim();
|
|
722
|
+
}
|
|
723
|
+
/**
|
|
724
|
+
* /product/query 的智能定价评估只读取 strategy_context;
|
|
725
|
+
* application_code 仅作为接口兼容字段,不能替代 channel / business_code。
|
|
726
|
+
*/
|
|
727
|
+
getPriceQueryStrategyContext(channel) {
|
|
728
|
+
var _a, _b, _c;
|
|
729
|
+
const inherited = ((_a = this.otherParams) == null ? void 0 : _a.strategy_context) && typeof this.otherParams.strategy_context === "object" ? this.otherParams.strategy_context : {};
|
|
730
|
+
const strategyContext = { ...inherited };
|
|
731
|
+
const resolvedChannel = this.getPriceQueryChannel(channel);
|
|
732
|
+
const businessCode = strategyContext.business_code ?? ((_b = this.otherParams) == null ? void 0 : _b.businessCode) ?? ((_c = this.otherParams) == null ? void 0 : _c.business_code);
|
|
733
|
+
if (resolvedChannel)
|
|
734
|
+
strategyContext.channel = resolvedChannel;
|
|
735
|
+
if (businessCode !== void 0 && businessCode !== null && String(businessCode).trim() !== "") {
|
|
736
|
+
strategyContext.business_code = String(businessCode).trim();
|
|
737
|
+
}
|
|
738
|
+
const availableWalletIds = this.getAvailableWalletIds();
|
|
739
|
+
if (availableWalletIds.length > 0 && !Array.isArray(strategyContext.available_wallet_ids)) {
|
|
740
|
+
strategyContext.available_wallet_ids = availableWalletIds;
|
|
741
|
+
}
|
|
742
|
+
return strategyContext;
|
|
743
|
+
}
|
|
744
|
+
/**
|
|
745
|
+
* 子类可在商品重报价前准备客户维度的策略上下文,例如等待 Wallet/优惠资产加载。
|
|
746
|
+
*/
|
|
747
|
+
async prepareProductPriceQueryContext(_customerId) {
|
|
748
|
+
}
|
|
749
|
+
/**
|
|
750
|
+
* 默认保留 BaseSales 的 legacy quotation 行为;已由 /product/query 统一完成
|
|
751
|
+
* 智能定价与报价合并的业务可在子类中覆盖,避免二次覆盖权威价格。
|
|
752
|
+
*/
|
|
753
|
+
preferAuthoritativeProductQueryPrice() {
|
|
754
|
+
return false;
|
|
755
|
+
}
|
|
706
756
|
getPriceQuerySchedule(params) {
|
|
707
757
|
const booking = params.booking || {};
|
|
708
758
|
if (typeof booking.start_date === "string" && booking.start_date.trim()) {
|
|
@@ -730,13 +780,15 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
730
780
|
};
|
|
731
781
|
}
|
|
732
782
|
async loadProductsForPriceQuery(params) {
|
|
733
|
-
var _a
|
|
783
|
+
var _a;
|
|
734
784
|
const ids = Array.from(new Set(
|
|
735
785
|
params.ids.filter((id) => Number.isFinite(id))
|
|
736
786
|
));
|
|
737
787
|
const productsById = /* @__PURE__ */ new Map();
|
|
738
788
|
if (!ids.length || !this.request)
|
|
739
789
|
return productsById;
|
|
790
|
+
const channel = this.getPriceQueryChannel(params.channel);
|
|
791
|
+
const strategyContext = this.getPriceQueryStrategyContext(channel);
|
|
740
792
|
try {
|
|
741
793
|
const response = await this.request.post("/product/query", {
|
|
742
794
|
ids,
|
|
@@ -748,13 +800,14 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
748
800
|
customer_id: params.customerId,
|
|
749
801
|
schedule_date: params.schedule.schedule_date,
|
|
750
802
|
schedule_datetime: params.schedule.schedule_datetime,
|
|
751
|
-
application_code:
|
|
803
|
+
application_code: channel,
|
|
804
|
+
...Object.keys(strategyContext).length ? { strategy_context: strategyContext } : {}
|
|
752
805
|
}, {
|
|
753
806
|
osServer: true,
|
|
754
807
|
customToast: () => {
|
|
755
808
|
}
|
|
756
809
|
});
|
|
757
|
-
const list = ((
|
|
810
|
+
const list = ((_a = response == null ? void 0 : response.data) == null ? void 0 : _a.list) || (response == null ? void 0 : response.list) || [];
|
|
758
811
|
if (!Array.isArray(list))
|
|
759
812
|
return productsById;
|
|
760
813
|
list.forEach((item) => {
|
|
@@ -980,11 +1033,26 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
980
1033
|
}
|
|
981
1034
|
return (0, import_payment_number.resolvePaymentNumberDevicePrefix)((key) => this.getAppData(key));
|
|
982
1035
|
}
|
|
1036
|
+
isMultiCurrencySettlementEnabled() {
|
|
1037
|
+
var _a;
|
|
1038
|
+
return ((_a = this.otherParams) == null ? void 0 : _a.enableMultiCurrencySettlement) === true;
|
|
1039
|
+
}
|
|
1040
|
+
isActiveVirtualSettlementOrder(tempOrder) {
|
|
1041
|
+
return this.isMultiCurrencySettlementEnabled() && (0, import_virtualSettlement.isVirtualSettlementOrder)(tempOrder);
|
|
1042
|
+
}
|
|
1043
|
+
isHistoricalVirtualSettlementOrder(tempOrder) {
|
|
1044
|
+
var _a, _b;
|
|
1045
|
+
return ((_b = (_a = tempOrder == null ? void 0 : tempOrder.metadata) == null ? void 0 : _a.currency_settlement_config) == null ? void 0 : _b.settlement_type) === "virtual_currency";
|
|
1046
|
+
}
|
|
983
1047
|
syncAppDataToTempOrder(tempOrder) {
|
|
1048
|
+
var _a, _b, _c;
|
|
984
1049
|
const isPriceIncludeTax = this.getAppData("is_price_include_tax");
|
|
985
1050
|
const taxCountryCode = this.getAppData("tax_country_code");
|
|
986
1051
|
const currencyCode = this.getAppData("shop_currency_code");
|
|
987
1052
|
const currencySymbol = this.getAppData("shop_symbol");
|
|
1053
|
+
const isHistoricalVirtualSettlement = this.isHistoricalVirtualSettlementOrder(tempOrder);
|
|
1054
|
+
const isVirtualSettlement = this.isActiveVirtualSettlementOrder(tempOrder) || isHistoricalVirtualSettlement;
|
|
1055
|
+
const shouldManageLegalCurrencySnapshot = this.isMultiCurrencySettlementEnabled() || isHistoricalVirtualSettlement;
|
|
988
1056
|
let isChanged = false;
|
|
989
1057
|
if (isPriceIncludeTax !== void 0) {
|
|
990
1058
|
const nextIsPriceIncludeTax = Number(isPriceIncludeTax);
|
|
@@ -1000,14 +1068,32 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1000
1068
|
isChanged = true;
|
|
1001
1069
|
}
|
|
1002
1070
|
}
|
|
1003
|
-
|
|
1071
|
+
tempOrder.metadata = tempOrder.metadata || {};
|
|
1072
|
+
if (shouldManageLegalCurrencySnapshot) {
|
|
1073
|
+
const legalCurrencySnapshot = {
|
|
1074
|
+
currency_code: String(
|
|
1075
|
+
currencyCode ?? ((_a = tempOrder.metadata.legal_currency_snapshot) == null ? void 0 : _a.currency_code) ?? tempOrder.currency_code ?? ""
|
|
1076
|
+
),
|
|
1077
|
+
currency_symbol: String(
|
|
1078
|
+
currencySymbol ?? ((_b = tempOrder.metadata.legal_currency_snapshot) == null ? void 0 : _b.currency_symbol) ?? tempOrder.currency_symbol ?? ""
|
|
1079
|
+
),
|
|
1080
|
+
currency_format: String(
|
|
1081
|
+
((_c = tempOrder.metadata.legal_currency_snapshot) == null ? void 0 : _c.currency_format) || (isVirtualSettlement ? "symbol_first" : tempOrder.currency_format) || "symbol_first"
|
|
1082
|
+
)
|
|
1083
|
+
};
|
|
1084
|
+
if (JSON.stringify(tempOrder.metadata.legal_currency_snapshot || {}) !== JSON.stringify(legalCurrencySnapshot)) {
|
|
1085
|
+
tempOrder.metadata.legal_currency_snapshot = legalCurrencySnapshot;
|
|
1086
|
+
isChanged = true;
|
|
1087
|
+
}
|
|
1088
|
+
}
|
|
1089
|
+
if (!isVirtualSettlement && currencyCode !== void 0) {
|
|
1004
1090
|
const nextCurrencyCode = String(currencyCode || "");
|
|
1005
1091
|
if (tempOrder.currency_code !== nextCurrencyCode) {
|
|
1006
1092
|
tempOrder.currency_code = nextCurrencyCode;
|
|
1007
1093
|
isChanged = true;
|
|
1008
1094
|
}
|
|
1009
1095
|
}
|
|
1010
|
-
if (currencySymbol !== void 0) {
|
|
1096
|
+
if (!isVirtualSettlement && currencySymbol !== void 0) {
|
|
1011
1097
|
const nextCurrencySymbol = String(currencySymbol || "");
|
|
1012
1098
|
if (tempOrder.currency_symbol !== nextCurrencySymbol) {
|
|
1013
1099
|
tempOrder.currency_symbol = nextCurrencySymbol;
|
|
@@ -1203,10 +1289,10 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1203
1289
|
const result = ((_a = this.store.order) == null ? void 0 : _a.getTempOrder()) || null;
|
|
1204
1290
|
return result;
|
|
1205
1291
|
}
|
|
1206
|
-
async replaceTempOrder(tempOrder) {
|
|
1292
|
+
async replaceTempOrder(tempOrder, options) {
|
|
1207
1293
|
if (!this.store.order)
|
|
1208
1294
|
throw new Error("order 模块未初始化");
|
|
1209
|
-
const nextTempOrder = await this.store.order.replaceTempOrder(tempOrder);
|
|
1295
|
+
const nextTempOrder = await this.store.order.replaceTempOrder(tempOrder, options);
|
|
1210
1296
|
await this.effectsEmit("onTempOrderReplaced", { tempOrder: nextTempOrder });
|
|
1211
1297
|
return nextTempOrder;
|
|
1212
1298
|
}
|
|
@@ -1359,6 +1445,24 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1359
1445
|
throw error;
|
|
1360
1446
|
}
|
|
1361
1447
|
}
|
|
1448
|
+
/** 切换法币 / WalletPass 单位时清空商品、折扣与支付状态,保留客户。 */
|
|
1449
|
+
async clearOrderForSettlementSwitch() {
|
|
1450
|
+
if (!this.store.order)
|
|
1451
|
+
throw new Error("order 模块未初始化");
|
|
1452
|
+
const tempOrder = await this.store.order.clearOrderForSettlementSwitch();
|
|
1453
|
+
if (this.currentSalesDetail) {
|
|
1454
|
+
this.currentSalesDetail = {
|
|
1455
|
+
...this.currentSalesDetail,
|
|
1456
|
+
products: [],
|
|
1457
|
+
bookings: [],
|
|
1458
|
+
rootBooking: null,
|
|
1459
|
+
bookingsByProductUid: {},
|
|
1460
|
+
discount_list: [],
|
|
1461
|
+
payments: []
|
|
1462
|
+
};
|
|
1463
|
+
}
|
|
1464
|
+
return tempOrder;
|
|
1465
|
+
}
|
|
1362
1466
|
getOrderProducts() {
|
|
1363
1467
|
if (!this.store.order)
|
|
1364
1468
|
throw new Error("order 模块未初始化");
|
|
@@ -1485,7 +1589,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1485
1589
|
});
|
|
1486
1590
|
}
|
|
1487
1591
|
async loadDiscountConfig(params) {
|
|
1488
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
|
|
1592
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
|
|
1489
1593
|
if (!this.store.order)
|
|
1490
1594
|
throw new Error("order 模块未初始化");
|
|
1491
1595
|
const tempOrder = this.store.order.ensureTempOrder();
|
|
@@ -1507,7 +1611,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1507
1611
|
].join(":");
|
|
1508
1612
|
let preparedDiscountList = [];
|
|
1509
1613
|
if (customerId && customerId !== 1) {
|
|
1510
|
-
if (this.discountConfigCacheKey === discountConfigCacheKey) {
|
|
1614
|
+
if (!(params == null ? void 0 : params.force) && this.discountConfigCacheKey === discountConfigCacheKey) {
|
|
1511
1615
|
preparedDiscountList = originalDiscountList;
|
|
1512
1616
|
} else {
|
|
1513
1617
|
preparedDiscountList = await this.store.order.loadDiscountConfig({
|
|
@@ -1520,15 +1624,28 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1520
1624
|
await ((_j = discountModule == null ? void 0 : discountModule.setOriginalDiscountList) == null ? void 0 : _j.call(discountModule, preparedDiscountList));
|
|
1521
1625
|
}
|
|
1522
1626
|
}
|
|
1627
|
+
if (this.isActiveVirtualSettlementOrder(tempOrder)) {
|
|
1628
|
+
await ((_k = discountModule == null ? void 0 : discountModule.setOriginalDiscountList) == null ? void 0 : _k.call(discountModule, []));
|
|
1629
|
+
await ((_l = discountModule == null ? void 0 : discountModule.setDiscountList) == null ? void 0 : _l.call(discountModule, []));
|
|
1630
|
+
tempOrder.discount_list = [];
|
|
1631
|
+
tempOrder.shop_discount = "0.00";
|
|
1632
|
+
return {
|
|
1633
|
+
productList: tempOrder.products || [],
|
|
1634
|
+
discountList: [],
|
|
1635
|
+
availableWalletIds: this.getAvailableWalletIds(),
|
|
1636
|
+
virtualCurrencyList: this.store.order.getVirtualCurrencyList()
|
|
1637
|
+
};
|
|
1638
|
+
}
|
|
1523
1639
|
if (hasManualDiscountSelection && currentDiscountList.length) {
|
|
1524
1640
|
return {
|
|
1525
1641
|
productList: tempOrder.products || [],
|
|
1526
1642
|
discountList: currentDiscountList,
|
|
1527
|
-
availableWalletIds: this.getAvailableWalletIds()
|
|
1643
|
+
availableWalletIds: this.getAvailableWalletIds(),
|
|
1644
|
+
virtualCurrencyList: this.store.order.getVirtualCurrencyList()
|
|
1528
1645
|
};
|
|
1529
1646
|
}
|
|
1530
1647
|
let nextDiscountList = this.mergeHistoricalDiscountList(
|
|
1531
|
-
preparedDiscountList || ((
|
|
1648
|
+
preparedDiscountList || ((_m = discountModule == null ? void 0 : discountModule.getDiscountList) == null ? void 0 : _m.call(discountModule)) || [],
|
|
1532
1649
|
tempOrder.products || []
|
|
1533
1650
|
);
|
|
1534
1651
|
nextDiscountList = this.mergeCurrentDiscountSelectionState(
|
|
@@ -1554,11 +1671,12 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1554
1671
|
return {
|
|
1555
1672
|
productList: tempOrder.products || [],
|
|
1556
1673
|
discountList: nextDiscountList,
|
|
1557
|
-
availableWalletIds: this.getAvailableWalletIds()
|
|
1674
|
+
availableWalletIds: this.getAvailableWalletIds(),
|
|
1675
|
+
virtualCurrencyList: this.store.order.getVirtualCurrencyList()
|
|
1558
1676
|
};
|
|
1559
1677
|
}
|
|
1560
1678
|
if (rulesModule) {
|
|
1561
|
-
const orderTotalAmount = Number(((
|
|
1679
|
+
const orderTotalAmount = Number(((_n = orderStore.summary) == null ? void 0 : _n.total_amount) || 0);
|
|
1562
1680
|
console.log("[BaseSales.applyDiscountConfig.calcDiscount]");
|
|
1563
1681
|
const result = rulesModule.calcDiscount({
|
|
1564
1682
|
productList: tempOrder.products,
|
|
@@ -1574,8 +1692,8 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1574
1692
|
);
|
|
1575
1693
|
}
|
|
1576
1694
|
for (const product of tempOrder.products || []) {
|
|
1577
|
-
const productUid = (
|
|
1578
|
-
const runtimeOrigin = productUid ? (
|
|
1695
|
+
const productUid = (_o = product.metadata) == null ? void 0 : _o.unique_identification_number;
|
|
1696
|
+
const runtimeOrigin = productUid ? (_r = (_q = (_p = tempOrder._extend) == null ? void 0 : _p.productsByUid) == null ? void 0 : _q[productUid]) == null ? void 0 : _r.origin : void 0;
|
|
1579
1697
|
if ((runtimeOrigin == null ? void 0 : runtimeOrigin.isManualDiscount) || isBaseSalesManualProductDiscountProduct(product))
|
|
1580
1698
|
continue;
|
|
1581
1699
|
const totalPerUnitDiscount = (product.discount_list || []).reduce(
|
|
@@ -1583,7 +1701,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1583
1701
|
0
|
|
1584
1702
|
);
|
|
1585
1703
|
const optionSum = (0, import_utils.sumOptionUnitPrice)((0, import_utils.getProductSkuOptions)(product));
|
|
1586
|
-
const sourcePrice = ((
|
|
1704
|
+
const sourcePrice = ((_s = product.metadata) == null ? void 0 : _s.source_product_price) ?? (((_t = product.metadata) == null ? void 0 : _t.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");
|
|
1587
1705
|
const newSourceSellingPrice = new import_decimal.default(Number(sourcePrice) || 0).minus(totalPerUnitDiscount).toDecimalPlaces(2).toString();
|
|
1588
1706
|
const newMainSellingPrice = new import_decimal.default(Number(newSourceSellingPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
|
|
1589
1707
|
if (product.metadata) {
|
|
@@ -1616,7 +1734,8 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1616
1734
|
return {
|
|
1617
1735
|
productList: tempOrder.products || [],
|
|
1618
1736
|
discountList: nextDiscountList,
|
|
1619
|
-
availableWalletIds: this.getAvailableWalletIds()
|
|
1737
|
+
availableWalletIds: this.getAvailableWalletIds(),
|
|
1738
|
+
virtualCurrencyList: this.store.order.getVirtualCurrencyList()
|
|
1620
1739
|
};
|
|
1621
1740
|
}
|
|
1622
1741
|
getAvailableWalletIds() {
|
|
@@ -1625,11 +1744,25 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1625
1744
|
return [];
|
|
1626
1745
|
return this.store.order.getAvailableWalletIds();
|
|
1627
1746
|
}
|
|
1747
|
+
getVirtualCurrencyList() {
|
|
1748
|
+
var _a;
|
|
1749
|
+
if (!((_a = this.store.order) == null ? void 0 : _a.getVirtualCurrencyList))
|
|
1750
|
+
return [];
|
|
1751
|
+
return this.store.order.getVirtualCurrencyList();
|
|
1752
|
+
}
|
|
1628
1753
|
async bestDiscount(cb) {
|
|
1629
1754
|
var _a, _b, _c;
|
|
1630
1755
|
if (!this.store.order)
|
|
1631
1756
|
throw new Error("order 模块未初始化");
|
|
1632
1757
|
const tempOrder = this.store.order.ensureTempOrder();
|
|
1758
|
+
if (this.isActiveVirtualSettlementOrder(tempOrder)) {
|
|
1759
|
+
const result2 = {
|
|
1760
|
+
productList: tempOrder.products || [],
|
|
1761
|
+
discountList: []
|
|
1762
|
+
};
|
|
1763
|
+
cb == null ? void 0 : cb(result2);
|
|
1764
|
+
return result2;
|
|
1765
|
+
}
|
|
1633
1766
|
const orderStore = this.store.order.store || {};
|
|
1634
1767
|
const discountModule = orderStore.discount;
|
|
1635
1768
|
const rulesModule = orderStore.rules;
|
|
@@ -1743,10 +1876,19 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1743
1876
|
}
|
|
1744
1877
|
// TODO 需要优化,这段逻辑太长了,里面应该有些历史遗留问题
|
|
1745
1878
|
async setDiscountSelected(params) {
|
|
1746
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
1879
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
1747
1880
|
try {
|
|
1748
1881
|
if (!this.store.order)
|
|
1749
1882
|
throw new Error("order 模块未初始化");
|
|
1883
|
+
const currentOrder = this.store.order.ensureTempOrder();
|
|
1884
|
+
if (this.isActiveVirtualSettlementOrder(currentOrder)) {
|
|
1885
|
+
currentOrder.discount_list = [];
|
|
1886
|
+
currentOrder.shop_discount = "0.00";
|
|
1887
|
+
await ((_c = (_b = (_a = this.store.order.store) == null ? void 0 : _a.discount) == null ? void 0 : _b.setDiscountList) == null ? void 0 : _c.call(_b, []));
|
|
1888
|
+
await this.store.order.recalculateSummary({ createIfMissing: true });
|
|
1889
|
+
this.store.order.persistTempOrder();
|
|
1890
|
+
return;
|
|
1891
|
+
}
|
|
1750
1892
|
const list = this.store.order.getDiscountList();
|
|
1751
1893
|
const updated = list.map(
|
|
1752
1894
|
(d) => d.id === params.discountId && !isBaseSalesHistoricalDiscountEntry(d) ? {
|
|
@@ -1763,7 +1905,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1763
1905
|
let nextDiscountList = updated;
|
|
1764
1906
|
await (discountModule == null ? void 0 : discountModule.setDiscountList(updated));
|
|
1765
1907
|
if (rulesModule) {
|
|
1766
|
-
const orderTotalAmount = Number(((
|
|
1908
|
+
const orderTotalAmount = Number(((_d = orderStore.summary) == null ? void 0 : _d.total_amount) || 0);
|
|
1767
1909
|
console.log("[BaseSales.setDiscountSelected.calcDiscount]");
|
|
1768
1910
|
const result = rulesModule.calcDiscount(
|
|
1769
1911
|
{
|
|
@@ -1809,8 +1951,8 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1809
1951
|
return rid != null && selectedResourceIds.has(rid);
|
|
1810
1952
|
});
|
|
1811
1953
|
for (const product of tempOrder.products) {
|
|
1812
|
-
const productUid = (
|
|
1813
|
-
const runtimeOrigin = productUid ? (
|
|
1954
|
+
const productUid = (_e = product.metadata) == null ? void 0 : _e.unique_identification_number;
|
|
1955
|
+
const runtimeOrigin = productUid ? (_h = (_g = (_f = tempOrder._extend) == null ? void 0 : _f.productsByUid) == null ? void 0 : _g[productUid]) == null ? void 0 : _h.origin : void 0;
|
|
1814
1956
|
if ((runtimeOrigin == null ? void 0 : runtimeOrigin.isManualDiscount) || isBaseSalesManualProductDiscountProduct(product))
|
|
1815
1957
|
continue;
|
|
1816
1958
|
product.discount_list = filterSelectedDiscountDetails(product.discount_list);
|
|
@@ -1834,7 +1976,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1834
1976
|
0
|
|
1835
1977
|
);
|
|
1836
1978
|
const optionSum = (0, import_utils.sumOptionUnitPrice)((0, import_utils.getProductSkuOptions)(product));
|
|
1837
|
-
const sourcePrice = ((
|
|
1979
|
+
const sourcePrice = ((_i = product.metadata) == null ? void 0 : _i.source_product_price) ?? (((_j = product.metadata) == null ? void 0 : _j.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");
|
|
1838
1980
|
const newSourceSellingPrice = new import_decimal.default(Number(sourcePrice) || 0).minus(totalPerUnitDiscount).toDecimalPlaces(2).toString();
|
|
1839
1981
|
const newMainSellingPrice = new import_decimal.default(Number(newSourceSellingPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
|
|
1840
1982
|
if (product.metadata) {
|
|
@@ -1901,6 +2043,88 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1901
2043
|
async submitScanOrder(params) {
|
|
1902
2044
|
return this.submitSalesOrder(params);
|
|
1903
2045
|
}
|
|
2046
|
+
async buildVirtualSettlementSubmitData() {
|
|
2047
|
+
var _a, _b, _c;
|
|
2048
|
+
if (!this.store.order)
|
|
2049
|
+
return null;
|
|
2050
|
+
const tempOrder = this.store.order.getTempOrder();
|
|
2051
|
+
if (!this.isActiveVirtualSettlementOrder(tempOrder))
|
|
2052
|
+
return null;
|
|
2053
|
+
const snapshot = (0, import_virtualSettlement.getTempOrderSettlementSnapshot)(tempOrder);
|
|
2054
|
+
const currencyProductId = Number(
|
|
2055
|
+
((_c = (_b = (_a = tempOrder == null ? void 0 : tempOrder.metadata) == null ? void 0 : _a.currency_settlement_config) == null ? void 0 : _b.settlement_ids) == null ? void 0 : _c[0]) ?? (snapshot == null ? void 0 : snapshot.currency_product_id)
|
|
2056
|
+
);
|
|
2057
|
+
if (!snapshot || !Number.isFinite(currencyProductId) || currencyProductId <= 0) {
|
|
2058
|
+
throw new Error("Virtual currency settlement configuration is invalid.");
|
|
2059
|
+
}
|
|
2060
|
+
const summary = await this.store.order.recalculateSummary({ createIfMissing: true });
|
|
2061
|
+
const amount = new import_decimal.default(
|
|
2062
|
+
(summary == null ? void 0 : summary.total_amount) || 0
|
|
2063
|
+
).toDecimalPlaces(2);
|
|
2064
|
+
const customerId = Number((tempOrder == null ? void 0 : tempOrder.customer_id) || 0);
|
|
2065
|
+
if (amount.gt(0) && customerId > 0 && customerId !== 1) {
|
|
2066
|
+
await this.store.order.loadDiscountConfig({
|
|
2067
|
+
customerId,
|
|
2068
|
+
action: (tempOrder == null ? void 0 : tempOrder.order_id) ? "edit" : "create",
|
|
2069
|
+
orderId: Number(tempOrder == null ? void 0 : tempOrder.order_id) || void 0,
|
|
2070
|
+
apply: false
|
|
2071
|
+
});
|
|
2072
|
+
}
|
|
2073
|
+
const asset = this.store.order.getVirtualCurrencyList().find(
|
|
2074
|
+
(item) => Number(item == null ? void 0 : item.product_id) === currencyProductId
|
|
2075
|
+
);
|
|
2076
|
+
const currencyCode = String((tempOrder == null ? void 0 : tempOrder.currency_code) || "");
|
|
2077
|
+
const currencySymbol = String((tempOrder == null ? void 0 : tempOrder.currency_symbol) || "");
|
|
2078
|
+
const currencyFormat = String((tempOrder == null ? void 0 : tempOrder.currency_format) || "symbol_first");
|
|
2079
|
+
if (amount.lte(0)) {
|
|
2080
|
+
return {
|
|
2081
|
+
payments: [],
|
|
2082
|
+
snapshot,
|
|
2083
|
+
currencyProductId,
|
|
2084
|
+
currencyCode,
|
|
2085
|
+
currencySymbol,
|
|
2086
|
+
currencyFormat
|
|
2087
|
+
};
|
|
2088
|
+
}
|
|
2089
|
+
if (!asset) {
|
|
2090
|
+
throw new Error("No matching virtual currency card is available.");
|
|
2091
|
+
}
|
|
2092
|
+
const balance = new import_decimal.default(asset.balance || 0);
|
|
2093
|
+
if (balance.lt(amount)) {
|
|
2094
|
+
throw new Error("Insufficient virtual currency balance.");
|
|
2095
|
+
}
|
|
2096
|
+
const paymentMethods = await this.getPaymentMethodsAsync();
|
|
2097
|
+
const paymentMethod = paymentMethods.find(
|
|
2098
|
+
(method) => String(method.code || "").toUpperCase() === "PRODUCTVOUCHER"
|
|
2099
|
+
);
|
|
2100
|
+
if (!paymentMethod) {
|
|
2101
|
+
throw new Error("PRODUCTVOUCHER payment method is unavailable.");
|
|
2102
|
+
}
|
|
2103
|
+
const amountText = amount.toFixed(2);
|
|
2104
|
+
const payment = {
|
|
2105
|
+
payment_number: `LOCAL_${(0, import_utils.createUuidV4)()}`,
|
|
2106
|
+
amount: amountText,
|
|
2107
|
+
origin_amount: amountText,
|
|
2108
|
+
code: paymentMethod.code,
|
|
2109
|
+
custom_payment_id: paymentMethod.id,
|
|
2110
|
+
custom_payment_type: paymentMethod.custom_payment_type ?? paymentMethod.type,
|
|
2111
|
+
name: paymentMethod.name,
|
|
2112
|
+
type: "normal",
|
|
2113
|
+
voucher_id: asset.id,
|
|
2114
|
+
order_payment_type: "normal",
|
|
2115
|
+
wallet_pass_usage_unit: { price: 1, points: 1 },
|
|
2116
|
+
wallet_pass_use_value: amountText,
|
|
2117
|
+
metadata: {}
|
|
2118
|
+
};
|
|
2119
|
+
return {
|
|
2120
|
+
payments: [payment],
|
|
2121
|
+
snapshot,
|
|
2122
|
+
currencyProductId,
|
|
2123
|
+
currencyCode,
|
|
2124
|
+
currencySymbol,
|
|
2125
|
+
currencyFormat
|
|
2126
|
+
};
|
|
2127
|
+
}
|
|
1904
2128
|
/**
|
|
1905
2129
|
* 提交当前 Sales 订单。
|
|
1906
2130
|
*
|
|
@@ -1912,6 +2136,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1912
2136
|
if (!this.store.order) {
|
|
1913
2137
|
throw new Error("BaseSales 解决方案需要 order 模块支持");
|
|
1914
2138
|
}
|
|
2139
|
+
const virtualSettlement = await this.buildVirtualSettlementSubmitData();
|
|
1915
2140
|
const inferredPaymentStatus = this.getSubmitPaymentStatus(params == null ? void 0 : params.paymentStatus);
|
|
1916
2141
|
const smallTicketDataFlag = (params == null ? void 0 : params.smallTicketDataFlag) ?? this.getDefaultCheckoutSmallTicketDataFlag();
|
|
1917
2142
|
const submitParams = {
|
|
@@ -1921,11 +2146,30 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1921
2146
|
channel: this.getSubmitOrderSalesChannel(),
|
|
1922
2147
|
type: (_d = this.otherParams) == null ? void 0 : _d.type,
|
|
1923
2148
|
request_unique_idempotency_token: this.store.order.generateIdempotencyToken(),
|
|
1924
|
-
...(params == null ? void 0 : params.payments) !== void 0 ? { payments: params.payments } : {},
|
|
2149
|
+
...virtualSettlement ? { payments: virtualSettlement.payments } : (params == null ? void 0 : params.payments) !== void 0 ? { payments: params.payments } : {},
|
|
1925
2150
|
...inferredPaymentStatus !== void 0 ? { paymentStatus: inferredPaymentStatus } : {},
|
|
1926
2151
|
...smallTicketDataFlag !== void 0 ? { smallTicketDataFlag } : {},
|
|
1927
|
-
...
|
|
1928
|
-
|
|
2152
|
+
...virtualSettlement ? {
|
|
2153
|
+
confirmPendingVoucherPayments: false
|
|
2154
|
+
} : (params == null ? void 0 : params.confirmPendingVoucherPayments) !== void 0 ? { confirmPendingVoucherPayments: params.confirmPendingVoucherPayments } : {},
|
|
2155
|
+
...virtualSettlement ? {
|
|
2156
|
+
enhancePayload: (payload, ctx) => {
|
|
2157
|
+
const callerPayload = (params == null ? void 0 : params.enhancePayload) ? params.enhancePayload(payload, ctx) : payload;
|
|
2158
|
+
return {
|
|
2159
|
+
...callerPayload,
|
|
2160
|
+
metadata: {
|
|
2161
|
+
...callerPayload.metadata || {},
|
|
2162
|
+
currency_settlement_config: {
|
|
2163
|
+
settlement_type: "virtual_currency",
|
|
2164
|
+
settlement_ids: [virtualSettlement.currencyProductId]
|
|
2165
|
+
}
|
|
2166
|
+
},
|
|
2167
|
+
currency_code: virtualSettlement.currencyCode,
|
|
2168
|
+
currency_symbol: virtualSettlement.currencySymbol,
|
|
2169
|
+
currency_format: virtualSettlement.currencyFormat
|
|
2170
|
+
};
|
|
2171
|
+
}
|
|
2172
|
+
} : (params == null ? void 0 : params.enhancePayload) !== void 0 ? { enhancePayload: params.enhancePayload } : {}
|
|
1929
2173
|
};
|
|
1930
2174
|
return this.shouldUseCheckoutSyncTask() ? this.store.order.submitTempOrder(submitParams) : this.store.order.submitTempOrderAsync(submitParams);
|
|
1931
2175
|
}
|
|
@@ -2634,11 +2878,27 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
2634
2878
|
await this.syncSelectedWalletAssets(state);
|
|
2635
2879
|
return this.publishWalletAssetsState(state);
|
|
2636
2880
|
}
|
|
2881
|
+
/** 更新已选钱包资产的手动使用金额,并同步 pending payment。 */
|
|
2882
|
+
async updateWalletAssetAmount(params) {
|
|
2883
|
+
if (!this.store.payment)
|
|
2884
|
+
throw new Error("payment 模块未初始化");
|
|
2885
|
+
const state = this.store.payment.wallet.updateWalletAssetAmount(
|
|
2886
|
+
params.assetId,
|
|
2887
|
+
params.amount
|
|
2888
|
+
);
|
|
2889
|
+
await this.syncSelectedWalletAssets(state);
|
|
2890
|
+
return this.publishWalletAssetsState(state);
|
|
2891
|
+
}
|
|
2637
2892
|
/** 扫码精确查券;仅可用资产会被自动选中。 */
|
|
2638
2893
|
async scanWalletAsset(code) {
|
|
2639
2894
|
if (!this.store.payment)
|
|
2640
2895
|
throw new Error("payment 模块未初始化");
|
|
2641
|
-
const
|
|
2896
|
+
const wallet = this.store.payment.wallet;
|
|
2897
|
+
const businessData = this.buildWalletInitBusinessData();
|
|
2898
|
+
if (businessData) {
|
|
2899
|
+
wallet.generateWalletParams(businessData);
|
|
2900
|
+
}
|
|
2901
|
+
const result = await wallet.scanWalletAssetAsync(code);
|
|
2642
2902
|
if (result.type === "normalCode") {
|
|
2643
2903
|
await this.syncSelectedWalletAssets(result.state);
|
|
2644
2904
|
await this.publishWalletAssetsState(result.state);
|
|
@@ -2766,7 +3026,9 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
2766
3026
|
confirmPendingVoucherPayments: true
|
|
2767
3027
|
});
|
|
2768
3028
|
if (isRejectedSalesSubmitResult(submitResult)) {
|
|
2769
|
-
throw new Error(
|
|
3029
|
+
throw new Error(
|
|
3030
|
+
getSalesSubmitErrorMessage(submitResult, "Wallet 支付确认失败")
|
|
3031
|
+
);
|
|
2770
3032
|
}
|
|
2771
3033
|
} catch (error) {
|
|
2772
3034
|
this.store.order.setOrderPayments(beforePayments);
|
|
@@ -2869,6 +3131,11 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
2869
3131
|
smallTicketDataFlag: 1,
|
|
2870
3132
|
confirmPendingVoucherPayments: true
|
|
2871
3133
|
});
|
|
3134
|
+
if (isRejectedSalesSubmitResult(syncResult.submitResult)) {
|
|
3135
|
+
throw new Error(
|
|
3136
|
+
getSalesSubmitErrorMessage(syncResult.submitResult, "订单提交失败")
|
|
3137
|
+
);
|
|
3138
|
+
}
|
|
2872
3139
|
if (this.store.payment) {
|
|
2873
3140
|
const committed = this.getCommittedWalletAssets();
|
|
2874
3141
|
const walletState = this.store.payment.wallet.setCommittedWalletAssets(
|
|
@@ -2979,6 +3246,11 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
2979
3246
|
smallTicketDataFlag: 1,
|
|
2980
3247
|
confirmPendingVoucherPayments: true
|
|
2981
3248
|
});
|
|
3249
|
+
if (isRejectedSalesSubmitResult(syncResult.submitResult)) {
|
|
3250
|
+
throw new Error(
|
|
3251
|
+
getSalesSubmitErrorMessage(syncResult.submitResult, "订单提交失败")
|
|
3252
|
+
);
|
|
3253
|
+
}
|
|
2982
3254
|
if (this.store.payment) {
|
|
2983
3255
|
const committed = this.getCommittedWalletAssets();
|
|
2984
3256
|
const walletState = this.store.payment.wallet.setCommittedWalletAssets(
|
|
@@ -3065,6 +3337,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
3065
3337
|
async calculateProductBookingPrice(params) {
|
|
3066
3338
|
const quotation = this.store.quotation;
|
|
3067
3339
|
const customerId = params.customer_id ?? this.getCurrentOrderCustomerId();
|
|
3340
|
+
await this.prepareProductPriceQueryContext(customerId);
|
|
3068
3341
|
const authoritativeProduct = await this.loadProductForPriceQuery(params, customerId);
|
|
3069
3342
|
const product = this.mergeProductForPriceQuery(params.product, authoritativeProduct);
|
|
3070
3343
|
await this.loadQuotationForPriceQuery({
|
|
@@ -3077,7 +3350,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
3077
3350
|
product,
|
|
3078
3351
|
fallback_price: authoritativeProduct ? void 0 : params.fallback_price,
|
|
3079
3352
|
customer_id: customerId,
|
|
3080
|
-
quotation
|
|
3353
|
+
quotation: authoritativeProduct && this.preferAuthoritativeProductQueryPrice() ? void 0 : quotation
|
|
3081
3354
|
});
|
|
3082
3355
|
}
|
|
3083
3356
|
getQuotationCustomerScopeInfo() {
|
|
@@ -3114,11 +3387,23 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
3114
3387
|
quotationScopes
|
|
3115
3388
|
};
|
|
3116
3389
|
}
|
|
3390
|
+
hasSmartPricingStrategies() {
|
|
3391
|
+
var _a, _b;
|
|
3392
|
+
const evaluator = (_b = (_a = this.core) == null ? void 0 : _a.context) == null ? void 0 : _b.dataVariantEvaluator;
|
|
3393
|
+
if (!evaluator || typeof evaluator.getStrategyConfigs !== "function") {
|
|
3394
|
+
return false;
|
|
3395
|
+
}
|
|
3396
|
+
const configs = evaluator.getStrategyConfigs();
|
|
3397
|
+
return Array.isArray(configs) && configs.length > 0;
|
|
3398
|
+
}
|
|
3117
3399
|
shouldRecalculateProductBookingPricesForContextChange(params) {
|
|
3118
3400
|
const scopeInfo = this.getQuotationCustomerScopeInfo();
|
|
3119
3401
|
const scopedCustomerIds = new Set(scopeInfo.customerIds.map((id) => String(id)));
|
|
3120
3402
|
const previousCustomerId = this.normalizePriceContextCustomerId(params.previousCustomerId);
|
|
3121
3403
|
const nextCustomerId = this.normalizePriceContextCustomerId(params.nextCustomerId);
|
|
3404
|
+
if (this.hasSmartPricingStrategies()) {
|
|
3405
|
+
return previousCustomerId !== nextCustomerId;
|
|
3406
|
+
}
|
|
3122
3407
|
const previousInScope = previousCustomerId ? scopedCustomerIds.has(previousCustomerId) : false;
|
|
3123
3408
|
const nextInScope = nextCustomerId ? scopedCustomerIds.has(nextCustomerId) : false;
|
|
3124
3409
|
let shouldRecalculate = false;
|
|
@@ -3139,6 +3424,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
3139
3424
|
return [];
|
|
3140
3425
|
const quotation = this.store.quotation;
|
|
3141
3426
|
const customerId = ((_a = paramsList[0]) == null ? void 0 : _a.customer_id) ?? this.getCurrentOrderCustomerId();
|
|
3427
|
+
await this.prepareProductPriceQueryContext(customerId);
|
|
3142
3428
|
const productMapsByGroup = /* @__PURE__ */ new Map();
|
|
3143
3429
|
const groups = /* @__PURE__ */ new Map();
|
|
3144
3430
|
paramsList.forEach((params) => {
|
|
@@ -3196,15 +3482,15 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
3196
3482
|
product,
|
|
3197
3483
|
fallback_price: authoritativeProduct ? void 0 : params.fallback_price,
|
|
3198
3484
|
customer_id: customerId,
|
|
3199
|
-
quotation
|
|
3485
|
+
quotation: authoritativeProduct && this.preferAuthoritativeProductQueryPrice() ? void 0 : quotation
|
|
3200
3486
|
});
|
|
3201
3487
|
});
|
|
3202
3488
|
}
|
|
3203
|
-
async addProductToOrder(product, booking) {
|
|
3489
|
+
async addProductToOrder(product, booking, options) {
|
|
3204
3490
|
try {
|
|
3205
3491
|
if (!this.store.order)
|
|
3206
3492
|
throw new Error("order 模块未初始化");
|
|
3207
|
-
const products = await this.store.order.addProductToOrder(product, booking);
|
|
3493
|
+
const products = await this.store.order.addProductToOrder(product, booking, options);
|
|
3208
3494
|
return products;
|
|
3209
3495
|
} catch (error) {
|
|
3210
3496
|
throw error;
|
|
@@ -3280,17 +3566,17 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
3280
3566
|
* @example
|
|
3281
3567
|
* await baseSales.removeProductsFromOrder([identityA, identityB]);
|
|
3282
3568
|
*/
|
|
3283
|
-
async removeProductsFromOrder(identities) {
|
|
3569
|
+
async removeProductsFromOrder(identities, options) {
|
|
3284
3570
|
try {
|
|
3285
3571
|
if (!this.store.order)
|
|
3286
3572
|
throw new Error("order 模块未初始化");
|
|
3287
|
-
return await this.store.order.removeProductsFromOrder(identities);
|
|
3573
|
+
return await this.store.order.removeProductsFromOrder(identities, options);
|
|
3288
3574
|
} catch (error) {
|
|
3289
3575
|
throw error;
|
|
3290
3576
|
}
|
|
3291
3577
|
}
|
|
3292
|
-
async removeProductFromOrder(identity) {
|
|
3293
|
-
return this.removeProductsFromOrder([identity]);
|
|
3578
|
+
async removeProductFromOrder(identity, options) {
|
|
3579
|
+
return this.removeProductsFromOrder([identity], options);
|
|
3294
3580
|
}
|
|
3295
3581
|
// ─── 促销/赠品 透传(迁移自 booking usePromotion) ────────────────
|
|
3296
3582
|
/**
|