|
@ -1,9 +1,22 @@ |
|
|
package com.epmet.service.impl; |
|
|
package com.epmet.service.impl; |
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
import com.epmet.commons.tools.security.dto.TokenDto; |
|
|
import com.epmet.commons.tools.security.dto.TokenDto; |
|
|
|
|
|
import com.epmet.commons.tools.utils.HttpClientManager; |
|
|
|
|
|
import com.epmet.constant.ModuleConstant; |
|
|
|
|
|
import com.epmet.dao.BindingAccountDao; |
|
|
|
|
|
import com.epmet.dao.CustomerMpDao; |
|
|
|
|
|
import com.epmet.dao.OpenPlatformAccountDao; |
|
|
import com.epmet.dao.PaCustomerAgencyDao; |
|
|
import com.epmet.dao.PaCustomerAgencyDao; |
|
|
import com.epmet.dto.form.GoToAuthFormDTO; |
|
|
import com.epmet.dto.form.GoToAuthFormDTO; |
|
|
|
|
|
import com.epmet.dto.form.OpenAppIdFormDTO; |
|
|
|
|
|
import com.epmet.dto.form.RemoveBindFormDTO; |
|
|
|
|
|
import com.epmet.dto.result.AuthorizationInfoResultDTO; |
|
|
import com.epmet.dto.result.GoToAuthResultDTO; |
|
|
import com.epmet.dto.result.GoToAuthResultDTO; |
|
|
|
|
|
import com.epmet.redis.RedisThird; |
|
|
import com.epmet.service.AppLetAuthorizationService; |
|
|
import com.epmet.service.AppLetAuthorizationService; |
|
|
import com.epmet.service.ComponentVerifyTicketService; |
|
|
import com.epmet.service.ComponentVerifyTicketService; |
|
|
import com.epmet.wxapi.constant.WxMaCodeConstant; |
|
|
import com.epmet.wxapi.constant.WxMaCodeConstant; |
|
@ -12,6 +25,8 @@ import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* @Author zxc |
|
|
* @Author zxc |
|
|
* @CreateTime 2020/7/10 15:52 |
|
|
* @CreateTime 2020/7/10 15:52 |
|
@ -24,6 +39,17 @@ public class AppLetAuthorizationServiceImpl implements AppLetAuthorizationServic |
|
|
private PaCustomerAgencyDao paCustomerAgencyDao; |
|
|
private PaCustomerAgencyDao paCustomerAgencyDao; |
|
|
@Autowired |
|
|
@Autowired |
|
|
private ComponentVerifyTicketService componentVerifyTicketService; |
|
|
private ComponentVerifyTicketService componentVerifyTicketService; |
|
|
|
|
|
@Autowired |
|
|
|
|
|
private ComponentVerifyTicketServiceImpl componentVerifyTicketServiceImpl; |
|
|
|
|
|
@Autowired |
|
|
|
|
|
private OpenPlatformAccountDao openPlatformAccountDao; |
|
|
|
|
|
@Autowired |
|
|
|
|
|
private CustomerMpDao customerMpDao; |
|
|
|
|
|
@Autowired |
|
|
|
|
|
private RedisThird redisThird; |
|
|
|
|
|
@Autowired |
|
|
|
|
|
private BindingAccountDao bindingAccountDao; |
|
|
|
|
|
|
|
|
@Value("${third.platform.appId}") |
|
|
@Value("${third.platform.appId}") |
|
|
private String componentAppId; |
|
|
private String componentAppId; |
|
|
|
|
|
|
|
@ -44,4 +70,56 @@ public class AppLetAuthorizationServiceImpl implements AppLetAuthorizationServic |
|
|
result.setUrl(authUrl); |
|
|
result.setUrl(authUrl); |
|
|
return result; |
|
|
return result; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* @Description 将公众号/小程序从开放平台帐号下解绑 |
|
|
|
|
|
* @param tokenDto |
|
|
|
|
|
* @param formDTO |
|
|
|
|
|
* @author zxc |
|
|
|
|
|
*/ |
|
|
|
|
|
@Override |
|
|
|
|
|
public void removeBind(TokenDto tokenDto, RemoveBindFormDTO formDTO) { |
|
|
|
|
|
String customerId = componentVerifyTicketServiceImpl.getLoginUserCustomerId(tokenDto); |
|
|
|
|
|
String clientType = formDTO.getClientType(); |
|
|
|
|
|
//查询openAppId
|
|
|
|
|
|
String openAppId = openPlatformAccountDao.selectOpenAppIdByCustomerId(customerId); |
|
|
|
|
|
//查询appId
|
|
|
|
|
|
String authAppId = customerMpDao.getAppId(customerId, clientType); |
|
|
|
|
|
Map<String, Object> authInfo = redisThird.getAuthInfo(customerId, clientType); |
|
|
|
|
|
AuthorizationInfoResultDTO authorizationInfo = componentVerifyTicketServiceImpl.mapToEntity(authInfo, AuthorizationInfoResultDTO.class); |
|
|
|
|
|
JSONObject jsonObject = new JSONObject(); |
|
|
|
|
|
jsonObject.put(ModuleConstant.LOW_APP_ID,authAppId); |
|
|
|
|
|
jsonObject.put(ModuleConstant.OPEN_APP_ID,openAppId); |
|
|
|
|
|
String data = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.UN_BIND + authorizationInfo.getAuthorizer_access_token(), JSON.toJSONString(jsonObject)).getData(); |
|
|
|
|
|
Map<String,String> map = JSON.parseObject(data, Map.class); |
|
|
|
|
|
if (!map.get(ModuleConstant.ERR_CODE).equals(NumConstant.ZERO_STR)){ |
|
|
|
|
|
log.error("解绑失败" + data); |
|
|
|
|
|
throw new RenException("解绑失败" + data); |
|
|
|
|
|
} |
|
|
|
|
|
bindingAccountDao.updateBindStatus(customerId,authAppId); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* @Description 查看小程序绑定的开放平台账号 |
|
|
|
|
|
* @param tokenDto |
|
|
|
|
|
* @param formDTO |
|
|
|
|
|
* @author zxc |
|
|
|
|
|
*/ |
|
|
|
|
|
@Override |
|
|
|
|
|
public String getOpenAppId(TokenDto tokenDto, OpenAppIdFormDTO formDTO) { |
|
|
|
|
|
String customerId = componentVerifyTicketServiceImpl.getLoginUserCustomerId(tokenDto); |
|
|
|
|
|
String clientType = formDTO.getClientType(); |
|
|
|
|
|
String authAppId = customerMpDao.getAppId(customerId, clientType); |
|
|
|
|
|
Map<String, Object> authInfo = redisThird.getAuthInfo(customerId, clientType); |
|
|
|
|
|
AuthorizationInfoResultDTO authorizationInfo = componentVerifyTicketServiceImpl.mapToEntity(authInfo, AuthorizationInfoResultDTO.class); |
|
|
|
|
|
JSONObject jsonObject = new JSONObject(); |
|
|
|
|
|
jsonObject.put(ModuleConstant.LOW_APP_ID,authAppId); |
|
|
|
|
|
String data = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.UN_BIND + authorizationInfo.getAuthorizer_access_token(), JSON.toJSONString(jsonObject)).getData(); |
|
|
|
|
|
Map map = JSON.parseObject(data, Map.class); |
|
|
|
|
|
if (map.containsKey(ModuleConstant.OPEN_APP_ID)){ |
|
|
|
|
|
return map.get(ModuleConstant.OPEN_APP_ID).toString(); |
|
|
|
|
|
} |
|
|
|
|
|
return map.get(ModuleConstant.ERR_MSG).toString(); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|