Commit b3e24940 by keith

1.服务记录增加所有数据列表选项 2.增加首页服务总数量显示 3.重写独立用户访问记录逻辑

parent cb7518d6
......@@ -78,11 +78,10 @@ func (c *HomeController) GetFlowStatistical() {
}
}
statisticalData, err := c.StatisticalRepository.GetFlowStatistical(statisticalRequest.DateStart, statisticalRequest.DateEnd)
statisticalData, err := services.GetFlowStatisticalRepositoryInstance().GetCounter(statisticalRequest.DateStart, statisticalRequest.DateEnd)
if err != nil {
c.JSON(configs.ResponseFail, err.Error(), err.Error())
}
c.JSON(configs.ResponseSucess, "success", &statisticalData)
}
......@@ -161,6 +161,9 @@ func (c *PublicController) Register() {
}
}
// flow Statistical
services.GetFlowStatisticalRepositoryInstance().Increment(user.Platform, user.ID)
} else {
// GetAdminAuthInfo
......
......@@ -38,7 +38,6 @@ func (c *ServicesStatisticalController) List() {
valid := validation.Validation{}
valid.Required(paginationDto.PageOn, "page_on").Message("page_on不能为空!")
valid.Required(paginationDto.PageSize, "page_size").Message("page_size不能为空!")
valid.Required(paginationDto.Cid, "cid").Message("cid不能为空!")
valid.Required(paginationDto.Date, "date").Message("date不能为空!")
if valid.HasErrors() {
for _, err := range valid.Errors {
......
......@@ -41,6 +41,7 @@ func Run() {
orm.RegisterModel(new(models.WorkOrder))
orm.RegisterModel(new(models.WorkOrderType))
orm.RegisterModel(new(models.WorkOrderComment))
orm.RegisterModel(new(models.FlowStatistical))
// 创建表
_ = orm.RunSyncdb("default", false, true)
......
package models
// FlowStatistical 独立流量统计
type FlowStatistical struct {
ID int64 `orm:"auto;pk;column(id)" json:"id"` // id
Date int64 `orm:"column(date)" json:"date"` // 统计日期
Platform int64 `orm:"column(platform)" json:"platform"` // 用户ID
Count int64 `orm:"column(count)" json:"count"` // 数量
Users string `orm:"null;type(text);column(users)" json:"users"` // 用户IDS
}
.mini-im-home-title[data-v-046eea91]{text-align:center;font-size:18px;color:#666;padding:15px 0 50px}.mini-im-home-copyright[data-v-046eea91]{text-align:center;color:#666;font-size:14px;padding-top:50px}.online-count[data-v-046eea91]{text-align:center;color:#666;margin-top:10px}.online-count span[data-v-046eea91]{color:#8bc34a;margin:0 5px}
\ No newline at end of file
.mini-im-home-title[data-v-48cdb8f2]{text-align:center;font-size:18px;color:#666;padding:15px 0 50px}.mini-im-home-copyright[data-v-48cdb8f2]{text-align:center;color:#666;font-size:14px;padding-top:50px}.online-count[data-v-48cdb8f2]{text-align:center;color:#666;margin-top:10px}.online-count span[data-v-48cdb8f2]{color:#8bc34a;margin:0 5px}
\ No newline at end of file
......@@ -47,4 +47,4 @@
}
input:-ms-input-placeholder{ /* Internet Explorer 10-11 */
color:#ccc;
}</style><link href=css/chunk-027be9b0.1440a418.css rel=prefetch><link href=css/chunk-08473d3a.77daa9fe.css rel=prefetch><link href=css/chunk-08627161.c1f4f120.css rel=prefetch><link href=css/chunk-0bf8947d.310a0e2f.css rel=prefetch><link href=css/chunk-132fc719.b547401f.css rel=prefetch><link href=css/chunk-1e573615.be89fdde.css rel=prefetch><link href=css/chunk-4d213a0b.e2ea152d.css rel=prefetch><link href=css/chunk-56896308.67b3f13c.css rel=prefetch><link href=css/chunk-650419d0.3897bea9.css rel=prefetch><link href=css/chunk-724a4e2a.507bad62.css rel=prefetch><link href=css/chunk-763d35df.70fac712.css rel=prefetch><link href=js/chunk-027be9b0.1078ee31.js rel=prefetch><link href=js/chunk-08473d3a.57550f5a.js rel=prefetch><link href=js/chunk-08627161.af4b0a2d.js rel=prefetch><link href=js/chunk-0bf8947d.9b4903e6.js rel=prefetch><link href=js/chunk-132fc719.078733a8.js rel=prefetch><link href=js/chunk-1e573615.16b6c862.js rel=prefetch><link href=js/chunk-343c8d41.1c228cb2.js rel=prefetch><link href=js/chunk-4d213a0b.21e8499f.js rel=prefetch><link href=js/chunk-56896308.2e82959c.js rel=prefetch><link href=js/chunk-650419d0.99e278a2.js rel=prefetch><link href=js/chunk-724a4e2a.f58c8db3.js rel=prefetch><link href=js/chunk-763d35df.f33fe524.js rel=prefetch><link href=css/app.ba710877.css rel=preload as=style><link href=css/chunk-vendors.cb739fea.css rel=preload as=style><link href=js/app.5bbe92af.js rel=preload as=script><link href=js/chunk-vendors.420bd1eb.js rel=preload as=script><link href=css/chunk-vendors.cb739fea.css rel=stylesheet><link href=css/app.ba710877.css rel=stylesheet></head><body><noscript><strong>We're sorry but m doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id=app></div><script src=js/chunk-vendors.420bd1eb.js></script><script src=js/app.5bbe92af.js></script></body></html>
\ No newline at end of file
}</style><link href=css/chunk-027be9b0.1440a418.css rel=prefetch><link href=css/chunk-08473d3a.77daa9fe.css rel=prefetch><link href=css/chunk-08627161.c1f4f120.css rel=prefetch><link href=css/chunk-0bf8947d.310a0e2f.css rel=prefetch><link href=css/chunk-132fc719.b547401f.css rel=prefetch><link href=css/chunk-1e573615.be89fdde.css rel=prefetch><link href=css/chunk-4d213a0b.e2ea152d.css rel=prefetch><link href=css/chunk-56896308.67b3f13c.css rel=prefetch><link href=css/chunk-650419d0.3897bea9.css rel=prefetch><link href=css/chunk-724a4e2a.507bad62.css rel=prefetch><link href=css/chunk-f8bfd426.2fc6ff09.css rel=prefetch><link href=js/chunk-027be9b0.1078ee31.js rel=prefetch><link href=js/chunk-08473d3a.b7eb59e9.js rel=prefetch><link href=js/chunk-08627161.af4b0a2d.js rel=prefetch><link href=js/chunk-0bf8947d.9b4903e6.js rel=prefetch><link href=js/chunk-132fc719.078733a8.js rel=prefetch><link href=js/chunk-1e573615.16b6c862.js rel=prefetch><link href=js/chunk-343c8d41.1c228cb2.js rel=prefetch><link href=js/chunk-4d213a0b.21e8499f.js rel=prefetch><link href=js/chunk-56896308.2e82959c.js rel=prefetch><link href=js/chunk-650419d0.99e278a2.js rel=prefetch><link href=js/chunk-724a4e2a.f58c8db3.js rel=prefetch><link href=js/chunk-f8bfd426.78f7bc0b.js rel=prefetch><link href=css/app.ba710877.css rel=preload as=style><link href=css/chunk-vendors.cb739fea.css rel=preload as=style><link href=js/app.d2d60b82.js rel=preload as=script><link href=js/chunk-vendors.420bd1eb.js rel=preload as=script><link href=css/chunk-vendors.cb739fea.css rel=stylesheet><link href=css/app.ba710877.css rel=stylesheet></head><body><noscript><strong>We're sorry but m doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id=app></div><script src=js/chunk-vendors.420bd1eb.js></script><script src=js/app.d2d60b82.js></script></body></html>
\ No newline at end of file
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
package services
import (
"kefu_server/models"
"strconv"
"strings"
"time"
"github.com/astaxie/beego/logs"
"github.com/astaxie/beego/orm"
)
// FlowStatisticalRepositoryInterface interface
type FlowStatisticalRepositoryInterface interface {
GetCounter(startDate string, endDate string) ([]orm.Params, error)
Increment(platform int64, uid int64)
}
// FlowStatisticalRepository struct
type FlowStatisticalRepository struct {
BaseRepository
}
// GetFlowStatisticalRepositoryInstance get instance
func GetFlowStatisticalRepositoryInstance() *FlowStatisticalRepository {
instance := new(FlowStatisticalRepository)
instance.Init(new(models.FlowStatistical))
return instance
}
// Increment add counter
func (r *FlowStatisticalRepository) Increment(platform int64, uid int64) {
uidStr := strconv.FormatInt(uid, 10)
// transform date
layoutDate := "2006-01-02 15:04:05"
loc, _ := time.LoadLocation("Local")
dateStartString := time.Now().Format("2006-01-02") + " 00:00:00"
dateEndString := time.Now().Format("2006-01-02") + " 23:59:59"
dateStart, _ := time.ParseInLocation(layoutDate, dateStartString, loc)
dateEnd, _ := time.ParseInLocation(layoutDate, dateEndString, loc)
var flowStatistical models.FlowStatistical
err := r.q.Filter("platform", platform).Filter("date__gte", dateStart.Unix()).Filter("date__lte", dateEnd.Unix()).One(&flowStatistical)
if err != nil {
logs.Warn("Increment add counter------------", err, dateStart, dateEnd)
_, err := r.o.Insert(&models.FlowStatistical{
Date: time.Now().Unix(),
Platform: platform,
Count: 1,
Users: uidStr + "|",
})
if err != nil {
logs.Warn("Increment Insert err------------", err, dateStart, dateEnd)
}
return
}
if !strings.Contains(flowStatistical.Users, uidStr) {
flowStatistical.Users = flowStatistical.Users + uidStr + "|"
flowStatistical.Count = flowStatistical.Count + 1
_, err := r.o.Update(&flowStatistical)
if err != nil {
logs.Warn("Increment Update err------------", err, dateStart, dateEnd)
}
}
}
// GetCounter get counter
func (r *FlowStatisticalRepository) GetCounter(startDate string, endDate string) ([]orm.Params, error) {
// transform date
layoutDate := "2006-01-02 15:04:05"
loc, _ := time.LoadLocation("Local")
dateStartString := startDate + " 00:00:00"
dateEndString := endDate + " 23:59:59"
dateStart, _ := time.ParseInLocation(layoutDate, dateStartString, loc)
dateEnd, _ := time.ParseInLocation(layoutDate, dateEndString, loc)
var statisticalData []orm.Params
_, err := r.o.Raw("SELECT p.id platform,p.title, IFNULL(f.count,0) AS `count` FROM platform as p LEFT JOIN (SELECT platform,SUM(count) AS `count` FROM `flow_statistical` WHERE date BETWEEN ? AND ? GROUP BY platform) f ON p.id = f.platform ORDER BY platform ASC", dateStart.Unix(), dateEnd.Unix()).Values(&statisticalData)
if err != nil {
logs.Warn("GetCounter get counter------------", err)
return []orm.Params{}, err
}
return statisticalData, nil
}
......@@ -4,6 +4,7 @@ import (
"errors"
"kefu_server/models"
"math"
"strconv"
"time"
"github.com/astaxie/beego/logs"
......@@ -14,7 +15,6 @@ import (
type StatisticalRepositoryInterface interface {
Add(servicesStatistical *models.ServicesStatistical) (int64, error)
GetStatisticals(startDate string, endDate string) (map[string]interface{}, error)
GetFlowStatistical(startDate string, endDate string) ([]orm.Params, error)
GetCustomerServiceList(request models.ServicesStatisticalPaginationDto) models.ServicesStatisticalPaginationDto
CheckIsReplyAndSetReply(uid int64, aid int64, platform int64)
}
......@@ -59,7 +59,12 @@ func (r *StatisticalRepository) GetCustomerServiceList(request models.ServicesSt
INReception = "0"
}
if err := r.o.Raw("SELECT "+addSQL+" AS `count` FROM services_statistical AS s INNER JOIN (SELECT * FROM `user`) AS u ON s.user_account = u.id AND s.service_account = ? AND s.create_at > ? AND s.create_at < ? AND is_reception IN("+INReception+")", request.Cid, startDate.Unix(), endDate.Unix()).QueryRow(&totalModel); err != nil {
serviceAccount := " "
if request.Cid != 0 {
serviceAccount = " s.service_account = " + strconv.FormatInt(request.Cid, 10) + " AND "
}
if err := r.o.Raw("SELECT "+addSQL+" AS `count` FROM services_statistical AS s INNER JOIN (SELECT * FROM `user`) AS u ON s.user_account = u.id AND "+serviceAccount+" s.create_at > ? AND s.create_at < ? AND is_reception IN("+INReception+")", startDate.Unix(), endDate.Unix()).QueryRow(&totalModel); err != nil {
logs.Warn("GetCustomerServiceList get Customer Service List1------------", err)
}
request.Total = totalModel.Count
......@@ -70,7 +75,7 @@ func (r *StatisticalRepository) GetCustomerServiceList(request models.ServicesSt
addSQL1 = " GROUP BY `user_account` "
}
if counter, err := r.o.Raw("SELECT s.id, s.user_account, s.service_account,s.create_at,s.is_reception, s.transfer_account,s.platform,u.nickname FROM services_statistical AS s INNER JOIN (SELECT * FROM `user` ) AS u ON s.user_account = u.id AND s.service_account = ? AND s.create_at > ? AND s.create_at < ? AND is_reception IN("+INReception+") "+addSQL1+" ORDER BY s.create_at DESC LIMIT ?,?", request.Cid, startDate.Unix(), endDate.Unix(), (request.PageOn-1)*request.PageSize, request.PageSize).Values(&params); counter <= 0 {
if counter, err := r.o.Raw("SELECT s.id, s.user_account, s.service_account,s.create_at,s.is_reception, s.transfer_account,s.platform,u.nickname FROM services_statistical AS s INNER JOIN (SELECT * FROM `user` ) AS u ON s.user_account = u.id AND "+serviceAccount+" s.create_at > ? AND s.create_at < ? AND is_reception IN("+INReception+") "+addSQL1+" ORDER BY s.create_at DESC LIMIT ?,?", startDate.Unix(), endDate.Unix(), (request.PageOn-1)*request.PageSize, request.PageSize).Values(&params); counter <= 0 {
logs.Warn("GetCustomerServiceList get Customer Service List2------------", err)
request.List = []string{}
return request
......@@ -144,25 +149,6 @@ func (r *StatisticalRepository) GetStatisticals(startDate string, endDate string
return countsArr, nil
}
// GetFlowStatistical get Today Action Statistical
func (r *StatisticalRepository) GetFlowStatistical(startDate string, endDate string) ([]orm.Params, error) {
// transform date
layoutDate := "2006-01-02 15:04:05"
loc, _ := time.LoadLocation("Local")
dateStartString := startDate + " 00:00:00"
dateEndString := endDate + " 23:59:59"
dateStart, _ := time.ParseInLocation(layoutDate, dateStartString, loc)
dateEnd, _ := time.ParseInLocation(layoutDate, dateEndString, loc)
var statisticalData []orm.Params
_, err := r.o.Raw("SELECT p.id platform,p.title, IFNULL(u.count,0) AS `count` FROM platform as p LEFT JOIN (SELECT platform,COUNT(*) AS count FROM `user` WHERE last_activity BETWEEN ? AND ? GROUP BY platform) u ON p.id = u.platform", dateStart.Unix(), dateEnd.Unix()).Values(&statisticalData)
if err != nil {
logs.Warn("GetFlowStatistical get Today Action Statistical------------", err)
return nil, err
}
return statisticalData, nil
}
// CheckIsReplyAndSetReply cehck is reply and set reply
func (r *StatisticalRepository) CheckIsReplyAndSetReply(userAccount int64, serviceAccount int64, userPlatform int64) {
var servicesStatistical models.ServicesStatistical
......
......@@ -151,7 +151,7 @@ export default {
is_de_weighting: false,
date: "",
},
customerData: [],
customerData: [{id:0, nickname: "全部"}],
selectCustomerId: null,
selectUser: {},
pickerOptions: {
......@@ -240,7 +240,7 @@ export default {
getAdmins(){
axios.post('/admin/list', {page_on: 1, page_size: 100, "online": 3})
.then(response => {
this.customerData = response.data.data.list
this.customerData = this.customerData.concat(response.data.data.list)
})
.catch(error => {
this.$message.error(error.response.data.message)
......
......@@ -2,6 +2,6 @@ module.exports = {
publicPath: process.env.NODE_ENV === 'production' ? './' : '/',
outputDir: '../../public/admin/',
devServer: {
proxy: 'http://im.cmp520.com',
proxy: 'http://localhost:8088',
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment