|
|
@@ -5,6 +5,7 @@ import ( |
|
|
|
"applet/app/db" |
|
|
|
db2 "applet/app/db/gim" |
|
|
|
"applet/app/db/gim/model" |
|
|
|
model2 "applet/app/db/model" |
|
|
|
"applet/app/svc" |
|
|
|
utils2 "applet/app/utils" |
|
|
|
"applet/app/utils/logx" |
|
|
@@ -116,62 +117,108 @@ func handleDouShenUserRegisterConsumeForOperationCenter(msgData []byte) error { |
|
|
|
return err |
|
|
|
} |
|
|
|
if OperationGroup == nil { |
|
|
|
utils2.FilePutContents("douShenUserRegisterConsumeForOperationCenter_not_found", utils2.SerializeStr(msg)) |
|
|
|
return errors.New("当前城市合伙人暂未拥有运营中心群,请联系管理员!!!") |
|
|
|
} else { |
|
|
|
userGroup, err2 := db2.GroupUserGetOneByParams(db.ImDb, 1, map[string]interface{}{ |
|
|
|
"key": "group_id", |
|
|
|
"value": OperationGroup.GroupId, |
|
|
|
//创建运营中心群 |
|
|
|
operationCenterUser, err := db.UserFindByID(db.DBs[msg.MasterId], msg.OperationCenterUid) |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
|
operationCenterGimUser, err := db2.UserGetOneByParams(db.ImDb, msg.MasterId, map[string]interface{}{ |
|
|
|
"key": "phone_number", |
|
|
|
"value": operationCenterUser.Phone, |
|
|
|
}) |
|
|
|
if err2 != nil { |
|
|
|
return err2 |
|
|
|
if operationCenterGimUser == nil { |
|
|
|
return errors.New("运营中心用户暂未注册im系统") |
|
|
|
} |
|
|
|
if userGroup == nil { |
|
|
|
return errors.New("当前运营中心群暂未设置群主,请联系管理员!!!") |
|
|
|
groupName := "抖省(" + utils2.AnyToString(msg.OperationCenterUid) + ")运营中心【1】群" |
|
|
|
if operationCenterUser.Nickname != "" { |
|
|
|
groupName = "抖省(" + utils2.AnyToString(operationCenterUser.Nickname) + ")运营中心【1】群" |
|
|
|
} |
|
|
|
|
|
|
|
//加入群 |
|
|
|
_, err = utils.GetLogicExtClient(cfg.ImLogicRpc.URL, cfg.ImLogicRpc.PORT).AddGroupMembers(utils.GetCtx("", strconv.FormatInt(userGroup.UserId, 10), "", msg.MasterId), &pb.AddGroupMembersReq{ |
|
|
|
GroupId: int64(OperationGroup.GroupId), |
|
|
|
UserIds: []int64{gimUser.Id}, |
|
|
|
resp, err := utils.GetLogicExtClient(cfg.ImLogicRpc.URL, cfg.ImLogicRpc.PORT).CreateGroup(utils.GetCtx("", utils2.Int64ToStr(operationCenterGimUser.Id), "", msg.MasterId), &pb.CreateGroupReq{ |
|
|
|
Name: groupName, |
|
|
|
AvatarUrl: "", |
|
|
|
//Introduction: gimUser.Nickname + "的粉丝群", |
|
|
|
Introduction: "", |
|
|
|
Extra: "", |
|
|
|
MemberIds: nil, |
|
|
|
}) |
|
|
|
|
|
|
|
//发送专属红包 |
|
|
|
gimSendSpeciallyRedPackageUser, err := db2.DbSysCfg.SysCfgGetOne("send_specially_red_package_user", msg.MasterId) |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
|
if gimSendSpeciallyRedPackageUser == nil { |
|
|
|
return errors.New("暂未设置专属红包发送用户") |
|
|
|
} |
|
|
|
sendSpeciallyRedPackageUser, err := db.SysCfgGetOne(db.DBs[msg.MasterId], "send_specially_red_package_user") |
|
|
|
//插入 dou_shen_im_group 记录 |
|
|
|
now := time.Now() |
|
|
|
_, err = db.DouShenImGroupInsert(db.Db, &model2.DouShenImGroup{ |
|
|
|
Kind: 2, |
|
|
|
Uid: int(msg.OperationCenterUid), |
|
|
|
GroupId: int(resp.GroupId), |
|
|
|
IsFull: 0, |
|
|
|
Name: groupName, |
|
|
|
CreateTime: now, |
|
|
|
UpdateTime: now, |
|
|
|
}) |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
|
amount, err := getSendAmount(msg.MasterId) |
|
|
|
OperationGroup, err = db.DouShenImGroupGetOneByParamsForFans(db.Db, 2, msg.OperationCenterUid) |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
|
args := md.SendRedPackageReq{ |
|
|
|
UserId: gimSendSpeciallyRedPackageUser.Val, |
|
|
|
DeviceId: "", |
|
|
|
Token: "", |
|
|
|
Amount: amount, |
|
|
|
RedPacketType: 5, |
|
|
|
RedPacketNums: 1, |
|
|
|
RedPacketContent: "抖省赚钱,大吉大利", |
|
|
|
RedPacketSmallContent: gimUser.Nickname + "的专属红包", |
|
|
|
ReceiverType: 2, |
|
|
|
ReceiverId: int64(OperationGroup.GroupId), |
|
|
|
SendTime: utils2.UnixMilliTime(time.Now()), |
|
|
|
ToUserIds: []int64{gimUser.Id}, |
|
|
|
RedPackageCover: "", |
|
|
|
} |
|
|
|
err, _ = svc.CurlSendRedPackage(args, msg.MasterId, sendSpeciallyRedPackageUser.Val) |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
if OperationGroup == nil { |
|
|
|
utils2.FilePutContents("douShenUserRegisterConsumeForOperationCenter_not_found", utils2.SerializeStr(msg)) |
|
|
|
return errors.New("当前城市合伙人暂未拥有运营中心群,请联系管理员!!!") |
|
|
|
} |
|
|
|
} |
|
|
|
userGroup, err2 := db2.GroupUserGetOneByParams(db.ImDb, 1, map[string]interface{}{ |
|
|
|
"key": "group_id", |
|
|
|
"value": OperationGroup.GroupId, |
|
|
|
}) |
|
|
|
if err2 != nil { |
|
|
|
return err2 |
|
|
|
} |
|
|
|
if userGroup == nil { |
|
|
|
return errors.New("当前运营中心群暂未设置群主,请联系管理员!!!") |
|
|
|
} |
|
|
|
|
|
|
|
//加入群 |
|
|
|
_, err = utils.GetLogicExtClient(cfg.ImLogicRpc.URL, cfg.ImLogicRpc.PORT).AddGroupMembers(utils.GetCtx("", strconv.FormatInt(userGroup.UserId, 10), "", msg.MasterId), &pb.AddGroupMembersReq{ |
|
|
|
GroupId: int64(OperationGroup.GroupId), |
|
|
|
UserIds: []int64{gimUser.Id}, |
|
|
|
}) |
|
|
|
|
|
|
|
//发送专属红包 |
|
|
|
gimSendSpeciallyRedPackageUser, err := db2.DbSysCfg.SysCfgGetOne("send_specially_red_package_user", msg.MasterId) |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
|
if gimSendSpeciallyRedPackageUser == nil { |
|
|
|
return errors.New("暂未设置专属红包发送用户") |
|
|
|
} |
|
|
|
sendSpeciallyRedPackageUser, err := db.SysCfgGetOne(db.DBs[msg.MasterId], "send_specially_red_package_user") |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
|
amount, err := getSendAmount(msg.MasterId) |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
|
args := md.SendRedPackageReq{ |
|
|
|
UserId: gimSendSpeciallyRedPackageUser.Val, |
|
|
|
DeviceId: "", |
|
|
|
Token: "", |
|
|
|
Amount: amount, |
|
|
|
RedPacketType: 5, |
|
|
|
RedPacketNums: 1, |
|
|
|
RedPacketContent: "抖省赚钱,大吉大利", |
|
|
|
RedPacketSmallContent: gimUser.Nickname + "的专属红包", |
|
|
|
ReceiverType: 2, |
|
|
|
ReceiverId: int64(OperationGroup.GroupId), |
|
|
|
SendTime: utils2.UnixMilliTime(time.Now()), |
|
|
|
ToUserIds: []int64{gimUser.Id}, |
|
|
|
RedPackageCover: "", |
|
|
|
} |
|
|
|
err, _ = svc.CurlSendRedPackage(args, msg.MasterId, sendSpeciallyRedPackageUser.Val) |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
|
return nil |
|
|
|
} |
|
|
|
|
|
|
|