默认幸运号码其实无需中奖,一元购中奖的计算方式也没有漏洞,但是,中奖之后的基础数据会随之公布,只需更改用于计算的基础数据使之和默认幸运号码一致即可。因为用户支付成功的时间存在于系统的数据库中,是不透明的,是可更改的!!! 更改支付的时间,使计算出来的幸运号码和默认中奖的幸运号码一致!
/** * 默认中奖用户计算幸运号码* */public void defaultCountLuckyNumber(HappyUserRecord insUserRecord,String partakeRecord,HappyCommodityRecord commodityRecordInfo,String jackpotUser, int jackpotLuckyNumber){ // 抓取最后6条幸运号码记录 ListLastSixLuckyNumber = userLuckynumberService.getLastSix(Integer.parseInt(partakeRecord)); double lastSixSum = 0; String lastSixInfo = ""; for (int i = 0; i < LastSixLuckyNumber.size(); i++) { lastSixSum = lastSixSum+Float.parseFloat(Tools.getTime(LastSixLuckyNumber.get(i).getUpdatetime())); // 根据用户参与id查询用户电话号码 String phoneNumber = LastSixLuckyNumber.get(i).getPhoneNumber(); lastSixInfo += Tools.getCreatetime(LastSixLuckyNumber.get(i).getUpdatetime())+"+"+Tools.getTime(LastSixLuckyNumber.get(i).getUpdatetime())+"+"+phoneNumber+"="; } int winningnumber = Integer.parseInt(commodityRecordInfo.getWinningnumber()); int luckyNumber = ((int)lastSixSum%winningnumber)+10000001;// 计算幸运号码 //System.out.println("计算出来的幸运号码是:"+luckyNumber);// 计算出来的幸运号码 int number=luckyNumber-jackpotLuckyNumber; // 更改时间 String timeStr = Tools.getTime(LastSixLuckyNumber.get(LastSixLuckyNumber.size()-1).getUpdatetime()); int timeNumber = Integer.parseInt(timeStr); int countTime = timeNumber-number; String date=Tools.getDate(LastSixLuckyNumber.get(LastSixLuckyNumber.size()-1).getUpdatetime())+countTime; String createtime = Tools.getCreatetime(Tools.getDate(date)); String lastSixInfoArr[] = lastSixInfo.split("="); lastSixInfoArr[lastSixInfoArr.length-1] = createtime+"+"+Tools.getTime(Tools.getDate(date))+"+"+LastSixLuckyNumber.get(LastSixLuckyNumber.size()-1).getPhoneNumber(); commodityRecordInfo.setLuckynumber(jackpotLuckyNumber+"");// 给存入订单表使用 commodityRecordInfo.setJackpotuser(jackpotUser); // 更新中奖用户时间 HappyJackpotInfo jackpotInfo = new HappyJackpotInfo(); jackpotInfo.setPartakeRecord(partakeRecord); jackpotInfo.setJackpotUser(jackpotUser); jackpotInfo.setJackpotLuckyNumber(jackpotLuckyNumber+""); for (int i = 0; i < lastSixInfoArr.length; i++) { if(i==0) {jackpotInfo.setCountTime1(lastSixInfoArr[0]);} if(i==1) {jackpotInfo.setCountTime2(lastSixInfoArr[1]);} if(i==2) {jackpotInfo.setCountTime3(lastSixInfoArr[2]);} if(i==3) {jackpotInfo.setCountTime4(lastSixInfoArr[3]);} if(i==4) {jackpotInfo.setCountTime5(lastSixInfoArr[4]);} if(i==5) {jackpotInfo.setCountTime6(lastSixInfoArr[5]);} } jackpotInfoService.updateJackpotDate(jackpotInfo); }