|
@@ -1,11 +1,13 @@
|
|
|
package com.ruoyi.system.service.impl;
|
|
|
|
|
|
|
|
|
+import cn.hutool.http.HttpUtil;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.ruoyi.common.constant.Constants;
|
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
import com.ruoyi.common.core.redis.RedisCache;
|
|
|
import com.ruoyi.common.exception.ServiceException;
|
|
|
+import com.ruoyi.common.utils.http.HttpUtils;
|
|
|
import com.ruoyi.common.utils.sign.Base64;
|
|
|
import com.ruoyi.system.domain.wx.*;
|
|
|
import com.ruoyi.system.service.IWxPayService;
|
|
@@ -126,6 +128,8 @@ public class WxPayServiceImpl implements IWxPayService {
|
|
|
String sign = WxPayUtil.getSign(signatureStr, wxPayV3Bean.getKeyPath());
|
|
|
vo.setPaySign(sign);
|
|
|
vo.setPrepayId(response.getPrepayId());
|
|
|
+ vo.setAppId(wxPayV3Bean.getAppId());
|
|
|
+ vo.setSignType("RSA");
|
|
|
//todo 存储预支付订单信息
|
|
|
return AjaxResult.success(vo);
|
|
|
} catch (ServiceException e) {
|
|
@@ -246,32 +250,33 @@ public class WxPayServiceImpl implements IWxPayService {
|
|
|
|
|
|
/**
|
|
|
* 根获取微信文本内容安全识别
|
|
|
+ *
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
public AjaxResult msgSecCheck(AppletSessionDTO dto) {
|
|
|
- Object accessToken =null;
|
|
|
+ Object accessToken = null;
|
|
|
try {
|
|
|
//从redis中获取
|
|
|
- accessToken = redisCache.getCacheObject(Constants.WX_ACCESS_TOKEN);
|
|
|
- if (ObjectUtils.isEmpty(accessToken)){
|
|
|
+ accessToken = redisCache.getCacheObject(Constants.WX_ACCESS_TOKEN);
|
|
|
+ if (ObjectUtils.isEmpty(accessToken)) {
|
|
|
String result = HttpClientUtils.doGet(ACCESS_TOKEN.replace("APPID", appId)
|
|
|
- .replace("SECRET", appSecret)
|
|
|
+ .replace("APPSECRET", appSecret)
|
|
|
);
|
|
|
JSONObject jsonObject = JSONObject.parseObject(result);
|
|
|
accessToken = jsonObject.get("access_token");
|
|
|
- redisCache.setCacheObject(Constants.WX_ACCESS_TOKEN,accessToken,Constants.CAPTCHA_EXPIRATION, TimeUnit.HOURS);
|
|
|
+ redisCache.setCacheObject(Constants.WX_ACCESS_TOKEN, accessToken, Constants.CAPTCHA_EXPIRATION, TimeUnit.HOURS);
|
|
|
}
|
|
|
- Map<String,String> map = new HashMap(4);
|
|
|
- map.put("content",dto.getContent());
|
|
|
- map.put("version","2");
|
|
|
- map.put("openid",dto.getOpenId());
|
|
|
- map.put("scene","2");
|
|
|
- String msgsecCheck = HttpClientUtils.doPost(MSGSECCHECK.replace("ACCESS_TOKEN", (String) accessToken), map);
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ jsonObject.put("content", dto.getContent());
|
|
|
+ jsonObject.put("version", 2);
|
|
|
+ jsonObject.put("openid", dto.getOpenId());
|
|
|
+ jsonObject.put("scene", 2);
|
|
|
+ String msgsecCheck = HttpUtil.post(MSGSECCHECK.replace("ACCESS_TOKEN", (String) accessToken), jsonObject.toJSONString());
|
|
|
JSONObject msgsecCheckResult = JSONObject.parseObject(msgsecCheck);
|
|
|
- Object result = msgsecCheckResult.get("result");
|
|
|
- Object label = JSONObject.parseObject((String) result).get("label");
|
|
|
- if (!"100".equals(label)){
|
|
|
+ JSONObject result = (JSONObject) msgsecCheckResult.get("result");
|
|
|
+ Integer label = (Integer) result.get("label");
|
|
|
+ if (label != 100) {
|
|
|
return AjaxResult.error("含有违规信息");
|
|
|
}
|
|
|
} catch (IOException e) {
|