|
|
@ -7,6 +7,7 @@ import com.hai.common.exception.SysCode; |
|
|
|
import com.hai.common.pay.util.IOUtil; |
|
|
|
import com.hai.common.pay.util.IOUtil; |
|
|
|
import com.hai.common.pay.util.XmlUtil; |
|
|
|
import com.hai.common.pay.util.XmlUtil; |
|
|
|
import com.hai.common.utils.HttpsUtils; |
|
|
|
import com.hai.common.utils.HttpsUtils; |
|
|
|
|
|
|
|
import com.hai.common.utils.RedisUtil; |
|
|
|
import com.hai.common.utils.ResponseMsgUtil; |
|
|
|
import com.hai.common.utils.ResponseMsgUtil; |
|
|
|
import com.hai.common.utils.WxUtils; |
|
|
|
import com.hai.common.utils.WxUtils; |
|
|
|
import com.hai.config.CommonSysConst; |
|
|
|
import com.hai.config.CommonSysConst; |
|
|
@ -33,10 +34,7 @@ import javax.annotation.Resource; |
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
|
|
|
|
|
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.*; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
import java.util.Objects; |
|
|
|
|
|
|
|
import java.util.SortedMap; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @author sum1dream |
|
|
|
* @author sum1dream |
|
|
@ -55,6 +53,9 @@ public class WxMsgController { |
|
|
|
@Resource |
|
|
|
@Resource |
|
|
|
private HighMerchantStoreService merchantStoreService; |
|
|
|
private HighMerchantStoreService merchantStoreService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
|
|
private RedisUtil redisUtil; |
|
|
|
|
|
|
|
|
|
|
|
// @RequestMapping(value = "/verifyWxToken", method = RequestMethod.GET)
|
|
|
|
// @RequestMapping(value = "/verifyWxToken", method = RequestMethod.GET)
|
|
|
|
// @ResponseBody
|
|
|
|
// @ResponseBody
|
|
|
|
// @ApiOperation(value = "验证servlet")
|
|
|
|
// @ApiOperation(value = "验证servlet")
|
|
|
@ -250,6 +251,69 @@ public class WxMsgController { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/verifyWx", method = RequestMethod.GET) |
|
|
|
|
|
|
|
@ResponseBody |
|
|
|
|
|
|
|
@ApiOperation(value = "微信签名") |
|
|
|
|
|
|
|
public ResponseData verifyWx(@RequestParam(value = "url", required = true) String url) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 获取access_token
|
|
|
|
|
|
|
|
Map<String, Object> params = new HashMap<>(); |
|
|
|
|
|
|
|
params.put("appid", SysConst.getSysConfig().getWxH5AppId()); |
|
|
|
|
|
|
|
params.put("secret", SysConst.getSysConfig().getWxH5AppSecret()); |
|
|
|
|
|
|
|
params.put("grant_type", "client_credential"); |
|
|
|
|
|
|
|
JSONObject accessTokenObject = HttpsUtils.doGet("https://api.weixin.qq.com/cgi-bin/token", params); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 获取ticket
|
|
|
|
|
|
|
|
Map<String, Object> ticketParams = new HashMap<>(); |
|
|
|
|
|
|
|
ticketParams.put("access_token", accessTokenObject.getString("access_token")); |
|
|
|
|
|
|
|
ticketParams.put("type", "jsapi"); |
|
|
|
|
|
|
|
JSONObject jsapiTicket = HttpsUtils.doGet("https://api.weixin.qq.com/cgi-bin/ticket/getticket", ticketParams); |
|
|
|
|
|
|
|
// 拼接签名
|
|
|
|
|
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
|
|
|
|
map.put("noncestr", WxUtils.makeNonStr()); |
|
|
|
|
|
|
|
map.put("jsapi_ticket",jsapiTicket.getString("ticket")); |
|
|
|
|
|
|
|
map.put("timestamp", new Date().getTime()); |
|
|
|
|
|
|
|
map.put("url",url); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> objectMap = new HashMap<>(); |
|
|
|
|
|
|
|
objectMap.put("appId" , SysConst.getSysConfig().getWxH5AppId()); |
|
|
|
|
|
|
|
objectMap.put("timestamp" , map.get("timestamp")); |
|
|
|
|
|
|
|
objectMap.put("nonceStr" , map.get("noncestr")); |
|
|
|
|
|
|
|
objectMap.put("signature" , WxUtils.getSHA1(map)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ResponseMsgUtil.success(objectMap); |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/getScheme", method = RequestMethod.GET) |
|
|
|
|
|
|
|
@ResponseBody |
|
|
|
|
|
|
|
@ApiOperation(value = "获取小程序scheme码") |
|
|
|
|
|
|
|
public ResponseData getSchemeCode() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 获取access_token
|
|
|
|
|
|
|
|
Map<String, Object> params = new HashMap<>(); |
|
|
|
|
|
|
|
params.put("appid", SysConst.getSysConfig().getWxAppId()); |
|
|
|
|
|
|
|
params.put("secret", SysConst.getSysConfig().getWxAppSecret()); |
|
|
|
|
|
|
|
params.put("grant_type", "client_credential"); |
|
|
|
|
|
|
|
JSONObject accessTokenObject = HttpsUtils.doGet("https://api.weixin.qq.com/cgi-bin/token", params); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JSONObject postObject = new JSONObject(); |
|
|
|
|
|
|
|
postObject.put("expire_type" ,1); |
|
|
|
|
|
|
|
postObject.put("expire_interval" ,30); |
|
|
|
|
|
|
|
JSONObject object = HttpsUtils.doPost("https://api.weixin.qq.com/wxa/generate_urllink?access_token=" + accessTokenObject.getString("access_token"), postObject); |
|
|
|
|
|
|
|
return ResponseMsgUtil.success(object); |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// @RequestMapping(value = "/verifyWx", method = RequestMethod.GET)
|
|
|
|
// @RequestMapping(value = "/verifyWx", method = RequestMethod.GET)
|
|
|
|
// @ResponseBody
|
|
|
|
// @ResponseBody
|
|
|
|