扣除确认接口

This commit is contained in:
钱涛 2025-03-12 13:55:59 +08:00
parent 12bbfeceae
commit a119e7c7cd
10 changed files with 320 additions and 36 deletions

View File

@ -0,0 +1,123 @@
package com.engine.salary.entity.deductionamount.dto;
import com.engine.salary.annotation.TableTitle;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Collection;
import java.util.Date;
/**
* 人员报送记录
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
//hrsa_deduction_amount
public class DeductionAmountDTO {
/**
* ID
*/
private Long id;
/**
* 个税扣缴义务人ID
*/
private Long taxAgentId;
/**
* 税款所属年度
*/
@TableTitle(title = "税款所属年度", dataIndex = "year", key = "year")
private String year;
/**
* 人员id
*/
private Long employeeId;
/**
* 姓名
*/
@TableTitle(title = "姓名", dataIndex = "employeeName", key = "employeeName")
private String employeeName;
/**
* 人员类型
*/
private Integer employeeType;
/**
* 工号
*/
@TableTitle(title = "工号", dataIndex = "jobNum", key = "jobNum")
private String jobNum;
/**
* 证件号码
*/
@TableTitle(title = "证件号码", dataIndex = "cardNum", key = "cardNum")
private String cardNum;
/**
* 证件类型
*/
private Integer cardType;
/**
* 国籍
*/
@TableTitle(title = "国籍", dataIndex = "nationality", key = "nationality")
private String nationality;
/**
* 是否扣除
*/
@TableTitle(title = "是否扣除", dataIndex = "deductFlag", key = "deductFlag")
private Integer deductFlag;
/**
* 报送状态
*/
@TableTitle(title = "报送状态", dataIndex = "declareStatus", key = "declareStatus")
private Integer declareStatus;
/**
* 是否成功报送过
*/
private Integer successfullyDeclared;
/**
* 创建时间
*/
private Date createTime;
/**
* 修改时间
*/
private Date updateTime;
/**
* 创建人id
*/
private Long creator;
/**
* 是否删除
*/
private Integer deleteType;
/**
* 租户KEY
*/
private String tenantKey;
//主键id集合
private Collection<Long> ids;
}

View File

@ -0,0 +1,36 @@
package com.engine.salary.entity.deductionamount.param;
import com.engine.salary.common.BaseQueryParam;
import com.engine.salary.util.valid.DataCheck;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* 扣除名单查询参数
* <p>Copyright: Copyright (c) 2023</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class DeductionAmountListParam extends BaseQueryParam {
/**
* 个税扣缴义务人id
*/
@DataCheck(require = true, message = "参数错误个税扣缴义务人id不能为空")
private Long taxAgentId;
/**
* 税款所属年度
*/
@DataCheck(require = true, message = "参数错误,税款所属年度参数格式错误")
private String year;
}

View File

@ -61,6 +61,12 @@ public class DeductionAmountPO {
@ElogTransform(name = "工号")
private String jobNum;
/**
* 国籍
*/
@ElogTransform(name = "国籍")
private String nationality;
/**
* 证件号码
*/

View File

@ -19,6 +19,7 @@
<result column="tenant_key" property="tenantKey"/>
<result column="update_time" property="updateTime"/>
<result column="year" property="year"/>
<result column="nationality" property="nationality"/>
</resultMap>
<!-- 表字段 -->
@ -42,6 +43,7 @@
, t.tenant_key
, t.update_time
, t.year
, t.nationality
</sql>
<!-- 查询全部 -->
@ -118,6 +120,9 @@
<if test="year != null">
AND year = #{year}
</if>
<if test="nationality != null">
AND nationality = #{nationality}
</if>
<if test="ids != null and ids.size()>0">
AND id IN
<foreach collection="ids" open="(" item="id" separator="," close=")">
@ -184,6 +189,9 @@
<if test="year != null">
year,
</if>
<if test="nationality != null">
nationality,
</if>
</trim>
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
<if test="cardNum != null">
@ -237,6 +245,9 @@
<if test="year != null">
#{year},
</if>
<if test="nationality != null">
#{nationality},
</if>
</trim>
</insert>
@ -261,6 +272,7 @@
tenant_key=#{tenantKey},
update_time=#{updateTime},
year=#{year},
nationality=#{nationality},
</set>
WHERE id = #{id} AND delete_type = 0
</update>
@ -318,6 +330,9 @@
<if test="year != null">
year=#{year},
</if>
<if test="nationality != null">
nationality=#{nationality},
</if>
</set>
WHERE id = #{id} AND delete_type = 0
</update>

View File

@ -10,6 +10,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
@ -60,7 +61,7 @@ public class DeductionAmountClient extends TaxBaseClient {
public String confirmPreDeduct(String year) {
public String confirmPreDeduct(String year, List<ConfirmPreDeductRequest.kczg> kczglb ) {
String url = super.apiConfig.getHost() + "gateway/iit/deductionAmount/queryPreDeduct";
ConfirmPreDeductRequest request = new ConfirmPreDeductRequest();
@ -78,16 +79,16 @@ public class DeductionAmountClient extends TaxBaseClient {
request.setJmsmmm("1");
request.setMmlx("" + returnPO.getPasswordType());
request.setSkssnd(year);
request.setKczglb(null);
request.setKczglb(kczglb);
String reqJson = JsonUtil.toJsonString(request);
log.info("queryDeductionAmountRequest params --- \n{}\n", reqJson);
log.info("confirmPreDeduct params --- \n{}\n", reqJson);
Map<String, String> params = new HashMap<>(1);
Map<String, String> header = SingnatureData.initHeader(params, apiConfig.getAppKey(), apiConfig.getAppSecret());
// 开始请求
String res = HttpUtil.doPost(url, header, reqJson, HttpUtil.JSON_TYPE);
log.info("queryDeductionAmountRequest res --- {}", res);
log.info("confirmPreDeduct res --- {}", res);
return res;
}
}

View File

@ -69,6 +69,7 @@ public class ConfirmPreDeductRequest {
private List<kczg> kczglb;
@Data
public static class kczg {
/**
* 姓名

View File

@ -1,6 +1,10 @@
package com.engine.salary.service;
import com.engine.salary.component.PageInfo;
import com.engine.salary.entity.deductionamount.dto.DeductionAmountDTO;
import com.engine.salary.entity.deductionamount.param.DeductionAmountAddParam;
import com.engine.salary.entity.deductionamount.param.DeductionAmountConfirmParam;
import com.engine.salary.entity.deductionamount.param.DeductionAmountListParam;
import com.engine.salary.entity.deductionamount.param.DeductionAmountOnlineQueryParam;
/**
@ -13,7 +17,13 @@ import com.engine.salary.entity.deductionamount.param.DeductionAmountOnlineQuery
**/
public interface DeductionAmountService {
Object query(DeductionAmountOnlineQueryParam queryParam);
PageInfo<DeductionAmountDTO> list(DeductionAmountListParam param);
void add(DeductionAmountAddParam param);
Object query(DeductionAmountOnlineQueryParam param);
Object confirm(DeductionAmountConfirmParam param);
}

View File

@ -3,17 +3,25 @@ package com.engine.salary.service.impl;
import com.engine.common.util.ServiceUtil;
import com.engine.core.impl.Service;
import com.engine.salary.component.PageInfo;
import com.engine.salary.constant.SalaryDefaultTenantConstant;
import com.engine.salary.entity.deductionamount.dto.DeductionAmountDTO;
import com.engine.salary.entity.deductionamount.param.DeductionAmountAddParam;
import com.engine.salary.entity.deductionamount.param.DeductionAmountConfirmParam;
import com.engine.salary.entity.deductionamount.param.DeductionAmountListParam;
import com.engine.salary.entity.deductionamount.param.DeductionAmountOnlineQueryParam;
import com.engine.salary.entity.deductionamount.po.DeductionAmountPO;
import com.engine.salary.entity.employeedeclare.po.EmployeeDeclarePO;
import com.engine.salary.enums.SalaryOnOffEnum;
import com.engine.salary.enums.employeedeclare.CardTypeEnum;
import com.engine.salary.mapper.deductionamount.DeductionAmountMapper;
import com.engine.salary.mapper.employeedeclare.EmployeeDeclareMapper;
import com.engine.salary.remote.tax.client.DeductionAmountClient;
import com.engine.salary.remote.tax.request.deductionAmount.ConfirmPreDeductRequest;
import com.engine.salary.service.*;
import com.engine.salary.util.SalaryEntityUtil;
import com.engine.salary.util.db.MapperProxyFactory;
import com.engine.salary.util.page.SalaryPageUtil;
import com.engine.salary.util.valid.ValidUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.math.NumberUtils;
@ -70,11 +78,35 @@ public class DeductionAmountServiceImpl extends Service implements DeductionAmou
return ServiceUtil.getService(TaxDeclarationApiBillingServiceImpl.class, user);
}
@Override
public Object query(DeductionAmountOnlineQueryParam queryParam) {
Long taxAgentId = queryParam.getTaxAgentId();
DeductionAmountClient deductionAmountClient = new DeductionAmountClient(taxAgentId);
return deductionAmountClient.query(queryParam.getYear());
public PageInfo<DeductionAmountDTO> list(DeductionAmountListParam param) {
ValidUtil.doValidator(param);
List<DeductionAmountPO> deductionAmountPOS = getDeductionAmountMapper().listSome(DeductionAmountPO.builder().year(param.getYear()).taxAgentId(param.getTaxAgentId()).build());
List<DeductionAmountDTO> list = deductionAmountPOS.stream().map(deductionAmountPO -> {
return DeductionAmountDTO.builder()
.id(deductionAmountPO.getId())
.taxAgentId(deductionAmountPO.getEmployeeId())
.year(deductionAmountPO.getYear())
.employeeId(deductionAmountPO.getEmployeeId())
.employeeName(deductionAmountPO.getEmployeeName())
.employeeType(deductionAmountPO.getEmployeeType())
.jobNum(deductionAmountPO.getJobNum())
.nationality(deductionAmountPO.getNationality())
.cardNum(deductionAmountPO.getCardNum())
.cardType(deductionAmountPO.getCardType())
.declareStatus(deductionAmountPO.getDeclareStatus())
.deductFlag(deductionAmountPO.getDeductFlag())
.successfullyDeclared(deductionAmountPO.getSuccessfullyDeclared())
.creator(deductionAmountPO.getCreator())
.createTime(deductionAmountPO.getCreateTime())
.updateTime(deductionAmountPO.getUpdateTime())
.build();
}).collect(Collectors.toList());
return SalaryPageUtil.buildPage(param.getCurrent(), param.getPageSize(), list, DeductionAmountDTO.class);
}
@Override
@ -92,25 +124,54 @@ public class DeductionAmountServiceImpl extends Service implements DeductionAmou
Date now = new Date();
employeeDeclarePOS.stream()
.filter(employeeDeclarePO -> !oldIds.contains(employeeDeclarePO.getEmployeeId()))
.map(employeeDeclarePO -> {
DeductionAmountPO.builder()
.id(employeeDeclarePO.getEmployeeId())
.taxAgentId(employeeDeclarePO.getEmployeeId())
.year(param.getYear())
.employeeId(employeeDeclarePO.getEmployeeId())
.employeeName(employeeDeclarePO.getEmployeeName())
.employeeType(employeeDeclarePO.getEmployeeType())
.jobNum(employeeDeclarePO.getJobNum())
.cardNum(employeeDeclarePO.getCardNum())
.cardType(employeeDeclarePO.getCardType())
.declareStatus(0)
.deductFlag(1)
.successfullyDeclared(0)
.creator((long)user.getUID())
.createTime(now)
.updateTime(now)
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
.deleteType(NumberUtils.INTEGER_ZERO);
});
.map(employeeDeclarePO -> DeductionAmountPO.builder()
.id(employeeDeclarePO.getEmployeeId())
.taxAgentId(employeeDeclarePO.getEmployeeId())
.year(param.getYear())
.employeeId(employeeDeclarePO.getEmployeeId())
.employeeName(employeeDeclarePO.getEmployeeName())
.employeeType(employeeDeclarePO.getEmployeeType())
.jobNum(employeeDeclarePO.getJobNum())
.cardNum(employeeDeclarePO.getCardNum())
.cardType(employeeDeclarePO.getCardType())
.nationality(employeeDeclarePO.getNationality())
.declareStatus(0)
.deductFlag(1)
.successfullyDeclared(0)
.creator((long) user.getUID())
.createTime(now)
.updateTime(now)
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
.deleteType(NumberUtils.INTEGER_ZERO)
.build())
.forEach(deductionAmountPO -> getDeductionAmountMapper().insertIgnoreNull(deductionAmountPO));
}
@Override
public Object query(DeductionAmountOnlineQueryParam param) {
Long taxAgentId = param.getTaxAgentId();
DeductionAmountClient deductionAmountClient = new DeductionAmountClient(taxAgentId);
return deductionAmountClient.query(param.getYear());
}
@Override
public Object confirm(DeductionAmountConfirmParam param) {
ValidUtil.doValidator(param);
Long taxAgentId = param.getTaxAgentId();
String year = param.getYear();
List<DeductionAmountPO> deductionAmountPOS = getDeductionAmountMapper().listSome(DeductionAmountPO.builder().taxAgentId(taxAgentId).year(year).build());
List<ConfirmPreDeductRequest.kczg> kczglb = deductionAmountPOS.stream()
.map(deductionAmountPO -> {
ConfirmPreDeductRequest.kczg kczg = new ConfirmPreDeductRequest.kczg();
kczg.setXm(deductionAmountPO.getEmployeeName());
kczg.setZzhm(deductionAmountPO.getCardNum());
kczg.setZzlx(CardTypeEnum.getByValue(deductionAmountPO.getCardType()).getDefaultLabel());
kczg.setGj(deductionAmountPO.getNationality());
kczg.setKcbs(SalaryOnOffEnum.parseByValue(deductionAmountPO.getDeductFlag()).getDefaultLabel());
return kczg;
}).collect(Collectors.toList());
DeductionAmountClient deductionAmountClient = new DeductionAmountClient(taxAgentId);
return deductionAmountClient.confirmPreDeduct(year, kczglb);
}
}

View File

@ -2,7 +2,11 @@ package com.engine.salary.web;
import com.engine.common.util.ServiceUtil;
import com.engine.salary.component.PageInfo;
import com.engine.salary.entity.deductionamount.dto.DeductionAmountDTO;
import com.engine.salary.entity.deductionamount.param.DeductionAmountAddParam;
import com.engine.salary.entity.deductionamount.param.DeductionAmountConfirmParam;
import com.engine.salary.entity.deductionamount.param.DeductionAmountListParam;
import com.engine.salary.entity.deductionamount.param.DeductionAmountOnlineQueryParam;
import com.engine.salary.util.ResponseResult;
import com.engine.salary.wrapper.DeductionAmountWrapper;
@ -34,6 +38,14 @@ public class DeductionAmountController {
return ServiceUtil.getService(DeductionAmountWrapper.class, user);
}
@POST
@Path("/list")
@Produces(MediaType.APPLICATION_JSON)
public String list(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody DeductionAmountListParam param) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<DeductionAmountListParam, PageInfo<DeductionAmountDTO>>(user).run(getDeductionAmountWrapper(user)::list, param);
}
@POST
@Path("/add")
@Produces(MediaType.APPLICATION_JSON)
@ -45,9 +57,17 @@ public class DeductionAmountController {
@POST
@Path("/query")
@Produces(MediaType.APPLICATION_JSON)
public String queryPreDeduct(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody DeductionAmountOnlineQueryParam queryParam) {
public String query(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody DeductionAmountOnlineQueryParam param) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<DeductionAmountOnlineQueryParam, Object>(user).run(getDeductionAmountWrapper(user)::query, queryParam);
return new ResponseResult<DeductionAmountOnlineQueryParam, Object>(user).run(getDeductionAmountWrapper(user)::query, param);
}
@POST
@Path("/confirm")
@Produces(MediaType.APPLICATION_JSON)
public String confirm(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody DeductionAmountConfirmParam param) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<DeductionAmountConfirmParam, Object>(user).run(getDeductionAmountWrapper(user)::confirm, param);
}
// @POST

View File

@ -2,10 +2,14 @@ package com.engine.salary.wrapper;
import com.engine.common.util.ServiceUtil;
import com.engine.core.impl.Service;
import com.engine.salary.component.PageInfo;
import com.engine.salary.entity.deductionamount.dto.DeductionAmountDTO;
import com.engine.salary.entity.deductionamount.param.DeductionAmountAddParam;
import com.engine.salary.entity.deductionamount.param.DeductionAmountConfirmParam;
import com.engine.salary.entity.deductionamount.param.DeductionAmountListParam;
import com.engine.salary.entity.deductionamount.param.DeductionAmountOnlineQueryParam;
import com.engine.salary.service.*;
import com.engine.salary.service.impl.*;
import com.engine.salary.service.DeductionAmountService;
import com.engine.salary.service.impl.DeductionAmountServiceImpl;
import lombok.extern.slf4j.Slf4j;
import weaver.hrm.User;
@ -23,12 +27,19 @@ public class DeductionAmountWrapper extends Service {
return ServiceUtil.getService(DeductionAmountServiceImpl.class, user);
}
public Object query(DeductionAmountOnlineQueryParam queryParam) {
return getDeductionAmountService(user).query(queryParam);
public PageInfo<DeductionAmountDTO> list(DeductionAmountListParam param) {
return getDeductionAmountService(user).list(param);
}
public void add(DeductionAmountAddParam param) {
getDeductionAmountService(user).add(param);
}
public Object query(DeductionAmountOnlineQueryParam param) {
return getDeductionAmountService(user).query(param);
}
public Object confirm(DeductionAmountConfirmParam param) {
return getDeductionAmountService(user).confirm(param);
}
}