|
@@ -1,14 +1,8 @@
|
|
|
package models
|
|
|
|
|
|
import (
|
|
|
- "fmt"
|
|
|
- "github.com/PuerkitoBio/goquery"
|
|
|
- "hongze/hongze_cygx/utils"
|
|
|
"rdluck_tools/orm"
|
|
|
"rdluck_tools/paging"
|
|
|
- "regexp"
|
|
|
- "strings"
|
|
|
- "time"
|
|
|
)
|
|
|
|
|
|
type Activity struct {
|
|
@@ -57,87 +51,39 @@ type ActivityRep struct {
|
|
|
|
|
|
//活动详情
|
|
|
type ActivityDetail struct {
|
|
|
- ActivityId int `orm:"column(activity_id);pk";description:"活动ID 等于0新增活动,大于0修改活动"`
|
|
|
- ActivityTypeId int `description:"活动类型id"`
|
|
|
- ActivityTypeName string `description:"活动类型名称"`
|
|
|
- ChartPermissionId int `description:"行业id"`
|
|
|
- ChartPermissionName string `description:"行业名称"`
|
|
|
- Body string `description:"内容"`
|
|
|
- CreateTime string `description:"创建时间"`
|
|
|
- IsLimitPeople int `description:"是否限制人数 1是,0否"`
|
|
|
- LimitPeopleNum string `description:"限制的人数数量"`
|
|
|
- CustomerTypeIds string `description:"活动可见的客户类型,多个ID用 , 隔开"`
|
|
|
- PublishStatus int `description:"发布状态 1已发布,0未发布"`
|
|
|
- LastUpdatedTime string `description:"更新时间"`
|
|
|
- ActivityTime string `description:"活动时间"`
|
|
|
- ActivityTimeText string `description:"活动时间带文字"`
|
|
|
- DistinguishedGuest string `description:"嘉宾"`
|
|
|
- Host string `description:"主持人"`
|
|
|
- MainlandTell string `description:"大陆拨入号"`
|
|
|
- HongKongTell string `description:"香港拨入号"`
|
|
|
- TaiwanTell string `description:"台湾拨入号"`
|
|
|
- AmericaTell string `description:"美国拨入号"`
|
|
|
- ParticipationCode string `description:"参会密码"`
|
|
|
- Theme string `description:"主题"`
|
|
|
- Expert string `description:"专家"`
|
|
|
- ActivityName string `description:"活动名称"`
|
|
|
- OnlineParticipation string `description:"网络参会"`
|
|
|
- ReportLink string `description:"报告链接"`
|
|
|
- City string `description:"城市"`
|
|
|
- Address string `description:"活动地址"`
|
|
|
- Highlights string `description:"活动亮点"`
|
|
|
- Remarks string `description:"备注"`
|
|
|
- ShowType string `description:"人数限制类型,1不展示限制,2可选限制,3强制限制"`
|
|
|
-}
|
|
|
-
|
|
|
-//活动详情
|
|
|
-type CygxActivity struct {
|
|
|
- ActivityId int `orm:"column(activity_id);pk";description:"活动ID 等于0新增活动,大于0修改活动"`
|
|
|
- ActivityTypeId int `description:"活动类型id"`
|
|
|
- ActivityTypeName string `description:"活动类型名称"`
|
|
|
- ChartPermissionId int `description:"行业id"`
|
|
|
- ChartPermissionName string `description:"行业名称"`
|
|
|
- Body string `description:"内容"`
|
|
|
- CreateTime time.Time `description:"创建时间"`
|
|
|
- IsLimitPeople int `description:"是否限制人数 1是,0否"`
|
|
|
- LimitPeopleNum int `description:"限制的人数数量"`
|
|
|
- CustomerTypeIds string `description:"活动可见的客户类型,多个ID用 , 隔开"`
|
|
|
- PublishStatus int `description:"发布状态 1已发布,0未发布"`
|
|
|
- LastUpdatedTime time.Time `description:"更新时间"`
|
|
|
- ActivityTime string `description:"活动时间"`
|
|
|
- ActivityTimeText string `description:"活动时间带文字"`
|
|
|
- DistinguishedGuest string `description:"嘉宾"`
|
|
|
- Host string `description:"主持人"`
|
|
|
- MainlandTell string `description:"大陆拨入号"`
|
|
|
- HongKongTell string `description:"香港拨入号"`
|
|
|
- TaiwanTell string `description:"台湾拨入号"`
|
|
|
- AmericaTell string `description:"美国拨入号"`
|
|
|
- ParticipationCode string `description:"参会密码"`
|
|
|
- Theme string `description:"主题"`
|
|
|
- Expert string `description:"专家"`
|
|
|
- ActivityName string `description:"活动名称"`
|
|
|
- OnlineParticipation string `description:"网络参会"`
|
|
|
- ReportLink string `description:"报告链接"`
|
|
|
- City string `description:"城市"`
|
|
|
- Address string `description:"活动地址"`
|
|
|
- Highlights string `description:"活动亮点"`
|
|
|
- Remarks string `description:"备注"`
|
|
|
-}
|
|
|
-
|
|
|
-type CygxActivityEditDetail struct {
|
|
|
- ActivityId int `orm:"column(activity_id);pk";description:"活动ID 等于0新增活动,大于0修改活动"`
|
|
|
- ActivityTypeId int `description:"活动类型id"`
|
|
|
- ChartPermissionId int `description:"行业id"`
|
|
|
- Body string `description:"内容"`
|
|
|
- LimitPeopleNum int `description:"限制的人数数量"`
|
|
|
- CustomerTypeIds string `description:"活动可见的客户类型,多个ID用 , 隔开"`
|
|
|
-}
|
|
|
-
|
|
|
-//添加活动
|
|
|
-func AddActivity(item *CygxActivity) (newId int64, err error) {
|
|
|
- o := orm.NewOrm()
|
|
|
- newId, err = o.Insert(item)
|
|
|
- return
|
|
|
+ ActivityId int `orm:"column(activity_id);pk";description:"活动ID "`
|
|
|
+ ActivityTypeId int `description:"活动类型id"`
|
|
|
+ ActivityTypeName string `description:"活动类型名称"`
|
|
|
+ ChartPermissionId int `description:"行业id"`
|
|
|
+ ChartPermissionName string `description:"行业名称"`
|
|
|
+ Body string `description:"内容"`
|
|
|
+ CreateTime string `description:"创建时间"`
|
|
|
+ IsLimitPeople int `description:"是否限制人数 1是,0否"`
|
|
|
+ LimitPeopleNum string `description:"限制的人数数量"`
|
|
|
+ LastUpdatedTime string `description:"更新时间"`
|
|
|
+ ActivityTime string `description:"活动时间"`
|
|
|
+ ActivityTimeText string `description:"活动时间带文字"`
|
|
|
+ DistinguishedGuest string `description:"嘉宾"`
|
|
|
+ Host string `description:"主持人"`
|
|
|
+ MainlandTell string `description:"大陆拨入号"`
|
|
|
+ HongKongTell string `description:"香港拨入号"`
|
|
|
+ TaiwanTell string `description:"台湾拨入号"`
|
|
|
+ AmericaTell string `description:"美国拨入号"`
|
|
|
+ ParticipationCode string `description:"参会密码"`
|
|
|
+ Theme string `description:"主题"`
|
|
|
+ Expert string `description:"专家"`
|
|
|
+ ActivityName string `description:"活动名称"`
|
|
|
+ OnlineParticipation string `description:"网络参会"`
|
|
|
+ ReportLink string `description:"报告链接"`
|
|
|
+ City string `description:"城市"`
|
|
|
+ Address string `description:"活动地址"`
|
|
|
+ Highlights string `description:"活动亮点"`
|
|
|
+ Remarks string `description:"备注"`
|
|
|
+ ShowType string `description:"人数限制类型,1不展示限制,2可选限制,3强制限制"`
|
|
|
+ IsSignup int `description:"是否已报名 1是 ,0 否"`
|
|
|
+ SignupNum int `description:"已报名人数"`
|
|
|
+ ActiveState string `description:"活动进行状态 未开始:1、进行中2、已结束3"`
|
|
|
+ IsCancelMeetingReminder int `description:"是否取消会议提醒 1展示取消会议提醒 ,0展示会议提醒"`
|
|
|
}
|
|
|
|
|
|
//通过纪要ID获取活动详情
|
|
@@ -148,19 +94,14 @@ func GetAddActivityInfoById(ActivityId int) (item *ActivityDetail, err error) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//通过ID获取活动详情
|
|
|
-func GetAddActivityInfoEditById(ActivityId int) (item *CygxActivityEditDetail, err error) {
|
|
|
- o := orm.NewOrm()
|
|
|
- sql := `SELECT * FROM cygx_activity WHERE activity_id=?`
|
|
|
- err = o.Raw(sql, ActivityId).QueryRow(&item)
|
|
|
- return
|
|
|
-}
|
|
|
-
|
|
|
-//修改
|
|
|
-func EditActivity(item *CygxActivity, oldPublishStatus int) (err error) {
|
|
|
+//通过纪要ID获取活动详情
|
|
|
+func GetAddActivityInfoByIdShow(uid, ActivityId int) (item *ActivityDetail, err error) {
|
|
|
o := orm.NewOrm()
|
|
|
- sql := `UPDATE cygx_activity SET activity_type_id=?, activity_type_name=?, chart_permission_id=?, chart_permission_name=?, body=?, is_limit_people=?,limit_people_num = ?,customer_type_ids=?,publish_status =?, last_updated_time=? ,activity_time=?, activity_time_text=?, distinguished_guest=?, host=?, mainland_tell=?, hong_kong_tell=?, taiwan_tell=?, america_tell=?, participation_code=?, theme=?, expert=?, activity_name=?, online_participation=?, report_link=?, city=?, address=?, highlights=?, remarks=? WHERE activity_id=?`
|
|
|
- _, err = o.Raw(sql, item.ActivityTypeId, item.ActivityTypeName, item.ChartPermissionId, item.ChartPermissionName, item.Body, item.IsLimitPeople, item.LimitPeopleNum, item.CustomerTypeIds, item.PublishStatus, item.LastUpdatedTime, item.ActivityTime, item.ActivityTimeText, item.DistinguishedGuest, item.Host, item.MainlandTell, item.HongKongTell, item.TaiwanTell, item.AmericaTell, item.ParticipationCode, item.Theme, item.Expert, item.ActivityName, item.OnlineParticipation, item.ReportLink, item.City, item.Address, item.Highlights, item.Remarks, item.ActivityId).Exec()
|
|
|
+ sql := `SELECT *,( SELECT COUNT( 1 ) FROM cygx_activity_signup AS s WHERE s.activity_id = a.activity_id AND s.user_id = ? ) AS is_signup,
|
|
|
+ ( SELECT COUNT( DISTINCT user_id ) FROM cygx_activity_signup AS s WHERE s.activity_id = a.activity_id ) AS signup_num,
|
|
|
+ ( SELECT COUNT( 1 ) FROM cygx_activity_meeting_reminder AS m WHERE m.activity_id = a.activity_id AND m.user_id = ? ) AS is_cancel_meeting_reminder
|
|
|
+ FROM cygx_activity AS a WHERE activity_id=? AND publish_status = 1 `
|
|
|
+ err = o.Raw(sql, uid, uid, ActivityId).QueryRow(&item)
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -252,14 +193,6 @@ func GetActivityCountById(activityId int) (count int, err error) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//修改发布状态
|
|
|
-func ActivityPublishAndCancel(item *CygxActivity) (err error) {
|
|
|
- sql := `UPDATE cygx_activity SET publish_status=? , last_updated_time= ? WHERE activity_id=? `
|
|
|
- o := orm.NewOrm()
|
|
|
- _, err = o.Raw(sql, item.PublishStatus, time.Now(), item.ActivityId).Exec()
|
|
|
- return
|
|
|
-}
|
|
|
-
|
|
|
//删除数据
|
|
|
func DeleteActivity(activityId int) (err error) {
|
|
|
o := orm.NewOrm()
|
|
@@ -267,99 +200,3 @@ func DeleteActivity(activityId int) (err error) {
|
|
|
_, err = o.Raw(sql, activityId).Exec()
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
-func ActivityBodyAnalysis(body string) (itemr *CygxActivity, errstr string) {
|
|
|
- item := new(CygxActivity)
|
|
|
- doc, _ := goquery.NewDocumentFromReader(strings.NewReader(body))
|
|
|
- doc.Find("p").Each(func(i int, s *goquery.Selection) {
|
|
|
- contentTxt := s.Text()
|
|
|
- contentTxt = strings.Replace(contentTxt, "\n", "", -1)
|
|
|
- contentTxt = strings.Replace(contentTxt, " ", "", -1)
|
|
|
-
|
|
|
- if strings.Contains(contentTxt, "活动名称:") {
|
|
|
- item.ActivityName = strings.Replace(contentTxt, "活动名称:", "", -1)
|
|
|
- }
|
|
|
- if strings.Contains(contentTxt, "时间:") {
|
|
|
- strText := strings.Replace(contentTxt, "时间:", "", -1)
|
|
|
- item.ActivityTimeText = strText
|
|
|
- strText = strings.Replace(strText, "AM", "", -1)
|
|
|
- strText = strings.Replace(strText, "PM", "", -1)
|
|
|
- strText = strings.Replace(strText, "(", "", -1)
|
|
|
- strText = strings.Replace(strText, ")", "", -1)
|
|
|
-
|
|
|
- fmt.Println("——————————")
|
|
|
- var hrefRegexp = regexp.MustCompile("[^\\\\x00-\\\\xff]+")
|
|
|
- match := hrefRegexp.FindAllString(strText, -1)
|
|
|
- for _, v := range match {
|
|
|
- fmt.Println(v)
|
|
|
- }
|
|
|
- fmt.Println("——————————")
|
|
|
- if match != nil {
|
|
|
- timeStr := strings.Replace(strText, match[len(match)-1], " ", -1)
|
|
|
- resultTime := utils.StrTimeToTime(timeStr + ":00") //时间字符串格式转时间格式
|
|
|
- fmt.Println(timeStr)
|
|
|
- fmt.Println(resultTime)
|
|
|
- item.ActivityTime = timeStr
|
|
|
- //fmt.Println("+++++++++++++")
|
|
|
- //fmt.Println(timeStr)
|
|
|
- //fmt.Println(len(match))
|
|
|
- //fmt.Println(match[0])
|
|
|
- //fmt.Println(match[1])
|
|
|
- //fmt.Println(match[2])
|
|
|
- //fmt.Println(timeStr)
|
|
|
- res := time.Now().After(resultTime)
|
|
|
- if res {
|
|
|
- errstr = "活动时间" + strText + "应在当前时间之后"
|
|
|
- }
|
|
|
- //fmt.Println("=================")
|
|
|
- }
|
|
|
- }
|
|
|
- if strings.Contains(contentTxt, "嘉宾:") {
|
|
|
- item.DistinguishedGuest = strings.Replace(contentTxt, "嘉宾:", "", -1)
|
|
|
- }
|
|
|
- if strings.Contains(contentTxt, "主持人:") {
|
|
|
- item.Host = strings.Replace(contentTxt, "主持人:", "", -1)
|
|
|
- }
|
|
|
- if strings.Contains(contentTxt, "大陆拨入号:") {
|
|
|
- item.MainlandTell = strings.Replace(contentTxt, "大陆拨入号:", "", -1)
|
|
|
- }
|
|
|
- if strings.Contains(contentTxt, "香港拨入号:") {
|
|
|
- item.HongKongTell = strings.Replace(contentTxt, "香港拨入号:", "", -1)
|
|
|
- }
|
|
|
- if strings.Contains(contentTxt, "台湾拨入号:") {
|
|
|
- item.TaiwanTell = strings.Replace(contentTxt, "台湾拨入号:", "", -1)
|
|
|
- }
|
|
|
- if strings.Contains(contentTxt, "美国拨入号:") {
|
|
|
- item.AmericaTell = strings.Replace(contentTxt, "美国拨入号:", "", -1)
|
|
|
- }
|
|
|
- if strings.Contains(contentTxt, "参会密码:") {
|
|
|
- item.ParticipationCode = strings.Replace(contentTxt, "参会密码:", "", -1)
|
|
|
- }
|
|
|
- if strings.Contains(contentTxt, "主题:") {
|
|
|
- item.Theme = strings.Replace(contentTxt, "主题:", "", -1)
|
|
|
- }
|
|
|
- if strings.Contains(contentTxt, "专家:") {
|
|
|
- item.Expert = strings.Replace(contentTxt, "专家:", "", -1)
|
|
|
- }
|
|
|
- if strings.Contains(contentTxt, "网络参会:") {
|
|
|
- item.OnlineParticipation = strings.Replace(contentTxt, "网络参会:", "", -1)
|
|
|
- }
|
|
|
- if strings.Contains(contentTxt, "报告链接:") {
|
|
|
- item.ReportLink = strings.Replace(contentTxt, "报告链接:", "", -1)
|
|
|
- }
|
|
|
- if strings.Contains(contentTxt, "城市:") {
|
|
|
- item.City = strings.Replace(contentTxt, "城市:", "", -1)
|
|
|
- }
|
|
|
- if strings.Contains(contentTxt, "活动地址:") {
|
|
|
- item.Address = strings.Replace(contentTxt, "活动地址:", "", -1)
|
|
|
- }
|
|
|
- if strings.Contains(contentTxt, "活动亮点:") {
|
|
|
- item.Highlights = strings.Replace(contentTxt, "活动亮点:", "", -1)
|
|
|
- }
|
|
|
- if strings.Contains(contentTxt, "备注:") {
|
|
|
- item.Remarks = strings.Replace(contentTxt, "备注:", "", -1)
|
|
|
- }
|
|
|
- })
|
|
|
- itemr = item
|
|
|
- return
|
|
|
-}
|