Преглед на файлове

营销首页统计开发

anderx преди 2 години
родител
ревизия
42eb165be7

+ 31 - 13
src/main/java/com/goafanti/admin/service/impl/AdminStatisticsServiceImpl.java

@@ -4,21 +4,19 @@ import com.goafanti.admin.bo.AdminStatisticsBo;
 import com.goafanti.admin.service.AdminStatisticsService;
 import com.goafanti.common.constant.AFTConstants;
 import com.goafanti.common.dao.AdminMapper;
+import com.goafanti.common.model.AdminUserCount;
 import com.goafanti.common.utils.DateUtils;
 import com.goafanti.common.utils.LoggerUtils;
 import com.goafanti.core.shiro.token.TokenManager;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.cache.annotation.CacheEvict;
-import org.springframework.cache.annotation.Cacheable;
 import org.springframework.stereotype.Service;
 
 import java.util.*;
 
 @Service
 public class AdminStatisticsServiceImpl implements AdminStatisticsService {
-    private static final Integer TYPE_PRIVATE=0;
-    private static final Integer TYPE_SIGN=2;
-    private static final Integer TYPE_CHANNEL=3;
+
 
 
     @Autowired
@@ -51,28 +49,48 @@ public class AdminStatisticsServiceImpl implements AdminStatisticsService {
     }
 
     @Override
-    @Cacheable(value = "adminStatisticeLists#300", key = "'key:'+#aid")
+//    @Cacheable(value = "adminStatisticeLists#300", key = "'key:'+#aid")
     public Object lists(String aid) {
         //获取当月的列表
         Map<String,Object> map=new HashMap<>();
         Days days = new Days();
         List thisMonth = getThisMonth(days);
-        List<Integer> signList = adminMapper.thisMonthUserByType(thisMonth,days.firstDay,days.endDay, aid,TYPE_SIGN);
+        List<AdminUserCount> userList = adminMapper.thisMonthUser(days.firstDay,days.endDay, aid);
+        List<Integer> signList=new ArrayList<>();
+        List<Integer> privateList=new ArrayList<>();
+        List<Integer> channelList=new ArrayList<>();
+        List<Integer> userFollowList=new ArrayList<>();
+        List<Integer> orderList=new ArrayList<>();
+            int signCount=0,privateCount=0,channelCount=0,followCount=0,orderCount=0;
+        for (AdminUserCount e : userList) {
+            signCount=signCount+e.getSignCount();
+            int newSign=signCount;
+            signList.add(newSign);
+            privateCount=privateCount+e.getPrivateCount();
+            int newPrivate=privateCount;
+            privateList.add(newPrivate);
+            channelCount=channelCount+e.getChannelCount();
+            int newChannel=channelCount;
+            channelList.add(newChannel);
+            followCount=followCount+e.getFollowCount();
+            int newFollow=followCount;
+            channelList.add(newFollow);
+            orderCount=orderCount+e.getOrderCount();
+            int newOrder=orderCount;
+            channelList.add(newOrder);
+        }
         map.put("dates",thisMonth);
         map.put("signList",signList);
-        List<Integer> privateList = adminMapper.thisMonthUserByType(thisMonth,days.firstDay,days.endDay, aid,TYPE_PRIVATE);
         map.put("privateList",privateList);
-        List<Integer> channelList = adminMapper.thisMonthUserByType(thisMonth,days.firstDay,days.endDay, aid,TYPE_CHANNEL);
         map.put("channelList",channelList);
-        //公出企业数
-        List<Integer> publicReleaseList = adminMapper.thisMonthPublicRelease(thisMonth,days.firstDay,  aid);
-        map.put("publicReleaseList",publicReleaseList);
         //跟进数
-        List<Integer> userFollowList = adminMapper.thisMonthUserFollow(thisMonth, days.firstDay, aid);
         map.put("userFollowList",userFollowList);
         //订单数
-        List<Integer> orderList = adminMapper.thisMonthOrderSum(thisMonth, days.firstDay, aid);
         map.put("orderList",orderList);
+        //公出企业数
+        List<Integer> publicReleaseList = adminMapper.thisMonthPublicRelease(thisMonth,days.firstDay,  aid);
+        map.put("publicReleaseList",publicReleaseList);
+
         return map;
     }
 

+ 2 - 4
src/main/java/com/goafanti/common/dao/AdminMapper.java

@@ -177,14 +177,12 @@ public interface AdminMapper {
     AdminStatisticsBo adminStatisticsInfo(@Param("aid") String aid);
     AdminStatisticsBo adminStatisticsInfoByTime(@Param("aid") String aid, @Param("startTime") String startTime, @Param("endTime") String endTime);
 
-    List<Integer> thisMonthUserByType(@Param("list")List thisMonth, @Param("firstDay")String firstDay, @Param("endDay")String endDay,
-                                    @Param("aid")String aid,@Param("type")Integer type);
+    List<AdminUserCount> thisMonthUser( @Param("firstDay")String firstDay, @Param("endDay")String endDay,
+                                    @Param("aid")String aid);
 
     List<Integer> thisMonthPublicRelease(@Param("list")List thisMonth,@Param("firstDay")String firstDay, @Param("aid")String aid);
 
-    List<Integer> thisMonthUserFollow(@Param("list")List thisMonth,@Param("firstDay")String firstDay, @Param("aid")String aid);
 
-    List<Integer> thisMonthOrderSum(@Param("list")List thisMonth,@Param("firstDay")String firstDay, @Param("aid")String aid);
 
     List<AdminUserCount> selectAdminPublicRelease(String aid);
     List<AdminUserCount> selectAdminUserFollow(String aid);

+ 8 - 32
src/main/java/com/goafanti/common/mapper/AdminMapper.xml

@@ -1268,25 +1268,13 @@
     from admin_user_count a where aid=#{aid} and  date_time BETWEEN #{startTime} and #{endTime}
     group by aid
   </select>
-  <select id="thisMonthUserByType" resultType="java.lang.Integer">
-    <foreach  collection="list" item="e"  index="index" separator="union all">
-      select  ifnull(sum(1),0) counts from user a
-      where a.status =0 and a.source in(1,2,3)
-      <if test="type==2">
-        and a.share_type =2
-      </if>
-      <if test="type==0">
-        and a.share_type =0
-        and a.new_channel=0
-      </if>
-      <if test="type==3">
-        and a.share_type =0
-        and a.new_channel=1
-      </if>
-      and a.aid= #{aid}
-      and a.transfer_time BETWEEN #{firstDay} and #{endDay}
-      and a.transfer_time &lt;  '${e} 23:59:59'
-    </foreach>
+  <select id="thisMonthUser" resultType="com.goafanti.common.model.AdminUserCount">
+    select id,aid,private_count privateCount,sign_count signCount,channel_count channelCount,
+           follow_count followCount,order_count orderCount, DATE_FORMAT(date_time , '%Y-%m-%d') dateTime
+    from admin_user_count
+    where  date_time BETWEEN #{firstDay} and  #{endDay}
+      and aid= #{aid}
+    order by date_time
   </select>
   <select id="thisMonthPublicRelease" resultType="java.lang.Integer">
     <foreach  collection="list" item="e"  index="index" separator="union all">
@@ -1298,19 +1286,7 @@
     and aid= #{aid}
     </foreach>
   </select>
-  <select id="thisMonthUserFollow" resultType="java.lang.Integer">
-    <foreach  collection="list" item="e"  index="index" separator="union all">
-      select ifnull(sum(1),0) rangeFollow from user_follow where  create_time BETWEEN  #{firstDay} and  '${e} 23:59:59'
-      and aid= #{aid}
-    </foreach>
-  </select>
-  <select id="thisMonthOrderSum" resultType="java.lang.Integer">
-    <foreach  collection="list" item="e"  index="index" separator="union all">
-      select ifnull(sum(1),0) rangeOrderSum from t_order_new where delete_sign in (0,2,3) and process_status >0
-      and salesman_id = #{aid}
-      and create_time BETWEEN  #{firstDay} and  '${e} 23:59:59'
-    </foreach>
-  </select>
+
   <select id="selectAdminPublicRelease" resultType="com.goafanti.common.model.AdminUserCount">
     select aid,count(*)publicReleaseCount, dates dateTime
     from (select aid,DATE_FORMAT(a.release_start , '%Y-%m-%d') dates