Browse Source

微信二维码

trick9191 6 years ago
parent
commit
4ef9a787d8

+ 7 - 7
svr/svr-base/pom.xml

@ -92,30 +92,30 @@
            <groupId>com.yihu.jw</groupId>
            <artifactId>common-web</artifactId>
        </dependency>
        <!-- Jzkl Starter -->
        <!-- 文件服务器 -->
        <dependency>
            <groupId>com.yihu</groupId>
            <artifactId>swagger-starter</artifactId>
            <artifactId>fastdfs-starter</artifactId>
            <version>2.0.0</version>
        </dependency>
        <!-- Jzkl Starter -->
        <dependency>
            <groupId>com.yihu</groupId>
            <artifactId>mysql-starter</artifactId>
            <artifactId>swagger-starter</artifactId>
            <version>2.0.0</version>
        </dependency>
        <dependency>
            <groupId>com.yihu</groupId>
            <artifactId>elasticsearch-starter</artifactId>
            <artifactId>mysql-starter</artifactId>
            <version>2.0.0</version>
        </dependency>
        <!-- 文件服务器 -->
        <dependency>
            <groupId>com.yihu</groupId>
            <artifactId>fastdfs-starter</artifactId>
            <artifactId>elasticsearch-starter</artifactId>
            <version>2.0.0</version>
        </dependency>
    </dependencies>
    <build>

+ 1 - 1
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/wx/WeChatQrcodeController.java

@ -26,7 +26,7 @@ public class WeChatQrcodeController extends EnvelopRestEndpoint {
    @Autowired
    private WeChatQrcodeService weChatQrcodeService;
    @PostMapping(value = WechatRequestMapping.WxMenu.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @PostMapping(value = WechatRequestMapping.WxQrcode.api_getQrcode, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "生成微信二维码", notes = "生成微信二维码")
    public Envelop getQrcode(@ApiParam(name = "wxId", value = "微信id")
                             @RequestParam(value = "wxId", required = true)String wxId,

+ 4 - 2
svr/svr-base/src/main/java/com/yihu/jw/base/service/wx/WeChatQrcodeService.java

@ -26,8 +26,10 @@ public class WeChatQrcodeService {
    private WxAccessTokenService wxAccessTokenService;
    public String getQrcode(String wechatId,String scene) throws Exception{
        String token_url = "https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=" + wxAccessTokenService.getWxAccessTokenById(wechatId);
        String token_url = "https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=" + wxAccessTokenService.getWxAccessTokenById(wechatId).getAccessToken();
        String params = "{\"action_name\": \"QR_LIMIT_STR_SCENE\", \"action_info\": {\"scene\": {\"scene_str\": \"" + scene + "\"}}}";
        //服务号必须是通过腾讯认证,每年是300元,如果没有认证而导致的错误提示,那就去认证
        //微信登录提示48001,{"errcode":48001,"errmsg":"api unauthorized, hints: [ req_id: 1QoCla0699ns81 ]"}
        String result = HttpUtil.sendPost(token_url, params);
        if (!StringUtils.isEmpty(result)) {
@ -46,6 +48,6 @@ public class WeChatQrcodeService {
            }
        }
        return null;
        return "";
    }
}