| | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.xiaopeng.api.dto.account.UserResourcesDto; |
| | | import com.xiaopeng.api.feignClient.account.SSOClient; |
| | | import com.xiaopeng.api.vo.account.WechatAccessTokenResVo; |
| | | import com.xiaopeng.common.core.domain.R; |
| | | import com.xiaopeng.common.core.exception.ServiceException; |
| | | import com.xiaopeng.common.core.utils.StringUtils; |
| | |
| | | |
| | | |
| | | String getToken(Boolean isRefresh){ |
| | | UserResourcesDto wechatAccessToken = ssoClient.getWechatAccessToken(appId, wxAppletsAppid, isRefresh); |
| | | WechatAccessTokenResVo wechatAccessToken = ssoClient.getWechatAccessToken(appId, wxAppletsAppid, isRefresh); |
| | | if(null == wechatAccessToken){ |
| | | log.info("获取微信access_token失败"); |
| | | throw new ServiceException("获取微信access_token失败"); |
| | |
| | | log.info("获取微信access_token失败:{}", wechatAccessToken.getMsg()); |
| | | throw new ServiceException("获取微信access_token失败"); |
| | | } |
| | | String accessToken = JSON.parseObject(wechatAccessToken.getData().toString()).getString("accessToken"); |
| | | String accessToken = wechatAccessToken.getData().getAccessToken(); |
| | | return accessToken; |
| | | } |
| | | |
| | |
| | | HttpResponse execute = post.execute(); |
| | | if(execute.getStatus() != 200){ |
| | | log.info("发送消息失败:{}", execute.body()); |
| | | throw new RuntimeException("发送消息失败"); |
| | | return R.fail(execute.body()); |
| | | } |
| | | JSONObject jsonObject = JSON.parseObject(execute.body()); |
| | | Integer errcode = jsonObject.getInteger("errcode"); |
| | | if(0 != errcode){ |
| | | log.info("发送消息失败:{}", jsonObject.getString("errmsg")); |
| | | throw new RuntimeException(jsonObject.getString("errmsg")); |
| | | return R.fail(jsonObject.getString("errmsg")); |
| | | } |
| | | return R.ok(); |
| | | } |