Files
youlegames/codes/agent/game/dlweb/api/lib/1.0/model/agent.php.bak
2026-03-15 01:27:05 +08:00

3521 lines
110 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
require_once dirname(dirname(dirname(dirname(__FILE__)))) . '/config/game_config.inc.php';
require_once dirname(dirname(dirname(dirname(__FILE__)))) . '/outData/outData.php';
/**
* Created by PhpStorm.
* User: win7
* Date: 2017-07-05
* Time: 9:39
*/
class agent extends BaseMethod
{
/**
* 获取代理商的服务器地址
* 被请求方法示例参数固定为RequestParameter和ReturnParameter对象返回值固定为true(成功)和false(失败)
* @param RequestParameter $inParam
* @param ReturnParameter $outParam
* @return bool
*/
public function serverAddress($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;
}
$channelData = $this->PDO_Request('
SELECT
a.agen_agentid, a.agen_name, a.agen_server,
b.agch_channelid, b.agch_channelname, b.agch_service_tel, b.agch_service_wechat,
b.agch_youle_appid, b.agch_youle_devkey, b.agch_youle_busiid, b.agch_pay_appid, b.agch_pay_devkey,
b.agch_pay_marketid
FROM
agent a
LEFT JOIN agent_channel b ON a.agen_agentid=b.agch_agentid
WHERE
a.agen_agentid=? AND b.agch_channelid=?
', $agentID, $channelID);
if (!is_array($channelData))
{
$outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo());
return false;
}
if (count($channelData) < 1)
{
$outParam->SetErrors(ERRORCODE_NODATAERROR, ERRORINFO_NODATAERROR);
return false;
}
$db_agent_info = $this->PDO_Request('
SELECT
html_buyroomcard, logo
FROM
config_agent
WHERE
agent_id=?', $agentID);
if (!is_array($db_agent_info))
{
$outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo());
return false;
}
if (count($db_agent_info) < 1)
{
$outParam->SetErrors(ERRORCODE_AGENTNOTEXISTERROR, ERRORINFO_AGENTNOTEXISTERROR);
return false;
}
$outParam->biz_content = array(
'state' => 0,
'error' => '',
'agentid' => $channelData[0]['agen_agentid'],
'agentname' => $channelData[0]['agen_name'],
'agentlogo' => $db_agent_info[0]['logo'],
'urlserver' => $channelData[0]['agen_server'],
'channelid' => $channelData[0]['agch_channelid'],
'channeltel' => $channelData[0]['agch_service_tel'],
'channelwechat' => $channelData[0]['agch_service_wechat'],
'html_buyroomcard' => $db_agent_info[0]['html_buyroomcard'],
'youle_appid' => $channelData[0]['agch_youle_appid'],
'youle_devkey' => $channelData[0]['agch_youle_devkey'],
'youle_busiid' => $channelData[0]['agch_youle_busiid'],
'youle_appid_pay' => $channelData[0]['agch_pay_appid'],
'youle_devkey_pay' => $channelData[0]['agch_pay_devkey'],
'youle_busiid_pay' => $channelData[0]['agch_pay_marketid'],
);
return true;
}
/**
* 查询推荐人
* 被请求方法示例参数固定为RequestParameter和ReturnParameter对象返回值固定为true(成功)和false(失败)
* @param RequestParameter $inParam
* @param ReturnParameter $outParam
* @return bool
*/
public function recommend($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;
}
$salesID = isset($request_data['salesid']) ? $request_data['salesid'] : '';
if (empty($salesID))
{
$outParam->SetErrors(ERRORCODE_SALESIDERROR, ERRORINFO_SALESIDERROR);
return false;
}
$db_data = $this->PDO_Request('
SELECT
saus_nickname, saus_avatar
FROM
sales_user
WHERE
saus_agentid = ? and saus_salesid = ?;', $agentID, $salesID);
if (!is_array($db_data))
{
$outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo());
return false;
}
if (count($db_data) < 1)
{
$outParam->biz_content = array(
'state' => 1,
'error' => '未查到推荐人',
);
return true;
}
$outParam->biz_content = array(
'state' => 0,
'salesid' => $salesID,
'name' => $db_data[0]['saus_nickname'],
'avatar' => $db_data[0]['saus_avatar'],
);
return true;
}
/**
* 绑定推荐人 代理绑定代理
* 被请求方法示例参数固定为RequestParameter和ReturnParameter对象返回值固定为true(成功)和false(失败)
* @param RequestParameter $inParam
* @param ReturnParameter $outParam
* @return bool
*/
public function bindRecommend($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;
}
$openID = isset($request_data['openid']) ? $request_data['openid'] : '';
if (empty($openID))
{
$outParam->SetErrors(ERRORCODE_OPENIDERROR, ERRORINFO_OPENIDERROR);
return false;
}
$salesID = isset($request_data['salesid']) ? $request_data['salesid'] : '';
if (empty($salesID))
{
$outParam->SetErrors(ERRORCODE_SALESIDERROR, ERRORINFO_SALESIDERROR);
return false;
}
$db_data = $this->PDO_Request(
'call cp_sales_binding_parent(?,?,?);',
$agentID,
$openID,
$salesID
);
if (!is_array($db_data) || count($db_data) < 1)
{
$outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo());
return false;
}
if (!isset($db_data[0]['result']))
{
return false;
}
$res_flag = intval($db_data[0]['result']);
if ($res_flag != 0)
{
$outParam->biz_content = array(
'state' => $res_flag,
'error' => isset($db_data[0]['error']) ? $db_data[0]['error'] : '',
);
if ($res_flag == 2)
{
$outParam->biz_content['salesid'] = isset($db_data[0]['salesid']) ? $db_data[0]['salesid'] : '';
$outParam->biz_content['wechat'] = isset($db_data[0]['wechat']) ? $db_data[0]['wechat'] : '';
$outParam->biz_content['tel'] = isset($db_data[0]['tel']) ? $db_data[0]['tel'] : '';
$outParam->biz_content['nickname'] = isset($db_data[0]['nickname']) ? $db_data[0]['nickname'] : '';
$outParam->biz_content['avatar'] = isset($db_data[0]['avatar']) ? $db_data[0]['avatar'] : '';
}
return true;
}
$outParam->biz_content = array(
'state' => 0,
'salesid' => isset($db_data[0]['salesid']) ? $db_data[0]['salesid'] : '',
'wechat' => isset($db_data[0]['wechat']) ? $db_data[0]['wechat'] : '',
'tel' => isset($db_data[0]['tel']) ? $db_data[0]['tel'] : '',
'nickname' => isset($db_data[0]['nickname']) ? $db_data[0]['nickname'] : '',
'avatar' => isset($db_data[0]['avatar']) ? $db_data[0]['avatar'] : '',
);
return true;
}
/**
* 我的推荐人
* 被请求方法示例参数固定为RequestParameter和ReturnParameter对象返回值固定为true(成功)和false(失败)
* @param RequestParameter $inParam
* @param ReturnParameter $outParam
* @return bool
*/
public function myRecommend($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;
}
$openID = isset($request_data['openid']) ? $request_data['openid'] : '';
if (empty($openID))
{
$outParam->SetErrors(ERRORCODE_OPENIDERROR, ERRORINFO_OPENIDERROR);
return false;
}
$type = isset($request_data['type']) ? $request_data['type'] : '';
$db_data = array();
if (empty($type))
{
$db_data = $this->PDO_Request(
'call cp_sales_get_parentinfo(?,?);',
$agentID, $openID);
}
else
{
$db_data = $this->PDO_Request(
'call cp_sales_get_invitecodeinfo(?,?);',
$agentID, $openID);
}
if (!is_array($db_data))
{
$outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo());
return false;
}
if (count($db_data) != 1)
{
$outParam->biz_content = array(
'parentid' => '',
'name' => '',
'avatar' => '',
);
return true;
}
$outParam->biz_content = array(
'parentid' => $db_data[0]['saus_salesid'],
'name' => $db_data[0]['saus_nickname'],
'avatar' => $db_data[0]['saus_avatar'],
);
return true;
}
/**
* 我的子代理
* 被请求方法示例参数固定为RequestParameter和ReturnParameter对象返回值固定为true(成功)和false(失败)
* @param RequestParameter $inParam
* @param ReturnParameter $outParam
* @return bool
*/
public function myAgent($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;
}
$openID = isset($request_data['openid']) ? $request_data['openid'] : '';
if (empty($openID))
{
$outParam->SetErrors(ERRORCODE_OPENIDERROR, ERRORINFO_OPENIDERROR);
return false;
}
$db_data = $this->PDO_Request(
'call cp_sales_get_child(?,?);',
$agentID,
$openID
);
if (!is_array($db_data))
{
$outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo());
return false;
}
$outParam->biz_content = array('childs' => $db_data);
return true;
}
/**
* 我的奖励
* 被请求方法示例参数固定为RequestParameter和ReturnParameter对象返回值固定为true(成功)和false(失败)
* @param RequestParameter $inParam
* @param ReturnParameter $outParam
* @return bool
*/
public function myAward($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;
}
$openID = isset($request_data['openid']) ? $request_data['openid'] : '';
if (empty($openID))
{
$outParam->SetErrors(ERRORCODE_OPENIDERROR, ERRORINFO_OPENIDERROR);
return false;
}
$db_data = $this->PDO_Request(
'call cp_sales_get_award(?,?);',
$agentID,
$openID
);
if (!is_array($db_data))
{
$outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo());
return false;
}
$outParam->biz_content = array('awards' => $db_data);
return true;
}
/**
* 领取奖励
* 被请求方法示例参数固定为RequestParameter和ReturnParameter对象返回值固定为true(成功)和false(失败)
* @param RequestParameter $inParam
* @param ReturnParameter $outParam
* @return bool
*/
public function getAward($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;
}
$openID = isset($request_data['openid']) ? $request_data['openid'] : '';
if (empty($openID))
{
$outParam->SetErrors(ERRORCODE_OPENIDERROR, ERRORINFO_OPENIDERROR);
return false;
}
$awardID = isset($request_data['awardid']) ? $request_data['awardid'] : '';
if (empty($awardID))
{
$outParam->SetErrors(ERRORCODE_AWARDIDERROR, ERRORINFO_AWARDIDERROR);
return false;
}
$db_data = $this->PDO_Request(
'call cp_sales_accept_award(?,?,?);',
$agentID,
$openID,
$awardID
);
if (!is_array($db_data) || count($db_data) < 1)
{
$outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo());
return false;
}
if (!isset($db_data[0]['result']) || intval($db_data[0]['result']) != 0)
{
$outParam->SetErrors($db_data[0]['result'], $db_data[0]['error']);
return false;
}
$outParam->biz_content = array(
'state' => 0,
'roomcard' => isset($db_data[0]['myroomcard']) ? intval($db_data[0]['myroomcard']) : 0,
'awardstate' => isset($db_data[0]['mystate']) ? intval($db_data[0]['mystate']) : 0,
);
return true;
}
/**
* 查询个人代理
* 被请求方法示例参数固定为RequestParameter和ReturnParameter对象返回值固定为true(成功)和false(失败)
* @param RequestParameter $inParam
* @param ReturnParameter $outParam
* @return bool
*/
public function queryAgent($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;
}
$openID = isset($request_data['openid']) ? $request_data['openid'] : '';
if (empty($openID))
{
$outParam->SetErrors(ERRORCODE_OPENIDERROR, ERRORINFO_OPENIDERROR);
return false;
}
$salesID = isset($request_data['salesid']) ? $request_data['salesid'] : '';
if (empty($salesID))
{
$outParam->SetErrors(ERRORCODE_SALESIDERROR, ERRORINFO_SALESIDERROR);
return false;
}
$db_data = $this->PDO_Request(
'call cp_sales_query_salesman(?,?,?);',
$agentID,
$openID,
$salesID
);
if (!is_array($db_data) || count($db_data) < 1)
{
$outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo());
return false;
}
if (!isset($db_data[0]['result']))
{
return false;
}
if (intval($db_data[0]['result']) != 0)
{
$outParam->biz_content = array(
'state' => $db_data[0]['result'],
'error' => $db_data[0]['error'],
);
return true;
}
$dbSaleInfo = $this->PDO_Request('
SELECT
saus_status, saus_bean
FROM
sales_user
WHERE
saus_agentid=? AND saus_salesid=?', $agentID, $salesID);
if (!is_array($dbSaleInfo) || count($dbSaleInfo) < 1)
{
$outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo());
return false;
}
$outParam->biz_content = array(
'state' => 0,
'salesid' => $db_data[0]['salesid'],
'salesname' => $db_data[0]['salesname'],
'roomcard' => $db_data[0]['salesroomcard'],
'salesstatus' => $dbSaleInfo[0]['saus_status'],
'bean' => $dbSaleInfo[0]['saus_bean'],
);
return true;
}
/**
* 获取绑定了我的邀请码的玩家列表
* 被请求方法示例参数固定为RequestParameter和ReturnParameter对象返回值固定为true(成功)和false(失败)
* @param RequestParameter $inParam
* @param ReturnParameter $outParam
* @return bool
*/
public function myPlayer($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;
}
$openID = isset($request_data['openid']) ? $request_data['openid'] : '';
if (empty($openID))
{
$outParam->SetErrors(ERRORCODE_OPENIDERROR, ERRORINFO_OPENIDERROR);
return false;
}
$db_data = $this->PDO_Request(
'call cp_sales_get_myplayer(?,?);',
$agentID,
$openID
);
if (!is_array($db_data))
{
$outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo());
return false;
}
$outParam->biz_content = array('list' => $db_data);
return true;
}
/**
* 获取我的下级代理列表
* 被请求方法示例参数固定为RequestParameter和ReturnParameter对象返回值固定为true(成功)和false(失败)
* @param RequestParameter $inParam
* @param ReturnParameter $outParam
* @return bool
*/
public function mySales($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;
}
$openID = isset($request_data['openid']) ? $request_data['openid'] : '';
if (empty($openID))
{
$outParam->SetErrors(ERRORCODE_OPENIDERROR, ERRORINFO_OPENIDERROR);
return false;
}
$db_data = $this->PDO_Request(
'call cp_sales_get_mysalesman(?,?);',
$agentID,
$openID
);
if (!is_array($db_data))
{
$outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo());
return false;
}
$outParam->biz_content = array('list' => $db_data);
return true;
}
/**
* 绑定推荐人 玩家绑定代理
* 被请求方法示例参数固定为RequestParameter和ReturnParameter对象返回值固定为true(成功)和false(失败)
* @param RequestParameter $inParam
* @param ReturnParameter $outParam
* @return bool
*/
public function bindSales($inParam, $outParam)
{
$param = $inParam->biz_content;
$agentid = isset($param['agentid']) ? $param['agentid'] : '';
$channelid = isset($param['channelid']) ? $param['channelid'] : '';
$openid = isset($param['openid']) ? $param['openid'] : '';
$unionid = isset($param['unionid']) ? $param['unionid'] : '';
$salesid = isset($param['salesid']) ? $param['salesid'] : '';
if (empty($agentid))
{
$outParam->SetErrors(ERRORCODE_AGENTIDERROR, ERRORINFO_AGENTIDERROR);
return false;
}
if (empty($channelid))
{
$outParam->SetErrors(ERRORCODE_CHANNELIDERROR, ERRORINFO_CHANNELIDERROR);
return false;
}
if (empty($openid))
{
$outParam->SetErrors(ERRORCODE_OPENIDERROR, ERRORINFO_OPENIDERROR);
return false;
}
if (empty($salesid))
{
$outParam->SetErrors(ERRORCODE_SALESIDERROR, ERRORINFO_SALESIDERROR);
return false;
}
$cmd = $this->NewMasterCommand();
$player_info = $cmd
->select('play_playerid', 'play_invitecode')
->from('player')
->where(array(
'play_agentid' => $agentid,
'play_unionid' => $unionid
))
->request();
if(empty($player_info))
{
$outParam->biz_content = array('state' => 1, 'error' => '未查询到你的玩家信息,如果你是新注册的玩家,请稍等几分钟!');
return true;
}
if(!empty($player_info[0]['play_invitecode']))
{
$outParam->biz_content = array('state' => 2, 'error' => '你已在游戏中绑定过代理!邀请码为:'.$player_info[0]['play_invitecode']);
return true;
}
$sales_user = $cmd
->select('saus_salesid', 'saus_nickname', 'saus_avatar', 'saus_wechat', 'saus_tel')
->from('sales_user')
->where(array(
'saus_agentid' => $agentid,
'saus_salesid' => $salesid,
'saus_salesman' => 1,
))
->request();
if (!empty($sales_user))
{
$saus_salesid = $sales_user[0]['saus_salesid'];
$nickname = $sales_user[0]['saus_nickname'];
$avatar = $sales_user[0]['saus_avatar'];
$wechat = $sales_user[0]['saus_wechat'];
$tel = $sales_user[0]['saus_tel'];
}
else
{
$saus_salesid = 0;
$nickname = '';
$avatar = '';
$wechat = '';
$tel = '';
}
if (empty($saus_salesid))
{
$outParam->SetErrors(ERRORCODE_SALESIDERROR, ERRORINFO_SALESIDERROR);
return false;
}
$sales_user = $cmd
->select('saus_invitecode')
->from('sales_user')
->where(array(
'saus_agentid' => $agentid,
'saus_openid' => $openid,
))
->request();
if (!empty($sales_user))
$myinvitecode = $sales_user[0]['saus_invitecode'];
else
$myinvitecode = null;
if (empty($myinvitecode))
{
$this->PDO_BeginTransaction();
try
{
/// 修改代理表的代理号
$ret = $cmd
->update('sales_user')
->fields('saus_invitecode')
->values($salesid)
->where(array('saus_agentid' => $agentid, 'saus_openid' => $openid,))
->execute();
if (!$ret)
throw new Exception($this->GetErrorInfo(), $this->GetErrorCode());
/// 修改玩家表的代理号
$ret = $cmd
->update('player')
->fields('play_invitecode')
->values($salesid)
->where(array('play_agentid' => $agentid, 'play_unionid' => $unionid,))
->execute();
if (!$ret)
throw new Exception($this->GetErrorInfo(), $this->GetErrorCode());
$outParam->biz_content = array('salesid' => $saus_salesid, 'nickname' => $nickname, 'avatar' => $avatar, 'wechat' => $wechat, 'tel' => $tel,);
/// 记录绑定日志
$ret = $cmd->execute(
/** @lang text */
'insert into ct_user_process_log(
from_agent, from_channel, from_user, to_agent, to_channel, to_user,
oper_type, oper_data, remark, oper_time, is_process)
values(?, ?, ?, ?, ?, ?, 101, ?, ?, ?, 0)',
$agentid, $channelid, $salesid, $agentid, $channelid, $openid,
$unionid, '来源用户为要绑定的代理目标用户为要绑定的玩家。其中目标用户的userid为用户的openidoper_data为用户unionid。', time());
if (!$ret)
throw new Exception($this->GetErrorInfo(), $this->GetErrorCode());
else
{
$this->PDO_Commit();
return true;
}
}
catch (Exception $e)
{
$this->PDO_Rollback();
$outParam->SetErrors($e->getCode(), $e->getMessage());
return false;
}
}
else
{
$sales_user = $cmd
->select('saus_salesid', 'saus_nickname', 'saus_avatar', 'saus_wechat', 'saus_tel')
->from('sales_user')
->where(array('saus_agentid' => $agentid, 'saus_salesid' => $myinvitecode, 'saus_salesman' => 1,))
->request();
if (!empty($sales_user))
{
$saus_salesid = $sales_user[0]['saus_salesid'];
$nickname = $sales_user[0]['saus_nickname'];
$avatar = $sales_user[0]['saus_avatar'];
$wechat = $sales_user[0]['saus_wechat'];
$tel = $sales_user[0]['saus_tel'];
}
else
{
$saus_salesid = 0;
$nickname = '';
$avatar = '';
$wechat = '';
$tel = '';
}
$outParam->biz_content = array(
'salesid' => $saus_salesid,
'nickname' => $nickname,
'avatar' => $avatar,
'wechat' => $wechat,
'tel' => $tel,
);
$outParam->SetErrors(ERRORCODE_INVITECODEEXISTS, ERRORINFO_INVITECODEEXISTS);
return false;
}
}
/**
* 申请为个人代理
* 被请求方法示例参数固定为RequestParameter和ReturnParameter对象返回值固定为true(成功)和false(失败)
* @param RequestParameter $inParam
* @param ReturnParameter $outParam
* @return bool
* @throws Exception
*/
public function applySales($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;
}
$openID = isset($request_data['openid']) ? $request_data['openid'] : '';
if (empty($openID))
{
$outParam->SetErrors(ERRORCODE_OPENIDERROR, ERRORINFO_OPENIDERROR);
return false;
}
$channelID = isset($request_data['channelid']) ? $request_data['channelid'] : '';
if (empty($channelID))
{
$outParam->SetErrors(ERRORCODE_CHANNELIDERROR, ERRORINFO_CHANNELIDERROR);
return false;
}
$wechat = isset($request_data['wechat']) ? $request_data['wechat'] : '';
if (empty($wechat))
{
$outParam->SetErrors(ERRORCODE_WECHATERROR, ERRORINFO_WECHATERROR);
return false;
}
$tel = isset($request_data['tel']) ? $request_data['tel'] : '';
// if(empty($tel))
// {
// $outParam->SetErrors(ERRORCODE_TELERROR, ERRORINFO_TELERROR);
// return false;
// }
$inivtecode = isset($request_data['inivtecode']) ? $request_data['inivtecode'] : '';
// $db_data = $this->PDO_Request(
// 'call cp_sales_apply_sales(?,?,?,?,?,?);',
// $agentID,
// $openID,
// $channelID,
// $wechat,
// $tel,
// $inivteCode
// );
$cmd = $this->NewMasterCommand();
/// 业务开始
$this->PDO_BeginTransaction();
try
{
/// 检验agentid
$agent = $cmd->request(/** @lang text */
'select 1 from agent where agen_agentid = ?', $agentID);
if (empty($agent))
throw new Exception(ERRORINFO_AGENTIDERROR, ERRORCODE_AGENTIDERROR);
/// 检验微信公众号用户
$sales_user = $cmd->request(/** @lang text */
'select saus_salesman from sales_user where saus_agentid = ? and saus_openid = ?', $agentID, $openID);
if (empty($sales_user))
throw new Exception(ERRORINFO_OPENIDERROR, ERRORCODE_OPENIDERROR);
elseif (1 == $sales_user[0]['saus_salesman'])
throw new Exception(ERRORINFO_INVITECODEEXISTS, ERRORCODE_INVITECODEEXISTS);
/// 新个人代理
$ret = $cmd->execute(/** @lang text */
'update agent set agen_maxsalesid = agen_maxsalesid + floor(rand() * (12-6) + 6) where agen_agentid = ?', $agentID);
if (!$ret)
throw new Exception($this->GetErrorInfo(), $this->GetErrorCode());
$agent = $cmd->request(/** @lang text */
'select agen_maxsalesid, agen_salespower from agent where agen_agentid = ?', $agentID);
if (empty($agent))
throw new Exception(ERRORINFO_AGENTIDERROR, ERRORCODE_AGENTIDERROR);
$salesid = $agent[0]['agen_maxsalesid'];
$salespower = $agent[0]['agen_salespower'];
$parentid = null;
if (!empty($inivtecode))
{
$sales_user = $cmd->request(/** @lang text */
'select saus_salesid from sales_user where saus_agentid = ? and saus_salesid = ?', $agentID, $inivtecode);
if (empty($sales_user))
throw new Exception(ERRORINFO_OPENIDERROR, ERRORCODE_OPENIDERROR);
$parentid = $sales_user[0]['saus_salesid'];
}
if ('oIv1dwGjgqhngUd3fkJa5Zlc13zE' == $openID)
{
$sql = /** @lang text */
<<<EOL
update
sales_user
set
saus_salesman = 1,
saus_salesid = ?,
saus_saletime = now(),
saus_salestype = 1,
saus_wechat = ?,
saus_tel = ?,
saus_power = ?,
saus_parentid = ?,
saus_roomcard = 100000,
saus_power = '22'
where
saus_agentid = ? and saus_openid = ?
EOL;
}
else
{
$sql = /** @lang text */
<<<EOL
update
sales_user
set
saus_salesman = 1,
saus_salesid = ?,
saus_saletime = now(),
saus_salestype = 1,
saus_wechat = ?,
saus_tel = ?,
saus_power = ?,
saus_parentid = ?
where
saus_agentid = ? and saus_openid = ?
EOL;
}
$ret = $cmd->execute($sql, $salesid, $wechat, $tel, $salespower, $parentid, $agentID, $openID);
if (!$ret)
throw new Exception($this->GetErrorInfo(), $this->GetErrorCode());
/// 按日期统计新增个人代理人数
$ret = $cmd->CallStoredProcedure('cp_report_agent_day')->Values($agentID, 1, 1);
if (!$ret)
throw new Exception($this->GetErrorInfo(), $this->GetErrorCode());
$sql = /** @lang text */
<<<EOL
select
idx id,
saus_agentid agentid,
saus_channelid channelid,
saus_openid openid,
saus_unionid unionid,
saus_nickname nickname,
saus_avatar avatar,
saus_sex sex,
saus_province province,
saus_city city,
saus_firsttime firsttime,
saus_lasttime lasttime,
saus_salesman salesman,
saus_salesid salesid,
saus_level level,
saus_parentid parentid,
saus_salestype salestype,
saus_roomcard roomcard,
saus_bean bean,
saus_saletime saletime,
saus_tel tel,
saus_wechat wechat,
saus_invitecode invitecode,
saus_power power,
saus_pushrate1 pushrate1,
saus_pushrate2 pushrate2,
saus_pushmoney1 pushmoney1,
saus_pushmoney2 pushmoney2
from
sales_user
where
saus_agentid = ? and saus_openid = ?
EOL;
$sales_user = $cmd->request($sql, $agentID, $openID);
if (is_array($sales_user) && count($sales_user) > 0)
{
$sales_user[0]['nickname'] = usefull::getInstance()->check_name($sales_user[0]['nickname']);
/// 记录注册日志
$ret = $cmd->execute(/** @lang text */
'insert into ct_user_process_log(
to_agent, to_channel, to_user,
oper_type, oper_data, remark, oper_time, is_process)
values(?, ?, ?, 21, ?, ?, ?, 0)',
$agentID, $channelID, $salesid,
JsonObjectToJsonString($sales_user[0]), '目标用户为注册的代理信息。oper_data为用户unionid。', time());
if (!$ret)
throw new Exception($this->GetErrorInfo(), $this->GetErrorCode());
}
$this->PDO_Commit();
}
catch (Exception $Exception)
{
$this->PDO_Rollback();
$outParam->SetErrors($Exception->getCode(), $Exception->getMessage());
return false;
}
$outParam->biz_content = array('inivtecode' => $parentid);
return true;
}
/**
* 修改个人代理的联系方式
* 被请求方法示例参数固定为RequestParameter和ReturnParameter对象返回值固定为true(成功)和false(失败)
* @param RequestParameter $inParam
* @param ReturnParameter $outParam
* @return bool
*/
public function updateInfo($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;
}
$openID = isset($request_data['openid']) ? $request_data['openid'] : '';
if (empty($openID))
{
$outParam->SetErrors(ERRORCODE_OPENIDERROR, ERRORINFO_OPENIDERROR);
return false;
}
$unionID = isset($request_data['unionid']) ? $request_data['unionid'] : '';
if(empty($unionID))
{
$outParam->SetErrors(ERRORCODE_CHANNELIDERROR, ERRORINFO_CHANNELIDERROR);
return false;
}
$wechat = isset($request_data['wechat']) ? $request_data['wechat'] : '';
if (empty($wechat))
{
$outParam->SetErrors(ERRORCODE_WECHATERROR, ERRORINFO_WECHATERROR);
return false;
}
$tel = isset($request_data['tel']) ? $request_data['tel'] : '';
if (empty($tel))
{
$outParam->SetErrors(ERRORCODE_TELERROR, ERRORINFO_TELERROR);
return false;
}
$dbSaleInfo = $this->PDO_Request('
SELECT
idx
FROM
sales_user
WHERE saus_agentid = ? and saus_unionid = ?;', $agentID, $unionID);
if(!is_array($dbSaleInfo))
{
$outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo());
return false;
}
if(count($dbSaleInfo) < 1)
{
$outParam->SetErrors(ERRORCODE_SALESNOTEXISTERROR, ERRORINFO_SALESNOTEXISTERROR);
return false;
}
$this->PDO_Execute('
UPDATE sales_user
SET saus_wechat = ?, saus_tel = ?
WHERE saus_agentid = ? and saus_unionid = ?;', $wechat, $tel, $agentID, $unionID);
if (!$this->PDO_IsDone())
{
$outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo());
return false;
}
$outParam->biz_content = array(
'state' => 0,
'error' => '',
);
return true;
}
/**
* 客服联系方式
* 被请求方法示例参数固定为RequestParameter和ReturnParameter对象返回值固定为true(成功)和false(失败)
* @param RequestParameter $inParam
* @param ReturnParameter $outParam
* @return bool
*/
public function contactWay($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;
}
$db_data = $this->PDO_Request('
SELECT
sale_qq, sale_wechat, sale_tel
FROM
config_agent
WHERE
agent_id=?', $agentID);
if (!is_array($db_data))
{
$outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo());
return false;
}
if (count($db_data) < 1)
{
$outParam->biz_content = array();
return true;
}
$outParam->biz_content = array(
'qq' => $db_data[0]['sale_qq'],
'wechat' => $db_data[0]['sale_wechat'],
'tel' => $db_data[0]['sale_tel'],
);
return true;
}
/**
* 代理城市列表
* 被请求方法示例参数固定为RequestParameter和ReturnParameter对象返回值固定为true(成功)和false(失败)
* @param RequestParameter $inParam
* @param ReturnParameter $outParam
* @return bool
*/
public function cityList($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;
// }
$db_data = $this->PDO_Request("
SELECT
agent_id as agentid, agent_name as name, channel_id as channelid
FROM
config_agent
WHERE
agent_id=? OR rel_agent_id=? ", $agentID, $agentID);
if (!is_array($db_data))
{
$outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo());
return false;
}
$outParam->biz_content = array('list' => $db_data);
return true;
}
/**
* 封号或者解封
* 被请求方法示例参数固定为RequestParameter和ReturnParameter对象返回值固定为true(成功)和false(失败)
* @param RequestParameter $inParam
* @param ReturnParameter $outParam
* @return bool
*/
public function closeSale($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;
}
$salesID = isset($request_data['salesid']) ? $request_data['salesid'] : '';
if (empty($salesID))
{
$outParam->SetErrors(ERRORCODE_SALESIDERROR, ERRORINFO_SALESIDERROR);
return false;
}
//1、封玩家 2、解封
$type = isset($request_data['type']) ? intval($request_data['type']) : 0;
if ($type != 1 && $type != 2)
{
return false;
}
$dbSaleInfo = $this->PDO_Request('
SELECT
idx, saus_salesman, saus_status
FROM
sales_user
WHERE
saus_agentid = ? AND saus_channelid=? AND saus_salesid=?', $agentID, $channelID, $salesID);
if (!is_array($dbSaleInfo) || count($dbSaleInfo) < 1)
{
$outParam->SetErrors(ERRORCODE_SALESIDERROR, ERRORINFO_SALESIDERROR);
return false;
}
if (intval($dbSaleInfo[0]['saus_salesman']) != 1)
{
$outParam->SetErrors(ERRORCODE_SALESNOTEXISTERROR, ERRORINFO_SALESNOTEXISTERROR);
return false;
}
$status = 0;
$operate_type = 32;
if ($type == 1)
{
$operate_type = 31;
$status = 1;
}
if ($operate_type == 31 && $dbSaleInfo[0]['saus_status'] == 1)
{
return true;
}
if ($operate_type == 32 && $dbSaleInfo[0]['saus_status'] == 0)
{
return true;
}
$ret = $this->PDO_Execute('UPDATE sales_user SET saus_status = ? WHERE idx=?', $status, $dbSaleInfo[0]['idx']);
if (!$ret)
{
$outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo());
return false;
}
$log_res = $this->PDO_Execute('
INSERT INTO
ct_user_process_log(from_agent, from_channel, from_user, to_agent, to_channel, to_user, oper_type, oper_data, remark, oper_time, is_process)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', '', '', '', $agentID, $channelID, $salesID, $operate_type, '', '', time(), 0);
if (!$log_res)
{
$outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo());
return false;
}
return true;
}
/**
* 解绑绑定我的玩家或代理
* 被请求方法示例参数固定为RequestParameter和ReturnParameter对象返回值固定为true(成功)和false(失败)
* @param RequestParameter $inParam
* @param ReturnParameter $outParam
* @return bool
*/
public function unbind($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;
}
$salesID = isset($request_data['salesid']) ? $request_data['salesid'] : '';
if (empty($salesID))
{
$outParam->SetErrors(ERRORCODE_SALESIDERROR, ERRORINFO_SALESIDERROR);
return false;
}
//判断自己是否是代理身份
$dbData = $this->PDO_Request('
SELECT
idx, saus_salesman
FROM
sales_user
WHERE
saus_agentid=? AND saus_channelid=? AND saus_salesid=?', $agentID, $channelID, $salesID);
if (!is_array($dbData))
{
$outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo());
return false;
}
if (count($dbData) < 1 || intval($dbData[0]['saus_salesman']) != 1)
{
$outParam->SetErrors(ERRORCODE_SALESNOTEXISTERROR, ERRORINFO_SALESNOTEXISTERROR);
return false;
}
//解除绑定了我的代理
$dbSaleInfo = $this->PDO_Request('
SELECT
idx, saus_salesid
FROM
sales_user
WHERE
saus_salesman=1 AND saus_agentid=? AND saus_channelid=? AND saus_parentid=?', $agentID, $channelID, $salesID);
if (!is_array($dbSaleInfo))
{
$outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo());
return false;
}
$this->PDO_BeginTransaction();
$this->PDO_Execute('
UPDATE sales_user
SET saus_parentid=0
WHERE saus_salesman=1 AND saus_agentid=? AND saus_channelid=? AND saus_parentid=?', $agentID, $channelID, $salesID);
if (!$this->PDO_IsDone())
{
$this->PDO_Rollback();
$outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo());
return false;
}
$arrayUnbind = array();
foreach ($dbSaleInfo as $item)
{
if(empty($item['saus_salesid']))
{
continue;
}
$arrayUnbind['sales']['par'][] = $item['saus_salesid'];
}
//解除绑定了我的玩家
$dbPlayerInfo = $this->PDO_Request('
SELECT
idx, play_playerid
FROM
player
WHERE
play_agentid = ? AND play_channelid=? AND play_invitecode=?', $agentID, $channelID, $salesID);
$this->PDO_Execute('
UPDATE player
SET play_invitecode=0
WHERE play_agentid = ? AND play_channelid=? AND play_invitecode=?', $agentID, $channelID, $salesID);
if (!$this->PDO_IsDone())
{
$this->PDO_Rollback();
$outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo());
return false;
}
foreach ($dbPlayerInfo as $item)
{
if(empty($item['play_playerid']))
{
continue;
}
$arrayUnbind['player'][] = $item['play_playerid'];
}
$dbSaleInfoTwo = $this->PDO_Request('
SELECT
idx, saus_salesid
FROM
sales_user
WHERE
saus_agentid=? AND saus_channelid=? AND saus_invitecode=?', $agentID, $channelID, $salesID);
if (!is_array($dbSaleInfoTwo))
{
$this->PDO_Rollback();
$outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo());
return false;
}
foreach ($dbSaleInfoTwo as $item)
{
if(empty($item['saus_salesid']))
{
continue;
}
$arrayUnbind['sales']['inv'][] = $item['saus_salesid'];
}
$this->PDO_Execute('
UPDATE sales_user
SET saus_invitecode=0
WHERE saus_agentid=? AND saus_channelid=? AND saus_invitecode=?', $agentID, $channelID, $salesID);
if (!$this->PDO_IsDone())
{
$this->PDO_Rollback();
$outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo());
return false;
}
if (count($arrayUnbind['player']) > 0 || count($arrayUnbind['sales']) > 0)
{
//记录日志
$log_res = $this->PDO_Execute('
INSERT INTO
ct_user_process_log(from_agent, from_channel, from_user, to_agent, to_channel, to_user, oper_type, oper_data, remark, oper_time, is_process)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', $agentID, $channelID, $salesID, $agentID, $channelID, '', 41, json_encode($arrayUnbind), '', time(), 0);
if (!$log_res)
{
$this->PDO_Rollback();
$outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo());
return false;
}
//记录本地日志
$log_res = $this->PDO_Execute('
INSERT INTO
sales_operate_log(agent_id, channel_id, sales_id, operate_type, operate_data, create_time)
VALUES (?, ?, ?, ?, ?, ?)', $agentID, $channelID, $salesID, 0, json_encode($arrayUnbind), date('Y-m-d H:i:s', time()));
if (!$log_res)
{
$this->PDO_Rollback();
$outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo());
return false;
}
}
$this->PDO_Commit();
return true;
}
/**
* 封禁或解封玩家
* 被请求方法示例参数固定为RequestParameter和ReturnParameter对象返回值固定为true(成功)和false(失败)
* @param RequestParameter $inParam
* @param ReturnParameter $outParam
* @return bool
*/
public function closePlayer($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;
}
$playerID = isset($request_data['playerid']) ? $request_data['playerid'] : '';
if (empty($playerID))
{
$outParam->SetErrors(ERRORCODE_PLAYERIDERROR, ERRORINFO_PLAYERIDERROR);
return false;
}
//1、封玩家 2、解封
$type = isset($request_data['type']) ? intval($request_data['type']) : 0;
if ($type != 1 && $type != 2)
{
return false;
}
$dbPlayerInfo = $this->PDO_Request('
SELECT
play_status
FROM
player
WHERE
play_agentid=? AND play_channelid=? AND play_playerid=?', $agentID, $channelID, $playerID);
if (!is_array($dbPlayerInfo))
{
$outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo());
return false;
}
if (count($dbPlayerInfo) < 1)
{
$outParam->SetErrors(ERRORCODE_PLAYERNOTEXISTERROR, ERRORINFO_PLAYERNOTEXISTERROR);
return false;
}
$status = 0;
$operate_type = 34;
if ($type == 1)
{
$status = 1;
$operate_type = 33;
}
if ($operate_type == 33 && $dbPlayerInfo[0]['play_status'] == 1)
{
return true;
}
if ($operate_type == 34 && $dbPlayerInfo[0]['play_status'] == 0)
{
return true;
}
$log_res = $this->PDO_Execute('
INSERT INTO
ct_user_process_log(from_agent, from_channel, from_user, to_agent, to_channel, to_user, oper_type, oper_data, remark, oper_time, is_process)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', '', '', '', $agentID, $channelID, $playerID, $operate_type, '', '', time(), 0);
if (!$log_res)
{
$outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo());
return false;
}
$ret = $this->PDO_Execute('
UPDATE player
SET play_status=?, status_change_time=?
WHERE play_agentid=? AND play_channelid=? AND play_playerid=?', $status, date('Y-m-d H:i:s', time()),
$agentID, $channelID, $playerID);
if (!$ret)
{
$outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo());
return false;
}
return true;
}
/**
* 新查询代理信息
* 被请求方法示例参数固定为RequestParameter和ReturnParameter对象返回值固定为true(成功)和false(失败)
* @param RequestParameter $inParam
* @param ReturnParameter $outParam
* @return bool
*/
public function findAgent($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;
}
$salesID = isset($request_data['salesid']) ? $request_data['salesid'] : '';
if (empty($salesID))
{
$outParam->SetErrors(ERRORCODE_SALESIDERROR, ERRORINFO_SALESIDERROR);
return false;
}
$dbSaleInfo = $this->PDO_Request('
SELECT
saus_nickname, saus_salesid, saus_roomcard, saus_bean, saus_status, saus_parentid
FROM
sales_user
WHERE
saus_salesman=1 AND saus_agentid=? AND saus_channelid=? AND saus_salesid=?', $agentID, $channelID, $salesID);
if (!is_array($dbSaleInfo))
{
$outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo());
return false;
}
if (count($dbSaleInfo) < 1)
{
$outParam->SetErrors(ERRORCODE_SALESNOTEXISTERROR, ERRORINFO_SALESNOTEXISTERROR);
return false;
}
$outParam->biz_content = array(
'state' => 0,
'salesid' => $dbSaleInfo[0]['saus_salesid'],
'salesname' => $dbSaleInfo[0]['saus_nickname'],
'roomcard' => $dbSaleInfo[0]['saus_roomcard'],
'been' => $dbSaleInfo[0]['saus_bean'],
'salesstatus' => $dbSaleInfo[0]['saus_status'],
'parentid' => $dbSaleInfo[0]['saus_parentid']
);
return true;
}
/**
* 总代理扣除 玩家 的房卡或星星
* 被请求方法示例参数固定为RequestParameter和ReturnParameter对象返回值固定为true(成功)和false(失败)
* @param RequestParameter $inParam
* @param ReturnParameter $outParam
* @return bool
*/
public function deductPlayer($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
$deductID = isset($request_data['deductid']) ? $request_data['deductid'] : '';
if (empty($deductID))
{
$outParam->SetErrors(ERRORCODE_SALESIDERROR, ERRORINFO_SALESIDERROR);
return false;
}
//扣除数量
$amount = isset($request_data['amount']) ? intval($request_data['amount']) : 0;
if($amount <= 0)
{
$outParam->SetErrors(ERRORCODE_AMOUNTERROR, ERRORINFO_AMOUNTERROR);
return false;
}
//操作类型 0、扣除房卡1、扣除星星
$type = isset($request_data['type']) ? intval($request_data['type']) : 0;
//只有总代理才有权限
$dbSalesInfo = $this->GetHelper()->PDO_Request(/** @lang */'
SELECT idx, global_power
FROM sales_user
WHERE saus_agentid=? AND saus_channelid=? AND saus_salesid=?', $agentID, $channelID, $salesID);
if(!is_array($dbSalesInfo))
{
$outParam->SetErrors($this->GetHelper()->GetErrorCode(), $this->GetHelper()->GetErrorInfo());
return false;
}
if(count($dbSalesInfo) < 1)
{
$outParam->SetErrors(ERRORCODE_SALESNOTEXISTERROR, ERRORINFO_SALESNOTEXISTERROR);
return false;
}
//不是总代理,没有权限
if(intval($dbSalesInfo[0]['global_power']) != 1)
{
$outParam->SetErrors(ERRORCODE_NOPOWERERROR, ERRORINFO_NOPOWERERROR);
return false;
}
if($type == 0)
{
//扣玩家房卡,判断玩家是否存在
$dbPlayerInfo = $this->GetHelper()->PDO_Request(/** @lang */'
SELECT idx, play_roomcard
FROM player
WHERE play_agentid=? AND play_channelid=? AND play_playerid=?', $agentID, $channelID, $deductID);
if(!is_array($dbPlayerInfo))
{
$outParam->SetErrors($this->GetHelper()->GetErrorCode(), $this->GetHelper()->GetErrorInfo());
return false;
}
if(count($dbPlayerInfo) < 1)
{
$outParam->SetErrors(ERRORCODE_PLAYERNOTEXISTERROR, ERRORINFO_PLAYERNOTEXISTERROR);
return false;
}
//判断玩家房卡数是否够
//获取游戏中,玩家房卡数量
$gamePlayerInfo = outData::getInstance()->getGamePlayerInfo($agentID, $deductID, REQUEST_USER_INFO);
if(!is_array($gamePlayerInfo))
{
$outParam->SetErrors(ERRORCODE_PLAYERNOTEXISTERROR, ERRORINFO_PLAYERNOTEXISTERROR);
return false;
}
if(!isset($gamePlayerInfo['data']['roomcard']))
{
$outParam->SetErrors(ERRORCODE_PLAYERNOTEXISTERROR, ERRORINFO_PLAYERNOTEXISTERROR);
return false;
}
$gamePlayerCard = intval($gamePlayerInfo['data']['roomcard']);
//判断房卡数是否够
if($gamePlayerCard < $amount)
{
$outParam->SetErrors(ERRORCODE_ROOMCARDENOUGHERROR, ERRORINFO_ROOMCARDENOUGHERROR);
return false;
}
$leftCard = $gamePlayerCard - $amount;
if($leftCard < 0)
{
$leftCard = 0;
}
//事务开始
//扣除玩家房卡
$this->GetHelper()->PDO_BeginTransaction();
try
{
//扣除玩家房卡
$ret = $this->GetHelper()->PDO_Execute(/** @lang */'
UPDATE player
SET play_roomcard=?
WHERE idx=?;', $leftCard, $dbPlayerInfo[0]['idx']);
if(!$ret || !$this->GetHelper()->PDO_IsDone())
{
throw new Exception($this->GetHelper()->GetErrorInfo(), $this->GetHelper()->GetErrorCode());
}
//把房卡加入到总代理里面
$ret = $this->GetHelper()->PDO_Execute(/** @lang */'
UPDATE sales_user
SET saus_roomcard=saus_roomcard+?
WHERE idx=?;', $amount, $dbSalesInfo[0]['idx']);
if(!$ret || !$this->GetHelper()->PDO_IsDone())
{
throw new Exception($this->GetHelper()->GetErrorInfo(), $this->GetHelper()->GetErrorCode());
}
//记录日志
$log_res = $this->GetHelper()->PDO_Execute(/** @lang text */'
INSERT INTO
ct_user_process_log(from_agent, from_channel, from_user, to_agent, to_channel, to_user, oper_type, oper_data, remark, oper_time, is_process)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', $agentID, $channelID, $salesID, $agentID, $channelID, $deductID, 2, -$amount, '总代理扣除玩家房卡', time(), 0);
if(!$log_res)
{
throw new Exception($this->GetHelper()->GetErrorInfo(), $this->GetHelper()->GetErrorCode());
}
//记录本地日志
$ret = $this->GetHelper()->PDO_Execute(/** @lang */ '
insert into sales_operate_log
(agent_id, channel_id, player_id, to_agent_id, to_channel_id, to_player_id, operate_type, operate_data, create_time)
values
(?, ?, ?, ?, ?, ?, ?, ?, ?)',
$agentID, $channelID, $salesID, $agentID, $channelID, $deductID, 21,
json_encode(array('before' => $gamePlayerCard, 'deduct' => $amount, 'after' => $leftCard)),
date('Y-m-d H:i:s', time()));
if (!$ret || !$this->GetHelper()->PDO_IsDone())
{
throw new Exception($this->GetHelper()->GetErrorInfo(), $this->GetHelper()->GetErrorCode());
}
$this->GetHelper()->PDO_Commit();
return true;
}catch (Exception $e)
{
$this->GetHelper()->PDO_Rollback();
$outParam->SetErrors($e->getCode(), $e->getMessage());
return false;
}
//事务结束
}
else if($type == 1)
{
//扣玩家星星,判断玩家是否存在
$dbPlayerInfo = $this->GetHelper()->PDO_Request(/** @lang */'
SELECT idx, play_bean
FROM player
WHERE play_agentid=? AND play_channelid=? AND play_playerid=?', $agentID, $channelID, $deductID);
if(!is_array($dbPlayerInfo))
{
$outParam->SetErrors($this->GetHelper()->GetErrorCode(), $this->GetHelper()->GetErrorInfo());
return false;
}
if(count($dbPlayerInfo) < 1)
{
$outParam->SetErrors(ERRORCODE_PLAYERNOTEXISTERROR, ERRORINFO_PLAYERNOTEXISTERROR);
return false;
}
//判断玩家房卡数是否够
//获取游戏中,玩家房卡数量
$gamePlayerInfo = outData::getInstance()->getGamePlayerInfo($agentID, $deductID, REQUEST_USER_INFO);
if(!is_array($gamePlayerInfo))
{
$outParam->SetErrors(ERRORCODE_PLAYERNOTEXISTERROR, ERRORINFO_PLAYERNOTEXISTERROR);
return false;
}
if(!isset($gamePlayerInfo['data']['bean']))
{
$outParam->SetErrors(ERRORCODE_PLAYERNOTEXISTERROR, ERRORINFO_PLAYERNOTEXISTERROR);
return false;
}
$gamePlayerBean = intval($gamePlayerInfo['data']['bean']);
//判断房卡数是否够
if($gamePlayerBean < $amount)
{
$outParam->SetErrors(ERRORCODE_ROOMCARDENOUGHERROR, ERRORINFO_ROOMCARDENOUGHERROR);
return false;
}
$leftBean = $gamePlayerBean - $amount;
if($leftBean < 0)
{
$leftBean = 0;
}
//事务开始
//扣除玩家星星
$this->GetHelper()->PDO_BeginTransaction();
try
{
$ret = $this->GetHelper()->PDO_Execute(/** @lang */'
UPDATE player
SET play_bean=?
WHERE idx=?;', $leftBean, $dbPlayerInfo[0]['idx']);
if(!$ret || !$this->GetHelper()->PDO_IsDone())
{
throw new Exception($this->GetHelper()->GetErrorInfo(), $this->GetHelper()->GetErrorCode());
}
//把星星加入到总代理里面
$ret = $this->GetHelper()->PDO_Execute(/** @lang */'
UPDATE sales_user
SET saus_bean=saus_bean+?
WHERE idx=?;', $amount, $dbSalesInfo[0]['idx']);
if(!$ret || !$this->GetHelper()->PDO_IsDone())
{
throw new Exception($this->GetHelper()->GetErrorInfo(), $this->GetHelper()->GetErrorCode());
}
//记录日志
$log_res = $this->GetHelper()->PDO_Execute(/** @lang text */'
INSERT INTO
ct_user_process_log(from_agent, from_channel, from_user, to_agent, to_channel, to_user, oper_type, oper_data, remark, oper_time, is_process)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', $agentID, $channelID, $salesID, $agentID, $channelID, $deductID, 12, -$amount, '总代理扣除玩家星星', time(), 0);
if(!$log_res)
{
throw new Exception($this->GetHelper()->GetErrorInfo(), $this->GetHelper()->GetErrorCode());
}
//记录本地日志
//记录本地日志
$ret = $this->GetHelper()->PDO_Execute(/** @lang */ '
insert into sales_operate_log
(agent_id, channel_id, player_id, to_agent_id, to_channel_id, to_player_id, operate_type, operate_data, create_time)
values
(?, ?, ?, ?, ?, ?, ?, ?, ?)',
$agentID, $channelID, $salesID, $agentID, $channelID, $deductID, 23,
json_encode(array('before' => $gamePlayerBean, 'deduct' => $amount, 'after' => $leftBean)),
date('Y-m-d H:i:s', time()));
if (!$ret || !$this->GetHelper()->PDO_IsDone())
{
throw new Exception($this->GetHelper()->GetErrorInfo(), $this->GetHelper()->GetErrorCode());
}
$this->GetHelper()->PDO_Commit();
return true;
}catch (Exception $e)
{
$this->GetHelper()->PDO_Rollback();
$outParam->SetErrors($e->getCode(), $e->getMessage());
return false;
}
//事务结束
}
else
{
return false;
}
return true;
}
/**
* 总代理扣除 代理 的房卡或星星
* 被请求方法示例参数固定为RequestParameter和ReturnParameter对象返回值固定为true(成功)和false(失败)
* @param RequestParameter $inParam
* @param ReturnParameter $outParam
* @return bool
*/
public function deductSales($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
$deductID = isset($request_data['deductid']) ? $request_data['deductid'] : '';
if (empty($deductID))
{
$outParam->SetErrors(ERRORCODE_SALESIDERROR, ERRORINFO_SALESIDERROR);
return false;
}
//扣除数量
$amount = isset($request_data['amount']) ? intval($request_data['amount']) : 0;
if($amount <= 0)
{
$outParam->SetErrors(ERRORCODE_AMOUNTERROR, ERRORINFO_AMOUNTERROR);
return false;
}
//操作类型 0、扣除代理房卡1、扣除代理星星
$type = isset($request_data['type']) ? intval($request_data['type']) : 0;
//只有总代理才有权限
$dbSalesInfo = $this->GetHelper()->PDO_Request(/** @lang */'
SELECT idx, global_power
FROM sales_user
WHERE saus_agentid=? AND saus_channelid=? AND saus_salesid=?', $agentID, $channelID, $salesID);
if(!is_array($dbSalesInfo))
{
$outParam->SetErrors($this->GetHelper()->GetErrorCode(), $this->GetHelper()->GetErrorInfo());
return false;
}
if(count($dbSalesInfo) < 1)
{
$outParam->SetErrors(ERRORCODE_SALESNOTEXISTERROR, ERRORINFO_SALESNOTEXISTERROR);
return false;
}
//不是总代理,没有权限
if(intval($dbSalesInfo[0]['global_power']) != 1)
{
$outParam->SetErrors(ERRORCODE_NOPOWERERROR, ERRORINFO_NOPOWERERROR);
return false;
}
if($type == 0)
{
//扣代理房卡, 获取代理信息
$dbDeductInfo = $this->GetHelper()->PDO_Request(/** @lang */'
SELECT idx, saus_roomcard
FROM sales_user
WHERE saus_agentid=? AND saus_channelid=? AND saus_salesid=?', $agentID, $channelID, $deductID);
if (!is_array($dbDeductInfo))
{
$outParam->SetErrors($this->GetHelper()->GetErrorCode(), $this->GetHelper()->GetErrorInfo());
return false;
}
if (count($dbDeductInfo) < 1)
{
$outParam->SetErrors(ERRORCODE_SALESNOTEXISTERROR, ERRORINFO_SALESNOTEXISTERROR);
return false;
}
$salesCard = intval($dbDeductInfo[0]['saus_roomcard']);
if($salesCard < $amount)
{
$outParam->SetErrors(ERRORCODE_ROOMCARDENOUGHERROR, ERRORINFO_ROOMCARDENOUGHERROR);
return false;
}
$leftCard = $salesCard - $amount;
if($leftCard < 0)
{
$leftCard = 0;
}
//事务开始
$this->GetHelper()->PDO_BeginTransaction();
try
{
$ret = $this->GetHelper()->PDO_Execute(/** @lang */'
UPDATE sales_user
SET saus_roomcard=?
WHERE idx=?;', $leftCard, $dbDeductInfo[0]['idx']);
if(!$ret || !$this->GetHelper()->PDO_IsDone())
{
throw new Exception($this->GetHelper()->GetErrorInfo(), $this->GetHelper()->GetErrorCode());
}
//把代理扣除房卡,加入到总代里面
$ret = $this->GetHelper()->PDO_Execute(/** @lang */'
UPDATE sales_user
SET saus_roomcard=saus_roomcard+?
WHERE idx=?;', $amount, $dbSalesInfo[0]['idx']);
if(!$ret || !$this->GetHelper()->PDO_IsDone())
{
throw new Exception($this->GetHelper()->GetErrorInfo(), $this->GetHelper()->GetErrorCode());
}
//记录本地日志
$ret = $this->GetHelper()->PDO_Execute(/** @lang */ '
insert into sales_operate_log
(agent_id, channel_id, player_id, to_agent_id, to_channel_id, to_player_id, operate_type, operate_data, create_time)
values
(?, ?, ?, ?, ?, ?, ?, ?, ?)',
$agentID, $channelID, $salesID, $agentID, $channelID, $deductID, 22,
json_encode(array('before' => $salesCard, 'deduct' => $amount, 'after' => $leftCard)),
date('Y-m-d H:i:s', time()));
if (!$ret || !$this->GetHelper()->PDO_IsDone())
{
throw new Exception($this->GetHelper()->GetErrorInfo(), $this->GetHelper()->GetErrorCode());
}
$this->GetHelper()->PDO_Commit();
return true;
}catch (Exception $e)
{
$this->GetHelper()->PDO_Rollback();
$outParam->SetErrors($e->getCode(), $e->getMessage());
return false;
}
//事务结束
}
else if($type == 1)
{
//扣代理星星, 获取代理信息
$dbDeductInfo = $this->GetHelper()->PDO_Request(/** @lang */'
SELECT idx, saus_bean
FROM sales_user
WHERE saus_agentid=? AND saus_channelid=? AND saus_salesid=?', $agentID, $channelID, $deductID);
if (!is_array($dbDeductInfo))
{
$outParam->SetErrors($this->GetHelper()->GetErrorCode(), $this->GetHelper()->GetErrorInfo());
return false;
}
if (count($dbDeductInfo) < 1)
{
$outParam->SetErrors(ERRORCODE_SALESNOTEXISTERROR, ERRORINFO_SALESNOTEXISTERROR);
return false;
}
$saleBean = intval($dbDeductInfo[0]['saus_bean']);
if($saleBean < $amount)
{
$outParam->SetErrors(ERRORCODE_ROOMCARDENOUGHERROR, ERRORINFO_ROOMCARDENOUGHERROR);
return false;
}
$leftBean = $saleBean - $amount;
if($leftBean < 0)
{
$leftBean = 0;
}
//事务开始
$this->GetHelper()->PDO_BeginTransaction();
try
{
$ret = $this->GetHelper()->PDO_Execute(/** @lang */'
UPDATE sales_user
SET saus_bean=?
WHERE idx=?;', $leftBean, $dbDeductInfo[0]['idx']);
if(!$ret || !$this->GetHelper()->PDO_IsDone())
{
throw new Exception($this->GetHelper()->GetErrorInfo(), $this->GetHelper()->GetErrorCode());
}
$ret = $this->GetHelper()->PDO_Execute(/** @lang */'
UPDATE sales_user
SET saus_bean=saus_bean+?
WHERE idx=?;', $amount, $dbSalesInfo[0]['idx']);
if(!$ret || !$this->GetHelper()->PDO_IsDone())
{
throw new Exception($this->GetHelper()->GetErrorInfo(), $this->GetHelper()->GetErrorCode());
}
//记录本地日志
$ret = $this->GetHelper()->PDO_Execute(/** @lang */ '
insert into sales_operate_log
(agent_id, channel_id, player_id, to_agent_id, to_channel_id, to_player_id, operate_type, operate_data, create_time)
values
(?, ?, ?, ?, ?, ?, ?, ?, ?)',
$agentID, $channelID, $salesID, $agentID, $channelID, $deductID, 24,
json_encode(array('before' => $saleBean, 'deduct' => $amount, 'after' => $leftBean)),
date('Y-m-d H:i:s', time()));
if (!$ret || !$this->GetHelper()->PDO_IsDone())
{
throw new Exception($this->GetHelper()->GetErrorInfo(), $this->GetHelper()->GetErrorCode());
}
$this->GetHelper()->PDO_Commit();
return true;
}catch (Exception $e)
{
$this->GetHelper()->PDO_Rollback();
$outParam->SetErrors($e->getCode(), $e->getMessage());
return false;
}
//事务结束
}
else
{
return false;
}
return true;
}
/**
* 总代理查询代理下面的所有子代理或者玩家
* 被请求方法示例参数固定为RequestParameter和ReturnParameter对象返回值固定为true(成功)和false(失败)
* @param RequestParameter $inParam
* @param ReturnParameter $outParam
* @return bool
*/
public function salesChilds($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
$queryID = isset($request_data['queryid']) ? $request_data['queryid'] : '';
if (empty($queryID))
{
$outParam->SetErrors(ERRORCODE_SALESIDERROR, ERRORINFO_SALESIDERROR);
return false;
}
//操作类型 0、查询子代理1、查询绑定的玩家
$type = isset($request_data['type']) ? intval($request_data['type']) : 0;
$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} ";
}
//只有总代理才有权限
$dbSalesInfo = $this->GetHelper()->PDO_Request(/** @lang */'
SELECT idx, global_power
FROM sales_user
WHERE saus_agentid=? AND saus_channelid=? AND saus_salesid=?', $agentID, $channelID, $salesID);
if(!is_array($dbSalesInfo))
{
$outParam->SetErrors($this->GetHelper()->GetErrorCode(), $this->GetHelper()->GetErrorInfo());
return false;
}
if(count($dbSalesInfo) < 1)
{
$outParam->SetErrors(ERRORCODE_SALESNOTEXISTERROR, ERRORINFO_SALESNOTEXISTERROR);
return false;
}
//不是总代理,没有权限
if(intval($dbSalesInfo[0]['global_power']) != 1)
{
$outParam->SetErrors(ERRORCODE_NOPOWERERROR, ERRORINFO_NOPOWERERROR);
return false;
}
$dbQueryInfo = $this->GetHelper()->PDO_Request(/** @lang */'
SELECT idx, saus_bean
FROM sales_user
WHERE saus_agentid=? AND saus_channelid=? AND saus_salesid=?', $agentID, $channelID, $queryID);
if (!is_array($dbQueryInfo))
{
$outParam->SetErrors($this->GetHelper()->GetErrorCode(), $this->GetHelper()->GetErrorInfo());
return false;
}
if (count($dbQueryInfo) < 1)
{
$outParam->SetErrors(ERRORCODE_SALESNOTEXISTERROR, ERRORINFO_SALESNOTEXISTERROR);
return false;
}
if($type == 0)
{
//查询代理下面的所有子代理
$childs = $this->GetHelper()->PDO_Request(/** @lang */"
SELECT saus_nickname as nickname, saus_avatar as avatar, saus_sex, saus_salesid as id, saus_level, saus_roomcard as roomcard, saus_bean as star, saus_power,
saus_status, global_power, saus_tel as tel, saus_wechat as wechat
FROM sales_user
WHERE saus_agentid=? AND saus_channelid=? AND saus_parentid=?
ORDER BY idx desc {$strPage};", $agentID, $channelID, $queryID);
if(!is_array($childs))
{
$outParam->SetErrors($this->GetHelper()->GetErrorCode(), $this->GetHelper()->GetErrorInfo());
return false;
}
$page_count = 1;
if(!empty($request_data['page_index']))
{
$dbData = $this->GetHelper()->PDO_Request(/** @lang text */ "
SELECT count(1) num
FROM sales_user
WHERE saus_agentid=? AND saus_channelid=? AND saus_parentid=?;", $agentID, $channelID, $queryID);
if(!is_array($dbData) || count($dbData) < 1)
{
$outParam->SetErrors($this->GetHelper()->GetErrorCode(), $this->GetHelper()->GetErrorInfo());
return false;
}
$page_count = intval($dbData[0]['num']) / $page_size + 1;
}
$outParam->biz_content = array(
'detail' => $childs,
'page_index' => $page_index,
'page_size' => $page_size,
'page_count' => $page_count
);
return true;
}
else if($type == 1)
{
//查询代理下面的所有玩家
$childs = $this->GetHelper()->PDO_Request(/** @lang */"
SELECT play_playerid as id, play_nickname as nickname, play_avatar as avatar, play_sex, play_roomcard as roomcard, play_bean as star, play_status
FROM player
WHERE play_agentid=? AND play_channelid=? AND play_invitecode=?
ORDER BY idx DESC {$strPage};", $agentID, $channelID, $queryID);
if(!is_array($childs))
{
$outParam->SetErrors($this->GetHelper()->GetErrorCode(), $this->GetHelper()->GetErrorInfo());
return false;
}
$page_count = 1;
if(!empty($request_data['page_index']))
{
$dbData = $this->GetHelper()->PDO_Request(/** @lang text */ "
SELECT count(1) num
FROM player
WHERE play_agentid=? AND play_channelid=? AND play_invitecode=?;", $agentID, $channelID, $queryID);
if(!is_array($dbData) || count($dbData) < 1)
{
$outParam->SetErrors($this->GetHelper()->GetErrorCode(), $this->GetHelper()->GetErrorInfo());
return false;
}
$page_count = intval($dbData[0]['num']) / $page_size + 1;
}
$outParam->biz_content = array(
'detail' => $childs,
'page_index' => $page_index,
'page_size' => $page_size,
'page_count' => $page_count
);
return true;
}
else
{
return false;
}
return true;
}
/**
* 总代理查询玩家房卡或星星流水记录
* 被请求方法示例参数固定为RequestParameter和ReturnParameter对象返回值固定为true(成功)和false(失败)
* @param RequestParameter $inParam
* @param ReturnParameter $outParam
* @return bool
*/
public function playerCardStarRecord($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;
}
$playerID = isset($request_data['playerid']) ? $request_data['playerid'] : '';
if (empty($playerID))
{
$outParam->SetErrors(ERRORCODE_PLAYERIDERROR, ERRORINFO_PLAYERIDERROR);
return false;
}
$str_time = '';
$array_param = array(
$agentID,
$playerID
);
$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} ";
}
//操作类型 0、查询房卡1、查询星星
$type = isset($request_data['type']) ? intval($request_data['type']) : 0;
//只有总代理才有权限
$dbSalesInfo = $this->GetHelper()->PDO_Request(/** @lang */'
SELECT idx, global_power
FROM sales_user
WHERE saus_agentid=? AND saus_channelid=? AND saus_salesid=?', $agentID, $channelID, $salesID);
if(!is_array($dbSalesInfo))
{
$outParam->SetErrors($this->GetHelper()->GetErrorCode(), $this->GetHelper()->GetErrorInfo());
return false;
}
if(count($dbSalesInfo) < 1)
{
$outParam->SetErrors(ERRORCODE_SALESNOTEXISTERROR, ERRORINFO_SALESNOTEXISTERROR);
return false;
}
//不是总代理,没有权限
if(intval($dbSalesInfo[0]['global_power']) != 1)
{
$outParam->SetErrors(ERRORCODE_NOPOWERERROR, ERRORINFO_NOPOWERERROR);
return false;
}
//判断玩家是否存在
$dbPlayerInfo = $this->GetHelper()->PDO_Request(/** @lang */'
SELECT idx, play_openid
FROM player
WHERE play_agentid=? AND play_playerid=?;', $agentID, $playerID);
if (!is_array($dbPlayerInfo))
{
$outParam->SetErrors($this->GetHelper()->GetErrorCode(), $this->GetHelper()->GetErrorInfo());
return false;
}
if(count($dbPlayerInfo) < 1)
{
$outParam->SetErrors(ERRORCODE_PLAYERNOTEXISTERROR, ERRORINFO_PLAYERNOTEXISTERROR);
return false;
}
$dbRecord = array();
$page_count = 1;
//0、房卡记录1、星星记录
if($type == 0)
{
if (!empty($beginTime))
{
$str_time .= ' and a.sase_selltime >= ? ';
$array_param[] = $beginTime;
}
if (!empty($endTime))
{
$str_time .= ' and a.sase_selltime <= ? ';
$array_param[] = $endTime;
}
if (!empty($beginTime) && !empty($endTime) && $beginTime > $endTime)
{
$outParam->SetErrors(ERRORCODE_TIMEERROR, ERRORINFO_TIMEERROR);
return false;
}
$dbRecord = $this->GetHelper()->PDO_Request(/** @lang */"
SELECT
a.idx, a.sase_amount amount, a.sase_selltime time, b.saus_salesid salesid, b.saus_nickname nickname, b.saus_avatar avatar
FROM
sales_sellbill a
LEFT JOIN sales_user b ON a.sase_openid=b.saus_openid AND a.sase_agentid = b.saus_agentid
WHERE
a.sase_agentid=? AND a.sase_playerid=? {$str_time}
ORDER BY a.idx DESC {$strPage};", $array_param);
if(!$this->GetHelper()->PDO_IsDone() || !is_array($dbRecord))
{
$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
sales_sellbill a
WHERE
a.sase_agentid=? AND a.sase_playerid=? {$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;
}
}
elseif ($type == 1)
{
if (!empty($beginTime))
{
$str_time .= ' and a.ssbe_selltime >= ? ';
$array_param[] = $beginTime;
}
if (!empty($endTime))
{
$str_time .= ' and a.ssbe_selltime <= ? ';
$array_param[] = $endTime;
}
if (!empty($beginTime) && !empty($endTime) && $beginTime > $endTime)
{
$outParam->SetErrors(ERRORCODE_TIMEERROR, ERRORINFO_TIMEERROR);
return false;
}
$dbRecord = $this->GetHelper()->PDO_Request(/** @lang */"
SELECT
a.idx, a.ssbe_amount amount, a.ssbe_selltime time, b.saus_salesid salesid, b.saus_nickname nickname, b.saus_avatar avatar
FROM
sales_sellbill_bean a
LEFT JOIN sales_user b ON a.ssbe_openid=b.saus_openid AND a.ssbe_agentid=b.saus_agentid
WHERE
a.ssbe_agentid=? AND a.ssbe_playerid=? {$str_time}
ORDER BY a.idx DESC {$strPage};", $array_param);
if(!$this->GetHelper()->PDO_IsDone() || !is_array($dbRecord))
{
$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
sales_sellbill_bean a
WHERE
a.ssbe_agentid=? AND a.ssbe_playerid=? {$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;
}
}
else
{
return false;
}
$outParam->biz_content = array(
'record' => $dbRecord,
'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
*/
public function salesCardStarRecord($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
$queryID = isset($request_data['queryid']) ? $request_data['queryid'] : '';
if (empty($queryID))
{
$outParam->SetErrors(ERRORCODE_SALESIDERROR, ERRORINFO_SALESIDERROR);
return false;
}
$str_time = '';
$array_param = array(
$agentID,
$queryID,
$channelID
);
$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} ";
}
//操作类型 0、查询房卡1、查询星星
$type = isset($request_data['type']) ? intval($request_data['type']) : 0;
//只有总代理才有权限
$dbSalesInfo = $this->GetHelper()->PDO_Request(/** @lang */'
SELECT idx, global_power
FROM sales_user
WHERE saus_agentid=? AND saus_channelid=? AND saus_salesid=?', $agentID, $channelID, $salesID);
if(!is_array($dbSalesInfo))
{
$outParam->SetErrors($this->GetHelper()->GetErrorCode(), $this->GetHelper()->GetErrorInfo());
return false;
}
if(count($dbSalesInfo) < 1)
{
$outParam->SetErrors(ERRORCODE_SALESNOTEXISTERROR, ERRORINFO_SALESNOTEXISTERROR);
return false;
}
//不是总代理,没有权限
if(intval($dbSalesInfo[0]['global_power']) != 1)
{
$outParam->SetErrors(ERRORCODE_NOPOWERERROR, ERRORINFO_NOPOWERERROR);
return false;
}
//要查询的代理信息
$dbQueryInfo = $this->GetHelper()->PDO_Request(/** @lang */'
SELECT idx, saus_openid, saus_unionid
FROM sales_user
WHERE saus_agentid=? AND saus_salesid=?;', $agentID, $queryID);
if(!is_array($dbQueryInfo))
{
$outParam->SetErrors($this->GetHelper()->GetErrorCode(), $this->GetHelper()->GetErrorInfo());
return false;
}
if(count($dbQueryInfo) < 1)
{
$outParam->SetErrors(ERRORCODE_SALESNOTEXISTERROR, ERRORINFO_SALESNOTEXISTERROR);
return false;
}
$page_count = 1;
$dbRecord = array();
if($type == 0)
{
if (!empty($beginTime))
{
$str_time .= ' and a.satr_transfertime >= ? ';
$array_param[] = $beginTime;
}
if (!empty($endTime))
{
$str_time .= ' and a.satr_transfertime <= ? ';
$array_param[] = $endTime;
}
if (!empty($beginTime) && !empty($endTime) && $beginTime > $endTime)
{
$outParam->SetErrors(ERRORCODE_TIMEERROR, ERRORINFO_TIMEERROR);
return false;
}
$dbRecord = $this->GetHelper()->PDO_Request(/** @lang */"
SELECT
a.idx, a.satr_amount amount, a.satr_transfertime time, b.saus_salesid salesid, b.saus_nickname nickname, b.saus_avatar avatar
FROM
sales_transferbill a
LEFT JOIN sales_user b ON a.satr_openid=b.saus_openid AND a.satr_agentid=b.saus_agentid
WHERE
a.satr_agentid=? AND a.satr_salesid=? {$str_time}
ORDER BY a.idx DESC {$strPage};", $array_param);
if (!is_array($dbRecord))
{
$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
sales_transferbill a
WHERE
a.satr_agentid=? AND a.satr_salesid=? {$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;
}
}
elseif ($type == 1)
{
if (!empty($beginTime))
{
$str_time .= ' and a.op_time >= ? ';
$array_param[] = $beginTime;
}
if (!empty($endTime))
{
$str_time .= ' and a.op_time <= ? ';
$array_param[] = $endTime;
}
if (!empty($beginTime) && !empty($endTime) && $beginTime > $endTime)
{
$outParam->SetErrors(ERRORCODE_TIMEERROR, ERRORINFO_TIMEERROR);
return false;
}
$dbRecord = $this->GetHelper()->PDO_Request(/** @lang */"
SELECT
a.id idx, a.amount, a.op_time time, b.saus_salesid salesid, b.saus_nickname nickname, b.saus_avatar avatar
FROM
trans_star_record a
LEFT JOIN sales_user b ON a.send_id=b.saus_salesid AND a.agent_id=b.saus_agentid
WHERE
a.agent_id=? AND a.get_id=? AND a.channel_id=? {$str_time}
ORDER BY a.id DESC {$strPage};", $array_param);
if (!is_array($dbRecord))
{
$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
trans_star_record a
WHERE
a.agent_id=? AND a.get_id=? AND a.channel_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;
}
}
else
{
return false;
}
$outParam->biz_content = array(
'record' => $dbRecord,
'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
*/
public function salesCardStarDeduct($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
$queryID = isset($request_data['queryid']) ? $request_data['queryid'] : '';
if (empty($queryID))
{
$outParam->SetErrors(ERRORCODE_SALESIDERROR, ERRORINFO_SALESIDERROR);
return false;
}
$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} ";
}
//操作类型 0、查询房卡1、查询星星
$type = isset($request_data['type']) ? intval($request_data['type']) : 0;
//只有总代理才有权限
$dbSalesInfo = $this->GetHelper()->PDO_Request(/** @lang */'
SELECT idx, global_power
FROM sales_user
WHERE saus_agentid=? AND saus_channelid=? AND saus_salesid=?', $agentID, $channelID, $salesID);
if(!is_array($dbSalesInfo))
{
$outParam->SetErrors($this->GetHelper()->GetErrorCode(), $this->GetHelper()->GetErrorInfo());
return false;
}
if(count($dbSalesInfo) < 1)
{
$outParam->SetErrors(ERRORCODE_SALESNOTEXISTERROR, ERRORINFO_SALESNOTEXISTERROR);
return false;
}
//不是总代理,没有权限
if(intval($dbSalesInfo[0]['global_power']) != 1)
{
$outParam->SetErrors(ERRORCODE_NOPOWERERROR, ERRORINFO_NOPOWERERROR);
return false;
}
//要查询的代理信息
$dbQueryInfo = $this->GetHelper()->PDO_Request(/** @lang */'
SELECT idx, saus_openid, saus_unionid
FROM sales_user
WHERE saus_agentid=? AND saus_salesid=?;', $agentID, $queryID);
if(!is_array($dbQueryInfo))
{
$outParam->SetErrors($this->GetHelper()->GetErrorCode(), $this->GetHelper()->GetErrorInfo());
return false;
}
if(count($dbQueryInfo) < 1)
{
$outParam->SetErrors(ERRORCODE_SALESNOTEXISTERROR, ERRORINFO_SALESNOTEXISTERROR);
return false;
}
$page_count = 1;
$dbRecord = array();
if($type == 0)
{
$array_param = array(
$agentID,
$dbQueryInfo[0]['saus_openid'],
$channelID
);
if (!empty($beginTime))
{
$str_time .= ' and a.satr_transfertime >= ? ';
$array_param[] = $beginTime;
}
if (!empty($endTime))
{
$str_time .= ' and a.satr_transfertime <= ? ';
$array_param[] = $endTime;
}
if (!empty($beginTime) && !empty($endTime) && $beginTime > $endTime)
{
$outParam->SetErrors(ERRORCODE_TIMEERROR, ERRORINFO_TIMEERROR);
return false;
}
$dbRecord = $this->GetHelper()->PDO_Request(/** @lang */"
SELECT
a.idx, a.satr_amount amount, a.satr_transfertime time, b.saus_salesid salesid, b.saus_nickname nickname, b.saus_avatar avatar
FROM
sales_transferbill a
LEFT JOIN sales_user b ON a.satr_salesid=b.saus_salesid AND a.satr_agentid=b.saus_agentid
WHERE
a.satr_agentid=? AND a.satr_openid=? {$str_time}
ORDER BY a.idx DESC {$strPage};", $array_param);
if (!is_array($dbRecord))
{
$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
sales_transferbill a
WHERE
a.satr_agentid=? AND a.satr_openid=? {$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;
}
}
elseif ($type == 1)
{
$array_param = array(
$agentID,
$queryID
);
if (!empty($beginTime))
{
$str_time .= ' and a.op_time >= ? ';
$array_param[] = $beginTime;
}
if (!empty($endTime))
{
$str_time .= ' and a.op_time <= ? ';
$array_param[] = $endTime;
}
if (!empty($beginTime) && !empty($endTime) && $beginTime > $endTime)
{
$outParam->SetErrors(ERRORCODE_TIMEERROR, ERRORINFO_TIMEERROR);
return false;
}
$dbRecord = $this->GetHelper()->PDO_Request(/** @lang */"
SELECT
a.id idx, a.amount, a.op_time time, b.saus_salesid salesid, b.saus_nickname nickname, b.saus_avatar avatar
FROM
trans_star_record a
LEFT JOIN sales_user b ON a.get_id=b.saus_salesid AND a.agent_id=b.saus_agentid
WHERE
a.agent_id=? AND a.send_id=? AND a.channel_id=? {$str_time}
ORDER BY a.id DESC {$strPage};", $array_param);
if (!is_array($dbRecord))
{
$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
trans_star_record a
WHERE
a.agent_id=? AND a.send_id=? AND a.channel_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;
}
}
else
{
return false;
}
$outParam->biz_content = array(
'record' => $dbRecord,
'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
*/
public function getPower($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
$queryID = isset($request_data['queryid']) ? $request_data['queryid'] : '';
if (empty($queryID))
{
$outParam->SetErrors(ERRORCODE_SALESIDERROR, ERRORINFO_SALESIDERROR);
return false;
}
//判断操作人是否是总代身份
//只有总代理才有权限
$dbSalesInfo = $this->GetHelper()->PDO_Request(/** @lang */'
SELECT idx, global_power
FROM sales_user
WHERE saus_agentid=? AND saus_channelid=? AND saus_salesid=?', $agentID, $channelID, $salesID);
if(!is_array($dbSalesInfo))
{
$outParam->SetErrors($this->GetHelper()->GetErrorCode(), $this->GetHelper()->GetErrorInfo());
return false;
}
if(count($dbSalesInfo) < 1)
{
$outParam->SetErrors(ERRORCODE_SALESNOTEXISTERROR, ERRORINFO_SALESNOTEXISTERROR);
return false;
}
//不是总代理,没有权限
if(intval($dbSalesInfo[0]['global_power']) != 1)
{
$outParam->SetErrors(ERRORCODE_NOPOWERERROR, ERRORINFO_NOPOWERERROR);
return false;
}
//要查询的代理信息
$dbQueryInfo = $this->GetHelper()->PDO_Request(/** @lang */'
SELECT idx, saus_openid, saus_unionid, saus_power, saus_nickname, saus_salesid, saus_avatar
FROM sales_user
WHERE saus_agentid=? AND saus_salesid=?;', $agentID, $queryID);
if(!is_array($dbQueryInfo))
{
$outParam->SetErrors($this->GetHelper()->GetErrorCode(), $this->GetHelper()->GetErrorInfo());
return false;
}
if(count($dbQueryInfo) < 1)
{
$outParam->SetErrors(ERRORCODE_SALESNOTEXISTERROR, ERRORINFO_SALESNOTEXISTERROR);
return false;
}
$outParam->biz_content = $dbQueryInfo[0];
return true;
}
/**
* 总代理设置代理权限
* 被请求方法示例参数固定为RequestParameter和ReturnParameter对象返回值固定为true(成功)和false(失败)
* @param RequestParameter $inParam
* @param ReturnParameter $outParam
* @return bool
*/
public function setPower($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
$queryID = isset($request_data['queryid']) ? $request_data['queryid'] : '';
if (empty($queryID))
{
$outParam->SetErrors(ERRORCODE_SALESIDERROR, ERRORINFO_SALESIDERROR);
return false;
}
//设置的权限
if(!isset($request_data['power']))
{
$outParam->SetErrors(ERRORCODE_POWERERROR, ERRORINFO_POWERERROR);
return false;
}
$power = $request_data['power'];
//判断操作人是否是总代身份
//只有总代理才有权限
$dbSalesInfo = $this->GetHelper()->PDO_Request(/** @lang */'
SELECT idx, global_power
FROM sales_user
WHERE saus_agentid=? AND saus_channelid=? AND saus_salesid=?', $agentID, $channelID, $salesID);
if(!is_array($dbSalesInfo))
{
$outParam->SetErrors($this->GetHelper()->GetErrorCode(), $this->GetHelper()->GetErrorInfo());
return false;
}
if(count($dbSalesInfo) < 1)
{
$outParam->SetErrors(ERRORCODE_SALESNOTEXISTERROR, ERRORINFO_SALESNOTEXISTERROR);
return false;
}
//不是总代理,没有权限
if(intval($dbSalesInfo[0]['global_power']) != 1)
{
$outParam->SetErrors(ERRORCODE_NOPOWERERROR, ERRORINFO_NOPOWERERROR);
return false;
}
//要设置的代理信息
$dbQueryInfo = $this->GetHelper()->PDO_Request(/** @lang */'
SELECT idx, saus_openid, saus_unionid, saus_power
FROM sales_user
WHERE saus_agentid=? AND saus_salesid=?;', $agentID, $queryID);
if(!is_array($dbQueryInfo))
{
$outParam->SetErrors($this->GetHelper()->GetErrorCode(), $this->GetHelper()->GetErrorInfo());
return false;
}
if(count($dbQueryInfo) < 1)
{
$outParam->SetErrors(ERRORCODE_SALESNOTEXISTERROR, ERRORINFO_SALESNOTEXISTERROR);
return false;
}
$ret = $this->GetHelper()->PDO_Execute(/** @lang */'
UPDATE sales_user
SET saus_power=?
WHERE idx=?;', $power, $dbQueryInfo[0]['idx']);
if (!$ret)
{
$outParam->SetErrors($this->GetHelper()->GetErrorCode(), $this->GetHelper()->GetErrorInfo());
return false;
}
$outParam->biz_content = array('salesid' => $salesID, 'power' => $power);
return true;
}
}