一元购使用默认幸运号码中奖

本文揭示了一种一元购抽奖活动背后的中奖机制,通过调整系统内部数据实现特定用户的中奖。详细介绍了如何通过修改参与者的支付时间来确保其幸运号码与预设的中奖号码一致。

默认幸运号码其实无需中奖,一元购中奖的计算方式也没有漏洞,但是,中奖之后的基础数据会随之公布,只需更改用于计算的基础数据使之和默认幸运号码一致即可。因为用户支付成功的时间存在于系统的数据库中,是不透明的,是可更改的!!! 更改支付的时间,使计算出来的幸运号码和默认中奖的幸运号码一致!

/**
 * 默认中奖用户计算幸运号码
* */
public void defaultCountLuckyNumber(HappyUserRecord insUserRecord,String partakeRecord,HappyCommodityRecord commodityRecordInfo,String jackpotUser, int jackpotLuckyNumber){

    // 抓取最后6条幸运号码记录
    List<HappyUserRecord> LastSixLuckyNumber = 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);
		

}

转载于:https://my.oschina.net/hehongbo/blog/715607

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值