Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php namespace app\api\controller; use addons\shopro\model\User as UserModel; use ..

Decoded Output download

<?php 
 
namespace app\api\controller; 
 
use addons\shopro\model\User as UserModel; 
use app\common\controller\Api; 
use app\common\library\Upload; 
use think\Config; 
use think\Db; 
 
/** 
 *  
 */ 
class Index extends Api 
{ 
    protected $noNeedLogin = ['*']; 
    protected $noNeedRight = ['*']; 
 
    /** 
     *  
     * 
     */ 
    public function index() 
    { 
        $this->success(''); 
    } 
    // 
    public function zcglnew() 
    { 
        $post = $this->request->post(); 
        $time = strtotime(date('2023-08-28', time())); //12 
        //  $time = 1689696000; // 
        // $time = time() - 300; //-5 
        $find = db('soccer')->where('ids', 27)->where('time', $time)->find(); 
 
        $getresp = $find['content']; 
 
        $resp = $getresp; 
        $resp = json_decode($resp, true); 
 
        $jclist = $resp['list']['0']['jczq']; // 
        // echo "<pre>"; 
        // print_r($jclist);exit(); 
        $newjc = array(); 
        // 
        foreach ($jclist as $k => &$v) { 
            $newjc[$k] = $v['id']; //ID 
        } 
        // echo "<pre>"; 
        // print_r($jclist);exit(); 
 
        $count2 = db('soccer_zc')->where('jcid', 'in', $newjc)->where('matchId', 'null')->count(); 
 
        //echo $count2;exit(); 
        if ($count2 > 0) { 
            $list2 = db('soccer_zc')->where('jcid', 'in', $newjc)->where('matchId', 'null')->field('id,jcid,matchtime,startTime')->select(); 
 
            $data2 = array(); // 
            foreach ($list2 as $k => &$v) { 
                $v['jckey'] = array_search($v['jcid'], $newjc); //id 
                if ($jclist[$v['jckey']]['matchTime'] == $v['matchtime']) { 
                    // matchId  
                    $data2[$k]['id'] = $v['id']; 
                    $data2[$k]['matchId'] = $jclist[$v['jckey']]['matchId']; 
                    //$data[$k]['startTime'] = $jclist[$v['jckey']]['startTime']; 
                    $data2[$k]['isTurn'] = $jclist[$v['jckey']]['isTurn']; 
                    if ($data2[$k]['isTurn'] == 1) { 
                        // 
                        $data2[$k]['homeId'] = $jclist[$v['jckey']]['awayId']; 
                        $data2[$k]['awayId'] = $jclist[$v['jckey']]['homeId']; 
                    } else { 
                        $data2[$k]['homeId'] = $jclist[$v['jckey']]['homeId']; 
                        $data2[$k]['awayId'] = $jclist[$v['jckey']]['awayId']; 
                    } 
                } 
            } 
            // echo "<pre>"; 
            // print_r($list2);exit(); 
            if (!empty($data2)) { 
                $this->model2 = new \app\common\model\SoccerZc; 
                $up2 = $this->model2->saveall($data2); 
                if ($up2) { 
                    echo '';exit(); 
                } else { 
                    echo "";exit(); 
                } 
            } 
        } else { 
            echo "";exit(); 
        } 
    } 
    // matchId  
    public function zcgl() 
    { 
        $post = $this->request->post(); 
        $time = strtotime(date('Y-m-d', time())); //12 
        //  $time = 1689696000; // 
        // $time = time() - 300; //-5 
        $find = db('soccer')->where('ids', 27)->where('time', $time)->find(); 
        // $find = db('soccer')->where('ids', 56)->where('time', $time)->find(); //5 
        $url = "http://interface.bet007.com/lottery/MatchidInterface.aspx?key=200AB2AB2B444E35"; 
        $getresp = $this->curlGet($url); 
        // print_r($getresp);exit(); 
        if (!empty($find)) { 
            // 
 
            $data['content'] = $getresp; 
            $data['create_time'] = time(); 
            //  $data['id'] = $find['id']; 
            $insert = db('soccer')->where('id', $find['id'])->update($data); 
        } else { 
            // 
 
            $data['content'] = $getresp; 
            $data['create_time'] = time(); 
            $data['ids'] = 27; 
            $data['time'] = $time; 
            $insert = db('soccer')->insert($data); 
        } 
        $resp = $getresp; 
        $resp = json_decode($resp, true); 
        $jclist = $resp['list']['0']['jczq']; // 
 
        $newjc = array(); 
        // 
        foreach ($jclist as $k => &$v) { 
            $newjc[$k] = $v['id']; //ID 
        } 
        // echo "<pre>"; 
        // print_r($jclist);exit(); 
        //idmatchId 
        $count = db('soccer_jc')->where('jcid', 'in', $newjc)->where('matchId', 'null')->count(); 
 
        $count2 = db('soccer_zc')->where('jcid', 'in', $newjc)->where('matchId', 'null')->count(); 
        // echo "<pre>"; 
        // print_R($count2);exit(); 
        if ($count > 0) { 
            // id  
            $list = db('soccer_jc')->where('jcid', 'in', $newjc)->where('matchId', 'null')->field('id,jcid,matchtime,startTime')->select(); 
 
            $data = array(); // 
            foreach ($list as $k => &$v) { 
                $v['jckey'] = array_search($v['jcid'], $newjc); //id 
                if ($jclist[$v['jckey']]['matchTime'] == $v['matchtime']) { 
                    // matchId  
                    $data[$k]['id'] = $v['id']; 
                    $data[$k]['matchId'] = $jclist[$v['jckey']]['matchId']; 
                    //$data[$k]['startTime'] = $jclist[$v['jckey']]['startTime']; 
                    $data[$k]['isTurn'] = $jclist[$v['jckey']]['isTurn']; 
                    if ($data[$k]['isTurn'] == 1) { 
                        // 
                        $data[$k]['homeId'] = $jclist[$v['jckey']]['awayId']; 
                        $data[$k]['awayId'] = $jclist[$v['jckey']]['homeId']; 
                    } else { 
                        $data[$k]['homeId'] = $jclist[$v['jckey']]['homeId']; 
                        $data[$k]['awayId'] = $jclist[$v['jckey']]['awayId']; 
                    } 
                } 
            } 
 
            if (!empty($data)) { 
                // 
                $this->model = new \app\common\model\SoccerJc; 
                $up = $this->model->saveall($data); 
 
                if ($up) { 
                    echo ""; 
                } else { 
                    echo ""; 
                } 
            } 
 
        } else { 
            echo ""; 
        } 
        //echo $count2;exit(); 
        if ($count2 > 0) { 
            $list2 = db('soccer_zc')->where('jcid', 'in', $newjc)->where('matchId', 'null')->field('id,jcid,matchtime,startTime')->select(); 
 
            $data2 = array(); // 
            foreach ($list2 as $k => &$v) { 
                $v['jckey'] = array_search($v['jcid'], $newjc); //id 
                if ($jclist[$v['jckey']]['matchTime'] == $v['matchtime']) { 
                    // matchId  
                    $data2[$k]['id'] = $v['id']; 
                    $data2[$k]['matchId'] = $jclist[$v['jckey']]['matchId']; 
                    //$data[$k]['startTime'] = $jclist[$v['jckey']]['startTime']; 
                    $data2[$k]['isTurn'] = $jclist[$v['jckey']]['isTurn']; 
                    if ($data2[$k]['isTurn'] == 1) { 
                        // 
                        $data2[$k]['homeId'] = $jclist[$v['jckey']]['awayId']; 
                        $data2[$k]['awayId'] = $jclist[$v['jckey']]['homeId']; 
                    } else { 
                        $data2[$k]['homeId'] = $jclist[$v['jckey']]['homeId']; 
                        $data2[$k]['awayId'] = $jclist[$v['jckey']]['awayId']; 
                    } 
                } 
            } 
            // echo "<pre>"; 
            // print_r($list2);exit(); 
            if (!empty($data2)) { 
                $this->model2 = new \app\common\model\SoccerZc; 
                $up2 = $this->model2->saveall($data2); 
                if ($up2) { 
                    echo '';exit(); 
                } else { 
                    echo "";exit(); 
                } 
            } 
        } else { 
            echo "";exit(); 
        } 
 
    } 
    //  5   
    public function get_hmorder() 
    { 
        //id 
        $lists1 = db('cp_order')->where('is_h', 1)->where('status', 6)->where('jztime', 'elt', time())->limit(20)->column('id'); 
        //id  
        $lists2 = db('cp_order')->field('id,user_id,money,orderno')->where('is_h', 1)->where('status', 6)->where('jztime', 'elt', time())->limit(20)->select(); 
 
        if (!empty($lists1)) { 
            $data['status'] = 5; // 
            // echo "<pre>"; 
            // print_r($lists2);exit(); 
            $up1 = db('cp_order')->where('id', 'in', $lists1)->update($data); 
            foreach ($lists2 as $k => $v) { 
                UserModel::money($v['money'], $v['user_id'], '9', '', '' . $v['money'] . '', $v['orderno'], 1); //3     
            } 
            if ($up1) { 
                echo ""; 
            } else { 
                echo ""; 
            } 
        } else { 
            echo ""; 
        } 
 
    } 
    //5 
    public function get_jczqjk() 
    { 
 
        $post = $this->request->post(); 
 
        $time = time() - 300; //-5 
        $find = db('soccer')->where('ids', 56)->where('create_time', 'egt', $time)->order('id desc')->find(); //5 
        if (empty($find)) { 
            //  
            // $resp = ''; 
            // $data['content'] = $resp; 
            // $data['create_time'] = time(); 
            // $data['ids'] = 56; 
            // $insert = db('soccer')->insert($data); 
            $find = db('soccer')->where('ids', 56)->order('id desc')->find(); //  
            $resp = $find['content']; 
        } else { 
            $resp = $find['content']; 
        } 
        // echo "<pre>"; 
        // var_dump($resp);exit(); 
        $resp = json_decode($resp, true); 
 
        $this->success('', $resp, 0); 
    } 
    // 
    public function jclist() 
    { 
        $newlist = db('soccer_jc')->group('time')->order('time desc')->limit(10)->column('id,time'); 
        $list = array(); 
        foreach ($newlist as $k => $v) { 
            $list[$k]['id'] = $k; 
            $list[$k]['time'] = $v; 
 
        } 
        // echo "<pre>"; 
        // print_r($list);exit(); 
        // $list = db('soccer')->where('ids', 53)->field('id,time')->order('time desc')->limit(10)->select(); //10 
        $week_array = array("", "", "", "", "", "", ""); 
        foreach ($list as $k => &$v) { 
 
            $v['newtime'] = date('Y-m-d', $v['time']); 
 
            $week = date("w", $v['time']); 
            $v['date'] = '' . $week_array[$week]; 
            // $v['num1'] = db('soccer')->where('time', $v['time'])->where('') 
            $v['num1'] = db('soccer_jc')->where('time', $v['time'])->where('spfsge', 'spf3')->count(); // 
            $v['num2'] = db('soccer_jc')->where('time', $v['time'])->where('spfsge', 'spf1')->count(); // 
            $v['num3'] = db('soccer_jc')->where('time', $v['time'])->where('spfsge', 'spf0')->count(); // 
 
            $v['bisainum'] = db('soccer_jc')->where('time', $v['time'])->where('state', '-1')->count(); // 
 
        } 
        $this->success('', $list, 0); 
 
    } 
    // 
    public function testjgnew() 
    { 
        $time = strtotime(date('Y-m-d', time())); // 
 
        $url = "http://interface.bet007.com/lottery/Zq_BF.aspx?key=200AB2AB2B444E35"; 
        // &&cmd=result 
        $getresp = $this->curlGet($url); 
 
        $getresp = json_decode($getresp, true); 
        $data = $getresp['matchList']; // 
        // echo "<pre>"; 
        // print_r($data);exit(); 
        $this->model = new \app\common\model\SoccerZc; 
 
        $newarr = array(); // 
        foreach ($data as $k => $v) { 
            $newarr[$k] = $v['matchId']; //mactchid 
        } 
        // echo "<pre>"; 
        // print_r($newarr);exit(); 
        $where['matchId'] = ['in', $newarr]; 
        // $where['time'] = ['eq', $time]; // 814  
        $check = db('soccer_zc')->where($where)->where('state', 'neq', '-1')->count(); //  
        $list = db('soccer_zc')->where($where)->where('state', 'neq', '-1')->select(); 
        $check2 = db('soccer_zc')->where($where)->where('state', 'neq', '-1')->count(); //  
        $list2 = db('soccer_zc')->where($where)->where('state', 'neq', '-1')->select(); 
        // echo "<pre>"; 
        // print_r($list);exit(); 
        // echo $check;exit(); 
        $newdata = array(); 
        if ($check > 0) { 
            //  
            $sl = db('soccer_zc')->where($where)->where('state', 'neq', '-1')->column('id, matchId'); //  
            // echo "<pre>"; 
            // print_r($sl);exit(); 
            $goal = db('soccer_zc')->where($where)->where('state', 'neq', '-1')->column('id, rqspf'); // 
            $bf = db('soccer_zc')->where($where)->where('state', 'neq', '-1')->column('id, bf'); // 
            $spf = db('soccer_zc')->where($where)->where('state', 'neq', '-1')->column('id, spf'); // 
 
            $rqspf = db('soccer_zc')->where($where)->where('state', 'neq', '-1')->column('id, rqspf'); // 
            //$bqc = db('soccer_zc')->where($where)->where('state', 'neq', '-1')->column('id, bqc'); // 
            // echo "<pre>"; 
            // print_r($bqc);exit(); 
            $jq = db('soccer_zc')->where($where)->where('state', 'neq', '-1')->column('id, jq'); // 
            $is_turn = db('soccer_zc')->where($where)->where('state', 'neq', '-1')->column('id, isTurn'); // 
            foreach ($goal as $k => &$v) { 
                parse_str($v, $newgoal); 
                $v = $newgoal['goal']; 
            } 
            foreach ($bf as $k => &$v) { 
                parse_str($v, $newgoal); 
                $v = $newgoal; 
            } 
            foreach ($rqspf as $k => &$v) { 
                parse_str($v, $newgoal); 
                $v = $newgoal; 
            } 
            // foreach ($bqc as $k => &$v) { 
            //     parse_str($v, $newgoal); 
            //     $v = $newgoal; 
            // } 
            foreach ($jq as $k => &$v) { 
                parse_str($v, $newgoal); 
                $v = $newgoal; 
            } 
            foreach ($spf as $k => &$v) { 
                parse_str($v, $newgoal); 
                $v = $newgoal; 
            } 
 
            // echo "<pre>"; 
            // print_r($sl);exit(); 
            foreach ($data as $k => &$v) { 
                $v['searchkey'] = array_search($v['matchId'], $sl); // 
 
                if (!empty($v['searchkey']) || $v['searchkey'] === 0) { 
                    // echo $v['searchkey'];exit(); 
                    // 
                    if ($v['state'] == '-1') { 
                        //  
 
                        $newdata[$k]['id'] = $v['searchkey']; //id 
                        $newdata[$k]['leagueId'] = $v['leagueId']; //id 
                        $newdata[$k]['state'] = $v['state']; 
                        $newdata[$k]['startTime'] = $v['startTime']; 
                        if ($is_turn[$v['searchkey']] == 1) { 
                            // 
                            $newdata[$k]['homeScore'] = $v['awayScore']; // 
                            $newdata[$k]['awayScore'] = $v['homeScore']; // 
                            $newdata[$k]['homeHalfScore'] = $v['awayHalfScore']; // 
                            $newdata[$k]['awayHalfScore'] = $v['homeHalfScore']; // 
                            $newdata[$k]['homeRed'] = $v['awayRed']; // 
                            $newdata[$k]['homeYellow'] = $v['awayYellow']; // 
                            $newdata[$k]['awayRed'] = $v['homeRed']; // 
                            $newdata[$k]['awayYellow'] = $v['homeYellow']; // 
                            $newdata[$k]['homeCorner'] = $v['awayCorner']; // 
                            $newdata[$k]['awayCorner'] = $v['homeCorner']; // 
                            $newdata[$k]['homeRank'] = $v['awayRank']; // 
                            $newdata[$k]['awayRank'] = $v['homeRank']; // 
                        } else { 
                            $newdata[$k]['homeScore'] = $v['homeScore']; // 
                            $newdata[$k]['awayScore'] = $v['awayScore']; // 
                            $newdata[$k]['homeHalfScore'] = $v['homeHalfScore']; // 
                            $newdata[$k]['awayHalfScore'] = $v['awayHalfScore']; // 
                            $newdata[$k]['homeRed'] = $v['homeRed']; // 
                            $newdata[$k]['homeYellow'] = $v['homeYellow']; // 
                            $newdata[$k]['awayRed'] = $v['awayRed']; // 
                            $newdata[$k]['awayYellow'] = $v['awayYellow']; // 
                            $newdata[$k]['homeCorner'] = $v['homeCorner']; // 
                            $newdata[$k]['awayCorner'] = $v['awayCorner']; // 
                            $newdata[$k]['homeRank'] = $v['homeRank']; // 
                            $newdata[$k]['awayRank'] = $v['awayRank']; // 
                        } 
 
                        $newdata[$k]['isNeutral'] = $v['isNeutral']; // 
                        $newdata[$k]['hasLineup'] = $v['hasLineup']; // 
                        $newdata[$k]['explain'] = $v['explain']; // 
                        $newdata[$k]['extraExplain'] = $v['extraExplain']; //2 
                        if ($is_turn[$v['searchkey']] == 1) { 
                            //// 
                            $v['sg'] = $this->getcg($v['awayScore'], $v['homeScore'], $v['awayHalfScore'], $v['homeHalfScore'], $goal[$v['searchkey']]); 
                        } else { 
                            $v['sg'] = $this->getcg($v['homeScore'], $v['awayScore'], $v['homeHalfScore'], $v['awayHalfScore'], $goal[$v['searchkey']]); 
                        } 
                        // 
                        // if ($v['sg']['bfcg'] == 'sl5') { 
 
                        //     echo "<pre>"; 
                        //     print_r($v['sg']);exit(); 
                        // } 
                        // echo "<pre>"; 
                        // print_r($v['sg']); 
                        $newdata[$k]['bfsg'] = $v['sg']['bf']; // 
                        $newdata[$k]['rq'] = $goal[$v['searchkey']]; // 
                        $newdata[$k]['bfpl'] = $bf[$v['searchkey']][$v['sg']['bfcg']]; // 
                        $newdata[$k]['rqspfsg'] = $v['sg']['rqspf']; // 
                        $newdata[$k]['rqspfpl'] = $rqspf[$v['searchkey']][$v['sg']['rqspfcg']]; // 
                        $newdata[$k]['zjq'] = $v['sg']['jq']; // 
                        $newdata[$k]['zjqpl'] = $jq[$v['searchkey']][$v['sg']['jqcg']]; // 
                        $newdata[$k]['bqcsg'] = $v['sg']['bqc']; // 
                        //$newdata[$k]['bqcpl'] = $bqc[$v['searchkey']][$v['sg']['bqccg']]; // 
 
                        $newdata[$k]['bbfsg'] = $v['homeHalfScore'] . ':' . $v['awayHalfScore']; //  
                        $newdata[$k]['spfsg'] = $v['sg']['spftext']; // 
                        if (isset($spf[$v['searchkey']][$v['sg']['spfcg']])) { 
                            $newdata[$k]['spfpl'] = $spf[$v['searchkey']][$v['sg']['spfcg']]; // 
                        } 
 
                        $newdata[$k]['spfsge'] = $v['sg']['spfcg']; // 
                        $newdata[$k]['rqspfsge'] = $v['sg']['rqspfcg']; // 
                        $newdata[$k]['bfsge'] = $v['sg']['bfcg']; // 
                        $newdata[$k]['zjqsge'] = $v['sg']['jqcg']; // 
                        $newdata[$k]['bqcsge'] = $v['sg']['bqccg']; // 
                        // if ($v['matchId'] == 2337322) { 
                        //     print_r($newdata[$k]);exit(); 
 
                        // } 
                    } else { 
                        // 
                        if ($v['state'] != 0) { 
                            //   
                            $newdata[$k]['id'] = $v['searchkey']; //id 
                            $newdata[$k]['leagueId'] = $v['leagueId']; //id 
                            $newdata[$k]['state'] = $v['state']; 
                            $newdata[$k]['startTime'] = $v['startTime']; 
                            $newdata[$k]['bbfsg'] = $v['homeHalfScore'] . ':' . $v['awayHalfScore']; //  
                            if ($is_turn[$v['searchkey']] == 1) { 
                                // 
                                $newdata[$k]['homeScore'] = $v['awayScore']; // 
                                $newdata[$k]['awayScore'] = $v['homeScore']; // 
                                $newdata[$k]['homeHalfScore'] = $v['awayHalfScore']; // 
                                $newdata[$k]['awayHalfScore'] = $v['homeHalfScore']; // 
                                $newdata[$k]['homeRed'] = $v['awayRed']; // 
                                $newdata[$k]['homeYellow'] = $v['awayYellow']; // 
                                $newdata[$k]['awayRed'] = $v['homeRed']; // 
                                $newdata[$k]['awayYellow'] = $v['homeYellow']; // 
                                $newdata[$k]['homeCorner'] = $v['awayCorner']; // 
                                $newdata[$k]['awayCorner'] = $v['homeCorner']; // 
                                $newdata[$k]['homeRank'] = $v['awayRank']; // 
                                $newdata[$k]['awayRank'] = $v['homeRank']; // 
                            } else { 
                                $newdata[$k]['homeScore'] = $v['homeScore']; // 
                                $newdata[$k]['awayScore'] = $v['awayScore']; // 
                                $newdata[$k]['homeHalfScore'] = $v['homeHalfScore']; // 
                                $newdata[$k]['awayHalfScore'] = $v['awayHalfScore']; // 
                                $newdata[$k]['homeRed'] = $v['homeRed']; // 
                                $newdata[$k]['homeYellow'] = $v['homeYellow']; // 
                                $newdata[$k]['awayRed'] = $v['awayRed']; // 
                                $newdata[$k]['awayYellow'] = $v['awayYellow']; // 
                                $newdata[$k]['homeCorner'] = $v['homeCorner']; // 
                                $newdata[$k]['awayCorner'] = $v['awayCorner']; // 
                                $newdata[$k]['homeRank'] = $v['homeRank']; // 
                                $newdata[$k]['awayRank'] = $v['awayRank']; // 
                            } 
 
                            $newdata[$k]['isNeutral'] = $v['isNeutral']; // 
                            $newdata[$k]['hasLineup'] = $v['hasLineup']; // 
                            $newdata[$k]['explain'] = $v['explain']; // 
                            $newdata[$k]['extraExplain'] = $v['extraExplain']; //2 
                        } 
                    } 
                } 
            } 
            // echo "<pre>"; 
            // print_r($data);exit(); 
            if (!empty($newdata)) { 
                $insert = $this->model->saveall($newdata); 
 
                if ($insert) { 
                    echo "";exit(); 
                } else { 
                    echo "";exit(); 
                } 
            } else { 
                echo "";exit(); 
            } 
 
        } 
    } 
 
    //  
    public function bfjc() 
    { 
        $post = $this->request->post(); 
        $time = strtotime($post['time']); 
        $time3 = $time + 86400; // 
        $time = date('Y-m-d 11:00:00', $time); 
        //$time = date('Y-m-d', $time); 
        $time3 = date('Y-m-d H:i:s', $time3); 
        $time2 = strtotime($post['time']); 
        //826  
        //913 where('time', $time2)-> 
        $ids = db('soccer_jc')->where('jctime', 'egt', $time)->where('jctime', 'lt', $time3)->column('matchId', 'id'); 
        //echo db('soccer_jc')->getlastsql();exit(); 
        // echo "<pre>"; 
        //  print_r($ids);exit(); 
        //$ids = db('soccer_zc')->order('state desc')->where('bstime', $time)->column('id', 'jcid'); 
        $newarr = array(); 
        foreach ($ids as $k => &$v) { 
 
            $newarr[] = $v; 
 
        } 
        $list = db('soccer_zc')->field('matchtime,jcid,league,home,away,state,spf,rqspf,bfsg,bbfsg,matchId,homeScore,awayScore,isTurn,homeId,awayId,startTime')->order('state desc')->order('matchtime asc')->where('matchId', 'in', $newarr)->select(); // 
        foreach ($list as $k => &$v) { 
 
            $v['newrqspf'] = ''; 
            parse_str($v['rqspf'], $v['newrqspf']); // 
            unset($v['rqspf']); 
            $v['newspf'] = ''; 
            parse_str($v['spf'], $v['newspf']); // 
            unset($v['spf']); 
            // 
            $find = db('soccer_tj')->where('matchId', $v['matchId'])->find(); 
            if (!empty($find)) { 
                $v['eventList'] = $find['eventList']; // 
                $v['technic'] = $find['technic']; // 
                $v['penalty'] = $find['penalty']; // 
            } else { 
                $v['eventList'] = ''; 
                $v['technic'] = ''; 
                $v['penalty'] = ''; 
            } 
 
            if (!empty($v['eventList'])) { 
                $v['eventList'] = json_decode($v['eventList'], true); 
 
            } 
            if (!empty($v['penalty'])) { 
 
                $v['penalty'] = json_decode($v['penalty'], true); 
            } 
            if ($v['isTurn'] == 1) { 
                // 
                $v['bf'] = $v['awayScore'] . ':' . $v['homeScore']; 
            } else { 
                $v['bf'] = $v['homeScore'] . ':' . $v['awayScore']; 
            } 
 
            if (!empty($v['homeId'])) { 
                $homelogo = db('soccer_zl')->where('teamId', $v['homeId'])->find(); // 
                if (!empty($homelogo['logo'])) { 
                    if (!empty($homelogo['logolink'])) { 
                        $v['homelogo'] = $homelogo['logolink']; //logo 
                    } else { 
                        $v['homelogo'] = $this->getimg($homelogo['logo'], $homelogo['teamId']); // 
                        if ($v['homelogo'] != 0) { 
                            // 
                            $v['homelogo'] = $this->request->domain() . '/static/logo/' . $homelogo['teamId'] . '.png'; 
                            $data['logolink'] = $v['homelogo']; 
                            $up = db('soccer_zl')->where('id', $homelogo['id'])->update($data); 
                        } else { 
                            $v['homelogo'] = ''; 
                        } 
                    } 
                } else { 
                    $v['homelogo'] = ''; //logo 
                } 
            } else { 
                $v['homelogo'] = ''; //logo 
            } 
            if (!empty($v['awayId'])) { 
                $awaylogo = db('soccer_zl')->where('teamId', $v['awayId'])->find(); // 
 
                if (!empty($awaylogo['logo'])) { 
                    if (!empty($awaylogo['logolink'])) { 
                        $v['awaylogo'] = $awaylogo['logolink']; //logo 
                    } else { 
                        //echo $awaylogo['teamId'];exit(); 
                        $v['awaylogo'] = $this->getimg($awaylogo['logo'], $awaylogo['teamId']); // 
                        if ($v['awaylogo'] != 0) { 
                            // 
                            //echo $this->request->domain() . '/static/logo/' . $awaylogo['teamId'] . '.png';exit(); 
                            $v['awaylogo'] = $this->request->domain() . '/static/logo/' . $awaylogo['teamId'] . '.png'; 
                            $data['logolink'] = $v['awaylogo']; 
                            $up = db('soccer_zl')->where('id', $awaylogo['id'])->update($data); 
                        } else { 
                            $v['awaylogo'] = ''; 
                        } 
                    } 
                } else { 
                    $v['awaylogo'] = ''; //logo 
                } 
            } else { 
                $v['awaylogo'] = ''; //logo 
            } 
 
        } 
        //$list = array_unique($list); 
        $this->success('', $list, 0); 
    } 
    //  
    public function bfbd() 
    { 
        $post = $this->request->post(); 
        $time = strtotime($post['time']); 
        $ids = db('soccer_bd')->order('state desc')->where('jctime2', $time)->column('id', 'jcid'); 
        $newarr = array(); 
        foreach ($ids as $k => &$v) { 
 
            $newarr[] = $v; 
 
        } 
        $list = db('soccer_bd')->field('matchtime,jcid,league,home,away,state,spf,bfsg,bbfsg,matchId,homeScore,awayScore,isTurn,homeId,awayId,startTime')->order('jcid asc')->where('id', 'in', $newarr)->select(); // 
        foreach ($list as $k => &$v) { 
 
            // $v['newrqspf'] = ''; 
            // parse_str($v['rqspf'], $v['newrqspf']); // 
            // unset($v['rqspf']); 
            // $v['newspf'] = ''; 
            // parse_str($v['spf'], $v['newspf']); // 
            // unset($v['spf']); 
 
            $find = db('soccer_tj')->where('matchId', $v['matchId'])->find(); 
            if (!empty($find)) { 
                $v['eventList'] = $find['eventList']; // 
                $v['technic'] = $find['technic']; // 
                $v['penalty'] = $find['penalty']; // 
            } else { 
                $v['eventList'] = ''; 
                $v['technic'] = ''; 
                $v['penalty'] = ''; 
            } 
            if (!empty($v['eventList'])) { 
                $v['eventList'] = json_decode($v['eventList'], true); 
 
            } 
            if (!empty($v['penalty'])) { 
 
                $v['penalty'] = json_decode($v['penalty'], true); 
            } 
            if ($v['isTurn'] == 1) { 
                // 
                $v['bf'] = $v['awayScore'] . ':' . $v['homeScore']; 
            } else { 
                $v['bf'] = $v['homeScore'] . ':' . $v['awayScore']; 
            } 
 
            if (!empty($v['homeId'])) { 
                $homelogo = db('soccer_zl')->where('teamId', $v['homeId'])->find(); // 
                if (!empty($homelogo['logo'])) { 
                    if (!empty($homelogo['logolink'])) { 
                        $v['homelogo'] = $homelogo['logolink']; //logo 
                    } else { 
                        $v['homelogo'] = $this->getimg($homelogo['logo'], $homelogo['teamId']); // 
                        if ($v['homelogo'] != 0) { 
                            // 
                            $v['homelogo'] = $this->request->domain() . '/static/logo/' . $homelogo['teamId'] . '.png'; 
                            $data['logolink'] = $v['homelogo']; 
                            $up = db('soccer_zl')->where('id', $homelogo['id'])->update($data); 
                        } else { 
                            $v['homelogo'] = ''; 
                        } 
                    } 
                } else { 
                    $v['homelogo'] = ''; //logo 
                } 
            } else { 
                $v['homelogo'] = ''; //logo 
            } 
            if (!empty($v['awayId'])) { 
                $awaylogo = db('soccer_zl')->where('teamId', $v['awayId'])->find(); // 
 
                if (!empty($awaylogo['logo'])) { 
                    if (!empty($awaylogo['logolink'])) { 
                        $v['awaylogo'] = $awaylogo['logolink']; //logo 
                    } else { 
                        //echo $awaylogo['teamId'];exit(); 
                        $v['awaylogo'] = $this->getimg($awaylogo['logo'], $awaylogo['teamId']); // 
                        if ($v['awaylogo'] != 0) { 
                            // 
                            //echo $this->request->domain() . '/static/logo/' . $awaylogo['teamId'] . '.png';exit(); 
                            $v['awaylogo'] = $this->request->domain() . '/static/logo/' . $awaylogo['teamId'] . '.png'; 
                            $data['logolink'] = $v['awaylogo']; 
                            $up = db('soccer_zl')->where('id', $awaylogo['id'])->update($data); 
                        } else { 
                            $v['awaylogo'] = ''; 
                        } 
                    } 
                } else { 
                    $v['awaylogo'] = ''; //logo 
                } 
            } else { 
                $v['awaylogo'] = ''; //logo 
            } 
 
        } 
        //$list = array_unique($list); 
        $this->success('', $list, 0); 
    } 
 
    // 
    public function getimg($logo, $name) 
    { 
        $logo = $logo . '?win007=sell'; //logo  
        if (!empty($name)) { 
            $name = './static/logo/' . $name . '.png'; 
            $ch = curl_init(); 
            $fp = fopen($name, 'w'); 
            curl_setopt($ch, CURLOPT_URL, $logo); 
            curl_setopt($ch, CURLOPT_FAILONERROR, true); 
            curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); 
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
            curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 100); 
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 
            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); 
            curl_setopt($ch, CURLOPT_FILE, $fp); 
            $output = curl_exec($ch); 
            $info = curl_getinfo($ch); 
            $error = curl_error($ch); 
            fclose($fp); 
            $size = filesize($name); 
 
            curl_close($ch); 
            if ($size != $info['size_download']) { 
                // echo ""; 
                // echo $error; 
                return 0; 
            } else { 
                //echo ""; 
                return 1; 
            } 
        } else { 
            return 0; 
        } 
 
    } 
 
    // 
    public function newkjzb() 
    { 
        $post = $this->request->post(); 
        if ($post['type'] == 1) { 
            // 
            $where['type'] = ['eq', 1]; 
        } else { 
            $where['type'] = ['eq', 2]; 
        } 
        $data['list'] = db('kjzb')->where($where)->order('kjtime asc')->select(); 
        foreach ($data['list'] as $k => &$v) { 
            $v['icon'] = cdnurl($v['icon'], true); 
        } 
        $cle = strtotime($data['list'][0]['kjtime']) - time(); 
 
        $data['h'] = floor(($cle % (3600 * 24)) / 3600); //% 
        $data['m'] = floor(($cle % (3600 * 24)) % 3600 / 60); 
        $data['s'] = floor(($cle % (3600 * 24)) % 60); 
        //echo $h . $m . $s;exit(); 
        $this->success('', $data, 0); 
    } 
    //  
    public function bfzc() 
    { 
        $post = $this->request->post(); 
        $time = strtotime($post['time']); 
 
        $list = db('soccer_zc')->field('matchtime,jcid,league,home,away,state,bfsg')->order('id desc')->where('time', $time)->select(); // 
 
        $this->success('', $list, 0); 
    } 
 
    public function curlGet($url) 
    { 
        $ch = curl_init(); 
        curl_setopt($ch, CURLOPT_URL, $url); 
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
        curl_setopt($ch, CURLOPT_HEADER, 0); 
        curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.172 Safari/537.22"); 
        curl_setopt($ch, CURLOPT_ENCODING, 'gzip'); //gzip 
        $output = curl_exec($ch); 
        $info = curl_getinfo($ch); 
        curl_close($ch); 
        return $output; 
    } 
    //logo 
    public function check_imglink() 
    { 
        $where['logolink'] = ['like', '%' . 'http://cp.1122334455.cn/' . '%']; 
        $count = db('soccer_zl')->field('id,logolink')->where($where)->count(); 
        //  echo $count;exit(); 
        if ($count == 0) { 
            echo "logo";exit(); 
        } 
        $list = db('soccer_zl')->where($where)->column('id'); 
        $data['logolink'] = ''; 
        $up = db('soccer_zl')->where('id', 'in', $list)->update($data); 
        if ($up) { 
            echo ""; 
        } else { 
            echo ""; 
        } 
        echo "<pre>"; 
        print_r($list);exit(); 
    } 
    public function testaddimg() 
    { 
        $homelogo = db('soccer_zl')->where('id', 3)->find(); // 
        if (!empty($homelogo['logo'])) { 
            if (!empty($homelogo['logolink'])) { 
                $list['homelogo'] = $homelogo['logolink']; //logo 
            } else { 
                $list['homelogo'] = $this->getimg($homelogo['logo'], $homelogo['teamId']); // 
                if ($list['homelogo'] != 0) { 
                    // 
                    $list['homelogo'] = $this->request->domain() . '/static/logo/' . $homelogo['teamId'] . '.png'; 
                    $data['logolink'] = $list['homelogo']; 
                    $up = db('soccer_zl')->where('id', $homelogo['id'])->update($data); 
                } else { 
                    $list['homelogo'] = ''; 
                } 
            } 
        } 
    } 
 
    // 
    public function get_jczq() 
    { 
 
        $post = $this->request->post(); 
        $time = strtotime(date('Y-m-d', time())); //12 
 
        // $time = time() - 300; //-5 
 
        $find = db('soccer')->where('ids', 56)->where('time', $time)->find(); //5 
        $url = "http://interface.bet007.com/lottery/JczqOdds.aspx?key=200AB2AB2B444E35"; 
        $getresp = $this->curlGet($url); 
 
        //print_r($getresp);exit(); 
        if (!empty($find)) { 
            // 
 
            $data['content'] = $getresp; 
            $data['create_time'] = time(); 
            //  $data['id'] = $find['id']; 
            $insert = db('soccer')->where('id', $find['id'])->update($data); 
        } else { 
            // 
 
            $data['content'] = $getresp; 
            $data['create_time'] = time(); 
            $data['ids'] = 56; 
            $data['time'] = $time; 
            $insert = db('soccer')->insert($data); 
        } 
        if ($insert) { 
            echo "";exit(); 
        } else { 
            echo "";exit(); 
        } 
        // $resp = json_decode($resp, true); 
 
        // $this->success('', $resp, 0); 
    } 
 
    // 
    public function get_bjdcsj() 
    { 
        $time = strtotime(date('Y-m-d', time())); // 
        //  
        $getresp = db('soccer')->where('ids', 53)->field('id,content,time')->where('time', $time)->find(); //  
        if (!empty($getresp)) { 
            $getresp = json_decode($getresp['content'], true); 
            $data = $getresp['matchList']; // 
            // echo "<pre>"; 
            // print_r($data);exit; 
 
            $this->model = new \app\common\model\SoccerBd; 
 
            $newarr = array(); // 
            foreach ($data as $k => $v) { 
                $newarr[$k] = $v['matchId']; //mactchid 
            } 
            $where['matchId'] = ['in', $newarr]; 
            $check = db('soccer_bd')->where($where)->where('state', 'neq', '-1')->count(); //  
            $newdata = array(); 
            if ($check > 0) { 
                $sl = db('soccer_bd')->where($where)->where('state', 'neq', '-1')->column('id, matchId'); //  
                $is_turn = db('soccer_bd')->where($where)->where('state', 'neq', '-1')->column('id, isTurn'); // 
                foreach ($data as $k => &$v) { 
                    $v['searchkey'] = array_search($v['matchId'], $sl); // 
 
                    if (!empty($v['searchkey']) || $v['searchkey'] === 0) { 
                        // echo $v['searchkey'];exit(); 
                        // 
 
                        // 
 
                        $newdata[$k]['id'] = $v['searchkey']; //id 
                        $newdata[$k]['state'] = $v['state']; 
                        $newdata[$k]['startTime'] = $v['startTime']; 
                        $newdata[$k]['bbfsg'] = $v['homeHalfScore'] . ':' . $v['awayHalfScore']; //  
                        if ($is_turn[$v['searchkey']] == 1) { 
                            // 
                            $newdata[$k]['homeScore'] = $v['awayScore']; // 
                            $newdata[$k]['awayScore'] = $v['homeScore']; // 
                            $newdata[$k]['homeRed'] = $v['awayRed']; // 
                            $newdata[$k]['homeYellow'] = $v['awayYellow']; // 
                            $newdata[$k]['awayRed'] = $v['homeRed']; // 
                            $newdata[$k]['awayYellow'] = $v['homeYellow']; // 
                            $newdata[$k]['homeCorner'] = $v['awayCorner']; // 
                            $newdata[$k]['awayCorner'] = $v['homeCorner']; // 
                            $newdata[$k]['homeRank'] = $v['awayRank']; // 
                            $newdata[$k]['awayRank'] = $v['homeRank']; // 
                        } else { 
                            $newdata[$k]['homeScore'] = $v['homeScore']; // 
                            $newdata[$k]['awayScore'] = $v['awayScore']; // 
                            $newdata[$k]['homeRed'] = $v['homeRed']; // 
                            $newdata[$k]['homeYellow'] = $v['homeYellow']; // 
                            $newdata[$k]['awayRed'] = $v['awayRed']; // 
                            $newdata[$k]['awayYellow'] = $v['awayYellow']; // 
                            $newdata[$k]['homeCorner'] = $v['homeCorner']; // 
                            $newdata[$k]['awayCorner'] = $v['awayCorner']; // 
                            $newdata[$k]['homeRank'] = $v['homeRank']; // 
                            $newdata[$k]['awayRank'] = $v['awayRank']; // 
                        } 
 
                        $newdata[$k]['isNeutral'] = $v['isNeutral']; // 
                        $newdata[$k]['hasLineup'] = $v['hasLineup']; // 
                        $newdata[$k]['explain'] = $v['explain']; // 
                        $newdata[$k]['extraExplain'] = $v['extraExplain']; //2 
 
                    } 
                } 
                if (!empty($newdata)) { 
                    $insert = $this->model->saveall($newdata); 
 
                    if ($insert) { 
                        echo "";exit(); 
                    } else { 
                        echo "";exit(); 
                    } 
                } else { 
                    echo "";exit(); 
                } 
                // echo "<pre>"; 
                // print_r($newdata);exit(); 
            } 
        } 
    } 
    // //jctime2 
    public function addendumbd() 
    { 
        $ids = db('soccer_bd')->field('id,jctime')->where('jctime2', 'null')->select(); 
        if (!empty($ids)) { 
            foreach ($ids as $k => $v) { 
                $data[$k]['id'] = $v['id']; 
                $data[$k]['jctime2'] = strtotime(date('Y-m-d', strtotime($v['jctime']))); // 
            } 
            $this->model = new \app\common\model\SoccerBd; 
            $insert = $this->model->saveall($data); 
 
            if ($insert) { 
                echo "";exit(); 
            } else { 
                echo "";exit(); 
            } 
        } else { 
            echo "";exit(); 
        } 
        echo "<pre>"; 
        print_r($ids); 
    } 
 
    public function getsg($sg, $type) 
    { 
 
        switch ($type) { 
            case '1': 
                $list['-'] = 'ht33'; 
                $list['-'] = 'ht31'; 
                $list['-'] = 'ht30'; 
                $list['-'] = 'ht13'; 
                $list['-'] = 'ht11'; 
                $list['-'] = 'ht10'; 
                $list['-'] = 'ht03'; 
                $list['-'] = 'ht01'; 
                $list['-'] = 'ht00'; 
                break; 
            case '2': 
                $list[''] = 'sf3'; 
                $list[''] = 'sf1'; 
                $list[''] = 'sf0'; 
 
                break; 
            case '3': 
                $list[''] = 'ds11'; 
                $list[''] = 'ds10'; 
                $list[''] = 'ds01'; 
                $list[''] = 'ds00'; 
 
                break; 
            case '4': 
                $list[''] = 'sf3'; // 
                $list[''] = 'sf0'; // 
 
                break; 
            case '5': 
                $list['0'] = 't0'; 
                $list['1'] = 't1'; 
                $list['2'] = 't2'; 
                $list['3'] = 't3'; 
                $list['4'] = 't4'; 
                $list['5'] = 't5'; 
                $list['6'] = 't6'; 
                $list['7'] = 't7'; 
                break; 
            default: 
                # code... 
                break; 
        } 
        if ($type == 5) { 
            if ($sg > 7) { 
                $list = 't7'; 
                return $list; 
            } else { 
                return $list[$sg]; 
            } 
        } else { 
            return $list[$sg]; 
        } 
 
    } 
 
    // 
    public function month_del() 
    { 
        $time = strtotime(date('Y-m-d', time())) - 86400 * 30; 
 
        $count = db('soccer_tj')->where('time', 'elt', $time)->count(); 
        $count1 = db('soccer_jc')->where('time', 'elt', $time)->count(); 
        $count2 = db('soccer_bd')->where('time', 'elt', $time)->count(); 
        $count3 = db('soccer_zc')->where('time', 'elt', $time)->count(); 
        $count4 = db('soccer_bdall')->where('time', 'elt', $time)->count(); 
        if ($count > 0) { 
            $del = db('soccer_tj')->where('time', 'elt', $time)->delete(); 
            if ($del) { 
                echo "1"; 
            } else { 
                echo "1"; 
            } 
        } else { 
            echo "1"; 
        } 
        if ($count1 > 0) { 
            $del = db('soccer_jc')->where('time', 'elt', $time)->delete(); 
            if ($del) { 
                echo ""; 
            } else { 
                echo ""; 
            } 
        } else { 
            echo ""; 
        } 
        if ($count2 > 0) { 
            $del = db('soccer_bd')->where('time', 'elt', $time)->delete(); 
            if ($del) { 
                echo ""; 
            } else { 
                echo ""; 
            } 
        } else { 
            echo ""; 
        } 
        if ($count3 > 0) { 
            $del = db('soccer_zc')->where('time', 'elt', $time)->delete(); 
            if ($del) { 
                echo ""; 
            } else { 
                echo ""; 
            } 
        } else { 
            echo ""; 
        } 
        if ($count4 > 0) { 
            $del = db('soccer_all')->where('time', 'elt', $time)->delete(); 
            if ($del) { 
                echo ""; 
            } else { 
                echo ""; 
            } 
        } else { 
            echo ""; 
        } 
    } 
 
    // 
    public function get_bssj() 
    { 
 
        $post = $this->request->post(); 
        $time = strtotime(date('Y-m-d', time())); //12 
 
        // $time = strtotime('2023-07-29'); //&&date=2023-07-29 
 
        $url = "http://interface.bet007.com/football/detail.aspx?key=200AB2AB2B444E35"; 
        $getresp = $this->curlGet($url); 
        $getresp2 = json_decode($getresp, true); 
 
        $eventList = $getresp2['eventList']; // 
        // echo "<pre>"; 
        // print_r($getresp2);exit(); 
        $technic = $getresp2['technic']; // 
 
        $penalty = $getresp2['penalty']; // 
        $count = db('soccer_tj')->where('time', $time)->count(); 
        if ($count > 0) { 
 
            $del = db('soccer_tj')->where('time', $time)->delete(); 
        } 
        $data = array(); 
        $data2 = array(); 
        foreach ($eventList as $k => $v) { 
            $data[$k]['matchId'] = $v['matchId']; 
            $data[$k]['eventList'] = json_encode($v['event']); 
            $data[$k]['time'] = $time; 
            $data[$k]['technic'] = ''; 
            $data[$k]['penalty'] = ''; 
            $data[$k]['createtime'] = time(); 
            $data2[$k] = $v['matchId']; 
        } 
        foreach ($technic as $k => $v) { 
            $v['check'] = array_search($v['matchId'], $data2); 
            if (!empty($v['check']) || $v['check'] === 0) { 
                // 
                $data[$v['check']]['technic'] = $v['technicCount']; 
            } 
 
        } 
        foreach ($penalty as $k => $v) { 
            $v['check'] = array_search($v['matchId'], $data2); 
            if (!empty($v['check']) || $v['check'] === 0) { 
                // 
                $data[$v['check']]['penalty'] = json_encode($v['event']); 
            } 
 
        } 
        // echo "<pre>"; 
        // print_r($data);exit(); 
        $insert = db('soccer_tj')->insertall($data); 
        if ($insert) { 
            echo ""; 
        } else { 
            echo ""; 
        } 
 
    } 
    //  // $v['newrqspf'] = parse_str($v['rqspf'], $new);  
    // 
    public function testjc() 
    { 
        $time = strtotime(date('Y-m-d', time())); // 
        $pl = db('soccer')->where('ids', 56)->field('id,content,time')->order('time desc')->find(); //  
        // $time = strtotime('2023-08-28'); // // 
 
        // $pl = db('soccer')->where('ids', 56)->field('id,content,time')->where('time', $time)->find(); // 
        // echo "<pre>"; 
        // print_r($pl) 
        $pl['resp'] = json_decode($pl['content'], true); 
        $bisai = $pl['resp']['list']; // 
        if (empty($bisai)) { 
            echo '';exit(); 
        } 
        $check = db('soccer_jc')->where('time', $time)->count(); // 
        //$check = 0;// 
 
        $data = $bisai; 
        $data2 = $bisai; 
        $bscount = count($bisai); // 
        $this->model = new \app\common\model\SoccerJc; 
        $this->model2 = new \app\common\model\SoccerZc; // 
 
        $data2count = 0; 
        foreach ($data2 as $k => &$v) { 
 
            $v['jcid'] = $v['id']; 
            $v['time'] = $time; // 
            $v['createtime'] = time(); 
            $v['bstime'] = strtotime(date('Y-m-d', strtotime($v['matchTime']))); 
            $v['rqspf'] = http_build_query($v['rqspf']); 
            $v['bf'] = http_build_query($v['bf']); 
            $v['jq'] = http_build_query($v['jq']); 
            $v['bqc'] = http_build_query($v['bqc']); 
            $v['spf'] = http_build_query($v['spf']); 
            $check2 = db('soccer_zc')->where('jcid', $v['jcid'])->where('matchTime', $v['matchTime'])->value('id'); 
            if (!empty($check2)) { 
                // 
                $v['id'] = $check2; 
                $data2count = $data2count + 1; 
 
            } else { 
                // 
                unset($v['id']); 
            } 
        } 
 
        if ($data2count > 0) { 
            // 
 
            $insert2 = $this->model2->saveall($data2); 
 
            if ($insert2) { 
                echo ''; 
            } else { 
                echo ''; 
            } 
        } else { 
            // 
            $insert2 = $this->model2->insertall($data2); 
            if ($insert2) { 
                echo ''; 
            } else { 
                echo ''; 
            } 
        } 
 
        if ($check == 0) { 
            // 
 
            foreach ($data as $k => &$v) { 
 
                $v['jcid'] = $v['id']; 
                $v['time'] = $time; // 
                $v['createtime'] = time(); 
                $v['rqspf'] = http_build_query($v['rqspf']); 
                $v['bf'] = http_build_query($v['bf']); 
                $v['jq'] = http_build_query($v['jq']); 
                $v['bqc'] = http_build_query($v['bqc']); 
                $v['spf'] = http_build_query($v['spf']); 
                unset($v['id']); 
 
                // echo "<pre>"; 
                // print_r($new);exit(); 
            } 
            // echo "<pre>"; 
            // print_r($data);exit(); 
            $insert = $this->model->insertall($data); 
 
            if ($insert) { 
                echo "";exit(); 
            } else { 
                echo "";exit(); 
            } 
        } else { 
            //  
            $sl = db('soccer_jc')->where('time', $time)->column('id,jcid'); // 
            // echo "<pre>"; 
            // print_r($sl);exit(); 
 
            foreach ($data as $k => &$v) { 
                //unset($v['id']); 
                $v['jcid'] = $v['id']; 
 
                // echo "<pre>"; 
                // print_r($searchkey);exit(); 
                // unset($v['id']); 
                $v['id'] = array_search($v['jcid'], $sl); // 
                if (!empty($v['id']) || $v['id'] === 0) { 
                    // 
                    $v['id'] = $v['id']; 
                } else { 
 
                    unset($v['id']); 
                } 
 
                $v['time'] = $time; // 
                $v['createtime'] = time(); 
                // print_r($v['rqspf']);exit(); 
                if (is_array($v['rqspf'])) { 
                    $v['rqspf'] = http_build_query($v['rqspf']); 
                } 
                if (is_array($v['bf'])) { 
                    $v['bf'] = http_build_query($v['bf']); 
                } 
                if (is_array($v['jq'])) { 
                    $v['jq'] = http_build_query($v['jq']); 
                } 
                if (is_array($v['bqc'])) { 
                    $v['bqc'] = http_build_query($v['bqc']); 
                } 
                if (is_array($v['spf'])) { 
                    $v['spf'] = http_build_query($v['spf']); 
                } 
 
            } 
            // echo "<pre>"; 
            // print_r($data);exit(); 
            $insert = $this->model->saveall($data); 
 
            if ($insert) { 
                echo "";exit(); 
            } else { 
                echo "";exit(); 
            } 
 
        } 
 
    } 
 
    //12  
    //7 
    public function checkmzyl() 
    { 
        $time = strtotime(date('Y-m-d', time())) - 86400; // 
        $time2 = $time - 6 * 86400; // 
        $user_ids = db('cp_order')->where('is_zj', 1)->where('createtime', 'egt', $time)->column('user_id'); 
        if (!empty($user_ids)) { 
            $data = array(); 
            foreach ($user_ids as $k => &$v) { 
                $count1 = db('cp_order')->where('status', 'egt', 1)->where('createtime', 'egt', $time2)->where('user_id', $v)->count(); // 
                $count2 = db('cp_order')->where('is_zj', 1)->where('createtime', 'egt', $time2)->where('user_id', $v)->count(); // 
                $mzl = round(($count2 / $count1) * 100, 0); // 
                $count3 = db('cp_order')->where('status', 'egt', 1)->where('createtime', 'egt', $time2)->where('user_id', $v)->sum('money'); // 
                $count4 = db('cp_order')->where('is_zj', 1)->where('createtime', 'egt', $time2)->where('user_id', $v)->sum('true_jmoey'); // 
                $yll = round(($count4 / $count3) * 100, 0); // 
                $data[$k]['id'] = $v; //id 
                $data[$k]['mzl'] = $mzl; // 
                $data[$k]['yll'] = $yll; // 
            } 
            if (!empty($data)) { 
                $this->model = new \app\common\model\User; 
                $up = $this->model->saveall($data); 
                if ($up) { 
                    echo ""; 
                } else { 
                    echo ""; 
                } 
            } 
            // echo "<pre>"; 
            // print_r($data);exit(); 
        } else { 
            echo "";exit; 
        } 
 
    } 
 
    // 
    // 
    public function testjg() 
    { 
        $time = strtotime(date('Y-m-d', time())); // 
        $pl = db('soccer')->where('ids', 53)->field('id,content,time')->where('time', $time)->find(); //  
        $url = "http://interface.bet007.com/lottery/Zq_BF.aspx?key=200AB2AB2B444E35"; 
        //&&cmd=result 
        $getresp = $this->curlGet($url); 
        // echo "<pre>"; 
        // print_r($getresp);exit(); 
        if (!empty($pl)) { 
            // 
 
            $data['content'] = $getresp; 
            $data['create_time'] = time(); 
            //  $data['id'] = $find['id']; 
            $insert = db('soccer')->where('id', $pl['id'])->update($data); 
        } else { 
            // 
 
            $data['content'] = $getresp; 
            $data['create_time'] = time(); 
            $data['ids'] = 53; 
            $data['time'] = $time; 
            $insert = db('soccer')->insert($data); 
        } 
        // $pl['resp'] = json_decode($getresp, true); 
        $getresp = json_decode($getresp, true); 
        $data = $getresp['matchList']; // 
        // echo "<pre>"; 
        // print_r($data);exit(); 
        //$time = 1684944000; // 
 
        $this->model = new \app\common\model\SoccerJc; 
 
        $newarr = array(); // 
        foreach ($data as $k => $v) { 
            $newarr[$k] = $v['matchId']; //mactchid 
        } 
        // echo "<pre>"; 
        // print_r($newarr);exit(); 
        $where['matchId'] = ['in', $newarr]; 
        // $where['time'] = ['eq', $time]; // 814  
        $check = db('soccer_jc')->where($where)->where('state', 'neq', '-1')->count(); //  
        $list = db('soccer_jc')->where($where)->where('state', 'neq', '-1')->select(); 
 
        // echo "<pre>"; 
        // print_r($list);exit(); 
        // echo $check;exit(); 
        $newdata = array(); 
        if ($check > 0) { 
            //  
            $sl = db('soccer_jc')->where($where)->where('state', 'neq', '-1')->column('id, matchId'); //  
            // echo "<pre>"; 
            // print_r($sl);exit(); 
            $goal = db('soccer_jc')->where($where)->where('state', 'neq', '-1')->column('id, rqspf'); // 
            $bf = db('soccer_jc')->where($where)->where('state', 'neq', '-1')->column('id, bf'); // 
            $spf = db('soccer_jc')->where($where)->where('state', 'neq', '-1')->column('id, spf'); // 
            // echo "<pre>"; 
            // print_r($spf);exit(); 
            $rqspf = db('soccer_jc')->where($where)->where('state', 'neq', '-1')->column('id, rqspf'); // 
            // $bqc = db('soccer_jc')->where($where)->where('state', 'neq', '-1')->column('id, bqc'); // 
            $jq = db('soccer_jc')->where($where)->where('state', 'neq', '-1')->column('id, jq'); // 
            $is_turn = db('soccer_jc')->where($where)->where('state', 'neq', '-1')->column('id, isTurn'); // 
            foreach ($goal as $k => &$v) { 
                parse_str($v, $newgoal); 
                $v = $newgoal['goal']; 
            } 
            foreach ($bf as $k => &$v) { 
                parse_str($v, $newgoal); 
                $v = $newgoal; 
            } 
            foreach ($rqspf as $k => &$v) { 
                parse_str($v, $newgoal); 
                $v = $newgoal; 
            } 
            // foreach ($bqc as $k => &$v) { 
            //     parse_str($v, $newgoal); 
            //     $v = $newgoal; 
            // } 
            foreach ($jq as $k => &$v) { 
                parse_str($v, $newgoal); 
                $v = $newgoal; 
            } 
            foreach ($spf as $k => &$v) { 
                parse_str($v, $newgoal); 
                $v = $newgoal; 
            } 
 
            // echo "<pre>"; 
            // print_r($sl);exit(); 
            foreach ($data as $k => &$v) { 
                $v['searchkey'] = array_search($v['matchId'], $sl); // 
 
                if (!empty($v['searchkey']) || $v['searchkey'] === 0) { 
                    // echo $v['searchkey'];exit(); 
                    // 
                    if ($v['state'] == '-1') { 
                        //  
 
                        $newdata[$k]['id'] = $v['searchkey']; //id 
                        $newdata[$k]['state'] = $v['state']; 
                        if ($is_turn[$v['searchkey']] == 1) { 
                            // 
                            $newdata[$k]['homeScore'] = $v['awayScore']; // 
                            $newdata[$k]['awayScore'] = $v['homeScore']; // 
                            $newdata[$k]['homeHalfScore'] = $v['awayHalfScore']; // 
                            $newdata[$k]['awayHalfScore'] = $v['homeHalfScore']; // 
                            $newdata[$k]['homeRed'] = $v['awayRed']; // 
                            $newdata[$k]['homeYellow'] = $v['awayYellow']; // 
                            $newdata[$k]['awayRed'] = $v['homeRed']; // 
                            $newdata[$k]['awayYellow'] = $v['homeYellow']; // 
                            $newdata[$k]['homeCorner'] = $v['awayCorner']; // 
                            $newdata[$k]['awayCorner'] = $v['homeCorner']; // 
                            $newdata[$k]['homeRank'] = $v['awayRank']; // 
                            $newdata[$k]['awayRank'] = $v['homeRank']; // 
                        } else { 
                            $newdata[$k]['homeScore'] = $v['homeScore']; // 
                            $newdata[$k]['awayScore'] = $v['awayScore']; // 
                            $newdata[$k]['homeHalfScore'] = $v['homeHalfScore']; // 
                            $newdata[$k]['awayHalfScore'] = $v['awayHalfScore']; // 
                            $newdata[$k]['homeRed'] = $v['homeRed']; // 
                            $newdata[$k]['homeYellow'] = $v['homeYellow']; // 
                            $newdata[$k]['awayRed'] = $v['awayRed']; // 
                            $newdata[$k]['awayYellow'] = $v['awayYellow']; // 
                            $newdata[$k]['homeCorner'] = $v['homeCorner']; // 
                            $newdata[$k]['awayCorner'] = $v['awayCorner']; // 
                            $newdata[$k]['homeRank'] = $v['homeRank']; // 
                            $newdata[$k]['awayRank'] = $v['awayRank']; // 
                        } 
 
                        $newdata[$k]['isNeutral'] = $v['isNeutral']; // 
                        $newdata[$k]['hasLineup'] = $v['hasLineup']; // 
                        $newdata[$k]['explain'] = $v['explain']; // 
                        $newdata[$k]['extraExplain'] = $v['extraExplain']; //2 
                        if ($is_turn[$v['searchkey']] == 1) { 
                            //// 
                            $v['sg'] = $this->getcg($v['awayScore'], $v['homeScore'], $v['awayHalfScore'], $v['homeHalfScore'], $goal[$v['searchkey']]); 
                        } else { 
                            $v['sg'] = $this->getcg($v['homeScore'], $v['awayScore'], $v['homeHalfScore'], $v['awayHalfScore'], $goal[$v['searchkey']]); 
                        } 
                        // 
                        // echo "<pre>"; 
                        // print_r($v['sg']);exit(); 
                        $newdata[$k]['bfsg'] = $v['sg']['bf']; // 
                        $newdata[$k]['rq'] = $goal[$v['searchkey']]; // 
                        $newdata[$k]['bfpl'] = $bf[$v['searchkey']][$v['sg']['bfcg']]; // 
                        $newdata[$k]['rqspfsg'] = $v['sg']['rqspf']; // 
                        $newdata[$k]['rqspfpl'] = $rqspf[$v['searchkey']][$v['sg']['rqspfcg']]; // 
                        $newdata[$k]['zjq'] = $v['sg']['jq']; // 
                        $newdata[$k]['zjqpl'] = $jq[$v['searchkey']][$v['sg']['jqcg']]; // 
                        $newdata[$k]['bqcsg'] = $v['sg']['bqc']; // 
                        // $newdata[$k]['bqcpl'] = $bqc[$v['searchkey']][$v['sg']['bqccg']]; // 
 
                        $newdata[$k]['bbfsg'] = $v['homeHalfScore'] . ':' . $v['awayHalfScore']; //  
                        $newdata[$k]['spfsg'] = $v['sg']['spftext']; // 
                        if (isset($spf[$v['searchkey']][$v['sg']['spfcg']])) { 
                            $newdata[$k]['spfpl'] = $spf[$v['searchkey']][$v['sg']['spfcg']]; // 
                        } 
 
                        $newdata[$k]['spfsge'] = $v['sg']['spfcg']; // 
                        $newdata[$k]['rqspfsge'] = $v['sg']['rqspfcg']; // 
                        $newdata[$k]['bfsge'] = $v['sg']['bfcg']; // 
                        $newdata[$k]['zjqsge'] = $v['sg']['jqcg']; // 
                        $newdata[$k]['bqcsge'] = $v['sg']['bqccg']; // 
                        // if ($v['matchId'] == 2337322) { 
                        //     print_r($newdata[$k]);exit(); 
 
                        // } 
                    } else { 
                        // 
                        if ($v['state'] != 0) { 
                            //   
                            $newdata[$k]['id'] = $v['searchkey']; //id 
                            $newdata[$k]['state'] = $v['state']; 
                            if ($is_turn[$v['searchkey']] == 1) { 
                                // 
                                $newdata[$k]['homeScore'] = $v['awayScore']; // 
                                $newdata[$k]['awayScore'] = $v['homeScore']; // 
                                $newdata[$k]['homeHalfScore'] = $v['awayHalfScore']; // 
                                $newdata[$k]['awayHalfScore'] = $v['homeHalfScore']; // 
                                $newdata[$k]['homeRed'] = $v['awayRed']; // 
                                $newdata[$k]['homeYellow'] = $v['awayYellow']; // 
                                $newdata[$k]['awayRed'] = $v['homeRed']; // 
                                $newdata[$k]['awayYellow'] = $v['homeYellow']; // 
                                $newdata[$k]['homeCorner'] = $v['awayCorner']; // 
                                $newdata[$k]['awayCorner'] = $v['homeCorner']; // 
                                $newdata[$k]['homeRank'] = $v['awayRank']; // 
                                $newdata[$k]['awayRank'] = $v['homeRank']; // 
                            } else { 
                                $newdata[$k]['homeScore'] = $v['homeScore']; // 
                                $newdata[$k]['awayScore'] = $v['awayScore']; // 
                                $newdata[$k]['homeHalfScore'] = $v['homeHalfScore']; // 
                                $newdata[$k]['awayHalfScore'] = $v['awayHalfScore']; // 
                                $newdata[$k]['homeRed'] = $v['homeRed']; // 
                                $newdata[$k]['homeYellow'] = $v['homeYellow']; // 
                                $newdata[$k]['awayRed'] = $v['awayRed']; // 
                                $newdata[$k]['awayYellow'] = $v['awayYellow']; // 
                                $newdata[$k]['homeCorner'] = $v['homeCorner']; // 
                                $newdata[$k]['awayCorner'] = $v['awayCorner']; // 
                                $newdata[$k]['homeRank'] = $v['homeRank']; // 
                                $newdata[$k]['awayRank'] = $v['awayRank']; // 
                            } 
 
                            $newdata[$k]['isNeutral'] = $v['isNeutral']; // 
                            $newdata[$k]['hasLineup'] = $v['hasLineup']; // 
                            $newdata[$k]['explain'] = $v['explain']; // 
                            $newdata[$k]['extraExplain'] = $v['extraExplain']; //2 
                        } 
                    } 
                } 
            } 
            // echo "<pre>"; 
            // print_r($newdata);exit(); 
 
            if (!empty($newdata)) { 
                $insert = $this->model->saveall($newdata); 
 
                if ($insert) { 
                    echo "";exit(); 
                } else { 
                    echo "";exit(); 
                } 
            } else { 
                echo "";exit(); 
            } 
 
        } 
    } 
    //9.4 
    public function editjctime2() 
    { 
        $time = strtotime(date('Y-m-d', time())); //12 
        $time = strtotime('2023-09-18'); //12 
        // $time = time() - 300; //-5 
        $time2 = date('Y-m-d H:i:s', time()); 
        $list = db('soccer_jc')->field('matchtime,id,jcid')-> 
            where('time', 'egt', $time)->select(); 
        $week[1] = ''; 
        $week[2] = ''; 
        $week[3] = ''; 
        $week[4] = ''; 
        $week[5] = ''; 
        $week[6] = ''; 
        $week[7] = ''; 
        // echo "<pre>"; 
        // print_r($week);exit(); 
        if (!empty($list)) { 
            $data = array(); 
            foreach ($list as $k => &$v) { 
                $data[$k]['id'] = $v['id']; 
                $data[$k]['matchtime'] = $v['matchtime']; 
                $v['matchtime'] = strtotime($v['matchtime']); 
                $data[$k]['week'] = date('w', $v['matchtime']); 
                if ($data[$k]['week'] == 0) { 
                    $data[$k]['week'] = 7; 
                } 
                $data[$k]['hour'] = date('H', $v['matchtime']); 
                $data[$k]['minute'] = date('i', $v['matchtime']); 
                $data[$k]['bstime'] = strtotime(date('Y-m-d', $v['matchtime'])); //0 
                $v['todaytime'] = strtotime(date('Y-m-d', time())); //0 
                $v['jcid'] = explode('0', $v['jcid']); 
 
                if (count($v['jcid']) == 1) { 
                    //0xx  1xx 
                    $v['jcid'] = explode('1', $v['jcid'][0]); 
                } 
                if ($data[$k]['week'] == 6 || $data[$k]['week'] == 7) { 
                    // 
                    if ($data[$k]['hour'] . $data[$k]['minute'] >= 2240 || $data[$k]['hour'] . $data[$k]['minute'] <= 1100) { 
 
                        if ($data[$k]['hour'] . $data[$k]['minute'] <= 1100) { 
                            //11 
                            if ($data[$k]['week'] != 6) { 
                                // 
                                $data[$k]['jctime'] = date('Y-m-d', $v['matchtime'] - 86400) . ' 22:40:00'; 
                            } else { 
                                // 2140 
                                $data[$k]['jctime'] = date('Y-m-d', $v['matchtime'] - 86400) . ' 21:40:00'; 
                            } 
 
                        } else { 
                            //2140 
                            $data[$k]['jctime'] = date('Y-m-d', $v['matchtime']) . ' 21:40:00'; 
                        } 
 
                    } else { 
                        // echo "2";exit(); 
                        //.   10.40 11  21.40 
                        $data[$k]['jctime'] = date('Y-m-d H:i:s', $v['matchtime'] - 20 * 60); 
 
                    } 
                } else { 
                    // 
                    // 
                    if ($data[$k]['hour'] . $data[$k]['minute'] >= 2140 || $data[$k]['hour'] . $data[$k]['minute'] <= 1100) { 
                        //echo "1";exit(); 
                        //-20 
                        if ($data[$k]['hour'] . $data[$k]['minute'] <= 1100) { 
                            //11 
                            if ($data[$k]['week'] != 1) { 
                                // 
                                $data[$k]['jctime'] = date('Y-m-d', $v['matchtime'] - 86400) . ' 21:40:00'; 
                            } else { 
                                // 2240 
                                $data[$k]['jctime'] = date('Y-m-d', $v['matchtime'] - 86400) . ' 22:40:00'; 
                            } 
 
                        } else { 
                            //2140 
                            $data[$k]['jctime'] = date('Y-m-d', $v['matchtime']) . ' 21:40:00'; 
                        } 
 
                    } else { 
                        // echo "2";exit(); 
                        //.   9.40 11  21.40 
                        $data[$k]['jctime'] = date('Y-m-d H:i:s', $v['matchtime'] - 20 * 60); 
 
                    } 
 
                } 
 
                $data[$k]['jctime2'] = strtotime(date('Y-m-d', strtotime($data[$k]['jctime']))); // 
 
                unset($data[$k]['week']); 
                unset($data[$k]['hour']); 
                unset($data[$k]['minute']); 
                unset($data[$k]['matchtime']); 
                //"", "", "", "", "", "", "" 
 
            } 
            // echo "<pre>"; 
            // print_r($data);exit(); 
            if (!empty($data)) { 
                // 
                $this->model = new \app\common\model\SoccerJc; 
                $up = $this->model->saveall($data); 
                if ($up) { 
                    echo "";exit(); 
                } else { 
                    echo "";exit(); 
                } 
            } else { 
                echo "2"; 
            } 
        } else { 
            echo ""; 
        } 
    } 
    //  9.4  jcid  2140  22:40 
    public function editjctime() 
    { 
        $list = db('soccer_jc')->field('matchtime,id,jcid')->where('jctime', null)->select(); 
        // echo "<pre>"; 
        // print_r($list);exit(); 
        $week[1] = ''; 
        $week[2] = ''; 
        $week[3] = ''; 
        $week[4] = ''; 
        $week[5] = ''; 
        $week[6] = ''; 
        $week[7] = ''; 
        // echo "<pre>"; 
        // print_r($week);exit(); 
        if (!empty($list)) { 
            $data = array(); 
            foreach ($list as $k => &$v) { 
                $data[$k]['id'] = $v['id']; 
                $data[$k]['matchtime'] = $v['matchtime']; 
                $v['matchtime'] = strtotime($v['matchtime']); 
                $data[$k]['week'] = date('w', $v['matchtime']); 
                if ($data[$k]['week'] == 0) { 
                    $data[$k]['week'] = 7; 
                } 
                $data[$k]['hour'] = date('H', $v['matchtime']); 
                $data[$k]['minute'] = date('i', $v['matchtime']); 
                $data[$k]['bstime'] = strtotime(date('Y-m-d', $v['matchtime'])); //0 
 
                $v['jcid'] = explode('0', $v['jcid']); 
 
                if (count($v['jcid']) == 1) { 
                    //0xx  1xx 
                    $v['jcid'] = explode('1', $v['jcid'][0]); 
                } 
                //918 mathctimejctime  
                if ($data[$k]['week'] == 6 || $data[$k]['week'] == 7) { 
                    // 
                    if ($data[$k]['hour'] . $data[$k]['minute'] >= 2240 || $data[$k]['hour'] . $data[$k]['minute'] <= 1100) { 
 
                        if ($data[$k]['hour'] . $data[$k]['minute'] <= 1100) { 
                            // echo 1;exit(); 
                            //11 
                            if ($data[$k]['week'] != 6) { 
                                // 
                                $data[$k]['jctime'] = date('Y-m-d', $v['matchtime'] - 86400) . ' 22:40:00'; 
                            } else { 
                                // 2140 
                                $data[$k]['jctime'] = date('Y-m-d', $v['matchtime'] - 86400) . ' 21:40:00'; 
                            } 
 
                        } else { 
                            //2140 
                            //echo 2;exit(); 
                            $data[$k]['jctime'] = date('Y-m-d', $v['matchtime']) . ' 22:40:00'; 
                        } 
 
                    } else { 
                        // echo "2";exit(); 
                        //.   10.40 11  21.40 
                        $data[$k]['jctime'] = date('Y-m-d H:i:s', $v['matchtime'] - 20 * 60); 
 
                    } 
                } else { 
                    // 
                    // 
                    if ($data[$k]['hour'] . $data[$k]['minute'] >= 2140 || $data[$k]['hour'] . $data[$k]['minute'] <= 1100) { 
                        //echo "1";exit(); 
                        //-20 
                        if ($data[$k]['hour'] . $data[$k]['minute'] <= 1100) { 
                            //11 
                            if ($data[$k]['week'] != 1) { 
                                // 
                                $data[$k]['jctime'] = date('Y-m-d', $v['matchtime'] - 86400) . ' 21:40:00'; 
                            } else { 
                                // 2240 
                                $data[$k]['jctime'] = date('Y-m-d', $v['matchtime'] - 86400) . ' 22:40:00'; 
                            } 
 
                        } else { 
                            //2140 
                            $data[$k]['jctime'] = date('Y-m-d', $v['matchtime']) . ' 21:40:00'; 
                        } 
 
                    } else { 
                        // echo "2";exit(); 
                        //.   9.40 11  21.40 
                        $data[$k]['jctime'] = date('Y-m-d H:i:s', $v['matchtime'] - 20 * 60); 
 
                    } 
 
                } 
 
                $data[$k]['jctime2'] = strtotime(date('Y-m-d', strtotime($data[$k]['jctime']))); // 
                // echo "<pre>"; 
                // print_r($data);exit(); 
                unset($data[$k]['week']); 
                unset($data[$k]['hour']); 
                unset($data[$k]['minute']); 
                unset($data[$k]['matchtime']); 
                //"", "", "", "", "", "", "" 
 
            } 
            // echo "<pre>"; 
            // print_r($data);exit(); 
            if (!empty($data)) { 
                // 
                $this->model = new \app\common\model\SoccerJc; 
                $up = $this->model->saveall($data); 
                if ($up) { 
                    echo "";exit(); 
                } else { 
                    echo "";exit(); 
                } 
            } else { 
                echo "2"; 
            } 
        } else { 
            echo ""; 
        } 
 
    } 
 
    //  
    public function jczq() 
    { 
        $post = $this->request->post(); 
        if (isset($post['id']) && !empty($post['id'])) { 
 
            $where['id'] = ['eq', $post['id']]; 
            $list = db('soccer_jc')->where($where)->field('id, time')->order('time desc')->find(); // 
        } else { 
            $list = db('soccer_jc')->field('id, time')->order('time desc')->find(); // 
        } 
 
        $week_array = array("", "", "", "", "", "", ""); 
 
        $list['newtime'] = date('Y - m - d', $list['time']); 
        $week = date("w", $list['time']); 
        $list['date'] = '' . $week_array[$week]; 
        $list['num1'] = db('soccer_jc')->where('time', $list['time'])->where('spfsge', 'spf3')->count(); // 
        $list['num2'] = db('soccer_jc')->where('time', $list['time'])->where('spfsge', 'spf1')->count(); // 
        $list['num3'] = db('soccer_jc')->where('time', $list['time'])->where('spfsge', 'spf0')->count(); // 
        $list['bisainum'] = db('soccer_jc')->where('time', $list['time'])->where('state', '-1')->count(); // 
        $list['bisaidetail'] = db('soccer_jc')->field('home as homeChs,away as awayChs,bfsg as bf,rq,bbfsg as rqbf,spfsg as spf, spfpl,rqspfsg as rqspf,rqspfpl,bfpl,zjq,zjqpl,bqcsg as bqc,bqcpl,league as leagueChs')->where('time', $list['time'])->where('state', '-1')->select(); // 
 
        $this->success('', $list, 0); 
    } 
    // 
    //bf1  
    //bf2  
    //bf3  
    //bf4  
    //rq  
    public function getcg($bf1, $bf2, $bf3, $bf4, $rq) 
    { 
        $message['homeScore'] = $bf1; 
        $message['awayScore'] = $bf2; 
        $message['homeHalfScore'] = $bf3; 
        $message['awayHalfScore'] = $bf4; 
 
        // 
        if ($message['homeScore'] > $message['awayScore']) { 
            $data['spfcg'] = 'spf3'; 
            $data['spftext'] = ''; 
        } elseif ($message['homeScore'] < $message['awayScore']) { 
            $data['spfcg'] = 'spf0'; 
            $data['spftext'] = ''; 
        } else { 
            $data['spfcg'] = 'spf1'; 
            $data['spftext'] = ''; 
        } 
        // 
        if ($message['homeScore'] > $message['awayScore']) { 
            // sw 
            $hlist = ['1', '2', '3', '4', '5']; // 
            $alist = ['0', '1', '2']; // 
            $hcheck = in_array($message['homeScore'], $hlist); 
            $acheck = in_array($message['awayScore'], $alist); 
            if ($hcheck && $acheck) { 
                // $cg = 'sw' . $message['homeScore'] . $message['awayScore']; 
                $data['bfcg'] = 'sw' . $message['homeScore'] . $message['awayScore']; 
 
            } else { 
                $data['bfcg'] = 'sw5'; // 
            } 
 
        } elseif ($message['homeScore'] == $message['awayScore']) { 
            // 
 
            $hlist = ['0', '1', '2', '3']; // 
 
            $hcheck = in_array($message['homeScore'], $hlist); 
            $acheck = in_array($message['awayScore'], $hlist); 
            if ($hcheck && $acheck) { 
                $data['bfcg'] = 'sd' . $message['homeScore'] . $message['awayScore']; 
            } else { 
                $data['bfcg'] = 'sd4'; // 
            } 
 
        } else { 
            // 
            $hlist = ['0', '1', '2']; // 
            $alist = ['1', '2', '3', '4', '5']; // 
 
            $hcheck = in_array($message['homeScore'], $hlist); 
            $acheck = in_array($message['awayScore'], $alist); 
            if ($hcheck && $acheck) { 
                $data['bfcg'] = 'sl' . $message['homeScore'] . $message['awayScore']; 
            } else { 
                $data['bfcg'] = 'sl5'; // 
            } 
 
        } 
        // 
        $data['bf'] = $message['homeScore'] . ":" . $message['awayScore']; 
        // 
        if ($message['homeScore'] + $message['awayScore'] > 6) { 
            $data['jqcg'] = 't7'; 
        } else { 
            $zjq = $message['homeScore'] + $message['awayScore']; 
            $data['jqcg'] = 't' . $zjq; 
        } 
        $data['jq'] = $message['homeScore'] + $message['awayScore'] . ''; // 
        // 
        if ($message['homeHalfScore'] > $message['awayHalfScore'] && $message['homeScore'] > $message['awayScore']) { 
            // 
            $data['bqccg'] = 'ht33'; 
            $data['bqc'] = '-'; 
        } elseif ($message['homeHalfScore'] > $message['awayHalfScore'] && $message['homeScore'] == $message['awayScore']) { 
            // 
            $data['bqccg'] = 'ht31'; 
            $data['bqc'] = '-'; 
        } elseif ($message['homeHalfScore'] > $message['awayHalfScore'] && $message['homeScore'] < $message['awayScore']) { 
            // 
            $data['bqccg'] = 'ht30'; 
            $data['bqc'] = '-'; 
        } elseif ($message['homeHalfScore'] == $message['awayHalfScore'] && $message['homeScore'] > $message['awayScore']) { 
            // 
            $data['bqccg'] = 'ht13'; 
            $data['bqc'] = '-'; 
        } elseif ($message['homeHalfScore'] == $message['awayHalfScore'] && $message['homeScore'] == $message['awayScore']) { 
            // 
            $data['bqccg'] = 'ht11'; 
            $data['bqc'] = '-'; 
        } elseif ($message['homeHalfScore'] == $message['awayHalfScore'] && $message['homeScore'] < $message['awayScore']) { 
            // 
            $data['bqccg'] = 'ht10'; 
            $data['bqc'] = '-'; 
        } elseif ($message['homeHalfScore'] < $message['awayHalfScore'] && $message['homeScore'] > $message['awayScore']) { 
            // 
            $data['bqccg'] = 'ht03'; 
            $data['bqc'] = '-'; 
        } elseif ($message['homeHalfScore'] < $message['awayHalfScore'] && $message['homeScore'] == $message['awayScore']) { 
            // 
            $data['bqccg'] = 'ht01'; 
            $data['bqc'] = '-'; 
        } else { 
            // 
            $data['bqccg'] = 'ht00'; 
            $data['bqc'] = '-'; 
        } 
 
        if ($rq < 0) { 
            // 
            //  echo $message['homeScore'] + $order['rqno']; 
            if ($message['homeScore'] + $rq > $message['awayScore']) { 
                $data['rqspfcg'] = 'rq3'; 
            } elseif ($message['homeScore'] + $rq < $message['awayScore']) { 
                $data['rqspfcg'] = 'rq0'; 
            } else { 
                $data['rqspfcg'] = 'rq1'; 
            } 
            // echo $cg;exit(); 
        } else { 
            // 
            if ($message['homeScore'] > $message['awayScore'] - $rq) { 
                $data['rqspfcg'] = 'rq3'; 
            } elseif ($message['homeScore'] < $message['awayScore'] - $rq) { 
                $data['rqspfcg'] = 'rq0'; 
            } else { 
                $data['rqspfcg'] = 'rq1'; 
            } 
        } 
        switch ($data['rqspfcg']) { 
            case 'rq3': 
                $data['rqspf'] = ''; 
                break; 
            case 'rq1': 
                $data['rqspf'] = ''; 
                break; 
            default: 
                $data['rqspf'] = ''; 
                break; 
        } 
        return $data; 
 
    } 
 
    // 
    public function szc() 
    { 
        $dlt = db('gzgl')->field('id, number, kjtime, is_end')->order('no desc')->find(); 
        $dlt['single'] = explode(' ', $dlt['number']); 
        $dlt['type_text'] = ''; 
        $dlt['kjtime'] = date('Y - m - d', strtotime($dlt['kjtime'])); 
        $week_array = array("", "", "", "", "", "", ""); 
 
        $week = date("w", strtotime($dlt['kjtime'])); 
        $dlt['date'] = '' . $week_array[$week]; 
        $list['dlt'] = $dlt; 
        $this->success('', $list, 0); 
    } 
    // 
    public function dlt() 
    { 
        $post = $this->request->post(); 
        $page = $post['page']; 
        $limit = $post['limit']; 
        $list = db('gzgl')->order('no desc')->page($page, $limit)->select(); 
        foreach ($list as $k => &$v) { 
            $v['single'] = explode(' ', $v['number']); 
        } 
        $this->success('', $list, 0); 
    } 
    //3 
    public function plthree() 
    { 
        $post = $this->request->post(); 
        $page = $post['page']; 
        $limit = $post['limit']; 
        $list = db('gzglplthree')->order('no desc')->where('deletetime', 'null')->page($page, $limit)->select(); 
        foreach ($list as $k => &$v) { 
            $v['single'] = explode(' ', $v['number']); 
        } 
        $this->success('3', $list, 0); 
    } 
    //5 
    public function plfive() 
    { 
        $post = $this->request->post(); 
        $page = $post['page']; 
        $limit = $post['limit']; 
        $list = db('gzglplfive')->order('no desc')->page($page, $limit)->select(); 
        foreach ($list as $k => &$v) { 
            $v['single'] = explode(' ', $v['number']); 
        } 
        $this->success('', $list, 0); 
    } 
    // 
    public function qxc() 
    { 
        $post = $this->request->post(); 
        $page = $post['page']; 
        $limit = $post['limit']; 
        $list = db('gzglqxc')->order('no desc')->page($page, $limit)->select(); 
        foreach ($list as $k => &$v) { 
            $v['single'] = explode(' ', $v['number']); 
        } 
        $this->success('', $list, 0); 
    } 
    // 
    public function dlt_detail() 
    { 
        $post = $this->request->post(); 
        $list = db('gzgl')->where('id', $post['id'])->find(); 
        $list['single'] = explode(' ', $list['number']); 
        $this->success('', $list, 0); 
    } 
    //3 
    public function plthree_detail() 
    { 
        $post = $this->request->post(); 
        $list = db('gzglplthree')->where('id', $post['id'])->find(); 
        $list['single'] = explode(' ', $list['number']); 
        $this->success('', $list, 0); 
    } 
    //5 
    public function plfive_detail() 
    { 
        $post = $this->request->post(); 
        $list = db('gzglplfive')->where('id', $post['id'])->find(); 
        $list['single'] = explode(' ', $list['number']); 
        $this->success('', $list, 0); 
    } 
    // 
    public function qxc_detail() 
    { 
        $post = $this->request->post(); 
        $list = db('gzglqxc')->where('id', $post['id'])->find(); 
        $list['single'] = explode(' ', $list['number']); 
        $this->success('', $list, 0); 
    } 
    // 
    public function zst() 
    { 
        $post = $this->request->post(); 
        if (!isset($post['type']) && empty($post['type'])) { 
            $type = 1; // 
        } else { 
            $type = $post['type']; 
        } 
        $list = db('zst')->where('type', $type)->order('createtime desc')->select(); 
        foreach ($list as $k => &$v) { 
            if (!empty($v['zj'])) { 
                $v['single'] = explode(' ', $v['zj']); 
            } 
 
        } 
        $this->success('', $list, 0); 
    } 
    // 
    public function sdgc() 
    { 
        $post = $this->request->post(); 
        if (!isset($post['time']) && empty($post['time'])) { 
            $time = strtotime(date('Y-m-d', time())); // 
        } else { 
            $time = strtotime($post['time']); // 
        } 
        $time2 = $time + 86400; 
        $list = db('sdgc')->where('time', 'egt', $time)->where('time', 'elt', $time2)->order('bonus desc')->select(); 
        $week_array = array("", "", "", "", "", "", ""); 
 
        foreach ($list as $k => &$v) { 
            $v['sort'] = $k + 1; 
            $v['newtime'] = date('Y - m', $v['time']); 
            $v['newtime2'] = date('m - d', $v['time']); 
            $week = date("w", $v['time']); 
            $v['date'] = '' . $week_array[$week]; 
        } 
        $this->success('', $list, 0); 
    } 
    // 
    public function kjzb() 
    { 
        $list = db('config')->where('name', 'kjzb')->value('value'); // 
        $this->success('', $list, 0); 
    } 
    // 
    public function hmbz() 
    { 
        $list = db('config')->where('name', 'hmbz')->value('value'); // 
        $this->success('', $list, 0); 
    } 
    // 
    public function bzzx() 
    { 
        $list['bz_zc'] = db('config')->where('name', 'bz_zc')->value('value'); // 
        $list['bz_cz'] = db('config')->where('name', 'bz_cz')->value('value'); // 
        $list['bz_gc'] = db('config')->where('name', 'bz_gc')->value('value'); // 
        $list['bz_zj'] = db('config')->where('name', 'bz_zj')->value('value'); // 
        $list['bz_tk'] = db('config')->where('name', 'bz_tk')->value('value'); // 
        $list['bz_qt'] = db('config')->where('name', 'bz_qt')->value('value'); // 
        $this->success('', $list, 0); 
    } 
    // 
    public function bzzxnew() 
    { 
        $post = $this->request->post(); 
        $type = $post['type']; 
        $list = db('bzzx')->field('title,content')->where('type', $type)->select(); 
        $this->success('', $list, 0); 
    } 
    // 
    public function gdtips() 
    { 
        $list = db('config')->where('name', 'gdtips')->value('value'); // 
        $this->success('', $list, 0); 
    } 
 
    // 
    public function cz() 
    { 
        $list = db('cz')->field('cz_money, cz_price')->select(); 
        $this->success('', $list, 0); 
    } 
    // 
    public function tx() 
    { 
        $list = db('config')->where('group', 'tx')->field('name, title, value')->select(); 
        $this->success('', $list, 0); 
    } 
    // 
    public function zl() 
    { 
        $list = db('config')->where('group', 'zl')->field('name, title, value')->select(); 
        $this->success('', $list, 0); 
    } 
 
    // 
    public function bfsj() 
    { 
 
        $post = $this->request->post(); 
 
        $time = time() - 300; //-5 
        $find = db('soccer')->where('ids', 53)->where('create_time', 'egt', $time)->order('id desc')->find(); //5 
        if (empty($find)) { 
            //  
            // $resp = ''; 
            // $data['content'] = $resp; 
            // $data['create_time'] = time(); 
            // $data['ids'] = 56; 
            // $insert = db('soccer')->insert($data); 
            $find = db('soccer')->where('ids', 53)->order('id desc')->find(); //  
            $resp = $find['content']; 
        } else { 
            $resp = $find['content']; 
        } 
 
        $resp = json_decode($resp, true); 
        $content = $resp['matchList']; // 
        $newlist = array(); 
        $matchTime = array(); 
        foreach ($content as $k => &$v) { 
 
            $newlist[$k] = $v['homeChs'] . 'VS' . $v['awayChs']; // 
            $matchTime[$k] = strtotime($v['matchTime']); //  
        } 
 
        // foreach ($newlist as $k => &$v) { 
        //     # code... 
        // } 
        // echo "<pre>"; 
        // print_r($newlist);exit(); 
        $list = db('cp_order_detail')->where('dz', 'in', $newlist)->where('matchTime', 'in', $matchTime)->where('is_check', 0)->select(); //  
        if (!empty($list)) { 
            // 
            //  
            $data = array(); 
            foreach ($list as $k => &$v) { 
                $data[] = $this->check_zj($v, $content, $newlist); //   
 
            } 
            if (!empty($data)) { 
                $this->model = new \app\common\model\CpOrderDetail; 
                $up = $this->model->saveall($data); 
            } 
            // echo "<pre>"; 
            // print_r($data);exit(); 
        } 
        // echo "<pre>111"; 
        // print_r($list);exit(); 
        //  $this->success('', $resp, 0); 
    } 
    // 
    //ordermessage  newlist  
    public function check_zj($order, $message, $newlist) 
    { 
 
        //$order['wfbd'] = 'rqspf'; // 
        $searchkey = array_search($order['dz'], $newlist); // 
        $message = $message[$searchkey]; // 
 
        if ($message['state'] == '-1') { 
            // 
            switch ($order['wfbd']) { 
                // 
                case 'spf': // spf3  spf1 spf0  
 
                    if ($message['homeScore'] > $message['awayScore']) { 
                        $cg = 'spf3'; 
                    } elseif ($message['homeScore'] < $message['awayScore']) { 
                        $cg = 'spf0'; 
                    } else { 
                        $cg = 'spf1'; 
                    } 
 
                    break; 
                case 'bf': //  swsdsl<sd00>0:0 sw5  sw 
 
                    if ($message['homeScore'] > $message['awayScore']) { 
                        // sw 
                        $hlist = ['1', '2', '3', '4', '5']; // 
                        $alist = ['0', '1', '2']; // 
                        $hcheck = in_array($message['homeScore'], $hlist); 
                        $acheck = in_array($message['awayScore'], $alist); 
                        if ($hcheck && $acheck) { 
                            $cg = 'sw' . $message['homeScore'] . $message['awayScore']; 
                        } else { 
                            $cg = 'sw5'; // 
                        } 
 
                    } elseif ($message['homeScore'] == $message['awayScore']) { 
                        // 
 
                        $hlist = ['0', '1', '2', '3']; // 
 
                        $hcheck = in_array($message['homeScore'], $hlist); 
                        $acheck = in_array($message['awayScore'], $hlist); 
                        if ($hcheck && $acheck) { 
                            $cg = 'sd' . $message['homeScore'] . $message['awayScore']; 
                        } else { 
                            $cg = 'sd4'; // 
                        } 
 
                    } else { 
                        // 
                        $hlist = ['0', '1', '2']; // 
                        $alist = ['1', '2', '3', '4', '5']; // 
 
                        $hcheck = in_array($message['homeScore'], $hlist); 
                        $acheck = in_array($message['awayScore'], $alist); 
                        if ($hcheck && $acheck) { 
                            $cg = 'sl' . $message['homeScore'] . $message['awayScore']; 
                        } else { 
                            $cg = 'sl5'; // 
                        } 
 
                    } 
 
                    break; 
                case 'jq': // 
 
                    if ($message['homeScore'] + $message['awayScore'] > 6) { 
                        $cg = 't7'; 
                    } else { 
                        $zjq = $message['homeScore'] + $message['awayScore']; 
                        $cg = 't' . $zjq; 
                    } 
 
                    break; 
                case 'bqc': // 
 
                    if ($message['homeHalfScore'] > $message['awayHalfScore'] && $message['homeScore'] > $message['awayScore']) { 
                        // 
                        $cg = 'ht31'; 
                    } elseif ($message['homeHalfScore'] > $message['awayHalfScore'] && $message['homeScore'] < $message['awayScore']) { 
                        // 
                        $cg = 'ht30'; 
                    } elseif ($message['homeHalfScore'] == $message['awayHalfScore'] && $message['homeScore'] < $message['awayScore']) { 
                        // 
                        $cg = 'ht13'; 
                    } elseif ($message['homeHalfScore'] == $message['awayHalfScore'] && $message['homeScore'] == $message['awayScore']) { 
                        // 
                        $cg = 'ht11'; 
                    } elseif ($message['homeHalfScore'] == $message['awayHalfScore'] && $message['homeScore'] < $message['awayScore']) { 
                        // 
                        $cg = 'ht10'; 
                    } elseif ($message['homeHalfScore'] == $message['awayHalfScore'] && $message['homeScore'] > $message['awayScore']) { 
                        // 
                        $cg = 'ht03'; 
                    } elseif ($message['homeHalfScore'] < $message['awayHalfScore'] && $message['homeScore'] == $message['awayScore']) { 
                        // 
                        $cg = 'ht01'; 
                    } else { 
                        // 
                        $cg = 'ht00'; 
                    } 
 
                    break; 
                case 'rqspf': // rq3  rq1  rq0  
                    if ($order['rqno'] < 0) { 
                        // 
                        //  echo $message['homeScore'] + $order['rqno']; 
                        if ($message['homeScore'] + $order['rqno'] > $message['awayScore']) { 
                            $cg = 'rq3'; 
                        } elseif ($message['homeScore'] + $order['rqno'] < $message['awayScore']) { 
                            $cg = 'rq0'; 
                        } else { 
                            $cg = 'rq1'; 
                        } 
                        // echo $cg;exit(); 
                    } else { 
                        // 
                        if ($message['homeScore'] > $message['awayScore'] - $order['rqno']) { 
                            $cg = 'rq3'; 
                        } elseif ($message['homeScore'] < $message['awayScore'] - $order['rqno']) { 
                            $cg = 'rq0'; 
                        } else { 
                            $cg = 'rq1'; 
                        } 
                    } 
 
                    break; 
 
                default: 
                    $cg = 0; 
                    break; 
            } 
        } 
        //echo $cg;exit(); 
        if ($cg != "0") { 
            //   
            //echo $cg;exit(); 
            $xx = explode(':', $order['xx']); // 
            $zj = 0; 
            $zj_xx = ''; //  
            $zj_pl = ''; //  
            foreach ($xx as $k => $v) { 
                if ($v == $cg) { 
                    // 
                    $zj = 1; 
                    $data['zjxx'] = $v; 
                    $pl = explode(':', $order['pl']); 
                    $data['zjpl'] = $pl[$k]; 
                } 
 
            } 
            $data['is_check'] = 1; 
            $data['is_zj'] = $zj; 
            $data['id'] = $order['id']; 
            return $data; 
        } 
 
        // echo "<pre>"; 
        // print_r($cg);exit(); 
        // echo "<pre>"; 
        // print_r($order);exit(); 
 
    } 
    // 
    public function check_zero() 
    { 
        $count = db('cp_order')->where('is_check', 1)->where('status', 2)->count(); 
        if ($count > 0) { 
            $list = db('cp_order')->where('is_check', 1)->where('status', 2)->column('id'); //id 
            $data = array(); 
            foreach ($list as $k => $v) { 
                $data[$k]['id'] = $v; 
                $data[$k]['is_check'] = 0; 
 
            } 
            $this->model = new \app\common\model\CpOrder; 
            $up = $this->model->saveall($data); 
            if ($up) { 
                echo "";exit(); 
            } else { 
                echo "";exit(); 
            } 
 
        } else { 
            echo "";exit(); 
        } 
 
    } 
    // 
    public function check_detail_zero() 
    { 
        $count = db('cp_order_detail')->where('is_check', 0)->where('tem_check', 1)->count(); 
        if ($count > 0) { 
            $list = db('cp_order_detail')->where('is_check', 0)->where('tem_check', 1)->column('id'); //id 
            $data = array(); 
            foreach ($list as $k => $v) { 
                $data[$k]['id'] = $v; 
                $data[$k]['tem_check'] = 0; 
 
            } 
            $this->model = new \app\common\model\CpOrderDetail; 
            $up = $this->model->saveall($data); 
            if ($up) { 
                echo ""; 
            } else { 
                echo ""; 
            } 
 
        } else { 
            echo ""; 
        } 
        $count = db('cp_order_detailbd')->where('is_check', 0)->where('tem_check', 1)->count(); 
        if ($count > 0) { 
            $list = db('cp_order_detailbd')->where('is_check', 0)->where('tem_check', 1)->column('id'); //id 
            $data = array(); 
            foreach ($list as $k => $v) { 
                $data[$k]['id'] = $v; 
                $data[$k]['tem_check'] = 0; 
 
            } 
            $this->model = new \app\common\model\CpOrderDetailbd; 
            $up = $this->model->saveall($data); 
            if ($up) { 
                echo ""; 
            } else { 
                echo ""; 
            } 
 
        } else { 
            echo ""; 
        } 
        exit(); 
    } 
 
    // 
    public function check_order_detail() 
    { 
        // 
        $count = db('cp_order_detail')->where('is_check', 0)->where('tem_check', 0)->count(); 
        if ($count > 0) { 
            $limit = 30; 
            // $idlist = db('cp_order_detail')->where('is_check', 0)->column('id'); 
            // $randkey = rand(0, $count); 
            // 
            // $randkey = $randkey - $limit; 
            // if ($randkey < 0) { 
            //     $randkey = 0; 
            // } 
            // $rand = $idlist[$randkey]; 
            //where('id', 'egt', $rand)-> 
            //9.8 rand   
            $orderlist = db('cp_order')->where('type', 2)->where('status', 2)->where('is_check', 0)->where('hg_orderno', 0)->column('orderno'); // 
            // echo "<pre>"; 
            // print_r($orderlist);exit(); 
            $list = db('cp_order_detail')->where('orderno', 'in', $orderlist)->where('is_check', 0)->where('tem_check', 0)->field('id,xx,wfbd,matchtime,cc,pl,dz')->order('createtime asc')->limit($limit)->select(); // 
            // echo "<pre>"; 
            // print_r($list);exit(); 
            //  
            // $list = db('cp_order_detail')->field('id,xx,wfbd,matchtime,cc,pl')->order('createtime asc')->limit($limit)->select(); // 
 
            if (!empty($list)) { 
                $data = array(); 
                foreach ($list as $k => &$v) { 
                    $v['dz'] = explode('VS', $v['dz']); 
 
                    // $v['check'] = db('soccer_jc')->where('matchTime', $v['matchtime'])->where('jcid', $v['cc'])->where('state', '-1')->field('matchTime,jcid,spfsge,bqcsge,rqspfsge,zjqsge,bfsge,spfsg,bqcsg,rqspfsg,zjq,bfsg')->find(); // 
                    $v['check'] = db('soccer_jc')->where('home', $v['dz'][0])->where('away', $v['dz'][1])->where('jcid', $v['cc'])->where('state', '-1')->field('id,matchTime,jcid,spfsge,bqcsge,rqspfsge,zjqsge,bfsge,spfsg,bqcsg,rqspfsg,zjq,bfsg')->order('createtime desc')->find(); // 
 
                    // echo "<pre>"; 
                    // print_r($v);exit(); 
                    // print_r($v['check']);exit(); 
                    if (!empty($v['check'])) { 
                        $v['xx'] = explode(':', $v['xx']); // 
                        $v['pl'] = explode(':', $v['pl']); // 
                        switch ($v['wfbd']) { 
                            case 'spf': 
                                $v['sg'] = $v['check']['spfsge']; // 
                                $v['cg'] = $v['check']['spfsg']; // 
                                break; 
                            case 'bqc': 
                                $v['sg'] = $v['check']['bqcsge']; // 
                                $v['cg'] = $v['check']['bqcsg']; // 
                                break; 
                            case 'rqspf': 
                                $v['sg'] = $v['check']['rqspfsge']; // 
                                $v['cg'] = $v['check']['rqspfsg']; // 
                                break; 
                            //case 'zjq': 20238143   jq 
                            case 'jq': 
                                $v['sg'] = $v['check']['zjqsge']; // 
                                $v['cg'] = $v['check']['zjq']; // 
                                break; 
                            default: 
                                $v['sg'] = $v['check']['bfsge']; // 
                                $v['cg'] = $v['check']['bfsg']; // 
                                break; 
                        } 
                        //echo $v['sg'];exit(); 
                        $v['searchkey'] = array_search($v['sg'], $v['xx']); 
                        //echo array_search($v['sg'], $v['xx']);exit(); 
 
                        $data[$k]['id'] = $v['id']; 
                        $data[$k]['is_check'] = 1; 
                        if (!empty($v['searchkey']) || $v['searchkey'] === 0) { 
                            // 
                            $data[$k]['is_zj'] = 1; 
                            $data[$k]['zj_xx'] = $v['xx'][$v['searchkey']]; 
                            $data[$k]['zj_pl'] = $v['pl'][$v['searchkey']]; 
                        } else { 
 
                            $data[$k]['is_zj'] = 0; 
                        } 
                        $data[$k]['cg'] = $v['cg']; 
 
                        // $searchkey[] = array_search($v[0], $newlist); // 
                    } else { 
 
                        $v['check'] = db('soccer_jc')->where('home', $v['dz'][0])->where('away', $v['dz'][1])->where('jcid', $v['cc'])->where('state', '<', '-1')->field('id,matchTime,jcid,state')->order('createtime desc')->find(); // 
 
                        // echo "<pre>"; 
                        // print_r($v);exit(); 
                        //print_r($v['check']);exit(); 
                        if (!empty($v['check'])) { 
                            // 
                            $data[$k]['id'] = $v['id']; 
                            $data[$k]['is_zj'] = 1; 
                            $data[$k]['zj_xx'] = $v['check']['state']; 
                            $data[$k]['zj_pl'] = 1; //1 
                            $data[$k]['cg'] = ''; 
                            $data[$k]['is_check'] = 1; 
                        } else { 
                            $data[$k]['id'] = $v['id']; 
                            $data[$k]['tem_check'] = 1; // 
                        } 
 
                    } 
 
                } 
                // echo "<pre>"; 
                // print_r($data);exit(); 
                if (!empty($data)) { 
                    $this->model = new \app\common\model\CpOrderDetail; 
                    $up = $this->model->saveall($data); 
                    if ($up) { 
                        echo "";exit(); 
                    } else { 
                        echo "";exit(); 
                    } 
                } 
                // echo "<pre>"; 
                // print_r($data);exit(); 
            } 
            // echo "<pre>"; 
            // print_r($list);exit(); 
        } else { 
            echo "";exit(); 
        } 
    } 
 
    // 
    public function getname($a, $b) 
    { 
        if (5 == $a && 2 == $b) { 
            return "prize1"; 
        } else if (5 == $a && 1 == $b) { 
            return "prize2"; 
        } else if (5 == $a && 0 == $b) { 
            return "prize3"; 
        } else if (4 == $a && 2 == $b) { 
            return "prize4"; 
        } else if (4 == $a && 1 == $b) { 
            return "prize5"; 
        } else if (3 == $a && 2 == $b) { 
            return "prize6"; 
        } else if (4 == $a && 0 == $b) { 
            return "prize7"; 
        } else if ((3 == $a && 1 == $b) || (2 == $a && 2 == $b)) { 
            return "prize8"; 
        } else if ((3 == $a && 0 == $b) || (1 == $a && 2 == $b) || (2 == $a && 1 == $b) || (0 == $a && 2 == $b)) { 
            return "prize9"; 
        } else { 
            return "no prize"; 
        } 
    } 
    // public function GetMoneyByName {$name}{ 
 
    //     if ("prize1" == $name) { 
    //         return this.money = "A" 
    //     } else if ("prize2" == name) { 
    //         return this.money = "B" 
    //     } else if ("prize3" == name) { 
    //         return this.money = 10000 
    //     } else if ("prize4" == name) { 
    //         return this.money = 3000 
    //     } else if ("prize5" == name) { 
    //         return this.money = 300 
    //     } else if ("prize6" == name) { 
    //         return this.money = 200 
    //     } else if ("prize7" == name) { 
    //         return this.money = 100 
    //     } else if ("prize8" == name) { 
    //         return this.money = 15 
    //     } else if ("prize9" == name) { 
    //         return this.money = 5 
    //     } else { 
    //         return this.money = 0 
    //     } 
 
    // } 
    public function comb($head, $foot) 
    { 
 
        $A = $head; 
        $B = $foot; 
        $C = 1; 
        for ($i = $B - $A + 1; $i <= $B; $i++) { 
            $C = $C * $i; 
        } 
        for ($i = 2; $i <= $A; $i++) { 
            $C = $C / $i; 
        } 
        return $C; 
 
    } 
 
    /** 
     *  
     * @Author   MAX 
     * @DateTime 2018-09-07T16:28:40+0800 
     * @param    Array                   $arr  
     * @param    Number                   $m    
     * @param    [Array]                  $push    
     * @return   Array                         
     */ 
    public function getCombinationToString($arr, $m, $push = null) 
    { 
        $rst = array(); 
        // echo count($arr);exit(); 
        // echo "<pre>"; 
        // var_dump($arr);exit(); 
        for ($i = 0; $i < pow(2, count($arr)); $i++) { 
            $a = 0; 
            $b = array(); 
            for ($j = 0; $j < count($arr); $j++) { 
                if ($i >> $j & 1) { 
                    $a++; 
                    array_push($b, $arr[$j]); 
                } 
            } 
            if ($a == $m) { 
                if (!is_null($push)) { 
                    if (is_string($push)) { 
                        $b = array_unshift($b, $push); 
                    } else { 
                        $b = array_merge($push, $b); 
                    } 
                } 
                $rst[] = $b; 
            } 
        } 
        return $rst; 
    } 
 
    //  
    public function check_order() 
    { 
        //$time = strtotime(date('Y - m - d', time())); // 
        $list = db('cp_order')->where('status', 2)->where('type', 2)->where('is_check', 0)->where('is_h', 0)->order('createtime desc')->limit(30)->select(); // 
        // echo "<pre>"; 
        // print_r($list);exit(); 
        if (!empty($list)) { 
            //   
 
            foreach ($list as $k => &$v) { 
 
                $v['count1'] = db('cp_order_detail')->where('orderno', $v['orderno'])->count(); // 
                $v['count2'] = db('cp_order_detail')->where('orderno', $v['orderno'])->where('is_check', 1)->count(); // 
                $v['count3'] = db('cp_order_detail')->where('orderno', $v['orderno'])->where('is_zj', 1)->count(); // 
 
                if ($v['count1'] == $v['count2']) { 
                    //  
                    if (!empty($v['cp_type2'])) { 
                        //MN 
                        $data[$k] = $this->get_orderdatamore($v, 2); 
 
                    } else { 
                        if ($v['cp_type'] == '') { 
                            // 
                            //  
                            // echo "<pre>"; 
                            // print_r($v); 
                            $data[$k] = $this->get_orderdatamore($v, 1); 
 
                        } else { 
                            //x1 8.16 x1 
                            // $v['cp_type'] = explode('', $v['cp_type']); 
                            $v['newcheck'] = explode(',', $v['cp_type']); 
                            $v['checkcount'] = count($v['newcheck']); 
                            if ($v['checkcount'] > 1) { 
                                //N1 
                                // echo "<pre>"; 
                                // print_r($v); 
                                $data[$k] = $this->get_orderdatamore($v, 1); 
 
                            } else { 
                                //$data[$k] = $this->get_orderdataone($v); 
                                $data[$k] = $this->get_orderdatamore($v, 1); 
                            } 
 
                        } 
 
                    } 
 
                } else { 
                    //  
                    $data[$k]['id'] = $v['id']; 
                    $data[$k]['is_check'] = 1; // 
 
                } 
            } 
            // echo "<pre>"; 
            // print_r($data);exit(); 
            if (!empty($data)) { 
 
                $this->model = new \app\common\model\CpOrder; 
                $xejmoney = db('config')->where('name', 'jmoney')->value('value'); // 
                // echo "<pre>"; 
                // print_r($xejmoney);exit(); 
                foreach ($data as $k => $v) { 
                    if (isset($v['is_zj'])) { 
                        if ($v['is_zj'] == 1) { 
                            //  
                            // echo 111; 
                            if ($v['true_jmoey'] > $xejmoney) { 
                                $is_check = 0; // 01 
                            } else { 
                                $is_check = 1; 
                            } 
                            UserModel::jmoney($v['true_jmoey'], $v['user_id'], '4', '', '+' . $v['true_jmoey'] . '', $v['orderno'], $is_check); //4        
                        } 
                    } 
                } 
 
                $up = $this->model->saveall($data); 
                if ($up) { 
                    echo "";exit(); 
                } else { 
                    echo "";exit(); 
                } 
            } else { 
                echo "";exit(); 
            } 
 
        } 
 
    } 
    public function get_orderdatamore($v, $type) 
    { 
 
        if ($type == 1) { 
            //N1  
            $v['cp_type'] = explode(',', $v['cp_type']); 
            foreach ($v['cp_type'] as $g => &$t) { 
                if ($t == '') { 
                    $t = '11'; 
                } 
                $t = explode('', $t); 
                if (!empty($t)) { 
                    $t = $t[0]; 
                } 
                //$t = $g[0]; 
            } 
            // echo "<pre>"; 
            // print_r($v['cp_type']);exit(); 
        } else { 
            //MN or  
            $v['cp_type2'] = explode(',', $v['cp_type2']); 
            foreach ($v['cp_type2'] as $g => &$t) { 
                $t = explode('', $t); 
                if (!empty($t)) { 
                    $t = $t[0]; 
                } 
                //$t = $g[0]; 
            } 
        } 
 
        // echo "<pre>"; 
        // print_r($v['cp_type2']);exit(); 
        $v['newcount'] = $v['cp_type'][0]; //  
 
        //     
        $v['list'] = db('cp_order_detail')->where('orderno', $v['orderno'])->where('is_zj', 1)->column('id,cc'); // 
        //  $v['list']['352'] = '002'; 
        $v['listpl'] = db('cp_order_detail')->where('orderno', $v['orderno'])->where('is_zj', 1)->column('id,zj_pl'); // 
 
        $v['count4'] = $v['count1'] - $v['newcount']; // 
 
        //  
        $v['unique_arr'] = array_unique($v['list']); 
 
        //  
        $v['repeat_arr'] = array_diff_assoc($v['list'], $v['unique_arr']); 
 
        $nk = 0; 
        $v['newlist'] = array(); 
        foreach ($v['repeat_arr'] as $g => &$t) { 
            $searchkey = array_search($t, $v['unique_arr']); //id 
            if (!empty($searchkey)) { 
                $v['newlist'][$nk] = $v['unique_arr']; 
                // $newlist[$nk] = $unique_arr; 
 
                unset($v['newlist'][$nk][$searchkey]); 
 
                $v['newlist'][$nk][$g] = $t; 
 
                $nk++; 
 
            } 
 
        } 
 
        $v['newlist'][$v['count4']] = $v['unique_arr']; // 
 
        //id 
        foreach ($v['newlist'] as $g => &$t) { 
            foreach ($t as $z => &$x) { 
                $x = $z; 
 
            } 
            $t = array_values($t); // 
        } 
 
        $v['zjbs'] = array(); // 
 
        foreach ($v['newlist'] as $zz => $xx) { 
            //  
            if ($type == 1) { 
                foreach ($v['cp_type'] as $gg => $tt) { 
                    $v['zjbs'][] = $this->getCombinationToString($xx, $tt, []); //   
                } 
            } else { 
                foreach ($v['cp_type2'] as $gg => $tt) { 
                    $v['zjbs'][] = $this->getCombinationToString($xx, $tt, []); //   
                } 
            } 
 
        } 
        // echo "<pre>"; 
        // print_r($v['zjbs']);exit(); 
        if (!empty($v['zjbs'])) { 
            // 
 
            $v['newzhpl'] = array(); // 
            // echo "<pre>"; 
            // echo "231 621,"; 
 
            foreach ($v['zjbs'] as $g => $t) { 
                // print_r($t); 
                foreach ($t as $z => $x) { 
                    $v['newzhpl'][$g][$z] = 0; // 
                    foreach ($x as $zz => $xx) { 
                        //xx=id 
                        // x x2x 
                        //print_r($xx); 
                        if ($v['newzhpl'][$g][$z] != 0) { 
 
                            $v['newzhpl'][$g][$z] = $v['newzhpl'][$g][$z] * $v['listpl'][$xx]; 
                        } else { 
                            //$v['zhpl'] = $v['listpl'][$xx]; 
                            $v['newzhpl'][$g][$z] = $v['listpl'][$xx]; 
                        } 
 
                    } 
 
                } 
            } 
 
            $v['lastjmoney'] = 0; // 
            // x2x 
            foreach ($v['newzhpl'] as $g => &$t) { 
                foreach ($t as $z => &$x) { 
 
                    $x = $x * 2 * $v['bs']; 
                    $v['lastjmoney'] = $v['lastjmoney'] + $x; 
                    // echo $x; 
                } 
            } 
 
        } 
 
        $v['lastjmoney'] = bcadd($v['lastjmoney'], 0, 2); 
        if ($v['lastjmoney'] > 0) { 
            $data['id'] = $v['id']; 
            $data['true_jmoey'] = $v['lastjmoney']; 
            $data['is_zj'] = 1; // 
            $data['status'] = 4; // 
            $data['user_id'] = $v['user_id']; //id  
            $data['orderno'] = $v['orderno']; // 
 
        } else { 
 
            $data['id'] = $v['id']; 
            $data['is_zj'] = 2; // 
            $data['status'] = 3; // 
 
        } 
        return $data; 
 
    } 
    //N1  
    public function get_orderdataone($v) 
    { 
 
        $v['cp_type'] = explode('', $v['cp_type']); 
 
        if ($v['cp_type'][1] == 1) { 
 
            $v['count1'] = $v['cp_type'][0]; // 
 
            // echo $v['count2'];exit(); 
            if ($v['count2'] > $v['count1']) { 
                $type = 1; 
                $v['newcount'] = $v['cp_type'][0]; //  
 
                // N1 
                //     
                $v['list'] = db('cp_order_detail')->where('orderno', $v['orderno'])->where('is_zj', 1)->column('id,cc'); // 
                //  $v['list']['352'] = '002'; 
                $v['listpl'] = db('cp_order_detail')->where('orderno', $v['orderno'])->where('is_zj', 1)->column('id,zj_pl'); // 
 
                $v['count4'] = $v['count1'] - $v['newcount']; // 
 
                //  
                $v['unique_arr'] = array_unique($v['list']); 
 
                //  
                $v['repeat_arr'] = array_diff_assoc($v['list'], $v['unique_arr']); 
 
                $nk = 0; 
                $v['newlist'] = array(); 
                foreach ($v['repeat_arr'] as $g => &$t) { 
                    $searchkey = array_search($t, $v['unique_arr']); //id 
                    if (!empty($searchkey)) { 
                        $v['newlist'][$nk] = $v['unique_arr']; 
                        // $newlist[$nk] = $unique_arr; 
 
                        unset($v['newlist'][$nk][$searchkey]); 
 
                        $v['newlist'][$nk][$g] = $t; 
 
                        $nk++; 
 
                    } 
 
                } 
 
                $v['newlist'][$v['count4']] = $v['unique_arr']; // 
 
                //id 
                foreach ($v['newlist'] as $g => &$t) { 
                    foreach ($t as $z => &$x) { 
                        $x = $z; 
 
                    } 
                    $t = array_values($t); // 
                } 
 
                $v['zjbs'] = array(); // 
 
                foreach ($v['newlist'] as $zz => $xx) { 
                    //  
                    if ($type == 1) { 
                        foreach ($v['cp_type'] as $gg => $tt) { 
                            $v['zjbs'][] = $this->getCombinationToString($xx, $tt, []); //   
                        } 
                    } else { 
                        foreach ($v['cp_type2'] as $gg => $tt) { 
                            $v['zjbs'][] = $this->getCombinationToString($xx, $tt, []); //   
                        } 
                    } 
 
                } 
 
                if (!empty($v['zjbs'])) { 
                    // 
 
                    $v['newzhpl'] = array(); // 
                    // echo "<pre>"; 
                    // echo "231 621,"; 
 
                    foreach ($v['zjbs'] as $g => $t) { 
                        // print_r($t); 
                        foreach ($t as $z => $x) { 
                            $v['newzhpl'][$g][$z] = 0; // 
                            foreach ($x as $zz => $xx) { 
                                //xx=id 
                                // x x2x 
                                //print_r($xx); 
                                if ($v['newzhpl'][$g][$z] != 0) { 
 
                                    $v['newzhpl'][$g][$z] = $v['newzhpl'][$g][$z] * $v['listpl'][$xx]; 
                                } else { 
                                    //$v['zhpl'] = $v['listpl'][$xx]; 
                                    $v['newzhpl'][$g][$z] = $v['listpl'][$xx]; 
                                } 
 
                            } 
 
                        } 
                    } 
 
                    $v['lastjmoney'] = 0; // 
                    // x2x 
                    foreach ($v['newzhpl'] as $g => &$t) { 
                        foreach ($t as $z => &$x) { 
 
                            $x = $x * 2 * $v['bs']; 
                            $v['lastjmoney'] = $v['lastjmoney'] + $x; 
                            // echo $x; 
                        } 
                    } 
 
                } 
                // $v['lastjmoney'] = floor($v['lastjmoney'] * 100) / 100; 
                $v['lastjmoney'] = bcadd($v['lastjmoney'], 0, 2); 
                if ($v['lastjmoney'] > 0) { 
                    $data['id'] = $v['id']; 
                    $data['true_jmoey'] = $v['lastjmoney']; 
                    $data['is_zj'] = 1; // 
                    $data['status'] = 4; // 
                    $data['user_id'] = $v['user_id']; //id  
                    $data['orderno'] = $v['orderno']; // 
 
                } else { 
 
                    $data['id'] = $v['id']; 
                    $data['is_zj'] = 2; // 
                    $data['status'] = 3; // 
 
                } 
            } elseif ($v['count3'] == $v['count1']) { 
                $data['id'] = $v['id']; 
                $data['is_zj'] = 1; // 
                $data['status'] = 4; // 
                $pl = db('cp_order_detail')->where('orderno', $v['orderno'])->where('is_zj', 1)->column('zj_pl'); // 
                $jmoney = 0; // 
 
                foreach ($pl as $g => $t) { 
 
                    if ($jmoney == 0) { 
 
                        $jmoney = 2 * $t * $v['bs']; //2xx 
                    } else { 
                        $jmoney = $jmoney * $t * $v['bs']; //x 
                    } 
 
                } 
 
                //$data['true_jmoey'] = floor($jmoney * 100) / 100; // 
                $data['true_jmoey'] = bcadd($jmoney, 0, 2); // 
 
                $data['user_id'] = $v['user_id']; 
                $data['orderno'] = $v['orderno']; // 
            } else { 
                $data['id'] = $v['id']; 
                $data['is_zj'] = 2; // 
                $data['status'] = 3; // 
 
            } 
            return $data; 
 
        } 
    } 
 
    //   
    public function check_orderhmgd() 
    { 
        //$time = strtotime(date('Y - m - d', time())); // 
        $list = db('cp_order')->where('status', 2)->where('is_check', 0)->where('is_hmcheck', 0)->where('is_h', 'neq', 0)->where('hg_orderno', '0')->where('type', 2)->order('createtime desc')->limit(20)->select(); // 
        // echo "<pre>"; 
        // print_r($list);exit(); 
        if (!empty($list)) { 
            //   
            $gdjl1 = db('config')->where('name', 'gdbl1')->value('value'); // 
            $gdjl2 = db('config')->where('name', 'gdjl2')->value('value'); // 
            foreach ($list as $k => &$v) { 
                $v['count1'] = db('cp_order_detail')->where('orderno', $v['orderno'])->count(); // 
                $v['count2'] = db('cp_order_detail')->where('orderno', $v['orderno'])->where('is_check', 1)->count(); // 
                $v['count3'] = db('cp_order_detail')->where('orderno', $v['orderno'])->where('is_zj', 1)->count(); // 
 
                if ($v['count1'] == $v['count2']) { 
                    //  
                    if (!empty($v['cp_type2'])) { 
                        //MN 
                        $v['cp_type2'] = explode(',', $v['cp_type2']); 
                        foreach ($v['cp_type2'] as $g => &$t) { 
                            $t = explode('', $t); 
                            if (!empty($t)) { 
                                $t = $t[0]; 
                            } 
                            //$t = $g[0]; 
                        } 
                        // echo "<pre>"; 
                        // print_r($v['cp_type2']);exit(); 
                        $v['newcount'] = $v['cp_type'][0]; //  
 
                        //     
                        $v['list'] = db('cp_order_detail')->where('orderno', $v['orderno'])->where('is_zj', 1)->column('id,cc'); // 
                        //  $v['list']['352'] = '002'; 
                        $v['listpl'] = db('cp_order_detail')->where('orderno', $v['orderno'])->where('is_zj', 1)->column('id,zj_pl'); // 
                        $v['count4'] = $v['count1'] - $v['newcount']; // 
 
                        //  
                        $v['unique_arr'] = array_unique($v['list']); 
 
                        //  
                        $v['repeat_arr'] = array_diff_assoc($v['list'], $v['unique_arr']); 
 
                        $nk = 0; 
                        $v['newlist'] = array(); 
                        foreach ($v['repeat_arr'] as $g => &$t) { 
                            $searchkey = array_search($t, $v['unique_arr']); //id 
                            if (!empty($searchkey)) { 
                                $v['newlist'][$nk] = $v['unique_arr']; 
                                // $newlist[$nk] = $unique_arr; 
 
                                unset($v['newlist'][$nk][$searchkey]); 
 
                                $v['newlist'][$nk][$g] = $t; 
 
                                $nk++; 
 
                            } 
 
                        } 
 
                        $v['newlist'][$v['count4']] = $v['unique_arr']; // 
 
                        //id 
                        foreach ($v['newlist'] as $g => &$t) { 
                            foreach ($t as $z => &$x) { 
                                $x = $z; 
 
                            } 
                            $t = array_values($t); // 
                        } 
 
                        $v['zjbs'] = array(); // 
 
                        foreach ($v['newlist'] as $zz => $xx) { 
                            //  
 
                            foreach ($v['cp_type2'] as $gg => $tt) { 
                                $v['zjbs'][] = $this->getCombinationToString($xx, $tt, []); //   
                            } 
 
                        } 
 
                        if (!empty($v['zjbs'])) { 
                            // 
 
                            $v['newzhpl'] = array(); // 
                            // echo "<pre>"; 
                            // echo "231 621,"; 
 
                            foreach ($v['zjbs'] as $g => $t) { 
                                // print_r($t); 
                                foreach ($t as $z => $x) { 
                                    $v['newzhpl'][$g][$z] = 0; // 
                                    foreach ($x as $zz => $xx) { 
                                        //xx=id 
                                        // x x2x 
                                        //print_r($xx); 
                                        if ($v['newzhpl'][$g][$z] != 0) { 
 
                                            $v['newzhpl'][$g][$z] = $v['newzhpl'][$g][$z] * $v['listpl'][$xx]; 
                                        } else { 
                                            //$v['zhpl'] = $v['listpl'][$xx]; 
                                            $v['newzhpl'][$g][$z] = $v['listpl'][$xx]; 
                                        } 
 
                                    } 
 
                                } 
                            } 
 
                            $v['lastjmoney'] = 0; // 
                            // x2x 
                            foreach ($v['newzhpl'] as $g => &$t) { 
                                foreach ($t as $z => &$x) { 
 
                                    $x = $x * 2 * $v['bs']; 
                                    $v['lastjmoney'] = $v['lastjmoney'] + $x; 
                                    // echo $x; 
                                } 
                            } 
 
                        } 
                        //$v['lastjmoney'] = floor($v['lastjmoney'] * 100) / 100; 
                        $v['lastjmoney'] = bcadd($v['lastjmoney'], 0, 2); 
                        //echo $v['lastjmoney'];exit(); 
                        if ($v['lastjmoney'] > 0) { 
                            $data[$k]['id'] = $v['id']; 
                            $data[$k]['z_jmoney'] = $v['lastjmoney']; // 
                            $data[$k]['is_zj'] = 1; // 
                            $data[$k]['status'] = 4; // 
                            $data[$k]['user_id'] = $v['user_id']; //id  
                            $data[$k]['orderno'] = $v['orderno']; // 
                            $data[$k]['is_hmcheck'] = 1; //  
                            if ($v['is_h'] == 2) { 
                                //  
                                $data[$k]['true_jmoey'] = $data[$k]['z_jmoney']; // 
                                $newdata = db('cp_order')->where('status', 2)->where('is_check', 0)->where('is_hmcheck', 0)->where('hg_orderno', $v['orderno'])->column('id,bs'); // 
                                $onemoney = $data[$k]['true_jmoey'] / $v['bs']; // 
                                if (!empty($newdata)) { 
                                    foreach ($newdata as $g => $vv) { 
                                        $data[$g]['id'] = $g; 
                                        $data[$g]['is_zj'] = 1; // 
                                        $data[$g]['status'] = 4; // 
                                        $data[$g]['z_jmoney'] = $onemoney * $vv; 
                                        $data[$g]['true_jmoey'] = $data[$g]['z_jmoney']; // 
 
                                        //$data[$g]['yj'] = floor($data[$g]['true_jmoey'] * $gdjl2 * 100) / 100; // 
                                        $data[$g]['yj'] = bcadd($data[$g]['true_jmoey'] * $gdjl2, 0, 2); // 
                                        // 
                                        $data[$g]['true_jmoey'] = $data[$g]['true_jmoey'] - bcadd($data[$g]['true_jmoey'] * $gdjl2, 0, 2); // 
 
                                        $data[$g]['hm_userid'] = $v['user_id']; 
                                        $data[$g]['is_hmcheck'] = 1; //  
                                    } 
                                } 
                                //  print_r($data);exit(); 
 
                            } else { 
                                // 
                                $data[$k]['true_jmoey'] = ($data[$k]['z_jmoney'] / $v['hm_num']) * $v['hm_num2']; // 
                                $newdata = db('cp_order')->where('status', 2)->where('is_check', 0)->where('is_hmcheck', 0)->where('hg_orderno', $v['orderno'])->column('id,hm_num2'); 
                                if (!empty($newdata)) { 
                                    foreach ($newdata as $g => $vv) { 
                                        $data[$g]['id'] = $g; 
                                        $data[$g]['is_zj'] = 1; // 
                                        $data[$g]['status'] = 4; // 
                                        $data[$g]['z_jmoney'] = $data[$k]['z_jmoney']; 
                                        $data[$g]['true_jmoey'] = ($data[$k]['z_jmoney'] / $v['hm_num']) * $vv; // 
                                        $data[$g]['yj'] = bcadd($data[$g]['true_jmoey'] * $v['yjbl'], 0, 2); // 
 
                                        $data[$g]['true_jmoey'] = $data[$g]['true_jmoey'] - $data[$g]['yj']; //- 
                                        $data[$g]['hm_userid'] = $v['user_id']; 
                                        $data[$g]['is_hmcheck'] = 1; //  
                                    } 
                                } 
 
                            } 
 
                        } else { 
 
                            $data[$k]['id'] = $v['id']; 
                            $data[$k]['is_zj'] = 2; // 
                            $data[$k]['status'] = 3; // 
                            $newdata = db('cp_order')->where('status', 2)->where('is_check', 0)->where('is_hmcheck', 0)->where('hg_orderno', $v['orderno'])->column('id,hm_num2'); 
                            if (!empty($newdata)) { 
                                foreach ($newdata as $g => $vv) { 
                                    $data[$g]['id'] = $g; 
                                    $data[$g]['is_zj'] = 2; // 
                                    $data[$g]['status'] = 3; // 
                                    // 
                                } 
                                if ($v['is_baodi'] == 1) { 
                                    // 
                                    $v['bdpc'] = ($v['money'] / $v['hm_num2']) * $v['baodi_num']; //= /= x  
                                    $v['child_count'] = db('cp_order')->where('status', 2)->where('is_check', 0)->where('is_hmcheck', 0)->where('hg_orderno', $v['orderno'])->count(); // / 
                                    $v['dfbdpc'] = bcadd($v['bdpc'] / $v['child_count'], 0, 2); // 
                                    foreach ($newdata as $g => $vv) { 
                                        # code... 
                                        $data[$g]['bdpc'] = $v['dfbdpc']; // 
                                        $data[$g]['is_hmcheck'] = 1; //  
                                    } 
 
                                } 
 
                            } 
                            // echo "<pre>"; 
                            // print_r($data);exit(); 
                        } 
 
                    } else { 
                        // x1  
                        //x1 8.18   
                        //x1 8.16 x1 
                        // $v['cp_type'] = explode('', $v['cp_type']); 
                        $v['newcheck'] = explode(',', $v['cp_type']); 
                        $v['checkcount'] = count($v['newcheck']); 
                        if ($v['checkcount'] > 1) { 
                            //N1 
                            $data[$k] = $this->get_orderdatamore($v, 1); 
                            // echo "<pre>"; 
                            // print_r($data[$k]);exit(); 
                        } else { 
                            $data[$k] = $this->get_orderdatamore($v, 1); 
                            //  $data[$k] = $this->get_orderdataone($v); 
                        } 
                        // echo "<pre>"; 
                        // print_r($data);exit(); 
                        $data[$k]['is_hmcheck'] = 1; //  
 
                        if ($data[$k]['is_zj'] == 1) { 
                            $data[$k]['z_jmoney'] = $data[$k]['true_jmoey']; 
                            // 
                            if ($v['is_h'] == 2) { 
                                //  
                                $data[$k]['true_jmoey'] = $data[$k]['z_jmoney']; // 
                                $newdata = db('cp_order')->where('status', 2)->where('is_check', 0)->where('is_hmcheck', 0)->where('hg_orderno', $v['orderno'])->column('id,bs'); // 
                                $onemoney = $data[$k]['true_jmoey'] / $v['bs']; // 
                                if (!empty($newdata)) { 
                                    foreach ($newdata as $g => $vv) { 
                                        $data[$g]['id'] = $g; 
                                        $data[$g]['is_zj'] = 1; // 
                                        $data[$g]['status'] = 4; // 
                                        $data[$g]['z_jmoney'] = $onemoney * $vv; 
                                        $data[$g]['true_jmoey'] = $data[$g]['z_jmoney']; // 
 
                                        $data[$g]['yj'] = bcadd($data[$g]['true_jmoey'] * $gdjl2, 0, 2); // 
                                        $data[$g]['true_jmoey'] = $data[$g]['true_jmoey'] - bcadd($data[$g]['true_jmoey'] * $gdjl2, 0, 2); // 
 
                                        $data[$g]['hm_userid'] = $v['user_id']; 
                                        $data[$g]['is_hmcheck'] = 1; //  
                                    } 
                                } 
                                //  print_r($data);exit(); 
 
                            } else { 
                                // 
                                $data[$k]['true_jmoey'] = ($data[$k]['z_jmoney'] / $v['hm_num']) * $v['hm_num2']; // 
                                $newdata = db('cp_order')->where('status', 2)->where('is_check', 0)->where('is_hmcheck', 0)->where('hg_orderno', $v['orderno'])->column('id,hm_num2'); 
                                if (!empty($newdata)) { 
                                    foreach ($newdata as $g => $vv) { 
                                        $data[$g]['id'] = $g; 
                                        $data[$g]['is_zj'] = 1; // 
                                        $data[$g]['status'] = 4; // 
                                        $data[$g]['z_jmoney'] = $data[$k]['z_jmoney']; 
                                        $data[$g]['true_jmoey'] = ($data[$k]['z_jmoney'] / $v['hm_num']) * $vv; // 
                                        $data[$g]['yj'] = bcadd($data[$g]['true_jmoey'] * $v['yjbl'], 0, 2); // 
                                        $data[$g]['true_jmoey'] = $data[$g]['true_jmoey'] - $data[$g]['yj']; //- 
                                        $data[$g]['hm_userid'] = $v['user_id']; 
                                        $data[$g]['is_hmcheck'] = 1; //  
                                    } 
                                } 
 
                            } 
                        } else { 
                            // 
                            $data[$k]['id'] = $v['id']; 
                            $data[$k]['is_zj'] = 2; // 
                            $data[$k]['status'] = 3; // 
                            $newdata = db('cp_order')->where('status', 2)->where('is_check', 0)->where('is_hmcheck', 0)->where('hg_orderno', $v['orderno'])->column('id,hm_num'); 
                            if (!empty($newdata)) { 
                                foreach ($newdata as $g => $vv) { 
                                    $data[$g]['id'] = $g; 
                                    $data[$g]['is_zj'] = 2; // 
                                    $data[$g]['status'] = 3; // 
                                    // 
                                } 
                                if ($v['is_baodi'] == 1) { 
                                    // 
                                    $v['bdpc'] = ($v['money'] / $v['hm_num2']) * $v['baodi_num']; //= /= x  
                                    $v['child_count'] = db('cp_order')->where('status', 2)->where('is_check', 0)->where('is_hmcheck', 0)->where('hg_orderno', $v['orderno'])->count(); // / 
                                    $v['dfbdpc'] = bcadd($v['bdpc'] / $v['child_count'], 0, 2); // 
                                    foreach ($newdata as $g => $vv) { 
                                        # code... 
                                        $data[$g]['bdpc'] = $v['dfbdpc']; // 
                                        $data[$g]['is_hmcheck'] = 1; //  
                                    } 
 
                                } 
 
                            } 
                        } 
 
                    } 
 
                } else { 
                    //  
                    $data[$k]['id'] = $v['id']; 
                    $data[$k]['is_check'] = 1; // 
 
                } 
            } 
            // echo "<pre>"; 
            // print_r($data);exit(); 
            if (!empty($data)) { 
 
                $this->model = new \app\common\model\CpOrder; 
 
                $up = $this->model->saveall($data); 
                if ($up) { 
                    echo "";exit(); 
                } else { 
                    echo "";exit(); 
                } 
            } else { 
                echo "";exit(); 
            } 
 
        } 
 
    } 
//    
    public function check_hmgdjmoney() 
    { 
        $list = db('cp_order')->where('is_hmcheck', 1)->where('is_h', 'neq', 0)->where('type', 2)->order('createtime desc')->limit(20)->select(); //  
        // echo "<pre>"; 
        // print_r($list);exit(); 
        $xejmoney = db('config')->where('name', 'jmoney')->value('value'); // 
 
        if (!empty($list)) { 
            foreach ($list as $k => &$v) { 
                $data[$k]['id'] = $v['id']; 
                $data[$k]['is_hmcheck'] = 2; // 
                $data[$k]['status'] = $v['status']; // 
                if ($v['status'] == 4) { 
                    // 
                    if ($v['true_jmoey'] > $xejmoney) { 
                        $is_check = 0; // 01 
                    } else { 
                        $is_check = 1; 
                    } 
                    //echo $v['true_jmoey'];exit(); 
                    // 
 
                    if ($v['true_jmoey'] > 0) { 
                        UserModel::jmoney($v['true_jmoey'], $v['user_id'], '4', '', '+' . $v['true_jmoey'] . '', $v['orderno'], $is_check); //4  
                    } 
 
                    if (!empty($v['hm_userid'])) { 
                        //id 
                        if ($v['yj'] > 0) { 
                            UserModel::jmoney($v['yj'], $v['hm_userid'], '4', '', '+' . $v['yj'] . '', $v['orderno'], $is_check); //4  
                        } 
 
                    } 
 
                } else { 
                    if ($v['bdpc'] > $xejmoney) { 
                        $is_check = 0; // 01 
                    } else { 
                        $is_check = 1; 
                    } 
                    // 824 
                    // UserModel::jmoney($v['bdpc'], $v['user_id'], '4', '', '+' . $v['bdpc'] . '', $v['orderno'], $is_check); //4        
                } 
            } 
            if (!empty($data)) { 
                $this->model = new \app\common\model\CpOrder; 
                $up = $this->model->saveall($data); 
                if ($up) { 
                    echo "";exit(); 
                } else { 
                    echo "";exit(); 
                } 
            } else { 
                echo "";exit(); 
            } 
        } else { 
            echo "";exit(); 
        } 
 
    } 
 
/** 
 *  
 */ 
    public function upload() 
    { 
        Config::set('default_return_type', 'json'); 
        //cdnurl,cdnurl 
        Config::set('upload . cdnurl', ''); 
 
        $attachment = null; 
        // 
        $file = $this->request->file('file'); 
        try { 
            $upload = new Upload($file); 
            $attachment = $upload->upload(); 
        } catch (UploadException $e) { 
            $this->error($e->getMessage()); 
        } 
        $this->success('', cdnurl($attachment->url, true), 0); 
        //$this->success(__('Uploadedsuccessful'), '', ['url' => $attachment->url, 'fullurl' => cdnurl($attachment->url, true)]); 
 
    } 
} 
 ?>

Did this file decode correctly?

Original Code

<?php

namespace app\api\controller;

use addons\shopro\model\User as UserModel;
use app\common\controller\Api;
use app\common\library\Upload;
use think\Config;
use think\Db;

/**
 * 
 */
class Index extends Api
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];

    /**
     * 
     *
     */
    public function index()
    {
        $this->success('');
    }
    //
    public function zcglnew()
    {
        $post = $this->request->post();
        $time = strtotime(date('2023-08-28', time())); //12
        //  $time = 1689696000; //
        // $time = time() - 300; //-5
        $find = db('soccer')->where('ids', 27)->where('time', $time)->find();

        $getresp = $find['content'];

        $resp = $getresp;
        $resp = json_decode($resp, true);

        $jclist = $resp['list']['0']['jczq']; //
        // echo "<pre>";
        // print_r($jclist);exit();
        $newjc = array();
        //
        foreach ($jclist as $k => &$v) {
            $newjc[$k] = $v['id']; //ID
        }
        // echo "<pre>";
        // print_r($jclist);exit();

        $count2 = db('soccer_zc')->where('jcid', 'in', $newjc)->where('matchId', 'null')->count();

        //echo $count2;exit();
        if ($count2 > 0) {
            $list2 = db('soccer_zc')->where('jcid', 'in', $newjc)->where('matchId', 'null')->field('id,jcid,matchtime,startTime')->select();

            $data2 = array(); //
            foreach ($list2 as $k => &$v) {
                $v['jckey'] = array_search($v['jcid'], $newjc); //id
                if ($jclist[$v['jckey']]['matchTime'] == $v['matchtime']) {
                    // matchId 
                    $data2[$k]['id'] = $v['id'];
                    $data2[$k]['matchId'] = $jclist[$v['jckey']]['matchId'];
                    //$data[$k]['startTime'] = $jclist[$v['jckey']]['startTime'];
                    $data2[$k]['isTurn'] = $jclist[$v['jckey']]['isTurn'];
                    if ($data2[$k]['isTurn'] == 1) {
                        //
                        $data2[$k]['homeId'] = $jclist[$v['jckey']]['awayId'];
                        $data2[$k]['awayId'] = $jclist[$v['jckey']]['homeId'];
                    } else {
                        $data2[$k]['homeId'] = $jclist[$v['jckey']]['homeId'];
                        $data2[$k]['awayId'] = $jclist[$v['jckey']]['awayId'];
                    }
                }
            }
            // echo "<pre>";
            // print_r($list2);exit();
            if (!empty($data2)) {
                $this->model2 = new \app\common\model\SoccerZc;
                $up2 = $this->model2->saveall($data2);
                if ($up2) {
                    echo '';exit();
                } else {
                    echo "";exit();
                }
            }
        } else {
            echo "";exit();
        }
    }
    // matchId 
    public function zcgl()
    {
        $post = $this->request->post();
        $time = strtotime(date('Y-m-d', time())); //12
        //  $time = 1689696000; //
        // $time = time() - 300; //-5
        $find = db('soccer')->where('ids', 27)->where('time', $time)->find();
        // $find = db('soccer')->where('ids', 56)->where('time', $time)->find(); //5
        $url = "http://interface.bet007.com/lottery/MatchidInterface.aspx?key=200AB2AB2B444E35";
        $getresp = $this->curlGet($url);
        // print_r($getresp);exit();
        if (!empty($find)) {
            //

            $data['content'] = $getresp;
            $data['create_time'] = time();
            //  $data['id'] = $find['id'];
            $insert = db('soccer')->where('id', $find['id'])->update($data);
        } else {
            //

            $data['content'] = $getresp;
            $data['create_time'] = time();
            $data['ids'] = 27;
            $data['time'] = $time;
            $insert = db('soccer')->insert($data);
        }
        $resp = $getresp;
        $resp = json_decode($resp, true);
        $jclist = $resp['list']['0']['jczq']; //

        $newjc = array();
        //
        foreach ($jclist as $k => &$v) {
            $newjc[$k] = $v['id']; //ID
        }
        // echo "<pre>";
        // print_r($jclist);exit();
        //idmatchId
        $count = db('soccer_jc')->where('jcid', 'in', $newjc)->where('matchId', 'null')->count();

        $count2 = db('soccer_zc')->where('jcid', 'in', $newjc)->where('matchId', 'null')->count();
        // echo "<pre>";
        // print_R($count2);exit();
        if ($count > 0) {
            // id 
            $list = db('soccer_jc')->where('jcid', 'in', $newjc)->where('matchId', 'null')->field('id,jcid,matchtime,startTime')->select();

            $data = array(); //
            foreach ($list as $k => &$v) {
                $v['jckey'] = array_search($v['jcid'], $newjc); //id
                if ($jclist[$v['jckey']]['matchTime'] == $v['matchtime']) {
                    // matchId 
                    $data[$k]['id'] = $v['id'];
                    $data[$k]['matchId'] = $jclist[$v['jckey']]['matchId'];
                    //$data[$k]['startTime'] = $jclist[$v['jckey']]['startTime'];
                    $data[$k]['isTurn'] = $jclist[$v['jckey']]['isTurn'];
                    if ($data[$k]['isTurn'] == 1) {
                        //
                        $data[$k]['homeId'] = $jclist[$v['jckey']]['awayId'];
                        $data[$k]['awayId'] = $jclist[$v['jckey']]['homeId'];
                    } else {
                        $data[$k]['homeId'] = $jclist[$v['jckey']]['homeId'];
                        $data[$k]['awayId'] = $jclist[$v['jckey']]['awayId'];
                    }
                }
            }

            if (!empty($data)) {
                //
                $this->model = new \app\common\model\SoccerJc;
                $up = $this->model->saveall($data);

                if ($up) {
                    echo "";
                } else {
                    echo "";
                }
            }

        } else {
            echo "";
        }
        //echo $count2;exit();
        if ($count2 > 0) {
            $list2 = db('soccer_zc')->where('jcid', 'in', $newjc)->where('matchId', 'null')->field('id,jcid,matchtime,startTime')->select();

            $data2 = array(); //
            foreach ($list2 as $k => &$v) {
                $v['jckey'] = array_search($v['jcid'], $newjc); //id
                if ($jclist[$v['jckey']]['matchTime'] == $v['matchtime']) {
                    // matchId 
                    $data2[$k]['id'] = $v['id'];
                    $data2[$k]['matchId'] = $jclist[$v['jckey']]['matchId'];
                    //$data[$k]['startTime'] = $jclist[$v['jckey']]['startTime'];
                    $data2[$k]['isTurn'] = $jclist[$v['jckey']]['isTurn'];
                    if ($data2[$k]['isTurn'] == 1) {
                        //
                        $data2[$k]['homeId'] = $jclist[$v['jckey']]['awayId'];
                        $data2[$k]['awayId'] = $jclist[$v['jckey']]['homeId'];
                    } else {
                        $data2[$k]['homeId'] = $jclist[$v['jckey']]['homeId'];
                        $data2[$k]['awayId'] = $jclist[$v['jckey']]['awayId'];
                    }
                }
            }
            // echo "<pre>";
            // print_r($list2);exit();
            if (!empty($data2)) {
                $this->model2 = new \app\common\model\SoccerZc;
                $up2 = $this->model2->saveall($data2);
                if ($up2) {
                    echo '';exit();
                } else {
                    echo "";exit();
                }
            }
        } else {
            echo "";exit();
        }

    }
    //  5  
    public function get_hmorder()
    {
        //id
        $lists1 = db('cp_order')->where('is_h', 1)->where('status', 6)->where('jztime', 'elt', time())->limit(20)->column('id');
        //id 
        $lists2 = db('cp_order')->field('id,user_id,money,orderno')->where('is_h', 1)->where('status', 6)->where('jztime', 'elt', time())->limit(20)->select();

        if (!empty($lists1)) {
            $data['status'] = 5; //
            // echo "<pre>";
            // print_r($lists2);exit();
            $up1 = db('cp_order')->where('id', 'in', $lists1)->update($data);
            foreach ($lists2 as $k => $v) {
                UserModel::money($v['money'], $v['user_id'], '9', '', '' . $v['money'] . '', $v['orderno'], 1); //3    
            }
            if ($up1) {
                echo "";
            } else {
                echo "";
            }
        } else {
            echo "";
        }

    }
    //5
    public function get_jczqjk()
    {

        $post = $this->request->post();

        $time = time() - 300; //-5
        $find = db('soccer')->where('ids', 56)->where('create_time', 'egt', $time)->order('id desc')->find(); //5
        if (empty($find)) {
            // 
            // $resp = '';
            // $data['content'] = $resp;
            // $data['create_time'] = time();
            // $data['ids'] = 56;
            // $insert = db('soccer')->insert($data);
            $find = db('soccer')->where('ids', 56)->order('id desc')->find(); // 
            $resp = $find['content'];
        } else {
            $resp = $find['content'];
        }
        // echo "<pre>";
        // var_dump($resp);exit();
        $resp = json_decode($resp, true);

        $this->success('', $resp, 0);
    }
    //
    public function jclist()
    {
        $newlist = db('soccer_jc')->group('time')->order('time desc')->limit(10)->column('id,time');
        $list = array();
        foreach ($newlist as $k => $v) {
            $list[$k]['id'] = $k;
            $list[$k]['time'] = $v;

        }
        // echo "<pre>";
        // print_r($list);exit();
        // $list = db('soccer')->where('ids', 53)->field('id,time')->order('time desc')->limit(10)->select(); //10
        $week_array = array("", "", "", "", "", "", "");
        foreach ($list as $k => &$v) {

            $v['newtime'] = date('Y-m-d', $v['time']);

            $week = date("w", $v['time']);
            $v['date'] = '' . $week_array[$week];
            // $v['num1'] = db('soccer')->where('time', $v['time'])->where('')
            $v['num1'] = db('soccer_jc')->where('time', $v['time'])->where('spfsge', 'spf3')->count(); //
            $v['num2'] = db('soccer_jc')->where('time', $v['time'])->where('spfsge', 'spf1')->count(); //
            $v['num3'] = db('soccer_jc')->where('time', $v['time'])->where('spfsge', 'spf0')->count(); //

            $v['bisainum'] = db('soccer_jc')->where('time', $v['time'])->where('state', '-1')->count(); //

        }
        $this->success('', $list, 0);

    }
    //
    public function testjgnew()
    {
        $time = strtotime(date('Y-m-d', time())); //

        $url = "http://interface.bet007.com/lottery/Zq_BF.aspx?key=200AB2AB2B444E35";
        // &&cmd=result
        $getresp = $this->curlGet($url);

        $getresp = json_decode($getresp, true);
        $data = $getresp['matchList']; //
        // echo "<pre>";
        // print_r($data);exit();
        $this->model = new \app\common\model\SoccerZc;

        $newarr = array(); //
        foreach ($data as $k => $v) {
            $newarr[$k] = $v['matchId']; //mactchid
        }
        // echo "<pre>";
        // print_r($newarr);exit();
        $where['matchId'] = ['in', $newarr];
        // $where['time'] = ['eq', $time]; // 814 
        $check = db('soccer_zc')->where($where)->where('state', 'neq', '-1')->count(); // 
        $list = db('soccer_zc')->where($where)->where('state', 'neq', '-1')->select();
        $check2 = db('soccer_zc')->where($where)->where('state', 'neq', '-1')->count(); // 
        $list2 = db('soccer_zc')->where($where)->where('state', 'neq', '-1')->select();
        // echo "<pre>";
        // print_r($list);exit();
        // echo $check;exit();
        $newdata = array();
        if ($check > 0) {
            // 
            $sl = db('soccer_zc')->where($where)->where('state', 'neq', '-1')->column('id, matchId'); // 
            // echo "<pre>";
            // print_r($sl);exit();
            $goal = db('soccer_zc')->where($where)->where('state', 'neq', '-1')->column('id, rqspf'); //
            $bf = db('soccer_zc')->where($where)->where('state', 'neq', '-1')->column('id, bf'); //
            $spf = db('soccer_zc')->where($where)->where('state', 'neq', '-1')->column('id, spf'); //

            $rqspf = db('soccer_zc')->where($where)->where('state', 'neq', '-1')->column('id, rqspf'); //
            //$bqc = db('soccer_zc')->where($where)->where('state', 'neq', '-1')->column('id, bqc'); //
            // echo "<pre>";
            // print_r($bqc);exit();
            $jq = db('soccer_zc')->where($where)->where('state', 'neq', '-1')->column('id, jq'); //
            $is_turn = db('soccer_zc')->where($where)->where('state', 'neq', '-1')->column('id, isTurn'); //
            foreach ($goal as $k => &$v) {
                parse_str($v, $newgoal);
                $v = $newgoal['goal'];
            }
            foreach ($bf as $k => &$v) {
                parse_str($v, $newgoal);
                $v = $newgoal;
            }
            foreach ($rqspf as $k => &$v) {
                parse_str($v, $newgoal);
                $v = $newgoal;
            }
            // foreach ($bqc as $k => &$v) {
            //     parse_str($v, $newgoal);
            //     $v = $newgoal;
            // }
            foreach ($jq as $k => &$v) {
                parse_str($v, $newgoal);
                $v = $newgoal;
            }
            foreach ($spf as $k => &$v) {
                parse_str($v, $newgoal);
                $v = $newgoal;
            }

            // echo "<pre>";
            // print_r($sl);exit();
            foreach ($data as $k => &$v) {
                $v['searchkey'] = array_search($v['matchId'], $sl); //

                if (!empty($v['searchkey']) || $v['searchkey'] === 0) {
                    // echo $v['searchkey'];exit();
                    //
                    if ($v['state'] == '-1') {
                        // 

                        $newdata[$k]['id'] = $v['searchkey']; //id
                        $newdata[$k]['leagueId'] = $v['leagueId']; //id
                        $newdata[$k]['state'] = $v['state'];
                        $newdata[$k]['startTime'] = $v['startTime'];
                        if ($is_turn[$v['searchkey']] == 1) {
                            //
                            $newdata[$k]['homeScore'] = $v['awayScore']; //
                            $newdata[$k]['awayScore'] = $v['homeScore']; //
                            $newdata[$k]['homeHalfScore'] = $v['awayHalfScore']; //
                            $newdata[$k]['awayHalfScore'] = $v['homeHalfScore']; //
                            $newdata[$k]['homeRed'] = $v['awayRed']; //
                            $newdata[$k]['homeYellow'] = $v['awayYellow']; //
                            $newdata[$k]['awayRed'] = $v['homeRed']; //
                            $newdata[$k]['awayYellow'] = $v['homeYellow']; //
                            $newdata[$k]['homeCorner'] = $v['awayCorner']; //
                            $newdata[$k]['awayCorner'] = $v['homeCorner']; //
                            $newdata[$k]['homeRank'] = $v['awayRank']; //
                            $newdata[$k]['awayRank'] = $v['homeRank']; //
                        } else {
                            $newdata[$k]['homeScore'] = $v['homeScore']; //
                            $newdata[$k]['awayScore'] = $v['awayScore']; //
                            $newdata[$k]['homeHalfScore'] = $v['homeHalfScore']; //
                            $newdata[$k]['awayHalfScore'] = $v['awayHalfScore']; //
                            $newdata[$k]['homeRed'] = $v['homeRed']; //
                            $newdata[$k]['homeYellow'] = $v['homeYellow']; //
                            $newdata[$k]['awayRed'] = $v['awayRed']; //
                            $newdata[$k]['awayYellow'] = $v['awayYellow']; //
                            $newdata[$k]['homeCorner'] = $v['homeCorner']; //
                            $newdata[$k]['awayCorner'] = $v['awayCorner']; //
                            $newdata[$k]['homeRank'] = $v['homeRank']; //
                            $newdata[$k]['awayRank'] = $v['awayRank']; //
                        }

                        $newdata[$k]['isNeutral'] = $v['isNeutral']; //
                        $newdata[$k]['hasLineup'] = $v['hasLineup']; //
                        $newdata[$k]['explain'] = $v['explain']; //
                        $newdata[$k]['extraExplain'] = $v['extraExplain']; //2
                        if ($is_turn[$v['searchkey']] == 1) {
                            ////
                            $v['sg'] = $this->getcg($v['awayScore'], $v['homeScore'], $v['awayHalfScore'], $v['homeHalfScore'], $goal[$v['searchkey']]);
                        } else {
                            $v['sg'] = $this->getcg($v['homeScore'], $v['awayScore'], $v['homeHalfScore'], $v['awayHalfScore'], $goal[$v['searchkey']]);
                        }
                        //
                        // if ($v['sg']['bfcg'] == 'sl5') {

                        //     echo "<pre>";
                        //     print_r($v['sg']);exit();
                        // }
                        // echo "<pre>";
                        // print_r($v['sg']);
                        $newdata[$k]['bfsg'] = $v['sg']['bf']; //
                        $newdata[$k]['rq'] = $goal[$v['searchkey']]; //
                        $newdata[$k]['bfpl'] = $bf[$v['searchkey']][$v['sg']['bfcg']]; //
                        $newdata[$k]['rqspfsg'] = $v['sg']['rqspf']; //
                        $newdata[$k]['rqspfpl'] = $rqspf[$v['searchkey']][$v['sg']['rqspfcg']]; //
                        $newdata[$k]['zjq'] = $v['sg']['jq']; //
                        $newdata[$k]['zjqpl'] = $jq[$v['searchkey']][$v['sg']['jqcg']]; //
                        $newdata[$k]['bqcsg'] = $v['sg']['bqc']; //
                        //$newdata[$k]['bqcpl'] = $bqc[$v['searchkey']][$v['sg']['bqccg']]; //

                        $newdata[$k]['bbfsg'] = $v['homeHalfScore'] . ':' . $v['awayHalfScore']; // 
                        $newdata[$k]['spfsg'] = $v['sg']['spftext']; //
                        if (isset($spf[$v['searchkey']][$v['sg']['spfcg']])) {
                            $newdata[$k]['spfpl'] = $spf[$v['searchkey']][$v['sg']['spfcg']]; //
                        }

                        $newdata[$k]['spfsge'] = $v['sg']['spfcg']; //
                        $newdata[$k]['rqspfsge'] = $v['sg']['rqspfcg']; //
                        $newdata[$k]['bfsge'] = $v['sg']['bfcg']; //
                        $newdata[$k]['zjqsge'] = $v['sg']['jqcg']; //
                        $newdata[$k]['bqcsge'] = $v['sg']['bqccg']; //
                        // if ($v['matchId'] == 2337322) {
                        //     print_r($newdata[$k]);exit();

                        // }
                    } else {
                        //
                        if ($v['state'] != 0) {
                            //  
                            $newdata[$k]['id'] = $v['searchkey']; //id
                            $newdata[$k]['leagueId'] = $v['leagueId']; //id
                            $newdata[$k]['state'] = $v['state'];
                            $newdata[$k]['startTime'] = $v['startTime'];
                            $newdata[$k]['bbfsg'] = $v['homeHalfScore'] . ':' . $v['awayHalfScore']; // 
                            if ($is_turn[$v['searchkey']] == 1) {
                                //
                                $newdata[$k]['homeScore'] = $v['awayScore']; //
                                $newdata[$k]['awayScore'] = $v['homeScore']; //
                                $newdata[$k]['homeHalfScore'] = $v['awayHalfScore']; //
                                $newdata[$k]['awayHalfScore'] = $v['homeHalfScore']; //
                                $newdata[$k]['homeRed'] = $v['awayRed']; //
                                $newdata[$k]['homeYellow'] = $v['awayYellow']; //
                                $newdata[$k]['awayRed'] = $v['homeRed']; //
                                $newdata[$k]['awayYellow'] = $v['homeYellow']; //
                                $newdata[$k]['homeCorner'] = $v['awayCorner']; //
                                $newdata[$k]['awayCorner'] = $v['homeCorner']; //
                                $newdata[$k]['homeRank'] = $v['awayRank']; //
                                $newdata[$k]['awayRank'] = $v['homeRank']; //
                            } else {
                                $newdata[$k]['homeScore'] = $v['homeScore']; //
                                $newdata[$k]['awayScore'] = $v['awayScore']; //
                                $newdata[$k]['homeHalfScore'] = $v['homeHalfScore']; //
                                $newdata[$k]['awayHalfScore'] = $v['awayHalfScore']; //
                                $newdata[$k]['homeRed'] = $v['homeRed']; //
                                $newdata[$k]['homeYellow'] = $v['homeYellow']; //
                                $newdata[$k]['awayRed'] = $v['awayRed']; //
                                $newdata[$k]['awayYellow'] = $v['awayYellow']; //
                                $newdata[$k]['homeCorner'] = $v['homeCorner']; //
                                $newdata[$k]['awayCorner'] = $v['awayCorner']; //
                                $newdata[$k]['homeRank'] = $v['homeRank']; //
                                $newdata[$k]['awayRank'] = $v['awayRank']; //
                            }

                            $newdata[$k]['isNeutral'] = $v['isNeutral']; //
                            $newdata[$k]['hasLineup'] = $v['hasLineup']; //
                            $newdata[$k]['explain'] = $v['explain']; //
                            $newdata[$k]['extraExplain'] = $v['extraExplain']; //2
                        }
                    }
                }
            }
            // echo "<pre>";
            // print_r($data);exit();
            if (!empty($newdata)) {
                $insert = $this->model->saveall($newdata);

                if ($insert) {
                    echo "";exit();
                } else {
                    echo "";exit();
                }
            } else {
                echo "";exit();
            }

        }
    }

    // 
    public function bfjc()
    {
        $post = $this->request->post();
        $time = strtotime($post['time']);
        $time3 = $time + 86400; //
        $time = date('Y-m-d 11:00:00', $time);
        //$time = date('Y-m-d', $time);
        $time3 = date('Y-m-d H:i:s', $time3);
        $time2 = strtotime($post['time']);
        //826 
        //913 where('time', $time2)->
        $ids = db('soccer_jc')->where('jctime', 'egt', $time)->where('jctime', 'lt', $time3)->column('matchId', 'id');
        //echo db('soccer_jc')->getlastsql();exit();
        // echo "<pre>";
        //  print_r($ids);exit();
        //$ids = db('soccer_zc')->order('state desc')->where('bstime', $time)->column('id', 'jcid');
        $newarr = array();
        foreach ($ids as $k => &$v) {

            $newarr[] = $v;

        }
        $list = db('soccer_zc')->field('matchtime,jcid,league,home,away,state,spf,rqspf,bfsg,bbfsg,matchId,homeScore,awayScore,isTurn,homeId,awayId,startTime')->order('state desc')->order('matchtime asc')->where('matchId', 'in', $newarr)->select(); //
        foreach ($list as $k => &$v) {

            $v['newrqspf'] = '';
            parse_str($v['rqspf'], $v['newrqspf']); //
            unset($v['rqspf']);
            $v['newspf'] = '';
            parse_str($v['spf'], $v['newspf']); //
            unset($v['spf']);
            //
            $find = db('soccer_tj')->where('matchId', $v['matchId'])->find();
            if (!empty($find)) {
                $v['eventList'] = $find['eventList']; //
                $v['technic'] = $find['technic']; //
                $v['penalty'] = $find['penalty']; //
            } else {
                $v['eventList'] = '';
                $v['technic'] = '';
                $v['penalty'] = '';
            }

            if (!empty($v['eventList'])) {
                $v['eventList'] = json_decode($v['eventList'], true);

            }
            if (!empty($v['penalty'])) {

                $v['penalty'] = json_decode($v['penalty'], true);
            }
            if ($v['isTurn'] == 1) {
                //
                $v['bf'] = $v['awayScore'] . ':' . $v['homeScore'];
            } else {
                $v['bf'] = $v['homeScore'] . ':' . $v['awayScore'];
            }

            if (!empty($v['homeId'])) {
                $homelogo = db('soccer_zl')->where('teamId', $v['homeId'])->find(); //
                if (!empty($homelogo['logo'])) {
                    if (!empty($homelogo['logolink'])) {
                        $v['homelogo'] = $homelogo['logolink']; //logo
                    } else {
                        $v['homelogo'] = $this->getimg($homelogo['logo'], $homelogo['teamId']); //
                        if ($v['homelogo'] != 0) {
                            //
                            $v['homelogo'] = $this->request->domain() . '/static/logo/' . $homelogo['teamId'] . '.png';
                            $data['logolink'] = $v['homelogo'];
                            $up = db('soccer_zl')->where('id', $homelogo['id'])->update($data);
                        } else {
                            $v['homelogo'] = '';
                        }
                    }
                } else {
                    $v['homelogo'] = ''; //logo
                }
            } else {
                $v['homelogo'] = ''; //logo
            }
            if (!empty($v['awayId'])) {
                $awaylogo = db('soccer_zl')->where('teamId', $v['awayId'])->find(); //

                if (!empty($awaylogo['logo'])) {
                    if (!empty($awaylogo['logolink'])) {
                        $v['awaylogo'] = $awaylogo['logolink']; //logo
                    } else {
                        //echo $awaylogo['teamId'];exit();
                        $v['awaylogo'] = $this->getimg($awaylogo['logo'], $awaylogo['teamId']); //
                        if ($v['awaylogo'] != 0) {
                            //
                            //echo $this->request->domain() . '/static/logo/' . $awaylogo['teamId'] . '.png';exit();
                            $v['awaylogo'] = $this->request->domain() . '/static/logo/' . $awaylogo['teamId'] . '.png';
                            $data['logolink'] = $v['awaylogo'];
                            $up = db('soccer_zl')->where('id', $awaylogo['id'])->update($data);
                        } else {
                            $v['awaylogo'] = '';
                        }
                    }
                } else {
                    $v['awaylogo'] = ''; //logo
                }
            } else {
                $v['awaylogo'] = ''; //logo
            }

        }
        //$list = array_unique($list);
        $this->success('', $list, 0);
    }
    // 
    public function bfbd()
    {
        $post = $this->request->post();
        $time = strtotime($post['time']);
        $ids = db('soccer_bd')->order('state desc')->where('jctime2', $time)->column('id', 'jcid');
        $newarr = array();
        foreach ($ids as $k => &$v) {

            $newarr[] = $v;

        }
        $list = db('soccer_bd')->field('matchtime,jcid,league,home,away,state,spf,bfsg,bbfsg,matchId,homeScore,awayScore,isTurn,homeId,awayId,startTime')->order('jcid asc')->where('id', 'in', $newarr)->select(); //
        foreach ($list as $k => &$v) {

            // $v['newrqspf'] = '';
            // parse_str($v['rqspf'], $v['newrqspf']); //
            // unset($v['rqspf']);
            // $v['newspf'] = '';
            // parse_str($v['spf'], $v['newspf']); //
            // unset($v['spf']);

            $find = db('soccer_tj')->where('matchId', $v['matchId'])->find();
            if (!empty($find)) {
                $v['eventList'] = $find['eventList']; //
                $v['technic'] = $find['technic']; //
                $v['penalty'] = $find['penalty']; //
            } else {
                $v['eventList'] = '';
                $v['technic'] = '';
                $v['penalty'] = '';
            }
            if (!empty($v['eventList'])) {
                $v['eventList'] = json_decode($v['eventList'], true);

            }
            if (!empty($v['penalty'])) {

                $v['penalty'] = json_decode($v['penalty'], true);
            }
            if ($v['isTurn'] == 1) {
                //
                $v['bf'] = $v['awayScore'] . ':' . $v['homeScore'];
            } else {
                $v['bf'] = $v['homeScore'] . ':' . $v['awayScore'];
            }

            if (!empty($v['homeId'])) {
                $homelogo = db('soccer_zl')->where('teamId', $v['homeId'])->find(); //
                if (!empty($homelogo['logo'])) {
                    if (!empty($homelogo['logolink'])) {
                        $v['homelogo'] = $homelogo['logolink']; //logo
                    } else {
                        $v['homelogo'] = $this->getimg($homelogo['logo'], $homelogo['teamId']); //
                        if ($v['homelogo'] != 0) {
                            //
                            $v['homelogo'] = $this->request->domain() . '/static/logo/' . $homelogo['teamId'] . '.png';
                            $data['logolink'] = $v['homelogo'];
                            $up = db('soccer_zl')->where('id', $homelogo['id'])->update($data);
                        } else {
                            $v['homelogo'] = '';
                        }
                    }
                } else {
                    $v['homelogo'] = ''; //logo
                }
            } else {
                $v['homelogo'] = ''; //logo
            }
            if (!empty($v['awayId'])) {
                $awaylogo = db('soccer_zl')->where('teamId', $v['awayId'])->find(); //

                if (!empty($awaylogo['logo'])) {
                    if (!empty($awaylogo['logolink'])) {
                        $v['awaylogo'] = $awaylogo['logolink']; //logo
                    } else {
                        //echo $awaylogo['teamId'];exit();
                        $v['awaylogo'] = $this->getimg($awaylogo['logo'], $awaylogo['teamId']); //
                        if ($v['awaylogo'] != 0) {
                            //
                            //echo $this->request->domain() . '/static/logo/' . $awaylogo['teamId'] . '.png';exit();
                            $v['awaylogo'] = $this->request->domain() . '/static/logo/' . $awaylogo['teamId'] . '.png';
                            $data['logolink'] = $v['awaylogo'];
                            $up = db('soccer_zl')->where('id', $awaylogo['id'])->update($data);
                        } else {
                            $v['awaylogo'] = '';
                        }
                    }
                } else {
                    $v['awaylogo'] = ''; //logo
                }
            } else {
                $v['awaylogo'] = ''; //logo
            }

        }
        //$list = array_unique($list);
        $this->success('', $list, 0);
    }

    //
    public function getimg($logo, $name)
    {
        $logo = $logo . '?win007=sell'; //logo 
        if (!empty($name)) {
            $name = './static/logo/' . $name . '.png';
            $ch = curl_init();
            $fp = fopen($name, 'w');
            curl_setopt($ch, CURLOPT_URL, $logo);
            curl_setopt($ch, CURLOPT_FAILONERROR, true);
            curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 100);
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
            curl_setopt($ch, CURLOPT_FILE, $fp);
            $output = curl_exec($ch);
            $info = curl_getinfo($ch);
            $error = curl_error($ch);
            fclose($fp);
            $size = filesize($name);

            curl_close($ch);
            if ($size != $info['size_download']) {
                // echo "";
                // echo $error;
                return 0;
            } else {
                //echo "";
                return 1;
            }
        } else {
            return 0;
        }

    }

    //
    public function newkjzb()
    {
        $post = $this->request->post();
        if ($post['type'] == 1) {
            //
            $where['type'] = ['eq', 1];
        } else {
            $where['type'] = ['eq', 2];
        }
        $data['list'] = db('kjzb')->where($where)->order('kjtime asc')->select();
        foreach ($data['list'] as $k => &$v) {
            $v['icon'] = cdnurl($v['icon'], true);
        }
        $cle = strtotime($data['list'][0]['kjtime']) - time();

        $data['h'] = floor(($cle % (3600 * 24)) / 3600); //%
        $data['m'] = floor(($cle % (3600 * 24)) % 3600 / 60);
        $data['s'] = floor(($cle % (3600 * 24)) % 60);
        //echo $h . $m . $s;exit();
        $this->success('', $data, 0);
    }
    // 
    public function bfzc()
    {
        $post = $this->request->post();
        $time = strtotime($post['time']);

        $list = db('soccer_zc')->field('matchtime,jcid,league,home,away,state,bfsg')->order('id desc')->where('time', $time)->select(); //

        $this->success('', $list, 0);
    }

    public function curlGet($url)
    {
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.172 Safari/537.22");
        curl_setopt($ch, CURLOPT_ENCODING, 'gzip'); //gzip
        $output = curl_exec($ch);
        $info = curl_getinfo($ch);
        curl_close($ch);
        return $output;
    }
    //logo
    public function check_imglink()
    {
        $where['logolink'] = ['like', '%' . 'http://cp.1122334455.cn/' . '%'];
        $count = db('soccer_zl')->field('id,logolink')->where($where)->count();
        //  echo $count;exit();
        if ($count == 0) {
            echo "logo";exit();
        }
        $list = db('soccer_zl')->where($where)->column('id');
        $data['logolink'] = '';
        $up = db('soccer_zl')->where('id', 'in', $list)->update($data);
        if ($up) {
            echo "";
        } else {
            echo "";
        }
        echo "<pre>";
        print_r($list);exit();
    }
    public function testaddimg()
    {
        $homelogo = db('soccer_zl')->where('id', 3)->find(); //
        if (!empty($homelogo['logo'])) {
            if (!empty($homelogo['logolink'])) {
                $list['homelogo'] = $homelogo['logolink']; //logo
            } else {
                $list['homelogo'] = $this->getimg($homelogo['logo'], $homelogo['teamId']); //
                if ($list['homelogo'] != 0) {
                    //
                    $list['homelogo'] = $this->request->domain() . '/static/logo/' . $homelogo['teamId'] . '.png';
                    $data['logolink'] = $list['homelogo'];
                    $up = db('soccer_zl')->where('id', $homelogo['id'])->update($data);
                } else {
                    $list['homelogo'] = '';
                }
            }
        }
    }

    //
    public function get_jczq()
    {

        $post = $this->request->post();
        $time = strtotime(date('Y-m-d', time())); //12

        // $time = time() - 300; //-5

        $find = db('soccer')->where('ids', 56)->where('time', $time)->find(); //5
        $url = "http://interface.bet007.com/lottery/JczqOdds.aspx?key=200AB2AB2B444E35";
        $getresp = $this->curlGet($url);

        //print_r($getresp);exit();
        if (!empty($find)) {
            //

            $data['content'] = $getresp;
            $data['create_time'] = time();
            //  $data['id'] = $find['id'];
            $insert = db('soccer')->where('id', $find['id'])->update($data);
        } else {
            //

            $data['content'] = $getresp;
            $data['create_time'] = time();
            $data['ids'] = 56;
            $data['time'] = $time;
            $insert = db('soccer')->insert($data);
        }
        if ($insert) {
            echo "";exit();
        } else {
            echo "";exit();
        }
        // $resp = json_decode($resp, true);

        // $this->success('', $resp, 0);
    }

    //
    public function get_bjdcsj()
    {
        $time = strtotime(date('Y-m-d', time())); //
        // 
        $getresp = db('soccer')->where('ids', 53)->field('id,content,time')->where('time', $time)->find(); // 
        if (!empty($getresp)) {
            $getresp = json_decode($getresp['content'], true);
            $data = $getresp['matchList']; //
            // echo "<pre>";
            // print_r($data);exit;

            $this->model = new \app\common\model\SoccerBd;

            $newarr = array(); //
            foreach ($data as $k => $v) {
                $newarr[$k] = $v['matchId']; //mactchid
            }
            $where['matchId'] = ['in', $newarr];
            $check = db('soccer_bd')->where($where)->where('state', 'neq', '-1')->count(); // 
            $newdata = array();
            if ($check > 0) {
                $sl = db('soccer_bd')->where($where)->where('state', 'neq', '-1')->column('id, matchId'); // 
                $is_turn = db('soccer_bd')->where($where)->where('state', 'neq', '-1')->column('id, isTurn'); //
                foreach ($data as $k => &$v) {
                    $v['searchkey'] = array_search($v['matchId'], $sl); //

                    if (!empty($v['searchkey']) || $v['searchkey'] === 0) {
                        // echo $v['searchkey'];exit();
                        //

                        //

                        $newdata[$k]['id'] = $v['searchkey']; //id
                        $newdata[$k]['state'] = $v['state'];
                        $newdata[$k]['startTime'] = $v['startTime'];
                        $newdata[$k]['bbfsg'] = $v['homeHalfScore'] . ':' . $v['awayHalfScore']; // 
                        if ($is_turn[$v['searchkey']] == 1) {
                            //
                            $newdata[$k]['homeScore'] = $v['awayScore']; //
                            $newdata[$k]['awayScore'] = $v['homeScore']; //
                            $newdata[$k]['homeRed'] = $v['awayRed']; //
                            $newdata[$k]['homeYellow'] = $v['awayYellow']; //
                            $newdata[$k]['awayRed'] = $v['homeRed']; //
                            $newdata[$k]['awayYellow'] = $v['homeYellow']; //
                            $newdata[$k]['homeCorner'] = $v['awayCorner']; //
                            $newdata[$k]['awayCorner'] = $v['homeCorner']; //
                            $newdata[$k]['homeRank'] = $v['awayRank']; //
                            $newdata[$k]['awayRank'] = $v['homeRank']; //
                        } else {
                            $newdata[$k]['homeScore'] = $v['homeScore']; //
                            $newdata[$k]['awayScore'] = $v['awayScore']; //
                            $newdata[$k]['homeRed'] = $v['homeRed']; //
                            $newdata[$k]['homeYellow'] = $v['homeYellow']; //
                            $newdata[$k]['awayRed'] = $v['awayRed']; //
                            $newdata[$k]['awayYellow'] = $v['awayYellow']; //
                            $newdata[$k]['homeCorner'] = $v['homeCorner']; //
                            $newdata[$k]['awayCorner'] = $v['awayCorner']; //
                            $newdata[$k]['homeRank'] = $v['homeRank']; //
                            $newdata[$k]['awayRank'] = $v['awayRank']; //
                        }

                        $newdata[$k]['isNeutral'] = $v['isNeutral']; //
                        $newdata[$k]['hasLineup'] = $v['hasLineup']; //
                        $newdata[$k]['explain'] = $v['explain']; //
                        $newdata[$k]['extraExplain'] = $v['extraExplain']; //2

                    }
                }
                if (!empty($newdata)) {
                    $insert = $this->model->saveall($newdata);

                    if ($insert) {
                        echo "";exit();
                    } else {
                        echo "";exit();
                    }
                } else {
                    echo "";exit();
                }
                // echo "<pre>";
                // print_r($newdata);exit();
            }
        }
    }
    // //jctime2
    public function addendumbd()
    {
        $ids = db('soccer_bd')->field('id,jctime')->where('jctime2', 'null')->select();
        if (!empty($ids)) {
            foreach ($ids as $k => $v) {
                $data[$k]['id'] = $v['id'];
                $data[$k]['jctime2'] = strtotime(date('Y-m-d', strtotime($v['jctime']))); //
            }
            $this->model = new \app\common\model\SoccerBd;
            $insert = $this->model->saveall($data);

            if ($insert) {
                echo "";exit();
            } else {
                echo "";exit();
            }
        } else {
            echo "";exit();
        }
        echo "<pre>";
        print_r($ids);
    }

    public function getsg($sg, $type)
    {

        switch ($type) {
            case '1':
                $list['-'] = 'ht33';
                $list['-'] = 'ht31';
                $list['-'] = 'ht30';
                $list['-'] = 'ht13';
                $list['-'] = 'ht11';
                $list['-'] = 'ht10';
                $list['-'] = 'ht03';
                $list['-'] = 'ht01';
                $list['-'] = 'ht00';
                break;
            case '2':
                $list[''] = 'sf3';
                $list[''] = 'sf1';
                $list[''] = 'sf0';

                break;
            case '3':
                $list[''] = 'ds11';
                $list[''] = 'ds10';
                $list[''] = 'ds01';
                $list[''] = 'ds00';

                break;
            case '4':
                $list[''] = 'sf3'; //
                $list[''] = 'sf0'; //

                break;
            case '5':
                $list['0'] = 't0';
                $list['1'] = 't1';
                $list['2'] = 't2';
                $list['3'] = 't3';
                $list['4'] = 't4';
                $list['5'] = 't5';
                $list['6'] = 't6';
                $list['7'] = 't7';
                break;
            default:
                # code...
                break;
        }
        if ($type == 5) {
            if ($sg > 7) {
                $list = 't7';
                return $list;
            } else {
                return $list[$sg];
            }
        } else {
            return $list[$sg];
        }

    }

    //
    public function month_del()
    {
        $time = strtotime(date('Y-m-d', time())) - 86400 * 30;

        $count = db('soccer_tj')->where('time', 'elt', $time)->count();
        $count1 = db('soccer_jc')->where('time', 'elt', $time)->count();
        $count2 = db('soccer_bd')->where('time', 'elt', $time)->count();
        $count3 = db('soccer_zc')->where('time', 'elt', $time)->count();
        $count4 = db('soccer_bdall')->where('time', 'elt', $time)->count();
        if ($count > 0) {
            $del = db('soccer_tj')->where('time', 'elt', $time)->delete();
            if ($del) {
                echo "1";
            } else {
                echo "1";
            }
        } else {
            echo "1";
        }
        if ($count1 > 0) {
            $del = db('soccer_jc')->where('time', 'elt', $time)->delete();
            if ($del) {
                echo "";
            } else {
                echo "";
            }
        } else {
            echo "";
        }
        if ($count2 > 0) {
            $del = db('soccer_bd')->where('time', 'elt', $time)->delete();
            if ($del) {
                echo "";
            } else {
                echo "";
            }
        } else {
            echo "";
        }
        if ($count3 > 0) {
            $del = db('soccer_zc')->where('time', 'elt', $time)->delete();
            if ($del) {
                echo "";
            } else {
                echo "";
            }
        } else {
            echo "";
        }
        if ($count4 > 0) {
            $del = db('soccer_all')->where('time', 'elt', $time)->delete();
            if ($del) {
                echo "";
            } else {
                echo "";
            }
        } else {
            echo "";
        }
    }

    //
    public function get_bssj()
    {

        $post = $this->request->post();
        $time = strtotime(date('Y-m-d', time())); //12

        // $time = strtotime('2023-07-29'); //&&date=2023-07-29

        $url = "http://interface.bet007.com/football/detail.aspx?key=200AB2AB2B444E35";
        $getresp = $this->curlGet($url);
        $getresp2 = json_decode($getresp, true);

        $eventList = $getresp2['eventList']; //
        // echo "<pre>";
        // print_r($getresp2);exit();
        $technic = $getresp2['technic']; //

        $penalty = $getresp2['penalty']; //
        $count = db('soccer_tj')->where('time', $time)->count();
        if ($count > 0) {

            $del = db('soccer_tj')->where('time', $time)->delete();
        }
        $data = array();
        $data2 = array();
        foreach ($eventList as $k => $v) {
            $data[$k]['matchId'] = $v['matchId'];
            $data[$k]['eventList'] = json_encode($v['event']);
            $data[$k]['time'] = $time;
            $data[$k]['technic'] = '';
            $data[$k]['penalty'] = '';
            $data[$k]['createtime'] = time();
            $data2[$k] = $v['matchId'];
        }
        foreach ($technic as $k => $v) {
            $v['check'] = array_search($v['matchId'], $data2);
            if (!empty($v['check']) || $v['check'] === 0) {
                //
                $data[$v['check']]['technic'] = $v['technicCount'];
            }

        }
        foreach ($penalty as $k => $v) {
            $v['check'] = array_search($v['matchId'], $data2);
            if (!empty($v['check']) || $v['check'] === 0) {
                //
                $data[$v['check']]['penalty'] = json_encode($v['event']);
            }

        }
        // echo "<pre>";
        // print_r($data);exit();
        $insert = db('soccer_tj')->insertall($data);
        if ($insert) {
            echo "";
        } else {
            echo "";
        }

    }
    //  // $v['newrqspf'] = parse_str($v['rqspf'], $new); 
    //
    public function testjc()
    {
        $time = strtotime(date('Y-m-d', time())); //
        $pl = db('soccer')->where('ids', 56)->field('id,content,time')->order('time desc')->find(); // 
        // $time = strtotime('2023-08-28'); // //

        // $pl = db('soccer')->where('ids', 56)->field('id,content,time')->where('time', $time)->find(); //
        // echo "<pre>";
        // print_r($pl)
        $pl['resp'] = json_decode($pl['content'], true);
        $bisai = $pl['resp']['list']; //
        if (empty($bisai)) {
            echo '';exit();
        }
        $check = db('soccer_jc')->where('time', $time)->count(); //
        //$check = 0;//

        $data = $bisai;
        $data2 = $bisai;
        $bscount = count($bisai); //
        $this->model = new \app\common\model\SoccerJc;
        $this->model2 = new \app\common\model\SoccerZc; //

        $data2count = 0;
        foreach ($data2 as $k => &$v) {

            $v['jcid'] = $v['id'];
            $v['time'] = $time; //
            $v['createtime'] = time();
            $v['bstime'] = strtotime(date('Y-m-d', strtotime($v['matchTime'])));
            $v['rqspf'] = http_build_query($v['rqspf']);
            $v['bf'] = http_build_query($v['bf']);
            $v['jq'] = http_build_query($v['jq']);
            $v['bqc'] = http_build_query($v['bqc']);
            $v['spf'] = http_build_query($v['spf']);
            $check2 = db('soccer_zc')->where('jcid', $v['jcid'])->where('matchTime', $v['matchTime'])->value('id');
            if (!empty($check2)) {
                //
                $v['id'] = $check2;
                $data2count = $data2count + 1;

            } else {
                //
                unset($v['id']);
            }
        }

        if ($data2count > 0) {
            //

            $insert2 = $this->model2->saveall($data2);

            if ($insert2) {
                echo '';
            } else {
                echo '';
            }
        } else {
            //
            $insert2 = $this->model2->insertall($data2);
            if ($insert2) {
                echo '';
            } else {
                echo '';
            }
        }

        if ($check == 0) {
            //

            foreach ($data as $k => &$v) {

                $v['jcid'] = $v['id'];
                $v['time'] = $time; //
                $v['createtime'] = time();
                $v['rqspf'] = http_build_query($v['rqspf']);
                $v['bf'] = http_build_query($v['bf']);
                $v['jq'] = http_build_query($v['jq']);
                $v['bqc'] = http_build_query($v['bqc']);
                $v['spf'] = http_build_query($v['spf']);
                unset($v['id']);

                // echo "<pre>";
                // print_r($new);exit();
            }
            // echo "<pre>";
            // print_r($data);exit();
            $insert = $this->model->insertall($data);

            if ($insert) {
                echo "";exit();
            } else {
                echo "";exit();
            }
        } else {
            // 
            $sl = db('soccer_jc')->where('time', $time)->column('id,jcid'); //
            // echo "<pre>";
            // print_r($sl);exit();

            foreach ($data as $k => &$v) {
                //unset($v['id']);
                $v['jcid'] = $v['id'];

                // echo "<pre>";
                // print_r($searchkey);exit();
                // unset($v['id']);
                $v['id'] = array_search($v['jcid'], $sl); //
                if (!empty($v['id']) || $v['id'] === 0) {
                    //
                    $v['id'] = $v['id'];
                } else {

                    unset($v['id']);
                }

                $v['time'] = $time; //
                $v['createtime'] = time();
                // print_r($v['rqspf']);exit();
                if (is_array($v['rqspf'])) {
                    $v['rqspf'] = http_build_query($v['rqspf']);
                }
                if (is_array($v['bf'])) {
                    $v['bf'] = http_build_query($v['bf']);
                }
                if (is_array($v['jq'])) {
                    $v['jq'] = http_build_query($v['jq']);
                }
                if (is_array($v['bqc'])) {
                    $v['bqc'] = http_build_query($v['bqc']);
                }
                if (is_array($v['spf'])) {
                    $v['spf'] = http_build_query($v['spf']);
                }

            }
            // echo "<pre>";
            // print_r($data);exit();
            $insert = $this->model->saveall($data);

            if ($insert) {
                echo "";exit();
            } else {
                echo "";exit();
            }

        }

    }

    //12 
    //7
    public function checkmzyl()
    {
        $time = strtotime(date('Y-m-d', time())) - 86400; //
        $time2 = $time - 6 * 86400; //
        $user_ids = db('cp_order')->where('is_zj', 1)->where('createtime', 'egt', $time)->column('user_id');
        if (!empty($user_ids)) {
            $data = array();
            foreach ($user_ids as $k => &$v) {
                $count1 = db('cp_order')->where('status', 'egt', 1)->where('createtime', 'egt', $time2)->where('user_id', $v)->count(); //
                $count2 = db('cp_order')->where('is_zj', 1)->where('createtime', 'egt', $time2)->where('user_id', $v)->count(); //
                $mzl = round(($count2 / $count1) * 100, 0); //
                $count3 = db('cp_order')->where('status', 'egt', 1)->where('createtime', 'egt', $time2)->where('user_id', $v)->sum('money'); //
                $count4 = db('cp_order')->where('is_zj', 1)->where('createtime', 'egt', $time2)->where('user_id', $v)->sum('true_jmoey'); //
                $yll = round(($count4 / $count3) * 100, 0); //
                $data[$k]['id'] = $v; //id
                $data[$k]['mzl'] = $mzl; //
                $data[$k]['yll'] = $yll; //
            }
            if (!empty($data)) {
                $this->model = new \app\common\model\User;
                $up = $this->model->saveall($data);
                if ($up) {
                    echo "";
                } else {
                    echo "";
                }
            }
            // echo "<pre>";
            // print_r($data);exit();
        } else {
            echo "";exit;
        }

    }

    //
    //
    public function testjg()
    {
        $time = strtotime(date('Y-m-d', time())); //
        $pl = db('soccer')->where('ids', 53)->field('id,content,time')->where('time', $time)->find(); // 
        $url = "http://interface.bet007.com/lottery/Zq_BF.aspx?key=200AB2AB2B444E35";
        //&&cmd=result
        $getresp = $this->curlGet($url);
        // echo "<pre>";
        // print_r($getresp);exit();
        if (!empty($pl)) {
            //

            $data['content'] = $getresp;
            $data['create_time'] = time();
            //  $data['id'] = $find['id'];
            $insert = db('soccer')->where('id', $pl['id'])->update($data);
        } else {
            //

            $data['content'] = $getresp;
            $data['create_time'] = time();
            $data['ids'] = 53;
            $data['time'] = $time;
            $insert = db('soccer')->insert($data);
        }
        // $pl['resp'] = json_decode($getresp, true);
        $getresp = json_decode($getresp, true);
        $data = $getresp['matchList']; //
        // echo "<pre>";
        // print_r($data);exit();
        //$time = 1684944000; //

        $this->model = new \app\common\model\SoccerJc;

        $newarr = array(); //
        foreach ($data as $k => $v) {
            $newarr[$k] = $v['matchId']; //mactchid
        }
        // echo "<pre>";
        // print_r($newarr);exit();
        $where['matchId'] = ['in', $newarr];
        // $where['time'] = ['eq', $time]; // 814 
        $check = db('soccer_jc')->where($where)->where('state', 'neq', '-1')->count(); // 
        $list = db('soccer_jc')->where($where)->where('state', 'neq', '-1')->select();

        // echo "<pre>";
        // print_r($list);exit();
        // echo $check;exit();
        $newdata = array();
        if ($check > 0) {
            // 
            $sl = db('soccer_jc')->where($where)->where('state', 'neq', '-1')->column('id, matchId'); // 
            // echo "<pre>";
            // print_r($sl);exit();
            $goal = db('soccer_jc')->where($where)->where('state', 'neq', '-1')->column('id, rqspf'); //
            $bf = db('soccer_jc')->where($where)->where('state', 'neq', '-1')->column('id, bf'); //
            $spf = db('soccer_jc')->where($where)->where('state', 'neq', '-1')->column('id, spf'); //
            // echo "<pre>";
            // print_r($spf);exit();
            $rqspf = db('soccer_jc')->where($where)->where('state', 'neq', '-1')->column('id, rqspf'); //
            // $bqc = db('soccer_jc')->where($where)->where('state', 'neq', '-1')->column('id, bqc'); //
            $jq = db('soccer_jc')->where($where)->where('state', 'neq', '-1')->column('id, jq'); //
            $is_turn = db('soccer_jc')->where($where)->where('state', 'neq', '-1')->column('id, isTurn'); //
            foreach ($goal as $k => &$v) {
                parse_str($v, $newgoal);
                $v = $newgoal['goal'];
            }
            foreach ($bf as $k => &$v) {
                parse_str($v, $newgoal);
                $v = $newgoal;
            }
            foreach ($rqspf as $k => &$v) {
                parse_str($v, $newgoal);
                $v = $newgoal;
            }
            // foreach ($bqc as $k => &$v) {
            //     parse_str($v, $newgoal);
            //     $v = $newgoal;
            // }
            foreach ($jq as $k => &$v) {
                parse_str($v, $newgoal);
                $v = $newgoal;
            }
            foreach ($spf as $k => &$v) {
                parse_str($v, $newgoal);
                $v = $newgoal;
            }

            // echo "<pre>";
            // print_r($sl);exit();
            foreach ($data as $k => &$v) {
                $v['searchkey'] = array_search($v['matchId'], $sl); //

                if (!empty($v['searchkey']) || $v['searchkey'] === 0) {
                    // echo $v['searchkey'];exit();
                    //
                    if ($v['state'] == '-1') {
                        // 

                        $newdata[$k]['id'] = $v['searchkey']; //id
                        $newdata[$k]['state'] = $v['state'];
                        if ($is_turn[$v['searchkey']] == 1) {
                            //
                            $newdata[$k]['homeScore'] = $v['awayScore']; //
                            $newdata[$k]['awayScore'] = $v['homeScore']; //
                            $newdata[$k]['homeHalfScore'] = $v['awayHalfScore']; //
                            $newdata[$k]['awayHalfScore'] = $v['homeHalfScore']; //
                            $newdata[$k]['homeRed'] = $v['awayRed']; //
                            $newdata[$k]['homeYellow'] = $v['awayYellow']; //
                            $newdata[$k]['awayRed'] = $v['homeRed']; //
                            $newdata[$k]['awayYellow'] = $v['homeYellow']; //
                            $newdata[$k]['homeCorner'] = $v['awayCorner']; //
                            $newdata[$k]['awayCorner'] = $v['homeCorner']; //
                            $newdata[$k]['homeRank'] = $v['awayRank']; //
                            $newdata[$k]['awayRank'] = $v['homeRank']; //
                        } else {
                            $newdata[$k]['homeScore'] = $v['homeScore']; //
                            $newdata[$k]['awayScore'] = $v['awayScore']; //
                            $newdata[$k]['homeHalfScore'] = $v['homeHalfScore']; //
                            $newdata[$k]['awayHalfScore'] = $v['awayHalfScore']; //
                            $newdata[$k]['homeRed'] = $v['homeRed']; //
                            $newdata[$k]['homeYellow'] = $v['homeYellow']; //
                            $newdata[$k]['awayRed'] = $v['awayRed']; //
                            $newdata[$k]['awayYellow'] = $v['awayYellow']; //
                            $newdata[$k]['homeCorner'] = $v['homeCorner']; //
                            $newdata[$k]['awayCorner'] = $v['awayCorner']; //
                            $newdata[$k]['homeRank'] = $v['homeRank']; //
                            $newdata[$k]['awayRank'] = $v['awayRank']; //
                        }

                        $newdata[$k]['isNeutral'] = $v['isNeutral']; //
                        $newdata[$k]['hasLineup'] = $v['hasLineup']; //
                        $newdata[$k]['explain'] = $v['explain']; //
                        $newdata[$k]['extraExplain'] = $v['extraExplain']; //2
                        if ($is_turn[$v['searchkey']] == 1) {
                            ////
                            $v['sg'] = $this->getcg($v['awayScore'], $v['homeScore'], $v['awayHalfScore'], $v['homeHalfScore'], $goal[$v['searchkey']]);
                        } else {
                            $v['sg'] = $this->getcg($v['homeScore'], $v['awayScore'], $v['homeHalfScore'], $v['awayHalfScore'], $goal[$v['searchkey']]);
                        }
                        //
                        // echo "<pre>";
                        // print_r($v['sg']);exit();
                        $newdata[$k]['bfsg'] = $v['sg']['bf']; //
                        $newdata[$k]['rq'] = $goal[$v['searchkey']]; //
                        $newdata[$k]['bfpl'] = $bf[$v['searchkey']][$v['sg']['bfcg']]; //
                        $newdata[$k]['rqspfsg'] = $v['sg']['rqspf']; //
                        $newdata[$k]['rqspfpl'] = $rqspf[$v['searchkey']][$v['sg']['rqspfcg']]; //
                        $newdata[$k]['zjq'] = $v['sg']['jq']; //
                        $newdata[$k]['zjqpl'] = $jq[$v['searchkey']][$v['sg']['jqcg']]; //
                        $newdata[$k]['bqcsg'] = $v['sg']['bqc']; //
                        // $newdata[$k]['bqcpl'] = $bqc[$v['searchkey']][$v['sg']['bqccg']]; //

                        $newdata[$k]['bbfsg'] = $v['homeHalfScore'] . ':' . $v['awayHalfScore']; // 
                        $newdata[$k]['spfsg'] = $v['sg']['spftext']; //
                        if (isset($spf[$v['searchkey']][$v['sg']['spfcg']])) {
                            $newdata[$k]['spfpl'] = $spf[$v['searchkey']][$v['sg']['spfcg']]; //
                        }

                        $newdata[$k]['spfsge'] = $v['sg']['spfcg']; //
                        $newdata[$k]['rqspfsge'] = $v['sg']['rqspfcg']; //
                        $newdata[$k]['bfsge'] = $v['sg']['bfcg']; //
                        $newdata[$k]['zjqsge'] = $v['sg']['jqcg']; //
                        $newdata[$k]['bqcsge'] = $v['sg']['bqccg']; //
                        // if ($v['matchId'] == 2337322) {
                        //     print_r($newdata[$k]);exit();

                        // }
                    } else {
                        //
                        if ($v['state'] != 0) {
                            //  
                            $newdata[$k]['id'] = $v['searchkey']; //id
                            $newdata[$k]['state'] = $v['state'];
                            if ($is_turn[$v['searchkey']] == 1) {
                                //
                                $newdata[$k]['homeScore'] = $v['awayScore']; //
                                $newdata[$k]['awayScore'] = $v['homeScore']; //
                                $newdata[$k]['homeHalfScore'] = $v['awayHalfScore']; //
                                $newdata[$k]['awayHalfScore'] = $v['homeHalfScore']; //
                                $newdata[$k]['homeRed'] = $v['awayRed']; //
                                $newdata[$k]['homeYellow'] = $v['awayYellow']; //
                                $newdata[$k]['awayRed'] = $v['homeRed']; //
                                $newdata[$k]['awayYellow'] = $v['homeYellow']; //
                                $newdata[$k]['homeCorner'] = $v['awayCorner']; //
                                $newdata[$k]['awayCorner'] = $v['homeCorner']; //
                                $newdata[$k]['homeRank'] = $v['awayRank']; //
                                $newdata[$k]['awayRank'] = $v['homeRank']; //
                            } else {
                                $newdata[$k]['homeScore'] = $v['homeScore']; //
                                $newdata[$k]['awayScore'] = $v['awayScore']; //
                                $newdata[$k]['homeHalfScore'] = $v['homeHalfScore']; //
                                $newdata[$k]['awayHalfScore'] = $v['awayHalfScore']; //
                                $newdata[$k]['homeRed'] = $v['homeRed']; //
                                $newdata[$k]['homeYellow'] = $v['homeYellow']; //
                                $newdata[$k]['awayRed'] = $v['awayRed']; //
                                $newdata[$k]['awayYellow'] = $v['awayYellow']; //
                                $newdata[$k]['homeCorner'] = $v['homeCorner']; //
                                $newdata[$k]['awayCorner'] = $v['awayCorner']; //
                                $newdata[$k]['homeRank'] = $v['homeRank']; //
                                $newdata[$k]['awayRank'] = $v['awayRank']; //
                            }

                            $newdata[$k]['isNeutral'] = $v['isNeutral']; //
                            $newdata[$k]['hasLineup'] = $v['hasLineup']; //
                            $newdata[$k]['explain'] = $v['explain']; //
                            $newdata[$k]['extraExplain'] = $v['extraExplain']; //2
                        }
                    }
                }
            }
            // echo "<pre>";
            // print_r($newdata);exit();

            if (!empty($newdata)) {
                $insert = $this->model->saveall($newdata);

                if ($insert) {
                    echo "";exit();
                } else {
                    echo "";exit();
                }
            } else {
                echo "";exit();
            }

        }
    }
    //9.4
    public function editjctime2()
    {
        $time = strtotime(date('Y-m-d', time())); //12
        $time = strtotime('2023-09-18'); //12
        // $time = time() - 300; //-5
        $time2 = date('Y-m-d H:i:s', time());
        $list = db('soccer_jc')->field('matchtime,id,jcid')->
            where('time', 'egt', $time)->select();
        $week[1] = '';
        $week[2] = '';
        $week[3] = '';
        $week[4] = '';
        $week[5] = '';
        $week[6] = '';
        $week[7] = '';
        // echo "<pre>";
        // print_r($week);exit();
        if (!empty($list)) {
            $data = array();
            foreach ($list as $k => &$v) {
                $data[$k]['id'] = $v['id'];
                $data[$k]['matchtime'] = $v['matchtime'];
                $v['matchtime'] = strtotime($v['matchtime']);
                $data[$k]['week'] = date('w', $v['matchtime']);
                if ($data[$k]['week'] == 0) {
                    $data[$k]['week'] = 7;
                }
                $data[$k]['hour'] = date('H', $v['matchtime']);
                $data[$k]['minute'] = date('i', $v['matchtime']);
                $data[$k]['bstime'] = strtotime(date('Y-m-d', $v['matchtime'])); //0
                $v['todaytime'] = strtotime(date('Y-m-d', time())); //0
                $v['jcid'] = explode('0', $v['jcid']);

                if (count($v['jcid']) == 1) {
                    //0xx  1xx
                    $v['jcid'] = explode('1', $v['jcid'][0]);
                }
                if ($data[$k]['week'] == 6 || $data[$k]['week'] == 7) {
                    //
                    if ($data[$k]['hour'] . $data[$k]['minute'] >= 2240 || $data[$k]['hour'] . $data[$k]['minute'] <= 1100) {

                        if ($data[$k]['hour'] . $data[$k]['minute'] <= 1100) {
                            //11
                            if ($data[$k]['week'] != 6) {
                                //
                                $data[$k]['jctime'] = date('Y-m-d', $v['matchtime'] - 86400) . ' 22:40:00';
                            } else {
                                // 2140
                                $data[$k]['jctime'] = date('Y-m-d', $v['matchtime'] - 86400) . ' 21:40:00';
                            }

                        } else {
                            //2140
                            $data[$k]['jctime'] = date('Y-m-d', $v['matchtime']) . ' 21:40:00';
                        }

                    } else {
                        // echo "2";exit();
                        //.   10.40 11  21.40
                        $data[$k]['jctime'] = date('Y-m-d H:i:s', $v['matchtime'] - 20 * 60);

                    }
                } else {
                    //
                    //
                    if ($data[$k]['hour'] . $data[$k]['minute'] >= 2140 || $data[$k]['hour'] . $data[$k]['minute'] <= 1100) {
                        //echo "1";exit();
                        //-20
                        if ($data[$k]['hour'] . $data[$k]['minute'] <= 1100) {
                            //11
                            if ($data[$k]['week'] != 1) {
                                //
                                $data[$k]['jctime'] = date('Y-m-d', $v['matchtime'] - 86400) . ' 21:40:00';
                            } else {
                                // 2240
                                $data[$k]['jctime'] = date('Y-m-d', $v['matchtime'] - 86400) . ' 22:40:00';
                            }

                        } else {
                            //2140
                            $data[$k]['jctime'] = date('Y-m-d', $v['matchtime']) . ' 21:40:00';
                        }

                    } else {
                        // echo "2";exit();
                        //.   9.40 11  21.40
                        $data[$k]['jctime'] = date('Y-m-d H:i:s', $v['matchtime'] - 20 * 60);

                    }

                }

                $data[$k]['jctime2'] = strtotime(date('Y-m-d', strtotime($data[$k]['jctime']))); //

                unset($data[$k]['week']);
                unset($data[$k]['hour']);
                unset($data[$k]['minute']);
                unset($data[$k]['matchtime']);
                //"", "", "", "", "", "", ""

            }
            // echo "<pre>";
            // print_r($data);exit();
            if (!empty($data)) {
                //
                $this->model = new \app\common\model\SoccerJc;
                $up = $this->model->saveall($data);
                if ($up) {
                    echo "";exit();
                } else {
                    echo "";exit();
                }
            } else {
                echo "2";
            }
        } else {
            echo "";
        }
    }
    //  9.4  jcid  2140  22:40
    public function editjctime()
    {
        $list = db('soccer_jc')->field('matchtime,id,jcid')->where('jctime', null)->select();
        // echo "<pre>";
        // print_r($list);exit();
        $week[1] = '';
        $week[2] = '';
        $week[3] = '';
        $week[4] = '';
        $week[5] = '';
        $week[6] = '';
        $week[7] = '';
        // echo "<pre>";
        // print_r($week);exit();
        if (!empty($list)) {
            $data = array();
            foreach ($list as $k => &$v) {
                $data[$k]['id'] = $v['id'];
                $data[$k]['matchtime'] = $v['matchtime'];
                $v['matchtime'] = strtotime($v['matchtime']);
                $data[$k]['week'] = date('w', $v['matchtime']);
                if ($data[$k]['week'] == 0) {
                    $data[$k]['week'] = 7;
                }
                $data[$k]['hour'] = date('H', $v['matchtime']);
                $data[$k]['minute'] = date('i', $v['matchtime']);
                $data[$k]['bstime'] = strtotime(date('Y-m-d', $v['matchtime'])); //0

                $v['jcid'] = explode('0', $v['jcid']);

                if (count($v['jcid']) == 1) {
                    //0xx  1xx
                    $v['jcid'] = explode('1', $v['jcid'][0]);
                }
                //918 mathctimejctime 
                if ($data[$k]['week'] == 6 || $data[$k]['week'] == 7) {
                    //
                    if ($data[$k]['hour'] . $data[$k]['minute'] >= 2240 || $data[$k]['hour'] . $data[$k]['minute'] <= 1100) {

                        if ($data[$k]['hour'] . $data[$k]['minute'] <= 1100) {
                            // echo 1;exit();
                            //11
                            if ($data[$k]['week'] != 6) {
                                //
                                $data[$k]['jctime'] = date('Y-m-d', $v['matchtime'] - 86400) . ' 22:40:00';
                            } else {
                                // 2140
                                $data[$k]['jctime'] = date('Y-m-d', $v['matchtime'] - 86400) . ' 21:40:00';
                            }

                        } else {
                            //2140
                            //echo 2;exit();
                            $data[$k]['jctime'] = date('Y-m-d', $v['matchtime']) . ' 22:40:00';
                        }

                    } else {
                        // echo "2";exit();
                        //.   10.40 11  21.40
                        $data[$k]['jctime'] = date('Y-m-d H:i:s', $v['matchtime'] - 20 * 60);

                    }
                } else {
                    //
                    //
                    if ($data[$k]['hour'] . $data[$k]['minute'] >= 2140 || $data[$k]['hour'] . $data[$k]['minute'] <= 1100) {
                        //echo "1";exit();
                        //-20
                        if ($data[$k]['hour'] . $data[$k]['minute'] <= 1100) {
                            //11
                            if ($data[$k]['week'] != 1) {
                                //
                                $data[$k]['jctime'] = date('Y-m-d', $v['matchtime'] - 86400) . ' 21:40:00';
                            } else {
                                // 2240
                                $data[$k]['jctime'] = date('Y-m-d', $v['matchtime'] - 86400) . ' 22:40:00';
                            }

                        } else {
                            //2140
                            $data[$k]['jctime'] = date('Y-m-d', $v['matchtime']) . ' 21:40:00';
                        }

                    } else {
                        // echo "2";exit();
                        //.   9.40 11  21.40
                        $data[$k]['jctime'] = date('Y-m-d H:i:s', $v['matchtime'] - 20 * 60);

                    }

                }

                $data[$k]['jctime2'] = strtotime(date('Y-m-d', strtotime($data[$k]['jctime']))); //
                // echo "<pre>";
                // print_r($data);exit();
                unset($data[$k]['week']);
                unset($data[$k]['hour']);
                unset($data[$k]['minute']);
                unset($data[$k]['matchtime']);
                //"", "", "", "", "", "", ""

            }
            // echo "<pre>";
            // print_r($data);exit();
            if (!empty($data)) {
                //
                $this->model = new \app\common\model\SoccerJc;
                $up = $this->model->saveall($data);
                if ($up) {
                    echo "";exit();
                } else {
                    echo "";exit();
                }
            } else {
                echo "2";
            }
        } else {
            echo "";
        }

    }

    // 
    public function jczq()
    {
        $post = $this->request->post();
        if (isset($post['id']) && !empty($post['id'])) {

            $where['id'] = ['eq', $post['id']];
            $list = db('soccer_jc')->where($where)->field('id, time')->order('time desc')->find(); //
        } else {
            $list = db('soccer_jc')->field('id, time')->order('time desc')->find(); //
        }

        $week_array = array("", "", "", "", "", "", "");

        $list['newtime'] = date('Y - m - d', $list['time']);
        $week = date("w", $list['time']);
        $list['date'] = '' . $week_array[$week];
        $list['num1'] = db('soccer_jc')->where('time', $list['time'])->where('spfsge', 'spf3')->count(); //
        $list['num2'] = db('soccer_jc')->where('time', $list['time'])->where('spfsge', 'spf1')->count(); //
        $list['num3'] = db('soccer_jc')->where('time', $list['time'])->where('spfsge', 'spf0')->count(); //
        $list['bisainum'] = db('soccer_jc')->where('time', $list['time'])->where('state', '-1')->count(); //
        $list['bisaidetail'] = db('soccer_jc')->field('home as homeChs,away as awayChs,bfsg as bf,rq,bbfsg as rqbf,spfsg as spf, spfpl,rqspfsg as rqspf,rqspfpl,bfpl,zjq,zjqpl,bqcsg as bqc,bqcpl,league as leagueChs')->where('time', $list['time'])->where('state', '-1')->select(); //

        $this->success('', $list, 0);
    }
    //
    //bf1 
    //bf2 
    //bf3 
    //bf4 
    //rq 
    public function getcg($bf1, $bf2, $bf3, $bf4, $rq)
    {
        $message['homeScore'] = $bf1;
        $message['awayScore'] = $bf2;
        $message['homeHalfScore'] = $bf3;
        $message['awayHalfScore'] = $bf4;

        //
        if ($message['homeScore'] > $message['awayScore']) {
            $data['spfcg'] = 'spf3';
            $data['spftext'] = '';
        } elseif ($message['homeScore'] < $message['awayScore']) {
            $data['spfcg'] = 'spf0';
            $data['spftext'] = '';
        } else {
            $data['spfcg'] = 'spf1';
            $data['spftext'] = '';
        }
        //
        if ($message['homeScore'] > $message['awayScore']) {
            // sw
            $hlist = ['1', '2', '3', '4', '5']; //
            $alist = ['0', '1', '2']; //
            $hcheck = in_array($message['homeScore'], $hlist);
            $acheck = in_array($message['awayScore'], $alist);
            if ($hcheck && $acheck) {
                // $cg = 'sw' . $message['homeScore'] . $message['awayScore'];
                $data['bfcg'] = 'sw' . $message['homeScore'] . $message['awayScore'];

            } else {
                $data['bfcg'] = 'sw5'; //
            }

        } elseif ($message['homeScore'] == $message['awayScore']) {
            //

            $hlist = ['0', '1', '2', '3']; //

            $hcheck = in_array($message['homeScore'], $hlist);
            $acheck = in_array($message['awayScore'], $hlist);
            if ($hcheck && $acheck) {
                $data['bfcg'] = 'sd' . $message['homeScore'] . $message['awayScore'];
            } else {
                $data['bfcg'] = 'sd4'; //
            }

        } else {
            //
            $hlist = ['0', '1', '2']; //
            $alist = ['1', '2', '3', '4', '5']; //

            $hcheck = in_array($message['homeScore'], $hlist);
            $acheck = in_array($message['awayScore'], $alist);
            if ($hcheck && $acheck) {
                $data['bfcg'] = 'sl' . $message['homeScore'] . $message['awayScore'];
            } else {
                $data['bfcg'] = 'sl5'; //
            }

        }
        //
        $data['bf'] = $message['homeScore'] . ":" . $message['awayScore'];
        //
        if ($message['homeScore'] + $message['awayScore'] > 6) {
            $data['jqcg'] = 't7';
        } else {
            $zjq = $message['homeScore'] + $message['awayScore'];
            $data['jqcg'] = 't' . $zjq;
        }
        $data['jq'] = $message['homeScore'] + $message['awayScore'] . ''; //
        //
        if ($message['homeHalfScore'] > $message['awayHalfScore'] && $message['homeScore'] > $message['awayScore']) {
            //
            $data['bqccg'] = 'ht33';
            $data['bqc'] = '-';
        } elseif ($message['homeHalfScore'] > $message['awayHalfScore'] && $message['homeScore'] == $message['awayScore']) {
            //
            $data['bqccg'] = 'ht31';
            $data['bqc'] = '-';
        } elseif ($message['homeHalfScore'] > $message['awayHalfScore'] && $message['homeScore'] < $message['awayScore']) {
            //
            $data['bqccg'] = 'ht30';
            $data['bqc'] = '-';
        } elseif ($message['homeHalfScore'] == $message['awayHalfScore'] && $message['homeScore'] > $message['awayScore']) {
            //
            $data['bqccg'] = 'ht13';
            $data['bqc'] = '-';
        } elseif ($message['homeHalfScore'] == $message['awayHalfScore'] && $message['homeScore'] == $message['awayScore']) {
            //
            $data['bqccg'] = 'ht11';
            $data['bqc'] = '-';
        } elseif ($message['homeHalfScore'] == $message['awayHalfScore'] && $message['homeScore'] < $message['awayScore']) {
            //
            $data['bqccg'] = 'ht10';
            $data['bqc'] = '-';
        } elseif ($message['homeHalfScore'] < $message['awayHalfScore'] && $message['homeScore'] > $message['awayScore']) {
            //
            $data['bqccg'] = 'ht03';
            $data['bqc'] = '-';
        } elseif ($message['homeHalfScore'] < $message['awayHalfScore'] && $message['homeScore'] == $message['awayScore']) {
            //
            $data['bqccg'] = 'ht01';
            $data['bqc'] = '-';
        } else {
            //
            $data['bqccg'] = 'ht00';
            $data['bqc'] = '-';
        }

        if ($rq < 0) {
            //
            //  echo $message['homeScore'] + $order['rqno'];
            if ($message['homeScore'] + $rq > $message['awayScore']) {
                $data['rqspfcg'] = 'rq3';
            } elseif ($message['homeScore'] + $rq < $message['awayScore']) {
                $data['rqspfcg'] = 'rq0';
            } else {
                $data['rqspfcg'] = 'rq1';
            }
            // echo $cg;exit();
        } else {
            //
            if ($message['homeScore'] > $message['awayScore'] - $rq) {
                $data['rqspfcg'] = 'rq3';
            } elseif ($message['homeScore'] < $message['awayScore'] - $rq) {
                $data['rqspfcg'] = 'rq0';
            } else {
                $data['rqspfcg'] = 'rq1';
            }
        }
        switch ($data['rqspfcg']) {
            case 'rq3':
                $data['rqspf'] = '';
                break;
            case 'rq1':
                $data['rqspf'] = '';
                break;
            default:
                $data['rqspf'] = '';
                break;
        }
        return $data;

    }

    //
    public function szc()
    {
        $dlt = db('gzgl')->field('id, number, kjtime, is_end')->order('no desc')->find();
        $dlt['single'] = explode(' ', $dlt['number']);
        $dlt['type_text'] = '';
        $dlt['kjtime'] = date('Y - m - d', strtotime($dlt['kjtime']));
        $week_array = array("", "", "", "", "", "", "");

        $week = date("w", strtotime($dlt['kjtime']));
        $dlt['date'] = '' . $week_array[$week];
        $list['dlt'] = $dlt;
        $this->success('', $list, 0);
    }
    //
    public function dlt()
    {
        $post = $this->request->post();
        $page = $post['page'];
        $limit = $post['limit'];
        $list = db('gzgl')->order('no desc')->page($page, $limit)->select();
        foreach ($list as $k => &$v) {
            $v['single'] = explode(' ', $v['number']);
        }
        $this->success('', $list, 0);
    }
    //3
    public function plthree()
    {
        $post = $this->request->post();
        $page = $post['page'];
        $limit = $post['limit'];
        $list = db('gzglplthree')->order('no desc')->where('deletetime', 'null')->page($page, $limit)->select();
        foreach ($list as $k => &$v) {
            $v['single'] = explode(' ', $v['number']);
        }
        $this->success('3', $list, 0);
    }
    //5
    public function plfive()
    {
        $post = $this->request->post();
        $page = $post['page'];
        $limit = $post['limit'];
        $list = db('gzglplfive')->order('no desc')->page($page, $limit)->select();
        foreach ($list as $k => &$v) {
            $v['single'] = explode(' ', $v['number']);
        }
        $this->success('', $list, 0);
    }
    //
    public function qxc()
    {
        $post = $this->request->post();
        $page = $post['page'];
        $limit = $post['limit'];
        $list = db('gzglqxc')->order('no desc')->page($page, $limit)->select();
        foreach ($list as $k => &$v) {
            $v['single'] = explode(' ', $v['number']);
        }
        $this->success('', $list, 0);
    }
    //
    public function dlt_detail()
    {
        $post = $this->request->post();
        $list = db('gzgl')->where('id', $post['id'])->find();
        $list['single'] = explode(' ', $list['number']);
        $this->success('', $list, 0);
    }
    //3
    public function plthree_detail()
    {
        $post = $this->request->post();
        $list = db('gzglplthree')->where('id', $post['id'])->find();
        $list['single'] = explode(' ', $list['number']);
        $this->success('', $list, 0);
    }
    //5
    public function plfive_detail()
    {
        $post = $this->request->post();
        $list = db('gzglplfive')->where('id', $post['id'])->find();
        $list['single'] = explode(' ', $list['number']);
        $this->success('', $list, 0);
    }
    //
    public function qxc_detail()
    {
        $post = $this->request->post();
        $list = db('gzglqxc')->where('id', $post['id'])->find();
        $list['single'] = explode(' ', $list['number']);
        $this->success('', $list, 0);
    }
    //
    public function zst()
    {
        $post = $this->request->post();
        if (!isset($post['type']) && empty($post['type'])) {
            $type = 1; //
        } else {
            $type = $post['type'];
        }
        $list = db('zst')->where('type', $type)->order('createtime desc')->select();
        foreach ($list as $k => &$v) {
            if (!empty($v['zj'])) {
                $v['single'] = explode(' ', $v['zj']);
            }

        }
        $this->success('', $list, 0);
    }
    //
    public function sdgc()
    {
        $post = $this->request->post();
        if (!isset($post['time']) && empty($post['time'])) {
            $time = strtotime(date('Y-m-d', time())); //
        } else {
            $time = strtotime($post['time']); //
        }
        $time2 = $time + 86400;
        $list = db('sdgc')->where('time', 'egt', $time)->where('time', 'elt', $time2)->order('bonus desc')->select();
        $week_array = array("", "", "", "", "", "", "");

        foreach ($list as $k => &$v) {
            $v['sort'] = $k + 1;
            $v['newtime'] = date('Y - m', $v['time']);
            $v['newtime2'] = date('m - d', $v['time']);
            $week = date("w", $v['time']);
            $v['date'] = '' . $week_array[$week];
        }
        $this->success('', $list, 0);
    }
    //
    public function kjzb()
    {
        $list = db('config')->where('name', 'kjzb')->value('value'); //
        $this->success('', $list, 0);
    }
    //
    public function hmbz()
    {
        $list = db('config')->where('name', 'hmbz')->value('value'); //
        $this->success('', $list, 0);
    }
    //
    public function bzzx()
    {
        $list['bz_zc'] = db('config')->where('name', 'bz_zc')->value('value'); //
        $list['bz_cz'] = db('config')->where('name', 'bz_cz')->value('value'); //
        $list['bz_gc'] = db('config')->where('name', 'bz_gc')->value('value'); //
        $list['bz_zj'] = db('config')->where('name', 'bz_zj')->value('value'); //
        $list['bz_tk'] = db('config')->where('name', 'bz_tk')->value('value'); //
        $list['bz_qt'] = db('config')->where('name', 'bz_qt')->value('value'); //
        $this->success('', $list, 0);
    }
    //
    public function bzzxnew()
    {
        $post = $this->request->post();
        $type = $post['type'];
        $list = db('bzzx')->field('title,content')->where('type', $type)->select();
        $this->success('', $list, 0);
    }
    //
    public function gdtips()
    {
        $list = db('config')->where('name', 'gdtips')->value('value'); //
        $this->success('', $list, 0);
    }

    //
    public function cz()
    {
        $list = db('cz')->field('cz_money, cz_price')->select();
        $this->success('', $list, 0);
    }
    //
    public function tx()
    {
        $list = db('config')->where('group', 'tx')->field('name, title, value')->select();
        $this->success('', $list, 0);
    }
    //
    public function zl()
    {
        $list = db('config')->where('group', 'zl')->field('name, title, value')->select();
        $this->success('', $list, 0);
    }

    //
    public function bfsj()
    {

        $post = $this->request->post();

        $time = time() - 300; //-5
        $find = db('soccer')->where('ids', 53)->where('create_time', 'egt', $time)->order('id desc')->find(); //5
        if (empty($find)) {
            // 
            // $resp = '';
            // $data['content'] = $resp;
            // $data['create_time'] = time();
            // $data['ids'] = 56;
            // $insert = db('soccer')->insert($data);
            $find = db('soccer')->where('ids', 53)->order('id desc')->find(); // 
            $resp = $find['content'];
        } else {
            $resp = $find['content'];
        }

        $resp = json_decode($resp, true);
        $content = $resp['matchList']; //
        $newlist = array();
        $matchTime = array();
        foreach ($content as $k => &$v) {

            $newlist[$k] = $v['homeChs'] . 'VS' . $v['awayChs']; //
            $matchTime[$k] = strtotime($v['matchTime']); // 
        }

        // foreach ($newlist as $k => &$v) {
        //     # code...
        // }
        // echo "<pre>";
        // print_r($newlist);exit();
        $list = db('cp_order_detail')->where('dz', 'in', $newlist)->where('matchTime', 'in', $matchTime)->where('is_check', 0)->select(); // 
        if (!empty($list)) {
            //
            // 
            $data = array();
            foreach ($list as $k => &$v) {
                $data[] = $this->check_zj($v, $content, $newlist); //  

            }
            if (!empty($data)) {
                $this->model = new \app\common\model\CpOrderDetail;
                $up = $this->model->saveall($data);
            }
            // echo "<pre>";
            // print_r($data);exit();
        }
        // echo "<pre>111";
        // print_r($list);exit();
        //  $this->success('', $resp, 0);
    }
    //
    //ordermessage  newlist 
    public function check_zj($order, $message, $newlist)
    {

        //$order['wfbd'] = 'rqspf'; //
        $searchkey = array_search($order['dz'], $newlist); //
        $message = $message[$searchkey]; //

        if ($message['state'] == '-1') {
            //
            switch ($order['wfbd']) {
                //
                case 'spf': // spf3  spf1 spf0 

                    if ($message['homeScore'] > $message['awayScore']) {
                        $cg = 'spf3';
                    } elseif ($message['homeScore'] < $message['awayScore']) {
                        $cg = 'spf0';
                    } else {
                        $cg = 'spf1';
                    }

                    break;
                case 'bf': //  swsdsl<sd00>0:0 sw5  sw

                    if ($message['homeScore'] > $message['awayScore']) {
                        // sw
                        $hlist = ['1', '2', '3', '4', '5']; //
                        $alist = ['0', '1', '2']; //
                        $hcheck = in_array($message['homeScore'], $hlist);
                        $acheck = in_array($message['awayScore'], $alist);
                        if ($hcheck && $acheck) {
                            $cg = 'sw' . $message['homeScore'] . $message['awayScore'];
                        } else {
                            $cg = 'sw5'; //
                        }

                    } elseif ($message['homeScore'] == $message['awayScore']) {
                        //

                        $hlist = ['0', '1', '2', '3']; //

                        $hcheck = in_array($message['homeScore'], $hlist);
                        $acheck = in_array($message['awayScore'], $hlist);
                        if ($hcheck && $acheck) {
                            $cg = 'sd' . $message['homeScore'] . $message['awayScore'];
                        } else {
                            $cg = 'sd4'; //
                        }

                    } else {
                        //
                        $hlist = ['0', '1', '2']; //
                        $alist = ['1', '2', '3', '4', '5']; //

                        $hcheck = in_array($message['homeScore'], $hlist);
                        $acheck = in_array($message['awayScore'], $alist);
                        if ($hcheck && $acheck) {
                            $cg = 'sl' . $message['homeScore'] . $message['awayScore'];
                        } else {
                            $cg = 'sl5'; //
                        }

                    }

                    break;
                case 'jq': //

                    if ($message['homeScore'] + $message['awayScore'] > 6) {
                        $cg = 't7';
                    } else {
                        $zjq = $message['homeScore'] + $message['awayScore'];
                        $cg = 't' . $zjq;
                    }

                    break;
                case 'bqc': //

                    if ($message['homeHalfScore'] > $message['awayHalfScore'] && $message['homeScore'] > $message['awayScore']) {
                        //
                        $cg = 'ht31';
                    } elseif ($message['homeHalfScore'] > $message['awayHalfScore'] && $message['homeScore'] < $message['awayScore']) {
                        //
                        $cg = 'ht30';
                    } elseif ($message['homeHalfScore'] == $message['awayHalfScore'] && $message['homeScore'] < $message['awayScore']) {
                        //
                        $cg = 'ht13';
                    } elseif ($message['homeHalfScore'] == $message['awayHalfScore'] && $message['homeScore'] == $message['awayScore']) {
                        //
                        $cg = 'ht11';
                    } elseif ($message['homeHalfScore'] == $message['awayHalfScore'] && $message['homeScore'] < $message['awayScore']) {
                        //
                        $cg = 'ht10';
                    } elseif ($message['homeHalfScore'] == $message['awayHalfScore'] && $message['homeScore'] > $message['awayScore']) {
                        //
                        $cg = 'ht03';
                    } elseif ($message['homeHalfScore'] < $message['awayHalfScore'] && $message['homeScore'] == $message['awayScore']) {
                        //
                        $cg = 'ht01';
                    } else {
                        //
                        $cg = 'ht00';
                    }

                    break;
                case 'rqspf': // rq3  rq1  rq0 
                    if ($order['rqno'] < 0) {
                        //
                        //  echo $message['homeScore'] + $order['rqno'];
                        if ($message['homeScore'] + $order['rqno'] > $message['awayScore']) {
                            $cg = 'rq3';
                        } elseif ($message['homeScore'] + $order['rqno'] < $message['awayScore']) {
                            $cg = 'rq0';
                        } else {
                            $cg = 'rq1';
                        }
                        // echo $cg;exit();
                    } else {
                        //
                        if ($message['homeScore'] > $message['awayScore'] - $order['rqno']) {
                            $cg = 'rq3';
                        } elseif ($message['homeScore'] < $message['awayScore'] - $order['rqno']) {
                            $cg = 'rq0';
                        } else {
                            $cg = 'rq1';
                        }
                    }

                    break;

                default:
                    $cg = 0;
                    break;
            }
        }
        //echo $cg;exit();
        if ($cg != "0") {
            //  
            //echo $cg;exit();
            $xx = explode(':', $order['xx']); //
            $zj = 0;
            $zj_xx = ''; // 
            $zj_pl = ''; // 
            foreach ($xx as $k => $v) {
                if ($v == $cg) {
                    //
                    $zj = 1;
                    $data['zjxx'] = $v;
                    $pl = explode(':', $order['pl']);
                    $data['zjpl'] = $pl[$k];
                }

            }
            $data['is_check'] = 1;
            $data['is_zj'] = $zj;
            $data['id'] = $order['id'];
            return $data;
        }

        // echo "<pre>";
        // print_r($cg);exit();
        // echo "<pre>";
        // print_r($order);exit();

    }
    //
    public function check_zero()
    {
        $count = db('cp_order')->where('is_check', 1)->where('status', 2)->count();
        if ($count > 0) {
            $list = db('cp_order')->where('is_check', 1)->where('status', 2)->column('id'); //id
            $data = array();
            foreach ($list as $k => $v) {
                $data[$k]['id'] = $v;
                $data[$k]['is_check'] = 0;

            }
            $this->model = new \app\common\model\CpOrder;
            $up = $this->model->saveall($data);
            if ($up) {
                echo "";exit();
            } else {
                echo "";exit();
            }

        } else {
            echo "";exit();
        }

    }
    //
    public function check_detail_zero()
    {
        $count = db('cp_order_detail')->where('is_check', 0)->where('tem_check', 1)->count();
        if ($count > 0) {
            $list = db('cp_order_detail')->where('is_check', 0)->where('tem_check', 1)->column('id'); //id
            $data = array();
            foreach ($list as $k => $v) {
                $data[$k]['id'] = $v;
                $data[$k]['tem_check'] = 0;

            }
            $this->model = new \app\common\model\CpOrderDetail;
            $up = $this->model->saveall($data);
            if ($up) {
                echo "";
            } else {
                echo "";
            }

        } else {
            echo "";
        }
        $count = db('cp_order_detailbd')->where('is_check', 0)->where('tem_check', 1)->count();
        if ($count > 0) {
            $list = db('cp_order_detailbd')->where('is_check', 0)->where('tem_check', 1)->column('id'); //id
            $data = array();
            foreach ($list as $k => $v) {
                $data[$k]['id'] = $v;
                $data[$k]['tem_check'] = 0;

            }
            $this->model = new \app\common\model\CpOrderDetailbd;
            $up = $this->model->saveall($data);
            if ($up) {
                echo "";
            } else {
                echo "";
            }

        } else {
            echo "";
        }
        exit();
    }

    //
    public function check_order_detail()
    {
        //
        $count = db('cp_order_detail')->where('is_check', 0)->where('tem_check', 0)->count();
        if ($count > 0) {
            $limit = 30;
            // $idlist = db('cp_order_detail')->where('is_check', 0)->column('id');
            // $randkey = rand(0, $count);
            //
            // $randkey = $randkey - $limit;
            // if ($randkey < 0) {
            //     $randkey = 0;
            // }
            // $rand = $idlist[$randkey];
            //where('id', 'egt', $rand)->
            //9.8 rand  
            $orderlist = db('cp_order')->where('type', 2)->where('status', 2)->where('is_check', 0)->where('hg_orderno', 0)->column('orderno'); //
            // echo "<pre>";
            // print_r($orderlist);exit();
            $list = db('cp_order_detail')->where('orderno', 'in', $orderlist)->where('is_check', 0)->where('tem_check', 0)->field('id,xx,wfbd,matchtime,cc,pl,dz')->order('createtime asc')->limit($limit)->select(); //
            // echo "<pre>";
            // print_r($list);exit();
            // 
            // $list = db('cp_order_detail')->field('id,xx,wfbd,matchtime,cc,pl')->order('createtime asc')->limit($limit)->select(); //

            if (!empty($list)) {
                $data = array();
                foreach ($list as $k => &$v) {
                    $v['dz'] = explode('VS', $v['dz']);

                    // $v['check'] = db('soccer_jc')->where('matchTime', $v['matchtime'])->where('jcid', $v['cc'])->where('state', '-1')->field('matchTime,jcid,spfsge,bqcsge,rqspfsge,zjqsge,bfsge,spfsg,bqcsg,rqspfsg,zjq,bfsg')->find(); //
                    $v['check'] = db('soccer_jc')->where('home', $v['dz'][0])->where('away', $v['dz'][1])->where('jcid', $v['cc'])->where('state', '-1')->field('id,matchTime,jcid,spfsge,bqcsge,rqspfsge,zjqsge,bfsge,spfsg,bqcsg,rqspfsg,zjq,bfsg')->order('createtime desc')->find(); //

                    // echo "<pre>";
                    // print_r($v);exit();
                    // print_r($v['check']);exit();
                    if (!empty($v['check'])) {
                        $v['xx'] = explode(':', $v['xx']); //
                        $v['pl'] = explode(':', $v['pl']); //
                        switch ($v['wfbd']) {
                            case 'spf':
                                $v['sg'] = $v['check']['spfsge']; //
                                $v['cg'] = $v['check']['spfsg']; //
                                break;
                            case 'bqc':
                                $v['sg'] = $v['check']['bqcsge']; //
                                $v['cg'] = $v['check']['bqcsg']; //
                                break;
                            case 'rqspf':
                                $v['sg'] = $v['check']['rqspfsge']; //
                                $v['cg'] = $v['check']['rqspfsg']; //
                                break;
                            //case 'zjq': 20238143   jq
                            case 'jq':
                                $v['sg'] = $v['check']['zjqsge']; //
                                $v['cg'] = $v['check']['zjq']; //
                                break;
                            default:
                                $v['sg'] = $v['check']['bfsge']; //
                                $v['cg'] = $v['check']['bfsg']; //
                                break;
                        }
                        //echo $v['sg'];exit();
                        $v['searchkey'] = array_search($v['sg'], $v['xx']);
                        //echo array_search($v['sg'], $v['xx']);exit();

                        $data[$k]['id'] = $v['id'];
                        $data[$k]['is_check'] = 1;
                        if (!empty($v['searchkey']) || $v['searchkey'] === 0) {
                            //
                            $data[$k]['is_zj'] = 1;
                            $data[$k]['zj_xx'] = $v['xx'][$v['searchkey']];
                            $data[$k]['zj_pl'] = $v['pl'][$v['searchkey']];
                        } else {

                            $data[$k]['is_zj'] = 0;
                        }
                        $data[$k]['cg'] = $v['cg'];

                        // $searchkey[] = array_search($v[0], $newlist); //
                    } else {

                        $v['check'] = db('soccer_jc')->where('home', $v['dz'][0])->where('away', $v['dz'][1])->where('jcid', $v['cc'])->where('state', '<', '-1')->field('id,matchTime,jcid,state')->order('createtime desc')->find(); //

                        // echo "<pre>";
                        // print_r($v);exit();
                        //print_r($v['check']);exit();
                        if (!empty($v['check'])) {
                            //
                            $data[$k]['id'] = $v['id'];
                            $data[$k]['is_zj'] = 1;
                            $data[$k]['zj_xx'] = $v['check']['state'];
                            $data[$k]['zj_pl'] = 1; //1
                            $data[$k]['cg'] = '';
                            $data[$k]['is_check'] = 1;
                        } else {
                            $data[$k]['id'] = $v['id'];
                            $data[$k]['tem_check'] = 1; //
                        }

                    }

                }
                // echo "<pre>";
                // print_r($data);exit();
                if (!empty($data)) {
                    $this->model = new \app\common\model\CpOrderDetail;
                    $up = $this->model->saveall($data);
                    if ($up) {
                        echo "";exit();
                    } else {
                        echo "";exit();
                    }
                }
                // echo "<pre>";
                // print_r($data);exit();
            }
            // echo "<pre>";
            // print_r($list);exit();
        } else {
            echo "";exit();
        }
    }

    //
    public function getname($a, $b)
    {
        if (5 == $a && 2 == $b) {
            return "prize1";
        } else if (5 == $a && 1 == $b) {
            return "prize2";
        } else if (5 == $a && 0 == $b) {
            return "prize3";
        } else if (4 == $a && 2 == $b) {
            return "prize4";
        } else if (4 == $a && 1 == $b) {
            return "prize5";
        } else if (3 == $a && 2 == $b) {
            return "prize6";
        } else if (4 == $a && 0 == $b) {
            return "prize7";
        } else if ((3 == $a && 1 == $b) || (2 == $a && 2 == $b)) {
            return "prize8";
        } else if ((3 == $a && 0 == $b) || (1 == $a && 2 == $b) || (2 == $a && 1 == $b) || (0 == $a && 2 == $b)) {
            return "prize9";
        } else {
            return "no prize";
        }
    }
    // public function GetMoneyByName {$name}{

    //     if ("prize1" == $name) {
    //         return this.money = "A"
    //     } else if ("prize2" == name) {
    //         return this.money = "B"
    //     } else if ("prize3" == name) {
    //         return this.money = 10000
    //     } else if ("prize4" == name) {
    //         return this.money = 3000
    //     } else if ("prize5" == name) {
    //         return this.money = 300
    //     } else if ("prize6" == name) {
    //         return this.money = 200
    //     } else if ("prize7" == name) {
    //         return this.money = 100
    //     } else if ("prize8" == name) {
    //         return this.money = 15
    //     } else if ("prize9" == name) {
    //         return this.money = 5
    //     } else {
    //         return this.money = 0
    //     }

    // }
    public function comb($head, $foot)
    {

        $A = $head;
        $B = $foot;
        $C = 1;
        for ($i = $B - $A + 1; $i <= $B; $i++) {
            $C = $C * $i;
        }
        for ($i = 2; $i <= $A; $i++) {
            $C = $C / $i;
        }
        return $C;

    }

    /**
     * 
     * @Author   MAX
     * @DateTime 2018-09-07T16:28:40+0800
     * @param    Array                   $arr 
     * @param    Number                   $m   
     * @param    [Array]                  $push   
     * @return   Array                        
     */
    public function getCombinationToString($arr, $m, $push = null)
    {
        $rst = array();
        // echo count($arr);exit();
        // echo "<pre>";
        // var_dump($arr);exit();
        for ($i = 0; $i < pow(2, count($arr)); $i++) {
            $a = 0;
            $b = array();
            for ($j = 0; $j < count($arr); $j++) {
                if ($i >> $j & 1) {
                    $a++;
                    array_push($b, $arr[$j]);
                }
            }
            if ($a == $m) {
                if (!is_null($push)) {
                    if (is_string($push)) {
                        $b = array_unshift($b, $push);
                    } else {
                        $b = array_merge($push, $b);
                    }
                }
                $rst[] = $b;
            }
        }
        return $rst;
    }

    // 
    public function check_order()
    {
        //$time = strtotime(date('Y - m - d', time())); //
        $list = db('cp_order')->where('status', 2)->where('type', 2)->where('is_check', 0)->where('is_h', 0)->order('createtime desc')->limit(30)->select(); //
        // echo "<pre>";
        // print_r($list);exit();
        if (!empty($list)) {
            //  

            foreach ($list as $k => &$v) {

                $v['count1'] = db('cp_order_detail')->where('orderno', $v['orderno'])->count(); //
                $v['count2'] = db('cp_order_detail')->where('orderno', $v['orderno'])->where('is_check', 1)->count(); //
                $v['count3'] = db('cp_order_detail')->where('orderno', $v['orderno'])->where('is_zj', 1)->count(); //

                if ($v['count1'] == $v['count2']) {
                    // 
                    if (!empty($v['cp_type2'])) {
                        //MN
                        $data[$k] = $this->get_orderdatamore($v, 2);

                    } else {
                        if ($v['cp_type'] == '') {
                            //
                            // 
                            // echo "<pre>";
                            // print_r($v);
                            $data[$k] = $this->get_orderdatamore($v, 1);

                        } else {
                            //x1 8.16 x1
                            // $v['cp_type'] = explode('', $v['cp_type']);
                            $v['newcheck'] = explode(',', $v['cp_type']);
                            $v['checkcount'] = count($v['newcheck']);
                            if ($v['checkcount'] > 1) {
                                //N1
                                // echo "<pre>";
                                // print_r($v);
                                $data[$k] = $this->get_orderdatamore($v, 1);

                            } else {
                                //$data[$k] = $this->get_orderdataone($v);
                                $data[$k] = $this->get_orderdatamore($v, 1);
                            }

                        }

                    }

                } else {
                    // 
                    $data[$k]['id'] = $v['id'];
                    $data[$k]['is_check'] = 1; //

                }
            }
            // echo "<pre>";
            // print_r($data);exit();
            if (!empty($data)) {

                $this->model = new \app\common\model\CpOrder;
                $xejmoney = db('config')->where('name', 'jmoney')->value('value'); //
                // echo "<pre>";
                // print_r($xejmoney);exit();
                foreach ($data as $k => $v) {
                    if (isset($v['is_zj'])) {
                        if ($v['is_zj'] == 1) {
                            // 
                            // echo 111;
                            if ($v['true_jmoey'] > $xejmoney) {
                                $is_check = 0; // 01
                            } else {
                                $is_check = 1;
                            }
                            UserModel::jmoney($v['true_jmoey'], $v['user_id'], '4', '', '+' . $v['true_jmoey'] . '', $v['orderno'], $is_check); //4       
                        }
                    }
                }

                $up = $this->model->saveall($data);
                if ($up) {
                    echo "";exit();
                } else {
                    echo "";exit();
                }
            } else {
                echo "";exit();
            }

        }

    }
    public function get_orderdatamore($v, $type)
    {

        if ($type == 1) {
            //N1 
            $v['cp_type'] = explode(',', $v['cp_type']);
            foreach ($v['cp_type'] as $g => &$t) {
                if ($t == '') {
                    $t = '11';
                }
                $t = explode('', $t);
                if (!empty($t)) {
                    $t = $t[0];
                }
                //$t = $g[0];
            }
            // echo "<pre>";
            // print_r($v['cp_type']);exit();
        } else {
            //MN or 
            $v['cp_type2'] = explode(',', $v['cp_type2']);
            foreach ($v['cp_type2'] as $g => &$t) {
                $t = explode('', $t);
                if (!empty($t)) {
                    $t = $t[0];
                }
                //$t = $g[0];
            }
        }

        // echo "<pre>";
        // print_r($v['cp_type2']);exit();
        $v['newcount'] = $v['cp_type'][0]; // 

        //    
        $v['list'] = db('cp_order_detail')->where('orderno', $v['orderno'])->where('is_zj', 1)->column('id,cc'); //
        //  $v['list']['352'] = '002';
        $v['listpl'] = db('cp_order_detail')->where('orderno', $v['orderno'])->where('is_zj', 1)->column('id,zj_pl'); //

        $v['count4'] = $v['count1'] - $v['newcount']; //

        // 
        $v['unique_arr'] = array_unique($v['list']);

        // 
        $v['repeat_arr'] = array_diff_assoc($v['list'], $v['unique_arr']);

        $nk = 0;
        $v['newlist'] = array();
        foreach ($v['repeat_arr'] as $g => &$t) {
            $searchkey = array_search($t, $v['unique_arr']); //id
            if (!empty($searchkey)) {
                $v['newlist'][$nk] = $v['unique_arr'];
                // $newlist[$nk] = $unique_arr;

                unset($v['newlist'][$nk][$searchkey]);

                $v['newlist'][$nk][$g] = $t;

                $nk++;

            }

        }

        $v['newlist'][$v['count4']] = $v['unique_arr']; //

        //id
        foreach ($v['newlist'] as $g => &$t) {
            foreach ($t as $z => &$x) {
                $x = $z;

            }
            $t = array_values($t); //
        }

        $v['zjbs'] = array(); //

        foreach ($v['newlist'] as $zz => $xx) {
            // 
            if ($type == 1) {
                foreach ($v['cp_type'] as $gg => $tt) {
                    $v['zjbs'][] = $this->getCombinationToString($xx, $tt, []); //  
                }
            } else {
                foreach ($v['cp_type2'] as $gg => $tt) {
                    $v['zjbs'][] = $this->getCombinationToString($xx, $tt, []); //  
                }
            }

        }
        // echo "<pre>";
        // print_r($v['zjbs']);exit();
        if (!empty($v['zjbs'])) {
            //

            $v['newzhpl'] = array(); //
            // echo "<pre>";
            // echo "231 621,";

            foreach ($v['zjbs'] as $g => $t) {
                // print_r($t);
                foreach ($t as $z => $x) {
                    $v['newzhpl'][$g][$z] = 0; //
                    foreach ($x as $zz => $xx) {
                        //xx=id
                        // x x2x
                        //print_r($xx);
                        if ($v['newzhpl'][$g][$z] != 0) {

                            $v['newzhpl'][$g][$z] = $v['newzhpl'][$g][$z] * $v['listpl'][$xx];
                        } else {
                            //$v['zhpl'] = $v['listpl'][$xx];
                            $v['newzhpl'][$g][$z] = $v['listpl'][$xx];
                        }

                    }

                }
            }

            $v['lastjmoney'] = 0; //
            // x2x
            foreach ($v['newzhpl'] as $g => &$t) {
                foreach ($t as $z => &$x) {

                    $x = $x * 2 * $v['bs'];
                    $v['lastjmoney'] = $v['lastjmoney'] + $x;
                    // echo $x;
                }
            }

        }

        $v['lastjmoney'] = bcadd($v['lastjmoney'], 0, 2);
        if ($v['lastjmoney'] > 0) {
            $data['id'] = $v['id'];
            $data['true_jmoey'] = $v['lastjmoney'];
            $data['is_zj'] = 1; //
            $data['status'] = 4; //
            $data['user_id'] = $v['user_id']; //id 
            $data['orderno'] = $v['orderno']; //

        } else {

            $data['id'] = $v['id'];
            $data['is_zj'] = 2; //
            $data['status'] = 3; //

        }
        return $data;

    }
    //N1 
    public function get_orderdataone($v)
    {

        $v['cp_type'] = explode('', $v['cp_type']);

        if ($v['cp_type'][1] == 1) {

            $v['count1'] = $v['cp_type'][0]; //

            // echo $v['count2'];exit();
            if ($v['count2'] > $v['count1']) {
                $type = 1;
                $v['newcount'] = $v['cp_type'][0]; // 

                // N1
                //    
                $v['list'] = db('cp_order_detail')->where('orderno', $v['orderno'])->where('is_zj', 1)->column('id,cc'); //
                //  $v['list']['352'] = '002';
                $v['listpl'] = db('cp_order_detail')->where('orderno', $v['orderno'])->where('is_zj', 1)->column('id,zj_pl'); //

                $v['count4'] = $v['count1'] - $v['newcount']; //

                // 
                $v['unique_arr'] = array_unique($v['list']);

                // 
                $v['repeat_arr'] = array_diff_assoc($v['list'], $v['unique_arr']);

                $nk = 0;
                $v['newlist'] = array();
                foreach ($v['repeat_arr'] as $g => &$t) {
                    $searchkey = array_search($t, $v['unique_arr']); //id
                    if (!empty($searchkey)) {
                        $v['newlist'][$nk] = $v['unique_arr'];
                        // $newlist[$nk] = $unique_arr;

                        unset($v['newlist'][$nk][$searchkey]);

                        $v['newlist'][$nk][$g] = $t;

                        $nk++;

                    }

                }

                $v['newlist'][$v['count4']] = $v['unique_arr']; //

                //id
                foreach ($v['newlist'] as $g => &$t) {
                    foreach ($t as $z => &$x) {
                        $x = $z;

                    }
                    $t = array_values($t); //
                }

                $v['zjbs'] = array(); //

                foreach ($v['newlist'] as $zz => $xx) {
                    // 
                    if ($type == 1) {
                        foreach ($v['cp_type'] as $gg => $tt) {
                            $v['zjbs'][] = $this->getCombinationToString($xx, $tt, []); //  
                        }
                    } else {
                        foreach ($v['cp_type2'] as $gg => $tt) {
                            $v['zjbs'][] = $this->getCombinationToString($xx, $tt, []); //  
                        }
                    }

                }

                if (!empty($v['zjbs'])) {
                    //

                    $v['newzhpl'] = array(); //
                    // echo "<pre>";
                    // echo "231 621,";

                    foreach ($v['zjbs'] as $g => $t) {
                        // print_r($t);
                        foreach ($t as $z => $x) {
                            $v['newzhpl'][$g][$z] = 0; //
                            foreach ($x as $zz => $xx) {
                                //xx=id
                                // x x2x
                                //print_r($xx);
                                if ($v['newzhpl'][$g][$z] != 0) {

                                    $v['newzhpl'][$g][$z] = $v['newzhpl'][$g][$z] * $v['listpl'][$xx];
                                } else {
                                    //$v['zhpl'] = $v['listpl'][$xx];
                                    $v['newzhpl'][$g][$z] = $v['listpl'][$xx];
                                }

                            }

                        }
                    }

                    $v['lastjmoney'] = 0; //
                    // x2x
                    foreach ($v['newzhpl'] as $g => &$t) {
                        foreach ($t as $z => &$x) {

                            $x = $x * 2 * $v['bs'];
                            $v['lastjmoney'] = $v['lastjmoney'] + $x;
                            // echo $x;
                        }
                    }

                }
                // $v['lastjmoney'] = floor($v['lastjmoney'] * 100) / 100;
                $v['lastjmoney'] = bcadd($v['lastjmoney'], 0, 2);
                if ($v['lastjmoney'] > 0) {
                    $data['id'] = $v['id'];
                    $data['true_jmoey'] = $v['lastjmoney'];
                    $data['is_zj'] = 1; //
                    $data['status'] = 4; //
                    $data['user_id'] = $v['user_id']; //id 
                    $data['orderno'] = $v['orderno']; //

                } else {

                    $data['id'] = $v['id'];
                    $data['is_zj'] = 2; //
                    $data['status'] = 3; //

                }
            } elseif ($v['count3'] == $v['count1']) {
                $data['id'] = $v['id'];
                $data['is_zj'] = 1; //
                $data['status'] = 4; //
                $pl = db('cp_order_detail')->where('orderno', $v['orderno'])->where('is_zj', 1)->column('zj_pl'); //
                $jmoney = 0; //

                foreach ($pl as $g => $t) {

                    if ($jmoney == 0) {

                        $jmoney = 2 * $t * $v['bs']; //2xx
                    } else {
                        $jmoney = $jmoney * $t * $v['bs']; //x
                    }

                }

                //$data['true_jmoey'] = floor($jmoney * 100) / 100; //
                $data['true_jmoey'] = bcadd($jmoney, 0, 2); //

                $data['user_id'] = $v['user_id'];
                $data['orderno'] = $v['orderno']; //
            } else {
                $data['id'] = $v['id'];
                $data['is_zj'] = 2; //
                $data['status'] = 3; //

            }
            return $data;

        }
    }

    //  
    public function check_orderhmgd()
    {
        //$time = strtotime(date('Y - m - d', time())); //
        $list = db('cp_order')->where('status', 2)->where('is_check', 0)->where('is_hmcheck', 0)->where('is_h', 'neq', 0)->where('hg_orderno', '0')->where('type', 2)->order('createtime desc')->limit(20)->select(); //
        // echo "<pre>";
        // print_r($list);exit();
        if (!empty($list)) {
            //  
            $gdjl1 = db('config')->where('name', 'gdbl1')->value('value'); //
            $gdjl2 = db('config')->where('name', 'gdjl2')->value('value'); //
            foreach ($list as $k => &$v) {
                $v['count1'] = db('cp_order_detail')->where('orderno', $v['orderno'])->count(); //
                $v['count2'] = db('cp_order_detail')->where('orderno', $v['orderno'])->where('is_check', 1)->count(); //
                $v['count3'] = db('cp_order_detail')->where('orderno', $v['orderno'])->where('is_zj', 1)->count(); //

                if ($v['count1'] == $v['count2']) {
                    // 
                    if (!empty($v['cp_type2'])) {
                        //MN
                        $v['cp_type2'] = explode(',', $v['cp_type2']);
                        foreach ($v['cp_type2'] as $g => &$t) {
                            $t = explode('', $t);
                            if (!empty($t)) {
                                $t = $t[0];
                            }
                            //$t = $g[0];
                        }
                        // echo "<pre>";
                        // print_r($v['cp_type2']);exit();
                        $v['newcount'] = $v['cp_type'][0]; // 

                        //    
                        $v['list'] = db('cp_order_detail')->where('orderno', $v['orderno'])->where('is_zj', 1)->column('id,cc'); //
                        //  $v['list']['352'] = '002';
                        $v['listpl'] = db('cp_order_detail')->where('orderno', $v['orderno'])->where('is_zj', 1)->column('id,zj_pl'); //
                        $v['count4'] = $v['count1'] - $v['newcount']; //

                        // 
                        $v['unique_arr'] = array_unique($v['list']);

                        // 
                        $v['repeat_arr'] = array_diff_assoc($v['list'], $v['unique_arr']);

                        $nk = 0;
                        $v['newlist'] = array();
                        foreach ($v['repeat_arr'] as $g => &$t) {
                            $searchkey = array_search($t, $v['unique_arr']); //id
                            if (!empty($searchkey)) {
                                $v['newlist'][$nk] = $v['unique_arr'];
                                // $newlist[$nk] = $unique_arr;

                                unset($v['newlist'][$nk][$searchkey]);

                                $v['newlist'][$nk][$g] = $t;

                                $nk++;

                            }

                        }

                        $v['newlist'][$v['count4']] = $v['unique_arr']; //

                        //id
                        foreach ($v['newlist'] as $g => &$t) {
                            foreach ($t as $z => &$x) {
                                $x = $z;

                            }
                            $t = array_values($t); //
                        }

                        $v['zjbs'] = array(); //

                        foreach ($v['newlist'] as $zz => $xx) {
                            // 

                            foreach ($v['cp_type2'] as $gg => $tt) {
                                $v['zjbs'][] = $this->getCombinationToString($xx, $tt, []); //  
                            }

                        }

                        if (!empty($v['zjbs'])) {
                            //

                            $v['newzhpl'] = array(); //
                            // echo "<pre>";
                            // echo "231 621,";

                            foreach ($v['zjbs'] as $g => $t) {
                                // print_r($t);
                                foreach ($t as $z => $x) {
                                    $v['newzhpl'][$g][$z] = 0; //
                                    foreach ($x as $zz => $xx) {
                                        //xx=id
                                        // x x2x
                                        //print_r($xx);
                                        if ($v['newzhpl'][$g][$z] != 0) {

                                            $v['newzhpl'][$g][$z] = $v['newzhpl'][$g][$z] * $v['listpl'][$xx];
                                        } else {
                                            //$v['zhpl'] = $v['listpl'][$xx];
                                            $v['newzhpl'][$g][$z] = $v['listpl'][$xx];
                                        }

                                    }

                                }
                            }

                            $v['lastjmoney'] = 0; //
                            // x2x
                            foreach ($v['newzhpl'] as $g => &$t) {
                                foreach ($t as $z => &$x) {

                                    $x = $x * 2 * $v['bs'];
                                    $v['lastjmoney'] = $v['lastjmoney'] + $x;
                                    // echo $x;
                                }
                            }

                        }
                        //$v['lastjmoney'] = floor($v['lastjmoney'] * 100) / 100;
                        $v['lastjmoney'] = bcadd($v['lastjmoney'], 0, 2);
                        //echo $v['lastjmoney'];exit();
                        if ($v['lastjmoney'] > 0) {
                            $data[$k]['id'] = $v['id'];
                            $data[$k]['z_jmoney'] = $v['lastjmoney']; //
                            $data[$k]['is_zj'] = 1; //
                            $data[$k]['status'] = 4; //
                            $data[$k]['user_id'] = $v['user_id']; //id 
                            $data[$k]['orderno'] = $v['orderno']; //
                            $data[$k]['is_hmcheck'] = 1; // 
                            if ($v['is_h'] == 2) {
                                // 
                                $data[$k]['true_jmoey'] = $data[$k]['z_jmoney']; //
                                $newdata = db('cp_order')->where('status', 2)->where('is_check', 0)->where('is_hmcheck', 0)->where('hg_orderno', $v['orderno'])->column('id,bs'); //
                                $onemoney = $data[$k]['true_jmoey'] / $v['bs']; //
                                if (!empty($newdata)) {
                                    foreach ($newdata as $g => $vv) {
                                        $data[$g]['id'] = $g;
                                        $data[$g]['is_zj'] = 1; //
                                        $data[$g]['status'] = 4; //
                                        $data[$g]['z_jmoney'] = $onemoney * $vv;
                                        $data[$g]['true_jmoey'] = $data[$g]['z_jmoney']; //

                                        //$data[$g]['yj'] = floor($data[$g]['true_jmoey'] * $gdjl2 * 100) / 100; //
                                        $data[$g]['yj'] = bcadd($data[$g]['true_jmoey'] * $gdjl2, 0, 2); //
                                        //
                                        $data[$g]['true_jmoey'] = $data[$g]['true_jmoey'] - bcadd($data[$g]['true_jmoey'] * $gdjl2, 0, 2); //

                                        $data[$g]['hm_userid'] = $v['user_id'];
                                        $data[$g]['is_hmcheck'] = 1; // 
                                    }
                                }
                                //  print_r($data);exit();

                            } else {
                                //
                                $data[$k]['true_jmoey'] = ($data[$k]['z_jmoney'] / $v['hm_num']) * $v['hm_num2']; //
                                $newdata = db('cp_order')->where('status', 2)->where('is_check', 0)->where('is_hmcheck', 0)->where('hg_orderno', $v['orderno'])->column('id,hm_num2');
                                if (!empty($newdata)) {
                                    foreach ($newdata as $g => $vv) {
                                        $data[$g]['id'] = $g;
                                        $data[$g]['is_zj'] = 1; //
                                        $data[$g]['status'] = 4; //
                                        $data[$g]['z_jmoney'] = $data[$k]['z_jmoney'];
                                        $data[$g]['true_jmoey'] = ($data[$k]['z_jmoney'] / $v['hm_num']) * $vv; //
                                        $data[$g]['yj'] = bcadd($data[$g]['true_jmoey'] * $v['yjbl'], 0, 2); //

                                        $data[$g]['true_jmoey'] = $data[$g]['true_jmoey'] - $data[$g]['yj']; //-
                                        $data[$g]['hm_userid'] = $v['user_id'];
                                        $data[$g]['is_hmcheck'] = 1; // 
                                    }
                                }

                            }

                        } else {

                            $data[$k]['id'] = $v['id'];
                            $data[$k]['is_zj'] = 2; //
                            $data[$k]['status'] = 3; //
                            $newdata = db('cp_order')->where('status', 2)->where('is_check', 0)->where('is_hmcheck', 0)->where('hg_orderno', $v['orderno'])->column('id,hm_num2');
                            if (!empty($newdata)) {
                                foreach ($newdata as $g => $vv) {
                                    $data[$g]['id'] = $g;
                                    $data[$g]['is_zj'] = 2; //
                                    $data[$g]['status'] = 3; //
                                    //
                                }
                                if ($v['is_baodi'] == 1) {
                                    //
                                    $v['bdpc'] = ($v['money'] / $v['hm_num2']) * $v['baodi_num']; //= /= x 
                                    $v['child_count'] = db('cp_order')->where('status', 2)->where('is_check', 0)->where('is_hmcheck', 0)->where('hg_orderno', $v['orderno'])->count(); // /
                                    $v['dfbdpc'] = bcadd($v['bdpc'] / $v['child_count'], 0, 2); //
                                    foreach ($newdata as $g => $vv) {
                                        # code...
                                        $data[$g]['bdpc'] = $v['dfbdpc']; //
                                        $data[$g]['is_hmcheck'] = 1; // 
                                    }

                                }

                            }
                            // echo "<pre>";
                            // print_r($data);exit();
                        }

                    } else {
                        // x1 
                        //x1 8.18  
                        //x1 8.16 x1
                        // $v['cp_type'] = explode('', $v['cp_type']);
                        $v['newcheck'] = explode(',', $v['cp_type']);
                        $v['checkcount'] = count($v['newcheck']);
                        if ($v['checkcount'] > 1) {
                            //N1
                            $data[$k] = $this->get_orderdatamore($v, 1);
                            // echo "<pre>";
                            // print_r($data[$k]);exit();
                        } else {
                            $data[$k] = $this->get_orderdatamore($v, 1);
                            //  $data[$k] = $this->get_orderdataone($v);
                        }
                        // echo "<pre>";
                        // print_r($data);exit();
                        $data[$k]['is_hmcheck'] = 1; // 

                        if ($data[$k]['is_zj'] == 1) {
                            $data[$k]['z_jmoney'] = $data[$k]['true_jmoey'];
                            //
                            if ($v['is_h'] == 2) {
                                // 
                                $data[$k]['true_jmoey'] = $data[$k]['z_jmoney']; //
                                $newdata = db('cp_order')->where('status', 2)->where('is_check', 0)->where('is_hmcheck', 0)->where('hg_orderno', $v['orderno'])->column('id,bs'); //
                                $onemoney = $data[$k]['true_jmoey'] / $v['bs']; //
                                if (!empty($newdata)) {
                                    foreach ($newdata as $g => $vv) {
                                        $data[$g]['id'] = $g;
                                        $data[$g]['is_zj'] = 1; //
                                        $data[$g]['status'] = 4; //
                                        $data[$g]['z_jmoney'] = $onemoney * $vv;
                                        $data[$g]['true_jmoey'] = $data[$g]['z_jmoney']; //

                                        $data[$g]['yj'] = bcadd($data[$g]['true_jmoey'] * $gdjl2, 0, 2); //
                                        $data[$g]['true_jmoey'] = $data[$g]['true_jmoey'] - bcadd($data[$g]['true_jmoey'] * $gdjl2, 0, 2); //

                                        $data[$g]['hm_userid'] = $v['user_id'];
                                        $data[$g]['is_hmcheck'] = 1; // 
                                    }
                                }
                                //  print_r($data);exit();

                            } else {
                                //
                                $data[$k]['true_jmoey'] = ($data[$k]['z_jmoney'] / $v['hm_num']) * $v['hm_num2']; //
                                $newdata = db('cp_order')->where('status', 2)->where('is_check', 0)->where('is_hmcheck', 0)->where('hg_orderno', $v['orderno'])->column('id,hm_num2');
                                if (!empty($newdata)) {
                                    foreach ($newdata as $g => $vv) {
                                        $data[$g]['id'] = $g;
                                        $data[$g]['is_zj'] = 1; //
                                        $data[$g]['status'] = 4; //
                                        $data[$g]['z_jmoney'] = $data[$k]['z_jmoney'];
                                        $data[$g]['true_jmoey'] = ($data[$k]['z_jmoney'] / $v['hm_num']) * $vv; //
                                        $data[$g]['yj'] = bcadd($data[$g]['true_jmoey'] * $v['yjbl'], 0, 2); //
                                        $data[$g]['true_jmoey'] = $data[$g]['true_jmoey'] - $data[$g]['yj']; //-
                                        $data[$g]['hm_userid'] = $v['user_id'];
                                        $data[$g]['is_hmcheck'] = 1; // 
                                    }
                                }

                            }
                        } else {
                            //
                            $data[$k]['id'] = $v['id'];
                            $data[$k]['is_zj'] = 2; //
                            $data[$k]['status'] = 3; //
                            $newdata = db('cp_order')->where('status', 2)->where('is_check', 0)->where('is_hmcheck', 0)->where('hg_orderno', $v['orderno'])->column('id,hm_num');
                            if (!empty($newdata)) {
                                foreach ($newdata as $g => $vv) {
                                    $data[$g]['id'] = $g;
                                    $data[$g]['is_zj'] = 2; //
                                    $data[$g]['status'] = 3; //
                                    //
                                }
                                if ($v['is_baodi'] == 1) {
                                    //
                                    $v['bdpc'] = ($v['money'] / $v['hm_num2']) * $v['baodi_num']; //= /= x 
                                    $v['child_count'] = db('cp_order')->where('status', 2)->where('is_check', 0)->where('is_hmcheck', 0)->where('hg_orderno', $v['orderno'])->count(); // /
                                    $v['dfbdpc'] = bcadd($v['bdpc'] / $v['child_count'], 0, 2); //
                                    foreach ($newdata as $g => $vv) {
                                        # code...
                                        $data[$g]['bdpc'] = $v['dfbdpc']; //
                                        $data[$g]['is_hmcheck'] = 1; // 
                                    }

                                }

                            }
                        }

                    }

                } else {
                    // 
                    $data[$k]['id'] = $v['id'];
                    $data[$k]['is_check'] = 1; //

                }
            }
            // echo "<pre>";
            // print_r($data);exit();
            if (!empty($data)) {

                $this->model = new \app\common\model\CpOrder;

                $up = $this->model->saveall($data);
                if ($up) {
                    echo "";exit();
                } else {
                    echo "";exit();
                }
            } else {
                echo "";exit();
            }

        }

    }
//   
    public function check_hmgdjmoney()
    {
        $list = db('cp_order')->where('is_hmcheck', 1)->where('is_h', 'neq', 0)->where('type', 2)->order('createtime desc')->limit(20)->select(); // 
        // echo "<pre>";
        // print_r($list);exit();
        $xejmoney = db('config')->where('name', 'jmoney')->value('value'); //

        if (!empty($list)) {
            foreach ($list as $k => &$v) {
                $data[$k]['id'] = $v['id'];
                $data[$k]['is_hmcheck'] = 2; //
                $data[$k]['status'] = $v['status']; //
                if ($v['status'] == 4) {
                    //
                    if ($v['true_jmoey'] > $xejmoney) {
                        $is_check = 0; // 01
                    } else {
                        $is_check = 1;
                    }
                    //echo $v['true_jmoey'];exit();
                    //

                    if ($v['true_jmoey'] > 0) {
                        UserModel::jmoney($v['true_jmoey'], $v['user_id'], '4', '', '+' . $v['true_jmoey'] . '', $v['orderno'], $is_check); //4 
                    }

                    if (!empty($v['hm_userid'])) {
                        //id
                        if ($v['yj'] > 0) {
                            UserModel::jmoney($v['yj'], $v['hm_userid'], '4', '', '+' . $v['yj'] . '', $v['orderno'], $is_check); //4 
                        }

                    }

                } else {
                    if ($v['bdpc'] > $xejmoney) {
                        $is_check = 0; // 01
                    } else {
                        $is_check = 1;
                    }
                    // 824
                    // UserModel::jmoney($v['bdpc'], $v['user_id'], '4', '', '+' . $v['bdpc'] . '', $v['orderno'], $is_check); //4       
                }
            }
            if (!empty($data)) {
                $this->model = new \app\common\model\CpOrder;
                $up = $this->model->saveall($data);
                if ($up) {
                    echo "";exit();
                } else {
                    echo "";exit();
                }
            } else {
                echo "";exit();
            }
        } else {
            echo "";exit();
        }

    }

/**
 * 
 */
    public function upload()
    {
        Config::set('default_return_type', 'json');
        //cdnurl,cdnurl
        Config::set('upload . cdnurl', '');

        $attachment = null;
        //
        $file = $this->request->file('file');
        try {
            $upload = new Upload($file);
            $attachment = $upload->upload();
        } catch (UploadException $e) {
            $this->error($e->getMessage());
        }
        $this->success('', cdnurl($attachment->url, true), 0);
        //$this->success(__('Uploadedsuccessful'), '', ['url' => $attachment->url, 'fullurl' => cdnurl($attachment->url, true)]);

    }
}

Function Calls

None

Variables

None

Stats

MD5 e383b1746465b9e61263b8fe64ea29c2
Eval Count 0
Decode Time 143 ms