微信密钥

This commit is contained in:
clunt 2022-05-23 09:53:14 +08:00
parent d0016e9d16
commit 65b3680c49
2 changed files with 19 additions and 2 deletions

View File

@ -10,6 +10,8 @@ import com.ghy.common.utils.WxUtils;
import com.ghy.common.utils.http.HttpUtils;
import com.ghy.customer.domain.Customer;
import com.ghy.customer.service.CustomerService;
import com.ghy.system.domain.SysDeptConfig;
import com.ghy.system.service.ISysDeptConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
@ -32,6 +34,9 @@ public class WxController extends BaseController {
@Autowired
private WxConfig wxConfig;
@Autowired
private ISysDeptConfigService sysDeptConfigService;
@Autowired
private CustomerService customerService;
@ -76,8 +81,16 @@ public class WxController extends BaseController {
@GetMapping("/auth")
@ResponseBody
public AjaxResult auth(HttpServletRequest request) {
String url;
String deptId = request.getHeader("deptId");
String from = request.getHeader("from");
SysDeptConfig sysDeptConfig = sysDeptConfigService.selectByDeptId(Long.parseLong(deptId));
String code = request.getHeader("code");
String url = "https://api.weixin.qq.com/sns/jscode2session?appid=" + wxConfig.getAppId() + "&secret=" + wxConfig.getSecret() + "&js_code=" + code + "&grant_type=authorization_code";
if("customer".equals(from)){
url = "https://api.weixin.qq.com/sns/jscode2session?appid=" + sysDeptConfig.getWxAppId() + "&secret=" + sysDeptConfig.getWxSecret() + "&js_code=" + code + "&grant_type=authorization_code";
}else {
url = "https://api.weixin.qq.com/sns/jscode2session?appid=" + sysDeptConfig.getServWxAppId() + "&secret=" + sysDeptConfig.getServWxSecret() + "&js_code=" + code + "&grant_type=authorization_code";
}
String data = HttpUtils.sendGet(url, null);
JSONObject result = JSONObject.parseObject(data);
return AjaxResult.success(result);

View File

@ -30,10 +30,14 @@ public class SysDeptConfig extends BaseEntity {
private String adapayRsaPrivateKey;
private String adapayMaxRetryTimes;
//微信配置
//微信消费者端配置
private String wxAppId;
private String wxSecret;
//微信师傅端配置
private String servWxAppId;
private String servWxSecret;
//平台扣点比例
private String takeRate;