parent
420d0a1fff
commit
0c22a57f19
|
|
@ -2,6 +2,7 @@ package com.engine.salary.remote.tax.client;
|
|||
|
||||
import com.engine.salary.constant.SzyhApiConstant;
|
||||
import com.engine.salary.entity.datacollection.response.QuerySpecialAmountResponse;
|
||||
import com.engine.salary.entity.taxpayment.response.SyncWithholdingFeedbackResponse;
|
||||
import com.engine.salary.entity.taxpayment.response.WithheldVoucherResponse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
|
|
@ -25,9 +26,26 @@ public class TaxPaymentClient extends TaxBaseClient {
|
|||
String url = apiConfig.getHost() + SzyhApiConstant.CANCEL_WITHHOLDING_VOUCHER;
|
||||
String requestId = request(url, requestParam);
|
||||
|
||||
url = apiConfig.getHost() + SzyhApiConstant.CANCEL_WITHHOLDING_VOUCHER_FEEDBACK + "?requestId=" + requestId;
|
||||
url = apiConfig.getHost() + SzyhApiConstant.CANCEL_WITHHOLDING_VOUCHER_FEEDBACK;
|
||||
Map<String, String> responseParam = new HashMap<>(1);
|
||||
return postResponse(url, responseParam, QuerySpecialAmountResponse.class);
|
||||
responseParam.put("requestId", requestId);
|
||||
return response(url, responseParam, QuerySpecialAmountResponse.class);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新缴款状态
|
||||
* @param requestParam
|
||||
* @return
|
||||
*/
|
||||
public SyncWithholdingFeedbackResponse getSyncWithholding(Map<String, Object> requestParam) {
|
||||
String url = apiConfig.getHost() + SzyhApiConstant.GET_SYNC_WITHHOLDING_FEEDBACK;
|
||||
String requestId = request(url, requestParam);
|
||||
|
||||
url = apiConfig.getHost() + SzyhApiConstant.GET_SYNC_WITHHOLDING_FEEDBACK_FEEDBACK;
|
||||
Map<String, String> responseParam = new HashMap<>(1);
|
||||
responseParam.put("requestId", requestId);
|
||||
return response(url, responseParam, SyncWithholdingFeedbackResponse.class);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ package com.engine.salary.service.impl;
|
|||
import com.alibaba.fastjson.JSON;
|
||||
import com.engine.salary.constant.SzyhApiConstant;
|
||||
import com.engine.salary.entity.datacollection.bo.DataCollectionBO;
|
||||
import com.engine.salary.entity.datacollection.response.QuerySpecialAmountResponse;
|
||||
import com.engine.salary.entity.taxagent.po.TaxAgentTaxReturnPO;
|
||||
import com.engine.salary.entity.taxagent.response.SzyhResponseHead;
|
||||
import com.engine.salary.entity.taxdeclaration.po.TaxDeclarationApiConfigPO;
|
||||
|
|
@ -13,16 +12,13 @@ import com.engine.salary.entity.taxpayment.dto.TaxAgreementFeedbackResultDTO;
|
|||
import com.engine.salary.entity.taxpayment.dto.TaxAmountFormDTO;
|
||||
import com.engine.salary.entity.taxpayment.dto.TaxFeedbackResultDTO;
|
||||
import com.engine.salary.entity.taxpayment.param.TaxPaymentQueryParam;
|
||||
import com.engine.salary.entity.taxpayment.po.TaxPaymentRequestPO;
|
||||
import com.engine.salary.entity.taxpayment.response.BaseResponse;
|
||||
import com.engine.salary.entity.taxpayment.response.WithholdingFeedbackResponse;
|
||||
import com.engine.salary.enums.SalaryOnOffEnum;
|
||||
import com.engine.salary.enums.salarysob.DeclareReportTypeEnum;
|
||||
import com.engine.salary.enums.taxdeclaration.TaxDeclareStatusEnum;
|
||||
import com.engine.salary.enums.taxdeclaration.TaxPaymentServiceTypeEnum;
|
||||
import com.engine.salary.enums.taxdeclaration.TaxPaymentStatusEnum;
|
||||
import com.engine.salary.exception.SalaryRunTimeException;
|
||||
import com.engine.salary.remote.tax.client.TaxPaymentClient;
|
||||
import com.engine.salary.util.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
|
|
@ -143,40 +139,38 @@ public class TaxPaymentWithholdingServiceImpl extends AbstractTaxPaymentService
|
|||
@Override
|
||||
protected TempWrapper checkBeforeGetRequestIdResponse(TaxPaymentQueryParam param) {
|
||||
TempWrapper tempWrapper = super.checkBeforeGetRequestIdResponse(param);
|
||||
Map<String, Object> requestParam = DataCollectionBO.getApiBaseQueryParams(tempWrapper.getTaxReturnPO(), tempWrapper.getTaxAgentPO().getName(), SalaryDateUtil.getFormatYYYYMM(param.getTaxYearMonth()));
|
||||
cancelWithholdingVoucher(tempWrapper.getApiConfigPO(), tempWrapper.getTaxDeclareRecord(), requestParam);
|
||||
return tempWrapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancelWithholdingVoucher(TaxDeclarationApiConfigPO apiConfig, TaxDeclareRecordPO taxDeclareRecord, Map<String, Object> requestParam) {
|
||||
TaxPaymentRequestPO paymentRequestPO = getTaxPaymentRequestMapper().getOne(TaxPaymentRequestPO
|
||||
.builder()
|
||||
.requestType(TaxPaymentServiceTypeEnum.WITHHOLDING_VOUCHER.getValue())
|
||||
.taxAgentId(taxDeclareRecord.getTaxAgentId())
|
||||
.taxYearMonth(taxDeclareRecord.getTaxCycle())
|
||||
.build());
|
||||
// if (paymentRequestPO != null) {
|
||||
TaxPaymentClient taxPaymentClient = new TaxPaymentClient(taxDeclareRecord.getTaxAgentId());
|
||||
List<TaxDeclareStatusPO> statuses = getTaxDeclareStatusService(user).getTaxDeclareStatusByTaxDeclareRecordId(taxDeclareRecord.getId());
|
||||
statuses.forEach(status -> {
|
||||
requestParam.put("sblx", status.getReportType());
|
||||
QuerySpecialAmountResponse cancelResponse = taxPaymentClient.cancelWithholdingVoucher(requestParam);
|
||||
SzyhResponseHead head = Optional.ofNullable(cancelResponse).map(QuerySpecialAmountResponse::getHead)
|
||||
.orElse(new SzyhResponseHead("0", SalaryI18nUtil.getI18nLabel(183785, "银联缴款凭证作废失败,请稍后重试")));
|
||||
SalaryAssert.isTrue(SzyhApiConstant.SUCCESS_CODE.equals(head.getCode()) || SzyhApiConstant.NONE_VOUCHER_CODE.equals(head.getCode()), head.getMsg());
|
||||
|
||||
getTaxPaymentRequestMapper().updateFeedbackByRequestTypeTaxAgentIdTaxYearMonth(TaxPaymentRequestPO
|
||||
.builder()
|
||||
.feedback(SalaryOnOffEnum.ON.getValue())
|
||||
.requestType(TaxPaymentServiceTypeEnum.WITHHOLDING_VOUCHER.getValue())
|
||||
.taxAgentId(taxDeclareRecord.getTaxAgentId())
|
||||
.taxYearMonth(taxDeclareRecord.getTaxCycle())
|
||||
.build());
|
||||
});
|
||||
|
||||
// }
|
||||
}
|
||||
// @Override
|
||||
// public void cancelWithholdingVoucher(TaxDeclarationApiConfigPO apiConfig, TaxDeclareRecordPO taxDeclareRecord, Map<String, Object> requestParam) {
|
||||
// TaxPaymentRequestPO paymentRequestPO = getTaxPaymentRequestMapper().getOne(TaxPaymentRequestPO
|
||||
// .builder()
|
||||
// .requestType(TaxPaymentServiceTypeEnum.WITHHOLDING_VOUCHER.getValue())
|
||||
// .taxAgentId(taxDeclareRecord.getTaxAgentId())
|
||||
// .taxYearMonth(taxDeclareRecord.getTaxCycle())
|
||||
// .build());
|
||||
//// if (paymentRequestPO != null) {
|
||||
// TaxPaymentClient taxPaymentClient = new TaxPaymentClient(taxDeclareRecord.getTaxAgentId());
|
||||
// List<TaxDeclareStatusPO> statuses = getTaxDeclareStatusService(user).getTaxDeclareStatusByTaxDeclareRecordId(taxDeclareRecord.getId());
|
||||
// statuses.forEach(status -> {
|
||||
// requestParam.put("sblx", status.getReportType());
|
||||
// QuerySpecialAmountResponse cancelResponse = taxPaymentClient.cancelWithholdingVoucher(requestParam);
|
||||
// SzyhResponseHead head = Optional.ofNullable(cancelResponse).map(QuerySpecialAmountResponse::getHead)
|
||||
// .orElse(new SzyhResponseHead("0", SalaryI18nUtil.getI18nLabel(183785, "银联缴款凭证作废失败,请稍后重试")));
|
||||
// SalaryAssert.isTrue(SzyhApiConstant.SUCCESS_CODE.equals(head.getCode()) || SzyhApiConstant.NONE_VOUCHER_CODE.equals(head.getCode()), head.getMsg());
|
||||
//
|
||||
// getTaxPaymentRequestMapper().updateFeedbackByRequestTypeTaxAgentIdTaxYearMonth(TaxPaymentRequestPO
|
||||
// .builder()
|
||||
// .feedback(SalaryOnOffEnum.ON.getValue())
|
||||
// .requestType(TaxPaymentServiceTypeEnum.WITHHOLDING_VOUCHER.getValue())
|
||||
// .taxAgentId(taxDeclareRecord.getTaxAgentId())
|
||||
// .taxYearMonth(taxDeclareRecord.getTaxCycle())
|
||||
// .build());
|
||||
// });
|
||||
//
|
||||
//// }
|
||||
// }
|
||||
|
||||
protected BaseResponse getFeedbackResponse(TaxDeclarationApiConfigPO apiConfig, String requestId) {
|
||||
String url = apiConfig.getHost() + SzyhApiConstant.DECLARE_WITH_HOLDING_FEEDBACK;
|
||||
|
|
|
|||
|
|
@ -16,20 +16,19 @@ import com.engine.salary.entity.taxpayment.param.TaxPaymentQueryParam;
|
|||
import com.engine.salary.entity.taxpayment.po.TaxPaymentRequestPO;
|
||||
import com.engine.salary.entity.taxpayment.response.BaseResponse;
|
||||
import com.engine.salary.entity.taxpayment.response.SyncWithholdingFeedbackResponse;
|
||||
import com.engine.salary.entity.taxpayment.response.WithholdingFeedbackResponse;
|
||||
import com.engine.salary.entity.taxpayment.response.WithholdingVoucherFeedbackResponse;
|
||||
import com.engine.salary.enums.SalaryOnOffEnum;
|
||||
import com.engine.salary.enums.taxdeclaration.TaxPaymentServiceTypeEnum;
|
||||
import com.engine.salary.enums.taxdeclaration.TaxPaymentStatusEnum;
|
||||
import com.engine.salary.exception.SalaryRunTimeException;
|
||||
import com.engine.salary.remote.tax.client.TaxPaymentClient;
|
||||
import com.engine.salary.util.*;
|
||||
import com.engine.salary.util.JsonUtil;
|
||||
import com.engine.salary.util.SalaryAssert;
|
||||
import com.engine.salary.util.SalaryDateUtil;
|
||||
import com.engine.salary.util.SalaryI18nUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
|
@ -134,40 +133,43 @@ public class TaxPaymentWithholdingVoucherServiceImpl extends AbstractTaxPaymentS
|
|||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncWithholdingFeedback(TaxPaymentQueryParam param) {
|
||||
TempWrapper tempWrapper = checkBeforeGetRequestIdResponse(param);
|
||||
SyncWithholdingFeedbackResponse response = getRequestIdResponse(tempWrapper.getTaxReturnPO(), tempWrapper.getTaxAgentPO().getName(),
|
||||
param, tempWrapper.getApiConfigPO(), SyncWithholdingFeedbackResponse.class);
|
||||
// 校验请求结果
|
||||
String responseCode = Optional.ofNullable(response)
|
||||
.map(SyncWithholdingFeedbackResponse::getHead)
|
||||
.map(SzyhResponseHead::getCode)
|
||||
.orElse(null);
|
||||
WithholdingFeedbackResponse.Feedback body = Optional.ofNullable(response)
|
||||
.map(SyncWithholdingFeedbackResponse::getBody)
|
||||
.orElse(null);
|
||||
if (!SzyhApiConstant.SUCCESS_CODE.equals(responseCode) || Objects.isNull(body)) {
|
||||
log.info("syncWithholdingFeedback code error:{}", JSON.toJSONString(response));
|
||||
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(95828, "税局接口异常,请稍后重试"));
|
||||
}
|
||||
Integer paymentStatus = SalaryEntityUtil.getIntValue(body.getJkzt(), -1);
|
||||
TaxPaymentStatusEnum paymentStatusEnum = SalaryEnumUtil.enumMatchByValue(paymentStatus, TaxPaymentStatusEnum.class);
|
||||
if (paymentStatusEnum != TaxPaymentStatusEnum.SUCCESS) {
|
||||
throw new SalaryRunTimeException(String.format("查询失败,失败原因:%s,申报状态:%s", body.getJksbyy(), body.getSbzt()));
|
||||
}
|
||||
// 累计实缴金额
|
||||
BigDecimal totalPaid = body.getKkfhlb().stream().map(e -> new BigDecimal(e.getSjse())).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
// 更新个税申报记录状态为已缴款
|
||||
updateTaxDeclareRecord(param, totalPaid);
|
||||
// 更新三方缴款反馈状态
|
||||
getTaxPaymentRequestMapper().updateFeedbackByTaxDeclareRecordId(TaxPaymentRequestPO
|
||||
.builder()
|
||||
.feedback(SalaryOnOffEnum.ON.getValue())
|
||||
.requestType(TaxPaymentServiceTypeEnum.WITHHOLDING_VOUCHER.getValue())
|
||||
.taxDeclareRecordId(param.getTaxDeclareRecordId())
|
||||
.build());
|
||||
}
|
||||
// @Override
|
||||
// public void syncWithholdingFeedback(TaxPaymentQueryParam param) {
|
||||
// TempWrapper tempWrapper = checkBeforeGetRequestIdResponse(param);
|
||||
// TaxPaymentClient taxPaymentClient = new TaxPaymentClient(param.getTaxAgentId());
|
||||
// Map<String, Object> requestParam = DataCollectionBO.getApiBaseQueryParams(tempWrapper.getTaxReturnPO(), tempWrapper.getTaxAgentPO().getName(), SalaryDateUtil.getFormatYYYYMM(param.getTaxYearMonth()));
|
||||
// requestParam.put("bblx", param.getReportType());
|
||||
// SyncWithholdingFeedbackResponse response = taxPaymentClient.getSyncWithholding(requestParam);
|
||||
//
|
||||
// // 校验请求结果
|
||||
// String responseCode = Optional.ofNullable(response)
|
||||
// .map(SyncWithholdingFeedbackResponse::getHead)
|
||||
// .map(SzyhResponseHead::getCode)
|
||||
// .orElse(null);
|
||||
// WithholdingFeedbackResponse.Feedback body = Optional.ofNullable(response)
|
||||
// .map(SyncWithholdingFeedbackResponse::getBody)
|
||||
// .orElse(null);
|
||||
// if (!SzyhApiConstant.SUCCESS_CODE.equals(responseCode) || Objects.isNull(body)) {
|
||||
// log.info("syncWithholdingFeedback code error:{}", JSON.toJSONString(response));
|
||||
// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(95828, "税局接口异常,请稍后重试"));
|
||||
// }
|
||||
// Integer paymentStatus = SalaryEntityUtil.getIntValue(body.getJkzt(), -1);
|
||||
// TaxPaymentStatusEnum paymentStatusEnum = SalaryEnumUtil.enumMatchByValue(paymentStatus, TaxPaymentStatusEnum.class);
|
||||
// if (paymentStatusEnum != TaxPaymentStatusEnum.SUCCESS) {
|
||||
// throw new SalaryRunTimeException(String.format("查询失败,失败原因:%s,申报状态:%s", body.getJksbyy(), body.getSbzt()));
|
||||
// }
|
||||
// // 累计实缴金额
|
||||
// BigDecimal totalPaid = body.getKkfhlb().stream().map(e -> new BigDecimal(e.getSjse())).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
// // 更新个税申报记录状态为已缴款
|
||||
// updateTaxDeclareRecord(param, totalPaid);
|
||||
// // 更新三方缴款反馈状态
|
||||
// getTaxPaymentRequestMapper().updateFeedbackByTaxDeclareRecordId(TaxPaymentRequestPO
|
||||
// .builder()
|
||||
// .feedback(SalaryOnOffEnum.ON.getValue())
|
||||
// .requestType(TaxPaymentServiceTypeEnum.WITHHOLDING_VOUCHER.getValue())
|
||||
// .taxDeclareRecordId(param.getTaxDeclareRecordId())
|
||||
// .build());
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void cancelWithholdingVoucher(TaxPaymentQueryParam param) {
|
||||
|
|
|
|||
|
|
@ -17,20 +17,25 @@ public class TaskUtil {
|
|||
}
|
||||
|
||||
public void writeApiTaskRecord(String source, String api, String param, String response) {
|
||||
log.info("source:{} , api:{} , param:{} , response : {}", source, api, param, response);
|
||||
Date now = new Date();
|
||||
ApiTaskRecordPO build = ApiTaskRecordPO.builder()
|
||||
.id(IdGenerator.generate())
|
||||
.source(source)
|
||||
.api(api)
|
||||
.param(param)
|
||||
.response(response)
|
||||
.createTime(now)
|
||||
.updateTime(now)
|
||||
.deleteType(0)
|
||||
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
|
||||
.build();
|
||||
getApiTaskRecordMapper().insertIgnoreNull(build);
|
||||
try {
|
||||
log.info("source:{} , api:{} , param:{} , response : {}", source, api, param, response);
|
||||
Date now = new Date();
|
||||
ApiTaskRecordPO build = ApiTaskRecordPO.builder()
|
||||
.id(IdGenerator.generate())
|
||||
.source(source)
|
||||
.api(api)
|
||||
.param(param)
|
||||
.response(response)
|
||||
.createTime(now)
|
||||
.updateTime(now)
|
||||
.deleteType(0)
|
||||
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
|
||||
.build();
|
||||
getApiTaskRecordMapper().insertIgnoreNull(build);
|
||||
}catch (Exception e){
|
||||
log.error("writeApiTaskRecord error", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -103,6 +103,7 @@ public class TaxPaymentController {
|
|||
@Path("/voucher/print")
|
||||
@POST
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Deprecated
|
||||
public String printVoucher(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody TaxPaymentQueryParam param) {
|
||||
param.setType(TaxPaymentServiceTypeEnum.WITHHOLDING_VOUCHER.getValue());
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
|
|
@ -118,6 +119,7 @@ public class TaxPaymentController {
|
|||
@Path("/voucher/print/feedback")
|
||||
@POST
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Deprecated
|
||||
public String printVoucherFeedback(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody TaxPaymentQueryParam param) {
|
||||
param.setType(TaxPaymentServiceTypeEnum.WITHHOLDING_VOUCHER.getValue());
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
|
|
@ -133,6 +135,7 @@ public class TaxPaymentController {
|
|||
@Path("/voucher/cancel")
|
||||
@POST
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Deprecated
|
||||
public String cancelVoucher(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody TaxPaymentQueryParam param) {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
return new ResponseResult<TaxPaymentQueryParam, TaxFeedbackResultDTO>(user).run(getTaxPaymentWrapper(user)::cancelVoucher, param);
|
||||
|
|
@ -161,6 +164,7 @@ public class TaxPaymentController {
|
|||
@Path("/voucher/status/sync")
|
||||
@POST
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Deprecated
|
||||
public String getSyncWithholdingFeedback(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody TaxPaymentQueryParam param) {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
return new ResponseResult<TaxPaymentQueryParam, TaxWithheldVoucherResultDTO>(user).run(getTaxPaymentWrapper(user)::getSyncWithholdingFeedback, param);
|
||||
|
|
|
|||
|
|
@ -33,9 +33,6 @@ public class TaxPaymentWrapper extends Service {
|
|||
return ServiceUtil.getService(TaxPaymentWithholdingServiceImpl.class, user).getFeedback(param);
|
||||
}
|
||||
|
||||
public TaxFeedbackResultDTO printVoucherFeedback(TaxPaymentQueryParam param) {
|
||||
return ServiceUtil.getService(TaxPaymentWithholdingVoucherServiceImpl.class, user).getFeedback(param);
|
||||
}
|
||||
|
||||
public String getRequestId(TaxPaymentQueryParam param) {
|
||||
return taxPaymentServiceFactory.get(param.getType()).getRequestId(param);
|
||||
|
|
@ -49,11 +46,17 @@ public class TaxPaymentWrapper extends Service {
|
|||
return ServiceUtil.getService(TaxPaymentWithheldVoucherServiceImpl.class, user).getWithheldVoucher(param);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void getSyncWithholdingFeedback(TaxPaymentQueryParam param) {
|
||||
ServiceUtil.getService(TaxPaymentWithholdingVoucherServiceImpl.class, user).syncWithholdingFeedback(param);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void cancelVoucher(TaxPaymentQueryParam param) {
|
||||
ServiceUtil.getService(TaxPaymentWithholdingVoucherServiceImpl.class, user).cancelWithholdingVoucher(param);
|
||||
}
|
||||
@Deprecated
|
||||
public TaxFeedbackResultDTO printVoucherFeedback(TaxPaymentQueryParam param) {
|
||||
return ServiceUtil.getService(TaxPaymentWithholdingVoucherServiceImpl.class, user).getFeedback(param);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue