| @@ -28,16 +28,35 @@ public class MarkingDataReportController extends BaseController { | |||
| public ResultData findCouponData() { | |||
| return new ResultData(markingDataReportService.getCouponDate(getTenantId())); | |||
| } | |||
| @ApiOperation("查询券数据列表") | |||
| @GetMapping("/couponDataList") | |||
| public ResultData findCouponDataList(@ModelAttribute MarkingCouponDataReportDto markingCouponDataReportDto) { | |||
| return new ResultData(markingDataReportService.getCouponDateList(getTenantId(),markingCouponDataReportDto)); | |||
| } | |||
| @ApiOperation("查询场景投放券数据") | |||
| @GetMapping("/sceneData") | |||
| public ResultData findSceneData() { | |||
| return new ResultData(markingDataReportService.getSceneData(getTenantId())); | |||
| } | |||
| @ApiOperation("查询券数据列表") | |||
| @GetMapping("/couponDataList") | |||
| public ResultData findCouponDataList(@ModelAttribute MarkingCouponDataReportDto markingCouponDataReportDto) { | |||
| return new ResultData(markingDataReportService.getCouponDateList(getTenantId(),markingCouponDataReportDto)); | |||
| @ApiOperation("查询场景营销数据列表") | |||
| @GetMapping("/sceneDataList") | |||
| public ResultData findSceneDataList(@ModelAttribute MarkingCouponDataReportDto markingCouponDataReportDto) { | |||
| return new ResultData(markingDataReportService.getSceneDataList(getTenantId(),markingCouponDataReportDto)); | |||
| } | |||
| @ApiOperation("查询触达用户数数据") | |||
| @GetMapping("/touchUsersData") | |||
| public ResultData touchUsersData() { | |||
| return new ResultData(markingDataReportService.getTouchUsersReportData(getTenantId())); | |||
| } | |||
| @ApiOperation("查询触达用户数数据列表") | |||
| @GetMapping("/touchUsersDataList") | |||
| public ResultData touchUsersDataList(@ModelAttribute MarkingCouponDataReportDto markingCouponDataReportDto) { | |||
| return new ResultData(markingDataReportService.getTouchUsersReportList(getTenantId(),markingCouponDataReportDto)); | |||
| } | |||
| @@ -39,9 +39,12 @@ public class WxUserVisit implements Serializable { | |||
| public void setIds(List<Long> ids) { | |||
| this.ids = ids; | |||
| } | |||
| /*租户ID**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId") | |||
| private String tenantId; | |||
| /*日期字符串**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="日期字符串",name="refDate") | |||
| private String refDate; | |||
| @@ -141,6 +144,13 @@ public class WxUserVisit implements Serializable { | |||
| public void setCreateDate(Date _createDate) { | |||
| createDate = _createDate; | |||
| } | |||
| public String getTenantId() { | |||
| return tenantId; | |||
| } | |||
| public void setTenantId(String tenantId) { | |||
| this.tenantId = tenantId; | |||
| } | |||
| @@ -3,6 +3,7 @@ package com.simple.mapper; | |||
| import java.util.*; | |||
| import com.simple.common.CommonMapper; | |||
| import com.simple.domain.vo.MarkingCouponDataReportVo; | |||
| import com.simple.domain.vo.TouchUsersReportVo; | |||
| import com.simple.domain.vo.WxCouponOrderBVo; | |||
| import com.simple.domain.vo.WxCouponOrderCVo; | |||
| import org.apache.ibatis.annotations.Param; | |||
| @@ -24,10 +25,14 @@ public interface WxCouponOrderMapper extends CommonMapper<WxCouponOrder, Long> { | |||
| List<WxCouponOrderCVo> findListOfCUser(WxCouponOrder wxCouponOrder); | |||
| List<WxCouponOrderCVo> findListOfAdmin(WxCouponOrder wxCouponOrder); | |||
| //营销报表 券数据图表 | |||
| List<MarkingCouponDataReportVo> couponDataMap(HashMap<String,Object> params); | |||
| //营销报表 券数据报表 | |||
| List<MarkingCouponDataReportVo> couponDataList(HashMap<String,Object> params); //返回日期格式yy-MM-dd | |||
| //营销报表 触达用户数 | |||
| List<TouchUsersReportVo> touchUsersReportList(HashMap<String,Object> params); //返回日期格式yy-MM-dd | |||
| /** | |||
| @@ -2,12 +2,15 @@ package com.simple.mapper; | |||
| import java.util.*; | |||
| import com.simple.common.CommonMapper; | |||
| import com.simple.domain.vo.TouchUsersReportVo; | |||
| import org.apache.ibatis.annotations.Param; | |||
| import com.simple.domain.po.WxUserVisit; | |||
| public interface WxUserVisitMapper extends CommonMapper<WxUserVisit, Long> { | |||
| List<WxUserVisit> findList(WxUserVisit wxUserVisit); | |||
| List<TouchUsersReportVo> touchUsersReportList(HashMap<String,Object> params); | |||
| @@ -4,6 +4,7 @@ import com.simple.domain.dto.MarkingCouponDataReportDto; | |||
| import com.simple.domain.vo.MarkingCouponDataReportVo; | |||
| import com.simple.domain.vo.MarkingSceneDataReportVo; | |||
| import com.simple.domain.vo.MarkingSceneDataVo; | |||
| import com.simple.domain.vo.TouchUsersReportVo; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| @@ -19,4 +20,8 @@ public interface MarkingDataReportService { | |||
| List<MarkingCouponDataReportVo> getCouponDateList(String tenantId, MarkingCouponDataReportDto markingCouponDataReportDto); | |||
| List<MarkingSceneDataVo> getSceneDataList(String tenantId, MarkingCouponDataReportDto markingCouponDataReportDto); | |||
| List<TouchUsersReportVo> getTouchUsersReportList(String tenantId, MarkingCouponDataReportDto markingCouponDataReportDto); | |||
| List<TouchUsersReportVo> getTouchUsersReportData(String tenantId); | |||
| } | |||
| @@ -1,12 +1,15 @@ | |||
| package com.simple.service.impl; | |||
| import com.simple.domain.dto.MarkingCouponDataReportDto; | |||
| import com.simple.domain.po.WxUserVisit; | |||
| import com.simple.domain.vo.MarkingCouponDataReportVo; | |||
| import com.simple.domain.vo.MarkingSceneDataReportVo; | |||
| import com.simple.domain.vo.MarkingSceneDataVo; | |||
| import com.simple.domain.vo.TouchUsersReportVo; | |||
| import com.simple.mapper.WxCarCmdLogMapper; | |||
| import com.simple.mapper.WxCouponActionLogMapper; | |||
| import com.simple.mapper.WxCouponOrderMapper; | |||
| import com.simple.mapper.WxUserVisitMapper; | |||
| import com.simple.service.MarkingDataReportService; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Service; | |||
| @@ -28,6 +31,8 @@ public class MarkingDataReportServiceImpl implements MarkingDataReportService { | |||
| private WxCouponActionLogMapper wxCouponActionLogMapper; | |||
| @Autowired | |||
| private WxCarCmdLogMapper wxCarCmdLogMapper; | |||
| @Autowired | |||
| private WxUserVisitMapper wxUserVisitMapper; | |||
| //取本月第一天 | |||
| private Date getFirstDayOfMonth() { | |||
| @@ -197,7 +202,7 @@ public class MarkingDataReportServiceImpl implements MarkingDataReportService { | |||
| params.put("startTime", convertDate(markingCouponDataReportDto.getStartTime())); | |||
| params.put("endTime", convertDateAndAdd(convertDate(markingCouponDataReportDto.getEndTime()), 1)); | |||
| //停车发券数 停车发券被核销数 核销发券数 核销发券被核销数 | |||
| List<MarkingSceneDataReportVo> templist = wxCouponActionLogMapper.sceneDataMap(params); | |||
| List<MarkingSceneDataReportVo> templist = wxCouponActionLogMapper.sceneDataList(params); | |||
| List<MarkingSceneDataVo> list = new ArrayList<>(); | |||
| for (MarkingSceneDataReportVo temp: templist) { | |||
| @@ -208,6 +213,7 @@ public class MarkingDataReportServiceImpl implements MarkingDataReportService { | |||
| }else{ | |||
| vo.setSendCount(temp.getVerifySendCount()); | |||
| } | |||
| list.add(vo); | |||
| } | |||
| @@ -255,16 +261,47 @@ public class MarkingDataReportServiceImpl implements MarkingDataReportService { | |||
| return list; | |||
| } | |||
| public Map<String, Object> getTouchUsersReport(String tenantId, MarkingCouponDataReportDto markingCouponDataReportDto){ | |||
| @Override | |||
| public List<TouchUsersReportVo> getTouchUsersReportList(String tenantId, MarkingCouponDataReportDto markingCouponDataReportDto){ | |||
| //获取领取人数 | |||
| //获取领取量 | |||
| //获取核销人数 | |||
| //核销量 | |||
| HashMap<String, Object> params = new HashMap<>(); | |||
| params.put("tenantId", tenantId); | |||
| params.put("startTime", convertDate(markingCouponDataReportDto.getStartTime())); | |||
| params.put("endTime", convertDateAndAdd(convertDate(markingCouponDataReportDto.getEndTime()), 1)); | |||
| List<TouchUsersReportVo> couponDatalist = wxCouponOrderMapper.touchUsersReportList(params); | |||
| //查询UV PV | |||
| HashMap<String, Object> params1 = new HashMap<>(); | |||
| params1.put("tenantId", tenantId); | |||
| params1.put("startTime", convertDate(markingCouponDataReportDto.getStartTime())); | |||
| params1.put("endTime", convertDateAndAdd(convertDate(markingCouponDataReportDto.getEndTime()), 1)); | |||
| List<TouchUsersReportVo> wxUserVisitList = wxUserVisitMapper.touchUsersReportList(params1); | |||
| Map<String,TouchUsersReportVo> visitMap = wxUserVisitList.stream().collect(Collectors.toMap(TouchUsersReportVo::getxTime, p -> p)); | |||
| for (TouchUsersReportVo temp:couponDatalist) { | |||
| if(visitMap.get(temp.getxTime())!=null){ | |||
| temp.setUv(visitMap.get(temp.getxTime()).getUv()); | |||
| temp.setPv(visitMap.get(temp.getxTime()).getPv()); | |||
| } | |||
| } | |||
| return couponDatalist; | |||
| } | |||
| @Override | |||
| public List<TouchUsersReportVo> getTouchUsersReportData(String tenantId){ | |||
| //查询UV PV | |||
| HashMap<String, Object> params = new HashMap<>(); | |||
| params.put("tenantId", tenantId); | |||
| params.put("startTime", getFirstDayOfMonth()); | |||
| params.put("endTime", addDay(1)); | |||
| List<TouchUsersReportVo> wxUserVisitList = wxUserVisitMapper.touchUsersReportList(params); | |||
| return wxUserVisitList; | |||
| return null; | |||
| } | |||
| //计算最大公约数 | |||
| public int gcd(int x, int y){ // 这个是运用辗转相除法求 两个数的 最大公约数 看不懂可以百度 // 下 | |||
| if(y == 0) | |||
| @@ -390,6 +390,14 @@ | |||
| from wx_coupon_order where tenant_id=#{tenantId} AND create_date >= #{startTime} and create_date <= #{endTime} GROUP BY createTime | |||
| </select> | |||
| <select id="touchUsersReportList" resultType="com.simple.domain.vo.TouchUsersReportVo" parameterType="hashmap"> | |||
| SELECT DATE_FORMAT(create_date,'%Y-%m-%d') as xTime | |||
| ,COUNT(DISTINCT c_user_id) as userCount,count(*) as couponCount | |||
| ,(select Count(*) from wx_coupon_order c where coupon_order_status=1 AND DATE_FORMAT(create_date,'%Y-%m-%d')=xTime and tenant_id=#{tenantId} AND c.update_date >= #{startTime} and c.update_date <= #{endTime}) as verifyCount | |||
| ,(select Count(DISTINCT c_user_id) from wx_coupon_order d where coupon_order_status=1 AND DATE_FORMAT(create_date,'%Y-%m-%d')=xTime and tenant_id=#{tenantId} AND d.update_date >= #{startTime} and d.update_date <= #{endTime}) as verifyUserCount | |||
| from wx_coupon_order where tenant_id=#{tenantId} AND create_date >= #{startTime} and create_date <= #{endTime} GROUP BY xTime | |||
| </select> | |||
| @@ -3,6 +3,7 @@ | |||
| <mapper namespace="com.simple.mapper.WxUserVisitMapper"> | |||
| <resultMap id="BaseResultMap" type="com.simple.domain.po.WxUserVisit"> | |||
| <id column="id" jdbcType="BIGINT" property="id" /> | |||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" /> | |||
| <result column="ref_date" jdbcType="VARCHAR" property="refDate" /> | |||
| <result column="day_date" jdbcType="TIMESTAMP" property="dayDate" /> | |||
| <result column="session_cnt" jdbcType="INTEGER" property="sessionCnt" /> | |||
| @@ -17,7 +18,7 @@ | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`,`ref_date`,`day_date`,`session_cnt`,`visit_pv`,`visit_uv`,`visit_uv_new`,`stay_time_uv`,`stay_time_session`,`visit_depth`,`app_id`,`create_date` | |||
| `id`,`tenant_id`,`ref_date`,`day_date`,`session_cnt`,`visit_pv`,`visit_uv`,`visit_uv_new`,`stay_time_uv`,`stay_time_session`,`visit_depth`,`app_id`,`create_date` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| @@ -26,7 +27,11 @@ | |||
| <if test=" null != id "> | |||
| and `id` = #{id} | |||
| </if> | |||
| </if> | |||
| <if test=" null != tenantId "> | |||
| and `tenant_id` like concat('%', #{tenantId},'%') | |||
| </if> | |||
| <if test=" null != refDate "> | |||
| and `ref_date` like concat('%', #{refDate},'%') | |||
| @@ -95,6 +100,11 @@ | |||
| select <include refid="allColumns" /> from wx_user_visit | |||
| <include refid="dynamicWhereConditions" /> | |||
| </select> | |||
| <select id="touchUsersReportList" resultType="com.simple.domain.vo.TouchUsersReportVo" parameterType="hashmap"> | |||
| SELECT DATE_FORMAT(day_date,'%Y-%m-%d') as xTime,visit_pv as pv,visit_uv as uv | |||
| from wx_user_visit where tenant_id=#{tenantId} AND day_date >= #{startTime} and day_date <= #{endTime} order by day_date ASC | |||
| </select> | |||