From b2fce0dc7dc4ea5dec9792a2bc3ceb9d33d6e07b Mon Sep 17 00:00:00 2001
From: lidongdong <1459917685@qq.com>
Date: 星期一, 04 九月 2023 13:59:52 +0800
Subject: [PATCH] 修改后台社区动态加载不出来

---
 springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ConvenientMerchantServiceImpl.java |   56 ++++++++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 46 insertions(+), 10 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 2af73b7..c973642 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
@@ -1,5 +1,6 @@
 package com.panzhihua.service_community.service.impl;
 
+import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.util.NumberUtil;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@@ -124,7 +125,9 @@
         if (isNull(convenientMerchantDO)) {
             return R.fail("商家不存在");
         }
-        if (nonNull(merchantDO)&&!merchantDO.getId().equals(convenientMerchantDO.getId())) {
+        Long createBy = convenientMerchantDO.getCreatedBy();
+        BeanUtils.copyProperties(convenientMerchantDTO, convenientMerchantDO);
+        if (nonNull(merchantDO) && !merchantDO.getId().equals(convenientMerchantDO.getId())) {
             R.fail("该微信手机号:" + mobilePhone + "已被使用!请更换");
         }
         Long communityId = convenientMerchantDTO.getCommunityId();
@@ -150,10 +153,10 @@
             serviceIds.forEach(serviceId -> {
                 ConvenientServiceCategoryDO convenientServiceCategoryDO = convenientServiceCategoryDAO.selectById(serviceId);
                 convenientServiceCategoryDAO.createMerchantServiceRelation(Snowflake.getId(), merchantId, serviceId,
-                        convenientServiceCategoryDO.getName(), convenientMerchantDTO.getCreatedBy());
+                        convenientServiceCategoryDO.getName(), createBy);
             });
         }
-        BeanUtils.copyProperties(convenientMerchantDTO, convenientMerchantDO);
+
         convenientMerchantDO.setIntroduction(convenientMerchantDTO.getIntroduction());
         this.baseMapper.updateById(convenientMerchantDO);
         return R.ok();
@@ -189,7 +192,7 @@
     @Override
     public R getMerchant(Long merchantId) {
         ConvenientMerchantVO convenientMerchantVO = this.baseMapper.selectMerchantById(merchantId);
-        List<Long> serviceIds = convenientServiceCategoryDAO.selectServiceIdsForMerchant(merchantId);
+        List<String> serviceIds = convenientServiceCategoryDAO.selectServiceIdsForMerchant(merchantId);
         convenientMerchantVO.setServiceIds(serviceIds);
         return R.ok(convenientMerchantVO);
     }
@@ -225,7 +228,7 @@
     @Override
     public R<ConvenientMerchantVO> getUserMerchantInfoByAccount(String account) {
         try {
-            R<LoginUserInfoVO> loginUserInfoVOR = userService.getUserInfo(account + "_10");
+            R<LoginUserInfoVO> loginUserInfoVOR = userService.getUserInfo(account + "_5");
             LoginUserInfoVO loginUserInfoVO =
                     JSONObject.parseObject(JSONObject.toJSONString(loginUserInfoVOR.getData()), LoginUserInfoVO.class);
 
@@ -248,6 +251,20 @@
     }
 
     @Override
+    public R<ConvenientMerchantVO> getMerchantInfoByAccount(String account) {
+        try {
+            List<ConvenientMerchantVO> merchantDetailByAccount = this.baseMapper.getMerchantDetailByAccount(account);
+            if (CollUtil.isEmpty(merchantDetailByAccount)) {
+                return R.fail(500, "该账号不存在");
+            }
+            ConvenientMerchantVO convenientMerchantVO = merchantDetailByAccount.get(0);
+            return R.ok(convenientMerchantVO);
+        } catch (Exception e) {
+            return R.fail();
+        }
+    }
+
+    @Override
     public R<ConvenientMerchantVO> getUserConvenientMerchantInfo(Long userId) {
         ConvenientMerchantDO merchantDO = this.baseMapper.selectOne(new QueryWrapper<ConvenientMerchantDO>()
                 .lambda().eq(ConvenientMerchantDO::getUserId, userId));
@@ -257,7 +274,7 @@
         Long merchantId = merchantDO.getId();
         ConvenientMerchantVO convenientMerchantVO = new ConvenientMerchantVO();
         BeanUtils.copyProperties(merchantDO, convenientMerchantVO);
-        List<Long> serviceIds = convenientServiceCategoryDAO.selectServiceIdsForMerchant(merchantId);
+        List<String> serviceIds = convenientServiceCategoryDAO.selectServiceIdsForMerchant(merchantId);
         convenientMerchantVO.setServiceIds(serviceIds);
         Date nowDate = new Date();
         SimpleDateFormat mothFormat = new SimpleDateFormat("yyyy-MM");
@@ -465,12 +482,31 @@
     @Override
     public R getMerchantByUserId(Long userId) {
         ConvenientMerchantVO convenientMerchantVO = this.baseMapper.selectMerchantByUserId(userId);
-        if (nonNull(convenientMerchantVO)) {
-            List<Long> serviceIds = convenientServiceCategoryDAO.selectServiceIdsForMerchant(convenientMerchantVO.getId());
-            convenientMerchantVO.setServiceIds(serviceIds);
+        if (isNull(convenientMerchantVO)) {
+            return R.fail("商家不存在");
         }
-        BigDecimal score = comShopFlowerEvaluateDAO.statisticsScore(convenientMerchantVO.getId());
+        Long merchantId = convenientMerchantVO.getId();
+        List<String> serviceIds = convenientServiceCategoryDAO.selectServiceIdsForMerchant(merchantId);
+        convenientMerchantVO.setServiceIds(serviceIds);
+        BigDecimal score = comShopFlowerEvaluateDAO.statisticsScore(merchantId);
         convenientMerchantVO.setScore(null == score ? BigDecimal.ZERO : NumberUtil.round(score, 1));
+        Date nowDate = new Date();
+        SimpleDateFormat mothFormat = new SimpleDateFormat("yyyy-MM");
+        SimpleDateFormat dayFormat = new SimpleDateFormat("yyyy-MM-dd");
+        String moth = mothFormat.format(nowDate);
+        String day = dayFormat.format(nowDate);
+        int consultationCount = convenientConsultationStatisticsDAO.selectTotalConsultationVolume(merchantId);
+        int monthConsultationVolume = convenientConsultationStatisticsDAO.selectMonthConsultationVolume(merchantId, moth);
+        int dayConsultationVolume = convenientConsultationStatisticsDAO.selectDayConsultationVolume(merchantId, day);
+        Integer viewCount = convenientViewStatisticsDAO.selectTotalViewNum(merchantId);
+        int monthViewNum = convenientViewStatisticsDAO.selectMonthViewNum(merchantId, moth);
+        int dayViewNum = convenientViewStatisticsDAO.selectDayViewNum(merchantId, day);
+        convenientMerchantVO.setConsultationVolume(consultationCount);
+        convenientMerchantVO.setViewNum(viewCount);
+        convenientMerchantVO.setMonthConsultationVolume(monthConsultationVolume);
+        convenientMerchantVO.setDayConsultationVolume(dayConsultationVolume);
+        convenientMerchantVO.setMonthViewNum(monthViewNum);
+        convenientMerchantVO.setDayViewNum(dayViewNum);
         return R.ok(convenientMerchantVO);
     }
 }

--
Gitblit v1.7.1