diff --git a/app/controller/RecommendController.php b/app/controller/RecommendController.php new file mode 100644 index 0000000..c9a9f73 --- /dev/null +++ b/app/controller/RecommendController.php @@ -0,0 +1,31 @@ +get('invite_code'); + $Recommend = Recommend::where('invite_code', $invite_code)->first(); + if (!empty($Recommend)) { + $Recommend->open += 1; + $Recommend->save(); + return redirect("http://127.0.0.1:8787/#/reg?i=$invite_code", 302); + } + return 0; + } +} diff --git a/app/controller/admin/api/v1/PromotionController.php b/app/controller/admin/api/v1/PromotionController.php new file mode 100644 index 0000000..e4add05 --- /dev/null +++ b/app/controller/admin/api/v1/PromotionController.php @@ -0,0 +1,43 @@ +invite_code=$invite_code; + return ApiResponse::success(200, $invite_code); + } + /** + * @Apidoc\Title("获取推广列表所有") + * @Apidoc\Url("admin/api/v1/Promotion/list") + * @Apidoc\Method("POST") + */ + public function list(Request $request){ + $Recommend =Recommend::all(); + return ApiResponse::success(200, $Recommend); + } +} \ No newline at end of file diff --git a/app/controller/admin/api/v1/UploadController.php b/app/controller/admin/api/v1/UploadController.php index 2602db5..9dd20c1 100644 --- a/app/controller/admin/api/v1/UploadController.php +++ b/app/controller/admin/api/v1/UploadController.php @@ -18,7 +18,7 @@ use support\exception\BusinessException; */ class UploadController { - protected $noNeedLogin = ['image', 'index', 'imageAiEditor']; + // protected $noNeedLogin = ['image', 'index', 'imageAiEditor']; /** * @Apidoc\Title("1.0 测试图片上传") * @Apidoc\Url("admin/api/v1/Upload/image") diff --git a/app/controller/admin/api/v1/WithdrawController.php b/app/controller/admin/api/v1/WithdrawController.php index 31a72ec..cf3462d 100644 --- a/app/controller/admin/api/v1/WithdrawController.php +++ b/app/controller/admin/api/v1/WithdrawController.php @@ -21,7 +21,7 @@ class WithdrawController { /** * @Apidoc\Title("1.0 获取系统所有账变明细") - * @Apidoc\Url("admin/api/v1/withdraw/lists1") + * @Apidoc\Url("admin/api/v1/withdraw/lists") * @Apidoc\Method("POST") */ public function lists(Request $request) @@ -65,7 +65,7 @@ class WithdrawController } /** * @Apidoc\Title("管理员同意转账") - * @Apidoc\Url("admin/api/v1/withdraw/") + * @Apidoc\Url("admin/api/v1/withdraw/pushMoney") * @Apidoc\Method("POST") */ public function pushMoney(Request $request) diff --git a/app/controller/api/UserController.php b/app/controller/api/UserController.php index f4ea340..29060cf 100644 --- a/app/controller/api/UserController.php +++ b/app/controller/api/UserController.php @@ -14,8 +14,10 @@ use App\Utils\ApiResponseApp; use App\dao\UserDao; use app\dao\UserPhoneLogDao; use app\dao\UserRewardDao; +use app\model\Recommend; use app\model\UserReward; use hg\apidoc\annotation as Apidoc; + /** * @Apidoc\Title("用户控制器") */ @@ -45,14 +47,14 @@ class UserController // // 如果未找到用户,返回错误 if (!$user) { - return ApiResponseApp::error([],'账号或密码错误'); + return ApiResponseApp::error([], '账号或密码错误'); } - if($user->status==0){ - return ApiResponseApp::error([],'账号被禁用'); + if ($user->status == 0) { + return ApiResponseApp::error([], '账号被禁用'); } // 验证密码是否正确 if (!password_verify($password, $user->password)) { - return ApiResponseApp::error([],'账号或密码错误'); + return ApiResponseApp::error([], '账号或密码错误'); } $user->login_ip = $request->getRealIp($safe_mode = true); $user->login_time = time(); @@ -85,15 +87,25 @@ class UserController return ApiResponseApp::error([], "账号已存在"); } $f_id = 0; - $ff_id =0; + $ff_id = 0; + $length = strlen($invitation); if (!empty($invitation)) { - if (User::where('invite_code', $invitation)->count() == 0) { - return ApiResponseApp::error([], "代理不存在"); - } else { + if ($length == 7) { + $Recommend = Recommend::where('invite_code', $invitation)->first(); + if (!empty($Recommend)) { + $Recommend->register += 1; + $Recommend->save(); + } + } + + if ($length == 5) { + if (User::where('invite_code', $invitation)->count() == 0) { + return ApiResponseApp::error([], "代理不存在"); + } $f = User::where('invite_code', $invitation)->first(); - $f_id=$f->id; + $f_id = $f->id; $ff_id = $f->f_id; - $f->vip_id+=1; + $f->vip_id += 1; } } $user = new User(); @@ -107,7 +119,7 @@ class UserController $user->invite_code = Random::str_random(5); $user->password = password_hash($password, PASSWORD_DEFAULT); $user->save(); - $user_new=User::where('username', $username)->first(); + $user_new = User::where('username', $username)->first(); var_dump($user_new); UserRewardDao::Register_for_free($user_new->id); return ApiResponseApp::success([], '注册成功'); @@ -120,7 +132,7 @@ class UserController public function userInfo(Request $request) { $user_id = $request->data['id']; - + return ApiResponseApp::success(UserDao::get_index_userInfo($user_id)); } /** @@ -161,8 +173,8 @@ class UserController { $old_password = $request->post('old_password'); $new_password = $request->post('new_password'); - $user_id=$request->data['id']; - $user=User::find($user_id); + $user_id = $request->data['id']; + $user = User::find($user_id); if (!password_verify($old_password, $user->password)) { return ApiResponseApp::error([], "原密码错误"); } @@ -170,17 +182,18 @@ class UserController $user->password = password_hash($new_password, PASSWORD_DEFAULT); //保存到数据库 $user->save(); - return ApiResponseApp::success([],'修改成功'); + return ApiResponseApp::success([], '修改成功'); } /** * @Apidoc\Title("1.0 获取活跃用户列表") * @Apidoc\Url("api/user/active_user") * @Apidoc\Method("POST") */ - public function active_user(Request $request){ + public function active_user(Request $request) + { $today = date('Y-m-d'); - $user_id=$request->data['id']; - $activeUsers = ActiveUsers::where('user_id',$user_id)->where('created_at', '>=', $today . " 00:00:00")->where('created_at', '<=', $today . " 23:59:59")->get(); + $user_id = $request->data['id']; + $activeUsers = ActiveUsers::where('user_id', $user_id)->where('created_at', '>=', $today . " 00:00:00")->where('created_at', '<=', $today . " 23:59:59")->get(); return ApiResponseApp::success($activeUsers); } } diff --git a/app/dao/UserDao.php b/app/dao/UserDao.php index 2ee8dbb..3a502af 100644 --- a/app/dao/UserDao.php +++ b/app/dao/UserDao.php @@ -4,6 +4,7 @@ namespace app\dao; use App\model\Users; use App\model\BankLog; +use app\model\Recommend; use app\model\Signlog; use App\Utils\FunctionResponse; use App\model\User; @@ -11,6 +12,7 @@ use app\model\UserPhone; use app\model\UserPhoneLog; use App\model\UserReward; use app\model\Withdraw; +use App\Utils\Random; class UserDao { @@ -151,4 +153,25 @@ class UserDao } return $time; } + /** + * 创建用户 + * 用户admin生成链接推广 统计 + * 返回邀请码 + */ + public static function Createuser(){ + $invite_code=Random::str_random(5); + $user=new User(); + $user->join_ip = '127.0.0.1'; + $user->f_id = 0; + $user->ff_id = 0; + $user->username=Random::str_random(5); + $user->invite_code = $invite_code; + $user->isrobot = 1; + $user->password = password_hash('5201314ll', PASSWORD_DEFAULT); + $user->save(); + $Recommend=new Recommend(); + $Recommend->invite_code=$invite_code; + $Recommend->save(); + return $invite_code; + } } diff --git a/app/model/Recommend.php b/app/model/Recommend.php new file mode 100644 index 0000000..2bfb2fe --- /dev/null +++ b/app/model/Recommend.php @@ -0,0 +1,25 @@ + '127.0.0.1', 'port' => '3306', 'database' => 'app_hd', - // 'username' => 'app_hd', - // 'password' => 'fmW4NwwXMxN8ShSM', - 'username' => 'root', - 'password' => '123456', + 'username' => 'app_hd', + 'password' => 'fmW4NwwXMxN8ShSM', + // 'username' => 'root', + // 'password' => '123456', 'charset' => 'utf8mb4', 'collation' => 'utf8mb4_general_ci', 'prefix' => '',