房间老板位上麦限制
This commit is contained in:
@@ -914,6 +914,7 @@ public enum BusiStatus {
|
||||
|
||||
ROOM_LEVEL_NOT_ENOUGH(20504, "房间等级不够,不能使用该皮肤。"),
|
||||
ROOM_LEVEL_NOT_MANAGER(20504, "管理员数量已达上限"),
|
||||
ROOM_BOSS_MIC_UP_MSG(20505, "很遗憾,用户当前的房间贡献值未达到,无法上麦。"),
|
||||
;
|
||||
|
||||
|
||||
|
@@ -39,12 +39,21 @@ public class NumberUtils {
|
||||
if (number < 10000) {
|
||||
return df.format(number);
|
||||
} else if (number < 1000000) {
|
||||
return df.format((double) number / 1000) + "K";
|
||||
return df.format((double) number / 1000D) + "K";
|
||||
} else if (number < 1000000000) {
|
||||
return df.format((double) number / 1000000) + "M";
|
||||
return df.format((double) number / 1000000D) + "M";
|
||||
} else {
|
||||
return df.format((double) number / 1000000000) + "B";
|
||||
return df.format((double) number / 1000000000D) + "B";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(formatNumberSimple(5000L));
|
||||
System.out.println(formatNumberSimple(500000L));
|
||||
System.out.println(formatNumberSimple(500000000000L));
|
||||
;
|
||||
;
|
||||
;
|
||||
}
|
||||
}
|
||||
|
@@ -1379,6 +1379,8 @@ public class Constant {
|
||||
public static final String GUILD_DRESS_UP_CONFIG = "guild_dress_up_config";
|
||||
|
||||
public static final String ACTIVITY_TEMPLATE_CONFIG = "activity_template_config";//通用活动模板
|
||||
|
||||
public static final String ROOM_BOSS_MIC_UP_DAY_SEND_LIMIT = "room_bossMic_up_daySend_limit";//房间老板位上麦日贡献值最小限制
|
||||
}
|
||||
|
||||
public static class WithDrawStatus {
|
||||
|
@@ -254,6 +254,7 @@ public enum I18nAlertEnum {
|
||||
GUILD_APPLY_PASS("恭喜!您的公会申请已成功通过审核。页面变为我的公会页面"),
|
||||
BE_INVITE_REWARD_MSG("恭喜!您收到了一份奖励!"),
|
||||
INVITE_COINS_REWARD_MSG("你已经成功领取邀请活动的充值奖励了。"),
|
||||
ROOM_BOSS_MIC_UP_MSG_I18N("很遗憾,用户当前的房间贡献值未达到{0},无法上麦。"),
|
||||
;
|
||||
|
||||
private final String defaultStr;
|
||||
|
@@ -22,11 +22,10 @@ import org.springframework.context.i18n.LocaleContextHolder;
|
||||
import org.springframework.core.env.Environment;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
import static com.accompany.common.status.BusiStatus.ACCOUNT_BLOCK_ERROR;
|
||||
import static com.accompany.common.status.BusiStatus.ROOM_BOSS_MIC_UP_MSG;
|
||||
|
||||
@Slf4j
|
||||
@Data
|
||||
@@ -61,7 +60,7 @@ public class MessageSourceI18nSerialize extends JsonSerializer<String> implement
|
||||
}
|
||||
jsonGenerator.writeString(JSON.toJSONString(i18nMap));
|
||||
} else {
|
||||
if (ACCOUNT_BLOCK_ERROR.name().equals(fieldName)) {
|
||||
if (fieldNameNotI18n.contains(fieldName)) {
|
||||
jsonGenerator.writeString(str);
|
||||
return;
|
||||
}
|
||||
@@ -72,6 +71,13 @@ public class MessageSourceI18nSerialize extends JsonSerializer<String> implement
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 无需进行多语言的key
|
||||
*/
|
||||
private List<String> fieldNameNotI18n = Arrays.asList(
|
||||
ACCOUNT_BLOCK_ERROR.name(),
|
||||
ROOM_BOSS_MIC_UP_MSG.name());
|
||||
|
||||
private String getFieldNameValue(Object obj) {
|
||||
Object val = BeanUtil.getFieldValue(obj, fieldName);
|
||||
if (val != null) {
|
||||
|
@@ -409,6 +409,29 @@ public class RoomSendRankingService extends BaseService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取贡献值
|
||||
* @param roomUid
|
||||
* @param contributorUid
|
||||
* @param date
|
||||
* @param partitionId
|
||||
* @return
|
||||
*/
|
||||
public Double getContributorScore(Long roomUid, Long contributorUid, Date date, Integer partitionId, String rankingType) {
|
||||
Double zscore;
|
||||
if (Constant.RankingType.DAY.equalsIgnoreCase(rankingType)) {
|
||||
zscore = this.jedisService.zscore(this.getDayRankingsKey(roomUid, date, partitionId), contributorUid.toString());
|
||||
} else if (Constant.RankingType.WEEK.equalsIgnoreCase(rankingType)) {
|
||||
zscore = this.jedisService.zscore(this.getWeekRankingsKey(roomUid, date, partitionId), contributorUid.toString());
|
||||
} else if (Constant.RankingType.MONTH.equalsIgnoreCase(rankingType)) {
|
||||
zscore = this.jedisService.zscore(this.getMonthRankingsKey(roomUid, date, partitionId), contributorUid.toString());
|
||||
} else {
|
||||
zscore = this.jedisService.zscore(RedisKey.room_total_rankings.getKey(roomUid.toString()), contributorUid.toString());
|
||||
}
|
||||
zscore = zscore == null ? 0D : zscore;
|
||||
return zscore;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取个播房间贡献榜排名
|
||||
*
|
||||
|
@@ -26,10 +26,13 @@ import com.accompany.common.constant.Constant;
|
||||
import com.accompany.common.redis.RedisKey;
|
||||
import com.accompany.common.result.BusiResult;
|
||||
import com.accompany.common.status.BusiStatus;
|
||||
import com.accompany.common.utils.NumberUtils;
|
||||
import com.accompany.core.base.UidContextHolder;
|
||||
import com.accompany.core.exception.ServiceException;
|
||||
import com.accompany.core.model.Room;
|
||||
import com.accompany.core.model.Users;
|
||||
import com.accompany.core.service.SysConfService;
|
||||
import com.accompany.core.util.I18NMessageSourceUtil;
|
||||
import com.accompany.core.util.MD5;
|
||||
import com.accompany.core.util.StringUtils;
|
||||
import com.accompany.sharding.vo.RoomSerialVo;
|
||||
@@ -50,6 +53,9 @@ import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.accompany.common.constant.Constant.SysConfId.ROOM_BOSS_MIC_UP_DAY_SEND_LIMIT;
|
||||
import static com.accompany.core.enumeration.I18nAlertEnum.ROOM_BOSS_MIC_UP_MSG_I18N;
|
||||
|
||||
/**
|
||||
* Created by liuguofu on 2017/5/20.
|
||||
*/
|
||||
@@ -93,6 +99,10 @@ public class RoomController extends BaseController {
|
||||
private UsersService usersService;
|
||||
@Autowired
|
||||
private RoomMicDressService roomMicDressService;
|
||||
@Autowired
|
||||
private RoomSendRankingService roomSendRankingService;
|
||||
@Autowired
|
||||
private SysConfService sysConfService;
|
||||
|
||||
private RateLimiter roomGetLimiter = RateLimiter.create(1000);
|
||||
|
||||
@@ -560,4 +570,20 @@ public class RoomController extends BaseController {
|
||||
Long uid = getUid();
|
||||
return roomService.clearHistoryRecord(roomUid, uid);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "老板位上麦条件校验", httpMethod = "GET")
|
||||
@GetMapping(value = "/bossMic/up")
|
||||
@ResponseBody
|
||||
public BusiResult<Void> bossMicUp(@RequestParam Long roomUid, @RequestParam Long uid) {
|
||||
Users usersByUid = usersService.getUsersByUid(roomUid);
|
||||
Integer partitionId = usersByUid.getPartitionId();
|
||||
Double score = roomSendRankingService.getContributorScore(roomUid, uid, new Date(), partitionId, Constant.RankingType.DAY);
|
||||
Long configScore = Long.valueOf(sysConfService.getDefaultSysConfValueById(ROOM_BOSS_MIC_UP_DAY_SEND_LIMIT, "70000000"));
|
||||
if (score >= configScore ) {
|
||||
return BusiResult.success();
|
||||
}
|
||||
throw new ServiceException(BusiStatus.ROOM_BOSS_MIC_UP_MSG, I18NMessageSourceUtil.getMessage(ROOM_BOSS_MIC_UP_MSG_I18N, new Object[]{NumberUtils.formatNumberSimple(configScore)}, partitionId));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user