Browse Source

no message

zhangchuanxing 3 weeks ago
parent
commit
5694c93bec

+ 48 - 0
controllers/cygx/user_rai_label.go

@@ -269,6 +269,54 @@ func (this *UserRaiLabelController) Detail() {
 
 		item.Label = detail.Label
 		resp.Article = item
+
+	case 9:
+		item := new(cygx.WxUserRaiLabelActivityVivoResp)
+		activityInfo, err := cygx.GetAddActivityInfoById(sourceId)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取信息失败,GetAddActivityInfoById Err:" + err.Error()
+			return
+		}
+		var title string
+		totalVoice, err := cygx.GetCygxActivityVoiceCountByActivityId(sourceId)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取信息失败, GetCygxActivityVoiceCountByActivityId :" + err.Error()
+			return
+		}
+		if totalVoice > 0 {
+			voiceDetail, err := cygx.GetCygxActivityVoiceReqDetail(sourceId)
+			if err != nil {
+				br.Msg = "获取信息失败"
+				br.ErrMsg = "获取信息失败, GetCygxActivityVoiceReqDetail :" + err.Error()
+				return
+			}
+			title = voiceDetail.VoiceName
+		} else {
+			totalVideo, err := cygx.GetActivityVideoCountByActivityId(sourceId)
+			if err != nil {
+				br.Msg = "获取信息失败"
+				br.ErrMsg = "获取信息失败, GetActivityVideoCountByActivityId :" + err.Error()
+				return
+			}
+
+			if totalVideo > 0 {
+				videoDetail, err := cygx.GetCygxActivityVideoReqDetail(sourceId)
+				if err != nil {
+					br.Msg = "获取信息失败"
+					br.ErrMsg = "GetCygxActivityVideoReqDetail,Err:" + err.Error() + "activityId:" + strconv.Itoa(sourceId)
+					return
+				}
+				title = videoDetail.VideoName
+			}
+		}
+
+		item.Title = title
+		item.ActivityTime = activityInfo.ActivityTime
+		item.Label = detail.Label
+		item.CreateTime = detail.CreateTime.Format(utils.FormatDateTime)
+		resp.ActivityVivo = item
 	}
 
 	resp.SourceType = detail.SourceType

+ 1 - 2
models/cygx/activity_video.go

@@ -105,8 +105,7 @@ func GetActivityVideoCountByActivityId(activityId int) (count int, err error) {
 	o := orm.NewOrmUsingDB("hz_cygx")
 	sqlCount := ` SELECT
 				COUNT( 1 ) AS count 
-			FROM
-   				JOIN cygx_activity_video
+			FROM cygx_activity_video
 			WHERE activity_id = ? `
 	err = o.Raw(sqlCount, activityId).QueryRow(&count)
 	return

+ 8 - 0
models/cygx/activity_voice.go

@@ -67,6 +67,14 @@ func GetCygxActivityVoiceCount(condition string, pars []interface{}) (count int,
 	return
 }
 
+// 获取数量
+func GetCygxActivityVoiceCountByActivityId(activityId int) (count int, err error) {
+	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_activity_voice   WHERE activity_id= ?  `
+	o := orm.NewOrmUsingDB("hz_cygx")
+	err = o.Raw(sqlCount, activityId).QueryRow(&count)
+	return
+}
+
 // 列表
 func GetCygxActivityVoiceReqList(activityId int) (items []*CygxActivityVoiceReq, err error) {
 	o := orm.NewOrmUsingDB("hz_cygx")

+ 83 - 7
models/cygx/wx_user_rai_label.go

@@ -1,6 +1,7 @@
 package cygx
 
 import (
+	"fmt"
 	"github.com/beego/beego/v2/client/orm"
 	"hongze/hz_crm_api/utils"
 	"time"
@@ -24,6 +25,26 @@ type WxUserRaiLabel struct {
 	TableName       string    `description:"数据来源的表名"`
 }
 
+// 标签记录表,所有内容都不删除
+type WxUserRaiLabelLog struct {
+	RaiLabelId       int       `orm:"column(rai_label_id);pk"`
+	UserId           int       `description:"用户ID"`
+	RealName         string    `description:"用户实际名称"`
+	Mobile           string    `description:"手机号"`
+	Email            string    `description:"邮箱"`
+	CompanyId        int       `description:"公司id"`
+	CompanyName      string    `description:"公司名称"`
+	Label            string    `description:"标签内容"`
+	SourceId         int       `description:"来源ID"`
+	SourceType       int       `description:"来源1:搜索关键字标签、2:产业/个股标签(线下活动)、3:产业/个股标签(线下路演)、4:产业/个股标签(线上活动)、5:产业/个股标签(线上路演)、6:销售输入标签、7:产业/个股标签(报告)、8:报告类型标签"`
+	SysUserId        int       `description:"创建人id"`
+	SysUserRealName  string    `description:"创建人名称"`
+	CreateTime       time.Time `description:"创建时间"`
+	ModifyTime       time.Time `description:"更新时间"`
+	RegisterPlatform int       `description:"来源 1小程序,2:网页"`
+	TableName        string    `description:"数据来源的表名"`
+}
+
 type WxUserRaiLabelList struct {
 	List []*WxUserRaiLabelListResp
 }
@@ -45,9 +66,56 @@ type WxUserRaiLabelIdReq struct {
 }
 
 // 添加
+//func AddWxUserRaiLabel(item *WxUserRaiLabel) (err error) {
+//	o := orm.NewOrmUsingDB("hz_cygx")
+//	_, err = o.Insert(item)
+//	return
+//}
+
 func AddWxUserRaiLabel(item *WxUserRaiLabel) (err error) {
-	o := orm.NewOrmUsingDB("hz_cygx")
+	o, err := orm.NewOrmUsingDB("hz_cygx").Begin()
+	if err != nil {
+		return
+	}
+	defer func() {
+		fmt.Println(err)
+		if err == nil {
+			o.Commit()
+		} else {
+			o.Rollback()
+		}
+	}()
+
+	//删除原有数据
+	sql := ` DELETE FROM wx_user_rai_label WHERE user_id = ? AND label = ?  `
+	_, err = o.Raw(sql, item.UserId, item.Label).Exec()
+	if err != nil {
+		return
+	}
+
 	_, err = o.Insert(item)
+
+	if err != nil {
+		return
+	}
+
+	itemLog := new(WxUserRaiLabelLog)
+	itemLog.UserId = item.UserId
+	itemLog.RealName = item.RealName
+	itemLog.Mobile = item.Mobile
+	itemLog.Email = item.Email
+	itemLog.CompanyId = item.CompanyId
+	itemLog.CompanyName = item.CompanyName
+	itemLog.Label = item.Label
+	itemLog.SourceId = item.SourceId
+	itemLog.SourceType = item.SourceType
+	itemLog.SysUserId = item.SysUserId
+	itemLog.SysUserRealName = item.SysUserRealName
+	itemLog.CreateTime = item.CreateTime
+	itemLog.ModifyTime = item.ModifyTime
+	//itemLog.RegisterPlatform = item.RegisterPlatform
+	itemLog.TableName = item.TableName
+	_, err = o.Insert(itemLog)
 	return
 }
 
@@ -131,12 +199,13 @@ func GetWxUserRaiLabelDetailById(raiLabelId int) (item *WxUserRaiLabel, err erro
 }
 
 type WxUserRaiLabelDetailResp struct {
-	SourceType int `description:"来源1:搜索关键字标签、2:产业/个股标签(线下活动)、3:产业/个股标签(线下路演)、4:产业/个股标签(线上活动)、5:产业/个股标签(线上路演)、6:销售输入标签、7:产业/个股标签(报告)、8:报告类型标签"`
-	KeyWord    *WxUserRaiLabelKeyWordResp
-	Activity   *WxUserRaiLabelActivityResp
-	RoadShow   *WxUserRaiLabelRoadShowResp
-	Seller     *WxUserRaiLabelSellerResp
-	Article    *WxUserRaiLabelArticleResp
+	SourceType   int `description:"来源1:搜索关键字标签、2:产业/个股标签(线下活动)、3:产业/个股标签(线下路演)、4:产业/个股标签(线上活动)、5:产业/个股标签(线上路演)、6:销售输入标签、7:产业/个股标签(报告)、8:报告类型标签"`
+	KeyWord      *WxUserRaiLabelKeyWordResp
+	Activity     *WxUserRaiLabelActivityResp
+	RoadShow     *WxUserRaiLabelRoadShowResp
+	Seller       *WxUserRaiLabelSellerResp
+	Article      *WxUserRaiLabelArticleResp
+	ActivityVivo *WxUserRaiLabelActivityVivoResp
 }
 
 type WxUserRaiLabelKeyWordResp struct {
@@ -152,6 +221,13 @@ type WxUserRaiLabelActivityResp struct {
 	Label            string `description:"标签内容"`
 }
 
+type WxUserRaiLabelActivityVivoResp struct {
+	Title        string `description:"活动名称"`
+	ActivityTime string `description:"活动时间"`
+	Label        string `description:"标签内容"`
+	CreateTime   string `description:"查看时间"`
+}
+
 type WxUserRaiLabelRoadShowResp struct {
 	Theme          string `description:"会议主题"`
 	ResearcherName string `description:"研究员名称"`

+ 1 - 0
models/db.go

@@ -491,6 +491,7 @@ func initCygx() {
 		new(cygx.CygxReportSelectionThirdName),
 		new(cygx.CygxGushouTimeLine),
 		new(cygx.WxUserRaiLabel),
+		new(cygx.WxUserRaiLabelLog),
 	)
 }