feat: 移除“租户管理员为用户充值 / 每租户一套余额”能力:余额统一为全局用户余额
This commit is contained in:
@@ -265,14 +265,12 @@ func (t *tenant) JoinByInvite(ctx context.Context, tenantID, userID int64, invit
|
||||
|
||||
// 加入租户:默认 member + verified;与 tenant.AddUser 保持一致。
|
||||
tu := &models.TenantUser{
|
||||
TenantID: tenantID,
|
||||
UserID: userID,
|
||||
Role: types.NewArray([]consts.TenantUserRole{consts.TenantUserRoleMember}),
|
||||
Status: consts.UserStatusVerified,
|
||||
Balance: 0,
|
||||
BalanceFrozen: 0,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
TenantID: tenantID,
|
||||
UserID: userID,
|
||||
Role: types.NewArray([]consts.TenantUserRole{consts.TenantUserRoleMember}),
|
||||
Status: consts.UserStatusVerified,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
}
|
||||
if err := tx.Create(tu).Error; err != nil {
|
||||
if isUniqueViolation(err) {
|
||||
@@ -430,14 +428,12 @@ func (t *tenant) AdminApproveJoinRequest(ctx context.Context, tenantID, operator
|
||||
|
||||
// 先落成员关系,再更新申请状态,保证“通过后一定能成为成员”(至少幂等)。
|
||||
tu := &models.TenantUser{
|
||||
TenantID: tenantID,
|
||||
UserID: req.UserID,
|
||||
Role: types.NewArray([]consts.TenantUserRole{consts.TenantUserRoleMember}),
|
||||
Status: consts.UserStatusVerified,
|
||||
Balance: 0,
|
||||
BalanceFrozen: 0,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
TenantID: tenantID,
|
||||
UserID: req.UserID,
|
||||
Role: types.NewArray([]consts.TenantUserRole{consts.TenantUserRoleMember}),
|
||||
Status: consts.UserStatusVerified,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
}
|
||||
if err := tx.Create(tu).Error; err != nil && !isUniqueViolation(err) {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user