소스 검색

送礼物简单调整

lizhen_gitee 1 년 전
부모
커밋
173bc7fe4b
1개의 변경된 파일15개의 추가작업 그리고 6개의 파일을 삭제
  1. 15 6
      application/api/controller/Party.php

+ 15 - 6
application/api/controller/Party.php

@@ -1905,6 +1905,7 @@ class Party extends Api
             // 获取背包礼物信息
             $giftbackInfo = Db::name('gift_back')->field('gift_id')->where('id',$gift_id)->find();
             if(!$giftbackInfo){
+                Db::rollback();
                 $this->error("背包礼物获取失败");
             }
             $backGiftId = $giftbackInfo['gift_id'];
@@ -1931,6 +1932,7 @@ class Party extends Api
 
             $giftInfo = Db::name('gift')->field('id,value,name,image,special as gif_image,is_baobi')->where('id',$gift_id)->find();
             if (!$giftInfo) {
+                Db::rollback();
                 $this->error("请选择礼物!");
             }
 
@@ -1940,6 +1942,7 @@ class Party extends Api
             $giftCountValue = $giftValue * $userCount;
             $user_jewel = model('wallet')->getWallet($this->auth->id,'jewel');
             if($user_jewel < $giftCountValue){
+                Db::rollback();
                 $this->error("您的金币余额不足!");
             }
 
@@ -1950,6 +1953,10 @@ class Party extends Api
         $partyInfo = null;
 
         $partyInfo = \app\common\model\Party::field("id,room_type,party_name,party_hot,user_id,platRate,guilderRate,easemob_room_id")->where(["id"=>$party_id])->find();
+        if(empty($partyInfo)){
+            Db::rollback();
+            $this->error("不存在的派对!");
+        }
         // 获取系统配置信息
         $platRate    = $partyInfo->platRate; // 平台抽成百分比
         $guilderRate = $partyInfo->guilderRate; // 房主抽成百分比,包括公会房主,普通房房主
@@ -2027,7 +2034,8 @@ class Party extends Api
                 $data['guildermoney'] = bcdiv($data['guildervalue'],$money_to_jewel,2);
                 $data['getvalue']     = bcsub(bcsub($data["value"] ,$data['platvalue'],2),$data['guildervalue'],2);//减去抽成剩余价值
 
-                $data['task_status'] = 0;
+                $data['task_status'] = 0; //环信任务
+                $data['new_task_status'] = 0; //加钱任务
                 $data["createtime"] = time();
                 $res5 = Db::name('gift_user_party')->insertGetId($data);
                 if(!$res5){
@@ -2051,8 +2059,8 @@ class Party extends Api
                 }
 
                 // 增加房主抽成
-                if ($partyInfo && $data['guildervalue'] > 0) {
-                    $guilderMoney = bcdiv($data['guildervalue'],$money_to_jewel,2);
+                if ($partyInfo) {
+                    $guilderMoney = $data['guildermoney'];
                     if($guilderMoney > 0){
                         $touserInfo    = Db::name('user')->field('nickname')->where('id',$user_id)->find();
                         $rs_wallet = model('wallet')->lockChangeAccountRemain($partyInfo->user_id,$guilderMoney,'+',0,"{$this->auth->nickname}送礼物{$giftInfo['name']}x{$number}给{$touserInfo['nickname']},房间礼物抽成",102,'money');
@@ -2137,7 +2145,8 @@ class Party extends Api
                 Db::commit();
                 $this->success("赠送成功!",$returnData);
             } else {
-                $this->success("赠送失败!");
+                Db::rollback();
+                $this->error("赠送失败!");
             }
         } catch (ValidateException $e) {
             Db::rollback();
@@ -2160,13 +2169,13 @@ class Party extends Api
             return true;
         }
 
-        //用户今天的爆币情况,与消费情况,不用区分具体哪个爆币礼物
+        //用户今天的爆币情况,与消费情况
         $today_start = strtotime(date('Y-m-d')) - (86400 * 3);
         $today_end   = time();
         $map = [
             //'user_id' => $user_id,
-            'gift_id' => $gift_id,
             'createtime' => ['BETWEEN',[$today_start,$today_end]],
+            'gift_id' => $gift_id,
         ];
         $today_data = Db::name('gift_baobi_log')->field('IFNULL(sum(pay_total),0) as today_pay_total,IFNULL(sum(baobi_total),0) as today_baobi_total')->where($map)->find();
         //select IFNULL(sum(pay_total),0) as today_pay_total,IFNULL(sum(baobi_total),0) as today_baobi_total from hx_gift_baobi_log where user_id = 1001 and createtime BETWEEN 1703088000 and 1703174399