Przeglądaj źródła

大中型我的订单应收款逻辑修改涉及到认领实收款到产品。不支持认领到订单上。

wucl 10 miesięcy temu
rodzic
commit
0cc6f5afc8

+ 6 - 0
biz-base/src/main/java/com/dayou/controller/FinanceRealFundController.java

@@ -1,6 +1,7 @@
 package com.dayou.controller;
 
 import cn.hutool.core.collection.CollectionUtil;
+import com.dayou.annotation.DataPermission;
 import com.dayou.dto.FinanceRealFundExportDTO;
 import com.dayou.utils.ExcelOneToManyExportUtils;
 import com.dayou.vo.*;
@@ -20,6 +21,9 @@ import java.util.List;
 import javax.servlet.http.HttpServletResponse;
 import javax.validation.Valid;
 
+import static com.dayou.common.Constants.FINANCE_DEPARTMENT;
+import static com.dayou.common.Constants.MANAGER_OFFICE;
+
 /**
  * 财务实收款
  *
@@ -84,6 +88,7 @@ public class FinanceRealFundController extends BaseController {
      * @param page
      * @return
      */
+    @DataPermission(postChild = false,ignoreDepartment = {MANAGER_OFFICE,FINANCE_DEPARTMENT})
     @GetMapping("/overdue/major")
     public RestResponse<Page<MajorProdOverdueVO>> overdueMajor(MajorProdOverdueVO overdueVO, Page page){
         Page<MajorProdOverdueVO> result = financeRealFundService.overdueMajor(overdueVO,page);
@@ -97,6 +102,7 @@ public class FinanceRealFundController extends BaseController {
      * @param overdueVO
      * @return
      */
+    @DataPermission(postChild = false,ignoreDepartment = {MANAGER_OFFICE,FINANCE_DEPARTMENT})
     @GetMapping("/overdue/major/export")
     public void overdueMajorExport(MajorProdOverdueVO overdueVO, HttpServletResponse response)throws IOException {
         List<MajorProdOverdueVO> result = financeRealFundService.overdueMajorExport(overdueVO);

+ 4 - 1
dao/src/main/resources/mapper/FinanceClaimMapper.xml

@@ -35,10 +35,13 @@
             fc.created,
             orf.order_id,
             orf.order_name,
-            orf.remark
+            orf.remark,
+            off.production_should_amount,
+            off.production_no
         FROM
             finance_claim fc
                 LEFT JOIN order_fund orf ON fc.order_fund_id = orf.id
+                LEFT JOIN ( SELECT id,order_fund_id,production_no,production_should_amount FROM production_fund WHERE deleted = 0) off  ON (off.order_fund_id = fc.order_fund_id  and fc.production_fund_id = off.id)
                 LEFT JOIN user u ON u.id = fc.claim_user_id
         WHERE
             fc.real_fund_id = #{realFundId}

+ 30 - 21
dao/src/main/resources/mapper/FinanceRealFundMapper.xml

@@ -104,10 +104,12 @@
         u1.NAME AS principal,
         cc1.NAME AS clientName,
         cc2.NAME AS clientSubName,
-        pf.production_should_amount,
-        ofu.should_amount,
+        pf.production_should_amount as shouldAmount,
         mp.*
         FROM
+        ( SELECT business_id, production_no, production_should_amount, real_amount FROM production_fund WHERE business_type = 'MAJOR_BUSINESS'
+        AND deleted = 0 and production_should_amount is not null and real_amount is null)  pf
+        left join
         (
         SELECT
         id,
@@ -122,31 +124,38 @@
         major_production mp
         WHERE
         deleted = 0
-        AND repertory_out_time IS NOT NULL  and production != 'STATEMENT'
+        AND repertory_out_time IS NOT NULL
         ) mp
-        LEFT JOIN ( SELECT business_id, production_no, production_should_amount, real_amount FROM production_fund WHERE business_type = 'MAJOR_BUSINESS' AND deleted = 0 ) pf ON ( mp.major_id = pf.business_id AND mp.report_no = pf.production_no )
-        left join ( SELECT business_id,should_amount FROM order_fund WHERE business_type = 'MAJOR_BUSINESS' AND deleted = 0 ) ofu ON ofu.business_id = mp.major_id
+        ON ( mp.major_id = pf.business_id AND mp.report_no = pf.production_no )
+
         LEFT JOIN major m ON m.id = mp.major_id
         LEFT JOIN user u ON u.id = m.client_manager_id
         LEFT JOIN user u1 ON u1.id = m.principal_id
         LEFT JOIN customer_company cc1 ON cc1.id = m.clientele_id
         LEFT JOIN customer_company cc2 ON cc2.id = m.clientele_sub_id
-        WHERE
-        mp.production != 'STATEMENT'
-        AND ( pf.production_no IS NULL OR pf.real_amount IS NULL )
-        AND DATEDIFF(CURDATE(),DATE( mp.repertory_out_time )) >= #{overdueVO.overdueMin}
-        <if test="overdueVO!=null and overdueVO.overdueMax!=null">
-            AND DATEDIFF(CURDATE(),DATE( mp.repertory_out_time )) &lt;= #{overdueVO.overdueMax}
-        </if>
-        <if test="overdueVO!=null and overdueVO.orderId!=null and overdueVO.orderId!=''">
-            and m.order_id = #{overdueVO.orderId}
-        </if>
-        <if test="overdueVO!=null and overdueVO.reportNo!=null and overdueVO.reportNo!=''">
-            and mp.report_no like concat ('%',#{overdueVO.reportNo},'%')
-        </if>
-        <if test="overdueVO!=null and overdueVO.principal!=null and overdueVO.principal!=''">
-            and u1.NAME like concat ('%',#{overdueVO.principal},'%')
-        </if>
+        <where>
+            <if test="overdueVO!=null and overdueVO.overdueMin!=null">
+                AND DATEDIFF(CURDATE(),DATE( mp.repertory_out_time )) >= #{overdueVO.overdueMin}
+            </if>
+            <if test="overdueVO!=null and overdueVO.overdueMax!=null">
+                AND DATEDIFF(CURDATE(),DATE( mp.repertory_out_time )) &lt;= #{overdueVO.overdueMax}
+            </if>
+            <if test="overdueVO!=null and overdueVO.orderId!=null and overdueVO.orderId!=''">
+                and m.order_id = #{overdueVO.orderId}
+            </if>
+            <if test="overdueVO!=null and overdueVO.reportNo!=null and overdueVO.reportNo!=''">
+                and mp.report_no like concat ('%',#{overdueVO.reportNo},'%')
+            </if>
+            <if test="overdueVO!=null and overdueVO.principal!=null and overdueVO.principal!=''">
+                and u1.NAME like concat ('%',#{overdueVO.principal},'%')
+            </if>
+            <if test="overdueVO!=null and overdueVO.userIds!=null and overdueVO.userIds.size!=0">
+                and m.client_manager_id in
+                <foreach collection="overdueVO.userIds" open="(" close=")" separator="," item="userId">
+                    #{userId}
+                </foreach>
+            </if>
+        </where>
         order by overdueDay desc
     </sql>
     <select id="overdueMajor" parameterType="com.dayou.vo.MajorProdOverdueVO" resultType="com.dayou.vo.MajorProdOverdueVO">

+ 36 - 10
dao/src/main/resources/mapper/MajorProductionMapper.xml

@@ -270,7 +270,9 @@
         <result column="businessId" property="businessId" />
         <result column="order_id" property="orderId" />
         <result column="orderName" property="orderName" />
+        <result column="production" property="production" />
         <result column="productionNo" property="productionNo" />
+        <result column="evaluate_amount" property="evaluateAmount" />
         <result column="if_save_file" property="ifSaveFile" />
         <result column="principal" property="principal" />
         <result column="clientManager" property="clientManager" />
@@ -282,6 +284,10 @@
         <result column="orderFundId" property="orderFundId" />
         <result column="should_amount" property="shouldAmount" />
         <result column="real_amount" property="realAmount" />
+        <result column="shouldAmount" property="shouldAmount" />
+        <result column="orderShouldAmount" property="orderShouldAmount" />
+        <result column="orderRealAmount" property="orderRealAmount" />
+        <result column="productionFundId" property="productionFundId" />
         <result column="created" property="created" />
         <result column="remark" property="remark" />
         <result column="mDeclareResult" property="mDeclareResult" />
@@ -313,7 +319,9 @@
             m.order_id,
             m.name as orderName,
             mp.report_no as productionNo,
+            mp.production,
             mp.if_save_file,
+            mp.evaluate_amount,
             u.name as principal,
             u1.name as clientManager,
             cc.name as clienteleName,
@@ -323,21 +331,26 @@
             m.owner,
             m.created,
             orf.id as orderFundId,
-            orf.should_amount,
-            orf.real_amount,
-            orf.remark,
+            orf.should_amount as orderShouldAmount,
+            orf.real_amount as orderRealAmount,
+            pf.remark,
+            pf.id as productionFundId,
+            pf.real_amount,
+            pf.production_should_amount as shouldAmount,
             ( SELECT declare_result FROM commission_declare WHERE business_id = m.id AND production_id IS NULL AND business_type = 'COMMISSION_DECLARE_MAJOR_MARKET' AND deleted = 0 ) as mDeclareResult,
             ( SELECT declare_result FROM commission_declare WHERE business_id = m.id AND production_id IS NULL AND business_type = 'COMMISSION_DECLARE_MAJOR_EVALUATE' AND deleted = 0 ) as eDeclareResult
         FROM
             major m
-                left join major_production mp on mp.major_id = m.id
+                left join (select id,major_id,report_no,evaluate_amount,production,if_save_file from major_production where deleted = 0 ) mp on mp.major_id = m.id
                 left join user u on u.id = m.principal_id
                 left join user u1 on u1.id = m.client_manager_id
                 left join customer_company cc on cc.id = m.clientele_id
                 left join customer_company cc1 on cc1.id = m.clientele_sub_id
                 left join customer_linkman cl on  cl.id = m.clientele_contact_id
                 left join (select * from order_fund where business_type ='MAJOR_BUSINESS' and deleted = 0) orf on orf.business_id = m.id
-</sql>
+                left join (select * from production_fund where business_type = 'MAJOR_BUSINESS' and deleted = 0) pf on (pf.business_id = m.id and pf.production_no = mp.report_no)
+
+    </sql>
 
     <select id="myOrder" parameterType="com.dayou.vo.MajorOrderVO" resultMap="myOrderMap">
         <include refid="myMajorOrder" />
@@ -357,6 +370,7 @@
             or orf.should_amount like concat('%',#{keyword},'%')
             or orf.real_amount like concat('%',#{keyword},'%')
             or orf.remark like concat('%',#{keyword},'%')
+            or mp.report_no like concat('%',#{keyword},'%')
             )
         </if>
         <if test="vo!=null and vo.principalId!=null and vo.principalId!=''">
@@ -380,6 +394,12 @@
         <if test="vo!=null and vo.endDate!=null and vo.endDate!=''">
             and m.created &lt;= #{vo.endDate}
         </if>
+        <if test="vo!=null and vo.production!=null and vo.production!='ORDER'">
+            AND mp.production = #{vo.production}
+        </if>
+        <if test="vo!=null and vo.production!=null and vo.production=='ORDER'">
+            AND mp.id is null
+        </if>
         order by m.created DESC
     </select>
 
@@ -439,11 +459,17 @@
             mp.if_save_file,
             mp.save_file_date,
             mp.delivery,
-            `of`.should_amount AS orderShouldAmount
+            `of`.should_amount AS orderShouldAmount,
+            pf.production_should_amount as shouldAmount,
+            m.order_id,
+            m.name as orderName,
+            m.id as businessId,
+            `of`.id as orderFundId
         FROM
             major_production mp
-                LEFT JOIN ( SELECT id, business_id, production_no, real_amount, production_type FROM production_fund WHERE business_type = 'MAJOR_BUSINESS' AND deleted = 0 ) pf ON ( mp.major_id = pf.business_id AND mp.report_no = pf.production_no AND mp.production = pf.production_type )
-        LEFT JOIN (SELECT business_id,should_amount FROM order_fund WHERE business_type = 'MAJOR_BUSINESS' AND deleted = 0) AS `of` ON mp.major_id = `of`.business_id
+                left join major m on m.id =mp.major_id
+                LEFT JOIN ( SELECT id, business_id, production_no, real_amount, production_type,production_should_amount FROM production_fund WHERE business_type = 'MAJOR_BUSINESS' AND deleted = 0 ) pf ON ( mp.major_id = pf.business_id AND mp.report_no = pf.production_no AND mp.production = pf.production_type )
+        LEFT JOIN (SELECT id,business_id,should_amount FROM order_fund WHERE business_type = 'MAJOR_BUSINESS' AND deleted = 0) AS `of` ON mp.major_id = `of`.business_id
         WHERE
             mp.major_id = #{majorId} and mp.deleted = 0
 
@@ -588,10 +614,10 @@
             u1.NAME AS clientManager,
             cc.NAME AS clienteleName,
             orf.id AS orderFundId,
-            orf.should_amount,
+            orf.should_amount as orderShouldAmount,
+            off.production_should_amount as shouldAmount,
             off.id as productionFundId,
             off.real_amount,
-            off.standard_amount,
         ifnull(( SELECT declare_result FROM commission_declare WHERE business_id = m.id AND production_id = mp.id AND business_type = 'COMMISSION_DECLARE_MAJOR_MARKET' AND deleted = 0 ),
         ( SELECT declare_result FROM commission_declare WHERE business_id = m.id  and production_id is null AND business_type = 'COMMISSION_DECLARE_MAJOR_MARKET' AND deleted = 0 )) as mDeclareResult,
         ifnull(( SELECT declare_result FROM commission_declare WHERE business_id = m.id AND production_id = mp.id AND business_type = 'COMMISSION_DECLARE_MAJOR_EVALUATE' AND deleted = 0 ),

+ 2 - 0
domain/src/main/java/com/dayou/common/Constants.java

@@ -81,6 +81,8 @@ public interface Constants {
 
     String MANAGER_OFFICE = "总经办";
 
+    String FINANCE_DEPARTMENT = "财务部";
+
     String MARKET_DEPARTMENT = "市场部";
 
     String CUSTOMER_MANAGER = "客户经理";

+ 15 - 0
domain/src/main/java/com/dayou/dto/ProductionDTO.java

@@ -130,4 +130,19 @@ public class ProductionDTO {
      */
     private BigDecimal orderShouldAmount;
 
+    /**
+     * 产品应收款
+     */
+    private BigDecimal shouldAmount;
+
+    private String orderId;
+
+    private String orderName;
+
+    private Long businessId;
+
+    private Long orderFundId;
+
+
+
 }

+ 13 - 0
domain/src/main/java/com/dayou/entity/MajorProduction.java

@@ -246,7 +246,20 @@ public class MajorProduction extends BaseEntity {
      */
     @TableField(exist = false)
     private BigDecimal orderShouldAmount;
+    /**
+     * 产品应收款
+     */
+    @TableField(exist = false)
+    private BigDecimal shouldAmount;
     @TableField(exist = false)
     private Integer printTimes;
+    @TableField(exist = false)
+    private String orderName;
+    @TableField(exist = false)
+    private String orderId;
+    @TableField(exist = false)
+    private Long businessId;
+    @TableField(exist = false)
+    private Long orderFundId;
 
 }

+ 11 - 0
domain/src/main/java/com/dayou/entity/ProductionFund.java

@@ -85,5 +85,16 @@ public class ProductionFund extends BaseEntity {
     @TableField(exist = false)
     private BigDecimal evaluateAmount;
 
+    /**
+     *订单号
+     */
+    @TableField(exist = false)
+    private String orderId;
+    /**
+     *订单名称
+     */
+    @TableField(exist = false)
+    private String orderName;
+
 
 }

+ 4 - 0
domain/src/main/java/com/dayou/vo/FinanceClaimVO.java

@@ -27,4 +27,8 @@ public class FinanceClaimVO extends FinanceClaim {
 
     private String claimName;
 
+    private BigDecimal productionShouldAmount;
+
+    private String productionNo;
+
 }

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

@@ -28,11 +28,16 @@ public class MajorOrderVO {
 
 
     /**
-     * 产品收款id
+     * 订单收款id
      */
     private Long orderFundId;
 
     /**
+     * 产品收款id
+     */
+    private Long productionFundId;
+
+    /**
      * 订单号
      */
     private String orderId;
@@ -85,6 +90,15 @@ public class MajorOrderVO {
      *实收款
      */
     private BigDecimal realAmount;
+
+    /**
+     *订单应收款
+     */
+    private BigDecimal orderShouldAmount;
+    /**
+     *订单实收款
+     */
+    private BigDecimal orderRealAmount;
     /**
      *开票金额
      */
@@ -127,4 +141,8 @@ public class MajorOrderVO {
 
     private Boolean ifSaveFile;
 
+    private String production;
+
+    private BigDecimal evaluateAmount;
+
 }

+ 7 - 0
domain/src/main/java/com/dayou/vo/MajorProdOverdueVO.java

@@ -5,6 +5,8 @@ import lombok.Data;
 
 import java.math.BigDecimal;
 import java.util.Date;
+import java.util.List;
+import java.util.Set;
 
 /**
  * 类说明:大中型逾期未收款VO
@@ -65,5 +67,10 @@ public class MajorProdOverdueVO {
 
     private Integer overdueMax;
 
+    /**
+     * 人员id列表
+     */
+    private Set<Long> userIds;
+
 
 }

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

@@ -154,4 +154,6 @@ public class MajorProductionVO {
 
     private String businessType;
 
+    private BigDecimal orderShouldAmount;
+
 }

+ 10 - 0
service/src/main/java/com/dayou/service/impl/ProductionFundServiceImpl.java

@@ -79,11 +79,21 @@ public class ProductionFundServiceImpl extends ServiceImpl<ProductionFundMapper,
         return this.getById(id);
     }
 
+    @Transactional
     @Override
     public Boolean add(ProductionFund productionFund){
         BigDecimal evaluateAmount = productionFund.getEvaluateAmount();
         BigDecimal standardAmount = calculateStandardAmount(evaluateAmount);
         productionFund.setStandardAmount(standardAmount);
+        if (productionFund.getOrderFundId()==null){
+            OrderFund orderFund = new OrderFund();
+            orderFund.setOrderName(productionFund.getOrderName());
+            orderFund.setOrderId(productionFund.getOrderId());
+            orderFund.setBusinessId(productionFund.getBusinessId());
+            orderFund.setBusinessType(productionFund.getBusinessType());
+            orderFundService.save(orderFund);
+            productionFund.setOrderFundId(orderFund.getId());
+        }
         return  this.save(productionFund);
     }