Browse Source

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

dev_shibei_match
zxc 5 years ago
parent
commit
5b34f79ae4
  1. 4
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/ComponentVerifyTicketDao.java
  2. 7
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/OpenPlatformAccountDao.java
  3. 16
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ComponentVerifyTicketServiceImpl.java
  4. 7
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/constant/WxMaCodeConstant.java
  5. 6
      epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/ComponentVerifyTicketDao.xml
  6. 5
      epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/OpenFlatformAccountDao.xml

4
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/ComponentVerifyTicketDao.java

@ -39,10 +39,10 @@ public interface ComponentVerifyTicketDao extends BaseDao<ComponentVerifyTicketE
void insertComponentVerifyTicket(ComponentVerifyTicketFormDTO formDTO); void insertComponentVerifyTicket(ComponentVerifyTicketFormDTO formDTO);
/** /**
* @Description 逻辑删除 component_verify_ticket * @Description 物理删除 component_verify_ticket
* @param * @param
* @author zxc * @author zxc
*/ */
void updateOldComponentVerifyTicket(); void deleteOldComponentVerifyTicket();
} }

7
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/OpenPlatformAccountDao.java

@ -41,6 +41,13 @@ public interface OpenPlatformAccountDao extends BaseDao<OpenPlatformAccountEntit
*/ */
void insertOpenPlatFormAccount(CreateOpenFormDTO coForm); void insertOpenPlatFormAccount(CreateOpenFormDTO coForm);
/**
* @Description 删除客户下报废的开放平台账号信息
* @param customerId
* @author zxc
*/
void deleteOldOpenPlatFprmAccount(@Param("customerId")String customerId);
/** /**
* @Description 根据客户Id查询已绑定开放平台的账号ID * @Description 根据客户Id查询已绑定开放平台的账号ID
* @param customerId * @param customerId

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

@ -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,14 +509,20 @@ 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);
String authorizerAccessToken = authorizerRefreshToken.get("authorizerAccessToken").toString();
if (authCount.size() == NumConstant.ZERO) { if (authCount.size() == NumConstant.ZERO) {
log.info("未查询到该客户授权信息,先创建开放平台账号,再绑定"); log.info("未查询到该客户授权信息,先创建开放平台账号,再绑定");
//没有任何一个小程序/公众号授权,【先创建,再绑定】 //没有任何一个小程序/公众号授权,【先创建,再绑定】
@ -537,6 +543,7 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
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:
@ -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

7
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/constant/WxMaCodeConstant.java

@ -40,6 +40,8 @@ public interface WxMaCodeConstant {
* component_appid:第三方AppId * component_appid:第三方AppId
* pre_auth_code预授权码 * pre_auth_code预授权码
* redirect_uri回调url获取授权码 * redirect_uri回调url获取授权码
* 上面url为扫码形式
* 下面注释url为按钮形式
*/ */
String API_AUTH_REGISTER_URL = "https://mp.weixin.qq.com/cgi-bin/componentloginpage?component_appid=%s&pre_auth_code=%s&redirect_uri=%s"; String API_AUTH_REGISTER_URL = "https://mp.weixin.qq.com/cgi-bin/componentloginpage?component_appid=%s&pre_auth_code=%s&redirect_uri=%s";
// String API_AUTH_REGISTER_URL = "https://mp.weixin.qq.com/safe/bindcomponent?action=bindcomponent&auth_type=3&no_scan=1&component_appid=%s&pre_auth_code=%s&redirect_uri=%s#wechat_redirect"; // String API_AUTH_REGISTER_URL = "https://mp.weixin.qq.com/safe/bindcomponent?action=bindcomponent&auth_type=3&no_scan=1&component_appid=%s&pre_auth_code=%s&redirect_uri=%s#wechat_redirect";
@ -59,6 +61,11 @@ public interface WxMaCodeConstant {
*/ */
String API_GET_AUTHORIZER_INFO = "https://api.weixin.qq.com/cgi-bin/component/api_get_authorizer_info?component_access_token="; String API_GET_AUTHORIZER_INFO = "https://api.weixin.qq.com/cgi-bin/component/api_get_authorizer_info?component_access_token=";
/**
* 获取公众号/小程序所绑定的开放平台帐号
*/
String API_OPEN_GET = "https://api.weixin.qq.com/cgi-bin/open/get?access_token=";
/** /**
* 为授权的小程序帐号上传小程序代码. * 为授权的小程序帐号上传小程序代码.
*/ */

6
epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/ComponentVerifyTicketDao.xml

@ -21,9 +21,9 @@
</insert> </insert>
<!-- 逻辑删除 【component_verify_ticket】 --> <!-- 逻辑删除 【component_verify_ticket】 -->
<update id="updateOldComponentVerifyTicket"> <delete id="deleteOldComponentVerifyTicket">
update component_verify_ticket set del_flag = 1 DELETE FROM component_verify_ticket WHERE del_flag = 0
</update> </delete>
</mapper> </mapper>

5
epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/OpenFlatformAccountDao.xml

@ -23,6 +23,11 @@
) )
</insert> </insert>
<!-- 删除客户下报废的开放平台账号信息 -->
<update id="deleteOldOpenPlatFprmAccount">
UPDATE open_platform_account set del_flag = 1 where customer_id = #{customerId}
</update>
<!-- 根据客户Id查询已绑定开放平台的账号ID --> <!-- 根据客户Id查询已绑定开放平台的账号ID -->
<select id="selectOpenAppIdByCustomerId" resultType="java.lang.String"> <select id="selectOpenAppIdByCustomerId" resultType="java.lang.String">
SELECT SELECT

Loading…
Cancel
Save