Ver código fonte

Merge branch 'master' of http://8.136.199.33:3000/hongze/hongze_task into cyxg_need_1035

zhangchuanxing 3 dias atrás
pai
commit
7110555ad9

+ 54 - 41
models/db.go

@@ -32,47 +32,60 @@ func init() {
 	report_db, _ := orm.GetDB("rddp")
 	report_db, _ := orm.GetDB("rddp")
 	report_db.SetConnMaxLifetime(10 * time.Minute)
 	report_db.SetConnMaxLifetime(10 * time.Minute)
 
 
-	_ = orm.RegisterDataBase("edb", "mysql", utils.MYSQL_URL_EDB)
-	orm.SetMaxIdleConns("edb", 50)
-	orm.SetMaxOpenConns("edb", 100)
-
-	edb_db, _ := orm.GetDB("edb")
-	edb_db.SetConnMaxLifetime(10 * time.Minute)
-
-	_ = orm.RegisterDataBase("data", "mysql", utils.MYSQL_URL_DATA)
-	orm.SetMaxIdleConns("data", 50)
-	orm.SetMaxOpenConns("data", 100)
-
-	data_db, _ := orm.GetDB("data")
-	data_db.SetConnMaxLifetime(10 * time.Minute)
-
-	_ = orm.RegisterDataBase("gl", "mysql", utils.MYSQL_URL_GL)
-	orm.SetMaxIdleConns("gl", 50)
-	orm.SetMaxOpenConns("gl", 100)
-
-	gl, _ := orm.GetDB("gl")
-	gl.SetConnMaxLifetime(10 * time.Minute)
-
-	_ = orm.RegisterDataBase("weekly_trial", "mysql", utils.MYSQL_URL_WEEKLY_TRIAL)
-	orm.SetMaxIdleConns("weekly_trial", 50)
-	orm.SetMaxOpenConns("weekly_trial", 100)
-
-	trial_datadb, _ := orm.GetDB("weekly_trial")
-	trial_datadb.SetConnMaxLifetime(10 * time.Minute)
-
-	_ = orm.RegisterDataBase("eta", "mysql", utils.MYSQL_URL_ETA)
-	orm.SetMaxIdleConns("eta", 50)
-	orm.SetMaxOpenConns("eta", 100)
-
-	etaDb, _ := orm.GetDB("eta")
-	etaDb.SetConnMaxLifetime(10 * time.Minute)
-
-	_ = orm.RegisterDataBase("hz_cygx", "mysql", utils.MYSQL_URL_CYGX)
-	orm.SetMaxIdleConns("hz_cygx", 50)
-	orm.SetMaxOpenConns("hz_cygx", 100)
-
-	cygx_db, _ := orm.GetDB("hz_cygx")
-	cygx_db.SetConnMaxLifetime(10 * time.Minute)
+	if utils.MYSQL_URL_EDB != "" {
+		_ = orm.RegisterDataBase("edb", "mysql", utils.MYSQL_URL_EDB)
+		orm.SetMaxIdleConns("edb", 50)
+		orm.SetMaxOpenConns("edb", 100)
+
+		edb_db, _ := orm.GetDB("edb")
+		edb_db.SetConnMaxLifetime(10 * time.Minute)
+
+	}
+
+	if utils.MYSQL_URL_DATA != "" {
+		_ = orm.RegisterDataBase("data", "mysql", utils.MYSQL_URL_DATA)
+		orm.SetMaxIdleConns("data", 50)
+		orm.SetMaxOpenConns("data", 100)
+
+		data_db, _ := orm.GetDB("data")
+		data_db.SetConnMaxLifetime(10 * time.Minute)
+	}
+
+	if utils.MYSQL_URL_GL != "" {
+		_ = orm.RegisterDataBase("gl", "mysql", utils.MYSQL_URL_GL)
+		orm.SetMaxIdleConns("gl", 50)
+		orm.SetMaxOpenConns("gl", 100)
+
+		gl, _ := orm.GetDB("gl")
+		gl.SetConnMaxLifetime(10 * time.Minute)
+	}
+
+	if utils.MYSQL_URL_WEEKLY_TRIAL != "" {
+		_ = orm.RegisterDataBase("weekly_trial", "mysql", utils.MYSQL_URL_WEEKLY_TRIAL)
+		orm.SetMaxIdleConns("weekly_trial", 50)
+		orm.SetMaxOpenConns("weekly_trial", 100)
+
+		trial_datadb, _ := orm.GetDB("weekly_trial")
+		trial_datadb.SetConnMaxLifetime(10 * time.Minute)
+	}
+
+	if utils.MYSQL_URL_ETA != "" {
+		_ = orm.RegisterDataBase("eta", "mysql", utils.MYSQL_URL_ETA)
+		orm.SetMaxIdleConns("eta", 50)
+		orm.SetMaxOpenConns("eta", 100)
+
+		etaDb, _ := orm.GetDB("eta")
+		etaDb.SetConnMaxLifetime(10 * time.Minute)
+	}
+
+	if utils.MYSQL_URL_CYGX != "" {
+		_ = orm.RegisterDataBase("hz_cygx", "mysql", utils.MYSQL_URL_CYGX)
+		orm.SetMaxIdleConns("hz_cygx", 50)
+		orm.SetMaxOpenConns("hz_cygx", 100)
+
+		cygx_db, _ := orm.GetDB("hz_cygx")
+		cygx_db.SetConnMaxLifetime(10 * time.Minute)
+	}
 
 
 	orm.Debug = true
 	orm.Debug = true
 	orm.DebugLog = orm.NewLog(utils.Binlog)
 	orm.DebugLog = orm.NewLog(utils.Binlog)

+ 35 - 0
models/roadshow/calendar.go

@@ -107,3 +107,38 @@ func GetRsCalendarResearcherById(rsCalendarId int) (item *RsCalendarResearcher,
 	err = o.Raw(sql, rsCalendarId).QueryRow(&item)
 	err = o.Raw(sql, rsCalendarId).QueryRow(&item)
 	return
 	return
 }
 }
+
+type CalendarTesearcherQuestionTips struct {
+	CompanyName            string
+	OpenId                 string
+	RsCalendarId           int
+	RsCalendarResearcherId int
+}
+
+func GetCalendarTesearcherQuestionTips(endTime string) (list []*CalendarTesearcherQuestionTips, err error) {
+	sql := `
+select a.rs_calendar_id,a.rs_calendar_researcher_id,c.company_name,b.open_id 
+from rs_calendar_researcher as a
+inner join admin as b on a.researcher_id=b.admin_id
+inner join rs_calendar as c on a.rs_calendar_id=c.rs_calendar_id
+where 
+a.question_status=0
+and a.status in(2,6)
+and a.question_msg_status=0
+and CONCAT(a.end_date,' ',a.end_time) <= ?
+and b.open_id<>''
+and c.activity_type='路演'
+and c.roadshow_type<>''
+group by a.researcher_id,b.open_id
+`
+	o := orm.NewOrm()
+	_, err = o.Raw(sql, endTime).QueryRows(&list)
+	return
+}
+
+func ModifyRsCalendarResearcherQuestionMsgStatus(rsCalendarResearcher_id int) (err error) {
+	sql := ` UPDATE rs_calendar_researcher SET question_msg_status=1,modify_time=NOW() WHERE rs_calendar_researcher_id=? `
+	o := orm.NewOrm()
+	_, err = o.Raw(sql, rsCalendarResearcher_id).Exec()
+	return
+}

+ 4 - 0
models/roadshow/report.go

@@ -34,6 +34,7 @@ type RsReportRecord struct {
 	ActivityType               string    `description:"活动类型"`
 	ActivityType               string    `description:"活动类型"`
 	RoadshowType               string    `description:"路演形式"`
 	RoadshowType               string    `description:"路演形式"`
 	InteractionNum             int       `description:"当时用户总的互动量"`
 	InteractionNum             int       `description:"当时用户总的互动量"`
+	QuestionStatus             int       `description:"问答状态:0-未填写;1-已填写"`
 }
 }
 
 
 func AddRsReportRecord(item *RsReportRecord) (lastId int64, err error) {
 func AddRsReportRecord(item *RsReportRecord) (lastId int64, err error) {
@@ -79,6 +80,9 @@ type RsCalendarResearcherView struct {
 	ApproveTime            time.Time `description:"接受时间"`
 	ApproveTime            time.Time `description:"接受时间"`
 	IsSynced               int       `description:"是否与上海同步 0:未同步 1:已同步"`
 	IsSynced               int       `description:"是否与上海同步 0:未同步 1:已同步"`
 	ResearcherSort         int       `description:"研究员新增排序"`
 	ResearcherSort         int       `description:"研究员新增排序"`
+	QuestionStatus         int       `description:"问答状态:0-未填写;1-已填写"`
+	EnglishCompany         int       `description:"是否为英文客户: 0-否; 1-是"`
+	CompanyStatus          string    `description:"客户状态:'试用','永续','冻结','流失','正式','潜在'"`
 }
 }
 
 
 func GetRsCalendarDetail(endDate string) (list []*RsCalendarResearcherView, err error) {
 func GetRsCalendarDetail(endDate string) (list []*RsCalendarResearcherView, err error) {

+ 55 - 0
services/calendar_researcher_question.go

@@ -0,0 +1,55 @@
+package services
+
+import (
+	"context"
+	"encoding/json"
+	"fmt"
+	"hongze/hongze_task/models/roadshow"
+	"hongze/hongze_task/utils"
+	"strconv"
+	"time"
+)
+
+func SendCalendarResearcherQuestionTips(cont context.Context) (err error) {
+	utils.FileLog.Info("start SendCalendarResearcherQuestionTips")
+	endTime := time.Now().Add(-2 * time.Second).Format(utils.FormatDateTime)
+	list, err := roadshow.GetCalendarTesearcherQuestionTips(endTime)
+	if err != nil {
+		fmt.Println("SendCalendarResearcherQuestionTips Err:" + err.Error())
+		utils.FileLog.Info("GetCalendarTesearcherQuestionTips Err:" + err.Error())
+		return
+	}
+
+	var redirectUrl string
+
+	redirectUrl = `/pages-approve/activity/detail?RsCalendarResearcherId=%s&RsCalendarId=%s`
+	for _, v := range list {
+		var openIdArr []string
+		openIdArr = append(openIdArr, v.OpenId)
+
+		keyword1 := v.CompanyName + "路演已结束,请及时填写客户回答"
+		redirectUrl = fmt.Sprintf(redirectUrl, strconv.Itoa(v.RsCalendarResearcherId), strconv.Itoa(v.RsCalendarId))
+		sendInfo := new(SendWxTemplate)
+		sendInfo.WxAppId = utils.AdminWxAppId
+		sendInfo.Keyword1 = keyword1
+		sendInfo.Keyword2 = "待填写"
+		sendInfo.RedirectUrl = redirectUrl
+		sendInfo.RedirectTarget = 2
+		sendInfo.TemplateId = "rciDm9ThigRBGi1SZ4TFd74XA4aoAxSz_ugdv_tZ450"
+		sendInfo.Remark = time.Now().Format(utils.FormatDateTime)
+		sendInfo.OpenIdArr = openIdArr
+		err = SendTemplateMsgV2(sendInfo)
+		if err != nil {
+			utils.FileLog.Info("GetCalendarTesearcherQuestionTips SendTemplateMsgV2 Err:" + err.Error())
+			return
+		}
+		param, err := json.Marshal(sendInfo)
+		utils.FileLog.Info("SendTemplateMsgV2 success:" + string(param))
+		err = roadshow.ModifyRsCalendarResearcherQuestionMsgStatus(v.RsCalendarResearcherId)
+		if err != nil {
+			utils.FileLog.Info("ModifyRsCalendarResearcherQuestionMsgStatus Err:" + err.Error())
+		}
+	}
+	utils.FileLog.Info("end SendCalendarResearcherQuestionTips")
+	return
+}

+ 16 - 8
services/roadshow/report.go

@@ -172,15 +172,21 @@ func AddReportRecord(cont context.Context) (err error) {
 		}
 		}
 		company := new(roadshow.CompanySearchView)
 		company := new(roadshow.CompanySearchView)
 		if v.CompanyId > 0 {
 		if v.CompanyId > 0 {
-			if mapRaiSllerId[v.SysUserId] {
-				company, _ = companyMapRai[v.CompanyId] // 如果是权益销售添加的信息,就用权益相关的客户信息
-				if len(mapPermissionNameRai[v.CompanyId]) > 0 {
-					company.PermissionName = strings.Join(mapPermissionNameRai[v.CompanyId], "/")
-				}
+			if v.EnglishCompany == 1 { //如果是海外客户公司信息就直接拿存在海外的客户数据
+				company.CompanyId = v.CompanyId
+				company.CompanyName = v.CompanyName
+				company.Status = v.CompanyStatus
 			} else {
 			} else {
-				company, _ = companyMap[v.CompanyId]
-				if len(mapPermissionNameFicc[v.CompanyId]) > 0 {
-					company.PermissionName = strings.Join(mapPermissionNameFicc[v.CompanyId], "/")
+				if mapRaiSllerId[v.SysUserId] {
+					company, _ = companyMapRai[v.CompanyId] // 如果是权益销售添加的信息,就用权益相关的客户信息
+					if len(mapPermissionNameRai[v.CompanyId]) > 0 {
+						company.PermissionName = strings.Join(mapPermissionNameRai[v.CompanyId], "/")
+					}
+				} else {
+					company, _ = companyMap[v.CompanyId]
+					if len(mapPermissionNameFicc[v.CompanyId]) > 0 {
+						company.PermissionName = strings.Join(mapPermissionNameFicc[v.CompanyId], "/")
+					}
 				}
 				}
 			}
 			}
 		}
 		}
@@ -245,6 +251,7 @@ func AddReportRecord(cont context.Context) (err error) {
 			reportUpdateParams["rs_calendar_researcher_status"] = v.Status
 			reportUpdateParams["rs_calendar_researcher_status"] = v.Status
 			reportUpdateParams["activity_type"] = v.ActivityType
 			reportUpdateParams["activity_type"] = v.ActivityType
 			reportUpdateParams["roadshow_type"] = v.RoadshowType
 			reportUpdateParams["roadshow_type"] = v.RoadshowType
+			reportUpdateParams["question_status"] = v.QuestionStatus
 			reportUpdateParams["modify_time"] = time.Now()
 			reportUpdateParams["modify_time"] = time.Now()
 			err = roadshow.UpdateRsReportRecord(reportWhereParams, reportUpdateParams)
 			err = roadshow.UpdateRsReportRecord(reportWhereParams, reportUpdateParams)
 		} else { //新增
 		} else { //新增
@@ -291,6 +298,7 @@ func AddReportRecord(cont context.Context) (err error) {
 			item.ModifyTime = time.Now()
 			item.ModifyTime = time.Now()
 			item.RsCalendarResearcherStatus = v.Status
 			item.RsCalendarResearcherStatus = v.Status
 			item.RoadshowType = v.RoadshowType
 			item.RoadshowType = v.RoadshowType
+			item.QuestionStatus = v.QuestionStatus
 			item.InteractionNum = mapInteractionNum[v.CompanyId]
 			item.InteractionNum = mapInteractionNum[v.CompanyId]
 			_, err = roadshow.AddRsReportRecord(item)
 			_, err = roadshow.AddRsReportRecord(item)
 			if err != nil {
 			if err != nil {

+ 4 - 0
services/task.go

@@ -199,6 +199,10 @@ func Task() {
 	fixCompanyOverseasStatus := task.NewTask("fixCompanyOverseasStatus", "0 */5 * * * *", overseas_custom.FixCompanyOverseasStatus)
 	fixCompanyOverseasStatus := task.NewTask("fixCompanyOverseasStatus", "0 */5 * * * *", overseas_custom.FixCompanyOverseasStatus)
 	task.AddTask("同步客户状态", fixCompanyOverseasStatus)
 	task.AddTask("同步客户状态", fixCompanyOverseasStatus)
 
 
+	//路演问答填写提示
+	sendCalendarResearcherQuestionTips := task.NewTask("sendCalendarResearcherQuestionTips", "0 */1 * * * *", SendCalendarResearcherQuestionTips)
+	task.AddTask("sendCalendarResearcherQuestionTips", sendCalendarResearcherQuestionTips)
+
 	task.StartTask()
 	task.StartTask()
 
 
 	fmt.Println("task end")
 	fmt.Println("task end")