|
@@ -7,6 +7,7 @@ import com.wechat.pay.java.service.payments.model.Transaction;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.web.client.RestTemplate;
|
|
|
import thyyxxk.wxservice_server.config.exception.ExceptionEnum;
|
|
|
import thyyxxk.wxservice_server.constant.OrderType;
|
|
|
import thyyxxk.wxservice_server.dao.WxApiDao;
|
|
@@ -40,6 +41,17 @@ public class WxApiService {
|
|
|
this.savePayResultService = savePayResultService;
|
|
|
}
|
|
|
|
|
|
+ public JSONObject getAuthorization(String code) {
|
|
|
+ RestTemplate template = new RestTemplate();
|
|
|
+ String url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=" +
|
|
|
+ PropertiesUtil.getLocalProperty("appId") + "&secret=" +
|
|
|
+ PropertiesUtil.getLocalProperty("appSecret") + "&code=" +
|
|
|
+ code + "&grant_type=authorization_code";
|
|
|
+ String str = template.getForObject(url, String.class);
|
|
|
+ log.info("微信获取authorization:{}", str);
|
|
|
+ return JSONObject.parseObject(str);
|
|
|
+ }
|
|
|
+
|
|
|
public ResultVo<JsApiSHA1> getJsapiSHA1Sign(JsApiSHA1 data) throws Exception {
|
|
|
data.setAppId(PropertiesUtil.getLocalProperty("appId"));
|
|
|
data.setTicket(PropertiesUtil.getLocalProperty("ticket"));
|