|
@@ -6,12 +6,11 @@ import com.ym.mec.biz.dal.dto.*;
|
|
import com.ym.mec.biz.dal.entity.*;
|
|
import com.ym.mec.biz.dal.entity.*;
|
|
import com.ym.mec.biz.dal.enums.*;
|
|
import com.ym.mec.biz.dal.enums.*;
|
|
import com.ym.mec.biz.dal.page.ChildrenReserveQueryInfo;
|
|
import com.ym.mec.biz.dal.page.ChildrenReserveQueryInfo;
|
|
-import com.ym.mec.biz.service.ChildrenDayDegreeDetailService;
|
|
|
|
-import com.ym.mec.biz.service.ChildrenDayReserveService;
|
|
|
|
-import com.ym.mec.biz.service.StudentPaymentOrderService;
|
|
|
|
|
|
+import com.ym.mec.biz.service.*;
|
|
import com.ym.mec.common.dal.BaseDAO;
|
|
import com.ym.mec.common.dal.BaseDAO;
|
|
import com.ym.mec.common.exception.BizException;
|
|
import com.ym.mec.common.exception.BizException;
|
|
import com.ym.mec.common.page.PageInfo;
|
|
import com.ym.mec.common.page.PageInfo;
|
|
|
|
+import com.ym.mec.common.service.IdGeneratorService;
|
|
import com.ym.mec.common.service.impl.BaseServiceImpl;
|
|
import com.ym.mec.common.service.impl.BaseServiceImpl;
|
|
import com.ym.mec.util.collection.MapUtil;
|
|
import com.ym.mec.util.collection.MapUtil;
|
|
import com.ym.mec.util.date.DateUtil;
|
|
import com.ym.mec.util.date.DateUtil;
|
|
@@ -44,6 +43,12 @@ public class ChildrenDayReserveServiceImpl extends BaseServiceImpl<Integer, Chil
|
|
private StudentPaymentOrderService studentPaymentOrderService;
|
|
private StudentPaymentOrderService studentPaymentOrderService;
|
|
@Autowired
|
|
@Autowired
|
|
private SysConfigDao sysConfigDao;
|
|
private SysConfigDao sysConfigDao;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IdGeneratorService idGeneratorService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private StudentPaymentRouteOrderService studentPaymentRouteOrderService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private PayService payService;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public BaseDAO<Integer, ChildrenDayReserve> getDAO() {
|
|
public BaseDAO<Integer, ChildrenDayReserve> getDAO() {
|
|
@@ -51,7 +56,7 @@ public class ChildrenDayReserveServiceImpl extends BaseServiceImpl<Integer, Chil
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public ChildrenDayReserve addReserve(SysUser user) {
|
|
|
|
|
|
+ public ChildrenDayReserve addReserve(SysUser user, YesOrNoEnum status) {
|
|
Date nowTime = new Date();
|
|
Date nowTime = new Date();
|
|
String startTimeStr = sysConfigDao.findConfigValue("children_day_start_time");
|
|
String startTimeStr = sysConfigDao.findConfigValue("children_day_start_time");
|
|
Date startTime = DateUtil.stringToDate(startTimeStr);
|
|
Date startTime = DateUtil.stringToDate(startTimeStr);
|
|
@@ -68,11 +73,12 @@ public class ChildrenDayReserveServiceImpl extends BaseServiceImpl<Integer, Chil
|
|
if (hasOne != null) {
|
|
if (hasOne != null) {
|
|
throw new BizException("您已预报名");
|
|
throw new BizException("您已预报名");
|
|
}
|
|
}
|
|
|
|
+ studentDao.lockUser(user.getId());
|
|
MusicGroup studentLastMusicGroup = musicGroupDao.getStudentLastMusicGroup(user.getId());
|
|
MusicGroup studentLastMusicGroup = musicGroupDao.getStudentLastMusicGroup(user.getId());
|
|
ChildrenDayReserve childrenDayReserve = new ChildrenDayReserve();
|
|
ChildrenDayReserve childrenDayReserve = new ChildrenDayReserve();
|
|
childrenDayReserve.setUserId(user.getId());
|
|
childrenDayReserve.setUserId(user.getId());
|
|
childrenDayReserve.setOrganId(user.getOrganId());
|
|
childrenDayReserve.setOrganId(user.getOrganId());
|
|
- childrenDayReserve.setIsReserve(YesOrNoEnum.YES);
|
|
|
|
|
|
+ childrenDayReserve.setIsReserve(status);
|
|
if (studentLastMusicGroup != null) {
|
|
if (studentLastMusicGroup != null) {
|
|
childrenDayReserve.setCooperationOrganId(studentLastMusicGroup.getCooperationOrganId());
|
|
childrenDayReserve.setCooperationOrganId(studentLastMusicGroup.getCooperationOrganId());
|
|
childrenDayReserve.setMusicGroupId(studentLastMusicGroup.getId());
|
|
childrenDayReserve.setMusicGroupId(studentLastMusicGroup.getId());
|
|
@@ -170,102 +176,137 @@ public class ChildrenDayReserveServiceImpl extends BaseServiceImpl<Integer, Chil
|
|
throw new BizException("您已购买过VIP 1V2课程,请勿重复选择");
|
|
throw new BizException("您已购买过VIP 1V2课程,请勿重复选择");
|
|
}
|
|
}
|
|
|
|
|
|
- if (degreePayDto.getVip1v2() && detailTypes.contains(5)) {
|
|
|
|
|
|
+ if (degreePayDto.getTheoryCourse() && detailTypes.contains(5)) {
|
|
throw new BizException("您已购买过乐理考级专项训练课,请勿重复选择");
|
|
throw new BizException("您已购买过乐理考级专项训练课,请勿重复选择");
|
|
}
|
|
}
|
|
- //检查考级等级是否重复
|
|
|
|
|
|
+ //检查器乐考级等级是否重复
|
|
if (degreePayDto.getMusicGradeLevel() != null) {
|
|
if (degreePayDto.getMusicGradeLevel() != null) {
|
|
|
|
+ if (degreePayDto.getSubject() == null) {
|
|
|
|
+ throw new BizException("请选择考级声部");
|
|
|
|
+ }
|
|
|
|
+ List<ChildrenDayDegreeDetail> hasList = details.stream().filter(e -> e.getType().equals(1)).filter(e -> e.getSubjectId().equals(degreePayDto.getSubject()))
|
|
|
|
+ .filter(e -> e.getLevel().equals(degreePayDto.getMusicGradeLevel())).collect(Collectors.toList());
|
|
|
|
+ if (hasList.size() > 0) {
|
|
|
|
+ throw new BizException("您已报考同声部同等级,请勿重复报考");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //检查乐理考级等级是否重复
|
|
|
|
+ if (degreePayDto.getTheoryLevel() != null) {
|
|
|
|
+ List<ChildrenDayDegreeDetail> hasList = details.stream().filter(e -> e.getType().equals(2))
|
|
|
|
+ .filter(e -> e.getLevel().equals(degreePayDto.getMusicGradeLevel())).collect(Collectors.toList());
|
|
|
|
+ if (hasList.size() > 0) {
|
|
|
|
+ throw new BizException("您已报考同等级乐理,请勿重复报考");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ ChildrenDayReserve userReserve = this.getUserReserve(degreePayDto.getUserId());
|
|
|
|
+
|
|
|
|
+ if (userReserve == null) {
|
|
|
|
+ this.addReserve(degreePayDto.getUser(), YesOrNoEnum.NO);
|
|
}
|
|
}
|
|
|
|
+
|
|
//获取课程的价格
|
|
//获取课程的价格
|
|
OrganizationDegreeCourseFee courseFee = organizationDegreeCourseFeeDao.getByOrganId(degreePayDto.getOrganId());
|
|
OrganizationDegreeCourseFee courseFee = organizationDegreeCourseFeeDao.getByOrganId(degreePayDto.getOrganId());
|
|
-//
|
|
|
|
-//
|
|
|
|
-// Goods goods = goodsDao.get(replacementInstrumentActivity.getInstrumentsId());
|
|
|
|
-// BigDecimal orderAmount = goods.getGroupPurchasePrice();
|
|
|
|
-// BigDecimal amount = replacementPayDto.getAmount(); //扣除余额之前的金额
|
|
|
|
-// if (amount.compareTo(orderAmount) != 0) {
|
|
|
|
-// throw new BizException("商品价格不符");
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// String channelType = "";
|
|
|
|
-// Date nowDate = new Date();
|
|
|
|
-//
|
|
|
|
-// BigDecimal balance = BigDecimal.ZERO;
|
|
|
|
-// if (replacementPayDto.getUseBalance() && amount.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
|
-// SysUserCashAccount userCashAccount = sysUserCashAccountService.getLocked(userId);
|
|
|
|
-// if (userCashAccount == null) {
|
|
|
|
-// throw new BizException("用户账户找不到");
|
|
|
|
-// }
|
|
|
|
-// if (userCashAccount.getBalance() != null && userCashAccount.getBalance().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
|
-// balance = amount.compareTo(userCashAccount.getBalance()) >= 0 ? userCashAccount.getBalance() : amount;
|
|
|
|
-// amount = amount.subtract(balance);
|
|
|
|
-// sysUserCashAccountService.updateBalance(userId, balance.negate(), PlatformCashAccountDetailTypeEnum.PAY_FEE, "乐保购买");
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// CooperationOrgan cooperationOrgan = cooperationOrganDao.get(replacementInstrumentActivity.getCooperationOrganId());
|
|
|
|
-//
|
|
|
|
-// String orderNo = idGeneratorService.generatorId("payment") + "";
|
|
|
|
-// StudentPaymentOrder studentPaymentOrder = new StudentPaymentOrder();
|
|
|
|
-//
|
|
|
|
-// studentPaymentOrder.setPaymentChannel("BALANCE");
|
|
|
|
-// studentPaymentOrder.setUserId(userId);
|
|
|
|
-// studentPaymentOrder.setGroupType(GroupType.REPLACEMENT);
|
|
|
|
-// studentPaymentOrder.setOrderNo(orderNo);
|
|
|
|
-// studentPaymentOrder.setType(OrderTypeEnum.REPLACEMENT);
|
|
|
|
-// studentPaymentOrder.setExpectAmount(orderAmount);
|
|
|
|
-// studentPaymentOrder.setActualAmount(amount);
|
|
|
|
-// studentPaymentOrder.setBalancePaymentAmount(balance);
|
|
|
|
-// studentPaymentOrder.setStatus(DealStatusEnum.ING);
|
|
|
|
-// studentPaymentOrder.setMusicGroupId(replacementInstrumentActivity.getId().toString());
|
|
|
|
-// studentPaymentOrder.setRemitFee(BigDecimal.ZERO);
|
|
|
|
-// studentPaymentOrder.setCourseRemitFee(BigDecimal.ZERO);
|
|
|
|
-// studentPaymentOrder.setOrganId(cooperationOrgan.getOrganId());
|
|
|
|
-// studentPaymentOrder.setRoutingOrganId(cooperationOrgan.getOrganId());
|
|
|
|
-// studentPaymentOrder.setCreateTime(nowDate);
|
|
|
|
-// studentPaymentOrder.setUpdateTime(nowDate);
|
|
|
|
-// studentPaymentOrderService.insert(studentPaymentOrder);
|
|
|
|
-// //修改支付状态
|
|
|
|
-// replacementInstrumentActivity.setPayStatus(1);
|
|
|
|
-// replacementInstrumentActivity.setUpdateTime(nowDate);
|
|
|
|
-// replacementInstrumentActivityDao.update(replacementInstrumentActivity);
|
|
|
|
-//
|
|
|
|
-// studentPaymentOrder.setVersion(0);
|
|
|
|
-// if (amount.compareTo(BigDecimal.ZERO) == 0) {
|
|
|
|
-// studentPaymentRouteOrderService.addRouteOrder(orderNo, cooperationOrgan.getOrganId(), balance);
|
|
|
|
-// Map<String, String> notifyMap = new HashMap<>();
|
|
|
|
-// notifyMap.put("tradeState", "1");
|
|
|
|
-// notifyMap.put("merOrderNo", studentPaymentOrder.getOrderNo());
|
|
|
|
-// notifyMap.put("channelType", channelType);
|
|
|
|
-// notifyMap.put("orderNo", "");
|
|
|
|
-// studentPaymentOrderService.updateOrder(notifyMap);
|
|
|
|
-// return notifyMap;
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// String orderSubject = "乐器置换";
|
|
|
|
-// String receiver = "replacement";
|
|
|
|
-//
|
|
|
|
-// String baseApiUrl = sysConfigDao.findConfigValue("base_api_url");
|
|
|
|
-//
|
|
|
|
-// Map payMap = payService.getPayMap(
|
|
|
|
-// amount,
|
|
|
|
-// balance,
|
|
|
|
-// orderNo,
|
|
|
|
-// baseApiUrl + "/api-student/studentOrder/notify",
|
|
|
|
-// baseApiUrl + "/api-student/studentOrder/paymentResult?orderNo=" + orderNo,
|
|
|
|
-// orderSubject,
|
|
|
|
-// orderSubject,
|
|
|
|
-// cooperationOrgan.getOrganId(),
|
|
|
|
-// receiver
|
|
|
|
-// );
|
|
|
|
-//
|
|
|
|
-// studentPaymentOrder.setOrganId(cooperationOrgan.getOrganId());
|
|
|
|
-// studentPaymentOrder.setMerNos((String) payMap.get("routingMerNos"));
|
|
|
|
-// studentPaymentOrder.setPaymentChannel((String) payMap.get("type"));
|
|
|
|
-// studentPaymentOrder.setUpdateTime(nowDate);
|
|
|
|
-// studentPaymentOrderService.update(studentPaymentOrder);
|
|
|
|
- Map<Object, Object> payMap = new HashMap<>();
|
|
|
|
|
|
+ List<DegreeLevelFee> degreeLevelFees = degreeLevelFeeDao.getAll();
|
|
|
|
+
|
|
|
|
+ //订单总金额
|
|
|
|
+ BigDecimal orderAmount = BigDecimal.ZERO;
|
|
|
|
+
|
|
|
|
+ //器乐考级费用
|
|
|
|
+ if (degreePayDto.getMusicGradeLevel() != null) {
|
|
|
|
+ BigDecimal gradeFee = degreeLevelFees.stream().filter(e -> e.getLevel().equals(degreePayDto.getMusicGradeLevel())).map(DegreeLevelFee::getGrade).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
+ orderAmount = orderAmount.add(gradeFee);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //乐理考级费用
|
|
|
|
+ if (degreePayDto.getTheoryLevel() != null) {
|
|
|
|
+ BigDecimal theoryLevelFee = degreeLevelFees.stream().filter(e -> e.getLevel().equals(degreePayDto.getTheoryLevel())).map(DegreeLevelFee::getTheory).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
+ orderAmount = orderAmount.add(theoryLevelFee);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //VIP 1v1 1v2费用
|
|
|
|
+ if (degreePayDto.getVip1v1()) {
|
|
|
|
+ BigDecimal vip1v1Fee = courseFee.getVip1v1();
|
|
|
|
+ orderAmount = orderAmount.add(vip1v1Fee);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //VIP 1v2费用
|
|
|
|
+ if (degreePayDto.getVip1v2()) {
|
|
|
|
+ BigDecimal vip1v2Fee = courseFee.getVip1v2();
|
|
|
|
+ orderAmount = orderAmount.add(vip1v2Fee);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //VIP 乐理课费用
|
|
|
|
+ if (degreePayDto.getTheoryCourse()) {
|
|
|
|
+ BigDecimal theoryFee = courseFee.getTheory();
|
|
|
|
+ orderAmount = orderAmount.add(theoryFee);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (orderAmount.compareTo(degreePayDto.getAmount()) != 0) {
|
|
|
|
+ throw new BizException("价格不符,请核查");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ String channelType = "";
|
|
|
|
+ Date nowDate = new Date();
|
|
|
|
+
|
|
|
|
+ BigDecimal balance = BigDecimal.ZERO;
|
|
|
|
+
|
|
|
|
+ String orderNo = idGeneratorService.generatorId("payment") + "";
|
|
|
|
+ StudentPaymentOrder studentPaymentOrder = new StudentPaymentOrder();
|
|
|
|
+
|
|
|
|
+ studentPaymentOrder.setPaymentChannel("BALANCE");
|
|
|
|
+ studentPaymentOrder.setUserId(degreePayDto.getUserId());
|
|
|
|
+ studentPaymentOrder.setGroupType(GroupType.DEGREE);
|
|
|
|
+ studentPaymentOrder.setOrderNo(orderNo);
|
|
|
|
+ studentPaymentOrder.setType(OrderTypeEnum.DEGREE);
|
|
|
|
+ studentPaymentOrder.setExpectAmount(orderAmount);
|
|
|
|
+ studentPaymentOrder.setActualAmount(orderAmount);
|
|
|
|
+ studentPaymentOrder.setBalancePaymentAmount(balance);
|
|
|
|
+ studentPaymentOrder.setStatus(DealStatusEnum.ING);
|
|
|
|
+ studentPaymentOrder.setRemitFee(BigDecimal.ZERO);
|
|
|
|
+ studentPaymentOrder.setCourseRemitFee(BigDecimal.ZERO);
|
|
|
|
+ studentPaymentOrder.setOrganId(degreePayDto.getOrganId());
|
|
|
|
+ studentPaymentOrder.setRoutingOrganId(degreePayDto.getOrganId());
|
|
|
|
+ studentPaymentOrder.setCreateTime(nowDate);
|
|
|
|
+ studentPaymentOrder.setUpdateTime(nowDate);
|
|
|
|
+ studentPaymentOrderService.insert(studentPaymentOrder);
|
|
|
|
+
|
|
|
|
+ studentPaymentOrder.setVersion(0);
|
|
|
|
+ if (orderAmount.compareTo(BigDecimal.ZERO) == 0) {
|
|
|
|
+ studentPaymentRouteOrderService.addRouteOrder(orderNo, degreePayDto.getOrganId(), balance);
|
|
|
|
+ Map<String, String> notifyMap = new HashMap<>();
|
|
|
|
+ notifyMap.put("tradeState", "1");
|
|
|
|
+ notifyMap.put("merOrderNo", studentPaymentOrder.getOrderNo());
|
|
|
|
+ notifyMap.put("channelType", channelType);
|
|
|
|
+ notifyMap.put("orderNo", "");
|
|
|
|
+ studentPaymentOrderService.updateOrder(notifyMap);
|
|
|
|
+ return notifyMap;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String orderSubject = "6.1考级活动";
|
|
|
|
+ String receiver = "degree";
|
|
|
|
+
|
|
|
|
+ String baseApiUrl = sysConfigDao.findConfigValue("base_api_url");
|
|
|
|
+
|
|
|
|
+ Map payMap = payService.getPayMap(
|
|
|
|
+ orderAmount,
|
|
|
|
+ balance,
|
|
|
|
+ orderNo,
|
|
|
|
+ baseApiUrl + "/api-student/studentOrder/notify",
|
|
|
|
+ baseApiUrl + "/api-student/studentOrder/paymentResult?orderNo=" + orderNo,
|
|
|
|
+ orderSubject,
|
|
|
|
+ orderSubject,
|
|
|
|
+ degreePayDto.getOrganId(),
|
|
|
|
+ receiver
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ studentPaymentOrder.setOrganId(degreePayDto.getOrganId());
|
|
|
|
+ studentPaymentOrder.setMerNos((String) payMap.get("routingMerNos"));
|
|
|
|
+ studentPaymentOrder.setPaymentChannel((String) payMap.get("type"));
|
|
|
|
+ studentPaymentOrder.setUpdateTime(nowDate);
|
|
|
|
+ studentPaymentOrderService.update(studentPaymentOrder);
|
|
return payMap;
|
|
return payMap;
|
|
}
|
|
}
|
|
}
|
|
}
|