master
ELF 5 years ago
parent 8a8c7a17ba
commit 15d0b454a4

@ -1194,7 +1194,9 @@ class PromoteController extends ThinkController
$data['data']['game_list'] = empty($game_list) ? '' : $game_list;
//获取推广员信息
$promote_info = M('promote', 'tab_')->field('id,account,game_ids')->where(['id'=>I('id', 0, 'intval')])->find();
if (!empty($promote_info['game_ids'])) {
if (empty($promote_info['game_ids'])) {
$promote_info['game_ids'] = [];
} else {
$this->changeGameidToRelationGameid($promote_info['game_ids']);
$promote_info['game_ids'] = explode(',', $promote_info['game_ids']);
}

@ -65,29 +65,45 @@ class PromoteModel extends Model{
$map['account'] = $account;
/* 获取用户数据 */
$user = $this->where($map)->find();
if(is_array($user) && $user['status'] == 1){
/* 验证用户密码 */
if(think_ucenter_md5($password, UC_AUTH_KEY) === $user['password']){
$this->autoLogin($user); //更新用户登录信息
return $user['id']; //登录成功返回用户ID
} else {
return -2; //密码错误
}
$status = $this->checkStatus($user);
if ($status != 1) {
return $status;
}
/* 验证用户密码 */
if(think_ucenter_md5($password, UC_AUTH_KEY) === $user['password']){
$this->autoLogin($user); //更新用户登录信息
return $user['id']; //登录成功返回用户ID
} else {
if(is_array($user) && $user['status'] == 2){return -3;}
if(is_array($user) && $user['status'] == 0){return -4;}
return -1; //用户不存在或被禁用
return -2; //密码错误
}
}
public function login_phone($user) {
$status = $this->checkStatus($user);
if ($status != 1) {
return $status;
}
$this->autoLogin($user);
return $user['id'];
}
public function checkStatus($user)
{
if (!is_array($user)) {
return -1;
}
if ($user['status'] == 1) {
return 1;
} elseif ($user['status'] == 2) {
return -3;
} elseif ($user['status'] == 0) {
return -4;
}
return -1;
}
public function register($reg_data){
$data = array(
'account' => $reg_data['account'],

@ -588,9 +588,9 @@
lis.push('<li class="fl pro_promot_game_con" data-short="'+ele.short+'">');
if(promote_info['game_ids']==''){
lis.push('<input type="checkbox" value="'+ele.id+'" name="game_ids[]" class="fl pro_promot_game_check jsgameid" checked="checked" id="gameCheck'+index+'" />');
}else{
// if(promote_info['game_ids']==''){
// lis.push('<input type="checkbox" value="'+ele.id+'" name="game_ids[]" class="fl pro_promot_game_check jsgameid" checked="checked" id="gameCheck'+index+'" />');
// }else{
if(promote_info['game_ids'].indexOf(ele.id)>-1){
lis.push('<input type="checkbox" value="'+ele.id+'" name="game_ids[]" class="fl pro_promot_game_check jsgameid" checked="checked" id="gameCheck'+index+'" />');
}else{
@ -598,7 +598,7 @@
lis.push('<input type="checkbox" value="'+ele.id+'" name="game_ids[]" class="fl pro_promot_game_check jsgameid" id="gameCheck'+index+'" />');
checked = '';
}
}
// }
lis.push('<label for="gameCheck'+index+'" class="fl"></label>');
lis.push('<span class="fl pro_promot_game_name">'+ele.game_name+'</span>');

@ -1035,7 +1035,7 @@ class PromoteService {
return null;
}
public function canPresidentApplyGame($promote)
public function isPresidentAccess($promote)
{
$topPromote = $this->getTopPromote($promote);
if (in_array($topPromote['company_belong'], [1, 2])) {
@ -1110,8 +1110,10 @@ class PromoteService {
public function getVisibleGameIds($promote)
{
$gameIds = M('game', 'tab_')->getField('id', true);
$selfGameIds = $promote['game_ids'] == '' ? $gameIds : explode(',', $promote['game_ids']);
/* $gameIds = M('game', 'tab_')->getField('id', true);
$selfGameIds = $promote['game_ids'] == '' ? $gameIds : explode(',', $promote['game_ids']); */
$selfGameIds = $promote['game_ids'] == '' ? [] : explode(',', $promote['game_ids']);
if ($promote['level'] == 1) {
return $selfGameIds;
}

@ -1028,7 +1028,7 @@ class ApplyController extends BaseController
if ($_POST['game_id']) {
$loginPromote = $this->getLoginPromote();
$promoteService = new PromoteService();
if (!$promoteService->canPresidentApplyGame($loginPromote)) {
if (!$promoteService->isPresidentAccess($loginPromote)) {
$this->ajaxReturn([
'status' => 0,
'msg' => '请联系市场专员开启',
@ -1640,7 +1640,7 @@ class ApplyController extends BaseController
{
$promote = $this->getLoginPromote();
$promoteService = new PromoteService();
if (!$promoteService->canPresidentApplyGame($promote)) {
if (!$promoteService->isPresidentAccess($promote)) {
$this->ajaxReturn([
'status' => 0,
'message' => '请联系市场专员开启',
@ -1820,7 +1820,7 @@ class ApplyController extends BaseController
}
$promoteService = new PromoteService();
if (!$promoteService->canPresidentApplyGame($promote)) {
if (!$promoteService->isPresidentAccess($promote)) {
$this->ajaxReturn([
'status' => 0,
'message' => '请联系市场专员开启',
@ -1873,7 +1873,7 @@ class ApplyController extends BaseController
}
$promoteService = new PromoteService();
if (!$promoteService->canPresidentApplyGame($promote)) {
if (!$promoteService->isPresidentAccess($promote)) {
$this->ajaxReturn([
'status' => 0,
'message' => '请联系市场专员开启',

@ -135,7 +135,7 @@ class GameController extends BaseController
}
$promoteService = new PromoteService();
if (!$promoteService->canPresidentApplyGame($loginPromote)) {
if (!$promoteService->isPresidentAccess($loginPromote)) {
return $this->ajaxReturn(['status' => 0, 'message' => '请联系市场专员开启']);
}
@ -200,7 +200,7 @@ class GameController extends BaseController
$loginPromote = $this->getLoginPromote();
$promoteService = new PromoteService();
if (!$promoteService->canPresidentApplyGame($loginPromote)) {
if (!$promoteService->isPresidentAccess($loginPromote)) {
return $this->ajaxReturn(['status' => 0, 'message' => '请联系市场专员开启']);
}
@ -1829,7 +1829,7 @@ class GameController extends BaseController
{
$promote = $this->getLoginPromote();
$promoteService = new PromoteService();
if (!$promoteService->canPresidentApplyGame($promote)) {
if (!$promoteService->isPresidentAccess($promote)) {
$this->ajaxReturn([
'status' => 0,
'message' => '请联系市场专员开启',
@ -2009,7 +2009,7 @@ class GameController extends BaseController
}
$promoteService = new PromoteService();
if (!$promoteService->canPresidentApplyGame($promote)) {
if (!$promoteService->isPresidentAccess($promote)) {
$this->ajaxReturn([
'status' => 0,
'message' => '请联系市场专员开启',
@ -2062,7 +2062,7 @@ class GameController extends BaseController
}
$promoteService = new PromoteService();
if (!$promoteService->canPresidentApplyGame($promote)) {
if (!$promoteService->isPresidentAccess($promote)) {
$this->ajaxReturn([
'status' => 0,
'message' => '请联系市场专员开启',

@ -15,6 +15,7 @@ use User\Api\PromoteApi;
use Home\Controller\DownController;
use Base\Tool\TaskClient;
use Base\Service\PromoteService;
/**
* 前台首页控制器
@ -68,10 +69,16 @@ class IndexController extends HomeController
$account = $_POST['account'];
$password = $_POST['password'];
$promote = new PromoteApi();
$result = $promote->login($account, $password);
$api = new PromoteApi();
$result = $api->login($account, $password);
if ($result > 0) {
$promote = M("promote", "tab_")->where(['id' => $result])->find();
$promoteService = new PromoteService();
if ($promoteService->isPresidentAccess($promote)) {
$this->ajaxReturn(array("status" => 0, "msg" => '请联系市场专员开通账号。'));
}
$map['account'] = $account;
$data['last_login_time'] = time();
M("promote", "tab_")->where($map)->save($data);
@ -83,25 +90,7 @@ class IndexController extends HomeController
M("promote_login_record", "tab_")->add($loginrecord);
$this->ajaxReturn(array("status" => 1, "msg" => "登录成功", 'url' => U('Promote/index')));
} else {
$msg = "";
switch ($result) {
case -1:
$msg = "账号或密码错误!";
break;
case -2:
$msg = "账号或密码错误!";
break;
case -3:
$msg = "账号被禁用,请联系管理员";
break;
case -4:
$msg = "审核中,请联系管理员";
break;
default:
$msg = "未知错误!请联系管理员";
break;
}
$msg = $this->getLoginMessage($result);
$this->ajaxReturn(array("status" => 0, "msg" => $msg));
}
}
@ -115,6 +104,7 @@ class IndexController extends HomeController
$promote = M('promote', 'tab_')->where([
'login_phone' => $mobile,
])->find();
if($promote) {
$loginrecord['promote_id'] = $promote['id'];
$loginrecord['account'] = $promote['account'];
@ -123,17 +113,48 @@ class IndexController extends HomeController
$loginrecord['create_time'] = time();
M("promote_login_record", "tab_")->add($loginrecord);
setcookie('login_phone', $mobile, time() + 3600 * 10000, $_SERVER["HTTP_HOST"]);
$promote1 = new PromoteApi();
$result = $promote1->login_phone($promote['account']);
if ($result) {
$api = new PromoteApi();
$result = $api->login_phone($promote['account']);
if ($result > 0) {
$promoteService = new PromoteService();
if ($promoteService->isPresidentAccess($promote)) {
$this->ajaxReturn(array("status" => 0, "msg" => '请联系市场专员开通账号。'));
}
$this->ajaxReturn(array("status" => 1, "msg" => "登录成功", 'url' => U('Promote/index')));
}
}else {
} else {
$msg = $this->getLoginMessage($result);
$this->ajaxReturn(array("status" => 0, "msg" => $msg));
}
} else {
$this->error('此电话未注册,登录失败');
}
}
public function getLoginMessage($result)
{
$msg = "";
switch ($result) {
case -1:
$msg = "账号或密码错误!";
break;
case -2:
$msg = "账号或密码错误!";
break;
case -3:
$msg = "账号被禁用,请联系管理员";
break;
case -4:
$msg = "审核中,请联系管理员";
break;
default:
$msg = "未知错误!请联系管理员";
break;
}
return $msg;
}
/* public function register()
{
if (IS_POST) {

Loading…
Cancel
Save