添加后台代理代码

This commit is contained in:
2026-03-15 01:27:05 +08:00
parent 11f9ac4dc1
commit ea08c9366a
5254 changed files with 721042 additions and 0 deletions

View File

@@ -0,0 +1,531 @@
<?php
require_once dirname(dirname(__DIR__)) . '/common/ErrorType.php';
require_once dirname(dirname(__DIR__)) . '/common/BaseMethodHelper.php';
require_once dirname(dirname(__DIR__)) . '/public/public_data.php';
class test extends BaseMethod
{
/**
* 被请求方法示例参数固定为RequestParameter和ReturnParameter对象返回值固定为true(成功)和false(失败)
* @param RequestParameter $request
* @param ReturnParameter $return
* @return bool
*/
public function test_1($request, &$return)
{
//echo ($this->GetMasterDatabase()->Quote(JsonObjectToJsonString($request)));
$return->biz_content = ['ok'];
return true;
}
/**
* 被请求方法示例参数固定为RequestParameter和ReturnParameter对象返回值固定为true(成功)和false(失败)
* @param RequestParameter $request
* @param ReturnParameter $return
* @return bool
*/
public function test_2($request, &$return)
{
$return->biz_content = $request->biz_content;
return true;
}
/**
* @param RequestParameter $inParam
* @param ReturnParameter $outParam
* @return bool
*/
public function read_game_config($inParam, $outParam)
{
//http://localhost/project/daili/api/Index.php?method=test.test.read_game_config&format=json&charset=utf-8&timestamp=1&version=1.0&biz_content={%22a%22:%22a%22,%22b%22:%22b%22}
$game_config = publicData::getInstance()->getConfig();
$game_config = trim($game_config, "\xEF\xBB\xBF");
$array_config = json_decode($game_config, true);
if(!is_array($array_config))
{
die('配置信息不是json格式');
}
$this->PDO_Execute('
truncate table config_agent;
truncate table config_game;
truncate table config_channel;
truncate table config_market;
');
$agent_list = $array_config['agentlist'];
foreach($agent_list as $item)
{
$agent_data = array(
isset($item['agentid']) ? $item['agentid'] : '',
isset($item['agentname']) ? $item['agentname'] : '',
isset($item['html_buyroomcard']) ? $item['html_buyroomcard'] : '',
isset($item['html_applysales']) ? $item['html_applysales'] : '',
isset($item['agentmode']) ? intval($item['agentmode']) : 0,
isset($item['sale_qq']) ? $item['sale_qq'] : '',
isset($item['sale_wechat']) ? $item['sale_wechat'] : '',
isset($item['sale_tel']) ? $item['sale_tel'] : '',
isset($item['relagentid']) ? $item['relagentid'] : '',
isset($item['logimage2']) ? $item['logimage2'] : '',
isset($item['gamelist'][0]['channellist'][0]['channelid']) ? $item['gamelist'][0]['channellist'][0]['channelid'] : '',
);
$ret = $this->PDO_Execute('
insert into
config_agent(agent_id,agent_name,html_buyroomcard,html_applysales,agent_mode,sale_qq,sale_wechat,sale_tel,rel_agent_id, logo, channel_id)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);
', $agent_data);
if(!$ret)
{
$outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo());
return false;
}
$game_list = $item['gamelist'];
foreach($game_list as $one_game)
{
$game_data = array(
isset($item['agentid']) ? $item['agentid'] : '',
isset($one_game['gameid']) ? $one_game['gameid'] : '',
isset($one_game['gamename']) ? $one_game['gamename'] : '',
isset($one_game['game_down_image']) ? $one_game['game_down_image'] : '',
isset($one_game['game_down_state']) ? intval($one_game['game_down_state']) : 0,
isset($one_game['game_down_memo']) ? $one_game['game_down_memo'] : '',
);
$ret = $this->PDO_Execute('
insert into
config_game(agent_id,game_id, game_name, game_down_image, game_down_state,game_down_memo)
values(?, ?, ?, ?, ?, ?)', $game_data);
if(!$ret)
{
$outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo());
return false;
}
$channelList = $one_game['channellist'];
foreach($channelList as $oneChannel)
{
$marketList = $oneChannel['marketlist'];
foreach($marketList as $one_market)
{
/*$marketData = array(
isset($item['agentid']) ? $item['agentid'] : '',
isset($one_game['gameid']) ? $one_game['gameid'] : '',
isset($oneChannel['channelid']) ? $oneChannel['channelid'] : '',
isset($oneChannel['channelname']) ? $oneChannel['channelname'] : '',
isset($one_market['marketid']) ? $one_market['marketid'] : '',
isset($one_market['marketname']) ? $one_market['marketname'] : '',
isset($one_market['app_download']) ? $one_market['app_download'] : '',
isset($one_market['app_size']) ? $one_market['app_size'] : '',
);*/
if($oneChannel['ios_defdownload_marketid'] == $one_market['marketid'])
{
$ios_down = $one_market['app_download'];
$ios_app_size = $one_market['app_size'];
}
if($oneChannel['and_defdownload_marketid'] == $one_market['marketid'])
{
$and_down = $one_market['app_download'];
$and_app_size = $one_market['app_size'];
}
}
$channelData = array(
isset($item['agentid']) ? $item['agentid'] : '',
isset($one_game['gameid']) ? $one_game['gameid'] : '',
isset($oneChannel['channelid']) ? $oneChannel['channelid'] : '',
isset($oneChannel['channelname']) ? $oneChannel['channelname'] : '',
isset($ios_down) ? $ios_down : '',
isset($oneChannel['ios_defdownload_marketid']) ? $oneChannel['ios_defdownload_marketid'] : '',
isset($ios_app_size) ? $ios_app_size : 0,
isset($and_down) ? $and_down : '',
isset($and_app_size) ? $and_app_size : 0,
isset($oneChannel['service_wechat']) ? $oneChannel['service_wechat'] : '',
isset($oneChannel['service_qq']) ? $oneChannel['service_qq'] : '',
);
$ret = $this->PDO_Execute('
insert into
config_channel(agent_id, game_id, channel_id, channel_name, ios_download, ios_market_id, ios_app_size, and_download, and_app_size, wechat, qq)
values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
', $channelData);
if(!$ret)
{
$outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo());
return false;
}
}
}
}
return true;
}
/**
* 查询个人信息
* 被请求方法示例参数固定为RequestParameter和ReturnParameter对象返回值固定为true(成功)和false(失败)
* @param RequestParameter $inParam
* @param ReturnParameter $outParam
* @return bool
* method=test.test.salesInfo&format=json&charset=utf-8&timestamp=1&version=1.0&biz_content={}
*/
public function salesInfo($inParam, $outParam)
{
$request_data = isset($inParam->biz_content) ? $inParam->biz_content : '';
if (!is_array($request_data))
{
//参数格式错误
$outParam->SetErrors(ERRORCODE_INPARAMERROR, ERRORINFO_INPARAMERROR);
return false;
}
$salesInfo = $this->GetHelper()->PDO_Request(/** @lang */'
SELECT
agent_id, channel_id, open_id, union_id, nick_name, avatar, sex, sales_man, sales_id as salesid, parent_id,
room_card as roomcard, bean, credit, power, global_status
FROM
test_sales_user
WHERE
id=?;', 1);
if(!is_array($salesInfo))
{
$outParam->SetErrors($this->GetHelper()->GetErrorCode(), $this->GetHelper()->GetErrorInfo());
return false;
}
if(count($salesInfo) < 1)
{
$outParam->SetErrors(ERRORCODE_SALESNOTEXISTERROR, ERRORINFO_SALESNOTEXISTERROR);
return false;
}
$outParam->biz_content = $salesInfo[0];
return true;
}
/**
* 新增房卡、星星或积分
* 被请求方法示例参数固定为RequestParameter和ReturnParameter对象返回值固定为true(成功)和false(失败)
* @param RequestParameter $inParam
* @param ReturnParameter $outParam
* @return bool
* method=test.test.addInfo&format=json&charset=utf-8&timestamp=1&version=1.0&biz_content={"agentid":"1","channelid":"1","salesid":"100001","roomcard":10,"bean":10,"credit":10}
*/
public function addInfo($inParam, $outParam)
{
$request_data = isset($inParam->biz_content) ? $inParam->biz_content : '';
if (!is_array($request_data))
{
//参数格式错误
$outParam->SetErrors(ERRORCODE_INPARAMERROR, ERRORINFO_INPARAMERROR);
return false;
}
$agentID = isset($request_data['agentid']) ? $request_data['agentid'] : '';
if (empty($agentID))
{
$outParam->SetErrors(ERRORCODE_AGENTIDERROR, ERRORINFO_AGENTIDERROR);
return false;
}
$channelID = isset($request_data['channelid']) ? $request_data['channelid'] : '';
if (empty($channelID))
{
$outParam->SetErrors(ERRORCODE_CHANNELIDERROR, ERRORINFO_CHANNELIDERROR);
return false;
}
//操作人id
$salesID = isset($request_data['salesid']) ? $request_data['salesid'] : '';
if (empty($salesID))
{
$outParam->SetErrors(ERRORCODE_SALESIDERROR, ERRORINFO_SALESIDERROR);
return false;
}
$roomCard = isset($request_data['roomcard']) ? intval($request_data['roomcard']) : 0;
$bean = isset($request_data['bean']) ? intval($request_data['bean']) : 0;
$credit = isset($request_data['credit']) ? intval($request_data['credit']) : 0;
$createTime = isset($request_data['createtime']) ? $request_data['createtime'] : '';
if (empty($createTime))
{
$createTime = date('Y-m-d H:i:s', time());
}
else
{
$addTime = strtotime($createTime);
if(!$addTime)
{
$createTime = date('Y-m-d H:i:s', time());
}
else
{
$createTime = date('Y-m-d H:i:s', $addTime);
}
}
$salesInfo = $this->GetHelper()->PDO_Request(/** @lang */'
SELECT
id, open_id, union_id, nick_name, avatar, sex, sales_man, parent_id,
room_card, bean, credit, power, global_status
FROM
test_sales_user
WHERE
agent_id=? AND channel_id=? AND sales_id=?;', $agentID, $channelID, $salesID);
if(!is_array($salesInfo))
{
$outParam->SetErrors($this->GetHelper()->GetErrorCode(), $this->GetHelper()->GetErrorInfo());
return false;
}
if(count($salesInfo) < 1)
{
$outParam->SetErrors(ERRORCODE_SALESNOTEXISTERROR, ERRORINFO_SALESNOTEXISTERROR);
return false;
}
$this->GetHelper()->PDO_BeginTransaction();
try
{
$ret = $this->GetHelper()->PDO_Execute(/** @lang */'
INSERT INTO test_sales_order(agent_id, channel_id, sales_id, room_card, bean, credit, create_time)
VALUES(?, ?, ?, ?, ?, ?, ?);', $agentID, $channelID, $salesID, $roomCard, $bean, $credit, $createTime);
if (!$ret || !$this->GetHelper()->PDO_IsDone())
{
throw new Exception($this->GetHelper()->GetErrorInfo(), $this->GetHelper()->GetErrorCode());
}
$ret = $this->GetHelper()->PDO_Execute(/** @lang */'
UPDATE
test_sales_user
SET
room_card=room_card+?, bean=bean+?, credit=credit+?
WHERE
id=?;', $roomCard, $bean, $credit, $salesInfo[0]['id']);
if (!$ret || !$this->GetHelper()->PDO_IsDone())
{
throw new Exception($this->GetHelper()->GetErrorInfo(), $this->GetHelper()->GetErrorCode());
}
$this->GetHelper()->PDO_Commit();
}
catch (Exception $e)
{
$this->GetHelper()->PDO_Rollback();
$outParam->SetErrors($e->getCode(), $e->getMessage());
return false;
}
return true;
}
/**
* 查询添加房卡星星记录
* 被请求方法示例参数固定为RequestParameter和ReturnParameter对象返回值固定为true(成功)和false(失败)
* @param RequestParameter $inParam
* @param ReturnParameter $outParam
* @return bool
* method=test.test.addRecord&format=json&charset=utf-8&timestamp=1&version=1.0&biz_content={"agentid":"1","channelid":"1","salesid":"100001","begintime":"2017-09-09","endtime":"2017-09-29","page_index":1}
*/
public function addRecord($inParam, $outParam)
{
$request_data = isset($inParam->biz_content) ? $inParam->biz_content : '';
if (!is_array($request_data))
{
//参数格式错误
$outParam->SetErrors(ERRORCODE_INPARAMERROR, ERRORINFO_INPARAMERROR);
return false;
}
$agentID = isset($request_data['agentid']) ? $request_data['agentid'] : '';
if (empty($agentID))
{
$outParam->SetErrors(ERRORCODE_AGENTIDERROR, ERRORINFO_AGENTIDERROR);
return false;
}
$channelID = isset($request_data['channelid']) ? $request_data['channelid'] : '';
if (empty($channelID))
{
$outParam->SetErrors(ERRORCODE_CHANNELIDERROR, ERRORINFO_CHANNELIDERROR);
return false;
}
//操作人id
$salesID = isset($request_data['salesid']) ? $request_data['salesid'] : '';
if (empty($salesID))
{
$outParam->SetErrors(ERRORCODE_SALESIDERROR, ERRORINFO_SALESIDERROR);
return false;
}
$page_count=1;
$str_time = '';
$beginTime = isset($request_data['begintime']) ? $request_data['begintime'] : '';
$endTime = isset($request_data['endtime']) ? $request_data['endtime'] : '';
$page_index = empty($request_data['page_index']) ? 1 : intval($request_data['page_index']);
$page_size = empty($request_data['page_size']) ? 10 : intval($request_data['page_size']);
$start = ($page_index - 1) * $page_size;
$strPage = '';
if (!empty($request_data['page_index']))
{
$strPage .= " LIMIT {$start},{$page_size} ";
}
$array_param = array($agentID, $channelID, $salesID);
if (!empty($beginTime))
{
$str_time .= ' and create_time >= ? ';
$array_param[] = $beginTime;
}
if (!empty($endTime))
{
$str_time .= ' and create_time <= ? ';
$array_param[] = $endTime;
}
if (!empty($beginTime) && !empty($endTime) && $beginTime > $endTime)
{
$outParam->SetErrors(ERRORCODE_TIMEERROR, ERRORINFO_TIMEERROR);
return false;
}
$recordList = $this->GetHelper()->PDO_Request(/** @lang */"
SELECT
id, sales_id, room_card, bean, credit, create_time
FROM
test_sales_order
WHERE
status=0 AND agent_id=? AND channel_id=? AND sales_id=? {$str_time}
ORDER BY id DESC {$strPage};", $array_param);
if (!is_array($recordList))
{
$outParam->SetErrors($this->GetHelper()->GetErrorCode(), $this->GetHelper()->GetErrorInfo());
return false;
}
if (!empty($request_data['page_index']))
{
$dbCount = $this->GetHelper()->PDO_Request(/** @lang */"
SELECT
count(1) num
FROM
test_sales_order
WHERE
status=0 AND agent_id=? AND channel_id=? AND sales_id=? {$str_time}", $array_param);
if (!is_array($dbCount) || count($dbCount) < 1)
{
$outParam->SetErrors($this->GetHelper()->GetErrorCode(), $this->GetHelper()->GetErrorInfo());
return false;
}
$page_count = intval($dbCount[0]['num']) / $page_size + 1;
}
$outParam->biz_content = array(
'record' => $recordList,
'page_index' => $page_index,
'page_size' => $page_size,
'page_count' => intval($page_count),
);
return true;
}
/**
* 删除添加房卡星星记录
* 被请求方法示例参数固定为RequestParameter和ReturnParameter对象返回值固定为true(成功)和false(失败)
* @param RequestParameter $inParam
* @param ReturnParameter $outParam
* @return bool
* method=test.test.deleteRecord&format=json&charset=utf-8&timestamp=1&version=1.0&biz_content={"agentid":"1","channelid":"1","salesid":"100001","recordid":"3"}
*/
public function deleteRecord($inParam, $outParam)
{
$request_data = isset($inParam->biz_content) ? $inParam->biz_content : '';
if (!is_array($request_data))
{
//参数格式错误
$outParam->SetErrors(ERRORCODE_INPARAMERROR, ERRORINFO_INPARAMERROR);
return false;
}
$agentID = isset($request_data['agentid']) ? $request_data['agentid'] : '';
if (empty($agentID))
{
$outParam->SetErrors(ERRORCODE_AGENTIDERROR, ERRORINFO_AGENTIDERROR);
return false;
}
$channelID = isset($request_data['channelid']) ? $request_data['channelid'] : '';
if (empty($channelID))
{
$outParam->SetErrors(ERRORCODE_CHANNELIDERROR, ERRORINFO_CHANNELIDERROR);
return false;
}
//操作人id
$salesID = isset($request_data['salesid']) ? $request_data['salesid'] : '';
if (empty($salesID))
{
$outParam->SetErrors(ERRORCODE_SALESIDERROR, ERRORINFO_SALESIDERROR);
return false;
}
//要删除的记录id
$recordID = isset($request_data['recordid']) ? $request_data['recordid'] : '';
if (empty($recordID))
{
$outParam->SetErrors(ERRORCODE_ORDERIDERROR, ERRORINFO_ORDERIDERROR);
return false;
}
$this->GetHelper()->PDO_Execute(/** @lang */'
UPDATE
test_sales_order
SET
status=1
WHERE
id=? AND sales_id=?;', $recordID, $salesID);
if (!$this->GetHelper()->PDO_IsDone())
{
$outParam->SetErrors($this->GetHelper()->GetErrorCode(), $this->GetHelper()->GetErrorInfo());
return false;
}
return true;
}
}