SportsfootController.php 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056
  1. <?php
  2. namespace App\Http\Controllers\Admin;
  3. use App\Http\Controllers\Controller;
  4. use Illuminate\Http\Request as Req;
  5. use Illuminate\Support\Facades\DB;
  6. Use App\Lib\Settlement\SettlementOrder;
  7. use App\Models;
  8. use Request;
  9. use App\Lib\Biz\Sport\Common as commonFunction;
  10. /**
  11. *足球结算
  12. */
  13. class SportsfootController extends Controller {
  14. function Settlement(Req $req){
  15. $jsurl = config('sconstant.url');//结算请求域名地址
  16. $match_id = $req->match_id;
  17. $type = $req->type;
  18. $token = session('adminInfo.token');
  19. $notice = \App\Models\Comendnotice::where('match_id', $match_id)->first();
  20. if(!$notice){
  21. return json_encode(['status'=>5,'msg'=>'请先核对结果,并提交结果']);
  22. }
  23. $noticeid = $notice['id'];
  24. //查询赛事单式是否有订单(足球)
  25. $newapp = new \App\Models\MoneyBuyMatch();
  26. $simplex_ids = array_column($newapp->simsettleorder($match_id,'zq'),'order_id');
  27. $str_ids = array_column($newapp->strsettleorder($match_id),'order_id');
  28. //去重
  29. $simplex_ids = array_unique($simplex_ids);
  30. $str_ids = array_unique($str_ids);
  31. //判断赛事下注单输赢
  32. $datas = array('noticeid' => $noticeid , 'token' => $token);
  33. $settlementAuto = new \App\Lib\Settlement\SettlementAuto();
  34. $winfail = $settlementAuto->SubmitSettelement('w',$datas);
  35. if($winfail == false){
  36. return json_encode(['status'=>2,'msg'=>'判断输赢错误,请联系管理员!!!']);//输赢错误
  37. }
  38. $sim = array(
  39. 'token'=>$token,
  40. 'order_ids'=>'', //订单id字符串,用半角都好分隔
  41. 'bettype'=>1, //结算类型 1单式 2串式
  42. 'settype'=>2, //结算次数 1首次 2非首次
  43. 'game_code'=>$type, //赛事类型 zq lq wq bq
  44. 'match_id'=>$match_id, // 赛事ID
  45. 'change_status'=>1 //是否改状态
  46. );
  47. $str = array(
  48. 'token'=>$token,
  49. 'order_ids'=>'', //订单id字符串,用半角都好分隔
  50. 'bettype'=>2, //结算类型 1单式 2串式
  51. 'settype'=>2, //结算次数 1首次 2非首次
  52. 'game_code'=>$type, //赛事类型 zq lq wq bq
  53. 'match_id'=>$match_id, // 赛事ID
  54. 'change_status'=>1 //是否改状态
  55. );
  56. if(count($simplex_ids)>0 || count($str_ids)>0){
  57. //单式结算
  58. if(count($simplex_ids)>0 && count($str_ids)==0){
  59. $sim['order_ids'] = implode(',',$simplex_ids);
  60. $settlesim = $settlementAuto->SubmitSettelement('s',$sim);
  61. if($settlesim == false){
  62. return json_encode(['status'=>3,'msg'=>'单式注单结算有误,请联系管理员!!!']);
  63. }else{
  64. return json_encode(['status'=>1,'msg'=>'单式结算成功,没有串式订单']);
  65. }
  66. }
  67. //串式结算
  68. elseif(count($str_ids)>0 && count($simplex_ids)==0){
  69. $str['order_ids'] = implode(',',$str_ids);
  70. $settlestr = $settlementAuto->SubmitSettelement('s',$str);
  71. if($settlestr == false){
  72. return json_encode(['status'=>3,'msg'=>'串式注单结算有误,请联系管理员!!!']);
  73. }else{
  74. return json_encode(['status'=>1,'msg'=>'串式结算成功,没有单式订单']);
  75. }
  76. }
  77. //既有单式也有串式
  78. elseif(count($str_ids)>0 && count($simplex_ids)>0){
  79. $sim['order_ids'] = implode(',',$simplex_ids);
  80. $str['order_ids'] = implode(',',$str_ids);
  81. $settlesim = $settlementAuto->SubmitSettelement('s',$sim);
  82. $settlestr = $settlementAuto->SubmitSettelement('s',$str);
  83. if($settlesim == true || $settlestr == true){
  84. return json_encode(['status'=>1,'msg'=>'结算成功']);
  85. }else{
  86. return json_encode(['status'=>3,'msg'=>'结算有误,请联系管理员!!!']);
  87. }
  88. }
  89. }else{
  90. $log = array(
  91. session('adminInfo.admin_name'),
  92. );
  93. OperationLog(session('adminInfo.admin_id'), '足球结算', $log);
  94. $res = \App\Models\Stzqresult::where ('match_id', $match_id)->update(['status' =>3]);
  95. $res = \App\Models\SportsSoccer::where ('id', $match_id)->update(['status' =>3]);
  96. return json_encode(['status'=>4,'msg'=>'该赛事没有任何订单,将会结束该赛事!!!']);
  97. }
  98. }
  99. //添加危险球列表
  100. function addwarn(Req $req){
  101. $match_id = $req->match_id;
  102. $warn = \App\Models\Stzqresult::where('match_id', $match_id)->select("warn_more")->first();
  103. $warnmore = json_decode($warn['warn_more'],true);
  104. $sousuo = $req->sousuo?$req->sousuo:'';
  105. if($sousuo){
  106. $shuzu = array();
  107. for ($i=0; $i < count($warnmore); $i++) {
  108. if($warnmore[$i]['rtype']==$sousuo){
  109. $shuzu[$i]['timei'] = $warnmore[$i]['timei'];
  110. $shuzu[$i]['rtype'] = $warnmore[$i]['rtype'];
  111. $shuzu[$i]['timep'] = $warnmore[$i]['timep'];
  112. }
  113. }
  114. $shuzu = array_values($shuzu);
  115. $warnmore = $shuzu;
  116. // $warnmore[0]['timei'] = 10000;
  117. }
  118. if($warnmore[0]['timei']!="1970-1-1 0:0:1"){
  119. $request['warnmore'] = $warnmore;
  120. // $request['warnmore'][0]['rtype'] = $sousuo;1
  121. }else{
  122. $request['warnmore'] = '';
  123. }
  124. $request['match_id'] = $match_id;
  125. $request['sousuo'] = $sousuo;
  126. return view('admin.sportsfoot/addwarn', $request);
  127. }
  128. //获取指定赛事危险球数据
  129. function getWarnData(Req $req){
  130. $match_id = $req->match_id;
  131. $warnonlys = \App\Models\Stzqresult::where('match_id', $match_id)->select("warn_more","start_time")->first();
  132. $warn_more = json_decode($warnonlys['warn_more'],true);
  133. if(!empty($warn_more)){
  134. $data = [];
  135. foreach($warn_more as $k=>$v){
  136. $v['id'] =$k+1;
  137. $data[$k] = $v;
  138. }
  139. }
  140. if($data[0]['timei']=="1970-1-1 0:0:1"){
  141. $data = [];
  142. }
  143. return \App\Lib\DataTable\DataTable::init()->toJson($data);
  144. }
  145. //危险球查询
  146. function warnresult(Req $req){
  147. $match_id = $req->match_id;
  148. $wid = $req->wid;
  149. $typenum = $req->typenum;
  150. $warnonlys = \App\Models\Stzqresult::where('match_id', $match_id)->select("warn_more","start_time")->first();
  151. $warn_data = json_decode($warnonlys['warn_more'],true);
  152. if($typenum == 10000){ //添加危险球时,默认出现时间为赛事开始时间
  153. $warn_data[0] =[
  154. 'timei' =>$warnonlys['start_time'],
  155. 'rtype' =>0,
  156. 'timep' =>90
  157. ];
  158. }
  159. $warno = array(
  160. 'warn_more' => $warn_data,
  161. 'starttime' => $warnonlys['start_time'],
  162. 'endtime'=> date("Y-m-d H:i:s", strtotime("+2 hour",strtotime($warnonlys['start_time']))),//$warnonlys['start_time']
  163. );
  164. return $warno;
  165. }
  166. //添加编辑危险球
  167. function addwarnonly(Req $req){
  168. //编辑对象值
  169. $wid = ($req->wid);
  170. //赛事id
  171. $matchid = $req->match_id;
  172. /*
  173. //出现危险球的分钟数
  174. $time_i = $req->time_i;
  175. //出现危险球的秒数
  176. $time_s = $req->time_s;
  177. //危险球审核有效时间 秒
  178. */
  179. $timei = $req->time_i;
  180. $timep = $req->time_p;
  181. //危险球类型
  182. $rtype = $req->warn_type;
  183. //验证是否是首次添加危险球
  184. $typenum = $req->type_num;
  185. if(empty($matchid) || empty($timep) || empty($rtype)) return json_encode(['status'=>2,'msg'=>'设置数据异常']);
  186. $model = \App\Models\Stzqresult::where('match_id', $matchid)->select("warn_more","start_time","status")->first()->toArray();
  187. // if($model['status'] != 2) return json_encode(['status'=>3,'msg'=>'赛事未结束,不能设置危险球']);
  188. /*
  189. //赛事开赛时间
  190. $match_time = $model['start_time'];
  191. //危险球出现进行时间 秒
  192. $warn_time_s = ($time_i*60)+$time_s;
  193. //危险球出现时间 == 开赛时间+进行时间 秒
  194. $timei = date('Y-m-d H:i:s',strtotime($match_time)+$warn_time_s);
  195. */
  196. //该赛事的单式注单
  197. $orders = array();
  198. $otherorders = array();
  199. $account_identitys = array();
  200. $order_ids = array();
  201. $order = \App\Models\SportsNoteList::where('match_id',$matchid)->get();
  202. if(!empty($order)){
  203. for ($c=0; $c < count($order); $c++){
  204. if(strtotime($timei) >= strtotime($order[$c]['money_time']) && strtotime($timei)-$timep <= strtotime($order[$c]['money_time'])){
  205. $orders[] = $order[$c];
  206. $account_identitys[] = $order[$c]['account_identity'];
  207. $order_ids[] = $order[$c]['order_id'];
  208. }else{
  209. $otherorders[] = $order[$c]['id'];
  210. }
  211. }
  212. }
  213. //危险球范围外的注单自动审核通过
  214. //return $otherorders;
  215. if(!empty($otherorders)){
  216. \App\Models\SportsNoteList::wherein('id', $otherorders)->update(['roll_ratify' => '1']);
  217. }
  218. //return $account_identitys;
  219. $sel = json_decode($model['warn_more'],true);
  220. $addru = array(
  221. array(
  222. 'timei'=>$timei,
  223. 'timep'=>$timep,
  224. 'rtype'=>$rtype,
  225. ),
  226. );
  227. if($typenum==10000){
  228. if($sel[0]['timei']=="1970-1-1 0:0:1"){
  229. //首次添加
  230. $res = \App\Models\Stzqresult::where ('match_id', $matchid)->update(['warn_more' => json_encode($addru,JSON_UNESCAPED_UNICODE)]);
  231. }else{
  232. //再次添加
  233. $upnum = array_merge_recursive($sel,$addru);
  234. $res = \App\Models\Stzqresult::where ('match_id', $matchid)->update(['warn_more' => json_encode($upnum,JSON_UNESCAPED_UNICODE)]);
  235. }
  236. }else{
  237. //编辑
  238. for ($i=0; $i < count($sel); $i++) {
  239. $sel[$wid]['timei'] = $timei;
  240. $sel[$wid]['timep'] = $timep;
  241. $sel[$wid]['rtype'] = $rtype;
  242. }
  243. $res = \App\Models\Stzqresult::where ('match_id', $matchid)->update(['warn_more' => json_encode($sel,JSON_UNESCAPED_UNICODE)]);
  244. }
  245. //用戶账户金额
  246. $account_money = \App\Models\Account_detailed::wherein('account_identity',$account_identitys)->get();
  247. //反水
  248. $water_return_money = \App\Models\Money_details::wherein('trade_id',$order_ids)->where('trade_type', '7')->get();
  249. if(!empty($orders)){
  250. for($i=0;$i<count($orders);$i++){
  251. for($a=0;$a<count($account_money);$a++){
  252. if($orders[$i]['account_identity'] == $account_money[$a]['account_identity']){
  253. $available_cash = $account_money[$a]['available_cash'];
  254. }
  255. }
  256. for($b=0;$b<count($water_return_money);$b++){
  257. if($orders[$i]['order_id'] == $water_return_money[$b]['trade_id']){
  258. $water_return = $water_return_money[$b]['money'];
  259. } else {
  260. $water_return = 0;
  261. }
  262. }
  263. $new_available_cash = $available_cash + $orders[$i]->money - $orders[$i]->gain_money - $water_return;
  264. $models = new \App\Models\Money_details();
  265. $models->info_identity = UUID();
  266. $models->trade_id = $orders[$i]->order_id;
  267. $models->account_name = $orders[$i]->account_name;
  268. $models->account_identity = $orders[$i]->account_identity;
  269. $models->money = abs($orders[$i]->money - $orders[$i]->gain_money - $water_return);
  270. $models->money_time = date("Y-m-d H:i:s", time());
  271. if ($new_available_cash > $available_cash) {
  272. $models->money_type = '1';
  273. } else {
  274. $models->money_type = '2';
  275. }
  276. $models->money_cash = $new_available_cash;
  277. $models->trade_type = '25';
  278. $models->trade_desc = '单式注单审核不通过回款';
  279. $models->status = '1';
  280. try {
  281. DB::beginTransaction();//开启事务
  282. \App\Models\SportsNoteList::where('id', $orders[$i]['id'])->update(['roll_ratify' => '-1','status' => '2']);
  283. \App\Models\Account_detailed::where('account_identity', $orders[$i]->account_identity)->update(['available_cash' => $new_available_cash, 'cash' => $new_available_cash]);
  284. $models->save();
  285. DB::commit();//提交
  286. } catch (Exception $e) {
  287. DB::rollback();//回滚
  288. }
  289. }
  290. }
  291. return responseToJson(1);
  292. }
  293. //弃用
  294. function addwarnonly__(Req $req){
  295. $matchid = $req->matchid;
  296. $wid = $req->wid;//编辑对象值
  297. $timei = $req->timei?$req->timei:"1970-11-1 0:0:1";
  298. $timep = $req->timep?$req->timep:"90";
  299. $rtype = $req->warntype?$req->warntype:0;
  300. $typenum = $req->typenum;
  301. $model = \App\Models\Stzqresult::where('match_id', $matchid)->select("warn_more","start_time")->first()->toArray();
  302. //该赛事的单式注单
  303. $orders = array();
  304. $otherorders = array();
  305. $account_identitys = array();
  306. $order_ids = array();
  307. $order = \App\Models\SportsNoteList::where('match_id',$matchid)->get();
  308. if(!empty($order)){
  309. for ($c=0; $c < count($order); $c++){
  310. if(strtotime($timei) >= strtotime($order[$c]['money_time']) && strtotime($timei)-$timep <= strtotime($order[$c]['money_time'])){
  311. $orders[] = $order[$c];
  312. $account_identitys[] = $order[$c]['account_identity'];
  313. $order_ids[] = $order[$c]['order_id'];
  314. }else{
  315. $otherorders[] = $order[$c]['id'];
  316. }
  317. }
  318. }
  319. //危险球范围外的注单自动审核通过
  320. //return $otherorders;
  321. if(!empty($otherorders)){
  322. \App\Models\SportsNoteList::wherein('id', $otherorders)->update(['roll_ratify' => '1']);
  323. }
  324. //return $account_identitys;
  325. $sel = json_decode($model['warn_more'],true);
  326. $addru = array(
  327. array(
  328. 'timei'=>$timei,
  329. 'timep'=>$timep,
  330. 'rtype'=>$rtype,
  331. ),
  332. );
  333. $only =$model['start_time'];
  334. $t = strtotime($only);
  335. $tt = date('Y-m-d H:i:s', $t+1*3*60*60);
  336. //timei']!="1970-1-1 0:0:1"
  337. if($only<$timei && $timei<$tt){
  338. if($typenum==10000){
  339. if($sel[0]['timei']=="1970-1-1 0:0:1"){
  340. //首次添加
  341. $res = \App\Models\Stzqresult::where ('match_id', $matchid)->update(['warn_more' => json_encode($addru,JSON_UNESCAPED_UNICODE)]);
  342. }else{
  343. //再次添加
  344. $upnum = array_merge_recursive($sel,$addru);
  345. $res = \App\Models\Stzqresult::where ('match_id', $matchid)->update(['warn_more' => json_encode($upnum,JSON_UNESCAPED_UNICODE)]);
  346. }
  347. }else{
  348. //编辑
  349. for ($i=0; $i < count($sel); $i++) {
  350. $sel[$wid]['timei'] = $timei;
  351. $sel[$wid]['timep'] = $timep;
  352. $sel[$wid]['rtype'] = $rtype;
  353. }
  354. $res = \App\Models\Stzqresult::where ('match_id', $matchid)->update(['warn_more' => json_encode($sel,JSON_UNESCAPED_UNICODE)]);
  355. }
  356. //用戶账户金额
  357. $account_money = \App\Models\Account_detailed::wherein('account_identity',$account_identitys)->get();
  358. //反水
  359. $water_return_money = \App\Models\Money_details::wherein('trade_id',$order_ids)->where('trade_type', '7')->get();
  360. //return $water_return_money;
  361. if(!empty($orders)){
  362. for($i=0;$i<count($orders);$i++){
  363. for($a=0;$a<count($account_money);$a++){
  364. if($orders[$i]['account_identity'] == $account_money[$a]['account_identity']){
  365. $available_cash = $account_money[$a]['available_cash'];
  366. }
  367. }
  368. for($b=0;$b<count($water_return_money);$b++){
  369. if($orders[$i]['order_id'] == $water_return_money[$b]['trade_id']){
  370. $water_return = $water_return_money[$b]['money'];
  371. } else {
  372. $water_return = 0;
  373. }
  374. }
  375. $new_available_cash = $available_cash + $orders[$i]->money - $orders[$i]->gain_money - $water_return;
  376. $models = new \App\Models\Money_details();
  377. $models->info_identity = UUID();
  378. $models->trade_id = $orders[$i]->order_id;
  379. $models->account_name = $orders[$i]->account_name;
  380. $models->account_identity = $orders[$i]->account_identity;
  381. $models->money = abs($orders[$i]->money - $orders[$i]->gain_money - $water_return);
  382. $models->money_time = date("Y-m-d H:i:s", time());
  383. if ($new_available_cash > $available_cash) {
  384. $models->money_type = '1';
  385. } else {
  386. $models->money_type = '2';
  387. }
  388. $models->money_cash = $new_available_cash;
  389. $models->trade_type = '25';
  390. $models->trade_desc = '单式注单审核不通过回款';
  391. $models->status = '1';
  392. try {
  393. DB::beginTransaction();//开启事务
  394. \App\Models\SportsNoteList::where('id', $orders[$i]['id'])->update(['roll_ratify' => '-1','status' => '2']);
  395. \App\Models\Account_detailed::where('account_identity', $orders[$i]->account_identity)->update(['available_cash' => $new_available_cash, 'cash' => $new_available_cash]);
  396. $models->save();
  397. DB::commit();//提交
  398. } catch (Exception $e) {
  399. DB::rollback();//回滚
  400. }
  401. }
  402. }
  403. }else{
  404. return json_encode(['status'=>2,'msg'=>'请设置正确时间']);
  405. }
  406. return responseToJson(1);
  407. }
  408. //足球结果列表 1
  409. function outcome(Req $req) {
  410. $request=array();
  411. $request['home_team'] = isset($req->home_team) ? trim($req->home_team) : null;
  412. $request['status'] = isset($req->status) ? trim($req->status) : '-1';
  413. $request['if_order'] = isset($req->if_order) ? trim($req->if_order) : '1';
  414. $request['sureblurs'] = isset($req->sureblurs) ? $req->sureblurs : 'on';
  415. $request['star_time'] = isset($req->star_time) ? trim($req->star_time) :trans('status.default_time.seven_day') ;
  416. $request['end_time'] = isset($req->end_time) ? trim($req->end_time) : trans('status.default_time.etime');
  417. $newapp = new \App\Models\SoccerLeague();
  418. $data = $newapp->allleague();
  419. $request['league'] = $data;//联赛id
  420. $request['token'] = session('adminInfo.token');//token 变量
  421. $dt = \App\Lib\DataTable\DataTable::init();
  422. $dt->setDataSource('/admin/sportsfoot/outcomeinfo');
  423. $dt->setLang('sportsfoot');
  424. $dt->addColsFields('newtime', array('templet' => '#newtime', 'sort' => false, 'width' => 200));
  425. $dt->addColsFields('totime', array('templet' => '#totime', 'sort' => false, 'width' => 155));
  426. $dt->addColsFields('home_team', array('templet' => '#userdetail', 'sort' => false, 'width' => 90));
  427. $dt->addColsFields('guest_team', array('templet' => '#userdetail', 'sort' => false, 'width' => 90));
  428. $dt->addColsFields('dsnum', array('templet' => '#dsnum', 'sort' => false, 'width' => 100));
  429. $dt->addColsFields('csnum', array('templet' => '#csnum', 'sort' => false, 'width' => 100));
  430. //$dt->addColsFields('match_score', array('sort' => false, 'width' => 210));
  431. $dt->addColsFields('match_score', array('templet' => '#match_score', 'sort' => false, 'width' => 180));
  432. $dt->addColsFields('statusmatch', array('templet' => '#statusmatch', 'sort' => false, 'width' => 100,'align' => 'left'));
  433. $dt->addColsFields('operation', array('templet' => '#status', 'sort' => false, 'width' => 300));
  434. // $arr[] = 'view';
  435. // if (checkRriv('/admin/sportsfoot/edit')) {
  436. // $arr[] = 'edit';
  437. // }
  438. // $dt->setToolBar($arr, array('width' => 200));1
  439. $dt->enableCheckBox();
  440. return view('admin.sportsfoot/outcome', $dt->render($request));
  441. }
  442. //结果添加
  443. function addend(Req $req){
  444. $match_id = $req->matchid;
  445. $model = \App\Models\Stzqresult::where('match_id', $match_id)->first();
  446. $match = \App\Models\SportsSoccer::where('id', $match_id)->first();
  447. $match_status = $match['status'];
  448. $data = array(
  449. "half" => array(
  450. 'home' => intval($req->homehalf)?intval($req->homehalf):0,
  451. 'guest' => intval($req->guesthalf)?intval($req->guesthalf):0,
  452. ),
  453. "all" => array(
  454. 'home' => intval($req->homeall)?intval($req->homeall):0,
  455. 'guest' => intval($req->guestall)?intval($req->guestall):0,
  456. ),
  457. );
  458. foreach($data as $key){
  459. $array[] = $key['home'];
  460. $array[] = $key['guest'];
  461. }
  462. //修改足球比分前的比分数据
  463. $res = \App\Models\Stzqresult::where('match_id', $match_id)->first();
  464. //$scores = json_decode($res['penalty_card'],true);
  465. $process = array();//进程
  466. if($res['home_score'] != $data['all']['home'] || $res['guest_score'] != $data['all']['guest']){
  467. $process[] = 'all';
  468. }
  469. if($res['u_home_score'] != $data['half']['home'] || $res['u_guest_score'] != $data['half']['guest']){
  470. $process[] = 'half';
  471. }
  472. //print_r($process);exit;
  473. if(!empty($process)){
  474. //赛事下注单作废 处理
  475. commonFunction::HandleInvalid($data,$match_id,$match_status,'zq',$process);
  476. $penaltycard = array(
  477. 'home'=>intval($req->homeallcard)?intval($req->homeallcard):0,
  478. 'guest'=>intval($req->guestallcard)?intval($req->guestallcard):0,
  479. 'home_half'=>intval($req->homehalfcard)?intval($req->homehalfcard):0,
  480. 'guest_half'=>intval($req->guesthalfcard)?intval($req->guesthalfcard):0,
  481. );
  482. $cornerball = array(
  483. 'home'=>intval($req->homeallcorner)?intval($req->homeallcorner):0,
  484. 'guest'=>intval($req->guestallcorner)?intval($req->guestallcorner):0,
  485. 'home_half'=>intval($req->homehalfcorner)?intval($req->homehalfcorner):0,
  486. 'guest_half'=>intval($req->guesthalfcorner)?intval($req->guesthalfcorner):0,
  487. );
  488. $firstone = array(
  489. 'teamscore'=>$req->firstscore ? $req->firstscore:0,
  490. 'scoretime'=>intval($req->onescoretime)?intval($req->onescoretime):0,
  491. 'scoretype'=>$req->firststye ? $req->firststye:0,
  492. );
  493. $model->match_score = $data['all']['home'].':'.$data['all']['guest'];
  494. $model->u_home_score = $data['half']['home'];
  495. $model->u_guest_score = $data['half']['guest'];
  496. $model->home_score = $data['all']['home'];
  497. $model->guest_score = $data['all']['guest'];
  498. $model->last_score = $req->lastscore?$req->lastscore:'';
  499. $model->match_winer = $req->matchwiner?$req->matchwiner:'';
  500. $model->penalty_card = json_encode($penaltycard,JSON_UNESCAPED_UNICODE);
  501. $model->corner_ball = json_encode($cornerball,JSON_UNESCAPED_UNICODE);
  502. $model->first_score = json_encode($firstone,JSON_UNESCAPED_UNICODE);
  503. $model->is_correct = 1;
  504. $model->save();
  505. $update = $this->addcomendnotice($match_id);
  506. //赛事下所有注单状态都改变时,修改赛事,赛事结果状态
  507. if(count($process) == count($data)){
  508. $twoapp = new \App\Models\SportsSoccer();
  509. $twoapp->updatestatus('id',$match_id,['status'=>2,'utime'=>date('Y-m-d H:i:s')]);//修改赛事状态
  510. $newapp = new \App\Models\Stzqresult();
  511. $newapp->updatestatus('match_id',$match_id,['status'=>2,'update_time'=>date('Y-m-d H:i:s')]);//修改结果状态
  512. }
  513. //添加赛事结果记录
  514. $lastLog = \App\Models\Stzqresultlog::where([
  515. ['match_id', $match_id],
  516. ['type', 1]
  517. ])->orderBy('id', 'desc')->first();
  518. if(empty($lastLog) || !($lastLog['penalty_card'] == $model->penalty_card
  519. && $lastLog['corner_ball'] == $model->corner_ball
  520. && $lastLog['first_score'] == $model->first_score
  521. && $lastLog['last_score'] == $model->last_score
  522. && $lastLog['match_winer'] == $model->match_winer
  523. && $lastLog['u_home_score'] == $data['half']['home']
  524. && $lastLog['u_guest_score'] == $data['half']['guest']
  525. && $lastLog['home_score'] == $data['all']['home']
  526. && $lastLog['guest_score'] == $data['all']['guest']
  527. )){
  528. \App\Models\Stzqresultlog::insert([
  529. 'u_home_score' => $data['half']['home'],
  530. 'u_guest_score' => $data['half']['guest'],
  531. 'home_score' => $data['all']['home'],
  532. 'guest_score' => $data['all']['guest'],
  533. 'match_id' => $match_id,
  534. 'penalty_card' => $model->penalty_card ,
  535. 'corner_ball' => $model->corner_ball,
  536. 'first_score' => $model->first_score,
  537. 'last_score' => $model->last_score,
  538. 'match_winer' => $model->match_winer,
  539. 'user_id' => session('adminInfo.admin_id'),
  540. 'type' => 1,
  541. 'create_at' => now()
  542. ]);
  543. }
  544. }
  545. return responseToJson(1);
  546. }
  547. //查询赛事结果
  548. function Matchresult(Req $req){
  549. $match_id = $req->match_id;
  550. $newapp = \App\Models\Stzqresult::where('match_id', $match_id)->first();
  551. $array =array(
  552. 'corner_ball' => json_decode($newapp['corner_ball'],true),
  553. 'penalty_card' => json_decode($newapp['penalty_card'],true),
  554. 'first_score' => json_decode($newapp['first_score'],true),
  555. 'newapp' => $newapp,
  556. );
  557. return $array;
  558. }
  559. //查询赛事结果记录
  560. function resultLog(Req $req){
  561. $match_id = $req->match_id;
  562. $list = \App\Models\Stzqresultlog::leftJoin('system_user', 'user_id', '=', 'system_user.id')
  563. ->select('st_zq_result_log.*', 'system_user.loginname')->where('match_id', $match_id)->orderBy('id', 'asc')->get();
  564. foreach ($list as $key=>$value){
  565. $list[$key]['penalty_card'] = json_decode($value['penalty_card'], true);
  566. $list[$key]['corner_ball'] = json_decode($value['corner_ball'], true);
  567. $list[$key]['first_score'] = empty($value['first_score']) ? '' : json_decode($value['first_score'], true);
  568. }
  569. $result =array(
  570. 'status' => 200,
  571. 'list' => $list
  572. );
  573. echo json_encode($result);die;
  574. }
  575. function onlyresult(Req $req){
  576. $match_id = $req->matchid;
  577. $newapp = \App\Models\Stzqresult::where('match_id', $match_id)->first();
  578. return $newapp;
  579. }
  580. //作废
  581. function revokeft(Req $req){
  582. $iszf = $req->iszf?$req->iszf:'';//赛事id
  583. if(intval($iszf)){
  584. $id = $req->input('id');
  585. if (empty($id)) {
  586. return responseToJson(-2001); //
  587. }
  588. $ids = explode(',', $id);
  589. if (!is_array($ids) && intval($ids) < 0) {
  590. return responseToJson(-2002); //
  591. }
  592. if (is_array($ids) && count($ids) > 0) {
  593. foreach ($ids as $k => $v) {
  594. if (intval($v) < 1) {
  595. unset($ids[$k]);
  596. }
  597. }
  598. }
  599. for ($ii=0; $ii < count($ids); $ii++) {
  600. $model = \App\Models\Stzqresult::where('match_id', $ids[$ii])->first();
  601. $model->status = 4;
  602. $model->save();
  603. $ssid = $model['match_id'];//赛事id
  604. $smodel = \App\Models\SportsSoccer::where('id', $ssid)->first();
  605. if($smodel){
  606. $smodel->status = 4;
  607. $smodel->save();
  608. }
  609. //赛事下单式注单作废,串关注单下此赛事按平局处理
  610. $upapp = new \App\Models\SportsNoteList();
  611. $upapp->delorder($ssid,'zq');
  612. // $upapp = new \App\Models\SportsNoteList();
  613. // $data = $upapp->updatesimplex($ssid,'zq');//修改单式状态
  614. //单式撤单返现
  615. // $newapp = new \App\Models\MoneyBuyMatch();
  616. // $all = $newapp->allsimplexorder($ssid,'zq');
  617. // for ($i=0; $i < count($all); $i++) {
  618. // $appgx = new \App\Lib\Settlement\SettlementOrder();
  619. // $appgx->insertData($all[$i]['order_id'], $all[$i]['money'], $all[$i]['account_identity'], '1', 'zq', $all[$i]['info_identity'], $all[$i]['money'],$all[$i]['match_id']);
  620. // }
  621. //
  622. // //串式撤单只改状态
  623. // $str_ids = array_column($newapp->allstrorder($ssid),'order_id');
  624. // $csapp = new \App\Models\MoneyBuyStr();
  625. // $csapp->updatestatus($str_ids);//var_dump($ss);die;
  626. // //修改money_buy_match 投注结果result=2为平
  627. // $newapp->updatast($ssid);
  628. }
  629. return responseToJson(1);
  630. }else{
  631. $match_id = $req->match_id;//赛事id
  632. $model = \App\Models\Stzqresult::where('match_id', $match_id)->first();
  633. $model->status = 4;
  634. $model->save();
  635. $smodel = \App\Models\SportsSoccer::where('id', $match_id)->first();
  636. if($smodel){
  637. $smodel->status = 4;
  638. $smodel->save();
  639. }
  640. //赛事下单式注单作废,串关注单下此赛事按平局处理
  641. $upapp = new \App\Models\SportsNoteList();
  642. $upapp->delorder($match_id,'zq');
  643. // $upapp = new \App\Models\SportsNoteList();
  644. // $data = $upapp->updatesimplex($match_id,'zq');//修改单式状态
  645. // //单式撤单返现
  646. // $newapp = new \App\Models\MoneyBuyMatch();
  647. // $all = $newapp->allsimplexorder($match_id,'zq');
  648. // for ($i=0; $i < count($all); $i++) {
  649. // $appgx = new \App\Lib\Settlement\SettlementOrder();
  650. // $appgx->insertData($all[$i]['order_id'], $all[$i]['money'], $all[$i]['account_identity'], '1', 'zq', $all[$i]['info_identity'], $all[$i]['money'],$all[$i]['match_id']);
  651. // }
  652. // //串式撤单只改状态
  653. // $str_ids = array_column($newapp->allstrorder($match_id),'order_id');
  654. // $csapp = new \App\Models\MoneyBuyStr();
  655. // $csapp->updatestatus($str_ids);//var_dump($ss);die;
  656. // //修改money_buy_match 投注结果result=2为平
  657. // $newapp->updatast($match_id);
  658. return responseToJson(1);
  659. }
  660. }
  661. //赛事结果修改
  662. function edit(Req $req) {
  663. $id = $req->id;
  664. if (intval($id) < 1) {
  665. return -1;
  666. }
  667. if (!$req->isMethod('post')) {
  668. $data = \App\Models\Stzqresult::where('id', $id)->first();
  669. if (!$data) {
  670. return -2;
  671. }
  672. $data = $data->toArray();
  673. return view('admin.sportsfoot/edit', $data);
  674. } else {
  675. $model = \App\Models\Stzqresult::where('id', $id)->first();
  676. $model->home_team = $req->input('home_team');
  677. $model->guest_team = $req->input('guest_team');
  678. $model->home_rate = $req->input('home_rate');
  679. $model->guest_rate = $req->input('guest_rate');
  680. $model->status = $req->input('status');
  681. //$model->update_time = time();
  682. $model->save();
  683. return responseToJson(1);
  684. }
  685. }
  686. function outcomeinfo() {
  687. $page = Request::has('page') ? Request::get('page') : '';
  688. $list = Request::has('limit') ? Request::get('limit') : 10;
  689. $home_team = Request::has('home_team') ? Request::get('home_team') : '';
  690. $sureblur = Request::has('sureblurs') ? Request::get('sureblurs') : 'off';
  691. $status = Request::has('status') ? Request::get('status') : '';
  692. $if_order = Request::has('if_order') ? Request::get('if_order') : '';
  693. $star_time = Request::get('star_time') ? Request::get('star_time').' 00:00:00' : '';
  694. $end_time = Request::get('end_time') ? Request::get('end_time').' 23:59:59' : '';
  695. $where = array();
  696. $orwhere = array();
  697. if (!empty($home_team)) {
  698. if (empty($sureblur) || $sureblur == 'off') {
  699. $where[] = array('st_zq_result.home_team', 'like', '%' . $home_team . '%');
  700. $orwhere[] = array('st_zq_result.guest_team', 'like', '%' . $home_team . '%');
  701. } else {
  702. if(is_numeric($home_team)){
  703. $where[] = array('st_zq_result.match_id', '=', $home_team);
  704. $orwhere[] = array('st_zq_result.match_id', '=', $home_team);
  705. }else{
  706. $where[] = array('st_zq_result.home_team', '=', $home_team);
  707. $orwhere[] = array('st_zq_result.guest_team', '=', $home_team);
  708. }
  709. }
  710. }
  711. //
  712. if ($status != -1) {
  713. $where[] = array('st_zq_competition.status', '=', $status);
  714. $orwhere[] = array('st_zq_competition.status', '=', $status);
  715. }
  716. if (!empty($star_time) and empty($home_team)) {
  717. $star_time = date('Y-m-d H:i:s', strtotime($star_time));
  718. $where[] = array('st_zq_result.start_time', '>', $star_time);
  719. $orwhere[] = array('st_zq_result.start_time', '>', $star_time);
  720. }
  721. if (!empty($end_time) and empty($home_team)) {
  722. $end_time = date('Y-m-d H:i:s', strtotime($end_time));
  723. $where[] = array('st_zq_result.start_time', '<', $end_time);
  724. $orwhere[] = array('st_zq_result.start_time', '<', $end_time);
  725. }
  726. $newapp = new \App\Models\Stzqresult();
  727. $data = $newapp->resultlist($list, $page, $where, $orwhere,$if_order);
  728. return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
  729. }
  730. function saislist(Req $req){
  731. $lgid = $req->lgid;//赛事id
  732. $newstzqcompetition = new \App\Models\Stzqcompetition();
  733. $league_data = $newstzqcompetition->allcompetition($lgid);//赛事id
  734. return $league_data;
  735. }
  736. //赛事结果添加 guest_score 客队进球 all_goal总进球数
  737. function addoutcome(Req $req) {
  738. if (!$req->isMethod('post')) {
  739. $lange = trans('menu');
  740. $newapp = new \App\Models\SoccerLeague();
  741. $league_data = $newapp->allleague();//联赛id
  742. return view('admin.sportsfoot/addoutcome',['data'=>$league_data]);
  743. } else {
  744. $match_id = trim($req->input('match_id'));//赛事id
  745. //添加足球比赛结果表
  746. $alldata = $req->input();
  747. unset($alldata['_token']);
  748. $all_goal = intval($alldata['home_score'])+intval($alldata['guest_score']);//总进球数
  749. $penaltycard = array(
  750. 'home'=>intval($alldata['homeallcard'])?intval($alldata['homeallcard']):0,
  751. 'guest'=>intval($alldata['guestallcard'])?intval($alldata['guestallcard']):0,
  752. 'home_half'=>intval($alldata['homehalfcard'])?intval($alldata['homehalfcard']):0,
  753. 'guest_half'=>intval($alldata['guesthalfcard'])?intval($alldata['guesthalfcard']):0,
  754. );
  755. $cornerball = array(
  756. 'home'=>intval($alldata['homeallcorner'])?intval($alldata['homeallcorner']):0,
  757. 'guest'=>intval($alldata['guestallcorner'])?intval($alldata['guestallcorner']):0,
  758. 'home_half'=>intval($alldata['homehalfcorner'])?intval($alldata['homehalfcorner']):0,
  759. 'guest_half'=>intval($alldata['guesthalfcorner'])?intval($alldata['guesthalfcorner']):0,
  760. );
  761. $ret = \App\Models\Stzqresult::updateOrCreate(['match_id'=>$match_id],array_merge($alldata,['match_time'=>'00:01','update_time'=>date('Y-m-d H:i:s'),'all_goal'=>$all_goal,'penalty_card'=>json_encode($penaltycard),'corner_ball'=>json_encode($cornerball)]));
  762. //添加足球比赛结果记录表
  763. \App\Models\Stzqresultrecord::updateOrCreate(['match_id'=>$match_id,'update_time'=>date('Y-m-d H:i:s')],array_merge($alldata,['match_time'=>'00:01','update_time'=>date('Y-m-d H:i:s')]));
  764. }
  765. return responseToJson(1);
  766. }
  767. //删除赛事结果
  768. function deleteoutcome(Req $req) {
  769. $id = $req->input('id');
  770. if (empty($id)) {
  771. return responseToJson(-2001); //
  772. }
  773. $ids = explode(',', $id);
  774. if (!is_array($ids) && intval($ids) < 0) {
  775. return responseToJson(-2002); //
  776. }
  777. if (is_array($ids) && count($ids) > 0) {
  778. foreach ($ids as $k => $v) {
  779. if (intval($v) < 1) {
  780. unset($ids[$k]);
  781. }
  782. }
  783. }
  784. $rows = \App\Models\Stzqresult::whereIn('id', $ids)->delete();
  785. if (!$rows) {
  786. return responseToJson(-2003);
  787. }
  788. return responseToJson(1);
  789. }
  790. /**
  791. * 更新赛事比分
  792. * 追加 赛事及所属注单作废处理
  793. */
  794. function updatenum(Req $req){
  795. $match_id = $req->match_id;
  796. $newapp = new \App\Models\Stzqresult();
  797. //赛事状态
  798. $match_status = intval($req->match_status)?intval($req->match_status):0;
  799. $data['u_home_score'] = intval($req->u_home_score)?intval($req->u_home_score):0;
  800. $data['u_guest_score'] = intval($req->u_guest_score)?intval($req->u_guest_score):0;
  801. $data['home_score'] = intval($req->home_score)?intval($req->home_score):0;
  802. $data['guest_score'] = intval($req->guest_score)?intval($req->guest_score):0;
  803. $data['is_correct'] = 1;//追加手动更改标识
  804. //更新比分 默认 status
  805. $status = 2;
  806. //赛事下注单作废 处理
  807. if(in_array(-1,$data)){
  808. commonFunction::HandleInvalid($data,$match_id,$match_status,'zq');
  809. // $this->HandleInvalid($data,$match_id,$match_status,'zq');
  810. }
  811. $newapp->updateInfo($data,$match_id);//联赛id
  812. $newapp->totalgoal($match_id);
  813. $update = $this->addcomendnotice($match_id);
  814. $twoapp = new \App\Models\SportsSoccer();
  815. $twoapp->updatestatus('match_id',$match_id,['status'=>$status,'utime'=>date('Y-m-d H:i:s')]);//修改赛事状态
  816. $newapp->updatestatus('match_id',$match_id,['status'=>$status,'update_time'=>date('Y-m-d H:i:s')]);//修改结果状态
  817. //添加赛事结果比较记录
  818. $lastLog = \App\Models\Stzqresultlog::where([
  819. ['match_id', $match_id],
  820. ['type', 2]
  821. ])->orderBy('id', 'desc')->first();
  822. if(empty($lastLog) || !(
  823. $lastLog['u_home_score'] == $data['u_home_score']
  824. && $lastLog['u_guest_score'] == $data['u_guest_score']
  825. && $lastLog['home_score'] == $data['home_score']
  826. && $lastLog['guest_score'] == $data['guest_score']
  827. )){
  828. $logData = $data;
  829. unset($logData['is_correct']);
  830. $logData['type'] = 2;
  831. $logData['match_id'] = $match_id;
  832. $logData['user_id'] = session('adminInfo.admin_id');
  833. $logData['create_at'] = now();
  834. \App\Models\Stzqresultlog::insert($logData);
  835. }
  836. return responseToJson(1);
  837. }
  838. /**
  839. * 赛事下注单作废处理
  840. * 弃用 保留备份
  841. */
  842. function HandleInvalid($data=[],$match_id='',$match_status='',$game_code=''){
  843. //===作废处理===
  844. $moneyBuyMatch = new \App\Models\MoneyBuyMatch();
  845. //获取赛事下所有单式注单
  846. $select = ['money_buy_simplex.order_id', 'money_buy_simplex.match_id', 'money_buy_simplex.account_identity', 'money_buy_simplex.account_name','money_buy_simplex.money', 'money_buy_simplex.gain_money','money_buy_match.odds_code','st_odds_code.odds_name'];
  847. //obj
  848. $match_order_sim_obj = $moneyBuyMatch->allsimplexorder($match_id,$game_code,$select);
  849. //获取赛事下所有串式注单
  850. $select = ['money_buy_str.order_id', 'money_buy_match.match_id', 'money_buy_str.account_identity', 'money_buy_str.account_name','money_buy_str.money', 'money_buy_str.gain_money','st_odds_code.odds_name','money_buy_match.odds_code'];
  851. //obj
  852. $match_order_str_obj = $moneyBuyMatch->allstrorder($match_id,$game_code,$select);
  853. //如果赛事下有 单式 注单
  854. if(!empty($match_order_sim_obj)){
  855. //获取单式注单中 待处理注单
  856. $oddsData_sim = $this->getOrderData($data,$match_order_sim_obj,$game_code);
  857. }
  858. //如果赛事下有 串式 注单
  859. if(!empty($match_order_str_obj)){
  860. //获取串式注单中 待处理注单
  861. $oddsData_str = $this->getOrderData($data,$match_order_str_obj,$game_code);
  862. }
  863. //如果是已结算赛事
  864. if($match_status == 3){
  865. //合并上半场/全场 待处理 单式+串式订单
  866. $oddsData = array_merge($oddsData_sim,$oddsData_str);
  867. //去重
  868. $oddsData = commonFunction::uniquArrV2($oddsData,'order_id');
  869. $url = 'http://stadmin.bocai108.com:9094/UnsetOneOrder';
  870. $data_up = [
  871. 'token'=>session('adminInfo.token'),
  872. 'game_code'=>$game_code,
  873. 'match_id'=>$match_id,
  874. ];
  875. //返回请求状态码
  876. $set_status = [];
  877. foreach($oddsData as $k=>$v){
  878. $data_up['order_id'] = $v['order_id'];
  879. $ret_json = commonFunction::https_request($url,$data_up);
  880. $ret_arr = json_decode($ret_json,true);
  881. $set_status[] = $ret_arr['status'];
  882. }
  883. if(in_array(0,$set_status)){
  884. return responseToJson(-20003);
  885. }
  886. }else{
  887. //未结算赛事 处理 下单式注单作废,串关注单下此赛事按平局处理
  888. $oddsData_str = $oddsData_str->toArray();
  889. $upapp = new \App\Models\SportsNoteList();
  890. $upapp->delorder($match_id,$game_code,$match_order_sim_obj,$oddsData_str);
  891. }
  892. //=== end ===
  893. }
  894. /**
  895. * 获取赛事下 符合条件 待处理注单
  896. * 弃用 保留备份
  897. */
  898. function getOrderData($data,$match_order,$game_code){
  899. //足球 获取 上半场/全场
  900. if($game_code == 'zq'){
  901. // 获取上半场作废 需处理 单式注单
  902. $matchOdds_h = [];
  903. if($data['u_home_score'] == -1 and $data['u_guest_score'] == -1){
  904. foreach($match_order as $k=>$v){
  905. $tmparray = explode('上半场',$v->odds_name);
  906. if(count($tmparray) > 1){
  907. $matchOdds_h[] = $v;
  908. }
  909. }
  910. }
  911. //获取全场作废 需处理 单式注单
  912. $matchOdds_f = [];
  913. if($data['home_score'] == -1 and $data['guest_score'] == -1){
  914. foreach($match_order as $k=>$v){
  915. $tmparray = explode('全场',$v->odds_name);
  916. if(count($tmparray) > 1){
  917. $matchOdds_f[] = $v;
  918. }
  919. }
  920. }
  921. $orderData = array_merge($matchOdds_h,$matchOdds_f);
  922. }
  923. return $orderData;
  924. }
  925. //添加赛事结束纪录
  926. function addcomendnotice($match_id){
  927. $data = \App\Models\Comendnotice::where(['match_id'=>$match_id,'game_code'=>'zq'])->first();
  928. if(!$data){
  929. $model = new \App\Models\Comendnotice();
  930. $model->status = 0;//联赛id
  931. $model->game_code = 'zq';
  932. $model->match_id = $match_id;//赛事id
  933. $model->ctime = date('Y-m-d H:i:s');
  934. $model->save();
  935. }
  936. }
  937. }