SoccerNoteListController.php 55 KB

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