Pārlūkot izejas kodu

1、乐团课新增排课教师课酬计算逻辑调整
2、陪练课接口
3、陪练课指派教师广东分部特殊处理

Joburgess 5 gadi atpakaļ
vecāks
revīzija
966dd86a9f

+ 11 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentPaymentOrderDao.java

@@ -222,4 +222,15 @@ public interface StudentPaymentOrderDao extends BaseDAO<Long, StudentPaymentOrde
      */
     int countUserBuyVipGroupSuccessOrder(@Param("userId") Integer userId,
                                          @Param("vipGroupId") Integer vipGroupId);
+
+    /**
+     * @describe 获取学员购买小课的订单
+     * @author Joburgess
+     * @date 2020/2/5
+     * @param userId: 用户编号
+     * @param vipGroupId: 小课编号
+     * @return java.util.List<com.ym.mec.biz.dal.entity.StudentPaymentOrder>
+     */
+    List<StudentPaymentOrder> findUserBuyVipGroupOrder(@Param("userId") Integer userId,
+                                                       @Param("vipGroupId") Integer vipGroupId);
 }

+ 17 - 9
mec-biz/src/main/java/com/ym/mec/biz/service/impl/VipGroupServiceImpl.java

@@ -1106,17 +1106,22 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 				throw new BizException("您已预约过此课程");
 			}
 			throw new BizException("您已购买过此课程");
-		}else if(CollectionUtils.isEmpty(oldOrders)||Objects.isNull(statusCountMap.get(DealStatusEnum.ING))){
+		}else if(CollectionUtils.isEmpty(oldOrders)){
 			if(classGroup.getStudentNum()>=classGroup.getExpectStudentNum()){
 				throw new BizException("该课程人数已达上限");
 			}
 			//更新班级人数,如果订单支付失败则减少
 			this.updateVipGroupStudentNumAndStatus(vipGroup.getId(),classGroup,1,false);
 
-			ClassGroupStudentMapper classGroupStudentMapper=new ClassGroupStudentMapper(classGroup.getId(),user.getId().intValue());
-			classGroupStudentMapper.setGroupType(GroupType.VIP);
-			classGroupStudentMapper.setMusicGroupId(vipGroup.getId().toString());
-			classGroupStudentMapperDao.insert(classGroupStudentMapper);
+			ClassGroupStudentMapper classGroupStudentMapper=classGroupStudentMapperDao.query(classGroup.getId(),user.getId());
+			if(Objects.isNull(classGroupStudentMapper)){
+				classGroupStudentMapper=new ClassGroupStudentMapper(classGroup.getId(),user.getId().intValue());
+				classGroupStudentMapper.setGroupType(GroupType.VIP);
+				classGroupStudentMapper.setMusicGroupId(vipGroup.getId().toString());
+				classGroupStudentMapperDao.insert(classGroupStudentMapper);
+			}else{
+				classGroupStudentMapper.setStatus(ClassGroupStudentStatusEnum.NORMAL);
+			}
 		}
 
 		Date date=new Date();
@@ -1237,8 +1242,9 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 		Integer userId = order.getUserId();
 		boolean isOk=order.getStatus().equals(DealStatusEnum.SUCCESS);
 
-		int successOrderNum = studentPaymentOrderDao.countUserBuyVipGroupSuccessOrder(userId, vipGroupId.intValue());
-		if(successOrderNum>0){
+		List<StudentPaymentOrder> userOrders = studentPaymentOrderDao.findUserBuyVipGroupOrder(userId, vipGroupId.intValue());
+		Map<DealStatusEnum, List<StudentPaymentOrder>> statusOrdersMap = userOrders.stream().collect(Collectors.groupingBy(StudentPaymentOrder::getStatus));
+		if(!CollectionUtils.isEmpty(statusOrdersMap.get(DealStatusEnum.SUCCESS))){
 			studentPaymentOrderDao.update(order);
 			return;
 		}
@@ -1254,8 +1260,10 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 
 		//将学生加入到班级,更新班级报名状态及人数信息
 		if(!isOk){
-			updateVipGroupStudentNumAndStatus(vipGroupId,classGroup,-1,false);
-			classGroupStudentMapperDao.deleteStudentByMusicGroupId(vipGroupId.toString(),userId);
+			if(CollectionUtils.isEmpty(statusOrdersMap.get(DealStatusEnum.ING))){
+				updateVipGroupStudentNumAndStatus(vipGroupId,classGroup,-1,false);
+				classGroupStudentMapperDao.deleteStudentByMusicGroupId(vipGroupId.toString(),userId);
+			}
 			if (studentPaymentOrder.getBalancePaymentAmount() != null && studentPaymentOrder.getBalancePaymentAmount().doubleValue() > 0) {
 				sysUserCashAccountService.updateBalance(userId, studentPaymentOrder.getBalancePaymentAmount(), PlatformCashAccountDetailTypeEnum.REFUNDS,
 						"VIP课购买失败");

+ 3 - 0
mec-biz/src/main/resources/config/mybatis/StudentPaymentOrderMapper.xml

@@ -507,4 +507,7 @@
     <select id="countUserBuyVipGroupSuccessOrder" resultType="int">
       select count(*) from student_payment_order where  user_id_=#{userId} and music_group_id_=#{vipGroupId} and group_type_='VIP' and status_='SUCCESS'
     </select>
+    <select id="findUserBuyVipGroupOrder" resultMap="StudentPaymentOrder">
+      select * from student_payment_order where  user_id_=#{userId} and music_group_id_=#{vipGroupId} and group_type_='VIP'
+    </select>
 </mapper>