Browse Source

no message

xingzai 1 year ago
parent
commit
889970d7f4
4 changed files with 72 additions and 8 deletions
  1. 12 8
      controllers/report.go
  2. 1 0
      models/db.go
  3. 28 0
      models/industry_fllow_log.go
  4. 31 0
      services/industry_fllow.go

+ 12 - 8
controllers/report.go

@@ -651,15 +651,17 @@ func (this *ReportController) IndustrialFllow() {
 		return
 	}
 	resp := new(models.CygxIndustryFllowResp)
+	item := new(models.CygxIndustryFllow)
+	item.IndustrialManagementId = industrialManagementId
+	item.UserId = uid
+	item.Email = user.Email
+	item.Mobile = user.Mobile
+	item.RealName = user.RealName
+	item.Source = utils.REGISTER_PLATFORM
+	item.CompanyId = user.CompanyId
+	item.CompanyName = user.CompanyName
+
 	if count == 0 {
-		item := new(models.CygxIndustryFllow)
-		item.IndustrialManagementId = industrialManagementId
-		item.UserId = uid
-		item.Email = user.Email
-		item.Mobile = user.Mobile
-		item.RealName = user.RealName
-		item.CompanyId = user.CompanyId
-		item.CompanyName = user.CompanyName
 		item.Type = 1
 		item.CreateTime = time.Now()
 		item.ModifyTime = time.Now()
@@ -672,6 +674,7 @@ func (this *ReportController) IndustrialFllow() {
 		resp.Status = 1
 		br.Msg = "关注成功"
 	} else {
+		item.Type = 2
 		err = models.RemoveCygxIndustryFllow(uid, industrialManagementId)
 		if err != nil {
 			br.Msg = "操作失败"
@@ -684,6 +687,7 @@ func (this *ReportController) IndustrialFllow() {
 	//处理是否关注全部赛道字段
 	go services.IndustryFllowWithTrack(industrialManagementId, count, uid)
 	go services.IndustryFllowUserLabelLogAdd(industrialManagementId, count, uid) //处理用户标签
+	go services.AddCygxIndustryFllowLog(item)                                    //添加操作日志记录
 	br.Ret = 200
 	br.Success = true
 	br.Data = resp

+ 1 - 0
models/db.go

@@ -82,6 +82,7 @@ func init() {
 		new(CygxArticleApplyAppointmentExpert),
 		new(CygxBannerYxSurvey),
 		new(CygxReportSelectionLogApply),
+		new(CygxIndustryFllowLog),
 	)
 	// 记录ORM查询日志
 	orm.Debug = true

+ 28 - 0
models/industry_fllow_log.go

@@ -0,0 +1,28 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxIndustryFllowLog struct {
+	Id                     int       `orm:"column(id);pk"`
+	IndustrialManagementId int       `description:"产业D"`
+	UserId                 int       `description:"用户ID"`
+	Mobile                 string    `description:"手机号"`
+	Email                  string    `description:"邮箱"`
+	CompanyId              int       `description:"公司id"`
+	CompanyName            string    `description:"公司名称"`
+	Type                   int       `description:"操作方式,1报名,2取消报名"`
+	CreateTime             time.Time `description:"创建时间"`
+	ModifyTime             time.Time `description:"更新时间"`
+	RealName               string    `description:"用户实际名称"`
+	Source                 int       `description:"来源1查研观向,2查研观向小助手,3勾选全部赛道的用户进行自动关注"`
+}
+
+// 添加
+func AddCygxIndustryFllowLog(item *CygxIndustryFllowLog) (lastId int64, err error) {
+	o := orm.NewOrm()
+	lastId, err = o.Insert(item)
+	return
+}

+ 31 - 0
services/industry_fllow.go

@@ -0,0 +1,31 @@
+package services
+
+import (
+	"fmt"
+	"hongze/hongze_clpt/models"
+	"hongze/hongze_clpt/utils"
+	"time"
+)
+
+// 添加用户关注,取消关注产业日志记录
+func AddCygxIndustryFllowLog(item *models.CygxIndustryFllow) (err error) {
+	defer func() {
+		if err != nil {
+			go utils.SendAlarmMsg("添加用户关注,取消关注产业日志记录失败"+err.Error()+fmt.Sprint(item), 2)
+		}
+	}()
+	itemlog := new(models.CygxIndustryFllowLog)
+	itemlog.IndustrialManagementId = item.IndustrialManagementId
+	itemlog.UserId = item.UserId
+	itemlog.Email = item.Email
+	itemlog.Mobile = item.Mobile
+	itemlog.RealName = item.RealName
+	itemlog.CompanyId = item.CompanyId
+	itemlog.CompanyName = item.CompanyName
+	itemlog.Type = item.Type
+	itemlog.Source = utils.REGISTER_PLATFORM
+	itemlog.CreateTime = time.Now()
+	itemlog.ModifyTime = time.Now()
+	_, err = models.AddCygxIndustryFllowLog(itemlog)
+	return err
+}