SoccerNoteListController.php 65 KB

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