From 394e4fa863f445f0b5a339e239cf52a7d39f8641 Mon Sep 17 00:00:00 2001 From: tping Date: Tue, 14 Dec 2021 23:17:39 +0800 Subject: [PATCH] 1 --- .../Sdk/Controller/UserController.class.php | 56 +++++++++++++++++-- 1 file changed, 52 insertions(+), 4 deletions(-) diff --git a/Application/Sdk/Controller/UserController.class.php b/Application/Sdk/Controller/UserController.class.php index a51e157c..6953a337 100644 --- a/Application/Sdk/Controller/UserController.class.php +++ b/Application/Sdk/Controller/UserController.class.php @@ -938,17 +938,16 @@ class UserController extends BaseController */ public function user_phone_register() { - C(api('Config/lists')); #获取SDK上POST方式传过来的数据 然后base64解密 然后将json字符串转化成数组 $user = json_decode(base64_decode(file_get_contents("php://input")), true); #判断数据是否为空 if (empty($user)) { - $this -> set_message(1001, "fail", "注册数据不能为空"); + $this->set_message(1001, "fail", "注册数据不能为空"); } Log::write('user_phone_register:' . date('Y-m-d H:i:s') . ' ---- ' . json_encode($user), 'INFO'); #验证短信验证码 - $this -> sms_verify($user['account'], $user['code']); + $this->sms_verify($user['account'], $user['code']); /**是否开启ucenter**/ if (C('UC_OPEN') == 1) { //Ucenter注册 @@ -979,9 +978,58 @@ class UserController extends BaseController cus_uc_register($user['account'], $user['password'], $user['account'] . '@vlcms.com'); } } - $this -> reg_data($user, 2); + try { + $this->register_check($user); + } catch (\Exception $e) { + $this->set_message(1001, "fail", $e->getMessage()); + } + $this->reg_data($user, 2); + } + private function register_check($data) { + if (!isset($data['promote_id']) || !$data['promote_id']) { + return true; + } + $baseGame = M('base_game', 'tab_')->where([ + 'android_game_id|ios_game_id' => $data['game_id'] + ])->find(); + if (!$baseGame) { + throw new \Exception("游戏不存在".$data['game_id']); + } + $promote = M('promote', 'tab_')->where([ + 'id' => $data['promote_id'] + ])->find(); + if (!$promote) { + throw new \Exception("推广不存在"); + } + // 上级推广员 + $promoteRule = M('promote_limit_rules', 'tab_')->where([ + 'promote_id' => $data['promote_id'] + ])->find(); + if ($promoteRule && !$promoteRule['base_game_id']) { + throw new \Exception("推广员违规,请更换推广员"); + } + if ($promoteRule && $promoteRule['base_game_id'] == $baseGame['id']) { + throw new \Exception("推广员违规,请更换推广员"); + } + // 推广员链 +$promote['chain'] = '/1032/10099/10118/'; + $promoteChain = explode('/', $promote['chain']); +// $promoteStr = implode(',', $promoteChain); + + $promoteRules = M('promote_limit_rules', 'tab_')->where([ + 'in' => ['promote_id', $promoteChain] + ])->select(); + foreach ($promoteRules as $promoteRule) { + if ($promoteRule['base_game_id'] == 0 && $promoteRule['with_sub'] == 1) { + throw new \Exception("推广员违规,请更换推广员"); + } + if ($promoteRule['base_game_id'] == $baseGame['id'] && $promoteRule['with_sub'] == 1) { + throw new \Exception("推广员违规,请更换推广员"); + } + } + return true; } //注册信息