Browse Source

Merge branch 'dev_thirdplatform' of http://git.elinkit.com.cn:7070/r/epmet-cloud into dev_thirdplatform

master
sunyuchao 5 years ago
parent
commit
278fe90221
  1. 3
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/ModuleConstant.java
  2. 2
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/ThirdRunTimeInfoConstant.java
  3. 36
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/WarrantServiceImpl.java

3
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/ModuleConstant.java

@ -91,6 +91,9 @@ public interface ModuleConstant {
String FROM_CALLBACK = "from_callback"; String FROM_CALLBACK = "from_callback";
String APPLICATION_JSON = "application/json"; String APPLICATION_JSON = "application/json";
String _FROM_API = "_from_api"; String _FROM_API = "_from_api";
String WE_APP_AUDIT = "we_app_audit";
String TO_USER_NAME = "ToUserName";
String FROM_USER_NAME = "FromUserName";
/** /**
* 微信模推送给第三方平台方 Content固定格式 * 微信模推送给第三方平台方 Content固定格式

2
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/ThirdRunTimeInfoConstant.java

@ -109,4 +109,6 @@ public interface ThirdRunTimeInfoConstant {
String SEND_MESSAGE_XML = "要发送的xml内容为:%s"; String SEND_MESSAGE_XML = "要发送的xml内容为:%s";
String CONTENT = "content为:%s"; String CONTENT = "content为:%s";
String MSG_TYPE = "消息类型为:%s";
} }

36
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/WarrantServiceImpl.java

@ -106,12 +106,24 @@ public class WarrantServiceImpl implements WarrantService {
// 将xml转为map // 将xml转为map
Map<String, Object> result = WXXmlToMapUtil.multilayerXmlToMap(msg); Map<String, Object> result = WXXmlToMapUtil.multilayerXmlToMap(msg);
Map<String,Object> xml = (Map<String, Object>) result.get(ModuleConstant.XML); Map<String,Object> xml = (Map<String, Object>) result.get(ModuleConstant.XML);
if (xml.get(ModuleConstant.MSG_TYPE).equals(ModuleConstant.EVENT_LOW)) { String msgType = xml.get(ModuleConstant.MSG_TYPE).toString();
log.info(String.format(ThirdRunTimeInfoConstant.MSG_TYPE,msgType));
String toUserName = null;
String fromUserName = null;
if (msgType.equals(ModuleConstant.EVENT_LOW)) {
String event = xml.get(ModuleConstant.EVENT).toString();
if (xml.containsKey(ModuleConstant.TO_USER_NAME)){
toUserName = xml.get(ModuleConstant.TO_USER_NAME).toString();
}
if (xml.containsKey(ModuleConstant.FROM_USER_NAME)){
fromUserName = xml.get(ModuleConstant.FROM_USER_NAME).toString();
}
if (event.startsWith(ModuleConstant.WE_APP_AUDIT)) {
// TODO 目前来看,msgType = ‘event’ 的是代码审核结果 // TODO 目前来看,msgType = ‘event’ 的是代码审核结果
Long createTime = Long.valueOf(xml.get(ModuleConstant.CREATE_TIME).toString()); Long createTime = Long.valueOf(xml.get(ModuleConstant.CREATE_TIME).toString());
CodeAuditRecordFormDTO codeAuditRecord = ConvertUtils.mapToEntity(xml, CodeAuditRecordFormDTO.class); CodeAuditRecordFormDTO codeAuditRecord = ConvertUtils.mapToEntity(xml, CodeAuditRecordFormDTO.class);
codeAuditRecord.setWechatCreateTime(componentVerifyTicketServiceImpl.sToDate(createTime.toString())); codeAuditRecord.setWechatCreateTime(componentVerifyTicketServiceImpl.sToDate(createTime.toString()));
String toUserName = codeAuditRecord.getToUserName();//小程序原始ID // String toUserName = codeAuditRecord.getToUserName();//小程序原始ID
CustomerIdAndClientResultDTO customerIdAndClientResultDTO = miniInfoDao.selectCustomerIdAndClientByToUserName(toUserName); CustomerIdAndClientResultDTO customerIdAndClientResultDTO = miniInfoDao.selectCustomerIdAndClientByToUserName(toUserName);
String clientType = customerIdAndClientResultDTO.getClientType(); String clientType = customerIdAndClientResultDTO.getClientType();
String customerId = customerIdAndClientResultDTO.getCustomerId(); String customerId = customerIdAndClientResultDTO.getCustomerId();
@ -123,10 +135,10 @@ public class WarrantServiceImpl implements WarrantService {
codeAuditRecord.setAuthAppId(authAppId); codeAuditRecord.setAuthAppId(authAppId);
codeAuditRecord.setTemplateId(templateId); codeAuditRecord.setTemplateId(templateId);
//插入 代码审核 记录 //插入 代码审核 记录
log.info(String.format(ThirdRunTimeInfoConstant.CODE_AUDIT_RESULT,xml)); log.info(String.format(ThirdRunTimeInfoConstant.CODE_AUDIT_RESULT, xml));
codeAuditRecordDao.insertCodeAuditRecord(codeAuditRecord); codeAuditRecordDao.insertCodeAuditRecord(codeAuditRecord);
// 修改 code_audit_result 中的代码审核结果 // 修改 code_audit_result 中的代码审核结果
String event = codeAuditRecord.getEvent(); // String event = codeAuditRecord.getEvent();
String codeResult = null; String codeResult = null;
switch (event) { switch (event) {
case ModuleConstant.WEAPP_AUDIT_SUCCESS: case ModuleConstant.WEAPP_AUDIT_SUCCESS:
@ -141,7 +153,10 @@ public class WarrantServiceImpl implements WarrantService {
} }
String codeCustomerId = codeCustomerDao.selectCodeCustomerId(codeAuditRecord); String codeCustomerId = codeCustomerDao.selectCodeCustomerId(codeAuditRecord);
codeAuditResultDao.updateAuditResult(customerId, codeCustomerId, codeResult); codeAuditResultDao.updateAuditResult(customerId, codeCustomerId, codeResult);
}else if (xml.get(ModuleConstant.MSG_TYPE).equals(ModuleConstant.TEXT)){ }else {
this.replyEventMessage(request,response,event,toUserName,fromUserName);
}
}else if (msgType.equals(ModuleConstant.TEXT)){
// TODO 公众号回复消息 // TODO 公众号回复消息
MessagePushTextFormDTO messagePushTextFormDTO = ConvertUtils.mapToEntity(xml, MessagePushTextFormDTO.class); MessagePushTextFormDTO messagePushTextFormDTO = ConvertUtils.mapToEntity(xml, MessagePushTextFormDTO.class);
Object createTime = xml.get(ModuleConstant.CREATE_TIME); Object createTime = xml.get(ModuleConstant.CREATE_TIME);
@ -157,7 +172,7 @@ public class WarrantServiceImpl implements WarrantService {
* 1微信模推送给第三方平台方文本消息其中 Content 字段的内容固定为TESTCOMPONENT_MSG_TYPE_TEXT * 1微信模推送给第三方平台方文本消息其中 Content 字段的内容固定为TESTCOMPONENT_MSG_TYPE_TEXT
* 2第三方平台方立马回应文本消息并最终触达粉丝Content 必须固定为TESTCOMPONENT_MSG_TYPE_TEXT_callback * 2第三方平台方立马回应文本消息并最终触达粉丝Content 必须固定为TESTCOMPONENT_MSG_TYPE_TEXT_callback
*/ */
if (content.equals(ModuleConstant.TESTCOMPONENT_MSG_TYPE_TEXT)){ /*if (content.equals(ModuleConstant.TESTCOMPONENT_MSG_TYPE_TEXT)){
}else if (content.startsWith(ModuleConstant.QUERY_AUTH_CODE)){ }else if (content.startsWith(ModuleConstant.QUERY_AUTH_CODE)){
@ -166,7 +181,10 @@ public class WarrantServiceImpl implements WarrantService {
//auth_code //auth_code
String queryAuthCode = content.substring(contentBefore.length() + NumConstant.ONE, content.length()); String queryAuthCode = content.substring(contentBefore.length() + NumConstant.ONE, content.length());
} }*/
this.processTextMessage(request,response,content,toUserName,fromUserName);
} }
log.info("消息与事件接收URL【代码审核结果】结束......"); log.info("消息与事件接收URL【代码审核结果】结束......");
return ModuleConstant.SUCCESS; return ModuleConstant.SUCCESS;
@ -224,7 +242,7 @@ public class WarrantServiceImpl implements WarrantService {
public void replyTextMessage(HttpServletRequest request, HttpServletResponse response, public void replyTextMessage(HttpServletRequest request, HttpServletResponse response,
String content,String toUserName, String fromUserName) String content,String toUserName, String fromUserName)
throws DocumentException, IOException { throws DocumentException, IOException {
Long createTime = System.currentTimeMillis() / 1000; Long createTime = System.currentTimeMillis() / NumConstant.ONE_THOUSAND;
StringBuffer sb = new StringBuffer(512); StringBuffer sb = new StringBuffer(512);
sb.append("<xml>"); sb.append("<xml>");
sb.append("<ToUserName><![CDATA["+toUserName+"]]></ToUserName>"); sb.append("<ToUserName><![CDATA["+toUserName+"]]></ToUserName>");
@ -251,7 +269,7 @@ public class WarrantServiceImpl implements WarrantService {
// 得到微信授权成功的消息后,应该立刻进行处理!!相关信息只会在首次授权的时候推送过来 // 得到微信授权成功的消息后,应该立刻进行处理!!相关信息只会在首次授权的时候推送过来
//第三方平台【component_access_token】 //第三方平台【component_access_token】
String componentAccessToken = redisThird.getComponentAccessToken(); String componentAccessToken = redisThird.getComponentAccessToken();
com.alibaba.fastjson.JSONObject jsonObject = new com.alibaba.fastjson.JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put(ModuleConstant.COMPONENT_APPID, componentAppId); jsonObject.put(ModuleConstant.COMPONENT_APPID, componentAppId);
jsonObject.put(ModuleConstant.AUTHORIZATION_CODE, auth_code); jsonObject.put(ModuleConstant.AUTHORIZATION_CODE, auth_code);
String authInfo = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_QUERY_AUTH_URL + componentAccessToken, JSON.toJSONString(jsonObject)).getData(); String authInfo = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_QUERY_AUTH_URL + componentAccessToken, JSON.toJSONString(jsonObject)).getData();

Loading…
Cancel
Save