|
@@ -0,0 +1,308 @@
|
|
|
+package roadshow
|
|
|
+
|
|
|
+import (
|
|
|
+ "encoding/json"
|
|
|
+ "github.com/rdlucklib/rdluck_tools/paging"
|
|
|
+ "hongze/hongze_mobile_admin/controllers"
|
|
|
+ "hongze/hongze_mobile_admin/models"
|
|
|
+ "hongze/hongze_mobile_admin/models/roadshow"
|
|
|
+ "hongze/hongze_mobile_admin/models/tables/admin"
|
|
|
+ "hongze/hongze_mobile_admin/services"
|
|
|
+ "hongze/hongze_mobile_admin/utils"
|
|
|
+ "strconv"
|
|
|
+ "strings"
|
|
|
+ "time"
|
|
|
+)
|
|
|
+
|
|
|
+//日历
|
|
|
+type CalendarController struct {
|
|
|
+ controllers.BaseAuth
|
|
|
+}
|
|
|
+
|
|
|
+// CalendarList
|
|
|
+// @Title 我的日历列表
|
|
|
+// @Description 我的日历列表接口
|
|
|
+// @Param PageSize query int true "每页数据条数"
|
|
|
+// @Param CurrentIndex query int true "当前页页码,从1开始"
|
|
|
+// @Param Status query int true "1:待接受,2:包含,已接受,已拒绝,已删除"
|
|
|
+// @Success 200 {object} roadshow.CalendarListResp
|
|
|
+// @router /calendar/list [get]
|
|
|
+func (this *CalendarController) CalendarList() {
|
|
|
+ adminItem := this.AdminWx
|
|
|
+
|
|
|
+ status, _ := this.GetInt("Status")
|
|
|
+
|
|
|
+ pageSize, _ := this.GetInt("PageSize")
|
|
|
+ currentIndex, _ := this.GetInt("CurrentIndex")
|
|
|
+
|
|
|
+ var total int
|
|
|
+ page := paging.GetPaging(currentIndex, pageSize, total)
|
|
|
+
|
|
|
+ var startSize int
|
|
|
+ if pageSize <= 0 {
|
|
|
+ pageSize = utils.PageSize10
|
|
|
+ }
|
|
|
+ if currentIndex <= 0 {
|
|
|
+ currentIndex = 1
|
|
|
+ }
|
|
|
+ startSize = paging.StartIndex(currentIndex, pageSize)
|
|
|
+
|
|
|
+ var condition string
|
|
|
+ var pars []interface{}
|
|
|
+
|
|
|
+ condition += ` AND b.researcher_id=?`
|
|
|
+ pars = append(pars, adminItem.AdminId)
|
|
|
+
|
|
|
+ condition += ` AND a.activity_type IN('路演','公开会议') `
|
|
|
+
|
|
|
+ if status == 1 {
|
|
|
+ condition += ` AND b.status=?`
|
|
|
+ pars = append(pars, 1)
|
|
|
+ } else {
|
|
|
+ condition += ` AND b.status IN(2,3,4)`
|
|
|
+ }
|
|
|
+
|
|
|
+ resp := new(roadshow.CalendarListResp)
|
|
|
+ total, err := roadshow.GetCalendarListCount(condition, pars)
|
|
|
+ if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ this.FailWithMessage("获取信息失败!", "获取数据总数失败,GetCalendarListCount,Err:"+err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ page = paging.GetPaging(currentIndex, pageSize, total)
|
|
|
+ dataList, err := roadshow.GetCalendarList(condition, pars, status, startSize, pageSize)
|
|
|
+ if err != nil {
|
|
|
+ this.FailWithMessage("获取信息失败!", "获取数据失败,GetCalendarList,Err:"+err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ resp.Paging = page
|
|
|
+ resp.List = dataList
|
|
|
+ this.OkDetailed(resp, "获取成功")
|
|
|
+}
|
|
|
+
|
|
|
+// Accept
|
|
|
+// @Description 接受路演活动接口
|
|
|
+// @Param request body roadshow.AcceptReq true "type json string"
|
|
|
+// @Success Ret=200 保存成功
|
|
|
+// @router /accept [post]
|
|
|
+func (this *CalendarController) Accept() {
|
|
|
+
|
|
|
+ //adminItem:=this.AdminWx
|
|
|
+ var req roadshow.AcceptReq
|
|
|
+ err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
|
|
|
+ if err != nil {
|
|
|
+ this.FailWithMessage("参数解析失败!", "参数解析失败,Err:"+err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if req.RsCalendarId <= 0 || req.RsCalendarResearcherId <= 0 {
|
|
|
+ this.FailWithMessage("参数错误!", "RsCalendarId 或 RsCalendarResearcherId 小于等于0:")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ rsCalendar, err := roadshow.GetRsCalendarById(req.RsCalendarId)
|
|
|
+ if err != nil {
|
|
|
+ this.FailWithMessage("获取数据失败!", "GetRsCalendarById Err:"+err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ rsCalendarResearcher, err := roadshow.GetRsCalendarResearcherById(req.RsCalendarResearcherId)
|
|
|
+ if err != nil {
|
|
|
+ this.FailWithMessage("获取数据失败!", "GetRsCalendarResearcherById Err:"+err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if rsCalendarResearcher.Status == 2 {
|
|
|
+ this.FailWithMessage("已接受,不可重复操作!", "")
|
|
|
+ return
|
|
|
+ } else if rsCalendarResearcher.Status == 3 {
|
|
|
+ this.FailWithMessage("已拒绝,不可进行接受操作!", "")
|
|
|
+ return
|
|
|
+ } else if rsCalendarResearcher.Status == 4 {
|
|
|
+ this.FailWithMessage("已删除,不可进行接受操作!", "")
|
|
|
+ return
|
|
|
+ } else if rsCalendarResearcher.Status == 5 {
|
|
|
+ this.FailWithMessage("已撤回,不可进行接受操作!", "")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ whereParams := make(map[string]interface{})
|
|
|
+ updateParams := make(map[string]interface{})
|
|
|
+
|
|
|
+ whereParams["rs_calendar_researcher_id"] = req.RsCalendarResearcherId
|
|
|
+ whereParams["rs_calendar_id"] = req.RsCalendarId
|
|
|
+
|
|
|
+ updateParams["status"] = 2
|
|
|
+ updateParams["modify_time"] = time.Now()
|
|
|
+ updateParams["approve_time"] = time.Now()
|
|
|
+
|
|
|
+ err = roadshow.UpdateCalendarResearcher(whereParams, updateParams)
|
|
|
+ if err != nil {
|
|
|
+ this.FailWithMessage("获取数据失败!", "UpdateCalendarResearcher Err:"+err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //模板消息通知
|
|
|
+ {
|
|
|
+
|
|
|
+ if rsCalendar != nil {
|
|
|
+ sysAdmin, _ := admin.GetAdminById(rsCalendar.SysUserId)
|
|
|
+ first := "【" + this.AdminWx.RealName + "】接受了你的【" + rsCalendar.ActivityType + "】申请"
|
|
|
+ var keyword1 string
|
|
|
+ if rsCalendar.ActivityType == "路演" {
|
|
|
+ keyword1 = rsCalendar.CompanyName + "," + rsCalendar.RoadshowType + rsCalendar.ActivityType
|
|
|
+ } else {
|
|
|
+ keyword1 = rsCalendar.Theme + "," + rsCalendar.RoadshowType + rsCalendar.ActivityType
|
|
|
+ }
|
|
|
+ keyword2 := "已接受"
|
|
|
+ remark := ""
|
|
|
+ if sysAdmin.Mobile != "" {
|
|
|
+ go services.SendWxMsgWithRoadshowDetailResult(first, keyword1, keyword2, remark, sysAdmin.Mobile, "", "")
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.OkDetailed(nil, "保存成功")
|
|
|
+}
|
|
|
+
|
|
|
+// @Title 拒绝路演活动接口
|
|
|
+// @Description 拒绝路演活动接口
|
|
|
+// @Param request body roadshow.RefuseReq true "type json string"
|
|
|
+// @Success Ret=200 保存成功
|
|
|
+// @router /refuse [post]
|
|
|
+func (this *CalendarController) Refuse() {
|
|
|
+ //adminItem:=this.AdminWx
|
|
|
+
|
|
|
+ var req roadshow.RefuseReq
|
|
|
+ err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
|
|
|
+ if err != nil {
|
|
|
+ this.FailWithMessage("参数解析失败!", "参数解析失败,Err:"+err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if req.RsCalendarId <= 0 || req.RsCalendarResearcherId <= 0 {
|
|
|
+ this.FailWithMessage("参数错误!", "参数错误!RsCalendarId:"+strconv.Itoa(req.RsCalendarId)+";RsCalendarResearcherId:"+strconv.Itoa(req.RsCalendarResearcherId))
|
|
|
+ return
|
|
|
+ }
|
|
|
+ rsCalendar, err := roadshow.GetRsCalendarById(req.RsCalendarId)
|
|
|
+ if err != nil {
|
|
|
+ this.FailWithMessage("获取数据失败!", "GetRsCalendarById,Err:"+err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ rsCalendarResearcher, err := roadshow.GetRsCalendarResearcherById(req.RsCalendarResearcherId)
|
|
|
+ if err != nil {
|
|
|
+ this.FailWithMessage("获取数据失败!", "GetRsCalendarResearcherById,Err:"+err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if rsCalendarResearcher.Status == 2 {
|
|
|
+ this.FailWithMessage("已接受,不可进行拒绝操作!", "")
|
|
|
+ return
|
|
|
+ } else if rsCalendarResearcher.Status == 3 {
|
|
|
+ this.FailWithMessage("已拒绝,不可进行重复操作!", "")
|
|
|
+ return
|
|
|
+ } else if rsCalendarResearcher.Status == 4 {
|
|
|
+ this.FailWithMessage("已删除,不可进行拒绝操作!", "")
|
|
|
+ return
|
|
|
+ } else if rsCalendarResearcher.Status == 5 {
|
|
|
+ this.FailWithMessage("已撤回,不可进行拒绝操作!", "")
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ whereParams := make(map[string]interface{})
|
|
|
+ updateParams := make(map[string]interface{})
|
|
|
+
|
|
|
+ whereParams["rs_calendar_researcher_id"] = req.RsCalendarResearcherId
|
|
|
+ whereParams["rs_calendar_id"] = req.RsCalendarId
|
|
|
+
|
|
|
+ updateParams["status"] = 3
|
|
|
+ updateParams["refuse_reason"] = req.RefuseReason
|
|
|
+ updateParams["refuse_time"] = time.Now()
|
|
|
+ updateParams["modify_time"] = time.Now()
|
|
|
+
|
|
|
+ err = roadshow.UpdateCalendarResearcher(whereParams, updateParams)
|
|
|
+ if err != nil {
|
|
|
+ this.FailWithMessage("保存失败", "保存失败!UpdateCalendarResearcher:"+err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ //模板消息通知
|
|
|
+ {
|
|
|
+
|
|
|
+ if rsCalendar != nil {
|
|
|
+ sysAdmin, _ := admin.GetAdminById(rsCalendar.SysUserId)
|
|
|
+ first := "【" + this.AdminWx.RealName + "】拒绝了你的【" + rsCalendar.ActivityType + "】申请"
|
|
|
+ var keyword1 string
|
|
|
+ if rsCalendar.ActivityType == "路演" {
|
|
|
+ keyword1 = rsCalendar.CompanyName + "," + rsCalendar.RoadshowType + rsCalendar.ActivityType
|
|
|
+ } else {
|
|
|
+ keyword1 = rsCalendar.Theme + "," + rsCalendar.RoadshowType + rsCalendar.ActivityType
|
|
|
+ }
|
|
|
+ keyword2 := "已拒绝"
|
|
|
+ remark := req.RefuseReason
|
|
|
+ if sysAdmin.Mobile != "" {
|
|
|
+ go services.SendWxMsgWithRoadshowDetailResult(first, keyword1, keyword2, remark, sysAdmin.Mobile, "", "")
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.OkDetailed(nil, "保存成功")
|
|
|
+}
|
|
|
+
|
|
|
+// @Title 日历详情
|
|
|
+// @Description 日历详情接口
|
|
|
+// @Param RsCalendarId query int true "路演活动id"
|
|
|
+// @Param RsCalendarResearcherId query int true "活动研究员id"
|
|
|
+// @Success 200 {object} roadshow.CalendarDetailResp
|
|
|
+// @router /calendar/detail [get]
|
|
|
+func (this *CalendarController) CalendarDetail() {
|
|
|
+ //adminItem:=this.AdminWx
|
|
|
+ //roleTypeCode := adminItem.RoleTypeCode
|
|
|
+
|
|
|
+ rsCalendarId, _ := this.GetInt("RsCalendarId")
|
|
|
+ rsCalendarResearcherId, _ := this.GetInt("RsCalendarResearcherId")
|
|
|
+
|
|
|
+ if rsCalendarId <= 0 || rsCalendarResearcherId <= 0 {
|
|
|
+ this.FailWithMessage("参数错误", "rsCalendarId 或 rsCalendarResearcherId")
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ calendarItem, err := roadshow.GetRsCalendarById(rsCalendarId)
|
|
|
+ if err != nil {
|
|
|
+ this.FailWithMessage("获取数据失败", "获取数据失败!GetRsCalendarById:"+err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ rsCalendarResearcherItem, err := roadshow.GetRsCalendarResearcherById(rsCalendarResearcherId)
|
|
|
+ if err != nil {
|
|
|
+ this.FailWithMessage("获取数据失败", "获取数据失败!GetRsCalendarResearcherById:"+err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ companyDetailView := new(roadshow.CompanyDetailView)
|
|
|
+ if calendarItem != nil && calendarItem.CompanyId > 0 {
|
|
|
+ companyId := calendarItem.CompanyId
|
|
|
+ companyProductItem, err := models.GetCompanyProductByCompanyIdAndProductId(companyId, 1)
|
|
|
+ if err != nil {
|
|
|
+ this.FailWithMessage("获取数据失败", "获取数据失败!GetRsCalendarResearcherById:"+err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ permissionList, err := models.GetCompanyProductReportPermissionList(companyId, 1)
|
|
|
+ if err != nil {
|
|
|
+ this.FailWithMessage("搜索客户权限失败", "搜索客户权限失败!GetRsCalendarResearcherById:"+err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var permissionArr []string
|
|
|
+ for _, v := range permissionList {
|
|
|
+ permissionArr = append(permissionArr, v.PermissionName)
|
|
|
+ }
|
|
|
+
|
|
|
+ readNum := companyProductItem.ViewTotal
|
|
|
+ companyDetailView.CompanyId = companyProductItem.CompanyId
|
|
|
+ companyDetailView.CompanyName = companyProductItem.CompanyName
|
|
|
+ companyDetailView.Status = companyProductItem.Status
|
|
|
+ companyDetailView.IndustryId = companyProductItem.IndustryId
|
|
|
+ companyDetailView.IndustryName = companyProductItem.IndustryName
|
|
|
+ companyDetailView.PermissionName = strings.Join(permissionArr, "/")
|
|
|
+ companyDetailView.ReportReadTotal = readNum //ficc报告-累计阅读次数
|
|
|
+ }
|
|
|
+
|
|
|
+ resp := new(roadshow.CalendarDetailResp)
|
|
|
+ resp.RsCalendarItem = calendarItem
|
|
|
+ resp.RsCalendarResearcherItem = rsCalendarResearcherItem
|
|
|
+ resp.CompanyDetail = companyDetailView
|
|
|
+ this.OkDetailed(resp, "获取成功")
|
|
|
+}
|