小修改

back_recharge
duhui 2022-09-14 16:37:19 +08:00
parent 31a2d5b56a
commit 5bb9388894
2 changed files with 34 additions and 17 deletions

View File

@ -7,7 +7,6 @@ import com.ljsd.jieling.handler.BaseHandler;
import com.ljsd.jieling.logic.dao.UserManager; import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.logic.dao.root.User; import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.store.BuyGoodsNewLogic; 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.logic.store.newRechargeInfo.rechargeHandler.RechargeHandler;
import com.ljsd.jieling.network.session.ISession; import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.util.ItemUtil; 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); 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){ if (master == null){
throw new ErrorCodeException(ErrorCode.CFG_NULL,"策划未未配置gm礼包id"+goodsId); throw new ErrorCodeException(ErrorCode.CFG_NULL,"策划未未配置gm礼包id"+goodsId);
} }
@ -67,7 +66,7 @@ public class GmBuyGoodHandler extends BaseHandler<PlayerInfoProto.GmBuyGoodReque
* @return * @return
*/ */
public static boolean isCanBuy(User user, int id){ 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); SGMMaster master = config.get(id);
if (master == null){ if (master == null){
return false; return false;
@ -96,11 +95,8 @@ public class GmBuyGoodHandler extends BaseHandler<PlayerInfoProto.GmBuyGoodReque
break v; break v;
} }
for (SGMMaster sgmMaster : masters) { for (SGMMaster sgmMaster : masters) {
int packID = sgmMaster.getPackID(); boolean status = checkGoodStatus(user, sgmMaster.getPackID());
SRechargeCommodityNewConfig recharge = SRechargeCommodityNewConfig.getConfigById(packID); if (status){
RechargeHandler rechargeHandler = BuyGoodsNewLogic.getRechargeHandler(recharge.getOtype());
boolean status = rechargeHandler.refreshStatus(user, packID);
if (!status){
result = false; result = false;
break v; break v;
} }
@ -114,10 +110,8 @@ public class GmBuyGoodHandler extends BaseHandler<PlayerInfoProto.GmBuyGoodReque
} }
break; break;
case 5:// 购买了其他礼包rechargeID开启 case 5:// 购买了其他礼包rechargeID开启
SRechargeCommodityNewConfig recharge = SRechargeCommodityNewConfig.getConfigById(value[1]); boolean status = checkGoodStatus(user, value[1]);
RechargeHandler rechargeHandler = BuyGoodsNewLogic.getRechargeHandler(recharge.getOtype()); if (status){
boolean status = rechargeHandler.refreshStatus(user, value[1]);
if (!status){
result = false; result = false;
break v; break v;
} }
@ -128,4 +122,16 @@ public class GmBuyGoodHandler extends BaseHandler<PlayerInfoProto.GmBuyGoodReque
} }
return result; 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);
}
} }

View File

@ -23,26 +23,37 @@ public class SGMMaster implements BaseConfig {
private int packID; private int packID;
private static Map<Integer, List<SGMMaster>> typeMap = new HashMap<>(); private static Map<Integer, List<SGMMaster>> typeMap = new HashMap<>();
private static Map<Integer, SGMMaster> map = new HashMap<>();
@Override @Override
public void init() throws Exception { public void init() throws Exception {
Map<Integer, SGMMaster> config = STableManager.getConfig(SGMMaster.class); 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()) { for (SGMMaster master : config.values()) {
List<SGMMaster> list = map.get(master.getType()); List<SGMMaster> list = map1.get(master.getType());
if (list == null){ if (list == null){
List<SGMMaster> masters = config.values().stream().filter(v -> v.getType() == master.getType()).collect(Collectors.toList()); 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.clear();
typeMap = map; typeMap = map1;
map.clear();
map = map2;
} }
public static Map<Integer, List<SGMMaster>> getTypeMap() { public static Map<Integer, List<SGMMaster>> getTypeMap() {
return typeMap; return typeMap;
} }
public static Map<Integer, SGMMaster> getMap() {
return map;
}
public int getId() { public int getId() {
return id; return id;
} }