|
@@ -95,8 +95,6 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
@Resource
|
|
|
TAlipayConfigService alipayConfigService;
|
|
|
|
|
|
- @Autowired
|
|
|
- private StringRedisTemplate redisTemplate;
|
|
|
|
|
|
@Autowired
|
|
|
private TOrderDetailsService orderDetailsService;
|
|
@@ -522,18 +520,20 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
String accessToken = "";
|
|
|
try {
|
|
|
if(StringUtils.isEmpty(companyType) || companyType.equals("0")) {
|
|
|
- accessToken = redisTemplate.opsForValue().get(SZ_ACCESS_TOKEN_KEY);
|
|
|
+ TAdmin admin = R.getDataIfSuccess(szwlFeign.getAdmin("2738"));
|
|
|
+ accessToken = admin.getApiKey();
|
|
|
log.info("申泽的accessToken:{}", accessToken);
|
|
|
} else {
|
|
|
- accessToken = redisTemplate.opsForValue().get(SC_ACCESS_TOKEN_KEY);
|
|
|
+ TAdmin admin = R.getDataIfSuccess(szwlFeign.getAdmin("2739"));
|
|
|
+ accessToken = admin.getApiKey();
|
|
|
log.info("七云的accessToken:{}", accessToken);
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
- if(StringUtils.isEmpty(accessToken)) {
|
|
|
- accessToken = getAccessToken(companyType);
|
|
|
- }
|
|
|
+// if(StringUtils.isEmpty(accessToken)) {
|
|
|
+// accessToken = getAccessToken(companyType);
|
|
|
+// }
|
|
|
// 推送消息
|
|
|
// 模板参数
|
|
|
Map<String, WeChatTemplateMsg> sendMag = new HashMap();
|
|
@@ -568,13 +568,13 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
} else {
|
|
|
sendBody.put("template_id", HuifuConstant.SC_TEMPLATE_ID);
|
|
|
}
|
|
|
- String messageCode = sendMessage(accessToken, restTemplate, sendBody);
|
|
|
- if (StringUtils.isNotEmpty(messageCode) && messageCode.equals("40001")) {
|
|
|
- // 获取到新的accessToken
|
|
|
- accessToken = getAccessToken(companyType);
|
|
|
- messageCode = sendMessage(accessToken, restTemplate, sendBody);
|
|
|
- log.info("微信推送结果:{}","messageCode : " + messageCode);
|
|
|
- }
|
|
|
+ sendMessage(accessToken, restTemplate, sendBody);
|
|
|
+// if (StringUtils.isNotEmpty(messageCode) && messageCode.equals("40001")) {
|
|
|
+// // 获取到新的accessToken
|
|
|
+// accessToken = getAccessToken(companyType);
|
|
|
+// messageCode = sendMessage(accessToken, restTemplate, sendBody);
|
|
|
+// log.info("微信推送结果:{}","messageCode : " + messageCode);
|
|
|
+// }
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -600,70 +600,70 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
* @param companyType
|
|
|
* @return
|
|
|
*/
|
|
|
- private String getAccessToken(String companyType) {
|
|
|
- String accessToken = "";
|
|
|
- String url = "";
|
|
|
- if(StringUtils.isEmpty(companyType) || companyType.equals("0")) {
|
|
|
- url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid="
|
|
|
- + HuifuConstant.SZ_WX_SUB_APP_ID + "&secret=" + HuifuConstant.SZ_WX_APP_SECRET;
|
|
|
- } else {
|
|
|
- url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid="
|
|
|
- + HuifuConstant.SC_WX_SUB_APP_ID + "&secret=" + HuifuConstant.SC_WX_APP_SECRET;
|
|
|
- }
|
|
|
- PrintWriter out = null;
|
|
|
- BufferedReader in = null;
|
|
|
- String line;
|
|
|
- StringBuffer stringBuffer = new StringBuffer();
|
|
|
- try {
|
|
|
- URL realUrl = new URL(url);
|
|
|
- // 打开和URL之间的连接
|
|
|
- URLConnection conn = realUrl.openConnection();
|
|
|
-
|
|
|
- // 设置通用的请求属性 设置请求格式
|
|
|
- //设置返回类型
|
|
|
- conn.setRequestProperty("contentType", "text/plain");
|
|
|
- //设置请求类型
|
|
|
- conn.setRequestProperty("content-type", "application/x-www-form-urlencoded");
|
|
|
- //设置超时时间
|
|
|
- conn.setConnectTimeout(1000);
|
|
|
- conn.setReadTimeout(1000);
|
|
|
- conn.setDoOutput(true);
|
|
|
- conn.connect();
|
|
|
- // 获取URLConnection对象对应的输出流
|
|
|
- out = new PrintWriter(conn.getOutputStream());
|
|
|
- // flush输出流的缓冲
|
|
|
- out.flush();
|
|
|
- // 定义BufferedReader输入流来读取URL的响应 设置接收格式
|
|
|
- in = new BufferedReader(
|
|
|
- new InputStreamReader(conn.getInputStream(), "UTF-8"));
|
|
|
- while ((line = in.readLine()) != null) {
|
|
|
- stringBuffer.append(line);
|
|
|
- }
|
|
|
- JSONObject jsonObject = JSONObject.parseObject(stringBuffer.toString());
|
|
|
- log.info("获取token:{}",jsonObject.toString());
|
|
|
- accessToken = jsonObject.getString("access_token");
|
|
|
- if(StringUtils.isEmpty(companyType) || companyType.equals("0")) {
|
|
|
- redisTemplate.opsForValue().set(SZ_ACCESS_TOKEN_KEY, accessToken, EXPIRATION_TIME, TimeUnit.SECONDS);
|
|
|
- } else {
|
|
|
- redisTemplate.opsForValue().set(SZ_ACCESS_TOKEN_KEY, accessToken, EXPIRATION_TIME, TimeUnit.SECONDS);
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- } finally {
|
|
|
- //使用finally块来关闭输出流、输入流
|
|
|
- try {
|
|
|
- if (out != null) {
|
|
|
- out.close();
|
|
|
- }
|
|
|
- if (in != null) {
|
|
|
- in.close();
|
|
|
- }
|
|
|
- } catch (IOException ex) {
|
|
|
- ex.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
- return accessToken;
|
|
|
- }
|
|
|
+// private String getAccessToken(String companyType) {
|
|
|
+// String accessToken = "";
|
|
|
+// String url = "";
|
|
|
+// if(StringUtils.isEmpty(companyType) || companyType.equals("0")) {
|
|
|
+// url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid="
|
|
|
+// + HuifuConstant.SZ_WX_SUB_APP_ID + "&secret=" + HuifuConstant.SZ_WX_APP_SECRET;
|
|
|
+// } else {
|
|
|
+// url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid="
|
|
|
+// + HuifuConstant.SC_WX_SUB_APP_ID + "&secret=" + HuifuConstant.SC_WX_APP_SECRET;
|
|
|
+// }
|
|
|
+// PrintWriter out = null;
|
|
|
+// BufferedReader in = null;
|
|
|
+// String line;
|
|
|
+// StringBuffer stringBuffer = new StringBuffer();
|
|
|
+// try {
|
|
|
+// URL realUrl = new URL(url);
|
|
|
+// // 打开和URL之间的连接
|
|
|
+// URLConnection conn = realUrl.openConnection();
|
|
|
+//
|
|
|
+// // 设置通用的请求属性 设置请求格式
|
|
|
+// //设置返回类型
|
|
|
+// conn.setRequestProperty("contentType", "text/plain");
|
|
|
+// //设置请求类型
|
|
|
+// conn.setRequestProperty("content-type", "application/x-www-form-urlencoded");
|
|
|
+// //设置超时时间
|
|
|
+// conn.setConnectTimeout(1000);
|
|
|
+// conn.setReadTimeout(1000);
|
|
|
+// conn.setDoOutput(true);
|
|
|
+// conn.connect();
|
|
|
+// // 获取URLConnection对象对应的输出流
|
|
|
+// out = new PrintWriter(conn.getOutputStream());
|
|
|
+// // flush输出流的缓冲
|
|
|
+// out.flush();
|
|
|
+// // 定义BufferedReader输入流来读取URL的响应 设置接收格式
|
|
|
+// in = new BufferedReader(
|
|
|
+// new InputStreamReader(conn.getInputStream(), "UTF-8"));
|
|
|
+// while ((line = in.readLine()) != null) {
|
|
|
+// stringBuffer.append(line);
|
|
|
+// }
|
|
|
+// JSONObject jsonObject = JSONObject.parseObject(stringBuffer.toString());
|
|
|
+// log.info("获取token:{}",jsonObject.toString());
|
|
|
+// accessToken = jsonObject.getString("access_token");
|
|
|
+// if(StringUtils.isEmpty(companyType) || companyType.equals("0")) {
|
|
|
+// redisTemplate.opsForValue().set(SZ_ACCESS_TOKEN_KEY, accessToken, EXPIRATION_TIME, TimeUnit.SECONDS);
|
|
|
+// } else {
|
|
|
+// redisTemplate.opsForValue().set(SZ_ACCESS_TOKEN_KEY, accessToken, EXPIRATION_TIME, TimeUnit.SECONDS);
|
|
|
+// }
|
|
|
+// } catch (Exception e) {
|
|
|
+// e.printStackTrace();
|
|
|
+// } finally {
|
|
|
+// //使用finally块来关闭输出流、输入流
|
|
|
+// try {
|
|
|
+// if (out != null) {
|
|
|
+// out.close();
|
|
|
+// }
|
|
|
+// if (in != null) {
|
|
|
+// in.close();
|
|
|
+// }
|
|
|
+// } catch (IOException ex) {
|
|
|
+// ex.printStackTrace();
|
|
|
+// }
|
|
|
+// }
|
|
|
+// return accessToken;
|
|
|
+// }
|
|
|
|
|
|
public void processRefund(Map<String, Object> bodyMap) {
|
|
|
String decrypt = wechatPayConfigService.decryptFromResource(bodyMap);
|