提交 e0c3d57a authored 作者: 吴德鹏's avatar 吴德鹏

完成访问量统计

上级 525c873a
......@@ -5,14 +5,11 @@ import com.platform.service.TbCfVisitService;
import com.platform.utils.PageUtils;
import com.platform.utils.Query;
import com.platform.utils.R;
import com.platform.vo.StatisticalVo;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
......@@ -113,4 +110,13 @@ public class TbCfVisitController {
long dayVisit = tbCfVisitService.getDayVisit();
return R.ok().put("dayVisit", dayVisit);
}
@GetMapping("/getVisitByDate")
@ResponseBody
public R getOrderByDate(@RequestParam(value = "start", required = false) String start,
@RequestParam(value = "end", required = false) String end,
@RequestParam(value = "flag", required = false) String flag) {
List<StatisticalVo> visitList = tbCfVisitService.getVisitByDate(start, end, flag);
return R.ok().put("list", visitList);
}
}
package com.platform.dao;
import com.platform.entity.TbCfVisitEntity;
import com.platform.vo.StatisticalVo;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* Dao
......@@ -12,4 +16,6 @@ public interface TbCfVisitDao extends BaseDao<TbCfVisitEntity> {
long getDayVisit();
List<StatisticalVo> getVisitByDate(@Param("start") String start, @Param("end") String end, @Param("flag") String flag);
}
package com.platform.service;
import com.platform.entity.TbCfVisitEntity;
import com.platform.vo.StatisticalVo;
import java.util.List;
import java.util.Map;
......@@ -70,4 +71,6 @@ public interface TbCfVisitService {
int deleteBatch(String[] ids);
long getDayVisit();
List<StatisticalVo> getVisitByDate(String start, String end,String flag);
}
......@@ -4,6 +4,7 @@ import com.platform.dao.TbCfVisitDao;
import com.platform.entity.TbCfVisitEntity;
import com.platform.service.TbCfVisitService;
import com.platform.utils.IdUtil;
import com.platform.vo.StatisticalVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -61,4 +62,10 @@ public class TbCfVisitServiceImpl implements TbCfVisitService {
public long getDayVisit() {
return tbCfVisitDao.getDayVisit();
}
@Override
public List<StatisticalVo> getVisitByDate(String start, String end, String flag) {
return tbCfVisitDao.getVisitByDate(start, end, flag);
}
}
......@@ -10,7 +10,7 @@
<result property="visitTime" column="visit_time"/>
</resultMap>
<select id="queryObject" resultType="com.platform.entity.TbCfVisitEntity">
<select id="queryObject" resultType="com.platform.entity.TbCfVisitEntity">
select
`id`,
`source`,
......@@ -20,39 +20,64 @@
where id = #{id}
</select>
<select id="queryList" resultType="com.platform.entity.TbCfVisitEntity">
select
`id`,
`source`,
`user_id`,
`visit_time`
from tb_cf_visit
WHERE 1=1
<if test="name != null and name.trim() != ''">
AND name LIKE concat('%',#{name},'%')
</if>
<select id="queryList" resultType="com.platform.entity.TbCfVisitEntity">
select
`id`,
`source`,
`user_id`,
`visit_time`
from tb_cf_visit
WHERE 1=1
<if test="name != null and name.trim() != ''">
AND name LIKE concat('%',#{name},'%')
</if>
<choose>
<when test="sidx != null and sidx.trim() != ''">
order by ${sidx} ${order}
</when>
<otherwise>
<otherwise>
order by id desc
</otherwise>
</otherwise>
</choose>
<if test="offset != null and limit != null">
limit #{offset}, #{limit}
</if>
</select>
<select id="queryTotal" resultType="int">
select count(*) from tb_cf_visit
WHERE 1=1
<if test="offset != null and limit != null">
limit #{offset}, #{limit}
</if>
</select>
<select id="getVisitByDate" resultType="com.platform.vo.StatisticalVo">
SELECT
<choose>
<when test="flag != null and flag.trim() != ''">
DATE_FORMAT( visit_time, '%Y-%m' ) date,
</when>
<otherwise>
DATE_FORMAT( visit_time, '%Y-%m-%d' ) date,
</otherwise>
</choose>
count( 1 ) num
FROM
tb_cf_visit
WHERE
1=1
<if test="start != null and start.trim() != ''">
AND date_format( visit_time, '%Y-%m-%d' ) >= #{start}
</if>
<if test="end != null and end.trim() != ''">
AND date_format( visit_time, '%Y-%m-%d' ) &lt;= #{end}
</if>
GROUP BY
date
</select>
<select id="queryTotal" resultType="int">
select count(*) from tb_cf_visit
WHERE 1=1
<if test="name != null and name.trim() != ''">
AND name LIKE concat('%',#{name},'%')
</if>
</select>
<insert id="save" parameterType="com.platform.entity.TbCfVisitEntity">
</select>
<insert id="save" parameterType="com.platform.entity.TbCfVisitEntity">
insert into tb_cf_visit(
`id`,
`source`,
......@@ -65,29 +90,29 @@
#{visitTime})
</insert>
<select id="getDayVisit" resultType="long">
<select id="getDayVisit" resultType="long">
SELECT count(1) from tb_cf_visit WHERE DATE_FORMAT(visit_time,'%Y-%m-%d')=CURDATE()
</select>
<update id="update" parameterType="com.platform.entity.TbCfVisitEntity">
update tb_cf_visit
<set>
<if test="source != null">`source` = #{source}, </if>
<if test="userId != null">`user_id` = #{userId}, </if>
<if test="visitTime != null">`visit_time` = #{visitTime}</if>
</set>
where id = #{id}
</update>
<delete id="delete">
<update id="update" parameterType="com.platform.entity.TbCfVisitEntity">
update tb_cf_visit
<set>
<if test="source != null">`source` = #{source},</if>
<if test="userId != null">`user_id` = #{userId},</if>
<if test="visitTime != null">`visit_time` = #{visitTime}</if>
</set>
where id = #{id}
</update>
<delete id="delete">
delete from tb_cf_visit where id = #{value}
</delete>
<delete id="deleteBatch">
delete from tb_cf_visit where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<delete id="deleteBatch">
delete from tb_cf_visit where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>
\ No newline at end of file
......@@ -473,7 +473,7 @@
<div class="m-card-functionzone" id='echartsPV'>
</div>
<div class="m-card-bottom">
<span>日访问量 <i>127230</i></span>
<span>日访问量 <i>{{dayVisit}}</i></span>
</div>
</div>
<!-- 支付笔数 -->
......
......@@ -2,6 +2,7 @@ let app = new Vue({
el: '#app',
data() {
return {
dayVisit: 0,
rate: 0,
dayRate: 0,
flag: false,
......@@ -314,7 +315,7 @@ let app = new Vue({
this.initEchartsMiddleData[0].data = []
let objList = JSON.parse(res).list
objList.map(res => {
// console.log('date', res.date)
console.log('date', res.date)
this.initEchartsMiddleData[0].data.push([res.date, res.num])
})
this.initEchartsMiddle();
......@@ -324,7 +325,7 @@ let app = new Vue({
$.get(url, res => {
this.initEchartsMiddleData[0].data = []
res.list.map(res => {
// console.log('date', res.date)
console.log('date', res.date)
this.initEchartsMiddleData[0].data.push([res.date, res.num])
})
this.initEchartsMiddle();
......@@ -338,7 +339,8 @@ let app = new Vue({
let url = '../tbcfuserinfo/getDayRegistered'
this.templateMethod(url);
} else if (this.middleOption[1].isActive) {
let url = '../tbcfvisit/getVisitByDate?start=' + endDate;
this.templateMethod(url);
} else if (this.middleOption[2].isActive) {
let url = '../tbcforder/getOrderByDate?start=' + endDate;
this.templateMethod1(url);
......@@ -363,7 +365,8 @@ let app = new Vue({
let url = '../tbcfuserinfo/getWeekRegistered'
this.templateMethod(url);
} else if (this.middleOption[1].isActive) {
let url = '../tbcfvisit/getVisitByDate?start=' + start + '&end' + end;
this.templateMethod(url);
} else if (this.middleOption[2].isActive) {
let url = '../tbcforder/getOrderByDate?start=' + start + '&end' + end;
this.templateMethod1(url);
......@@ -382,7 +385,8 @@ let app = new Vue({
let url = '../tbcfuserinfo/getMonthRegistered'
this.templateMethod(url);
} else if (this.middleOption[1].isActive) {
let url = '../tbcfvisit/getVisitByDate?start=' + start + '&end' + end;
this.templateMethod(url);
} else if (this.middleOption[2].isActive) {
let url = '../tbcforder/getOrderByDate?start=' + start + '&end' + end;
this.templateMethod1(url);
......@@ -401,7 +405,8 @@ let app = new Vue({
let url = '../tbcfuserinfo/getYearRegistered'
this.templateMethod(url);
} else if (this.middleOption[1].isActive) {
let url = '../tbcfvisit/getVisitByDate?start=' + start + '&end' + end + '&flag=y';
this.templateMethod(url);
} else if (this.middleOption[2].isActive) {
let url = '../tbcforder/getOrderByDate?start=' + start + '&end' + end + '&flag=y';
this.templateMethod1(url);
......@@ -709,7 +714,8 @@ let app = new Vue({
this.templateMethod(url);
} else if (index === 1) {
this.initEchartsMiddleData[0].name = '访问量'
this.initEchartsMiddleData[0].data = []
let url = '../tbcfvisit/getVisitByDate';
this.templateMethod(url);
} else if (index === 2) {
this.initEchartsMiddleData[0].name = '订单笔数'
let url = '../tbcforder/getOrderByDate';
......@@ -744,6 +750,8 @@ let app = new Vue({
this.templateMethod(url);
} else if (this.middleOption[1].isActive) {
//访问量
let url = '../tbcfvisit/getVisitByDate?start=' + e[0] + '&end=' + e[1];
this.templateMethod(url);
} else if (this.middleOption[2].isActive) {
//订单量
let url = '../tbcforder/getOrderByDate?start=' + e[0] + '&end=' + e[1];
......@@ -774,11 +782,11 @@ let app = new Vue({
}
let endDate = this.getEndDate();
if (this.middleOption[0].isActive) {
this.initEchartsMiddleData[0].name = '注册量'
let url = '../tbcfuserinfo/getDailyRegistered?flag=' + flag;
this.templateMethod(url);
} else if (this.middleOption[1].isActive) {
let url = '../tbcfvisit/getVisitByDate?flag=' + flag;
this.templateMethod(url);
} else if (this.middleOption[2].isActive) {
let url = '../tbcforder/getOrderByDate?flag=' + flag;
this.templateMethod1(url);
......@@ -814,6 +822,12 @@ let app = new Vue({
this.total = res.dayOrderNum;
})
},
getDayVisit() {
$.get('../tbcfvisit/getDayVisit', res => {
this.dayVisit = JSON.parse(res).dayVisit;
TweenLite.to(this.$data, 1, {PVNumber: this.dayVisit});
})
},
getSearchKeywords() {
$.get('../tbcfsearch/getSearchKeywords?page=1&limit=10&sidx=&order=', res => {
let list = JSON.parse(res);
......@@ -865,6 +879,7 @@ let app = new Vue({
this.getCategory();
},
mounted() {
this.getDayVisit();
this.getDayRate();
this.getUserDayRate();
this.getSearchKeywords();
......@@ -884,7 +899,6 @@ let app = new Vue({
this.newNum = objList[0].num;
})
// this.orderRate = orderPaidNum / orderNum
TweenLite.to(this.$data, 1, {PVNumber: 135245554});
this.changeMiddelActive({
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论