Browse Source

Merge branch 'cygx/cygx_11.2' of http://8.136.199.33:3000/hongze/hz_crm_api into debug

xingzai 1 year ago
parent
commit
34c2b7b87d

+ 2 - 2
controllers/business_trip/business_apply.go

@@ -166,7 +166,7 @@ func (this *BusinessTrip) ApplyAdd() {
 		}
 	}
 
-	approveItem, err := system.GetSysUserById(66)
+	approveItem, err := system.GetSysUserById(utils.ApproveUserId)
 	if err != nil {
 		br.Msg = "获取审批人信息失败!"
 		br.ErrMsg = "获取审批人信息失败,Err:" + err.Error()
@@ -508,7 +508,7 @@ func (this *BusinessTrip) ApplyEdit() {
 		}
 	}
 
-	approveItem, err := system.GetSysUserById(66)
+	approveItem, err := system.GetSysUserById(utils.ApproveUserId)
 	if err != nil {
 		br.Msg = "获取审批人信息失败!"
 		br.ErrMsg = "获取审批人信息失败,Err:" + err.Error()

+ 12 - 1
controllers/cygx/activity.go

@@ -89,7 +89,18 @@ func (this *ActivityCoAntroller) PreserveAndPublish() {
 	//处理识图建会的会议信息列表 因为活动发布处理的业务逻辑过多,方便后期统一维护这里 根据 list 数据类型自己拼接 活动的 body  查研观向 11.12
 	listImgToText := req.ListImgToText
 	if len(listImgToText) > 0 {
-		req = cygxService.MakeActivityReqText(listImgToText)
+		var errmsg string
+		req, err, errmsg = cygxService.MakeActivityReqText(listImgToText)
+		if err != nil {
+			br.Msg = "识图建会失败!"
+			br.ErrMsg = "参数解析失败,Err:" + err.Error()
+			return
+		}
+		if errmsg != "" {
+			br.Msg = "识图建会失败," + errmsg
+			br.ErrMsg = "识图建会失败," + errmsg
+			return
+		}
 	}
 	if req.Body == "" {
 		br.Msg = "内容不可为空"

+ 1 - 1
controllers/sys_menu.go

@@ -100,7 +100,7 @@ func (this *SysRoleController) SysMenuList() {
 			}
 		}
 
-		if strings.Contains(item.Name, "出差管理") && sysUser.AdminId == 66 {
+		if strings.Contains(item.Name, "出差管理") && sysUser.AdminId == utils.ApproveUserId {
 			cm := new(system.ChildMenu)
 			cm.MenuId = 10000
 			cm.Name = "出差审批"

+ 33 - 7
services/cygx/activity_ocr.go

@@ -1,6 +1,7 @@
 package cygx
 
 import (
+	"errors"
 	"hongze/hz_crm_api/models/cygx"
 	"hongze/hz_crm_api/utils"
 	"strconv"
@@ -51,12 +52,12 @@ func ConvertActivityTitmeYMD(TitmeYMD string) (titmeYMDNew string) {
 func ConvertActivityTitmeHM(titmeHM string) (titmeHMNew string) {
 	titmeHMNew = titmeHM
 	var hNum int
-	//var amOrPm string
+	var amOrPm string
 	if strings.Contains(titmeHM, "PM") {
 		hNum = 12
-		//amOrPm = "PM"
+		amOrPm = "PM"
 	} else {
-		//amOrPm = "AM"
+		amOrPm = "AM"
 	}
 	titmeHM = strings.Replace(titmeHM, "AM", "", -1)
 	titmeHM = strings.Replace(titmeHM, "PM", "", -1)
@@ -66,14 +67,14 @@ func ConvertActivityTitmeHM(titmeHM string) (titmeHMNew string) {
 	}
 	hourNum, _ := strconv.Atoi(sliceHm[0])
 	minute := sliceHm[1]
-	titmeHMNew = strconv.Itoa(hNum+hourNum) + ":" + minute
+	titmeHMNew = strconv.Itoa(hNum+hourNum) + ":" + minute + amOrPm
 	return
 }
 
 // 活动内容模版
 var ActivityOcrTemplate = "<p>【买方研选-小范围公司线上交流】{{COMPANY}}</p><p>时间:{{TIME}}</p><p>嘉宾:IR</p><p>主持人:IR</p><p>链接参会:(会前一天下午更新)</p><p>备注:</p><p>1、请先报名,我们将于会议前一天提供【Webex】入会链接(可电话拨入or网络端参会);</p><p>2、会议语言:{{LANGUAGE}};</p><p>3、本场会议报名截止时间为会议开始前一天下午3点半;</p><p>4、本次会议扣0.5次研选服务点。</p>"
 
-func MakeActivityReqText(list []*cygx.AliyunOcrTextActivityResp) (req cygx.ActivityRep) {
+func MakeActivityReqText(list []*cygx.AliyunOcrTextActivityResp) (req cygx.ActivityRep, err error, errMsg string) {
 	for _, v := range list {
 		ActivityOcrTmp := ActivityOcrTemplate
 		sliceCompany := strings.Split(v.Company, "(")
@@ -81,8 +82,32 @@ func MakeActivityReqText(list []*cygx.AliyunOcrTextActivityResp) (req cygx.Activ
 		ActivityOcrTmp = strings.Replace(ActivityOcrTmp, "{{COMPANY}}", company, -1)
 		v.TitmeYMD = strings.Replace(v.TitmeYMD, "年", "-", -1)
 		v.TitmeYMD = strings.Replace(v.TitmeYMD, "月", "-", -1)
-		v.TitmeYMD = strings.Replace(v.TitmeYMD, "日", " ", -1)
-		ActivityOcrTmp = strings.Replace(ActivityOcrTmp, "{{TIME}}", v.TitmeYMD+v.TitmeHM, -1)
+		v.TitmeYMD = strings.Replace(v.TitmeYMD, "日", "", -1)
+		weeknum := utils.StrDateTimeToWeek(v.TitmeYMD + " 00:00:00")
+
+		var condition string
+		var pars []interface{}
+		condition = " AND activity_type_id = 3 AND  activity_time = ? AND temporary_label = ? "
+		var activityTime string
+		activityTime = strings.Replace(v.TitmeHM, " ", "", -1)
+		activityTime = strings.Replace(activityTime, "AM", "", -1)
+		activityTime = strings.Replace(activityTime, "PM", "", -1)
+		activityTime = v.TitmeYMD + " " + activityTime + ":00"
+		//fmt.Println(activityTime)
+		pars = append(pars, activityTime, company)
+		total, e := cygx.GetActivityCount(condition, pars)
+		if e != nil {
+			err = errors.New("GetActivityCount,Err" + e.Error())
+			return
+		}
+		//fmt.Println(total)
+
+		//return
+		if total > 0 {
+			errMsg = "相同时段已存在对应活动"
+			return
+		}
+		ActivityOcrTmp = strings.Replace(ActivityOcrTmp, "{{TIME}}", v.TitmeYMD+"("+weeknum+")"+v.TitmeHM, -1)
 		if utils.CheckStrHaveLetter(company) {
 			ActivityOcrTmp = strings.Replace(ActivityOcrTmp, "{{LANGUAGE}}", "中文", -1)
 		} else {
@@ -105,6 +130,7 @@ func MakeActivityReqText(list []*cygx.AliyunOcrTextActivityResp) (req cygx.Activ
 	req.VisibleRange = 2
 	req.IsResearchPoints = 1
 	req.IsNeedEmail = 1
+	// 研选点数
 	pointsSet := new(cygx.CygxActivityPointsSetRsq)
 	pointsSet.PointsObject = "1"
 	pointsSet.UserPointsNum = "0.5"

+ 4 - 0
utils/constants.go

@@ -511,3 +511,7 @@ const (
 
 // BusinessCodeSalt 商家编码盐值
 const BusinessCodeSalt = "dr7WY0OZgGR7upw1"
+
+const (
+	ApproveUserId = 2 //施琪-出差审批人
+)