Roc 1 سال پیش
والد
کامیت
7616f26e67
8فایلهای تغییر یافته به همراه33 افزوده شده و 2135 حذف شده
  1. 0 1011
      models/company/company.go
  2. 0 62
      models/company_view_statistics.go
  3. 6 5
      models/system/sys_session.go
  4. 0 426
      models/user_view_history.go
  5. 0 351
      models/wx_user.go
  6. 27 0
      routers/commentsRouter.go
  7. 0 277
      services/company.go
  8. 0 3
      services/user.go

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 0 - 1011
models/company/company.go


+ 0 - 62
models/company_view_statistics.go

@@ -1,62 +0,0 @@
-package models
-
-import (
-	"github.com/beego/beego/v2/client/orm"
-	"time"
-)
-
-// CompanyViewStatistics 客户报告报告阅读数量统计表
-type CompanyViewStatistics struct {
-	Id         int       `orm:"column(id)" description:"自增Id"`
-	CompanyId  int       `description:"客户id"`
-	ViewNum    int       `description:"阅读总数"`
-	Date       time.Time `description:"阅读日期"`
-	CreateTime time.Time `description:"添加时间"`
-}
-
-// CompanyViewTotalSlice 获取客户的浏览次数
-type CompanyViewTotalSellerSlice struct {
-	CompanyIds string `description:"客户id字符串"`
-	Num        int    `description:"用户浏览次数"`
-	AdminId    int    `description:"所属销售id"`
-}
-
-// GetCompanyViewTotalList 获取客户的浏览数
-func GetCompanyViewTotalList(condition string, pars []interface{}, viewNum int, sumNumType string) (items []*CompanyViewTotalSellerSlice, err error) {
-	o := orm.NewOrm()
-	sql := `select count(DISTINCT(company_id)) num,GROUP_CONCAT(DISTINCT company_id SEPARATOR ',') AS company_ids,admin_id from (SELECT sum(a.view_num) sum_num,a.company_id,b.seller_id admin_id FROM company_view_statistics a 
-join company_product b on a.company_id=b.company_id
-WHERE 1=1 `
-	if condition != "" {
-		sql += condition
-	}
-
-	childSql := ` sum_num >= `
-	if sumNumType == "<" {
-		childSql = ` sum_num ` + sumNumType + ` `
-	}
-
-	sql += ` GROUP BY company_id) b where 1 = 1 and ` + childSql + `? GROUP BY admin_id`
-	_, err = o.Raw(sql, pars, viewNum).QueryRows(&items)
-	return
-}
-
-// GetAllCompanyViewTotalList 获取所有客户的浏览数
-func GetAllCompanyViewTotalList(condition string, pars []interface{}, viewNum int, sumNumType string) (items []*CompanyViewTotalSellerSlice, err error) {
-	o := orm.NewOrm()
-	sql := `select count(DISTINCT(company_id)) num,GROUP_CONCAT(DISTINCT company_id SEPARATOR ',') AS company_ids,admin_id from (SELECT sum(a.view_num) sum_num,a.company_id,b.seller_id admin_id FROM company_view_statistics a 
-join company_product b on a.company_id=b.company_id
-WHERE 1=1 `
-	if condition != "" {
-		sql += condition
-	}
-
-	childSql := ` sum_num >= `
-	if sumNumType == "<" {
-		childSql = ` sum_num ` + sumNumType + ` `
-	}
-
-	sql += ` GROUP BY company_id) b where 1 = 1 and ` + childSql + `? GROUP BY admin_id`
-	_, err = o.Raw(sql, pars, viewNum).QueryRows(&items)
-	return
-}

+ 6 - 5
models/system/sys_session.go

@@ -16,9 +16,9 @@ type SysSession struct {
 	LastUpdatedTime time.Time
 }
 
-// 新增用户登录session信息
+// AddSysSession 新增用户登录session信息
 func AddSysSession(item *SysSession) (err error) {
-	o := orm.NewOrmUsingDB("rddp")
+	o := orm.NewOrm()
 	lastId, err := o.Insert(item)
 	if err != nil {
 		return
@@ -29,14 +29,15 @@ func AddSysSession(item *SysSession) (err error) {
 
 func GetSysSessionBySysUserId(sysUserId int) (item *SysSession, err error) {
 	sql := `SELECT * FROM sys_session WHERE sys_user_id=? AND expired_time> NOW() ORDER BY expired_time DESC LIMIT 1 `
-	o := orm.NewOrmUsingDB("rddp")
+	o := orm.NewOrm()
 	err = o.Raw(sql, sysUserId).QueryRow(&item)
 	return
 }
 
+// GetSysSessionByToken 根据token获取session
 func GetSysSessionByToken(token string) (item *SysSession, err error) {
 	sql := `SELECT * FROM sys_session WHERE access_token=? AND expired_time> NOW() ORDER BY expired_time DESC LIMIT 1 `
-	o := orm.NewOrmUsingDB("rddp")
+	o := orm.NewOrm()
 	err = o.Raw(sql, token).QueryRow(&item)
 	return
 }
@@ -44,7 +45,7 @@ func GetSysSessionByToken(token string) (item *SysSession, err error) {
 // ExpiredSysSessionByAdminId 过期掉用户token
 func ExpiredSysSessionByAdminId(adminId int) (err error) {
 	sql := `update sys_session set expired_time = NOW()  WHERE sys_user_id=? `
-	o := orm.NewOrmUsingDB("rddp")
+	o := orm.NewOrm()
 	_, err = o.Raw(sql, adminId).Exec()
 	return
 }

+ 0 - 426
models/user_view_history.go

@@ -2,434 +2,8 @@ package models
 
 import (
 	"github.com/beego/beego/v2/client/orm"
-	"hongze/hz_eta_api/utils"
-	"time"
 )
 
-type UserViewHistory struct {
-	ViewHistoryId        int       `orm:"column(id);pk"`
-	UserId               int       `description:"用户id"`
-	Mobile               string    `description:"手机号"`
-	Email                string    `description:"邮箱"`
-	RealName             string    `description:"用户实际姓名"`
-	CompanyName          string    `description:"公司名称"`
-	ViewTitle            string    `description:"访问标题"`
-	ViewPage             string    `description:"访问页面"`
-	ReportChapterModule  string    `description:"访问核心观点或者图文逻辑"`
-	CreatedTime          string    `description:"创建时间"`
-	LastUpdatedTime      time.Time `description:"访问历史类型,weekly_report 周报,pdf;默认值:weekly_report"`
-	ResearchReportId     int       `description:"研报id"`
-	ResearchReportTypeId int       `description:"报告章节id,为0时表示查看目录或者首页"`
-}
-
-// 根据用户id字符串获取用户的浏览数
-type UserViewTotalSlice struct {
-	UserId      int       `description:"用户id"`
-	Total       int       `description:"总阅读数"`
-	CreatedTime time.Time `description:"用户浏览时间"`
-}
-
-func GetCountUserViewHistoryByUserIds(userIds string) (items []*UserViewTotalSlice, err error) {
-	o := orm.NewOrm()
-	sql := `SELECT count(1) total,user_id,max(created_time) as created_time FROM user_view_history WHERE user_id in (` + userIds + `) group by user_id`
-	_, err = o.Raw(sql).QueryRows(&items)
-	return
-	//return items2,err
-}
-
-// 根据用户手机号字符串获取用户的浏览数
-type UserViewMobileTotalSlice struct {
-	Mobile      string    `description:"用户手机号"`
-	Total       int       `description:"总阅读数"`
-	CreatedTime time.Time `description:"用户浏览时间"`
-}
-
-func GetCountUserViewHistoryByMobiles(mobiles string) (items []*UserViewMobileTotalSlice, err error) {
-	o := orm.NewOrm()
-	sql := `SELECT count(1) total,mobile,max(created_time) as created_time FROM user_view_history WHERE mobile in (` + mobiles + `) group by mobile`
-	_, err = o.Raw(sql).QueryRows(&items)
-	return
-}
-
-// 根据用户id字符串获取用户的浏览数
-type UserViewEmailTotalSlice struct {
-	Email       string    `description:"用户邮箱"`
-	Total       int       `description:"总阅读数"`
-	CreatedTime time.Time `description:"用户浏览时间"`
-}
-
-func GetCountUserViewHistoryByEmails(emails string) (items []*UserViewEmailTotalSlice, err error) {
-	o := orm.NewOrm()
-	sql := `SELECT count(1) total,email,max(created_time) as created_time FROM user_view_history WHERE email in (` + emails + `) group by email`
-	_, err = o.Raw(sql).QueryRows(&items)
-	return
-	//return items2,err
-}
-
-func GetCountCygxArticleHistoryRecordByMobiles(mobiles string) (items []*UserViewMobileTotalSlice, err error) {
-	o := orm.NewOrm()
-	sql := `SELECT count(1) total,h.mobile,max(h.create_time) as created_time FROM cygx_article_history_record_all  AS h  INNER JOIN cygx_article  AS art  ON  art.article_id = h.article_id  WHERE h.mobile in (` + mobiles + `) AND h.is_del = 0  AND h.company_id != 16 group by h.mobile`
-	_, err = o.Raw(sql).QueryRows(&items)
-	return
-}
-
-func GetCountCygxArticleHistoryRecordByEmails(emails string) (items []*UserViewEmailTotalSlice, err error) {
-	o := orm.NewOrm()
-	sql := `SELECT count(1) total,h.email,max(h.create_time) as created_time FROM cygx_article_history_record_all AS h  INNER JOIN cygx_article  AS art  ON  art.article_id = h.article_id  WHERE h.email in (` + emails + `) AND h.is_del = 0 AND h.company_id != 16 group by email`
-	_, err = o.Raw(sql).QueryRows(&items)
-	return
-}
-
-// CompanyLastViewSlice 根据手机号获取客户的最新浏览时间
-type CompanyLastViewSlice struct {
-	CompanyId int       `description:"客户id"`
-	ViewTime  time.Time `description:"用户浏览时间"`
-}
-
-// GetLastUserViewHistoryByCompanyIdsMobile 根据手机号获取客户的最新浏览时间
-func GetLastUserViewHistoryByCompanyIdsMobile(companyIds string) (items []*CompanyLastViewSlice, err error) {
-	today := time.Now().Format(utils.FormatDate)
-	o := orm.NewOrm()
-	sql := `SELECT
-	a.company_id ,max(b.created_time) view_time
-FROM
-	wx_user a
-	JOIN user_view_history b ON a.mobile = b.mobile 
-WHERE
-	a.company_id IN ( ` + companyIds + ` )  and b.mobile !="" and b.created_time>=? GROUP BY company_id`
-	_, err = o.Raw(sql, today).QueryRows(&items)
-	return
-}
-
-// GetLastUserViewHistoryByCompanyIdsEmail 根据邮箱获取客户的最新浏览时间
-func GetLastUserViewHistoryByCompanyIdsEmail(companyIds string) (items []*CompanyLastViewSlice, err error) {
-	today := time.Now().Format(utils.FormatDate)
-	o := orm.NewOrm()
-	//	sql := `SELECT
-	//	a.company_id ,max(b.created_time) view_time
-	//FROM
-	//	wx_user a
-	//	JOIN user_view_history b ON a.email = b.email
-	//WHERE a.company_id IN ( ` + companyIds + ` ) and b.email !="" and b.mobile=""  and b.created_time>=?  GROUP BY company_id`
-
-	sql := `SELECT
-	a.company_id ,max(b.created_time) view_time FROM wx_user a
-	JOIN user_view_history b ON a.email = b.email 
-WHERE b.email !="" and b.mobile=""  and b.created_time>=?  GROUP BY company_id`
-
-	_, err = o.Raw(sql, today).QueryRows(&items)
-	return
-}
-
-// GetLastAdvisoryArticleViewRecordByCompanyIdsMobile 根据手机号获取客户的最新浏览时间
-func GetLastAdvisoryArticleViewRecordByCompanyIdsMobile(companyIds string) (items []*CompanyLastViewSlice, err error) {
-	today := time.Now().Format(utils.FormatDate)
-	o := orm.NewOrm()
-	sql := `SELECT
-	a.company_id ,max(b.create_time) view_time
-FROM
-	wx_user a
-	JOIN advisory_user_chart_article_record b ON a.mobile = b.mobile 
-WHERE
-	a.company_id IN ( ` + companyIds + ` )  and b.mobile !="" and b.create_time>=? GROUP BY company_id`
-	_, err = o.Raw(sql, today).QueryRows(&items)
-	return
-}
-
-// GetLastAdvisoryArticleViewRecordByCompanyIdsEmail 根据邮箱获取客户的最新浏览时间
-func GetLastAdvisoryArticleViewRecordByCompanyIdsEmail(companyIds string) (items []*CompanyLastViewSlice, err error) {
-	today := time.Now().Format(utils.FormatDate)
-	o := orm.NewOrm()
-	sql := `SELECT
-	a.company_id ,max(b.create_time) view_time
-FROM
-	wx_user a
-	JOIN advisory_user_chart_article_record b ON a.email = b.email 
-WHERE a.company_id IN ( ` + companyIds + ` ) and b.email !="" and b.mobile=""  and b.create_time>=?  GROUP BY company_id`
-	_, err = o.Raw(sql, today).QueryRows(&items)
-	return
-}
-
-// GetLastCygxArticleViewRecordByCompanyIdsMobile 根据手机号获取客户的最新浏览时间
-func GetLastCygxArticleViewRecordByCompanyIdsMobile(companyIds string) (items []*CompanyLastViewSlice, err error) {
-	o := orm.NewOrm()
-	//dataName := ""
-	//if utils.RunMode == "debug" {
-	//	dataName = "test_v2_hongze_rddp"
-	//} else {
-	//	dataName = "hongze_rddp"
-	//}
-	sql := `SELECT
-	a.company_id ,max(b.create_time) view_time
-FROM
-	wx_user a
-	JOIN cygx_article_history_record_newpv b ON a.mobile = b.mobile 
-WHERE
-	a.company_id IN ( ` + companyIds + ` )  and b.mobile !="" GROUP BY company_id`
-	_, err = o.Raw(sql).QueryRows(&items)
-	return
-}
-
-// GetLastCygxArticleViewRecordByCompanyIdsEmail 根据邮箱获取客户的最新浏览时间
-func GetLastCygxArticleViewRecordByCompanyIdsEmail(companyIds string) (items []*CompanyLastViewSlice, err error) {
-	o := orm.NewOrm()
-	sql := `SELECT
-	a.company_id ,max(b.create_time) view_time
-FROM
-	wx_user a
-	JOIN cygx_article_history_record_newpv b ON a.email = b.email 
-WHERE a.company_id IN ( ` + companyIds + ` ) and b.email !="" and b.mobile=""   GROUP BY company_id`
-	_, err = o.Raw(sql).QueryRows(&items)
-	return
-}
-
-// GetLastReportViewRecordByCompanyIdsMobile 根据手机号获取客户的最新浏览时间
-func GetLastReportViewRecordByCompanyIdsMobile(companyIds string) (items []*CompanyLastViewSlice, err error) {
-	today := time.Now().Format(utils.FormatDate)
-	o := orm.NewOrm()
-	dataName := ""
-	if utils.RunMode == "debug" {
-		dataName = "test_v2_hongze_rddp"
-	} else {
-		dataName = "hongze_rddp"
-	}
-	sql := `SELECT
-	a.company_id ,max(b.create_time) view_time
-FROM
-	wx_user a
-	JOIN ` + dataName + `.report_view_record b ON a.mobile = b.mobile 
-WHERE
-	a.company_id IN ( ` + companyIds + ` )  and b.mobile !="" and b.create_time>=? GROUP BY company_id`
-	_, err = o.Raw(sql, today).QueryRows(&items)
-	return
-}
-
-// GetLastReportViewRecordByCompanyIdsEmail 根据邮箱获取客户的最新浏览时间
-func GetLastReportViewRecordByCompanyIdsEmail(companyIds string) (items []*CompanyLastViewSlice, err error) {
-	today := time.Now().Format(utils.FormatDate)
-	o := orm.NewOrm()
-	dataName := ""
-	if utils.RunMode == "debug" {
-		dataName = "test_v2_hongze_rddp"
-	} else {
-		dataName = "hongze_rddp"
-	}
-	sql := `SELECT	a.company_id ,max(b.create_time) view_time FROM wx_user a
-	JOIN ` + dataName + `.report_view_record b ON a.email = b.email 
-WHERE a.company_id IN ( ` + companyIds + ` ) and b.email !="" and b.mobile=""   and b.create_time>=? GROUP BY company_id`
-	_, err = o.Raw(sql, today).QueryRows(&items)
-	return
-}
-
-// GetLastUserViewStatisticsByCompanyIdsMobile 根据手机号获取客户的最新浏览时间
-func GetLastUserViewStatisticsByCompanyIdsMobile(companyIds string) (items []*CompanyLastViewSlice, err error) {
-	today := time.Now().Format(utils.FormatDate)
-	o := orm.NewOrm()
-	sql := `SELECT
-	a.company_id ,max(b.last_view_time) view_time
-FROM
-	wx_user a
-	JOIN user_view_statistics b ON a.mobile = b.mobile 
-WHERE
-	a.company_id IN ( ` + companyIds + ` )  and a.mobile !="" and b.mobile !="" and b.date<=? GROUP BY a.company_id`
-	_, err = o.Raw(sql, today).QueryRows(&items)
-	return
-}
-
-// GetLastUserViewStatisticsByCompanyIdsEmail 根据邮箱获取客户的最新浏览时间
-func GetLastUserViewStatisticsByCompanyIdsEmail(companyIds string) (items []*CompanyLastViewSlice, err error) {
-	today := time.Now().Format(utils.FormatDate)
-	o := orm.NewOrm()
-	sql := `SELECT
-	a.company_id ,max(b.last_view_time) view_time
-FROM
-	wx_user a
-	JOIN user_view_statistics b ON a.email = b.email 
-WHERE a.company_id IN ( ` + companyIds + ` ) and a.email !="" and b.email !="" and a.mobile="" and b.mobile="" and b.date<=? GROUP BY a.company_id`
-	_, err = o.Raw(sql, today).QueryRows(&items)
-	return
-}
-
-// CompanyViewTotalSlice 获取客户的浏览次数
-type CompanyViewTotalSlice struct {
-	CompanyId int `description:"客户id"`
-	ViewTotal int `description:"用户浏览次数"`
-}
-
-// GetCountUserViewHistoryByCompanyIdsMobile 根据手机号获取客户的浏览次数
-func GetCountUserViewHistoryByCompanyIdsMobile(companyIds string) (items []*CompanyViewTotalSlice, err error) {
-	today := time.Now().Format(utils.FormatDate) + " 00:00:00"
-	o := orm.NewOrm()
-	sql := `SELECT
-	a.company_id ,count(1) view_total FROM 	wx_user a
-	JOIN user_view_history b ON a.mobile = b.mobile 
-WHERE 	a.company_id IN ( ` + companyIds + ` )  and b.mobile !="" and b.created_time>=? GROUP BY company_id`
-	_, err = o.Raw(sql, today).QueryRows(&items)
-	return
-}
-
-// GetCountUserViewHistoryByCompanyIdsEmail 根据邮箱获取客户的浏览次数
-func GetCountUserViewHistoryByCompanyIdsEmail(companyIds string) (items []*CompanyViewTotalSlice, err error) {
-	today := time.Now().Format(utils.FormatDate) + " 00:00:00"
-	o := orm.NewOrm()
-	//	sql := `SELECT
-	//	a.company_id ,count(1) view_total
-	//FROM
-	//	wx_user a
-	//	JOIN user_view_history b ON a.email = b.email
-	//WHERE a.company_id IN ( ` + companyIds + ` ) and b.email !="" and b.mobile=""  and b.created_time>=? GROUP BY company_id`
-
-	sql := `SELECT a.company_id ,count(1) view_total FROM wx_user a 
-JOIN user_view_history b ON a.email = b.email 
-WHERE  b.email !="" and b.mobile=""  and b.created_time>=? GROUP BY company_id`
-	_, err = o.Raw(sql, today).QueryRows(&items)
-	return
-}
-
-// GetCountAdvisoryArticleViewRecordByCompanyIdsMobile 根据手机号获取客户的浏览次数
-func GetCountAdvisoryArticleViewRecordByCompanyIdsMobile(companyIds string) (items []*CompanyViewTotalSlice, err error) {
-	today := time.Now().Format(utils.FormatDate) + " 00:00:00"
-	o := orm.NewOrm()
-	sql := `SELECT
-	a.company_id ,count(1) view_total
-FROM
-	wx_user a
-	JOIN advisory_user_chart_article_record b ON a.mobile = b.mobile 
-WHERE
-	a.company_id IN ( ` + companyIds + ` )  and b.mobile !="" and create_time>=? GROUP BY company_id`
-	_, err = o.Raw(sql, today).QueryRows(&items)
-	return
-}
-
-// GetCountAdvisoryArticleViewRecordByCompanyIdsEmail 根据邮箱获取客户的浏览次数
-func GetCountAdvisoryArticleViewRecordByCompanyIdsEmail(companyIds string) (items []*CompanyViewTotalSlice, err error) {
-	today := time.Now().Format(utils.FormatDate) + " 00:00:00"
-	o := orm.NewOrm()
-	sql := `SELECT
-	a.company_id ,count(1) view_total
-FROM
-	wx_user a
-	JOIN advisory_user_chart_article_record b ON a.email = b.email 
-WHERE a.company_id IN ( ` + companyIds + ` ) and b.email !="" and b.mobile="" and create_time>=? GROUP BY company_id`
-	_, err = o.Raw(sql, today).QueryRows(&items)
-	return
-}
-
-// GetCountCygxArticleViewRecordByCompanyIdsMobile 根据手机号获取客户的浏览次数
-func GetCountCygxArticleViewRecordByCompanyIdsMobile(companyIds string) (items []*CompanyViewTotalSlice, err error) {
-	o := orm.NewOrm()
-	//dataName := ""
-	//if utils.RunMode == "debug" {
-	//	dataName = "test_v2_hongze_rddp"
-	//} else {
-	//	dataName = "hongze_rddp"
-	//}
-	sql := `SELECT
-	a.company_id ,count(1) view_total
-FROM
-	wx_user a
-	JOIN cygx_article_history_record_newpv b ON a.mobile = b.mobile 
-WHERE
-	a.company_id IN ( ` + companyIds + ` )  and b.mobile !="" GROUP BY company_id`
-	_, err = o.Raw(sql).QueryRows(&items)
-	return
-}
-
-// GetCountCygxArticleViewRecordByCompanyIdsEmail 根据邮箱获取客户的浏览次数
-func GetCountCygxArticleViewRecordByCompanyIdsEmail(companyIds string) (items []*CompanyViewTotalSlice, err error) {
-	o := orm.NewOrm()
-	sql := `SELECT
-	a.company_id ,count(1) view_total
-FROM
-	wx_user a
-	JOIN cygx_article_history_record_newpv b ON a.email = b.email 
-WHERE a.company_id IN ( ` + companyIds + ` ) and b.email !="" and b.mobile="" GROUP BY company_id`
-	_, err = o.Raw(sql).QueryRows(&items)
-	return
-}
-
-// GetCountReportViewRecordByCompanyIdsMobile 根据手机号获取客户的浏览次数
-func GetCountReportViewRecordByCompanyIdsMobile(companyIds string) (items []*CompanyViewTotalSlice, err error) {
-	today := time.Now().Format(utils.FormatDate) + " 00:00:00"
-	o := orm.NewOrm()
-	dataName := ""
-	if utils.RunMode == "debug" {
-		dataName = "test_v2_hongze_rddp"
-	} else {
-		dataName = "hongze_rddp"
-	}
-	sql := `SELECT
-	a.company_id ,count(1) view_total
-FROM
-	wx_user a
-	JOIN ` + dataName + `.report_view_record b ON a.mobile = b.mobile 
-WHERE
-	a.company_id IN ( ` + companyIds + ` )  and b.mobile !="" and create_time>=? GROUP BY company_id`
-	_, err = o.Raw(sql, today).QueryRows(&items)
-	return
-}
-
-// GetCountReportViewRecordByCompanyIdsEmail 根据邮箱获取客户的浏览次数
-func GetCountReportViewRecordByCompanyIdsEmail(companyIds string) (items []*CompanyViewTotalSlice, err error) {
-	today := time.Now().Format(utils.FormatDate) + " 00:00:00"
-	o := orm.NewOrm()
-	dataName := ""
-	if utils.RunMode == "debug" {
-		dataName = "test_v2_hongze_rddp"
-	} else {
-		dataName = "hongze_rddp"
-	}
-	sql := `SELECT	a.company_id ,count(1) view_total FROM wx_user a
-	JOIN ` + dataName + `.report_view_record b ON a.email = b.email 
-WHERE a.company_id IN ( ` + companyIds + ` ) and b.email !="" and b.mobile="" and create_time>=? GROUP BY company_id`
-	_, err = o.Raw(sql, today).QueryRows(&items)
-	return
-}
-
-// GetUserViewStatisticsByCompanyIdsMobile 根据手机号获取客户的浏览次数
-func GetUserViewStatisticsByCompanyIdsMobile(companyIds string) (items []*CompanyViewTotalSlice, err error) {
-	today := time.Now().Format(utils.FormatDate)
-	o := orm.NewOrm()
-	sql := `SELECT
-	a.company_id ,sum(b.view_num) view_total
-FROM
-	wx_user a
-	JOIN user_view_statistics b ON a.mobile = b.mobile 
-WHERE
-	a.company_id IN ( ` + companyIds + ` )  and a.mobile !="" and b.mobile !="" and date<=? GROUP BY a.company_id`
-	_, err = o.Raw(sql, today).QueryRows(&items)
-	return
-}
-
-// GetUserViewStatisticsByCompanyIdsEmail 根据邮箱获取客户的浏览次数
-func GetUserViewStatisticsByCompanyIdsEmail(companyIds string) (items []*CompanyViewTotalSlice, err error) {
-	today := time.Now().Format(utils.FormatDate)
-	o := orm.NewOrm()
-	sql := `SELECT
-	a.company_id ,sum(b.view_num) view_total
-FROM
-	wx_user a
-	JOIN user_view_statistics b ON a.email = b.email 
-WHERE a.company_id IN ( ` + companyIds + ` ) and a.email !="" and b.email !="" and a.mobile="" and b.mobile="" and date<=? GROUP BY a.company_id`
-	_, err = o.Raw(sql, today).QueryRows(&items)
-	return
-}
-
-// UserViewStatisticsInfo 根据用户手机号字符串获取用户的浏览数和最晚阅读次数
-type UserViewStatisticsInfo struct {
-	Mobile       string    `description:"用户手机号"`
-	Total        int       `description:"总阅读数"`
-	LastViewTime time.Time `description:"用户浏览时间"`
-}
-
-// GetUserViewStatisticsByMobile 根据手机号获取联系人的浏览次数
-func GetUserViewStatisticsByMobile(mobile string) (item *UserViewStatisticsInfo, err error) {
-	o := orm.NewOrm()
-	sql := `SELECT mobile,sum(view_num) total,max(last_view_time) last_view_time FROM  user_view_statistics  WHERE mobile = ? `
-	err = o.Raw(sql, mobile).QueryRow(&item)
-	return
-}
-
 type ResearchReportViewPUV struct {
 	ResearchReportId int
 	Pv               int

+ 0 - 351
models/wx_user.go

@@ -3,7 +3,6 @@ package models
 import (
 	"github.com/beego/beego/v2/client/orm"
 	"github.com/rdlucklib/rdluck_tools/paging"
-	"hongze/hz_eta_api/utils"
 	"time"
 )
 
@@ -94,275 +93,6 @@ type PotentialUserListResp struct {
 	Paging *paging.PagingItem `description:"分页数据"`
 }
 
-// 联系人导入预览数据返回
-type ImportListResp struct {
-	ValidUser  []*WxUser `description:"有效客户数据"`
-	RepeatUser []*WxUser `description:"重复客户数据"`
-}
-
-func GetPotentialUserListCount(condition string, pars []interface{}) (count int, err error) {
-	o := orm.NewOrm()
-	sql := `SELECT COUNT(1) AS count
-			FROM wx_user AS a
-			LEFT JOIN company AS b ON a.company_id = b.company_id
-            LEFT JOIN user_record AS c ON a.user_id=c.user_id
-			WHERE b.enabled = 1 AND b.company_id = 1 
-			AND (a.mobile IS NOT NULL || a.email IS NOT NULL)
-            AND (a.mobile<>'' OR a.email<>'') 
-            AND (c.create_platform<>4 or c.create_platform is null)`
-	if condition != "" {
-		sql += condition
-	}
-	err = o.Raw(sql, pars).QueryRow(&count)
-	return
-}
-
-func GetPotentialUserList(condition string, pars []interface{}, startSize, pageSize int) (items []*PotentialUserItem, err error) {
-	o := orm.NewOrm()
-	sql := `SELECT a.*,a.note AS company_name,
-			IF(b.type IN (1,2),1,0) AS is_fee_customer,
-            (SELECT count(1) FROM user_view_history AS uvh WHERE uvh.user_id=a.user_id GROUP BY a.user_id) AS view_total,
-            a.report_last_view_time AS last_view_time_str,
-            c.create_platform
-			FROM wx_user AS a
-			LEFT JOIN company AS b ON a.company_id = b.company_id
-            LEFT JOIN user_record AS c ON a.user_id=c.user_id
-			WHERE b.enabled = 1 AND b.company_id = 1 
-			AND (a.mobile IS NOT NULL || a.email IS NOT NULL) 
-            AND (a.mobile<>'' OR a.email<>'') 
-           AND (c.create_platform<>4 or c.create_platform is null) `
-	if condition != "" {
-		sql += condition
-	}
-	sql += ` GROUP BY a.user_id `
-	sql += `ORDER BY  a.created_time DESC LIMIT ?,? `
-	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
-	return
-}
-
-type PotentialUserDeleteReq struct {
-	UserId int `description:"用户id"`
-}
-
-// 标记潜在用户请求
-type PotentialUserDealReq struct {
-	UserId int `description:"用户id"`
-}
-
-func DeletePotentialUser(userId int) (err error) {
-	sql := ` DELETE FROM wx_user WHERE user_id=? `
-	_, err = orm.NewOrm().Raw(sql, userId).Exec()
-	return
-}
-
-// DeleteWxUserByUserIds 根据用户id字符串批量删除用户信息
-func DeleteWxUserByUserIds(userIds string) (err error) {
-	sql := ` DELETE FROM wx_user WHERE user_id in (` + userIds + `) `
-	_, err = orm.NewOrm().Raw(sql).Exec()
-	return
-}
-
-// 移动潜在客户名下的联系人 请求数据
-type PotentialUserMoveReq struct {
-	UserId    int    `description:"用户id"`
-	CompanyId int    `description:"移动到的客户id"`
-	SellerId  int    `description:"需要移动到的销售id"`
-	RealName  string `description:"姓名"`
-	Mobile    string `description:"手机号"`
-	Email     string `description:"邮箱"`
-	Remark    string `description:"备注信息"`
-
-	//crm4.0新增校验字段
-	Sex             int    `description:"用户性别,1为男性,2为女性"`
-	RegionType      string `description:"区域,枚举值:国内、海外"`
-	Position        string `description:"职位"`
-	IsMaker         int    `description:"是否决策人,1:是,0:否"`
-	BusinessCardUrl string `description:"名片地址"`
-	DepartmentName  string `description:"联系人部门"`
-	CountryCode     string `description:"区号,86、852、886等"`
-}
-
-// 移动联系人请求数据
-type UserMoveReq struct {
-	UserId    int `description:"用户id"`
-	CompanyId int `description:"移动到的客户id"`
-	SellerId  int `description:"需要移动到的销售id"`
-}
-
-// FICC申请单-移动潜在客户名下的联系人 请求数据
-type ApplyRecordPotentialUserMoveReq struct {
-	UserId          int    `description:"用户id"`
-	CompanyId       int    `description:"移动到的客户id"`
-	SellerId        int    `description:"需要移动到的销售id"`
-	RealName        string `description:"姓名"`
-	Mobile          string `description:"手机号"`
-	Email           string `description:"邮箱"`
-	Remark          string `description:"备注信息"`
-	ApplyRecordId   int    `description:"申请单ID"`
-	Sex             int    `description:"用户性别,1为男性,2为女性"`
-	RegionType      string `description:"区域,枚举值:国内、海外"`
-	Position        string `description:"职位"`
-	IsMaker         int    `description:"是否决策人,1:是,0:否"`
-	BusinessCardUrl string `description:"名片地址"`
-	DepartmentName  string `description:"联系人部门"`
-	CountryCode     string `description:"区号,86、852、886等"`
-}
-
-func CheckUserMobileIsRegister(userId int, mobile string) (count int, err error) {
-	sql := `SELECT COUNT(1) AS count FROM wx_user AS a
-          INNER JOIN company AS b ON a.company_id = b.company_id
-          WHERE a.mobile = ? AND a.user_id<> ? `
-	o := orm.NewOrm()
-	err = o.Raw(sql, mobile, userId).QueryRow(&count)
-	return
-}
-
-func CheckUserEmailIsRegister(userId int, email string) (count int, err error) {
-	sql := `SELECT COUNT(1) AS count FROM wx_user AS a
-          INNER JOIN company AS b ON a.company_id = b.company_id
-          WHERE a.email = ? AND a.user_id<> ? `
-	o := orm.NewOrm()
-	err = o.Raw(sql, email, userId).QueryRow(&count)
-	return
-}
-
-// 移动潜在客户名下的联系人
-func MovePotentialUser(userId, companyId int, realName, mobile, email, remark string) (err error) {
-	if realName != "" {
-		sql := ` UPDATE wx_user
-			SET
-			  company_id = ?,
-			  real_name = ?,
-			  mobile = ?,
-			  email = ?,
-			  remark = ?,
-			  last_updated_time = NOW(),
-			  is_note = 1
-			WHERE user_id = ? `
-		_, err = orm.NewOrm().Raw(sql, companyId, realName, mobile, email, remark, userId).Exec()
-	} else {
-		sql := ` UPDATE wx_user
-			SET
-			  company_id = ?,
-			  mobile = ?,
-			  email = ?,
-			  remark = ?,
-			  last_updated_time = NOW(),
-			  is_note = 1
-			WHERE user_id = ? `
-		_, err = orm.NewOrm().Raw(sql, companyId, mobile, email, remark, userId).Exec()
-	}
-	return
-}
-
-// 移动联系人
-func MoveUser(userId, companyId int) (err error) {
-	sql := ` UPDATE wx_user
-			SET
-			  company_id = ?,
-			  last_updated_time = NOW(),
-			  is_note = 1
-			WHERE user_id = ? `
-	_, err = orm.NewOrm().Raw(sql, companyId, userId).Exec()
-	return
-}
-
-type ReportViewRecordTotal struct {
-	ViewTotal    int
-	LastViewTime time.Time
-}
-
-func GetReportViewMaxTime(uid int) (item *ReportViewRecordTotal, err error) {
-	o := orm.NewOrmUsingDB("rddp")
-	rddpSql := "SELECT MAX(create_time) AS last_view_time,COUNT(1) AS view_total FROM report_view_record WHERE user_id=? "
-	err = o.Raw(rddpSql, uid).QueryRow(&item)
-	return
-}
-
-// 根据用户id字符串获取用户的浏览数
-func GetReportViewMaxTimeByUserIds(userIds string) (items []*ReportViewRecord, err error) {
-	o := orm.NewOrmUsingDB("rddp")
-	rddpSql := `SELECT user_id,MAX(create_time) AS last_view_time,COUNT(1) AS view_total FROM report_view_record WHERE user_id in (` + userIds + `) group by user_id`
-	_, err = o.Raw(rddpSql).QueryRows(&items)
-	return
-}
-
-// 根据用户手机号字符串获取用户的浏览数
-type ReportViewMobileRecord struct {
-	Mobile       string
-	ViewTotal    int
-	LastViewTime time.Time
-}
-
-func GetReportViewMaxTimeByMobiles(mobiles string) (items []*ReportViewMobileRecord, err error) {
-	o := orm.NewOrmUsingDB("rddp")
-	rddpSql := `SELECT mobile,MAX(create_time) AS last_view_time,COUNT(1) AS view_total FROM report_view_record WHERE mobile in (` + mobiles + `) group by mobile`
-	_, err = o.Raw(rddpSql).QueryRows(&items)
-	return
-}
-
-// 根据用户邮箱字符串获取用户的浏览数
-type ReportViewEmailRecord struct {
-	Email        string
-	ViewTotal    int
-	LastViewTime time.Time
-}
-
-func GetReportViewMaxTimeByEmails(emails string) (items []*ReportViewEmailRecord, err error) {
-	o := orm.NewOrmUsingDB("rddp")
-	rddpSql := `SELECT email,MAX(create_time) AS last_view_time,COUNT(1) AS view_total FROM report_view_record WHERE email in (` + emails + `) group by email`
-	_, err = o.Raw(rddpSql).QueryRows(&items)
-	return
-}
-
-func GetPotentialUserListExport(condition string, pars []interface{}) (items []*PotentialUserItem, err error) {
-	o := orm.NewOrm()
-	sql := `SELECT DISTINCT a.*,b.company_name,
-			IF(b.type IN (1,2),1,0) AS is_fee_customer,
-            (SELECT count(1) FROM user_view_history AS uvh WHERE uvh.user_id=a.user_id GROUP BY a.user_id) AS view_total,
-            (SELECT max(uvh.created_time) FROM user_view_history AS uvh WHERE uvh.user_id=a.user_id GROUP BY a.user_id) AS last_view_time
-			FROM wx_user AS a
-			LEFT JOIN company AS b ON a.company_id = b.company_id
-			INNER JOIN user_record AS c ON a.user_id=c.user_id
-			WHERE b.enabled = 1 AND b.company_id = 1 
-			AND (a.mobile IS NOT NULL || a.email IS NOT NULL) 
-            AND (a.mobile<>'' OR a.email<>'') 
-            AND c.create_platform<>4 `
-	if condition != "" {
-		sql += condition
-	}
-	sql += `ORDER BY  a.last_updated_time DESC `
-	_, err = o.Raw(sql, pars).QueryRows(&items)
-	return
-}
-
-type WxUserDetail struct {
-	UserId          int64  `orm:"column(user_id);pk"`
-	CountryCode     string `description:"区号,86、852、886等"`
-	Mobile          string
-	Email           string
-	CompanyId       int
-	RealName        string `description:"姓名"`
-	CreatedTime     time.Time
-	MobileTwo       string `description:"备用手机号"`
-	BusinessCardUrl string `description:"名片"`
-	IsMaker         int    `description:"是否决策人,1:是,0:否"`
-	Position        string `description:"职位"`
-	Sex             int    `description:"普通用户性别,1为男性,2为女性"`
-	CompanyName     string `description:"公司名称"`
-	DepartmentName  string `description:"联系人部门"`
-	SellerRealName  string `description:"销售"`
-}
-
-// GetWxUserListByUserIds 根据用户ID集合获取用户
-func GetWxUserListByUserIds(userIds string) (list []*WxUser, err error) {
-	o := orm.NewOrm()
-	sql := ` SELECT * FROM wx_user WHERE user_id IN (` + userIds + `) `
-	_, err = o.Raw(sql).QueryRows(&list)
-
-	return
-}
-
 // GetWxUserByCompanyIdAndMobile 根据客户ID及手机号获取用户
 func GetWxUserByCompanyIdAndMobile(companyId int, mobile string) (item *WxUser, err error) {
 	o := orm.NewOrm()
@@ -398,24 +128,6 @@ func DeleteWxUserAndRecordByUserId(userId int) (err error) {
 	return
 }
 
-// 获取这个公司下面所有用户的手机号
-func GetCompanyUserMobilesByCompanyId(companyId int) (mobiles string, err error) {
-	o := orm.NewOrm()
-	sql := ` SELECT	GROUP_CONCAT( DISTINCT a.mobile SEPARATOR ',' ) AS mobiles	FROM
-			wx_user AS a WHERE company_id = ? AND mobile != '' `
-	err = o.Raw(sql, companyId).QueryRow(&mobiles)
-	return
-}
-
-// 获取这个公司下面所有用户的邮箱号
-func GetCompanyUserEmailsByCompanyId(companyId int) (emails string, err error) {
-	o := orm.NewOrm()
-	sql := ` SELECT	GROUP_CONCAT( DISTINCT a.email SEPARATOR ',' ) AS emails	FROM
-			wx_user AS a WHERE company_id = ? AND email != '' `
-	err = o.Raw(sql, companyId).QueryRow(&emails)
-	return
-}
-
 // 获取这个公司下面所有用户的手机号
 func SetUserSubscribe(openId string) (err error) {
 	o := orm.NewOrm()
@@ -451,66 +163,3 @@ type WxUserItem struct {
 	IsMaker             int       `description:"是否是决策人"`
 	Source              int
 }
-
-// GetWxUserListByUserIds 根据用户ID集合获取用户有公司名称
-func GetWxUserListByUserIdsHaveCompany(userIds string) (list []*WxUserItem, err error) {
-	o := orm.NewOrm()
-	sql := ` SELECT u.*, c.company_name FROM wx_user AS u
-			INNER JOIN company AS c ON c.company_id = u.company_id 
-			WHERE user_id IN (` + userIds + `) `
-	_, err = o.Raw(sql).QueryRows(&list)
-	return
-}
-
-// GetWxUserByAdminId 通过后台用户ID及微信平台获取对应的微信用户
-func GetWxUserByAdminId(platform, adminId int) (item *WxUser, err error) {
-	o := orm.NewOrm()
-	sql := `SELECT
-				wu.user_id
-			FROM
-				wx_user AS wu
-			JOIN user_record AS ur ON wu.user_id = ur.user_id AND ur.create_platform = ?
-			JOIN admin AS ad ON wu.mobile = ad.mobile
-			WHERE
-				ad.admin_id = ?`
-	err = o.Raw(sql, platform, adminId).QueryRow(&item)
-	return
-}
-
-// GetWxUserByOutboundMobiles 根据用户手机号获取用户详情
-func GetWxUserByOutboundMobiles(mobiles []string) (items []*WxUser, err error) {
-	lenmobiles := len(mobiles)
-	if lenmobiles == 0 {
-		return
-	}
-	sql := `SELECT* FROM wx_user  WHERE outbound_mobile in (` + utils.GetOrmInReplace(lenmobiles) + `)  `
-	o := orm.NewOrm()
-	_, err = o.Raw(sql, mobiles).QueryRows(&items)
-	return
-}
-
-// GetWxUserByUserIds 根据用户ID获取用户详情
-func GetWxUserByUserIds(userIds []int) (items []*WxUser, err error) {
-	lenuserIds := len(userIds)
-	if lenuserIds == 0 {
-		return
-	}
-	sql := `SELECT* FROM wx_user  WHERE user_id in (` + utils.GetOrmInReplace(lenuserIds) + `)  `
-	o := orm.NewOrm()
-	_, err = o.Raw(sql, userIds).QueryRows(&items)
-	return
-}
-
-// GetWxUserListByUserMobileHaveCompany 根据用户手机号集合获取用户有公司名称
-func GetWxUserListByUserMobileHaveCompany(mobiles []string) (list []*WxUserItem, err error) {
-	lenmobiles := len(mobiles)
-	if lenmobiles == 0 {
-		return
-	}
-	o := orm.NewOrm()
-	sql := ` SELECT u.*, c.company_name FROM wx_user AS u
-			INNER JOIN company AS c ON c.company_id = u.company_id 
-			WHERE mobile in (` + utils.GetOrmInReplace(lenmobiles) + `)  `
-	_, err = o.Raw(sql, mobiles).QueryRows(&list)
-	return
-}

+ 27 - 0
routers/commentsRouter.go

@@ -5632,6 +5632,24 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hz_eta_api/controllers:SysAdminController"] = append(beego.GlobalControllerRouter["hongze/hz_eta_api/controllers:SysAdminController"],
+        beego.ControllerComments{
+            Method: "Move",
+            Router: `/sysuser/move`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hz_eta_api/controllers:SysAdminController"] = append(beego.GlobalControllerRouter["hongze/hz_eta_api/controllers:SysAdminController"],
+        beego.ControllerComments{
+            Method: "ResetPass",
+            Router: `/sysuser/reset_pass`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hz_eta_api/controllers:SysDepartmentController"] = append(beego.GlobalControllerRouter["hongze/hz_eta_api/controllers:SysDepartmentController"],
         beego.ControllerComments{
             Method: "Add",
@@ -5695,6 +5713,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hz_eta_api/controllers:SysGroupController"] = append(beego.GlobalControllerRouter["hongze/hz_eta_api/controllers:SysGroupController"],
+        beego.ControllerComments{
+            Method: "SetSort",
+            Router: `/group/set_sort`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hz_eta_api/controllers:SysRoleAdminController"] = append(beego.GlobalControllerRouter["hongze/hz_eta_api/controllers:SysRoleAdminController"],
         beego.ControllerComments{
             Method: "AddAdmin",

+ 0 - 277
services/company.go

@@ -1,13 +1,7 @@
 package services
 
 import (
-	"encoding/json"
-	"fmt"
-	"hongze/hz_eta_api/models"
-	"hongze/hz_eta_api/models/company"
-	"hongze/hz_eta_api/services/alarm_msg"
 	"hongze/hz_eta_api/utils"
-	"time"
 )
 
 func GetProductId(roleTypeCode string) (productId int) {
@@ -27,274 +21,3 @@ func GetProductId(roleTypeCode string) (productId int) {
 	}
 	return
 }
-
-// GetFiccLastUserViewHistoryByCompanyIds 根据客户id集合map获取ficc最后一次阅读时间
-func GetFiccLastUserViewHistoryByCompanyIds(companyIdStr string) (companyViewTime map[int]time.Time, err error) {
-	//user_view_record mobile
-	companyViewTime = make(map[int]time.Time)
-	userViewList, err := models.GetLastUserViewHistoryByCompanyIdsMobile(companyIdStr)
-	if err != nil {
-		return
-	}
-	for _, userView := range userViewList {
-		companyViewTime[userView.CompanyId] = userView.ViewTime
-	}
-
-	//user_view_record email
-	userViewList, err = models.GetLastUserViewHistoryByCompanyIdsEmail(companyIdStr)
-	if err != nil {
-		return
-	}
-	checkLastTime(companyViewTime, userViewList)
-
-	//AdvisoryArticleViewRecord mobile
-	userViewList, err = models.GetLastAdvisoryArticleViewRecordByCompanyIdsMobile(companyIdStr)
-	if err != nil {
-		return
-	}
-	checkLastTime(companyViewTime, userViewList)
-
-	//AdvisoryArticleViewRecord email
-	userViewList, err = models.GetLastAdvisoryArticleViewRecordByCompanyIdsEmail(companyIdStr)
-	if err != nil {
-		return
-	}
-	checkLastTime(companyViewTime, userViewList)
-
-	//ReportViewRecord mobile
-	userViewList, err = models.GetLastReportViewRecordByCompanyIdsMobile(companyIdStr)
-	if err != nil {
-		return
-	}
-	checkLastTime(companyViewTime, userViewList)
-
-	//ReportViewRecord email
-	userViewList, err = models.GetLastReportViewRecordByCompanyIdsEmail(companyIdStr)
-	if err != nil {
-		return
-	}
-	checkLastTime(companyViewTime, userViewList)
-
-	//UserViewStatistics mobile
-	userViewList, err = models.GetLastUserViewStatisticsByCompanyIdsMobile(companyIdStr)
-	if err != nil {
-		return
-	}
-	checkLastTime(companyViewTime, userViewList)
-
-	//UserViewStatistics email
-	userViewList, err = models.GetLastUserViewStatisticsByCompanyIdsEmail(companyIdStr)
-	if err != nil {
-		return
-	}
-	checkLastTime(companyViewTime, userViewList)
-
-	return
-}
-
-// GetRaiLastUserViewHistoryByCompanyIds 根据客户id集合map获取权益最后一次阅读时间
-func GetRaiLastUserViewHistoryByCompanyIds(companyIdStr string) (companyViewTime map[int]time.Time, err error) {
-	//CygxArticleViewRecord mobile
-	companyViewTime = make(map[int]time.Time)
-	userViewList, err := models.GetLastCygxArticleViewRecordByCompanyIdsMobile(companyIdStr)
-	if err != nil {
-		return
-	}
-	for _, userView := range userViewList {
-		companyViewTime[userView.CompanyId] = userView.ViewTime
-	}
-
-	//CygxArticleViewRecord email
-	userViewList, err = models.GetLastCygxArticleViewRecordByCompanyIdsEmail(companyIdStr)
-	if err != nil {
-		return
-	}
-	checkLastTime(companyViewTime, userViewList)
-	return
-}
-
-// checkLastTime 检测最后的时间并重新赋值
-func checkLastTime(companyViewTime map[int]time.Time, userViewList []*models.CompanyLastViewSlice) {
-	for _, userView := range userViewList {
-		if viewTime, ok := companyViewTime[userView.CompanyId]; ok {
-			if userView.ViewTime.After(viewTime) { //如果当前时间晚于 map中的时间,那么重新赋值
-				companyViewTime[userView.CompanyId] = userView.ViewTime
-			}
-		} else { //如果没有数据,那么直接赋值
-			companyViewTime[userView.CompanyId] = userView.ViewTime
-		}
-	}
-	return
-}
-
-// GetFiccCountUserViewHistoryByCompanyIds 根据客户id集合map获取ficc的阅读次数
-func GetFiccCountUserViewHistoryByCompanyIds(companyIdStr string) (companyViewTotal map[int]int, err error) {
-	//user_view_record mobile
-	companyViewTotal = make(map[int]int)
-	userViewList, err := models.GetCountUserViewHistoryByCompanyIdsMobile(companyIdStr)
-	if err != nil {
-		return
-	}
-	for _, userView := range userViewList {
-		companyViewTotal[userView.CompanyId] = userView.ViewTotal
-	}
-	userViewList, err = models.GetCountUserViewHistoryByCompanyIdsEmail(companyIdStr)
-	if err != nil {
-		return
-	}
-	checkCount(companyViewTotal, userViewList)
-
-	//AdvisoryArticleViewRecord mobile
-	userViewList, err = models.GetCountAdvisoryArticleViewRecordByCompanyIdsMobile(companyIdStr)
-	if err != nil {
-		return
-	}
-	checkCount(companyViewTotal, userViewList)
-
-	//AdvisoryArticleViewRecord email
-	userViewList, err = models.GetCountAdvisoryArticleViewRecordByCompanyIdsEmail(companyIdStr)
-	if err != nil {
-		return
-	}
-	checkCount(companyViewTotal, userViewList)
-
-	//ReportViewRecord mobile
-	userViewList, err = models.GetCountReportViewRecordByCompanyIdsMobile(companyIdStr)
-	if err != nil {
-		return
-	}
-	checkCount(companyViewTotal, userViewList)
-
-	//ReportViewRecord email
-	userViewList, err = models.GetCountReportViewRecordByCompanyIdsEmail(companyIdStr)
-	if err != nil {
-		return
-	}
-	checkCount(companyViewTotal, userViewList)
-
-	//UserViewStatistics mobile
-	userViewList, err = models.GetUserViewStatisticsByCompanyIdsMobile(companyIdStr)
-	if err != nil {
-		return
-	}
-	checkCount(companyViewTotal, userViewList)
-
-	//UserViewStatistics email
-	userViewList, err = models.GetUserViewStatisticsByCompanyIdsEmail(companyIdStr)
-	if err != nil {
-		return
-	}
-	checkCount(companyViewTotal, userViewList)
-	return
-}
-
-// GetRaiCountUserViewHistoryByCompanyIds 根据客户id集合map获取权益的阅读次数
-func GetRaiCountUserViewHistoryByCompanyIds(companyIdStr string) (companyViewTotal map[int]int, err error) {
-	//CygxArticleViewRecord mobile
-	companyViewTotal = make(map[int]int)
-	userViewList, err := models.GetCountCygxArticleViewRecordByCompanyIdsMobile(companyIdStr)
-	if err != nil {
-		return
-	}
-	for _, userView := range userViewList {
-		companyViewTotal[userView.CompanyId] = userView.ViewTotal
-	}
-
-	//CygxArticleViewRecord email
-	userViewList, err = models.GetCountCygxArticleViewRecordByCompanyIdsEmail(companyIdStr)
-	if err != nil {
-		return
-	}
-	checkCount(companyViewTotal, userViewList)
-	return
-}
-
-func checkCount(companyViewTotal map[int]int, userViewList []*models.CompanyViewTotalSlice) {
-	for _, userView := range userViewList {
-		if viewTotal, ok := companyViewTotal[userView.CompanyId]; ok {
-			companyViewTotal[userView.CompanyId] = viewTotal + userView.ViewTotal
-		} else { //如果没有数据,那么直接赋值
-			companyViewTotal[userView.CompanyId] = userView.ViewTotal
-		}
-	}
-	return
-}
-
-// ModifyCompanyProductLastViewData 修改客户产品的总共阅读次数以及最近阅读时间
-func ModifyCompanyProductLastViewData(companyIdList []int) (err error) {
-	defer func() {
-		if err != nil {
-			go alarm_msg.SendAlarmMsg("修改客户产品的总共阅读次数以及最近阅读时间失败,"+fmt.Sprint("companyIdList:", companyIdList, ";err:", err), 3)
-			//go utils.SendEmail("修改客户产品的总共阅读次数以及最近阅读时间失败", fmt.Sprint("companyIdList:", companyIdList, ";err:", err), utils.EmailSendToUsers)
-		}
-	}()
-	companyIdStr := ``
-	for _, companyId := range companyIdList {
-		companyIdStr += fmt.Sprint(companyId, ",")
-	}
-	companyIdStr = companyIdStr[:len(companyIdStr)-1]
-
-	companyFiccViewTotalMap, err := GetFiccCountUserViewHistoryByCompanyIds(companyIdStr)
-	if err != nil {
-		return
-	}
-
-	companyFiccLastViewMap, err := GetFiccLastUserViewHistoryByCompanyIds(companyIdStr)
-	if err != nil {
-		return
-	}
-
-	companyRaiViewTotalMap, err := GetRaiCountUserViewHistoryByCompanyIds(companyIdStr)
-	if err != nil {
-		return
-	}
-
-	companyRaiLastViewMap, err := GetRaiLastUserViewHistoryByCompanyIds(companyIdStr)
-	if err != nil {
-		return
-	}
-
-	for _, companyId := range companyIdList {
-		//ficc
-		var companyFiccViewTotal int
-		var companyFiccLastView time.Time
-		var companyFiccLastViewStr string
-		companyFiccViewTotal, _ = companyFiccViewTotalMap[companyId]
-		companyFiccLastView, _ = companyFiccLastViewMap[companyId]
-
-		if companyFiccLastView.IsZero() {
-			companyFiccLastViewStr = "0000-00-00 00:00:00"
-		} else {
-			companyFiccLastViewStr = companyFiccLastView.Format(utils.FormatDateTime)
-		}
-		company.ModifyCompanyProductLastViewData(companyId, 1, companyFiccViewTotal, companyFiccLastViewStr)
-
-		//权益
-		var companyRaiViewTotal int
-		var companyRaiLastView time.Time
-		var companyRaiLastViewStr string
-		companyRaiViewTotal, _ = companyRaiViewTotalMap[companyId]
-		companyRaiLastView, _ = companyRaiLastViewMap[companyId]
-		if companyRaiLastView.IsZero() {
-			companyRaiLastViewStr = "0000-00-00 00:00:00"
-		} else {
-			companyRaiLastViewStr = companyRaiLastView.Format(utils.FormatDateTime)
-		}
-
-		company.ModifyCompanyProductLastViewData(companyId, 2, companyRaiViewTotal, companyRaiLastViewStr)
-	}
-
-	return
-}
-
-// AddWxUserOpLog 记录新增用户的日志
-func AddWxUserOpLog(wxUserOpLog company.WxUserOpLog) {
-	userSellerRelationList, err := models.GetUserSellerRelationList(wxUserOpLog.UserId)
-	if err != nil {
-		return
-	}
-
-	userSellerRelationInfo, _ := json.Marshal(userSellerRelationList)
-	wxUserOpLog.UserSellerInfo = string(userSellerRelationInfo)
-	company.AddWxUserOpLog(&wxUserOpLog)
-}

+ 0 - 3
services/user.go

@@ -55,9 +55,6 @@ func DeleteHzUserByMobile(mobile string) (err error) {
 		// 删除所有的标识,并真正删除数据
 		_ = models.DeleteUserSellerRelationByProductId(userId, 1)
 		_ = models.DeleteUserSellerRelationByProductId(userId, 2)
-
-		// 更新客户最近阅读次数以及最近阅读时间
-		go ModifyCompanyProductLastViewData([]int{userInfo.CompanyId})
 	}
 
 	return nil

برخی فایل ها در این مقایسه diff نمایش داده نمی شوند زیرا تعداد فایل ها بسیار زیاد است