Browse Source

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupPaymentCalenderCourseSettingsDao.java
#	mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupPaymentCalenderCourseSettings.java
#	mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentCalenderCourseSettingsMapper.xml
Joburgess 5 years ago
parent
commit
0f4081f785
42 changed files with 1761 additions and 242 deletions
  1. 9 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/LuckDrawCountDao.java
  2. 8 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/LuckDrawGroupDao.java
  3. 8 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/LuckDrawLogDao.java
  4. 23 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/LuckDrawPrizeDao.java
  5. 2 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupOrganizationCourseSettingsDetailDao.java
  6. 10 1
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupPaymentCalenderCourseSettingsDao.java
  7. 9 16
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupPaymentCalenderDao.java
  8. 6 13
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupPaymentCalenderDetailDao.java
  9. 56 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/LuckDrawCount.java
  10. 75 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/LuckDrawGroup.java
  11. 77 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/LuckDrawLog.java
  12. 148 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/LuckDrawPrize.java
  13. 12 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupPaymentCalender.java
  14. 10 8
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupPaymentCalenderCourseSettings.java
  15. 68 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/page/LuckDrawQueryInfo.java
  16. 0 15
      mec-biz/src/main/java/com/ym/mec/biz/dal/page/MusicCalenderQueryInfo.java
  17. 38 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/page/MusicGroupPaymentCalenderQueryInfo.java
  18. 33 0
      mec-biz/src/main/java/com/ym/mec/biz/service/LuckDrawCountService.java
  19. 8 0
      mec-biz/src/main/java/com/ym/mec/biz/service/LuckDrawGroupService.java
  20. 16 0
      mec-biz/src/main/java/com/ym/mec/biz/service/LuckDrawLogService.java
  21. 15 0
      mec-biz/src/main/java/com/ym/mec/biz/service/LuckDrawPrizeService.java
  22. 5 16
      mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupPaymentCalenderService.java
  23. 82 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/LuckDrawCountServiceImpl.java
  24. 23 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/LuckDrawGroupServiceImpl.java
  25. 35 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/LuckDrawLogServiceImpl.java
  26. 147 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/LuckDrawPrizeServiceImpl.java
  27. 208 101
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderServiceImpl.java
  28. 9 9
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java
  29. 5 2
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupSubjectPlanServiceImpl.java
  30. 1 1
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/SporadicChargeInfoImpl.java
  31. 63 0
      mec-biz/src/main/resources/config/mybatis/LuckDrawCountMapper.xml
  32. 63 0
      mec-biz/src/main/resources/config/mybatis/LuckDrawGroupMapper.xml
  33. 108 0
      mec-biz/src/main/resources/config/mybatis/LuckDrawLogMapper.xml
  34. 116 0
      mec-biz/src/main/resources/config/mybatis/LuckDrawPrizeMapper.xml
  35. 4 0
      mec-biz/src/main/resources/config/mybatis/MusicGroupOrganizationCourseSettingsDetailMapper.xml
  36. 17 4
      mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentCalenderCourseSettingsMapper.xml
  37. 1 6
      mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentCalenderDetailMapper.xml
  38. 36 20
      mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentCalenderMapper.xml
  39. 82 0
      mec-student/src/main/java/com/ym/mec/student/controller/LuckDrawController.java
  40. 105 0
      mec-web/src/main/java/com/ym/mec/web/controller/LuckDrawController.java
  41. 15 29
      mec-web/src/main/java/com/ym/mec/web/controller/MusicGroupPaymentCalenderController.java
  42. 5 1
      mec-web/src/main/java/com/ym/mec/web/controller/SporadicChargeInfoController.java

+ 9 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/LuckDrawCountDao.java

@@ -0,0 +1,9 @@
+package com.ym.mec.biz.dal.dao;
+
+import com.ym.mec.biz.dal.entity.LuckDrawCount;
+import com.ym.mec.common.dal.BaseDAO;
+
+public interface LuckDrawCountDao extends BaseDAO<Long, LuckDrawCount> {
+
+	public LuckDrawCount getLock(Long userId);
+}

+ 8 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/LuckDrawGroupDao.java

@@ -0,0 +1,8 @@
+package com.ym.mec.biz.dal.dao;
+
+import com.ym.mec.biz.dal.entity.LuckDrawGroup;
+import com.ym.mec.common.dal.BaseDAO;
+
+public interface LuckDrawGroupDao extends BaseDAO<Integer, LuckDrawGroup> {
+
+}

+ 8 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/LuckDrawLogDao.java

@@ -0,0 +1,8 @@
+package com.ym.mec.biz.dal.dao;
+
+import com.ym.mec.biz.dal.entity.LuckDrawLog;
+import com.ym.mec.common.dal.BaseDAO;
+
+public interface LuckDrawLogDao extends BaseDAO<Long, LuckDrawLog> {
+	
+}

+ 23 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/LuckDrawPrizeDao.java

@@ -0,0 +1,23 @@
+package com.ym.mec.biz.dal.dao;
+
+import java.util.List;
+
+import com.ym.mec.biz.dal.entity.LuckDrawPrize;
+import com.ym.mec.common.dal.BaseDAO;
+
+public interface LuckDrawPrizeDao extends BaseDAO<Integer, LuckDrawPrize> {
+
+	/**
+	 * 查询所有可用记录
+	 * @param group
+	 * @return
+	 */
+	List<LuckDrawPrize> queryEnabledList(int group);
+
+	/**
+	 * 获取锁
+	 * @param id
+	 * @return
+	 */
+	LuckDrawPrize getLock(Integer id);
+}

+ 2 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupOrganizationCourseSettingsDetailDao.java

@@ -11,4 +11,6 @@ public interface MusicGroupOrganizationCourseSettingsDetailDao extends BaseDAO<I
     int batchInsert(@Param("settingDetails") List<MusicGroupOrganizationCourseSettingsDetail> settingDetails);
 
     int deleteBySettingId(@Param("settingId") Integer settingId);
+    
+    List<MusicGroupOrganizationCourseSettingsDetail> queryByMusicGroupOrganizationCourseSettingsId(Integer musicGroupOrganizationCourseSettingsId);
 }

+ 10 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupPaymentCalenderCourseSettingsDao.java

@@ -16,5 +16,14 @@ public interface MusicGroupPaymentCalenderCourseSettingsDao extends BaseDAO<Inte
      * @return java.util.List<com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderCourseSettings>
      */
     List<MusicGroupPaymentCalenderCourseSettings> getWithPaymentCalender(@Param("calenderId") Long calenderId);
-	
+
+	int deleteByMusicGroupPaymentCalenderId(Long musicGroupPaymentCalenderId);
+
+    /**
+     * 获取乐团的缴费课程
+     *
+     * @param musicGroupId
+     * @return
+     */
+    List<MusicGroupPaymentCalenderCourseSettings> getMusicGroupRegCalenderCourseSettings(@Param("musicGroupId") String musicGroupId);
 }

+ 9 - 16
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupPaymentCalenderDao.java

@@ -34,6 +34,15 @@ public interface MusicGroupPaymentCalenderDao extends BaseDAO<Long, MusicGroupPa
      */
     int batchUpdate(List<MusicGroupPaymentCalender> musicGroupPaymentCalenderList);
 
+
+    /**
+     * 批量插入
+     *
+     * @param musicGroupPaymentCalenderList
+     * @return
+     */
+    int batchInsert(List<MusicGroupPaymentCalender> musicGroupPaymentCalenderList);
+
     /**
      * 查询指定状态的记录
      *
@@ -62,22 +71,6 @@ public interface MusicGroupPaymentCalenderDao extends BaseDAO<Long, MusicGroupPa
                                        @Param("deadlinePaymentDate") Date deadlinePaymentDate,@Param("calenderId") Long calenderId);
 
     /**
-     * 统计预计缴费人数
-     *
-     * @param collect
-     * @return
-     */
-    List<Map<Long, Long>> countExpectNum(@Param("collect") Set<Long> collect);
-
-    /**
-     * 统计预计缴费人数
-     *
-     * @param collect
-     * @return
-     */
-    List<Map<Long, Long>> countActualNum(@Param("collect") Set<Long> collect);
-
-    /**
      * 乐团最后一次交费信息
      * @param musicGroupId
      * @return

+ 6 - 13
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupPaymentCalenderDetailDao.java

@@ -1,15 +1,15 @@
 package com.ym.mec.biz.dal.dao;
 
-import com.ym.mec.biz.dal.dto.SimpleUserDto;
-import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderDetail;
-import com.ym.mec.common.dal.BaseDAO;
-import org.apache.ibatis.annotations.Param;
-
-import java.math.BigDecimal;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
+import org.apache.ibatis.annotations.Param;
+
+import com.ym.mec.biz.dal.dto.SimpleUserDto;
+import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderDetail;
+import com.ym.mec.common.dal.BaseDAO;
+
 public interface MusicGroupPaymentCalenderDetailDao extends BaseDAO<Long, MusicGroupPaymentCalenderDetail> {
 
 	/**
@@ -49,13 +49,6 @@ public interface MusicGroupPaymentCalenderDetailDao extends BaseDAO<Long, MusicG
 														 @Param("subjectId") Integer subjectId);
 
 	/**
-	 * 统计实际收款金额
-	 * @param id
-	 * @return
-	 */
-	BigDecimal sumActualAmount(@Param("id") Long id);
-
-	/**
 	 * 获取学生最后一期续费记录
 	 * @param musicGroupId
 	 * @param userId

+ 56 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/LuckDrawCount.java

@@ -0,0 +1,56 @@
+package com.ym.mec.biz.dal.entity;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+public class LuckDrawCount {
+	private Long userId;
+
+	private Integer usedCount;
+
+	private Integer availableCount;
+
+	private BigDecimal availableAmount = new BigDecimal(0);
+
+	private Date modifyOn;
+
+	public Long getUserId() {
+		return userId;
+	}
+
+	public void setUserId(Long userId) {
+		this.userId = userId;
+	}
+
+	public Integer getUsedCount() {
+		return usedCount == null ? 0 : usedCount;
+	}
+
+	public void setUsedCount(Integer usedCount) {
+		this.usedCount = usedCount;
+	}
+
+	public Integer getAvailableCount() {
+		return availableCount == null ? 0 : availableCount;
+	}
+
+	public void setAvailableCount(Integer availableCount) {
+		this.availableCount = availableCount;
+	}
+
+	public BigDecimal getAvailableAmount() {
+		return availableAmount;
+	}
+
+	public void setAvailableAmount(BigDecimal availableAmount) {
+		this.availableAmount = availableAmount;
+	}
+
+	public Date getModifyOn() {
+		return modifyOn;
+	}
+
+	public void setModifyOn(Date modifyOn) {
+		this.modifyOn = modifyOn;
+	}
+}

+ 75 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/LuckDrawGroup.java

@@ -0,0 +1,75 @@
+package com.ym.mec.biz.dal.entity;
+
+import java.util.Date;
+
+public class LuckDrawGroup {
+    private Integer id;
+
+    private String name;
+
+    private String consumeType;
+    
+    private Integer consumeValue;
+
+    private Date startTime;
+
+    private Date endTime;
+
+    private Date createOn;
+
+    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 == null ? null : name.trim();
+    }
+
+    public String getConsumeType() {
+        return consumeType;
+    }
+
+    public void setConsumeType(String consumeType) {
+        this.consumeType = consumeType == null ? null : consumeType.trim();
+    }
+
+    public Integer getConsumeValue() {
+		return consumeValue;
+	}
+
+	public void setConsumeValue(Integer consumeValue) {
+		this.consumeValue = consumeValue;
+	}
+
+	public Date getStartTime() {
+        return startTime;
+    }
+
+    public void setStartTime(Date startTime) {
+        this.startTime = startTime;
+    }
+
+    public Date getEndTime() {
+        return endTime;
+    }
+
+    public void setEndTime(Date endTime) {
+        this.endTime = endTime;
+    }
+
+    public Date getCreateOn() {
+        return createOn;
+    }
+
+    public void setCreateOn(Date createOn) {
+        this.createOn = createOn;
+    }
+}

+ 77 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/LuckDrawLog.java

@@ -0,0 +1,77 @@
+package com.ym.mec.biz.dal.entity;
+
+import java.util.Date;
+
+import com.ym.mec.auth.api.entity.SysUser;
+
+public class LuckDrawLog {
+	private Long id;
+
+	private Integer prizeId;
+
+	private Long userId;
+
+	private Date createOn;
+
+	private LuckDrawPrize luckDrawPrize = new LuckDrawPrize();
+
+	private SysUser user = new SysUser();
+
+	private Integer groupId;
+
+	public Long getId() {
+		return id;
+	}
+
+	public void setId(Long id) {
+		this.id = id;
+	}
+
+	public Integer getPrizeId() {
+		return prizeId;
+	}
+
+	public void setPrizeId(Integer prizeId) {
+		this.prizeId = prizeId;
+	}
+
+	public Long getUserId() {
+		return userId;
+	}
+
+	public void setUserId(Long userId) {
+		this.userId = userId;
+	}
+
+	public Date getCreateOn() {
+		return createOn;
+	}
+
+	public void setCreateOn(Date createOn) {
+		this.createOn = createOn;
+	}
+
+	public LuckDrawPrize getLuckDrawPrize() {
+		return luckDrawPrize;
+	}
+
+	public void setLuckDrawPrize(LuckDrawPrize luckDrawPrize) {
+		this.luckDrawPrize = luckDrawPrize;
+	}
+
+	public SysUser getUser() {
+		return user;
+	}
+
+	public void setUser(SysUser user) {
+		this.user = user;
+	}
+
+	public Integer getGroupId() {
+		return groupId;
+	}
+
+	public void setGroupId(Integer groupId) {
+		this.groupId = groupId;
+	}
+}

+ 148 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/LuckDrawPrize.java

@@ -0,0 +1,148 @@
+package com.ym.mec.biz.dal.entity;
+
+import java.util.Date;
+
+import org.apache.commons.lang.StringUtils;
+
+import com.ym.mec.common.enums.BaseEnum;
+
+public class LuckDrawPrize {
+
+	public enum ActiveRewardType implements BaseEnum<String, ActiveRewardType> {
+
+		/** 优惠券 */
+		COUPON("优惠券"),
+		/** 积分 */
+		POINTS("积分"),
+		/** 现金 */
+		CASH("现金"),
+		/** 抽奖 */
+		LUCK_DRAW("抽奖"),
+		/** 其他 */
+		OTHER("其他");
+
+		private String description;
+
+		private ActiveRewardType(String description) {
+			this.description = description;
+		}
+
+		public String getDescription() {
+			return description;
+		}
+
+		@Override
+		public String getCode() {
+			return this.name();
+		}
+
+		public static ActiveRewardType codeOf(String name) {
+			for (ActiveRewardType type : ActiveRewardType.values()) {
+				if (StringUtils.equals(type.name(), name)) {
+					return type;
+				}
+			}
+			return null;
+		}
+	}
+
+	private Integer id;
+
+	private String name;
+
+	private Double chances;
+
+	private Integer stock;
+
+	private Boolean enabled;
+
+	private ActiveRewardType rewardType;
+
+	private String memo;
+
+	private Date createOn;
+
+	private Date modifyOn;
+
+	private Integer groupId;
+
+	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 == null ? null : name.trim();
+	}
+
+	public Double getChances() {
+		return chances;
+	}
+
+	public void setChances(Double chances) {
+		this.chances = chances;
+	}
+
+	public Integer getStock() {
+		return stock;
+	}
+
+	public void setStock(Integer stock) {
+		this.stock = stock;
+	}
+
+	public Boolean getEnabled() {
+		return enabled;
+	}
+
+	public void setEnabled(Boolean enabled) {
+		this.enabled = enabled;
+	}
+
+	public ActiveRewardType getRewardType() {
+		return rewardType;
+	}
+
+	public void setRewardType(ActiveRewardType rewardType) {
+		this.rewardType = rewardType;
+	}
+
+	public String getMemo() {
+		return memo;
+	}
+
+	public void setMemo(String memo) {
+		this.memo = memo;
+	}
+
+	public Date getCreateOn() {
+		return createOn;
+	}
+
+	public void setCreateOn(Date createOn) {
+		this.createOn = createOn;
+	}
+
+	public Date getModifyOn() {
+		return modifyOn;
+	}
+
+	public void setModifyOn(Date modifyOn) {
+		this.modifyOn = modifyOn;
+	}
+
+	public Integer getGroupId() {
+		return groupId;
+	}
+
+	public void setGroupId(Integer groupId) {
+		this.groupId = groupId;
+	}
+}

+ 12 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupPaymentCalender.java

@@ -2,7 +2,9 @@ package com.ym.mec.biz.dal.entity;
 
 import io.swagger.annotations.ApiModelProperty;
 
+import java.util.ArrayList;
 import java.util.Date;
+import java.util.List;
 
 import org.apache.commons.lang3.builder.ToStringBuilder;
 
@@ -97,6 +99,8 @@ public class MusicGroupPaymentCalender {
 	private java.util.Date updateTime;
 
 	private String studentIds;
+	
+	private List<MusicGroupPaymentCalenderCourseSettings> MusicGroupPaymentCalenderCourseSettingsList = new ArrayList<MusicGroupPaymentCalenderCourseSettings>();
 
 	public Integer getPaymentType() {
 		return paymentType;
@@ -250,6 +254,14 @@ public class MusicGroupPaymentCalender {
 		this.payUserType = payUserType;
 	}
 
+	public List<MusicGroupPaymentCalenderCourseSettings> getMusicGroupPaymentCalenderCourseSettingsList() {
+		return MusicGroupPaymentCalenderCourseSettingsList;
+	}
+
+	public void setMusicGroupPaymentCalenderCourseSettingsList(List<MusicGroupPaymentCalenderCourseSettings> musicGroupPaymentCalenderCourseSettingsList) {
+		MusicGroupPaymentCalenderCourseSettingsList = musicGroupPaymentCalenderCourseSettingsList;
+	}
+
 	@Override
 	public String toString() {
 		return ToStringBuilder.reflectionToString(this);

+ 10 - 8
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupPaymentCalenderCourseSettings.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_calender_course_settings):
  */
@@ -15,7 +17,7 @@ public class MusicGroupPaymentCalenderCourseSettings {
 	
 	/** 课程类型 */
 	private CourseSchedule.CourseScheduleType courseType;
-	
+
 	/** 课程总时间 */
 	private Integer courseTotalMinuties;
 	
@@ -52,14 +54,14 @@ public class MusicGroupPaymentCalenderCourseSettings {
 	public Integer getMusicGroupPaymentCalenderId(){
 		return this.musicGroupPaymentCalenderId;
 	}
-
-	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 Integer getCourseTotalMinuties() {
 		return courseTotalMinuties;
@@ -68,7 +70,7 @@ public class MusicGroupPaymentCalenderCourseSettings {
 	public void setCourseTotalMinuties(Integer courseTotalMinuties) {
 		this.courseTotalMinuties = courseTotalMinuties;
 	}
-
+			
 	public void setUnitPrice(java.math.BigDecimal unitPrice){
 		this.unitPrice = unitPrice;
 	}

+ 68 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/page/LuckDrawQueryInfo.java

@@ -0,0 +1,68 @@
+package com.ym.mec.biz.dal.page;
+
+import java.util.Date;
+
+import com.ym.mec.common.page.QueryInfo;
+
+public class LuckDrawQueryInfo extends QueryInfo {
+
+	private String name;
+
+	private Integer id;
+
+	private Integer userId;
+
+	private Date startDate;
+
+	private Date endDate;
+
+	private Integer groupId;
+
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	public Integer getId() {
+		return id;
+	}
+
+	public void setId(Integer id) {
+		this.id = id;
+	}
+
+	public Integer getUserId() {
+		return userId;
+	}
+
+	public void setUserId(Integer userId) {
+		this.userId = userId;
+	}
+
+	public Date getStartDate() {
+		return startDate;
+	}
+
+	public void setStartDate(Date startDate) {
+		this.startDate = startDate;
+	}
+
+	public Date getEndDate() {
+		return endDate;
+	}
+
+	public void setEndDate(Date endDate) {
+		this.endDate = endDate;
+	}
+
+	public Integer getGroupId() {
+		return groupId;
+	}
+
+	public void setGroupId(Integer groupId) {
+		this.groupId = groupId;
+	}
+}

+ 0 - 15
mec-biz/src/main/java/com/ym/mec/biz/dal/page/MusicCalenderQueryInfo.java

@@ -1,15 +0,0 @@
-package com.ym.mec.biz.dal.page;
-
-import com.ym.mec.common.page.QueryInfo;
-
-public class MusicCalenderQueryInfo extends QueryInfo {
-	private String musicGroupId;
-
-	public String getMusicGroupId() {
-		return musicGroupId;
-	}
-
-	public void setMusicGroupId(String musicGroupId) {
-		this.musicGroupId = musicGroupId;
-	}
-}

+ 38 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/page/MusicGroupPaymentCalenderQueryInfo.java

@@ -0,0 +1,38 @@
+package com.ym.mec.biz.dal.page;
+
+import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PayUserType;
+import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentCalenderStatusEnum;
+import com.ym.mec.common.page.QueryInfo;
+
+public class MusicGroupPaymentCalenderQueryInfo extends QueryInfo {
+	
+	private String musicGroupId;
+	
+	private PayUserType payUserType;
+	
+	private PaymentCalenderStatusEnum status;
+
+	public String getMusicGroupId() {
+		return musicGroupId;
+	}
+
+	public void setMusicGroupId(String musicGroupId) {
+		this.musicGroupId = musicGroupId;
+	}
+
+	public PayUserType getPayUserType() {
+		return payUserType;
+	}
+
+	public void setPayUserType(PayUserType payUserType) {
+		this.payUserType = payUserType;
+	}
+
+	public PaymentCalenderStatusEnum getStatus() {
+		return status;
+	}
+
+	public void setStatus(PaymentCalenderStatusEnum status) {
+		this.status = status;
+	}
+}

+ 33 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/LuckDrawCountService.java

@@ -0,0 +1,33 @@
+package com.ym.mec.biz.service;
+
+import com.ym.mec.biz.dal.entity.LuckDrawCount;
+import com.ym.mec.common.service.BaseService;
+
+public interface LuckDrawCountService extends BaseService<Long, LuckDrawCount> {
+
+	public LuckDrawCount getLock(Long userId);
+
+	/**
+	 * 免费赠送次数
+	 * @param userId
+	 * @param times
+	 * @return
+	 */
+	public boolean freeGive(Long userId, int times);
+
+	/**
+	 * 更新抽奖次数
+	 * @param userId
+	 * @param times
+	 * @return
+	 */
+	public boolean updateTimes(Long userId, int times);
+
+	/**
+	 * 更新抽奖金额
+	 * @param userId
+	 * @param amount 以分为单位
+	 * @return
+	 */
+	public boolean updateAmount(Long userId, Long amount);
+}

+ 8 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/LuckDrawGroupService.java

@@ -0,0 +1,8 @@
+package com.ym.mec.biz.service;
+
+import com.ym.mec.biz.dal.entity.LuckDrawGroup;
+import com.ym.mec.common.service.BaseService;
+
+public interface LuckDrawGroupService extends BaseService<Integer, LuckDrawGroup> {
+
+}

+ 16 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/LuckDrawLogService.java

@@ -0,0 +1,16 @@
+package com.ym.mec.biz.service;
+
+import com.ym.mec.biz.dal.entity.LuckDrawLog;
+import com.ym.mec.common.service.BaseService;
+
+public interface LuckDrawLogService extends BaseService<Long, LuckDrawLog> {
+
+	/**
+	 * 增加中奖记录
+	 * @param userId
+	 * @param prizeId
+	 * @param groupId
+	 * @return
+	 */
+	boolean add(Long userId, Integer prizeId, Integer groupId);
+}

+ 15 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/LuckDrawPrizeService.java

@@ -0,0 +1,15 @@
+package com.ym.mec.biz.service;
+
+import com.ym.mec.biz.dal.entity.LuckDrawPrize;
+import com.ym.mec.common.service.BaseService;
+
+public interface LuckDrawPrizeService extends BaseService<Integer, LuckDrawPrize> {
+
+	/**
+	 * 抽奖
+	 * @param userId 用户编号
+	 * @param group 奖品组
+	 * @return
+	 */
+	public LuckDrawPrize draw(Long userId, int group);
+}

+ 5 - 16
mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupPaymentCalenderService.java

@@ -3,25 +3,21 @@ package com.ym.mec.biz.service;
 import java.util.List;
 
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
-import com.ym.mec.biz.dal.page.MusicCalenderQueryInfo;
-import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.service.BaseService;
 
 public interface MusicGroupPaymentCalenderService extends BaseService<Long, MusicGroupPaymentCalender> {
 
 	/**
-	 * 获取列表
-	 * @param queryInfo
+	 * 创建缴费信息
+	 * @param musicGroupPaymentCalenderList
 	 * @return
 	 */
-	PageInfo<MusicGroupPaymentCalender> queryDetailPage(MusicCalenderQueryInfo queryInfo);
+	boolean create(List<MusicGroupPaymentCalender> musicGroupPaymentCalenderList);
 	
 	/**
-	 * 创建缴费信息
-	 * @param musicGroupPaymentCalender
-	 * @return
+	 * 更新缴费信息
 	 */
-	boolean create(MusicGroupPaymentCalender musicGroupPaymentCalender);
+	int update(MusicGroupPaymentCalender musicGroupPaymentCalender);
 	
 	/**
 	 * 自动更新付款日历记录状态
@@ -48,13 +44,6 @@ public interface MusicGroupPaymentCalenderService extends BaseService<Long, Musi
 	void del(Long id);
 
 	/**
-	 * 获取明细
-	 * @param id
-	 * @return
-	 */
-    Object getDetail(Long id);
-
-	/**
 	 * 推送乐团缴费提醒
 	 * @param id
 	 * @param userIds

+ 82 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/LuckDrawCountServiceImpl.java

@@ -0,0 +1,82 @@
+package com.ym.mec.biz.service.impl;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Propagation;
+import org.springframework.transaction.annotation.Transactional;
+
+import com.ym.mec.biz.dal.dao.LuckDrawCountDao;
+import com.ym.mec.biz.dal.entity.LuckDrawCount;
+import com.ym.mec.biz.service.LuckDrawCountService;
+import com.ym.mec.common.dal.BaseDAO;
+import com.ym.mec.common.service.impl.BaseServiceImpl;
+
+@Service
+public class LuckDrawCountServiceImpl extends BaseServiceImpl<Long, LuckDrawCount> implements LuckDrawCountService {
+
+	@Autowired
+	private LuckDrawCountDao luckDrawCountDao;
+
+	@Override
+	public BaseDAO<Long, LuckDrawCount> getDAO() {
+		return luckDrawCountDao;
+	}
+
+	@Override
+	public LuckDrawCount getLock(Long userId) {
+		return luckDrawCountDao.getLock(userId);
+	}
+
+	@Override
+	@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
+	public boolean freeGive(Long userId, int times) {
+		boolean isInsert = false;
+		LuckDrawCount luckDrawCount = luckDrawCountDao.getLock(userId);
+		if (luckDrawCount == null) {
+			luckDrawCount = new LuckDrawCount();
+			luckDrawCount.setUserId(userId);
+			isInsert = true;
+		}
+		luckDrawCount.setAvailableCount(luckDrawCount.getAvailableCount() + times);
+		luckDrawCount.setModifyOn(new Date());
+
+		return isInsert ? insert(luckDrawCount) > 0 : update(luckDrawCount) > 0;
+	}
+
+	@Override
+	@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
+	public boolean updateTimes(Long userId, int times) {
+		boolean isInsert = false;
+		LuckDrawCount luckDrawCount = luckDrawCountDao.getLock(userId);
+		if (luckDrawCount == null) {
+			luckDrawCount = new LuckDrawCount();
+			luckDrawCount.setUserId(userId);
+			isInsert = true;
+		}
+		luckDrawCount.setAvailableCount(luckDrawCount.getAvailableCount() + times);
+		luckDrawCount.setModifyOn(new Date());
+		return isInsert ? insert(luckDrawCount) > 0 : update(luckDrawCount) > 0;
+	}
+
+	@Override
+	@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
+	public boolean updateAmount(Long userId, Long amount) {
+		boolean isInsert = false;
+		LuckDrawCount luckDrawCount = luckDrawCountDao.getLock(userId);
+		if (luckDrawCount == null) {
+			luckDrawCount = new LuckDrawCount();
+			luckDrawCount.setUserId(userId);
+			isInsert = true;
+		}
+		luckDrawCount.setAvailableAmount(luckDrawCount.getAvailableAmount().add(new BigDecimal(amount)));
+		if (amount < 0) {
+			luckDrawCount.setUsedCount(luckDrawCount.getUsedCount() + 1);
+		}
+		luckDrawCount.setModifyOn(new Date());
+		return isInsert ? insert(luckDrawCount) > 0 : update(luckDrawCount) > 0;
+	}
+
+}

+ 23 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/LuckDrawGroupServiceImpl.java

@@ -0,0 +1,23 @@
+package com.ym.mec.biz.service.impl;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import com.ym.mec.biz.dal.dao.LuckDrawGroupDao;
+import com.ym.mec.biz.dal.entity.LuckDrawGroup;
+import com.ym.mec.biz.service.LuckDrawGroupService;
+import com.ym.mec.common.dal.BaseDAO;
+import com.ym.mec.common.service.impl.BaseServiceImpl;
+
+@Service
+public class LuckDrawGroupServiceImpl extends BaseServiceImpl<Integer, LuckDrawGroup> implements LuckDrawGroupService {
+
+	@Autowired
+	private LuckDrawGroupDao luckDrawGroupDao;
+
+	@Override
+	public BaseDAO<Integer, LuckDrawGroup> getDAO() {
+		return luckDrawGroupDao;
+	}
+
+}

+ 35 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/LuckDrawLogServiceImpl.java

@@ -0,0 +1,35 @@
+package com.ym.mec.biz.service.impl;
+
+import java.util.Date;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import com.ym.mec.biz.dal.dao.LuckDrawLogDao;
+import com.ym.mec.biz.dal.entity.LuckDrawLog;
+import com.ym.mec.biz.service.LuckDrawLogService;
+import com.ym.mec.common.dal.BaseDAO;
+import com.ym.mec.common.service.impl.BaseServiceImpl;
+
+@Service
+public class LuckDrawLogServiceImpl extends BaseServiceImpl<Long, LuckDrawLog> implements LuckDrawLogService {
+
+	@Autowired
+	private LuckDrawLogDao luckDrawLogDao;
+
+	@Override
+	public BaseDAO<Long, LuckDrawLog> getDAO() {
+		return luckDrawLogDao;
+	}
+
+	@Override
+	public boolean add(Long userId, Integer prizeId, Integer groupId) {
+		LuckDrawLog log = new LuckDrawLog();
+		log.setPrizeId(prizeId);
+		log.setUserId(userId);
+		log.setGroupId(groupId);
+		log.setCreateOn(new Date());
+		return luckDrawLogDao.insert(log) > 0;
+	}
+
+}

+ 147 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/LuckDrawPrizeServiceImpl.java

@@ -0,0 +1,147 @@
+package com.ym.mec.biz.service.impl;
+
+import java.util.Date;
+import java.util.List;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.FutureTask;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.math.RandomUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Propagation;
+import org.springframework.transaction.annotation.Transactional;
+
+import com.ym.mec.biz.dal.dao.LuckDrawPrizeDao;
+import com.ym.mec.biz.dal.entity.LuckDrawCount;
+import com.ym.mec.biz.dal.entity.LuckDrawGroup;
+import com.ym.mec.biz.dal.entity.LuckDrawPrize;
+import com.ym.mec.biz.service.LuckDrawCountService;
+import com.ym.mec.biz.service.LuckDrawGroupService;
+import com.ym.mec.biz.service.LuckDrawLogService;
+import com.ym.mec.biz.service.LuckDrawPrizeService;
+import com.ym.mec.common.dal.BaseDAO;
+import com.ym.mec.common.exception.BizException;
+import com.ym.mec.common.service.impl.BaseServiceImpl;
+
+@Service
+public class LuckDrawPrizeServiceImpl extends BaseServiceImpl<Integer, LuckDrawPrize> implements LuckDrawPrizeService {
+
+	/** 抽奖概率的固定基数 */
+	private final int DRAW_BASE_NUMBER = 100000;
+
+	@Autowired
+	private LuckDrawPrizeDao luckDrawPrizeDao;
+
+	@Autowired
+	private LuckDrawLogService luckDrawLogService;
+
+	@Autowired
+	private LuckDrawCountService luckDrawCountService;
+
+	@Autowired
+	private LuckDrawGroupService luckDrawGroupService;
+
+	@Override
+	public BaseDAO<Integer, LuckDrawPrize> getDAO() {
+		return luckDrawPrizeDao;
+	}
+
+	@Override
+	@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
+	public LuckDrawPrize draw(final Long userId, int group) {
+		final LuckDrawGroup luckDrawGroup = luckDrawGroupService.get(group);
+		if (luckDrawGroup == null) {
+			throw new BizException("系统出错");
+		}
+		Date currentDate = new Date();
+		// 是否过期
+		if (currentDate.before(luckDrawGroup.getStartTime()) || currentDate.after(luckDrawGroup.getEndTime())) {
+			throw new BizException("抽奖未开始或已结束");
+		}
+
+		int consumeValue = luckDrawGroup.getConsumeValue();
+		String consumeType = luckDrawGroup.getConsumeType();
+
+		if (StringUtils.equalsIgnoreCase("TIMES", consumeType)) {
+			// 判断是否有抽奖机会
+			LuckDrawCount luckDrawCount = luckDrawCountService.getLock(userId);
+			if (luckDrawCount == null) {
+				throw new BizException("当前没有抽奖机会");
+			}
+			if (luckDrawCount.getAvailableCount() <= 0) {
+				throw new BizException("当前没有抽奖机会");
+			}
+			// 更新抽奖机会
+			luckDrawCount.setAvailableCount(luckDrawCount.getAvailableCount() - consumeValue);
+			luckDrawCount.setModifyOn(currentDate);
+			if (luckDrawCount.getUsedCount() == null) {
+				luckDrawCount.setUsedCount(1);
+			} else {
+				luckDrawCount.setUsedCount(luckDrawCount.getUsedCount() + consumeValue);
+			}
+			luckDrawCountService.update(luckDrawCount);
+		} else {
+			throw new BizException("系统数据异常");
+		}
+		// 抽奖逻辑
+		List<LuckDrawPrize> luckDraws = luckDrawPrizeDao.queryEnabledList(group);
+		if (luckDraws != null) {
+			int randomNum = RandomUtils.nextInt(DRAW_BASE_NUMBER);
+			double start = 0;
+			double chances = 0;
+			ExecutorService executor = Executors.newCachedThreadPool();
+			for (LuckDrawPrize luckDraw : luckDraws) {
+				chances += luckDraw.getChances();
+				// 抽中了
+				if (start <= randomNum && randomNum < (chances * DRAW_BASE_NUMBER)) {
+					final LuckDrawPrize syncLuckDraw = luckDrawPrizeDao.getLock(luckDraw.getId());
+					// 检查库存
+					if (syncLuckDraw.getStock() > 0) {
+						Date date = new Date();
+						// 减库存
+						syncLuckDraw.setStock(syncLuckDraw.getStock() - 1);
+						syncLuckDraw.setModifyOn(date);
+						update(syncLuckDraw);
+						// 抽奖记录
+						luckDrawLogService.add(userId, syncLuckDraw.getId(), group);
+
+						// 给奖励
+						FutureTask<String> task = new FutureTask<String>(new Callable<String>() {
+							@Override
+							public String call() throws Exception {
+
+								switch (syncLuckDraw.getRewardType()) {
+								case COUPON:
+									break;
+
+								case POINTS:
+									break;
+
+								case CASH:
+									break;
+
+								default:
+									break;
+								}
+
+								return null;
+							}
+						});
+						executor.submit(task);
+						executor.shutdown();
+
+						return syncLuckDraw;
+					} else {
+						throw new BizException("系统繁忙,请重试");
+					}
+				}
+				start = luckDraw.getChances() * DRAW_BASE_NUMBER;
+			}
+		}
+		return null;
+	}
+
+}

+ 208 - 101
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderServiceImpl.java

@@ -8,6 +8,7 @@ import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Map.Entry;
 import java.util.Set;
 import java.util.stream.Collectors;
 
@@ -17,26 +18,30 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import com.ym.mec.biz.dal.dao.MusicGroupDao;
+import com.ym.mec.biz.dal.dao.MusicGroupOrganizationCourseSettingsDetailDao;
+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.MusicGroupStudentFeeDao;
 import com.ym.mec.biz.dal.dao.SysConfigDao;
 import com.ym.mec.biz.dal.dto.CalenderPushDto;
+import com.ym.mec.biz.dal.entity.CourseSchedule.CourseScheduleType;
 import com.ym.mec.biz.dal.entity.MusicGroup;
+import com.ym.mec.biz.dal.entity.MusicGroupOrganizationCourseSettingsDetail;
 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.MusicGroupStudentFee;
 import com.ym.mec.biz.dal.entity.MusicGroupStudentFee.PaymentStatus;
 import com.ym.mec.biz.dal.enums.MessageTypeEnum;
+import com.ym.mec.biz.dal.enums.MusicGroupStatusEnum;
 import com.ym.mec.biz.dal.enums.PaymentStatusEnum;
-import com.ym.mec.biz.dal.page.MusicCalenderQueryInfo;
 import com.ym.mec.biz.service.MusicGroupPaymentCalenderService;
 import com.ym.mec.biz.service.SysConfigService;
 import com.ym.mec.biz.service.SysMessageService;
 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.thirdparty.message.MessageSenderPluginContext;
 import com.ym.mec.util.collection.MapUtil;
@@ -51,6 +56,13 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 	private MusicGroupPaymentCalenderDetailDao musicGroupPaymentCalenderDetailDao;
 	@Autowired
 	private MusicGroupStudentFeeDao musicGroupStudentFeeDao;
+	
+	@Autowired
+	private MusicGroupPaymentCalenderCourseSettingsDao musicGroupPaymentCalenderCourseSettingsDao;
+	
+	@Autowired
+	private MusicGroupOrganizationCourseSettingsDetailDao musicGroupOrganizationCourseSettingsDetailDao;
+	
 	@Autowired
 	private MusicGroupDao musicGroupDao;
 	@Autowired
@@ -64,120 +76,219 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 	}
 
 	@Override
-	public PageInfo<MusicGroupPaymentCalender> queryDetailPage(MusicCalenderQueryInfo queryInfo) {
-		PageInfo<MusicGroupPaymentCalender> pageInfo = queryPage(queryInfo);
-		List<MusicGroupPaymentCalender> rows = pageInfo.getRows();
-		if (rows.size() == 0) {
-			return pageInfo;
-		}
-		Set<Long> collect = rows.stream().map(e -> e.getId()).collect(Collectors.toSet());
-		Map<Long, Long> expectNumMap = MapUtil.convertIntegerMap(musicGroupPaymentCalenderDao.countExpectNum(collect));
-		Map<Long, Long> actualNumMap = MapUtil.convertIntegerMap(musicGroupPaymentCalenderDao.countActualNum(collect));
-		rows.forEach(e -> {
-			e.setActualNum(actualNumMap.get(e.getId()) == null ? 0 : actualNumMap.get(e.getId()).intValue());
-			e.setExpectNum(expectNumMap.get(e.getId()) == null ? 0 : expectNumMap.get(e.getId()).intValue());
-		});
-		return pageInfo;
+	@Transactional(rollbackFor = Exception.class)
+	public boolean create(List<MusicGroupPaymentCalender> musicGroupPaymentCalenderList) {
+		if(musicGroupPaymentCalenderList == null || musicGroupPaymentCalenderList.size() == 0){
+			throw new BizException("请重新创建缴费记录");
+		}
+		
+		String musicGroupId = musicGroupPaymentCalenderList.get(0).getMusicGroupId();
+
+		MusicGroup musicGroup = musicGroupDao.getLocked(musicGroupId);
+		
+		if(musicGroup == null){
+			throw new BizException("乐团查询失败,请检查参数");
+		}
+
+		Date date = new Date();
+		Map<Integer, String> pushUserMap = new HashMap<Integer, String>();
+		MusicGroupPaymentCalenderDetail musicGroupPaymentCalenderDetail = null;
+		List<MusicGroupPaymentCalenderDetail> musicGroupPaymentCalenderDetailList = new ArrayList<MusicGroupPaymentCalenderDetail>();
+
+		for(MusicGroupPaymentCalender musicGroupPaymentCalender : musicGroupPaymentCalenderList){
+			musicGroupPaymentCalender.setCreateTime(date);
+			musicGroupPaymentCalender.setUpdateTime(date);
+			if (musicGroupPaymentCalender.getDeadlinePaymentDate() == null) {
+				musicGroupPaymentCalender.setDeadlinePaymentDate(DateUtil.addDays(musicGroupPaymentCalender.getStartPaymentDate(), 3));
+			}
+			int count = musicGroupPaymentCalenderDao.queryIntersectionByValidDate(musicGroupId, musicGroupPaymentCalender.getPaymentValidStartDate(),
+					musicGroupPaymentCalender.getPaymentValidEndDate(), null);
+			if (count > 0) {
+				throw new BizException("缴费有效期存在冲突,请修改缴费有效期");
+			}
+			
+			//查询默认课程费用
+			Integer musicGroupOrganizationCourseSettingId = musicGroupPaymentCalender.getMusicGroupOrganizationCourseSettingId();
+			Map<CourseScheduleType, BigDecimal> defaultCoursePrice = musicGroupOrganizationCourseSettingsDetailDao.queryByMusicGroupOrganizationCourseSettingsId(musicGroupOrganizationCourseSettingId).stream().collect(Collectors.toMap(MusicGroupOrganizationCourseSettingsDetail :: getCourseType, MusicGroupOrganizationCourseSettingsDetail :: getCourseCurrentPrice));
+			
+			//当前缴费的课程费用
+			Map<CourseScheduleType,BigDecimal> currentCoursePrice = musicGroupPaymentCalender.getMusicGroupPaymentCalenderCourseSettingsList().stream().collect(Collectors.toMap(MusicGroupPaymentCalenderCourseSettings :: getCourseType, MusicGroupPaymentCalenderCourseSettings :: getCourseCurrentPrice));
+			
+			BigDecimal totalPrice = new BigDecimal(0);
+			//相同类型的课程如果修改了课程费用,需要走审批
+			for(Entry<CourseScheduleType, BigDecimal> entry : currentCoursePrice.entrySet()){
+				if(defaultCoursePrice.get(entry.getKey()).compareTo(entry.getValue()) != 0){
+					musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.AUDITING);
+				}
+				totalPrice.add(entry.getValue());
+			}
+			
+			if (musicGroupPaymentCalender.getStatus() != PaymentCalenderStatusEnum.AUDITING) {
+				if (date.after(musicGroupPaymentCalender.getDeadlinePaymentDate())) {
+					musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.OVER);
+				} else if (date.after(musicGroupPaymentCalender.getStartPaymentDate())) {
+					musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.OPEN);
+				} else {
+					musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.NO);
+				}
+				
+				//如果是报名,需要修改乐团状态
+				if (musicGroupPaymentCalender.getPaymentType() == 1) {
+					musicGroup.setStatus(MusicGroupStatusEnum.AUDIT);
+					musicGroup.setUpdateTime(date);
+					musicGroupDao.update(musicGroup);
+				}
+			}
+
+			musicGroupPaymentCalender.setExpectNum(0);
+			if(StringUtils.isNoneBlank(musicGroupPaymentCalender.getStudentIds())){
+				String[] sutdentIdList = musicGroupPaymentCalender.getStudentIds().split(",");
+				musicGroupPaymentCalender.setExpectNum(sutdentIdList.length);
+				
+				if (musicGroupPaymentCalender.getStatus() == PaymentCalenderStatusEnum.OPEN) {
+					for(String studentId : sutdentIdList){
+						pushUserMap.put(Integer.parseInt(studentId), studentId);
+					}
+				}
+				
+				//创建缴费明细
+				for(String studentId : sutdentIdList){
+					musicGroupPaymentCalenderDetail = new MusicGroupPaymentCalenderDetail();
+					musicGroupPaymentCalenderDetail.setMusicGroupPaymentCalenderId(musicGroupPaymentCalender.getId());
+					musicGroupPaymentCalenderDetail.setCreateTime(date);
+					musicGroupPaymentCalenderDetail.setExpectAmount(totalPrice);
+					musicGroupPaymentCalenderDetail.setPaymentStatus(PaymentStatus.NON_PAYMENT);
+					musicGroupPaymentCalenderDetail.setUpdateTime(date);
+					musicGroupPaymentCalenderDetail.setUserId(Integer.parseInt(studentId));
+					
+					musicGroupPaymentCalenderDetailList.add(musicGroupPaymentCalenderDetail);
+				}
+			}
+		}
+
+		if (musicGroupPaymentCalenderDetailList.size() > 0) {
+			musicGroupPaymentCalenderDetailDao.batchInsert(musicGroupPaymentCalenderDetailList);
+		}
+		
+		if(musicGroupPaymentCalenderList.size() > 0){
+			musicGroupPaymentCalenderDao.batchInsert(musicGroupPaymentCalenderList);
+		}
+		
+		// 发送续费通知
+		if (pushUserMap.size() > 0) {
+			String configValue = sysConfigDao.findConfigValue(SysConfigService.BASE_API_URL);
+			String memo = "4?" + configValue + "/#/renew?musicGroupId=" + musicGroup.getId();
+
+			sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.STUDENT_PUSH_WAIT_RENEW_MESSAGE,
+					pushUserMap, null, 0, memo, "STUDENT", musicGroup.getName());
+		}
+
+		return true;
 	}
 
 	@Override
 	@Transactional(rollbackFor = Exception.class)
-	public boolean create(MusicGroupPaymentCalender musicGroupPaymentCalender) {
+	public int update(MusicGroupPaymentCalender musicGroupPaymentCalender) {
 		String musicGroupId = musicGroupPaymentCalender.getMusicGroupId();
 
-		musicGroupDao.getLocked(musicGroupId);
-
+		MusicGroup musicGroup = musicGroupDao.getLocked(musicGroupId);
+		
+		if(musicGroup == null){
+			throw new BizException("乐团查询失败,请检查参数");
+		}
+		
 		Date date = new Date();
-		List<MusicGroupStudentFee> musicGroupStudentFeeList = null;
-
-		musicGroupPaymentCalender.setCreateTime(date);
+		
 		musicGroupPaymentCalender.setUpdateTime(date);
 		if (musicGroupPaymentCalender.getDeadlinePaymentDate() == null) {
 			musicGroupPaymentCalender.setDeadlinePaymentDate(DateUtil.addDays(musicGroupPaymentCalender.getStartPaymentDate(), 3));
 		}
-		// 判断缴费开始时间、结束时间是否被其他缴费记录占用
-		int count = musicGroupPaymentCalenderDao.queryIntersectionByPaymentDate(musicGroupId, musicGroupPaymentCalender.getStartPaymentDate(),
-				musicGroupPaymentCalender.getDeadlinePaymentDate(), null);
-
-		// String format = DateUtil.format(musicGroupPaymentCalender.getStartPaymentDate(), DateUtil.DEFAULT_PATTERN);
-		// String format1 = DateUtil.format(musicGroupPaymentCalender.getDeadlinePaymentDate(), DateUtil.DEFAULT_PATTERN);
-		// int count = musicGroupPaymentCalenderDao.queryIntersectionByDate(musicGroupId, format,format1);
-		if (count > 0) {
-			throw new BizException("缴费日期存在冲突,请修改缴费日期");
-		}
-		count = musicGroupPaymentCalenderDao.queryIntersectionByValidDate(musicGroupId, musicGroupPaymentCalender.getPaymentValidStartDate(),
+		int count = musicGroupPaymentCalenderDao.queryIntersectionByValidDate(musicGroupId, musicGroupPaymentCalender.getPaymentValidStartDate(),
 				musicGroupPaymentCalender.getPaymentValidEndDate(), null);
 		if (count > 0) {
 			throw new BizException("缴费有效期存在冲突,请修改缴费有效期");
 		}
-		if (date.after(musicGroupPaymentCalender.getDeadlinePaymentDate())) {
-			musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.OVER);
-		} else if (date.after(musicGroupPaymentCalender.getStartPaymentDate())) {
-			musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.OPEN);
-		} else {
-			musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.NO);
+		
+		//查询默认课程费用
+		Integer musicGroupOrganizationCourseSettingId = musicGroupPaymentCalender.getMusicGroupOrganizationCourseSettingId();
+		Map<CourseScheduleType, BigDecimal> defaultCoursePrice = musicGroupOrganizationCourseSettingsDetailDao.queryByMusicGroupOrganizationCourseSettingsId(musicGroupOrganizationCourseSettingId).stream().collect(Collectors.toMap(MusicGroupOrganizationCourseSettingsDetail :: getCourseType, MusicGroupOrganizationCourseSettingsDetail :: getCourseCurrentPrice));
+		
+		//当前缴费的课程费用
+		Map<CourseScheduleType,BigDecimal> currentCoursePrice = musicGroupPaymentCalender.getMusicGroupPaymentCalenderCourseSettingsList().stream().collect(Collectors.toMap(MusicGroupPaymentCalenderCourseSettings :: getCourseType, MusicGroupPaymentCalenderCourseSettings :: getCourseCurrentPrice));
+		
+		BigDecimal totalPrice = new BigDecimal(0);
+		//相同类型的课程如果修改了课程费用,需要走审批
+		for(Entry<CourseScheduleType, BigDecimal> entry : currentCoursePrice.entrySet()){
+			if(defaultCoursePrice.get(entry.getKey()).compareTo(entry.getValue()) != 0){
+				musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.AUDITING);
+			}
+			totalPrice.add(entry.getValue());
 		}
-		// 统计缴费人数
-		musicGroupStudentFeeList = musicGroupStudentFeeDao.queryByMusicGroupId(musicGroupId, musicGroupPaymentCalender.getStudentIds());
-		if (musicGroupStudentFeeList == null) {
-			musicGroupStudentFeeList = new ArrayList<>();
+		
+		if (musicGroupPaymentCalender.getStatus() != PaymentCalenderStatusEnum.AUDITING) {
+			if (date.after(musicGroupPaymentCalender.getDeadlinePaymentDate())) {
+				musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.OVER);
+			} else if (date.after(musicGroupPaymentCalender.getStartPaymentDate())) {
+				musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.OPEN);
+			} else {
+				musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.NO);
+			}
+			
+			//如果是报名,需要修改乐团状态
+			if (musicGroupPaymentCalender.getPaymentType() == 1) {
+				musicGroup.setStatus(MusicGroupStatusEnum.AUDIT);
+				musicGroup.setUpdateTime(date);
+				musicGroupDao.update(musicGroup);
+			}
 		}
-		musicGroupPaymentCalender.setExpectNum(musicGroupStudentFeeList.size());
-
-		this.insert(musicGroupPaymentCalender);
-
-		List<MusicGroupStudentFee> updateMusicGroupStudentFeeList = new ArrayList<MusicGroupStudentFee>();
-
 		List<MusicGroupPaymentCalenderDetail> musicGroupPaymentCalenderDetailList = new ArrayList<MusicGroupPaymentCalenderDetail>();
+		Map<Integer, String> pushUserMap = new HashMap<Integer, String>();
 
-		if (musicGroupStudentFeeList != null && musicGroupStudentFeeList.size() > 0) {
-			Set<Integer> studentIds = new HashSet<>();
+		musicGroupPaymentCalender.setExpectNum(0);
+		if(StringUtils.isNoneBlank(musicGroupPaymentCalender.getStudentIds())){
+			String[] sutdentIdList = musicGroupPaymentCalender.getStudentIds().split(",");
+			musicGroupPaymentCalender.setExpectNum(sutdentIdList.length);
+			
+			if (musicGroupPaymentCalender.getStatus() == PaymentCalenderStatusEnum.OPEN) {
+				for(String studentId : sutdentIdList){
+					pushUserMap.put(Integer.parseInt(studentId), studentId);
+				}
+			}
+			
+			//删除历史数据
+			musicGroupPaymentCalenderDetailDao.deleteByCalenderId(musicGroupPaymentCalender.getId());
+			
+			//创建缴费明细
 			MusicGroupPaymentCalenderDetail musicGroupPaymentCalenderDetail = null;
-			// 创建缴费明细
-			for (MusicGroupStudentFee mgsf : musicGroupStudentFeeList) {
+			for(String studentId : sutdentIdList){
 				musicGroupPaymentCalenderDetail = new MusicGroupPaymentCalenderDetail();
 				musicGroupPaymentCalenderDetail.setMusicGroupPaymentCalenderId(musicGroupPaymentCalender.getId());
 				musicGroupPaymentCalenderDetail.setCreateTime(date);
-				musicGroupPaymentCalenderDetail.setExpectAmount(mgsf.getCourseFee());
+				musicGroupPaymentCalenderDetail.setExpectAmount(totalPrice);
 				musicGroupPaymentCalenderDetail.setPaymentStatus(PaymentStatus.NON_PAYMENT);
-				if (mgsf.getCourseFee().doubleValue() != 0) {
-					studentIds.add(mgsf.getUserId());
-				}
 				musicGroupPaymentCalenderDetail.setUpdateTime(date);
-				musicGroupPaymentCalenderDetail.setUserId(mgsf.getUserId());
+				musicGroupPaymentCalenderDetail.setUserId(Integer.parseInt(studentId));
+				
 				musicGroupPaymentCalenderDetailList.add(musicGroupPaymentCalenderDetail);
 			}
-			if (musicGroupPaymentCalender.getStatus() == PaymentCalenderStatusEnum.OPEN) {
-				// 更新学员缴费状态
-				for (MusicGroupStudentFee mgsf : musicGroupStudentFeeList) {
-					mgsf.setPaymentStatus(PaymentStatus.NON_PAYMENT);
-					mgsf.setUpdateTime(date);
-					updateMusicGroupStudentFeeList.add(mgsf);
-				}
-				if (studentIds.size() > 0) {
-					Map<Integer, String> push = new HashMap<>();
-					for (Integer userId : studentIds) {
-						push.put(userId, userId + "");
-					}
-					MusicGroup musicGroup = musicGroupDao.get(musicGroupPaymentCalender.getMusicGroupId());
-					String configValue = sysConfigDao.findConfigValue(SysConfigService.BASE_API_URL);
-					String memo = "4?" + configValue + "/#/renew?musicGroupId=" + musicGroup.getId();
-					// 发送续费通知
-					sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.STUDENT_PUSH_WAIT_RENEW_MESSAGE, push,
-							null, 0, memo, "STUDENT", musicGroup.getName());
-				}
-			}
 		}
+		
+		musicGroupPaymentCalenderDao.update(musicGroupPaymentCalender);
 
 		if (musicGroupPaymentCalenderDetailList.size() > 0) {
 			musicGroupPaymentCalenderDetailDao.batchInsert(musicGroupPaymentCalenderDetailList);
 		}
-
-		if (updateMusicGroupStudentFeeList.size() > 0) {
-			musicGroupStudentFeeDao.batchUpdate(updateMusicGroupStudentFeeList);
+		
+		// 发送续费通知
+		if (pushUserMap.size() > 0) {
+			String configValue = sysConfigDao.findConfigValue(SysConfigService.BASE_API_URL);
+			String memo = "4?" + configValue + "/#/renew?musicGroupId=" + musicGroup.getId();
+
+			sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.STUDENT_PUSH_WAIT_RENEW_MESSAGE,
+					pushUserMap, null, 0, memo, "STUDENT", musicGroup.getName());
 		}
-
-		return true;
+		
+		return 1;
 	}
 
 	@Override
@@ -439,27 +550,23 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 		if (calender == null) {
 			throw new BizException("缴费信息不存在");
 		}
-		if (calender.getStatus() == null || calender.getStatus() != PaymentCalenderStatusEnum.NO) {
-			throw new BizException("删除失败,缴费状态不匹配");
+		if (calender.getStatus() != PaymentCalenderStatusEnum.NO || calender.getStatus() != PaymentCalenderStatusEnum.REJECT) {
+			throw new BizException("删除失败,只有“拒绝”或“未开启缴费”状态才能删除");
+		}
+
+		List<MusicGroupPaymentCalenderDetail> musicGroupPaymentCalenderDetailList = musicGroupPaymentCalenderDetailDao.queryByCalenderId(id);
+		if (musicGroupPaymentCalenderDetailList != null && musicGroupPaymentCalenderDetailList.size() > 0) {
+			List<MusicGroupPaymentCalenderDetail> paidList = musicGroupPaymentCalenderDetailList.stream()
+					.filter(MusicGroupPaymentCalenderDetail -> MusicGroupPaymentCalenderDetail.getPaymentStatus() != PaymentStatus.NON_PAYMENT)
+					.collect(Collectors.toList());
+			if (paidList.size() > 0) {
+				throw new BizException("存在已缴费的学生不能删除");
+			}
 		}
+
 		musicGroupPaymentCalenderDao.delete(id);
 		musicGroupPaymentCalenderDetailDao.deleteByCalenderId(id);
-	}
-
-	@Override
-	public Object getDetail(Long id) {
-		MusicGroupPaymentCalender calender = musicGroupPaymentCalenderDao.get(id);
-		Set<Long> set = new HashSet<>();
-		set.add(id);
-		Map<Long, Long> expectNumMap = MapUtil.convertIntegerMap(musicGroupPaymentCalenderDao.countExpectNum(set));
-		Map<Long, Long> actualNumMap = MapUtil.convertIntegerMap(musicGroupPaymentCalenderDao.countActualNum(set));
-		calender.setActualNum(actualNumMap.get(id) == null ? 0 : actualNumMap.get(id).intValue());
-		calender.setExpectNum(expectNumMap.get(id) == null ? 0 : expectNumMap.get(id).intValue());
-		BigDecimal sumActualAmount = musicGroupPaymentCalenderDetailDao.sumActualAmount(id);
-		Map<String, Object> result = new HashMap<>(2);
-		result.put("calender", calender);
-		result.put("sumActualAmount", sumActualAmount);
-		return result;
+		musicGroupPaymentCalenderCourseSettingsDao.deleteByMusicGroupPaymentCalenderId(id);
 	}
 
 	@Override

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

@@ -383,7 +383,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         if (chargeInfo == null) {
             throw new BizException("支付项不存在");
         }
-        if(chargeInfo.getOpenFlag().equals(1)){
+        if (chargeInfo.getOpenFlag().equals(1)) {
             throw new BizException("项目已关闭");
         }
         BigDecimal amount = chargeInfo.getAmount();
@@ -398,7 +398,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
             boolean flag = false;
             for (int i = 1; i <= 10; i++) {
                 chargeInfo = sporadicChargeInfoDao.get(sporadicPayDto.getSporadicId());
-                if (chargeInfo.getMaxNum() >= chargeInfo.getPaidNum()) {
+                if (chargeInfo.getMaxNum() != null && chargeInfo.getMaxNum() <= chargeInfo.getPaidNum()) {
                     throw new BizException("活动人数暂时已满,请稍后再试");
                 }
                 chargeInfo.setPaidNum(chargeInfo.getPaidNum() + 1);
@@ -415,7 +415,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         }
 
         OrderTypeEnum type = OrderTypeEnum.SPORADIC;
-        if(chargeInfo.getChargeType().equals(SporadicChargeTypeEnum.DOUBLE_ELEVEN2020)){
+        if (chargeInfo.getChargeType().equals(SporadicChargeTypeEnum.DOUBLE_ELEVEN2020)) {
             type = OrderTypeEnum.DOUBLE_ELEVEN2020;
         }
 
@@ -643,7 +643,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 
         String channelType = "";
 
-        StudentPaymentOrder studentPaymentOrder = studentRegistrationService.addOrder(studentRegistration, amount, orderNo, channelType, courseFee, goodsGroups, goodsList, otherGoodsList, courseForms,remitFee,courseRemitFee);
+        StudentPaymentOrder studentPaymentOrder = studentRegistrationService.addOrder(studentRegistration, amount, orderNo, channelType, courseFee, goodsGroups, goodsList, otherGoodsList, courseForms, remitFee, courseRemitFee);
         studentPaymentOrder.setVersion(0);
 
         Date date = new Date();
@@ -850,7 +850,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 
         String channelType = "";
 
-        StudentPaymentOrder studentPaymentOrder = studentRegistrationService.reAddOrder(userId, amount, orderNo, channelType, courseFee, goodsGroups, goodsList, otherGoodsList, studentRegistration.getMusicGroupId(), ApplyOrder, courseForms,remitFee,courseRemitFee);
+        StudentPaymentOrder studentPaymentOrder = studentRegistrationService.reAddOrder(userId, amount, orderNo, channelType, courseFee, goodsGroups, goodsList, otherGoodsList, studentRegistration.getMusicGroupId(), ApplyOrder, courseForms, remitFee, courseRemitFee);
         studentPaymentOrder.setVersion(0);
         Date date = new Date();
 
@@ -1451,7 +1451,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
     }
 
     @Override
-	public boolean extensionApplyExpireDate(String musicGroupId, Date expireDate) {
+    public boolean extensionApplyExpireDate(String musicGroupId, Date expireDate) {
         SysUser sysUser = sysUserFeignService.queryUserInfo();
         if (sysUser == null) {
             throw new BizException("用户信息获取失败");
@@ -1478,7 +1478,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         return true;
     }
 
-	@Override
+    @Override
     @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
     public boolean applyQuitMusicGroup(String musicGroupId) {
         SysUser sysUser = sysUserFeignService.queryUserInfo();
@@ -1540,7 +1540,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
                 if (classGroup.getType().equals(ClassGroupTypeEnum.MUSIC_NETWORK)) {
                     classGroupService.delSingle(classGroupId);
                 } else {
-                    classGroupStudentMapperService.delClassGroupStudent(userId, classGroupId,true);
+                    classGroupStudentMapperService.delClassGroupStudent(userId, classGroupId, true);
                 }
             }
 
@@ -1642,7 +1642,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
             if (classGroup.getType().equals(ClassGroupTypeEnum.MUSIC_NETWORK)) {
                 classGroupService.delSingle(classGroupId);
             } else {
-                classGroupStudentMapperService.delClassGroupStudent(userId, classGroupId,true);
+                classGroupStudentMapperService.delClassGroupStudent(userId, classGroupId, true);
             }
         }
 

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

@@ -93,6 +93,10 @@ public class MusicGroupSubjectPlanServiceImpl extends BaseServiceImpl<Integer, M
         //课程形态
         Map<String, Object> courseForm = JSON.parseObject(musicGroup.getCourseForm(), Map.class);
 
+        //新的课程形态10.27
+
+
+
         //乐团计划及收费信息
         MusicGroupSubjectPlan musicOneSubjectClassPlan = this.getMusicOneSubjectClassPlan(musicGroupId, subjectId);
 
@@ -228,8 +232,7 @@ public class MusicGroupSubjectPlanServiceImpl extends BaseServiceImpl<Integer, M
         }
         for (MusicGroupGoodsAndDiscountDto musicGroupGoodsAndDiscountDto : goodsList) {
             musicGroupGoodsAndDiscountDto.setDiscountRate(subjectDiscount.getGoodsDiscountRate());
-            musicGroupGoodsAndDiscountDto.setDiscountPrice(musicGroupGoodsAndDiscountDto.getGroupPurchasePrice()
-                    .subtract(musicGroupGoodsAndDiscountDto.getGroupPurchasePrice().multiply(subjectDiscount.getGoodsDiscountRate())).setScale(2, BigDecimal.ROUND_HALF_UP));
+            musicGroupGoodsAndDiscountDto.setGroupPurchasePrice(musicGroupGoodsAndDiscountDto.getGroupPurchasePrice().multiply(subjectDiscount.getGoodsDiscountRate()).setScale(2, BigDecimal.ROUND_HALF_UP));
         }
         return goodsList;
     }

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

@@ -139,7 +139,7 @@ public class SporadicChargeInfoImpl extends BaseServiceImpl<Integer, SporadicCha
             return true;
         }
         if (studentPaymentOrder.getStatus() == DealStatusEnum.CLOSE || studentPaymentOrder.getStatus() == DealStatusEnum.FAILED) {
-            if (info.getMaxNum() != null) {
+            if (info.getMaxNum() != null && info.getPaidNum() > 0) {
                 //重试避免人数过多频繁冲突
                 boolean flag = false;
                 for (int i = 1; i <= 10; i++) {

+ 63 - 0
mec-biz/src/main/resources/config/mybatis/LuckDrawCountMapper.xml

@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
+<mapper namespace="com.ym.mec.biz.dal.dao.LuckDrawCountDao" >
+  <resultMap id="BaseResultMap" type="com.ym.mec.biz.dal.entity.LuckDrawCount" >
+    <id column="user_id_" property="userId" jdbcType="BIGINT" />
+    <result column="used_count_" property="usedCount" jdbcType="INTEGER" />
+    <result column="available_count_" property="availableCount" jdbcType="INTEGER" />
+    <result column="available_amount_" property="availableAmount.cent" jdbcType="BIGINT" />
+    <result column="modify_on_" property="modifyOn" jdbcType="TIMESTAMP" />
+  </resultMap>
+  <sql id="Base_Column_List" >
+    user_id_, used_count_, available_count_, available_amount_, modify_on_
+  </sql>
+  
+  <select id="get" resultMap="BaseResultMap" parameterType="java.lang.Long" >
+    select 
+    <include refid="Base_Column_List" />
+    from luck_draw_count
+    where user_id_ = #{userId,jdbcType=BIGINT}
+  </select>
+  
+  <select id="getLock" resultMap="BaseResultMap" parameterType="java.lang.Long" >
+    select 
+    <include refid="Base_Column_List" />
+    from luck_draw_count
+    where user_id_ = #{userId,jdbcType=BIGINT} for update
+  </select>
+  
+  <select id="findAll" resultMap="BaseResultMap">
+    select * from luck_draw_count
+  </select>
+  
+  <delete id="delete" parameterType="java.lang.Long" >
+    delete from luck_draw_count
+    where user_id_ = #{userId,jdbcType=BIGINT}
+  </delete>
+  
+  <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.LuckDrawCount" >
+    insert into luck_draw_count (user_id_, used_count_, available_count_, available_amount_,
+      modify_on_)
+    values (#{userId,jdbcType=BIGINT}, #{usedCount,jdbcType=INTEGER}, #{availableCount,jdbcType=INTEGER}, #{availableAmount.cent,jdbcType=BIGINT}, 
+      #{modifyOn,jdbcType=TIMESTAMP})
+  </insert>
+  
+  <update id="update" parameterType="com.ym.mec.biz.dal.entity.LuckDrawCount" >
+    update luck_draw_count
+    <set >
+      <if test="usedCount != null" >
+        used_count_ = #{usedCount,jdbcType=INTEGER},
+      </if>
+      <if test="availableCount != null" >
+        available_count_ = #{availableCount,jdbcType=INTEGER},
+      </if>
+      <if test="availableAmount != null" >
+        available_amount_ = #{availableAmount.cent,jdbcType=BIGINT},
+      </if>
+      <if test="modifyOn != null" >
+        modify_on_ = #{modifyOn,jdbcType=TIMESTAMP},
+      </if>
+    </set>
+    where user_id_ = #{userId,jdbcType=BIGINT}
+  </update>
+</mapper>

+ 63 - 0
mec-biz/src/main/resources/config/mybatis/LuckDrawGroupMapper.xml

@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
+<mapper namespace="com.ym.mec.biz.dal.dao.LuckDrawGroupDao" >
+  <resultMap id="BaseResultMap" type="com.ym.mec.biz.dal.entity.LuckDrawGroup" >
+    <id column="id_" property="id" jdbcType="INTEGER" />
+    <result column="name_" property="name" jdbcType="VARCHAR" />
+    <result column="consume_type_" property="consumeType" jdbcType="VARCHAR" />
+    <result column="consume_value_" property="consumeValue" jdbcType="INTEGER" />
+    <result column="start_time_" property="startTime" jdbcType="TIMESTAMP" />
+    <result column="end_time_" property="endTime" jdbcType="TIMESTAMP" />
+    <result column="create_on_" property="createOn" jdbcType="TIMESTAMP" />
+  </resultMap>
+  
+  <sql id="Base_Column_List" >
+    id_, name_, consume_type_, consume_value_, start_time_, end_time_, create_on_
+  </sql>
+  
+  <select id="get" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
+    select 
+    <include refid="Base_Column_List" />
+    from luck_draw_group
+    where id_ = #{id,jdbcType=INTEGER}
+  </select>
+  
+  <delete id="delete" parameterType="java.lang.Integer" >
+    delete from luck_draw_group
+    where id_ = #{id,jdbcType=INTEGER}
+  </delete>
+  
+  <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.LuckDrawGroup" >
+    insert into luck_draw_group (id_, name_, consume_type_, consume_value_,
+      start_time_, end_time_, create_on_
+      )
+    values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{consumeType,jdbcType=VARCHAR}, #{consumeValue,jdbcType=INTEGER},
+      #{startTime,jdbcType=TIMESTAMP}, #{endTime,jdbcType=TIMESTAMP}, #{createOn,jdbcType=TIMESTAMP}
+      )
+  </insert>
+
+  <update id="update" parameterType="com.ym.mec.biz.dal.entity.LuckDrawGroup" >
+    update luck_draw_group
+    <set >
+      <if test="name != null" >
+        name_ = #{name,jdbcType=VARCHAR},
+      </if>
+      <if test="consumeType != null" >
+        consume_type_ = #{consumeType,jdbcType=VARCHAR},
+      </if>
+      <if test="consumeValue != null" >
+        consume_value_ = #{consumeValue,jdbcType=INTEGER},
+      </if>
+      <if test="startTime != null" >
+        start_time_ = #{startTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="endTime != null" >
+        end_time_ = #{endTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="createOn != null" >
+        create_on_ = #{createOn,jdbcType=TIMESTAMP},
+      </if>
+    </set>
+    where id_ = #{id,jdbcType=INTEGER}
+  </update>
+</mapper>

+ 108 - 0
mec-biz/src/main/resources/config/mybatis/LuckDrawLogMapper.xml

@@ -0,0 +1,108 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
+<mapper namespace="com.ym.mec.biz.dal.dao.LuckDrawLogDao">
+	<resultMap id="BaseResultMap" type="com.ym.mec.biz.dal.entity.LuckDrawLog">
+		<id column="id_" property="id" jdbcType="BIGINT" />
+		<result column="group_id_" property="groupId" jdbcType="INTEGER" />
+		<result column="prize_id_" property="prizeId" jdbcType="INTEGER" />
+		<result column="user_id_" property="userId" jdbcType="BIGINT" />
+		<result column="create_on_" property="createOn" jdbcType="TIMESTAMP" />
+		<result column="name_" property="luckDrawPrize.name" jdbcType="VARCHAR" />
+		<result column="reward_type_" property="luckDrawPrize.rewardType" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler" />
+	</resultMap>
+	
+	<resultMap id="BaseResultMapExt" type="com.ym.mec.biz.dal.entity.LuckDrawLog" extends="BaseResultMap">
+		<result column="nickname_" property="user.nickname" jdbcType="VARCHAR" />
+		<result column="mobile_no_" property="user.mobileNo" jdbcType="VARCHAR" />
+	</resultMap>
+
+	<sql id="Base_Column_List">
+		l.id_,l.group_id_, l.prize_id_,d.name_,d.reward_type_, l.user_id_, l.create_on_
+	</sql>
+
+	<sql id="queryCondition">
+		<where>
+			<if test="prizeId != null">
+				and l.prize_id_ = #{id}
+			</if>
+			<if test="userId != null">
+				and l.user_id_ = #{userId}
+			</if>
+			<if test="name != null">
+				and d.name_ like '%' #{name} '%'
+			</if>
+			<if test="rewardType != null">
+				and d.reward_type_ like '%' #{rewardType} '%'
+			</if>
+			<if test="groupId != null">
+				and l.group_id_ = #{groupId}
+			</if>
+			<if test="startDate != null">
+				and l.create_on_ &gt;= #{startDate}
+			</if>
+			<if test="endDate != null">
+				and l.create_on_ &lt;= #{endDate}
+			</if>
+		</where>
+	</sql>
+
+	<select id="get" resultMap="BaseResultMap" parameterType="java.lang.Long">
+		select
+		<include refid="Base_Column_List" />
+		from luck_draw_log l left join luck_draw_prize d on
+		l.prize_id_ = d.id_
+		where l.id_ = #{id,jdbcType=BIGINT}
+	</select>
+
+	<delete id="delete" parameterType="java.lang.Long">
+		delete from
+		luck_draw_log
+		where id_ = #{id,jdbcType=BIGINT}
+	</delete>
+
+	<insert id="insert" parameterType="com.ym.mec.biz.dal.entity.LuckDrawLog">
+		insert into
+		luck_draw_log (id_,group_id_, prize_id_, user_id_,
+		create_on_)
+		values
+		(#{id,jdbcType=BIGINT}, #{groupId,jdbcType=INTEGER}, #{prizeId,jdbcType=INTEGER},
+		#{userId,jdbcType=BIGINT},
+		#{createOn,jdbcType=TIMESTAMP})
+	</insert>
+
+	<update id="update" parameterType="com.ym.mec.biz.dal.entity.LuckDrawLog">
+		update luck_draw_log
+		<set>
+			<if test="groupId != null">
+				group_id_ = #{groupId,jdbcType=INTEGER},
+			</if>
+			<if test="prizeId != null">
+				prize_id_ = #{prizeId,jdbcType=INTEGER},
+			</if>
+			<if test="userId != null">
+				user_id_ = #{userId,jdbcType=BIGINT},
+			</if>
+			<if test="createOn != null">
+				create_on_ = #{createOn,jdbcType=TIMESTAMP},
+			</if>
+		</set>
+		where id_ = #{id,jdbcType=BIGINT}
+	</update>
+
+	<select id="findCount" parameterType="map" resultType="int">
+		select count(*)
+		from (luck_draw_log l left join luck_draw_prize d on
+		l.prize_id_ = d.id_) left join sys_user u on u.id_=l.user_id_
+		<include refid="queryCondition" />
+	</select>
+
+	<select id="queryPage" parameterType="map" resultMap="BaseResultMapExt">
+		select
+		<include refid="Base_Column_List" />,nickname_,mobile_no_
+		from (luck_draw_log l left join luck_draw_prize d on
+		l.prize_id_ = d.id_) left join sys_user u on u.id_=l.user_id_
+		<include refid="queryCondition" />
+		<include refid="global.orderby" />
+		<include refid="global.limit" />
+	</select>
+</mapper>

+ 116 - 0
mec-biz/src/main/resources/config/mybatis/LuckDrawPrizeMapper.xml

@@ -0,0 +1,116 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
+<mapper namespace="com.ym.mec.biz.dal.dao.LuckDrawDao">
+	<resultMap id="BaseResultMap" type="com.ym.mec.biz.dal.entity.LuckDrawPrize">
+		<id column="id_" property="id" jdbcType="INTEGER" />
+		<result column="name_" property="name" jdbcType="VARCHAR" />
+		<result column="chances_" property="chances" jdbcType="DOUBLE" />
+		<result column="stock_" property="stock" jdbcType="INTEGER" />
+		<result column="enabled_" property="enabled" jdbcType="BIT" />
+		<result column="reward_type_" property="rewardType" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler" />
+		<result column="memo_" property="memo" jdbcType="VARCHAR" />
+		<result column="group_id_" property="groupId" jdbcType="INTEGER" />
+		<result column="create_on_" property="createOn" jdbcType="TIMESTAMP" />
+		<result column="modify_on_" property="modifyOn" jdbcType="TIMESTAMP" />
+	</resultMap>
+
+	<sql id="Base_Column_List">
+		id_, name_, chances_, stock_, enabled_, reward_type_, memo_, group_id_, create_on_, modify_on_
+	</sql>
+
+	<sql id="queryCondition">
+		<where>
+			<if test="id != null">
+				and id_ = #{id}
+			</if>
+			<if test="name != null">
+				and name_ like '%' #{name} '%'
+			</if>
+			<if test="rewardType != null">
+				and reward_type_ like '%' #{rewardType} '%'
+			</if>
+		</where>
+	</sql>
+
+	<select id="get" resultMap="BaseResultMap" parameterType="java.lang.Integer">
+		select
+		<include refid="Base_Column_List" />
+		from luck_draw_prize
+		where id_ = #{id,jdbcType=INTEGER}
+	</select>
+
+	<select id="getLock" resultMap="BaseResultMap" parameterType="java.lang.Integer">
+		select
+		<include refid="Base_Column_List" />
+		from luck_draw_prize
+		where id_ = #{id,jdbcType=INTEGER} for update
+	</select>
+
+	<delete id="delete" parameterType="java.lang.Integer">
+		delete from luck_draw_prize
+		where id_ = #{id,jdbcType=INTEGER}
+	</delete>
+
+	<insert id="insert" parameterType="com.ym.mec.biz.dal.entity.LuckDrawPrize">
+		insert into luck_draw_prize (id_, name_, chances_,
+		stock_, enabled_, reward_type_, memo_, group_id_, create_on_,
+		modify_on_)
+		values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR},
+		#{chances,jdbcType=DOUBLE},
+		#{stock,jdbcType=INTEGER}, #{enabled,jdbcType=BIT},#{rewardType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}, #{memo,jdbcType=VARCHAR}, #{groupId,jdbcType=INTEGER}, #{createOn,jdbcType=TIMESTAMP},
+		#{modifyOn,jdbcType=TIMESTAMP})
+	</insert>
+
+	<update id="update" parameterType="com.ym.mec.biz.dal.entity.LuckDrawPrize">
+		update luck_draw_prize
+		<set>
+			<if test="name != null">
+				name_ = #{name,jdbcType=VARCHAR},
+			</if>
+			<if test="chances != null">
+				chances_ = #{chances,jdbcType=DOUBLE},
+			</if>
+			<if test="stock != null">
+				stock_ = #{stock,jdbcType=INTEGER},
+			</if>
+			<if test="enabled != null">
+				enabled_ = #{enabled,jdbcType=BIT},
+			</if>
+			<if test="rewardType != null">
+				reward_type_ = #{rewardType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
+			</if>
+			<if test="memo != null">
+				memo_ = #{memo,jdbcType=VARCHAR},
+			</if>
+			<if test="groupId != null">
+				group_id_ = #{groupId,jdbcType=INTEGER},
+			</if>
+			<if test="createOn != null">
+				create_on_ = #{createOn,jdbcType=TIMESTAMP},
+			</if>
+			<if test="modifyOn != null">
+				modify_on_ = #{modifyOn,jdbcType=TIMESTAMP},
+			</if>
+		</set>
+		where id_ = #{id,jdbcType=INTEGER}
+	</update>
+
+	<select id="findCount" parameterType="map" resultType="int">
+		select count(*) from luck_draw_prize
+		<include refid="queryCondition" />
+	</select>
+
+	<select id="queryPage" parameterType="map" resultMap="BaseResultMap">
+		select * from luck_draw_prize
+		<include refid="queryCondition" />
+		<include refid="global.orderby" />
+		<include refid="global.limit" />
+	</select>
+
+	<select id="queryEnabledList" resultMap="BaseResultMap" parameterType="int">
+		select
+		<include refid="Base_Column_List" />
+		from luck_draw_prize
+		where enabled_ = 1 and group_id_ = #{group} order by id_ asc
+	</select>
+</mapper>

+ 4 - 0
mec-biz/src/main/resources/config/mybatis/MusicGroupOrganizationCourseSettingsDetailMapper.xml

@@ -112,4 +112,8 @@
     <delete id="deleteBySettingId" parameterType="java.lang.Integer">
         DELETE FROM music_group_organization_course_settings_detail WHERE music_group_organization_course_settings_id_ = #{settingId}
     </delete>
+
+    <select id="queryByMusicGroupOrganizationCourseSettingsId" resultMap="MusicGroupOrganizationCourseSettingsDetail">
+        SELECT * FROM music_group_organization_course_settings_detail where music_group_organization_course_settings_id_ = #{musicGroupOrganizationCourseSettingsId}
+    </select>
 </mapper>

+ 17 - 4
mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentCalenderCourseSettingsMapper.xml

@@ -9,7 +9,7 @@
 		id="MusicGroupPaymentCalenderCourseSettings">
 		<result column="id_" property="id" />
 		<result column="music_group_payment_calender_id_" property="musicGroupPaymentCalenderId" />
-		<result column="course_type_" property="courseType" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
+		<result column="course_type_" property="courseType" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler" />
 		<result column="course_total_minuties_" property="courseTotalMinuties" />
 		<result column="unit_price_" property="unitPrice" />
 		<result column="course_original_price_" property="courseOriginalPrice" />
@@ -36,8 +36,8 @@
 		<!-- <selectKey resultClass="int" keyProperty="id" > SELECT SEQ_WSDEFINITION_ID.nextval 
 			AS ID FROM DUAL </selectKey> -->
 		INSERT INTO music_group_payment_calender_course_settings
-		(music_group_payment_calender_id_,course_type_,course_total_minuties_,unit_price_,course_original_price_,course_current_price_,is_student_optional_,create_time_,update_time_)
-		VALUES(#{musicGroupPaymentCalenderId},#{courseType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{courseTotalMinuties},#{unitPrice},#{courseOriginalPrice},#{courseCurrentPrice},#{isStudentOptional},NOW(),NOW())
+		(id_,music_group_payment_calender_id_,course_type_,course_total_minuties_,unit_price_,course_original_price_,course_current_price_,is_student_optional_,create_time_,update_time_)
+		VALUES(#{id},#{musicGroupPaymentCalenderId},#{courseType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{courseTotalMinuties},#{unitPrice},#{courseOriginalPrice},#{courseCurrentPrice},#{isStudentOptional},#{createTime},#{updateTime})
 	</insert>
 
 	<!-- 根据主键查询一条记录 -->
@@ -61,7 +61,7 @@
 				music_group_payment_calender_id_ = #{musicGroupPaymentCalenderId},
 			</if>
 			<if test="courseType != null">
-				course_type_ = #{courseType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
+				course_type_ = #{courseType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
 			</if>
 			<if test="courseOriginalPrice != null">
 				course_original_price_ = #{courseOriginalPrice},
@@ -94,4 +94,17 @@
     <select id="getWithPaymentCalender" resultMap="MusicGroupPaymentCalenderCourseSettings">
 		SELECT * FROM music_group_payment_calender_course_settings WHERE music_group_payment_calender_id_=#{calenderId}
 	</select>
+
+	<delete id="deleteByMusicGroupPaymentCalenderId">
+		DELETE FROM music_group_payment_calender_course_settings WHERE music_group_payment_calender_id_ = #{musicGroupPaymentCalenderId}
+	</delete>
+
+	<select id="getMusicGroupRegCalenderCourseSettings" resultMap="MusicGroupPaymentCalenderCourseSettings">
+		SELECT mgpccs.*
+		FROM music_group_payment_calender mgpc
+		LEFT JOIN music_group_payment_calender_course_settings mgpccs
+		ON mgpccs.music_group_payment_calender_id_ = mgpc.id_
+		WHERE mgpc.music_group_id_ = #{musicGroupId}
+		AND mgpc.payment_type_ = 1
+	</select>
 </mapper>

+ 1 - 6
mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentCalenderDetailMapper.xml

@@ -167,8 +167,7 @@
 		AND user_id_ = #{userId} AND payment_status_ = 'NON_PAYMENT'
 	</delete>
     <delete id="deleteByCalenderId">
-		DELETE FROM music_group_payment_calender_detail
-		WHERE music_group_payment_calender_id_ = #{id} AND payment_status_ = 'NON_PAYMENT'
+		DELETE FROM music_group_payment_calender_detail WHERE music_group_payment_calender_id_ = #{id}
 	</delete>
 
     <!-- 分页查询 -->
@@ -248,10 +247,6 @@
 		AND mgstf.remain_network_class_times_>0
 		ORDER BY su.id_
 	</select>
-	<select id="sumActualAmount" resultType="java.math.BigDecimal">
-		SELECT SUM(mgpcd.actual_amount_) FROM music_group_payment_calender_detail mgpcd
-		WHERE mgpcd.music_group_payment_calender_id_ = #{id}
-	</select>
 
 	<select id="getUserLastCalenderDetail" resultMap="MusicGroupPaymentCalenderDetail">
 		SELECT * FROM music_group_payment_calender_detail mgpcd

+ 36 - 20
mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentCalenderMapper.xml

@@ -48,6 +48,19 @@
         #{paymentValidStartDate},#{paymentValidEndDate},#{paymentPattern},#{paymentType})
     </insert>
 
+    <insert id="batchInsert" parameterType="com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender" useGeneratedKeys="true"
+            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_)
+        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.paymentType})
+        </foreach>
+    </insert>
+
     <!-- 根据主键查询一条记录 -->
     <update id="update" parameterType="com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender">
         UPDATE music_group_payment_calender
@@ -162,15 +175,35 @@
     <!-- 分页查询 -->
     <select id="queryPage" resultMap="MusicGroupPaymentCalender" parameterType="map">
         SELECT * FROM music_group_payment_calender mgpc
-        WHERE mgpc.music_group_id_ = #{musicGroupId}
-        ORDER BY mgpc.update_time_ DESC
+        <where>
+        	<if test="musicGroupId != null">
+        		and mgpc.music_group_id_ = #{musicGroupId}
+        	</if>
+        	<if test="musicGroupId != null">
+        		and mgpc.pay_user_type_ = #{payUserType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+        	</if>
+        	<if test="musicGroupId != null">
+        		and mgpc.status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+        	</if>
+        </where>
+        ORDER BY mgpc.payment_valid_start_date_ DESC
         <include refid="global.limit"/>
     </select>
 
     <!-- 查询当前表的总记录数 -->
     <select id="queryCount" resultType="int">
 		SELECT COUNT(mgpc.id_) FROM music_group_payment_calender mgpc
-        WHERE mgpc.music_group_id_ = #{musicGroupId}
+        <where>
+        	<if test="musicGroupId != null">
+        		and mgpc.music_group_id_ = #{musicGroupId}
+        	</if>
+        	<if test="musicGroupId != null">
+        		and mgpc.pay_user_type_ = #{payUserType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+        	</if>
+        	<if test="musicGroupId != null">
+        		and mgpc.status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+        	</if>
+        </where>
 	</select>
 	
     <select id="findByMusicGroupId" resultMap="MusicGroupPaymentCalender">
@@ -204,23 +237,6 @@
             AND mgpc.id_ != #{calenderId}
         </if>
     </select>
-    <select id="countExpectNum" resultType="java.util.Map">
-        SELECT mgpcd.music_group_payment_calender_id_ 'key',COUNT(DISTINCT mgpcd.user_id_) 'value' FROM music_group_payment_calender_detail mgpcd
-        WHERE mgpcd.music_group_payment_calender_id_ IN
-        <foreach collection="collect" item="item" open="(" close=")" separator=",">
-            #{item}
-        </foreach>
-        GROUP BY mgpcd.music_group_payment_calender_id_
-    </select>
-    <select id="countActualNum" resultType="java.util.Map">
-        SELECT mgpcd.music_group_payment_calender_id_ 'key',COUNT(DISTINCT mgpcd.user_id_) 'value' FROM music_group_payment_calender_detail mgpcd
-        WHERE mgpcd.music_group_payment_calender_id_ IN
-        <foreach collection="collect" item="item" open="(" close=")" separator=",">
-            #{item}
-        </foreach>
-        AND mgpcd.payment_status_ = 'PAID_COMPLETED'
-        GROUP BY mgpcd.music_group_payment_calender_id_
-    </select>
     
     <select id="getLastStartOne" resultMap="MusicGroupPaymentCalender">
         SELECT * FROM music_group_payment_calender WHERE music_group_id_ = #{musicGroupId} ORDER BY start_payment_date_ DESC LIMIT 1

+ 82 - 0
mec-student/src/main/java/com/ym/mec/student/controller/LuckDrawController.java

@@ -0,0 +1,82 @@
+package com.ym.mec.student.controller;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.MediaType;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+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.LuckDrawLog;
+import com.ym.mec.biz.dal.page.LuckDrawQueryInfo;
+import com.ym.mec.biz.service.LuckDrawCountService;
+import com.ym.mec.biz.service.LuckDrawLogService;
+import com.ym.mec.biz.service.LuckDrawPrizeService;
+import com.ym.mec.common.controller.BaseController;
+import com.ym.mec.common.page.PageInfo;
+import com.ym.mec.util.string.ValueUtil;
+
+@Api(tags = "抽奖")
+@RestController
+@RequestMapping(value = "luckDraw")
+public class LuckDrawController extends BaseController {
+
+	@Autowired
+	private LuckDrawPrizeService luckDrawPrizeService;
+
+	@Autowired
+	private LuckDrawLogService luckDrawLogService;
+
+	@Autowired
+	private LuckDrawCountService luckDrawCountService;
+
+	@Autowired
+	private SysUserFeignService sysUserFeignService;
+
+	@ApiOperation(value = "查询抽奖记录")
+	@GetMapping(value = "/list", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+	public Object list(LuckDrawQueryInfo queryInfo) {
+		PageInfo<LuckDrawLog> pageInfo = luckDrawLogService.queryPage(queryInfo);
+		for (LuckDrawLog log : pageInfo.getRows()) {
+			log.getUser().setPhone(ValueUtil.fuzzyMobile(log.getUser().getPhone()));
+		}
+		return succeed(pageInfo);
+	}
+
+	@ApiOperation(value = "查询我的抽奖记录")
+	@GetMapping(value = "/myList", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+	public Object myList(LuckDrawQueryInfo queryInfo) {
+		SysUser sysUser = sysUserFeignService.queryUserInfo();
+		if (sysUser == null) {
+			return failed("用户信息获取失败");
+		}
+		queryInfo.setUserId(sysUser.getId());
+		return succeed(luckDrawLogService.queryPage(queryInfo));
+	}
+
+	@ApiOperation(value = "抽奖")
+	@PostMapping(value = "/draw", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+	public Object draw(int group) {
+		SysUser sysUser = sysUserFeignService.queryUserInfo();
+		if (sysUser == null) {
+			return failed("用户信息获取失败");
+		}
+		return succeed(luckDrawPrizeService.draw((long) sysUser.getId(), group));
+	}
+
+	@ApiOperation(value = "查询个人抽奖机会")
+	@GetMapping(value = "/queryCount", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+	public Object queryCount() {
+		SysUser sysUser = sysUserFeignService.queryUserInfo();
+		if (sysUser == null) {
+			return failed("用户信息获取失败");
+		}
+		return succeed(luckDrawCountService.get((long) sysUser.getId()));
+	}
+
+}

+ 105 - 0
mec-web/src/main/java/com/ym/mec/web/controller/LuckDrawController.java

@@ -0,0 +1,105 @@
+package com.ym.mec.web.controller;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+
+import java.util.Date;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.MediaType;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.ym.mec.biz.dal.entity.LuckDrawGroup;
+import com.ym.mec.biz.dal.entity.LuckDrawPrize;
+import com.ym.mec.biz.dal.page.LuckDrawQueryInfo;
+import com.ym.mec.biz.service.LuckDrawGroupService;
+import com.ym.mec.biz.service.LuckDrawLogService;
+import com.ym.mec.biz.service.LuckDrawPrizeService;
+import com.ym.mec.common.controller.BaseController;
+import com.ym.mec.common.page.QueryInfo;
+
+@Api(tags = "抽奖")
+@RestController
+public class LuckDrawController extends BaseController {
+	
+	@Autowired
+	private LuckDrawGroupService luckDrawGroupService;
+
+	@Autowired
+	private LuckDrawPrizeService luckDrawPrizeService;
+
+	@Autowired
+	private LuckDrawLogService luckDrawLogService;
+	
+	@ApiOperation(value = "查询奖品组列表")
+	@GetMapping(value = "luckDrawGroup/list", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+	@PreAuthorize("@pcs.hasPermissions('luckDrawGroup/list')")
+	public Object luckDrawGroupList(QueryInfo queryInfo) {
+		return succeed(luckDrawGroupService.queryPage(queryInfo));
+	}
+
+	@ApiOperation(value = "新增抽奖组")
+	@PostMapping(value = "luckDrawGroup/add", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+	@PreAuthorize("@pcs.hasPermissions('luckDrawGroup/add')")
+	public Object luckDrawGroupAdd(@RequestBody LuckDrawGroup luckDrawGroup) {
+		Date date = new Date();
+		luckDrawGroup.setCreateOn(date);
+		return luckDrawGroupService.insert(luckDrawGroup) > 0 ? succeed() : failed();
+	}
+
+	@ApiOperation(value = "编辑抽奖组")
+	@PostMapping(value = "luckDrawGroup/update", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+	@PreAuthorize("@pcs.hasPermissions('luckDrawGroup/update')")
+	public Object luckDrawGroupUpdate(@RequestBody LuckDrawGroup luckDrawGroup) {
+		LuckDrawGroup oriGroup = luckDrawGroupService.get(luckDrawGroup.getId());
+		oriGroup.setName(luckDrawGroup.getName());
+		oriGroup.setConsumeType(luckDrawGroup.getConsumeType());
+		oriGroup.setConsumeValue(luckDrawGroup.getConsumeValue());
+		oriGroup.setEndTime(luckDrawGroup.getEndTime());
+		oriGroup.setStartTime(luckDrawGroup.getStartTime());
+		return luckDrawGroupService.update(oriGroup) > 0 ? succeed() : failed();
+	}
+
+	@ApiOperation(value = "查询奖品列表")
+	@GetMapping(value = "luckDrawPrize/list", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+	@PreAuthorize("@pcs.hasPermissions('luckDrawPrize/list')")
+	public Object list(LuckDrawQueryInfo queryInfo) {
+		return succeed(luckDrawPrizeService.queryPage(queryInfo));
+	}
+
+	@ApiOperation(value = "新增抽奖奖品")
+	@PostMapping(value = "luckDrawPrize/add", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+	@PreAuthorize("@pcs.hasPermissions('luckDrawPrize/add')")
+	public Object add(@RequestBody LuckDrawPrize luckDrawPrize) {
+		Date date = new Date();
+		luckDrawPrize.setCreateOn(date);
+		luckDrawPrize.setModifyOn(date);
+		return luckDrawPrizeService.insert(luckDrawPrize) > 0 ? succeed() : failed();
+	}
+
+	@ApiOperation(value = "编辑抽奖奖品")
+	@PostMapping(value = "luckDrawPrize/update", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+	@PreAuthorize("@pcs.hasPermissions('luckDrawPrize/update')")
+	public Object update(@RequestBody LuckDrawPrize luckDrawPrize) {
+		LuckDrawPrize oriGoods = luckDrawPrizeService.get(luckDrawPrize.getId());
+		oriGoods.setChances(luckDrawPrize.getChances());
+		oriGoods.setEnabled(luckDrawPrize.getEnabled());
+		oriGoods.setName(luckDrawPrize.getName());
+		oriGoods.setStock(luckDrawPrize.getStock());
+		Date date = new Date();
+		oriGoods.setModifyOn(date);
+		return luckDrawPrizeService.update(oriGoods) > 0 ? succeed() : failed();
+	}
+
+	@ApiOperation(value = "查询抽奖列表")
+	@GetMapping(value = "luckDrawLog/rewardlist", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+	@PreAuthorize("@pcs.hasPermissions('luckDrawLog/rewardlist')")
+	public Object rewardlist(LuckDrawQueryInfo queryInfo) {
+		return succeed(luckDrawLogService.queryPage(queryInfo));
+	}
+
+}

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

@@ -1,11 +1,12 @@
 package com.ym.mec.web.controller;
 
+import java.util.List;
+
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 
-import java.util.List;
-
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.MediaType;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -14,7 +15,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
-import com.ym.mec.biz.dal.page.MusicCalenderQueryInfo;
+import com.ym.mec.biz.dal.page.MusicGroupPaymentCalenderQueryInfo;
 import com.ym.mec.biz.service.MusicGroupPaymentCalenderService;
 import com.ym.mec.common.controller.BaseController;
 
@@ -26,19 +27,18 @@ public class MusicGroupPaymentCalenderController extends BaseController {
     @Autowired
     private MusicGroupPaymentCalenderService musicGroupPaymentCalenderService;
 
-    @ApiOperation(value = "新增乐团缴费日历")
-    @PostMapping("/add")
-    @PreAuthorize("@pcs.hasPermissions('musicGroupPaymentCalender/add')")
-    public Object add(MusicGroupPaymentCalender musicGroupPaymentCalender) {
-        musicGroupPaymentCalenderService.create(musicGroupPaymentCalender);
-        return succeed();
+    @ApiOperation(value = "分页查询乐团缴费日历列表")
+    @GetMapping(value = "/queryPage", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+    @PreAuthorize("@pcs.hasPermissions('musicGroupPaymentCalender/queryPage')")
+    public Object queryPage(MusicGroupPaymentCalenderQueryInfo queryInfo) {
+        return succeed(musicGroupPaymentCalenderService.queryPage(queryInfo));
     }
 
-    @ApiOperation(value = "批量新增、修改乐团缴费周期")
-    @PostMapping("/batchAdd")
-    @PreAuthorize("@pcs.hasPermissions('musicGroupPaymentCalender/batchAdd')")
-    public Object batchAdd(@RequestBody List<MusicGroupPaymentCalender> musicGroupPaymentCalenders) {
-        musicGroupPaymentCalenderService.batchInsert(musicGroupPaymentCalenders);
+    @ApiOperation(value = "新增乐团缴费日历")
+    @PostMapping(value = "/add", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+    @PreAuthorize("@pcs.hasPermissions('musicGroupPaymentCalender/add')")
+    public Object add(@RequestBody List<MusicGroupPaymentCalender> musicGroupPaymentCalenderList) {
+        musicGroupPaymentCalenderService.create(musicGroupPaymentCalenderList);
         return succeed();
     }
 
@@ -54,24 +54,10 @@ public class MusicGroupPaymentCalenderController extends BaseController {
     @PostMapping("/updateStartTime")
     @PreAuthorize("@pcs.hasPermissions('musicGroupPaymentCalender/updateStartTime')")
     public Object updateStartTime(MusicGroupPaymentCalender paymentCalender) {
-        musicGroupPaymentCalenderService.updateStartTime(paymentCalender);
+        musicGroupPaymentCalenderService.update(paymentCalender);
         return succeed();
     }
 
-    @ApiOperation(value = "分页查询乐团缴费日历列表")
-    @GetMapping("/queryPage")
-    @PreAuthorize("@pcs.hasPermissions('musicGroupPaymentCalender/queryPage')")
-    public Object queryPage(MusicCalenderQueryInfo queryInfo) {
-        return succeed(musicGroupPaymentCalenderService.queryDetailPage(queryInfo));
-    }
-
-    @ApiOperation(value = "获取缴费信息")
-    @GetMapping("/getDetail")
-    @PreAuthorize("@pcs.hasPermissions('musicGroupPaymentCalender/getDetail')")
-    public Object getDetail(Long id) {
-        return succeed(musicGroupPaymentCalenderService.getDetail(id));
-    }
-
     @ApiOperation(value = "开启缴费的推送(暂时不用,没写完)")
     @GetMapping("/paymentPush")
     @PreAuthorize("@pcs.hasPermissions('musicGroupPaymentCalender/paymentPush')")

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

@@ -116,7 +116,11 @@ public class SporadicChargeInfoController extends BaseController {
 		sporadicChargeInfo.setVersion(info.getVersion());
 		sporadicChargeInfo.setOperatorId(sysUser.getId());
 		sporadicChargeInfo.setUpdateTime(new Date());
-		return succeed(sporadicChargeInfoService.update(sporadicChargeInfo));
+		int update = sporadicChargeInfoService.update(sporadicChargeInfo);
+		if (update <= 0) {
+			return failed("修改失败,请重试");
+		}
+		return succeed(update);
 	}
 
 	@ApiOperation(value = "开启/关闭缴费")