Account.php 24 KB

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