Browse Source

营销首页统计开发

anderx 2 years ago
parent
commit
5cec1dd8f8

+ 8 - 0
src/main/java/com/goafanti/admin/controller/AdminStatisticsController.java

@@ -22,4 +22,12 @@ public class AdminStatisticsController extends CertifyApiController {
         return res;
 
     }
+
+    @RequestMapping(value = "/lists", method = RequestMethod.GET)
+    public Result lists() {
+        Result res =new Result();
+        res.data(adminStatisticsService.lists());
+        return res;
+
+    }
 }

+ 2 - 0
src/main/java/com/goafanti/admin/service/AdminStatisticsService.java

@@ -2,4 +2,6 @@ package com.goafanti.admin.service;
 
 public interface AdminStatisticsService {
     Object info( String startTime,String endTime);
+
+    Object lists();
 }

+ 85 - 1
src/main/java/com/goafanti/admin/service/impl/AdminStatisticsServiceImpl.java

@@ -1,20 +1,104 @@
 package com.goafanti.admin.service.impl;
 
 import com.goafanti.admin.service.AdminStatisticsService;
+import com.goafanti.common.constant.AFTConstants;
 import com.goafanti.common.dao.AdminMapper;
+import com.goafanti.common.utils.DateUtils;
 import com.goafanti.core.shiro.token.TokenManager;
 import org.springframework.beans.factory.annotation.Autowired;
 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
     private AdminMapper adminMapper;
 
 
     @Override
     public Object info( String startTime, String endTime) {
+        String aid=TokenManager.getAdminId();
         endTime=endTime+" 23:59:59";
-        return adminMapper.adminStatisticsInfo(TokenManager.getAdminId(),startTime,endTime);
+        return adminMapper.adminStatisticsInfo(aid,startTime,endTime);
+    }
+
+    @Override
+    public Object lists() {
+        //获取当月的列表
+        String aid=TokenManager.getAdminId();
+        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);
+        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);
+        return map;
+    }
+
+    public  List getThisMonth(Days days) {
+        //获取当月的第一天
+        Date date=new Date();
+
+        Calendar ca=Calendar.getInstance();
+        ca.setTime(date);
+        ca.add(Calendar.DAY_OF_MONTH,-30);
+        days.setFirstDay(DateUtils.formatDate(ca.getTime(),AFTConstants.YYYYMMDD));
+        List<String> list=new ArrayList<>();
+        for (int i=0;i<31;i++){
+            if (i==0){
+                Calendar newc=Calendar.getInstance();
+                newc.setTime(ca.getTime());
+                list.add(DateUtils.formatDate(newc.getTime(), AFTConstants.YYYYMMDD));
+            }else {
+                ca.add(Calendar.DAY_OF_MONTH,1);
+                if (ca.getTimeInMillis()<date.getTime()){
+                    Calendar newc=Calendar.getInstance();
+                    newc.setTime(ca.getTime());
+                    days.setEndDay(DateUtils.formatDate(newc.getTime(), AFTConstants.YYYYMMDD));
+                    list.add(days.getEndDay());
+                }
+            }
+        }
+    return list;
+
+    }
+    class Days{
+        private String firstDay;
+        private String endDay;
+
+        public String getFirstDay() {
+            return firstDay;
+        }
+
+        public void setFirstDay(String firstDay) {
+            this.firstDay = firstDay;
+        }
+
+        public String getEndDay() {
+            return endDay;
+        }
+
+        public void setEndDay(String endDay) {
+            this.endDay = endDay;
+        }
     }
 }

+ 9 - 0
src/main/java/com/goafanti/common/dao/AdminMapper.java

@@ -175,4 +175,13 @@ public interface AdminMapper {
     List<Integer> selectRoleTypeByid(String aid);
 
     AdminStatisticsBo adminStatisticsInfo(@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<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);
 }

+ 43 - 0
src/main/java/com/goafanti/common/mapper/AdminMapper.xml

@@ -1281,4 +1281,47 @@
       where a.salesman_id =  #{aid})i
 
     </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>
+  <select id="thisMonthPublicRelease" resultType="java.lang.Integer">
+    <foreach  collection="list" item="e"  index="index" separator="union all">
+    select ifnull(sum(1),0) rangePublicRelease
+    from public_release a left join public_release_details b on a.id=b.prid
+    where status =2 and((a.release_start &gt; #{firstDay} and a.release_start &lt; '${e} 23:59:59')or
+    (a.release_end &gt; #{firstDay} and a.release_end  &lt;  '${e} 23:59:59')or
+    (a.release_start &lt;  #{firstDay} and a.release_end  &gt; '${e} 23:59:59'))
+    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>
 </mapper>