123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- package services
- import (
- "errors"
- "fmt"
- "hongze/hongze_clpt/models"
- "hongze/hongze_clpt/utils"
- "strconv"
- "strings"
- "time"
- )
- // 添加晨会点评点击记录
- func AddCygxMorningMeetingReviewChapterHistory(user *models.WxUserItem, articleId int, sourcePage string) (err error) {
- defer func() {
- if err != nil {
- go utils.SendAlarmMsg(fmt.Sprint("添加晨会点评点击记录失败 ,AddCygxMorningMeetingReviewChapterHistory err"+err.Error(), "id:", articleId, "sourcePage:", sourcePage, "userid:", user.UserId), 2)
- }
- }()
- detail, e := models.GetCygxMorningMeetingReviewChapterDetail(articleId)
- if e != nil {
- err = errors.New("GetCygxMorningMeetingReviewChapterDetail, Err: " + e.Error())
- return
- }
- historyRecord := new(models.CygxMorningMeetingReviewChapterHistory)
- historyRecord.UserId = user.UserId
- historyRecord.ArticleId = articleId
- historyRecord.SourcePage = sourcePage
- historyRecord.CreateTime = time.Now()
- historyRecord.Mobile = user.Mobile
- historyRecord.Email = user.Email
- historyRecord.CompanyId = user.CompanyId
- historyRecord.CompanyName = user.CompanyName
- historyRecord.MeetingId = int(detail.MeetingId)
- historyRecord.RegisterPlatform = utils.REGISTER_PLATFORM
- sellerItem, e := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
- if e != nil && e.Error() != utils.ErrNoRow() {
- err = errors.New("GetSellerByCompanyIdCheckFicc, Err: " + e.Error())
- return
- }
- historyRecord.RealName = user.RealName
- if sellerItem != nil {
- historyRecord.SellerName = sellerItem.RealName
- }
- _, e = models.AddCygxMorningMeetingReviewChapterHistory(historyRecord)
- if e != nil {
- err = errors.New("AddCygxMorningMeetingReviewChapterHistorymodels, Err: " + e.Error())
- return
- }
- return
- }
- // 通过晨会精华子ID,获取出参列表详情
- func GetCygxMorningMeetingReviewChapterListByIds(meetingreviewchaptIds []int) (items []*models.CygxMorningMeetingGatherDetailListResp, err error) {
- lenArr := len(meetingreviewchaptIds)
- if lenArr == 0 {
- return
- }
- defer func() {
- if err != nil {
- go utils.SendAlarmMsg(fmt.Sprint("通过晨会精华子ID,获取出参列表详情失败 ,GetCygxMorningMeetingReviewChapterListByIds err"+err.Error(), "meetingreviewchaptIds:", meetingreviewchaptIds), 2)
- }
- }()
- var condition string
- var pars []interface{}
- pars = make([]interface{}, 0)
- condition = ` AND c.id IN (` + utils.GetOrmInReplace(lenArr) + `)`
- pars = append(pars, meetingreviewchaptIds)
- //查询晨会
- listrMeet, e := models.GetCygxMorningMeetingReviewChapterList(condition, pars)
- if e != nil {
- err = errors.New("GetCygxMorningMeetingReviewChapterList, Err: " + e.Error())
- return
- }
- //获取晨会相关的标的
- var subjectIds []string
- for _, v := range listrMeet {
- if v.IndustrialSubjectIds != "" {
- slice := strings.Split(v.IndustrialSubjectIds, ",")
- for _, vS := range slice {
- subjectIds = append(subjectIds, vS)
- }
- }
- }
- lensubjectIds := len(subjectIds)
- if lensubjectIds > 0 {
- //获取标的信息
- pars = make([]interface{}, 0)
- condition = ` AND industrial_subject_id IN (` + utils.GetOrmInReplace(lensubjectIds) + `)`
- pars = append(pars, subjectIds)
- listsubject, e := models.GetCygxIndustrialSubjectListCondition(condition, pars)
- if e != nil {
- err = errors.New("GetCygxIndustrialSubjectListCondition, Err: " + e.Error())
- return
- }
- var meetSubjectItems = make(map[string]*models.CygxIndustrialSubject)
- for _, v := range listsubject {
- meetSubjectItems[strconv.Itoa(v.IndustrialSubjectId)] = v
- }
- //建立标的与晨会的映射关系
- for _, v := range listrMeet {
- if v.IndustrialSubjectIds != "" {
- slice := strings.Split(v.IndustrialSubjectIds, ",")
- for _, vS := range slice {
- if meetSubjectItems[vS] != nil {
- v.ListSubject = append(v.ListSubject, meetSubjectItems[vS])
- }
- }
- }
- }
- }
- items = listrMeet
- return
- }
|