Преглед на файлове

修改bug:
私有应收 手续费和跟单结算时,实收金额=未结算金额时,回款差额为0且不存在差额原因,结清标识自动确认。实收金额>未结算金额时,存在回款差额,需填写差额原因并展示在结算记录中。实收金额<未结算金额时,回款差额与回款原因不显示或者不可编辑,结算完成后,手动去点选标识结清并且弹出填写框,带出回款差额,填写回款原因并展示在结算记录中

jiakai преди 2 месеца
родител
ревизия
3c8fe28ca6

+ 23 - 0
commons/src/main/java/com/jzg/commons/entity/finance/vo/UpdateSettlementStatusVo.java

@@ -0,0 +1,23 @@
+package com.jzg.commons.entity.finance.vo;
+
+import com.jzg.commons.core.base.PageRequest;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * @author quchen
+ * @date 2025/7/31 17:59
+ */
+
+@Data
+public class UpdateSettlementStatusVo extends PageRequest {
+
+    @Schema(description = "开票id")
+    private String invoiceId;
+
+    @Schema(description = "回款原因")
+    private String settlementPaymentReason;
+
+}

+ 3 - 3
tenant/organization/src/main/java/com/jzg/organization/controller/ReceivableController.java

@@ -759,13 +759,13 @@ public class ReceivableController {
     /**
     /**
      * 设置指定发票为结算完成状态
      * 设置指定发票为结算完成状态
      *
      *
-     * @param invoiceId 发票序号
+     * @param updateSettlementStatusVo 发票序号
      * @author lipf
      * @author lipf
      * @date 2026/6/11 9:33
      * @date 2026/6/11 9:33
      */
      */
     @PostMapping("updateSettlementStatus")
     @PostMapping("updateSettlementStatus")
-    public HttpResult<String> updateSettlementStatus(@RequestParam("id") String invoiceId){
-        int count = receivableService.updateSettlementStatus(invoiceId);
+    public HttpResult<String> updateSettlementStatus(@RequestBody UpdateSettlementStatusVo updateSettlementStatusVo){
+        int count = receivableService.updateSettlementStatus(updateSettlementStatusVo);
         if(count>0){
         if(count>0){
             return HttpResult.ok("订单被标记为结算完成");
             return HttpResult.ok("订单被标记为结算完成");
         }else{
         }else{

+ 2 - 2
tenant/organization/src/main/java/com/jzg/organization/service/ReceivableService.java

@@ -492,11 +492,11 @@ public interface ReceivableService extends IService<InsPlyIncome> {
     /**
     /**
      * 设置指定发票为结算完成状态
      * 设置指定发票为结算完成状态
      *
      *
-     * @param invoiceId 发票序号
+     * @param updateSettlementStatusVo 发票序号
      * @author lipf
      * @author lipf
      * @date 2026/6/11 9:33
      * @date 2026/6/11 9:33
      */
      */
-    int updateSettlementStatus(String invoiceId);
+    int updateSettlementStatus(UpdateSettlementStatusVo updateSettlementStatusVo);
 
 
     /**
     /**
      * 平台协议结算
      * 平台协议结算

+ 23 - 12
tenant/organization/src/main/java/com/jzg/organization/service/impl/ReceivableServiceImpl.java

@@ -768,10 +768,14 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
             resultList.addAll(followAggVoList);
             resultList.addAll(followAggVoList);
         }
         }
 
 
-        // 3. 查询额外其他费用收入数据,补充到结果集
-        List<InsPlyIncomeDto> incomeDtoList = queryFollowIncomeData(settlementReportQueryVo);
-        if (CollUtil.isEmpty(incomeDtoList)) {
-            return resultList;
+        // 应收项为空时才去补充数据,不为空时不补充数据,补充数据是因为联查了invoice和settlement表,所以没开票和结算的数据会被过滤掉,才需要补充数据
+        List<InsPlyIncomeDto> incomeDtoList = CollUtil.newArrayList();
+        if (StrUtil.isBlank(settlementReportQueryVo.getInvoiceType())){
+            // 3. 查询额外其他费用收入数据,补充到结果集
+            incomeDtoList = queryFollowIncomeData(settlementReportQueryVo);
+            if (CollUtil.isEmpty(incomeDtoList)) {
+                return resultList;
+            }
         }
         }
 
 
         // 4. 根据筛选条件过滤收入数据(发票、结算时间/状态过滤)
         // 4. 根据筛选条件过滤收入数据(发票、结算时间/状态过滤)
@@ -4535,16 +4539,19 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
                         .map(InsPlyIncomeInvoiceSettlement::getActualReceivedAmount)
                         .map(InsPlyIncomeInvoiceSettlement::getActualReceivedAmount)
                         .filter(Objects::nonNull)
                         .filter(Objects::nonNull)
                         .reduce(BigDecimal.ZERO, BigDecimal::add);
                         .reduce(BigDecimal.ZERO, BigDecimal::add);
-//                BigDecimal settlementPaymentDifference = insPlyIncomeInvoiceSettlements.stream()
-//                        .map(InsPlyIncomeInvoiceSettlement::getSettlementPaymentDifference)
-//                        .filter(Objects::nonNull)
-//                        .reduce(BigDecimal.ZERO, BigDecimal::add);
+                BigDecimal settlementPaymentDifference = insPlyIncomeInvoiceSettlements.stream()
+                        .map(InsPlyIncomeInvoiceSettlement::getSettlementPaymentDifference)
+                        .filter(Objects::nonNull)
+                        .reduce(BigDecimal.ZERO, BigDecimal::add);
 
 
                 BigDecimal receivableSupervisePremium = action.getReceivableSupervisePremium()  != null ? action.getReceivableSupervisePremium(): BigDecimal.ZERO;
                 BigDecimal receivableSupervisePremium = action.getReceivableSupervisePremium()  != null ? action.getReceivableSupervisePremium(): BigDecimal.ZERO;
 
 
 //                BigDecimal overinflatedAmount = action.getOverinflatedAmount() != null? action.getOverinflatedAmount(): BigDecimal.ZERO;
 //                BigDecimal overinflatedAmount = action.getOverinflatedAmount() != null? action.getOverinflatedAmount(): BigDecimal.ZERO;
                 // 回款差计算逻辑调整 2026年7月14日09:29:08
                 // 回款差计算逻辑调整 2026年7月14日09:29:08
-                BigDecimal settlementPaymentDifference = BigDecimalUtil.subtract(settlementAmount,receivableSupervisePremium);
+//                BigDecimal settlementPaymentDifference = BigDecimal.ZERO;
+//                if (CollUtil.isNotEmpty(insPlyIncomeInvoiceSettlements) && settlementAmount.compareTo(BigDecimal.ZERO) > 0){
+//                    settlementPaymentDifference = BigDecimalUtil.subtract(settlementAmount,receivableSupervisePremium);
+//                }
                 // 待结算金额 = 开票金额 - 已收金额
                 // 待结算金额 = 开票金额 - 已收金额
                 BigDecimal remainSettlementAmount = receivableSupervisePremium.subtract(BigDecimalUtil.add(settlementAmount, settlementPaymentDifference));
                 BigDecimal remainSettlementAmount = receivableSupervisePremium.subtract(BigDecimalUtil.add(settlementAmount, settlementPaymentDifference));
                 // 设置已结算的金额
                 // 设置已结算的金额
@@ -4554,7 +4561,7 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
                     // 特殊梳理,当待结算金额计算出来为负数时, 设置为0
                     // 特殊梳理,当待结算金额计算出来为负数时, 设置为0
                     remainSettlementAmount = BigDecimal.ZERO;
                     remainSettlementAmount = BigDecimal.ZERO;
                 }
                 }
-                action.setRemainSettlementAmount( remainSettlementAmount);
+                action.setRemainSettlementAmount(remainSettlementAmount);
                 action.setCompanyAllName(allCompanyHierarchyPaths.get(Objects.toString(action.getCompanyId(),"")));
                 action.setCompanyAllName(allCompanyHierarchyPaths.get(Objects.toString(action.getCompanyId(),"")));
                 action.setSettlementStatus(settlementStatusName);
                 action.setSettlementStatus(settlementStatusName);
 
 
@@ -6090,11 +6097,14 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
      * 3. 记录更新人和更新时间
      * 3. 记录更新人和更新时间
      * </p>
      * </p>
      *
      *
-     * @param invoiceId 发票序号,用于定位需要更新的发票记录
+     * @param updateSettlementStatusVo 发票序号,用于定位需要更新的发票记录
      * @return int 返回受影响的记录数,通常为1表示更新成功,0表示更新失败或记录不存在
      * @return int 返回受影响的记录数,通常为1表示更新成功,0表示更新失败或记录不存在
      */
      */
     @Override
     @Override
-    public int updateSettlementStatus(String invoiceId) {
+    public int updateSettlementStatus(UpdateSettlementStatusVo updateSettlementStatusVo) {
+        String invoiceId = updateSettlementStatusVo.getInvoiceId();
+        String settlementPaymentReason = updateSettlementStatusVo.getSettlementPaymentReason();
+
         String userName = baseController.getUserName();
         String userName = baseController.getUserName();
         String systemCode = baseController.getSystemCode();
         String systemCode = baseController.getSystemCode();
         log.info("租户[{}]下的用户[{}]标识发票[{}]为结算完成", systemCode, userName, invoiceId);
         log.info("租户[{}]下的用户[{}]标识发票[{}]为结算完成", systemCode, userName, invoiceId);
@@ -6109,6 +6119,7 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
         if(subtract.compareTo(BigDecimal.ZERO) != 0){
         if(subtract.compareTo(BigDecimal.ZERO) != 0){
             InsPlyIncomeInvoiceSettlement insPlyIncomeInvoiceSettlement = insPlyIncomeInvoiceSettlements.get(0);
             InsPlyIncomeInvoiceSettlement insPlyIncomeInvoiceSettlement = insPlyIncomeInvoiceSettlements.get(0);
             insPlyIncomeInvoiceSettlement.setSettlementPaymentDifference(BigDecimalUtil.add(subtract,insPlyIncomeInvoiceSettlement.getSettlementPaymentDifference()));
             insPlyIncomeInvoiceSettlement.setSettlementPaymentDifference(BigDecimalUtil.add(subtract,insPlyIncomeInvoiceSettlement.getSettlementPaymentDifference()));
+            insPlyIncomeInvoiceSettlement.setSettlementPaymentReason(settlementPaymentReason);
             insPlyIncomeInvoiceSettlementMapper.updateById(insPlyIncomeInvoiceSettlement);
             insPlyIncomeInvoiceSettlementMapper.updateById(insPlyIncomeInvoiceSettlement);
         }
         }
         return insPlyIncomeInvoiceMapper.update(null, new LambdaUpdateWrapper<InsPlyIncomeInvoice>()
         return insPlyIncomeInvoiceMapper.update(null, new LambdaUpdateWrapper<InsPlyIncomeInvoice>()

+ 2 - 2
tenant/organization/src/main/resources/mapper/ReceivableMapper.xml

@@ -1481,7 +1481,7 @@
         eic.name as company_name,
         eic.name as company_name,
         eic.name_simple as companyNameSimple,
         eic.name_simple as companyNameSimple,
         sum( ipiis.actual_received_amount ) AS actual_received_amount,
         sum( ipiis.actual_received_amount ) AS actual_received_amount,
-        GROUP_CONCAT(DISTINCT ipiis.settlement_payment_reason SEPARATOR ',') AS settlement_payment_reason,
+        GROUP_CONCAT(DISTINCT ipiis.settlement_payment_reason SEPARATOR ',') AS paymentReason,
         ipii.status,
         ipii.status,
         ipii.payment_reason
         ipii.payment_reason
         FROM
         FROM
@@ -1552,7 +1552,7 @@
         eic.name_simple as companyNameSimple,
         eic.name_simple as companyNameSimple,
         sum( ipiis.actual_received_amount ) AS actual_received_amount,
         sum( ipiis.actual_received_amount ) AS actual_received_amount,
         ipii.status,
         ipii.status,
-        GROUP_CONCAT(DISTINCT iffo.falsely_increased_reason SEPARATOR ',') as paymentReason,
+        GROUP_CONCAT(DISTINCT ipiis.settlement_payment_reason SEPARATOR ',') as paymentReason,
         GROUP_CONCAT(DISTINCT iffo.year SEPARATOR ',') AS year,
         GROUP_CONCAT(DISTINCT iffo.year SEPARATOR ',') AS year,
         GROUP_CONCAT(DISTINCT iffo.month SEPARATOR ',') AS month,
         GROUP_CONCAT(DISTINCT iffo.month SEPARATOR ',') AS month,
         iffo.partner_company_id,
         iffo.partner_company_id,