Эх сурвалжийг харах

Merge branch 'cygx_12.0' into debug

ziwen 1 жил өмнө
parent
commit
522ca6b650

+ 17 - 0
controllers/report_selection.go

@@ -63,6 +63,21 @@ func (this *ReportSelectionController) Detail() {
 		br.ErrMsg = "报告ID错误" + strconv.Itoa(articleId)
 		return
 	}
+
+	PermissionNameMap, err := services.GetPermissionNameMap()
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败 GetPermissionNameMap,Err:" + err.Error()
+		return
+	}
+
+	PermissionIcoMap, err := services.GetPermissionNameIcoMap()
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败 GetPermissionNameMap,Err:" + err.Error()
+		return
+	}
+
 	resp := new(models.ReportSelectionLetailResp)
 	//判断用户权限
 	hasPermission, err := services.GetUserhasPermission(user)
@@ -154,6 +169,8 @@ func (this *ReportSelectionController) Detail() {
 			}
 			item.BodyChartSummary = mapChartLog[v.PermissionName]
 			item.List = listSonLog
+			item.PermissionName = PermissionNameMap[v.ChartPermissionId]
+			item.IcoLink = PermissionIcoMap[v.ChartPermissionId]
 			items = append(items, item)
 			itemsSubject = append(itemsSubject, itemSubject)
 			//itemLogs = make([]*models.CygxReportSelectionLogDetail, 0)

+ 10 - 2
controllers/yanxuan_special.go

@@ -332,16 +332,18 @@ func (this *YanxuanSpecialController) Save() {
 		item.Status = 1
 	} else {
 		item.Status = 2
-		//todo
 	}
 
+	specialId := 0
+
 	if req.Id == 0 {
-		_, err = models.AddCygxYanxuanSpecial(&item)
+		id, err := models.AddCygxYanxuanSpecial(&item)
 		if err != nil {
 			br.Msg = "新增失败"
 			br.ErrMsg = "新增失败,Err:" + err.Error()
 			return
 		}
+		specialId = int(id)
 	} else {
 		err = models.UpdateYanxuanSpecial(&item)
 		if err != nil {
@@ -349,8 +351,14 @@ func (this *YanxuanSpecialController) Save() {
 			br.ErrMsg = "保存失败,Err:" + err.Error()
 			return
 		}
+		specialId = req.Id
+	}
+
+	if req.DoType == 2 {
+		go services.SendReviewTemplateMsgAdmin(specialId)
 	}
 
+
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "保存成功"

+ 9 - 8
models/activity.go

@@ -730,6 +730,7 @@ func GetActivityIdToSendFile(endDate string) (items []*ActivityIdRep, err error)
 type SignupExportRep struct {
 	Mobile         string `description:"手机号"`
 	CompanyName    string `description:"公司名称"`
+	CompanyId      int    `description:"公司Id"`
 	RealName       string `description:"姓名"`
 	CountryCode    string `description:"区号"`
 	OutboundMobile string `description:"外呼手机号"`
@@ -748,17 +749,17 @@ type ActivityMsgExportRep struct {
 
 func GetSignupExport(activityId int) (item []*SignupExportRep, err error) {
 	o := orm.NewOrm()
-	sql := ` SELECT  s.outbound_mobile,
+	sql := `SELECT
+			s.outbound_mobile,
 			s.country_code,
 			a.is_limit_people,
-			u.real_name,
-			( SELECT p.seller_name FROM company_product AS p WHERE p.company_id = u.company_id AND p.product_id = 2 ) AS seller_name,
-			( SELECT c.company_name FROM company AS c WHERE c.company_id = u.company_id  ) AS company_name
-			FROM
+			s.real_name,
+			s.seller_name,
+			s.company_id,
+			s.company_name 
+		FROM
 			cygx_activity_signup AS s
-			LEFT JOIN wx_user AS u ON u.user_id = s.user_id
-			LEFT JOIN cygx_activity AS a ON a.activity_id = s.activity_id
-			LEFT JOIN company_product AS p ON p.company_id = u.company_id 
+			JOIN cygx_activity AS a ON a.activity_id = s.activity_id 
 			WHERE a.activity_id = ?  AND s.do_fail_type = 0 AND s.signup_type = 1  GROUP BY s.id `
 	_, err = o.Raw(sql, activityId).QueryRows(&item)
 	return

+ 1 - 0
models/chart_permission.go

@@ -9,6 +9,7 @@ type ChartPermission struct {
 	ChartPermissionId int    `description:"权限id"`
 	PermissionName    string `description:"权限名称"`
 	IsShowSustainable bool   `description:"是否展示限免标签"`
+	ImageUrlM         string `description:"图片地址"`
 }
 
 type ActivityChartPermission struct {

+ 0 - 31
models/product_interior.go

@@ -36,37 +36,6 @@ type ProductInteriorIdReq struct {
 	ProductInteriorId int `description:"ID"`
 }
 
-// 添加
-func AddProductInterior(item *CygxProductInterior) (err error) {
-	o := orm.NewOrm()
-	_, err = o.Insert(item)
-	return
-}
-
-// 修改
-func UpdateProductInterior(item *CygxProductInterior) (err error) {
-	to := orm.NewOrm()
-	updateParams := make(map[string]interface{})
-	updateParams["PublishTime"] = item.PublishTime
-	updateParams["ModifyTime"] = item.ModifyTime
-	updateParams["ColumnName"] = item.ColumnName
-	updateParams["Title"] = item.Title
-	updateParams["Status"] = item.Status
-	updateParams["Body"] = item.Body
-	updateParams["IsCancel"] = item.IsCancel
-	updateParams["VisibleRange"] = item.VisibleRange
-	updateParams["Abstract"] = item.Abstract
-	updateParams["Department"] = item.Department
-	ptrStructOrTableName := "cygx_product_interior"
-	whereParam := map[string]interface{}{"product_interior_id": item.ProductInteriorId}
-	qs := to.QueryTable(ptrStructOrTableName)
-	for expr, exprV := range whereParam {
-		qs = qs.Filter(expr, exprV)
-	}
-	_, err = qs.Update(updateParams)
-	return
-}
-
 type GetCygxProductInteriorResp struct {
 	Paging *paging.PagingItem `description:"分页数据"`
 	List   []*CygxProductInteriorResp

+ 2 - 4
models/report_selection.go

@@ -170,10 +170,9 @@ func GetReportSelectionListHome(condition, tbdb string, pars []interface{}, star
 // 列表
 func GetReportSelectionlogListAll(articleId int) (items []*CygxReportSelectionLog, err error) {
 	o := orm.NewOrm()
-	sql := `SELECT c.permission_name ,c.image_url,s.subject_name , l.*  ,l.company_label as label
+	sql := `SELECT s.subject_name , l.*  ,l.company_label as label
 			FROM
 			cygx_report_selection_log AS l
-			INNER JOIN chart_permission AS c ON c.chart_permission_id = l.chart_permission_id 
 			INNER JOIN cygx_industrial_subject AS s ON s.industrial_subject_id = l.industrial_subject_id 
 			WHERE l.article_id = ? `
 	_, err = o.Raw(sql, articleId).QueryRows(&items)
@@ -183,10 +182,9 @@ func GetReportSelectionlogListAll(articleId int) (items []*CygxReportSelectionLo
 // 列表
 func GetReportSelectionlogSonListAll(articleId, chartPermissionId int) (items []*CygxReportSelectionLogDetail, err error) {
 	o := orm.NewOrm()
-	sql := `SELECT c.permission_name , l.* ,l.company_label as label
+	sql := `SELECT  l.* ,l.company_label as label
 			FROM
 			cygx_report_selection_log AS l
-			INNER JOIN chart_permission AS c ON c.chart_permission_id = l.chart_permission_id 
 			LEFT JOIN cygx_industrial_subject AS s ON s.industrial_subject_id = l.industrial_subject_id 
 			WHERE l.article_id = ? AND l.chart_permission_id =?`
 	_, err = o.Raw(sql, articleId, chartPermissionId).QueryRows(&items)

+ 1 - 2
models/report_selection_chart_log.go

@@ -27,9 +27,8 @@ type AddCygxReportSelectionChartLog struct {
 
 func GetCygxReportSelectionChartLogRepList(articleId int) (items []*CygxReportSelectionChartLogRep, err error) {
 	o := orm.NewOrm()
-	sql := `SELECT l.*,c.chart_permission_name
+	sql := `SELECT l.*
 			FROM cygx_report_selection_chart_log AS l
-			LEFT JOIN chart_permission as c  ON c.chart_permission_id = l.chart_permission_id
 			WHERE  1= 1 AND article_id=?  `
 	_, err = o.Raw(sql, articleId).QueryRows(&items)
 	return

+ 27 - 22
services/activity.go

@@ -172,23 +172,26 @@ func SendEmailFileToExpert(cont context.Context) (err error) {
 	defer func() {
 		if err != nil {
 			fmt.Println("err:", err)
-			go utils.SendAlarmMsg("预约外呼名单,会前1小时自动发送邮件给专家组失败"+msg, 2)
+			go utils.SendAlarmMsg("预约外呼名单,会前1小时自动发送邮件给专家组失败"+err.Error()+msg, 2)
 		}
 	}()
 	endDate := time.Now().Add(+time.Minute * 60).Format(utils.FormatDateTime)
-	total, err := models.GetCountActivityIdToSendFile(endDate)
-
+	total, e := models.GetCountActivityIdToSendFile(endDate)
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		err = errors.New("GetCountActivityIdToSendFile" + e.Error())
+		return
+	}
 	if total == 0 {
 		fmt.Println("发送附件完成0")
 		return nil
 	}
-	if err != nil {
-		msg = "发送附件模版消息失败 Err:" + err.Error()
+
+	listActivity, e := models.GetActivityIdToSendFile(endDate)
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		err = errors.New("GetActivityIdToSendFile" + e.Error())
 		return
 	}
-	listActivity, err := models.GetActivityIdToSendFile(endDate)
-	if err != nil {
-		msg = "发送附件模版消息失败 Err:" + err.Error()
+	if len(listActivity) == 0 {
 		return
 	}
 	var activityIds []int
@@ -196,22 +199,23 @@ func SendEmailFileToExpert(cont context.Context) (err error) {
 		activityIds = append(activityIds, v.ActivityId)
 	}
 
-	//{
-	//	utils.SendAlarmMsg("预约外呼名单,会前1小时自动发送邮件给专家组 监控日志,监控使用无需处理,活动ID:"+fmt.Sprint(activityIds), 2)
-	//}
-
 	for _, v := range listActivity {
 		//time.Sleep(30 * time.Second) //延时30秒,避免邮件发送不成功
-		activityInfo, _ := models.GetAddActivityInfoById(v.ActivityId)
-		if activityInfo == nil {
-			msg = "活动不存在,Err:activityId:" + strconv.Itoa(v.ActivityId)
+		activityInfo, e := models.GetAddActivityInfoById(v.ActivityId)
+		if e != nil {
+			err = errors.New("GetAddActivityInfoById" + e.Error())
 			return
 		}
-		list, errFile := models.GetSignupExport(v.ActivityId)
-		if errFile != nil {
-			msg = "获取失败,Err:" + errFile.Error()
+		list, e := models.GetSignupExport(v.ActivityId)
+		if e != nil {
+			err = errors.New("GetSignupExport" + e.Error())
 			return
 		}
+		var companyIds []int
+		for _, vSin := range list {
+			companyIds = append(companyIds, vSin.CompanyId)
+		}
+		sellNameMap := GetSellNameMapByCompanyIds(companyIds)
 		//创建excel
 		dir, errFile := os.Executable()
 		exPath := filepath.Dir(dir)
@@ -265,8 +269,9 @@ func SendEmailFileToExpert(cont context.Context) (err error) {
 			cellD := row.AddCell()
 			cellD.Value = item.CompanyName
 			cellE := row.AddCell()
-			cellE.Value = item.SellerName
+			cellE.Value = sellNameMap[item.CompanyId]
 		}
+
 		errFile = xlsxFile.Save(downLoadnFilePath)
 		if errFile != nil {
 			msg = "保存文件失败Err:" + errFile.Error()
@@ -297,9 +302,9 @@ func SendEmailFileToExpert(cont context.Context) (err error) {
 			}
 		}
 		os.Remove(downLoadnFilePath)
-		err = models.UPdateActivityIdToSendFile(v.ActivityId)
-		if err != nil {
-			go utils.SendAlarmMsg("UPdateActivityIdToSendFile err"+msg, 2)
+		e = models.UPdateActivityIdToSendFile(v.ActivityId)
+		if e != nil {
+			go utils.SendAlarmMsg("UPdateActivityIdToSendFile err"+e.Error(), 2)
 		}
 
 		//sendResult := utils.SendEmailByHongze(title, content, touser, fileName, title+".xlsx")

+ 14 - 0
services/company_permission.go

@@ -301,3 +301,17 @@ func GetPermissionNameMap() (mapItem map[int]string, err error) {
 	mapItem = mapPermissionName
 	return
 }
+
+func GetPermissionNameIcoMap() (mapItem map[int]string, err error) {
+	list, e := models.GetChartPermissionListRai()
+	if e != nil {
+		err = e
+		return
+	}
+	mapPermissionName := make(map[int]string)
+	for _, v := range list {
+		mapPermissionName[v.ChartPermissionId] = v.ImageUrlM
+	}
+	mapItem = mapPermissionName
+	return
+}

+ 63 - 32
services/cygx_yanxuan_special.go

@@ -75,7 +75,7 @@ func SendWxMsgSpecialFollow(specialId int) (err error) {
 	for _, v := range openIdList {
 		openIdArr = append(openIdArr, v.OpenId)
 	}
-	redirectUrl := utils.WX_MSG_PATH_ACTIVITY_SPECIAL_DETAIL + strconv.Itoa(specialId)
+	redirectUrl := utils.WX_MSG_PATH_YX_SPECIAL_DETAIL + strconv.Itoa(specialId)
 	sendInfo := new(SendWxTemplate)
 	sendInfo.First = first
 	sendInfo.Keyword1 = keyword1
@@ -96,34 +96,65 @@ func SendWxMsgSpecialFollow(specialId int) (err error) {
 	return
 }
 
-//// SendReviewTemplateMsgAdmin 提交审核时给王芳,汪洋发消息
-//func SendReviewTemplateMsgAdmin(req models.ApplyTryReq, usermobile, applyMethod string, isResearch bool) (err error) {
-//	defer func() {
-//		if err != nil {
-//			go utils.SendAlarmMsg("处理试用申请给王芳,汪洋发消息失败, ErrMsg: "+err.Error(), 3)
-//		}
-//	}()
-//	var configCode string
-//	//如果是研选的就推送给汪洋跟王芳,否则就推送给王芳
-//	if isResearch {
-//		configCode = utils.TPL_MSG_WANG_FANG_WANG_YANG
-//	} else {
-//		configCode = utils.TPL_MSG
-//	}
-//	cnf, e := models.GetConfigByCode(configCode)
-//	if e != nil {
-//		err = errors.New("GetConfigByCode, Err: " + e.Error() + configCode)
-//		return
-//	}
-//	openIdList, e := models.GetUserRecordListByMobile(4, cnf.ConfigValue)
-//	if e != nil && e.Error() != utils.ErrNoRow() {
-//		err = errors.New("GetUserRecordListByMobile, Err: " + e.Error() + cnf.ConfigValue)
-//		return err
-//	}
-//
-//	for _, v := range openIdList {
-//		go SendPermissionApplyTemplateMsg(req.RealName, req.CompanyName, usermobile, applyMethod, v)
-//	}
-//
-//	return
-//}
+// SendReviewTemplateMsgAdmin 提交审核时给王芳,汪洋发消息
+func SendReviewTemplateMsgAdmin(specialId int) (err error) {
+	defer func() {
+		if err != nil {
+			go utils.SendAlarmMsg("处理试用申请给王芳,汪洋发消息失败, ErrMsg: "+err.Error(), 3)
+		}
+	}()
+	var configCode string
+	//如果是研选的就推送给汪洋跟王芳,否则就推送给王芳
+	configCode = utils.TPL_MSG_WANG_FANG_WANG_YANG
+	cnf, e := models.GetConfigByCode(configCode)
+	if e != nil {
+		err = errors.New("GetConfigByCode, Err: " + e.Error() + configCode)
+		return
+	}
+	openIdList, e := models.GetUserRecordListByMobile(4, cnf.ConfigValue)
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		err = errors.New("GetUserRecordListByMobile, Err: " + e.Error() + cnf.ConfigValue)
+		return err
+	}
+	specialItem, e := models.GetYanxuanSpecialItemById(specialId)
+	if e != nil {
+		err = errors.New("GetYanxuanSpecialFollowUserById, Err: " + e.Error())
+		return
+	}
+	user, e := models.GetWxUserItemByUserId(specialItem.UserId)
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		err = errors.New("GetWxUserItemByUserId, Err: " + e.Error())
+		return err
+	}
+	var keyword1 string
+	var keyword2 string
+	var keyword3 string
+	var keyword4 string
+	var remark string
+	keyword1 = specialItem.RealName + "【" +user.CompanyName+"】"
+	keyword2 = user.Mobile
+	keyword3 = time.Now().Format(utils.FormatDateTime)
+	keyword4 = "研选专栏提交了内容待审核"
+	openIdArr := make([]string, 0)
+	for _, v := range openIdList {
+		openIdArr = append(openIdArr, v.OpenId)
+	}
+	redirectUrl := utils.WX_MSG_PATH_YX_SPECIAL_DETAIL + strconv.Itoa(specialId)
+	sendInfo := new(SendWxTemplate)
+	sendInfo.Keyword1 = keyword1
+	sendInfo.Keyword2 = keyword2
+	sendInfo.Keyword3 = keyword3
+	sendInfo.Keyword4 = keyword4
+	sendInfo.Remark = remark
+	sendInfo.TemplateId = utils.WxMsgTemplateIdAskMsgXzs
+	sendInfo.RedirectUrl = redirectUrl
+	sendInfo.RedirectTarget = 3
+	sendInfo.Resource = strconv.Itoa(specialId)
+	sendInfo.SendType = utils.TEMPLATE_MSG_CYGX_ARTICLE_ADD
+	sendInfo.OpenIdArr = openIdArr
+	err = PublicSendTemplateMsg(sendInfo)
+	if err != nil {
+		return
+	}
+	return
+}

+ 1 - 0
utils/constants.go

@@ -183,6 +183,7 @@ const (
 	WX_MSG_PATH_APPLY_DETAIL             = "pages-message/applyFor/applyFor?id="                          //潜在用户试用权限申请
 	WX_MSG_PATH_YX_SURVEY_DETAIL         = "pages-purchaser/survey/surveyDetail?surveyId="                //用户提交研选调研需求
 	WX_MSG_PATH_APPLY_COLLECTION_DETAIL  = "reportPages/bulletinDetail/bulletinDetail?id="                //精选看板申请详情页
+	WX_MSG_PATH_YX_SPECIAL_DETAIL  = "pages-purchaser/noteAndViewpoint/noteAndViewpoint?id="                //精选看板申请详情页
 )
 
 //2:文章详情  https://web.hzinsights.com/material/info/8436  小程序路径:/pageMy/reportDetail/reportDetail?id=

+ 8 - 8
utils/email.go

@@ -13,7 +13,7 @@ var (
 	AlarmMsgUrl = "http://127.0.0.1:8606/api/alarm/send"
 )
 
-//发送邮件
+// 发送邮件
 func SendEmail(title, content string, touser string) bool {
 	if RunMode == "debug" {
 		return false
@@ -40,10 +40,10 @@ func SendEmail(title, content string, touser string) bool {
 	return true
 }
 
-//projectName-项目名称
-//runMode-运行模式
-//msgBody-消息内容
-//level:消息基本,1:提示消息,2:警告消息,3:严重错误信息,默认为1 提示消息
+// projectName-项目名称
+// runMode-运行模式
+// msgBody-消息内容
+// level:消息基本,1:提示消息,2:警告消息,3:严重错误信息,默认为1 提示消息
 func SendAlarmMsg(msgBody string, level int) {
 	params := make(map[string]interface{})
 	params["ProjectName"] = APPNAME
@@ -58,7 +58,7 @@ func SendAlarmMsg(msgBody string, level int) {
 	http.Post(AlarmMsgUrl, string(param))
 }
 
-//发送邮件
+// 发送邮件
 func SendEmailByHz(title, content string, touser string) (result bool, err error) {
 	//if RunMode == "debug" {
 	//	result = false
@@ -88,7 +88,7 @@ func SendEmailByHz(title, content string, touser string) (result bool, err error
 	return
 }
 
-//发送带有文件的邮件
+// 发送带有文件的邮件
 func SendEmailHaveFile(title, content string, fileName, touser string) bool {
 	var arr []string
 	sub := strings.Index(touser, ";")
@@ -113,7 +113,7 @@ func SendEmailHaveFile(title, content string, fileName, touser string) bool {
 	return true
 }
 
-//发送邮件
+// 发送邮件
 func SendEmailByHongze(title, content string, touser, attachPath, attachName string) bool {
 	var arr []string
 	sub := strings.Index(touser, ";")