更新google预注册奖励处理

grimm 2025-05-04 16:27:54 +08:00
parent 1393504763
commit 0e32f69d84
4 changed files with 98 additions and 1 deletions

View File

@ -474,7 +474,8 @@ public class RedisKey {
public static final String AREAN_SEASON_RANK_MARK = "AREAN_SEASON_RANK_MARK";//竞技场赛季奖励排行标记信息
public static final String USER_SIMPLE_INFO = "USER_SIMPLE_INFO";
public static final String DEFTRAINING_RANK_MARK = "DEFTRAINING_RANK_MARK";//深渊试炼每日排行标记信息
public static final String DEFTRAINING_RANK_MARK = "DEFTRAINING_RANK_MARK";
public static final String F5_PRE_REWARD = "F5_PRE_REWARD";//F5谷歌预注册奖励
//public static Set<String> worldDeathPathCacChe = new HashSet<>();

View File

@ -1400,6 +1400,17 @@ public class RedisUtil {
return result;
}
public Map<String,Integer> getSimpleMapValues(String key){
Map<String,Integer> result = new HashMap<String,Integer>();
Map<Object, Object> entries = redisTemplate.opsForHash().entries(key);
for(Map.Entry<Object,Object> item : entries.entrySet()){
Object key1 = item.getKey();
Object value = item.getValue();
result.put(gson.fromJson(gson.toJson(key1),String.class),gson.fromJson(value.toString(),Integer.class));
}
return result;
}
public <T> List<T> getMapEntrys(String type, String key, Collection<Object> mapKeys, Class<T> valueClazz) {
String rkey = getKey(type, key);
List<T> result = new ArrayList<>();

View File

@ -225,6 +225,8 @@ public class GetPlayerInfoHandler extends BaseHandler {
InvestigateLogic.getInstance().dealInvestigateReward(user);
//处理离线榜单结算
RankRewardLogic.getInstance().dealRankReward(user);
//处理google预注册奖励
PlayerLogic.getInstance().dealGooglePreReward(user);
int trainTaskCurLevel = MissionLoigc.getTrainTaskCurLevel(user.getUserMissionManager());
PlayerInfoProto.GetPlayerInfoResponse getPlayerInfoResponse
= PlayerInfoProto.GetPlayerInfoResponse.newBuilder()

View File

@ -1807,4 +1807,87 @@ public class PlayerLogic {
LOGGER.error("uid:"+user.getId()+",exception==>",e);
}
}
/**
* google
* @param user
*/
public void dealGooglePreReward(User user) throws Exception {
String key = RedisKey.F5_PRE_REWARD + RedisKey.Delimiter_colon + user.getPlayerInfoManager().getOpenId();
Map<String, Integer> map = RedisUtil.getInstence().getSimpleMapValues(key);
if(map == null || map.size() ==0){
return;
}
boolean update = false;
for(String goodsId : map.keySet()){
int status = map.get(goodsId);
//已领取
if(status == 1){
continue;
}
//发奖
SRechargeCommodityConfig config = SRechargeCommodityConfig.getConfigBySdkRechargeId(goodsId);
if(config == null){
continue;
}
//发奖
String rewardStr = getRewardStr(false, config, 0);
MailLogic.getInstance().sendMail(user.getId(),SErrorCodeEerverConfig.getI18NMessage("Google_Pre_title"),
SErrorCodeEerverConfig.getI18NMessage("Google_Pre_txt"),rewardStr,TimeUtils.nowInt(),Global.MAIL_EFFECTIVE_TIME);
map.put(goodsId, 1);
update = true;
}
if(update) {
RedisUtil.getInstence().putMap(key, "",map);
}
}
//邮件奖励
private static String getRewardStr(boolean first, SRechargeCommodityConfig sRechargeCommodityConfig, double price) throws Exception {
int[][] baseReward = sRechargeCommodityConfig.getBaseReward();
if (sRechargeCommodityConfig.getIsExtraItem() == 1){
int[][] newReward = new int[baseReward.length + 1][2];
int itemId = SSpecialConfig.getIntegerValue(SSpecialConfig.RECHARGE_EXTRA_ITEM_ID);
int itemNum = (int)(SSpecialConfig.getIntegerValue(SSpecialConfig.RECHARGE_EXTRA_ITEM_NUM_PARMA) * price);
for (int i = 0; i < newReward.length - 1; i++) {
newReward[i][0] = baseReward[i][0];
newReward[i][1] = baseReward[i][1];
}
newReward[newReward.length - 1][0] = itemId;
newReward[newReward.length - 1][1] = itemNum;
baseReward = newReward;
}
int length = baseReward.length;
String rewardStr = "";
if (first) {
int[][] firstMultiple = sRechargeCommodityConfig.getFirstMultiple();
if (firstMultiple != null) {
length += firstMultiple.length;
}
int[][] reward = null;
if (length > baseReward.length) {
int[][] result = new int[length][];
int i = 0;
for (; i < baseReward.length; i++) {
result[i] = baseReward[i];
}
for (int j = 0; j < firstMultiple.length; j++) {
result[i++] = firstMultiple[j];
}
if (reward != null) {
for (int j = 0; j < reward.length; j++) {
result[i++] = reward[j];
}
}
rewardStr = ItemUtil.getMailReward(result);
} else {
rewardStr = ItemUtil.getMailReward(baseReward);
}
} else {
rewardStr = ItemUtil.getMailReward(baseReward);
}
return rewardStr;
}
}