| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290 |
- <?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\Models;
- use Request;
- /**
- *
- */
- class SoccerStringNoteListController 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['status'] = isset($req->status) ? trim($req->status) : '-1';
- $dt = \App\Lib\DataTable\DataTable::init();
- $dt->setDataSource('/admin/SoccerStringNoteList/info');
- $dt->setLang('sportsnotelist');
- //$dt->addColsFields('id', array('templet' => '#userdetail', 'sort' => true, 'width' => 80));
- $dt->addColsFields('order_id', array('templet' => '#userdetail', 'sort' => true, 'width' => 200));
- $dt->addColsFields('str_type', array('templet' => '#userdetail', 'sort' => false, 'width' => 70));
- $dt->addColsFields('detail_content', array('sort' => false, 'width' => 150));
- $dt->addColsFields('money', array('templet' => '#userdetail', 'sort' => false, 'width' => 90));
- $dt->addColsFields('water_return', array('templet' => '#userdetail', 'sort' => false, 'width' => 90));
- $dt->addColsFields('prize_money', array('templet' => '#userdetail', 'sort' => false, 'width' => 90));
- $dt->addColsFields('result', array('templet' => '#userdetail', 'sort' => false, 'width' => 90));
- $dt->addColsFields('money_match_time', array('templet' => '#userdetail', 'sort' => false, 'width' => 200));
- $dt->addColsFields('account', array('templet' => '#userdetail', 'sort' => false, 'width' => 240));
- $dt->addColsFields('settle_status', array('sort' => false, 'width' => 100));
- // if (checkRriv('/admin/SoccerStringNoteList/edit')) {
- // $arr[] ='edit';
- // }
- // $dt->setToolBar($arr, array('width' => 100));
- $dt->enableCheckBox();
- return view('sports/sports_stringnotelist', $dt->render($request));
- }
- 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') : '';
- $status = Request::has('status') ? Request::get('status') : '';
- $sureblur = Request::has('sureblurs') ? Request::get('sureblurs') : 'off';
- $where = array();
- if (!empty($account)) {
- if (empty($sureblur) || $sureblur == 'off') {
- $where[] = array('money_buy_str.account_name', 'like', '%' . $account . '%');
- } else {
- $where[] = array('money_buy_str.account_name', '=', $account);
- }
- }
- if (!empty($star_time)) {
- if (!empty($end_time)){
- $where[] = array('money_buy_str.money_time', '>', $star_time);
- $where[] = array('money_buy_str.money_time', '<', $end_time);
- }else{
- $where[] = array('money_buy_str.money_time', '>', $star_time);
- }
- }else if(empty($star_time)){
- if (!empty($end_time)){
- $where[] = array('money_buy_str.money_time', '<', $end_time);
- }
- }
- if (!empty($order_id)){
- $where[] = array('money_buy_str.order_id', $order_id);
- }
- if ($status != -1) {
- $where[] = array('money_buy_str.settle_status', '=', $status);
- }
- $newapp = new \App\Models\MoneyBuyStr();
- $data = $newapp->getinfo($list, $page, $where);
- return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total'], 0, $where);
- }
- /**
- *串关注单详情
- */
- function detail(Req $req) {
- $id = $req->id;
- $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['match_id'] = isset($req->match_id) ? trim($req->match_id) :null ;
- $dt = \App\Lib\DataTable\DataTable::init();
- $dt->setDataSource('/admin/SoccerStringNoteList/detailinfo?id='.$id.'');
- $dt->setLang('sportsnotelist');
- $dt->addColsFields('match_id', array('templet' => '#userdetail', 'sort' => true, 'width' => 80));
- $dt->addColsFields('league', array('templet' => '#userdetail', 'sort' => false, 'width' => 150));
- $dt->addColsFields('home_guest', array('templet' => '#userdetail', 'sort' => false, 'width' => 180));
- $dt->addColsFields('game_type', array('templet' => '#userdetail', 'sort' => false, 'width' => 90));
- $dt->addColsFields('odds_code', array('templet' => '#userdetail', 'sort' => false, 'width' => 180));
- $dt->addColsFields('condition', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
- $dt->addColsFields('odds', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
- $dt->addColsFields('status', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
- $dt->addColsFields('result', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
- $dt->enableCheckBox();
- return view('sports/sports_notelistdetail', $dt->render($request));
- }
- function detailinfo(Req $req) {
- $id = $req->id;
- $newapp = new \App\Models\MoneyBuyStr();
- $data = $newapp->getdetailinfo($id);
- return \App\Lib\DataTable\DataTable::init()->toJson($data);
- }
- /**
- *串关注单结算
- */
- public function settlement(Req $req)
- {
- $id = $req->id;
- if (intval($id) < 1) {
- return -1;
- }
- $order = \App\Models\MoneyBuyStr::where('id', $id)->first();
- $order_ids = array($order->order_id);
- //return $order_ids;
- $SettlementOrder = new SettlementOrder();
- $bet_type = 2; //串关注单
- $data = $SettlementOrder->reSettlement($order_ids, $bet_type);
- //dd($SettlementOrder);
- return $data;
- }
- /**
- *串关注单重新结算
- */
- public function resettlement(Req $req) {
- $id = $req->id;
- if (intval($id) < 1) {
- return -1;
- }
- $order = \App\Models\MoneyBuyStr::where('id',$id)->first();
- $order_ids = array($order->order_id);
- //return $order_ids;
- $SettlementOrder = new SettlementOrder();
- $bet_type = 2; //串关注单
- $data = $SettlementOrder->reSettlement($order_ids,$bet_type);
- return $data;
- $m = explode('串',$order->str_type);
- //获取此订单下包含的赛事
- $matchs = \App\Models\MoneyBuyMatch::where('batch_id',$order->batch_id)->where('bet_type',2)->get()->toArray();
- function combination($a, $m) {
- $r = array();
- $n = count($a);
- if ($m <= 0 || $m > $n) {
- return $r;
- }
- for ($i=0; $i<$n; $i++) {
- $t = array($a[$i]);
- if ($m == 1) {
- $r[] = $t;
- } else {
- $b = array_slice($a, $i+1);
- $c = combination($b, $m-1);
- foreach ($c as $v) {
- $r[] = array_merge($t, $v);
- }
- }
- }
- return $r;
- }
- $arr = combination($matchs,$m[0]);
- $win_money = 0;
- for($i=0;$i<count($arr);$i++){
- $money = $order->money/count($arr);
- for($j=0;$j<count($arr[$i]);$j++){
- if($arr[$i][$j]->result == 0){ //未处理
- return "<script>history.go(-1);</script>";
- }else if($arr[$i][$j]->result == -1){ //输
- $win_money = 0;
- $model = new \App\Models\MoneyBuyStr();
- $model = $model::find($id);
- $model->gain_money = $win_money;
- $model->save();
- return "<script>history.go(-1);</script>";
- }else if($arr[$i][$j]->result == 1){ //赢
- $odds = $arr[$i][$j]->odds;
- $money = $money*$odds;
- }else if($arr[$i][$j]->result == 2){ //平
- $money = $money*1;
- }else if($arr[$i][$j]->result == 3){ //赢半平半
- $odds = $arr[$i][$j]->odds;
- $money = $money/2*$odds+$money/2*1;
- }else if($arr[$i][$j]->result == 4){ //输半平半
- $money = $money/2*1;
- }
- }
- //减本金
- // $win_money = $win_money+$money-$order->money/count($arr);
- //不减本金
- $win_money = $win_money+$money;
- }
- $model = new \App\Models\MoneyBuyStr();
- $model = $model::find($id);
- $model->settle_status = 2;
- $model->gain_money = $win_money;
- $model->save();
- return 1;
- }
- /**
- *串关注单批量结算
- */
- public function batchsettlement(){
- $bet_type = 2; //串关注单
- $orders = \App\Models\MoneyBuyStr::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)->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;
- }
- }
- //return $order_id;
- $SettlementOrder = new SettlementOrder();
- $data = $SettlementOrder->reSettlement($order_ids,$bet_type);
- return $data;
- }
- /**
- *删除串关注单
- */
- public function deletel(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\MoneyBuyStr::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') : '';
- $db = new \App\Models\MoneyBuyStr();
- $data = $db->MoneyCount($where);
- return responseToJson($data);
- }
- }
|