xingzai 1 سال پیش
والد
کامیت
5f040b325f
5فایلهای تغییر یافته به همراه113 افزوده شده و 22 حذف شده
  1. 8 13
      controllers/collection.go
  2. 9 9
      routers/commentsRouter.go
  3. 1 0
      routers/router.go
  4. 94 0
      services/collection.go
  5. 1 0
      utils/constants.go

+ 8 - 13
controllers/collection.go

@@ -2,8 +2,8 @@ package controllers
 
 import (
 	"encoding/json"
-	"fmt"
 	"hongze/hongze_clpt/models"
+	"hongze/hongze_clpt/services"
 	"hongze/hongze_clpt/utils"
 	"time"
 )
@@ -13,29 +13,26 @@ type CollectionController struct {
 	BaseAuthController
 }
 
+type BaseCollectionController struct {
+	BaseCommonController
+}
+
 // @Title 精选看板、路演banner列表
 // @Description 精选看板、路演banner列表接口
 // @Success Ret=200 {object} cygx.CollectionBannerListResp
 // @router /banner/list [get]
-func (this *CollectionController) BannerList() {
+func (this *BaseCollectionController) BannerList() {
 	br := new(models.BaseResponse).Init()
 	defer func() {
 		this.Data["json"] = br
 		this.ServeJSON()
 	}()
-	user := this.User
-	if user == nil {
-		br.Msg = "请登录"
-		br.ErrMsg = "请登录,SysUser Is Empty"
-		br.Ret = 408
-		return
-	}
 
 	resp := new(models.CollectionBannerListResp)
 	var listA []*models.CollectionBannerResp
 	listB := new(models.CollectionBannerResp)
 	listA = []*models.CollectionBannerResp{
-		&models.CollectionBannerResp{Title: "", IndexImg: "https://hzstatic.hzinsights.com/cygx/banner/web/lyhf.png", Path: "https://web.hzinsights.com/activity"},
+		&models.CollectionBannerResp{Title: "路演回放-策略系列培训视频", IndexImg: "https://hzstatic.hzinsights.com/cygx/banner/web/lyhf.png", Path: "https://web.hzinsights.com/activity"},
 	}
 	listB.Title = ""
 	listB.IndexImg = "https://hzstatic.hzinsights.com/cygx/banner/web/jxkb.png"
@@ -122,9 +119,7 @@ func (this *CollectionController) ApplyAdd() {
 		item.SellerName = sellerItem.RealName
 	}
 	newId, err := models.AddCygxApplyCollection(item)
-	fmt.Println(newId)
-	//err = services.AddCygxBannerYxSurvey(user, content)
-	//services.SendCygxBannerYxSurveyTemplateMsg(user, content, int(newId))
+	go services.SendCygxApplyCollectionTemplateMsg(user, content, int(newId))
 	if err != nil {
 		br.Msg = "申请失败"
 		br.ErrMsg = "申请失败,Err:" + err.Error()

+ 9 - 9
routers/commentsRouter.go

@@ -277,6 +277,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:BaseCollectionController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:BaseCollectionController"],
+        beego.ControllerComments{
+            Method: "BannerList",
+            Router: `/banner/list`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:BaseConfigController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:BaseConfigController"],
         beego.ControllerComments{
             Method: "ResearchHb",
@@ -340,15 +349,6 @@ func init() {
             Filters: nil,
             Params: nil})
 
-    beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:CollectionController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:CollectionController"],
-        beego.ControllerComments{
-            Method: "BannerList",
-            Router: `/banner/list`,
-            AllowHTTPMethods: []string{"get"},
-            MethodParams: param.Make(),
-            Filters: nil,
-            Params: nil})
-
     beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:CollectionController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:CollectionController"],
         beego.ControllerComments{
             Method: "Detail",

+ 1 - 0
routers/router.go

@@ -147,6 +147,7 @@ func init() {
 		web.NSNamespace("/collection",
 			web.NSInclude(
 				&controllers.CollectionController{},
+				&controllers.BaseCollectionController{},
 			),
 		),
 	)

+ 94 - 0
services/collection.go

@@ -0,0 +1,94 @@
+package services
+
+import (
+	"errors"
+	"fmt"
+	"hongze/hongze_clpt/models"
+	"hongze/hongze_clpt/utils"
+	"strconv"
+	"strings"
+	"time"
+)
+
+//精选看板
+
+// 用户提交研选调研需求,给王芳、对口销售、内容组全员发模板消息
+func SendCygxApplyCollectionTemplateMsg(user *models.WxUserItem, content string, articleId int) (err error) {
+	var msg string
+	msg = fmt.Sprint(user, articleId)
+	defer func() {
+		if err != nil {
+			go utils.SendAlarmMsg("SendCygxBannerYxSurveyTemplateMsg Err"+msg, 2)
+		}
+	}()
+
+	var mobiles []string
+	//获取权益销售
+	sellerItem, e := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
+	if e != nil {
+		err = errors.New("GetAdminByRoleName, Err: " + e.Error())
+		return
+	}
+	//内容组全员手机号
+	configCode := utils.TPL_MSG_NEI_RONG_ZU
+	cnf, e := models.GetConfigByCode(configCode)
+	if e != nil {
+		err = errors.New("GetConfigByCode, Err: " + e.Error() + configCode)
+		return
+	}
+
+	//王芳手机号
+	cnfWangFang, e := models.GetConfigByCode(utils.TPL_MSG)
+	if e != nil {
+		err = errors.New("GetConfigByCode, Err: " + e.Error() + configCode)
+		return
+	}
+
+	mobiles = append(mobiles, sellerItem.Mobile)
+	mobiles = append(mobiles, cnfWangFang.ConfigValue)
+	listMobile := strings.Split(cnf.ConfigValue, ",")
+	for _, v := range listMobile {
+		mobiles = append(mobiles, v)
+	}
+
+	openIdList, e := models.GetWxOpenIdByMobileSliceList(mobiles)
+	if e != nil {
+		err = errors.New("GetWxOpenIdByMobileSliceList, Err: " + e.Error() + configCode)
+		return
+	}
+	if len(openIdList) == 0 {
+		return
+	}
+	openIdArr := make([]string, 0)
+	for _, v := range openIdList {
+		openIdArr = append(openIdArr, v.OpenId)
+	}
+	var keyword1 string
+	var keyword2 string
+	var keyword3 string
+	var keyword4 string
+	keyword1 = fmt.Sprint(user.RealName, "--", user.CompanyName, "(", sellerItem.RealName, ")")
+	if user.Mobile == "" {
+		user.Mobile = user.Email
+	}
+	keyword2 = user.Mobile
+	keyword3 = time.Now().Format(utils.FormatDateTime)
+	keyword4 = fmt.Sprint("精选看板:", content)
+	var redirectUrl string
+	if utils.RunMode == "release" {
+		redirectUrl = utils.WX_MSG_PATH_APPLY_COLLECTION_DETAIL + strconv.Itoa(articleId)
+	}
+	sendInfo := new(SendWxTemplate)
+	sendInfo.Keyword1 = keyword1
+	sendInfo.Keyword2 = keyword2
+	sendInfo.Keyword3 = keyword3
+	sendInfo.Keyword4 = keyword4
+	sendInfo.SendType = utils.TEMPLATE_MSG_CYGX_ACTIVITY_ADD
+	sendInfo.TemplateId = utils.WxMsgTemplateIdApplyXzs
+	sendInfo.RedirectUrl = redirectUrl
+	sendInfo.RedirectTarget = 3
+	sendInfo.Resource = strconv.Itoa(articleId)
+	sendInfo.OpenIdArr = openIdArr
+	err = PublicSendTemplateMsg(sendInfo)
+	return
+}

+ 1 - 0
utils/constants.go

@@ -177,6 +177,7 @@ const (
 	WX_MSG_PATH_ACTIVITY_INDUSTRYR_EPORT = "reportPages/IndustryReport/IndustryReport?id="   //产业文章列表模板消息地址
 	WX_MSG_PATH_ACTIVITY_DETAIL          = "activityPages/activityDetail/activityDetail?id=" //活动模板消息地址
 	WX_MSG_PATH_APPLY_DETAIL             = "pages-message/applyFor/applyFor?id="             //潜在用户试用权限申请
+	WX_MSG_PATH_APPLY_COLLECTION_DETAIL  = "reportPages/bulletinDetail/bulletinDetail?id="   //精选看板申请详情页
 )
 
 // 微信模板消息推送公共接口的秘钥