财富等级奖励配置
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.accompany.admin.controller.api;
|
||||
|
||||
import com.accompany.admin.service.api.MyApiService;
|
||||
import com.accompany.business.service.activity.h5.ActivityUserLevelExpService;
|
||||
import com.accompany.business.vo.RoomVo;
|
||||
import com.accompany.common.result.BusiResult;
|
||||
import com.accompany.common.status.BusiStatus;
|
||||
@@ -223,4 +224,15 @@ public class MyApiController {
|
||||
return BusiResult.success();
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private ActivityUserLevelExpService activityUserLevelExpService;
|
||||
|
||||
@GetMapping("/initLevelExpReward")
|
||||
public BusiResult<Void> initLevelExpReward(String pwd) {
|
||||
if (!"gasdgdgadsf234r3".equals(pwd)) {
|
||||
return BusiResult.fail("pwd");
|
||||
}
|
||||
activityUserLevelExpService.initOldData();
|
||||
return BusiResult.success();
|
||||
}
|
||||
}
|
||||
|
@@ -74,4 +74,6 @@ public interface UsersMapper {
|
||||
*/
|
||||
List<Long> getActiveAnchorUidList(@Param("gender") Byte gender, @Param("lastLoginTime") Date lastLoginTime);
|
||||
|
||||
|
||||
List<Users> listUid(@Param("start") Integer start, @Param("len") Integer len);
|
||||
}
|
@@ -1073,4 +1073,7 @@
|
||||
where alr.create_time > #{lastLoginTime}
|
||||
</select>
|
||||
|
||||
<select id="listUid" resultType="com.accompany.core.model.Users">
|
||||
select uid, partition_id partitionId from users order by uid asc limit #{start},#{len}
|
||||
</select>
|
||||
</mapper>
|
@@ -256,7 +256,8 @@ public enum I18nAlertEnum {
|
||||
INVITE_COINS_REWARD_MSG("你已经成功领取邀请活动的充值奖励了。"),
|
||||
ROOM_BOSS_MIC_UP_MSG_I18N("很遗憾,用户当前的房间贡献值未达到{0},无法上麦。"),
|
||||
|
||||
LUCKY_24_SEND_WEEK_RANK_REWARD_TIP("恭喜您获得上周超级幸运活动TOP{0},奖励已入账。")
|
||||
LUCKY_24_SEND_WEEK_RANK_REWARD_TIP("恭喜您获得上周超级幸运活动TOP{0},奖励已入账。"),
|
||||
USER_LEVEL_EXP_UP("恭喜您达到了财富Lv.{0},我们给您发送了财富等级奖励,快去你的背包查看吧!"),
|
||||
;
|
||||
|
||||
private final String defaultStr;
|
||||
|
@@ -20,6 +20,7 @@ public enum ActivityType {
|
||||
|
||||
GUILD_MONTH_TOP(12, "GUILD MONTH", ACTIVITY_FIRST_COMMON, true),
|
||||
GUILD_MONTH_ANCHOR_TOP(13, "GUILD_MONTH_ANCHOR_TOP", ACTIVITY_FIRST_COMMON, true),
|
||||
USER_LEVEL_EXP(14, "USER LEVEL EXP", ACTIVITY_FIRST_COMMON, true),
|
||||
;
|
||||
|
||||
private Integer type;
|
||||
|
@@ -403,6 +403,7 @@ public class ActivityOfChargeService {
|
||||
MarkdownMessage msg = new MarkdownMessage();
|
||||
msg.add(MarkdownMessage.getHeaderText(3, title));
|
||||
msg.add(MarkdownMessage.getReferenceText("用户ID: " + users.getErbanNo()));
|
||||
msg.add(MarkdownMessage.getReferenceText("用户UID: " + uid));
|
||||
msg.add(MarkdownMessage.getReferenceText("用户分区: " + partitionEnum.getDesc() + "区"));
|
||||
msg.add(MarkdownMessage.getReferenceText("用户充值金额: " + amount));
|
||||
msg.add(MarkdownMessage.getReferenceText("达标时间(GMT+8): " + DateUtil.formatDateTime(new Date())));
|
||||
|
@@ -462,6 +462,10 @@ public class ActivityRankRuleService {
|
||||
}
|
||||
|
||||
public void sendLevelRankAward(ActivityType activityType, Long uid, Integer level, String currentKeyDate, Integer partitionId, String message) {
|
||||
this.sendLevelRankAward_(activityType, uid, level, currentKeyDate, partitionId, message, expire);
|
||||
}
|
||||
|
||||
public void sendLevelRankAward_(ActivityType activityType, Long uid, Integer level, String currentKeyDate, Integer partitionId, String message, Long rewardSignExpireDay) {
|
||||
try {
|
||||
log.info("sendLevelRankAward, activityType:{},uid:{}, level:{}, currentKeyDate:{}, partitionId:{},begin", activityType.name(), uid, level, currentKeyDate, partitionId);
|
||||
RSet<Integer> set = this.activityRewardSign(activityType, uid, currentKeyDate, partitionId);
|
||||
@@ -477,7 +481,7 @@ public class ActivityRankRuleService {
|
||||
if (sysFlag && StringUtils.isNotEmpty(message)) {
|
||||
baseSendService.sendSystemMsg(uid.toString(), message);
|
||||
}
|
||||
set.expire(expire, TimeUnit.DAYS);
|
||||
set.expire(rewardSignExpireDay, TimeUnit.DAYS);
|
||||
log.info("sendLevelRankAward, activityType:{},uid:{}, level:{}, currentKeyDate:{}, partitionId:{},success", activityType.name(), uid, level, currentKeyDate, partitionId);
|
||||
} catch (Exception e) {
|
||||
log.info("sendLevelRankAward, activityType:{} uid:{}, level:{}, currentKeyDate:{}, partitionId:{},error :{}", activityType.name(), uid, level, currentKeyDate, partitionId, e.getMessage(), e);
|
||||
|
@@ -0,0 +1,157 @@
|
||||
package com.accompany.business.service.activity.h5;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.accompany.business.service.user.UsersService;
|
||||
import com.accompany.business.vo.activity.h5.ActivityDiffExpVo;
|
||||
import com.accompany.common.constant.Level;
|
||||
import com.accompany.common.push.MarkdownMessage;
|
||||
import com.accompany.common.redis.RedisKey;
|
||||
import com.accompany.common.utils.EnvComponent;
|
||||
import com.accompany.common.utils.StringUtils;
|
||||
import com.accompany.core.enumeration.PartitionEnum;
|
||||
import com.accompany.core.model.Users;
|
||||
import com.accompany.core.service.common.JedisService;
|
||||
import com.accompany.core.service.message.MessageRobotPushService;
|
||||
import com.accompany.core.util.I18NMessageSourceUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.redisson.api.RSet;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static com.accompany.business.constant.activity.ActivityType.USER_LEVEL_EXP;
|
||||
import static com.accompany.core.enumeration.I18nAlertEnum.USER_LEVEL_EXP_UP;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class ActivityUserLevelExpService {
|
||||
@Autowired
|
||||
private ActivityRankRuleService activityRankRuleService;
|
||||
@Autowired
|
||||
private UsersService usersService;
|
||||
@Autowired
|
||||
private EnvComponent envComponent;
|
||||
@Autowired
|
||||
private MessageRobotPushService messageRobotPushService;
|
||||
@Autowired
|
||||
protected JedisService jedisService;
|
||||
private final Integer ROBOT_PUSH_LEVEL = 60;
|
||||
|
||||
public void calUserLevelExpUp(Long uid, Integer partitionId, Long addVal, Long addTotalVal) {
|
||||
try {
|
||||
int lastLevel = this.calExperLevel(addTotalVal - addVal);
|
||||
int nowLevel = this.calExperLevel(addTotalVal);
|
||||
if (nowLevel - lastLevel <= 0) {
|
||||
return;
|
||||
}
|
||||
if (partitionId == null) {
|
||||
Users usersByUid = usersService.getUsersByUid(uid);
|
||||
partitionId = usersByUid.getPartitionId();
|
||||
}
|
||||
ActivityDiffExpVo diffExpVo = activityRankRuleService.getDiffExpVo(USER_LEVEL_EXP, partitionId, Double.valueOf(nowLevel));
|
||||
Integer level = diffExpVo.getLevel();
|
||||
if (level == 0) {
|
||||
return;
|
||||
}
|
||||
String message = I18NMessageSourceUtil.getMessage(USER_LEVEL_EXP_UP, new Object[]{nowLevel}, partitionId);
|
||||
activityRankRuleService.sendLevelRankAward_(USER_LEVEL_EXP, uid, level, "", partitionId, message, 365 * 3L);
|
||||
this.sendLevelUpQYWXKey(uid, diffExpVo.getExp().intValue(), nowLevel);
|
||||
} catch (Exception e) {
|
||||
log.error("calUserLevelExpUp-uid:{},addVal:{}, addTotalVal:{},e:{}", uid, addVal, addTotalVal, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
private int calExperLevel(Long experAmount) {
|
||||
if (experAmount == null) {
|
||||
return 0;
|
||||
}
|
||||
if (Level.exper == null || Level.exper.length == 0) {
|
||||
return 0;
|
||||
}
|
||||
int maxExperLevel = Level.exper.length;
|
||||
for (int i = 0; i < Level.exper.length; i++) {
|
||||
long curAmount = Level.exper[i];
|
||||
if (i >= Level.exper.length - 1) {
|
||||
// 如果已经是最后一个等级
|
||||
return maxExperLevel;
|
||||
} else {
|
||||
long nextAmount = Level.exper[i + 1];
|
||||
if (experAmount >= curAmount && experAmount < nextAmount) {
|
||||
return i + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void sendLevelUpQYWXKey(Long uid, Integer reachLevel, Integer expLevel) {
|
||||
if (reachLevel < ROBOT_PUSH_LEVEL) {
|
||||
return;
|
||||
}
|
||||
Users users = usersService.getUsersByUid(uid);
|
||||
Integer partitionId = users.getPartitionId();
|
||||
RSet<String> levelUpQYWXKey = activityRankRuleService.getLevelUpQYWXKey(USER_LEVEL_EXP, "", partitionId, uid);
|
||||
boolean added = levelUpQYWXKey.add(reachLevel.toString());
|
||||
if (!added) {
|
||||
return;
|
||||
}
|
||||
String key;
|
||||
if (envComponent.getDevOrNativeEnv()) {
|
||||
key = "ce275432-117d-4016-9f24-3410f1d54e4d";
|
||||
} else {
|
||||
key = "4bcec8b9-ab8e-4a6d-9e14-0cbde8c453f1";
|
||||
}
|
||||
PartitionEnum partitionEnum = PartitionEnum.getByPartitionId(partitionId);
|
||||
String title = "财富等级达到" + ROBOT_PUSH_LEVEL + "级以上(" + partitionEnum.getDesc() + "区)";
|
||||
MarkdownMessage msg = new MarkdownMessage();
|
||||
msg.add(MarkdownMessage.getHeaderText(3, title));
|
||||
msg.add(MarkdownMessage.getReferenceText("用户ID: " + users.getErbanNo()));
|
||||
msg.add(MarkdownMessage.getReferenceText("用户UID: " + uid));
|
||||
msg.add(MarkdownMessage.getReferenceText("用户财富等级: " + expLevel));
|
||||
msg.add(MarkdownMessage.getReferenceText("达标时间(GMT+8): " + DateUtil.formatDateTime(new Date())));
|
||||
messageRobotPushService.pushMessageByKey(key, msg, false);
|
||||
}
|
||||
|
||||
public void initOldData() {
|
||||
int pageSize = 1000;
|
||||
for (int pageNo = 1; pageNo < pageSize * 1000; pageNo++) {
|
||||
List<Users> listUid = usersService.listUid((pageNo - 1) * pageSize, pageSize);
|
||||
if (CollectionUtils.isEmpty(listUid)) {
|
||||
return;
|
||||
}
|
||||
for (Users u : listUid) {
|
||||
Long uid = u.getUid();
|
||||
String originLevelValue = jedisService.hget(RedisKey.user_level_exper.getKey(), uid.toString());
|
||||
if (StringUtils.isEmpty(originLevelValue)) {
|
||||
continue;
|
||||
}
|
||||
Long amountLevelExp = Long.valueOf(originLevelValue);
|
||||
Integer partitionId = u.getPartitionId();
|
||||
int lastLevel = this.calExperLevel(amountLevelExp - amountLevelExp);
|
||||
int nowLevel = this.calExperLevel(amountLevelExp);
|
||||
if (nowLevel - lastLevel <= 0) {
|
||||
return;
|
||||
}
|
||||
if (partitionId == null) {
|
||||
Users usersByUid = usersService.getUsersByUid(uid);
|
||||
partitionId = usersByUid.getPartitionId();
|
||||
}
|
||||
ActivityDiffExpVo diffExpVo = activityRankRuleService.getDiffExpVo(USER_LEVEL_EXP, partitionId, Double.valueOf(nowLevel));
|
||||
Integer level = diffExpVo.getLevel();
|
||||
if (level == 0) {
|
||||
return;
|
||||
}
|
||||
String message = I18NMessageSourceUtil.getMessage(USER_LEVEL_EXP_UP, new Object[]{nowLevel}, partitionId);
|
||||
activityRankRuleService.sendLevelRankAward_(USER_LEVEL_EXP, uid, level, "", partitionId, message, 365 * 3L);
|
||||
this.sendLevelUpQYWXKey(uid, diffExpVo.getExp().intValue(), nowLevel);
|
||||
}
|
||||
if (listUid.size() < pageSize) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -8,6 +8,7 @@ import com.accompany.business.message.ActivityOfDayConsumeMessage;
|
||||
import com.accompany.business.message.GiftMessage;
|
||||
import com.accompany.business.model.Gift;
|
||||
import com.accompany.business.model.vip.VipAuthItem;
|
||||
import com.accompany.business.service.activity.h5.ActivityUserLevelExpService;
|
||||
import com.accompany.business.service.record.BillRecordService;
|
||||
import com.accompany.business.service.vip.VipAuthItemService;
|
||||
import com.accompany.business.util.VipUtil;
|
||||
@@ -42,6 +43,8 @@ public class GiftMessageService extends BaseService {
|
||||
private GiftService giftService;
|
||||
@Autowired
|
||||
private GiftEarnAllotService giftEarnAllotService;
|
||||
@Autowired
|
||||
private ActivityUserLevelExpService activityUserLevelExpService;
|
||||
|
||||
public void handleGiftMessage(GiftMessage giftMessage) {
|
||||
// 防止消息被重复消费
|
||||
@@ -127,8 +130,9 @@ public class GiftMessageService extends BaseService {
|
||||
if (experAmount > 0L) {
|
||||
String originLevelValue = jedisService.hget(RedisKey.user_level_exper.getKey(), sendUid.toString());
|
||||
logger.info("user_level_exper sendUid : {}, originLevelValue : {}, experAmount : {}", sendUid, originLevelValue, experAmount);
|
||||
jedisService.hincrBy(RedisKey.user_level_exper.getKey(), sendUid.toString(), experAmount);
|
||||
Long hincrBy = jedisService.hincrBy(RedisKey.user_level_exper.getKey(), sendUid.toString(), experAmount);
|
||||
jedisService.hdel(RedisKey.user_summary.getKey(), sendUid.toString());
|
||||
activityUserLevelExpService.calUserLevelExpUp(sendUid, giftMessage.getPartitionId(), experAmount, hincrBy);
|
||||
}
|
||||
|
||||
Gift gift = giftService.getGiftByIdFromDb(giftId);
|
||||
|
@@ -1476,4 +1476,8 @@ public class UsersService extends BaseService {
|
||||
return JSONObject.parseArray(idStr, Long.class);
|
||||
}
|
||||
|
||||
public List<Users> listUid(Integer offect, Integer pageSize) {
|
||||
return usersMapper.listUid(offect, pageSize);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user