| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177 |
- <?php
- namespace App\Http\Controllers\Admin;
- use App\Http\Controllers\Controller;
- use Illuminate\Http\Request as Req;
- use Illuminate\Support\Facades\DB;
- use App\Models;
- use Request;
- /**
- *
- */
- class SportsbqController extends Controller {
- //棒球结果列表
- function outcome(Req $req) {
- $request=array();
- $request['status'] = isset($req->status) ? trim($req->status) : '-1';
- $request['source'] = isset($req->source) ? $req->source : null;
- $request['sureblurs'] = isset($req->sureblurs) ? $req->sureblurs : 'on';
- $request['home_team'] = isset($req->home_team) ? trim($req->home_team) : null;
- $request['star_time'] = isset($req->star_time) ? trim($req->star_time) :trans('status.default_time.seven_day') ;
- $request['end_time'] = isset($req->end_time) ? trim($req->end_time) : trans('status.default_time.etime');
- $dt = \App\Lib\DataTable\DataTable::init();
- $dt->setDataSource('/admin/Sportsbq/info');
- $dt->setLang('Sportsbq');
- $dt->addColsFields('newtime', array('templet' => '#home_team', 'sort' => false, 'width' => 200));
- $dt->addColsFields('home_team', array('templet' => '#home_team', 'sort' => false, 'width' => 80));
- $dt->addColsFields('guest_team', array('templet' => '#guest_team', 'sort' => false, 'width' => 80));
- $dt->addColsFields('dsnum', array('templet' => '#home_rate', 'sort' => false, 'width' => 80));
- $dt->addColsFields('csnum', array('templet' => '#home_rate', 'sort' => false, 'width' => 80));
- $dt->addColsFields('match_score', array('templet' => '#match_score', 'sort' => false, 'width' => 80));
- $dt->addColsFields('statusmatch', array('templet' => '#statusmatch', 'sort' => false, 'width' => 80));
- $dt->addColsFields('operation', array('templet' => '#operation', 'sort' => false, 'width' => 300));
- return view('admin.Sportsbq/outcome', $dt->render($request));
- }
- function info(){
- $page = Request::has('page') ? Request::get('page') : '';
- $list = Request::has('limit') ? Request::get('limit') : 10;
- $home_team = Request::has('home_team') ? Request::get('home_team') : '';
- $sureblur = Request::has('sureblurs') ? Request::get('sureblurs') : 'off';
- $status = Request::has('status') ? Request::get('status') : '';
- $source = Request::has('source') ? Request::get('source') : 'hg3535';
- $star_time = Request::get('star_time') ? Request::get('star_time').' 00:00:00' : '';
- $end_time = Request::get('end_time') ? Request::get('end_time').' 23:59:59' : '';
- $where = array();
- if ($status != -1) {
- $where[] = array('st_bq_result.status', '=', $status);
- }
- if (!empty($source)) {
- $where[] = array('st_bq_result.source', '=', $source);
- }
- if (!empty($star_time)) {
- $star_time = date('Y-m-d H:i:s', strtotime($star_time));
- $where[] = array('st_bq_result.start_time', '>', $star_time);
- }
- if (!empty($end_time)) {
- $end_time = date('Y-m-d H:i:s', strtotime($end_time));
- $where[] = array('st_bq_result.start_time', '<', $end_time);
- }//var_dump($where);die;
- $newapp = new \App\Models\Stbqresult();
- $data = $newapp->getinfo($list, $page, $where);
-
- return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
- }
- //作废
- function revoke(Req $req){
- $match_id = $req->match_id;//赛事id
- $model = \App\Models\Stbqresult::where('match_id', $match_id)->first();
- $model->status = 4;
- $model->save();
- $smodel = \App\Models\SportsSoccer::where('match_id', $match_id)->first();
- if($smodel){
- $smodel->status = 4;
- $smodel->save();
- }
- $upapp = new \App\Models\SportsNoteList();
- $data = $upapp->updatesimplex($match_id,'bq');//修改单式状态
- //单式撤单返现
- $newapp = new \App\Models\MoneyBuyMatch();
- $all = $newapp->allsimplexorder($match_id,'bq');
- for ($i=0; $i < count($all); $i++) {
- $appgx = new \App\Lib\Settlement\SettlementOrder();
- $appgx->insertData($all[$i]['order_id'], $all[$i]['money'], $all[$i]['account_identity'], '1', 'bq', $all[$i]['info_identity'], $all[$i]['money'],$all[$i]['match_id']);
- }
- //串式撤单只改状态
- $str_ids = array_column($newapp->allstrorder($match_id),'order_id');
- $csapp = new \App\Models\MoneyBuyStr();
- $csapp->updatestatus($str_ids);//var_dump($ss);die;
- //修改money_buy_match 投注结果result=2为平
- $newapp->updatast($match_id);
-
- return responseToJson(1);
- }
- //结算
- function Settlement(Req $req){
- //查询赛事下所有订单
- $ssid = $req->match_id;//赛事id
- $type = $req->type;//是否再结算1,首次结算2,再次结算
- $newapp = new \App\Models\MoneyBuyMatch();
- $simplex_ids = array_column($newapp->allsimplexorder($ssid,'bq'),'order_id');
- $str_ids = array_column($newapp->allstrorder($ssid),'order_id');
- $update = $this->addcomendnotice($ssid);
- if($update['status']==1){
- $SettlementOrder = new SettlementOrder();
- $SettlementOrder->reSettlement($str_ids, 2,$type,'bq',$ssid);//串式
- $data = $SettlementOrder->reSettlement($simplex_ids, 1,$type,'bq',$ssid);//单式注单
- return responseToJson($data);
- }else{
- return responseToJson($update);
- }
- }
- //查询赛事结果
- function Matchresult(Req $req){
- $match_id = $req->match_id;
- $newapp = \App\Models\Stbqresult::where('match_id', $match_id)->first();
- $array =array(
- 'corner_ball' => json_decode($newapp['corner_ball'],true),
- 'penalty_card' => json_decode($newapp['penalty_card'],true),
- 'newapp' => $newapp,
- );
- return $array;
- }
- function onlyresult(Req $req){
- $match_id = $req->matchid;
- $newapp = \App\Models\Stbqresult::where('match_id', $match_id)->first();
- return $newapp;
- }
- //结果添加
- function addend(Req $req){
- $match_id = $req->matchid;
- $model = \App\Models\Stbqresult::where('match_id', $match_id)->first();
- $penaltycard = array(
- 'home'=>intval($req->homeallcard)?intval($req->homeallcard):0,
- 'guest'=>intval($req->guestallcard)?intval($req->guestallcard):0,
- 'home_half'=>intval($req->homehalfcard)?intval($req->homehalfcard):0,
- 'guest_half'=>intval($req->guesthalfcard)?intval($req->guesthalfcard):0,
- );
- $cornerball = array(
- 'home'=>intval($req->homeallcorner)?intval($req->homeallcorner):0,
- 'guest'=>intval($req->guestallcorner)?intval($req->guestallcorner):0,
- 'home_half'=>intval($req->homehalfcorner)?intval($req->homehalfcorner):0,
- 'guest_half'=>intval($req->guesthalfcorner)?intval($req->guesthalfcorner):0,
- );
- $model->first_score = $req->firstscore;
- $model->last_score = $req->lastscore;
- $model->match_winer = $req->matchwiner;
- $model->penalty_card = json_encode($penaltycard);
- $model->corner_ball = json_encode($cornerball);
- $model->save();
- return responseToJson(1);
- }
- }
|