Browse Source

送礼物优化

lizhen_gitee 1 year ago
parent
commit
98263b3f07

+ 3 - 3
application/api/controller/Party.php

@@ -1865,7 +1865,7 @@ class Party extends Common
                         $this->updateUserCharm($party_id, $user_id, $hotValue);
 
                         // 如果是主播,则添加魅力值记录做榜单统计
-                        if($room_type == 2) {
+                        /*if($room_type == 2) {
                             $data = [];
                             $data["user_id"] = $user_id;
                             $data["party_id"] = $party_id;
@@ -1873,7 +1873,7 @@ class Party extends Common
                             $data["createtime"] = time();
                             \app\common\model\UserCharmRank::insert($data);
 
-                        }
+                        }*/
 
                     }
 
@@ -1899,7 +1899,7 @@ class Party extends Common
                     \app\common\model\TaskLog::tofinish($this->auth->id,"OBHqCX4g",$number);
                     */
                     // +message
-                    \app\common\model\Message::addMessage($user_id,"礼物通知","收到 ".$this->auth->nickname." 赠送的".$giftInfo["name"]." x".$number." 价值 ".$giftValue ." 钻石");
+                    //\app\common\model\Message::addMessage($user_id,"礼物通知","收到 ".$this->auth->nickname." 赠送的".$giftInfo["name"]." x".$number." 价值 ".$giftValue ." 钻石");
 
                     $allVal = $allVal + $hotValue;
 

+ 2 - 2
application/common/controller/Api.php

@@ -194,12 +194,12 @@ class Api
                 $this->error(__('Please login first'), null, 401);
             }
             // 判断是否需要验证权限
-            if (!$this->auth->match($this->noNeedRight)) {
+            /*if (!$this->auth->match($this->noNeedRight)) {
                 // 判断控制器和方法判断是否有对应权限
                 if (!$this->auth->check($path)) {
                     $this->error(__('You have no permission'), null, 403);
                 }
-            }
+            }*/
         } else {
             // 如果有传递token才验证是否登录状态
             if ($token) {

+ 17 - 2
application/index/controller/Plantask.php

@@ -154,6 +154,7 @@ class Plantask extends Controller
                 //用户信息
                 $authuser_info = Db::name('user')->field('nickname')->where('id',$giftuserparty['user_id'])->find();
                 $touserInfo    = Db::name('user')->field('nickname')->where('id',$giftuserparty['user_to_id'])->find();
+                $party_id = $giftuserparty['party_id'];
 
 
                 //添加获赠用户余额
@@ -181,7 +182,16 @@ class Plantask extends Controller
                     }
                 }
 
+                // 如果是主播,则添加魅力值记录做榜单统计
+                if($partyInfo['room_type'] == 2) {
+                    $data = [];
+                    $data["user_id"] = $giftuserparty['user_to_id'];
+                    $data["party_id"] = $party_id;
+                    $data["charm"] = $hotValue;
+                    $data["createtime"] = time();
+                    \app\common\model\UserCharmRank::insert($data);
 
+                }
 
                 //用户经验升级
                 $getempirical = $getempirical_conf * $hotValue;
@@ -204,12 +214,17 @@ class Plantask extends Controller
                 \app\common\model\TaskLog::tofinish($giftuserparty['user_id'],"OBHqCX4g",$giftuserparty['number']);
 
                 // +message
-                //\app\common\model\Message::addMessage($user_id,"礼物通知","收到 ".$this->auth->nickname." 赠送的".$giftInfo["name"]." x".$number." 价值 ".$giftValue ." 钻石");
+                \app\common\model\Message::addMessage($giftuserparty['user_to_id'],"礼物通知","收到 ".$authuser_info['nickname']." 赠送的".$giftuserparty['gift_name']." x".$giftuserparty['number']." 价值 ".$giftValue ." 钻石");
 
                 //增加送礼用户的财富等级
                 $res_wealth = \app\common\model\User::add_wealth_level($giftuserparty['user_id'],$giftValue);
 
-                Db::name('gift_user_party')->where('id',$giftuserparty['id'])->update(['task_status'=>1]);
+                $rs_up = Db::name('gift_user_party')->where('id',$giftuserparty['id'])->update(['task_status'=>1]);
+                if($rs_up === false){
+                    Db::rollback();
+                    echo '更新错误'.$giftuserparty['id'];
+                    exit;
+                }
             }
             Db::commit();
         } catch (ValidateException $e) {