|
@@ -1,60 +1,35 @@
|
|
|
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.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.Objects;
|
|
|
-
|
|
|
-import org.apache.commons.lang3.StringUtils;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.http.HttpStatus;
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
-import org.springframework.transaction.annotation.Isolation;
|
|
|
-import org.springframework.transaction.annotation.Transactional;
|
|
|
-import org.springframework.util.CollectionUtils;
|
|
|
-
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
-import com.ym.mec.biz.dal.dao.DegreeRegistrationDao;
|
|
|
-import com.ym.mec.biz.dal.dao.PracticeGroupSellPriceDao;
|
|
|
-import com.ym.mec.biz.dal.dao.SporadicChargeInfoDao;
|
|
|
-import com.ym.mec.biz.dal.dao.StudentDao;
|
|
|
-import com.ym.mec.biz.dal.dao.StudentPaymentOrderDetailDao;
|
|
|
-import com.ym.mec.biz.dal.dao.SysConfigDao;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.ym.mec.biz.dal.dao.*;
|
|
|
import com.ym.mec.biz.dal.dto.DegreeRegistrationActivityDto;
|
|
|
+import com.ym.mec.biz.dal.dto.DegreeRegistrationDto;
|
|
|
import com.ym.mec.biz.dal.dto.PageInfoDegree;
|
|
|
-import com.ym.mec.biz.dal.entity.CourseSchedule;
|
|
|
-import com.ym.mec.biz.dal.entity.DegreeRegistration;
|
|
|
-import com.ym.mec.biz.dal.entity.PracticeGroupSellPrice;
|
|
|
-import com.ym.mec.biz.dal.entity.SporadicChargeInfo;
|
|
|
-import com.ym.mec.biz.dal.entity.Student;
|
|
|
-import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
|
|
|
-import com.ym.mec.biz.dal.entity.StudentPaymentOrderDetail;
|
|
|
-import com.ym.mec.biz.dal.entity.SysUserCashAccount;
|
|
|
-import com.ym.mec.biz.dal.enums.DealStatusEnum;
|
|
|
-import com.ym.mec.biz.dal.enums.GroupType;
|
|
|
-import com.ym.mec.biz.dal.enums.OrderDetailTypeEnum;
|
|
|
-import com.ym.mec.biz.dal.enums.OrderTypeEnum;
|
|
|
-import com.ym.mec.biz.dal.enums.PlatformCashAccountDetailTypeEnum;
|
|
|
+import com.ym.mec.biz.dal.entity.*;
|
|
|
+import com.ym.mec.biz.dal.enums.*;
|
|
|
import com.ym.mec.biz.dal.page.DegreeQueryInfo;
|
|
|
-import com.ym.mec.biz.service.DegreeRegistrationService;
|
|
|
-import com.ym.mec.biz.service.PayService;
|
|
|
-import com.ym.mec.biz.service.StudentPaymentOrderService;
|
|
|
-import com.ym.mec.biz.service.SysConfigService;
|
|
|
-import com.ym.mec.biz.service.SysTenantConfigService;
|
|
|
-import com.ym.mec.biz.service.SysUserCashAccountService;
|
|
|
-import com.ym.mec.common.constant.CommonConstants;
|
|
|
+import com.ym.mec.biz.service.*;
|
|
|
import com.ym.mec.common.controller.BaseController;
|
|
|
import com.ym.mec.common.dal.BaseDAO;
|
|
|
import com.ym.mec.common.entity.HttpResponseResult;
|
|
|
import com.ym.mec.common.exception.BizException;
|
|
|
import com.ym.mec.common.service.IdGeneratorService;
|
|
|
import com.ym.mec.common.service.impl.BaseServiceImpl;
|
|
|
-import com.ym.mec.common.tenant.TenantContextHolder;
|
|
|
import com.ym.mec.util.collection.MapUtil;
|
|
|
import com.ym.mec.util.date.DateUtil;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.http.HttpStatus;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Isolation;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
+
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
|
public class DegreeRegistrationServiceImpl extends BaseServiceImpl<Integer, DegreeRegistration> implements DegreeRegistrationService {
|
|
@@ -70,14 +45,8 @@ public class DegreeRegistrationServiceImpl extends BaseServiceImpl<Integer, Degr
|
|
|
@Autowired
|
|
|
private SysConfigDao sysConfigDao;
|
|
|
@Autowired
|
|
|
- private SysTenantConfigService sysTenantConfigService;
|
|
|
- @Autowired
|
|
|
private PayService payService;
|
|
|
@Autowired
|
|
|
- private PracticeGroupSellPriceDao practiceGroupSellPriceDao;
|
|
|
- @Autowired
|
|
|
- private StudentDao studentDao;
|
|
|
- @Autowired
|
|
|
private StudentPaymentOrderDetailDao studentPaymentOrderDetailDao;
|
|
|
@Autowired
|
|
|
private SysUserCashAccountService sysUserCashAccountService;
|
|
@@ -86,225 +55,68 @@ public class DegreeRegistrationServiceImpl extends BaseServiceImpl<Integer, Degr
|
|
|
public BaseDAO<Integer, DegreeRegistration> getDAO() {
|
|
|
return degreeRegistrationDao;
|
|
|
}
|
|
|
+
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
|
|
|
public HttpResponseResult pay(DegreeRegistrationActivityDto degreeRegistration) throws Exception {
|
|
|
- Student student = studentDao.getLocked(degreeRegistration.getUserId());
|
|
|
-
|
|
|
- List<DegreeRegistration> userLevelDegrees = degreeRegistrationDao.getUserLevelDegrees(degreeRegistration.getUserId(), ACTIVITY_TAG,degreeRegistration.getDegreeType(),degreeRegistration.getSporadicId());
|
|
|
- long endLevelNum = userLevelDegrees.stream().filter(d -> Objects.nonNull(d.getSporadicId())&&d.getStatus().equals(2)).count();
|
|
|
- long ingLevelNum = userLevelDegrees.stream().filter(d -> Objects.nonNull(d.getSporadicId())&&d.getStatus().equals(1)).count();
|
|
|
- long endTheoryLevelNum = userLevelDegrees.stream().filter(d -> StringUtils.isNotBlank(d.getTheoryLevel())&&d.getStatus().equals(2)).count();
|
|
|
- long ingTheoryLevelNum = userLevelDegrees.stream().filter(d -> StringUtils.isNotBlank(d.getTheoryLevel())&&d.getStatus().equals(1)).count();
|
|
|
-
|
|
|
- if(Objects.nonNull(degreeRegistration.getSporadicId())&&endLevelNum>0){
|
|
|
- throw new BizException("您已报考过选择的考级项目");
|
|
|
- }
|
|
|
- if(StringUtils.isNotBlank(degreeRegistration.getTheoryLevel())&&endTheoryLevelNum>0){
|
|
|
- throw new BizException("您已报考过选择的考级项目");
|
|
|
+ //判断用户是否已存在订单
|
|
|
+ List<StudentPaymentOrder> paymentOrders = studentPaymentOrderService.getUserOrderByType(degreeRegistration.getUserId(), OrderTypeEnum.DEGREE_REGISTRATION, DealStatusEnum.ING);
|
|
|
+ if (org.apache.commons.collections.CollectionUtils.isNotEmpty(paymentOrders)) {
|
|
|
+ HttpResponseResult result = studentPaymentOrderService.checkRepeatPay(paymentOrders.get(0), degreeRegistration.getIsRepay());
|
|
|
+ if (result.getCode() != 200) {
|
|
|
+ return result;
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
degreeRegistration.setActivityTag(ACTIVITY_TAG);
|
|
|
-
|
|
|
- Integer tenantId = TenantContextHolder.getTenantId();
|
|
|
-
|
|
|
Date nowDate = new Date();
|
|
|
- String startTimeStr = sysTenantConfigService.getTenantConfigValue(SysConfigService.DEGREE_ACTIVITY_START_TIME,tenantId);
|
|
|
- if(StringUtils.isEmpty(startTimeStr)){
|
|
|
- throw new BizException("活动还未开始,谢谢关注");
|
|
|
- }
|
|
|
- Date startTime = DateUtil.stringToDate(startTimeStr);
|
|
|
- if (startTime.compareTo(nowDate) > 0) {
|
|
|
- throw new BizException("活动还未开始,谢谢关注");
|
|
|
- }
|
|
|
- String endTimeStr = sysTenantConfigService.getTenantConfigValue(SysConfigService.DEGREE_ACTIVITY_END_TIME,tenantId);
|
|
|
- if(StringUtils.isEmpty(endTimeStr)){
|
|
|
- throw new BizException("活动还未开始,谢谢关注");
|
|
|
- }
|
|
|
- Date endTime = DateUtil.stringToDate(endTimeStr);
|
|
|
- if (endTime.compareTo(nowDate) <= 0) {
|
|
|
- throw new BizException("活动已结束,谢谢关注");
|
|
|
- }
|
|
|
-
|
|
|
String orderNo = idGeneratorService.generatorId("payment") + "";
|
|
|
-
|
|
|
+ degreeRegistration.setOrderNo(orderNo);
|
|
|
//获取收费项价格
|
|
|
- SporadicChargeInfo chargeInfo = null;
|
|
|
- if(Objects.nonNull(degreeRegistration.getSporadicId())){
|
|
|
- chargeInfo = sporadicChargeInfoDao.get(degreeRegistration.getSporadicId());
|
|
|
- if (chargeInfo == null || chargeInfo.getDelFlag().equals(1) || chargeInfo.getOpenFlag().equals(1)) {
|
|
|
- throw new BizException("你选的考试级别不存在");
|
|
|
- }
|
|
|
-
|
|
|
- if (!chargeInfo.getTitle().equals("一级") && !chargeInfo.getTitle().equals("二级") && StringUtils.equals("免考", degreeRegistration.getTheoryLevel())
|
|
|
- && StringUtils.isBlank(degreeRegistration.getTheoryCert())) {
|
|
|
- throw new BizException("报考级别为“" + chargeInfo.getTitle() + "”且乐理级别是“免考”时,必须上传证书");
|
|
|
- }
|
|
|
- degreeRegistration.setLevel(chargeInfo.getTitle());
|
|
|
- degreeRegistration.setMoney(chargeInfo.getAmount());
|
|
|
- }else{
|
|
|
- degreeRegistration.setMoney(BigDecimal.ZERO);
|
|
|
- }
|
|
|
-
|
|
|
- List<String> courseInfos = new ArrayList<>();
|
|
|
-
|
|
|
- if("免考".equals(degreeRegistration.getTheoryLevel())){
|
|
|
- degreeRegistration.setTheoryLevel(null);
|
|
|
- }
|
|
|
-
|
|
|
- if(StringUtils.isNotBlank(degreeRegistration.getTheoryLevel())){
|
|
|
- degreeRegistration.setOrderNo(orderNo);
|
|
|
- BigDecimal theoryMoney = BigDecimal.ZERO;
|
|
|
- switch (degreeRegistration.getTheoryLevel()) {
|
|
|
- case "一级":
|
|
|
- theoryMoney = new BigDecimal(200);
|
|
|
- break;
|
|
|
- case "二级":
|
|
|
- theoryMoney = new BigDecimal(240);
|
|
|
- break;
|
|
|
- case "三级":
|
|
|
- theoryMoney = new BigDecimal(280);
|
|
|
- break;
|
|
|
- case "四级":
|
|
|
- theoryMoney = new BigDecimal(320);
|
|
|
- break;
|
|
|
- case "免考":
|
|
|
- break;
|
|
|
- default:
|
|
|
- throw new BizException("您选择的乐理级别不存在,请核对");
|
|
|
- }
|
|
|
- degreeRegistration.setTheoryMoney(theoryMoney);
|
|
|
- }else{
|
|
|
- degreeRegistration.setTheoryMoney(BigDecimal.ZERO);
|
|
|
- }
|
|
|
-
|
|
|
- if(Objects.nonNull(degreeRegistration.getSporadicId())||StringUtils.isNotBlank(degreeRegistration.getTheoryLevel())){
|
|
|
- degreeRegistration.setStatus(1);
|
|
|
- degreeRegistration.setCreateTime(nowDate);
|
|
|
- degreeRegistration.setUpdateTime(nowDate);
|
|
|
- degreeRegistrationDao.insert(degreeRegistration);
|
|
|
-
|
|
|
- List<DegreeRegistration> updateDegrees = new ArrayList<>();
|
|
|
- if(ingLevelNum>0||ingTheoryLevelNum>0){
|
|
|
- for (DegreeRegistration userLevelDegree : userLevelDegrees) {
|
|
|
- if(Objects.nonNull(userLevelDegree.getSporadicId())&&Objects.nonNull(userLevelDegree.getSporadicId())){
|
|
|
- userLevelDegree.setStatus(0);
|
|
|
- updateDegrees.add(userLevelDegree);
|
|
|
- }
|
|
|
- if(Objects.nonNull(userLevelDegree.getTheoryLevel())&&StringUtils.isNotBlank(userLevelDegree.getTheoryLevel())){
|
|
|
- userLevelDegree.setStatus(0);
|
|
|
- updateDegrees.add(userLevelDegree);
|
|
|
- }
|
|
|
- }
|
|
|
- if(!CollectionUtils.isEmpty(updateDegrees)){
|
|
|
- degreeRegistrationDao.batchUpdate(updateDegrees);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- BigDecimal additionCoursePrice = new BigDecimal("0");
|
|
|
- Map<CourseSchedule.CourseScheduleType, Integer> additionCourseInfo = degreeRegistration.getAdditionCourseInfo();
|
|
|
- if(additionCourseInfo != null && additionCourseInfo.size() > 0){
|
|
|
- PracticeGroupSellPrice practiceGroupSellPrice = practiceGroupSellPriceDao.get(degreeRegistration.getOrganId());
|
|
|
- if(Objects.isNull(practiceGroupSellPrice)){
|
|
|
- throw new BizException("该分部暂未参与此活动");
|
|
|
- }
|
|
|
-
|
|
|
- List<StudentPaymentOrderDetail> historyOrderDetails = studentPaymentOrderDetailDao.getWithUserAndOrderType(degreeRegistration.getUserId(), OrderTypeEnum.DEGREE_REGISTRATION);
|
|
|
- int historyVipNum = 0, historyPracticeNum = 0, historyHighNum = 0;
|
|
|
- for (StudentPaymentOrderDetail historyOrderDetail : historyOrderDetails) {
|
|
|
- if(StringUtils.isBlank(historyOrderDetail.getGoodsIdList())){
|
|
|
- continue;
|
|
|
- }
|
|
|
- Map<String, Integer> courseNumMap = JSON.parseObject(historyOrderDetail.getGoodsIdList(), Map.class);
|
|
|
- for (Map.Entry<String, Integer> stringIntegerEntry : courseNumMap.entrySet()) {
|
|
|
- switch (stringIntegerEntry.getKey()){
|
|
|
- case "VIP":
|
|
|
- historyVipNum = historyVipNum + stringIntegerEntry.getValue();
|
|
|
- break;
|
|
|
- case "PRACTICE":
|
|
|
- historyPracticeNum = historyPracticeNum + stringIntegerEntry.getValue();
|
|
|
- break;
|
|
|
- case "HIGH":
|
|
|
- historyHighNum = historyHighNum + stringIntegerEntry.getValue();
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- BigDecimal practiceUnitPrice = practiceGroupSellPrice.getOnceOriginalPrice(),
|
|
|
- vipUnitPrice = practiceGroupSellPrice.getVipOneStudentTwelveCourseActivityPriceWithNewUser(), highUnitPrice;
|
|
|
-
|
|
|
- if(additionCourseInfo.containsKey(CourseSchedule.CourseScheduleType.HIGH)){
|
|
|
- historyHighNum = historyHighNum + additionCourseInfo.get(CourseSchedule.CourseScheduleType.HIGH);
|
|
|
- }
|
|
|
- if(student.getIsNewUser()){
|
|
|
- highUnitPrice = practiceGroupSellPrice.getHighOnlineTenCourseOriginalPriceWithNewUser();
|
|
|
- if(additionCourseInfo.containsKey(CourseSchedule.CourseScheduleType.VIP)){
|
|
|
- historyVipNum = historyVipNum + additionCourseInfo.get(CourseSchedule.CourseScheduleType.VIP);
|
|
|
- }
|
|
|
- if(historyVipNum<=0){
|
|
|
- additionCourseInfo.remove(CourseSchedule.CourseScheduleType.PRACTICE);
|
|
|
- }
|
|
|
- boolean vipMoreThan2 = historyVipNum>=2;
|
|
|
- if(vipMoreThan2){
|
|
|
- if(FREE_PRICE_LEVEL.contains(degreeRegistration.getLevel())){
|
|
|
- degreeRegistration.setMoney(BigDecimal.ZERO);
|
|
|
- }else{
|
|
|
- degreeRegistration.setMoney(degreeRegistration.getMoney().divide(new BigDecimal(2), CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_DOWN));
|
|
|
- }
|
|
|
- highUnitPrice = practiceGroupSellPrice.getHighOnlineTenCourseActivityPriceWithNewUser();
|
|
|
- }
|
|
|
- if(vipMoreThan2&&historyHighNum>0){
|
|
|
- degreeRegistration.setTheoryMoney(BigDecimal.ZERO);
|
|
|
+ BigDecimal money = BigDecimal.ZERO;
|
|
|
+ List<DegreeRegistrationDto> registrationDtos = degreeRegistration.getDegreeRegistrationDtos();
|
|
|
+ List<DegreeRegistration> degreeRegistrationList = new ArrayList<>();
|
|
|
+ JSONObject jsonObject = JSON.parseObject(sysConfigDao.findConfigValue("degree_theory_amount_config"));
|
|
|
+ for (DegreeRegistrationDto registrationDto : registrationDtos) {
|
|
|
+ DegreeRegistration degree = new DegreeRegistration();
|
|
|
+ BeanUtils.copyProperties(degreeRegistration,degree);
|
|
|
+ String level = registrationDto.getLevel();
|
|
|
+ degree.setLevel(level);
|
|
|
+ degree.setSporadicId(registrationDto.getSporadicId());
|
|
|
+ degree.setMoney(registrationDto.getMoney());
|
|
|
+ degree.setTheoryCert(registrationDto.getTheoryCert());
|
|
|
+ degree.setType(registrationDto.getType());
|
|
|
+ degree.setStatus(1);
|
|
|
+ degree.setCreateTime(nowDate);
|
|
|
+ degree.setUpdateTime(nowDate);
|
|
|
+ if(Objects.nonNull(registrationDto.getSporadicId())){
|
|
|
+ SporadicChargeInfo chargeInfo = sporadicChargeInfoDao.get(registrationDto.getSporadicId());
|
|
|
+ if (chargeInfo == null || chargeInfo.getDelFlag().equals(1) || chargeInfo.getOpenFlag().equals(1)) {
|
|
|
+ throw new BizException("你选的考试级别不存在");
|
|
|
}
|
|
|
+ money = money.add(chargeInfo.getAmount());
|
|
|
+ degree.setMoney(chargeInfo.getAmount());
|
|
|
}else{
|
|
|
- highUnitPrice = practiceGroupSellPrice.getHighOnlineTenCourseActivityPriceWithOldUser();
|
|
|
- if(historyHighNum<=0){
|
|
|
- additionCourseInfo.remove(CourseSchedule.CourseScheduleType.PRACTICE);
|
|
|
- }
|
|
|
- }
|
|
|
- for (Map.Entry<CourseSchedule.CourseScheduleType, Integer> courseScheduleTypeIntegerEntry : additionCourseInfo.entrySet()) {
|
|
|
- BigDecimal courseTime = new BigDecimal(courseScheduleTypeIntegerEntry.getValue());
|
|
|
- switch (courseScheduleTypeIntegerEntry.getKey()){
|
|
|
- case VIP:
|
|
|
- BigDecimal vipPrice = vipUnitPrice.multiply(courseTime);
|
|
|
- additionCoursePrice = additionCoursePrice.add(vipPrice);
|
|
|
- courseInfos.add((courseTime.multiply(new BigDecimal(12)))+"节VIP-1V1课程费用:" + vipPrice);
|
|
|
- break;
|
|
|
- case PRACTICE:
|
|
|
- BigDecimal practicePrice = practiceUnitPrice.multiply(courseTime);
|
|
|
- additionCoursePrice = additionCoursePrice.add(practicePrice);
|
|
|
- courseInfos.add((courseTime.multiply(new BigDecimal(12)))+"节1V1网管课课程费用:" + practicePrice);
|
|
|
- break;
|
|
|
- case HIGH:
|
|
|
- BigDecimal highPrice = highUnitPrice.multiply(courseTime);
|
|
|
- additionCoursePrice = additionCoursePrice.add(highPrice);
|
|
|
- courseInfos.add((courseTime.multiply(new BigDecimal(10)))+"节乐理课程费用:" + highPrice);
|
|
|
- break;
|
|
|
- }
|
|
|
+ BigDecimal theoryPrice = new BigDecimal(jsonObject.get(level.equals("一级") ? "ONE" : level.equals("二级") ? "TWO" : level.equals("三级") ? "THREE" : "FOUR").toString());
|
|
|
+ money = money.add(theoryPrice);
|
|
|
+ degree.setMoney(theoryPrice);
|
|
|
}
|
|
|
+ degreeRegistrationList.add(degree);
|
|
|
}
|
|
|
+ degreeRegistrationDao.batchInsert(degreeRegistrationList);
|
|
|
|
|
|
- BigDecimal amount = degreeRegistration.getMoney();
|
|
|
- amount = amount.add(degreeRegistration.getTheoryMoney());
|
|
|
- amount = amount.add(additionCoursePrice);
|
|
|
-
|
|
|
- if(amount.compareTo(degreeRegistration.getPrice())!=0){
|
|
|
+ if(money.compareTo(degreeRegistration.getPrice())!=0){
|
|
|
throw new BizException("商品价格不符");
|
|
|
}
|
|
|
|
|
|
Integer userId = degreeRegistration.getUserId();
|
|
|
|
|
|
- OrderTypeEnum type = OrderTypeEnum.DEGREE_REGISTRATION;
|
|
|
-
|
|
|
String channelType = "";
|
|
|
StudentPaymentOrder studentPaymentOrder = new StudentPaymentOrder();
|
|
|
studentPaymentOrder.setUserId(userId);
|
|
|
studentPaymentOrder.setGroupType(GroupType.SPORADIC);
|
|
|
studentPaymentOrder.setOrderNo(orderNo);
|
|
|
- studentPaymentOrder.setType(type);
|
|
|
- studentPaymentOrder.setExpectAmount(amount);
|
|
|
+ studentPaymentOrder.setType(OrderTypeEnum.DEGREE_REGISTRATION);
|
|
|
+ studentPaymentOrder.setExpectAmount(money);
|
|
|
|
|
|
if(degreeRegistration.isUseBalance()){
|
|
|
SysUserCashAccount userCashAccount = sysUserCashAccountService.getLocked(userId);
|
|
@@ -312,55 +124,44 @@ public class DegreeRegistrationServiceImpl extends BaseServiceImpl<Integer, Degr
|
|
|
throw new BizException("用户账户找不到");
|
|
|
}
|
|
|
BigDecimal deductBalance = BigDecimal.ZERO;
|
|
|
- if (userCashAccount.getBalance().subtract(amount).doubleValue() >= 0) {
|
|
|
+ if (userCashAccount.getBalance().subtract(money).doubleValue() >= 0) {
|
|
|
// 更新订单信息
|
|
|
studentPaymentOrder.setActualAmount(BigDecimal.ZERO);
|
|
|
- studentPaymentOrder.setBalancePaymentAmount(amount);
|
|
|
- deductBalance = amount;
|
|
|
+ studentPaymentOrder.setBalancePaymentAmount(money);
|
|
|
+ deductBalance = money;
|
|
|
studentPaymentOrder.setPaymentChannel("BALANCE");
|
|
|
} else {
|
|
|
- studentPaymentOrder.setActualAmount(amount.subtract(userCashAccount.getBalance()));
|
|
|
+ studentPaymentOrder.setActualAmount(money.subtract(userCashAccount.getBalance()));
|
|
|
studentPaymentOrder.setBalancePaymentAmount(userCashAccount.getBalance());
|
|
|
deductBalance = userCashAccount.getBalance();
|
|
|
}
|
|
|
- amount = amount.subtract(deductBalance);
|
|
|
+ money = money.subtract(deductBalance);
|
|
|
sysUserCashAccountService.updateBalance(userId, deductBalance.negate(), PlatformCashAccountDetailTypeEnum.PAY_FEE, "考级报名");
|
|
|
}else{
|
|
|
- studentPaymentOrder.setActualAmount(amount);
|
|
|
+ studentPaymentOrder.setActualAmount(money);
|
|
|
studentPaymentOrder.setBalancePaymentAmount(BigDecimal.ZERO);
|
|
|
}
|
|
|
studentPaymentOrder.setStatus(DealStatusEnum.ING);
|
|
|
studentPaymentOrder.setClassGroupId(degreeRegistration.getId());
|
|
|
- if(Objects.nonNull(degreeRegistration.getSporadicId())){
|
|
|
- studentPaymentOrder.setMusicGroupId(degreeRegistration.getSporadicId().toString());
|
|
|
+ String collect = degreeRegistrationList.stream().filter(e -> e.getSporadicId() != null).map(e -> e.getSporadicId().toString()).collect(Collectors.joining(","));
|
|
|
+ if(StringUtils.isNotEmpty(collect)){
|
|
|
+ studentPaymentOrder.setMusicGroupId(collect);
|
|
|
}
|
|
|
studentPaymentOrder.setOrganId(degreeRegistration.getOrganId());
|
|
|
studentPaymentOrder.setRoutingOrganId(degreeRegistration.getOrganId());
|
|
|
- if(Objects.nonNull(degreeRegistration.getSporadicId())){
|
|
|
- courseInfos.add("乐器" + degreeRegistration.getLevel() + ",费用:" + degreeRegistration.getMoney());
|
|
|
- }
|
|
|
- if (StringUtils.isNotBlank(degreeRegistration.getTheoryLevel())) {
|
|
|
- courseInfos.add("乐理" + degreeRegistration.getTheoryLevel() + ",费用:" + degreeRegistration.getTheoryMoney());
|
|
|
- }
|
|
|
- studentPaymentOrder.setMemo(StringUtils.join(courseInfos, ";"));
|
|
|
studentPaymentOrderService.insert(studentPaymentOrder);
|
|
|
studentPaymentOrder.setVersion(0);
|
|
|
|
|
|
- if(BigDecimal.ZERO.compareTo(additionCoursePrice)<0){
|
|
|
- StudentPaymentOrderDetail studentPaymentOrderDetail = new StudentPaymentOrderDetail();
|
|
|
- studentPaymentOrderDetail.setType(OrderDetailTypeEnum.DEGREE_REGISTRATION);
|
|
|
- if(additionCourseInfo != null && additionCourseInfo.size() > 0){
|
|
|
- studentPaymentOrderDetail.setGoodsIdList(JSON.toJSONString(degreeRegistration.getAdditionCourseInfo()));
|
|
|
- }
|
|
|
- studentPaymentOrderDetail.setPrice(additionCoursePrice);
|
|
|
- studentPaymentOrderDetail.setRemitFee(BigDecimal.ZERO);
|
|
|
- studentPaymentOrderDetail.setPaymentOrderId(studentPaymentOrder.getId());
|
|
|
- studentPaymentOrderDetail.setCreateTime(nowDate);
|
|
|
- studentPaymentOrderDetail.setUpdateTime(nowDate);
|
|
|
- studentPaymentOrderDetailDao.insert(studentPaymentOrderDetail);
|
|
|
- }
|
|
|
+ StudentPaymentOrderDetail studentPaymentOrderDetail = new StudentPaymentOrderDetail();
|
|
|
+ studentPaymentOrderDetail.setType(OrderDetailTypeEnum.DEGREE_REGISTRATION);
|
|
|
+ studentPaymentOrderDetail.setPrice(money);
|
|
|
+ studentPaymentOrderDetail.setRemitFee(BigDecimal.ZERO);
|
|
|
+ studentPaymentOrderDetail.setPaymentOrderId(studentPaymentOrder.getId());
|
|
|
+ studentPaymentOrderDetail.setCreateTime(nowDate);
|
|
|
+ studentPaymentOrderDetail.setUpdateTime(nowDate);
|
|
|
+ studentPaymentOrderDetailDao.insert(studentPaymentOrderDetail);
|
|
|
|
|
|
- if (amount.compareTo(BigDecimal.ZERO) == 0) {
|
|
|
+ if (money.compareTo(BigDecimal.ZERO) == 0) {
|
|
|
Map<String, String> notifyMap = new HashMap<>();
|
|
|
notifyMap.put("tradeState", "1");
|
|
|
notifyMap.put("merOrderNo", studentPaymentOrder.getOrderNo());
|
|
@@ -374,13 +175,13 @@ public class DegreeRegistrationServiceImpl extends BaseServiceImpl<Integer, Degr
|
|
|
|
|
|
String receiver = "kjRegister";
|
|
|
Map payMap = payService.getPayMap(
|
|
|
- amount,
|
|
|
+ money,
|
|
|
BigDecimal.ZERO,
|
|
|
orderNo,
|
|
|
baseApiUrl + "/api-student/studentOrder/notify",
|
|
|
baseApiUrl + "/api-student/studentOrder/paymentResult?orderNo=" + orderNo,
|
|
|
- Objects.nonNull(chargeInfo)?chargeInfo.getDetail():"考级报名活动",
|
|
|
- Objects.nonNull(chargeInfo)?chargeInfo.getDetail():"考级报名活动",
|
|
|
+ "考级报名活动",
|
|
|
+ "考级报名活动",
|
|
|
degreeRegistration.getOrganId(),
|
|
|
receiver
|
|
|
);
|
|
@@ -392,8 +193,7 @@ public class DegreeRegistrationServiceImpl extends BaseServiceImpl<Integer, Degr
|
|
|
studentPaymentOrderService.update(studentPaymentOrder);
|
|
|
return BaseController.succeed(payMap);
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
+/*
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
|
|
@@ -426,7 +226,6 @@ public class DegreeRegistrationServiceImpl extends BaseServiceImpl<Integer, Degr
|
|
|
if("免考".equals(degreeRegistration.getTheoryLevel())){
|
|
|
degreeRegistration.setTheoryLevel(null);
|
|
|
}
|
|
|
-
|
|
|
if(StringUtils.isNotBlank(degreeRegistration.getTheoryLevel())){
|
|
|
degreeRegistration.setOrderNo(orderNo);
|
|
|
BigDecimal theoryMoney = BigDecimal.ZERO;
|
|
@@ -587,7 +386,7 @@ public class DegreeRegistrationServiceImpl extends BaseServiceImpl<Integer, Degr
|
|
|
studentPaymentOrder.setUpdateTime(nowDate);
|
|
|
studentPaymentOrderService.update(studentPaymentOrder);
|
|
|
return BaseController.succeed(payMap);
|
|
|
- }
|
|
|
+ }*/
|
|
|
|
|
|
@Override
|
|
|
public Boolean updateStatus(StudentPaymentOrder studentPaymentOrder) {
|
|
@@ -668,4 +467,49 @@ public class DegreeRegistrationServiceImpl extends BaseServiceImpl<Integer, Degr
|
|
|
pageInfo.setRows(dataList);
|
|
|
return pageInfo;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(isolation = Isolation.READ_COMMITTED)
|
|
|
+ public HttpResponseResult check(DegreeRegistrationActivityDto degreeRegistration) {
|
|
|
+ Date nowDate = new Date();
|
|
|
+ String startTimeStr = sysConfigDao.findConfigValue(SysConfigService.DEGREE_ACTIVITY_START_TIME);
|
|
|
+ if(StringUtils.isEmpty(startTimeStr)){
|
|
|
+ throw new BizException("活动还未开始,谢谢关注");
|
|
|
+ }
|
|
|
+ Date startTime = DateUtil.stringToDate(startTimeStr);
|
|
|
+ if (startTime.compareTo(nowDate) > 0) {
|
|
|
+ throw new BizException("活动还未开始,谢谢关注");
|
|
|
+ }
|
|
|
+ String endTimeStr = sysConfigDao.findConfigValue(SysConfigService.DEGREE_ACTIVITY_END_TIME);
|
|
|
+ if(StringUtils.isEmpty(endTimeStr)){
|
|
|
+ throw new BizException("活动还未开始,谢谢关注");
|
|
|
+ }
|
|
|
+ Date endTime = DateUtil.stringToDate(endTimeStr);
|
|
|
+ if (endTime.compareTo(nowDate) <= 0) {
|
|
|
+ throw new BizException("活动已结束,谢谢关注");
|
|
|
+ }
|
|
|
+ List<DegreeRegistrationDto> registrationDtos = degreeRegistration.getDegreeRegistrationDtos();
|
|
|
+ if(CollectionUtils.isEmpty(registrationDtos)){
|
|
|
+ return BaseController.failed(HttpStatus.FORBIDDEN,"请选择考级项目");
|
|
|
+ }
|
|
|
+ List<DegreeRegistrationDto> collect = registrationDtos.stream().filter(e -> e.getType() == 1).collect(Collectors.toList());
|
|
|
+ if(!CollectionUtils.isEmpty(collect)){
|
|
|
+ List<Integer> collect1 = collect.stream().map(e -> e.getSporadicId()).collect(Collectors.toList());
|
|
|
+ List<DegreeRegistration> userLevelDegrees = degreeRegistrationDao.getUserLevelDegrees(degreeRegistration.getUserId(),
|
|
|
+ DegreeRegistrationService.ACTIVITY_TAG,degreeRegistration.getDegreeType(),StringUtils.join(collect1,","),null);
|
|
|
+ if(!CollectionUtils.isEmpty(userLevelDegrees)){
|
|
|
+ return BaseController.failed(HttpStatus.CREATED, "您选择的 {} 乐器考级已报名,请勿重复选择",collect.get(0).getLevel());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ collect = registrationDtos.stream().filter(e -> e.getType() == 2).collect(Collectors.toList());
|
|
|
+ if(!CollectionUtils.isEmpty(collect)){
|
|
|
+ List<String> collect1 = collect.stream().map(e -> e.getLevel()).collect(Collectors.toList());
|
|
|
+ List<DegreeRegistration> userLevelDegrees = degreeRegistrationDao.getUserLevelDegrees(degreeRegistration.getUserId(),
|
|
|
+ DegreeRegistrationService.ACTIVITY_TAG,degreeRegistration.getDegreeType(),null,StringUtils.join(collect1,","));
|
|
|
+ if(!CollectionUtils.isEmpty(userLevelDegrees)){
|
|
|
+ return BaseController.failed(HttpStatus.CREATED, "您选择的 {} 乐理考级已报名,请勿重复选择",collect.get(0).getLevel());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return BaseController.succeed();
|
|
|
+ }
|
|
|
}
|