浏览代码

Merge branch 'cygx_12.2' of http://8.136.199.33:3000/hongze/hongze_cygx into debug

xingzai 1 年之前
父节点
当前提交
8f6b20c4e5

+ 7 - 7
controllers/activity.go

@@ -413,12 +413,12 @@ func (this *ActivityCoAntroller) Detail() {
 			}
 
 			// 查研观向7.4-行业新标签
-			industryNewMap, e := services.GetIndustryNewLabelMap(industryIds)
-			if e != nil {
-				br.Msg = "获取信息失败"
-				br.ErrMsg = "获取产业新标签失败, Err: " + e.Error()
-				return
-			}
+			//industryNewMap, e := services.GetIndustryNewLabelMap(industryIds)
+			//if e != nil {
+			//	br.Msg = "获取信息失败"
+			//	br.ErrMsg = "获取产业新标签失败, Err: " + e.Error()
+			//	return
+			//}
 
 			//判断产业下是否有关联的报告,并处理是否跳转
 			industrialManagementId = strings.TrimRight(industrialManagementId, ",")
@@ -442,7 +442,7 @@ func (this *ActivityCoAntroller) Detail() {
 					if mapIndustrial[v.IndustrialManagementId] > 0 && !industrialList[k].IsResearch {
 						industrialList[k].IsJump = true
 					}
-					industrialList[k].IndustryNewLabel = industryNewMap[v.IndustrialManagementId]
+					//industrialList[k].IndustryNewLabel = industryNewMap[v.IndustrialManagementId]
 				}
 			}
 		}

+ 4 - 0
controllers/report.go

@@ -1900,6 +1900,8 @@ func (this *ReportController) ResearchDetail() {
 	//	historyRecord.SellerName = sellerItem.RealName
 	//}
 	//go models.AddCygxReportHistoryRecord(historyRecord)
+
+	go services.ResearchSummaryHistoryUserRmind(user, articleId) // 本周研究汇总用户阅读操作操作行为,模板消息推送
 	resp.List = listFirst
 	resp.Detail = detail
 	br.Ret = 200
@@ -2048,6 +2050,8 @@ func (this *ReportController) MinutesDetailV4() {
 	//	historyRecord.SellerName = sellerItem.RealName
 	//}
 	//go models.AddCygxReportHistoryRecord(historyRecord)
+
+	go services.MinutesSummaryHistoryUserRmind(user, articleId) // 上周纪要汇总用户阅读,给销售发消息提醒
 	resp.List = listFirst
 	resp.Detail = detail
 	br.Ret = 200

+ 9 - 0
controllers/tactics.go

@@ -112,7 +112,16 @@ func (this *TacticsController) List() {
 		}
 	}
 
+	articleMapPv := services.GetArticleHistoryByArticleId(articleIds)                       //文章Pv
+	articleCollectMap, _ := services.GetCygxArticleCollectMap(user.UserId)                  //用户收藏的文章
+	articleCollectNumMap, _ := services.GetCygxArticleCollectNumMapByArtcileIds(articleIds) //文章收藏的数量
+
 	for _, v := range list {
+		if v.Resource == 1 {
+			v.Pv = articleMapPv[v.ArticleId]
+			v.IsCollect = articleCollectMap[v.ArticleId]
+			v.CollectNum = articleCollectNumMap[v.ArticleId]
+		}
 		if v.Resource == 2 {
 			v.PublishDate = utils.TimeRemoveHms2(v.PublishDate)
 		}

+ 25 - 0
models/activity_signup_detail.go

@@ -1,6 +1,7 @@
 package models
 
 import (
+	"fmt"
 	"github.com/beego/beego/v2/client/orm"
 	"hongze/hongze_cygx/utils"
 	"time"
@@ -176,3 +177,27 @@ func UpdateActivitySignupDetailMultiByYiDong(items []*CygxActivitySignupDetail)
 	}
 	return
 }
+
+// UpdateActivitySignupDetailMultiByYiDong 易董批量修改用户报名信息且报名的人
+func UpdateActivitySignupDetailMultiMobileAndUserId(items []*CygxActivitySignupDetail) (err error) {
+	o := orm.NewOrm()
+	p, err := o.Raw(` UPDATE cygx_activity_signup_detail SET
+							user_id = ?
+							WHERE mobile = ? AND user_id = 0 `).Prepare()
+	if err != nil {
+		return
+	}
+	defer func() {
+		_ = p.Close() // 别忘记关闭 statement
+	}()
+	for _, v := range items {
+		fmt.Println(v.Mobile)
+		_, err = p.Exec(
+			v.UserId,
+			v.Mobile)
+		if err != nil {
+			return
+		}
+	}
+	return
+}

+ 8 - 0
models/cygx_morning_meeting_review_chapter.go

@@ -20,6 +20,14 @@ type CygxMorningMeetingReviewChapter struct {
 	Content              string    `json:"content"`             // 内容
 }
 
+// 通过ID获取详情
+func GetCygxMorningMeetingReviewChapterDetail(id int) (item *CygxMorningMeetingReviewChapter, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_morning_meeting_review_chapter  WHERE id =? `
+	err = o.Raw(sql, id).QueryRow(&item)
+	return
+}
+
 // 列表
 func GetCygxMorningMeetingReviewChapterList(condition string, pars []interface{}) (items []*CygxMorningMeetingGatherDetailListResp, err error) {
 	o := orm.NewOrm()

+ 1 - 0
models/morning_meeting_review_chapter_history.go

@@ -19,6 +19,7 @@ type CygxMorningMeetingReviewChapterHistory struct {
 	SourcePage       string    `description:"页面来源 微信、首页、展开"`
 	RegisterPlatform int       `description:"来源 1小程序,2:网页"`
 	ModifyTime       time.Time `description:"更新时间"`
+	MeetingId        int       `description:"晨会精华主表ID"`
 }
 
 type AddCygxMorningMeetingReviewChapterHistoryReq struct {

+ 67 - 0
services/activity_signup_detail.go

@@ -2,6 +2,7 @@ package services
 
 import (
 	"context"
+	"errors"
 	"fmt"
 	"hongze/hongze_cygx/models"
 	"hongze/hongze_cygx/utils"
@@ -253,6 +254,28 @@ func AddctivitySignupDetailByJmcjNew(itemsDetail []*models.CygxActivityAttendanc
 	var itemsAdd []*models.CygxActivitySignupDetail
 	var itemsUpdate []*models.CygxActivitySignupDetail
 
+	var mobiles []string
+	mobileMap := make(map[string]bool)
+	mobileUserMap := make(map[string]int)
+	for _, v := range itemsDetail {
+		if !mobileMap[v.Mobile] {
+			mobiles = append(mobiles, v.Mobile)
+		}
+		mobileMap[v.Mobile] = true
+	}
+	//mobiles = make([]string, 0)
+	//mobiles = append(mobiles, "13054631616")
+	//根据手机号获取这些用户的信息
+	listUser, e := models.GetWxUserByOutboundMobiles(mobiles)
+	if e != nil {
+		err = errors.New("GetWxUserOutboundMobiles, Err: " + e.Error())
+		return
+	}
+
+	for _, v := range listUser {
+		mobileUserMap[v.Mobile] = v.UserId
+	}
+
 	for _, v := range itemsDetail {
 		var item = new(models.CygxActivitySignupDetail)
 		item.ActivityId = v.ActivityId
@@ -279,6 +302,7 @@ func AddctivitySignupDetailByJmcjNew(itemsDetail []*models.CygxActivityAttendanc
 		item.UseridEntity = v.UseridEntity
 		item.ActivityTime = v.ActivityTime
 		item.CrmCompanyMapStatusId = v.CrmCompanyMapStatusId
+		item.UserId = mobileUserMap[v.Mobile]
 
 		if _, ok := mapsignUpDetai[fmt.Sprint("ActivityId", v.ActivityId, "Mobile", item.Mobile)]; !ok {
 			itemsAdd = append(itemsAdd, item)
@@ -308,3 +332,46 @@ func AddctivitySignupDetailByJmcjNew(itemsDetail []*models.CygxActivityAttendanc
 	}
 	return err
 }
+
+//func init() {
+//	var err error
+//	defer func() {
+//		if err != nil {
+//			fmt.Println(err)
+//		}
+//	}()
+//	var condition string
+//	var pars []interface{}
+//	condition = " AND  user_id = 0 AND company_id > 1 AND mobile != '' "
+//	signUpDetailList, e := models.GetSignupDetailList(condition, pars)
+//	if e != nil && e.Error() != utils.ErrNoRow() {
+//		err = errors.New("GetSignupDetailList, Err: " + e.Error())
+//		return
+//	}
+//	var mobiles []string
+//	mobileMap := make(map[string]bool)
+//	for _, v := range signUpDetailList {
+//		if !mobileMap[v.Mobile] {
+//			mobiles = append(mobiles, v.Mobile)
+//		}
+//		mobileMap[v.Mobile] = true
+//	}
+//	//mobiles = make([]string, 0)
+//	//mobiles = append(mobiles, "13054631616")
+//	//根据手机号获取这些用户的信息
+//	listUser, e := models.GetWxUserByOutboundMobiles(mobiles)
+//	if e != nil {
+//		err = errors.New("GetWxUserOutboundMobiles, Err: " + e.Error())
+//		return
+//	}
+//
+//	var itemsUpdate []*models.CygxActivitySignupDetail
+//	for _, v := range listUser {
+//		item := new(models.CygxActivitySignupDetail)
+//		item.UserId = v.UserId
+//		item.Mobile = v.Mobile
+//		itemsUpdate = append(itemsUpdate, item)
+//	}
+//	fmt.Println(len(itemsUpdate))
+//	err = models.UpdateActivitySignupDetailMultiMobileAndUserId(itemsUpdate)
+//}

+ 77 - 0
services/minutes_summary.go

@@ -0,0 +1,77 @@
+package services
+
+import (
+	"errors"
+	"fmt"
+	"hongze/hongze_cygx/models"
+	"hongze/hongze_cygx/utils"
+	"strconv"
+)
+
+// 上周纪要汇总用户阅读,给销售发消息提醒
+func MinutesSummaryHistoryUserRmind(user *models.WxUserItem, articleId int) (err error) {
+	defer func() {
+		if err != nil {
+			go utils.SendAlarmMsg("用户搜专项调研操作操作行为,模板消息推送失败"+err.Error(), 2)
+		}
+	}()
+	countUser, err := models.GetUserRemind(user.UserId)
+	if err != nil {
+		return err
+	}
+	if countUser == 0 {
+		return err
+	}
+	var first string
+	var keyword1 string
+	var keyword2 string
+	var keyword3 string
+	var keyword4 string
+	var remark string
+	//获取销售手机号
+	sellerItemQy, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		return err
+	}
+	if sellerItemQy != nil {
+		openIdList, e := models.GetWxOpenIdByMobileList(sellerItemQy.Mobile)
+		if e != nil {
+			err = errors.New("GetSellerByAdminId, Err: " + e.Error())
+			return
+		}
+		detail, e := models.GetCygxMinutesSummaryInfoById(articleId)
+		if e != nil {
+			err = errors.New("GetCygxProductInteriorDetail, Err: " + e.Error())
+			return
+		}
+		if detail == nil {
+			return
+		}
+		keyword1 = detail.Title
+		keyword2 = fmt.Sprint("互动:阅读报告,", user.RealName, "--", user.CompanyName)
+		openIdArr := make([]string, 0)
+		for _, v := range openIdList {
+			openIdArr = append(openIdArr, v.OpenId)
+		}
+		redirectUrl := utils.WX_MSG_PATH_LAST_WEEK_DETAIL + strconv.Itoa(articleId)
+		sendInfo := new(SendWxTemplate)
+		sendInfo.First = first
+		sendInfo.Keyword1 = keyword1
+		sendInfo.Keyword2 = keyword2
+		sendInfo.Keyword3 = keyword3
+		sendInfo.Keyword4 = keyword4
+		sendInfo.Remark = remark
+		sendInfo.TemplateId = utils.WxMsgTemplateIdArticleUserRemind
+		sendInfo.RedirectUrl = redirectUrl
+		sendInfo.RedirectTarget = 3
+		sendInfo.Resource = strconv.Itoa(articleId)
+		sendInfo.SendType = utils.TEMPLATE_MSG_CYGX_ARTICLE_ADD
+		sendInfo.OpenIdArr = openIdArr
+		e = PublicSendTemplateMsg(sendInfo)
+		if e != nil {
+			err = errors.New("PublicSendTemplateMsg, Err: " + e.Error())
+			return
+		}
+	}
+	return
+}

+ 6 - 0
services/morning_meeting.go

@@ -80,6 +80,11 @@ func AddCygxMorningMeetingReviewChapterHistory(user *models.WxUserItem, articleI
 			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
@@ -89,6 +94,7 @@ func AddCygxMorningMeetingReviewChapterHistory(user *models.WxUserItem, articleI
 	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() {

+ 77 - 0
services/research_summary.go

@@ -0,0 +1,77 @@
+package services
+
+import (
+	"errors"
+	"fmt"
+	"hongze/hongze_cygx/models"
+	"hongze/hongze_cygx/utils"
+	"strconv"
+)
+
+// 本周研究汇总用户阅读操作操作行为,模板消息推送
+func ResearchSummaryHistoryUserRmind(user *models.WxUserItem, articleId int) (err error) {
+	defer func() {
+		if err != nil {
+			go utils.SendAlarmMsg("用户搜专项调研操作操作行为,模板消息推送失败"+err.Error(), 2)
+		}
+	}()
+	countUser, err := models.GetUserRemind(user.UserId)
+	if err != nil {
+		return err
+	}
+	if countUser == 0 {
+		return err
+	}
+	var first string
+	var keyword1 string
+	var keyword2 string
+	var keyword3 string
+	var keyword4 string
+	var remark string
+	//获取销售手机号
+	sellerItemQy, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		return err
+	}
+	if sellerItemQy != nil {
+		openIdList, e := models.GetWxOpenIdByMobileList(sellerItemQy.Mobile)
+		if e != nil {
+			err = errors.New("GetSellerByAdminId, Err: " + e.Error())
+			return
+		}
+		detail, e := models.GetCygxResearchSummaryInfoById(articleId)
+		if e != nil {
+			err = errors.New("GetCygxProductInteriorDetail, Err: " + e.Error())
+			return
+		}
+		if detail == nil {
+			return
+		}
+		keyword1 = detail.Title
+		keyword2 = fmt.Sprint("互动:阅读报告,", user.RealName, "--", user.CompanyName)
+		openIdArr := make([]string, 0)
+		for _, v := range openIdList {
+			openIdArr = append(openIdArr, v.OpenId)
+		}
+		redirectUrl := utils.WX_MSG_PATH_THIS_WEEK_DETAIL + strconv.Itoa(articleId)
+		sendInfo := new(SendWxTemplate)
+		sendInfo.First = first
+		sendInfo.Keyword1 = keyword1
+		sendInfo.Keyword2 = keyword2
+		sendInfo.Keyword3 = keyword3
+		sendInfo.Keyword4 = keyword4
+		sendInfo.Remark = remark
+		sendInfo.TemplateId = utils.WxMsgTemplateIdArticleUserRemind
+		sendInfo.RedirectUrl = redirectUrl
+		sendInfo.RedirectTarget = 3
+		sendInfo.Resource = strconv.Itoa(articleId)
+		sendInfo.SendType = utils.TEMPLATE_MSG_CYGX_ARTICLE_ADD
+		sendInfo.OpenIdArr = openIdArr
+		e = PublicSendTemplateMsg(sendInfo)
+		if e != nil {
+			err = errors.New("PublicSendTemplateMsg, Err: " + e.Error())
+			return
+		}
+	}
+	return
+}