SoccerNoteListController.php 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968
  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. *1
  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. //调整状态查询 1,2,3为订单状态 1投注 2作废 3撤单
  256. if($order_status == 1 || $order_status == 2 || $order_status == 3){
  257. $where[] = array('money_buy_simplex.status', '=', $order_status);
  258. }
  259. //4 5为结算状态 4未结算 5已结算
  260. if($order_status == 4){
  261. $status = 1;
  262. $where[] = array('money_buy_simplex.settle_status', '=', $status);
  263. }
  264. if($order_status == 5){
  265. $status = 2;
  266. $where[] = array('money_buy_simplex.settle_status', '=', $status);
  267. }
  268. /*
  269. if ($status != -1) {
  270. $where[] = array('money_buy_simplex.settle_status', '=', $status);
  271. }
  272. if ($order_status != -1) {
  273. $where[] = array('money_buy_simplex.status', '=', $order_status);
  274. }
  275. */
  276. $where[] = array('money_buy_simplex.game_code', $type);
  277. $newapp = new \App\Models\SportsNoteList();
  278. $data = $newapp->getinfo($list, $page, $where, $type);
  279. return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total'], 0, $where);
  280. }
  281. public function search(Req $req)
  282. {
  283. $request['name_chinese'] = isset($req->name_chinese) ? trim($req->name_chinese) : null;
  284. $request['sureblurs'] = isset($req->sureblurs) ? $req->sureblurs : 'on';
  285. $request['account'] = isset($req->account) ? trim($req->account) : null;
  286. $request['star_time'] = isset($req->star_time) ? trim($req->star_time) : null;
  287. $request['end_time'] = isset($req->end_time) ? trim($req->end_time) : null;
  288. $request['order_id'] = isset($req->order_id) ? trim($req->order_id) : null;
  289. $request['match_id'] = isset($req->match_id) ? trim($req->match_id) : null;
  290. $request['status'] = isset($req->status) ? trim($req->status) : '-1';
  291. $request['order_status'] = isset($req->order_status) ? trim($req->order_status) : '-1';
  292. $request['type'] = isset($req->type) ? trim($req->type) : 'zq';
  293. $dt = \App\Lib\DataTable\DataTable::init();
  294. $dt->setDataSource('/admin/SoccerNoteList/info');
  295. $dt->setLang('sportsnotelist');
  296. //$dt->addColsFields('id', array('templet' => '#userdetail', 'sort' => true, 'width' => 80));
  297. $dt->addColsFields('match_id_order', array('sort' => true, 'width' => 200));
  298. $dt->addColsFields('league', array('templet' => '#userdetail', 'sort' => false, 'width' => 100));
  299. $dt->addColsFields('home_guest', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
  300. $dt->addColsFields('content', array('templet' => '#userdetail', 'sort' => false, 'width' => 250));
  301. $dt->addColsFields('money', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
  302. $dt->addColsFields('water_return', array('templet' => '#userdetail', 'sort' => false, 'width' => 70));
  303. $dt->addColsFields('prize_money', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
  304. $dt->addColsFields('result', array('templet' => '#userdetail', 'sort' => false, 'width' => 70));
  305. $dt->addColsFields('money_match_time', array('templet' => '#userdetail', 'sort' => false, 'width' => 200));
  306. $dt->addColsFields('order_status', array('sort' => false, 'width' => 80));
  307. $dt->addColsFields('account_money', array('templet' => '#userdetail', 'sort' => false, 'width' => 110));
  308. $dt->addColsFields('settle_status', array('sort' => false, 'width' => 90));
  309. //$arr[] = 'view';
  310. // if (checkRriv('/admin/SoccerNoteList/edit')) {
  311. // $arr[] = 'edit';
  312. // }
  313. // $dt->setToolBar($arr, array('width' => 70));
  314. $dt->enableCheckBox();
  315. return view('sports/sports_search', $dt->render($request));
  316. }
  317. //冠军注单
  318. public function champion(Req $req)
  319. {
  320. $request['name_chinese'] = isset($req->name_chinese) ? trim($req->name_chinese) : null;
  321. $request['sureblurs'] = isset($req->sureblurs) ? $req->sureblurs : 'on';
  322. $request['account'] = isset($req->account) ? trim($req->account) : null;
  323. $request['star_time'] = isset($req->star_time) ? trim($req->star_time) : null;
  324. $request['end_time'] = isset($req->end_time) ? trim($req->end_time) : null;
  325. $request['order_id'] = isset($req->order_id) ? trim($req->order_id) : null;
  326. $request['match_id'] = isset($req->match_id) ? trim($req->match_id) : null;
  327. $request['status'] = isset($req->status) ? trim($req->status) : '-1';
  328. $request['order_status'] = isset($req->order_status) ? trim($req->order_status) : '-1';
  329. $request['type'] = isset($req->type) ? trim($req->type) : 'zq';
  330. $dt = \App\Lib\DataTable\DataTable::init();
  331. $dt->setDataSource('/admin/SoccerNoteList/championinfo');
  332. $dt->setLang('sportsnotelist');
  333. //$dt->addColsFields('id', array('templet' => '#userdetail', 'sort' => true, 'width' => 80));
  334. $dt->addColsFields('lg_id_order', array('sort' => true, 'width' => 200));
  335. $dt->addColsFields('league', array('templet' => '#userdetail', 'sort' => false, 'width' => 100));
  336. $dt->addColsFields('home_guest', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
  337. $dt->addColsFields('content', array('templet' => '#userdetail', 'sort' => false, 'width' => 250));
  338. $dt->addColsFields('money', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
  339. $dt->addColsFields('water_return', array('templet' => '#userdetail', 'sort' => false, 'width' => 70));
  340. $dt->addColsFields('prize_money', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
  341. $dt->addColsFields('result', array('templet' => '#userdetail', 'sort' => false, 'width' => 70));
  342. $dt->addColsFields('money_match_time', array('templet' => '#userdetail', 'sort' => false, 'width' => 200));
  343. $dt->addColsFields('order_status', array('sort' => false, 'width' => 80));
  344. $dt->addColsFields('account_money', array('templet' => '#userdetail', 'sort' => false, 'width' => 110));
  345. $dt->addColsFields('game_status', array('sort' => false, 'width' => 90));
  346. //$arr[] = 'view';
  347. // if (checkRriv('/admin/SoccerNoteList/edit')) {
  348. // $arr[] = 'edit';
  349. // }
  350. // $dt->setToolBar($arr, array('width' => 70));
  351. $dt->enableCheckBox();
  352. return view('sports/sports_search', $dt->render($request));
  353. }
  354. function championinfo()
  355. {
  356. $page = Request::has('page') ? Request::get('page') : '';
  357. $list = Request::has('limit') ? Request::get('limit') : 10;
  358. $account = Request::get('account') ? Request::get('account') : '';
  359. $star_time = Request::get('star_time') ? Request::get('star_time') . ' 00:00:00' : '';
  360. $end_time = Request::get('end_time') ? Request::get('end_time') . ' 23:59:59' : '';
  361. $order_id = Request::get('order_id') ? Request::get('order_id') : '';
  362. $match_id = Request::get('match_id') ? Request::get('match_id') : '';
  363. $status = Request::has('status') ? Request::get('status') : '';
  364. $order_status = Request::has('order_status') ? Request::get('order_status') : '';
  365. $sureblur = Request::has('sureblurs') ? Request::get('sureblurs') : 'off';
  366. $type = Request::has('type') ? Request::get('type') : 'zq';
  367. $where = array();
  368. $where[] = array('money_buy_simplex.is_champion', 1);
  369. if (!empty($account)) {
  370. if (empty($sureblur) || $sureblur == 'off') {
  371. $where[] = array('money_buy_simplex.account_name', 'like', '%' . $account . '%');
  372. } else {
  373. $where[] = array('money_buy_simplex.account_name', '=', $account);
  374. }
  375. }
  376. if (!empty($star_time)) {
  377. if (!empty($end_time)) {
  378. $where[] = array('money_buy_simplex.money_time', '>', $star_time);
  379. $where[] = array('money_buy_simplex.money_time', '<', $end_time);
  380. } else {
  381. $where[] = array('money_buy_simplex.money_time', '>', $star_time);
  382. }
  383. } else if (empty($star_time)) {
  384. if (!empty($end_time)) {
  385. $where[] = array('money_buy_simplex.money_time', '<', $end_time);
  386. }
  387. }
  388. if (!empty($order_id)) {
  389. $where[] = array('money_buy_simplex.order_id', $order_id);
  390. }
  391. if (!empty($match_id)) {
  392. $where[] = array('money_buy_simplex.match_id', $match_id);
  393. }
  394. //调整状态查询 1,2,3为订单状态 1投注 2作废 3撤单
  395. if($order_status == 1 || $order_status == 2 || $order_status == 3){
  396. $where[] = array('money_buy_simplex.status', '=', $order_status);
  397. }
  398. //4 5为结算状态 4未结算 5已结算
  399. if($order_status == 4){
  400. $status = 1;
  401. $where[] = array('money_buy_simplex.settle_status', '=', $status);
  402. }
  403. if($order_status == 5){
  404. $status = 2;
  405. $where[] = array('money_buy_simplex.settle_status', '=', $status);
  406. }
  407. /*
  408. if ($status != -1) {
  409. $where[] = array('money_buy_simplex.settle_status', '=', $status);
  410. }
  411. if ($order_status != -1) {
  412. $where[] = array('money_buy_simplex.status', '=', $order_status);
  413. }
  414. */
  415. $where[] = array('money_buy_simplex.game_code', $type);
  416. $newapp = new \App\Models\SportsNoteList();
  417. $data = $newapp->getinfo($list, $page, $where, $type);
  418. return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total'], 0, $where);
  419. }
  420. //查询赛事结果
  421. // function Sairesult(Req $req){
  422. // $did = $req->did;
  423. // $qlgame = $req->qlgame?$req->qlgame:'zq';
  424. // $newapp = \App\Models\SportsNoteList::where('id', $did)->first();
  425. // if($qlgame=='zq'){
  426. // if($newapp['match_id']){
  427. // $newre = new \App\Models\Stzqresult();
  428. // $teamname = $newre->matchjg($newapp['match_id']);
  429. // }else{
  430. // $teamname ='';
  431. // }
  432. // }elseif($qlgame=='lq'){
  433. // if($newapp['match_id']){
  434. // $newre = new \App\Models\Stlqresult();
  435. // $teamname = $newre->matchjg($newapp['match_id']);
  436. // }else{
  437. // $teamname ='';
  438. // }
  439. // }elseif($qlgame=='bq'){
  440. // if($newapp['match_id']){
  441. // $newre = new \App\Models\Stbqresult();
  442. // $teamname = $newre->matchjg($newapp['match_id']);
  443. // }else{
  444. // $teamname ='';
  445. // }
  446. // }elseif($qlgame=='wq'){
  447. // if($newapp['match_id']){
  448. // $newre = new \App\Models\Stwqresult();
  449. // $teamname = $newre->matchjg($newapp['match_id']);
  450. // }else{
  451. // $teamname ='';
  452. // }
  453. // }else{
  454. // $data = "参数错误";
  455. // }
  456. // $data =array(
  457. // 'singleresult' => json_decode($newapp['single_result'],true),
  458. // 'teamname' => $teamname,
  459. // );
  460. // return $data;
  461. // }
  462. // function Sairesult(Req $req){
  463. // $did = $req->did;
  464. // $model = \App\Models\SportsNoteList::where('id', $did)->first();
  465. // $pid = $model['match_id'];
  466. // $saisjg = \App\Models\Stzqresult::where('match_id',$pid)->first()->toArray();//赛事结果
  467. // $saisjg['corner_ball'] = json_decode($saisjg['corner_ball'],true);
  468. // $saisjg['first_score'] = json_decode($saisjg['first_score'],true);
  469. // $saisjg['penalty_card'] = json_decode($saisjg['penalty_card'],true);
  470. // $saisjg['warn_more'] = json_decode($saisjg['warn_more'],true);
  471. // }
  472. //结果添加
  473. function addend(Req $req)
  474. {
  475. $did = $req->did;//59;//
  476. $qlgame = $req->qlgame;//1;
  477. $model = \App\Models\SportsNoteList::where('id', $did)->first();
  478. $pid = $model['match_id'];
  479. if ($qlgame == 1) {
  480. if ($model['result_flag'] != 1) {
  481. $saisjg = \App\Models\Stzqresult::where('match_id', $pid)->first()->toArray();//赛事结果
  482. $saisjg['corner_ball'] = json_decode($saisjg['corner_ball'], true);
  483. $saisjg['first_score'] = json_decode($saisjg['first_score'], true);
  484. $saisjg['penalty_card'] = json_decode($saisjg['penalty_card'], true);
  485. $saisjg['warn_more'] = json_decode($saisjg['warn_more'], true);
  486. $model->single_result = json_encode([$saisjg], JSON_UNESCAPED_UNICODE);
  487. $model->save();
  488. }
  489. $newm = \App\Models\SportsNoteList::where('id', $did)->first();
  490. return $newm['single_result'];
  491. } else {
  492. $new = \App\Models\SportsNoteList::where('id', $did)->first();
  493. $newa = json_decode($new['single_result'], true);
  494. $newa[0]['home_score'] = $req->home_score;//主队进球
  495. $newa[0]['guest_score'] = $req->guest_score;//客队进球
  496. $newa[0]['all_goal'] = intval($req->guest_score) + intval($req->home_score);//总进球
  497. $newa[0]['last_score'] = $req->lastscore ? $req->lastscore : '';//最后进球球队
  498. $newa[0]['match_winer'] = $req->matchwiner ? $req->matchwiner : '';//赢球球队
  499. $newa[0]['update_time'] = time();//更新时间
  500. $newa[0]['u_guest_score'] = $req->u_guest_score;//上半场-主队进球数
  501. $newa[0]['u_home_score'] = $req->u_home_score;//上半场-客队进球数
  502. $newa[0]['penalty_card'] = array(
  503. 'home' => $req->homeallcard,
  504. 'guest' => $req->guestallcard,
  505. 'home_half' => $req->homehalfcard,
  506. 'guest_half' => $req->guesthalfcard,
  507. );
  508. $newa[0]['corner_ball'] = array(
  509. 'home' => $req->homeallcorner,
  510. 'guest' => $req->guestallcorner,
  511. 'home_half' => $req->homehalfcorner,
  512. 'guest_half' => $req->guesthalfcorner,
  513. );
  514. //最新进球
  515. $newa[0]['first_score'] = array(
  516. 'teamscore' => $req->firstscore ? $req->firstscore : 0,//最先进球球队
  517. 'scoretime' => $req->onescoretime ? $req->onescoretime : '',//进球时间
  518. 'scoretype' => $req->firststye ? $req->firststye : '',//进球方式
  519. );
  520. $model->single_result = json_encode($newa, JSON_UNESCAPED_UNICODE);
  521. $model->result_flag = 1;
  522. $model->save();
  523. return responseToJson(1);
  524. }
  525. }
  526. function getinfo()
  527. {
  528. $page = Request::has('page') ? Request::get('page') : '';
  529. $list = Request::has('limit') ? Request::get('limit') : 10;
  530. $account = Request::get('account') ? Request::get('account') : '';
  531. $star_time = Request::get('star_time') ? Request::get('star_time') . ' 00:00:00' : '';
  532. $end_time = Request::get('end_time') ? Request::get('end_time') . ' 23:59:59' : '';
  533. $order_id = Request::get('order_id') ? Request::get('order_id') : '';
  534. $match_id = Request::get('match_id') ? Request::get('match_id') : '';
  535. $status = Request::has('status') ? Request::get('status') : '-1';
  536. $order_status = Request::has('order_status') ? Request::get('order_status') : '';
  537. $sureblur = Request::has('sureblurs') ? Request::get('sureblurs') : 'off';
  538. $type = Request::has('type') ? Request::get('type') : 'zq';
  539. $where = array();
  540. $where[] = array('money_buy_simplex.is_champion','<>',1);
  541. if (!empty($account)) {
  542. if (empty($sureblur) || $sureblur == 'off') {
  543. $where[] = array('money_buy_simplex.account_name', 'like', '%' . $account . '%');
  544. } else {
  545. $where[] = array('money_buy_simplex.account_name', '=', $account);
  546. }
  547. }
  548. if (!empty($star_time)) {
  549. if (!empty($end_time)) {
  550. $where[] = array('money_buy_simplex.money_time', '>', $star_time);
  551. $where[] = array('money_buy_simplex.money_time', '<', $end_time);
  552. } else {
  553. $where[] = array('money_buy_simplex.money_time', '>', $star_time);
  554. }
  555. } else if (empty($star_time)) {
  556. if (!empty($end_time)) {
  557. $where[] = array('money_buy_simplex.money_time', '<', $end_time);
  558. }
  559. }
  560. if (!empty($order_id)) {
  561. $where[] = array('money_buy_simplex.order_id', $order_id);
  562. }
  563. if (!empty($match_id)) {
  564. $where[] = array('money_buy_simplex.match_id', $match_id);
  565. }
  566. //调整状态查询 1,2,3为订单状态 1投注 2作废 3撤单
  567. if($order_status == 1 || $order_status == 2 || $order_status == 3){
  568. $where[] = array('money_buy_simplex.status', '=', $order_status);
  569. }
  570. //4 5为结算状态 4未结算 5已结算
  571. if($order_status == 4){
  572. $status = 1;
  573. $where[] = array('money_buy_simplex.settle_status', '=', $status);
  574. }
  575. if($order_status == 5){
  576. $status = 2;
  577. $where[] = array('money_buy_simplex.settle_status', '=', $status);
  578. }
  579. /*
  580. if ($status != -1) {
  581. $where[] = array('money_buy_simplex.settle_status', '=', $status);
  582. }
  583. if ($order_status != -1) {
  584. $where[] = array('money_buy_simplex.status', '=', $order_status);
  585. }
  586. */
  587. $where[] = array('money_buy_simplex.game_code', $type);
  588. $newapp = new \App\Models\SportsNoteList();
  589. $data = $newapp->info($list, $page, $where, $type);
  590. //$alldata = Models\MoneyBuyMatch::where('bet_type',1)->where('is_rolling',1)->distinct('order_id')->count('order_id');
  591. return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total'], 0, $where);
  592. }
  593. /**
  594. *单式注单作废
  595. */
  596. public function invalid(Req $req)
  597. {
  598. $id = $req->id;
  599. $reason = $_GET['reason'];
  600. if (intval($id) < 1) {
  601. return -1;
  602. }
  603. $order = \App\Models\SportsNoteList::where('id', $id)->first();
  604. //用戶账户金额
  605. $account_money = \App\Models\Account_detailed::where('account_identity', $order->account_identity)->first();
  606. //反水
  607. $water_return_money = \App\Models\Money_details::where('trade_id', $order->order_id)->where('trade_type', '7')->first();
  608. if (!empty($water_return_money)) {
  609. $water_return = $water_return_money->money;
  610. } else {
  611. $water_return = 0;
  612. }
  613. //撤单后用户账户金额
  614. $available_cash = $account_money->available_cash;
  615. $new_available_cash = $available_cash + $order->money - $order->gain_money - $water_return;
  616. $model = new \App\Models\Money_details();
  617. $model->info_identity = UUID();
  618. $model->trade_id = $order->order_id;
  619. $model->account_name = $order->account_name;
  620. $model->account_identity = $order->account_identity;
  621. $model->money = abs($order->money - $order->gain_money - $water_return);
  622. $model->money_time = date("Y-m-d H:i:s", time());
  623. if ($new_available_cash > $available_cash) {
  624. $model->money_type = '1';
  625. } else {
  626. $model->money_type = '2';
  627. }
  628. $model->money_cash = $new_available_cash;
  629. $model->trade_type = '3';
  630. $model->trade_desc = '管理员作废单式注单';
  631. $model->status = '1';
  632. try {
  633. DB::beginTransaction();//开启事务
  634. \App\Models\SportsNoteList::where('id', $id)->update(['status' => '2', 'gain_money' => '0', 'use_mark' => $reason]);
  635. \App\Models\Account_detailed::where('account_identity', $order->account_identity)->update(['available_cash' => $new_available_cash, 'cash' => $new_available_cash]);
  636. $model->save();
  637. DB::commit();//提交
  638. return 1;
  639. } catch (Exception $e) {
  640. DB::rollback();//回滚
  641. return -1;
  642. }
  643. }
  644. /**
  645. *单式注单首次结算
  646. */
  647. public function settlement(Req $req)
  648. {
  649. $id = $req->id;
  650. if (intval($id) < 1) {
  651. return -1;
  652. }
  653. $order = \App\Models\SportsNoteList::where('id', $id)->first();
  654. $order_id = $order->order_id;
  655. $order_ids = array($order->order_id);
  656. $match_id = $order->match_id;
  657. $game_code = $order->game_code;
  658. $bet_type = 1;//单式注单
  659. //return $match_id;
  660. //判断输赢
  661. $settlementWinFail = new SettlementWinFail();
  662. $res = $settlementWinFail->ProcWinInfoByOneOrder($match_id, $order_id, $bet_type);
  663. //结算
  664. $SettlementOrder = new SettlementOrder();
  665. $settype = 1; //首次结算
  666. $data = $SettlementOrder->reSettlement($order_ids, $bet_type, $settype, $game_code, $match_id, $match_status = 0);
  667. return $data;
  668. }
  669. /**
  670. *单式注单重新结算
  671. */
  672. // public function resettlement(Req $req) {
  673. // $id = $req->id;
  674. // if (intval($id) < 1) {
  675. // return -1;
  676. // }
  677. // $order = \App\Models\SportsNoteList::where('id',$id)->first();
  678. // $match_id = $order->match_id;
  679. // $game_code = $order->game_code;
  680. // $order_id = $order->order_id;
  681. // $order_ids = array($order->order_id);
  682. // //return $match_id;
  683. // $bet_type = 1;//单式注单
  684. // //重新判断输赢
  685. // $settlementWinFail = new SettlementWinFail();
  686. // $res = $settlementWinFail->ProcWinInfoByOneOrder($match_id, $order_id, $bet_type);
  687. // //结算
  688. // $SettlementOrder = new SettlementOrder();
  689. // $settype = 2; //重新结算
  690. // $data = $SettlementOrder->reSettlement($order_ids,$bet_type,$settype,$game_code,$match_id,$match_status=0);
  691. // return $data;
  692. // }
  693. public function resettlement(Req $req)
  694. {
  695. $order_id = $req->order_id;
  696. $type = $req->type;
  697. $match_id = $req->match_id;
  698. $jsurl = config('sconstant.url');//结算请求域名地址
  699. $token = session('adminInfo.token');
  700. //查询是否有订单
  701. $newapp = new \App\Models\SportsNoteList();
  702. $simplexnum = $newapp->onlyorder($order_id);
  703. if ($simplexnum == 1) {
  704. $requet = file_get_contents($jsurl . "/DoWinFailOneOrder?order_id=" . $order_id . "&token=" . $token);
  705. if (json_decode($requet, true)['status'] == 1) {
  706. $napp = new \App\Models\Stzqresult();
  707. $simplex = array(
  708. 'token' => $token,
  709. 'order_ids' => $order_id, //订单id字符串,用半角都好分隔
  710. 'bettype' => 1, //结算类型 1单式 2串式
  711. 'settype' => 2, //结算次数 1首次 2非首冷饮
  712. 'game_code' => $type, //赛事类型 zq lq wq bq
  713. 'match_id' => $match_id, // 赛事ID
  714. 'change_status' => 0 //是否改状态
  715. );
  716. $url = $jsurl . '/Settelement';
  717. $simplex_res = $napp->post_curls($url, $simplex);//返回json
  718. $huawei_res = json_decode($simplex_res, true);
  719. if ($huawei_res['status'] == 1) {
  720. return json_encode(['status' => 1, 'msg' => '结算成功']);
  721. } else {
  722. return json_encode(['status' => 4, 'msg' => '结算失败']);
  723. }
  724. } else {
  725. return json_encode(['status' => 3, 'msg' => '输赢判断错误']);
  726. }
  727. } else {
  728. return json_encode(['status' => 2, 'msg' => '订单不存在']);
  729. }
  730. }
  731. /**
  732. *单式注单批量结算
  733. */
  734. public function batchsettlement()
  735. {
  736. $orders = \App\Models\SportsNoteList::where('settle_status', '1')->get();
  737. $order_ids = array();
  738. for ($i = 0; $i < count($orders); $i++) {
  739. $result = \App\Models\MoneyBuyMatch::where('batch_id', $orders[$i]->batch_id)->where('match_id', $orders[$i]->match_id)->get();
  740. $res = array();
  741. for ($j = 0; $j < count($result); $j++) {
  742. $res[] = $result[$j]->result;
  743. }
  744. if (!in_array(0, $res)) {
  745. $order_ids[] = $orders[$i]->order_id;
  746. }
  747. }
  748. $SettlementOrder = new SettlementOrder();
  749. $bet_type = 1;//单式注单
  750. $data = $SettlementOrder->reSettlement($order_ids, $bet_type);
  751. return $data;
  752. }
  753. /**
  754. *删除订单
  755. */
  756. public function delete(Req $req)
  757. {
  758. $id = $req->input('id');
  759. if (empty($id)) {
  760. return responseToJson(-2001); //id
  761. }
  762. $ids = explode(',', $id);
  763. if (!is_array($ids) && intval($ids) < 0) {
  764. return responseToJson(-2002); //id
  765. }
  766. if (is_array($ids) && count($ids) > 0) {
  767. foreach ($ids as $k => $v) {
  768. if (intval($v) < 1) {
  769. unset($ids[$k]);
  770. }
  771. }
  772. }
  773. $rows = \App\Models\SportsNoteList::whereIn('id', $ids)->delete();
  774. if (!$rows) {
  775. return responseToJson(-2003); //id
  776. }
  777. return responseToJson(1, trans('menu.delete_success')); //id
  778. }
  779. /**
  780. * 投注金额统计
  781. */
  782. function moneycount()
  783. {
  784. $where = Request::has('where') ? Request::get('where') : '';
  785. $type = Request::has('type') ? Request::get('type') : 'zq';
  786. $db = new \App\Models\SportsNoteList;
  787. $data = $db->MoneyCount($where, $type);
  788. return responseToJson($data);
  789. }
  790. //单式订单数据
  791. public function manualmatchget(Req $req)
  792. {
  793. $order_id = isset($req->order_id) ? $req->order_id : 0;
  794. $model = new \App\Models\SportsNoteList();
  795. $ret = $model->getorder($order_id);
  796. if ($ret) {
  797. // $league = db('st_'.$ret->game_code.'_league')->where('id',$ret->lg_id)->first();
  798. // $ret->league = $league->name_chinese;
  799. $modelcode = new \App\Models\StoddsCode();
  800. $opcode_nameArr = $modelcode->getTypeDatas($ret->game_code);
  801. $ret = $ret->toArray();
  802. foreach ($ret['matchdatas'] as $key => $val) {
  803. $tmp_pcode = $val['p_code'];
  804. $tmp_code = $val['odds_code'];
  805. $ret['matchdatas'][$key]['odds_name'] = isset($opcode_nameArr[$tmp_pcode][$tmp_code]['odds_name']) ? $opcode_nameArr[$tmp_pcode][$tmp_code]['odds_name'] : '';
  806. }
  807. return responseToJson(1, '成功', $ret);
  808. } else {
  809. return responseToJson(-1, 'false', $ret);
  810. }
  811. }
  812. //单式订单直接手动更改输赢结果并结算
  813. public function manualmatchpdate(Req $req)
  814. {
  815. $order_id = isset($req->order_id) ? $req->order_id : 0;
  816. $datas = isset($req->matchdata) ? $req->matchdata : [];
  817. $datas = json_decode($datas, true);
  818. if (empty($order_id) || empty($datas)) {
  819. return responseToJson(-1, '参数不能为空!');
  820. }
  821. $model = new \App\Models\SportsNoteList();
  822. $modeldata = $model->getorder($order_id);
  823. if (empty($modeldata)) {
  824. return responseToJson(-1, 'false');
  825. }
  826. $sdataArr = [];
  827. foreach ($datas as $val) {
  828. $tmp_id = $val['id'];
  829. $tmp_result = intval($val['result']);
  830. $tmp_matchword = trim($val['matchresult']);
  831. if (!in_array($tmp_result, [-1, 1, 2, 3, 4])) {
  832. continue;
  833. }
  834. $sdataArr[$tmp_id] = ['result' => $tmp_result, 'matchresult' => $tmp_matchword];
  835. }
  836. if (empty($sdataArr)) {
  837. return responseToJson(-2, '没有要更新的数据');
  838. }
  839. $chageNum = 0;
  840. foreach ($modeldata->matchdatas as $key => $val) {
  841. $id = $val->id;
  842. if (isset($sdataArr[$id])) {
  843. if ($val->result != $sdataArr[$id]['result'] || $val->matchwork != $sdataArr[$id]['matchresult']) {
  844. $val->result = $sdataArr[$id]['result'];
  845. $val->matchresult = $sdataArr[$id]['matchresult'];
  846. $val->save();
  847. $chageNum++;
  848. }
  849. }
  850. }
  851. if ($chageNum) {
  852. $modeldata->is_manual = 1;
  853. $modeldata->save();
  854. } else {
  855. return responseToJson(1, '没有更新操作数据!');
  856. }
  857. $data = [
  858. 'token' => session('adminInfo.token'), //外网
  859. 'order_ids' => $modeldata->order_id,
  860. 'bettype' => 1,
  861. 'settype' => 2,
  862. 'game_code' => $modeldata->game_code,
  863. 'match_id' => $modeldata->match_id,
  864. 'change_status' => 0,
  865. 'is_manual' => 1,
  866. ];
  867. $ret = $this->request_post(config('sconstant.url') . '/Settelement', $data);
  868. $retjson = json_decode($ret, true);
  869. if (isset($retjson['status']) && $retjson['status'] == 1) {
  870. $model->where('order_id', $order_id)->update(['settle_status' => 2]);
  871. }
  872. return responseToJson(1, '更新成功');
  873. }
  874. private function request_post($url = '', $param = '')
  875. {
  876. if (empty($url) || empty($param)) {
  877. return false;
  878. }
  879. $postUrl = $url;
  880. $curlPost = $param;
  881. $ch = curl_init();//初始化curl
  882. curl_setopt($ch, CURLOPT_URL, $postUrl);//抓取指定网页
  883. curl_setopt($ch, CURLOPT_HEADER, 0);//设置header
  884. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//要求结果为字符串且输出到屏幕上
  885. curl_setopt($ch, CURLOPT_POST, 1);//post提交方式
  886. curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost);
  887. $data = curl_exec($ch);//运行curl
  888. curl_close($ch);
  889. return $data;
  890. }
  891. }