From 5bf19ca3f8380a9578878f9b769de497d6f32bd8 Mon Sep 17 00:00:00 2001 From: sunyuchao Date: Fri, 24 Jul 2020 16:33:55 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E6=94=BF=E5=BA=9C=E7=AB=AFenterorg?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E8=B0=83=E7=94=A8=E5=BE=AE=E4=BF=A1api?= =?UTF-8?q?=E6=96=B9=E5=BC=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epmet/dto/form/GovWxmpEnteOrgFormDTO.java | 6 ++++ .../service/impl/GovLoginServiceImpl.java | 30 ++++++++++++++----- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/epmet-auth/src/main/java/com/epmet/dto/form/GovWxmpEnteOrgFormDTO.java b/epmet-auth/src/main/java/com/epmet/dto/form/GovWxmpEnteOrgFormDTO.java index e68df77236..8951235a94 100644 --- a/epmet-auth/src/main/java/com/epmet/dto/form/GovWxmpEnteOrgFormDTO.java +++ b/epmet-auth/src/main/java/com/epmet/dto/form/GovWxmpEnteOrgFormDTO.java @@ -38,5 +38,11 @@ public class GovWxmpEnteOrgFormDTO implements Serializable { */ @NotBlank(message = "组织id不能为空",groups = {AddUserInternalGroup.class}) private String rootAgencyId; + + /** + * 客户appId(exJson文件中获取) + */ + @NotBlank(message = "appId不能为空",groups = {AddUserInternalGroup.class}) + private String appId; } diff --git a/epmet-auth/src/main/java/com/epmet/service/impl/GovLoginServiceImpl.java b/epmet-auth/src/main/java/com/epmet/service/impl/GovLoginServiceImpl.java index 092a327312..406ae0fe6f 100644 --- a/epmet-auth/src/main/java/com/epmet/service/impl/GovLoginServiceImpl.java +++ b/epmet-auth/src/main/java/com/epmet/service/impl/GovLoginServiceImpl.java @@ -19,12 +19,10 @@ import com.epmet.constant.SmsTemplateConstant; import com.epmet.dto.CustomerAgencyDTO; import com.epmet.dto.CustomerStaffDTO; import com.epmet.dto.GovStaffRoleDTO; +import com.epmet.dto.UserWechatDTO; import com.epmet.dto.form.*; import com.epmet.dto.result.*; -import com.epmet.feign.EpmetMessageOpenFeignClient; -import com.epmet.feign.EpmetUserFeignClient; -import com.epmet.feign.EpmetUserOpenFeignClient; -import com.epmet.feign.GovOrgFeignClient; +import com.epmet.feign.*; import com.epmet.jwt.JwtTokenProperties; import com.epmet.jwt.JwtTokenUtils; import com.epmet.redis.CaptchaRedis; @@ -67,6 +65,8 @@ public class GovLoginServiceImpl implements GovLoginService { private EpmetMessageOpenFeignClient epmetMessageOpenFeignClient; @Autowired private EpmetUserOpenFeignClient userOpenFeignClient; + @Autowired + private EpmetThirdFeignClient epmetThirdFeignClient; /** * @param formDTO @@ -272,8 +272,24 @@ public class GovLoginServiceImpl implements GovLoginService { throw new RenException(customerStaffDTOResult.getCode()); } CustomerStaffDTO customerStaff = customerStaffDTOResult.getData(); - //2、解析微信用户 - WxMaJscode2SessionResult wxMaJscode2SessionResult = loginService.getWxMaUser(LoginConstant.APP_GOV, formDTO.getWxCode()); + /*//2、解析微信用户 + WxMaJscode2SessionResult wxMaJscode2SessionResult = loginService.getWxMaUser(LoginConstant.APP_GOV, formDTO.getWxCode());*/ + //2020.7.24 获取微信信息接口调整,改调用微信api的方式 sun + //2.调用epmet_third服务,校验appId是否有效以及是否授权,校验通过的调用微信API获取用户基本信息 + WxLoginFormDTO resiLoginFormDTO = new WxLoginFormDTO(); + resiLoginFormDTO.setAppId(formDTO.getAppId()); + resiLoginFormDTO.setWxCode(formDTO.getWxCode()); + Result result = epmetThirdFeignClient.resiAndWorkLogin(resiLoginFormDTO); + if (!result.success()) { + logger.error("工作端小程序登陆,调用epmet_third服务获取数据失败"); + throw new RenException(result.getCode()); + } + UserWechatDTO userWechatDTO = result.getData(); + WxMaJscode2SessionResult wxMaJscode2SessionResult = new WxMaJscode2SessionResult(); + wxMaJscode2SessionResult.setOpenid(userWechatDTO.getWxOpenId()); + wxMaJscode2SessionResult.setSessionKey(userWechatDTO.getSessionKey()); + wxMaJscode2SessionResult.setUnionid(""); + //3、记录staff_wechat,并记录用户激活状态,激活时间 this.savestaffwechat(customerStaff.getUserId(), wxMaJscode2SessionResult.getOpenid()); //4、记录登录日志 @@ -437,7 +453,7 @@ public class GovLoginServiceImpl implements GovLoginService { govTokenDto.setUserId(staffId); govTokenDto.setOpenId(wxMaJscode2SessionResult.getOpenid()); govTokenDto.setSessionKey(wxMaJscode2SessionResult.getSessionKey()); - govTokenDto.setUnionId(wxMaJscode2SessionResult.getUnionid()); + govTokenDto.setUnionId(null == wxMaJscode2SessionResult.getUnionid() ? "" : wxMaJscode2SessionResult.getUnionid()); govTokenDto.setToken(token); govTokenDto.setUpdateTime(System.currentTimeMillis()); govTokenDto.setExpireTime(jwtTokenUtils.getExpiration(token).getTime()); From 592aacb6c601cc6bab6ca71e50e9b137d21c6f39 Mon Sep 17 00:00:00 2001 From: sunyuchao Date: Fri, 24 Jul 2020 16:36:20 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E5=8D=87=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- epmet-auth/deploy/docker-compose-dev.yml | 2 +- epmet-auth/pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/epmet-auth/deploy/docker-compose-dev.yml b/epmet-auth/deploy/docker-compose-dev.yml index 8fadcbfa6d..edf73a05cc 100644 --- a/epmet-auth/deploy/docker-compose-dev.yml +++ b/epmet-auth/deploy/docker-compose-dev.yml @@ -2,7 +2,7 @@ version: "3.7" services: epmet-auth-server: container_name: epmet-auth-server-dev - image: 192.168.1.130:10080/epmet-cloud-dev/epmet-auth:0.3.47 + image: 192.168.1.130:10080/epmet-cloud-dev/epmet-auth:0.3.48 ports: - "8081:8081" network_mode: host # 使用现有网络 diff --git a/epmet-auth/pom.xml b/epmet-auth/pom.xml index 11a9728472..fb25b63090 100644 --- a/epmet-auth/pom.xml +++ b/epmet-auth/pom.xml @@ -2,7 +2,7 @@ 4.0.0 - 0.3.47 + 0.3.48 com.epmet epmet-cloud From a01057d543ae3138de9de4c585a7474e7db6c7d8 Mon Sep 17 00:00:00 2001 From: zxc <954985706@qq.com> Date: Fri, 24 Jul 2020 16:59:41 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E7=AC=AC=E4=B8=89?= =?UTF-8?q?=E6=96=B9=E5=B9=B3=E5=8F=B0-=E6=8E=88=E6=9D=83=E5=9B=9E?= =?UTF-8?q?=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/epmet/dto/form/OpenAppIdFormDTO.java | 20 +++++ .../com/epmet/dto/form/RemoveBindFormDTO.java | 26 +++++++ .../AppLetAuthorizationController.java | 27 +++++++ .../java/com/epmet/dao/BindingAccountDao.java | 9 +++ .../java/com/epmet/dao/CustomerMpDao.java | 10 ++- .../main/java/com/epmet/redis/RedisThird.java | 11 +++ .../service/AppLetAuthorizationService.java | 18 +++++ .../impl/AppLetAuthorizationServiceImpl.java | 78 +++++++++++++++++++ .../ComponentVerifyTicketServiceImpl.java | 8 +- .../wxapi/constant/WxMaCodeConstant.java | 10 +++ .../resources/mapper/BindingAccountDao.xml | 9 +++ .../main/resources/mapper/CustomerMpDao.xml | 19 ++++- 12 files changed, 236 insertions(+), 9 deletions(-) create mode 100644 epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/OpenAppIdFormDTO.java create mode 100644 epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/RemoveBindFormDTO.java diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/OpenAppIdFormDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/OpenAppIdFormDTO.java new file mode 100644 index 0000000000..ddd36a2376 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/OpenAppIdFormDTO.java @@ -0,0 +1,20 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author zxc + * @CreateTime 2020/7/24 16:31 + */ +@Data +public class OpenAppIdFormDTO implements Serializable { + + private static final long serialVersionUID = 4181403694668558506L; + + /** + * 客户端类型 + */ + private String clientType; +} diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/RemoveBindFormDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/RemoveBindFormDTO.java new file mode 100644 index 0000000000..c83dbcc97b --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/RemoveBindFormDTO.java @@ -0,0 +1,26 @@ +package com.epmet.dto.form; + +import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Author zxc + * @CreateTime 2020/7/23 9:09 + */ +@Data +public class RemoveBindFormDTO implements Serializable { + + private static final long serialVersionUID = 1920195626466407047L; + + public interface RemoveBind extends CustomerClientShowGroup {} + + /** + * 客户端类型 resi:居民端 , work:工作端 + */ + @NotBlank(message = "客户端类型不能为空",groups = {RemoveBindFormDTO.RemoveBind.class}) + private String clientType; + +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/AppLetAuthorizationController.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/AppLetAuthorizationController.java index 45c8a65cb4..34d3d87cf2 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/AppLetAuthorizationController.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/AppLetAuthorizationController.java @@ -5,6 +5,8 @@ import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.dto.form.GoToAuthFormDTO; +import com.epmet.dto.form.OpenAppIdFormDTO; +import com.epmet.dto.form.RemoveBindFormDTO; import com.epmet.dto.result.GoToAuthResultDTO; import com.epmet.service.AppLetAuthorizationService; import org.springframework.beans.factory.annotation.Autowired; @@ -36,4 +38,29 @@ public class AppLetAuthorizationController { return new Result().ok(goToAuthResultDTO); } + /** + * @Description 将公众号/小程序从开放平台帐号下解绑 + * @param tokenDto + * @param formDTO + * @author zxc + */ + @PostMapping("removeBind") + public Result removeBind(@LoginUser TokenDto tokenDto , @RequestBody RemoveBindFormDTO formDTO){ + ValidatorUtils.validateEntity(formDTO,RemoveBindFormDTO.RemoveBind.class); + appLetAuthorizationService.removeBind(tokenDto,formDTO); + return new Result(); + } + + /** + * @Description 查看小程序绑定的开放平台账号 + * @param tokenDto + * @param formDTO + * @author zxc + */ + @PostMapping("getopenappidbyauthappid") + public Result getOpenAppId(@LoginUser TokenDto tokenDto , @RequestBody OpenAppIdFormDTO formDTO){ + String openAppId = appLetAuthorizationService.getOpenAppId(tokenDto, formDTO); + return new Result().ok(openAppId); + } + } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/BindingAccountDao.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/BindingAccountDao.java index 4ea9771d2c..2d6b624400 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/BindingAccountDao.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/BindingAccountDao.java @@ -21,6 +21,7 @@ import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.dto.form.BindingAccountFormDTO; import com.epmet.entity.BindingAccountEntity; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; /** * 公众号/小程序绑定开放平台帐号表 @@ -37,5 +38,13 @@ public interface BindingAccountDao extends BaseDao { * @author zxc */ void insertBindingAccount(BindingAccountFormDTO formDTO); + + /** + * @Description 更新绑定状态 + * @param customerId + * @param authAppId + * @author zxc + */ + void updateBindStatus(@Param("customerId")String customerId,@Param("authAppId")String authAppId); } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/CustomerMpDao.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/CustomerMpDao.java index ae1fb6ebf7..3b3a4ee9b8 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/CustomerMpDao.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/CustomerMpDao.java @@ -58,7 +58,7 @@ public interface CustomerMpDao extends BaseDao { * @param customerId * @author zxc */ - List selectAuthCount(@Param("customerId")String customerId); + Integer selectAuthCount(@Param("customerId")String customerId); /** * @Description 回填customer_mp的appId @@ -115,4 +115,12 @@ public interface CustomerMpDao extends BaseDao { * @author zxc */ Integer checkBind(String authAppId,String clientType); + + /** + * @Description 根据客户Id和客户端类型查询AppId + * @param customerId + * @param clientType + * @author zxc + */ + String getAppId(@Param("customerId")String customerId,@Param("clientType")String clientType); } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/redis/RedisThird.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/redis/RedisThird.java index e367e13227..50de85c556 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/redis/RedisThird.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/redis/RedisThird.java @@ -126,4 +126,15 @@ public class RedisThird { redisUtils.hMSet(key, map,NOT_EXPIRE); } + /** + * @Description 获取授权信息 + * @param customerId + * @param clientType + * @author zxc + */ + public Map getAuthInfo(String customerId,String clientType){ + String key = ThirdRedisKeyConstant.AUTH_INFO_REDIS_KEY + customerId + ThirdRedisKeyConstant.COLON + clientType; + return redisUtils.hGetAll(key); + } + } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/AppLetAuthorizationService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/AppLetAuthorizationService.java index 30fa445a54..abb8f4bfbd 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/AppLetAuthorizationService.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/AppLetAuthorizationService.java @@ -2,6 +2,8 @@ package com.epmet.service; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.dto.form.GoToAuthFormDTO; +import com.epmet.dto.form.OpenAppIdFormDTO; +import com.epmet.dto.form.RemoveBindFormDTO; import com.epmet.dto.result.GoToAuthResultDTO; /** @@ -17,4 +19,20 @@ public interface AppLetAuthorizationService { */ GoToAuthResultDTO goToAuth(TokenDto tokenDto, GoToAuthFormDTO formDTO); + /** + * @Description 将公众号/小程序从开放平台帐号下解绑 + * @param tokenDto + * @param formDTO + * @author zxc + */ + void removeBind(TokenDto tokenDto, RemoveBindFormDTO formDTO); + + /** + * @Description 查看小程序绑定的开放平台账号 + * @param tokenDto + * @param formDTO + * @author zxc + */ + String getOpenAppId(TokenDto tokenDto, OpenAppIdFormDTO formDTO); + } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/AppLetAuthorizationServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/AppLetAuthorizationServiceImpl.java index a80fe2b76a..db41634212 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/AppLetAuthorizationServiceImpl.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/AppLetAuthorizationServiceImpl.java @@ -1,9 +1,22 @@ 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.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.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.redis.RedisThird; import com.epmet.service.AppLetAuthorizationService; import com.epmet.service.ComponentVerifyTicketService; 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.stereotype.Service; +import java.util.Map; + /** * @Author zxc * @CreateTime 2020/7/10 15:52 @@ -24,6 +39,17 @@ public class AppLetAuthorizationServiceImpl implements AppLetAuthorizationServic private PaCustomerAgencyDao paCustomerAgencyDao; @Autowired 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}") private String componentAppId; @@ -44,4 +70,56 @@ public class AppLetAuthorizationServiceImpl implements AppLetAuthorizationServic result.setUrl(authUrl); 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 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 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 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(); + } } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ComponentVerifyTicketServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ComponentVerifyTicketServiceImpl.java index 69302821e7..4bcf98a9e3 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ComponentVerifyTicketServiceImpl.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ComponentVerifyTicketServiceImpl.java @@ -525,12 +525,12 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe boolean bindStatus = bindInfo.containsKey(ModuleConstant.OPEN_APP_ID); if (bindStatus != true) { log.info(CREATE_AND_BIND_SUCCESS); - List authCount = customerMpDao.selectAuthCount(customerId); + Integer authCount = customerMpDao.selectAuthCount(customerId); String openPlatformId = null; - if (authCount.size() > 0) { + if (authCount > 0) { openPlatformId = openPlatformAccountDao.selectOpenAppIdByCustomerId(customerId); } - if (authCount.size() == NumConstant.ZERO) { + if (authCount == NumConstant.ZERO) { log.info("未查询到该客户授权信息,先创建开放平台账号,再绑定"); //没有任何一个小程序/公众号授权,【先创建,再绑定】 JSONObject jsonObject = new JSONObject(); @@ -560,7 +560,7 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe case ModuleConstant.EIGHTY_NINE_THOUSAND: throw new RenException(ACCOUNT_HAS_BOUND_OPEN); } - } else if (authCount.size() > NumConstant.ZERO && !authCount.contains(authAppId)) { + } else if (authCount > NumConstant.ZERO) { log.info("该客户已创建过开放平台账号,直接绑定"); JSONObject jsonObject = new JSONObject(); jsonObject.put(ModuleConstant.LOW_APP_ID, authAppId); diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/constant/WxMaCodeConstant.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/constant/WxMaCodeConstant.java index 8ec83ac350..9302f876ff 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/constant/WxMaCodeConstant.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/constant/WxMaCodeConstant.java @@ -56,6 +56,16 @@ public interface WxMaCodeConstant { */ String API_BIND_OPEN = "https://api.weixin.qq.com/cgi-bin/open/bind?access_token="; + /** + *公众号/小程序从开放平台帐号下解绑 + */ + String UN_BIND = "https://api.weixin.qq.com/cgi-bin/open/unbind?access_token="; + + /** + * 获取公众号/小程序所绑定的开放平台帐号 + */ + String OPEN_GET = "https://api.weixin.qq.com/cgi-bin/open/get?access_token="; + /** * 获取授权方的帐号基本信息 */ diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/BindingAccountDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/BindingAccountDao.xml index d0d3d49815..c745f40578 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/BindingAccountDao.xml +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/BindingAccountDao.xml @@ -21,4 +21,13 @@ NOW() ) + + + + UPDATE binding_account + SET del_flag = 1 + WHERE + customer_id = #{customerId} + AND client_type = #{clientType} + \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CustomerMpDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CustomerMpDao.xml index f4e6b6403a..cd54689027 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CustomerMpDao.xml +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CustomerMpDao.xml @@ -19,15 +19,14 @@ client ASC - SELECT app_id AS authAppId FROM - customer_mp + open_platform_account WHERE - del_flag = '0' + del_flag = 0 AND customer_id = #{customerId} - AND authorization_flag = 1 @@ -127,4 +126,16 @@ AND client != #{clientType} + + + \ No newline at end of file From 0ba119a8729a4bf42f64c6c38c4605c874e4b59a Mon Sep 17 00:00:00 2001 From: zxc <954985706@qq.com> Date: Fri, 24 Jul 2020 17:01:36 +0800 Subject: [PATCH 4/4] =?UTF-8?q?epmet-third=E6=9C=8D=E5=8A=A1=E5=8D=87?= =?UTF-8?q?=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epmet-third-server/deploy/docker-compose-dev.yml | 2 +- epmet-module/epmet-third/epmet-third-server/pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/epmet-module/epmet-third/epmet-third-server/deploy/docker-compose-dev.yml b/epmet-module/epmet-third/epmet-third-server/deploy/docker-compose-dev.yml index 62b4f74e2e..fa21816242 100644 --- a/epmet-module/epmet-third/epmet-third-server/deploy/docker-compose-dev.yml +++ b/epmet-module/epmet-third/epmet-third-server/deploy/docker-compose-dev.yml @@ -2,7 +2,7 @@ version: "3.7" services: epmet-third-server: container_name: epmet-third-server-dev - image: 192.168.1.130:10080/epmet-cloud-dev/epmet-third-server:0.0.56 + image: 192.168.1.130:10080/epmet-cloud-dev/epmet-third-server:0.0.57 ports: - "8110:8110" network_mode: host # 使用现有网络 diff --git a/epmet-module/epmet-third/epmet-third-server/pom.xml b/epmet-module/epmet-third/epmet-third-server/pom.xml index ffe5d338fd..09f02070aa 100644 --- a/epmet-module/epmet-third/epmet-third-server/pom.xml +++ b/epmet-module/epmet-third/epmet-third-server/pom.xml @@ -2,7 +2,7 @@ 4.0.0 - 0.0.56 + 0.0.57 com.epmet