Bläddra i källkod

代码整理, fixed: 关卡掉落首次奖励与常规奖励互相切换

gwang 5 år sedan
förälder
incheckning
7e9cbefff1

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

@@ -24,9 +24,9 @@ class AppServer {
         $err = PreProc::tk($req);                                               # 预处理
         if ($err) {                                                             # 如果tk校验未通过
             Err($err);
-        } else {
-            $resp = self::Route($req);                                              # 分发逻辑
         }
+        $resp = self::Route($req);                                              # 分发逻辑
+
         self::AfterProc($req, $resp);                                           # 执行后处理逻辑
         $req->mem->close();                                                     # 销毁已申请的资源
         return $resp;

+ 3 - 81
Gameserver/Amfphp/Services/TestServer.php

@@ -60,38 +60,6 @@ class TestServer {
         }
     }
 
-// rsa加密传输
-    public static function testMyRsaCommunication() {
-        require_once 'OpenSSLVerify.php';                                       # Ps. 这个文件和类名没有对应关系.
-        MyRsa::Test();
-        echo '<br/>';
-        MyRsa::testSign();
-        echo '<br/>';
-        echo true;
-    }
-
-    public static function testPayDb() {
-        global $zoneid;
-        $zoneid = 1;
-
-        $db = CPayInit();
-        $SQL = "INSERT IGNORE INTO `tab_rankuserlog_1` (`id`, `cash`, `oid`, `info`, `insertDatetime`, `lastUpdatetime`) VALUES (NULL, '1', '2', '3', CURRENT_TIMESTAMP, '2015-11-24 00:00:00');";
-        $arr = $db->query($SQL);
-        DebugHelper::var_dump("TestDb:" . $arr);
-        $db->close();
-    }
-
-    public function testBase32($code) {
-//        $code = "r4fismgn";
-        DebugHelper::debug("code: $code <br/>");
-        DebugHelper::debug("解码: <br>");
-
-        $decode = CipheredBase32::Decode($code);
-
-        DebugHelper:: var_dump($decode);
-        DebugHelper::debug("plat:" . GameConstants::GetPlatStringByActivteCode($decode));
-    }
-
     public function testMemDelete($key) {
         $mem = gMem();
         $res = $mem->delete($key);
@@ -104,35 +72,17 @@ class TestServer {
         return $res;
     }
 
-    public function testVerifySign() {
-        $data = 'wanggang';
-        $sign = 'KGNg2I7kis9vz1p2uzZZ1igj6fVERxvGrQK4zJPGPiEIjdzyZ3bogxG2kMwDn1zjQBlqGqzjcwKhCWf6JVoDT2WPnxYd9O4qF+kaIaMpOq4ZNy+dQL+FnsCRMhl+EV7ejK9RUgw7AkLSqIm3gRdMEiZnHjHk6C2JtHUgLZJ+nyY = ';
-        $keypath = ROOTDIR . "/Util/key";                                       // 验证并查找回归密码记录
-        $myrsa = new MyRsa($keypath);
-        if ($myrsa->verify($data, $sign)) {                                     // 验证下签名
-            echo "签名验证成功!";
-        } else {
-            echo '验签失败';
-        }
-    }
-
     public function testMemGet($key) {
         $mem = gMem();
         $res = $mem->get($key);
         return $res;
     }
 
-// 微秒
-    public static function microtime_float() {
-        echoLine(microsecond());
-    }
-
     public static function dtCurrent() {
-        echoLine(TimeUtil::tsWeek());
         $timezone = date_default_timezone_get();
-        echoLine($timezone);
-        echoLine(date('Y-m-d H:i:s'));
-        return date('Y-m-d ') . (date('H') + 8) . date(':i:s');
+        echoLine($timezone . " " . date('Y-m-d H:i:s'));
+        echoLine("tsweek: " . TimeUtil::tsWeek());
+        echoLine("tsday: " . TimeUtil::tsDay());
     }
 
 //----------------------------------------------------
@@ -201,34 +151,6 @@ SCR;
         echo($index);
     }
 
-    public function testArrayInsert() {
-        $array = array(1, 2, 3, 4, 11, 12, 124, 1245);
-        StlUtil::arrayInsert($array, 0, 0);
-        DebugHelper::debug($array);
-    }
-
-    public function testArrayFunc() {
-        $array = ArrayInit();
-        $array[] = 1;
-        $array[] = 1;
-        $array[] = 6;
-        $array[] = 1;
-        $index = StlUtil::arrayIndexOf($array, 6);
-        DebugHelper::debug($index);
-    }
-
-    public function testMD5() {
-        $v3 = CV3Init();
-        $paras = array();
-        $paras["openid"] = "382E5D8EDB8E6BAE17B9EE44E532631F";
-        $paras["ep"] = HttpUtil::getClientEP();
-        $paras["ts"] = now();
-        $self_url_path = "atomsoft.com";
-        $sig = $v3->cee_self_sig($paras, $self_url_path);
-        $v3->close();
-        DebugHelper::debug($sig);
-    }
-
     public function tsetIp() {
         DebugHelper::debug(HttpUtil::getClientEP());
     }

+ 1 - 11
Gameserver/Amfphp/main.php

@@ -89,17 +89,6 @@ function req() {
     return Req::Ins();
 }
 
-/**
- * 初始化CV3工具, 主要用于腾讯专有支付平台, 比如QQ空间和应用宝.
- * 需要调用Close方法
- * @return \CV3Util
- */
-function CV3Init() {
-    $cv3 = new CV3Util();
-    $cv3->v3conn(V3_HOST, V3_APPID, V3_APPKEY);
-    return $cv3;
-}
-
 /**
  * 对象初始化
  * @return type
@@ -131,6 +120,7 @@ function default_timezone() {
 }
 
 default_timezone();                                                             # 全局范围内启用默认时区 中国时区
+
 $zoneid = "1";                                                                  # 定义全局变量zoneid
 
 /**

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

@@ -49,7 +49,7 @@ class ActiveProc {
             case CmdCode::active_token_drawReward:                              # 6512 兑换码礼包
                 return self::drawActivePackageByCode($req);
             case CmdCode::active_draw_onlinegift:                               # 6513 领取在线礼包
-                return self::drawOnlineGift($req);
+                return self::drawOnlineGift();
             case CmdCode::active_draw_reggift:                                  # 6514 领取全服注册礼包
                 return self::drawRegGift($req);
             case CmdCode::active_presentTili:                                   # 6515 领取在线赠送体力
@@ -148,10 +148,10 @@ class ActiveProc {
 
     /**
      * 6513 领取连续在线礼包
-     * @param Req $req
      * @return type
      */
-    static function drawOnlineGift($req) {
+    static function drawOnlineGift() {
+        $req = req();
         $user = $req->userInfo->game;
         $privateState = new PrivateStateModel($user->privateState);
         $giftid = $req->paras[0];                                               # 提取参数: 礼包的编号

+ 0 - 32
Gameserver/Amfphp/process/ConstProc.php

@@ -1,32 +0,0 @@
-<?php
-
-namespace loyalsoft;
-
-/**
- * Description of ConstProc
- * 常量数据处理流程
- * 负责向客户端提供基本的数据配置信息
- * 及服务端常量数据检索
- * @author gwang
- */
-class ConstProc {
-
-    /**
-     * 逻辑分发
-     * 所有的Proc中必须有这样一个方法
-     * @param type $req
-     */
-    public static function procMain($req) {
-        return Resp::err(ErrCode::err_method_notimplement);
-    }
-
-    /**
-     * 获取物品常量
-     * @param string $itemID
-     * @return GoodsItemModel
-     */
-    static public function getGoodsItemConst($itemID) {
-        return GameConfig::item_getItem($itemID);
-    }
-
-}

+ 15 - 17
Gameserver/Amfphp/process/FightProc/SweepGatesProc.php

@@ -196,11 +196,8 @@ class SweepGatesProc {
         list($gateId, $difficulty, $star, $TeamObj) = $req->paras;              # 提取参数: 挑战的关卡Id, 关卡难度(0,1,2), 几星, 队伍
         Resp::assert($gateId > 0, "关卡id非法");
         $isFirst = false;                                                       # 是否首次通关
-
-        $err = self::recordFight($req, $gateId, $difficulty, $star, $isFirst);  # 挑战记录
-        if (ErrCode::ok != $err) {
-            return Resp::err($err);
-        }
+        self::recordFight($req, $gateId, $difficulty, $star, $isFirst);         # 更新挑战记录
+//        CLog::err($isFirst);
         $smGate = GameConfig::gate_getItem($gateId);                            # 关卡配置数据
         $i = $difficulty + 1;                                                   # 按三个难度取不同的值.
 //        $tili = self::getProperty_n($smGate, "tili", $i);                     # 体力暂时未用上
@@ -208,8 +205,12 @@ class SweepGatesProc {
         $firstPassRewardStr = self::getProperty_n($smGate, 'first_reward', $i);
         $gold = self::getProperty_n($smGate, "gold", $i);
         $exp = self::getProperty_n($smGate, "exp", $i);
+        $firstExp = self::getProperty_n($smGate, "first_exp", $i);
         $heroExp = self::getProperty_n($smGate, "heroExp", $i);
-
+        if ($isFirst) {                                                         # 是否首次通关切换奖励内容
+            $exp = $firstExp;
+            $rwdstr = $firstPassRewardStr;
+        }
 //        ActiveProc::ChangeTili(-$tili, $req);                                   # 扣减体力变化 
 //        UserGameModel::Add_Exp($req->mem, $req->userInfo->game, $tili);         # 老的增加玩家经验的去掉
 //        
@@ -217,11 +218,9 @@ class SweepGatesProc {
             HeroProc::HeroAddEXP($heroUID, $heroExp, $req);                     # 增加英雄经验 
         }
 
+
         $rewardArr = array();                                                   # 统计所获奖励物品
         $rewardArr = array_merge($rewardArr, self::SetRewards($req, $rwdstr));  # 通关奖励
-        if ($isFirst) {                                                         # 首次通关奖励
-            $rewardArr = array_merge($rewardArr, self::SetRewards($req, $firstPassRewardStr));
-        }
 
         UserGameModel::Add_Gold($req->mem, $req->userInfo->game, $gold);        # 发金币
         UserGameModel::Add_Exp($req, $exp);                                     # 给玩家(指挥官)增加经验
@@ -247,7 +246,7 @@ class SweepGatesProc {
      * @param type $rewardStr
      */
     public static function SetRewards($req, $rewardStr) {
-        $getedArr = array();                                                   # 统计所获奖励物品
+        $getedArr = array();                                                    # 统计所获奖励物品
         $rewardsArr = explode(";", $rewardStr);
         foreach ($rewardsArr as $r) {                                           #   
             if (strlen($r) <= 0) {                                              # 奖励串为空
@@ -260,7 +259,7 @@ class SweepGatesProc {
                 if ($err != ErrCode::ok) {                                      # 出错了
                     Err($err);
                 }
-                $getedArr[] = substr($r, 0, strrpos($r, ','));                 # 剔除最后一段概率字符串
+                $getedArr[] = substr($r, 0, strrpos($r, ','));                  # 剔除最后一段概率字符串
             }
         }
         return $getedArr;
@@ -273,7 +272,7 @@ class SweepGatesProc {
      * @param type $difficulty
      * @param type $star
      */
-    private static function recordFight($req, $gateId, $difficulty, $star, $isFirst = false) {
+    private static function recordFight($req, $gateId, $difficulty, $star, &$isFirst = false) {
         $userGates = $req->userInfo->game->gates;
         if ($difficulty == 0) {                                                 # 按照难度查找
             $diffCult = $userGates->normal;
@@ -282,7 +281,7 @@ class SweepGatesProc {
         } else if ($difficulty == 2) {
             $diffCult = $userGates->elite;
         } else {
-            return ErrCode::err_arenas_difficulty;                              # 找不到难度类型
+            Err(ErrCode::err_arenas_difficulty);                                # 找不到难度类型
         }
 
         $typeId = substr($diffCult->highest, 0, 3);                             # 防御: 分类头不对
@@ -290,7 +289,7 @@ class SweepGatesProc {
             $diffCult->highest = 503000;                                        # 设置为关卡第一关
         }
         if ($gateId > $diffCult->highest + 1) {                                 # 不能跳关
-            return ErrCode::err_arenasgate_indexillegal;
+            Err(ErrCode::err_arenasgate_indexillegal);
         }
 
         if ($gateId == $diffCult->highest + 1 && $star > 0) {                   # 星级大于等于0,才可以推关
@@ -307,18 +306,17 @@ class SweepGatesProc {
         if ($uGate->star < $star) {                                             # 当前关卡得分评星
             $uGate->star = $star;
         }
-
+//        CLog::err($uGate);
         if (!$uGate->cleared) {
             $uGate->cleared = 1;                                                # 当前关卡是否已通关     
             $isFirst = true;
+//            CLog::err($uGate);
         }
         $diffCult->gates->$gateId = $uGate;                                     # 回写关卡记录
 
         $userGates->TotalNum++;                                                 # 总战斗次数+1 
         $userGates->Times++;
         $req->userInfo->game->gates = $userGates;                               # 回写数据
-
-        return ErrCode::ok;
     }
 
     /**

+ 51 - 47
Gameserver/Amfphp/process/HeroProc.php

@@ -1261,66 +1261,62 @@ class HeroProc {
         foreach ($collectHeros as $key => $value) {
             isEditor() and $value = new UserHeroModel();
             if ($value->typeId == $heroModelId) {                               # 检查玩家是否已经拥有此类英雄
-                return Resp::err(ErrCode::hero_existSameHero_err);
+                Err(ErrCode::hero_existSameHero_err);
             }
         }
         $heroCfg = GameConfig::hero_getItem($heroModelId);                      # 检查账户余额是否充足
         if (!$heroCfg) {
-            return Resp::err(ErrCode::hero_const_no_err);
+            Err(ErrCode::hero_const_no_err);
         }
         if ($heroCfg->isCanBuy == 0) {
-            return Resp::err(ErrCode::paras_err);
+            Err(ErrCode::paras_err);
         }
         $piecesCfg = GameConfig::segment_getItem($piecesId);                    # 检查需要消耗的碎片的常量配置是否存在
         if (!$piecesCfg) {
-            return Resp::err(ErrCode::err_store_itemnoconst);
+            Err(ErrCode::err_store_itemnoconst);
         }
         $myPacketItems = $user->store->segement;
         $requirePiecesNum = $piecesCfg->mergePrototypeNeedNum;
         if ($heroModelId == $piecesCfg->prototypeData && $requirePiecesNum == $piecesNum) {
             if (!CommUtil::isPropertyExists($myPacketItems, $piecesId)#
                     || $myPacketItems->$piecesId < $requirePiecesNum) {         # 检查碎片道具数量是否充足
-                return Resp::err(ErrCode::hero_godblood_notengoughitem);
+                Err(ErrCode::hero_godblood_notengoughitem);
             }
         } else {
-            return Resp::err(ErrCode ::paras_err, #
-                            "error pieces para" . "req" . $piecesId . "_" .
-                            $requirePiecesNum . "/" . $piecesId . "_" . $piecesNum);
+            Err(ErrCode::paras_err, "error pieces para" . "req" . $piecesId . "_" .
+                    $requirePiecesNum . "/" . $piecesId . "_" . $piecesNum);
         }
         $bDeal = false;                                                         # 成交
         if ($costType == "cash") {
             $realPrice = $heroCfg->cashPrice;
             if ($realPrice != $costMoneyNum) {
-                return Resp::err(ErrCode::paras_err, "costCASH error! server need:" . $realPrice);
-            } else {
-                if ($costMoneyNum > 0) {
-                    if ($user->cash < $costMoneyNum) {
-                        return Resp::err(ErrCode::err_msg_cashnotenough);
-                    } else {
-                        $bDeal = UserGameModel::Consume_Cash($user, $costMoneyNum);
-                    }
-                } else if ($costMoneyNum == 0) {
-                    $bDeal = true;
+                Err(ErrCode::paras_err, "costCASH error! server need:" . $realPrice);
+            }
+            if ($costMoneyNum > 0) {
+                if ($user->cash < $costMoneyNum) {
+                    Err(ErrCode::err_msg_cashnotenough);
                 } else {
-                    return Resp::err(ErrCode::paras_err);
+                    $bDeal = UserGameModel::Consume_Cash($user, $costMoneyNum);
                 }
+            } else if ($costMoneyNum == 0) {
+                $bDeal = true;
+            } else {
+                Err(ErrCode::paras_err);
             }
         } else if ($costType == "gold") {
             $realPrice = $heroCfg->goldPrice;
             if ($realPrice != $costMoneyNum) {
-                return Resp::err(ErrCode::paras_err, "costGold error! server need:" . $realPrice);
-            } else {
-                if ($costMoneyNum > 0) {
-                    if ($user->gold < $costMoneyNum) {
-                        return Resp::err(ErrCode::err_msg_goldnotenough);
-                    } else {
-                        $bDeal = UserGameModel::Consume_Gold($user, $costMoneyNum);
-                    }
-                } else if ($costMoneyNum == 0) {
-                    $bDeal = true;
-                } else {
-                    return Resp::err(ErrCode::paras_err);
+                Err(ErrCode::paras_err, "costGold error! server need:" . $realPrice);
+            }
+            if ($costMoneyNum > 0) {
+                if ($user->gold < $costMoneyNum) {
+                    Err(ErrCode::err_msg_goldnotenough);
                 }
+                $bDeal = UserGameModel::Consume_Gold($user, $costMoneyNum);
+            } else if ($costMoneyNum == 0) {
+                $bDeal = true;
+            } else {
+                Err(ErrCode::paras_err);
             }
         }
         # 4.消耗来获得英雄
@@ -1355,18 +1351,18 @@ class HeroProc {
                 / $g->Game_CollectHero_OneBuyLimtNum);
         $arr = explode(",", $g->Game_CollectHero_BasicMaxPrice);
         if ($index >= count($arr)) {
-            return Resp::err(ErrCode::paras_err, "yi da shang xian");
+            Err(ErrCode::paras_err, "yi da shang xian");
         }
         $realCost = $arr[$index];
 
         if ($realCost != $costCash) {
-            return Resp::err(ErrCode::paras_err, "costCash error! server need:" . $realCost);
+            Err(ErrCode::paras_err, "costCash error! server need:" . $realCost);
         }
         if ($costCash <= 0) {
-            return Resp::err(ErrCode::paras_err);
+            Err(ErrCode::paras_err);
         }
         if ($user->cash < $costCash) {
-            return Resp::err(ErrCode::notenough_spar);
+            Err(ErrCode::notenough_spar);
         }
         UserGameModel::Consume_Cash($user, $costCash);                          # 扣除宝石
         $user->heros->maxCollectCount += $buyNum;                               # 修改上限
@@ -1400,7 +1396,7 @@ class HeroProc {
      * @param HeroManualModel $manual
      * @param type $hero
      */
-    static function tryNewManual($mem, &$manual, $hero) {
+    static function tryNewManual(&$manual, $hero) {
         $godpetId = $hero->typeId;
         $level = 0;
 
@@ -1456,7 +1452,7 @@ class HeroProc {
             $user->heroManual->initInstance();
         }
         $manual = $user->heroManual;
-        self::tryNewManual($req->mem, $manual, $hero);                          # 更新 图鉴
+        self::tryNewManual($manual, $hero);                                     # 更新 图鉴
         return $hero;                                                           # 返回
     }
 
@@ -1504,7 +1500,7 @@ class HeroProc {
         $lvs = GameConfig::hero_levelexp_getItem($hero->level + 1);
         $hero->maxXp = $lvs->requiredExp;
 
-        //  取可用武器第一个初始化
+        //  取可用武器第一个初始化 -- 策划要求初始英雄要带有武器 -- 王刚 2020年1月
         $wp = null;
         foreach (GameConfig::item_weapon() as $id => $mo) {
             isEditor() and $mo = new \sm_item_weapon();
@@ -1607,7 +1603,7 @@ class HeroProc {
             $collectHeros = ObjectInit();
         }
         if (!CommUtil::isPropertyExists($collectHeros, $heroUID)) {
-            return Resp::err(ErrCode::hero_no);
+            Err(ErrCode::hero_no);
         }
         isEditor() and $hero = new UserHeroModel;
         $hero = $collectHeros->$heroUID;                                        # 1. 获取这个英雄的实例数据是
@@ -1627,14 +1623,13 @@ class HeroProc {
      * @return type
      */
     static function CalcTeamFightPower($zoneid, $uid, $user) {
-        $mem = gMem();
-        $teamsetting = $user->heroTeamConfig; # 更新配置
+        $teamsetting = $user->heroTeamConfig;                                   # 战队配置
 //        var_dump($user);
         $heros = $user->heros;
         $teamCfg = JsonUtil::decode($teamsetting);
         $tid = $teamCfg->curUseTeamID;
         $team = $teamCfg->teamDic->$tid;
-        $fp = 0;                                             # 返回值
+        $fp = 0;                                                                # 返回值
         if ($team) {
             foreach ($team->heros as $hid) {
 //                isEditor() and $hero = new GameHeroModel();
@@ -1645,7 +1640,7 @@ class HeroProc {
                     }
                 }
             }
-            $mem->zadd(MemKey_GameRun::Game_FightPowerRank_zset($zoneid), array($uid => $fp));
+            gMem()->zadd(MemKey_GameRun::Game_FightPowerRank_zset($zoneid), array($uid => $fp));
         }
         return $fp;
     }
@@ -1676,10 +1671,19 @@ class HeroProc {
      * @param type $propertyname
      */
     private static function calcHeroProperty($hero, $propertyname) {
-        $level = $hero->level;
-        $modle = GameConfig::hero_getItem($hero->typeId);
-        $extra = GameConfig::heroextra_level_getItem(1);
-        return (int) ($modle->$propertyname * (1 + $extra->$propertyname));
+        $val = 0;
+        if ($hero) {
+            $modle = GameConfig::hero_getItem($hero->typeId);
+            if ($modle) {
+                $extra = GameConfig::heroextra_level_getItem($hero->typeId, $hero->grade);
+                if ($extra) {
+                    $val = (int) ($modle->$propertyname * (1 + $extra->$propertyname));
+                } else {
+                    $val = $modle->$propertyname;
+                }
+            }
+        }
+        return $val;
     }
 
 // </editor-fold>

+ 29 - 73
Gameserver/Amfphp/process/PayProc.php

@@ -34,20 +34,6 @@ class PayProc {
             // 支付相关的活动
             case CmdCode::cmd_pay_getfirstpaygift:                              # 8802 领取首充礼包
                 return PayProc::m_GetFirstPayGift($req);
-            //
-            // <editor-fold defaultstate="collapsed" desc="  页游支付  ">
-            case CmdCode::cmd_pay_buygoods:                           # 8801 购买商品
-                return WebPayProc::buyGoods($req);
-            case CmdCode::cmd_pay_getvipnewergift:                    # 8803 领取vip新手礼包
-                return WebPayProc::getVipNewerGift($req);
-            case CmdCode::cmd_pay_getvipdaygift:                      # 8804 领取黄钻每日礼包
-                return WebPayProc::getVipDayGift($req);
-            case CmdCode::cmd_pay_getvipopengift:                     # 8805 领取黄钻开通包月礼包
-                return WebPayProc::getVipOpenGift($req);
-            case CmdCode::cmd_pay_confirmdelivery:                    # 8806 客户端确认支付
-                return WebPayProc::confirmDelivery($req);
-            // </editor-fold>
-            //
             // <editor-fold defaultstate="collapsed" desc="  手机多渠道版 mpay  ">
             case CmdCode::cmd_mpay_pay:                                         # 8807 消费..
                 return self::m_pay($req);                                       # 购买普通商城物品
@@ -60,9 +46,9 @@ class PayProc {
             case CmdCode::cmd_mpay_selfCheckOrders:                             # 8811 自助检查异常订单
                 return self::selfhelpCheckOrders($req);
             case CmdCode::cmd_mpay_selfCheckOrders:
-                return;
+                return self::GetPayRecoreds($req);
 // </editor-fold>
-            //
+
             default:
                 return Resp::err(ErrCode::cmd_err);
         }
@@ -324,7 +310,7 @@ class PayProc {
             UserProc::updateUserInfo($req);
         }
         // 返回最新物品表
-        return Resp::ok(array(#                                     # 成功后将最新的玩家数据返回给客户端
+        return Resp::ok(array(#                                                 # 成功后将最新的玩家数据返回给客户端
                     'gold' => $user->gold,
                     'tili' => $user->tili,
                     'cash' => $user->cash,
@@ -446,7 +432,7 @@ class PayProc {
         $req->userInfo->game = $user;
         UserProc::updateUserInfo($req);                                         # 回写数据
         StatProc::secretShopbuy($req->zoneid, $req->uid, $itemId, $num);        # 统计/监控数据
-        return Resp::ok(array(#                                     # 成功后将最新的玩家数据返回给客户端
+        return Resp::ok(array(#                                                 # 成功后将最新的玩家数据返回给客户端
                     'gold' => $user->gold,
                     'tili' => $user->tili,
                     'cash' => $user->cash,
@@ -481,56 +467,56 @@ class PayProc {
 
         $zoneid = $req->zoneid;
         $uid = $req->uid;
-        $user = $req->userInfo->game;                           # user引用
-        if (count($req->paras) < 3) {                           # 参数不足
+        $user = $req->userInfo->game;                                           # user引用
+        if (count($req->paras) < 3) {                                           # 参数不足
             return Resp::err(ErrCode::parasnotenough_msg);
         }
-        $paytype = $req->paras[0];                              # 付费类型, 1.钻石, 2.金币
-        $itemId = $req->paras[1];                               # 道具ID
-        $num = $req->paras[2];                                  # 数量, 默认为1
-        if ($num < 1) {                                         # 参数非法,
+        $paytype = $req->paras[0];                                              # 付费类型, 1.钻石, 2.金币
+        $itemId = $req->paras[1];                                               # 道具ID
+        $num = $req->paras[2];                                                  # 数量, 默认为1
+        if ($num < 1) {                                                         # 参数非法,
             return Resp::err(ErrCode::paras_err);
         }
-        $shopItem = GameConfig::shop_getItem($itemId);          # 取商品的常量数据
-        if ($shopItem == null) {                                # 检测是否存在道具的常量数据
+        $shopItem = GameConfig::shop_getItem($itemId);                          # 取商品的常量数据
+        if ($shopItem == null) {                                                # 检测是否存在道具的常量数据
             return Resp::err(ErrCode::err_const_no);
         }
-        if ($shopItem->pricetype != $paytype) {                 # 商品定价类型检查
+        if ($shopItem->pricetype != $paytype) {                                 # 商品定价类型检查
             return Resp::err(ErrCode::pay_price_err);
         }
-        $amt = $shopItem->price;                                # 道具价格(钻石)
-        if ($amt <= 0) {                                        # 商品定价数值检查
+        $amt = $shopItem->price;                                                # 道具价格(钻石)
+        if ($amt <= 0) {                                                        # 商品定价数值检查
             return Resp::err(ErrCode::pay_price_err);
         }
-        $bDeal = false;                                         # 成交标志位
-        switch ($paytype) {                                     # 1. 钻石, 2. 金币, other:非法
-            case 1:                                             # 钻石
-                $err = self::_SaveUserCash($req, $amt * $num);  # 更新(扣除)玩家游戏币(钻石)余额
+        $bDeal = false;                                                         # 成交标志位
+        switch ($paytype) {                                                     # 1. 钻石, 2. 金币, other:非法
+            case 1:                                                             # 钻石
+                $err = self::_SaveUserCash($req, $amt * $num);                  # 更新(扣除)玩家游戏币(钻石)余额
                 if (ErrCode::ok != $err) {
                     return Resp::err($err);
                 }
                 $bDeal = true;
                 break;
-            case 2:                                             # 金币
-                if (!UserGameModel::Consume_Gold($user, $amt * $num)) { # 更新玩家金币余额
+            case 2:                                                             # 金币
+                if (!UserGameModel::Consume_Gold($user, $amt * $num)) {         # 更新玩家金币余额
                     return Resp::err(ErrCode::notenough_gold_msg);
-                }                                               # 更新(扣除)玩家游戏币(金币)余额
+                }                                                               # 更新(扣除)玩家游戏币(金币)余额
                 $bDeal = true;
                 break;
-            default :                                           # 未知的支付类型
+            default :                                                           # 未知的支付类型
                 return Resp::err(ErrCode::pay_m_type_err);
         }
 
         if ($bDeal) {
 //            var_dump($shopItem);
-            $err = self::expendShopItem($shopItem, $num, $req); # 发放商品(普通商城只有金币和体力)
+            $err = self::expendShopItem($shopItem, $num, $req);                 # 发放商品(普通商城只有金币和体力)
 
-            if ($err != ErrCode::ok) {                          # 发货失败
+            if ($err != ErrCode::ok) {                                          # 发货失败
                 return Resp::err($err);
             }
-            UserProc::updateUserInfo($req);                     # 回写数据
-            StatProc::shopbuy($zoneid, $uid, $itemId, $num);    # 统计/监控数据
-            return Resp::ok(array(#                 # 成功后将最新的玩家数据返回给客户端
+            UserProc::updateUserInfo($req);                                     # 回写数据
+            StatProc::shopbuy($zoneid, $uid, $itemId, $num);                    # 统计/监控数据
+            return Resp::ok(array(#                                             # 成功后将最新的玩家数据返回给客户端
                         'gold' => $user->gold,
                         'tili' => $user->tili,
                         'cash' => $user->cash,
@@ -594,37 +580,7 @@ class PayProc {
     }
 
 // </editor-fold>
-//
-// <editor-fold defaultstate="collapsed" desc="  移动支付 - 插入日志  ">
-
-    /**
-     * Sql语句移动支付插入一条log日志。
-     * @var string
-     */
-    const SQL_M_LOG = "INSERT INTO `tab_mpaylog_%s` (zoneid,type,result,amt,balance,giftedcash,chargedcash,source,oid,itemid) VALUES (%d,%d,%d,%d,%d,%d,%d,'%s','%s','%s')";
-
-    /**
-     * 移动支付插入一条记录
-     * @param int $zoneid 分区ID
-     * @param string $uid 玩家ID
-     * @param int $type   记录类型
-     * @param int $amt    发生金额
-     * @param int $balance 账号当前余额(钻石)
-     * @param int $giftedcash 游戏内赠送游戏币总额
-     * @param int $chargedcash 历史充值游戏币总额
-     * @param int $source  记录发生来源(起因)
-     */
-    public static function _mChargeLog($zoneid, $uid, $type, $result, $amt, $balance, $giftedcash, $chargedcash, $source = "srcUnKnown", $itemid = "") {
-//        throw new Exception("Method must be completed before online.");
-//        $month = date("Ym");
-//        $sql = sprintf(self::SQL_M_LOG, $month, $zoneid, $type, $result, $amt, $balance, $giftedcash, $chargedcash, $source, $uid, $itemid);
-//        $paydb = CPayInit();
-//        $paydb->query($sql);
-//        $paydb->close();
-    }
-
-    // </editor-fold>
-    //
+// 
     //
 // <editor-fold defaultstate="collapsed" desc="  支付活动 - 首付礼包">
 

+ 512 - 511
Gameserver/Amfphp/process/PayProc/WebPayProc.php

@@ -1,513 +1,514 @@
 <?php
 
-namespace loyalsoft;
-
-/**
- * Qzone页游支付处理代码
- */
-class WebPayProc {
-
-    const PAY_BILL_SELECT = "SELECT * FROM `tab_billrecord` where `openid`='%s' and `state`='0' order by id;"; // 筛选尚未确认支付的订单
-    const PAY_BILL_DELETE = "DELETE FROM `tab_billrecord` where id = '%d';";                                   // 删除未确认的支付订单
-    const PAY_BILL_CONFIRM = "INSERT INTO `tab_billconfirm` (`openid`,`billno`,`amt`,`payitem`,`token`,`state`,`msg`) VALUES ('%s','%s','%d','%s','%s','1','OK');"; // 变更订单确认支付状态字
-    const PAY_BILL_LOST = "INSERT INTO `tab_billconfirm` (`openid`,`billno`,`amt`,`payitem`,`token`,`state`,`msg`) VALUES ('%s','%s','%d','%s','%s','-1','%s');"; // 变更订单支付丢失状态字
-    const PAY_LOG_INSERT = "INSERT INTO `tab_paylog` (`msg`) VALUES ('%s');";                                   // 新增支付日志
-
-    /**
-     * 【PC端】购买付费道具
-     * @param Req $req
-     * @return type
-     */
-
-    public static function buyGoods($req) {
-        $resp = new Resp();
-        $mem = $req->mem;
-        $v3 = CV3Init();
-        $private = $req->userInfo->game->privateState;
-//客户端参数解析
-        $openid = $req->uid;
-        $zoneid = $req->zoneid;
-        $openkey = $req->paras[0];
-        $pf = $req->paras[1];
-        $pfkey = $req->paras[2];
-        $itemPriceYuan = $req->paras[3];
-
-        //ID=Q点价格=元宝价格
-        $itemPriceDot = $itemPriceYuan * 10;
-        $itemID = $itemPriceDot;
-        $itemPrice = $itemPriceDot;
-        $itemName = $itemPriceDot . '元宝';
-        $itemDes = $itemName;
-
-        $ts = now();
-        $goodsurl = self::_getGoodsImgUrl($itemModel);
-        $v3PayRet = $v3->pay_buy_goods($openid, $openkey, $pf, $pfkey, #
-                $ts, $itemID, $itemPrice, $itemName, $itemDes, $goodsurl, $zoneid - 1);
-        if ($v3PayRet->ret == 1002) { //假如玩家未登录
-            $resp = Resp::err(ErrCode::user_login_err);
-        } elseif ($v3PayRet->ret != 0) { //
-            $resp = Resp::err($v3PayRet->ret);
-            $resp->result = $v3PayRet;
-        } else {
-            $tokenInfo = self::getTokenInfo($mem, $zoneid, $openid);
-            if ($tokenInfo == null) {
-                $resp = Resp::err(ErrCode::user_no_err);
-            } else {
-                self::insToken($tokenInfo, $v3PayRet->token);
-                self::updateTokenInfo($mem, $zoneid, $openid, $tokenInfo);
-                $resp = Resp::ok($v3PayRet);
-            }
-        }
-        $v3->close();
-        return $resp;
-    }
-
-    /**
-     * 客户端确认支付
-     * @param type $req
-     * @return \ResponseVo
-     */
-    public static function confirmDelivery($req) {
-        $resp = new Resp();
-        $v3 = CV3Init();
-        self::confirmPay($req, $v3);
-        $resp = Resp::ok("succeed!");
-        $v3->close();
-        return $resp;
-    }
-
-    /**
-     * 领取首付礼包
-     * @param Req $req
-     * @return Resp
-     */
-    public static function getFirstPayGift($req) {
-        $resp = new Resp();
-        $map = $req->userInfo->game->map;
-        $privateState = $req->userInfo->game->privateState;
-
-//  如果已经领取首付礼包
-        if (!CommUtil::isPropertyExists($privateState, "firstPayGift")) {
-            $resp = Resp::err(ErrCode::pay_firstpaygetted);
-        } elseif (!$privateState->firstPayGift) { //  如果尚未完成首付
-            $resp = Resp::err(ErrCode::pay_firstpayno_err);
-        } else {
-            $itemModel = ConstProc::getGoodsItemConst(ITEM_FIRSTPAY);
-//  检测首付礼包是否存在
-            if ($itemModel == null) {
-                $resp = Resp::err(ErrCode::err_const_no);
-            } else {
-                unset($privateState->firstPayGift); # .剔除首付标志
-                StoreProc::addSeprateItem($itemModel, $req); #  .发放首付礼包
-                $result = array(# 把玩家最新的仓库数据发给客户端
-                    'store' => $map->store,
-                );
-// 7.回送成功信息
-                $resp = Resp::ok($result);
-// 成就触发--获取金币
-                AchievementProc::dealAchievementState($req, $resp, AchievementProc::Gold);
-                UserProc::updateUserInfo($req); # 更新玩家数据
-            }
-        }
-
-        return $resp;
-    }
-
-    /**
-     * 获取黄钻新手礼包
-     * @param Req $req
-     * @return type
-     */
-    public static function getVipNewerGift($req) {
-        $user = $req->userInfo->game->user;
-        $map = $req->userInfo->game->map;
-        $privateState = $req->userInfo->game->privateState;
-//客户端参数解析
-        $itemId = ITEM_VIPNEWER;  # 新手礼包是个常量
-        $item = ConstProc::getGoodsItemConst($itemId);
-
-        $isYellowYear = $user->is_yellow_year_vip;
-        $itemYear = null;
-        if ($isYellowYear) {
-            $itemIdYear = ITEM_YEARVIPNEWER;
-            $itemYear = ConstProc::getGoodsItemConst($itemIdYear);
-            if ($itemYear == null) {
-                $resp = Resp::err(ErrCode::err_const_no);
-                return;
-            }
-        }
-//1.检测是否存在道具的常量数据
-        if ($item == null) {
-            $resp = Resp::err(ErrCode::err_const_no);
-        } else {//2.检测是否可以领取黄钻新手礼包
-            if (!WebPayProc::tryVipNewerGift($user, $privateState)) {
-                $resp = Resp::err(ErrCode::pay_vipnewerno);
-            } else {
-                StoreProc::addSeprateItem($item, $req);
-                if ($itemYear) {
-                    StoreProc::addSeprateItem($itemYear, $req);
-                }
-                $result = array(
-                    'store' => $map->store,
-                );
-                $resp = Resp::ok($result); # 返回值
-//成就触发--获取金币
-                AchievementProc::dealAchievementState($req, $resp, AchievementProc::Gold);
-                UserProc::updateUserInfo($req); # 回写数据
-            }
-        }
-        return $resp;
-    }
-
-    /**
-     * 开通包月送礼包
-     * @param Req $req
-     */
-    public static function getVipOpenGift($req) {
-        $mem = $req->mem;
-        $v3 = CV3Init();
-//客户端参数解析
-        $openid = $req->uid;
-        $openkey = $req->paras[0];
-        $pf = $req->paras[1];
-        $pfkey = $req->paras[2];
-
-        $ts = now();
-        $v3Ret = $v3->pay_gift_get_token($openid, $openkey, $pf, $pfkey, "1", ACT_VIP_OPEN, $ts);
-        if ($v3Ret->ret == 1001) {
-            $resp = Resp::err($v3Ret->ret);
-            $resp->result = $v3Ret->msg;
-        } elseif ($v3Ret->ret == 1099) {
-            $resp = Resp::err(ErrCode::pay_systembusy_err);
-            $resp->result = $v3Ret->msg;
-        } elseif ($v3Ret->ret != 0) {
-            $resp = Resp::err(ErrCode::pay_systembusy_err);
-            $resp->result = $v3Ret;
-        } else {  //v3成功返回
-            $tokenInfo = WebPayProc::getTokenInfo($mem, $req->zoneid, $openid);
-            if ($tokenInfo == null) {
-                $resp = Resp::err(ErrCode::user_no_err);
-            } else {
-                WebPayProc::insToken($tokenInfo, $v3Ret->token);
-                WebPayProc::updateTokenInfo($mem, $req->zoneid, $openid, $tokenInfo);
-// 开通包月送礼包活动号,腾讯分配
-                $v3Ret->actid = ACT_VIP_OPEN;  // 将actid插入返回值中一块儿发送给客户端
-                $v3Ret->zoneid = 0;            // fusionAPI 需要
-                $resp = Resp::ok($v3Ret);
-            }
-        }
-        $v3->close();
-        return $resp;
-    }
-
-    /**
-     * 领取黄钻每日礼包
-     * @param Req $req
-     */
-    public static function getVipDayGift($req) {
-        $mem = $req->mem;
-        $zoneid = $req->zoneid;
-        $v3 = CV3Init();
-        $user = $req->userInfo->game->user;
-//客户端参数解析
-        $openid = $req->uid;
-        $openkey = $req->paras[0];
-        $pf = $req->paras[1];
-        $pfkey = $req->paras[2];
-
-        $ts = now();
-        CLog::giftlog("getVipDayGift $zoneid|$openid|$openkey|$pf");
-        $v3Ret = $v3->pay_gift_get_token($openid, $openkey, $pf, $pfkey, "1", ACT_VIP_DAY, $ts, $zoneid - 1);
-        if ($v3Ret->ret == 1001) {
-            $resp = Resp::err($v3Ret->ret);
-            $resp->result = $v3Ret->msg;
-        } elseif ($v3Ret->ret == 1099) {
-            $resp = Resp::err(ErrCode::pay_systembusy_err);
-            $resp->result = $v3Ret->msg;
-        } elseif ($v3Ret->ret != 0) {
-            $resp = Resp::err(ErrCode::pay_systembusy_err);
-            $resp->result = $v3Ret;
-        } else {  //v3成功返回
-            $tokenInfo = WebPayProc::getTokenInfo($mem, $zoneid, $openid);
-            if ($tokenInfo == null) {
-                $resp = Resp::err(ErrCode::user_no_err);
-            } else {
-                WebPayProc::insToken($tokenInfo, $v3Ret->token);
-                if ($user->is_yellow_vip) {
-                    WebPayProc::insToken($tokenInfo, $v3Ret->token . "-year");
-                }
-                WebPayProc::updateTokenInfo($mem, $zoneid, $openid, $tokenInfo);
-                $v3Ret->actid = ACT_VIP_DAY;  //将actid 插入返回值中一块儿发送给客户端
-                $resp = Resp::ok($v3Ret);
-            }
-        }
-        $v3->close();
-        return $resp;
-    }
-
-//  ----------------  --------------------
-    /**
-     * 领取黄钻升级礼包
-     * @param type $user
-     */
-    public static function getVipLvGift($mem, & $user, &$map) {
-        
-    }
-
-    /**
-     * 获取玩家token校验表
-     * @param type $mem
-     * @param int $zoneid
-     * @param type $uid
-     * @return type
-     */
-    public static function getTokenInfo($mem, $zoneid, $uid) {
-        return $mem->get(MemKey_User::TokenInfo($zoneid, $uid));
-    }
-
-    /**
-     * 更新玩家token校验表
-     * @param type $mem
-     * @param int $zoneid
-     * @param type $uid
-     * @param type $tokenInfo
-     */
-    public static function updateTokenInfo($mem, $zoneid, $uid, $tokenInfo) {
-        $mem->set(MemKey_User::TokenInfo($zoneid, $uid), $tokenInfo);
-    }
-
-    /**
-     * 新增token
-     * @param type $mem
-     * @param type $oid
-     * @param type $token
-     */
-    public static function insToken(& $tokenInfo, $token) {
-        $tokenInfo->$token = now();
-    }
-
-    /**
-     * 读取token
-     * @param type $mem
-     * @param type $oid
-     * @param type $token
-     * @return null
-     */
-    public static function getToken($tokenInfo, $token) {
-        if (!CommUtil::isPropertyExists($tokenInfo, $token)) {
-            return null;
-        } else {
-            return $tokenInfo->$token;
-        }
-    }
-
-    /**
-     * 删除token
-     * @param type $mem
-     * @param type $oid
-     * @param type $token
-     */
-    public static function delToken(& $tokenInfo, $token) {
-        if (CommUtil::isPropertyExists($tokenInfo, $token)) {
-            unset($tokenInfo->$token);
-        }
-    }
-
-    /**
-     * 添加付费道具到挂起列表
-     * @param CMemBase $mem
-     * @param int $zoneid
-     * @param string $uid
-     * @param type $itemId
-     */
-    public static function addPayStoreItem($mem, $zoneid, $uid, $itemId) {
-        $payStore = $mem->get(MemKey_User::PayOrders($zoneid, $uid));
-        if ($payStore == null) {
-            $payStore = ArrayInit();
-        }
-        $payStore[] = $itemId;
-        $mem->set(MemKey_User::PayOrders($zoneid, $uid), $payStore);
-    }
-
-    /**
-     * 添加营销礼包到挂起列表
-     * @param CMemBase $mem
-     * @param int $zoneid
-     * @param string $uid
-     * @param type $itemId
-     */
-    public static function addGiftStoreItem($mem, $zoneid, $uid, $itemId) {
-        $giftStore = $mem->get(MemKey_User::GiftStore($zoneid, $uid));
-        CLog::pay("WebGift addGiftStoreItem1 giftStore:$giftStore|itemId:$itemId|oid:$uid");
-        if ($giftStore == null) {
-            $giftStore = ArrayInit();
-        }
-        $giftStore[] = $itemId;
-        CLog::pay("WebGift addGiftStoreItem1 giftStore:$giftStore|itemId:$itemId|oid:$uid");
-        $mem->set(MemKey_User::GiftStore($zoneid, $uid), $giftStore);
-    }
-
-    /**
-     * 刷新挂起列表中的付费道具到仓库
-     * @param Req $req
-     */
-    public static function refreshPayStoreItem($req) {
-        $mem = $req->mem;
-        $oid = $req->uid;
-        $privateState = $req->userInfo->game->privateState;
-
-        $payGodpetItems = ArrayInit();
-        $payStore = $mem->get(MemKey_User::PayOrders($req->zoneid, $oid));
-        if ($payStore != null) {
-            foreach ($payStore as $payItemId) {
-                $itemModel = ConstProc::getGoodsItemConst($payItemId);
-                if ($itemModel != null) {
-                    $payGodpetItems[] = $payItemId;
-                    if (CommUtil::isPropertyExists($privateState, "firstPayGift") //
-                            && !$privateState->firstPayGift) {
-                        $privateState->firstPayGift = true;
-                    }
-                    $properties = JsonUtil::decode($itemModel->properties);
-                    if (CommUtil::isPropertyExists($properties, "isActive")) {
-                        $activeList = $privateState->activeList;
-                        $activeId = $properties->isActive;
-                        $activeList[] = $activeId;
-                        $privateState->activeList = $activeList;
-                    }
-                    StoreProc::addSeprateItem($itemModel, $req);
-                }
-            }
-            $mem->delete(MemKey_User::PayOrders($req->zoneid, $oid));
-        }
-        return $payGodpetItems;
-    }
-
-    /**
-     * 刷新挂起列表中的营销礼包到仓库
-     * @param Req $req
-     */
-    public static function refreshGiftStoreItem($req) {
-        $oid = $req->uid;
-        $mem = $req->mem;
-        $giftStore = $mem->get(MemKey_User::GiftStore($req->zoneid, $oid));
-        CLog::pay("WebGift refreshGiftStoreItem giftStore:$giftStore|oid:$oid");
-
-        if ($giftStore != null) {
-            foreach ($giftStore as $giftItemId) {
-                $itemModel = ConstProc::getGoodsItemConst($giftItemId);
-                CLog::pay("WebGift refreshGiftStoreItem2 giftItemId:$giftItemId");
-
-                if ($itemModel != null) {
-                    StoreProc::addSeprateItem($itemModel, $req);
-                } else {
-                    CLog::pay("WebGift refreshGiftStoreItem3 ERR giftItemId:$giftItemId");
-                }
-            }
-            $mem->delete(MemKey_User::GiftStore($req->zoneid, $oid));
-        }
-    }
-
-    /**
-     * 尝试领取黄钻新手礼包
-     * @param type $user
-     * @param type $privateState
-     * @return boolean
-     */
-    public static function tryVipNewerGift($user, &$privateState) {
-//1.检查是否为黄钻
-        if ($user->is_yellow_vip) {
-# //2.检查是否含有新手礼包标志
-            if (CommUtil::isPropertyExists($privateState, "vipNewerGift")) {
-                if ($privateState->vipNewerGift) {# //3.检查是否能够领取
-                    unset($privateState->vipNewerGift); # //4.剔除新手礼包标志
-                    return true; //5.返回成功
-                }
-            }
-        }
-        return false;
-    }
-
-    /**
-     * 尝试领取黄钻每日礼包
-     * @param type $user
-     * @param type $privateState
-     * @return boolean
-     */
-    public static function tryVipDayGift($user, &$privateState) {
-        if ($user->is_yellow_vip) {//1.检查是否为黄钻
-            if (CommUtil::isPropertyExists($privateState, "vipDayGift")) {//2.检查黄钻礼包标志是否为真
-                if ($privateState->vipDayGift) {//3.检查是否能够领取
-                    $privateState->vipDayGift = false; //4.修改黄钻每日礼包标志
-                    return true; //5.返回成功
-                }
-            }
-        }
-        return false;
-    }
-
-    /**
-     * 客户端确认支付
-     * @param type $req
-     * @return \ResponseVo
-     */
-    public static function confirmPay($req, $v3) {
-        $paydb = CPayInit();
-        $openid = $req->uid; //客户端参数解析
-        $billArray = $paydb->fetch_array(sprintf(self::PAY_BILL_SELECT, $openid));
-        if (count($billArray) > 0) {
-            foreach ($billArray as $billRecord) {
-                $id = $billRecord['id'];
-                $ts = now();
-                $payitem = $billRecord['payitem'];
-                $token = $billRecord['token'];
-                $billno = $billRecord['billno'];
-                $amt = $billRecord['amt'];
-                if (GAME_ONLINE) {
-                    $ret = $v3->pay_confirm_delivery($openid, $openkey, $pf, $ts, //
-                            $payitem, $token, $billno, $amt);
-                    if ($ret->ret == 0 || $ret->ret == 1069) {// 订单确认的情况
-                        $dbRet = $paydb->query(sprintf(self::PAY_BILL_DELETE, $id));
-                        $sqlConfirm = sprintf(self::PAY_BILL_CONFIRM, $openid, $billno, $amt, $payitem, $token);
-                        $dbRet = $paydb->query($sqlConfirm); // 写订单支付日志
-                        $log = $billno . "|" . $ret->msg . "[" . $openid . "]已确认支付!";
-                        $dbRet = WebPayProc::_paylog($paydb, $log);
-                    }// 订单丢失的情况
-                    else if ($ret->ret == 1060 || $ret->ret == 1063 || $ret->ret == 1068) {
-                        $dbRet = $paydb->query(sprintf(self::PAY_BILL_DELETE, $id));
-                        $sqlLost = sprintf(self::PAY_BILL_LOST, $openid, $billno, $amt, $payitem, $token, $ret->msg);
-                        $dbRet = $paydb->query($sqlLost); // 写订单支付日志
-                        $log = $billno . "|" . $ret->msg . "[" . $openid . "]已确认丢失!";
-                        $dbRet = WebPayProc::_paylog($paydb, $log);
-                    }
-                } else {
-                    $dbRet = $paydb->query(sprintf(self::PAY_BILL_DELETE, $id));
-                    $sqlConfirm = sprintf(self::PAY_BILL_CONFIRM, $openid, $billno, $amt, $payitem, $token);
-                    $dbRet = $paydb->query($sqlConfirm); // 写订单支付日志
-                    $log = $billno . "|" . $ret->msg . "[" . $openid . "]已确认支付!";
-                    $dbRet = WebPayProc::_paylog($paydb, $log);
-                }
-            }
-        }
-        $paydb->close();
-    }
-
-    /**
-     * 插入日志
-     * @param CDBUtil $paydb
-     * @param string $log
-     * @return mixed
-     */
-    static function _paylog($paydb, $log) {
-        return $paydb->query(sprintf(self::PAY_LOG_INSERT, $log));
-    }
-
-    /**
-     * 获取指定道具的图片Url
-     * @param GoodsItemModel $item
-     * @return String 返回字符串
-     */
-    private static function _getGoodsImgUrl($item) {
-        return CDN_HOST . "res/yuanbao3.png";
-    }
-
-}
+//
+//namespace loyalsoft;
+//
+///**
+// * Qzone页游支付处理代码
+// */
+//class WebPayProc {
+//
+//    const PAY_BILL_SELECT = "SELECT * FROM `tab_billrecord` where `openid`='%s' and `state`='0' order by id;"; // 筛选尚未确认支付的订单
+//    const PAY_BILL_DELETE = "DELETE FROM `tab_billrecord` where id = '%d';";                                   // 删除未确认的支付订单
+//    const PAY_BILL_CONFIRM = "INSERT INTO `tab_billconfirm` (`openid`,`billno`,`amt`,`payitem`,`token`,`state`,`msg`) VALUES ('%s','%s','%d','%s','%s','1','OK');"; // 变更订单确认支付状态字
+//    const PAY_BILL_LOST = "INSERT INTO `tab_billconfirm` (`openid`,`billno`,`amt`,`payitem`,`token`,`state`,`msg`) VALUES ('%s','%s','%d','%s','%s','-1','%s');"; // 变更订单支付丢失状态字
+//    const PAY_LOG_INSERT = "INSERT INTO `tab_paylog` (`msg`) VALUES ('%s');";                                   // 新增支付日志
+//
+//    /**
+//     * 【PC端】购买付费道具
+//     * @param Req $req
+//     * @return type
+//     */
+//
+//    public static function buyGoods($req) {
+//        $resp = new Resp();
+//        $mem = $req->mem;
+//        $v3 = CV3Init();
+//        $private = $req->userInfo->game->privateState;
+////客户端参数解析
+//        $openid = $req->uid;
+//        $zoneid = $req->zoneid;
+//        $openkey = $req->paras[0];
+//        $pf = $req->paras[1];
+//        $pfkey = $req->paras[2];
+//        $itemPriceYuan = $req->paras[3];
+//
+//        //ID=Q点价格=元宝价格
+//        $itemPriceDot = $itemPriceYuan * 10;
+//        $itemID = $itemPriceDot;
+//        $itemPrice = $itemPriceDot;
+//        $itemName = $itemPriceDot . '元宝';
+//        $itemDes = $itemName;
+//
+//        $ts = now();
+//        $goodsurl = self::_getGoodsImgUrl($itemModel);
+//        $v3PayRet = $v3->pay_buy_goods($openid, $openkey, $pf, $pfkey, #
+//                $ts, $itemID, $itemPrice, $itemName, $itemDes, $goodsurl, $zoneid - 1);
+//        if ($v3PayRet->ret == 1002) { //假如玩家未登录
+//            $resp = Resp::err(ErrCode::user_login_err);
+//        } elseif ($v3PayRet->ret != 0) { //
+//            $resp = Resp::err($v3PayRet->ret);
+//            $resp->result = $v3PayRet;
+//        } else {
+//            $tokenInfo = self::getTokenInfo($mem, $zoneid, $openid);
+//            if ($tokenInfo == null) {
+//                $resp = Resp::err(ErrCode::user_no_err);
+//            } else {
+//                self::insToken($tokenInfo, $v3PayRet->token);
+//                self::updateTokenInfo($mem, $zoneid, $openid, $tokenInfo);
+//                $resp = Resp::ok($v3PayRet);
+//            }
+//        }
+//        $v3->close();
+//        return $resp;
+//    }
+//
+//    /**
+//     * 客户端确认支付
+//     * @param type $req
+//     * @return \ResponseVo
+//     */
+//    public static function confirmDelivery($req) {
+//        $resp = new Resp();
+//        $v3 = CV3Init();
+//        self::confirmPay($req, $v3);
+//        $resp = Resp::ok("succeed!");
+//        $v3->close();
+//        return $resp;
+//    }
+//
+//    /**
+//     * 领取首付礼包
+//     * @param Req $req
+//     * @return Resp
+//     */
+//    public static function getFirstPayGift($req) {
+//        $resp = new Resp();
+//        $map = $req->userInfo->game->map;
+//        $privateState = $req->userInfo->game->privateState;
+//
+////  如果已经领取首付礼包
+//        if (!CommUtil::isPropertyExists($privateState, "firstPayGift")) {
+//            $resp = Resp::err(ErrCode::pay_firstpaygetted);
+//        } elseif (!$privateState->firstPayGift) { //  如果尚未完成首付
+//            $resp = Resp::err(ErrCode::pay_firstpayno_err);
+//        } else {
+//            $itemModel = ConstProc::getGoodsItemConst(ITEM_FIRSTPAY);
+////  检测首付礼包是否存在
+//            if ($itemModel == null) {
+//                $resp = Resp::err(ErrCode::err_const_no);
+//            } else {
+//                unset($privateState->firstPayGift); # .剔除首付标志
+//                StoreProc::addSeprateItem($itemModel, $req); #  .发放首付礼包
+//                $result = array(# 把玩家最新的仓库数据发给客户端
+//                    'store' => $map->store,
+//                );
+//// 7.回送成功信息
+//                $resp = Resp::ok($result);
+//// 成就触发--获取金币
+//                AchievementProc::dealAchievementState($req, $resp, AchievementProc::Gold);
+//                UserProc::updateUserInfo($req); # 更新玩家数据
+//            }
+//        }
+//
+//        return $resp;
+//    }
+//
+//    /**
+//     * 获取黄钻新手礼包
+//     * @param Req $req
+//     * @return type
+//     */
+//    public static function getVipNewerGift($req) {
+//        $user = $req->userInfo->game->user;
+//        $map = $req->userInfo->game->map;
+//        $privateState = $req->userInfo->game->privateState;
+////客户端参数解析
+//        $itemId = ITEM_VIPNEWER;  # 新手礼包是个常量
+//        $item = ConstProc::getGoodsItemConst($itemId);
+//
+//        $isYellowYear = $user->is_yellow_year_vip;
+//        $itemYear = null;
+//        if ($isYellowYear) {
+//            $itemIdYear = ITEM_YEARVIPNEWER;
+//            $itemYear = ConstProc::getGoodsItemConst($itemIdYear);
+//            if ($itemYear == null) {
+//                $resp = Resp::err(ErrCode::err_const_no);
+//                return;
+//            }
+//        }
+////1.检测是否存在道具的常量数据
+//        if ($item == null) {
+//            $resp = Resp::err(ErrCode::err_const_no);
+//        } else {//2.检测是否可以领取黄钻新手礼包
+//            if (!WebPayProc::tryVipNewerGift($user, $privateState)) {
+//                $resp = Resp::err(ErrCode::pay_vipnewerno);
+//            } else {
+//                StoreProc::addSeprateItem($item, $req);
+//                if ($itemYear) {
+//                    StoreProc::addSeprateItem($itemYear, $req);
+//                }
+//                $result = array(
+//                    'store' => $map->store,
+//                );
+//                $resp = Resp::ok($result); # 返回值
+////成就触发--获取金币
+//                AchievementProc::dealAchievementState($req, $resp, AchievementProc::Gold);
+//                UserProc::updateUserInfo($req); # 回写数据
+//            }
+//        }
+//        return $resp;
+//    }
+//
+//    /**
+//     * 开通包月送礼包
+//     * @param Req $req
+//     */
+//    public static function getVipOpenGift($req) {
+//        $mem = $req->mem;
+//        $v3 = CV3Init();
+////客户端参数解析
+//        $openid = $req->uid;
+//        $openkey = $req->paras[0];
+//        $pf = $req->paras[1];
+//        $pfkey = $req->paras[2];
+//
+//        $ts = now();
+//        $v3Ret = $v3->pay_gift_get_token($openid, $openkey, $pf, $pfkey, "1", ACT_VIP_OPEN, $ts);
+//        if ($v3Ret->ret == 1001) {
+//            $resp = Resp::err($v3Ret->ret);
+//            $resp->result = $v3Ret->msg;
+//        } elseif ($v3Ret->ret == 1099) {
+//            $resp = Resp::err(ErrCode::pay_systembusy_err);
+//            $resp->result = $v3Ret->msg;
+//        } elseif ($v3Ret->ret != 0) {
+//            $resp = Resp::err(ErrCode::pay_systembusy_err);
+//            $resp->result = $v3Ret;
+//        } else {  //v3成功返回
+//            $tokenInfo = WebPayProc::getTokenInfo($mem, $req->zoneid, $openid);
+//            if ($tokenInfo == null) {
+//                $resp = Resp::err(ErrCode::user_no_err);
+//            } else {
+//                WebPayProc::insToken($tokenInfo, $v3Ret->token);
+//                WebPayProc::updateTokenInfo($mem, $req->zoneid, $openid, $tokenInfo);
+//// 开通包月送礼包活动号,腾讯分配
+//                $v3Ret->actid = ACT_VIP_OPEN;  // 将actid插入返回值中一块儿发送给客户端
+//                $v3Ret->zoneid = 0;            // fusionAPI 需要
+//                $resp = Resp::ok($v3Ret);
+//            }
+//        }
+//        $v3->close();
+//        return $resp;
+//    }
+//
+//    /**
+//     * 领取黄钻每日礼包
+//     * @param Req $req
+//     */
+//    public static function getVipDayGift($req) {
+//        $mem = $req->mem;
+//        $zoneid = $req->zoneid;
+//        $v3 = CV3Init();
+//        $user = $req->userInfo->game->user;
+////客户端参数解析
+//        $openid = $req->uid;
+//        $openkey = $req->paras[0];
+//        $pf = $req->paras[1];
+//        $pfkey = $req->paras[2];
+//
+//        $ts = now();
+//        CLog::giftlog("getVipDayGift $zoneid|$openid|$openkey|$pf");
+//        $v3Ret = $v3->pay_gift_get_token($openid, $openkey, $pf, $pfkey, "1", ACT_VIP_DAY, $ts, $zoneid - 1);
+//        if ($v3Ret->ret == 1001) {
+//            $resp = Resp::err($v3Ret->ret);
+//            $resp->result = $v3Ret->msg;
+//        } elseif ($v3Ret->ret == 1099) {
+//            $resp = Resp::err(ErrCode::pay_systembusy_err);
+//            $resp->result = $v3Ret->msg;
+//        } elseif ($v3Ret->ret != 0) {
+//            $resp = Resp::err(ErrCode::pay_systembusy_err);
+//            $resp->result = $v3Ret;
+//        } else {  //v3成功返回
+//            $tokenInfo = WebPayProc::getTokenInfo($mem, $zoneid, $openid);
+//            if ($tokenInfo == null) {
+//                $resp = Resp::err(ErrCode::user_no_err);
+//            } else {
+//                WebPayProc::insToken($tokenInfo, $v3Ret->token);
+//                if ($user->is_yellow_vip) {
+//                    WebPayProc::insToken($tokenInfo, $v3Ret->token . "-year");
+//                }
+//                WebPayProc::updateTokenInfo($mem, $zoneid, $openid, $tokenInfo);
+//                $v3Ret->actid = ACT_VIP_DAY;  //将actid 插入返回值中一块儿发送给客户端
+//                $resp = Resp::ok($v3Ret);
+//            }
+//        }
+//        $v3->close();
+//        return $resp;
+//    }
+//
+////  ----------------  --------------------
+//    /**
+//     * 领取黄钻升级礼包
+//     * @param type $user
+//     */
+//    public static function getVipLvGift($mem, & $user, &$map) {
+//        
+//    }
+//
+//    /**
+//     * 获取玩家token校验表
+//     * @param type $mem
+//     * @param int $zoneid
+//     * @param type $uid
+//     * @return type
+//     */
+//    public static function getTokenInfo($mem, $zoneid, $uid) {
+//        return $mem->get(MemKey_User::TokenInfo($zoneid, $uid));
+//    }
+//
+//    /**
+//     * 更新玩家token校验表
+//     * @param type $mem
+//     * @param int $zoneid
+//     * @param type $uid
+//     * @param type $tokenInfo
+//     */
+//    public static function updateTokenInfo($mem, $zoneid, $uid, $tokenInfo) {
+//        $mem->set(MemKey_User::TokenInfo($zoneid, $uid), $tokenInfo);
+//    }
+//
+//    /**
+//     * 新增token
+//     * @param type $mem
+//     * @param type $oid
+//     * @param type $token
+//     */
+//    public static function insToken(& $tokenInfo, $token) {
+//        $tokenInfo->$token = now();
+//    }
+//
+//    /**
+//     * 读取token
+//     * @param type $mem
+//     * @param type $oid
+//     * @param type $token
+//     * @return null
+//     */
+//    public static function getToken($tokenInfo, $token) {
+//        if (!CommUtil::isPropertyExists($tokenInfo, $token)) {
+//            return null;
+//        } else {
+//            return $tokenInfo->$token;
+//        }
+//    }
+//
+//    /**
+//     * 删除token
+//     * @param type $mem
+//     * @param type $oid
+//     * @param type $token
+//     */
+//    public static function delToken(& $tokenInfo, $token) {
+//        if (CommUtil::isPropertyExists($tokenInfo, $token)) {
+//            unset($tokenInfo->$token);
+//        }
+//    }
+//
+//    /**
+//     * 添加付费道具到挂起列表
+//     * @param CMemBase $mem
+//     * @param int $zoneid
+//     * @param string $uid
+//     * @param type $itemId
+//     */
+//    public static function addPayStoreItem($mem, $zoneid, $uid, $itemId) {
+//        $payStore = $mem->get(MemKey_User::PayOrders($zoneid, $uid));
+//        if ($payStore == null) {
+//            $payStore = ArrayInit();
+//        }
+//        $payStore[] = $itemId;
+//        $mem->set(MemKey_User::PayOrders($zoneid, $uid), $payStore);
+//    }
+//
+//    /**
+//     * 添加营销礼包到挂起列表
+//     * @param CMemBase $mem
+//     * @param int $zoneid
+//     * @param string $uid
+//     * @param type $itemId
+//     */
+//    public static function addGiftStoreItem($mem, $zoneid, $uid, $itemId) {
+//        $giftStore = $mem->get(MemKey_User::GiftStore($zoneid, $uid));
+//        CLog::pay("WebGift addGiftStoreItem1 giftStore:$giftStore|itemId:$itemId|oid:$uid");
+//        if ($giftStore == null) {
+//            $giftStore = ArrayInit();
+//        }
+//        $giftStore[] = $itemId;
+//        CLog::pay("WebGift addGiftStoreItem1 giftStore:$giftStore|itemId:$itemId|oid:$uid");
+//        $mem->set(MemKey_User::GiftStore($zoneid, $uid), $giftStore);
+//    }
+//
+//    /**
+//     * 刷新挂起列表中的付费道具到仓库
+//     * @param Req $req
+//     */
+//    public static function refreshPayStoreItem($req) {
+//        $mem = $req->mem;
+//        $oid = $req->uid;
+//        $privateState = $req->userInfo->game->privateState;
+//
+//        $payGodpetItems = ArrayInit();
+//        $payStore = $mem->get(MemKey_User::PayOrders($req->zoneid, $oid));
+//        if ($payStore != null) {
+//            foreach ($payStore as $payItemId) {
+//                $itemModel = ConstProc::getGoodsItemConst($payItemId);
+//                if ($itemModel != null) {
+//                    $payGodpetItems[] = $payItemId;
+//                    if (CommUtil::isPropertyExists($privateState, "firstPayGift") //
+//                            && !$privateState->firstPayGift) {
+//                        $privateState->firstPayGift = true;
+//                    }
+//                    $properties = JsonUtil::decode($itemModel->properties);
+//                    if (CommUtil::isPropertyExists($properties, "isActive")) {
+//                        $activeList = $privateState->activeList;
+//                        $activeId = $properties->isActive;
+//                        $activeList[] = $activeId;
+//                        $privateState->activeList = $activeList;
+//                    }
+//                    StoreProc::addSeprateItem($itemModel, $req);
+//                }
+//            }
+//            $mem->delete(MemKey_User::PayOrders($req->zoneid, $oid));
+//        }
+//        return $payGodpetItems;
+//    }
+//
+//    /**
+//     * 刷新挂起列表中的营销礼包到仓库
+//     * @param Req $req
+//     */
+//    public static function refreshGiftStoreItem($req) {
+//        $oid = $req->uid;
+//        $mem = $req->mem;
+//        $giftStore = $mem->get(MemKey_User::GiftStore($req->zoneid, $oid));
+//        CLog::pay("WebGift refreshGiftStoreItem giftStore:$giftStore|oid:$oid");
+//
+//        if ($giftStore != null) {
+//            foreach ($giftStore as $giftItemId) {
+//                $itemModel = ConstProc::getGoodsItemConst($giftItemId);
+//                CLog::pay("WebGift refreshGiftStoreItem2 giftItemId:$giftItemId");
+//
+//                if ($itemModel != null) {
+//                    StoreProc::addSeprateItem($itemModel, $req);
+//                } else {
+//                    CLog::pay("WebGift refreshGiftStoreItem3 ERR giftItemId:$giftItemId");
+//                }
+//            }
+//            $mem->delete(MemKey_User::GiftStore($req->zoneid, $oid));
+//        }
+//    }
+//
+//    /**
+//     * 尝试领取黄钻新手礼包
+//     * @param type $user
+//     * @param type $privateState
+//     * @return boolean
+//     */
+//    public static function tryVipNewerGift($user, &$privateState) {
+////1.检查是否为黄钻
+//        if ($user->is_yellow_vip) {
+//# //2.检查是否含有新手礼包标志
+//            if (CommUtil::isPropertyExists($privateState, "vipNewerGift")) {
+//                if ($privateState->vipNewerGift) {# //3.检查是否能够领取
+//                    unset($privateState->vipNewerGift); # //4.剔除新手礼包标志
+//                    return true; //5.返回成功
+//                }
+//            }
+//        }
+//        return false;
+//    }
+//
+//    /**
+//     * 尝试领取黄钻每日礼包
+//     * @param type $user
+//     * @param type $privateState
+//     * @return boolean
+//     */
+//    public static function tryVipDayGift($user, &$privateState) {
+//        if ($user->is_yellow_vip) {//1.检查是否为黄钻
+//            if (CommUtil::isPropertyExists($privateState, "vipDayGift")) {//2.检查黄钻礼包标志是否为真
+//                if ($privateState->vipDayGift) {//3.检查是否能够领取
+//                    $privateState->vipDayGift = false; //4.修改黄钻每日礼包标志
+//                    return true; //5.返回成功
+//                }
+//            }
+//        }
+//        return false;
+//    }
+//
+//    /**
+//     * 客户端确认支付
+//     * @param type $req
+//     * @return \ResponseVo
+//     */
+//    public static function confirmPay($req, $v3) {
+//        $paydb = CPayInit();
+//        $openid = $req->uid; //客户端参数解析
+//        $billArray = $paydb->fetch_array(sprintf(self::PAY_BILL_SELECT, $openid));
+//        if (count($billArray) > 0) {
+//            foreach ($billArray as $billRecord) {
+//                $id = $billRecord['id'];
+//                $ts = now();
+//                $payitem = $billRecord['payitem'];
+//                $token = $billRecord['token'];
+//                $billno = $billRecord['billno'];
+//                $amt = $billRecord['amt'];
+//                if (GAME_ONLINE) {
+//                    $ret = $v3->pay_confirm_delivery($openid, $openkey, $pf, $ts, //
+//                            $payitem, $token, $billno, $amt);
+//                    if ($ret->ret == 0 || $ret->ret == 1069) {// 订单确认的情况
+//                        $dbRet = $paydb->query(sprintf(self::PAY_BILL_DELETE, $id));
+//                        $sqlConfirm = sprintf(self::PAY_BILL_CONFIRM, $openid, $billno, $amt, $payitem, $token);
+//                        $dbRet = $paydb->query($sqlConfirm); // 写订单支付日志
+//                        $log = $billno . "|" . $ret->msg . "[" . $openid . "]已确认支付!";
+//                        $dbRet = WebPayProc::_paylog($paydb, $log);
+//                    }// 订单丢失的情况
+//                    else if ($ret->ret == 1060 || $ret->ret == 1063 || $ret->ret == 1068) {
+//                        $dbRet = $paydb->query(sprintf(self::PAY_BILL_DELETE, $id));
+//                        $sqlLost = sprintf(self::PAY_BILL_LOST, $openid, $billno, $amt, $payitem, $token, $ret->msg);
+//                        $dbRet = $paydb->query($sqlLost); // 写订单支付日志
+//                        $log = $billno . "|" . $ret->msg . "[" . $openid . "]已确认丢失!";
+//                        $dbRet = WebPayProc::_paylog($paydb, $log);
+//                    }
+//                } else {
+//                    $dbRet = $paydb->query(sprintf(self::PAY_BILL_DELETE, $id));
+//                    $sqlConfirm = sprintf(self::PAY_BILL_CONFIRM, $openid, $billno, $amt, $payitem, $token);
+//                    $dbRet = $paydb->query($sqlConfirm); // 写订单支付日志
+//                    $log = $billno . "|" . $ret->msg . "[" . $openid . "]已确认支付!";
+//                    $dbRet = WebPayProc::_paylog($paydb, $log);
+//                }
+//            }
+//        }
+//        $paydb->close();
+//    }
+//
+//    /**
+//     * 插入日志
+//     * @param CDBUtil $paydb
+//     * @param string $log
+//     * @return mixed
+//     */
+//    static function _paylog($paydb, $log) {
+//        return $paydb->query(sprintf(self::PAY_LOG_INSERT, $log));
+//    }
+//
+//    /**
+//     * 获取指定道具的图片Url
+//     * @param GoodsItemModel $item
+//     * @return String 返回字符串
+//     */
+//    private static function _getGoodsImgUrl($item) {
+//        return CDN_HOST . "res/yuanbao3.png";
+//    }
+//
+//}

+ 508 - 506
Gameserver/Amfphp/process/PayProc/YYBPay.php

@@ -1,501 +1,161 @@
 <?php
 
-namespace loyalsoft;
-
-/**
- * Description of YYBPay
- * @version
- *          1.0.0 Created at 2016-4-20. by --gwang
- * @author gwang (mail@wanggangzero.cn)
- * @copyright © 2016-4-20, SJZ LoyalSoft Corporation & gwang. All rights reserved.
- */
-class YYBPay {
-//put your code here
-}
-
-/**
- *  移动支付
- * @history
- *    1. m_pay m_AddUserCash ... 以 m_ 打头的函数是第一版, 完全按照应用宝官方要求托管游戏币的模式开发的.  * 2015年4月23日
- *    2. mn_pay mn_AddUserCash ... 以 mn_ 打头的函数是第二版, 修改为伪托管模式,除了充值的时候跟腾讯通讯,其余时间自己管理游戏币:钻石. * 2015年7月23日
- *    3. 第三版: 独立的游戏币<元宝>, 面向多渠道的充值模式, 拉起充值成功后, 给玩家发放元宝. 游戏内部消费元宝,钻石和金币.
- *       可以用元宝购买金币和钻石.这一版在上面的PayProc中 * 2015年9月23日
- *
- */
-class MobilePayProc {
-
-    /**
-     * Sql语句移动支付插入一条log日志。
-     * @var string
-     */
-    const SQL_M_LOG = "INSERT INTO `tab_mpaylog_%s` (zoneid,type,result,amt,balance,cash,giftedcash,chargedcash,source,oid,itemid) VALUES (%d,%d,%d,%d,%d,%d,%d,%d,'%s','%s','%s')";
-
-    /**
-     * 【移动端】查询账户游戏币余额(v3)
-     * @param Req $req
-     * @param string $source 来源
-     */
-    public static function v3_m_get_Balance($req, $source = "") {
-        if ($req->userInfo->isTest) {
-            return Resp::myRetResponse($req, $req->userInfo->game->user);
-        }
-        $resp = new Resp();
-        $sdkUser = $req->userInfo->sdkUserKey;
-        $user = $req->userInfo->game->user;
-// 客户端参数解析
-        $openid = $req->uid;  // openid
-        $zoneid = $req->zoneid;  // 分区Id
-        $openkey = $sdkUser->access_token;  // openkey|accesstoken
-        $pf = $sdkUser->pf;       // pf
-        $pfkey = $sdkUser->pf_key;    // pfkey
-        $paytoken = $sdkUser->pay_token;  // 手Q客户端获取,微信传空
-        $v3 = CV3Init();
-        $appid = V3_APPID;  # 支付模块,微信和手Q统一使用手Q的appid
-        $ts = now();
-        $v3PayRet = $v3->m_get_balance($sdkUser->platform, $openid, $openkey, $pf, $paytoken, $appid, $pfkey, $ts, $zoneid);
-        $v3->close();
-        $amt = 0;
-        if ($v3PayRet->ret != 0) { //v3其他错误
-            $resp = Resp::err($v3PayRet->ret);
-            $resp->result = $v3PayRet;
-        } else {
-            $amt = $v3PayRet->save_amt - $user->charge_amt;  # 本次充值金额
-            $user->cash = $v3PayRet->balance;
-            $user->charge_amt = $v3PayRet->save_amt;  # 历史
-
-            $user->gift_cash = $v3PayRet->gen_balance;  // 赠送的宝石数量
-            if ($amt > 0 # 充值金额大于0,且首付标志为false才可以   /* 其实腾讯有返 isfirstpay字段 */
-                    && isset($req->userInfo->game->privateState->firstPayGift)   # 无此字段代表已经领取礼包
-                    && !$req->userInfo->game->privateState->firstPayGift) {
-                $req->userInfo->game->privateState->firstPayGift = true;
-            }
-//            self::m_FixUserCash($req);  # 修复(特定)用户钻石数据(端午节系统邮件失误)
-            UserProc::updateUserInfo($req); // 更新玩家数据信息
-
-            $resp = Resp::myRetResponse($req, $user); // 直接将$user的最新值返回给客户端
-        }
-        self::_mPayLog($zoneid, $openid, MLogType::Inquire, $v3PayRet->ret, #
-                $amt, $user->yuanbao, $user->cash, $user->gift_cash, $user->charge_amt, $source);
-        return $resp;
-    }
-
-    /**
-     * 【移动端】扣除游戏币购买道具(V3)
-     * @param Req $req
-     */
-    public static function v3_m_pay($req) {
-        $resp = new Resp();
-        $user = $req->userInfo->game->user; # user引用
-// 客户端参数解析
-        $openid = $req->uid;  // openid
-        $zoneid = $req->zoneid;   // 分区id
-        $openkey = $req->paras[0];  // openkey|accesstoken
-        $pf = $req->paras[1];       // pf
-        $pfkey = $req->paras[2];    // pfkey
-        $paytoken = $req->paras[3];  // 手Q客户端获取 微信传空
-        $itemId = $req->paras[4];  // 道具ID
-
-        $v3 = CV3Init();
-        $appid = V3_APPID;  # 支付模块,微信和手Q统一使用手Q的appid
-        $ts = now();
-        $itemModel = ConstProc::getGoodsItemConst($itemId);    // 取道具的常量数据
-        if ($itemModel == null) { //1.检测是否存在道具的常量数据
-            $resp = Resp::myErrResponse($req, ErrCode::err_const_no);
-        } else {
-            $prize = JsonUtil::decode($itemModel->prize); # 价格
-            if (property_exists($prize, "c") && $prize->c > 0) {// 钻石购买
-                $amt = self::_getItemCashPrize($itemModel); // 道具价格(钻石)
-                $remark = $itemModel->name;
-                if ($amt <= 0) {
-                    $resp = Resp::myErrResponse($req, ErrCode::pay_vipnewerno);
-                } else {
-                    if ($req->userInfo->isTest) {   # 测试用,直接模拟一个支付返回值
-                        $v3PayRet = json_decode(json_encode(array(
-                            'ret' => 0,
-                            'balance' => $user->cash -= $amt
-                        )));
-                    } else {
-                        $v3PayRet = $v3->m_pay($req->userInfo->sdkUserKey->platform, #
-                                $openid, $openkey, $pf, $paytoken, #
-                                $appid, $pfkey, $ts, $zoneid, $amt, $itemId, $remark);
-                    }
-                    $v3->close();
-                    if ($v3PayRet->ret == 1004) { // 余额不足
-                        $resp = Resp::myErrResponse($req, ErrCode::notenough_cash_msg);
-                    } elseif ($v3PayRet->ret != 0) { //v3其他错误
-                        $resp = Resp::myErrResponse($req, $v3PayRet->ret);
-                        $resp->result = $v3PayRet;
-                    } else { // 发货
-                        StoreProc::addSeprateItem($itemModel, $req); // 更新玩家游戏币余额
-                        UserModel::set_Cash($user, $v3PayRet->balance); // 更新玩家数据信息
-                        UserProc::updateUserInfo($req); // 直接将$user的最新值返回给客户端
-                        $resp = Resp::myRetResponse($req, $user);
-                    }
-                    $source = "商城购买-" . $itemModel->name;
-                    self::_mPayLog($req->zoneid, $req->uid, MLogType::Shop, $resp->err, #
-                            $amt, $user->yuanbao, $user->cash, $user->gift_cash, $user->charge_amt, $source, $itemId);
-                }
-            }// 金币购买
-            else if (CommUtil::isPropertyExists($prize, "g") && $prize->g > 0) {
-                if ($req->userInfo->game->user->gold < $prize->g) {
-                    $resp = Resp::myErrResponse($req, ErrCode::notenough_gold_msg);
-                } else {// 发货
-                    StoreProc::addSeprateItem($itemModel, $req); // 更新玩家金币余额
-                    UserModel::Comsume_Gold($user, $prize->g); // 更新玩家数据信息
-                    UserProc::updateUserInfo($req); // 直接将$user的最新值返回给客户端
-                    $resp = Resp::myRetResponse($req, $user);
-                }
-            }// 除了金币和钻石以外还有荣誉点。
-            else if (CommUtil::isPropertyExists($prize, "h") && $prize->h > 0) {
-                if ($user->honour < $prize->h) {
-                    $resp = Resp::myErrResponse($req, ErrCode::notenough_honour);
-                } else {// 发货
-                    StoreProc::addSeprateItem($itemModel, $req); // 更新玩家荣誉值余额
-                    $user->honour -= $prize->h; // 更新玩家数据信息
-                    UserProc::updateUserInfo($req); // 直接将$user的最新值返回给客户端
-                    $resp = Resp::myRetResponse($req, $user);
-                }
-            }
-        }
-        return $resp;
-    }
-
-    /**
-     * 领取首付礼包
-     * @param Req $req
-     * @return Resp
-     */
-    public static function m_GetFirstPayGift($req) {
-        $resp = new Resp();
-        $privateState = $req->userInfo->game->privateState;
-# 客户端参数解析
-        $itemId = glc()->FirstPay_ItemId;
-//  如果已经领取首付礼包
-        if (!CommUtil::isPropertyExists($privateState, "firstPayGift")) {
-            $resp = Resp::myErrResponse($req, ErrCode::pay_firstpaygetted);
-        } elseif ($req->userInfo->game->user->charge_amt <= 0) { //  如果尚未完成首付
-            $resp = Resp::myErrResponse($req, ErrCode::pay_firstpayno_err);
-        } else {
-            $itemModel = ConstProc::getGoodsItemConst($itemId);  # 取物品常量
-            if ($itemModel == null) {//  检测首付礼包是否存在
-                $resp = Resp::myErrResponse($req, ErrCode::err_const_no);
-            } else {
-                unset($privateState->firstPayGift); # .剔除首付标志
-                StoreProc::addSeprateItem($itemModel, $req); #  .发放首付礼包
-                $result = array(# 把玩家最新的仓库数据发给客户端
-                    'itemid' => $itemId
-                );
-// 7.回送成功信息
-                $resp = Resp::myRetResponse($req, $result);
-// 成就触发--获取金币
-                AchievementProc::dealAchievementState($req, $resp, AchievementProc::Gold);
-                UserProc::updateUserInfo($req); # 更新玩家数据
-            }
-        }
-        return $resp;
-    }
-
-//-----------   以下是辅助方法     -------------
-
-    /**
-     * 【移动端】调用V3函数给玩家账号直接增加(赠送)游戏币(钻石),
-     *   赠送的游戏币不参与分成结算,若是造成收入损失,自负。
-     * @param Req $req Description
-     * @param type $amt 数量
-     * @param string $source 来源
-     */
-    public static function v3_m_AddUserCash($req, $amt, $source = "") {
-        $err = ErrCode::ok;
-        if ($req->userInfo->isTest) {  // 跳过支付api
-            $req->userInfo->game->user->cash += $amt;
-            return $err;
-        }
-        if ($amt > 0) {// 防御,若是给出错误数值直接返回
-            $user = $req->userInfo->game->user;
-            $sdkUser = $req->userInfo->sdkUserKey;
-// 参数准备
-            $zoneid = $req->zoneid; # 分区Id
-            $openid = $sdkUser->open_id;
-            $openkey = $sdkUser->access_token;
-            $pf = $sdkUser->pf;
-            $paytoken = $sdkUser->pay_token;
-            $pfkey = $sdkUser->pf_key;
-
-            $ts = now();
-            $v3 = CV3Init();
-            $appid = V3_APPID;  // 微信和QQ统一使用手Q的appId
-            $v3PayRet = $v3->m_present($sdkUser->platform, $openid, $openkey, $pf, # 调用后台接口
-                    $paytoken, $appid, $pfkey, #
-                    $ts, $zoneid, PAY_PRESENTCASH_ACTID, PAY_PRESENTCSAH_GIFTID, $amt);
-            $v3->close();
-            if ($v3PayRet->ret != ErrCode::ok) { //v3其他错误
-                $err = $v3PayRet->ret;
-            } else {
-                self::$m_billno = $v3PayRet->billno;  // 账单号,扣费后其他逻辑失败的话,调用取消扣费接口
-// 更新玩家游戏币余额, 老版本的文档中有balance字段,新的没有说明
-                if (isset($v3PayRet->balance)) {
-                    UserModel::set_Cash($user, $v3PayRet->balance);
-                } else {
-                    UserModel::set_Cash($user, $user->cash + $amt);
-                }
-# 日志
-                self::_mPayLog($req->zoneid, $req->uid, MLogType::Present, $err, #
-                        $amt, $user->yuanbao, $user->cash, $user->gift_cash, $user->charge_amt, $source);
-            }
-        }
-        return $err;
-    }
-
-    /**
-     * 【移动端】扣除玩家游戏币(V3)(Ps.发货逻辑最后执行此步骤)
-     * @param Req $req Description
-     * @param int $amt 扣除数量
-     * @param string $source  (string)备注,扣除来源(模块)
-     * @param string $itemid (option)相关物品id
-     * @return int ErrCode
-     */
-    public static function v3_m_SaveUserCash($req, $amt, $source = "", $itemid = "0") {
-        if ($req->userInfo->isTest) {  # 跳过腾讯api(子豪)
-            $req->userInfo->game->user->cash -= $amt;
-            return ErrCode::ok;
-        }
-        if ($amt <= 0) {  // 防御,数量不可能小于0
-            return ErrCode::ok;
-        }
-
-        $user = $req->userInfo->game->user;
-        $sdkUser = $req->userInfo->sdkUserKey;
-
-        $v3 = CV3Init();
-        $appid = V3_APPID;  # 支付模块,微信和手Q统一使用手Q的appid
-        $ts = now();
-        $zoneid = $req->zoneid;  // 分区Id
-// 调用腾讯api
-        $v3PayRet = $v3->m_pay($sdkUser->platform, $sdkUser->open_id, $sdkUser->access_token, $sdkUser->pf, //
-                $sdkUser->pay_token, $appid, $sdkUser->pf_key, $ts, $zoneid, //
-                $amt, $itemid, $source);
-        $v3->close(); // 关闭
-
-        $err = ErrCode::ok;
-        if ($v3PayRet->ret == 1004) { // 余额不足
-            $err = ErrCode::notenough_cash_msg;
-        } elseif ($v3PayRet->ret != 0) { //v3其他错误
-            $err = $v3PayRet->ret;
-        } else {
-            self::$m_billno = $v3PayRet->billno;  // 账单号,扣费后其他逻辑失败的话,调用取消扣费接口
-// 更新玩家游戏币余额, 老版本的文档中有balance字段,新的没有说明
-            if (property_exists($v3PayRet, "balance")) {
-                UserModel::set_Cash($user, $v3PayRet->balance);
-            } else {
-                UserModel::set_Cash($user, $user->cash - $amt);
-            }
-            $err = ErrCode::ok;
-        }
-        self::_mPayLog($zoneid, $req->uid, MLogType::Save, $err, #
-                $amt, $user->yuanbao, $user->cash, $user->gift_cash, $user->charge_amt, $source);
-        return $err;
-    }
-
-    /**
-     * 缓存一个账单号,如果代码执行过程中出现错误,直接取消扣除游戏币
-     * 注意,若是逻辑不是在一次Request内完成的,那么次订单号需要进行存储
-     * @var string
-     */
-    static $m_billno;
-
-    /**
-     * 【移动端】取消扣除玩家游戏币(V3)
-     * @param Req $req
-     * @param UserModel $user
-     * @param CstSDK_UserModel $sdkUser
-     * @param int $amt
-     * @return int
-     */
-    public static function v3_m_CancelConsumCash($req, $amt) {
-        if ($req->userInfo->isTest) {  // 跳过腾讯api
-            $user->cash += $amt;
-            return ErrCode::ok;
-        }
-        $user = $req->userInfo->game->user;
-        $sdkUser = $req->userInfo->sdkUserKey;
-        $appid = V3_APPID;  # 支付模块,微信和手Q统一使用手Q的appid
-        $ts = now();
-        $zoneid = $req->zoneid;  # 分区Id
-        $v3 = CV3Init();
-        $v3PayRet = $v3->m_cancel_pay($sdkUser->platform, $sdkUser->open_id, $sdkUser->access_token, #
-                $sdkUser->pf, $sdkUser->pay_token, $appid, $sdkUser->pf_key, $ts, //
-                $zoneid, $amt, self::$m_billno);
-        $v3->close(); // 关闭
-        if ($v3PayRet->ret != 0) { //v3其他错误
-            return $v3PayRet->ret;
-        } else {
-// 更新玩家游戏币余额, 老版本的文档中有balance字段,新的没有说明
-            if (property_exists($v3PayRet, "balance")) {
-                UserModel::set_Cash($user, $v3PayRet->balance);
-            } else {
-                UserModel::set_Cash($user, $user->cash + $amt);
-            }
-            return ErrCode::ok;
-        }
-    }
-
-    /**
-     * 取物品的价格(钻石)
-     * @param GoodsItemModel $itemModel
-     */
-    private static function _getItemCashPrize($itemModel) {
-        $c = 0;
-        $prize = JsonUtil::decode($itemModel->prize);
-        if (CommUtil::isPropertyExists($prize, "c")) {
-            $c = $prize->c;
-        }
-        return $c;
-    }
-
-    /**
-     * 插入一条记录
-     * @param int $zoneid
-     * @param string $oid
-     * @param int $type
-     * @param int $amt
-     * @param int $balance
-     * @param int $cash 钻石
-     * @param int $giftedcash
-     * @param int $chargedcash
-     * @param int $source
-     */
-    public static function _mPayLog($zoneid, $oid, $type, $result, $amt, $balance, $cash, $giftedcash, $chargedcash, $source = "srcUnKnown", $itemid = "") {
-//        var_dump(func_get_args());
-//        CLogUtil::print_stack_trace();
-        $month = date("Ym");
-        $sql = sprintf(self::SQL_M_LOG, $month, $zoneid, $type, $result, $amt, $balance, $cash, $giftedcash, $chargedcash, $source, $oid, $itemid);
-        $paydb = CPayInit();
-        $paydb->query($sql);
-        $paydb->close();
-    }
-
-// ----------------new pay proc -------------------------
-//  腾讯支付修改版,不再让钻石存储在腾讯端
-
-    /**
-     * 【移动端】取消扣除玩家游戏币,无v3调用
-     * @param Req $req
-     * @param UserModel $user
-     * @param CstSDK_UserModel $sdkUser
-     * @param int $amt
-     * @return int
-     */
-    public static function mn_CancelConsumCash($req, $amt) {
-        $err = ErrCode::ok;
-        $user = $req->userInfo->game->user;
-        $zoneid = $req->zoneid;  # 分区Id
-        if ($amt > 0) { // 更新玩家游戏币余额, 老版本的文档中有balance字段,新的没有说明
-            UserModel::set_Cash($user, $user->cash + $amt);
-# 记录日志
-            self::_mPayLog($zoneid, $user->oId, MLogType::Present, $err, $amt, $user->yuanbao, #
-                    $user->cash, $user->gift_cash, $user->charge_amt, "<取消订单>" . self::$m_billno);
-        }
-        return $err;
-    }
-
-    /**
-     * 【移动端】扣除玩家游戏币,无V3调用(Ps.发货逻辑最后执行此步骤)
-     * @param Req $req Description
-     * @param int $amt 扣除数量
-     * @param string $source  (string)备注,扣除来源(模块)
-     * @param string $itemid (option)相关物品id
-     * @return int ErrCode
-     */
-    public static function mn_SaveUserCash($req, $amt, $source = "", $itemid = "0") {
-        $err = ErrCode::ok;
-        if ($amt > 0) {  // 防御,数量不可能小于0
-            $user = $req->userInfo->game->user;
-            $zoneid = $req->zoneid;  // 分区Id
-            if ($user->cash < $amt) { // 余额不足
-                $err = ErrCode::notenough_cash_msg;
-            } else {// 更新玩家游戏币余额
-                UserModel::set_Cash($user, $user->cash - $amt);
-                self::$m_billno = date("Y-m-d H:i:is");
-            }
-            self::_mPayLog($zoneid, $req->uid, MLogType::Save, $err, #
-                    $amt, $user->yuanbao, $user->cash, $user->gift_cash, $user->charge_amt, $source);
-        }
-        return $err;
-    }
-
-    /**
-     * 【移动端】给玩家账号直接增加(赠送)游戏币(钻石)(无V3),
-     *   赠送的游戏币不参与分成结算,若是造成收入损失,自负。
-     * @param Req $req Description
-     * @param type $amt 数量
-     */
-    public static function mn_AddUserCash($req, $amt, $source = "") {
-        $err = ErrCode::ok;
-        if ($amt > 0) {// 防御,若是给出错误数值直接返回
-            $user = $req->userInfo->game->user;
-            UserModel::set_Cash($user, $user->cash + $amt);
-            if ($user->cash < 0) {
-                # 输出日志-wqq
-            }
-# 记录日志
-            self::_mPayLog($req->zoneid, $req->uid, MLogType::Present, $err, #
-                    $amt, $user->yuanbao, $user->cash, $user->gift_cash, $user->charge_amt, $source);
-        }
-        return ErrCode::ok;
-    }
-
+//
+//
+//namespace loyalsoft;
+//
+///**
+// * Description of YYBPay
+// * @version
+// *          1.0.0 Created at 2016-4-20. by --gwang
+// * @author gwang (mail@wanggangzero.cn)
+// * @copyright © 2016-4-20, SJZ LoyalSoft Corporation & gwang. All rights reserved.
+// */
+//class YYBPay {
+////put your code here
+//}
+//
+///**
+// *  移动支付
+// * @history
+// *    1. m_pay m_AddUserCash ... 以 m_ 打头的函数是第一版, 完全按照应用宝官方要求托管游戏币的模式开发的.  * 2015年4月23日
+// *    2. mn_pay mn_AddUserCash ... 以 mn_ 打头的函数是第二版, 修改为伪托管模式,除了充值的时候跟腾讯通讯,其余时间自己管理游戏币:钻石. * 2015年7月23日
+// *    3. 第三版: 独立的游戏币<元宝>, 面向多渠道的充值模式, 拉起充值成功后, 给玩家发放元宝. 游戏内部消费元宝,钻石和金币.
+// *       可以用元宝购买金币和钻石.这一版在上面的PayProc中 * 2015年9月23日
+// *
+// */
+//class MobilePayProc {
+//
 //    /**
-//     * 【移动端】扣除游戏币购买道具
-//     * @param RequestVo $req
+//     * Sql语句移动支付插入一条log日志。
+//     * @var string
 //     */
-//    static function mn_pay($req) {
-//        $resp = new ResponseVo();
-//        $user = $req->userInfo->user; # user引用
+//    const SQL_M_LOG = "INSERT INTO `tab_mpaylog_%s` (zoneid,type,result,amt,balance,cash,giftedcash,chargedcash,source,oid,itemid) VALUES (%d,%d,%d,%d,%d,%d,%d,%d,'%s','%s','%s')";
+//
+//    /**
+//     * 【移动端】查询账户游戏币余额(v3)
+//     * @param Req $req
+//     * @param string $source 来源
+//     */
+//    public static function v3_m_get_Balance($req, $source = "") {
+//        if ($req->userInfo->isTest) {
+//            return Resp::myRetResponse($req, $req->userInfo->game->user);
+//        }
+//        $resp = new Resp();
+//        $sdkUser = $req->userInfo->sdkUserKey;
+//        $user = $req->userInfo->game->user;
 //// 客户端参数解析
+//        $openid = $req->uid;  // openid
+//        $zoneid = $req->zoneid;  // 分区Id
+//        $openkey = $sdkUser->access_token;  // openkey|accesstoken
+//        $pf = $sdkUser->pf;       // pf
+//        $pfkey = $sdkUser->pf_key;    // pfkey
+//        $paytoken = $sdkUser->pay_token;  // 手Q客户端获取,微信传空
+//        $v3 = CV3Init();
+//        $appid = V3_APPID;  # 支付模块,微信和手Q统一使用手Q的appid
+//        $ts = now();
+//        $v3PayRet = $v3->m_get_balance($sdkUser->platform, $openid, $openkey, $pf, $paytoken, $appid, $pfkey, $ts, $zoneid);
+//        $v3->close();
+//        $amt = 0;
+//        if ($v3PayRet->ret != 0) { //v3其他错误
+//            $resp = Resp::err($v3PayRet->ret);
+//            $resp->result = $v3PayRet;
+//        } else {
+//            $amt = $v3PayRet->save_amt - $user->charge_amt;  # 本次充值金额
+//            $user->cash = $v3PayRet->balance;
+//            $user->charge_amt = $v3PayRet->save_amt;  # 历史
+//
+//            $user->gift_cash = $v3PayRet->gen_balance;  // 赠送的宝石数量
+//            if ($amt > 0 # 充值金额大于0,且首付标志为false才可以   /* 其实腾讯有返 isfirstpay字段 */
+//                    && isset($req->userInfo->game->privateState->firstPayGift)   # 无此字段代表已经领取礼包
+//                    && !$req->userInfo->game->privateState->firstPayGift) {
+//                $req->userInfo->game->privateState->firstPayGift = true;
+//            }
+////            self::m_FixUserCash($req);  # 修复(特定)用户钻石数据(端午节系统邮件失误)
+//            UserProc::updateUserInfo($req); // 更新玩家数据信息
+//
+//            $resp = Resp::myRetResponse($req, $user); // 直接将$user的最新值返回给客户端
+//        }
+//        self::_mPayLog($zoneid, $openid, MLogType::Inquire, $v3PayRet->ret, #
+//                $amt, $user->yuanbao, $user->cash, $user->gift_cash, $user->charge_amt, $source);
+//        return $resp;
+//    }
+//
+//    /**
+//     * 【移动端】扣除游戏币购买道具(V3)
+//     * @param Req $req
+//     */
+//    public static function v3_m_pay($req) {
+//        $resp = new Resp();
+//        $user = $req->userInfo->game->user; # user引用
+//// 客户端参数解析
+//        $openid = $req->uid;  // openid
+//        $zoneid = $req->zoneid;   // 分区id
+//        $openkey = $req->paras[0];  // openkey|accesstoken
+//        $pf = $req->paras[1];       // pf
+//        $pfkey = $req->paras[2];    // pfkey
+//        $paytoken = $req->paras[3];  // 手Q客户端获取 微信传空
 //        $itemId = $req->paras[4];  // 道具ID
 //
-//        $itemModel = ConstProc::getItemConst($req->mem, $itemId);    // 取道具的常量数据
+//        $v3 = CV3Init();
+//        $appid = V3_APPID;  # 支付模块,微信和手Q统一使用手Q的appid
+//        $ts = now();
+//        $itemModel = ConstProc::getGoodsItemConst($itemId);    // 取道具的常量数据
 //        if ($itemModel == null) { //1.检测是否存在道具的常量数据
-//            $resp = ResponseVo::myErrResponse($req, ErrCode::err_msg_itemnoconst);
+//            $resp = Resp::myErrResponse($req, ErrCode::err_const_no);
 //        } else {
 //            $prize = JsonUtil::decode($itemModel->prize); # 价格
 //            if (property_exists($prize, "c") && $prize->c > 0) {// 钻石购买
 //                $amt = self::_getItemCashPrize($itemModel); // 道具价格(钻石)
+//                $remark = $itemModel->name;
 //                if ($amt <= 0) {
-//                    $resp = ResponseVo::myErrResponse($req, ErrCode::err_pay_vipnewerno);
+//                    $resp = Resp::myErrResponse($req, ErrCode::pay_vipnewerno);
 //                } else {
-//                    if ($user->cash < $amt) { // 余额不足
-//                        $resp = ResponseVo::myErrResponse($req, ErrCode::err_msg_cashnotenough);
+//                    if ($req->userInfo->isTest) {   # 测试用,直接模拟一个支付返回值
+//                        $v3PayRet = json_decode(json_encode(array(
+//                            'ret' => 0,
+//                            'balance' => $user->cash -= $amt
+//                        )));
+//                    } else {
+//                        $v3PayRet = $v3->m_pay($req->userInfo->sdkUserKey->platform, #
+//                                $openid, $openkey, $pf, $paytoken, #
+//                                $appid, $pfkey, $ts, $zoneid, $amt, $itemId, $remark);
+//                    }
+//                    $v3->close();
+//                    if ($v3PayRet->ret == 1004) { // 余额不足
+//                        $resp = Resp::myErrResponse($req, ErrCode::notenough_cash_msg);
+//                    } elseif ($v3PayRet->ret != 0) { //v3其他错误
+//                        $resp = Resp::myErrResponse($req, $v3PayRet->ret);
+//                        $resp->result = $v3PayRet;
 //                    } else { // 发货
 //                        StoreProc::addSeprateItem($itemModel, $req); // 更新玩家游戏币余额
-//                        UserModel::set_Cash($user, $user->cash - $amt); // 更新玩家数据信息
+//                        UserModel::set_Cash($user, $v3PayRet->balance); // 更新玩家数据信息
 //                        UserProc::updateUserInfo($req); // 直接将$user的最新值返回给客户端
-//                        $resp = ResponseVo::myRetResponse($req, $user);
-//# 记录日志
-//                        $source = "商城购买-" . $itemModel->name;
-//                        self::_mPayLog($req->zoneid, $req->oid, MLogType::Shop, $resp->err, #
-//                                $amt, $user->yuanbao, $user->cash, $user->gift_cash, $user->charge_amt, $source, $itemId);
+//                        $resp = Resp::myRetResponse($req, $user);
 //                    }
+//                    $source = "商城购买-" . $itemModel->name;
+//                    self::_mPayLog($req->zoneid, $req->uid, MLogType::Shop, $resp->err, #
+//                            $amt, $user->yuanbao, $user->cash, $user->gift_cash, $user->charge_amt, $source, $itemId);
 //                }
 //            }// 金币购买
 //            else if (CommUtil::isPropertyExists($prize, "g") && $prize->g > 0) {
-//                if ($req->userInfo->user->gold < $prize->g) {
-//                    $resp = ResponseVo::myErrResponse($req, ErrCode::err_msg_goldnotenough);
+//                if ($req->userInfo->game->user->gold < $prize->g) {
+//                    $resp = Resp::myErrResponse($req, ErrCode::notenough_gold_msg);
 //                } else {// 发货
 //                    StoreProc::addSeprateItem($itemModel, $req); // 更新玩家金币余额
 //                    UserModel::Comsume_Gold($user, $prize->g); // 更新玩家数据信息
 //                    UserProc::updateUserInfo($req); // 直接将$user的最新值返回给客户端
-//                    $resp = ResponseVo::myRetResponse($req, $user);
+//                    $resp = Resp::myRetResponse($req, $user);
 //                }
 //            }// 除了金币和钻石以外还有荣誉点。
 //            else if (CommUtil::isPropertyExists($prize, "h") && $prize->h > 0) {
 //                if ($user->honour < $prize->h) {
-//                    $resp = ResponseVo::myErrResponse($req, ErrCode::err_msg_honournotenough);
+//                    $resp = Resp::myErrResponse($req, ErrCode::notenough_honour);
 //                } else {// 发货
 //                    StoreProc::addSeprateItem($itemModel, $req); // 更新玩家荣誉值余额
-//                    $user->honour-=$prize->h; // 更新玩家数据信息
+//                    $user->honour -= $prize->h; // 更新玩家数据信息
 //                    UserProc::updateUserInfo($req); // 直接将$user的最新值返回给客户端
-//                    $resp = ResponseVo::myRetResponse($req, $user);
+//                    $resp = Resp::myRetResponse($req, $user);
 //                }
 //            }
 //        }
@@ -503,54 +163,396 @@ class MobilePayProc {
 //    }
 //
 //    /**
-//     * 【移动端】查询账户游戏币余额
-//     * @history
-//     *      2015-7-6 改动思路, 不直接拿api返回值中的balance更新玩家的钻石余额,
-//     *               采用计算相对值的方法计算距离上次更新,玩家是否有新的充值,
-//     *               $amt>0,则代表有新的充值,将$amt更新到玩家账户.
-//     * @param RequestVo $req
+//     * 领取首付礼包
+//     * @param Req $req
+//     * @return Resp
+//     */
+//    public static function m_GetFirstPayGift($req) {
+//        $resp = new Resp();
+//        $privateState = $req->userInfo->game->privateState;
+//# 客户端参数解析
+//        $itemId = glc()->FirstPay_ItemId;
+////  如果已经领取首付礼包
+//        if (!CommUtil::isPropertyExists($privateState, "firstPayGift")) {
+//            $resp = Resp::myErrResponse($req, ErrCode::pay_firstpaygetted);
+//        } elseif ($req->userInfo->game->user->charge_amt <= 0) { //  如果尚未完成首付
+//            $resp = Resp::myErrResponse($req, ErrCode::pay_firstpayno_err);
+//        } else {
+//            $itemModel = ConstProc::getGoodsItemConst($itemId);  # 取物品常量
+//            if ($itemModel == null) {//  检测首付礼包是否存在
+//                $resp = Resp::myErrResponse($req, ErrCode::err_const_no);
+//            } else {
+//                unset($privateState->firstPayGift); # .剔除首付标志
+//                StoreProc::addSeprateItem($itemModel, $req); #  .发放首付礼包
+//                $result = array(# 把玩家最新的仓库数据发给客户端
+//                    'itemid' => $itemId
+//                );
+//// 7.回送成功信息
+//                $resp = Resp::myRetResponse($req, $result);
+//// 成就触发--获取金币
+//                AchievementProc::dealAchievementState($req, $resp, AchievementProc::Gold);
+//                UserProc::updateUserInfo($req); # 更新玩家数据
+//            }
+//        }
+//        return $resp;
+//    }
+//
+////-----------   以下是辅助方法     -------------
+//
+//    /**
+//     * 【移动端】调用V3函数给玩家账号直接增加(赠送)游戏币(钻石),
+//     *   赠送的游戏币不参与分成结算,若是造成收入损失,自负。
+//     * @param Req $req Description
+//     * @param type $amt 数量
 //     * @param string $source 来源
 //     */
-//    static function mn_get_Balance($req, $source = "") {
-//        if ($req->userInfo->isTest) {
-//            return ResponseVo::myRetResponse($req, $req->userInfo->user);
+//    public static function v3_m_AddUserCash($req, $amt, $source = "") {
+//        $err = ErrCode::ok;
+//        if ($req->userInfo->isTest) {  // 跳过支付api
+//            $req->userInfo->game->user->cash += $amt;
+//            return $err;
+//        }
+//        if ($amt > 0) {// 防御,若是给出错误数值直接返回
+//            $user = $req->userInfo->game->user;
+//            $sdkUser = $req->userInfo->sdkUserKey;
+//// 参数准备
+//            $zoneid = $req->zoneid; # 分区Id
+//            $openid = $sdkUser->open_id;
+//            $openkey = $sdkUser->access_token;
+//            $pf = $sdkUser->pf;
+//            $paytoken = $sdkUser->pay_token;
+//            $pfkey = $sdkUser->pf_key;
+//
+//            $ts = now();
+//            $v3 = CV3Init();
+//            $appid = V3_APPID;  // 微信和QQ统一使用手Q的appId
+//            $v3PayRet = $v3->m_present($sdkUser->platform, $openid, $openkey, $pf, # 调用后台接口
+//                    $paytoken, $appid, $pfkey, #
+//                    $ts, $zoneid, PAY_PRESENTCASH_ACTID, PAY_PRESENTCSAH_GIFTID, $amt);
+//            $v3->close();
+//            if ($v3PayRet->ret != ErrCode::ok) { //v3其他错误
+//                $err = $v3PayRet->ret;
+//            } else {
+//                self::$m_billno = $v3PayRet->billno;  // 账单号,扣费后其他逻辑失败的话,调用取消扣费接口
+//// 更新玩家游戏币余额, 老版本的文档中有balance字段,新的没有说明
+//                if (isset($v3PayRet->balance)) {
+//                    UserModel::set_Cash($user, $v3PayRet->balance);
+//                } else {
+//                    UserModel::set_Cash($user, $user->cash + $amt);
+//                }
+//# 日志
+//                self::_mPayLog($req->zoneid, $req->uid, MLogType::Present, $err, #
+//                        $amt, $user->yuanbao, $user->cash, $user->gift_cash, $user->charge_amt, $source);
+//            }
+//        }
+//        return $err;
+//    }
+//
+//    /**
+//     * 【移动端】扣除玩家游戏币(V3)(Ps.发货逻辑最后执行此步骤)
+//     * @param Req $req Description
+//     * @param int $amt 扣除数量
+//     * @param string $source  (string)备注,扣除来源(模块)
+//     * @param string $itemid (option)相关物品id
+//     * @return int ErrCode
+//     */
+//    public static function v3_m_SaveUserCash($req, $amt, $source = "", $itemid = "0") {
+//        if ($req->userInfo->isTest) {  # 跳过腾讯api(子豪)
+//            $req->userInfo->game->user->cash -= $amt;
+//            return ErrCode::ok;
+//        }
+//        if ($amt <= 0) {  // 防御,数量不可能小于0
+//            return ErrCode::ok;
 //        }
-//        $resp = new ResponseVo();
+//
+//        $user = $req->userInfo->game->user;
 //        $sdkUser = $req->userInfo->sdkUserKey;
-//        $user = $req->userInfo->user;
-//// 客户端参数解析
-//        $openid = $req->oid;  // openid
-//        $zoneid = $req->zoneid;  // 分区Id
-//        $openkey = $sdkUser->access_token;  // openkey|accesstoken
-//        $pf = $sdkUser->pf;       // pf
-//        $pfkey = $sdkUser->pf_key;    // pfkey
-//        $paytoken = $sdkUser->pay_token;  // 手Q客户端获取,微信传空
+//
 //        $v3 = CV3Init();
 //        $appid = V3_APPID;  # 支付模块,微信和手Q统一使用手Q的appid
-//        $ts = TimeUtil::tsCurrent();
-//        $v3PayRet = $v3->m_get_balance($sdkUser->platform, $openid, $openkey, $pf, $paytoken, $appid, $pfkey, $ts, $zoneid);
-//        $v3->close();
-//        $amt = 0;
-//        if ($v3PayRet->ret != 0) { //v3其他错误
-//            $resp = ResponseVo::errResponse($req->oid, $req->msgid, $v3PayRet->ret);
-//            $resp->result = $v3PayRet;
+//        $ts = now();
+//        $zoneid = $req->zoneid;  // 分区Id
+//// 调用腾讯api
+//        $v3PayRet = $v3->m_pay($sdkUser->platform, $sdkUser->open_id, $sdkUser->access_token, $sdkUser->pf, //
+//                $sdkUser->pay_token, $appid, $sdkUser->pf_key, $ts, $zoneid, //
+//                $amt, $itemid, $source);
+//        $v3->close(); // 关闭
+//
+//        $err = ErrCode::ok;
+//        if ($v3PayRet->ret == 1004) { // 余额不足
+//            $err = ErrCode::notenough_cash_msg;
+//        } elseif ($v3PayRet->ret != 0) { //v3其他错误
+//            $err = $v3PayRet->ret;
 //        } else {
-//            $amt = $v3PayRet->save_amt - $user->charge_amt;  # 本次充值金额 = v3提供的历史充值金额 - 玩家记录的历史充值金额
-//            if ($amt > 0) {
-//                $user->cash +=$amt;  # $v3PayRet->balance;
-//                $user->charge_amt = $v3PayRet->save_amt;  # 更新历史充值金额
-//                $user->gift_cash = $v3PayRet->gen_balance;  // 赠送的宝石数量
-//                if (isset($req->userInfo->game->privateState->firstPayGift)   # 无此字段代表已经领取礼包
-//                        && !$req->userInfo->game->privateState->firstPayGift) {
-//                    $req->userInfo->game->privateState->firstPayGift = true;
-//                }
+//            self::$m_billno = $v3PayRet->billno;  // 账单号,扣费后其他逻辑失败的话,调用取消扣费接口
+//// 更新玩家游戏币余额, 老版本的文档中有balance字段,新的没有说明
+//            if (property_exists($v3PayRet, "balance")) {
+//                UserModel::set_Cash($user, $v3PayRet->balance);
+//            } else {
+//                UserModel::set_Cash($user, $user->cash - $amt);
 //            }
-////            self::m_FixUserCash($req);  # 修复(特定)用户钻石数据(端午节系统邮件失误)
-//            UserProc::updateUserInfo($req); // 更新玩家数据信息
-//            $resp = ResponseVo::myRetResponse($req, $user); // 直接将$user的最新值返回给客户端
+//            $err = ErrCode::ok;
 //        }
-//        self::_mPayLog($zoneid, $openid, MLogType::Inquire, $v3PayRet->ret, #
+//        self::_mPayLog($zoneid, $req->uid, MLogType::Save, $err, #
 //                $amt, $user->yuanbao, $user->cash, $user->gift_cash, $user->charge_amt, $source);
-//        return $resp;
+//        return $err;
 //    }
-}
+//
+//    /**
+//     * 缓存一个账单号,如果代码执行过程中出现错误,直接取消扣除游戏币
+//     * 注意,若是逻辑不是在一次Request内完成的,那么次订单号需要进行存储
+//     * @var string
+//     */
+//    static $m_billno;
+//
+//    /**
+//     * 【移动端】取消扣除玩家游戏币(V3)
+//     * @param Req $req
+//     * @param UserModel $user
+//     * @param CstSDK_UserModel $sdkUser
+//     * @param int $amt
+//     * @return int
+//     */
+//    public static function v3_m_CancelConsumCash($req, $amt) {
+//        if ($req->userInfo->isTest) {  // 跳过腾讯api
+//            $user->cash += $amt;
+//            return ErrCode::ok;
+//        }
+//        $user = $req->userInfo->game->user;
+//        $sdkUser = $req->userInfo->sdkUserKey;
+//        $appid = V3_APPID;  # 支付模块,微信和手Q统一使用手Q的appid
+//        $ts = now();
+//        $zoneid = $req->zoneid;  # 分区Id
+//        $v3 = CV3Init();
+//        $v3PayRet = $v3->m_cancel_pay($sdkUser->platform, $sdkUser->open_id, $sdkUser->access_token, #
+//                $sdkUser->pf, $sdkUser->pay_token, $appid, $sdkUser->pf_key, $ts, //
+//                $zoneid, $amt, self::$m_billno);
+//        $v3->close(); // 关闭
+//        if ($v3PayRet->ret != 0) { //v3其他错误
+//            return $v3PayRet->ret;
+//        } else {
+//// 更新玩家游戏币余额, 老版本的文档中有balance字段,新的没有说明
+//            if (property_exists($v3PayRet, "balance")) {
+//                UserModel::set_Cash($user, $v3PayRet->balance);
+//            } else {
+//                UserModel::set_Cash($user, $user->cash + $amt);
+//            }
+//            return ErrCode::ok;
+//        }
+//    }
+//
+//    /**
+//     * 取物品的价格(钻石)
+//     * @param GoodsItemModel $itemModel
+//     */
+//    private static function _getItemCashPrize($itemModel) {
+//        $c = 0;
+//        $prize = JsonUtil::decode($itemModel->prize);
+//        if (CommUtil::isPropertyExists($prize, "c")) {
+//            $c = $prize->c;
+//        }
+//        return $c;
+//    }
+//
+//    /**
+//     * 插入一条记录
+//     * @param int $zoneid
+//     * @param string $oid
+//     * @param int $type
+//     * @param int $amt
+//     * @param int $balance
+//     * @param int $cash 钻石
+//     * @param int $giftedcash
+//     * @param int $chargedcash
+//     * @param int $source
+//     */
+//    public static function _mPayLog($zoneid, $oid, $type, $result, $amt, $balance, $cash, $giftedcash, $chargedcash, $source = "srcUnKnown", $itemid = "") {
+////        var_dump(func_get_args());
+////        CLogUtil::print_stack_trace();
+//        $month = date("Ym");
+//        $sql = sprintf(self::SQL_M_LOG, $month, $zoneid, $type, $result, $amt, $balance, $cash, $giftedcash, $chargedcash, $source, $oid, $itemid);
+//        $paydb = CPayInit();
+//        $paydb->query($sql);
+//        $paydb->close();
+//    }
+//
+//// ----------------new pay proc -------------------------
+////  腾讯支付修改版,不再让钻石存储在腾讯端
+//
+//    /**
+//     * 【移动端】取消扣除玩家游戏币,无v3调用
+//     * @param Req $req
+//     * @param UserModel $user
+//     * @param CstSDK_UserModel $sdkUser
+//     * @param int $amt
+//     * @return int
+//     */
+//    public static function mn_CancelConsumCash($req, $amt) {
+//        $err = ErrCode::ok;
+//        $user = $req->userInfo->game->user;
+//        $zoneid = $req->zoneid;  # 分区Id
+//        if ($amt > 0) { // 更新玩家游戏币余额, 老版本的文档中有balance字段,新的没有说明
+//            UserModel::set_Cash($user, $user->cash + $amt);
+//# 记录日志
+//            self::_mPayLog($zoneid, $user->oId, MLogType::Present, $err, $amt, $user->yuanbao, #
+//                    $user->cash, $user->gift_cash, $user->charge_amt, "<取消订单>" . self::$m_billno);
+//        }
+//        return $err;
+//    }
+//
+//    /**
+//     * 【移动端】扣除玩家游戏币,无V3调用(Ps.发货逻辑最后执行此步骤)
+//     * @param Req $req Description
+//     * @param int $amt 扣除数量
+//     * @param string $source  (string)备注,扣除来源(模块)
+//     * @param string $itemid (option)相关物品id
+//     * @return int ErrCode
+//     */
+//    public static function mn_SaveUserCash($req, $amt, $source = "", $itemid = "0") {
+//        $err = ErrCode::ok;
+//        if ($amt > 0) {  // 防御,数量不可能小于0
+//            $user = $req->userInfo->game->user;
+//            $zoneid = $req->zoneid;  // 分区Id
+//            if ($user->cash < $amt) { // 余额不足
+//                $err = ErrCode::notenough_cash_msg;
+//            } else {// 更新玩家游戏币余额
+//                UserModel::set_Cash($user, $user->cash - $amt);
+//                self::$m_billno = date("Y-m-d H:i:is");
+//            }
+//            self::_mPayLog($zoneid, $req->uid, MLogType::Save, $err, #
+//                    $amt, $user->yuanbao, $user->cash, $user->gift_cash, $user->charge_amt, $source);
+//        }
+//        return $err;
+//    }
+//
+//    /**
+//     * 【移动端】给玩家账号直接增加(赠送)游戏币(钻石)(无V3),
+//     *   赠送的游戏币不参与分成结算,若是造成收入损失,自负。
+//     * @param Req $req Description
+//     * @param type $amt 数量
+//     */
+//    public static function mn_AddUserCash($req, $amt, $source = "") {
+//        $err = ErrCode::ok;
+//        if ($amt > 0) {// 防御,若是给出错误数值直接返回
+//            $user = $req->userInfo->game->user;
+//            UserModel::set_Cash($user, $user->cash + $amt);
+//            if ($user->cash < 0) {
+//                # 输出日志-wqq
+//            }
+//# 记录日志
+//            self::_mPayLog($req->zoneid, $req->uid, MLogType::Present, $err, #
+//                    $amt, $user->yuanbao, $user->cash, $user->gift_cash, $user->charge_amt, $source);
+//        }
+//        return ErrCode::ok;
+//    }
+//
+////    /**
+////     * 【移动端】扣除游戏币购买道具
+////     * @param RequestVo $req
+////     */
+////    static function mn_pay($req) {
+////        $resp = new ResponseVo();
+////        $user = $req->userInfo->user; # user引用
+////// 客户端参数解析
+////        $itemId = $req->paras[4];  // 道具ID
+////
+////        $itemModel = ConstProc::getItemConst($req->mem, $itemId);    // 取道具的常量数据
+////        if ($itemModel == null) { //1.检测是否存在道具的常量数据
+////            $resp = ResponseVo::myErrResponse($req, ErrCode::err_msg_itemnoconst);
+////        } else {
+////            $prize = JsonUtil::decode($itemModel->prize); # 价格
+////            if (property_exists($prize, "c") && $prize->c > 0) {// 钻石购买
+////                $amt = self::_getItemCashPrize($itemModel); // 道具价格(钻石)
+////                if ($amt <= 0) {
+////                    $resp = ResponseVo::myErrResponse($req, ErrCode::err_pay_vipnewerno);
+////                } else {
+////                    if ($user->cash < $amt) { // 余额不足
+////                        $resp = ResponseVo::myErrResponse($req, ErrCode::err_msg_cashnotenough);
+////                    } else { // 发货
+////                        StoreProc::addSeprateItem($itemModel, $req); // 更新玩家游戏币余额
+////                        UserModel::set_Cash($user, $user->cash - $amt); // 更新玩家数据信息
+////                        UserProc::updateUserInfo($req); // 直接将$user的最新值返回给客户端
+////                        $resp = ResponseVo::myRetResponse($req, $user);
+////# 记录日志
+////                        $source = "商城购买-" . $itemModel->name;
+////                        self::_mPayLog($req->zoneid, $req->oid, MLogType::Shop, $resp->err, #
+////                                $amt, $user->yuanbao, $user->cash, $user->gift_cash, $user->charge_amt, $source, $itemId);
+////                    }
+////                }
+////            }// 金币购买
+////            else if (CommUtil::isPropertyExists($prize, "g") && $prize->g > 0) {
+////                if ($req->userInfo->user->gold < $prize->g) {
+////                    $resp = ResponseVo::myErrResponse($req, ErrCode::err_msg_goldnotenough);
+////                } else {// 发货
+////                    StoreProc::addSeprateItem($itemModel, $req); // 更新玩家金币余额
+////                    UserModel::Comsume_Gold($user, $prize->g); // 更新玩家数据信息
+////                    UserProc::updateUserInfo($req); // 直接将$user的最新值返回给客户端
+////                    $resp = ResponseVo::myRetResponse($req, $user);
+////                }
+////            }// 除了金币和钻石以外还有荣誉点。
+////            else if (CommUtil::isPropertyExists($prize, "h") && $prize->h > 0) {
+////                if ($user->honour < $prize->h) {
+////                    $resp = ResponseVo::myErrResponse($req, ErrCode::err_msg_honournotenough);
+////                } else {// 发货
+////                    StoreProc::addSeprateItem($itemModel, $req); // 更新玩家荣誉值余额
+////                    $user->honour-=$prize->h; // 更新玩家数据信息
+////                    UserProc::updateUserInfo($req); // 直接将$user的最新值返回给客户端
+////                    $resp = ResponseVo::myRetResponse($req, $user);
+////                }
+////            }
+////        }
+////        return $resp;
+////    }
+////
+////    /**
+////     * 【移动端】查询账户游戏币余额
+////     * @history
+////     *      2015-7-6 改动思路, 不直接拿api返回值中的balance更新玩家的钻石余额,
+////     *               采用计算相对值的方法计算距离上次更新,玩家是否有新的充值,
+////     *               $amt>0,则代表有新的充值,将$amt更新到玩家账户.
+////     * @param RequestVo $req
+////     * @param string $source 来源
+////     */
+////    static function mn_get_Balance($req, $source = "") {
+////        if ($req->userInfo->isTest) {
+////            return ResponseVo::myRetResponse($req, $req->userInfo->user);
+////        }
+////        $resp = new ResponseVo();
+////        $sdkUser = $req->userInfo->sdkUserKey;
+////        $user = $req->userInfo->user;
+////// 客户端参数解析
+////        $openid = $req->oid;  // openid
+////        $zoneid = $req->zoneid;  // 分区Id
+////        $openkey = $sdkUser->access_token;  // openkey|accesstoken
+////        $pf = $sdkUser->pf;       // pf
+////        $pfkey = $sdkUser->pf_key;    // pfkey
+////        $paytoken = $sdkUser->pay_token;  // 手Q客户端获取,微信传空
+////        $v3 = CV3Init();
+////        $appid = V3_APPID;  # 支付模块,微信和手Q统一使用手Q的appid
+////        $ts = TimeUtil::tsCurrent();
+////        $v3PayRet = $v3->m_get_balance($sdkUser->platform, $openid, $openkey, $pf, $paytoken, $appid, $pfkey, $ts, $zoneid);
+////        $v3->close();
+////        $amt = 0;
+////        if ($v3PayRet->ret != 0) { //v3其他错误
+////            $resp = ResponseVo::errResponse($req->oid, $req->msgid, $v3PayRet->ret);
+////            $resp->result = $v3PayRet;
+////        } else {
+////            $amt = $v3PayRet->save_amt - $user->charge_amt;  # 本次充值金额 = v3提供的历史充值金额 - 玩家记录的历史充值金额
+////            if ($amt > 0) {
+////                $user->cash +=$amt;  # $v3PayRet->balance;
+////                $user->charge_amt = $v3PayRet->save_amt;  # 更新历史充值金额
+////                $user->gift_cash = $v3PayRet->gen_balance;  // 赠送的宝石数量
+////                if (isset($req->userInfo->game->privateState->firstPayGift)   # 无此字段代表已经领取礼包
+////                        && !$req->userInfo->game->privateState->firstPayGift) {
+////                    $req->userInfo->game->privateState->firstPayGift = true;
+////                }
+////            }
+//////            self::m_FixUserCash($req);  # 修复(特定)用户钻石数据(端午节系统邮件失误)
+////            UserProc::updateUserInfo($req); // 更新玩家数据信息
+////            $resp = ResponseVo::myRetResponse($req, $user); // 直接将$user的最新值返回给客户端
+////        }
+////        self::_mPayLog($zoneid, $openid, MLogType::Inquire, $v3PayRet->ret, #
+////                $amt, $user->yuanbao, $user->cash, $user->gift_cash, $user->charge_amt, $source);
+////        return $resp;
+////    }
+//}

+ 1 - 1
Gameserver/Amfphp/process/PayProc/YuanBaoPayProc.php

@@ -51,7 +51,7 @@ class YuanBaoPayProc {
         $paytype = $req->paras[0];  // 付费类型 3.元宝, 2. 钻石, 1. 金币,
         $itemId = $req->paras[1];  // 道具ID
 
-        $itemModel = ConstProc::getGoodsItemConst($itemId);    // 取道具的常量数据
+        $itemModel = CGameConfig::item_getItem($itemId);                        # 取道具的常量数据
         if ($itemModel == null) { //1.检测是否存在道具的常量数据
             $resp = Resp::err(ErrCode::err_const_no);
         } else {

+ 1 - 1
Gameserver/Amfphp/process/StatProc.php

@@ -43,7 +43,7 @@ class StatProc {
         }
         $redis = gMem();
 
-        if ($tarStep == 0) {                                                    //  跳过新手引导
+        if ($tarStep == 0) {                                                    #  跳过新手引导
             $redis->hincrby(MemKey_Stat::UserGuidSkip_Day($tsBirth, $zoneid), $currentStep);
             $redis->hincrby(MemKey_Stat::UserGuidSkip_Week($tsBirth, $zoneid), $currentStep);
             $redis->hincrby(MemKey_Stat::UserGuidSkip_Month($tsBirth, $zoneid), $currentStep);

+ 110 - 223
Gameserver/Amfphp/process/StoreProc.php

@@ -28,12 +28,12 @@ class StoreProc {
                 return StoreProc::useItem($req);
             case CmdCode::cmd_store_refresh:                                    # 6405 获取最新的仓库数据
                 return StoreProc::refreshStore($req);
-            case CmdCode::cmd_store_decomposeItem:                              # 6406 分解道具
-                return StoreProc::decomposeItem($req);
-            case CmdCode::cmd_store_ItemUpgrade:                                # 6408 装备升级
-                return StoreProc::ItemUpgrade($req);
-            case CmdCode::cmd_store_GemCompose:                                 # 6408 装备合成
-                return StoreProc::composeItem($req);
+//            case CmdCode::cmd_store_decomposeItem:                              # 6406 分解道具
+//                return StoreProc::decomposeItem($req);
+//            case CmdCode::cmd_store_ItemUpgrade:                                # 6408 装备升级
+//                return StoreProc::ItemUpgrade($req);
+//            case CmdCode::cmd_store_GemCompose:                                 # 6408 装备合成
+//                return StoreProc::composeItem($req);
 //
             case CmdCode::cmd_store_WearEquip:                                  # 6410 给英雄穿装备
                 return StoreProc::WearEquipToHero($req);
@@ -46,12 +46,11 @@ class StoreProc {
 // 
             case CmdCode::cmd_store_AddMaxPacketNum:                            # 6412 扩展包裹格子数量
                 return StoreProc::AddPacketNum($req);
-            case CmdCode::cmd_store_MeltEquip:                                  # 6413 装备融合
-                Err(ErrCode::err_method_obsoleted);
-//                return StoreProc::MeltEquip($req);
-            case CmdCode::cmd_store_PiecesCompose:                              # 6415 碎片合成
-                return StoreProc::composePieces($req);
-
+//            case CmdCode::cmd_store_MeltEquip:                                  # 6413 装备融合
+//                Err(ErrCode::err_method_obsoleted);
+////                return StoreProc::MeltEquip($req);
+//            case CmdCode::cmd_store_PiecesCompose:                              # 6415 碎片合成
+//                return StoreProc::composePieces($req);
             case CmdCode::cmd_store_Testcmd:                                    # 6407 测试方法
                 return StoreProc::Test($req);
             default:
@@ -105,105 +104,104 @@ class StoreProc {
 
 //
 // <editor-fold defaultstate="collapsed" desc="    物品升级    ">
-
-    /**
-     * [6408] 物品的升级
-     * @param Req $req
-     * @return type
-     */
-    static function ItemUpgrade($req) {
-        $mem = $req->mem;
-        $uid = $req->paras[0]; //获取物品uid
-        $money = $req->paras[1]; //需要的手工费
-        $resp = new Resp();
-        $user = $req->userInfo->game; # user引用
-        $ary = $req->paras[3]; //获取物品的结构数组
-        foreach ($ary as $value) {
-            $itemId = $value[1];
-            $uid = $value[2];
-            if ($uid < 1) {
-                Err(ErrCode::paras_err);
-            }
-
-            $ok = StoreProc::removeEquipFromStore($uid, $itemId, $req); # 从背包移除
-            if (!$ok) {//1.如果背包道具移出时出错,则直接返回错误
-                Err(ErrCode::store_removefail);
-            }
-            $item = GameConfig::item_getItem($itemId);                        //ConstProc::getItemConst($itemId);
-            if ($item == null) { //2.检测是否存在装备的原始数据
-                Err(ErrCode::err_const_no);
-            }
-
-            $ret = array('resp' => "succeed!");
-            $resp = Resp::ok($ret); //返回必须是object
-        }
-        $bDeal = UserGameModel::Consume_Gold($user, $money);
-        if ($bDeal) {
-
-            ActiveProc::ChangeTaskCount($req);
-            $result = array(
-                'store' => $req->userInfo->game->store,
-                'resp' => "succeed!"
-            );
-            $resp = Resp::ok($result);
-        } else {
-            Err(ErrCode::notenough_gold_msg);
-        }
-
-
-        if (0 == $resp->err) {
-            StoreProc:: UpdateItem($req);
-            $result = array(
-                'store' => $req->userInfo->game->store,
-                'resp' => "succeed!"
-            );
-            $resp = Resp::ok($result);
-        }
-
-        StoreProc::CheckItemNum($req);
-
-        return $resp;
-    }
-
-    /**
-     * 更新单个物品属性
-     * @param Req $req
-     */
-    private static function UpdateItem($req) {
-        $store = $req->userInfo->game->store;
-        $uid = $req->paras[0]; //获取物品uid
-        $obj = $req->paras[2]; //获取物品的结构数组
-        $itemLevel = 0;
-        $bUplevel = false;
-        foreach ($obj as $key => $value) {
-            if ($key === "level") {
-                if (CommUtil::isPropertyExists($store->equipment->$uid, $key)) {
-                    if ($store->equipment->$uid->$key < $value) {
-                        $bUplevel = true;
-                        $itemLevel = $value;
-                    }
-                } else {
-                    if ($value > 1) {
-                        $bUplevel = true;
-                        $itemLevel = $value;
-                    }
-                }
-            }
-            if ($bUplevel) {
-                $item = GameConfig::item_getItem($store->equipment->$uid->typeId);
-                if ($item == null) { //2.检测是否存在装备的原始数据
-                    Err(ErrCode::err_const_no);
-                }
-                // 推送系统消息
-                SystemProc::insertWeapon_promoteUp($req->zoneid, $req->uid, $req->userInfo->game->name, $item->name, $itemLevel);
-            }
-            $store->equipment->$uid->$key = $value;
-        }
-        UserProc::updateUserInfo($req);
-        $ret = array('resp' => "succeed!");
-        $resp = Resp::ok($ret); //返回必须是object
-        return $resp;
-    }
+//    /**
+//     * [6408] 物品的升级
+//     * @param Req $req
+//     * @return type
+//     */
+//    static function ItemUpgrade($req) {
+//        $mem = $req->mem;
+//        $uid = $req->paras[0]; //获取物品uid
+//        $money = $req->paras[1]; //需要的手工费
+//        $resp = new Resp();
+//        $user = $req->userInfo->game; # user引用
+//        $ary = $req->paras[3]; //获取物品的结构数组
+//        foreach ($ary as $value) {
+//            $itemId = $value[1];
+//            $uid = $value[2];
+//            if ($uid < 1) {
+//                Err(ErrCode::paras_err);
+//            }
+//
+//            $ok = StoreProc::removeEquipFromStore($uid, $itemId, $req); # 从背包移除
+//            if (!$ok) {//1.如果背包道具移出时出错,则直接返回错误
+//                Err(ErrCode::store_removefail);
+//            }
+//            $item = GameConfig::item_getItem($itemId);                        //ConstProc::getItemConst($itemId);
+//            if ($item == null) { //2.检测是否存在装备的原始数据
+//                Err(ErrCode::err_const_no);
+//            }
+//
+//            $ret = array('resp' => "succeed!");
+//            $resp = Resp::ok($ret); //返回必须是object
+//        }
+//        $bDeal = UserGameModel::Consume_Gold($user, $money);
+//        if ($bDeal) {
+//
+//            ActiveProc::ChangeTaskCount($req);
+//            $result = array(
+//                'store' => $req->userInfo->game->store,
+//                'resp' => "succeed!"
+//            );
+//            $resp = Resp::ok($result);
+//        } else {
+//            Err(ErrCode::notenough_gold_msg);
+//        }
+//
+//
+//        if (0 == $resp->err) {
+//            StoreProc:: UpdateItem($req);
+//            $result = array(
+//                'store' => $req->userInfo->game->store,
+//                'resp' => "succeed!"
+//            );
+//            $resp = Resp::ok($result);
+//        }
+//
+//        StoreProc::CheckItemNum($req);
+//
+//        return $resp;
+//    }
+//
+//    /**
+//     * 更新单个物品属性
+//     * @param Req $req
+//     */
+//    private static function UpdateItem($req) {
+//        $store = $req->userInfo->game->store;
+//        $uid = $req->paras[0]; //获取物品uid
+//        $obj = $req->paras[2]; //获取物品的结构数组
+//        $itemLevel = 0;
+//        $bUplevel = false;
+//        foreach ($obj as $key => $value) {
+//            if ($key === "level") {
+//                if (CommUtil::isPropertyExists($store->equipment->$uid, $key)) {
+//                    if ($store->equipment->$uid->$key < $value) {
+//                        $bUplevel = true;
+//                        $itemLevel = $value;
+//                    }
+//                } else {
+//                    if ($value > 1) {
+//                        $bUplevel = true;
+//                        $itemLevel = $value;
+//                    }
+//                }
+//            }
+//            if ($bUplevel) {
+//                $item = GameConfig::item_getItem($store->equipment->$uid->typeId);
+//                if ($item == null) { //2.检测是否存在装备的原始数据
+//                    Err(ErrCode::err_const_no);
+//                }
+//                // 推送系统消息
+//                SystemProc::insertWeapon_promoteUp($req->zoneid, $req->uid, $req->userInfo->game->name, $item->name, $itemLevel);
+//            }
+//            $store->equipment->$uid->$key = $value;
+//        }
+//        UserProc::updateUserInfo($req);
+//        $ret = array('resp' => "succeed!");
+//        $resp = Resp::ok($ret); //返回必须是object
+//        return $resp;
+//    }
 
     /**
      * 
@@ -787,8 +785,6 @@ class StoreProc {
             StoreProc:: PutOverlyingItemInStore($itemId, $num, $req); ///准备添加其他
         }
 
-
-
         //  更新数据库数据
         UserProc::updateUserInfo($req);
         // 返回
@@ -1092,19 +1088,6 @@ class StoreProc {
         }
     }
 
-    public static function CheckHeroNum($req) {
-        $heroNum = 0;
-        $gamedata = $req->userInfo->game;
-
-        $HeroObj = $gamedata->heros->collectHeros;
-        if ($HeroObj) {
-            foreach ($HeroObj as $value) {
-                $heroNum++;
-            }
-        }
-        return $heroNum;
-    }
-
     /**
      * 检查背包中物品的个数
      * @param type $req
@@ -1203,102 +1186,9 @@ class StoreProc {
 //
 // -------------- 已废弃的代码 -------------------------------
 //
-// <editor-fold defaultstate="collapsed" desc="  --- 已废弃的代码 ---  ">
-//
-
-    /**
-     * 符石放入仓库
-     * @param type $itemId
-     * @param MapModel $map
-     */
-    static function putStoneInStore($itemId, $itemNum, &$map) {
-        if (!CommUtil::isPropertyExists($map->store, "stones")) {
-            $map->store->stones = ObjectInit();
-        }
-        if (CommUtil::isPropertyExists($map->store->stones, $itemId)) {
-            $map->store->stones->$itemId += $itemNum;
-        } else {// 如果仓库中没有这种元素,则其数目置1
-            $map->store->stones->$itemId = $itemNum;
-        }
-    }
-
-// </editor-fold>
 //
 // <editor-fold defaultstate="collapsed" desc="   出售   ">
-//
-//       /**
-//     * 从仓库出售可叠加物品
-//     * @param RequestVo $req
-//     * @return type
-//     */
-//    static function sellGemFromStore($req)
-//    {
-//        $resp = new ResponseVo();
-//        $mem = $req->mem;
-//      //  $user = $req->userInfo->user;
-//        $store = $req->userInfo->game->store; //$req->userInfo->game->store->items
-////客户端参数解析
-//        $type = $req->paras[0]; //1=神兽 2=建筑   //需要判断是否叠加
-//        $itemId = $req->paras[1]; // 注意:这里不是单体的id,而是物种的id
-//        $count = intval($req->paras[2]);  // 数量
-//
-//       ////0是type 1是itemid,2是uid,3是数量
-//
-//        if (4 == $type) {  // 从仓库出售宝石 出售可叠加的物品
-//
-//            $ok = StoreProc::removeItemFromStore($store, $itemId, $count); // 支持移除指定数量
-//
-////1.如果仓库道具移出时出错,则直接返回错误
-//            if ($ok != ErrCode::succeed) {
-//                $resp = ResponseVo::ErrResponse($req, $ok);
-//
-//            } else {
-//             //   echo "弄弄";
-//                $gem = ConstProc::getItemConst ($mem, $itemId);
-//                echo var_export($gem);
-////2.检测是否存在该物品的原始物种
-//                if ($gem == null) {
-//                    $resp = ResponseVo::ErrResponse($req, ErrCode::err_godpet_noconst);
-//                } else {
-//                      // 发金币
-//
-//                     UserGameModel::Add_Gold($mem, $req->userInfo->game,$gem->maijia *$count );
-//
-//                   $resp = ResponseVo::RetResponse($req, "succeed!");
-//
-//                    UserProc::updateUserInfo($req);
-//
-//                }
-//            }
-//        } else if (1 == $type) { # 建筑  // 其它
-//            if ($count > 1) {
-//                $resp = ResponseVo::ErrResponse($req, ErrCode::err_msg_paras);
-//            } else {
-//                $ok = StoreProc::removeFromStore($itemId, $map); # 从仓库移除
-//                if ($ok) {//1.如果仓库道具移出时出错,则直接返回错误
-//                    $resp = ResponseVo::ErrResponse($req, ErrCode::err_store_removefail);
-//                } else {
-//                    $build = ConstProc::getBuildConst($mem, $itemId);
-//                    if (build == null) { //2.检测是否存在建筑的原始数据
-//                        $resp = ResponseVo::errResponse($req->oid, $req->msgid, ErrCode::err_build_noconst);
-//                    } else {
-//                        UserModel::Add_Gold($user, JsonUtil::decode($build->sellPrice)->g); # 加金币
-//                        $resp = ResponseVo::myRetResponse($req, "succeed!"); # 返回值
-//                        //成就触发--获取金币
-//                       /// AchievementProc::dealAchievementState($req, $resp, AchievementProc::Gold);
-//                        UserProc::updateUserInfo($req);
-//                    }
-//                }
-//            }
-//        }
-//    }
-//
-//
-//
-//
-//
-//
-//
+// 
 
     /**
      * 出售单一的物品
@@ -1472,9 +1362,6 @@ class StoreProc {
     static function sellMultiItemFromStore($req) {
         $resp = new Resp();
 
-
-
-
         $obj = $req->paras[0]; //获取物品的结构数组
 
         echo var_export($obj);

+ 2 - 1
Gameserver/Amfphp/process/SystemProc.php

@@ -433,7 +433,8 @@ class SystemProc {
         throw new \Exception("need reimplement");
         $err = ErrCode::ok;
 // 向系统消息区域发送中奖消息.
-        $broadCastIDs = ConstProc::getBuildReward($mem, ConstProc::buildreward_lottery_broadcast);
+
+        $broadCastIDs = glc()->broadCastIDs;
         if ($broadCastIDs == null) {                                            # 需要广播的道具ID
             $err = ErrCode::err_msg_buildrewardnoconst;
         } else {

+ 10 - 63
Gameserver/Amfphp/process/UserProc.php

@@ -18,7 +18,6 @@ define("INIT_GODPETMANUAL", '{"exp":0,"godpetDic":{"101001":[0],"101002":[0],"10
  */
 class UserProc {
 
-    const reg_Table = '';
     const role_Table = 'tab_rolename';
 
     /**
@@ -107,7 +106,7 @@ class UserProc {
         if ($itemid) {
             $err = StoreProc::removeItemFromStore($req->userInfo->game->store, $itemid, 1);
             if ($err) {
-                return Resp::err($err);
+                Err($err);
             }
         }
         $req->userInfo->game->name = $newname;
@@ -170,6 +169,7 @@ class UserProc {
      * @param Req $req
      */
     public static function RegisterNewRole($req) {
+//        Err(ErrCode::err_method_obsoleted, "注册逻辑已经转移到龙游SDK中 --王刚");
         $userID = $req->uid;
         list($rolename, $gender, $profile_img) = $req->paras;                   # 参数: 昵称,性别,头像
         if (self::checkRoleNameNotExist($rolename)) {                           # 记录玩家
@@ -200,12 +200,6 @@ class UserProc {
             if ($zone->publicTs > $ts) {
                 continue;
             }
-            if ($req->clientVer == '1.0.2') {
-                if ($zone->publicTs != 1527213601) {                            # 特殊版本屏蔽以前的分区列表.
-                    continue;
-                }
-                $defaultZone = new ZoneInfoModel(4, 0, "");                     # 新用户默认分区
-            }
             $zone->zoneid = $zoneid;                                            # 把zoneid塞进zone数据结构中
             if ($bGetRecommended) {
                 if ($zone->isRecommended > 0 && $zone->status == 1) {
@@ -217,9 +211,6 @@ class UserProc {
                 $zoneList[] = $zone;
             }
             unset($zone->isRecommended);
-//            if ($zone->isdefaul) {                                            # 获取默认分区.
-//                $defaultZone = new ZoneInfoModel($zone->id, 0);
-//            }
         }
         UserProc::_AddTesterZonelist($req, $zoneList);                          # 添加测试分区
 #
@@ -292,9 +283,7 @@ class UserProc {
      */
     public static function loginUserInfo($req) {
 //        return ResponseVo::ErrResponse($req, ErrCode::msg_methodnotimplement);
-        $mem = $req->mem;
-//客户端参数解析
-        $userInfo = UserProc::getUserInfo($mem, $req->zoneid, $req->uid);       # 取玩家信息
+        $userInfo = UserProc::getUserInfo(gMem(), $req->zoneid, $req->uid);     # 取玩家信息
         if ($userInfo == null) {                                                # 新用户, -> 6006创建账号
             $ret = array(
                 'isNewUser' => true
@@ -304,8 +293,7 @@ class UserProc {
             $req->userInfo = $userInfo;                                         # 给Req挂载userInfo
             UserProc::checkContidays($req);                                     # 连续登录,状态检查
 //            UserProc::_checkUpdateGift($req);                                 # 检查更新礼包
-//            UserProc::fetchFromInteract($mem, $req);                          # 从交互体更新部分信息
-            self::FixNewbieGuideData($req);                                     # 修复引导结构改变引起的老玩家无法登录问题-2018年4月4日
+//            UserProc::fetchFromInteract($mem, $req);                          # 从交互体更新部分信息 
             PayProc::m_refreshChargeOrders($req);                               # 刷新订单, 多平台版本
             PayProc::checkDeltest($req);                                        # 检查内侧充值记录(函数内部会只检查一次)
             UserProc::updateUserInfo($req);                                     # 这一步回存操作只有在 userInfo正常存在的情况下才进行
@@ -320,25 +308,6 @@ class UserProc {
         return $resp;
     }
 
-    /**
-     * 修理玩家引导数据(结构变动) -gwang 2018年4月4日
-     * @param Req $req
-     */
-    private static function FixNewbieGuideData($req) {
-        $bExist = false;
-        $arr = array_keys((array) $req->userInfo->game->NewbieGuide);
-        foreach ($arr as $s) {
-            if (!is_numeric($s)) {                                              # 判断是否存在字符型节点
-                $bExist = true;
-                break;
-            }
-        }
-        if ($bExist) {                                                          # 存在字符型节点=>需要替换
-            $str1 = '{"5010":{"guideIndex":4,"guideState":1},"5001":{"guideIndex":0,"guideState":1},"5011":{"guideIndex":3,"guideState":1},"5007":{"guideIndex":3,"guideState":1},"5002":{"guideIndex":8,"guideState":1},"5009":{"guideIndex":6,"guideState":1},"5003":{"guideIndex":12,"guideState":1},"5004":{"guideIndex":3,"guideState":1},"5005":{"guideIndex":10,"guideState":1}}';
-            $req->userInfo->game->NewbieGuide = JsonUtil::decode($str1);
-        }
-    }
-
     /**
      * 6003 领取连续登录奖励
      * @param Req $req
@@ -350,10 +319,10 @@ class UserProc {
     }
 
     /**
-     * 初始化图鉴信息
+     * 初始化卡牌图鉴信息
      * @param UserGameModel $userInfo
      */
-    private static function _intiGodpetManual($userInfo) {
+    private static function _intiHeroManual($userInfo) {
         if (INIT_TUTORIAL == 1) {                                               # 配合新手引导产生的图鉴数据
             $userInfo->heroManual = JsonUtil::decode(INIT_GODPETMANUAL);
         } else {
@@ -408,6 +377,7 @@ class UserProc {
      * @return boolean
      */
     static function checkRoleNameNotExist($roleName) {
+
         static $sqlFormat = "SELECT count(*) as rows FROM `tab_rolename` WHERE roleName='%s';";
         $sql = sprintf($sqlFormat, $roleName);
         $n = daoInst()->query($sql)->fetch();
@@ -458,32 +428,9 @@ class UserProc {
      * @param bool $isnew Description
      */
     static function OnNewDay($req, $isnew) {
-
         self::updatePlatUserRecord($req, $isnew);                               # 添加到到当天活跃玩家记录集合
         ActiveProc::DailyReset($req);                                           # 抽奖、每日任务状态,计数器...
         FightProc::ClearByDay($req);                                            # 战斗相关状态每日清理
-        UserProc::tempFunction($req);
-    }
-
-    static function tempFunction($req) {
-        $Boxs = $req->userInfo->game->store->boxes;
-
-        if (!CommUtil::isPropertyExists($Boxs, "701001")) {
-            $ss = "701001";
-            $Boxs->$ss = 0;
-        }
-        if (!CommUtil::isPropertyExists($Boxs, "702002")) {
-            $ss = "702002";
-            $Boxs->$ss = 0;
-        }
-        if (!CommUtil::isPropertyExists($Boxs, "703003")) {
-            $ss = "703003";
-            $Boxs->$ss = 0;
-        }
-        if (!CommUtil::isPropertyExists($Boxs, "704004")) {
-            $ss = "704004";
-            $Boxs->$ss = 0;
-        }
     }
 
 // <editor-fold defaultstate="collapsed" desc="创建新用户">
@@ -506,7 +453,7 @@ class UserProc {
         $userInfo->game->firstLogin = now();
 //        $userInfo->game->pvp->socre = PVPProc::_getScore_by_uid($req, $req->uid); # 初始化pvp积分
 //        $userInfo->game->NewbieGuideOver = 1;
-        UserProc::_intiGodpetManual($userInfo->game);                           # 初始化图鉴
+        UserProc::_intiHeroManual($userInfo->game);                             # 初始化图鉴
         $userInfo->interact = new UserInteractModel();                          # 初始化交互体数据
         #Ps 6006是没有获得到Userinfo到Req中的
         UserProc::checkContidays($req, 1);                                      # 每日状态检查
@@ -575,8 +522,8 @@ class UserProc {
      * @param Req $req
      */
     public static function updateUserInfo($req) {
-        if ($req->userInfo) {
-            $req->userInfoChanged = TRUE;
+        if (req()->userInfo) {
+            req()->userInfoChanged = TRUE;
         } else {
             CLog::Assert("UserProc", $req->userInfo, #
                     "[" . $req->cmd . '] >>>>>>>>>>用户数据正试图置空!!<<<<<<<<<<<' . $req->uid);

+ 14 - 14
Gameserver/Amfphp/service_call/cmemdata/kvflush.php

@@ -3,7 +3,7 @@
 namespace loyalsoft;
 
 include_once __DIR__ . '/../../main.php';
-require_once ROOTDIR . '/Util/OpenSSLVerify.php'; #Ps. 这个文件和类名没有对应关系.
+require_once ROOTDIR . '/Util/OpenSSLVerify.php';                               # Ps. 这个文件和类名没有对应关系.
 
 define("CLOGUTIL_DEBUG", true);
 
@@ -26,7 +26,7 @@ define("CLOGUTIL_DEBUG", true);
 class kvflush {
 
     public static function flush() {
-        InitZoneId();                                        # 初始化分区信息 Ps. $_REQUEST["zoneid"]
+        InitZoneId();                                                           # 初始化分区信息 Ps. $_REQUEST["zoneid"]
         $params = HttpUtil::getQueryParas();
         $key = CommUtil::zb64decode(urldecode($params["key"]));
         $val = CommUtil::zb64decode(urldecode($params["val"]));
@@ -35,12 +35,13 @@ class kvflush {
         $keypath = ROOTDIR . "/Util/key";
         $myrsa = new MyRsa($keypath);
         $sign = urldecode($params['sign']);
-        if (!$myrsa->verify_arr($params, $sign)) {            # 验证下签名
+        if (!$myrsa->verify_arr($params, $sign)) {                              # 验证下签名
             echo "签名验证失败!";
         } else {
+            CLog::info($key . " " . $val, "刷数据");
             switch ($type) {
                 case 'hash':
-                    $val = json_decode($val);                 # 需要还原为Obj才能解开
+                    $val = json_decode($val);                                   # 需要还原为Obj才能解开
                     $ret = self::FlushToMem_hmSet($key, $val);
                     self::FlushToFile_hash($key, $val);
                     break;
@@ -52,10 +53,9 @@ class kvflush {
                     $ret = self::FlushToMem_set($key, $val);
                     break;
             }
-
             if ($ret) {
                 echo "success";
-                self::log($user, $key);                      # 记录日志
+                self::log($user, $key);                                         # 记录日志
             } else {
                 echo "[$key] flush to mem failed!";
             }
@@ -68,9 +68,9 @@ class kvflush {
     static function log($user, $modelname) {
         $who = $user . '_' . HttpUtil::clientIP();
         $key = "log-flush";
-        CLog::warn($who . "flushing  [$modelname]", __CLASS__);   # 写文件
+//        CLog::warn($who . "flushing  [$modelname]", __CLASS__);                 # 写文件
         $mem = gMem();
-        $ret = $mem->hset($key, $who, TimeUtil::tsYmdHis()); # 写入mem
+        $ret = $mem->hset($key, $who, TimeUtil::tsYmdHis());                    # 写入mem
         $mem->close();
         return $ret;
     }
@@ -84,7 +84,7 @@ class kvflush {
     public static function FlushToMem_set($key, $value) {
         $mem = gMem();
         $mem->delete($key);
-        $ret = $mem->set($key, $value);                       # 写入mem
+        $ret = $mem->set($key, $value);                                         # 写入mem
         $mem->close();
         return $ret;
     }
@@ -100,7 +100,7 @@ class kvflush {
         if (!is_array($assoc_array)) {
             if (is_object($assoc_array)) {
                 $assoc_arr = array();
-                foreach ($assoc_array as $k => $v) {           # 组合成符合hmset的关联数组
+                foreach ($assoc_array as $k => $v) {                            # 组合成符合hmset的关联数组
                     $assoc_arr[$k] = JsonUtil::encode($v);
                 }
                 $assoc_array = $assoc_arr;
@@ -111,7 +111,7 @@ class kvflush {
         $ret = TRUE;
         if (count($assoc_arr) > 0) {
             $mem->delete($key);
-            $ret = $mem->hmset($key, $assoc_array);            # 写入
+            $ret = $mem->hmset($key, $assoc_array);                             # 写入
         }
         $mem->close();
         return $ret;
@@ -131,7 +131,7 @@ class kvflush {
     }
 
     private static function writePHPFile($key, $value) {
-        if (defined('CodeGen_Enabled') && CodeGen_Enabled) {     # (部署环境)是否允许代码生成
+        if (defined('CodeGen_Enabled') && CodeGen_Enabled) {                    # (部署环境)是否允许代码生成
             $file = fopen(self::getFolder() . $key . ".php", 'w');
             $str = "<?php " . PHP_EOL . " return unserialize('" . serialize($value) . "');";
             fwrite($file, $str);
@@ -154,6 +154,6 @@ class kvflush {
 }
 
 //exit("success");
-CLog::err(HttpUtil::getQueryString(), "刷数据");
+
 HttpUtil::PostOnly();
-kvflush::flush(); # do it 
+kvflush::flush();                                                               # do it 

+ 4 - 2
Gameserver/Amfphp/test.php

@@ -14,6 +14,8 @@ $r = "1,23, 305%";
 $A = [1, 2, 3];
 $B = [4, 5, 6];
 
-var_dump(array_merge($A, $B));
-var_dump($A);
+
+list($a, $b, $c, $d) = $A;
+var_dump($c);
+var_dump($d);
 

+ 2 - 2
Gameserver/Amfphp/util/ErrHandler.php

@@ -21,7 +21,7 @@ class ErrHandler {
      */
     static function error_handler($errno, $errstr, $errfile, $errline) {
         $msg = CommUtil::str2UTF8($errstr) . " in " . CommUtil::str2UTF8($errfile) . ":" . $errline;
-        CLog::err($msg, 'Error Handler:');
+        CLog::err($msg . PHP_EOL . DebugHelper::get_call_stack(10), 'Error Handler:');
         CLog::flush();                                                          # 最后再将快速日志刷到文件
         return TRUE;                                                            # 不再继续错误处理的冒泡过程
     }
@@ -48,7 +48,7 @@ class ErrHandler {
         $msg = CommUtil::str2UTF8($exception->getMessage())
                 . '  in ' . CommUtil::str2UTF8($exception->getFile())
                 . ":" . $exception->getLine();
-        CLog::err($msg, 'Exception Handler:');
+        CLog::err($msg . PHP_EOL . DebugHelper::get_call_stack(10), 'Exception Handler:');
         CLog::flush();                                                          # 最后再将快速日志刷到文件
     }
 

+ 14 - 3
Gameserver/nbproject/private/private.xml

@@ -12,11 +12,22 @@
     </editor-bookmarks>
     <open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
         <group>
-            <file>file:/E:/www/ylsj2019/Gameserver/Amfphp/base/ErrCode.php</file>
-            <file>file:/E:/www/ylsj2019/Gameserver/Amfphp/test.php</file>
+            <file>file:/E:/www/ylsj2019/Gameserver/Amfphp/process/UserProc.php</file>
+            <file>file:/E:/www/ylsj2019/Gameserver/Amfphp/process/HeroProc.php</file>
+            <file>file:/E:/www/ylsj2019/Gameserver/Amfphp/process/ActiveProc.php</file>
+            <file>file:/E:/www/ylsj2019/Gameserver/Amfphp/index.php</file>
+            <file>file:/E:/www/ylsj2019/Gameserver/Amfphp/config.php</file>
+            <file>file:/E:/www/ylsj2019/Gameserver/Amfphp/service_call/InquireApi/VerifyReturnCode.php</file>
             <file>file:/E:/www/ylsj2019/Gameserver/Amfphp/process/FightProc.php</file>
-            <file>file:/E:/www/ylsj2019/Gameserver/Amfphp/process/StoreProc.php</file>
             <file>file:/E:/www/ylsj2019/Gameserver/Amfphp/process/FightProc/SweepGatesProc.php</file>
+            <file>file:/E:/www/ylsj2019/Gameserver/Amfphp/service_call/cmemdata/kvflush.php</file>
+            <file>file:/E:/www/ylsj2019/Gameserver/Amfphp/util/CLog.php</file>
+            <file>file:/E:/www/ylsj2019/Gameserver/Amfphp/AutoLoad.php</file>
+            <file>file:/E:/www/ylsj2019/Gameserver/Amfphp/configs/GameConstants.php</file>
+            <file>file:/E:/www/ylsj2019/Gameserver/Amfphp/base/Req.php</file>
+            <file>file:/E:/www/ylsj2019/Gameserver/Amfphp/Services/AppServer.php</file>
+            <file>file:/E:/www/ylsj2019/Gameserver/Amfphp/Services/TestServer.php</file>
+            <file>file:/E:/www/ylsj2019/Gameserver/Amfphp/main.php</file>
         </group>
     </open-files>
 </project-private>