充值金额校验

zhangshanxue 2020-07-28 21:50:54 +08:00
parent 95e84791cd
commit 0c728fd2cb
2 changed files with 41 additions and 18 deletions

View File

@ -25,6 +25,7 @@ public class CoreService implements RPCRequestIFace.Iface {
@Override
public Result deliveryRecharge(int uid, int goodsId, String openId, String orderId, long orderTime, int amount) throws InvalidOperException, TException {
try {
LOGGER.info("deliveryRecharge start",uid );
return BuyGoodsLogic.sendGoods(uid, goodsId, openId, orderId, orderTime, amount);
} catch (Exception e) {
User user = UserManager.getUserInMem(uid);

View File

@ -89,6 +89,17 @@ public class BuyGoodsLogic {
LOGGER.info("send to uid={},the goods={},openID={},orderId={},orderTime={},amount={}",uid,goodsId,openId,orderId,orderTime,amount);
User user = UserManager.getUser(uid);
SRechargeCommodityConfig sRechargeCommodityConfig = SRechargeCommodityConfig.rechargeCommodityConfigMap.get(goodsId);
//check money
int realMoney =sRechargeCommodityConfig.getPrice();
if(amount!=realMoney){
LOGGER.error("the uid={},the goodId={}, amount={},real={}", uid, goodsId, amount,realMoney);
resultRes.setResultCode(0);
resultRes.setResultMsg("前后端金额不对"+amount+"realMoney = " + realMoney);
return resultRes;
}
RechargeInfo rechargeInfo = user.getPlayerInfoManager().getRechargeInfo();
Map<Integer, Integer> buyGoodsTimes = rechargeInfo.getBuyGoodsTimes();
Integer buyCount = buyGoodsTimes.get(goodsId);
@ -153,29 +164,40 @@ public class BuyGoodsLogic {
if(sRechargeCommodityConfig.getAccumulativeRecharge() == 1){
int monthline = STableManager.getConfig(SMonthcardConfig.class).get(Global.MONTHCARDID).getPrice();
int lmonthline = STableManager.getConfig(SMonthcardConfig.class).get(Global.LMONTHCARDID).getPrice();
boolean sendneed =false;
if(rechargeInfo.getMonthSaveAmt()<monthline&&(price+rechargeInfo.getMonthSaveAmt())>=monthline){
sendneed=true;
user.getPlayerInfoManager().getMonthCard().put(Global.MONTHCARDID, (int) (System.currentTimeMillis() / 1000));
}
if(rechargeInfo.getSmonthSaveAmt()<lmonthline&&(price+rechargeInfo.getSmonthSaveAmt())>=lmonthline){
sendneed=true;
user.getPlayerInfoManager().getMonthCard().put(Global.LMONTHCARDID, (int) (System.currentTimeMillis() / 1000));
Poster.getPoster().dispatchEvent(new NewWelfareEvent(user, NewWelfareTypeEnum.RECHARGE_BUY.getType(),Global.LMONTHCARDID));
}
if(sendneed){
ISession session = OnlineUserManager.sessionMap.get(uid);
if(session!=null){
PlayerInfoProto.MonthCardIndication monthCardIndication = PlayerInfoProto.MonthCardIndication.newBuilder().addAllMonthinfos(PlayerLogic.getInstance().getMonthCardInfo(user)).build();
MessageUtil.sendIndicationMessage(session, 1, MessageTypeProto.MessageType.MONTHCARD_INDICATION_VALUE, monthCardIndication, true);
try {
int monthline = STableManager.getConfig(SMonthcardConfig.class).get(Global.MONTHCARDID).getPrice();
int lmonthline = STableManager.getConfig(SMonthcardConfig.class).get(Global.LMONTHCARDID).getPrice();
boolean sendneed =false;
if(rechargeInfo.getMonthSaveAmt()<monthline&&(price+rechargeInfo.getMonthSaveAmt())>=monthline){
sendneed=true;
user.getPlayerInfoManager().getMonthCard().put(Global.MONTHCARDID, (int) (System.currentTimeMillis() / 1000));
}
if(rechargeInfo.getSmonthSaveAmt()<lmonthline&&(price+rechargeInfo.getSmonthSaveAmt())>=lmonthline){
sendneed=true;
user.getPlayerInfoManager().getMonthCard().put(Global.LMONTHCARDID, (int) (System.currentTimeMillis() / 1000));
Poster.getPoster().dispatchEvent(new NewWelfareEvent(user, NewWelfareTypeEnum.RECHARGE_BUY.getType(),Global.LMONTHCARDID));
}
if(sendneed){
ISession session = OnlineUserManager.sessionMap.get(uid);
if(session!=null){
PlayerInfoProto.MonthCardIndication monthCardIndication = PlayerInfoProto.MonthCardIndication.newBuilder().addAllMonthinfos(PlayerLogic.getInstance().getMonthCardInfo(user)).build();
MessageUtil.sendIndicationMessage(session, 1, MessageTypeProto.MessageType.MONTHCARD_INDICATION_VALUE, monthCardIndication, true);
}
}
}catch (Exception e){
LOGGER.error("充值异常跳过"+e.toString());
}
}
triggerEvent(user,sRechargeCommodityConfig,nowTime);
try {
triggerEvent(user,sRechargeCommodityConfig,nowTime);
}catch (Exception e){
LOGGER.error("充值异常跳过"+e.toString());
}
int[][] baseReward = sRechargeCommodityConfig.getBaseReward();
int length = baseReward.length;
String rewardStr="";