微信密钥
This commit is contained in:
parent
d0016e9d16
commit
65b3680c49
|
|
@ -10,6 +10,8 @@ import com.ghy.common.utils.WxUtils;
|
||||||
import com.ghy.common.utils.http.HttpUtils;
|
import com.ghy.common.utils.http.HttpUtils;
|
||||||
import com.ghy.customer.domain.Customer;
|
import com.ghy.customer.domain.Customer;
|
||||||
import com.ghy.customer.service.CustomerService;
|
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.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
@ -32,6 +34,9 @@ public class WxController extends BaseController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private WxConfig wxConfig;
|
private WxConfig wxConfig;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ISysDeptConfigService sysDeptConfigService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private CustomerService customerService;
|
private CustomerService customerService;
|
||||||
|
|
||||||
|
|
@ -76,8 +81,16 @@ public class WxController extends BaseController {
|
||||||
@GetMapping("/auth")
|
@GetMapping("/auth")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult auth(HttpServletRequest request) {
|
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 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);
|
String data = HttpUtils.sendGet(url, null);
|
||||||
JSONObject result = JSONObject.parseObject(data);
|
JSONObject result = JSONObject.parseObject(data);
|
||||||
return AjaxResult.success(result);
|
return AjaxResult.success(result);
|
||||||
|
|
|
||||||
|
|
@ -30,10 +30,14 @@ public class SysDeptConfig extends BaseEntity {
|
||||||
private String adapayRsaPrivateKey;
|
private String adapayRsaPrivateKey;
|
||||||
private String adapayMaxRetryTimes;
|
private String adapayMaxRetryTimes;
|
||||||
|
|
||||||
//微信配置
|
//微信消费者端配置
|
||||||
private String wxAppId;
|
private String wxAppId;
|
||||||
private String wxSecret;
|
private String wxSecret;
|
||||||
|
|
||||||
|
//微信师傅端配置
|
||||||
|
private String servWxAppId;
|
||||||
|
private String servWxSecret;
|
||||||
|
|
||||||
//平台扣点比例
|
//平台扣点比例
|
||||||
private String takeRate;
|
private String takeRate;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue