@pisell/pisellos 2.3.80 → 2.3.82
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/modules/ProductList/clientDataVariants.d.ts +50 -0
- package/dist/modules/ProductList/clientDataVariants.js +216 -0
- package/dist/modules/ProductList/index.d.ts +14 -13
- package/dist/modules/ProductList/index.js +104 -76
- package/dist/solution/BaseSales/index.d.ts +16 -1
- package/dist/solution/BaseSales/index.js +530 -260
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/UnifiedBookingSales/index.js +2 -2
- package/dist/utils/platform.d.ts +8 -0
- package/dist/utils/platform.js +15 -0
- package/lib/modules/ProductList/clientDataVariants.d.ts +50 -0
- package/lib/modules/ProductList/clientDataVariants.js +204 -0
- package/lib/modules/ProductList/index.d.ts +14 -13
- package/lib/modules/ProductList/index.js +76 -57
- package/lib/solution/BaseSales/index.d.ts +16 -1
- package/lib/solution/BaseSales/index.js +269 -65
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/UnifiedBookingSales/index.js +2 -2
- package/lib/utils/platform.d.ts +8 -0
- package/lib/utils/platform.js +22 -0
- package/package.json +1 -1
|
@@ -29,6 +29,8 @@ var _paymentUtils = require("../../modules/Order/payment-utils");
|
|
|
29
29
|
var _paymentNumber = require("../../utils/payment-number");
|
|
30
30
|
var _orderCollectionIdentity = require("../../modules/Order/utils/orderCollectionIdentity");
|
|
31
31
|
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
32
|
+
var _clientDataVariants = require("../../modules/ProductList/clientDataVariants");
|
|
33
|
+
var _platform = require("../../utils/platform");
|
|
32
34
|
var _Quotation = require("../../modules/Quotation");
|
|
33
35
|
var _transformBaseProductToOrderProduct = require("./utils/transformBaseProductToOrderProduct");
|
|
34
36
|
var _quotationPrice = require("./utils/quotationPrice");
|
|
@@ -720,34 +722,175 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
720
722
|
schedule_datetime: now.format('YYYY-MM-DD HH:mm:ss')
|
|
721
723
|
};
|
|
722
724
|
}
|
|
725
|
+
isCustomerUserPriceQuery() {
|
|
726
|
+
return (0, _platform.isCustomerUserPlatform)(this.otherParams?.platform);
|
|
727
|
+
}
|
|
728
|
+
getPriceQueryScheduleList() {
|
|
729
|
+
const storeScheduleList = this.store.schedule?.getScheduleList?.();
|
|
730
|
+
if (Array.isArray(storeScheduleList) && storeScheduleList.length > 0) {
|
|
731
|
+
return storeScheduleList;
|
|
732
|
+
}
|
|
733
|
+
const contextScheduleList = this.core?.context?.scheduleList;
|
|
734
|
+
return Array.isArray(contextScheduleList) && contextScheduleList.length > 0 ? contextScheduleList : undefined;
|
|
735
|
+
}
|
|
736
|
+
buildPriceQueryPayload(params) {
|
|
737
|
+
const channel = this.getPriceQueryChannel(params.channel);
|
|
738
|
+
const strategyContext = this.getPriceQueryStrategyContext(channel);
|
|
739
|
+
return {
|
|
740
|
+
ids: params.ids,
|
|
741
|
+
...(this.isCustomerUserPriceQuery() ? {} : {
|
|
742
|
+
open_quotation: 1
|
|
743
|
+
}),
|
|
744
|
+
open_bundle: 1,
|
|
745
|
+
with: [..._clientDataVariants.PRODUCT_QUERY_DATA_VARIANT_RELATIONS],
|
|
746
|
+
status: 'published',
|
|
747
|
+
num: Math.max(params.ids.length, 1),
|
|
748
|
+
skip: 1,
|
|
749
|
+
customer_id: params.customerId,
|
|
750
|
+
schedule_date: params.schedule.schedule_date,
|
|
751
|
+
schedule_datetime: params.schedule.schedule_datetime,
|
|
752
|
+
application_code: channel,
|
|
753
|
+
...(Object.keys(strategyContext).length ? {
|
|
754
|
+
strategy_context: strategyContext
|
|
755
|
+
} : {})
|
|
756
|
+
};
|
|
757
|
+
}
|
|
758
|
+
getRawProductPriceSources(ids) {
|
|
759
|
+
const products = this.store.products;
|
|
760
|
+
if (typeof products?.getRawProductPriceSources !== 'function') {
|
|
761
|
+
return new Map();
|
|
762
|
+
}
|
|
763
|
+
try {
|
|
764
|
+
const result = products.getRawProductPriceSources(ids);
|
|
765
|
+
return result instanceof Map ? result : new Map();
|
|
766
|
+
} catch (error) {
|
|
767
|
+
this.logWarning('getRawProductPriceSources: 读取商品原始报价源失败', {
|
|
768
|
+
ids,
|
|
769
|
+
error: error instanceof Error ? error.message : String(error)
|
|
770
|
+
});
|
|
771
|
+
return new Map();
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
rememberRawProductPriceSources(products) {
|
|
775
|
+
const productList = this.store.products;
|
|
776
|
+
if (typeof productList?.rememberRawProductQueryResult !== 'function') return;
|
|
777
|
+
try {
|
|
778
|
+
productList.rememberRawProductQueryResult(products);
|
|
779
|
+
} catch (error) {
|
|
780
|
+
this.logWarning('rememberRawProductPriceSources: 保存商品原始报价源失败', {
|
|
781
|
+
error: error instanceof Error ? error.message : String(error)
|
|
782
|
+
});
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
getSelectedProductVariantId(product) {
|
|
786
|
+
const variantId = Number(product?.product_variant_id ?? product?.variant_id ?? 0);
|
|
787
|
+
return Number.isFinite(variantId) && variantId > 0 ? variantId : 0;
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
/**
|
|
791
|
+
* 将目录原始商品还原为本次选择的 SKU 基线。
|
|
792
|
+
*
|
|
793
|
+
* 这里绝不能复用已评估后的目录商品,否则从命中智能价切回不命中的
|
|
794
|
+
* 日期时会残留旧价格。套餐仅验证所选关系存在,最终仍由 merge 方法把
|
|
795
|
+
* 评估后的套餐价格映射回用户的选择数据。
|
|
796
|
+
*/
|
|
797
|
+
prepareRawProductForPriceQuery(rawProduct, selectedProduct) {
|
|
798
|
+
const product = (0, _lodashEs.cloneDeep)(rawProduct);
|
|
799
|
+
const rawProductId = this.getPriceQueryProductId(product);
|
|
800
|
+
const selectedProductId = this.getPriceQueryProductId(selectedProduct);
|
|
801
|
+
if (rawProductId === null || selectedProductId === null || rawProductId !== selectedProductId) {
|
|
802
|
+
return null;
|
|
803
|
+
}
|
|
804
|
+
const selectedVariantId = this.getSelectedProductVariantId(selectedProduct);
|
|
805
|
+
product.product_id = product.product_id ?? product.id;
|
|
806
|
+
product.product_variant_id = selectedVariantId;
|
|
807
|
+
product.variant_id = selectedVariantId;
|
|
808
|
+
if (selectedVariantId > 0) {
|
|
809
|
+
const variants = Array.isArray(product.variant) ? product.variant : [];
|
|
810
|
+
const selectedVariant = variants.find(variant => Number(variant?.id) === selectedVariantId);
|
|
811
|
+
if (!selectedVariant) return null;
|
|
812
|
+
const variantPrice = selectedVariant.price ?? selectedVariant.selling_price ?? selectedVariant.base_price;
|
|
813
|
+
if (variantPrice === undefined || variantPrice === null || variantPrice === '') {
|
|
814
|
+
return null;
|
|
815
|
+
}
|
|
816
|
+
product.price = variantPrice;
|
|
817
|
+
product.selling_price = selectedVariant.selling_price ?? variantPrice;
|
|
818
|
+
product.base_price = selectedVariant.base_price ?? variantPrice;
|
|
819
|
+
}
|
|
820
|
+
const selectedBundles = Array.isArray(selectedProduct.product_bundle) ? selectedProduct.product_bundle : [];
|
|
821
|
+
if (selectedBundles.length > 0) {
|
|
822
|
+
const rawBundleItems = this.getAuthoritativeBundleItems(product);
|
|
823
|
+
const allSelectedBundlesExist = selectedBundles.every(bundle => {
|
|
824
|
+
const authoritativeBundle = this.findAuthoritativeBundleItem(bundle, rawBundleItems);
|
|
825
|
+
if (!authoritativeBundle) return false;
|
|
826
|
+
const selectedBundleVariantId = Number(bundle?.bundle_variant_id ?? bundle?.variant_id ?? 0);
|
|
827
|
+
const authoritativeBundleVariantId = Number(authoritativeBundle?.bundle_variant_id ?? authoritativeBundle?.variant_id ?? 0);
|
|
828
|
+
if ((Number.isFinite(selectedBundleVariantId) ? selectedBundleVariantId : 0) !== (Number.isFinite(authoritativeBundleVariantId) ? authoritativeBundleVariantId : 0)) {
|
|
829
|
+
return false;
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
// 省略字段表示该套餐子商品关系没有被价格查询完整水合,不能把它
|
|
833
|
+
// 当作“没有规则”而静默使用基础价。
|
|
834
|
+
return Array.isArray(authoritativeBundle.data_variants);
|
|
835
|
+
});
|
|
836
|
+
if (!allSelectedBundlesExist) return null;
|
|
837
|
+
}
|
|
838
|
+
return product;
|
|
839
|
+
}
|
|
840
|
+
resolveLocalProductForPriceQuery(params) {
|
|
841
|
+
if (!params.rawProduct) return null;
|
|
842
|
+
const preparedProduct = this.prepareRawProductForPriceQuery(params.rawProduct, params.selectedProduct);
|
|
843
|
+
if (!preparedProduct) return null;
|
|
844
|
+
const scheduleList = this.getPriceQueryScheduleList();
|
|
845
|
+
const result = (0, _clientDataVariants.tryResolveClientDataVariants)({
|
|
846
|
+
core: this.core,
|
|
847
|
+
otherParams: this.otherParams,
|
|
848
|
+
products: [preparedProduct],
|
|
849
|
+
queryPayload: params.queryPayload,
|
|
850
|
+
handledByOsServer: false,
|
|
851
|
+
...(scheduleList ? {
|
|
852
|
+
scheduleList
|
|
853
|
+
} : {})
|
|
854
|
+
});
|
|
855
|
+
if (result.status !== 'resolved') return null;
|
|
856
|
+
return result.products[0] || null;
|
|
857
|
+
}
|
|
723
858
|
async loadProductsForPriceQuery(params) {
|
|
724
859
|
const ids = Array.from(new Set(params.ids.filter(id => Number.isFinite(id))));
|
|
725
860
|
const productsById = new Map();
|
|
726
861
|
if (!ids.length || !this.request) return productsById;
|
|
727
|
-
const
|
|
728
|
-
const strategyContext = this.getPriceQueryStrategyContext(channel);
|
|
862
|
+
const handledByOsServer = (0, _clientDataVariants.isProductQueryHandledByOsServer)(this.core, this.request);
|
|
729
863
|
try {
|
|
730
|
-
const
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
num: 1,
|
|
736
|
-
skip: 1,
|
|
737
|
-
customer_id: params.customerId,
|
|
738
|
-
schedule_date: params.schedule.schedule_date,
|
|
739
|
-
schedule_datetime: params.schedule.schedule_datetime,
|
|
740
|
-
application_code: channel,
|
|
741
|
-
...(Object.keys(strategyContext).length ? {
|
|
742
|
-
strategy_context: strategyContext
|
|
743
|
-
} : {})
|
|
744
|
-
}, {
|
|
864
|
+
const queryPayload = this.buildPriceQueryPayload({
|
|
865
|
+
...params,
|
|
866
|
+
ids
|
|
867
|
+
});
|
|
868
|
+
const response = await this.request.post('/product/query', queryPayload, {
|
|
745
869
|
osServer: true,
|
|
746
870
|
customToast: () => {}
|
|
747
871
|
});
|
|
748
872
|
const list = response?.data?.list || response?.list || [];
|
|
749
873
|
if (!Array.isArray(list)) return productsById;
|
|
750
|
-
|
|
874
|
+
if (this.isCustomerUserPriceQuery() && !handledByOsServer) {
|
|
875
|
+
this.rememberRawProductPriceSources(list);
|
|
876
|
+
list.forEach(item => {
|
|
877
|
+
const productId = Number(item?.id ?? item?.product_id);
|
|
878
|
+
if (Number.isFinite(productId)) productsById.set(productId, item);
|
|
879
|
+
});
|
|
880
|
+
return productsById;
|
|
881
|
+
}
|
|
882
|
+
const scheduleList = this.getPriceQueryScheduleList();
|
|
883
|
+
const resolvedList = (0, _clientDataVariants.resolveClientDataVariants)({
|
|
884
|
+
core: this.core,
|
|
885
|
+
otherParams: this.otherParams,
|
|
886
|
+
products: list,
|
|
887
|
+
queryPayload,
|
|
888
|
+
handledByOsServer,
|
|
889
|
+
...(scheduleList ? {
|
|
890
|
+
scheduleList
|
|
891
|
+
} : {})
|
|
892
|
+
});
|
|
893
|
+
resolvedList.forEach(item => {
|
|
751
894
|
const productId = Number(item?.id ?? item?.product_id);
|
|
752
895
|
if (Number.isFinite(productId)) productsById.set(productId, item);
|
|
753
896
|
});
|
|
@@ -760,18 +903,69 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
760
903
|
return productsById;
|
|
761
904
|
}
|
|
762
905
|
}
|
|
763
|
-
async
|
|
764
|
-
const
|
|
765
|
-
const
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
906
|
+
async resolveProductsForPriceQuery(params) {
|
|
907
|
+
const selectedProducts = params.priceQueries.map(item => item.product || {});
|
|
908
|
+
const productIds = selectedProducts.map(product => this.getPriceQueryProductId(product));
|
|
909
|
+
const ids = Array.from(new Set(productIds.filter(id => id !== null)));
|
|
910
|
+
if (!ids.length) {
|
|
911
|
+
return selectedProducts.map(() => null);
|
|
912
|
+
}
|
|
913
|
+
const handledByOsServer = this.request ? (0, _clientDataVariants.isProductQueryHandledByOsServer)(this.core, this.request) : false;
|
|
914
|
+
const canUseLocalFastPath = this.isCustomerUserPriceQuery() && !handledByOsServer;
|
|
915
|
+
if (!canUseLocalFastPath) {
|
|
916
|
+
if (!this.request) return selectedProducts.map(() => null);
|
|
917
|
+
const productsById = await this.loadProductsForPriceQuery({
|
|
918
|
+
ids,
|
|
919
|
+
schedule: params.schedule,
|
|
920
|
+
customerId: params.customerId,
|
|
921
|
+
channel: params.channel
|
|
922
|
+
});
|
|
923
|
+
return productIds.map(productId => productId === null ? null : productsById.get(productId) || null);
|
|
924
|
+
}
|
|
925
|
+
const queryPayload = this.buildPriceQueryPayload({
|
|
926
|
+
ids,
|
|
927
|
+
schedule: params.schedule,
|
|
928
|
+
customerId: params.customerId,
|
|
772
929
|
channel: params.channel
|
|
773
930
|
});
|
|
774
|
-
|
|
931
|
+
const cachedRawProducts = this.getRawProductPriceSources(ids);
|
|
932
|
+
const authoritativeProducts = selectedProducts.map((selectedProduct, index) => {
|
|
933
|
+
const productId = productIds[index];
|
|
934
|
+
return productId === null ? null : this.resolveLocalProductForPriceQuery({
|
|
935
|
+
selectedProduct,
|
|
936
|
+
rawProduct: cachedRawProducts.get(productId),
|
|
937
|
+
queryPayload
|
|
938
|
+
});
|
|
939
|
+
});
|
|
940
|
+
const missingIds = Array.from(new Set(productIds.filter((productId, index) => productId !== null && !authoritativeProducts[index])));
|
|
941
|
+
if (!missingIds.length) return authoritativeProducts;
|
|
942
|
+
if (!this.request) return authoritativeProducts;
|
|
943
|
+
const remoteRawProducts = await this.loadProductsForPriceQuery({
|
|
944
|
+
ids: missingIds,
|
|
945
|
+
schedule: params.schedule,
|
|
946
|
+
customerId: params.customerId,
|
|
947
|
+
channel: params.channel
|
|
948
|
+
});
|
|
949
|
+
authoritativeProducts.forEach((authoritativeProduct, index) => {
|
|
950
|
+
if (authoritativeProduct) return;
|
|
951
|
+
const productId = productIds[index];
|
|
952
|
+
if (productId === null) return;
|
|
953
|
+
const rawProduct = remoteRawProducts.get(productId);
|
|
954
|
+
const locallyResolved = this.resolveLocalProductForPriceQuery({
|
|
955
|
+
selectedProduct: selectedProducts[index],
|
|
956
|
+
rawProduct,
|
|
957
|
+
queryPayload
|
|
958
|
+
});
|
|
959
|
+
if (locallyResolved) {
|
|
960
|
+
authoritativeProducts[index] = locallyResolved;
|
|
961
|
+
return;
|
|
962
|
+
}
|
|
963
|
+
|
|
964
|
+
// 严格客户端能力仍不可用时,真实请求已经是最后的权威降级。
|
|
965
|
+
// 尽量应用所选 SKU 基线;关系不完整时保持旧的远端商品语义。
|
|
966
|
+
authoritativeProducts[index] = rawProduct ? this.prepareRawProductForPriceQuery(rawProduct, selectedProducts[index]) || rawProduct : null;
|
|
967
|
+
});
|
|
968
|
+
return authoritativeProducts;
|
|
775
969
|
}
|
|
776
970
|
getAuthoritativeBundleItems(product) {
|
|
777
971
|
if (Array.isArray(product?.product_bundle)) return product.product_bundle;
|
|
@@ -2955,16 +3149,24 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
2955
3149
|
return (0, _transformBaseProductToOrderProduct.transformBaseProductToOrderProduct)(params);
|
|
2956
3150
|
}
|
|
2957
3151
|
async calculateProductBookingPrice(params) {
|
|
2958
|
-
const
|
|
3152
|
+
const useCustomerUserPricing = this.isCustomerUserPriceQuery();
|
|
3153
|
+
const quotation = useCustomerUserPricing ? undefined : this.store.quotation;
|
|
2959
3154
|
const customerId = params.customer_id ?? this.getCurrentOrderCustomerId();
|
|
2960
3155
|
await this.prepareProductPriceQueryContext(customerId);
|
|
2961
|
-
const authoritativeProduct = await this.
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
customer_id: customerId,
|
|
3156
|
+
const [authoritativeProduct] = await this.resolveProductsForPriceQuery({
|
|
3157
|
+
priceQueries: [params],
|
|
3158
|
+
schedule: this.getPriceQuerySchedule(params),
|
|
3159
|
+
customerId,
|
|
2966
3160
|
channel: params.channel
|
|
2967
3161
|
});
|
|
3162
|
+
const product = this.mergeProductForPriceQuery(params.product, authoritativeProduct);
|
|
3163
|
+
if (!useCustomerUserPricing) {
|
|
3164
|
+
await this.loadQuotationForPriceQuery({
|
|
3165
|
+
quotation,
|
|
3166
|
+
customer_id: customerId,
|
|
3167
|
+
channel: params.channel
|
|
3168
|
+
});
|
|
3169
|
+
}
|
|
2968
3170
|
return (0, _quotationPrice.calculateBaseSalesProductBookingPrice)({
|
|
2969
3171
|
...params,
|
|
2970
3172
|
product,
|
|
@@ -3014,13 +3216,13 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
3014
3216
|
return Array.isArray(configs) && configs.length > 0;
|
|
3015
3217
|
}
|
|
3016
3218
|
shouldRecalculateProductBookingPricesForContextChange(params) {
|
|
3017
|
-
const scopeInfo = this.getQuotationCustomerScopeInfo();
|
|
3018
|
-
const scopedCustomerIds = new Set(scopeInfo.customerIds.map(id => String(id)));
|
|
3019
3219
|
const previousCustomerId = this.normalizePriceContextCustomerId(params.previousCustomerId);
|
|
3020
3220
|
const nextCustomerId = this.normalizePriceContextCustomerId(params.nextCustomerId);
|
|
3021
|
-
if (this.hasSmartPricingStrategies()) {
|
|
3221
|
+
if (this.isCustomerUserPriceQuery() || this.hasSmartPricingStrategies()) {
|
|
3022
3222
|
return previousCustomerId !== nextCustomerId;
|
|
3023
3223
|
}
|
|
3224
|
+
const scopeInfo = this.getQuotationCustomerScopeInfo();
|
|
3225
|
+
const scopedCustomerIds = new Set(scopeInfo.customerIds.map(id => String(id)));
|
|
3024
3226
|
const previousInScope = previousCustomerId ? scopedCustomerIds.has(previousCustomerId) : false;
|
|
3025
3227
|
const nextInScope = nextCustomerId ? scopedCustomerIds.has(nextCustomerId) : false;
|
|
3026
3228
|
let shouldRecalculate = false;
|
|
@@ -3037,48 +3239,50 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
3037
3239
|
}
|
|
3038
3240
|
async calculateProductBookingPrices(paramsList) {
|
|
3039
3241
|
if (!paramsList.length) return [];
|
|
3040
|
-
const
|
|
3041
|
-
const
|
|
3042
|
-
|
|
3043
|
-
const
|
|
3242
|
+
const useCustomerUserPricing = this.isCustomerUserPriceQuery();
|
|
3243
|
+
const quotation = useCustomerUserPricing ? undefined : this.store.quotation;
|
|
3244
|
+
const currentOrderCustomerId = this.getCurrentOrderCustomerId();
|
|
3245
|
+
const authoritativeProducts = paramsList.map(() => null);
|
|
3044
3246
|
const groups = new Map();
|
|
3045
|
-
paramsList.forEach(params => {
|
|
3046
|
-
const product = params.product || {};
|
|
3047
|
-
const productId = this.getPriceQueryProductId(product);
|
|
3048
|
-
if (productId === null) return;
|
|
3247
|
+
paramsList.forEach((params, index) => {
|
|
3049
3248
|
const schedule = this.getPriceQuerySchedule(params);
|
|
3050
|
-
const channel = params.channel
|
|
3051
|
-
const
|
|
3249
|
+
const channel = this.getPriceQueryChannel(params.channel);
|
|
3250
|
+
const customerId = params.customer_id ?? currentOrderCustomerId;
|
|
3251
|
+
const groupKey = [schedule.schedule_date, schedule.schedule_datetime, channel || '', this.normalizePriceContextCustomerId(customerId) || ''].join('|');
|
|
3052
3252
|
const group = groups.get(groupKey) || {
|
|
3053
|
-
|
|
3253
|
+
indices: [],
|
|
3054
3254
|
schedule,
|
|
3255
|
+
customerId,
|
|
3055
3256
|
channel
|
|
3056
3257
|
};
|
|
3057
|
-
group.
|
|
3258
|
+
group.indices.push(index);
|
|
3058
3259
|
groups.set(groupKey, group);
|
|
3059
3260
|
});
|
|
3060
|
-
await Promise.all(Array.from(groups.
|
|
3061
|
-
|
|
3062
|
-
|
|
3261
|
+
await Promise.all(Array.from(groups.values()).map(async group => {
|
|
3262
|
+
await this.prepareProductPriceQueryContext(group.customerId);
|
|
3263
|
+
const priceQueries = group.indices.map(index => paramsList[index]);
|
|
3264
|
+
const resolvedProducts = await this.resolveProductsForPriceQuery({
|
|
3265
|
+
priceQueries,
|
|
3063
3266
|
schedule: group.schedule,
|
|
3064
|
-
customerId,
|
|
3267
|
+
customerId: group.customerId,
|
|
3065
3268
|
channel: group.channel
|
|
3066
3269
|
});
|
|
3067
|
-
|
|
3270
|
+
group.indices.forEach((originalIndex, groupIndex) => {
|
|
3271
|
+
authoritativeProducts[originalIndex] = resolvedProducts[groupIndex] || null;
|
|
3272
|
+
});
|
|
3068
3273
|
}));
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3274
|
+
if (!useCustomerUserPricing) {
|
|
3275
|
+
await this.loadQuotationForPriceQuery({
|
|
3276
|
+
quotation,
|
|
3277
|
+
customer_id: paramsList[0]?.customer_id ?? currentOrderCustomerId,
|
|
3278
|
+
channel: paramsList[0]?.channel
|
|
3279
|
+
});
|
|
3280
|
+
}
|
|
3281
|
+
return paramsList.map((params, index) => {
|
|
3075
3282
|
const productInput = params.product || {};
|
|
3076
|
-
const
|
|
3077
|
-
const schedule = this.getPriceQuerySchedule(params);
|
|
3078
|
-
const channel = params.channel || this.otherParams?.channel;
|
|
3079
|
-
const groupKey = [schedule.schedule_date, schedule.schedule_datetime, channel || ''].join('|');
|
|
3080
|
-
const authoritativeProduct = productId === null ? null : productMapsByGroup.get(groupKey)?.get(productId) || null;
|
|
3283
|
+
const authoritativeProduct = authoritativeProducts[index];
|
|
3081
3284
|
const product = this.mergeProductForPriceQuery(productInput, authoritativeProduct);
|
|
3285
|
+
const customerId = params.customer_id ?? currentOrderCustomerId;
|
|
3082
3286
|
return (0, _quotationPrice.calculateBaseSalesProductBookingPrice)({
|
|
3083
3287
|
...params,
|
|
3084
3288
|
product,
|
|
@@ -326,7 +326,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
326
326
|
date: string;
|
|
327
327
|
status: string;
|
|
328
328
|
week: string;
|
|
329
|
-
weekNum: 0 | 1 |
|
|
329
|
+
weekNum: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
330
330
|
}[]>;
|
|
331
331
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
332
332
|
private getScheduleDataByIds;
|
|
@@ -334,7 +334,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
334
334
|
* 获取当前的客户搜索条件
|
|
335
335
|
* @returns 当前搜索条件
|
|
336
336
|
*/
|
|
337
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
337
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
|
|
338
338
|
/**
|
|
339
339
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
340
340
|
* @returns 客户状态
|
|
@@ -49,6 +49,7 @@ Object.keys(_types).forEach(function (key) {
|
|
|
49
49
|
var _remoteOccupancyCache = require("./remoteOccupancyCache");
|
|
50
50
|
var _BookingTicket = require("../BookingTicket");
|
|
51
51
|
var _localClock = require("../../modules/ResourcePlanner/localClock");
|
|
52
|
+
var _platform = require("../../utils/platform");
|
|
52
53
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
53
54
|
const OPEN_DATA_SECTION_CODES = ['sale', 'reservation', 'fulfillment', 'menu', 'workflow', 'basic', 'checkout', 'availability'];
|
|
54
55
|
const OPEN_DATA_CACHE_TTL = 5 * 60 * 1000;
|
|
@@ -1546,8 +1547,7 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
1546
1547
|
return true;
|
|
1547
1548
|
}
|
|
1548
1549
|
isAuthenticatedCustomerUserPlatform() {
|
|
1549
|
-
|
|
1550
|
-
return platform === 'pc' || platform === 'h5';
|
|
1550
|
+
return (0, _platform.isCustomerUserPlatform)(this.otherParams?.platform);
|
|
1551
1551
|
}
|
|
1552
1552
|
resolveDiscountOrderIdentity(tempOrder) {
|
|
1553
1553
|
return tempOrder?.order_id || this.store.order?.getOrderIdentity?.()?.orderId || null;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalize the runtime platform passed through solution/module otherParams.
|
|
3
|
+
*/
|
|
4
|
+
export declare function normalizeRuntimePlatform(platform: unknown): string;
|
|
5
|
+
/**
|
|
6
|
+
* PC and H5 are authenticated-customer clients rather than staff terminals.
|
|
7
|
+
*/
|
|
8
|
+
export declare function isCustomerUserPlatform(platform: unknown): boolean;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isCustomerUserPlatform = isCustomerUserPlatform;
|
|
7
|
+
exports.normalizeRuntimePlatform = normalizeRuntimePlatform;
|
|
8
|
+
const CUSTOMER_USER_PLATFORMS = new Set(['pc', 'h5']);
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Normalize the runtime platform passed through solution/module otherParams.
|
|
12
|
+
*/
|
|
13
|
+
function normalizeRuntimePlatform(platform) {
|
|
14
|
+
return String(platform ?? '').trim().toLowerCase();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* PC and H5 are authenticated-customer clients rather than staff terminals.
|
|
19
|
+
*/
|
|
20
|
+
function isCustomerUserPlatform(platform) {
|
|
21
|
+
return CUSTOMER_USER_PLATFORMS.has(normalizeRuntimePlatform(platform));
|
|
22
|
+
}
|