Sfoglia il codice sorgente

Merge branch 'master' of http://git.dayaedu.com/yonge/mec

zouxuan 5 anni fa
parent
commit
316989e662

+ 7 - 8
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentPaymentOrderDao.java

@@ -1,12 +1,5 @@
 package com.ym.mec.biz.dal.dao;
 
-import java.math.BigDecimal;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.ibatis.annotations.Param;
-
 import com.ym.mec.biz.dal.dto.SporadicChargeInfoDto;
 import com.ym.mec.biz.dal.dto.StudentPaymentOrderExportDto;
 import com.ym.mec.biz.dal.dto.UserGoodsDto;
@@ -17,6 +10,12 @@ 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.common.dal.BaseDAO;
+import org.apache.ibatis.annotations.Param;
+
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
 
 public interface StudentPaymentOrderDao extends BaseDAO<Long, StudentPaymentOrder> {
 
@@ -57,7 +56,7 @@ public interface StudentPaymentOrderDao extends BaseDAO<Long, StudentPaymentOrde
      * @Date: 2019/10/3
      * 根据学生vip课获取非失败缴费订单
      */
-    StudentPaymentOrder findNotFailedOrderByStudentVipGroup(@Param("vipGroupId") Long vipGroupId,
+    List<StudentPaymentOrder> findNotFailedOrderByStudentVipGroup(@Param("vipGroupId") Long vipGroupId,
                                                             @Param("userId") Integer userId);
 
     /**

+ 11 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/VipGroupBuyParamsDto.java

@@ -20,6 +20,17 @@ public class VipGroupBuyParamsDto {
     @ApiModelProperty(value = "是否使用账户余额支付")
     private boolean isUseBalancePayment;
 
+    @ApiModelProperty(value = "是否重新支付")
+    private boolean isRepeatPay;
+
+    public boolean isRepeatPay() {
+        return isRepeatPay;
+    }
+
+    public void setRepeatPay(boolean repeatPay) {
+        isRepeatPay = repeatPay;
+    }
+
     public boolean isUseBalancePayment() {
         return isUseBalancePayment;
     }

+ 10 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/SchoolService.java

@@ -17,6 +17,16 @@ public interface SchoolService extends BaseService<Integer, School> {
     List<School> queryByOrganId(String organId);
 
     /**
+     * @describe 根据教师编号删除对应教学点
+     * @author Joburgess
+     * @date 2020/1/3
+     * @param schoolId: 教学点编号
+     * @param userId: 用户编号
+     * @return void
+     */
+    void deleteByTeacherAndId(Integer schoolId,Integer userId);
+
+    /**
      * @describe 获取教师vip课教学点
      * @author Joburgess
      * @date 2019/10/19

+ 1 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/VipGroupService.java

@@ -186,7 +186,7 @@ public interface VipGroupService extends BaseService<Long, VipGroup> {
      * @param vipGroupId:
      * @return void
      */
-    void enableBuyVipGroup(Integer vipGroupId);
+    void enableBuyVipGroup(Integer vipGroupId, Integer userId);
 
     /**
      * @Author: Joburgess

+ 2 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ClassGroupServiceImpl.java

@@ -2272,10 +2272,10 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
                         if(!CollectionUtils.isEmpty(classGroupTeachers)){
                             List<String> userNames = classGroupTeachers.stream().map(ClassGroupTeacherMapDto::getUserName).collect(Collectors.toList());
                             if(teachType.equals(TeachTypeEnum.BISHOP)){
-                                result.setBishopTeacherNames(Arrays.toString(userNames.toArray()));
+                                result.setBishopTeacherNames(StringUtils.join(userNames.toArray(),","));
                             }
                             if(teachType.equals(TeachTypeEnum.TEACHING)){
-                                result.setTeachingTeacherNames(Arrays.toString(userNames.toArray()));
+                                result.setTeachingTeacherNames(StringUtils.join(userNames.toArray(),","));
                             }
                         }
                     }

+ 7 - 6
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderServiceImpl.java

@@ -1,11 +1,11 @@
 package com.ym.mec.biz.service.impl;
 
-import java.io.Serializable;
-import java.util.*;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
 import java.util.stream.Collectors;
 
-import com.ym.mec.biz.dal.entity.MusicGroupStudentFee;
-import io.swagger.models.auth.In;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -13,6 +13,7 @@ import org.springframework.transaction.annotation.Transactional;
 
 import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDao;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
+import com.ym.mec.biz.dal.entity.MusicGroupStudentFee;
 import com.ym.mec.biz.service.MusicGroupPaymentCalenderService;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
@@ -47,8 +48,8 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 			String paymentPeriodList = fee.getPaymentPeriodList();
 			if(StringUtils.isEmpty(paymentPeriodList)){
 				return null;
-			}else {
-				months = new ArrayList(Arrays.asList(paymentPeriodList.split(",")));
+			} else {
+				months = Arrays.asList(paymentPeriodList.split(",")).stream().map(x -> Integer.parseInt(x)).collect(Collectors.toList());
 				Collections.sort(months);
 			}
 		}else {

+ 21 - 9
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SchoolServiceImpl.java

@@ -1,23 +1,24 @@
 package com.ym.mec.biz.service.impl;
 
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.stream.Collectors;
-
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
 import com.ym.mec.biz.dal.dao.OrganizationDao;
 import com.ym.mec.biz.dal.dao.SchoolDao;
 import com.ym.mec.biz.dal.entity.School;
 import com.ym.mec.biz.dal.page.SchoolQueryInfo;
 import com.ym.mec.biz.service.SchoolService;
 import com.ym.mec.common.dal.BaseDAO;
+import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
 import com.ym.mec.util.collection.MapUtil;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.stream.Collectors;
 
 @Service
 public class SchoolServiceImpl extends BaseServiceImpl<Integer, School>  implements SchoolService {
@@ -38,6 +39,17 @@ public class SchoolServiceImpl extends BaseServiceImpl<Integer, School>  impleme
 	}
 
 	@Override
+	public void deleteByTeacherAndId(Integer schoolId, Integer userId) {
+		School school = schoolDao.get(schoolId);
+		if(Objects.isNull(school)){
+			throw new BizException("此教学点不存在");
+		}
+		if(Objects.nonNull(school.getUserId())&&school.getUserId().equals(userId)){
+			schoolDao.delete(schoolId);
+		}
+	}
+
+	@Override
 	public List<School> findVipSchoolByTeacher(Integer teacherId,String organId,Integer isDefault) {
 		return schoolDao.findVipSchoolByUserId(teacherId,organId,isDefault);
 	}

+ 16 - 10
mec-biz/src/main/java/com/ym/mec/biz/service/impl/VipGroupServiceImpl.java

@@ -894,11 +894,17 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
     }
 
 	@Override
-	public void enableBuyVipGroup(Integer vipGroupId) {
+	public void enableBuyVipGroup(Integer vipGroupId, Integer userId) {
 		if (Objects.isNull(vipGroupId)){
 			throw new BizException("请指定VIP课");
 		}
 		VipGroup vipGroup = get(vipGroupId.longValue());
+		if(Objects.nonNull(vipGroup.getStudentIdList())){
+			Set<Integer> userIds = Arrays.asList(vipGroup.getStudentIdList().split(",")).stream().mapToInt(Integer::parseInt).boxed().collect(Collectors.toSet());
+			if(!userIds.contains(userId)){
+				throw new BizException("您无法购买此课程");
+			}
+		}
 		List<CourseSchedule> courseSchedules = JSON.parseArray(vipGroup.getCourseSchedulesJson(),CourseSchedule.class);
 		courseScheduleService.checkNewCourseSchedules(courseSchedules,false);
 	}
@@ -982,7 +988,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 
 	@Transactional(rollbackFor = Exception.class)
 	@Override
-	public Map buyVipGroup(VipGroupBuyParamsDto vipGroupBuyParams) throws Exception {
+	public Map buyVipGroup(VipGroupBuyParamsDto vipGroupBuyParams) {
 		SysUser user = sysUserFeignService.queryUserInfo();
 		if(user == null){
 			throw new BizException("用户信息获取失败");
@@ -1009,19 +1015,17 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 			}
 		}
 
-		StudentPaymentOrder oldOrder = studentPaymentOrderDao.findNotFailedOrderByStudentVipGroup(vipGroupBuyParams.getVipGroupId(),
+		List<StudentPaymentOrder> oldOrders = studentPaymentOrderDao.findNotFailedOrderByStudentVipGroup(vipGroupBuyParams.getVipGroupId(),
 				user.getId());
+		Map<DealStatusEnum, Long> statusCountMap = oldOrders.stream().collect(Collectors.groupingBy(StudentPaymentOrder::getStatus, Collectors.counting()));
 
-		if(Objects.nonNull(oldOrder)&&oldOrder.getStatus().equals(DealStatusEnum.SUCCESS)){
+		if(Objects.nonNull(statusCountMap.get(DealStatusEnum.SUCCESS))&&statusCountMap.get(DealStatusEnum.SUCCESS)>0){
 			if("36".equals(user.getOrganId())){
 				throw new BizException("您已预约过此课程");
 			}
 			throw new BizException("您已购买过此课程");
-		}else if(Objects.nonNull(oldOrder)&&oldOrder.getStatus().equals(DealStatusEnum.ING)){
-			if("36".equals(user.getOrganId())){
-				throw new BizException("您已预约过此课程,请等待处理结果");
-			}
-			throw new BizException("您有处理中的订单,请等待处理结果");
+		}else if(Objects.nonNull(statusCountMap.get(DealStatusEnum.ING))&&statusCountMap.get(DealStatusEnum.ING)>0){
+
 		}else{
 			if(classGroup.getStudentNum()>=classGroup.getExpectStudentNum()){
 				throw new BizException("该课程人数已达上限");
@@ -1170,7 +1174,9 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 		}
 
 		try {
-			updateVipGroupStudentNumAndStatus(vipGroupId, classGroup,0,true);
+			if(classGroup.getDelFlag()==1){
+				updateVipGroupStudentNumAndStatus(vipGroupId, classGroup,0,true);
+			}
 		} catch (Exception e) {
 			LOGGER.error("小课[{}]开课失败:{}",vipGroupId,e.getCause());
 		}

+ 2 - 2
mec-biz/src/main/resources/config/mybatis/CourseScheduleMapper.xml

@@ -1272,7 +1272,7 @@
         SELECT DISTINCT cgsm.music_group_id_ FROM class_group_student_mapper cgsm
         LEFT JOIN music_group mg ON mg.id_ = cgsm.music_group_id_ AND cgsm.group_type_ = 'MUSIC'
         LEFT JOIN vip_group vg ON vg.id_ = cgsm.music_group_id_ AND cgsm.group_type_ = 'VIP'
-        WHERE cgsm.user_id_ = #{userId} AND cgsm.status_ != 'QUIT' AND (mg.status_ = 'PROGRESS' OR vg.status_ = 2 OR vg.status_=5)
+        WHERE cgsm.user_id_ = #{userId} AND cgsm.status_ != 'QUIT' AND (mg.status_ = 'PROGRESS' OR vg.status_ = 2 OR vg.status_=5 OR vg.status_=1)
         ORDER BY cgsm.music_group_id_
         <include refid="global.limit"/>
     </select>
@@ -1288,7 +1288,7 @@
         LEFT JOIN class_group cg ON cgsm.class_group_id_ = cg.id_
         WHERE spo.type_ != 'OTHER' AND spo.music_group_id_ IS NOT NULL
         AND spo.user_id_ = #{userId} AND spo.status_='SUCCESS' AND cgsm.status_ != 'QUIT'
-        AND IF(spo.group_type_ = 'VIP', (vg.status_ = 4 OR vg.status_ = 3),0)=0 AND cg.del_flag_ = 0
+        AND IF(spo.group_type_ = 'VIP', (vg.status_ = 4 OR vg.status_ = 3 ),0)=0 AND cg.del_flag_ = 0
         <include refid="global.limit"/>
     </select>
 

+ 24 - 1
mec-student/src/main/java/com/ym/mec/student/controller/StudentVipGroupController.java

@@ -5,7 +5,12 @@ import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.dto.ConditionDto;
 import com.ym.mec.biz.dal.dto.QueryConditionDto;
 import com.ym.mec.biz.dal.dto.VipGroupBuyParamsDto;
+import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
+import com.ym.mec.biz.dal.enums.DealStatusEnum;
+import com.ym.mec.biz.dal.enums.GroupType;
+import com.ym.mec.biz.dal.enums.OrderTypeEnum;
 import com.ym.mec.biz.dal.page.StudentVipGroupQueryInfo;
+import com.ym.mec.biz.service.StudentPaymentOrderService;
 import com.ym.mec.biz.service.SubjectService;
 import com.ym.mec.biz.service.VipGroupCategoryService;
 import com.ym.mec.biz.service.VipGroupService;
@@ -39,6 +44,8 @@ public class StudentVipGroupController extends BaseController {
     private SysUserFeignService sysUserFeignService;
     @Autowired
     private VipGroupCategoryService vipGroupCategoryService;
+    @Autowired
+    private StudentPaymentOrderService studentPaymentOrderService;
 
     @ApiOperation(value = "获取vip课列表筛选条件")
     @GetMapping(value = "/findQueryCondition")
@@ -81,13 +88,29 @@ public class StudentVipGroupController extends BaseController {
         if (null == sysUser) {
             return failed(HttpStatus.FORBIDDEN, "请登录");
         }
-        vipGroupService.enableBuyVipGroup(vipGroupId);
+        vipGroupService.enableBuyVipGroup(vipGroupId,sysUser.getId());
         return succeed();
     }
 
     @ApiOperation(value = "vip课购买")
     @PostMapping("/buyVipGroup")
     public Object buyVipGroup(VipGroupBuyParamsDto vipGroupBuyParams) throws Exception {
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if (null == sysUser) {
+            return failed(HttpStatus.FORBIDDEN, "请登录");
+        }
+        if(!vipGroupBuyParams.isRepeatPay()){
+            // 判断是否存在支付中的记录
+            List<StudentPaymentOrder> list = studentPaymentOrderService
+                    .queryByCondition(GroupType.VIP,
+                            vipGroupBuyParams.getVipGroupId().toString(),
+                            sysUser.getId(),
+                            DealStatusEnum.ING,
+                            OrderTypeEnum.SMALL_CLASS_TO_BUY);
+            if (list.size() > 0) {
+                return failed(HttpStatus.CONTINUE, "您有待支付的订单");
+            }
+        }
         return succeed(vipGroupService.buyVipGroup(vipGroupBuyParams));
     }
 

+ 5 - 1
mec-teacher/src/main/java/com/ym/mec/teacher/controller/TeacherSchoolController.java

@@ -56,7 +56,11 @@ public class TeacherSchoolController extends BaseController {
     @ApiOperation(value = "删除学校")
     @PostMapping("/del")
     public Object del(@ApiParam(value = "学校编号", required = true) Integer id){
-        schoolService.delete(id);
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if(sysUser == null){
+            return failed(HttpStatus.FORBIDDEN,"请登录");
+        }
+        schoolService.deleteByTeacherAndId(id,sysUser.getId());
         return succeed();
     }