订单查询回调优化
This commit is contained in:
@@ -124,7 +124,7 @@ public class WuyouController {
|
||||
return Result.success().put("data", data);
|
||||
}
|
||||
|
||||
BaseResp baseResp = wuyouPay.payOrder(payDetails.getTradeNo(), order.getPayMoney().toString(),
|
||||
BaseResp baseResp = wuyouPay.payOrder(payDetails.getTradeNo(), order.getUserId(), order.getPayMoney().toString(),
|
||||
request.getHeader("User-Agent"), String.format("%d-%d", order.getCourseId(), order.getCourseDetailsId()),
|
||||
payType);
|
||||
if (baseResp.getCode() == null) {
|
||||
@@ -154,7 +154,7 @@ public class WuyouController {
|
||||
return Result.success().put("data", 1);
|
||||
}
|
||||
|
||||
BaseResp baseResp = wuyouPay.queryOrder(payDetails.getTradeNo(), order.getPayMoney().toString(), request.getHeader("User-Agent"));
|
||||
BaseResp baseResp = wuyouPay.queryOrder(payDetails.getTradeNo(), order.getUserId(), order.getPayMoney().toString(), request.getHeader("User-Agent"));
|
||||
if (baseResp.getCode() == null || baseResp.getCode() != 200) {
|
||||
return Result.success().put("data", 0);
|
||||
}
|
||||
@@ -205,10 +205,24 @@ public class WuyouController {
|
||||
|
||||
log.info("无忧支付回调成功, 参数: {}", JSONObject.toJSONString(notifyDto));
|
||||
|
||||
String orderNo = notifyDto.getOut_trade_no();
|
||||
long userId = 0L;
|
||||
String[] split = orderNo.split("-");
|
||||
if (split.length != 2) {
|
||||
log.error("无忧支付回调订单号错误, 参数: {}", JSONObject.toJSONString(notifyDto));
|
||||
return "success";
|
||||
}
|
||||
orderNo = split[0];
|
||||
userId = Long.parseLong(split[1]);
|
||||
|
||||
DateTime offsetMinute = DateUtil.offsetMinute(new Date(), -30);
|
||||
String format = DateUtil.format(offsetMinute, "yyyy-MM-dd HH:mm:ss");
|
||||
List<PayDetails> details = payDetailsDao.selectList(new LambdaQueryWrapper<PayDetails>()
|
||||
.eq(PayDetails::getTradeNo, notifyDto.getOut_trade_no()).ge(PayDetails::getCreateTime, format));
|
||||
LambdaQueryWrapper<PayDetails> detailsLambdaQueryWrapper = new LambdaQueryWrapper<PayDetails>()
|
||||
.eq(PayDetails::getTradeNo, orderNo).ge(PayDetails::getCreateTime, format);
|
||||
if (userId != 0) {
|
||||
detailsLambdaQueryWrapper.eq(PayDetails::getUserId, userId);
|
||||
}
|
||||
List<PayDetails> details = payDetailsDao.selectList(detailsLambdaQueryWrapper);
|
||||
if (details.isEmpty()) {
|
||||
log.error("无忧支付回调订单不存在, 参数: {}", JSONObject.toJSONString(notifyDto));
|
||||
return "success";
|
||||
@@ -265,7 +279,29 @@ public class WuyouController {
|
||||
log.error("无忧支付提现回调签名错误, 参数: {},签名结果:{}", JSONObject.toJSONString(notifyDto), sign);
|
||||
// return "签名错误";
|
||||
}
|
||||
CashOut cashOut = cashOutDao.selectOne(new QueryWrapper<CashOut>().eq("order_number", notifyDto.getOut_trade_no()));
|
||||
|
||||
String orderNo = notifyDto.getOut_trade_no();
|
||||
long userId = 0L;
|
||||
String[] split = orderNo.split("-");
|
||||
if (split.length != 2) {
|
||||
log.error("无忧支付回调订单号错误, 参数: {}", JSONObject.toJSONString(notifyDto));
|
||||
return;
|
||||
}
|
||||
orderNo = split[0];
|
||||
String sub = split[1];
|
||||
String[] split1 = sub.split(":");
|
||||
if (split1.length != 2) {
|
||||
log.error("无忧支付回调订单号错误, 参数: {}", JSONObject.toJSONString(notifyDto));
|
||||
return;
|
||||
}
|
||||
userId = Long.parseLong(split1[0]);
|
||||
|
||||
QueryWrapper<CashOut> orderNumber = new QueryWrapper<CashOut>().eq("order_number", orderNo);
|
||||
if (userId != 0) {
|
||||
orderNumber.eq("user_id", userId);
|
||||
}
|
||||
|
||||
CashOut cashOut = cashOutDao.selectOne(orderNumber);
|
||||
if (cashOut != null) {
|
||||
if ("2".equals(notifyDto.getStatus())) {
|
||||
cashOut.setState(1);
|
||||
|
||||
@@ -535,11 +535,13 @@ public class CashOutServiceImpl extends ServiceImpl<CashOutDao, CashOut> impleme
|
||||
CashOut cashOut = new CashOut();
|
||||
cashOut.setIsOut(false);
|
||||
cashOut.setMoney(money.toString());
|
||||
cashOut.setUserId(userId);
|
||||
if (isSys) {
|
||||
cashOut.setSysUserId(userId);
|
||||
cashOut.setUserType(2);
|
||||
} else {
|
||||
cashOut.setUserId(userId);
|
||||
cashOut.setUserType(1);
|
||||
}
|
||||
|
||||
cashOut.setZhifubao(alipayAccount);
|
||||
cashOut.setZhifubaoName(alipayName);
|
||||
|
||||
@@ -571,7 +573,7 @@ public class CashOutServiceImpl extends ServiceImpl<CashOutDao, CashOut> impleme
|
||||
}
|
||||
if (wuyouPay.checkCanCash(userId, WithdrawTypeEnum.MANUAL, new BigDecimal(money.toString()))) {
|
||||
cashOut.setStatus(4);
|
||||
BaseResp baseResp = wuyouPay.extractOrder(outOrderNo, cashOut.getMoney(), cashOut.getZhifubao(), cashOut.getZhifubaoName());
|
||||
BaseResp baseResp = wuyouPay.extractOrder(outOrderNo, cashOut.getUserId(), false, cashOut.getMoney(), cashOut.getZhifubao(), cashOut.getZhifubaoName());
|
||||
if (baseResp.getStatus() != null && (baseResp.getStatus().equals(2) || baseResp.getStatus().equals(10000))) {
|
||||
sysUserMoneyDetails.setContent("成功提现:" + money);
|
||||
cashOut.setState(1);
|
||||
@@ -607,7 +609,7 @@ public class CashOutServiceImpl extends ServiceImpl<CashOutDao, CashOut> impleme
|
||||
}
|
||||
if (wuyouPay.checkCanCash(userId, WithdrawTypeEnum.MANUAL, new BigDecimal(money.toString()))) {
|
||||
cashOut.setStatus(4);
|
||||
BaseResp baseResp = wuyouPay.extractOrder(outOrderNo, cashOut.getMoney(), cashOut.getZhifubao(), cashOut.getZhifubaoName());
|
||||
BaseResp baseResp = wuyouPay.extractOrder(outOrderNo, cashOut.getUserId(), true, cashOut.getMoney(), cashOut.getZhifubao(), cashOut.getZhifubaoName());
|
||||
if (baseResp.getStatus() != null && (baseResp.getStatus().equals(2) || baseResp.getStatus().equals(10000))) {
|
||||
userMoneyDetails.setContent("成功提现:" + money);
|
||||
cashOut.setState(1);
|
||||
@@ -705,18 +707,21 @@ public class CashOutServiceImpl extends ServiceImpl<CashOutDao, CashOut> impleme
|
||||
entity.setRefund(cashOut.getRefund());
|
||||
}
|
||||
|
||||
boolean isSysUser = entity.getSysUserId() != null;
|
||||
boolean isUser = true;
|
||||
if (entity.getUserType() == 2) {
|
||||
isUser = false;
|
||||
}
|
||||
|
||||
if (isSysUser) {
|
||||
SysUserEntity sysUserEntity = sysUserService.getById(entity.getSysUserId());
|
||||
if (sysUserEntity == null) {
|
||||
throw new SqxException("提现代理信息不存在!");
|
||||
}
|
||||
} else {
|
||||
if (isUser) {
|
||||
UserEntity userEntity = userService.selectUserById(entity.getUserId());
|
||||
if (userEntity == null) {
|
||||
throw new SqxException("提现用户信息不存在!");
|
||||
}
|
||||
} else {
|
||||
SysUserEntity sysUserEntity = sysUserService.getById(entity.getSysUserId());
|
||||
if (sysUserEntity == null) {
|
||||
throw new SqxException("提现代理信息不存在!");
|
||||
}
|
||||
}
|
||||
|
||||
if (isAgree == 0) {
|
||||
@@ -730,7 +735,7 @@ public class CashOutServiceImpl extends ServiceImpl<CashOutDao, CashOut> impleme
|
||||
entity.setOrderNumber(outOrderNo);
|
||||
}
|
||||
// 执行提现操作
|
||||
BaseResp baseResp = wuyouPay.extractOrderForAudit(entity.getOrderNumber(), entity.getMoney(), entity.getZhifubao(), entity.getZhifubaoName());
|
||||
BaseResp baseResp = wuyouPay.extractOrderForAudit(entity.getOrderNumber(), entity.getUserId(), isUser, entity.getMoney(), entity.getZhifubao(), entity.getZhifubaoName());
|
||||
if (baseResp.getStatus() != null && (baseResp.getStatus().equals(2) || baseResp.getStatus().equals(10000))) {
|
||||
entity.setState(1);
|
||||
} else if (StringUtils.isNotBlank(baseResp.getErrorMsg())) {
|
||||
|
||||
@@ -41,7 +41,7 @@ public class WuyouPay {
|
||||
this.commonInfoService = commonInfoService;
|
||||
}
|
||||
|
||||
public BaseResp payOrder(String orderNo, String amount, String userAgent, String allId, String payType) {
|
||||
public BaseResp payOrder(String orderNo, Long userId, String amount, String userAgent, String allId, String payType) {
|
||||
String payConfig = commonInfoService.findOne(926).getValue();
|
||||
if (!"1".equals(payConfig)) {
|
||||
BaseResp baseResp = new BaseResp();
|
||||
@@ -51,7 +51,7 @@ public class WuyouPay {
|
||||
Map<String, Object> params = getBaseParams();
|
||||
params.put("type", "6001");
|
||||
params.put("is_code", "1");
|
||||
params.put("out_trade_no", orderNo);
|
||||
params.put("out_trade_no", String.format("%s-%s", orderNo, userId));
|
||||
params.put("total", amount);
|
||||
params.put("notify_url", notifyUrl);
|
||||
|
||||
@@ -68,9 +68,9 @@ public class WuyouPay {
|
||||
return JSONObject.parseObject(body, BaseResp.class);
|
||||
}
|
||||
|
||||
public BaseResp queryOrder(String orderNo, String amount, String userAgent) {
|
||||
public BaseResp queryOrder(String orderNo, Long userId, String amount, String userAgent) {
|
||||
Map<String, Object> params = getBaseParams();
|
||||
params.put("out_trade_no", orderNo);
|
||||
params.put("out_trade_no", String.format("%s-%s", orderNo, userId));
|
||||
params.put("total", amount);
|
||||
|
||||
String sign = Encrypt.getParamsSign(params);
|
||||
@@ -116,7 +116,7 @@ public class WuyouPay {
|
||||
* @param account 支付宝账号
|
||||
* @param userName 支付宝名称
|
||||
*/
|
||||
public BaseResp extractOrder(String outOrderNo, String amount, String account, String userName) {
|
||||
public BaseResp extractOrder(String outOrderNo, Long userId, boolean isUser, String amount, String account, String userName) {
|
||||
String payConfig = commonInfoService.findOne(927).getValue();
|
||||
if (!"1".equals(payConfig)) {
|
||||
BaseResp baseResp = new BaseResp();
|
||||
@@ -125,7 +125,7 @@ public class WuyouPay {
|
||||
}
|
||||
Map<String, Object> params = getBaseParams();
|
||||
|
||||
params.put("out_trade_no", outOrderNo);
|
||||
params.put("out_trade_no", String.format("%s-%s:%s", outOrderNo, userId, isUser ? "us" : "dl"));
|
||||
params.put("total", amount);
|
||||
params.put("bank_card", account);
|
||||
params.put("bank_account_name", userName);
|
||||
@@ -151,10 +151,10 @@ public class WuyouPay {
|
||||
* @param account 支付宝账号
|
||||
* @param userName 支付宝名称
|
||||
*/
|
||||
public BaseResp extractOrderForAudit(String outOrderNo, String amount, String account, String userName) {
|
||||
public BaseResp extractOrderForAudit(String outOrderNo, Long userId, boolean isUser, String amount, String account, String userName) {
|
||||
Map<String, Object> params = getBaseParams();
|
||||
|
||||
params.put("out_trade_no", outOrderNo);
|
||||
params.put("out_trade_no", String.format("%s-%s:%s", outOrderNo, userId, isUser ? "us" : "dl"));
|
||||
params.put("total", amount);
|
||||
params.put("bank_card", account);
|
||||
params.put("bank_account_name", userName);
|
||||
@@ -174,9 +174,9 @@ public class WuyouPay {
|
||||
return JSONObject.parseObject(body, BaseResp.class);
|
||||
}
|
||||
|
||||
public BaseResp queryExtractOrder(String outOrderNo, String amount) {
|
||||
public BaseResp queryExtractOrder(String outOrderNo, Long userId, boolean isUser, String amount) {
|
||||
Map<String, Object> params = getBaseParams();
|
||||
params.put("out_trade_no", outOrderNo);
|
||||
params.put("out_trade_no", String.format("%s-%s:%s", outOrderNo, userId, isUser ? "us" : "dl"));
|
||||
params.put("total", amount);
|
||||
|
||||
String sign = Encrypt.getParamsSign(params);
|
||||
|
||||
Reference in New Issue
Block a user