金额校验

back_recharge
lvxinran 2020-09-27 11:58:44 +08:00
parent dc9665c93a
commit 7c88b404c9
2 changed files with 12 additions and 8 deletions

View File

@ -403,4 +403,9 @@ public class MathUtils {
return Double.parseDouble(Float.toString(f));
}
public static boolean doubleEquals(double d1 ,double d2){
BigDecimal data1 = new BigDecimal(d1);
BigDecimal data2 = new BigDecimal(d2);
return data1.compareTo(data2)==0;
}
}

View File

@ -141,23 +141,22 @@ public class BuyGoodsLogic {
//check money
// int realMoney =sRechargeCommodityConfig.getPrice();
// if(amount!=-999&&amount!=realMoney){
// LOGGER.error("the uid={},the goodId={}, amount={},real={}", uid, goodsId, amount,realMoney);
double priceTemp =sRechargeCommodityConfig.getPrice();
int cfgType = SSpecialConfig.getIntegerValue(SSpecialConfig.EXCHANGE_FORCE_TYPE);
double price = SExchangeRate.doubleIntegerHashMap.get(cfgType).get((int)priceTemp);
if(amount!=-999&&MathUtils.doubleEquals(amount,price)){
LOGGER.error("金额不对the uid={},the goodId={}, amount={},real={}", uid, goodsId, amount,price);
// 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);
if(buyCount ==null){
buyCount = 0;
}
double priceTemp =sRechargeCommodityConfig.getPrice();
int cfgType = SSpecialConfig.getIntegerValue(SSpecialConfig.EXCHANGE_FORCE_TYPE);
double price = SExchangeRate.doubleIntegerHashMap.get(cfgType).get((int)priceTemp);
buyCount=buyCount+1;
//time check