<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/4/25
 * Time: 14:10
 */

namespace App\Lib\Settlement\Adapter;

use Illuminate\Support\Facades\DB;
use App\Lib\Biz\Sport\Common as commonFunction;


class ZqRule
{
    use RulePlus;

    /**
     * 全场|主队|让球
     * @param mixed $model 注单表数据
     * @param mixed $resultModel 结果表数据
     * @param mixed $resultRecords 结果记录表数据
     * @return string 1：赢  -1：输  2：平  3：赢半平半  4：输半平半
     */
    public function coh($model, $resultModels, $resultRecords)
    {
        $isgqwx = $this->GunqiuWeixian($model, $resultModels, $resultRecords);
        if ($isgqwx) {
            return $isgqwx;
        }

        $resultModel = $resultModels['0'];
        $home = intval($resultModel->home_score);
        $guest = intval($resultModel->guest_score);
        $word = $home . '-' . $guest . '(全场)';
        $ret = $this->zq_letball($home - $guest, $model->condition, $word);
        return $ret;
    }

    /**
     * 全场|客队|让球
     * @param mixed $model 注单表数据
     * @param mixed $resultModel 结果表数据
     * @param mixed $resultRecords 结果记录表数据
     * @return string 1：赢  -1：输  2：平  3：赢半平半  4：输半平半
     */
    public function cog($model, $resultModels, $resultRecords)
    {
        $isgqwx = $this->GunqiuWeixian($model, $resultModels, $resultRecords);
        if ($isgqwx) {
            return $isgqwx;
        }

        $resultModel = $resultModels['0'];
        $home = intval($resultModel->home_score);
        $guest = intval($resultModel->guest_score);
        $word = $home . '-' . $guest . '(全场)';
        $ret = $this->zq_letball($guest - $home, $model->condition, $word);
        return $ret;
    }


    /**
     * 上半场|主队|让球
     * @param mixed $model 注单表数据
     * @param mixed $resultModel 结果表数据
     * @param mixed $resultRecords 结果记录表数据
     * @return string 1：赢  -1：输  2：平  3：赢半平半  4：输半平半
     */
    public function coh_h($model, $resultModels, $resultRecords)
    {
        $isgqwx = $this->GunqiuWeixian($model, $resultModels, $resultRecords);
        if ($isgqwx) {
            return $isgqwx;
        }

        $resultModel = $resultModels['0'];
        $home = intval($resultModel->u_home_score);
        $guest = intval($resultModel->u_guest_score);
        $word = $home . '-' . $guest . '(上半场)';
        $ret = $this->zq_letball($home - $guest, $model->condition, $word);
        return $ret;
    }

    /**
     * 上半场|客队|让球
     * @param mixed $model 注单表数据
     * @param mixed $resultModel 结果表数据
     * @param mixed $resultRecords 结果记录表数据
     * @return string 1：赢  -1：输  2：平  3：赢半平半  4：输半平半
     */
    public function cog_h($model, $resultModels, $resultRecords)
    {
        $isgqwx = $this->GunqiuWeixian($model, $resultModels, $resultRecords);
        if ($isgqwx) {
            return $isgqwx;
        }

        $resultModel = $resultModels['0'];
        $home = intval($resultModel->u_home_score);
        $guest = intval($resultModel->u_guest_score);
        $word = $home . '-' . $guest . '(上半场)';
        $ret = $this->zq_letball($guest - $home, $model->condition, $word);
        return $ret;

    }

    /**
     * 进球|全场|大
     * @param mixed $model 注单表数据
     * @param mixed $resultModel 结果表数据
     * @param mixed $resultMgoal_size_smallodel 结果表数据
     * @param mixed $resultRecords 结果记录表数据
     * @return string 1：赢  -1：输  2：平  3：赢半平半  4：输半平半
     */
    public function goal_size_home($model, $resultModels, $resultRecords)
    {
        $isgqwx = $this->GunqiuWeixian($model, $resultModels, $resultRecords);
        if ($isgqwx) {
            return $isgqwx;
        }

        $resultModel = $resultModels['0'];
        $home = intval($resultModel->u_home_score);
        $guest = intval($resultModel->u_guest_score);
        $total = $home + $guest;
        $word = $home . '-' . $guest . '(全场)';
        $ret = $this->zq_inball_bigsmall($total, $model->condition, 2, $word);
        return $ret;
    }

    /**
     * 进球|全场|小
     * @param mixed $model 注单表数据
     * @param mixed $resultModel 结果表数据
     * @param mixed $resultRecords 结果记录表数据
     * @return string 1：赢  -1：输  2：平  3：赢半平半  4：输半平半
     */
    public function goal_size_guest($model, $resultModels, $resultRecords)
    {
        $isgqwx = $this->GunqiuWeixian($model, $resultModels, $resultRecords);
        if ($isgqwx) {
            return $isgqwx;
        }

        $resultModel = $resultModels['0'];
        $home = intval($resultModel->u_home_score);
        $guest = intval($resultModel->u_guest_score);
        $total = $home + $guest;
        $word = $home . '-' . $guest . '(全场)';
        $ret = $this->zq_inball_bigsmall($total, $model->condition, 1, $word);
        return $ret;
    }


    //全场|进球|大
    public function gsb($model, $resultModels, $resultRecords)
    {
        $isgqwx = $this->GunqiuWeixian($model, $resultModels, $resultRecords);
        if ($isgqwx) {
            return $isgqwx;
        }

        $resultModel = $resultModels['0'];
        $allscore = intval($resultModel->home_score) + intval($resultModel->guest_score);
        $word = $resultModel->home_score . '-' . $resultModel->guest_score . "(全场)";
        $returnDatas = $this->zq_inball_bigsmall($allscore, $model->condition, 2, $word);
        return $returnDatas;

    }

    //全场|进球|小
    public function gss($model, $resultModels, $resultRecords)
    {
        $isgqwx = $this->GunqiuWeixian($model, $resultModels, $resultRecords);
        if ($isgqwx) {
            return $isgqwx;
        }

        $resultModel = $resultModels['0'];
        $allscore = intval($resultModel->home_score) + intval($resultModel->guest_score);
        $word = $resultModel->home_score . '-' . $resultModel->guest_score . "(全场)";
        $returnDatas = $this->zq_inball_bigsmall($allscore, $model->condition, 1, $word);
        return $returnDatas;
    }

    /**
     * 进球|上半场|大
     * @param mixed $model 注单表数据
     * @param mixed $resultModel 结果表数据
     * @param mixed $resultRecords 结果记录表数据
     * @return string 1：赢  -1：输  2：平  3：赢半平半  4：输半平半
     */
    public function gsb_h($model, $resultModels, $resultRecords)
    {
        $isgqwx = $this->GunqiuWeixian($model, $resultModels, $resultRecords);
        if ($isgqwx) {
            return $isgqwx;
        }

        $resultModel = $resultModels['0'];
        $score = intval($resultModel->u_home_score) + intval($resultModel->u_guest_score);
        return $this->zq_inball_bigsmall($score, $model->condition, 2, $resultModel->u_home_score . '-' . $resultModel->u_guest_score . '(上半场)');
    }

    /**
     * 进球|上半场|小
     * @param mixed $model 注单表数据
     * @param mixed $resultModel 结果表数据
     * @param mixed $resultRecords 结果记录表数据
     * @return string 1：赢  -1：输  2：平  3：赢半平半  4：输半平半
     */
    public function gss_h($model, $resultModels, $resultRecords)
    {
        $isgqwx = $this->GunqiuWeixian($model, $resultModels, $resultRecords);
        if ($isgqwx) {
            return $isgqwx;
        }

        $resultModel = $resultModels['0'];
        $score = intval($resultModel->u_home_score) + intval($resultModel->u_guest_score);
        return $this->zq_inball_bigsmall($score, $model->condition, 1, $resultModel->u_home_score . '-' . $resultModel->u_guest_score . '(上半场)');
    }


    /**
     * 全场|主队|独赢
     * @param mixed $model 注单表数据
     * @param mixed $resultModel 结果表数据
     * @param mixed $resultRecords 结果记录表数据
     * @return string 1：赢  -1：输
     */
    public function ch($model, $resultModels, $resultRecords)
    {
        $isgqwx = $this->GunqiuWeixian($model, $resultModels, $resultRecords);
        if ($isgqwx) {
            return $isgqwx;
        }

        $resultModel = $resultModels['0'];
        $home = intval($resultModel->home_score);
        $guest = intval($resultModel->guest_score);
        $word = $home . '-' . $guest . '(全场)';
        $ret = $this->zq_duyingv2(1, 4, $resultModel, $word);
        return $ret;
    }

    /**
     * 全场|客队|独赢
     * @param mixed $model 注单表数据
     * @param mixed $resultModel 结果表数据
     * @param mixed $resultRecords 结果记录表数据
     * @return string 1：赢  -1：输
     */
    public function cg($model, $resultModels, $resultRecords)
    {
        $isgqwx = $this->GunqiuWeixian($model, $resultModels, $resultRecords);
        if ($isgqwx) {
            return $isgqwx;
        }

        $resultModel = $resultModels['0'];
        $home = intval($resultModel->home_score);
        $guest = intval($resultModel->guest_score);
        $word = $home . '-' . $guest . '(全场)';
        $ret = $this->zq_duyingv2(2, 4, $resultModel, $word);
        return $ret;
    }

    /**
     * 全场|主客平|独赢
     * @param mixed $model 注单表数据
     * @param mixed $resultModel 结果表数据
     * @param mixed $resultRecords 结果记录表数据
     * @return string 1：赢  -1：输
     */
    public function cd($model, $resultModels, $resultRecords)
    {
        $isgqwx = $this->GunqiuWeixian($model, $resultModels, $resultRecords);
        if ($isgqwx) {
            return $isgqwx;
        }

        $resultModel = $resultModels['0'];
        $home = intval($resultModel->home_score);
        $guest = intval($resultModel->guest_score);
        $word = $home . '-' . $guest . '(全场)';
        if ($home == $guest) {
            $return['result'] = 1;
        } else {
            $return['result'] = -1;
        }
        $return['matchResult'] = $word;
        return $return;
    }

    /**
     * 上半场|主队|独赢
     * @param mixed $model 注单表数据
     * @param mixed $resultModel 结果表数据
     * @param mixed $resultRecords 结果记录表数据
     * @return string 1：赢  -1：输
     */
    public function ch_h($model, $resultModels, $resultRecords)
    {
        $isgqwx = $this->GunqiuWeixian($model, $resultModels, $resultRecords);
        if ($isgqwx) {
            return $isgqwx;
        }

        $resultModel = $resultModels['0'];
        $word = $resultModel->u_home_score . '-' . $resultModel->u_guest_score . '(上半场)';
        return $this->zq_duyingv2(1, 1, $resultModel, $word);

    }

    /**
     * 上半场|客队|独赢
     * @param mixed $model 注单表数据
     * @param mixed $resultModel 结果表数据
     * @param mixed $resultRecords 结果记录表数据
     * @return string 1：赢  -1：输
     */
    public function cg_h($model, $resultModels, $resultRecords)
    {
        $isgqwx = $this->GunqiuWeixian($model, $resultModels, $resultRecords);
        if ($isgqwx) {
            return $isgqwx;
        }

        $resultModel = $resultModels['0'];
        $word = $resultModel->u_home_score . '-' . $resultModel->u_guest_score . '(上半场)';
        return $this->zq_duyingv2(2, 1, $resultModel, $word);

    }

    /**
     * 上半场|主客平|独赢
     * @param mixed $model 注单表数据
     * @param mixed $resultModel 结果表数据
     * @param mixed $resultRecords 结果记录表数据
     * @return string 1：赢  -1：输
     */
    public function cd_h($model, $resultModels, $resultRecords)
    {
        $isgqwx = $this->GunqiuWeixian($model, $resultModels, $resultRecords);
        if ($isgqwx) {
            return $isgqwx;
        }

        $resultModel = $resultModels['0'];
        $word = $resultModel->u_home_score . '-' . $resultModel->u_guest_score . '(上半场)';
        if ($resultModel->u_home_score == $resultModel->u_guest_score) {
            $result = 1;
        } else {
            $result = -1;
        }
        return ['result' => $result, 'matchResult' => $word];
    }



    //  first_last_ball最先/最后进球 开始-----------------------
    //主队|最先进球
    public function flbfh($model, $resultModel, $resultRecords)
    {
        $return = ['result' => -1, 'matchResult' => ''];
        $resultModel = $resultModel['0'];
        $resArray = json_decode($resultModel->first_score, true);
        if ($resArray && isset($resArray['teamscore'])) {
            if ($resArray['teamscore'] == '') {
                $word = '0:0';
                $return['result'] = -1;
            } elseif ($resArray['teamscore'] == $resultModel->home_team) {
                $word = '1:0';
                $return['result'] = 1;
            } else {
                $word = '0:1';
                $return['result'] = -1;
            }
        } else {
            $word = '0:0';
            $return['result'] = -1;
        }
        $return['matchResult'] = $word;
        return $return;
    }

    //客队|最先进球
    public function flbfg($model, $resultModel, $resultRecords)
    {
        $return = ['result' => -1, 'matchResult' => ''];
        $resultModel = $resultModel['0'];
        $resArray = json_decode($resultModel->first_score, true);
        if ($resArray && isset($resArray['teamscore'])) {
            if ($resArray['teamscore'] == '') {
                $word = '0:0';
                $return['result'] = -1;
            } elseif ($resArray['teamscore'] == $resultModel->guest_team) {
                $word = '0:1';
                $return['result'] = 1;
            } else {
                $word = '1:0';
                $return['result'] = -1;
            }
        } else {
            $word = '0:0';
            $return['result'] = -1;
        }
        $return['matchResult'] = $word;
        return $return;

    }

    //主队|最后进球
    public function flblh($model, $resultModel, $resultRecords)
    {
        $isgqwx = $this->GunqiuWeixian($model, $resultModel, $resultRecords);
        if ($isgqwx) {
            return $isgqwx;
        }

        $resultModel = $resultModel['0'];
        $word = ($resultModel->last_score != '') ? (($resultModel->last_score == $model->home_team) ? '1:0' : '0:1') : '0:0';
        $word .= '(主客)';

        if (trim($resultModel->last_score) == trim($resultModel->home_team)) {
            return ['result' => 1, 'matchResult' => $word];
        } else {
            return ['result' => -1, 'matchResult' => $word];
        }


    }

    //客队|最后进球
    public function flblg($model, $resultModel, $resultRecords)
    {
        $isgqwx = $this->GunqiuWeixian($model, $resultModel, $resultRecords);
        if ($isgqwx) {
            return $isgqwx;
        }

        $resultModel = $resultModel['0'];
        $word = ($resultModel->last_score != '') ? (($resultModel->last_score == $model->guest_team) ? '0:1' : '1:0') : '0:0';
        $word .= '(主客)';

        if (trim($resultModel->last_score) == trim($resultModel->guest_team)) {
            return ['result' => 1, 'matchResult' => $word];
        } else {
            return ['result' => -1, 'matchResult' => $word];
        }

    }

    //没有进球
    public function flbn($model, $resultModel, $resultRecords)
    {
        $isgqwx = $this->GunqiuWeixian($model, $resultModel, $resultRecords);
        if ($isgqwx) {
            return $isgqwx;
        }

        $resultModel = $resultModel['0'];
        $home = intval($resultModel->home_score);
        $guest = intval($resultModel->guest_score);
        $all_score = $home + $guest;
        $word = ($home > 0 ? 1 : 0) . '-' . ($guest > 0 ? 1 : 0) . '(主客)';

        if ($all_score <= 0) {
            return ['result' => 1, 'matchResult' => $word];
        } else {
            return ['result' => -1, 'matchResult' => $word];
        }

    }
    //////////  first_last_ball最先/最后进球 结束-----------------------

    /**
     * 足球波胆 规则
     * @param $bet_match  投注赛事数据
     * @param $result_match  最终结果
     * @param $result_match_r  结果记录
     * User: Tank
     * Date: 2019/5/13
     * Time: 10:19
     */
    public function B($bet_match, $result_match, $result_match_r)
    {
        $p_code = $bet_match->p_code;
        $odds_code = $bet_match->odds_code;
        //==获取是否是滚球投注==
        $isgqwx = $this->GunqiuWeixian($bet_match, $result_match, $result_match_r);
        if ($isgqwx) {
            return $isgqwx;
        }
        //==end==

        //获取主客队投注比分
        $bet_score = explode('-', $bet_match->condition);
        $bet_home_score = (int)$bet_score[0];
        $bet_guest_score = isset($bet_score[1]) ? intval($bet_score[1]) : 0;


        //获取赛事最终结果数据
        $result_match = $this->getHalfData($result_match);
        if (strstr($odds_code, "_h")) {//上半场

            //获取主客队上半场得分
            $home_score = $result_match->u_home_score;
            $guest_score = $result_match->u_guest_score;
            //返回结果
            $data = [
                'result' => 1,
                'matchResult' => "$home_score-$guest_score(上半场)"
            ];
            if (strstr($bet_match->condition, "其他")) {
                if (($home_score > 3) || ($guest_score > 3)) {
                    return $data;
                }
            }
            //判断结果
            if ($bet_home_score == $home_score and $bet_guest_score == $guest_score) {
                return $data;
            }
            $data['result'] = -1;
            return $data;
        } else {//全场
            //获取主客队全场得分
            $home_score = $result_match->home_score;
            $guest_score = $result_match->guest_score;

            //返回结果
            $data = [
                'result' => 1,
                'matchResult' => "$home_score-$guest_score(全场)"
            ];
            if (strstr($bet_match->condition, "其他")) {
                if (($home_score > 4) || ($guest_score > 4)) {
                    return $data;
                }
            }
            //判断结果
            if ($bet_home_score == $home_score and $bet_guest_score == $guest_score) {
                return $data;
            }
            $data['result'] = -1;
            return $data;
        }
    }

    //结果单/双 home_score 主队进球数 guest_score 客队进球数 home_rate 主队让球 guest_rate 客队让球 u_home_score 上半场主队进球 u_guest_score 上半场-客队进球数  two_sides_single 全场单 two_sides_double 全场双 half_two_sides_single 上半场单 half_two_sides_double 上半场双
    public function TS($model, $resultModels, $resultRecords)
    {
        $isgqwx = $this->GunqiuWeixian($model, $resultModels, $resultRecords);
        if ($isgqwx) {
            return $isgqwx;
        }

        $resultModel = $resultModels['0'];
        $resulttod = intval($resultModel->home_score) + intval($resultModel->guest_score);//全场

        $score_home = intval($resultModel->home_score);
        $guest_home = intval($resultModel->guest_score);
        $word_all = $score_home . '-' . $guest_home . '(全场)';
        $score_home_half = intval($resultModel->u_home_score);
        $guest_home_half = intval($resultModel->u_guest_score);
        $word_all_half = $score_home_half . '-' . $guest_home_half . '(半场)';


        if ($resulttod % 2 == 0) {
            $text = '双';
        } else {
            $text = '单';
        }

        if ($model->odds_code == "tss" || $model->odds_code == 'tsd') {
            if ($text == $model->condition) {
                $dsresult = 1;
            } else {
                $dsresult = -1;
            }
            return ['result' => $dsresult, 'matchResult' => $word_all];
        } elseif ($model->odds_code == 'tss_h' || $model->odds_code == 'tsd_h') {
            $hafs = intval($resultModel->u_home_score) + intval($resultModel->u_guest_score);
            $text = ($hafs % 2 == 0) ? '双' : '单';
            $dsresult = ($text == $model->condition) ? 1 : -1;
            return ['result' => $dsresult, 'matchResult' => $word_all_half];
        } else {
            $data = [
                'result' => 100,
                'matchResult' => "参数不存在",
            ];
            return $data;
        }

    }

    //结果总数 home_score 主队进球数 guest_score 客队进球数 home_rate 主队让球 guest_rate 客队让球 u_home_score 上半场-主队进球数 u_guest_score 上半场-客队进球数
    public function TG($model, $resultModels, $resultRecords)
    {
        $isgqwx = $this->GunqiuWeixian($model, $resultModels, $resultRecords);
        if ($isgqwx) {
            return $isgqwx;
        }

        $resultModel = $resultModels['0'];
        //全场总进球数
        $resulttod = intval($resultModel->home_score) + intval($resultModel->guest_score);
        $score_home = intval($resultModel->home_score);
        $guest_home = intval($resultModel->guest_score);
        $word_all = $score_home . '-' . $guest_home . '(全场)';
        $score_home_half = intval($resultModel->u_home_score);
        $guest_home_half = intval($resultModel->u_guest_score);
        $word_all_half = $score_home_half . '-' . $guest_home_half . '(半场)';

        //上半场总进球数
        $firsthalftod = intval($resultModel->u_home_score) + intval($resultModel->u_guest_score);
        $results = 0;
        $resultb = 0;
        if ($model->odds_code == "tg2") {
            if (4 <= $resulttod and $resulttod <= 6) {
                $results = 1;
            } else {
                $results = -1;
            }
        }
        if ($model->odds_code == "tg0") {
            if (0 <= $resulttod and $resulttod <= 1) {
                $results = 1;
            } else {
                $results = -1;
            }
        }
        if ($model->odds_code == "tg1") {
            if (2 <= $resulttod and $resulttod <= 3) {
                $results = 1;
            } else {
                $results = -1;
            }
        }
        if ($model->odds_code == "tg3") {
            if (7 <= $resulttod) {
                $results = 1;
            } else {
                $results = -1;
            }
        }
        if ($model->odds_code == "tg0_h") {
            if ($firsthalftod == 0) {
                $resultb = 1;
            } else {
                $resultb = -1;
            }
        }
        if ($model->odds_code == "tg1_h") {
            if ($firsthalftod == 1) {
                $resultb = 1;
            } else {
                $resultb = -1;
            }
        }
        if ($model->odds_code == "tg2_h") {
            if ($firsthalftod == 2) {
                $resultb = 1;
            } else {
                $resultb = -1;
            }
        }
        if ($model->odds_code == "tg3_h") {
            if ($firsthalftod >= 3) {
                $resultb = 1;
            } else {
                $resultb = -1;
            }
        }

        if ($results == 1) {
            $data = [
                'result' => 1,
                'matchResult' => $word_all,
            ];
        }
        if ($results == -1) {
            $data = [
                'result' => -1,
                'matchResult' => $word_all,
            ];
        }
        if ($resultb == 1) {
            $data = [
                'result' => 1,
                'matchResult' => $word_all_half,
            ];
        }
        if ($resultb == -1) {
            $data = [
                'result' => -1,
                'matchResult' => $word_all_half,
            ];
        }
        return $data;
    }

    //球队进球数:大/小
    //condition   0.5    或   0.5/1  这种
    public function TB($model, $resultModels, $result_match_r = [])
    {
        $isgqwx = $this->GunqiuWeixian($model, $resultModels, $result_match_r);
        if ($isgqwx) {
            return $isgqwx;
        }

        $resultModel = $resultModels['0'];

        $odds_code = trim($model->odds_code);
        $score_home = intval($resultModel->home_score);
        $score_guest = intval($resultModel->guest_score);
        $score_home_uhalf = intval($resultModel->u_home_score);
        $score_guest_uhalf = intval($resultModel->u_guest_score);

        switch ($odds_code) {
            case 'tbhb':
                $returnDatas['matchResult'] = $score_home . '-' . $score_guest . '(全场)';
                $returnDatas = $this->zq_inball_bigsmall($score_home, $model->condition, 2, $returnDatas['matchResult']);
                break;
            case 'tbhs':
                $returnDatas['matchResult'] = $score_home . '-' . $score_guest . '(全场)';
                $returnDatas = $this->zq_inball_bigsmall($score_home, $model->condition, 1, $returnDatas['matchResult']);
                break;
            case 'tbgb':
                $returnDatas['matchResult'] = $score_home . '-' . $score_guest . '(全场)';
                $returnDatas = $this->zq_inball_bigsmall($score_guest, $model->condition, 2, $returnDatas['matchResult']);
                break;
            case 'tbgs':
                $returnDatas['matchResult'] = $score_home . '-' . $score_guest . '(全场)';
                $returnDatas = $this->zq_inball_bigsmall($score_guest, $model->condition, 1, $returnDatas['matchResult']);
                break;
            case 'tbhb_h':
                $returnDatas['matchResult'] = $score_home_uhalf . '-' . $score_guest_uhalf . '(上半场)';
                $returnDatas = $this->zq_inball_bigsmall($score_home_uhalf, $model->condition, 2, $returnDatas['matchResult']);
                break;
            case 'tbhs_h':
                $returnDatas['matchResult'] = $score_home_uhalf . '-' . $score_guest_uhalf . '(上半场)';
                $returnDatas = $this->zq_inball_bigsmall($score_home_uhalf, $model->condition, 1, $returnDatas['matchResult']);
                break;
            case 'tbgb_h':
                $returnDatas['matchResult'] = $score_home_uhalf . '-' . $score_guest_uhalf . '(上半场)';
                $returnDatas = $this->zq_inball_bigsmall($score_guest_uhalf, $model->condition, 2, $returnDatas['matchResult']);
                break;
            case 'tbgs_h':
                $returnDatas['matchResult'] = $score_home_uhalf . '-' . $score_guest_uhalf . '(上半场)';
                $returnDatas = $this->zq_inball_bigsmall($score_guest_uhalf, $model->condition, 1, $returnDatas['matchResult']);
                break;
        }
        return $returnDatas;
    }


    /**
     * 半场/全场 投注规则
     * User: Tank
     * Date: 2019/5/13
     * Time: 10:19
     */
    public function HF($bet_match, $result_match, $result_match_r)
    {

        if (empty($bet_match) || empty($result_match)) return false;

        //获取父/子级赔率代码
        $p_code = $bet_match->p_code;
        $odds_code = $bet_match->odds_code;

        //==获取是否是滚球投注==
        $isgqwx = $this->GunqiuWeixian($bet_match, $result_match, $result_match_r);
        if ($isgqwx) {
            return $isgqwx;
        }
        //==end==

        //获取最终赛事数据
        $result_match = $this->getHalfData($result_match);
        //获取主客队上半场得分
        $half_home_score = $result_match->u_home_score;
        $half_guest_score = $result_match->u_guest_score;

        //获取主客队全场得分
        $full_home_score = $result_match->home_score;
        $full_guest_score = $result_match->guest_score;
        //半场/全场盘口


        //返回结果
        $data = [
            'result' => 1,
            'matchResult' => "$half_home_score-$half_guest_score(上半场);$full_home_score-$full_guest_score(全场)"
        ];
        switch ($odds_code) {
            case 'hfhh':// 主-主
                if ($half_home_score > $half_guest_score and $full_home_score > $full_guest_score) return $data;
                break;
            case 'hfhd':// 主-和
                if ($half_home_score > $half_guest_score and $full_home_score == $full_guest_score) return $data;
                break;
            case 'hfhg':// 主-客
                if ($half_home_score > $half_guest_score and $full_home_score < $full_guest_score) return $data;
                break;
            case 'hfdh':// 和-主
                if ($half_home_score == $half_guest_score and $full_home_score > $full_guest_score) return $data;
                break;
            case 'hfdd':// 和-和
                if ($half_home_score == $half_guest_score and $full_home_score == $full_guest_score) return $data;
                break;
            case 'hfdg':// 和-客
                if ($half_home_score == $half_guest_score and $full_home_score < $full_guest_score) return $data;
                break;
            case 'hfgh':// 客-主
                if ($half_home_score < $half_guest_score and $full_home_score > $full_guest_score) return $data;
                break;
            case 'hfgd':// 客-和
                if ($half_home_score < $half_guest_score and $full_home_score == $full_guest_score) return $data;
                break;
            case 'hfgg':// 客-客
                if ($half_home_score < $half_guest_score and $full_home_score < $full_guest_score) return $data;
                break;
            default:
                return false;
        }

        $data['result'] = -1;
        return $data;
    }

    /**
     * @param $result_match_r 赛事结果记录
     * @return mixed 返回最新一条上半场结果数据
     */
    public function getHalfData($result_match_r = [])
    {
        return $result_match_r['0'];

        if (empty($result_match_r)) return false;
        if (is_array($result_match_r)) {
            foreach ($result_match_r as $k => $v) {
                return $v;
            }
        }
    }

    /**bo
     * 冠军盘口投注
     * $bet_match 投注赛事数据
     * $result_match 联赛结果 数据 根据玩法代码查询一条
     * $result_match_r 无用参数
     */
    public function gj($bet_match, $result_match, $result_match_r)
    {

//        $bet_match = DB::table('money_buy_match')->where('match_id', 127317)->first();
//        $bet_match->odds_code = '巴西小组赛积分成绩';

//        $result_match = DB::table('st_zq_league_result')->where(['lg_id'=>27317,'game_name'=>$bet_match->odds_code])->first();

        //获取 赛事最终数据
        $result_match = $this->getHalfData($result_match);
        if (empty($bet_match) || empty($result_match)) return false;
        if ($bet_match->p_code != 'gj') return false;//冠军玩法

        if ($bet_match->odds_code == $result_match->game_name) {
            $condition = $bet_match->condition;

            //进球数判断
            if (strpos($bet_match->odds_code, '进球数') !== false) {
                //返回结果
                $data = [
                    'result' => 1,
                    'matchResult' => "$result_match->result(球队进球数)"
                ];
                //获取数值
                $bet = $this->findNum($condition);
                //以上/以下判断
                if (strpos($condition, '上') !== false) {
                    if ($bet < $result_match->result) {
                        return $data;
                    }
                    $data['result'] = -1;
                    return $data;
                }
                if (strpos($condition, '下') !== false) {
                    if ($bet > $result_match->result) {
                        return $data;
                    }
                    $data['result'] = -1;
                    return $data;
                }
                //大/小判断
                if (strpos($condition, '大') !== false) {
                    if ($bet < $result_match->result) {
                        return $data;
                    }
                    $data['result'] = -1;
                    return $data;
                }
                if (strpos($condition, '小') !== false) {
                    if ($bet > $result_match->result) {
                        return $data;
                    }
                    $data['result'] = -1;
                    return $data;
                }
            }
            //积分成绩判断
            if (strpos($bet_match->odds_code, '积分') !== false) {
                //返回结果
                $data = [
                    'result' => 1,
                    'matchResult' => "$result_match->result(球队积分)"
                ];
                $condition = $bet_match->condition;
                //获取数值
                $bet = $this->findNum($condition);
                if ($bet == $result_match->result) {
                    return $data;
                }
                $data['result'] = -1;
                return $data;
            }

            //如果条件中没有数字，则获取球队/球员结果
            if ((preg_match('/\d+/', $condition)) == 0) {
                //返回结果
                $data = [
                    'result' => 1,
                    'matchResult' => "$result_match->result(晋级球队)"
                ];
                $result = $this->teamJudge($condition, $result_match->result);

                if ($result) {
                    return $data;
                }
                $data['result'] = -1;
                return $data;
            };

            return false;
        }
        return false;
    }

    /**
     * 冠军盘口 球队/球员结果判断
     */
    public function teamJudge($condition, $result, $result_match_r = [])
    {
        //返回结果数组中是否包含该球队
        $result = in_array($condition, json_decode($result, true));
        return $result;
    }

    /**
     * @param string $str
     * @return string
     * 处理字符串中的数字
     */
    public function findNum($str = '')
    {
        $str = trim($str);
        if (empty($str)) {
            return '';
        }
        $result = '';
        for ($i = 0; $i < strlen($str); $i++) {
            if (is_numeric($str[$i]) || $str[$i] == '.') {
                $result .= $str[$i];
            }
        }
        //如果有小数点，返回浮点数
        if (strpos($result, '.')) return floatval($result);
        //返回整数
        return (int)$result;
    }


    /**
     * 角球相关--------->开始
     */
    public function CB($model, $resultModels, $result_match_r)
    {
        //如果是滚球投注，则进行危险球审核
        $isgqwx = $this->GunqiuWeixian($model, $resultModels, $result_match_r);
        if ($isgqwx) {
            return $isgqwx;
        }
        //==end==

        $odds_code = $model->odds_code;
        $isHalf = strpos(strtolower($odds_code), 'half');
        if ($isHalf) {
            return $this->corner_ball_half($model, $resultModels, $result_match_r);
        } else {
            return $this->corner_ball_all($model, $resultModels, $result_match_r);
        }
    }

    public function corner_ball_all($model, $resultModels, $result_match_r)
    {

        $resultModel = $resultModels['0'];
        if ($resultModel->corner_ball == '') {
            $game_ret = json_decode(json_encode(['home' => 0, 'guest' => 0, 'home_half' => 0, 'guest_half' => 0]));
        } else {
            $game_ret = json_decode($resultModel->corner_ball);
        }
        $word = $game_ret->home . '-' . $game_ret->guest . "(全场)";
        $returnDatas = ['result' => -1, 'matchResult' => $word];

        $odds_code = $model->odds_code;
        switch ($odds_code) {
            case "cbcoh":
                $returnDatas = $this->zq_letball($game_ret->home - $game_ret->guest, $model->condition, $word);
                break;
            case "cbcog":
                $returnDatas = $this->zq_letball($game_ret->guest - $game_ret->home, $model->condition, $word);
                break;
            case "cbgb":
                $returnDatas = $this->zq_inball_bigsmall($game_ret->home - $game_ret->guest, $model->condition, 2, $word);
                break;
            case "cbgs":
                $returnDatas = $this->zq_inball_bigsmall($game_ret->guest - $game_ret->home, $model->condition, 1, $word);
                break;
            case "cbch":
                $returnDatas = $this->zq_duyingv2(1, 4, $resultModel, $word);
                break;
            case "cbcg":
                $returnDatas = $this->zq_duyingv2(2, 4, $resultModel, $word);
                break;
            case "cbcd":
                $returnDatas['result'] = ($game_ret->home == $game_ret->guest) ? 1 : -1;
                break;
            case "cbtss":
                $returnDatas = $this->zq_doublesing($game_ret->home + $game_ret->guest, $model->condition, $word);
                break;
            case "cbtsd":
                $returnDatas = $this->zq_doublesing($game_ret->home + $game_ret->guest, $model->condition, $word);
                break;
            default:
                $returnDatas = ['result' => 2, 'matchResult' => '(玩法无规则异常)-' . $odds_code];
        }
        return $returnDatas;
    }

    public function corner_ball_half($model, $resultModels, $result_match_r)
    {

        $resultModel = $resultModels['0'];
        if ($resultModel->corner_ball == '') {
            $game_ret = json_decode(json_encode(['home' => 0, 'guest' => 0, 'home_half' => 0, 'guest_half' => 0]));
        } else {
            $game_ret = json_decode($resultModel->corner_ball);
        }
        $word = $game_ret->home_half . '-' . $game_ret->guest_half . "(上半场)";
        $returnDatas = ['result' => -1, 'matchResult' => $word];

        $odds_code = $model->odds_code;
        switch ($odds_code) {
            case "cbcoh_h":
                $returnDatas = $this->zq_letball($game_ret->home_half - $game_ret->guest_half, $model->condition, $word);
                break;
            case "cbcog_h":
                $returnDatas = $this->zq_letball($game_ret->guest_half - $game_ret->home_half, $model->condition, $word);
                break;
            case "cbgb_h":
                $returnDatas = $this->zq_inball_bigsmall($game_ret->home_half - $game_ret->guest_half, $model->condition, 2, $word);
                break;
            case "cbgs_h":
                $returnDatas = $this->zq_inball_bigsmall($game_ret->guest_half - $game_ret->home_half, $model->condition, 1, $word);
                break;
            case "cbch_h":
                $returnDatas = $this->zq_duyingv2(1, 1, $resultModel, $word);
                break;
            case "cbcg_h":
                $returnDatas = $this->zq_duyingv2(2, 1, $resultModel, $word);
                break;
            case "cbcd_h":
                $returnDatas['result'] = ($game_ret->home_half == $game_ret->guest_half) ? 1 : -1;
                break;
            case "cbtss_h":
                $returnDatas = $this->zq_doublesing($game_ret->home_half + $game_ret->guest_half, $model->condition, $word);
                break;
            case "cbtsd_h":
                $returnDatas = $this->zq_doublesing($game_ret->home_half + $game_ret->guest_half, $model->condition, $word);
                break;
            default:
                $returnDatas = ['result' => 2, 'matchResult' => '(玩法无规则异常)-' . $odds_code];
        }
        return $returnDatas;
    }

    /**
     * 角球相关--------->结束
     */


    //净胜球相关
    public function GD($model, $resultModels, $result_match_r)
    {
        //如果是滚球投注，则进行危险球审核
        $isgqwx = $this->GunqiuWeixian($model, $resultModels, $result_match_r);
        if ($isgqwx) {
            return $isgqwx;
        }
        //==end==

        $resultModel = $resultModels['0'];
        $home = intval($resultModel->home_score);
        $guest = intval($resultModel->guest_score);
        $word = $home . '-' . $guest . '(全场)';
        $game_odds = $model->odde_code;

        switch ($game_odds) {
            case  'gdh1':
                $ret = $this->zq_jingshengqiu($home, $guest, 1, $word);
                break;
            case 'gdh2':
                $ret = $this->zq_jingshengqiu($home, $guest, 2, $word);
                break;
            case 'gdh3':
                $ret = $this->zq_jingshengqiu($home, $guest, 3, $word);
                break;
            case 'gdh4':
                $ret = $this->zq_jingshengqiu($home, $guest, 4, $word);
                break;
            case 'gdg1':
                $ret = $this->zq_jingshengqiu($guest, $home, 1, $word);
                break;
            case 'gdg2':
                $ret = $this->zq_jingshengqiu($guest, $home, 2, $word);
                break;
            case 'gdg3':
                $ret = $this->zq_jingshengqiu($guest, $home, 3, $word);
                break;
            case 'gdg4':
                $ret = $this->zq_jingshengqiu($guest, $home, 4, $word);
                break;
            case 'gd0':
                $ret = $this->zq_jingshengqiu($home, $guest, 0, $word);
                break;
            case 'gdd':
                $ret = $this->zq_jingshengqiu($guest, $home, 99, $word);
                break;
            default:
                $ret = $this->return_error;
                break;
        }
        return $ret;
    }

    //足球净胜球胜负判断
    private function zq_jingshengqiu($winScore, $loseScore, $condNum, $word)
    {
        if (in_array($condNum, [1, 2, 3])) {
            if ($winScore - $loseScore = $condNum) {
                return ['result' => 1, 'matchResult' => $word];
            } else {
                return ['result' => -1, 'matchResult' => $word];
            }
        }

        if ($condNum == 4) {
            if ($winScore - $loseScore >= 4) {
                return ['result' => 1, 'matchResult' => $word];
            } else {
                return ['result' => -1, 'matchResult' => $word];
            }
        }

        if ($condNum == 0) {
            if ($winScore == 0 && $loseScore == 0) {
                return ['result' => 1, 'matchResult' => $word];
            } else {
                return ['result' => -1, 'matchResult' => $word];
            }
        }

        if ($condNum == 99) {
            if ($winScore > 0 && $winScore == $loseScore) {
                return ['result' => 1, 'matchResult' => $word];
            } else {
                return ['result' => -1, 'matchResult' => $word];
            }
        }
        return $this->return_error;
    }


    /**
     * 罚球相关  开始
     */
    public function PC($model, $resultModels, $result_match_r)
    {
        //==获取是否是滚球投注==
        $is_rolling = $model->is_rolling;
        //如果是滚球投注，则进行危险球审核
        if ($is_rolling == 1) {
            $ret = commonFunction::WARN_CHECK($model, $resultModels);
            //如果审核不通过，则返回2   1赢 2平 -1输
            if ($ret['code'] == -1) {
                $data = [
                    'result' => 2,
                    'msg' => "滚球投注，危险球审核不通过",
                    'warn_more' => $ret['warn_more']
                ];
                return $data;
            }
        }
        //==end==
        $odde_code = $model->odde_code;
        $isHalf = strpos(strtolower($odde_code), 'half');
        if ($isHalf) {
            return $this->penalty_card_half($model, $resultModels, $result_match_r);
        } else {
            return $this->penalty_card_all($model, $resultModels, $result_match_r);
        }
    }

    public function penalty_card_half($model, $resultModels, $result_match_r)
    {

        $resultModel = $resultModels['0'];
        if ($resultModel->conner_ball == '') {
            $game_ret = json_decode(json_encode(['home' => 0, 'guest' => 0, 'home_half' => 0, 'guest_half' => 0]));
        } else {
            $game_ret = json_decode($resultModel->penalty_card);
        }
        $word = $game_ret->home_half . '-' . $game_ret->guest_half . "(上半场)";
        $returnDatas = ['result' => -1, 'matchResult' => $word];

        $odds_code = $model->odds_code;
        switch ($odds_code) {
            case "pccoh_h":
                $returnDatas = $this->zq_letball($game_ret->home_half - $game_ret->guest_half, $model->condition, $word);
                break;
            case "pccog_h":
                $returnDatas = $this->zq_letball($game_ret->guest_half - $game_ret->home_half, $model->condition, $word);
                break;
            case "pcgb_h":
                $returnDatas = $this->zq_inball_bigsmall($game_ret->home_half - $game_ret->guest_half, $model->condition, 2, $word);
                break;
            case "pcgs_h":
                $returnDatas = $this->zq_inball_bigsmall($game_ret->guest_half - $game_ret->home_half, $model->condition, 1, $word);
                break;
            case "pcch_h":
                $returnDatas = $this->zq_duyingv2(1, 1, $resultModel, $word);
                break;
            case "pccg_h":
                $returnDatas = $this->zq_duyingv2(2, 1, $resultModel, $word);
                break;
            case "pccd_h":
                $returnDatas['result'] = ($game_ret->home_half == $game_ret->guest_half) ? 1 : -1;
                break;
            case "pctss_h":
                $returnDatas = $this->zq_doublesing($game_ret->home_half + $game_ret->guest_half, $model->condition, $word);
                break;
            case "pctsd_h":
                $returnDatas = $this->zq_doublesing($game_ret->home_half + $game_ret->guest_half, $model->condition, $word);
                break;
            default:
                $returnDatas = ['result' => 2, 'matchResult' => '(玩法无规则异常)-' . $odds_code];
        }
        return $returnDatas;
    }

    public function penalty_card_all($model, $resultModels, $result_match_r)
    {
        $resultModel = $resultModels['0'];
        if ($resultModel->conner_ball == '') {
            $game_ret = json_decode(json_encode(['home' => 0, 'guest' => 0, 'home_half' => 0, 'guest_half' => 0]));
        } else {
            $game_ret = json_decode($resultModel->penalty_card);
        }
        $word = $game_ret->home . '-' . $game_ret->guest . "(全场)";
        $returnDatas = ['result' => -1, 'matchResult' => $word];

        $odds_code = $model->odds_code;
        switch ($odds_code) {
            case "pccoh":
                $returnDatas = $this->zq_letball($game_ret->home - $game_ret->guest, $model->condition, $word);
                break;
            case "pccog":
                $returnDatas = $this->zq_letball($game_ret->guest - $game_ret->home, $model->condition, $word);
                break;
            case "pcgb":
                $returnDatas = $this->zq_inball_bigsmall($game_ret->home - $game_ret->guest, $model->condition, 2, $word);
                break;
            case "pcgs":
                $returnDatas = $this->zq_inball_bigsmall($game_ret->guest - $game_ret->home, $model->condition, 1, $word);
                break;
            case "pcch":
                $returnDatas = $this->zq_duyingv2(1, 4, $resultModel, $word);
                break;
            case "pccg":
                $returnDatas = $this->zq_duyingv2(2, 4, $resultModel, $word);
                break;
            case "pccd":
                $returnDatas['result'] = ($game_ret->home == $game_ret->guest) ? 1 : -1;
                break;
            case "pctss":
                $returnDatas = $this->zq_doublesing($game_ret->home + $game_ret->guest, $model->condition, $word);
                break;
            case "pctsd":
                $returnDatas = $this->zq_doublesing($game_ret->home + $game_ret->guest, $model->condition, $word);
                break;
            default:
                $returnDatas = ['result' => 2, 'matchResult' => '(玩法无规则异常)-' . $odds_code];
        }
        return $returnDatas;
    }
    /**
     * 发球相关  结束
     */

    /*
     * 双重机会
     * User: Tank
     * Date: 2019/6/28
     * Time: 10:19
     */
    public function DO($bet_match = '', $result_match = [], $result_match_r = [])
    {
        if (empty($bet_match) || empty($result_match)) return false;


        $isgqwx = $this->GunqiuWeixian($bet_match, $result_match, $result_match_r);
        if ($isgqwx) {
            return $isgqwx;
        }

        $result_match = $result_match['0'];
        //获取父/子级赔率代码
        $p_code = $bet_match->p_code;
        $odds_code = $bet_match->odds_code;

        //获取主客队全场得分
        $full_home_score = $result_match->home_score;
        $full_guest_score = $result_match->guest_score;
        //双重机会
        //if ($p_code != 'sw_DC') return false;

        //返回结果
        $data = [
            'result' => 1,
            'matchResult' => "$full_home_score-$full_guest_score(全场)"
        ];
        switch ($odds_code) {
            case 'dohd':// 主队/和局
                if ($full_home_score > $full_guest_score || $full_home_score == $full_guest_score) return $data;
                break;
            case 'dogd':// 客队/和局
                if ($full_home_score < $full_guest_score || $full_home_score == $full_guest_score) return $data;
                break;
            case 'dohg':// 主队/客队
                if ($full_home_score > $full_guest_score || $full_home_score < $full_guest_score) return $data;
                break;
            default:
                return false;
        }

        $data['result'] = -1;
        return $data;
    }

    /*
     * 三项让球投注
     * User: Tank
     * Date: 2019/6/28
     * Time: 10:19
     */
    public function TLB($bet_match = '', $result_match = '', $result_match_r = [])
    {
        if (empty($bet_match) || empty($result_match)) return false;

        $isgqwx = $this->GunqiuWeixian($bet_match, $result_match, $result_match_r);
        if ($isgqwx) {
            return $isgqwx;
        }

        $result_match = $result_match['0'];
        //获取父/子级赔率代码
        $p_code = $bet_match->p_code;
        $odds_code = $bet_match->odds_code;

        //获取主客队全场比分
        $full_home_score = $result_match->home_score;
        $full_guest_score = $result_match->guest_score;
        //三项让球投注
        //if ($p_code != 'sw_W3') return false;

        //返回结果
        $data = [
            'result' => 1,
            'matchResult' => "$full_home_score-$full_guest_score(全场)"
        ];

        switch ($odds_code) {
            case 'tlbcoh':// 让球|主队 +1
                //如果 主队-客队 比分 > 1,则 赢
                if (($full_home_score - $full_guest_score) > 1) return $data;
                $data['result'] = 2;
                //如果 主队-客队 比分 = 1,则 平
                if (($full_home_score - $full_guest_score) == 1) return $data;
                break;
            case 'tlbcog':// 让球|客队 -1
                $data['result'] = 2;
                //如果 主队-客队 比分 = 1,则 平
                if (($full_home_score - $full_guest_score) == 1) return $data;
                break;
            case 'tlbcod':// 让球|和局 +1
                //如果 主队-客队 比分 = 1,则 赢
                if (($full_home_score - $full_guest_score) == 1) return $data;
                break;
            default:
                return false;
        }

        $data['result'] = -1;
        return $data;
    }

    /*
    * 零失球
    * User: Tank
    * Date: 2019/6/28
    * Time: 10:19
    */
    public function NLB($bet_match = '', $result_match = '', $result_match_r = [])
    {
        if (empty($bet_match) || empty($result_match)) return false;

        $isgqwx = $this->GunqiuWeixian($bet_match, $result_match, $result_match_r);
        if ($isgqwx) {
            return $isgqwx;
        }


        $result_match = $result_match['0'];
        //获取父/子级赔率代码
        $p_code = $bet_match->p_code;
        $odds_code = $bet_match->odds_code;

        //获取主客队全场比分
        $full_home_score = $result_match->home_score;
        $full_guest_score = $result_match->guest_score;
        //零失球
        //if ($p_code != 'sw_CS') return false;

        //返回结果
        $data = [
            'result' => 1,
            'matchResult' => "$full_home_score-$full_guest_score(全场)"
        ];
        switch ($odds_code) {
            case 'nlbh':// 零失球|主队
                //客队 比分 为 0
                if ($full_guest_score == 0) return $data;
                break;
            case 'nlbg':// 零失球|客队
                //主队 比分 为 0
                if ($full_home_score == 0) return $data;
                break;
            default:
                return false;
        }

        $data['result'] = -1;
        return $data;
    }

    /*
    * 零失球获胜
    * User: Tank
    * Date: 2019/6/28
    * Time: 10:19
    */
    public function NLW($bet_match = '', $result_match = '', $result_match_r = [])
    {
        if (empty($bet_match) || empty($result_match)) return false;

        $isgqwx = $this->GunqiuWeixian($bet_match, $result_match, $result_match_r);
        if ($isgqwx) {
            return $isgqwx;
        }


        $result_match = $result_match['0'];
        //获取父/子级赔率代码
        $p_code = $bet_match->p_code;
        $odds_code = $bet_match->odds_code;

        //获取主客队全场比分
        $full_home_score = $result_match->home_score;
        $full_guest_score = $result_match->guest_score;
        //零失球
        //if ($p_code != 'sw_WN') return false;

        //返回结果
        $data = [
            'result' => 1,
            'matchResult' => "$full_home_score-$full_guest_score(全场)"
        ];
        switch ($odds_code) {
            case 'nlwh':// 零失球获胜|主队
                //客队 比分 为 0 并且 主队 大于 客队
                if ($full_home_score > $full_guest_score and $full_guest_score == 0) return $data;
                break;
            case 'nlwg':// 零失球获胜|客队
                //主队 比分 为 0 并且 客队 大于 主队
                if ($full_home_score < $full_guest_score || $full_home_score == 0) return $data;
                break;
            default:
                return false;
        }

        $data['result'] = -1;
        return $data;
    }

    /*
    * 赢得所有半场
    * User: Tank
    * Date: 2019/6/28
    * Time: 10:19
    */
    public function WAH($bet_match = '', $result_match = '', $result_match_r = [])
    {
        if (empty($bet_match) || empty($result_match)) return false;

        $isgqwx = $this->GunqiuWeixian($bet_match, $result_match, $result_match_r);
        if ($isgqwx) {
            return $isgqwx;
        }


        $result_match = $result_match['0'];
        //获取父/子级赔率代码
        $p_code = $bet_match->p_code;
        $odds_code = $bet_match->odds_code;

        //获取主客队全场比分
        $full_home_score = $result_match->home_score;
        $full_guest_score = $result_match->guest_score;

        //获取主客队上半场得分
        $half_home_score = $result_match->u_home_score;
        $half_guest_score = $result_match->u_guest_score;
        //赢得所有半场
        //if ($p_code != 'sw_WB') return false;

        //返回结果
        $data = [
            'result' => 1,
            'matchResult' => "$full_home_score-$full_guest_score(全场)"
        ];

        switch ($odds_code) {
            case 'wahh':// 赢得所有半场|主队
                //上半场/下半场 都满足 主队 > 客队
                if (($full_home_score - $half_home_score) > ($full_guest_score - $half_guest_score) and $half_home_score > $half_guest_score) return $data;
                break;
            case 'wahg':// 赢得所有半场|客队
                //上半场/下半场 都满足 主队 < 客队
                if (($full_home_score - $half_home_score) < ($full_guest_score - $half_guest_score) and $half_home_score < $half_guest_score) return $data;
                break;
            default:
                return false;
        }

        $data['result'] = -1;
        return $data;
    }

    /*
    * 赢得任一半场
    * User: Tank
    * Date: 2019/6/28
    * Time: 10:19
    */
    public function WEH($bet_match = '', $result_match = '', $result_match_r = [])
    {
        if (empty($bet_match) || empty($result_match)) return false;

        $isgqwx = $this->GunqiuWeixian($bet_match, $result_match, $result_match_r);
        if ($isgqwx) {
            return $isgqwx;
        }

        $result_match = $result_match['0'];
        //获取父/子级赔率代码
        $p_code = $bet_match->p_code;
        $odds_code = $bet_match->odds_code;

        //获取主客队全场比分
        $full_home_score = $result_match->home_score;
        $full_guest_score = $result_match->guest_score;

        //获取主客队上半场得分
        $half_home_score = $result_match->u_home_score;
        $half_guest_score = $result_match->u_guest_score;
        //赢得任一半场
        //if ($p_code != 'WEH') return false;

        //返回结果
        $data = [
            'result' => 1,
            'matchResult' => "$full_home_score-$full_guest_score(全场)"
        ];

        switch ($odds_code) {
            case 'wehh':// 赢得任一半场|主队
                //上半场/下半场 任一满足 主队 > 客队
                if (($full_home_score - $half_home_score) > ($full_guest_score - $half_guest_score) || $half_home_score > $half_guest_score) return $data;
                break;
            case 'wehg':// 赢得任一半场|客队
                //上半场/下半场 任一满足 主队 < 客队
                if (($full_home_score - $half_home_score) < ($full_guest_score - $half_guest_score) || $half_home_score < $half_guest_score) return $data;
                break;
            default:
                return false;
        }

        $data['result'] = -1;
        return $data;
    }

    /*
    * 双半场进球
    * User: Tank
    * Date: 2019/6/28
    * Time: 10:19
    */
    public function DHG($bet_match = '', $result_match = '', $result_match_r = [])
    {
        if (empty($bet_match) || empty($result_match)) return false;

        $isgqwx = $this->GunqiuWeixian($bet_match, $result_match, $result_match_r);
        if ($isgqwx) {
            return $isgqwx;
        }

        $result_match = $result_match['0'];
        //获取父/子级赔率代码
        $p_code = $bet_match->p_code;
        $odds_code = $bet_match->odds_code;

        //获取主客队全场比分
        $full_home_score = $result_match->home_score;
        $full_guest_score = $result_match->guest_score;

        //获取主客队上半场得分
        $half_home_score = $result_match->u_home_score;
        $half_guest_score = $result_match->u_guest_score;
        //双半场进球
        //if ($p_code != 'DHG') return false;

        //返回结果
        $data = [
            'result' => 1,
            'matchResult' => "$full_home_score-$full_guest_score(全场)"
        ];

        switch ($odds_code) {
            case 'dhgh':// 双半场进球|主队
                //上半场/下半场 主队都有 进球
                if (($full_home_score - $half_home_score) > 0 and $half_home_score > 0) return $data;
                break;
            case 'ghgg':// 双半场进球|客队
                //上半场/下半场 客队都有 进球
                if (($full_guest_score - $half_guest_score) > 0 and $half_guest_score > 0) return $data;
                break;
            default:
                return false;
        }

        $data['result'] = -1;
        return $data;
    }

    /*
    * 最多进球半场
    * User: Tank
    * Date: 2019/6/28
    * Time: 10:19
    */
    public function MHG($bet_match = '', $result_match = '', $result_match_r = [])
    {
        if (empty($bet_match) || empty($result_match)) return false;

        $isgqwx = $this->GunqiuWeixian($bet_match, $result_match, $result_match_r);
        if ($isgqwx) {
            return $isgqwx;
        }

        $result_match = $result_match['0'];
        //获取父/子级赔率代码
        $p_code = $bet_match->p_code;
        $odds_code = $bet_match->odds_code;

        //获取主客队全场比分
        $full_home_score = $result_match->home_score;
        $full_guest_score = $result_match->guest_score;

        //获取主客队上半场得分
        $half_home_score = $result_match->u_home_score;
        $half_guest_score = $result_match->u_guest_score;

        //获取下半场得分
        $lower_home_score = $full_home_score - $half_home_score;
        $lower_guest_score = $half_guest_score - $half_guest_score;
        //最多进球半场
        //if ($p_code != 'MHG') return false;

        //返回结果
        $data = [
            'result' => 1,
            'matchResult' => "$full_home_score-$full_guest_score(全场)"
        ];

        switch ($odds_code) {
            case 'mhgf':// 最多进球半场|上半场
                //主队+客队上半场 > 主队+客队下半场
                if (($half_home_score + $half_guest_score) > ($lower_home_score + $lower_guest_score)) return $data;
                break;
            case 'mhgs':// 最多进球半场|下半场
                //主队+客队上半场 < 主队+客队下半场
                if (($half_home_score + $half_guest_score) < ($lower_home_score + $lower_guest_score)) return $data;
                break;
            default:
                return false;
        }

        $data['result'] = -1;
        return $data;
    }

    /*
    * 最多进球半场-独赢
    * User: Tank
    * Date: 2019/6/28
    * Time: 10:19
    */
    public function MHGC($bet_match = '', $result_match = '', $result_match_r = [])
    {
        if (empty($bet_match) || empty($result_match)) return false;

        $isgqwx = $this->GunqiuWeixian($bet_match, $result_match, $result_match_r);
        if ($isgqwx) {
            return $isgqwx;
        }

        $result_match = $result_match['0'];
        //获取父/子级赔率代码
        $p_code = $bet_match->p_code;
        $odds_code = $bet_match->odds_code;

        //获取主客队全场比分
        $full_home_score = $result_match->home_score;
        $full_guest_score = $result_match->guest_score;

        //获取主客队上半场得分
        $half_home_score = $result_match->u_home_score;
        $half_guest_score = $result_match->u_guest_score;

        //获取下半场得分
        $lower_home_score = $full_home_score - $half_home_score;
        $lower_guest_score = $half_guest_score - $half_guest_score;
        //最多进球半场-独赢
        //if ($p_code != 'MHGC') return false;

        //返回结果
        $data = [
            'result' => 1,
            'matchResult' => "$full_home_score-$full_guest_score(全场)"
        ];

        switch ($odds_code) {
            case 'mhgcf':// 最多进球半场-独赢|上半场
                //主队+客队上半场 > 主队+客队下半场  and 主队 独赢
                if (($half_home_score + $half_guest_score) > ($lower_home_score + $lower_guest_score) and $full_home_score > $full_guest_score) return $data;
                break;
            case 'mfgcs':// 最多进球半场-独赢|下半场
                //主队+客队上半场 < 主队+客队下半场  and 主队 独赢
                if (($half_home_score + $half_guest_score) < ($lower_home_score + $lower_guest_score) and $full_home_score > $full_guest_score) return $data;
                break;
            case 'mhgcd':// 最多进球半场-独赢|和局
                //全场主队 == 全场客队
                if ($full_home_score == $full_guest_score) return $data;
                break;
            default:
                return false;
        }

        $data['result'] = -1;
        return $data;
    }

    /*
    * 首个进球时间
    * User: Tank
    * Date: 2019/6/28
    * Time: 10:19
    */
    public function FGT($bet_match = '', $result_match = '', $result_match_r = [])
    {
        if (empty($bet_match) || empty($result_match)) return false;

        $isgqwx = $this->GunqiuWeixian($bet_match, $result_match, $result_match_r);
        if ($isgqwx) {
            return $isgqwx;
        }

        $result_match = $result_match['0'];
        //获取父/子级赔率代码
        $p_code = $bet_match->p_code;
        $odds_code = $bet_match->odds_code;

        //获取 首进球 时间
        $first_score = json_decode($result_match->first_score, true);
        $first_time_int = $first_score['scoretime'];//$result_match;//{"teamscore":0,"scoretime":0,"scoretype":0}
        // $first_time_int = 0;
        // if($first_time_str) {
        //     $first_time_int = (int)substr($first_time_str,0,strpos($first_time_str, ':'));
        // }

        //首个进球时间
        //if ($p_code != 'FGT') return false;

        //返回结果
        $data = [
            'result' => 1,
            'matchResult' => "$first_time_int(首进球时间)"
        ];

        switch ($odds_code) {
            case 'fgt15'://上半场开场-14:59分钟
                if ($first_time_int < 15) return $data;
                break;
            case 'fgt30'://15:00分钟-29:59分钟
                if (15 <= $first_time_int and $first_time_int < 30) return $data;
                break;
            case 'fgt45'://30:00分钟-半场
                if (30 <= $first_time_int and $first_time_int < 45) return $data;
                break;
            case 'fgt60'://下半场开场-59:59分钟
                if (45 <= $first_time_int and $first_time_int < 60) return $data;
                break;
            case 'fgt75'://60:00分钟-74:59分钟
                if (60 <= $first_time_int and $first_time_int < 75) return $data;
                break;
            case 'fgt90'://75:00分钟-全场完场
                if (75 <= $first_time_int and $first_time_int < 90) return $data;
                break;
            case 'fgtno'://无进球
                $data['matchResult'] = '没有进球';
                if ($first_time_int == 0) return $data;
                break;
            default:
                return false;
        }

        $data['result'] = -1;
        return $data;
    }

    /*
     * 首个进球时间-3项
     * User: Tank
     * Date: 2019/6/28
     * Time: 10:19
     */
    public function FGTT($bet_match = '', $result_match = '', $result_match_r = [])
    {
        if (empty($bet_match) || empty($result_match)) return false;

        $isgqwx = $this->GunqiuWeixian($bet_match, $result_match, $result_match_r);
        if ($isgqwx) {
            return $isgqwx;
        }

        $result_match = $result_match['0'];
        //获取父/子级赔率代码
        $p_code = $bet_match->p_code;
        $odds_code = $bet_match->odds_code;

        //获取 首进球 时间
        $first_score = json_decode($result_match->first_score, true);
        $first_time_int = $first_score['scoretime'];//$result_match;//{"teamscore":0,"scoretime":0,"scoretype":0}
        // $first_time_int = 0;
        // if($first_time_str) {
        //     $first_time_int = (int)substr($first_time_str,0,strpos($first_time_str, ':'));
        // }


        //首个进球时间-3项
        //if ($p_code != 'FGTT') return false;

        //返回结果
        $data = [
            'result' => 1,
            'matchResult' => "$first_time_int(首进球时间)"
        ];

        switch ($odds_code) {
            case 'fgtt26'://第26分钟或之前
                if ($first_time_int <= 26) return $data;
                break;
            case 'fgtt27'://第27分钟或之后
                if (27 <= $first_time_int) return $data;
                break;
            case 'fgttno'://无进球
                $data['matchResult'] = '没有进球';
                if ($first_time_int == 0) return $data;
                break;
            default:
                return false;
        }

        $data['result'] = -1;
        return $data;
    }

    /**
     * 双方球队进球
     * @param mixed $model 注单表数据
     * @param mixed $resultModels 结果表数据
     * @param mixed $resultRecords 结果记录表数据
     * model--money_buy_match resultModels--st_zq_result resultRecords--st_zq_result_record
     * @return string jimy start
     */
    public function BG($model, $resultModels, $resultRecords)
    {

        $isgqwx = $this->GunqiuWeixian($model, $resultModels, $resultRecords);
        if ($isgqwx) {
            return $isgqwx;
        }

        $resultModel = $resultModels['0'];
        $allword = $resultModel->home_score . '-' . $resultModel->guest_score . "(全场)";
        $hlefword = $resultModel->u_home_score . '-' . $resultModel->u_guest_score . "(上半场)";

        $odds_code = $model->odds_code;
        switch ($odds_code) {
            case "bgy":
                $returnDatas = $this->isgoal($resultModel, $model, bgy, $allword);
                break;
            case "bgn":
                $returnDatas = $this->isgoal($resultModel, $model, bgn, $allword);
                break;
            case "bgy_h":
                $returnDatas = $this->isgoal($resultModel, $model, bgy_h, $hlefword);
                break;
            case "bgn_h":
                $returnDatas = $this->isgoal($resultModel, $model, bgn_h, $hlefword);
                break;
            default:
                $returnDatas = ['result' => 2, 'matchResult' => '(玩法无规则异常)-' . $odds_code];
        }
        return $returnDatas;
    }

    /**
     * 独赢&进球大小
     * @param mixed $model 注单表数据
     * @param mixed $resultModels 结果表数据
     * @param mixed $resultRecords 结果记录表数据
     * model--money_buy_match resultModels--st_zq_result resultRecords--st_zq_result_record
     * @return string
     * 注:大1.5|和局 主队-客队大于1.5 并且为和局  小1.5|和局 主队-客队小于1.5 并且为和局
     */
    public function CGS($model, $resultModels, $resultRecords)
    {
        $isgqwx = $this->GunqiuWeixian($model, $resultModels, $resultRecords);
        if ($isgqwx) {
            return $isgqwx;
        }

        $resultModel = $resultModels['0'];
        $allword = $resultModel->home_score . '-' . $resultModel->guest_score . "(主队全场-客队全场)";

        $odds_code = $model->odds_code;
        switch ($odds_code) {
            case "cgsh1b": //大1.5|主队
                $returnDatas = $this->isonlysize($resultModel, $model, cgsh1b, $allword);
                break;
            case "cgsh1s": //小1.5|主队
                $returnDatas = $this->isonlysize($resultModel, $model, cgsh1s, $allword);
                break;
            case "cgsg1b": //大1.5|客队
                $returnDatas = $this->isonlysize($resultModel, $model, cgsg1b, $allword);
                break;
            case "cgsg1s": //小1.5|客队
                $returnDatas = $this->isonlysize($resultModel, $model, cgsg1s, $allword);
                break;
            case "cgsd1b": //大1.5|和局
                $returnDatas = $this->isonlysize($resultModel, $model, cgsd1b, $allword);
                break;
            case "cgsd1s": //小1.5|和局
                $returnDatas = $this->isonlysize($resultModel, $model, cgsd1s, $allword);
                break;
            case "cgsh2b": //大2.5|主队
                $returnDatas = $this->isonlysize($resultModel, $model, cgsh2b, $allword);
                break;
            case "cgsh2s": //小2.5|主队
                $returnDatas = $this->isonlysize($resultModel, $model, cgsh2s, $allword);
                break;
            case "cgsg2b": //大2.5|客队
                $returnDatas = $this->isonlysize($resultModel, $model, cgsg2b, $allword);
                break;
            case "cgsg2s": //小2.5|主队
                $returnDatas = $this->isonlysize($resultModel, $model, cgsg2s, $allword);
                break;
            case "cgsd2b": //大2.5|和局
                $returnDatas = $this->isonlysize($resultModel, $model, cgsd2b, $allword);
                break;
            case "cgsd3s": //小2.5|和局
                $returnDatas = $this->isonlysize($resultModel, $model, cgsd3s, $allword);
                break;
            case "cgsh3b": //大3.5|主队
                $returnDatas = $this->isonlysize($resultModel, $model, cgsh3b, $allword);
                break;
            case "cgsh3s": //小3.5|主队
                $returnDatas = $this->isonlysize($resultModel, $model, cgsh3s, $allword);
                break;
            case "cgsg3b": //大3.5|客队
                $returnDatas = $this->isonlysize($resultModel, $model, cgsg3b, $allword);
                break;
            case "cgsg3s": //小3.5|客队
                $returnDatas = $this->isonlysize($resultModel, $model, cgsg3s, $allword);
                break;
            case "cgsd3b": //大3.5|和局
                $returnDatas = $this->isonlysize($resultModel, $model, cgsd3b, $allword);
                break;
            case "cgsd3s": //小3.5|和局
                $returnDatas = $this->isonlysize($resultModel, $model, cgsd3s, $allword);
                break;
            case "cgsh4b": //大4.5|主队
                $returnDatas = $this->isonlysize($resultModel, $model, cgsh4b, $allword);
                break;
            case "cgsh4s": //小4.5|主队
                $returnDatas = $this->isonlysize($resultModel, $model, cgsh4s, $allword);
                break;
            case "cgsg4b": //大4.5|客队
                $returnDatas = $this->isonlysize($resultModel, $model, cgsg4b, $allword);
                break;
            case "cgsg4s": //小4.5|主队
                $returnDatas = $this->isonlysize($resultModel, $model, cgsg4s, $allword);
                break;
            case "cgsd4b": //大4.5|和局
                $returnDatas = $this->isonlysize($resultModel, $model, cgsd4b, $allword);
                break;
            case "cgsd4s": //小4.5|和局
                $returnDatas = $this->isonlysize($resultModel, $model, cgsd4s, $allword);
                break;
            default:
                $returnDatas = ['result' => 2, 'matchResult' => '(玩法无规则异常)-' . $odds_code];
        }
        return $returnDatas;
    }

    /**
     * 独赢&双方球队进球
     * @param mixed $model 注单表数据
     * @param mixed $resultModels 结果表数据
     * @param mixed $resultRecords 结果记录表数据
     * model--money_buy_match resultModels--st_zq_result resultRecords--st_zq_result_record
     * @return string
     */
    public function CBG($model, $resultModels, $resultRecords)
    {

        $isgqwx = $this->GunqiuWeixian($model, $resultModels, $resultRecords);
        if ($isgqwx) {
            return $isgqwx;
        }

        $resultModel = $resultModels['0'];
        $homeword = $resultModel->home_score . "(主队全场)";
        $guestword = $resultModel->guest_score . "(客队全场)";
        $allword = $resultModel->home_score . '-' . $resultModel->guest_score . "(全场)";

        $odds_code = $model->odds_code;
        switch ($odds_code) {
            case "cbghy": //独赢&双方球队进球|主队|是
                $returnDatas = $this->ishvgoal($resultModel, $model, cbghy, $homeword);
                break;
            case "cbghn": //独赢&双方球队进球|主队|否
                $returnDatas = $this->ishvgoal($resultModel, $model, cbghn, $homeword);
                break;
            case "cbggy": //独赢&双方球队进球|客队|是
                $returnDatas = $this->ishvgoal($resultModel, $model, cbggy, $guestword);
                break;
            case "cbggn": //独赢&双方球队进球|客队|否
                $returnDatas = $this->ishvgoal($resultModel, $model, cbggn, $guestword);
                break;
            case "cbgdy": //独赢&双方球队进球|和局|是
                $returnDatas = $this->ishvgoal($resultModel, $model, cbgdy, $allword);
                break;
            case "cbgdn": //独赢&双方球队进球|和局|否
                $returnDatas = $this->ishvgoal($resultModel, $model, cbgdn, $allword);
                break;
            default:
                $returnDatas = ['result' => 2, 'matchResult' => '(玩法无规则异常)-' . $odds_code];
        }
        return $returnDatas;


    }

    /**
     * 进球大/小&双方球队进球
     * @param mixed $model 注单表数据
     * @param mixed $resultModels 结果表数据
     * @param mixed $resultRecords 结果记录表数据
     * model--money_buy_match resultModels--st_zq_result resultRecords--st_zq_result_record
     * @return string
     */
    public function TBBG($model, $resultModels, $resultRecords)
    {
        $isgqwx = $this->GunqiuWeixian($model, $resultModels, $resultRecords);
        if ($isgqwx) {
            return $isgqwx;
        }


        $resultModel = $resultModels['0'];
        $homeword = $resultModel->home_score . "(主队全场)";
        $guestword = $resultModel->guest_score . "(客队全场)";
        $allword = $resultModel->home_score . '-' . $resultModel->guest_score . "(全场)";

        $odds_code = $model->odds_code;
        switch ($odds_code) {
            case "tbbgb1y": //大1.5|主队|是
                $returnDatas = $this->goalsize($resultModel, $model, tbbgb1y, $homeword);
                break;
            case "tbbgs1y": //小1.5|主队|不是
                $returnDatas = $this->goalsize($resultModel, $model, tbbgs1y, $homeword);
                break;
            case "tbbgb1n": //大1.5|客队|是
                $returnDatas = $this->goalsize($resultModel, $model, tbbgb1n, $guestword);
                break;
            case "tbbgs1n": //小1.5|客队|不是
                $returnDatas = $this->goalsize($resultModel, $model, tbbgs1n, $guestword);
                break;
            case "tbbgb2y": //大2.5|主队|是
                $returnDatas = $this->goalsize($resultModel, $model, tbbgb2y, $allword);
                break;
            case "tbbgs2y": //小2.5|主队|不是
                $returnDatas = $this->goalsize($resultModel, $model, tbbgs2y, $allword);
                break;
            case "tbbgb2n": //大2.5|客队|是
                $returnDatas = $this->goalsize($resultModel, $model, tbbgb2n, $homeword);
                break;
            case "tbbgs2n": //小2.5|客队|不是
                $returnDatas = $this->goalsize($resultModel, $model, tbbgs2n, $homeword);
                break;
            case "tbbgb3y": //大3.5|主队|是
                $returnDatas = $this->goalsize($resultModel, $model, tbbgb3y, $guestword);
                break;
            case "tbbgs3y": //小3.5|主队|不是
                $returnDatas = $this->goalsize($resultModel, $model, tbbgs3y, $guestword);
                break;
            case "tbbgb3n": //大3.5|客队|是
                $returnDatas = $this->goalsize($resultModel, $model, tbbgb3n, $allword);
                break;
            case "tbbgs3n": //小3.5|客队|不是
                $returnDatas = $this->goalsize($resultModel, $model, tbbgs3n, $allword);
                break;
            case "tbbgb4y": //大4.5|主队|是
                $returnDatas = $this->goalsize($resultModel, $model, tbbgb4y, $homeword);
                break;
            case "tbbgs4y": //小4.5|主队|不是
                $returnDatas = $this->goalsize($resultModel, $model, tbbgs4y, $homeword);
                break;
            case "tbbgb4n": //大4.5|客队|是
                $returnDatas = $this->goalsize($resultModel, $model, tbbgb4n, $guestword);
                break;
            case "tbbgs4n": //小4.5|客队|不是
                $returnDatas = $this->goalsize($resultModel, $model, tbbgs4n, $guestword);
                break;
            default:
                $returnDatas = ['result' => 2, 'matchResult' => '(玩法无规则异常)-' . $odds_code];
        }
    }

    /**
     * 独赢 & 最先进球
     * @param mixed $model 注单表数据
     * @param mixed $resultModels 结果表数据
     * @param mixed $resultRecords 结果记录表数据
     * model--money_buy_match resultModels--st_zq_result resultRecords--st_zq_result_record
     * @return string  ？？？
     */
    public function CFB($model, $resultModels, $resultRecords)
    {
        $isgqwx = $this->GunqiuWeixian($model, $resultModels, $resultRecords);
        if ($isgqwx) {
            return $isgqwx;
        }

        $resultModel = $resultModels['0'];
        $allword = array(
            'score' => $resultModel->home_score . '-' . $resultModel->guest_score . "(全场)",
            'one_score' => $resultModel->first_score,//首进球
        );

        $odds_code = $model->odds_code;
        switch ($odds_code) {
            case "cfbchh":  ///主队最先进球|主队
                $returnDatas = $this->firstball($resultModel, $model, cfbchh, $allword);
                break;
            case "cfbchg": //客队最先进球|主队
                $returnDatas = $this->firstball($resultModel, $model, cfbchg, $allword);
                break;
            case "cfbcgh": //主队最先进球|客队
                $returnDatas = $this->firstball($resultModel, $model, cfbcgh, $allword);
                break;
            case "cfbcgg": //客队最先进球|客队
                $returnDatas = $this->firstball($resultModel, $model, cfbcgg, $allword);
                break;
            case "cfbcdh": //主队最先进球|和局
                $returnDatas = $this->firstball($resultModel, $model, cfbcdh, $allword);
                break;
            case "cfbcdg": //客队最先进球|和局
                $returnDatas = $this->firstball($resultModel, $model, cfbcdg, $allword);
                break;
            // case "ior_F2GH":
            //     $returnDatas = $this->firstball($resultModel, $model, ior_F2GH, $allword);
            //     break;
            // case "ior_F3GH":
            //     $returnDatas = $this->firstball($resultModel, $model, ior_F3GH, $allword);
            //     break;
            // case "ior_F3GC":
            //     $returnDatas = $this->firstball($resultModel, $model, ior_F3GC, $allword);
            //     break;
            default:
                $returnDatas = ['result' => 2, 'matchResult' => '(玩法无规则异常)-' . $odds_code];
        }
    }

    /**
     * 首个进球方式
     * @param mixed $model 注单表数据
     * @param mixed $resultModels 结果表数据
     * @param mixed $resultRecords 结果记录表数据
     * model--money_buy_match resultModels--st_zq_result resultRecords--st_zq_result_record
     * @return string
     */
    public function FGW($model, $resultModels, $resultRecords)
    {
        $isgqwx = $this->GunqiuWeixian($model, $resultModels, $resultRecords);
        if ($isgqwx) {
            return $isgqwx;
        }

        $resultModels = $resultModels['0'];
        $word = json_decode($resultModels->first_score, true)['scoretype'] . "(首个进球方式)";

        $odds_code = $model->odds_code;
        switch ($odds_code) {
            case "fgws": //射门
                $returnDatas = $this->onewaygoal($resultModels, $model, fgws, $word);
                break;
            case "fgwh": //头球
                $returnDatas = $this->onewaygoal($resultModels, $model, fgwh, $word);
                break;
            case "fgwn": //无进球
                $returnDatas = $this->onewaygoal($resultModels, $model, fgwn, $word);
                break;
            case "fgwp": //点球
                $returnDatas = $this->onewaygoal($resultModels, $model, fgwp, $word);
                break;
            case "fgwa": //任意球
                $returnDatas = $this->onewaygoal($resultModels, $model, fgwa, $word);
                break;
            case "fgwo": //乌龙球
                $returnDatas = $this->onewaygoal($resultModels, $model, fgwo, $word);
                break;
            default:
                $returnDatas = ['result' => 2, 'matchResult' => '(玩法无规则异常)-' . $odds_code];
        }
    }

    /**
     * 双重机会&进球大/小
     * @param mixed $model 注单表数据
     * @param mixed $resultModels 结果表数据
     * @param mixed $resultRecords 结果记录表数据
     * model--money_buy_match resultModels--st_zq_result resultRecords--st_zq_result_record
     * @return string
     */
    public function DOGS($model, $resultModels, $resultRecords)
    {

        $isgqwx = $this->GunqiuWeixian($model, $resultModels, $resultRecords);
        if ($isgqwx) {
            return $isgqwx;
        }

        $resultModels = $resultModels['0'];
        $homeword = $resultModels->home_score . "(主队全场)";
        $guestword = $resultModels->guest_score . "(客队全场)";
        $allword = $resultModels->home_score . '-' . $resultModels->guest_score . "(全场)";

        $odds_code = $model->odds_code;
        switch ($odds_code) {
            case "dogsb1_cohd": //大1.5|主队|和局
                $returnDatas = $this->twosize($resultModels, $model, dogsb1_cohd, $homeword);
                break;
            case "dogss1_cohd": //小1.5|主队|和局
                $returnDatas = $this->twosize($resultModels, $model, dogss1_cohd, $homeword);
                break;
            case "dogsb1_cogd": //大1.5|客队|和局
                $returnDatas = $this->twosize($resultModels, $model, dogsb1_cogd, $guestword);
                break;
            case "dogss1_cogd": //小1.5|客队|和局
                $returnDatas = $this->twosize($resultModels, $model, dogss1_cogd, $guestword);
                break;
            case "dogsb1_cohg": //大1.5|主队|客队
                $returnDatas = $this->twosize($resultModels, $model, dogsb1_cohg, $allword);
                break;
            case "dogss1_cohg": //小1.5|主队|客队
                $returnDatas = $this->twosize($resultModels, $model, dogss1_cohg, $allword);
                break;
            case "dogsb2_cohd": //大2.5|主队|和局
                $returnDatas = $this->twosize($resultModels, $model, dogsb2_cohd, $homeword);
                break;
            case "dogss2_cohd": //小2.5|主队|和局
                $returnDatas = $this->twosize($resultModels, $model, dogss2_cohd, $homeword);
                break;
            case "dogsb2_cogd": //大2.5|客队|和局
                $returnDatas = $this->twosize($resultModels, $model, dogsb2_cogd, $guestword);
                break;
            case "dogss2_cogd": //小2.5|客队|和局
                $returnDatas = $this->twosize($resultModels, $model, dogss2_cogd, $guestword);
                break;
            case "dogsb2_cohg": //大2.5|主队|客队
                $returnDatas = $this->twosize($resultModels, $model, dogsb2_cohg, $allword);
                break;
            case "dogss2_cohg": //小2.5|主队|客队
                $returnDatas = $this->twosize($resultModels, $model, dogss2_cohg, $allword);
                break;
            case "dogsb3_cohd": //大3.5|主队|和局
                $returnDatas = $this->twosize($resultModels, $model, dogsb3_cohd, $homeword);
                break;
            case "dogss3_cohd": //小3.5|主队|和局
                $returnDatas = $this->twosize($resultModels, $model, dogss3_cohd, $homeword);
                break;
            case "dogsb3_cogd": //大3.5|客队|和局
                $returnDatas = $this->twosize($resultModels, $model, dogsb3_cogd, $guestword);
                break;
            case "dogss3_cogd": //小3.5|客队|和局
                $returnDatas = $this->twosize($resultModels, $model, dogss3_cogd, $guestword);
                break;
            case "dogsb3_cohg": //大3.5|主队|客队
                $returnDatas = $this->twosize($resultModels, $model, dogsb3_cohg, $allword);
                break;
            case "dogss3_cohg": //小3.5|主队|客队
                $returnDatas = $this->twosize($resultModels, $model, dogss3_cohg, $allword);
                break;
            case "dogsb4_cohd": //大4.5|主队|和局
                $returnDatas = $this->twosize($resultModels, $model, dogsb4_cohd, $homeword);
                break;
            case "dogss4_cohd": //小4.5|主队|和局
                $returnDatas = $this->twosize($resultModels, $model, dogss4_cohd, $homeword);
                break;
            case "dogsb4_cogd": //大4.5|客队|和局
                $returnDatas = $this->twosize($resultModels, $model, dogsb4_cogd, $guestword);
                break;
            case "dogss4_cogd": //小4.5|客队|和局
                $returnDatas = $this->twosize($resultModels, $model, dogss4_cogd, $guestword);
                break;
            case "dogsb4_cohg": //大4.5|主队|客队
                $returnDatas = $this->twosize($resultModels, $model, dogsb4_cohg, $allword);
                break;
            case "dogss4_cohg": //小4.5|主队|客队
                $returnDatas = $this->twosize($resultModels, $model, dogss4_cohg, $allword);
                break;
            default:
                $returnDatas = ['result' => 2, 'matchResult' => '(玩法无规则异常)-' . $odds_code];
        }
    }

    /**
     * 双重机会&双方球队进球
     * @param mixed $model 注单表数据
     * @param mixed $resultModels 结果表数据
     * @param mixed $resultRecords 结果记录表数据
     * model--money_buy_match resultModels--st_zq_result resultRecords--st_zq_result_record
     * @return string
     */
    public function DOBG($model, $resultModels, $resultRecords)
    {

        $isgqwx = $this->GunqiuWeixian($model, $resultModels, $resultRecords);
        if ($isgqwx) {
            return $isgqwx;
        }

        $resultModels = $resultModels['0'];
        $homeword = $resultModels->home_score . "(主队全场)";
        $guestword = $resultModels->guest_score . "(客队全场)";
        $allword = $resultModels->home_score . '-' . $resultModels->guest_score . "(全场)";

        $odds_code = $model->odds_code;
        switch ($odds_code) {
            case "dobgy_cohd": //主队/和局|是
                $returnDatas = $this->allgoals($resultModels, $model, dobgy_cohd, $allword);
                break;
            case "dobgn_cohd": //主队/和局|不是
                $returnDatas = $this->allgoals($resultModels, $model, dobgn_cohd, $allword);
                break;
            case "dobgy_cogd": //客队/和局|是
                $returnDatas = $this->allgoals($resultModels, $model, dobgy_cogd, $allword);
                break;
            case "dobgn_cogd": //客队/和局|不是
                $returnDatas = $this->allgoals($resultModels, $model, dobgn_cogd, $allword);
                break;
            case "dobgy_cohg": //主队/客队|是
                $returnDatas = $this->allgoals($resultModels, $model, dobgy_cohg, $allword);
                break;
            case "dobgn_cohg": //主队/客队|不是
                $returnDatas = $this->allgoals($resultModels, $model, dobgn_cohg, $allword);
                break;
            default:
                $returnDatas = ['result' => 2, 'matchResult' => '(玩法无规则异常)-' . $odds_code];
        }
    }

    /**
     * 双重机会&最先进球
     * @param mixed $model 注单表数据
     * @param mixed $resultModels 结果表数据
     * @param mixed $resultRecords 结果记录表数据
     * model--money_buy_match resultModels--st_zq_result resultRecords--st_zq_result_record
     * @return string
     */
    public function DOFB($model, $resultModels, $resultRecords)
    {

        $isgqwx = $this->GunqiuWeixian($model, $resultModels, $resultRecords);
        if ($isgqwx) {
            return $isgqwx;
        }

        $resultModels = $resultModels['0'];
        $word = array(
            'home' => $resultModels->home_score . "(主队全场)",
            'guest' => $resultModels->guest_score . "(客队全场)",
            'firstscore' => $resultModels->first_score . "(最先进球)",
        );

        $odds_code = $model->odds_code;
        switch ($odds_code) {
            case "dofgh_cohd": //主队最先进球(主队/和局)
                $returnDatas = $this->oneball($resultModels, $model, dofgh_cohd, $word);
                break;
            case "dofbg_cohd": //客队最先进球(主队/和局)
                $returnDatas = $this->oneball($resultModels, $model, dofbg_cohd, $word);
                break;
            case "dofbh_cogd": //主队最先进球(主队/和局)
                $returnDatas = $this->oneball($resultModels, $model, dofbh_cogd, $word);
                break;
            case "dofbg_cogd": //客队最先进球(主队/和局)
                $returnDatas = $this->oneball($resultModels, $model, dofbg_cogd, $word);
                break;
            case "dofbh_cohg": //主队最先进球(主队/和局)
                $returnDatas = $this->oneball($resultModels, $model, dofbh_cohg, $word);
                break;
            case "dofbg_cohg": //客队最先进球(主队/和局)
                $returnDatas = $this->oneball($resultModels, $model, dofbg_cohg, $word);
                break;
            default:
                $returnDatas = ['result' => 2, 'matchResult' => '(玩法无规则异常)-' . $odds_code];
        }
    }

    /**
     * 进球大/小&进球单/双
     * @param mixed $model 注单表数据
     * @param mixed $resultModels 结果表数据
     * @param mixed $resultRecords 结果记录表数据
     * model--money_buy_match resultModels--st_zq_result resultRecords--st_zq_result_record
     * @return string
     */
    public function GSTS($model, $resultModels, $resultRecords)
    {
        $isgqwx = $this->GunqiuWeixian($model, $resultModels, $resultRecords);
        if ($isgqwx) {
            return $isgqwx;
        }


        $resultModels = $resultModels['0'];
        $allword = $resultModels->home_score . '-' . $resultModels->guest_score . "(全场)";

        $odds_code = $model->odds_code;
        switch ($odds_code) {
            case "gstsb1s": //大1.5|单
                $returnDatas = $this->sizesd($resultModels, $model, gstsb1s, $allword);
                break;
            case "gstss1s": //小1.5|单
                $returnDatas = $this->sizesd($resultModels, $model, gstss1s, $allword);
                break;
            case "gstsb1d": //大1.5|双
                $returnDatas = $this->sizesd($resultModels, $model, gstsb1d, $allword);
                break;
            case "gstss1d": //小1.5|双
                $returnDatas = $this->sizesd($resultModels, $model, gstss1d, $allword);
                break;
            case "gstsb2s": //大2.5|单
                $returnDatas = $this->sizesd($resultModels, $model, gstsb2s, $allword);
                break;
            case "gstss2s": //小2.5|单
                $returnDatas = $this->sizesd($resultModels, $model, gstss2s, $allword);
                break;
            case "gstsb2d": //大2.5|双
                $returnDatas = $this->sizesd($resultModels, $model, gstsb2d, $allword);
                break;
            case "gstss2d": //小2.5|双
                $returnDatas = $this->sizesd($resultModels, $model, gstss2d, $allword);
                break;
            case "gstsb3s": //大3.5|单
                $returnDatas = $this->sizesd($resultModels, $model, gstsb3s, $allword);
                break;
            case "gstss3s": //小3.5|单
                $returnDatas = $this->sizesd($resultModels, $model, gstss3s, $allword);
                break;
            case "gstsb3d": //大3.5|双
                $returnDatas = $this->sizesd($resultModels, $model, gstsb3d, $allword);
                break;
            case "gstss3d": //小3.5|双
                $returnDatas = $this->sizesd($resultModels, $model, gstss3d, $allword);
                break;
            case "gstsb4s": //大4.5|单
                $returnDatas = $this->sizesd($resultModels, $model, gstsb4s, $allword);
                break;
            case "gstss4s": //小4.5|单
                $returnDatas = $this->sizesd($resultModels, $model, gstss4s, $allword);
                break;
            case "gstsb4d": //大4.5|双
                $returnDatas = $this->sizesd($resultModels, $model, gstsb4d, $allword);
                break;
            case "gstss4d": //小4.5|双
                $returnDatas = $this->sizesd($resultModels, $model, gstss4d, $allword);
                break;
            default:
                $returnDatas = ['result' => 2, 'matchResult' => '(玩法无规则异常)-' . $odds_code];
        }
    }

    /**
     * 进球大/小&最先进球
     * @param mixed $model 注单表数据
     * @param mixed $resultModels 结果表数据
     * @param mixed $resultRecords 结果记录表数据
     * model--money_buy_match resultModels--st_zq_result resultRecords--st_zq_result_record
     * @return string
     */
    public function GSFB($model, $resultModels, $resultRecords)
    {
        $isgqwx = $this->GunqiuWeixian($model, $resultModels, $resultRecords);
        if ($isgqwx) {
            return $isgqwx;
        }

        $resultModels = $resultModels['0'];
        $allword = array(
            'score' => $resultModels->home_score . '-' . $resultModels->guest_score . "(全场)",
            'firstscore' => $resultModels->first_score,
        );

        $odds_code = $model->odds_code;
        switch ($odds_code) {
            case "gsfbb1h": //大1.5|主队最先进球
                $returnDatas = $this->sizeone($resultModels, $model, gsfbb1h, $allword);
                break;
            case "gsfbs1h": //小1.5|主队最先进球
                $returnDatas = $this->sizeone($resultModels, $model, gsfbs1h, $allword);
                break;
            case "gsfbb1g": //大1.5|客队最先进球
                $returnDatas = $this->sizeone($resultModels, $model, gsfbb1g, $allword);
                break;
            case "gsfbs1g": //小1.5|客队最先进球
                $returnDatas = $this->sizeone($resultModels, $model, gsfbs1g, $allword);
                break;
            case "gsfbb2h": //大2.5|主队最先进球
                $returnDatas = $this->sizeone($resultModels, $model, gsfbb2h, $allword);
                break;
            case "gsfbs2h": //小2.5|主队最先进球
                $returnDatas = $this->sizeone($resultModels, $model, gsfbs2h, $allword);
                break;
            case "gsfbb2g": //大2.5|客队最先进球
                $returnDatas = $this->sizeone($resultModels, $model, gsfbb2g, $allword);
                break;
            case "gsfbs2g": //小2.5|客队最先进球
                $returnDatas = $this->sizeone($resultModels, $model, gsfbs2g, $allword);
                break;
            case "gsfbb3h": //大3.5|主队最先进球
                $returnDatas = $this->sizeone($resultModels, $model, gsfbb3h, $allword);
                break;
            case "gsfbs3h": //小3.5|主队最先进球
                $returnDatas = $this->sizeone($resultModels, $model, gsfbs3h, $allword);
                break;
            case "gsfbb3g": //大3.5|客队最先进球
                $returnDatas = $this->sizeone($resultModels, $model, gsfbb3g, $allword);
                break;
            case "gsfbs3g": //小3.5|客队最先进球
                $returnDatas = $this->sizeone($resultModels, $model, gsfbs3g, $allword);
                break;
            case "gsfbb4h": //大4.5|主队最先进球
                $returnDatas = $this->sizeone($resultModels, $model, gsfbb4h, $allword);
                break;
            case "gsfbs4h": //小4.5|主队最先进球
                $returnDatas = $this->sizeone($resultModels, $model, gsfbs4h, $allword);
                break;
            case "gsfbb4g": //大4.5|客队最先进球
                $returnDatas = $this->sizeone($resultModels, $model, gsfbb4g, $allword);
                break;
            case "gsfbs4g": //小4.5|客队最先进球
                $returnDatas = $this->sizeone($resultModels, $model, gsfbs4g, $allword);
                break;
            default:
                $returnDatas = ['result' => 2, 'matchResult' => '(玩法无规则异常)-' . $odds_code];
        }
    }

    /**
     * 落后反超获胜
     * @param mixed $model 注单表数据
     * @param mixed $resultModels 结果表数据
     * @param mixed $resultRecords 结果记录表数据
     * model--money_buy_match resultModels--st_zq_result resultRecords--st_zq_result_record
     * @return string jimy end  ？？？
     */
    public function FW($model, $resultModels, $resultRecords)
    {

        $isgqwx = $this->GunqiuWeixian($model, $resultModels, $resultRecords);
        if ($isgqwx) {
            return $isgqwx;
        }

        $resultModels = $resultModels['0'];
        $homeword = $resultModels->home_score . "(主队全场)";
        $guestword = $resultModels->guest_score . "(客队全场)";
        $allword = $resultModels->home_score . '-' . $resultModels->guest_score . "(全场)";

        $odds_code = $model->odds_code;
        switch ($odds_code) {
            case "fwh": //主队
                $returnDatas = $this->backwardwins($resultModels, $model, fwh, $homeword);
                break;
            case "fwg": //客队
                $returnDatas = $this->backwardwins($resultModels, $model, fwg, $homeword);
                break;
            default:
                $returnDatas = ['result' => 2, 'matchResult' => '(玩法无规则异常)-' . $odds_code];
        }
    }


    //滚球危险球判断处理
    public function GunqiuWeixian($model, $resultModels, $resultRecords)
    {
        //==获取是否是滚球投注==
        $is_rolling = $model->is_rolling;
        //如果是滚球投注，则进行危险球审核
        if ($is_rolling == 1) {
            $ret = commonFunction::WARN_CHECK($model, $resultModels);
            //如果审核不通过，则返回2   1赢 2平 -1输
            if ($ret['code'] == -1) {
                $data = [
                    'result' => 2,
                    'matchResult' => "滚球投注，危险球审核不通过",
                    'warn_more' => $ret['warn_more']
                ];
                return $data;
            }
        }
        return false;
    }

}