Ver Fonte

1.产品退回流程发起时设置发票号,详情中显示发票号
2.产品退回发票状态新增-未开发票,相关代码调整
3.个贷我的订单返回是否有出具产品

GouGengquan há 2 meses atrás
pai
commit
e26e356e7e

+ 8 - 0
dao/src/main/java/com/dayou/mapper/FinanceInvoiceMapper.java

@@ -32,4 +32,12 @@ public interface FinanceInvoiceMapper extends CustomBaseMapper<FinanceInvoice> {
     List<FinanceInvoiceVo> getInvoiceAmountInfo(@Param("dto") MajorProductionSimpleDTO simpleDTO);
 
     List<FinanceInvoiceVo> getInvoiceAmountInfoEmptyProduction(@Param("dto") MajorProductionSimpleDTO simpleDTO);
+
+    /**
+     * 根据收款信息获取发票号
+     * @param orderFundId 订单收款信息
+     * @param productionFundId 产品收款信息
+     * @return String
+     */
+    String getInvoiceNoByFundId(@Param("orderFundId") Long orderFundId, @Param("productionFundId") Long productionFundId);
 }

+ 11 - 0
dao/src/main/resources/mapper/FinanceInvoiceMapper.xml

@@ -224,4 +224,15 @@
             ) invoice ON invoice.order_fund_id = orderFund.id
 
     </select>
+
+    <!--根据收款信息获取发票号-->
+    <select id="getInvoiceNoByFundId" resultType="java.lang.String">
+        SELECT GROUP_CONCAT(ticket_no SEPARATOR ',')
+        FROM finance_invoice
+        WHERE finance_invoice.deleted = 0
+          AND finance_invoice.order_fund_id = #{orderFundId}
+          <if test="productionFundId != null">
+              AND finance_invoice.production_fund_id = #{productionFundId}
+          </if>
+    </select>
 </mapper>

+ 1 - 2
dao/src/main/resources/mapper/PersonalMapper.xml

@@ -466,7 +466,7 @@
         p.save_file_date,
         o.id as orderFundId,
         fi.invoiceAmount,
-        pro.repertory_state
+        (SELECT IF(COUNT(id) > 0, TRUE, FALSE) FROM personal_production WHERE deleted = 0 AND target_id = pt.id) AS harReport
         from
             personal p
                 LEFT JOIN personal_target pt ON pt.personal_id =  p.id
@@ -478,7 +478,6 @@
                 LEFT JOIN user u3 ON u3.id = p.pricing_staff
                 left join (select id,business_id,real_amount,should_amount from order_fund where business_type='PERSONAL_BUSINESS' and deleted = 0) o on o.business_id = p.id
         left join (select sum(real_amount) as invoiceAmount,order_fund_id from finance_invoice where state ='已开票' and deleted = 0 GROUP BY order_fund_id) fi on fi.order_fund_id = o.id
-        LEFT JOIN personal_production AS pro ON p.deleted = 0 AND pt.id = pro.target_id AND pro.production = 'FINAL'
         where
             p.deleted = 0  and p.client_manager_id = #{personal.clientManagerId}
         <if test="keyword!=null and keyword!='' ">

+ 6 - 1
domain/src/main/java/com/dayou/entity/ProductionReturn.java

@@ -101,7 +101,7 @@ public class ProductionReturn extends BaseEntity {
     /**
      * 是否包含退发票
      */
-    private Boolean returnInvoice;
+    private Integer returnInvoice;
 
     /**
      * 审核中、审核通过、审核拒绝 (用代码中的枚举code)
@@ -110,5 +110,10 @@ public class ProductionReturn extends BaseEntity {
     @ExportCell(columnName = "审核中、审核通过、审核拒绝 (用代码中的枚举code)")
     private String status;
 
+    /**
+     * 发票号
+     */
+    private String invoiceNo;
+
 
 }

+ 1 - 1
domain/src/main/java/com/dayou/enums/FineRefundReasonEnum.java

@@ -6,7 +6,7 @@ package com.dayou.enums;
 public enum FineRefundReasonEnum {
 
     RETURN_PRODUCTION("退产品","RETURN_PRODUCTION"),
-    RETURN_MONEY("退款","RETURN_MONEY"),
+    RETURN_MONEY("产品回款","RETURN_MONEY"),
     RETURN_PRODUCTION_INVOICE("退产品并退发票","RETURN_PRODUCTION_INVOICE"),
     ;
 

+ 1 - 1
domain/src/main/java/com/dayou/vo/FinanceFineRefundVO.java

@@ -99,7 +99,7 @@ public class FinanceFineRefundVO {
     /**
      * 退款原因(RETURN_PRODUCTION: 退产品,RETURN_MONEY:退款,RETURN_PRODUCTION_INVOICE:退产品并退发票)
      */
-    @Excel(name = "退款原因", readConverterExp ="RETURN_PRODUCTION=退产品,RETURN_MONEY=退款,RETURN_PRODUCTION_INVOICE=退产品并退发票")
+    @Excel(name = "退款原因", readConverterExp ="RETURN_PRODUCTION=退产品,RETURN_MONEY=产品回款,RETURN_PRODUCTION_INVOICE=退产品并退发票")
     private String refundReason;
 
     /**

+ 2 - 2
domain/src/main/java/com/dayou/vo/PersonalVO.java

@@ -214,9 +214,9 @@ public class PersonalVO extends Personal {
     private Set<Long> userIds;
 
     /**
-     * 结果报告库存状态
+     * 是否已出具报告
      */
-    private Boolean repertoryState;
+    private Boolean harReport;
 
     /**
      * 项目作废(查询条件)

+ 2 - 2
domain/src/main/java/com/dayou/vo/ProductionReturnVO.java

@@ -74,8 +74,8 @@ public class ProductionReturnVO {
     /**
      * 是否包含退发票
      */
-    @Excel(name = "是否包含退发票", readConverterExp = "true=是,false=否")
-    private Boolean returnInvoice;
+    @Excel(name = "是否包含退发票", readConverterExp = "0=不退发票,1=退发票,2=未开发票")
+    private Integer returnInvoice;
 
     /**
      * 审核中、审核通过、审核拒绝 (用代码中的枚举code)

+ 37 - 0
service/src/main/java/com/dayou/service/impl/ProductionReturnServiceImpl.java

@@ -1,13 +1,21 @@
 package com.dayou.service.impl;
 
+import cn.hutool.core.util.ObjectUtil;
 import com.dayou.common.BaseEntity;
 import com.dayou.dto.ProductionReturnSelectDTO;
 import com.dayou.dto.WorkNodeCommit;
+import com.dayou.entity.FinanceFine;
+import com.dayou.entity.OrderFund;
+import com.dayou.entity.ProductionFund;
 import com.dayou.entity.ProductionReturn;
 import com.dayou.enums.workflow.NodeLogEnum;
 import com.dayou.exception.BusinessException;
 import com.dayou.exception.ErrorCode;
+import com.dayou.mapper.FinanceInvoiceMapper;
 import com.dayou.mapper.ProductionReturnMapper;
+import com.dayou.service.IFinanceFineService;
+import com.dayou.service.IOrderFundService;
+import com.dayou.service.IProductionFundService;
 import com.dayou.service.IProductionReturnService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.dayou.service.workflow.IWorkFlowService;
@@ -53,6 +61,15 @@ public class ProductionReturnServiceImpl extends ServiceImpl<ProductionReturnMap
     private ProductionReturnMapper productionReturnMapper;
 
     @Autowired
+    private IProductionFundService productionFundService;
+
+    @Autowired
+    private IOrderFundService orderFundService;
+
+    @Autowired
+    private FinanceInvoiceMapper financeInvoiceMapper;
+
+    @Autowired
     private IWorkFlowService workFlowService;
 
     /**
@@ -199,6 +216,26 @@ public class ProductionReturnServiceImpl extends ServiceImpl<ProductionReturnMap
     @Override
     @Transactional(rollbackFor = Exception.class)
     public Boolean add(ProductionReturn productionReturn){
+        Long orderFundId = null;
+        Long productionFundId = null;
+        // 获取收款信息
+        OrderFund orderFund = orderFundService.getOne(new LambdaQueryWrapper<OrderFund>()
+                .eq(BaseEntity::getDeleted, false)
+                .eq(OrderFund::getBusinessType, productionReturn.getBusinessType())
+                .eq(OrderFund::getBusinessId, productionReturn.getBusinessId()));
+        if(ObjectUtil.isNotNull(orderFund)) { // 判断有没有订单收款信息
+            ProductionFund productionFund = productionFundService.getOne(new LambdaQueryWrapper<ProductionFund>()
+                    .eq(BaseEntity::getDeleted, false)
+                    .eq(ProductionFund::getBusinessType, productionReturn.getBusinessType())
+                    .eq(ProductionFund::getBusinessId, productionReturn.getBusinessId())
+                    .eq(ProductionFund::getProductionNo, productionReturn.getProductionNo())
+                    .eq(ProductionFund::getProductionType, productionReturn.getProductionType())
+                    .eq(ProductionFund::getOrderFundId, orderFund.getId()));
+            orderFundId = orderFund.getId();
+            productionFundId = productionFund != null ? productionFund.getId() : null;
+        }
+        // 获取发票号
+        productionReturn.setInvoiceNo(financeInvoiceMapper.getInvoiceNoByFundId(orderFundId, productionFundId));
         Integer count = productionReturnMapper.count(productionReturn);
         if (count > 0) {
             ErrorCode.throwBusinessException(ErrorCode.CUSTOM_ERROR, "当前已有审核中或已通过的流程,无需重复提交");

+ 1 - 1
service/src/main/java/com/dayou/workflow/config/WorkNodeProcessable.java

@@ -219,7 +219,7 @@ public class WorkNodeProcessable {
                                     .refundAmount(financeFine.getRealFineAmount())
                                     .status(NOT_RETURNED.getCode())
                                     .build();
-                            if (productionReturn.getReturnInvoice()) {
+                            if (productionReturn.getReturnInvoice() == 1) { // 等于1说明还要退发票
                                 financeFineRefund.setRefundReason(RETURN_PRODUCTION_INVOICE.getCode());
                             } else {
                                 financeFineRefund.setRefundReason(RETURN_PRODUCTION.getCode());

+ 9 - 1
sql/update_sql.sql

@@ -867,4 +867,12 @@ CREATE TABLE `personal_face_price` (
                                        `created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
                                        `modified` timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6) COMMENT '修改时间',
                                        PRIMARY KEY (`id`)
-) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4  COMMENT='口估执行记录';
+) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4  COMMENT='口估执行记录';
+
+/**
+  日期:2025-04-29
+  修改人:苟耕铨
+  未更新到test-env
+ */
+ALTER TABLE `production_return` ADD `invoice_no` varchar ( 255 ) NULL COMMENT '发票号';
+ALTER TABLE `production_return` MODIFY `return_invoice` int ( 1 ) NOT NULL COMMENT '退发票状态(0:不退发票,1:退发票,2:未开发票)';