这个程序也是目前相对比较完整的一个项目,支持电脑版,和手机版,手机版是响应式的,网站采用了PHP+MYSQL开发实现的,也是目前比较主流的开发模式。
申明:这个项目代码,只是提供学习使用,不得用于其他用途,谢谢配合
前端时间帮朋友做了一个这样的程序,是湛江和海南那边的下单投注卖码的程序系统,经过差不多一个多月的时间,终于把这个项目完整的开发出来,接下来我给大家介绍一下,这些算法是怎么实现的和原理,希望可以帮到大家的学习,不要用来做其他事就可以。
手机版:
这个是快选
class FastChooseController extends HomebaseController {
protected $user_model;
public function __construct() {
parent::__construct();
$this->check_login();
$this->user_model = M("user");//打款凭证
}
public function index() {
$this->display();
}
public function SetFastBeatItem(){
header("Content-type: application/json");
if($this->user['lock']==1){
M("user")->where(array("id"=>$this->user["id"]))->save(array('lock'=>0));
$this->ejson("操作太快,稍等下再来下注吧");
}
if($this->user['user_status']==2){
$this->ejson('禁止下注');
}
M("user")->where(array("id"=>$this->user["id"]))->save(array('lock'=>1));
/* $_POST['Amount']=1;
$_POST['AmountCount']=4000;
$_POST['Bzxx']='三字定';
$_POST['data']='{"B2":[],"B3":[],"B4":[],"B5":[],"B6":[],"B7":[],"B9":["111X"],"B10":[],"B11":[],"B12":[],"B13":[],"B14":[],"B15":[],"B16":[],"B17":[],"B18":[]}';*/
$zmmtime=time();
ob_start();
@set_time_limit(0);
@ini_set("memory_limit", "512M");
$type=M('type')->where(array('id'=>'1'))->find();
$now=getnow('1',1);
$data['DrawDt']=$now['DrawDt'];
$data['OpenDt']=$now['OpenDt'];
if(time()<=strtotime($data['OpenDt'])){
$this->ejson("下注失败");
}
//获取上级帐户分批管理
for($i=$this->user["parent"];$i>0;$i){
$agent=M('agent')->find($i);
$agentlist[$i]=$agent;
$agentts[$i]=json_decode($agent["commission"],true);
$ff[]=$i;
$caopan[$i]=json_decode($agent["caopansetting"],true);
$i=$agent["parent"];
}
$commissionodds=json_decode($agent['commissionodds'],true);
$PeriodsNumber=$now["hm"];
$commission=json_decode($this->user["commission"],true);
$sjcommission=json_decode($this->user["sjcommission"],true);
$BetNumber=json_decode($_POST["Data"],true);
$ky_money=$this->user['money']-$this->user['yymoney'];
if($ky_money<$_POST["AmountCount"]){
$this->ejson("信用额度不足");
}
$money=0;
$data=array();
$bet=array();
$betxx=array();
$betList=array();
$bet2=array();
$bet2xx=array();
$bet2List=array();
$BetInfoID=time();
if($this->user["periodsnumber"]==$PeriodsNumber){
$xxx=file_get_contents("storexx/".md5($this->user["id"])."text");
$storexx=json_decode($xxx,true);
}
else{
$storexx=array();
}
$playlist=array();
$count=0;
$bet["BackComm"]=0;
$bet["count"]=0;
//查询数据库本期该类型已经下了多少钱的
$bet666['PeriodsNumber'] = $PeriodsNumber;
$bet666['BetNumber']=$value;
$bet666['sftm']=0;
$sum666=M('userbet'.$this->user['id'])->where($bet666)->sum('BetAmount');
if($maxcount<($typemoney[$value]+$sum666+0) || $maxbet<$_POST["Amount"]+$storexx[$result['number']]+0){
$typemoney[$played["id"]]=$typemoney[$played["id"]]-$_POST["Amount"];
$bet2["BetNumber"]=$value;
$bet2List[]=$bet2;
$isStopNum=55;
if(count($bet2List)==20){
M("bet2")->addAll($bet2List);
$bet2List=array();
}
}
else{
unset($xiatiao);
//start
$bet4['BetNumber']=$bet3['BetNumber']=$value;
$bet4['BetTypeID']=$bet3['BetTypeID']=$i;
if(empty($bet3s[$value])){
$bet3['BetAmount']=$_POST["Amount"];
$save1['BetAmount']='0';
$max_money=$_POST["Amount"];
}else{
$bet3['BetAmount']=$max_money=$save1['BetAmount']=$bet3s[$value]['betamount']+$_POST["Amount"];
}
//判断当前金额在哪个级别
foreach ($commissionodds[$bet3['BetTypeID']] as $kco => $vco) {
if(isset($vco)){
if($vco['is_use']==1&&$vco['Startamount']<=$max_money&&$max_money<$vco['Amountup']){
$Odds1=getodds2($vco['MaxLimitSigleBet'],$bet4['BetNumber']);
$xiatiao=getodds1($played,$bet4['BetNumber'])-$Odds1;
}
}
}
$xiatiao=isset($xiatiao)?$xiatiao:0;
$Odds=getodds($played,$this->user,$value);
$Odds=$Odds-$xiatiao;
if($bet3['BetTypeID']!=16&&$bet3['BetTypeID']!=15&&$bet3['BetTypeID']!=14){
if(isset($bet3s[$value])){
$Odds=$Odds-$bet3s[$value]['xiatiao'];
}
$bet3[Odds]=$xiatiao;
$bet3['id']=isset($bet3s[$value])?$bet3s[$value]['id']:0;
$bet5[]=$bet3;
}
//END
$bet["BackComm"]=$bet["BackComm"]+$BackComm;
$money=$money+$_POST["Amount"];
$storexx[$value]=$storexx[$value]+$_POST["Amount"]+0;
$add=array();
$add["Odds"]=$Odds;
$add["BetNumber"]=$value;
$add["playedId"]=$bet["playedId"];
$add["BetInfoID"]=$bet["BetInfoID"];
$add["BetAmount"]=$_POST["Amount"];
$add["BackComm"]=$BackComm;
$add["ProfitAndLoss"]=$bet["ProfitAndLoss"];
$add["PeriodsNumber"]=$PeriodsNumber;
$add["BetDt"]=$bet["BetDt"];
$tongji[$played["bettypeid"]]["BetAmount"]+=$_POST["Amount"];
$tongji[$played["bettypeid"]]["zjiang"]=0;
//$tongji[$played["bettypeid"]]["BackComm"]+=$add["BackComm"];
$tongji[$played["bettypeid"]]["ProfitAndLoss"]=0;
$tongji[$played["bettypeid"]]["count"]+=1;
//计算反水 占成
$pratio=$this->user['ratio'];;
$pratios=100;
$mfsxx=array();
$mlhxx=array();
$ymoney=0;
$is_fs=0;
$agent['parent']=$this->user['parent'];
$commission1=json_decode($this->user['commission'],true);
for($ii=$agent['parent'];$ii>0;$ii){
$agent=$agentlist[$ii];
$sjcommission1=$commission1;
$commission1=json_decode($agent["commission"],true);
$fszc=$sjcommission1[$i]['Commission']-$commission1[$i]['Commission'];
$fsmoney=$fszc*($add['BetAmount']-$ymoney);
if($commission1[$i]['MaxLimitStore']==0&&$agent['agentlevel']!==1){
$pratio=0;
}
$lhmoney=$pratio*$add['BetAmount']/100;
if($lhmoney<=0){
$lhmoney=0;
}
if($lhmoney+$ymoney>$add['BetAmount']){
$lhmoney=$add['BetAmount']-$ymoney;
}
//拦货 占成金额大于拦货金额的情况下拦货 $zlhmoney[$ii][$add['playedId']]
if(($add['BetAmount']*$pratio/100)>$commission1[$i]['MaxLimitStore']){
if($zlhmoney[$ii][$add['BetNumber']]+$lhmoney>$commission1[$i]['MaxLimitStore']){
$lhmoney=$commission1[$i]['MaxLimitStore']-$zlhmoney[$ii][$add['BetNumber']];
}
}
//判断是谁回收 1代表大股东 0代表公司
if($agent['agentlevel']==2&&$agent['is_fs']==1){
$is_fs=1;
}
if($is_fs==0){
if($agent['agentlevel']==1){
$lhmoney=$add["BetAmount"]-$ymoney;
}
}else{
//还要去掉公司占成
if($agent['agentlevel']==2){
$lhmoney=$add["BetAmount"]-$ymoney-($agent['pratio']*$add['BetAmount']/100);
}
}
$ymoney+=$lhmoney;
//$agentmoney[$i]+=$lhmoney;
$mlhxx[$ii]['money']=$lhmoney;
$mlhxx[$ii]['win']=0;
$lhxx[$ii]['money']+=$lhmoney;
$lhxx[$ii]['win']=0;
$tongji[$played["bettypeid"]]['lhxx'][$ii]['money']=0;
$tongji[$played["bettypeid"]]['lhxx'][$ii]['win']=0;
$zlhmoney[$ii][$add['BetNumber']]+=$lhmoney;
if($fsmoney>0){
$mfsxx[$ii]=$fsmoney;
$fsxx[$ii]+=$fsmoney;
$tongji[$played["bettypeid"]]['fsxx'][$ii]=0;
//$agentmoney[$ii]+=$fsmoney;
}
$bet4['agentid']=$ii;
if(empty($bet9s[$ii][$value])){
$bet4['lhmoney']=$lhmoney;
$bet4['BetAmount']=$add['BetAmount'];
}else{
$bet4['id']=$bet9s[$ii][$value]['id'];
$bet4['lhmoney']=$lhmoney+$bet9s[$ii][$value]['lhmoney'];
$bet4['BetAmount']=$add['BetAmount']+$bet9s[$ii][$value]['betamount'];
}
$bet6[]=$bet4;
if($bet4['lhmoney']>$caopan[$ii][$bet3['BetTypeID']]&&isset($caopan[$ii][$bet3['BetTypeID']])){
$bet991['money']=$bet4['lhmoney']-$caopan[$ii][$bet3['BetTypeID']];
$bet991['BetTypeID']=$bet4['BetTypeID'];
$bet991['BetNumber']=$bet4['BetNumber'];
$bet991['agentid']=$bet4['agentid'];
$bet991['PeriodsNumber']=$bet4['PeriodsNumber'];
if(!empty($bet99s[$ii][$value])){
$bet991['id']=$bet99s[$ii][$value]['id'];
}
$bet7[]=$bet991;
}
$ii=$agent["parent"];
$pratio=$agent['pratio'];
$pratios=$pratios-$pratio;
if($agent['agentlevel']==1){
$agent["parent"]=0;
}
if($ymoney==$add['BetAmount']){
$ii=0;
}
}
$add['lhxx']=json_encode($mlhxx);
$add['fsxx']=json_encode($mfsxx);
以上是这个快选这样的功能内容,下一章我这边讲都是,快驿功能,后面还有......
有什么不明白的,关于这个算法了解的,可以交流,我扣3053723033
来源:https://www.cnblogs.com/luenmicro/p/12449828.html