|
@@ -234,21 +234,26 @@ public class WxPayServiceImpl implements WxPayService {
|
|
|
return "success";
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
- public String chargePage(String userId, String code, String domain) {
|
|
|
- User userByUserId = userService.getUserByUserId(Long.parseLong(userId));
|
|
|
- Integer channelId = userByUserId.getChannelId();
|
|
|
- AdminConfig adminConfig = adminConfigMapper.selectByPrimaryKey(channelId);
|
|
|
+ public String chargePage(String userId, String channelId, String redirectUrl, String redirectId, String state, String code) {
|
|
|
+
|
|
|
+
|
|
|
+ AdminConfig adminConfig = adminConfigMapper.selectByPrimaryKey(Integer.valueOf(channelId));
|
|
|
Integer wxpayId = adminConfig.getWxpayId();
|
|
|
Wxpay wxpay = wxpayMapper.selectByPrimaryKey(wxpayId);
|
|
|
String appid = wxpay.getAppid();
|
|
|
String secret = wxpay.getSecret();
|
|
|
String host = wxpay.getPayHost();
|
|
|
if (StringUtils.isEmpty(code)) {
|
|
|
- String redirectUrl = "http://" + host + "/api/wxpay/login?userId=" + userId;
|
|
|
+ String params = "userId=%s&channelId=%s&redirectUrl=%s&redirectId=%s";
|
|
|
+ params = String.format(params,userId,channelId,redirectUrl,redirectId);
|
|
|
+
|
|
|
+ String oau2thRedirectUrl = "http://" + host + "/api/wxpay/login?" +params;
|
|
|
String url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=%s&redirect_uri=%s&response_type=code&scope=snsapi_base&state=%s#wechat_redirect";
|
|
|
try {
|
|
|
- url = String.format(url, appid, java.net.URLEncoder.encode(redirectUrl, "UTF-8"), userId);
|
|
|
+ url = String.format(url, appid, java.net.URLEncoder.encode(oau2thRedirectUrl, "UTF-8"), userId);
|
|
|
} catch (UnsupportedEncodingException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
@@ -262,10 +267,7 @@ public class WxPayServiceImpl implements WxPayService {
|
|
|
String s = HttpUtils.sendGet(format);
|
|
|
SnsapiBase object = JsonUtils.getObject(s, SnsapiBase.class);
|
|
|
String openid = object.getOpenid();
|
|
|
- String url = Const.URL_PAY_CENTER
|
|
|
- .replace("{host}", wxpay.getPayHost())
|
|
|
- .replace("userId", userId)
|
|
|
- .replace("{openid}", openid);
|
|
|
+ String url =String.format( Const.URL_PAY_CENTER,wxpay.getPayHost(),userId,channelId,redirectUrl,redirectId,openid);
|
|
|
return "redirect:" + url;
|
|
|
}
|
|
|
|