Kaynağa Gözat

预收实收又原先的存在判断逻辑改为通过审核表的auditstatus字段联合查询
金额明细app查询慢去除实收的金额逻辑判断,查询语句只返回需要的字段
添加存储过程将原先未审核的数据显示出来
CREATE DEFINER=`root`@`localhost` PROCEDURE `updateInsAreaCompanyProductnew3`()
BEGIN
DECLARE sub_id VARCHAR(100);
DECLARE order_no VARCHAR(100);
DECLARE done INT ;
DECLARE cur_sub_id CURSOR FOR SELECT id,orderno FROM ins_area_company WHERE orderstatus = 3 AND id NOT IN ( SELECT ins_order_no FROM ins_fee_audit);
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1 ;
OPEN cur_sub_id ;
cursor_loop :
LOOP FETCH cur_sub_id INTO sub_id,order_no;

IF done = 1 THEN LEAVE cursor_loop ;
END IF ;
insert into ins_fee_audit values(order_no,sub_id,'0',now(),'admin');
END LOOP cursor_loop ;
COMMIT ;
CLOSE cur_sub_id;
END

hxl13994548489 2 yıl önce
ebeveyn
işleme
b445f28d9d

+ 16 - 10
src/main/java/com/ydtech/modules/admin/service/impl/SysUserAccountServiceImpl.java

@@ -36,7 +36,6 @@ import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 
 import java.math.BigDecimal;
-import java.time.LocalDate;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashMap;
@@ -371,7 +370,12 @@ public class SysUserAccountServiceImpl extends ServiceImpl<SysUserAccountMapper,
 
         return sysUserAccount;
     }
-
+    /**
+     *  @version
+     *  @author: hxl
+     *  @Date: 2024/6/11 16:05
+     *  @Description: 注释掉实收的总金额提升查询效率
+     */
     @Override
     public SysUserAccountVo getSysAllAmount(String userId) {
         SysUserAccountVo sysUserAccountVo = new SysUserAccountVo();
@@ -384,16 +388,16 @@ public class SysUserAccountServiceImpl extends ServiceImpl<SysUserAccountMapper,
         BigDecimal willHalding = BigDecimal.ZERO;        //预收手续费佣金
         BigDecimal willDocumentary = BigDecimal.ZERO;   //预收 非跟单佣金
         BigDecimal willPromotion = BigDecimal.ZERO;   //预收 推广
-        BigDecimal receivedWillHalding = BigDecimal.ZERO;        //实收手续费佣金
-        BigDecimal receivedWillDocumentary = BigDecimal.ZERO;   //实收非跟单佣金
-        BigDecimal receivedWillPromotion = BigDecimal.ZERO;   //实收推广费
+        //BigDecimal receivedWillHalding = BigDecimal.ZERO;        //实收手续费佣金
+       // BigDecimal receivedWillDocumentary = BigDecimal.ZERO;   //实收非跟单佣金
+       // BigDecimal receivedWillPromotion = BigDecimal.ZERO;   //实收推广费
         // 预收手续费佣金
         willPromotion = this.willPromotionAll(willPromotion, userId,"1");
         // 实收手续费佣金
-        receivedWillPromotion = this.willPromotionAll(willPromotion, userId,"2");
+        //receivedWillPromotion = this.willPromotionAll(willPromotion, userId,"2");
         // add by   hxl  修改sql 添加承保状态和不在审核表中的条件   begin ===============
         List<InsFeeOrderNew> willList = insFeeOrderNewService.getByUserIdAndOrderStatusAndNoCheckType(userId,"1");
-        List<InsFeeOrderNew> willListnew = insFeeOrderNewService.getByUserIdAndOrderStatusAndNoCheckType(userId,"2");
+        //List<InsFeeOrderNew> willListnew = insFeeOrderNewService.getByUserIdAndOrderStatusAndNoCheckType(userId,"2");
         if (!CollectionUtils.isEmpty(willList)) {
             for (InsFeeOrderNew item : willList) {
                 if (ObjectUtils.isNotEmpty(item)) {
@@ -403,6 +407,7 @@ public class SysUserAccountServiceImpl extends ServiceImpl<SysUserAccountMapper,
                 }
             }
         }
+        /**
         if (!CollectionUtils.isEmpty(willListnew)) {
             for (InsFeeOrderNew item : willListnew) {
                 if (ObjectUtils.isNotEmpty(item)) {
@@ -412,14 +417,15 @@ public class SysUserAccountServiceImpl extends ServiceImpl<SysUserAccountMapper,
                 }
             }
         }
+         **/
         //预收手续费佣金
         sysUserAccountVo.setWillHalding(willPromotion);
         //预收非跟单佣金
         sysUserAccountVo.setWillDocumentary(willDocumentary);
         //实收手续费佣金
-        sysUserAccountVo.setReceivedWillHalding(receivedWillHalding);
+        //sysUserAccountVo.setReceivedWillHalding(receivedWillHalding);
         //实收非跟单佣金
-        sysUserAccountVo.setReceivedWillDocumentary(receivedWillDocumentary);
+        //sysUserAccountVo.setReceivedWillDocumentary(receivedWillDocumentary);
         //提现现中 手续费、非跟单、推广费
         HashMap<String, Object> params = new HashMap<>();
         params.put("auditingStatus", "2");  // 待审核
@@ -435,7 +441,7 @@ public class SysUserAccountServiceImpl extends ServiceImpl<SysUserAccountMapper,
         //预收手续费佣金
         sysUserAccountVo.setWillPromotion(willPromotion);
         //实收手续费佣金
-        sysUserAccountVo.setReceivedWillPromotion(receivedWillPromotion);
+       // sysUserAccountVo.setReceivedWillPromotion(receivedWillPromotion);
         return sysUserAccountVo;
     }
 

+ 63 - 29
src/main/resources/mapper/modules/ins/InsFeeOrderNewMapper.xml

@@ -199,10 +199,11 @@
     <select id="getByUserIdAndOrderStatusAndNoCheck"  resultType="com.ydtech.modules.protocols.entity.po.InsFeeOrderNew">
         select a.*  from
             ins_fee_order_new a  left join ins_area_company ins  on  a.ins_order_no=ins.id
+                                 left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
         WHERE
             a.user_id = #{userId}
           and  ins.orderstatus ='3'
-          and NOT EXISTS (SELECT ins_order_no FROM ins_fee_audit fee where fee.ins_order_no =a.ins_order_no)
+          and iff.auditstatus=0
     </select>
 
     <select id="getSumWillAmount"  resultType="com.ydtech.modules.protocols.entity.po.InsFeeOrderNew">
@@ -220,12 +221,13 @@
         from
         ins_fee_order_new a  left join ins_area_company ins  on  a.ins_order_no=ins.id
         left join  ins_orders o ON o.orderno=ins.orderno
+        left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
         <where>
             <if test="userId !=null  and  userId !=''">
                 a.user_id = #{userId}
             </if>
             and  ins.orderstatus ='3'
-            and NOT EXISTS (SELECT ins_order_no FROM ins_fee_audit fee where fee.ins_order_no =a.ins_order_no)
+            and iff.auditstatus=0
             <if test="timeFiltering!= null  and  timeFiltering  !=''">
                 AND DATE_FORMAT(ins.signing_time, '%Y-%m' ) = #{timeFiltering}
             </if>
@@ -267,8 +269,9 @@
         ins_fee_order_new a
         LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
         left join  ins_orders o ON o.orderno=iac.orderno
+        left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
         <where>
-            NOT EXISTS (SELECT ins_order_no FROM ins_fee_audit fee where fee.ins_order_no =a.ins_order_no)
+            iff.auditstatus=0
             and iac.orderstatus = '3'
             <if test="userId!=null and  userId!= ''">
                 AND a.first_level_user_id = #{userId}
@@ -291,8 +294,9 @@
         ins_fee_order_new a
         LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
         left join  ins_orders o ON o.orderno=iac.orderno
+        left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
         <where>
-            NOT EXISTS (SELECT ins_order_no FROM ins_fee_audit fee where fee.ins_order_no =a.ins_order_no)
+            iff.auditstatus=0
             and iac.orderstatus = '3'
             <if test="userId!=null and  userId!= ''">
                 AND a.three_level_user_id = #{userId}
@@ -315,8 +319,9 @@
         ins_fee_order_new a
         LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
         left join  ins_orders o ON o.orderno=iac.orderno
+        left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
         <where>
-            NOT EXISTS (SELECT ins_order_no FROM ins_fee_audit fee where fee.ins_order_no =a.ins_order_no)
+            iff.auditstatus=0
             and iac.orderstatus = '3'
             <if test="userId!=null and  userId!= ''">
                 AND a.two_level_user_id = #{userId}
@@ -326,17 +331,27 @@
     </select>
     <select id="getByUserIdAndOrderStatusAndNoCheckType"
             resultType="com.ydtech.modules.protocols.entity.po.InsFeeOrderNew">
-        select a.*  from
+        select
+            a.jq_export_supervise_costs_premiums as "jqExportSuperviseCostsPremiums",
+            a.sy_export_supervise_costs_premiums as "syExportSuperviseCostsPremiums",
+            a.no_export_supervise_costs_premiums as "noExportSuperviseCostsPremiums",
+            a.jq_export_other_costs_premiums as "jqExportOtherCostsPremiums",
+            a.sy_export_other_costs_premiums as "syExportOtherCostsPremiums",
+            a.no_export_other_costs_premiums as "noExportOtherCostsPremiums"
+            from
             ins_fee_order_new a  left join ins_area_company ins  on  a.ins_order_no=ins.id
+            left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
         WHERE
             a.user_id = #{userId}
           and  ins.orderstatus ='3'
-          and a.ins_order_no
-          <if test="type=='1'">
-             not
-          </if>
-           in
-           (select ins_order_no from ins_fee_audit)
+            <choose>
+                <when  test='type == "1"'>
+                    and iff.auditstatus=0
+                </when>
+                <otherwise>
+                    and  iff.auditstatus=1
+                </otherwise>
+            </choose>
     </select>
     <select id="getSumWillAmountGeneralizationNew"
             resultType="com.ydtech.modules.protocols.entity.po.InsFeeOrderNew">
@@ -370,11 +385,16 @@
         ins_fee_order_new a
         LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
         left join  ins_orders o ON o.orderno=iac.orderno
+        left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
         <where>
-            <if test='type == "1"'>
-                NOT
-            </if>
-            EXISTS (SELECT ins_order_no FROM ins_fee_audit fee where fee.ins_order_no =a.ins_order_no)
+            <choose>
+                <when  test='type == "1"'>
+                    iff.auditstatus=0
+                </when>
+                <otherwise>
+                    iff.auditstatus=1
+                </otherwise>
+            </choose>
             and iac.orderstatus = '3'
             <if test="userId!=null and  userId!= ''">
                 AND a.first_level_user_id = #{userId}
@@ -407,11 +427,16 @@
         ins_fee_order_new a
         LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
         left join  ins_orders o ON o.orderno=iac.orderno
+        left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
         <where>
-            <if test='type == "1"'>
-                NOT
-            </if>
-            EXISTS (SELECT ins_order_no FROM ins_fee_audit fee where fee.ins_order_no =a.ins_order_no)
+            <choose>
+                <when  test='type == "1"'>
+                    iff.auditstatus=0
+                </when>
+                <otherwise>
+                    iff.auditstatus=1
+                </otherwise>
+            </choose>
             and iac.orderstatus = '3'
             <if test="userId!=null and  userId!= ''">
                 AND a.three_level_user_id = #{userId}
@@ -444,11 +469,16 @@
         ins_fee_order_new a
         LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
         left join  ins_orders o ON o.orderno=iac.orderno
+        left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
         <where>
-            <if test='type == "1"'>
-                NOT
-            </if>
-            EXISTS (SELECT ins_order_no FROM ins_fee_audit fee where fee.ins_order_no =a.ins_order_no)
+            <choose>
+                <when  test='type == "1"'>
+                    iff.auditstatus=0
+                </when>
+                <otherwise>
+                    iff.auditstatus=1
+                </otherwise>
+            </choose>
             and iac.orderstatus = '3'
             <if test="userId!=null and  userId!= ''">
                 AND a.two_level_user_id = #{userId}
@@ -482,16 +512,20 @@
         from
         ins_fee_order_new a  left join ins_area_company ins  on  a.ins_order_no=ins.id
         left join  ins_orders o ON o.orderno=ins.orderno
+        left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
         <where>
             <if test="userId !=null  and  userId !=''">
                 a.user_id = #{userId}
             </if>
             and  ins.orderstatus ='3'
-            and
-            <if test='type == "1"'>
-                NOT
-            </if>
-            EXISTS (SELECT ins_order_no FROM ins_fee_audit fee where fee.ins_order_no =a.ins_order_no)
+            <choose>
+                <when  test='type == "1"'>
+                    and  iff.auditstatus=0
+                </when>
+                <otherwise>
+                    and  iff.auditstatus=1
+                </otherwise>
+            </choose>
             <if test="timeFiltering!= null  and  timeFiltering  !=''">
                 <choose>
                     <when  test='type == "1"'>

+ 37 - 23
src/main/resources/mapper/modules/order/InsAreaCompanyMapper.xml

@@ -310,13 +310,9 @@
         FROM
         ins_fee_order_new a
         LEFT JOIN ins_area_company iac on iac.id=a.ins_order_no
+        left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
         WHERE
-        a.ins_order_no NOT IN (
-        SELECT
-        ins_order_no
-        FROM
-        ins_fee_audit
-        )
+        iff.auditstatus=0
         AND iac.orderstatus =3
         <if test="firstUserId != null and firstUserId != ''">
             AND a.first_level_user_id = #{firstUserId}
@@ -343,8 +339,9 @@
         FROM
         ins_fee_order_new a
         LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
+        left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
         <where>
-            NOT EXISTS ( SELECT ins_order_no FROM ins_fee_audit AS b WHERE b.ins_order_no = a.ins_order_no )
+            iff.auditstatus=0
             and iac.orderstatus = '3'
             <if test="userId!=null and  userId!= ''">
                 AND a.first_level_user_id = #{userId}
@@ -359,8 +356,9 @@
         FROM
         ins_fee_order_new a
         LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
+        left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
         <where>
-            NOT EXISTS ( SELECT ins_order_no FROM ins_fee_audit AS b WHERE b.ins_order_no = a.ins_order_no )
+            iff.auditstatus=0
             and iac.orderstatus = '3'
             <if test="userId!=null and  userId!= ''">
                 AND a.three_level_user_id = #{userId}
@@ -375,8 +373,9 @@
         FROM
         ins_fee_order_new a
         LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
+        left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
         <where>
-            NOT EXISTS ( SELECT ins_order_no FROM ins_fee_audit AS b WHERE b.ins_order_no = a.ins_order_no )
+            iff.auditstatus=0
             and iac.orderstatus = '3'
             <if test="userId!=null and  userId!= ''">
                 AND a.two_level_user_id = #{userId}
@@ -394,8 +393,9 @@
         FROM
         ins_fee_order_new a
         LEFT JOIN ins_area_company iac on iac.id=a.ins_order_no
+        left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
         WHERE
-        NOT EXISTS ( SELECT ins_order_no FROM ins_fee_audit AS b WHERE b.ins_order_no = a.ins_order_no )
+        iff.auditstatus=0
         AND iac.orderstatus =3
         <if test="firstUserId != null and firstUserId != ''">
             AND a.first_level_user_id = #{firstUserId}
@@ -499,12 +499,16 @@
         FROM
         ins_fee_order_new a
         LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
+        left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
         <where>
-            <if test='type == "1"'>
-                NOT
-            </if>
-            EXISTS
-            ( SELECT ins_order_no FROM ins_fee_audit AS b WHERE b.ins_order_no = a.ins_order_no )
+            <choose>
+                <when  test='type == "1"'>
+                    iff.auditstatus=0
+                </when>
+                <otherwise>
+                    iff.auditstatus=1
+                </otherwise>
+            </choose>
             and iac.orderstatus = '3'
             <if test="userId!=null and  userId!= ''">
                 AND a.first_level_user_id = #{userId}
@@ -519,11 +523,16 @@
         FROM
         ins_fee_order_new a
         LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
+        left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
         <where>
-            <if test='type == "1"'>
-                NOT
-            </if>
-            EXISTS ( SELECT ins_order_no FROM ins_fee_audit AS b WHERE b.ins_order_no = a.ins_order_no )
+            <choose>
+                <when  test='type == "1"'>
+                    iff.auditstatus=0
+                </when>
+                <otherwise>
+                    iff.auditstatus=1
+                </otherwise>
+            </choose>
             and iac.orderstatus = '3'
             <if test="userId!=null and  userId!= ''">
                 AND a.three_level_user_id = #{userId}
@@ -538,11 +547,16 @@
         FROM
         ins_fee_order_new a
         LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
+        left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
         <where>
-            <if test='type == "1"'>
-                NOT
-            </if>
-            EXISTS ( SELECT ins_order_no FROM ins_fee_audit AS b WHERE b.ins_order_no = a.ins_order_no )
+            <choose>
+                <when  test='type == "1"'>
+                    iff.auditstatus=0
+                </when>
+                <otherwise>
+                    iff.auditstatus=1
+                </otherwise>
+            </choose>
             and iac.orderstatus = '3'
             <if test="userId!=null and  userId!= ''">
                 AND a.two_level_user_id = #{userId}