WriteSports.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Jun.peng
  5. * Date: 2019/5/13
  6. * Time: 10:19
  7. */
  8. namespace App\Sports\Controller;
  9. use BaseController\Controller;
  10. use App\Sports\Model\St_area_country as St_area_countryModel;
  11. class WriteSports extends Controller{
  12. public function init() {
  13. $this->commonFunction = C()->get('commonFunction');
  14. //当前时间
  15. $this->newTime = date('Y-m-d H:m:i');
  16. }
  17. /**
  18. * 体育数据入库接口
  19. */
  20. public function setSports(){
  21. $obt = $_REQUEST['data'];
  22. $data = $this->getAddData($obt);
  23. //验证二维数组内是否有空值
  24. // foreach ($data['data'] as $v){
  25. // if(in_array('', $v)) Render([], '10001', lang('Tips','Sports')->get('PARAM_ERROR'));
  26. // }
  27. switch ($data['title']){
  28. // case 'area'://地区
  29. // $ret = $this->area($data['data']);
  30. // break;
  31. // case 'country'://国家
  32. // $ret = $this->country($data['data']);
  33. // break;
  34. case 'league'://联赛
  35. $ret = $this->league($data);
  36. break;
  37. case 'competition'://赛事
  38. $ret = $this->competition($data);
  39. break;
  40. case 'odds'://赔率
  41. $ret = $this->odds($data);
  42. break;
  43. case 'league_result'://联赛结果
  44. $ret = $this->league_result($data);
  45. break;
  46. case 'match_result'://赛事结果
  47. $ret = $this->com_result($data);
  48. break;
  49. case 'match_result_record'://赛事结果记录
  50. $ret = $this->com_result_record($data);
  51. break;
  52. case 'odds_record'://赔率记录
  53. $ret = $this->odds_record($data);
  54. break;
  55. default:
  56. Render([], '10007', lang('Tips','Sports')->get('abnormal'));
  57. }
  58. //写入成功
  59. if($ret) Render([], '1', lang('Tips','Sports')->get('success'));
  60. //写入失败
  61. Render([], '10010', lang('Tips','Sports')->get('HANDLE_ERRORS'));
  62. }
  63. //写入地区数据 弃用
  64. public function __area($opt = []){
  65. $ret = lm('st_area','Sports')->insert($opt);
  66. return $ret;
  67. }
  68. //写入国家数据 弃用
  69. public function __country($opt = []){
  70. $ret = lm('st_country','Sports')->insert($opt);
  71. return $ret;
  72. }
  73. //写入联赛数据
  74. public function league($opt = []){
  75. $game_code = $opt['game_code'];
  76. //根据球类代码获取相关model
  77. $model = $this->commonFunction->getModels($game_code,1);
  78. $data = $opt['data'];
  79. if(empty($data['belong'])) Render([], '10013', lang('Tips','Sports')->get('country_error'));
  80. //获取联赛所属 国家/地区id
  81. $belong = St_area_countryModel::getID($data['belong']);
  82. $set_lg['area_id'] = $belong['area_id'];
  83. $set_lg['country_id'] = $belong['country_id'];
  84. //查询中间表 是否已记录
  85. $lg_id = lm($model['model_local_league'],'Sports')
  86. ->select('lg_id')
  87. ->where(['others_lg_id'=>$data['lg_id'],'source'=>$data['source']])
  88. ->first()->lg_id;
  89. //如果没有记录
  90. if(empty($lg_id)){
  91. //查询联赛是否已存在
  92. $id = lm($model['model_league'],'Sports')
  93. ->select('id')
  94. ->where('name_chinese','=',$data['name_chinese'])
  95. ->first()->id;
  96. if(empty($id)){
  97. $set_lg['name_chinese'] = $data['name_chinese'];
  98. $set_lg['kind'] = $data['kind'];
  99. $set_lg['match_mode'] = $data['match_mode'];
  100. $set_lg['if_stop'] = $data['if_stop'];
  101. $set_lg['last_time'] = $data['last_time'];
  102. $set_lg['utime'] = $this->newTime;
  103. $id = lm($model['model_league'],'Sports')->insertGetId($set_lg);
  104. $m_lg_id = $id;
  105. if($m_lg_id < 1) Render([], '10012', lang('Tips','Sports')->get('insert_error'));
  106. }
  107. $set_local = [
  108. 'lg_id'=>$id,
  109. 'others_lg_id'=>$data['lg_id'],
  110. 'source'=>$data['source'],
  111. ];
  112. $ret = lm($model['model_local_league'],'Sports')-> insertGetId($set_local);
  113. if($ret < 1) Render([], '10017', lang('Tips','Sports')->get('local_league_error'));
  114. }
  115. Render([], '1', lang('Tips','Sports')->get('success'));
  116. }
  117. //弃用
  118. public function __league($opt = []){
  119. $game_code = $opt['game_code'];
  120. //根据球类代码获取相关model
  121. $model = $this->commonFunction->getModels($game_code,1);
  122. $data = $opt['data'];
  123. // foreach ($opt['data'] as $k => $v){
  124. //验证联赛所属国家
  125. if(!empty($data['country_id'])){
  126. $country = lm('st_country','Sports')
  127. ->where(['country_id'=>$data['country_id']])
  128. ->count();
  129. if($country < 1) Render([], '10013', lang('Tips','Sports')->get('country_error'));
  130. }
  131. //验证联赛所属地区
  132. if(!empty($data['area_id'])){
  133. $area = lm('st_area','Sports')
  134. ->where(['id'=>$data['area_id']])
  135. ->count();
  136. if($area < 1) Render([], '10014', lang('Tips','Sports')->get('area_error'));
  137. }
  138. $post = lm($model['model_league'],'Sports')
  139. ->where(['lg_id'=>$data['lg_id']])
  140. ->count();
  141. //更新操作
  142. if($post > 0){
  143. $ret = lm($model['model_league'],'Sports')
  144. -> where(['lg_id'=>$data['lg_id']])
  145. -> update($data);
  146. if($ret < 1) Render([], '10011', lang('Tips','Sports')->get('update_error'));
  147. }else{
  148. //写入操作
  149. $ret = lm($model['model_league'],'Sports')->insert($data);
  150. if($ret != true) Render([], '10012', lang('Tips','Sports')->get('insert_error'));
  151. }
  152. // }
  153. Render([], '1', lang('Tips','Sports')->get('success'));
  154. }
  155. //写入赛事数据
  156. public function competition($opt = []){
  157. $game_code = $opt['game_code'];
  158. //根据球类代码获取相关model
  159. $model = $this->commonFunction->getModels($game_code,1);
  160. $data = $opt['data'];
  161. if(empty($data['lg_id'])) Render([], '10015', lang('Tips','Sports')->get('league_error'));
  162. //根据源联赛ID 获取本地关联id
  163. $lg_id = lm($model['model_local_league'],'Sports')
  164. ->select('lg_id')
  165. ->where(['others_lg_id'=>$data['lg_id'],'source'=>$data['source']])
  166. ->first()->lg_id;
  167. if(empty($lg_id)) Render([], '10015', lang('Tips','Sports')->get('league_error'));
  168. //查询关联记录是否存在
  169. $match_id = lm($model['model_local_match'],'Sports')
  170. ->select('match_id')
  171. ->where(['others_match_id'=>$data['match_id'],'source'=>$data['source']])
  172. ->first()->match_id;
  173. if(empty($match_id)){
  174. //查询赛事是否存在
  175. $id = lm($model['model_match'],'Sports')
  176. ->select('id')
  177. ->where(['home_team'=>$data['home_team'],'guest_team'=>$data['guest_team'],'match_date'=>$data['match_date'],'match_time'=>$data['match_time']])
  178. ->first()->id;
  179. //写入赛事
  180. if(empty($id)){
  181. $set_match = [
  182. 'ctime'=>$this->newTime,
  183. 'utime'=>$this->newTime,
  184. 'expire_time'=>date('Y-m-d H:m:i',time()+60),
  185. 'home_team'=>$data['home_team'],
  186. 'guest_team'=>$data['guest_team'],
  187. 'lg_id'=>$lg_id,
  188. 'status'=>$data['status'],
  189. 'match_date'=>$data['match_date'],
  190. 'match_time'=>$data['match_time'],
  191. 'tag'=>$data['tag'],
  192. 'is_rollball'=>$data['is_rollball'],
  193. 'is_today'=>$data['is_today'],
  194. 'is_morningplate'=>$data['is_morningplate'],
  195. 'is_stringscene'=>$data['is_stringscene'],
  196. 'us_time'=>$data['us_time'],
  197. ];
  198. $id = lm($model['model_match'],'Sports')->insertGetId($set_match);
  199. if($id < 1) Render([], '10012', lang('Tips','Sports')->get('insert_error'));
  200. }
  201. $set_local = [
  202. 'match_id'=>$id,
  203. 'others_match_id'=>$data['match_id'],
  204. 'source'=>$data['source'],
  205. ];
  206. $ret = lm($model['model_local_match'],'Sports')-> insertGetId($set_local);
  207. if($ret < 1) Render([], '10018', lang('Tips','Sports')->get('local_match_error'));
  208. }
  209. Render([], '1', lang('Tips','Sports')->get('success'));
  210. }
  211. //写入赛事数据 弃用
  212. public function __competition($opt = []){
  213. $game_code = $opt['game_code'];
  214. //根据球类代码获取相关model
  215. $model = $this->commonFunction->getModels($game_code,1);
  216. $data = $opt['data'];
  217. // foreach ($opt['data'] as $k => $v){
  218. //验证赛事所属联赛
  219. if(!empty($data['lg_id'])){
  220. $lg = lm($model['model_league'],'Sports')
  221. ->where(['lg_id'=>$data['lg_id']])
  222. ->count();
  223. if($lg < 1) Render([], '10015', lang('Tips','Sports')->get('league_error'));
  224. }
  225. $post = lm($model['model_match'],'Sports')
  226. ->where(['match_id'=>$data['match_id']])
  227. ->count();
  228. //更新操作
  229. if($post > 0){
  230. $ret = lm($model['model_match'],'Sports')
  231. -> where(['match_id'=>$data['match_id']])
  232. -> update($data);
  233. if($ret < 1) Render([], '10011', lang('Tips','Sports')->get('update_error'));
  234. }else{
  235. //写入操作
  236. $ret = lm($model['model_match'],'Sports')->insert($data);
  237. if($ret != true) Render([], '10012', lang('Tips','Sports')->get('insert_error'));
  238. }
  239. // }
  240. Render([], '1', lang('Tips','Sports')->get('success'));
  241. }
  242. //写入赔率数据
  243. public function odds($opt){
  244. $game_code = $opt['game_code'];
  245. //根据球类代码获取相关model
  246. $model = $this->commonFunction->getModels($game_code,1);
  247. $data = $opt['data'];
  248. $match = lm($model['model_local_match'],'Sports')
  249. ->select('match_id','others_match_id')
  250. ->where(['others_match_id'=>$data['match_id'],'source'=>$data['source']])
  251. ->first();
  252. if(count($match) < 1) Render([], '10016', lang('Tips','Sports')->get('match_error'));
  253. //获取赛事 本地/源ID
  254. $others_match_id = $match->others_match_id;
  255. $match_id = $match->match_id;
  256. $lg = lm($model['model_local_league'],'Sports')
  257. ->select('lg_id','others_lg_id')
  258. ->where(['others_lg_id'=>$data['lg_id'],'source'=>$data['source']])
  259. ->first();
  260. if(count($lg) < 1) Render([], '10015', lang('Tips','Sports')->get('league_error'));
  261. //获取联赛 本地/源ID
  262. $others_lg_id = $lg->others_lg_id;
  263. $lg_id = $lg->lg_id;
  264. //查询 赔率数据是否存在
  265. $oddsID = lm($model['model_odds'],'Sports')
  266. ->where(['lg_id'=>$lg_id,'others_lg_id'=>$others_lg_id,'match_id'=>$match_id,'others_match_id'=>$others_match_id,'odds_code'=>$data['odds_code'],'sort'=>$data['sort']])
  267. ->value('id');
  268. $set_odds = [
  269. 'match_id'=> $match_id,
  270. 'others_match_id'=> $others_match_id,
  271. 'odds_code'=> $data['odds_code'],
  272. 'status'=> $data['status'],
  273. 'sort'=> $data['sort'],
  274. 'p_code'=> $data['p_code'],
  275. 'odds'=> $data['odds'],
  276. 'condition'=> $data['condition'],
  277. 'odds_only'=> $data['odds_only'],
  278. 'sole'=> $data['sole'],
  279. 'source'=> $data['source'],
  280. 'type'=> $data['type'],
  281. 'team'=> $data['team'],
  282. 'lg_id'=> $lg_id,
  283. 'others_lg_id'=> $others_lg_id,
  284. 'ctime'=> $this->newTime,
  285. 'utime'=> $this->newTime,
  286. 'expire_time'=>date('Y-m-d H:m:i',time()+60),
  287. ];
  288. //更新或写入赔率数据
  289. if(!empty($oddsID)){
  290. $ret = lm($model['model_odds'],'Sports')
  291. ->where(['id'=>$oddsID])
  292. -> update($set_odds);
  293. if($ret < 1) Render([], '10019', lang('Tips','Sports')->get('add_odds_error'));
  294. }else{
  295. $ret = lm($model['model_odds'],'Sports')->insert($set_odds);
  296. if($ret != true) Render([], '10019', lang('Tips','Sports')->get('add_odds_error'));
  297. }
  298. Render([], '1', lang('Tips','Sports')->get('success'));
  299. }
  300. //写入联赛结果
  301. public function league_result($opt){
  302. $game_code = $opt['game_code'];
  303. //根据球类代码获取相关model
  304. $model = $this->commonFunction->getModels($game_code,1);
  305. $data = $opt['data'];
  306. //验证结果所属联赛
  307. $lg_id = lm($model['model_local_league'],'Sports')
  308. ->select('lg_id')
  309. ->where(['others_lg_id'=>$data['lg_id'],'source'=>$data['source']])
  310. ->first()->lg_id;
  311. if($lg_id < 1) Render([], '10015', lang('Tips','Sports')->get('league_error'));
  312. $lg_result_id = lm($model['model_league_result'],'Sports')
  313. ->where(['lg_id'=>$lg_id,'game_name'=>$data['game_name']])
  314. ->value('id');
  315. $set_lg_result = [
  316. 'lg_id'=>$lg_id,
  317. 'game_name'=>$data['game_name'],
  318. 'result'=>json_encode($data['result'],JSON_UNESCAPED_UNICODE),
  319. 'status'=>$data['status'],
  320. 'ctime'=> $this->newTime,
  321. 'utime'=> $this->newTime,
  322. ];
  323. //联赛结果数据处理
  324. if(!empty($lg_result_id)){
  325. $ret = lm($model['model_league_result'],'Sports')
  326. ->where(['id'=>$lg_result_id])
  327. -> update($set_lg_result);
  328. if($ret < 1) Render([], '10021', lang('Tips','Sports')->get('add_lg_r_error'));
  329. }else{
  330. $ret = lm($model['model_league_result'],'Sports')->insert($set_lg_result);
  331. if($ret != true) Render([], '10021', lang('Tips','Sports')->get('add_lg_r_error'));
  332. }
  333. Render([], '1', lang('Tips','Sports')->get('success'));
  334. }
  335. //写入赛事结果
  336. public function com_result($opt){
  337. $game_code = $opt['game_code'];
  338. //根据球类代码获取相关model
  339. $model = $this->commonFunction->getModels($game_code,1);
  340. $data = $opt['data'];
  341. //验证结果所属联赛
  342. $lg_id = lm($model['model_local_league'],'Sports')
  343. ->select('lg_id')
  344. ->where(['others_lg_id'=>$data['lg_id'],'source'=>$data['source']])
  345. ->first()->lg_id;
  346. if($lg_id < 1) Render([], '10015', lang('Tips','Sports')->get('league_error'));
  347. //验证结果所属赛事
  348. $match_id = lm($model['model_local_match'],'Sports')
  349. ->select('match_id')
  350. ->where(['others_match_id'=>$data['match_id'],'source'=>$data['source']])
  351. ->value('match_id');
  352. if($match_id < 1) Render([], '10016', lang('Tips','Sports')->get('match_error'));
  353. //查询结果是否存在
  354. $match_r_id = lm($model['model_result'],'Sports')
  355. ->where(['match_id'=>$match_id])
  356. ->value('id');
  357. $set_match_r = [
  358. "home_team"=>$data['home_team'],
  359. "guest_team"=>$data['guest_team'],
  360. "lg_id"=>$lg_id,
  361. "home_rate"=> $data['home_rate'],
  362. "guest_rate"=> $data['guest_rate'],
  363. "home_score"=> $data['home_score'],
  364. "guest_score"=> $data['guest_score'],
  365. "all_goal"=> $data['all_goal'],
  366. "status"=>$data['status'],
  367. "first_score"=>$data['first_score'],
  368. "last_score"=> $data['last_score'],
  369. "match_score"=> $data['match_score'],
  370. "match_winer"=> $data['match_winer'],
  371. "match_time"=> $data['match_time'],
  372. "match_process"=> $data['match_process'],
  373. "tag"=> $data['tag'],
  374. "match_id"=> $match_id,
  375. "u_home_score"=> $data['u_home_score'],
  376. "u_guest_score"=> $data['u_guest_score'],
  377. "p_code"=> $data['p_code'],
  378. "update_time"=>$this->newTime
  379. ];
  380. //赛事结果数据处理
  381. if(!empty($match_r_id)){
  382. $ret = lm($model['model_result'],'Sports')
  383. -> where(['id'=>$match_r_id])
  384. -> update($set_match_r);
  385. if($ret < 1) Render([], '10022', lang('Tips','Sports')->get('add_match_r_error'));
  386. }else{
  387. $ret = lm($model['model_result'],'Sports')->insert($set_match_r);
  388. if($ret != true) Render([], '10022', lang('Tips','Sports')->get('add_match_r_error'));
  389. }
  390. Render([], '1', lang('Tips','Sports')->get('success'));
  391. }
  392. //写入赛事结果记录
  393. public function com_result_record($opt){
  394. $game_code = $opt['game_code'];
  395. //根据球类代码获取相关model
  396. $model = $this->commonFunction->getModels($game_code,1);
  397. $data = $opt['data'];
  398. //验证结果所属联赛
  399. $lg_id = lm($model['model_local_league'],'Sports')
  400. ->select('lg_id')
  401. ->where(['others_lg_id'=>$data['lg_id'],'source'=>$data['source']])
  402. ->first()->lg_id;
  403. if($lg_id < 1) Render([], '10015', lang('Tips','Sports')->get('league_error'));
  404. //验证结果所属赛事
  405. $match_id = lm($model['model_local_match'],'Sports')
  406. ->select('match_id')
  407. ->where(['others_match_id'=>$data['match_id'],'source'=>$data['source']])
  408. ->value('match_id');
  409. if($match_id < 1) Render([], '10016', lang('Tips','Sports')->get('match_error'));
  410. $match_r_id = lm($model['model_result_record'],'Sports')
  411. ->where(['match_id'=>$match_id,'match_time'=>$data['match_time']])
  412. ->value('id');
  413. $set_match_r = [
  414. "home_team"=>$data['home_team'],
  415. "guest_team"=>$data['guest_team'],
  416. "lg_id"=>$lg_id,
  417. "home_rate"=> $data['home_rate'],
  418. "guest_rate"=> $data['guest_rate'],
  419. "home_score"=> $data['home_score'],
  420. "guest_score"=> $data['guest_score'],
  421. "all_goal"=> $data['all_goal'],
  422. "status"=>$data['status'],
  423. "first_score"=>$data['first_score'],
  424. "last_score"=> $data['last_score'],
  425. "match_score"=> $data['match_score'],
  426. "match_winer"=> $data['match_winer'],
  427. "match_time"=> $data['match_time'],
  428. "match_process"=> $data['match_process'],
  429. "tag"=> $data['tag'],
  430. "match_id"=> $match_id,
  431. "p_code"=> $data['p_code'],
  432. "update_time"=>$this->newTime
  433. ];
  434. //赛事结果记录处理
  435. if($match_r_id > 0){
  436. $ret = lm($model['model_result_record'],'Sports')
  437. ->where(['id'=>$match_r_id])
  438. ->update($set_match_r);
  439. if($ret < 1) Render([], '10022', lang('Tips','Sports')->get('add_match_r_r_error'));
  440. }else{
  441. $ret = lm($model['model_result_record'],'Sports')->insert($set_match_r);
  442. if($ret != true) Render([], '10022', lang('Tips','Sports')->get('add_match_r_r_error'));
  443. }
  444. Render([], '1', lang('Tips','Sports')->get('success'));
  445. }
  446. //写入赔率记录
  447. public function odds_record($opt){
  448. $game_code = $opt['game_code'];
  449. //根据球类代码获取相关model
  450. $model = $this->commonFunction->getModels($game_code,1);
  451. $data = $opt['data'];
  452. $match = lm($model['model_local_match'],'Sports')
  453. ->select('match_id','others_match_id')
  454. ->where(['others_match_id'=>$data['match_id'],'source'=>$data['source']])
  455. ->first();
  456. if(count($match) < 1) Render([], '10016', lang('Tips','Sports')->get('match_error'));
  457. //获取赛事 本地/源ID
  458. $others_match_id = $match->others_match_id;
  459. $match_id = $match->match_id;
  460. $lg = lm($model['model_local_league'],'Sports')
  461. ->select('lg_id','others_lg_id')
  462. ->where(['others_lg_id'=>$data['lg_id'],'source'=>$data['source']])
  463. ->first();
  464. if(count($lg) < 1) Render([], '10015', lang('Tips','Sports')->get('league_error'));
  465. //获取联赛 本地/源ID
  466. $others_lg_id = $lg->others_lg_id;
  467. $lg_id = $lg->lg_id;
  468. //查询 赔率数据是否存在
  469. $oddsID = lm($model['model_odds_record'],'Sports')
  470. ->where(['odds_only'=>$data['odds_only']])
  471. ->value('id');
  472. $set_odds = [
  473. 'match_id'=> $match_id,
  474. 'others_match_id'=> $others_match_id,
  475. 'odds_code'=> $data['odds_code'],
  476. 'status'=> $data['status'],
  477. 'sort'=> $data['sort'],
  478. 'p_code'=> $data['p_code'],
  479. 'odds'=> $data['odds'],
  480. 'condition'=> $data['condition'],
  481. 'odds_only'=> $data['odds_only'],
  482. 'source'=> $data['source'],
  483. 'type'=> $data['type'],
  484. 'team'=> $data['team'],
  485. 'lg_id'=> $lg_id,
  486. 'others_lg_id'=> $others_lg_id,
  487. 'ctime'=> $this->newTime,
  488. 'utime'=> $this->newTime,
  489. ];
  490. //更新或写入赔率记录
  491. if(!empty($oddsID)){
  492. $ret = lm($model['model_odds_record'],'Sports')
  493. ->where(['id'=>$oddsID])
  494. -> update($set_odds);
  495. if($ret < 1) Render([], '10020', lang('Tips','Sports')->get('add_odds_r_error'));
  496. }else{
  497. $ret = lm($model['model_odds_record'],'Sports')->insert($set_odds);
  498. if($ret != true) Render([], '10020', lang('Tips','Sports')->get('add_odds_r_error'));
  499. }
  500. Render([], '1', lang('Tips','Sports')->get('success'));
  501. }
  502. /**
  503. * @param $data
  504. * @return mixed
  505. * json转数组
  506. */
  507. public function getAddData($data){
  508. $data = json_decode($data,true);
  509. return $data;
  510. }
  511. }