瀏覽代碼

Merge remote-tracking branch 'origin/master'

周箭河 5 年之前
父節點
當前提交
4c993f1903

+ 11 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/SysConfigService.java

@@ -72,9 +72,20 @@ public interface SysConfigService extends BaseService<Long, SysConfig> {
     String TEACHER_ENTRY_DATE = "teacher_entry_date";
 
     /**
+     * 可签退时间限制(自然天)
+     */
+    String ENABLE_SIGN_OUT_TIME_RANGE = "enable_sign_out_time_range";
+
+    /**
+     * 可更新学生签到状态时间限制,课程结束后{}分钟
+     */
+    String ENABLE_STUDENT_ATTENDANCE_TIME_RANGE = "enable_student_attendance_time_range";
+
+    /**
      * @return com.ym.mec.biz.dal.entity.SysConfig
      * @params paramName
      * @describe 根据配置名称获取配置信息
      */
     SysConfig findByParamName(String paramName);
+
 }

+ 10 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/SysUserCashAccountService.java

@@ -1,11 +1,11 @@
 package com.ym.mec.biz.service;
 
-import java.math.BigDecimal;
-
 import com.ym.mec.biz.dal.entity.SysUserCashAccount;
 import com.ym.mec.biz.dal.enums.PlatformCashAccountDetailTypeEnum;
 import com.ym.mec.common.service.BaseService;
 
+import java.math.BigDecimal;
+
 public interface SysUserCashAccountService extends BaseService<Integer, SysUserCashAccount> {
 
 	/**
@@ -35,6 +35,14 @@ public interface SysUserCashAccountService extends BaseService<Integer, SysUserC
 	boolean updateCourseBalance(Integer userId, BigDecimal decimal);
 
 	/**
+	 * 更新指定用户的账户课程余额
+	 * @param userId 用户编号
+	 * @param decimal 交易金额(支持负数)
+	 * @return
+	 */
+	boolean appendCourseBalance(Integer userId, BigDecimal decimal);
+
+	/**
 	 * 将课程余额转入到可用余额
 	 * @param userId
 	 * @return

+ 21 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SysUserCashAccountServiceImpl.java

@@ -132,6 +132,27 @@ public class SysUserCashAccountServiceImpl extends BaseServiceImpl<Integer, SysU
 	}
 
 	@Override
+	public boolean appendCourseBalance(Integer userId, BigDecimal decimal) {
+		SysUserCashAccount cashAccount = sysUserCashAccountDao.getLocked(userId);
+		if (cashAccount == null) {
+			throw new BizException("用户[{}]现金账户不存在", userId);
+		}
+
+		BigDecimal balance = cashAccount.getCourseBalance().add(decimal);
+		if (balance.doubleValue() < 0) {
+			throw new BizException("现金账户[{}]课程余额不足,可用余额剩{}元", userId, cashAccount.getBalance().doubleValue());
+		}
+
+		Date date = new Date();
+		cashAccount.setCourseBalance(balance);
+		cashAccount.setUpdateTime(date);
+
+		sysUserCashAccountDao.update(cashAccount);
+
+		return true;
+	}
+
+	@Override
 	@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
 	public boolean transferCourseBalanceToBalance(Integer userId) {
 		SysUserCashAccount cashAccount = sysUserCashAccountDao.getLocked(userId);

+ 4 - 3
mec-biz/src/main/java/com/ym/mec/biz/service/impl/VipGroupServiceImpl.java

@@ -1392,7 +1392,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 
         courseScheduleTeacherSalaryService.updateVipGroupCourseTeacherSalary(vipGroupId.intValue(),-1,vipGroup.getStatus());
 
-        sysUserCashAccountService.updateCourseBalance(studentId, surplusCourseFee);
+        sysUserCashAccountService.appendCourseBalance(studentId, surplusCourseFee);
 		classStudentMapperByUserIdAndClassGroupId.setStatus(ClassGroupStudentStatusEnum.QUIT_SCHOOL);
 		classGroupStudentMapperDao.update(classStudentMapperByUserIdAndClassGroupId);
 
@@ -1459,6 +1459,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
         Integer[] teachModeSequence=JSON.parseArray(courseInfo.get("teaChModeSequence").toString(), Integer.class).stream().toArray(Integer[]::new);
 		List<BigDecimal> coursePrices = (List<BigDecimal>) courseInfo.get("coursePriceInfo");
 		coursePrices.sort(Comparator.naturalOrder());
+		Collections.reverse(coursePrices);
 
 		if(vipGroup.getStatus().equals(VipGroupStatusEnum.PAUSE)){
 			studentRecoverInfo.setCourseCount(teachModeSequence.length);
@@ -1492,7 +1493,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 		List<CourseSchedule> surplusCourseWithGroup = courseScheduleDao.findSurplusCourseWithGroup(GroupType.VIP, studentRecoverInfo.getVipGroupId().toString());
 		surplusCourseWithGroup.sort(Comparator.comparing(CourseSchedule::getStartClassTime));
 
-		if(coursePrices.size()<surplusCourseFee.signum()){
+		if(coursePrices.size()<surplusCourseWithGroup.size()){
 			throw new BizException("剩余课时不足,无法与现有课时对齐");
 		}
 
@@ -1514,7 +1515,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 		if(!CollectionUtils.isEmpty(courseScheduleStudentPaymentList)){
 			courseScheduleStudentPaymentDao.batchInsert(courseScheduleStudentPaymentList);
 		}
-		sysUserCashAccountService.updateCourseBalance(studentRecoverInfo.getUserId(), surplusCourseFee);
+		sysUserCashAccountService.appendCourseBalance(studentRecoverInfo.getUserId(), surplusCourseFee.negate());
 		classStudentMapperByUserIdAndClassGroupId.setStatus(ClassGroupStudentStatusEnum.NORMAL);
 		classGroupStudentMapperDao.update(classStudentMapperByUserIdAndClassGroupId);
 		studentPauseInfo.setDelFlag(1);

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

@@ -82,6 +82,7 @@
             <if test="currentClassTimes != null">
                 current_class_times_ = #{currentClassTimes},
             </if>
+            update_time_=NOW()
         </set>
         WHERE id_ = #{id}
     </update>
@@ -117,6 +118,7 @@
 	            <if test="item.currentClassTimes != null">
 	                current_class_times_ = #{item.currentClassTimes},
 	            </if>
+                update_time_=NOW()
         	</set>
 	        where id_ = #{item.id}
 	    </foreach>