Merge remote-tracking branch 'origin/order_yy' into order_yy

# Conflicts:
#	hai-bweb/src/main/java/com/bweb/controller/HighTestController.java
#	hai-cweb/src/main/java/com/cweb/controller/HighTestController.java
#	hai-service/src/main/java/com/hai/common/utils/WxUtils.java
dev-discount
袁野 2 years ago
commit 2b7bd11c52
  1. 5
      hai-bweb/src/main/java/com/bweb/controller/HighTestController.java
  2. 5
      hai-cweb/src/main/java/com/cweb/controller/HighTestController.java
  3. 2
      hai-service/src/main/java/com/hai/common/utils/WxUtils.java
  4. BIN
      hai-service/src/main/java/com/hai/entity/._BsMsg.java
  5. 19
      v1/src/main/java/com/v1/config/SysConfig.java
  6. 72
      v1/src/main/java/com/v1/controller/WxMsgController.java
  7. 4
      v1/src/main/resources/dev/application.yml
  8. 3
      v1/src/main/resources/dev/config.properties

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -562,7 +562,7 @@ public class WxUtils {
sb.append(k).append("=").append(data.get(k)).append("&");
}
}
String str = sb.toString();
String str = sb.substring(0 , sb.length()-1);
// SHA1签名生成
MessageDigest md = MessageDigest.getInstance("SHA-1");
md.update(str.getBytes());

@ -12,6 +12,9 @@ public class SysConfig {
private String wxH5AppId;
private String wxH5AppSecret;
private String wxAppId;
private String wxAppSecret;
public String getWxH5AppId() {
return wxH5AppId;
}
@ -27,4 +30,20 @@ public class SysConfig {
public void setWxH5AppSecret(String wxH5AppSecret) {
this.wxH5AppSecret = wxH5AppSecret;
}
public String getWxAppId() {
return wxAppId;
}
public void setWxAppId(String wxAppId) {
this.wxAppId = wxAppId;
}
public String getWxAppSecret() {
return wxAppSecret;
}
public void setWxAppSecret(String wxAppSecret) {
this.wxAppSecret = wxAppSecret;
}
}

@ -7,6 +7,7 @@ import com.hai.common.exception.SysCode;
import com.hai.common.pay.util.IOUtil;
import com.hai.common.pay.util.XmlUtil;
import com.hai.common.utils.HttpsUtils;
import com.hai.common.utils.RedisUtil;
import com.hai.common.utils.ResponseMsgUtil;
import com.hai.common.utils.WxUtils;
import com.hai.config.CommonSysConst;
@ -33,10 +34,7 @@ import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.SortedMap;
import java.util.*;
/**
* @author sum1dream
@ -55,6 +53,9 @@ public class WxMsgController {
@Resource
private HighMerchantStoreService merchantStoreService;
@Resource
private RedisUtil redisUtil;
// @RequestMapping(value = "/verifyWxToken", method = RequestMethod.GET)
// @ResponseBody
// @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)
// @ResponseBody

@ -50,7 +50,7 @@ spring:
#客户端id(不能重复)
# client:
# id: provider-id
#MQTT默认的消息推送主题,实际可在调用接口是指定
#MQTT默认的消息推送主题,实际可在调用接口是指定
# default:
# topic: topic
rocketmq:
@ -64,7 +64,7 @@ spring:
write-dates-as-timestamps: true
mybatis:
mapperLocations:
- classpath*:sqlmap*/*.xml
- classpath*:sqlmap*/*.xml
type-aliases-package:
org.springboot.sample.entity
jetcache:

@ -1,2 +1,5 @@
wxH5AppId=wxa075e8509802f826
wxH5AppSecret=0e606fc1378d35e359fcf3f15570b2c5
wxAppId=wx8d49e2f83025229d
wxAppSecret=d8d6dcaef77d3b659258a01b5ddba5df

Loading…
Cancel
Save