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

完成访问量统计

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