SoccerNoteListController.php 52 KB

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