SoccerNoteListController.php 74 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743
  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. $home = $pdatas['home'];
  1408. $guest = $pdatas['guest'];
  1409. $restModel->home_score = ['1' => intval($home['0']), '2' => intval($home['1']), '3' => intval($home['2']), '4' => intval($home['3'])];
  1410. $restModel->guest_score = ['1' => intval($guest['0']), '2' => intval($guest['1']), '3' => intval($guest['2']), '4' => intval($guest['3'])];
  1411. $restModel->u_home_score = intval($home['0']) + intval($home['1']);
  1412. $restModel->u_guest_score = intval($guest['0']) + intval($guest['1']);
  1413. $all_home = intval($home['0']) + intval($home['1']) + intval($home['2']) + intval($home['3']);
  1414. $all_guest = intval($guest['0']) + intval($guest['1']) + intval($guest['2']) + intval($guest['3']);
  1415. $restModel->all_goal = $all_home + $all_guest;
  1416. $restModel->match_score = $all_home . ':' . $all_guest;
  1417. $restModel->match_winer = $all_home > $all_guest ? $restModel->home_team : $restModel->guest_team;
  1418. $restModel->warn_more = json_decode($restModel->warn_more, 256);
  1419. $buyModel->single_result = json_encode([$restModel], 256);
  1420. $buyModel->result_flag = 1;
  1421. $buyModel->is_manual = 1;
  1422. $ret = $buyModel->save();
  1423. if ($ret) {
  1424. $ret2 = $this->do_win_set($order_id, $game_code, $match_id);
  1425. if ($ret2['status'] == 1) {
  1426. return responseToJson(1, '操作成功!');
  1427. } else {
  1428. return responseToJson(0, '操作失败2!--' . $ret2['data']);
  1429. }
  1430. }
  1431. return responseToJson(0, '更新失败1');
  1432. }
  1433. if ($game_code == 'bq') {
  1434. $home = $pdatas['home'];
  1435. $guest = $pdatas['guest'];
  1436. $home_other = $pdatas['home_other'];
  1437. $guest_other = $pdatas['guest_other'];
  1438. $arrs = [];
  1439. for ($i = 0; $i <= 8; $i++) {
  1440. $j = $i + 1;
  1441. $arrs[$j] = [
  1442. 'home' => intval($home[$i]),
  1443. 'guest' => intval($guest[$i]),
  1444. ];
  1445. }
  1446. $arrs['other'] = [
  1447. 'home' => intval($home_other),
  1448. 'guest' => intval($guest_other),
  1449. ];
  1450. $restModel->match_score_t = $arrs;
  1451. $restModel->warn_more = json_decode($restModel->warn_more, 256);
  1452. $buyModel->single_result = json_encode([$restModel], 256);
  1453. $buyModel->result_flag = 1;
  1454. $buyModel->is_manual = 1;
  1455. $ret = $buyModel->save();
  1456. if ($ret) {
  1457. $ret2 = $this->do_win_set($order_id, $game_code, $match_id);
  1458. if ($ret2['status'] == 1) {
  1459. return responseToJson(1, '操作成功!');
  1460. } else {
  1461. return responseToJson(0, '操作失败2!--' . $ret2['data']);
  1462. }
  1463. }
  1464. return responseToJson(0, '更新失败1');
  1465. }
  1466. if ($game_code == 'wq') {
  1467. $home = $pdatas['home'];
  1468. $guest = $pdatas['guest'];
  1469. $arrs = [];
  1470. for ($i = 0; $i <= 4; $i++) {
  1471. $j = $i + 1;
  1472. $arrs[$j] = [
  1473. 'home' => intval($home[$i]),
  1474. 'guest' => intval($guest[$i]),
  1475. ];
  1476. }
  1477. $restModel->inning = $arrs;
  1478. $restModel->warn_more = json_decode($restModel->warn_more, 256);
  1479. $buyModel->single_result = json_encode([$restModel], 256);
  1480. $buyModel->result_flag = 1;
  1481. $buyModel->is_manual = 1;
  1482. $ret = $buyModel->save();
  1483. if ($ret) {
  1484. $ret2 = $this->do_win_set($order_id, $game_code, $match_id);
  1485. if ($ret2['status'] == 1) {
  1486. return responseToJson(1, '操作成功!');
  1487. } else {
  1488. return responseToJson(0, '操作失败2!--' . $ret2['data']);
  1489. }
  1490. }
  1491. return responseToJson(0, '更新失败1');
  1492. }
  1493. return responseToJson(0, '未做更新', ['order_id' => $order_id, 'game_code' => $game_code, 'match_id' => $game_code, 'datas' => $pdatas]);
  1494. }
  1495. //修复比分时用到订单信息及比赛结果数据
  1496. public function manualmatchget_v2(Req $req)
  1497. {
  1498. $order_id = isset($req->order_id) ? $req->order_id : 0;
  1499. $ScoreTitle = isset($req->ScoreTitle) ? $req->ScoreTitle : 0;
  1500. $model = new MoneyBuySimplexModel();
  1501. $ret = $model->OrderinfoResult($order_id,$ScoreTitle);
  1502. if ($ret && !empty($ret['result'])) {
  1503. return responseToJson(1, '成功', $ret);
  1504. } else {
  1505. return responseToJson(-1, 'false', $ret);
  1506. }
  1507. }
  1508. //先提交输赢,再结算
  1509. private function do_win_set($order_id, $game_code, $match_id)
  1510. {
  1511. $winret = $this->do_winfail($order_id, $game_code, $match_id);
  1512. if ($winret['status'] == 1) {
  1513. $setret = $this->do_settelement($order_id, $game_code, $match_id);
  1514. if ($setret['status'] == 1) {
  1515. return ['status' => 1, 'msg' => 'success', 'data' => []];
  1516. } else {
  1517. return ['status' => 0, 'msg' => 'failse', 'data' => $setret['msg']];
  1518. }
  1519. } else {
  1520. return ['status' => 0, 'msg' => 'failse', 'data' => $winret['msg']];
  1521. }
  1522. }
  1523. //单订单手动提交输赢计算
  1524. private function do_winfail($order_id, $game_code, $match_id)
  1525. {
  1526. $data = [
  1527. 'token' => session('adminInfo.token'), //外网
  1528. 'order_id' => $order_id,
  1529. ];
  1530. $ret = $this->request_post(config('sconstant.url') . '/DoWinFailOneOrder', $data);
  1531. return json_decode($ret, true);
  1532. }
  1533. //单订单手动提交结算
  1534. private function do_settelement($order_id, $game_code, $match_id)
  1535. {
  1536. $data = [
  1537. 'token' => session('adminInfo.token'), //外网
  1538. 'order_ids' => $order_id,
  1539. 'bettype' => 1,
  1540. 'settype' => 2,
  1541. 'game_code' => $game_code,
  1542. 'match_id' => $match_id,
  1543. 'change_status' => 0,
  1544. 'is_manual' => 1,
  1545. ];
  1546. $ret = $this->request_post(config('sconstant.url') . '/Settelement', $data);
  1547. return json_decode($ret, true);
  1548. }
  1549. private function request_post($url = '', $param = '')
  1550. {
  1551. if (empty($url) || empty($param)) {
  1552. return false;
  1553. }
  1554. $postUrl = $url;
  1555. $curlPost = $param;
  1556. $ch = curl_init();//初始化curl
  1557. curl_setopt($ch, CURLOPT_URL, $postUrl);//抓取指定网页
  1558. curl_setopt($ch, CURLOPT_HEADER, 0);//设置header
  1559. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//要求结果为字符串且输出到屏幕上
  1560. curl_setopt($ch, CURLOPT_POST, 1);//post提交方式
  1561. curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost);
  1562. $data = curl_exec($ch);//运行curl
  1563. curl_close($ch);
  1564. return $data;
  1565. }
  1566. //获取球类分类下的父级玩法数据
  1567. public function getpcode(){
  1568. $game_type = $_GET["game_type"];
  1569. $pcode = new \App\Models\StoddsCode();
  1570. $p_code = $pcode->getpcode($game_type);
  1571. return json_encode($p_code);
  1572. }
  1573. }