コード例 #1
0
ファイル: ChargeAction.php プロジェクト: bluefan/phpsource
 public function doAction()
 {
     $arrData = $this->_parseData;
     $strAccount = isset($arrData["account"]) ? trim($arrData["account"]) : "";
     #账号
     $strOrderId = isset($arrData["order_id"]) ? trim($arrData["order_id"]) : "";
     #订单号
     $iGameMoney = isset($arrData["game_money"]) ? intval($arrData["game_money"]) : 0;
     #充值黄金
     $iUMoney = isset($arrData["u_money"]) ? floatval($arrData["u_money"]) : 0;
     #充值U币(可以理解为人民币)
     $serverId = isset($arrData['sid']) ? $arrData['sid'] : 0;
     if (intval($iGameMoney) <= 0) {
         echo json_encode(array('status' => 7));
         exit;
     }
     $objAccount = $this->get_data('Account');
     $player_id = $objAccount->get_pid_byaccount($strAccount, true, $serverId);
     if (empty($player_id)) {
         echo json_encode(array('status' => 6));
         exit;
     }
     $objPlayerCharge = $this->get_data('PlayerCharge');
     $arrCharge = $objPlayerCharge->get_charge_info($strOrderId);
     if (!empty($arrCharge)) {
         echo json_encode(array('status' => 4));
         exit;
     }
     $arrPlayer = $this->get_data('Player')->get_player_info($player_id, array('gold', 'level', 'vip', 'privilege_level'));
     $b_gold = $arrPlayer['gold'];
     #改变之前的钻石
     $this->get_data('Player')->check_player_resource($player_id, $arrPlayer, '+', 'gold', $iGameMoney);
     $iGold = $iGameMoney * 10;
     $this->start_trans();
     $result = $this->get_data('Player')->update_player_resource($player_id, $arrPlayer, 111, array('is_pay' => 1));
     if ($result) {
         $after = $arrPlayer['gold'];
         $result = $objPlayerCharge->add_charge($player_id, $strOrderId, $strAccount, $arrPlayer['level'], $iGameMoney, $iUMoney, $b_gold, $after);
     }
     if ($result) {
         $this->commit();
         Log_Charge::getInstance()->add_charge_log($player_id, $arrPlayer['level'], $arrPlayer['vip'], $arrPlayer['privilege_level'], $strOrderId, $iGameMoney, $iUMoney, $arrPlayer['gold'], $b_gold);
         $data['status'] = 0;
         #新服活动
         $pub_day = $this->get_data('NewServerActivity')->get_server_day();
         if ($pub_day <= 7) {
             $this->get_game('NewServerActivity')->add_sign($player_id, $pub_day, $iGameMoney);
         }
         # 充值回馈活动,蛋疼的次数埋点
         $this->get_game('PlayerFunc')->sync_func_tips($player_id, 1260);
         #vip升级
         $this->get_game('VipReward')->vip_upgrade($player_id, $iGameMoney);
     } else {
         $this->rollback();
         $data['status'] = 4;
     }
     echo json_encode($data);
     return;
 }
コード例 #2
0
 public function payback()
 {
     $result = $this->objTencent->verityToken($this->auth, $this->script_name);
     //file_put_contents(PROJECT_ROOT.'/uuzudo.log',var_export(array('pay2',$this->player_id,$this->auth,$result),true)."\n",FILE_APPEND);
     if ($result['ret'] != 0) {
         return $result;
     }
     $senddata = explode('*', $this->auth['payitem']);
     $goodsid = $senddata[0];
     $price = (int) $senddata[1];
     $num = (int) $senddata[2];
     /** 所有道具 */
     $payGoods = $this->objTencent->payGoods();
     if (empty($payGoods[$goodsid])) {
         return array('ret' => 1, 'msg' => '道具不存在' . $goodsid);
     }
     /** @var  is_double 是否双倍 */
     //$this->is_double = (int) $payGoods[$goodsid]['double'];
     /** @var  $is_cash 是否钻石充值 */
     $this->is_cash = (int) $payGoods[$goodsid]['is_cash'];
     $cash = $price * $num;
     $this->cash = $cash;
     // 档次
     $this->price = $price;
     // Token缓存
     $tokenKey = $this->objTencent->tokenTable . ':pay:' . $this->player_id;
     $tokenField = $goodsid;
     $buy_info_json = $this->redis()->hash_get($tokenKey, $tokenField);
     //file_put_contents(PROJECT_ROOT.'/uuzudo.log',var_export(array('pay3',$this->player_id,$this->auth,json_decode($buy_info_json,'array')),true)."\n",FILE_APPEND);
     $this->redis()->hash_delete($tokenKey, $tokenField);
     if ($buy_info_json) {
         $buy_info = json_decode($buy_info_json, 'array');
         if ($buy_info['token'] != $this->auth['token']) {
             return array('ret' => 3, 'msg' => 'token不存在');
         }
         $timeout = $this->objTencent->tokenTypes['pay']['timeout'];
         if (time() > $timeout + $buy_info['create_time']) {
             return array('ret' => 2, 'msg' => 'token已过期');
         }
         //charge log
         $insertData = array('uid' => $this->player_id, 'passport' => $this->auth['openid'], 'tokentype' => 'pay', 'token' => $this->auth['token'], 'create_time' => $buy_info['create_time'], 'content' => $buy_info['url_params'], 'senddata' => $this->auth['payitem'], 'verity_time' => time());
         $objPlayerCharge = $this->get_data('PlayerCharge');
         $arrCharge = $objPlayerCharge->get_charge_info($this->auth['billno']);
         if (!empty($arrCharge)) {
             return array('ret' => 2, 'msg' => '订单号已经存在');
         }
         $arrPlayer = $this->get_data('Player')->get_player_info($this->player_id, array('gold', 'level', 'vip', 'privilege_level', 'qq_blue_points'));
         $b_gold = $arrPlayer['gold'];
         #改变之前的钻石
         if ($tokenField == 18) {
             #$this->get_data('Player')->check_player_resource($this->player_id, $arrPlayer, '+', 'qq_blue_points', $cash);
         } else {
             $this->get_data('Player')->check_player_resource($this->player_id, $arrPlayer, '+', 'gold', $cash);
         }
         $iGold = $cash * 10;
         $this->start_trans();
         $result = $this->get_data('Player')->update_player_resource($this->player_id, $arrPlayer, 111, array('is_pay' => 1));
         if ($result) {
             $after = $arrPlayer['gold'];
             $result = $objPlayerCharge->add_charge($this->player_id, $this->auth['billno'], $this->auth['openid'], $arrPlayer['level'], $cash, $cash, $b_gold, $after);
         }
         if ($result) {
             $this->commit();
             Log_Charge::getInstance()->add_charge_log($this->player_id, $arrPlayer['level'], $arrPlayer['vip'], $arrPlayer['privilege_level'], $this->auth['billno'], $cash, $cash, $arrPlayer['gold'], $b_gold);
             $data['status'] = 0;
             if ($tokenField != 18) {
                 # 充值回馈活动,蛋疼的次数埋点
                 $this->get_game('PlayerFunc')->sync_func_tips($this->player_id, 1260);
                 #vip升级
                 $this->get_game('VipReward')->vip_upgrade($this->player_id, $cash);
                 #新服活动
                 $pub_day = $this->get_data('NewServerActivity')->get_server_day();
                 if ($pub_day <= 7) {
                     $this->get_game('NewServerActivity')->add_sign($this->player_id, $pub_day, $cash);
                 }
             }
         } else {
             $this->rollback();
             return array('ret' => 1, 'msg' => '充值失败');
         }
     } else {
         return array('ret' => 1, 'msg' => '充值失败');
     }
     ###############################################################################
     #  充值成功,上报数据,上报字段信息:
     #       modifyfee是充值金额,上报单位为Q分,1Q币=100Q分
     #       modifycoin对应为玩家充值变化的钻石数
     #       totalcoin对应充值完成之后,玩家总钻石数
     #       level为玩家等级
     $arrData = $this->auth;
     $platform = $arrData['platform'];
     $serverId = $arrData['serverid'];
     $openid = $arrData['openid'];
     $playerid = $this->player_id;
     $level = $arrPlayer['level'];
     $modifycoin = $after - $b_gold;
     $chargeData = array('modifyfee' => $cash * 10, 'modifycoin' => $modifycoin, 'totalcoin' => $after, 'level' => $level);
     Com_TencentDataUpload::getInstance()->init($platform, $serverId, $playerid, $openid);
     if (!($res = Com_TencentDataUpload::getInstance()->recharge_data_upload($chargeData))) {
         Com_Log::write("uploadDataError", "recharge_data_upload failed!");
     }
     ###############################################################################
     //file_put_contents(PROJECT_ROOT.'/uuzudo.log',var_export(array('pay4',$this->player_id,$this->auth,$result),true)."\n",FILE_APPEND);
     return array('ret' => 0, 'msg' => 'OK');
 }
コード例 #3
0
 public function doAction()
 {
     $userInfo_json = base64_decode($_POST['data']);
     $arrData = json_decode($userInfo_json, true);
     $strAccount = isset($arrData["user_account"]) ? trim($arrData["user_account"]) : "";
     #账号
     $strOrderId = isset($arrData["order_id"]) ? trim($arrData["order_id"]) : "";
     #订单号
     $iGameMoney = isset($arrData["game_money"]) ? intval($arrData["game_money"]) : 0;
     #充值黄金
     $iUMoney = isset($arrData["u_money"]) ? floatval($arrData["u_money"]) : 0;
     #充值U币(可以理解为人民币)
     $serverId = isset($arrData['server_id']) ? $arrData['server_id'] : 0;
     $player_id = isset($arrData['player_id']) ? $arrData['player_id'] : 0;
     $type = isset($arrData['type']) ? $arrData['type'] : 1;
     #1充值 2赠送3仅仅刷新VIP
     if (intval($iGameMoney) <= 0) {
         echo json_encode(array('status' => 0, 'data' => '充值金额有误'));
         exit;
     }
     if (!in_array($type, array(1, 2, 3))) {
         echo json_encode(array('status' => 8, 'data' => '类型错误'));
         #类型错误
         exit;
     }
     if (!empty($strAccount)) {
         $player_id = $this->get_data('Account')->get_pid_byaccount($strAccount, true, $serverId);
     }
     if (empty($player_id)) {
         echo json_encode(array('status' => 0, 'data' => '账户不存在'));
         exit;
     }
     $objPlayerCharge = $this->get_data('PlayerCharge');
     if ($type == 1) {
         $strOrderId = "gm" . time();
         // 			$arrCharge = $objPlayerCharge->get_charge_info($strOrderId);
         // 			if(!empty($arrCharge)){
         // 				echo  json_encode(array('status'=>0, 'data'=>'订单不存在'));
         // 				exit;
         // 			}
     }
     $objPlayerData = $this->get_data('Player');
     $arrPlayer = $objPlayerData->get_player_info($player_id, array('gold', 'level', 'vip', 'privilege_level'));
     $b_gold = $arrPlayer['gold'];
     #改变之前的钻石
     // $iGold = $arrPlayer['gold'];
     // $player_level = $arrPlayer['level'];
     $result = false;
     #$this->get_data('Player')->check_player_resource($player_id, $player_info, '+', 'gold', $iGameMoney);
     $this->start_trans();
     $iGold = $iGameMoney * 10;
     /*
     if ($iGameMoney)
     {
     	$result = $this->get_data('Player')->update_player_resource($player_id, $player_info, 525);
     }
     */
     $result = $objPlayerData->update_player_info($player_id, array('gold' => "+" . $iGold));
     if ($result) {
         $after = $arrPlayer['gold'] + $iGold;
         if ($type == 1) {
             //充值
             $result = $objPlayerCharge->add_charge($player_id, $strOrderId, $strAccount, $arrPlayer['level'], $iGold, $iGameMoney, $b_gold, $after);
         } else {
             //赠送
             $result = $objPlayerCharge->add_present($player_id, $iGameMoney);
         }
         if ($type == 2) {
             //计入充值活动
             $player_charge_dummy_info = array();
             $player_charge_dummy_info["order_id"] = "gmorder" . time();
             $player_charge_dummy_info["player_id"] = $player_id;
             $player_charge_dummy_info["user_account"] = $strAccount;
             $player_charge_dummy_info["player_level"] = $arrPlayer['level'];
             $player_charge_dummy_info["front_gold"] = $b_gold;
             $player_charge_dummy_info["gold"] = $iGold;
             $player_charge_dummy_info["after_gold"] = $after;
             $player_charge_dummy_info["u_money"] = $iGameMoney;
             $player_charge_dummy_info["add_time"] = time();
             $player_charge_dummy_info["active"] = 0;
             $player_charge_dummy_info["active2"] = 0;
             $player_charge_dummy_info["active3"] = 0;
             $player_charge_dummy_info["active4"] = 0;
             $player_charge_dummy_info["active5"] = 0;
             $result = $this->get_data("Event")->insert_into_player_charge_dummy($player_charge_dummy_info);
         }
     }
     if ($result) {
         $this->commit();
         if ($type == 1) {
             //充值记录
             Log_Charge::getInstance()->add_charge_log($player_id, $arrPlayer['level'], $arrPlayer['vip'], $arrPlayer['privilege_level'], $strOrderId, $iGold, $iUMoney, $arrPlayer['gold'], $b_gold);
         } else {
             Log_Common::getInstance()->add_resource_log($player_id, $arrPlayer['level'], $arrPlayer['vip'], $arrPlayer['privilege_level'], 100, 1, 2, $iGold, $arrPlayer['gold']);
         }
         // 				$logs[] = array('type'=>1,'item_id'=>2,'item_num'=>$iGold,'amount'=>$arrPlayer['gold']);
         //			Log_Common::getInstance()->add_resource_log($player_id, $arrPlayer['level'], $arrPlayer['vip'],$arrPlayer['privilege_level'], 100, 1, 2, $iGold, $arrPlayer['gold']);
         // 				Log_Common::getInstance()->add_multi_resource_log($player_id, $arrPlayer['level'], $arrPlayer['vip'],$arrPlayer['privilege_level'], 100, $logs);
         $data['status'] = 1;
         $data['data']['success'][] = $player_id;
         #同步更新面板数据
         Protocol_Player::p2c_part_update($player_id, array('gold' => $iGold + $arrPlayer['gold']));
         #vip升级
         if ($type == 3) {
             #不参加 首次充值
             $this->get_game('VipReward')->vip_upgrade($player_id, $iGold);
         } else {
             $this->get_game('VipReward')->vip_upgrade($player_id, $iGold);
         }
         #新服活动
         if ($type < 3) {
             $pub_day = $this->get_data('NewServerActivity')->get_server_day();
             if ($pub_day <= 7) {
                 $this->get_game('NewServerActivity')->add_sign($player_id, $pub_day, $iGold);
             }
         }
     } else {
         $this->rollback();
         $data['status'] = 0;
     }
     echo json_encode($data);
     define("FROM_GATEWAY", true);
     $this->get_game('PlayerFunc')->sync_func_tips($player_id, 1260);
     Protocol::out();
     return;
 }