فهرست منبع

Merge branch 'master' into adapay_delay

周箭河 4 سال پیش
والد
کامیت
e4e01083c7
24فایلهای تغییر یافته به همراه502 افزوده شده و 300 حذف شده
  1. 9 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/DataChangeLogDao.java
  2. 2 2
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/CourseSchedule.java
  3. 70 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/DataChangeLog.java
  4. 42 36
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/VipGroupActivity.java
  5. 35 0
      mec-biz/src/main/java/com/ym/mec/biz/event/EntityChangeEvent.java
  6. 26 0
      mec-biz/src/main/java/com/ym/mec/biz/event/listener/EntityChangeListener.java
  7. 33 0
      mec-biz/src/main/java/com/ym/mec/biz/event/source/EntityChangeEventSource.java
  8. 8 0
      mec-biz/src/main/java/com/ym/mec/biz/service/DataChangeLogService.java
  9. 19 0
      mec-biz/src/main/java/com/ym/mec/biz/service/LogService.java
  10. 1 1
      mec-biz/src/main/java/com/ym/mec/biz/service/VipGroupActivityService.java
  11. 0 8
      mec-biz/src/main/java/com/ym/mec/biz/service/VipGroupService.java
  12. 12 11
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleStudentPaymentServiceImpl.java
  13. 34 181
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleTeacherSalaryServiceImpl.java
  14. 22 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/DataChangeLogServiceImpl.java
  15. 16 4
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/DegreeRegistrationServiceImpl.java
  16. 83 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/LogServiceImpl.java
  17. 2 1
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRegistrationServiceImpl.java
  18. 10 4
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/VipGroupActivityServiceImpl.java
  19. 0 42
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/VipGroupServiceImpl.java
  20. 2 2
      mec-biz/src/main/resources/config/mybatis/CourseScheduleTeacherSalaryMapper.xml
  21. 66 0
      mec-biz/src/main/resources/config/mybatis/DataChangeLogMapper.xml
  22. 5 1
      mec-teacher/src/main/java/com/ym/mec/teacher/controller/VipGroupActivityController.java
  23. 0 6
      mec-web/src/main/java/com/ym/mec/web/controller/CourseScheduleTeacherSalaryController.java
  24. 5 1
      mec-web/src/main/java/com/ym/mec/web/controller/VipGroupActivityController.java

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

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

+ 2 - 2
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/CourseSchedule.java

@@ -27,8 +27,8 @@ public class CourseSchedule {
 
 	public enum CourseScheduleType implements BaseEnum<String, CourseScheduleType> {
 
-		SINGLE("SINGLE", "单技课"), MIX("MIX", "合奏课"), HIGH("HIGH", "小班课"), VIP("VIP", "vip课"), DEMO("DEMO", "试听课"), COMPREHENSIVE("COMPREHENSIVE", "综合课"), PRACTICE(
-				"PRACTICE", "网管课"), ENLIGHTENMENT("ENLIGHTENMENT", "启蒙课"), TRAINING_SINGLE("TRAINING_SINGLE", "集训单技课"), TRAINING_MIX("TRAINING_MIX", "集训合奏课"), CLASSROOM(
+		SINGLE("SINGLE", "声部课"), MIX("MIX", "合奏课"), HIGH("HIGH", "小班课"), VIP("VIP", "vip课"), DEMO("DEMO", "试听课"), COMPREHENSIVE("COMPREHENSIVE", "综合课"), PRACTICE(
+				"PRACTICE", "网管课"), ENLIGHTENMENT("ENLIGHTENMENT", "启蒙课"), TRAINING_SINGLE("TRAINING_SINGLE", "集训声部课"), TRAINING_MIX("TRAINING_MIX", "集训合奏课"), CLASSROOM(
 				"CLASSROOM", "课堂课"),COMM("COMM","对外课程"),HIGH_ONLINE("HIGH_ONLINE","网络基础训练课"),MUSIC_NETWORK("MUSIC_NETWORK","乐团网管课");
 
 		private String code;

+ 70 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/DataChangeLog.java

@@ -0,0 +1,70 @@
+package com.ym.mec.biz.dal.entity;
+
+import org.apache.commons.lang3.builder.ToStringBuilder;
+
+/**
+ * 对应数据库表(data_change_log):
+ */
+public class DataChangeLog {
+
+	/**  */
+	private Long id;
+	
+	/** 操作人编号 */
+	private Integer operatorId;
+	
+	/** 变更信息 */
+	private String changeInfo;
+	
+	/** 操作时间 */
+	private java.util.Date createTime;
+	
+	/** 类型名称 */
+	private String className;
+	
+	public void setId(Long id){
+		this.id = id;
+	}
+	
+	public Long getId(){
+		return this.id;
+	}
+			
+	public void setOperatorId(Integer operatorId){
+		this.operatorId = operatorId;
+	}
+	
+	public Integer getOperatorId(){
+		return this.operatorId;
+	}
+			
+	public void setChangeInfo(String changeInfo){
+		this.changeInfo = changeInfo;
+	}
+	
+	public String getChangeInfo(){
+		return this.changeInfo;
+	}
+			
+	public void setCreateTime(java.util.Date createTime){
+		this.createTime = createTime;
+	}
+	
+	public java.util.Date getCreateTime(){
+		return this.createTime;
+	}
+			
+	public void setClassName(String className){
+		this.className = className;
+	}
+	
+	public String getClassName(){
+		return this.className;
+	}
+			
+	@Override
+	public String toString() {
+		return ToStringBuilder.reflectionToString(this);
+	}
+
+}

+ 42 - 36
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/VipGroupActivity.java

@@ -1,6 +1,7 @@
 package com.ym.mec.biz.dal.entity;
 
 import com.ym.mec.biz.dal.enums.VipGroupActivityTypeEnum;
+import io.swagger.annotations.ApiModelProperty;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 
 /**
@@ -8,70 +9,75 @@ import org.apache.commons.lang3.builder.ToStringBuilder;
  */
 public class VipGroupActivity {
 
-	/**  */
+	@ApiModelProperty(value = "活动编号")
 	private Integer id;
-	
-	/**  */
+
+	@ApiModelProperty(value = "活动名称")
 	private String name;
-	
-	/**  */
+
+	@ApiModelProperty(value = "活动描述\n")
 	private String description;
-	
-	/**  */
+
+	@ApiModelProperty(value = "课程形式")
 	private String vipGroupCategoryIdList;
-	
-	/**  */
+
+	@ApiModelProperty(value = "活动开始时间")
 	private java.util.Date startTime;
-	
-	/**  */
+
+	@ApiModelProperty(value = "活动结束时间")
 	private java.util.Date endTime;
-	
-	/**  */
+
+	@ApiModelProperty(value = "适用分部")
 	private String organId;
-	
-	/**  */
+
+	@ApiModelProperty(value = "可排课开始时间")
 	private java.util.Date coursesStartTime;
-	
-	/**  */
+
+	@ApiModelProperty(value = "可排课截至时间")
 	private java.util.Date coursesEndTime;
-	
-	/** 活动类型(基础活动、折扣、赠送课时) */
+
+	@ApiModelProperty(value = "活动类型(基础活动、折扣、赠送课时)")
 	private VipGroupActivityTypeEnum type;
-	
-	/**  */
+
+	@ApiModelProperty(value = "活动值")
 	private String attribute1;
-	
-	/**  */
+
+	@ApiModelProperty(value = "")
 	private String attribute2;
-	
-	/**  */
+
+	@ApiModelProperty(value = "")
 	private String attribute3;
-	
-	/** 薪水只读标识(1-只读 0-可写) */
+
+	@ApiModelProperty(value = "薪水只读标识(1-只读 0-可写)")
 	private String salaryReadonlyFlag;
 
+	@ApiModelProperty(value = "单节课程费用只读标识")
 	private String paymentReadonlyFlag;
-	
-	/** 赠送课时支付薪水标识(1-计课酬  0-不计课酬) */
+
+	@ApiModelProperty(value = "赠送课时支付薪水标识(1-计课酬  0-不计课酬)")
 	private String giveClassPaySalaryFlag;
-	
-	/**  */
+
+	@ApiModelProperty(value = "创建时间")
 	private java.util.Date createTime;
-	
-	/**  */
+
+	@ApiModelProperty(value = "更新时间")
 	private java.util.Date updateTime;
-	
-	/** 结算标准 */
+
+	@ApiModelProperty(value = "结算标准")
 	private String salarySettlementJson;
 
 	private String vipGroupCategoryNames;
-	
+
+	@ApiModelProperty(value = "是否删除")
 	private Boolean delFlag = false;
 
+	@ApiModelProperty(value = "是否可用")
 	private Integer enable;
 
+	@ApiModelProperty(value = "线上课是否参与梯度奖励")
 	private Integer onlineClassJoinGradientRewards;
 
+	@ApiModelProperty(value = "线下课是否参与梯度奖励")
 	private Integer offlineClassJoinGradientRewards;
 
 	public Integer getOnlineClassJoinGradientRewards() {

+ 35 - 0
mec-biz/src/main/java/com/ym/mec/biz/event/EntityChangeEvent.java

@@ -0,0 +1,35 @@
+package com.ym.mec.biz.event;
+
+import org.springframework.context.ApplicationEvent;
+
+/**
+ * @Author qnc99
+ * @Date 2020/12/15 0015
+ */
+public class EntityChangeEvent extends ApplicationEvent {
+
+    private Integer operatorId;
+
+    private Object oldEntity;
+
+    private Object newEntity;
+
+    public EntityChangeEvent(Object source, Object oldEntity, Object newEntity, Integer operatorId) {
+        super(source);
+        this.oldEntity = oldEntity;
+        this.newEntity = newEntity;
+        this.operatorId = operatorId;
+    }
+
+    public Object getOldEntity() {
+        return oldEntity;
+    }
+
+    public Object getNewEntity() {
+        return newEntity;
+    }
+
+    public Integer getOperatorId() {
+        return operatorId;
+    }
+}

+ 26 - 0
mec-biz/src/main/java/com/ym/mec/biz/event/listener/EntityChangeListener.java

@@ -0,0 +1,26 @@
+package com.ym.mec.biz.event.listener;
+
+import com.ym.mec.biz.event.EntityChangeEvent;
+import com.ym.mec.biz.service.LogService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.event.EventListener;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.stereotype.Component;
+
+/**
+ * @Author qnc99
+ * @Date 2020/12/15 0015
+ */
+@Component
+public class EntityChangeListener {
+
+    @Autowired
+    private LogService logService;
+
+    @Async
+    @EventListener
+    public void onEntityChangedEvent(EntityChangeEvent entityChangeEvent) {
+        logService.entityVariationAnalysis(entityChangeEvent.getOldEntity(), entityChangeEvent.getNewEntity(), entityChangeEvent.getOperatorId());
+    }
+
+}

+ 33 - 0
mec-biz/src/main/java/com/ym/mec/biz/event/source/EntityChangeEventSource.java

@@ -0,0 +1,33 @@
+package com.ym.mec.biz.event.source;
+
+import com.ym.mec.biz.dal.enums.GroupType;
+import com.ym.mec.biz.event.EntityChangeEvent;
+import com.ym.mec.biz.event.StudentCourseChangeEvent;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.context.ApplicationContext;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+
+/**
+ * @Author qnc99
+ * @Date 2020/12/15 0015
+ */
+@Service
+public class EntityChangeEventSource {
+    private Logger logger = LoggerFactory.getLogger(this.getClass());
+
+    @Resource
+    private ApplicationContext applicationContext;
+
+    /**
+     * @describe 数据变更事件源
+     * @author Joburgess
+     * @date 2020.09.24
+     * @return void
+     */
+    public void entityChange(Object oldEntity, Object newEntity, Integer operatorId) {
+        applicationContext.publishEvent(new EntityChangeEvent(this, oldEntity, newEntity, operatorId));
+    }
+}

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

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

+ 19 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/LogService.java

@@ -0,0 +1,19 @@
+package com.ym.mec.biz.service;
+
+/**
+ * @Author qnc99
+ * @Date 2020/12/15 0015
+ **/
+public interface LogService {
+
+    /**
+     * @describe 实体类变动分析
+     * @author qnc99
+     * @date 2020/12/15 0015
+     * @param oldEntity:
+     * @param newEntity:
+     * @return void
+     */
+    void entityVariationAnalysis(Object oldEntity, Object newEntity, Integer operatorId);
+
+}

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

@@ -20,7 +20,7 @@ public interface VipGroupActivityService extends BaseService<Integer, VipGroupAc
      * @Date: 2019/10/1
      * 修改vip课活动方案
      */
-    void updateVipGroupActivity(VipGroupActivityAddDto vipGroupActivityAddDto);
+    void updateVipGroupActivity(VipGroupActivityAddDto vipGroupActivityAddDto, Integer operatorId);
 
     /**
      * @Author: Joburgess

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

@@ -425,12 +425,4 @@ public interface VipGroupService extends BaseService<Long, VipGroup> {
      * @return java.util.List<com.ym.mec.biz.dal.dto.TeacherBasicDto>
      */
     List<TeacherBasicDto> findTeacherWithVipGroupOrganAndSubject(Long vipGroupId);
-
-    /**
-     * 更新线上课老师的课酬
-     * @param startDate
-     * @param endDate
-     * @return
-     */
-    void updateHistoryTeacherSalaryOfOnline(String startDate, String endDate);
 }

+ 12 - 11
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleStudentPaymentServiceImpl.java

@@ -321,17 +321,16 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 		List<Long> studentPaymentIds = JSON.parseArray(classAdjust.getStudentPaymentIds(), Long.class);
 		String batchNo = classAdjust.getBatchNo();
 
-		List<CourseScheduleStudentPayment> courseScheduleStudentPayments = new ArrayList<>();
-
 		//获取默认的排课时长
 //		classAdjust.getDefaultCourseTypeMinute();
 //		String courseDefaultMinutes = sysConfigDao.findConfigValue("music_course_default_minutes");
 		JSONObject jsonObject = JSON.parseObject(classAdjust.getDefaultCourseTypeMinute());
-
+		List<CourseScheduleStudentPayment> totalCourseScheduleStudentPayments = new ArrayList<>();
 		for (Integer studentId : studentIds) {
 			List<MusicGroupPaymentStudentCourseDetail> musicGroupPaymentStudentCourseDetails = null;
 			BigDecimal typeCourseTotalOriginalPrice = new BigDecimal("0"), typeCourseTotalCurrentPrice = new BigDecimal("0");
-			int index = courseScheduleStudentPayments.size();
+			List<CourseScheduleStudentPayment> oldCourseScheduleStudentPayments = new ArrayList<>();
+			List<CourseScheduleStudentPayment> newCourseScheduleStudentPayments = new ArrayList<>();
 			for (int i = 0; i < courseSchedules.size(); i++) {
 				CourseSchedule courseSchedule = courseSchedules.get(i);
 				//优先处理之前的剩余课程
@@ -352,7 +351,8 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 						studentPayment.setSettlementTime(null);
 						studentPayment.setExamSongDownloadJson(null);
 						studentPayment.setId(null);
-						courseScheduleStudentPayments.add(studentPayment);
+						oldCourseScheduleStudentPayments.add(studentPayment);
+						totalCourseScheduleStudentPayments.add(studentPayment);
 						continue ;
 					}
 				}
@@ -365,13 +365,13 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 				}
 				//获取合班时的缴费项目
 				Set<Long> calenderIds = musicGroupPaymentCalenderDao.findByBatchNoAndStudentId(batchNo,studentId);
-				List<MusicGroupPaymentCalenderCourseSettings> musicGroupPaymentCalenderCourseSettings = musicGroupPaymentCalenderCourseSettingsDao.getWithPaymentCalendersAndCourseType(calenderIds, null);
+				List<MusicGroupPaymentCalenderCourseSettings> musicGroupPaymentCalenderCourseSettings = musicGroupPaymentCalenderCourseSettingsDao.getWithPaymentCalendersAndCourseType(calenderIds, courseSchedule.getType());
 				MusicGroupPaymentCalenderCourseSettings courseSetting = musicGroupPaymentCalenderCourseSettings.get(0);
 				//课程每分钟原价
-				BigDecimal unitMinuteOriginalPrice = courseSetting.getCourseOriginalPrice().divide(new BigDecimal(courseSetting.getCourseTotalMinuties()), CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_DOWN);
+				BigDecimal unitMinuteOriginalPrice = courseSetting.getCourseOriginalPrice().divide(new BigDecimal(courseSetting.getCourseTotalMinuties()), CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN);
 
 				//课程每分钟现价
-				BigDecimal unitMinuteCurrentPrice = courseSetting.getCourseCurrentPrice().divide(new BigDecimal(courseSetting.getCourseTotalMinuties()), CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_DOWN);
+				BigDecimal unitMinuteCurrentPrice = courseSetting.getCourseCurrentPrice().divide(new BigDecimal(courseSetting.getCourseTotalMinuties()), CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN);
 
 				//默认课程时长
 				int courseDuration = Integer.parseInt(jsonObject.get(courseSchedule.getType().getCode()).toString());
@@ -391,11 +391,12 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 				cssp.setOriginalPrice(courseOriginalPrice);
 				cssp.setExpectPrice(courseCurrentPrice);
 				cssp.setActualPrice(BigDecimal.ZERO);
-				courseScheduleStudentPayments.add(cssp);
+				newCourseScheduleStudentPayments.add(cssp);
 				if(courseSchedules.size() - 1 == i){
-					CourseScheduleStudentPayment scheduleStudentPayment = courseScheduleStudentPayments.get(index);
+					CourseScheduleStudentPayment scheduleStudentPayment = newCourseScheduleStudentPayments.get(0);
 					scheduleStudentPayment.setOriginalPrice(scheduleStudentPayment.getOriginalPrice().add(courseSetting.getCourseOriginalPrice().subtract(typeCourseTotalOriginalPrice)));
 					scheduleStudentPayment.setExpectPrice(scheduleStudentPayment.getExpectPrice().add(courseSetting.getCourseCurrentPrice().subtract(typeCourseTotalCurrentPrice)));
+					totalCourseScheduleStudentPayments.addAll(newCourseScheduleStudentPayments);
 				}
 				//获取课程类型默认排课时长
 				int typeCourseDuration = Integer.parseInt(jsonObject.get(courseSchedule.getType().getCode()).toString());
@@ -411,7 +412,7 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 				musicGroupPaymentStudentCourseDetailDao.batchUpdate(musicGroupPaymentStudentCourseDetails);
 			}
 		}
-		courseScheduleStudentPaymentDao.batchInsert(courseScheduleStudentPayments);
+		courseScheduleStudentPaymentDao.batchInsert(totalCourseScheduleStudentPayments);
 	}
 
 

+ 34 - 181
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleTeacherSalaryServiceImpl.java

@@ -30,6 +30,7 @@ import org.springframework.util.CollectionUtils;
 import org.springframework.util.StringUtils;
 
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.time.Duration;
 import java.time.LocalDateTime;
 import java.util.*;
@@ -43,12 +44,8 @@ public class CourseScheduleTeacherSalaryServiceImpl extends BaseServiceImpl<Long
     @Autowired
     private VipGroupActivityDao vipGroupActivityDao;
     @Autowired
-    private CourseScheduleComplaintsDao courseScheduleComplaintsDao;
-    @Autowired
     private CourseScheduleStudentPaymentDao courseScheduleStudentPaymentDao;
     @Autowired
-    private SysUserCashAccountService sysUserCashAccountService;
-    @Autowired
     @Lazy
     private VipGroupService vipGroupService;
     @Autowired
@@ -58,8 +55,6 @@ public class CourseScheduleTeacherSalaryServiceImpl extends BaseServiceImpl<Long
     @Autowired
     private TeacherDefaultMusicGroupSalaryDao teacherDefaultMusicGroupSalaryDao;
     @Autowired
-    private SysUserCashAccountDetailDao sysUserCashAccountDetailDao;
-    @Autowired
     private SysConfigService sysConfigDao;
     @Autowired
     private TeacherAttendanceDao teacherAttendanceDao;
@@ -70,14 +65,10 @@ public class CourseScheduleTeacherSalaryServiceImpl extends BaseServiceImpl<Long
     @Autowired
     private ClassGroupStudentMapperDao classGroupStudentMapperDao;
     @Autowired
-    private ClassGroupTeacherSalaryDao classGroupTeacherSalaryDao;
-    @Autowired
     private TeacherDefaultVipGroupSalaryDao teacherDefaultVipGroupSalaryDao;
     @Autowired
     private CourseScheduleRewardsRulesService courseScheduleRewardsRulesService;
     @Autowired
-    private VipGroupCategoryDao vipGroupCategoryDao;
-    @Autowired
     private StudentAttendanceDao studentAttendanceDao;
     @Autowired
     private TeacherSalaryComplaintsDao teacherSalaryComplaintsDao;
@@ -91,6 +82,8 @@ public class CourseScheduleTeacherSalaryServiceImpl extends BaseServiceImpl<Long
     private MusicGroupDao musicGroupDao;
     @Autowired
     private TeacherDefaultPracticeGroupSalaryDao teacherDefaultPracticeGroupSalaryDao;
+    @Autowired
+    private VipGroupDao vipGroupDao;
 
     private static final Logger LOGGER = LoggerFactory
             .getLogger(CourseScheduleTeacherSalaryServiceImpl.class);
@@ -221,7 +214,7 @@ public class CourseScheduleTeacherSalaryServiceImpl extends BaseServiceImpl<Long
         List<CourseScheduleTeacherSalary> someDayAgoTeacherCourseSalaryNoSettlement = courseScheduleTeacherSalaryDao.findTeacherCourseSalaryNoSettlement(startDate,endDate);
         if (!CollectionUtils.isEmpty(someDayAgoTeacherCourseSalaryNoSettlement)) {
             someDayAgoTeacherCourseSalaryNoSettlement.forEach(courseScheduleTeacherSalary -> {
-                courseScheduleTeacherSalary.setActualSalary(courseScheduleTeacherSalary.getTeacherActualSalary());
+                courseScheduleTeacherSalary.setActualSalary(courseScheduleTeacherSalary.getTeacherActualSalary().setScale(BigDecimal.ZERO.intValue(), BigDecimal.ROUND_HALF_UP));
                 courseScheduleTeacherSalary.setSettlementTime(now);
                 courseScheduleTeacherSalaryDao.update(courseScheduleTeacherSalary);
             });
@@ -295,15 +288,38 @@ public class CourseScheduleTeacherSalaryServiceImpl extends BaseServiceImpl<Long
     @Override
     @Transactional(rollbackFor = Exception.class)
     public void teacherSalarySettlement() {
-//        int days = Integer.parseInt(sysConfigDao.findByParamName(SysConfigService.VIP_APPEAL_DAYS_RANGE).getParanValue());
-//        int days = 0;
-        BigDecimal percent = new BigDecimal(10);
         Date now = new Date();
         Date date = DateUtil.addMonths(now, -1);
         String startDate = DateUtil.format(DateUtil.getFirstDayOfMonth(date),DateUtil.DEFAULT_PATTERN);
         String endDate = DateUtil.format(DateUtil.getLastDayOfMonth(date),DateUtil.DEFAULT_PATTERN);
 
-        vipGroupService.updateHistoryTeacherSalaryOfOnline(startDate, endDate);
+        // 查询需要修改的课酬记录
+        List<TeacherVipSalaryDto> teacherSalaryList = courseScheduleTeacherSalaryDao.queryOnlineCourseByGroupType(startDate, endDate);
+
+        for (TeacherVipSalaryDto ts : teacherSalaryList) {
+            // 修复兼职老师不管1v?和全职老师1vn的课酬为系统默认课酬(不管线上还是线下课)
+            if (ts.getTeacherJobNature() != JobNatureEnum.FULL_TIME || !org.apache.commons.lang3.StringUtils.equalsIgnoreCase("1v1", ts.getVipGroupCategoryName())) {
+                // 查询默认课酬
+                TeacherDefaultVipGroupSalary tdvs = teacherDefaultVipGroupSalaryDao.findByTeacherAndCategory(ts.getUserId(), ts.getVipGroupCategoryId());
+                if (tdvs != null) {
+                    if (ts.getTeachMode() == TeachModeEnum.ONLINE) {
+                        ts.setExpectSalary(tdvs.getOfflineClassesSalary());
+                    } else {
+                        ts.setExpectSalary(tdvs.getOfflineClassesSalary());
+                    }
+                }
+            }else{
+                //按照活动重新计算课酬
+                VipGroup vipGroup = vipGroupService.get(Long.valueOf(ts.getMusicGroupId()));
+                Map<String, BigDecimal> teachModeSalaryMap = vipGroupService.countVipGroupPredictFee(vipGroup, ts.getUserId(), null, null);
+                if(TeachModeEnum.ONLINE.equals(ts.getTeachMode())&&teachModeSalaryMap.containsKey("onlineTeacherSalary")){
+                    ts.setExpectSalary(teachModeSalaryMap.get("onlineTeacherSalary"));
+                }else if(TeachModeEnum.OFFLINE.equals(ts.getTeachMode())&&teachModeSalaryMap.containsKey("offlineTeacherSalary")){
+                    ts.setExpectSalary(teachModeSalaryMap.get("offlineTeacherSalary"));
+                }
+            }
+            courseScheduleTeacherSalaryDao.update(ts);
+        }
 
         //获取教师未结算课程记录
         List<CourseScheduleTeacherSalary> someDayAgoTeacherCourseSalaryNoSettlement = courseScheduleTeacherSalaryDao.findSomeDayAgoTeacherCourseSalaryNoSettlement(startDate,endDate);
@@ -314,31 +330,14 @@ public class CourseScheduleTeacherSalaryServiceImpl extends BaseServiceImpl<Long
         //获取未结算课程编号列表
         List<Long> courseScheduleIds = someDayAgoTeacherCourseSalaryNoSettlement.stream().map(CourseScheduleTeacherSalary::getCourseScheduleId).collect(Collectors.toList());
 
-        //所有课程的学生考勤记录
-//        List<StudentAttendance> studentAttendances = studentAttendanceDao.findByCourseIds(courseScheduleIds);
-//        Map<Long, List<StudentAttendance>> courseStudentAttendancesMap = studentAttendances.stream().collect(Collectors.groupingBy(StudentAttendance::getCourseScheduleId));
-
-        //所有课程的教师考勤记录
-//        List<TeacherAttendance> teacherAttendancesByCourseSchedule = teacherAttendanceDao.findTeacherIdByCourseSchedule(courseScheduleIds);
-//        Map<Long, List<TeacherAttendance>> courseTeacherAttendancesMap = teacherAttendancesByCourseSchedule.stream().collect(Collectors.groupingBy(TeacherAttendance::getCourseScheduleId));
-
-        //获取未结算课程投诉记录
-        List<CourseScheduleComplaints> courseScheduleComplaints = courseScheduleComplaintsDao.findByCourseScheduleIds(courseScheduleIds);
         //获取未结算课程学生缴费信息
         List<CourseScheduleStudentPayment> courseScheduleStudentPayments = courseScheduleStudentPaymentDao.findByCourseScheduleIds(courseScheduleIds);
 
-        //根据课程将投诉信息分组
-        Map<Long, List<CourseScheduleComplaints>> complaintsGroupByCourse = courseScheduleComplaints.stream().collect(Collectors.groupingBy(CourseScheduleComplaints::getCourseScheduleId));
         //根据课程将学生缴费信息分组
         Map<Long, List<CourseScheduleStudentPayment>> studentPaymentGroupByCourse = courseScheduleStudentPayments.stream().collect(Collectors.groupingBy(CourseScheduleStudentPayment::getCourseScheduleId));
 
         //需更新教师课程结算记录
         List<CourseScheduleTeacherSalary> updateTeacherSalarys = new ArrayList<>();
-        //需更新学生课程缴费记录
-        List<CourseScheduleStudentPayment> updateStudentPayments = new ArrayList<>();
-
-        //用户账户资金变动信息列表
-//        List<SysUserCashAccountDetail> userCashAccountDetails = new ArrayList<>();
 
         //处理课酬信息
         someDayAgoTeacherCourseSalaryNoSettlement.forEach(courseScheduleTeacherSalary -> {
@@ -349,160 +348,14 @@ public class CourseScheduleTeacherSalaryServiceImpl extends BaseServiceImpl<Long
             if (CollectionUtils.isEmpty(studentPaymentsWithCourse)) {
                 return;
             }
+            BigDecimal expectSalary = courseScheduleTeacherSalary.getTeacherActualSalary().setScale(BigDecimal.ZERO.intValue(), BigDecimal.ROUND_HALF_UP);
 
-//            List<StudentAttendance> courseStudentAttendances = courseStudentAttendancesMap.get(courseScheduleTeacherSalary.getCourseScheduleId());
-//            int normalStudentNum=0;
-//            if(CollectionUtils.isEmpty(courseStudentAttendances)){
-//                return;
-//            }
-//            for (StudentAttendance courseStudentAttendance : courseStudentAttendances) {
-//                if(Objects.nonNull(courseStudentAttendance.getStatus())&&courseStudentAttendance.getStatus().equals(StudentAttendanceStatusEnum.NORMAL)){
-//                    normalStudentNum+=1;
-//                }
-//            }
-//            if(normalStudentNum==0){
-//                return;
-//            }
-
-//            List<TeacherAttendance> teacherAttendances = courseTeacherAttendancesMap.get(courseScheduleTeacherSalary.getCourseScheduleId());
-//            if(CollectionUtils.isEmpty(teacherAttendances)){
-//                return;
-//            }
-//            int teacherAttendanceNum=0;
-//            for (TeacherAttendance teacherAttendance : teacherAttendances) {
-//                if(Objects.nonNull(teacherAttendance.getSignInTime())||Objects.nonNull(teacherAttendance.getSignOutTime())){
-//                    teacherAttendanceNum+=1;
-//                }
-//            }
-//            if(teacherAttendanceNum==0){
-//                return;
-//            }
-
-            //当前课程缴费学生数量
-//            BigDecimal courseStudentNum = new BigDecimal(studentPaymentsWithCourse.size());
-
-            //教师预计课酬
-            BigDecimal expectSalary = courseScheduleTeacherSalary.getTeacherActualSalary();
-            //当前课程每个学生平均课酬
-//            BigDecimal avgSalary = expectSalary.divide(courseStudentNum, CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN);
-            //教师当前课程责任总占比,当前课程应得课酬
-//            BigDecimal teacherLiabilityAllratio;
-
-            //当前课程学生投诉记录
-            List<CourseScheduleComplaints> courseStudentComplaints = complaintsGroupByCourse.get(courseScheduleTeacherSalary.getCourseScheduleId());
-
-            //如果存在投诉记录,需要扣除相应费用
-            /*if (Objects.nonNull(courseStudentComplaints)) {
-                //获取审批中的投诉
-                List<CourseScheduleComplaints> auditIng = courseStudentComplaints.stream().filter(courseScheduleComplaint -> courseScheduleComplaint.getStatus() == AuditStatusEnum.ING).collect(Collectors.toList());
-                if (!CollectionUtils.isEmpty(auditIng)) {
-                    //如果当前课程存在未处理的投诉,则不做结算处理
-                    return;
-                }
-                //计算教师责任总占比
-                double teacherLiabilityRatioSum = courseStudentComplaints.stream().mapToDouble(courseScheduleComplaint -> Objects.isNull(courseScheduleComplaint.getTeacherLiabilityRatio()) ? 0 : courseScheduleComplaint.getTeacherLiabilityRatio()).sum();
-                teacherLiabilityAllratio = new BigDecimal(teacherLiabilityRatioSum).divide(percent,CommonConstants.DECIMAL_PLACE,BigDecimal.ROUND_DOWN);
-            } else {
-                //如果没有投诉,则教师和学生的责任占比为0
-                teacherLiabilityAllratio = new BigDecimal(0);
-            }*/
-
-            //教师应扣除费用
-            /*BigDecimal deductPrice = avgSalary.multiply(teacherLiabilityAllratio);
-            //教师实际课酬
-            BigDecimal schoolSubsidy = new BigDecimal(0);
-            if (Objects.nonNull(courseScheduleTeacherSalary.getSubsidy())) {
-                schoolSubsidy = courseScheduleTeacherSalary.getSubsidy();
-            }
-            BigDecimal actualSalary = expectSalary.subtract(deductPrice).add(schoolSubsidy);
-
-            //更新教师结算信息
-            courseScheduleTeacherSalary.setActualSalary(actualSalary);*/
             courseScheduleTeacherSalary.setActualSalary(expectSalary);
             courseScheduleTeacherSalary.setSettlementTime(now);
             courseScheduleTeacherSalaryDao.update(courseScheduleTeacherSalary);
             updateTeacherSalarys.add(courseScheduleTeacherSalary);
 
-            //生成教师账户资金变动记录
-//            sysUserCashAccountService.updateBalance(courseScheduleTeacherSalary.getUserId(), actualSalary);
-//            SysUserCashAccount teacherCashAccount = sysUserCashAccountService.get(courseScheduleTeacherSalary.getUserId().intValue());
-//            SysUserCashAccountDetail teacherCashAccountDetail = new SysUserCashAccountDetail();
-//            teacherCashAccountDetail.setUserId(courseScheduleTeacherSalary.getUserId());
-//            teacherCashAccountDetail.setType(PlatformCashAccountDetailTypeEnum.WAGE);
-//            teacherCashAccountDetail.setStatus(DealStatusEnum.SUCCESS);
-//            teacherCashAccountDetail.setAmount(actualSalary);
-//            if(Objects.isNull(teacherCashAccount)){
-//                teacherCashAccountDetail.setBalance(new BigDecimal(0));
-//            }else{
-//                teacherCashAccountDetail.setBalance(teacherCashAccount.getBalance());
-//            }
-//            teacherCashAccountDetail.setAttribute(courseScheduleTeacherSalary.getCourseScheduleId().toString());
-//
-//            userCashAccountDetails.add(teacherCashAccountDetail);
-
-            //根据学生进行投诉分组
-            Map<Integer, List<CourseScheduleComplaints>> complainsGroupByStudent = null;
-            if (Objects.nonNull(courseStudentComplaints)) {
-                complainsGroupByStudent = courseStudentComplaints.stream().collect(Collectors.groupingBy(CourseScheduleComplaints::getUserId));
-            }
-
-//            BigDecimal zero=new BigDecimal(0);
-
-            //计算学生当前课程应缴费用
-            for (CourseScheduleStudentPayment studentPayment : studentPaymentsWithCourse) {
-                //当前课程学生应缴费用
-                BigDecimal studentExpectPrice = studentPayment.getExpectPrice();
-                if (Objects.isNull(studentExpectPrice)) {
-                    studentExpectPrice = new BigDecimal(0);
-                }
-                //当前课程学生责任占比
-                BigDecimal studentLiabilityRatio;
-                List<CourseScheduleComplaints> currentCourseScheduleComplaints = null;
-                if (!CollectionUtils.isEmpty(complainsGroupByStudent)) {
-                    currentCourseScheduleComplaints = complainsGroupByStudent.get(studentPayment.getUserId());
-                }
-                if (!CollectionUtils.isEmpty(currentCourseScheduleComplaints)) {
-                    Double temp = currentCourseScheduleComplaints.get(0).getStudentLiabilityRatio();
-                    if (Objects.isNull(temp)) {
-                        temp = 0.0;
-                    }
-                    studentLiabilityRatio = new BigDecimal(temp).divide(percent,CommonConstants.DECIMAL_PLACE,BigDecimal.ROUND_DOWN);
-                } else {
-                    studentLiabilityRatio = new BigDecimal(1);
-                }
-
-
-                //当前课程学生实际缴费
-                BigDecimal actualPrice = studentExpectPrice.multiply(studentLiabilityRatio);
-                //当前课程学生应退费用
-                BigDecimal returnPrice = studentExpectPrice.subtract(actualPrice);
-                //更新学生结算信息
-                studentPayment.setActualPrice(actualPrice);
-                studentPayment.setSettlementTime(now);
-                courseScheduleStudentPaymentDao.update(studentPayment);
-                updateStudentPayments.add(studentPayment);
-
-
-//                if(returnPrice.compareTo(zero)!=0){
-//                    //生成学生账户资金变动记录
-//                    sysUserCashAccountService.updateBalance(studentPayment.getUserId(), returnPrice);
-//                    SysUserCashAccount studentCashAccount = sysUserCashAccountService.get(studentPayment.getUserId().intValue());
-//                    SysUserCashAccountDetail studentAccountDetail = new SysUserCashAccountDetail();
-//                    studentAccountDetail.setUserId(studentPayment.getUserId());
-//                    studentAccountDetail.setType(PlatformCashAccountDetailTypeEnum.REFUNDS);
-//                    studentAccountDetail.setStatus(DealStatusEnum.SUCCESS);
-//                    studentAccountDetail.setAmount(returnPrice);
-//                    studentAccountDetail.setBalance(studentCashAccount.getBalance());
-//                    studentAccountDetail.setAttribute(courseScheduleTeacherSalary.getCourseScheduleId().toString());
-//
-//                    userCashAccountDetails.add(studentAccountDetail);
-//                }
-            }
-
         });
-//        if(!CollectionUtils.isEmpty(userCashAccountDetails)){
-//            sysUserCashAccountDetailDao.batchInsert(userCashAccountDetails);
-//        }
     }
 
     @Override
@@ -555,7 +408,7 @@ public class CourseScheduleTeacherSalaryServiceImpl extends BaseServiceImpl<Long
         Map<Long, Long> courseNormalStudentsMap = new HashMap<>();
         if(!CollectionUtils.isEmpty(studentAttendances)){
             courseNormalStudentsMap =studentAttendances.stream()
-                    .filter(studentAttendance -> StudentAttendanceStatusEnum.NORMAL.equals(studentAttendance.getStatus()))
+//                    .filter(studentAttendance -> StudentAttendanceStatusEnum.NORMAL.equals(studentAttendance.getStatus()))
                     .collect(Collectors.groupingBy(StudentAttendance::getCourseScheduleId, Collectors.counting()));
         }
 
@@ -671,7 +524,7 @@ public class CourseScheduleTeacherSalaryServiceImpl extends BaseServiceImpl<Long
 
             }
 
-            BigDecimal finalSalary = teacherSalary.subtract(deductCost);
+            BigDecimal finalSalary = teacherSalary.subtract(deductCost).setScale(BigDecimal.ZERO.intValue(), BigDecimal.ROUND_HALF_UP);
 
             //更新教师结算信息
             courseScheduleTeacherSalary.setActualSalary(finalSalary.compareTo(BigDecimal.ZERO)<0?BigDecimal.ZERO:finalSalary);

+ 22 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/DataChangeLogServiceImpl.java

@@ -0,0 +1,22 @@
+package com.ym.mec.biz.service.impl;
+
+import com.ym.mec.common.dal.BaseDAO;
+import com.ym.mec.common.service.impl.BaseServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
+import com.ym.mec.biz.dal.entity.DataChangeLog;
+import com.ym.mec.biz.service.DataChangeLogService;
+import com.ym.mec.biz.dal.dao.DataChangeLogDao;
+import org.springframework.stereotype.Service;
+
+@Service
+public class DataChangeLogServiceImpl extends BaseServiceImpl<Long, DataChangeLog> implements DataChangeLogService {
+	
+	@Autowired
+	private DataChangeLogDao dataChangeLogDao;
+
+	@Override
+	public BaseDAO<Long, DataChangeLog> getDAO() {
+		return dataChangeLogDao;
+	}
+	
+}

+ 16 - 4
mec-biz/src/main/java/com/ym/mec/biz/service/impl/DegreeRegistrationServiceImpl.java

@@ -7,7 +7,8 @@ import com.alibaba.fastjson.JSON;
 import com.ym.mec.biz.dal.dao.*;
 import com.ym.mec.biz.dal.dto.DegreeRegistrationActivityDto;
 import com.ym.mec.biz.dal.entity.*;
-import com.ym.mec.biz.dal.enums.OrderDetailTypeEnum;
+import com.ym.mec.biz.dal.enums.*;
+import com.ym.mec.biz.service.SysUserCashAccountService;
 import com.ym.mec.common.constant.CommonConstants;
 import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.entity.HttpResponseResult;
@@ -19,9 +20,6 @@ import org.springframework.transaction.annotation.Isolation;
 import org.springframework.transaction.annotation.Transactional;
 
 import com.ym.mec.biz.dal.dto.PageInfoDegree;
-import com.ym.mec.biz.dal.enums.DealStatusEnum;
-import com.ym.mec.biz.dal.enums.GroupType;
-import com.ym.mec.biz.dal.enums.OrderTypeEnum;
 import com.ym.mec.biz.dal.page.DegreeQueryInfo;
 import com.ym.mec.biz.service.DegreeRegistrationService;
 import com.ym.mec.biz.service.PayService;
@@ -66,6 +64,9 @@ public class DegreeRegistrationServiceImpl extends BaseServiceImpl<Integer, Degr
     @Autowired
     private StudentPaymentOrderDetailDao studentPaymentOrderDetailDao;
 
+    @Autowired
+    private SysUserCashAccountService sysUserCashAccountService;
+
     @Override
     public BaseDAO<Integer, DegreeRegistration> getDAO() {
         return degreeRegistrationDao;
@@ -345,6 +346,17 @@ public class DegreeRegistrationServiceImpl extends BaseServiceImpl<Integer, Degr
             throw new BizException("订单更新失败");
         }
 
+        if(DealStatusEnum.SUCCESS.equals(studentPaymentOrder.getStatus())){
+            List<StudentPaymentOrderDetail> orderDetails = studentPaymentOrderDetailDao.getOrderDetail(studentPaymentOrder.getId());
+            BigDecimal additionCoursePrice = new BigDecimal(0);
+            if(!CollectionUtils.isEmpty(orderDetails)){
+                additionCoursePrice = orderDetails.stream().map(StudentPaymentOrderDetail::getPrice).reduce(BigDecimal.ZERO, BigDecimal::add);
+            }
+            if(additionCoursePrice.compareTo(BigDecimal.ZERO)>0){
+                sysUserCashAccountService.appendCourseBalance(studentPaymentOrder.getUserId(), additionCoursePrice, PlatformCashAccountDetailTypeEnum.RECHARGE, "2020考级报名");
+            }
+        }
+
         if(Objects.isNull(studentPaymentOrder.getClassGroupId())){
             return true;
         }

+ 83 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/LogServiceImpl.java

@@ -0,0 +1,83 @@
+package com.ym.mec.biz.service.impl;
+
+import com.ym.mec.biz.dal.dao.DataChangeLogDao;
+import com.ym.mec.biz.dal.dto.VipGroupActivityAddDto;
+import com.ym.mec.biz.dal.entity.DataChangeLog;
+import com.ym.mec.biz.dal.enums.VipGroupActivityTypeEnum;
+import com.ym.mec.biz.service.DataChangeLogService;
+import com.ym.mec.biz.service.LogService;
+import com.ym.mec.util.date.DateUtil;
+import io.swagger.annotations.ApiModelProperty;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
+
+import java.lang.reflect.Field;
+import java.util.*;
+
+/**
+ * @Author qnc99
+ * @Date 2020/12/15 0015
+ */
+@Service
+public class LogServiceImpl implements LogService {
+
+    @Autowired
+    private DataChangeLogDao dataChangeLogDao;
+
+    private Field[] getAllFields(Object object){
+        Class clazz = object.getClass();
+        List<Field> fieldList = new ArrayList<>();
+        while (clazz != null){
+            fieldList.addAll(new ArrayList<>(Arrays.asList(clazz.getDeclaredFields())));
+            clazz = clazz.getSuperclass();
+        }
+        Field[] fields = new Field[fieldList.size()];
+        fieldList.toArray(fields);
+        return fields;
+    }
+
+    @Override
+    public void entityVariationAnalysis(Object oldEntity, Object newEntity, Integer operatorId) {
+        List<String> changes = new ArrayList<>();
+        Field[] allFields = getAllFields(oldEntity);
+        for (Field field : allFields) {
+            if(field.getName().equals("createTime")||field.getName().equals("updateTime")){
+                continue;
+            }
+            ApiModelProperty annotation = field.getAnnotation(ApiModelProperty.class);
+            if(Objects.isNull(annotation)){
+                continue;
+            }
+            field.setAccessible(true);
+            try {
+                String oldValue = "", newValue = "";
+                if(field.getType().equals(Date.class)){
+                    if(Objects.nonNull(field.get(oldEntity))){
+                        oldValue = DateUtil.dateToString((Date) field.get(oldEntity), DateUtil.EXPANDED_DATE_TIME_FORMAT);
+                    }
+                    if(Objects.nonNull(field.get(newEntity))){
+                        newValue = DateUtil.dateToString((Date) field.get(newEntity), DateUtil.EXPANDED_DATE_TIME_FORMAT);
+                    }
+                }else{
+                    oldValue = String.valueOf(field.get(oldEntity));
+                    newValue = String.valueOf(field.get(newEntity));
+                }
+                if(!oldValue.equals(newValue)){
+                    changes.add(annotation.value() + ":" + oldValue + " -> " + newValue);
+                }
+            } catch (IllegalAccessException e) {
+                e.printStackTrace();
+            }
+        }
+        if(CollectionUtils.isEmpty(changes)){
+            return;
+        }
+        DataChangeLog dataChangeLog = new DataChangeLog();
+        dataChangeLog.setClassName(oldEntity.getClass().getName());
+        dataChangeLog.setChangeInfo(StringUtils.join(changes, ";"));
+        dataChangeLog.setOperatorId(operatorId);
+        dataChangeLogDao.insert(dataChangeLog);
+    }
+}

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

@@ -1431,7 +1431,8 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
     public BigDecimal updateUserSurplusCourseFee(Integer userId, String musicGroupId, BigDecimal amount, String memo, Integer operatorId) {
         StudentRegistration studentRegistration = studentRegistrationDao.lockWithUserAndMusic(userId, musicGroupId);
         if (Objects.isNull(studentRegistration)) {
-            throw new BizException("学员注册信息不存在");
+            LOGGER.error("学员可用排课余额更新失败{}:学员注册信息不存在", amount);
+            return BigDecimal.ZERO;
         }
 
         if (BigDecimal.ZERO.compareTo(amount) > 0 && amount.abs().compareTo(studentRegistration.getSurplusCourseFee()) > 0) {

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

@@ -7,6 +7,7 @@ import com.ym.mec.biz.dal.dto.VipGroupActivityAddDto;
 import com.ym.mec.biz.dal.dto.VipGroupSalarySettlementDto;
 import com.ym.mec.biz.dal.entity.Teacher;
 import com.ym.mec.biz.dal.entity.VipGroupActivity;
+import com.ym.mec.biz.event.source.EntityChangeEventSource;
 import com.ym.mec.biz.service.VipGroupActivityService;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.exception.BizException;
@@ -15,6 +16,7 @@ import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Objects;
 
@@ -25,6 +27,8 @@ public class VipGroupActivityServiceImpl extends BaseServiceImpl<Integer, VipGro
 	private VipGroupActivityDao vipGroupActivityDao;
 	@Autowired
 	private TeacherDao teacherDao;
+	@Autowired
+	private EntityChangeEventSource entityChangeEventSource;
 
 	@Override
 	public BaseDAO<Integer, VipGroupActivity> getDAO() {
@@ -77,21 +81,23 @@ public class VipGroupActivityServiceImpl extends BaseServiceImpl<Integer, VipGro
 			}
 		}
 
-
 		vipGroupActivityAddDto.setSalarySettlementJson(JSON.toJSONString(vipGroupActivityAddDto.getVipGroupSalarySettlement()));
 		super.insert(vipGroupActivityAddDto);
 	}
 
 	@Override
-	public void updateVipGroupActivity(VipGroupActivityAddDto vipGroupActivityAddDto) {
-		if(Objects.isNull(vipGroupActivityAddDto.getId())){
-			throw new BizException("请指定活动编号!");
+	public void updateVipGroupActivity(VipGroupActivityAddDto vipGroupActivityAddDto, Integer operatorId) {
+		VipGroupActivity oldVipGroupActivity = vipGroupActivityDao.get(vipGroupActivityAddDto.getId());
+		if(Objects.isNull(oldVipGroupActivity)){
+			throw new BizException("活动不存在!");
 		}
 		if(Objects.isNull(vipGroupActivityAddDto.getOrganId())){
 			throw new BizException("请指定部门!");
 		}
 		vipGroupActivityAddDto.setSalarySettlementJson(JSON.toJSONString(vipGroupActivityAddDto.getVipGroupSalarySettlement()));
+
 		super.update(vipGroupActivityAddDto);
+		entityChangeEventSource.entityChange(oldVipGroupActivity, vipGroupActivityAddDto, operatorId);
 	}
 
 	@Override

+ 0 - 42
mec-biz/src/main/java/com/ym/mec/biz/service/impl/VipGroupServiceImpl.java

@@ -3105,46 +3105,4 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
         }
 		return teacherByOrganAndSubject;
 	}
-
-	@Override
-	@Async
-	public void updateHistoryTeacherSalaryOfOnline(String startDate, String endDate) {
-		// 查询所有含有线上课的课程组,线上课节数,实付金额
-		List<VipCourseStudentInfoDto> list = vipGroupDao.queryVipCourseStudentInfo();
-		Map<String, VipCourseStudentInfoDto> map = list.stream().collect(Collectors.toMap(VipCourseStudentInfoDto::getMusicGroupId, e -> e));
-
-		VipCourseStudentInfoDto dto = null;
-		// 查询需要修改的课酬记录
-		List<TeacherVipSalaryDto> teacherSalaryList = courseScheduleTeacherSalaryDao.queryOnlineCourseByGroupType(startDate, endDate);
-		for (TeacherVipSalaryDto ts : teacherSalaryList) {
-			// 修复兼职老师不管1v?和全职老师1vn的课酬为系统默认课酬(不管线上还是线下课)
-			if (ts.getTeacherJobNature() != JobNatureEnum.FULL_TIME || !StringUtils.equalsIgnoreCase("1v1", ts.getVipGroupCategoryName())) {
-				// 查询默认课酬
-				TeacherDefaultVipGroupSalary tdvs = teacherDefaultVipGroupSalaryDao.findByTeacherAndCategory(ts.getUserId(), ts.getVipGroupCategoryId());
-				if (tdvs != null) {
-					if (ts.getTeachMode() == TeachModeEnum.ONLINE) {
-						ts.setExpectSalary(tdvs.getOfflineClassesSalary());
-					} else {
-						ts.setExpectSalary(tdvs.getOfflineClassesSalary());
-					}
-				}
-			} else {
-				if (ts.getTeachMode() == TeachModeEnum.ONLINE && ts.getTeacherJobNature() == JobNatureEnum.FULL_TIME) {
-					dto = map.get(ts.getMusicGroupId());
-					if (dto != null) {
-						ts.setExpectSalary(dto
-								.getTotalAmount()
-								.divide(new BigDecimal(dto.getTotalCourseTimes()).divide(new BigDecimal(dto.getStudentNum()), RoundingMode.HALF_UP),
-										RoundingMode.HALF_UP).multiply(new BigDecimal(0.6)));
-					}
-				}
-			}
-			courseScheduleTeacherSalaryDao.update(ts);
-		}
-
-		if (teacherSalaryList.size() > 0) {
-			// courseScheduleTeacherSalaryDao.batchUpdateTeacherExpectSalarys(teacherSalaryList);
-		}
-
-	}
 }

+ 2 - 2
mec-biz/src/main/resources/config/mybatis/CourseScheduleTeacherSalaryMapper.xml

@@ -267,9 +267,9 @@
     <select id="findSomeDayAgoTeacherCourseSalaryNoSettlement" resultMap="CourseScheduleTeacherSalary">
 		SELECT
 		cs.class_date_,
-		csts.*,CASE WHEN cs.teach_mode_ = 'ONLINE' THEN csts.expect_salary_ * (CASE WHEN (ta.sign_in_status_ IS NULL OR ta.sign_in_status_ = 0) AND (ta.sign_out_status_ IS NULL OR ta.sign_out_status_ = 0) THEN 0
+		csts.*,csts.expect_salary_ * (CASE WHEN (ta.sign_in_status_ IS NULL OR ta.sign_in_status_ = 0) AND (ta.sign_out_status_ IS NULL OR ta.sign_out_status_ = 0) THEN 0
 		WHEN ta.sign_in_status_ IS NULL OR ta.sign_in_status_ = 0 THEN 0.5
-		WHEN ta.sign_out_status_ IS NULL OR ta.sign_out_status_ = 0 THEN 0.5 ELSE 1 END) ELSE csts.expect_salary_ END teacher_actual_salary_
+		WHEN ta.sign_out_status_ IS NULL OR ta.sign_out_status_ = 0 THEN 0.5 ELSE 1 END) teacher_actual_salary_
 		FROM
 		course_schedule_teacher_salary csts
 		LEFT JOIN course_schedule cs ON cs.id_ = csts.course_schedule_id_

+ 66 - 0
mec-biz/src/main/resources/config/mybatis/DataChangeLogMapper.xml

@@ -0,0 +1,66 @@
+<?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.DataChangeLogDao">
+	
+	<resultMap type="com.ym.mec.biz.dal.entity.DataChangeLog" id="DataChangeLog">
+		<result column="id_" property="id" />
+		<result column="operator_id_" property="operatorId" />
+		<result column="change_info_" property="changeInfo" />
+		<result column="create_time_" property="createTime" />
+		<result column="class_name_" property="className" />
+	</resultMap>
+	
+	<!-- 根据主键查询一条记录 -->
+	<select id="get" resultMap="DataChangeLog" >
+		SELECT * FROM data_change_log WHERE id_ = #{id} 
+	</select>
+	
+	<!-- 全查询 -->
+	<select id="findAll" resultMap="DataChangeLog">
+		SELECT * FROM data_change_log ORDER BY id_
+	</select>
+	
+	<!-- 向数据库增加一条记录 -->
+	<insert id="insert" parameterType="com.ym.mec.biz.dal.entity.DataChangeLog" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
+		INSERT INTO data_change_log (id_,operator_id_,change_info_,create_time_,class_name_)
+		VALUES(#{id},#{operatorId},#{changeInfo},NOW(),#{className})
+	</insert>
+	
+	<!-- 根据主键查询一条记录 -->
+	<update id="update" parameterType="com.ym.mec.biz.dal.entity.DataChangeLog">
+		UPDATE data_change_log
+		<set>
+			<if test="operatorId != null">
+				operator_id_ = #{operatorId},
+			</if>
+			<if test="id != null">
+				id_ = #{id},
+			</if>
+			<if test="className != null">
+				class_name_ = #{className},
+			</if>
+			<if test="changeInfo != null">
+				change_info_ = #{changeInfo},
+			</if>
+		</set> WHERE id_ = #{id}
+	</update>
+	
+	<!-- 根据主键删除一条记录 -->
+	<delete id="delete" >
+		DELETE FROM data_change_log WHERE id_ = #{id} 
+	</delete>
+	
+	<!-- 分页查询 -->
+	<select id="queryPage" resultMap="DataChangeLog" parameterType="map">
+		SELECT * FROM data_change_log ORDER BY id_ <include refid="global.limit"/>
+	</select>
+	
+	<!-- 查询当前表的总记录数 -->
+	<select id="queryCount" resultType="int">
+		SELECT COUNT(*) FROM data_change_log
+	</select>
+</mapper>

+ 5 - 1
mec-teacher/src/main/java/com/ym/mec/teacher/controller/VipGroupActivityController.java

@@ -51,7 +51,11 @@ public class VipGroupActivityController extends BaseController {
     @ApiOperation(value = "修改活动方案")
     @PostMapping("/update")
     public Object update(@RequestBody VipGroupActivityAddDto vipGroupActivityAddDto){
-        vipGroupActivityService.updateVipGroupActivity(vipGroupActivityAddDto);
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if(sysUser == null){
+            return failed("用户信息获取失败");
+        }
+        vipGroupActivityService.updateVipGroupActivity(vipGroupActivityAddDto, sysUser.getId());
         return succeed();
     }
 

+ 0 - 6
mec-web/src/main/java/com/ym/mec/web/controller/CourseScheduleTeacherSalaryController.java

@@ -46,12 +46,6 @@ public class CourseScheduleTeacherSalaryController extends BaseController {
     public Object queryPage(CourseScheduleTeacherSalaryQueryInfo queryInfo) {
         return succeed(courseScheduleTeacherSalaryService.querySalaries(queryInfo));
     }
-    
-    @GetMapping("/updateHistoryTeacherSalaryOfOnline")
-    public Object updateHistoryTeacherSalaryOfOnline(String startDate, String endDate) {
-    	vipGroupService.updateHistoryTeacherSalaryOfOnline(startDate, endDate);
-        return succeed();
-    }
 
     @ApiOperation(value = "获取已结算的课酬记录")
     @GetMapping("/findIsSettlementCourseSalarys")

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

@@ -75,7 +75,11 @@ public class VipGroupActivityController extends BaseController {
     @PostMapping("/update")
     @PreAuthorize("@pcs.hasPermissions('vipGroupActivity/update')")
     public Object update(@RequestBody VipGroupActivityAddDto vipGroupActivityAddDto){
-        vipGroupActivityService.updateVipGroupActivity(vipGroupActivityAddDto);
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if(sysUser == null){
+            return failed("用户信息获取失败");
+        }
+        vipGroupActivityService.updateVipGroupActivity(vipGroupActivityAddDto, sysUser.getId());
         return succeed();
     }