申报状态拆分
This commit is contained in:
parent
be85c47a68
commit
e994a61037
|
|
@ -1,5 +1,6 @@
|
|||
package com.engine.salary.entity.taxdeclaration.param;
|
||||
|
||||
import com.engine.salary.util.valid.DataCheck;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
|
@ -12,7 +13,12 @@ import lombok.experimental.Accessors;
|
|||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DeclareTaxResultFeedbackQueryParam {
|
||||
|
||||
@DataCheck(require = true, message = "个税申报记录id不能为空!")
|
||||
Long id;
|
||||
|
||||
@DataCheck(require = true, message = "申报类型不能为空!")
|
||||
Integer reportType;
|
||||
|
||||
String requestId;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,6 +73,7 @@ public class TaxDeclareRecordPO implements Serializable {
|
|||
/**
|
||||
* 申报的requestId,用于下载申报过程
|
||||
*/
|
||||
@Deprecated
|
||||
private String declareRequestId;
|
||||
/**
|
||||
* 备注
|
||||
|
|
|
|||
|
|
@ -134,8 +134,6 @@ public interface TaxDeclareRecordService {
|
|||
*/
|
||||
void declare(Long id, Integer reportType);
|
||||
|
||||
TaxDeclareStatusPO getTaxDeclareStatus(Long taxDeclareRecordId, Integer reportType);
|
||||
|
||||
List<TaxDeclareStatusPO> getTaxDeclareStatusByTaxDeclareRecordId(Long taxDeclareRecordId);
|
||||
|
||||
/**
|
||||
|
|
@ -191,19 +189,6 @@ public interface TaxDeclareRecordService {
|
|||
*/
|
||||
String queryDeclareStatus(Long id);
|
||||
|
||||
|
||||
void updateById(TaxDeclareRecordPO taxDeclareRecord);
|
||||
|
||||
/**
|
||||
* 获取申报记录状态列表
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
List<TaxDeclareStatusPO> getOrInitTaxReports(Long id);
|
||||
|
||||
/**
|
||||
* 更新申报状态,同时更新主记录
|
||||
* @param declareStatus
|
||||
*/
|
||||
void updateTaxDeclareStatus(TaxDeclareStatusPO declareStatus);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,37 @@
|
|||
package com.engine.salary.service;
|
||||
|
||||
import com.engine.salary.entity.taxdeclaration.po.TaxDeclareStatusPO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 个税申报表状态
|
||||
* <p>Copyright: Copyright (c) 2023</p>
|
||||
* <p>Company: 泛微软件</p>
|
||||
*
|
||||
* @author qiantao
|
||||
* @version 1.0
|
||||
**/
|
||||
public interface TaxDeclareStatusService {
|
||||
|
||||
/**
|
||||
* 获取申报记录状态
|
||||
* @param taxDeclareRecordId
|
||||
* @param reportType
|
||||
* @return
|
||||
*/
|
||||
TaxDeclareStatusPO getTaxDeclareStatus(Long taxDeclareRecordId, Integer reportType);
|
||||
|
||||
/**
|
||||
* 获取申报记录状态列表
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
List<TaxDeclareStatusPO> getOrInitTaxReports(Long id);
|
||||
|
||||
/**
|
||||
* 更新申报状态,同时更新主记录
|
||||
* @param declareStatus
|
||||
*/
|
||||
void updateTaxDeclareStatus(TaxDeclareStatusPO declareStatus);
|
||||
}
|
||||
|
|
@ -52,6 +52,9 @@ public abstract class AbstractTaxPaymentService extends Service implements TaxPa
|
|||
return ServiceUtil.getService(TaxAgentTaxReturnServiceImpl.class, user);
|
||||
}
|
||||
|
||||
protected TaxDeclareStatusService getTaxDeclareStatusService(User user) {
|
||||
return ServiceUtil.getService(TaxDeclareStatusServiceImpl.class, user);
|
||||
}
|
||||
protected TaxAgentService getTaxAgentService(User user) {
|
||||
return ServiceUtil.getService(TaxAgentServiceImpl.class, user);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,10 +20,7 @@ import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationValueListDTO;
|
|||
import com.engine.salary.entity.taxdeclaration.param.ContrastQueryParam;
|
||||
import com.engine.salary.entity.taxdeclaration.param.TaxDeclarationValueListQueryParam;
|
||||
import com.engine.salary.entity.taxdeclaration.param.TaxDeclareRecordDetailSaveParam;
|
||||
import com.engine.salary.entity.taxdeclaration.po.TaxDeclarationPO;
|
||||
import com.engine.salary.entity.taxdeclaration.po.TaxDeclarationValuePO;
|
||||
import com.engine.salary.entity.taxdeclaration.po.TaxDeclareRecordPO;
|
||||
import com.engine.salary.entity.taxdeclaration.po.TaxReportColumnPO;
|
||||
import com.engine.salary.entity.taxdeclaration.po.*;
|
||||
import com.engine.salary.enums.OperateTypeEnum;
|
||||
import com.engine.salary.enums.salaryaccounting.EmployeeTypeEnum;
|
||||
import com.engine.salary.enums.salaryitem.SalaryDataTypeEnum;
|
||||
|
|
@ -78,6 +75,11 @@ public class TaxDeclarationValueServiceImpl extends Service implements TaxDeclar
|
|||
return MapperProxyFactory.getProxy(TaxDeclareRecordMapper.class);
|
||||
}
|
||||
|
||||
private TaxDeclareStatusService getTaxDeclareStatusService(User user) {
|
||||
return ServiceUtil.getService(TaxDeclareStatusServiceImpl.class, user);
|
||||
}
|
||||
|
||||
|
||||
private SalaryEmployeeService getSalaryEmployeeService(User user) {
|
||||
return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user);
|
||||
}
|
||||
|
|
@ -355,10 +357,12 @@ public class TaxDeclarationValueServiceImpl extends Service implements TaxDeclar
|
|||
throw new SalaryRunTimeException("申报记录不存在!");
|
||||
}
|
||||
|
||||
Integer reportType = IncomeCategoryEnum.parseByValue(taxDeclaration.getIncomeCategory()).getReportType().getValue();
|
||||
TaxDeclareStatusPO taxDeclareStatus = getTaxDeclareStatusService(user).getTaxDeclareStatus(taxDeclareRecordPO.getId(), reportType);
|
||||
|
||||
//线上数据
|
||||
DeclareClient declareClient = new DeclareClient(taxDeclareRecordPO.getTaxAgentId());
|
||||
GetDeclareTaxResultFeedbackResponse declareTaxResultFeedbackResponse = declareClient.getDeclareTaxResultFeedback(taxDeclareRecordPO.getDeclareRequestId());
|
||||
GetDeclareTaxResultFeedbackResponse declareTaxResultFeedbackResponse = declareClient.getDeclareTaxResultFeedback(taxDeclareStatus.getDeclareRequestId());
|
||||
|
||||
Map<String, List<List<Object>>> onlineDataMap = new HashMap<>();
|
||||
List<TaxDeclarationPO> list = getTaxDeclarationService(user).listByTaxDeclareRecordId(taxDeclareRecordPO.getId());
|
||||
|
|
|
|||
|
|
@ -92,6 +92,10 @@ public class TaxDeclareRecordServiceImpl extends Service implements TaxDeclareRe
|
|||
return MapperProxyFactory.getProxy(TaxDeclareStatusMapper.class);
|
||||
}
|
||||
|
||||
private TaxDeclareStatusService getTaxDeclareStatusService(User user) {
|
||||
return ServiceUtil.getService(TaxDeclareStatusServiceImpl.class, user);
|
||||
}
|
||||
|
||||
private TaxDeclarationService getTaxDeclarationService(User user) {
|
||||
return ServiceUtil.getService(TaxDeclarationServiceImpl.class, user);
|
||||
}
|
||||
|
|
@ -641,7 +645,7 @@ public class TaxDeclareRecordServiceImpl extends Service implements TaxDeclareRe
|
|||
|
||||
DeclareReportTypeEnum declareReportType = DeclareReportTypeEnum.parseByValue(reportType);
|
||||
|
||||
TaxDeclareStatusPO declareStatus = getTaxDeclareStatus(id, reportType);
|
||||
TaxDeclareStatusPO declareStatus = getTaxDeclareStatusService(user).getTaxDeclareStatus(id, reportType);
|
||||
|
||||
|
||||
TaxDeclareRequest taxDeclareRequest = buildTaxDeclareRequest(id);
|
||||
|
|
@ -720,7 +724,7 @@ public class TaxDeclareRecordServiceImpl extends Service implements TaxDeclareRe
|
|||
declareStatus.setTaxDeclareStatus(TaxDeclareStatusEnum.DECLARING.getValue());
|
||||
declareStatus.setRequestId(declareTaxResponse.getBody().getRequestId());
|
||||
declareStatus.setTaxDeclareErrorMsg("");
|
||||
updateTaxDeclareStatus(declareStatus);
|
||||
getTaxDeclareStatusService(user).updateTaxDeclareStatus(declareStatus);
|
||||
|
||||
// 记录日志
|
||||
TaxAgentPO taxAgent = taxDeclareRequest.getTaxAgent();
|
||||
|
|
@ -736,11 +740,6 @@ public class TaxDeclareRecordServiceImpl extends Service implements TaxDeclareRe
|
|||
SalaryElogConfig.taxDeclarationLoggerTemplate.write(loggerContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TaxDeclareStatusPO getTaxDeclareStatus(Long taxDeclareRecordId, Integer reportType) {
|
||||
return getTaxDeclareStatusMapper().getDeclareStatus(taxDeclareRecordId, reportType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TaxDeclareStatusPO> getTaxDeclareStatusByTaxDeclareRecordId(Long taxDeclareRecordId) {
|
||||
return getTaxDeclareStatusMapper().listSome(TaxDeclareStatusPO.builder().taxDeclareRecordId(taxDeclareRecordId).build());
|
||||
|
|
@ -751,7 +750,7 @@ public class TaxDeclareRecordServiceImpl extends Service implements TaxDeclareRe
|
|||
TaxDeclareRequest taxDeclareRequest = buildTaxDeclareRequest(id);
|
||||
TaxDeclareRecordPO taxDeclareRecord = taxDeclareRequest.getTaxDeclareRecord();
|
||||
|
||||
TaxDeclareStatusPO declareStatus = getTaxDeclareStatus(id, reportType);
|
||||
TaxDeclareStatusPO declareStatus = getTaxDeclareStatusService(user).getTaxDeclareStatus(id, reportType);
|
||||
|
||||
if (StringUtils.isEmpty(declareStatus.getRequestId()) || !Objects.equals(declareStatus.getTaxDeclareStatus(), TaxDeclareStatusEnum.DECLARING.getValue())) {
|
||||
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(156496, "请先点击「在线申报」后再点击「申报反馈」获取申报结果"));
|
||||
|
|
@ -851,7 +850,7 @@ public class TaxDeclareRecordServiceImpl extends Service implements TaxDeclareRe
|
|||
declareStatus.setTaxPayAmount(payAmount.subtract(purePaidAmount).toString());
|
||||
}
|
||||
//更新申报状态
|
||||
updateTaxDeclareStatus(declareStatus);
|
||||
getTaxDeclareStatusService(user).updateTaxDeclareStatus(declareStatus);
|
||||
|
||||
// 如果申报失败
|
||||
if (CollectionUtils.isNotEmpty(taxDeclareFails)) {
|
||||
|
|
@ -884,7 +883,7 @@ public class TaxDeclareRecordServiceImpl extends Service implements TaxDeclareRe
|
|||
TaxDeclareRequest taxDeclareRequest = buildTaxDeclareRequest(id);
|
||||
TaxDeclareRecordPO taxDeclareRecord = taxDeclareRequest.getTaxDeclareRecord();
|
||||
|
||||
TaxDeclareStatusPO declareStatus = getTaxDeclareStatus(id, reportType);
|
||||
TaxDeclareStatusPO declareStatus = getTaxDeclareStatusService(user).getTaxDeclareStatus(id, reportType);
|
||||
// 更正申报成功后不能作废
|
||||
if (Objects.equals(declareStatus.getTaxDeclareType(), TaxDeclareTypeEnum.UPDATE_DECLARE.getValue())) {
|
||||
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(182701, "更正申报后不允许作废"));
|
||||
|
|
@ -922,7 +921,7 @@ public class TaxDeclareRecordServiceImpl extends Service implements TaxDeclareRe
|
|||
// 更新个税申报状态
|
||||
declareStatus.setTaxDeclareStatus(TaxDeclareStatusEnum.DECLARE_CANCELLING.getValue());
|
||||
declareStatus.setRequestId(declareTaxResponse.getBody().getRequestId());
|
||||
updateTaxDeclareStatus(declareStatus);
|
||||
getTaxDeclareStatusService(user).updateTaxDeclareStatus(declareStatus);
|
||||
|
||||
// 记录日志
|
||||
TaxAgentPO taxAgent = taxDeclareRequest.getTaxAgent();
|
||||
|
|
@ -943,7 +942,7 @@ public class TaxDeclareRecordServiceImpl extends Service implements TaxDeclareRe
|
|||
TaxDeclareRequest taxDeclareRequest = buildTaxDeclareRequest(id);
|
||||
TaxDeclareRecordPO taxDeclareRecord = taxDeclareRequest.getTaxDeclareRecord();
|
||||
|
||||
TaxDeclareStatusPO declareStatus = getTaxDeclareStatus(id, reportType);
|
||||
TaxDeclareStatusPO declareStatus = getTaxDeclareStatusService(user).getTaxDeclareStatus(id, reportType);
|
||||
|
||||
|
||||
if (!Objects.equals(declareStatus.getTaxDeclareStatus(), TaxDeclareStatusEnum.DECLARE_CANCELLING.getValue()) || StringUtils.isEmpty(declareStatus.getRequestId())) {
|
||||
|
|
@ -979,7 +978,7 @@ public class TaxDeclareRecordServiceImpl extends Service implements TaxDeclareRe
|
|||
//更新个税申报状态
|
||||
declareStatus.setTaxDeclareStatus(taxDeclareStatusEnum.getValue());
|
||||
declareStatus.setRequestId("");
|
||||
updateTaxDeclareStatus(declareStatus);
|
||||
getTaxDeclareStatusService(user).updateTaxDeclareStatus(declareStatus);
|
||||
|
||||
// 记录日志
|
||||
TaxAgentPO taxAgent = taxDeclareRequest.getTaxAgent();
|
||||
|
|
@ -1013,12 +1012,12 @@ public class TaxDeclareRecordServiceImpl extends Service implements TaxDeclareRe
|
|||
@Override
|
||||
public XSSFWorkbook exportGetDeclareTaxResultFeedback(DeclareTaxResultFeedbackQueryParam param) {
|
||||
Long id = param.getId();
|
||||
TaxDeclareRecordPO taxDeclareRecord = getById(id);
|
||||
String requestId = param.getRequestId();
|
||||
TaxDeclareRequest taxDeclareRequest = buildTaxDeclareRequest(id);
|
||||
TaxDeclareRecordPO taxDeclareRecord = taxDeclareRequest.getTaxDeclareRecord();
|
||||
TaxDeclareStatusPO declareStatus = getTaxDeclareStatusService(user).getTaxDeclareStatus(id, param.getReportType());
|
||||
|
||||
DeclareClient declareClient = new DeclareClient(taxDeclareRecord.getTaxAgentId());
|
||||
GetDeclareTaxResultFeedbackResponse declareTaxResultFeedbackResponse = declareClient.getDeclareTaxResultFeedback(StringUtils.isEmpty(requestId) ? taxDeclareRecord.getDeclareRequestId() : requestId);
|
||||
GetDeclareTaxResultFeedbackResponse declareTaxResultFeedbackResponse = declareClient.getDeclareTaxResultFeedback(StringUtils.isEmpty(requestId) ? declareStatus.getDeclareRequestId() : requestId);
|
||||
|
||||
Map<String, List<List<Object>>> map = new HashMap<>();
|
||||
List<TaxDeclarationPO> list = getTaxDeclarationService(user).listByTaxDeclareRecordId(id);
|
||||
|
|
@ -1031,7 +1030,7 @@ public class TaxDeclareRecordServiceImpl extends Service implements TaxDeclareRe
|
|||
public void updateDeclare(Long id, Integer reportType) {
|
||||
TaxDeclareRequest taxDeclareRequest = buildTaxDeclareRequest(id);
|
||||
TaxDeclareRecordPO taxDeclareRecord = taxDeclareRequest.getTaxDeclareRecord();
|
||||
TaxDeclareStatusPO declareStatus = getTaxDeclareStatus(id, reportType);
|
||||
TaxDeclareStatusPO declareStatus = getTaxDeclareStatusService(user).getTaxDeclareStatus(id, reportType);
|
||||
|
||||
|
||||
List<Integer> taxDeclareStatusEnumValueList = Lists.newArrayList(TaxDeclareStatusEnum.DECLARE_SUCCESS_UNPAID.getValue(), TaxDeclareStatusEnum.DECLARE_SUCCESS_NO_PAY.getValue(), TaxDeclareStatusEnum.DECLARE_SUCCESS_PAID.getValue(), TaxDeclareStatusEnum.DECLARE_SUCCESS_PAYING.getValue());
|
||||
|
|
@ -1066,7 +1065,7 @@ public class TaxDeclareRecordServiceImpl extends Service implements TaxDeclareRe
|
|||
declareStatus.setTaxDeclareType(TaxDeclareTypeEnum.UPDATE_DECLARE.getValue());
|
||||
declareStatus.setTaxDeclareStatus(NOT_DECLARE.getValue());
|
||||
declareStatus.setRequestId("");
|
||||
updateTaxDeclareStatus(declareStatus);
|
||||
getTaxDeclareStatusService(user).updateTaxDeclareStatus(declareStatus);
|
||||
|
||||
// 记录日志
|
||||
TaxAgentPO taxAgent = taxDeclareRequest.getTaxAgent();
|
||||
|
|
@ -1082,16 +1081,6 @@ public class TaxDeclareRecordServiceImpl extends Service implements TaxDeclareRe
|
|||
SalaryElogConfig.taxDeclarationLoggerTemplate.write(loggerContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTaxDeclareStatus(TaxDeclareStatusPO declareStatus) {
|
||||
//更新申报表状态
|
||||
getTaxDeclareStatusMapper().updateIgnoreNull(declareStatus);
|
||||
|
||||
//更新主记录
|
||||
getOrInitTaxReports(declareStatus.getTaxDeclareRecordId());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void cancelCorrect(Long id) {
|
||||
TaxDeclareRequest taxDeclareRequest = buildTaxDeclareRequest(id);
|
||||
|
|
@ -1193,72 +1182,6 @@ public class TaxDeclareRecordServiceImpl extends Service implements TaxDeclareRe
|
|||
getTaxDeclareRecordMapper().updateIgnoreNull(taxDeclareRecord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TaxDeclareStatusPO> getOrInitTaxReports(Long id) {
|
||||
|
||||
// 查询个税申报记录
|
||||
TaxDeclareRecordPO taxDeclareRecord = getById(id);
|
||||
if (Objects.isNull(taxDeclareRecord)) {
|
||||
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(156495, "参数异常,个税申报记录不存在或已被删除"));
|
||||
}
|
||||
|
||||
// 查询个税申报表
|
||||
List<TaxDeclarationPO> taxDeclarations = getTaxDeclarationService(user).listByTaxCycleAndTaxAgentIds(SalaryDateUtil.localDate2YearMonth(taxDeclareRecord.getTaxCycle()), Collections.singleton(taxDeclareRecord.getTaxAgentId()));
|
||||
if (CollectionUtils.isEmpty(taxDeclarations)) {
|
||||
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(156494, "当前无可申报的数据"));
|
||||
}
|
||||
|
||||
Set<Integer> reportTypes = new HashSet<>();
|
||||
taxDeclarations.forEach(taxDeclarationPO -> {
|
||||
reportTypes.add(IncomeCategoryEnum.parseByValue(taxDeclarationPO.getIncomeCategory()).getReportType().getValue());
|
||||
});
|
||||
|
||||
List<TaxDeclareStatusPO> statuses = new ArrayList<>();
|
||||
|
||||
int personNum = 0;
|
||||
BigDecimal taxPayAmount = new BigDecimal(0);
|
||||
BigDecimal taxPaidAmount = new BigDecimal(0);
|
||||
BigDecimal taxPurePaidAmount = new BigDecimal(0);
|
||||
|
||||
for (Integer reportType : reportTypes) {
|
||||
TaxDeclareStatusPO declareStatus = getTaxDeclareStatus(id, reportType);
|
||||
if (declareStatus == null) {
|
||||
declareStatus = TaxDeclareStatusPO.builder()
|
||||
.id(IdGenerator.generate())
|
||||
.taxDeclareRecordId(id)
|
||||
.reportType(reportType)
|
||||
.taxDeclareType(taxDeclareRecord.getTaxDeclareType())
|
||||
.taxDeclareStatus(taxDeclareRecord.getTaxDeclareStatus())
|
||||
.taxDeclareErrorMsg(taxDeclareRecord.getTaxDeclareErrorMsg())
|
||||
.personNum(taxDeclareRecord.getPersonNum())
|
||||
.taxPayAmount(taxDeclareRecord.getTaxPayAmount())
|
||||
.taxPaidAmount(taxDeclareRecord.getTaxPaidAmount())
|
||||
.taxPurePaidAmount(taxDeclareRecord.getTaxPaidAmount())
|
||||
.deleteType(0)
|
||||
.build();
|
||||
getTaxDeclareStatusMapper().insertIgnoreNull(declareStatus);
|
||||
}
|
||||
statuses.add(declareStatus);
|
||||
|
||||
personNum += declareStatus.getPersonNum() == null ? 0 : declareStatus.getPersonNum();
|
||||
taxPayAmount = taxPayAmount.add(SalaryEntityUtil.empty2Zero(declareStatus.getTaxPayAmount()));
|
||||
taxPaidAmount = taxPaidAmount.add(SalaryEntityUtil.empty2Zero(declareStatus.getTaxPaidAmount()));
|
||||
taxPurePaidAmount = taxPurePaidAmount.add(SalaryEntityUtil.empty2Zero(declareStatus.getTaxPurePaidAmount()));
|
||||
}
|
||||
|
||||
//更新记录的状态,各个报表状态一致则采纳,否则取最小的进度状态
|
||||
Integer declareStatusEnum = statuses.stream().map(TaxDeclareStatusPO::getTaxDeclareStatus).min(Comparator.comparing(Integer::valueOf)).orElse(NOT_DECLARE.getValue());
|
||||
|
||||
taxDeclareRecord.setPersonNum(personNum);
|
||||
taxDeclareRecord.setTaxPayAmount(taxPayAmount.toString());
|
||||
taxDeclareRecord.setTaxPaidAmount(taxPaidAmount.toString());
|
||||
taxDeclareRecord.setTaxPurePaidAmount(taxPurePaidAmount.toString());
|
||||
taxDeclareRecord.setTaxDeclareStatus(declareStatusEnum);
|
||||
updateById(taxDeclareRecord);
|
||||
|
||||
return statuses;
|
||||
}
|
||||
|
||||
|
||||
private TaxDeclareRequest buildTaxDeclareRequest(Long id) {
|
||||
// 查询供应商信息
|
||||
|
|
|
|||
|
|
@ -0,0 +1,135 @@
|
|||
package com.engine.salary.service.impl;
|
||||
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.core.impl.Service;
|
||||
import com.engine.salary.entity.taxdeclaration.po.TaxDeclarationPO;
|
||||
import com.engine.salary.entity.taxdeclaration.po.TaxDeclareRecordPO;
|
||||
import com.engine.salary.entity.taxdeclaration.po.TaxDeclareStatusPO;
|
||||
import com.engine.salary.enums.salarysob.IncomeCategoryEnum;
|
||||
import com.engine.salary.exception.SalaryRunTimeException;
|
||||
import com.engine.salary.mapper.taxdeclaration.TaxDeclareRecordMapper;
|
||||
import com.engine.salary.mapper.taxdeclaration.TaxDeclareStatusMapper;
|
||||
import com.engine.salary.service.TaxDeclarationService;
|
||||
import com.engine.salary.service.TaxDeclareStatusService;
|
||||
import com.engine.salary.util.SalaryDateUtil;
|
||||
import com.engine.salary.util.SalaryEntityUtil;
|
||||
import com.engine.salary.util.SalaryI18nUtil;
|
||||
import com.engine.salary.util.db.IdGenerator;
|
||||
import com.engine.salary.util.db.MapperProxyFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import weaver.hrm.User;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
|
||||
import static com.engine.salary.enums.taxdeclaration.TaxDeclareStatusEnum.NOT_DECLARE;
|
||||
|
||||
/**
|
||||
* 个税申报
|
||||
* <p>Copyright: Copyright (c) 2022</p>
|
||||
* <p>Company: 泛微软件</p>
|
||||
*
|
||||
* @author qiantao
|
||||
* @version 1.0
|
||||
**/
|
||||
@Slf4j
|
||||
public class TaxDeclareStatusServiceImpl extends Service implements TaxDeclareStatusService {
|
||||
|
||||
|
||||
private TaxDeclareRecordMapper getTaxDeclareRecordMapper() {
|
||||
return MapperProxyFactory.getProxy(TaxDeclareRecordMapper.class);
|
||||
}
|
||||
|
||||
private TaxDeclareStatusMapper getTaxDeclareStatusMapper() {
|
||||
return MapperProxyFactory.getProxy(TaxDeclareStatusMapper.class);
|
||||
}
|
||||
|
||||
private TaxDeclarationService getTaxDeclarationService(User user) {
|
||||
return ServiceUtil.getService(TaxDeclarationServiceImpl.class, user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TaxDeclareStatusPO getTaxDeclareStatus(Long taxDeclareRecordId, Integer reportType) {
|
||||
return getTaxDeclareStatusMapper().getDeclareStatus(taxDeclareRecordId, reportType);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void updateTaxDeclareStatus(TaxDeclareStatusPO declareStatus) {
|
||||
//更新申报表状态
|
||||
getTaxDeclareStatusMapper().updateIgnoreNull(declareStatus);
|
||||
|
||||
//更新主记录
|
||||
getOrInitTaxReports(declareStatus.getTaxDeclareRecordId());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<TaxDeclareStatusPO> getOrInitTaxReports(Long id) {
|
||||
|
||||
// 查询个税申报记录
|
||||
TaxDeclareRecordPO taxDeclareRecord = getTaxDeclareRecordMapper().getById(id);
|
||||
if (Objects.isNull(taxDeclareRecord)) {
|
||||
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(156495, "参数异常,个税申报记录不存在或已被删除"));
|
||||
}
|
||||
|
||||
// 查询个税申报表
|
||||
List<TaxDeclarationPO> taxDeclarations = getTaxDeclarationService(user).listByTaxCycleAndTaxAgentIds(SalaryDateUtil.localDate2YearMonth(taxDeclareRecord.getTaxCycle()), Collections.singleton(taxDeclareRecord.getTaxAgentId()));
|
||||
if (CollectionUtils.isEmpty(taxDeclarations)) {
|
||||
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(156494, "当前无可申报的数据"));
|
||||
}
|
||||
|
||||
Set<Integer> reportTypes = new HashSet<>();
|
||||
taxDeclarations.forEach(taxDeclarationPO -> {
|
||||
reportTypes.add(IncomeCategoryEnum.parseByValue(taxDeclarationPO.getIncomeCategory()).getReportType().getValue());
|
||||
});
|
||||
|
||||
List<TaxDeclareStatusPO> statuses = new ArrayList<>();
|
||||
|
||||
int personNum = 0;
|
||||
BigDecimal taxPayAmount = new BigDecimal(0);
|
||||
BigDecimal taxPaidAmount = new BigDecimal(0);
|
||||
BigDecimal taxPurePaidAmount = new BigDecimal(0);
|
||||
|
||||
for (Integer reportType : reportTypes) {
|
||||
TaxDeclareStatusPO declareStatus = getTaxDeclareStatus(id, reportType);
|
||||
if (declareStatus == null) {
|
||||
declareStatus = TaxDeclareStatusPO.builder()
|
||||
.id(IdGenerator.generate())
|
||||
.taxDeclareRecordId(id)
|
||||
.reportType(reportType)
|
||||
.taxDeclareType(taxDeclareRecord.getTaxDeclareType())
|
||||
.taxDeclareStatus(taxDeclareRecord.getTaxDeclareStatus())
|
||||
.taxDeclareErrorMsg(taxDeclareRecord.getTaxDeclareErrorMsg())
|
||||
.personNum(taxDeclareRecord.getPersonNum())
|
||||
.taxPayAmount(taxDeclareRecord.getTaxPayAmount())
|
||||
.taxPaidAmount(taxDeclareRecord.getTaxPaidAmount())
|
||||
.taxPurePaidAmount(taxDeclareRecord.getTaxPaidAmount())
|
||||
.deleteType(0)
|
||||
.build();
|
||||
getTaxDeclareStatusMapper().insertIgnoreNull(declareStatus);
|
||||
}
|
||||
statuses.add(declareStatus);
|
||||
|
||||
personNum += declareStatus.getPersonNum() == null ? 0 : declareStatus.getPersonNum();
|
||||
taxPayAmount = taxPayAmount.add(SalaryEntityUtil.empty2Zero(declareStatus.getTaxPayAmount()));
|
||||
taxPaidAmount = taxPaidAmount.add(SalaryEntityUtil.empty2Zero(declareStatus.getTaxPaidAmount()));
|
||||
taxPurePaidAmount = taxPurePaidAmount.add(SalaryEntityUtil.empty2Zero(declareStatus.getTaxPurePaidAmount()));
|
||||
}
|
||||
|
||||
//更新记录的状态,各个报表状态一致则采纳,否则取最小的进度状态
|
||||
Integer declareStatusEnum = statuses.stream().map(TaxDeclareStatusPO::getTaxDeclareStatus).min(Comparator.comparing(Integer::valueOf)).orElse(NOT_DECLARE.getValue());
|
||||
|
||||
taxDeclareRecord.setPersonNum(personNum);
|
||||
taxDeclareRecord.setTaxPayAmount(taxPayAmount.toString());
|
||||
taxDeclareRecord.setTaxPaidAmount(taxPaidAmount.toString());
|
||||
taxDeclareRecord.setTaxPurePaidAmount(taxPurePaidAmount.toString());
|
||||
taxDeclareRecord.setTaxDeclareStatus(declareStatusEnum);
|
||||
getTaxDeclareRecordMapper().updateIgnoreNull(taxDeclareRecord);
|
||||
|
||||
return statuses;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -98,7 +98,7 @@ public class TaxPaymentWithholdingServiceImpl extends AbstractTaxPaymentService
|
|||
status.setTaxPaidAmount(totalPaid.toString());
|
||||
status.setTaxPurePaidAmount(taxPurePaidAmount.add(taxPayAmount).toString());
|
||||
status.setTaxPayAmount(BigDecimal.ZERO.toString());
|
||||
getTaxDeclareRecordService(user).updateTaxDeclareStatus(status);
|
||||
getTaxDeclareStatusService(user).updateTaxDeclareStatus(status);
|
||||
});
|
||||
|
||||
TaxAmountFormDTO taxAmountFormDTO = queryTaxAmount(param);
|
||||
|
|
|
|||
|
|
@ -64,6 +64,10 @@ public class TaxDeclareRecordWrapper extends Service {
|
|||
return ServiceUtil.getService(TaxDeclareRecordServiceImpl.class, user);
|
||||
}
|
||||
|
||||
private TaxDeclareStatusService getTaxDeclareStatusService(User user) {
|
||||
return ServiceUtil.getService(TaxDeclareStatusServiceImpl.class, user);
|
||||
}
|
||||
|
||||
private TaxAgentService getTaxAgentService(User user) {
|
||||
return ServiceUtil.getService(TaxAgentServiceImpl.class, user);
|
||||
}
|
||||
|
|
@ -361,7 +365,7 @@ public class TaxDeclareRecordWrapper extends Service {
|
|||
// 查询个税扣缴义务人
|
||||
TaxAgentPO taxAgentPO = getTaxAgentService(user).getById(taxDeclareRecord.getTaxAgentId());
|
||||
|
||||
TaxDeclareStatusPO taxDeclareStatus = getTaxDeclareRecordService(user).getTaxDeclareStatus(taxDeclareRecordId, param.getReportType());
|
||||
TaxDeclareStatusPO taxDeclareStatus = getTaxDeclareStatusService(user).getTaxDeclareStatus(taxDeclareRecordId, param.getReportType());
|
||||
TaxDeclareTypeEnum taxDeclareTypeEnum = SalaryEnumUtil.enumMatchByValue(taxDeclareStatus.getTaxDeclareType(), TaxDeclareTypeEnum.class);
|
||||
TaxDeclareStatusEnum taxDeclareStatusEnum = SalaryEnumUtil.enumMatchByValue(taxDeclareStatus.getTaxDeclareStatus(), TaxDeclareStatusEnum.class);
|
||||
|
||||
|
|
@ -888,6 +892,6 @@ public class TaxDeclareRecordWrapper extends Service {
|
|||
}
|
||||
|
||||
public List<TaxDeclareStatusPO> getTaxReports(Long id) {
|
||||
return getTaxDeclareRecordService(user).getOrInitTaxReports(id);
|
||||
return getTaxDeclareStatusService(user).getOrInitTaxReports(id);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue