SoccerNoteListController.php 77 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810
  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. $arrs = [
  1497. '1'=>['home'=>$home_sorce,'guest'=>$guest_sorce],
  1498. '2'=>['home'=>0,'guest'=>0],
  1499. '3'=>['home'=>0,'guest'=>0],
  1500. '4'=>['home'=>0,'guest'=>0],
  1501. '5'=>['home'=>0,'guest'=>0],
  1502. 'all'=>['home'=>0,'guest'=>0],
  1503. ];
  1504. }
  1505. if($ScoreTitle == '第二盘'){
  1506. $arrs = [
  1507. '1'=>['home'=>0,'guest'=>0],
  1508. '2'=>['home'=>$home_sorce,'guest'=>$guest_sorce],
  1509. '3'=>['home'=>0,'guest'=>0],
  1510. '4'=>['home'=>0,'guest'=>0],
  1511. '5'=>['home'=>0,'guest'=>0],
  1512. 'all'=>['home'=>0,'guest'=>0],
  1513. ];
  1514. }
  1515. if($ScoreTitle == '第三盘'){
  1516. $arrs = [
  1517. '1'=>['home'=>0,'guest'=>0],
  1518. '2'=>['home'=>0,'guest'=>0],
  1519. '3'=>['home'=>$home_sorce,'guest'=>$guest_sorce],
  1520. '4'=>['home'=>0,'guest'=>0],
  1521. '5'=>['home'=>0,'guest'=>0],
  1522. 'all'=>['home'=>0,'guest'=>0],
  1523. ];
  1524. }
  1525. if($ScoreTitle == '第四盘'){
  1526. $arrs = [
  1527. '1'=>['home'=>0,'guest'=>0],
  1528. '2'=>['home'=>0,'guest'=>0],
  1529. '3'=>['home'=>0,'guest'=>0],
  1530. '4'=>['home'=>$home_sorce,'guest'=>$guest_sorce],
  1531. '5'=>['home'=>0,'guest'=>0],
  1532. 'all'=>['home'=>0,'guest'=>0],
  1533. ];
  1534. }
  1535. if($ScoreTitle == '第五盘'){
  1536. $arrs = [
  1537. '1'=>['home'=>0,'guest'=>0],
  1538. '2'=>['home'=>0,'guest'=>0],
  1539. '3'=>['home'=>0,'guest'=>0],
  1540. '4'=>['home'=>0,'guest'=>0],
  1541. '5'=>['home'=>$home_sorce,'guest'=>$guest_sorce],
  1542. 'all'=>['home'=>0,'guest'=>0],
  1543. ];
  1544. }
  1545. $restModel->inning = $arrs;
  1546. $restModel->warn_more = json_decode($restModel->warn_more, 256);
  1547. $buyModel->single_result = json_encode([$restModel], 256);
  1548. $buyModel->result_flag = 1;
  1549. $buyModel->is_manual = 1;
  1550. $ret = $buyModel->save();
  1551. if ($ret) {
  1552. $ret2 = $this->do_win_set($order_id, $game_code, $match_id);
  1553. if ($ret2['status'] == 1) {
  1554. return responseToJson(1, '操作成功!');
  1555. } else {
  1556. return responseToJson(0, '操作失败2!--' . $ret2['data']);
  1557. }
  1558. }
  1559. return responseToJson(0, '更新失败1');
  1560. }
  1561. return responseToJson(0, '未做更新', ['order_id' => $order_id, 'game_code' => $game_code, 'match_id' => $game_code, 'datas' => $pdatas]);
  1562. }
  1563. //修复比分时用到订单信息及比赛结果数据
  1564. public function manualmatchget_v2(Req $req)
  1565. {
  1566. $order_id = isset($req->order_id) ? $req->order_id : 0;
  1567. $ScoreTitle = isset($req->ScoreTitle) ? $req->ScoreTitle : 0;
  1568. $model = new MoneyBuySimplexModel();
  1569. $ret = $model->OrderinfoResult($order_id,$ScoreTitle);
  1570. if ($ret && !empty($ret['result'])) {
  1571. return responseToJson(1, '成功', $ret);
  1572. } else {
  1573. return responseToJson(-1, 'false', $ret);
  1574. }
  1575. }
  1576. //先提交输赢,再结算
  1577. private function do_win_set($order_id, $game_code, $match_id)
  1578. {
  1579. $winret = $this->do_winfail($order_id, $game_code, $match_id);
  1580. if ($winret['status'] == 1) {
  1581. $setret = $this->do_settelement($order_id, $game_code, $match_id);
  1582. if ($setret['status'] == 1) {
  1583. return ['status' => 1, 'msg' => 'success', 'data' => []];
  1584. } else {
  1585. return ['status' => 0, 'msg' => 'failse', 'data' => $setret['msg']];
  1586. }
  1587. } else {
  1588. return ['status' => 0, 'msg' => 'failse', 'data' => $winret['msg']];
  1589. }
  1590. }
  1591. //单订单手动提交输赢计算
  1592. private function do_winfail($order_id, $game_code, $match_id)
  1593. {
  1594. $data = [
  1595. 'token' => session('adminInfo.token'), //外网
  1596. 'order_id' => $order_id,
  1597. ];
  1598. $ret = $this->request_post(config('sconstant.url') . '/DoWinFailOneOrder', $data);
  1599. return json_decode($ret, true);
  1600. }
  1601. //单订单手动提交结算
  1602. private function do_settelement($order_id, $game_code, $match_id)
  1603. {
  1604. $data = [
  1605. 'token' => session('adminInfo.token'), //外网
  1606. 'order_ids' => $order_id,
  1607. 'bettype' => 1,
  1608. 'settype' => 2,
  1609. 'game_code' => $game_code,
  1610. 'match_id' => $match_id,
  1611. 'change_status' => 0,
  1612. 'is_manual' => 1,
  1613. ];
  1614. $ret = $this->request_post(config('sconstant.url') . '/Settelement', $data);
  1615. return json_decode($ret, true);
  1616. }
  1617. private function request_post($url = '', $param = '')
  1618. {
  1619. if (empty($url) || empty($param)) {
  1620. return false;
  1621. }
  1622. $postUrl = $url;
  1623. $curlPost = $param;
  1624. $ch = curl_init();//初始化curl
  1625. curl_setopt($ch, CURLOPT_URL, $postUrl);//抓取指定网页
  1626. curl_setopt($ch, CURLOPT_HEADER, 0);//设置header
  1627. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//要求结果为字符串且输出到屏幕上
  1628. curl_setopt($ch, CURLOPT_POST, 1);//post提交方式
  1629. curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost);
  1630. $data = curl_exec($ch);//运行curl
  1631. curl_close($ch);
  1632. return $data;
  1633. }
  1634. //获取球类分类下的父级玩法数据
  1635. public function getpcode(){
  1636. $game_type = $_GET["game_type"];
  1637. $pcode = new \App\Models\StoddsCode();
  1638. $p_code = $pcode->getpcode($game_type);
  1639. return json_encode($p_code);
  1640. }
  1641. }