From 0c22a57f1961ca85d44c05e5b1dc5e2df86ad25d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=92=B1=E6=B6=9B?= <15850646081@163.com> Date: Thu, 4 Jul 2024 10:32:09 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=96=E6=B6=88=E5=88=B7=E6=96=B0=E7=BC=B4?= =?UTF-8?q?=E6=AC=BE=E7=8A=B6=E6=80=81=20=E5=8F=96=E6=B6=88=E7=BA=BF?= =?UTF-8?q?=E4=B8=8B=E7=BC=B4=E6=AC=BE=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../remote/tax/client/TaxPaymentClient.java | 22 ++++- .../TaxPaymentWithholdingServiceImpl.java | 64 +++++++-------- ...xPaymentWithholdingVoucherServiceImpl.java | 80 ++++++++++--------- src/com/engine/salary/util/TaskUtil.java | 33 ++++---- .../salary/web/TaxPaymentController.java | 4 + .../salary/wrapper/TaxPaymentWrapper.java | 11 ++- 6 files changed, 120 insertions(+), 94 deletions(-) diff --git a/src/com/engine/salary/remote/tax/client/TaxPaymentClient.java b/src/com/engine/salary/remote/tax/client/TaxPaymentClient.java index 5d06903cc..2f80692b1 100644 --- a/src/com/engine/salary/remote/tax/client/TaxPaymentClient.java +++ b/src/com/engine/salary/remote/tax/client/TaxPaymentClient.java @@ -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 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 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 responseParam = new HashMap<>(1); + responseParam.put("requestId", requestId); + return response(url, responseParam, SyncWithholdingFeedbackResponse.class); } diff --git a/src/com/engine/salary/service/impl/TaxPaymentWithholdingServiceImpl.java b/src/com/engine/salary/service/impl/TaxPaymentWithholdingServiceImpl.java index 4b37d0c0f..678f125da 100644 --- a/src/com/engine/salary/service/impl/TaxPaymentWithholdingServiceImpl.java +++ b/src/com/engine/salary/service/impl/TaxPaymentWithholdingServiceImpl.java @@ -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 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 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 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 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 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; diff --git a/src/com/engine/salary/service/impl/TaxPaymentWithholdingVoucherServiceImpl.java b/src/com/engine/salary/service/impl/TaxPaymentWithholdingVoucherServiceImpl.java index 517548901..6eaabba46 100644 --- a/src/com/engine/salary/service/impl/TaxPaymentWithholdingVoucherServiceImpl.java +++ b/src/com/engine/salary/service/impl/TaxPaymentWithholdingVoucherServiceImpl.java @@ -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 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) { diff --git a/src/com/engine/salary/util/TaskUtil.java b/src/com/engine/salary/util/TaskUtil.java index 9b498d316..63df65134 100644 --- a/src/com/engine/salary/util/TaskUtil.java +++ b/src/com/engine/salary/util/TaskUtil.java @@ -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); + } + } diff --git a/src/com/engine/salary/web/TaxPaymentController.java b/src/com/engine/salary/web/TaxPaymentController.java index 07e5203ca..800e9e91d 100644 --- a/src/com/engine/salary/web/TaxPaymentController.java +++ b/src/com/engine/salary/web/TaxPaymentController.java @@ -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(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(user).run(getTaxPaymentWrapper(user)::getSyncWithholdingFeedback, param); diff --git a/src/com/engine/salary/wrapper/TaxPaymentWrapper.java b/src/com/engine/salary/wrapper/TaxPaymentWrapper.java index 41e153802..258af95af 100644 --- a/src/com/engine/salary/wrapper/TaxPaymentWrapper.java +++ b/src/com/engine/salary/wrapper/TaxPaymentWrapper.java @@ -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); + } + }