Account.php 24 KB

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