Skip to content

Commit

Permalink
add annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
sqmax committed Sep 21, 2018
1 parent 2598c3d commit fa54405
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/main/java/com/imooc/controller/WechatController.java
Expand Up @@ -42,12 +42,11 @@ public String authorize(@RequestParam("returnUrl") String returnUrl){
String url=projectUrlConfig.getWechatMpAuthorize()+"/sell/wechat/userInfo";
String redirectUrl=wxMpService.oauth2buildAuthorizationUrl(url,WxConsts.OAUTH2_SCOPE_BASE, URLEncoder.encode(returnUrl));
log.info("【微信网页授权】获取code,redirectUrl={}",redirectUrl);
return "redirect:"+redirectUrl;
return "redirect:"+redirectUrl;//重定向到下面一个方法
}
@GetMapping("/userInfo")
public String userInfo(@RequestParam("code") String code,
@RequestParam("state") String returnUrl){
log.info("hello");
WxMpOAuth2AccessToken wxMpOAuth2AccessToken=new WxMpOAuth2AccessToken();
try {
wxMpOAuth2AccessToken=wxMpService.oauth2getAccessToken(code);
Expand All @@ -59,8 +58,11 @@ public String userInfo(@RequestParam("code") String code,
log.info("【微信网页授权】获取openid,returnUrl={}",returnUrl);
return "redirect:"+ returnUrl+"?openid="+openId;

}
}//以上两个方法是SDK方式微信网页授权的过程,
// 访问http://sqmax.natapp1.cc/sell/wechat/authorize?returnUrl=http://www.imooc.com,
//最终将会跳转到这个链接:http://www.imooc.com?openid={openid}

//微信登陆
@GetMapping("/qrAuthorize")
public String qrAuthorize(@RequestParam("returnUrl") String returnUrl){
String url=projectUrlConfig.getWechatOpenAuthorize()+"/sell/wechat/userInfo";
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/imooc/service/impl/PayServiceImpl.java
Expand Up @@ -58,7 +58,7 @@ public PayResponse notify(String notifyData) {
//2.支付状态
//3. 支付金额
//4. 支付人(下单人==支付人)
PayResponse payResponse=bestPayService.asyncNotify(notifyData);
PayResponse payResponse=bestPayService.asyncNotify(notifyData);//可以完成1、2两步
log.info("【微信支付 异步通知】,payResponse={}",JsonUtil.toJson(payResponse));

//查询订单
Expand Down

0 comments on commit fa54405

Please sign in to comment.