SoccerNoteListController.php 41 KB

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