فهرست منبع

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupPaymentStudentCourseDetailDao.java
#	mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupPaymentStudentCourseDetail.java
Joburgess 4 سال پیش
والد
کامیت
1b3cdaf9ae
17فایلهای تغییر یافته به همراه247 افزوده شده و 65 حذف شده
  1. 12 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupPaymentCalenderDao.java
  2. 4 2
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupPaymentStudentCourseDetailDao.java
  3. 10 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/SporadicChargeInfoDao.java
  4. 12 1
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/LuckStatisDto.java
  5. 12 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/OrderStatisDto.java
  6. 36 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/OrganMaxAmountDto.java
  7. 1 1
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupPaymentCalenderCourseSettings.java
  8. 10 8
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupPaymentStudentCourseDetail.java
  9. 77 28
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderDetailServiceImpl.java
  10. 11 7
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java
  11. 8 5
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/SporadicChargeInfoImpl.java
  12. 13 4
      mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentCalenderMapper.xml
  13. 10 0
      mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentStudentCourseDetailMapper.xml
  14. 9 0
      mec-biz/src/main/resources/config/mybatis/SporadicChargeInfo.xml
  15. 1 1
      mec-student/src/main/java/com/ym/mec/student/controller/MusicGroupController.java
  16. 1 1
      mec-web/src/main/java/com/ym/mec/web/controller/MusicGroupPaymentCalenderController.java
  17. 20 7
      mec-web/src/main/java/com/ym/mec/web/controller/education/ActivityController.java

+ 12 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupPaymentCalenderDao.java

@@ -237,4 +237,16 @@ public interface MusicGroupPaymentCalenderDao extends BaseDAO<Long, MusicGroupPa
      * @return
      */
     MusicGroupPaymentCalender getMusicGroupRegCalender(@Param("musicGroupId") String musicGroupId);
+
+    /**
+     * @describe 获取学员在乐团的缴费状态
+     * @apiNote 时光荏苒,认真工作的时间总是过得很快,而我、享受这一刻!
+     * @author zouxuan
+     * @date 2020/11/4
+     * @time 15:43
+     * @param userId:
+     * @param musicGroupId:
+     * @return java.util.Map<java.lang.String,java.lang.String>
+     */
+    Map<String, String> queryUserPaymentStatus(@Param("userId") Integer userId, @Param("musicGroupId") String musicGroupId);
 }

+ 4 - 2
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupPaymentStudentCourseDetailDao.java

@@ -1,12 +1,12 @@
 package com.ym.mec.biz.dal.dao;
 
 import com.ym.mec.biz.dal.entity.CourseSchedule;
+import java.util.List;
+
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentStudentCourseDetail;
 import com.ym.mec.common.dal.BaseDAO;
 import org.apache.ibatis.annotations.Param;
 
-import java.util.List;
-
 public interface MusicGroupPaymentStudentCourseDetailDao extends BaseDAO<Long, MusicGroupPaymentStudentCourseDetail> {
 
     /**
@@ -31,4 +31,6 @@ public interface MusicGroupPaymentStudentCourseDetailDao extends BaseDAO<Long, M
      */
     List<MusicGroupPaymentStudentCourseDetail> getUnUseWithStudents(@Param("studentIds") List<Integer> studentIds);
 
+	int batchInsert(List<MusicGroupPaymentStudentCourseDetail> musicGroupPaymentStudentCourseDetailList);
+
 }

+ 10 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/SporadicChargeInfoDao.java

@@ -1,5 +1,6 @@
 package com.ym.mec.biz.dal.dao;
 
+import com.ym.mec.biz.dal.dto.OrganMaxAmountDto;
 import com.ym.mec.biz.dal.entity.Organization;
 import com.ym.mec.biz.dal.entity.SporadicChargeInfo;
 import com.ym.mec.common.dal.BaseDAO;
@@ -14,6 +15,7 @@ public interface SporadicChargeInfoDao extends BaseDAO<Integer, SporadicChargeIn
 
     /**
      * 根据分部和类型获取活动信息
+     *
      * @param organId
      * @param chargeType
      * @return
@@ -22,8 +24,16 @@ public interface SporadicChargeInfoDao extends BaseDAO<Integer, SporadicChargeIn
 
     /**
      * 获取所有的活动分部
+     *
      * @param type
      * @return
      */
     List<Organization> getActiveOrgans(@Param("type") Integer type);
+
+    /**
+     * 获取活动分部的最大缴费金额
+     * @param type
+     * @return
+     */
+    List<OrganMaxAmountDto> getActiveOrgansMaxAmount(@Param("type") Integer type);
 }

+ 12 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/LuckStatisDto.java

@@ -20,7 +20,10 @@ public class LuckStatisDto {
     @ApiModelProperty(value = "总金额",required = true)
     private BigDecimal totalMoney = BigDecimal.ZERO;
 
-    @ApiModelProperty(value = "总转化率",required = true)
+    @ApiModelProperty(value = "总目标金额",required = true)
+    private BigDecimal totalMaxAmount= BigDecimal.ZERO;
+
+    @ApiModelProperty(value = "总完成度",required = true)
     private BigDecimal scale = BigDecimal.ZERO;
 
     public List<OrderStatisDto> getOrderStatisDtoList() {
@@ -70,4 +73,12 @@ public class LuckStatisDto {
     public void setTotalTimes(Integer totalTimes) {
         this.totalTimes = totalTimes;
     }
+
+    public BigDecimal getTotalMaxAmount() {
+        return totalMaxAmount;
+    }
+
+    public void setTotalMaxAmount(BigDecimal totalMaxAmount) {
+        this.totalMaxAmount = totalMaxAmount;
+    }
 }

+ 12 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/OrderStatisDto.java

@@ -1,5 +1,7 @@
 package com.ym.mec.biz.dal.dto;
 
+import io.swagger.annotations.ApiModelProperty;
+
 import java.math.BigDecimal;
 
 public class OrderStatisDto {
@@ -10,6 +12,8 @@ public class OrderStatisDto {
     private Integer times = 0;
     private BigDecimal scale = BigDecimal.ZERO;
     private BigDecimal money = BigDecimal.ZERO;
+    @ApiModelProperty(value = "目标金额", required = true)
+    private BigDecimal maxAmount = BigDecimal.ZERO;
 
     public Integer getOrganId() {
         return organId;
@@ -66,4 +70,12 @@ public class OrderStatisDto {
     public void setTimes(Integer times) {
         this.times = times;
     }
+
+    public BigDecimal getMaxAmount() {
+        return maxAmount;
+    }
+
+    public void setMaxAmount(BigDecimal maxAmount) {
+        this.maxAmount = maxAmount;
+    }
 }

+ 36 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/OrganMaxAmountDto.java

@@ -0,0 +1,36 @@
+package com.ym.mec.biz.dal.dto;
+
+import java.math.BigDecimal;
+
+public class OrganMaxAmountDto {
+    //分部id
+    private Integer id;
+
+    private String name;
+
+    private BigDecimal maxAmount;
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public BigDecimal getMaxAmount() {
+        return maxAmount;
+    }
+
+    public void setMaxAmount(BigDecimal maxAmount) {
+        this.maxAmount = maxAmount;
+    }
+}

+ 1 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupPaymentCalenderCourseSettings.java

@@ -110,7 +110,7 @@ public class MusicGroupPaymentCalenderCourseSettings {
 		this.isStudentOptional = isStudentOptional;
 	}
 	
-	public boolean isIsStudentOptional(){
+	public boolean getIsStudentOptional(){
 		return this.isStudentOptional;
 	}
 			

+ 10 - 8
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupPaymentStudentCourseDetail.java

@@ -2,6 +2,8 @@ package com.ym.mec.biz.dal.entity;
 
 import org.apache.commons.lang3.builder.ToStringBuilder;
 
+import com.ym.mec.biz.dal.entity.CourseSchedule.CourseScheduleType;
+
 /**
  * 对应数据库表(music_group_payment_student_course_detail):
  */
@@ -20,7 +22,7 @@ public class MusicGroupPaymentStudentCourseDetail {
 	private Integer userId;
 	
 	/**  */
-	private CourseSchedule.CourseScheduleType courseType;
+	private CourseScheduleType courseType;
 	
 	/**  */
 	private Integer totalCourseMinutes;
@@ -65,15 +67,15 @@ public class MusicGroupPaymentStudentCourseDetail {
 	public Integer getUserId(){
 		return this.userId;
 	}
-
-	public CourseSchedule.CourseScheduleType getCourseType() {
-		return courseType;
-	}
-
-	public void setCourseType(CourseSchedule.CourseScheduleType courseType) {
+			
+	public void setCourseType(CourseScheduleType courseType){
 		this.courseType = courseType;
 	}
-
+	
+	public CourseScheduleType getCourseType(){
+		return this.courseType;
+	}
+			
 	public void setTotalCourseMinutes(Integer totalCourseMinutes){
 		this.totalCourseMinutes = totalCourseMinutes;
 	}

+ 77 - 28
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderDetailServiceImpl.java

@@ -24,6 +24,7 @@ import com.ym.mec.biz.dal.dao.MusicGroupDao;
 import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderCourseSettingsDao;
 import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDao;
 import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDetailDao;
+import com.ym.mec.biz.dal.dao.MusicGroupPaymentStudentCourseDetailDao;
 import com.ym.mec.biz.dal.dao.MusicGroupStudentFeeDao;
 import com.ym.mec.biz.dal.dao.SysConfigDao;
 import com.ym.mec.biz.dal.dto.FeeStudentDto;
@@ -33,6 +34,7 @@ import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentCalenderStatusEnum;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderCourseSettings;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderDetail;
+import com.ym.mec.biz.dal.entity.MusicGroupPaymentStudentCourseDetail;
 import com.ym.mec.biz.dal.entity.MusicGroupStudentFee;
 import com.ym.mec.biz.dal.entity.MusicGroupStudentFee.PaymentStatus;
 import com.ym.mec.biz.dal.enums.MessageTypeEnum;
@@ -56,6 +58,9 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
 	private MusicGroupPaymentCalenderCourseSettingsDao musicGroupPaymentCalenderCourseSettingsDao;
 	
 	@Autowired
+	private MusicGroupPaymentStudentCourseDetailDao musicGroupPaymentStudentCourseDetailDao;
+	
+	@Autowired
 	private MusicGroupDao musicGroupDao;
 	@Autowired
 	private SysConfigDao sysConfigDao;
@@ -215,41 +220,56 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
 		if(calender == null){
 			throw new BizException("缴费信息不存在");
 		}
-		/*MusicGroupPaymentCalenderDetail userLastCalenderDetail = musicGroupPaymentCalenderDetailDao.getUserLastCalenderDetail(calender.getMusicGroupId(), userId);
-		if(userLastCalenderDetail != null){
-			throw new BizException("缴费信息已存在");
-		}*/
+		MusicGroupPaymentCalenderDetail musicGroupPaymentCalenderDetail = musicGroupPaymentCalenderDetailDao.findByCalenderIdAndUserId(musicGroupPaymentCalenderId, userId);
+		if(musicGroupPaymentCalenderDetail != null){
+			throw new BizException("新增失败,已经存在缴费记录");
+		}
+		
+		List<MusicGroupPaymentCalenderCourseSettings> courseSettingsList = musicGroupPaymentCalenderCourseSettingsDao.getWithPaymentCalender(musicGroupPaymentCalenderId);
+		
+		BigDecimal totalPrice = new BigDecimal(0);
+		for(MusicGroupPaymentCalenderCourseSettings courseSettings : courseSettingsList){
+			//剔除可选课程
+			if (courseSettings.getIsStudentOptional() == false) {
+				totalPrice.add(courseSettings.getCourseCurrentPrice());
+			}
+			totalPrice.add(courseSettings.getCourseCurrentPrice());
+		}
 		Date date = new Date();
-//		Integer countOpenPayment = musicGroupPaymentCalenderDetailDao.countOpenPayment(calender.getMusicGroupId(), userId);
-		MusicGroupStudentFee studentFee = musicGroupStudentFeeDao.findByUser(userId, calender.getMusicGroupId());
-		/*if(countOpenPayment > 0){
-			throw new BizException("操作失败: 学员有未完成的缴费");
-		}*/
 		calender.setUpdateTime(date);
+		calender.setExpectNum(calender.getExpectNum() + 1);
 		//生成详情
-		MusicGroupPaymentCalenderDetail musicGroupPaymentCalenderDetail = new MusicGroupPaymentCalenderDetail();
+		musicGroupPaymentCalenderDetail = new MusicGroupPaymentCalenderDetail();
 		musicGroupPaymentCalenderDetail.setMusicGroupPaymentCalenderId(calender.getId());
 		musicGroupPaymentCalenderDetail.setCreateTime(date);
-		musicGroupPaymentCalenderDetail.setExpectAmount(studentFee.getCourseFee());
-		studentFee.setUpdateTime(date);
-		/*if (studentFee.getCourseFee().doubleValue() == 0) {
-			studentFee.setPaymentStatus(PAID_COMPLETED);
-			musicGroupPaymentCalenderDetail.setPaymentStatus(PAID_COMPLETED);
-			if(calender.getType() == ONLINE){
-				studentFee.setRemainNetworkClassTimes(studentFee.getRemainNetworkClassTimes() + 1);
-//				musicGroupStudentFeeDao.remainNetworkClassTimesAdd(userLastCalenderDetail.getId().toString());
-			}
-		} else {
-			studentFee.setPaymentStatus(NON_PAYMENT);
-			musicGroupPaymentCalenderDetail.setPaymentStatus(MusicGroupStudentFee.PaymentStatus.NON_PAYMENT);
-		}*/
-		studentFee.setPaymentStatus(NON_PAYMENT);
+		musicGroupPaymentCalenderDetail.setExpectAmount(totalPrice);
 		musicGroupPaymentCalenderDetail.setPaymentStatus(MusicGroupStudentFee.PaymentStatus.NON_PAYMENT);
 		musicGroupPaymentCalenderDetail.setUpdateTime(date);
 		musicGroupPaymentCalenderDetail.setUserId(userId);
 		musicGroupPaymentCalenderDetailDao.insert(musicGroupPaymentCalenderDetail);
 		musicGroupPaymentCalenderDao.update(calender);
-		musicGroupStudentFeeDao.update(studentFee);
+		
+		List<MusicGroupPaymentStudentCourseDetail> musicGroupPaymentStudentCourseDetailList = new ArrayList<MusicGroupPaymentStudentCourseDetail>();
+		MusicGroupPaymentStudentCourseDetail musicGroupPaymentStudentCourseDetail = null;
+		for (MusicGroupPaymentCalenderCourseSettings courseSettings : courseSettingsList) {
+			if (courseSettings.getIsStudentOptional() == true) {
+				continue;
+			}
+			musicGroupPaymentStudentCourseDetail = new MusicGroupPaymentStudentCourseDetail();
+			musicGroupPaymentStudentCourseDetail.setCourseType(courseSettings.getCourseType());
+			musicGroupPaymentStudentCourseDetail.setCreateTime(date);
+			musicGroupPaymentStudentCourseDetail.setMusicGroupPaymentCalenderDetailId(musicGroupPaymentCalenderDetail.getId());
+			musicGroupPaymentStudentCourseDetail.setTotalCourseMinutes(courseSettings.getCourseTotalMinuties());
+			musicGroupPaymentStudentCourseDetail.setUpdateTime(date);
+			musicGroupPaymentStudentCourseDetail.setUsedCourseMinutes(0);
+			musicGroupPaymentStudentCourseDetail.setUserId(userId);
+
+			musicGroupPaymentStudentCourseDetailList.add(musicGroupPaymentStudentCourseDetail);
+		}
+
+		if (musicGroupPaymentStudentCourseDetailList.size() > 0) {
+			musicGroupPaymentStudentCourseDetailDao.batchInsert(musicGroupPaymentStudentCourseDetailList);
+		}
 	}
 
 	@Override
@@ -270,12 +290,15 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
 		
 		BigDecimal totalPrice = new BigDecimal(0);
 		for(MusicGroupPaymentCalenderCourseSettings courseSettings : courseSettingsList){
-			totalPrice.add(courseSettings.getCourseCurrentPrice());
+			//剔除可选课程
+			if (courseSettings.getIsStudentOptional() == false) {
+				totalPrice.add(courseSettings.getCourseCurrentPrice());
+			}
 		}
 		
 		Date date = new Date();
 		MusicGroupPaymentCalenderDetail musicGroupPaymentCalenderDetail = null;
-
+		Map<Integer,MusicGroupPaymentCalenderDetail> userMap = new HashMap<Integer, MusicGroupPaymentCalenderDetail>();
 		List<MusicGroupPaymentCalenderDetail> musicGroupPaymentCalenderDetailList = new ArrayList<MusicGroupPaymentCalenderDetail>();
 		//创建缴费明细
 		for(Integer studentId : userIdList){
@@ -289,6 +312,7 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
 			musicGroupPaymentCalenderDetail.setStartPaymentDate(musicGroupPaymentCalender.getStartPaymentDate());
 			musicGroupPaymentCalenderDetail.setDeadlinePaymentDate(musicGroupPaymentCalender.getDeadlinePaymentDate());
 			
+			userMap.put(studentId, musicGroupPaymentCalenderDetail);
 			musicGroupPaymentCalenderDetailList.add(musicGroupPaymentCalenderDetail);
 		}
 
@@ -298,7 +322,32 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
 		//更新预计缴费人数
 		musicGroupPaymentCalender.setExpectNum(userIdList.size());
 		musicGroupPaymentCalender.setUpdateTime(date);
-		musicGroupPaymentCalenderDetailDao.update(musicGroupPaymentCalenderDetail);
+		musicGroupPaymentCalenderDao.update(musicGroupPaymentCalender);
+		
+		List<MusicGroupPaymentStudentCourseDetail> musicGroupPaymentStudentCourseDetailList = new ArrayList<MusicGroupPaymentStudentCourseDetail>();
+		MusicGroupPaymentStudentCourseDetail musicGroupPaymentStudentCourseDetail = null;
+		//创建学生课排课分钟数
+		for(Integer studentId : userIdList){
+			for(MusicGroupPaymentCalenderCourseSettings courseSettings : courseSettingsList){
+				if (courseSettings.getIsStudentOptional() == true) {
+					continue;
+				}
+				musicGroupPaymentStudentCourseDetail = new MusicGroupPaymentStudentCourseDetail();
+				musicGroupPaymentStudentCourseDetail.setCourseType(courseSettings.getCourseType());
+				musicGroupPaymentStudentCourseDetail.setCreateTime(date);
+				musicGroupPaymentStudentCourseDetail.setMusicGroupPaymentCalenderDetailId(userMap.get(studentId).getId());
+				musicGroupPaymentStudentCourseDetail.setTotalCourseMinutes(courseSettings.getCourseTotalMinuties());
+				musicGroupPaymentStudentCourseDetail.setUpdateTime(date);
+				musicGroupPaymentStudentCourseDetail.setUsedCourseMinutes(0);
+				musicGroupPaymentStudentCourseDetail.setUserId(studentId);
+				
+				musicGroupPaymentStudentCourseDetailList.add(musicGroupPaymentStudentCourseDetail);
+			}
+		}
+		
+		if(musicGroupPaymentStudentCourseDetailList.size() > 0){
+			musicGroupPaymentStudentCourseDetailDao.batchInsert(musicGroupPaymentStudentCourseDetailList);
+		}
 	}
 
 	@Override

+ 11 - 7
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java

@@ -305,11 +305,14 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
             if (chargeInfo.getOpenMaxTerm().equals(YesOrNoEnum.YES) && chargeInfo.getMaxAmount().compareTo(chargeInfo.getPaidAmount()) <= 0) {
                 throw new Exception("活动人数暂时已满,请稍后再试");
             }
-            chargeInfo.setPaidAmount(chargeInfo.getPaidAmount().add(chargeInfo.getAmount()));
-            chargeInfo.setUpdateTime(new Date());
-            int update = sporadicChargeInfoDao.update(chargeInfo);
-            if (update <= 0) {
-                throw new BizException("活动火爆,请稍后再试");
+            List<SporadicChargeInfo> activeInfos = sporadicChargeInfoDao.getOrganActiveInfo(chargeInfo.getOrganId(), 12);
+            for (SporadicChargeInfo activeInfo : activeInfos) {
+                activeInfo.setPaidAmount(activeInfo.getPaidAmount().add(chargeInfo.getAmount()));
+                activeInfo.setUpdateTime(new Date());
+                int update = sporadicChargeInfoDao.update(activeInfo);
+                if (update <= 0) {
+                    throw new BizException("活动火爆,请稍后再试");
+                }
             }
         }
 
@@ -1123,7 +1126,8 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
     public List<MusicCardDto> queryUserMusicGroups(Integer userId) {
         List<MusicCardDto> musicCardDtos = musicGroupDao.queryUserMusicGroups(userId);
         Set<String> musicGroupIds = musicCardDtos.stream().map(MusicCardDto::getMusicGroupId).collect(Collectors.toSet());
-        Map<String, String> paymentStatus = MapUtil.convertMybatisMap(musicGroupStudentFeeDao.queryUserPaymentStatus(userId, StringUtils.join(musicGroupIds, ",")));
+//        Map<String, String> paymentStatus = MapUtil.convertMybatisMap(musicGroupStudentFeeDao.queryUserPaymentStatus(userId, StringUtils.join(musicGroupIds, ",")));
+        Map<String, String> paymentStatus = musicGroupPaymentCalenderDao.queryUserPaymentStatus(userId, StringUtils.join(musicGroupIds, ","));
         // 获取学员在该乐团续费状态
         musicCardDtos.forEach(e -> {
             e.setPaymentStatus(paymentStatus.get(e.getMusicGroupId()));
@@ -1740,7 +1744,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 
         if (amount.compareTo(BigDecimal.ZERO) == 0) {
             studentPaymentRouteOrderService.addRouteOrder(orderNo,organId, balance);
-            Map<String, String> notifyMap = new HashMap<>();
+            Map<String, String> notifyMap = new HashMap<>(4);
             notifyMap.put("tradeState", "1");
             notifyMap.put("merOrderNo", studentPaymentOrder.getOrderNo());
             notifyMap.put("channelType", "");

+ 8 - 5
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SporadicChargeInfoImpl.java

@@ -149,11 +149,14 @@ public class SporadicChargeInfoImpl extends BaseServiceImpl<Integer, SporadicCha
         }
         if (studentPaymentOrder.getStatus() == DealStatusEnum.CLOSE || studentPaymentOrder.getStatus() == DealStatusEnum.FAILED) {
             if (info.getMaxAmount() != null && info.getPaidAmount().compareTo(BigDecimal.ZERO) > 0) {
-                info.setPaidAmount(info.getPaidAmount().subtract(studentPaymentOrder.getActualAmount()));
-                info.setUpdateTime(new Date());
-                int update = sporadicChargeInfoDao.update(info);
-                if (update <= 0) {
-                    throw new BizException("已收金额更新失败,请重试");
+                List<SporadicChargeInfo> activeInfos = sporadicChargeInfoDao.getOrganActiveInfo(info.getOrganId(), 12);
+                for (SporadicChargeInfo activeInfo : activeInfos) {
+                    activeInfo.setPaidAmount(activeInfo.getPaidAmount().subtract(info.getAmount()));
+                    activeInfo.setUpdateTime(new Date());
+                    int update = sporadicChargeInfoDao.update(activeInfo);
+                    if (update <= 0) {
+                        throw new BizException("已收金额更新失败,请重试");
+                    }
                 }
             }
             if (info.getOrganId().equals(42) && info.getChargeType().equals(SporadicChargeTypeEnum.LEVEL)) {

+ 13 - 4
mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentCalenderMapper.xml

@@ -45,11 +45,13 @@
             keyColumn="id_" keyProperty="id">
         INSERT INTO music_group_payment_calender
         (music_group_id_,music_group_organization_course_settings_id_,pay_user_type_,reject_reason_,start_payment_date_,deadline_payment_date_,status_,expect_num_,
-        actual_num_,memo_,is_give_music_network_,create_time_,update_time_,payment_valid_start_date_,payment_valid_end_date_,payment_pattern_,payment_type_,payment_amount_,batch_no_,audit_memo_)
+        actual_num_,memo_,is_give_music_network_,create_time_,update_time_,payment_valid_start_date_,payment_valid_end_date_,
+        payment_pattern_,payment_type_,payment_amount_,batch_no_,audit_memo_,operator_)
         VALUES(#{musicGroupId},#{musicGroupOrganizationCourseSettingId},#{payUserType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
         #{rejectReason},#{startPaymentDate},#{deadlinePaymentDate},#{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
         #{expectNum},#{actualNum},#{memo},#{isGiveMusicNetwork},now(),now(),
-        #{paymentValidStartDate},#{paymentValidEndDate},#{paymentPattern},#{paymentType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{paymentAmount},#{batchNo},#{auditMemo})
+        #{paymentValidStartDate},#{paymentValidEndDate},#{paymentPattern},#{paymentType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
+        #{paymentAmount},#{batchNo},#{auditMemo},#{operator})
     </insert>
 
     <insert id="batchInsert" parameterType="com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender" useGeneratedKeys="true"
@@ -57,13 +59,13 @@
         INSERT INTO music_group_payment_calender
         (music_group_id_,music_group_organization_course_settings_id_,pay_user_type_,reject_reason_,start_payment_date_,deadline_payment_date_,status_,expect_num_,
         actual_num_,memo_,is_give_music_network_,create_time_,update_time_,payment_valid_start_date_,payment_valid_end_date_,payment_pattern_,payment_amount_,
-        payment_type_,batch_no_,audit_memo_)
+        payment_type_,batch_no_,audit_memo_,operator_)
         VALUES
         <foreach collection="list" item="item" index="index" separator=",">
         (#{item.musicGroupId},#{item.musicGroupOrganizationCourseSettingId},#{item.payUserType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{item.rejectReason},#{item.startPaymentDate},#{item.deadlinePaymentDate},#{item.status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
         #{item.expectNum},#{item.actualNum},#{item.memo},#{item.isGiveMusicNetwork},now(),now(),
         #{item.paymentValidStartDate},#{item.paymentValidEndDate},#{item.paymentPattern},#{item.paymentAmount},#{item.paymentType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
-        #{item.batchNo},#{item.auditMemo})
+        #{item.batchNo},#{item.auditMemo},#{item.operator})
         </foreach>
     </insert>
 
@@ -462,4 +464,11 @@
         AND pay_user_type_='STUDENT'
         AND status_='OPEN'
     </select>
+    <select id="queryUserPaymentStatus" resultType="java.util.Map">
+        SELECT mgpc.music_group_id_ 'key',CASE WHEN COUNT(DISTINCT mgpcd.id_) > 0 THEN 'NON_PAYMENT' ELSE 'PAID_COMPLETED' END 'value'
+        FROM music_group_payment_calender mgpc
+        LEFT JOIN music_group_payment_calender_detail mgpcd ON mgpc.id_ = mgpcd.music_group_payment_calender_id_
+        WHERE FIND_IN_SET(mgpc.music_group_id_,#{musicGroupId}) AND mgpcd.user_id_ = #{userId} AND payment_status_ = 'NON_PAYMENT'
+        GROUP BY mgpc.music_group_id_
+    </select>
 </mapper>

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

@@ -40,6 +40,16 @@
 		(id_,music_group_payment_calender_id_,music_group_payment_calender_detail_id_,user_id_,course_type_,total_course_minutes_,used_course_minutes_,create_time_,update_time_)
 		VALUES(#{id},#{musicGroupPaymentCalenderId},#{musicGroupPaymentCalenderDetailId},#{userId},#{courseType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{totalCourseMinutes},#{usedCourseMinutes},#{createTime},#{updateTime})
 	</insert>
+	
+	<insert id="batchInsert" parameterType="java.util.List" useGeneratedKeys="true" keyColumn="id"
+            keyProperty="id">
+		INSERT INTO music_group_payment_student_course_detail
+		(id_,music_group_payment_calender_id_,music_group_payment_calender_detail_id_,user_id_,course_type_,total_course_minutes_,used_course_minutes_,create_time_,update_time_)
+		VALUES
+		<foreach collection="list" item="item" separator=",">
+		(#{item.id},#{item.musicGroupPaymentCalenderId},#{item.musicGroupPaymentCalenderDetailId},#{item.userId},#{item.courseType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{item.totalCourseMinutes},#{item.usedCourseMinutes},#{item.createTime},#{item.updateTime})
+		</foreach>
+	</insert>
 
 	<!-- 根据主键查询一条记录 -->
 	<update id="update"

+ 9 - 0
mec-biz/src/main/resources/config/mybatis/SporadicChargeInfo.xml

@@ -185,4 +185,13 @@
           AND sci.del_flag_ = 0
         GROUP BY o.id_
     </select>
+
+    <select id="getActiveOrgansMaxAmount" resultType="com.ym.mec.biz.dal.dto.OrganMaxAmountDto">
+        SELECT o.id_ id,o.name_ name ,(SUM(sci.max_amount_)/COUNT(*)) maxAmount
+        FROM sporadic_charge_info sci
+        LEFT JOIN organization o ON o.id_ = sci.organ_id_
+        WHERE sci.charge_type_ = #{type}
+        AND sci.del_flag_ = 0
+        GROUP BY o.id_
+    </select>
 </mapper>

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

@@ -236,7 +236,7 @@ public class MusicGroupController extends BaseController {
             throw new BizException("缴费项不存在该学员,请联系教务老师");
         }
         if(calenderDetail.getPaymentStatus() == PaymentStatus.PAID_COMPLETED){
-            throw new BizException("当前缴费项已缴费");
+            throw new BizException("您已缴费请勿重复支付");
         }else if(calenderDetail.getPaymentStatus() == PaymentStatus.PROCESSING){
             throw new BizException("当前缴费项存在待处理的订单,请稍候尝试");
         }

+ 1 - 1
mec-web/src/main/java/com/ym/mec/web/controller/MusicGroupPaymentCalenderController.java

@@ -81,7 +81,7 @@ public class MusicGroupPaymentCalenderController extends BaseController {
     @ApiOperation(value = "修改乐团缴费时间")
     @PostMapping("/update")
     @PreAuthorize("@pcs.hasPermissions('musicGroupPaymentCalender/update')")
-    public Object update(MusicGroupPaymentCalender paymentCalender) {
+    public Object update(@RequestBody MusicGroupPaymentCalender paymentCalender) {
     	Long musicGroupPaymentCalenderId = musicGroupPaymentCalenderService.merge(paymentCalender);
         ModelMap map = new ModelMap();
         map.put("musicGroupPaymentCalenderId", musicGroupPaymentCalenderId);

+ 20 - 7
mec-web/src/main/java/com/ym/mec/web/controller/education/ActivityController.java

@@ -6,6 +6,7 @@ import com.ym.mec.biz.dal.dao.StudentPaymentOrderDao;
 import com.ym.mec.biz.dal.dao.StudentRegistrationDao;
 import com.ym.mec.biz.dal.dto.LuckStatisDto;
 import com.ym.mec.biz.dal.dto.OrderStatisDto;
+import com.ym.mec.biz.dal.dto.OrganMaxAmountDto;
 import com.ym.mec.biz.dal.entity.Organization;
 import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.entity.HttpResponseResult;
@@ -43,6 +44,8 @@ public class ActivityController extends BaseController {
         Set<Integer> orderOrganIds = orders.stream().map(OrderStatisDto::getOrganId).collect(Collectors.toSet());
         //获取所有分部预计的人数
         List<OrderStatisDto> organNormalStudents = studentRegistrationDao.getOrganNormalStudent();
+        //获取分部的目标金额
+        List<OrganMaxAmountDto> maxAmount4Organs = sporadicChargeInfoDao.getActiveOrgansMaxAmount(12);
 
         for (Organization organ : organs) {
             if (!orderOrganIds.contains(organ.getId())) {
@@ -56,7 +59,15 @@ public class ActivityController extends BaseController {
         Integer totalEstimatedNums = 0;
         Integer totalNum = 0;
         Integer totalTimes = 0;
+        BigDecimal totalMaxAmount = BigDecimal.ZERO;
         for (OrderStatisDto order : orders) {
+            for (OrganMaxAmountDto maxAmount4Organ : maxAmount4Organs) {
+                if (order.getOrganId().equals(maxAmount4Organ.getId())) {
+                    order.setMaxAmount(maxAmount4Organ.getMaxAmount() == null ? BigDecimal.ZERO.setScale(2) : maxAmount4Organ.getMaxAmount().setScale(2));
+                    break;
+                }
+            }
+
             for (OrderStatisDto organNormalStudent : organNormalStudents) {
                 if (order.getOrganId().equals(organNormalStudent.getOrganId())) {
                     order.setEstimatedNums(organNormalStudent.getEstimatedNums());
@@ -67,10 +78,11 @@ public class ActivityController extends BaseController {
             totalNum += order.getNums();
             totalTimes += order.getTimes();
             totalMoney = totalMoney.add(order.getMoney());
-            if (order.getEstimatedNums() <= 0) {
-                order.setScale(new BigDecimal(order.getNums()).multiply(new BigDecimal(100)).divide(new BigDecimal(1), 2, BigDecimal.ROUND_HALF_UP));
-            }else {
-                order.setScale(new BigDecimal(order.getNums()).multiply(new BigDecimal(100)).divide(new BigDecimal(order.getEstimatedNums()), 2, BigDecimal.ROUND_HALF_UP));
+            totalMaxAmount = totalMaxAmount.add(order.getMaxAmount());
+            if (order.getMaxAmount().compareTo(BigDecimal.ZERO) <= 0) {
+                order.setScale(new BigDecimal("100.00"));
+            } else {
+                order.setScale(order.getMoney().multiply(new BigDecimal(100)).divide(order.getMaxAmount(), 2, BigDecimal.ROUND_HALF_UP));
             }
         }
         orders.sort(Comparator.comparing(OrderStatisDto::getMoney).reversed());
@@ -81,10 +93,11 @@ public class ActivityController extends BaseController {
         luckStatisDto.setTotalNum(totalNum);
         luckStatisDto.setTotalTimes(totalTimes);
         luckStatisDto.setTotalMoney(totalMoney);
-        if (luckStatisDto.getTotalEstimatedNums() <= 0) {
-            totalEstimatedNums = 1;
+        luckStatisDto.setTotalMaxAmount(totalMaxAmount);
+        if (luckStatisDto.getTotalMaxAmount().compareTo(BigDecimal.ZERO) <= 0) {
+            totalMaxAmount = BigDecimal.ONE;
         }
-        luckStatisDto.setScale(new BigDecimal(totalNum).multiply(new BigDecimal(100)).divide(new BigDecimal(totalEstimatedNums), 2, BigDecimal.ROUND_HALF_UP));
+        luckStatisDto.setScale(totalMoney.multiply(new BigDecimal(100)).divide(totalMaxAmount, 2, BigDecimal.ROUND_HALF_UP));
         return succeed(luckStatisDto);
     }
 }