Переглянути джерело

Merge branch 'feature/0406-degree' of http://git.dayaedu.com/yonge/mec into master_saas

zouxuan 2 роки тому
батько
коміт
a114c7195a
18 змінених файлів з 198 додано та 81 видалено
  1. 1 1
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/DegreeRegistrationDao.java
  2. 0 3
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/DegreeRegistrationDto.java
  3. 2 1
      mec-biz/src/main/java/com/ym/mec/biz/dal/mapper/DegreeMapper.java
  4. 12 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/page/DegreeQueryInfo.java
  5. 7 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/wrapper/DegreeNewsWrapper.java
  6. 28 7
      mec-biz/src/main/java/com/ym/mec/biz/dal/wrapper/DegreeWrapper.java
  7. 5 0
      mec-biz/src/main/java/com/ym/mec/biz/service/DegreeService.java
  8. 4 5
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/DegreeRegistrationServiceImpl.java
  9. 63 5
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/DegreeServiceImpl.java
  10. 10 0
      mec-biz/src/main/resources/config/mybatis/DegreeMapper.xml
  11. 7 1
      mec-biz/src/main/resources/config/mybatis/DegreeNewsMapper.xml
  12. 10 18
      mec-biz/src/main/resources/config/mybatis/DegreeRegistrationMapper.xml
  13. 4 0
      mec-client-api/src/main/java/com/ym/mec/task/TaskRemoteService.java
  14. 5 0
      mec-client-api/src/main/java/com/ym/mec/task/fallback/TaskRemoteServiceFallback.java
  15. 10 39
      mec-student/src/main/java/com/ym/mec/student/controller/DegreeController.java
  16. 2 1
      mec-student/src/main/java/com/ym/mec/student/controller/StudentOrderController.java
  17. 19 0
      mec-task/src/main/java/com/ym/mec/task/jobs/DegreeStatusChangeTask.java
  18. 9 0
      mec-web/src/main/java/com/ym/mec/web/controller/TaskController.java

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

@@ -24,7 +24,7 @@ public interface DegreeRegistrationDao extends BaseDAO<Integer, DegreeRegistrati
 
     DegreeRegistration getUserLevelDegrees(@Param("userId") Integer userId,
                                                  @Param("degreeId") Long degreeId,
-                                                 @Param("degreeType") DegreeTypeEnum degreeType,
+                                                 @Param("type") DegreeTypeEnum type,
                                                  @Param("levels") String levels,
                                                  @Param("subjectId") Integer subjectId);
 

+ 0 - 3
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/DegreeRegistrationDto.java

@@ -9,9 +9,6 @@ import java.util.Date;
 
 @Data
 public class DegreeRegistrationDto{
-    @ApiModelProperty(value = "考级编号",required = false)
-    private Long degreeId;
-
     @ApiModelProperty(value = "考试级别",required = false)
     private String level;
 

+ 2 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/mapper/DegreeMapper.java

@@ -23,5 +23,6 @@ public interface DegreeMapper extends BaseMapper<Degree> {
 	 * @return List<DegreeWrapper.Degree>
 	 */
 	List<Degree> selectPage(@Param("page") IPage<Degree> page, @Param("param") DegreeWrapper.DegreeQuery param);
-	
+
+    void degreeStatusChange();
 }

+ 12 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/page/DegreeQueryInfo.java

@@ -143,6 +143,18 @@ public class DegreeQueryInfo extends QueryInfo {
     @ApiModelProperty(value = "0-未支付 1-支付中 2-已支付 2-已退费",required = false)
     private Integer status;
 
+
+    @ApiModelProperty(value = "考级管理ID",required = false)
+    private Integer degreeId;
+
+    public Integer getDegreeId() {
+        return degreeId;
+    }
+
+    public void setDegreeId(Integer degreeId) {
+        this.degreeId = degreeId;
+    }
+
     public Integer getSubjectId() {
         return subjectId;
     }

+ 7 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/wrapper/DegreeNewsWrapper.java

@@ -36,6 +36,7 @@ public class DegreeNewsWrapper {
         @ApiModelProperty("关键字匹配")
 		private String keyword;
 
+        @ApiModelProperty("用户所在机构")
         private Integer organId;
 
         @ApiModelProperty("用户所在分部")
@@ -47,6 +48,12 @@ public class DegreeNewsWrapper {
         @ApiModelProperty("咨询类型")
         private String type;
 
+        @ApiModelProperty("用户机构ID")
+        private Integer tenantId;
+
+        @ApiModelProperty(value = "排序方式", hidden = true)
+        private Boolean sortedTime;
+
         public String getKeyword() {
             return Optional.ofNullable(keyword).filter(StringUtils::isNotBlank).orElse(null);
         }

+ 28 - 7
mec-biz/src/main/java/com/ym/mec/biz/dal/wrapper/DegreeWrapper.java

@@ -11,6 +11,8 @@ import lombok.Builder;
 import lombok.Data;
 import lombok.NoArgsConstructor;
 import org.apache.commons.lang3.StringUtils;
+import org.joda.time.DateTime;
+import org.joda.time.Days;
 
 import javax.validation.constraints.NotBlank;
 import javax.validation.constraints.NotNull;
@@ -18,6 +20,7 @@ import java.io.Serializable;
 import java.math.BigDecimal;
 import java.util.Date;
 import java.util.List;
+import java.util.Objects;
 import java.util.Optional;
 
 /**
@@ -28,20 +31,20 @@ import java.util.Optional;
 public class DegreeWrapper {
 
     @Data
-	@Builder
+    @Builder
     @NoArgsConstructor
     @AllArgsConstructor
     @ApiModel(" DegreeQuery-考级信息")
     public static class DegreeQuery implements QueryInfo {
-    
-    	@ApiModelProperty("当前页")
+
+        @ApiModelProperty("当前页")
         private Integer page;
         
         @ApiModelProperty("分页行数")
         private Integer rows;
         
         @ApiModelProperty("考级名称/编号")
-		private String keyword;
+        private String keyword;
 
 
         @ApiModelProperty("开始时间")
@@ -101,7 +104,7 @@ public class DegreeWrapper {
     }
 
     @Data
-	@ApiModel(" Degree-考级信息")
+    @ApiModel(" Degree-考级信息")
     public static class Degree {
 
 
@@ -131,7 +134,7 @@ public class DegreeWrapper {
         private Date endTime;
 
         @ApiModelProperty(value = "登记时间",required = true)
-        @NotNull(message = "登记时间不能为空")
+//        @NotNull(message = "登记时间不能为空")
         private Date registrationTime;
 
         @ApiModelProperty("报名人次")
@@ -146,6 +149,8 @@ public class DegreeWrapper {
         @ApiModelProperty("报名状态 NOT_START:未开始,START:报名中,END:报名结束")
         private EDegreeStatus status;
 
+        @ApiModelProperty("倒计时开始天数")
+        private Integer startDays;
 
         public String jsonString() {
             return JSON.toJSONString(this);
@@ -154,7 +159,17 @@ public class DegreeWrapper {
         public static Degree from(String json) {
             return JSON.parseObject(json, Degree.class);
         }
-	}
+
+        public Integer getStartDays() {
+            if (Objects.nonNull(getStartTime()) && EDegreeStatus.NOT_START == getStatus()) {
+
+                DateTime now = DateTime.now().withHourOfDay(0).withMinuteOfHour(0).withSecondOfMinute(0).withMillisOfSecond(0);
+                // 计算与当前时间相差天数
+                return Days.daysBetween(now, new DateTime(getStartTime())).getDays();
+            }
+            return Optional.ofNullable(startDays).orElse(0);
+        }
+    }
 
     @Data
     @ApiModel(" DegreeStatistical-考级信息统计")
@@ -166,6 +181,9 @@ public class DegreeWrapper {
         @ApiModelProperty("报名人次")
         private Integer registerTotal;
 
+        @ApiModelProperty("报名人数")
+        private Integer registerNum;
+
         @ApiModelProperty("购课人次")
         private Integer purchaseCourse;
 
@@ -213,6 +231,9 @@ public class DegreeWrapper {
         @ApiModelProperty("报名状态 NOT_START:未开始,START:报名中,END:报名结束")
         private EDegreeStatus status;
 
+        @ApiModelProperty("考级简章ID")
+        private Long examinationBriefId;
+
         @ApiModelProperty("考级城市分部")
         private List<DegreeCity> degreeCities;
 

+ 5 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/DegreeService.java

@@ -52,4 +52,9 @@ public interface DegreeService extends IService<Degree>  {
      * @return DegreeWrapper.StudentDegreeInfo
      */
     DegreeWrapper.StudentDegreeInfo studentDegreeInfoById(Long id);
+
+    /**
+     * 考级状态变更
+     */
+    void degreeStatusChange();
 }

+ 4 - 5
mec-biz/src/main/java/com/ym/mec/biz/service/impl/DegreeRegistrationServiceImpl.java

@@ -94,7 +94,7 @@ public class DegreeRegistrationServiceImpl extends BaseServiceImpl<Integer, Degr
             String level = registrationDto.getLevel();
             degree.setOrderNo(orderNo);
             degree.setLevel(level);
-            degree.setDegreeId(registrationDto.getDegreeId());
+            degree.setDegreeId(degreeRegistration.getDegreeId());
             degree.setTheoryCert(registrationDto.getTheoryCert());
             degree.setType(registrationDto.getType());
             degree.setStatus(1);
@@ -301,7 +301,7 @@ public class DegreeRegistrationServiceImpl extends BaseServiceImpl<Integer, Degr
         //是否对分部开放
         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())){
+            if(!studentIdList.contains(degreeRegistration.getOrganId())){
                 return BaseController.failed("该分部暂未开放此活动");
             }
         }
@@ -316,11 +316,10 @@ public class DegreeRegistrationServiceImpl extends BaseServiceImpl<Integer, Degr
             return BaseController.failed(HttpStatus.CREATED,"请选择考级项目");
         }
         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)){
             String levels = collect.stream().map(e -> e.getLevel()).collect(Collectors.joining(","));
             DegreeRegistration userLevelDegree = degreeRegistrationDao.getUserLevelDegrees(degreeRegistration.getUserId(),
-                    degreeId,DegreeTypeEnum.GRADE,levels,degreeRegistration.getSubjectId());
+                    degree.getId(),DegreeTypeEnum.GRADE,levels,degreeRegistration.getSubjectId());
             if(Objects.nonNull(userLevelDegree)){
                 return BaseController.failed(HttpStatus.CREATED, "您选择的 " + userLevelDegree.getLevel() +  " 乐器考级已报名,请勿重复选择");
             }
@@ -329,7 +328,7 @@ public class DegreeRegistrationServiceImpl extends BaseServiceImpl<Integer, Degr
         if(!CollectionUtils.isEmpty(collect)){
             String levels = collect.stream().map(e -> e.getLevel()).collect(Collectors.joining(","));
             DegreeRegistration userLevelDegree = degreeRegistrationDao.getUserLevelDegrees(degreeRegistration.getUserId(),
-                    degreeId,DegreeTypeEnum.THEORY,levels,degreeRegistration.getSubjectId());
+                    degree.getId(),DegreeTypeEnum.THEORY,levels,degreeRegistration.getSubjectId());
             if(Objects.nonNull(userLevelDegree)){
                 return BaseController.failed(HttpStatus.CREATED, "您选择的 " + userLevelDegree.getLevel() +  " 乐理考级已报名,请勿重复选择");
             }

+ 63 - 5
mec-biz/src/main/java/com/ym/mec/biz/service/impl/DegreeServiceImpl.java

@@ -3,12 +3,17 @@ package com.ym.mec.biz.service.impl;
 import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.microsvc.toolkit.common.response.paging.QueryInfo;
 import com.ym.mec.biz.dal.dao.DegreeRegistrationDao;
 import com.ym.mec.biz.dal.dao.OrganizationDao;
 import com.ym.mec.biz.dal.dao.StudentPaymentOrderDetailDao;
 import com.ym.mec.biz.dal.entity.*;
+import com.ym.mec.biz.dal.enums.DegreeNewsTypeEnum;
 import com.ym.mec.biz.dal.enums.EDegreeStatus;
 import com.ym.mec.biz.dal.enums.OrderDetailTypeEnum;
+import com.ym.mec.biz.dal.vo.DegreeNewsVo;
+import com.ym.mec.biz.dal.wrapper.DegreeNewsWrapper;
+import com.ym.mec.biz.service.DegreeNewsService;
 import com.ym.mec.biz.service.OrganizationService;
 import com.ym.mec.biz.service.StudentPaymentOrderService;
 import com.ym.mec.common.exception.BizException;
@@ -53,12 +58,15 @@ public class DegreeServiceImpl extends ServiceImpl<DegreeMapper, Degree> impleme
     @Autowired
     private OrganizationDao organizationDao;
 
-	/**
+    @Autowired
+    private DegreeNewsService degreeNewsService;
+
+    /**
      * 查询详情
      * @param id 详情ID
      * @return Degree
      */
-	@Override
+    @Override
     public Degree detail(Long id) {
         
         return baseMapper.selectById(id);
@@ -110,7 +118,7 @@ public class DegreeServiceImpl extends ServiceImpl<DegreeMapper, Degree> impleme
         return result.setRecords(degrees);
 
     }
-	
+
     /**
      * 添加
      * @param degree DegreeWrapper.Degree
@@ -121,12 +129,34 @@ public class DegreeServiceImpl extends ServiceImpl<DegreeMapper, Degree> impleme
 
         Integer tenantId = TenantContextHolder.getTenantId();
         degree.setTenantId(tenantId);
+
+        // 判断考级时间冲突
+        checkTime(degree);
+
         updateDegreeStatus(degree);
 
         
         return this.save(JSON.parseObject(degree.jsonString(), Degree.class));
     }
 
+    private void checkTime(DegreeWrapper.Degree degree) {
+        List<Degree> list = this.lambdaQuery()
+                .eq(Degree::getTenantId, degree.getTenantId())
+                .le(Degree::getStartTime, degree.getEndTime())
+                .ge(Degree::getEndTime, degree.getStartTime())
+                .list();
+
+        if (CollectionUtils.isEmpty(list)) {
+            return;
+        }
+
+        if (list.size()  == 1) {
+            Degree degree1 = list.get(0);
+            if (degree1.getId().equals(degree.getId())) return;
+        }
+        throw new BizException("考级时间冲突");
+    }
+
     /**
      * 根据时间设置状态
      * @param degree DegreeWrapper.Degree
@@ -149,6 +179,13 @@ public class DegreeServiceImpl extends ServiceImpl<DegreeMapper, Degree> impleme
      */
     @Override
     public Boolean update(DegreeWrapper.Degree degree){
+
+        Integer tenantId = TenantContextHolder.getTenantId();
+        degree.setTenantId(tenantId);
+
+        // 判断考级时间冲突
+        checkTime(degree);
+
         updateDegreeStatus(degree);
 
         return this.updateById(JSON.parseObject(degree.jsonString(), Degree.class));       
@@ -167,6 +204,7 @@ public class DegreeServiceImpl extends ServiceImpl<DegreeMapper, Degree> impleme
         statistical.setActualAmount(BigDecimal.ZERO);
         statistical.setDegreeIncome(BigDecimal.ZERO);
         statistical.setCourseIncome(BigDecimal.ZERO);
+        statistical.setRegisterNum(degree.getRegisterNum());
 
         // 查询考级报名的订单
         List<DegreeRegistration> registrations = degreeRegistrationDao.selectByDegreeId(id);
@@ -226,11 +264,11 @@ public class DegreeServiceImpl extends ServiceImpl<DegreeMapper, Degree> impleme
             throw new BizException("考级信息不存在");
         }
 
-        Date currentDate = DateTime.now().toDate();
         // 考级时间不匹配
+        /*Date currentDate = DateTime.now().toDate();
         if (degree.getEndTime().before(currentDate)) {
             throw new BizException("考级报名已经结束");
-        }
+        }*/
 
         // 考级分部信息
         DegreeWrapper.StudentDegreeInfo wrapper = DegreeWrapper.StudentDegreeInfo.from(JSON.toJSONString(degree));
@@ -250,6 +288,26 @@ public class DegreeServiceImpl extends ServiceImpl<DegreeMapper, Degree> impleme
             }
         }
 
+        // 考级最新简章消息ID
+        DegreeNewsWrapper.DegreeNewsQuery newsQuery = DegreeNewsWrapper.DegreeNewsQuery
+                .builder()
+                .page(1)
+                .rows(1)
+                .status(true)
+                .tenantId(wrapper.getTenantId())
+                .type(DegreeNewsTypeEnum.GRADE_EXAMINATION_BRIEF.getCode())
+                .sortedTime(true)
+                .build();
+        List<DegreeNewsVo> records = degreeNewsService.selectPage(QueryInfo.getPage(newsQuery), newsQuery).getRecords();
+        if (org.apache.commons.collections.CollectionUtils.isNotEmpty(records)) {
+            wrapper.setExaminationBriefId(records.get(0).getId());
+        }
+
         return wrapper;
     }
+
+    @Override
+    public void degreeStatusChange() {
+        this.baseMapper.degreeStatusChange();
+    }
 }

+ 10 - 0
mec-biz/src/main/resources/config/mybatis/DegreeMapper.xml

@@ -28,4 +28,14 @@
         </where>
 	</select>
 
+    <update id="degreeStatusChange">
+        UPDATE degree SET status_ =
+            case
+                when start_time_ &lt; now() and end_time_ &gt; now() then 'START'
+                when end_time_ &lt;= now() then 'END'
+                else 'NOT_START'
+            end
+
+        WHERE status_ != 'END' and start_time_ &lt; now()
+    </update>
 </mapper>

+ 7 - 1
mec-biz/src/main/resources/config/mybatis/DegreeNewsMapper.xml

@@ -15,6 +15,9 @@
 			<if test="param.status != null">
 				AND dn.status_ = #{param.status}
 			</if>
+		    <if test="param.tenantId != null">
+				AND dn.tenant_id_ = #{param.tenantId}
+			</if>
 			<if test="param.organId != null">
 				AND (FIND_IN_SET(#{param.organId},dn.organ_ids_) OR dn.organ_ids_ IS NULL OR dn.organ_ids_ = '')
 			</if>
@@ -23,7 +26,10 @@
 			</if>
 		</where>
 		group by dn.id_
-		ORDER BY dn.id_ DESC
+		<choose>
+			<when test="param.sortedTime != null">ORDER BY dn.update_time_ DESC</when>
+			<otherwise>ORDER BY dn.id_ DESC</otherwise>
+		</choose>
 	</select>
     
 </mapper>

+ 10 - 18
mec-biz/src/main/resources/config/mybatis/DegreeRegistrationMapper.xml

@@ -88,7 +88,7 @@
             <if test="mobile != null">
                 AND mobile_= #{mobile}
             </if>
-            <if test="level != null">
+            <if test="level != null and level != ''">
                 AND level_= #{level}
             </if>
             <if test="startTime != null">
@@ -100,6 +100,9 @@
             <if test="search != null and search != ''">
                 and (user_id_ like concat('%',#{search},'%') or name_ like CONCAT('%',#{search},'%') or mobile_ like CONCAT('%',#{search},'%') )
             </if>
+            <if test="degreeId != null ">
+                and degree_id_ = #{degreeId}
+            </if>
         </where>
     </sql>
 
@@ -140,22 +143,19 @@
         insert into degree_registration (user_id_,degree_id_,organ_id_,order_no_, name_, gender_,
         idcard_, city_, school_,
         subject_id_,level_, theory_cert_,mobile_,
-        money_, memo_, create_time_,
-        update_time_, status_,certificate_type_,tenant_id_,type_)
+        money_, memo_,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},
         #{subjectId},#{level,jdbcType=VARCHAR},
         #{theoryCert,jdbcType=VARCHAR},#{mobile,jdbcType=VARCHAR},#{money,jdbcType=DECIMAL}, #{memo,jdbcType=VARCHAR},
-        #{createTime}, #{updateTime}, #{status,jdbcType=TINYINT},
-                #{certificateType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
+        #{status,jdbcType=TINYINT},#{certificateType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
                 #{tenantId},#{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler})
     </insert>
     <insert id="batchInsert">
         INSERT INTO degree_registration (user_id_,degree_id_,organ_id_,order_no_, name_, gender_,
         idcard_, city_, school_,
         subject_id_,level_, theory_cert_,mobile_,
-        money_, memo_, create_time_,
-        update_time_, status_,certificate_type_,tenant_id_,type_)
+        money_, memo_,status_,certificate_type_,tenant_id_,type_)
         VALUE
         <foreach collection="degreeRegistrationList" separator="," item="degreeRegistration">
             (#{degreeRegistration.userId},#{degreeRegistration.degreeId,jdbcType=INTEGER},#{degreeRegistration.organId,jdbcType=INTEGER},
@@ -163,7 +163,7 @@
             #{degreeRegistration.idcard,jdbcType=VARCHAR}, #{degreeRegistration.city,jdbcType=VARCHAR}, #{degreeRegistration.school,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.status,jdbcType=TINYINT},
             #{degreeRegistration.certificateType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
             #{degreeRegistration.tenantId},#{degreeRegistration.type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler})
         </foreach>
@@ -220,16 +220,12 @@
             <if test="memo != null">
                 memo_ = #{memo,jdbcType=VARCHAR},
             </if>
-            <if test="createTime != null">
-                create_time_ = #{createTime},
-            </if>
             <if test="status != null">
                 status_ = #{status,jdbcType=INTEGER},
             </if>
             <if test="certificateType != null">
                 certificate_type_ = #{certificateType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
             </if>
-                update_time_ = NOW()
         </set>
         where id_ = #{id,jdbcType=INTEGER} and tenant_id_ = #{tenantId}
     </update>
@@ -286,16 +282,12 @@
                 <if test="degree.memo != null">
                     memo_ = #{degree.memo,jdbcType=VARCHAR},
                 </if>
-                <if test="degree.createTime != null">
-                    create_time_ = #{degree.createTime},
-                </if>
                 <if test="degree.status != null">
                     status_ = #{degree.status,jdbcType=INTEGER},
                 </if>
 	            <if test="degree.certificateType != null">
 	                certificate_type_ = #{degree.certificateType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
 	            </if>
-                    update_time_ = NOW()
             </set>
             where id_ = #{degree.id,jdbcType=INTEGER} and tenant_id_ = #{degree.tenantId}
         </foreach>
@@ -334,8 +326,8 @@
 
     <select id="getUserLevelDegrees" resultMap="DegreeRegistration">
         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
+        where user_id_ = #{userId} and degree_id_ = #{degreeId} and type_ = #{type}
+          AND FIND_IN_SET(level_,#{levels}) AND subject_id_ = #{subjectId} AND status_ = 2 LIMIT 1
     </select>
     <select id="getLockByOrderId" resultMap="DegreeRegistration">
         SELECT * FROM degree_registration WHERE order_no_ = #{orderNo} FOR UPDATE

+ 4 - 0
mec-client-api/src/main/java/com/ym/mec/task/TaskRemoteService.java

@@ -299,4 +299,8 @@ public interface TaskRemoteService {
 
     @GetMapping("task/teacherCloudCourseReport")
     void teacherCloudCourseReport();
+
+
+    @GetMapping("task/degreeStatusChange")
+    void degreeStatusChange() ;
 }

+ 5 - 0
mec-client-api/src/main/java/com/ym/mec/task/fallback/TaskRemoteServiceFallback.java

@@ -349,4 +349,9 @@ public class TaskRemoteServiceFallback implements TaskRemoteService {
     public void teacherCloudCourseReport() {
 
     }
+
+    @Override
+    public void degreeStatusChange() {
+        logger.error("考级状态变更失败");
+    }
 }

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

@@ -67,29 +67,19 @@ public class DegreeController extends BaseController {
     @ApiOperation(value = "考级报名支付")
     @PostMapping("/pay")
     public HttpResponseResult pay(@RequestBody DegreeRegistrationActivityDto degreeRegistration) throws Exception {
+        if(degreeRegistration.getOrganId() == null){
+            return failed("该分部暂未开放此活动");
+        }
         SysUser user = sysUserFeignService.queryUserInfo();
         if(Objects.isNull(user)){
             return failed(HttpStatus.FORBIDDEN,"请登录");
         }
+        TenantContextHolder.setTenantId(user.getTenantId());
         degreeRegistration.setUserId(user.getId());
-        if(user.getOrganId() == null || user.getOrganId() == 43){
-            user.setUsername(degreeRegistration.getName());
-            user.setIdCardNo(degreeRegistration.getIdcard());
-            Organization organization = organizationDao.findByName(degreeRegistration.getCity());
-            if(Objects.nonNull(organization)){
-                user.setOrganId(organization.getId());
-            }
-            teacherDao.updateUser(user);
-        }
-        degreeRegistration.setOrganId(user.getOrganId());
-        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();
@@ -97,35 +87,16 @@ public class DegreeController extends BaseController {
 	            throw new BizException("身份证号不正确,请核对");
 	        }
         }
+        if(user.getOrganId() == null || user.getOrganId() == 43){
+            user.setUsername(degreeRegistration.getName());
+            user.setIdCardNo(degreeRegistration.getIdcard());
+            user.setOrganId(degreeRegistration.getOrganId());
+            teacherDao.updateUser(user);
+        }
         HttpResponseResult pay = degreeRegistrationService.pay(degreeRegistration);
         TenantContextHolder.clearTenantId();
         return pay;
     }
-/*
-    @ApiOperation(value = "考级报名支付")
-    @PostMapping("/theoryPay")
-    public HttpResponseResult theoryPay(@RequestBody DegreeRegistrationActivityDto degreeRegistration) throws Exception {
-        SysUser user = sysUserFeignService.queryUserInfo();
-        if(Objects.isNull(user)){
-            return failed(HttpStatus.FORBIDDEN,"请登录");
-        }
-        degreeRegistration.setUserId(user.getId());
-
-        if(Objects.nonNull(degreeRegistration.getTheoryLevel())){
-            IdcardValidator idcardValidator = new IdcardValidator();
-            if (!idcardValidator.isValidatedAllIdcard(degreeRegistration.getIdcard())) {
-                throw new BizException("身份证号不正确,请核对");
-            }
-        }else{
-            degreeRegistration.setOrganId(user.getOrganId());
-        }
-
-        if(Objects.isNull(degreeRegistration.getOrganId()) || degreeRegistration.getOrganId() == 4){
-            return failed("该分部暂未开放此活动");
-        }
-
-        return degreeRegistrationService.theoryPay(degreeRegistration);
-    }*/
 
     @ApiOperation(value = "考级报名检查")
     @PostMapping("/check")

+ 2 - 1
mec-student/src/main/java/com/ym/mec/student/controller/StudentOrderController.java

@@ -314,7 +314,8 @@ public class StudentOrderController extends BaseController {
         } else if (orderByOrderNo.getGroupType().equals(GroupType.REPLACEMENT)) {
             orderDetail.put("detail", replacementInstrumentActivityDao.getInfo(Integer.parseInt(orderByOrderNo.getMusicGroupId())));
         } else if (orderByOrderNo.getGroupType().equals(GroupType.DEGREE)) {
-            orderDetail.put("detail", childrenDayDegreeDetailDao.getByOrderId(orderByOrderNo.getId()));
+//            orderDetail.put("detail", childrenDayDegreeDetailDao.getByOrderId(orderByOrderNo.getId()));
+            orderDetail.put("detail", degreeRegistrationDao.findByByOrderId(orderByOrderNo.getOrderNo()));
         } else if (orderByOrderNo.getGroupType().equals(GroupType.ACTIVITY)) {
             List<VipGroupActivity> vipGroupActivities = vipGroupActivityService.getDao().queryByIds(orderByOrderNo.getActivityId());
             if(CollectionUtils.isNotEmpty(vipGroupActivities)){

+ 19 - 0
mec-task/src/main/java/com/ym/mec/task/jobs/DegreeStatusChangeTask.java

@@ -0,0 +1,19 @@
+package com.ym.mec.task.jobs;
+
+import com.ym.mec.task.TaskRemoteService;
+import com.ym.mec.task.core.BaseTask;
+import com.ym.mec.task.core.TaskException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class DegreeStatusChangeTask extends BaseTask {
+
+	@Autowired
+	private TaskRemoteService taskRemoteService;
+
+	@Override
+	public void execute() throws TaskException {
+		taskRemoteService.degreeStatusChange();
+	}
+}

+ 9 - 0
mec-web/src/main/java/com/ym/mec/web/controller/TaskController.java

@@ -129,6 +129,9 @@ public class TaskController extends BaseController {
     @Autowired
     private TeacherCloudCourseReportService teacherCloudCourseReportService;
 
+    @Autowired
+    private DegreeService degreeService;
+
 	@GetMapping(value = "/initSysMusicCompareDayData")
 	public void initSysMusicCompareDayData(){
 		sysMusicCompareRecordService.initSysMusicCompareDayData();
@@ -642,4 +645,10 @@ public class TaskController extends BaseController {
 		return succeed();
 	}
 
+    @ApiOperation("考级状态变更 - 1分钟一次")
+    @GetMapping("/degreeStatusChange")
+    public Object degreeStatusChange() {
+        degreeService.degreeStatusChange();
+        return succeed();
+    }
 }