| 
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -199,6 +199,7 @@ public class SubscribeServiceImpl implements SubscribeService { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							personalTemplateDTO.setKeyWords(keywords); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							personalTemplateDTO.setType(formDTO.getType()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							personalTemplateService.save(personalTemplateDTO); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							if (formDTO.getIsSync()) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								//获取客户列表
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								List<PaCustomerDTO> customerList = paCustomerService.getCustomerListByTestId(authInfo.getCustomerId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								List<String> customerNames = new ArrayList<>(); | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -238,6 +239,7 @@ public class SubscribeServiceImpl implements SubscribeService { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									String names = String.join(",", customerNames); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									throw new RenException("客户[" + names + "]添加模板失败"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -348,7 +350,6 @@ public class SubscribeServiceImpl implements SubscribeService { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									log.error("居民端同步失败:" + wxResult.getErrorCode() + wxResult.getErrorMsg()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							}); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							resultDTO.setResiList(resiList); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							AuthorizationInfoDTO workAuthDTO = authorizationInfoDao.getAuthInfoByCustomer(formDTO.getCustomerId(), "work"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							if (null == workAuthDTO) { | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -371,10 +372,87 @@ public class SubscribeServiceImpl implements SubscribeService { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									log.error("工作端同步失败:" + wxResult.getErrorCode() + wxResult.getErrorMsg()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							}); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//		resultDTO.setResiList(resiList.stream().filter(item -> formDTO.getSync().equals(item.getState())).collect(Collectors.toList()));
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//		resultDTO.setWorkList(workList.stream().filter(item -> formDTO.getSync().equals(item.getState())).collect(Collectors.toList()));
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							resultDTO.setResiList(resiList); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							resultDTO.setWorkList(workList); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							return resultDTO; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						/** | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						 * 同步单一模板到所有客户 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						 * | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						 * @param formDTO | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						 * @return void | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						 * @author zhaoqifeng | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						 * @date 2021/1/11 14:49 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						 */ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						@Override | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						public void initAll(InitAllFormDTO formDTO) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							AuthorizationInfoDTO authInfo = authorizationInfoDao.selectInfoByAppId(formDTO.getAppId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							PersonalTemplateDTO publicDTO = personalTemplateService.get(formDTO.getTempId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							//获取客户列表
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							List<PaCustomerDTO> customerList = paCustomerService.getCustomerListByTestId(authInfo.getCustomerId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							List<String> customerNames = new ArrayList<>(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							if (null != customerList && customerList.size() > NumConstant.ZERO) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								for (PaCustomerDTO paCustomerDTO : customerList) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									PersonalTemplateDTO personalTemplateDTO = personalTemplateService.getTempByPid(paCustomerDTO.getId(), publicDTO.getPriTmplId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									if (null != personalTemplateDTO) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										//获取小程序调用令牌
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										AuthorizationInfoDTO authDTO = authorizationInfoDao.getAuthInfoByCustomer(paCustomerDTO.getId(), authInfo.getClientType()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										List<String> keyIds = Arrays.asList(publicDTO.getKeyIds().split(",")); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										List<Integer> keyIdList = keyIds.stream().map(Integer::parseInt).collect(Collectors.toList()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										WxAddTemplateReq request = new WxAddTemplateReq(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										request.setTid(publicDTO.getTid()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										request.setKidList(keyIdList); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										request.setSceneDesc(publicDTO.getSceneDesc()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										WxResult<String> wxResult =  wxMaSubscribeService.addTemplate(authInfo.getAuthorizerAccessToken(), request); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										if (null == authDTO) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											log.error("客户[" + paCustomerDTO.getCustomerName() + "]未授权"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											customerNames.add(paCustomerDTO.getCustomerName()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											continue; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										String tmplId = wxResult.getData(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										PersonalTemplateDTO templateDTO = new PersonalTemplateDTO(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										templateDTO.setCustomerId(paCustomerDTO.getId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										templateDTO.setClientType(authInfo.getClientType()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										templateDTO.setAppId(authDTO.getAuthorizerAppid()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										templateDTO.setPid(publicDTO.getPriTmplId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										templateDTO.setPriTmplId(tmplId); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										templateDTO.setTid(publicDTO.getTid()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										templateDTO.setKeyIds(publicDTO.getKeyIds()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										templateDTO.setTitle(publicDTO.getTitle()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										templateDTO.setSceneDesc(publicDTO.getSceneDesc()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										templateDTO.setKeyWords(publicDTO.getKeyWords()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										templateDTO.setType(publicDTO.getType()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										personalTemplateService.save(templateDTO); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							if (customerNames.size() > NumConstant.ZERO) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								String names = String.join(",", customerNames); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								log.error("客户[" + names + "]添加模板失败"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						/** | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						 * 删除客户模板 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						 * | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						 * @param formDTO | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						 * @return void | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						 * @author zhaoqifeng | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						 * @date 2021/1/11 14:54 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						 */ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						@Override | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						public void delPersonalTemp(DelPersonalTempFormDTO formDTO) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						private WxGetCategoryResult getCategoryResult(String accessToken) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							WxResult<WxGetCategoryResult> wxResult =  wxMaSubscribeService.getCategory(accessToken); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
				
				 | 
				
					
  |