Browse Source

Merge remote-tracking branch 'origin/developer' into developerA

# Conflicts:
#	src/main/java/com/caimei365/user/mapper/ClubMapper.java
#	src/main/java/com/caimei365/user/service/ClubService.java
#	src/main/resources/mapper/ClubMapper.xml
zhijiezhao 2 years ago
parent
commit
49cd616fe9

+ 70 - 4
src/main/java/com/caimei365/user/controller/ClubApi.java

@@ -1,10 +1,7 @@
 package com.caimei365.user.controller;
 
 import com.caimei365.user.model.ResponseJson;
-import com.caimei365.user.model.dto.ClubRemarksDto;
-import com.caimei365.user.model.dto.ClubUpdateDto;
-import com.caimei365.user.model.dto.DeductionDto;
-import com.caimei365.user.model.dto.JsonParamsDto;
+import com.caimei365.user.model.dto.*;
 import com.caimei365.user.model.vo.*;
 import com.caimei365.user.service.ClubService;
 import io.swagger.annotations.Api;
@@ -12,6 +9,7 @@ import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
 import lombok.RequiredArgsConstructor;
+import org.apache.commons.lang.StringUtils;
 import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
@@ -550,4 +548,72 @@ public class ClubApi {
     public ResponseJson choseSales(Integer clubId, Integer spId, Integer choseServiceId) {
         return clubService.changeSales(clubId, spId, choseServiceId);
     }
+
+    /**
+     * 机构访问记录列表
+     * @param clubId
+     * @return
+     */
+    @GetMapping("/record/list")
+    public ResponseJson accessRecords(Integer clubId) {
+
+        if (null == clubId) {
+            return ResponseJson.error("机构id不能为空");
+        }
+        return clubService.accessRecords(clubId);
+    }
+
+    /**
+     * 机构访问记录详情
+     * @param clubId
+     * @param accessDate
+     * @return
+     */
+    @GetMapping("/record/detail")
+    public ResponseJson recordDetail(Integer clubId, String accessDate,String ip, Integer pageNum, Integer pageSize) {
+        if (null == clubId) {
+            return ResponseJson.error("机构id不能为空",null);
+        }
+        if (!StringUtils.isNotBlank(accessDate)) {
+            return ResponseJson.error("详情时间不能为空",null);
+        }
+        return clubService.recordDetail(clubId, accessDate, ip, pageNum, pageSize);
+    }
+
+    /**
+     * 机构初始出局
+     * @param clubId
+     * @return
+     */
+    @GetMapping("/clubInitial")
+    public ResponseJson selTotal(Integer clubId) {
+        if (null == clubId) {
+            return ResponseJson.error("机构id不能为空",null);
+        }
+        return clubService.selTotal(clubId);
+    }
+    /**
+     * 机构画像
+     * @param cmPortrait
+     * @return
+     */
+    @PostMapping("/clubPortrait")
+    @ResponseBody
+    public ResponseJson clubPortrait(CmPortraitDto cmPortrait) {
+        if (null == cmPortrait.getClubId()) {
+            return ResponseJson.error("机构id不能为空",null);
+        }
+        if (null == cmPortrait.getDateType()) {
+            return ResponseJson.error("时间类型不能为空",null);
+        }
+        if (null == cmPortrait.getType()) {
+            return ResponseJson.error("数据类型不能为空",null);
+        }
+        if (StringUtils.isNotBlank(cmPortrait.getStartTime()) && StringUtils.isNotBlank(cmPortrait.getEndTime())) {
+            if (cmPortrait.getStartTime().compareTo(cmPortrait.getEndTime()) > 0 ) {
+                return ResponseJson.error("开始时间不能大于结束时间",null);
+            }
+        }
+        return clubService.dataList(cmPortrait);
+    }
 }

+ 2 - 2
src/main/java/com/caimei365/user/controller/CmBehaviorRecordApi.java

@@ -29,8 +29,8 @@ public class CmBehaviorRecordApi {
      */
     @IpSave(saveName="用户行为记录",saveParams = true)
     @GetMapping("/Statistics")
-    public ResponseJson<String> behaviorRecordApp(Integer userId,String pagePath,String pageType,String pageLabel,String behaviorType,Integer productId,String accessDuration,Integer accessClient){
-        log.info("用户行为记录=========》"+userId+"===="+pagePath+"===="+pageType+"===="+pageLabel+"===="+behaviorType+"===="+productId+"===="+accessDuration+"===="+accessClient);
+    public ResponseJson<String> behaviorRecordApp(Integer userId,String pagePath,String pageType,String pageLabel,String behaviorType,Integer productId,String accessDuration,Integer accessClient,Integer shopId){
+        log.info("用户行为记录=======userId==》"+userId+"==pagePath=="+pagePath+"==pageType=="+pageType+"==pageLabel=="+pageLabel+"==behaviorType=="+behaviorType+"==productId=="+productId+"==accessDuration=="+accessDuration+"==accessClient=="+accessClient+"==shopId=="+shopId);
         return ResponseJson.success("用户行为记录完成");
     }
 

+ 42 - 0
src/main/java/com/caimei365/user/mapper/ClubMapper.java

@@ -1,7 +1,10 @@
 package com.caimei365.user.mapper;
 
 import com.caimei365.user.model.dto.ClubUpdateDto;
+import com.caimei365.user.model.dto.CmPortraitDto;
 import com.caimei365.user.model.po.ClubRemarksPo;
+import com.caimei365.user.model.po.NewOrderPo;
+import com.caimei365.user.model.po.OperationalLogsPo;
 import com.caimei365.user.model.po.UserPo;
 import com.caimei365.user.model.vo.*;
 import org.apache.ibatis.annotations.Mapper;
@@ -35,6 +38,25 @@ public interface ClubMapper {
      */
     void updateClubUserByUpdateInfo(UserPo user);
 
+    /**
+     * 查询机构信息
+     * @return
+     */
+    ClubVo selClubData(Integer clubId);
+
+
+    /**
+     * 查询协销信息
+     * @param serviceProviderId
+     * @return
+     */
+    String selSpName(Integer serviceProviderId);
+
+    /**
+     * 插入操作记录
+     * @param operationalLogsPo
+     */
+    void insertOpLogs(OperationalLogsPo operationalLogsPo);
     /**
      * 修改机构信息保存机构
      *
@@ -247,6 +269,8 @@ public interface ClubMapper {
 
     void insertVisitorRemark(VisitorRemarkVo visitorRemarkVo);
 
+    void updateClubNewDeal(@Param("clubId") Integer clubId);
+
     void updateVisitorRemark(VisitorRemarkVo visitorRemarkVo);
 
     void clearVisitorRemarks(Integer remarksId);
@@ -304,6 +328,8 @@ public interface ClubMapper {
 
     String serviceProviderNameage(Integer serviceProviderId);
 
+    String selAddTime(@Param("clubId") Integer clubId);
+
     List<ServiceProviderVo> findSales();
 
     Integer findOldSpId(Integer clubId);
@@ -331,4 +357,20 @@ public interface ClubMapper {
     Integer findLeaderIdBySp(Integer spId);
 
     List<BanksVo> findBanks(Integer userId);
+
+    CmPortraitDto selTotal(Integer clubId);
+
+    List<RecordVo> accessRecords(Integer clubId);
+
+    List<BehaviorRecodeVo> recordDetail(@Param("clubId") Integer clubId, @Param("accessDate") String accessDate);
+
+    List<NewOrderPo> selOrderList(CmPortraitDto cmPortrait);
+
+    List<BehaviorRecodeVo> selBehaviorList(CmPortraitDto cmPortrait);
+
+    List<BehaviorRecodeVo> selRegion(@Param("ip") String ip, @Param("accessDate") String accessDate);
+
+    List<CmClubRemarksVo> selRemarksList(CmPortraitDto cmPortrait);
+
+    List<BehaviorRecodeVo> selBehaviorPageTypeList(CmPortraitDto cmPortrait);
 }

+ 25 - 0
src/main/java/com/caimei365/user/model/dto/ArrDateDto.java

@@ -0,0 +1,25 @@
+package com.caimei365.user.model.dto;
+
+import com.caimei365.user.model.vo.PortraitMap;
+import lombok.Data;
+
+import java.util.ArrayList;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2023/3/27
+ */
+@Data
+public class ArrDateDto {
+
+    private ArrayList<String> name;
+    private ArrayList<Integer> value;
+
+    private ArrayList<PortraitMap> orderList;
+    private Integer orderTotalNum;
+
+    private String startTime;
+    private String endTime;
+}

+ 11 - 0
src/main/java/com/caimei365/user/model/dto/ClubUpdateDto.java

@@ -25,6 +25,11 @@ public class ClubUpdateDto implements Serializable {
      */
     @ApiModelProperty("用户Id")
     private Integer userId;
+    /**
+     * 协销id
+     */
+    @ApiModelProperty("协销Id")
+    private Integer serviceProviderId;
     /**
      * 机构名称
      */
@@ -124,4 +129,10 @@ public class ClubUpdateDto implements Serializable {
      */
     @ApiModelProperty("公司简介(info)")
     private String profile;
+
+    /**
+     * 最后修改时间
+     */
+    @ApiModelProperty("最后修改时间")
+    private String lastModify;
 }

+ 105 - 0
src/main/java/com/caimei365/user/model/dto/CmPortraitDto.java

@@ -0,0 +1,105 @@
+package com.caimei365.user.model.dto;
+
+import com.caimei365.user.model.vo.PortraitMap;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2023/3/27
+ */
+@Data
+public class CmPortraitDto {
+    /**
+     * 机构id
+     */
+    private Integer clubId;
+    /**
+     * 机构名称
+     */
+    private String clubName;
+    /**
+     * 日期类别 0日 1月 2半年 3全年
+     */
+    private Integer dateType;
+    /**
+     * 开始时间
+     */
+    private String startTime;
+    /**
+     * 结束时间
+     */
+    private String endTime;
+    /**
+     * 统计类别 0订单 1搜索关键词 2咨询记录 3访问记录 4初始状态
+     */
+    private Integer type;
+    /**
+     * 时间
+     */
+    private String accessDate;
+    /**
+     * 订单总量
+     */
+    private Integer orderTotal;
+    /**
+     * 当前范围订单总金额
+     */
+    private double orderScopeTotalFee;
+    /**
+     * 当前订单范围总量
+     */
+    private Integer orderScopeNum;
+    /**
+     * 订单总金额
+     */
+    private BigDecimal orderTotalAmount;
+    /**
+     * 订单类型值value  订单类型name
+     */
+    private ArrayList<PortraitMap> orderPortrait;
+    /**
+     * 搜索关键词总数
+     */
+    private Integer totalKeywords;
+    /**
+     * 当前关键词范围总量
+     */
+    private Integer keyWordsScopeNum;
+    /**
+     * 搜索关键词数量
+     */
+    private ArrayList<Integer> behaviorValue;
+    /**
+     * 搜索关键词
+     */
+    private ArrayList<String> behaviorType;
+    /**
+     * 咨询记录总数
+     */
+    private Integer remarksTotal;
+    /**
+     * 当前咨询记录范围总量
+     */
+    private Integer remarksScopeNum;
+    /**
+     * 咨询记录数
+     */
+    private ArrayList<Integer> remarksValue;
+    /**
+     * 咨询记录关键词
+     */
+    private ArrayList<String> remarksType;
+    /**
+     * 访问记录数
+     */
+    private ArrayList<Integer> pageTypeValue;
+    /**
+     * 访问词
+     */
+    private ArrayList<String> pageType;
+}

+ 44 - 0
src/main/java/com/caimei365/user/model/po/NewOrderPo.java

@@ -0,0 +1,44 @@
+package com.caimei365.user.model.po;
+
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2023/3/27
+ */
+@Data
+public class NewOrderPo {
+    /**
+     * 二手商品订单标识  0非二手商品订单、 1二手商品订单
+     */
+    private String secondHandOrderFlag;
+    /**
+     * 返佣订单标识,0非返佣订单,1返佣订单,2普通订单有返佣服务费
+     */
+    private String rebateFlag;
+    /**
+     * 退货退款类型:1部分退、2全部退
+     */
+    private String refundType;
+    /**
+     * 订单状态
+     */
+    private String status;
+
+    /**
+     * 总数
+     */
+    private Integer numbers;
+    /**
+     * 总金额
+     */
+    private Double totalMoney;
+    /**
+     * 支付金额
+     */
+    private Double payTotalFee;
+}

+ 39 - 0
src/main/java/com/caimei365/user/model/po/OperationalLogsPo.java

@@ -0,0 +1,39 @@
+package com.caimei365.user.model.po;
+
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2023/3/9
+ */
+@Data
+public class OperationalLogsPo {
+    /**
+     * 机构名称
+     */
+    private String institutionName;
+    /**
+     * 联系人
+     */
+    private String contact;
+    /**
+     * 操作类型
+     */
+    private String operationType;
+    /**
+     * 操作内容
+     */
+    private String actionContent;
+    /**
+     * 操作人
+     */
+    private String operator;
+    /**
+     * 操作时间
+     */
+    private Date operationTime;
+}

+ 73 - 0
src/main/java/com/caimei365/user/model/vo/BehaviorRecodeVo.java

@@ -0,0 +1,73 @@
+package com.caimei365.user.model.vo;
+
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2023/3/24
+ */
+@Data
+public class BehaviorRecodeVo {
+
+    /**
+     * 用户Id
+     */
+    private Integer userId;
+    /**
+     * 机构Id
+     */
+    private Integer clubId;
+    /**
+     * 访问记录ip
+     */
+    private String ip;
+    /**
+     * 页面类型
+     */
+    private String pageType;
+    /**
+     * 页面标签
+     */
+    private String pageLabel;
+    /**
+     * 商品图片
+     */
+    private String productImage;
+    /**
+     * 商品名称
+     */
+    private String productName;
+    /**
+     * 访问来源
+     */
+    private String accessSource;
+    /**
+     * 访问客户端
+     */
+    private String accessClient;
+    /**
+     * 访问时间
+     */
+    private Date accessTime;
+    /**
+     * 新访问时间
+     */
+    private String accessNewTime;
+    /**
+     * 访问时长
+     */
+    private String accessDuration;
+    /**
+     * 数量
+     */
+    private Integer number;
+    /**
+     * 访问页面总数
+     */
+    private Integer numbers;
+
+}

+ 21 - 0
src/main/java/com/caimei365/user/model/vo/CmClubRemarksVo.java

@@ -0,0 +1,21 @@
+package com.caimei365.user.model.vo;
+
+import lombok.Data;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2023/3/27
+ */
+@Data
+public class CmClubRemarksVo {
+    /**
+     * 文字备注/关键词
+     */
+    private String remarks;
+    /**
+     * 咨询记录总数
+     */
+    private Integer numbers;
+}

+ 24 - 0
src/main/java/com/caimei365/user/model/vo/CmRecordVo.java

@@ -0,0 +1,24 @@
+package com.caimei365.user.model.vo;
+
+import lombok.Data;
+
+import java.util.ArrayList;
+import java.util.Map;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2023/3/24
+ */
+@Data
+public class CmRecordVo {
+    /**
+     * 年份
+     */
+    private String year;
+    /**
+     * 数据
+     */
+    private ArrayList<RecordVo> data;
+}

+ 25 - 0
src/main/java/com/caimei365/user/model/vo/PortraitMap.java

@@ -0,0 +1,25 @@
+package com.caimei365.user.model.vo;
+
+import lombok.Data;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2023/3/24
+ */
+@Data
+public class PortraitMap {
+    /**
+     * 名称
+     */
+    private String name;
+    /**
+     * 数值
+     */
+    private Integer value;
+    /**
+     * 百分比
+     */
+    private String per;
+}

+ 29 - 0
src/main/java/com/caimei365/user/model/vo/RecordVo.java

@@ -0,0 +1,29 @@
+package com.caimei365.user.model.vo;
+
+import lombok.Data;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2023/3/24
+ */
+@Data
+public class RecordVo {
+    /**
+     * 访问记录数
+     */
+    private Integer number;
+    /**
+     * 访问记录时间
+     */
+    private String accessDate;
+    /**
+     * 月份时间
+     */
+    private String monthAndDay;
+    /**
+     * 访问记录用ip
+     */
+    private String ip;
+}

+ 9 - 0
src/main/java/com/caimei365/user/service/ClubService.java

@@ -3,6 +3,7 @@ package com.caimei365.user.service;
 import com.caimei365.user.model.ResponseJson;
 import com.caimei365.user.model.dto.ClubRemarksDto;
 import com.caimei365.user.model.dto.ClubUpdateDto;
+import com.caimei365.user.model.dto.CmPortraitDto;
 import com.caimei365.user.model.dto.JsonParamsDto;
 import com.caimei365.user.model.vo.*;
 import org.springframework.web.bind.annotation.RequestParam;
@@ -278,5 +279,13 @@ public interface ClubService {
 
     ResponseJson changeSales(Integer clubId, Integer spId, Integer choseServiceId);
 
+    ResponseJson accessRecords(Integer clubId);
+
+    ResponseJson recordDetail(Integer clubId, String accessDate,String ip,Integer pageNum, Integer pageSize);
+
+    ResponseJson selTotal(Integer clubId);
+
+    ResponseJson dataList(CmPortraitDto cmPortrait);
+
     ResponseJson<List<BanksVo>> getUserBanks(Integer userId);
 }

+ 874 - 7
src/main/java/com/caimei365/user/service/impl/ClubServiceImpl.java

@@ -5,13 +5,8 @@ import com.alibaba.fastjson.JSONObject;
 import com.caimei365.user.components.RedisService;
 import com.caimei365.user.mapper.*;
 import com.caimei365.user.model.ResponseJson;
-import com.caimei365.user.model.dto.ClubUpdateDto;
-import com.caimei365.user.model.dto.SuperVipDto;
-import com.caimei365.user.model.po.SuperVipPo;
-import com.caimei365.user.model.dto.JsonParamsDto;
-import com.caimei365.user.model.po.ClubRemarksPo;
-import com.caimei365.user.model.po.UserBeansHistoryPo;
-import com.caimei365.user.model.po.UserPo;
+import com.caimei365.user.model.dto.*;
+import com.caimei365.user.model.po.*;
 import com.caimei365.user.model.vo.*;
 import com.caimei365.user.service.ClubService;
 import com.caimei365.user.service.SellerService;
@@ -20,14 +15,19 @@ import com.caimei365.user.utils.MathUtil;
 import com.caimei365.user.utils.OssUtil;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
+import com.google.common.collect.Maps;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
+import org.springframework.util.ObjectUtils;
 import org.springframework.web.bind.annotation.RequestParam;
 
 import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.text.NumberFormat;
+import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.*;
 
@@ -140,6 +140,29 @@ public class ClubServiceImpl implements ClubService {
         Map<String, Object> map = new HashMap(2);
         map.put("club", club);
         map.put("saleName", saleName);
+        // 是否失效 有效时间3天
+        String addTime = clubMapper.selAddTime(clubId);
+        if (StringUtils.isNotBlank(addTime)) {
+            //计算距今时长
+            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
+            Date date = null;
+            try {
+                date = dateFormat.parse(addTime);
+            } catch (ParseException e) {
+                e.printStackTrace();
+            }
+            Calendar calendar = Calendar.getInstance();
+            calendar.setTime(date);
+            long timeOld = calendar.getTime().getTime();
+            calendar.setTime(new Date());
+            long timeNew = calendar.getTime().getTime();
+            int day = (int)(timeNew - timeOld) / 1000 / 60 / 60 / 24;
+            if (day > 3) {
+                map.put("lostType",1);
+            } else {
+                map.put("lostType",0);
+            }
+        }
         return ResponseJson.success(map);
     }
 
@@ -205,6 +228,12 @@ public class ClubServiceImpl implements ClubService {
         }
         // 更新机构用户信息
         clubMapper.updateClubUserByUpdateInfo(user);
+        //添加操作日志
+        int type = insertOperationalLogs(club);
+
+        if (type == 1) {
+            club.setLastModify(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
+        }
         // 更新机构信息
         clubMapper.updateClubByUpdateInfo(club);
 
@@ -240,6 +269,381 @@ public class ClubServiceImpl implements ClubService {
         return ResponseJson.success("修改机构资料成功", club);
     }
 
+    private int insertOperationalLogs(ClubUpdateDto club) {
+        int type = 0;
+        log.info("====开始操作记录====");
+        List<String> list = new ArrayList<>();
+        OperationalLogsPo operationalLogsPo = new OperationalLogsPo();
+        ClubVo clubVo = clubMapper.selClubData(club.getClubId());
+        // 判断修改的内容
+        if (club.getClubId() != null) {
+
+            if (clubVo != null) {
+                if (StringUtils.isNotBlank(clubVo.getName())) {
+                    if (StringUtils.isNotBlank(club.getName())) {
+                        if (!club.getName().equals(clubVo.getName())) {
+                            list.add("修改了机构名称");
+                            type = 1;
+                        }
+                    } else {
+                        list.add("删除了机构名称");
+                        type = 1;
+                    }
+                } else {
+                    if (StringUtils.isNotBlank(club.getName())) {
+                        list.add("新增了机构名称");
+                        type = 1;
+                    }
+                }
+
+                if (StringUtils.isNotBlank(clubVo.getLinkMan())) {
+                    if (StringUtils.isNotBlank(club.getLinkMan())) {
+                        if (!club.getLinkMan().equals(clubVo.getLinkMan())) {
+                            list.add("修改了联系人");
+                            type = 1;
+                        }
+                    } else {
+                        list.add("删除了联系人");
+                        type = 1;
+                    }
+                } else {
+                    if (StringUtils.isNotBlank(club.getLinkMan())) {
+                        list.add("新增了联系人");
+                        type = 1;
+                    }
+                }
+
+                if (clubVo.getLinkManIdentity() != null) {
+                    if (club.getLinkManIdentity() != null ) {
+                        if (club.getLinkManIdentity().equals(clubVo.getLinkManIdentity())) {
+                            list.add("修改了联系人身份");
+                            type = 1;
+                        }
+                    } else {
+                        list.add("删除了联系人身份");
+                        type = 1;
+                    }
+                } else {
+                    if (club.getLinkManIdentity() != null ) {
+                        list.add("新增了联系人身份");
+                        type = 1;
+                    }
+                }
+
+                if (StringUtils.isNotBlank(clubVo.getContractEmail())) {
+                    if (StringUtils.isNotBlank(club.getContractEmail())) {
+                        if (!club.getContractEmail().equals(clubVo.getContractEmail())) {
+                            list.add("修改了联系邮箱");
+                            type = 1;
+                        }
+                    } else {
+                        list.add("删除了联系邮箱");
+                        type = 1;
+                    }
+                } else {
+                    if (StringUtils.isNotBlank(club.getContractEmail())) {
+                        list.add("新增了联系邮箱");
+                        type = 1;
+                    }
+                }
+
+                if (StringUtils.isNotBlank(clubVo.getShortName())) {
+                    if (StringUtils.isNotBlank(club.getShortName())) {
+                        if (!club.getShortName().equals(clubVo.getShortName())) {
+                            list.add("修改了机构简称");
+                            type = 1;
+                        }
+                    } else {
+                        list.add("删除了机构简称");
+                        type = 1;
+                    }
+                } else {
+                    if (StringUtils.isNotBlank(club.getShortName())) {
+                        list.add("新增了机构简称");
+                        type = 1;
+                    }
+                }
+
+                if (clubVo.getProvinceId() != null || clubVo.getCityId() != null || clubVo.getTownId() != null || StringUtils.isNotBlank(clubVo.getAddress())) {
+                    if (club.getProvinceId() != null || club.getCityId() != null || club.getTownId() != null || StringUtils.isNotBlank(club.getAddress())) {
+                        if (!club.getProvinceId().equals(clubVo.getProvinceId()) || !club.getCityId().equals(clubVo.getCityId()) || !club.getTownId().equals(clubVo.getTownId()) || !club.getAddress().equals(clubVo.getAddress())) {
+                            list.add("修改了详细地址");
+                            type = 1;
+                        }
+                    } else {
+                        list.add("删除了详细地址");
+                        type = 1;
+                    }
+                } else {
+                    if (club.getProvinceId() != null || club.getCityId() != null || club.getTownId() != null || StringUtils.isNotBlank(club.getAddress())) {
+                        list.add("新增了详细地址");
+                        type = 1;
+                    }
+                }
+/*
+                if (clubVo.getCityId() != null) {
+                    if (club.getCityId() != null) {
+                        if (!club.getCityId().equals(clubVo.getCityId())) {
+                            list.add("修改了详细地址");
+                        }
+                    } else {
+                        list.add("删除了详细地址");
+                    }
+                } else {
+                    if (club.getCityId() != null) {
+                        list.add("新增了详细地址");
+                    }
+                }
+
+                if (clubVo.getTownId() != null) {
+                    if (club.getTownId() != null) {
+                        if (!club.getTownId().equals(clubVo.getTownId())) {
+                            list.add("修改了详细地址");
+                        }
+                    } else {
+                        list.add("删除了详细地址");
+                    }
+                } else {
+                    if (club.getTownId() != null) {
+                        list.add("新增了详细地址");
+                    }
+                }
+
+                if (StringUtils.isNotBlank(clubVo.getAddress())) {
+                    if (StringUtils.isNotBlank(club.getAddress())) {
+                        if (!club.getAddress().equals(clubVo.getAddress())) {
+                            list.add("修改了详细地址");
+                        }
+                    } else {
+                        list.add("删除了详细地址");
+                    }
+                } else {
+                    if (StringUtils.isNotBlank(club.getAddress())) {
+                        list.add("新增了详细地址");
+                    }
+                }*/
+
+                if (StringUtils.isNotBlank(clubVo.getSocialCreditCode())) {
+                    if (StringUtils.isNotBlank(club.getSocialCreditCode())) {
+                        if (!club.getSocialCreditCode().equals(clubVo.getSocialCreditCode())) {
+                            list.add("修改了营业执照编号");
+                            type = 1;
+                        }
+                    } else {
+                        list.add("删除了营业执照编号");
+                        type = 1;
+                    }
+                } else {
+                    if (StringUtils.isNotBlank(club.getSocialCreditCode())) {
+                        list.add("新增了营业执照编号");
+                        type = 1;
+                    }
+                }
+
+                if (StringUtils.isNotBlank(clubVo.getBusinessLicense())) {
+                    if (StringUtils.isNotBlank(club.getBusinessLicense())) {
+                        if (!club.getBusinessLicense().equals(clubVo.getBusinessLicense())) {
+                            list.add("修改了营业执照");
+                            type = 1;
+                        }
+                    } else {
+                        list.add("删除了营业执照");
+                        type = 1;
+                    }
+                } else {
+                    if (StringUtils.isNotBlank(club.getBusinessLicense())) {
+                        list.add("新增了营业执照");
+                        type = 1;
+                    }
+                }
+
+                if (StringUtils.isNotBlank(clubVo.getShopPhoto())) {
+                    if (StringUtils.isNotBlank(club.getShopPhoto())) {
+                        if (!club.getShopPhoto().equals(clubVo.getShopPhoto())) {
+                            list.add("修改了门头照");
+                            type = 1;
+                        }
+                    } else {
+                        list.add("删除了门头照");
+                        type = 1;
+                    }
+                } else {
+                    if (StringUtils.isNotBlank(club.getShopPhoto())) {
+                        list.add("新增了门头照");
+                        type = 1;
+                    }
+                }
+
+                if (clubVo.getFirstClubType() != null) {
+                    if (club.getFirstClubType() != null) {
+                        if (!club.getFirstClubType().equals(clubVo.getFirstClubType())) {
+                            list.add("修改了机构类型分类");
+                            type = 1;
+                        }
+                    } else {
+                        list.add("删除了机构类型分类");
+                        type = 1;
+                    }
+                } else {
+                    if (club.getFirstClubType() != null) {
+                        list.add("新增了机构类型分类");
+                        type = 1;
+                    }
+                }
+
+                if (clubVo.getSecondClubType() != null) {
+                    if (club.getSecondClubType() != null) {
+                        if (!club.getSecondClubType().equals(clubVo.getSecondClubType())) {
+                            list.add("修改了机构类型二级分类");
+                            type = 1;
+                        }
+                    } else {
+                        list.add("删除了机构类型二级分类");
+                        type = 1;
+                    }
+                } else {
+                    if (club.getSecondClubType() != null) {
+                        list.add("新增了机构类型二级分类");
+                        type = 1;
+                    }
+                }
+
+                if (StringUtils.isNotBlank(clubVo.getDepartment())) {
+                    if (StringUtils.isNotBlank(club.getDepartment())) {
+                        if (!club.getDepartment().equals(clubVo.getDepartment())) {
+                            list.add("修改了科室");
+                            type = 1;
+                        }
+                    } else {
+                        list.add("删除了科室");
+                        type = 1;
+                    }
+                } else {
+                    if (StringUtils.isNotBlank(club.getDepartment())) {
+                        list.add("新增了科室");
+                        type = 1;
+                    }
+                }
+
+                if (StringUtils.isNotBlank(clubVo.getMedicalPracticeLicense())) {
+                    if (StringUtils.isNotBlank(club.getMedicalPracticeLicense())) {
+                        if (!club.getMedicalPracticeLicense().equals(clubVo.getMedicalPracticeLicense())) {
+                            list.add("修改了医美分类必须上传医疗执业许可证");
+                            type = 1;
+                        }
+                    } else {
+                        list.add("删除了医美分类必须上传医疗执业许可证");
+                        type = 1;
+                    }
+                } else {
+                    if (StringUtils.isNotBlank(club.getMedicalPracticeLicense())) {
+                        list.add("新增了医美分类必须上传医疗执业许可证");
+                        type = 1;
+                    }
+                }
+
+                if (StringUtils.isNotBlank(clubVo.getMainProduct())) {
+                    if (StringUtils.isNotBlank(club.getMainProduct())) {
+                        if (!club.getMainProduct().equals(clubVo.getMainProduct())) {
+                            list.add("修改了主打项目");
+                            type = 1;
+                        }
+                    } else {
+                        list.add("删除了主打项目");
+                        type = 1;
+                    }
+                } else {
+                    if (StringUtils.isNotBlank(club.getMainProduct())) {
+                        list.add("新增了主打项目");
+                        type = 1;
+                    }
+                }
+
+                if (StringUtils.isNotBlank(clubVo.getFax())) {
+                    if (StringUtils.isNotBlank(club.getFax())) {
+                        if (!club.getFax().equals(clubVo.getFax())) {
+                            list.add("修改了传真");
+                            type = 1;
+                        }
+                    } else {
+                        list.add("删除了传真");
+                        type = 1;
+                    }
+                } else {
+                    if (StringUtils.isNotBlank(club.getFax())) {
+                        list.add("新增了传真");
+                        type = 1;
+                    }
+                }
+
+                if (StringUtils.isNotBlank(clubVo.getContractPhone())) {
+                    if (StringUtils.isNotBlank(club.getContractPhone())) {
+                        if (!club.getContractPhone().equals(clubVo.getContractPhone())) {
+                            list.add("修改了固定电话");
+                            type = 1;
+                        }
+                    } else {
+                        list.add("删除了固定电话");
+                        type = 1;
+                    }
+                } else {
+                    if (StringUtils.isNotBlank(club.getContractPhone())) {
+                        list.add("新增了固定电话");
+                        type = 1;
+                    }
+                }
+
+                if (StringUtils.isNotBlank(clubVo.getProfile())) {
+                    if (StringUtils.isNotBlank(club.getProfile())) {
+                        if (!club.getProfile().equals(clubVo.getProfile())) {
+                            list.add("修改了公司简介");
+                            type = 1;
+                        }
+                    } else {
+                        list.add("删除了公司简介");
+                        type = 1;
+                    }
+                } else {
+                    if (StringUtils.isNotBlank(club.getProfile())) {
+                        list.add("新增了公司简介");
+                        type = 1;
+                    }
+                }
+            }
+        }
+
+        operationalLogsPo.setInstitutionName(club.getName());
+
+        if (StringUtils.isNotBlank(club.getLinkMan())) {
+            operationalLogsPo.setContact(club.getLinkMan());
+        } else {
+            if (StringUtils.isNotBlank(clubVo.getLinkMan())) {
+                operationalLogsPo.setContact(club.getLinkMan());
+            }
+        }
+        operationalLogsPo.setOperationType("编辑");
+        operationalLogsPo.setActionContent(StringUtils.strip(list.toString(),"[]"));
+
+        // 机构修改 机构联系人 为操作人
+        if (StringUtils.isNotBlank(club.getLinkMan())) {
+            operationalLogsPo.setOperator(club.getLinkMan());
+        } else {
+            if (StringUtils.isNotBlank(clubVo.getLinkMan())) {
+                operationalLogsPo.setOperator(clubVo.getLinkMan());
+            }
+        }
+        // 协销帮忙修改 取协销人员
+        if (club.getServiceProviderId() != 0) {
+            String spName = clubMapper.selSpName(club.getServiceProviderId());
+            operationalLogsPo.setOperator(spName);
+        }
+        operationalLogsPo.setOperationTime(new Date());
+
+        log.info("operationalLogsPo====="+operationalLogsPo);
+        clubMapper.insertOpLogs(operationalLogsPo);
+        return type;
+    }
+
     private void saveUserBeans(UserVo user) {
         //机构完善资料,送500采美豆
         UserBeansHistoryPo beansHistory = new UserBeansHistoryPo();
@@ -483,6 +887,7 @@ public class ClubServiceImpl implements ClubService {
             if (newRemarks) {
                 // 新增备注
                 clubMapper.insertRemarks(clubRemarksPo);
+                clubMapper.updateClubNewDeal(clubId);
             } else {
                 // 修改备注
                 clubMapper.updateRemarks(clubRemarksPo);
@@ -1647,4 +2052,466 @@ public class ClubServiceImpl implements ClubService {
     }
 
 
+    @Override
+    public ResponseJson accessRecords(Integer clubId) {
+        List<CmRecordVo> data = new ArrayList<>();
+        ArrayList list = new ArrayList<>();
+        ArrayList<String> listYear = new ArrayList<>();
+        CmRecordVo cmRecordVo = new CmRecordVo();
+        List<RecordVo> records = clubMapper.accessRecords(clubId);
+        String substring = "";
+        if (records.size() > 0) {
+            for (RecordVo recordVo : records) {
+                substring = recordVo.getAccessDate().substring(0, 4);
+                if (!listYear.contains(substring)) {
+                    listYear.add(substring);
+                }
+            }
+            for (int i = 0; i < listYear.size() ; i++) {
+                for (RecordVo recordVo : records) {
+                    if (listYear.get(i).equals(recordVo.getAccessDate().substring(0, 4))) {
+                        recordVo.setMonthAndDay(recordVo.getAccessDate().substring(5));
+                        list.add(recordVo);
+                    }
+                }
+                cmRecordVo.setYear(listYear.get(i));
+                cmRecordVo.setData(list);
+                data.add(cmRecordVo);
+            }
+        }
+        return ResponseJson.success(data);
+    }
+
+    @Override
+    public ResponseJson recordDetail(Integer clubId, String accessDate, String ip, Integer pageNum, Integer pageSize) {
+        PageHelper.startPage(pageNum, pageSize);
+        //访问详情数据
+        List<BehaviorRecodeVo> recordDetail = clubMapper.recordDetail(clubId, accessDate);
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
+        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+
+        List<BehaviorRecodeVo> region = clubMapper.selRegion(ip,accessDate);
+        String format = "";
+        for(BehaviorRecodeVo record: recordDetail) {
+            // 图片处理
+            if (StringUtils.isNotBlank(record.getProductImage())) {
+                record.setProductImage(ImageUtils.getImageURL("product", record.getProductImage(), 0, wwwDomain));
+            }
+            String time = calculationTime(record.getAccessDuration());
+            record.setAccessDuration(time);
+            record.setAccessNewTime(dateFormat.format(record.getAccessTime()));
+            String s = simpleDateFormat.format(record.getAccessTime());
+
+            // 访问来源
+            if (region.size() != 0) {
+                for (BehaviorRecodeVo behaviorRecord : region) {
+                    format = simpleDateFormat.format(behaviorRecord.getAccessTime());
+                    if (StringUtils.isNotBlank(record.getPageType()) && StringUtils.isNotBlank(behaviorRecord.getPageType())) {
+                        if (record.getPageType().equals(behaviorRecord.getPageType()) && s.equals(format)) {
+                            record.setAccessSource(behaviorRecord.getAccessSource());
+                        }
+                    }
+                }
+            }
+        }
+        PageInfo<BehaviorRecodeVo> pageInfo = new PageInfo<>(recordDetail);
+        return ResponseJson.success(pageInfo);
+    }
+
+    @Override
+    public ResponseJson selTotal(Integer clubId) {
+        // 查询机构画像总数据
+        CmPortraitDto cmPortraitDto = clubMapper.selTotal(clubId);
+        return ResponseJson.success(cmPortraitDto);
+    }
+
+    @Override
+    public ResponseJson dataList(CmPortraitDto cmPortrait) {
+        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
+        Date date = new Date();
+        String endTime = "";
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(date);
+        calendar.add(Calendar.DAY_OF_MONTH, -1);
+        Date time = calendar.getTime();
+        endTime = dateFormat.format(time);
+        String time1 = "";
+        String time2 = "";
+        boolean expty = ObjectUtils.isEmpty(cmPortrait.getStartTime()) && ObjectUtils.isEmpty(cmPortrait.getEndTime());
+        if (expty) {
+            Date start = null;
+            String startTime = "";
+            cmPortrait.setEndTime(endTime);
+            // 日期参数为    日
+            if (0 ==  cmPortrait.getDateType() || 1 == cmPortrait.getDateType()) {
+//                cmPortrait.setAccessDate(endTime);
+                cmPortrait.setStartTime(endTime);
+//                cmPortrait.setEndTime(endTime);
+            }
+            if (1 == cmPortrait.getDateType()) {
+//                cmPortrait.setEndTime(endTime);
+                calendar.setTime(time);
+                calendar.add(Calendar.MONTH, -1);
+                start = calendar.getTime();
+                startTime = dateFormat.format(start);
+                cmPortrait.setStartTime(startTime);
+            }
+            if (2 == cmPortrait.getDateType()) {
+//                cmPortrait.setEndTime(endTime);
+                calendar.setTime(time);
+                calendar.add(Calendar.MONTH, -6);
+                start = calendar.getTime();
+                startTime = dateFormat.format(start);
+                cmPortrait.setStartTime(startTime);
+            }
+            if (3 == cmPortrait.getDateType()) {
+//                cmPortrait.setEndTime(endTime);
+                calendar.setTime(time);
+                calendar.add(Calendar.YEAR, -1);
+                start = calendar.getTime();
+                startTime = dateFormat.format(start);
+                cmPortrait.setStartTime(startTime);
+            }
+        } else {
+            time1 = cmPortrait.getStartTime();
+            time2 = cmPortrait.getEndTime();
+        }
+        // 机构订单
+        if (0 == cmPortrait.getType() || 4 == cmPortrait.getType()) {
+            if ((0 ==  cmPortrait.getDateType() || 1 == cmPortrait.getDateType()) && expty) {
+                cmPortrait.setEndTime(dateFormat.format(date));
+            }
+            if (cmPortrait.getEndTime().equals(endTime)) {
+                cmPortrait.setEndTime(dateFormat.format(date));
+            }
+            int ordinary = 0, secondHand = 0, rebate = 0, partialRefund = 0, fullRefund = 0, closed = 0,total = 0;
+            double orderScopeTotalFee = 0.0;
+            ArrayList<PortraitMap> orderPortraits = new ArrayList<>();
+            PortraitMap orderPortrait = new PortraitMap();
+            List<NewOrderPo> orderList = clubMapper.selOrderList(cmPortrait);
+            int length = orderList.size();
+            NumberFormat instance = NumberFormat.getInstance();
+            instance.setMaximumFractionDigits(2);
+            if (length != 0) {
+                for (NewOrderPo order : orderList) {
+                    // 普通订单
+                    if (("0".equals(order.getSecondHandOrderFlag()) || StringUtils.isEmpty(order.getSecondHandOrderFlag()))
+                            && (!"1".equals(order.getRebateFlag()) || "".equals(order.getRebateFlag()) || StringUtils.isEmpty(order.getRebateFlag()))
+                            && ((!"1".equals(order.getRefundType()) && !"2".equals(order.getRefundType())) || "".equals(order.getRefundType()) || StringUtils.isEmpty(order.getRefundType()))
+                            && !"6".equals(order.getStatus())) {
+                        ordinary++;
+                    }
+                    // 二手订单
+                    if ("1".equals(order.getSecondHandOrderFlag()) && !"1".equals(order.getRebateFlag())
+                            && (!"1".equals(order.getRefundType()) && !"2".equals(order.getRefundType())) && !"6".equals(order.getStatus())) {
+                        secondHand++;
+                    }
+                    // 返佣订单
+                    if ("1".equals(order.getRebateFlag()) &&
+                            (!"1".equals(order.getRefundType()) && !"2".equals(order.getRefundType()) || StringUtils.isEmpty(order.getRefundType())) && !"6".equals(order.getStatus())) {
+                        rebate++;
+                    }
+                    // 部分退款
+                    if ("1".equals(order.getRefundType()) && !"6".equals(order.getStatus())) {
+                        partialRefund++;
+                    }
+                    // 全部退款
+                    if ("2".equals(order.getRefundType()) && !"6".equals(order.getStatus())) {
+                        fullRefund++;
+                    }
+                    // 已关闭
+                    if ("6".equals(order.getStatus()) || StringUtils.isEmpty(order.getStatus())) {
+                        closed++;
+                    }
+                    if (null != order.getPayTotalFee()) {
+                        orderScopeTotalFee += order.getPayTotalFee();
+                    }
+                }
+                cmPortrait.setOrderTotal(length);
+                /*cmPortrait.setOrderTotalAmount(new BigDecimal(orderList.get(0).getTotalMoney()));*/
+                // 当前单位订单总额
+                cmPortrait.setOrderScopeTotalFee(Double.valueOf(String.format("%.2f", orderScopeTotalFee)));
+
+                orderPortrait.setValue(ordinary);
+                if (ordinary != 0) {
+                    orderPortrait.setName("普通");
+                    orderPortrait.setPer(instance.format((float)ordinary / (float) length * 100));
+                } else {
+                    orderPortrait.setName("普通");
+                    orderPortrait.setPer("0");
+                }
+                orderPortraits.add(orderPortrait);
+                orderPortrait = new PortraitMap();
+                orderPortrait.setValue(secondHand);
+                if (secondHand != 0) {
+                    orderPortrait.setName("二手");
+                    orderPortrait.setPer(instance.format((float)secondHand / (float) length * 100));
+                } else {
+                    orderPortrait.setName("二手");
+                    orderPortrait.setPer("0");
+                }
+                orderPortraits.add(orderPortrait);
+                orderPortrait = new PortraitMap();
+                orderPortrait.setValue(rebate);
+                if (rebate != 0) {
+                    orderPortrait.setName("返佣");
+                    orderPortrait.setPer(instance.format((float)rebate / (float) length * 100));
+                } else {
+                    orderPortrait.setName("返佣");
+                    orderPortrait.setPer("0");
+                }
+                orderPortraits.add(orderPortrait);
+                orderPortrait = new PortraitMap();
+                orderPortrait.setValue(partialRefund);
+                if (partialRefund != 0) {
+                    orderPortrait.setName("部分退款");
+                    orderPortrait.setPer(instance.format((float)partialRefund / (float) length * 100));
+                } else {
+                    orderPortrait.setName("部分退款");
+                    orderPortrait.setPer("0");
+                }
+                orderPortraits.add(orderPortrait);
+                orderPortrait = new PortraitMap();
+                orderPortrait.setValue(fullRefund);
+                if (fullRefund != 0) {
+                    orderPortrait.setName("全部退款");
+                    orderPortrait.setPer(instance.format((float)fullRefund / (float) length * 100));
+                } else {
+                    orderPortrait.setName("全部退款");
+                    orderPortrait.setPer("0");
+                }
+                orderPortraits.add(orderPortrait);
+                orderPortrait = new PortraitMap();
+                orderPortrait.setValue(closed);
+                if (closed != 0) {
+                    orderPortrait.setName("已关闭");
+                    orderPortrait.setPer(instance.format((float)closed / (float) length * 100));
+                } else {
+                    orderPortrait.setName("已关闭");
+                    orderPortrait.setPer("0");
+                }
+                orderPortraits.add(orderPortrait);
+                cmPortrait.setOrderPortrait(orderPortraits);
+            } else {
+                cmPortrait.setOrderTotalAmount(BigDecimal.ZERO);
+            }
+            // 总量
+            total = ordinary + secondHand + rebate + partialRefund + fullRefund + closed;
+            cmPortrait.setOrderScopeNum(total);
+            calendar.setTime(date);
+            calendar.add(Calendar.DAY_OF_MONTH, -1);
+            time = calendar.getTime();
+            endTime = dateFormat.format(time);
+            cmPortrait.setEndTime(endTime);
+        }
+        // 搜索关键词
+        if (1 == cmPortrait.getType() || 4 == cmPortrait.getType()) {
+            List<BehaviorRecodeVo> behaviorRecordList = clubMapper.selBehaviorList(cmPortrait);
+            int keywordsTotal = 0;
+            ArrayList<Integer> integers = new ArrayList<>();
+            ArrayList<String> strings = new ArrayList<>();
+            if (behaviorRecordList.size() != 0) {
+                for (BehaviorRecodeVo record : behaviorRecordList) {
+                    keywordsTotal += record.getNumber();
+                    integers.add(record.getNumber());
+                    if (!ObjectUtils.isEmpty(record.getPageLabel())) {
+                        strings.add(record.getPageLabel());
+                    } else {
+                        strings.add("未知");
+                    }
+//                    cmPortrait.setTotalKeywords(behaviorRecordList.get(0).getNumbers());
+                    cmPortrait.setBehaviorValue(integers);
+                    cmPortrait.setBehaviorType(strings);
+
+                }
+            }
+            /*else {
+                cmPortrait.setTotalKeywords(0);
+            }*/
+            cmPortrait.setKeyWordsScopeNum(keywordsTotal);
+        }
+        // 咨询记录
+        if (2 == cmPortrait.getType() || 4 == cmPortrait.getType()) {
+            if ((0 ==  cmPortrait.getDateType() || 1 == cmPortrait.getDateType()) && expty) {
+                cmPortrait.setEndTime(dateFormat.format(date));
+            }
+            if (cmPortrait.getEndTime().equals(endTime)) {
+                cmPortrait.setEndTime(dateFormat.format(date));
+            }
+            List<CmClubRemarksVo> remarksList = clubMapper.selRemarksList(cmPortrait);
+//            int remarksTotal = 0;
+            ArrayList<Integer> integers = new ArrayList<>();
+            ArrayList<String> strings = new ArrayList<>();
+            ArrayList<String> strRemark = new ArrayList<>();
+            ArrayList<String> remarkAll = new ArrayList<>();
+            int number = 0;
+            if (remarksList.size() != 0) {
+                for (CmClubRemarksVo remarks: remarksList) {
+                    String[] split = remarks.getRemarks().split(",");
+                    for (String str : split) {
+                        if (!strRemark.contains(str)) {
+                            strRemark.add(str);
+                        }
+                        remarkAll.add(str);
+                    }
+                }
+                for (String str : strRemark) {
+                    for (int i = 0;i < remarkAll.size(); i++) {
+                        if (str.equals(remarkAll.get(i))) {
+                            number++;
+                        }
+                    }
+                    integers.add(number);
+//                    remarksTotal += number;
+                    if (!ObjectUtils.isEmpty(str)) {
+                        strings.add(str);
+                    } else {
+                        strings.add("未知");
+                    }
+                    number = 0;
+                }
+                // 数组根据出现次数排序
+                int temp = 0;
+                String strTemp = "";
+                for (int i = 0; i < integers.size() - 1; i++) {
+                    for (int k = 0; k < integers.size() - 1 - i; k++) {
+                        if (integers.get(k) > integers.get(k+1)) {
+                            temp = integers.get(k);
+                            integers.set(k,integers.get(k+1));
+                            integers.set(k+1,temp);
+
+                            strTemp = strings.get(k);
+                            strings.set(k,strings.get(k+1));
+                            strings.set(k+1,strTemp);
+                        }
+                    }
+                }
+//                cmPortrait.setRemarksTotal(remarksList.get(0).getNumbers());
+                cmPortrait.setRemarksValue(integers);
+                cmPortrait.setRemarksType(strings);
+
+                cmPortrait.setRemarksScopeNum(remarksList.size());
+            } else {
+                cmPortrait.setRemarksScopeNum(0);
+//                cmPortrait.setRemarksTotal(0);
+            }
+            calendar.setTime(date);
+            calendar.add(Calendar.DAY_OF_MONTH, -1);
+            time = calendar.getTime();
+            endTime = dateFormat.format(time);
+            cmPortrait.setEndTime(endTime);
+        }
+        // 访问记录
+        if (3 == cmPortrait.getType() || 4 == cmPortrait.getType()) {
+            List<BehaviorRecodeVo> pageTypeList = clubMapper.selBehaviorPageTypeList(cmPortrait);
+            ArrayList<Integer> integers = new ArrayList<>();
+            ArrayList<String> strings = new ArrayList<>();
+            if (pageTypeList.size() != 0) {
+                for(BehaviorRecodeVo record : pageTypeList) {
+                    integers.add(record.getNumbers());
+                    strings.add(record.getPageLabel());
+                }
+                cmPortrait.setPageTypeValue(integers);
+                cmPortrait.setPageType(strings);
+            }
+        }
+        if (!expty) {
+            cmPortrait.setStartTime(time1);
+            if ((0 ==  cmPortrait.getDateType() || 1 == cmPortrait.getDateType()) && ObjectUtils.isEmpty(cmPortrait.getStartTime())) {
+                cmPortrait.setStartTime(time2);
+            }
+            cmPortrait.setEndTime(time2);
+        }
+        // 数据返回处理
+        Map<String, Object> map = Maps.newLinkedHashMap();
+        try {
+            ArrDateDto order = new ArrDateDto();
+            ArrDateDto behavior = new ArrDateDto();
+            ArrDateDto remarks = new ArrDateDto();
+            ArrDateDto pageType = new ArrDateDto();
+
+//            ArrayList<OrderPortrait> orderPortrait = portrait.getOrderPortrait();
+            order.setOrderList(cmPortrait.getOrderPortrait());
+            if (cmPortrait.getOrderTotal() == null) {
+                cmPortrait.setOrderTotal(0);
+            }
+            order.setOrderTotalNum(cmPortrait.getOrderTotal());
+            order.setStartTime(cmPortrait.getStartTime());
+            order.setEndTime(cmPortrait.getEndTime());
+            if (order.getOrderTotalNum() == 0) {
+                map.put("order",null);
+            } else {
+                map.put("order",order);
+            }
+            behavior.setName(cmPortrait.getBehaviorType());
+            behavior.setValue(cmPortrait.getBehaviorValue());
+            behavior.setStartTime(cmPortrait.getStartTime());
+            behavior.setEndTime(cmPortrait.getEndTime());
+            if (ObjectUtils.isEmpty(behavior.getValue())) {
+                map.put("behavior",null);
+            } else {
+                map.put("behavior",behavior);
+            }
+            remarks.setName(cmPortrait.getRemarksType());
+            remarks.setValue(cmPortrait.getRemarksValue());
+            remarks.setStartTime(cmPortrait.getStartTime());
+            remarks.setEndTime(cmPortrait.getEndTime());
+            if (ObjectUtils.isEmpty(remarks.getValue())) {
+                map.put("remarks",null);
+            } else {
+                map.put("remarks",remarks);
+            }
+            pageType.setName(cmPortrait.getPageType());
+            pageType.setValue(cmPortrait.getPageTypeValue());
+            pageType.setStartTime(cmPortrait.getStartTime());
+            pageType.setEndTime(cmPortrait.getEndTime());
+            if (ObjectUtils.isEmpty(pageType.getValue())) {
+                map.put("pageType",null);
+            } else {
+                map.put("pageType",pageType);
+            }
+            map.put("portrait",cmPortrait);
+            map.put("code",0);
+        } catch (Exception e) {
+            e.printStackTrace();
+            map.put("code",-1);
+        }
+        return ResponseJson.success(map);
+    }
+    /**
+     * 时间计算
+     * @param recordTime
+     * @return
+     */
+    public String calculationTime(String recordTime){
+        double doc = Double.parseDouble(recordTime);
+        int num = (int)doc;
+        //小时
+        int HH = 0;
+        // 分钟
+        int mm = 0;
+        //秒
+        int ss = 0;
+        int item = num / 1000;
+        if ((item / 60) >0) {
+            mm = item / 60;
+            ss = item % 60;
+        } else {
+            ss = item;
+        }
+        if ((mm / 60) >0) {
+            HH = mm / 60;
+            mm = mm % 60;
+        }
+        String  str= HH+":"+mm+":"+ss;
+        SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
+        Date parse = null;
+        try {
+            parse = dateFormat.parse(str);
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        String format = dateFormat.format(parse);
+        return format;
+    }
 }

+ 165 - 3
src/main/resources/mapper/ClubMapper.xml

@@ -26,6 +26,11 @@
         values (#{questionMan}, #{questionManId}, #{serviceProviderId}, #{remarks}, now(), #{consult}, #{clubType},
                 #{pinceSensitve}, #{satisfied}, #{followup}, #{extra}, #{reportId}, #{productId})
     </insert>
+    <update id="updateClubNewDeal">
+        update club
+        set newDeal = 2
+        where clubId = #{clubId}
+    </update>
     <insert id="insertVisitorRemarksImage">
         insert into cm_visitor_remarks_file(remarksId, fileType, imageUrl)
         values (#{remarksId}, 1, #{image})
@@ -74,6 +79,51 @@
         userName = #{userName}
         where userID = #{userId}
     </update>
+    <select id="selClubData" resultType="com.caimei365.user.model.vo.ClubVo">
+        select
+        userId,
+        clubId,
+        name,
+        linkMan,
+        linkManIdentity,
+        contractEmail,
+        sname as shortName,
+        provinceId,
+        cityId,
+        townId,
+        address,
+        socialCreditCode,
+        businessLicenseImage as businessLicense,
+        headpic as shopPhoto,
+        firstClubType,
+        secondClubType,
+        department,
+        medicalPracticeLicenseImg as medicalPracticeLicense,
+        mainpro as mainProduct,
+        fax,
+        contractPhone,
+        info as profile
+        from club where clubID = #{clubID}
+    </select>
+    <select id="selSpName" resultType="java.lang.String">
+        select case status when 91 then '采美默认协销经理(官方账号)' else linkMan end AS spName
+               from serviceprovider where serviceProviderID = #{serviceProviderId}
+    </select>
+    <insert id="insertOpLogs">
+        INSERT INTO operational_logs
+        (institutionName,
+         Contact,
+         operationtype,
+         Actioncontent,
+         Operator,
+         Operationtime)
+        VALUES (#{institutionName},
+                #{contact},
+                #{operationType},
+                #{actionContent},
+                #{operator},
+                #{operationTime})
+    </insert>
     <update id="updateClubByUpdateInfo">
         update club set
         <if test="name != null and name != ''">
@@ -114,9 +164,11 @@
         <if test="mainProduct != null and mainProduct != ''">
             mainpro = #{mainProduct},
         </if>
+        <if test="lastModify != null and lastModify != ''">
+            lastModify = #{lastModify},
+        </if>
         fax = #{fax},
-        info = #{profile},
-        lastModify = NOW()
+        info = #{profile}
         where clubID = #{clubId}
     </update>
     <delete id="clearRemarksFiles">
@@ -157,7 +209,7 @@
                provinceID                as proviceId,
                cityID                    as cityId,
                townID                    as townId,
-               ifnull(address, '暂无')     as address,
+               ifnull(address,'暂无')     as address,
                headpic                   as shopPhoto,
                businessLicenseImage      as businessLicense,
                socialCreditCode,
@@ -891,6 +943,10 @@
 
     </select>
 
+    <select id="selAddTime" resultType="java.lang.String">
+        select addTime from record_link where clubId = #{clubId} order by addTime desc limit 1
+    </select>
+
     <select id="serviceProviderNameage" resultType="java.lang.String">
         select linkMan
         from `serviceprovider`
@@ -962,6 +1018,112 @@
         LEFT JOIN cm_serviceteam_group csg ON csr.id=csg.teamId
         WHERE csg.serviceId = #{spId}
     </select>
+    <select id="selTotal" resultType="com.caimei365.user.model.dto.CmPortraitDto">
+        SELECT
+            (SELECT COUNT(orderID) FROM cm_order WHERE clubID = #{clubId} AND orderTime <![CDATA[ < ]]> now()) AS orderTotal,
+            (SELECT SUM(payTotalFee) FROM cm_order WHERE clubID = #{clubId} AND orderTime <![CDATA[ < ]]> now()) AS orderTotalAmount,
+            (SELECT COUNT(cbr.recordID) FROM cm_behavior_record cbr LEFT JOIN club c ON cbr.userID = c.userID WHERE cbr.pageType IN (8, 9) AND c.clubID = #{clubId} AND cbr.accessDate <![CDATA[ < ]]> now()) AS totalkeywords ,
+            (SELECT COUNT(remarks) FROM cm_club_remarks WHERE clubID = #{clubId} AND addTime <![CDATA[ < ]]> now()) AS remarksTotal
+    </select>
+    <select id="accessRecords" resultType="com.caimei365.user.model.vo.RecordVo">
+        SELECT accessDate,COUNT(cbr.recordID) AS number,IP AS ip
+        FROM cm_behavior_record cbr
+        LEFT JOIN club c ON cbr.userID = c.userID
+        WHERE cbr.delFlag = 0
+          AND c.clubID = #{clubId}
+        GROUP BY cbr.IP, cbr.accessDate ORDER BY cbr.accessDate DESC
+    </select>
+    <select id="recordDetail" resultType="com.caimei365.user.model.vo.BehaviorRecodeVo">
+        SELECT
+            pt.pageType,
+            b.pageLabel,
+            p.name AS productName,
+            p.mainImage AS productImage,
+            b.accessDuration,
+            b.accessSource,
+            b.accessClient,
+            b.accessTime
+        FROM cm_behavior_record b
+         LEFT JOIN club c ON b.userID = c.userID
+         LEFT JOIN product p ON b.productID = p.productID
+         LEFT JOIN cm_page_type pt ON b.pageType = pt.id
+        WHERE c.clubID = #{clubId} AND b.accessDate = #{accessDate} order by b.accessTime desc
+    </select>
+    <select  id="selOrderList" resultType="com.caimei365.user.model.po.NewOrderPo">
+        SELECT
+        (SELECT COUNT(orderID) FROM cm_order WHERE clubID = #{clubId}) as numbers,
+        (SELECT SUM(payTotalFee) FROM cm_order WHERE clubID = #{clubId}) as totalMoney,
+        clubID,
+        secondHandOrderFlag,
+        rebateFlag,
+        refundType,
+        payTotalFee,
+        STATUS,
+        orderTime
+        FROM cm_order
+        <where>
+            clubID = #{clubId}
+            <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
+                AND orderTime <![CDATA[ >= ]]> #{startTime} AND orderTime <![CDATA[ <= ]]> #{endTime}
+            </if>
+        </where>
+    </select>
+    <select id="selBehaviorList" resultType="com.caimei365.user.model.vo.BehaviorRecodeVo">
+        SELECT
+        c.clubID,
+        COUNT(cbr.pageLabel) as number,
+        cbr.pageLabel,
+        cbr.accessDate
+        FROM cm_behavior_record cbr LEFT JOIN club c ON cbr.userID = c.userID
+        <where>
+            cbr.pageType IN (8, 9) AND c.clubID = #{clubId} AND cbr.pageLabel IS NOT NULL AND cbr.pageLabel != ''
+            <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
+                AND cbr.accessDate <![CDATA[ >= ]]> #{startTime} AND cbr.accessDate <![CDATA[ <= ]]> #{endTime}
+            </if>
+        </where>
+        GROUP BY cbr.pageLabel
+        ORDER BY COUNT(cbr.pageLabel) LIMIT 10
+    </select>
+    <select id="selRegion" resultType="com.caimei365.user.model.vo.BehaviorRecodeVo">
+        SELECT
+            IP as ip,
+            accessSource,
+            accessTime,
+            pageType
+        FROM cm_behavior_record_ref WHERE IP = #{ip} AND accessTime like concat('%', #{accessDate} ,'%')
+    </select>
+    <select id="selRemarksList" resultType="com.caimei365.user.model.vo.CmClubRemarksVo">
+        SELECT
+        (SELECT COUNT(remarks) FROM cm_club_remarks WHERE clubID = #{clubId}) as numbers,
+        clubID,
+        COUNT(remarks) as number,
+        remarks,
+        addTime
+        FROM cm_club_remarks
+        <where>
+            clubID = #{clubId}
+            <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
+                AND addTime <![CDATA[ >= ]]> #{startTime} AND addTime <![CDATA[ <= ]]> #{endTime}
+            </if>
+        </where>
+        GROUP BY remarks ORDER BY COUNT(remarks) LIMIT 10
+    </select>
+    <select id="selBehaviorPageTypeList" resultType="com.caimei365.user.model.vo.BehaviorRecodeVo">
+        SELECT
+        c.clubID,
+        COUNT(cbr.pageType) as numbers,
+        cbr.pageLabel,
+        cbr.accessDate
+        FROM cm_behavior_record cbr
+        LEFT JOIN club c ON cbr.userID = c.userID
+        <where>
+            c.clubID = #{clubId}
+            <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
+                AND cbr.accessDate <![CDATA[ >= ]]> #{startTime} AND cbr.accessDate <![CDATA[ <= ]]> #{endTime}
+            </if>
+        </where>
+        GROUP BY cbr.pageType  ORDER BY COUNT(cbr.pageType) LIMIT 10
+    </select>
     <select id="findBanks" resultType="com.caimei365.user.model.vo.BanksVo">
         SELECT DISTINCT id, bankNumber, bankType, cqb.bankName
         FROM cm_quickpay_info cqi

+ 2 - 0
src/main/resources/mapper/SellerMapper.xml

@@ -112,12 +112,14 @@
         c.mainpro as mainProduct, c.fax, c.info as profile, c.spID as serviceProviderId, c.addTime, c.status,
         c.lastCheckOrderDate,
         u.userIdentity,c.newDeal as newDeal,IF(r.id IS NOT NULL,1,0) AS recordCount,
+        sp.name AS serviceName,
         covs.activeState AS activeState,
         covs.customerValue AS customerValue
         from club c
         left join user u on c.userID = u.userID
         LEFT JOIN record_link r ON r.`clubId`=c.`clubID`
         LEFT JOIN cm_organ_value_system covs ON covs.userID = u.userID
+        LEFT JOIN serviceprovider sp ON c.spID = sp.serviceProviderID
         where
         <if test="1 == type">
             c.spID = #{serviceProviderId}