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.dto.app.vo.pay.OrderPayStatusResp;
|
||||
import com.ruoyi.cai.enums.SystemConfigEnum;
|
||||
import com.ruoyi.cai.manager.DangerManger;
|
||||
import com.ruoyi.cai.manager.SystemConfigManager;
|
||||
import com.ruoyi.cai.pay.*;
|
||||
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.v14.V14Token;
|
||||
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.core.domain.R;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
@@ -161,15 +163,22 @@ public class PayController {
|
||||
if(payOrderInfo == null){
|
||||
return V14R.fail14(600,"支付失败,未找到订单");
|
||||
}
|
||||
log.info("收到微信支付/efps/wx, token={},orderNo={},body={}",efpsToken,payOrderInfo.getOrderNo(), JacksonUtil.objToJson(payDTO));
|
||||
try {
|
||||
long startTime = System.currentTimeMillis();
|
||||
V14ExtendMapDTO extendMap = JSON.parseObject(payTrdConfig.getExtendData(), V14ExtendMapDTO.class);
|
||||
String openId = getOpenIdByCode(payDTO.getWx_code(), extendMap.getMinAppId(), extendMap.getMinSecret());
|
||||
payOrderInfo.setOpenId(openId);
|
||||
long endTime = System.currentTimeMillis();
|
||||
log.info("获取openId耗时:{}ms",endTime-startTime);
|
||||
} catch (IOException e) {
|
||||
log.error("获取openid失败",e);
|
||||
return V14R.fail14(600,"微信登录失败");
|
||||
}
|
||||
long startTime = System.currentTimeMillis();
|
||||
WechatJSAPIResponse pay = v14Manager.pay(payOrderInfo, payTrdConfig);
|
||||
long endTime = System.currentTimeMillis();
|
||||
log.info("处理v14请求耗时:{}ms",endTime-startTime);
|
||||
V14R<WechatJSAPIResponse> result = V14R.ok14(pay);
|
||||
result.setWxJsapiParam(pay.getWxJsapiParam());
|
||||
return result;
|
||||
@@ -433,6 +442,9 @@ public class PayController {
|
||||
}
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private DangerManger dangerManger;
|
||||
|
||||
@RequestMapping(value = "/trd/notify/wx/{type}", method = {RequestMethod.POST, RequestMethod.GET})
|
||||
@Operation(hidden = true)
|
||||
@Log(title = "第三方微信支付回调", businessType = BusinessType.OTHER, isSaveDb = false)
|
||||
@@ -451,6 +463,7 @@ public class PayController {
|
||||
if(trdPayTypeEnum == TrdPayTypeEnum.V14){
|
||||
try {
|
||||
JSONObject jsonObject = v14Manager.notifyDeal(request);
|
||||
dangerManger.notifyPay(TrdPayTypeEnum.V14);
|
||||
PrintWriter writer = response.getWriter();
|
||||
writer.print(jsonObject.toJSONString());
|
||||
writer.close();
|
||||
|
||||
@@ -115,6 +115,12 @@ public class V14Manager {
|
||||
header.put("x-efps-timestamp",LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss")));
|
||||
String gatewayUrl = getGatewayUrl(payTrdConfig);
|
||||
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);
|
||||
log.info("v14调用支付日志 url:{} body:{} header:{} response:{}", createOrderUrl,JacksonUtil.objToJson(order),JacksonUtil.objToJson(header),body);
|
||||
WechatJSAPIResponse response = JacksonUtil.jsonToObj(body, WechatJSAPIResponse.class);
|
||||
@@ -125,9 +131,30 @@ public class V14Manager {
|
||||
}
|
||||
orderLogsService.createAliPayLogs(payOrderInfoDTO.getOrderNo(), createOrderUrl,
|
||||
JacksonUtil.objToJson(order), body, true, type, "四方微信支付");
|
||||
this.setRedisData(payOrderInfoDTO.getOrderNo(), 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) {
|
||||
V14Manager v14Manager = new V14Manager();
|
||||
PayOrderInfoDTO payOrderInfoDTO = new PayOrderInfoDTO();
|
||||
|
||||
Reference in New Issue
Block a user