From 8eb8d2c48c9457f5f1d4d873dca4b32086be08dd Mon Sep 17 00:00:00 2001 From: Jack <46790855@qq.com> Date: Mon, 12 Jan 2026 21:58:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E5=BA=97=E9=93=BA=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E5=A2=9E=E5=8A=A0=E5=88=86=E8=A1=A8=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E9=9B=86=E5=90=88=20branch=5Fstore=5Flist=20=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/ShopStoreBaseServiceImpl.java | 119 ++++++++++++------ 1 file changed, 81 insertions(+), 38 deletions(-) diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/store/service/impl/ShopStoreBaseServiceImpl.java b/mall-shop/src/main/java/com/suisung/mall/shop/store/service/impl/ShopStoreBaseServiceImpl.java index 32202029..d88daf4e 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/store/service/impl/ShopStoreBaseServiceImpl.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/store/service/impl/ShopStoreBaseServiceImpl.java @@ -93,6 +93,7 @@ import java.math.BigDecimal; import java.util.*; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ThreadPoolExecutor; +import java.util.function.Function; import java.util.stream.Collectors; import java.util.stream.IntStream; import java.util.stream.Stream; @@ -1480,35 +1481,63 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl queryWrapper, Integer pageNum, Integer pageSize) { Map data = getLists(queryWrapper, pageNum, pageSize); - List items = (List) data.get("items"); + List items = procStoreBaseItem((List) data.get("items")); - //经营期限 - List store_ids = items.stream().map(s -> Convert.toInt(s.get("store_id"))).collect(Collectors.toList()); - List store_info_rows = shopStoreInfoService.gets(store_ids); - List subsite_ids = items.stream().map(s -> Convert.toInt(s.get("subsite_id"))).distinct().collect(Collectors.toList()); - List subsite_rows = null; - if (CollUtil.isNotEmpty(subsite_ids)) { - subsite_rows = shopPlantformSubsiteService.gets(subsite_ids); + // 商家图片 + data.put("items", accountService.fixUserAvatar(items, true)); + + return data; + } + + public List procStoreBaseItem(List items) { + if (CollUtil.isEmpty(items)) { + return new ArrayList<>(); } - //店铺统计 + // 预加载相关数据 + List store_ids = items.stream() + .map(s -> Convert.toInt(s.get("store_id"))) + .collect(Collectors.toList()); + + List store_info_rows = shopStoreInfoService.gets(store_ids); List store_analytics_rows = shopStoreAnalyticsService.gets(store_ids); - List finalSubsite_rows = subsite_rows; + + // 预加载站点信息 + List subsite_ids = items.stream() + .map(s -> Convert.toInt(s.get("subsite_id"))) + .distinct() + .collect(Collectors.toList()); + List subsite_rows = CollUtil.isNotEmpty(subsite_ids) ? + shopPlantformSubsiteService.gets(subsite_ids) : new ArrayList<>(); + + // 构建映射关系 + Map storeInfoMap = store_info_rows.stream() + .collect(Collectors.toMap(ShopStoreInfo::getStore_id, Function.identity(), (a, b) -> a)); + Map analyticsMap = store_analytics_rows.stream() + .collect(Collectors.toMap(ShopStoreAnalytics::getStore_id, Function.identity(), (a, b) -> a)); + Map subsiteMap = subsite_rows.stream() + .collect(Collectors.toMap(ShopPlantformSubsite::getSubsite_id, + ShopPlantformSubsite::getSubsite_name, (a, b) -> a)); + + // 处理每个店铺项 items.forEach(s -> { - Integer _store_id = Convert.toInt(s.get("store_id")); - Optional 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 = 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_num", analytics.getStore_evaluation_num()); s.put("store_sales_num", analytics.getStore_sales_num()); @@ -1516,30 +1545,26 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl arr = Arrays.asList(1, 1, 1, 1, 1); - s.put("scores_arr", arr); - } - Integer subsite_id = Convert.toInt(s.get("subsite_id")); - Optional 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._("全国站")); + s.put("scores_arr", new Integer[]{1, 1, 1, 1, 1}); } - // 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 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); if (ObjectUtil.isNotEmpty(entry)) { lkl_contract_file_url = entry.getContract_download_url(); @@ -1554,13 +1579,31 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("parent_id", s.get("store_id")) + .eq("store_is_open", CommonConstant.Enable); + + Map data = getLists(queryWrapper, 1, 500); + List branchItems = (List) 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) data.get("items"), true)); - - return data; + return items; } + @Override public Map getBase(Integer store_id) {