瀏覽代碼

Merge branch 'dev' of http://ylsjtt.game7000.com:3000/YLSJ/jzhj2024server into dev

王刚 11 月之前
父節點
當前提交
9e95ae2e11

+ 1 - 0
Gameserver/App/AutoLoad.php

@@ -21,6 +21,7 @@ class AutoLoad {
                 ROOTDIR . '/util/', #                                           # 常用辅助代码
                 ROOTDIR . '/process/', #                                        # 逻辑处理代码
                 ROOTDIR . '/model/User/', #                                     # 数据结构定义
+                ROOTDIR . '/process/ActiveProc/',
             );
             if (defined("CodeGen_Folder")) {
                 $incs[] = CodeGen_Folder;

+ 6 - 1
Gameserver/App/base/CmdCode.php

@@ -108,7 +108,12 @@ class CmdCode {
     /**
      * 7日奖励领取
      */
-    const active_day7_drawreward = 6101;
+    const cmd_active_day7_drawreward = 6101;
+    
+    /**
+     * 
+     */
+    const cmd_active_drawPackageByCode = 6102;
 
     // </editor-fold>
     // <editor-fold defaultstate="collapsed" desc="任务操作码 - 62xx">

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

@@ -483,7 +483,37 @@ class ErrCode {
      * 无效的时间内不能领取奖励
      */
     const active_day7_expired = 3502;
+    
+    /*
+     * 不存在活动配置信息
+     */
+    const active_const_no_err = 3503;
+    
+    /**
+     * 活动 - 激活码 无效
+     */
+    const active_activecode_format = 3504;
+    
+    /**
+     * 活动 - 激活码 渠道错误.
+     */
+    const active_activecode_plat = 3905;
+    
+    /**
+     * 激活码礼包已经过期
+     */
+    const active_activecode_outtime = 3906;
 
+    /**
+     * 活动 - 兑换码已经使用过了
+     */
+    const active_activecode_used = 3907;
+    
+    /**
+     * 活动 - 此活动尚未开放
+     */
+    const active_time = 3908;
+    
 // </editor-fold>
 //
 //   // <editor-fold defaultstate="collapsed" desc="    task 3600    ">

+ 33 - 1
Gameserver/App/configs/GameConfig.php

@@ -3,7 +3,7 @@
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
- // 日期: 2024-06-18 14:38:55
+ // 日期: 2024-06-20 17:10:35
 ////////////////////
 
 namespace loyalsoft;
@@ -719,6 +719,38 @@ class GameConfig {
         return self::get_hash_item('heroType_typeId', $key);
     }
     /**
+    * 激活码表
+    * @return \token_gift
+    */
+    public static function token_gift()
+    { 
+        static $a = null; 
+        return self::initValue($a, 'token_gift');
+    }
+    /**
+    * @return \sm_token_gift token_gift item数据 
+    */
+    public static function token_gift_getItem($itemid)
+    { 
+        return self::get_hash_item('token_gift', $itemid);
+    }
+    /**
+    * 公共兑换码
+    * @return \token_publicgift
+    */
+    public static function token_publicgift()
+    { 
+        static $a = null; 
+        return self::initValue($a, 'token_publicgift');
+    }
+    /**
+    * @return \sm_token_publicgift token_publicgift item数据 
+    */
+    public static function token_publicgift_getItem($itemid)
+    { 
+        return self::get_hash_item('token_publicgift', $itemid);
+    }
+    /**
     * 当前版本(时间戳)
     * @return \ver
     */

+ 1 - 1
Gameserver/App/configs/GameConstants.php

@@ -28,7 +28,7 @@ class GameConstants {
                 return "zgyqfmpav4whex9td7nu2kj8b5ris36c";
             case 'ios':                                                         # ios平台
                 return "m8hsn46efyuatvp972cdgz3qrxj5wibk";
-            case 'and_hw':                                                         # android平台 20171101110403
+            case 'dev':                                                         # android平台 20171101110403
                 return "qh6jid4g598rfnwp37xyb2vetzuskcam";
             default :                                                           # 默认采用原文密码本
                 return "abcdefghijkmnpqrstuvwxyz23456789";

+ 33 - 1
Gameserver/App/model/Const/GameConfig.php

@@ -3,7 +3,7 @@
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
- // 日期: 2024-06-19 14:08:35
+ // 日期: 2024-06-20 17:10:35
 ////////////////////
 
 /**
@@ -717,6 +717,38 @@ class GameConfig {
         return self::get_hash_item('heroType_typeId', $key);
     }
     /**
+    * 激活码表
+    * @return \token_gift
+    */
+    public static function token_gift()
+    { 
+        static $a = null; 
+        return self::initValue($a, 'token_gift');
+    }
+    /**
+    * @return \sm_token_gift token_gift item数据 
+    */
+    public static function token_gift_getItem($itemid)
+    { 
+        return self::get_hash_item('token_gift', $itemid);
+    }
+    /**
+    * 公共兑换码
+    * @return \token_publicgift
+    */
+    public static function token_publicgift()
+    { 
+        static $a = null; 
+        return self::initValue($a, 'token_publicgift');
+    }
+    /**
+    * @return \sm_token_publicgift token_publicgift item数据 
+    */
+    public static function token_publicgift_getItem($itemid)
+    { 
+        return self::get_hash_item('token_publicgift', $itemid);
+    }
+    /**
     * 当前版本(时间戳)
     * @return \ver
     */

+ 2 - 2
Gameserver/App/model/Const/sm_globalsettings.php

@@ -3,7 +3,7 @@
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
- // 日期: 2024-06-19 09:35:46
+ // 日期: 2024-06-20 14:54:52
 ////////////////////
 
 
@@ -114,7 +114,7 @@ class sm_globalsettings
     public $DailyShopShowNum;
 
     /**
-    * @var string   
+    * @var string 宝石品阶  
     */
     public $GemQualName;
 

+ 1 - 1
Gameserver/App/model/Const/sm_hero.php

@@ -3,7 +3,7 @@
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
- // 日期: 2024-06-18 14:50:18
+ // 日期: 2024-06-20 11:05:46
 ////////////////////
 
 

+ 1 - 1
Gameserver/App/model/Const/sm_heroType_typeId.php

@@ -3,7 +3,7 @@
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
- // 日期: 2024-06-18 14:50:18
+ // 日期: 2024-06-20 11:05:46
 ////////////////////
 
 

+ 1 - 1
Gameserver/App/model/Const/sm_item.php

@@ -3,7 +3,7 @@
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
- // 日期: 2024-06-18 14:41:36
+ // 日期: 2024-06-20 11:33:01
 ////////////////////
 
 

+ 1 - 1
Gameserver/App/model/Const/sm_predicate.php

@@ -3,7 +3,7 @@
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
- // 日期: 2024-06-19 11:35:46
+ // 日期: 2024-06-20 15:05:46
 ////////////////////
 
 

+ 3 - 3
Gameserver/App/model/Const/sm_token_PublicGift.php

@@ -3,14 +3,14 @@
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
- // 日期: 2024-03-20 15:21:24
+ // 日期: 2024-06-20 17:00:35
 ////////////////////
 
 
 /**
- * Static Model token_PublicGift 公共兑换码
+ * Static Model token_publicgift 公共兑换码
  */
-class sm_token_PublicGift
+class sm_token_publicgift
 {
 
     /**

+ 52 - 0
Gameserver/App/model/Const/sm_token_gift.php

@@ -0,0 +1,52 @@
+<?php
+////////////////////
+ // 由CodeGenerator创建。
+ // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
+ // author: gwang 
+ // 日期: 2024-06-07 18:24:37
+////////////////////
+
+
+/**
+ * Static Model token_gift 激活码表
+ */
+class sm_token_gift
+{
+
+    /**
+    * @var Int32 用途未知!!请到数据库中添加字段注释。  
+    */
+    public $id;
+
+    /**
+    * @var Int32 礼包id(最大255)  
+    */
+    public $typeId;
+
+    /**
+    * @var Int32 平台(0:all,1:腾讯,2:九游,...)  
+    */
+    public $plat;
+
+    /**
+    * @var Int32 开始生效时间戳  
+    */
+    public $startTs;
+
+    /**
+    * @var Int32 失效时间戳  
+    */
+    public $expirets;
+
+    /**
+    * @var String 礼包内容: itemid,num;itemid,num...  
+    */
+    public $reward;
+
+    /**
+    * @var String 备注  
+    */
+    public $desc;
+
+}
+

+ 1 - 1
Gameserver/App/model/Const/sm_waveItem.php

@@ -3,7 +3,7 @@
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
- // 日期: 2024-06-19 14:05:46
+ // 日期: 2024-06-20 17:11:02
 ////////////////////
 
 

+ 1 - 1
Gameserver/App/model/Const/sm_waves.php

@@ -3,7 +3,7 @@
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
- // 日期: 2024-06-19 14:05:46
+ // 日期: 2024-06-20 17:11:02
 ////////////////////
 
 

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

@@ -195,6 +195,12 @@ class Info_PrivateState extends Object_ext {
      */
     public $buyTiliNum = 0;
     
+    /**
+     *  广告得体力倒计时
+     * @var type
+     */
+    public $guanggaoGetTili_ts = 0;
+
     /*
      * 通关荣誉榜奖励领取记录
      */
@@ -208,6 +214,12 @@ class Info_PrivateState extends Object_ext {
     #[ArrayType]
     public $rankReward_drawed_fightPower = array();
     
+    /**
+     * @var array[] 领取激活码记录
+     */
+    #[ArrayType]
+    public $usedTokens = array();
+    
     public function initialize() {
         $this->junbeiShopNumRecord = new \stdClass();
         $this->junbeiShop_AllNumRecord = new \stdClass();

+ 2 - 2
Gameserver/App/model/User/Info_UserBase.php

@@ -66,7 +66,7 @@ class Info_UserBase extends Object_ext {
      * 额外体力值
      * @var int
      */
-    public $tili = 120;
+    public $tili = 0;
 
     /**
      * @var int 体力时间戳
@@ -119,7 +119,7 @@ class Info_UserBase extends Object_ext {
         $this->gold = glc()->Init_Player_gold;
         $this->cash = glc()->Init_Player_cash;
         $this->xp = 0;
-        $this->tili = GameConfig::globalsettings()->tili_RecoverrMax;           # 恢复体力上限
+            
         $this->maxXp = GameConfig::player_level_getItem(2)->xp_need;
 
         $this->level = 1;

+ 117 - 12
Gameserver/App/process/ActiveProc.php

@@ -14,6 +14,7 @@ namespace loyalsoft;
  * @author c'y'zhao
  */
 class ActiveProc {
+
     /**
      * 逻辑分发
      * 所有的Proc中必须有这样一个方法
@@ -21,25 +22,128 @@ class ActiveProc {
      */
     public static function procMain($req) {
         switch ($req->cmd) {
-            case CmdCode::active_day7_drawreward:                               # 6101 签到
-                return ActiveProc::Day7_DrawReward();        
-                                    
+            case CmdCode::cmd_active_day7_drawreward:                           # 6101 签到
+                return ActiveProc::Day7_DrawReward();
+            case CmdCode::cmd_active_drawPackageByCode:                         # 6102 兑换码礼包
+                return ActiveProc::drawPackageByCode();
             default:
                 Err(ErrCode::cmd_err);
         }
     }
+
+    /**
+     *  6102 兑换码礼包
+     */
+    static function drawPackageByCode() {
+        list($activeId, $codestring) = req()->paras;                            # 取参数 活动id, 兑换码
+
+        $codePlatStr = "";
+        $packageID = 0;
+
+        if (self::PublicTokenCodeCheck($codestring)) {
+            $packageInfo = GameConfig::token_PublicGift_getItem($codestring);
+            my_Assert($packageInfo->expirets >= now() && $packageInfo->startTs <= now(),
+                    ErrCode::active_activecode_outtime);
+            my_Assert(!in_array($codestring, ctx()->privateState->usedTokens), ErrCode::active_hasgetted); # 已经领取过该礼包了
+            $packageID = $codestring;
+            $err = StoreProc::AddMultiItemInStore($packageInfo->reward);            # 发放礼包
+            EmailProc::SendPackageByCodeMail(req()->zoneid, req()->uid, $packageInfo->reward);           
+            my_Assert(ErrCode::ok == $err, $err);
+        } else {
+            $active = GameConfig::activity_getItem($activeId);                      # 活动数据
+            my_Assert(null != $active, ErrCode::active_const_no_err);
+            my_Assert($active->startts <= now() && $active->endts >= now(), ErrCode::active_time); # 校验开放时间
+            my_Assert(preg_match("/^[a-kmnp-z2-9]{10}$/", $codestring), ErrCode::active_activecode_format); # 基础格式校验(10个特定字符)
+            $activeCode = CipheredBase32::Decode($codestring);                      # 解码
+            $codePlatStr = GameConstants::GetPlatStringByActivteCode($activeCode);  # platstr
+            my_Assert(GameConstants::AllPlatStr == $codePlatStr #                   # 忽略全平台礼包
+                    || req()->getPlatStr() == $codePlatStr, #                       # 平台字符串必须相符
+                    ErrCode::active_activecode_plat); #                             # 平台错误
+
+            my_Assert(is_int($activeCode->number) #                                 # 编号为int值
+                    && $activeCode->number >= 1 && $activeCode->number <= 50000, #  # 检查 兑换码的编号范围0~50000
+                    ErrCode::active_activecode_format);
+
+            $packageID = $activeCode->package;                                      # 礼包id
+            $packageInfo = GameConfig::token_gift_getItem($packageID);               # 礼包常量数据
+            my_Assert(null != $packageInfo, ErrCode::err_const_no);                 # 防御
+            my_Assert($packageInfo->expirets >= now() && $packageInfo->startTs <= now(),
+                    ErrCode::active_activecode_outtime);                            # 激活码已经失效,或者礼包尚未开启
+
+            $privateState = new Info_PrivateState(ctx()->privateState);             # 快速访问
+            my_Assert(!in_array($packageID, $privateState->usedTokens), ErrCode::active_hasgetted); # 已经领取过该礼包了
+            my_Assert(!self::checkActiveCodeIsUsed($activeCode), ErrCode::active_activecode_used);  # 检查 该激活码是否别人已经使用过了
+            $err = StoreProc::AddMultiItemInStore($packageInfo->reward);            # 发放礼包
+            my_Assert(ErrCode::ok == $err, $err);                                   # 防御发放礼包过程出错
+            $ok = self::setActiveCodeUserRecord($activeCode, req()->uid);           # 插入数据库
+            my_Assert($ok, ErrCode::err_db);                                        # 数据库操作失败- 重试     
+        }
+      
+        ctx()->privateState->usedTokens[] = $packageID;
+
+        UserProc::updateUserInfo();                                             # 回存玩家数据     
+        $ret = array(#                                                          # 返回值
+            "plat" => $codePlatStr,
+            "packageId" => $packageID,
+            "reward" => $packageInfo->reward,
+            'gold' => ctx()->base()->gold,
+            'cash' => ctx()->base()->cash,
+            //'tili' => ctx()->base()->tili,
+            'store' => ctx()->store,
+            //'hero' => ctx()->heros,
+        );
+        return Resp::ok($ret);                                                  # 返回成功信息
+    }
     
+    public static function PublicTokenCodeCheck($codestring) {
+        $dic = GameConfig::token_PublicGift();
+        if (StlUtil::dictHasProperty($dic, $codestring)) {
+            return true;
+        }
+        return false;
+    }
     
+    /**
+     * 检查兑换码是否已经使用过了
+     * @param ActiveCode $activeCode
+     * @return boolean true : 已经用过了, false : 激活码尚未使用过.
+     */
+    static function checkActiveCodeIsUsed($activeCode) {
+        $sql = sprintf("`plat`='%d' and `package`='%d' and `number`='%d'", #       # where 子句
+                $activeCode->plat, $activeCode->package, $activeCode->number);
+        $rows = daoInst()
+                ->select()
+                ->from(self::tab_toke_gift)                                     # 表名
+                ->where($sql)
+                ->count();
+        return $rows > 0;
+    }
+
+    /**
+     * 将兑换码添加到使用记录中
+     * @param ActiveCode $actvieCode
+     * @param string $uid
+     * @return boolean true: 操作成功, false: 操作失败
+     */
+    static function setActiveCodeUserRecord($actvieCode, $uid) {
+        $actvieCode->uid = $uid;                                                # 添加uid
+        $ret = daoInst()
+                ->insert(self::tab_toke_gift)                                   # 表名
+                ->data($actvieCode)
+                ->exec();
+        return $ret > 0;
+    }
+
     /**
      * 7日签到 数据更新
      */
     public static function DailyResetDay7Task() {
-        if(count(ctx()->privateState->LoginDays) >= 7){
+        if (count(ctx()->privateState->LoginDays) >= 7) {
             ctx()->privateState->LoginDays = array();
             ctx()->privateState->day7_drawed = array();
         }
-        $index = count(ctx()->privateState->LoginDays)+1;       
-        ctx()->privateState->LoginDays[] = $index;       
+        $index = count(ctx()->privateState->LoginDays) + 1;
+        ctx()->privateState->LoginDays[] = $index;
         ctx()->privateState->day7_accumulate += 1;
     }
 
@@ -50,21 +154,22 @@ class ActiveProc {
     public static function Day7_DrawReward() {
         list($day) = req()->paras;                                              # 参数: 领取第x天的奖励
         $user = ctx();
-       
-        my_Assert(in_array($day,$user->privateState->LoginDays), ErrCode::active_day7_expired);
+
+        my_Assert(in_array($day, $user->privateState->LoginDays), ErrCode::active_day7_expired);
         my_Assert(!in_array($day, $user->privateState->day7_drawed), ErrCode::active_hasgetted);
         $day_rwd = GameConfig::activity_day7_getItem($day);                     # 查询奖励数据
         my_Assert(null != $day_rwd, ErrCode::err_const_no);                     # 防御找不到配置
         StoreProc::AddMultiItemInStore($day_rwd->reward);                       # 发放奖励
         $user->privateState->day7_drawed[] = $day;                              # 添加领取记录
-                 
+
         ctx($user);
         UserProc::updateUserInfo();                                             # 回存
         return Resp::ok(array(
                     'gold' => $user->baseInfo->gold,
                     'cash' => $user->baseInfo->cash,
                     'tili' => $user->baseInfo->tili,
-                    'store' => $user->store,                  
-        ));   
-    } 
+                    'store' => $user->store,
+        ));
+    }
+
 }

+ 13 - 0
Gameserver/App/process/EmailProc.php

@@ -548,6 +548,19 @@ class EmailProc {
                 "资源月卡每日奖励!", $reward);
         self::InsertMail($zoneid, $uid, $mail);
     }
+    
+    /**
+     * 激活码邮件
+     * @param type $zoneid
+     * @param type $uid
+     * @param type $title
+     * @param type $content
+     */
+    public static function SendPackageByCodeMail($zoneid, $uid, $reward) {
+        $mail = new Ins_Email(null, enum_Mail_Type::SysTemMail, "激活码兑换礼包奖励", #
+                "激活码兑换礼包奖励!", $reward);
+        self::InsertMail($zoneid, $uid, $mail);
+    }
 
 // </editor-fold>
 //

+ 8 - 7
Gameserver/App/process/FightProc.php

@@ -91,7 +91,6 @@ class FightProc {
         if ($wavesMo->rewardTuZhi != null) {
             $tuzhi = explode('-', $wavesMo->rewardTuZhi);
             $n = rand($tuzhi[0], $tuzhi[1]);
-
             $tuzhiArr = array();
             $item = GameConfig::item();
             foreach ($item as $id => $mo) {
@@ -99,12 +98,13 @@ class FightProc {
                     $tuzhiArr[] = $id;
                 }
             }
-
-            $index = rand(0, count($tuzhiArr) - 1);
-            $goodsStr = $tuzhiArr[$index] . ',' . $n;
-
-            $prizeArr[] = $goodsStr;
-            StoreProc::AddMultiItemInStore($goodsStr);
+            for ($i = 0; $i < $n; $i++) {
+                $index = rand(0, count($tuzhiArr) - 1);
+                $goodsStr = $tuzhiArr[$index] . ',' . 1;
+                $prizeArr[] = $goodsStr;
+                StoreProc::AddMultiItemInStore($goodsStr);
+            }                    
+            
         }
 
         if ($wavesMo->rewardGem != null) {
@@ -439,6 +439,7 @@ class FightProc {
                 ctx()->gates->GateList->$gateId->pass = 1;
                 TaskProc::Day7TaskReset($gateId);                               # 刷新七日任务
                 $maxGateId = ctx()->gates->maxPassGateNumId();
+
                 if ($maxGateId > 0) {
                     self::Ranking_MainGateIndex($maxGateId);
                     self::IsAchievedMainGate_PassReward($maxGateId);

+ 4 - 2
Gameserver/App/process/ShopProc.php

@@ -37,11 +37,13 @@ class ShopProc {
         $addTili = 0;
         if ($type == 1) {//广告
             $maxNum = glc()->GuanggaoGetTili_DailyMaxNum;
-            my_Assert(ctx()->privateState->guanggaoGetTiliNum < $maxNum, ErrCode::user_shop_GuanggaoGetTiliNumLimit);
-
+            my_Assert(ctx()->privateState->guanggaoGetTiliNum < $maxNum, ErrCode::user_shop_GuanggaoGetTiliNumLimit);                      
+            my_Assert(now() - ctx()->privateState->guanggaoGetTili_ts > 300, ErrCode::user_shop_DownTsLimit);           
             $addTili = glc()->GuanggaoGetTili;
             ctx()->baseInfo->Add_tili(glc()->GuanggaoGetTili);
             ctx()->privateState->guanggaoGetTiliNum += 1;
+            
+            ctx()->privateState->guanggaoGetTili_ts = now();
         } else {
             $maxNum = glc()->BuyTili_DailyMaxNum;
             my_Assert(ctx()->privateState->buyTiliNum < $maxNum, ErrCode::user_shop_buyTiliNumLimit);

+ 1 - 0
Gameserver/App/process/TaskProc.php

@@ -122,6 +122,7 @@ class TaskProc {
         return Resp::ok(array("task" => ctx()->task,
                     "store" => ctx()->store,
                     'reward' => StoreProc::$reward,
+                    'cash'=>ctx()->baseInfo->cash,
         ));
     }