nnnn
This commit is contained in:
@@ -18,6 +18,7 @@ import com.ruoyi.cai.domain.PayConfig;
|
|||||||
import com.ruoyi.cai.domain.PayTrdConfig;
|
import com.ruoyi.cai.domain.PayTrdConfig;
|
||||||
import com.ruoyi.cai.dto.app.vo.pay.OrderPayStatusResp;
|
import com.ruoyi.cai.dto.app.vo.pay.OrderPayStatusResp;
|
||||||
import com.ruoyi.cai.enums.SystemConfigEnum;
|
import com.ruoyi.cai.enums.SystemConfigEnum;
|
||||||
|
import com.ruoyi.cai.manager.DangerManger;
|
||||||
import com.ruoyi.cai.manager.SystemConfigManager;
|
import com.ruoyi.cai.manager.SystemConfigManager;
|
||||||
import com.ruoyi.cai.pay.*;
|
import com.ruoyi.cai.pay.*;
|
||||||
import com.ruoyi.cai.service.OrderLogsService;
|
import com.ruoyi.cai.service.OrderLogsService;
|
||||||
@@ -29,6 +30,7 @@ import com.ruoyi.cai.trdpay.dto.NotifyResp;
|
|||||||
import com.ruoyi.cai.trdpay.dto.extend.V14ExtendMapDTO;
|
import com.ruoyi.cai.trdpay.dto.extend.V14ExtendMapDTO;
|
||||||
import com.ruoyi.cai.trdpay.dto.v14.V14Token;
|
import com.ruoyi.cai.trdpay.dto.v14.V14Token;
|
||||||
import com.ruoyi.cai.trdpay.dto.v14.wechatJSAPI.WechatJSAPIResponse;
|
import com.ruoyi.cai.trdpay.dto.v14.wechatJSAPI.WechatJSAPIResponse;
|
||||||
|
import com.ruoyi.cai.trdpay.handle.v12new.utils.JacksonUtil;
|
||||||
import com.ruoyi.common.annotation.Log;
|
import com.ruoyi.common.annotation.Log;
|
||||||
import com.ruoyi.common.core.domain.R;
|
import com.ruoyi.common.core.domain.R;
|
||||||
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
@@ -161,15 +163,22 @@ public class PayController {
|
|||||||
if(payOrderInfo == null){
|
if(payOrderInfo == null){
|
||||||
return V14R.fail14(600,"支付失败,未找到订单");
|
return V14R.fail14(600,"支付失败,未找到订单");
|
||||||
}
|
}
|
||||||
|
log.info("收到微信支付/efps/wx, token={},orderNo={},body={}",efpsToken,payOrderInfo.getOrderNo(), JacksonUtil.objToJson(payDTO));
|
||||||
try {
|
try {
|
||||||
|
long startTime = System.currentTimeMillis();
|
||||||
V14ExtendMapDTO extendMap = JSON.parseObject(payTrdConfig.getExtendData(), V14ExtendMapDTO.class);
|
V14ExtendMapDTO extendMap = JSON.parseObject(payTrdConfig.getExtendData(), V14ExtendMapDTO.class);
|
||||||
String openId = getOpenIdByCode(payDTO.getWx_code(), extendMap.getMinAppId(), extendMap.getMinSecret());
|
String openId = getOpenIdByCode(payDTO.getWx_code(), extendMap.getMinAppId(), extendMap.getMinSecret());
|
||||||
payOrderInfo.setOpenId(openId);
|
payOrderInfo.setOpenId(openId);
|
||||||
|
long endTime = System.currentTimeMillis();
|
||||||
|
log.info("获取openId耗时:{}ms",endTime-startTime);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.error("获取openid失败",e);
|
log.error("获取openid失败",e);
|
||||||
return V14R.fail14(600,"微信登录失败");
|
return V14R.fail14(600,"微信登录失败");
|
||||||
}
|
}
|
||||||
|
long startTime = System.currentTimeMillis();
|
||||||
WechatJSAPIResponse pay = v14Manager.pay(payOrderInfo, payTrdConfig);
|
WechatJSAPIResponse pay = v14Manager.pay(payOrderInfo, payTrdConfig);
|
||||||
|
long endTime = System.currentTimeMillis();
|
||||||
|
log.info("处理v14请求耗时:{}ms",endTime-startTime);
|
||||||
V14R<WechatJSAPIResponse> result = V14R.ok14(pay);
|
V14R<WechatJSAPIResponse> result = V14R.ok14(pay);
|
||||||
result.setWxJsapiParam(pay.getWxJsapiParam());
|
result.setWxJsapiParam(pay.getWxJsapiParam());
|
||||||
return result;
|
return result;
|
||||||
@@ -433,6 +442,9 @@ public class PayController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private DangerManger dangerManger;
|
||||||
|
|
||||||
@RequestMapping(value = "/trd/notify/wx/{type}", method = {RequestMethod.POST, RequestMethod.GET})
|
@RequestMapping(value = "/trd/notify/wx/{type}", method = {RequestMethod.POST, RequestMethod.GET})
|
||||||
@Operation(hidden = true)
|
@Operation(hidden = true)
|
||||||
@Log(title = "第三方微信支付回调", businessType = BusinessType.OTHER, isSaveDb = false)
|
@Log(title = "第三方微信支付回调", businessType = BusinessType.OTHER, isSaveDb = false)
|
||||||
@@ -451,6 +463,7 @@ public class PayController {
|
|||||||
if(trdPayTypeEnum == TrdPayTypeEnum.V14){
|
if(trdPayTypeEnum == TrdPayTypeEnum.V14){
|
||||||
try {
|
try {
|
||||||
JSONObject jsonObject = v14Manager.notifyDeal(request);
|
JSONObject jsonObject = v14Manager.notifyDeal(request);
|
||||||
|
dangerManger.notifyPay(TrdPayTypeEnum.V14);
|
||||||
PrintWriter writer = response.getWriter();
|
PrintWriter writer = response.getWriter();
|
||||||
writer.print(jsonObject.toJSONString());
|
writer.print(jsonObject.toJSONString());
|
||||||
writer.close();
|
writer.close();
|
||||||
|
|||||||
@@ -115,6 +115,12 @@ public class V14Manager {
|
|||||||
header.put("x-efps-timestamp",LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss")));
|
header.put("x-efps-timestamp",LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss")));
|
||||||
String gatewayUrl = getGatewayUrl(payTrdConfig);
|
String gatewayUrl = getGatewayUrl(payTrdConfig);
|
||||||
String createOrderUrl = gatewayUrl + "/api/txs/pay/WxJSAPIPayment";
|
String createOrderUrl = gatewayUrl + "/api/txs/pay/WxJSAPIPayment";
|
||||||
|
WechatJSAPIResponse data = getData(payOrderInfoDTO.getOrderNo());
|
||||||
|
if(data != null){
|
||||||
|
orderLogsService.createAliPayLogs(payOrderInfoDTO.getOrderNo(), "命中缓存",
|
||||||
|
JacksonUtil.objToJson(order), JacksonUtil.objToJson(data), false, type, "四方微信支付");
|
||||||
|
return data;
|
||||||
|
}
|
||||||
String body = RestTemplateUtil.postJsonData(createOrderUrl, JacksonUtil.objToJson(order), header);
|
String body = RestTemplateUtil.postJsonData(createOrderUrl, JacksonUtil.objToJson(order), header);
|
||||||
log.info("v14调用支付日志 url:{} body:{} header:{} response:{}", createOrderUrl,JacksonUtil.objToJson(order),JacksonUtil.objToJson(header),body);
|
log.info("v14调用支付日志 url:{} body:{} header:{} response:{}", createOrderUrl,JacksonUtil.objToJson(order),JacksonUtil.objToJson(header),body);
|
||||||
WechatJSAPIResponse response = JacksonUtil.jsonToObj(body, WechatJSAPIResponse.class);
|
WechatJSAPIResponse response = JacksonUtil.jsonToObj(body, WechatJSAPIResponse.class);
|
||||||
@@ -125,9 +131,30 @@ public class V14Manager {
|
|||||||
}
|
}
|
||||||
orderLogsService.createAliPayLogs(payOrderInfoDTO.getOrderNo(), createOrderUrl,
|
orderLogsService.createAliPayLogs(payOrderInfoDTO.getOrderNo(), createOrderUrl,
|
||||||
JacksonUtil.objToJson(order), body, true, type, "四方微信支付");
|
JacksonUtil.objToJson(order), body, true, type, "四方微信支付");
|
||||||
|
this.setRedisData(payOrderInfoDTO.getOrderNo(), response);
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String REDIS_KEY = "cai:v14:%s";
|
||||||
|
|
||||||
|
private String getKey(String orderNo){
|
||||||
|
return String.format(REDIS_KEY,orderNo);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setRedisData(String orderNo, WechatJSAPIResponse response){
|
||||||
|
String redisKey = getKey(orderNo);
|
||||||
|
RBucket<String> bucket = redissonClient.getBucket(redisKey);
|
||||||
|
bucket.set(JSON.toJSONString(response),20,TimeUnit.MINUTES);
|
||||||
|
}
|
||||||
|
|
||||||
|
private WechatJSAPIResponse getData(String orderNo){
|
||||||
|
String redisKey = getKey(orderNo);
|
||||||
|
RBucket<String> bucket = redissonClient.getBucket(redisKey);
|
||||||
|
String name = bucket.get();
|
||||||
|
return JSON.parseObject(name, WechatJSAPIResponse.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
V14Manager v14Manager = new V14Manager();
|
V14Manager v14Manager = new V14Manager();
|
||||||
PayOrderInfoDTO payOrderInfoDTO = new PayOrderInfoDTO();
|
PayOrderInfoDTO payOrderInfoDTO = new PayOrderInfoDTO();
|
||||||
|
|||||||
Reference in New Issue
Block a user