|
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
|
|
|
import com.ym.mec.biz.dal.dao.MusicGroupDao;
|
|
|
import com.ym.mec.biz.dal.dao.StudentPaymentRouteOrderDao;
|
|
|
import com.ym.mec.biz.dal.dao.SysConfigDao;
|
|
|
+import com.ym.mec.biz.dal.dto.AmountChannelDto;
|
|
|
import com.ym.mec.biz.dal.dto.RouteScaleDto;
|
|
|
import com.ym.mec.biz.dal.entity.StudentPaymentRouteOrder;
|
|
|
import com.ym.mec.biz.dal.entity.SysAccount;
|
|
@@ -245,10 +246,10 @@ public class PayServiceImpl implements PayService {
|
|
|
@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 {
|
|
|
//根据金额获取分润
|
|
|
- List<RouteScaleDto> routeScaleDtos = getAmountChannel(amount);
|
|
|
+ List<RouteScaleDto> routeScaleDtos = getAmountChannel(organId, amount, receiver);
|
|
|
//零星支付,收到指定
|
|
|
- if (routeScaleDtos == null && receiver != null && receiver.equals("sporadic")) {
|
|
|
- routeScaleDtos = getSporadicChannel(amount);
|
|
|
+ if (routeScaleDtos == null) {
|
|
|
+ routeScaleDtos = getSporadicChannel(amount, receiver);
|
|
|
}
|
|
|
//比例或者笔数分佣
|
|
|
if (routeScaleDtos == null) {
|
|
@@ -324,24 +325,41 @@ public class PayServiceImpl implements PayService {
|
|
|
*
|
|
|
* @param amount 金额
|
|
|
*/
|
|
|
- private List<RouteScaleDto> getAmountChannel(BigDecimal amount) {
|
|
|
+ private List<RouteScaleDto> getAmountChannel(Integer organId, BigDecimal amount, String receiver) {
|
|
|
String amountChannel = sysConfigDao.findConfigValue("amount_channel");
|
|
|
if (StringUtils.isBlank(amountChannel)) {
|
|
|
return null;
|
|
|
}
|
|
|
- Integer organId = null;
|
|
|
- Map<String, Integer> channel = (Map<String, Integer>) JSON.parseObject(amountChannel, Map.class);
|
|
|
- for (Map.Entry<String, Integer> amountStr : channel.entrySet()) {
|
|
|
- if (new BigDecimal(amountStr.getKey()).compareTo(amount) == 0) {
|
|
|
- organId = amountStr.getValue();
|
|
|
+ Set<String> musicGroupType = new HashSet<>();
|
|
|
+ musicGroupType.add("renew");
|
|
|
+ musicGroupType.add("register");
|
|
|
+ if(musicGroupType.contains(receiver)){
|
|
|
+ receiver = "musicGroupBuy";
|
|
|
+ }
|
|
|
+
|
|
|
+ Integer routeOrganId = null;
|
|
|
+ List<AmountChannelDto> amountChannelDtoList = JSON.parseArray(amountChannel, AmountChannelDto.class);
|
|
|
+ for (AmountChannelDto amountChannelDto : amountChannelDtoList) {
|
|
|
+ if (amountChannelDto.getOrganId().equals(organId) &&
|
|
|
+ amount.compareTo(amountChannelDto.getAmount()) == 0 &&
|
|
|
+ receiver.equals(amountChannelDto.getType())
|
|
|
+ ) {
|
|
|
+ routeOrganId = amountChannelDto.getRouteOrganId();
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- if (organId == null) {
|
|
|
+
|
|
|
+ if (routeOrganId == null) {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- SysPaymentConfig paymentConfig = sysPaymentConfigService.findPaymentConfigByOrganId(organId);
|
|
|
+ //调度到 鎏逸乐器经营部 检测限定金额
|
|
|
+ if (checkHasMaxReceipt(routeOrganId, amount)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ SysPaymentConfig paymentConfig = sysPaymentConfigService.findPaymentConfigByOrganId(routeOrganId);
|
|
|
+
|
|
|
RouteScaleDto routeScaleDto = new RouteScaleDto();
|
|
|
List<RouteScaleDto> routeScaleDtos = new ArrayList<>();
|
|
|
routeScaleDto.setAmount(amount);
|
|
@@ -364,7 +382,10 @@ public class PayServiceImpl implements PayService {
|
|
|
* @param amount
|
|
|
* @return
|
|
|
*/
|
|
|
- private List<RouteScaleDto> getSporadicChannel(BigDecimal amount) {
|
|
|
+ private List<RouteScaleDto> getSporadicChannel(BigDecimal amount, String receiver) {
|
|
|
+ if (receiver == null || !receiver.equals("sporadic")) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
String SporadicChannel = sysConfigDao.findConfigValue("sporadic_channel");
|
|
|
if (StringUtils.isBlank(SporadicChannel)) {
|
|
|
return null;
|
|
@@ -378,26 +399,10 @@ public class PayServiceImpl implements PayService {
|
|
|
}
|
|
|
|
|
|
Integer organId = Integer.parseInt(channel.get("organId"));
|
|
|
- BigDecimal monthMaxReceipt = new BigDecimal(channel.get("maxReceipt")); //每月限定金额
|
|
|
- BigDecimal totalMaxReceipt = new BigDecimal(channel.get("totalMaxReceipt")); //总限定金额(500W)
|
|
|
-
|
|
|
- Date monthStartTime = DateUtil.getFirstDayOfMonth(new Date());
|
|
|
-
|
|
|
-
|
|
|
- //已收金额
|
|
|
- List<PaymentChannelEnum> paymentChannelList = new ArrayList<>();
|
|
|
- paymentChannelList.add(PaymentChannelEnum.YQPAY);
|
|
|
- paymentChannelList.add(PaymentChannelEnum.ADAPAY);
|
|
|
-
|
|
|
- BigDecimal monthHasReceipt = studentPaymentRouteOrderDao.getRouteOrderAmount(organId, paymentChannelList, monthStartTime);
|
|
|
- if (monthHasReceipt.compareTo(monthMaxReceipt) >= 0) {
|
|
|
- return null;
|
|
|
- }
|
|
|
- BigDecimal totalHasReceipt = studentPaymentRouteOrderDao.getRouteOrderAmount(organId, paymentChannelList, null);
|
|
|
- if (totalHasReceipt.compareTo(totalMaxReceipt) >= 0) {
|
|
|
+ if (checkHasMaxReceipt(organId, amount)) {
|
|
|
return null;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
SysPaymentConfig paymentConfig = sysPaymentConfigService.findPaymentConfigByOrganId(organId);
|
|
|
|
|
|
RouteScaleDto routeScaleDto = new RouteScaleDto();
|
|
@@ -416,6 +421,34 @@ public class PayServiceImpl implements PayService {
|
|
|
return routeScaleDtos;
|
|
|
}
|
|
|
|
|
|
+ //按金额和零星支付(调度到 鎏逸乐器经营部 检测限定金额)
|
|
|
+ private Boolean checkHasMaxReceipt(Integer organId, BigDecimal amount) {
|
|
|
+ SysPaymentConfig paymentConfig = sysPaymentConfigService.findPaymentConfigByOrganId(organId);
|
|
|
+
|
|
|
+ if (!paymentConfig.getHfMerNo().equals("H004218")) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ BigDecimal monthMaxReceipt = new BigDecimal(75000); //每月限定金额
|
|
|
+ BigDecimal totalMaxReceipt = new BigDecimal(5000000); //总限定金额(500W)
|
|
|
+
|
|
|
+ Date monthStartTime = DateUtil.getFirstDayOfMonth(new Date());
|
|
|
+
|
|
|
+ //已收金额
|
|
|
+ List<PaymentChannelEnum> paymentChannelList = new ArrayList<>();
|
|
|
+ paymentChannelList.add(PaymentChannelEnum.YQPAY);
|
|
|
+ paymentChannelList.add(PaymentChannelEnum.ADAPAY);
|
|
|
+
|
|
|
+ BigDecimal monthHasReceipt = studentPaymentRouteOrderDao.getRouteOrderAmount(organId, paymentChannelList, monthStartTime);
|
|
|
+ if (amount.add(monthHasReceipt).compareTo(monthMaxReceipt) >= 0) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ BigDecimal totalHasReceipt = studentPaymentRouteOrderDao.getRouteOrderAmount(organId, paymentChannelList, null);
|
|
|
+ if (amount.add(totalHasReceipt).compareTo(totalMaxReceipt) >= 0) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
private Map<String, Object> getPayRoute(BigDecimal amount, BigDecimal balanceAmount, String orderNo, String notifyUrl, String returnUrl, String orderSubject, String orderBody, List<RouteScaleDto> routeScaleDtos) throws Exception {
|
|
|
Map<String, Object> unionPay = new HashMap<>();
|
|
|
Map<String, Object> payMap = null;
|