Account.php 26 KB

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