|
@@ -141,8 +141,10 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
|
|
|
//计算课程相关费用信息
|
|
|
Map<String, BigDecimal> costInfo = countVipGroupPredictFee(vipGroupApplyBaseInfoDto,
|
|
|
+ vipGroupApplyBaseInfoDto.getUserId(),
|
|
|
vipGroupApplyBaseInfoDto.getOnlineClassesUnitPrice(),
|
|
|
- vipGroupApplyBaseInfoDto.getOfflineClassesUnitPrice());
|
|
|
+ vipGroupApplyBaseInfoDto.getOfflineClassesUnitPrice(),
|
|
|
+ true);
|
|
|
|
|
|
//如果默认课酬与实际课酬不匹配则需要审批
|
|
|
if(costInfo.get("offlineTeacherSalary").compareTo(vipGroupApplyBaseInfoDto.getOfflineTeacherSalary())!=0||
|
|
@@ -441,14 +443,13 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
return new VipGroupCostCountDto(null,teacherSalary);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * @Author: Joburgess
|
|
|
- * @Date: 2019/10/2
|
|
|
- * 计算VIP课程预计收费
|
|
|
- */
|
|
|
@Override
|
|
|
- public Map<String,BigDecimal> countVipGroupPredictFee(VipGroup vipGroup,BigDecimal onlineClassesUnitPrice,BigDecimal offlineClassesUnitPrice){
|
|
|
- if(Objects.isNull(vipGroup.getUserId())){
|
|
|
+ public Map<String,BigDecimal> countVipGroupPredictFee(VipGroup vipGroup,
|
|
|
+ Integer teacherId,
|
|
|
+ BigDecimal onlineClassesUnitPrice,
|
|
|
+ BigDecimal offlineClassesUnitPrice,
|
|
|
+ boolean computeTotalPrice){
|
|
|
+ if(Objects.isNull(teacherId)){
|
|
|
throw new BizException("请指定教师");
|
|
|
}
|
|
|
|
|
@@ -461,9 +462,13 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
throw new BizException("未找到课程形式");
|
|
|
}
|
|
|
|
|
|
- TeacherDefaultVipGroupSalary teacherDefaultVipGroupSalary = teacherDefaultVipGroupSalaryDao.findByTeacherAndCategory(vipGroup.getUserId().longValue(),
|
|
|
+ TeacherDefaultVipGroupSalary teacherDefaultVipGroupSalary = teacherDefaultVipGroupSalaryDao.findByTeacherAndCategory(teacherId.longValue(),
|
|
|
vipGroup.getVipGroupCategoryId());
|
|
|
|
|
|
+ if(Objects.isNull(vipGroup.getVipGroupActivityId())){
|
|
|
+ throw new BizException("请指定活动方案");
|
|
|
+ }
|
|
|
+
|
|
|
VipGroupActivity vipGroupActivity = vipGroupActivityDao.get(vipGroup.getVipGroupActivityId().intValue());
|
|
|
|
|
|
if(Objects.isNull(vipGroupActivity)){
|
|
@@ -486,82 +491,75 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
BigDecimal onlineVipGroupCharge = onlineClassesUnitPrice.multiply(onlineClassNum);
|
|
|
BigDecimal offlineVipGroupCharge = offlineClassesUnitPrice.multiply(offlineClassNum);
|
|
|
|
|
|
- if(vipGroup.getOnlineClassesNum()>0){
|
|
|
- //教师课酬线上单课酬计算
|
|
|
- switch (vipGroupSalarySettlementDto.getOnlineSalarySettlement().getSalarySettlementType()){
|
|
|
- case TEACHER_DEFAULT:
|
|
|
- if(Objects.isNull(teacherDefaultVipGroupSalary)){
|
|
|
- throw new BizException("未设置教师默认课酬");
|
|
|
- }
|
|
|
- results.put("onlineTeacherSalary",teacherDefaultVipGroupSalary.getOfflineClassesSalary().multiply(classTimeDuty));
|
|
|
- break;
|
|
|
- case RATIO_DISCOUNT:
|
|
|
- results.put("onlineTeacherSalary",onlineClassesUnitPrice.multiply((vipGroupSalarySettlementDto.getOnlineSalarySettlement().getSettlementValue())));
|
|
|
- break;
|
|
|
- case FIXED_SALARY:
|
|
|
- results.put("onlineTeacherSalary",vipGroupSalarySettlementDto.getOnlineSalarySettlement().getSettlementValue());
|
|
|
- break;
|
|
|
- default:
|
|
|
- throw new BizException("未指定课酬结算标准!");
|
|
|
- }
|
|
|
- }else{
|
|
|
- results.put("onlineTeacherSalary",new BigDecimal(0));
|
|
|
+ //教师课酬线上单课酬计算
|
|
|
+ switch (vipGroupSalarySettlementDto.getOnlineSalarySettlement().getSalarySettlementType()){
|
|
|
+ case TEACHER_DEFAULT:
|
|
|
+ if(Objects.isNull(teacherDefaultVipGroupSalary)){
|
|
|
+ throw new BizException("未设置教师默认课酬");
|
|
|
+ }
|
|
|
+ results.put("onlineTeacherSalary",teacherDefaultVipGroupSalary.getOfflineClassesSalary().multiply(classTimeDuty));
|
|
|
+ break;
|
|
|
+ case RATIO_DISCOUNT:
|
|
|
+ results.put("onlineTeacherSalary",onlineClassesUnitPrice.multiply((vipGroupSalarySettlementDto.getOnlineSalarySettlement().getSettlementValue())));
|
|
|
+ break;
|
|
|
+ case FIXED_SALARY:
|
|
|
+ results.put("onlineTeacherSalary",vipGroupSalarySettlementDto.getOnlineSalarySettlement().getSettlementValue());
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ throw new BizException("未指定课酬结算标准!");
|
|
|
}
|
|
|
|
|
|
- if(vipGroup.getOfflineClassesNum()>0){
|
|
|
- //教师线下单课酬计算
|
|
|
- switch (vipGroupSalarySettlementDto.getOfflineSalarySettlement().getSalarySettlementType()){
|
|
|
- case TEACHER_DEFAULT:
|
|
|
- if(Objects.isNull(teacherDefaultVipGroupSalary)){
|
|
|
- throw new BizException("未设置教师默认课酬");
|
|
|
- }
|
|
|
- results.put("offlineTeacherSalary",teacherDefaultVipGroupSalary.getOfflineClassesSalary().multiply(classTimeDuty));
|
|
|
+ //教师线下单课酬计算
|
|
|
+ switch (vipGroupSalarySettlementDto.getOfflineSalarySettlement().getSalarySettlementType()){
|
|
|
+ case TEACHER_DEFAULT:
|
|
|
+ if(Objects.isNull(teacherDefaultVipGroupSalary)){
|
|
|
+ throw new BizException("未设置教师默认课酬");
|
|
|
+ }
|
|
|
+ results.put("offlineTeacherSalary",teacherDefaultVipGroupSalary.getOfflineClassesSalary().multiply(classTimeDuty));
|
|
|
+ break;
|
|
|
+ case RATIO_DISCOUNT:
|
|
|
+ results.put("offlineTeacherSalary",offlineClassesUnitPrice.multiply(vipGroupSalarySettlementDto.getOfflineSalarySettlement().getSettlementValue()));
|
|
|
+ break;
|
|
|
+ case FIXED_SALARY:
|
|
|
+ results.put("offlineTeacherSalary",vipGroupSalarySettlementDto.getOfflineSalarySettlement().getSettlementValue());
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ throw new BizException("未指定课酬结算标准!");
|
|
|
+ }
|
|
|
+
|
|
|
+ if(computeTotalPrice){
|
|
|
+ //课程购买费用计算
|
|
|
+ BigDecimal totalPrice;
|
|
|
+ switch (vipGroupActivity.getType()){
|
|
|
+ case BASE_ACTIVITY:
|
|
|
+ totalPrice=onlineVipGroupCharge.add(offlineVipGroupCharge);
|
|
|
break;
|
|
|
- case RATIO_DISCOUNT:
|
|
|
- results.put("offlineTeacherSalary",offlineClassesUnitPrice.multiply(vipGroupSalarySettlementDto.getOfflineSalarySettlement().getSettlementValue()));
|
|
|
+ case DISCOUNT:
|
|
|
+ BigDecimal discount=new BigDecimal(vipGroupActivity.getAttribute1());
|
|
|
+ totalPrice=onlineVipGroupCharge.add(offlineVipGroupCharge);
|
|
|
+ totalPrice=totalPrice.multiply(discount);
|
|
|
break;
|
|
|
- case FIXED_SALARY:
|
|
|
- results.put("offlineTeacherSalary",vipGroupSalarySettlementDto.getOfflineSalarySettlement().getSettlementValue());
|
|
|
+ case GIVE_CLASS:
|
|
|
+ if(vipGroup.getGiveTeachMode()==TeachModeEnum.OFFLINE){
|
|
|
+ if(offlineClassNum.compareTo(new BigDecimal(vipGroupActivity.getAttribute1()))>-1){
|
|
|
+ offlineClassNum=offlineClassNum.subtract(new BigDecimal(vipGroupActivity.getAttribute2()));
|
|
|
+ }
|
|
|
+ offlineVipGroupCharge = offlineClassesUnitPrice.multiply(offlineClassNum);
|
|
|
+ }else if(vipGroup.getGiveTeachMode()==TeachModeEnum.ONLINE){
|
|
|
+ if(onlineClassNum.compareTo(new BigDecimal(vipGroupActivity.getAttribute1()))>-1){
|
|
|
+ onlineClassNum=onlineClassNum.subtract(new BigDecimal(vipGroupActivity.getAttribute2()));
|
|
|
+ }
|
|
|
+ onlineVipGroupCharge = onlineClassesUnitPrice.multiply(onlineClassNum);
|
|
|
+ }else{
|
|
|
+ throw new BizException("请指定赠送课程类型!");
|
|
|
+ }
|
|
|
+ totalPrice=onlineVipGroupCharge.add(offlineVipGroupCharge);
|
|
|
break;
|
|
|
default:
|
|
|
- throw new BizException("未指定课酬结算标准!");
|
|
|
+ throw new BizException("活动类型错误!");
|
|
|
}
|
|
|
- }else{
|
|
|
- results.put("offlineTeacherSalary",new BigDecimal(0));
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- //课程购买费用计算
|
|
|
- BigDecimal totalPrice;
|
|
|
- switch (vipGroupActivity.getType()){
|
|
|
- case BASE_ACTIVITY:
|
|
|
- totalPrice=onlineVipGroupCharge.add(offlineVipGroupCharge);
|
|
|
- break;
|
|
|
- case DISCOUNT:
|
|
|
- BigDecimal discount=new BigDecimal(vipGroupActivity.getAttribute1());
|
|
|
- totalPrice=onlineVipGroupCharge.add(offlineVipGroupCharge);
|
|
|
- totalPrice=totalPrice.multiply(discount);
|
|
|
- break;
|
|
|
- case GIVE_CLASS:
|
|
|
- if(vipGroup.getGiveTeachMode()==TeachModeEnum.OFFLINE){
|
|
|
- if(offlineClassNum.compareTo(new BigDecimal(vipGroupActivity.getAttribute1()))>-1){
|
|
|
- offlineClassNum=offlineClassNum.subtract(new BigDecimal(vipGroupActivity.getAttribute2()));
|
|
|
- }
|
|
|
- offlineVipGroupCharge = offlineClassesUnitPrice.multiply(offlineClassNum);
|
|
|
- }else if(vipGroup.getGiveTeachMode()==TeachModeEnum.ONLINE){
|
|
|
- if(onlineClassNum.compareTo(new BigDecimal(vipGroupActivity.getAttribute1()))>-1){
|
|
|
- onlineClassNum=onlineClassNum.subtract(new BigDecimal(vipGroupActivity.getAttribute2()));
|
|
|
- }
|
|
|
- onlineVipGroupCharge = onlineClassesUnitPrice.multiply(onlineClassNum);
|
|
|
- }else{
|
|
|
- throw new BizException("请指定赠送课程类型!");
|
|
|
- }
|
|
|
- totalPrice=onlineVipGroupCharge.add(offlineVipGroupCharge);
|
|
|
- break;
|
|
|
- default:
|
|
|
- throw new BizException("活动类型错误!");
|
|
|
+ results.put("totalPrice",totalPrice);
|
|
|
}
|
|
|
- results.put("totalPrice",totalPrice);
|
|
|
return results;
|
|
|
}
|
|
|
|
|
@@ -632,8 +630,8 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
Map payMap = payService.getPayMap(
|
|
|
vipGroup.getTotalPrice(),
|
|
|
orderNo,
|
|
|
- "http://47.99.212.176:8000/api-student/studentOrder/notify",
|
|
|
- "http://dev.dayaedu.com",
|
|
|
+ "http://103.46.128.45:11805/api-student/studentOrder/notify",
|
|
|
+ "http://103.46.128.45:41818/paymentresult",
|
|
|
"vip课购买",
|
|
|
vipGroup.getName());
|
|
|
|
|
@@ -651,6 +649,8 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
Integer userId = order.getUserId();
|
|
|
boolean isOk=order.getStatus().equals(DealStatusEnum.SUCCESS);
|
|
|
|
|
|
+ studentPaymentOrderDao.update(order);
|
|
|
+
|
|
|
//将学生加入到班级,更新班级报名状态及人数信息
|
|
|
if(!isOk){
|
|
|
updateVipGroupStudentNumAndStatus(vipGroupId,-1);
|
|
@@ -693,8 +693,9 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
//剩余课时数
|
|
|
Map surplusClassTimes=MapUtil.convertMybatisMap(vipGroupDao.countSurplusClassTimes(vipGroupId));
|
|
|
studentApplyRefunds.setExpectAmount(countVipGroupPredictFee(vipGroup,
|
|
|
+ vipGroup.getUserId(),
|
|
|
new BigDecimal(surplusClassTimes.get(TeachModeEnum.ONLINE.getCode()).toString()),
|
|
|
- new BigDecimal(surplusClassTimes.get(TeachModeEnum.OFFLINE.getCode()).toString())).get("totalPrice"));
|
|
|
+ new BigDecimal(surplusClassTimes.get(TeachModeEnum.OFFLINE.getCode()).toString()),true).get("totalPrice"));
|
|
|
studentApplyRefunds.setStatus(AuditStatusEnum.ING);
|
|
|
String orderNo=StringUtils.join(new String[]{studentId.toString(),String.valueOf(System.currentTimeMillis())});
|
|
|
studentApplyRefunds.setOrderNo(orderNo);
|
|
@@ -705,7 +706,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
|
- public void applyRefundAudit(Long id, AuditStatusEnum status, String remark) {
|
|
|
+ public void applyRefundAudit(Long id, AuditStatusEnum status, String remark,BigDecimal amount) {
|
|
|
|
|
|
StudentApplyRefunds studentApplyRefunds = studentApplyRefundsDao.get(id);
|
|
|
if (studentApplyRefunds == null) {
|
|
@@ -719,7 +720,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
|
|
|
studentApplyRefunds.setStatus(status);
|
|
|
if (studentApplyRefunds.getStatus() == AuditStatusEnum.PASS) {
|
|
|
- studentApplyRefunds.setActualAmount(studentApplyRefunds.getExpectAmount());
|
|
|
+ studentApplyRefunds.setActualAmount(amount);
|
|
|
} else {
|
|
|
studentApplyRefunds.setActualAmount(new BigDecimal(0));
|
|
|
}
|
|
@@ -733,7 +734,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
sysUserCashAccountDetail.setUserId(studentApplyRefunds.getUserId());
|
|
|
sysUserCashAccountDetail.setType(PlatformCashAccountDetailTypeEnum.REFUNDS);
|
|
|
sysUserCashAccountDetail.setStatus(DealStatusEnum.SUCCESS);
|
|
|
- sysUserCashAccountDetail.setAmount(studentApplyRefunds.getActualAmount());
|
|
|
+ sysUserCashAccountDetail.setAmount(amount);
|
|
|
sysUserCashAccountDetail.setBalance(sysUserCashAccount.getBalance());
|
|
|
sysUserCashAccountDetail.setAttribute(studentApplyRefunds.getId().toString());
|
|
|
sysUserCashAccountDetailDao.insert(sysUserCashAccountDetail);
|