|
@@ -358,21 +358,70 @@ func (this *ActivityCoAntroller) ScheduleList() {
|
|
|
}
|
|
|
startSize = utils.StartIndex(currentIndex, pageSize)
|
|
|
var condition string
|
|
|
+ var conditionCount string
|
|
|
var pars []interface{}
|
|
|
- //condition += ` AND art.publish_status = 1 AND art.active_state IN(1,2) AND s.is_cancel = 0 AND s.fail_type = 0 `
|
|
|
- condition += ` AND art.publish_status = 1 AND art.active_state IN(1,2) `
|
|
|
- total, err := models.GetScheduleCount(uid)
|
|
|
+ condition += ` AND art.publish_status = 1 `
|
|
|
+ total, err := models.GetScheduleCount(conditionCount, uid)
|
|
|
+ page := paging.GetPaging(currentIndex, pageSize, total)
|
|
|
if err != nil {
|
|
|
br.Msg = "获取失败"
|
|
|
br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
- list, errList := models.GetScheduleList(condition, pars, uid, startSize, pageSize)
|
|
|
- if errList != nil {
|
|
|
+ conditionCount = ` AND art.active_state = 2 `
|
|
|
+ totalCount, err := models.GetScheduleCount(conditionCount, uid) //获取正在进行中的活动数量
|
|
|
+ if err != nil {
|
|
|
br.Msg = "获取失败"
|
|
|
- br.ErrMsg = "获取失败,Err:" + errList.Error()
|
|
|
+ br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
+ var list []*models.CygxActivityList
|
|
|
+ fmt.Println(totalCount)
|
|
|
+ //全部都是进行中的活动
|
|
|
+ if totalCount > currentIndex*pageSize {
|
|
|
+ condition += ` AND art.active_state IN(2) `
|
|
|
+ listHave, errList := models.GetScheduleList(condition, pars, uid, startSize, pageSize)
|
|
|
+ list = listHave
|
|
|
+ if errList != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取失败,Err:" + errList.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ fmt.Println("22222")
|
|
|
+ } else if totalCount > currentIndex-1*pageSize && totalCount < currentIndex*pageSize { //部分是进行中的活动
|
|
|
+ condition = ` AND art.publish_status = 1 AND art.active_state IN(2) `
|
|
|
+ listHave, errList := models.GetScheduleList(condition, pars, uid, startSize, pageSize)
|
|
|
+ list = listHave
|
|
|
+ if errList != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取失败,Err:" + errList.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ fmt.Println("33333")
|
|
|
+ pageSize = pageSize - len(listHave)
|
|
|
+ condition = ` AND art.publish_status = 1 AND art.active_state IN(1,3) `
|
|
|
+ listOther, errList := models.GetScheduleList(condition, pars, uid, startSize, pageSize)
|
|
|
+ if errList != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取失败,Err:" + errList.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ fmt.Println("长度", len(listOther))
|
|
|
+ if len(listOther) > 0 {
|
|
|
+ for _, v := range listOther {
|
|
|
+ list = append(list, v)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ condition += ` AND art.active_state IN(1,3)` //全部都不是进行中的活动
|
|
|
+ listOther, errList := models.GetScheduleList(condition, pars, uid, startSize, pageSize)
|
|
|
+ list = listOther
|
|
|
+ if errList != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取失败,Err:" + errList.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
for k, v := range list {
|
|
|
if strings.Contains(v.ActivityName, "【") {
|
|
|
list[k].IsBrackets = 1
|
|
@@ -385,7 +434,6 @@ func (this *ActivityCoAntroller) ScheduleList() {
|
|
|
list[k].IsShowSustainable = true
|
|
|
}
|
|
|
}
|
|
|
- page := paging.GetPaging(currentIndex, pageSize, total)
|
|
|
resp := new(models.GetCygxActivityListRep)
|
|
|
resp.List = list
|
|
|
resp.Paging = page
|