|
@@ -1,26 +1,17 @@
|
|
|
package activity
|
|
|
|
|
|
import (
|
|
|
- "errors"
|
|
|
"gorm.io/gorm"
|
|
|
- "hongze/hongze_yb/global"
|
|
|
- "hongze/hongze_yb/models/tables/chart_permission"
|
|
|
"hongze/hongze_yb/models/tables/company_product"
|
|
|
- "hongze/hongze_yb/models/tables/research_report"
|
|
|
- "hongze/hongze_yb/models/tables/teleconference"
|
|
|
- "hongze/hongze_yb/models/tables/teleconference_video"
|
|
|
"hongze/hongze_yb/models/tables/yb_activity"
|
|
|
"hongze/hongze_yb/models/tables/yb_activity_permission"
|
|
|
"hongze/hongze_yb/models/tables/yb_activity_register"
|
|
|
"hongze/hongze_yb/models/tables/yb_activity_remind"
|
|
|
- "hongze/hongze_yb/models/tables/yb_activity_type"
|
|
|
"hongze/hongze_yb/models/tables/yb_activity_voice"
|
|
|
- "hongze/hongze_yb/models/tables/yb_speaker"
|
|
|
"hongze/hongze_yb/services/company"
|
|
|
"hongze/hongze_yb/services/user"
|
|
|
"hongze/hongze_yb/utils"
|
|
|
"log"
|
|
|
- "strconv"
|
|
|
"strings"
|
|
|
"time"
|
|
|
)
|
|
@@ -203,207 +194,5 @@ func GetUserAuthActivityIds(userInfo user.UserInfo) (acrivityIds []int, err erro
|
|
|
acrivityIds = append(acrivityIds, int(v.ActivityID))
|
|
|
}
|
|
|
|
|
|
- return
|
|
|
-}
|
|
|
-
|
|
|
-// SyncTeleconferenceOldData 同步旧数据
|
|
|
-func SyncTeleconferenceOldData() (countTotal, countSuccess int, err error) {
|
|
|
- // 查询所有前三个月的电话会
|
|
|
- condition := "enabled = 1"
|
|
|
- pars := make([]interface{}, 0)
|
|
|
- nowTime := time.Now()
|
|
|
- threeMonth := nowTime.AddDate(0, -3, 0).Format(utils.FormatDateTime)
|
|
|
- condition += " AND created_time >= ? AND created_time <= ?"
|
|
|
- pars = append(pars, threeMonth, nowTime)
|
|
|
- teleconferenceList, err := teleconference.GetTeleconferenceList(condition, pars)
|
|
|
- if err != nil {
|
|
|
- return
|
|
|
- }
|
|
|
- countTotal = len(teleconferenceList)
|
|
|
-
|
|
|
- // 取出电话会IDs和报告Ids
|
|
|
- var teleconferenceIds, reportIds, chartPermissionIds []int
|
|
|
- for i := 0; i < len(teleconferenceList); i++ {
|
|
|
- teleconferenceIds = append(teleconferenceIds, int(teleconferenceList[i].TeleconferenceID))
|
|
|
- reportIds = append(reportIds, int(teleconferenceList[i].ReferResearchReportID))
|
|
|
- chartPermissionIds = append(chartPermissionIds, teleconferenceList[i].ReportPermissionID)
|
|
|
- }
|
|
|
-
|
|
|
- // 报告名称map
|
|
|
- var reportIdNameMap = make(map[int]string, 0)
|
|
|
- reportList, err := research_report.GetListByResearchReportIds(reportIds)
|
|
|
- if err != nil {
|
|
|
- return
|
|
|
- }
|
|
|
- for i := 0; i < len(reportList); i++ {
|
|
|
- reportIdNameMap[int(reportList[i].ResearchReportID)] = reportList[i].ResearchReportName
|
|
|
- }
|
|
|
-
|
|
|
- // 活动类型map
|
|
|
- var typeNameIdMap = make(map[string]int, 0)
|
|
|
- var typeFirstMap = make(map[int]int, 0)
|
|
|
- var typeIdNameMap = make(map[int]string, 0)
|
|
|
- activityTypeList, err := yb_activity_type.GetTypeList()
|
|
|
- if err != nil {
|
|
|
- return
|
|
|
- }
|
|
|
- for _, activityType := range activityTypeList {
|
|
|
- typeNameIdMap[activityType.ActivityTypeName] = activityType.ActivityTypeID
|
|
|
- typeFirstMap[activityType.ActivityTypeID] = activityType.Pid
|
|
|
- typeIdNameMap[activityType.ActivityTypeID] = activityType.ActivityTypeName
|
|
|
- }
|
|
|
-
|
|
|
- // 主讲人map
|
|
|
- speakerList, err := yb_speaker.GetSpeakerList()
|
|
|
- if err != nil {
|
|
|
- return
|
|
|
- }
|
|
|
- var speakerNamePicMap = make(map[string]string, 0)
|
|
|
- for i := 0; i < len(speakerList); i++ {
|
|
|
- speakerNamePicMap[speakerList[i].SpeakerName] = speakerList[i].SpeakerHeadPic
|
|
|
- }
|
|
|
-
|
|
|
- // 音频列表
|
|
|
- voicesList, err := teleconference_video.GetListByTeleconferenceIds(teleconferenceIds)
|
|
|
- if err != nil {
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- // 图片权限map
|
|
|
- chartPermissionList, err := chart_permission.GetListByIds(chartPermissionIds)
|
|
|
- if err != nil {
|
|
|
- return
|
|
|
- }
|
|
|
- var chartPermissionIdNameMap = make(map[int]string, 0)
|
|
|
- for i := 0; i < len(chartPermissionList); i++ {
|
|
|
- chartPermissionIdNameMap[int(chartPermissionList[i].ChartPermissionID)] = chartPermissionList[i].PermissionName
|
|
|
- }
|
|
|
-
|
|
|
- // 开启事务
|
|
|
- tx := global.DEFAULT_MYSQL.Begin()
|
|
|
- defer func() {
|
|
|
- if err != nil {
|
|
|
- tx.Rollback()
|
|
|
- } else {
|
|
|
- tx.Commit()
|
|
|
- }
|
|
|
- }()
|
|
|
-
|
|
|
- // 遍历数据
|
|
|
- for _, item := range teleconferenceList {
|
|
|
-
|
|
|
- // 匹配报告名称和link
|
|
|
- reportId := int(item.ReferResearchReportID)
|
|
|
- linkUrl := `https://details.hzinsights.com/ficcReportDetail?research_report_id=`
|
|
|
- if global.CONFIG.Serve.RunMode == `debug` {
|
|
|
- linkUrl = `http://advisoryadmin.brilliantstart.cn/xcx_h5/ficcReportDetail?research_report_id=`
|
|
|
- }
|
|
|
- reportLink := linkUrl + strconv.Itoa(reportId)
|
|
|
- reportName := reportIdNameMap[reportId]
|
|
|
-
|
|
|
- // 匹配活动类型-中文匹配ID
|
|
|
- var firstActivityTypeId, activityTypeId int
|
|
|
- var firstActivityTypeName, activityTypeName string
|
|
|
- activityTypeId = typeNameIdMap[item.Type]
|
|
|
- if activityTypeId > 0 {
|
|
|
- // 类型匹配到了
|
|
|
- activityTypeName = typeIdNameMap[activityTypeId]
|
|
|
- firstActivityTypeId = typeFirstMap[activityTypeId]
|
|
|
- firstActivityTypeName = typeIdNameMap[firstActivityTypeId]
|
|
|
- }
|
|
|
-
|
|
|
- // 匹配主讲人头像
|
|
|
- speakerName := item.Speaker
|
|
|
- if speakerName == "" {
|
|
|
- continue
|
|
|
- } else if speakerName == "全体FICC研究员" || speakerName == "弘则FICC研究员" {
|
|
|
- speakerName = "FICC研究员"
|
|
|
- }
|
|
|
- speakerPic := "https://hzstatic.hzinsights.com/static/images/202112/20211210/wn6c3oYKTfT4NbTZgRGflRuIBZaa.png"
|
|
|
- for i := 0; i < len(speakerList); i++ {
|
|
|
- if strings.Contains(speakerName, speakerList[i].SpeakerName) {
|
|
|
- speakerName = speakerList[i].SpeakerName // 存在多个人的情况,则以新表数据为准
|
|
|
- speakerPic = speakerNamePicMap[speakerList[i].SpeakerName]
|
|
|
- break
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- backgroundPic := ""
|
|
|
- if firstActivityTypeId == 1 {
|
|
|
- // 电话会议
|
|
|
- backgroundPic = `https://hongze.oss-accelerate.aliyuncs.com/static/images/202112/20211214/nNSTxmH6lxlT0PAp7xcfJJTGX9Gu.png`
|
|
|
- } else {
|
|
|
- // 线下沙龙
|
|
|
- backgroundPic = `https://hongze.oss-accelerate.aliyuncs.com/static/images/202112/20211214/k77gDxvFvuAnYUhF6PU1FOVDHI8O.png`
|
|
|
- }
|
|
|
-
|
|
|
- // 新增活动数据
|
|
|
- activityInfo := &yb_activity.YbActivity{
|
|
|
- FirstActivityTypeID: firstActivityTypeId,
|
|
|
- FirstActivityTypeName: firstActivityTypeName,
|
|
|
- ActivityTypeID: activityTypeId,
|
|
|
- ActivityTypeName: activityTypeName,
|
|
|
- ActivityName: item.TeleconferenceTitle,
|
|
|
- StartTime: item.StartTime,
|
|
|
- EndTime: item.EndTime,
|
|
|
- Speaker: speakerName,
|
|
|
- SpeakerHeadPic: speakerPic,
|
|
|
- SpeakerBackgroundPic: backgroundPic,
|
|
|
- SingaporeTel: item.SingaporeTelephone,
|
|
|
- ParticipationCode: item.Password,
|
|
|
- MainlandTel: item.Telephone,
|
|
|
- HongKongTel: item.HkTelephone,
|
|
|
- ReportID: reportId,
|
|
|
- ReportLink: reportLink,
|
|
|
- ReportName: reportName,
|
|
|
- Remarks: item.Remark,
|
|
|
- PublishStatus: 1,
|
|
|
- IsSendWxMsg: 1,
|
|
|
- IsSendSalonWxMsg: 1,
|
|
|
- ModifyTime: nowTime,
|
|
|
- CreateTime: nowTime,
|
|
|
- }
|
|
|
-
|
|
|
- // 开启事务之后的操作要使用tx
|
|
|
- activityCreate := tx.Debug().Create(activityInfo)
|
|
|
- if activityCreate.Error != nil {
|
|
|
- err = errors.New("新增活动失败")
|
|
|
- return
|
|
|
- }
|
|
|
- activityId := activityInfo.ActivityID
|
|
|
-
|
|
|
- // 5.新增活动音频-音频列表
|
|
|
- for _, voice := range voicesList {
|
|
|
- if int(item.TeleconferenceID) == voice.TeleconferenceID {
|
|
|
- activityVoice := &yb_activity_voice.YbActivityVoice{
|
|
|
- ActivityID: uint32(activityId),
|
|
|
- VoiceURL: voice.VideoURL,
|
|
|
- VoiceName: voice.VideoName,
|
|
|
- VoicePlaySeconds: voice.VideoPlaySeconds,
|
|
|
- CreateTime: nowTime,
|
|
|
- }
|
|
|
- activityVoiceCreate := tx.Debug().Create(activityVoice)
|
|
|
- if activityVoiceCreate.Error != nil {
|
|
|
- err = errors.New("新增活动音频失败")
|
|
|
- return
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 6.新增活动关联权限-源数据权限仅一个
|
|
|
- activityPermission := &yb_activity_permission.YbActivityPermission{
|
|
|
- ActivityID: uint32(activityId),
|
|
|
- PermissionID: uint32(item.ReportPermissionID),
|
|
|
- PermissionName: chartPermissionIdNameMap[item.ReportPermissionID],
|
|
|
- CreateTime: nowTime,
|
|
|
- }
|
|
|
- activityPermissionCreate := tx.Debug().Create(activityPermission)
|
|
|
- if activityPermissionCreate.Error != nil {
|
|
|
- err = errors.New("新增活动权限失败")
|
|
|
- return
|
|
|
- }
|
|
|
- countSuccess += 1
|
|
|
- }
|
|
|
-
|
|
|
return
|
|
|
}
|