Browse Source

fixed: 将竞技场检查并发送上榜奖励邮件的逻辑提前到每日登录时触发.

gwang 5 years ago
parent
commit
14def54a75

+ 44 - 0
Gameserver/Amfphp/model/User/UserPVPModel.php

@@ -75,6 +75,50 @@ class UserPVPModel extends Object_ext {
         }
     }
 
+    /**
+     * 发送上榜奖励(昨天的奖励,以及上一赛季的奖励)
+     * @param type $zoneid
+     * @param type $uid
+     * @param type $seasonId
+     */
+    public function sendRewardEmail($zoneid, $uid, $seasonId) {
+        $key = MemKey_GameRun::Game_PVPScoreByZoneSeason_zset($zoneid, $seasonId); # 积分总榜
+        if ($this->haventReward_season >= 0 && $this->haventReward_season < $seasonId) { # 尚未发放上赛季奖励
+            $haventKey = MemKey_GameRun::Game_PVPScoreByZoneSeason_zset($zoneid, $this->haventReward_season);
+            // todo:发放上赛季奖励邮件
+            $rank = self::_getRank_by_uid($uid, $haventKey);                    # 查询上赛季排名
+            if ($rank <= self::pvpMaxRank) {                                    # 防御未上榜
+                foreach (GameConfig::pvp_rankreward() as $cfg) {
+                    isEditor() and $cfg = new \sm_pvp_rankreward();
+                    if ($rank >= $cfg->minRank && $rank <= $cfg->maxRank) {     # 找到对应的名次段
+                        EmailProc::SendPvpRankReward_Season($zoneid, $uid, $rank); # 发放奖励邮件(竞技币)
+                    }
+                }
+                UserProc::updateUserInfo();
+            }
+        }
+        $this->haventReward_season = $seasonId;                                  # 更新待发奖赛季
+        if ($this->haventReward_tsDay == tsDay() - 1) {                          # 尚未发放昨天奖励
+            $haventKey_day = MemKey_GameRun::Game_PVPScoreByZone_zset_Day($zoneid, $this->haventReward_tsDay);
+            if (!gMem()->exists($haventKey_day) && $this->haventReward_tsDay == tsDay() - 1) { # 昨天的积分记录不存在
+                gMem()->zcopy($key, $haventKey_day);                            # 复制一份当前积分作为昨天的截止积分榜
+            } else {
+                // 不是昨天登录的, 且没有对应的数据 就不再复制当前数据了.直接未上榜处理
+            }
+            $rank = self::_getRank_by_uid($uid, $haventKey_day);                # 查询上一天排名
+            if ($rank <= self::pvpMaxRank) {                                    # 防御未上榜
+                foreach (GameConfig::pvp_rankreward() as $cfg) {
+                    isEditor() and $cfg = new \sm_pvp_rankreward();
+                    if ($rank >= $cfg->minRank && $rank <= $cfg->maxRank) {     # 找到对应的名次段
+                        EmailProc::SendPvpRankReward_Lastday($zoneid, $uid, $rank); # 发放奖励邮件(竞技币)
+                    }
+                }
+                UserProc::updateUserInfo();
+            }
+        }
+        $this->haventReward_tsDay = tsDay();                                     # 更新待发放奖励日期
+    }
+
     public function __construct($arg = null) {
         parent::__construct($arg);
         if (null == $this->curShopItems) {

+ 4 - 0
Gameserver/Amfphp/process/FightProc.php

@@ -71,6 +71,10 @@ class FightProc {
      */
     static function ClearByDay($req) {
         SweepGatesProc::ClearGateTimes($req);                                   # 清理每个难度副本的每日战斗次数 
+        $pvp = new UserPVPModel($req->userInfo->game->pvp);
+        $pvp->refreshDailyData();
+        $pvp->sendRewardEmail($req->zoneid, $req->uid, PVPProc::GetCurSeasonID());
+        $req->userInfo->game->pvp = $pvp;
     }
 
 }

+ 35 - 35
Gameserver/Amfphp/process/FightProc/PVPProc.php

@@ -254,41 +254,41 @@ class PVPProc {
         $fPower = HeroProc::CalcUserFightPower($zoneid, $uid, $req->userInfo->game); # 玩家总战力?还是当前防守队伍的战斗力?
         $numNewLog = 0; // todo: 真正查询是否有新战报
         $matches = self::getNewMatches($pvp, $uid, $zoneid);                    # 获得新的匹配对手
-
-        if ($pvp->haventReward_season >= 0 && $pvp->haventReward_season < $seasonId) { # 尚未发放上赛季奖励
-            $haventKey = MemKey_GameRun::Game_PVPScoreByZoneSeason_zset($zoneid, $pvp->haventReward_season);
-            // todo:发放上赛季奖励邮件
-            $rank = self::_getRank_by_uid($uid, $haventKey);                    # 查询上赛季排名
-            if ($rank <= self::pvpMaxRank) {                                    # 防御未上榜
-                foreach (GameConfig::pvp_rankreward() as $cfg) {
-                    isEditor() and $cfg = new \sm_pvp_rankreward();
-                    if ($rank >= $cfg->minRank && $rank <= $cfg->maxRank) {     # 找到对应的名次段
-                        EmailProc::SendPvpRankReward_Season($zoneid, $uid, $rank); # 发放奖励邮件(竞技币)
-                    }
-                }
-                UserProc::updateUserInfo();
-            }
-        }
-        $pvp->haventReward_season = $seasonId;                                  # 更新待发奖赛季
-        if ($pvp->haventReward_tsDay == tsDay() - 1) {                          # 尚未发放昨天奖励
-            $haventKey_day = MemKey_GameRun::Game_PVPScoreByZone_zset_Day($zoneid, $pvp->haventReward_tsDay);
-            if (!gMem()->exists($haventKey_day) && $pvp->haventReward_tsDay == tsDay() - 1) { # 昨天的积分记录不存在
-                gMem()->zcopy($key, $haventKey_day);                            # 复制一份当前积分作为昨天的截止积分榜
-            } else {
-                // 不是昨天登录的, 且没有对应的数据 就不再复制当前数据了.直接未上榜处理
-            }
-            $rank = self::_getRank_by_uid($uid, $haventKey_day);                # 查询上一天排名
-            if ($rank <= self::pvpMaxRank) {                                    # 防御未上榜
-                foreach (GameConfig::pvp_rankreward() as $cfg) {
-                    isEditor() and $cfg = new \sm_pvp_rankreward();
-                    if ($rank >= $cfg->minRank && $rank <= $cfg->maxRank) {     # 找到对应的名次段
-                        EmailProc::SendPvpRankReward_Lastday($zoneid, $uid, $rank); # 发放奖励邮件(竞技币)
-                    }
-                }
-                UserProc::updateUserInfo();
-            }
-        }
-        $pvp->haventReward_tsDay = tsDay();                                     # 更新待发放奖励日期
+        $pvp->sendRewardEmail($zoneid, $uid, $seasonId);                        # 发奖励邮件
+//        if ($pvp->haventReward_season >= 0 && $pvp->haventReward_season < $seasonId) { # 尚未发放上赛季奖励
+//            $haventKey = MemKey_GameRun::Game_PVPScoreByZoneSeason_zset($zoneid, $pvp->haventReward_season);
+//            // todo:发放上赛季奖励邮件
+//            $rank = self::_getRank_by_uid($uid, $haventKey);                    # 查询上赛季排名
+//            if ($rank <= self::pvpMaxRank) {                                    # 防御未上榜
+//                foreach (GameConfig::pvp_rankreward() as $cfg) {
+//                    isEditor() and $cfg = new \sm_pvp_rankreward();
+//                    if ($rank >= $cfg->minRank && $rank <= $cfg->maxRank) {     # 找到对应的名次段
+//                        EmailProc::SendPvpRankReward_Season($zoneid, $uid, $rank); # 发放奖励邮件(竞技币)
+//                    }
+//                }
+//                UserProc::updateUserInfo();
+//            }
+//        }
+//        $pvp->haventReward_season = $seasonId;                                  # 更新待发奖赛季
+//        if ($pvp->haventReward_tsDay == tsDay() - 1) {                          # 尚未发放昨天奖励
+//            $haventKey_day = MemKey_GameRun::Game_PVPScoreByZone_zset_Day($zoneid, $pvp->haventReward_tsDay);
+//            if (!gMem()->exists($haventKey_day) && $pvp->haventReward_tsDay == tsDay() - 1) { # 昨天的积分记录不存在
+//                gMem()->zcopy($key, $haventKey_day);                            # 复制一份当前积分作为昨天的截止积分榜
+//            } else {
+//                // 不是昨天登录的, 且没有对应的数据 就不再复制当前数据了.直接未上榜处理
+//            }
+//            $rank = self::_getRank_by_uid($uid, $haventKey_day);                # 查询上一天排名
+//            if ($rank <= self::pvpMaxRank) {                                    # 防御未上榜
+//                foreach (GameConfig::pvp_rankreward() as $cfg) {
+//                    isEditor() and $cfg = new \sm_pvp_rankreward();
+//                    if ($rank >= $cfg->minRank && $rank <= $cfg->maxRank) {     # 找到对应的名次段
+//                        EmailProc::SendPvpRankReward_Lastday($zoneid, $uid, $rank); # 发放奖励邮件(竞技币)
+//                    }
+//                }
+//                UserProc::updateUserInfo();
+//            }
+//        }
+//        $pvp->haventReward_tsDay = tsDay();                                     # 更新待发放奖励日期
         $req->userInfo->game->pvp = $pvp;
         UserProc::updateUserInfo();
         // 组装 返回值结构