浏览代码

增加分润财务订单

周箭河 5 年之前
父节点
当前提交
be16de4f40

+ 2 - 50
mec-biz/src/main/java/com/ym/mec/biz/service/impl/PayServiceImpl.java

@@ -560,14 +560,10 @@ public class PayServiceImpl implements PayService {
             return routingFee;
         }
 
-        SysPaymentConfig paymentConfig = sysPaymentConfigService.findPaymentConfigByOrganId(organId);
 
         int payOrderNums = studentPaymentOrderService.findPayOrderNum(); //获取支付中和成功的订单数
         //前几笔收入私户
-        Integer nums = Integer.parseInt(sysConfigDao.findConfigValue("per_account_nums"));
-        if (paymentConfig != null && paymentConfig.getType().equals(1)) {
-            nums = paymentConfig.getPerScale();
-        }
+        int nums = Integer.parseInt(sysConfigDao.findConfigValue("per_account_nums"));
 
         String type = null;
         int rem = (payOrderNums + 1) % 10;
@@ -577,26 +573,6 @@ public class PayServiceImpl implements PayService {
             type = "COM";
         }
         routingFee.put(type, amount);
-
-        if (paymentConfig == null || !paymentConfig.getType().equals(2)) {
-            return routingFee;
-        }
-        routingFee.put(type, BigDecimal.ZERO);
-        for (Map.Entry<String, BigDecimal> feeEntry : fee.entrySet()) {
-            if (feeEntry.getKey().equals("course")) {
-                BigDecimal RoutingFee = routingFee.get(paymentConfig.getCourseFee()).add(feeEntry.getValue());
-                routingFee.put(paymentConfig.getCourseFee(), RoutingFee);
-            } else if (feeEntry.getKey().equals("instrument")) {
-                BigDecimal RoutingFee = routingFee.get(paymentConfig.getInstrumentFee()).add(feeEntry.getValue());
-                routingFee.put(paymentConfig.getInstrumentFee(), RoutingFee);
-            } else if (feeEntry.getKey().equals("accessories")) {
-                BigDecimal RoutingFee = routingFee.get(paymentConfig.getAccessoriesFee()).add(feeEntry.getValue());
-                routingFee.put(paymentConfig.getAccessoriesFee(), RoutingFee);
-            } else if (feeEntry.getKey().equals("other")) {
-                BigDecimal RoutingFee = routingFee.get(paymentConfig.getOtherFee()).add(feeEntry.getValue());
-                routingFee.put(paymentConfig.getOtherFee(), RoutingFee);
-            }
-        }
         return routingFee;
     }
 
@@ -615,14 +591,9 @@ public class PayServiceImpl implements PayService {
             return routingFee;
         }
 
-        SysPaymentConfig paymentConfig = sysPaymentConfigService.findPaymentConfigByOrganId(organId);
-
         int payOrderNums = studentPaymentOrderService.findPayOrderNum(); //获取支付中和成功的订单数
         //前几笔收入私户
-        Integer nums = Integer.parseInt(sysConfigDao.findConfigValue("per_account_nums"));
-        if (paymentConfig != null && paymentConfig.getType().equals(1)) {
-            nums = paymentConfig.getPerScale();
-        }
+        int nums = Integer.parseInt(sysConfigDao.findConfigValue("per_account_nums"));
 
         String type = null;
         int rem = (payOrderNums + 1) % 10;
@@ -633,25 +604,6 @@ public class PayServiceImpl implements PayService {
         }
         routingFee.put(type, amount);
 
-        if (paymentConfig == null || !paymentConfig.getType().equals(2)) {
-            return routingFee;
-        }
-        routingFee.put(type, BigDecimal.ZERO);
-        for (Map.Entry<String, BigDecimal> feeEntry : fee.entrySet()) {
-            if (feeEntry.getKey().equals("course")) {
-                BigDecimal RoutingFee = routingFee.get(paymentConfig.getCourseFee()).add(feeEntry.getValue());
-                routingFee.put(paymentConfig.getCourseFee(), RoutingFee);
-            } else if (feeEntry.getKey().equals("instrument")) {
-                BigDecimal RoutingFee = routingFee.get(paymentConfig.getInstrumentFee()).add(feeEntry.getValue());
-                routingFee.put(paymentConfig.getInstrumentFee(), RoutingFee);
-            } else if (feeEntry.getKey().equals("accessories")) {
-                BigDecimal RoutingFee = routingFee.get(paymentConfig.getAccessoriesFee()).add(feeEntry.getValue());
-                routingFee.put(paymentConfig.getAccessoriesFee(), RoutingFee);
-            } else if (feeEntry.getKey().equals("other")) {
-                BigDecimal RoutingFee = routingFee.get(paymentConfig.getOtherFee()).add(feeEntry.getValue());
-                routingFee.put(paymentConfig.getOtherFee(), RoutingFee);
-            }
-        }
         return routingFee;
     }
 

+ 16 - 13
mec-biz/src/main/java/com/ym/mec/biz/service/impl/VipGroupServiceImpl.java

@@ -46,7 +46,7 @@ import java.util.stream.Collectors;
 
 @Service
 public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> implements VipGroupService {
-	
+
 	@Autowired
 	private VipGroupDao vipGroupDao;
 	@Autowired
@@ -137,6 +137,8 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 	private OrganizationDao organizationDao;
 	@Autowired
 	private GroupClassService groupClassService;
+	@Autowired
+	private StudentPaymentRouteOrderService studentPaymentRouteOrderService;
 
 	private static final Logger LOGGER = LoggerFactory
 			.getLogger(VipGroup.class);
@@ -233,7 +235,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 			}
 		}else{
 			VipGroupDefaultClassesCycle vipGroupDefaultClassesCycle = vipGroupDefaultClassesCycleDao.findByOrganAndClassTimes(totalClassTimes);
-			
+
 			if (vipGroupDefaultClassesCycle != null) {
 				int month = DateUtil.monthsBetween(firstCourseSchedule.getStartClassTime(), latestCourseSchedule.getEndClassTime());
 				if (month > vipGroupDefaultClassesCycle.getMonth()) {
@@ -1242,7 +1244,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 
 	@Override
 	@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
-	public Map buyVipGroup(VipGroupBuyParamsDto vipGroupBuyParams) {
+	public Map buyVipGroup(VipGroupBuyParamsDto vipGroupBuyParams) throws Exception {
 		SysUser user = sysUserFeignService.queryUserInfo();
 		if(user == null){
 			throw new BizException("用户信息获取失败");
@@ -1321,11 +1323,14 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 		studentPaymentOrder.setActualAmount(studentPaymentOrder.getExpectAmount());
 		studentPaymentOrder.setMusicGroupId(vipGroup.getId().toString());
 		studentPaymentOrder.setClassGroupId(classGroup.getId());
+		studentPaymentOrder.setOrganId(vipGroup.getOrganId());
 		studentPaymentOrder.setVersion(0);
 		studentPaymentOrderDao.insert(studentPaymentOrder);
 
 		BigDecimal amount=vipGroup.getTotalPrice();
+		BigDecimal balance = BigDecimal.ZERO;
 		if("36".equals(user.getOrganId())){
+			studentPaymentRouteOrderService.addRouteOrder(orderNo, vipGroup.getOrganId(), vipGroup.getTotalPrice());
 			studentPaymentOrder.setPaymentChannel("BALANCE");
 			studentPaymentOrder.setActualAmount(new BigDecimal(0));
 			studentPaymentOrder.setBalancePaymentAmount(amount);
@@ -1342,6 +1347,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 			}
 			studentPaymentOrder.setPaymentChannel("BALANCE");
 			if(userCashAccount.getBalance().subtract(vipGroup.getTotalPrice()).doubleValue() >= 0){
+				studentPaymentRouteOrderService.addRouteOrder(orderNo, vipGroup.getOrganId(), vipGroup.getTotalPrice());
 				// 更新订单信息
 				studentPaymentOrder.setActualAmount(new BigDecimal(0));
 				studentPaymentOrder.setBalancePaymentAmount(amount);
@@ -1360,7 +1366,8 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 				return result;
 			}else{
 				if (userCashAccount.getBalance().doubleValue() > 0) {
-					sysUserCashAccountService.updateBalance(user.getId(), userCashAccount.getBalance().negate(), PlatformCashAccountDetailTypeEnum.PAY_FEE, "VIP课购买");
+					balance = userCashAccount.getBalance();
+					sysUserCashAccountService.updateBalance(user.getId(), balance.negate(), PlatformCashAccountDetailTypeEnum.PAY_FEE, "VIP课购买");
 					amount = amount.subtract(userCashAccount.getBalance());
 					studentPaymentOrder.setActualAmount(amount);
 					studentPaymentOrder.setBalancePaymentAmount(userCashAccount.getBalance());
@@ -1384,17 +1391,16 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 		classFee.put("instrument",BigDecimal.ZERO);
 		classFee.put("accessories",BigDecimal.ZERO);
 		classFee.put("other",BigDecimal.ZERO);
-		try {
 			Map<String,Object> payMap = payService.getPayMap(
 					amount,
+					balance,
 					orderNo,
 					baseApiUrl+"/api-student/studentOrder/notify",
 					baseApiUrl+"/api-student/studentOrder/paymentResult?orderNo=" + orderNo,
 					"vip课购买",
 					vipGroup.getName(),
-					user.getId(),
-					classFee,
-					vipGroup.getOrganId()
+					vipGroup.getOrganId(),
+					"vipBuy"
 			);
 
 			Map<String,BigDecimal> routingFee = (Map<String,BigDecimal>)payMap.get("routingFee");
@@ -1408,9 +1414,6 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 			studentPaymentOrderService.update(studentPaymentOrder);
 
 			return payMap;
-		} catch (Exception e) {
-			throw new BizException("调用支付接口出错", e);
-		}
 
 	}
 
@@ -2059,7 +2062,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 		if (null == studentPaymentOrder) {
 			throw new BizException("未找到原订单信息!");
 		}
-		
+
 		if(status ==StudentApplyRefundsStatus.ING){
 			throw new BizException("状态不正确");
 		}
@@ -2925,7 +2928,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 		}
 		if(noCreateSuccessVipGroups != null && noCreateSuccessVipGroups.size() > 0){
 			vipGroupDao.batchUpdate(noCreateSuccessVipGroups);
-			
+
 			for (VipGroup noCreateSuccessVipGroup : noCreateSuccessVipGroups) {
 				//推送消息
 				if(noCreateSuccessVipGroup.getStatus().equals(VipGroupStatusEnum.CANCEL)) {