门店推广数据接口
parent
0c7fe8852a
commit
c4aab3efa2
@ -0,0 +1,70 @@
|
||||
package com.kiisoo.ic.store.controller;
|
||||
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.kiisoo.ic.common.BaseController;
|
||||
import com.kiisoo.ic.store.entity.StorePromotionDataDO;
|
||||
import com.kiisoo.ic.store.service.StoreEmployeeService;
|
||||
import com.kiisoo.ic.store.service.StorePromotionDataService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author yunjie.jiang
|
||||
* @date 2020/4/10 10:49
|
||||
* @company kiisoo
|
||||
* @details 门店推广数据controller
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/store/promotion/data")
|
||||
@Slf4j
|
||||
public class StorePromotionDataController extends BaseController {
|
||||
|
||||
/**
|
||||
* 推广数据数据
|
||||
*/
|
||||
@Autowired
|
||||
private StorePromotionDataService storePromotionDataService;
|
||||
|
||||
/**
|
||||
* 查询门店推广数据列表
|
||||
* @param userId
|
||||
* @param storeId
|
||||
* @param regionId
|
||||
* @param sellerId
|
||||
* @param startDate
|
||||
* @param endDate
|
||||
* @param type 页面类型 "region".区域, "store".门店, "seller".导购
|
||||
* @param pageNum
|
||||
* @param pageSize
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "list",method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Map<String,Object> listStorePromotionDate(@RequestParam("userId") Long userId,
|
||||
@RequestParam("storeId") Long storeId,
|
||||
@RequestParam("regionId") Long regionId,
|
||||
@RequestParam("sellerId") Long sellerId,
|
||||
@RequestParam("startDate") Date startDate,
|
||||
@RequestParam("endDate") Date endDate,
|
||||
@RequestParam("type") String type,
|
||||
@RequestParam(value = "pageNum", required = false, defaultValue = "1") int pageNum,
|
||||
@RequestParam(value = "pageSize", required = false, defaultValue = "15") int pageSize){
|
||||
try {
|
||||
PageInfo<StorePromotionDataDO> storePromotionDataDOS = storePromotionDataService.listStorePromotionDate(userId, storeId,
|
||||
regionId, sellerId, startDate, endDate, type, pageNum, pageSize);
|
||||
return data(storePromotionDataDOS);
|
||||
}catch (Exception e){
|
||||
log.error("查询门店推广数据列表",e);
|
||||
return fail();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
package com.kiisoo.ic.store.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @Description:
|
||||
* @Author: JYJ
|
||||
* @Date: 2020/4/10 14:39
|
||||
* @Version: v1.0
|
||||
*/
|
||||
@Data
|
||||
public class StorePromotionDataDO {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
public Long id;
|
||||
|
||||
/**
|
||||
* 客户id
|
||||
*/
|
||||
public String userId;
|
||||
|
||||
/**
|
||||
* 店铺id
|
||||
*/
|
||||
public Long storeId;
|
||||
|
||||
/**
|
||||
* 店铺名
|
||||
*/
|
||||
public Long storeName;
|
||||
|
||||
/**
|
||||
* 区域id
|
||||
*/
|
||||
public Long regionId;
|
||||
|
||||
/**
|
||||
* 区域名
|
||||
*/
|
||||
public String regionName;
|
||||
|
||||
/**
|
||||
* 导购id
|
||||
*/
|
||||
public Long sellerId;
|
||||
|
||||
/**
|
||||
* 导购名
|
||||
*/
|
||||
public String sellerName;
|
||||
|
||||
/**
|
||||
* 总客户数
|
||||
*/
|
||||
public Integer cusNum;
|
||||
|
||||
/**
|
||||
* 新增客户数
|
||||
*/
|
||||
public Integer newCusNum;
|
||||
|
||||
/**
|
||||
* 日增客户平均
|
||||
*/
|
||||
public Integer avgNewCusNum;
|
||||
|
||||
/**
|
||||
* 删除/拉黑成员客户数(累计)
|
||||
*/
|
||||
public Integer delCusNum;
|
||||
|
||||
/**
|
||||
* 拉黑率(累计)
|
||||
*/
|
||||
public Float delCusRate;
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package com.kiisoo.ic.store.entity;
|
||||
|
||||
import lombok.Data;
|
||||
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Description: 微信获取外部联系人请求类
|
||||
* @Author: JYJ
|
||||
* @Date: 2020/4/10 16:12
|
||||
* @Version: v1.0
|
||||
*/
|
||||
@Data
|
||||
public class WxCusInfoReqDO {
|
||||
|
||||
/**
|
||||
* 调用接口凭证
|
||||
*/
|
||||
private String access_token;
|
||||
|
||||
/**
|
||||
* 客户id
|
||||
*/
|
||||
private String userid;
|
||||
|
||||
/**
|
||||
* 开始时间
|
||||
*/
|
||||
private Long start_time;
|
||||
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
private Long end_time;
|
||||
|
||||
public String toJson() {
|
||||
return WxCpGsonBuilder.create().toJson(this);
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package com.kiisoo.ic.store.entity;
|
||||
|
||||
import lombok.Data;
|
||||
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Description: 微信获取外部联系人请求类
|
||||
* @Author: JYJ
|
||||
* @Date: 2020/4/10 16:12
|
||||
* @Version: v1.0
|
||||
*/
|
||||
@Data
|
||||
public class WxCusInfoRespDO {
|
||||
|
||||
/**
|
||||
* 删除/拉黑成员的客户数 (被拉黑数)
|
||||
*/
|
||||
private Integer negative_feedback_cnt;
|
||||
|
||||
/**
|
||||
* 新增客户数
|
||||
*/
|
||||
private Integer new_contact_cnt;
|
||||
|
||||
/**
|
||||
* 店铺id
|
||||
*/
|
||||
private Long storeId;
|
||||
|
||||
/**
|
||||
* 区域id
|
||||
*/
|
||||
private Long regionId;
|
||||
|
||||
/**
|
||||
* 统计时间
|
||||
*/
|
||||
private Date statTime;
|
||||
}
|
@ -0,0 +1,99 @@
|
||||
package com.kiisoo.ic.store.mapper;
|
||||
|
||||
import com.kiisoo.ic.store.entity.StorePromotionDataDO;
|
||||
import com.kiisoo.ic.store.entity.WxCusInfoRespDO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* 店铺-企业微信账号-关联表 Mapper
|
||||
* @author yechenhao
|
||||
* @since 2020-04-09
|
||||
*/
|
||||
@Repository
|
||||
public interface StorePromotionDataDOMapper {
|
||||
|
||||
/**
|
||||
* 查询门店推广数据列表 区域
|
||||
* @param storeIds
|
||||
* @param regionId
|
||||
* @param startDate
|
||||
* @param endDate
|
||||
* @return
|
||||
*/
|
||||
List<StorePromotionDataDO> selectPromotionDataGroupByRegion(@Param("storeIds") List<Long> storeIds,
|
||||
@Param("regionId") Long regionId,
|
||||
@Param("startDate") Date startDate,
|
||||
@Param("endDate") Date endDate);
|
||||
|
||||
/**
|
||||
* 查询门店推广数据列表 店铺
|
||||
* @param storeIds
|
||||
* @param storeId
|
||||
* @param regionId
|
||||
* @param startDate
|
||||
* @param endDate
|
||||
* @return
|
||||
*/
|
||||
List<StorePromotionDataDO> selectPromotionDataGroupByStore(@Param("storeIds") List<Long> storeIds,
|
||||
@Param("storeId") Long storeId,
|
||||
@Param("regionId") Long regionId,
|
||||
@Param("startDate") Date startDate,
|
||||
@Param("endDate") Date endDate);
|
||||
|
||||
/**
|
||||
* 查询门店推广数据列表 导购
|
||||
* @param storeIds
|
||||
* @param storeId
|
||||
* @param regionId
|
||||
* @param sellerId
|
||||
* @param startDate
|
||||
* @param endDate
|
||||
* @return
|
||||
*/
|
||||
List<StorePromotionDataDO> selectPromotionDataGroupBySeller(@Param("storeIds") List<Long> storeIds,
|
||||
@Param("storeId") Long storeId,
|
||||
@Param("regionId") Long regionId,
|
||||
@Param("sellerId") Long sellerId,
|
||||
@Param("startDate") Date startDate,
|
||||
@Param("endDate") Date endDate);
|
||||
|
||||
/**
|
||||
* 查询所有导购的客户
|
||||
* @return storePromotionDataDO
|
||||
*/
|
||||
List<StorePromotionDataDO> selectCustomer();
|
||||
|
||||
/**
|
||||
* 新增门店企业微信的联系人数据到数据库
|
||||
* @param wxCusInfoRespDO
|
||||
* @return
|
||||
*/
|
||||
int insertStorePromotionData(WxCusInfoRespDO wxCusInfoRespDO);
|
||||
|
||||
/**
|
||||
* 查询门店企业微信的联系人数据 按区域
|
||||
* @param regionId
|
||||
* @param startDate
|
||||
* @param endDate
|
||||
* @return
|
||||
*/
|
||||
StorePromotionDataDO selectWxCusInfoByRegionId(@Param("regionId") Long regionId,
|
||||
@Param("startDate") Date startDate,
|
||||
@Param("endDate") Date endDate);
|
||||
|
||||
/**
|
||||
* 查询门店企业微信的联系人数据 按店铺
|
||||
* @param storeId
|
||||
* @param startDate
|
||||
* @param endDate
|
||||
* @return
|
||||
*/
|
||||
StorePromotionDataDO selectWxCusInfoByStoreId(@Param("storeId") Long storeId,
|
||||
@Param("startDate") Date startDate,
|
||||
@Param("endDate") Date endDate);
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package com.kiisoo.ic.store.service;
|
||||
|
||||
import com.xxl.job.core.biz.model.ReturnT;
|
||||
import com.xxl.job.core.handler.IJobHandler;
|
||||
import com.xxl.job.core.handler.annotation.JobHandler;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author jinchaofan
|
||||
* @date 2019/4/28 15:20
|
||||
* @company kiisoo
|
||||
* @details 获取联系客户统计数据定时任务 job 0 0 1 * * ?
|
||||
*/
|
||||
@JobHandler(value="storePromotionData")
|
||||
@Component
|
||||
@Slf4j
|
||||
public class StorePromotionDataJob extends IJobHandler {
|
||||
|
||||
/**
|
||||
* 客流定时任务 service
|
||||
*/
|
||||
@Autowired
|
||||
private StorePromotionDataService storePromotionDataService;
|
||||
|
||||
@Override
|
||||
public ReturnT<String> execute(String s) throws Exception {
|
||||
try {
|
||||
log.info("<--获取联系客户统计数据定时任务执行-->");
|
||||
storePromotionDataService.syncCustomerBlackList();
|
||||
log.info("<--获取联系客户统计数据定时任务结束-->");
|
||||
} catch (Exception e) {
|
||||
log.error("获取联系客户统计数据任务出错", e);
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,161 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.kiisoo.ic.store.mapper.StorePromotionDataDOMapper">
|
||||
|
||||
<select id="selectPromotionDataGroupByRegion" resultType="com.kiisoo.ic.store.entity.StorePromotionDataDO">
|
||||
SELECT
|
||||
t3.id as regionId,
|
||||
t3.NAME AS regionName,
|
||||
sum( t4.customer_id ) AS cusNum
|
||||
FROM
|
||||
poi_store t1
|
||||
LEFT JOIN op_seller_customer_relation t4 on t1.id = t4.store_id
|
||||
<if test="startDate != null">
|
||||
and DATE_FORMAT(t4.create_time,'%Y-%m-%d') > DATE_FORMAT(#{endDate},'%Y-%m-%d')
|
||||
</if>
|
||||
<if test="endDate != null">
|
||||
and DATE_FORMAT(t4.create_time,'%Y-%m-%d') < DATE_FORMAT(#{endDate},'%Y-%m-%d')
|
||||
</if>,
|
||||
poi_store_region t2,
|
||||
poi_region t3
|
||||
WHERE
|
||||
t1.id = t2.store_id
|
||||
and t2.region_id = t3.id
|
||||
<choose>
|
||||
<when test="storeIds != null and storeIds.size > 0">
|
||||
and t1.id in
|
||||
<foreach collection="storeIds" index="index" item="item" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</when>
|
||||
<otherwise>
|
||||
and 1 = 0
|
||||
</otherwise>
|
||||
</choose>
|
||||
<if test="regionId != null">
|
||||
and t3.id = #{regionId}
|
||||
</if>
|
||||
and t1.status = 1
|
||||
GROUP BY
|
||||
t3.id
|
||||
</select>
|
||||
|
||||
<select id="selectPromotionDataGroupByStore" resultType="com.kiisoo.ic.store.entity.StorePromotionDataDO">
|
||||
SELECT
|
||||
t1.id as storeId,
|
||||
t1.NAME as storeName,
|
||||
sum( t4.customer_id ) AS cusNum
|
||||
FROM
|
||||
poi_store t1
|
||||
LEFT JOIN op_seller_customer_relation t4 on t1.id = t4.store_id
|
||||
<if test="startDate != null">
|
||||
and DATE_FORMAT(t4.create_time,'%Y-%m-%d') > DATE_FORMAT(#{endDate},'%Y-%m-%d')
|
||||
</if>
|
||||
<if test="endDate != null">
|
||||
and DATE_FORMAT(t4.create_time,'%Y-%m-%d') < DATE_FORMAT(#{endDate},'%Y-%m-%d')
|
||||
</if>,
|
||||
poi_store_region t2
|
||||
WHERE
|
||||
t1.id = t2.store_id
|
||||
<choose>
|
||||
<when test="storeIds != null and storeIds.size > 0">
|
||||
and t1.id in
|
||||
<foreach collection="storeIds" index="index" item="item" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</when>
|
||||
<otherwise>
|
||||
and 1 = 0
|
||||
</otherwise>
|
||||
</choose>
|
||||
<if test="storeId != null">
|
||||
and t1.id = #{storeId}
|
||||
</if>
|
||||
<if test="regionId != null">
|
||||
and t3.id = #{regionId}
|
||||
</if>
|
||||
and t1.status = 1
|
||||
GROUP BY
|
||||
t1.id
|
||||
</select>
|
||||
|
||||
<select id="selectPromotionDataGroupBySeller" resultType="com.kiisoo.ic.store.entity.StorePromotionDataDO">
|
||||
SELECT
|
||||
t1.id AS sellerId,
|
||||
t3.NAME AS sellerName,
|
||||
sum( t2.customer_id ) AS cusNum
|
||||
FROM
|
||||
poi_store_staff t1
|
||||
LEFT JOIN op_seller_customer_relation t2 ON t1.id = t2.user_id
|
||||
<if test="startDate != null">
|
||||
and DATE_FORMAT(t4.create_time,'%Y-%m-%d') > DATE_FORMAT(#{endDate},'%Y-%m-%d')
|
||||
</if>
|
||||
<if test="endDate != null">
|
||||
and DATE_FORMAT(t4.create_time,'%Y-%m-%d') < DATE_FORMAT(#{endDate},'%Y-%m-%d')
|
||||
</if>,
|
||||
privilage_user t3,
|
||||
poi_store_region t4
|
||||
WHERE
|
||||
t1.user_id = t3.id
|
||||
and t1.store_id = t4.store_id
|
||||
<choose>
|
||||
<when test="storeIds != null and storeIds.size > 0">
|
||||
and t1.id in
|
||||
<foreach collection="storeIds" index="index" item="item" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</when>
|
||||
<otherwise>
|
||||
and 1 = 0
|
||||
</otherwise>
|
||||
</choose>
|
||||
AND t1.type = 4
|
||||
AND t1.STATUS = 1
|
||||
AND t1.deleted = 0
|
||||
AND t3.STATUS = 1
|
||||
<if test="storeId != null">
|
||||
and t1.store_id = #{storeId}
|
||||
</if>
|
||||
<if test="regionId != null">
|
||||
and t4.region_id = #{regionId}
|
||||
</if>
|
||||
group by t1.id
|
||||
</select>
|
||||
<select id="selectCustomer" resultType="com.kiisoo.ic.store.entity.StorePromotionDataDO">
|
||||
SELECT
|
||||
t1.cp_user_id AS userid,
|
||||
t2.store_id AS storeId,
|
||||
t3.region_id AS regionId
|
||||
FROM
|
||||
privilage_cp_user t1,
|
||||
privilage_cp_user_store t2,
|
||||
poi_store_region t3
|
||||
WHERE
|
||||
t1.id = t2.cp_user_id
|
||||
AND t2.store_id = t3.store_id
|
||||
</select>
|
||||
|
||||
<insert id="insertStorePromotionData" parameterType="com.kiisoo.ic.store.entity.WxCusInfoRespDO">
|
||||
INSERT INTO poi_customer_contact_data_stat (store_id, region_id,
|
||||
negative_feedback_cnt, new_contact_cnt, stat_time, create_time) VALUES (#{storeId}, #{regionId},
|
||||
#{negative_feedback_cnt}, #{new_contact_cnt}, #{statTime}, NOW())
|
||||
</insert>
|
||||
|
||||
<select id="selectWxCusInfoByRegionId" resultType="com.kiisoo.ic.store.entity.StorePromotionDataDO">
|
||||
SELECT sum( new_contact_cnt ) AS newCusNum,
|
||||
sum( negative_feedback_cnt ) AS delCusNum
|
||||
FROM poi_customer_contact_data_stat
|
||||
WHERE region_id = #{regionId}
|
||||
AND stat_time > #{startDate}
|
||||
AND stat_time < #{endDate}
|
||||
</select>
|
||||
|
||||
<select id="selectWxCusInfoByStoreId" resultType="com.kiisoo.ic.store.entity.StorePromotionDataDO">
|
||||
SELECT sum( new_contact_cnt ) AS newCusNum,
|
||||
sum( negative_feedback_cnt ) AS delCusNum
|
||||
FROM poi_customer_contact_data_stat
|
||||
WHERE store_id = #{storeId}
|
||||
AND stat_time > #{startDate}
|
||||
AND stat_time < #{endDate}
|
||||
</select>
|
||||
</mapper>
|
Loading…
Reference in New Issue