Browse Source

退税入账申请

liangbo.huang 2 weeks ago
parent
commit
35e093de1b
16 changed files with 412 additions and 7 deletions
  1. 57 1
      trade-admin/src/main/java/com/trade/admin/trade/exportrebate/controller/ExportTaxRebateController.java
  2. 28 0
      trade-admin/src/main/java/com/trade/admin/trade/exportrebate/dto/ExportTaxRefundBatchRequest.java
  3. 26 0
      trade-admin/src/main/java/com/trade/admin/trade/exportrebate/dto/ExportTaxRefundDetailsRequest.java
  4. 46 0
      trade-admin/src/main/java/com/trade/admin/trade/exportrebate/service/ExportTaxRebateService.java
  5. 164 3
      trade-admin/src/main/java/com/trade/admin/trade/exportrebate/service/impl/ExportTaxRebateServiceImpl.java
  6. 3 1
      trade-service/src/main/java/com/trade/service/DictConstants.java
  7. 14 0
      trade-service/src/main/java/com/trade/service/trade/exportrebate/domain/TaxRebateExportDetails.java
  8. 12 0
      trade-service/src/main/java/com/trade/service/trade/exportrebate/dto/TaxRebateExportAbstractInfo.java
  9. 13 0
      trade-service/src/main/java/com/trade/service/trade/exportrebate/dto/TaxRebateSummaryDataDto.java
  10. 12 0
      trade-service/src/main/java/com/trade/service/trade/exportrebate/dto/search/TaxRebateExportAbstractInfoSearchDto.java
  11. 10 0
      trade-service/src/main/java/com/trade/service/trade/exportrebate/service/TaxRebateExportDetailsBaseService.java
  12. 9 0
      trade-service/src/main/java/com/trade/service/trade/exportrebate/service/impl/TaxRebateExportDetailsBaseServiceImpl.java
  13. 4 0
      trade-service/src/main/java/com/trade/service/trade/salesorder/vo/CustomsDeclarationGoodsBelongsVO.java
  14. 4 1
      trade-service/src/main/resources/data.init/v1.1/20241022.sql
  15. 8 1
      trade-service/src/main/resources/mapper/trade/exportrebate/TaxRebateExportDetailsMapper.xml
  16. 2 0
      trade-service/src/main/resources/mapper/trade/salesorder/CustomsDeclarationGoodsMapper.xml

+ 57 - 1
trade-admin/src/main/java/com/trade/admin/trade/exportrebate/controller/ExportTaxRebateController.java

@@ -1,6 +1,8 @@
 package com.trade.admin.trade.exportrebate.controller;
 
 import com.trade.admin.system.controller.BaseController;
+import com.trade.admin.trade.exportrebate.dto.ExportTaxRefundBatchRequest;
+import com.trade.admin.trade.exportrebate.dto.ExportTaxRefundDetailsRequest;
 import com.trade.common.core.domain.ResponseResult;
 import com.trade.common.core.page.GridPage;
 import com.trade.service.trade.exportrebate.dto.*;
@@ -13,6 +15,8 @@ import org.springframework.web.bind.annotation.*;
 import com.trade.admin.trade.exportrebate.service.ExportTaxRebateService;
 
 import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.util.List;
 
 /**
  * 出口退税-出口明细接口
@@ -21,7 +25,7 @@ import javax.annotation.Resource;
  * @since 2024-10-22 15:46:46
  */
 @Controller
-@RequestMapping("taxRebateExportDetails")
+@RequestMapping("/exportTaxRebate")
 public class ExportTaxRebateController extends BaseController {
 
     /**
@@ -93,4 +97,56 @@ public class ExportTaxRebateController extends BaseController {
         String taxRebateUrl = exportTaxRebateService.getTaxRebateUrl(xtUserId, xtEid);
         return "redirect:" + taxRebateUrl;
     }
+
+    /**
+     * 获取退税到账金额(批量选择申报批次)
+     *
+     * @param request 查询实体
+     * @return
+     */
+    @GetMapping("/declarationBatch/refundAmount")
+    @ResponseBody
+    @PreAuthorize("@ss.hasPermi('trade:exportTaxRebate.exportTaxRefund')")
+    public ResponseResult<BigDecimal> getRefundAmountForDeclarationBatch(ExportTaxRefundBatchRequest request) {
+        return success(exportTaxRebateService.getRefundAmountForDeclarationBatch(request));
+    }
+
+    /**
+     * 出口退税款确认(批量选择申报批次)
+     *
+     * @param request 查询实体
+     * @return
+     */
+    @PostMapping("/declarationBatch/exportTaxRefund")
+    @ResponseBody
+    @PreAuthorize("@ss.hasPermi('trade:exportTaxRebate.exportTaxRefund')")
+    public ResponseResult<Boolean> refundExportTaxForDeclarationBatch(ExportTaxRefundBatchRequest request) {
+        return success(exportTaxRebateService.refundExportTaxForDeclarationBatch(request));
+    }
+
+    /**
+     * 获取退税到账金额(批量选择商品)
+     *
+     * @param request 查询实体
+     * @return
+     */
+    @GetMapping("/exportDetails/refundAmount")
+    @ResponseBody
+    @PreAuthorize("@ss.hasPermi('trade:exportTaxRebate.exportTaxRefund')")
+    public ResponseResult<BigDecimal> getRefundAmountForExportDetails(List<TaxRebateExportAbstractInfo> request) {
+        return success(exportTaxRebateService.getRefundAmountForExportDetails(request));
+    }
+
+    /**
+     * 出口退税款确认(批量选择商品)
+     *
+     * @param request 查询实体
+     * @return
+     */
+    @PostMapping("/exportDetails/exportTaxRefund")
+    @ResponseBody
+    @PreAuthorize("@ss.hasPermi('trade:exportTaxRebate.exportTaxRefund')")
+    public ResponseResult<Boolean> refundExportTaxForExportDetails(ExportTaxRefundDetailsRequest request) {
+        return success(exportTaxRebateService.refundExportTaxForExportDetails(request));
+    }
 }

+ 28 - 0
trade-admin/src/main/java/com/trade/admin/trade/exportrebate/dto/ExportTaxRefundBatchRequest.java

@@ -0,0 +1,28 @@
+package com.trade.admin.trade.exportrebate.dto;
+
+import com.trade.service.trade.exportrebate.dto.search.TaxRebateExportAbstractInfoSearchDto;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.time.LocalDate;
+import java.util.List;
+
+@Data
+public class ExportTaxRefundBatchRequest {
+    /**
+     * 多选条件
+     */
+    List<TaxRebateExportAbstractInfoSearchDto> searchDtos;
+    /**
+     * 退税到账金额
+     */
+    private BigDecimal refundAmount;
+    /**
+     * 到账日期
+     */
+    private LocalDate entryDate;
+    /**
+     * 收款银行账号
+     */
+    private String accountNumber;
+}

+ 26 - 0
trade-admin/src/main/java/com/trade/admin/trade/exportrebate/dto/ExportTaxRefundDetailsRequest.java

@@ -0,0 +1,26 @@
+package com.trade.admin.trade.exportrebate.dto;
+
+import com.trade.service.trade.exportrebate.dto.TaxRebateExportAbstractInfo;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.time.LocalDate;
+import java.util.List;
+
+@Data
+public class ExportTaxRefundDetailsRequest {
+
+    List<TaxRebateExportAbstractInfo> details;
+    /**
+     * 退税到账金额
+     */
+    private BigDecimal refundAmount;
+    /**
+     * 到账日期
+     */
+    private LocalDate entryDate;
+    /**
+     * 收款银行账号
+     */
+    private String accountNumber;
+}

+ 46 - 0
trade-admin/src/main/java/com/trade/admin/trade/exportrebate/service/ExportTaxRebateService.java

@@ -1,11 +1,16 @@
 package com.trade.admin.trade.exportrebate.service;
 
+import com.trade.admin.trade.exportrebate.dto.ExportTaxRefundBatchRequest;
+import com.trade.admin.trade.exportrebate.dto.ExportTaxRefundDetailsRequest;
 import com.trade.common.core.page.GridPage;
 import com.trade.service.trade.exportrebate.dto.*;
 import com.trade.service.trade.exportrebate.dto.search.TaxRebateExportAbstractInfoSearchDto;
 import com.trade.service.trade.exportrebate.dto.search.TaxRebatePurchaseAbstractInfoSearchDto;
 import com.trade.service.trade.exportrebate.dto.search.TaxRebateSummarySearchDto;
 
+import java.math.BigDecimal;
+import java.util.List;
+
 /**
  * 出口退税服务接口
  *
@@ -50,9 +55,50 @@ public interface ExportTaxRebateService {
 
     /**
      * 获取小图退税链接
+     * 
      * @param xtUserId
      * @param xtEid
      * @return
      */
     String getTaxRebateUrl(String xtUserId, String xtEid);
+
+    /**
+     * 获取退税到账金额(批量选择申报批次)
+     * 
+     * @param request
+     * @return
+     */
+    BigDecimal getRefundAmountForDeclarationBatch(ExportTaxRefundBatchRequest request);
+
+    /**
+     * 出口退税款确认(批量选择申报批次)
+     * 
+     * @param request
+     * @return
+     */
+    Boolean refundExportTaxForDeclarationBatch(ExportTaxRefundBatchRequest request);
+
+    /**
+     * 获取退税到账金额(批量选择商品)
+     * 
+     * @param request
+     * @return
+     */
+    BigDecimal getRefundAmountForExportDetails(List<TaxRebateExportAbstractInfo> request);
+
+    /**
+     * 出口退税款确认(批量选择商品)
+     * 
+     * @param request
+     * @return
+     */
+    Boolean refundExportTaxForExportDetails(ExportTaxRefundDetailsRequest request);
+
+    /**
+     * 出口退税入账审核通过
+     * 
+     * @param detailIds
+     * @return
+     */
+    Boolean refundExportTaxAuditPassed(List<Long> detailIds);
 }

+ 164 - 3
trade-admin/src/main/java/com/trade/admin/trade/exportrebate/service/impl/ExportTaxRebateServiceImpl.java

@@ -1,10 +1,17 @@
 package com.trade.admin.trade.exportrebate.service.impl;
 
+import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.util.StrUtil;
+import com.trade.admin.trade.exportrebate.dto.ExportTaxRefundBatchRequest;
+import com.trade.admin.trade.exportrebate.dto.ExportTaxRefundDetailsRequest;
 import com.trade.admin.trade.exportrebate.service.ExportTaxRebateService;
 import com.trade.common.constant.HttpStatus;
 import com.trade.common.core.page.GridPage;
 import com.trade.common.exception.ServiceException;
+import com.trade.common.utils.DateUtils;
+import com.trade.service.DictConstants;
+import com.trade.service.finance.paymentcollection.dto.ExportTaxRefundV2Dto;
+import com.trade.service.finance.paymentcollection.service.BillingIncomeService;
 import com.trade.service.thirdparty.xiaotu.service.XiaotuRequestService;
 import com.trade.service.trade.exportrebate.dto.*;
 import com.trade.service.trade.exportrebate.dto.search.TaxRebateExportAbstractInfoSearchDto;
@@ -15,8 +22,15 @@ import com.trade.service.trade.exportrebate.service.TaxRebatePurchaseDetailsBase
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.time.LocalDate;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
 
 /**
  * 出口退税服务实现类
@@ -34,15 +48,16 @@ public class ExportTaxRebateServiceImpl implements ExportTaxRebateService {
     private TaxRebatePurchaseDetailsBaseService taxRebatePurchaseDetailsBaseService;
     @Resource
     private XiaotuRequestService xiaotuRequestService;
+    @Resource
+    private BillingIncomeService billingIncomeService;
 
     @Override
-    public TaxRebateTotalDataDto getTaxRebateTotalDataBySearch( TaxRebateSummarySearchDto search) {
+    public TaxRebateTotalDataDto getTaxRebateTotalDataBySearch(TaxRebateSummarySearchDto search) {
         return taxRebateExportDetailsBaseService.getTaxRebateTotalDataBySearch(search);
     }
 
     @Override
-    public GridPage<TaxRebateSummaryDataDto> getTaxRebateSummaryDataPagesBySearch(
-             TaxRebateSummarySearchDto search) {
+    public GridPage<TaxRebateSummaryDataDto> getTaxRebateSummaryDataPagesBySearch(TaxRebateSummarySearchDto search) {
         return taxRebateExportDetailsBaseService.getTaxRebateSummaryDataPagesBySearch(search);
     }
 
@@ -65,4 +80,150 @@ public class ExportTaxRebateServiceImpl implements ExportTaxRebateService {
         }
         return xiaotuRequestService.getExportRebateUrl(xtUserId, xtEid);
     }
+
+    @Override
+    public BigDecimal getRefundAmountForDeclarationBatch(ExportTaxRefundBatchRequest request) {
+        if (request == null || CollUtil.isEmpty(request.getSearchDtos())) {
+            throw new ServiceException("请求参数错误", HttpStatus.BAD_REQUEST);
+        }
+        int page = 1;
+        int pageSize = 100;
+        BigDecimal refundAmount = BigDecimal.ZERO;
+        for (TaxRebateExportAbstractInfoSearchDto searchDto : request.getSearchDtos()) {
+            searchDto.setStatus(DictConstants.REBATE_PROCESS_STATUS_DONE);
+            searchDto.setPaymentStatus(DictConstants.REBATE_PAYMENT_STATUS_NOT_PAY);
+            searchDto.setRows(pageSize);
+            while (true) {
+                searchDto.setPage(page);
+                GridPage<TaxRebateExportAbstractInfo> pages = taxRebateExportDetailsBaseService
+                        .getTaxRebateExportAbstractInfoPagesBySearch(searchDto);
+                List<TaxRebateExportAbstractInfo> rows = pages.getRows();
+                BigDecimal amount = rows.stream().map(TaxRebateExportAbstractInfo::getTaxRefundAmount)
+                        .reduce(BigDecimal.ZERO, BigDecimal::add);
+                refundAmount = refundAmount.add(amount);
+                if (rows.size() < pageSize) {
+                    break;
+                }
+                page++;
+            }
+        }
+        return refundAmount;
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public Boolean refundExportTaxForDeclarationBatch(ExportTaxRefundBatchRequest request) {
+        if (request == null || CollUtil.isEmpty(request.getSearchDtos())) {
+            throw new ServiceException("请求参数错误", HttpStatus.BAD_REQUEST);
+        }
+        int page = 1;
+        int pageSize = 100;
+        List<ExportTaxRefundV2Dto> exportTaxRefundDtos = new ArrayList<>();
+        List<Long> recordIds = new ArrayList<>();
+        for (TaxRebateExportAbstractInfoSearchDto searchDto : request.getSearchDtos()) {
+            searchDto.setStatus(DictConstants.REBATE_PROCESS_STATUS_DONE);
+            searchDto.setPaymentStatus(DictConstants.REBATE_PAYMENT_STATUS_NOT_PAY);
+            searchDto.setRows(pageSize);
+            while (true) {
+                searchDto.setPage(page);
+                GridPage<TaxRebateExportAbstractInfo> pages = taxRebateExportDetailsBaseService
+                        .getTaxRebateExportAbstractInfoPagesBySearch(searchDto);
+                List<TaxRebateExportAbstractInfo> rows = pages.getRows();
+                buildRefundSaveParam(rows, recordIds, exportTaxRefundDtos, request.getEntryDate(),
+                        request.getAccountNumber());
+                if (rows.size() < pageSize) {
+                    break;
+                }
+                page++;
+            }
+        }
+        if (CollUtil.isNotEmpty(exportTaxRefundDtos)) {
+            // 生成退税入账确认记录
+            billingIncomeService.saveExportTaxRefundV2(exportTaxRefundDtos);
+        }
+        if (CollUtil.isNotEmpty(recordIds)) {
+            // 更新退税状态
+            taxRebateExportDetailsBaseService.batchUpdatePaymentStatusAndPaymentDate(recordIds,
+                    DictConstants.REBATE_PAYMENT_STATUS_AUDITING,
+                    DateUtils.parseLocalDate2Date(request.getEntryDate()));
+        }
+        return true;
+    }
+
+    @Override
+    public BigDecimal getRefundAmountForExportDetails(List<TaxRebateExportAbstractInfo> request) {
+        if (CollUtil.isNotEmpty(request)) {
+            return BigDecimal.ZERO;
+        }
+        return request.stream()
+                .filter(o -> DictConstants.REBATE_PROCESS_STATUS_DONE.equals(o.getStatus())
+                        && DictConstants.REBATE_PAYMENT_STATUS_NOT_PAY.equals(o.getPaymentStatus()))
+                .map(TaxRebateExportAbstractInfo::getTaxRefundAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public Boolean refundExportTaxForExportDetails(ExportTaxRefundDetailsRequest request) {
+        if (CollUtil.isEmpty(request.getDetails())) {
+            return false;
+        }
+        List<TaxRebateExportAbstractInfo> details = request.getDetails().stream()
+                .filter(o -> DictConstants.REBATE_PROCESS_STATUS_DONE.equals(o.getStatus())
+                        && DictConstants.REBATE_PAYMENT_STATUS_NOT_PAY.equals(o.getPaymentStatus()))
+                .collect(Collectors.toList());
+        List<ExportTaxRefundV2Dto> exportTaxRefundDtos = new ArrayList<>();
+        List<Long> recordIds = new ArrayList<>();
+        buildRefundSaveParam(details, recordIds, exportTaxRefundDtos, request.getEntryDate(),
+                request.getAccountNumber());
+        if (CollUtil.isNotEmpty(exportTaxRefundDtos)) {
+            // 生成退税入账确认记录
+            billingIncomeService.saveExportTaxRefundV2(exportTaxRefundDtos);
+        }
+        if (CollUtil.isNotEmpty(recordIds)) {
+            // 更新退税状态
+            taxRebateExportDetailsBaseService.batchUpdatePaymentStatusAndPaymentDate(recordIds,
+                    DictConstants.REBATE_PAYMENT_STATUS_AUDITING,
+                    DateUtils.parseLocalDate2Date(request.getEntryDate()));
+        }
+        return true;
+    }
+
+    private void buildRefundSaveParam(List<TaxRebateExportAbstractInfo> details, List<Long> recordIds,
+            List<ExportTaxRefundV2Dto> exportTaxRefundDtos, LocalDate entryDate, String accountNumber) {
+        Map<String, List<TaxRebateExportAbstractInfo>> map = details.stream()
+                .collect(Collectors.groupingBy(o -> o.getDeclarationBatch() + "_" + o.getDeclarationMonthYear() + "_"
+                        + o.getAgencyCertNo() + "_" + o.getSalesContractId()));
+        for (Map.Entry<String, List<TaxRebateExportAbstractInfo>> entry : map.entrySet()) {
+            String key = entry.getKey();
+            String[] arr = key.split("_");
+            String declarationBatch = arr[0];
+            String declarationMonthYear = arr[1];
+            // String agencyCertNo = arr[2];
+            Long salesContractId = Long.valueOf(arr[3]);
+            List<TaxRebateExportAbstractInfo> records = entry.getValue();
+            BigDecimal refundAmount = records.stream().map(TaxRebateExportAbstractInfo::getTaxRefundAmount)
+                    .reduce(BigDecimal.ZERO, BigDecimal::add);
+            List<String> detailIds = records.stream().map(o -> o.getId().toString()).distinct()
+                    .collect(Collectors.toList());
+            recordIds.addAll(
+                    records.stream().map(TaxRebateExportAbstractInfo::getId).distinct().collect(Collectors.toList()));
+            ExportTaxRefundV2Dto dto = new ExportTaxRefundV2Dto();
+            dto.setDeclarationMonthYear(declarationMonthYear);
+            dto.setDeclarationBatch(declarationBatch);
+            dto.setDetailIds(detailIds);
+            dto.setRefundAmount(refundAmount);
+            dto.setSaleContractId(salesContractId);
+            dto.setEntryDate(entryDate);
+            dto.setAccountNumber(accountNumber);
+            exportTaxRefundDtos.add(dto);
+        }
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public Boolean refundExportTaxAuditPassed(List<Long> detailIds) {
+        taxRebateExportDetailsBaseService.batchUpdatePaymentStatusAndPaymentDate(detailIds,
+                DictConstants.REBATE_PAYMENT_STATUS_PAYED, null);
+        return true;
+    }
 }

+ 3 - 1
trade-service/src/main/java/com/trade/service/DictConstants.java

@@ -119,6 +119,8 @@ public class DictConstants {
      */
     // 未到账
     public static final String REBATE_PAYMENT_STATUS_NOT_PAY = "0";
+    // 审核中
+    public static final String REBATE_PAYMENT_STATUS_AUDITING = "1";
     // 已到账
-    public static final String REBATE_PAYMENT_STATUS_PAYED = "1";
+    public static final String REBATE_PAYMENT_STATUS_PAYED = "2";
 }

+ 14 - 0
trade-service/src/main/java/com/trade/service/trade/exportrebate/domain/TaxRebateExportDetails.java

@@ -37,6 +37,10 @@ public class TaxRebateExportDetails extends BaseEntity<TaxRebateExportDetails> {
      * 销售订单号
      */
     private String salesOrderNo;
+    /**
+     * 销售合同id
+     */
+    private Long salesContractId;
     /**
      * 申报年月(生产企业:所属期)(yyyyMM)
      */
@@ -220,6 +224,14 @@ public class TaxRebateExportDetails extends BaseEntity<TaxRebateExportDetails> {
         this.salesOrderNo = salesOrderNo;
     }
 
+    public Long getSalesContractId() {
+        return salesContractId;
+    }
+
+    public void setSalesContractId(Long salesContractId) {
+        this.salesContractId = salesContractId;
+    }
+
     public String getDeclarationMonthYear() {
         return declarationMonthYear;
     }
@@ -525,6 +537,7 @@ public class TaxRebateExportDetails extends BaseEntity<TaxRebateExportDetails> {
         this.agencyCertNo = goodsBelongs == null ? null : goodsBelongs.getAgencyCertNo();
         this.importerCertNo = goodsBelongs == null ? null : goodsBelongs.getImporterCertNo();
         this.salesOrderNo = goodsBelongs == null ? null : goodsBelongs.getSalesOrderNo();
+        this.salesContractId = goodsBelongs == null ? null : goodsBelongs.getSalesContractId();
         this.declarationMonthYear = response.getSsq();
         this.declarationBatch = response.getSbpc();
         this.declarationSerialNo = response.getSbxh();
@@ -576,6 +589,7 @@ public class TaxRebateExportDetails extends BaseEntity<TaxRebateExportDetails> {
         this.agencyCertNo = goodsBelongs == null ? null : goodsBelongs.getAgencyCertNo();
         this.importerCertNo = goodsBelongs == null ? null : goodsBelongs.getImporterCertNo();
         this.salesOrderNo = goodsBelongs == null ? null : goodsBelongs.getSalesOrderNo();
+        this.salesContractId = goodsBelongs == null ? null : goodsBelongs.getSalesContractId();
         this.declarationMonthYear = response.getSsq();
         this.declarationSerialNo = response.getSbxh();
         this.correlationNo = response.getGlh();

+ 12 - 0
trade-service/src/main/java/com/trade/service/trade/exportrebate/dto/TaxRebateExportAbstractInfo.java

@@ -42,6 +42,10 @@ public class TaxRebateExportAbstractInfo {
      * 销售订单号
      */
     private String salesOrderNo;
+    /**
+     * 销售合同id
+     */
+    private Long salesContractId;
     /**
      * 申报年月(所属期)(yyyyMM)
      */
@@ -173,6 +177,14 @@ public class TaxRebateExportAbstractInfo {
         this.salesOrderNo = salesOrderNo;
     }
 
+    public Long getSalesContractId() {
+        return salesContractId;
+    }
+
+    public void setSalesContractId(Long salesContractId) {
+        this.salesContractId = salesContractId;
+    }
+
     public String getDeclarationMonthYear() {
         return declarationMonthYear;
     }

+ 13 - 0
trade-service/src/main/java/com/trade/service/trade/exportrebate/dto/TaxRebateSummaryDataDto.java

@@ -43,6 +43,11 @@ public class TaxRebateSummaryDataDto {
      * 退税状态,枚举rebate_process_status
      */
     private String status;
+    /**
+     * 是否可选进行退税款确认
+     */
+    private boolean selectable;
+
     public String getDeclarationMonthYear() {
         return declarationMonthYear;
     }
@@ -114,4 +119,12 @@ public class TaxRebateSummaryDataDto {
     public void setStatus(String status) {
         this.status = status;
     }
+
+    public boolean isSelectable() {
+        return selectable;
+    }
+
+    public void setSelectable(boolean selectable) {
+        this.selectable = selectable;
+    }
 }

+ 12 - 0
trade-service/src/main/java/com/trade/service/trade/exportrebate/dto/search/TaxRebateExportAbstractInfoSearchDto.java

@@ -43,6 +43,10 @@ public class TaxRebateExportAbstractInfoSearchDto extends PageDomain {
      * 退税状态,枚举:rebate_process_status
      */
     private String status;
+    /**
+     * 退税到账状态,枚举rebate_payment_status
+     */
+    private String paymentStatus;
 
     public String getDeclarationMonthYear() {
         return declarationMonthYear;
@@ -115,4 +119,12 @@ public class TaxRebateExportAbstractInfoSearchDto extends PageDomain {
     public void setStatus(String status) {
         this.status = status;
     }
+
+    public String getPaymentStatus() {
+        return paymentStatus;
+    }
+
+    public void setPaymentStatus(String paymentStatus) {
+        this.paymentStatus = paymentStatus;
+    }
 }

+ 10 - 0
trade-service/src/main/java/com/trade/service/trade/exportrebate/service/TaxRebateExportDetailsBaseService.java

@@ -8,6 +8,7 @@ import com.trade.service.trade.exportrebate.dto.search.TaxRebateExportAbstractIn
 import com.trade.service.trade.exportrebate.dto.search.TaxRebateSearchDto;
 import com.trade.service.trade.exportrebate.dto.search.TaxRebateSummarySearchDto;
 
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -18,6 +19,15 @@ import java.util.List;
  */
 public interface TaxRebateExportDetailsBaseService extends IService<TaxRebateExportDetails> {
 
+    /**
+     * 批量更新出口退税明细的支付状态和支付日期
+     * 
+     * @param ids
+     * @param paymentStatus
+     * @param paymentDate
+     */
+    void batchUpdatePaymentStatusAndPaymentDate(List<Long> ids, String paymentStatus, Date paymentDate);
+
     /**
      * 根据条件分页查询退税明细汇总(自营模式下)
      * 

+ 9 - 0
trade-service/src/main/java/com/trade/service/trade/exportrebate/service/impl/TaxRebateExportDetailsBaseServiceImpl.java

@@ -7,6 +7,7 @@ import com.github.pagehelper.PageHelper;
 import com.trade.common.constant.HttpStatus;
 import com.trade.common.core.page.GridPage;
 import com.trade.common.exception.ServiceException;
+import com.trade.service.DictConstants;
 import com.trade.service.trade.exportrebate.dto.*;
 import com.trade.service.trade.exportrebate.dto.search.TaxRebateExportAbstractInfoSearchDto;
 import com.trade.service.trade.exportrebate.dto.search.TaxRebateSearchDto;
@@ -19,6 +20,7 @@ import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -34,6 +36,13 @@ public class TaxRebateExportDetailsBaseServiceImpl extends ServiceImpl<TaxRebate
     @Resource
     private TaxRebateExportDetailsMapper taxRebateExportDetailsMapper;
 
+    @Override
+    public void batchUpdatePaymentStatusAndPaymentDate(List<Long> ids, String paymentStatus, Date paymentDate) {
+        this.lambdaUpdate().in(TaxRebateExportDetails::getId, ids)
+                .set(TaxRebateExportDetails::getPaymentStatus, paymentStatus)
+                .set(paymentDate != null, TaxRebateExportDetails::getPaymentDate, paymentDate).update();
+    }
+
     @Override
     public GridPage<ExportTaxRebateStatisticDto> getPagesBySearch(TaxRebateSearchDto search) {
         Page<ExportTaxRebateStatisticDto> page = PageHelper.startPage(search.getPage(), search.getRows());

+ 4 - 0
trade-service/src/main/java/com/trade/service/trade/salesorder/vo/CustomsDeclarationGoodsBelongsVO.java

@@ -12,6 +12,10 @@ public class CustomsDeclarationGoodsBelongsVO {
      * 销售订单号
      */
     private String salesOrderNo;
+    /**
+     * 销售合同id
+     */
+    private Long salesContractId;
     /**
      * 海关出口商品代码(对应销售订单商品hs_code)
      */

+ 4 - 1
trade-service/src/main/resources/data.init/v1.1/20241022.sql

@@ -17,6 +17,7 @@ CREATE TABLE `tax_rebate_export_details`
     `agency_cert_no`                     varchar(32)                                           DEFAULT NULL COMMENT '代理公司统一社会信用代码/注册号',
     `importer_cert_no`                   varchar(32)                                           DEFAULT NULL COMMENT '进口商统一社会信用代码/注册号',
     `sales_order_no`                     varchar(64)                                           DEFAULT NULL COMMENT '销售订单号',
+    `sales_contract_id`                  bigint(20)                                            DEFAULT NULL COMMENT '销售合同id',
     `declaration_month_year`             varchar(8)                                            DEFAULT NULL COMMENT '申报年月(所属期)',
     `declaration_batch`                  varchar(16)                                           DEFAULT '0' COMMENT '申报批次',
     `declaration_serial_no`              varchar(16)                                           DEFAULT NULL COMMENT '申报序号',
@@ -127,7 +128,9 @@ VALUES ('退税到账状态', 'rebate_payment_status', '0', 'admin', '', NULL );
 INSERT INTO `sys_dict_data` ( `dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `update_by`, `remark`)
 VALUES (0, '未到账', '0', 'rebate_payment_status', NULL, 'default', 'N', '0', 'admin', '', NULL);
 INSERT INTO `sys_dict_data` ( `dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `update_by`, `remark`)
-VALUES (1, '已到账', '1', 'rebate_payment_status', NULL, 'default', 'N', '0', 'admin', '', NULL);
+VALUES (1, '审核中', '1', 'rebate_payment_status', NULL, 'default', 'N', '0', 'admin', '', NULL);
+INSERT INTO `sys_dict_data` ( `dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `update_by`, `remark`)
+VALUES (2, '已到账', '2', 'rebate_payment_status', NULL, 'default', 'N', '0', 'admin', '', NULL);
 
 ALTER TABLE `trade`.`customs_declaration_goods`
 ADD COLUMN `tsjltbbs` tinyint(4) NULL DEFAULT 0 COMMENT '退税记录是否已同步' AFTER `sbsl1`;

+ 8 - 1
trade-service/src/main/resources/mapper/trade/exportrebate/TaxRebateExportDetailsMapper.xml

@@ -129,6 +129,7 @@
         <result property="agencyCertNo" column="agency_cert_no"/>
         <result property="agencyName" column="agency_name"/>
         <result property="status" column="status"/>
+        <result property="selectable" column="selectable"/>
     </resultMap>
 
     <select id="getTaxRebateSummaryDataPagesBySearch"
@@ -143,7 +144,8 @@
         SUM(COALESCE(d.tax_refund_amount,0)) / 10000 AS tax_rebate_total_amount,
         d.agency_cert_no,
         p.platform_name AS agency_name,
-        d.status
+        d.status,
+        SUM(IF(d.payment_status IS NOT NULL AND d.payment_status = '0', 1, 0)) > 0 AS selectable
         FROM tax_rebate_export_details d
         LEFT JOIN (
             SELECT rebate_export_details_id, COUNT(DISTINCT purchase_voucher_no) AS purchase_invoice_count
@@ -184,6 +186,7 @@
         <result property="importerCertNo" column="importer_cert_no"/>
         <result property="importerName" column="importer_name"/>
         <result property="salesOrderNo" column="sales_order_no"/>
+        <result property="salesContractId" column="sales_contract_id"/>
         <result property="declarationMonthYear" column="declaration_month_year"/>
         <result property="declarationBatch" column="declaration_batch"/>
         <result property="declarationSerialNo" column="declaration_serial_no"/>
@@ -215,6 +218,7 @@
         d.importer_cert_no,
         i.entity_name AS importer_name,
         d.sales_order_no,
+        d.sales_contract_id,
         d.declaration_month_year,
         d.declaration_batch,
         d.declaration_serial_no,
@@ -256,6 +260,9 @@
         <if test="importerName != null and importerName != ''">
             AND i.entity_name LIKE CONCAT ('%',#{importerName},'%')
         </if>
+        <if test="paymentStatus != null and paymentStatus != ''">
+            AND d.payment_status = #{paymentStatus}
+        </if>
     </select>
 
 </mapper>

+ 2 - 0
trade-service/src/main/resources/mapper/trade/salesorder/CustomsDeclarationGoodsMapper.xml

@@ -69,6 +69,7 @@ yfhghbzm_dm, bfje, bfhghbzm_dm, zfje1, zfhghbzm_dm, js1, mz2, jz, hgckhwbgdsbrq,
         <result column="importer_cert_no" property="importerCertNo"/>
         <result column="agency_cert_no" property="agencyCertNo"/>
         <result column="has_purchase_contract" property="hasPurchaseContract"/>
+        <result column="sales_contract_id" property="salesContractId"/>
         <result column="xt_user_id" property="xtUserId"/>
         <result column="xt_eid" property="xtEid"/>
     </resultMap>
@@ -77,6 +78,7 @@ yfhghbzm_dm, bfje, bfhghbzm_dm, zfje1, zfhghbzm_dm, js1, mz2, jz, hgckhwbgdsbrq,
             resultMap="BaseResultBelongsMap">
         SELECT a.id,
                a.sale_order_no,
+               o.sale_contract_id AS sales_contract_id,
                a.hgcksp_dm,
                a.ckbgdh,
                a.bgdhgbh,