作者 tangxvhui

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

... ... @@ -819,8 +819,29 @@ func RankRangeMove(fromId int64, toId int64, relationId []int64, companyid int64
o.Rollback()
return protocol.NewErrWithMessage("1")
}
if err = removeRanks(o, companyid, fromRankRange.RankTypeId, fromRankRange.Id, relationId); err != nil {
log.Error("更新rank数据失败:%s", err)
o.Rollback()
return protocol.NewErrWithMessage("1")
}
o.Commit()
return nil
}
// func SetAutoCreateRank
//排行榜批量转移用户时 ,把当前进行的排行榜分数置为无效
func removeRanks(o orm.Ormer, companyId, rankTypeId, rankRangeId int64, relationIds []int64) (err error) {
var sqlRemoveRanks = fmt.Sprintf(`
update rank set enable_status=0,update_at=NOW()
where company_id=? and rank_type_id=? and rank_range_id=? and rank_period_id in
(
select id from rank_period where company_id=? and rank_type_id=? and status=1
) and relation_id in (%v)
`, utils.JoinInt64s(relationIds, ","))
if _, err = o.Raw(sqlRemoveRanks, companyId, rankTypeId, rankRangeId,
companyId, rankTypeId,
).Exec(); err != nil {
return
}
return
}
... ...
package utils
import (
"fmt"
"strings"
)
... ... @@ -54,3 +55,11 @@ func ArrayStringIn(arr1 []string, s string) bool {
}
return false
}
func JoinInt64s(ids []int64, spilt string) string {
var idStrings []string = make([]string, len(ids))
for i := 0; i < len(ids); i++ {
idStrings[i] = fmt.Sprintf("%v", ids[i])
}
return strings.Join(idStrings, spilt)
}
... ...