平台店铺列表增加分表数据集合 branch_store_list 字段

This commit is contained in:
Jack 2026-01-12 21:58:30 +08:00
parent 3891469582
commit 8eb8d2c48c

View File

@ -93,6 +93,7 @@ import java.math.BigDecimal;
import java.util.*; import java.util.*;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.ThreadPoolExecutor;
import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.IntStream; import java.util.stream.IntStream;
import java.util.stream.Stream; import java.util.stream.Stream;
@ -1480,35 +1481,63 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
public Map getBaseList(QueryWrapper<ShopStoreBase> queryWrapper, Integer pageNum, Integer pageSize) { public Map getBaseList(QueryWrapper<ShopStoreBase> queryWrapper, Integer pageNum, Integer pageSize) {
Map data = getLists(queryWrapper, pageNum, pageSize); Map data = getLists(queryWrapper, pageNum, pageSize);
List<Map> items = (List<Map>) data.get("items"); List<Map> items = procStoreBaseItem((List<Map>) data.get("items"));
//经营期限 // 商家图片
List<Integer> store_ids = items.stream().map(s -> Convert.toInt(s.get("store_id"))).collect(Collectors.toList()); data.put("items", accountService.fixUserAvatar(items, true));
List<ShopStoreInfo> store_info_rows = shopStoreInfoService.gets(store_ids);
List<Integer> subsite_ids = items.stream().map(s -> Convert.toInt(s.get("subsite_id"))).distinct().collect(Collectors.toList()); return data;
List<ShopPlantformSubsite> subsite_rows = null; }
if (CollUtil.isNotEmpty(subsite_ids)) {
subsite_rows = shopPlantformSubsiteService.gets(subsite_ids); public List<Map> procStoreBaseItem(List<Map> items) {
if (CollUtil.isEmpty(items)) {
return new ArrayList<>();
} }
//店铺统计 // 预加载相关数据
List<Integer> store_ids = items.stream()
.map(s -> Convert.toInt(s.get("store_id")))
.collect(Collectors.toList());
List<ShopStoreInfo> store_info_rows = shopStoreInfoService.gets(store_ids);
List<ShopStoreAnalytics> store_analytics_rows = shopStoreAnalyticsService.gets(store_ids); List<ShopStoreAnalytics> store_analytics_rows = shopStoreAnalyticsService.gets(store_ids);
List<ShopPlantformSubsite> finalSubsite_rows = subsite_rows;
// 预加载站点信息
List<Integer> subsite_ids = items.stream()
.map(s -> Convert.toInt(s.get("subsite_id")))
.distinct()
.collect(Collectors.toList());
List<ShopPlantformSubsite> subsite_rows = CollUtil.isNotEmpty(subsite_ids) ?
shopPlantformSubsiteService.gets(subsite_ids) : new ArrayList<>();
// 构建映射关系
Map<Integer, ShopStoreInfo> storeInfoMap = store_info_rows.stream()
.collect(Collectors.toMap(ShopStoreInfo::getStore_id, Function.identity(), (a, b) -> a));
Map<Integer, ShopStoreAnalytics> analyticsMap = store_analytics_rows.stream()
.collect(Collectors.toMap(ShopStoreAnalytics::getStore_id, Function.identity(), (a, b) -> a));
Map<Integer, String> subsiteMap = subsite_rows.stream()
.collect(Collectors.toMap(ShopPlantformSubsite::getSubsite_id,
ShopPlantformSubsite::getSubsite_name, (a, b) -> a));
// 处理每个店铺项
items.forEach(s -> { items.forEach(s -> {
Integer _store_id = Convert.toInt(s.get("store_id")); Integer _store_id = Convert.toInt(s.get("store_id"));
Optional<ShopStoreInfo> Store_Info_rows = store_info_rows.stream().filter(t -> ObjectUtil.equal(t.getStore_id(), _store_id)).findFirst();
ShopStoreInfo storeInfo = Store_Info_rows.orElseGet(ShopStoreInfo::new);
s.put("store_start_time", storeInfo.getStore_start_time()); // 填充店铺信息
s.put("store_end_time", Convert.toDate(s.get("store_end_time"))); ShopStoreInfo storeInfo = storeInfoMap.get(_store_id);
if (storeInfo != null) {
s.put("store_start_time", storeInfo.getStore_start_time());
s.put("store_end_time", Convert.toDate(s.get("store_end_time")));
s.put("store_opening_hours", storeInfo.getStore_opening_hours());
s.put("store_close_hours", storeInfo.getStore_close_hours());
}
s.put("store_opening_hours", storeInfo.getStore_opening_hours()); // 填充统计数据
s.put("store_close_hours", storeInfo.getStore_close_hours()); ShopStoreAnalytics analytics = analyticsMap.get(_store_id);
if (analytics == null) {
analytics = new ShopStoreAnalytics();
}
Optional<ShopStoreAnalytics> shopStoreAnalytics = store_analytics_rows.stream().filter(r -> ObjectUtil.equal(r.getStore_id(), _store_id)).findFirst();
ShopStoreAnalytics analytics = shopStoreAnalytics.orElseGet(ShopStoreAnalytics::new);
s.put("store_evaluation_rate", analytics.getStore_evaluation_rate()); s.put("store_evaluation_rate", analytics.getStore_evaluation_rate());
s.put("store_evaluation_num", analytics.getStore_evaluation_num()); s.put("store_evaluation_num", analytics.getStore_evaluation_num());
s.put("store_sales_num", analytics.getStore_sales_num()); s.put("store_sales_num", analytics.getStore_sales_num());
@ -1516,30 +1545,26 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
s.put("store_favorite_num", analytics.getStore_favorite_num()); s.put("store_favorite_num", analytics.getStore_favorite_num());
s.put("store_trade_amount", analytics.getStore_trade_amount()); s.put("store_trade_amount", analytics.getStore_trade_amount());
if (ObjectUtil.isNotNull(analytics.getStore_evaluation_num()) && analytics.getStore_evaluation_num() != 0) { // 处理评价率计算
if (ObjectUtil.isNotNull(analytics.getStore_evaluation_num())
&& analytics.getStore_evaluation_num() != 0) {
BigDecimal store_servicecredit = analytics.getStore_servicecredit(); BigDecimal store_servicecredit = analytics.getStore_servicecredit();
BigDecimal div = NumberUtil.div(store_servicecredit, analytics.getStore_evaluation_num()); BigDecimal div = NumberUtil.div(store_servicecredit, analytics.getStore_evaluation_num());
s.put("store_evaluation_rate", div); s.put("store_evaluation_rate", div);
s.put("scores_arr", IntStream.rangeClosed(1, Convert.toInt(analytics.getStore_evaluation_rate())).toArray()); s.put("scores_arr", IntStream.rangeClosed(1, Convert.toInt(div)).toArray());
} else { } else {
s.put("store_evaluation_rate", 5.0); s.put("store_evaluation_rate", 5.0);
List<Integer> arr = Arrays.asList(1, 1, 1, 1, 1); s.put("scores_arr", new Integer[]{1, 1, 1, 1, 1});
s.put("scores_arr", arr);
}
Integer subsite_id = Convert.toInt(s.get("subsite_id"));
Optional<ShopPlantformSubsite> shopPlantformSubsites = finalSubsite_rows.stream()
.filter(g -> ObjectUtil.equal(g.getSubsite_id(), subsite_id)).findFirst();
if (shopPlantformSubsites.isPresent()) {
s.put("subsite_name", shopPlantformSubsites.get().getSubsite_name());
} else {
s.put("subsite_name", I18nUtil._("全国站"));
} }
// E签宝和拉卡拉的合同文件下载地址 // 填充站点名称
Integer subsite_id = Convert.toInt(s.get("subsite_id"));
s.put("subsite_name", subsiteMap.getOrDefault(subsite_id, I18nUtil._("全国站")));
// 填充合同信息
String lkl_contract_file_url = ""; String lkl_contract_file_url = "";
String esign_contract_file_url = ""; String esign_contract_file_url = "";
Integer esign_contract_flow_status = -1;//合同签署状态-1预备数据阶段0-等待签署1-已部分签署2-已完成所有签署方完成签署;3-已撤销发起方撤销签署任务;5-已过期签署截止日到期后触发;7-已拒签签署方拒绝签署 Integer esign_contract_flow_status = -1;
ShopMchEntry entry = shopMchEntryService.getLklContractStatusUrl(_store_id); ShopMchEntry entry = shopMchEntryService.getLklContractStatusUrl(_store_id);
if (ObjectUtil.isNotEmpty(entry)) { if (ObjectUtil.isNotEmpty(entry)) {
lkl_contract_file_url = entry.getContract_download_url(); lkl_contract_file_url = entry.getContract_download_url();
@ -1554,13 +1579,31 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
s.put("lkl_contract_file_url", lkl_contract_file_url); s.put("lkl_contract_file_url", lkl_contract_file_url);
s.put("esign_contract_file_url", esign_contract_file_url); s.put("esign_contract_file_url", esign_contract_file_url);
s.put("esign_contract_flow_status", esign_contract_flow_status); s.put("esign_contract_flow_status", esign_contract_flow_status);
// 处理分店信息限制递归深度以避免栈溢出
Integer parentId = Convert.toInt(s.get("parent_id"));
if (parentId != null && parentId == 0) {
QueryWrapper<ShopStoreBase> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("parent_id", s.get("store_id"))
.eq("store_is_open", CommonConstant.Enable);
Map data = getLists(queryWrapper, 1, 500);
List<Map> branchItems = (List<Map>) data.get("items");
if (CollUtil.isNotEmpty(branchItems)) {
s.put("branch_store_list", procStoreBaseItem(branchItems));
} else {
s.put("branch_store_list", Collections.emptyList());
}
} else {
s.put("branch_store_list", Collections.emptyList());
}
}); });
data.put("items", accountService.fixUserAvatar((List<Map>) data.get("items"), true)); return items;
return data;
} }
@Override @Override
public Map getBase(Integer store_id) { public Map getBase(Integer store_id) {