Browse Source

转盘抽奖接口

cyzhao 8 months ago
parent
commit
470f1cf8aa

+ 5 - 0
Gameserver/App/base/CmdCode.php

@@ -149,6 +149,11 @@ class CmdCode {
      */
     const cmd_active_lottery_Tree_cashExchange = 6104;
     
+    /**
+     * 抽奖宝箱奖励领取
+     */
+    const cmd_active_lotteryNumBox_RewardReceived = 6105;
+    
 // </editor-fold>
 // <editor-fold defaultstate="collapsed" desc="任务操作码 - 62xx">
 

+ 5 - 0
Gameserver/App/base/ErrCode.php

@@ -572,6 +572,11 @@ class ErrCode {
      * 寻宝券数量充足不需要兑换
      */
     const active_lottery_unwantedExchange = 3512;
+    
+    /**
+     * 抽奖次数不足
+     */
+    const active_lotteryNumNotEnough = 3513;
 // </editor-fold>
 //
 //   // <editor-fold defaultstate="collapsed" desc="    task 3600    ">

+ 6 - 0
Gameserver/App/model/User/Info_PrivateState.php

@@ -313,6 +313,12 @@ class Info_PrivateState extends Object_ext {
      * @var type
      */
     public $lottery_qualGem_4 = 0;
+    
+    /**
+     * 抽奖累计次数宝箱奖励领取记录
+     */
+    #[ArrayType]
+    public $lotteryNumRewardReceived = array();
 
     public function initialize() {
         $this->junbeiShopNumRecord = new \stdClass();

+ 28 - 3
Gameserver/App/process/ActiveProc.php

@@ -29,12 +29,34 @@ class ActiveProc {
             case CmdCode::cmd_active_lottery_Tree:                              # 6103 转盘抽奖
                 return ActiveProc::lottery_Tree();
             case CmdCode::cmd_active_lottery_Tree_cashExchange:                 # 6104 元宝兑换抽奖券
-                return ActiveProc::lottery_Tree_cashExchange();    
+                return ActiveProc::lottery_Tree_cashExchange();
+            case CmdCode::cmd_active_lotteryNumBox_RewardReceived:              # 6105 抽奖宝箱奖励领取
+                return ActiveProc::lotteryNumBox_RewardReceived();
             default:
                 Err(ErrCode::cmd_err);
         }
     }
     
+    /**
+     * 6105 抽奖宝箱奖励领取
+     * @return type
+     */
+    public static function lotteryNumBox_RewardReceived() {
+        list($id) = req()->paras;
+        
+        my_Assert(ctx()->privateState->lotteryNum >= $id,ErrCode::active_lotteryNumNotEnough);
+        my_Assert(!StlUtil::dictHasProperty(ctx()->privateState->lotteryNumRewardReceived, $id),ErrCode::active_hasgetted);
+        
+        ctx()->privateState->lotteryNumRewardReceived[] = $id;
+        
+        UserProc::updateUserInfo();
+        return Resp::ok(array(
+                    "store" => ctx()->store,                           
+                    'cash' => ctx()->baseInfo->cash,
+                    'reward'=> StoreProc::$reward,
+        ));
+    }
+    
     /**
      *  6103 转盘抽奖
      */
@@ -57,9 +79,12 @@ class ActiveProc {
         $costId = $costArr[0];
         $costNum = $costArr[1];
         my_Assert(StlUtil::dictHasProperty($item, $costId) && $item->$costId >= $costNum,ErrCode::notenough_item);        
-        ctx()->store->removeItem($costId, $costNum);       
-        ctx()->privateState->lotteryNum += $num;        
+        ctx()->store->removeItem($costId, $costNum);    
         
+        if(ctx()->privateState->lotteryNum < glc()->activity_lottery_allNum){
+            ctx()->privateState->lotteryNum += $num;        
+        }
+                
         $rewardList = array();
         $dic = GameConfig::activity_lottery_tree();
         for ($i = 0; $i < $num; $i++) {