|
@@ -14,8 +14,6 @@ import ( |
|
|
"errors" |
|
|
"errors" |
|
|
"fmt" |
|
|
"fmt" |
|
|
"github.com/streadway/amqp" |
|
|
"github.com/streadway/amqp" |
|
|
"regexp" |
|
|
|
|
|
"strconv" |
|
|
|
|
|
"strings" |
|
|
"strings" |
|
|
"time" |
|
|
"time" |
|
|
) |
|
|
) |
|
@@ -94,73 +92,73 @@ func CanalOrderConsumev2(queue md.MqQueue) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func CanalOrderConsume(queue md.MqQueue) { |
|
|
func CanalOrderConsume(queue md.MqQueue) { |
|
|
now := time.Now() |
|
|
|
|
|
var list []model2.Group |
|
|
|
|
|
err := db.ImDb.Where("master_id = 68823769").And("user_num > ?", 500).Find(&list) |
|
|
|
|
|
//eg := db.DBs["68823769"] |
|
|
|
|
|
for _, v := range list { |
|
|
|
|
|
var groupUsers []model2.GroupUser |
|
|
|
|
|
var groupLeader model2.GroupUser |
|
|
|
|
|
err = db.ImDb.Where("group_id = ?", v.Id).And("member_type = 2").Limit(10000, 499).Find(&groupUsers) |
|
|
|
|
|
db.ImDb.Where("group_id = ?", v.Id).And("member_type = 1").Get(&groupLeader) |
|
|
|
|
|
|
|
|
|
|
|
//新增一个群 |
|
|
|
|
|
re := regexp.MustCompile("[0-9]+") |
|
|
|
|
|
num := re.FindAllString(v.Name, -1)[0] |
|
|
|
|
|
name := strings.Replace(v.Name, num, strconv.Itoa(utils.StrToInt(num)+1), 1) |
|
|
|
|
|
temGroup := model2.Group{ |
|
|
|
|
|
Name: name, |
|
|
|
|
|
AvatarUrl: "", |
|
|
|
|
|
Introduction: "", |
|
|
|
|
|
UserNum: int32(len(groupUsers)) + 1, |
|
|
|
|
|
IsAllMemberBanned: 0, |
|
|
|
|
|
MasterId: v.MasterId, |
|
|
|
|
|
Extra: "", |
|
|
|
|
|
CreateTime: now, |
|
|
|
|
|
UpdateTime: now, |
|
|
|
|
|
} |
|
|
|
|
|
_, err := db.ImDb.InsertOne(&temGroup) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
panic(err) |
|
|
|
|
|
} |
|
|
|
|
|
groupId := temGroup.Id |
|
|
|
|
|
|
|
|
|
|
|
//新增群主 |
|
|
|
|
|
_, err = db.ImDb.InsertOne(model2.GroupUser{ |
|
|
|
|
|
GroupId: groupId, |
|
|
|
|
|
UserId: groupLeader.UserId, |
|
|
|
|
|
MemberType: 1, |
|
|
|
|
|
Status: 0, |
|
|
|
|
|
CreateTime: now.Format("2006-01-02 15:04:05"), |
|
|
|
|
|
UpdateTime: now.Format("2006-01-02 15:04:05"), |
|
|
|
|
|
}) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
panic(err) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for _, groupUser := range groupUsers { |
|
|
|
|
|
groupUser.GroupId = groupId |
|
|
|
|
|
db.ImDb.ID(groupUser.Id).Update(groupUser) |
|
|
|
|
|
} |
|
|
|
|
|
v.UserNum = 500 |
|
|
|
|
|
db.ImDb.ID(v.Id).Update(v) |
|
|
|
|
|
var oldDouShenImGroup model.DouShenImGroup |
|
|
|
|
|
if has, err := db.Db.Where("group_id =?", v.Id).Get(&oldDouShenImGroup); err != nil || has == false { |
|
|
|
|
|
panic(err) |
|
|
|
|
|
} |
|
|
|
|
|
_, err = db.DouShenImGroupInsert(db.Db, &model.DouShenImGroup{ |
|
|
|
|
|
Kind: oldDouShenImGroup.Kind, |
|
|
|
|
|
Uid: int(oldDouShenImGroup.Uid), |
|
|
|
|
|
GroupId: int(groupId), |
|
|
|
|
|
IsFull: 0, |
|
|
|
|
|
Name: name, |
|
|
|
|
|
CreateTime: now, |
|
|
|
|
|
UpdateTime: now, |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return |
|
|
|
|
|
fmt.Println(">>>>>>>>>>>>>>>>>>>>>>>>") |
|
|
|
|
|
|
|
|
//now := time.Now() |
|
|
|
|
|
//var list []model2.Group |
|
|
|
|
|
//err := db.ImDb.Where("master_id = 68823769").And("user_num > ?", 500).Find(&list) |
|
|
|
|
|
////eg := db.DBs["68823769"] |
|
|
|
|
|
//for _, v := range list { |
|
|
|
|
|
// var groupUsers []model2.GroupUser |
|
|
|
|
|
// var groupLeader model2.GroupUser |
|
|
|
|
|
// err = db.ImDb.Where("group_id = ?", v.Id).And("member_type = 2").Limit(10000, 499).Find(&groupUsers) |
|
|
|
|
|
// db.ImDb.Where("group_id = ?", v.Id).And("member_type = 1").Get(&groupLeader) |
|
|
|
|
|
// |
|
|
|
|
|
// //新增一个群 |
|
|
|
|
|
// re := regexp.MustCompile("[0-9]+") |
|
|
|
|
|
// num := re.FindAllString(v.Name, -1)[0] |
|
|
|
|
|
// name := strings.Replace(v.Name, num, strconv.Itoa(utils.StrToInt(num)+1), 1) |
|
|
|
|
|
// temGroup := model2.Group{ |
|
|
|
|
|
// Name: name, |
|
|
|
|
|
// AvatarUrl: "", |
|
|
|
|
|
// Introduction: "", |
|
|
|
|
|
// UserNum: int32(len(groupUsers)) + 1, |
|
|
|
|
|
// IsAllMemberBanned: 0, |
|
|
|
|
|
// MasterId: v.MasterId, |
|
|
|
|
|
// Extra: "", |
|
|
|
|
|
// CreateTime: now, |
|
|
|
|
|
// UpdateTime: now, |
|
|
|
|
|
// } |
|
|
|
|
|
// _, err := db.ImDb.InsertOne(&temGroup) |
|
|
|
|
|
// if err != nil { |
|
|
|
|
|
// panic(err) |
|
|
|
|
|
// } |
|
|
|
|
|
// groupId := temGroup.Id |
|
|
|
|
|
// |
|
|
|
|
|
// //新增群主 |
|
|
|
|
|
// _, err = db.ImDb.InsertOne(model2.GroupUser{ |
|
|
|
|
|
// GroupId: groupId, |
|
|
|
|
|
// UserId: groupLeader.UserId, |
|
|
|
|
|
// MemberType: 1, |
|
|
|
|
|
// Status: 0, |
|
|
|
|
|
// CreateTime: now.Format("2006-01-02 15:04:05"), |
|
|
|
|
|
// UpdateTime: now.Format("2006-01-02 15:04:05"), |
|
|
|
|
|
// }) |
|
|
|
|
|
// if err != nil { |
|
|
|
|
|
// panic(err) |
|
|
|
|
|
// } |
|
|
|
|
|
// |
|
|
|
|
|
// for _, groupUser := range groupUsers { |
|
|
|
|
|
// groupUser.GroupId = groupId |
|
|
|
|
|
// db.ImDb.ID(groupUser.Id).Update(groupUser) |
|
|
|
|
|
// } |
|
|
|
|
|
// v.UserNum = 500 |
|
|
|
|
|
// db.ImDb.ID(v.Id).Update(v) |
|
|
|
|
|
// var oldDouShenImGroup model.DouShenImGroup |
|
|
|
|
|
// if has, err := db.Db.Where("group_id =?", v.Id).Get(&oldDouShenImGroup); err != nil || has == false { |
|
|
|
|
|
// panic(err) |
|
|
|
|
|
// } |
|
|
|
|
|
// _, err = db.DouShenImGroupInsert(db.Db, &model.DouShenImGroup{ |
|
|
|
|
|
// Kind: oldDouShenImGroup.Kind, |
|
|
|
|
|
// Uid: int(oldDouShenImGroup.Uid), |
|
|
|
|
|
// GroupId: int(groupId), |
|
|
|
|
|
// IsFull: 0, |
|
|
|
|
|
// Name: name, |
|
|
|
|
|
// CreateTime: now, |
|
|
|
|
|
// UpdateTime: now, |
|
|
|
|
|
// }) |
|
|
|
|
|
//} |
|
|
|
|
|
// |
|
|
|
|
|
//return |
|
|
|
|
|
//fmt.Println(">>>>>>>>>>>>>>>>>>>>>>>>") |
|
|
ch, err := rabbit.Cfg.Pool.GetChannel() |
|
|
ch, err := rabbit.Cfg.Pool.GetChannel() |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
logx.Error(err) |
|
|
logx.Error(err) |
|
|