Ver Fonte

转盘抽奖接口

cyzhao há 8 meses atrás
pai
commit
30d2647852
2 ficheiros alterados com 35 adições e 8 exclusões
  1. 5 0
      Gameserver/App/base/ErrCode.php
  2. 30 8
      Gameserver/App/process/ActiveProc.php

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

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

+ 30 - 8
Gameserver/App/process/ActiveProc.php

@@ -95,19 +95,41 @@ class ActiveProc {
         ));
     }
 
+    /**
+     * 元宝兑换寻宝券
+     * @return type
+     */
     public static function lottery_Tree_cashExchange() {
         list($num) = req()->paras;//抽奖次数 1  10
         
+        $cost ="";
+        if($num == 1){
+            $cost = glc()->activity_lottery_tree_one_cost;
+        } else {
+            $cost = glc()->activity_lottery_tree_ten_cost;
+        }
+        my_Assert($cost != "",ErrCode::active_lotteryCostErr);
+        $costArr = explode(',', $cost);     
+        $item = ctx()->store->items;        
+        $costId = $costArr[0];
+        $costNum = $costArr[1];
+        
+        $selfNum = 0;
+        if(StlUtil::dictHasProperty($item, $costId)){
+            $selfNum = $item->$costId;
+        }
+        my_Assert($selfNum >= $costNum,ErrCode::active_lottery_unwantedExchange);
+        
+        $costNum -= $selfNum;
+        $cash = glc()->activity_lottery_oneCost_cash * $costNum;
+        my_Assert(ctx()->baseInfo->cash >= $cash,ErrCode::notenough_cash_msg);
+        ctx()->baseInfo->Consume_Cash($cash);
+        StoreProc::AddMultiItemInStore($costId.','.$costNum);
+        
         UserProc::updateUserInfo();
         return Resp::ok(array(
-                    "store" => ctx()->store,
-                    'reward' => StoreProc::$reward,
-                    'reward_Gem' => StoreProc::$reward_Gem,
-                    'gold' => ctx()->baseInfo->gold,
-                    'cash' => ctx()->baseInfo->cash,
-                    'lotteryNum'=> ctx()->privateState->lotteryNum,
-                    'indexReward'=> $rewardList,
-            
+                    "store" => ctx()->store,                           
+                    'cash' => ctx()->baseInfo->cash,                          
         ));
     }