| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226 |
- <?php
- /**
- * Created by PhpStorm.
- * User: Jonlin
- * Date: 2019/4/9
- * Time: 9:11
- */
- namespace App\Http\Controllers\Admin;
- use App\Http\Controllers\Controller;
- use Illuminate\Http\Request as Req;
- use Illuminate\Support\Facades\DB;
- Use App\Lib\Settlement\SettlementOrder;
- Use App\Lib\Settlement\SettlementWinFail;
- use App\Models;
- use App\Models\MoneyBuySimplex as MoneyBuySimplexModel;
- use Request;
- /**
- *1
- */
- class SoccerNoteListController extends Controller
- {
- public function notelist(Req $req)
- {
- $request['name_chinese'] = isset($req->name_chinese) ? trim($req->name_chinese) : null;
- $request['sureblurs'] = isset($req->sureblurs) ? $req->sureblurs : 'on';
- $request['account'] = isset($req->account) ? trim($req->account) : null;
- $request['star_time'] = isset($req->star_time) ? trim($req->star_time) : null;
- $request['end_time'] = isset($req->end_time) ? trim($req->end_time) : null;
- $request['order_id'] = isset($req->order_id) ? trim($req->order_id) : null;
- $request['match_id'] = isset($req->match_id) ? trim($req->match_id) : null;
- $request['lg_id'] = isset($req->lg_id) ? trim($req->lg_id) : null;//联赛id 用于冠军联赛投注
- $request['is_gj'] = isset($req->is_gj) ? trim($req->is_gj) : 0;//是否是冠军联赛投注 0否 1是
- $request['status'] = isset($req->status) ? trim($req->status) : '-1';
- $request['order_status'] = isset($req->order_status) ? trim($req->order_status) : '-1';
- $request['game_status'] = isset($req->game_status) ? trim($req->game_status) : 0;
- $request['type'] = isset($req->type) ? trim($req->type) : 'zq';
- $dt = \App\Lib\DataTable\DataTable::init();
- $dt->setDataSource('/admin/SoccerNoteList/getinfo');
- $dt->setLang('sportsnotelist');
- //$dt->addColsFields('id', array('templet' => '#userdetail', 'sort' => true, 'width' => 80));
- $dt->addColsFields('match_id_order', array('sort' => true, 'width' => 210, 'minWidth'=>200));
- $dt->addColsFields('league', array('templet' => '#userdetail', 'sort' => false, 'width' => 100));
- $dt->addColsFields('home_guest', array('templet' => '#userdetail', 'sort' => false, 'width' => 260));
- $dt->addColsFields('content', array('templet' => '#userdetail', 'sort' => false, 'width' => 250));
- $dt->addColsFields('money', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
- $dt->addColsFields('water_return', array('templet' => '#userdetail', 'sort' => false, 'width' => 70));
- $dt->addColsFields('prize_money', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
- $dt->addColsFields('result', array('templet' => '#userdetail', 'sort' => false, 'width' => 70));
- $dt->addColsFields('money_match_time', array('templet' => '#userdetail', 'sort' => false, 'width' => 200));
- $dt->addColsFields('order_status', array('sort' => false, 'width' => 80));
- $dt->addColsFields('account_money', array('templet' => '#userdetail', 'sort' => false, 'width' => 110));
- // $dt->addColsFields('game_status', array('templet' => '#game_status', 'sort' => false, 'width' => 114));
- $dt->addColsFields('game_status', array('sort' => false, 'width' => 80));
- // $arr[] = 'view';1
- // if (checkRriv('/admin/SoccerNoteList/edit')) {
- // $arr[] = 'edit';
- // }
- // $dt->setToolBar($arr, array('width' => 70));
- $dt->enableCheckBox();//var_dump($request['type']);
- return view('sports/sports_notelist', $dt->render($request));
- }
- //冠军注单手工结算1
- public function championset(Req $req)
- {
- $request['name_chinese'] = isset($req->name_chinese) ? trim($req->name_chinese) : null;
- $request['sureblurs'] = isset($req->sureblurs) ? $req->sureblurs : 'on';
- $request['account'] = isset($req->account) ? trim($req->account) : null;
- $request['star_time'] = isset($req->star_time) ? trim($req->star_time) : null;
- $request['end_time'] = isset($req->end_time) ? trim($req->end_time) : null;
- $request['order_id'] = isset($req->order_id) ? trim($req->order_id) : null;
- $request['match_id'] = isset($req->match_id) ? trim($req->match_id) : null;
- $request['lg_id'] = isset($req->lg_id) ? trim($req->lg_id) : null;//联赛id 用于冠军联赛投注
- $request['is_gj'] = isset($req->is_gj) ? trim($req->is_gj) : 1;//是否是冠军联赛投注 0否 1是
- $request['status'] = isset($req->status) ? trim($req->status) : '-1';
- $request['order_status'] = isset($req->order_status) ? trim($req->order_status) : '-1';
- $request['type'] = isset($req->type) ? trim($req->type) : 'zq';
- $dt = \App\Lib\DataTable\DataTable::init();
- $dt->setDataSource('/admin/SoccerNoteList/championsetinfo');
- $dt->setLang('sportsnotelist');
- //$dt->addColsFields('id', array('templet' => '#userdetail', 'sort' => true, 'width' => 80));
- $dt->addColsFields('lg_id_order', array('sort' => true, 'width' => 210, 'minWidth' => 200));
- $dt->addColsFields('league', array('templet' => '#userdetail', 'sort' => false, 'width' => 100));
- $dt->addColsFields('home_guest', array('templet' => '#userdetail', 'sort' => false, 'width' => 260));
- $dt->addColsFields('content', array('templet' => '#userdetail', 'sort' => false, 'width' => 250));
- $dt->addColsFields('money', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
- $dt->addColsFields('water_return', array('templet' => '#userdetail', 'sort' => false, 'width' => 70));
- $dt->addColsFields('prize_money', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
- $dt->addColsFields('result', array('templet' => '#userdetail', 'sort' => false, 'width' => 70));
- $dt->addColsFields('money_match_time', array('templet' => '#userdetail', 'sort' => false, 'width' => 200));
- $dt->addColsFields('order_status', array('sort' => false, 'width' => 80));
- $dt->addColsFields('account_money', array('templet' => '#userdetail', 'sort' => false, 'width' => 110));
- // $dt->addColsFields('game_status', array('templet' => '#game_status', 'sort' => false, 'width' => 114));
- $dt->addColsFields('game_status', array( 'sort' => false, 'width' => 114));
- //$arr[] = 'view';
- // if (checkRriv('/admin/SoccerNoteList/edit')) {
- // $arr[] = 'edit';
- // }
- // $dt->setToolBar($arr, array('width' => 70));
- $dt->enableCheckBox();//var_dump($request['type']);
- return view('sports/sports_notelist', $dt->render($request));
- }
- function championsetinfo()
- {
- $page = Request::has('page') ? Request::get('page') : '';
- $list = Request::has('limit') ? Request::get('limit') : 10;
- $account = Request::get('account') ? Request::get('account') : '';
- $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' : '';
- $order_id = Request::get('order_id') ? Request::get('order_id') : '';
- $match_id = Request::get('match_id') ? Request::get('match_id') : '';
- $lg_id = Request::get('lg_id') ? Request::get('lg_id') : '';
- $status = Request::has('status') ? Request::get('status') : '-1';
- $order_status = Request::has('order_status') ? Request::get('order_status') : '';
- $sureblur = Request::has('sureblurs') ? Request::get('sureblurs') : 'off';
- $type = Request::has('type') ? Request::get('type') : 'zq';
- $where = array();
- $where[] = array('money_buy_simplex.is_champion', 1);
- if (!empty($account)) {
- if (empty($sureblur) || $sureblur == 'off') {
- $where[] = array('money_buy_simplex.account_name', 'like', '%' . $account . '%');
- } else {
- $where[] = array('money_buy_simplex.account_name', '=', $account);
- }
- }
- if (!empty($star_time)) {
- if (!empty($end_time)) {
- $where[] = array('money_buy_simplex.money_time', '>', $star_time);
- $where[] = array('money_buy_simplex.money_time', '<', $end_time);
- } else {
- $where[] = array('money_buy_simplex.money_time', '>', $star_time);
- }
- } else if (empty($star_time)) {
- if (!empty($end_time)) {
- $where[] = array('money_buy_simplex.money_time', '<', $end_time);
- }
- }
- if (!empty($order_id)) {
- $where[] = array('money_buy_simplex.order_id', $order_id);
- }
- if (!empty($match_id)) {
- $where[] = array('money_buy_simplex.match_id', $match_id);
- }
- if(!empty($lg_id)){
- $where[] = array('money_buy_simplex.lg_id', $lg_id);
- }
- if ($status != -1) {
- $where[] = array('money_buy_simplex.settle_status', '=', $status);
- }
- if ($order_status != -1) {
- $where[] = array('money_buy_simplex.status', '=', $order_status);
- }
- $where[] = array('money_buy_simplex.game_code', $type);
- $newapp = new \App\Models\SportsNoteList();
- $data = $newapp->getinfo($list, $page, $where, $type);
- //$alldata = Models\MoneyBuyMatch::where('bet_type',1)->where('is_rolling',1)->distinct('order_id')->count('order_id');
- return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total'], 0, $where);
- }
- //修改冠军单订单结果
- function orderupgj(Req $req)
- {
- $id = $req->id;//37
- $orderid = $req->order;//S20190916094723915270970
- if (intval($id) < 1) {
- return -1;
- }
- $data = \App\Models\SoccerLeague::where('id', $id)->first();
- $odds_code = \App\Models\SoccerOdds::where('lg_id', $id)->where('type', 1)->where('odds_code', '!=', '')->select('odds_code')->distinct()->get()->toArray();//赔率表
- for ($i = 0; $i < count($odds_code); $i++) {
- $allteam[] = \App\Models\SoccerOdds::where('odds_code', $odds_code[$i]['odds_code'])->where('lg_id', $id)->where('type', 1)->select('team')->distinct()->get()->toArray();
- }
- $data = $data->toArray();
- $isdisplay = \App\Models\Stwqleagueresult::where(['lg_id' => $id, 'status' => 1])->select("game_name")->distinct()->get()->toArray();
- $idisplay = array_column($isdisplay, 'game_name');
- $displays = implode(",", $idisplay);//转换成字符串
- //新增纪录
- foreach ($odds_code as $k => $v) {
- foreach ($allteam[$k] as $kk => $vv) {
- $name = $v['odds_code'];
- $isteam = $allteam[$k][$kk]['team'];
- $res = \App\Models\Stwqleagueresult::where(['lg_id' => $id, 'game_name' => $name, 'result' => $isteam])->first();
- $addresult = [
- 'lg_id' => $id,
- 'game_name' => $name,
- 'result' => $isteam,
- 'ctime' => date('Y-m-d H:i:s', time()),
- 'status' => 0,
- 'updated_at' => date('Y-m-d H:i:s', time()),
- ];
- if (empty($res)) {
- \App\Models\Stwqleagueresult::insert($addresult);
- }
- }
- }
- $orderjg = \App\Models\SportsNoteList::where(['order_id' => $orderid])->select("single_result")->first();
- $orderjg = json_decode($orderjg['single_result'], true);
- $data['allteam'] = $allteam;
- $data['odds_code'] = $odds_code;
- $data['displays'] = $displays;
- $data['isdisplay'] = $isdisplay;
- $data['orderjg'] = $orderjg;
- $data['orderid'] = $orderid;
- $data['lg_id'] = $id;
- return view('sports/orderupgj', $data);
- }
- //修改冠军单订单结果提交
- function ajaxtj(Req $req)
- {
- $isstatus = $req->isstatus;//更新
- $order = $req->order;
- if ($isstatus) {
- $gjresult = array(
- 'lg_id' => $req->lg_id ? $req->lg_id : '',
- 'game_name' => $req->odds_code ? $req->odds_code : '',
- 'result' => $req->team ? $req->team : '',
- 'updatetime' => date("Y-m-d H:i:s", time()),
- );
- } else {
- $gjresult = array(
- 'lg_id' => '',
- 'game_name' => '',
- 'result' => '',
- );
- }
- \App\Models\SportsNoteList::where(['order_id' => $order])->update(['single_result' => json_encode($gjresult, JSON_UNESCAPED_UNICODE)]);
- return responseToJson(1);
- }
- function info()
- {
- $page = Request::has('page') ? Request::get('page') : '';
- $list = Request::has('limit') ? Request::get('limit') : 10;
- $account = Request::get('account') ? Request::get('account') : '';
- $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' : '';
- $order_id = Request::get('order_id') ? Request::get('order_id') : '';
- $match_id = Request::get('match_id') ? Request::get('match_id') : '';
- // $status = Request::has('status') ? Request::get('status') : '';
- $order_status = Request::has('order_status') ? Request::get('order_status') : '';
- $sureblur = Request::has('sureblurs') ? Request::get('sureblurs') : 'off';
- $type = Request::has('type') ? Request::get('type') : 'zq';
- $where = array();
- $where[] = array('money_buy_simplex.is_champion', '<>', 1);
- if (!empty($account)) {
- if (empty($sureblur) || $sureblur == 'off') {
- $where[] = array('money_buy_simplex.account_name', 'like', '%' . $account . '%');
- } else {
- $where[] = array('money_buy_simplex.account_name', '=', $account);
- }
- }
- if (!empty($star_time)) {
- if (!empty($end_time)) {
- $where[] = array('money_buy_simplex.money_time', '>', $star_time);
- $where[] = array('money_buy_simplex.money_time', '<', $end_time);
- } else {
- $where[] = array('money_buy_simplex.money_time', '>', $star_time);
- }
- } else if (empty($star_time)) {
- if (!empty($end_time)) {
- $where[] = array('money_buy_simplex.money_time', '<', $end_time);
- }
- }
- if (!empty($order_id)) {
- $where[] = array('money_buy_simplex.order_id', $order_id);
- }
- if (!empty($match_id)) {
- $where[] = array('money_buy_simplex.match_id', $match_id);
- }
- //调整状态查询 1,2,3为订单状态 1投注 2作废 3撤单
- if ($order_status == 1 || $order_status == 2 || $order_status == 3) {
- $where[] = array('money_buy_simplex.status', '=', $order_status);
- }
- //4 5为结算状态 4未结算 5已结算
- if ($order_status == 4) {
- $status = 1;
- $where[] = array('money_buy_simplex.settle_status', '=', $status);
- }
- if ($order_status == 5) {
- $status = 2;
- $where[] = array('money_buy_simplex.settle_status', '=', $status);
- }
- /*
- if ($status != -1) {
- $where[] = array('money_buy_simplex.settle_status', '=', $status);
- }
- if ($order_status != -1) {
- $where[] = array('money_buy_simplex.status', '=', $order_status);
- }
- */
- $where[] = array('money_buy_simplex.game_code', $type);
- $newapp = new \App\Models\SportsNoteList();
- $data = $newapp->getinfo($list, $page, $where, $type);
- return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total'], 0, $where);
- }
- public function search(Req $req)
- {
- $request['name_chinese'] = isset($req->name_chinese) ? trim($req->name_chinese) : null;
- $request['sureblurs'] = isset($req->sureblurs) ? $req->sureblurs : 'on';
- $request['account'] = isset($req->account) ? trim($req->account) : null;
- $request['star_time'] = isset($req->star_time) ? trim($req->star_time) : null;
- $request['end_time'] = isset($req->end_time) ? trim($req->end_time) : null;
- $request['order_id'] = isset($req->order_id) ? trim($req->order_id) : null;
- $request['match_id'] = isset($req->match_id) ? trim($req->match_id) : null;
- $request['lg_id'] = isset($req->lg_id) ? trim($req->lg_id) : null;//联赛id 用于冠军联赛投注
- $request['is_gj'] = isset($req->is_gj) ? trim($req->is_gj) : 0;//是否是冠军联赛投注 0否 1是
- $request['status'] = isset($req->status) ? trim($req->status) : '-1';
- $request['order_status'] = isset($req->order_status) ? trim($req->order_status) : '-1';
- $request['type'] = isset($req->type) ? trim($req->type) : 'zq';
- $dt = \App\Lib\DataTable\DataTable::init();
- $dt->setDataSource('/admin/SoccerNoteList/info');
- $dt->setLang('sportsnotelist');
- //$dt->addColsFields('id', array('templet' => '#userdetail', 'sort' => true, 'width' => 80));
- $dt->addColsFields('match_id_order', array('sort' => true, 'width' => 210, 'minWidth'=>200));
- $dt->addColsFields('league', array('templet' => '#userdetail', 'sort' => false, 'width' => 100));
- $dt->addColsFields('home_guest', array('templet' => '#userdetail', 'sort' => false, 'width' => 260));
- $dt->addColsFields('content', array('templet' => '#userdetail', 'sort' => false, 'width' => 250));
- $dt->addColsFields('money', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
- $dt->addColsFields('water_return', array('templet' => '#userdetail', 'sort' => false, 'width' => 70));
- $dt->addColsFields('prize_money', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
- $dt->addColsFields('result', array('templet' => '#userdetail', 'sort' => false, 'width' => 70));
- $dt->addColsFields('money_match_time', array('templet' => '#userdetail', 'sort' => false, 'width' => 200));
- $dt->addColsFields('order_status', array('sort' => false, 'width' => 80));
- $dt->addColsFields('account_money', array('templet' => '#userdetail', 'sort' => false, 'width' => 110));
- // $dt->addColsFields('settle_status', array('sort' => false, 'width' => 90));
- //$arr[] = 'view';
- // if (checkRriv('/admin/SoccerNoteList/edit')) {
- // $arr[] = 'edit';
- // }
- // $dt->setToolBar($arr, array('width' => 70));
- $dt->enableCheckBox();
- return view('sports/sports_search', $dt->render($request));
- }
- //冠军注单
- public function champion(Req $req)
- {
- $request['name_chinese'] = isset($req->name_chinese) ? trim($req->name_chinese) : null;
- $request['sureblurs'] = isset($req->sureblurs) ? $req->sureblurs : 'on';
- $request['account'] = isset($req->account) ? trim($req->account) : null;
- $request['star_time'] = isset($req->star_time) ? trim($req->star_time) : null;
- $request['end_time'] = isset($req->end_time) ? trim($req->end_time) : null;
- $request['order_id'] = isset($req->order_id) ? trim($req->order_id) : null;
- $request['match_id'] = isset($req->match_id) ? trim($req->match_id) : null;
- $request['lg_id'] = isset($req->lg_id) ? trim($req->lg_id) : null;//联赛id 用于冠军联赛投注
- $request['is_gj'] = isset($req->is_gj) ? trim($req->is_gj) : 1;//是否是冠军联赛投注 0否 1是
- $request['status'] = isset($req->status) ? trim($req->status) : '-1';
- $request['order_status'] = isset($req->order_status) ? trim($req->order_status) : '-1';
- $request['type'] = isset($req->type) ? trim($req->type) : 'zq';
- $dt = \App\Lib\DataTable\DataTable::init();
- $dt->setDataSource('/admin/SoccerNoteList/championinfo');
- $dt->setLang('sportsnotelist');
- //$dt->addColsFields('id', array('templet' => '#userdetail', 'sort' => true, 'width' => 80));
- $dt->addColsFields('lg_id_order', array('sort' => true, 'width' => 210, 'minWidth' => 200));
- $dt->addColsFields('league', array('templet' => '#userdetail', 'sort' => false, 'width' => 100));
- $dt->addColsFields('home_guest', array('templet' => '#userdetail', 'sort' => false, 'width' => 260));
- $dt->addColsFields('content', array('templet' => '#userdetail', 'sort' => false, 'width' => 250));
- $dt->addColsFields('money', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
- $dt->addColsFields('water_return', array('templet' => '#userdetail', 'sort' => false, 'width' => 70));
- $dt->addColsFields('prize_money', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
- $dt->addColsFields('result', array('templet' => '#userdetail', 'sort' => false, 'width' => 70));
- $dt->addColsFields('money_match_time', array('templet' => '#userdetail', 'sort' => false, 'width' => 200));
- $dt->addColsFields('order_status', array('sort' => false, 'width' => 80));
- $dt->addColsFields('account_money', array('templet' => '#userdetail', 'sort' => false, 'width' => 110));
- // $dt->addColsFields('game_status', array('sort' => false, 'width' => 90));
- //$arr[] = 'view';
- // if (checkRriv('/admin/SoccerNoteList/edit')) {
- // $arr[] = 'edit';
- // }
- // $dt->setToolBar($arr, array('width' => 70));
- $dt->enableCheckBox();
- return view('sports/sports_search', $dt->render($request));
- }
- function championinfo()
- {
- $page = Request::has('page') ? Request::get('page') : '';
- $list = Request::has('limit') ? Request::get('limit') : 10;
- $account = Request::get('account') ? Request::get('account') : '';
- $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' : '';
- $order_id = Request::get('order_id') ? Request::get('order_id') : '';
- $match_id = Request::get('match_id') ? Request::get('match_id') : '';
- $lg_id = Request::get('lg_id') ? Request::get('lg_id') : '';
- $status = Request::has('status') ? Request::get('status') : '';
- $order_status = Request::has('order_status') ? Request::get('order_status') : '';
- $sureblur = Request::has('sureblurs') ? Request::get('sureblurs') : 'off';
- $type = Request::has('type') ? Request::get('type') : 'zq';
- $where = array();
- $where[] = array('money_buy_simplex.is_champion', 1);
- if (!empty($account)) {
- if (empty($sureblur) || $sureblur == 'off') {
- $where[] = array('money_buy_simplex.account_name', 'like', '%' . $account . '%');
- } else {
- $where[] = array('money_buy_simplex.account_name', '=', $account);
- }
- }
- if (!empty($star_time)) {
- if (!empty($end_time)) {
- $where[] = array('money_buy_simplex.money_time', '>', $star_time);
- $where[] = array('money_buy_simplex.money_time', '<', $end_time);
- } else {
- $where[] = array('money_buy_simplex.money_time', '>', $star_time);
- }
- } else if (empty($star_time)) {
- if (!empty($end_time)) {
- $where[] = array('money_buy_simplex.money_time', '<', $end_time);
- }
- }
- if (!empty($order_id)) {
- $where[] = array('money_buy_simplex.order_id', $order_id);
- }
- if (!empty($match_id)) {
- $where[] = array('money_buy_simplex.match_id', $match_id);
- }
- if(!empty($lg_id)){
- $where[] = array('money_buy_simplex.lg_id', $lg_id);
- }
- //调整状态查询 1,2,3为订单状态 1投注 2作废 3撤单
- if ($order_status == 1 || $order_status == 2 || $order_status == 3) {
- $where[] = array('money_buy_simplex.status', '=', $order_status);
- }
- //4 5为结算状态 4未结算 5已结算
- if ($order_status == 4) {
- $status = 1;
- $where[] = array('money_buy_simplex.settle_status', '=', $status);
- }
- if ($order_status == 5) {
- $status = 2;
- $where[] = array('money_buy_simplex.settle_status', '=', $status);
- }
- /*
- if ($status != -1) {
- $where[] = array('money_buy_simplex.settle_status', '=', $status);
- }
- if ($order_status != -1) {
- $where[] = array('money_buy_simplex.status', '=', $order_status);
- }
- */
- $where[] = array('money_buy_simplex.game_code', $type);
- $newapp = new \App\Models\SportsNoteList();
- $data = $newapp->getinfo($list, $page, $where, $type);
- return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total'], 0, $where);
- }
- //查询赛事结果
- // function Sairesult(Req $req){
- // $did = $req->did;
- // $qlgame = $req->qlgame?$req->qlgame:'zq';
- // $newapp = \App\Models\SportsNoteList::where('id', $did)->first();
- // if($qlgame=='zq'){
- // if($newapp['match_id']){
- // $newre = new \App\Models\Stzqresult();
- // $teamname = $newre->matchjg($newapp['match_id']);
- // }else{
- // $teamname ='';
- // }
- // }elseif($qlgame=='lq'){
- // if($newapp['match_id']){
- // $newre = new \App\Models\Stlqresult();
- // $teamname = $newre->matchjg($newapp['match_id']);
- // }else{
- // $teamname ='';
- // }
- // }elseif($qlgame=='bq'){
- // if($newapp['match_id']){
- // $newre = new \App\Models\Stbqresult();
- // $teamname = $newre->matchjg($newapp['match_id']);
- // }else{
- // $teamname ='';
- // }
- // }elseif($qlgame=='wq'){
- // if($newapp['match_id']){
- // $newre = new \App\Models\Stwqresult();
- // $teamname = $newre->matchjg($newapp['match_id']);
- // }else{
- // $teamname ='';
- // }
- // }else{
- // $data = "参数错误";
- // }
- // $data =array(
- // 'singleresult' => json_decode($newapp['single_result'],true),
- // 'teamname' => $teamname,
- // );
- // return $data;
- // }
- // function Sairesult(Req $req){
- // $did = $req->did;
- // $model = \App\Models\SportsNoteList::where('id', $did)->first();
- // $pid = $model['match_id'];
- // $saisjg = \App\Models\Stzqresult::where('match_id',$pid)->first()->toArray();//赛事结果
- // $saisjg['corner_ball'] = json_decode($saisjg['corner_ball'],true);
- // $saisjg['first_score'] = json_decode($saisjg['first_score'],true);
- // $saisjg['penalty_card'] = json_decode($saisjg['penalty_card'],true);
- // $saisjg['warn_more'] = json_decode($saisjg['warn_more'],true);
- // }
- //结果添加
- function addend(Req $req)
- {
- $did = $req->did;//59;//
- $qlgame = $req->qlgame;//1;
- $model = \App\Models\SportsNoteList::where('id', $did)->first();
- $pid = $model['match_id'];
- if ($qlgame == 1) {
- if ($model['result_flag'] != 1) {
- $saisjg = \App\Models\Stzqresult::where('match_id', $pid)->first()->toArray();//赛事结果
- $saisjg['corner_ball'] = json_decode($saisjg['corner_ball'], true);
- $saisjg['first_score'] = json_decode($saisjg['first_score'], true);
- $saisjg['penalty_card'] = json_decode($saisjg['penalty_card'], true);
- $saisjg['warn_more'] = json_decode($saisjg['warn_more'], true);
- $model->single_result = json_encode([$saisjg], JSON_UNESCAPED_UNICODE);
- $model->save();
- }
- $newm = \App\Models\SportsNoteList::where('id', $did)->first();
- return $newm['single_result'];
- } else {
- $new = \App\Models\SportsNoteList::where('id', $did)->first();
- $newa = json_decode($new['single_result'], true);
- $newa[0]['home_score'] = $req->home_score;//主队进球
- $newa[0]['guest_score'] = $req->guest_score;//客队进球
- $newa[0]['all_goal'] = intval($req->guest_score) + intval($req->home_score);//总进球
- $newa[0]['last_score'] = $req->lastscore ? $req->lastscore : '';//最后进球球队
- $newa[0]['match_winer'] = $req->matchwiner ? $req->matchwiner : '';//赢球球队
- $newa[0]['update_time'] = time();//更新时间
- $newa[0]['u_guest_score'] = $req->u_guest_score;//上半场-主队进球数
- $newa[0]['u_home_score'] = $req->u_home_score;//上半场-客队进球数
- $newa[0]['penalty_card'] = array(
- 'home' => $req->homeallcard,
- 'guest' => $req->guestallcard,
- 'home_half' => $req->homehalfcard,
- 'guest_half' => $req->guesthalfcard,
- );
- $newa[0]['corner_ball'] = array(
- 'home' => $req->homeallcorner,
- 'guest' => $req->guestallcorner,
- 'home_half' => $req->homehalfcorner,
- 'guest_half' => $req->guesthalfcorner,
- );
- //最新进球
- $newa[0]['first_score'] = array(
- 'teamscore' => $req->firstscore ? $req->firstscore : 0,//最先进球球队
- 'scoretime' => $req->onescoretime ? $req->onescoretime : '',//进球时间
- 'scoretype' => $req->firststye ? $req->firststye : '',//进球方式
- );
- $model->single_result = json_encode($newa, JSON_UNESCAPED_UNICODE);
- $model->result_flag = 1;
- $model->save();
- return responseToJson(1);
- }
- }
- function getinfo()
- {
- $page = Request::has('page') ? Request::get('page') : '';
- $list = Request::has('limit') ? Request::get('limit') : 10;
- $account = Request::get('account') ? Request::get('account') : '';
- $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' : '';
- $order_id = Request::get('order_id') ? Request::get('order_id') : '';
- $match_id = Request::get('match_id') ? Request::get('match_id') : '';
- $status = Request::has('status') ? Request::get('status') : '-1';
- $order_status = Request::has('order_status') ? Request::get('order_status') : '';
- $sureblur = Request::has('sureblurs') ? Request::get('sureblurs') : 'off';
- $type = Request::has('type') ? Request::get('type') : 'zq';
- $where = array();
- $where[] = array('money_buy_simplex.is_champion', '<>', 1);
- if (!empty($account)) {
- if (empty($sureblur) || $sureblur == 'off') {
- $where[] = array('money_buy_simplex.account_name', 'like', '%' . $account . '%');
- } else {
- $where[] = array('money_buy_simplex.account_name', '=', $account);
- }
- }
- if (!empty($star_time)) {
- if (!empty($end_time)) {
- $where[] = array('money_buy_simplex.money_time', '>', $star_time);
- $where[] = array('money_buy_simplex.money_time', '<', $end_time);
- } else {
- $where[] = array('money_buy_simplex.money_time', '>', $star_time);
- }
- } else if (empty($star_time)) {
- if (!empty($end_time)) {
- $where[] = array('money_buy_simplex.money_time', '<', $end_time);
- }
- }
- if (!empty($order_id)) {
- $where[] = array('money_buy_simplex.order_id', $order_id);
- }
- if (!empty($match_id)) {
- $where[] = array('money_buy_simplex.match_id', $match_id);
- }
- //调整状态查询 1,2,3为订单状态 1投注 2作废 3撤单
- if ($order_status == 1 || $order_status == 2 || $order_status == 3) {
- $where[] = array('money_buy_simplex.status', '=', $order_status);
- }
- //4 5为结算状态 4未结算 5已结算
- if ($order_status == 4) {
- $status = 1;
- $where[] = array('money_buy_simplex.settle_status', '=', $status);
- }
- if ($order_status == 5) {
- $status = 2;
- $where[] = array('money_buy_simplex.settle_status', '=', $status);
- }
- /*
- if ($status != -1) {
- $where[] = array('money_buy_simplex.settle_status', '=', $status);
- }
- if ($order_status != -1) {
- $where[] = array('money_buy_simplex.status', '=', $order_status);
- }
- */
- $where[] = array('money_buy_simplex.game_code', $type);
- $newapp = new \App\Models\SportsNoteList();
- $data = $newapp->getinfo($list, $page, $where, $type);
- //$alldata = Models\MoneyBuyMatch::where('bet_type',1)->where('is_rolling',1)->distinct('order_id')->count('order_id');
- return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total'], 0, $where);
- }
- /**
- *单式注单作废
- */
- public function invalid(Req $req)
- {
- $id = $req->id;
- $reason = $_GET['reason'];
- if (intval($id) < 1) {
- return -1;
- }
- $order = \App\Models\SportsNoteList::where('id', $id)->first();
- //用戶账户金额
- $account_money = \App\Models\Account_detailed::where('account_identity', $order->account_identity)->first();
- //反水
- $water_return_money = \App\Models\Money_details::where('trade_id', $order->order_id)->where('trade_type', '7')->first();
- if (!empty($water_return_money)) {
- $water_return = $water_return_money->money;
- } else {
- $water_return = 0;
- }
- //撤单后用户账户金额
- $available_cash = $account_money->available_cash;
- $new_available_cash = $available_cash + $order->money - $order->gain_money - $water_return;
- $model = new \App\Models\Money_details();
- $model->info_identity = UUID();
- $model->trade_id = $order->order_id;
- $model->account_name = $order->account_name;
- $model->account_identity = $order->account_identity;
- $model->money = abs($order->money - $order->gain_money - $water_return);
- $model->money_time = date("Y-m-d H:i:s", time());
- if ($new_available_cash > $available_cash) {
- $model->money_type = '1';
- } else {
- $model->money_type = '2';
- }
- $model->money_cash = $new_available_cash;
- $model->trade_type = '3';
- $model->trade_desc = '管理员作废单式注单';
- $model->status = '1';
- try {
- DB::beginTransaction();//开启事务
- \App\Models\SportsNoteList::where('id', $id)->update(['status' => '2', 'gain_money' => '0', 'use_mark' => $reason]);
- \App\Models\Account_detailed::where('account_identity', $order->account_identity)->update(['available_cash' => $new_available_cash, 'cash' => $new_available_cash]);
- $model->save();
- DB::commit();//提交
- return 1;
- } catch (Exception $e) {
- DB::rollback();//回滚
- return -1;
- }
- }
- /**
- *单式注单首次结算
- */
- public function settlement(Req $req)
- {
- $id = $req->id;
- if (intval($id) < 1) {
- return -1;
- }
- $order = \App\Models\SportsNoteList::where('id', $id)->first();
- $order_id = $order->order_id;
- $order_ids = array($order->order_id);
- $match_id = $order->match_id;
- $game_code = $order->game_code;
- $bet_type = 1;//单式注单
- //return $match_id;
- //判断输赢
- $settlementWinFail = new SettlementWinFail();
- $res = $settlementWinFail->ProcWinInfoByOneOrder($match_id, $order_id, $bet_type);
- //结算
- $SettlementOrder = new SettlementOrder();
- $settype = 1; //首次结算
- $data = $SettlementOrder->reSettlement($order_ids, $bet_type, $settype, $game_code, $match_id, $match_status = 0);
- return $data;
- }
- /**
- *单式注单重新结算
- */
- // public function resettlement(Req $req) {
- // $id = $req->id;
- // if (intval($id) < 1) {
- // return -1;
- // }
- // $order = \App\Models\SportsNoteList::where('id',$id)->first();
- // $match_id = $order->match_id;
- // $game_code = $order->game_code;
- // $order_id = $order->order_id;
- // $order_ids = array($order->order_id);
- // //return $match_id;
- // $bet_type = 1;//单式注单
- // //重新判断输赢
- // $settlementWinFail = new SettlementWinFail();
- // $res = $settlementWinFail->ProcWinInfoByOneOrder($match_id, $order_id, $bet_type);
- // //结算
- // $SettlementOrder = new SettlementOrder();
- // $settype = 2; //重新结算
- // $data = $SettlementOrder->reSettlement($order_ids,$bet_type,$settype,$game_code,$match_id,$match_status=0);
- // return $data;
- // }
- public function resettlement(Req $req)
- {
- $order_id = $req->order_id;
- $type = $req->type;
- $match_id = $req->match_id;
- $jsurl = config('sconstant.url');//结算请求域名地址
- $token = session('adminInfo.token');
- //查询是否有订单
- $newapp = new \App\Models\SportsNoteList();
- $simplexnum = $newapp->onlyorder($order_id);
- if ($simplexnum == 1) {
- $requet = file_get_contents($jsurl . "/DoWinFailOneOrder?order_id=" . $order_id . "&token=" . $token);
- if (json_decode($requet, true)['status'] == 1) {
- $napp = new \App\Models\Stzqresult();
- $simplex = array(
- 'token' => $token,
- 'order_ids' => $order_id, //订单id字符串,用半角都好分隔
- 'bettype' => 1, //结算类型 1单式 2串式
- 'settype' => 2, //结算次数 1首次 2非首冷饮
- 'game_code' => $type, //赛事类型 zq lq wq bq
- 'match_id' => $match_id, // 赛事ID
- 'change_status' => 0 //是否改状态
- );
- $url = $jsurl . '/Settelement';
- $simplex_res = $napp->post_curls($url, $simplex);//返回json
- $huawei_res = json_decode($simplex_res, true);
- if ($huawei_res['status'] == 1) {
- return json_encode(['status' => 1, 'msg' => '结算成功']);
- } else {
- return json_encode(['status' => 4, 'msg' => '结算失败']);
- }
- } else {
- return json_encode(['status' => 3, 'msg' => '输赢判断错误']);
- }
- } else {
- return json_encode(['status' => 2, 'msg' => '订单不存在']);
- }
- }
- /**
- *单式注单批量结算
- */
- public function batchsettlement()
- {
- $orders = \App\Models\SportsNoteList::where('settle_status', '1')->get();
- $order_ids = array();
- for ($i = 0; $i < count($orders); $i++) {
- $result = \App\Models\MoneyBuyMatch::where('batch_id', $orders[$i]->batch_id)->where('match_id', $orders[$i]->match_id)->get();
- $res = array();
- for ($j = 0; $j < count($result); $j++) {
- $res[] = $result[$j]->result;
- }
- if (!in_array(0, $res)) {
- $order_ids[] = $orders[$i]->order_id;
- }
- }
- $SettlementOrder = new SettlementOrder();
- $bet_type = 1;//单式注单
- $data = $SettlementOrder->reSettlement($order_ids, $bet_type);
- return $data;
- }
- /**
- *删除订单
- */
- public function delete(Req $req)
- {
- $id = $req->input('id');
- if (empty($id)) {
- return responseToJson(-2001); //id
- }
- $ids = explode(',', $id);
- if (!is_array($ids) && intval($ids) < 0) {
- return responseToJson(-2002); //id
- }
- if (is_array($ids) && count($ids) > 0) {
- foreach ($ids as $k => $v) {
- if (intval($v) < 1) {
- unset($ids[$k]);
- }
- }
- }
- $rows = \App\Models\SportsNoteList::whereIn('id', $ids)->delete();
- if (!$rows) {
- return responseToJson(-2003); //id
- }
- return responseToJson(1, trans('menu.delete_success')); //id
- }
- /**
- * 投注金额统计
- */
- function moneycount()
- {
- $where = Request::has('where') ? Request::get('where') : '';
- $type = Request::has('type') ? Request::get('type') : 'zq';
- $db = new \App\Models\SportsNoteList;
- $data = $db->MoneyCount($where, $type);
- return responseToJson($data);
- }
- //单式订单数据
- public function manualmatchget(Req $req)
- {
- $order_id = isset($req->order_id) ? $req->order_id : 0;
- $model = new \App\Models\SportsNoteList();
- $ret = $model->getorder($order_id);
- if ($ret) {
- // $league = db('st_'.$ret->game_code.'_league')->where('id',$ret->lg_id)->first();
- // $ret->league = $league->name_chinese;
- $modelcode = new \App\Models\StoddsCode();
- $opcode_nameArr = $modelcode->getTypeDatas($ret->game_code);
- $ret = $ret->toArray();
- foreach ($ret['matchdatas'] as $key => $val) {
- $tmp_pcode = $val['p_code'];
- $tmp_code = $val['odds_code'];
- $ret['matchdatas'][$key]['odds_name'] = isset($opcode_nameArr[$tmp_pcode][$tmp_code]['odds_name']) ? $opcode_nameArr[$tmp_pcode][$tmp_code]['odds_name'] : '';
- }
- return responseToJson(1, '成功', $ret);
- } else {
- return responseToJson(-1, 'false', $ret);
- }
- }
- //单式订单直接手动更改输赢结果并结算
- public function manualmatchpdate(Req $req)
- {
- $order_id = isset($req->order_id) ? $req->order_id : 0;
- $datas = isset($req->matchdata) ? $req->matchdata : [];
- $datas = json_decode($datas, true);
- if (empty($order_id) || empty($datas)) {
- return responseToJson(-1, '参数不能为空!');
- }
- $model = new \App\Models\SportsNoteList();
- $modeldata = $model->getorder($order_id);
- if (empty($modeldata)) {
- return responseToJson(-1, 'false');
- }
- $sdataArr = [];
- foreach ($datas as $val) {
- $tmp_id = $val['id'];
- $tmp_result = intval($val['result']);
- $tmp_matchword = trim($val['matchresult']);
- if (!in_array($tmp_result, [-1, 1, 2, 3, 4])) {
- continue;
- }
- $sdataArr[$tmp_id] = ['result' => $tmp_result, 'matchresult' => $tmp_matchword];
- }
- if (empty($sdataArr)) {
- return responseToJson(-2, '没有要更新的数据');
- }
- $chageNum = 0;
- foreach ($modeldata->matchdatas as $key => $val) {
- $id = $val->id;
- if (isset($sdataArr[$id])) {
- if ($val->result != $sdataArr[$id]['result'] || $val->matchwork != $sdataArr[$id]['matchresult']) {
- $val->result = $sdataArr[$id]['result'];
- $val->matchresult = $sdataArr[$id]['matchresult'];
- $val->save();
- $chageNum++;
- }
- }
- }
- if ($chageNum) {
- $modeldata->is_manual = 1;
- $modeldata->save();
- } else {
- return responseToJson(1, '没有更新操作数据!');
- }
- $data = [
- 'token' => session('adminInfo.token'), //外网
- 'order_ids' => $modeldata->order_id,
- 'bettype' => 1,
- 'settype' => 2,
- 'game_code' => $modeldata->game_code,
- 'match_id' => $modeldata->match_id,
- 'change_status' => 0,
- 'is_manual' => 1,
- ];
- $ret = $this->request_post(config('sconstant.url') . '/Settelement', $data);
- $retjson = json_decode($ret, true);
- if (isset($retjson['status']) && $retjson['status'] == 1) {
- $model->where('order_id', $order_id)->update(['settle_status' => 2]);
- }
- return responseToJson(1, '更新成功');
- }
- //单式订单直接手动设置比赛结果 --> 提交胜负判断处理以及 --> 提交结算
- public function manualmatchpdate_v2(Req $req)
- {
- $order_id = isset($req->order_id) ? $req->order_id : 0;
- $game_code = isset($req->game_code) ? $req->game_code : 0;
- $match_id = isset($req->match_id) ? $req->match_id : 0;
- $pdatas = isset($req->matchdata) ? $req->matchdata : [];
- $pdatas = json_decode($pdatas, true);
- if (empty($order_id) || empty($game_code) || empty($match_id) || empty($pdatas)) {
- return responseToJson(0, '参数错误');
- }
- $buyModel = (new MoneyBuySimplexModel())->where([['order_id', '=', $order_id]])->first();
- if (empty($buyModel)) {
- return responseToJson(0, '订单数据错误');
- }
- $restModel = '';
- switch ($game_code) {
- case 'zq':
- $restModel = DB::table('st_zq_result')->where([['match_id', '=', $match_id]])->first();
- break;
- case 'lq':
- $restModel = DB::table('st_lq_result')->where([['match_id', '=', $match_id]])->first();
- break;
- case 'wq':
- $restModel = DB::table('st_wq_result')->where([['match_id', '=', $match_id]])->first();
- break;
- case 'bq':
- $restModel = DB::table('st_bq_result')->where([['match_id', '=', $match_id]])->first();
- break;
- }
- if (empty($restModel)) {
- return responseToJson(0, '赛事结果记录没有找到,数据错误');
- }
- if ($game_code == 'zq') {
- $home = intval($pdatas['home']);
- $guest = intval($pdatas['guest']);
- $home_u = intval($pdatas['home_u']);
- $guest_u = intval($pdatas['guest_u']);
- $restModel->home_score = $home;
- $restModel->guest_score = $guest;
- $restModel->u_home_score = $home_u;
- $restModel->u_guest_score = $guest_u;
- $restModel->corner_ball = json_decode($restModel->corner_ball, 256);
- $restModel->penalty_card = json_decode($restModel->penalty_card, 256);
- $restModel->first_score = json_decode($restModel->first_score, 256);
- $restModel->warn_more = json_decode($restModel->warn_more, 256);
- $buyModel->single_result = json_encode([$restModel], 256);
- $buyModel->result_flag = 1;
- $buyModel->is_manual = 1;
- $ret = $buyModel->save();
- if ($ret) {
- $ret2 = $this->do_win_set($order_id, $game_code, $match_id);
- if ($ret2['status'] == 1) {
- return responseToJson(1, '操作成功!');
- } else {
- return responseToJson(0, '操作失败2!--' . $ret2['data']);
- }
- }
- return responseToJson(0, '更新失败1');
- }
- if ($game_code == 'lq') {
- $home = $pdatas['home'];
- $guest = $pdatas['guest'];
- $restModel->home_score = ['1' => intval($home['0']), '2' => intval($home['1']), '3' => intval($home['2']), '4' => intval($home['3'])];
- $restModel->guest_score = ['1' => intval($guest['0']), '2' => intval($guest['1']), '3' => intval($guest['2']), '4' => intval($guest['3'])];
- $restModel->u_home_score = intval($home['0']) + intval($home['1']);
- $restModel->u_guest_score = intval($guest['0']) + intval($guest['1']);
- $all_home = intval($home['0']) + intval($home['1']) + intval($home['2']) + intval($home['3']);
- $all_guest = intval($guest['0']) + intval($guest['1']) + intval($guest['2']) + intval($guest['3']);
- $restModel->all_goal = $all_home + $all_guest;
- $restModel->match_score = $all_home . ':' . $all_guest;
- $restModel->match_winer = $all_home > $all_guest ? $restModel->home_team : $restModel->guest_team;
- $restModel->warn_more = json_decode($restModel->warn_more, 256);
- $buyModel->single_result = json_encode([$restModel], 256);
- $buyModel->result_flag = 1;
- $buyModel->is_manual = 1;
- $ret = $buyModel->save();
- if ($ret) {
- $ret2 = $this->do_win_set($order_id, $game_code, $match_id);
- if ($ret2['status'] == 1) {
- return responseToJson(1, '操作成功!');
- } else {
- return responseToJson(0, '操作失败2!--' . $ret2['data']);
- }
- }
- return responseToJson(0, '更新失败1');
- }
- if ($game_code == 'bq') {
- $home = $pdatas['home'];
- $guest = $pdatas['guest'];
- $home_other = $pdatas['home_other'];
- $guest_other = $pdatas['guest_other'];
- $arrs = [];
- for ($i = 0; $i <= 8; $i++) {
- $j = $i + 1;
- $arrs[$j] = [
- 'home' => intval($home[$i]),
- 'guest' => intval($guest[$i]),
- ];
- }
- $arrs['other'] = [
- 'home' => intval($home_other),
- 'guest' => intval($guest_other),
- ];
- $restModel->match_score_t = $arrs;
- $restModel->warn_more = json_decode($restModel->warn_more, 256);
- $buyModel->single_result = json_encode([$restModel], 256);
- $buyModel->result_flag = 1;
- $buyModel->is_manual = 1;
- $ret = $buyModel->save();
- if ($ret) {
- $ret2 = $this->do_win_set($order_id, $game_code, $match_id);
- if ($ret2['status'] == 1) {
- return responseToJson(1, '操作成功!');
- } else {
- return responseToJson(0, '操作失败2!--' . $ret2['data']);
- }
- }
- return responseToJson(0, '更新失败1');
- }
- if ($game_code == 'wq') {
- $home = $pdatas['home'];
- $guest = $pdatas['guest'];
- $arrs = [];
- for ($i = 0; $i <= 4; $i++) {
- $j = $i + 1;
- $arrs[$j] = [
- 'home' => intval($home[$i]),
- 'guest' => intval($guest[$i]),
- ];
- }
- $restModel->inning = $arrs;
- $restModel->warn_more = json_decode($restModel->warn_more, 256);
- $buyModel->single_result = json_encode([$restModel], 256);
- $buyModel->result_flag = 1;
- $buyModel->is_manual = 1;
- $ret = $buyModel->save();
- if ($ret) {
- $ret2 = $this->do_win_set($order_id, $game_code, $match_id);
- if ($ret2['status'] == 1) {
- return responseToJson(1, '操作成功!');
- } else {
- return responseToJson(0, '操作失败2!--' . $ret2['data']);
- }
- }
- return responseToJson(0, '更新失败1');
- }
- return responseToJson(0, '未做更新', ['order_id' => $order_id, 'game_code' => $game_code, 'match_id' => $game_code, 'datas' => $pdatas]);
- }
- //修复比分时用到订单信息及比赛结果数据
- public function manualmatchget_v2(Req $req)
- {
- $order_id = isset($req->order_id) ? $req->order_id : 0;
- $model = new MoneyBuySimplexModel();
- $ret = $model->OrderinfoResult($order_id);
- if ($ret && !empty($ret['result'])) {
- return responseToJson(1, '成功', $ret);
- } else {
- return responseToJson(-1, 'false', $ret);
- }
- }
- //先提交输赢,再结算
- private function do_win_set($order_id, $game_code, $match_id)
- {
- $winret = $this->do_winfail($order_id, $game_code, $match_id);
- if ($winret['status'] == 1) {
- $setret = $this->do_settelement($order_id, $game_code, $match_id);
- if ($setret['status'] == 1) {
- return ['status' => 1, 'msg' => 'success', 'data' => []];
- } else {
- return ['status' => 0, 'msg' => 'failse', 'data' => $setret['msg']];
- }
- } else {
- return ['status' => 0, 'msg' => 'failse', 'data' => $winret['msg']];
- }
- }
- //单订单手动提交输赢计算
- private function do_winfail($order_id, $game_code, $match_id)
- {
- $data = [
- 'token' => session('adminInfo.token'), //外网
- 'order_id' => $order_id,
- ];
- $ret = $this->request_post(config('sconstant.url') . '/DoWinFailOneOrder', $data);
- return json_decode($ret, true);
- }
- //单订单手动提交结算
- private function do_settelement($order_id, $game_code, $match_id)
- {
- $data = [
- 'token' => session('adminInfo.token'), //外网
- 'order_ids' => $order_id,
- 'bettype' => 1,
- 'settype' => 2,
- 'game_code' => $game_code,
- 'match_id' => $match_id,
- 'change_status' => 0,
- 'is_manual' => 1,
- ];
- $ret = $this->request_post(config('sconstant.url') . '/Settelement', $data);
- return json_decode($ret, true);
- }
- private function request_post($url = '', $param = '')
- {
- if (empty($url) || empty($param)) {
- return false;
- }
- $postUrl = $url;
- $curlPost = $param;
- $ch = curl_init();//初始化curl
- curl_setopt($ch, CURLOPT_URL, $postUrl);//抓取指定网页
- curl_setopt($ch, CURLOPT_HEADER, 0);//设置header
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//要求结果为字符串且输出到屏幕上
- curl_setopt($ch, CURLOPT_POST, 1);//post提交方式
- curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost);
- $data = curl_exec($ch);//运行curl
- curl_close($ch);
- return $data;
- }
- }
|