SoccerNoteListController.php 52 KB

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