Browse Source

Merge branch 'practice_1129' into online1

yonge 3 years ago
parent
commit
1ee0797823

+ 2 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/StudentService.java

@@ -83,6 +83,8 @@ public interface StudentService extends BaseService<Integer, Student> {
      * 更新学员会员信息
      */
     void updateMemberRank(CloudTeacherOrder cloudTeacherOrder, PeriodEnum periodEnum);
+    
+    void updateMemberRank(Integer userId, PeriodEnum periodEnum, int times, Integer memberRankSettingId);
 
     /**
      * 更新服务指标

+ 43 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentServiceImpl.java

@@ -149,7 +149,7 @@ public class StudentServiceImpl extends BaseServiceImpl<Integer, Student> implem
         		throw new BizException("您已注册,请直接下载APP!");
         	}
         	userId = user.getId();
-
+        	user.setOrganId(studentPreRegistration.getOrganId());
             user.setUpdateTime(date);
             teacherDao.updateUser(user);
         }else{
@@ -179,6 +179,10 @@ public class StudentServiceImpl extends BaseServiceImpl<Integer, Student> implem
         student.setCurrentClass(studentPreRegistration.getCurrentClass());
         studentDao.insert(student);
         
+        if(user.getOrganId() == 59){
+        	updateMemberRank(userId, PeriodEnum.MONTH, 1, 1);
+        }
+        
         return true;
 	}
 
@@ -481,6 +485,44 @@ public class StudentServiceImpl extends BaseServiceImpl<Integer, Student> implem
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
+	public void updateMemberRank(Integer userId, PeriodEnum periodEnum, int times, Integer memberRankSettingId) {
+    	Student student = this.get(userId);
+        if (student == null) {
+            throw new BizException("学员信息不存在");
+        }
+        
+        Date nowDate = new Date();
+        
+        if(student.getMembershipStartTime() == null){
+            student.setMembershipStartTime(nowDate);
+        }
+        
+        if(student.getMembershipEndTime() != null && student.getMembershipEndTime().after(nowDate)){
+        	nowDate = student.getMembershipEndTime();
+        }
+        
+        switch (periodEnum) {
+		case DAY:
+            student.setMembershipEndTime(DateUtil.addDays(nowDate, times));
+			break;
+		case MONTH:
+		case QUARTERLY:
+		case YEAR_HALF:
+            student.setMembershipEndTime(DateUtil.addMonths(nowDate, times));
+			break;
+		case YEAR:
+            student.setMembershipEndTime(DateUtil.addYears(nowDate, times));
+			break;
+
+		default:
+			break;
+		}
+        student.setMemberRankSettingId(memberRankSettingId);
+        this.update(student);
+	}
+
+	@Override
     public void updateStudentServiceTag(Integer studentId,List<Integer> studentIds,Integer serviceTag) {
         studentDao.updateStudentServiceTag(studentId, studentIds, serviceTag);
     }

+ 1 - 1
mec-student/src/main/java/com/ym/mec/student/config/ResourceServerConfig.java

@@ -24,7 +24,7 @@ public class ResourceServerConfig extends ResourceServerConfigurerAdapter {
     @Override
     public void configure(HttpSecurity http) throws Exception {
         http.csrf().disable().exceptionHandling().accessDeniedHandler(baseAccessDeniedHandler).authenticationEntryPoint(baseAuthenticationEntryPoint).and()
-                .authorizeRequests().antMatchers("/wechat/*","/v2/api-docs", "/code/*", "/register/*", "/studentOrder/*", "/musicGroup/getSubjectGoodsAndInfo",
+                .authorizeRequests().antMatchers("/wechat/*","/v2/api-docs", "/code/*", "/student/registering", "/register/*", "/studentOrder/*", "/musicGroup/getSubjectGoodsAndInfo",
                 "/musicGroup/getMusicGroupStatus", "/musicGroup/getOrderStatus","/sysCouponCode/queryPage",
                 "/musicGroup/pay",
                 "/musicGroup/rePay",

+ 11 - 1
mec-student/src/main/java/com/ym/mec/student/controller/StudentController.java

@@ -12,6 +12,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import com.ym.mec.auth.api.client.SysUserFeignService;
+import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.entity.StudentPreRegistration;
 import com.ym.mec.biz.service.StudentService;
 import com.ym.mec.common.controller.BaseController;
@@ -29,7 +30,16 @@ public class StudentController extends BaseController {
 
     @ApiOperation("注册")
     @PostMapping(value = "/registering")
-    public Object preRegister(@RequestBody StudentPreRegistration studentPreRegistration) {
+    public Object registering(@RequestBody StudentPreRegistration studentPreRegistration) {
+
+    	// 判断用户是否存在
+        SysUser user = sysUserFeignService.queryUserByMobile(studentPreRegistration.getPhone());
+        if(user != null && user.getId() != null){
+        	if(user.getUserType().contains("STUDENT")){
+        		return succeed("您已注册,请直接下载APP!");
+        	}
+        }
+        
         return studentService.register(studentPreRegistration) ? succeed() : failed();
     }