From 232ba6884fc96e251184a2a1b0fc1499fbe899b0 Mon Sep 17 00:00:00 2001
From: puhanshu <a9236326>
Date: 星期五, 24 九月 2021 15:25:29 +0800
Subject: [PATCH] 便民服务问题修改

---
 springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ConvenientMerchantServiceImpl.java |   39 ++++++++++++++++++++++++++++++++++++++-
 1 files changed, 38 insertions(+), 1 deletions(-)

diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ConvenientMerchantServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ConvenientMerchantServiceImpl.java
index a5e3fa5..f9576b7 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ConvenientMerchantServiceImpl.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ConvenientMerchantServiceImpl.java
@@ -11,6 +11,7 @@
 
 import javax.annotation.Resource;
 
+import com.panzhihua.common.model.vos.community.convenient.ExportMerchantVO;
 import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -159,6 +160,15 @@
         page.setSize(pageConvenientMerchantDTO.getPageSize());
         page.setCurrent(pageConvenientMerchantDTO.getPageNum());
         IPage<ConvenientMerchantVO> iPage = this.baseMapper.pageMerchant(page, pageConvenientMerchantDTO);
+        if (nonNull(pageConvenientMerchantDTO.getServiceId())) {
+            List<ConvenientMerchantVO> records = iPage.getRecords();
+            if (!records.isEmpty()) {
+                records.forEach(record -> {
+                    String serviceScope = convenientServiceCategoryDAO.selectServiceScopeByMerchantId(record.getId());
+                    record.setServiceScope(serviceScope);
+                });
+            }
+        }
         return R.ok(iPage);
     }
 
@@ -261,6 +271,13 @@
         page.setSize(pageClassifyMerchantDTO.getPageSize());
         page.setCurrent(pageClassifyMerchantDTO.getPageNum());
         IPage<ConvenientMerchantVO> merchantVOList = this.baseMapper.getClassifyMerchants(page, pageClassifyMerchantDTO, currentMon);
+        List<ConvenientMerchantVO> records = merchantVOList.getRecords();
+        if (!records.isEmpty()) {
+            records.forEach(record -> {
+                String serviceScope = convenientServiceCategoryDAO.selectServiceScopeByMerchantId(record.getId());
+                record.setServiceScope(serviceScope);
+            });
+        }
         return R.ok(merchantVOList);
     }
 
@@ -313,6 +330,10 @@
 
     @Override
     public R consultMerchant(Long merchantId) {
+        ConvenientMerchantDO merchantDO = this.baseMapper.selectById(merchantId);
+        if (isNull(merchantDO)) {
+            return R.fail("商家不存在");
+        }
         SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
         String nowDate = simpleDateFormat.format(new Date());
         ConvenientConsultationStatisticsDO statisticsDO = convenientConsultationStatisticsDAO.selectOne(new LambdaQueryWrapper<ConvenientConsultationStatisticsDO>()
@@ -327,6 +348,10 @@
 
     @Override
     public R incrMerchantView(Long merchantId) {
+        ConvenientMerchantDO merchantDO = this.baseMapper.selectById(merchantId);
+        if (isNull(merchantDO)) {
+            return R.fail("商家不存在");
+        }
         SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
         String nowDate = simpleDateFormat.format(new Date());
         ConvenientViewStatisticsDO statisticsDO = convenientViewStatisticsDAO.selectOne(new LambdaQueryWrapper<ConvenientViewStatisticsDO>()
@@ -341,7 +366,19 @@
 
     @Override
     public R exportMerchant(ExportMerchantDTO exportMerchantDTO) {
-        return R.ok(this.baseMapper.exportMerchant(exportMerchantDTO));
+        List<Long> needExportIds = exportMerchantDTO.getIds();
+        if (nonNull(needExportIds) && !needExportIds.isEmpty()) {
+            //根据id导出
+            return R.ok(this.baseMapper.exportMerchantByIds(needExportIds));
+        }
+        List<ExportMerchantVO> exportMerchantVOList = this.baseMapper.exportMerchantBySearch(exportMerchantDTO);
+        if (nonNull(exportMerchantDTO.getServiceId()) && !exportMerchantVOList.isEmpty()) {
+            exportMerchantVOList.forEach(merchant -> {
+                String serviceScope = convenientServiceCategoryDAO.selectServiceScopeByMerchantId(merchant.getId());
+                merchant.setServiceScope(serviceScope);
+            });
+        }
+        return R.ok(exportMerchantVOList);
     }
 
     /**

--
Gitblit v1.7.1