Merge branch 'master' of 60.1.1.230:backend/jieling_server
commit
f16f86c7ee
|
@ -159,6 +159,10 @@ public class RedisKey {
|
|||
public static final String FAMILY_FIGHT_TOTAL_EXP = "FAMILY_FIGHT_TOTAL_EXP";
|
||||
//公会战服务器准备就绪标识
|
||||
public static final String FAMILY_FIGHT_FINISH_MATCHING = "FAMILY_FIGHT_FINISH_MATCHING";
|
||||
//公会红包
|
||||
public static final String FAMILY_RED_PACKAGE = "FAMILY_RED_PACKAGE";
|
||||
//公会红包自增Id
|
||||
public static final String FAMILY_RED_PACKAGE_INCRE_ID = "FAMILY_RED_PACKAGE_INCRE_ID";
|
||||
//给用户发送邮件
|
||||
public static final String READY_TO_USER_MAIL = "READY_TO_USER_MAIL";
|
||||
//把用户踢下线
|
||||
|
|
|
@ -731,6 +731,21 @@ public class RedisUtil {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除集合中的左边第一个元素
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public Object lPop(String key){
|
||||
try {
|
||||
Object pop= redisTemplate.opsForList().leftPop(key);
|
||||
return pop;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//操作sortset
|
||||
public void zsetAddAall(String key, Set<ZSetOperations.TypedTuple<String>> items){
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
package com.ljsd.jieling.handler.family;
|
||||
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.logic.family.GuildLogic;
|
||||
import com.ljsd.jieling.netty.cocdex.PacketNetData;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author lvxinran
|
||||
* @date 2020/1/8
|
||||
* @discribe
|
||||
*/
|
||||
@Component
|
||||
public class GetAllRedPackageHandler extends BaseHandler {
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.J_GET_ALL_REDPACKAGE_INFO_REQUEST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(ISession iSession, PacketNetData netData) throws Exception {
|
||||
GuildLogic.getAllRedPackageInfo(iSession, MessageTypeProto.MessageType.J_GET_ALL_REDPACKAGE_INFO_RESPONSE);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package com.ljsd.jieling.handler.family;
|
||||
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.logic.family.GuildLogic;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.Family;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author lvxinran
|
||||
* @date 2020/1/8
|
||||
* @discribe
|
||||
*/
|
||||
@Component
|
||||
public class RedPackageDetailHandler extends BaseHandler<Family.RedPackageDetailRequest> {
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.J_GET_REDPACKAGE_DETAIL_REQUEST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processWithProto(ISession iSession, Family.RedPackageDetailRequest proto) throws Exception {
|
||||
GuildLogic.getRedPackageDetail(iSession,proto.getId(),MessageTypeProto.MessageType.J_GET_REDPACKAGE_DETAIL_RESPONSE);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package com.ljsd.jieling.handler.family;
|
||||
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.logic.family.GuildLogic;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.Family;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author lvxinran
|
||||
* @date 2020/1/7
|
||||
* @discribe
|
||||
*/
|
||||
@Component
|
||||
public class RobFamilyRedPackageHandler extends BaseHandler<Family.RobRedPackageRequest> {
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.J_ROB_REDPACKAGE_INFO_REQUEST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processWithProto(ISession iSession, Family.RobRedPackageRequest proto) throws Exception {
|
||||
GuildLogic.robRedPackage(iSession,proto.getId(),MessageTypeProto.MessageType.J_ROB_REDPACKAGE_INFO_RESPONSE);
|
||||
}
|
||||
}
|
|
@ -13,6 +13,10 @@ import com.ljsd.jieling.logic.activity.ActivityLogic;
|
|||
import com.ljsd.jieling.logic.activity.FightMainEventHandler;
|
||||
import com.ljsd.jieling.logic.activity.RemoveEventHeroHandler;
|
||||
import com.ljsd.jieling.logic.activity.UserLevelEventHandler;
|
||||
import com.ljsd.jieling.logic.activity.event.HeroFiveStarGetEvent;
|
||||
import com.ljsd.jieling.logic.activity.event.Poster;
|
||||
import com.ljsd.jieling.logic.activity.eventhandler.BuyGoodsDirectHandler;
|
||||
import com.ljsd.jieling.logic.activity.eventhandler.HeroFiveStarGetEventHandler;
|
||||
import com.ljsd.jieling.logic.arena.ArenaLogic;
|
||||
import com.ljsd.jieling.logic.championship.ChampionshipLogic;
|
||||
import com.ljsd.jieling.logic.dao.ServerConfig;
|
||||
|
@ -241,6 +245,7 @@ public class GlobalDataManaager implements IManager {
|
|||
new UserLevelEventHandler();
|
||||
new RemoveEventHeroHandler();
|
||||
new FightMainEventHandler();
|
||||
new BuyGoodsDirectHandler();
|
||||
ChampionshipLogic.minuteCheck(true);
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("e",e);
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
package com.ljsd.jieling.logic.activity.event;
|
||||
|
||||
/**
|
||||
* @author lvxinran
|
||||
* @date 2020/1/7
|
||||
* @discribe
|
||||
*/
|
||||
public class BuyGoodsDirectEvent implements IEvent{
|
||||
private int uid;
|
||||
private int goodsId;
|
||||
|
||||
|
||||
public int getUid() {
|
||||
return uid;
|
||||
}
|
||||
|
||||
public void setUid(int uid) {
|
||||
this.uid = uid;
|
||||
}
|
||||
|
||||
public int getGoodsId() {
|
||||
return goodsId;
|
||||
}
|
||||
|
||||
public void setGoodsId(int goodsId) {
|
||||
this.goodsId = goodsId;
|
||||
}
|
||||
|
||||
public BuyGoodsDirectEvent(int uid,int goodsId) {
|
||||
this.uid = uid;
|
||||
this.goodsId = goodsId;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package com.ljsd.jieling.logic.activity.eventhandler;
|
||||
|
||||
import com.ljsd.jieling.logic.activity.IEventHandler;
|
||||
import com.ljsd.jieling.logic.activity.event.BuyGoodsDirectEvent;
|
||||
import com.ljsd.jieling.logic.activity.event.IEvent;
|
||||
import com.ljsd.jieling.logic.activity.event.Poster;
|
||||
import com.ljsd.jieling.logic.family.GuildLogic;
|
||||
import config.SGuildRedPackConfig;
|
||||
|
||||
/**
|
||||
* @author lvxinran
|
||||
* @date 2020/1/7
|
||||
* @discribe
|
||||
*/
|
||||
public class BuyGoodsDirectHandler implements IEventHandler{
|
||||
public BuyGoodsDirectHandler() {
|
||||
Poster.getPoster().listenEvent(this,BuyGoodsDirectEvent.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEvent(IEvent event) throws Exception {
|
||||
if (!(event instanceof BuyGoodsDirectEvent))
|
||||
return;
|
||||
BuyGoodsDirectEvent directEvent = (BuyGoodsDirectEvent) event;
|
||||
if(!SGuildRedPackConfig.sGuildRedPackByGoodsId.containsKey(directEvent.getGoodsId())){
|
||||
return;
|
||||
}
|
||||
SGuildRedPackConfig sGuildRedPackConfig = SGuildRedPackConfig.sGuildRedPackByGoodsId.get(directEvent.getGoodsId());
|
||||
GuildLogic.sendRedPackage(directEvent.getUid(),sGuildRedPackConfig.getId());
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
package com.ljsd.jieling.logic.family;
|
||||
|
||||
/**
|
||||
* @author lvxinran
|
||||
* @date 2020/1/8
|
||||
* @discribe
|
||||
*/
|
||||
public class AcceptRedInfo {
|
||||
public int uid;
|
||||
public int count;
|
||||
public int itemId;
|
||||
public int time;
|
||||
|
||||
public int getUid() {
|
||||
return uid;
|
||||
}
|
||||
|
||||
public void setUid(int uid) {
|
||||
this.uid = uid;
|
||||
}
|
||||
|
||||
public int getCount() {
|
||||
return count;
|
||||
}
|
||||
|
||||
public void setCount(int count) {
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
public int getItemId() {
|
||||
return itemId;
|
||||
}
|
||||
|
||||
public void setItemId(int itemId) {
|
||||
this.itemId = itemId;
|
||||
}
|
||||
|
||||
public int getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public void setTime(int time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public AcceptRedInfo(int uid, int itemId,int count, int time) {
|
||||
this.uid = uid;
|
||||
this.itemId = itemId;
|
||||
this.count = count;
|
||||
this.time = time;
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package com.ljsd.jieling.logic.family;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.protobuf.GeneratedMessage;
|
||||
import com.ljsd.GameApplication;
|
||||
import com.ljsd.jieling.core.GlobalsDef;
|
||||
|
@ -26,6 +27,7 @@ import com.ljsd.jieling.protocols.MessageTypeProto;
|
|||
import com.ljsd.jieling.util.*;
|
||||
import config.SErrorCodeEerverConfig;
|
||||
import config.SGuildLevelConfig;
|
||||
import config.SGuildRedPackConfig;
|
||||
import config.SGuildSetting;
|
||||
import manager.STableManager;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -38,6 +40,7 @@ import java.util.*;
|
|||
|
||||
public class GuildLogic {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(GuildLogic.class);
|
||||
private static Gson gson = new Gson();
|
||||
|
||||
|
||||
public static int getMemberType(int targetUid, Map<Integer, Set<Integer>> members ){
|
||||
|
@ -978,4 +981,98 @@ public class GuildLogic {
|
|||
RedisUtil.getInstence().putMapEntry(RedisKey.FAMILY_INFO,"", String.valueOf(playerInfoManager.getGuildId()),new GuildCache(GameApplication.serverId,iconId,GuilidManager.guildInfoMap.get(playerInfoManager.getGuildId()).getLevel(),GuilidManager.guildInfoMap.get(playerInfoManager.getGuildId()).getName()));
|
||||
MessageUtil.sendMessage(session,1,messageType.getNumber(),null,true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发公会红包
|
||||
* @param redId
|
||||
* @throws Exception
|
||||
*/
|
||||
public static void sendRedPackage(int uid,int redId) throws Exception {
|
||||
User user = UserManager.getUser(uid);
|
||||
SGuildRedPackConfig config = SGuildRedPackConfig.sGuildRedPackConfigMap.get(redId);
|
||||
if(config==null){
|
||||
return;
|
||||
}
|
||||
long[] generate = HongBaoAlgorithm.generate(config.getTotalMoney()[1], config.getNum(), config.getMaxPercent(), config.getMinPercent());
|
||||
if(generate==null){
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||
}
|
||||
long increment = RedisUtil.getInstence().increment(RedisKey.getKey(RedisKey.FAMILY_RED_PACKAGE_INCRE_ID, "", false));
|
||||
RedisUtil.getInstence().putMapEntry(RedisKey.FAMILY_RED_PACKAGE,String.valueOf(user.getPlayerInfoManager().getGuildId()),String.valueOf(increment),new RedPackage(redId,uid));
|
||||
List<String> reward = new ArrayList<>();
|
||||
for(Long count:generate){
|
||||
reward.add(String.valueOf(count));
|
||||
}
|
||||
RedisUtil.getInstence().lSet(RedisKey.getKey("red_remain_list",String.valueOf(increment),false),reward,200000);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有红包信息
|
||||
* @param session
|
||||
* @param messageType
|
||||
*/
|
||||
public static void getAllRedPackageInfo(ISession session,MessageTypeProto.MessageType messageType) throws Exception {
|
||||
User user = UserManager.getUser(session.getUid());
|
||||
int guildId = user.getPlayerInfoManager().getGuildId();
|
||||
Map<String, RedPackage> redPackageMap = RedisUtil.getInstence().getMapValues(RedisKey.FAMILY_RED_PACKAGE, String.valueOf(guildId), String.class, RedPackage.class);
|
||||
Family.GetAllRedPackageResponse.Builder builder = Family.GetAllRedPackageResponse.newBuilder();
|
||||
for(Map.Entry<String, RedPackage> entry:redPackageMap.entrySet()){
|
||||
CommonProto.RedPackage.Builder redPackage = CommonProto.RedPackage.newBuilder();
|
||||
redPackage.setGetCount(RedisUtil.getInstence().getMapValues("red_already_list", entry.getKey(),int.class,AcceptRedInfo.class).size());
|
||||
AcceptRedInfo already = RedisUtil.getInstence().getMapEntry("red_already_list", entry.getKey(), String.valueOf(session.getUid()), AcceptRedInfo.class);
|
||||
redPackage.setIsGet(already==null?0:1);
|
||||
redPackage.setRedId(Integer.parseInt(entry.getKey()));
|
||||
redPackage.setUserName(UserManager.getUser(entry.getValue().getUid()).getPlayerInfoManager().getNickName());
|
||||
redPackage.setRedType(entry.getValue().getTypeId());
|
||||
builder.addInfo(redPackage);
|
||||
}
|
||||
MessageUtil.sendMessage(session,1,messageType.getNumber(),builder.build(),true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 抢红包
|
||||
*/
|
||||
public static void robRedPackage(ISession session, int redId, MessageTypeProto.MessageType messageType) throws Exception{
|
||||
int uid = session.getUid();
|
||||
Object redPackage = RedisUtil.getInstence().lPop(RedisKey.getKey("red_remain_list", String.valueOf(redId),false));
|
||||
Family.RobRedPackageResponse.Builder builder = Family.RobRedPackageResponse.newBuilder();
|
||||
if(redPackage!=null){
|
||||
builder.setIsSuccess(1);
|
||||
RedPackage packInfo = RedisUtil.getInstence().getMapValue(RedisKey.FAMILY_RED_PACKAGE, String.valueOf(UserManager.getUser(uid).getPlayerInfoManager().getGuildId()), String.valueOf(redId), RedPackage.class);
|
||||
SGuildRedPackConfig config = SGuildRedPackConfig.sGuildRedPackConfigMap.get(packInfo.getTypeId());
|
||||
RedisUtil.getInstence().putMapEntry("red_already_list", String.valueOf(redId),String.valueOf(uid),new AcceptRedInfo(uid,config.getTotalMoney()[0],Integer.parseInt(String.valueOf(redPackage)),(int)(TimeUtils.now()/1000)));
|
||||
}
|
||||
MessageUtil.sendMessage(session,1,messageType.getNumber(),builder.build(),true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看红包详情
|
||||
* @param session
|
||||
* @param redId
|
||||
* @param messageType
|
||||
*/
|
||||
public static void getRedPackageDetail(ISession session,int redId, MessageTypeProto.MessageType messageType) throws Exception {
|
||||
Map<Integer, AcceptRedInfo> alreadyList = RedisUtil.getInstence().getMapValues("red_already_list", String.valueOf(redId), Integer.class, AcceptRedInfo.class);
|
||||
Family.RedPackageDetailResponse.Builder builder = Family.RedPackageDetailResponse.newBuilder();
|
||||
if(!alreadyList.isEmpty()) {
|
||||
for(Map.Entry<Integer, AcceptRedInfo> already:alreadyList.entrySet()){
|
||||
PlayerManager playerInfoManager = UserManager.getUser(already.getValue().getUid()).getPlayerInfoManager();
|
||||
CommonProto.RedOneDetail.Builder detail= CommonProto.RedOneDetail.newBuilder()
|
||||
.setUid(already.getValue().getUid())
|
||||
.setHead(playerInfoManager.getHead())
|
||||
.setHeadFrame(playerInfoManager.getHeadFrame())
|
||||
.setName(playerInfoManager.getNickName())
|
||||
.setTime(already.getValue().getTime())
|
||||
.setItemId(already.getValue().getItemId())
|
||||
.setCount(already.getValue().getCount());
|
||||
builder.addInfo(detail.build());
|
||||
}
|
||||
}
|
||||
RedPackage packInfo = RedisUtil.getInstence().getMapValue(RedisKey.FAMILY_RED_PACKAGE, String.valueOf(UserManager.getUser(session.getUid()).getPlayerInfoManager().getGuildId()), String.valueOf(redId), RedPackage.class);
|
||||
PlayerManager playerInfoManager = UserManager.getUser(packInfo.getUid()).getPlayerInfoManager();
|
||||
builder.setSendName(playerInfoManager.getNickName())
|
||||
.setHead(playerInfoManager.getHead())
|
||||
.setHeadFrame(playerInfoManager.getHeadFrame());
|
||||
MessageUtil.sendMessage(session,1,messageType.getNumber(),builder.build(),true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,133 @@
|
|||
package com.ljsd.jieling.logic.family;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class HongBaoAlgorithm {
|
||||
static Random random = new Random();
|
||||
static {
|
||||
random.setSeed(System.currentTimeMillis());
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
long max = 3000;
|
||||
long min = 300;
|
||||
|
||||
long[] result = HongBaoAlgorithm.generate(6480, 20, max, min);
|
||||
long total = 0;
|
||||
for (int i = 0; i < result.length; i++) {
|
||||
System.out.println("result[" + i + "]:" + result[i]);
|
||||
System.out.println(result[i]);
|
||||
total += result[i];
|
||||
}
|
||||
//检查生成的红包的总额是否正确
|
||||
System.out.println("total:" + total);
|
||||
|
||||
//统计每个钱数的红包数量,检查是否接近正态分布
|
||||
int count[] = new int[(int) max + 1];
|
||||
for (int i = 0; i < result.length; i++) {
|
||||
count[(int) result[i]] += 1;
|
||||
}
|
||||
|
||||
for (int i = 0; i < count.length; i++) {
|
||||
System.out.println("" + i + " " + count[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 生产min和max之间的随机数,但是概率不是平均的,从min到max方向概率逐渐加大。
|
||||
* 先平方,然后产生一个平方值范围内的随机数,再开方,这样就产生了一种“膨胀”再“收缩”的效果。
|
||||
*
|
||||
* @param min
|
||||
* @param max
|
||||
* @return
|
||||
*/
|
||||
static long xRandom(long min, long max) {
|
||||
return sqrt(nextLong(sqr(max - min)));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param total
|
||||
* 红包总额
|
||||
* @param count
|
||||
* 红包个数
|
||||
* @param max
|
||||
* 每个小红包的最大额
|
||||
* @param min
|
||||
* 每个小红包的最小额
|
||||
* @return 存放生成的每个小红包的值的数组
|
||||
*/
|
||||
public static long[] generate(long total, int count, long max, long min) {
|
||||
if(total/count>max||total/count<min){
|
||||
return null;
|
||||
}
|
||||
long[] result = new long[count];
|
||||
|
||||
long average = total / count;
|
||||
|
||||
long a = average - min;
|
||||
long b = max - min;
|
||||
|
||||
//
|
||||
//这样的随机数的概率实际改变了,产生大数的可能性要比产生小数的概率要小。
|
||||
//这样就实现了大部分红包的值在平均数附近。大红包和小红包比较少。
|
||||
long range1 = sqr(average - min);
|
||||
long range2 = sqr(max - average);
|
||||
|
||||
for (int i = 0; i < result.length; i++) {
|
||||
//因为小红包的数量通常是要比大红包的数量要多的,因为这里的概率要调换过来。
|
||||
//当随机数>平均值,则产生小红包
|
||||
//当随机数<平均值,则产生大红包
|
||||
if (nextLong(min, max) > average) {
|
||||
// 在平均线上减钱
|
||||
// long temp = min + sqrt(nextLong(range1));
|
||||
long temp = min + xRandom(min, average);
|
||||
result[i] = temp;
|
||||
total -= temp;
|
||||
} else {
|
||||
// 在平均线上加钱
|
||||
// long temp = max - sqrt(nextLong(range2));
|
||||
long temp = max - xRandom(average, max);
|
||||
result[i] = temp;
|
||||
total -= temp;
|
||||
}
|
||||
}
|
||||
// 如果还有余钱,则尝试加到小红包里,如果加不进去,则尝试下一个。
|
||||
while (total > 0) {
|
||||
for (int i = 0; i < result.length; i++) {
|
||||
if (total > 0 && result[i] < max) {
|
||||
result[i]++;
|
||||
total--;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 如果钱是负数了,还得从已生成的小红包中抽取回来
|
||||
while (total < 0) {
|
||||
for (int i = 0; i < result.length; i++) {
|
||||
if (total < 0 && result[i] > min) {
|
||||
result[i]--;
|
||||
total++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static long sqrt(long n) {
|
||||
// 改进为查表?
|
||||
return (long) Math.sqrt(n);
|
||||
}
|
||||
|
||||
static long sqr(long n) {
|
||||
// 查表快,还是直接算快?
|
||||
return n * n;
|
||||
}
|
||||
|
||||
static long nextLong(long n) {
|
||||
return random.nextInt((int) n);
|
||||
}
|
||||
|
||||
static long nextLong(long min, long max) {
|
||||
return random.nextInt((int) (max - min + 1)) + min;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package com.ljsd.jieling.logic.family;
|
||||
|
||||
/**
|
||||
* @author lvxinran
|
||||
* @date 2020/1/7
|
||||
* @discribe
|
||||
*/
|
||||
public class RedPackage {
|
||||
|
||||
private int typeId;
|
||||
|
||||
private int uid;
|
||||
|
||||
|
||||
|
||||
public int getTypeId() {
|
||||
return typeId;
|
||||
}
|
||||
|
||||
public void setTypeId(int typeId) {
|
||||
this.typeId = typeId;
|
||||
}
|
||||
|
||||
public int getUid() {
|
||||
return uid;
|
||||
}
|
||||
|
||||
public void setUid(int uid) {
|
||||
this.uid = uid;
|
||||
}
|
||||
|
||||
public RedPackage(int typeId, int uid) {
|
||||
this.typeId = typeId;
|
||||
this.uid = uid;
|
||||
}
|
||||
|
||||
public RedPackage() {
|
||||
}
|
||||
}
|
|
@ -13,10 +13,7 @@ import com.ljsd.jieling.ktbeans.parmsBean.ParamEventBean;
|
|||
import com.ljsd.jieling.logic.OnlineUserManager;
|
||||
import com.ljsd.jieling.logic.activity.ActivityLogic;
|
||||
import com.ljsd.jieling.logic.activity.ActivityType;
|
||||
import com.ljsd.jieling.logic.activity.event.NewWelfareEvent;
|
||||
import com.ljsd.jieling.logic.activity.event.NewWelfareTypeEnum;
|
||||
import com.ljsd.jieling.logic.activity.event.Poster;
|
||||
import com.ljsd.jieling.logic.activity.event.SecretEvent;
|
||||
import com.ljsd.jieling.logic.activity.event.*;
|
||||
import com.ljsd.jieling.logic.dao.RechargeInfo;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.logic.dao.VipInfo;
|
||||
|
@ -213,7 +210,7 @@ public class BuyGoodsLogic {
|
|||
// user.getPlayerInfoManager().updateVipInfo(user,newLeve);
|
||||
user.getPlayerInfoManager().setVipLevel(newLeve);
|
||||
user.getPlayerInfoManager().updateVipInfo(GlobalsDef.VIP_UNLOCK_PRIVILEGE,newLeve);
|
||||
CombatLogic.getInstance().getNewAdventureReward(user, true);
|
||||
// CombatLogic.getInstance().getNewAdventureReward(user, true);
|
||||
}
|
||||
PlayerInfoProto.RefreshRechargeIndication.Builder builder = PlayerInfoProto.RefreshRechargeIndication.newBuilder();
|
||||
builder.setAmount(rechargeInfo.getSaveAmt());
|
||||
|
@ -230,7 +227,6 @@ public class BuyGoodsLogic {
|
|||
PlayerInfoProto.DirectBuyIndication build = PlayerInfoProto.DirectBuyIndication.newBuilder().setDrop(drop).build();
|
||||
MessageUtil.sendIndicationMessage(session,1, MessageTypeProto.MessageType.DIRECT_BUY_GOODS_INDICATION_VALUE,build,true);
|
||||
}
|
||||
|
||||
if(sRechargeCommodityConfig.getTime()==4&&sRechargeCommodityConfig.getDiscountType().length==3){
|
||||
int[] discountType = sRechargeCommodityConfig.getDiscountType();
|
||||
int temptype = discountType[0];
|
||||
|
@ -255,6 +251,8 @@ public class BuyGoodsLogic {
|
|||
MessageUtil.sendIndicationMessage(session,1, MessageTypeProto.MessageType.ALL_GIFTGOODS_INDICATION_VALUE,build,true);
|
||||
}
|
||||
}
|
||||
//发送直购事件
|
||||
Poster.getPoster().dispatchEvent(new BuyGoodsDirectEvent(uid,goodsId));
|
||||
|
||||
}else{
|
||||
String title = SErrorCodeEerverConfig.getI18NMessage("recharge_" + sRechargeCommodityConfig.getType() + "_title");
|
||||
|
@ -289,7 +287,7 @@ public class BuyGoodsLogic {
|
|||
|
||||
public static void addNewPrivilege(User user ,int privilege,PlayerInfoProto.PrivilegeIndication.Builder indication) throws Exception {
|
||||
int privilegeType = SPrivilegeTypeConfig.getsPrivilegeTypeConfigMap().get(privilege).getPrivilegeType();
|
||||
if(privilegeType== VipPrivilegeType.ADVENTURE_BASE_REWARD||privilegeType==VipPrivilegeType.FAST_MAP_LIMIT){
|
||||
if(privilegeType== VipPrivilegeType.ADVENTURE_BASE_REWARD){
|
||||
CombatLogic.getInstance().getNewAdventureReward(user,true);
|
||||
}
|
||||
user.getPlayerInfoManager().addVipInfo(privilege);
|
||||
|
|
|
@ -0,0 +1,85 @@
|
|||
package config;
|
||||
|
||||
|
||||
import manager.STableManager;
|
||||
import manager.Table;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Table(name ="GuildRedPackConfig")
|
||||
public class SGuildRedPackConfig implements BaseConfig {
|
||||
|
||||
private int id;
|
||||
|
||||
private int dailyNum;
|
||||
|
||||
private int[] totalMoney;
|
||||
|
||||
private int num;
|
||||
|
||||
private int reward;
|
||||
|
||||
private int lastTime;
|
||||
|
||||
private int minPercent;
|
||||
|
||||
private int maxPercent;
|
||||
|
||||
private int tradeId;
|
||||
|
||||
public static Map<Integer,SGuildRedPackConfig> sGuildRedPackConfigMap;
|
||||
|
||||
public static Map<Integer,SGuildRedPackConfig> sGuildRedPackByGoodsId;
|
||||
|
||||
@Override
|
||||
public void init() throws Exception {
|
||||
sGuildRedPackConfigMap = STableManager.getConfig(SGuildRedPackConfig.class);
|
||||
sGuildRedPackByGoodsId = new HashMap<>();
|
||||
for(Map.Entry<Integer,SGuildRedPackConfig> entry:sGuildRedPackConfigMap.entrySet()){
|
||||
int tradeId = entry.getValue().getTradeId();
|
||||
if(!sGuildRedPackConfigMap.containsKey(tradeId)){
|
||||
sGuildRedPackByGoodsId.put(tradeId,entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public int getDailyNum() {
|
||||
return dailyNum;
|
||||
}
|
||||
|
||||
public int[] getTotalMoney() {
|
||||
return totalMoney;
|
||||
}
|
||||
|
||||
public int getNum() {
|
||||
return num;
|
||||
}
|
||||
|
||||
public int getReward() {
|
||||
return reward;
|
||||
}
|
||||
|
||||
public int getLastTime() {
|
||||
return lastTime;
|
||||
}
|
||||
|
||||
public int getMinPercent() {
|
||||
return minPercent;
|
||||
}
|
||||
|
||||
public int getMaxPercent() {
|
||||
return maxPercent;
|
||||
}
|
||||
|
||||
public int getTradeId() {
|
||||
return tradeId;
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue