|
@@ -76,5 +76,31 @@ public class WxController {
|
|
|
}
|
|
|
return ResponseBeanBuilder.ok();
|
|
|
}
|
|
|
+ @ApiOperation(value = "检测用户是否绑定微信")
|
|
|
+ @PostMapping("/bind/check")
|
|
|
+ public ResponseBean bindWechatUserCheck(@RequestBody UserBindReq userBindReq, HttpServletResponse response, HttpServletRequest request) throws Throwable {
|
|
|
+ Integer checked = 0;//默认为绑定
|
|
|
+ try {
|
|
|
+ response.setContentType("text/html");
|
|
|
+ request.setCharacterEncoding("UTF-8");
|
|
|
+ response.setCharacterEncoding("UTF-8");
|
|
|
+ Map params = new HashMap();
|
|
|
+ params.put("secret", appsecret);
|
|
|
+ params.put("appid", appid);
|
|
|
+ params.put("grant_type", "authorization_code");
|
|
|
+ params.put("js_code", userBindReq.getCode());
|
|
|
+ params.put("connect_redirect", "1");
|
|
|
+ String result = HttpCilentUntil.httpGetToString(
|
|
|
+ "https://api.weixin.qq.com/sns/jscode2session", params);
|
|
|
+ JSONObject jsonObject = JSON.parseObject(result);
|
|
|
+ String openid = jsonObject.get("openid").toString();
|
|
|
+
|
|
|
+ Long userId = (Long) request.getAttribute("LOGIN_USER_ID");//获取用户id
|
|
|
+ checked = wxService.selectBindWeChatUserCount(openid, userId);
|
|
|
+ } catch (Exception e) {
|
|
|
+ return ResponseBeanBuilder.fail("小程序绑定用户失败");
|
|
|
+ }
|
|
|
+ return ResponseBeanBuilder.ok(checked);
|
|
|
+ }
|
|
|
|
|
|
}
|