Account.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690
  1. <?php
  2. /**
  3. *------Create thems Controller------
  4. *------SCWPHP Version 1.0.0------
  5. *------Dev Model Jions------
  6. *------Create Time 2017-06-08 10:07:19------
  7. */
  8. namespace App\Api\Controller;
  9. use App\Api\Model\Lottery_money;
  10. use App\Api\Model\Lottery_money_log;
  11. use Biz\Account\AccountManager;
  12. use Biz\Common\Common;
  13. use Biz\Game\GameList;
  14. use System\Lang;
  15. class Account extends BaseController {
  16. private $accountManager;
  17. public function init() {
  18. $this->accountManager = new AccountManager();
  19. }
  20. /**
  21. * 验证用户资金密码
  22. */
  23. public function checkPayPass() {
  24. $payPass = $_POST['payPass'];
  25. $token = $_GET['token'] ?? '';
  26. if (empty($token)) {
  27. Render('5555', '-4010', lang('errors')->get('-4010'));
  28. }
  29. $status = \App\Api\Model\Account::checkPayPwd($token, $payPass);
  30. $data = new \stdClass();
  31. Render($data, $status);
  32. }
  33. /**
  34. * 用户登录
  35. */
  36. public function Login() {
  37. $result = $this->accountManager->login($_POST['account'], $_POST['password']);
  38. //$result = $this->accountManager->login('x0053', '123456');
  39. /*if ($result['status'] == 1) {
  40. $this->UserUpgrade();
  41. }*/
  42. Render($result['data'], $result['status'], $result['msg']);
  43. }
  44. /**
  45. * 用户修改密码
  46. */
  47. public function resetPassword() {
  48. $result = $this -> accountManager -> savePassword($_POST);
  49. Render($result['data'], $result['status'], $result['msg']);
  50. }
  51. /**
  52. * 用户注册
  53. */
  54. public function enroll() {
  55. $account_name = $_POST['account'];
  56. // if (stripos($_POST['account_name'],'guest') === false){
  57. //// var_dump($v['account_name']);
  58. // Render('',-4101);
  59. // }
  60. $result = $this->accountManager->register($_POST);
  61. if ($result['status'] == 1) {
  62. $settings = lm('settings', 'Commons')->first();
  63. $result['data']['0']['success_tip'] = $settings->success_tip;
  64. }
  65. Render($result['data'], $result['status'], $result['msg']);
  66. }
  67. /**
  68. * 直接开户
  69. */
  70. public function directAccount() {
  71. $result = $this->accountManager->directAccountOpening($_POST);
  72. Render($result['data'], $result['status'], $result['msg']);
  73. }
  74. /**
  75. * token获取用户详情
  76. */
  77. public function getAccount() {
  78. dd($_SESSION);
  79. if ($_REQUEST['dbg'] == 1) dd($_SESSION);
  80. $checkToken = $this->accountManager->checkEffectiveTime();
  81. if ($checkToken['status'] != 1) {
  82. Render($checkToken['data'], $checkToken['status'], $checkToken['msg']);
  83. };
  84. $result = $this->accountManager->refreshToken();
  85. //删除不需要的字段
  86. unset($result['data']['token']);
  87. unset($result['data']['finance_cash']);
  88. unset($result['data']['parent_id']);
  89. unset($result['data']['parent_path']);
  90. unset($result['data']['hand_pass']);
  91. if (!empty($result)) {
  92. $find_name = lm('dc_user_grade', 'commons')->where('grade', $result['data']['grade'])->first();
  93. if (!empty($find_name)) {
  94. $res = $find_name->toArray();
  95. $result['data']['vname'] = $res['name'];
  96. }
  97. }
  98. $result['data']['qq'] = trim($result['data']['qq']);
  99. if (!$result['data']['img_url']) {
  100. $result['data']['img_url'] = $result['data']['img_id'] ? "/Public/themes/default/static/img/{$result['data']['img_url']}.png" : "/Public/themes/default/static/img/0.png";
  101. }
  102. Render($result['data'], $result['status'], $result['msg']);
  103. }
  104. /**
  105. * 用户退出登录
  106. */
  107. public function Logout() {
  108. $account = $this->accountManager->getCurrentUser();
  109. if ($account) {
  110. $result = $this->accountManager->logout($account->account_identity);
  111. Render($result['data'], $result['status'], $result['msg']);
  112. } else {
  113. Render('', -1);
  114. }
  115. }
  116. /**
  117. * 试玩用户注册
  118. */
  119. public function Playtest() {
  120. $ip = GETIP();
  121. $time = lm('Setinfo', 'commons')->select('infocontent')->where('status', 1)->where('infotype', '2000')->first();
  122. $time = $time->toArray();
  123. // $limit_time = date ('Y-m-d H:i:s', strtotime ('-3day'));
  124. $limit_time = date('Y-m-d H:i:s', strtotime('-' . $time['infocontent'] . 'hour'));
  125. $res = lm('account_detailed', 'commons')->join('account', 'account.identity', 'account_detailed.account_identity')->where('account.status', 4)->where('register_ip', $ip)->where('register_time', '>', $limit_time)->first();
  126. if ($res) {
  127. Render('', -4025);
  128. }
  129. $result = $this->accountManager->demoAccount();
  130. Render($result['data'], $result['status'], $result['msg']);
  131. }
  132. /**
  133. * 判断是否已绑定银行卡
  134. */
  135. public function Iscard() {
  136. $result = $this->accountManager->Iscard();
  137. Render($result['data'], $result['status'], $result['msg']);
  138. }
  139. /**
  140. * 修改支付密码
  141. */
  142. public function resetPayPassword() {
  143. $_POST['token'] = isset($_GET['token']) ? $_GET['token'] : '';
  144. $result = $this->accountManager->updatePayPassword($_POST);
  145. Render($result['data'], $result['status'], $result['msg']);
  146. }
  147. /**
  148. * 申请代理用户
  149. */
  150. public function applyAgent() {
  151. $result = $this->accountManager->applyAgent($_POST);
  152. Render('', $result, lang('errors')->get($result));
  153. }
  154. /**
  155. * 代理用户登录
  156. */
  157. public function agentLogin() {
  158. $result = $this->accountManager->agentLogin($_POST);
  159. if ($result < 0) {
  160. Render('', $result);
  161. } else {
  162. Render($result, 1, lang('errors')->get(1));
  163. }
  164. }
  165. /**
  166. * 代理用户token是否过期
  167. */
  168. public function agentTokenOverdue() {
  169. $token = isset($_GET['token']) ? $_GET['token'] : '';
  170. $result = $this->accountManager->agentTokenOverdue($token);
  171. if ($result < 0) {
  172. Render('', $result, lang('errors')->get($result));
  173. } else {
  174. Render($result, 1, lang('errors')->get(1));
  175. }
  176. }
  177. /**
  178. *登录添加登录区域日志
  179. */
  180. public function areaLog() {
  181. $result = $this->accountManager->areaLog($_GET['ip'], $_GET['accountIdentity']);
  182. if ($result == 1) {
  183. Render('', $result, '成功');
  184. } else {
  185. Render('', $result, '添加登录日志区域错误');
  186. }
  187. }
  188. /**
  189. * 获取用户信息
  190. */
  191. function getAccountInfo() {
  192. $data = array();
  193. $data = $_SESSION['uinfo'];
  194. $bankInfo = lm('account_bank', 'commons')->where('account_identity', $_SESSION['uinfo']['account_identity'])->first();
  195. if (empty($bankInfo)) {
  196. Render('', -40451);
  197. }
  198. $bankInfo = $bankInfo->toArray();
  199. $data['bank_name'] = $bankInfo['bank_name'];
  200. $data['bank_address'] = $bankInfo['bank_address'];
  201. $data['bank_number'] = $bankInfo['bank_number'];
  202. Render($data, 1);
  203. }
  204. /**
  205. * token获取用户详情
  206. */
  207. public function getAgent() {
  208. $checkToken = $this->accountManager->checkEffectiveTime();
  209. if ($checkToken['status'] != 1) {
  210. Render($checkToken['data'], $checkToken['status'], lang('commons')->get('user does login'));
  211. };
  212. $result = $this->accountManager->refreshToken();
  213. Render($result['data'], $result['status'], $result['msg']);
  214. }
  215. /**
  216. * 等级升级申请
  217. * @return [type] [description]
  218. */
  219. public function UserUpgrade(int $total_flow = 0) {
  220. $uinfo = $this->accountManager->getCurrentUser();
  221. if (!$uinfo) {
  222. return '-50003';
  223. }
  224. $result['data'] = $uinfo->toArray();
  225. if ($result['data']['grade'] == 0 || $result['data']['grade'] == -1) {
  226. return '-50019';
  227. }
  228. $res = lm('UserGrade', 'Api')->upgrade($result['data'], $total_flow);
  229. if ($res == 1) {
  230. return 1;
  231. } else {
  232. return $res;
  233. }
  234. }
  235. /**
  236. * 活动升级彩金公用接口
  237. * @return [type] [description]
  238. */
  239. public function Promotiongold() {
  240. $id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : "";
  241. if (empty($id)) {
  242. Render('', "-50009");
  243. }
  244. $wherel['id'] = $id;
  245. $Promotiong = lm('lottery_money', 'Api')->where($wherel)->first();
  246. if (empty($Promotiong)) {
  247. Render('', "-50010");
  248. }
  249. $Promotiong = $Promotiong->toArray();
  250. if ($Promotiong['type'] == 'upgrade') {
  251. $this->rank($id);
  252. } elseif ($Promotiong['type'] == 'first_save') {
  253. $utype = $_REQUEST['per_key'];
  254. if (!$utype) {
  255. Render('', -50025);
  256. }
  257. $this->firstRecharge($id, $utype);
  258. }
  259. }
  260. //晋级彩金
  261. public function rank($id) {
  262. $uinfo = $this->accountManager->getCurrentUser();
  263. if (!$uinfo) {
  264. return '-50003';
  265. }
  266. $result['data'] = $uinfo->toArray();
  267. if ($result['data']['grade'] == 0 || $result['data']['grade'] == '-1') {
  268. return Render('', '-50035');
  269. }
  270. $res = lm('UserGrade', 'Api')->gold($result['data'], $id);
  271. if ($res == 1) {
  272. return Render('', 1);
  273. } else {
  274. return Render('', $res);
  275. }
  276. }
  277. protected function firstRecharge($active_id, $utype = '') {
  278. $uinfo = $this->accountManager->getCurrentUser();
  279. if (!$uinfo) {
  280. Render('', -50011);
  281. }
  282. $userinfo = $uinfo->toArray();
  283. //$userinfo = lm ('AccountDetail', 'Api')->where ('account_identity', $uinfo['account_identity'])->first ();
  284. $account = $userinfo['account'];
  285. $account_identity = $userinfo['account_identity'];
  286. $lm = new Lottery_money();
  287. $type = 'first_save';
  288. $data = $lm->where('id', $active_id)->first()->toArray();
  289. if (!$data)
  290. Render('', -50016);
  291. $money = 0;
  292. //todo:首充检查并返回金额
  293. $content = json_decode($data['conent'], 1);
  294. $ftype = $content['fr_type'];
  295. $f = \App\Api\Model\Account::chkFirstRecharge($account_identity, $active_id, $ftype);
  296. $order_id = $f->order_id;
  297. $activeName = Lottery_money::where('id', $active_id)->first(['name'])->name ?? '';
  298. $Lottery_log = new Lottery_money_log();
  299. //查询申请记录
  300. $where = [
  301. ['account_identity', $account_identity],
  302. ['order_id', $order_id],
  303. ['status', '<>', 2]
  304. ];
  305. //需要逻辑:查询当前用户当前订单号是否有参与当前活动
  306. $active = $Lottery_log->where($where)->first();
  307. if ($active) {
  308. Render('', -50034);
  309. }
  310. $money = $f->money;
  311. $ranges = json_decode($data['conent'], 1)['ranges'];
  312. $sel = (function ($param, $num, $type) {
  313. foreach ($param as $k => $v) {
  314. if ($v[5] == $type && $num >= $v[0])
  315. return $v;
  316. }
  317. return [];
  318. })($ranges, $money, $utype);
  319. if (!$sel)
  320. Render('', -50016);//无活动数据
  321. $giftMoney = $money * ($sel[2] / 100);
  322. if ($giftMoney > (float)$sel[3])
  323. $giftMoney = $sel[3];
  324. $totalMoney = $giftMoney + $money;
  325. $rate = $sel[2];
  326. $frate = $sel[4];
  327. $needMoney = $totalMoney * $frate;
  328. $newremark = ['gift_money' => $giftMoney, 'money' => $money, 'needBettingMoney' => $needMoney, 'frate' => $sel[2] / 100, 'rate' => $sel[4]];
  329. $tpl = lang('money')->get('first');
  330. $grade = $sel[5];
  331. $newremark['selected'] = $grade;
  332. $detail = sprintf($tpl, $account, $activeName, $money, $rate, $giftMoney, $grade, $frate, $order_id);
  333. $newremark = json_encode($newremark);
  334. if (!$active) {
  335. {
  336. $data = [];
  337. $data['account_identity'] = $account_identity;
  338. $data['grade'] = $userinfo["grade"];
  339. $data['lottery_money_type'] = $type;
  340. $data['lottery_money_id'] = $active_id;
  341. $data['money'] = $giftMoney;
  342. $data['create_time'] = date('Y-m-d H:i:s');
  343. $data['status'] = 0;
  344. $data['detail'] = $detail ?? '无';
  345. $data['account_name'] = $account;
  346. $data['lottery_money_name'] = $activeName;
  347. $data['flow_record'] = $newremark ?? '';
  348. $data['order_id'] = $order_id;
  349. $res = lm('lottery_money_log', 'Api')->insert($data);
  350. }
  351. if ($res) Render('', 1);
  352. }
  353. Render('', -30018);
  354. }
  355. public function analysis($str = '', $arr = array()) {
  356. if (empty($str)) {
  357. return -51055;
  358. }
  359. if (empty($arr)) {
  360. return -51055;
  361. }
  362. foreach ($arr as $key => $value) {
  363. $str = str_replace("#" . $key . "#", $value, $str);
  364. }
  365. return $str;
  366. }
  367. //申请vip
  368. public function ApplyVip() {
  369. $result = $this->accountManager->refreshToken();
  370. if ($result['status'] < 0) {
  371. Render('', "-50011");
  372. }
  373. if ($result['data']['grade'] > 0) {
  374. Render('', "-50028");
  375. }
  376. if ($result['data']['grade'] != 0) {
  377. Render('', "-50028");
  378. }
  379. //试玩账号 --2019/1/15 17/14 blues
  380. if (isset($result['data']['status']) && $result['data']['status'] == 4) {
  381. Render('', -4026);
  382. }
  383. $num = lm('User_vip', 'Api')->where('account_identity', $result['data']['account_identity'])->count();
  384. if ($num == 0) {
  385. $data['account_name'] = $result['data']['account'];
  386. $data['account_identity'] = $result['data']['account_identity'];
  387. $data['addtime'] = date('Y-m-d H:i:s');
  388. $data['status'] = 1;
  389. $res = lm('User_vip', 'Api')->insert($data);
  390. if ($res) {
  391. lm('AccountDetail', 'Api')->where('account_identity', $result['data']['account_identity'])->update(['grade' => -1]);
  392. Render('', '1');
  393. } else {
  394. Render('', "-50026");
  395. }
  396. } else {
  397. if ($result['data']['grade'] == 0) {
  398. lm('User_vip', 'Api')->where('account_identity', $result['data']['account_identity'])->update(['status' => 1]);
  399. lm('AccountDetail', 'Api')->where('account_identity', $result['data']['account_identity'])->update(['grade' => -1]);
  400. Render('', '1');
  401. } else {
  402. Render('', "-50036");
  403. }
  404. }
  405. }
  406. //开新用户
  407. public function households() {
  408. if (empty($_POST['account'])) {
  409. Render('', "-50060", '缺少用户名称');
  410. }
  411. if (empty($_POST['name'])) {
  412. Render('', "-50061", '缺少真实用户名称');
  413. }
  414. if (empty($_POST['password'])) {
  415. Render('', "-50062", '缺少密码');
  416. }
  417. if (empty($_POST['again_password'])) {
  418. Render('', "-50063", '缺少确定密码');
  419. }
  420. if ($_POST['password'] != $_POST['again_password']) {
  421. Render('', "-50064", '确定密码不一致');
  422. }
  423. if (empty($_POST['phone'])) {
  424. Render('', "-50065", '缺少手机号码');
  425. }
  426. $this->checkLogin();
  427. $uinfo = $this->accountManager->getCurrentUser();
  428. if (empty($uinfo->account_identity)) {
  429. Render('', "-50066", '用户未登录');
  430. }
  431. $_POST['parent_identity'] = $uinfo->account_identity;
  432. $result = $this->accountManager->newhouseholds($_POST);
  433. Render($result['data'], $result['status'], $result['msg']);
  434. }
  435. protected function checkLogin() {
  436. $checkToken = $this->accountManager->checkEffectiveTime();
  437. if ($checkToken['status'] != 1) {
  438. Render($checkToken['data'], $checkToken['status'], $checkToken['msg']);
  439. };
  440. $this->accountManager->refreshToken();
  441. }
  442. public function checkHandPass() {
  443. $hand_pass = $_REQUEST['hand_pass'];
  444. $this->checkLogin();
  445. $uinfo = $this->accountManager->getCurrentUser();
  446. $uuid = $uinfo->account_identity;
  447. if ($uuid) {
  448. $ret = lm('UserSetting', 'api')->getUserSetting($uuid);
  449. //dd($ret);
  450. if ($ret && isset($ret['hand_pass']) && $ret['hand_pass']) {
  451. if (!$ret['hand_lock'])
  452. Render('' - 60002);//未开启手势密码
  453. if ($ret['hand_pass'] === md5($hand_pass))
  454. Render('', 1);
  455. Render('', -60000);//手势密码不匹配
  456. } else
  457. Render('', -60001);//未设置手势密码
  458. }
  459. Render('', -51017);//用户不存在
  460. }
  461. public function getUserSetting() {
  462. $this->checkLogin();
  463. $uinfo = $this->accountManager->getCurrentUser();
  464. $uuid = $uinfo->account_identity;
  465. $ret = lm('UserSetting', 'api')->getUserSetting($uuid);
  466. if ($_REQUEST['devicetype'] === 'android' || $_REQUEST['devicetype'] === 'ios') {
  467. $ret['fav_info'] = json_decode($ret['fav_info'], 1) ?? [];
  468. $ret['cart_info'] = json_decode($ret['cart_info'], 1) ?? [];
  469. }
  470. Render($ret, 1);
  471. }
  472. public function setUserSetting() {
  473. $this->checkLogin();
  474. $uinfo = $this->accountManager->getCurrentUser();
  475. //if ($uinfo && $uinfo->account_identity)
  476. $uuid = $uinfo->account_identity;
  477. if (isset($_POST['hand_pass']) && $_POST['hand_pass'] != '') $data ['hand_pass'] = md5($_POST['hand_pass']);
  478. if (isset($_POST['hand_lock']) && $_POST['hand_lock'] != '') $data ['hand_lock'] = $_POST['hand_lock'];
  479. if (isset($_POST['sound']) && $_POST['sound'] != '') $data ['sound'] = $_POST['sound'];
  480. if (isset($_POST['shake_rand']) && $_POST['shake_rand'] != '') $data ['shake_rand'] = $_POST['shake_rand'];
  481. if (isset($_POST['prize_ani']) && $_POST['prize_ani'] != '') $data ['prize_ani'] = $_POST['prize_ani'];
  482. if (isset($_POST['prize_all']) && $_POST['prize_all'] != '') $data ['prize_all'] = $_POST['prize_all'];
  483. if (isset($_POST['win_games']) && $_POST['win_games'] != '') $data ['win_games'] = $_POST['win_games'];
  484. if (isset($_POST['prize_games']) && $_POST['prize_games'] != '') $data ['prize_games'] = $_POST['prize_games'];
  485. if (isset($_POST['fav_info']) && $_POST['fav_info'] != '') $data ['fav_info'] = ($_POST['fav_info']);
  486. if (isset($_POST['cart_info']) && $_POST['cart_info'] != '') $data ['cart_info'] = ($_POST['cart_info']);
  487. if (isset($_POST['device_state']) && $_POST['device_state'] != '') $data ['device_state'] = ($_POST['device_state']);
  488. if (isset($_POST['device_number']) && $_POST['device_number'] != '') $data ['device_number'] = ($_POST['device_number']);
  489. if ($data['prize_games'] == -1) $data['prize_games'] = '';
  490. $lm = lm('UserSetting', 'api');
  491. $favs = json_decode($data['fav_info'], 1);
  492. $favs = array_unique($favs);
  493. $data['fav_info'] = json_encode($favs);
  494. $ret = $lm->setUserSettings($uuid, $data);
  495. Render('', 1);
  496. }
  497. public function setUserSet() {
  498. $this->checkLogin();
  499. $uinfo = $this->accountManager->getCurrentUser();
  500. //if ($uinfo && $uinfo->account_identity)
  501. $uuid = $uinfo->account_identity;
  502. // $data ['hand_pass'] = md5 ($_POST['hand_pass']);
  503. // $data ['win_games'] = $_POST['win_games'];
  504. $data = array(
  505. 'prize_all' => isset($_POST['prize_all']) ? 1 : 0,
  506. 'win_games' => isset($_POST['win_games']) ? 1 : 0,
  507. );
  508. if (empty($data)) {
  509. return -909090;
  510. }
  511. $ret = lm('UserSetting', 'api')->where('account_identity', $uuid)->update($data);
  512. if ($ret == 1) {
  513. return Render('', 1);
  514. } else {
  515. return Render('', 0);
  516. }
  517. }
  518. public function setHeadImg() {
  519. //$imgUrl = $_REQUEST['imgUrl'];
  520. $imgId = $_REQUEST['imgId'] ?? 0;
  521. $accountMan = new AccountManager();
  522. // if ($_POST['dd'] == 1)
  523. // dd ($imgUrl);
  524. // if (!$imgUrl) {
  525. // $arr = json_decode (file_get_contents ('php://input'), 1);
  526. // if (isset($arr['imgUrl']) && $arr['imgUrl']) {
  527. // $imgUrl = $arr['imgUrl'];
  528. // }
  529. // }
  530. $ret = null;
  531. $imgUrl = "/Public/themes/default/static/img/{$imgId}.png";
  532. if ($imgUrl) $ret = $accountMan->chHeadImg($imgUrl, $imgId);
  533. if ($ret < 1) {
  534. Render('', $ret);
  535. }
  536. Render($ret, 1);
  537. }
  538. public function setDetail() {
  539. $phone = $_POST['phone'] ? strip_tags(trim($_POST['phone'])) : '';
  540. $qq = $_POST['qq'] ? strip_tags(trim($_POST['qq'])) : '';
  541. $email = $_POST['email'] ? strip_tags(trim($_POST['email'])) : '';
  542. $wechat = $_POST['wechat'] ? strip_tags(trim($_POST['wechat'])) : '';
  543. if (!$phone && !$qq && !$email && !$wechat) {
  544. Render('', -40256);//数据不能全为空
  545. }
  546. $data = [];
  547. if ($phone) {
  548. $data['phone'] = $phone;
  549. }
  550. if ($qq) {
  551. $data['qq'] = $qq;
  552. }
  553. if ($email) {
  554. $data['email'] = $email;
  555. }
  556. if ($wechat) {
  557. $data['wechat'] = $wechat;
  558. }
  559. $accountMan = new AccountManager();
  560. $uinfo = $accountMan->getCurrentUser();
  561. $uuid = $uinfo->account_identity ?? null;
  562. if (!$uuid) {
  563. Render('', -4001);//用户未找到
  564. }
  565. $ret = lm('AccountDetail', 'Api')->where('account_identity', $uuid)->update($data);
  566. if ($ret) {
  567. Render('', 1);
  568. } else {
  569. Render('', -40254);
  570. }
  571. }
  572. //获取当前用户安全等级
  573. public function safetygrade() {
  574. //if($_REQUEST['dbg']==1)dd($_SESSION);
  575. $checkToken = $this->accountManager->checkEffectiveTime();
  576. if ($checkToken['status'] != 1) {
  577. Render($checkToken['data'], $checkToken['status'], $checkToken['msg']);
  578. };
  579. $result = $this->accountManager->refreshToken();
  580. if (!empty($result)) {
  581. $bankstate = lm('account_bank', 'commons')->where('account_identity', $result['data']['account_identity'])->count();
  582. $paypasswordstate = lm('pay_password', 'commons')->where('account_identity', $result['data']['account_identity'])->count();
  583. if ($bankstate != 0 && $paypasswordstate != 0 && $result['data']['email'] != '' && $result['data']['qq'] != '') {
  584. $safetystate = '高';
  585. } elseif ($bankstate != 0 && $paypasswordstate != 0) {
  586. $safetystate = '中';
  587. } else {
  588. $safetystate = '低';
  589. }
  590. Render($safetystate, 1);
  591. } else {
  592. Render('', $result['status'], $result['msg']);
  593. }
  594. }
  595. //检查用户是否已注册
  596. public function isRegistered() {
  597. $an = $_REQUEST['account_name'];
  598. $ret = (new \App\Api\Model\Account())->where('account', $an)->exists();
  599. Render(null, $ret ? -40040 : 1);
  600. }
  601. /**
  602. *错误码列表接口
  603. */
  604. public function getErrLangs() {
  605. $lang = Lang('Errors', 'Api');
  606. $langs = $lang->getAll();
  607. $newLangs = [];
  608. foreach ($langs as $k => $v) {
  609. $k = trim($k, 'error');
  610. $newLangs["$k"] = $v;
  611. }
  612. Render($newLangs, 1);
  613. }
  614. /**
  615. * 玩法语言包总列表接口
  616. */
  617. public function getGameLangs() {
  618. if (C()->get('cache')->has('totalGameLangs')) {
  619. $data = C()->get('cache')->get('totalGameLangs');
  620. // C()->get('cache')->delete('totalGameLangs');
  621. } else {
  622. $cls = new Common();
  623. $data = $cls->getGameLangs();
  624. C()->get('cache')->set('totalGameLangs', $data, 86400 * 7);
  625. }
  626. Render($data, 1);
  627. }
  628. }