|
@@ -77,6 +77,7 @@ public class WxPayServiceImpl implements WxPayService {
|
|
|
Integer wxpayId = adminConfig.getWxpayId();
|
|
|
Wxpay wxpay = wxpayMapper.selectByPrimaryKey(wxpayId);
|
|
|
String appid = wxpay.getAppid();
|
|
|
+ appid = adminConfig.getAppid();
|
|
|
String secret = wxpay.getSecret();
|
|
|
String host = wxpay.getPayHost();
|
|
|
String palmpayAppid = wxpay.getQuartetAppId();
|
|
@@ -137,7 +138,7 @@ public class WxPayServiceImpl implements WxPayService {
|
|
|
map.put("notifyUrl", url + "/api/wxpay/notify");
|
|
|
map.put("ip", wxPayRequest.getIp());
|
|
|
|
|
|
- map.put("api", "1");
|
|
|
+
|
|
|
|
|
|
|
|
|
String str = palmpayAppid + "WECHAT_SUB" + amount + mchOrderid + palmpayAppkey;
|
|
@@ -152,9 +153,9 @@ public class WxPayServiceImpl implements WxPayService {
|
|
|
wxPayInfo.setUserId(userByUserId.getId() + "");
|
|
|
wxPayInfo.setOrderId(String.valueOf(order.getId()));
|
|
|
if ( StringUtils.isNotEmpty(wxPayRequest.getOpenid())) {
|
|
|
- map.put("subAppid", wxpay.getAppid()==null?"":wxpay.getAppid());
|
|
|
+ map.put("subAppid", appid==null?"":appid);
|
|
|
map.put("openid", wxPayRequest.getOpenid());
|
|
|
-
|
|
|
+ map.put("api", "1");
|
|
|
String result = HTTPSUtil.sendGetByHttps(PALMPAY_URL, map);
|
|
|
System.out.println("响应:" + result);
|
|
|
PalmpayResponse object = JsonUtils.getObject(result, PalmpayResponse.class);
|
|
@@ -169,11 +170,17 @@ public class WxPayServiceImpl implements WxPayService {
|
|
|
updateOrder.setId(order.getId());
|
|
|
updateOrder.setPdorderid(r.getPdorderid());
|
|
|
String pay_info = r.getPay_info();
|
|
|
+
|
|
|
+
|
|
|
updateOrder.setPayJson(pay_info);
|
|
|
+ if(pay_info.startsWith("http")){
|
|
|
+ wxPayInfo.setUrl(PALMPAY_URL + "?" + form);
|
|
|
+ }else {
|
|
|
+ Map<String, Object> map1 = JsonUtils.getMap(pay_info);
|
|
|
+ wxPayInfo.setPayInfo(map1);
|
|
|
+ wxPayInfo.setUrl("");
|
|
|
+ }
|
|
|
|
|
|
- Map<String, Object> map1 = JsonUtils.getMap(pay_info);
|
|
|
- wxPayInfo.setPayInfo(map1);
|
|
|
- wxPayInfo.setUrl("");
|
|
|
|
|
|
} else {
|
|
|
wxPayInfo.setUrl(PALMPAY_URL + "?" + form);
|
|
@@ -240,12 +247,23 @@ public class WxPayServiceImpl implements WxPayService {
|
|
|
|
|
|
|
|
|
@Override
|
|
|
- public String chargePage(String userId, String channelId, String redirectUrl, String redirectId, String state, String code) {
|
|
|
+ public String chargePage(String userId, String channelId, String redirectUrl, String redirectId, String state, String code,String openid) {
|
|
|
|
|
|
|
|
|
AdminConfig adminConfig = adminConfigMapper.selectByPrimaryKey(Integer.valueOf(channelId));
|
|
|
Integer wxpayId = adminConfig.getWxpayId();
|
|
|
Wxpay wxpay = wxpayMapper.selectByPrimaryKey(wxpayId);
|
|
|
+ boolean newpay = true;
|
|
|
+ if (newpay){
|
|
|
+ if (StringUtils.isEmpty(openid)){
|
|
|
+ User userByUserId = userService.getUserByUserId(Long.parseLong(userId));
|
|
|
+ openid = userByUserId.getOpenid();
|
|
|
+ }
|
|
|
+ String url =String.format( Const.URL_PAY_CENTER,wxpay.getPayHost(),userId,channelId,redirectUrl,redirectId,openid);
|
|
|
+ return "redirect:" + url;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
String appid = wxpay.getAppid();
|
|
|
String secret = wxpay.getSecret();
|
|
|
String host = wxpay.getPayHost();
|
|
@@ -269,7 +287,7 @@ public class WxPayServiceImpl implements WxPayService {
|
|
|
String format = String.format(openidUrl, appid, secret, code);
|
|
|
String s = HttpUtils.sendGet(format);
|
|
|
SnsapiBase object = JsonUtils.getObject(s, SnsapiBase.class);
|
|
|
- String openid = object.getOpenid();
|
|
|
+ openid = object.getOpenid();
|
|
|
String url =String.format( Const.URL_PAY_CENTER,wxpay.getPayHost(),userId,channelId,redirectUrl,redirectId,openid);
|
|
|
return "redirect:" + url;
|
|
|
}
|