|
@@ -1,5 +1,6 @@
|
|
|
package com.caimei365.manager.service.caimei.impl;
|
|
|
|
|
|
+import com.caimei365.manager.config.utils.DateUtil;
|
|
|
import com.caimei365.manager.dao.HomeDao;
|
|
|
import com.caimei365.manager.entity.ResponseJson;
|
|
|
import com.caimei365.manager.service.caimei.HomeService;
|
|
@@ -7,8 +8,8 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.Map;
|
|
|
+import javax.xml.crypto.Data;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* Description
|
|
@@ -21,6 +22,8 @@ import java.util.Map;
|
|
|
public class HomeServiceImpl implements HomeService {
|
|
|
@Resource
|
|
|
private HomeDao homeDao;
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 仪表盘数据
|
|
|
*/
|
|
@@ -41,4 +44,166 @@ public class HomeServiceImpl implements HomeService {
|
|
|
data.put("money", money);
|
|
|
return ResponseJson.success(data);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResponseJson<Map<String, Object>> getClubCount(Date startCreateTime, Date endCreateTime) {
|
|
|
+ int count = homeDao.countClub(null, startCreateTime, endCreateTime);
|
|
|
+ //机构统计
|
|
|
+ Map<String, Object> dataClub = new LinkedHashMap<>(5);
|
|
|
+ dataClub.put("个人机构", homeDao.countClub(1, startCreateTime, endCreateTime));
|
|
|
+ dataClub.put("医美机构", homeDao.countClub(2, startCreateTime, endCreateTime));
|
|
|
+ dataClub.put("生美机构", homeDao.countClub(3, startCreateTime, endCreateTime));
|
|
|
+ dataClub.put("项目公司", homeDao.countClub(4, startCreateTime, endCreateTime));
|
|
|
+ dataClub.put("其他", homeDao.countClub(-1, startCreateTime, endCreateTime));
|
|
|
+
|
|
|
+ Map<String, Object> mapclubCount = new HashMap<>(3);
|
|
|
+ mapclubCount.put("name", "机构统计");
|
|
|
+ mapclubCount.put("count", count);
|
|
|
+ mapclubCount.put("data", dataClub);
|
|
|
+
|
|
|
+ // 机构活跃度统计
|
|
|
+ Map<String, Object> clubActivity = new LinkedHashMap<>(2);
|
|
|
+ int countClubActivity = homeDao.countClubActivity(startCreateTime, endCreateTime);
|
|
|
+ clubActivity.put("活跃机构", countClubActivity);
|
|
|
+ clubActivity.put("不活跃机构",count-countClubActivity);
|
|
|
+
|
|
|
+ Map<String, Object> mapclubActivityCount = new HashMap<>(3);
|
|
|
+ mapclubActivityCount.put("name", "机构活跃度统计");
|
|
|
+ mapclubActivityCount.put("count", count);
|
|
|
+ mapclubActivityCount.put("data", clubActivity);
|
|
|
+
|
|
|
+ //封装数据
|
|
|
+ Map<String, Object> data = new HashMap<>(2);
|
|
|
+ data.put("clubCount", mapclubCount);
|
|
|
+ data.put("clubActivityCount", mapclubActivityCount);
|
|
|
+ return ResponseJson.success(data);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResponseJson<Map<String, Object>> getClubTrend(Date startCreateTime, Date endCreateTime) {
|
|
|
+ List<Map<String, Object>> mapCreateTimeList = setCreateTime(startCreateTime, endCreateTime);
|
|
|
+ //机构新增趋势
|
|
|
+ Map<String, Object> dataClub = new LinkedHashMap<>(5);
|
|
|
+ dataClub.put("个人机构", setClubTrend(1,1,mapCreateTimeList));
|
|
|
+ dataClub.put("医美机构", setClubTrend(1,2,mapCreateTimeList));
|
|
|
+ dataClub.put("生美机构", setClubTrend(1,3,mapCreateTimeList));
|
|
|
+ dataClub.put("项目公司", setClubTrend(1,4,mapCreateTimeList));
|
|
|
+ dataClub.put("其他", setClubTrend(1,-1,mapCreateTimeList));
|
|
|
+
|
|
|
+ Map<String, Object> mapclubCount = new HashMap<>(3);
|
|
|
+ mapclubCount.put("name", "机构新增趋势");
|
|
|
+ mapclubCount.put("count", homeDao.countClub(null, startCreateTime, endCreateTime));
|
|
|
+ mapclubCount.put("data", dataClub);
|
|
|
+
|
|
|
+
|
|
|
+ // 机构订单趋势
|
|
|
+ Map<String, Object> clubOrder = new LinkedHashMap<>(5);
|
|
|
+ clubOrder.put("个人机构", setClubTrend(2,1,mapCreateTimeList));
|
|
|
+ clubOrder.put("医美机构", setClubTrend(2,2,mapCreateTimeList));
|
|
|
+ clubOrder.put("生美机构", setClubTrend(2,3,mapCreateTimeList));
|
|
|
+ clubOrder.put("项目公司", setClubTrend(2,4,mapCreateTimeList));
|
|
|
+ clubOrder.put("其他", setClubTrend(2,-1,mapCreateTimeList));
|
|
|
+
|
|
|
+ Map<String, Object> mapclubOrder = new HashMap<>(3);
|
|
|
+ mapclubOrder.put("name", "机构订单趋势");
|
|
|
+ mapclubOrder.put("count", homeDao.countClubOrder(null, startCreateTime, endCreateTime));
|
|
|
+ mapclubOrder.put("data", clubOrder);
|
|
|
+
|
|
|
+ //封装数据
|
|
|
+ Map<String, Object> data = new HashMap<>(2);
|
|
|
+ data.put("clubCount", mapclubCount);
|
|
|
+ data.put("clubOrder", mapclubOrder);
|
|
|
+ return ResponseJson.success(data);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResponseJson<Map<String, Object>> getAccessRecordCount(Date startCreateTime, Date endCreateTime) {
|
|
|
+ // 咨询统计
|
|
|
+ int clubRemarks = homeDao.countClubRemarks(startCreateTime, endCreateTime);
|
|
|
+ int clubVisitorRemarks = homeDao.countClubVisitorRemarks(startCreateTime, endCreateTime);
|
|
|
+ Map<String, Object> countClubRemarks = new LinkedHashMap<>(2);
|
|
|
+ countClubRemarks.put("机构咨询", clubRemarks);
|
|
|
+ countClubRemarks.put("游客咨询", clubVisitorRemarks);
|
|
|
+
|
|
|
+ Map<String, Object> mapRemarks = new HashMap<>(3);
|
|
|
+ mapRemarks.put("name", "咨询统计");
|
|
|
+ mapRemarks.put("count", (clubRemarks + clubVisitorRemarks));
|
|
|
+ mapRemarks.put("data", countClubRemarks);
|
|
|
+
|
|
|
+ //访问统计
|
|
|
+ Map<String, Object> countRecord = new LinkedHashMap<>(7);
|
|
|
+ countRecord.put("个人机构", homeDao.countRecord(null, 1, startCreateTime, endCreateTime));
|
|
|
+ countRecord.put("医美机构", homeDao.countRecord(null, 2, startCreateTime, endCreateTime));
|
|
|
+ countRecord.put("生美机构", homeDao.countRecord(null, 3, startCreateTime, endCreateTime));
|
|
|
+ countRecord.put("项目公司", homeDao.countRecord(null, 4, startCreateTime, endCreateTime));
|
|
|
+ countRecord.put("其他", homeDao.countRecord(null, -1, startCreateTime, endCreateTime));
|
|
|
+ countRecord.put("游客", homeDao.countRecord(0, null, startCreateTime, endCreateTime));
|
|
|
+ countRecord.put("供应商", homeDao.countRecord(null, 5, startCreateTime, endCreateTime));
|
|
|
+
|
|
|
+ Map<String, Object> mapRecord = new HashMap<>(3);
|
|
|
+ mapRecord.put("name", "访问统计");
|
|
|
+ mapRecord.put("count", homeDao.countRecord(null, null, startCreateTime, endCreateTime));
|
|
|
+ mapRecord.put("data", countRecord);
|
|
|
+
|
|
|
+ // 热门品牌
|
|
|
+ List<Map<String, String>> mapBrandProductSalesRecord = homeDao.countBrandProductSalesRecord(startCreateTime, endCreateTime);
|
|
|
+ // 热门商品
|
|
|
+ List<Map<String, String>> mapProductSalesRecord = homeDao.countProductSalesRecord(startCreateTime, endCreateTime);
|
|
|
+ // 热门搜索词
|
|
|
+ List<String> mapKeyword = homeDao.countKeyword(startCreateTime, endCreateTime);
|
|
|
+
|
|
|
+ //封装数据
|
|
|
+ Map<String, Object> data = new HashMap<>(5);
|
|
|
+ data.put("record", mapRecord);
|
|
|
+ data.put("remarks", mapRemarks);
|
|
|
+ data.put("brandProductSalesRecords", mapBrandProductSalesRecord);
|
|
|
+ data.put("productSalesRecords", mapProductSalesRecord);
|
|
|
+ data.put("keywords", mapKeyword);
|
|
|
+ return ResponseJson.success(data);
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<Map<String, Object>> setCreateTime(Date startCreateTime, Date endCreateTime) {
|
|
|
+ List<Map<String, Object>> list = new ArrayList<>();
|
|
|
+ // Calendar获取日期字符串
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ calendar.setTime(startCreateTime);
|
|
|
+ int ofTwoDate = (int) DateUtil.getDistanceOfTwoDate(startCreateTime, endCreateTime);
|
|
|
+ int ofTwoMonth = (int) ofTwoDate / 30;
|
|
|
+ int dates, cycle, count;
|
|
|
+ if (ofTwoMonth > 1) {
|
|
|
+ dates = ofTwoMonth;
|
|
|
+ cycle = Calendar.MONTH;
|
|
|
+ count = 1;
|
|
|
+ } else if (ofTwoMonth == 1 && ofTwoDate > 7) {
|
|
|
+ dates = 4;
|
|
|
+ cycle = Calendar.DATE;
|
|
|
+ count = 7;
|
|
|
+ } else {
|
|
|
+ dates = 7;
|
|
|
+ cycle = Calendar.DATE;
|
|
|
+ count = 1;
|
|
|
+ }
|
|
|
+ for (int i = 0; i < dates; i++) {
|
|
|
+ Map<String, Object> mapCreateTime = new HashMap<>(2);
|
|
|
+ mapCreateTime.put("startCreateTime", calendar.getTime());
|
|
|
+ calendar.add(cycle, count);
|
|
|
+ mapCreateTime.put("endCreateTime",calendar.getTime());
|
|
|
+ list.add(mapCreateTime);
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<Map<String, Object>> setClubTrend(Integer type,Integer userType, List<Map<String, Object>> mapCreateTimeList) {
|
|
|
+ List<Map<String, Object>> list = new ArrayList<>();
|
|
|
+ Date startCreateTime, endCreateTime;
|
|
|
+ for (Map<String, Object> map : mapCreateTimeList) {
|
|
|
+ Map<String, Object> mapClubTrend = new HashMap<>(2);
|
|
|
+ startCreateTime = (Date) map.get("startCreateTime");
|
|
|
+ endCreateTime =(Date) map.get("endCreateTime");
|
|
|
+ mapClubTrend.put("time", DateUtil.setDate(startCreateTime,"yyyy/MM/dd"));
|
|
|
+ mapClubTrend.put("num", type==1?homeDao.countClub(userType, startCreateTime, endCreateTime):homeDao.countClubOrder(userType, startCreateTime, endCreateTime));
|
|
|
+ list.add(mapClubTrend);
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
}
|