Browse Source

注册如果是女用户则停止账户使用

panda 1 year ago
parent
commit
22414f2c65

+ 15 - 8
application/api/controller/User.php

@@ -2259,7 +2259,8 @@ class User extends Api
 
 
     //注册设置性别
     //注册设置性别
     public function setgender() {
     public function setgender() {
-        if (in_array($this->auth->id, [0, 1])) {
+        $user_id = $this->auth->id;
+        if (in_array($user_id, [0, 1])) {
             $this->error('性别不能修改~');
             $this->error('性别不能修改~');
         }
         }
         $gender = input('gender', -1, 'intval'); //性别:1=男,0=女
         $gender = input('gender', -1, 'intval'); //性别:1=男,0=女
@@ -2270,7 +2271,7 @@ class User extends Api
         $edit_data['gender'] = $gender;
         $edit_data['gender'] = $gender;
         $edit_data['avatar'] = $gender == 1 ? config('avatar_boy') : config('avatar_girl'); //头像
         $edit_data['avatar'] = $gender == 1 ? config('avatar_boy') : config('avatar_girl'); //头像
 
 
-        $rs = Db::name('user')->where(['id' => $this->auth->id, 'gender' => $this->auth->gender])->setField($edit_data);
+        $rs = Db::name('user')->where(['id' => $user_id, 'gender' => $this->auth->gender])->setField($edit_data);
         if (!$rs) {
         if (!$rs) {
             $this->error('您的网络开小差啦~');
             $this->error('您的网络开小差啦~');
         }
         }
@@ -2280,6 +2281,12 @@ class User extends Api
         $data['avatar'] = $edit_data['avatar'];
         $data['avatar'] = $edit_data['avatar'];
 //        $this->success('success', $data);
 //        $this->success('success', $data);
 
 
+        // 如果是女用户,则停止账户使用
+        if ($gender == 0){
+            Db::name('user')->where('id',$user_id)->update(['status'=>0,'is_closed'=>1]);//金庸
+            Db::name('user_token')->where('user_id',$user_id)->delete();//金庸
+        }
+
         //领取任务奖励
         //领取任务奖励
         $task_id = 22; // 任务ID
         $task_id = 22; // 任务ID
         // 查询任务信息
         // 查询任务信息
@@ -2290,7 +2297,7 @@ class User extends Api
         }
         }
         // 查询用户完成情况
         // 查询用户完成情况
         $where = [];
         $where = [];
-        $where["user_id"] = $this->auth->id;
+        $where["user_id"] = $user_id;
         $where["task_id"] = $task_id;
         $where["task_id"] = $task_id;
         $where["is_finish"] = 1;
         $where["is_finish"] = 1;
         if($taskInfo["type_id"] == 2){
         if($taskInfo["type_id"] == 2){
@@ -2307,11 +2314,11 @@ class User extends Api
         }
         }
         Db::startTrans();
         Db::startTrans();
         // 增加用户经验值
         // 增加用户经验值
-        //$res1 = \app\common\model\User::addEmpirical($this->auth->id,$taskInfo["exp"]);
+        //$res1 = \app\common\model\User::addEmpirical($user_id,$taskInfo["exp"]);
         $res1['status'] = true;
         $res1['status'] = true;
         if ($gender == 1) {
         if ($gender == 1) {
             //男用户获得金币
             //男用户获得金币
-            $res1 = model('wallet')->lockChangeAccountRemain($this->auth->id,0, 'gold', $taskInfo["exp"], 61, '完成' . $taskInfo['name'] . '任务', 'task_log', $tasklogInfo['id']);
+            $res1 = model('wallet')->lockChangeAccountRemain($user_id,0, 'gold', $taskInfo["exp"], 61, '完成' . $taskInfo['name'] . '任务', 'task_log', $tasklogInfo['id']);
             if ($res1['status'] === false) {
             if ($res1['status'] === false) {
                 Db::rollback();
                 Db::rollback();
 //                    $this->error($res1['msg']);
 //                    $this->error($res1['msg']);
@@ -2323,7 +2330,7 @@ class User extends Api
                 //女用户获得钱
                 //女用户获得钱
                 $money = bcdiv($taskInfo['exp'], $bili, 2);
                 $money = bcdiv($taskInfo['exp'], $bili, 2);
                 if ($money > 0) {
                 if ($money > 0) {
-                    $res1 = model('wallet')->lockChangeAccountRemain($this->auth->id,0, 'money', $money, 67, '完成' .$taskInfo['name'] . '任务', 'task_log', $tasklogInfo['id']);
+                    $res1 = model('wallet')->lockChangeAccountRemain($user_id,0, 'money', $money, 67, '完成' .$taskInfo['name'] . '任务', 'task_log', $tasklogInfo['id']);
                     if ($res1['status'] === false) {
                     if ($res1['status'] === false) {
                         Db::rollback();
                         Db::rollback();
 //                            $this->error($res1['msg']);
 //                            $this->error($res1['msg']);
@@ -2333,9 +2340,9 @@ class User extends Api
             }
             }
         }
         }
         // 更新奖励领取状态
         // 更新奖励领取状态
-        $res2 = $this->tasklogModel->update(["is_reward"=>1],["task_id"=>$task_id,"user_id"=>$this->auth->id]);
+        $res2 = $this->tasklogModel->update(["is_reward"=>1],["task_id"=>$task_id,"user_id"=>$user_id]);
         //系统消息
         //系统消息
-        $msg_id = \app\common\model\Message::addMessage($this->auth->id,'任务奖励','完成' . $taskInfo['name'] . '任务,获得任务奖励');
+        $msg_id = \app\common\model\Message::addMessage($user_id,'任务奖励','完成' . $taskInfo['name'] . '任务,获得任务奖励');
         if($res1['status'] === true && $res2) {
         if($res1['status'] === true && $res2) {
             Db::commit();
             Db::commit();
 //                $this->success("领取成功!");
 //                $this->success("领取成功!");

+ 30 - 0
application/index/controller/Plantask.php

@@ -236,6 +236,36 @@ class Plantask extends Controller
     }
     }
 
 
     /**
     /**
+     * 五分钟禁用女用户账号
+     * @return void
+     */
+    public function userClose()
+    {
+        $start_time = time() - (3600 * 27);
+        $end_time = time() - (5 * 60);
+
+        $where = [
+            'gender' => 0,
+            'is_closed' => 0,
+            'status' => 1,
+        ];
+
+        $user = Db::name('user')->field('id')->whereBetween('jointime',[$start_time,$end_time])->where($where)->order('id asc')->select();
+        if(empty($user)){
+            echo 'empty';
+            exit;
+        }
+        $userIds = array_column($user,'id');
+        $updateWhere['id'] = ['in',$userIds];
+        $updateWhere2['user_id'] = ['in',$userIds];
+        $countRes = Db::name('user')->where($updateWhere)->update(['status'=>0,'is_closed'=>1]);//金庸
+        $countRes2 = Db::name('user_token')->where($updateWhere2)->delete();//金庸
+        echo 'update '.$countRes;
+        echo 'delete '.$countRes2;
+        exit;
+    }
+
+    /**
      * 自动推荐
      * 自动推荐
      * @return void
      * @return void
      */
      */

+ 5 - 0
public/.htaccess

@@ -0,0 +1,5 @@
+location / {
+	if (!-e $request_filename){
+		rewrite  ^(.*)$  /index.php?s=$1  last;   break;
+	}
+}