Browse Source

Merge remote-tracking branch 'origin/dev_thirdplatform' into dev

dev_shibei_match
zxc 5 years ago
parent
commit
a9b7db3d04
  1. 80
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ComponentVerifyTicketServiceImpl.java
  2. 2
      epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CustomerMpDao.xml

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

@ -32,9 +32,7 @@ import org.springframework.web.bind.annotation.RequestBody;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Field;
import java.util.*;
@ -139,7 +137,6 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
break;
case ModuleConstant.AUTHORIZED: //授权成功
// 更改customer_mp 授权信息,appId,并绑定
// String authAppId = result.get(ModuleConstant.APP_ID);
String authCode = result.get(ModuleConstant.AUTHORIZATION_CODE_HUMP);
log.info("=============================="+authCode);
AuthCodeResultDTO authCodeResultDTO = authCodeDao.selectCustomerIdByAuthCode(authCode);
@ -148,10 +145,8 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
Map<String, Object> authorizerRefreshToken = redisThird.getAuthorizerRefreshToken(customerId + ThirdRedisKeyConstant.COLON + clientType);
String authAppId = authorizerRefreshToken.get("authorizerAppid").toString();
this.updateCustomerMpAppIdAndCreateOpenPlatform(customerId,authAppId,clientType);
// this.authInfoByAuthCode(authCode, customerId,clientType);
authCodeDao.updateAppId(customerId,clientType,authAppId);
this.saveAuthAccountInfo(customerId,authAppId,clientType);
// customerMpDao.updateAuthorizationFlag(authAppId);
case ModuleConstant.UNAUTHORIZED://用户取消授权
//todo 取消授权
String authorizerAppId = result.get(ModuleConstant.AUTHORIZER_APP_ID_HUMP);
@ -494,89 +489,20 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
}
/**
* @Description 1.创建开放平台账号并绑定 2.回填 customer_mp appId
* @Description 回填 customer_mp appId , 更改授权状态
* @param
* @author zxc
*/
@Transactional(rollbackFor = Exception.class)
public void updateCustomerMpAppIdAndCreateOpenPlatform(String customerId,String authAppId,String clientType){
/*log.info("开始创建开放平台账号并绑定");
Integer authCount = customerMpDao.selectAuthCount(customerId);
String openPlatformId = null;
Map<String, Object> authorizerRefreshToken = redisThird.getAuthorizerRefreshToken(customerId + ThirdRedisKeyConstant.COLON + clientType);
String authorizerAccessToken = authorizerRefreshToken.get("authorizerAccessToken").toString();
if (authCount==NumConstant.ZERO){
log.info("未查询到该客户授权信息,先创建开放平台账号,再绑定");
//没有任何一个小程序/公众号授权,【先创建,再绑定】
JSONObject jsonObject = new JSONObject();
jsonObject.put(ModuleConstant.LOW_APP_ID,authAppId);
// 此处的 access_token 为 【authorizer_access_token】
String data = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_CREATE_OPEN + authorizerAccessToken, JSON.toJSONString(jsonObject)).getData();
Map<String,String> map = JSON.parseObject(data, Map.class);
CreateOpenResultDTO createOpen = new CreateOpenResultDTO();
createOpen.setErrCode(Integer.valueOf(map.get(ModuleConstant.ERR_CODE)));
createOpen.setErrMsg(map.get(ModuleConstant.ERR_MSG));
createOpen.setOpenAppId(map.get(ModuleConstant.OPEN_APP_ID));
switch (createOpen.getErrCode()){
case NumConstant.ONE:
log.info(CREATE_AND_BIND_SUCCESS);
break;
case NumConstant.ONE_NEG:
throw new RenException(SYSTEM_ERROR);
case ModuleConstant.FORTY_THOUSAND_AND_THIRTEEN:
throw new RenException(INVALID_APP_ID);
case ModuleConstant.EIGHTY_NINE_THOUSAND:
throw new RenException(ACCOUNT_HAS_BOUND_OPEN);
}
CreateOpenFormDTO coForm = new CreateOpenFormDTO();
coForm.setOpenid(map.get(ModuleConstant.OPEN_APP_ID));
coForm.setCustomerId(customerId);
//插入 open_platform_account 表
openPlatformAccountDao.insertOpenPlatFormAccount(coForm);
openPlatformId = coForm.getId();
}else if (authCount>NumConstant.ZERO){
log.info("该客户已创建过开放平台账号,直接绑定");
String openAppId = openPlatformAccountDao.selectOpenAppIdByCustomerId(customerId);
JSONObject jsonObject = new JSONObject();
jsonObject.put(ModuleConstant.LOW_APP_ID,componentAppId);
jsonObject.put(ModuleConstant.OPEN_APP_ID,openAppId);
String data = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_BIND_OPEN + authorizerRefreshToken, JSON.toJSONString(jsonObject)).getData();
Map<String,String> map = JSON.parseObject(data, Map.class);
CreateOpenResultDTO createOpen = new CreateOpenResultDTO();
createOpen.setErrCode(Integer.valueOf(map.get(ModuleConstant.ERR_CODE)));
createOpen.setErrMsg(map.get(ModuleConstant.ERR_MSG));
switch (createOpen.getErrCode()){
case NumConstant.ONE:
log.info(BIND_SUCCESS);
break;
case NumConstant.ONE_NEG:
throw new RenException(SYSTEM_ERROR);
case ModuleConstant.FORTY_THOUSAND_AND_THIRTEEN:
throw new RenException(INVALID_APP_ID);
case ModuleConstant.EIGHTY_NINE_THOUSAND:
throw new RenException(ACCOUNT_HAS_BOUND_OPEN);
case ModuleConstant.EIGHTY_NINE_THOUSAND_AND_ONE:
throw new RenException(NOT_SAME_CONTRACTOR);
case ModuleConstant.EIGHTY_NINE_THOUSAND_AND_THREE:
throw new RenException(NOT_ALLOWED_OPERATE);
case ModuleConstant.EIGHTY_NINE_THOUSAND_AND_FOUR:
throw new RenException(TO_LIMIT);
}
}*/
log.info("==========回填customer_mp开始==========");
AuthCodeFormDTO formDTO = new AuthCodeFormDTO();
formDTO.setClientType(clientType);
formDTO.setAuthAppId(authAppId);
formDTO.setCustomerId(customerId);
//回填customer_mp的appId 只需以上三个字段
customerMpDao.updateAppIDByCustomerIdAndClient(formDTO);
//插入 binding_account
/*BindingAccountFormDTO bindingAccount = new BindingAccountFormDTO();
bindingAccount.setOpenPlatformAccountId(openPlatformId);
bindingAccount.setAuthAppId(authAppId);
bindingAccount.setClientType(clientType);
bindingAccount.setCustomerId(customerId);
bindingAccountDao.insertBindingAccount(bindingAccount);*/
log.info("创建绑定账号结束");
log.info("==========回填customer_mp结束==========");
}
/**

2
epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CustomerMpDao.xml

@ -51,7 +51,7 @@
<!-- 根据 客户Id和授权方AppId查询clientType -->
<select id="selectClientTypeByCustomerIdAndAuthId" resultType="java.lang.String">
SELECT
client_type AS clientType
client AS clientType
FROM
customer_mp
WHERE

Loading…
Cancel
Save