SpecialReportController.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <?php
  2. namespace App\Http\Controllers\Admin;
  3. use App\Http\Controllers\Controller;
  4. use Illuminate\Http\Request as Req;
  5. use Request;
  6. /**
  7. *
  8. */
  9. class SpecialReportController extends Controller {
  10. /**
  11. * @return 六合彩特码报表
  12. */
  13. function index(Req $req) {
  14. $request=array();
  15. $request['game']=isset($req->game)?trim($req->game):'sixlottery';
  16. $request['game_no']=isset($req->game_no)?trim($req->game_no):null;
  17. $gamelist = \App\Models\GameType::select('table_name','name')->whereIn('table_name',array('sixlottery','sfsixlottery'))->get();
  18. if($gamelist){
  19. $request['gameList'] = $gamelist->toArray();
  20. }else{
  21. $request['gameList'] = array('table_name'=>'sixlottery','name'=>'香港六合彩');
  22. }
  23. $dt = \App\Lib\DataTable\DataTable::init();
  24. $dt->setDataSource('/admin/SpecialReport/ReportList');
  25. $dt->setLang('sixlottery');
  26. $dt->setPriKey('identity');
  27. $dt->addColsFields('name', array('sort' => false));
  28. $dt->addColsFields('specialcode', array('sort' => false,'width'=>'80'));
  29. $dt->addColsFields('codea_summoney', array('sort' => false,'templet' => '#userrecharge','width'=>'150'));
  30. $dt->addColsFields('codeb_summoney', array('sort' => false,'templet' => '#orderid_time','width'=>'150'));
  31. $dt->addColsFields('code_summoney', array('sort' => false,'width'=>'150'));
  32. $dt->addColsFields('code1_summoney', array('sort' => false,'width'=>'150'));
  33. $dt->addColsFields('code2_summoney', array('sort' => false,'width'=>'150'));
  34. $dt->addColsFields('code3_summoney', array('sort' => false,'width'=>'150'));
  35. $dt->addColsFields('code4_summoney', array('sort' => false,'width'=>'150'));
  36. $dt->addColsFields('code5_summoney', array('sort' => false,'width'=>'150'));
  37. $dt->addColsFields('code6_summoney', array('sort' => false,'width'=>'150'));
  38. $dt->addColsFields('codee_summoney', array('sort' => false));
  39. $gameno = $this->getAllno($request['game']);
  40. $request['noinfo'] = $gameno;
  41. //print_r($gameno);exit;
  42. return view('admin.SpecialReport/index', $dt->render($request));
  43. }
  44. //获取特码报表
  45. function ReportList() {
  46. $where = array();
  47. $info_no = Request::has('game_no') ? Request::get('game_no') : '';
  48. $game = Request::has('game') ? Request::get('game') : 'sixlottery';
  49. $where[] = array('delstatus','=',1);
  50. $cls = '\App\Models\Game' . ucfirst($game);
  51. $clsbuy = '\\App\\Model\\' . ucfirst($game) . 'Buy';
  52. if(empty($info_no)){
  53. $gameno =new $cls;
  54. $gamenofirst = $gameno->getGameno();
  55. if($gamenofirst<0){
  56. return responseToJson($gamenofirst);
  57. }
  58. $info_no = $gamenofirst['info_no'];
  59. }
  60. $where[] = array('no','=',$info_no);
  61. $moneybuy =new $clsbuy;
  62. $data = $moneybuy->getBetInfo($where);
  63. //$data[0]['codes'] = '{"special_code_a":{"1":{"0":"1","settings":{"multiple":"42.5","back":"0"}},"2":{"0":"1","settings":{"multiple":"42.5","back":"0"}}}}';
  64. if($data<0){
  65. return responseToJson($data);
  66. }
  67. $newdata = array();
  68. for($i=1;$i<50;$i++){
  69. $newdata[] = array(
  70. 'name' => trans($game . '.' . $game),
  71. 'specialcode' => $i,
  72. 'codea_summoney' => 0,
  73. 'codeb_summoney' => 0,
  74. 'code_summoney' => 0,
  75. 'code1_summoney' => 0,
  76. 'code2_summoney' => 0,
  77. 'code3_summoney' => 0,
  78. 'code4_summoney' => 0,
  79. 'code5_summoney' => 0,
  80. 'code6_summoney' => 0,
  81. 'codee_summoney' => 0,
  82. );
  83. }
  84. foreach($data as $k=>$v){
  85. $codes = json_decode($v['codes'],1);
  86. //print_r($codes);
  87. if(!empty($codes)){
  88. foreach($codes as $sk=>$sv){
  89. if($sk=='special_code_a'||$sk=='special_code_b'){
  90. foreach($sv as $ck=>$cv){
  91. $j = $ck-1;
  92. $codename = ($sk=='special_code_a')?'codea_summoney':'codeb_summoney';
  93. $newdata[$j]['code_summoney'] += $cv[0];
  94. $newdata[$j][$codename] += $cv[0];
  95. }
  96. }else if ($sk == 'general_special'){
  97. foreach($sv as $ck=>$cv){
  98. $gk = explode('_', $ck);
  99. $j = $gk[1]-1;
  100. $codename = 'code' . $gk[0] . '_summoney';
  101. $newdata[$j]['codee_summoney'] += $cv[0];
  102. $newdata[$j][$codename] += $cv[0];
  103. }
  104. }
  105. }
  106. }
  107. }
  108. return \App\Lib\DataTable\DataTable::init()->toJson($newdata, 49);
  109. }
  110. function getAllno($game){
  111. $cls = '\App\Models\Game' . ucfirst($game);
  112. $gameno =new $cls;
  113. $gamenoAll = $gameno->getGameAllno();
  114. if($gamenoAll<0){
  115. return 1;
  116. }else{
  117. return $gamenoAll;
  118. }
  119. }
  120. }
  121. ?>