generated from root/miduo_server
增加F5浮窗奖励逻辑
parent
ad261c8d6c
commit
a80b8c95be
|
@ -16,6 +16,7 @@ import com.ljsd.jieling.logic.dao.UserManager;
|
|||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.logic.mail.MailLogic;
|
||||
import com.ljsd.jieling.logic.mission.event.MissionEventDistributor;
|
||||
import com.ljsd.jieling.logic.player.PlayerLogic;
|
||||
import com.ljsd.jieling.logic.store.BuyGoodsLogic;
|
||||
import com.ljsd.jieling.logic.store.RechargeStatisticType;
|
||||
import com.ljsd.jieling.network.server.ProtocolsManager;
|
||||
|
@ -51,6 +52,10 @@ public class CoreService implements RPCRequestIFace.Iface {
|
|||
if(Objects.nonNull(devalueRet)) {
|
||||
devalueId = Integer.valueOf((String) devalueRet) ;
|
||||
}
|
||||
//浮窗礼包走单独逻辑,不走充值逻辑
|
||||
if(PlayerLogic.getInstance().isF5Gift(goodsId)){
|
||||
return PlayerLogic.getInstance().sendF5Gift(orderId,goodsId,uid);
|
||||
}
|
||||
Result result = BuyGoodsLogic.sendGoods(uid, goodsId, openId, orderId, orderTime, amount, false, null, RechargeStatisticType.REAL_RECHARGE, devalueId);
|
||||
MissionEventDistributor.requestEnd(OnlineUserManager.getSessionByUid(uid), true);
|
||||
User user = UserManager.getUser(uid);
|
||||
|
|
|
@ -1433,6 +1433,17 @@ public class RedisUtil {
|
|||
return result;
|
||||
}
|
||||
|
||||
public Map<String,String> getSimpleStringMapValues(String key){
|
||||
Map<String,String> result = new HashMap<String,String>();
|
||||
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(),String.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<>();
|
||||
|
|
|
@ -227,6 +227,8 @@ public class GetPlayerInfoHandler extends BaseHandler {
|
|||
RankRewardLogic.getInstance().dealRankReward(user);
|
||||
//处理google预注册奖励
|
||||
PlayerLogic.getInstance().dealGooglePreReward(user);
|
||||
//处理F5浮窗礼包奖励
|
||||
PlayerLogic.getInstance().dealF5Gift(user);
|
||||
int trainTaskCurLevel = MissionLoigc.getTrainTaskCurLevel(user.getUserMissionManager());
|
||||
PlayerInfoProto.GetPlayerInfoResponse getPlayerInfoResponse
|
||||
= PlayerInfoProto.GetPlayerInfoResponse.newBuilder()
|
||||
|
|
|
@ -51,6 +51,7 @@ import com.ljsd.jieling.protocols.CommonProto;
|
|||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import com.ljsd.jieling.protocols.PlayerInfoProto;
|
||||
import com.ljsd.jieling.reportBeans_37.ChatContentType;
|
||||
import com.ljsd.jieling.thrift.idl.Result;
|
||||
import com.ljsd.jieling.util.*;
|
||||
import config.*;
|
||||
import manager.STableManager;
|
||||
|
@ -1918,4 +1919,101 @@ public class PlayerLogic {
|
|||
SErrorCodeEerverConfig.getI18NMessage("Google_Comment_txt"),rewardStr,TimeUtils.nowInt(),Global.MAIL_EFFECTIVE_TIME);
|
||||
user.getPlayerInfoManager().setIsGoogleCommentReward(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否是F5浮窗礼包
|
||||
* @param goodsId
|
||||
* @return
|
||||
*/
|
||||
public boolean isF5Gift(String goodsId) {
|
||||
SRechargeCommodityConfig config = SRechargeCommodityConfig.getConfigBySdkRechargeId(goodsId);
|
||||
if(config == null){
|
||||
return false;
|
||||
}
|
||||
if(config.getType() == 26){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public Result sendF5Gift(String transactionId, String goodsId, int uid) throws Exception {
|
||||
String key = GameApplication.serverId + RedisKey.Delimiter_colon + uid;
|
||||
Map<String, String> map = RedisUtil.getInstence().getSimpleStringMapValues(key);
|
||||
Result resultRes = new Result();
|
||||
//商品不存在,直接返回失败
|
||||
SRechargeCommodityConfig config = SRechargeCommodityConfig.getConfigBySdkRechargeId(goodsId);
|
||||
if(config == null){
|
||||
resultRes.setResultCode(0);
|
||||
resultRes.setResultMsg("gift config is not exist");
|
||||
return resultRes;
|
||||
}
|
||||
if(map == null){
|
||||
map = new HashMap<String, String>();
|
||||
}
|
||||
//重复订单,直接返回成功
|
||||
if (map.containsKey(transactionId)) {
|
||||
resultRes.setResultCode(1);
|
||||
resultRes.setResultMsg("SUCCESS");
|
||||
return resultRes;
|
||||
}
|
||||
String giftInfo = "";
|
||||
User user = UserManager.getUserOnlyInMap(uid,true);
|
||||
//玩家不在线,保存礼包信息,登录时候处理
|
||||
if(user == null){
|
||||
giftInfo = goodsId + ",0";
|
||||
}else{
|
||||
//玩家在线,直接发奖
|
||||
String rewardStr = getRewardStr(false, config, 0);
|
||||
MailLogic.getInstance().sendMail(user.getId(),SErrorCodeEerverConfig.getI18NMessage("Google_Comment_title"),
|
||||
SErrorCodeEerverConfig.getI18NMessage("Google_Comment_txt"),rewardStr,TimeUtils.nowInt(),Global.MAIL_EFFECTIVE_TIME);
|
||||
giftInfo = goodsId + ",1";
|
||||
}
|
||||
map.put(transactionId,giftInfo);
|
||||
RedisUtil.getInstence().set(key,map);
|
||||
resultRes.setResultCode(1);
|
||||
resultRes.setResultMsg("SUCCESS");
|
||||
return resultRes;
|
||||
}
|
||||
|
||||
/**
|
||||
* 登录处理离线的F5gift奖励
|
||||
* @param user
|
||||
* @throws Exception
|
||||
*/
|
||||
public void dealF5Gift(User user) throws Exception {
|
||||
String key = GameApplication.serverId + RedisKey.Delimiter_colon + user.getId();
|
||||
Map<String, String> map = RedisUtil.getInstence().getSimpleStringMapValues(key);
|
||||
if(map == null||map.size() == 0){
|
||||
return;
|
||||
}
|
||||
boolean change = false;
|
||||
for(String transactionId : map.keySet()){
|
||||
String giftInfo = map.get(transactionId);
|
||||
if(giftInfo == null||giftInfo.length() < 2){
|
||||
continue;
|
||||
}
|
||||
String[] gift = giftInfo.split(",");
|
||||
String goodsId = gift[0];
|
||||
int status = Integer.parseInt(gift[1]);
|
||||
//已经发过了
|
||||
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("F5_Gift_title"),
|
||||
SErrorCodeEerverConfig.getI18NMessage("F5_Gift_txt"),rewardStr,TimeUtils.nowInt(),Global.MAIL_EFFECTIVE_TIME);
|
||||
giftInfo = goodsId + ",1";
|
||||
map.put(transactionId,giftInfo);
|
||||
change = true;
|
||||
}
|
||||
//有变化,更新redis
|
||||
if(change) {
|
||||
RedisUtil.getInstence().set(key, map);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue