Browse Source

微信第三方平台-{APPID}/callback修改,获取component_access_token修改

master
zxc 5 years ago
parent
commit
f489119f6f
  1. 3
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/ModuleConstant.java
  2. 3
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/WarrantController.java
  3. 6
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ComponentVerifyTicketServiceImpl.java
  4. 4
      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

@ -75,6 +75,9 @@ public interface ModuleConstant {
//代码审核结果推送 如下 //代码审核结果推送 如下
String EVENT = "Event"; String EVENT = "Event";
String MSG_TYPE = "MsgType";
String EVENT_LOW = "event";
String TEXT = "text";
String WEAPP_AUDIT_SUCCESS = "weapp_audit_success"; //审核通过 String WEAPP_AUDIT_SUCCESS = "weapp_audit_success"; //审核通过
String WEAPP_AUDIT_FAIL = "weapp_audit_fail"; //审核不通过 String WEAPP_AUDIT_FAIL = "weapp_audit_fail"; //审核不通过
String WEAPP_AUDIT_DELAY = "weapp_audit_delay"; //审核延后 String WEAPP_AUDIT_DELAY = "weapp_audit_delay"; //审核延后

3
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/WarrantController.java

@ -6,6 +6,7 @@ import lombok.extern.slf4j.Slf4j;
import org.dom4j.DocumentException; import org.dom4j.DocumentException;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
@ -25,7 +26,7 @@ public class WarrantController {
@Autowired @Autowired
private WarrantService warrantService; private WarrantService warrantService;
@RequestMapping(value ="/{APPID}/callback") @PostMapping(value ="/{APPID}/callback")
public String acceptMessageAndEvent(HttpServletRequest request, @PathVariable("APPID") String appid, public String acceptMessageAndEvent(HttpServletRequest request, @PathVariable("APPID") String appid,
HttpServletResponse response)throws IOException, DocumentException, AesException { HttpServletResponse response)throws IOException, DocumentException, AesException {
return warrantService.acceptMessageAndEvent(request, appid, response); return warrantService.acceptMessageAndEvent(request, appid, response);

6
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ComponentVerifyTicketServiceImpl.java

@ -201,6 +201,7 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
jsonObject.put(ModuleConstant.TICKET_UNDERLINE_KEY, componentVerifyTicket); jsonObject.put(ModuleConstant.TICKET_UNDERLINE_KEY, componentVerifyTicket);
String post = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_COMPONENT_TOKEN_URL, JSON.toJSONString(jsonObject)).getData(); String post = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_COMPONENT_TOKEN_URL, JSON.toJSONString(jsonObject)).getData();
Map hashMap = JSON.parseObject(post, Map.class); Map hashMap = JSON.parseObject(post, Map.class);
if (!hashMap.containsKey(ModuleConstant.ERR_MSG)) {
String componentAccessToken = hashMap.get(COMPONENT_ACCESS_TOKEN).toString(); String componentAccessToken = hashMap.get(COMPONENT_ACCESS_TOKEN).toString();
Integer expiresIn = (Integer) hashMap.get(ModuleConstant.EXPIRES_IN); Integer expiresIn = (Integer) hashMap.get(ModuleConstant.EXPIRES_IN);
Date expiresInTime = this.countExpirationTime(expiresIn.toString()); Date expiresInTime = this.countExpirationTime(expiresIn.toString());
@ -221,6 +222,7 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
log.info(ThirdRunTimeInfoConstant.SUCCESS_ACCESS_TOKEN); log.info(ThirdRunTimeInfoConstant.SUCCESS_ACCESS_TOKEN);
} }
} }
}
/** /**
* @Description 获取预授权码 * @Description 获取预授权码
@ -232,7 +234,6 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
public String preAuthCode() { public String preAuthCode() {
log.info(START_GET_PRE_AUTH_CODE); log.info(START_GET_PRE_AUTH_CODE);
String preAuthCode = ""; String preAuthCode = "";
try {
String accessToken = redisThird.getComponentAccessToken(); String accessToken = redisThird.getComponentAccessToken();
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put(ModuleConstant.COMPONENT_APPID, componentAppId); jsonObject.put(ModuleConstant.COMPONENT_APPID, componentAppId);
@ -255,9 +256,6 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
} else { } else {
throw new RuntimeException(FAILURE_GET_PRE_AUTH_CODE); throw new RuntimeException(FAILURE_GET_PRE_AUTH_CODE);
} }
} catch (Exception e) {
e.printStackTrace();
}
log.info(END_GET_PRE_AUTH_CODE); log.info(END_GET_PRE_AUTH_CODE);
return preAuthCode; return preAuthCode;
} }

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

@ -90,6 +90,7 @@ 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)) {
Long createTime = Long.valueOf(xml.get(ModuleConstant.CREATE_TIME).toString()); Long createTime = Long.valueOf(xml.get(ModuleConstant.CREATE_TIME).toString());
CodeAuditRecordFormDTO codeAuditRecord = componentVerifyTicketService.mapToEntity(xml, CodeAuditRecordFormDTO.class); CodeAuditRecordFormDTO codeAuditRecord = componentVerifyTicketService.mapToEntity(xml, CodeAuditRecordFormDTO.class);
codeAuditRecord.setWechatCreateTime(new Date(createTime)); codeAuditRecord.setWechatCreateTime(new Date(createTime));
@ -119,6 +120,9 @@ 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)){
}
return ModuleConstant.SUCCESS; return ModuleConstant.SUCCESS;
} }
} }

Loading…
Cancel
Save