Browse Source

1.官网支付增加了防沉迷系统关于充值金额限制的逻辑. 2. 代码更新维护,TimeUtil增补部分函数,更名了部分函数.

王刚 3 years ago
parent
commit
6e27bf6f8e

+ 1 - 1
Gameserver/Amfphp/Services/AppServer.php

@@ -74,7 +74,7 @@ class AppServer {
         $sql .= sprintf('drop table if exists %s;', $old_tablename);            # 循环删除以前的表
         $sql .= sprintf("insert into %s (`uid`,`zoneid`,`cmd`,`days`,`param`,`ret`) values ('%s', %d, %d, %d, '%s', '%s');", #
                 $tablename, req()->uid, req()->zoneid, req()->cmd, #            # Uid, zoneid, cmd
-                (isset(req()->userInfo) ? (tsDay() - tsDay(req()->userInfo->game->baseInfo->firstLogin)) : 0), #  # ps.留存天数
+                (isset(req()->userInfo) ? (totalDays() - totalDays(req()->userInfo->game->baseInfo->firstLogin)) : 0), #  # ps.留存天数
                 JsonUtil::encode(req()->paras), #                               # req->paras
                 JsonUtil::encode($resp->result)); #                             # resp->result
         daoInst()->exec($sql);                                                  # 执行sql

+ 2 - 2
Gameserver/Amfphp/base/MemKey_GameRun.php

@@ -176,7 +176,7 @@ class MemKey_GameRun {
      */
     static function DailyLoginUser_byUID_hash($zoneid, $tsDay = null) {
         if (!$tsDay) {                                                          # 检查是否默认参数
-            $tsDay = tsDay();
+            $tsDay = totalDays();
         }
         return "gamerun-loginUser-byUid-zone$zoneid-day_$tsDay";
     }
@@ -190,7 +190,7 @@ class MemKey_GameRun {
      */
     static function DailyLoginUser_byLevel_hash($zoneid, $level, $tsDay = null) {
         if (!$tsDay) {                                                          # 检查是否默认参数
-            $tsDay = tsDay();
+            $tsDay = totalDays();
         }
         return "gamerun-loginUser-byLevel-zone$zoneid-day_$tsDay-lvl_$level";
     }

+ 113 - 109
Gameserver/Amfphp/model/User/Info_College.php

@@ -1,5 +1,7 @@
 <?php
+
 namespace loyalsoft;
+
 /*
  * To change this license header, choose License Headers in Project Properties.
  * To change this template file, choose Tools | Templates
@@ -13,49 +15,48 @@ namespace loyalsoft;
  *
  * @author cyzhao
  */
-class Info_College extends Object_ext{
+class Info_College extends Object_ext {
+
     /**
-     * 当前所在的级别 
+     * 当前所在的级别
      */
     public $collegeId = 1;
-
     /// <summary>
     /// 所处的课程id
     /// </summary>
     public $courseId = 1001;
-    
+
     /**
      * 将领取课程奖励的保存在这
      * @var type
      */
     public $comCourseList = array();
-
     /// <summary>
     /// 任务卡信息
     /// </summary>
     //public List<missCourseItem> compMissCardList = new List<missCourseItem>();
-    public $compMissCardDic=null;
-    
+    public $compMissCardDic = null;
+
     /**
      * 当前课程进度,进入下一个课程清0
      * @var type
      */
     public $progress = 0;
-    
+
     /**
      * 年级奖励领取记录
      * @var type
      */
     public $collegeRewardList = array();
-    
+
     /**
-     * 
+     *
      * @var type
      */
     public $maskCollege = 0;
-    
+
     /**
-     * 
+     *
      * @var type
      */
     public $ingTaskCardDic = null;
@@ -65,15 +66,15 @@ class Info_College extends Object_ext{
      * @var type
      */
     public $funUnluckTs = 0;
-    
+
     /**
      * 累计积分
      * @var type
      */
     public $score = 0;
-    
+
     /**
-     * 
+     *
      * @var type
      */
     public $scoreRewardList = array();
@@ -82,85 +83,85 @@ class Info_College extends Object_ext{
      * 构造函数
      * @param type $args
      */
-    public function __construct($args = null) {    
-        if($args == null){
+    public function __construct($args = null) {
+        if ($args == null) {
             $this->compMissCardDic = new \stdClass();
             $this->ingTaskCardDic = new \stdClass();
         } else {
-            parent::__construct($args);   
-        }                    
+            parent::__construct($args);
+        }
     }
+
     /**
      * 废弃了
      */
     //public function initialize() {
-//        $this->compMissCardDic = new \stdClass();  
-//        $dic = GameConfig::course_getItem($this->courseId);       
-//        $misslist = explode(',',$dic->misslist);      
+//        $this->compMissCardDic = new \stdClass();
+//        $dic = GameConfig::course_getItem($this->courseId);
+//        $misslist = explode(',',$dic->misslist);
 //        foreach ($misslist as $id) {
-//            $item = new ins_missCourseItem();        
-//            $item->initialize($id);         
+//            $item = new ins_missCourseItem();
+//            $item->initialize($id);
 //            $this->compMissCardDic->$id = $item;
 //        }
-        //$this->initCompMissCardDic();
+    //$this->initCompMissCardDic();
     //}
-    
+
     public function initCompMissCardDic() {
-        $this->compMissCardDic = new \stdClass();  
-        $dic = GameConfig::course_getItem($this->courseId);       
-        $misslist = explode(',',$dic->misslist);      
+        $this->compMissCardDic = new \stdClass();
+        $dic = GameConfig::course_getItem($this->courseId);
+        $misslist = explode(',', $dic->misslist);
         foreach ($misslist as $id) {
-            $item = new ins_missCourseItem();        
-            $item->initialize($id);         
+            $item = new ins_missCourseItem();
+            $item->initialize($id);
             $this->compMissCardDic->$id = $item;
         }
     }
-    
+
     /**
      * 修改任务卡状态
      * @param type $id
      * @param type $state
      */
-    public function modifyTaskCardState($id,$state) {
+    public function modifyTaskCardState($id, $state) {
         $ingTaskCardDic = $this->ingTaskCardDic;
         foreach ($ingTaskCardDic as $collegeId => $courseDic) {
             foreach ($courseDic as $courseId => $cardDic) {
                 foreach ($cardDic as $cardId => $val) {
-                    if($cardId == $id){
+                    if ($cardId == $id) {
                         TaskProc::OnFinishSchoolTask();
                         $this->ingTaskCardDic->$collegeId->$courseId->$cardId->type = $state;
-                        break 3; 
+                        break 3;
                     }
                 }
             }
         }
-        
+
 //        if(!StlUtil::dictHasProperty($this->compMissCardDic, $id)){
 //            return;
 //        }
 //        $this->compMissCardDic->$id->type = $state;
-//        $this->progress += 1;           
-        
-        
+//        $this->progress += 1;
     }
+
     /**
      * 废弃
-     */  
-    public function updataCourseNew() {            
+     */
+    public function updataCourseNew() {
         //检测是否到下一年级
-//        $collegeDic = GameConfig::college_getItem($this->collegeId);      
+//        $collegeDic = GameConfig::college_getItem($this->collegeId);
 //        if(in_array($this->courseId +1,explode(',', $collegeDic->cList))){
 //            $this->courseId += 1;
 //            $this->initCompMissCardDic();
 //            $this->progress = 0;
 //        } else {
-            
+
         $this->collegeRewardList[] = $this->collegeId;
         //TaskProc::OnFinishAllSchoolTaskOfGrade($this->collegeId);
-        
-        $this->collegeId += 1;    
-        $newCollegeDic = GameConfig::college_getItem($this->collegeId);  
-        if($newCollegeDic == null){
+
+        $this->collegeId += 1;
+        $newCollegeDic = GameConfig::college_getItem($this->collegeId);
+        if ($newCollegeDic == null) {
             $this->maskCollege = Enum_College::finish;
             $this->collegeId -= 1;
         } elseif ($newCollegeDic != null && $newCollegeDic->cList == null) {
@@ -168,87 +169,90 @@ class Info_College extends Object_ext{
         } else {
             $cList = explode(',', $newCollegeDic->cList);
             $this->courseId = $cList[0];
-            $this->initCompMissCardDic();   
-        }                    
-//        }                  
+            $this->initCompMissCardDic();
+        }
+//        }
     }
-    
+
     /**
      * 废弃
      */
-    public function updataCourse() { 
-        $this->comCourseList[] = $this->courseId;       
+    public function updataCourse() {
+        $this->comCourseList[] = $this->courseId;
         //检测是否到下一年级
-        $collegeDic = GameConfig::college_getItem($this->collegeId);      
-        if(in_array($this->courseId +1,explode(',', $collegeDic->cList))){
+        $collegeDic = GameConfig::college_getItem($this->collegeId);
+        if (in_array($this->courseId + 1, explode(',', $collegeDic->cList))) {
             $this->courseId += 1;
             $this->initCompMissCardDic();
             $this->progress = 0;
-        } 
-        
+        }
+
 //        else {
 //            $this->collegeId += 1;
-//            $newCollegeDic = GameConfig::college_getItem($this->collegeId);  
+//            $newCollegeDic = GameConfig::college_getItem($this->collegeId);
 //            $cList = explode(',', $newCollegeDic->cList);
 //            $this->courseId = $cList[0];
 //            $this->initCompMissCardDic();
 //            $this->progress = 0;
-//        }                  
+//        }
     }
+
     //废弃
     public function checkCollege() {
-        if($this->maskCollege == Enum_College::update){
+        if ($this->maskCollege == Enum_College::update) {
             $dic = GameConfig::college_getItem($this->collegeId);
-            if($dic != null && $dic->cList != null){
+            if ($dic != null && $dic->cList != null) {
                 $this->maskCollege = 0;
                 $cList = explode(',', $dic->cList);
                 $this->courseId = $cList[0];
                 $this->initCompMissCardDic();
-            }                               
-        }           
+            }
+        }
     }
+
 //------------------new---------------------
+
     /**
      * 根据天 初始化
      * @return type
      */
-    public function initTaskCard() {             
-        if($this->funUnluckTs == 0){
-           return;
+    public function initTaskCard() {
+        if ($this->funUnluckTs == 0) {
+            return;
         }
-      
-        $day = TimeUtil::tsDay($this->funUnluckTs);
-        $curDay = TimeUtil::tsDay(time());
+
+        $day = TimeUtil::totalDays($this->funUnluckTs);
+        $curDay = TimeUtil::totalDays(time());
         $num = $curDay - $day;
-       
-        $collegeMo = GameConfig::college();       
-        $college = (array)$collegeMo;
+
+        $collegeMo = GameConfig::college();
+        $college = (array) $collegeMo;
         ksort($college);
-        
+
         $index = 0;
         foreach ($college as $collegeId => $collegeMo) {
-            $courseArr = explode(',',$collegeMo->cList);
-         
-            if(!StlUtil::dictHasProperty($this->ingTaskCardDic, $collegeId)){
+            $courseArr = explode(',', $collegeMo->cList);
+
+            if (!StlUtil::dictHasProperty($this->ingTaskCardDic, $collegeId)) {
                 $this->ingTaskCardDic->$collegeId = new \stdClass();
             }
             $collegeDic = $this->ingTaskCardDic->$collegeId;
-            foreach ($courseArr as $courseId) {                            
-                if(!StlUtil::dictHasProperty($collegeDic, $courseId)){
-                    $mo= GameConfig::course_getItem($courseId);
-                    $arr = explode(',',$mo->misslist);
+            foreach ($courseArr as $courseId) {
+                if (!StlUtil::dictHasProperty($collegeDic, $courseId)) {
+                    $mo = GameConfig::course_getItem($courseId);
+                    $arr = explode(',', $mo->misslist);
                     $dic = new \stdClass();
                     foreach ($arr as $cardId) {
-                        $item = new ins_missCourseItem();        
-                        $item->initialize($cardId);         
-                       
+                        $item = new ins_missCourseItem();
+                        $item->initialize($cardId);
+
                         $cid = StoreProc::PutTaskCardInStore($cardId);                      // 存入背包
                         NormalEventProc::OnTaskCard_Actived($cid, null);                        # 带入事件
-                          
+
                         $item->indexId = $cid;
-                        $taskCard = new Ins_TaskCard(req()->userInfo->game->store->taskcards->$cid);# 任务卡对象
+                        $taskCard = new Ins_TaskCard(req()->userInfo->game->store->taskcards->$cid); # 任务卡对象
                         $taskCard->state = Enum_TaskCardStateType::ing;
-                
+
                         TaskProc::OnGetSchoolTask();
                         foreach ($taskCard->curSteps as &$tsp) {                                # 初期里面只有一个任务
                             $tsp = new Ins_TaskStep($tsp);
@@ -265,21 +269,21 @@ class Info_College extends Object_ext{
                         }
                         $dic->$cardId = $item;
                         //统计
-                        StatisticsProc::TargetStatistics(Enum_TargetStatistics::collegeCouseId_UnlockUserNum,$cardId);
+                        StatisticsProc::TargetStatistics(Enum_TargetStatistics::collegeCouseId_UnlockUserNum, $cardId);
                         req()->userInfo->game->store->taskcards->$cid = $taskCard;
-                    }              
-                    //$this->ingTaskCardDic->$courseId = $dic;   
+                    }
+                    //$this->ingTaskCardDic->$courseId = $dic;
                     $collegeDic->$courseId = $dic;
                 }
-                $this->ingTaskCardDic->$collegeId = $collegeDic;   
-                if($index >= $num){                    
+                $this->ingTaskCardDic->$collegeId = $collegeDic;
+                if ($index >= $num) {
                     break 2;
                 }
-                $index += 1;  
+                $index += 1;
             }
-        } 
-        req()->userInfo->game->college->ingTaskCardDic = $this->ingTaskCardDic; 
-        
+        }
+        req()->userInfo->game->college->ingTaskCardDic = $this->ingTaskCardDic;
+
         //--------------------
         //$courseDic = GameConfig::course();
 //        $index = 0;
@@ -288,16 +292,16 @@ class Info_College extends Object_ext{
 //                $arr = explode(',',$mo->misslist);
 //                $dic = new \stdClass();
 //                foreach ($arr as $cardId) {
-//                    $item = new ins_missCourseItem();        
-//                    $item->initialize($cardId);         
-//                            
+//                    $item = new ins_missCourseItem();
+//                    $item->initialize($cardId);
+//
 //                    $cid = StoreProc::PutTaskCardInStore($cardId);                      // 存入背包
 //                    NormalEventProc::OnTaskCard_Actived($cid, null);                        # 带入事件
-//                
+//
 //                    $item->indexId = $cid;
 //                    $taskCard = new Ins_TaskCard(req()->userInfo->game->store->taskcards->$cid);# 任务卡对象
 //                    $taskCard->state = Enum_TaskCardStateType::ing;
-//                
+//
 //                    TaskProc::OnGetSchoolTask();
 //                    foreach ($taskCard->curSteps as &$tsp) {                                # 初期里面只有一个任务
 //                        $tsp = new Ins_TaskStep($tsp);
@@ -314,26 +318,26 @@ class Info_College extends Object_ext{
 //                    }
 //                    $dic->$cardId = $item;
 //                    req()->userInfo->game->store->taskcards->$cid = $taskCard;
-//                }              
-//                $this->ingTaskCardDic->$courseId = $dic;                                      
+//                }
+//                $this->ingTaskCardDic->$courseId = $dic;
 //            }
-//                
+//
 //            if($index >= $num){
 //                break;
 //            }
 //            $index += 1;
-//        }                 
+//        }
     }
-            
+
     /**
      * 圣哲学院功能结算时间
      */
     public function setFunUnluckTs() {
-        if($this->funUnluckTs != 0){
+        if ($this->funUnluckTs != 0) {
             return;
         }
-        
-        $this->funUnluckTs = time();     
+
+        $this->funUnluckTs = time();
         $this->initTaskCard();
     }
 
@@ -352,5 +356,5 @@ class Info_College extends Object_ext{
     public function addScore($val) {
         $this->score += $val;
     }
-    
+
 }

+ 6 - 6
Gameserver/Amfphp/model/User/Info_UserPVP.php

@@ -79,7 +79,7 @@ class Info_UserPVP extends Object_ext {
 
     public function refreshDailyData() {
         // 刷新免费挑战次数
-        if (tsDay($this->fightTicketRefreshTs) <= tsDay()) {                    # 刷新时间<=今天,该刷新了
+        if (totalDays($this->fightTicketRefreshTs) <= totalDays()) {                    # 刷新时间<=今天,该刷新了
             $this->freeFightTickets = 3;                                        # 重置为3, 此处的3可以改为读取配置数据
             $this->fightTicketRefreshTs = now() + 86400;                        # 刷新时间设置为明天
         }
@@ -108,13 +108,13 @@ class Info_UserPVP extends Object_ext {
             }
         }
         $this->haventReward_season = $seasonId;                                  # 更新待发奖赛季
-        if ($this->haventReward_tsDay < tsDay() - 7) {
-            $this->haventReward_tsDay = tsDay() - 7;
+        if ($this->haventReward_tsDay < totalDays() - 7) {
+            $this->haventReward_tsDay = totalDays() - 7;
         }
-        for ($this->haventReward_tsDay; $this->haventReward_tsDay < tsDay(); $this->haventReward_tsDay++) {
+        for ($this->haventReward_tsDay; $this->haventReward_tsDay < totalDays(); $this->haventReward_tsDay++) {
 //        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) { # 昨天的积分记录不存在
+            if (!gMem()->exists($haventKey_day) && $this->haventReward_tsDay == totalDays() - 1) { # 昨天的积分记录不存在
                 gMem()->zcopy($key, $haventKey_day);                            # 复制一份当前积分作为昨天的截止积分榜
             } else {
                 // 不是昨天登录的, 且没有对应的数据 就不再复制当前数据了.直接未上榜处理
@@ -131,7 +131,7 @@ class Info_UserPVP extends Object_ext {
             }
 //        }
         }
-        $this->haventReward_tsDay = tsDay();                                     # 更新待发放奖励日期
+        $this->haventReward_tsDay = totalDays();                                     # 更新待发放奖励日期
     }
 
     public function __construct($arg = null) {

+ 1 - 1
Gameserver/Amfphp/model/User/Info_UserTask.php

@@ -70,7 +70,7 @@ class Info_UserTask extends Object_ext {
     }
 
     public function resetDailyTask() {
-        if (tsDay($this->dailyResetTs - 18000) < tsDay() || $this->dailyResetTs <= 0) { # 每天5点
+        if (totalDays($this->dailyResetTs - 18000) < totalDays() || $this->dailyResetTs <= 0) { # 每天5点
             $dts = GameConfig::task_daily();
             $this->taskListDaily = ObjectInit();
             foreach ($dts as $tid => $t) {

+ 16 - 16
Gameserver/Amfphp/process/ActiveProc.php

@@ -134,13 +134,13 @@ class ActiveProc {
                     $tag = true;
                 }
                 if ($n == 10 && $tag == false && $shenmiaoInfo->activeDic->$type->totalNum > 10) {
-                    $list[] = self::getActiveRandomItem(Enum_ActiveItemType::Sr, $shenmo); //self::randSsrUr($shenmo->per)                                  
+                    $list[] = self::getActiveRandomItem(Enum_ActiveItemType::Sr, $shenmo); //self::randSsrUr($shenmo->per)
                 } else {
                     if ($shenmiaoInfo->activeDic->$type->totalNum <= 10) {
                         $itemType = Enum_ActiveItemType::R;
                     }
                     $nId = self::getActiveRandomItem($itemType, $shenmo);
-                    $list[] = $nId;                   
+                    $list[] = $nId;
                 }
             }
             if ($shenmiaoInfo->activeDic->$type->totalNum == 10 && !in_array($shenmo->must, $list)) {//首次10连抽有必出--临时
@@ -151,7 +151,7 @@ class ActiveProc {
                 $shenmiaoInfo->isComNewWish = 1;
                 StlUtil::dictRemove($shenmiaoInfo->activeDic, $type);
             }
-            if($num == 1){
+            if ($num == 1) {
                 StatisticsProc::TargetStatistics(Enum_TargetStatistics::newUserLotteryDraw_one);
             } else {
                 StatisticsProc::TargetStatistics(Enum_TargetStatistics::newUserLotteryDraw_ten);
@@ -167,8 +167,8 @@ class ActiveProc {
                 $shenmiaoInfo->activeDic->$type->totalNum += $num;
                 $list = self::drawTenLottery($shenmo, $type, $num);
             }
-            
-            if($num == 1){
+
+            if ($num == 1) {
                 StatisticsProc::TargetStatistics(Enum_TargetStatistics::commonLotteryDraw_one);
             } else {
                 StatisticsProc::TargetStatistics(Enum_TargetStatistics::commonLotteryDraw_ten);
@@ -184,19 +184,19 @@ class ActiveProc {
                 $shenmiaoInfo->activeDic->$type->totalNum += $num;
                 $list = self::drawTenLottery($shenmo, $type, $num);
             }
-            
-            if($num == 1){
-                if($type == 4){
+
+            if ($num == 1) {
+                if ($type == 4) {
                     StatisticsProc::TargetStatistics(Enum_TargetStatistics::yanLingLotteryDraw_one);
                 } elseif ($type == 5) {
                     StatisticsProc::TargetStatistics(Enum_TargetStatistics::weaponLotteryDraw_one);
-                }                             
+                }
             } else {
-                if($type == 4){
+                if ($type == 4) {
                     StatisticsProc::TargetStatistics(Enum_TargetStatistics::yanLingLotteryDraw_ten);
                 } elseif ($type == 5) {
                     StatisticsProc::TargetStatistics(Enum_TargetStatistics::weaponLotteryDraw_ten);
-                }  
+                }
             }
         }
 
@@ -204,7 +204,7 @@ class ActiveProc {
             $s = $id . ',1';
             StoreProc::AddMultiItemInStore($s);
         }
-              
+
         $req->userInfo->game->shenmiao = $shenmiaoInfo;
         UserProc::updateUserInfo();
         TaskProc::OnTempleLottery();                                            # 检测神庙抽奖任务
@@ -816,15 +816,15 @@ class ActiveProc {
         $typeID = 6;                                                            #  7日活动
         $ac = GameConfig::activity_getItem($typeID);
         my_Assert(null != $ac, ErrCode::err_const_no);
-        $startDay = tsDay($ac->startts);
+        $startDay = totalDays($ac->startts);
         $newLoginDays = array_filter(req()->userInfo->game->privateState->LoginDays, # 剔除不符合时间的登录记录
                 function ($tsday)use ($startDay) {
-                    return $startDay <= $tsday;
-                }
+            return $startDay <= $tsday;
+        }
         );
         req()->userInfo->game->privateState->LoginDays = $newLoginDays;          #
         if (count(req()->userInfo->game->privateState->LoginDays) < 7) {
-            req()->userInfo->game->privateState->LoginDays[] = tsDay();
+            req()->userInfo->game->privateState->LoginDays[] = totalDays();
         }
     }
 

+ 3 - 2
Gameserver/Amfphp/process/PayProc.php

@@ -199,6 +199,7 @@ class PayProc {
         
         req()->userInfo->game = $user;
 
+        NormalEventProc::OnPaySuccess();
         UserProc::updateUserInfo();                                             # 回写玩家数据
         return Resp::ok(array(
                     "ret"=>self::$retArr,        
@@ -275,9 +276,9 @@ class PayProc {
             self::$retArr[] = $packageCfg->pri_reward;
             my_Assert(ErrCode::ok == $err, $err);
             if ($packageCfg->subType == 4) {
-                $shopdata->monthlyVIP1_ts = 3600 * 24 * (tsDay() + 1) - 1;           
+                $shopdata->monthlyVIP1_ts = 3600 * 24 * (totalDays() + 1) - 1;           
             } elseif ($packageCfg->subType == 5) {
-                $shopdata->monthlyVIP2_ts = 3600 * 24 * (tsDay() + 1) - 1;
+                $shopdata->monthlyVIP2_ts = 3600 * 24 * (totalDays() + 1) - 1;
             }
         
             EmailProc::SendMonthlyVIPDailyReward(req()->zoneid, req()->uid, $packageCfg->name, $packageCfg->daily_reward);

+ 39 - 38
Gameserver/Amfphp/process/ShopProc.php

@@ -12,7 +12,7 @@ class ShopProc {
 
     /**
      * 逻辑分发
-     * 所有的Proc中必须有这样一个方法 
+     * 所有的Proc中必须有这样一个方法
      */
     public static function procMain() {
         switch (req()->cmd) {
@@ -32,35 +32,35 @@ class ShopProc {
                 Err(ErrCode::cmd_err);
         }
     }
-    
+
     /*
      * 限购礼包触发条件检测
      */
-    public function checkLimitTsRandGiftTrigger($typeId,$para) {
+
+    public function checkLimitTsRandGiftTrigger($typeId, $para) {
         $arr = GameConfig::shop_limitTs_Type_getItemArray($typeId);
         my_Assert($arr != null, ErrCode::err_const_no);
-        $giftId = 0;  
-        
+        $giftId = 0;
+
         $giftArr = array();
         foreach ($arr as $item) {
-            if($item->para <= $para){                  
-                if(!in_array($item->giftId, req()->userInfo->game->shopdata->limitTsRewardsList)){
+            if ($item->para <= $para) {
+                if (!in_array($item->giftId, req()->userInfo->game->shopdata->limitTsRewardsList)) {
                     $giftId = $item->giftId;
                     //$giftArr[] = $giftId;
-                    
                     //没有触发对应的礼包条件
-                    if($giftId == 0){
+                    if ($giftId == 0) {
                         continue;
-                    }     
+                    }
                     //已经触发过了但是礼包还没有被领取
-                    if(count(req()->userInfo->game->store->triggerLimitTsGift) != 0){
+                    if (count(req()->userInfo->game->store->triggerLimitTsGift) != 0) {
                         foreach (req()->userInfo->game->store->triggerLimitTsGift as $val) {
-                            if($val->giftId == $giftId){
+                            if ($val->giftId == $giftId) {
                                 continue;
                             }
-                        } 
+                        }
                     }
-                    
+
                     //触发对应的礼包条件。则将礼包id存储在
                     $gift = new Ins_Gift();
                     $gift->giftId = $giftId;
@@ -68,45 +68,46 @@ class ShopProc {
                     $gift->endTs = now() + GameConfig::shop_limit_getItem($giftId)->limit_ts;
                     req()->userInfo->game->store->triggerLimitTsGift[] = $gift;
                 }
-            }                                        
+            }
         }
     }
-    
+
     public static function GetRechargeRebate() {
         return Resp::ok(array(
                     "shopdata" => req()->userInfo->game->shopdata
         ));
     }
-    
+
     //
     public static function GetDaliySpecial() {
         return Resp::ok(array(
                     "shopdata" => req()->userInfo->game->shopdata
         ));
     }
-    
+
     /*
      * 重置每日特惠信息
      */
-    static function resetDaliySpecialPackages() {             
-        if(req()->userInfo->game->shopdata->daliySpecialClear_ts == 0){
+
+    static function resetDaliySpecialPackages() {
+        if (req()->userInfo->game->shopdata->daliySpecialClear_ts == 0) {
             req()->userInfo->game->shopdata->daliySpecialClear_ts = now();
         }
-        $curDay = TimeUtil::tsDay();
-        $lastDay = TimeUtil::tsDay(req()->userInfo->game->shopdata->daliySpecialClear_ts);
-               
-        if($curDay-$lastDay ==1 && TimeUtil::tsHour(req()->userInfo->game->shopdata->daliySpecialClear_ts) < 5 && TimeUtil::tsHour(now()) > 5){              
+        $curDay = TimeUtil::totalDays();
+        $lastDay = TimeUtil::totalDays(req()->userInfo->game->shopdata->daliySpecialClear_ts);
+
+        if ($curDay - $lastDay == 1 && TimeUtil::Hour(req()->userInfo->game->shopdata->daliySpecialClear_ts) < 5 && TimeUtil::Hour(now()) > 5) {
             req()->userInfo->game->shopdata->daliySpecialClear_ts = now();
-            req()->userInfo->game->shopdata->daliySpecialPackages = array();                
-        } else if($curDay-$lastDay >1){
+            req()->userInfo->game->shopdata->daliySpecialPackages = array();
+        } else if ($curDay - $lastDay > 1) {
             req()->userInfo->game->shopdata->daliySpecialClear_ts = now();
-            req()->userInfo->game->shopdata->daliySpecialPackages = array(); 
+            req()->userInfo->game->shopdata->daliySpecialPackages = array();
         }
-        
-        if(TimeUtil::tsDay(req()->userInfo->game->shopdata->daliySpecialClear_ts) == TimeUtil::tsDay() #
-                && TimeUtil::tsHour(req()->userInfo->game->shopdata->daliySpecialClear_ts) < 5 && TimeUtil::tsHour(now()) > 5){
+
+        if (TimeUtil::totalDays(req()->userInfo->game->shopdata->daliySpecialClear_ts) == TimeUtil::totalDays() #
+                && TimeUtil::Hour(req()->userInfo->game->shopdata->daliySpecialClear_ts) < 5 && TimeUtil::Hour(now()) > 5) {
             req()->userInfo->game->shopdata->daliySpecialClear_ts = now();
-            req()->userInfo->game->shopdata->daliySpecialPackages = array(); 
+            req()->userInfo->game->shopdata->daliySpecialPackages = array();
         }
     }
 
@@ -137,13 +138,13 @@ class ShopProc {
         $err = StoreProc::AddMultiItemInStore($packageCfg->pri_reward);         # 发放一次性奖励
         my_Assert(ErrCode::ok == $err, $err);
         if ($packageCfg->subType == 4) {
-            $shopdata->monthlyVIP1_ts = 3600 * 24 * (tsDay() + 1) - 1;           
+            $shopdata->monthlyVIP1_ts = 3600 * 24 * (totalDays() + 1) - 1;
         } elseif ($packageCfg->subType == 5) {
-            $shopdata->monthlyVIP2_ts = 3600 * 24 * (tsDay() + 1) - 1;
+            $shopdata->monthlyVIP2_ts = 3600 * 24 * (totalDays() + 1) - 1;
         }
-        
+
         EmailProc::SendMonthlyVIPDailyReward(req()->zoneid, req()->uid, $packageCfg->name, $packageCfg->daily_reward);
-        
+
         req()->userInfo->game->shopdata = $shopdata;                             # 回写数据
         UserProc::updateUserInfo();
         $user = req()->userInfo->game;
@@ -159,7 +160,7 @@ class ShopProc {
     }
 
     /**
-     * 【7101】限购礼包主界面 
+     * 【7101】限购礼包主界面
      */
     public static function GetLimitMainInfo() {
         return Resp::ok(array(
@@ -168,7 +169,7 @@ class ShopProc {
     }
 
     /**
-     * 【7102】 购买限购礼包 
+     * 【7102】 购买限购礼包
      */
     public static function BuyLimitPackage() {
         $packageId = req()->paras[0];                                            # 参数; 礼包id
@@ -217,7 +218,7 @@ class ShopProc {
     }
 
     /**
-     * 每日检查 
+     * 每日检查
      */
     static function DailyCheck() {
         CLog::info("shop-每日检查-清除每日/周限量礼包购买记录");

+ 7 - 7
Gameserver/Amfphp/process/UserProc.php

@@ -225,10 +225,10 @@ class UserProc {
 
         $NewbieGuide->guideStep = $guideIndex;
         $user->NewbieGuide = $NewbieGuide;
-        if($NewbieGuide->guideStep == 2){
+        if ($NewbieGuide->guideStep == 2) {
             StatisticsProc::TargetStatistics(Enum_TargetStatistics::comNewGuide_UserNum);
         }
-        
+
         req()->userInfo->game = $user;
         UserProc::updateUserInfo();                                             # 回写数据
         return Resp::ok(array(
@@ -251,9 +251,9 @@ class UserProc {
         if (self::checkRoleNameNotExist($rolename)) {                           # 记录玩家
             $userinfo = self::createUser($rolename, $gender, $profile_img);
             if (1 == self::regRole(req()->zoneid, $userID, $rolename, $gender, $profile_img, $userinfo->getPlatStr())) {
-                StatisticsProc::TargetStatistics(Enum_TargetStatistics::registerUserNum);//注册人数统计
+                StatisticsProc::TargetStatistics(Enum_TargetStatistics::registerUserNum); //注册人数统计
                 StatisticsProc::dailyTaskInit();
-                               
+
                 $resp = Resp::ok($userinfo);
                 self::updtateUserZoneInfo();
             } else {
@@ -433,7 +433,7 @@ class UserProc {
      * 检测连续登录状态,重置必要字段[时间戳自动记录]
      */
     static function checkContidays($isnew = 0) {
-        $ret = TimeUtil::tsDay() - TimeUtil::tsDay(req()->userInfo->game->baseInfo->lastLogin); // 对比登录日期
+        $ret = TimeUtil::totalDays() - TimeUtil::totalDays(req()->userInfo->game->baseInfo->lastLogin); // 对比登录日期
         if ($ret > 0 || $isnew) {                                               # 当天第一次登录
             self::OnNewDay($isnew);
         } else {                                                                # 更新下登录次数记录(任务计数器)
@@ -498,7 +498,7 @@ class UserProc {
         $zoneid = req()->zoneid;
         $uid = req()->uid;
         $user = req()->userInfo->game->baseInfo;
-        $day = tsDay();
+        $day = totalDays();
         $level = $user->level;
         $platUser = ObjectInit();
         $platUser->uid = $uid;                                                  #
@@ -617,7 +617,7 @@ class UserProc {
      *           version 1.0.0 Mysql storagef 1. 分表不做了, 2. 存储过程不用了 3. 先能用再说
      */
     public static function backupUserInfo() {
-        $tsday = TimeUtil::tsDay();                                             # 精确到天,保留10个最近记录.
+        $tsday = TimeUtil::totalDays();                                             # 精确到天,保留10个最近记录.
         $value = base64_encode(gzdeflate(JsonUtil::encode(req()->userInfo)));    # blob数据,序列化下
         $sql = sprintf("call insertUserInfo('%s', %d, %d, '%s');", #            # 所以直接将序列化后的结果存进去吧,
                 req()->uid, req()->zoneid, $tsday, $value);                       # zoneid, uid, tsday

+ 64 - 1
Gameserver/Amfphp/service_call/pay/Mo/payRequest.php

@@ -43,6 +43,12 @@ class PayRequest extends loyalsoft\Object_ext {
     public $product_price;
     public $product_count;
 
+    /**
+     * @var 防沉迷年龄段 ( -1 未实名, 0(0~7) 8(8~16) 16(16~18) 18(18+成年)
+     * #[optional]
+     */
+    public $ageRange;
+
     /**
      * @var string 公会id
      */
@@ -168,7 +174,7 @@ class PayRequest extends loyalsoft\Object_ext {
         $this->callbackInfo .= "," . $this->cpOrderId;                                                       # 将cpOrderId追加到透传参数中
         $this->notifyUrl = self::get_notify_url();                                                           # 自动提取支付回调地址
     }
- 
+
     /**
      * PS. 仅限pay.php作为入口使用才行
      * @return string 获取支付回调地址,
@@ -179,4 +185,61 @@ class PayRequest extends loyalsoft\Object_ext {
         return $nurl;                                                           # 回调地址
     }
 
+    public function AntiAdditionCheck() {
+        $uid = $this->accountId;
+        $ageRange = $this->ageRange;
+        $amt = $this->amount;
+        if (isset($uid) && isset($ageRange)) {
+            $monthTS = loyalsoft\TimeUtil::tsMonthBegin();                      # 本月初起始时间戳
+            $dayTS = loyalsoft\TimeUtil::tsDayBegin();                          # 当天起始时间戳
+            $monthTotal = loyalsoft\daoInst()
+                    ->select("sum(`amount`)/100 as total")                      # 总金额(单位:分转元)
+                    ->from("tpl_order_tab")
+                    ->where("uid")->eq($uid)                                    # 该玩家
+                    ->andWhere("status")->eq(1)                                 # 成交订单
+                    ->andWhere("order_ts")->ge($monthTS)                        # 本月
+                    ->fetch('total');
+            if (!is_numeric($monthTotal)) {
+                $monthTotal = 0;
+            }
+            $dayTotal = loyalsoft\daoInst()
+                    ->select("sum(`amount`)/100 as total")                      # 总金额(单位:分转元)
+                    ->from("tpl_order_tab")
+                    ->where("uid")->eq($uid)                                    # 该玩家
+                    ->andWhere("status")->eq(1)                                 # 成交订单
+                    ->andWhere("order_ts")->ge($dayTS)                          # 今日
+                    ->fetch('total');
+            if (!is_numeric($dayTotal)) {
+                $dayTotal = 0;
+            }
+            if ($ageRange < 0 || !is_numeric($ageRange)) {
+                return \Resp::err(1, "未完成实名认证的用户暂不提供充值.");
+            } else if ($ageRange < 8) {
+                return \Resp::err(1, "未慢8周岁的用户暂不提供充值.");
+            } else if ($ageRange < 16) {                                        # 单笔/每月: 50,200
+                if ($amt > 50) {
+                    return \Resp::err(1, "单笔充值金额不高于50¥");
+                }
+//            if (($amt + $dayTotal) > 100) {
+//                return \Resp::err(1, "单日累计充值金额不高于100¥");
+//            }
+                if (($amt + $monthTotal) > 200) {
+                    return \Resp::err(1, "当月累计充值金额不高于200¥");
+                }
+            } else if ($ageRange < 18) {                                        # 单笔/每月: 100,400
+                if ($amt > 100) {
+                    return \Resp::err(1, "单笔充值金额不高于100¥");
+                }
+//            if (($amt + $dayTotal) > 100) {
+//                return \Resp::err(1, "单日累计充值金额不高于100¥");
+//            }
+                if (($amt + $monthTotal) > 400) {
+                    return \Resp::err(1, "当月累计充值金额不高于400¥");
+                }
+            }
+            return \Resp::ok("ok");
+        }
+        return \Resp::err(-1, "参数不足");                                       # 其他情况
+    }
+
 }

+ 26 - 23
Gameserver/Amfphp/service_call/pay/official/alipay/pay.php

@@ -5,25 +5,28 @@
  *    因为签名秘钥不适合放在客户端. (wg)
  *
  */
-require_once __DIR__ . '/../../../../main.php';            # 导入游戏库
-require_once __DIR__ . '/../../Mo/resp.php';               # 响应模型
+require_once __DIR__ . '/../../../../main.php';                                 # 导入游戏库
+require_once __DIR__ . '/../../Mo/resp.php';                                    # 响应模型
 require_once __DIR__ . '/../../Mo/payRequest.php';
-require_once __DIR__ . '/AopSdk.php';                      # 导入alipay库
-require_once __DIR__ . '/config_alipay.php';               # 导入配置文件
+require_once __DIR__ . '/AopSdk.php';                                           # 导入alipay库
+require_once __DIR__ . '/config_alipay.php';                                    # 导入配置文件
 
-use loyalsoft\CLog;                                        # 添加 use
+use loyalsoft\CLog;                                                             # 添加 use
 use loyalsoft\JsonUtil;
 use loyalsoft\HttpUtil;
 
-HttpUtil::PostOnly();                                       # 限定客户端用post
-$str = HttpUtil::getQueryString();                          # 提取参数串
-// $str=gzinflate($str);                                     # 编码方案
+HttpUtil::PostOnly();                                                           # 限定客户端用post
+$str = HttpUtil::getQueryString();                                              # 提取参数串
+// $str=gzinflate($str);                                                        # 编码方案
 $data = JsonUtil::decode($str);
-$req = new PayRequest($data);                               # 创建订单
+$req = new PayRequest($data);                                                   # 创建订单
+$resp = $req->AntiAdditionCheck();                                              # 防沉迷金额校验
+if ($resp->err != 0) {
+    exit($resp);                                                                # 返回
+}
 $cfg = loyalsoft\config_alipay::Inst();
-//$req->notifyUrl = $cfg->notify_Url;                         # 给客户端传递回调URL.
-$req->InserDataBase();                                      # 将订单插入数据库
-CLog::pay('[alipay.pay]创建订单' . $req);          # 日志
+$req->InserDataBase();                                                          # 将订单插入数据库
+CLog::pay('[alipay.pay]创建订单' . $req);                                        # 日志
 // SDK已经封装掉了公共参数,这里只需要传入业务参数: https://docs.open.alipay.com/204/105465/
 $bizcontent = "{\"body\":\"" . $req->product_name . "\","
         . "\"subject\": \"龙游科技\","
@@ -34,9 +37,9 @@ $bizcontent = "{\"body\":\"" . $req->product_name . "\","
         . "\"passback_params\":\"" . $req->callbackInfo . "\""                  # 透传参数
         . "}";
 
-$aop = new AopClient();                                     # 客户端
-$aop->appId = $cfg->appId;                                  # "app_id";
-$aop->gatewayUrl = $cfg->gatewayUrl;                        # 支付宝网关
+$aop = new AopClient();                                                         # 客户端
+$aop->appId = $cfg->appId;                                                      # "app_id";
+$aop->gatewayUrl = $cfg->gatewayUrl;                                            # 支付宝网关
 $aop->alipayrsaPublicKey = $cfg->alipayrsaPublicKey;
 $aop->rsaPrivateKey = $cfg->rsaPrivateKey;
 $aop->format = "json";
@@ -44,15 +47,15 @@ $aop->charset = "UTF-8";
 $aop->signType = "RSA2";
 
 //实例化具体API对应的request类,类名称和接口名称对应,
-$request = new AlipayTradeAppPayRequest();                  # 当前调用接口名称:alipay.trade.app.pay
+$request = new AlipayTradeAppPayRequest();                                      # 当前调用接口名称:alipay.trade.app.pay
 $request->setNotifyUrl($req->notifyUrl);
 $request->setBizContent($bizcontent);
-$response = $aop->sdkExecute($request);                     # 这里和普通的接口调用不同,使用的是sdkExecute
+$response = $aop->sdkExecute($request);                                         # 这里和普通的接口调用不同,使用的是sdkExecute
 
-$ret = array(#                                              # 返回值
-    'err' => 0, #                                           # 错误码
-    'platformCode' => 'zfb', #                              # 平台
-    'cpOrderId' => $req->cpOrderId, #                       # 渠道订单号
-    'platformInfo' => base64_encode($response)              # token串
+$ret = array(#                                                                  # 返回值
+    'err' => 0, #                                                               # 错误码
+    'platformCode' => 'zfb', #                                                  # 平台
+    'cpOrderId' => $req->cpOrderId, #                                           # 渠道订单号
+    'platformInfo' => base64_encode($response)                                  # token串
 );
-echo json_encode($ret);                                     # 返回客户端
+echo json_encode($ret);                                                         # 返回客户端

+ 10 - 7
Gameserver/Amfphp/service_call/pay/official/wxpay/pay.php

@@ -8,7 +8,6 @@ require_once __DIR__ . '/../../../../main.php';
 require_once __DIR__ . '/../../Mo/resp.php';                                    # 响应模型
 require_once __DIR__ . '/../../Mo/payRequest.php';                              # 通用请求订单结构
 require_once __DIR__ . '/wx.php';                                               # 导入微信支付lib
-//require_once __DIR__ . '/config_alipay.php';                                    # 导入配置文件
 
 use loyalsoft\CLog;                                                             # 添加 use
 use loyalsoft\JsonUtil;
@@ -20,18 +19,22 @@ $str = HttpUtil::getQueryString();
 // $str=gzinflate($str);                                                         # 编码方案
 $data = JsonUtil::decode($str);                                                 # 提取数据
 $req = new PayRequest($data);                                                   # 创建订单
+$resp = $req->AntiAdditionCheck();                                              # 防沉迷金额校验
+if ($resp->err != 0) {
+    exit($resp);                                                                # 返回
+}
 if ($req->InserDataBase()) {                                                    # 订单数据入库
     CLog::pay($tag . ' 创建订单' . $req);
     $input = new WxPayUnifiedOrder();                                           # 微信下单参数
-    $input->SetBody($req->product_name);                                        # 商品描述,格式: 应用名称-商品WxPayConfig::APPID . "-" . 
+    $input->SetBody($req->product_name);                                        # 商品描述,格式: 应用名称-商品WxPayConfig::APPID . "-" .
     $input->SetAttach($req->callbackInfo);                                      # 透传参数
     $input->SetOut_trade_no($req->cpOrderId);                                   # cporderidd
-    $input->SetTotal_fee($req->amount);//*100                                     # 总价格,单位:分
-    $input->SetTime_start(date("YmdHis"));                                      # 开始时间  
+    $input->SetTotal_fee($req->amount); //*100                                     # 总价格,单位:分
+    $input->SetTime_start(date("YmdHis"));                                      # 开始时间
     $input->SetTime_expire(date("YmdHis", time() + 600));                       # 过期时间
     $input->SetGoods_tag("test");                                               # 活动标记,不管
     $input->SetNotify_url($req->notifyUrl);                                     # 支付回调地址
-    $input->SetTrade_type("APP");                                               # 交易类型, 
+    $input->SetTrade_type("APP");                                               # 交易类型,
 //    $input->SetTrade_type("JSAPI");
 //    $input->SetOpenid($openId);                                                 # jsapi需要,其他非必需
     CLog::pay("[weixin]统一下单");
@@ -42,12 +45,12 @@ if ($req->InserDataBase()) {
             $platPayParams = array(#                                            # 客户端需要的参数
                 'appid' => WxPayConfig::APPID, #                                # 微信开平分配的appid
                 'partnerid' => WxPayConfig::MCHID, #                            # 微信支付平台分配的商户id
-                'prepayid' => $order["prepay_id"], #                             # 预支付交易会话id (微信返回的支付交易会话ID) 
+                'prepayid' => $order["prepay_id"], #                             # 预支付交易会话id (微信返回的支付交易会话ID)
                 'package' => 'Sign=WXPay', #                                    # 扩展字段, 固定值Sign=WXPay
                 'noncestr' => WxPayApi::getNonceStr(), #                        # 随机字符串
                 'timestamp' => \loyalsoft\now(), #                              # 时间戳
             );
-            $_sign = WxPayConfig::MakeSign($platPayParams);                     # 计算下签名 
+            $_sign = WxPayConfig::MakeSign($platPayParams);                     # 计算下签名
             $platPayParams["sign"] = $_sign;                                    # 附加签名
             $platPayParams['extData'] = $req->callbackInfo;                     # 透传参数
             $ret = array(#                                                      # 返回值

+ 1 - 1
Gameserver/Amfphp/test.php

@@ -5,7 +5,7 @@ namespace loyalsoft;
 include __DIR__ . '/main.php';
 var_dump(__DIR__);
 echoLine("phpver: " . PHP_VERSION . PHP_EOL);
-echoLine("tsDay:" . tsDay());
+echoLine("tsDay:" . totalDays());
 //SelfChecker::CheckAll();
 //
 //set_time_limit(15);                                                           # 设置执行超时时间

+ 112 - 15
Gameserver/Amfphp/util/TimeUtil.php

@@ -26,13 +26,83 @@ class TimeUtil {
         return 1999999999;
     }
 
+    /**
+     * 计算某时刻所在日的开始时间戳
+     * @param type $time
+     * @return type
+     */
+    public static function tsDayBegin($time = -1) {
+        if ($time < 0) {
+            $time = TimeUtil::tsCurrent();
+        }
+        $year = date("Y", $time);
+        $month = date("m", $time);
+        $day = date("d", $time);
+        return mktime(0, 0, 0, $month, $day, $year);                            # 创建当日开始时间戳
+    }
+
+    /**
+     * 计算某时刻所在日的最后一秒时间戳
+     * @param type $time
+     * @return type
+     */
+    public static function tsDayEnd($time = -1) {
+        if ($time < 0) {
+            $time = TimeUtil::tsCurrent();
+        }
+        $year = date("Y", $time);
+        $month = date("m", $time);
+        $day = date("d", $time);
+        return mktime(23, 59, 59, $month, $day, $year);                         # 创建当日最后一秒时间戳
+    }
+
+    /**
+     * 计算某时刻所在月份的开始时间戳
+     * @param type $time
+     * @return type
+     */
+    public static function tsMonthBegin($time = -1) {
+        if ($time < 0) {
+            $time = TimeUtil::tsCurrent();
+        }
+        $year = date("Y", $time);
+        $month = date("m", $time);
+        return mktime(0, 0, 0, $month, 1, $year);                               # 创建当月开始时间戳
+    }
+
+    /**
+     * 计算某时刻所在月份的最后一秒时间戳
+     * @param type $time
+     * @return type
+     */
+    public static function tsMonthEnd($time = -1) {
+        if ($time < 0) {
+            $time = TimeUtil::tsCurrent();
+        }
+        $year = date("Y", $time);
+        $month = date("m", $time);
+        $t = date('t');                                                         # 该月一共有几天
+        return mktime(23, 59, 59, $month, $t, $year);                           # 创建当月最后一秒的时间戳
+    }
+
+// <editor-fold defaultstate="collapsed" desc="累计天数/周数">
+
+    /**
+     *  返回自从 Unix 纪元(格林威治时间 1970 年 1 月 1 日 00:00:00)到当前时间的周数。
+     * @param int $time ts时间戳
+     * @return number
+     */
+    public static function totalWeeks($time = -1) {
+        return CommUtil::floatToInt((TimeUtil::totalDays($time) + 3) / 7);
+    }
+
     /**
      *  返回自从 Unix 纪元(格林威治时间 1970 年 1 月 1 日 00:00:00)到当前时间的天数。
      * 检测玩家连续登录及隔天刷新操作用
      * @param type $time 当前时间戳
      * @return type
      */
-    public static function tsDay($time = -1) {
+    public static function totalDays($time = -1) {
         if ($time < 0) {
             $time = TimeUtil::tsCurrent();
         }
@@ -40,14 +110,21 @@ class TimeUtil {
     }
 
     /**
-     *  返回自从 Unix 纪元(格林威治时间 1970 年 1 月 1 日 00:00:00)到当前时间的周数。
-     * @param int $time ts时间戳
-     * @return number
+     *  返回自从 Unix 纪元(格林威治时间 1970 年 1 月 1 日 00:00:00)到当前时间的天数。
+     * 检测玩家连续登录及隔天刷新操作用
+     * @deprecated since version 请使用变更后的名称 totalDays()
+     * @param type $time 当前时间戳
+     * @return type
      */
-    public static function tsWeek($time = -1) {
-        return CommUtil::floatToInt((TimeUtil::tsDay($time) + 3) / 7);
+    public static function tsDay($time = -1) {
+        if ($time < 0) {
+            $time = TimeUtil::tsCurrent();
+        }
+        return CommUtil::floatToInt(($time + 28800) / 86400);                   # 东八区前提8小时时差
     }
 
+// </editor-fold>
+
     /**
      * 返回年月日时分秒(例:20161028101530)这样的时间戳
      * @return number
@@ -56,6 +133,17 @@ class TimeUtil {
         return date($fmt);
     }
 
+//
+// <editor-fold defaultstate="collapsed" desc="快速获得日期字符串">
+
+    /**
+     * 返回年月日时分秒(例:20161028101530)这样的时间格式
+     * @return number
+     */
+    public static function dtYmdHis($fmt = "YmdHis") {
+        return date($fmt);
+    }
+
     /**
      * 获取当前的日期时间(例: 2016-06-16 18:08:18 )字符串
      * date('Y-m-d H:i:s')
@@ -145,6 +233,9 @@ class TimeUtil {
         return date($format, strtotime("-90 day"));
     }
 
+// </editor-fold>
+//
+
     /**
      * 返回自从 Unix 纪元(格林威治时间 1970 年 1 月 1 日 00:00:00)到当前时间的微秒数。
      * @return float 注意这个值的精度, 需要使用高精度数据类型保存和使用
@@ -162,18 +253,14 @@ class TimeUtil {
     }
 
     /**
-     * 当前小时数
+     * 计算指定时刻(默认当前)的小时数字
+     * @param type $ts 时间戳, 默认-1,采用当前时间
      * @param string $fmt 默认'H'(24小时制),可以输入'h'
      * @return type
      */
-    public static function Hour($fmt = 'H') {
+    public static function Hour($ts = -1, $fmt = 'H') {
         my_Assert(strtolower($fmt) == 'h', '获取Hour的参数只接受: H/h');
-        return date($fmt);
-    }
-    
-    public static function tsHour($ts,$fmt = 'H') {
-        my_Assert(strtolower($fmt) == 'h', '获取Hour的参数只接受: H/h');
-        return date($fmt,$ts);
+        return date($fmt, $ts);
     }
 
 }
@@ -190,10 +277,20 @@ function now($offset = 0) {
 /**
  * 天(自1970年7月1号以来)的整数
  * @param int $time Unix Timestamp
+ * @deprecated since version 建议使用变更后的名称 totalDays()
  * @return int
  */
 function tsDay($time = -1) {
-    return TimeUtil::tsDay($time);
+    return TimeUtil::totalDays($time);
+}
+
+/**
+ * 天(自1970年7月1号以来)的整数
+ * @param int $time Unix Timestamp 指定时刻的时间戳
+ * @return int
+ */
+function totalDays($time = -1) {
+    return TimeUtil::totalDays($time);
 }
 
 /**

+ 1 - 1
Gameserver/Amfphp/util/dao.php

@@ -586,7 +586,7 @@ class dao {
         try {
             $method = $this->method;
             $this->reset();
-//            var_dump($sql);
+            var_dump($sql);
             if ($this->slaveDBH and $method == 'select') {
                 return $this->slaveDBH->query($sql);
             } else {