完成补贴发放后的超过最大上限的自动冲减。
This commit is contained in:
parent
adaf6abd7b
commit
230442827f
@ -2,6 +2,7 @@ package com.ruoyi.system.fantang.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
@ -10,10 +11,9 @@ import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.system.fantang.domain.FtStaffInfoDao;
|
||||
import com.ruoyi.system.fantang.domain.FtStaffSubsidyDao;
|
||||
import com.ruoyi.system.fantang.domain.FtSubsidyDao;
|
||||
import com.ruoyi.system.fantang.domain.*;
|
||||
import com.ruoyi.system.fantang.mapper.FtStaffInfoDaoMapper;
|
||||
import com.ruoyi.system.fantang.service.IFtConfigDaoService;
|
||||
import com.ruoyi.system.fantang.service.IFtStaffInfoDaoService;
|
||||
import com.ruoyi.system.fantang.service.IFtStaffSubsidyDaoService;
|
||||
import com.ruoyi.system.fantang.vo.FtStaffSubsidyVo;
|
||||
@ -22,6 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
@ -39,6 +40,8 @@ public class FtStaffSubsidyDaoController extends BaseController {
|
||||
|
||||
private final IFtStaffInfoDaoService staffInfoDaoService;
|
||||
|
||||
private final IFtConfigDaoService configDaoService;
|
||||
|
||||
/**
|
||||
* 查询补贴流水查看列表
|
||||
*/
|
||||
@ -125,7 +128,7 @@ public class FtStaffSubsidyDaoController extends BaseController {
|
||||
List<String> noGiveoutList = ftStaffSubsidyVo.getNoGiveoutList();
|
||||
Date giveOutDate = ftStaffSubsidyVo.getGiveOutDate();
|
||||
QueryWrapper<FtStaffInfoDao> wrapper = new QueryWrapper<>();
|
||||
wrapper.notIn("staff_id",noGiveoutList);
|
||||
wrapper.notIn("staff_id", noGiveoutList);
|
||||
List<FtStaffInfoDao> staffData = staffInfoDaoService.list(wrapper);
|
||||
|
||||
List<FtStaffSubsidyDao> ftStaffSubsidyDaoList = new ArrayList<>();
|
||||
@ -142,8 +145,47 @@ public class FtStaffSubsidyDaoController extends BaseController {
|
||||
}
|
||||
}
|
||||
|
||||
iFtStaffSubsidyDaoService.insertBatchStaffSubsidy(ftStaffSubsidyDaoList);
|
||||
Integer ret = iFtStaffSubsidyDaoService.insertBatchStaffSubsidy(ftStaffSubsidyDaoList);
|
||||
logger.info("发放补贴:{} 人", ret);
|
||||
|
||||
return AjaxResult.success("发放成功");
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(String.format("本次发放合计:%d 人;", ret));
|
||||
|
||||
// 统计发放补贴后,有多少人的补贴超过了设置的上限150元;
|
||||
// 1 先去应用数据配置表中找到该企业配置的最大补贴上限
|
||||
QueryWrapper<FtConfigDao> wrapper1 = new QueryWrapper<>();
|
||||
wrapper1
|
||||
.eq("config_key", "max_subsidy")
|
||||
.eq("corp_id", 1);
|
||||
List<FtConfigDao> list = configDaoService.list(wrapper1);
|
||||
if (list.size() <= 0 ) {
|
||||
logger.error("获取系统配置的最大补贴数据失败!");
|
||||
return AjaxResult.error("获取系统配置的最大补贴数据失败!");
|
||||
}
|
||||
FtConfigDao configDao = list.get(0);
|
||||
Integer maxSubsidy = Integer.parseInt(configDao.getConfigValue());
|
||||
|
||||
// 2 去员工信息表中统计余额信息超过 最大补贴数的信息
|
||||
QueryWrapper<FtStaffInfoDao> wrapper2 = new QueryWrapper<>();
|
||||
wrapper2.gt("balance", 150);
|
||||
int overflowCount = staffInfoDaoService.count(wrapper2);
|
||||
builder.append(String.format("本次统计超出余额上限员工合计:%d", overflowCount));
|
||||
|
||||
if (overflowCount <= 0) {
|
||||
builder.append(String.format("本次补贴发放没有累计余额超出上限员工"));
|
||||
return AjaxResult.success(builder);
|
||||
}
|
||||
|
||||
// 3 如果有超过的余额的,进行余额冲减操作
|
||||
iFtStaffSubsidyDaoService.reBalance(subsidy.getType(), maxSubsidy);
|
||||
|
||||
// 4 更新员工表的余额信息,超过 最大数的全部冲减
|
||||
UpdateWrapper<FtStaffInfoDao> updateWrapper=new UpdateWrapper<>();
|
||||
FtStaffInfoDao staffInfoDao = new FtStaffInfoDao();
|
||||
staffInfoDao.setBalance(BigDecimal.valueOf(maxSubsidy));
|
||||
updateWrapper.gt("balance", maxSubsidy);
|
||||
staffInfoDaoService.update(staffInfoDao, updateWrapper);
|
||||
builder.append(String.format("本次超出余额上限员工全部进行冲减,请查看日志"));
|
||||
return AjaxResult.success(builder);
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package com.ruoyi.system.fantang.mapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.ruoyi.system.fantang.domain.FtStaffSubsidyDao;
|
||||
import org.apache.ibatis.annotations.Insert;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -15,4 +16,11 @@ import java.util.List;
|
||||
public interface FtStaffSubsidyDaoMapper extends BaseMapper<FtStaffSubsidyDao> {
|
||||
|
||||
Integer insertBatchStaffSubsidy(List<FtStaffSubsidyDao> ftStaffSubsidyDaoList);
|
||||
|
||||
@Insert("")
|
||||
void reBalance();
|
||||
|
||||
@Insert("INSERT into ft_staff_subsidy (staff_id, subsidy_type , income_type, price , consum_at) " +
|
||||
" select staff_id, #{subsidyType}, 3, balance -#{maxBalance}, now() from ft_staff_info where balance > #{maxBalance} ")
|
||||
void insertReBalance(@Param("subsidyType")String subsidyType, @Param("maxBalance") Integer maxBalance);
|
||||
}
|
||||
|
@ -14,4 +14,6 @@ import java.util.List;
|
||||
public interface IFtStaffSubsidyDaoService extends IService<FtStaffSubsidyDao> {
|
||||
|
||||
Integer insertBatchStaffSubsidy(List<FtStaffSubsidyDao> ftStaffSubsidyDaoList);
|
||||
|
||||
void reBalance(String subsidyType, Integer maxBalance);
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.system.fantang.domain.FtStaffSubsidyDao;
|
||||
import com.ruoyi.system.fantang.mapper.FtStaffSubsidyDaoMapper;
|
||||
import com.ruoyi.system.fantang.service.IFtStaffSubsidyDaoService;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
@ -21,4 +22,9 @@ public class FtStaffSubsidyDaoServiceImpl extends ServiceImpl<FtStaffSubsidyDaoM
|
||||
public Integer insertBatchStaffSubsidy(List<FtStaffSubsidyDao> ftStaffSubsidyDaoList) {
|
||||
return this.baseMapper.insertBatchStaffSubsidy(ftStaffSubsidyDaoList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reBalance(String subsidyType, Integer maxBalance) {
|
||||
this.baseMapper.insertReBalance(subsidyType, maxBalance);
|
||||
}
|
||||
}
|
||||
|
@ -534,6 +534,7 @@ export default {
|
||||
|
||||
// 收费弹出层所有根据时间范围未付费数据列表
|
||||
popupShowMealsWithSelect() {
|
||||
console.log('this.formAddNewSettlement:',this.formAddNewSettlement);
|
||||
showMealsWithSelect(this.formAddNewSettlement).then(response => {
|
||||
this.mealsList = response.data.reportMealsList.records;
|
||||
this.totalDetails = response.data.reportMealsList.total;
|
||||
@ -571,6 +572,7 @@ export default {
|
||||
}
|
||||
|
||||
if (this.formAddNewSettlement.selectBillingDate != null) {
|
||||
|
||||
this.popupShowMealsWithSelect();
|
||||
} else {
|
||||
this.mealsList = null;
|
||||
|
Loading…
x
Reference in New Issue
Block a user