2022-03-01 18:49:22 +08:00
|
|
|
package com.engine.salary.service.impl;
|
|
|
|
|
|
2022-05-09 11:46:49 +08:00
|
|
|
import com.engine.common.util.ServiceUtil;
|
2022-03-01 18:49:22 +08:00
|
|
|
import com.engine.core.impl.Service;
|
2022-04-16 15:33:51 +08:00
|
|
|
import com.engine.salary.cmd.taxDeclaration.*;
|
|
|
|
|
import com.engine.salary.common.LocalDateRange;
|
|
|
|
|
import com.engine.salary.entity.taxdeclaration.TaxDeclaration;
|
|
|
|
|
import com.engine.salary.entity.taxdeclaration.param.TaxDeclarationListQueryParam;
|
|
|
|
|
import com.engine.salary.entity.taxdeclaration.param.TaxDeclarationSaveParam;
|
|
|
|
|
import com.engine.salary.entity.taxdeclaration.po.TaxDeclarationPO;
|
|
|
|
|
import com.engine.salary.entity.taxrate.TaxAgent;
|
|
|
|
|
import com.engine.salary.entity.taxrate.param.TaxAgentQueryParam;
|
2022-05-09 11:46:49 +08:00
|
|
|
import com.engine.salary.exception.SalaryRunTimeException;
|
2022-04-16 15:33:51 +08:00
|
|
|
import com.engine.salary.mapper.TaxAgentMapper;
|
|
|
|
|
import com.engine.salary.mapper.taxdeclaration.TaxDeclarationMapper;
|
2022-05-09 11:46:49 +08:00
|
|
|
import com.engine.salary.service.AddUpSituationService;
|
|
|
|
|
import com.engine.salary.service.TaxDeclarationDetailService;
|
2022-03-01 18:49:22 +08:00
|
|
|
import com.engine.salary.service.TaxDeclarationService;
|
2022-04-16 15:33:51 +08:00
|
|
|
import com.engine.salary.util.SalaryDateUtil;
|
2022-05-09 11:46:49 +08:00
|
|
|
import com.engine.salary.util.SalaryEntityUtil;
|
|
|
|
|
import com.engine.salary.util.SalaryI18nUtil;
|
2022-04-16 15:33:51 +08:00
|
|
|
import com.engine.salary.util.db.MapperProxyFactory;
|
|
|
|
|
import com.engine.salary.util.page.PageInfo;
|
|
|
|
|
import com.engine.salary.util.page.PageUtil;
|
|
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
|
|
import org.apache.ibatis.session.SqlSession;
|
|
|
|
|
import weaver.conn.mybatis.MyBatisFactory;
|
2022-05-09 11:46:49 +08:00
|
|
|
import weaver.hrm.User;
|
2022-03-01 18:49:22 +08:00
|
|
|
|
2022-05-09 11:46:49 +08:00
|
|
|
import java.time.YearMonth;
|
2022-04-16 15:33:51 +08:00
|
|
|
import java.util.*;
|
2022-03-01 18:49:22 +08:00
|
|
|
|
|
|
|
|
public class TaxDeclarationServiceImpl extends Service implements TaxDeclarationService {
|
|
|
|
|
|
2022-04-16 15:33:51 +08:00
|
|
|
private TaxDeclarationMapper getTaxDeclarationMapper() {
|
|
|
|
|
return MapperProxyFactory.getProxy(TaxDeclarationMapper.class);
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-09 11:46:49 +08:00
|
|
|
private TaxDeclarationDetailService getTaxDeclarationDetailService(User user) {
|
|
|
|
|
return (TaxDeclarationDetailService) ServiceUtil.getService(TaxDeclarationDetailServiceImpl.class, user);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private AddUpSituationService getAddUpSituationService(User user) {
|
|
|
|
|
return (AddUpSituationService) ServiceUtil.getService(AddUpSituationServiceImpl.class, user);
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-01 18:49:22 +08:00
|
|
|
@Override
|
|
|
|
|
public Map<String, Object> listPage(Map<String, Object> params) {
|
2022-03-02 09:54:55 +08:00
|
|
|
return commandExecutor.execute(new TaxDeclarationListCmd(params, user));
|
2022-03-01 18:49:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2022-04-16 15:33:51 +08:00
|
|
|
public PageInfo<TaxDeclarationPO> listPageByParam(TaxDeclarationListQueryParam queryParam) {
|
|
|
|
|
// 分页参数
|
|
|
|
|
TaxDeclarationPO po = TaxDeclarationPO.builder().build();
|
|
|
|
|
PageInfo<TaxDeclarationPO> page = new PageInfo<>();
|
|
|
|
|
LocalDateRange localDateRange = new LocalDateRange();
|
|
|
|
|
if (Objects.nonNull(queryParam.getFromSalaryMonth())) {
|
|
|
|
|
localDateRange.setFromDate(SalaryDateUtil.localDateToDate(queryParam.getFromSalaryMonth().atDay(1)));
|
|
|
|
|
}
|
|
|
|
|
if (Objects.nonNull(queryParam.getEndSalaryMonth())) {
|
|
|
|
|
localDateRange.setEndDate(SalaryDateUtil.localDateToDate(queryParam.getEndSalaryMonth().atEndOfMonth()));
|
|
|
|
|
}
|
|
|
|
|
po.setSalaryMonths(localDateRange);
|
|
|
|
|
// 查询个税申报表
|
|
|
|
|
PageUtil.start(queryParam.getCurrent(), queryParam.getPageSize());
|
|
|
|
|
List<TaxDeclarationPO> taxDeclarationPOS = getTaxDeclarationMapper().listSome(po);
|
|
|
|
|
page.setList(taxDeclarationPOS);
|
|
|
|
|
|
|
|
|
|
return page;
|
|
|
|
|
}
|
2022-05-09 11:46:49 +08:00
|
|
|
|
2022-04-16 15:33:51 +08:00
|
|
|
//根据id查询taxAgents
|
|
|
|
|
@Override
|
|
|
|
|
public List<TaxAgent> countByTaxDeclarationId(Collection<Long> taxAgentIds) {
|
|
|
|
|
if (CollectionUtils.isEmpty(taxAgentIds)) {
|
|
|
|
|
return Collections.emptyList();
|
|
|
|
|
}
|
|
|
|
|
SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
|
|
|
|
|
try {
|
|
|
|
|
TaxAgentMapper taxAgentMapper = sqlSession.getMapper(TaxAgentMapper.class);
|
|
|
|
|
return taxAgentMapper.listBySome(TaxAgentQueryParam.builder().ids(taxAgentIds).build());
|
|
|
|
|
} finally {
|
|
|
|
|
sqlSession.close();
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-05-09 11:46:49 +08:00
|
|
|
|
2022-04-16 15:33:51 +08:00
|
|
|
//根据id获取TaxDeclaration
|
|
|
|
|
@Override
|
|
|
|
|
public TaxDeclaration getById(Long id) {
|
|
|
|
|
return getTaxDeclarationMapper().getById(id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Map<String, Object> getForm(Map<String, Object> params) {
|
|
|
|
|
return commandExecutor.execute(new TaxDeclarationGetFormCmd(params, user));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Map<String, Object> getTaxDeclarationInfo(Map<String, Object> params) {
|
|
|
|
|
return commandExecutor.execute(new TaxDeclarationGetTaxDeclarationInfoCmd(params, user));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void save(TaxDeclarationSaveParam saveParam) {
|
|
|
|
|
//return commandExecutor.execute(new TaxDeclarationSaveCmd(saveParam));
|
|
|
|
|
return;
|
2022-03-01 18:49:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Map<String, Object> update(Map<String, Object> params) {
|
2022-03-02 09:54:55 +08:00
|
|
|
return commandExecutor.execute(new TaxDeclarationUpdateCmd(params, user));
|
|
|
|
|
}
|
2022-05-09 11:46:49 +08:00
|
|
|
|
2022-03-02 09:54:55 +08:00
|
|
|
@Override
|
|
|
|
|
public Map<String, Object> delete(Map<String, Object> params) {
|
|
|
|
|
return commandExecutor.execute(new TaxDeclarationDeleteCmd(params, user));
|
2022-03-01 18:49:22 +08:00
|
|
|
}
|
2022-05-09 11:46:49 +08:00
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void deleteBySalaryMonth(YearMonth salaryMonth) {
|
|
|
|
|
// 薪资所属月的日期范围
|
|
|
|
|
LocalDateRange salaryMonthDateRange = SalaryDateUtil.localDate2Range(SalaryDateUtil.localDateToDate(salaryMonth.atDay(1)));
|
|
|
|
|
if (Objects.isNull(salaryMonthDateRange)) {
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "参数错误"));
|
|
|
|
|
}
|
|
|
|
|
List<TaxDeclarationPO> taxDeclarationPOS = listBySalaryMonth(salaryMonthDateRange);
|
|
|
|
|
if (CollectionUtils.isEmpty(taxDeclarationPOS)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// 删除个税申报表
|
|
|
|
|
Set<Long> taxDeclarationIds = SalaryEntityUtil.properties(taxDeclarationPOS, TaxDeclarationPO::getId);
|
|
|
|
|
getTaxDeclarationMapper().deleteByIds(taxDeclarationIds);
|
|
|
|
|
// 删除个税申报表详情
|
|
|
|
|
getTaxDeclarationDetailService(user).deleteByTaxDeclarationIds(taxDeclarationIds);
|
|
|
|
|
// 删除往期累计情况
|
|
|
|
|
getAddUpSituationService(user).deleteAddUpSituationList(salaryMonth, Collections.emptyList());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<TaxDeclarationPO> listBySalaryMonth(LocalDateRange salaryMonthDateRange) {
|
|
|
|
|
|
|
|
|
|
return getTaxDeclarationMapper().listSome(TaxDeclarationPO.builder().salaryMonths(salaryMonthDateRange).build());
|
|
|
|
|
}
|
2022-03-01 18:49:22 +08:00
|
|
|
}
|