|  |  | @ -7,8 +7,10 @@ import com.epmet.commons.tools.exception.RenException; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.page.PageData; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.utils.ConvertUtils; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.utils.DateUtils; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.utils.HttpClientManager; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.utils.Result; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.constant.CodeConstant; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.constant.ModuleConstant; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dao.AuthorizationInfoDao; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dao.ComponentAccessTokenDao; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dao.MiniInfoDao; | 
			
		
	
	
		
			
				
					|  |  | @ -17,7 +19,9 @@ import com.epmet.dto.form.*; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.result.*; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.feign.OperCrmOpenFeignClient; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.feign.OssFeignClient; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.redis.RedisThird; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.service.*; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.wxapi.constant.WxMaCodeConstant; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.wxapi.param.*; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.wxapi.result.*; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.wxapi.service.WxMaCodeService; | 
			
		
	
	
		
			
				
					|  |  | @ -27,6 +31,7 @@ import lombok.extern.slf4j.Slf4j; | 
			
		
	
		
			
				
					|  |  |  | import org.apache.commons.io.FileUtils; | 
			
		
	
		
			
				
					|  |  |  | import org.apache.commons.lang3.StringUtils; | 
			
		
	
		
			
				
					|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
			
		
	
		
			
				
					|  |  |  | import org.springframework.beans.factory.annotation.Value; | 
			
		
	
		
			
				
					|  |  |  | import org.springframework.mock.web.MockMultipartFile; | 
			
		
	
		
			
				
					|  |  |  | import org.springframework.stereotype.Service; | 
			
		
	
		
			
				
					|  |  |  | import org.springframework.transaction.annotation.Transactional; | 
			
		
	
	
		
			
				
					|  |  | @ -71,6 +76,11 @@ public class CodeServiceImpl implements CodeService { | 
			
		
	
		
			
				
					|  |  |  | 	private MiniInfoDao miniInfoDao; | 
			
		
	
		
			
				
					|  |  |  | 	@Autowired | 
			
		
	
		
			
				
					|  |  |  | 	private OperCrmOpenFeignClient operCrmOpenFeignClient; | 
			
		
	
		
			
				
					|  |  |  | 	@Autowired | 
			
		
	
		
			
				
					|  |  |  | 	private RedisThird redisThird; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 	@Value("${third.platform.appId}") | 
			
		
	
		
			
				
					|  |  |  | 	private String componentAppId; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 	@Override | 
			
		
	
		
			
				
					|  |  |  | 	public List<TemplateListResultDTO> templateList() { | 
			
		
	
	
		
			
				
					|  |  | @ -117,29 +127,42 @@ public class CodeServiceImpl implements CodeService { | 
			
		
	
		
			
				
					|  |  |  | 		if (null == authInfo) { | 
			
		
	
		
			
				
					|  |  |  | 			throw new RenException("未授权"); | 
			
		
	
		
			
				
					|  |  |  | 		} | 
			
		
	
		
			
				
					|  |  |  | 		/*CustomerDTO customerFormDTO = new CustomerDTO(); | 
			
		
	
		
			
				
					|  |  |  | 		customerFormDTO.setId(formDTO.getCustomerId()); | 
			
		
	
		
			
				
					|  |  |  | 		Result<CustomerDTO> result = operCrmOpenFeignClient.getCustomerInfo(customerFormDTO); | 
			
		
	
		
			
				
					|  |  |  | 		if (!result.success()) { | 
			
		
	
		
			
				
					|  |  |  | 			throw new RenException(result.getCode(), result.getMsg()); | 
			
		
	
		
			
				
					|  |  |  | 		}*/ | 
			
		
	
		
			
				
					|  |  |  | 		String customerName = ""; | 
			
		
	
		
			
				
					|  |  |  | 		Result<List<CustomerDTO>> customerList =  operCrmOpenFeignClient.getAllCustomerList(); | 
			
		
	
		
			
				
					|  |  |  | 		if (customerList.success()) { | 
			
		
	
		
			
				
					|  |  |  | 			for (CustomerDTO dto : customerList.getData()) { | 
			
		
	
		
			
				
					|  |  |  | 				if(formDTO.getCustomerId().equals(dto.getId())) { | 
			
		
	
		
			
				
					|  |  |  | 					customerName = dto.getCustomerName(); | 
			
		
	
		
			
				
					|  |  |  | 				} | 
			
		
	
		
			
				
					|  |  |  | 			} | 
			
		
	
		
			
				
					|  |  |  | 		} | 
			
		
	
		
			
				
					|  |  |  | 		String resiName = ""; | 
			
		
	
		
			
				
					|  |  |  | 		String workName = ""; | 
			
		
	
		
			
				
					|  |  |  | 		if(CodeConstant.RESI.equals(formDTO.getClientType())) { | 
			
		
	
		
			
				
					|  |  |  | 			resiName = getNickName(authInfo.getAuthorizerAppid()); | 
			
		
	
		
			
				
					|  |  |  | 			AuthorizationInfoDTO workAuthInfo = authorizationInfoDao.getAuthInfoByCustomer(formDTO.getCustomerId(), CodeConstant.WORK); | 
			
		
	
		
			
				
					|  |  |  | 			workName = getNickName(workAuthInfo.getAuthorizerAppid()); | 
			
		
	
		
			
				
					|  |  |  | 		} else { | 
			
		
	
		
			
				
					|  |  |  | 			workName = getNickName(authInfo.getAuthorizerAppid()); | 
			
		
	
		
			
				
					|  |  |  | 			AuthorizationInfoDTO resiAuthInfo = authorizationInfoDao.getAuthInfoByCustomer(formDTO.getCustomerId(), CodeConstant.RESI); | 
			
		
	
		
			
				
					|  |  |  | 			resiName = getNickName(resiAuthInfo.getAuthorizerAppid()); | 
			
		
	
		
			
				
					|  |  |  | 		} | 
			
		
	
		
			
				
					|  |  |  | 		//获取小程序居民端与工作端名称
 | 
			
		
	
		
			
				
					|  |  |  | 		String resiName = miniInfoDao.getNickName(formDTO.getCustomerId(), CodeConstant.RESI); | 
			
		
	
		
			
				
					|  |  |  | 		String workName = miniInfoDao.getNickName(formDTO.getCustomerId(), CodeConstant.WORK); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 		String extJson = getExtJson(formDTO); | 
			
		
	
		
			
				
					|  |  |  | 		WxExtJson wxExtJson = JSONObject.parseObject(extJson, WxExtJson.class); | 
			
		
	
		
			
				
					|  |  |  | 		wxExtJson.setExtAppid(authInfo.getAuthorizerAppid()); | 
			
		
	
		
			
				
					|  |  |  | 		wxExtJson.getExt().setExtAppid(authInfo.getAuthorizerAppid()); | 
			
		
	
		
			
				
					|  |  |  | 		wxExtJson.getExt().setResiName(resiName); | 
			
		
	
		
			
				
					|  |  |  | 		wxExtJson.getExt().setWorkName(workName); | 
			
		
	
		
			
				
					|  |  |  | 		//wxExtJson.getExt().setCustomerName(null == result.getData().getCustomerName()?"":result.getData().getCustomerName());
 | 
			
		
	
		
			
				
					|  |  |  | 		wxExtJson.getExt().setCustomerName(""); | 
			
		
	
		
			
				
					|  |  |  | 		wxExtJson.getExt().setCustomerName(customerName); | 
			
		
	
		
			
				
					|  |  |  | 		if (CodeConstant.RESI.equals(formDTO.getClientType())) { | 
			
		
	
		
			
				
					|  |  |  | 			wxExtJson.getWindow().setNavigationBarTitleText(resiName); | 
			
		
	
		
			
				
					|  |  |  | 		} else { | 
			
		
	
		
			
				
					|  |  |  | 			wxExtJson.getWindow().setNavigationBarTitleText(workName); | 
			
		
	
		
			
				
					|  |  |  | 		} | 
			
		
	
		
			
				
					|  |  |  | 		extJson = JSON.toJSONString(wxExtJson); | 
			
		
	
		
			
				
					|  |  |  | 		log.info(extJson); | 
			
		
	
		
			
				
					|  |  |  | 		CodeExtDTO codeExtDTO = codeExtService.getExtByCustomer(formDTO.getCustomerId(), formDTO.getClientType()); | 
			
		
	
		
			
				
					|  |  |  | 		if (null == codeExtDTO) { | 
			
		
	
		
			
				
					|  |  |  | 			codeExtDTO = new CodeExtDTO(); | 
			
		
	
	
		
			
				
					|  |  | @ -729,4 +752,15 @@ public class CodeServiceImpl implements CodeService { | 
			
		
	
		
			
				
					|  |  |  | 		codeOperationHistoryService.save(operationDTO); | 
			
		
	
		
			
				
					|  |  |  | 	} | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 	private String getNickName(String appId) { | 
			
		
	
		
			
				
					|  |  |  | 		JSONObject jsonObject = new JSONObject(); | 
			
		
	
		
			
				
					|  |  |  | 		jsonObject.put(ModuleConstant.COMPONENT_APP_ID,componentAppId); | 
			
		
	
		
			
				
					|  |  |  | 		jsonObject.put(ModuleConstant.AUTHORIZER_APP_ID,appId); | 
			
		
	
		
			
				
					|  |  |  | 		String componentAccessToken = componentAccessTokenDao.getComponentAccessToken(); | 
			
		
	
		
			
				
					|  |  |  | 		String data = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_GET_AUTHORIZER_INFO + componentAccessToken , JSON.toJSONString(jsonObject)).getData(); | 
			
		
	
		
			
				
					|  |  |  | 		Map map = JSON.parseObject(data, Map.class); | 
			
		
	
		
			
				
					|  |  |  | 		Map authInfo = (Map) map.get(ModuleConstant.AUTHORIZER_INFO); | 
			
		
	
		
			
				
					|  |  |  | 		return ConvertUtils.mapToEntity(authInfo, MiniInfoFormDTO.class).getNick_name(); | 
			
		
	
		
			
				
					|  |  |  | 	} | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | } | 
			
		
	
	
		
			
				
					|  |  | 
 |