SoccerNoteListController.php 56 KB

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