## Opt - 增加回调中支付通道流水号

This commit is contained in:
sangelxiu1 2025-07-14 13:47:48 +08:00
parent 3313905cf7
commit 408690ca79
5 changed files with 31 additions and 4 deletions

View File

@ -52,6 +52,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit; import java.time.temporal.ChronoUnit;
@ -671,6 +672,8 @@ public class ApiMemberStructureController extends BaseController {
BigDecimal rightFirstSurplus = new BigDecimal(rightFirstSurplusStr.replaceAll(",", "")); BigDecimal rightFirstSurplus = new BigDecimal(rightFirstSurplusStr.replaceAll(",", ""));
result.get(0).putExtra("leftFirstSurplus", leftFirstSurplus.toString()); result.get(0).putExtra("leftFirstSurplus", leftFirstSurplus.toString());
result.get(0).putExtra("rightFirstSurplus", rightFirstSurplus.toString()); result.get(0).putExtra("rightFirstSurplus", rightFirstSurplus.toString());
result.get(0).putExtra("leftFirstSurplusAll", formatBigDecimal(leftFirstSurplus));
result.get(0).putExtra("rightFirstSurplusAll", formatBigDecimal(rightFirstSurplus));
log.info("result : {}", JSONUtil.toJsonStr(result)); log.info("result : {}", JSONUtil.toJsonStr(result));
if(leftFirstSurplus.compareTo(rightFirstSurplus) >= 0){ if(leftFirstSurplus.compareTo(rightFirstSurplus) >= 0){
// 左大右小 // 左大右小
@ -695,4 +698,23 @@ public class ApiMemberStructureController extends BaseController {
return AjaxResult.success(data); return AjaxResult.success(data);
} }
private static final BigDecimal FIVE_MILLION = BigDecimal.valueOf(5_000_000); // 500万的固定值
/**
* 格式化BigDecimal数值为指定规则的字符串
* @param input 输入的BigDecimal数值需非null
* @return 格式化后的字符串小于500万返回四舍五入两位小数否则返回"500万+"
*/
public static String formatBigDecimal(BigDecimal input) {
if (input == null) {
throw new IllegalArgumentException("输入数值不能为null");
}
int compareResult = input.compareTo(FIVE_MILLION);
if (compareResult < 0) {
BigDecimal rounded = input.setScale(2, RoundingMode.HALF_UP);
return rounded.toString();
} else {
return "500万+";
}
}
} }

View File

@ -131,13 +131,14 @@ public class JdPayNotifyController extends JdBaseController {
String thirdOrderCode = successNotify.getOutTradeNo(); String thirdOrderCode = successNotify.getOutTradeNo();
// 订单编号 // 订单编号
String orderCode = thirdOrderCode; String orderCode = thirdOrderCode;
String acqOrderId = successNotify.getAcqOrderId();
// 订单金额 // 订单金额
int tradeAmount = Integer.parseInt(successNotify.getTradeAmount()); int tradeAmount = Integer.parseInt(successNotify.getTradeAmount());
BigDecimal payMoney = new BigDecimal(tradeAmount).divide(new BigDecimal("100"), 2, BigDecimal.ROUND_HALF_UP); BigDecimal payMoney = new BigDecimal(tradeAmount).divide(new BigDecimal("100"), 2, BigDecimal.ROUND_HALF_UP);
Integer payType = convertPayType(successNotify.getPayTool()); Integer payType = convertPayType(successNotify.getPayTool());
// 支付后续业务处理 // 支付后续业务处理
if (iPayService.notifyHandle(type, orderCode, thirdOrderCode, payNumber, payTime, payMoney, EPayChannel.JD, channelNumber, payType)) { if (iPayService.notifyHandle(type, orderCode, thirdOrderCode, payNumber, payTime, payMoney, EPayChannel.JD, channelNumber, payType, acqOrderId)) {
return SUCCESS; return SUCCESS;
} }
} else { } else {

View File

@ -95,4 +95,5 @@ public class JdPayTradeSuccessNotify implements Serializable {
*/ */
private String installmentNum; private String installmentNum;
private String acqOrderId;
} }

View File

@ -30,7 +30,7 @@ public interface IPayService {
boolean notifyHandle(String businessType, String businessCode, String originalOrder, boolean notifyHandle(String businessType, String businessCode, String originalOrder,
String payNumber, Date payTime, BigDecimal payMoney, String payNumber, Date payTime, BigDecimal payMoney,
EPayChannel ePayChannel, String channelNumber, Integer payType); EPayChannel ePayChannel, String channelNumber, Integer payType, String acqOrderId);
/** /**
* 业务处理重试 * 业务处理重试

View File

@ -119,7 +119,9 @@ public class PayServiceImpl implements IPayService {
} }
@Override @Override
public boolean notifyHandle(String businessType, String businessCode, String originalOrder, String payNumber, Date payTime, BigDecimal payMoney, EPayChannel ePayChannel, String channelNumber, Integer payType) { public boolean notifyHandle(String businessType, String businessCode, String originalOrder, String payNumber,
Date payTime, BigDecimal payMoney, EPayChannel ePayChannel, String channelNumber,
Integer payType, String acqOrderId) {
Long pkId = null; Long pkId = null;
String redisKey = CacheConstants.ONLINE_PAY_KEY + businessCode; String redisKey = CacheConstants.ONLINE_PAY_KEY + businessCode;
@ -148,6 +150,7 @@ public class PayServiceImpl implements IPayService {
onlinePayment.setPkModified(MagicNumberConstants.PK_ADMIN); onlinePayment.setPkModified(MagicNumberConstants.PK_ADMIN);
onlinePayment.setModifiedTime(new Date()); onlinePayment.setModifiedTime(new Date());
onlinePayment.setPayType(payType); onlinePayment.setPayType(payType);
onlinePayment.setChannelNumber(acqOrderId);
if (null != ePayChannel) { if (null != ePayChannel) {
onlinePayment.setPayChannel(ePayChannel.getValue()); onlinePayment.setPayChannel(ePayChannel.getValue());
} }