From 1c20c8231980a8d4b91688ff8641a06d3b2f68ab Mon Sep 17 00:00:00 2001
From: MrShi <1878285526@qq.com>
Date: 星期二, 14 十月 2025 16:34:22 +0800
Subject: [PATCH] 改bug

---
 server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/ApproveServiceImpl.java |  112 ++++++++++++++++++++++++++++++-------------------------
 1 files changed, 61 insertions(+), 51 deletions(-)

diff --git a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/ApproveServiceImpl.java b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/ApproveServiceImpl.java
index cbdaa5b..b352a5e 100644
--- a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/ApproveServiceImpl.java
+++ b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/ApproveServiceImpl.java
@@ -9,8 +9,8 @@
 import com.doumee.core.haikang.model.param.request.ParkReservationAddRequest;
 import com.doumee.core.haikang.model.param.respose.ParkReservationAddResponse;
 import com.doumee.core.haikang.service.HKService;
-import com.doumee.core.model.PageData;
-import com.doumee.core.model.PageWrap;
+import com.doumee.service.business.third.model.PageData;
+import com.doumee.service.business.third.model.PageWrap;
 import com.doumee.core.utils.Constants;
 import com.doumee.core.utils.DateUtil;
 import com.doumee.core.utils.SmsConstants;
@@ -19,6 +19,7 @@
 import com.doumee.core.wx.wxPlat.WxPlatNotice;
 import com.doumee.dao.business.*;
 import com.doumee.dao.business.dao.CompanyMapper;
+import com.doumee.dao.business.dao.MemberMapper;
 import com.doumee.dao.business.dao.SmsConfigMapper;
 import com.doumee.dao.business.dao.SmsEmailMapper;
 import com.doumee.dao.business.dto.ApproveDTO;
@@ -27,6 +28,7 @@
 import com.doumee.dao.business.join.VisitsJoinMapper;
 import com.doumee.dao.business.model.*;
 import com.doumee.dao.business.vo.ApproveDataVO;
+import com.doumee.dao.business.model.Member;
 import com.doumee.dao.system.SystemUserMapper;
 import com.doumee.dao.system.dto.NoticesDTO;
 import com.doumee.dao.system.join.NoticesJoinMapper;
@@ -284,6 +286,7 @@
                                 Constants.equalsInteger(i.getUserId(),memberId)
                                 &&Constants.equalsInteger(i.getStatus(),Constants.ZERO)
                                 &&Constants.equalsInteger(i.getSendacopy(),Constants.ZERO)
+                                        &&StringUtils.equals(i.getParam2(),"0")
                         ).count()
                 );
                 //宸插鐞嗘暟鎹�
@@ -300,7 +303,7 @@
                         noticesJoinMapper.selectCount(new QueryWrapper<Notices>().lambda().eq(Notices::getParam3,memberId))
                 );
                 //鎶勯�佹垜鐨勬暟鎹�
-                 internalHomeVO.setNoticeCopyNum(
+                internalHomeVO.setNoticeCopyNum(
                         noticesList.stream().filter(i->Constants.equalsInteger(i.getUserId(),memberId)
                                 &&Constants.equalsInteger(i.getSendacopy(),Constants.ONE)
                                 &&Constants.equalsInteger(i.getReaded(),Constants.ZERO)
@@ -333,6 +336,7 @@
                     noticesList.stream().filter(i->Constants.equalsInteger(i.getUserId(),noticesDTO.getMemberId())
                             &&Constants.equalsInteger(i.getStatus(),Constants.ZERO)
                             &&Constants.equalsInteger(i.getSendacopy(),Constants.ZERO)
+                            &&StringUtils.equals(i.getParam2(),"0")
                     ).count()
             );
             internalHomeVO.setNoticeDealNum(
@@ -362,10 +366,11 @@
      * @param tempType 妯℃澘绫诲瀷  0闈炴柦宸ヤ汉鍛樿瀹㈢敵璇� 1鏂藉伐浜哄憳璁垮鐢宠 2璁垮鎶ュ 3鍏溅甯傚唴鐢ㄨ溅 4鍏溅瀹ゅ鐢ㄨ溅 5甯傚叕鍙哥墿娴佽溅棰勭害
      * @param businessId 涓氬姟涓婚敭 鏍规嵁 tempType
      * @param createMemberId 鎻愪氦娴佺▼浜哄憳
+     * @param applyMember 鐢宠浜哄璞★紙濡傛灉涓虹┖锛岄粯璁や负鎻愪氦浜猴級
      */
     @Override
     @Transactional(rollbackFor = {Exception.class,BusinessException.class})
-    public void createApproveFlow(Integer tempType,Integer businessId,Integer createMemberId){
+    public void createApproveFlow(Integer tempType,Integer businessId,Integer createMemberId,Member applyMember){
         //鏌ヨ澶勭悊妯℃澘
         ApproveTempl approveTempl = approveTemplMapper.selectOne(new QueryWrapper<ApproveTempl>().lambda()
                 .eq(ApproveTempl::getType,tempType)
@@ -392,18 +397,15 @@
         }
         List<ApproveParam> approveCopyList = approveParamAllList.stream().filter(i->i.getType().equals(Constants.ONE)).collect(Collectors.toList());
 
-        Member createMember = memberMapper.selectById(createMemberId);
+        Member createMember =    memberMapper.selectById(createMemberId);
         if(Objects.isNull(createMember)|| Objects.isNull(createMember.getCompanyId())){
             throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"鐢宠浜虹粍缁囦俊鎭紓甯�");
         }
         List<Approve> approveList = new ArrayList<>();
-
-        this.organizeApproveData(approveTempl,approveParamList,createMember,businessId,approveList);
-
+        this.organizeApproveData(approveTempl,approveParamList,createMember,applyMember,businessId,approveList);
         if(CollectionUtils.isEmpty(approveList)){
             throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"瀹℃壒娴侀厤缃敊璇�");
         }
-
         //澶勭悊鎶勯�佹暟鎹�
         if(CollectionUtils.isNotEmpty(approveCopyList)){
             this.organizeApproveCopyData(approveTempl,approveCopyList,businessId,approveList);
@@ -415,7 +417,7 @@
 
     @Override
     @Transactional(rollbackFor = {Exception.class,BusinessException.class})
-    public void createApproveForPlatfrom(Integer tempId,Integer businessId,Integer createMemberId){
+    public void createApproveForPlatfrom(Integer tempId,Integer businessId,Integer createMemberId ){
         //鏌ヨ澶勭悊妯℃澘
         ApproveTempl approveTempl = approveTemplMapper.selectById(tempId);
         if(Objects.isNull(approveTempl)){
@@ -444,7 +446,7 @@
         }
         List<Approve> approveList = new ArrayList<>();
 
-        this.organizeApproveData(approveTempl,approveParamList,createMember,businessId,approveList);
+        this.organizeApproveData(approveTempl,approveParamList,createMember,null,businessId,approveList);
 
         if(CollectionUtils.isEmpty(approveList)){
             throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"瀹℃壒娴侀厤缃敊璇�");
@@ -466,15 +468,18 @@
      * @param businessId
      * @param approveList
      */
-    public void organizeApproveData(ApproveTempl approveTempl,List<ApproveParam> approveParamList,Member createMember,Integer businessId,List<Approve> approveList){
+    public void organizeApproveData(ApproveTempl approveTempl,List<ApproveParam> approveParamList,Member createMember,Member applyMember,Integer businessId,List<Approve> approveList){
 
+        if(applyMember ==null){
+            applyMember = createMember;
+        }
         //鍒涘缓榛樿浜轰俊鎭�
         Approve createUserApprove = new Approve();
         createUserApprove.setRemark("鍙戣捣鐢宠");
         createUserApprove.setCreateDate(new Date());
         createUserApprove.setIsdeleted(Constants.ZERO);
         createUserApprove.setTemplatId(approveTempl.getId());
-        createUserApprove.setChekorId(createMember.getId());
+        createUserApprove.setChekorId(applyMember.getId());
         createUserApprove.setCheckDate(createUserApprove.getCreateDate());
         createUserApprove.setStatus(Constants.approveStatus.pass);
         createUserApprove.setTitle("鍙戣捣鐢宠");
@@ -490,7 +495,7 @@
         approveList.add(createUserApprove);
 
         //鏌ヨ鎵�鏈夊緟澶勭悊浜�
-        String token = systemDictDataBiz.queryByCode(Constants.WX_PLATFORM,Constants.WX_PLATFORM_ACCESS_TOKEN).getCode();
+//        String token = systemDictDataBiz.queryByCode(Constants.WX_PLATFORM,Constants.WX_PLATFORM_ACCESS_TOKEN).getCode();
         //瀹℃壒涓氬姟鏁版嵁
         for (int i = 0; i < approveParamList.size(); i++) {
             ApproveParam approveParam = approveParamList.get(i);
@@ -516,22 +521,25 @@
                         title = this.createNoticesData(noticeType,businessId,title,jsonMap);
                     }
                     if(j==0){
-                        //榛樿鐢熸垚涓�鏉� 鐢宠浜虹殑鏁版嵁 鏍囪鍒犻櫎鐘舵�佺敤浜庡鐞嗗埌 浠诲姟涓績锛堟垜鍙戣捣锛変娇鐢�
-                        Notices notices = new Notices();
-                        notices.setCreateDate(new Date());
-                        notices.setIsdeleted(Constants.ONE);
-                        notices.setObjId(businessId);
-                        notices.setObjType(noticeType);
-                        notices.setType(noticeType);
-                        notices.setTitle(title);
-                        notices.setParam1(JSONObject.toJSONString(jsonMap));
-                        notices.setStatus(Constants.ZERO);
-                        notices.setReaded(Constants.ZERO);
-                        notices.setSendacopy(Constants.ZERO);
-                        notices.setParam2("0");
-                        notices.setParam3(createMember.getId().toString());
-                        notices.setInfo("澶勭悊涓�");
-                        noticesJoinMapper.insert(notices);
+                        //璁垮浜哄憳涓嶇敓鎴愭璁板綍
+                       if(!(Constants.equalsInteger(noticeType,Constants.noticesObjectType.visit)&&Constants.equalsInteger(applyMember.getType(),Constants.ONE))){
+                            //榛樿鐢熸垚涓�鏉� 鐢宠浜虹殑鏁版嵁 鏍囪鍒犻櫎鐘舵�佺敤浜庡鐞嗗埌 浠诲姟涓績锛堟垜鍙戣捣锛変娇鐢�
+                            Notices notices = new Notices();
+                            notices.setCreateDate(new Date());
+                            notices.setIsdeleted(Constants.ONE);
+                            notices.setObjId(businessId);
+                            notices.setObjType(noticeType);
+                            notices.setType(noticeType);
+                            notices.setTitle(title);
+                            notices.setParam1(JSONObject.toJSONString(jsonMap));
+                            notices.setStatus(Constants.ZERO);
+                            notices.setReaded(Constants.ZERO);
+                            notices.setSendacopy(Constants.ZERO);
+                            notices.setParam2("0");
+                            notices.setParam3(createMember.getId().toString());
+                            notices.setInfo("澶勭悊涓�");
+                            noticesJoinMapper.insert(notices);
+                        }
                     }
                     if(CollectionUtils.isEmpty(memberList)){
                         throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鏈煡璇㈠埌瀹℃壒浜轰俊鎭�");
@@ -594,8 +602,7 @@
                             wxPlatNotice.sendPlatformBookTemplateNotice(systemDictDataBiz,
                                     wxNoticeConfigMapper,
                                     platformBooksMapper.selectById(businessId),
-                                    WxPlatConstants.platformBookContent.platformBookWaitAudit,
-                                    token,
+                                    WxPlatConstants.platformBookContent.platformBookWaitAudit, 
                                     Arrays.asList(member.getSystemOpenid().split(",")),
                                     Constants.ONE);
                         }
@@ -611,7 +618,6 @@
                         if(StringUtils.isNotBlank(member.getSystemOpenid())){
                             wxPlatNotice.sendVisitTemplateNotice(systemDictDataBiz,
                                     wxNoticeConfigMapper,visitsMapper.selectById(businessId), WxPlatConstants.visitContent.visitWaitAudit,
-                                    token,
                                     Arrays.asList(member.getSystemOpenid().split(","))
                             );
                         }
@@ -626,7 +632,6 @@
                         if(StringUtils.isNotBlank(member.getSystemOpenid())){
                             wxPlatNotice.sendVisitTemplateNotice(systemDictDataBiz,
                                     wxNoticeConfigMapper,visitsMapper.selectById(businessId), WxPlatConstants.visitReportContent.visitReportWaitAudit,
-                                    token,
                                     Arrays.asList(member.getSystemOpenid().split(","))
                             );
                         }
@@ -648,7 +653,6 @@
                                             wxNoticeConfigMapper,
                                             carUseBookMapper.selectById(businessId),
                                             WxPlatConstants.carUseBookContent.carUseBookWaitAudit,
-                                            token,
                                             Arrays.asList(member.getSystemOpenid().split(",")),
                                             Constants.ONE);
                                 }
@@ -717,13 +721,23 @@
             if(Objects.isNull(platformBooks)){
                 throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鏈煡璇㈠埌涓氬姟鏁版嵁淇℃伅");
             }
-            title = "[鐗╂祦杞﹀叆鍥绾鐢宠浜�-" + platformBooks.getDriverName();
-            jsonMap.put("inType", "鍏ュ簱绫诲瀷锛�"+(Constants.equalsInteger(platformBooks.getInType(),Constants.ZERO)?"鏁存墭鐩�":"浠剁儫"));
-            jsonMap.put("totalNum", "鎬昏繍杈撻噺锛�"+platformBooks.getTotalNum()+"涓囨敮");
-            jsonMap.put("arriveDate", "鍒板満鏃堕棿锛�" + DateUtil.DateToStr(platformBooks.getArriveDate() , "yyyy-MM-dd HH:mm"));
-            jsonMap.put("carNum", "杞︾墝鐓э細"+platformBooks.getCarCodeFront());
+            title = ApproveServiceImpl.creatPlatformBookNotice(platformBooks,jsonMap);
+//            title = "[鐗╂祦杞﹀叆鍥绾鐢宠浜�-" + platformBooks.getDriverName();
+//            jsonMap.put("inType", "鍏ュ簱绫诲瀷锛�"+(Constants.equalsInteger(platformBooks.getInType(),Constants.ZERO)?"鏁存墭鐩�":"浠剁儫"));
+//            jsonMap.put("totalNum", "鎬昏繍杈撻噺锛�"+platformBooks.getTotalNum()+"涓囨敮");
+//            jsonMap.put("arriveDate", "鍒板満鏃堕棿锛�" + DateUtil.DateToStr(platformBooks.getArriveDate() , "yyyy-MM-dd HH:mm"));
+//            jsonMap.put("carNum", "杞︾墝鐓э細"+platformBooks.getCarCodeFront());
         }
         return title;
+    }
+
+    public static String creatPlatformBookNotice(PlatformBooks platformBooks,Map<String,Object> jsonMap){
+        jsonMap.put("inType", "浣滀笟绫诲瀷锛�"+(Constants.equalsInteger(platformBooks.getInType(),Constants.ZERO)?"鏁存墭鐩�":"浠剁儫"));
+        jsonMap.put("totalNum", "鎬昏繍杈撻噺锛�"+platformBooks.getTotalNum()+"涓囨敮");
+        jsonMap.put("arriveDate", "鍒板満鏃堕棿锛�" + DateUtil.DateToStr(platformBooks.getArriveDate() , "yyyy-MM-dd HH:mm"));
+        jsonMap.put("carNum", "杞︾墝鐓э細"+platformBooks.getCarCodeFront());
+        return  "[鐗╂祦杞﹀叆鍥绾鐢宠浜�-" + platformBooks.getDriverName() ;
+
     }
 
 
@@ -1204,8 +1218,10 @@
                 || Objects.isNull(approveDTO.getLoginUserInfo())){
             throw new BusinessException(ResponseStatus.BAD_REQUEST);
         }
-        if(approveDTO.getStatus().equals(Constants.THREE)&&StringUtils.isBlank(approveDTO.getCheckInfo())){
-            throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"璇疯緭鍏ユ嫆缁濊鏄�");
+        if(!(Constants.equalsInteger(approveDTO.getObjType(),Constants.THREE)||Constants.equalsInteger(approveDTO.getObjType(),Constants.FOUR))){
+            if(approveDTO.getStatus().equals(Constants.THREE)&&StringUtils.isBlank(approveDTO.getCheckInfo())){
+                throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"璇疯緭鍏ユ嫆缁濊鏄�");
+            }
         }
         Approve approve = approveMapper.selectOne(new QueryWrapper<Approve>()
                 .lambda()
@@ -1302,7 +1318,7 @@
                         .set(Notices::getInfo,"宸叉嫆缁�")
                         .eq(Notices::getObjId,notices.getObjId())
                         .eq(Notices::getObjType,notices.getObjType())
-                        .eq(Notices::getReaded,Constants.ZERO)
+//                        .eq(Notices::getReaded,Constants.ZERO)
                         .ne(Notices::getId,notices.getId())
                 );
             }
@@ -1438,7 +1454,6 @@
                         wxNoticeConfigMapper,
                         platformBooksMapper.selectById(approveDTO.getObjId()),
                         WxPlatConstants.platformBookContent.platformBookWaitAudit,
-                        systemDictDataBiz.queryByCode(Constants.WX_PLATFORM,Constants.WX_PLATFORM_ACCESS_TOKEN).getCode(),
                         openIdList,
                         Constants.ONE);
             }
@@ -1462,8 +1477,7 @@
                         //鍙戦�佸井淇″叕浼楀彿閫氱煡
                         wxPlatNotice.sendCarUseBookTemplateNotice(systemDictDataBiz,
                                 wxNoticeConfigMapper,carUseBook,
-                                WxPlatConstants.carUseBookContent.carUseBookWaitAudit,
-                                systemDictDataBiz.queryByCode(Constants.WX_PLATFORM,Constants.WX_PLATFORM_ACCESS_TOKEN).getCode(),
+                                WxPlatConstants.carUseBookContent.carUseBookWaitAudit, 
                                 openIdList,1);
                     }
                 }
@@ -1489,7 +1503,6 @@
                         wxPlatNotice.sendVisitTemplateNotice(systemDictDataBiz,
                                 wxNoticeConfigMapper,visitsMapper.selectById(approveDTO.getObjId()),
                                 approveDTO.getObjType().equals(Constants.approveObjectType.visitReporting)?WxPlatConstants.visitReportContent.visitReportWaitAudit:WxPlatConstants.visitContent.visitWaitAudit,
-                                systemDictDataBiz.queryByCode(Constants.WX_PLATFORM,Constants.WX_PLATFORM_ACCESS_TOKEN).getCode(),
                                 openIdList
                         );
                     }
@@ -1746,7 +1759,6 @@
                 if(Objects.nonNull(visits) && StringUtils.isNotBlank(visits.getOpenid())){
                     wxPlatNotice.sendVisitTemplateNotice(systemDictDataBiz,
                             wxNoticeConfigMapper,visits, objCode,
-                            systemDictDataBiz.queryByCode(Constants.WX_PLATFORM,Constants.WX_PLATFORM_ACCESS_TOKEN).getCode(),
                             Arrays.asList(visits.getOpenid().split(","))
                     );
                 }
@@ -1773,7 +1785,6 @@
                     wxPlatNotice.sendCarUseBookTemplateNotice(systemDictDataBiz,
                             wxNoticeConfigMapper,carUseBook,
                             Constants.equalsInteger(approveDTO.getStatus(),Constants.TWO)?WxPlatConstants.carUseBookContent.carUseBookAuditSuccess: WxPlatConstants.carUseBookContent.carUseBookAuditFail,
-                            systemDictDataBiz.queryByCode(Constants.WX_PLATFORM,Constants.WX_PLATFORM_ACCESS_TOKEN).getCode(),
                             Arrays.asList(systemUser.getOpenid().split(",")),0);
                 }
             }
@@ -1842,9 +1853,8 @@
             if(Objects.nonNull(driver) && StringUtils.isNotBlank(driver.getOpenid())){
                 //鍙戦�佸井淇″叕浼楀彿閫氱煡
                 wxPlatNotice.sendPlatformBookTemplateNotice(systemDictDataBiz,
-                        wxNoticeConfigMapper,platformBooks,
+                        wxNoticeConfigMapper, platformBooks,
                         Constants.equalsInteger(approveDTO.getStatus(),Constants.TWO)?WxPlatConstants.platformBookContent.platformBookAuditSuccess: WxPlatConstants.platformBookContent.platformBookAuditFail,
-                        systemDictDataBiz.queryByCode(Constants.WX_PLATFORM,Constants.WX_PLATFORM_ACCESS_TOKEN).getCode(),
                         Arrays.asList(driver.getOpenid().split(",")),0);
             }
 

--
Gitblit v1.9.3