作者 唐旭辉

Merge branch 'test' of http://gitlab.fjmaimaimai.com/mmm-go/oppmg into test

... ... @@ -522,6 +522,12 @@ func EditRankRange(id int64, name string, rangetype int8, relationId []int64, co
}
} else {
//移除不在当前范围的榜单数据
if err = removeRanksNotIn(o, companyid, rankRange.RankTypeId, rankRange.Id, relationId); err != nil {
log.Error("更新rank数据失败:%s", err)
o.Rollback()
return protocol.NewErrWithMessage("1")
}
//移除在其他范围的榜单数据
if err = removeRanksOutRange(o, companyid, rankRange.RankTypeId, rankRange.Id, relationId); err != nil {
log.Error("更新rank数据失败:%s", err)
o.Rollback()
... ... @@ -960,6 +966,28 @@ where company_id=%v and rank_type_id=%v and rank_range_id<>%v and enable_status=
return
}
//移除参与范围外 其他参与范围的已统计版本记录
//@rankRangeId 当前参与范围编号
func removeRanksNotIn(o orm.Ormer, companyId, rankTypeId, rankRangeId int64, relationIds []int64) (err error) {
if len(relationIds) <= 0 {
return
}
var sqlRemoveRanks = fmt.Sprintf(`
update rank set enable_status=0,update_at=NOW()
where company_id=%v and rank_type_id=%v and rank_range_id=%v and enable_status=1 and rank_period_id in
(
select id from rank_period where company_id=%v and rank_type_id=%v and status=1
)
`, companyId, rankTypeId, rankRangeId,
companyId, rankTypeId)
sqlRemoveRanks += fmt.Sprintf(" and relation_id not in (%v)", utils.JoinInt64s(relationIds, ","))
if err = utils.ExecuteSQLWithOrmer(o, sqlRemoveRanks); err != nil {
return
}
return
}
//移除已存在的榜单记录(榜单周期内)
//同时只会存在在一个排行榜单里面
func removeAllRanks(o orm.Ormer, companyId, rankTypeId int64, rankRangeId int64, relationIds []int64) (err error) {
... ...