he2802 hai 1 ano
pai
achega
7fae302ed7

+ 1 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/top/goods/mapper/TopOldOrderMapper.java

@@ -78,7 +78,7 @@ public interface TopOldOrderMapper extends BaseMapper<TopOldOrder> {
 
     Long getSingleTenantStatisticsOrderNum(TopOrderStatisticsBo bo);
 
-    Long getNumStatisticsTotalWithBo(TopOrderStatisticsBo bo);
+    BigDecimal getNumStatisticsTotalWithBo(TopOrderStatisticsBo bo);
 
     BigDecimal getMoneyStatisticsWithBo(TopOrderStatisticsBo bo);
 

+ 36 - 19
zhongzheng-system/src/main/java/com/zhongzheng/modules/top/goods/service/impl/TopOldOrderServiceImpl.java

@@ -2413,10 +2413,15 @@ public class TopOldOrderServiceImpl extends ServiceImpl<TopOldOrderMapper, TopOl
                 item.setYearRate(divide.multiply(new BigDecimal("100")));
             }
 
-            //占比
-            BigDecimal divide = item.getMoney().divide(moneyTotal, 2, RoundingMode.HALF_UP);
-            String s = divide.multiply(new BigDecimal("100")).toString();
-            item.setOccupationRate(s+"%");
+            if(moneyTotal.compareTo(BigDecimal.ZERO)>1){
+                //占比
+                BigDecimal divide = item.getMoney().divide(moneyTotal, 2, RoundingMode.HALF_UP);
+                String s = divide.multiply(new BigDecimal("100")).toString();
+                item.setOccupationRate(s+"%");
+            }else{
+                item.setOccupationRate("0%");
+            }
+
         });
         return moneyVos;
     }
@@ -2456,7 +2461,7 @@ public class TopOldOrderServiceImpl extends ServiceImpl<TopOldOrderMapper, TopOl
             return new ArrayList<>();
         }
         //订单总数量
-        Long numTotal = baseMapper.getNumStatisticsTotalWithBo(bo);
+        BigDecimal numTotal = baseMapper.getNumStatisticsTotalWithBo(bo);
         numVos.forEach(item -> {
             if (ObjectUtils.isNull(item.getOrderNum()) || item.getOrderNum() == 0){
                 return;
@@ -2484,13 +2489,17 @@ public class TopOldOrderServiceImpl extends ServiceImpl<TopOldOrderMapper, TopOl
             if (num2 > 0){
                 Long subtract = item.getOrderNum() - num2;
                 BigDecimal divide = new BigDecimal(subtract).divide(new BigDecimal(num2),2, RoundingMode.HALF_UP);
-                item.setWeekRate(divide.multiply(new BigDecimal("100")));
+                item.setYearRate(divide.multiply(new BigDecimal("100")));
+            }
+            if(numTotal.compareTo(BigDecimal.ZERO)>1){
+                //占比
+                BigDecimal divide = new BigDecimal(item.getOrderNum()).divide(numTotal, 2, RoundingMode.HALF_UP);
+                String s = divide.multiply(new BigDecimal("100")).toString();
+                item.setOccupationRate(s+"%");
+            }else{
+                item.setOccupationRate("0%");
             }
 
-            //占比
-            BigDecimal divide = new BigDecimal(item.getOrderNum()).divide(new BigDecimal(numTotal), 2, RoundingMode.HALF_UP);
-            String s = divide.multiply(new BigDecimal("100")).toString();
-            item.setOccupationRate(s+"%");
         });
         return numVos;
     }
@@ -3367,7 +3376,7 @@ public class TopOldOrderServiceImpl extends ServiceImpl<TopOldOrderMapper, TopOl
         //订单总额
         BigDecimal moneyTotal = baseMapper.getMoneyStatisticsWithBo(bo);
         //订单总数量
-        Long numTotal = baseMapper.getNumStatisticsTotalWithBo(bo);
+        BigDecimal numTotal = baseMapper.getNumStatisticsTotalWithBo(bo);
         detailVos.forEach(item -> {
             //订单客户机构ID
 
@@ -3419,15 +3428,23 @@ public class TopOldOrderServiceImpl extends ServiceImpl<TopOldOrderMapper, TopOl
                 BigDecimal divide = new BigDecimal(subtract).divide(new BigDecimal(num2),2, RoundingMode.HALF_UP);
                 item.setYearRate(divide.multiply(new BigDecimal("100")));
             }
+            if(moneyTotal.compareTo(BigDecimal.ZERO)>1){
+                //金额占比
+                BigDecimal divide = item.getMoney().divide(moneyTotal, 2, RoundingMode.HALF_UP);
+                String s = divide.multiply(new BigDecimal("100")).toString();
+                item.setMoneyOccupationRate(s+"%");
+            }else{
+                item.setMoneyOccupationRate("0%");
+            }
+            if(numTotal.compareTo(BigDecimal.ZERO)>1){
+                //数量占比
+                BigDecimal divide2 = new BigDecimal(item.getOrderNum()).divide(numTotal, 2, RoundingMode.HALF_UP);
+                String s2 = divide2.multiply(new BigDecimal("100")).toString();
+                item.setOccupationRate(s2+"%");
+            }else{
+                item.setOccupationRate("0%");
+            }
 
-            //金额占比
-            BigDecimal divide = item.getMoney().divide(moneyTotal, 2, RoundingMode.HALF_UP);
-            String s = divide.multiply(new BigDecimal("100")).toString();
-            item.setMoneyOccupationRate(s+"%");
-            //数量占比
-            BigDecimal divide2 = new BigDecimal(item.getOrderNum()).divide(new BigDecimal(numTotal), 2, RoundingMode.HALF_UP);
-            String s2 = divide2.multiply(new BigDecimal("100")).toString();
-            item.setOccupationRate(s2+"%");
         });
         return detailVos;
     }

+ 75 - 0
zhongzheng-system/src/main/resources/mapper/modules/top/TopOldOrderMapper.xml

@@ -1587,6 +1587,27 @@
         <if test="customerId != null and customerId != ''">
             AND o.tenant_id  = #{customerId}
         </if>
+        <if test="businessName != null and businessName != ''">
+            AND (
+            SELECT
+            count(*)
+            FROM
+            (
+            SELECT
+            concat( `cet`.`education_name`, '-', `cb`.`business_name`, `cpt`.`project_name` ) AS `business_name`,
+            g.goods_id,
+            og.order_sn
+            FROM
+            order_goods og LEFT JOIN  `goods` `g` on og.goods_id = `g`.goods_id
+            LEFT JOIN `course_education_type` `cet` ON `g`.`education_type_id` = `cet`.`id`
+            LEFT JOIN `course_project_type` `cpt` ON `g`.`education_type_id` = `cpt`.`id`
+            LEFT JOIN `course_business` `cb` ON `g`.`business_id` = `cb`.`id`
+            ) oug
+            WHERE
+            o.order_sn = oug.order_sn
+            AND oug.business_name = #{businessName}
+            )>0
+        </if>
         )) AS orderNum
         FROM
         top_old_order too
@@ -1606,6 +1627,23 @@
         <if test="customerId != null and customerId != ''">
             AND too.tenant_id  = #{customerId}
         </if>
+        <if test="businessName != null and businessName != ''">
+            AND (
+            SELECT
+            count(*)
+            FROM
+            (
+            SELECT
+            `otg`.`order_sn` AS `order_sn`,
+            concat( substr( `otg`.`business_full_name`, 5, 4 ), '-', `otg`.`business_name` ) AS `business_name`
+            FROM
+            `top_old_order_goods` `otg`
+            ) ouu
+            WHERE
+            ouu.order_sn = too.order_sn
+            AND ouu.business_name = #{businessName}
+            ) >0
+        </if>
     </select>
 
     <select id="getMoneyStatisticsWithBo" parameterType="com.zhongzheng.modules.top.order.bo.TopOrderStatisticsBo"
@@ -1638,6 +1676,26 @@
         <if test="customerId != null and customerId != ''">
             AND o.tenant_id  = #{customerId}
         </if>
+        <if test="businessName != null and businessName != ''">
+            AND (
+            SELECT
+            count(*)
+            FROM
+            (
+            SELECT
+            concat( `cet`.`education_name`, '-', `cb`.`business_name`, `cpt`.`project_name` ) AS `business_name`,
+            g.goods_id
+            FROM
+            `goods` `g`
+            LEFT JOIN `course_education_type` `cet` ON `g`.`education_type_id` = `cet`.`id`
+            LEFT JOIN `course_project_type` `cpt` ON `g`.`education_type_id` = `cpt`.`id`
+            LEFT JOIN `course_business` `cb` ON `g`.`business_id` = `cb`.`id`
+            ) oug
+            WHERE
+            og.goods_id = oug.goods_id
+            AND oug.business_name = #{businessName}
+            )>0
+        </if>
         ) AS money
         FROM
         top_old_order too
@@ -1657,6 +1715,23 @@
         <if test="customerId != null and customerId != ''">
             AND too.old_customer_id  = #{customerId}
         </if>
+        <if test="businessName != null and businessName != ''">
+            AND (
+            SELECT
+            count(*)
+            FROM
+            (
+            SELECT
+            `otg`.`order_sn` AS `order_sn`,
+            concat( substr( `otg`.`business_full_name`, 5, 4 ), '-', `otg`.`business_name` ) AS `business_name`
+            FROM
+            `top_old_order_goods` `otg`
+            ) ouu
+            WHERE
+            ouu.order_sn = too.order_sn
+            AND ouu.business_name = #{businessName}
+            ) >0
+        </if>
     </select>
 
     <select id="getBusinessOrderMoney" parameterType="com.zhongzheng.modules.top.order.bo.TopOrderStatisticsBo"