Sfoglia il codice sorgente

一件发群逻辑修改

吴树波 1 giorno fa
parent
commit
b6e2e06101

+ 57 - 22
fs-service/src/main/java/com/fs/sop/service/impl/SopUserLogsInfoServiceImpl.java

@@ -482,6 +482,15 @@ public class SopUserLogsInfoServiceImpl implements ISopUserLogsInfoService {
             return R.error().put("msg","企业编号为空,不能创建一键群发");
         }
 
+
+        // 查询公司关联小程序数据
+        List<CompanyMiniapp> miniList = companyMiniappService.list(new QueryWrapper<CompanyMiniapp>().orderByAsc("sort_num"));
+
+        Map<Long, Map<Integer, List<CompanyMiniapp>>> miniMap = miniList.stream().collect(Collectors.groupingBy(CompanyMiniapp::getCompanyId, Collectors.groupingBy(CompanyMiniapp::getType)));
+        QwCompany qwCompany = iQwCompanyService.getQwCompanyByRedis(param.getCorpId());
+        if (qwCompany == null ) {
+            return  R.error().put("msg","企业不存在,请联系管理员");
+        }
         List<QwSopLogs> sopLogsList;
         if(param.getFilterMode() != null && param.getFilterMode() == 2 && param.getChatIds() != null && param.getChatIds().length > 0){
             List<QwGroupChat> groupList = qwGroupChatMapper.selectQwGroupChatByChatIds(param.getChatIds());
@@ -616,11 +625,31 @@ public class SopUserLogsInfoServiceImpl implements ISopUserLogsInfoService {
                                 String linkByMiniApp = createLinkByMiniApp(st, param.getCorpId(), new Date(), param.getCourseId(), param.getVideoId(),
                                         qwUser.getId(), qwUser.getCompanyUserId().toString(), qwUser.getCompanyId().toString(), null, config, qwGroupChat.getChatId());
 
-                                if (StringUtil.strIsNullOrEmpty(config.getMiniprogramAppid())) {
-                                    log.error("配置中无小程序id,采用默认的");
-                                    st.setMiniprogramAppid("wxc84c6f789ba7f176");
+                                String miniAppId = null;
+
+                                int listIndex = 1;
+                                if (!miniMap.isEmpty() && qwUser.getSendMsgType() == 1) {
+                                    Map<Integer, List<CompanyMiniapp>> integerListMap = miniMap.get(qwUser.getCompanyId());
+                                    if (integerListMap != null) {
+                                        List<CompanyMiniapp> miniapps = integerListMap.get(listIndex);
+
+                                        if (miniapps != null && !miniapps.isEmpty()) {
+                                            CompanyMiniapp companyMiniapp = miniapps.get(0);
+                                            if (companyMiniapp != null && !StringUtil.strIsNullOrEmpty(companyMiniapp.getAppId())) {
+                                                miniAppId = companyMiniapp.getAppId();
+                                            }
+                                        }
+                                    }
+                                }
+
+                                if (StringUtil.strIsNullOrEmpty(miniAppId) && !StringUtil.strIsNullOrEmpty(qwCompany.getMiniAppId())) {
+                                    miniAppId = qwCompany.getMiniAppId();
+                                }
+                                st.setMiniType(listIndex);
+                                if (!StringUtil.strIsNullOrEmpty(miniAppId)) {
+                                    st.setMiniprogramAppid(miniAppId);
                                 } else {
-                                    st.setMiniprogramAppid(config.getMiniprogramAppid());
+                                    log.error("公司的小程序id为空:采用了前端传的固定值" + sopLogs.getSopId());
                                 }
 
                                 st.setMiniprogramPage(linkByMiniApp);
@@ -724,11 +753,31 @@ public class SopUserLogsInfoServiceImpl implements ISopUserLogsInfoService {
                                 String linkByMiniApp = createLinkByMiniApp(st, param.getCorpId(), new Date(), param.getCourseId(), param.getVideoId(),
                                         qwUser.getId(), qwUser.getCompanyUserId().toString(), qwUser.getCompanyId().toString(), null, config, groupChat.getChatId());
 
-                                if (StringUtil.strIsNullOrEmpty(config.getMiniprogramAppid())) {
-                                    log.error("配置中无小程序id,采用默认的");
-                                    st.setMiniprogramAppid("wxc84c6f789ba7f176");
+                                String miniAppId = null;
+
+                                int listIndex = 1;
+                                if (!miniMap.isEmpty() && qwUser.getSendMsgType() == 1) {
+                                    Map<Integer, List<CompanyMiniapp>> integerListMap = miniMap.get(qwUser.getCompanyId());
+                                    if (integerListMap != null) {
+                                        List<CompanyMiniapp> miniapps = integerListMap.get(listIndex);
+
+                                        if (miniapps != null && !miniapps.isEmpty()) {
+                                            CompanyMiniapp companyMiniapp = miniapps.get(0);
+                                            if (companyMiniapp != null && !StringUtil.strIsNullOrEmpty(companyMiniapp.getAppId())) {
+                                                miniAppId = companyMiniapp.getAppId();
+                                            }
+                                        }
+                                    }
+                                }
+
+                                if (StringUtil.strIsNullOrEmpty(miniAppId) && !StringUtil.strIsNullOrEmpty(qwCompany.getMiniAppId())) {
+                                    miniAppId = qwCompany.getMiniAppId();
+                                }
+                                st.setMiniType(listIndex);
+                                if (!StringUtil.strIsNullOrEmpty(miniAppId)) {
+                                    st.setMiniprogramAppid(miniAppId);
                                 } else {
-                                    st.setMiniprogramAppid(config.getMiniprogramAppid());
+                                    log.error("公司的小程序id为空:采用了前端传的固定值" + sopLogs.getSopId());
                                 }
 
                                 st.setMiniprogramPage(linkByMiniApp);
@@ -751,14 +800,6 @@ public class SopUserLogsInfoServiceImpl implements ISopUserLogsInfoService {
                 }).collect(Collectors.toList());
             }
         }else{
-
-
-            // 查询公司关联小程序数据
-            List<CompanyMiniapp> miniList = companyMiniappService.list(new QueryWrapper<CompanyMiniapp>().orderByAsc("sort_num"));
-
-            Map<Long, Map<Integer, List<CompanyMiniapp>>> miniMap = miniList.stream().collect(Collectors.groupingBy(CompanyMiniapp::getCompanyId, Collectors.groupingBy(CompanyMiniapp::getType)));
-
-
             sopLogsList = new ArrayList<>();
             SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
             List<SopUserLogsInfo> sopUserLogsInfos = sopUserLogsInfoMapper.selectSopUserLogsInfoByIds(param.getIds());
@@ -791,12 +832,6 @@ public class SopUserLogsInfoServiceImpl implements ISopUserLogsInfoService {
 //                domainName = config.getRealLinkDomainName();
 //            }
 
-            QwCompany qwCompany = iQwCompanyService.getQwCompanyByRedis(param.getCorpId());
-
-            if (qwCompany == null ) {
-                return  R.error().put("msg","企业不存在,请联系管理员");
-            }
-
 
             String finalDomainName = "domainName";