|
@@ -48,22 +48,33 @@ public class TenantAssetsInfoServiceImpl extends ServiceImpl<TenantAssetsInfoDao
|
|
|
private TenantCloudCourseRecordService tenantCloudCourseRecordService;
|
|
|
|
|
|
/**
|
|
|
- * 恢复/取消 冻结的金额
|
|
|
+ * 扣除冻结的金额
|
|
|
*
|
|
|
* @param courseId 课程id
|
|
|
*/
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public void courseRecoverAmountRules(Integer courseId) {
|
|
|
- TenantCloudCourseRecord lastRecord = tenantCloudCourseRecordService.queryLastRecord(courseId);
|
|
|
- if (Objects.nonNull(lastRecord) && lastRecord.getDeductState() != 0) {
|
|
|
- //只有冻结的
|
|
|
- throw new BizException("该课程非线上课!");
|
|
|
+ public void courseDeductAmount(Integer courseId){
|
|
|
+ TenantCloudCourseRecord lastRecord = checkLastRecord(courseId);
|
|
|
+ //写入流水
|
|
|
+ lastRecord.setDeductState(1);
|
|
|
+ tenantCloudCourseRecordService.save(lastRecord);
|
|
|
+ if (baseMapper.deductAmount(lastRecord.getAmount()) != 1) {
|
|
|
+ throw new BizException("解除冻结金额失败!");
|
|
|
}
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 恢复/取消 冻结的金额
|
|
|
+ *
|
|
|
+ * @param courseId 课程id
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void courseRecoverAmount(Integer courseId) {
|
|
|
+ TenantCloudCourseRecord lastRecord = checkLastRecord(courseId);
|
|
|
//写入流水
|
|
|
lastRecord.setDeductState(2);
|
|
|
- lastRecord.setCreatedBy(getUserId());
|
|
|
- lastRecord.setCreatedTime(new Date());
|
|
|
tenantCloudCourseRecordService.save(lastRecord);
|
|
|
//解除冻结金额,恢复余额
|
|
|
if (baseMapper.recoverAmount(lastRecord.getAmount()) != 1) {
|
|
@@ -71,6 +82,18 @@ public class TenantAssetsInfoServiceImpl extends ServiceImpl<TenantAssetsInfoDao
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private TenantCloudCourseRecord checkLastRecord(Integer courseId) {
|
|
|
+ TenantCloudCourseRecord lastRecord = tenantCloudCourseRecordService.queryLastRecord(courseId);
|
|
|
+ //判断是否是冻结的状态
|
|
|
+ if (Objects.nonNull(lastRecord) && lastRecord.getDeductState() != 0) {
|
|
|
+ //只有冻结的才能取消冻结 或者 扣费
|
|
|
+ throw new BizException("该课程非线上课!");
|
|
|
+ }
|
|
|
+ lastRecord.setCreatedBy(getUserId());
|
|
|
+ lastRecord.setCreatedTime(new Date());
|
|
|
+ return lastRecord;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 排课扣费计算
|
|
|
* 1.线上排课计算出的总价格不能超过账户余额(注意多人同时操作账户余额多扣问题)
|
|
@@ -78,7 +101,7 @@ public class TenantAssetsInfoServiceImpl extends ServiceImpl<TenantAssetsInfoDao
|
|
|
*/
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public void courseDeductAmountRules(List<CourseSchedule> dto) {
|
|
|
+ public void courseFrozenAmount(List<CourseSchedule> dto) {
|
|
|
Integer tenantId = TenantContextHolder.getTenantId();
|
|
|
|
|
|
//校验课程 筛选出线上课
|