Browse Source

抽奖修改

lizhen_gitee 1 year ago
parent
commit
d3346a1042
1 changed files with 18 additions and 10 deletions
  1. 18 10
      application/api/controller/Eggnew.php

+ 18 - 10
application/api/controller/Eggnew.php

@@ -84,6 +84,10 @@ class Eggnew extends Api
                 $jackpot_id = $jackpot["id"];
             } else { // 没有开放的奖池
                 $jackpotInfo = \app\common\model\EggJackpot::where('type',$type)->order('weigh asc,id asc')->find();
+                if(!empty($jackpotInfo)){
+                    Db::rollback();
+                    $this->error('暂时还没有奖池');
+                }
                 $jackpot_id = $jackpotInfo["id"];
                 \app\common\model\EggJackpot::update(["status"=>1],["id"=>$jackpot_id]);//打开
             }
@@ -134,13 +138,17 @@ class Eggnew extends Api
                     $giftdata = $giftArr1;
                 } else {
                     if($newnum > count($nextjackpotGift)){
+                        Db::rollback();
                         $this->error("奖池礼物待更新,请耐心等待!");
                     }
 
                     $giftArr = [];
                     foreach($nextjackpotGift as $k => $v) $giftArr[$v["id"]] = $v;
 
-                    if(!$giftArr) $this->error("奖池礼物待更新,请耐心等待!");
+                    if(!$giftArr){
+                        Db::rollback();
+                        $this->error("奖池礼物待更新,请耐心等待!");
+                    }
 
                     $giftids = array_rand($giftArr,$newnum);
 
@@ -195,7 +203,10 @@ class Eggnew extends Api
                 $giftdata = $res1Info;
             }
 
-            if(!$giftdata) $this->error("系统错误!");
+            if(!$giftdata) {
+                Db::rollback();
+                $this->error('礼物为空');
+            }
 
             $data = [];
             foreach($giftdata as $k => $v) {
@@ -235,9 +246,9 @@ class Eggnew extends Api
             $backdata && $res7 = \app\common\model\GiftBack::insertAll($backdata);
 
 
-            if($res1 !== false && $res2 && $res3 && $res4 && $res5 && $res6 && $res7) {
+            if($res1 !== false && $res2 !== false && $res3 !== false && $res4 !== false && $res5 !== false && $res6 && $res7) {
                 Db::commit();
-                $eggStrikeNotice = config("site.eggStrikeNotice");
+                /*$eggStrikeNotice = config("site.eggStrikeNotice");
                 if($party_id){
                     $partyInfo = \app\common\model\Party::field("id,room_type,party_name")->where(["id"=>$party_id])->find();
                     foreach ($backdata as $backdatum) {
@@ -247,13 +258,10 @@ class Eggnew extends Api
                             QueueApi::sendGroupMessage(73, '', $this->auth->nickname, $partyInfo, $giftUserParty);
                         }
                     }
-                }
+                }*/
             } else {
-                // 返还锤子
-                for($i=1;$i<=$num;$i++) {
-                    $val = date("YmdHis").$i;
-                    $redis->lpush("hammer_num_".$user_id,$val);
-                }
+                Db::rollback();
+                $this->error('开奖失败');
             }
 
         }catch (ValidateException $e) {