SoccerNoteListController.php 54 KB

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