Commit db416e73 authored by chenweijian's avatar chenweijian

代理分享充值限制

parent def9e5e1
package common
type MsgIdType = uint
type OnlineStatusType = uint
type GroupRoleType = uint16
type AddGroupResultType = uint
const (
APP_KICKOFF_TIME = "2020-12-19"
DEFAULT_LANG = "en"
DEFAULT_COUNTRY = "KSA"
DEFAULT_NICK = "Hilo No.%s"
DEFAULT_DESCRIPTION = "Welcome to Hilo"
DEFAULT_GROUP_NAME = "Hilo Group NO.%s"
DefaultAvatarMan = "hilo/manager/ea48b62d54a24a709de3c38702c89995.png"
DefaultAvatarWoman = "hilo/manager/ea48b62d54a24a709de3c38702c89995.png"
// 用户视频最低要求时长
BASIC_VIDEO_TIME = 1
// 公会用户视频最低要求时长
GUILD_USER_VIDEO_TIME = 15
STATUS_IN_USE = 1
STATUS_UNUSED = 2
// 公会用户是否打开通知
GuildUserNotifyOn = 1
GuildUserNotifyOff = 2
// 平台
PlatformIOS = 1
PlatformGOOGLE = 2
PlatformEggPlant = 3 // 通过starchat回调的茄子充值
PlatformCheckout = 4
// 加、减
DIRECTION_ADD = 1
DIRECTION_REDUCE = 2
// 操作类型
//发送礼物
OPERATE_TYPE_SENDGIFT = 1
//匹配条件
OPERATE_TYPE_MATCHCONDITION = 2
//建立融云会话
OPERATE_TYPE_SESSIONPAY = 3
//购买钻石
OPERATE_TYPE_BUYDIAMOND = 4
//接受礼物
OPERATE_TYPE_RECEIVEGIFT = 5
//注册
OPERATE_TYPE_REGISTER = 6
//平台赠送
OPERATE_TYPE_MGRSEND = 8
MATCH_CONFIRM_SUCCESS = 1
MATCH_CONFIRM_FAIL = 2
MATCH_CONFIRM_TEMP = 3
ACCEPT_MATCH_CONFIRM = 1
REFUSE_MATCH_CONFIRM = 2
// 视频通话是否达标
VIDEO_EFFECTIVE_YES = 1
VIDEO_EFFECTIVE_NO = 2
// 最大用户相册数
USER_PHOTO_MAX = 9
// 上下架状态
SWITCH_ON = 1
SWITH_OFF = 0
// 群组角色
GROUP_VISITOR GroupRoleType = 0 // 游客
GROUP_MEMBER GroupRoleType = 1 // 成员
GROUP_ADMIN GroupRoleType = 10 // 管理员
GROUP_MANAGER GroupRoleType = 50 // 经理
GROUP_OWNER GroupRoleType = 100 // owner
ROOM_PASSWORD_LENGTH = 4
CREATE_GROUP_MAX_ATTEMPT = 10
// 在线状态
IM_STATUS_OFF_LINE OnlineStatusType = 0
IM_STATUS_PUSH_ON_LINE OnlineStatusType = 1
IM_STATUS_ON_LINE OnlineStatusType = 2
MSG_ID_GROUP_NAME MsgIdType = 101
MSG_ID_GROUP_INTRODUCTION MsgIdType = 102
MSG_ID_GROUP_NOTIFICATION MsgIdType = 103
MSG_ID_GROUP_WELCOME MsgIdType = 104
MSG_ID_GROUP_INVITE MsgIdType = 105
MSG_ID_GROUP_LEAVE_POWER MsgIdType = 106
MSG_ID_ALL_GROUP_ROCKET MsgIdType = 107
MSG_ID_ROOM_MEADAL MsgIdType = 108
MSG_ID_VIDEO_PUSH_TITITLE MsgIdType = 109
MSG_ID_VIDEO_PUSH_CONTENT MsgIdType = 110
MSG_ID_REPEAT_ACCOUNT MsgIdType = 111
MSG_ID_USER_TRANSFER MsgIdType = 114
MSG_ID_NO_POWER_TO_SVIP6 MsgIdType = 115 // 不能对svip6做某些动作
// ps:116-138 在hilo-finance定义了!
MSG_ID_NOT_FAMILY_MEMBER MsgIdType = 165 // 非家族成员
MSG_ID_DEALER_CAN_NOT_SOLE MsgIdType = 166 // 此用户已有家族代理,不能出售钻石
MSG_ID_BUY_FROM_FAMILY MsgIdType = 167 // 请向本家族代理购买钻石
MSG_ID_NEED_JOIN_FAMILY MsgIdType = 168 // 请加入代理的家族后进行购买
ADD_GROUP_FAILED AddGroupResultType = 0
ADD_GROUP_DONE AddGroupResultType = 1
ADD_GROUP_DUPLICATE AddGroupResultType = 2
ADD_GROUP_PENDING AddGroupResultType = 3
SETTING_OFFICIAL = 1
SETTING_CUSTOMIZED = 2
)
var USER_QPS_DEFAULT_MAX int64 = 15
var HEART_VALUE_MAX uint32 = 2000
var BUILDBOARD_SMALL_SIZE = 30
var BUILDBOARD_SIZE = 50
var GROUP_CREATE_LIMIT = 1
var GROUP_NAME_LENGTH_LIMIT = 30
var GROUP_INTRODUCTION_LENGTH_LIMIT = 500
var GROUP_NOTIFICATION_LENGTH_LIMIT = 150
var MAX_BEAUTIFUL_CODE_LENGTH = 8
var GROUP_DEFAULT_CODE_LENGTH uint16 = 8
var GROUP_DEFAULT_JOIN_LIMIT uint = 200
var GROUP_VIP_JOIN_LIMIT uint = 500
var GROUP_NOBLE4_JOIN_LIMIT uint = 1000
var GROUP_MANAGER_LIMIT uint = 30
var GROUP_ADMIN_LIMIT uint = 50
var GROUP_ROLE_VIEW_LIMIT = 10
var GROUP_ROLE_PERSONAL_VIEW_LIMIT = 5
var GROUP_RECOMMEND_SIZE = 5
var IM_INVALID_USER = "@TLS#NOT_FOUND"
// TIM相关常量
const (
SYNC_TO_SENDER = 1
NOSYNC_TO_SENDER = 2
TAG_PROFILE_IM_LEVEL = "Tag_Profile_IM_Level"
TAG_PROFILE_IM_NICK = "Tag_Profile_IM_Nick"
TAG_PROFILE_IM_IMAGE = "Tag_Profile_IM_Image"
TAG_PROFILE_IM_HILO = "Tag_Profile_Custom_Hilo"
)
// 群组内游戏相关
const (
GROUP_DICE_NUM_DEFAULT = 5
GROUP_DICE_NUM_MAX = 5
)
var PAY_TEST_USERS = []uint64{11, 21, 41, 71, 151, 251, 291, 881, 1041, 4411, 951, 24091}
var ROCKET_STAGE_NUM uint16 = 3
var ROCKET_STAGE_CHANGE_THRESHOLD = 10
var ROCKET_SHOW_DURATION = 10
// RocketAwardType
const (
ROCKET_AWARD_GUEST_DIAMOND = 0 // 观众分到小额钻石
ROCKET_AWARD_PROPERTY = 1 // TOP6抽到的座驾
ROCKET_AWARD_HEADDRESS = 2 // TOP6抽到的头饰
ROCKET_AWARD_DIAMOND = 3 // TOP6抽到的钻石
)
const DefaultMinimalVersionAndroid = 100
const DefaultMinimalVersionIOS = 100
const DefaultMsgParallelSize = 20
const OldGroupNamePrefix = "@TGS#"
const NewGroupNamePrefix = "HTGS#"
const OverseaGroupNamePrefix = NewGroupNamePrefix + "a"
const (
SendSmsCodeIpMaxHourTimes = 20
SendSmsCodeImeiMaxHourTimes = 10
SendSmsCodePhoneMaxHourTimes = 5
SendSmsCodeUserMaxHourTimes = 3
SendSmsCodeLen = 6 // 验证码长度
SendSmsCodeMaxCheckTimes = 3 // 验证码最大校验次数
SendSmsCodeNoUserIdMaxHourTimes = 1000 // 没有传userId调用发短信,5分钟最大次数
CallbackCheckoutPaySucceed = "payment_captured" // checkout回调支付成功
// ranking
RankingDay = "day"
RankingWeek = "week"
RankingMonth = "month"
RankingAll = "all"
// ranking module
RankingModulePinkDiamond = "pinkDiamond"
// giftwall 礼物墙
GiftWallInitNum = 15000 // 礼物墙初始化数量
GiftWallInitOnceSetNum = 500 // 礼物墙初始化,一次插入的数量
GiftWallStartReduceNum = 20000 // 礼物墙触发清理逻辑数量
GiftWallReduceNum = 3000 // 礼物墙触发清理逻辑,清理的数量
)
......@@ -334,6 +334,20 @@ func GetGroupPowerByGroupOrNil(model *domain.Model, groupUid string) (*GroupPowe
return &groupPower, nil
}
// 某个势力的势力主是否是代理
func IsGroupPowerHasMgrDealer(model *domain.Model, groupId mysql.ID) (bool, error) {
var num int64
if err := model.Db.Raw("select count(1) from (select * from diamond_dealer where user_id in "+
"(select user_id from group_power_user where group_power_id = ? and role = ?)) a", groupId, groupPower_e.GroupPowerUserRoleMgr).
Scan(&num).Error; err != nil {
return false, myerr.WrapErr(err)
}
if num > 0 {
return true, nil
}
return false, nil
}
func GetGroupPowerMap(db *gorm.DB, userIds []mysql.ID) (map[mysql.ID]uint64, error) {
rows := make([]GroupPowerUser, 0)
if len(userIds) > 0 {
......
package diamond_s
import (
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/mycontext"
"hilo-group/common"
"hilo-group/domain/model/groupPower_m"
"hilo-group/domain/model/res_m"
"hilo-group/myerr"
"hilo-group/myerr/bizerr"
)
type DiamondService struct {
svc *domain.Service
}
func NewDiamondService(myContext *mycontext.MyContext) *DiamondService {
svc := domain.CreateService(myContext)
return &DiamondService{svc}
}
// 币商转账钻石-家族限制检查
func (this *DiamondService) CheckDealerTransferFamilyLimit(dealerId, userId uint64, lang string) error {
model := domain.CreateModelContext(this.svc.MyContext)
// 代理、用户是否加入了家族
dealerFamily, err := groupPower_m.GetGroupPowerUserOrNil(model, dealerId)
if err != nil {
return err
}
userFamily, err := groupPower_m.GetGroupPowerUserOrNil(model, userId)
if err != nil {
return err
}
// 用户的家族是否有家族长,而且家族长是代理
var hasDealerMgr bool
if userFamily != nil {
hasDealerMgr, err = groupPower_m.IsGroupPowerHasMgrDealer(model, userFamily.GroupPowerId)
if err != nil {
return err
}
}
if dealerFamily != nil && dealerFamily.GroupPowerId > 0 { // 家族代理
// 家族代理:只能向本家族成员转移钻石,如果向非家族成员转移钻石,则提示“非家族成员”
if userFamily == nil || userFamily.GroupPowerId != dealerFamily.GroupPowerId {
return myerr.WrapErr(res_m.GetErrByLanguage(model.Db, common.MSG_ID_NOT_FAMILY_MEMBER, lang, bizerr.GroupPowerDealerNotMember))
}
} else { // 普通代理,没有加入家族的
// 普通代理:不能向已经加入家族的成员(并且家族长是代理)转移钻石,如果转移则提示“此用户已有家族代理,不能出售钻石”
if hasDealerMgr {
return myerr.WrapErr(res_m.GetErrByLanguage(model.Db, common.MSG_ID_DEALER_CAN_NOT_SOLE, lang, bizerr.GroupPowerDealerCanNotSole))
}
}
return nil
}
......@@ -71,12 +71,16 @@ var (
GroupNoPowerToSvip6 = myerr.NewBusinessCode(14026, "Cannot use this permission for SVIP6", myerr.BusinessData{}) // 踢出,无法对SVIP6使用此权限
// 家族
GroupPowerHasJoinOther = myerr.NewBusinessCode(15001, "You already have joined power, please exit first", myerr.BusinessData{}) // 已经加入了其它国家势力
GroupPowerHasJoinMy = myerr.NewBusinessCode(15002, "You already have joined power, please exit first", myerr.BusinessData{}) // 已经加入了该国家势力
GroupPowerOwnerLeave = myerr.NewBusinessCode(15003, "power owner cannot exit", myerr.BusinessData{}) // 势力主不能退出
GroupPowerNotExist = myerr.NewBusinessCode(15004, "国家势力不存在", myerr.BusinessData{}) // 国家势力不存在
GroupPowerNoOwner = myerr.NewBusinessCode(15005, "power owner not exits or unique", myerr.BusinessData{}) // 国家势力主不存在或不唯一
GroupPowerStayTooShort = myerr.NewBusinessCode(15006, "You joined this power not more than 10 days ago", myerr.BusinessData{}) // 加入国家势力不超过10天
GroupPowerHasJoinOther = myerr.NewBusinessCode(15001, "You already have joined power, please exit first", myerr.BusinessData{}) // 已经加入了其它国家势力
GroupPowerHasJoinMy = myerr.NewBusinessCode(15002, "You already have joined power, please exit first", myerr.BusinessData{}) // 已经加入了该国家势力
GroupPowerOwnerLeave = myerr.NewBusinessCode(15003, "power owner cannot exit", myerr.BusinessData{}) // 势力主不能退出
GroupPowerNotExist = myerr.NewBusinessCode(15004, "国家势力不存在", myerr.BusinessData{}) // 国家势力不存在
GroupPowerNoOwner = myerr.NewBusinessCode(15005, "power owner not exits or unique", myerr.BusinessData{}) // 国家势力主不存在或不唯一
GroupPowerStayTooShort = myerr.NewBusinessCode(15006, "You joined this power not more than 10 days ago", myerr.BusinessData{}) // 加入国家势力不超过10天
GroupPowerDealerNotMember = myerr.NewBusinessCode(15007, "Not family member", myerr.BusinessData{}) // 代理转账失败-非家族成员
GroupPowerDealerCanNotSole = myerr.NewBusinessCode(15008, "This user already has a family agent and cannot sell diamonds", myerr.BusinessData{}) // 代理转账失败-此用户已有家族代理,不能出售钻石
GroupPowerDealerCanNotBuy = myerr.NewBusinessCode(15009, "Buy diamonds from your family agent", myerr.BusinessData{}) // 请向本家族代理购买钻石
GroupPowerDealerNeedJoin = myerr.NewBusinessCode(15010, "Please join the agent's family to purchase", myerr.BusinessData{}) // 请加入代理的家族后进行购买
TaskHasAward = myerr.NewBusinessCode(19001, "task has award", myerr.BusinessData{})
......
ALTER TABLE hilo.group_power ADD `level` INT UNSIGNED DEFAULT 0 NOT NULL COMMENT '家族等级';
ALTER TABLE hilo.group_power ADD nameplate varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' NOT NULL COMMENT '家族铭牌';
ALTER TABLE hilo.group_power ADD declaration varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' NOT NULL COMMENT '家族宣言';
ALTER TABLE hilo.group_power ADD icon varchar(200) DEFAULT '' NOT NULL COMMENT '家族头像';
update hilo.group_power set nameplate = id;
CREATE UNIQUE INDEX nameplate_IDX USING BTREE ON hilo.group_power (nameplate);
package charge_r
import (
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/mycontext"
"github.com/gin-gonic/gin"
"hilo-group/domain/cache/user_c"
"hilo-group/domain/service/diamond_s"
"hilo-group/req"
"hilo-group/resp"
)
......@@ -13,92 +17,25 @@ import (
// @Router /v1/charge/share [get]
func CanShareChargeLink(c *gin.Context) (*mycontext.MyContext, error) {
myContext := mycontext.CreateMyContext(c.Keys)
//userId, err := req.GetUserId(c)
//if err != nil {
// return myContext, err
//}
//extId := c.Query("extId")
//model := domain.CreateModelContext(myContext)
//toUser, err := user_c.GetUserByExternalId(model, extId)
//if err != nil {
// return myContext, err
//}
//type res struct {
// CanShare bool `json:"canShare"`
//}
////var beginTime, endTime time.Time
//var beginTime time.Time
//if t == 1 {
// //endTime = now
// beginTime = midnight
//} else if t == 2 {
// //endTime = midnight
// beginTime = midnight.AddDate(0, 0, -7)
//} else {
// return myContext, myerr.NewSysError("type 参数错误")
//}
//
//type R struct {
// DiamondNum uint
// UserId uint64
//}
//rs := []R{}
////用缓存
//rows, err := redisCli.GetRedis().ZRevRangeWithScores(context.Background(), redis_key.GetGroupPowerDiamondLogWeek(beginTime.Format(utils.COMPACT_DATE_FORMAT)), 0, -1).Result()
//if err != nil {
// return nil, myerr.WrapErr(err)
//}
//groupPowerIds := make([]uint64, 0, len(rows))
//for i, _ := range rows {
// groupPowerId, err := strconv.ParseUint(rows[i].Member.(string), 10, 64)
// if err != nil {
// return nil, myerr.WrapErr(err)
// }
// groupPowerIds = append(groupPowerIds, groupPowerId)
//}
////搜集所有的群组(有效) + 群组管理人
//groupPowerUsers := []groupPower_m.GroupPowerUser{}
//if err := mysql.Db.Raw("SELECT u.user_id, u.group_power_id FROM group_power_user u, group_power p WHERE u.group_power_id = p.id AND u.role = ? and p.status = ? and p.id in (?)", groupPower_e.GroupPowerUserRoleMgr, groupPower_e.GroupPowerUserHas, groupPowerIds).Scan(&groupPowerUsers).Error; err != nil {
// return nil, myerr.WrapErr(err)
//}
////转换成map
//groupPowerIdUserIdMap := map[uint64]uint64{}
//for _, r := range groupPowerUsers {
// groupPowerIdUserIdMap[r.GroupPowerId] = r.UserId
//}
////只需找到前3个
//for i, _ := range rows {
// groupPowerId, err := strconv.ParseUint(rows[i].Member.(string), 10, 64)
// if err != nil {
// return nil, myerr.WrapErr(err)
// }
// if len(rs) >= 3 {
// break
// } else if userId, flag := groupPowerIdUserIdMap[groupPowerId]; flag {
// rs = append(rs, R{
// DiamondNum: uint(rows[i].Score),
// UserId: userId,
// })
// }
//}
//
//userIds := make([]uint64, 0, 64)
//for i, _ := range rs {
// userIds = append(userIds, rs[i].UserId)
//}
//
//userMap, err := user_cv.GetUserDetailMap(userIds, userId)
//if err != nil {
// return myContext, err
//}
//
//results := make([]ReturnGroupPowerBillboardOwnerWeek, 0, len(userIds))
//for i, _ := range rs {
// results = append(results, ReturnGroupPowerBillboardOwnerWeek{
// User: *userMap[rs[i].UserId],
// Diamond: rs[i].DiamondNum,
// })
//}
userId, lang, err := req.GetUserIdLang(c, myContext)
if err != nil {
return myContext, err
}
extId := c.Query("extId")
model := domain.CreateModelContext(myContext)
toUser, err := user_c.GetUserByExternalId(model, extId)
if err != nil {
return myContext, err
}
// 家族限制检查
if err = diamond_s.NewDiamondService(myContext).CheckDealerTransferFamilyLimit(userId, toUser.ID, lang); err != nil {
myContext.Log.Errorf("CanShareChargeLink err:%v", err)
return myContext, err
}
resp.ResponseOk(c, nil)
return myContext, nil
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment