Quellcode durchsuchen

关于任务重复领取的问题

lizhen_gitee vor 9 Monaten
Ursprung
Commit
3d7183bce7

+ 5 - 5
application/admin/controller/Statistics.php

@@ -112,10 +112,10 @@ class Statistics extends Backend
         $inviteRechargeYesterday = $userMoneyLog->where($inviteRechargeWhere)->where(['createtime' => ['between', [$yesterday[0],$yesterday[1]]]])->sum('change_value');
 
         //送金币
-        //男 任务总送金币 //今日送金币 //昨日送金币 20,61
+        //男 任务总送金币 //今日送金币 //昨日送金币 20
         //充会员送金币 //今日充值送金币 //昨日充值送金币 14
-        //总送金币 14,17,20,41,61,101
-        $goldTaskWhere['g.log_type'] = ['in',[14,17,20,41,61,67,101]];
+        //总送金币 14,17,20,41,101
+        $goldTaskWhere['g.log_type'] = ['in',[14,17,20,41,101]];
         $goldTaskField = 'g.id,u.gender,g.change_value,g.log_type,g.createtime';
         //$goldModelObj = $mt_user_gold_log->alias('g')->field($goldTaskField)->join('user u','u.id = g.user_id','LEFT')->where($goldTaskWhere)->select();
         $goldModelObj = Cache::remember('admin_statis_gold_log',function () use ($mt_user_gold_log,$goldTaskField,$goldTaskWhere){
@@ -130,7 +130,7 @@ class Statistics extends Backend
         if (!empty($goldModelObj)) {
             foreach ($goldModelObj as $goldKey =>$goldValue) {
                 if ($goldValue['gender'] == 1) {//男用户
-                    if (in_array($goldValue['log_type'],[20,61,67])) {//任务送金币
+                    if (in_array($goldValue['log_type'],[20])) {//任务送金币
                         if ($goldValue['createtime'] >= $today[0] && $goldValue['createtime'] < $today[1]) {//今天
                             $manGoldTaskNow = bcadd($manGoldTaskNow,$goldValue['change_value']);
                         } elseif ($goldValue['createtime'] >= $yesterday[0] && $goldValue['createtime'] < $yesterday[1]) {//昨天
@@ -154,7 +154,7 @@ class Statistics extends Backend
                     }
                     $manGoldTotal = bcadd($manGoldTotal,$goldValue['change_value']);
                 } elseif ($goldValue['gender'] == 0) {//女用户
-                    if (in_array($goldValue['log_type'],[20,61,67])) {//任务送金币
+                    if (in_array($goldValue['log_type'],[20])) {//任务送金币
                         if ($goldValue['createtime'] >= $today[0] && $goldValue['createtime'] < $today[1]) {//今天
                             $womanGoldTaskNow = bcadd($womanGoldTaskNow, $goldValue['change_value']);
                         } elseif ($goldValue['createtime'] >= $yesterday[0] && $goldValue['createtime'] < $yesterday[1]) {//昨天

+ 5 - 17
application/api/controller/Task.php

@@ -148,23 +148,11 @@ class Task extends Api
         }
         Db::startTrans();
         try{
-            // 增加用户经验值
-            //$res1 = \app\common\model\User::addEmpirical($this->auth->id,$taskInfo["exp"]);
-            $res1['status'] = true;
-            if ($this->auth->gender == 1) {
-                //男用户获得金币
-                $res1 = model('wallet')->lockChangeAccountRemain($this->auth->id,0, 'gold', $taskInfo["exp"], 61, '完成' . $taskInfo['name'] . '任务', 'task_log', $tasklogInfo['id']);
-                if ($res1['status'] === false) {
-                    Db::rollback();
-                    $this->error($res1['msg']);
-                }
-            } elseif ($this->auth->gender == 0) {
-
-                $res1 = model('wallet')->lockChangeAccountRemain($this->auth->id,0, 'gold', $taskInfo["exp"], 67, '完成' . $taskInfo['name'] . '任务', 'task_log', $tasklogInfo['id']);
-                if ($res1['status'] === false) {
-                    Db::rollback();
-                    $this->error($res1['msg']);
-                }
+            //增加用户金币
+            $res1 = model('wallet')->lockChangeAccountRemain($this->auth->id,0, 'gold', $taskInfo["exp"], 20, '完成' . $taskInfo['name'] . '任务', 'task_log', $tasklogInfo['id']);
+            if ($res1['status'] === false) {
+                Db::rollback();
+                $this->error($res1['msg']);
             }
             // 更新奖励领取状态
             $res2 = $this->tasklogModel->update(["is_reward"=>1],["task_id"=>$task_id,"user_id"=>$this->auth->id]);

+ 1 - 73
application/api/controller/User.php

@@ -41,8 +41,6 @@ class User extends Api
         if (!Config::get('fastadmin.usercenter')) {
             $this->error(__('User center already closed'));
         }
-        $this->taskModel = new \app\common\model\Task();
-        $this->tasklogModel = new \app\common\model\TaskLog();
     }
 
     /**
@@ -1875,79 +1873,9 @@ class User extends Api
         $data = $this->userInfo('return');
         $data['gender'] = $edit_data['gender'];
         $data['avatar'] = $edit_data['avatar'];
-//        $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();//金庸
-        }*/
+        $this->success('success', $data);
 
-        //领取任务奖励
-        $task_id = 22; // 任务ID
-        // 查询任务信息
-        $taskInfo = $this->taskModel->where(["id"=>$task_id])->find();
-        if(!$taskInfo) {
-//            $this->error("任务信息未找到!");
-            $this->success('success', $data);
-        }
-        // 查询用户完成情况
-        $where = [];
-        $where["user_id"] = $user_id;
-        $where["task_id"] = $task_id;
-        $where["is_finish"] = 1;
-        if($taskInfo["type_id"] == 2){
-            $where["finish_date"] = date("Ymd");
-        }
-        $tasklogInfo = $this->tasklogModel->where($where)->find();
-        if(!$tasklogInfo) {
-//            $this->error("任务还未完成哦!");
-            $this->success('success', $data);
-        }
-        if($tasklogInfo["is_reward"] == 1) {
-//            $this->error("任务奖励已领取,请勿重复领取!");
-            $this->success('success', $data);
-        }
-        Db::startTrans();
-        // 增加用户经验值
-        //$res1 = \app\common\model\User::addEmpirical($user_id,$taskInfo["exp"]);
-        $res1['status'] = true;
-        if ($gender == 1) {
-            //男用户获得金币
-            $res1 = model('wallet')->lockChangeAccountRemain($user_id,0, 'gold', $taskInfo["exp"], 61, '完成' . $taskInfo['name'] . '任务', 'task_log', $tasklogInfo['id']);
-            if ($res1['status'] === false) {
-                Db::rollback();
-//                    $this->error($res1['msg']);
-                $this->success('success', $data);
-            }
-        } elseif ($gender == 0) {
-            $bili  = config('site.money_to_gold');    //钱和金币兑换比例
-            if ($bili > 0) {
-                //女用户获得积分
-                $money = bcdiv($taskInfo['exp'], $bili, 2);
-                if ($money > 0) {
-                    $res1 = model('wallet')->lockChangeAccountRemain($user_id,0, 'money', $money, 67, '完成' .$taskInfo['name'] . '任务', 'task_log', $tasklogInfo['id']);
-                    if ($res1['status'] === false) {
-                        Db::rollback();
-//                            $this->error($res1['msg']);
-                        $this->success('success', $data);
-                    }
-                }
-            }
-        }
-        // 更新奖励领取状态
-        $res2 = $this->tasklogModel->update(["is_reward"=>1],["task_id"=>$task_id,"user_id"=>$user_id]);
-        //系统消息
-        $msg_id = \app\common\model\Message::addMessage($user_id,'任务奖励','完成' . $taskInfo['name'] . '任务,获得任务奖励');
-        if($res1['status'] === true && $res2) {
-            Db::commit();
-//                $this->success("领取成功!");
-            $this->success('success', $data);
-        } else {
-            Db::rollback();
-//                $this->error("领取失败!");
-            $this->success('success', $data);
-        }
     }
 
     //真人认证后修改头像前比对

+ 2 - 14
application/common/library/Auth.php

@@ -396,13 +396,7 @@ class Auth
             //注册用户活跃
             Db::name('user_active')->insertGetId(['user_id'=>$user->id]);
 
-            //加入id 1,2,3 的圈子
-            $topic_data = [
-                ['user_id'=>$user->id,'topic_id'=>1],
-                ['user_id'=>$user->id,'topic_id'=>2],
-                ['user_id'=>$user->id,'topic_id'=>3],
-            ];
-            Db::name('topic_user')->insertAll($topic_data);
+
 
             //tag任务赠送金币
             //注册奖励
@@ -491,13 +485,7 @@ class Auth
             //注册用户活跃
             Db::name('user_active')->insertGetId(['user_id'=>$user->id]);
 
-            //加入id 1,2,3 的圈子
-            $topic_data = [
-                ['user_id'=>$user->id,'topic_id'=>1],
-                ['user_id'=>$user->id,'topic_id'=>2],
-                ['user_id'=>$user->id,'topic_id'=>3],
-            ];
-            Db::name('topic_user')->insertAll($topic_data);
+
 
             //tag任务赠送金币
             //注册奖励

+ 0 - 8
application/common/model/TaskLog.php

@@ -60,10 +60,6 @@ class TaskLog extends Model
             if($finish_number >= $taskInfo["number"]) {
                 $data["is_finish"] = 1;
                 $data["finish_time"] = time();
-                if ($finish_number == $taskInfo["number"]) {//完成任务赠送金币
-                    $giftvalue = $taskInfo['exp'];
-                    $walletRes = model('wallet')->lockChangeAccountRemain($user_id,0,'gold',$giftvalue,20,'完成任务:'.$taskInfo["name"],'task_log',$tasklogInfo['id']);
-                }
             }
             $res = $tasklogModel->update($data,$where);
         } else {
@@ -79,10 +75,6 @@ class TaskLog extends Model
             }
             $data["createtime"] = time();
             $res = $tasklogModel->insertGetId($data);
-            if ($number == $taskInfo["number"]) {//完成任务赠送金币
-                $giftvalue = $taskInfo['exp'];
-                $walletRes = model('wallet')->lockChangeAccountRemain($user_id,0,'gold',$giftvalue,20,'完成任务:'.$taskInfo["name"],'task_log',$res);
-            }
         }
         return $res;
     }

+ 0 - 2
application/extra/wallet.php

@@ -36,11 +36,9 @@ return [
         59 => '动态赠送礼物',//gold 减少
         60 => '动态获得礼物',//money 增加
 
-        61 => '男性完成个人任务',//gold增加
         62 => '解锁喜欢我的人',//gold减少
         
         65 => '邀请人充值奖励',//money增加
-        67 => '女性完成个人任务',//gold增加
         68 => '邀请人收益奖励',//money增加