Jelajahi Sumber

用户行为优化1.0.4

huangzhiguo 1 tahun lalu
induk
melakukan
e61480697b

+ 2 - 0
src/main/java/com/caimei/modules/user/dao/NewCmClubDao.java

@@ -101,4 +101,6 @@ public interface NewCmClubDao extends CrudDao<NewCmClub> {
     List<String> getClubIds();
 
     List<ActiveClub> getActiveClubInfo(ActiveClub activeClub);
+
+    List<ActiveClubExcel> getExportActiveClubInfo(ActiveClub activeClub);
 }

+ 2 - 1
src/main/java/com/caimei/modules/user/entity/ActiveClub.java

@@ -1,5 +1,7 @@
 package com.caimei.modules.user.entity;
 
+import com.alibaba.excel.annotation.ExcelIgnore;
+import com.alibaba.excel.annotation.ExcelProperty;
 import com.thinkgem.jeesite.common.persistence.DataEntity;
 
 /**
@@ -24,7 +26,6 @@ public class ActiveClub  extends DataEntity<ActiveClub> {
     private String provinceID;
     // 市
     private String cityID;
-
     private String province;
     private String city;
     private String town;

+ 325 - 0
src/main/java/com/caimei/modules/user/entity/ActiveClubExcel.java

@@ -0,0 +1,325 @@
+package com.caimei.modules.user.entity;
+
+import com.alibaba.excel.annotation.ExcelIgnore;
+import com.alibaba.excel.annotation.ExcelProperty;
+
+/**
+ * Description
+ *
+ * @author : hzg
+ * @date : 2024/1/17
+ */
+public class ActiveClubExcel {
+    @ExcelIgnore
+    private Integer userID; // 用户Id
+    @ExcelProperty(value = "机构Id", index = 0)
+    private Integer clubID; // 机构Id
+    // 省
+    @ExcelIgnore
+    private String provinceID;
+    // 市
+    @ExcelIgnore
+    private String cityID;
+    @ExcelIgnore
+    private String province;
+    @ExcelIgnore
+    private String city;
+    @ExcelIgnore
+    private String town;
+    @ExcelProperty(value = "机构名称", index = 1)
+    private String name;    // 机构名称
+    @ExcelProperty(value = "联系人", index = 2)
+    private String linkMan; //联系人
+    @ExcelProperty(value = "联系手机", index = 4)
+    private String contractMobile;  //联系手机
+    @ExcelIgnore
+    private String linkManIdentity; //联系人身份:1老板,2采购,3运营,4其他
+    @ExcelIgnore
+    private Integer spID;   // 协销Id
+    @ExcelProperty(value = "协销人员", index = 5)
+    private String spName;      //协销人员
+    @ExcelProperty(value = "地址", index = 6)
+    private String address;         //详细地址
+    @ExcelIgnore
+    private String userIdentity;    //用户身份
+    @ExcelIgnore
+    private String sname;   //机构简称
+    @ExcelProperty(value = "联系人身份", index = 3)
+    private String linkManStatus;   //联系人身份
+    @ExcelProperty(value = "状态", index = 7)
+    private String clubStatus;  // 机构状态
+    @ExcelProperty(value = "机构类型", index = 8)
+    private String clubType;  // 机构类型
+    @ExcelProperty(value = "机构级别", index = 9)
+    private String clubRank;  // 机构级别
+    @ExcelIgnore
+    private String firstClubType;  // 机构一级分类
+    @ExcelIgnore
+    private String classify;  // 机构二级分类
+    @ExcelIgnore
+    private String addTime;  // 注册时间
+    @ExcelIgnore
+    private String svipUserFlag;  // vip类别
+    @ExcelIgnore
+    private String activeStatus;     // 活跃状态 0:活跃、1:不活跃
+    @ExcelIgnore
+    private String activeState;     // 活跃状态
+    @ExcelIgnore
+    private String customerValues;   // 客户价值
+    @ExcelProperty(value = "注册时间", index = 10)
+    private String registerTime;    // 注册时间
+    @ExcelProperty(value = "最近访问时间", index = 11)
+    private String behaviorTime;    // 最近访问时间
+    @ExcelProperty(value = "最近下单时间", index = 13)
+    private String lastOrderTime;  // 最近下单时间
+    @ExcelProperty(value = "最近咨询时间", index = 12)
+    private String recentlyTime;    //最近咨询时间
+
+    public Integer getUserID() {
+        return userID;
+    }
+
+    public void setUserID(Integer userID) {
+        this.userID = userID;
+    }
+
+    public Integer getClubID() {
+        return clubID;
+    }
+
+    public void setClubID(Integer clubID) {
+        this.clubID = clubID;
+    }
+
+    public String getProvinceID() {
+        return provinceID;
+    }
+
+    public void setProvinceID(String provinceID) {
+        this.provinceID = provinceID;
+    }
+
+    public String getCityID() {
+        return cityID;
+    }
+
+    public void setCityID(String cityID) {
+        this.cityID = cityID;
+    }
+
+    public String getProvince() {
+        return province;
+    }
+
+    public void setProvince(String province) {
+        this.province = province;
+    }
+
+    public String getCity() {
+        return city;
+    }
+
+    public void setCity(String city) {
+        this.city = city;
+    }
+
+    public String getTown() {
+        return town;
+    }
+
+    public void setTown(String town) {
+        this.town = town;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getLinkMan() {
+        return linkMan;
+    }
+
+    public void setLinkMan(String linkMan) {
+        this.linkMan = linkMan;
+    }
+
+    public String getContractMobile() {
+        return contractMobile;
+    }
+
+    public void setContractMobile(String contractMobile) {
+        this.contractMobile = contractMobile;
+    }
+
+    public String getLinkManIdentity() {
+        return linkManIdentity;
+    }
+
+    public void setLinkManIdentity(String linkManIdentity) {
+        this.linkManIdentity = linkManIdentity;
+    }
+
+    public Integer getSpID() {
+        return spID;
+    }
+
+    public void setSpID(Integer spID) {
+        this.spID = spID;
+    }
+
+    public String getSpName() {
+        return spName;
+    }
+
+    public void setSpName(String spName) {
+        this.spName = spName;
+    }
+
+    public String getAddress() {
+        return address;
+    }
+
+    public void setAddress(String address) {
+        this.address = address;
+    }
+
+    public String getUserIdentity() {
+        return userIdentity;
+    }
+
+    public void setUserIdentity(String userIdentity) {
+        this.userIdentity = userIdentity;
+    }
+
+    public String getSname() {
+        return sname;
+    }
+
+    public void setSname(String sname) {
+        this.sname = sname;
+    }
+
+    public String getLinkManStatus() {
+        return linkManStatus;
+    }
+
+    public void setLinkManStatus(String linkManStatus) {
+        this.linkManStatus = linkManStatus;
+    }
+
+    public String getClubStatus() {
+        return clubStatus;
+    }
+
+    public void setClubStatus(String clubStatus) {
+        this.clubStatus = clubStatus;
+    }
+
+    public String getClubType() {
+        return clubType;
+    }
+
+    public void setClubType(String clubType) {
+        this.clubType = clubType;
+    }
+
+    public String getClubRank() {
+        return clubRank;
+    }
+
+    public void setClubRank(String clubRank) {
+        this.clubRank = clubRank;
+    }
+
+    public String getFirstClubType() {
+        return firstClubType;
+    }
+
+    public void setFirstClubType(String firstClubType) {
+        this.firstClubType = firstClubType;
+    }
+
+    public String getClassify() {
+        return classify;
+    }
+
+    public void setClassify(String classify) {
+        this.classify = classify;
+    }
+
+    public String getAddTime() {
+        return addTime;
+    }
+
+    public void setAddTime(String addTime) {
+        this.addTime = addTime;
+    }
+
+    public String getSvipUserFlag() {
+        return svipUserFlag;
+    }
+
+    public void setSvipUserFlag(String svipUserFlag) {
+        this.svipUserFlag = svipUserFlag;
+    }
+
+    public String getActiveStatus() {
+        return activeStatus;
+    }
+
+    public void setActiveStatus(String activeStatus) {
+        this.activeStatus = activeStatus;
+    }
+
+    public String getActiveState() {
+        return activeState;
+    }
+
+    public void setActiveState(String activeState) {
+        this.activeState = activeState;
+    }
+
+    public String getCustomerValues() {
+        return customerValues;
+    }
+
+    public void setCustomerValues(String customerValues) {
+        this.customerValues = customerValues;
+    }
+
+    public String getRegisterTime() {
+        return registerTime;
+    }
+
+    public void setRegisterTime(String registerTime) {
+        this.registerTime = registerTime;
+    }
+
+    public String getBehaviorTime() {
+        return behaviorTime;
+    }
+
+    public void setBehaviorTime(String behaviorTime) {
+        this.behaviorTime = behaviorTime;
+    }
+
+    public String getLastOrderTime() {
+        return lastOrderTime;
+    }
+
+    public void setLastOrderTime(String lastOrderTime) {
+        this.lastOrderTime = lastOrderTime;
+    }
+
+    public String getRecentlyTime() {
+        return recentlyTime;
+    }
+
+    public void setRecentlyTime(String recentlyTime) {
+        this.recentlyTime = recentlyTime;
+    }
+}

+ 38 - 0
src/main/java/com/caimei/modules/user/service/NewCmClubService.java

@@ -347,6 +347,44 @@ public class NewCmClubService extends CrudService<NewCmClubDao, NewCmClub> {
         return page;
     }
 
+    public List<ActiveClubExcel> exportClubActive(ActiveClub activeClub) {
+        List<ActiveClubExcel> clubActiveExcel = newCmClubDao.getExportActiveClubInfo(activeClub);
+        clubActiveExcel.forEach( club -> {
+            // 设置地址
+            if (StringUtils.isNotBlank(club.getProvince())) {
+                club.setAddress(club.getProvince());
+            }
+            if (StringUtils.isNotBlank(club.getCity())) {
+                club.setAddress(club.getAddress() + club.getCity());
+            }
+            // 设置机构类型
+            if (StringUtils.isNotBlank(club.getFirstClubType())) {
+                club.setClubType(club.getFirstClubType());
+            }
+            if (StringUtils.isNotBlank(club.getClassify())) {
+                club.setClubType(club.getClubType() + "-" + club.getClassify());
+            }
+            // 设置机构级别
+            if (StringUtils.isNotBlank(club.getUserIdentity())) {
+                if ("4".equals(club.getUserIdentity())) {
+                    club.setClubRank("个人机构");
+                }
+                if ("2".equals(club.getUserIdentity())) {
+                    club.setClubRank("资质机构");
+                }
+                if (StringUtils.isNotBlank(club.getSvipUserFlag())) {
+                    if ("1".equals(club.getSvipUserFlag())) {
+                        club.setClubRank(club.getClubRank() + "(超级会员)");
+                    }
+                    if ("2".equals(club.getUserIdentity()) && "0".equals(club.getSvipUserFlag())) {
+                        club.setClubRank(club.getClubRank() + "(普通会员)");
+                    }
+                }
+            }
+        });
+        return clubActiveExcel;
+    }
+
     public List<easyExcel> exportExcel(ClubStatistics statistics) {
         List<easyExcel> statisticsList = newCmClubDao.findExcelList(statistics);
         List<easyExcel> easyExcels = setExData(statisticsList, statistics);

+ 20 - 0
src/main/java/com/caimei/modules/user/web/newUser/AgencyController.java

@@ -2039,4 +2039,24 @@ public class AgencyController extends BaseController {
         model.addAttribute("spNameList", spNameList);
         return "modules/userNew/activeClubInfoList";
     }
+
+    @RequestMapping("/exportClubActiveInfo")
+    public void exportClubActiveInfo(ActiveClub activeClub, HttpServletRequest request, HttpServletResponse response , RedirectAttributes redirectAttributes) {
+        String name = "客户活跃情况";
+        try {
+
+            List<ActiveClubExcel> clubActive = newCmClubService.exportClubActive(activeClub);
+            response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
+            response.setCharacterEncoding("utf-8");
+            // 这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系
+            String fileName = URLEncoder.encode(name, "UTF-8").replaceAll("\\+", "%20");
+            response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
+            // 这里需要设置不关闭流
+            EasyExcel.write(response.getOutputStream(), ActiveClubExcel.class).autoCloseStream(Boolean.FALSE).sheet("客户活跃情况")
+                    .doWrite(clubActive);
+        } catch (Exception e) {
+            addMessage(redirectAttributes, "机构活跃数据导出失败", e.getMessage());
+            e.printStackTrace();
+        }
+    }
 }

+ 1 - 1
src/main/resources/mappings/modules/user/CmPortraitMapper.xml

@@ -287,7 +287,7 @@
     <select id="getActiveInfo" resultType="com.caimei.modules.user.entity.ClubData">
         SELECT
             coas.activeStatus as activeStatus,
-            COUNT(coas.id) as number
+            COUNT(c.clubId) as number
         FROM cm_organ_active_system coas
                  LEFT JOIN club c ON coas.userId = c.userId
                  LEFT JOIN serviceprovider s ON s.serviceProviderId = c.spId

+ 1 - 1
src/main/resources/mappings/modules/user/CmUserMapper.xml

@@ -555,6 +555,6 @@
     <insert id="insertActiveOrgan">
         INSERT INTO cm_organ_active_system
             (userID, activeState, activeStatus, stage, addTime, delType)
-        VALUES (#{userId}, '活跃', 0, 0, date_format(now(), '%Y-%m-%d'), 1)
+        VALUES (#{userId}, '活跃用户', 0, 0, date_format(now(), '%Y-%m-%d'), 1)
     </insert>
 </mapper>

+ 139 - 3
src/main/resources/mappings/modules/user/NewCmClubMapper.xml

@@ -1546,11 +1546,147 @@
                 AND cso.orderTime <![CDATA[ <= ]]> #{orderEndTime}
             </if>
         </where>
-        <if test="orderByType == null or orderByType == 1">
+        <if test="orderByType == null">
             ORDER BY cb.accessTime DESC
         </if>
-        <if test="orderByType == 2">
-            ORDER BY cb.accessTime asc
+        <if test="orderByType != null">
+            <if test="orderByType == 1">
+                ORDER BY cb.accessTime DESC
+            </if>
+            <if test="orderByType == 2">
+                ORDER BY cb.accessTime asc
+            </if>
+        </if>
+    </select>
+
+    <select id="getExportActiveClubInfo" resultType="com.caimei.modules.user.entity.ActiveClubExcel">
+        SELECT
+        DISTINCT u.userId,
+        coas.activeStatus,
+        c.clubID,
+        c.name,
+        c.linkMan,
+        c.contractMobile,
+        c.linkManIdentity,
+        c.address,
+        u.userIdentity,
+        u.registerTime,
+        c.sname,
+        c.info,
+        d.name AS province,
+        c.name AS city,
+        b.name AS  town,
+        (CASE WHEN c.linkManIdentity=1 THEN '老板'
+        WHEN c.linkManIdentity=2 THEN '采购'
+        WHEN c.linkManIdentity=3 THEN '运营'
+        WHEN c.linkManIdentity=4 THEN '其他'
+        END) AS linkManStatus,
+        (CASE WHEN c.status = 1 THEN '待审核'
+        WHEN c.status=91 THEN '已下线'
+        WHEN c.status=90 THEN '已上线'
+        WHEN c.status=92 THEN '审核未通过'
+        WHEN c.status=93 THEN '已确认'
+        ELSE '已冻结' END) AS clubStatus,
+        (CASE WHEN u.userIdentity=2 THEN '资质机构'
+        ELSE '个人机构' END) AS clubRank,
+        (CASE WHEN c.firstClubType=1 THEN '医美'
+        WHEN c.firstClubType=2 THEN '生美'
+        WHEN c.firstClubType=3 THEN '项目公司'
+        WHEN c.firstClubType=4 THEN '个人'
+        ELSE '其他' END) AS firstClubType,
+        (CASE WHEN c.secondClubType=1 THEN '诊所'
+        WHEN c.secondClubType=2 THEN '门诊'
+        WHEN c.secondClubType=3 THEN '医院'
+        WHEN c.secondClubType=5 THEN '美容院'
+        WHEN c.secondClubType=6 THEN '养生馆'
+        WHEN c.secondClubType=7 THEN '其他'
+        END) AS classify,
+        c.addTime AS addTime,
+        IF(csu.delFlag = '0' AND NOW() <![CDATA[ < ]]> csu.endTime,1,0) AS svipUserFlag,
+        CASE sp.status WHEN 91 THEN '采美默认协销经理(官方账号)' ELSE sp.linkMan END AS spName,
+        cb.accessTime AS behaviorTime,
+        ccr.addTime AS recentlyTime,
+        cso.orderTime as lastOrderTime
+        FROM club c
+        LEFT JOIN cm_organ_active_system coas ON coas.userId = c.userID
+        LEFT JOIN USER u ON u.userId = c.userId
+        LEFT JOIN cm_svip_user csu ON csu.userId = u.userID
+        LEFT JOIN serviceprovider sp ON sp.serviceProviderID = c.spID
+        LEFT JOIN town b ON b.townID = c.townID
+        LEFT JOIN city ct ON ct.cityID = c.cityID
+        LEFT JOIN province d ON d.provinceID = c.provinceID
+        LEFT JOIN (SELECT userId, MAX(accessTime) AS accessTime FROM cm_behavior_record WHERE delFlag = 0 AND userId != 0 GROUP BY userId) cb ON cb.userId = c.userId
+        LEFT JOIN (SELECT clubId, ADDTIME FROM (SELECT clubId, ADDTIME FROM cm_club_remarks
+        UNION SELECT clubId, ADDTIME FROM cm_visitor_remarks WHERE clubId IS NOT NULL AND clubId != '') remark
+        GROUP BY remark.clubId ORDER BY remark.addTime DESC) ccr ON ccr.clubId = c.clubId
+        LEFT JOIN (SELECT userId, MAX(orderTime) AS orderTime FROM cm_shop_order  GROUP BY userId) cso ON cso.userId = c.userId
+        <where>
+            coas.stage = 0
+            <if test="activeStatus == 0">
+                and coas.activeStatus = 0
+            </if>
+            <if test="activeStatus == 1">
+                and coas.activeStatus = 1
+            </if>
+            <if test="clubID != null and clubID != ''">
+                AND c.clubID = #{clubID}
+            </if>
+            <if test="name != null and name != ''">
+                AND c.name LIKE concat('%',#{name},'%')
+            </if>
+            <if test="linkMan != null and linkMan != ''">
+                AND c.linkMan LIKE concat('%',#{linkMan},'%')
+            </if>
+            <if test="contractMobile != null and contractMobile != ''">
+                AND c.contractMobile LIKE concat('%',#{contractMobile},'%')
+            </if>
+            <if test="spID != null and spID != ''">
+                AND c.spID = #{spID}
+            </if>
+            <if test="firstClubType != null and firstClubType != ''">
+                AND c.firstClubType = #{firstClubType}
+            </if>
+            <if test="linkManIdentity != null and linkManIdentity != ''">
+                AND c.linkManIdentity = #{linkManIdentity}
+            </if>
+            <if test="userIdentity != null and userIdentity != ''">
+                AND u.userIdentity = #{userIdentity}
+            </if>
+            <if test="registerStartTime != null and registerStartTime != ''">
+                AND u.registerTime <![CDATA[ >= ]]> #{registerStartTime}
+            </if>
+            <if test="registerEndTime != null and registerEndTime != ''">
+                AND u.registerTime <![CDATA[ <= ]]> #{registerEndTime}
+            </if>
+            <if test="behaviorStartTime != null and behaviorStartTime != ''">
+                AND cb.accessTime <![CDATA[ >= ]]> #{behaviorStartTime}
+            </if>
+            <if test="behaviorEndTime != null and behaviorEndTime != ''">
+                AND cb.accessTime <![CDATA[ <= ]]> #{behaviorEndTime}
+            </if>
+            <if test="recentlyStartTime != null and recentlyStartTime != ''">
+                AND ccr.addTime <![CDATA[ >= ]]> #{recentlyStartTime}
+            </if>
+            <if test="recentlyEndTime != null and recentlyEndTime != ''">
+                AND ccr.addTime <![CDATA[ <= ]]> #{recentlyEndTime}
+            </if>
+            <if test="orderStartTime != null and orderStartTime != ''">
+                AND cso.orderTime <![CDATA[ >= ]]> #{orderStartTime}
+            </if>
+            <if test="orderEndTime != null and orderEndTime != ''">
+                AND cso.orderTime <![CDATA[ <= ]]> #{orderEndTime}
+            </if>
+        </where>
+        <if test="orderByType == null">
+            ORDER BY cb.accessTime DESC
+        </if>
+        <if test="orderByType != null">
+            <if test="orderByType == 1">
+                ORDER BY cb.accessTime DESC
+            </if>
+            <if test="orderByType == 2">
+                ORDER BY cb.accessTime asc
+            </if>
         </if>
     </select>
 </mapper>

+ 1 - 1
src/main/resources/mappings/modules/weisha/CmOrganizeStoreMapper.xml

@@ -143,7 +143,7 @@
         cmou.clubId,
         cmou.linkName,
         u.userName AS name,
-        u.bindMobile AS mobile,
+        cmou.mobile AS mobile,
         cmou.status,
         cmou.bindTime,
         cmou.addTime

+ 9 - 2
src/main/webapp/WEB-INF/views/modules/userNew/activeClubInfoList.jsp

@@ -332,6 +332,12 @@
         $('#searchForm').submit();
     })
 
+    // 导出
+    $('#export').click( function () {
+        var formData = $('#searchForm').serialize();
+        window.location.href= "${ctx}/new/user/agency/exportClubActiveInfo?"+formData
+    })
+
     function goNewBack(type, addTime, userIdentity, name, linkMan, clubId) {
         // 跳转到新后台查询数据 type: 1 访问记录 2:咨询记录
         const date = getZeroTimeToday();
@@ -408,7 +414,8 @@
             }
         }
         const setActiveFn = function (type,num){
-            if( type === 0){
+            console.log('type====', type)
+            if( type === 1){
                 typeMap[num].dom.find('.icon-up').addClass('active');
             }else{
                 typeMap[num].dom.find('.icon-down').addClass('active');
@@ -423,7 +430,7 @@
             }
         }
         // 最近访问时间 1 降序  2 升序
-        if(typeMap[1].val || typeMap[1].val === 0) {
+        if(typeMap[1].val || typeMap[1].val === 1) {
             setActiveFn(typeMap[1].val,1)
         }
         // 活跃、不活跃机构