1.变身卡升星修改

2.bug处理
back_recharge
duhui 2022-11-01 17:06:06 +08:00
parent 8f602dfebe
commit 753e693fed
10 changed files with 117 additions and 154 deletions

View File

@ -42,7 +42,7 @@ public class GmBuyGoodHandler extends BaseHandler<PlayerInfoProto.GmBuyGoodReque
// 礼包是否到达购买条件
boolean canBuy = isCanBuy(user, goodsId);
if (!canBuy){
throw new ErrorCodeException(ErrorCode.BLOOD_BUY_SCORE_YET);
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE,"购买条件不足");
}
// 礼包配置是否存在
SGMMaster master = SGMMaster.getMap().get(goodsId);

View File

@ -12,7 +12,7 @@ import com.ljsd.jieling.util.ItemUtil;
import com.ljsd.jieling.util.MessageUtil;
import config.SChangingCard;
import config.SChangingCardLevel;
import config.SItem;
import config.SChangingCardStar;
import manager.STableManager;
import org.springframework.stereotype.Component;
import rpc.protocols.CommonProto;
@ -20,7 +20,6 @@ import rpc.protocols.HeroInfoProto;
import rpc.protocols.MessageTypeProto;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
@ -49,8 +48,8 @@ public class TransformationUpGradeHandler extends BaseHandler<HeroInfoProto.Tran
TransformationInfo info = infoMap.get(id);
HeroInfoProto.TransformationUpGradeResponse.Builder builder = HeroInfoProto.TransformationUpGradeResponse.newBuilder();
CommonProto.Drop.Builder drop = CommonProto.Drop.newBuilder();
if (type == 1) {
//升级
if (type == 1) {
int pool = changingCard.getLevelUpPool();
Map<Integer, SChangingCardLevel> poolConfig = SChangingCardLevel.getConfigByPoolId(pool);
if (poolConfig == null) {
@ -65,53 +64,50 @@ public class TransformationUpGradeHandler extends BaseHandler<HeroInfoProto.Tran
if (!ItemUtil.itemCost(user, costItem, BIReason.TRANSFORMATION_CARD_LEVEL_COST, 1)) {
throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH);
}
//更新数据库
info.setLevel(info.getLevel() + 1);
user.getHeroManager().putTransformationList(info);
// 获得道具
int[][] dropItem = {nextConfig.getChangingForceExp()};
ItemUtil.drop(user, dropItem, drop, BIReason.TRANSFORMATION_CARD_LEVEL_REWARD);
builder.setDrop(drop);
} else if (type == 2) {
}
//升星
List<CommonProto.KeyVal> itemIdList = proto.getItemListList();
Map<Integer, Integer> costMap = new HashMap<>();
for (CommonProto.KeyVal keyVal : itemIdList) {
if (costMap.containsKey(keyVal.getKey())) {
costMap.put(keyVal.getKey(), costMap.get(keyVal.getKey()) + keyVal.getVal());
if (type == 2) {
SChangingCard card = STableManager.getConfig(SChangingCard.class).get(proto.getId());
if (card == null){
throw new ErrorCodeException(ErrorCode.CFG_NULL, "变身卡不存在");
}
if (info.getStar() >= card.getStarMax()){
throw new ErrorCodeException(ErrorCode.LEVE_MAX, "变身卡最大星级");
}
Map<Integer, SChangingCardStar> starMap = SChangingCardStar.getPoolMap().get(card.getStar());
if (starMap == null){
throw new ErrorCodeException(ErrorCode.CFG_NULL, "变身卡升星库不存在");
}
SChangingCardStar cardStar = starMap.get(info.getStar());
// 转换消耗物品id
HashMap<Integer, Integer> costMap = new HashMap<>();
for (int[] item : cardStar.getPropList()) {
// 0表示消耗本体
if (item[0] == 0){
costMap.put(card.getCardId(),item[1]);
}else {
costMap.put(keyVal.getKey(), keyVal.getVal());
costMap.put(item[0],item[1]);
}
}
int num = 0;
int quantity = 0;
if(changingCard.getStarUpCost().length>= info.getStar() + 1){
num = changingCard.getStarUpCost()[info.getStar()][1];
quantity = changingCard.getStarUpCost()[info.getStar()][0];
boolean cost = ItemUtil.itemCost(user, costMap, BIReason.TRANSFORMATION_CARD_STAR_COST, 0);
if (!cost){
throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH, "变身卡升星库不存在");
}
for (Integer itemId : costMap.keySet()) {
SItem sItem = SItem.getsItemMap().get(itemId);
if(sItem == null || sItem.getQuantity() != quantity){
throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH);
}
}
int sum = costMap.values().stream().mapToInt(Integer::intValue).sum();
if(sum != num){
throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH);
}
if (!ItemUtil.itemCost(user, costMap, BIReason.TRANSFORMATION_CARD_STAR_COST, 1)) {
throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH);
}
if (info != null) {
// 更新变身卡对象
info.setStar(info.getStar() + 1);
user.getHeroManager().putTransformationList(info);
Map<Integer, Long> itemMap = new HashMap<>(1);
int[] item = changingCard.getStarUpExp()[info.getStar() - 1];
itemMap.put(item[0], Long.valueOf(item[1]));
ItemUtil.addItem(user, itemMap, drop, BIReason.TRANSFORMATION_CARD_STAR_REWARD);
// 获得道具
int[][] dropItem = {cardStar.getStarUpExp()};
ItemUtil.drop(user, dropItem, drop, BIReason.TRANSFORMATION_CARD_LEVEL_REWARD);
builder.setDrop(drop);
}
}
CommonProto.TransformationCardInfo cardInfo = CommonProto.TransformationCardInfo.newBuilder()
.setId(info.getCardId())
.setIndex(info.getIndex())

View File

@ -1,6 +1,7 @@
package com.ljsd.jieling.jbean.gm;
import com.ljsd.common.mogodb.MongoBase;
import com.ljsd.jieling.logic.dao.root.User;
import java.util.HashMap;
@ -10,7 +11,7 @@ import java.util.HashMap;
* @author ascend
* 2022/10/27 16:09:45
*/
public class GmActivity {
public class GmActivity extends MongoBase {
private HashMap<String, GmMission> missionMap = new HashMap<>();
private String id;
private int type;
@ -18,12 +19,18 @@ public class GmActivity {
private String startTime;
private String endTime;
public GmActivity() {
//绑定关系
this.setRootCollection(User._COLLECTION_NAME);
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
updateString("id",id);
}
public HashMap<String, GmMission> getMissionMap() {
@ -32,10 +39,12 @@ public class GmActivity {
public void setMissionMap(HashMap<String, GmMission> missionMap) {
this.missionMap = missionMap;
updateString("missionMap",missionMap);
}
public void putMissionMap(String id, GmMission mission) {
this.missionMap.put(id,mission);
updateString("missionMap",missionMap);
}
public int getType() {
@ -44,6 +53,7 @@ public class GmActivity {
public void setType(int type) {
this.type = type;
updateString("type",type);
}
public int getValue() {
@ -52,6 +62,7 @@ public class GmActivity {
public void setValue(int value) {
this.value = value;
updateString("value",value);
}
public String getStartTime() {
@ -60,6 +71,7 @@ public class GmActivity {
public void setStartTime(String startTime) {
this.startTime = startTime;
updateString("startTime",startTime);
}
public String getEndTime() {
@ -68,5 +80,6 @@ public class GmActivity {
public void setEndTime(String endTime) {
this.endTime = endTime;
updateString("endTime",endTime);
}
}

View File

@ -1,22 +1,31 @@
package com.ljsd.jieling.jbean.gm;
import com.ljsd.common.mogodb.MongoBase;
import com.ljsd.jieling.logic.dao.root.User;
/**
* gm
*
* @author ascend
* 2022/10/27 16:09:54
*/
public class GmMission {
public class GmMission extends MongoBase {
private String id;
private int value;
private int state;
public GmMission() {
//绑定关系
this.setRootCollection(User._COLLECTION_NAME);
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
updateString("id",id);
}
public int getValue() {
@ -25,6 +34,7 @@ public class GmMission {
public void setValue(int value) {
this.value = value;
updateString("value",value);
}
public int getState() {
@ -33,5 +43,6 @@ public class GmMission {
public void setState(int state) {
this.state = state;
updateString("state",state);
}
}

View File

@ -2,7 +2,6 @@ package com.ljsd.jieling.kefu;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.store.BuyGoodsNewLogic;
import util.TimeUtils;
/**
* @author hj
@ -13,22 +12,7 @@ public class Cmd_support extends GmRoleAbstract {
public boolean exec(String[] args) throws Exception {
// 获取用户
User user = getUser();
// 第一位是奖励信息
String arg = args[0];
// 价格
int price = 0;
// 订单id
String orderId = "support-order";
// 多个奖励组,需要用"|"分割
String[] rewards = arg.split("\\|");
for (String reward : rewards) {
// 奖励id#奖励数量
String[] item = reward.split("#");
for (int i = 0; i < Integer.parseInt(item[1]); i++) {
// 发送充值礼包
BuyGoodsNewLogic.sendGoods(user.getId(), item[0], user.getPlayerInfoManager().getOpenId(), orderId, TimeUtils.now(), price);
}
}
BuyGoodsNewLogic.supportBuyGoods(user,args[0]);
return true;
}
}

View File

@ -105,8 +105,6 @@ public class GmActivityLogic implements IEventHandler {
LOGGER.error("充值返利未找到得活动类型uid:{}, activityId{}", user.getId(), gmActivity.getId());
continue;
}
// 入库
manager.putActivityMap(gmActivity.getId(),gmActivity);
// 验证奖励非空
String mailReward = ItemUtil.getMailReward(rewards);
if (StringUtil.isEmpty(mailReward)){
@ -241,7 +239,6 @@ public class GmActivityLogic implements IEventHandler {
gmActivity.setType(arbActivity.getType());
gmActivity.setStartTime(arbActivity.getStartTime());
gmActivity.setEndTime(arbActivity.getEndTime());
gmActivityManager.putActivityMap(gmActivity.getId(),gmActivity);
}
gmActivityManager.setUpdateVersion(version);
}
@ -253,14 +250,11 @@ public class GmActivityLogic implements IEventHandler {
public void zeroUpdateGmActivity(User user){
updateGmActivity(user);
GmActivityManager manager = user.getGmActivityManager();
HashMap<String, GmActivity> activityMap = manager.getActivityMap();
for (GmActivity gmActivity : activityMap.values()) {
for (GmActivity gmActivity : manager.getActivityMap().values()) {
// 单笔累充和妖晶返利每日清零
if (gmActivity.getType() == 1 || gmActivity.getType() == 2){
gmActivity.setValue(0);
gmActivity.setMissionMap(new HashMap<>());
// 入库
manager.putActivityMap(gmActivity.getId(),gmActivity);
}
}
}

View File

@ -2942,30 +2942,15 @@ public class HeroLogic {
// 变身卡单独提供得属性
combinedAttribute(card.getPropList(), heroAllAttribute);
//变身卡升星属性
switch (info.getStar()){
case 1:
combinedAttribute(card.getStar1UpProps(), heroAllAttribute);
break;
case 2:
combinedAttribute(card.getStar2UpProps(), heroAllAttribute);
break;
case 3:
combinedAttribute(card.getStar3UpProps(), heroAllAttribute);
break;
case 4:
combinedAttribute(card.getStar4UpProps(), heroAllAttribute);
break;
case 5:
combinedAttribute(card.getStar5UpProps(), heroAllAttribute);
break;
default:break;
SChangingCardStar cardStar = SChangingCardStar.getPoolMap().get(card.getStar()).get(info.getStar());
if (cardStar != null){
combinedAttribute(cardStar.getExp(), heroAllAttribute);
}
//变身卡升级属性
int pool = card.getLevelUpPool();
Map<Integer, SChangingCardLevel> poolConfig = SChangingCardLevel.getConfigByPoolId(pool);
List<SChangingCardLevel> selectConfiglist = poolConfig.values().stream().filter(n->n.getLevel() == info.getLevel()).collect(Collectors.toList());
if(selectConfiglist != null &&selectConfiglist.size()>0 ){
combinedAttribute(selectConfiglist.get(0).getPropList(), heroAllAttribute);
Map<Integer, SChangingCardLevel> poolConfig = SChangingCardLevel.getConfigByPoolId(card.getLevelUpPool());
List<SChangingCardLevel> levelList = poolConfig.values().stream().filter(n->n.getLevel() == info.getLevel()).collect(Collectors.toList());
if(levelList.size()>0){
combinedAttribute(levelList.get(0).getPropList(), heroAllAttribute);
}
}
}

View File

@ -57,13 +57,15 @@ import java.util.*;
public class BuyGoodsNewLogic {
private static final Logger LOGGER = LoggerFactory.getLogger(BuyGoodsNewLogic.class);
public static RechargeHandler getRechargeHandler(int type){
return RechargeType.getHandler(type);
}
private static final String test_buy_order = "test_buy_order";
private static final String gm_modifier = "gm_modifier";
private static final String support_order = "support_order";
//获取充值总金额,结合前面的
public static double getAllAmount(User user){
PlayerManager playerInfoManager = user.getPlayerInfoManager();
@ -126,11 +128,9 @@ public class BuyGoodsNewLogic {
if (sRechargeCommodityConfig == null){
throw new ErrorCodeException(ErrorCode.CFG_NULL);
}
String openId = "test_buy_openId";
String orderId = "test_buy_order";
int price = (int)sRechargeCommodityConfig.getPrice() *100;
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.TEST_BUY_GIGT_GOODS_RESPONSE_VALUE,null,true);
sendGoods(uid, goodsId, openId, orderId, TimeUtils.now(), price);
sendGoods(uid, goodsId, "", test_buy_order, TimeUtils.now(), price);
}
/**
@ -144,10 +144,32 @@ public class BuyGoodsNewLogic {
if(sRechargeCommodityConfig == null){
throw new ErrorCodeException(ErrorCode.CFG_NULL);
}
String orderId = "gm_modifier";
int price = (int)sRechargeCommodityConfig.getPrice() * 100;
MessageUtil.sendMessage(iSession,1, MessageTypeProto.MessageType.TEST_BUY_GIGT_GOODS_RESPONSE_VALUE,null,true);
sendGoods(iSession.getUid(), String.valueOf(goodsId), "", orderId, TimeUtils.now(), price);
sendGoods(iSession.getUid(), String.valueOf(goodsId), "", gm_modifier, TimeUtils.now(), price);
}
/**
*
* @param user
* @param goods
* @throws Exception
*/
public static void supportBuyGoods(User user, String goods) throws Exception {
String[] good = goods.split("\\|");
for (String info : good) {
String[] gift = info.split("#");
int goodId = Integer.parseInt(gift[0]);
// 礼包内从校验
SRechargeCommodityNewConfig config = SRechargeCommodityNewConfig.getConfigById(goodId);
if(config == null){
LOGGER.error("sendGoods to 扶持发奖礼包id未找到uid{}good:{}",user.getId(),goodId);
continue;
}
int price = (int)config.getPrice() * 100;
// 发送多个礼包
sendGoods(user.getId(), String.valueOf(goodId), "", support_order, TimeUtils.now(), price);
}
}
/**
@ -156,7 +178,7 @@ public class BuyGoodsNewLogic {
* @return
*/
private static boolean isRmbBuy(String orderId){
return !"support-order".equals(orderId) && !"gm_modifier".equals(orderId) && !"test_buy_order".equals(orderId);
return !gm_modifier.equals(orderId);
}
/**
@ -193,7 +215,7 @@ public class BuyGoodsNewLogic {
double priceTemp =config.getPrice();
int cfgType = SSpecialConfig.getIntegerValue(SSpecialConfig.EXCHANGE_FORCE_TYPE);
double price = priceTemp==0?0: SExchangeRate.doubleIntegerHashMap.get(cfgType).get((int)priceTemp);
if(isRmbBuy(orderId) && !MathUtils.doubleEquals(amount,price * 100)){
if(!MathUtils.doubleEquals(amount,price * 100)){
resultRes.setResultCode(0);
resultRes.setResultMsg("charge price error");
LOGGER.error("sendGoods charge price error, uid={},the goodId={}, currentPrice={},realPrice={}",uid,goodsId, amount,price);
@ -220,13 +242,14 @@ public class BuyGoodsNewLogic {
}
}
List<int[][]> list = bag.getDropByBag();
if (isRmbBuy(orderId) && config.getGainFame() != null && config.getGainFame().length > 0){
list.add(config.getGainFame());
int[][] gainFame = config.getGainFame();
if (gainFame != null && gainFame.length > 0){
list.add(gainFame);
}
//发货
sendGoodsByType(user,config,list);
if(config.getAccumulativeRecharge() == 1 && !"gm_modifier".equals(orderId)){
if(config.getAccumulativeRecharge() == 1 && !gm_modifier.equals(orderId)){
if(info.getMaxSingleR() < price){
info.setMaxSingleR(price);
}
@ -262,7 +285,7 @@ public class BuyGoodsNewLogic {
// 更新入库
MongoUtil.getLjsdMongoTemplate().lastUpdate();
// 扶持订单不需要上报
if(price>0 && !orderId.equals("support-order")) {
if(price>0 && !orderId.equals(support_order)) {
MessageUtil.sendIndicationMessage(session, 1, MessageTypeProto.MessageType.RECHARGE_SUCCESS_INDICATION_VALUE,
PlayerInfoProto.RechargeSuccessIndication.newBuilder().setOrderId(orderId).build(), true);
// 开天上报

View File

@ -1,48 +1,29 @@
package config;
import manager.STableManager;
import manager.Table;
import java.util.HashMap;
import java.util.Map;
@Table(name ="ChangingCard")
public class SChangingCard implements BaseConfig {
private int id;
private int cardId;
private int[][] propList;
private int[][] starUpCost;
private int[][] star1UpProps;
private int[][] star2UpProps;
private int[][] star3UpProps;
private int[][] star4UpProps;
private int[][] star5UpProps;
private int star;
private int[] exp;
private int[][] starUpExp;
private int levelUpPool;
private int[] skill;
private int isOpen;
private int starMax;
private int levelMax;
@Override
public void init() throws Exception {
}
public int getId() {
return id;
}
@ -55,30 +36,14 @@ public class SChangingCard implements BaseConfig {
return propList;
}
public int[][] getStarUpCost() {
return starUpCost;
}
public int[][] getStar1UpProps() {
return star1UpProps;
}
public int[][] getStar2UpProps() {
return star2UpProps;
}
public int[][] getStar3UpProps() {
return star3UpProps;
public int getStar() {
return star;
}
public int[] getExp() {
return exp;
}
public int[][] getStarUpExp() {
return starUpExp;
}
public int getLevelUpPool() {
return levelUpPool;
}
@ -98,12 +63,4 @@ public class SChangingCard implements BaseConfig {
public int getLevelMax() {
return levelMax;
}
public int[][] getStar4UpProps() {
return star4UpProps;
}
public int[][] getStar5UpProps() {
return star5UpProps;
}
}