SoccerNoteListController.php 52 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Jonlin
  5. * Date: 2019/4/9
  6. * Time: 9:11
  7. */
  8. namespace App\Http\Controllers\Admin;
  9. use App\Http\Controllers\Controller;
  10. use Illuminate\Http\Request as Req;
  11. use Illuminate\Support\Facades\DB;
  12. Use App\Lib\Settlement\SettlementOrder;
  13. Use App\Lib\Settlement\SettlementWinFail;
  14. use App\Models;
  15. use App\Models\MoneyBuySimplex as MoneyBuySimplexModel;
  16. use Request;
  17. /**
  18. *1
  19. */
  20. class SoccerNoteListController extends Controller
  21. {
  22. public function notelist(Req $req)
  23. {
  24. $request['name_chinese'] = isset($req->name_chinese) ? trim($req->name_chinese) : null;
  25. $request['sureblurs'] = isset($req->sureblurs) ? $req->sureblurs : 'on';
  26. $request['account'] = isset($req->account) ? trim($req->account) : null;
  27. $request['star_time'] = isset($req->star_time) ? trim($req->star_time) : null;
  28. $request['end_time'] = isset($req->end_time) ? trim($req->end_time) : null;
  29. $request['order_id'] = isset($req->order_id) ? trim($req->order_id) : null;
  30. $request['match_id'] = isset($req->match_id) ? trim($req->match_id) : null;
  31. $request['status'] = isset($req->status) ? trim($req->status) : '-1';
  32. $request['order_status'] = isset($req->order_status) ? trim($req->order_status) : '-1';
  33. $request['game_status'] = isset($req->game_status) ? trim($req->game_status) : 0;
  34. $request['type'] = isset($req->type) ? trim($req->type) : 'zq';
  35. $dt = \App\Lib\DataTable\DataTable::init();
  36. $dt->setDataSource('/admin/SoccerNoteList/getinfo');
  37. $dt->setLang('sportsnotelist');
  38. //$dt->addColsFields('id', array('templet' => '#userdetail', 'sort' => true, 'width' => 80));
  39. $dt->addColsFields('match_id_order', array('sort' => true, 'width' => 210, 'minWidth'=>200));
  40. $dt->addColsFields('league', array('templet' => '#userdetail', 'sort' => false, 'width' => 100));
  41. $dt->addColsFields('home_guest', array('templet' => '#userdetail', 'sort' => false, 'width' => 260));
  42. $dt->addColsFields('content', array('templet' => '#userdetail', 'sort' => false, 'width' => 250));
  43. $dt->addColsFields('money', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
  44. $dt->addColsFields('water_return', array('templet' => '#userdetail', 'sort' => false, 'width' => 70));
  45. $dt->addColsFields('prize_money', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
  46. $dt->addColsFields('result', array('templet' => '#userdetail', 'sort' => false, 'width' => 70));
  47. $dt->addColsFields('money_match_time', array('templet' => '#userdetail', 'sort' => false, 'width' => 200));
  48. $dt->addColsFields('order_status', array('sort' => false, 'width' => 80));
  49. $dt->addColsFields('account_money', array('templet' => '#userdetail', 'sort' => false, 'width' => 110));
  50. // $dt->addColsFields('game_status', array('templet' => '#game_status', 'sort' => false, 'width' => 114));
  51. $dt->addColsFields('game_status', array('sort' => false, 'width' => 80));
  52. // $arr[] = 'view';
  53. // if (checkRriv('/admin/SoccerNoteList/edit')) {
  54. // $arr[] = 'edit';
  55. // }
  56. // $dt->setToolBar($arr, array('width' => 70));
  57. $dt->enableCheckBox();//var_dump($request['type']);
  58. return view('sports/sports_notelist', $dt->render($request));
  59. }
  60. //冠军注单手工结算
  61. public function championset(Req $req)
  62. {
  63. $request['name_chinese'] = isset($req->name_chinese) ? trim($req->name_chinese) : null;
  64. $request['sureblurs'] = isset($req->sureblurs) ? $req->sureblurs : 'on';
  65. $request['account'] = isset($req->account) ? trim($req->account) : null;
  66. $request['star_time'] = isset($req->star_time) ? trim($req->star_time) : null;
  67. $request['end_time'] = isset($req->end_time) ? trim($req->end_time) : null;
  68. $request['order_id'] = isset($req->order_id) ? trim($req->order_id) : null;
  69. $request['match_id'] = isset($req->match_id) ? trim($req->match_id) : null;
  70. $request['status'] = isset($req->status) ? trim($req->status) : '-1';
  71. $request['order_status'] = isset($req->order_status) ? trim($req->order_status) : '-1';
  72. $request['type'] = isset($req->type) ? trim($req->type) : 'zq';
  73. $dt = \App\Lib\DataTable\DataTable::init();
  74. $dt->setDataSource('/admin/SoccerNoteList/championsetinfo');
  75. $dt->setLang('sportsnotelist');
  76. //$dt->addColsFields('id', array('templet' => '#userdetail', 'sort' => true, 'width' => 80));
  77. $dt->addColsFields('lg_id_order', array('sort' => true, 'width' => 210, 'minWidth' => 200));
  78. $dt->addColsFields('league', array('templet' => '#userdetail', 'sort' => false, 'width' => 100));
  79. $dt->addColsFields('home_guest', array('templet' => '#userdetail', 'sort' => false, 'width' => 260));
  80. $dt->addColsFields('content', array('templet' => '#userdetail', 'sort' => false, 'width' => 250));
  81. $dt->addColsFields('money', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
  82. $dt->addColsFields('water_return', array('templet' => '#userdetail', 'sort' => false, 'width' => 70));
  83. $dt->addColsFields('prize_money', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
  84. $dt->addColsFields('result', array('templet' => '#userdetail', 'sort' => false, 'width' => 70));
  85. $dt->addColsFields('money_match_time', array('templet' => '#userdetail', 'sort' => false, 'width' => 200));
  86. $dt->addColsFields('order_status', array('sort' => false, 'width' => 80));
  87. $dt->addColsFields('account_money', array('templet' => '#userdetail', 'sort' => false, 'width' => 110));
  88. // $dt->addColsFields('game_status', array('templet' => '#game_status', 'sort' => false, 'width' => 114));
  89. $dt->addColsFields('game_status', array( 'sort' => false, 'width' => 114));
  90. //$arr[] = 'view';
  91. // if (checkRriv('/admin/SoccerNoteList/edit')) {
  92. // $arr[] = 'edit';
  93. // }
  94. // $dt->setToolBar($arr, array('width' => 70));
  95. $dt->enableCheckBox();//var_dump($request['type']);
  96. return view('sports/sports_notelist', $dt->render($request));
  97. }
  98. function championsetinfo()
  99. {
  100. $page = Request::has('page') ? Request::get('page') : '';
  101. $list = Request::has('limit') ? Request::get('limit') : 10;
  102. $account = Request::get('account') ? Request::get('account') : '';
  103. $star_time = Request::get('star_time') ? Request::get('star_time') . ' 00:00:00' : '';
  104. $end_time = Request::get('end_time') ? Request::get('end_time') . ' 23:59:59' : '';
  105. $order_id = Request::get('order_id') ? Request::get('order_id') : '';
  106. $match_id = Request::get('match_id') ? Request::get('match_id') : '';
  107. $status = Request::has('status') ? Request::get('status') : '-1';
  108. $order_status = Request::has('order_status') ? Request::get('order_status') : '';
  109. $sureblur = Request::has('sureblurs') ? Request::get('sureblurs') : 'off';
  110. $type = Request::has('type') ? Request::get('type') : 'zq';
  111. $where = array();
  112. $where[] = array('money_buy_simplex.is_champion', 1);
  113. if (!empty($account)) {
  114. if (empty($sureblur) || $sureblur == 'off') {
  115. $where[] = array('money_buy_simplex.account_name', 'like', '%' . $account . '%');
  116. } else {
  117. $where[] = array('money_buy_simplex.account_name', '=', $account);
  118. }
  119. }
  120. if (!empty($star_time)) {
  121. if (!empty($end_time)) {
  122. $where[] = array('money_buy_simplex.money_time', '>', $star_time);
  123. $where[] = array('money_buy_simplex.money_time', '<', $end_time);
  124. } else {
  125. $where[] = array('money_buy_simplex.money_time', '>', $star_time);
  126. }
  127. } else if (empty($star_time)) {
  128. if (!empty($end_time)) {
  129. $where[] = array('money_buy_simplex.money_time', '<', $end_time);
  130. }
  131. }
  132. if (!empty($order_id)) {
  133. $where[] = array('money_buy_simplex.order_id', $order_id);
  134. }
  135. if (!empty($match_id)) {
  136. $where[] = array('money_buy_simplex.match_id', $match_id);
  137. }
  138. if ($status != -1) {
  139. $where[] = array('money_buy_simplex.settle_status', '=', $status);
  140. }
  141. if ($order_status != -1) {
  142. $where[] = array('money_buy_simplex.status', '=', $order_status);
  143. }
  144. $where[] = array('money_buy_simplex.game_code', $type);
  145. $newapp = new \App\Models\SportsNoteList();
  146. $data = $newapp->getinfo($list, $page, $where, $type);
  147. //$alldata = Models\MoneyBuyMatch::where('bet_type',1)->where('is_rolling',1)->distinct('order_id')->count('order_id');
  148. return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total'], 0, $where);
  149. }
  150. //修改冠军单订单结果
  151. function orderupgj(Req $req)
  152. {
  153. $id = $req->id;//37
  154. $orderid = $req->order;//S20190916094723915270970
  155. if (intval($id) < 1) {
  156. return -1;
  157. }
  158. $data = \App\Models\SoccerLeague::where('id', $id)->first();
  159. $odds_code = \App\Models\SoccerOdds::where('lg_id', $id)->where('type', 1)->where('odds_code', '!=', '')->select('odds_code')->distinct()->get()->toArray();//赔率表
  160. for ($i = 0; $i < count($odds_code); $i++) {
  161. $allteam[] = \App\Models\SoccerOdds::where('odds_code', $odds_code[$i]['odds_code'])->where('lg_id', $id)->where('type', 1)->select('team')->distinct()->get()->toArray();
  162. }
  163. $data = $data->toArray();
  164. $isdisplay = \App\Models\Stwqleagueresult::where(['lg_id' => $id, 'status' => 1])->select("game_name")->distinct()->get()->toArray();
  165. $idisplay = array_column($isdisplay, 'game_name');
  166. $displays = implode(",", $idisplay);//转换成字符串
  167. //新增纪录
  168. foreach ($odds_code as $k => $v) {
  169. foreach ($allteam[$k] as $kk => $vv) {
  170. $name = $v['odds_code'];
  171. $isteam = $allteam[$k][$kk]['team'];
  172. $res = \App\Models\Stwqleagueresult::where(['lg_id' => $id, 'game_name' => $name, 'result' => $isteam])->first();
  173. $addresult = [
  174. 'lg_id' => $id,
  175. 'game_name' => $name,
  176. 'result' => $isteam,
  177. 'ctime' => date('Y-m-d H:i:s', time()),
  178. 'status' => 0,
  179. 'updated_at' => date('Y-m-d H:i:s', time()),
  180. ];
  181. if (empty($res)) {
  182. \App\Models\Stwqleagueresult::insert($addresult);
  183. }
  184. }
  185. }
  186. $orderjg = \App\Models\SportsNoteList::where(['order_id' => $orderid])->select("single_result")->first();
  187. $orderjg = json_decode($orderjg['single_result'], true);
  188. $data['allteam'] = $allteam;
  189. $data['odds_code'] = $odds_code;
  190. $data['displays'] = $displays;
  191. $data['isdisplay'] = $isdisplay;
  192. $data['orderjg'] = $orderjg;
  193. $data['orderid'] = $orderid;
  194. $data['lg_id'] = $id;
  195. return view('sports/orderupgj', $data);
  196. }
  197. //修改冠军单订单结果提交
  198. function ajaxtj(Req $req)
  199. {
  200. $isstatus = $req->isstatus;//更新
  201. $order = $req->order;
  202. if ($isstatus) {
  203. $gjresult = array(
  204. 'lg_id' => $req->lg_id ? $req->lg_id : '',
  205. 'game_name' => $req->odds_code ? $req->odds_code : '',
  206. 'result' => $req->team ? $req->team : '',
  207. 'updatetime' => date("Y-m-d H:i:s", time()),
  208. );
  209. } else {
  210. $gjresult = array(
  211. 'lg_id' => '',
  212. 'game_name' => '',
  213. 'result' => '',
  214. );
  215. }
  216. \App\Models\SportsNoteList::where(['order_id' => $order])->update(['single_result' => json_encode($gjresult, JSON_UNESCAPED_UNICODE)]);
  217. return responseToJson(1);
  218. }
  219. function info()
  220. {
  221. $page = Request::has('page') ? Request::get('page') : '';
  222. $list = Request::has('limit') ? Request::get('limit') : 10;
  223. $account = Request::get('account') ? Request::get('account') : '';
  224. $star_time = Request::get('star_time') ? Request::get('star_time') . ' 00:00:00' : '';
  225. $end_time = Request::get('end_time') ? Request::get('end_time') . ' 23:59:59' : '';
  226. $order_id = Request::get('order_id') ? Request::get('order_id') : '';
  227. $match_id = Request::get('match_id') ? Request::get('match_id') : '';
  228. // $status = Request::has('status') ? Request::get('status') : '';
  229. $order_status = Request::has('order_status') ? Request::get('order_status') : '';
  230. $sureblur = Request::has('sureblurs') ? Request::get('sureblurs') : 'off';
  231. $type = Request::has('type') ? Request::get('type') : 'zq';
  232. $where = array();
  233. $where[] = array('money_buy_simplex.is_champion', '<>', 1);
  234. if (!empty($account)) {
  235. if (empty($sureblur) || $sureblur == 'off') {
  236. $where[] = array('money_buy_simplex.account_name', 'like', '%' . $account . '%');
  237. } else {
  238. $where[] = array('money_buy_simplex.account_name', '=', $account);
  239. }
  240. }
  241. if (!empty($star_time)) {
  242. if (!empty($end_time)) {
  243. $where[] = array('money_buy_simplex.money_time', '>', $star_time);
  244. $where[] = array('money_buy_simplex.money_time', '<', $end_time);
  245. } else {
  246. $where[] = array('money_buy_simplex.money_time', '>', $star_time);
  247. }
  248. } else if (empty($star_time)) {
  249. if (!empty($end_time)) {
  250. $where[] = array('money_buy_simplex.money_time', '<', $end_time);
  251. }
  252. }
  253. if (!empty($order_id)) {
  254. $where[] = array('money_buy_simplex.order_id', $order_id);
  255. }
  256. if (!empty($match_id)) {
  257. $where[] = array('money_buy_simplex.match_id', $match_id);
  258. }
  259. //调整状态查询 1,2,3为订单状态 1投注 2作废 3撤单
  260. if ($order_status == 1 || $order_status == 2 || $order_status == 3) {
  261. $where[] = array('money_buy_simplex.status', '=', $order_status);
  262. }
  263. //4 5为结算状态 4未结算 5已结算
  264. if ($order_status == 4) {
  265. $status = 1;
  266. $where[] = array('money_buy_simplex.settle_status', '=', $status);
  267. }
  268. if ($order_status == 5) {
  269. $status = 2;
  270. $where[] = array('money_buy_simplex.settle_status', '=', $status);
  271. }
  272. /*
  273. if ($status != -1) {
  274. $where[] = array('money_buy_simplex.settle_status', '=', $status);
  275. }
  276. if ($order_status != -1) {
  277. $where[] = array('money_buy_simplex.status', '=', $order_status);
  278. }
  279. */
  280. $where[] = array('money_buy_simplex.game_code', $type);
  281. $newapp = new \App\Models\SportsNoteList();
  282. $data = $newapp->getinfo($list, $page, $where, $type);
  283. return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total'], 0, $where);
  284. }
  285. public function search(Req $req)
  286. {
  287. $request['name_chinese'] = isset($req->name_chinese) ? trim($req->name_chinese) : null;
  288. $request['sureblurs'] = isset($req->sureblurs) ? $req->sureblurs : 'on';
  289. $request['account'] = isset($req->account) ? trim($req->account) : null;
  290. $request['star_time'] = isset($req->star_time) ? trim($req->star_time) : null;
  291. $request['end_time'] = isset($req->end_time) ? trim($req->end_time) : null;
  292. $request['order_id'] = isset($req->order_id) ? trim($req->order_id) : null;
  293. $request['match_id'] = isset($req->match_id) ? trim($req->match_id) : null;
  294. $request['status'] = isset($req->status) ? trim($req->status) : '-1';
  295. $request['order_status'] = isset($req->order_status) ? trim($req->order_status) : '-1';
  296. $request['type'] = isset($req->type) ? trim($req->type) : 'zq';
  297. $dt = \App\Lib\DataTable\DataTable::init();
  298. $dt->setDataSource('/admin/SoccerNoteList/info');
  299. $dt->setLang('sportsnotelist');
  300. //$dt->addColsFields('id', array('templet' => '#userdetail', 'sort' => true, 'width' => 80));
  301. $dt->addColsFields('match_id_order', array('sort' => true, 'width' => 210, 'minWidth'=>200));
  302. $dt->addColsFields('league', array('templet' => '#userdetail', 'sort' => false, 'width' => 100));
  303. $dt->addColsFields('home_guest', array('templet' => '#userdetail', 'sort' => false, 'width' => 260));
  304. $dt->addColsFields('content', array('templet' => '#userdetail', 'sort' => false, 'width' => 250));
  305. $dt->addColsFields('money', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
  306. $dt->addColsFields('water_return', array('templet' => '#userdetail', 'sort' => false, 'width' => 70));
  307. $dt->addColsFields('prize_money', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
  308. $dt->addColsFields('result', array('templet' => '#userdetail', 'sort' => false, 'width' => 70));
  309. $dt->addColsFields('money_match_time', array('templet' => '#userdetail', 'sort' => false, 'width' => 200));
  310. $dt->addColsFields('order_status', array('sort' => false, 'width' => 80));
  311. $dt->addColsFields('account_money', array('templet' => '#userdetail', 'sort' => false, 'width' => 110));
  312. // $dt->addColsFields('settle_status', array('sort' => false, 'width' => 90));
  313. //$arr[] = 'view';
  314. // if (checkRriv('/admin/SoccerNoteList/edit')) {
  315. // $arr[] = 'edit';
  316. // }
  317. // $dt->setToolBar($arr, array('width' => 70));
  318. $dt->enableCheckBox();
  319. return view('sports/sports_search', $dt->render($request));
  320. }
  321. //冠军注单
  322. public function champion(Req $req)
  323. {
  324. $request['name_chinese'] = isset($req->name_chinese) ? trim($req->name_chinese) : null;
  325. $request['sureblurs'] = isset($req->sureblurs) ? $req->sureblurs : 'on';
  326. $request['account'] = isset($req->account) ? trim($req->account) : null;
  327. $request['star_time'] = isset($req->star_time) ? trim($req->star_time) : null;
  328. $request['end_time'] = isset($req->end_time) ? trim($req->end_time) : null;
  329. $request['order_id'] = isset($req->order_id) ? trim($req->order_id) : null;
  330. $request['match_id'] = isset($req->match_id) ? trim($req->match_id) : null;
  331. $request['status'] = isset($req->status) ? trim($req->status) : '-1';
  332. $request['order_status'] = isset($req->order_status) ? trim($req->order_status) : '-1';
  333. $request['type'] = isset($req->type) ? trim($req->type) : 'zq';
  334. $dt = \App\Lib\DataTable\DataTable::init();
  335. $dt->setDataSource('/admin/SoccerNoteList/championinfo');
  336. $dt->setLang('sportsnotelist');
  337. //$dt->addColsFields('id', array('templet' => '#userdetail', 'sort' => true, 'width' => 80));
  338. $dt->addColsFields('lg_id_order', array('sort' => true, 'width' => 210, 'minWidth' => 200));
  339. $dt->addColsFields('league', array('templet' => '#userdetail', 'sort' => false, 'width' => 100));
  340. $dt->addColsFields('home_guest', array('templet' => '#userdetail', 'sort' => false, 'width' => 260));
  341. $dt->addColsFields('content', array('templet' => '#userdetail', 'sort' => false, 'width' => 250));
  342. $dt->addColsFields('money', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
  343. $dt->addColsFields('water_return', array('templet' => '#userdetail', 'sort' => false, 'width' => 70));
  344. $dt->addColsFields('prize_money', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
  345. $dt->addColsFields('result', array('templet' => '#userdetail', 'sort' => false, 'width' => 70));
  346. $dt->addColsFields('money_match_time', array('templet' => '#userdetail', 'sort' => false, 'width' => 200));
  347. $dt->addColsFields('order_status', array('sort' => false, 'width' => 80));
  348. $dt->addColsFields('account_money', array('templet' => '#userdetail', 'sort' => false, 'width' => 110));
  349. // $dt->addColsFields('game_status', array('sort' => false, 'width' => 90));
  350. //$arr[] = 'view';
  351. // if (checkRriv('/admin/SoccerNoteList/edit')) {
  352. // $arr[] = 'edit';
  353. // }
  354. // $dt->setToolBar($arr, array('width' => 70));
  355. $dt->enableCheckBox();
  356. return view('sports/sports_search', $dt->render($request));
  357. }
  358. function championinfo()
  359. {
  360. $page = Request::has('page') ? Request::get('page') : '';
  361. $list = Request::has('limit') ? Request::get('limit') : 10;
  362. $account = Request::get('account') ? Request::get('account') : '';
  363. $star_time = Request::get('star_time') ? Request::get('star_time') . ' 00:00:00' : '';
  364. $end_time = Request::get('end_time') ? Request::get('end_time') . ' 23:59:59' : '';
  365. $order_id = Request::get('order_id') ? Request::get('order_id') : '';
  366. $match_id = Request::get('match_id') ? Request::get('match_id') : '';
  367. $status = Request::has('status') ? Request::get('status') : '';
  368. $order_status = Request::has('order_status') ? Request::get('order_status') : '';
  369. $sureblur = Request::has('sureblurs') ? Request::get('sureblurs') : 'off';
  370. $type = Request::has('type') ? Request::get('type') : 'zq';
  371. $where = array();
  372. $where[] = array('money_buy_simplex.is_champion', 1);
  373. if (!empty($account)) {
  374. if (empty($sureblur) || $sureblur == 'off') {
  375. $where[] = array('money_buy_simplex.account_name', 'like', '%' . $account . '%');
  376. } else {
  377. $where[] = array('money_buy_simplex.account_name', '=', $account);
  378. }
  379. }
  380. if (!empty($star_time)) {
  381. if (!empty($end_time)) {
  382. $where[] = array('money_buy_simplex.money_time', '>', $star_time);
  383. $where[] = array('money_buy_simplex.money_time', '<', $end_time);
  384. } else {
  385. $where[] = array('money_buy_simplex.money_time', '>', $star_time);
  386. }
  387. } else if (empty($star_time)) {
  388. if (!empty($end_time)) {
  389. $where[] = array('money_buy_simplex.money_time', '<', $end_time);
  390. }
  391. }
  392. if (!empty($order_id)) {
  393. $where[] = array('money_buy_simplex.order_id', $order_id);
  394. }
  395. if (!empty($match_id)) {
  396. $where[] = array('money_buy_simplex.match_id', $match_id);
  397. }
  398. //调整状态查询 1,2,3为订单状态 1投注 2作废 3撤单
  399. if ($order_status == 1 || $order_status == 2 || $order_status == 3) {
  400. $where[] = array('money_buy_simplex.status', '=', $order_status);
  401. }
  402. //4 5为结算状态 4未结算 5已结算
  403. if ($order_status == 4) {
  404. $status = 1;
  405. $where[] = array('money_buy_simplex.settle_status', '=', $status);
  406. }
  407. if ($order_status == 5) {
  408. $status = 2;
  409. $where[] = array('money_buy_simplex.settle_status', '=', $status);
  410. }
  411. /*
  412. if ($status != -1) {
  413. $where[] = array('money_buy_simplex.settle_status', '=', $status);
  414. }
  415. if ($order_status != -1) {
  416. $where[] = array('money_buy_simplex.status', '=', $order_status);
  417. }
  418. */
  419. $where[] = array('money_buy_simplex.game_code', $type);
  420. $newapp = new \App\Models\SportsNoteList();
  421. $data = $newapp->getinfo($list, $page, $where, $type);
  422. return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total'], 0, $where);
  423. }
  424. //查询赛事结果
  425. // function Sairesult(Req $req){
  426. // $did = $req->did;
  427. // $qlgame = $req->qlgame?$req->qlgame:'zq';
  428. // $newapp = \App\Models\SportsNoteList::where('id', $did)->first();
  429. // if($qlgame=='zq'){
  430. // if($newapp['match_id']){
  431. // $newre = new \App\Models\Stzqresult();
  432. // $teamname = $newre->matchjg($newapp['match_id']);
  433. // }else{
  434. // $teamname ='';
  435. // }
  436. // }elseif($qlgame=='lq'){
  437. // if($newapp['match_id']){
  438. // $newre = new \App\Models\Stlqresult();
  439. // $teamname = $newre->matchjg($newapp['match_id']);
  440. // }else{
  441. // $teamname ='';
  442. // }
  443. // }elseif($qlgame=='bq'){
  444. // if($newapp['match_id']){
  445. // $newre = new \App\Models\Stbqresult();
  446. // $teamname = $newre->matchjg($newapp['match_id']);
  447. // }else{
  448. // $teamname ='';
  449. // }
  450. // }elseif($qlgame=='wq'){
  451. // if($newapp['match_id']){
  452. // $newre = new \App\Models\Stwqresult();
  453. // $teamname = $newre->matchjg($newapp['match_id']);
  454. // }else{
  455. // $teamname ='';
  456. // }
  457. // }else{
  458. // $data = "参数错误";
  459. // }
  460. // $data =array(
  461. // 'singleresult' => json_decode($newapp['single_result'],true),
  462. // 'teamname' => $teamname,
  463. // );
  464. // return $data;
  465. // }
  466. // function Sairesult(Req $req){
  467. // $did = $req->did;
  468. // $model = \App\Models\SportsNoteList::where('id', $did)->first();
  469. // $pid = $model['match_id'];
  470. // $saisjg = \App\Models\Stzqresult::where('match_id',$pid)->first()->toArray();//赛事结果
  471. // $saisjg['corner_ball'] = json_decode($saisjg['corner_ball'],true);
  472. // $saisjg['first_score'] = json_decode($saisjg['first_score'],true);
  473. // $saisjg['penalty_card'] = json_decode($saisjg['penalty_card'],true);
  474. // $saisjg['warn_more'] = json_decode($saisjg['warn_more'],true);
  475. // }
  476. //结果添加
  477. function addend(Req $req)
  478. {
  479. $did = $req->did;//59;//
  480. $qlgame = $req->qlgame;//1;
  481. $model = \App\Models\SportsNoteList::where('id', $did)->first();
  482. $pid = $model['match_id'];
  483. if ($qlgame == 1) {
  484. if ($model['result_flag'] != 1) {
  485. $saisjg = \App\Models\Stzqresult::where('match_id', $pid)->first()->toArray();//赛事结果
  486. $saisjg['corner_ball'] = json_decode($saisjg['corner_ball'], true);
  487. $saisjg['first_score'] = json_decode($saisjg['first_score'], true);
  488. $saisjg['penalty_card'] = json_decode($saisjg['penalty_card'], true);
  489. $saisjg['warn_more'] = json_decode($saisjg['warn_more'], true);
  490. $model->single_result = json_encode([$saisjg], JSON_UNESCAPED_UNICODE);
  491. $model->save();
  492. }
  493. $newm = \App\Models\SportsNoteList::where('id', $did)->first();
  494. return $newm['single_result'];
  495. } else {
  496. $new = \App\Models\SportsNoteList::where('id', $did)->first();
  497. $newa = json_decode($new['single_result'], true);
  498. $newa[0]['home_score'] = $req->home_score;//主队进球
  499. $newa[0]['guest_score'] = $req->guest_score;//客队进球
  500. $newa[0]['all_goal'] = intval($req->guest_score) + intval($req->home_score);//总进球
  501. $newa[0]['last_score'] = $req->lastscore ? $req->lastscore : '';//最后进球球队
  502. $newa[0]['match_winer'] = $req->matchwiner ? $req->matchwiner : '';//赢球球队
  503. $newa[0]['update_time'] = time();//更新时间
  504. $newa[0]['u_guest_score'] = $req->u_guest_score;//上半场-主队进球数
  505. $newa[0]['u_home_score'] = $req->u_home_score;//上半场-客队进球数
  506. $newa[0]['penalty_card'] = array(
  507. 'home' => $req->homeallcard,
  508. 'guest' => $req->guestallcard,
  509. 'home_half' => $req->homehalfcard,
  510. 'guest_half' => $req->guesthalfcard,
  511. );
  512. $newa[0]['corner_ball'] = array(
  513. 'home' => $req->homeallcorner,
  514. 'guest' => $req->guestallcorner,
  515. 'home_half' => $req->homehalfcorner,
  516. 'guest_half' => $req->guesthalfcorner,
  517. );
  518. //最新进球
  519. $newa[0]['first_score'] = array(
  520. 'teamscore' => $req->firstscore ? $req->firstscore : 0,//最先进球球队
  521. 'scoretime' => $req->onescoretime ? $req->onescoretime : '',//进球时间
  522. 'scoretype' => $req->firststye ? $req->firststye : '',//进球方式
  523. );
  524. $model->single_result = json_encode($newa, JSON_UNESCAPED_UNICODE);
  525. $model->result_flag = 1;
  526. $model->save();
  527. return responseToJson(1);
  528. }
  529. }
  530. function getinfo()
  531. {
  532. $page = Request::has('page') ? Request::get('page') : '';
  533. $list = Request::has('limit') ? Request::get('limit') : 10;
  534. $account = Request::get('account') ? Request::get('account') : '';
  535. $star_time = Request::get('star_time') ? Request::get('star_time') . ' 00:00:00' : '';
  536. $end_time = Request::get('end_time') ? Request::get('end_time') . ' 23:59:59' : '';
  537. $order_id = Request::get('order_id') ? Request::get('order_id') : '';
  538. $match_id = Request::get('match_id') ? Request::get('match_id') : '';
  539. $status = Request::has('status') ? Request::get('status') : '-1';
  540. $order_status = Request::has('order_status') ? Request::get('order_status') : '';
  541. $sureblur = Request::has('sureblurs') ? Request::get('sureblurs') : 'off';
  542. $type = Request::has('type') ? Request::get('type') : 'zq';
  543. $where = array();
  544. $where[] = array('money_buy_simplex.is_champion', '<>', 1);
  545. if (!empty($account)) {
  546. if (empty($sureblur) || $sureblur == 'off') {
  547. $where[] = array('money_buy_simplex.account_name', 'like', '%' . $account . '%');
  548. } else {
  549. $where[] = array('money_buy_simplex.account_name', '=', $account);
  550. }
  551. }
  552. if (!empty($star_time)) {
  553. if (!empty($end_time)) {
  554. $where[] = array('money_buy_simplex.money_time', '>', $star_time);
  555. $where[] = array('money_buy_simplex.money_time', '<', $end_time);
  556. } else {
  557. $where[] = array('money_buy_simplex.money_time', '>', $star_time);
  558. }
  559. } else if (empty($star_time)) {
  560. if (!empty($end_time)) {
  561. $where[] = array('money_buy_simplex.money_time', '<', $end_time);
  562. }
  563. }
  564. if (!empty($order_id)) {
  565. $where[] = array('money_buy_simplex.order_id', $order_id);
  566. }
  567. if (!empty($match_id)) {
  568. $where[] = array('money_buy_simplex.match_id', $match_id);
  569. }
  570. //调整状态查询 1,2,3为订单状态 1投注 2作废 3撤单
  571. if ($order_status == 1 || $order_status == 2 || $order_status == 3) {
  572. $where[] = array('money_buy_simplex.status', '=', $order_status);
  573. }
  574. //4 5为结算状态 4未结算 5已结算
  575. if ($order_status == 4) {
  576. $status = 1;
  577. $where[] = array('money_buy_simplex.settle_status', '=', $status);
  578. }
  579. if ($order_status == 5) {
  580. $status = 2;
  581. $where[] = array('money_buy_simplex.settle_status', '=', $status);
  582. }
  583. /*
  584. if ($status != -1) {
  585. $where[] = array('money_buy_simplex.settle_status', '=', $status);
  586. }
  587. if ($order_status != -1) {
  588. $where[] = array('money_buy_simplex.status', '=', $order_status);
  589. }
  590. */
  591. $where[] = array('money_buy_simplex.game_code', $type);
  592. $newapp = new \App\Models\SportsNoteList();
  593. $data = $newapp->getinfo($list, $page, $where, $type);
  594. //$alldata = Models\MoneyBuyMatch::where('bet_type',1)->where('is_rolling',1)->distinct('order_id')->count('order_id');
  595. return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total'], 0, $where);
  596. }
  597. /**
  598. *单式注单作废
  599. */
  600. public function invalid(Req $req)
  601. {
  602. $id = $req->id;
  603. $reason = $_GET['reason'];
  604. if (intval($id) < 1) {
  605. return -1;
  606. }
  607. $order = \App\Models\SportsNoteList::where('id', $id)->first();
  608. //用戶账户金额
  609. $account_money = \App\Models\Account_detailed::where('account_identity', $order->account_identity)->first();
  610. //反水
  611. $water_return_money = \App\Models\Money_details::where('trade_id', $order->order_id)->where('trade_type', '7')->first();
  612. if (!empty($water_return_money)) {
  613. $water_return = $water_return_money->money;
  614. } else {
  615. $water_return = 0;
  616. }
  617. //撤单后用户账户金额
  618. $available_cash = $account_money->available_cash;
  619. $new_available_cash = $available_cash + $order->money - $order->gain_money - $water_return;
  620. $model = new \App\Models\Money_details();
  621. $model->info_identity = UUID();
  622. $model->trade_id = $order->order_id;
  623. $model->account_name = $order->account_name;
  624. $model->account_identity = $order->account_identity;
  625. $model->money = abs($order->money - $order->gain_money - $water_return);
  626. $model->money_time = date("Y-m-d H:i:s", time());
  627. if ($new_available_cash > $available_cash) {
  628. $model->money_type = '1';
  629. } else {
  630. $model->money_type = '2';
  631. }
  632. $model->money_cash = $new_available_cash;
  633. $model->trade_type = '3';
  634. $model->trade_desc = '管理员作废单式注单';
  635. $model->status = '1';
  636. try {
  637. DB::beginTransaction();//开启事务
  638. \App\Models\SportsNoteList::where('id', $id)->update(['status' => '2', 'gain_money' => '0', 'use_mark' => $reason]);
  639. \App\Models\Account_detailed::where('account_identity', $order->account_identity)->update(['available_cash' => $new_available_cash, 'cash' => $new_available_cash]);
  640. $model->save();
  641. DB::commit();//提交
  642. return 1;
  643. } catch (Exception $e) {
  644. DB::rollback();//回滚
  645. return -1;
  646. }
  647. }
  648. /**
  649. *单式注单首次结算
  650. */
  651. public function settlement(Req $req)
  652. {
  653. $id = $req->id;
  654. if (intval($id) < 1) {
  655. return -1;
  656. }
  657. $order = \App\Models\SportsNoteList::where('id', $id)->first();
  658. $order_id = $order->order_id;
  659. $order_ids = array($order->order_id);
  660. $match_id = $order->match_id;
  661. $game_code = $order->game_code;
  662. $bet_type = 1;//单式注单
  663. //return $match_id;
  664. //判断输赢
  665. $settlementWinFail = new SettlementWinFail();
  666. $res = $settlementWinFail->ProcWinInfoByOneOrder($match_id, $order_id, $bet_type);
  667. //结算
  668. $SettlementOrder = new SettlementOrder();
  669. $settype = 1; //首次结算
  670. $data = $SettlementOrder->reSettlement($order_ids, $bet_type, $settype, $game_code, $match_id, $match_status = 0);
  671. return $data;
  672. }
  673. /**
  674. *单式注单重新结算
  675. */
  676. // public function resettlement(Req $req) {
  677. // $id = $req->id;
  678. // if (intval($id) < 1) {
  679. // return -1;
  680. // }
  681. // $order = \App\Models\SportsNoteList::where('id',$id)->first();
  682. // $match_id = $order->match_id;
  683. // $game_code = $order->game_code;
  684. // $order_id = $order->order_id;
  685. // $order_ids = array($order->order_id);
  686. // //return $match_id;
  687. // $bet_type = 1;//单式注单
  688. // //重新判断输赢
  689. // $settlementWinFail = new SettlementWinFail();
  690. // $res = $settlementWinFail->ProcWinInfoByOneOrder($match_id, $order_id, $bet_type);
  691. // //结算
  692. // $SettlementOrder = new SettlementOrder();
  693. // $settype = 2; //重新结算
  694. // $data = $SettlementOrder->reSettlement($order_ids,$bet_type,$settype,$game_code,$match_id,$match_status=0);
  695. // return $data;
  696. // }
  697. public function resettlement(Req $req)
  698. {
  699. $order_id = $req->order_id;
  700. $type = $req->type;
  701. $match_id = $req->match_id;
  702. $jsurl = config('sconstant.url');//结算请求域名地址
  703. $token = session('adminInfo.token');
  704. //查询是否有订单
  705. $newapp = new \App\Models\SportsNoteList();
  706. $simplexnum = $newapp->onlyorder($order_id);
  707. if ($simplexnum == 1) {
  708. $requet = file_get_contents($jsurl . "/DoWinFailOneOrder?order_id=" . $order_id . "&token=" . $token);
  709. if (json_decode($requet, true)['status'] == 1) {
  710. $napp = new \App\Models\Stzqresult();
  711. $simplex = array(
  712. 'token' => $token,
  713. 'order_ids' => $order_id, //订单id字符串,用半角都好分隔
  714. 'bettype' => 1, //结算类型 1单式 2串式
  715. 'settype' => 2, //结算次数 1首次 2非首冷饮
  716. 'game_code' => $type, //赛事类型 zq lq wq bq
  717. 'match_id' => $match_id, // 赛事ID
  718. 'change_status' => 0 //是否改状态
  719. );
  720. $url = $jsurl . '/Settelement';
  721. $simplex_res = $napp->post_curls($url, $simplex);//返回json
  722. $huawei_res = json_decode($simplex_res, true);
  723. if ($huawei_res['status'] == 1) {
  724. return json_encode(['status' => 1, 'msg' => '结算成功']);
  725. } else {
  726. return json_encode(['status' => 4, 'msg' => '结算失败']);
  727. }
  728. } else {
  729. return json_encode(['status' => 3, 'msg' => '输赢判断错误']);
  730. }
  731. } else {
  732. return json_encode(['status' => 2, 'msg' => '订单不存在']);
  733. }
  734. }
  735. /**
  736. *单式注单批量结算
  737. */
  738. public function batchsettlement()
  739. {
  740. $orders = \App\Models\SportsNoteList::where('settle_status', '1')->get();
  741. $order_ids = array();
  742. for ($i = 0; $i < count($orders); $i++) {
  743. $result = \App\Models\MoneyBuyMatch::where('batch_id', $orders[$i]->batch_id)->where('match_id', $orders[$i]->match_id)->get();
  744. $res = array();
  745. for ($j = 0; $j < count($result); $j++) {
  746. $res[] = $result[$j]->result;
  747. }
  748. if (!in_array(0, $res)) {
  749. $order_ids[] = $orders[$i]->order_id;
  750. }
  751. }
  752. $SettlementOrder = new SettlementOrder();
  753. $bet_type = 1;//单式注单
  754. $data = $SettlementOrder->reSettlement($order_ids, $bet_type);
  755. return $data;
  756. }
  757. /**
  758. *删除订单
  759. */
  760. public function delete(Req $req)
  761. {
  762. $id = $req->input('id');
  763. if (empty($id)) {
  764. return responseToJson(-2001); //id
  765. }
  766. $ids = explode(',', $id);
  767. if (!is_array($ids) && intval($ids) < 0) {
  768. return responseToJson(-2002); //id
  769. }
  770. if (is_array($ids) && count($ids) > 0) {
  771. foreach ($ids as $k => $v) {
  772. if (intval($v) < 1) {
  773. unset($ids[$k]);
  774. }
  775. }
  776. }
  777. $rows = \App\Models\SportsNoteList::whereIn('id', $ids)->delete();
  778. if (!$rows) {
  779. return responseToJson(-2003); //id
  780. }
  781. return responseToJson(1, trans('menu.delete_success')); //id
  782. }
  783. /**
  784. * 投注金额统计
  785. */
  786. function moneycount()
  787. {
  788. $where = Request::has('where') ? Request::get('where') : '';
  789. $type = Request::has('type') ? Request::get('type') : 'zq';
  790. $db = new \App\Models\SportsNoteList;
  791. $data = $db->MoneyCount($where, $type);
  792. return responseToJson($data);
  793. }
  794. //单式订单数据
  795. public function manualmatchget(Req $req)
  796. {
  797. $order_id = isset($req->order_id) ? $req->order_id : 0;
  798. $model = new \App\Models\SportsNoteList();
  799. $ret = $model->getorder($order_id);
  800. if ($ret) {
  801. // $league = db('st_'.$ret->game_code.'_league')->where('id',$ret->lg_id)->first();
  802. // $ret->league = $league->name_chinese;
  803. $modelcode = new \App\Models\StoddsCode();
  804. $opcode_nameArr = $modelcode->getTypeDatas($ret->game_code);
  805. $ret = $ret->toArray();
  806. foreach ($ret['matchdatas'] as $key => $val) {
  807. $tmp_pcode = $val['p_code'];
  808. $tmp_code = $val['odds_code'];
  809. $ret['matchdatas'][$key]['odds_name'] = isset($opcode_nameArr[$tmp_pcode][$tmp_code]['odds_name']) ? $opcode_nameArr[$tmp_pcode][$tmp_code]['odds_name'] : '';
  810. }
  811. return responseToJson(1, '成功', $ret);
  812. } else {
  813. return responseToJson(-1, 'false', $ret);
  814. }
  815. }
  816. //单式订单直接手动更改输赢结果并结算
  817. public function manualmatchpdate(Req $req)
  818. {
  819. $order_id = isset($req->order_id) ? $req->order_id : 0;
  820. $datas = isset($req->matchdata) ? $req->matchdata : [];
  821. $datas = json_decode($datas, true);
  822. if (empty($order_id) || empty($datas)) {
  823. return responseToJson(-1, '参数不能为空!');
  824. }
  825. $model = new \App\Models\SportsNoteList();
  826. $modeldata = $model->getorder($order_id);
  827. if (empty($modeldata)) {
  828. return responseToJson(-1, 'false');
  829. }
  830. $sdataArr = [];
  831. foreach ($datas as $val) {
  832. $tmp_id = $val['id'];
  833. $tmp_result = intval($val['result']);
  834. $tmp_matchword = trim($val['matchresult']);
  835. if (!in_array($tmp_result, [-1, 1, 2, 3, 4])) {
  836. continue;
  837. }
  838. $sdataArr[$tmp_id] = ['result' => $tmp_result, 'matchresult' => $tmp_matchword];
  839. }
  840. if (empty($sdataArr)) {
  841. return responseToJson(-2, '没有要更新的数据');
  842. }
  843. $chageNum = 0;
  844. foreach ($modeldata->matchdatas as $key => $val) {
  845. $id = $val->id;
  846. if (isset($sdataArr[$id])) {
  847. if ($val->result != $sdataArr[$id]['result'] || $val->matchwork != $sdataArr[$id]['matchresult']) {
  848. $val->result = $sdataArr[$id]['result'];
  849. $val->matchresult = $sdataArr[$id]['matchresult'];
  850. $val->save();
  851. $chageNum++;
  852. }
  853. }
  854. }
  855. if ($chageNum) {
  856. $modeldata->is_manual = 1;
  857. $modeldata->save();
  858. } else {
  859. return responseToJson(1, '没有更新操作数据!');
  860. }
  861. $data = [
  862. 'token' => session('adminInfo.token'), //外网
  863. 'order_ids' => $modeldata->order_id,
  864. 'bettype' => 1,
  865. 'settype' => 2,
  866. 'game_code' => $modeldata->game_code,
  867. 'match_id' => $modeldata->match_id,
  868. 'change_status' => 0,
  869. 'is_manual' => 1,
  870. ];
  871. $ret = $this->request_post(config('sconstant.url') . '/Settelement', $data);
  872. $retjson = json_decode($ret, true);
  873. if (isset($retjson['status']) && $retjson['status'] == 1) {
  874. $model->where('order_id', $order_id)->update(['settle_status' => 2]);
  875. }
  876. return responseToJson(1, '更新成功');
  877. }
  878. //单式订单直接手动设置比赛结果 --> 提交胜负判断处理以及 --> 提交结算
  879. public function manualmatchpdate_v2(Req $req)
  880. {
  881. $order_id = isset($req->order_id) ? $req->order_id : 0;
  882. $game_code = isset($req->game_code) ? $req->game_code : 0;
  883. $match_id = isset($req->match_id) ? $req->match_id : 0;
  884. $pdatas = isset($req->matchdata) ? $req->matchdata : [];
  885. $pdatas = json_decode($pdatas, true);
  886. if (empty($order_id) || empty($game_code) || empty($match_id) || empty($pdatas)) {
  887. return responseToJson(0, '参数错误');
  888. }
  889. $buyModel = (new MoneyBuySimplexModel())->where([['order_id', '=', $order_id]])->first();
  890. if (empty($buyModel)) {
  891. return responseToJson(0, '订单数据错误');
  892. }
  893. $restModel = '';
  894. switch ($game_code) {
  895. case 'zq':
  896. $restModel = DB::table('st_zq_result')->where([['match_id', '=', $match_id]])->first();
  897. break;
  898. case 'lq':
  899. $restModel = DB::table('st_lq_result')->where([['match_id', '=', $match_id]])->first();
  900. break;
  901. case 'wq':
  902. $restModel = DB::table('st_wq_result')->where([['match_id', '=', $match_id]])->first();
  903. break;
  904. case 'bq':
  905. $restModel = DB::table('st_bq_result')->where([['match_id', '=', $match_id]])->first();
  906. break;
  907. }
  908. if (empty($restModel)) {
  909. return responseToJson(0, '赛事结果记录没有找到,数据错误');
  910. }
  911. if ($game_code == 'zq') {
  912. $home = intval($pdatas['home']);
  913. $guest = intval($pdatas['guest']);
  914. $home_u = intval($pdatas['home_u']);
  915. $guest_u = intval($pdatas['guest_u']);
  916. $restModel->home_score = $home;
  917. $restModel->guest_score = $guest;
  918. $restModel->u_home_score = $home_u;
  919. $restModel->u_guest_score = $guest_u;
  920. $restModel->corner_ball = json_decode($restModel->corner_ball, 256);
  921. $restModel->penalty_card = json_decode($restModel->penalty_card, 256);
  922. $restModel->first_score = json_decode($restModel->first_score, 256);
  923. $restModel->warn_more = json_decode($restModel->warn_more, 256);
  924. $buyModel->single_result = json_encode([$restModel], 256);
  925. $buyModel->result_flag = 1;
  926. $buyModel->is_manual = 1;
  927. $ret = $buyModel->save();
  928. if ($ret) {
  929. $ret2 = $this->do_win_set($order_id, $game_code, $match_id);
  930. if ($ret2['status'] == 1) {
  931. return responseToJson(1, '操作成功!');
  932. } else {
  933. return responseToJson(0, '操作失败2!--' . $ret2['data']);
  934. }
  935. }
  936. return responseToJson(0, '更新失败1');
  937. }
  938. if ($game_code == 'lq') {
  939. $home = $pdatas['home'];
  940. $guest = $pdatas['guest'];
  941. $restModel->home_score = ['1' => intval($home['0']), '2' => intval($home['1']), '3' => intval($home['2']), '4' => intval($home['3'])];
  942. $restModel->guest_score = ['1' => intval($guest['0']), '2' => intval($guest['1']), '3' => intval($guest['2']), '4' => intval($guest['3'])];
  943. $restModel->u_home_score = intval($home['0']) + intval($home['1']);
  944. $restModel->u_guest_score = intval($guest['0']) + intval($guest['1']);
  945. $all_home = intval($home['0']) + intval($home['1']) + intval($home['2']) + intval($home['3']);
  946. $all_guest = intval($guest['0']) + intval($guest['1']) + intval($guest['2']) + intval($guest['3']);
  947. $restModel->all_goal = $all_home + $all_guest;
  948. $restModel->match_score = $all_home . ':' . $all_guest;
  949. $restModel->match_winer = $all_home > $all_guest ? $restModel->home_team : $restModel->guest_team;
  950. $restModel->warn_more = json_decode($restModel->warn_more, 256);
  951. $buyModel->single_result = json_encode([$restModel], 256);
  952. $buyModel->result_flag = 1;
  953. $buyModel->is_manual = 1;
  954. $ret = $buyModel->save();
  955. if ($ret) {
  956. $ret2 = $this->do_win_set($order_id, $game_code, $match_id);
  957. if ($ret2['status'] == 1) {
  958. return responseToJson(1, '操作成功!');
  959. } else {
  960. return responseToJson(0, '操作失败2!--' . $ret2['data']);
  961. }
  962. }
  963. return responseToJson(0, '更新失败1');
  964. }
  965. if ($game_code == 'bq') {
  966. $home = $pdatas['home'];
  967. $guest = $pdatas['guest'];
  968. $home_other = $pdatas['home_other'];
  969. $guest_other = $pdatas['guest_other'];
  970. $arrs = [];
  971. for ($i = 0; $i <= 8; $i++) {
  972. $j = $i + 1;
  973. $arrs[$j] = [
  974. 'home' => intval($home[$i]),
  975. 'guest' => intval($guest[$i]),
  976. ];
  977. }
  978. $arrs['other'] = [
  979. 'home' => intval($home_other),
  980. 'guest' => intval($guest_other),
  981. ];
  982. $restModel->match_score_t = $arrs;
  983. $restModel->warn_more = json_decode($restModel->warn_more, 256);
  984. $buyModel->single_result = json_encode([$restModel], 256);
  985. $buyModel->result_flag = 1;
  986. $buyModel->is_manual = 1;
  987. $ret = $buyModel->save();
  988. if ($ret) {
  989. $ret2 = $this->do_win_set($order_id, $game_code, $match_id);
  990. if ($ret2['status'] == 1) {
  991. return responseToJson(1, '操作成功!');
  992. } else {
  993. return responseToJson(0, '操作失败2!--' . $ret2['data']);
  994. }
  995. }
  996. return responseToJson(0, '更新失败1');
  997. }
  998. if ($game_code == 'wq') {
  999. $home = $pdatas['home'];
  1000. $guest = $pdatas['guest'];
  1001. $arrs = [];
  1002. for ($i = 0; $i <= 4; $i++) {
  1003. $j = $i + 1;
  1004. $arrs[$j] = [
  1005. 'home' => intval($home[$i]),
  1006. 'guest' => intval($guest[$i]),
  1007. ];
  1008. }
  1009. $restModel->inning = $arrs;
  1010. $restModel->warn_more = json_decode($restModel->warn_more, 256);
  1011. $buyModel->single_result = json_encode([$restModel], 256);
  1012. $buyModel->result_flag = 1;
  1013. $buyModel->is_manual = 1;
  1014. $ret = $buyModel->save();
  1015. if ($ret) {
  1016. $ret2 = $this->do_win_set($order_id, $game_code, $match_id);
  1017. if ($ret2['status'] == 1) {
  1018. return responseToJson(1, '操作成功!');
  1019. } else {
  1020. return responseToJson(0, '操作失败2!--' . $ret2['data']);
  1021. }
  1022. }
  1023. return responseToJson(0, '更新失败1');
  1024. }
  1025. return responseToJson(0, '未做更新', ['order_id' => $order_id, 'game_code' => $game_code, 'match_id' => $game_code, 'datas' => $pdatas]);
  1026. }
  1027. //修复比分时用到订单信息及比赛结果数据
  1028. public function manualmatchget_v2(Req $req)
  1029. {
  1030. $order_id = isset($req->order_id) ? $req->order_id : 0;
  1031. $model = new MoneyBuySimplexModel();
  1032. $ret = $model->OrderinfoResult($order_id);
  1033. if ($ret && !empty($ret['result'])) {
  1034. return responseToJson(1, '成功', $ret);
  1035. } else {
  1036. return responseToJson(-1, 'false', $ret);
  1037. }
  1038. }
  1039. //先提交输赢,再结算
  1040. private function do_win_set($order_id, $game_code, $match_id)
  1041. {
  1042. $winret = $this->do_winfail($order_id, $game_code, $match_id);
  1043. if ($winret['status'] == 1) {
  1044. $setret = $this->do_settelement($order_id, $game_code, $match_id);
  1045. if ($setret['status'] == 1) {
  1046. return ['status' => 1, 'msg' => 'success', 'data' => []];
  1047. } else {
  1048. return ['status' => 0, 'msg' => 'failse', 'data' => $setret['msg']];
  1049. }
  1050. } else {
  1051. return ['status' => 0, 'msg' => 'failse', 'data' => $winret['msg']];
  1052. }
  1053. }
  1054. //单订单手动提交输赢计算
  1055. private function do_winfail($order_id, $game_code, $match_id)
  1056. {
  1057. $data = [
  1058. 'token' => session('adminInfo.token'), //外网
  1059. 'order_id' => $order_id,
  1060. ];
  1061. $ret = $this->request_post(config('sconstant.url') . '/DoWinFailOneOrder', $data);
  1062. return json_decode($ret, true);
  1063. }
  1064. //单订单手动提交结算
  1065. private function do_settelement($order_id, $game_code, $match_id)
  1066. {
  1067. $data = [
  1068. 'token' => session('adminInfo.token'), //外网
  1069. 'order_ids' => $order_id,
  1070. 'bettype' => 1,
  1071. 'settype' => 2,
  1072. 'game_code' => $game_code,
  1073. 'match_id' => $match_id,
  1074. 'change_status' => 0,
  1075. 'is_manual' => 1,
  1076. ];
  1077. $ret = $this->request_post(config('sconstant.url') . '/Settelement', $data);
  1078. return json_decode($ret, true);
  1079. }
  1080. private function request_post($url = '', $param = '')
  1081. {
  1082. if (empty($url) || empty($param)) {
  1083. return false;
  1084. }
  1085. $postUrl = $url;
  1086. $curlPost = $param;
  1087. $ch = curl_init();//初始化curl
  1088. curl_setopt($ch, CURLOPT_URL, $postUrl);//抓取指定网页
  1089. curl_setopt($ch, CURLOPT_HEADER, 0);//设置header
  1090. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//要求结果为字符串且输出到屏幕上
  1091. curl_setopt($ch, CURLOPT_POST, 1);//post提交方式
  1092. curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost);
  1093. $data = curl_exec($ch);//运行curl
  1094. curl_close($ch);
  1095. return $data;
  1096. }
  1097. }