liujc 2 years ago
parent
commit
dd9748d705

+ 6 - 7
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/DegreeRegistrationDao.java

@@ -1,6 +1,7 @@
 package com.ym.mec.biz.dal.dao;
 
 import com.ym.mec.biz.dal.entity.DegreeRegistration;
+import com.ym.mec.biz.dal.enums.DegreeTypeEnum;
 import com.ym.mec.common.dal.BaseDAO;
 import org.apache.ibatis.annotations.Param;
 
@@ -21,13 +22,11 @@ public interface DegreeRegistrationDao extends BaseDAO<Integer, DegreeRegistrati
 
     DegreeRegistration getWithUserIdAndActivityTag(@Param("degree") DegreeRegistration degree);
 
-    List<DegreeRegistration> getUserLevelDegrees(@Param("userId") Integer userId,
-                                                 @Param("activityTag") String activityTag,
-                                                 @Param("degreeType") Integer degreeType,
-                                                 @Param("sporadicId") String sporadicId,
-                                                 @Param("level") String level,
-                                                 @Param("status") Integer status,
-                                                 @Param("subject") String subject);
+    DegreeRegistration getUserLevelDegrees(@Param("userId") Integer userId,
+                                                 @Param("degreeId") Long degreeId,
+                                                 @Param("degreeType") DegreeTypeEnum degreeType,
+                                                 @Param("levels") String levels,
+                                                 @Param("subjectId") Integer subjectId);
 
     void batchInsert(@Param("degreeRegistrationList") List<DegreeRegistration> degreeRegistrationList);
 

+ 4 - 37
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/DegreeRegistrationActivityDto.java

@@ -3,55 +3,22 @@ package com.ym.mec.biz.dal.dto;
 import com.ym.mec.biz.dal.entity.CourseSchedule;
 import com.ym.mec.biz.dal.entity.DegreeRegistration;
 import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
 
 import java.math.BigDecimal;
 import java.util.List;
 import java.util.Map;
 
-/**
- * @Author qnc99
- * @Date 2020/12/3 0003
- */
+@Data
 public class DegreeRegistrationActivityDto extends DegreeRegistration {
 
-    @ApiModelProperty(value = "用户所选考级项目列表",required = true)
+    @ApiModelProperty(value = "用户考级报名基本信息",required = true)
     private List<DegreeRegistrationDto> degreeRegistrationDtos;
 
+    @ApiModelProperty(value = "课程信息",required = true)
     private Map<CourseSchedule.CourseScheduleType, Integer> additionCourseInfo;
 
     private BigDecimal price;
     
     private boolean isUseBalance;
-
-    public List<DegreeRegistrationDto> getDegreeRegistrationDtos() {
-        return degreeRegistrationDtos;
-    }
-
-    public void setDegreeRegistrationDtos(List<DegreeRegistrationDto> degreeRegistrationDtos) {
-        this.degreeRegistrationDtos = degreeRegistrationDtos;
-    }
-
-    public Map<CourseSchedule.CourseScheduleType, Integer> getAdditionCourseInfo() {
-        return additionCourseInfo;
-    }
-
-    public void setAdditionCourseInfo(Map<CourseSchedule.CourseScheduleType, Integer> additionCourseInfo) {
-        this.additionCourseInfo = additionCourseInfo;
-    }
-
-    public BigDecimal getPrice() {
-        return price;
-    }
-
-    public void setPrice(BigDecimal price) {
-        this.price = price;
-    }
-
-	public boolean isUseBalance() {
-		return isUseBalance;
-	}
-
-	public void setIsUseBalance(boolean isUseBalance) {
-		this.isUseBalance = isUseBalance;
-	}
 }

+ 6 - 43
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/DegreeRegistrationDto.java

@@ -1,13 +1,16 @@
 package com.ym.mec.biz.dal.dto;
 
+import com.ym.mec.biz.dal.enums.DegreeTypeEnum;
 import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
 
 import java.math.BigDecimal;
 import java.util.Date;
 
+@Data
 public class DegreeRegistrationDto{
-    @ApiModelProperty(value = "零星支付id",required = false)
-    private Integer sporadicId;
+    @ApiModelProperty(value = "考级编号",required = false)
+    private Long degreeId;
 
     @ApiModelProperty(value = "考试级别",required = false)
     private String level;
@@ -19,45 +22,5 @@ public class DegreeRegistrationDto{
     private BigDecimal money;
 
     @ApiModelProperty(value = "1乐器考级、2乐理考级",required = false)
-    private Integer type;
-
-    public Integer getType() {
-        return type;
-    }
-
-    public void setType(Integer type) {
-        this.type = type;
-    }
-
-    public Integer getSporadicId() {
-        return sporadicId;
-    }
-
-    public void setSporadicId(Integer sporadicId) {
-        this.sporadicId = sporadicId;
-    }
-
-    public String getLevel() {
-        return level;
-    }
-
-    public void setLevel(String level) {
-        this.level = level;
-    }
-
-    public String getTheoryCert() {
-        return theoryCert;
-    }
-
-    public void setTheoryCert(String theoryCert) {
-        this.theoryCert = theoryCert;
-    }
-
-    public BigDecimal getMoney() {
-        return money;
-    }
-
-    public void setMoney(BigDecimal money) {
-        this.money = money;
-    }
+    private DegreeTypeEnum type;
 }

+ 17 - 307
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/DegreeRegistration.java

@@ -1,380 +1,90 @@
 package com.ym.mec.biz.dal.entity;
 
+import com.ym.mec.biz.dal.enums.DegreeTypeEnum;
+import com.ym.mec.common.tenant.TenantContextHolder;
 import io.swagger.annotations.ApiModelProperty;
 
 import java.math.BigDecimal;
 import java.util.Date;
 
 import com.ym.mec.common.entity.BaseEntity;
+import lombok.Data;
 
-public class DegreeRegistration extends BaseEntity {
+@Data
+public class DegreeRegistration {
     private Integer id;
 
-    /**
-     * 零星支付id
-     */
-    @ApiModelProperty(value = "零星支付id",required = true)
-    private Integer sporadicId;
+    @ApiModelProperty(value = "考级编号",required = true)
+    private Long degreeId;
 
+    @ApiModelProperty(value = "学员编号",required = true)
     private Integer userId;
 
-    /**
-     * 订单编号
-     */
     @ApiModelProperty(value = "订单编号",required = false)
     private String orderNo;
 
-
-    /**
-     * 订单流水号
-     */
     @ApiModelProperty(value = "订单流水号",required = false)
     private String transNo;
 
-
-    /**
-     * 姓名
-     */
     @ApiModelProperty(value = "名字",required = true)
     private String name;
 
-    /**
-     * 性别
-     */
     @ApiModelProperty(value = "性别",required = true)
     private String gender;
 
     @ApiModelProperty(value = "证件类型",required = true)
 	private String certificateType;
 
-    /**
-     * 身份证号
-     */
     @ApiModelProperty(value = "身份证号",required = true)
     private String idcard;
 
-    /**
-     * 城市
-     */
     @ApiModelProperty(value = "城市",required = true)
     private String city;
 
-    /**
-     * 学校
-     */
     @ApiModelProperty(value = "学校",required = true)
     private String school;
 
-    /**
-     * 乐器
-     */
-    @ApiModelProperty(value = "乐器",required = true)
-    private String subject;
+    @ApiModelProperty(value = "声部",required = true)
+    private Integer subjectId;
 
-    /**
-     * 考试级别
-     */
     @ApiModelProperty(value = "考试级别",required = true)
     private String level;
 
-    /**
-     * 考试类型
-     */
-    @ApiModelProperty(value = "考试类型",required = true)
-    private Integer degreeType;
-
-    @ApiModelProperty(value = "1乐器考级、2乐理考级",required = true)
-    private Integer type;
-
+    @ApiModelProperty(value = "考级类型",required = true)
+    private DegreeTypeEnum type;
 
-    /**
-     * 乐理级别证书
-     */
-    @ApiModelProperty(value = "乐理级别证书",required = true)
+    @ApiModelProperty(value = "证书",required = true)
     private String theoryCert;
 
-    /**
-     * 家长联系电话
-     */
     @ApiModelProperty(value = "家长联系电话",required = true)
     private String mobile;
 
-    /**
-     * 考级费用
-     */
     @ApiModelProperty(value = "考级费用",required = false)
     private BigDecimal money;
 
-    /**
-     * 备注
-     */
     @ApiModelProperty(value = "备注",required = false)
     private String memo;
 
-    /**
-     * 报名时间
-     */
     private Date createTime;
 
-    /**
-     * 更新时间
-     */
     private Date updateTime;
 
-    /**
-     * 0-未支付 1-支付中 2-已支付 2-已退费
-     */
+    @ApiModelProperty(value = "支付状态 0-未支付 1-支付中 2-已支付 2-已退费",required = false)
     private Integer status;
 
-
-    /**
-     * 0-未支付 1-支付中 2-支付中
-     */
+    @ApiModelProperty(value = "支付状态 0-未支付 1-支付中 2-已支付 2-已退费",required = false)
     private String statusStr;
 
-    /**
-     *  是否重新支付
-     */
     @ApiModelProperty(value = "是否重新支付",required = false)
     private Boolean isRepay = false;
 
     private Integer organId;
 
-    private String activityTag;
+//    private String activityTag;
 
     private String vipTeacherName;
 
     private String normalTeacherName;
 
-    public String getVipTeacherName() {
-        return vipTeacherName;
-    }
-
-    public void setVipTeacherName(String vipTeacherName) {
-        this.vipTeacherName = vipTeacherName;
-    }
-
-    public String getNormalTeacherName() {
-        return normalTeacherName;
-    }
-
-    public void setNormalTeacherName(String normalTeacherName) {
-        this.normalTeacherName = normalTeacherName;
-    }
-
-    public Integer getType() {
-        return type;
-    }
-
-    public void setType(Integer type) {
-        this.type = type;
-    }
-
-    public Integer getDegreeType() {
-        return degreeType;
-    }
-
-    public void setDegreeType(Integer degreeType) {
-        this.degreeType = degreeType;
-    }
-
-    public Boolean getRepay() {
-        return isRepay;
-    }
-
-    public void setRepay(Boolean repay) {
-        isRepay = repay;
-    }
-
-    public Integer getId() {
-        return id;
-    }
-
-    public void setId(Integer id) {
-        this.id = id;
-    }
-
-    public Integer getUserId() {
-        return userId;
-    }
-
-    public void setUserId(Integer userId) {
-        this.userId = userId;
-    }
-
-    public String getActivityTag() {
-        return activityTag;
-    }
-
-    public void setActivityTag(String activityTag) {
-        this.activityTag = activityTag;
-    }
-
-    public Integer getSporadicId() {
-        return sporadicId;
-    }
-
-    public void setSporadicId(Integer sporadicId) {
-        this.sporadicId = sporadicId;
-    }
-
-    public String getName() {
-        return name;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    public String getGender() {
-        return gender;
-    }
-
-    public void setGender(String gender) {
-        this.gender = gender;
-    }
-
-    public String getIdcard() {
-        return idcard;
-    }
-
-    public void setIdcard(String idcard) {
-        this.idcard = idcard;
-    }
-
-    public String getCity() {
-        return city;
-    }
-
-    public void setCity(String city) {
-        this.city = city;
-    }
-
-    public String getSchool() {
-        return school;
-    }
-
-    public void setSchool(String school) {
-        this.school = school;
-    }
-
-    public String getSubject() {
-        return subject;
-    }
-
-    public void setSubject(String subject) {
-        this.subject = subject;
-    }
-
-    public String getMobile() {
-        return mobile;
-    }
-
-    public void setMobile(String mobile) {
-        this.mobile = mobile;
-    }
-
-    public BigDecimal getMoney() {
-        return money;
-    }
-
-    public void setMoney(BigDecimal money) {
-        this.money = money;
-    }
-
-    public String getMemo() {
-        return memo;
-    }
-
-    public void setMemo(String memo) {
-        this.memo = memo;
-    }
-
-    public Date getCreateTime() {
-        return createTime;
-    }
-
-    public void setCreateTime(Date createTime) {
-        this.createTime = createTime;
-    }
-
-    public Date getUpdateTime() {
-        return updateTime;
-    }
-
-    public void setUpdateTime(Date updateTime) {
-        this.updateTime = updateTime;
-    }
-
-    public Integer getStatus() {
-        return status;
-    }
-
-    public void setStatus(Integer status) {
-        this.status = status;
-    }
-
-    public Boolean getIsRepay() {
-        return isRepay;
-    }
-
-    public void setIsRepay(Boolean repay) {
-        isRepay = repay;
-    }
-
-    public String getLevel() {
-        return level;
-    }
-
-    public void setLevel(String level) {
-        this.level = level;
-    }
-
-    public String getTheoryCert() {
-        return theoryCert;
-    }
-
-    public void setTheoryCert(String theoryCert) {
-        this.theoryCert = theoryCert;
-    }
-
-    public String getStatusStr() {
-        return statusStr;
-    }
-
-    public void setStatusStr(String statusStr) {
-        this.statusStr = statusStr;
-    }
-
-    public String getOrderNo() {
-        return orderNo;
-    }
-
-    public void setOrderNo(String orderNo) {
-        this.orderNo = orderNo;
-    }
-
-    public String getTransNo() {
-        return transNo;
-    }
-
-    public void setTransNo(String transNo) {
-        this.transNo = transNo;
-    }
-
-    public Integer getOrganId() {
-        return organId;
-    }
-
-    public void setOrganId(Integer organId) {
-        this.organId = organId;
-    }
-
-	public String getCertificateType() {
-		return certificateType;
-	}
-
-	public void setCertificateType(String certificateType) {
-		this.certificateType = certificateType;
-	}
+    private Integer tenantId = TenantContextHolder.getTenantId();
 }

+ 2 - 2
mec-biz/src/main/java/com/ym/mec/biz/dal/enums/DegreeTypeEnum.java

@@ -4,8 +4,8 @@ import com.baomidou.mybatisplus.annotation.EnumValue;
 import com.ym.mec.common.enums.BaseEnum;
 
 public enum DegreeTypeEnum implements BaseEnum<String, ComplaintsStatusEnum> {
-    GRADE("GRADE", "级"),
-    THEORY("THEORY", "乐理");
+    GRADE("GRADE", "乐器考级"),
+    THEORY("THEORY", "乐理考级");
 
     @EnumValue
     private String code;

+ 40 - 48
mec-biz/src/main/java/com/ym/mec/biz/service/impl/DegreeRegistrationServiceImpl.java

@@ -1,8 +1,9 @@
 package com.ym.mec.biz.service.impl;
 
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONObject;
-import com.ym.mec.biz.dal.dao.*;
+import com.ym.mec.biz.dal.dao.DegreeRegistrationDao;
+import com.ym.mec.biz.dal.dao.StudentPaymentOrderDetailDao;
+import com.ym.mec.biz.dal.dao.StudentTeacherMapperDao;
+import com.ym.mec.biz.dal.dao.SysConfigDao;
 import com.ym.mec.biz.dal.dto.DegreeRegistrationActivityDto;
 import com.ym.mec.biz.dal.dto.DegreeRegistrationDto;
 import com.ym.mec.biz.dal.dto.PageInfoDegree;
@@ -17,7 +18,6 @@ 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.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;
@@ -37,8 +37,6 @@ public class DegreeRegistrationServiceImpl extends BaseServiceImpl<Integer, Degr
     @Autowired
     private DegreeRegistrationDao degreeRegistrationDao;
     @Autowired
-    private SporadicChargeInfoDao sporadicChargeInfoDao;
-    @Autowired
     private IdGeneratorService idGeneratorService;
     @Autowired
     private StudentPaymentOrderService studentPaymentOrderService;
@@ -52,6 +50,10 @@ public class DegreeRegistrationServiceImpl extends BaseServiceImpl<Integer, Degr
     private SysUserCashAccountService sysUserCashAccountService;
     @Autowired
     private StudentTeacherMapperDao studentTeacherMapperDao;
+    @Autowired
+    private DegreeLevelFeeService degreeLevelFeeService;
+    @Autowired
+    private DegreeService degreeService;
 
     @Override
     public BaseDAO<Integer, DegreeRegistration> getDAO() {
@@ -77,7 +79,6 @@ public class DegreeRegistrationServiceImpl extends BaseServiceImpl<Integer, Degr
                 }
             }
         }
-        degreeRegistration.setActivityTag(ACTIVITY_TAG);
         Date nowDate = new Date();
         String orderNo = idGeneratorService.generatorId("payment") + "";
         degreeRegistration.setOrderNo(orderNo);
@@ -85,31 +86,24 @@ public class DegreeRegistrationServiceImpl extends BaseServiceImpl<Integer, Degr
         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.setDegreeId(registrationDto.getDegreeId());
             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{
-                BigDecimal theoryPrice = new BigDecimal(jsonObject.get(level.equals("一级") ? "ONE" : level.equals("二级") ? "TWO" : level.equals("三级") ? "THREE" : "FOUR").toString());
-                money = money.add(theoryPrice);
-                degree.setMoney(theoryPrice);
+            DegreeLevelFeeNew one = degreeLevelFeeService.lambdaQuery()
+                    .eq(DegreeLevelFeeNew::getSubjectId, degreeRegistration.getSubjectId())
+                    .eq(DegreeLevelFeeNew::getDegreeType, degreeRegistration.getType())
+                    .eq(DegreeLevelFeeNew::getLevel, degreeRegistration.getLevel()).one();
+            if(Objects.isNull(one)){
+                throw new BizException("考级费用设置异常");
             }
+            degree.setMoney(one.getFee());
             degreeRegistrationList.add(degree);
         }
         degreeRegistrationDao.batchInsert(degreeRegistrationList);
@@ -153,7 +147,7 @@ public class DegreeRegistrationServiceImpl extends BaseServiceImpl<Integer, Degr
         }
         studentPaymentOrder.setStatus(DealStatusEnum.ING);
         studentPaymentOrder.setClassGroupId(degreeRegistration.getId());
-        String collect = degreeRegistrationList.stream().filter(e -> e.getSporadicId() != null).map(e -> e.getSporadicId().toString()).collect(Collectors.joining(","));
+        String collect = degreeRegistrationList.stream().map(e -> e.getDegreeId().toString()).collect(Collectors.joining(","));
         if(StringUtils.isNotEmpty(collect)){
             studentPaymentOrder.setMusicGroupId(collect);
         }
@@ -277,46 +271,44 @@ public class DegreeRegistrationServiceImpl extends BaseServiceImpl<Integer, Degr
     }
 
     @Override
-    @Transactional(isolation = Isolation.READ_COMMITTED)
+    @Transactional(rollbackFor = Exception.class)
     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("活动还未开始,谢谢关注");
+        Degree degree = degreeService.getById(degreeRegistration.getDegreeId());
+        //是否对分部开放
+        if(StringUtils.isNotEmpty(degree.getOrganIds())){
+            List<Integer> studentIdList = Arrays.stream(degree.getOrganIds().split(",")).map(id -> Integer.valueOf(id)).collect(Collectors.toList());
+            if(!studentIdList.contains(degreeRegistration.getSubjectId())){
+                return BaseController.failed("该分部暂未开放此活动");
+            }
         }
-        String endTimeStr = sysConfigDao.findConfigValue(SysConfigService.DEGREE_ACTIVITY_END_TIME);
-        if(StringUtils.isEmpty(endTimeStr)){
+        if (degree.getStartTime().compareTo(nowDate) > 0) {
             throw new BizException("活动还未开始,谢谢关注");
         }
-        Date endTime = DateUtil.stringToDate(endTimeStr);
-        if (endTime.compareTo(nowDate) <= 0) {
+        if (degree.getEndTime().compareTo(nowDate) <= 0) {
             throw new BizException("活动已结束,谢谢关注");
         }
         List<DegreeRegistrationDto> registrationDtos = degreeRegistration.getDegreeRegistrationDtos();
         if(CollectionUtils.isEmpty(registrationDtos)){
             return BaseController.failed(HttpStatus.CREATED,"请选择考级项目");
         }
-        List<DegreeRegistrationDto> collect = registrationDtos.stream().filter(e -> e.getType() == 1).collect(Collectors.toList());
+        List<DegreeRegistrationDto> collect = registrationDtos.stream().filter(e -> e.getType() == DegreeTypeEnum.GRADE).collect(Collectors.toList());
+        Long degreeId = collect.stream().map(e -> e.getDegreeId()).collect(Collectors.toList()).get(0);
         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,2,degreeRegistration.getSubject());
-            if(!CollectionUtils.isEmpty(userLevelDegrees)){
-                return BaseController.failed(HttpStatus.CREATED, "您选择的 " + userLevelDegrees.get(0).getLevel() +  " 乐器考级已报名,请勿重复选择");
+            String levels = collect.stream().map(e -> e.getLevel()).collect(Collectors.joining(","));
+            DegreeRegistration userLevelDegree = degreeRegistrationDao.getUserLevelDegrees(degreeRegistration.getUserId(),
+                    degreeId,DegreeTypeEnum.GRADE,levels,degreeRegistration.getSubjectId());
+            if(Objects.nonNull(userLevelDegree)){
+                return BaseController.failed(HttpStatus.CREATED, "您选择的 " + userLevelDegree.getLevel() +  " 乐器考级已报名,请勿重复选择");
             }
         }
-        collect = registrationDtos.stream().filter(e -> e.getType() == 2).collect(Collectors.toList());
+        collect = registrationDtos.stream().filter(e -> e.getType() == DegreeTypeEnum.THEORY).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,","),2,null);
-            if(!CollectionUtils.isEmpty(userLevelDegrees)){
-                return BaseController.failed(HttpStatus.CREATED, "您选择的 " + userLevelDegrees.get(0).getLevel() +  " 乐理考级已报名,请勿重复选择");
+            String levels = collect.stream().map(e -> e.getLevel()).collect(Collectors.joining(","));
+            DegreeRegistration userLevelDegree = degreeRegistrationDao.getUserLevelDegrees(degreeRegistration.getUserId(),
+                    degreeId,DegreeTypeEnum.THEORY,levels,degreeRegistration.getSubjectId());
+            if(Objects.nonNull(userLevelDegree)){
+                return BaseController.failed(HttpStatus.CREATED, "您选择的 " + userLevelDegree.getLevel() +  " 乐理考级已报名,请勿重复选择");
             }
         }
         return BaseController.succeed();

+ 26 - 59
mec-biz/src/main/resources/config/mybatis/DegreeRegistrationMapper.xml

@@ -6,7 +6,7 @@
         <!--@Table degree_registration-->
         <id column="id_" jdbcType="INTEGER" property="id"/>
         <result column="user_id_" property="userId"/>
-        <result column="sporadic_id_" jdbcType="INTEGER" property="sporadicId"/>
+        <result column="degree_id_" property="degreeId"/>
         <result column="organ_id_" jdbcType="INTEGER" property="organId"/>
         <result column="order_no_" jdbcType="VARCHAR" property="orderNo"/>
         <result column="trans_no_" jdbcType="VARCHAR" property="transNo"/>
@@ -15,7 +15,7 @@
         <result column="idcard_" jdbcType="VARCHAR" property="idcard"/>
         <result column="city_" jdbcType="VARCHAR" property="city"/>
         <result column="school_" jdbcType="VARCHAR" property="school"/>
-        <result column="subject_" jdbcType="VARCHAR" property="subject"/>
+        <result column="subject_id_" property="subjectId"/>
         <result column="level_" jdbcType="VARCHAR" property="level"/>
         <result column="theory_cert_" jdbcType="VARCHAR" property="theoryCert"/>
         <result column="mobile_" jdbcType="VARCHAR" property="mobile"/>
@@ -24,12 +24,10 @@
         <result column="create_time_" jdbcType="TIMESTAMP" property="createTime"/>
         <result column="update_time_" jdbcType="TIMESTAMP" property="updateTime"/>
         <result column="status_" jdbcType="TINYINT" property="status"/>
-        <result column="activity_tag_" property="activityTag"/>
-        <result column="degree_type_" property="degreeType"/>
         <result column="certificate_type_" property="certificateType"/>
 		<result column="tenant_id_" property="tenantId" />
 		<result column="type_" property="type" />
-		<result column="degree_id_" property="degreeId" />
+		<result column="type_" property="type"  typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
     </resultMap>
 
     <select id="get" parameterType="java.lang.Integer" resultMap="DegreeRegistration">
@@ -133,32 +131,32 @@
     <insert id="insert" keyColumn="id_" keyProperty="id" parameterType="com.ym.mec.biz.dal.entity.DegreeRegistration"
             useGeneratedKeys="true">
         <!--@mbg.generated-->
-        insert into degree_registration (user_id_,sporadic_id_,organ_id_,order_no_, name_, gender_,
+        insert into degree_registration (user_id_,degree_id_,organ_id_,order_no_, name_, gender_,
         idcard_, city_, school_,
-        subject_,level_, theory_cert_,mobile_,
+        subject_id_,level_, theory_cert_,mobile_,
         money_, memo_, create_time_,
-        update_time_, status_, activity_tag_,degree_type_,certificate_type_,tenant_id_,type_)
-        values (#{userId},#{sporadicId,jdbcType=INTEGER},#{organId,jdbcType=INTEGER}, #{orderNo,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{gender,jdbcType=VARCHAR},
+        update_time_, status_,certificate_type_,tenant_id_,type_)
+        values (#{userId},#{degreeId},#{organId,jdbcType=INTEGER}, #{orderNo,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{gender,jdbcType=VARCHAR},
         #{idcard,jdbcType=VARCHAR}, #{city,jdbcType=VARCHAR}, #{school,jdbcType=VARCHAR},
-        #{subject,jdbcType=VARCHAR},#{level,jdbcType=VARCHAR},
+        #{subjectId},#{level,jdbcType=VARCHAR},
         #{theoryCert,jdbcType=VARCHAR},#{mobile,jdbcType=VARCHAR},#{money,jdbcType=DECIMAL}, #{memo,jdbcType=VARCHAR},
-        #{createTime}, #{updateTime}, #{status,jdbcType=TINYINT}, #{activityTag}, #{degreeType},#{certificateType},#{tenantId},#{type})
+        #{createTime}, #{updateTime}, #{status,jdbcType=TINYINT},#{certificateType},#{tenantId},#{type})
     </insert>
     <insert id="batchInsert">
-        INSERT INTO degree_registration (user_id_,sporadic_id_,organ_id_,order_no_, name_, gender_,
+        INSERT INTO degree_registration (user_id_,degree_id_,organ_id_,order_no_, name_, gender_,
         idcard_, city_, school_,
-        subject_,level_, theory_cert_,mobile_,
+        subject_id_,level_, theory_cert_,mobile_,
         money_, memo_, create_time_,
-        update_time_, status_, activity_tag_,degree_type_,certificate_type_,tenant_id_,type_)
+        update_time_, status_,certificate_type_,tenant_id_,type_)
         VALUE
         <foreach collection="degreeRegistrationList" separator="," item="degreeRegistration">
-            (#{degreeRegistration.userId},#{degreeRegistration.sporadicId,jdbcType=INTEGER},#{degreeRegistration.organId,jdbcType=INTEGER},
+            (#{degreeRegistration.userId},#{degreeRegistration.degreeId,jdbcType=INTEGER},#{degreeRegistration.organId,jdbcType=INTEGER},
             #{degreeRegistration.orderNo,jdbcType=VARCHAR}, #{degreeRegistration.name,jdbcType=VARCHAR}, #{degreeRegistration.gender,jdbcType=VARCHAR},
             #{degreeRegistration.idcard,jdbcType=VARCHAR}, #{degreeRegistration.city,jdbcType=VARCHAR}, #{degreeRegistration.school,jdbcType=VARCHAR},
-            #{degreeRegistration.subject,jdbcType=VARCHAR},#{degreeRegistration.level,jdbcType=VARCHAR},
+            #{degreeRegistration.subjectId},#{degreeRegistration.level,jdbcType=VARCHAR},
             #{degreeRegistration.theoryCert,jdbcType=VARCHAR},#{degreeRegistration.mobile,jdbcType=VARCHAR},#{degreeRegistration.money,jdbcType=DECIMAL}, #{degreeRegistration.memo,jdbcType=VARCHAR},
             #{degreeRegistration.createTime}, #{degreeRegistration.updateTime}, #{degreeRegistration.status,jdbcType=TINYINT},
-            #{degreeRegistration.activityTag}, #{degreeRegistration.degreeType},#{degreeRegistration.certificateType},#{degreeRegistration.tenantId},#{degreeRegistration.type})
+            #{degreeRegistration.certificateType},#{degreeRegistration.tenantId},#{degreeRegistration.type})
         </foreach>
     </insert>
     <update id="update" parameterType="com.ym.mec.biz.dal.entity.DegreeRegistration">
@@ -168,14 +166,11 @@
             <if test="userId != null">
                 user_id_ = #{userId},
             </if>
-            <if test="degreeType != null">
-                degree_type_ = #{degreeType},
-            </if>
             <if test="organId != null">
                 organ_id_ = #{organId,jdbcType=INTEGER},
             </if>
-            <if test="sporadicId != null">
-                sporadic_id_ = #{sporadicId,jdbcType=INTEGER},
+            <if test="degreeId != null">
+                degree_id_ = #{degreeId},
             </if>
             <if test="orderNo != null">
                 order_no_ = #{orderNo,jdbcType=VARCHAR},
@@ -198,8 +193,8 @@
             <if test="school != null">
                 school_ = #{school,jdbcType=VARCHAR},
             </if>
-            <if test="subject != null">
-                subject_ = #{subject,jdbcType=VARCHAR},
+            <if test="subjectId != null">
+                subject_id_ = #{subjectId},
             </if>
             <if test="level != null">
                 level_ = #{level,jdbcType=VARCHAR},
@@ -222,9 +217,6 @@
             <if test="status != null">
                 status_ = #{status,jdbcType=INTEGER},
             </if>
-            <if test="activityTag != null">
-                activity_tag_ = #{activityTag},
-            </if>
             <if test="certificateType != null">
                 certificate_type_ = #{certificateType},
             </if>
@@ -240,14 +232,11 @@
                 <if test="degree.userId != null">
                     user_id_ = #{degree.userId},
                 </if>
-                <if test="degree.degreeType != null">
-                    degree_type_ = #{degree.degreeType},
-                </if>
                 <if test="degree.organId != null">
                     organ_id_ = #{degree.organId,jdbcType=INTEGER},
                 </if>
-                <if test="degree.sporadicId != null">
-                    sporadic_id_ = #{degree.sporadicId,jdbcType=INTEGER},
+                <if test="degree.degreeId != null">
+                    degree_id_ = #{degree.degreeId},
                 </if>
                 <if test="degree.orderNo != null">
                     order_no_ = #{degree.orderNo,jdbcType=VARCHAR},
@@ -270,8 +259,8 @@
                 <if test="degree.school != null">
                     school_ = #{degree.school,jdbcType=VARCHAR},
                 </if>
-                <if test="degree.subject != null">
-                    subject_ = #{degree.subject,jdbcType=VARCHAR},
+                <if test="degree.subjectId != null">
+                    subject_id_ = #{degree.subjectId},
                 </if>
                 <if test="degree.level != null">
                     level_ = #{degree.level,jdbcType=VARCHAR},
@@ -294,9 +283,6 @@
                 <if test="degree.status != null">
                     status_ = #{degree.status,jdbcType=INTEGER},
                 </if>
-                <if test="degree.activityTag != null">
-                    activity_tag_ = #{degree.activityTag},
-                </if>
 	            <if test="degree.certificateType != null">
 	                certificate_type_ = #{degree.certificateType},
 	            </if>
@@ -338,24 +324,9 @@
     </select>
 
     <select id="getUserLevelDegrees" resultMap="DegreeRegistration">
-        SELECT * FROM degree_registration
-        WHERE user_id_ = #{userId}
-            AND activity_tag_=#{activityTag}
-            <if test="degreeType != null">
-                AND degree_type_ = #{degreeType}
-            </if>
-            <if test="status != null">
-                AND status_ = #{status}
-            </if>
-            <if test="subject != null and subject != ''">
-                AND subject_ = #{subject}
-            </if>
-            <if test="sporadicId != null and sporadicId != ''">
-                AND FIND_IN_SET(sporadic_id_,#{sporadicId})
-            </if>
-            <if test="level != null and level != ''">
-                AND sporadic_id_ IS NULL AND FIND_IN_SET(level_,#{level})
-            </if>
+        select * from degree_registration
+        where user_id_ = #{userId} and degree_id_ = #{degreeId} and degree_type_ = #{degreeType}
+          AND FIND_IN_SET(level_,#{levels}) AND subject_id_ = #{subjectId} LIMIT 1
     </select>
     <select id="getLockByOrderId" resultMap="DegreeRegistration">
         SELECT * FROM degree_registration WHERE order_no_ = #{orderNo} FOR UPDATE
@@ -363,8 +334,4 @@
     <select id="findByByOrderId" resultMap="DegreeRegistration">
         SELECT * FROM degree_registration WHERE order_no_ = #{orderNo}
     </select>
-
-    <select id="selectByDegreeId" resultMap="DegreeRegistration">
-        SELECT * FROM degree_registration WHERE degree_id_ = #{degreeId}
-    </select>
 </mapper>

+ 12 - 12
mec-student/src/main/java/com/ym/mec/student/controller/DegreeController.java

@@ -72,18 +72,6 @@ public class DegreeController extends BaseController {
             return failed(HttpStatus.FORBIDDEN,"请登录");
         }
         degreeRegistration.setUserId(user.getId());
-        HttpResponseResult result = degreeRegistrationService.check(degreeRegistration);
-        if(result.getCode() != 200){
-            return result;
-        }
-        TenantContextHolder.setTenantId(user.getTenantId());
-        degreeRegistration.setUserId(user.getId());
-        if("IDENTITY".equals(degreeRegistration.getCertificateType())){
-	        IdcardValidator idcardValidator = new IdcardValidator();
-	        if (!debugMode && !idcardValidator.isValidatedAllIdcard(degreeRegistration.getIdcard())) {
-	            throw new BizException("身份证号不正确,请核对");
-	        }
-        }
         if(user.getOrganId() == null || user.getOrganId() == 43){
             user.setUsername(degreeRegistration.getName());
             user.setIdCardNo(degreeRegistration.getIdcard());
@@ -97,6 +85,18 @@ public class DegreeController extends BaseController {
         if(Objects.isNull(degreeRegistration.getOrganId())){
             return failed("该分部暂未开放此活动");
         }
+        HttpResponseResult result = degreeRegistrationService.check(degreeRegistration);
+        if(result.getCode() != 200){
+            return result;
+        }
+        TenantContextHolder.setTenantId(user.getTenantId());
+        degreeRegistration.setUserId(user.getId());
+        if("IDENTITY".equals(degreeRegistration.getCertificateType())){
+	        IdcardValidator idcardValidator = new IdcardValidator();
+	        if (!debugMode && !idcardValidator.isValidatedAllIdcard(degreeRegistration.getIdcard())) {
+	            throw new BizException("身份证号不正确,请核对");
+	        }
+        }
         HttpResponseResult pay = degreeRegistrationService.pay(degreeRegistration);
         TenantContextHolder.clearTenantId();
         return pay;

+ 4 - 4
mec-web/src/main/java/com/ym/mec/web/controller/ExportController.java

@@ -1784,10 +1784,10 @@ public class ExportController extends BaseController {
         map.put("九级", "9");
         map.put("十级", "10");
         for (DegreeRegistration row : pageList.getRows()) {
-            row.setActivityTag(map.get(row.getLevel()));
-            if (row.getType() == 2) {
-                row.setSubject("乐理");
-            }
+//            row.setActivityTag(map.get(row.getLevel()));
+//            if (row.getType() == DegreeTypeEnum.THEORY) {
+//                row.setSubject("乐理");
+//            }
             row.setGender("1".equals(row.getGender()) ? "男" : "女");
         }
         OutputStream outputStream = response.getOutputStream();

+ 1 - 1
mec-web/src/main/java/com/ym/mec/web/controller/degree/DegreeInfoController.java

@@ -92,7 +92,7 @@ public class DegreeInfoController extends BaseController {
 
     @ApiOperation(value = "详情统计", notes = "考级信息- 传入id")
 //    @PreAuthorize("@pcs.hasPermissions('degree/statistic')")
-	@PostMapping("/statistic")
+	@GetMapping("/statistic")
     public HttpResponseResult<DegreeWrapper.DegreeStatistical> statistic(@RequestParam Long id) {
 
         return succeed(degreeService.statistic(id));