Merge branch 'test' of http://gitlab.fjmaimaimai.com/mmm-go/oppmg into test
正在显示
1 个修改的文件
包含
28 行增加
和
0 行删除
@@ -522,6 +522,12 @@ func EditRankRange(id int64, name string, rangetype int8, relationId []int64, co | @@ -522,6 +522,12 @@ func EditRankRange(id int64, name string, rangetype int8, relationId []int64, co | ||
522 | } | 522 | } |
523 | } else { | 523 | } else { |
524 | //移除不在当前范围的榜单数据 | 524 | //移除不在当前范围的榜单数据 |
525 | + if err = removeRanksNotIn(o, companyid, rankRange.RankTypeId, rankRange.Id, relationId); err != nil { | ||
526 | + log.Error("更新rank数据失败:%s", err) | ||
527 | + o.Rollback() | ||
528 | + return protocol.NewErrWithMessage("1") | ||
529 | + } | ||
530 | + //移除在其他范围的榜单数据 | ||
525 | if err = removeRanksOutRange(o, companyid, rankRange.RankTypeId, rankRange.Id, relationId); err != nil { | 531 | if err = removeRanksOutRange(o, companyid, rankRange.RankTypeId, rankRange.Id, relationId); err != nil { |
526 | log.Error("更新rank数据失败:%s", err) | 532 | log.Error("更新rank数据失败:%s", err) |
527 | o.Rollback() | 533 | o.Rollback() |
@@ -960,6 +966,28 @@ where company_id=%v and rank_type_id=%v and rank_range_id<>%v and enable_status= | @@ -960,6 +966,28 @@ where company_id=%v and rank_type_id=%v and rank_range_id<>%v and enable_status= | ||
960 | return | 966 | return |
961 | } | 967 | } |
962 | 968 | ||
969 | +//移除参与范围外 其他参与范围的已统计版本记录 | ||
970 | +//@rankRangeId 当前参与范围编号 | ||
971 | +func removeRanksNotIn(o orm.Ormer, companyId, rankTypeId, rankRangeId int64, relationIds []int64) (err error) { | ||
972 | + if len(relationIds) <= 0 { | ||
973 | + return | ||
974 | + } | ||
975 | + var sqlRemoveRanks = fmt.Sprintf(` | ||
976 | + update rank set enable_status=0,update_at=NOW() | ||
977 | +where company_id=%v and rank_type_id=%v and rank_range_id=%v and enable_status=1 and rank_period_id in | ||
978 | +( | ||
979 | + select id from rank_period where company_id=%v and rank_type_id=%v and status=1 | ||
980 | +) | ||
981 | +`, companyId, rankTypeId, rankRangeId, | ||
982 | + companyId, rankTypeId) | ||
983 | + | ||
984 | + sqlRemoveRanks += fmt.Sprintf(" and relation_id not in (%v)", utils.JoinInt64s(relationIds, ",")) | ||
985 | + if err = utils.ExecuteSQLWithOrmer(o, sqlRemoveRanks); err != nil { | ||
986 | + return | ||
987 | + } | ||
988 | + return | ||
989 | +} | ||
990 | + | ||
963 | //移除已存在的榜单记录(榜单周期内) | 991 | //移除已存在的榜单记录(榜单周期内) |
964 | //同时只会存在在一个排行榜单里面 | 992 | //同时只会存在在一个排行榜单里面 |
965 | func removeAllRanks(o orm.Ormer, companyId, rankTypeId int64, rankRangeId int64, relationIds []int64) (err error) { | 993 | func removeAllRanks(o orm.Ormer, companyId, rankTypeId int64, rankRangeId int64, relationIds []int64) (err error) { |
-
请 注册 或 登录 后发表评论