Browse Source

修改云教室扣费标准相关功能

hgw 3 years ago
parent
commit
8888697826

+ 3 - 4
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/TenantAssetsInfoDao.java

@@ -2,6 +2,7 @@ package com.ym.mec.biz.dal.dao;
 
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.ym.mec.biz.dal.entity.TenantAssetsInfo;
 import com.ym.mec.biz.dal.entity.TenantAssetsInfo;
+import io.swagger.models.auth.In;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Param;
 
 
 import java.math.BigDecimal;
 import java.math.BigDecimal;
@@ -17,10 +18,8 @@ public interface TenantAssetsInfoDao extends BaseMapper<TenantAssetsInfo> {
 
 
     int insertBatch(@Param("entities") List<TenantAssetsInfo> entities);
     int insertBatch(@Param("entities") List<TenantAssetsInfo> entities);
 
 
-    int frozenAmount(BigDecimal frozenAmount);
+    int deductAmount(BigDecimal deductAmount, Integer tenantId);
 
 
-    int recoverAmount(BigDecimal recoverAmount);
-
-    int deductAmount(BigDecimal deductAmount);
+    int checkDeductAmount(BigDecimal deductAmount, Integer tenantId);
 }
 }
 
 

+ 4 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/TenantCloudCourseRecordDao.java

@@ -4,8 +4,10 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.ym.mec.biz.dal.entity.TenantCloudCourseRecord;
 import com.ym.mec.biz.dal.entity.TenantCloudCourseRecord;
+import com.ym.mec.biz.dal.vo.TenantCloudCourseRecordVo;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Param;
 
 
+import java.util.List;
 import java.util.Map;
 import java.util.Map;
 
 
 /**
 /**
@@ -18,6 +20,7 @@ public interface TenantCloudCourseRecordDao extends BaseMapper<TenantCloudCourse
 
 
     <T> IPage<T> queryPage(Page<T> page, @Param("param") Map<String, Object> param);
     <T> IPage<T> queryPage(Page<T> page, @Param("param") Map<String, Object> param);
 
 
-    TenantCloudCourseRecord queryLastRecord(Integer courseId);
+    List<TenantCloudCourseRecordVo> queryPage(@Param("param") Map<String, Object> param);
+
 }
 }
 
 

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

@@ -33,7 +33,7 @@ public class TenantCloudCourseRecord implements Serializable {
     private Integer courseId;
     private Integer courseId;
 
 
     @TableField("deduct_state_")
     @TableField("deduct_state_")
-    @ApiModelProperty(value = "扣费状态 0冻结 1扣费 2取消冻结")
+    @ApiModelProperty(value = "扣费状态 0冻结 1扣费 2取消冻结 3未扣费")
     private Integer deductState;
     private Integer deductState;
 
 
     @TableField("amount_")
     @TableField("amount_")

+ 11 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/vo/TenantCloudCourseRecordVo.java

@@ -28,6 +28,9 @@ public class TenantCloudCourseRecordVo implements Serializable {
     @ApiModelProperty(value = "分部名称")
     @ApiModelProperty(value = "分部名称")
     private Integer organName;
     private Integer organName;
 
 
+    @ApiModelProperty(value = "机构Id")
+    private Integer tenantId;
+
     @ApiModelProperty(value = "机构名称")
     @ApiModelProperty(value = "机构名称")
     private Integer tenantName;
     private Integer tenantName;
 
 
@@ -87,6 +90,14 @@ public class TenantCloudCourseRecordVo implements Serializable {
         this.organName = organName;
         this.organName = organName;
     }
     }
 
 
+    public Integer getTenantId() {
+        return tenantId;
+    }
+
+    public void setTenantId(Integer tenantId) {
+        this.tenantId = tenantId;
+    }
+
     public Integer getTenantName() {
     public Integer getTenantName() {
         return tenantName;
         return tenantName;
     }
     }

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

@@ -15,12 +15,9 @@ import java.util.List;
  */
  */
 public interface TenantAssetsInfoService extends IService<TenantAssetsInfo> {
 public interface TenantAssetsInfoService extends IService<TenantAssetsInfo> {
 
 
-    void courseFrozenAmount(List<CourseSchedule> dto);
+    void manualDeductAmount(List<Integer> ids);
 
 
-    void courseRecoverAmount(Integer courseId);
+    void deductAmount(List<CourseSchedule> dto);
 
 
-    void courseDeductAmount(Integer courseId);
-
-    void groupFrozenAmount(VipGroup vipGroup, List<CourseSchedule> dto);
 }
 }
 
 

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

@@ -5,6 +5,7 @@ import com.ym.mec.biz.dal.entity.TenantCloudCourseRecord;
 import com.ym.mec.biz.dal.vo.TenantCloudCourseRecordVo;
 import com.ym.mec.biz.dal.vo.TenantCloudCourseRecordVo;
 import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.page.PageInfo;
 
 
+import java.util.List;
 import java.util.Map;
 import java.util.Map;
 
 
 /**
 /**
@@ -17,7 +18,7 @@ public interface TenantCloudCourseRecordService extends IService<TenantCloudCour
 
 
     PageInfo<TenantCloudCourseRecordVo> queryPage(Map<String,Object> param);
     PageInfo<TenantCloudCourseRecordVo> queryPage(Map<String,Object> param);
 
 
-    TenantCloudCourseRecord queryLastRecord(Integer courseId);
+    List<TenantCloudCourseRecordVo> queryList(Map<String, Object> param);
 
 
 }
 }
 
 

+ 100 - 138
mec-biz/src/main/java/com/ym/mec/biz/service/impl/TenantAssetsInfoServiceImpl.java

@@ -2,25 +2,22 @@ package com.ym.mec.biz.service.impl;
 
 
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.ym.mec.auth.api.client.SysUserFeignService;
-import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.dao.TenantAssetsInfoDao;
 import com.ym.mec.biz.dal.dao.TenantAssetsInfoDao;
 import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.dal.entity.TenantConfigDetail.CloudRoomRule;
 import com.ym.mec.biz.dal.entity.TenantConfigDetail.CloudRoomRule;
 import com.ym.mec.biz.dal.enums.TeachModeEnum;
 import com.ym.mec.biz.dal.enums.TeachModeEnum;
+import com.ym.mec.biz.dal.vo.TenantCloudCourseRecordVo;
 import com.ym.mec.biz.service.TenantAssetsInfoService;
 import com.ym.mec.biz.service.TenantAssetsInfoService;
 import com.ym.mec.biz.service.TenantCloudCourseRecordService;
 import com.ym.mec.biz.service.TenantCloudCourseRecordService;
 import com.ym.mec.biz.service.TenantConfigService;
 import com.ym.mec.biz.service.TenantConfigService;
 import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.page.WrapperUtil;
 import com.ym.mec.common.page.WrapperUtil;
-import com.ym.mec.common.tenant.TenantContextHolder;
 import com.ym.mec.thirdparty.yqpay.DateUtils;
 import com.ym.mec.thirdparty.yqpay.DateUtils;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.collections.CollectionUtils;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
 
 
 import java.math.BigDecimal;
 import java.math.BigDecimal;
 import java.math.MathContext;
 import java.math.MathContext;
@@ -43,151 +40,122 @@ public class TenantAssetsInfoServiceImpl extends ServiceImpl<TenantAssetsInfoDao
     @Autowired
     @Autowired
     private TenantConfigService tenantConfigService;
     private TenantConfigService tenantConfigService;
     @Autowired
     @Autowired
-    private SysUserFeignService sysUserFeignService;
-    @Autowired
     private TenantCloudCourseRecordService tenantCloudCourseRecordService;
     private TenantCloudCourseRecordService tenantCloudCourseRecordService;
 
 
     /**
     /**
-     * 课程
-     * 扣除冻结的金额
+     * 手动执行未扣费的流水
      *
      *
-     * @param courseId 课程id
+     * @param ids 流水表id集合
      */
      */
-    @Override
-    @Transactional(rollbackFor = Exception.class)
-    public void courseDeductAmount(Integer courseId) {
-        TenantCloudCourseRecord lastRecord = checkLastRecord(courseId);
-        if (Objects.isNull(lastRecord)) {
+    public void manualDeductAmount(List<Integer> ids) {
+        if (CollectionUtils.isEmpty(ids)) {
             return;
             return;
         }
         }
-        //写入流水
-        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);
-        if (Objects.isNull(lastRecord)) {
+        List<TenantCloudCourseRecordVo> records = tenantCloudCourseRecordService.queryList(new HashMap<String, Object>() {{
+            put("ids", ids);
+            put("deductState", 3);
+        }});
+        if (CollectionUtils.isEmpty(records)) {
             return;
             return;
         }
         }
-        //写入流水
-        lastRecord.setDeductState(2);
-        tenantCloudCourseRecordService.save(lastRecord);
-        //解除冻结金额,恢复余额
-        if (baseMapper.recoverAmount(lastRecord.getAmount()) != 1) {
-            throw new BizException("解除冻结金额失败!");
-        }
-    }
+        records.forEach(record -> {
+            //获取总人数 ,+1是算上老师
+            Integer totalPeople = record.getStudentNum() + 1;
+            //获取云教室规则  String人数-BigDecimal每分钟扣费标准
+            Map<String, BigDecimal> rule = getRule(record.getTenantId());
+            if (Objects.isNull(rule)) {
+                throw new BizException("未查询到该机构的课程收费标准!");
+            }
+            //获取每分钟扣费标准
+            BigDecimal minutePrice = rule.get(String.valueOf(totalPeople));
+            if (Objects.isNull(minutePrice)) {
+                throw new BizException("未查到 [" + totalPeople + "人(含老师)] 的课程收费标准!");
+            }
+            //计算总上课时间
+            BigDecimal courseDate = getCourseDate(record.getClassDate(), record.getStartClassTime(), record.getEndClassTime());
+            //课程总价 = 每分钟扣费标准 * 总上课时间
+            BigDecimal coursePrice = minutePrice.multiply(courseDate, new MathContext(2, RoundingMode.HALF_UP));
+            //修改流水
+            TenantCloudCourseRecord sourceCord = new TenantCloudCourseRecord();
+            sourceCord.setId(record.getId());
+            sourceCord.setAmount(coursePrice);
+            sourceCord.setDeductState(1);
+            tenantCloudCourseRecordService.updateById(sourceCord);
+            //扣余额
+            if (baseMapper.checkDeductAmount(coursePrice, record.getTenantId()) == 0) {
+                throw new BizException("余额不足!");
+            }
+        });
 
 
-    private TenantCloudCourseRecord checkLastRecord(Integer courseId) {
-        TenantCloudCourseRecord lastRecord = tenantCloudCourseRecordService.queryLastRecord(courseId);
-        if (Objects.isNull(lastRecord)) {
-            return null;
-        }
-        //判断是否是冻结的状态
-        if (lastRecord.getDeductState() != 0) {
-            //只有冻结的才能取消冻结 或者 扣费
-            throw new BizException("该课程非线上课!");
-        }
-        lastRecord.setCreatedBy(getUserId());
-        lastRecord.setCreatedTime(new Date());
-        return lastRecord;
     }
     }
 
 
     /**
     /**
-     * 课程组金额冻结
+     * 上课时间到了后扣除账户余额,可以为负数
      *
      *
-     * @param vipGroup 课程组信息
-     * @param dto      课程组中的课程
-     */
-    @Override
-    @Transactional(rollbackFor = Exception.class)
-    public void groupFrozenAmount(VipGroup vipGroup, List<CourseSchedule> dto) {
-
-    }
-
-    /**
-     * 冻结课程的总价格
-     * 1.线上排课计算出的总价格不能超过账户余额(注意多人同时操作账户余额多扣问题)
-     * 2.若符合规则冻结部分账户
+     * @param dto 课程集合
      */
      */
-    @Override
-    @Transactional(rollbackFor = Exception.class)
-    public void courseFrozenAmount(List<CourseSchedule> dto) {
-        Integer tenantId = TenantContextHolder.getTenantId();
-
+    public void deductAmount(List<CourseSchedule> dto) {
         //校验课程 筛选出线上课
         //校验课程 筛选出线上课
         dto = getOnlineCourse(dto);
         dto = getOnlineCourse(dto);
         if (CollectionUtils.isEmpty(dto)) {
         if (CollectionUtils.isEmpty(dto)) {
             return;
             return;
         }
         }
-
-        TenantAssetsInfo assetsInfo = this.getOne(new WrapperUtil<TenantAssetsInfo>()
-                .hasEq("tenant_id_", tenantId).queryWrapper());
-        if (Objects.isNull(assetsInfo)) {
-            throw new BizException("未查询到该账户资产信息!");
-        }
-
-        //获取云教室规则  String人数-BigDecimal每分钟扣费标准
-        Map<String, BigDecimal> rule = getRule(tenantId);
-        BigDecimal frozenAmount = BigDecimal.ZERO;
-
-        for (CourseSchedule course : dto) {
-            TenantCloudCourseRecord lastRecord = tenantCloudCourseRecordService.queryLastRecord(course.getId().intValue());
-            if (Objects.nonNull(lastRecord) && lastRecord.getDeductState() == 0) {
-                //该课程id最后一条记录也是冻结状态
-                throw new BizException("该课程已是线上课!");
+        //开始扣费
+        dto.forEach(course -> {
+            if (Objects.isNull(course.getTenantId())) {
+                return;
             }
             }
-
             //获取总人数 ,+1是算上老师
             //获取总人数 ,+1是算上老师
             Integer totalPeople = course.getStudentNum() + 1;
             Integer totalPeople = course.getStudentNum() + 1;
+            //获取云教室规则  String人数-BigDecimal每分钟扣费标准
+            Map<String, BigDecimal> rule = getRule(course.getTenantId());
+            if (Objects.isNull(rule)) {
+                //没有这个扣费标准,写未扣费流水记录
+                insertRecord(course, BigDecimal.ZERO, 3);
+                return;
+            }
             //获取每分钟扣费标准
             //获取每分钟扣费标准
             BigDecimal minutePrice = rule.get(String.valueOf(totalPeople));
             BigDecimal minutePrice = rule.get(String.valueOf(totalPeople));
             if (Objects.isNull(minutePrice)) {
             if (Objects.isNull(minutePrice)) {
-                //没有这个扣费标准
-                throw new BizException("课程人数已达上限,请联系教务老师!");
+                //没有这个扣费标准,写未扣费流水记录
+                insertRecord(course, BigDecimal.ZERO, 3);
+                return;
             }
             }
             //计算总上课时间
             //计算总上课时间
-            BigDecimal courseDate = getCourseDate(course);
-            //课程价 = 每分钟扣费标准 * 总上课时间
+            BigDecimal courseDate = getCourseDate(course.getClassDate(), course.getStartClassTime(), course.getEndClassTime());
+            //课程价 = 每分钟扣费标准 * 总上课时间
             BigDecimal coursePrice = minutePrice.multiply(courseDate, new MathContext(2, RoundingMode.HALF_UP));
             BigDecimal coursePrice = minutePrice.multiply(courseDate, new MathContext(2, RoundingMode.HALF_UP));
-            frozenAmount = frozenAmount.add(coursePrice);
-
-            //写入流水
-            TenantCloudCourseRecord record = new TenantCloudCourseRecord();
-            record.setCourseId(course.getId().intValue());
-            record.setAmount(coursePrice);
-            record.setTenantId(tenantId);
-            record.setDeductState(0);
-            record.setCreatedBy(getUserId());
-            record.setCreatedTime(new Date());
-            tenantCloudCourseRecordService.save(record);
-        }
+            //写流水
+            insertRecord(course, coursePrice, 1);
+            //扣余额
+            baseMapper.deductAmount(coursePrice, course.getTenantId());
+        });
 
 
-        //直接修改余额,利用数据库的规则来防ABA的出现
-        if (baseMapper.frozenAmount(frozenAmount) != 1) {
-            //可能是余额不足
-            throw new BizException("线上课预约火爆,请联系教务老师!");
-        }
+    }
 
 
+    /**
+     * 写入流水
+     *
+     * @param course      课程
+     * @param coursePrice 课程总价
+     * @param state       扣费状态 1扣费  3未扣费
+     */
+    private void insertRecord(CourseSchedule course, BigDecimal coursePrice, Integer state) {
+        //写入流水
+        TenantCloudCourseRecord record = new TenantCloudCourseRecord();
+        record.setCourseId(course.getId().intValue());
+        record.setTenantId(course.getTenantId());
+        record.setAmount(coursePrice);
+        record.setDeductState(state);
+        record.setCreatedTime(new Date());
+        tenantCloudCourseRecordService.save(record);
     }
     }
 
 
     private List<CourseSchedule> getOnlineCourse(List<CourseSchedule> dto) {
     private List<CourseSchedule> getOnlineCourse(List<CourseSchedule> dto) {
-        return Optional.ofNullable(dto)
-                .filter(CollectionUtils::isNotEmpty)
-                .orElseThrow(() -> new BizException("请传入课程数据!"))
-                .stream()
+        if (CollectionUtils.isEmpty(dto)) {
+            return null;
+        }
+        return dto.stream()
                 .filter(c -> c.getTeachMode().equals(TeachModeEnum.ONLINE))
                 .filter(c -> c.getTeachMode().equals(TeachModeEnum.ONLINE))
                 .collect(Collectors.toList());
                 .collect(Collectors.toList());
     }
     }
@@ -197,41 +165,35 @@ public class TenantAssetsInfoServiceImpl extends ServiceImpl<TenantAssetsInfoDao
         TenantConfig tenantConfig = tenantConfigService.getOne(new WrapperUtil<TenantConfig>()
         TenantConfig tenantConfig = tenantConfigService.getOne(new WrapperUtil<TenantConfig>()
                 .hasEq("tenant_id_", tenantId).queryWrapper());
                 .hasEq("tenant_id_", tenantId).queryWrapper());
         if (Objects.isNull(tenantConfig)) {
         if (Objects.isNull(tenantConfig)) {
-            throw new BizException("未查询到云教室规则信息!");
+            return null;
         }
         }
         return Optional.ofNullable(tenantConfig.getConfig())
         return Optional.ofNullable(tenantConfig.getConfig())
                 .map(c -> JSON.parseObject(c, TenantConfigDetail.class))
                 .map(c -> JSON.parseObject(c, TenantConfigDetail.class))
                 .map(TenantConfigDetail::getCloud_room_rule)
                 .map(TenantConfigDetail::getCloud_room_rule)
                 .map(CloudRoomRule::getCloud_room_config)
                 .map(CloudRoomRule::getCloud_room_config)
-                .orElseThrow(() -> new BizException("未查询到云教室规则!"));
+                .orElse(null);
     }
     }
 
 
-    private BigDecimal getCourseDate(CourseSchedule course) {
-        String date = DateUtils.formatDate(course.getClassDate(), DateUtils.YYYY_MM_DD_DEF);
-        Date startDT = getDateTime(date, course.getStartClassTime());
-        Date endDT = getDateTime(date, course.getEndClassTime());
-        //课程结束时间-课程开始时间
-        long durationTime = endDT.getTime() - startDT.getTime();
-        //相差多少分钟
-        int durationMinute = new Long(durationTime / 1000 / 60).intValue();
-        return BigDecimal.valueOf(durationMinute);
-    }
-
-    private Date getDateTime(String dateStr, Date time) {
-        String timeStr = DateUtils.formatDate(time, "HH:mm:ss");
-        String s = dateStr + " " + timeStr;
+    private BigDecimal getCourseDate(Date date, Date startTime, Date endTime) {
+        String dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD_DEF);
+        int durationMinute = 0;
         try {
         try {
-            return DateUtils.parseDate(s, DateUtils.DATE_WEB_FORMAT);
+            Date startDT = getDateTime(dateStr, startTime);
+            Date endDT = getDateTime(dateStr, endTime);
+            //课程结束时间-课程开始时间
+            long durationTime = endDT.getTime() - startDT.getTime();
+            //相差多少分钟
+            durationMinute = new Long(durationTime / 1000 / 60).intValue();
         } catch (ParseException e) {
         } catch (ParseException e) {
-            throw new BizException("课程时间格式错误!");
+            log.error("deductAmount >>>>>> 计算时间出错 : {} {} {}", date, startTime, endTime);
         }
         }
+        return BigDecimal.valueOf(durationMinute);
     }
     }
 
 
-    private Integer getUserId() {
-        //修改机构基础信息
-        return Optional.ofNullable(sysUserFeignService.queryUserInfo())
-                .map(SysUser::getId)
-                .orElseThrow(() -> new BizException("用户信息获取失败,请刷新页面或者重新登录!"));
+    private Date getDateTime(String dateStr, Date time) throws ParseException {
+        String timeStr = DateUtils.formatDate(time, "HH:mm:ss");
+        String s = dateStr + " " + timeStr;
+        return DateUtils.parseDate(s, DateUtils.DATE_WEB_FORMAT);
     }
     }
 
 
 }
 }

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

@@ -12,6 +12,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 
 
+import java.util.List;
 import java.util.Map;
 import java.util.Map;
 
 
 /**
 /**
@@ -30,12 +31,11 @@ public class TenantCloudCourseRecordServiceImpl extends ServiceImpl<TenantCloudC
         Page<TenantCloudCourseRecordVo> pageInfo = PageUtil.getPageInfo(param);
         Page<TenantCloudCourseRecordVo> pageInfo = PageUtil.getPageInfo(param);
         pageInfo.setAsc("a.created_time_");
         pageInfo.setAsc("a.created_time_");
         return PageUtil.pageInfo(baseMapper.queryPage(pageInfo, param));
         return PageUtil.pageInfo(baseMapper.queryPage(pageInfo, param));
-
     }
     }
 
 
     @Override
     @Override
-    public TenantCloudCourseRecord queryLastRecord(Integer courseId) {
-        return baseMapper.queryLastRecord(courseId);
+    public List<TenantCloudCourseRecordVo> queryList(Map<String, Object> param) {
+        return baseMapper.queryPage(param);
     }
     }
 }
 }
 
 

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

@@ -410,7 +410,7 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoDao, TenantInfo
             if (tenantInfo.getPayState() == 1) {
             if (tenantInfo.getPayState() == 1) {
                 throw new BizException("已缴费请勿重复缴费!");
                 throw new BizException("已缴费请勿重复缴费!");
             }
             }
-            throw new BizException("该机构数正在缴费中请勿频繁操作");
+            throw new BizException("正在缴费中请稍后!");
         }
         }
         //机构产品信息
         //机构产品信息
         TenantProductInfo productInfo = tenantProductInfoService.getOne(new QueryWrapper<TenantProductInfo>()
         TenantProductInfo productInfo = tenantProductInfoService.getOne(new QueryWrapper<TenantProductInfo>()

+ 7 - 14
mec-biz/src/main/resources/config/mybatis/TenantAssetsInfoMapper.xml

@@ -25,24 +25,17 @@
         </foreach>
         </foreach>
     </insert>
     </insert>
 
 
-    <update id="frozenAmount" parameterType="decimal">
+    <update id="deductAmount" parameterType="object">
         update tenant_assets_info
         update tenant_assets_info
-        set balance_       = balance_ - #{frozenAmount},
-            frozen_amount_ = frozen_amount_ + #{frozenAmount}
-        where balance_  <![CDATA[ >= ]]> #{frozenAmount}
+        set balance_ = balance_ - #{deductAmount}
+        where tenant_id_ = #{tenantId}
     </update>
     </update>
 
 
-    <update id="recoverAmount" parameterType="decimal">
+    <update id="checkDeductAmount" parameterType="object">
         update tenant_assets_info
         update tenant_assets_info
-        set balance_       = balance_ + #{recoverAmount},
-            frozen_amount_ = frozen_amount_ - #{recoverAmount}
-        where frozen_amount_  <![CDATA[ >= ]]> #{recoverAmount}
-    </update>
-
-    <update id="deductAmount" parameterType="decimal">
-        update tenant_assets_info
-        set frozen_amount_ = frozen_amount_ - #{deductAmount}
-        where frozen_amount_  <![CDATA[ >= ]]> #{deductAmount}
+        set balance_ = balance_ - #{deductAmount}
+        where tenant_id_ = #{tenantId}
+          and balance_  <![CDATA[ >= ]]> #{deductAmount}
     </update>
     </update>
 
 
 </mapper>
 </mapper>

+ 10 - 10
mec-biz/src/main/resources/config/mybatis/TenantCloudCourseRecordMapper.xml

@@ -21,6 +21,7 @@
         select a.id_ as id,
         select a.id_ as id,
         b.id_ as courseId,
         b.id_ as courseId,
         o.name_ as organName,
         o.name_ as organName,
+        t.id_ as tenantId
         t.name_ as tenantName,
         t.name_ as tenantName,
         b.type_ as type,
         b.type_ as type,
         s.real_name_ as teacherName,
         s.real_name_ as teacherName,
@@ -60,6 +61,9 @@
             <if test="param.teacherId!= null ">
             <if test="param.teacherId!= null ">
                 AND b.teacher_id_ = #{param.teacherId}
                 AND b.teacher_id_ = #{param.teacherId}
             </if>
             </if>
+            <if test="param.deductState != null ">
+                AND a.deduct_state_ = #{param.deductState}
+            </if>
             <if test="param.status != null ">
             <if test="param.status != null ">
                 AND b.status_ = #{param.status}
                 AND b.status_ = #{param.status}
             </if>
             </if>
@@ -72,17 +76,13 @@
             <if test="param.endDate != null ">
             <if test="param.endDate != null ">
                 AND b.`class_date_` <![CDATA[ <= ]]>  #{param.endDate}
                 AND b.`class_date_` <![CDATA[ <= ]]>  #{param.endDate}
             </if>
             </if>
+            <if test="param.ids != null ">
+               AND a.id_ IN
+                <foreach collection="ids" item="id" open="(" close=")" separator=",">
+                    #{id}
+                </foreach>
+            </if>
         </where>
         </where>
     </select>
     </select>
 
 
-    <select id="queryLastRecord" parameterType="integer" resultMap="BaseResultMap">
-        select
-        <include refid="Base_Column_List"/>
-        from
-        tenant_cloud_course_record
-        where course_id_=#{courseId}
-        order by created_time_ desc
-        limit 1
-    </select>
-
 </mapper>
 </mapper>

+ 13 - 0
mec-web/src/main/java/com/ym/mec/web/controller/TenantAssetsInfoController.java

@@ -2,10 +2,14 @@ package com.ym.mec.web.controller;
 
 
 import com.ym.mec.biz.service.TenantAssetsInfoService;
 import com.ym.mec.biz.service.TenantAssetsInfoService;
 import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.controller.BaseController;
+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.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.bind.annotation.RestController;
 
 
 import javax.annotation.Resource;
 import javax.annotation.Resource;
+import java.util.List;
 
 
 /**
 /**
  * 机构资产信息(TenantAssetsInfo)表控制层
  * 机构资产信息(TenantAssetsInfo)表控制层
@@ -16,11 +20,20 @@ import javax.annotation.Resource;
 @RestController
 @RestController
 @RequestMapping("/tenantAssetsInfo")
 @RequestMapping("/tenantAssetsInfo")
 public class TenantAssetsInfoController extends BaseController {
 public class TenantAssetsInfoController extends BaseController {
+
     /**
     /**
      * 服务对象
      * 服务对象
      */
      */
     @Resource
     @Resource
     private TenantAssetsInfoService tenantAssetsInfoService;
     private TenantAssetsInfoService tenantAssetsInfoService;
 
 
+    @ApiOperation("手动扣费")
+    @PostMapping(value = "/manualDeduct")
+//    @PreAuthorize("@pcs.hasPermissions('tenantAssetsInfo/manualDeduct')")
+    public Object manualDeductAmount(@RequestBody List<Integer> ids) {
+        tenantAssetsInfoService.manualDeductAmount(ids);
+        return succeed();
+    }
+
 }
 }