123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872 |
- package roadshow
- import (
- "encoding/json"
- "github.com/rdlucklib/rdluck_tools/paging"
- "hongze/hz_crm_api/models"
- "hongze/hz_crm_api/models/company"
- "hongze/hz_crm_api/models/cygx"
- "hongze/hz_crm_api/models/roadshow"
- "hongze/hz_crm_api/models/system"
- "hongze/hz_crm_api/services"
- roadshowService "hongze/hz_crm_api/services/roadshow"
- "hongze/hz_crm_api/utils"
- "strconv"
- "strings"
- "time"
- )
- // ResearcherReportList
- // @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"
- // @Param CompanyType query string true "客户类型:'ficc','权益',传空默认为ficc,"
- // @Success 200 {object} roadshow.RsReportRecordResp
- // @router /report/researcher/list [get]
- func (this *CalendarController) ResearcherReportList() {
- 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")
- companyType := this.GetString("CompanyType", "ficc")
- var adminDataList []roadshowService.AdminDataMap
- var err error
- //var firstDate time.Time
- //获取列表
- switch dataType {
- case "week":
- adminDataList, _, err = roadshowService.GetWeekData("researcher", "company_status")
- if err != nil {
- br.Msg = "数据异常"
- br.ErrMsg = "数据异常,Err:" + err.Error()
- return
- }
- case "month":
- adminDataList, _, err = roadshowService.GetMonthData("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.GetTimeIntervalData(startDate, endDate, "researcher", "company_status")
- if err != nil {
- br.Msg = "数据异常"
- br.ErrMsg = "数据异常,Err:" + err.Error()
- return
- }
- }
- var group []*roadshow.ResearcherGroup
- var researcherList []*roadshow.ResearcherGroup
- switch companyType {
- case utils.COMPANY_CLASSIFY_FICC:
- 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
- }
- case utils.COMPANY_CLASSIFY_RAI:
- mapPermissionUser := make(map[string][]*roadshow.ResearcherGroup)
- listPermission, err := cygx.GetChartPermissionAll()
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- mapPermissionId := make(map[string]int)
- for _, v := range listPermission {
- mapPermissionId[v.PermissionName] = v.ChartPermissionId
- }
- askUserList, err := cygx.GetAskEmailListResearcher()
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,GetAskEmailListResearcher Err: " + err.Error()
- return
- }
- sysUserList, err := system.GetAdminList()
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取admin列表失败, Err:" + err.Error()
- return
- }
- adminMap := make(map[int]*system.Admin, 0)
- for _, v := range sysUserList {
- adminMap[v.AdminId] = v
- }
- for _, v := range askUserList {
- if admin, ok := adminMap[v.AdminId]; ok {
- item := &roadshow.ResearcherGroup{
- AdminId: v.AdminId,
- RealName: v.Name,
- GroupId: mapPermissionId[v.ChartPermissionName], //行业ID作为组别,进行关系映射
- GroupName: admin.GroupName,
- RoleTypeCode: admin.RoleTypeCode,
- }
- mapPermissionUser[v.ChartPermissionName] = append(mapPermissionUser[v.ChartPermissionName], item)
- researcherList = append(researcherList, item)
- }
- }
- for k, v := range mapPermissionUser {
- respItem := new(roadshow.ResearcherGroup)
- respItem.GroupName = k + "组"
- respItem.GroupId = mapPermissionId[k]
- respItem.ResearcherList = v
- group = append(group, respItem)
- }
- }
- groupMap := make(map[int][]*roadshow.ResearcherGroup)
- for _, v := range researcherList {
- item := &roadshow.ResearcherGroup{
- GroupId: v.GroupId,
- GroupName: v.GroupName,
- AdminId: v.AdminId,
- RealName: v.RealName,
- RoleTypeCode: v.RoleTypeCode,
- }
- if findItems, ok := groupMap[v.GroupId]; ok {
- findItems = append(findItems, item)
- groupMap[v.GroupId] = findItems
- } else {
- findItems = append(findItems, item)
- groupMap[v.GroupId] = findItems
- }
- //}
- }
- for _, v := range group {
- v.ResearcherList = groupMap[v.GroupId]
- }
- groupReportRecordList := make([]roadshow.GroupReportRecord, 0)
- rsAllReportRecordNumList := make([]roadshow.RsReportRecordNum, 0)
- RsReportRecordResp := roadshow.RsReportRecordResp{
- 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)
- tmpAllRoadShowNumMap := make(map[int]int)
- tmpAllSalonNumMap := make(map[int]int)
- for _, v := range group {
- v.ResearcherList = groupMap[v.GroupId]
- tmpGroupAdminReportRecord := make([]roadshow.AdminReportRecord, 0)
- tmpGroupRsReportRecordNumList := make([]roadshow.RsReportRecordNum, 0)
- //roadShowMap := make(map[int]int) // 路演总次数
- //salonMap := make(map[int]int) //沙龙路演次数
- tmpGroupTryOutNumMap := make(map[int]int)
- tmpGroupFormalNumMap := make(map[int]int)
- tmpGroupMeetingNumMap := make(map[int]int)
- tmpGroupRoadShowNumMap := make(map[int]int)
- tmpGroupSalonMapNumMap := make(map[int]int)
- for _, researcher := range groupMap[v.GroupId] {
- //组内研究员数据
- //每个区间的数据
- tmpAdminRsReportRecordNumList := make([]roadshow.RsReportRecordNum, 0)
- for index, adminData := range adminDataList {
- startDateIndexList[index] = adminData.StartDate
- endDateIndexList[index] = adminData.EndDate
- var tmpTryOutNum, tmpFormalNum, tmpMeetingNum, tmpRoadShowNum, tmpSalonNum 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.MeetingMap[researcher.AdminId]; ok {
- tmpMeetingNum = num
- }
- if num, ok := adminData.RoadShowMap[researcher.AdminId]; ok { //路演总次数
- tmpRoadShowNum = num
- }
- if num, ok := adminData.SalonMap[researcher.AdminId]; ok { //路演总次数
- tmpSalonNum = num
- }
- tmpAdminRsReportRecordNum := roadshow.RsReportRecordNum{
- TryOutNum: tmpTryOutNum,
- FormalNum: tmpFormalNum,
- MeetingNum: tmpMeetingNum,
- RoadShowNum: tmpRoadShowNum,
- SalonNum: tmpSalonNum,
- 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 := tmpGroupMeetingNumMap[index]; !ok {
- tmpGroupMeetingNumMap[index] = 0
- }
- if _, ok := tmpGroupRoadShowNumMap[index]; !ok {
- tmpGroupRoadShowNumMap[index] = 0
- }
- if _, ok := tmpGroupSalonMapNumMap[index]; !ok {
- tmpGroupSalonMapNumMap[index] = 0
- }
- tmpGroupTryOutNumMap[index] += tmpTryOutNum
- tmpGroupFormalNumMap[index] += tmpFormalNum
- tmpGroupMeetingNumMap[index] += tmpMeetingNum
- tmpGroupRoadShowNumMap[index] += tmpRoadShowNum
- tmpGroupSalonMapNumMap[index] += tmpSalonNum
- //总数据汇总
- if _, ok := tmpAllTryOutNumMap[index]; !ok {
- tmpAllTryOutNumMap[index] = 0
- }
- if _, ok := tmpAllFormalNumMap[index]; !ok {
- tmpAllFormalNumMap[index] = 0
- }
- if _, ok := tmpAllMeetingNumMap[index]; !ok {
- tmpAllMeetingNumMap[index] = 0
- }
- if _, ok := tmpGroupRoadShowNumMap[index]; !ok {
- tmpGroupRoadShowNumMap[index] = 0
- }
- if _, ok := tmpGroupSalonMapNumMap[index]; !ok {
- tmpGroupSalonMapNumMap[index] = 0
- }
- tmpAllTryOutNumMap[index] += tmpTryOutNum
- tmpAllFormalNumMap[index] += tmpFormalNum
- tmpAllMeetingNumMap[index] += tmpMeetingNum
- tmpAllRoadShowNumMap[index] += tmpRoadShowNum
- tmpAllSalonNumMap[index] += tmpSalonNum
- }
- tmpAdminReportRecord := roadshow.AdminReportRecord{
- Name: researcher.RealName,
- AdminId: researcher.AdminId,
- RsReportRecordNumList: tmpAdminRsReportRecordNumList,
- }
- tmpGroupAdminReportRecord = append(tmpGroupAdminReportRecord, tmpAdminReportRecord)
- }
- for i := 0; i < len(tmpGroupMeetingNumMap); i++ {
- tmpGroupRsReportRecordNum := roadshow.RsReportRecordNum{
- TryOutNum: tmpGroupTryOutNumMap[i],
- FormalNum: tmpGroupFormalNumMap[i],
- MeetingNum: tmpGroupMeetingNumMap[i],
- RoadShowNum: tmpGroupRoadShowNumMap[i],
- SalonNum: tmpGroupSalonMapNumMap[i],
- StartDate: startDateIndexList[i],
- EndDate: endDateIndexList[i],
- }
- tmpGroupRsReportRecordNumList = append(tmpGroupRsReportRecordNumList, tmpGroupRsReportRecordNum)
- }
- groupReportRecord := roadshow.GroupReportRecord{
- Item: tmpGroupAdminReportRecord,
- Name: v.GroupName,
- RsReportRecordNumList: tmpGroupRsReportRecordNumList,
- }
- RsReportRecordResp.List = append(RsReportRecordResp.List, groupReportRecord)
- }
- //总体汇总数据
- for i := 0; i < len(tmpAllFormalNumMap); i++ {
- tmpGroupRsReportRecordNum := roadshow.RsReportRecordNum{
- TryOutNum: tmpAllTryOutNumMap[i],
- FormalNum: tmpAllFormalNumMap[i],
- MeetingNum: tmpAllMeetingNumMap[i],
- RoadShowNum: tmpAllRoadShowNumMap[i],
- SalonNum: tmpAllSalonNumMap[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
- }
- // SellerReportList
- // @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"
- // @Param CompanyType query string true "客户类型:'ficc','权益',传空默认为ficc,"
- // @Success 200 {object} roadshow.RsReportRecordResp
- // @router /report/seller/list [get]
- func (this *CalendarController) SellerReportList() {
- 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")
- companyType := this.GetString("CompanyType", "ficc")
- if dimensionType == "" {
- dimensionType = "company_status"
- }
- if companyType == utils.COMPANY_CLASSIFY_RAI {
- dimensionType = "roadshow_rai" // 类型传了权益,就强制查询权益的路演
- }
- var adminDataList []roadshowService.AdminDataMap
- var err error
- var firstDate time.Time
- //获取列表
- switch dataType {
- case "week":
- adminDataList, firstDate, err = roadshowService.GetWeekDataV2("seller", dimensionType, 6)
- if err != nil {
- br.Msg = "数据异常"
- br.ErrMsg = "数据异常,Err:" + err.Error()
- return
- }
- case "month":
- adminDataList, firstDate, err = roadshowService.GetMonthDataV2("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.GetTimeIntervalData(startDate, endDate, "seller", dimensionType)
- if err != nil {
- br.Msg = "数据异常"
- br.ErrMsg = "数据异常,Err:" + err.Error()
- return
- }
- }
- var group []services.AdminGroup
- var groupIdRelationMap map[int]int
- var researcherList []*roadshow.Researcher
- switch companyType {
- case utils.COMPANY_CLASSIFY_FICC:
- group, groupIdRelationMap, err = services.GetFiccSystemGroup()
- if err != nil {
- br.Msg = "获取信息失败!"
- br.ErrMsg = "获取FICC销售信息失败!Err:" + err.Error()
- return
- }
- researcherList, err = services.GetFiccSeller(firstDate, groupIdRelationMap)
- case utils.COMPANY_CLASSIFY_RAI:
- group, groupIdRelationMap, err = services.GetRaiSystemGroup()
- if err != nil {
- br.Msg = "获取信息失败!"
- br.ErrMsg = "获取分组信息失败!Err:" + err.Error()
- return
- }
- researcherList, err = services.GetRaiSeller(groupIdRelationMap)
- if err != nil {
- br.Msg = "获取信息失败!"
- br.ErrMsg = "获取权益销售信息失败!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.GroupReportRecord, 0)
- rsAllReportRecordNumList := make([]roadshow.RsReportRecordNum, 0)
- RsReportRecordResp := roadshow.RsReportRecordResp{
- 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)
- tmpAllOnlineNumMap := make(map[int]int)
- tmpAllOfflineNumMap := make(map[int]int)
- tmpAllRoadShowNumMap := make(map[int]int)
- tmpAllSalonNumMap := make(map[int]int)
- for _, v := range group {
- v.ResearcherList = groupMap[v.GroupId]
- tmpGroupAdminReportRecord := make([]roadshow.AdminReportRecord, 0)
- tmpGroupRsReportRecordNumList := make([]roadshow.RsReportRecordNum, 0)
- tmpGroupTryOutNumMap := make(map[int]int)
- tmpGroupFormalNumMap := make(map[int]int)
- tmpGroupMeetingNumMap := make(map[int]int)
- tmpGroupOnlineNumMap := make(map[int]int)
- tmpGroupOfflineNumMap := make(map[int]int)
- tmpGroupRoadShowNumMap := make(map[int]int)
- tmpGroupSalonNumMap := make(map[int]int)
- for _, researcher := range groupMap[v.GroupId] {
- //组内研究员数据
- //每个区间的数据
- tmpAdminRsReportRecordNumList := make([]roadshow.RsReportRecordNum, 0)
- for index, adminData := range adminDataList {
- startDateIndexList[index] = adminData.StartDate
- endDateIndexList[index] = adminData.EndDate
- var tmpTryOutNum, tmpFormalNum, tmpMeetingNum, tmpOnlineNum, tmpOfflineNum, tmpRoadShowNum, tmpSalonNum 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.MeetingMap[researcher.AdminId]; ok {
- tmpMeetingNum = num
- }
- if num, ok := adminData.OnlineMap[researcher.AdminId]; ok {
- tmpOnlineNum = num
- }
- if num, ok := adminData.OfflineMap[researcher.AdminId]; ok {
- tmpOfflineNum = num
- }
- if num, ok := adminData.RoadShowMap[researcher.AdminId]; ok {
- tmpRoadShowNum = num
- }
- if num, ok := adminData.SalonMap[researcher.AdminId]; ok {
- tmpSalonNum = num
- }
- tmpAdminRsReportRecordNum := roadshow.RsReportRecordNum{
- TryOutNum: tmpTryOutNum,
- FormalNum: tmpFormalNum,
- MeetingNum: tmpMeetingNum,
- OnlineNum: tmpOnlineNum,
- OfflineNum: tmpOfflineNum,
- RoadShowNum: tmpRoadShowNum,
- SalonNum: tmpSalonNum,
- 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 := tmpGroupMeetingNumMap[index]; !ok {
- tmpGroupMeetingNumMap[index] = 0
- }
- if _, ok := tmpGroupOnlineNumMap[index]; !ok {
- tmpGroupOnlineNumMap[index] = 0
- }
- if _, ok := tmpGroupOfflineNumMap[index]; !ok {
- tmpGroupOfflineNumMap[index] = 0
- }
- if _, ok := tmpGroupRoadShowNumMap[index]; !ok {
- tmpGroupRoadShowNumMap[index] = 0
- }
- if _, ok := tmpGroupSalonNumMap[index]; !ok {
- tmpGroupSalonNumMap[index] = 0
- }
- tmpGroupTryOutNumMap[index] += tmpTryOutNum
- tmpGroupFormalNumMap[index] += tmpFormalNum
- tmpGroupMeetingNumMap[index] += tmpMeetingNum
- tmpGroupOnlineNumMap[index] += tmpOnlineNum
- tmpGroupOfflineNumMap[index] += tmpOfflineNum
- tmpGroupRoadShowNumMap[index] += tmpRoadShowNum
- tmpGroupSalonNumMap[index] += tmpSalonNum
- //总数据汇总
- if _, ok := tmpAllTryOutNumMap[index]; !ok {
- tmpAllTryOutNumMap[index] = 0
- }
- if _, ok := tmpAllFormalNumMap[index]; !ok {
- tmpAllFormalNumMap[index] = 0
- }
- if _, ok := tmpAllMeetingNumMap[index]; !ok {
- tmpAllMeetingNumMap[index] = 0
- }
- if _, ok := tmpAllOnlineNumMap[index]; !ok {
- tmpAllOnlineNumMap[index] = 0
- }
- if _, ok := tmpAllOfflineNumMap[index]; !ok {
- tmpAllOfflineNumMap[index] = 0
- }
- if _, ok := tmpAllRoadShowNumMap[index]; !ok {
- tmpAllRoadShowNumMap[index] = 0
- }
- if _, ok := tmpAllSalonNumMap[index]; !ok {
- tmpAllSalonNumMap[index] = 0
- }
- tmpAllTryOutNumMap[index] += tmpTryOutNum
- tmpAllFormalNumMap[index] += tmpFormalNum
- tmpAllMeetingNumMap[index] += tmpMeetingNum
- tmpAllOnlineNumMap[index] += tmpOnlineNum
- tmpAllOfflineNumMap[index] += tmpOfflineNum
- tmpAllRoadShowNumMap[index] += tmpRoadShowNum
- tmpAllSalonNumMap[index] += tmpSalonNum
- }
- tmpAdminReportRecord := roadshow.AdminReportRecord{
- Name: researcher.RealName,
- AdminId: researcher.AdminId,
- RsReportRecordNumList: tmpAdminRsReportRecordNumList,
- }
- tmpGroupAdminReportRecord = append(tmpGroupAdminReportRecord, tmpAdminReportRecord)
- }
- for i := 0; i < len(tmpGroupMeetingNumMap); i++ {
- tmpGroupRsReportRecordNum := roadshow.RsReportRecordNum{
- TryOutNum: tmpGroupTryOutNumMap[i],
- FormalNum: tmpGroupFormalNumMap[i],
- MeetingNum: tmpGroupMeetingNumMap[i],
- OnlineNum: tmpGroupOnlineNumMap[i],
- OfflineNum: tmpGroupOfflineNumMap[i],
- RoadShowNum: tmpGroupRoadShowNumMap[i],
- SalonNum: tmpGroupSalonNumMap[i],
- StartDate: startDateIndexList[i],
- EndDate: endDateIndexList[i],
- }
- tmpGroupRsReportRecordNumList = append(tmpGroupRsReportRecordNumList, tmpGroupRsReportRecordNum)
- }
- groupReportRecord := roadshow.GroupReportRecord{
- Item: tmpGroupAdminReportRecord,
- Name: v.GroupName,
- GruopId: v.GroupId,
- RsReportRecordNumList: tmpGroupRsReportRecordNumList,
- }
- groupReportRecordList = append(groupReportRecordList, groupReportRecord)
- }
- //总体汇总数据
- for i := 0; i < len(tmpAllFormalNumMap); i++ {
- tmpGroupRsReportRecordNum := roadshow.RsReportRecordNum{
- TryOutNum: tmpAllTryOutNumMap[i],
- FormalNum: tmpAllFormalNumMap[i],
- MeetingNum: tmpAllMeetingNumMap[i],
- OnlineNum: tmpAllOnlineNumMap[i],
- OfflineNum: tmpAllOfflineNumMap[i],
- RoadShowNum: tmpAllRoadShowNumMap[i],
- SalonNum: tmpAllSalonNumMap[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
- }
- // ReportCalendarList
- // @Title 路演详情列表
- // @Description 路演详情列表接口
- // @Param AdminType query string true "枚举值:researcher、seller、 special:专项路演"
- // @Param DataType query string true "枚举值:try_out、formal、meeting、online、offline"
- // @Param AdminId query int true "用户id"
- // @Param StartDate query string true "开始日期,格式:2022-04-06"
- // @Param EndDate query string true "结束日期,格式:2022-04-06"
- // @Success 200 {object} []roadshow.RsReportRecordList
- // @router /report/calendar/list [get]
- func (this *CalendarController) ReportCalendarList() {
- 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
- }
- adminType := this.GetString("AdminType")
- dataType := this.GetString("DataType")
- startDate := this.GetString("StartDate")
- endDate := this.GetString("EndDate")
- adminId, _ := this.GetInt("AdminId")
- if adminId <= 0 {
- br.Msg = "请传入对应的人员"
- return
- }
- //正式客户
- var condition string
- var pars []interface{}
- condition = ` and a.start_date >= ? and a.end_date <= ? `
- pars = append(pars, startDate, endDate)
- //选择的人员类型(发起人还是被发起人)
- if adminType == "seller" {
- condition += ` and a.seller_id = ? `
- } else if adminType == "special" {
- condition += ` and a.seller_id = ? `
- detail, err := company.GetConfigDetailByCode("choice_researcher_adminid")
- if err != nil {
- br.Msg = "获取研究员信息失败!"
- br.ErrMsg = "选择研究员失败,Err:" + err.Error()
- return
- }
- condition += ` and a.researcher_id IN (` + detail.ConfigValue + `) `
- } else {
- condition += ` and a.researcher_id = ? `
- }
- pars = append(pars, adminId)
- //获取列表
- switch dataType {
- case "try_out":
- condition += ` and a.company_status = ? `
- pars = append(pars, "试用")
- case "formal":
- condition += ` and a.company_status = ? `
- pars = append(pars, "正式")
- case "meeting":
- condition += ` and a.activity_type = ? `
- pars = append(pars, "公开会议")
- case "online":
- condition += ` and a.roadshow_type = ? `
- pars = append(pars, "线上")
- case "offline":
- condition += ` and a.roadshow_type = ? `
- pars = append(pars, "线下")
- case "road_show":
- condition += ` and a.activity_type = ? `
- pars = append(pars, "路演")
- case "salon":
- condition += ` and a.activity_type = ? `
- pars = append(pars, "沙龙")
- default:
- br.Msg = "请传入类型"
- br.ErrMsg = "请传入类型DataType"
- return
- }
- list, err := roadshow.GetRsReportRecordList(condition, pars)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,ERR:" + err.Error()
- return
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = list
- return
- }
- // ChoiceResearcher
- // @Title 选择的研究员
- // @Description 选择的研究员接口
- // @Param AdminIds query string true "研究员ID ,多个用 , 隔开"
- // @Success 200 操作成功
- // @router /report/choice/researcher [post]
- func (this *CalendarController) ChoiceResearcher() {
- 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
- }
- var req roadshow.ResearcherIds
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- if req.AdminIds == "" {
- req.AdminIds = "0"
- }
- adminIdArr := strings.Split(req.AdminIds, ",")
- for _, v := range adminIdArr {
- _, err := strconv.Atoi(v)
- if err != nil {
- br.Msg = "选择研究员失败!"
- br.ErrMsg = "选择研究员失败,Err:" + err.Error()
- return
- }
- }
- err = company.CrmConfigUpdate(req.AdminIds, "choice_researcher_adminid")
- if err != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,Err:" + err.Error()
- return
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "操作成功"
- return
- }
- // AdminList
- // @Title 选择的研究员列表
- // @Description 获取选择的研究员列表
- // @Success 200 {object} roadshow.Researcher
- // @Success 200 操作成功
- // @router /report/admin/list [get]
- func (this *CalendarController) AdminList() {
- 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
- }
- detail, err := company.GetConfigDetailByCode("choice_researcher_adminid")
- if err != nil {
- br.Msg = "获取研究员信息失败!"
- br.ErrMsg = "选择研究员失败,Err:" + err.Error()
- return
- }
- list, err := roadshow.GetChoiceResearcher(detail.ConfigValue)
- if err != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,Err:" + err.Error()
- return
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "操作成功"
- br.Data = list
- return
- }
- // SellerReportList
- // @Title 专项路演统计
- // @Description 专项路演统计接口
- // @Success 200 {object} roadshow.RsReportRecordResp
- // @router /report/special/list [get]
- func (this *CalendarController) SpecialReportList() {
- 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
- }
- dimensionType := this.GetString("DimensionType")
- if dimensionType == "" {
- dimensionType = "seller_special"
- }
- var adminDataList []roadshowService.AdminDataMap
- var err error
- var firstDate time.Time
- //获取列表
- adminDataList, firstDate, err = roadshowService.GetWeekData("seller", dimensionType)
- if err != nil {
- br.Msg = "数据异常"
- br.ErrMsg = "数据异常,Err:" + err.Error()
- return
- }
- var haveData bool
- detail, err := company.GetConfigDetailByCode("choice_researcher_adminid")
- if err != nil {
- br.Msg = "获取信息失败!"
- br.ErrMsg = "获取选择研究员信息失败,Err:" + err.Error()
- return
- }
- adminMap := make(map[int]int)
- adminIdArr := strings.Split(detail.ConfigValue, ",")
- for _, v := range adminIdArr {
- adminId, err := strconv.Atoi(v)
- if err != nil {
- br.Msg = "获取信息失败!"
- br.ErrMsg = "获取选择研究员信息失败,Err:" + err.Error()
- return
- }
- adminMap[adminId] = adminId
- }
- 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.GroupReportRecord, 0)
- rsAllReportRecordNumList := make([]roadshow.RsReportRecordNum, 0)
- RsReportRecordResp := roadshow.RsReportRecordResp{
- 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)
- tmpAllOnlineNumMap := make(map[int]int)
- tmpAllOfflineNumMap := make(map[int]int)
- for _, v := range group {
- v.ResearcherList = groupMap[v.GroupId]
- tmpGroupAdminReportRecord := make([]roadshow.AdminReportRecord, 0)
- tmpGroupRsReportRecordNumList := make([]roadshow.RsReportRecordNum, 0)
- tmpGroupTryOutNumMap := make(map[int]int)
- tmpGroupFormalNumMap := make(map[int]int)
- tmpGroupMeetingNumMap := make(map[int]int)
- tmpGroupOnlineNumMap := make(map[int]int)
- tmpGroupOfflineNumMap := make(map[int]int)
- for _, researcher := range groupMap[v.GroupId] {
- //组内研究员数据
- var isLook bool
- //如果是管理员或者本组的可以查看详情
- if sysUser.GroupId == v.GroupId || sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_ADMIN {
- isLook = true
- }
- //每个区间的数据
- tmpAdminRsReportRecordNumList := make([]roadshow.RsReportRecordNum, 0)
- var isAppend bool
- for index, adminData := range adminDataList {
- startDateIndexList[index] = adminData.StartDate
- endDateIndexList[index] = adminData.EndDate
- var tmpTryOutNum, tmpFormalNum, tmpMeetingNum, 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.MeetingMap[researcher.AdminId]; ok {
- tmpMeetingNum = num
- }
- if num, ok := adminData.OnlineMap[researcher.AdminId]; ok {
- tmpOnlineNum = num
- }
- if num, ok := adminData.OfflineMap[researcher.AdminId]; ok {
- tmpOfflineNum = num
- }
- tmpAdminRsReportRecordNum := roadshow.RsReportRecordNum{
- TryOutNum: tmpTryOutNum,
- FormalNum: tmpFormalNum,
- MeetingNum: tmpMeetingNum,
- OnlineNum: tmpOnlineNum,
- OfflineNum: tmpOfflineNum,
- StartDate: adminData.StartDate,
- EndDate: adminData.EndDate,
- IsLook: isLook,
- }
- if tmpTryOutNum > 0 || tmpFormalNum > 0 || tmpMeetingNum > 0 || tmpOnlineNum > 0 || tmpOfflineNum > 0 {
- isAppend = true
- haveData = true
- }
- tmpAdminRsReportRecordNumList = append(tmpAdminRsReportRecordNumList, tmpAdminRsReportRecordNum)
- //组内数据汇总
- if _, ok := tmpGroupTryOutNumMap[index]; !ok {
- tmpGroupTryOutNumMap[index] = 0
- }
- if _, ok := tmpGroupFormalNumMap[index]; !ok {
- tmpGroupFormalNumMap[index] = 0
- }
- if _, ok := tmpGroupMeetingNumMap[index]; !ok {
- tmpGroupMeetingNumMap[index] = 0
- }
- if _, ok := tmpGroupOnlineNumMap[index]; !ok {
- tmpGroupOnlineNumMap[index] = 0
- }
- if _, ok := tmpGroupOfflineNumMap[index]; !ok {
- tmpGroupOfflineNumMap[index] = 0
- }
- tmpGroupTryOutNumMap[index] += tmpTryOutNum
- tmpGroupFormalNumMap[index] += tmpFormalNum
- tmpGroupMeetingNumMap[index] += tmpMeetingNum
- tmpGroupOnlineNumMap[index] += tmpOnlineNum
- tmpGroupOfflineNumMap[index] += tmpOfflineNum
- //总数据汇总
- if _, ok := tmpAllTryOutNumMap[index]; !ok {
- tmpAllTryOutNumMap[index] = 0
- }
- if _, ok := tmpAllFormalNumMap[index]; !ok {
- tmpAllFormalNumMap[index] = 0
- }
- if _, ok := tmpAllMeetingNumMap[index]; !ok {
- tmpAllMeetingNumMap[index] = 0
- }
- if _, ok := tmpAllOnlineNumMap[index]; !ok {
- tmpAllOnlineNumMap[index] = 0
- }
- if _, ok := tmpAllOfflineNumMap[index]; !ok {
- tmpAllOfflineNumMap[index] = 0
- }
- tmpAllTryOutNumMap[index] += tmpTryOutNum
- tmpAllFormalNumMap[index] += tmpFormalNum
- tmpAllMeetingNumMap[index] += tmpMeetingNum
- tmpAllOnlineNumMap[index] += tmpOnlineNum
- tmpAllOfflineNumMap[index] += tmpOfflineNum
- }
- tmpAdminReportRecord := roadshow.AdminReportRecord{
- Name: researcher.RealName,
- AdminId: researcher.AdminId,
- RsReportRecordNumList: tmpAdminRsReportRecordNumList,
- }
- if isAppend {
- tmpGroupAdminReportRecord = append(tmpGroupAdminReportRecord, tmpAdminReportRecord)
- }
- }
- for i := 0; i < len(tmpGroupMeetingNumMap); i++ {
- tmpGroupRsReportRecordNum := roadshow.RsReportRecordNum{
- TryOutNum: tmpGroupTryOutNumMap[i],
- FormalNum: tmpGroupFormalNumMap[i],
- MeetingNum: tmpGroupMeetingNumMap[i],
- OnlineNum: tmpGroupOnlineNumMap[i],
- OfflineNum: tmpGroupOfflineNumMap[i],
- StartDate: startDateIndexList[i],
- EndDate: endDateIndexList[i],
- }
- tmpGroupRsReportRecordNumList = append(tmpGroupRsReportRecordNumList, tmpGroupRsReportRecordNum)
- }
- groupReportRecord := roadshow.GroupReportRecord{
- Item: tmpGroupAdminReportRecord,
- Name: v.GroupName,
- GruopId: v.GroupId,
- RsReportRecordNumList: tmpGroupRsReportRecordNumList,
- }
- if len(tmpGroupAdminReportRecord) > 0 {
- groupReportRecordList = append(groupReportRecordList, groupReportRecord)
- }
- }
- //总体汇总数据
- for i := 0; i < len(tmpAllFormalNumMap); i++ {
- tmpGroupRsReportRecordNum := roadshow.RsReportRecordNum{
- TryOutNum: tmpAllTryOutNumMap[i],
- FormalNum: tmpAllFormalNumMap[i],
- MeetingNum: tmpAllMeetingNumMap[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
- }
- //判断是否有数据如果没有,处理数据为空
- if !haveData {
- RsReportRecordResp = roadshow.RsReportRecordResp{
- List: make([]roadshow.GroupReportRecord, 0),
- RsReportRecordNumList: make([]roadshow.RsReportRecordNum, 0),
- }
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = RsReportRecordResp
- return
- }
- // ResearcherReportList
- // @Title 研究员出差表
- // @Description 研究员出差表接口
- // @Param AdminId query int true "研究员id"
- // @Param WeekQuery query int false "周查询: 0-本期(本周及下周); 1-前两周; 2-后两周"
- // @Param BaseQueryDate query string false "周查询时的开始日期"
- // @Success 200 {object} roadshow.BusinessTripResp
- // @router /report/researcher/business_trip [get]
- func (this *CalendarController) ResearcherBusinessTrip() {
- 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
- }
- adminId, _ := this.GetInt("AdminId")
- weekQuery, _ := this.GetInt("WeekQuery")
- baseQueryDate := this.GetString("BaseQueryDate")
- //fmt.Println(adminId)
- group, err := roadshow.GetResearcherGroup()
- if err != nil {
- br.Msg = "获取信息失败!"
- br.ErrMsg = "获取分组信息失败!Err:" + err.Error()
- return
- }
- researcherList, err := roadshow.GetBusinessTripResearcher()
- if err != nil {
- br.Msg = "获取信息失败!"
- br.ErrMsg = "获取分组信息失败!,GetBusinessTripResearcher Err:" + err.Error()
- return
- }
- ////获取当天周日期
- //nowWeekStart := utils.GetNowWeekMonday().AddDate(0, 0, -2)
- ////nowWeekEnd := utils.GetNowWeekLastDay()
- ////获取下周日期
- //nextWeekStart := utils.GetNextWeekMonday().AddDate(0, 0, -2)
- //nextWeekEnd := utils.GetNextWeekLastDay().AddDate(0, 0, -2)
- var nowWeekStart time.Time
- if baseQueryDate == "" {
- now := time.Now()
- weekDay := int(now.Weekday())
- if weekDay == 6 {
- nowWeekStart, _ = time.ParseInLocation(utils.FormatDate, now.Format(utils.FormatDate), time.Local)
- } else {
- nowWeekStart, _ = time.ParseInLocation(utils.FormatDate, now.AddDate(0, 0, -(weekDay+1)).Format(utils.FormatDate), time.Local)
- }
- }
- // 查询需求是可以无限往前后两周查询, 以入参为本周开始日期
- if baseQueryDate != "" {
- t, e := time.ParseInLocation(utils.FormatDate, baseQueryDate, time.Local)
- if e != nil {
- br.Msg = "查询开始日期格式有误"
- return
- }
- nowWeekStart = t
- }
- // 前/后两周
- if weekQuery == 1 {
- nowWeekStart = nowWeekStart.AddDate(0, 0, -14)
- }
- if weekQuery == 2 {
- nowWeekStart = nowWeekStart.AddDate(0, 0, +14)
- }
- //nowWeekEnd := utils.GetNowWeekLastDay()
- //获取下周日期
- nextWeekStart := nowWeekStart.AddDate(0, 0, +7)
- nextWeekEnd := nowWeekStart.AddDate(0, 0, +13)
- //获取路演信息
- roadshowList, err := roadshow.GetBusinessTripList(adminId, nowWeekStart.Format(utils.FormatDate), nextWeekEnd.Format(utils.FormatDateTime))
- if err != nil {
- br.Msg = "获取信息失败!"
- br.ErrMsg = "获取路演信息失败!,GetBusinessTripList Err:" + err.Error()
- return
- }
- roadshowMap := make(map[int][]*roadshow.BusinessTripResearcherList)
- for _, v := range roadshowList {
- if findVals, ok := roadshowMap[v.ResearcherId]; ok {
- findVals = append(findVals, v)
- roadshowMap[v.ResearcherId] = findVals
- } else {
- roadsItems := make([]*roadshow.BusinessTripResearcherList, 0)
- roadsItems = append(roadsItems, v)
- roadshowMap[v.ResearcherId] = roadsItems
- }
- }
- //fmt.Println("roadshow json start")
- //jsonBody, err := json.Marshal(roadshowMap)
- //fmt.Println("json body:" + string(jsonBody))
- //fmt.Println("roadshow json end")
- groupMap := make(map[int][]*roadshow.BusinessTripResearcher)
- for _, v := range researcherList {
- if findRoadshowList, ok := roadshowMap[v.AdminId]; ok {
- tripList := make([]*roadshow.BusinessTrip, 0)
- researcherMap := make(map[string]string)
- for i := 0; i < 7; i++ {
- newDay, _ := time.ParseInLocation(utils.FormatDate, nowWeekStart.AddDate(0, 0, i).Format(utils.FormatDate), time.Local)
- weekDate := newDay.Format(utils.FormatDate)
- tripItem := new(roadshow.BusinessTrip)
- for _, r := range findRoadshowList {
- startDateT, _ := time.ParseInLocation(utils.FormatDate, r.StartDate, time.Local)
- endDateT, _ := time.ParseInLocation(utils.FormatDate, r.EndDate, time.Local)
- if int(endDateT.Sub(startDateT)) <= 0 {
- skey := strconv.Itoa(r.ResearcherId) + r.StartDate
- if _, sok := researcherMap[skey]; !sok {
- if r != nil && (newDay.Equal(startDateT) || (newDay.Equal(endDateT)) || (newDay.Before(endDateT) && newDay.After(startDateT))) {
- tripItem.City = r.City
- researcherMap[skey] = skey
- }
- }
- } else {
- if r != nil && (newDay.Equal(startDateT) || (newDay.Equal(endDateT)) || (newDay.Before(endDateT) && newDay.After(startDateT))) {
- tripItem.City = r.City
- //researcherMap[skey] = skey
- }
- }
- }
- tripItem.WeekDate = weekDate
- tripItem.WeekType = "current"
- tripItem.Week = newDay.Weekday().String()
- tripList = append(tripList, tripItem)
- }
- for i := 0; i < 7; i++ {
- newDay := nextWeekStart.AddDate(0, 0, i)
- weekDate := newDay.Format(utils.FormatDate)
- tripItem := new(roadshow.BusinessTrip)
- for _, r := range findRoadshowList {
- startDateT, _ := time.ParseInLocation(utils.FormatDate, r.StartDate, time.Local)
- endDateT, _ := time.ParseInLocation(utils.FormatDate, r.EndDate, time.Local)
- if int(endDateT.Sub(startDateT)) <= 0 {
- skey := strconv.Itoa(r.ResearcherId) + r.StartDate
- if _, sok := researcherMap[skey]; !sok {
- if r != nil && (newDay.Equal(startDateT) || (newDay.Equal(endDateT)) || (newDay.Before(endDateT) && newDay.After(startDateT))) {
- tripItem.City = r.City
- researcherMap[skey] = skey
- }
- }
- } else {
- if r != nil && (newDay.Equal(startDateT) || (newDay.Equal(endDateT)) || (newDay.Before(endDateT) && newDay.After(startDateT))) {
- tripItem.City = r.City
- //researcherMap[skey] = skey
- }
- }
- }
- tripItem.WeekDate = weekDate
- tripItem.WeekType = "next"
- tripItem.Week = newDay.Weekday().String()
- tripList = append(tripList, tripItem)
- }
- v.BusinessTripList = tripList
- //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
- }
- //}
- }
- }
- groupList := make([]*roadshow.BusinessTripGroup, 0)
- for _, v := range group {
- item := new(roadshow.BusinessTripGroup)
- item.GroupName = v.GroupName
- item.GroupId = v.GroupId
- item.ResearcherList = groupMap[v.GroupId]
- groupList = append(groupList, item)
- }
- resp := new(roadshow.BusinessTripResp)
- resp.GroupList = groupList
- resp.BaseDate = nowWeekStart.Format(utils.FormatDate)
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- return
- }
- // OverseasCustomReportCalendarList
- // @Title 路演详情列表
- // @Description 路演详情列表接口
- // @Param Keyword query string true "关键字:客户名称"
- // @Param CompanyStatus query string true "客户状态,枚举值:正式、试用、关闭"
- // @Param SellerId query int true "销售id列表;多个用英文,分割"
- // @Param ResearcherId query int true "销售id列表;多个用英文,分割"
- // @Param StartDate query string true "开始日期,格式:2022-04-06"
- // @Param EndDate query string true "结束日期,格式:2022-04-06"
- // @Param SortField query string false "排序字段:start_date"
- // @Param SortDesc query int false "1:降序,默认,2:升序"
- // @Success 200 {object} []roadshow.RsReportRecordList
- // @router /overseas_custom/calendar/list [get]
- func (this *CalendarController) OverseasCustomReportCalendarList() {
- 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
- }
- keyword := this.GetString("Keyword")
- companyStatus := this.GetString("CompanyStatus")
- startDate := this.GetString("StartDate")
- endDate := this.GetString("EndDate")
- sellerId := this.GetString("SellerId")
- researcherId := this.GetString("ResearcherId")
- pageSize, _ := this.GetInt("PageSize")
- currentIndex, _ := this.GetInt("CurrentIndex")
- sortField := this.GetString("SortField")
- sortDesc, _ := this.GetInt("SortDesc")
- var startSize int
- if pageSize <= 0 {
- pageSize = utils.PageSize20
- }
- if currentIndex <= 0 {
- currentIndex = 1
- }
- startSize = paging.StartIndex(currentIndex, pageSize)
- switch sortField {
- case "start_date":
- default:
- sortField = "start_date"
- }
- // "1:降序,默认,2:升序"
- sortDesStr := ` desc `
- switch sortDesc {
- case 2:
- sortDesStr = ` asc `
- default:
- sortDesStr = "desc"
- }
- total, list, err := roadshow.GetOverseaCustomCalendarList(keyword, sellerId, researcherId, startDate, endDate, companyStatus, sortField, sortDesStr, startSize, pageSize)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,ERR:" + err.Error()
- return
- }
- page := paging.GetPaging(currentIndex, pageSize, total)
- resp := new(roadshow.OverseaCustomRecordInfoResp)
- resp.Paging = page
- resp.List = list
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- return
- }
- // OverseasCustomCalendarAdminList
- // @Title 海外客户路演用户列表接口
- // @Description 海外客户路演用户列表接口
- // @Param AdminType query string true "枚举值:researcher、seller"
- // @Success 200 {object} []roadshow.AdminInfo
- // @router /overseas_custom/sys_user/list [get]
- func (this *CalendarController) OverseasCustomCalendarAdminList() {
- 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
- }
- adminType := this.GetString("AdminType")
- var list []*roadshow.AdminInfo
- var err error
- //选择的人员类型(发起人还是被发起人)
- if adminType == "seller" {
- list, err = roadshow.GetOverseaCustomCalendarSellerList()
- } else if adminType == "researcher" {
- list, err = roadshow.GetOverseaCustomCalendarResearcherList()
- } else {
- br.Msg = "错误的类型"
- br.IsSendEmail = false
- }
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,ERR:" + err.Error()
- return
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- 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
- //获取列表
- switch dataType {
- case "week":
- adminDataList, _, err = roadshowService.GetOverseasWeekDataV2("seller", dimensionType, 6)
- if err != nil {
- br.Msg = "数据异常"
- br.ErrMsg = "数据异常,Err:" + err.Error()
- return
- }
- case "month":
- adminDataList, _, 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, _, err = roadshowService.GetOverseasTimeIntervalData(startDate, endDate, "seller", dimensionType)
- if err != nil {
- br.Msg = "数据异常"
- br.ErrMsg = "数据异常,Err:" + err.Error()
- return
- }
- }
- sellerList, err := roadshow.GetOverseaCustomCalendarSellerList()
- adminReportRecordList := make([]roadshow.OverseasAdminReportRecord, 0)
- rsAllReportRecordNumList := make([]roadshow.RsOverseasReportRecordNum, 0)
- RsReportRecordResp := roadshow.RsOverseasReportRecordResp{
- List: adminReportRecordList,
- 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 _, researcher := range sellerList {
- //每个区间的数据
- 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 := 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
- }
- // 数据都为0的时候不显示
- adminTotalNum := 0
- for _, v := range tmpAdminRsReportRecordNumList {
- adminTotalNum += v.TryOutNum + v.CloseNum + v.FormalNum
- }
- if adminTotalNum > 0 {
- tmpAdminReportRecord := roadshow.OverseasAdminReportRecord{
- Name: researcher.RealName,
- AdminId: researcher.AdminId,
- RsReportRecordNumList: tmpAdminRsReportRecordNumList,
- }
- RsReportRecordResp.List = append(RsReportRecordResp.List, tmpAdminReportRecord)
- }
- }
- //总体汇总数据
- 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
- 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
- }
- }
- researcherList, err := roadshow.GetOverseaCustomCalendarResearcherList()
- if err != nil {
- br.Msg = "获取信息失败!"
- br.ErrMsg = "获取分组信息失败!,GetResearcherV2 Err:" + err.Error()
- return
- }
- adminReportRecordList := make([]roadshow.OverseasAdminReportRecord, 0)
- rsAllReportRecordNumList := make([]roadshow.RsOverseasReportRecordNum, 0)
- RsReportRecordResp := roadshow.RsOverseasReportRecordResp{
- List: adminReportRecordList,
- 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 _, researcher := range researcherList {
- //组内研究员数据
- //每个区间的数据
- 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 := 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
- }
- // 数据都为0的时候不显示
- adminTotalNum := 0
- for _, v := range tmpAdminRsReportRecordNumList {
- adminTotalNum += v.TryOutNum + v.CloseNum + v.FormalNum
- }
- if adminTotalNum > 0 {
- tmpAdminReportRecord := roadshow.OverseasAdminReportRecord{
- Name: researcher.RealName,
- AdminId: researcher.AdminId,
- RsReportRecordNumList: tmpAdminRsReportRecordNumList,
- }
- RsReportRecordResp.List = append(RsReportRecordResp.List, tmpAdminReportRecord)
- }
- }
- //总体汇总数据
- 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
- }
- // OverseasCalendarList
- // @Title 海外客户路演详情列表
- // @Description 海外客户路演详情列表接口
- // @Param AdminType query string true "枚举值:researcher、seller、 special:专项路演"
- // @Param DataType query string true "枚举值:try_out、formal、close、online、offline"
- // @Param AdminIds query string true "用户ids"
- // @Param StartDate query string true "开始日期,格式:2022-04-06"
- // @Param EndDate query string true "结束日期,格式:2022-04-06"
- // @Success 200 {object} []roadshow.RsReportRecordList
- // @router /overseas/calendar/list [get]
- func (this *CalendarController) OverseasCalendarList() {
- 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
- }
- adminType := this.GetString("AdminType")
- dataType := this.GetString("DataType")
- startDate := this.GetString("StartDate")
- endDate := this.GetString("EndDate")
- adminIds := this.GetString("AdminIds")
- if adminIds == "" {
- br.Msg = "请传入对应的人员"
- return
- }
- //adminIdsArr := make([]int, 0)
- //adminIdSlice := strings.Split(adminIds, ",")
- //for _, v := range adminIdSlice {
- // id,_ := strconv.Atoi(v)
- // adminIdsArr = append(adminIdsArr, id)
- //}
- //正式客户
- //var condition string
- //var pars []interface{}
- //condition = ` and a.start_date >= ? and a.end_date <= ? `
- //pars = append(pars, startDate, endDate)
- var sellerIds, researcherIds string
- //选择的人员类型(发起人还是被发起人)
- if adminType == "seller" {
- //condition += ` and a.seller_id IN (` + utils.GetOrmInReplace(len(adminIdsArr)) + `)`
- sellerIds = adminIds
- } else {
- //condition += ` and a.researcher_id IN (` + utils.GetOrmInReplace(len(adminIdsArr)) + `)`
- researcherIds = adminIds
- }
- //pars = append(pars, adminIdsArr)
- var status string
- //获取列表
- switch dataType {
- case "try_out":
- //condition += ` and a.company_status = ? )`
- //pars = append(pars, "试用")
- status = "试用"
- case "formal":
- //condition += ` and a.company_status = ? )`
- //pars = append(pars, "正式")
- status = "正式"
- case "close":
- //condition += ` and a.company_status = ? )`
- //pars = append(pars, "关闭")
- status = "关闭"
- //case "online":
- // condition += ` and a.roadshow_type = ? `
- // pars = append(pars, "线上")
- //case "offline":
- // condition += ` and a.roadshow_type = ? `
- // pars = append(pars, "线下")
- default:
- br.Msg = "请传入类型"
- br.ErrMsg = "请传入类型DataType"
- return
- }
- list, err := roadshow.GetOverseaCustomCalendarList2(sellerIds, researcherIds, startDate, endDate, status)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,ERR:" + err.Error()
- return
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = list
- return
- }
|