|
@@ -245,8 +245,17 @@ public class PayServiceImpl implements PayService {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public Map<String, Object> getPayMap(BigDecimal amount, BigDecimal balanceAmount, String orderNo, String notifyUrl, String returnUrl, String orderSubject, String orderBody, Integer organId, String receiver) throws Exception {
|
|
public Map<String, Object> getPayMap(BigDecimal amount, BigDecimal balanceAmount, String orderNo, String notifyUrl, String returnUrl, String orderSubject, String orderBody, Integer organId, String receiver) throws Exception {
|
|
|
|
+ String usePaymentConfig = sysConfigDao.findConfigValue("use_payment_config");
|
|
|
|
+ List<RouteScaleDto> routeScaleDtos = null;
|
|
|
|
+ //使用配置开关
|
|
|
|
+ if (usePaymentConfig.equals("0")) {
|
|
|
|
+ routeScaleDtos = noUsePaymentConfig(organId, amount);
|
|
|
|
+ }
|
|
|
|
+
|
|
//根据金额获取分润
|
|
//根据金额获取分润
|
|
- List<RouteScaleDto> routeScaleDtos = getAmountChannel(organId, amount, receiver);
|
|
|
|
|
|
+ if (routeScaleDtos == null) {
|
|
|
|
+ routeScaleDtos = getAmountChannel(organId, amount, receiver);
|
|
|
|
+ }
|
|
//零星支付,收到指定
|
|
//零星支付,收到指定
|
|
if (routeScaleDtos == null) {
|
|
if (routeScaleDtos == null) {
|
|
routeScaleDtos = getSporadicChannel(amount, receiver);
|
|
routeScaleDtos = getSporadicChannel(amount, receiver);
|
|
@@ -259,10 +268,33 @@ public class PayServiceImpl implements PayService {
|
|
return getPayRoute(amount, balanceAmount, orderNo, notifyUrl, returnUrl, orderSubject, orderBody, routeScaleDtos);
|
|
return getPayRoute(amount, balanceAmount, orderNo, notifyUrl, returnUrl, orderSubject, orderBody, routeScaleDtos);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private List<RouteScaleDto> noUsePaymentConfig(Integer organId, BigDecimal amount) {
|
|
|
|
+ String paymentChannel = sysConfigDao.findConfigValue("payment_channel");
|
|
|
|
+ List<RouteScaleDto> routeScaleDtos = new ArrayList<>();
|
|
|
|
+ RouteScaleDto routeScaleDto = new RouteScaleDto();
|
|
|
|
+ routeScaleDto.setAmount(amount);
|
|
|
|
+ routeScaleDto.setOrganId(organId);
|
|
|
|
+ routeScaleDto.setScale(100);
|
|
|
|
+ if (paymentChannel.equals("YQPAY")) {
|
|
|
|
+ routeScaleDto.setMerNo(YqPayUtil.merNo);
|
|
|
|
+ routeScaleDto.setPayType(PaymentChannelEnum.YQPAY);
|
|
|
|
+ routeScaleDto.setFeeFlag("Y");
|
|
|
|
+ } else {
|
|
|
|
+ routeScaleDto.setMerNo(ConfigInit.merNo);
|
|
|
|
+ routeScaleDto.setPayType(PaymentChannelEnum.ADAPAY);
|
|
|
|
+ routeScaleDto.setFeeFlag("Y");
|
|
|
|
+ }
|
|
|
|
+ routeScaleDtos.add(routeScaleDto);
|
|
|
|
+ return routeScaleDtos;
|
|
|
|
+ }
|
|
|
|
+
|
|
private List<RouteScaleDto> getPaymentConfigChannel(Integer organId, BigDecimal amount) {
|
|
private List<RouteScaleDto> getPaymentConfigChannel(Integer organId, BigDecimal amount) {
|
|
SysPaymentConfig paymentConfig = sysPaymentConfigService.findPaymentConfigByOrganId(organId);
|
|
SysPaymentConfig paymentConfig = sysPaymentConfigService.findPaymentConfigByOrganId(organId);
|
|
if (paymentConfig == null || StringUtils.isBlank(paymentConfig.getRouteScale())) {
|
|
if (paymentConfig == null || StringUtils.isBlank(paymentConfig.getRouteScale())) {
|
|
String paymentChannel = sysConfigDao.findConfigValue("payment_channel");
|
|
String paymentChannel = sysConfigDao.findConfigValue("payment_channel");
|
|
|
|
+ if (paymentConfig != null) {
|
|
|
|
+ paymentChannel = paymentConfig.getPayType().getCode();
|
|
|
|
+ }
|
|
List<RouteScaleDto> routeScaleDtos = new ArrayList<>();
|
|
List<RouteScaleDto> routeScaleDtos = new ArrayList<>();
|
|
RouteScaleDto routeScaleDto = new RouteScaleDto();
|
|
RouteScaleDto routeScaleDto = new RouteScaleDto();
|
|
routeScaleDto.setAmount(amount);
|
|
routeScaleDto.setAmount(amount);
|
|
@@ -271,6 +303,7 @@ public class PayServiceImpl implements PayService {
|
|
if (paymentChannel.equals("YQPAY")) {
|
|
if (paymentChannel.equals("YQPAY")) {
|
|
routeScaleDto.setMerNo(YqPayUtil.merNo);
|
|
routeScaleDto.setMerNo(YqPayUtil.merNo);
|
|
routeScaleDto.setPayType(PaymentChannelEnum.YQPAY);
|
|
routeScaleDto.setPayType(PaymentChannelEnum.YQPAY);
|
|
|
|
+ routeScaleDto.setFeeFlag("Y");
|
|
} else {
|
|
} else {
|
|
routeScaleDto.setMerNo(ConfigInit.merNo);
|
|
routeScaleDto.setMerNo(ConfigInit.merNo);
|
|
routeScaleDto.setPayType(PaymentChannelEnum.ADAPAY);
|
|
routeScaleDto.setPayType(PaymentChannelEnum.ADAPAY);
|
|
@@ -299,7 +332,7 @@ public class PayServiceImpl implements PayService {
|
|
|
|
|
|
//笔数比例
|
|
//笔数比例
|
|
if (paymentConfig.getType().equals(1)) {
|
|
if (paymentConfig.getType().equals(1)) {
|
|
- int payOrderNums = studentPaymentOrderService.findPayOrderNum(); //获取支付中和成功的订单数
|
|
|
|
|
|
+ int payOrderNums = studentPaymentOrderService.findOrganPayOrderNum(organId); //获取支付中和成功的订单数
|
|
int rem = payOrderNums % 10;
|
|
int rem = payOrderNums % 10;
|
|
rem = rem == 0 ? 10 : rem;
|
|
rem = rem == 0 ? 10 : rem;
|
|
|
|
|
|
@@ -308,12 +341,15 @@ public class PayServiceImpl implements PayService {
|
|
while (iterator.hasNext()) {
|
|
while (iterator.hasNext()) {
|
|
RouteScaleDto routeScaleDto = iterator.next();
|
|
RouteScaleDto routeScaleDto = iterator.next();
|
|
Integer num = routeScaleDto.getScale();
|
|
Integer num = routeScaleDto.getScale();
|
|
|
|
+ boolean flag = false;
|
|
if (rem > scale && rem <= scale + num) {
|
|
if (rem > scale && rem <= scale + num) {
|
|
routeScaleDto.setScale(100);
|
|
routeScaleDto.setScale(100);
|
|
- continue;
|
|
|
|
|
|
+ flag = true;
|
|
}
|
|
}
|
|
scale += num;
|
|
scale += num;
|
|
- iterator.remove();
|
|
|
|
|
|
+ if (!flag) {
|
|
|
|
+ iterator.remove();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return routeScaleDtos;
|
|
return routeScaleDtos;
|
|
@@ -333,7 +369,7 @@ public class PayServiceImpl implements PayService {
|
|
Set<String> musicGroupType = new HashSet<>();
|
|
Set<String> musicGroupType = new HashSet<>();
|
|
musicGroupType.add("renew");
|
|
musicGroupType.add("renew");
|
|
musicGroupType.add("register");
|
|
musicGroupType.add("register");
|
|
- if(musicGroupType.contains(receiver)){
|
|
|
|
|
|
+ if (musicGroupType.contains(receiver)) {
|
|
receiver = "musicGroupBuy";
|
|
receiver = "musicGroupBuy";
|
|
}
|
|
}
|
|
|
|
|
|
@@ -391,14 +427,14 @@ public class PayServiceImpl implements PayService {
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
- Map<String, String> channel = (Map<String, String>) JSON.parseObject(SporadicChannel, Map.class);
|
|
|
|
|
|
+ Map<String, Object> channel = (Map<String, Object>) JSON.parseObject(SporadicChannel, Map.class);
|
|
|
|
|
|
- BigDecimal minReceiptMoney = new BigDecimal(channel.get("minReceiptMoney")); //最小接收的金额(不包含)
|
|
|
|
|
|
+ BigDecimal minReceiptMoney = new BigDecimal(channel.get("minReceipt").toString()); //最小接收的金额(不包含)
|
|
if (amount.compareTo(minReceiptMoney) <= 0) {
|
|
if (amount.compareTo(minReceiptMoney) <= 0) {
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
- Integer organId = Integer.parseInt(channel.get("organId"));
|
|
|
|
|
|
+ Integer organId = Integer.parseInt(channel.get("organId").toString());
|
|
if (checkHasMaxReceipt(organId, amount)) {
|
|
if (checkHasMaxReceipt(organId, amount)) {
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
@@ -439,10 +475,12 @@ public class PayServiceImpl implements PayService {
|
|
paymentChannelList.add(PaymentChannelEnum.ADAPAY);
|
|
paymentChannelList.add(PaymentChannelEnum.ADAPAY);
|
|
|
|
|
|
BigDecimal monthHasReceipt = studentPaymentRouteOrderDao.getRouteOrderAmount(organId, paymentChannelList, monthStartTime);
|
|
BigDecimal monthHasReceipt = studentPaymentRouteOrderDao.getRouteOrderAmount(organId, paymentChannelList, monthStartTime);
|
|
|
|
+ monthHasReceipt = monthHasReceipt == null ? BigDecimal.ZERO : monthHasReceipt;
|
|
if (amount.add(monthHasReceipt).compareTo(monthMaxReceipt) >= 0) {
|
|
if (amount.add(monthHasReceipt).compareTo(monthMaxReceipt) >= 0) {
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
BigDecimal totalHasReceipt = studentPaymentRouteOrderDao.getRouteOrderAmount(organId, paymentChannelList, null);
|
|
BigDecimal totalHasReceipt = studentPaymentRouteOrderDao.getRouteOrderAmount(organId, paymentChannelList, null);
|
|
|
|
+ totalHasReceipt = totalHasReceipt == null ? BigDecimal.ZERO : totalHasReceipt;
|
|
if (amount.add(totalHasReceipt).compareTo(totalMaxReceipt) >= 0) {
|
|
if (amount.add(totalHasReceipt).compareTo(totalMaxReceipt) >= 0) {
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
@@ -460,9 +498,11 @@ public class PayServiceImpl implements PayService {
|
|
int i = 0;
|
|
int i = 0;
|
|
BigDecimal hasRouteAmount = BigDecimal.ZERO;
|
|
BigDecimal hasRouteAmount = BigDecimal.ZERO;
|
|
BigDecimal hasRouteBalanceAmount = BigDecimal.ZERO;
|
|
BigDecimal hasRouteBalanceAmount = BigDecimal.ZERO;
|
|
|
|
+ BigDecimal hasRouteMoney = BigDecimal.ZERO;
|
|
List<Map<String, Object>> tempRoutingList = new ArrayList<>();
|
|
List<Map<String, Object>> tempRoutingList = new ArrayList<>();
|
|
|
|
|
|
PaymentChannelEnum patType = null;
|
|
PaymentChannelEnum patType = null;
|
|
|
|
+ boolean feeFlag = false;
|
|
for (RouteScaleDto routeScaleDto : routeScaleDtos) {
|
|
for (RouteScaleDto routeScaleDto : routeScaleDtos) {
|
|
patType = routeScaleDto.getPayType();
|
|
patType = routeScaleDto.getPayType();
|
|
Map<String, Object> routingList = new HashMap<>();
|
|
Map<String, Object> routingList = new HashMap<>();
|
|
@@ -474,26 +514,36 @@ public class PayServiceImpl implements PayService {
|
|
}
|
|
}
|
|
BigDecimal routingFee = routingAmount.multiply(new BigDecimal(routeScaleDto.getScale())).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP);
|
|
BigDecimal routingFee = routingAmount.multiply(new BigDecimal(routeScaleDto.getScale())).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP);
|
|
BigDecimal routeBalanceAmount = balanceAmount.multiply(new BigDecimal(routeScaleDto.getScale())).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP);
|
|
BigDecimal routeBalanceAmount = balanceAmount.multiply(new BigDecimal(routeScaleDto.getScale())).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
+ BigDecimal routingMoney = amount.multiply(new BigDecimal(routeScaleDto.getScale())).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP);
|
|
if (i == routeScaleDtos.size()) {
|
|
if (i == routeScaleDtos.size()) {
|
|
routingFee = routingAmount.subtract(hasRouteAmount).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
routingFee = routingAmount.subtract(hasRouteAmount).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
routeBalanceAmount = balanceAmount.subtract(hasRouteBalanceAmount).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
routeBalanceAmount = balanceAmount.subtract(hasRouteBalanceAmount).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
+ routingMoney = amount.subtract(hasRouteMoney).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
}
|
|
}
|
|
- hasRouteAmount = hasRouteAmount.add(routingFee);
|
|
|
|
- hasRouteBalanceAmount = hasRouteBalanceAmount.add(routeBalanceAmount);
|
|
|
|
|
|
|
|
if (routingFee.compareTo(BigDecimal.ZERO) <= 0) {
|
|
if (routingFee.compareTo(BigDecimal.ZERO) <= 0) {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ hasRouteAmount = hasRouteAmount.add(routingFee);
|
|
|
|
+ hasRouteBalanceAmount = hasRouteBalanceAmount.add(routeBalanceAmount);
|
|
|
|
+ hasRouteMoney = hasRouteMoney.add(routingMoney);
|
|
|
|
+
|
|
routingList.put("routingMerNo", routeScaleDto.getMerNo());//分佣账户
|
|
routingList.put("routingMerNo", routeScaleDto.getMerNo());//分佣账户
|
|
routingList.put("routingFee", routingFee); //分佣金额
|
|
routingList.put("routingFee", routingFee); //分佣金额
|
|
-
|
|
|
|
tempRoutingList.add(routingList);
|
|
tempRoutingList.add(routingList);
|
|
|
|
+ if (routeScaleDto.getFeeFlag().equals("Y")) {
|
|
|
|
+ feeFlag = true;
|
|
|
|
+ }
|
|
|
|
+ if (i == routeScaleDtos.size() && !feeFlag) {
|
|
|
|
+ routeScaleDto.setFeeFlag("Y");
|
|
|
|
+ }
|
|
|
|
|
|
StudentPaymentRouteOrder studentPaymentRouteOrder = new StudentPaymentRouteOrder();
|
|
StudentPaymentRouteOrder studentPaymentRouteOrder = new StudentPaymentRouteOrder();
|
|
studentPaymentRouteOrder.setOrderNo(orderNo);
|
|
studentPaymentRouteOrder.setOrderNo(orderNo);
|
|
studentPaymentRouteOrder.setRouteOrganId(routeScaleDto.getOrganId());
|
|
studentPaymentRouteOrder.setRouteOrganId(routeScaleDto.getOrganId());
|
|
studentPaymentRouteOrder.setFeeFlag(routeScaleDto.getFeeFlag());
|
|
studentPaymentRouteOrder.setFeeFlag(routeScaleDto.getFeeFlag());
|
|
- studentPaymentRouteOrder.setRouteAmount(routingFee);
|
|
|
|
|
|
+ studentPaymentRouteOrder.setRouteAmount(routingMoney);
|
|
studentPaymentRouteOrder.setRouteBalanceAmount(routeBalanceAmount);
|
|
studentPaymentRouteOrder.setRouteBalanceAmount(routeBalanceAmount);
|
|
studentPaymentRouteOrder.setMerNo(routeScaleDto.getMerNo());
|
|
studentPaymentRouteOrder.setMerNo(routeScaleDto.getMerNo());
|
|
RouteOrders.add(studentPaymentRouteOrder);
|
|
RouteOrders.add(studentPaymentRouteOrder);
|