Browse Source

我的收款接口

wanglang 2 weeks ago
parent
commit
69de16a049
18 changed files with 514 additions and 12 deletions
  1. 6 0
      trade-admin/src/main/java/com/trade/admin/finance/disbursement/service/impl/BBillingDisbursementServiceImpl.java
  2. 10 1
      trade-admin/src/main/java/com/trade/admin/finance/paymentcollection/service/impl/BPaymentCollectionServiceImpl.java
  3. 1 1
      trade-admin/src/main/java/com/trade/admin/trade/exportrebate/service/impl/ExportTaxRebateServiceImpl.java
  4. 53 0
      trade-client/src/main/java/com/trade/client/accounts/receivepayment/controller/ReceivePaymentController.java
  5. 30 0
      trade-client/src/main/java/com/trade/client/accounts/receivepayment/dto/DocumentInfoDto.java
  6. 31 0
      trade-client/src/main/java/com/trade/client/accounts/receivepayment/service/ReceivePaymentService.java
  7. 83 0
      trade-client/src/main/java/com/trade/client/accounts/receivepayment/service/impl/ReceivePaymentServiceImpl.java
  8. 29 0
      trade-client/src/main/java/com/trade/client/accounts/receivepayment/vo/ReceivePaymentDetailVo.java
  9. 10 1
      trade-service/src/main/java/com/trade/service/finance/constant/BillingConstant.java
  10. 5 5
      trade-service/src/main/java/com/trade/service/finance/disbursement/domain/BillingDisbursement.java
  11. 27 0
      trade-service/src/main/java/com/trade/service/finance/disbursement/dto/ExportTaxRefundSelfDto.java
  12. 42 0
      trade-service/src/main/java/com/trade/service/finance/disbursement/dto/ReceivePaymentSearchDto.java
  13. 10 0
      trade-service/src/main/java/com/trade/service/finance/disbursement/mapper/BillingDisbursementMapper.java
  14. 21 0
      trade-service/src/main/java/com/trade/service/finance/disbursement/service/BillingDisbursementService.java
  15. 54 0
      trade-service/src/main/java/com/trade/service/finance/disbursement/service/impl/BillingDisbursementServiceImpl.java
  16. 46 0
      trade-service/src/main/java/com/trade/service/finance/disbursement/vo/ReceivePaymentPageVo.java
  17. 1 1
      trade-service/src/main/java/com/trade/service/finance/paymentcollection/dto/ExportTaxRefundV2Dto.java
  18. 55 3
      trade-service/src/main/resources/mapper/finance/disbursement/BillingDisbursementMapper.xml

+ 6 - 0
trade-admin/src/main/java/com/trade/admin/finance/disbursement/service/impl/BBillingDisbursementServiceImpl.java

@@ -192,6 +192,12 @@ public class BBillingDisbursementServiceImpl implements BBillingDisbursementServ
         // billingDisbursement.setPaymentDate(paymentBasicInfo.getPaymentDate());
         billingDisbursement.setStatus(BillingConstant.DISBURSEMENT_STATUS_UNCONFIRMED);
         billingDisbursement.setPaymentType(separateAccountsInfo.getLedgerType());
+        if (BillingConstant.PAYMENT_TYPE_TAX_REFUND.equals(separateAccounts.getPaymentType())) {
+            billingDisbursement.setPayeeType(BillingConstant.PAYEE_TYPE_CUSTOMER);
+            billingDisbursement.setPayerType(BillingConstant.PAYERTYPE_AGENT);
+        }
+        billingDisbursement.setPayerName(separateAccounts.getAgencyEnterpriseName());
+        billingDisbursement.setSource(1);
         billingDisbursement
                 .setBusinessNumber(BizNoUtil.generateBusinessNumber(separateAccounts.getBusinessNumber(), 2));
         billingDisbursementService.save(billingDisbursement);

+ 10 - 1
trade-admin/src/main/java/com/trade/admin/finance/paymentcollection/service/impl/BPaymentCollectionServiceImpl.java

@@ -1,5 +1,6 @@
 package com.trade.admin.finance.paymentcollection.service.impl;
 
+import com.alibaba.fastjson2.JSON;
 import com.github.pagehelper.Page;
 import com.github.pagehelper.PageHelper;
 import com.trade.admin.business.separateaccounts.service.BSeparateAccountsService;
@@ -8,10 +9,12 @@ import com.trade.admin.finance.paymentcollection.dto.BillingIncomeDetailDto;
 import com.trade.admin.finance.paymentcollection.dto.BillingIncomeInfoDto;
 import com.trade.admin.finance.paymentcollection.service.BPaymentCollectionService;
 import com.trade.admin.system.security.utils.SecurityUtils;
+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.LoggerUtil;
+import com.trade.common.utils.StringUtils;
 import com.trade.common.utils.bean.BeanCopyUtils;
 import com.trade.common.validate.ValidatorGroup;
 import com.trade.common.validate.ValidatorUtil;
@@ -79,6 +82,8 @@ public class BPaymentCollectionServiceImpl implements BPaymentCollectionService
     private EnterpriseBaseService enterpriseBaseService;
     @Resource
     private FilingDocService filingDocService;
+    @Resource
+    private ExportTaxRebateService exportTaxRebateService;
 
     @Override
     public GridPage<BillingIncomePageVo> queryListByPage(BillingIncomeSearchDto incomeSearchDto) {
@@ -190,6 +195,10 @@ public class BPaymentCollectionServiceImpl implements BPaymentCollectionService
             billingIncomeInfo.setAccountNumber(reviewDto.getAccountNumber());
             billingIncomeInfo.setVoucherNo(reviewDto.getVoucherNo());
             billingIncomeInfoService.updateById(billingIncomeInfo);
+            if (StringUtils.isNotEmpty(billingIncomeInfo.getDetailIds())) {
+                List<Long> detailIds = JSON.parseArray(billingIncomeInfo.getDetailIds(), Long.class);
+                exportTaxRebateService.refundExportTaxAuditPassed(detailIds);
+            }
         }
         separateAccountsService.saveSeparateAccounts(income, userNickName);
         try {
@@ -198,7 +207,7 @@ public class BPaymentCollectionServiceImpl implements BPaymentCollectionService
             }
         } catch (Exception e) {
             log.error("新增备案单证写入任务失败,sale_order_no={}", income.getSaleOrderNo());
-            e.printStackTrace();
+            log.error("新增备案单证写入任务失败,异常信息={}", e.getMessage());
         }
         return true;
     }

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

@@ -203,7 +203,7 @@ public class ExportTaxRebateServiceImpl implements ExportTaxRebateService {
             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()
+            List<Long> detailIds = records.stream().map(o -> o.getId()).distinct()
                     .collect(Collectors.toList());
             recordIds.addAll(
                     records.stream().map(TaxRebateExportAbstractInfo::getId).distinct().collect(Collectors.toList()));

+ 53 - 0
trade-client/src/main/java/com/trade/client/accounts/receivepayment/controller/ReceivePaymentController.java

@@ -0,0 +1,53 @@
+package com.trade.client.accounts.receivepayment.controller;
+
+import com.trade.client.accounts.receivepayment.service.ReceivePaymentService;
+import com.trade.client.accounts.receivepayment.vo.ReceivePaymentDetailVo;
+import com.trade.common.core.domain.ResponseResult;
+import com.trade.common.core.page.GridPage;
+import com.trade.service.finance.disbursement.dto.ReceivePaymentSearchDto;
+import com.trade.service.finance.disbursement.vo.ReceivePaymentPageVo;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+
+/**
+ * @description:
+ * @Author: wanglang
+ * @Date: 2024/10/31 17:25
+ * @Version: 1.0
+ */
+@Api(tags = "我的收款接口", value = "我的收款接口")
+@RestController
+@RequestMapping("/receivePayment")
+public class ReceivePaymentController {
+
+    @Resource
+    private ReceivePaymentService receivePaymentService;
+
+    /**
+     * 获取我的收款列表分页
+     *
+     * @param searchDto 我的收款列表分页信息条件
+     * @return 我的收款列表分页信息
+     */
+    @ApiOperation(value = "获取我的收款列表分页", notes = "获取我的收款列表分页")
+    @PostMapping("/get/page")
+    public ResponseResult<GridPage<ReceivePaymentPageVo>> queryListByPage(
+            @RequestBody ReceivePaymentSearchDto searchDto) {
+        return ResponseResult.success(receivePaymentService.queryListByPage(searchDto));
+    }
+
+    /**
+     * 获取我的收款详情
+     *
+     * @param id 收款id
+     * @return 收款详情
+     */
+    @ApiOperation(value = "获取我的收款详情", notes = "获取我的收款详情")
+    @GetMapping("/get/detail")
+    public ResponseResult<ReceivePaymentDetailVo> queryDetailById(Long id) {
+        return ResponseResult.success(receivePaymentService.queryDetailById(id));
+    }
+}

+ 30 - 0
trade-client/src/main/java/com/trade/client/accounts/receivepayment/dto/DocumentInfoDto.java

@@ -0,0 +1,30 @@
+package com.trade.client.accounts.receivepayment.dto;
+
+import com.trade.service.filestorage.dto.FileAbstractDto;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * @description:
+ * @Author: wanglang
+ * @Date: 2024/10/31
+ * @Version: 1.0
+ */
+@ApiModel(value = "单据信息", description = "单据信息")
+@Data
+public class DocumentInfoDto {
+
+    @ApiModelProperty(name = "category", value = "合同单据类别")
+    private String category;
+    @ApiModelProperty(name = "documentNumber", value = "合同单据编号")
+    private String documentNumber;
+    @ApiModelProperty(name = "documentName", value = "合同单据名称")
+    private String documentName;
+    @ApiModelProperty(name = "documentDate", value = "合同单据日期")
+    private String documentDate;
+    @ApiModelProperty(name = "documentFile", value = "单据文件")
+    private FileAbstractDto documentFile;
+    @ApiModelProperty(name = "orderNumber", value = "订单编号")
+    private String orderNumber;
+}

+ 31 - 0
trade-client/src/main/java/com/trade/client/accounts/receivepayment/service/ReceivePaymentService.java

@@ -0,0 +1,31 @@
+package com.trade.client.accounts.receivepayment.service;
+
+import com.trade.client.accounts.receivepayment.vo.ReceivePaymentDetailVo;
+import com.trade.service.finance.disbursement.dto.ReceivePaymentSearchDto;
+import com.trade.service.finance.disbursement.vo.ReceivePaymentPageVo;
+import com.trade.common.core.page.GridPage;
+
+/**
+ * @description: 收款服务接口
+ * @Author: wanglang
+ * @Date: 2024/10/31
+ * @Version: 1.0
+ */
+public interface ReceivePaymentService {
+
+    /**
+     * 分页查询收款记录
+     * 
+     * @param searchDto
+     * @return 分页信息
+     */
+    GridPage<ReceivePaymentPageVo> queryListByPage(ReceivePaymentSearchDto searchDto);
+
+    /**
+     * 根据id查询收款详情
+     * 
+     * @param id 收款id
+     * @return 收款详情
+     */
+    ReceivePaymentDetailVo queryDetailById(Long id);
+}

+ 83 - 0
trade-client/src/main/java/com/trade/client/accounts/receivepayment/service/impl/ReceivePaymentServiceImpl.java

@@ -0,0 +1,83 @@
+package com.trade.client.accounts.receivepayment.service.impl;
+
+import com.github.pagehelper.Page;
+import com.github.pagehelper.PageHelper;
+import com.trade.client.accounts.receivepayment.vo.ReceivePaymentDetailVo;
+import com.trade.client.enterprise.customer.domain.CustomerUser;
+import com.trade.client.enterprise.customer.service.CustomerUserService;
+import com.trade.common.exception.ServiceException;
+import com.trade.common.utils.ConstantUtil;
+import com.trade.common.utils.LoggerUtil;
+import com.trade.service.finance.disbursement.domain.BillingDisbursement;
+import com.trade.service.finance.disbursement.dto.ReceivePaymentSearchDto;
+import com.trade.client.accounts.receivepayment.service.ReceivePaymentService;
+import com.trade.service.finance.disbursement.vo.ReceivePaymentPageVo;
+import com.trade.common.core.page.GridPage;
+import com.trade.service.finance.disbursement.service.BillingDisbursementService;
+import com.trade.service.trade.salescontract.domain.ContractTerms;
+import com.trade.service.trade.salescontract.domain.SalesContract;
+import com.trade.service.trade.salescontract.service.ContractTermsService;
+import com.trade.service.trade.salescontract.service.SalesContractService;
+import org.slf4j.Logger;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @description: 收款服务实现类
+ * @Author: wanglang
+ * @Date: 2024/10/31
+ * @Version: 1.0
+ */
+@Service
+public class ReceivePaymentServiceImpl implements ReceivePaymentService {
+
+    private static final Logger log = LoggerUtil.logger(LoggerUtil.LogFileNameEnum.SERVICES_LOG);;
+    @Resource
+    private BillingDisbursementService billingDisbursementService;
+    @Resource
+    private CustomerUserService customerUserService;
+    @Resource
+    private SalesContractService salesContractService;
+    @Resource
+    private ContractTermsService contractTermsService;
+
+    @Override
+    public GridPage<ReceivePaymentPageVo> queryListByPage(ReceivePaymentSearchDto searchDto) {
+        CustomerUser customerUser = customerUserService.getCustomerUser();
+        searchDto.setCustomerUserId(customerUser.getId());
+        Page<ReceivePaymentPageVo> page = PageHelper.startPage(searchDto.getPage(), searchDto.getRows());
+        List<ReceivePaymentPageVo> voList = billingDisbursementService.queryPageForCustomer(searchDto);
+        return new GridPage<>(searchDto.getPage(), searchDto.getRows(), page.getTotal(), voList);
+    }
+
+    @Override
+    public ReceivePaymentDetailVo queryDetailById(Long id) {
+        BillingDisbursement billingDisbursement = billingDisbursementService.getById(id);
+        if (billingDisbursement == null) {
+            throw new ServiceException("收款记录数据不存在");
+        }
+        ReceivePaymentDetailVo vo = new ReceivePaymentDetailVo();
+        vo.setBillingDisbursement(billingDisbursement);
+        SalesContract salesContract = salesContractService.getByContractNo(billingDisbursement.getSalesContractNo(),
+                billingDisbursement.getCustomerUserId());
+        if (salesContract == null) {
+            log.error("销售合同不存在,销售合同编号:{}", billingDisbursement.getSalesContractNo());
+            return vo;
+        }
+        ContractTerms contractTerms = contractTermsService.getByContractIdAndType(salesContract.getId(),
+                ConstantUtil.SALES_CONTRACT_NO_PREFIX);
+        if (contractTerms == null) {
+            log.error("销售合同条款不存在,销售合同编号:{}", billingDisbursement.getSalesContractNo());
+            return vo;
+        }
+        vo.setAccountNumber(contractTerms.getAccountNumber());
+        vo.setAccountName(contractTerms.getAccountName());
+        vo.setOpeningBank(contractTerms.getOpeningBank());
+        // 单据处理
+
+        return vo;
+    }
+}

+ 29 - 0
trade-client/src/main/java/com/trade/client/accounts/receivepayment/vo/ReceivePaymentDetailVo.java

@@ -0,0 +1,29 @@
+package com.trade.client.accounts.receivepayment.vo;
+
+import com.trade.client.accounts.receivepayment.dto.DocumentInfoDto;
+import com.trade.service.finance.disbursement.domain.BillingDisbursement;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * @description:
+ * @Author: wanglang
+ * @Date: 2024/10/31
+ * @Version: 1.0
+ */
+@Data
+public class ReceivePaymentDetailVo {
+
+    @ApiModelProperty(name = "billingDisbursement", value = "收款信息/贸易基础信息")
+    private BillingDisbursement billingDisbursement;
+    @ApiModelProperty(name = "documentInfoDto", value = "单据信息")
+    private DocumentInfoDto documentInfoDto;
+    @ApiModelProperty(name = "accountName", value = "账户名称")
+    private String accountName;
+    @ApiModelProperty(name = "accountNumber", value = "账号")
+    private String accountNumber;
+    @ApiModelProperty(name = "openingBank", value = "开户行名称")
+    private String openingBank;
+    // todo 融资相关信息 融资部分再做
+
+}

+ 10 - 1
trade-service/src/main/java/com/trade/service/finance/constant/BillingConstant.java

@@ -32,9 +32,18 @@ public class BillingConstant {
     public static final String PAYMENT_STATUS_CONFIRMING = "3";
     // 出账已确认
     public static final String PAYMENT_STATUS_CONFIRMED = "4";
-
     // 出账状态 待确认
     public static final String DISBURSEMENT_STATUS_UNCONFIRMED = "1";
     // 已确认
     public static final String DISBURSEMENT_STATUS_CONFIRMED = "2";
+    // 客户
+    public static final String PAYEE_TYPE_CUSTOMER = "1";
+    // 资金方
+    public static final String PAYEE_TYPE_FUNDER = "2";
+    // 付款方类型 代理公司
+    public static final String PAYERTYPE_AGENT = "1";
+    // 付款方类型 资金方
+    public static final String PAYERTYPE_FUNDER = "2";
+    // 付款方类型 税务局
+    public static final String PAYERTYPE_TAXATION_BUREAU = "3";
 }

+ 5 - 5
trade-service/src/main/java/com/trade/service/finance/disbursement/domain/BillingDisbursement.java

@@ -4,9 +4,6 @@
  */
 package com.trade.service.finance.disbursement.domain;
 
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.extension.activerecord.Model;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import com.trade.common.core.domain.BizBaseEntity;
 import io.swagger.annotations.ApiModel;
@@ -56,7 +53,7 @@ public class BillingDisbursement extends BizBaseEntity {
     private String financierIdentifier;
     @ApiModelProperty(name = "paymentType", value = "款项类型分账类型1出口退税款2贸易回款3预收货款4贸易融资款5贷款差额6贷款结汇差额")
     private String paymentType;
-    @ApiModelProperty(name = "status", value = "入账状态1待确认2已收款")
+    @ApiModelProperty(name = "status", value = "入账状态1待确认2已完成")
     private String status;
     @ApiModelProperty(name = "transactionNumber", value = "交易编号")
     private String transactionNumber;
@@ -72,11 +69,14 @@ public class BillingDisbursement extends BizBaseEntity {
     private String entryBusinessNumber;
     @ApiModelProperty(name = "payeeType", value = "收款方类型1客户2资金方")
     private String payeeType;
+    @ApiModelProperty(name = "payerType", value = "付款方类型1代理公司2资金方3税务局")
+    private String payerType;
+    @ApiModelProperty(name = "payerName", value = "付款方名称")
+    private String payerName;
     @ApiModelProperty(name = "source", value = "来源1B端2C端")
     private Integer source;
     @ApiModelProperty(name = "voucherNo", value = "凭证号")
     private String voucherNo;
     @ApiModelProperty(name = "accountNumber", value = "付款银行账号")
-    @NotEmpty(message = "付款银行账号不能为空")
     private String accountNumber;
 }

+ 27 - 0
trade-service/src/main/java/com/trade/service/finance/disbursement/dto/ExportTaxRefundSelfDto.java

@@ -0,0 +1,27 @@
+package com.trade.service.finance.disbursement.dto;
+
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * @description: 自营出口退税
+ * @Author: wanglang
+ * @Date: 2024/10/31
+ * @Version: 1.0
+ */
+@Data
+public class ExportTaxRefundSelfDto {
+
+    /**
+     * 海关报关单号(18位)
+     */
+    private String customsDeclarationNo;
+    // 合同id
+    private Long saleContractId;
+    // 已认证退税记录“认证日期”。
+    private Date rzrq;
+    // 退税金额
+    private BigDecimal refundAmount;
+}

+ 42 - 0
trade-service/src/main/java/com/trade/service/finance/disbursement/dto/ReceivePaymentSearchDto.java

@@ -0,0 +1,42 @@
+package com.trade.service.finance.disbursement.dto;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.trade.common.core.page.PageDomain;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.time.LocalDate;
+
+/**
+ * @description:
+ * @Author: wanglang
+ * @Date: 2024/10/31 16:18
+ * @Version: 1.0
+ */
+@Data
+public class ReceivePaymentSearchDto extends PageDomain {
+
+    @ApiModelProperty(name = "customerUserId", value = "客户id")
+    private Long customerUserId;
+    @ApiModelProperty(name = "businessNumber", value = "业务编号")
+    private String businessNumber;
+    @ApiModelProperty(name = "paymentType", value = "款项类型分账类型1出口退税款2贸易回款3预收货款4贸易融资款5贷款差额6贷款结汇差额")
+    private String paymentType;
+    @ApiModelProperty(name = "salesContractNo", value = "销售合同编号")
+    private String salesContractNo;
+    @ApiModelProperty(name = "importerCertNo", value = "进口商统一社会信用代码/注册号")
+    private String importerCertNo;
+    @ApiModelProperty(name = "payerType", value = "付款方类型1代理公司2资金方3税务局")
+    private String payerType;
+    @ApiModelProperty(name = "payerName", value = "付款方名称")
+    private String payerName;
+    @ApiModelProperty(name = "beginTime", value = "付款日期开始")
+    @DateTimeFormat(pattern = "yyyy-MM-dd")
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    private LocalDate beginTime;
+    @ApiModelProperty(name = "endTime", value = "付款日期结束")
+    @DateTimeFormat(pattern = "yyyy-MM-dd")
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    private LocalDate endTime;
+}

+ 10 - 0
trade-service/src/main/java/com/trade/service/finance/disbursement/mapper/BillingDisbursementMapper.java

@@ -7,7 +7,9 @@ package com.trade.service.finance.disbursement.mapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.trade.service.finance.disbursement.domain.BillingDisbursement;
 import com.trade.service.finance.disbursement.dto.DisbursementSearchDto;
+import com.trade.service.finance.disbursement.dto.ReceivePaymentSearchDto;
 import com.trade.service.finance.disbursement.vo.BillingDisbursementPageVo;
+import com.trade.service.finance.disbursement.vo.ReceivePaymentPageVo;
 import org.apache.ibatis.annotations.Mapper;
 
 import java.util.List;
@@ -27,4 +29,12 @@ public interface BillingDisbursementMapper extends BaseMapper<BillingDisbursemen
      * @return List<SeparateAccounts>
      */
     List<BillingDisbursementPageVo> selectByPage(DisbursementSearchDto searchDto);
+
+    /**
+     * 分页查询 C端
+     * 
+     * @param searchDto
+     * @return
+     */
+    List<ReceivePaymentPageVo> selectByPageForCustomer(ReceivePaymentSearchDto searchDto);
 }

+ 21 - 0
trade-service/src/main/java/com/trade/service/finance/disbursement/service/BillingDisbursementService.java

@@ -8,7 +8,12 @@ import com.baomidou.mybatisplus.extension.service.IService;
 import com.trade.common.core.page.GridPage;
 import com.trade.service.finance.disbursement.domain.BillingDisbursement;
 import com.trade.service.finance.disbursement.dto.DisbursementSearchDto;
+import com.trade.service.finance.disbursement.dto.ExportTaxRefundSelfDto;
+import com.trade.service.finance.disbursement.dto.ReceivePaymentSearchDto;
 import com.trade.service.finance.disbursement.vo.BillingDisbursementPageVo;
+import com.trade.service.finance.disbursement.vo.ReceivePaymentPageVo;
+
+import java.util.List;
 
 /**
  * @Description:出账表服务层
@@ -24,4 +29,20 @@ public interface BillingDisbursementService extends IService<BillingDisbursement
      * @return GridPage<BillingDisbursementPageVo>
      */
     GridPage<BillingDisbursementPageVo> queryListByPage(DisbursementSearchDto searchDto);
+
+    /**
+     * 分页查询 C端
+     *
+     * @param searchDto
+     * @return
+     */
+    List<ReceivePaymentPageVo> queryPageForCustomer(ReceivePaymentSearchDto searchDto);
+
+    /**
+     * 保存自营的出口退税信息
+     * 
+     * @param selfDtos
+     * @return true/false
+     */
+    boolean saveSelfTaxRefund(List<ExportTaxRefundSelfDto> selfDtos);
 }

+ 54 - 0
trade-service/src/main/java/com/trade/service/finance/disbursement/service/impl/BillingDisbursementServiceImpl.java

@@ -4,17 +4,28 @@
  */
 package com.trade.service.finance.disbursement.service.impl;
 
+import cn.hutool.core.collection.CollectionUtil;
 import com.github.pagehelper.Page;
 import com.github.pagehelper.PageHelper;
 import com.trade.common.core.page.GridPage;
+import com.trade.common.utils.DateUtils;
+import com.trade.common.utils.LoggerUtil;
+import com.trade.service.finance.constant.BillingConstant;
 import com.trade.service.finance.disbursement.domain.BillingDisbursement;
 import com.trade.service.finance.disbursement.dto.DisbursementSearchDto;
+import com.trade.service.finance.disbursement.dto.ExportTaxRefundSelfDto;
+import com.trade.service.finance.disbursement.dto.ReceivePaymentSearchDto;
 import com.trade.service.finance.disbursement.mapper.BillingDisbursementMapper;
 import com.trade.service.finance.disbursement.service.BillingDisbursementService;
 import com.trade.service.finance.disbursement.vo.BillingDisbursementPageVo;
+import com.trade.service.finance.disbursement.vo.ReceivePaymentPageVo;
+import com.trade.service.trade.salescontract.dto.SalesContractDto;
+import com.trade.service.trade.salescontract.service.SalesContractService;
+import org.slf4j.Logger;
 import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 
+import javax.annotation.Resource;
 import java.util.List;
 
 /**
@@ -25,10 +36,53 @@ import java.util.List;
 @Service
 public class BillingDisbursementServiceImpl extends ServiceImpl<BillingDisbursementMapper, BillingDisbursement> implements BillingDisbursementService {
 
+    private static final Logger log = LoggerUtil.logger(LoggerUtil.LogFileNameEnum.SERVICES_LOG);;
+    @Resource
+    private SalesContractService salesContractService;
+
     @Override
     public GridPage<BillingDisbursementPageVo> queryListByPage(DisbursementSearchDto searchDto) {
         Page<BillingDisbursementPageVo> page = PageHelper.startPage(searchDto.getPage(), searchDto.getRows());
         List<BillingDisbursementPageVo> voList = this.baseMapper.selectByPage(searchDto);
         return new GridPage<>(searchDto.getPage(), searchDto.getRows(), page.getTotal(), voList);
     }
+
+    @Override
+    public List<ReceivePaymentPageVo> queryPageForCustomer(ReceivePaymentSearchDto searchDto) {
+        return this.baseMapper.selectByPageForCustomer(searchDto);
+    }
+
+    @Override
+    public boolean saveSelfTaxRefund(List<ExportTaxRefundSelfDto> selfDtos) {
+        if (CollectionUtil.isEmpty(selfDtos)) {
+            return false;
+        }
+        for (ExportTaxRefundSelfDto selfDto : selfDtos) {
+            SalesContractDto salesContractDto = salesContractService.getSalesContractById(selfDto.getSaleContractId());
+            if (salesContractDto == null) {
+                log.error("销售合同id={}合同不存在", selfDto.getSaleContractId());
+                continue;
+            }
+            BillingDisbursement billingDisbursement = new BillingDisbursement();
+            billingDisbursement.setSalesContractNo(salesContractDto.getContractNo());
+            billingDisbursement.setCustomerUserId(salesContractDto.getCustomerUserId());
+            billingDisbursement.setPaymentAmount(selfDto.getRefundAmount());
+            billingDisbursement.setPaymentCurrency("CNY");
+            billingDisbursement.setAgencyCertNo(salesContractDto.getAgencyCertNo());
+            billingDisbursement.setAgencyEnterpriseName(salesContractDto.getAgencyEnterpriseName());
+            // 自营的是没有代理公司信息的 根据需求页面 设置这里为"税务局"
+            billingDisbursement.setPayerName("税务局");
+            billingDisbursement.setImporterCertNo(salesContractDto.getImporterCertNo());
+            billingDisbursement.setImporterEnterpriseName(salesContractDto.getImporterEnterpriseName());
+            billingDisbursement.setPaymentType(BillingConstant.PAYMENT_TYPE_TAX_REFUND);
+            billingDisbursement.setStatus(BillingConstant.DISBURSEMENT_STATUS_CONFIRMED);
+            billingDisbursement.setSource(2);
+            billingDisbursement.setPayeeType(BillingConstant.PAYEE_TYPE_CUSTOMER);
+            billingDisbursement.setPayerType(BillingConstant.PAYERTYPE_TAXATION_BUREAU);
+            billingDisbursement.setPaymentDate(DateUtils.parseDate2LocalDate(selfDto.getRzrq()));
+            billingDisbursement.setBusinessNumber(selfDto.getCustomsDeclarationNo());
+            this.save(billingDisbursement);
+        }
+        return true;
+    }
 }

+ 46 - 0
trade-service/src/main/java/com/trade/service/finance/disbursement/vo/ReceivePaymentPageVo.java

@@ -0,0 +1,46 @@
+package com.trade.service.finance.disbursement.vo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.math.BigDecimal;
+import java.time.LocalDate;
+
+/**
+ * @description:
+ * @Author: wanglang
+ * @Date: 2024/10/31
+ * @Version: 1.0
+ */
+@Data
+public class ReceivePaymentPageVo {
+
+    @ApiModelProperty(name = "id", value = "主键id")
+    private Long id;
+    @ApiModelProperty(name = "businessNumber", value = "业务编号")
+    private String businessNumber;
+    @ApiModelProperty(name = "paymentType", value = "款项类型分账类型1出口退税款2贸易回款3预收货款4贸易融资款5贷款差额6贷款结汇差额")
+    private String paymentType;
+    @ApiModelProperty(name = "receivePaymentAmount", value = "收款金额")
+    private BigDecimal receivePaymentAmount;
+    @ApiModelProperty(name = "receivePaymentCurrency", value = "收款金额币种代码")
+    private String receivePaymentCurrency;
+    @ApiModelProperty(name = "salesContractNo", value = "合同编号")
+    private String salesContractNo;
+    @ApiModelProperty(name = "contractName", value = "合同名称")
+    private String contractName;
+    @ApiModelProperty(name = "importerCertNo", value = "进口商统一社会信用代码/注册号")
+    private String importerCertNo;
+    @ApiModelProperty(name = "importerEnterpriseName", value = "进口商企业名称")
+    private String importerEnterpriseName;
+    @ApiModelProperty(name = "payerType", value = "付款方类型1代理公司2资金方3税务局")
+    private String payerType;
+    @ApiModelProperty(name = "payerName", value = "付款方名称")
+    private String payerName;
+    @ApiModelProperty(name = "paymentDate", value = "付款日期")
+    @DateTimeFormat(pattern = "yyyy-MM-dd")
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    private LocalDate paymentDate;
+}

+ 1 - 1
trade-service/src/main/java/com/trade/service/finance/paymentcollection/dto/ExportTaxRefundV2Dto.java

@@ -24,7 +24,7 @@ public class ExportTaxRefundV2Dto {
      */
     private String declarationBatch;
     // 出口明细表id
-    private List<String> detailIds;
+    private List<Long> detailIds;
     // 退税金额
     private BigDecimal refundAmount;
     // 银行账号

+ 55 - 3
trade-service/src/main/resources/mapper/finance/disbursement/BillingDisbursementMapper.xml

@@ -29,6 +29,8 @@
         <id column="separate_accounts_info_id" property="separateAccountsInfoId"/>
         <id column="voucher_no" property="voucherNo"/>
         <id column="account_number" property="accountNumber"/>
+        <id column="payer_type" property="payerType"/>
+        <id column="payer_name" property="payerName"/>
     </resultMap>
 
     <resultMap id="PageResultMap" type="com.trade.service.finance.disbursement.vo.BillingDisbursementPageVo">
@@ -55,7 +57,7 @@
     </resultMap>
     <sql id="Base_Column_List">
         id
-        , voucher_no, account_number
+        , voucher_no, account_number, payer_type, payer_name
         , customer_user_id, payment_basic_id, separate_accounts_info_id, business_number, entry_business_number, sales_contract_no, contract_name, importer_cert_no, importer_enterprise_name, agency_cert_no, agency_enterprise_name, financier_identifier, payment_type, status, transaction_number, payment_amount, payment_currency, payment_date, payee_type, source, deleted, gmt_create, gmt_modified
     </sql>
     <select id="selectByPage"
@@ -65,10 +67,10 @@
         t1.id, t1.sales_contract_no, t1.contract_name, t1.importer_cert_no, t1.importer_enterprise_name,
         t1.agency_cert_no, t1.agency_enterprise_name, t1.financier_identifier, t1.payment_type, t1.status,
         t1.transaction_number, t1.business_number, t1.payment_amount, t1.payment_currency, t1.payment_date,
-        t1.entry_business_number, t1.payee_type, t1.gmt_create
+        t1.entry_business_number, t1.payee_type, t1.gmt_create,
         e.name AS enterprise_name, e.customer_identifier_no
         from billing_disbursement t1 left join enterprise e on t1.customer_user_id = e.customer_id
-        where t1.deleted = 0
+        where t1.deleted = 0 and source = 1
         <if test="paymentType != null and paymentType != ''">
             AND t1.payment_type = #{paymentType}
         </if>
@@ -99,4 +101,54 @@
         ORDER BY t1.gmtCreate DESC
     </select>
 
+
+    <resultMap id="PageCResultMap" type="com.trade.service.finance.disbursement.vo.ReceivePaymentPageVo">
+        <id column="id" property="id"/>
+        <id column="business_number" property="businessNumber"/>
+        <id column="sales_contract_no" property="salesContractNo"/>
+        <id column="contract_name" property="contractName"/>
+        <id column="importer_cert_no" property="importerCertNo"/>
+        <id column="importer_enterprise_name" property="importerEnterpriseName"/>
+        <id column="payer_name" property="payerName"/>
+        <id column="payment_type" property="paymentType"/>
+        <id column="payer_type" property="payerType"/>
+        <id column="payment_amount" property="receivePaymentAmount"/>
+        <id column="payment_currency" property="receivePaymentCurrency"/>
+        <id column="payment_date" property="paymentDate"/>
+    </resultMap>
+
+    <select id="selectByPageForCustomer"
+            resultMap="PageCResultMap"
+            resultType="com.trade.service.finance.disbursement.dto.ReceivePaymentSearchDto">
+        select
+        t1.id, t1.sales_contract_no, t1.contract_name, t1.importer_cert_no, t1.importer_enterprise_name,
+        t1.payer_name, t1.payment_type, t1.payer_type,
+        t1.business_number, t1.payment_amount, t1.payment_currency, t1.payment_date
+        from billing_disbursement t1 where t1.deleted = 0
+        <if test="customerUserId != null">
+            AND t1.customer_user_id = #{customerUserId}
+        </if>
+        <if test="paymentType != null and paymentType != ''">
+            AND t1.payment_type = #{paymentType}
+        </if>
+        <if test="agencyCertNo != null and agencyCertNo != ''">
+            AND t1.agency_cert_no = #{agencyCertNo}
+        </if>
+        <if test="payerType != null and payerType != ''">
+            AND t1.payer_type = #{payerType}
+        </if>
+        <if test="contractNo != null and contractNo != ''">
+            AND t1.sales_contract_no = #{contractNo}
+        </if>
+        <if test="payerName != null and payerName != ''">
+            AND t1.payer_name = #{payerName}
+        </if>
+        <if test="beginTime != null">
+            AND t1.payment_date <![CDATA[ >= ]]> #{beginTime}
+        </if>
+        <if test="endTime != null">
+            AND t1.payment_date <![CDATA[ <= ]]> #{endTime}
+        </if>
+        ORDER BY t1.payment_date DESC
+    </select>
 </mapper>