Browse Source

Merge branch 'master' of http://8.136.199.33:3000/hongze/hongze_cygx

xingzai 2 years ago
parent
commit
e24de8f637

+ 3 - 0
controllers/activity.go

@@ -3097,6 +3097,9 @@ func (this *ActivityCoAntroller) LabelTypeListV5() {
 		}
 		//标签字段关联的产业与标签处理
 		for k2, v2 := range labelList {
+			if v2.YidongActivityId != 0 {
+				v2.IsExternalLabel = true
+			}
 			labelList[k2].KeyWord = services.LabelStrV5(v2.KeyWord, v2.IsShowSubjectName, v2.TemporaryLabel)
 			labelList[k2].ImgUrlBg = v.ImgUrlBgs
 		}

+ 3 - 3
controllers/micro_roadshow.go

@@ -127,9 +127,9 @@ func (this *MicroRoadShowController) List() {
 		}
 
 		//修改产业视频的标题
-		if list[i].Type == 3 && list[i].IndustryName != ""{
-			list[i].Title = "5min"+"【"+ list[i].IndustryName +"】"+"逻辑解析"
-		}
+		//if list[i].Type == 3 && list[i].IndustryName != "" {
+		//	list[i].Title = "5min" + "【" + list[i].IndustryName + "】" + "逻辑解析"
+		//}
 	}
 
 	resp := new(models.MicroRoadShowListResp)

+ 147 - 0
controllers/report.go

@@ -3,6 +3,7 @@ package controllers
 import (
 	"encoding/json"
 	"fmt"
+	"github.com/medivhzhan/weapp/v2"
 	"github.com/rdlucklib/rdluck_tools/paging"
 	"hongze/hongze_cygx/models"
 	"hongze/hongze_cygx/services"
@@ -3127,3 +3128,149 @@ func (this *ReportController) StockNameList() {
 	br.Msg = "获取成功"
 	br.Data = resp
 }
+
+// @Title 文章留言接口
+// @Description 文章留言接口
+// @Param	request	body models.AddCygxActivityHelpAsk true "type json string"
+// @Success 200 {object} models.TacticsListResp
+// @router /commentAdd [post]
+func (this *ReportController) CommentAdd() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请重新登录"
+		br.Ret = 408
+		return
+	}
+	var req models.AddCygxArticleCommentReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	if req.ArticleId <= 0 {
+		br.Msg = "文章不存在"
+		br.ErrMsg = "文章不存在,文章ID错误"
+		return
+	}
+	if req.Content == "" {
+		br.Msg = "建议内容不可为空"
+		return
+	}
+	content := req.Content
+	itemToken, err := services.WxGetToken()
+	if err != nil {
+		br.Msg = "GetWxAccessToken Err:" + err.Error()
+		return
+	}
+	if itemToken.AccessToken == "" {
+		br.Msg = "accessToken is empty"
+		return
+	}
+	commerr, err := weapp.MSGSecCheck(itemToken.AccessToken, content)
+	if err != nil {
+		br.Msg = "内容校验失败!"
+		br.ErrMsg = "内容校验失败,Err:" + err.Error()
+		return
+	}
+	if commerr.ErrCode != 0 {
+		br.Msg = "内容违规,请重新提交!"
+		br.ErrMsg = "内容违规,Err:" + commerr.ErrMSG
+		return
+	}
+
+	articleId := req.ArticleId
+	articleInfo, errInfo := models.GetArticleDetailById(articleId)
+	if articleInfo == nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = "文章ID错误,不存在articleId:" + strconv.Itoa(articleId)
+		return
+	}
+	if errInfo != nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = "操作失败,Err:" + errInfo.Error()
+		return
+	}
+
+	companyDetail, err := models.GetCompanyDetailById(user.CompanyId)
+	if err != nil {
+		br.Msg = "提交失败!"
+		br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
+		return
+	}
+	if companyDetail == nil {
+		br.Msg = "提交失败!"
+		br.ErrMsg = "客户不存在,uid:" + strconv.Itoa(user.UserId)
+		return
+	}
+	item := models.CygxArticleComment{
+		UserId:      user.UserId,
+		ArticleId:   req.ArticleId,
+		CreateTime:  time.Now(),
+		Mobile:      user.Mobile,
+		Email:       user.Email,
+		CompanyId:   user.CompanyId,
+		CompanyName: companyDetail.CompanyName,
+		Content:     content,
+	}
+	_, err = models.AddArticleComment(&item)
+	if err != nil {
+		br.Msg = "提交失败"
+		br.ErrMsg = "提交留言失败,Err:" + err.Error()
+		return
+	}
+
+
+	//var sendMobile string
+	//for _, v := range listEmail {
+	//	if strings.Index(activityInfo.Host, v.Name) > 0 {
+	//		sendMobile = v.Mobile
+	//	}
+	//}
+	//if activityInfo.ChartPermissionId == 31 {
+	//	sendMobile = utils.ActSendMsgMobile
+	//}
+
+	//获取销售信息
+	sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		br.Msg = "提交失败"
+		br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
+		return
+	}
+	// 给所属销售发送消息
+	var openIdList []*models.OpenIdList
+	if sellerItem != nil {
+		list, _ := models.GetWxOpenIdByMobileList(sellerItem.Mobile)
+		for _, idList := range list {
+			openIdList = append(openIdList, idList)
+		}
+		if openIdList != nil {
+			// 给芳姐发消息
+			cnf, _ := models.GetConfigByCode("tpl_msg")
+			if cnf != nil {
+				list, _ := models.GetWxOpenIdByMobileList(cnf.ConfigValue)
+				for _, idList := range list {
+					openIdList = append(openIdList, idList)
+				}
+			}
+			if articleId > 1000000{
+				//发给汪洋
+				list, _ := models.GetWxOpenIdByMobileList( utils.ActSendMsgMobile)
+				for _, idList := range list {
+					openIdList = append(openIdList, idList)
+				}
+			}
+			services.SendCommentWxTemplateMsg(articleInfo.Title, user.CompanyName, user.RealName, sellerItem.RealName, item.CreateTime.Format(utils.FormatDateTime), req.Content, openIdList, req.ArticleId)
+		}
+	}
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "提交成功"
+}

+ 3 - 1
models/activity.go

@@ -688,12 +688,14 @@ type CygxActivityLabelList struct {
 	Resource          int    `description:"位置 ,1:活动 ,2:专项产业调研"`
 	TemporaryLabel    string `description:"临时标签"`
 	IsNew             bool   `description:"是否为新:活动存在关联的的产业所关联的报告均在3个月内/无报告则标记新"`
+	YidongActivityId   int   `description:"易董活动ID"`
+	IsExternalLabel   bool   `description:"是否为外部资源"`
 }
 
 //主题列表
 func GetActivityLabelListAll(condition, sortTime string, pars []interface{}, startSize, pageSize int) (items []*CygxActivityLabelList, err error) {
 	o := orm.NewOrm()
-	sql := `SELECT	activity_id, label,temporary_label,is_show_subject_name, MAX( art.activity_time ) AS timesort, MIn( art.activity_time ) AS mintimesort 
+	sql := `SELECT	activity_id, label,temporary_label,is_show_subject_name, MAX( art.activity_time ) AS timesort, MIn( art.activity_time ) AS mintimesort , yidong_activity_id 
 		FROM cygx_activity as art WHERE 1= 1 `
 	if condition != "" {
 		sql += condition

+ 32 - 0
models/article_comment.go

@@ -0,0 +1,32 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxArticleComment struct {
+	Id       int       `orm:"column(id);pk" description:"留言id"`
+	UserId      int       `description:"用户id"`
+	ArticleId  int       `description:"活动id"`
+	CreateTime  time.Time `description:"创建时间"`
+	Mobile      string    `description:"手机号"`
+	Email       string    `description:"邮箱"`
+	CompanyId   int       `description:"公司id"`
+	CompanyName string    `description:"公司名称"`
+	Content     string    `description:"内容"`
+}
+
+
+//添加留言
+func AddArticleComment(item *CygxArticleComment) (lastId int64, err error) {
+	o := orm.NewOrm()
+	lastId, err = o.Insert(item)
+	return
+}
+
+
+type AddCygxArticleCommentReq struct {
+	ArticleId int    `description:"文章id"`
+	Content    string `description:"内容"`
+}

+ 1 - 0
models/db.go

@@ -127,6 +127,7 @@ func init() {
 		new(CygxActivityVideoHistory),
 		new(CygxActivitySpecialTrip),
 		new(CygxArticleData),
+		new(CygxArticleComment),
 	)
 	// 记录ORM查询日志
 	orm.Debug = true

+ 9 - 0
routers/commentsRouter.go

@@ -718,6 +718,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ReportController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ReportController"],
+        beego.ControllerComments{
+            Method: "CommentAdd",
+            Router: `/commentAdd`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ReportController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ReportController"],
         beego.ControllerComments{
             Method: "Fllow",

+ 41 - 0
services/wx_template_msg.go

@@ -658,3 +658,44 @@ func SendActivityOnenIdWxTemplateMsg(first, keyWord1, keyWord2, keyWord3, keyWor
 	WxSendTemplateMsg(sendUrl, sendMap, openIdList, "", utils.TEMPLATE_MSG_CYGX_ARTICLE_ADD)
 	return
 }
+
+//发送用户留言提醒
+func SendCommentWxTemplateMsg(title, companyName, userName, sellerName, createTime, content string, openIdList []*models.OpenIdList, articleId int) (err error) {
+	var msg string
+	defer func() {
+		if err != nil {
+			go utils.SendEmail("发送模版消息失败"+"【"+utils.APPNAME+"】"+time.Now().Format("2006-01-02 15:04:05"), msg+";Err:"+err.Error(), utils.EmailSendToUsers)
+			go utils.SendAlarmMsg(fmt.Sprint("发送用户用户留言提醒失败,文章ID:", articleId), 2)
+			utils.FileLog.Info("发送模版消息失败,Err:%s", err.Error())
+		}
+	}()
+	accessToken, err := models.GetWxAccessTokenByXzs()
+	if err != nil {
+		msg = "GetWxAccessToken Err:" + err.Error()
+		return
+	}
+	if accessToken == "" {
+		msg = "accessToken is empty"
+		return
+	}
+	var first string
+	first = "【"+title+"】有新的留言,请及时处理"
+	keyword1 := companyName + "--" + userName + "(" + sellerName + ")"
+	keyword2 := "-"
+	keyword3 := createTime
+	keyword4 := content
+	sendUrl := "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + accessToken
+	templateId := utils.WxMsgTemplateIdAskMsgXzs
+	sendMap := make(map[string]interface{})
+	sendData := make(map[string]interface{})
+	sendMap["template_id"] = templateId
+	sendMap["miniprogram"] = map[string]interface{}{"appid": utils.WxAppId, "pagepath": utils.WX_MSG_PATH_ARTICLE_DETAIL + strconv.Itoa(articleId)}
+	sendData["first"] = map[string]interface{}{"value": first, "color": "#173177"}
+	sendData["keyword1"] = map[string]interface{}{"value": keyword1, "color": "#173177"}
+	sendData["keyword2"] = map[string]interface{}{"value": keyword2, "color": "#173177"}
+	sendData["keyword3"] = map[string]interface{}{"value": keyword3, "color": "#173177"}
+	sendData["keyword4"] = map[string]interface{}{"value": keyword4, "color": "#173177"}
+	sendMap["data"] = sendData
+	WxSendTemplateMsg(sendUrl, sendMap, openIdList, strconv.Itoa(articleId), utils.TEMPLATE_MSG_CYGX_COMMENT)
+	return
+}

+ 1 - 0
utils/constants.go

@@ -70,6 +70,7 @@ const (
 	TEMPLATE_MSG_CYGX_ACTIVITY_ADD = 12 //查研观向小程序活动更新推送 12
 	TEMPLATE_MSG_CYGX_ARTICLE_ADD  = 13 //查研观向报告更新推送  13
 	TEMPLATE_MSG_CYGX_APPLY        = 14 //查研观向审批通知
+	TEMPLATE_MSG_CYGX_COMMENT      = 15 //查研观向留言通知
 )
 
 const (