Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: PHP
Posted by: user6d450
Added: May 17, 2019 7:12 AM
Views: 13
Tags: no tags
  1. <?php
  2.  
  3. /*
  4.  * To change this license header, choose License Headers in Project Properties.
  5.  * To change this template file, choose Tools | Templates
  6.  * and open the template in the editor.
  7.  */
  8.  
  9.  
  10.  
  11. include_once('../config.php');
  12.  
  13. include_once('function.php');
  14.  
  15.  
  16. //include_once GAMEBASEPATH.'agClass.php';
  17.  
  18.  
  19. //$newObj = new agClass(1);
  20.  
  21.  
  22. $timeFrom = time();
  23.  
  24. $timeTo  = time();
  25. function random_strings($length_of_string)
  26. {
  27.  
  28.     // String of all alphanumeric character
  29.     $str_result = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
  30.  
  31.     // Shufle the $str_result and returns substring
  32.     // of specified length
  33.     return substr(str_shuffle($str_result),  
  34.                        0, $length_of_string);
  35. }
  36.  
  37. function random19() {
  38.   $number = "";
  39.   for($i=0; $i<19; $i++) {
  40.     $min = ($i == 0) ? 1:0;
  41.     $number .= mt_rand($min,9);
  42.   }
  43.   return $number;
  44. }
  45. function callMeAlways($timeFrom,$nextId='')
  46. {
  47.    
  48.    
  49.     global $newObj;
  50.    
  51.     //$data = $newObj->getBetRecords($timeFrom,$nextId);
  52.    
  53.    
  54.     $data = json_decode($data,true);
  55.    
  56.     //print_r($data);
  57.       $playerIds = callsql("SELECT player_user_id FROM player_user order by player_user_id desc limit 50,200 ",'rows');
  58.      
  59.       //$wagerids=array("GC0081930108p");
  60.       $gamenames=array("ag_26","ag_12");
  61.       $channels=array("ag_26","ag_12");
  62.       $betamounts=array("600","800","700","2000");
  63.       $payoffs=array("1950","2000","700","3000");
  64.       $dates=array("2019-04-01 02:00:00","2019-04-02 02:00:00","2019-04-03 07:00:00","2019-04-04 06:00:00","2019-04-15 02:00:00","2019-04-16 02:00:00","2019-04-17 09:00:00","2019-04-21 11:00:00","2019-04-11 02:00:00","2019-04-16 02:00:00","2019-04-20 02:00:00","2019-04-21 02:00:00","2019-04-01 22:00:00","2019-04-23 02:00:00","2019-04-25 02:00:00","2019-04-24 02:00:00"
  65.           ,"2019-04-26 02:00:00","2019-04-27 02:00:00","2019-04-28 02:00:00","2019-04-29 02:00:00","2019-04-30 04:00:00");
  66.  
  67. $roundids=array("ivan001_RT","ivan002_RT");
  68. $sequences=array("ivan001_RT","ivan002_RT");
  69.  
  70.  
  71.    for($i=1;$i<1000;$i++)
  72.    {
  73.        $rand=random_strings(8);;
  74. $data['response']['data']['key'.$i]['UserName']=$playerIds[array_rand($playerIds)]['player_user_id'];
  75. $data['response']['data']['key'.$i]['WagersID']='GC00'.$rand;
  76. $data['response']['data']['key'.$i]['GAMENAME']=$gamenames[array_rand($gamenames)];
  77. $data['response']['data']['key'.$i]['betIp']='';
  78. $data['response']['data']['key'.$i]['WagersDate']=$dates[array_rand($dates)];
  79. $data['response']['data']['key'.$i]['BetAmount']=$betamounts[array_rand($betamounts)];
  80. $data['response']['data']['key'.$i]['Payoff']=$payoffs[array_rand($payoffs)];
  81. $data['response']['data']['key'.$i]['Currency']='CNY';
  82. $data['response']['data']['key'.$i]['jackpotAmount']='';
  83. $data['response']['data']['key'.$i]['luckyDrawId']='';
  84. $data['response']['data']['key'.$i]['roundId']=$roundids[array_rand($roundids)];
  85. $data['response']['data']['key'.$i]['SESSIONID']=$roundids[array_rand($roundids)];
  86. $data['response']['data']['key'.$i]['GAMETYPE']=$gamenames[array_rand($gamenames)];
  87. $data['response']['data']['key'.$i]['BALANCE']='';
  88. $data['response']['data']['key'.$i]['jpWin']='';
  89.    }
  90. $datas = $data['response']['data'];
  91.  
  92.     $serviceCode = 'AG';
  93.     $sg_turnover = $sg_unprocessed = $sg_winArray =array();
  94.  
  95.     $iaska =0;
  96.     foreach ($datas as $key=>$value)
  97.     {
  98.        // echo "SELECT username FROM player_user WHERE player_user_id='".$value['UserName']."'";
  99.         $playername = callsql("SELECT username FROM player_user WHERE player_user_id='".$value['UserName']."'",'value');
  100.           $upd = callsql("UPDATE player_game_details SET bbin_username='".$playername."',bbin_password='".$playername."' WHERE player_id='".$value['UserName']."'");
  101.        
  102.         $resultDetails = json_encode($value);
  103.      
  104.        
  105.         $iaska++;
  106.        
  107.         $sessionId = $value['SESSIONID'];
  108.         $timeTrans = strtotime($value['GAMEDATE']);
  109.        
  110.         //$md5 = md5($sessionId.$timeTrans);
  111.        
  112.         $acctId = $playername;
  113.         $ticketId = $value['WagersID']; //Tricky Way To Generate Ticket Id .. No Other Option to get Unique Transaction Id
  114.         $categoryId = $value['GAMENAME'];
  115.         $gameCode = $value['GameType'];
  116.         $betIp = $value['betIp'];
  117.         $ticketTime = $value['WagersDate'];
  118.         $betAmount = $value['BetAmount'];
  119.         $winLoss = $value['Payoff'];
  120.         $currency =$value['Currency'];
  121.         $result  = $resultDetails;
  122.         $jackpotAmount = $value['jackpotAmount'];
  123.         $luckyDrawId = $value['luckyDrawId'];
  124.         $result = $value['Result'];
  125.        
  126.  $r=random19();
  127.         $result = '{"BetAmount":'.$betAmount.',"Win":'.$winLoss.',"BetID":"'.$ticketId.'","BetTime":"'.$value['WagersDate'].'","BetTraceID":"'.$acctId.'_RT8::AG::STAKE::'.$r.'","GameCode":"'.$categoryId.'","UserName":"'.$acctId.'"}';
  128.        
  129.         $turnover = (isset($value['BetAmount']))?$value['BetAmount']:0;
  130.         $effective_turnover = $turnover;
  131.        
  132.         if($kind == 1 && $result == 'S') //Need to ask BBIN for more accurate
  133.             $completed = 0;
  134.         else
  135.             $completed = 1;
  136.            
  137.         $roundId = $value['roundId'];
  138.         $sequence = $value['SESSIONID'];
  139.         $channel = $value['GAMETYPE'];
  140.         $balance = $value['BALANCE'];
  141.         $jpWin = $value['jpWin'];
  142.  
  143.         $time = strtotime($ticketTime); //Convert to GMT + 8 - Now Result GMT -4
  144.        // echo "SELECT player_id FROM player_game_details WHERE bbin_username='$acctId'";
  145.         $playerId = callsql("SELECT player_id FROM player_game_details WHERE bbin_username='$acctId'",'value');
  146.       // exit();
  147.  
  148.         $checkExit = callsql("SELECT COUNT(*) FROM game_play_history WHERE  service_code='$serviceCode' AND ticketId='$ticketId'",'value');
  149.  
  150.  
  151.         if(!empty($playerId))
  152.         {
  153.             if(empty($checkExit) && $completed == 1)
  154.             {
  155.    
  156.                 $ins = mysql_query("INSERT INTO  game_play_history SET player_id='$playerId',service_code='$serviceCode',ticketId='$ticketId',categoryId='$categoryId',"
  157.                         . " gameCode='$gameCode',transTime='$time',betIp='$betIp',betAmount='$betAmount',winLoss='$winLoss',currency='$currency',result='$result',"
  158.                         . " jackpotAmount='$jackpotAmount',luckyDrawId='$luckyDrawId',status=1,roundId='$roundId',sequence='$sequence',channel='$channel',aftr_bal='$balance',jpWin='$jpWin',turnover='$turnover',effective_turnover='$effective_turnover'  ");
  159.    
  160.    
  161.    
  162.                 $sg_unprocessed[$playerId] = $sg_unprocessed[$playerId] + ($winLoss);
  163.    
  164.                 $sg_turnover[$playerId]= $sg_turnover[$playerId] + ($betAmount);
  165.    
  166.                 //echo "$iss <br>";
  167.                 if($winLoss > 0)
  168.                 {
  169.                     $sg_winArray[$playerId] = $sg_winArray[$playerId]+ $winLoss;
  170.                 }
  171.    
  172.                 $iss++;
  173.    
  174.             }
  175.         }
  176.          
  177.  
  178.     }
  179.    
  180.     foreach ($sg_turnover as $keyId=>$keyVal)
  181.     {
  182.         $upd = mysql_query("UPDATE player_game_details SET ag_turnover=ag_turnover+$keyVal,ag_unprocessed=ag_unprocessed+$sg_unprocessed[$keyId] WHERE player_id='$keyId'");
  183.    
  184.         $vendorId = 'AG';
  185.         $checkActivePromo = callsql("SELECT * FROM promo_activity_list WHERE player_id='$keyId' AND running_promo=1 AND used_games LIKE '%$vendorId%' ",'row');
  186.        
  187.         $addonPreWallet = $keyVal;
  188.        
  189.         if($sg_winArray[$keyId] > 0)
  190.         {
  191.             $addonPreWallet  =  $addonPreWallet + $sg_winArray[$keyId];
  192.         }
  193.        
  194.         if(!empty($checkActivePromo))
  195.         {
  196.             //$activeAddon = " , promo_turnover = promo_turnover + $keyVal ";  
  197.            
  198.             $myQry = mysql_query("SELECT * FROM promo_activity_list WHERE player_id='$keyId' AND running_promo=1 AND used_games LIKE '%$vendorId%' ORDER BY create_time ASC");
  199.            
  200.             $needToUse = $keyVal;
  201.            
  202.             while($myRes = mysql_fetch_assoc($myQry))
  203.             {
  204.                 if($needToUse > 0)
  205.                 {
  206.                     $currentMax = $myRes['turover_amount'];
  207.                     $currentReached = $myRes['turnover_reached'];
  208.                     $currentPromoBal = $myRes['bal_amount'];
  209.                     $promo_activity_list_id = $myRes['promo_activity_list_id'];
  210.                     $tempAfterAdd = $currentReached+$needToUse;
  211.                     $promoAmount = $myRes['amount'];
  212.  
  213.                    
  214.                     if($currentReached >= $currentMax && $currentPromoBal == 0)
  215.                     {
  216.                         $amountToUse =0;
  217.                         $status = 2;
  218.                         $running_promo = 0;
  219.                         $end_type = 1;
  220.                         $end_time = time();
  221.                     }
  222.                     if($tempAfterAdd >= $currentMax && $currentPromoBal ==0)
  223.                     {
  224.                         $amountToUse = $currentMax-$currentReached;
  225.                         $needToUse = $needToUse -$amountToUse;
  226.                         $status = 2;
  227.                         $running_promo = 0;
  228.                         $end_type = 1;
  229.                         $end_time = time();
  230.  
  231.  
  232.                         addPromoToMainWallet($keyId,$myRes['promo_activity_list_id']);
  233.  
  234.  
  235.                     }
  236.                     else
  237.                     {
  238.                         $amountToUse = $needToUse;
  239.                         $needToUse =0;
  240.                         if($currentPromoBal > 0)
  241.                             $status = 0;
  242.                         else
  243.                             $status =1;
  244.                        
  245.                         $running_promo = 1;
  246.                         $end_type = 0;
  247.                         $end_time = '';
  248.                     }
  249.                    
  250.                     mysql_query("UPDATE promo_activity_list SET promo_status='$status',running_promo='$running_promo',"
  251.                             . "end_type='$end_type',end_time='$end_time',turnover_reached=turnover_reached+$amountToUse WHERE promo_activity_list_id ='$promo_activity_list_id'");
  252.                    
  253.                     $transId = $myRes['transid'];
  254.                    
  255.                     if($status == 2)
  256.                     {
  257.                         if(!empty($transId))
  258.                         {
  259.                             $update = mysql_query("UPDATE player_turnover SET status=2,deposit_turnover=deposit_turnover+1 WHERE transaction_id='$transId' AND status != 2");
  260.                         }
  261.                     }
  262.                    
  263.                 }
  264.             }
  265.                
  266.         }
  267.         else
  268.         {
  269.             $activeAddon = " , pre_wallet_bal=pre_wallet_bal+$addonPreWallet ";
  270.             updateTurnover($keyId,$keyVal);
  271.         }
  272.        
  273.        
  274.         mysql_query(" UPDATE player_wallet SET deposit_turnover=deposit_turnover+$keyVal,vip_turnover=vip_turnover+$keyVal $activeAddon WHERE player_id ='$keyId'");
  275.        
  276.        
  277.        
  278.     }
  279.    
  280.     if(!empty($data['response']['pagination']))
  281.     {
  282.         $totalPages = $data['response']['pagination']['TotalPage'];
  283.         $currentPages = $data['response']['pagination']['Page'];
  284.        
  285.         if($totalPages > $currentPages )
  286.         {
  287.             $newPage = $currentPages+1;
  288.             callMeAlways($timeFrom,$newPage);
  289.         }
  290.     }
  291.    
  292.    
  293. }
  294.  
  295.  
  296. callMeAlways($timeFrom);
  297. ?>
  298.