SoccerNoteListController.php 78 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832
  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['p_codes'] = isset($req->p_codes) ? trim($req->p_codes) : null;
  36. $request['game_status'] = isset($req->game_status) ? trim($req->game_status) : 0;
  37. $request['type'] = isset($req->type) ? trim($req->type) : 'zq';
  38. $dt = \App\Lib\DataTable\DataTable::init();
  39. $dt->setDataSource('/admin/SoccerNoteList/getinfo');
  40. $dt->setLang('sportsnotelist');
  41. //$dt->addColsFields('id', array('templet' => '#userdetail', 'sort' => true, 'width' => 80));
  42. $dt->addColsFields('match_id_order', array('sort' => true, 'width' => 210, 'minWidth'=>200));
  43. $dt->addColsFields('league', array('templet' => '#userdetail', 'sort' => false, 'width' => 100));
  44. $dt->addColsFields('home_guest', array('templet' => '#userdetail', 'sort' => false, 'width' => 260));
  45. $dt->addColsFields('content', array('templet' => '#userdetail', 'sort' => false, 'width' => 250));
  46. $dt->addColsFields('money', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
  47. $dt->addColsFields('water_return', array('templet' => '#userdetail', 'sort' => false, 'width' => 70));
  48. $dt->addColsFields('prize_money', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
  49. $dt->addColsFields('result', array('templet' => '#userdetail', 'sort' => false, 'width' => 70));
  50. $dt->addColsFields('money_match_time', array('templet' => '#userdetail', 'sort' => false, 'width' => 200));
  51. $dt->addColsFields('order_status', array('sort' => false, 'width' => 80));
  52. $dt->addColsFields('account_money', array('templet' => '#userdetail', 'sort' => false, 'width' => 110));
  53. // $dt->addColsFields('game_status', array('templet' => '#game_status', 'sort' => false, 'width' => 114));
  54. $dt->addColsFields('game_status', array('sort' => false, 'width' => 80));
  55. // $arr[] = 'view';1
  56. // if (checkRriv('/admin/SoccerNoteList/edit')) {
  57. // $arr[] = 'edit';
  58. // }
  59. // $dt->setToolBar($arr, array('width' => 70));
  60. $dt->enableCheckBox();//var_dump($request['type']);
  61. return view('sports/sports_notelist', $dt->render($request));
  62. }
  63. //冠军注单手工结算1
  64. public function championset(Req $req)
  65. {
  66. $request['name_chinese'] = isset($req->name_chinese) ? trim($req->name_chinese) : null;
  67. $request['sureblurs'] = isset($req->sureblurs) ? $req->sureblurs : 'on';
  68. $request['account'] = isset($req->account) ? trim($req->account) : null;
  69. $request['star_time'] = isset($req->star_time) ? trim($req->star_time) : null;
  70. $request['end_time'] = isset($req->end_time) ? trim($req->end_time) : null;
  71. $request['order_id'] = isset($req->order_id) ? trim($req->order_id) : null;
  72. $request['match_id'] = isset($req->match_id) ? trim($req->match_id) : null;
  73. $request['lg_id'] = isset($req->lg_id) ? trim($req->lg_id) : null;//联赛id 用于冠军联赛投注
  74. $request['is_gj'] = isset($req->is_gj) ? trim($req->is_gj) : 1;//是否是冠军联赛投注 0否 1是
  75. $request['status'] = isset($req->status) ? trim($req->status) : '-1';
  76. $request['order_status'] = isset($req->order_status) ? trim($req->order_status) : '-1';
  77. $request['p_codes'] = isset($req->p_codes) ? trim($req->p_codes) : null;
  78. $request['type'] = isset($req->type) ? trim($req->type) : 'zq';
  79. $dt = \App\Lib\DataTable\DataTable::init();
  80. $dt->setDataSource('/admin/SoccerNoteList/championsetinfo');
  81. $dt->setLang('sportsnotelist');
  82. //$dt->addColsFields('id', array('templet' => '#userdetail', 'sort' => true, 'width' => 80));
  83. $dt->addColsFields('lg_id_order', array('sort' => true, 'width' => 210, 'minWidth' => 200));
  84. $dt->addColsFields('league', array('templet' => '#userdetail', 'sort' => false, 'width' => 100));
  85. $dt->addColsFields('home_guest', array('templet' => '#userdetail', 'sort' => false, 'width' => 260));
  86. $dt->addColsFields('content', array('templet' => '#userdetail', 'sort' => false, 'width' => 250));
  87. $dt->addColsFields('money', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
  88. $dt->addColsFields('water_return', array('templet' => '#userdetail', 'sort' => false, 'width' => 70));
  89. $dt->addColsFields('prize_money', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
  90. $dt->addColsFields('result', array('templet' => '#userdetail', 'sort' => false, 'width' => 70));
  91. $dt->addColsFields('money_match_time', array('templet' => '#userdetail', 'sort' => false, 'width' => 200));
  92. $dt->addColsFields('order_status', array('sort' => false, 'width' => 80));
  93. $dt->addColsFields('account_money', array('templet' => '#userdetail', 'sort' => false, 'width' => 110));
  94. // $dt->addColsFields('game_status', array('templet' => '#game_status', 'sort' => false, 'width' => 114));
  95. $dt->addColsFields('game_status', array( 'sort' => false, 'width' => 114));
  96. //$arr[] = 'view';
  97. // if (checkRriv('/admin/SoccerNoteList/edit')) {
  98. // $arr[] = 'edit';
  99. // }
  100. // $dt->setToolBar($arr, array('width' => 70));
  101. $dt->enableCheckBox();//var_dump($request['type']);
  102. return view('sports/sports_notelist', $dt->render($request));
  103. }
  104. function championsetinfo()
  105. {
  106. $page = Request::has('page') ? Request::get('page') : '';
  107. $list = Request::has('limit') ? Request::get('limit') : 10;
  108. $account = Request::get('account') ? Request::get('account') : '';
  109. $star_time = Request::get('star_time') ? Request::get('star_time') . ' 00:00:00' : '';
  110. $end_time = Request::get('end_time') ? Request::get('end_time') . ' 23:59:59' : '';
  111. $order_id = Request::get('order_id') ? Request::get('order_id') : '';
  112. $match_id = Request::get('match_id') ? Request::get('match_id') : '';
  113. $lg_id = Request::get('lg_id') ? Request::get('lg_id') : '';
  114. $status = Request::has('status') ? Request::get('status') : '-1';
  115. $order_status = Request::has('order_status') ? Request::get('order_status') : '';
  116. $p_codes = Request::has('p_codes') ? Request::get('p_codes') : '';
  117. $sureblur = Request::has('sureblurs') ? Request::get('sureblurs') : 'off';
  118. $type = Request::has('type') ? Request::get('type') : 'zq';
  119. $where = array();
  120. $where[] = array('money_buy_simplex.is_champion', 1);
  121. if (!empty($account)) {
  122. if (empty($sureblur) || $sureblur == 'off') {
  123. $where[] = array('money_buy_simplex.account_name', 'like', '%' . $account . '%');
  124. } else {
  125. $where[] = array('money_buy_simplex.account_name', '=', $account);
  126. }
  127. }
  128. if (!empty($star_time)) {
  129. if (!empty($end_time)) {
  130. $where[] = array('money_buy_simplex.money_time', '>', $star_time);
  131. $where[] = array('money_buy_simplex.money_time', '<', $end_time);
  132. } else {
  133. $where[] = array('money_buy_simplex.money_time', '>', $star_time);
  134. }
  135. } else if (empty($star_time)) {
  136. if (!empty($end_time)) {
  137. $where[] = array('money_buy_simplex.money_time', '<', $end_time);
  138. }
  139. }
  140. if (!empty($order_id)) {
  141. $where[] = array('money_buy_simplex.order_id', $order_id);
  142. }
  143. if (!empty($match_id)) {
  144. $where[] = array('money_buy_simplex.match_id', $match_id);
  145. }
  146. if (!empty($p_codes)) {
  147. $where[] = array('money_buy_match.p_code', $p_codes);
  148. }
  149. //调整状态查询 1,2,3为订单状态 1投注 2作废 3撤单
  150. if ($order_status == 1 || $order_status == 2 || $order_status == 3) {
  151. $where[] = array('money_buy_simplex.status', '=', $order_status);
  152. }
  153. //4 5为结算状态 4未结算 5已结算
  154. if ($order_status == 4) {
  155. $status = 1;
  156. $where[] = array('money_buy_simplex.status', '=',1);
  157. $where[] = array('money_buy_simplex.settle_status', '=', $status);
  158. }
  159. if ($order_status == 5) {
  160. $status = 2;
  161. $where[] = array('money_buy_simplex.status', '=',1);
  162. $where[] = array('money_buy_simplex.settle_status', '=', $status);
  163. }
  164. //10进球无效 11红卡无效
  165. if ($order_status == 10) {
  166. $use_mark = '进球无效';
  167. $where[] = array('money_buy_simplex.status', '=',1);
  168. $where[] = array('money_buy_simplex.use_mark', '=', $use_mark);
  169. }
  170. if ($order_status == 11) {
  171. $use_mark = '红卡无效';
  172. $where[] = array('money_buy_simplex.status', '=',1);
  173. $where[] = array('money_buy_simplex.use_mark', '=', $use_mark);
  174. }
  175. //6 7 8 9 12 为输赢 6赢 7输 8赢一半 9输一半 12和局
  176. if ($order_status == 6) {
  177. $result = 1;
  178. $where[] = array('money_buy_simplex.status', '=',1);
  179. $where[] = array('money_buy_match.result', '=', $result);
  180. }
  181. if ($order_status == 7) {
  182. $result = -1;
  183. $where[] = array('money_buy_simplex.status', '=',1);
  184. $where[] = array('money_buy_match.result', '=', $result);
  185. }
  186. if ($order_status == 8) {
  187. $result = 3;
  188. $where[] = array('money_buy_simplex.status', '=',1);
  189. $where[] = array('money_buy_match.result', '=', $result);
  190. }
  191. if ($order_status == 9) {
  192. $result = 4;
  193. $where[] = array('money_buy_simplex.status', '=',1);
  194. $where[] = array('money_buy_match.result', '=', $result);
  195. }
  196. if ($order_status == 12) {
  197. $result = 2;
  198. $where[] = array('money_buy_simplex.status', '=',1);
  199. $where[] = array('money_buy_match.result', '=', $result);
  200. }
  201. if(!empty($lg_id)){
  202. $where[] = array('money_buy_simplex.lg_id', $lg_id);
  203. }
  204. if ($status != -1) {
  205. $where[] = array('money_buy_simplex.settle_status', '=', $status);
  206. }
  207. if ($order_status != -1) {
  208. $where[] = array('money_buy_simplex.status', '=', $order_status);
  209. }
  210. $where[] = array('money_buy_simplex.game_code', $type);
  211. $newapp = new \App\Models\SportsNoteList();
  212. $data = $newapp->getinfo($list, $page, $where, $type);
  213. //$alldata = Models\MoneyBuyMatch::where('bet_type',1)->where('is_rolling',1)->distinct('order_id')->count('order_id');
  214. return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total'], 0, $where);
  215. }
  216. //修改冠军单订单结果
  217. function orderupgj(Req $req)
  218. {
  219. $id = $req->id;//37
  220. $orderid = $req->order;//S20190916094723915270970
  221. if (intval($id) < 1) {
  222. return -1;
  223. }
  224. $data = \App\Models\SoccerLeague::where('id', $id)->first();
  225. $odds_code = \App\Models\SoccerOdds::where('lg_id', $id)->where('type', 1)->where('odds_code', '!=', '')->select('odds_code')->distinct()->get()->toArray();//赔率表
  226. for ($i = 0; $i < count($odds_code); $i++) {
  227. $allteam[] = \App\Models\SoccerOdds::where('odds_code', $odds_code[$i]['odds_code'])->where('lg_id', $id)->where('type', 1)->select('team')->distinct()->get()->toArray();
  228. }
  229. $data = $data->toArray();
  230. $isdisplay = \App\Models\Stwqleagueresult::where(['lg_id' => $id, 'status' => 1])->select("game_name")->distinct()->get()->toArray();
  231. $idisplay = array_column($isdisplay, 'game_name');
  232. $displays = implode(",", $idisplay);//转换成字符串
  233. //新增纪录
  234. foreach ($odds_code as $k => $v) {
  235. foreach ($allteam[$k] as $kk => $vv) {
  236. $name = $v['odds_code'];
  237. $isteam = $allteam[$k][$kk]['team'];
  238. $res = \App\Models\Stwqleagueresult::where(['lg_id' => $id, 'game_name' => $name, 'result' => $isteam])->first();
  239. $addresult = [
  240. 'lg_id' => $id,
  241. 'game_name' => $name,
  242. 'result' => $isteam,
  243. 'ctime' => date('Y-m-d H:i:s', time()),
  244. 'status' => 0,
  245. 'updated_at' => date('Y-m-d H:i:s', time()),
  246. ];
  247. if (empty($res)) {
  248. \App\Models\Stwqleagueresult::insert($addresult);
  249. }
  250. }
  251. }
  252. $orderjg = \App\Models\SportsNoteList::where(['order_id' => $orderid])->select("single_result")->first();
  253. $orderjg = json_decode($orderjg['single_result'], true);
  254. $data['allteam'] = $allteam;
  255. $data['odds_code'] = $odds_code;
  256. $data['displays'] = $displays;
  257. $data['isdisplay'] = $isdisplay;
  258. $data['orderjg'] = $orderjg;
  259. $data['orderid'] = $orderid;
  260. $data['lg_id'] = $id;
  261. return view('sports/orderupgj', $data);
  262. }
  263. //修改冠军单订单结果提交
  264. function ajaxtj(Req $req)
  265. {
  266. $isstatus = $req->isstatus;//更新
  267. $order = $req->order;
  268. if ($isstatus) {
  269. $gjresult = array(
  270. 'lg_id' => $req->lg_id ? $req->lg_id : '',
  271. 'game_name' => $req->odds_code ? $req->odds_code : '',
  272. 'result' => $req->team ? $req->team : '',
  273. 'updatetime' => date("Y-m-d H:i:s", time()),
  274. );
  275. } else {
  276. $gjresult = array(
  277. 'lg_id' => '',
  278. 'game_name' => '',
  279. 'result' => '',
  280. );
  281. }
  282. \App\Models\SportsNoteList::where(['order_id' => $order])->update(['single_result' => json_encode($gjresult, JSON_UNESCAPED_UNICODE)]);
  283. return responseToJson(1);
  284. }
  285. function info()
  286. {
  287. $page = Request::has('page') ? Request::get('page') : '';
  288. $list = Request::has('limit') ? Request::get('limit') : 10;
  289. $account = Request::get('account') ? Request::get('account') : '';
  290. $star_time = Request::get('star_time') ? Request::get('star_time') . ' 00:00:00' : '';
  291. $end_time = Request::get('end_time') ? Request::get('end_time') . ' 23:59:59' : '';
  292. $order_id = Request::get('order_id') ? Request::get('order_id') : '';
  293. $match_id = Request::get('match_id') ? Request::get('match_id') : '';
  294. // $status = Request::has('status') ? Request::get('status') : '';
  295. $order_status = Request::has('order_status') ? Request::get('order_status') : '';
  296. $p_codes = Request::has('p_codes') ? Request::get('p_codes') : '';
  297. $sureblur = Request::has('sureblurs') ? Request::get('sureblurs') : 'off';
  298. $type = Request::has('type') ? Request::get('type') : 'zq';
  299. $where = array();
  300. $where[] = array('money_buy_simplex.is_champion', '<>', 1);
  301. if (!empty($account)) {
  302. if (empty($sureblur) || $sureblur == 'off') {
  303. $where[] = array('money_buy_simplex.account_name', 'like', '%' . $account . '%');
  304. } else {
  305. $where[] = array('money_buy_simplex.account_name', '=', $account);
  306. }
  307. }
  308. if (!empty($star_time)) {
  309. if (!empty($end_time)) {
  310. $where[] = array('money_buy_simplex.money_time', '>', $star_time);
  311. $where[] = array('money_buy_simplex.money_time', '<', $end_time);
  312. } else {
  313. $where[] = array('money_buy_simplex.money_time', '>', $star_time);
  314. }
  315. } else if (empty($star_time)) {
  316. if (!empty($end_time)) {
  317. $where[] = array('money_buy_simplex.money_time', '<', $end_time);
  318. }
  319. }
  320. if (!empty($order_id)) {
  321. $where[] = array('money_buy_simplex.order_id', $order_id);
  322. }
  323. if (!empty($match_id)) {
  324. $where[] = array('money_buy_simplex.match_id', $match_id);
  325. }
  326. if (!empty($p_codes)) {
  327. $where[] = array('money_buy_match.p_code', $p_codes);
  328. }
  329. //调整状态查询 1,2,3为订单状态 1投注 2作废 3撤单
  330. if ($order_status == 1 || $order_status == 2 || $order_status == 3) {
  331. $where[] = array('money_buy_simplex.status', '=', $order_status);
  332. }
  333. //4 5为结算状态 4未结算 5已结算
  334. if ($order_status == 4) {
  335. $status = 1;
  336. $where[] = array('money_buy_simplex.status', '=',1);
  337. $where[] = array('money_buy_simplex.settle_status', '=', $status);
  338. }
  339. if ($order_status == 5) {
  340. $status = 2;
  341. $where[] = array('money_buy_simplex.status', '=',1);
  342. $where[] = array('money_buy_simplex.settle_status', '=', $status);
  343. }
  344. //10进球无效 11红卡无效
  345. if ($order_status == 10) {
  346. $use_mark = '进球无效';
  347. $where[] = array('money_buy_simplex.status', '=',1);
  348. $where[] = array('money_buy_simplex.use_mark', '=', $use_mark);
  349. }
  350. if ($order_status == 11) {
  351. $use_mark = '红卡无效';
  352. $where[] = array('money_buy_simplex.status', '=',1);
  353. $where[] = array('money_buy_simplex.use_mark', '=', $use_mark);
  354. }
  355. //6 7 8 9 12 为输赢 6赢 7输 8赢一半 9输一半 12和局
  356. if ($order_status == 6) {
  357. $result = 1;
  358. $where[] = array('money_buy_simplex.status', '=',1);
  359. $where[] = array('money_buy_match.result', '=', $result);
  360. }
  361. if ($order_status == 7) {
  362. $result = -1;
  363. $where[] = array('money_buy_simplex.status', '=',1);
  364. $where[] = array('money_buy_match.result', '=', $result);
  365. }
  366. if ($order_status == 8) {
  367. $result = 3;
  368. $where[] = array('money_buy_simplex.status', '=',1);
  369. $where[] = array('money_buy_match.result', '=', $result);
  370. }
  371. if ($order_status == 9) {
  372. $result = 4;
  373. $where[] = array('money_buy_simplex.status', '=',1);
  374. $where[] = array('money_buy_match.result', '=', $result);
  375. }
  376. if ($order_status == 12) {
  377. $result = 2;
  378. $where[] = array('money_buy_simplex.status', '=',1);
  379. $where[] = array('money_buy_match.result', '=', $result);
  380. }
  381. /*
  382. if ($status != -1) {
  383. $where[] = array('money_buy_simplex.settle_status', '=', $status);
  384. }
  385. if ($order_status != -1) {
  386. $where[] = array('money_buy_simplex.status', '=', $order_status);
  387. }
  388. */
  389. $where[] = array('money_buy_simplex.game_code', $type);
  390. $newapp = new \App\Models\SportsNoteList();
  391. $data = $newapp->getinfo($list, $page, $where, $type);
  392. return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total'], 0, $where);
  393. }
  394. public function search(Req $req)
  395. {
  396. $request['name_chinese'] = isset($req->name_chinese) ? trim($req->name_chinese) : null;
  397. $request['sureblurs'] = isset($req->sureblurs) ? $req->sureblurs : 'on';
  398. $request['account'] = isset($req->account) ? trim($req->account) : null;
  399. $request['star_time'] = isset($req->star_time) ? trim($req->star_time) : null;
  400. $request['end_time'] = isset($req->end_time) ? trim($req->end_time) : null;
  401. $request['order_id'] = isset($req->order_id) ? trim($req->order_id) : null;
  402. $request['match_id'] = isset($req->match_id) ? trim($req->match_id) : null;
  403. $request['lg_id'] = isset($req->lg_id) ? trim($req->lg_id) : null;//联赛id 用于冠军联赛投注
  404. $request['is_gj'] = isset($req->is_gj) ? trim($req->is_gj) : 0;//是否是冠军联赛投注 0否 1是
  405. $request['status'] = isset($req->status) ? trim($req->status) : '-1';
  406. $request['order_status'] = isset($req->order_status) ? trim($req->order_status) : '-1';
  407. $request['p_codes'] = isset($req->p_codes) ? trim($req->p_codes) : null;
  408. $request['type'] = isset($req->type) ? trim($req->type) : 'zq';
  409. $dt = \App\Lib\DataTable\DataTable::init();
  410. $dt->setDataSource('/admin/SoccerNoteList/info');
  411. $dt->setLang('sportsnotelist');
  412. //$dt->addColsFields('id', array('templet' => '#userdetail', 'sort' => true, 'width' => 80));
  413. $dt->addColsFields('match_id_order', array('sort' => true, 'width' => 210, 'minWidth'=>200));
  414. $dt->addColsFields('league', array('templet' => '#userdetail', 'sort' => false, 'width' => 100));
  415. $dt->addColsFields('home_guest', array('templet' => '#userdetail', 'sort' => false, 'width' => 260));
  416. $dt->addColsFields('content', array('templet' => '#userdetail', 'sort' => false, 'width' => 250));
  417. $dt->addColsFields('money', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
  418. $dt->addColsFields('water_return', array('templet' => '#userdetail', 'sort' => false, 'width' => 70));
  419. $dt->addColsFields('prize_money', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
  420. $dt->addColsFields('result', array('templet' => '#userdetail', 'sort' => false, 'width' => 70));
  421. $dt->addColsFields('money_match_time', array('templet' => '#userdetail', 'sort' => false, 'width' => 200));
  422. $dt->addColsFields('order_status', array('sort' => false, 'width' => 80));
  423. $dt->addColsFields('account_money', array('templet' => '#userdetail', 'sort' => false, 'width' => 110));
  424. // $dt->addColsFields('settle_status', array('sort' => false, 'width' => 90));
  425. //$arr[] = 'view';
  426. // if (checkRriv('/admin/SoccerNoteList/edit')) {
  427. // $arr[] = 'edit';
  428. // }
  429. // $dt->setToolBar($arr, array('width' => 70));
  430. $dt->enableCheckBox();
  431. return view('sports/sports_search', $dt->render($request));
  432. }
  433. //冠军注单
  434. public function champion(Req $req)
  435. {
  436. $request['name_chinese'] = isset($req->name_chinese) ? trim($req->name_chinese) : null;
  437. $request['sureblurs'] = isset($req->sureblurs) ? $req->sureblurs : 'on';
  438. $request['account'] = isset($req->account) ? trim($req->account) : null;
  439. $request['star_time'] = isset($req->star_time) ? trim($req->star_time) : null;
  440. $request['end_time'] = isset($req->end_time) ? trim($req->end_time) : null;
  441. $request['order_id'] = isset($req->order_id) ? trim($req->order_id) : null;
  442. $request['match_id'] = isset($req->match_id) ? trim($req->match_id) : null;
  443. $request['lg_id'] = isset($req->lg_id) ? trim($req->lg_id) : null;//联赛id 用于冠军联赛投注
  444. $request['is_gj'] = isset($req->is_gj) ? trim($req->is_gj) : 1;//是否是冠军联赛投注 0否 1是
  445. $request['status'] = isset($req->status) ? trim($req->status) : '-1';
  446. $request['order_status'] = isset($req->order_status) ? trim($req->order_status) : '-1';
  447. $request['p_codes'] = isset($req->p_codes) ? trim($req->p_codes) : null;
  448. $request['type'] = isset($req->type) ? trim($req->type) : 'zq';
  449. $dt = \App\Lib\DataTable\DataTable::init();
  450. $dt->setDataSource('/admin/SoccerNoteList/championinfo');
  451. $dt->setLang('sportsnotelist');
  452. //$dt->addColsFields('id', array('templet' => '#userdetail', 'sort' => true, 'width' => 80));
  453. $dt->addColsFields('lg_id_order', array('sort' => true, 'width' => 210, 'minWidth' => 200));
  454. $dt->addColsFields('league', array('templet' => '#userdetail', 'sort' => false, 'width' => 100));
  455. $dt->addColsFields('home_guest', array('templet' => '#userdetail', 'sort' => false, 'width' => 260));
  456. $dt->addColsFields('content', array('templet' => '#userdetail', 'sort' => false, 'width' => 250));
  457. $dt->addColsFields('money', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
  458. $dt->addColsFields('water_return', array('templet' => '#userdetail', 'sort' => false, 'width' => 70));
  459. $dt->addColsFields('prize_money', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
  460. $dt->addColsFields('result', array('templet' => '#userdetail', 'sort' => false, 'width' => 70));
  461. $dt->addColsFields('money_match_time', array('templet' => '#userdetail', 'sort' => false, 'width' => 200));
  462. $dt->addColsFields('order_status', array('sort' => false, 'width' => 80));
  463. $dt->addColsFields('account_money', array('templet' => '#userdetail', 'sort' => false, 'width' => 110));
  464. // $dt->addColsFields('game_status', array('sort' => false, 'width' => 90));
  465. //$arr[] = 'view';
  466. // if (checkRriv('/admin/SoccerNoteList/edit')) {
  467. // $arr[] = 'edit';
  468. // }
  469. // $dt->setToolBar($arr, array('width' => 70));
  470. $dt->enableCheckBox();
  471. return view('sports/sports_search', $dt->render($request));
  472. }
  473. function championinfo()
  474. {
  475. $page = Request::has('page') ? Request::get('page') : '';
  476. $list = Request::has('limit') ? Request::get('limit') : 10;
  477. $account = Request::get('account') ? Request::get('account') : '';
  478. $star_time = Request::get('star_time') ? Request::get('star_time') . ' 00:00:00' : '';
  479. $end_time = Request::get('end_time') ? Request::get('end_time') . ' 23:59:59' : '';
  480. $order_id = Request::get('order_id') ? Request::get('order_id') : '';
  481. $match_id = Request::get('match_id') ? Request::get('match_id') : '';
  482. $lg_id = Request::get('lg_id') ? Request::get('lg_id') : '';
  483. $status = Request::has('status') ? Request::get('status') : '';
  484. $order_status = Request::has('order_status') ? Request::get('order_status') : '';
  485. $p_codes = Request::has('p_codes') ? Request::get('p_codes') : '';
  486. $sureblur = Request::has('sureblurs') ? Request::get('sureblurs') : 'off';
  487. $type = Request::has('type') ? Request::get('type') : 'zq';
  488. $where = array();
  489. $where[] = array('money_buy_simplex.is_champion', 1);
  490. if (!empty($account)) {
  491. if (empty($sureblur) || $sureblur == 'off') {
  492. $where[] = array('money_buy_simplex.account_name', 'like', '%' . $account . '%');
  493. } else {
  494. $where[] = array('money_buy_simplex.account_name', '=', $account);
  495. }
  496. }
  497. if (!empty($star_time)) {
  498. if (!empty($end_time)) {
  499. $where[] = array('money_buy_simplex.money_time', '>', $star_time);
  500. $where[] = array('money_buy_simplex.money_time', '<', $end_time);
  501. } else {
  502. $where[] = array('money_buy_simplex.money_time', '>', $star_time);
  503. }
  504. } else if (empty($star_time)) {
  505. if (!empty($end_time)) {
  506. $where[] = array('money_buy_simplex.money_time', '<', $end_time);
  507. }
  508. }
  509. if (!empty($order_id)) {
  510. $where[] = array('money_buy_simplex.order_id', $order_id);
  511. }
  512. if (!empty($match_id)) {
  513. $where[] = array('money_buy_simplex.match_id', $match_id);
  514. }
  515. if(!empty($lg_id)){
  516. $where[] = array('money_buy_simplex.lg_id', $lg_id);
  517. }
  518. if (!empty($p_codes)) {
  519. $where[] = array('money_buy_match.p_code', $p_codes);
  520. }
  521. //调整状态查询 1,2,3为订单状态 1投注 2作废 3撤单
  522. if ($order_status == 1 || $order_status == 2 || $order_status == 3) {
  523. $where[] = array('money_buy_simplex.status', '=', $order_status);
  524. }
  525. //4 5为结算状态 4未结算 5已结算
  526. if ($order_status == 4) {
  527. $status = 1;
  528. $where[] = array('money_buy_simplex.settle_status', '=', $status);
  529. }
  530. if ($order_status == 5) {
  531. $status = 2;
  532. $where[] = array('money_buy_simplex.settle_status', '=', $status);
  533. }
  534. //10进球无效 11红卡无效
  535. if ($order_status == 10) {
  536. $use_mark = '进球无效';
  537. $where[] = array('money_buy_simplex.status', '=',1);
  538. $where[] = array('money_buy_simplex.use_mark', '=', $use_mark);
  539. }
  540. if ($order_status == 11) {
  541. $use_mark = '红卡无效';
  542. $where[] = array('money_buy_simplex.status', '=',1);
  543. $where[] = array('money_buy_simplex.use_mark', '=', $use_mark);
  544. }
  545. //6 7 8 9 12 为输赢 6赢 7输 8赢一半 9输一半 12和局
  546. if ($order_status == 6) {
  547. $result = 1;
  548. $where[] = array('money_buy_simplex.status', '=',1);
  549. $where[] = array('money_buy_match.result', '=', $result);
  550. }
  551. if ($order_status == 7) {
  552. $result = -1;
  553. $where[] = array('money_buy_simplex.status', '=',1);
  554. $where[] = array('money_buy_match.result', '=', $result);
  555. }
  556. if ($order_status == 8) {
  557. $result = 3;
  558. $where[] = array('money_buy_simplex.status', '=',1);
  559. $where[] = array('money_buy_match.result', '=', $result);
  560. }
  561. if ($order_status == 9) {
  562. $result = 4;
  563. $where[] = array('money_buy_simplex.status', '=',1);
  564. $where[] = array('money_buy_match.result', '=', $result);
  565. }
  566. if ($order_status == 12) {
  567. $result = 2;
  568. $where[] = array('money_buy_simplex.status', '=',1);
  569. $where[] = array('money_buy_match.result', '=', $result);
  570. }
  571. /*
  572. if ($status != -1) {
  573. $where[] = array('money_buy_simplex.settle_status', '=', $status);
  574. }
  575. if ($order_status != -1) {
  576. $where[] = array('money_buy_simplex.status', '=', $order_status);
  577. }
  578. */
  579. $where[] = array('money_buy_simplex.game_code', $type);
  580. $newapp = new \App\Models\SportsNoteList();
  581. $data = $newapp->getinfo($list, $page, $where, $type);
  582. return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total'], 0, $where);
  583. }
  584. //查询赛事结果
  585. // function Sairesult(Req $req){
  586. // $did = $req->did;
  587. // $qlgame = $req->qlgame?$req->qlgame:'zq';
  588. // $newapp = \App\Models\SportsNoteList::where('id', $did)->first();
  589. // if($qlgame=='zq'){
  590. // if($newapp['match_id']){
  591. // $newre = new \App\Models\Stzqresult();
  592. // $teamname = $newre->matchjg($newapp['match_id']);
  593. // }else{
  594. // $teamname ='';
  595. // }
  596. // }elseif($qlgame=='lq'){
  597. // if($newapp['match_id']){
  598. // $newre = new \App\Models\Stlqresult();
  599. // $teamname = $newre->matchjg($newapp['match_id']);
  600. // }else{
  601. // $teamname ='';
  602. // }
  603. // }elseif($qlgame=='bq'){
  604. // if($newapp['match_id']){
  605. // $newre = new \App\Models\Stbqresult();
  606. // $teamname = $newre->matchjg($newapp['match_id']);
  607. // }else{
  608. // $teamname ='';
  609. // }
  610. // }elseif($qlgame=='wq'){
  611. // if($newapp['match_id']){
  612. // $newre = new \App\Models\Stwqresult();
  613. // $teamname = $newre->matchjg($newapp['match_id']);
  614. // }else{
  615. // $teamname ='';
  616. // }
  617. // }else{
  618. // $data = "参数错误";
  619. // }
  620. // $data =array(
  621. // 'singleresult' => json_decode($newapp['single_result'],true),
  622. // 'teamname' => $teamname,
  623. // );
  624. // return $data;
  625. // }
  626. // function Sairesult(Req $req){
  627. // $did = $req->did;
  628. // $model = \App\Models\SportsNoteList::where('id', $did)->first();
  629. // $pid = $model['match_id'];
  630. // $saisjg = \App\Models\Stzqresult::where('match_id',$pid)->first()->toArray();//赛事结果
  631. // $saisjg['corner_ball'] = json_decode($saisjg['corner_ball'],true);
  632. // $saisjg['first_score'] = json_decode($saisjg['first_score'],true);
  633. // $saisjg['penalty_card'] = json_decode($saisjg['penalty_card'],true);
  634. // $saisjg['warn_more'] = json_decode($saisjg['warn_more'],true);
  635. // }
  636. //结果添加
  637. function addend(Req $req)
  638. {
  639. $did = $req->did;//59;//
  640. $qlgame = $req->qlgame;//1;
  641. $model = \App\Models\SportsNoteList::where('id', $did)->first();
  642. $pid = $model['match_id'];
  643. if ($qlgame == 1) {
  644. if ($model['result_flag'] != 1) {
  645. $saisjg = \App\Models\Stzqresult::where('match_id', $pid)->first()->toArray();//赛事结果
  646. $saisjg['corner_ball'] = json_decode($saisjg['corner_ball'], true);
  647. $saisjg['first_score'] = json_decode($saisjg['first_score'], true);
  648. $saisjg['penalty_card'] = json_decode($saisjg['penalty_card'], true);
  649. $saisjg['warn_more'] = json_decode($saisjg['warn_more'], true);
  650. $model->single_result = json_encode([$saisjg], JSON_UNESCAPED_UNICODE);
  651. $model->save();
  652. }
  653. $newm = \App\Models\SportsNoteList::where('id', $did)->first();
  654. return $newm['single_result'];
  655. } else {
  656. $new = \App\Models\SportsNoteList::where('id', $did)->first();
  657. $newa = json_decode($new['single_result'], true);
  658. $newa[0]['home_score'] = $req->home_score;//主队进球
  659. $newa[0]['guest_score'] = $req->guest_score;//客队进球
  660. $newa[0]['all_goal'] = intval($req->guest_score) + intval($req->home_score);//总进球
  661. $newa[0]['last_score'] = $req->lastscore ? $req->lastscore : '';//最后进球球队
  662. $newa[0]['match_winer'] = $req->matchwiner ? $req->matchwiner : '';//赢球球队
  663. $newa[0]['update_time'] = time();//更新时间
  664. $newa[0]['u_guest_score'] = $req->u_guest_score;//上半场-主队进球数
  665. $newa[0]['u_home_score'] = $req->u_home_score;//上半场-客队进球数
  666. $newa[0]['penalty_card'] = array(
  667. 'home' => $req->homeallcard,
  668. 'guest' => $req->guestallcard,
  669. 'home_half' => $req->homehalfcard,
  670. 'guest_half' => $req->guesthalfcard,
  671. );
  672. $newa[0]['corner_ball'] = array(
  673. 'home' => $req->homeallcorner,
  674. 'guest' => $req->guestallcorner,
  675. 'home_half' => $req->homehalfcorner,
  676. 'guest_half' => $req->guesthalfcorner,
  677. );
  678. //最新进球
  679. $newa[0]['first_score'] = array(
  680. 'teamscore' => $req->firstscore ? $req->firstscore : 0,//最先进球球队
  681. 'scoretime' => $req->onescoretime ? $req->onescoretime : '',//进球时间
  682. 'scoretype' => $req->firststye ? $req->firststye : '',//进球方式
  683. );
  684. $model->single_result = json_encode($newa, JSON_UNESCAPED_UNICODE);
  685. $model->result_flag = 1;
  686. $model->save();
  687. return responseToJson(1);
  688. }
  689. }
  690. function getinfo()
  691. {
  692. $page = Request::has('page') ? Request::get('page') : '';
  693. $list = Request::has('limit') ? Request::get('limit') : 10;
  694. $account = Request::get('account') ? Request::get('account') : '';
  695. $star_time = Request::get('star_time') ? Request::get('star_time') . ' 00:00:00' : '';
  696. $end_time = Request::get('end_time') ? Request::get('end_time') . ' 23:59:59' : '';
  697. $order_id = Request::get('order_id') ? Request::get('order_id') : '';
  698. $match_id = Request::get('match_id') ? Request::get('match_id') : '';
  699. $status = Request::has('status') ? Request::get('status') : '-1';
  700. $order_status = Request::has('order_status') ? Request::get('order_status') : '';
  701. $p_codes = Request::has('p_codes') ? Request::get('p_codes') : '';
  702. $sureblur = Request::has('sureblurs') ? Request::get('sureblurs') : 'off';
  703. $type = Request::has('type') ? Request::get('type') : 'zq';
  704. $where = array();
  705. $where[] = array('money_buy_simplex.is_champion', '<>', 1);
  706. if (!empty($account)) {
  707. if (empty($sureblur) || $sureblur == 'off') {
  708. $where[] = array('money_buy_simplex.account_name', 'like', '%' . $account . '%');
  709. } else {
  710. $where[] = array('money_buy_simplex.account_name', '=', $account);
  711. }
  712. }
  713. if (!empty($star_time)) {
  714. if (!empty($end_time)) {
  715. $where[] = array('money_buy_simplex.money_time', '>', $star_time);
  716. $where[] = array('money_buy_simplex.money_time', '<', $end_time);
  717. } else {
  718. $where[] = array('money_buy_simplex.money_time', '>', $star_time);
  719. }
  720. } else if (empty($star_time)) {
  721. if (!empty($end_time)) {
  722. $where[] = array('money_buy_simplex.money_time', '<', $end_time);
  723. }
  724. }
  725. if (!empty($order_id)) {
  726. $where[] = array('money_buy_simplex.order_id', $order_id);
  727. }
  728. if (!empty($match_id)) {
  729. $where[] = array('money_buy_simplex.match_id', $match_id);
  730. }
  731. if (!empty($p_codes)) {
  732. $where[] = array('money_buy_match.p_code', $p_codes);
  733. }
  734. //调整状态查询 1,2,3为订单状态 1投注 2作废 3撤单
  735. if ($order_status == 1 || $order_status == 2 || $order_status == 3) {
  736. $where[] = array('money_buy_simplex.status', '=', $order_status);
  737. }
  738. //4 5为结算状态 4未结算 5已结算
  739. if ($order_status == 4) {
  740. $status = 1;
  741. $where[] = array('money_buy_simplex.status', '=',1);
  742. $where[] = array('money_buy_simplex.settle_status', '=', $status);
  743. }
  744. if ($order_status == 5) {
  745. $status = 2;
  746. $where[] = array('money_buy_simplex.status', '=', 1);
  747. $where[] = array('money_buy_simplex.settle_status', '=', $status);
  748. }
  749. //10进球无效 11红卡无效
  750. if ($order_status == 10) {
  751. $use_mark = '进球无效';
  752. $where[] = array('money_buy_simplex.status', '=',1);
  753. $where[] = array('money_buy_simplex.use_mark', '=', $use_mark);
  754. }
  755. if ($order_status == 11) {
  756. $use_mark = '红卡无效';
  757. $where[] = array('money_buy_simplex.status', '=',1);
  758. $where[] = array('money_buy_simplex.use_mark', '=', $use_mark);
  759. }
  760. //6 7 8 9 12 为输赢 6赢 7输 8赢一半 9输一半 12和局
  761. if ($order_status == 6) {
  762. $result = 1;
  763. $where[] = array('money_buy_simplex.status', '=',1);
  764. $where[] = array('money_buy_match.result', '=', $result);
  765. }
  766. if ($order_status == 7) {
  767. $result = -1;
  768. $where[] = array('money_buy_simplex.status', '=',1);
  769. $where[] = array('money_buy_match.result', '=', $result);
  770. }
  771. if ($order_status == 8) {
  772. $result = 3;
  773. $where[] = array('money_buy_simplex.status', '=',1);
  774. $where[] = array('money_buy_match.result', '=', $result);
  775. }
  776. if ($order_status == 9) {
  777. $result = 4;
  778. $where[] = array('money_buy_simplex.status', '=',1);
  779. $where[] = array('money_buy_match.result', '=', $result);
  780. }
  781. if ($order_status == 12) {
  782. $result = 2;
  783. $where[] = array('money_buy_simplex.status', '=',1);
  784. $where[] = array('money_buy_match.result', '=', $result);
  785. }
  786. /*
  787. if ($status != -1) {
  788. $where[] = array('money_buy_simplex.settle_status', '=', $status);
  789. }
  790. if ($order_status != -1) {
  791. $where[] = array('money_buy_simplex.status', '=', $order_status);
  792. }
  793. */
  794. $where[] = array('money_buy_simplex.game_code', $type);
  795. $newapp = new \App\Models\SportsNoteList();
  796. $data = $newapp->getinfo($list, $page, $where, $type);
  797. //$alldata = Models\MoneyBuyMatch::where('bet_type',1)->where('is_rolling',1)->distinct('order_id')->count('order_id');
  798. return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total'], 0, $where);
  799. }
  800. /**
  801. * 取消结算
  802. */
  803. public function no_cancel_end(Req $req){
  804. $order_id = $req->order_id;
  805. if(empty($order_id)){
  806. return responseToJson(-1, '参数错误');
  807. }
  808. try {
  809. //开启事务
  810. DB::beginTransaction();
  811. //处理注单数据
  812. $orderModel = new \App\Models\SportsNoteList();
  813. //取消结算处理
  814. $ret = $orderModel->no_cancel_end($order_id);
  815. if($ret != 1) throw new \Exception('取消结算失败');
  816. //提交事务
  817. DB::commit();
  818. return responseToJson(1, '成功');
  819. } catch (\Exception $e) {
  820. //回滚事务
  821. DB::rollBack();
  822. return responseToJson(-1, $e->getMessage());
  823. }
  824. }
  825. /**
  826. * 取消作废
  827. */
  828. public function no_cancel_invalid(Req $req){
  829. $order_id = $req->order_id;
  830. if(empty($order_id)){
  831. return responseToJson(-1, '参数错误');
  832. }
  833. try {
  834. //开启事务
  835. DB::beginTransaction();
  836. //处理注单数据
  837. $orderModel = new \App\Models\SportsNoteList();
  838. //取消作废处理
  839. $ret = $orderModel->no_cancel_invalid($order_id);
  840. if($ret != 1) throw new \Exception('取消作废失败');
  841. //提交事务
  842. DB::commit();
  843. return responseToJson(1, '成功');
  844. } catch (\Exception $e) {
  845. //回滚事务
  846. DB::rollBack();
  847. return responseToJson(-1, $e->getMessage());
  848. }
  849. }
  850. /**
  851. *单式注单作废
  852. */
  853. public function invalid(Req $req)
  854. {
  855. $id = $req->id;
  856. $reason = $_GET['reason'];
  857. if (intval($id) < 1) {
  858. return -1;
  859. }
  860. $order = \App\Models\SportsNoteList::where('id', $id)->first();
  861. //用戶账户金额
  862. $account_money = \App\Models\Account_detailed::where('account_identity', $order->account_identity)->first();
  863. //反水
  864. $water_return_money = \App\Models\Money_details::where('trade_id', $order->order_id)->where('trade_type', '7')->first();
  865. if (!empty($water_return_money)) {
  866. $water_return = $water_return_money->money;
  867. } else {
  868. $water_return = 0;
  869. }
  870. //撤单后用户账户金额
  871. $available_cash = $account_money->available_cash;
  872. $new_available_cash = $available_cash + $order->money - $order->gain_money - $water_return;
  873. $model = new \App\Models\Money_details();
  874. $model->info_identity = UUID();
  875. $model->trade_id = $order->order_id;
  876. $model->account_name = $order->account_name;
  877. $model->account_identity = $order->account_identity;
  878. $model->money = abs($order->money - $order->gain_money - $water_return);
  879. $model->money_time = date("Y-m-d H:i:s", time());
  880. if ($new_available_cash > $available_cash) {
  881. $model->money_type = '1';
  882. } else {
  883. $model->money_type = '2';
  884. }
  885. $model->money_cash = $new_available_cash;
  886. $model->trade_type = '3';
  887. $model->trade_desc = '管理员作废单式注单';
  888. $model->status = '1';
  889. try {
  890. DB::beginTransaction();//开启事务
  891. \App\Models\SportsNoteList::where('id', $id)->update(['status' => '2', 'gain_money' => '0', 'use_mark' => $reason]);
  892. \App\Models\Account_detailed::where('account_identity', $order->account_identity)->update(['available_cash' => $new_available_cash, 'cash' => $new_available_cash]);
  893. $model->save();
  894. DB::commit();//提交
  895. return 1;
  896. } catch (Exception $e) {
  897. DB::rollback();//回滚
  898. return -1;
  899. }
  900. }
  901. /**
  902. *单式注单首次结算
  903. */
  904. public function settlement(Req $req)
  905. {
  906. $id = $req->id;
  907. if (intval($id) < 1) {
  908. return -1;
  909. }
  910. $order = \App\Models\SportsNoteList::where('id', $id)->first();
  911. $order_id = $order->order_id;
  912. $order_ids = array($order->order_id);
  913. $match_id = $order->match_id;
  914. $game_code = $order->game_code;
  915. $bet_type = 1;//单式注单
  916. //return $match_id;
  917. //判断输赢
  918. $settlementWinFail = new SettlementWinFail();
  919. $res = $settlementWinFail->ProcWinInfoByOneOrder($match_id, $order_id, $bet_type);
  920. //结算
  921. $SettlementOrder = new SettlementOrder();
  922. $settype = 1; //首次结算
  923. $data = $SettlementOrder->reSettlement($order_ids, $bet_type, $settype, $game_code, $match_id, $match_status = 0);
  924. return $data;
  925. }
  926. /**
  927. *单式注单重新结算
  928. */
  929. // public function resettlement(Req $req) {
  930. // $id = $req->id;
  931. // if (intval($id) < 1) {
  932. // return -1;
  933. // }
  934. // $order = \App\Models\SportsNoteList::where('id',$id)->first();
  935. // $match_id = $order->match_id;
  936. // $game_code = $order->game_code;
  937. // $order_id = $order->order_id;
  938. // $order_ids = array($order->order_id);
  939. // //return $match_id;
  940. // $bet_type = 1;//单式注单
  941. // //重新判断输赢
  942. // $settlementWinFail = new SettlementWinFail();
  943. // $res = $settlementWinFail->ProcWinInfoByOneOrder($match_id, $order_id, $bet_type);
  944. // //结算
  945. // $SettlementOrder = new SettlementOrder();
  946. // $settype = 2; //重新结算
  947. // $data = $SettlementOrder->reSettlement($order_ids,$bet_type,$settype,$game_code,$match_id,$match_status=0);
  948. // return $data;
  949. // }
  950. public function resettlement(Req $req)
  951. {
  952. $order_id = $req->order_id;
  953. $type = $req->type;
  954. $match_id = $req->match_id;
  955. $jsurl = config('sconstant.url');//结算请求域名地址
  956. $token = session('adminInfo.token');
  957. //查询是否有订单
  958. $newapp = new \App\Models\SportsNoteList();
  959. $simplexnum = $newapp->onlyorder($order_id);
  960. if ($simplexnum == 1) {
  961. $requet = file_get_contents($jsurl . "/DoWinFailOneOrder?order_id=" . $order_id . "&token=" . $token);
  962. if (json_decode($requet, true)['status'] == 1) {
  963. $napp = new \App\Models\Stzqresult();
  964. $simplex = array(
  965. 'token' => $token,
  966. 'order_ids' => $order_id, //订单id字符串,用半角都好分隔
  967. 'bettype' => 1, //结算类型 1单式 2串式
  968. 'settype' => 2, //结算次数 1首次 2非首冷饮
  969. 'game_code' => $type, //赛事类型 zq lq wq bq
  970. 'match_id' => $match_id, // 赛事ID
  971. 'change_status' => 0 //是否改状态
  972. );
  973. $url = $jsurl . '/Settelement';
  974. $simplex_res = $napp->post_curls($url, $simplex);//返回json
  975. $huawei_res = json_decode($simplex_res, true);
  976. if ($huawei_res['status'] == 1) {
  977. return json_encode(['status' => 1, 'msg' => '结算成功']);
  978. } else {
  979. return json_encode(['status' => 4, 'msg' => '结算失败']);
  980. }
  981. } else {
  982. return json_encode(['status' => 3, 'msg' => '输赢判断错误']);
  983. }
  984. } else {
  985. return json_encode(['status' => 2, 'msg' => '订单不存在']);
  986. }
  987. }
  988. /**
  989. *单式注单批量结算
  990. */
  991. public function batchsettlement()
  992. {
  993. $orders = \App\Models\SportsNoteList::where('settle_status', '1')->get();
  994. $order_ids = array();
  995. for ($i = 0; $i < count($orders); $i++) {
  996. $result = \App\Models\MoneyBuyMatch::where('batch_id', $orders[$i]->batch_id)->where('match_id', $orders[$i]->match_id)->get();
  997. $res = array();
  998. for ($j = 0; $j < count($result); $j++) {
  999. $res[] = $result[$j]->result;
  1000. }
  1001. if (!in_array(0, $res)) {
  1002. $order_ids[] = $orders[$i]->order_id;
  1003. }
  1004. }
  1005. $SettlementOrder = new SettlementOrder();
  1006. $bet_type = 1;//单式注单
  1007. $data = $SettlementOrder->reSettlement($order_ids, $bet_type);
  1008. return $data;
  1009. }
  1010. /**
  1011. *删除订单
  1012. */
  1013. public function delete(Req $req)
  1014. {
  1015. $id = $req->input('id');
  1016. if (empty($id)) {
  1017. return responseToJson(-2001); //id
  1018. }
  1019. $ids = explode(',', $id);
  1020. if (!is_array($ids) && intval($ids) < 0) {
  1021. return responseToJson(-2002); //id
  1022. }
  1023. if (is_array($ids) && count($ids) > 0) {
  1024. foreach ($ids as $k => $v) {
  1025. if (intval($v) < 1) {
  1026. unset($ids[$k]);
  1027. }
  1028. }
  1029. }
  1030. $rows = \App\Models\SportsNoteList::whereIn('id', $ids)->delete();
  1031. if (!$rows) {
  1032. return responseToJson(-2003); //id
  1033. }
  1034. return responseToJson(1, trans('menu.delete_success')); //id
  1035. }
  1036. /**
  1037. * 投注金额统计
  1038. */
  1039. function moneycount()
  1040. {
  1041. $where = Request::has('where') ? Request::get('where') : '';
  1042. $type = Request::has('type') ? Request::get('type') : 'zq';
  1043. $db = new \App\Models\SportsNoteList;
  1044. $data = $db->MoneyCount($where, $type);
  1045. return responseToJson($data);
  1046. }
  1047. //单式订单数据
  1048. public function manualmatchget(Req $req)
  1049. {
  1050. $order_id = isset($req->order_id) ? $req->order_id : 0;
  1051. $model = new \App\Models\SportsNoteList();
  1052. $ret = $model->getorder($order_id);
  1053. if ($ret) {
  1054. // $league = db('st_'.$ret->game_code.'_league')->where('id',$ret->lg_id)->first();
  1055. // $ret->league = $league->name_chinese;
  1056. $modelcode = new \App\Models\StoddsCode();
  1057. $opcode_nameArr = $modelcode->getTypeDatas($ret->game_code);
  1058. $ret = $ret->toArray();
  1059. foreach ($ret['matchdatas'] as $key => $val) {
  1060. $tmp_pcode = $val['p_code'];
  1061. $tmp_code = $val['odds_code'];
  1062. $ret['matchdatas'][$key]['odds_name'] = isset($opcode_nameArr[$tmp_pcode][$tmp_code]['odds_name']) ? $opcode_nameArr[$tmp_pcode][$tmp_code]['odds_name'] : '';
  1063. }
  1064. return responseToJson(1, '成功', $ret);
  1065. } else {
  1066. return responseToJson(-1, 'false', $ret);
  1067. }
  1068. }
  1069. //单式订单直接手动更改输赢结果并结算
  1070. public function manualmatchpdate(Req $req)
  1071. {
  1072. $order_id = isset($req->order_id) ? $req->order_id : 0;
  1073. $datas = isset($req->matchdata) ? $req->matchdata : [];
  1074. $datas = json_decode($datas, true);
  1075. if (empty($order_id) || empty($datas)) {
  1076. return responseToJson(-1, '参数不能为空!');
  1077. }
  1078. $model = new \App\Models\SportsNoteList();
  1079. $modeldata = $model->getorder($order_id);
  1080. if (empty($modeldata)) {
  1081. return responseToJson(-1, 'false');
  1082. }
  1083. $sdataArr = [];
  1084. foreach ($datas as $val) {
  1085. $tmp_id = $val['id'];
  1086. $tmp_result = intval($val['result']);
  1087. $tmp_matchword = trim($val['matchresult']);
  1088. if (!in_array($tmp_result, [-1, 1, 2, 3, 4])) {
  1089. continue;
  1090. }
  1091. $sdataArr[$tmp_id] = ['result' => $tmp_result, 'matchresult' => $tmp_matchword];
  1092. }
  1093. if (empty($sdataArr)) {
  1094. return responseToJson(-2, '没有要更新的数据');
  1095. }
  1096. $chageNum = 0;
  1097. foreach ($modeldata->matchdatas as $key => $val) {
  1098. $id = $val->id;
  1099. if (isset($sdataArr[$id])) {
  1100. if ($val->result != $sdataArr[$id]['result'] || $val->matchwork != $sdataArr[$id]['matchresult']) {
  1101. $val->result = $sdataArr[$id]['result'];
  1102. $val->matchresult = $sdataArr[$id]['matchresult'];
  1103. $val->save();
  1104. $chageNum++;
  1105. }
  1106. }
  1107. }
  1108. if ($chageNum) {
  1109. $modeldata->is_manual = 1;
  1110. $modeldata->save();
  1111. } else {
  1112. return responseToJson(1, '没有更新操作数据!');
  1113. }
  1114. $data = [
  1115. 'token' => session('adminInfo.token'), //外网
  1116. 'order_ids' => $modeldata->order_id,
  1117. 'bettype' => 1,
  1118. 'settype' => 2,
  1119. 'game_code' => $modeldata->game_code,
  1120. 'match_id' => $modeldata->match_id,
  1121. 'change_status' => 0,
  1122. 'is_manual' => 1,
  1123. ];
  1124. $ret = $this->request_post(config('sconstant.url') . '/Settelement', $data);
  1125. $retjson = json_decode($ret, true);
  1126. if (isset($retjson['status']) && $retjson['status'] == 1) {
  1127. $model->where('order_id', $order_id)->update(['settle_status' => 2]);
  1128. }
  1129. return responseToJson(1, '更新成功');
  1130. }
  1131. //冠军注单直接手动设置比赛结果 --> 提交胜负判断处理以及 --> 提交结算
  1132. public function matchpdate_v2(Req $req)
  1133. {
  1134. $order_id = isset($req->order_id) ? $req->order_id : 0;
  1135. $game_code = isset($req->game_code) ? $req->game_code : 0;
  1136. $match_id = isset($req->match_id) ? $req->match_id : 0;
  1137. $pdatas = isset($req->matchdata) ? $req->matchdata : [];
  1138. $pdatas = json_decode($pdatas, true);
  1139. if (empty($order_id) || empty($game_code) || empty($match_id) || empty($pdatas)) {
  1140. return responseToJson(0, '参数错误');
  1141. }
  1142. $buyModel = (new MoneyBuySimplexModel())->where([['order_id', '=', $order_id]])->first();
  1143. if (empty($buyModel)) {
  1144. return responseToJson(0, '订单数据错误');
  1145. }
  1146. $game_name = $pdatas['odds_code'];
  1147. $result = $pdatas['result'];
  1148. $res = [];
  1149. $res['lg_id'] = $match_id;
  1150. $res['game_name'] = $game_name;
  1151. $res['result'] = $result;
  1152. $buyModel->single_result = json_encode([$res], 256);
  1153. //$buyModel->single_result = '{"lg_id":'.$match_id.',"game_name":'.$game_name.',"game_name":'.$result.',"game_name":'.time().'}';
  1154. $buyModel->result_flag = 1;
  1155. $buyModel->is_manual = 1;
  1156. $ret = $buyModel->save();
  1157. if ($ret) {
  1158. $ret2 = $this->do_win_set($order_id, $game_code, $match_id);
  1159. if ($ret2['status'] == 1) {
  1160. return responseToJson(1, '操作成功!');
  1161. } else {
  1162. return responseToJson(0, '操作失败2!--' . $ret2['data']);
  1163. }
  1164. }
  1165. return responseToJson(0, '未做更新', ['order_id' => $order_id, 'game_code' => $game_code, 'match_id' => $game_code, 'datas' => $pdatas]);
  1166. }
  1167. //单式订单直接手动设置比赛结果 --> 提交胜负判断处理以及 --> 提交结算
  1168. public function ___manualmatchpdate_v2(Req $req)
  1169. {
  1170. $order_id = isset($req->order_id) ? $req->order_id : 0;
  1171. $game_code = isset($req->game_code) ? $req->game_code : 0;
  1172. $match_id = isset($req->match_id) ? $req->match_id : 0;
  1173. $pdatas = isset($req->matchdata) ? $req->matchdata : [];
  1174. $ScoreTitle = isset($req->ScoreTitle) ? $req->ScoreTitle : '';//进程
  1175. $home_sorce = isset($req->home) ? $req->home : '';//主队比分
  1176. $guest_sorce = isset($req->guest) ? $req->guest : '';//客队比分
  1177. $pdatas = json_decode($pdatas, true);
  1178. if (empty($order_id) || empty($game_code) || empty($match_id) || empty($pdatas)) {
  1179. return responseToJson(0, '参数错误');
  1180. }
  1181. if(in_array(-1,$pdatas)){
  1182. return responseToJson(-1, '输入比分错误');
  1183. }
  1184. $buyModel = (new MoneyBuySimplexModel())->where([['order_id', '=', $order_id]])->first();
  1185. if (empty($buyModel)) {
  1186. return responseToJson(0, '订单数据错误');
  1187. }
  1188. $restModel = '';
  1189. switch ($game_code) {
  1190. case 'zq':
  1191. $restModel = DB::table('st_zq_result')->where([['match_id', '=', $match_id]])->first();
  1192. break;
  1193. case 'lq':
  1194. $restModel = DB::table('st_lq_result')->where([['match_id', '=', $match_id]])->first();
  1195. break;
  1196. case 'wq':
  1197. $restModel = DB::table('st_wq_result')->where([['match_id', '=', $match_id]])->first();
  1198. break;
  1199. case 'bq':
  1200. $restModel = DB::table('st_bq_result')->where([['match_id', '=', $match_id]])->first();
  1201. break;
  1202. }
  1203. if (empty($restModel)) {
  1204. return responseToJson(0, '赛事结果记录没有找到,数据错误');
  1205. }
  1206. if ($game_code == 'zq') {
  1207. $home = intval($pdatas['home']);
  1208. $guest = intval($pdatas['guest']);
  1209. $home_u = intval($pdatas['home_u']);
  1210. $guest_u = intval($pdatas['guest_u']);
  1211. $restModel->home_score = $home;
  1212. $restModel->guest_score = $guest;
  1213. $restModel->u_home_score = $home_u;
  1214. $restModel->u_guest_score = $guest_u;
  1215. $restModel->corner_ball = json_decode($restModel->corner_ball, 256);
  1216. $restModel->penalty_card = json_decode($restModel->penalty_card, 256);
  1217. $restModel->first_score = json_decode($restModel->first_score, 256);
  1218. $restModel->warn_more = json_decode($restModel->warn_more, 256);
  1219. $buyModel->single_result = json_encode([$restModel], 256);
  1220. $buyModel->result_flag = 1;
  1221. $buyModel->is_manual = 1;
  1222. $ret = $buyModel->save();
  1223. if ($ret) {
  1224. $ret2 = $this->do_win_set($order_id, $game_code, $match_id);
  1225. if ($ret2['status'] == 1) {
  1226. return responseToJson(1, '操作成功!');
  1227. } else {
  1228. return responseToJson(0, '操作失败2!--' . $ret2['data']);
  1229. }
  1230. }
  1231. return responseToJson(0, '更新失败1');
  1232. }
  1233. if ($game_code == 'lq') {
  1234. $home = $pdatas['home'];
  1235. $guest = $pdatas['guest'];
  1236. $restModel->home_score = ['1' => intval($home['0']), '2' => intval($home['1']), '3' => intval($home['2']), '4' => intval($home['3'])];
  1237. $restModel->guest_score = ['1' => intval($guest['0']), '2' => intval($guest['1']), '3' => intval($guest['2']), '4' => intval($guest['3'])];
  1238. $restModel->u_home_score = intval($home['0']) + intval($home['1']);
  1239. $restModel->u_guest_score = intval($guest['0']) + intval($guest['1']);
  1240. $all_home = intval($home['0']) + intval($home['1']) + intval($home['2']) + intval($home['3']);
  1241. $all_guest = intval($guest['0']) + intval($guest['1']) + intval($guest['2']) + intval($guest['3']);
  1242. $restModel->all_goal = $all_home + $all_guest;
  1243. $restModel->match_score = $all_home . ':' . $all_guest;
  1244. $restModel->match_winer = $all_home > $all_guest ? $restModel->home_team : $restModel->guest_team;
  1245. $restModel->warn_more = json_decode($restModel->warn_more, 256);
  1246. $buyModel->single_result = json_encode([$restModel], 256);
  1247. $buyModel->result_flag = 1;
  1248. $buyModel->is_manual = 1;
  1249. $ret = $buyModel->save();
  1250. if ($ret) {
  1251. $ret2 = $this->do_win_set($order_id, $game_code, $match_id);
  1252. if ($ret2['status'] == 1) {
  1253. return responseToJson(1, '操作成功!');
  1254. } else {
  1255. return responseToJson(0, '操作失败2!--' . $ret2['data']);
  1256. }
  1257. }
  1258. return responseToJson(0, '更新失败1');
  1259. }
  1260. if ($game_code == 'bq') {
  1261. $home = $pdatas['home'];
  1262. $guest = $pdatas['guest'];
  1263. $home_other = $pdatas['home_other'];
  1264. $guest_other = $pdatas['guest_other'];
  1265. $arrs = [];
  1266. for ($i = 0; $i <= 8; $i++) {
  1267. $j = $i + 1;
  1268. $arrs[$j] = [
  1269. 'home' => intval($home[$i]),
  1270. 'guest' => intval($guest[$i]),
  1271. ];
  1272. }
  1273. $arrs['other'] = [
  1274. 'home' => intval($home_other),
  1275. 'guest' => intval($guest_other),
  1276. ];
  1277. $restModel->match_score_t = $arrs;
  1278. $restModel->warn_more = json_decode($restModel->warn_more, 256);
  1279. $buyModel->single_result = json_encode([$restModel], 256);
  1280. $buyModel->result_flag = 1;
  1281. $buyModel->is_manual = 1;
  1282. $ret = $buyModel->save();
  1283. if ($ret) {
  1284. $ret2 = $this->do_win_set($order_id, $game_code, $match_id);
  1285. if ($ret2['status'] == 1) {
  1286. return responseToJson(1, '操作成功!');
  1287. } else {
  1288. return responseToJson(0, '操作失败2!--' . $ret2['data']);
  1289. }
  1290. }
  1291. return responseToJson(0, '更新失败1');
  1292. }
  1293. if ($game_code == 'wq') {
  1294. $home = $pdatas['home'];
  1295. $guest = $pdatas['guest'];
  1296. $arrs = [];
  1297. for ($i = 0; $i <= 4; $i++) {
  1298. $j = $i + 1;
  1299. $arrs[$j] = [
  1300. 'home' => intval($home[$i]),
  1301. 'guest' => intval($guest[$i]),
  1302. ];
  1303. }
  1304. $restModel->inning = $arrs;
  1305. $restModel->warn_more = json_decode($restModel->warn_more, 256);
  1306. $buyModel->single_result = json_encode([$restModel], 256);
  1307. $buyModel->result_flag = 1;
  1308. $buyModel->is_manual = 1;
  1309. $ret = $buyModel->save();
  1310. if ($ret) {
  1311. $ret2 = $this->do_win_set($order_id, $game_code, $match_id);
  1312. if ($ret2['status'] == 1) {
  1313. return responseToJson(1, '操作成功!');
  1314. } else {
  1315. return responseToJson(0, '操作失败2!--' . $ret2['data']);
  1316. }
  1317. }
  1318. return responseToJson(0, '更新失败1');
  1319. }
  1320. return responseToJson(0, '未做更新', ['order_id' => $order_id, 'game_code' => $game_code, 'match_id' => $game_code, 'datas' => $pdatas]);
  1321. }
  1322. //单式订单直接手动设置比赛结果 --> 提交胜负判断处理以及 --> 提交结算
  1323. public function manualmatchpdate_v2(Req $req)
  1324. {
  1325. $order_id = isset($req->order_id) ? $req->order_id : 0;
  1326. $game_code = isset($req->game_code) ? $req->game_code : 0;
  1327. $match_id = isset($req->match_id) ? $req->match_id : 0;
  1328. $pdatas = isset($req->matchdata) ? $req->matchdata : [];
  1329. $ScoreTitle = isset($req->ScoreTitle) ? $req->ScoreTitle : '';//进程
  1330. $home_sorce = isset($req->home) ? $req->home : '';//主队比分
  1331. $guest_sorce = isset($req->guest) ? $req->guest : '';//客队比分
  1332. $pdatas = json_decode($pdatas, true);
  1333. if (empty($order_id) || empty($game_code) || empty($match_id) || empty($pdatas)) {
  1334. return responseToJson(0, '参数错误');
  1335. }
  1336. if(in_array(-1,$pdatas)){
  1337. return responseToJson(-1, '输入比分错误');
  1338. }
  1339. $buyModel = (new MoneyBuySimplexModel())->where([['order_id', '=', $order_id]])->first();
  1340. if (empty($buyModel)) {
  1341. return responseToJson(0, '订单数据错误');
  1342. }
  1343. $restModel = '';
  1344. switch ($game_code) {
  1345. case 'zq':
  1346. $restModel = DB::table('st_zq_result')->where([['match_id', '=', $match_id]])->first();
  1347. break;
  1348. case 'lq':
  1349. $restModel = DB::table('st_lq_result')->where([['match_id', '=', $match_id]])->first();
  1350. break;
  1351. case 'wq':
  1352. $restModel = DB::table('st_wq_result')->where([['match_id', '=', $match_id]])->first();
  1353. break;
  1354. case 'bq':
  1355. $restModel = DB::table('st_bq_result')->where([['match_id', '=', $match_id]])->first();
  1356. break;
  1357. }
  1358. if (empty($restModel)) {
  1359. return responseToJson(0, '赛事结果记录没有找到,数据错误');
  1360. }
  1361. if ($game_code == 'zq') {
  1362. if($ScoreTitle == '上半'){
  1363. //替换上半场比分
  1364. $restModel->u_home_score = $home_sorce;
  1365. $restModel->u_guest_score = $guest_sorce;
  1366. }
  1367. if($ScoreTitle == '全场'){
  1368. //替换全场比分
  1369. $restModel->home_score = $home_sorce;
  1370. $restModel->guest_score = $guest_sorce;
  1371. }
  1372. if($ScoreTitle == '角球上半'){
  1373. //获取角球数据 arr {"home":0,"guest":0,"home_half":0,"guest_half":0}
  1374. $corner_arr = json_decode($restModel->corner_ball,256);
  1375. //替换上半场角球比分
  1376. $corner_arr['home_half'] = $home_sorce;
  1377. $corner_arr['guest_half'] = $guest_sorce;
  1378. $restModel->corner_ball = json_encode($corner_arr);
  1379. }
  1380. if($ScoreTitle == '角球全场'){
  1381. //获取角球数据 arr {"home":0,"guest":0,"home_half":0,"guest_half":0}
  1382. $corner_arr = json_decode($restModel->corner_ball,256);
  1383. //替换全场角球比分
  1384. $corner_arr['home'] = $home_sorce;
  1385. $corner_arr['guest'] = $guest_sorce;
  1386. $restModel->corner_ball = json_encode($corner_arr);
  1387. }
  1388. $restModel->corner_ball = json_decode($restModel->corner_ball, 256);
  1389. $restModel->penalty_card = json_decode($restModel->penalty_card, 256);
  1390. $restModel->first_score = json_decode($restModel->first_score, 256);
  1391. $restModel->warn_more = json_decode($restModel->warn_more, 256);
  1392. $buyModel->single_result = json_encode([$restModel], 256);
  1393. $buyModel->result_flag = 1;
  1394. $buyModel->is_manual = 1;
  1395. $ret = $buyModel->save();
  1396. if ($ret) {
  1397. $ret2 = $this->do_win_set($order_id, $game_code, $match_id);
  1398. if ($ret2['status'] == 1) {
  1399. return responseToJson(1, '操作成功!');
  1400. } else {
  1401. return responseToJson(0, '操作失败2!--' . $ret2['data']);
  1402. }
  1403. }
  1404. return responseToJson(0, '更新失败1');
  1405. }
  1406. if ($game_code == 'lq') {
  1407. if($ScoreTitle == '全场'){
  1408. $restModel->home_score = ['1' => intval($home_sorce), '2' => 0, '3' => 0, '4' => 0];
  1409. $restModel->guest_score = ['1' => intval($guest_sorce), '2' => 0, '3' => 0, '4' => 0];
  1410. }
  1411. if($ScoreTitle == '上半'){
  1412. $restModel->home_score = ['1' => intval($home_sorce), '2' => 0, '3' => 0, '4' => 0];
  1413. $restModel->guest_score = ['1' => intval($guest_sorce), '2' => 0, '3' => 0, '4' => 0];
  1414. }
  1415. if($ScoreTitle == '下半'){
  1416. $restModel->home_score = ['1' => 0, '2' => 0, '3' => intval($home_sorce), '4' => 0];
  1417. $restModel->guest_score = ['1' => 0, '2' => 0, '3' => intval($guest_sorce), '4' => 0];
  1418. }
  1419. if($ScoreTitle == '第一节'){
  1420. $restModel->home_score = ['1' => intval($home_sorce), '2' => 0, '3' => 0, '4' => 0];
  1421. $restModel->guest_score = ['1' => intval($guest_sorce), '2' => 0, '3' => 0, '4' => 0];
  1422. }
  1423. if($ScoreTitle == '第二节'){
  1424. $restModel->home_score = ['1' => 0, '2' => intval($home_sorce), '3' => 0, '4' => 0];
  1425. $restModel->guest_score = ['1' => 0, '2' => intval($guest_sorce), '3' => 0, '4' => 0];
  1426. }
  1427. if($ScoreTitle == '第三节'){
  1428. $restModel->home_score = ['1' => 0, '2' => 0, '3' => intval($home_sorce), '4' => 0];
  1429. $restModel->guest_score = ['1' => 0, '2' => 0, '3' => intval($guest_sorce), '4' => 0];
  1430. }
  1431. if($ScoreTitle == '第四节'){
  1432. $restModel->home_score = ['1' => 0, '2' => 0, '3' => 0, '4' => intval($home_sorce)];
  1433. $restModel->guest_score = ['1' => 0, '2' => 0, '3' => 0, '4' => intval($guest_sorce)];
  1434. }
  1435. $restModel->warn_more = json_decode($restModel->warn_more, 256);
  1436. $buyModel->single_result = json_encode([$restModel], 256);
  1437. $buyModel->result_flag = 1;
  1438. $buyModel->is_manual = 1;
  1439. $ret = $buyModel->save();
  1440. if ($ret) {
  1441. $ret2 = $this->do_win_set($order_id, $game_code, $match_id);
  1442. if ($ret2['status'] == 1) {
  1443. return responseToJson(1, '操作成功!');
  1444. } else {
  1445. return responseToJson(0, '操作失败2!--' . $ret2['data']);
  1446. }
  1447. }
  1448. return responseToJson(0, '更新失败1');
  1449. }
  1450. if ($game_code == 'bq') {
  1451. $home = $pdatas['home'];
  1452. $guest = $pdatas['guest'];
  1453. $home_other = $pdatas['home_other'];
  1454. $guest_other = $pdatas['guest_other'];
  1455. $arrs = [];
  1456. for ($i = 0; $i <= 8; $i++) {
  1457. $j = $i + 1;
  1458. $arrs[$j] = [
  1459. 'home' => intval($home[$i]),
  1460. 'guest' => intval($guest[$i]),
  1461. ];
  1462. }
  1463. $arrs['other'] = [
  1464. 'home' => intval($home_other),
  1465. 'guest' => intval($guest_other),
  1466. ];
  1467. $restModel->match_score_t = $arrs;
  1468. $restModel->warn_more = json_decode($restModel->warn_more, 256);
  1469. $buyModel->single_result = json_encode([$restModel], 256);
  1470. $buyModel->result_flag = 1;
  1471. $buyModel->is_manual = 1;
  1472. $ret = $buyModel->save();
  1473. if ($ret) {
  1474. $ret2 = $this->do_win_set($order_id, $game_code, $match_id);
  1475. if ($ret2['status'] == 1) {
  1476. return responseToJson(1, '操作成功!');
  1477. } else {
  1478. return responseToJson(0, '操作失败2!--' . $ret2['data']);
  1479. }
  1480. }
  1481. return responseToJson(0, '更新失败1');
  1482. }
  1483. if ($game_code == 'wq') {
  1484. //{"1":{"home":0,"guest":0},"2":{"home":0,"guest":0},"3":{"home":0,"guest":0},"4":{"home":0,"guest":0},"5":{"home":0,"guest":0},"all":{"home":0,"guest":0}}
  1485. if($ScoreTitle == '全场'){
  1486. $arrs = [
  1487. '1'=>['home'=>$home_sorce,'guest'=>$guest_sorce],
  1488. '2'=>['home'=>0,'guest'=>0],
  1489. '3'=>['home'=>0,'guest'=>0],
  1490. '4'=>['home'=>0,'guest'=>0],
  1491. '5'=>['home'=>0,'guest'=>0],
  1492. 'all'=>['home'=>0,'guest'=>0],
  1493. ];
  1494. }
  1495. if($ScoreTitle == '冠军'){
  1496. if($home_sorce > $guest_sorce){
  1497. $arrs = [
  1498. '1'=>['home'=>1,'guest'=>0],
  1499. '2'=>['home'=>1,'guest'=>0],
  1500. '3'=>['home'=>1,'guest'=>0],
  1501. '4'=>['home'=>1,'guest'=>0],
  1502. '5'=>['home'=>1,'guest'=>0],
  1503. 'all'=>['home'=>0,'guest'=>0],
  1504. ];
  1505. }else{
  1506. $arrs = [
  1507. '1'=>['home'=>0,'guest'=>1],
  1508. '2'=>['home'=>0,'guest'=>1],
  1509. '3'=>['home'=>0,'guest'=>1],
  1510. '4'=>['home'=>0,'guest'=>1],
  1511. '5'=>['home'=>0,'guest'=>1],
  1512. 'all'=>['home'=>0,'guest'=>0],
  1513. ];
  1514. }
  1515. }
  1516. if($ScoreTitle == '第一盘'){
  1517. $arrs = [
  1518. '1'=>['home'=>$home_sorce,'guest'=>$guest_sorce],
  1519. '2'=>['home'=>0,'guest'=>0],
  1520. '3'=>['home'=>0,'guest'=>0],
  1521. '4'=>['home'=>0,'guest'=>0],
  1522. '5'=>['home'=>0,'guest'=>0],
  1523. 'all'=>['home'=>0,'guest'=>0],
  1524. ];
  1525. }
  1526. if($ScoreTitle == '第二盘'){
  1527. $arrs = [
  1528. '1'=>['home'=>0,'guest'=>0],
  1529. '2'=>['home'=>$home_sorce,'guest'=>$guest_sorce],
  1530. '3'=>['home'=>0,'guest'=>0],
  1531. '4'=>['home'=>0,'guest'=>0],
  1532. '5'=>['home'=>0,'guest'=>0],
  1533. 'all'=>['home'=>0,'guest'=>0],
  1534. ];
  1535. }
  1536. if($ScoreTitle == '第三盘'){
  1537. $arrs = [
  1538. '1'=>['home'=>0,'guest'=>0],
  1539. '2'=>['home'=>0,'guest'=>0],
  1540. '3'=>['home'=>$home_sorce,'guest'=>$guest_sorce],
  1541. '4'=>['home'=>0,'guest'=>0],
  1542. '5'=>['home'=>0,'guest'=>0],
  1543. 'all'=>['home'=>0,'guest'=>0],
  1544. ];
  1545. }
  1546. if($ScoreTitle == '第四盘'){
  1547. $arrs = [
  1548. '1'=>['home'=>0,'guest'=>0],
  1549. '2'=>['home'=>0,'guest'=>0],
  1550. '3'=>['home'=>0,'guest'=>0],
  1551. '4'=>['home'=>$home_sorce,'guest'=>$guest_sorce],
  1552. '5'=>['home'=>0,'guest'=>0],
  1553. 'all'=>['home'=>0,'guest'=>0],
  1554. ];
  1555. }
  1556. if($ScoreTitle == '第五盘'){
  1557. $arrs = [
  1558. '1'=>['home'=>0,'guest'=>0],
  1559. '2'=>['home'=>0,'guest'=>0],
  1560. '3'=>['home'=>0,'guest'=>0],
  1561. '4'=>['home'=>0,'guest'=>0],
  1562. '5'=>['home'=>$home_sorce,'guest'=>$guest_sorce],
  1563. 'all'=>['home'=>0,'guest'=>0],
  1564. ];
  1565. }
  1566. $restModel->inning = $arrs;
  1567. $restModel->warn_more = json_decode($restModel->warn_more, 256);
  1568. $buyModel->single_result = json_encode([$restModel], 256);
  1569. $buyModel->result_flag = 1;
  1570. $buyModel->is_manual = 1;
  1571. $ret = $buyModel->save();
  1572. if ($ret) {
  1573. $ret2 = $this->do_win_set($order_id, $game_code, $match_id);
  1574. if ($ret2['status'] == 1) {
  1575. return responseToJson(1, '操作成功!');
  1576. } else {
  1577. return responseToJson(0, '操作失败2!--' . $ret2['data']);
  1578. }
  1579. }
  1580. return responseToJson(0, '更新失败1');
  1581. }
  1582. return responseToJson(0, '未做更新', ['order_id' => $order_id, 'game_code' => $game_code, 'match_id' => $game_code, 'datas' => $pdatas]);
  1583. }
  1584. //修复比分时用到订单信息及比赛结果数据
  1585. public function manualmatchget_v2(Req $req)
  1586. {
  1587. $order_id = isset($req->order_id) ? $req->order_id : 0;
  1588. $ScoreTitle = isset($req->ScoreTitle) ? $req->ScoreTitle : 0;
  1589. $model = new MoneyBuySimplexModel();
  1590. $ret = $model->OrderinfoResult($order_id,$ScoreTitle);
  1591. if ($ret && !empty($ret['result'])) {
  1592. return responseToJson(1, '成功', $ret);
  1593. } else {
  1594. return responseToJson(-1, 'false', $ret);
  1595. }
  1596. }
  1597. //先提交输赢,再结算
  1598. private function do_win_set($order_id, $game_code, $match_id)
  1599. {
  1600. $winret = $this->do_winfail($order_id, $game_code, $match_id);
  1601. if ($winret['status'] == 1) {
  1602. $setret = $this->do_settelement($order_id, $game_code, $match_id);
  1603. if ($setret['status'] == 1) {
  1604. return ['status' => 1, 'msg' => 'success', 'data' => []];
  1605. } else {
  1606. return ['status' => 0, 'msg' => 'failse', 'data' => $setret['msg']];
  1607. }
  1608. } else {
  1609. return ['status' => 0, 'msg' => 'failse', 'data' => $winret['msg']];
  1610. }
  1611. }
  1612. //单订单手动提交输赢计算
  1613. private function do_winfail($order_id, $game_code, $match_id)
  1614. {
  1615. $data = [
  1616. 'token' => session('adminInfo.token'), //外网
  1617. 'order_id' => $order_id,
  1618. ];
  1619. $ret = $this->request_post(config('sconstant.url') . '/DoWinFailOneOrder', $data);
  1620. return json_decode($ret, true);
  1621. }
  1622. //单订单手动提交结算
  1623. private function do_settelement($order_id, $game_code, $match_id)
  1624. {
  1625. $data = [
  1626. 'token' => session('adminInfo.token'), //外网
  1627. 'order_ids' => $order_id,
  1628. 'bettype' => 1,
  1629. 'settype' => 2,
  1630. 'game_code' => $game_code,
  1631. 'match_id' => $match_id,
  1632. 'change_status' => 0,
  1633. 'is_manual' => 1,
  1634. ];
  1635. $ret = $this->request_post(config('sconstant.url') . '/Settelement', $data);
  1636. return json_decode($ret, true);
  1637. }
  1638. private function request_post($url = '', $param = '')
  1639. {
  1640. if (empty($url) || empty($param)) {
  1641. return false;
  1642. }
  1643. $postUrl = $url;
  1644. $curlPost = $param;
  1645. $ch = curl_init();//初始化curl
  1646. curl_setopt($ch, CURLOPT_URL, $postUrl);//抓取指定网页
  1647. curl_setopt($ch, CURLOPT_HEADER, 0);//设置header
  1648. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//要求结果为字符串且输出到屏幕上
  1649. curl_setopt($ch, CURLOPT_POST, 1);//post提交方式
  1650. curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost);
  1651. $data = curl_exec($ch);//运行curl
  1652. curl_close($ch);
  1653. return $data;
  1654. }
  1655. //获取球类分类下的父级玩法数据
  1656. public function getpcode(){
  1657. $game_type = $_GET["game_type"];
  1658. $pcode = new \App\Models\StoddsCode();
  1659. $p_code = $pcode->getpcode($game_type);
  1660. return json_encode($p_code);
  1661. }
  1662. }