Pārlūkot izejas kodu

实收款认领推荐

wucl 10 mēneši atpakaļ
vecāks
revīzija
1cf24700d0

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

@@ -47,6 +47,15 @@ public class FinanceRealFundController extends BaseController {
     }
 
     /**
+     * 财务实收款认领列表
+     */
+    @GetMapping("/claim")
+    public RestResponse<Page<FinanceRealFundVO>> claimPage(FinanceRealFund financeRealFund, Page page,String keyword){
+        Page<FinanceRealFundVO> pages=financeRealFundService.claimPage(page,financeRealFund,keyword);
+        return RestResponse.data(pages);
+    }
+
+    /**
      * 财务实收款详情
      */
     @GetMapping("/{id}")

+ 4 - 0
dao/src/main/java/com/dayou/mapper/FinanceRealFundMapper.java

@@ -22,6 +22,8 @@ public interface FinanceRealFundMapper extends CustomBaseMapper<FinanceRealFund>
 
     Page<FinanceRealFundVO> getPage(Page page, @Param("vo") FinanceRealFund vo,@Param("keyword") String keyword);
 
+    Page<FinanceRealFundVO> claimPage(Page page, @Param("vo") FinanceRealFund vo,@Param("keyword")  String keyword);
+
     BigDecimal getNotClaimAmount(@Param("realFundId") Long realFundId);
 
     Page<MajorProdOverdueVO> overdueMajor(Page page, @Param("overdueVO")MajorProdOverdueVO overdueVO);
@@ -158,4 +160,6 @@ public interface FinanceRealFundMapper extends CustomBaseMapper<FinanceRealFund>
     List<PersonalOverdueVO> overduePersonalList(@Param("overdueVO") PersonalOverdueVO overdueVO);
 
     List<FinanceRealFundExportDTO> exportList(Page page,@Param("vo") FinanceRealFund vo,@Param("keyword") String keyword);
+
+
 }

+ 3 - 1
dao/src/main/resources/mapper/FinanceInvoiceMapper.xml

@@ -49,11 +49,13 @@
             orf.order_id,
             orf.order_name,
             (orf.should_amount=orf.real_amount) as isPayAll,
-            u.name AS applyName
+            u.name AS applyName,
+        pf.production_no
         FROM
             finance_invoice fi
                 LEFT JOIN order_fund orf ON fi.order_fund_id = orf.id
                 LEFT JOIN user u ON u.id = fi.apply_id
+        left join production_fund pf on pf.id = fi.production_fund_id
         where fi.deleted = 0 and orf.deleted = 0
           <if test="vo!=null and vo.state!=null and vo.state!='' and vo.state=='审核中' ">
               and (fi.state = '申请作废' or fi.state = '审核中')

+ 59 - 0
dao/src/main/resources/mapper/FinanceRealFundMapper.xml

@@ -78,10 +78,69 @@
         ifnull(t.ca,0) ASC ,frf.created DESC
     </sql>
 
+    <resultMap id="realAmountClaimMap" type="com.dayou.vo.FinanceRealFundVO">
+        <result column="id" property="id" />
+        <result column="created" property="created" />
+        <result column="payer" property="payer" />
+        <result column="payer_bank" property="payerBank" />
+        <result column="payer_account" property="payerAccount" />
+        <result column="amount" property="amount" />
+        <result column="pay_datetime" property="payDatetime" />
+        <result column="remark" property="remark" />
+        <result column="creator_id" property="creatorId" />
+        <result column="creator" property="creator" />
+        <result column="claimAmount" property="claimAmount" />
+        <result column="notClaimAmount" property="notClaimAmount" />
+        <collection property="recommends" select="findRecommends" ofType="java.lang.String" column="amount" />
+     </resultMap>
+
     <select id="getPage" parameterType="com.dayou.entity.FinanceRealFund" resultType="com.dayou.vo.FinanceRealFundVO">
         <include refid="pageListSql" />
     </select>
 
+    <select id="claimPage" parameterType="com.dayou.entity.FinanceRealFund" resultMap="realAmountClaimMap">
+        <include refid="pageListSql" />
+    </select>
+
+    <select id="findRecommends" parameterType="java.math.BigDecimal" resultType="java.lang.String">
+        SELECT
+            tt1.business_type
+        FROM
+            (
+                SELECT
+                    order_fund.business_type,
+                    temp.invoiceAmount
+                FROM
+                    (
+                        SELECT
+                            order_fund_id,
+                            sum( real_amount ) AS invoiceAmount
+                        FROM
+                            finance_invoice
+                        WHERE
+                            state = '已开票'
+                          AND deleted = 0
+                          AND production_fund_id IS NULL
+                        GROUP BY
+                            order_fund_id UNION ALL
+                        SELECT
+                            order_fund_id,
+                            sum( real_amount ) AS invoiceAmount
+                        FROM
+                            finance_invoice
+                        WHERE
+                            state = '已开票'
+                          AND deleted = 0
+                          AND production_fund_id IS NOT NULL
+                        GROUP BY
+                            production_fund_id
+                    ) temp
+                        LEFT JOIN order_fund ON order_fund.id = temp.order_fund_id
+            ) tt1
+        WHERE
+            tt1.invoiceAmount = #{amount}
+    </select>
+
     <select id="getNotClaimAmount" parameterType="java.lang.Long" resultType="java.math.BigDecimal">
         SELECT ( frf.amount -( SELECT ifnull( sum( claim_amount ), 0 ) AS ca FROM finance_claim WHERE deleted = 0 AND real_fund_id = #{realFundId} )
                    ) AS notClaimAmount

+ 9 - 5
dao/src/main/resources/mapper/MajorProductionMapper.xml

@@ -312,7 +312,7 @@
         <result column="productionFundId" property="productionFundId" />
         <result column="created" property="created" />
         <result column="remark" property="remark" />
-        <result column="plan_amount" property="planAmount" />
+        <result column="invoiceAmount" property="invoiceAmount" />
         <result column="delivery" property="delivery" />
         <result column="mDeclareResult" property="mDeclareResult" />
         <result column="eDeclareResult" property="eDeclareResult" />
@@ -361,7 +361,7 @@
             pf.id as productionFundId,
             pf.real_amount,
             pf.production_should_amount as shouldAmount,
-            fi.plan_amount,
+            fi.invoiceAmount,
             mp.delivery,
             ( 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
@@ -375,7 +375,7 @@
                 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
                 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)
-                left join (select plan_amount,order_fund_id,production_fund_id from finance_invoice where state in ('审核中','已开票') and deleted = 0) fi on (fi.order_fund_id = orf.id and fi.production_fund_id = pf.id)
+                left join (select sum(real_amount) as invoiceAmount,order_fund_id,production_fund_id from finance_invoice where state='已开票' and deleted = 0 group by production_fund_id) fi on (fi.order_fund_id = orf.id and fi.production_fund_id = pf.id)
 
     </sql>
 
@@ -645,6 +645,7 @@
             off.production_should_amount as shouldAmount,
             off.id as productionFundId,
             off.real_amount,
+            fi.invoiceAmount,
         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 ),
@@ -657,7 +658,7 @@
                 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 (select sum(real_amount) as invoiceAmount,order_fund_id,production_fund_id from finance_invoice where state='已开票' and deleted = 0 GROUP BY production_fund_id) fi on (fi.order_fund_id = orf.id and fi.production_fund_id = off.id)
         WHERE
             m.deleted = 0
           AND	mp.deleted = 0
@@ -696,7 +697,10 @@
             and ( 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 ) is null
         </if>
         ORDER BY
-            mp.created DESC
+            <if test="vo!=null and vo.invoiceAmount!=null">
+                fi.invoiceAmount=${vo.invoiceAmount} desc,
+            </if>
+                mp.created DESC
     </select>
 
     <update id="cancelDelivery">

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

@@ -338,7 +338,8 @@
             o.real_amount,
             o.should_amount,
             p.save_file_date,
-            o.id as orderFundId
+            o.id as orderFundId,
+            fi.invoiceAmount
         from
             personal p
                 LEFT JOIN personal_target pt ON pt.personal_id =  p.id
@@ -349,6 +350,7 @@
                 LEFT JOIN user u2 ON u2.id = p.inward_staff
                 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
         where
             p.deleted = 0  and p.client_manager_id = #{personal.clientManagerId}
         <if test="keyword!=null and keyword!='' ">

+ 3 - 0
domain/src/main/java/com/dayou/vo/FinanceRealFundVO.java

@@ -4,6 +4,7 @@ import com.dayou.entity.FinanceRealFund;
 import lombok.Data;
 
 import java.math.BigDecimal;
+import java.util.List;
 
 /**
  * 类说明:
@@ -20,4 +21,6 @@ public class FinanceRealFundVO extends FinanceRealFund {
     private BigDecimal claimAmount;
 
     private BigDecimal notClaimAmount;
+
+    private List<String> recommends;
 }

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

@@ -156,4 +156,6 @@ public class MajorProductionVO {
 
     private BigDecimal orderShouldAmount;
 
+    private BigDecimal invoiceAmount;
+
 }

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

@@ -145,4 +145,6 @@ public class PersonalVO extends Personal {
     private String comments;
 
     private Long orderFundId;
+
+    private BigDecimal invoiceAmount;
 }

+ 2 - 0
service/src/main/java/com/dayou/service/IFinanceRealFundService.java

@@ -185,4 +185,6 @@ public interface IFinanceRealFundService extends IService<FinanceRealFund> {
     List<PersonalOverdueVO> overduePersonalList(PersonalOverdueVO overdueVO);
 
     List<FinanceRealFundExportDTO> exportList(FinanceRealFund financeRealFund, String keyword,Page page);
+
+    Page<FinanceRealFundVO> claimPage(Page page, FinanceRealFund financeRealFund, String keyword);
 }

+ 8 - 0
service/src/main/java/com/dayou/service/impl/FinanceRealFundServiceImpl.java

@@ -64,6 +64,13 @@ public class FinanceRealFundServiceImpl extends ServiceImpl<FinanceRealFundMappe
 
 
     @Override
+    public Page<FinanceRealFundVO> claimPage(Page page, FinanceRealFund financeRealFund, String keyword) {
+        Page<FinanceRealFundVO> ret = financeRealFundMapper.claimPage(page,financeRealFund,keyword);
+        return ret;
+    }
+
+
+    @Override
     public FinanceRealFund detail(Long id){
         return this.getById(id);
     }
@@ -367,4 +374,5 @@ public class FinanceRealFundServiceImpl extends ServiceImpl<FinanceRealFundMappe
     public List<FinanceRealFundExportDTO> exportList(FinanceRealFund financeRealFund, String keyword,Page page) {
         return financeRealFundMapper.exportList(page,financeRealFund,keyword);
     }
+
 }