Selaa lähdekoodia

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

yanite 3 vuotta sitten
vanhempi
commit
df1212691c
20 muutettua tiedostoa jossa 390 lisäystä ja 238 poistoa
  1. 4 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/SysCouponDao.java
  2. 5 3
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/SysCouponIssueRecordDao.java
  3. 14 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupPaymentCalender.java
  4. 1 1
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/SysCoupon.java
  5. 2 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/enums/CouponDetailTypeEnum.java
  6. 1 1
      mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupPaymentCalenderDetailService.java
  7. 4 1
      mec-biz/src/main/java/com/ym/mec/biz/service/SysCouponIssueRecordService.java
  8. 1 22
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderCourseSettingsServiceImpl.java
  9. 128 109
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderDetailServiceImpl.java
  10. 57 79
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderServiceImpl.java
  11. 1 1
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentPaymentRouteOrderServiceImpl.java
  12. 10 4
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/SysCouponCodeServiceImpl.java
  13. 12 5
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/SysCouponIssueRecordServiceImpl.java
  14. 65 1
      mec-biz/src/main/resources/config/mybatis/SysCouponIssueRecordMapper.xml
  15. 16 0
      mec-biz/src/main/resources/config/mybatis/SysCouponMapper.xml
  16. 20 0
      mec-common/common-core/src/main/java/com/ym/mec/common/page/WrapperUtil.java
  17. 1 1
      mec-student/src/main/java/com/ym/mec/student/controller/MusicGroupController.java
  18. 0 1
      mec-student/src/main/java/com/ym/mec/student/controller/MusicGroupPaymentCalenderController.java
  19. 1 1
      mec-web/src/main/java/com/ym/mec/web/controller/MusicGroupPaymentCalenderDetailController.java
  20. 47 8
      mec-web/src/main/java/com/ym/mec/web/controller/SysCouponIssueRecordController.java

+ 4 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/SysCouponDao.java

@@ -4,8 +4,12 @@ import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.biz.dal.entity.SysCoupon;
 import org.apache.ibatis.annotations.Param;
 
+import java.util.Map;
+
 public interface SysCouponDao extends BaseDAO<Integer, SysCoupon> {
 
     SysCoupon lockCoupon(@Param("id") Integer id);
+
+    int updateExchange(@Param("param") Map<String, Object> param);
 	
 }

+ 5 - 3
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/SysCouponIssueRecordDao.java

@@ -3,6 +3,7 @@ package com.ym.mec.biz.dal.dao;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ym.mec.biz.dal.entity.SysCoupon;
 import com.ym.mec.biz.dal.entity.SysCouponIssueRecord;
 import org.apache.ibatis.annotations.Param;
 
@@ -23,7 +24,7 @@ public interface SysCouponIssueRecordDao extends BaseMapper<SysCouponIssueRecord
 
     <T> IPage<T> queryIssueRecord(Page<T> page, @Param("param") Map<String, Object> param);
 
-    int queryCouponCode(@Param("issueId") Integer issueId,@Param("state") Integer state);
+    int queryCouponCode(@Param("issueId") Integer issueId, @Param("state") Integer state);
 
     /**
      * 撤回未使用的优惠券
@@ -31,10 +32,11 @@ public interface SysCouponIssueRecordDao extends BaseMapper<SysCouponIssueRecord
     void revoke(Integer issueId);
 
     /**
-     * @param id sys_coupon表的id
+     * @param id         sys_coupon表的id
      * @param consumeNum 消费数量
      */
-    void opsConsume(@Param("id") Integer id,@Param("consumeNum") Integer consumeNum);
+    void opsConsume(@Param("id") Integer id, @Param("consumeNum") Integer consumeNum);
 
+    List<SysCoupon> queryUserCanGetCoupon(@Param("userId") Integer userId);
 }
 

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

@@ -117,18 +117,22 @@ public class MusicGroupPaymentCalender extends BaseEntity {
 	private Date deadlinePaymentDate;
 
 	@ApiModelProperty(value = "缴费有效期开始时间", required = false)
+	//废弃字段
 	private Date paymentValidStartDate;
 
 	@ApiModelProperty(value = "缴费有效期截止时间", required = false)
+	//废弃字段
 	private Date paymentValidEndDate;
 
 	@ApiModelProperty(value = "缴费方式0按月,1按学期,2一次性", required = false)
+	//废弃字段
 	private Integer paymentPattern;
 
 	@ApiModelProperty(value = "缴费类型", required = false)
 	private PaymentType paymentType;
 
 	@ApiModelProperty(value = "课程价格费用", required = false)
+	//废弃字段
 	private BigDecimal paymentAmount = new BigDecimal(0);
 
 	@ApiModelProperty(value = "状态", required = false)
@@ -174,33 +178,43 @@ public class MusicGroupPaymentCalender extends BaseEntity {
 	private CourseViewTypeEnum courseViewType;
 
 	//会员周期
+	//废弃字段
 	private PeriodEnum memberPeriod;
 
 	//会员有效期(月)
+	//废弃字段
 	private Integer memberValidDate;
 
 	//会员付款金额
+	//废弃字段
 	private BigDecimal memberPaymentAmount = BigDecimal.ZERO;
 
 	//会员原付款金额
+	//废弃字段
 	private BigDecimal originalMemberPaymentAmount = BigDecimal.ZERO;
 
 	//会员等级编号
+	//废弃字段
 	private Integer memberRankSettingId;
 
 	//会员等级名称
+	//废弃字段
 	private String memberRankSettingName;
 
 	//会员是否必选
+	//废弃字段
 	private Boolean memberOptionalFlag = false;
 
 	//乐保年限
+	//废弃字段
 	private BigDecimal musicRepairNum = BigDecimal.ZERO;
 
 	//乐保购买价格
+	//废弃字段
 	private BigDecimal musicRepairActualPrice = BigDecimal.ZERO;
 
 	//乐保是否必选
+	//废弃字段
 	private Boolean musicRepairOptionalFlag = false;
 
 	//申请价格

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

@@ -42,7 +42,7 @@ public class SysCoupon extends BaseEntity implements Serializable{
 	private CouponTypeEnum type;
 
     @NotBlank(message = "优惠券详细分类不能为空!")
-    @ApiModelProperty(value = "详情CouponDetailTypeEnum枚举类")
+    @ApiModelProperty(value = "详情-CouponDetailTypeEnum-枚举类")
     private String typeDetail;
 
 	@ApiModelProperty("面值")

+ 2 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/enums/CouponDetailTypeEnum.java

@@ -26,6 +26,8 @@ public enum CouponDetailTypeEnum {
     MIX("MIX", "合奏课"),
     //VIP = vip课 VIP +乐理课 THEORY_COURSE
     VIP("VIP", "VIP"),
+    //会员开通,团练宝
+    MEMBER("MEMBER","团练宝"),
     //全类都可以使用
     FULLCOUPON("FULLCOUPON", "全类券");
 

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

@@ -26,7 +26,7 @@ public interface MusicGroupPaymentCalenderDetailService extends BaseService<Long
      * @param ids
      * @return
      */
-    void updateExpectAmount(BigDecimal expectAmount,BigDecimal expectMemberAmount,String ids);
+//    void updateExpectAmount(BigDecimal expectAmount,BigDecimal expectMemberAmount,String ids);
 
     /**
      * 开启缴费

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

@@ -1,6 +1,7 @@
 package com.ym.mec.biz.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.ym.mec.biz.dal.entity.SysCoupon;
 import com.ym.mec.biz.dal.entity.SysCouponIssueRecord;
 import com.ym.mec.biz.dal.vo.CouponIssueRecordVo;
 import com.ym.mec.common.page.PageInfo;
@@ -22,10 +23,12 @@ public interface SysCouponIssueRecordService extends IService<SysCouponIssueReco
 
     void manualIssueCoupon(Integer userId, Integer couponId);
 
-    int checkRevoke(Integer couponId);
+    int checkRevoke(Integer issueId);
 
     PageInfo<?> queryIssueDetail(Map<String, Object> param);
 
     PageInfo<CouponIssueRecordVo> queryIssueRecord(Map<String, Object> param);
+
+    List<SysCoupon> queryCanBeGetCoupon(Integer userId);
 }
 

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

@@ -164,28 +164,7 @@ public class MusicGroupPaymentCalenderCourseSettingsServiceImpl extends BaseServ
     public BigDecimal getOriginalAmount(MusicGroupPaymentBaseCalender baseCalender) {
 		List<MusicGroupPaymentCalenderCourseSettings> musicGroupPaymentCalenderCourseSettingsList = baseCalender.getMusicGroupPaymentCalenderCourseSettingsList();
 		if(musicGroupPaymentCalenderCourseSettingsList != null && musicGroupPaymentCalenderCourseSettingsList.size() > 0){
-			if (baseCalender.getPaymentType() == MUSIC_APPLY || baseCalender.getPaymentType() == MUSIC_RENEW) {
-				// 查询默认课程费用
-				Integer musicGroupOrganizationCourseSettingId = baseCalender.getMusicGroupOrganizationCourseSettingId();
-				List<MusicGroupOrganizationCourseSettingsDetail> musicGroupOrganizationCourseSettingsDetails = musicGroupOrganizationCourseSettingsDetailDao.queryByMusicGroupOrganizationCourseSettingsId(musicGroupOrganizationCourseSettingId);
-				return musicGroupOrganizationCourseSettingsDetails.stream().map(e -> e.getCourseCurrentPrice()).reduce(BigDecimal.ZERO, BigDecimal::add);
-
-			} else if (baseCalender.getPaymentType() == MusicGroupPaymentCalender.PaymentType.ADD_COURSE) {
-				MusicGroup musicGroup = baseCalender.getMusicGroup();
-				BigDecimal totalAmount = BigDecimal.ZERO;
-				// 如果是课程收费,判断是否审核
-				for (MusicGroupPaymentCalenderCourseSettings courseSettings : musicGroupPaymentCalenderCourseSettingsList) {
-					OrganizationCourseUnitPriceSettings defaultUnitPrice = organizationCourseUnitPriceSettingsDao.queryByOrganIdAndCourseTypeAndChargeType(
-							musicGroup.getOrganId(), courseSettings.getCourseType(), musicGroup.getChargeTypeId());
-					if (defaultUnitPrice == null) {
-						throw new BizException("请先设置分部课程类型单价");
-					}
-					totalAmount = totalAmount.add(defaultUnitPrice.getUnitPrice().multiply(new BigDecimal(courseSettings.getCourseTotalMinuties())));
-				}
-				return totalAmount;
-			}else {
-				throw new BizException("错误的缴费类型");
-			}
+			return musicGroupPaymentCalenderCourseSettingsList.stream().map(e->e.getCourseOriginalPrice()).reduce(BigDecimal.ZERO,BigDecimal::add);
 		}
         return BigDecimal.ZERO;
     }

+ 128 - 109
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderDetailServiceImpl.java

@@ -70,24 +70,28 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
 	@Autowired
 	private MusicGroupStudentFeeDao musicGroupStudentFeeDao;
 	@Autowired
-	private StudentRegistrationDao studentRegistrationDao;
+	private ActivityUserMapperService activityUserMapperService;
 	@Autowired
 	private SysMessageService sysMessageService;
 	@Autowired
-	private GroupEventSource groupEventSource;
+	private MusicGroupPaymentCalenderMemberService musicGroupPaymentCalenderMemberService;
+	@Autowired
+	private MusicGroupPaymentCalenderActivityService musicGroupPaymentCalenderActivityService;
 	@Autowired
 	private StudentPaymentOrderDetailDao studentPaymentOrderDetailDao;
 	@Autowired
 	private CloudTeacherOrderDao cloudTeacherOrderDao;
 	@Autowired
 	private StudentPaymentOrderDao studentPaymentOrderDao;
+	@Autowired
+	private StudentDao studentDao;
 
 	@Override
 	public BaseDAO<Long, MusicGroupPaymentCalenderDetail> getDAO() {
 		return musicGroupPaymentCalenderDetailDao;
 	}
 
-	@Override
+	/*@Override
 	@Transactional(rollbackFor = Exception.class)
 	public void updateExpectAmount(BigDecimal expectAmount,BigDecimal expectMemberAmount,String ids) {
 		if((expectAmount == null && expectMemberAmount == null) || StringUtils.isEmpty(ids)){
@@ -224,7 +228,7 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
 						null, 0, memo, null, musicGroup.getName());
 			}
 		}
-	}
+	}*/
 
 	@Override
 	@Transactional(rollbackFor = Exception.class)
@@ -312,18 +316,18 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
 		List<MusicGroupPaymentCalenderCourseSettings> courseSettingsList = musicGroupPaymentCalenderCourseSettingsDao.getWithPaymentCalender(musicGroupPaymentCalenderId);
 
 		//总金额 = 会员费用 + 课程费用
-		BigDecimal expectAmount = BigDecimal.ZERO;
-		BigDecimal expectMemberAmount = musicGroupPaymentCalender.getMemberPaymentAmount();
-		if (musicGroupPaymentCalender.getPayUserType() == STUDENT) {
-			if (musicGroupPaymentCalender.getPayUserType() == STUDENT) {
-				for (MusicGroupPaymentCalenderCourseSettings courseSettings : courseSettingsList) {
-					// 剔除可选课程
-					if (courseSettings.getIsStudentOptional() == false) {
-						expectAmount = expectAmount.add(courseSettings.getCourseCurrentPrice());
-					}
-				}
-			}
-		}
+//		BigDecimal expectAmount = BigDecimal.ZERO;
+//		BigDecimal expectMemberAmount = musicGroupPaymentCalender.getMemberPaymentAmount();
+//		if (musicGroupPaymentCalender.getPayUserType() == STUDENT) {
+//			if (musicGroupPaymentCalender.getPayUserType() == STUDENT) {
+//				for (MusicGroupPaymentCalenderCourseSettings courseSettings : courseSettingsList) {
+//					 剔除可选课程
+//					if (courseSettings.getIsStudentOptional() == false) {
+//						expectAmount = expectAmount.add(courseSettings.getCourseCurrentPrice());
+//					}
+//				}
+//			}
+//		}
 
 		Date date = new Date();
 		MusicGroupPaymentCalenderDetail musicGroupPaymentCalenderDetail = null;
@@ -334,10 +338,7 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
 			musicGroupPaymentCalenderDetail = new MusicGroupPaymentCalenderDetail();
 			musicGroupPaymentCalenderDetail.setMusicGroupPaymentCalenderId(musicGroupPaymentCalenderId);
 			musicGroupPaymentCalenderDetail.setCreateTime(date);
-//			musicGroupPaymentCalenderDetail.setExpectAmount(expectAmount);
-//			musicGroupPaymentCalenderDetail.setExpectMemberAmount(expectMemberAmount);
-			if (expectAmount.doubleValue() == 0d && expectMemberAmount.doubleValue() == 0d) {
-//				musicGroupPaymentCalenderDetail.setActualAmount(BigDecimal.ZERO);
+			if (musicGroupPaymentCalender.getCurrentTotalAmount().compareTo(BigDecimal.ZERO) == 0) {
 				musicGroupPaymentCalenderDetail.setPaymentStatus(PaymentStatus.PAID_COMPLETED);
 			} else {
 				musicGroupPaymentCalenderDetail.setPaymentStatus(PaymentStatus.NON_PAYMENT);
@@ -359,7 +360,7 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
 		}
 		//更新预计缴费人数
 		musicGroupPaymentCalender.setExpectNum(musicGroupPaymentCalender.getExpectNum() + userIdList.size());
-		if (expectAmount.doubleValue() == 0d && expectMemberAmount.doubleValue() == 0d) {
+		if (musicGroupPaymentCalender.getCurrentTotalAmount().compareTo(BigDecimal.ZERO) == 0) {
 			musicGroupPaymentCalender.setActualNum(musicGroupPaymentCalender.getActualNum() + userIdList.size());
 		}
 		musicGroupPaymentCalender.setUpdateTime(date);
@@ -443,7 +444,8 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
 		if(musicGroupPaymentCalenderList == null || musicGroupPaymentCalenderList.size() == 0){
 			throw new BizException("操作失败:缴费项目不存在");
 		}
-		String musicGroupId = musicGroupPaymentCalenderList.get(0).getMusicGroupId();
+		MusicGroupPaymentCalender musicGroupPaymentCalender = musicGroupPaymentCalenderList.get(0);
+		String musicGroupId = musicGroupPaymentCalender.getMusicGroupId();
 		// 所有缴费项目已完成排课才能创建下一个缴费项目
 		List<String> batchNoList = new ArrayList<>();
 		batchNoList.add(batchNo);
@@ -465,104 +467,121 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
 				}
 			}
 		}
-		for(MusicGroupPaymentCalender musicGroupPaymentCalender : musicGroupPaymentCalenderList){
-			Long musicGroupPaymentCalenderId = musicGroupPaymentCalender.getId();
-			
-			if(musicGroupPaymentCalender.getPaymentType() == MusicGroupPaymentCalender.PaymentType.MUSIC_APPLY){
-				throw new BizException("操作失败:报名缴费项不允许添加学员");
-			}
-			if (musicGroupPaymentCalender.getStatus() == PaymentCalenderStatusEnum.AUDITING
-					|| musicGroupPaymentCalender.getStatus() == PaymentCalenderStatusEnum.REJECT) {
-				throw new BizException("当前缴费状态不能添加学生");
-			}
-			//判断学生是否已存在
-			Set<Integer> userList = musicGroupPaymentCalenderDetailDao.queryStudentIds(musicGroupPaymentCalenderId);
-			if(Collections.disjoint(userList, userIdList) == false){
-				throw new BizException("操作失败:包含已存在的学员");
+		Long musicGroupPaymentCalenderId = musicGroupPaymentCalender.getId();
+
+		if(musicGroupPaymentCalender.getPaymentType() == MusicGroupPaymentCalender.PaymentType.MUSIC_APPLY){
+			throw new BizException("操作失败:报名缴费项不允许添加学员");
+		}
+		if (musicGroupPaymentCalender.getStatus() == PaymentCalenderStatusEnum.AUDITING
+				|| musicGroupPaymentCalender.getStatus() == PaymentCalenderStatusEnum.REJECT) {
+			throw new BizException("当前缴费状态不能添加学生");
+		}
+		//判断学生是否已存在
+		Set<Integer> userList = musicGroupPaymentCalenderDetailDao.queryStudentIds(musicGroupPaymentCalenderId);
+		if(Collections.disjoint(userList, userIdList) == false){
+			throw new BizException("操作失败:包含已存在的学员");
+		}
+
+		Date date = new Date();
+		MusicGroupPaymentCalenderDetail musicGroupPaymentCalenderDetail = null;
+		Map<Integer,Long> userMap = new HashMap<>();
+		List<MusicGroupPaymentCalenderDetail> musicGroupPaymentCalenderDetailList = new ArrayList<MusicGroupPaymentCalenderDetail>();
+		//创建缴费明细
+		MusicGroup musicGroup = musicGroupDao.get(musicGroupId);
+
+		List<MusicGroupPaymentCalenderActivity> calenderActivities = musicGroupPaymentCalenderActivityService.findByCalenderId(musicGroupPaymentCalenderId);
+		MusicGroupPaymentCalenderMember calenderMember = musicGroupPaymentCalenderMemberService.findByCalenderId(musicGroupPaymentCalenderId);
+		for(Integer studentId : userIdList){
+			musicGroupPaymentCalenderDetail = new MusicGroupPaymentCalenderDetail();
+			musicGroupPaymentCalenderDetail.setMusicGroupPaymentCalenderId(musicGroupPaymentCalenderId);
+			musicGroupPaymentCalenderDetail.setCreateTime(date);
+			if (musicGroupPaymentCalender.getCurrentTotalAmount().compareTo(BigDecimal.ZERO) == 0) {
+				musicGroupPaymentCalenderDetail.setPaymentStatus(PaymentStatus.PAID_COMPLETED);
+			} else {
+				musicGroupPaymentCalenderDetail.setPaymentStatus(PaymentStatus.NON_PAYMENT);
 			}
-			
-			Date date = new Date();
-			MusicGroupPaymentCalenderDetail musicGroupPaymentCalenderDetail = null;
-			Map<Integer,Long> userMap = new HashMap<>();
-			List<MusicGroupPaymentCalenderDetail> musicGroupPaymentCalenderDetailList = new ArrayList<MusicGroupPaymentCalenderDetail>();
-			//创建缴费明细
-			MusicGroup musicGroup = musicGroupDao.get(musicGroupId);
-			for(Integer studentId : userIdList){
-				musicGroupPaymentCalenderDetail = new MusicGroupPaymentCalenderDetail();
-				musicGroupPaymentCalenderDetail.setMusicGroupPaymentCalenderId(musicGroupPaymentCalenderId);
-				musicGroupPaymentCalenderDetail.setCreateTime(date);
-				if (musicGroupPaymentCalender.getPaymentAmount().compareTo(BigDecimal.ZERO) == 0) {
-					musicGroupPaymentCalenderDetail.setPaymentStatus(PaymentStatus.PAID_COMPLETED);
-				} else {
-					musicGroupPaymentCalenderDetail.setPaymentStatus(PaymentStatus.NON_PAYMENT);
+			musicGroupPaymentCalenderDetail.setUpdateTime(date);
+			musicGroupPaymentCalenderDetail.setUserId(studentId);
+			musicGroupPaymentCalenderDetail.setStartPaymentDate(musicGroupPaymentCalender.getStartPaymentDate());
+			musicGroupPaymentCalenderDetail.setDeadlinePaymentDate(musicGroupPaymentCalender.getDeadlinePaymentDate());
+			musicGroupPaymentCalenderDetail.setResponsibleUserId(musicGroupPaymentCalender.getOperator());
+			musicGroupPaymentCalenderDetailList.add(musicGroupPaymentCalenderDetail);
+			if (musicGroupPaymentCalender.getCurrentTotalAmount().compareTo(BigDecimal.ZERO) == 0) {
+				// 添加会员
+				if(calenderMember != null){
+					CloudTeacherOrder cloudTeacherOrder = new CloudTeacherOrder();
+					cloudTeacherOrder.setOrganId(musicGroup.getOrganId());
+					cloudTeacherOrder.setType(calenderMember.getPeriod());
+					cloudTeacherOrder.setAmount(BigDecimal.ZERO);
+					cloudTeacherOrder.setStudentId(studentId);
+					cloudTeacherOrder.setLevel(calenderMember.getMemberRankSettingId());
+					cloudTeacherOrder.setTime(calenderMember.getNum().intValue());
+					cloudTeacherOrder.setStatus(1);
+					cloudTeacherOrder.setRemark("缴费项目0元新增学员");
+					cloudTeacherOrder.setMusicGroupId(musicGroupId);
+					cloudTeacherOrderDao.insert(cloudTeacherOrder);
 				}
-				musicGroupPaymentCalenderDetail.setUpdateTime(date);
-				musicGroupPaymentCalenderDetail.setUserId(studentId);
-				musicGroupPaymentCalenderDetail.setStartPaymentDate(musicGroupPaymentCalender.getStartPaymentDate());
-				musicGroupPaymentCalenderDetail.setDeadlinePaymentDate(musicGroupPaymentCalender.getDeadlinePaymentDate());
-				musicGroupPaymentCalenderDetail.setResponsibleUserId(musicGroupPaymentCalender.getOperator());
-
-				musicGroupPaymentCalenderDetailList.add(musicGroupPaymentCalenderDetail);
-				if (musicGroupPaymentCalender.getPaymentAmount().compareTo(BigDecimal.ZERO) == 0) {
-					// 添加会员有效时长
-					if(musicGroupPaymentCalender.getMemberRankSettingId() != null){
-						CloudTeacherOrder cloudTeacherOrder = new CloudTeacherOrder();
-						cloudTeacherOrder.setOrganId(musicGroup.getOrganId());
-						cloudTeacherOrder.setType(musicGroupPaymentCalender.getMemberPeriod());
-						cloudTeacherOrder.setTime(musicGroupPaymentCalender.getMemberValidDate());
-						cloudTeacherOrder.setAmount(BigDecimal.ZERO);
-						cloudTeacherOrder.setStudentId(studentId);
-						cloudTeacherOrder.setLevel(musicGroupPaymentCalender.getMemberRankSettingId());
-						cloudTeacherOrder.setStatus(1);
-						cloudTeacherOrder.setRemark("缴费项目0元新增学员");
-						cloudTeacherOrder.setMusicGroupId(musicGroupId);
-						cloudTeacherOrderDao.insert(cloudTeacherOrder);
+				//添加小课包
+				if(calenderActivities != null && calenderActivities.size() > 0){
+					List<ActivityUserMapper> activityUserMapperList = new ArrayList<>();
+					for (MusicGroupPaymentCalenderActivity calenderActivity : calenderActivities) {
+						ActivityUserMapper activityUserMapper = new ActivityUserMapper();
+						activityUserMapper.setActualPrice(BigDecimal.ZERO);
+						activityUserMapper.setActivityId(calenderActivity.getActivityId());
+						Student student = studentDao.get(studentId);
+						activityUserMapper.setUserId(studentId);
+						activityUserMapper.setTeacherId(student.getTeacherId());
+						if("网管课".equals(calenderActivity.getCategoryName())){
+							activityUserMapper.setPracticeFlag(1);
+						}else {
+							activityUserMapper.setVipFlag(1);
+						}
+						activityUserMapperList.add(activityUserMapper);
 					}
+					activityUserMapperService.batchInsert(activityUserMapperList);
 				}
 			}
+		}
 
-			if (musicGroupPaymentCalenderDetailList.size() > 0) {
-				musicGroupPaymentCalenderDetailDao.batchInsert(musicGroupPaymentCalenderDetailList);
-				musicGroupPaymentCalenderDetailList.stream().map(e-> userMap.put(e.getUserId(),e.getId()));
-			}
-			//更新预计缴费人数
-			musicGroupPaymentCalender.setExpectNum(musicGroupPaymentCalender.getExpectNum() + userIdList.size());
-			musicGroupPaymentCalender.setUpdateTime(date);
-			if (musicGroupPaymentCalender.getPaymentAmount().compareTo(BigDecimal.ZERO) == 0) {
-				musicGroupPaymentCalender.setActualNum(musicGroupPaymentCalender.getActualNum() + userIdList.size());
-			}
-			musicGroupPaymentCalenderService.update(musicGroupPaymentCalender);
+		if (musicGroupPaymentCalenderDetailList.size() > 0) {
+			musicGroupPaymentCalenderDetailDao.batchInsert(musicGroupPaymentCalenderDetailList);
+			musicGroupPaymentCalenderDetailList.stream().map(e-> userMap.put(e.getUserId(),e.getId()));
+		}
+		//更新预计缴费人数
+		musicGroupPaymentCalender.setExpectNum(musicGroupPaymentCalender.getExpectNum() + userIdList.size());
+		musicGroupPaymentCalender.setUpdateTime(date);
+		if (musicGroupPaymentCalender.getCurrentTotalAmount().compareTo(BigDecimal.ZERO) == 0) {
+			musicGroupPaymentCalender.setActualNum(musicGroupPaymentCalender.getActualNum() + userIdList.size());
+		}
+		musicGroupPaymentCalenderService.update(musicGroupPaymentCalender);
 
-			//创建学生课排课分钟数
-			List<MusicGroupPaymentCalenderCourseSettings> courseSettingsList = musicGroupPaymentCalenderCourseSettingsDao.getWithPaymentCalender(musicGroupPaymentCalenderId);
-			if(courseSettingsList != null && courseSettingsList.size() > 0){
-				List<MusicGroupPaymentStudentCourseDetail> musicGroupPaymentStudentCourseDetailList = new ArrayList<>();
-				MusicGroupPaymentStudentCourseDetail musicGroupPaymentStudentCourseDetail = null;
-				for(Integer studentId : userIdList){
-					for(MusicGroupPaymentCalenderCourseSettings courseSettings : courseSettingsList){
-						musicGroupPaymentStudentCourseDetail = new MusicGroupPaymentStudentCourseDetail();
-						musicGroupPaymentStudentCourseDetail.setCourseType(courseSettings.getCourseType());
-						musicGroupPaymentStudentCourseDetail.setCreateTime(date);
-						musicGroupPaymentStudentCourseDetail.setMusicGroupPaymentCalenderId(musicGroupPaymentCalenderId);
-						musicGroupPaymentStudentCourseDetail.setMusicGroupPaymentCalenderDetailId(userMap.get(studentId));
-						musicGroupPaymentStudentCourseDetail.setTotalCourseMinutes(courseSettings.getCourseTotalMinuties());
-						musicGroupPaymentStudentCourseDetail.setCourseOriginalPrice(courseSettings.getCourseOriginalPrice());
-						musicGroupPaymentStudentCourseDetail.setCourseCurrentPrice(courseSettings.getCourseCurrentPrice());
-						musicGroupPaymentStudentCourseDetail.setUpdateTime(date);
-						musicGroupPaymentStudentCourseDetail.setUsedCourseMinutes(0);
-						musicGroupPaymentStudentCourseDetail.setUserId(studentId);
-						musicGroupPaymentStudentCourseDetailList.add(musicGroupPaymentStudentCourseDetail);
-					}
+		//创建学生课排课分钟数
+		List<MusicGroupPaymentCalenderCourseSettings> courseSettingsList = musicGroupPaymentCalenderCourseSettingsDao.getWithPaymentCalender(musicGroupPaymentCalenderId);
+		if(courseSettingsList != null && courseSettingsList.size() > 0){
+			List<MusicGroupPaymentStudentCourseDetail> musicGroupPaymentStudentCourseDetailList = new ArrayList<>();
+			MusicGroupPaymentStudentCourseDetail musicGroupPaymentStudentCourseDetail = null;
+			for(Integer studentId : userIdList){
+				for(MusicGroupPaymentCalenderCourseSettings courseSettings : courseSettingsList){
+					musicGroupPaymentStudentCourseDetail = new MusicGroupPaymentStudentCourseDetail();
+					musicGroupPaymentStudentCourseDetail.setCourseType(courseSettings.getCourseType());
+					musicGroupPaymentStudentCourseDetail.setCreateTime(date);
+					musicGroupPaymentStudentCourseDetail.setMusicGroupPaymentCalenderId(musicGroupPaymentCalenderId);
+					musicGroupPaymentStudentCourseDetail.setMusicGroupPaymentCalenderDetailId(userMap.get(studentId));
+					musicGroupPaymentStudentCourseDetail.setTotalCourseMinutes(courseSettings.getCourseTotalMinuties());
+					musicGroupPaymentStudentCourseDetail.setCourseOriginalPrice(courseSettings.getCourseOriginalPrice());
+					musicGroupPaymentStudentCourseDetail.setCourseCurrentPrice(courseSettings.getCourseCurrentPrice());
+					musicGroupPaymentStudentCourseDetail.setUpdateTime(date);
+					musicGroupPaymentStudentCourseDetail.setUsedCourseMinutes(0);
+					musicGroupPaymentStudentCourseDetail.setUserId(studentId);
+					musicGroupPaymentStudentCourseDetailList.add(musicGroupPaymentStudentCourseDetail);
 				}
-				musicGroupPaymentStudentCourseDetailDao.batchInsert(musicGroupPaymentStudentCourseDetailList);
 			}
+			musicGroupPaymentStudentCourseDetailDao.batchInsert(musicGroupPaymentStudentCourseDetailList);
 		}
 		//给学员推送缴费通知
-		for (MusicGroupPaymentCalender musicGroupPaymentCalender : musicGroupPaymentCalenderList) {
-			if (musicGroupPaymentCalender.getPayUserType() == STUDENT && musicGroupPaymentCalender.getStatus() == PaymentCalenderStatusEnum.OPEN) {
-				musicGroupPaymentCalenderService.pushWaitRenewMessage(musicGroupPaymentCalender.getId(),
-						musicGroupDao.get(musicGroupPaymentCalender.getMusicGroupId()),userIdList);
-			}
+		if (musicGroupPaymentCalender.getPayUserType() == STUDENT && musicGroupPaymentCalender.getStatus() == PaymentCalenderStatusEnum.OPEN) {
+			musicGroupPaymentCalenderService.pushWaitRenewMessage(musicGroupPaymentCalender.getId(),
+					musicGroupDao.get(musicGroupPaymentCalender.getMusicGroupId()),userIdList);
 		}
 	}
 

+ 57 - 79
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderServiceImpl.java

@@ -115,7 +115,7 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 	@Autowired
 	private MemberFeeSettingDao memberFeeSettingDao;
 	@Autowired
-	private MemberRankSettingDao memberRankSettingDao;
+	private MemberRankPrivilegesService memberRankPrivilegesService;
 	@Autowired
 	private CloudTeacherOrderDao cloudTeacherOrderDao;
 	@Autowired
@@ -124,6 +124,10 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 	private MusicGroupPaymentCalenderMemberServiceImpl musicGroupPaymentCalenderMemberService;
 	@Autowired
 	private MusicGroupPaymentCalenderRepairServiceImpl musicGroupPaymentCalenderRepairService;
+	@Autowired
+	private StudentDao studentDao;
+	@Autowired
+	private ActivityUserMapperService activityUserMapperService;
 
 	@Override
 	public BaseDAO<Long, MusicGroupPaymentCalender> getDAO() {
@@ -337,7 +341,7 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 			musicGroupPaymentCalender.setOriginalMemberPaymentAmount(originalMemberPaymentAmount);
 			musicGroupPaymentCalender.setAttribute2(musicGroupPaymentCalenderDto.getAttribute2());
 			musicGroupPaymentCalender.setDeadlinePaymentDate(musicGroupPaymentDateRange.getDeadlinePaymentDate());
-			musicGroupPaymentCalender.setIsGiveMusicNetwork(musicGroupPaymentCalenderDto.getIsGiveMusicNetwork());
+//			musicGroupPaymentCalender.setIsGiveMusicNetwork(musicGroupPaymentCalenderDto.getIsGiveMusicNetwork());
 			musicGroupPaymentCalender.setMemo(musicGroupPaymentCalenderDto.getMemo());
 			musicGroupPaymentCalender.setMusicGroupId(musicGroupId);
 			musicGroupPaymentCalender.setMusicGroupOrganizationCourseSettingId(musicGroupPaymentCalenderDto.getMusicGroupOrganizationCourseSettingId());
@@ -382,11 +386,8 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 				}
 				musicGroupPaymentCalender.setMusicGroupPaymentCalenderCourseSettingsList(newCSList);
 			}
-			musicGroupPaymentCalender.setPaymentAmount(totalPaymentAmount);
-			musicGroupPaymentCalender.setPaymentPattern(musicGroupPaymentCalenderDto.getPaymentPattern());
-			musicGroupPaymentCalender.setPaymentValidEndDate(musicGroupPaymentDateRange.getPaymentValidEndDate());
-			musicGroupPaymentCalender.setPaymentValidStartDate(musicGroupPaymentDateRange.getPaymentValidStartDate());
-			
+			musicGroupPaymentCalender.setCurrentTotalAmount(totalPaymentAmount);
+
 			if (paymentType == PaymentType.MUSIC_APPLY) {
 				if (i == 0) {
 					musicGroupPaymentCalender.setPaymentType(paymentType);
@@ -409,20 +410,10 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 			if (musicGroupPaymentCalender.getDeadlinePaymentDate() == null && payUserType == PayUserType.STUDENT) {
 				musicGroupPaymentCalender.setDeadlinePaymentDate(DateUtil.addDays(musicGroupPaymentCalender.getStartPaymentDate(), 3));
 			}
-			//校验缴费有效期冲突
-			if (paymentType != ADD_STUDENT && paymentType != ADD_COURSE && paymentType != SPAN_GROUP_CLASS_ADJUST) {
-				if(musicGroupPaymentCalender.getPaymentValidStartDate() != null){
-					int count = musicGroupPaymentCalenderDao.queryIntersectionByValidDate(musicGroupId, musicGroupPaymentCalender.getPayUserType(),
-							musicGroupPaymentCalender.getPaymentValidStartDate(), musicGroupPaymentCalender.getPaymentValidEndDate(), null);
-					if (count > 0) {
-						throw new BizException("缴费有效期存在冲突,请修改缴费有效期");
-					}
-				}
-			}
 
 			if (paymentType == PaymentType.ADD_STUDENT) {
 				musicGroupPaymentCalender.setPayUserType(STUDENT);
-				musicGroupPaymentCalender.setIsGiveMusicNetwork(false);
+//				musicGroupPaymentCalender.setIsGiveMusicNetwork(false);
 				if (musicGroupPaymentCalender.getStatus() != AUDITING) {
 					musicGroupPaymentCalender.setExpectNum(1);
 				}
@@ -440,9 +431,9 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 			// 设置批次号
 			musicGroupPaymentCalender.setBatchNo(batchNo);
 			//设置会员缴费金额、级别以及有效期
-			musicGroupPaymentCalender.setMemberPaymentAmount(musicGroupPaymentCalenderDto.getMemberPaymentAmount());
-			musicGroupPaymentCalender.setMemberRankSettingId(musicGroupPaymentCalenderDto.getMemberRankSettingId());
-			musicGroupPaymentCalender.setMemberValidDate(musicGroupPaymentCalenderDto.getMemberValidDate());
+//			musicGroupPaymentCalender.setMemberPaymentAmount(musicGroupPaymentCalenderDto.getMemberPaymentAmount());
+//			musicGroupPaymentCalender.setMemberRankSettingId(musicGroupPaymentCalenderDto.getMemberRankSettingId());
+//			musicGroupPaymentCalender.setMemberValidDate(musicGroupPaymentCalenderDto.getMemberValidDate());
 			musicGroupPaymentCalenderDto.setBatchNo(batchNo);
 			musicGroupPaymentCalenderDao.insert(musicGroupPaymentCalender);
 
@@ -564,9 +555,6 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 		}
 		musicGroupPaymentBaseCalender.setMusicGroup(musicGroup);
 
-		//检测缴费项目是否有费用变更
-//		Map<CalenderBaseServiceEnum, MusicGroupPaymentCalenderBaseService> calenderBaseServiceMap = MusicGroupPaymentCalenderBaseService.calenderBaseServiceMap;
-
 		//计算缴费项目总金额(前端录入)
 		BigDecimal courseActualAmount = musicGroupPaymentCalenderCourseSettingsService.getActualAmount(musicGroupPaymentBaseCalender);
 		BigDecimal memberActualAmount = musicGroupPaymentCalenderMemberService.getActualAmount(musicGroupPaymentBaseCalender);
@@ -692,10 +680,14 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 		result.put("course", musicGroupPaymentCalenderCourseSettingsService.queryCalenderCourseSettings(calenderId));
 		//乐保
 		result.put("repair",musicGroupPaymentCalenderRepairService.findByCalenderId(calenderId));
+		MusicGroupPaymentCalenderMember calenderMember = musicGroupPaymentCalenderMemberService.findByCalenderId(calenderId);
 		//会员信息
-		result.put("member",musicGroupPaymentCalenderMemberService.findByCalenderId(calenderId));
+		result.put("member",calenderMember);
 		//活动相关信息
 		result.put("activity",musicGroupPaymentCalenderActivityService.findByCalenderId(calenderId));
+		if(calenderMember != null){
+			result.put("memberPrivilegesItemList", memberRankPrivilegesService.queryByMemberRankId(calenderMember.getMemberRankSettingId()));
+		}
 		return result;
 	}
 
@@ -799,9 +791,6 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 		// 获取设置的课程
 		List<MusicGroupPaymentCalenderCourseSettings> musicGroupPaymentCalenderCourseSettingsList = musicGroupPaymentCalenderDto
 				.getMusicGroupPaymentCalenderCourseSettingsList();
-//		if (musicGroupPaymentCalenderCourseSettingsList == null) {
-//			musicGroupPaymentCalenderCourseSettingsList = new ArrayList<>();
-//		}
 
 		//会员原价
 		BigDecimal memberPaymentAmount = BigDecimal.ZERO;
@@ -934,7 +923,7 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 			musicGroupPaymentCalender.setAttribute2(musicGroupPaymentCalenderDto.getAttribute2());
 			musicGroupPaymentCalender.setOriginalMemberPaymentAmount(originalMemberPaymentAmount);
 			musicGroupPaymentCalender.setDeadlinePaymentDate(musicGroupPaymentDateRange.getDeadlinePaymentDate());
-			musicGroupPaymentCalender.setIsGiveMusicNetwork(musicGroupPaymentCalenderDto.getIsGiveMusicNetwork());
+//			musicGroupPaymentCalender.setIsGiveMusicNetwork(musicGroupPaymentCalenderDto.getIsGiveMusicNetwork());
 			musicGroupPaymentCalender.setMemo(musicGroupPaymentCalenderDto.getMemo());
 			musicGroupPaymentCalender.setMusicGroupId(musicGroupId);
 			musicGroupPaymentCalender.setMusicGroupOrganizationCourseSettingId(musicGroupPaymentCalenderDto.getMusicGroupOrganizationCourseSettingId());
@@ -983,11 +972,8 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 				musicGroupPaymentCalender.setMusicGroupPaymentCalenderCourseSettingsList(newCSList);
 			}
 
-			musicGroupPaymentCalender.setPaymentAmount(totalPaymentAmount);
-			musicGroupPaymentCalender.setPaymentPattern(musicGroupPaymentCalenderDto.getPaymentPattern());
-			musicGroupPaymentCalender.setPaymentValidEndDate(musicGroupPaymentDateRange.getPaymentValidEndDate());
-			musicGroupPaymentCalender.setPaymentValidStartDate(musicGroupPaymentDateRange.getPaymentValidStartDate());
-			
+			musicGroupPaymentCalender.setCurrentTotalAmount(totalPaymentAmount);
+
 			if (paymentType == PaymentType.MUSIC_APPLY) {
 				if (i == 0) {
 					musicGroupPaymentCalender.setPaymentType(paymentType);
@@ -1010,19 +996,10 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 			if (musicGroupPaymentCalender.getDeadlinePaymentDate() == null && payUserType == PayUserType.STUDENT) {
 				musicGroupPaymentCalender.setDeadlinePaymentDate(DateUtil.addDays(musicGroupPaymentCalender.getStartPaymentDate(), 3));
 			}
-			if (paymentType != ADD_STUDENT && paymentType != ADD_COURSE && paymentType != SPAN_GROUP_CLASS_ADJUST) {
-				if(musicGroupPaymentCalender.getPaymentValidStartDate() != null){
-					int count = musicGroupPaymentCalenderDao.queryIntersectionByValidDate(musicGroupId, musicGroupPaymentCalender.getPayUserType(),
-							musicGroupPaymentCalender.getPaymentValidStartDate(), musicGroupPaymentCalender.getPaymentValidEndDate(), null);
-					if (count > 0) {
-						throw new BizException("缴费有效期存在冲突,请修改缴费有效期");
-					}
-				}
-			}
 
 			if (paymentType == PaymentType.ADD_STUDENT) {
 				musicGroupPaymentCalender.setPayUserType(STUDENT);
-				musicGroupPaymentCalender.setIsGiveMusicNetwork(false);
+//				musicGroupPaymentCalender.setIsGiveMusicNetwork(false);
 				if (musicGroupPaymentCalender.getStatus() != AUDITING) {
 					musicGroupPaymentCalender.setExpectNum(1);
 				}
@@ -1040,9 +1017,9 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 			// 设置批次号
 			musicGroupPaymentCalender.setBatchNo(batchNo);
 			//设置会员缴费金额、级别以及有效期
-			musicGroupPaymentCalender.setMemberPaymentAmount(musicGroupPaymentCalenderDto.getMemberPaymentAmount());
-			musicGroupPaymentCalender.setMemberRankSettingId(musicGroupPaymentCalenderDto.getMemberRankSettingId());
-			musicGroupPaymentCalender.setMemberValidDate(musicGroupPaymentCalenderDto.getMemberValidDate());
+//			musicGroupPaymentCalender.setMemberPaymentAmount(musicGroupPaymentCalenderDto.getMemberPaymentAmount());
+//			musicGroupPaymentCalender.setMemberRankSettingId(musicGroupPaymentCalenderDto.getMemberRankSettingId());
+//			musicGroupPaymentCalender.setMemberValidDate(musicGroupPaymentCalenderDto.getMemberValidDate());
 			musicGroupPaymentCalenderDto.setBatchNo(batchNo);
 			musicGroupPaymentCalenderDao.insert(musicGroupPaymentCalender);
 			List<MusicGroupPaymentCalenderCourseSettings> currentMusicGroupPaymentCalenderCourseSettings = musicGroupPaymentCalender
@@ -1152,20 +1129,13 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 		Date date = new Date();
 		String studentIdStr = musicGroupPaymentCalender.getStudentIds();
 		if (StringUtils.isNoneBlank(studentIdStr)) {
-			//计算总费用
-			BigDecimal expectAmount = BigDecimal.ZERO;
-			BigDecimal expectMemberAmount = musicGroupPaymentCalender.getMemberPaymentAmount();
-			if(musicGroupPaymentCalenderCourseSettingsList != null && musicGroupPaymentCalenderCourseSettingsList.size() > 0){
-				for(MusicGroupPaymentCalenderCourseSettings musicGroupPaymentCalenderCourseSettings : musicGroupPaymentCalenderCourseSettingsList){
-					expectAmount = expectAmount.add(musicGroupPaymentCalenderCourseSettings.getCourseCurrentPrice());
-				}
-			}
 			//当前乐团是否有预排课计划
 			MusicGroupSchoolTermCourseDetail termCourseDetail = musicGroupSchoolTermCourseDetailDao.findByCourseDateAndMusicGroupId(musicGroup.getId(), null, 0);
-
 			List<MusicGroupPaymentStudentCourseDetail> musicGroupPaymentStudentCourseDetailList = new ArrayList<MusicGroupPaymentStudentCourseDetail>();
 			MusicGroupPaymentStudentCourseDetail musicGroupPaymentStudentCourseDetail = null;
 
+			List<MusicGroupPaymentCalenderActivity> calenderActivities = musicGroupPaymentCalenderActivityService.findByCalenderId(musicGroupPaymentCalender.getId());
+			MusicGroupPaymentCalenderMember calenderMember = musicGroupPaymentCalenderMemberService.findByCalenderId(musicGroupPaymentCalender.getId());
 			for (String studentId : studentIdStr.split(",")) {
 				if(termCourseDetail != null){
 					//是否已经预排部分课程
@@ -1184,8 +1154,6 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 				MusicGroupPaymentCalenderDetail musicGroupPaymentCalenderDetail = new MusicGroupPaymentCalenderDetail();
 				musicGroupPaymentCalenderDetail.setMusicGroupPaymentCalenderId(musicGroupPaymentCalender.getId());
 				musicGroupPaymentCalenderDetail.setCreateTime(date);
-//				musicGroupPaymentCalenderDetail.setExpectAmount(expectAmount);
-//				musicGroupPaymentCalenderDetail.setExpectMemberAmount(expectMemberAmount);
 				musicGroupPaymentCalenderDetail.setPaymentStatus(PaymentStatus.NON_PAYMENT);
 				musicGroupPaymentCalenderDetail.setUpdateTime(date);
 				musicGroupPaymentCalenderDetail.setUserId(Integer.parseInt(studentId));
@@ -1194,30 +1162,40 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 
 				musicGroupPaymentCalenderDetailDao.insert(musicGroupPaymentCalenderDetail);
 				//如果是0元那么更新fee表和studentRegistration表
-				if(expectAmount.doubleValue() == 0d && expectMemberAmount.doubleValue() == 0d){
+				if(musicGroupPaymentCalender.getCurrentTotalAmount().compareTo(BigDecimal.ZERO) == 0){
 					// 添加会员有效时长
-					if(musicGroupPaymentCalender.getMemberRankSettingId() != null){
+					if(calenderMember != null){
 						CloudTeacherOrder cloudTeacherOrder = new CloudTeacherOrder();
-						cloudTeacherOrder.setLevel(musicGroupPaymentCalender.getMemberRankSettingId());
+						cloudTeacherOrder.setLevel(calenderMember.getMemberRankSettingId());
 						cloudTeacherOrder.setOrganId(musicGroup.getOrganId());
-						cloudTeacherOrder.setType(musicGroupPaymentCalender.getMemberPeriod());
+						cloudTeacherOrder.setType(calenderMember.getPeriod());
 						cloudTeacherOrder.setStudentId(Integer.parseInt(studentId));
 						cloudTeacherOrder.setOrderId(musicGroup.getOrganId().longValue());
-						cloudTeacherOrder.setTime(musicGroupPaymentCalender.getMemberValidDate());
-						cloudTeacherOrder.setAmount(expectMemberAmount);
+						cloudTeacherOrder.setTime(calenderMember.getNum().intValue());
+						cloudTeacherOrder.setAmount(BigDecimal.ZERO);
 						cloudTeacherOrder.setStatus(1);
 						cloudTeacherOrder.setRemark("进行中乐团0元加学生");
 						cloudTeacherOrder.setMusicGroupId(musicGroup.getId());
 						cloudTeacherOrderDao.insert(cloudTeacherOrder);
-//						studentService.updateMemberRank(cloudTeacherOrder);
 					}
-					MusicGroupStudentFee musicGroupStudentFee = musicGroupStudentFeeDao.findByUser(Integer.parseInt(studentId), musicGroupPaymentCalender.getMusicGroupId());
-					if (musicGroupStudentFee != null) {
-						musicGroupStudentFee.setUpdateTime(date);
-						musicGroupStudentFee.setLatestPaidTime(date);
-						musicGroupStudentFee.setPaymentStatus(PaymentStatus.PAID_COMPLETED);
-						musicGroupStudentFee.setTemporaryCourseFee(new BigDecimal(0));
-						musicGroupStudentFeeDao.update(musicGroupStudentFee);
+					//添加小课包
+					if(calenderActivities != null && calenderActivities.size() > 0){
+						List<ActivityUserMapper> activityUserMapperList = new ArrayList<>();
+						for (MusicGroupPaymentCalenderActivity calenderActivity : calenderActivities) {
+							ActivityUserMapper activityUserMapper = new ActivityUserMapper();
+							activityUserMapper.setActualPrice(BigDecimal.ZERO);
+							activityUserMapper.setActivityId(calenderActivity.getActivityId());
+							Student student = studentDao.get(Integer.parseInt(studentId));
+							activityUserMapper.setUserId(Integer.parseInt(studentId));
+							activityUserMapper.setTeacherId(student.getTeacherId());
+							if("网管课".equals(calenderActivity.getCategoryName())){
+								activityUserMapper.setPracticeFlag(1);
+							}else {
+								activityUserMapper.setVipFlag(1);
+							}
+							activityUserMapperList.add(activityUserMapper);
+						}
+						activityUserMapperService.batchInsert(activityUserMapperList);
 					}
 					//如果是进行中加学员
 					StudentRegistration studentRegistration = studentRegistrationDao.queryByUserIdAndMusicGroupId(Integer.parseInt(studentId), musicGroupPaymentCalender.getMusicGroupId());
@@ -1358,12 +1336,12 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 		}
 		calenderAuditDetailDto.setMusicGroupPaymentCalenders(groupPaymentCalenders);
 		MusicGroupPaymentCalender paymentCalender = groupPaymentCalenders.get(0);
-		if(paymentCalender.getMemberRankSettingId() != null){
-			MemberRankSetting memberRankSetting = memberRankSettingDao.get(paymentCalender.getMemberRankSettingId());
-			if(memberRankSetting != null){
-				paymentCalender.setMemberRankSettingName(memberRankSetting.getName());
-			}
-		}
+//		if(paymentCalender.getMemberRankSettingId() != null){
+//			MemberRankSetting memberRankSetting = memberRankSettingDao.get(paymentCalender.getMemberRankSettingId());
+//			if(memberRankSetting != null){
+//				paymentCalender.setMemberRankSettingName(memberRankSetting.getName());
+//			}
+//		}
 		if(paymentCalender.getPaymentType() == ADD_STUDENT){
 			try {
 				String studentIds = groupPaymentCalenders.get(0).getStudentIds();
@@ -1464,7 +1442,7 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 			for (MusicGroupPaymentCalender musicGroupPaymentCalender : musicGroupPaymentCalenders) {
 				//如果是报名项目,将乐团改为审核中,缴费项目修改状态,审核状态改为审核通过
 				if(musicGroupPaymentCalender.getPayUserType() == SCHOOL){
-					if(musicGroupPaymentCalender.getPaymentAmount().doubleValue() > 0){
+					if(musicGroupPaymentCalender.getCurrentTotalAmount().compareTo(BigDecimal.ZERO) > 0){
 						musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.OPEN);
 					}else{
 						musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.PAID);

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

@@ -309,7 +309,7 @@ public class StudentPaymentRouteOrderServiceImpl extends BaseServiceImpl<Long, S
             List<MusicGroupPaymentCalenderDetail> calenderDetails = musicGroupPaymentCalenderDetailDao.getCalenderDetailWithCalender(studentPaymentRouteOrder.getCalenderId());
             MusicGroupPaymentCalender musicGroupPaymentCalender = musicGroupPaymentCalenderDao.get(studentPaymentRouteOrder.getCalenderId());
 
-            if (amount.compareTo(musicGroupPaymentCalender.getPaymentAmount()) >= 0) {
+            if (amount.compareTo(musicGroupPaymentCalender.getCurrentTotalAmount()) >= 0) {
                 musicGroupPaymentCalender.setActualNum(musicGroupPaymentCalender.getExpectNum());
                 musicGroupPaymentCalender.setStatus(MusicGroupPaymentCalender.PaymentCalenderStatusEnum.PAID);
                 musicGroupPaymentCalenderDao.update(musicGroupPaymentCalender);

+ 10 - 4
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SysCouponCodeServiceImpl.java

@@ -31,7 +31,6 @@ import org.springframework.transaction.annotation.Transactional;
 
 import java.math.BigDecimal;
 import java.util.*;
-import java.util.concurrent.atomic.AtomicInteger;
 
 @Service
 public class SysCouponCodeServiceImpl extends BaseServiceImpl<Long, SysCouponCode> implements SysCouponCodeService {
@@ -160,12 +159,19 @@ public class SysCouponCodeServiceImpl extends BaseServiceImpl<Long, SysCouponCod
             couponCodes.add(couponCode);
         }
         sysCouponCodeDao.batchInsert(couponCodes);
-        sysCoupon.setConsumeNum(new AtomicInteger(sysCoupon.getConsumeNum()).addAndGet(exchangeNum));
+
+        Map<String, Object> updateParam = new HashMap<>();
+        updateParam.put("exchangeNum", exchangeNum);
+        updateParam.put("id", sysCoupon.getId());
+        updateParam.put("tenantId", tenantId);
         if (sysCoupon.getWarningStatus() == 0 && sysCoupon.getStockCount() != -1 && sysCoupon.getStockCount() - sysCoupon.getConsumeNum() < sysCoupon.getWarningStockNum()) {
             sysCouponService.stockWarning(sysCoupon.getId(), sysCoupon.getName());
-            sysCoupon.setWarningStatus(1);
+            updateParam.put("warningStatus", 1);
+        }
+        //扣减库存操作
+        if (sysCouponDao.updateExchange(updateParam) != 1) {
+            throw new BizException("优惠券库存不足!");
         }
-        sysCouponDao.update(sysCoupon);
     }
 
     @Override

+ 12 - 5
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SysCouponIssueRecordServiceImpl.java

@@ -16,7 +16,6 @@ import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.page.PageUtil;
 import com.ym.mec.common.page.WrapperUtil;
 import com.ym.mec.common.tenant.TenantContextHolder;
-import org.redisson.api.RedissonClient;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -45,8 +44,6 @@ public class SysCouponIssueRecordServiceImpl extends ServiceImpl<SysCouponIssueR
     private SysCouponService sysCouponService;
     @Autowired
     private SysUserFeignService sysUserFeignService;
-    @Autowired
-    private RedissonClient redissonClient;
 
     /**
      * 手动发优惠券
@@ -109,7 +106,7 @@ public class SysCouponIssueRecordServiceImpl extends ServiceImpl<SysCouponIssueR
                 .map(this::getById)
                 .orElseThrow(() -> new BizException("未查询到该发放记录!"));
 
-        //修改未使用的优惠券为撤回状态
+        //修改优惠券与用户关系表中未使用的优惠券为撤回状态
         baseMapper.revoke(issueId);
         //查询券的信息
         SysCoupon sysCoupon = Optional.ofNullable(issueRecord.getCouponId())
@@ -118,7 +115,7 @@ public class SysCouponIssueRecordServiceImpl extends ServiceImpl<SysCouponIssueR
 
         //查询未使用的优惠券有多少
         int useCount = baseMapper.queryCouponCode(issueId, 0);
-        if (useCount >= 0) {
+        if (useCount > 0) {
             //返还库存
             baseMapper.opsConsume(sysCoupon.getId(), useCount);
         }
@@ -148,6 +145,16 @@ public class SysCouponIssueRecordServiceImpl extends ServiceImpl<SysCouponIssueR
     }
 
     /**
+     * 查询可以领取的优惠券
+     *
+     * @param userId 用户id
+     */
+    @Override
+    public List<SysCoupon> queryCanBeGetCoupon(Integer userId) {
+        return baseMapper.queryUserCanGetCoupon(userId);
+    }
+
+    /**
      * 查询发放名单
      */
     @Override

+ 65 - 1
mec-biz/src/main/resources/config/mybatis/SysCouponIssueRecordMapper.xml

@@ -95,8 +95,72 @@
 
     <update id="opsConsume" parameterType="object">
         UPDATE sys_coupon
-        SET consume_num_ = consume_num_ - #{consumeNum}
+        SET
+            consume_num_ = consume_num_ - #{consumeNum},
+            stock_count_ = stock_count_ + #{consumeNum}
         WHERE id_ = #{id}
     </update>
 
+    <resultMap type="com.ym.mec.biz.dal.entity.SysCoupon" id="SysCoupon">
+        <result column="id_" property="id" />
+        <result column="name_" property="name" />
+        <result column="description_" property="description" />
+        <result column="status_" property="status" />
+        <result column="issuance_type_" jdbcType="INTEGER" property="issuanceType"/>
+        <result column="type_" property="type" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
+        <result column="type_detail_" jdbcType="VARCHAR" property="typeDetail"/>
+        <result column="face_value_" property="faceValue" />
+        <result column="full_amount_" property="fullAmount" />
+        <result column="limit_exchange_num_" property="limitExchangeNum" />
+        <result column="effective_type_" property="effectiveType" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
+        <result column="deadline_" property="deadline" />
+        <result column="effective_start_time_" property="effectiveStartTime" />
+        <result column="effective_expire_time_" property="effectiveExpireTime" />
+        <result column="end_date_" property="endDate" />
+        <result column="start_date_" property="startDate" />
+        <result column="stock_count_" property="stockCount" />
+        <result column="consume_num_" property="consumeNum" />
+        <result column="warning_stock_num_" property="warningStockNum" />
+        <result column="warning_status_" property="warningStatus" />
+        <result column="create_time_" property="createTime" />
+        <result column="update_time_" property="updateTime" />
+        <result column="tenant_id_" property="tenantId"/>
+    </resultMap>
+
+    <select id="queryUserCanGetCoupon" resultMap="SysCoupon">
+        select id_,
+               name_,
+               description_,
+               status_,
+               issuance_type_,
+               type_,
+               type_detail_,
+               face_value_,
+               full_amount_,
+               limit_exchange_num_,
+               effective_type_,
+               deadline_,
+               effective_start_time_,
+               effective_expire_time_,
+               end_date_,
+               start_date_,
+               stock_count_,
+               consume_num_,
+               warning_stock_num_,
+               warning_status_,
+               create_time_,
+               update_time_,
+               tenant_id_
+        from sys_coupon
+        where issuance_type_ = 0
+          and status_ = 1
+          and (effective_expire_time_ > now() or deadline_ > 0)
+          and (stock_count_ >= consume_num_ or stock_count_ = -1)
+          and id_ not in (
+            select distinct coupon_id_
+            from sys_coupon_code
+            where user_id_ = #{userId}
+        )
+    </select>
+
 </mapper>

+ 16 - 0
mec-biz/src/main/resources/config/mybatis/SysCouponMapper.xml

@@ -107,6 +107,22 @@
 		WHERE id_ = #{id} and tenant_id_ = #{tenantId}
 	</update>
 
+    <!-- 修改库存 -->
+    <update id="updateExchange" parameterType="map">
+        UPDATE sys_coupon
+        <set>
+            stock_count_ = stock_count_ - #{param.exchangeNum},
+            consume_num_ =consume_num_ + #{param.exchangeNum},
+            <if test="warningStatus != null">
+                warning_status_ = #{param.warningStatus},
+            </if>
+            update_time_ = NOW()
+        </set>
+        WHERE id_ = #{param.id}
+        and tenant_id_ = #{param.tenantId}
+        and stock_count_ >= #{param.exchangeNum}
+    </update>
+
 	<!-- 根据主键删除一条记录 -->
 	<delete id="delete" >
 		DELETE FROM sys_coupon WHERE id_ = #{id}

+ 20 - 0
mec-common/common-core/src/main/java/com/ym/mec/common/page/WrapperUtil.java

@@ -74,6 +74,26 @@ public class WrapperUtil<T> {
         return this.hasIn(column, WrapperUtil.toList(val));
     }
 
+    public static <S, O> Integer toInt(Map<S, O> map, S str, String exMsg) {
+        Optional<O> o = Optional.ofNullable(map)
+                .map(m -> m.get(str));
+        return intOptional(o)
+                .orElseThrow(() -> new BizException(exMsg));
+    }
+
+    public static <S, O> Integer toInt(Map<S, O> map, S str) {
+        Optional<O> o = Optional.ofNullable(map)
+                .map(m -> m.get(str));
+        return intOptional(o)
+                .orElse(null);
+    }
+
+    public static <O> Optional<Integer> intOptional(Optional<O> optional) {
+        return optional
+                .map(String::valueOf)
+                .map(Integer::valueOf);
+    }
+
     public static <S, O> String toStr(Map<S, O> map, S str) {
         Optional<O> o = Optional.ofNullable(map)
                 .map(m -> m.get(str));

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

@@ -6,7 +6,6 @@ import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDetailDao;
 import com.ym.mec.biz.dal.dao.StudentPreRegistrationDao;
 import com.ym.mec.biz.dal.dto.MusicGroupSubjectGoodsAndInfoDto;
 import com.ym.mec.biz.dal.dto.RegisterPayDto;
-import com.ym.mec.biz.dal.dto.RenewParamDto;
 import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentCalenderStatusEnum;
 import com.ym.mec.biz.dal.entity.MusicGroupStudentFee.PaymentStatus;
@@ -26,6 +25,7 @@ import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpStatus;
 import org.springframework.web.bind.annotation.*;
+
 import javax.annotation.Resource;
 import java.util.HashMap;
 import java.util.List;

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

@@ -79,7 +79,6 @@ public class MusicGroupPaymentCalenderController extends BaseController {
             model.put("musicGroup",musicGroupDao.get(musicGroupId));
             model.put("balance",studentRegistration.getBalance());
             model.put("calender",calender);
-            model.put("memberPrivilegesItemList", memberRankPrivilegesService.queryByMemberRankId(calender.getMemberRankSettingId()));
             musicGroupPaymentCalenderService.getCalenderDetail(model,calenderId);
             return succeed(model);
         }else if(calender.getStatus() == PaymentCalenderStatusEnum.OVER){

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

@@ -50,7 +50,7 @@ public class MusicGroupPaymentCalenderDetailController extends BaseController {
     @PostMapping("/updateExpectAmount")
     @PreAuthorize("@pcs.hasPermissions('musicGroupPaymentCalenderDetail/updateExpectAmount')")
     public Object updateExpectAmount(BigDecimal expectAmount,BigDecimal expectMemberAmount,String ids) {
-        musicGroupPaymentCalenderDetailService.updateExpectAmount(expectAmount,expectMemberAmount,ids);
+//        musicGroupPaymentCalenderDetailService.updateExpectAmount(expectAmount,expectMemberAmount,ids);
         return succeed();
     }
 

+ 47 - 8
mec-web/src/main/java/com/ym/mec/web/controller/SysCouponIssueRecordController.java

@@ -4,11 +4,9 @@ package com.ym.mec.web.controller;
 import com.ym.mec.biz.service.SysCouponIssueRecordService;
 import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.entity.HttpResponseResult;
+import com.ym.mec.common.page.WrapperUtil;
 import io.swagger.annotations.ApiOperation;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
 import java.util.Map;
@@ -38,19 +36,54 @@ public class SysCouponIssueRecordController extends BaseController {
         return succeed();
     }
 
+    /**
+     * 检查撤销的优惠券
+     *
+     * @param param issueId发放记录id
+     */
     @ApiOperation("检查撤销的优惠券")
     @PostMapping(value = "/checkRevoke")
-    public HttpResponseResult checkRevoke(Integer id) {
-        return succeed(couponIssueRecordService.checkRevoke(id));
+    public HttpResponseResult checkRevoke(@RequestBody Map<String, Object> param) {
+        Integer issueId = WrapperUtil.toInt(param, "issueId", "传入参数错误!");
+        return succeed(couponIssueRecordService.checkRevoke(issueId));
     }
 
+    /**
+     * 撤销发放优惠券
+     *
+     * @param param issueId发放记录id
+     */
     @ApiOperation("撤销发放优惠券")
     @PostMapping(value = "/revokeCoupon")
-    public HttpResponseResult revokeCoupon(Integer id) {
-        couponIssueRecordService.revokeCoupon(id);
+    public HttpResponseResult revokeCoupon(@RequestBody Map<String, Object> param) {
+        Integer issueId = WrapperUtil.toInt(param, "issueId", "传入参数错误!");
+        couponIssueRecordService.revokeCoupon(issueId);
+        return succeed();
+    }
+
+    /**
+     * 手动领取优惠券
+     *
+     * @param param userId 领取者id
+     * @param param couponId 优惠券id
+     */
+    @ApiOperation("手动领取优惠券")
+    @PostMapping(value = "/manualIssueCoupon")
+    public HttpResponseResult manualIssueCoupon(@RequestBody Map<String, Object> param) {
+        Integer userId = WrapperUtil.toInt(param, "userId", "传入参数错误!");
+        Integer couponId = WrapperUtil.toInt(param, "couponId", "传入参数错误!");
+        couponIssueRecordService.manualIssueCoupon(userId, couponId);
         return succeed();
     }
 
+    /**
+     * 查询优惠券发放名单
+     *
+     * @param param issueId 发放记录id
+     * @param param organId 分部id
+     * @param param subjectId 声部id
+     * @param param usageStatus 状态
+     */
     @ApiOperation("查询优惠券发放名单")
     @PostMapping(value = "/queryIssueDetail")
     public HttpResponseResult queryIssueDetail(@RequestBody Map<String, Object> param) {
@@ -63,5 +96,11 @@ public class SysCouponIssueRecordController extends BaseController {
         return succeed(couponIssueRecordService.queryIssueRecord(param));
     }
 
+    @ApiOperation("查询优惠券发放记录")
+    @GetMapping(value = "/queryCanBeGet")
+    public HttpResponseResult queryCanBeGetCoupon(Integer userId) {
+        return succeed(couponIssueRecordService.queryCanBeGetCoupon(userId));
+    }
+
 }