|
@ -119,7 +119,7 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe |
|
|
log.info(String.format(ThirdRunTimeInfoConstant.MSG,msg)); |
|
|
log.info(String.format(ThirdRunTimeInfoConstant.MSG,msg)); |
|
|
// 将xml转为map
|
|
|
// 将xml转为map
|
|
|
Map<String, String> result = WXXmlToMapUtil.xmlToMap(msg); |
|
|
Map<String, String> result = WXXmlToMapUtil.xmlToMap(msg); |
|
|
String infotype = result.get(ModuleConstant.INFO_TYPE); //获取infotype,注:微信开放平台文档中标明固定为:"component_verify_ticket",但参考其他代码,还包含authorized???
|
|
|
String infotype = result.get(ModuleConstant.INFO_TYPE); |
|
|
log.info(infotype); |
|
|
log.info(infotype); |
|
|
switch (infotype){ |
|
|
switch (infotype){ |
|
|
case ModuleConstant.TICKET_UNDERLINE_KEY: //接收票据 【component_verify_ticket】
|
|
|
case ModuleConstant.TICKET_UNDERLINE_KEY: //接收票据 【component_verify_ticket】
|
|
@ -131,7 +131,7 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe |
|
|
ticketFormDTO.setComponentAppId(componentAppId); |
|
|
ticketFormDTO.setComponentAppId(componentAppId); |
|
|
ticketFormDTO.setComponentVerifyTicket(ComponentVerifyTicket); |
|
|
ticketFormDTO.setComponentVerifyTicket(ComponentVerifyTicket); |
|
|
//先逻辑删
|
|
|
//先逻辑删
|
|
|
ticketDao.updateOldComponentVerifyTicket(); |
|
|
ticketDao.deleteOldComponentVerifyTicket(); |
|
|
ticketDao.insertComponentVerifyTicket(ticketFormDTO); |
|
|
ticketDao.insertComponentVerifyTicket(ticketFormDTO); |
|
|
log.info(ModuleConstant.TICKET_UNDERLINE_KEY+":"+ComponentVerifyTicket); |
|
|
log.info(ModuleConstant.TICKET_UNDERLINE_KEY+":"+ComponentVerifyTicket); |
|
|
break; |
|
|
break; |
|
@ -509,34 +509,41 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public void createAndBindOpenAccount(String customerId,String authAppId,String clientType){ |
|
|
public void createAndBindOpenAccount(String customerId,String authAppId,String clientType){ |
|
|
|
|
|
Map<String, Object> authorizerRefreshToken = redisThird.getAuthorizerRefreshToken(customerId + ThirdRedisKeyConstant.COLON + clientType); |
|
|
|
|
|
String authorizerAccessToken = authorizerRefreshToken.get("authorizerAccessToken").toString(); |
|
|
|
|
|
JSONObject bindInfoForm = new JSONObject(); |
|
|
|
|
|
bindInfoForm.put(ModuleConstant.LOW_APP_ID,authAppId); |
|
|
|
|
|
String bindResult = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_OPEN_GET + authorizerAccessToken, JSON.toJSONString(bindInfoForm)).getData(); |
|
|
|
|
|
Map<String,Object> bindInfo = JSON.parseObject(bindResult, Map.class); |
|
|
|
|
|
boolean bindStatus = bindInfo.containsKey(ModuleConstant.OPEN_APP_ID); |
|
|
|
|
|
if (bindStatus != true) { |
|
|
log.info("开始创建开放平台账号并绑定"); |
|
|
log.info("开始创建开放平台账号并绑定"); |
|
|
List<String> authCount = customerMpDao.selectAuthCount(customerId); |
|
|
List<String> authCount = customerMpDao.selectAuthCount(customerId); |
|
|
String openPlatformId = null; |
|
|
String openPlatformId = null; |
|
|
if (authCount.size()>0){ |
|
|
if (authCount.size() > 0) { |
|
|
openPlatformId = openPlatformAccountDao.selectOpenAppIdByCustomerId(customerId); |
|
|
openPlatformId = openPlatformAccountDao.selectOpenAppIdByCustomerId(customerId); |
|
|
} |
|
|
} |
|
|
Map<String, Object> authorizerRefreshToken = redisThird.getAuthorizerRefreshToken(customerId + ThirdRedisKeyConstant.COLON + clientType); |
|
|
if (authCount.size() == NumConstant.ZERO) { |
|
|
String authorizerAccessToken = authorizerRefreshToken.get("authorizerAccessToken").toString(); |
|
|
|
|
|
if (authCount.size()==NumConstant.ZERO){ |
|
|
|
|
|
log.info("未查询到该客户授权信息,先创建开放平台账号,再绑定"); |
|
|
log.info("未查询到该客户授权信息,先创建开放平台账号,再绑定"); |
|
|
//没有任何一个小程序/公众号授权,【先创建,再绑定】
|
|
|
//没有任何一个小程序/公众号授权,【先创建,再绑定】
|
|
|
JSONObject jsonObject = new JSONObject(); |
|
|
JSONObject jsonObject = new JSONObject(); |
|
|
jsonObject.put(ModuleConstant.LOW_APP_ID,authAppId); |
|
|
jsonObject.put(ModuleConstant.LOW_APP_ID, authAppId); |
|
|
// 此处的 access_token 为 【authorizer_access_token】
|
|
|
// 此处的 access_token 为 【authorizer_access_token】
|
|
|
String data = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_CREATE_OPEN + authorizerAccessToken, JSON.toJSONString(jsonObject)).getData(); |
|
|
String data = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_CREATE_OPEN + authorizerAccessToken, JSON.toJSONString(jsonObject)).getData(); |
|
|
Map<String,Object> map = JSON.parseObject(data, Map.class); |
|
|
Map<String, Object> map = JSON.parseObject(data, Map.class); |
|
|
openPlatformId = map.get(ModuleConstant.OPEN_APP_ID).toString(); |
|
|
openPlatformId = map.get(ModuleConstant.OPEN_APP_ID).toString(); |
|
|
CreateOpenResultDTO createOpen = new CreateOpenResultDTO(); |
|
|
CreateOpenResultDTO createOpen = new CreateOpenResultDTO(); |
|
|
createOpen.setErrCode((Integer)map.get(ModuleConstant.ERR_CODE)); |
|
|
createOpen.setErrCode((Integer) map.get(ModuleConstant.ERR_CODE)); |
|
|
createOpen.setErrMsg(map.get(ModuleConstant.ERR_MSG).toString()); |
|
|
createOpen.setErrMsg(map.get(ModuleConstant.ERR_MSG).toString()); |
|
|
createOpen.setOpenAppId(map.get(ModuleConstant.OPEN_APP_ID).toString()); |
|
|
createOpen.setOpenAppId(map.get(ModuleConstant.OPEN_APP_ID).toString()); |
|
|
switch (createOpen.getErrCode()){ |
|
|
switch (createOpen.getErrCode()) { |
|
|
case NumConstant.ZERO: |
|
|
case NumConstant.ZERO: |
|
|
log.info(CREATE_AND_BIND_SUCCESS); |
|
|
log.info(CREATE_AND_BIND_SUCCESS); |
|
|
CreateOpenFormDTO coForm = new CreateOpenFormDTO(); |
|
|
CreateOpenFormDTO coForm = new CreateOpenFormDTO(); |
|
|
coForm.setOpenid(map.get(ModuleConstant.OPEN_APP_ID).toString()); |
|
|
coForm.setOpenid(map.get(ModuleConstant.OPEN_APP_ID).toString()); |
|
|
coForm.setCustomerId(customerId); |
|
|
coForm.setCustomerId(customerId); |
|
|
//插入 open_platform_account 表
|
|
|
//插入 open_platform_account 表
|
|
|
|
|
|
openPlatformAccountDao.deleteOldOpenPlatFprmAccount(customerId); |
|
|
openPlatformAccountDao.insertOpenPlatFormAccount(coForm); |
|
|
openPlatformAccountDao.insertOpenPlatFormAccount(coForm); |
|
|
break; |
|
|
break; |
|
|
case NumConstant.ONE_NEG: |
|
|
case NumConstant.ONE_NEG: |
|
@ -546,17 +553,17 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe |
|
|
case ModuleConstant.EIGHTY_NINE_THOUSAND: |
|
|
case ModuleConstant.EIGHTY_NINE_THOUSAND: |
|
|
throw new RenException(ACCOUNT_HAS_BOUND_OPEN); |
|
|
throw new RenException(ACCOUNT_HAS_BOUND_OPEN); |
|
|
} |
|
|
} |
|
|
}else if (authCount.size()>NumConstant.ZERO && !authCount.contains(authAppId)){ |
|
|
} else if (authCount.size() > NumConstant.ZERO && !authCount.contains(authAppId)) { |
|
|
log.info("该客户已创建过开放平台账号,直接绑定"); |
|
|
log.info("该客户已创建过开放平台账号,直接绑定"); |
|
|
JSONObject jsonObject = new JSONObject(); |
|
|
JSONObject jsonObject = new JSONObject(); |
|
|
jsonObject.put(ModuleConstant.LOW_APP_ID,authAppId); |
|
|
jsonObject.put(ModuleConstant.LOW_APP_ID, authAppId); |
|
|
jsonObject.put(ModuleConstant.OPEN_APP_ID,openPlatformId); |
|
|
jsonObject.put(ModuleConstant.OPEN_APP_ID, openPlatformId); |
|
|
String data = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_BIND_OPEN + authorizerAccessToken, JSON.toJSONString(jsonObject)).getData(); |
|
|
String data = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_BIND_OPEN + authorizerAccessToken, JSON.toJSONString(jsonObject)).getData(); |
|
|
Map<String,Object> map = JSON.parseObject(data, Map.class); |
|
|
Map<String, Object> map = JSON.parseObject(data, Map.class); |
|
|
CreateOpenResultDTO createOpen = new CreateOpenResultDTO(); |
|
|
CreateOpenResultDTO createOpen = new CreateOpenResultDTO(); |
|
|
createOpen.setErrCode((Integer)map.get(ModuleConstant.ERR_CODE)); |
|
|
createOpen.setErrCode((Integer) map.get(ModuleConstant.ERR_CODE)); |
|
|
createOpen.setErrMsg(map.get(ModuleConstant.ERR_MSG).toString()); |
|
|
createOpen.setErrMsg(map.get(ModuleConstant.ERR_MSG).toString()); |
|
|
switch (createOpen.getErrCode()){ |
|
|
switch (createOpen.getErrCode()) { |
|
|
case NumConstant.ZERO: |
|
|
case NumConstant.ZERO: |
|
|
log.info(BIND_SUCCESS); |
|
|
log.info(BIND_SUCCESS); |
|
|
break; |
|
|
break; |
|
@ -583,6 +590,7 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe |
|
|
bindingAccountDao.insertBindingAccount(bindingAccount); |
|
|
bindingAccountDao.insertBindingAccount(bindingAccount); |
|
|
log.info("创建绑定账号结束"); |
|
|
log.info("创建绑定账号结束"); |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* @Description map 转 Entity |
|
|
* @Description map 转 Entity |
|
|