Commit 325f1f86 authored by hongguangwu's avatar hongguangwu

工资-按照项目的配置来取社保公积金

parent 44935282
......@@ -16,10 +16,12 @@
*/
package com.yifu.cloud.plus.v1.yifu.archives.entity;
import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ExcelAttribute;
import com.yifu.cloud.plus.v1.yifu.common.mybatis.base.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
......@@ -328,5 +330,19 @@ public class TSettleDomain extends BaseEntity {
@Schema(description = "回款周期1-12")
private String backPayCycle;
/**
* 社保类型0:缴费库;1:预估库
*/
@ExcelAttribute(name = "社保类型0:缴费库;1:预估库")
@ExcelProperty("社保类型0:缴费库;1:预估库")
@Schema(description = "社保类型0:缴费库;1:预估库")
private String socialType;
/**
* 公积金类型0:缴费库;1:预估库
*/
@ExcelAttribute(name = "公积金类型0:缴费库;1:预估库")
@ExcelProperty("公积金类型0:缴费库;1:预估库")
@Schema(description = "公积金类型0:缴费库;1:预估库")
private String fundType;
}
......@@ -71,13 +71,12 @@
<result property="exceptionRemark" column="EXCEPTION_REMARK"/>
<result property="existAdvancePayment" column="EXIST_ADVANCE_PAYMENT"/>
<result property="backPayCycle" column="BACK_PAY_CYCLE"/>
<result property="socialType" column="SOCIAL_TYPE"/>
<result property="fundType" column="FUND_TYPE"/>
</resultMap>
<sql id="Base_Column_List">
a
.
ID
,
a.ID,
a.DEPART_NO,
a.DEPART_NAME,
a.IS_NEW,
......@@ -128,7 +127,9 @@
a.CREATE_NAME,
a.CREATE_TIME,
a.UPDATE_BY,
a.UPDATE_TIME
a.UPDATE_TIME,
a.SOCIAL_TYPE,
a.FUND_TYPE
</sql>
<resultMap id="tSettleDomainSelectVoMap" type="com.yifu.cloud.plus.v1.yifu.archives.vo.TSettleDomainSelectVo">
......
......@@ -292,7 +292,6 @@ public class SalaryUploadServiceImpl extends ServiceImpl<TSalaryStandardMapper,
if (Common.isEmpty(invoiceTitle)) {
return R.failed("新建工资主表失败-获取结算主体的-封面抬头-信息为空,请去<客户管理-结算主体>模块,编辑封面抬头后再导入");
}
YifuUser user = SecurityUtils.getUser();
if (null == user || null == user.getId()) {
return R.failed("新建工资主表失败-获取登录人信息为空");
......@@ -369,8 +368,20 @@ public class SalaryUploadServiceImpl extends ServiceImpl<TSalaryStandardMapper,
, List<TSalaryAccountItem> saiList, TSalaryAccountItem sai, TSettleDomainSelectVo dept
, String invoiceTitle, YifuUser user, LocalDateTime nowTime, TSalaryStandard salary
, boolean isActual) {
// 社保类型0:缴费库;1:预估库
String socialType = CommonConstants.ZERO_STRING;
if (Common.isNotNull(dept.getSocialType())) {
socialType = dept.getSocialType();
}
// 公积金类型0:缴费库;1:预估库
String fundType = CommonConstants.ZERO_STRING;
if (Common.isNotNull(dept.getFundType())) {
fundType = dept.getFundType();
}
List<TSalaryAccount> aList;
TSalaryAccount a;//定库:
TSalaryAccount a;
//定库:
List<TPaymentBySalaryVo> socialEstmateList = null; //社保缴费库
List<TPaymentBySalaryVo> fundEstmateList = null; //公积金缴费库
List<TPaymentBySalaryVo> socialForecastList = null; //社保预估库
......@@ -386,11 +397,14 @@ public class SalaryUploadServiceImpl extends ServiceImpl<TSalaryStandardMapper,
} else {
forecast.setSocialPayMonth(SalaryConstants.PRIORITY_ZERO); //没优先级,则限制住
}
if (CommonConstants.ZERO_STRING.equals(socialType)) {
R<TPaymentVo> tPaymentVoR = HttpDaprUtil.invokeMethodPost(socialProperties.getAppUrl(), socialProperties.getAppId()
, "/tpaymentinfo/inner/selectTPaymentBySalaryVo", forecast, TPaymentVo.class, SecurityConstants.FROM_IN);
if (tPaymentVoR != null && tPaymentVoR.getData() != null && tPaymentVoR.getData().getPaymentList() != null) {
socialEstmateList = tPaymentVoR.getData().getPaymentList();
}
}
if (CommonConstants.ONE_STRING.equals(socialType)) {
// 预估数据
R<TPaymentVo> tForecastVoR = HttpDaprUtil.invokeMethodPost(socialProperties.getAppUrl(), socialProperties.getAppId()
, "/tforecastlibrary/inner/selectTForecastBySalaryVo", forecast, TPaymentVo.class, SecurityConstants.FROM_IN);
......@@ -398,6 +412,7 @@ public class SalaryUploadServiceImpl extends ServiceImpl<TSalaryStandardMapper,
socialForecastList = tForecastVoR.getData().getPaymentList();
}
}
}
if (salaryAccountVo != null && !CommonConstants.ZERO_STRING.equals(salaryAccountVo.getIsDeductFund())) {
forecast = new TPaymentBySalaryVo();
forecast.setSettleDomainId(dept.getId());
......@@ -408,11 +423,14 @@ public class SalaryUploadServiceImpl extends ServiceImpl<TSalaryStandardMapper,
} else {
forecast.setProvidentPayMonth(SalaryConstants.PRIORITY_ZERO); //没优先级,则限制住
}
if (CommonConstants.ZERO_STRING.equals(fundType)) {
R<TPaymentVo> tPaymentVoR = HttpDaprUtil.invokeMethodPost(socialProperties.getAppUrl(), socialProperties.getAppId()
, "/tpaymentinfo/inner/selectTPaymentBySalaryVo", forecast, TPaymentVo.class, SecurityConstants.FROM_IN);
if (tPaymentVoR != null && tPaymentVoR.getData() != null && tPaymentVoR.getData().getPaymentList() != null) {
fundEstmateList = tPaymentVoR.getData().getPaymentList();
}
}
if (CommonConstants.ONE_STRING.equals(fundType)) {
// 预估数据
R<TPaymentVo> tForecastVoR = HttpDaprUtil.invokeMethodPost(socialProperties.getAppUrl(), socialProperties.getAppId()
, "/tforecastlibrary/inner/selectTForecastBySalaryVo", forecast, TPaymentVo.class, SecurityConstants.FROM_IN);
......@@ -420,6 +438,7 @@ public class SalaryUploadServiceImpl extends ServiceImpl<TSalaryStandardMapper,
fundForecastList = tForecastVoR.getData().getPaymentList();
}
}
}
aList = new ArrayList<>();
//true:从缴费库等扣社保标识;false:走代扣
boolean modelPersonSocialFlag;
......@@ -571,30 +590,32 @@ public class SalaryUploadServiceImpl extends ServiceImpl<TSalaryStandardMapper,
}
}
if (Common.isEmpty(a.getIsDeductSocial()) || SalaryConstants.IS_DEDUCT_ONE.equals(a.getIsDeductSocial())) {
a.setSocialType(socialType);
a.setIsDeductSocial(SalaryConstants.IS_DEDUCT_ONE);
//社保公积金金额扣缴: true : 从库里扣除社保等;false : 走代扣
if (modelPersonSocialFlag) {
personalDebt = personalDebt.add(this.saveNewItems(sai, saiList, SalaryConstants.PERSONAL_SOCIAL,
SalaryConstants.PERSONAL_SOCIAL_JAVA,
this.getSocialOrFundMoneyForForecast(a, deptSet, a.getEmpIdcard(), socialEstmateList, socialForecastList, true, true, socialList, fundList, forecastSocialList, forecastFundList), CommonConstants.ONE_INT));
this.getSocialOrFundMoneyForForecast(socialType, deptSet, a.getEmpIdcard(), socialEstmateList, socialForecastList, true, true, socialList, fundList, forecastSocialList, forecastFundList), CommonConstants.ONE_INT));
}
if (modelUnitSocialFlag) {
this.saveNewItems(sai, saiList, SalaryConstants.UNIT_SOCIAL,
SalaryConstants.UNIT_SOCIAL_JAVA,
this.getSocialOrFundMoneyForForecast(a, deptSet, a.getEmpIdcard(), socialEstmateList, socialForecastList, true, false, socialList, fundList, forecastSocialList, forecastFundList), CommonConstants.ZERO_INT);
this.getSocialOrFundMoneyForForecast(socialType, deptSet, a.getEmpIdcard(), socialEstmateList, socialForecastList, true, false, socialList, fundList, forecastSocialList, forecastFundList), CommonConstants.ZERO_INT);
}
}
if (Common.isEmpty(a.getIsDeductFund()) || SalaryConstants.IS_DEDUCT_ONE.equals(a.getIsDeductFund())) {
a.setFundType(fundType);
a.setIsDeductFund(SalaryConstants.IS_DEDUCT_ONE);
if (modelPersonFundFlag) {
personalDebt = personalDebt.add(this.saveNewItems(sai, saiList, SalaryConstants.PERSONAL_FUND,
SalaryConstants.PERSONAL_FUND_JAVA,
this.getSocialOrFundMoneyForForecast(a, deptSet, a.getEmpIdcard(), fundEstmateList, fundForecastList, false, true, socialList, fundList, forecastSocialList, forecastFundList), CommonConstants.ONE_INT));
this.getSocialOrFundMoneyForForecast(fundType, deptSet, a.getEmpIdcard(), fundEstmateList, fundForecastList, false, true, socialList, fundList, forecastSocialList, forecastFundList), CommonConstants.ONE_INT));
}
if (modelUnitFundFlag) {
this.saveNewItems(sai, saiList, SalaryConstants.UNIT_FUND,
SalaryConstants.UNIT_FUND_JAVA,
this.getSocialOrFundMoneyForForecast(a, deptSet, a.getEmpIdcard(), fundEstmateList, fundForecastList, false, false, socialList, fundList, forecastSocialList, forecastFundList), CommonConstants.ZERO_INT);
this.getSocialOrFundMoneyForForecast(fundType, deptSet, a.getEmpIdcard(), fundEstmateList, fundForecastList, false, false, socialList, fundList, forecastSocialList, forecastFundList), CommonConstants.ZERO_INT);
}
}
}
......@@ -1008,7 +1029,7 @@ public class SalaryUploadServiceImpl extends ServiceImpl<TSalaryStandardMapper,
* @Date: 2019/9/26 15:38
* @return: java.math.BigDecimal
**/
public BigDecimal getSocialOrFundMoneyForForecast(TSalaryAccount a, TDepartSettlementInfo deptSet, String idNumber
public BigDecimal getSocialOrFundMoneyForForecast(String socialFundType, TDepartSettlementInfo deptSet, String idNumber
, List<TPaymentBySalaryVo> estmateList, List<TPaymentBySalaryVo> forecastList, boolean isSocial, boolean isPerson
, Set<String> socialList, Set<String> fundList, Set<String> forecastSocialList, Set<String> forecastFundList) {
BigDecimal money = SalaryConstants.B_ZERO;
......@@ -1018,54 +1039,26 @@ public class SalaryUploadServiceImpl extends ServiceImpl<TSalaryStandardMapper,
sub = (new BigDecimal("100").subtract(deptSet.getUnitSeriousIllnessProp()))
.divide(SalaryConstants.B_ONEHUNDRED, SalaryConstants.PLACES, BigDecimal.ROUND_HALF_UP);
}
boolean typeFlag = true;
if (estmateList != null && !estmateList.isEmpty()) {
money = money.setScale(SalaryConstants.PLACES, BigDecimal.ROUND_HALF_UP);
for (TPaymentBySalaryVo m : estmateList) {
if (Common.isNotNull(idNumber) && idNumber.equals(m.getEmpIdcard())) {
//社保
if (isSocial && (m.getPersonalSocialSum() != null || m.getUnitSocialSum() != null)) {
typeFlag = false;
if (Common.isEmpty(m.getSalarySocialFlag()) || CommonConstants.ZERO_STRING.equals(m.getSalarySocialFlag())) {
if (isPerson && m.getPersonalSocialSum() != null) {
money = money.add(m.getPersonalSocialSum());
if (sub.compareTo(SalaryConstants.B_ZERO) != SalaryConstants.EQUAL
&& m.getUnitBitmailmentFee() != null) {
money = money.add(m.getUnitBitmailmentFee().multiply(sub));
}
}
if (!isPerson && m.getUnitSocialSum() != null) {
money = money.add(m.getUnitSocialSum());
if (sub.compareTo(SalaryConstants.B_ZERO) != SalaryConstants.EQUAL
&& m.getUnitBitmailmentFee() != null) {
money = money.subtract(m.getUnitBitmailmentFee().multiply(sub));
}
}
a.setSocialType(CommonConstants.ZERO_STRING);
socialList.add(m.getId());
}
}
//公积金
if (!isSocial && (m.getPersonalFundSum() != null || m.getUnitFundSum() != null)) {
typeFlag = false;
if (Common.isEmpty(m.getSalaryFundFlag()) || CommonConstants.ZERO_STRING.equals(m.getSalaryFundFlag())) {
if (isPerson && m.getPersonalFundSum() != null) {
money = money.add(m.getPersonalFundSum());
}
if (!isPerson && m.getUnitFundSum() != null) {
money = money.add(m.getUnitFundSum());
}
a.setFundType(CommonConstants.ZERO_STRING);
fundList.add(m.getId());
}
}
if (CommonConstants.ZERO_STRING.equals(socialFundType) && estmateList != null && !estmateList.isEmpty()) {
money = this.getSocialFundMoney(idNumber, estmateList, isSocial, isPerson, socialList, fundList, money, sub);
}
// 缴费库没找到,从预估库找
if (CommonConstants.ONE_STRING.equals(socialFundType) && forecastList != null && !forecastList.isEmpty()) {
money = this.getSocialFundMoney(idNumber, forecastList, isSocial, isPerson, forecastSocialList, forecastFundList, money, sub);
}
return money;
}
// 缴费库没找到,从预估库找
if (typeFlag && forecastList != null && !forecastList.isEmpty()) {
/**
* @Description: 按类型拉取社保公积金
* @Author: hgw
* @Date: 2022/8/17 11:38
* @return: java.math.BigDecimal
**/
private BigDecimal getSocialFundMoney(String idNumber, List<TPaymentBySalaryVo> estmateList, boolean isSocial
, boolean isPerson, Set<String> socialList, Set<String> fundList, BigDecimal money, BigDecimal sub) {
money = money.setScale(SalaryConstants.PLACES, BigDecimal.ROUND_HALF_UP);
for (TPaymentBySalaryVo m : forecastList) {
for (TPaymentBySalaryVo m : estmateList) {
if (Common.isNotNull(idNumber) && idNumber.equals(m.getEmpIdcard())) {
//社保
if (isSocial && (!Common.isNotNull(m.getSalarySocialFlag()) || CommonConstants.ZERO_STRING.equals(m.getSalarySocialFlag()))
......@@ -1084,8 +1077,7 @@ public class SalaryUploadServiceImpl extends ServiceImpl<TSalaryStandardMapper,
money = money.subtract(m.getUnitBitmailmentFee().multiply(sub));
}
}
a.setSocialType(CommonConstants.ONE_STRING);
forecastSocialList.add(m.getId());
socialList.add(m.getId());
}
//公积金
if (!isSocial && (!Common.isNotNull(m.getSalaryFundFlag()) || CommonConstants.ZERO_STRING.equals(m.getSalaryFundFlag()))
......@@ -1096,9 +1088,7 @@ public class SalaryUploadServiceImpl extends ServiceImpl<TSalaryStandardMapper,
if (!isPerson && m.getUnitFundSum() != null) {
money = money.add(m.getUnitFundSum());
}
a.setFundType(CommonConstants.ONE_STRING);
forecastFundList.add(m.getId());
}
fundList.add(m.getId());
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment