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,64 +71,65 @@
<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.DEPART_NO,
a.DEPART_NAME,
a.IS_NEW,
a.NEW_REMARK,
a.DELETE_FLAG,
a.DP_AUDIT_FLAG,
a.OLD_ID,
a.BELONG_CONTRACT,
a.DP_AUDIT_OPINION,
a.DP_AUDIT_MAN,
a.DP_AUDIT_MAN_NAME,
a.LAST_AUDIT_DATE,
a.SERVER_ITEM,
a.INCOME_BELONG,
a.INCOME_BELONG_SUB,
a.CUSTOMER_ID,
a.CREATE_USER_NAME,
a.COMMIT_USER,
a.COMMIT_USER_NAME,
a.BALANCE,
a.INVOICE_BALANCE,
a.FIRST_PASS_FLAG,
a.FIRST_PASS_TIME,
a.PROVINCE,
a.CITY,
a.TOWN,
a.STOP_FLAG,
a.employee_num,
a.STOP_DATE,
a.STOP_REASON,
a.STOP_USER,
a.STOP_USER_NAME,
a.TYPE,
a.BUSINESS_PRIMARY_TYPE,
a.BUSINESS_SECOND_TYPE,
a.BUSINESS_THIRD_TYPE,
a.MANAGER_AUDIT_OPINION,
a.MANAGER_AUDIT_MAN,
a.MANAGER_AUDIT_MAN_NAME,
a.AUDIT_TIME,
a.MANAGER_AUDIT_TIME,
a.CREATE_TYPE,
a.RELATE_FLAG,
a.EXCEPTION_REMARK,
a.EXIST_ADVANCE_PAYMENT,
a.BACK_PAY_CYCLE,
a.CREATE_BY,
a.CREATE_NAME,
a.CREATE_TIME,
a.UPDATE_BY,
a.UPDATE_TIME
a.ID,
a.DEPART_NO,
a.DEPART_NAME,
a.IS_NEW,
a.NEW_REMARK,
a.DELETE_FLAG,
a.DP_AUDIT_FLAG,
a.OLD_ID,
a.BELONG_CONTRACT,
a.DP_AUDIT_OPINION,
a.DP_AUDIT_MAN,
a.DP_AUDIT_MAN_NAME,
a.LAST_AUDIT_DATE,
a.SERVER_ITEM,
a.INCOME_BELONG,
a.INCOME_BELONG_SUB,
a.CUSTOMER_ID,
a.CREATE_USER_NAME,
a.COMMIT_USER,
a.COMMIT_USER_NAME,
a.BALANCE,
a.INVOICE_BALANCE,
a.FIRST_PASS_FLAG,
a.FIRST_PASS_TIME,
a.PROVINCE,
a.CITY,
a.TOWN,
a.STOP_FLAG,
a.employee_num,
a.STOP_DATE,
a.STOP_REASON,
a.STOP_USER,
a.STOP_USER_NAME,
a.TYPE,
a.BUSINESS_PRIMARY_TYPE,
a.BUSINESS_SECOND_TYPE,
a.BUSINESS_THIRD_TYPE,
a.MANAGER_AUDIT_OPINION,
a.MANAGER_AUDIT_MAN,
a.MANAGER_AUDIT_MAN_NAME,
a.AUDIT_TIME,
a.MANAGER_AUDIT_TIME,
a.CREATE_TYPE,
a.RELATE_FLAG,
a.EXCEPTION_REMARK,
a.EXIST_ADVANCE_PAYMENT,
a.BACK_PAY_CYCLE,
a.CREATE_BY,
a.CREATE_NAME,
a.CREATE_TIME,
a.UPDATE_BY,
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,16 +397,20 @@ public class SalaryUploadServiceImpl extends ServiceImpl<TSalaryStandardMapper,
} else {
forecast.setSocialPayMonth(SalaryConstants.PRIORITY_ZERO); //没优先级,则限制住
}
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.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();
}
}
// 预估数据
R<TPaymentVo> tForecastVoR = HttpDaprUtil.invokeMethodPost(socialProperties.getAppUrl(), socialProperties.getAppId()
, "/tforecastlibrary/inner/selectTForecastBySalaryVo", forecast, TPaymentVo.class, SecurityConstants.FROM_IN);
if (tForecastVoR != null && tForecastVoR.getData() != null && tForecastVoR.getData().getPaymentList() != null) {
socialForecastList = tForecastVoR.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);
if (tForecastVoR != null && tForecastVoR.getData() != null && tForecastVoR.getData().getPaymentList() != null) {
socialForecastList = tForecastVoR.getData().getPaymentList();
}
}
}
if (salaryAccountVo != null && !CommonConstants.ZERO_STRING.equals(salaryAccountVo.getIsDeductFund())) {
......@@ -408,16 +423,20 @@ public class SalaryUploadServiceImpl extends ServiceImpl<TSalaryStandardMapper,
} else {
forecast.setProvidentPayMonth(SalaryConstants.PRIORITY_ZERO); //没优先级,则限制住
}
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.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();
}
}
// 预估数据
R<TPaymentVo> tForecastVoR = HttpDaprUtil.invokeMethodPost(socialProperties.getAppUrl(), socialProperties.getAppId()
, "/tforecastlibrary/inner/selectTForecastBySalaryVo", forecast, TPaymentVo.class, SecurityConstants.FROM_IN);
if (tForecastVoR != null && tForecastVoR.getData() != null && tForecastVoR.getData().getPaymentList() != null) {
fundForecastList = tForecastVoR.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);
if (tForecastVoR != null && tForecastVoR.getData() != null && tForecastVoR.getData().getPaymentList() != null) {
fundForecastList = tForecastVoR.getData().getPaymentList();
}
}
}
aList = new ArrayList<>();
......@@ -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,87 +1039,56 @@ 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 (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;
}
/**
* @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 : estmateList) {
if (Common.isNotNull(idNumber) && idNumber.equals(m.getEmpIdcard())) {
//社保
if (isSocial && (!Common.isNotNull(m.getSalarySocialFlag()) || CommonConstants.ZERO_STRING.equals(m.getSalarySocialFlag()))
&& (m.getPersonalSocialSum() != null || m.getUnitSocialSum() != null)) {
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 (!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 (!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));
}
}
socialList.add(m.getId());
}
}
}
// 缴费库没找到,从预估库找
if (typeFlag && forecastList != null && !forecastList.isEmpty()) {
money = money.setScale(SalaryConstants.PLACES, BigDecimal.ROUND_HALF_UP);
for (TPaymentBySalaryVo m : forecastList) {
if (Common.isNotNull(idNumber) && idNumber.equals(m.getEmpIdcard())) {
//社保
if (isSocial && (!Common.isNotNull(m.getSalarySocialFlag()) || CommonConstants.ZERO_STRING.equals(m.getSalarySocialFlag()))
&& (m.getPersonalSocialSum() != null || m.getUnitSocialSum() != null)) {
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.ONE_STRING);
forecastSocialList.add(m.getId());
//公积金
if (!isSocial && (!Common.isNotNull(m.getSalaryFundFlag()) || CommonConstants.ZERO_STRING.equals(m.getSalaryFundFlag()))
&& (m.getPersonalFundSum() != null || m.getUnitFundSum() != null)) {
if (isPerson && m.getPersonalFundSum() != null) {
money = money.add(m.getPersonalFundSum());
}
//公积金
if (!isSocial && (!Common.isNotNull(m.getSalaryFundFlag()) || CommonConstants.ZERO_STRING.equals(m.getSalaryFundFlag()))
&& (m.getPersonalFundSum() != null || m.getUnitFundSum() != null)) {
if (isPerson && m.getPersonalFundSum() != null) {
money = money.add(m.getPersonalFundSum());
}
if (!isPerson && m.getUnitFundSum() != null) {
money = money.add(m.getUnitFundSum());
}
a.setFundType(CommonConstants.ONE_STRING);
forecastFundList.add(m.getId());
if (!isPerson && m.getUnitFundSum() != null) {
money = money.add(m.getUnitFundSum());
}
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