Joburgess 5 年 前
コミット
b69af5888d

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

@@ -17,6 +17,16 @@ public class VipGroupBuyParamsDto {
     @ApiModelProperty(value = "业务渠道")
     private String paymentBusinessChannel;
 
+    private Integer userId;
+
+    public Integer getUserId() {
+        return userId;
+    }
+
+    public void setUserId(Integer userId) {
+        this.userId = userId;
+    }
+
     public Long getVipGroupId() {
         return vipGroupId;
     }

+ 18 - 10
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SysMessageServiceImpl.java

@@ -1,5 +1,22 @@
 package com.ym.mec.biz.service.impl;
 
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Random;
+import java.util.Set;
+
+import org.apache.commons.lang.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.stereotype.Service;
+
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.dao.SysMessageDao;
@@ -18,15 +35,6 @@ import com.ym.mec.common.service.impl.BaseServiceImpl;
 import com.ym.mec.thirdparty.message.MessageSenderPluginContext;
 import com.ym.mec.thirdparty.message.MessageSenderPluginContext.MessageSender;
 import com.ym.mec.util.string.MessageFormatter;
-import org.apache.commons.lang.StringUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.scheduling.annotation.Async;
-import org.springframework.stereotype.Service;
-
-import java.util.*;
-import java.util.Map.Entry;
 
 @Service
 public class SysMessageServiceImpl extends BaseServiceImpl<Long, SysMessage> implements SysMessageService {
@@ -56,7 +64,7 @@ public class SysMessageServiceImpl extends BaseServiceImpl<Long, SysMessage> imp
 
 	private final int DEFAULT_CODE = 888888;
 
-//	@Value("${message.debugMode}")
+	@Value("${message.debugMode}")
 	private boolean debugMode;
 
 	@Override

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

@@ -727,6 +727,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
     }
 
 	@Override
+	@Transactional(rollbackFor = Exception.class)
 	public void updateVipGroupStudentNumAndStatus(Long vipGroupId, Integer num, boolean updateVipStatus) {
 		VipGroup vipGroup = vipGroupDao.getLockVipGroup(vipGroupId);
 		if(Objects.isNull(vipGroup)){
@@ -777,7 +778,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 			throw new BizException("课程信息错误");
 		}
 
-		ClassGroup classGroup = classGroupDao.get(vipGroupClassGroupMapper.getClassGroupId());
+		ClassGroup classGroup = vipGroupClassGroupMapperDao.findClassGroupByVipGroup(vipGroupBuyParams.getVipGroupId());
 		if(Objects.isNull(classGroup)){
 			throw new BizException("课程信息错误");
 		}
@@ -786,19 +787,17 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 				user.getId(),
 				DealStatusEnum.ING.getCode());
 
-        if(classGroup.getStudentNum()>=classGroup.getExpectStudentNum()&&Objects.nonNull(byStudentVipGroup)){
-            throw new BizException("该课程人数已达上限");
-        }
-
 		if(Objects.nonNull(byStudentVipGroup)){
 			byStudentVipGroup.setStatus(DealStatusEnum.CLOSE);
 			studentPaymentOrderDao.update(byStudentVipGroup);
 		}else{
+			if(classGroup.getStudentNum()>=classGroup.getExpectStudentNum()){
+				throw new BizException("该课程人数已达上限");
+			}
 			//更新班级人数,如果订单支付失败则减少
-			updateVipGroupStudentNumAndStatus(vipGroup.getId(),1,false);
+			this.updateVipGroupStudentNumAndStatus(vipGroup.getId(),1,false);
 		}
 
-//		VipGroupActivity vipGroupActivity = vipGroupActivityDao.get(vipGroup.getVipGroupActivityId().intValue());
 		StudentPaymentOrder studentPaymentOrder=new StudentPaymentOrder();
 		studentPaymentOrder.setUserId(user.getId());
 		String orderNo=StringUtils.join(new String[]{user.getId().toString(),String.valueOf(System.currentTimeMillis())});
@@ -807,11 +806,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 		studentPaymentOrder.setType(OrderTypeEnum.SMALL_CLASS_TO_BUY);
 		studentPaymentOrder.setExpectAmount(vipGroup.getTotalPrice());
 		studentPaymentOrder.setMusicGroupId(vipGroup.getId().toString());
-//		if(vipGroupActivity.getType()==VipGroupActivityTypeEnum.DISCOUNT){
-//			studentPaymentOrder.setActualAmount(studentPaymentOrder.getExpectAmount().multiply(new BigDecimal(vipGroupActivity.getAttribute1())));
-//		}else{
 		studentPaymentOrder.setActualAmount(studentPaymentOrder.getExpectAmount());
-//		}
 		studentPaymentOrder.setMusicGroupId(vipGroup.getId().toString());
 		studentPaymentOrder.setClassGroupId(vipGroupClassGroupMapper.getClassGroupId());
 
@@ -826,12 +821,6 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 		studentPaymentOrder.setPaymentChannel((String) payMap.get("type"));
 		studentPaymentOrderDao.insert(studentPaymentOrder);
 
-//		StudentVipGroupPayment studentVipGroupPayment=new StudentVipGroupPayment();
-//		studentVipGroupPayment.setUserId(user.getId());
-//		studentVipGroupPayment.setVipGroupId(vipGroup.getId());
-//		studentVipGroupPayment.setClassGroupId(vipGroupClassGroupMapper.getClassGroupId());
-//		studentVipGroupPayment.setStudentPaymentOrderId(studentPaymentOrder.getId());
-//		studentVipGroupPaymentDao.insert(studentVipGroupPayment);
 		return payMap;
 
 	}

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

@@ -405,26 +405,26 @@
 
     <select id="getStudentCourseSchedulesWithDate" resultMap="courseScheduleDto">
         SELECT
-        cs.id_ seal_class_id_,
-        cs.name_,
-        cs.type_,
-        cs.id_,
-        cs.class_date_,
-        CONCAT(cs.class_date_,' ',cs.start_class_time_) start_class_time_,
-        CONCAT(cs.class_date_,' ',cs.end_class_time_) end_class_time_,
-        cs.status_,
-        su.username_ teacher_name_,
-        cgsm.status_ attendance_status_,
-        csc.id_ IS NOT NULL complaint_status_,
-        cs.teach_mode_
+            cs.id_ seal_class_id_,
+            cs.name_,
+            cs.type_,
+            cs.id_,
+            cs.class_date_,
+            CONCAT(cs.class_date_,' ',cs.start_class_time_) start_class_time_,
+            CONCAT(cs.class_date_,' ',cs.end_class_time_) end_class_time_,
+            cs.status_,
+            su.username_ teacher_name_,
+            cgsm.status_ attendance_status_,
+            csc.id_ IS NOT NULL complaint_status_,
+            cs.teach_mode_
         FROM
-        course_schedule_student_payment cssp
-	    LEFT JOIN course_schedule cs ON cssp.course_schedule_id_=cs.id_
-        LEFT JOIN sys_user su ON cs.teacher_id_=su.id_
-        LEFT JOIN course_schedule_complaints csc ON csc.course_schedule_id_=cssp.course_schedule_id_ AND csc.user_id_=#{studentId}
-        LEFT JOIN class_group_student_mapper cgsm ON cgsm.class_group_id_ = cs.class_group_id_ AND cgsm.user_id_=#{studentId}
+          course_schedule_student_payment cssp
+            LEFT JOIN course_schedule cs ON cssp.course_schedule_id_=cs.id_
+            LEFT JOIN sys_user su ON cs.teacher_id_=su.id_
+            LEFT JOIN course_schedule_complaints csc ON csc.course_schedule_id_=cssp.course_schedule_id_ AND csc.user_id_=#{studentId}
+            LEFT JOIN class_group_student_mapper cgsm ON cgsm.class_group_id_ = cs.class_group_id_ AND cgsm.user_id_=#{studentId}
         WHERE
-        cs.class_date_ = DATE_FORMAT(#{classDate},'%Y%m%d')
+          cs.class_date_ = DATE_FORMAT(#{classDate},'%Y%m%d')
         AND cssp.user_id_ = #{studentId}
         ORDER BY start_class_time_
     </select>

+ 3 - 3
mec-common/common-core/src/main/java/com/ym/mec/common/redis/config/RedisConfig.java

@@ -1,7 +1,5 @@
 package com.ym.mec.common.redis.config;
 
-import java.io.Serializable;
-
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
@@ -13,6 +11,8 @@ import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.data.redis.serializer.JdkSerializationRedisSerializer;
 import org.springframework.data.redis.serializer.StringRedisSerializer;
 
+import java.io.Serializable;
+
 @Configuration
 public class RedisConfig {
 
@@ -41,7 +41,7 @@ public class RedisConfig {
 	}
 
 	@Bean
-	public RedisTemplate<String, Serializable> redisTemplate() {
+	public RedisTemplate<String, Serializable> redisTemplate(JedisConnectionFactory connectionFactory) {
 		RedisTemplate<String, Serializable> redisTemplate = new RedisTemplate<>();
 		redisTemplate.setKeySerializer(new StringRedisSerializer());
 		redisTemplate.setHashKeySerializer(new StringRedisSerializer());