浏览代码

Merge branch 'CRM_15.6' into debug

zwxi 11 月之前
父节点
当前提交
cb62f9cc16
共有 5 个文件被更改,包括 1031 次插入0 次删除
  1. 478 0
      controllers/roadshow/report.go
  2. 7 0
      models/company/company.go
  3. 49 0
      models/roadshow/report_record.go
  4. 18 0
      routers/commentsRouter.go
  5. 479 0
      services/roadshow/report.go

+ 478 - 0
controllers/roadshow/report.go

@@ -1285,3 +1285,481 @@ func (this *CalendarController) OverseasCustomCalendarAdminList() {
 	br.Data = list
 	return
 }
+
+// OverseasSellerReportList
+// @Title 海外客户销售路演统计
+// @Description 海外客户销售路演统计接口
+// @Param   DataType   query   string  true       "枚举值:week、month、time_interval、online、offline"
+// @Param   DimensionType   query   string  true       "维度枚举值:company_status、roadshow_type"
+// @Param   StartDate   query   string  true       "开始日期,格式:2022-04-06"
+// @Param   EndDate   query   string  true       "结束日期,格式:2022-04-06"
+// @Success 200 {object} roadshow.RsReportRecordResp
+// @router /overseas_custom/seller/list [get]
+func (this *CalendarController) OverseasSellerReportList() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.SysUser
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+	dataType := this.GetString("DataType")
+	dimensionType := this.GetString("DimensionType")
+	startDate := this.GetString("StartDate")
+	endDate := this.GetString("EndDate")
+
+	if dimensionType == "" {
+		dimensionType = "company_status"
+	}
+
+	var adminDataList []roadshowService.OverseasAdminDataMap
+	var err error
+	var firstDate time.Time
+	//获取列表
+	switch dataType {
+	case "week":
+		adminDataList, firstDate, err = roadshowService.GetOverseasWeekDataV2("seller", dimensionType, 6)
+		if err != nil {
+			br.Msg = "数据异常"
+			br.ErrMsg = "数据异常,Err:" + err.Error()
+			return
+		}
+	case "month":
+		adminDataList, firstDate, err = roadshowService.GetOverseasMonthDataV2("seller", dimensionType, 6)
+		if err != nil {
+			br.Msg = "数据异常"
+			br.ErrMsg = "数据异常,Err:" + err.Error()
+			return
+		}
+	case "time_interval":
+		if startDate == `` || endDate == `` {
+			br.Msg = "开始日期或结束日期不能为空"
+			br.ErrMsg = "开始日期或结束日期不能为空,Err:" + err.Error()
+			return
+		}
+		adminDataList, firstDate, err = roadshowService.GetOverseasTimeIntervalData(startDate, endDate, "seller", dimensionType)
+		if err != nil {
+			br.Msg = "数据异常"
+			br.ErrMsg = "数据异常,Err:" + err.Error()
+			return
+		}
+
+	}
+	group, groupIdRelationMap, err := services.GetFiccSystemGroup()
+	if err != nil {
+		br.Msg = "获取信息失败!"
+		br.ErrMsg = "获取分组信息失败!Err:" + err.Error()
+		return
+	}
+	researcherList, err := services.GetFiccSeller(firstDate, groupIdRelationMap)
+	groupMap := make(map[int][]*roadshow.Researcher)
+	for _, v := range researcherList {
+		if v.RoleTypeCode == "ficc_admin" {
+			findItems := groupMap[1]
+			findItems = append(findItems, v)
+			groupMap[1] = findItems
+		} else {
+			if findItems, ok := groupMap[v.GroupId]; ok {
+				findItems = append(findItems, v)
+				groupMap[v.GroupId] = findItems
+			} else {
+				findItems = append(findItems, v)
+				groupMap[v.GroupId] = findItems
+			}
+		}
+	}
+
+	groupReportRecordList := make([]roadshow.OverseasGroupReportRecord, 0)
+	rsAllReportRecordNumList := make([]roadshow.RsOverseasReportRecordNum, 0)
+	RsReportRecordResp := roadshow.RsOverseasReportRecordResp{
+		List:                  groupReportRecordList,
+		RsReportRecordNumList: rsAllReportRecordNumList,
+	}
+
+	startDateIndexList := make(map[int]string) //开始时间间隔map
+	endDateIndexList := make(map[int]string)   //结束时间间隔map
+
+	tmpAllTryOutNumMap := make(map[int]int)
+	tmpAllFormalNumMap := make(map[int]int)
+	tmpAllCloseNumMap := make(map[int]int)
+	tmpAllOnlineNumMap := make(map[int]int)
+	tmpAllOfflineNumMap := make(map[int]int)
+	for _, v := range group {
+		v.ResearcherList = groupMap[v.GroupId]
+		tmpGroupAdminReportRecord := make([]roadshow.OverseasAdminReportRecord, 0)
+		tmpGroupRsReportRecordNumList := make([]roadshow.RsOverseasReportRecordNum, 0)
+
+		tmpGroupTryOutNumMap := make(map[int]int)
+		tmpGroupFormalNumMap := make(map[int]int)
+		tmpGroupCloseNumMap := make(map[int]int)
+		tmpGroupOnlineNumMap := make(map[int]int)
+		tmpGroupOfflineNumMap := make(map[int]int)
+		for _, researcher := range groupMap[v.GroupId] {
+			//组内研究员数据
+
+			//每个区间的数据
+			tmpAdminRsReportRecordNumList := make([]roadshow.RsOverseasReportRecordNum, 0)
+			for index, adminData := range adminDataList {
+				startDateIndexList[index] = adminData.StartDate
+				endDateIndexList[index] = adminData.EndDate
+
+				var tmpTryOutNum, tmpFormalNum, tmpCloseNum, tmpOnlineNum, tmpOfflineNum int
+				if num, ok := adminData.TryOutMap[researcher.AdminId]; ok {
+					tmpTryOutNum = num
+				}
+				if num, ok := adminData.FormalMap[researcher.AdminId]; ok {
+					tmpFormalNum = num
+				}
+				if num, ok := adminData.CloseMap[researcher.AdminId]; ok {
+					tmpCloseNum = num
+				}
+				if num, ok := adminData.OnlineMap[researcher.AdminId]; ok {
+					tmpOnlineNum = num
+				}
+				if num, ok := adminData.OfflineMap[researcher.AdminId]; ok {
+					tmpOfflineNum = num
+				}
+				tmpAdminRsReportRecordNum := roadshow.RsOverseasReportRecordNum{
+					TryOutNum:  tmpTryOutNum,
+					FormalNum:  tmpFormalNum,
+					CloseNum:   tmpCloseNum,
+					OnlineNum:  tmpOnlineNum,
+					OfflineNum: tmpOfflineNum,
+					StartDate:  adminData.StartDate,
+					EndDate:    adminData.EndDate,
+				}
+				tmpAdminRsReportRecordNumList = append(tmpAdminRsReportRecordNumList, tmpAdminRsReportRecordNum)
+
+				//组内数据汇总
+				if _, ok := tmpGroupTryOutNumMap[index]; !ok {
+					tmpGroupTryOutNumMap[index] = 0
+				}
+				if _, ok := tmpGroupFormalNumMap[index]; !ok {
+					tmpGroupFormalNumMap[index] = 0
+				}
+				if _, ok := tmpGroupCloseNumMap[index]; !ok {
+					tmpGroupCloseNumMap[index] = 0
+				}
+				if _, ok := tmpGroupOnlineNumMap[index]; !ok {
+					tmpGroupOnlineNumMap[index] = 0
+				}
+				if _, ok := tmpGroupOfflineNumMap[index]; !ok {
+					tmpGroupOfflineNumMap[index] = 0
+				}
+				tmpGroupTryOutNumMap[index] += tmpTryOutNum
+				tmpGroupFormalNumMap[index] += tmpFormalNum
+				tmpGroupCloseNumMap[index] += tmpCloseNum
+				tmpGroupOnlineNumMap[index] += tmpOnlineNum
+				tmpGroupOfflineNumMap[index] += tmpOfflineNum
+
+				//总数据汇总
+				if _, ok := tmpAllTryOutNumMap[index]; !ok {
+					tmpAllTryOutNumMap[index] = 0
+				}
+				if _, ok := tmpAllFormalNumMap[index]; !ok {
+					tmpAllFormalNumMap[index] = 0
+				}
+				if _, ok := tmpAllCloseNumMap[index]; !ok {
+					tmpAllCloseNumMap[index] = 0
+				}
+				if _, ok := tmpAllOnlineNumMap[index]; !ok {
+					tmpAllOnlineNumMap[index] = 0
+				}
+				if _, ok := tmpAllOfflineNumMap[index]; !ok {
+					tmpAllOfflineNumMap[index] = 0
+				}
+				tmpAllTryOutNumMap[index] += tmpTryOutNum
+				tmpAllFormalNumMap[index] += tmpFormalNum
+				tmpAllCloseNumMap[index] += tmpCloseNum
+				tmpAllOnlineNumMap[index] += tmpOnlineNum
+				tmpAllOfflineNumMap[index] += tmpOfflineNum
+			}
+			tmpAdminReportRecord := roadshow.OverseasAdminReportRecord{
+				Name:                  researcher.RealName,
+				AdminId:               researcher.AdminId,
+				RsReportRecordNumList: tmpAdminRsReportRecordNumList,
+			}
+			tmpGroupAdminReportRecord = append(tmpGroupAdminReportRecord, tmpAdminReportRecord)
+		}
+
+		for i := 0; i < len(tmpGroupCloseNumMap); i++ {
+			tmpGroupRsReportRecordNum := roadshow.RsOverseasReportRecordNum{
+				TryOutNum:  tmpGroupTryOutNumMap[i],
+				FormalNum:  tmpGroupFormalNumMap[i],
+				CloseNum:   tmpGroupCloseNumMap[i],
+				OnlineNum:  tmpGroupOnlineNumMap[i],
+				OfflineNum: tmpGroupOfflineNumMap[i],
+				StartDate:  startDateIndexList[i],
+				EndDate:    endDateIndexList[i],
+			}
+			tmpGroupRsReportRecordNumList = append(tmpGroupRsReportRecordNumList, tmpGroupRsReportRecordNum)
+		}
+		groupReportRecord := roadshow.OverseasGroupReportRecord{
+			Item:                  tmpGroupAdminReportRecord,
+			Name:                  v.GroupName,
+			GruopId:               v.GroupId,
+			RsReportRecordNumList: tmpGroupRsReportRecordNumList,
+		}
+		groupReportRecordList = append(groupReportRecordList, groupReportRecord)
+	}
+
+	//总体汇总数据
+	for i := 0; i < len(tmpAllFormalNumMap); i++ {
+		tmpGroupRsReportRecordNum := roadshow.RsOverseasReportRecordNum{
+			TryOutNum:  tmpAllTryOutNumMap[i],
+			FormalNum:  tmpAllFormalNumMap[i],
+			CloseNum:   tmpAllCloseNumMap[i],
+			OnlineNum:  tmpAllOnlineNumMap[i],
+			OfflineNum: tmpAllOfflineNumMap[i],
+			StartDate:  startDateIndexList[i],
+			EndDate:    endDateIndexList[i],
+		}
+		rsAllReportRecordNumList = append(rsAllReportRecordNumList, tmpGroupRsReportRecordNum)
+	}
+	RsReportRecordResp.RsReportRecordNumList = rsAllReportRecordNumList
+
+	//tmpList := groupReportRecordList
+	//因为RoleTypeCode不一样,所以需要重新从数据库取数据
+	//adminInfo, _ := system.GetSysAdminById(sysUser.AdminId)
+	//adminGroupId := adminInfo.GroupId
+	//if tmpGroupId, ok := groupIdRelationMap[adminGroupId]; ok {
+	//	adminGroupId = tmpGroupId
+	//}
+	//switch adminInfo.RoleTypeCode {
+	//case utils.ROLE_TYPE_CODE_FICC_GROUP, utils.ROLE_TYPE_CODE_FICC_TEAM:
+	//	for index, v := range tmpList {
+	//		//如果不是同一个分组,那么就移除该分组下的人员数据
+	//		if v.GruopId != adminGroupId {
+	//			tmpList[index].Item = make([]roadshow.AdminReportRecord, 0)
+	//		}
+	//	}
+	//	RsReportRecordResp.List = tmpList
+	//case utils.ROLE_TYPE_CODE_FICC_ADMIN, utils.ROLE_TYPE_CODE_ADMIN:
+	//	//管理员、超管看全部数据
+	//	RsReportRecordResp.List = groupReportRecordList
+	//}
+
+	// 20230529-有权限查看该页面的用户权限同admin
+	RsReportRecordResp.List = groupReportRecordList
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = RsReportRecordResp
+	return
+}
+
+// OverseasResearcherReportList
+// @Title 研究员路演统计
+// @Description 研究员路演统计接口
+// @Param   DataType   query   string  true       "枚举值:week、month、time_interval"
+// @Param   StartDate   query   string  true       "开始日期,格式:2022-04-06"
+// @Param   EndDate   query   string  true       "结束日期,格式:2022-04-06"
+// @Success 200 {object} roadshow.RsReportRecordResp
+// @router /overseas_custom/researcher/list [get]
+func (this *CalendarController) OverseasResearcherReportList() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.SysUser
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+	dataType := this.GetString("DataType")
+	startDate := this.GetString("StartDate")
+	endDate := this.GetString("EndDate")
+
+	var adminDataList []roadshowService.OverseasAdminDataMap
+	var err error
+	//var firstDate time.Time
+	//获取列表
+	switch dataType {
+	case "week":
+		adminDataList, _, err = roadshowService.GetOverseasWeekData("researcher", "company_status")
+		if err != nil {
+			br.Msg = "数据异常"
+			br.ErrMsg = "数据异常,Err:" + err.Error()
+			return
+		}
+	case "month":
+		adminDataList, _, err = roadshowService.GetOverseasMonthData("researcher", "company_status")
+		if err != nil {
+			br.Msg = "数据异常"
+			br.ErrMsg = "数据异常,Err:" + err.Error()
+			return
+		}
+	case "time_interval":
+		if startDate == `` || endDate == `` {
+			br.Msg = "开始日期或结束日期不能为空"
+			br.ErrMsg = "开始日期或结束日期不能为空,Err:" + err.Error()
+			return
+		}
+		adminDataList, _, err = roadshowService.GetOverseasTimeIntervalData(startDate, endDate, "researcher", "company_status")
+		if err != nil {
+			br.Msg = "数据异常"
+			br.ErrMsg = "数据异常,Err:" + err.Error()
+			return
+		}
+
+	}
+	group, err := roadshow.GetResearcherGroup()
+	if err != nil {
+		br.Msg = "获取信息失败!"
+		br.ErrMsg = "获取分组信息失败!Err:" + err.Error()
+		return
+	}
+	researcherList, err := roadshow.GetResearcherV2()
+	if err != nil {
+		br.Msg = "获取信息失败!"
+		br.ErrMsg = "获取分组信息失败!,GetResearcherV2 Err:" + err.Error()
+		return
+	}
+	groupMap := make(map[int][]*roadshow.Researcher)
+	for _, v := range researcherList {
+		//if v.RoleTypeCode == "ficc_admin" {
+		//	findItems := groupMap[1]
+		//	findItems = append(findItems, v)
+		//	groupMap[1] = findItems
+		//} else {
+		if findItems, ok := groupMap[v.GroupId]; ok {
+			findItems = append(findItems, v)
+			groupMap[v.GroupId] = findItems
+		} else {
+			findItems = append(findItems, v)
+			groupMap[v.GroupId] = findItems
+		}
+		//}
+	}
+
+	groupReportRecordList := make([]roadshow.OverseasGroupReportRecord, 0)
+	rsAllReportRecordNumList := make([]roadshow.RsOverseasReportRecordNum, 0)
+	RsReportRecordResp := roadshow.RsOverseasReportRecordResp{
+		List:                  groupReportRecordList,
+		RsReportRecordNumList: rsAllReportRecordNumList,
+	}
+
+	startDateIndexList := make(map[int]string) //开始时间间隔map
+	endDateIndexList := make(map[int]string)   //结束时间间隔map
+
+	tmpAllTryOutNumMap := make(map[int]int)
+	tmpAllFormalNumMap := make(map[int]int)
+	tmpAllMeetingNumMap := make(map[int]int)
+	for _, v := range group {
+		v.ResearcherList = groupMap[v.GroupId]
+		tmpGroupAdminReportRecord := make([]roadshow.OverseasAdminReportRecord, 0)
+		tmpGroupRsReportRecordNumList := make([]roadshow.RsOverseasReportRecordNum, 0)
+
+		tmpGroupTryOutNumMap := make(map[int]int)
+		tmpGroupFormalNumMap := make(map[int]int)
+		tmpGroupCloseNumMap := make(map[int]int)
+		for _, researcher := range groupMap[v.GroupId] {
+			//组内研究员数据
+
+			//每个区间的数据
+			tmpAdminRsReportRecordNumList := make([]roadshow.RsOverseasReportRecordNum, 0)
+			for index, adminData := range adminDataList {
+				startDateIndexList[index] = adminData.StartDate
+				endDateIndexList[index] = adminData.EndDate
+
+				var tmpTryOutNum, tmpFormalNum, tmpCloseNum int
+				if num, ok := adminData.TryOutMap[researcher.AdminId]; ok {
+					tmpTryOutNum = num
+				}
+				if num, ok := adminData.FormalMap[researcher.AdminId]; ok {
+					tmpFormalNum = num
+				}
+				if num, ok := adminData.CloseMap[researcher.AdminId]; ok {
+					tmpCloseNum = num
+				}
+				tmpAdminRsReportRecordNum := roadshow.RsOverseasReportRecordNum{
+					TryOutNum: tmpTryOutNum,
+					FormalNum: tmpFormalNum,
+					CloseNum:  tmpCloseNum,
+					StartDate: adminData.StartDate,
+					EndDate:   adminData.EndDate,
+				}
+				tmpAdminRsReportRecordNumList = append(tmpAdminRsReportRecordNumList, tmpAdminRsReportRecordNum)
+
+				//组内数据汇总
+				if _, ok := tmpGroupTryOutNumMap[index]; !ok {
+					tmpGroupTryOutNumMap[index] = 0
+				}
+				if _, ok := tmpGroupFormalNumMap[index]; !ok {
+					tmpGroupFormalNumMap[index] = 0
+				}
+				if _, ok := tmpGroupCloseNumMap[index]; !ok {
+					tmpGroupCloseNumMap[index] = 0
+				}
+				tmpGroupTryOutNumMap[index] += tmpTryOutNum
+				tmpGroupFormalNumMap[index] += tmpFormalNum
+				tmpGroupCloseNumMap[index] += tmpCloseNum
+
+				//总数据汇总
+				if _, ok := tmpAllTryOutNumMap[index]; !ok {
+					tmpAllTryOutNumMap[index] = 0
+				}
+				if _, ok := tmpAllFormalNumMap[index]; !ok {
+					tmpAllFormalNumMap[index] = 0
+				}
+				if _, ok := tmpAllMeetingNumMap[index]; !ok {
+					tmpAllMeetingNumMap[index] = 0
+				}
+				tmpAllTryOutNumMap[index] += tmpTryOutNum
+				tmpAllFormalNumMap[index] += tmpFormalNum
+				tmpAllMeetingNumMap[index] += tmpCloseNum
+			}
+			tmpAdminReportRecord := roadshow.OverseasAdminReportRecord{
+				Name:                  researcher.RealName,
+				AdminId:               researcher.AdminId,
+				RsReportRecordNumList: tmpAdminRsReportRecordNumList,
+			}
+			tmpGroupAdminReportRecord = append(tmpGroupAdminReportRecord, tmpAdminReportRecord)
+		}
+
+		for i := 0; i < len(tmpGroupCloseNumMap); i++ {
+			tmpGroupRsReportRecordNum := roadshow.RsOverseasReportRecordNum{
+				TryOutNum: tmpGroupTryOutNumMap[i],
+				FormalNum: tmpGroupFormalNumMap[i],
+				CloseNum:  tmpGroupCloseNumMap[i],
+				StartDate: startDateIndexList[i],
+				EndDate:   endDateIndexList[i],
+			}
+			tmpGroupRsReportRecordNumList = append(tmpGroupRsReportRecordNumList, tmpGroupRsReportRecordNum)
+		}
+		groupReportRecord := roadshow.OverseasGroupReportRecord{
+			Item:                  tmpGroupAdminReportRecord,
+			Name:                  v.GroupName,
+			RsReportRecordNumList: tmpGroupRsReportRecordNumList,
+		}
+		RsReportRecordResp.List = append(RsReportRecordResp.List, groupReportRecord)
+	}
+
+	//总体汇总数据
+	for i := 0; i < len(tmpAllFormalNumMap); i++ {
+		tmpGroupRsReportRecordNum := roadshow.RsOverseasReportRecordNum{
+			TryOutNum: tmpAllTryOutNumMap[i],
+			FormalNum: tmpAllFormalNumMap[i],
+			CloseNum:  tmpAllMeetingNumMap[i],
+			StartDate: startDateIndexList[i],
+			EndDate:   endDateIndexList[i],
+		}
+		rsAllReportRecordNumList = append(rsAllReportRecordNumList, tmpGroupRsReportRecordNum)
+	}
+	RsReportRecordResp.RsReportRecordNumList = rsAllReportRecordNumList
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = RsReportRecordResp
+	return
+}

+ 7 - 0
models/company/company.go

@@ -1958,3 +1958,10 @@ func GetCompanyListByCondition(condition string, pars []interface{}, fieldArr []
 	_, err = o.Raw(sql, pars).QueryRows(&items)
 	return
 }
+
+func GetOverseasCompanys() (items []*Company, err error) {
+	o := orm.NewOrm()
+	sql := ` SELECT * FROM company where region_type= '海外' `
+	err = o.Raw(sql).QueryRow(&items)
+	return
+}

+ 49 - 0
models/roadshow/report_record.go

@@ -229,3 +229,52 @@ func GetBusinessTripList(adminId int, startDate, endDate string) (list []*Busine
 	}
 	return
 }
+
+// GetOverseasGroupSellerRecordList 获取销售分组数据
+func GetOverseasGroupSellerRecordList(condition string, pars []interface{}) (list []*RsReportRecordGroup, err error) {
+	o := orm.NewOrm()
+	sql := ` SELECT seller_id as admin_id,seller_group_id as group_id,seller_name admin_name,count(1) num
+				FROM  rs_report_record 
+				WHERE 1=1 and rs_calendar_researcher_status = 2 
+ `
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` GROUP BY seller_id`
+	_, err = o.Raw(sql, pars).QueryRows(&list)
+
+	return
+}
+
+// OverseasAdminReportRecord 系统用户统计信息
+type OverseasAdminReportRecord struct {
+	Name                  string                      `description:"系统用户名"`
+	AdminId               int                         `description:"系统用户id"`
+	RsReportRecordNumList []RsOverseasReportRecordNum `description:"统计次数"`
+}
+
+// RsOverseasReportRecordNum 系统用户统计信息
+type RsOverseasReportRecordNum struct {
+	TryOutNum  int    `description:"试用路演次数"`
+	FormalNum  int    `description:"正式路演次数"`
+	CloseNum   int    `description:"关闭客户次数"`
+	OnlineNum  int    `description:"线上路演次数"`
+	OfflineNum int    `description:"线上路演次数"`
+	StartDate  string `description:"开始日期"`
+	EndDate    string `description:"结束日期"`
+	IsLook     bool   `description:"是否可以查看详情"`
+}
+
+// RsOverseasReportRecordResp 总统计信息
+type RsOverseasReportRecordResp struct {
+	List                  []OverseasGroupReportRecord `description:"系统用户分组信息"`
+	RsReportRecordNumList []RsOverseasReportRecordNum `description:"统计次数"`
+}
+
+// OverseasGroupReportRecord 分组统计信息
+type OverseasGroupReportRecord struct {
+	Item                  []OverseasAdminReportRecord `description:"系统用户信息"`
+	Name                  string                      `description:"分组名"`
+	GruopId               int                         `description:"分组id"`
+	RsReportRecordNumList []RsOverseasReportRecordNum `description:"统计次数"`
+}

+ 18 - 0
routers/commentsRouter.go

@@ -7477,6 +7477,24 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/roadshow:CalendarController"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/roadshow:CalendarController"],
+        beego.ControllerComments{
+            Method: "OverseasResearcherReportList",
+            Router: `/overseas_custom/researcher/list`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/roadshow:CalendarController"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/roadshow:CalendarController"],
+        beego.ControllerComments{
+            Method: "OverseasSellerReportList",
+            Router: `/overseas_custom/seller/list`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/roadshow:CalendarController"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/roadshow:CalendarController"],
         beego.ControllerComments{
             Method: "OverseasCustomCalendarAdminList",

+ 479 - 0
services/roadshow/report.go

@@ -1,6 +1,7 @@
 package roadshow
 
 import (
+	"fmt"
 	"hongze/hz_crm_api/models/company"
 	"hongze/hz_crm_api/models/roadshow"
 	"hongze/hz_crm_api/utils"
@@ -447,3 +448,481 @@ func getSellerSectionData(startDate, endDate time.Time, dimensionType string) (a
 	}
 	return
 }
+
+type OverseasAdminDataMap struct {
+	TryOutMap  map[int]int `description:"试用路演次数"`
+	FormalMap  map[int]int `description:"正式路演次数"`
+	CloseMap   map[int]int `description:"关闭客户次数"`
+	OnlineMap  map[int]int `description:"线上路演次数"`
+	OfflineMap map[int]int `description:"线上路演次数"`
+	StartDate  string      `description:"开始日期"`
+	EndDate    string      `description:"开始日期"`
+}
+
+// GetOverseasWeekDataV2 周度数据
+func GetOverseasWeekDataV2(adminType, dimensionType string, weekNum int) (adminDataList []OverseasAdminDataMap, firstDate time.Time, err error) {
+	nowWeekMonday := utils.GetNowWeekMonday() //本周周一
+	//fmt.Println(nowWeekMonday)
+	nowWeekSunday := nowWeekMonday.AddDate(0, 0, 7).Add(-1 * time.Second) //本周周日
+	chanList := make([]chan OverseasAdminDataMap, 0)
+	for i := 0; i < weekNum; i++ {
+		tmpCh := make(chan OverseasAdminDataMap, 0)
+		chanList = append(chanList, tmpCh)
+
+		lastWeekMonday := nowWeekMonday.AddDate(0, 0, -7*i)
+		lastWeekSunday := nowWeekSunday.AddDate(0, 0, -7*i)
+
+		// 第一个开始日期
+		firstDate = lastWeekMonday
+		go getOverseasSectionData(lastWeekMonday, lastWeekSunday, adminType, dimensionType, tmpCh)
+	}
+
+	adminDataList = make([]OverseasAdminDataMap, 0)
+	for _, vChan := range chanList {
+		var weekAdminDataMap OverseasAdminDataMap
+		weekAdminDataMap = <-vChan
+		close(vChan)
+		adminDataList = append(adminDataList, weekAdminDataMap)
+	}
+
+	return
+}
+
+// getOverseasSectionData 获取周期数据
+func getOverseasSectionData(startDate, endDate time.Time, adminType, dimensionType string, ch chan OverseasAdminDataMap) (adminDataMap OverseasAdminDataMap, err error) {
+	defer func() {
+		ch <- adminDataMap
+	}()
+	//adminType := `seller`
+	switch adminType {
+	case "researcher":
+		adminDataMap, err = getOverseasResearcherSectionData(startDate, endDate)
+	case "seller":
+		adminDataMap, err = getOverseasSellerSectionData(startDate, endDate, dimensionType)
+	}
+	return
+}
+
+// getOverseasSellerSectionData 获取销售周期数据
+func getOverseasSellerSectionData(startDate, endDate time.Time, dimensionType string) (adminDataMap OverseasAdminDataMap, err error) {
+	tryOutMap := make(map[int]int)
+	formalMap := make(map[int]int)
+	closeMap := make(map[int]int)
+	onlineMap := make(map[int]int)
+	offlineMap := make(map[int]int)
+	//fmt.Println()
+	//客户状态维度
+	companylist, err := company.GetOverseasCompanys()
+	if err != nil {
+		return
+	}
+	idsArr := make([]int, 0)
+	for _, v := range companylist {
+		idsArr = append(idsArr, v.CompanyId)
+	}
+	if dimensionType == "company_status" {
+		//正式客户
+		{
+			var condition string
+			var pars []interface{}
+			condition = ` and start_date >= ? and end_date <= ?  and company_status = ? and company_id IN (` + utils.GetOrmInReplace(len(idsArr)) + `)`
+			pars = append(pars, startDate, endDate, "正式", idsArr)
+			data, tmpErr := roadshow.GetOverseasGroupSellerRecordList(condition, pars)
+			if tmpErr != nil {
+				err = tmpErr
+				return
+			}
+			for _, v := range data {
+				fmt.Println(v)
+				formalMap[v.AdminId] = v.Num
+			}
+		}
+
+		//试用客户
+		{
+			var condition string
+			var pars []interface{}
+			condition = ` and start_date >= ? and end_date <= ? and company_status = ? and company_id IN (` + utils.GetOrmInReplace(len(idsArr)) + `)`
+			pars = append(pars, startDate, endDate, "试用", idsArr)
+			data, tmpErr := roadshow.GetOverseasGroupSellerRecordList(condition, pars)
+
+			if tmpErr != nil {
+				err = tmpErr
+				return
+			}
+			for _, v := range data {
+				//fmt.Println(v)
+				tryOutMap[v.AdminId] = v.Num
+			}
+		}
+
+		//关闭客户
+		{
+			var condition string
+			var pars []interface{}
+			condition = ` and start_date >= ? and end_date <= ? and company_status = ? and company_id IN (` + utils.GetOrmInReplace(len(idsArr)) + `)`
+			pars = append(pars, startDate, endDate, "关闭", idsArr)
+			data, tmpErr := roadshow.GetOverseasGroupSellerRecordList(condition, pars)
+
+			if tmpErr != nil {
+				err = tmpErr
+				return
+			}
+			for _, v := range data {
+				//fmt.Println(v)
+				closeMap[v.AdminId] = v.Num
+			}
+		}
+	}
+
+	//路演形式维度
+	if dimensionType == "roadshow_type" {
+		//线上路演
+		{
+			var condition string
+			var pars []interface{}
+			condition = ` and start_date >= ? and end_date <= ? and roadshow_type = ? and company_id IN (` + utils.GetOrmInReplace(len(idsArr)) + `)`
+			pars = append(pars, startDate, endDate, "线上", idsArr)
+			data, tmpErr := roadshow.GetOverseasGroupSellerRecordList(condition, pars)
+			if tmpErr != nil {
+				err = tmpErr
+				return
+			}
+			for _, v := range data {
+				//fmt.Println(v)
+				onlineMap[v.AdminId] = v.Num
+			}
+		}
+
+		//线下路演
+		{
+			var condition string
+			var pars []interface{}
+			condition = ` and start_date >= ? and end_date <= ? and roadshow_type = ? and company_id IN (` + utils.GetOrmInReplace(len(idsArr)) + `)`
+			pars = append(pars, startDate, endDate, "线下", idsArr)
+			data, tmpErr := roadshow.GetOverseasGroupSellerRecordList(condition, pars)
+			if tmpErr != nil {
+				err = tmpErr
+				return
+			}
+			for _, v := range data {
+				//fmt.Println(v)
+				offlineMap[v.AdminId] = v.Num
+			}
+		}
+	}
+
+	////销售专项路演统计
+	//if dimensionType == "seller_special" {
+	//
+	//	detail, errdetail := company.GetConfigDetailByCode("choice_researcher_adminid")
+	//	if errdetail != nil {
+	//		err = errdetail
+	//		return
+	//	}
+	//	//正式客户
+	//	{
+	//		var condition string
+	//		var pars []interface{}
+	//		condition = ` and start_date >= ? and end_date <= ?  and company_status = ? ` + ` and researcher_id IN (` + detail.ConfigValue + `) `
+	//		pars = append(pars, startDate, endDate, "正式")
+	//		data, tmpErr := roadshow.GetOverseasGroupSellerRecordList(condition, pars)
+	//		if tmpErr != nil {
+	//			err = tmpErr
+	//			return
+	//		}
+	//		for _, v := range data {
+	//			formalMap[v.AdminId] = v.Num
+	//		}
+	//	}
+	//
+	//	//试用客户
+	//	{
+	//		var condition string
+	//		var pars []interface{}
+	//		condition = ` and start_date >= ? and end_date <= ? and company_status = ? ` + ` and researcher_id IN (` + detail.ConfigValue + `) `
+	//		pars = append(pars, startDate, endDate, "试用")
+	//		data, tmpErr := roadshow.GetOverseasGroupSellerRecordList(condition, pars)
+	//
+	//		if tmpErr != nil {
+	//			err = tmpErr
+	//			return
+	//		}
+	//		for _, v := range data {
+	//			//fmt.Println(v)
+	//			tryOutMap[v.AdminId] = v.Num
+	//		}
+	//	}
+	//
+	//	//公开会议
+	//	{
+	//		var condition string
+	//		var pars []interface{}
+	//		condition = ` and start_date >= ? and end_date <= ? and activity_type = ? ` + ` and researcher_id IN (` + detail.ConfigValue + `) `
+	//		pars = append(pars, startDate, endDate, "公开会议")
+	//		data, tmpErr := roadshow.GetOverseasGroupSellerRecordList(condition, pars)
+	//		if tmpErr != nil {
+	//			err = tmpErr
+	//			return
+	//		}
+	//		for _, v := range data {
+	//			//fmt.Println(v)
+	//			meetingMap[v.AdminId] = v.Num
+	//		}
+	//	}
+	//} else {
+	//	//公开会议
+	//	{
+	//		var condition string
+	//		var pars []interface{}
+	//		condition = ` and start_date >= ? and end_date <= ? and activity_type = ? `
+	//		pars = append(pars, startDate, endDate, "公开会议")
+	//		data, tmpErr := roadshow.GetOverseasGroupSellerRecordList(condition, pars)
+	//		if tmpErr != nil {
+	//			err = tmpErr
+	//			return
+	//		}
+	//		for _, v := range data {
+	//			//fmt.Println(v)
+	//			meetingMap[v.AdminId] = v.Num
+	//		}
+	//	}
+	//}
+
+	adminDataMap = OverseasAdminDataMap{
+		TryOutMap:  tryOutMap,
+		FormalMap:  formalMap,
+		CloseMap:   closeMap,
+		OfflineMap: offlineMap,
+		OnlineMap:  onlineMap,
+		StartDate:  startDate.Format(utils.FormatDate),
+		EndDate:    endDate.Format(utils.FormatDate),
+	}
+	return
+}
+
+// getOverseasResearcherSectionData 获取研究员周期数据
+func getOverseasResearcherSectionData(startDate, endDate time.Time) (adminDataMap OverseasAdminDataMap, err error) {
+	tryOutMap := make(map[int]int)
+	formalMap := make(map[int]int)
+	closemap := make(map[int]int)
+
+	companylist, err := company.GetOverseasCompanys()
+	if err != nil {
+		return
+	}
+	idsArr := make([]int, 0)
+	for _, v := range companylist {
+		idsArr = append(idsArr, v.CompanyId)
+	}
+	//正式客户
+	{
+		var condition string
+		var pars []interface{}
+		condition = ` and start_date >= ? and end_date <= ?  and company_status = ? and is_overseas=0 and company_id IN (` + utils.GetOrmInReplace(len(idsArr)) + `)`
+		pars = append(pars, startDate, endDate, "正式", idsArr)
+		data, tmpErr := roadshow.GetGroupResearcherRecordList(condition, pars)
+		if tmpErr != nil {
+			err = tmpErr
+			return
+		}
+		for _, v := range data {
+			formalMap[v.AdminId] = v.Num
+		}
+	}
+
+	//试用客户
+	{
+		var condition string
+		var pars []interface{}
+		condition = ` and start_date >= ? and end_date <= ? and company_status = ? and is_overseas=0 and company_id IN (` + utils.GetOrmInReplace(len(idsArr)) + `)`
+		pars = append(pars, startDate, endDate, "试用", idsArr)
+		data, tmpErr := roadshow.GetGroupResearcherRecordList(condition, pars)
+
+		if tmpErr != nil {
+			err = tmpErr
+			return
+		}
+		for _, v := range data {
+			//fmt.Println(v)
+			tryOutMap[v.AdminId] = v.Num
+		}
+	}
+
+	//试用客户
+	{
+		var condition string
+		var pars []interface{}
+		condition = ` and start_date >= ? and end_date <= ? and company_status = ? and is_overseas=0 and company_id IN (` + utils.GetOrmInReplace(len(idsArr)) + `)`
+		pars = append(pars, startDate, endDate, "关闭", idsArr)
+		data, tmpErr := roadshow.GetGroupResearcherRecordList(condition, pars)
+		if tmpErr != nil {
+			err = tmpErr
+			return
+		}
+		for _, v := range data {
+			//fmt.Println(v)
+			closemap[v.AdminId] = v.Num
+		}
+	}
+
+	adminDataMap = OverseasAdminDataMap{
+		TryOutMap: tryOutMap,
+		FormalMap: formalMap,
+		CloseMap:  closemap,
+		StartDate: startDate.Format(utils.FormatDate),
+		EndDate:   endDate.Format(utils.FormatDate),
+	}
+	return
+}
+
+// GetOverseasMonthDataV2 月度数据
+func GetOverseasMonthDataV2(adminType, dimensionType string, dataNum int) (adminDataMapList []OverseasAdminDataMap, firstDate time.Time, err error) { //三个协程返回
+	nowMonthFirstDay := utils.GetNowMonthFirstDay() //本月第一天
+	//nowMonthLastDay := nowMonthFirstDay.AddDate(0, 1, 0).Add(-1 * time.Second) //本月最后一天
+
+	chanList := make([]chan OverseasAdminDataMap, 0)
+	for i := 0; i < dataNum; i++ {
+		tmpCh := make(chan OverseasAdminDataMap, 0)
+		chanList = append(chanList, tmpCh)
+
+		lastMonthFirstDay := nowMonthFirstDay.AddDate(0, -1*i, 0)                          //上个月第一天
+		lastMonthLastDay := nowMonthFirstDay.AddDate(0, -1*(i-1), 0).Add(-1 * time.Second) //上个月最后一天
+
+		// 第一个开始日期
+		firstDate = lastMonthFirstDay
+		go getOverseasSectionData(lastMonthFirstDay, lastMonthLastDay, adminType, dimensionType, tmpCh)
+	}
+
+	adminDataMapList = make([]OverseasAdminDataMap, 0)
+	for _, vChan := range chanList {
+		var monthAdminDataMap OverseasAdminDataMap
+		monthAdminDataMap = <-vChan
+		close(vChan)
+		adminDataMapList = append(adminDataMapList, monthAdminDataMap)
+	}
+
+	return
+}
+
+// GetOverseasTimeIntervalData 区间数据
+func GetOverseasTimeIntervalData(startDate, endDate, adminType, dimensionType string) (adminDataMapList []OverseasAdminDataMap, firstDate time.Time, err error) { //三个协程返回
+	startDateTimer, _ := time.ParseInLocation(utils.FormatDate, startDate, time.Local)
+	endDateTimer, _ := time.ParseInLocation(utils.FormatDate, endDate, time.Local)
+	endDateTimer = endDateTimer.AddDate(0, 0, 1).Add(-1 * time.Second) //本月最后一天
+
+	//最早的一天
+	firstDate = startDateTimer
+
+	ch1 := make(chan OverseasAdminDataMap, 0)
+
+	go getOverseasSectionData(startDateTimer, endDateTimer, adminType, dimensionType, ch1)
+
+	var adminDataMap OverseasAdminDataMap
+
+	adminDataMap = <-ch1
+	close(ch1)
+
+	adminDataMapList = make([]OverseasAdminDataMap, 0)
+	adminDataMapList = append(adminDataMapList, adminDataMap)
+	return
+}
+
+// GetOverseasWeekData 周度数据
+func GetOverseasWeekData(adminType, dimensionType string) (adminDataList []OverseasAdminDataMap, firstDate time.Time, err error) {
+	nowWeekMonday := utils.GetNowWeekMonday() //本周周一
+	//fmt.Println(nowWeekMonday)
+	nowWeekSunday := nowWeekMonday.AddDate(0, 0, 7).Add(-1 * time.Second) //本周周日
+	//fmt.Println(nowWeekSunday)
+
+	//nowWeekMonday = nowWeekMonday.AddDate(0, 0, -30) //上周周一
+	//nowWeekSunday = nowWeekSunday.AddDate(0, 0, -30) //上周周日
+
+	//adminDataMap, err := getSectionData(nowWeekMonday, nowWeekSunday)
+	//if err != nil {
+	//	fmt.Println(err)
+	//	return
+	//}
+	//fmt.Println(adminDataMap)
+
+	lastWeekMonday := nowWeekMonday.AddDate(0, 0, -7) //上周周一
+	//fmt.Println(lastWeekMonday)
+	//最早的一天
+	firstDate = lastWeekMonday
+	lastWeekSunday := nowWeekSunday.AddDate(0, 0, -7) //上周周日
+	//fmt.Println(lastWeekSunday)
+
+	nextWeekMonday := nowWeekMonday.AddDate(0, 0, 7) //下周周一
+	//fmt.Println(nextWeekMonday)
+	nextWeekSunday := nowWeekSunday.AddDate(0, 0, 7) //下周周日
+	//fmt.Println(nextWeekSunday)
+
+	ch1 := make(chan OverseasAdminDataMap, 0)
+	ch2 := make(chan OverseasAdminDataMap, 0)
+	ch3 := make(chan OverseasAdminDataMap, 0)
+
+	go getOverseasSectionData(lastWeekMonday, lastWeekSunday, adminType, dimensionType, ch1)
+	go getOverseasSectionData(nowWeekMonday, nowWeekSunday, adminType, dimensionType, ch2)
+	go getOverseasSectionData(nextWeekMonday, nextWeekSunday, adminType, dimensionType, ch3)
+
+	var nowWeekAdminDataMap, lastWeekAdminDataMap, nextWeekAdminDataMap OverseasAdminDataMap
+
+	lastWeekAdminDataMap = <-ch1
+	close(ch1)
+
+	nowWeekAdminDataMap = <-ch2
+	close(ch2)
+
+	nextWeekAdminDataMap = <-ch3
+	close(ch3)
+
+	adminDataList = make([]OverseasAdminDataMap, 0)
+	adminDataList = append(adminDataList, lastWeekAdminDataMap, nowWeekAdminDataMap, nextWeekAdminDataMap)
+	return
+}
+
+// GetOverseasMonthData 月度数据
+func GetOverseasMonthData(adminType, dimensionType string) (adminDataMapList []OverseasAdminDataMap, firstDate time.Time, err error) { //三个协程返回
+	nowMonthFirstDay := utils.GetNowMonthFirstDay()                            //本月第一天
+	nowMonthLastDay := nowMonthFirstDay.AddDate(0, 1, 0).Add(-1 * time.Second) //本月最后一天
+
+	lastMonthFirstDay1 := nowMonthFirstDay.AddDate(0, -1, 0)                       //上个月第一天
+	lastMonthLastDay1 := lastMonthFirstDay1.AddDate(0, 1, 0).Add(-1 * time.Second) //上个月最后一天
+
+	lastMonthFirstDay2 := nowMonthFirstDay.AddDate(0, -2, 0)                       //上上个月第一天
+	lastMonthLastDay2 := lastMonthFirstDay2.AddDate(0, 1, 0).Add(-1 * time.Second) //上上个月最后一天
+
+	lastMonthFirstDay3 := nowMonthFirstDay.AddDate(0, -3, 0)                       //上上上个月第一天
+	lastMonthLastDay3 := lastMonthFirstDay3.AddDate(0, 1, 0).Add(-1 * time.Second) //上上上个月最后一天
+
+	//最早的一天
+	firstDate = lastMonthFirstDay3
+
+	ch1 := make(chan OverseasAdminDataMap, 0)
+	ch2 := make(chan OverseasAdminDataMap, 0)
+	ch3 := make(chan OverseasAdminDataMap, 0)
+	ch4 := make(chan OverseasAdminDataMap, 0)
+
+	go getOverseasSectionData(nowMonthFirstDay, nowMonthLastDay, adminType, dimensionType, ch1)
+	go getOverseasSectionData(lastMonthFirstDay1, lastMonthLastDay1, adminType, dimensionType, ch2)
+	go getOverseasSectionData(lastMonthFirstDay2, lastMonthLastDay2, adminType, dimensionType, ch3)
+	go getOverseasSectionData(lastMonthFirstDay3, lastMonthLastDay3, adminType, dimensionType, ch4)
+
+	var nowMonthAdminDataMap, lastMonthAdminDataMap1, lastMonthAdminDataMap2, lastMonthAdminDataMap3 OverseasAdminDataMap
+
+	nowMonthAdminDataMap = <-ch1
+	close(ch1)
+
+	lastMonthAdminDataMap1 = <-ch2
+	close(ch2)
+
+	lastMonthAdminDataMap2 = <-ch3
+	close(ch3)
+
+	lastMonthAdminDataMap3 = <-ch4
+	close(ch4)
+
+	adminDataMapList = make([]OverseasAdminDataMap, 0)
+	adminDataMapList = append(adminDataMapList, nowMonthAdminDataMap, lastMonthAdminDataMap1, lastMonthAdminDataMap2, lastMonthAdminDataMap3)
+	return
+}