{$message}"); fclose($file); return true; } else return false; } $agent = isset($_REQUEST['a']) ? $_REQUEST['a'] : ''; $source = isset($_REQUEST['s']) ? $_REQUEST['s'] : ''; $target = isset($_REQUEST['t']) ? $_REQUEST['t'] : ''; if (empty($agent)) { $output = 'please enter agent id!'; OutputDebugMessage($output); die($output); } elseif (empty($source)) { $output = 'please enter source sales id!'; OutputDebugMessage($output); die($output); } elseif (empty($target)) { $output = 'please enter target sales id!'; OutputDebugMessage($output); die($output); } else { $connect_parameter = new ConnectParameter(MASTER_HOSTNAME, MASTER_HOSTPORT, MASTER_DATABASE, MASTER_USERNAME, MASTER_PASSWORD, MASTER_PERSISTENT, MASTER_CHARSET); /** @var IPDOHelper $db */ $db = new PDODelegator(DATABASE_TYPE); if (!$db->connect($connect_parameter)) { $output = JsonObjectToJsonString($db->geterrors()); OutputDebugMessage($output); die($output); } if (!$db->begintransaction()) { $output = JsonObjectToJsonString($db->geterrors()); OutputDebugMessage($output); die($output); } try { /// 转移房卡 $room_card = 0; /// 查询源代理信息 $sales_user = $db->request(/** @lang text */ 'select saus_roomcard from sales_user where saus_agentid = ? and saus_salesid = ?', $agent, $source); if (!$db->isdone()) { throw new Exception($db->geterrorinfo(), $db->geterrorcode()); } elseif (empty($sales_user)) { throw new Exception("unable to find sales id: {$source}!"); } else { $room_card = intval($sales_user[0]->saus_roomcard); } /// 查询新代理信息 $sales_user = $db->request(/** @lang text */ 'select saus_roomcard from sales_user where saus_agentid = ? and saus_salesid = ?', $agent, $target); if (!$db->isdone()) { throw new Exception($db->geterrorinfo(), $db->geterrorcode()); } elseif (empty($sales_user)) { throw new Exception("unable to find sales id: {$target}!"); } $command = <<execute($command, $agent, $source, $agent, $target); if (!$ret) throw new Exception($db->geterrorinfo(), $db->geterrorcode()); /// 更新代理的邀请码 $ret = $db->execute(/** @lang text */ 'update sales_user set saus_invitecode = ? where saus_agentid = ? and saus_invitecode = ?', $target, $agent, $source); if (!$ret) throw new Exception($db->geterrorinfo(), $db->geterrorcode()); /// 更新代理的上级代理 $ret = $db->execute(/** @lang text */ 'update sales_user set saus_parentid = ? where saus_agentid = ? and saus_parentid = ?', $target, $agent, $source); if (!$ret) throw new Exception($db->geterrorinfo(), $db->geterrorcode()); /// 更新玩家的邀请码 $ret = $db->execute(/** @lang text */ 'update player set play_invitecode = ? where play_agentid = ? and play_invitecode = ?', $target, $agent, $source); if (!$ret) throw new Exception($db->geterrorinfo(), $db->geterrorcode()); $db->commit(); } catch (Exception $Exception) { $db->rollback(); $output = JsonObjectToJsonString(array('code' => $Exception->getCode(), 'info' => $Exception->getMessage(),)); OutputDebugMessage($output); die($output); } }