field('platform_name, platform_code, platform_id, platform_remark, platform_url, platform_img') ->where($platformWhere) ->select(); return [ 'code' => 1, 'msg' => lang('MP01001'), 'data' => ['list' => $getPlatform], ]; }//end platformList() /** * 获取已注册平台列表 */ public function myPlatform() { $userToken = input('get.userToken'); // 获取用户信息. $getUserInfo = model('user')->currentUser($userToken); $getUserInfo = $getUserInfo['data']; // 获取平台列表. $platformWhere['platform_status'] = 1; $platformWhere['user_identity'] = $getUserInfo['user_identity']; $getPlatform = $this ->field('platform_user, platform_code, a.platform_id, platform_remark, platform_name, platform_img') ->alias('a') ->join('user_platform b', 'a.platform_id = b.platform_id') ->where($platformWhere) ->select(); // 循环添加验证码. foreach ($getPlatform as $k => $v) { $newCode = rand(100000, 999999); $codeData = [ 'code' => $newCode, 'time' => time(), ]; $codeKey = $v['platform_user'].'-'.$v['platform_code']; $data = [ 'code_key' => $codeKey, 'code_time' => $codeData['time'], ]; $addCode = model('Code')->addCode($data); $getPlatform[$k]['safetyCode'] = $newCode; } return [ 'code' => 1, 'msg' => lang('MP01001'), 'data' => ['list' => $getPlatform], ]; }//end myPlatform() /** * 安全验证 */ public function securityVerify() { $code = -2; $verifyCode = input('get.verifyCode'); $platformCode = input('get.platformCode'); $platformUser = input('get.userName'); if(empty($verifyCode)){ return [ 'code' => $code, 'msg' => lang('EP01007'), 'data' => [], ]; } if(empty($platformCode)){ return [ 'code' => $code, 'msg' => lang('EP01008'), 'data' => [], ]; } if(empty($platformUser)){ return [ 'code' => $code, 'msg' => lang('EP01009'), 'data' => [], ]; } $safetyCodeKey = $platformUser.'-'.$platformCode; $safetyCodeKey = model('Code')->selectCode($safetyCodeKey); $safetyCodeKey = $safetyCodeKey['data']; // 验证. $nowTime = strtotime(date('Y-m-d H:i:s').'-1 min'); if (!$safetyCodeKey || $safetyCodeKey['code_time'] < $nowTime) { return [ 'code' => $code, 'msg' => lang('EP01003'), 'data' => [], ]; } return [ 'code' => 1, 'msg' => lang('MP01002'), 'data' => [], ]; }//end securityVerify() /** * 获取平台验证码 */ public function platformToken($getData) { $code = -2; $userToken = input('get.userToken'); $userInfoWhere['user_token'] = $userToken; // 获取用户信息. $getUserInfo = model('user')->currentUser($userToken); $getUserInfo = $getUserInfo['data']; $platformId = $getData['platformId']; // 验证传参. $data = ['platformId' => $platformId]; $validate = Loader::validate('Platform'); if (!$validate->scene('platformToken')->check($data)) { return [ 'code' => $code, 'msg' => $validate->getError(), 'data' => [], ]; } // 获取平台信息. $platformWhere['platform_status'] = 1; $platformWhere['platform_id'] = $platformId; $getPlatform = $this ->field('platform_code') ->where($platformWhere) ->find(); // 加密. if(empty($getPlatform)){ return [ 'code' => $code, 'msg' => lang('EP01006'), 'data' => [], ]; } $token = randomPassword(); $data = [ 'user_identity' => $getUserInfo['user_identity'], 'platform_id' => $platformId, 'platform_code' => $getPlatform['platform_code'], 'platform_code_time' => time(), ]; $addCode = model('PlatformUser')->addPlatformUser($data); return [ 'code' => 1, 'msg' => lang('MC01005'), 'data' => [ 'verifySystem' => $token, 'verifySystemId' => $platformId, ], ]; }//end platformToken() /** * 验证 */ public function verifyPlatform() { $code = -2; $backSystem = input('get.backSystem'); $platformCode = input('get.platformCode'); $platformUser = input('get.userName'); if(empty($backSystem)){ return [ 'code' => $code, 'msg' => lang('EP01007'), 'data' => [], ]; } if(empty($platformCode)){ return [ 'code' => $code, 'msg' => lang('EP01008'), 'data' => [], ]; } if(empty($platformUser)){ return [ 'code' => $code, 'msg' => lang('EP01009'), 'data' => [], ]; } // 验证. $platformWhere['platform_code'] = $platformCode; $platformCode = model('PlatformUser')->selectPlatformUser($platformWhere); $platformCode = $platformCode['data']; $nowTime = strtotime(date('Y-m-d H:i:s').'-5 min'); if (!$platformCode || $platformCode['platform_code_time'] < $nowTime) { return [ 'code' => $code, 'msg' => lang('EP01002'), 'data' => [], ]; } // 获取平台信息. $platformWhere['platform_status'] = 1; $platformWhere['platform_code'] = $platformCode; $getPlatform = $this ->field('platform_id') ->where($platformWhere) ->find(); if (empty($getPlatform) === true) { return [ 'code' => $code, 'msg' => lang('EP01003'), 'data' => [], ]; } // 删除验证token. model('PlatformUser')->delPlatformUser($platformWhere); // 验证成功则加入数据. $addUserPlatform = model('UserPlatform')->addUserPlatform($platformCode['user_identity'], $getPlatform['platform_id'], $platformUser); return $addUserPlatform; }//end verifyPlatform() }