@ -21,9 +21,19 @@ class SsgController extends BaseController {
public function login(){
$user = session("user_auth");
$promoteId = I("promote_id");
if (!$promoteId) {
$this->error("参数非法");
}
$exists = M("promote", "tab_")->where(array('id' => $promoteId))->find();
if (!$exists) {
$this->error("参数非法.");
}
/*if ($user) {
redirect(U("ssg/index"));
}*/
$this->assign("promote_id", $promoteId);
$this->display();
}
@ -36,6 +46,15 @@ class SsgController extends BaseController {
{
$account = I("Account");
$password = I("Password");
$promoteId = I("promote_id");
if (!$promoteId) {
$this->ajaxReturn(array("ErrorCode" => -97, "ResultMsg" => "参数非法"));
}
$promote = M("promote", "tab_")->where(array('id' => $promoteId))->find();
if (!$promote) {
$this->ajaxReturn(array("ErrorCode" => -97, "ResultMsg" => "参数非法."));
}
//var_dump($password);
$verify = new \Think\Verify();
if (!$verify->check(I("VerifyCode"))) {
@ -62,6 +81,18 @@ class SsgController extends BaseController {
}
if($user_id>0){
$_SESSION['user_id'] = $user_id;
$user = M('user', 'tab_')->where(array(
'id' => $user_id
))->find();
if (!$user['promote_id']) {
M('user', 'tab_')->where(array(
'id' => $user_id
))->save(array(
'promote_id' => $promoteId,
'promote_account' => $promote['account']
));
}
}
$this->ajaxReturn(array("ErrorCode"=>$res_code,"ResultMsg"=>$res_msg),'JSON');
}
@ -95,6 +126,15 @@ class SsgController extends BaseController {
$map['a.user_id']= $user['user_id'];
$map['a.sdk_version'] = 2;
$game_list = M("user_play a","tab_")->field("b.*,b.id as game_id,od.pay_status")->join("inner join tab_game b on a.game_id=b.id left join tab_game_supersign od on od.user_id=a.user_id and od.game_id=b.id and od.pay_status=1")->where($map)->select();
if (!$game_list) {
$game_list = M("game", "tab_")->field("*, id as game_id")->where(array(
"sdk_version" => 2,
"game_status" => 1,
))->select();
foreach ($game_list as & $v) {
$v['pay_status'] = 0;
}
}
$this->assign("data_list",$game_list);
$this->display();
}