| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- <?php
- /**
- * Created by PhpStorm.
- * User: Administrator
- * Date: 2019/7/15
- * Time: 16:51
- */
- namespace App\Logic;
- use Illuminate\Database\Capsule\Manager as DB;
- use App\Lib\Settlement\Adapter\ZqRule;
- use App\Lib\Settlement\Adapter\LqRule;
- use App\Lib\Settlement\Adapter\WqRule;
- use App\Lib\Settlement\Adapter\BqRule;
- class WinfailLogic
- {
- //类型映射
- public $gameAllMap = [
- 'zq' => 'ZqRule',
- 'lq' => 'LqRule',
- 'wq' => 'WqRule',
- 'bq' => 'BqRule',
- ];
- public function getNoticeDate($id)
- {
- $noticeMode = DB::table('comendnotice')->where(['id' => $id])->first();
- if (empty($noticeMode)) {
- throw new \Exception("没有找到notice记录-" . $id);
- }
- return $noticeMode;
- }
- //得到比赛最终结果记录
- public function getCompResult($type, $match_id)
- {
- $model = null;
- switch ($type) {
- case 'bq':
- $model = DB::table('st_bq_result')->where('match_id', $match_id)->orderby('id', 'asc')->get();
- break;
- case 'lq':
- $model = DB::table('st_lq_result')->where('match_id', $match_id)->orderby('id', 'asc')->get();
- break;
- case 'wq':
- $model = DB::table('st_wq_result')->where('match_id', $match_id)->orderby('id', 'asc')->get();
- break;
- case 'zq':
- $model = DB::table('st_zq_result')->where('match_id', $match_id)->orderby('id', 'asc')->get();
- break;
- }
- if (empty($model)) {
- throw new \Exception("没有找到赛事结果记录-" . $type . '-' . $match_id);
- }
- return $model;
- }
- //单式订单存在 单独设置比赛结果的情况,要分开处理
- public function getSimplexData($type, $match_id)
- {
- $return = [];
- $ret = DB::table("money_buy_simplex")->where(['game_code' => $type, 'match_id' => $match_id])->get();
- if (count($ret) <= 0) {
- return;
- }
- foreach ($ret as $val) {
- $return[$val->batch_id][$val->match_id] = ['result_flag' => $val->result_flag, 'single_result' => $val->single_result];
- }
- return $return;
- }
- //找到订单详细数据
- public function getMatchRecords($type, $match_id, $bet_type)
- {
- $return = [];
- $ret = DB::table("money_buy_match")->where(['game_code' => $type, 'match_id' => $match_id, 'bet_type' => $bet_type])->get();
- if (count($ret) <= 0) {
- return;
- }
- foreach ($ret as $val) {
- $return[] = $val;
- }
- return $return;
- }
- public function getAdapterObj($game_type)
- {
- $game_type = strtolower($game_type);
- if (!isset($this->gameAllMap)) {
- throw new \Exception('赛事类型错误-' . $game_type, 4002);
- return false;
- }
- switch ($game_type) {
- case 'bq':
- $apd = new BqRule();
- break;
- case 'lq':
- $apd = new LqRule();
- break;
- case 'wq':
- $apd = new WqRule();
- break;
- case 'zq':
- $apd = new ZqRule();
- break;
- }
- return $apd;
- }
- //冠军比赛结果
- public function getGjDatas($matchModel)
- {
- $table = 'st_' . $matchModel->game_code . '_league_result';
- $where = ['lg_id' => $matchModel->lg_id, 'game_name' => $matchModel->odds_code];
- $model = DB::table($table)->where($where)->first();
- if (count($model) <= 0) {
- throw new \Exception('冠军数据没找到!');
- }
- return $model;
- }
- }
|