|
@@ -1,31 +1,42 @@
|
|
|
package com.ym.mec.biz.service.impl;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.HashSet;
|
|
|
+import java.util.Iterator;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Set;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.ym.mec.biz.dal.dao.HfMemberDao;
|
|
|
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.*;
|
|
|
+import com.ym.mec.biz.dal.entity.HfMember;
|
|
|
+import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
|
|
|
+import com.ym.mec.biz.dal.entity.StudentPaymentRouteOrder;
|
|
|
+import com.ym.mec.biz.dal.entity.SysPaymentConfig;
|
|
|
import com.ym.mec.biz.dal.enums.FeeTypeEnum;
|
|
|
import com.ym.mec.biz.dal.enums.PaymentChannelEnum;
|
|
|
-import com.ym.mec.biz.service.*;
|
|
|
+import com.ym.mec.biz.service.PayService;
|
|
|
+import com.ym.mec.biz.service.SellOrderService;
|
|
|
+import com.ym.mec.biz.service.StudentPaymentOrderService;
|
|
|
+import com.ym.mec.biz.service.SysPaymentConfigService;
|
|
|
import com.ym.mec.common.exception.BizException;
|
|
|
import com.ym.mec.common.redis.service.RedisCache;
|
|
|
import com.ym.mec.thirdparty.adapay.ConfigInit;
|
|
|
import com.ym.mec.thirdparty.adapay.Payment;
|
|
|
import com.ym.mec.thirdparty.yqpay.YqPayUtil;
|
|
|
import com.ym.mec.util.date.DateUtil;
|
|
|
-import org.apache.commons.lang3.StringUtils;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.data.redis.core.RedisTemplate;
|
|
|
-import org.springframework.data.redis.core.ValueOperations;
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
-
|
|
|
-import java.math.BigDecimal;
|
|
|
-import java.util.*;
|
|
|
-import java.util.concurrent.TimeUnit;
|
|
|
-import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 支付服务类
|
|
@@ -49,6 +60,52 @@ 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 {
|
|
|
+
|
|
|
+ StudentPaymentOrder studentPaymentOrder = studentPaymentOrderService.findOrderByOrderNo(orderNo);
|
|
|
+
|
|
|
+ if(studentPaymentOrder == null){
|
|
|
+ throw new BizException("订单[{}]查询失败", orderNo);
|
|
|
+ }
|
|
|
+
|
|
|
+ Integer tenantId = studentPaymentOrder.getTenantId();
|
|
|
+
|
|
|
+ if(tenantId != 1){//非大雅机构
|
|
|
+
|
|
|
+ SysPaymentConfig sysPaymentConfig = sysPaymentConfigService.findPaymentConfigByOrganId(organId);
|
|
|
+
|
|
|
+ if(sysPaymentConfig == null || StringUtils.isBlank(sysPaymentConfig.getHfMerNo())){
|
|
|
+ throw new BizException("分部[{}]没有设置收款账号", organId);
|
|
|
+ }
|
|
|
+
|
|
|
+ Date date = new Date();
|
|
|
+
|
|
|
+ String merNo = sysPaymentConfig.getHfMerNo();
|
|
|
+
|
|
|
+ StudentPaymentRouteOrder studentPaymentRouteOrder = new StudentPaymentRouteOrder();
|
|
|
+ studentPaymentRouteOrder.setOrderNo(orderNo);
|
|
|
+ studentPaymentRouteOrder.setRouteOrganId(organId);
|
|
|
+ studentPaymentRouteOrder.setFeeFlag("Y");
|
|
|
+ studentPaymentRouteOrder.setRouteAmount(amount);
|
|
|
+ studentPaymentRouteOrder.setRouteBalanceAmount(balanceAmount);
|
|
|
+ studentPaymentRouteOrder.setMerNo(merNo);
|
|
|
+ studentPaymentRouteOrder.setSaleAmount(BigDecimal.ZERO);
|
|
|
+ studentPaymentRouteOrder.setServiceAmount(amount);
|
|
|
+ studentPaymentRouteOrder.setCreateTime(date);
|
|
|
+ studentPaymentRouteOrder.setUpdateTime(date);
|
|
|
+ studentPaymentRouteOrderDao.insert(studentPaymentRouteOrder);
|
|
|
+
|
|
|
+ Map<String, Object> unionPay = new HashMap<>();
|
|
|
+ Map<String, Object> payMap = Payment.getPayMap(amount, orderNo, notifyUrl, returnUrl, orderSubject, orderBody);
|
|
|
+
|
|
|
+ PaymentChannelEnum payType = PaymentChannelEnum.ADAPAY;
|
|
|
+
|
|
|
+ unionPay.put("orderNo", orderNo);
|
|
|
+ unionPay.put("type", payType.getCode());
|
|
|
+ unionPay.put("payMap", payMap);
|
|
|
+ unionPay.put("routingMerNos", merNo);
|
|
|
+ return unionPay;
|
|
|
+ }
|
|
|
+
|
|
|
String usePaymentConfig = sysConfigDao.findConfigValue("use_payment_config");// 是否用收费配置(1:使用 0:不使用)
|
|
|
List<RouteScaleDto> routeScaleDtos = null;
|
|
|
//使用配置开关
|
|
@@ -82,7 +139,28 @@ public class PayServiceImpl implements PayService {
|
|
|
return getPayRoute(amount, balanceAmount, orderNo, notifyUrl, returnUrl, orderSubject, orderBody, routeScaleDtos);
|
|
|
}
|
|
|
|
|
|
- private List<RouteScaleDto> noUsePaymentConfig(BigDecimal amount) {
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> getPayToPlatformMap(PaymentChannelEnum paymentChannel, String payeeMerNo, BigDecimal amount, BigDecimal balanceAmount, String orderNo, String notifyUrl, String returnUrl,
|
|
|
+ String orderSubject, String orderBody) throws Exception {
|
|
|
+
|
|
|
+ Map<String, Object> payMap = null;
|
|
|
+
|
|
|
+ if (paymentChannel.equals(PaymentChannelEnum.YQPAY)) {
|
|
|
+ payMap = YqPayUtil.getPayMap(amount, orderNo, notifyUrl, returnUrl, orderSubject, orderBody, YqPayUtil.merNo, payeeMerNo);
|
|
|
+ } else {
|
|
|
+ payMap = Payment.getPayMap(amount, orderNo, notifyUrl, returnUrl, orderSubject, orderBody);
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, Object> unionPay = new HashMap<>();
|
|
|
+ unionPay.put("orderNo", orderNo);
|
|
|
+ unionPay.put("type", paymentChannel.getCode());
|
|
|
+ unionPay.put("payMap", payMap);
|
|
|
+ unionPay.put("routingMerNos", payeeMerNo);
|
|
|
+
|
|
|
+ return unionPay;
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<RouteScaleDto> noUsePaymentConfig(BigDecimal amount) {
|
|
|
String paymentChannel = sysConfigDao.findConfigValue("payment_channel");
|
|
|
List<RouteScaleDto> routeScaleDtos = new ArrayList<>();
|
|
|
RouteScaleDto routeScaleDto = new RouteScaleDto();
|
|
@@ -399,7 +477,7 @@ public class PayServiceImpl implements PayService {
|
|
|
}
|
|
|
payMap = YqPayUtil.getPayMap(amount, orderNo, notifyUrl, returnUrl, orderSubject, orderBody, YqPayUtil.merNo, tempRoutingList);
|
|
|
} else {
|
|
|
- payMap = Payment.getPayMap(amount, orderNo, notifyUrl, returnUrl, orderSubject, orderBody, ConfigInit.merNo, tempRoutingList);
|
|
|
+ payMap = Payment.getPayMap(amount, orderNo, notifyUrl, returnUrl, orderSubject, orderBody);
|
|
|
}
|
|
|
String routingMerNos = String.join(",", routingMerNoSet);
|
|
|
|