小修改
parent
31a2d5b56a
commit
5bb9388894
|
@ -7,7 +7,6 @@ import com.ljsd.jieling.handler.BaseHandler;
|
|||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.logic.store.BuyGoodsNewLogic;
|
||||
import com.ljsd.jieling.logic.store.newRechargeInfo.bean.AbstractWelfareBag;
|
||||
import com.ljsd.jieling.logic.store.newRechargeInfo.rechargeHandler.RechargeHandler;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.util.ItemUtil;
|
||||
|
@ -46,7 +45,7 @@ public class GmBuyGoodHandler extends BaseHandler<PlayerInfoProto.GmBuyGoodReque
|
|||
throw new ErrorCodeException(ErrorCode.BLOOD_BUY_SCORE_YET);
|
||||
}
|
||||
// 礼包配置是否存在
|
||||
SGMMaster master = STableManager.getConfig(SGMMaster.class).get(goodsId);
|
||||
SGMMaster master = SGMMaster.getMap().get(goodsId);
|
||||
if (master == null){
|
||||
throw new ErrorCodeException(ErrorCode.CFG_NULL,"策划未未配置gm礼包id:"+goodsId);
|
||||
}
|
||||
|
@ -67,7 +66,7 @@ public class GmBuyGoodHandler extends BaseHandler<PlayerInfoProto.GmBuyGoodReque
|
|||
* @return
|
||||
*/
|
||||
public static boolean isCanBuy(User user, int id){
|
||||
Map<Integer, SGMMaster> config = STableManager.getConfig(SGMMaster.class);
|
||||
Map<Integer, SGMMaster> config = SGMMaster.getMap();
|
||||
SGMMaster master = config.get(id);
|
||||
if (master == null){
|
||||
return false;
|
||||
|
@ -96,11 +95,8 @@ public class GmBuyGoodHandler extends BaseHandler<PlayerInfoProto.GmBuyGoodReque
|
|||
break v;
|
||||
}
|
||||
for (SGMMaster sgmMaster : masters) {
|
||||
int packID = sgmMaster.getPackID();
|
||||
SRechargeCommodityNewConfig recharge = SRechargeCommodityNewConfig.getConfigById(packID);
|
||||
RechargeHandler rechargeHandler = BuyGoodsNewLogic.getRechargeHandler(recharge.getOtype());
|
||||
boolean status = rechargeHandler.refreshStatus(user, packID);
|
||||
if (!status){
|
||||
boolean status = checkGoodStatus(user, sgmMaster.getPackID());
|
||||
if (status){
|
||||
result = false;
|
||||
break v;
|
||||
}
|
||||
|
@ -114,10 +110,8 @@ public class GmBuyGoodHandler extends BaseHandler<PlayerInfoProto.GmBuyGoodReque
|
|||
}
|
||||
break;
|
||||
case 5:// 购买了其他礼包(rechargeID)开启
|
||||
SRechargeCommodityNewConfig recharge = SRechargeCommodityNewConfig.getConfigById(value[1]);
|
||||
RechargeHandler rechargeHandler = BuyGoodsNewLogic.getRechargeHandler(recharge.getOtype());
|
||||
boolean status = rechargeHandler.refreshStatus(user, value[1]);
|
||||
if (!status){
|
||||
boolean status = checkGoodStatus(user, value[1]);
|
||||
if (status){
|
||||
result = false;
|
||||
break v;
|
||||
}
|
||||
|
@ -128,4 +122,16 @@ public class GmBuyGoodHandler extends BaseHandler<PlayerInfoProto.GmBuyGoodReque
|
|||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证礼包是否购买
|
||||
* @param user
|
||||
* @param goodId
|
||||
* @return
|
||||
*/
|
||||
private static boolean checkGoodStatus(User user, int goodId){
|
||||
SRechargeCommodityNewConfig recharge = SRechargeCommodityNewConfig.getConfigById(goodId);
|
||||
RechargeHandler rechargeHandler = BuyGoodsNewLogic.getRechargeHandler(recharge.getOtype());
|
||||
return rechargeHandler.refreshStatus(user, goodId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,26 +23,37 @@ public class SGMMaster implements BaseConfig {
|
|||
private int packID;
|
||||
|
||||
private static Map<Integer, List<SGMMaster>> typeMap = new HashMap<>();
|
||||
|
||||
|
||||
private static Map<Integer, SGMMaster> map = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void init() throws Exception {
|
||||
Map<Integer, SGMMaster> config = STableManager.getConfig(SGMMaster.class);
|
||||
Map<Integer, List<SGMMaster>> map = new HashMap<>();
|
||||
Map<Integer, List<SGMMaster>> map1 = new HashMap<>();
|
||||
Map<Integer, SGMMaster> map2 = new HashMap<>();
|
||||
for (SGMMaster master : config.values()) {
|
||||
List<SGMMaster> list = map.get(master.getType());
|
||||
List<SGMMaster> list = map1.get(master.getType());
|
||||
if (list == null){
|
||||
List<SGMMaster> masters = config.values().stream().filter(v -> v.getType() == master.getType()).collect(Collectors.toList());
|
||||
map.put(master.getType(), masters);
|
||||
map1.put(master.getType(), masters);
|
||||
}
|
||||
|
||||
map2.put(master.getPackID(), master);
|
||||
}
|
||||
typeMap.clear();
|
||||
typeMap = map;
|
||||
typeMap = map1;
|
||||
map.clear();
|
||||
map = map2;
|
||||
}
|
||||
|
||||
public static Map<Integer, List<SGMMaster>> getTypeMap() {
|
||||
return typeMap;
|
||||
}
|
||||
|
||||
public static Map<Integer, SGMMaster> getMap() {
|
||||
return map;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue