SoccerNoteListController.php 63 KB

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