biz_content) ? $inParam->biz_content : '';
if (!is_array($request_data))
{
//参数格式错误
$outParam->SetErrors(ERRORCODE_INPARAMERROR, ERRORINFO_INPARAMERROR);
return false;
}
$type = isset($request_data['type']) ? intval($request_data['type']) : 0; /// 类型(0:微信认证;1:密码认证)
$agent_id = @$request_data['agentid']; /// 代理
$channel_id = @$request_data['channelid']; /// 渠道
$sales_id = @$request_data['salesid']; /// 代理号
$open_id = @$request_data['openid']; /// openid
$union_id = @$request_data['unionid']; /// unionid
$nick_name = @$request_data['nickname']; /// 昵称
$is_log = @$request_data['islog']; /// 昵称
if (empty($agent_id))
{
$outParam->SetErrors(ERRORCODE_AGENTIDERROR, ERRORINFO_AGENTIDERROR);
return false;
}
if (empty($channel_id))
{
$outParam->SetErrors(ERRORCODE_CHANNELIDERROR, ERRORINFO_CHANNELIDERROR);
return false;
}
$this->PDO_BeginTransaction();
try
{
$retData = array();
switch ($type)
{
case 0: /// 微信认证
if (empty($open_id) && empty($union_id))
throw new Exception(ERRORINFO_OPENIDERROR, ERRORCODE_OPENIDERROR);
//if (empty($nick_name))
//throw new Exception(ERRORINFO_NICKNAMEERROR, ERRORCODE_NICKNAMEERROR);
$nick_name = usefull::getInstance()->check_name($nick_name);
$avatar = @$request_data['avatar'];
$sex = isset($request_data['sex']) ? intval($request_data['sex']) : 0;
$province = isset($request_data['province']) ? $request_data['province'] : '';
$city = isset($request_data['city']) ? $request_data['city'] : '';
if (!empty($union_id))
$dbSaleInfo = $this->PDO_Request(/** @lang text */'
select
idx, saus_agentid, saus_channelid, saus_openid, saus_unionid, saus_salesman, saus_salesid, saus_level, saus_salestype,
saus_roomcard, saus_bean, saus_power, saus_invitecode, saus_pushmoney1, saus_pushmoney2, saus_status,
password, global_power, saus_tel, saus_wechat, is_send_star, saus_nickname, saus_avatar, saus_sex,
saus_province, saus_city, user_id, player_id, is_vip, announcement
from
sales_user
where
saus_agentid = ? and saus_channelid = ? and saus_unionid = ?;',
$agent_id, $channel_id, $union_id);
else
$dbSaleInfo = $this->PDO_Request(/** @lang text */'
select
idx, saus_agentid, saus_channelid, saus_openid, saus_unionid, saus_salesman, saus_salesid, saus_level, saus_salestype,
saus_roomcard, saus_bean, saus_power, saus_invitecode, saus_pushmoney1, saus_pushmoney2, saus_status,
password, global_power, saus_tel, saus_wechat, is_send_star, saus_nickname, saus_avatar, saus_sex,
saus_province, saus_city, user_id, player_id, is_vip, announcement
from
sales_user
where
saus_agentid = ? and saus_channelid = ? and saus_openid = ?;',
$agent_id, $channel_id, $open_id);
if (!$this->PDO_IsDone())
throw new Exception($this->GetErrorInfo(), $this->GetErrorCode());
/// 无用户存在则先注册
if (count($dbSaleInfo) < 1)
{
if (!empty($union_id))
{
$command = /** @lang text */'select play_playerid from player where play_agentid = ? and play_channelid = ? and play_unionid = ?';
$ret = $this->pdo_request($command, $agent_id, $channel_id, $union_id);
}
elseif (!empty($open_id))
{
$command = /** @lang text */'select play_playerid from player where play_agentid = ? and play_channelid = ? and play_openid = ?';
$ret = $this->pdo_request($command, $agent_id, $channel_id, $open_id);
}
else
$ret = null;
if (!$this->pdo_isdone())
throw new Exception($this->geterrorinfo(), $this->geterrorcode());
elseif(empty($ret))
throw new Exception(ERRORINFO_PLAYER_NOT_EXISTS, ERRORCODE_PLAYER_NOT_EXISTS);
else
$player_id = $ret[0]['play_playerid'];
//$ret = $this->pdo_execute(/** @lang text */ 'update agent set agen_maxsalesid = agen_maxsalesid + floor(rand() * (12-6) + 6) where agen_agentid = ?', $agent_id);
$ret = $this->pdo_execute(/** @lang text */ 'update ct_agent_list set max_sales_id = max_sales_id + floor(rand() * (12-6) + 6) where agent_id = ?', $agent_id);
if (!$ret)
throw new Exception($this->GetErrorInfo(), $this->GetErrorCode());
//$agent = $this->pdo_request(/** @lang text */'select agen_maxsalesid, agen_salespower from agent where agen_agentid = ?', $agent_id);
$agent = $this->pdo_request(/** @lang text */'select max_sales_id as agen_maxsalesid, default_sales_power as agen_salespower from ct_agent_list where agent_id = ?', $agent_id);
if (empty($agent))
throw new Exception(ERRORINFO_AGENTIDERROR, ERRORCODE_AGENTIDERROR);
$sales_id = $agent[0]['agen_maxsalesid'];
$sales_power = $agent[0]['agen_salespower'];
$ret = $this->PDO_Execute(/** @lang text */'
insert into sales_user(saus_agentid, saus_channelid, saus_salesid, saus_power, saus_openid, saus_unionid, saus_nickname, saus_avatar, saus_sex, saus_province, saus_city, saus_firsttime, saus_lasttime, player_id)
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
$agent_id, $channel_id, $sales_id, $sales_power, $open_id, $union_id, $nick_name, $avatar,
$sex, $province, $city, date("Y-m-d H:i:s", time()), date("Y-m-d H:i:s", time()), $player_id);
if (!$ret)
throw new Exception($this->GetErrorInfo(), $this->GetErrorCode());
if (!empty($union_id))
$dbSaleInfo = $this->PDO_Request(/** @lang text */'
select
idx, saus_agentid, saus_channelid, saus_openid, saus_unionid, saus_salesman, saus_salesid, saus_level,
saus_salestype, saus_roomcard, saus_bean, saus_power, saus_invitecode, saus_pushmoney1,
saus_pushmoney2, saus_status, password, global_power, saus_tel, saus_wechat, is_send_star,
saus_nickname, saus_avatar, saus_sex, saus_province, saus_city, user_id, player_id, is_vip, announcement
from
sales_user
where
saus_agentid = ? and saus_channelid = ? and saus_unionid = ?', $agent_id, $channel_id, $union_id);
else
$dbSaleInfo = $this->PDO_Request(/** @lang text */'
select
idx, saus_agentid, saus_channelid, saus_openid, saus_unionid, saus_salesman, saus_salesid, saus_level,
saus_salestype, saus_roomcard, saus_bean, saus_power, saus_invitecode, saus_pushmoney1,
saus_pushmoney2, saus_status, password, global_power, saus_tel, saus_wechat, is_send_star,
saus_nickname, saus_avatar, saus_sex, saus_province, saus_city, user_id, player_id, is_vip, announcement
from
sales_user
where
saus_agentid = ? and saus_channelid = ? and saus_openid = ?;', $agent_id, $channel_id, $open_id);
if (!$this->PDO_IsDone())
throw new Exception($this->GetErrorInfo(), $this->GetErrorCode());
}
else
{
$this->PDO_Execute(/** @lang text */'
update sales_user set saus_unionid = ?, saus_openid = ?, saus_nickname = ?, saus_avatar = ?, saus_sex = ?, saus_province = ?, saus_city = ?, saus_lasttime = ? where idx = ?',
$union_id, $open_id, $nick_name, $avatar, $sex, $province, $city, date("Y-m-d H:i:s", time()),
$dbSaleInfo[0]['idx']);
if (!$this->PDO_IsDone())
throw new Exception($this->GetErrorInfo(), $this->GetErrorCode());
if ($open_id != $dbSaleInfo[0]['saus_openid'])
{
$this->PDO_Execute(/** @lang text */'
update sales_buybill set sabu_openid = ? where sabu_agentid = ? and sabu_channelid = ? and sabu_openid = ?;
update sales_sellbill set sase_openid = ? where sase_agentid = ? and channel_id = ? and sase_openid = ?;
update sales_sellbill_bean set ssbe_openid = ? where ssbe_agentid = ? and channel_id = ? and ssbe_openid = ?;
update sales_transferbill set satr_openid = ? where satr_agentid = ? and channel_id = ? and satr_openid = ?;',
$open_id, $agent_id, $channel_id, $dbSaleInfo[0]['saus_openid'],
$open_id, $agent_id, $channel_id, $dbSaleInfo[0]['saus_openid'],
$open_id, $agent_id, $channel_id, $dbSaleInfo[0]['saus_openid'],
$open_id, $agent_id, $channel_id, $dbSaleInfo[0]['saus_openid']);
if (!$this->PDO_IsDone())
throw new Exception($this->GetErrorInfo(), $this->GetErrorCode());
}
}
//0、微信登陆
$retData['logintype'] = 0;
break;
case 1: /// 账号登入
//if (0 != strcmp('veRa0qrBf0df2K1G4de2tgfmVxB2jxpv', $agent_id))
//throw new Exception('由于大部分用户密码过于简单导致大量账号被盗,密码登录功能暂时被禁止!
' . PHP_EOL . '请关注系统后续更新!
', ERRORCODE_DISABLED);
// $tel = isset($request_data['tel']) ? $request_data['tel'] : '';
// if (empty($tel))
// throw new Exception(ERRORINFO_TELERROR, ERRORCODE_TELERROR);
// //判断是否是正确的手机号
// if (!preg_match('/^1[34578]{1}\d{9}$/', $tel))
// throw new Exception(ERRORINFO_TELERROR, ERRORCODE_TELERROR);
if (empty($sales_id))
throw new Exception(ERRORINFO_SALESIDERROR, ERRORCODE_SALESIDERROR);
$password = isset($request_data['password']) ? $request_data['password'] : '';
if (empty($password))
throw new Exception(ERRORINFO_PASSWORDERROR, ERRORCODE_PASSWORDERROR);
$dbSaleInfo = $this->PDO_Request(/** @lang text */'
select
idx, saus_agentid, saus_channelid, saus_openid, saus_unionid, saus_salesman, saus_salesid, saus_level,
saus_salestype, saus_roomcard, saus_bean, saus_power, saus_invitecode, saus_pushmoney1, saus_pushmoney2,
saus_status, password, saus_nickname, saus_avatar, saus_sex, saus_province, saus_city, global_power,
saus_tel, saus_wechat, is_send_star, user_id, player_id, is_vip, announcement
from
sales_user
where
saus_agentid = ? and (saus_salesid = ? or (saus_tel = ? and is_send_star = 1)) and password = ?',
$agent_id, $sales_id, $sales_id, $password);
if (!$this->PDO_IsDone())
throw new Exception($this->GetErrorInfo(), $this->GetErrorCode());
elseif (empty($dbSaleInfo))
throw new Exception(ERRORINFO_INVALID_LOGIN_INFORMATION, ERRORCODE_INVALID_LOGIN_INFORMATION);
//1、账号密码登陆
$retData['logintype'] = 1;
break;
default:
throw new Exception(ERRORINFO_TYPEERROR, ERRORCODE_TYPEERROR);
break;
}
/// 判断是否有代理号
if (0 == intval($dbSaleInfo[0]['saus_salesid']))
{
$ret = $this->pdo_execute(/** @lang text */'update ct_agent_list set max_sales_id = max_sales_id + floor(rand() * (12-6) + 6) where agent_id = ?', $agent_id);
if (!$ret)
throw new Exception($this->GetErrorInfo(), $this->GetErrorCode());
$agent = $this->pdo_request(/** @lang text */'select max_sales_id as agen_maxsalesid, default_sales_power as agen_salespower from ct_agent_list where agent_id = ?', $agent_id);
if (empty($agent))
throw new Exception(ERRORINFO_AGENTIDERROR, ERRORCODE_AGENTIDERROR);
$sales_id = $agent[0]['agen_maxsalesid'];
$sales_power = $agent[0]['agen_salespower'];
$ret = $this->pdo_execute(/** @lang text */
'update sales_user set saus_salesid = ?, saus_power = ?, saus_salesman = 1 where idx = ?',
$sales_id, $sales_power, $dbSaleInfo[0]['idx']);
if (!$ret)
throw new Exception($this->GetErrorInfo(), $this->GetErrorCode());
}
elseif (0 == intval($dbSaleInfo[0]['saus_salesman']))
{
$ret = $this->pdo_execute(/** @lang text */'update sales_user set saus_salesman = 1 where idx = ?', $dbSaleInfo[0]['idx']);
if (!$ret)
throw new Exception($this->GetErrorInfo(), $this->GetErrorCode());
}
$nowPassword = isset($dbSaleInfo[0]['password']) ? $dbSaleInfo[0]['password'] : '';
/// 判断是否设置过密码
if (empty($nowPassword) && !empty($dbSaleInfo[0]['saus_salesid']))
{
$nowPassword = $dbSaleInfo[0]['saus_salesid'] . rand(1000, 9999);
$this->PDO_Execute(/** @lang text */'update sales_user set password = ? where idx = ?', $nowPassword, $dbSaleInfo[0]['idx']);
if (!$this->PDO_IsDone())
throw new Exception($this->GetErrorInfo(), $this->GetErrorCode());
}
if (intval($dbSaleInfo[0]['saus_salesman']) == 1) /// 是个人代理
{
/// 判断是否存在索要房卡信息
$dbAskBill = $this->PDO_Request(/** @lang text */'select idx, saab_type from sales_ask_bill where saab_agentid = ? and saab_salesid = ? and saab_state = 0;',
$dbSaleInfo[0]['saus_agentid'], $dbSaleInfo[0]['saus_salesid']);
if (!$this->PDO_IsDone())
throw new Exception($this->GetErrorInfo(), $this->GetErrorCode());
$retData['playerask'] = 0;
$retData['salesask'] = 0;
foreach ($dbAskBill as $item)
{
$askType = intval($item['saab_type']);
if ($askType == 0)
$retData['playerask'] = 1;
else if ($askType == 1)
$retData['salesask'] = 1;
}
}
/// 判断是否绑定代理
if (empty($dbSaleInfo[0]['saus_invitecode']))
{
$dbPlayerInfo = $this->PDO_Request(/** @lang text */'select play_invitecode from player where play_agentid = ? and play_unionid = ?;',
$dbSaleInfo[0]['saus_agentid'], $dbSaleInfo[0]['saus_unionid']);
if (is_array($dbPlayerInfo) && count($dbPlayerInfo) > 0)
$this->PDO_Execute(/** @lang text */'update sales_user set saus_invitecode = ? where idx=?;', $dbPlayerInfo[0]['play_invitecode'], $dbSaleInfo[0]['idx']);
}
//$db_agent_info = $this->PDO_Request(/** @lang text */'select agent_name, html_buyroomcard, html_applysales, agent_mode from config_agent where agent_id=?', $dbSaleInfo[0]['saus_agentid']);
$db_agent_info = $this->PDO_Request(/** @lang text */'select nickname agent_name, buy_card_mode html_buyroomcard, become_sales_mode html_applysales, invitation_model agent_mode, announcement from ct_channel_list where agent_id=?', $dbSaleInfo[0]['saus_agentid']);
if (!$this->PDO_IsDone())
throw new Exception($this->GetErrorInfo(), $this->GetErrorCode());
if (count($db_agent_info) < 1)
throw new Exception(ERRORINFO_AGENTNOTEXISTERROR, ERRORCODE_AGENTNOTEXISTERROR);
/// 获取用户权限并返回
$userPowers = $this->PDO_Request(/** @lang */"select id, user_name, module_id, user_auth from ct_user_authorization where user_id=?;",
$dbSaleInfo[0]['saus_salesid']);
if (!is_array($userPowers))
{
$outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo());
return false;
}
$retData['modelpowers'] = $userPowers;
// 记录登录
if($is_log) {
$login_sales_id = isset($dbSaleInfo[0]['saus_salesid']) ? $dbSaleInfo[0]['saus_salesid'] : (isset($sales_id) ? $sales_id : 0);
$sql = /** @lang text */'insert into ct_sales_login_log (agent_id, channel_id, sales_id, login_type, login_time, login_addr) values (?, ?, ?, ?, now(), ?)';
$this->PDO_Execute($sql, $agent_id, $channel_id, $login_sales_id, $retData['logintype'], @$_SERVER['REMOTE_ADDR']);
}
$this->PDO_Commit();
}
catch(Exception $e)
{
$this->PDO_Rollback();
$outParam->SetErrors($e->getCode(), $e->getMessage());
return false;
}
/// 返回用户信息
$outParam->biz_content = array(
'idx' => isset($dbSaleInfo[0]['idx']) ? $dbSaleInfo[0]['idx'] : '', /// 代理
'agentid' => isset($dbSaleInfo[0]['saus_agentid']) ? $dbSaleInfo[0]['saus_agentid'] : '', /// 代理
'channelid' => isset($dbSaleInfo[0]['saus_channelid']) ? $dbSaleInfo[0]['saus_channelid'] : '', /// 渠道
'openid' => isset($dbSaleInfo[0]['saus_openid']) ? $dbSaleInfo[0]['saus_openid'] : '', /// openid
'unionid' => isset($dbSaleInfo[0]['saus_unionid']) ? $dbSaleInfo[0]['saus_unionid'] : '', /// unionid
'nickname' => isset($dbSaleInfo[0]['saus_nickname']) ? $dbSaleInfo[0]['saus_nickname'] : '', /// 昵称
'headimgurl' => isset($dbSaleInfo[0]['saus_avatar']) ? $dbSaleInfo[0]['saus_avatar'] : '', /// 头像
'sex' => isset($dbSaleInfo[0]['saus_sex']) ? $dbSaleInfo[0]['saus_sex'] : '', /// 性别
'province' => isset($dbSaleInfo[0]['saus_province']) ? $dbSaleInfo[0]['saus_province'] : '', /// 省
'city' => isset($dbSaleInfo[0]['saus_city']) ? $dbSaleInfo[0]['saus_city'] : '', /// 市
'salesman' => empty($dbSaleInfo[0]['saus_salesman']) ? 0 : intval($dbSaleInfo[0]['saus_salesman']), /// 是否代理
'salesid' => isset($dbSaleInfo[0]['saus_salesid']) ? $dbSaleInfo[0]['saus_salesid'] : '', /// 代理编号
'level' => isset($dbSaleInfo[0]['saus_level']) ? $dbSaleInfo[0]['saus_level'] : '', /// 代理等级
'salestype' => isset($dbSaleInfo[0]['saus_salestype']) ? $dbSaleInfo[0]['saus_salestype'] : '', /// 代理类型
'roomcard' => isset($dbSaleInfo[0]['saus_roomcard']) ? $dbSaleInfo[0]['saus_roomcard'] : '', /// 账户房卡数
'bean' => isset($dbSaleInfo[0]['saus_bean']) ? $dbSaleInfo[0]['saus_bean'] : '', /// 账户金币数
'salespower' => isset($dbSaleInfo[0]['saus_power']) ? $dbSaleInfo[0]['saus_power'] : '', /// 代理权限
'agentmode' => isset($db_agent_info[0]['agent_mode']) ? $db_agent_info[0]['agent_mode'] : '', /// 分享模式
//'pushmoney' => intval($dbSaleInfo[0]['saus_pushmoney1']) + intval($dbSaleInfo[0]['saus_pushmoney2']), /// 提成金额
'sausstatus' => isset($dbSaleInfo[0]['saus_status']) ? $dbSaleInfo[0]['saus_status'] : '', /// 当前状态
'html_applysales' => isset($db_agent_info[0]['html_applysales']) ? $db_agent_info[0]['html_applysales'] : '', /// 成为代理的方式
'global_power' => isset($dbSaleInfo[0]['global_power']) ? intval($dbSaleInfo[0]['global_power']) : 0, /// 是否总代
'tel' => isset($dbSaleInfo[0]['saus_tel']) ? $dbSaleInfo[0]['saus_tel'] : '', /// 电话号码
'wechat' => isset($dbSaleInfo[0]['saus_wechat']) ? $dbSaleInfo[0]['saus_wechat'] : '', /// 微信号码
//'ppp' => $nowPassword, /// 密码
'user_id' => empty(@$dbSaleInfo[0]['user_id']) ? '' : $dbSaleInfo[0]['user_id'], /// 统一账户编号
'is_bind' => empty($dbSaleInfo[0]['saus_tel']) ? 0 : (0 == $dbSaleInfo[0]['is_send_star'] ? 0 : 1), /// 是否绑定
'logintype' => $retData['logintype'],
'player_id' => isset($dbSaleInfo[0]['player_id']) ? $dbSaleInfo[0]['player_id'] : '',
'is_vip' => $dbSaleInfo[0]['is_vip'],
'agent_announcement' => @$db_agent_info[0]['announcement'], /// 渠道公告
'sales_announcement' => @$dbSaleInfo[0]['announcement'], /// 代理公告
);
//$outParam->biz_content = $retData;
return true;
}
public function getUserInfo($request, $return)
{
$param = $request->biz_content;
if (!is_array($param))
{
//参数格式错误
$return->SetErrors(ERRORCODE_INPARAMERROR, ERRORINFO_INPARAMERROR);
return false;
}
$idx = @$param['idx']; /// 代理主键
$user_info = $this->PDO_Request(/** @lang text */'
select
saus_roomcard as roomcard, saus_bean as bean, is_vip, diamond
from
sales_user
where
idx = ?', $idx);
$return->biz_content = $user_info[0];
return true;
}
/**
* 被请求方法示例:参数固定为RequestParameter和ReturnParameter对象,返回值固定为true(成功)和false(失败)
* @note 获取用户信息
* @param RequestParameter $request
* @param ReturnParameter $return
* @return bool
*/
public function getinfo($request, $return)
{
$param = $request->biz_content;
if (!is_array($param))
{
//参数格式错误
$return->SetErrors(ERRORCODE_INPARAMERROR, ERRORINFO_INPARAMERROR);
return false;
}
$agent_id = @$param['agentid']; /// 代理
$channel_id = @$param['channelid']; /// 渠道
$sales_id = @$param['salesid']; /// 代理号
$key = md5(JsonObjectToJsonString(array('agentid' => $agent_id, 'channelid' => $channel_id, 'salesid' => $sales_id, )));
if ($result = $this->GetMemoryValue($key))
{
$return->biz_content = $result;
$this->ExpireMemoryValue($key, 600);
return true;
}
$cmd = /** @lang text */<<PDO_Request($cmd, $agent_id, $channel_id, $sales_id);
if (!$this->pdo_isdone())
{
$return->SetErrors($this->GetErrorCode(), $this->GetErrorInfo());
return false;
}
if (empty($sales_info))
{
$return->SetErrors(ERRORCODE_SALESIDERROR, ERRORINFO_SALESIDERROR);
return false;
}
$sales_info = $sales_info[0];
$cmd = /** @lang text */<<PDO_Request($cmd, $agent_id);
if (!$this->pdo_isdone())
{
$return->SetErrors($this->GetErrorCode(), $this->GetErrorInfo());
return false;
}
if (empty($agent_info))
{
$return->SetErrors(ERRORCODE_AGENTIDERROR, ERRORINFO_AGENTIDERROR);
return false;
}
$agent_info = $agent_info[0];
/// 返回用户信息
$return->biz_content = array(
'agentid' => isset($sales_info['saus_agentid']) ? $sales_info['saus_agentid'] : '', /// 代理
'channelid' => isset($sales_info['saus_channelid']) ? $sales_info['saus_channelid'] : '', /// 渠道
'openid' => isset($sales_info['saus_openid']) ? $sales_info['saus_openid'] : '', /// openid
'unionid' => isset($sales_info['saus_unionid']) ? $sales_info['saus_unionid'] : '', /// unionid
'nickname' => isset($sales_info['saus_nickname']) ? $sales_info['saus_nickname'] : '', /// 昵称
'headimgurl' => isset($sales_info['saus_avatar']) ? $sales_info['saus_avatar'] : '', /// 头像
'sex' => isset($sales_info['saus_sex']) ? $sales_info['saus_sex'] : '', /// 性别
'province' => isset($sales_info['saus_province']) ? $sales_info['saus_province'] : '', /// 省
'city' => isset($sales_info['saus_city']) ? $sales_info['saus_city'] : '', /// 市
'salesman' => empty($sales_info['saus_salesman']) ? 0 : intval($sales_info['saus_salesman']), /// 是否代理
'salesid' => isset($sales_info['saus_salesid']) ? $sales_info['saus_salesid'] : '', /// 代理编号
'level' => isset($sales_info['saus_level']) ? $sales_info['saus_level'] : '', /// 代理等级
'salestype' => isset($sales_info['saus_salestype']) ? $sales_info['saus_salestype'] : '', /// 代理类型
'roomcard' => isset($sales_info['saus_roomcard']) ? $sales_info['saus_roomcard'] : '', /// 账户房卡数
'bean' => isset($sales_info['saus_bean']) ? $sales_info['saus_bean'] : '', /// 账户金币数
'salespower' => isset($sales_info['saus_power']) ? $sales_info['saus_power'] : '', /// 代理权限
'agentmode' => isset($agent_info['agent_mode']) ? $agent_info['agent_mode'] : '', /// 分享模式
//'pushmoney' => intval($sales_info['saus_pushmoney1']) + intval($sales_info['saus_pushmoney2']), /// 提成金额
'sausstatus' => isset($sales_info['saus_status']) ? $sales_info['saus_status'] : '', /// 当前状态
'html_applysales' => isset($agent_info['html_applysales']) ? $agent_info['html_applysales'] : '', /// 成为代理的方式
'global_power' => isset($sales_info['global_power']) ? intval($sales_info['global_power']) : 0, /// 是否总代
'tel' => isset($sales_info['saus_tel']) ? $sales_info['saus_tel'] : '', /// 电话号码
'wechat' => isset($sales_info['saus_wechat']) ? $sales_info['saus_wechat'] : '', /// 微信号码
'user_id' => empty(@$sales_info['user_id']) ? '' : $sales_info['user_id'], /// 统一账户编号
'is_bind' => empty($sales_info['saus_tel']) ? 0 : (0 == $sales_info['is_send_star'] ? 0 : 1), /// 是否绑定
);
$this->SetMemoryValue($key, JsonObjectToJsonString($return->biz_content), 600);
return true;
}
/**
* 被请求方法示例:参数固定为RequestParameter和ReturnParameter对象,返回值固定为true(成功)和false(失败)
* @param RequestParameter $request
* @param ReturnParameter $return
* @return bool
*/
public function getppp($request, $return)
{
$agent_id = @$request->biz_content['agentid'];
$channel_id = @$request->biz_content['channelid'];
$sales_id = @$request->biz_content['salesid'];
if (empty($agent_id))
{
$return->SetErrors(ERRORCODE_AGENTIDERROR, ERRORINFO_AGENTIDERROR);
return false;
}
if (empty($channel_id))
{
$return->SetErrors(ERRORCODE_CHANNELIDERROR, ERRORINFO_CHANNELIDERROR);
return false;
}
if (empty($sales_id))
{
$return->SetErrors(ERRORCODE_SALESIDERROR, ERRORINFO_SALESIDERROR);
return false;
}
$ret = $this->pdo_request(/** @lang text */
'select idx, saus_salesid, password from sales_user where saus_agentid = ? and saus_channelid = ? and saus_salesid = ?',
$agent_id, $channel_id, $sales_id);
if (!$this->pdo_isdone())
{
$return->seterrors($this->geterrorcode(), $this->geterrorinfo());
return false;
}
if (empty($ret))
{
$return->seterrors(ERRORCODE_INVITECODE_NOT_EXISTS, ERRORINFO_INVITECODE_NOT_EXISTS);
return false;
}
$password = isset($ret[0]['password']) ? $ret[0]['password'] : '';
/// 判断是否设置过密码
if (empty($ret) && !empty($ret[0]['saus_salesid']))
{
$password = $ret[0]['saus_salesid'] . rand(1000, 9999);
$this->PDO_Execute(/** @lang text */'update sales_user set password = ? where idx = ?', $password, $ret[0]['idx']);
if (!$this->PDO_IsDone())
{
$return->seterrors($this->geterrorcode(), $this->geterrorinfo());
return false;
}
}
$return->biz_content = array(
'agentid' => $agent_id,
'channelid' => $channel_id,
'salesid' => $sales_id,
'ppp' => $password
);
return true;
}
/**
* 玩家查询
* 被请求方法示例:参数固定为RequestParameter和ReturnParameter对象,返回值固定为true(成功)和false(失败)
* @param RequestParameter $inParam
* @param ReturnParameter $outParam
* @return bool
*/
public function queryUser($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;
}
$playerID = isset($request_data['playerid']) ? $request_data['playerid'] : '';
if (empty($playerID))
{
$outParam->SetErrors(ERRORCODE_PLAYERIDERROR, ERRORINFO_PLAYERIDERROR);
return false;
}
$userInfo = $this->PDO_Request(
'call cp_sales_query_player(?,?,?);',
$agentID,
$openID,
$playerID
);
if (!is_array($userInfo) || count($userInfo) < 1)
{
$outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo());
return false;
}
if (!isset($userInfo[0]['result']) || intval($userInfo[0]['result']) != 0)
{
$outParam->SetErrors($userInfo[0]['result'], $userInfo[0]['error']);
return false;
}
$dbPlayerInfo = $this->PDO_Request(/** @lang text */
'
select
play_status
from
player
where
play_agentid=? and play_playerid = ?', $agentID, $playerID);
if (!is_array($dbPlayerInfo) || count($dbPlayerInfo) < 1)
{
$outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo());
return false;
}
$outParam->biz_content = array(
'state' => 0,
'playerid' => isset($userInfo[0]['playerid']) ? $userInfo[0]['playerid'] : '',
'playername' => isset($userInfo[0]['playername']) ? $userInfo[0]['playername'] : '',
'roomcard' => isset($userInfo[0]['playerroomcard']) ? $userInfo[0]['playerroomcard'] : '',
'playerstatus' => $dbPlayerInfo[0]['play_status'],
);
return true;
}
/**
* 我的信息
* 被请求方法示例:参数固定为RequestParameter和ReturnParameter对象,返回值固定为true(成功)和false(失败)
* @param RequestParameter $inParam
* @param ReturnParameter $outParam
* @return bool
*/
public function myInfo($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;
}
$myInfo = $this->PDO_Request(/** @lang text */
'
select
saus_salesid, saus_tel, saus_wechat, saus_power, saus_status, password
from
sales_user
where
saus_agentid = ? and saus_unionid = ?;', $agentID, $unionID);
if (!is_array($myInfo) || count($myInfo) < 1)
{
$outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo());
return false;
}
$outParam->biz_content = array(
'salesid' => $myInfo[0]['saus_salesid'],
'wechat' => $myInfo[0]['saus_wechat'],
'tel' => $myInfo[0]['saus_tel'],
'power' => $myInfo[0]['saus_power'],
'status' => $myInfo[0]['saus_status'],
'pw' => $myInfo[0]['password'],
);
return true;
}
/**
* 实时查询玩家信息
* 被请求方法示例:参数固定为RequestParameter和ReturnParameter对象,返回值固定为true(成功)和false(失败)
* @param RequestParameter $inParam
* @param ReturnParameter $outParam
* @return bool
*/
public function getUser($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;
}
// veRa0qrBf0df2K1G4de2tgfmVxB2jxpv/FtJf073aa0d6rI1xD8J1Y42fINTm0ziK
// $agentID = 'veRa0qrBf0df2K1G4de2tgfmVxB2jxpv';
// $channelID = 'FtJf073aa0d6rI1xD8J1Y42fINTm0ziK';
// $agentID = '00bA05haB0d9ZC0fwGD09Q2OA30insbQ';
// $channelID = 'frdt0C1GG0t91P0McFo0rbA1he5yurbS';
// $playerID = '100005';
//获取游戏服地址
/*$urlData = array(
'app' => 'youle',
'route' => 'platform',
'rpc' => 'agentserver_web',
'data' => array(
'agentid' => $agentID,
'channelid' => $channelID,
),
);
$json_data = json_encode($urlData);
$dd_ret = file_get_contents('http://ylyxservice1.willgames.cn:1089/index.html?' . $json_data);
//请求数据出错
if (!$dd_ret)
{
return false;
}
$ret_data = json_decode($dd_ret, true);
$str_url = isset($ret_data['data']['urlserver']) ? $ret_data['data']['urlserver'] : '';
if (empty($str_url))
{
return false;
}*/
//请求玩家
$playerData = array(
'app' => 'youle',
'route' => 'agent',
'rpc' => 'query_player2',
'data' => array(
'agentid' => $agentID,
'playerid' => $playerID,
),
);
$json_data = json_encode($playerData);
$dd_ret = file_get_contents(REQUEST_USER_INFO . '?' . $json_data);
/// 请求数据出错
if (!$dd_ret)
{
$outParam->SetErrors(ERRORCODE_NODATAERROR, ERRORINFO_NODATAERROR);
return false;
}
$playerInfo = json_decode($dd_ret, true);
$dbPlayerInfo = $this->PDO_Request(/** @lang text */
'select idx, play_status from player where play_agentid=? and play_playerid=? and play_channelid=?',
$agentID, $playerID, $channelID);
if (!is_array($dbPlayerInfo))
{
$outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo());
return false;
}
if (count($dbPlayerInfo) < 1)
{
$outParam->SetErrors(ERRORCODE_PLAYERNOTEXISTERROR, ERRORINFO_PLAYERNOTEXISTERROR);
return false;
}
if (!(isset($playerInfo['data']['nickname']) && isset($playerInfo['data']['roomcard']) && isset($playerInfo['data']['bean'])))
{
$outParam->SetErrors(ERRORCODE_PLAYERNOTEXISTERROR, ERRORINFO_PLAYERNOTEXISTERROR);
return false;
}
$ret = $this->PDO_Execute(/** @lang text */
'update player set play_nickname=?, play_avatar=?, play_sex=?, play_roomcard=?, play_bean=? where idx=?',
usefull::getInstance()->check_name($playerInfo['data']['nickname']),
isset($playerInfo['data']['avatar']) ? $playerInfo['data']['avatar'] : '',
isset($playerInfo['data']['sex']) ? $playerInfo['data']['sex'] : '',
isset($playerInfo['data']['roomcard']) ? $playerInfo['data']['roomcard'] : '',
isset($playerInfo['data']['bean']) ? $playerInfo['data']['bean'] : '', $dbPlayerInfo[0]['idx']);
if (!$ret)
{
$outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo());
return false;
}
$playerInfo['data']['play_status'] = $dbPlayerInfo[0]['play_status'];
$outParam->biz_content = $playerInfo['data'];
return true;
}
/**
* 实时查询玩家备注信息
* 被请求方法示例:参数固定为RequestParameter和ReturnParameter对象,返回值固定为true(成功)和false(失败)
* @param RequestParameter $inParam
* @param ReturnParameter $outParam
* @return bool
*/
public function getPlayerMemo($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;
}
$short_str = isset($request_data['short_str']) ? $request_data['short_str'] : '';
if (empty($short_str))
{
$outParam->SetErrors(200, '请输入短号');
return false;
}
//获取玩家短号信息
/*$shortInfo = $this->PDO_Request(
"
SELECT
short_str
FROM
player_short_num
WHERE
agent_id=? AND channel_id=? AND player_id=?;", $agentID, $channelID, $playerID);
if (!is_array($shortInfo) || count($shortInfo) < 1)
{
$outParam->SetErrors(ERRORCODE_PLAYERNOTEXISTERROR, ERRORINFO_PLAYERNOTEXISTERROR);
return false;
}*/
//请求玩家
$playerData = array(
'app' => 'youle',
'route' => 'agent',
'rpc' => 'query_player4',
'data' => array(
'agentid' => $agentID,
'shortcode' => $short_str,
'playerid' => $playerID,
),
);
$json_data = json_encode($playerData);
$dd_ret = file_get_contents(REQUEST_USER_INFO . '?' . $json_data);
/// 请求数据出错
if (!$dd_ret)
{
$outParam->SetErrors(ERRORCODE_NODATAERROR, ERRORINFO_NODATAERROR);
return false;
}
$playerInfo = json_decode($dd_ret, true);
if(isset($playerInfo['data'])) {
$playerInfo = $playerInfo['data'];
}
$outParam->biz_content = $playerInfo;
return true;
}
/**
* 用户修改密码
* 被请求方法示例:参数固定为RequestParameter和ReturnParameter对象,返回值固定为true(成功)和false(失败)
* @param RequestParameter $inParam
* @param ReturnParameter $outParam
* @return bool
*/
public function changePW($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;
}
$unionID = isset($request_data['unionid']) ? $request_data['unionid'] : '';
if (empty($unionID))
{
$outParam->SetErrors(ERRORCODE_CHANNELIDERROR, ERRORINFO_CHANNELIDERROR);
return false;
}
$dbSaleInfo = $this->PDO_Request(/** @lang text */
'
select
idx, saus_salesid, password
from
sales_user
where
saus_agentid = ? and saus_channelid = ? and saus_unionid = ?;', $agentID, $channelID, $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;
}
$newPW = isset($request_data['pw']) ? $request_data['pw'] : '';
if (empty($newPW))
{
$outParam->SetErrors(ERRORCODE_PASSWORDERROR, ERRORINFO_PASSWORDERROR);
return false;
}
if (strlen($newPW) < 6 || strlen($newPW) > 20)
{
$outParam->SetErrors(ERRORCODE_PASSWORDERROR, ERRORINFO_PASSWORDERROR);
return false;
}
//判断密码是否正常
if (!empty($dbSaleInfo[0]['password']))
{
$oldPW = isset($request_data['oldpw']) ? $request_data['oldpw'] : '';
if (empty($oldPW))
{
$outParam->SetErrors(ERRORCODE_OLDPASSWORDERROR, ERRORINFO_OLDPASSWORDERROR);
return false;
}
if ($oldPW == $newPW)
{
$outParam->SetErrors(ERRORCODE_OLDEQUALNEWERROR, ERRORINFO_OLDEQUALNEWERROR);
return false;
}
if ($dbSaleInfo[0]['password'] != $oldPW)
{
$outParam->SetErrors(ERRORCODE_OLDPASSWORDERROR, ERRORINFO_OLDPASSWORDERROR);
return false;
}
}
$this->PDO_Execute(/** @lang text */
'update sales_user set password=? where idx=?;', $newPW, $dbSaleInfo[0]['idx']);
if (!$this->PDO_IsDone())
{
$outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo());
return false;
}
$outParam->biz_content = array(
'saleid' => $dbSaleInfo[0]['saus_salesid'],
'pw' => $newPW,
);
return true;
}
/**
* 解绑我绑定的代理
* 被请求方法示例:参数固定为RequestParameter和ReturnParameter对象,返回值固定为true(成功)和false(失败)
* @param RequestParameter $inParam
* @param ReturnParameter $outParam
* @return bool
*/
public function releaseUser($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;
}
//判断玩家是否存在
$dbPlayerInfo = $this->PDO_Request(/** @lang */
'
SELECT idx, play_invitecode, play_unionid
FROM player
WHERE play_agentid=? AND play_playerid=? AND play_channelid=?;', $agentID, $playerID, $channelID);
/*if (!is_array($dbPlayerInfo))
{
$outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo());
return false;
}
if (count($dbPlayerInfo) < 1)
{
$outParam->SetErrors(ERRORCODE_PLAYERNOTEXISTERROR, ERRORINFO_PLAYERNOTEXISTERROR);
return false;
}
if (empty($dbPlayerInfo[0]['play_invitecode']))
{
$outParam->SetErrors(ERRORCODE_INVITECODE_NOT_EXISTS, ERRORINFO_INVITECODE_NOT_EXISTS);
return false;
}*/
$this->PDO_BeginTransaction();
try
{
$ret = $this->PDO_Execute(/** @lang */
'update player set play_invitecode = null where play_agentid=? and play_channelid=? and play_playerid = ?', $agentID, $channelID, $playerID);
if (!$ret || !$this->PDO_IsDone())
throw new Exception($this->GetErrorInfo(), $this->GetErrorCode());
$ret = $this->PDO_Execute(/** @lang */
'update sales_user set saus_invitecode = null, saus_parentid = null where saus_agentid = ? and saus_channelid = ? and player_id = ?', $agentID, $channelID, $playerID);
if (!$ret || !$this->PDO_IsDone())
throw new Exception($this->GetErrorInfo(), $this->GetErrorCode());
//记录日志
$ret = $this->PDO_Execute(/** @lang */
'
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, $agentID, $channelID, null, 42, '', '解除玩家绑定的代理', time(), 0);
if (!$ret || !$this->PDO_IsDone())
throw new Exception($this->GetErrorInfo(), $this->GetErrorCode());
//记录本地日志
$ret = $this->PDO_Execute(/** @lang */
'
insert into sales_operate_log
(agent_id, channel_id, player_id, operate_type, operate_data, create_time)
values
(?, ?, ?, ?, ?, ?)',
$agentID, $channelID, $playerID, 1, '', date('Y-m-d H:i:s', time()));
if (!$ret || !$this->PDO_IsDone())
throw new Exception($this->GetErrorInfo(), $this->GetErrorCode());
$this->PDO_Commit();
return true;
}
catch (Exception $e)
{
$this->PDO_Rollback();
$outParam->SetErrors($e->getCode(), $e->getMessage());
return false;
}
}
/**
* 查询玩家绑定的代理信息
* 被请求方法示例:参数固定为RequestParameter和ReturnParameter对象,返回值固定为true(成功)和false(失败)
* @param RequestParameter $inParam
* @param ReturnParameter $outParam
* @return bool
*/
public function mySale($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;
}
//判断玩家是否存在
$dbPlayerInfo = $this->PDO_Request(/** @lang */
'
SELECT idx, play_invitecode
FROM player
WHERE play_agentid=? AND play_playerid=? AND play_channelid=?;', $agentID, $playerID, $channelID);
if (!is_array($dbPlayerInfo))
{
$outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo());
return false;
}
if (count($dbPlayerInfo) < 1)
{
$outParam->SetErrors(ERRORCODE_PLAYERNOTEXISTERROR, ERRORINFO_PLAYERNOTEXISTERROR);
return false;
}
if (empty($dbPlayerInfo[0]['play_invitecode']))
{
$outParam->SetErrors(ERRORCODE_NOBINDERROR, '该玩家未绑定上级');
return false;
}
$dbSaleInfo = $this->PDO_Request(/** @lang */
'
SELECT saus_nickname, saus_avatar, saus_sex, saus_salesid
FROM sales_user
WHERE saus_agentid=? AND saus_channelid=? AND saus_salesid=?;', $agentID, $channelID, $dbPlayerInfo[0]['play_invitecode']);
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 = $dbSaleInfo[0];
return true;
}
/**
* 玩家加入代理的俱乐部
* 被请求方法示例:参数固定为RequestParameter和ReturnParameter对象,返回值固定为true(成功)和false(失败)
* @param RequestParameter $inParam
* @param ReturnParameter $outParam
* @return bool
*/
public function entryClub($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
$playerID = isset($request_data['playerid']) ? $request_data['playerid'] : '';
if (empty($playerID))
{
$outParam->SetErrors(ERRORCODE_PLAYERIDERROR, ERRORINFO_PLAYERIDERROR);
return false;
}
//俱乐部的代理id
$salesID = isset($request_data['salesid']) ? $request_data['salesid'] : '';
if (empty($salesID))
{
$outParam->SetErrors(ERRORCODE_SALESIDERROR, ERRORINFO_SALESIDERROR);
return false;
}
//判断玩家是否存在
$dbPlayerInfo = $this->PDO_Request(/** @lang */
'
SELECT idx, play_unionid, play_nickname
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;
}
//判断代理是否存在
$dbSalesInfo = $this->PDO_Request(/** @lang */
'
SELECT idx, saus_nickname
FROM sales_user
WHERE saus_agentid=? AND saus_channelid=? AND saus_salesid=?;', $agentID, $channelID, $salesID);
if (!is_array($dbSalesInfo))
{
$outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo());
return false;
}
if (count($dbSalesInfo) < 1)
{
$outParam->SetErrors(ERRORCODE_SALESNOTEXISTERROR, ERRORINFO_SALESNOTEXISTERROR);
return false;
}
//判断玩家是否已经参加俱乐部
$clubInfo = $this->PDO_Request(/** @lang */
'
SELECT idx, club_id
FROM player_club
WHERE agent_id=? AND channel_id=? AND player_id=?;', $agentID, $channelID, $playerID);
if (!is_array($clubInfo))
{
$outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo());
return false;
}
$this->PDO_BeginTransaction();
try
{
$clubData = array();
foreach ($clubInfo as $item)
{
$clubData[] = $item['club_id'];
}
if (count($clubInfo) < 1)
{
//没有参加过俱乐部
$ret = $this->PDO_Execute(/** @lang */
'
INSERT INTO player_club(agent_id, channel_id, union_id, player_id, club_id, sales_id, create_time)
VALUES(?, ?, ?, ?, ?, ?, ?);', $agentID, $channelID, $dbPlayerInfo[0]['play_unionid'], $playerID, $salesID, $salesID, date('Y-m-d H:i:s', time()));
if (!$ret)
{
throw new Exception($this->GetErrorInfo(), $this->GetErrorCode());
}
$clubData = array($salesID);
//写入日志
$log_res = $this->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, $playerID, 102, json_encode($clubData), '玩家参加俱乐部', time(), 0);
if (!$log_res)
{
throw new Exception($this->GetErrorInfo(), $this->GetErrorCode());
}
}
else
{
//目前只能参加一个俱乐部
if ($salesID == $clubInfo[0]['club_id'])
{
//已经绑定了这个俱乐部
throw new Exception(ERRORINFO_CLUBENTEDEXISTS, ERRORCODE_CLUBENTEDEXISTS);
}
$ret = $this->PDO_Execute(/** @lang */
'
UPDATE player_club
SET club_id=?, sales_id=?, create_time=?
WHERE idx=?;', $salesID, $salesID, date('Y-m-d H:i:s', time()), $clubInfo[0]['idx']);
if (!$ret)
{
throw new Exception($this->GetErrorInfo(), $this->GetErrorCode());
}
$clubData = array($salesID);
//写入日志
$log_res = $this->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, $playerID, 102, json_encode($clubData), '玩家更换俱乐部', time(), 0);
if (!$log_res)
{
throw new Exception($this->GetErrorInfo(), $this->GetErrorCode());
}
}
$this->PDO_Commit();
}
catch (Exception $e)
{
$this->PDO_Rollback();
$outParam->SetErrors($e->getCode(), $e->getMessage());
return false;
}
return true;
}
/**
* 通过代理商id和微信id获取玩家id
* 被请求方法示例:参数固定为RequestParameter和ReturnParameter对象,返回值固定为true(成功)和false(失败)
* @param RequestParameter $inParam
* @param ReturnParameter $outParam
* @return bool
*/
public function getPlayer($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;
}
$unionID = isset($request_data['unionid']) ? $request_data['unionid'] : '';
if (empty($unionID))
{
$outParam->SetErrors(ERRORCODE_UNIONIDERROR, ERRORINFO_UNIONIDERROR);
return false;
}
$playerInfo = $this->PDO_Request(/** @lang */
'
SELECT play_playerid, play_nickname, play_avatar, play_sex, play_roomcard, play_bean
FROM player
WHERE play_agentid=? AND play_channelid=? AND play_unionid=?;', $agentID, $channelID, $unionID);
if (!is_array($playerInfo))
{
$outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo());
return false;
}
if (count($playerInfo) < 1)
{
$outParam->SetErrors(ERRORCODE_PLAYERNOTEXISTERROR, ERRORINFO_PLAYERNOTEXISTERROR);
return false;
}
$outParam->biz_content = $playerInfo[0];
return true;
}
/**
* 玩家添加或删除短号白名单
* 被请求方法示例:参数固定为RequestParameter和ReturnParameter对象,返回值固定为true(成功)和false(失败)
* @param RequestParameter $inParam
* @param ReturnParameter $outParam
* @return bool
* method=agent.user.changeWhiteList&format=json&charset=utf-8×tamp=1&version=1.0&biz_content={"agentid":"00bA05haB0d9ZC0fwGD09Q2OA30insbQ","channelid":"frdt0C1GG0t91P0McFo0rbA1he5yurbS","playerid":"137892","type":2,"whiteid":"137900"}
*/
public function changeWhiteList($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
$playerID = isset($request_data['playerid']) ? $request_data['playerid'] : '';
$collection_code = isset($request_data['collectioncode']) ? $request_data['collectioncode'] : '';
$player_remark = isset($request_data['remark']) ? $request_data['remark'] : '';
//操作类型1、添加,2、删除
$type = isset($request_data['type']) ? intval($request_data['type']) : 0;
if ($type != 1 && $type != 2)
{
$outParam->SetErrors(ERRORCODE_TYPEERROR, ERRORINFO_TYPEERROR);
return false;
}
//白名单
$whiteID = isset($request_data['whiteid']) ? $request_data['whiteid'] : '';
if (empty($whiteID) || strlen($whiteID) > 10)
{
$outParam->SetErrors(ERRORCODE_WHITEIDERROR, ERRORINFO_WHITEIDERROR);
return false;
}
// 玩家只能加入一个短号房
// if($type == 1) {
// $is_in = $this->PDO_Request("SELECT
// id
// FROM
// ct_short_number_player_list
// WHERE
// agent_id=? and channel_id=? and player_id=?;", $agentID, $channelID, $whiteID);
// if (!is_array($is_in))
// {
// $outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo());
// return false;
// }
// if($is_in) {
// $outParam->SetErrors(4490, '玩家只能加入一个短号房');
// return false;
// }
// }
//获取玩家短号信息
$shortInfo = $this->PDO_Request(/** @lang */
"
SELECT
id, short_str, max_room, collection_code
FROM
player_short_num
WHERE
agent_id=? AND channel_id=? AND player_id=?;", $agentID, $channelID, $playerID);
if (!is_array($shortInfo) || count($shortInfo) < 1)
{
$outParam->SetErrors(ERRORCODE_PLAYERNOTEXISTERROR, ERRORINFO_PLAYERNOTEXISTERROR);
return false;
}
//判断玩家是否有这个白名单 property_1 => 收款码 property_2 => 备注
$whiteList = $this->PDO_Request(/** @lang */
"
SELECT
id, player_id, property_1 as collection_code, property_2 as remark
FROM
ct_short_number_player_list
WHERE
short_id=?;", $shortInfo[0]['id']);
if (!is_array($whiteList))
{
$outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo());
return false;
}
$existFlag = 0; // 0、不存在,1、存在
$playerWhiteList = array();
foreach ($whiteList as $item)
{
$playerWhiteList[] = [$item['player_id'], $item['collection_code'], $item['remark']];
//$playerWhiteList[] = $item['player_id'];
if ($item['player_id'] == $whiteID)
{
$existFlag = 1;
}
}
$this->PDO_BeginTransaction();
try
{
if ($type == 1)
{
if(count($whiteList) >= 1000)
throw new Exception('添加失败,已达到最大人数1000人', 400);
//添加
if ($existFlag == 1)
{
//已经存在,不用添加
throw new Exception(ERRORINFO_WHITEEXISTERROR, ERRORCODE_WHITEEXISTERROR);
}
//加入白名单列表
$ret = $this->PDO_Execute(/** @lang */"
insert into
ct_short_number_player_list(short_id, agent_id, channel_id, player_id, type, property_1, property_2)
values(?, ?, ?, ?, 1, ?, ?);", $shortInfo[0]['id'], $agentID, $channelID, $whiteID, $collection_code, $player_remark);
if (!$ret || !$this->PDO_IsDone())
{
throw new Exception($this->GetErrorInfo(), $this->GetErrorCode());
}
//$playerWhiteList[] = $whiteID;
$newPlayerWhite = [$shortInfo[0]['short_str'],$whiteID, $collection_code, $player_remark];
//记录玩家白名单列表
//写入日志
$log_res = $this->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, $playerID, $agentID, $channelID, '', 113, json_encode($newPlayerWhite), "玩家添加或修改白名单(ID:{$whiteID},code:{$collection_code},remark:{$player_remark})", time(), 0);
if (!$log_res)
{
throw new Exception($this->GetErrorInfo(), $this->GetErrorCode());
}
$result = $this->PDO_Request(/** @lang text */
'select play_nickname as nickname from player where play_agentid=? and play_channelid=? and play_playerid = ?;',
$agentID, $channelID, $whiteID
);
$outParam->biz_content = isset($result[0]) ? $result[0] : array('nickname' => '');
}
else if ($type == 2)
{
//从白名单列表中删除
if ($existFlag == 0)
{
//已经存在,不用添加
throw new Exception(ERRORINFO_WHITENOTEXISTERROR, ERRORCODE_WHITENOTEXISTERROR);
}
$player_white_info = $this->PDO_Request(/** @lang */
"
select property_1 as collection_code, property_2 as remark FROM
ct_short_number_player_list
WHERE
short_id=? AND player_id=? AND type=1;", $shortInfo[0]['id'], $whiteID);
//加入白名单列表
$ret = $this->PDO_Execute(/** @lang */
"
DELETE FROM
ct_short_number_player_list
WHERE
short_id=? AND player_id=? AND type=1;", $shortInfo[0]['id'], $whiteID);
if (!$ret || !$this->PDO_IsDone())
{
throw new Exception($this->GetErrorInfo(), $this->GetErrorCode());
}
foreach ($playerWhiteList as $key => $value)
{
if (is_array($value) && ($value[0] == $whiteID))
{
$delKey = $key;
break;
}
}
if ($delKey != -1)
{
array_splice($playerWhiteList, $delKey, 1);
}
$info = [$shortInfo[0]['short_str'], $whiteID, $player_white_info[0]['collection_code'], $player_white_info[0]['remark']];
//记录玩家白名单列表
//写入日志
$log_res = $this->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, $playerID, $agentID, $channelID, '', 114, json_encode($info), '玩家删除白名单' . $whiteID, time(), 0);
if (!$log_res)
{
throw new Exception($this->GetErrorInfo(), $this->GetErrorCode());
}
}
$this->PDO_Commit();
}
catch (Exception $e)
{
$this->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=agent.user.whiteList&format=json&charset=utf-8×tamp=1&version=1.0&biz_content={"agentid":"00bA05haB0d9ZC0fwGD09Q2OA30insbQ","channelid":"frdt0C1GG0t91P0McFo0rbA1he5yurbS","playerid":"137892"}
*/
public function whiteList($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
$playerID = isset($request_data['playerid']) ? $request_data['playerid'] : '';
//获取玩家短号信息
$shortInfo = $this->PDO_Request(/** @lang */
"
SELECT
id, short_str, max_room, collection_code
FROM
player_short_num
WHERE
agent_id=? AND channel_id=? AND player_id=?;", $agentID, $channelID, $playerID);
if (!is_array($shortInfo) || count($shortInfo) < 1)
{
$outParam->SetErrors(ERRORCODE_PLAYERNOTEXISTERROR, ERRORINFO_PLAYERNOTEXISTERROR);
return false;
}
//白名单列表 property_1 -> 收款码
$whiteList = $this->PDO_Request(/** @lang */
"
SELECT
id, player_id, property_1 as collection_code, play_nickname as nickname, property_2 as remark
FROM
ct_short_number_player_list LEFT JOIN player on player_id = play_playerid and play_agentid = ? and play_channelid = ?
WHERE
short_id=?;", $agentID, $channelID, $shortInfo[0]['id']);
if (!is_array($whiteList))
{
$outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo());
return false;
}
$outParam->biz_content = $whiteList;
return true;
}
/**
* 通过玩家openid和unionid查询短号
* 被请求方法示例:参数固定为RequestParameter和ReturnParameter对象,返回值固定为true(成功)和false(失败)
* @param RequestParameter $inParam
* @param ReturnParameter $outParam
* @return bool
*method=agent.user.queryShortNum&format=json&charset=utf-8×tamp=1&version=1.0&biz_content={"agentid":"00bA05haB0d9ZC0fwGD09Q2OA30insbQ","channelid":"frdt0C1GG0t91P0McFo0rbA1he5yurbS","openid":"ohRakwu0Ua6vLSq336LjDNa-RmOA","unionid":"oLVKis6bj3_l8qspMybG60KV2GN4"}
*/
public function queryShortNum($inParam, $outParam)
{
$request_data = isset($inParam->biz_content) ? $inParam->biz_content : '';
if (!is_array($request_data))
{
//参数格式错误
$outParam->SetErrors(ERRORCODE_INPARAMERROR, ERRORINFO_INPARAMERROR);
return false;
}
$agent_id = @$request_data['agentid']; /// 代理
$channel_id = @$request_data['channelid']; /// 渠道
$player_id = @$request_data['playerid']; /// 玩家号
if (empty($agent_id))
{
$outParam->SetErrors(ERRORCODE_AGENTIDERROR, ERRORINFO_AGENTIDERROR);
return false;
}
if (empty($channel_id))
{
$outParam->SetErrors(ERRORCODE_CHANNELIDERROR, ERRORINFO_CHANNELIDERROR);
return false;
}
if (empty($player_id))
{
$outParam->SetErrors(ERRORCODE_PLAYERIDERROR, ERRORINFO_PLAYERIDERROR);
return false;
}
/// 查询当前玩家
$result = $this->PDO_Request(/** @lang */'select player_id, short_str, max_room, collection_code, des_one, des_two, lower_limit, announcement from player_short_num where agent_id=? and channel_id=? and player_id=?;',
$agent_id, $channel_id, $player_id);
if(isset($result[0]))
$outParam->biz_content = isset($result[0]) ? $result[0] : array();
return $this->PDO_IsDone();
}
/**
* 查询用户的密码
* @param RequestParameter $inParam
* @param ReturnParameter $outParam
* @return bool
*/
public function querySalesPassword($inParam, $outParam)
{
$request_data = isset($inParam->biz_content) ? $inParam->biz_content : '';
if (!is_array($request_data))
{
//参数格式错误
$outParam->SetErrors(ERRORCODE_INPARAMERROR, ERRORINFO_INPARAMERROR);
return false;
}
$agent_id = @$request_data['agentid']; /// 代理
$channel_id = @$request_data['channelid']; /// 渠道
$sales_id = @$request_data['salesid'];
$query_id = @$request_data['queryid'];
if (empty($agent_id))
{
$outParam->SetErrors(ERRORCODE_AGENTIDERROR, ERRORINFO_AGENTIDERROR);
return false;
}
if (empty($channel_id))
{
$outParam->SetErrors(ERRORCODE_CHANNELIDERROR, ERRORINFO_CHANNELIDERROR);
return false;
}
if (empty($sales_id))
{
$outParam->SetErrors(ERRORCODE_SALESIDERROR, ERRORINFO_SALESNOTEXISTERROR);
return false;
}
if (empty($query_id))
{
$outParam->SetErrors(ERRORCODE_SALESIDERROR, ERRORINFO_SALESNOTEXISTERROR);
return false;
}
/// 查询当前玩家
$sql = /** @lang text */'select saus_nickname as nickname, saus_salesid as salesid, password from sales_user where saus_agentid = ? and saus_channelid = ? and player_id = ?;';
$tmp = $this->PDO_Request($sql, $agent_id, $channel_id, $query_id);
if(is_array($tmp) && isset($tmp[0]))
$outParam->biz_content = $tmp[0];
else {
$outParam->SetErrors(1000, '该用户不存在');
return false;
}
return $this->PDO_IsDone();
}
/**
* 获取所有模块的权限标识
* 被请求方法示例:参数固定为RequestParameter和ReturnParameter对象,返回值固定为true(成功)和false(失败)
* @param RequestParameter $inParam
* @param ReturnParameter $outParam
* @return bool
*
*/
public function modelPower($inParam, $outParam)
{
$model = $this->PDO_Request(/** @lang */'select module_id, module_name, parent_id from ct_system_module');
if (!is_array($model))
{
$outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo());
return false;
}
$outParam->biz_content = $model;
return true;
}
/******************************************************************************************
* ================ summer 2017/12/13 Handel 代理分成部分业务 ====================== *
*****************************************************************************************/
##------------ 渠道类型操作[curd] 总代才有使用权限
##------------[表:sales_user] ------------------------>
/**
* 总代/管理员登录
* @param RequestParameter $inParam
* @param ReturnParameter $outParam
* @return bool
*/
public function admin_login($inParam, $outParam)
{
$request_data = isset($inParam->biz_content) ? $inParam->biz_content : '';
if (!is_array($request_data))
{
//参数格式错误
$outParam->SetErrors(ERRORCODE_INPARAMERROR, ERRORINFO_INPARAMERROR);
return false;
}
$agent_id = empty($request_data['agentid']) ? false : $request_data['agentid']; // 代理号 登录账号
$channel_id = empty($request_data['channelid']) ? false : $request_data['channelid']; // 代理号 登录账号
$sales_id = empty($request_data['sales_id']) ? false : $request_data['sales_id']; // 代理号 登录账号
$password = empty($request_data['password']) ? false : $request_data['password']; // 登录密码
$client = empty($request_data['client']) ? 'pc' : $request_data['client']; // 登录端
if (!$agent_id || !$channel_id) {
$outParam->SetErrors(ERRORCODE_AGENTNOTEXISTERROR, ERRORINFO_AGENTNOTEXISTERROR);
return false;
}
if (!$sales_id || !$password) {
$outParam->SetErrors(ERRORCODE_INVALID_LOGIN_INFORMATION, ERRORINFO_INVALID_LOGIN_INFORMATION);
return false;
}
$this->PDO_BeginTransaction();
try
{
$dbSaleInfo = $this->PDO_Request(/** @lang text */'
SELECT
idx, saus_agentid, saus_channelid, saus_openid, saus_unionid, saus_salesman, saus_salesid, saus_level,
saus_salestype, saus_roomcard, saus_bean, saus_power, saus_invitecode, saus_pushmoney1, saus_pushmoney2,
saus_status, password, saus_nickname, saus_avatar, saus_sex, saus_province, saus_city, global_power,
saus_tel, saus_wechat, is_send_star, user_id, saus_commit_auth
FROM
sales_user
WHERE
saus_agentid = ? and saus_channelid = ? and saus_salesid = ? and password = ?;',
$agent_id, $channel_id, $sales_id, $password);
if (!$this->PDO_IsDone())
throw new Exception($this->GetErrorInfo(), $this->GetErrorCode());
elseif (empty($dbSaleInfo))
throw new Exception(ERRORINFO_INVALID_LOGIN_INFORMATION, ERRORCODE_INVALID_LOGIN_INFORMATION);
switch ($client) {
case 'pc':
if ($dbSaleInfo[0]['global_power'] != 1) {
$outParam->SetErrors(ERRORCODE_NOPOWERERROR, ERRORINFO_NOPOWERERROR);
return false;
}
break;
case 'mob':
if (1 != $dbSaleInfo[0]['saus_commit_auth']) {
$outParam->SetErrors(ERRORCODE_NOPOWERERROR, ERRORINFO_NOPOWERERROR);
return false;
}
break;
default:
if ($dbSaleInfo[0]['global_power'] != 1) {
$outParam->SetErrors(ERRORCODE_NOPOWERERROR, ERRORINFO_NOPOWERERROR);
return false;
}
break;
}
$db_agent_info = $this->PDO_Request(/** @lang text */'
SELECT
nickname as agent_name, buy_card_mode as html_buyroomcard, become_sales_mode as html_applysales, invitation_model as agent_mode
FROM
ct_channel_list
WHERE
agent_id=?', $dbSaleInfo[0]['saus_agentid']);
if (!$this->PDO_IsDone())
throw new Exception($this->GetErrorInfo(), $this->GetErrorCode());
if (count($db_agent_info) < 1)
throw new Exception(ERRORINFO_AGENTNOTEXISTERROR, ERRORCODE_AGENTNOTEXISTERROR);
/// 获取用户权限并返回
$userPowers = $this->PDO_Request(/** @lang text */"
SELECT
id, user_name, module_id, user_auth
FROM
ct_user_authorization
WHERE
user_id=?;", $dbSaleInfo[0]['saus_salesid']);
if (!is_array($userPowers))
{
$outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo());
return false;
}
$retData['modelpowers'] = $userPowers;
$this->PDO_Commit();
}
catch(Exception $e)
{
$this->PDO_Rollback();
$outParam->SetErrors($e->getCode(), $e->getMessage());
return false;
}
/// 返回用户信息
$outParam->biz_content = array(
'commit_auth' => $dbSaleInfo[0]['saus_commit_auth'], // 代理结算后台权限
'agentid' => isset($dbSaleInfo[0]['saus_agentid']) ? $dbSaleInfo[0]['saus_agentid'] : '', // 代理
'channelid' => isset($dbSaleInfo[0]['saus_channelid']) ? $dbSaleInfo[0]['saus_channelid'] : '', // 渠道
'openid' => isset($dbSaleInfo[0]['saus_openid']) ? $dbSaleInfo[0]['saus_openid'] : '', // openid
'unionid' => isset($dbSaleInfo[0]['saus_unionid']) ? $dbSaleInfo[0]['saus_unionid'] : '', // unionid
'nickname' => isset($dbSaleInfo[0]['saus_nickname']) ? $dbSaleInfo[0]['saus_nickname'] : '', // 昵称
'headimgurl' => isset($dbSaleInfo[0]['saus_avatar']) ? $dbSaleInfo[0]['saus_avatar'] : '', // 头像
'sex' => isset($dbSaleInfo[0]['saus_sex']) ? $dbSaleInfo[0]['saus_sex'] : '', // 性别
'province' => isset($dbSaleInfo[0]['saus_province']) ? $dbSaleInfo[0]['saus_province'] : '', // 省
'city' => isset($dbSaleInfo[0]['saus_city']) ? $dbSaleInfo[0]['saus_city'] : '', // 市
'salesman' => !empty($dbSaleInfo[0]['saus_salesman']) ? intval($dbSaleInfo[0]['saus_salesman']) : 0, // 是否代理
'salesid' => isset($dbSaleInfo[0]['saus_salesid']) ? $dbSaleInfo[0]['saus_salesid'] : '', // 代理编号
'level' => isset($dbSaleInfo[0]['saus_level']) ? $dbSaleInfo[0]['saus_level'] : '', // 代理等级
'salestype' => isset($dbSaleInfo[0]['saus_salestype']) ? $dbSaleInfo[0]['saus_salestype'] : '', // 代理类型
'roomcard' => isset($dbSaleInfo[0]['saus_roomcard']) ? $dbSaleInfo[0]['saus_roomcard'] : '', // 账户房卡数
'bean' => isset($dbSaleInfo[0]['saus_bean']) ? $dbSaleInfo[0]['saus_bean'] : '', // 账户金币数
'salespower' => isset($dbSaleInfo[0]['saus_power']) ? $dbSaleInfo[0]['saus_power'] : '', // 代理权限
'agentmode' => isset($db_agent_info[0]['agent_mode']) ? $db_agent_info[0]['agent_mode'] : '', // 分享模式
'sausstatus' => isset($dbSaleInfo[0]['saus_status']) ? $dbSaleInfo[0]['saus_status'] : '', // 当前状态
'html_applysales' => isset($db_agent_info[0]['html_applysales'])? $db_agent_info[0]['html_applysales'] : '', // 成为代理的方式
'global_power' => isset($dbSaleInfo[0]['global_power']) ? intval($dbSaleInfo[0]['global_power']) : 0, // 是否总代
'tel' => isset($dbSaleInfo[0]['saus_tel']) ? $dbSaleInfo[0]['saus_tel'] : '', // 电话号码
'wechat' => isset($dbSaleInfo[0]['saus_wechat']) ? $dbSaleInfo[0]['saus_wechat'] : '', // 微信号码
'user_id' => !empty(@$dbSaleInfo[0]['user_id']) ? $dbSaleInfo[0]['user_id'] : '', // 统一账户编号
'is_bind' => empty($dbSaleInfo[0]['saus_tel']) ? 0 : (0 == $dbSaleInfo[0]['is_send_star'] ? 0 : 1), /// 是否绑定
);
return true;
}
/**
* 修改用户密码
* @param RequestParameter $inParam
* @param ReturnParameter $outParam
* @return bool
*/
public function editSalesPassword($inParam, $outParam)
{
$request_data = isset($inParam->biz_content) ? $inParam->biz_content : '';
if (!is_array($request_data))
{
//参数格式错误
$outParam->SetErrors(ERRORCODE_INPARAMERROR, ERRORINFO_INPARAMERROR);
return false;
}
$agent_id = @$request_data['agentid']; // 代理id
$channel_id = @$request_data['channelid']; // 渠道id
$sales_id = @$request_data['salesid']; // 代理id
$old_pass = @$request_data['old_pass']; // 旧密码
$new_pass = @$request_data['new_pass']; // 新密码
$new_pass_re= @$request_data['new_pass_re']; // 确认新密码
if (empty($agent_id))
{
$outParam->SetErrors(ERRORCODE_AGENTIDERROR, ERRORINFO_AGENTIDERROR);
return false;
}
if (empty($channel_id))
{
$outParam->SetErrors(ERRORCODE_CHANNELIDERROR, ERRORINFO_CHANNELIDERROR);
return false;
}
if (empty($sales_id))
{
$outParam->SetErrors(ERRORCODE_SALESIDERROR, ERRORINFO_SALESNOTEXISTERROR);
return false;
}
if (empty($old_pass) || empty($new_pass))
{
$outParam->SetErrors('H00001', '旧密码或新密码不能为空');
return false;
}
if (empty($new_pass_re))
{
$outParam->SetErrors('H00001', '确认密码不能为空');
return false;
}
if ($new_pass_re !== $new_pass)
{
$outParam->SetErrors('H00005', '两次输入的新密码不一致');
return false;
}
// 1、查询当前用户密码并与传过来的旧密码对比
$sql = /** @lang text */'
select
idx, password
from
sales_user
where
saus_agentid = ? and saus_channelid = ? and saus_salesid = ?;';
$result = $this->PDO_Request($sql, $agent_id, $channel_id, $sales_id);
if (!$this->PDO_IsDone())
{
$outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo());
return false;
}
if($result[0]['password'] !== $old_pass){
$outParam->SetErrors('H00005', '旧密码错误');
return false;
}
// 2、旧密码匹配则进行新密码修改
// 新密码格式校验
if(strlen($new_pass)>10 || strlen($new_pass)<6){
$outParam->SetErrors('H00006', '请保证密码位数在6~10位之间');
return false;
}
// 入库
$this->PDO_Execute(/** @lang text */
'
update
sales_user
set
password = ?
where
idx = ? ; ', $new_pass, $result[0]['idx']
);
//c.异常处理
if (!$this->PDO_IsDone())
{
$outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo());
return false;
}
// 5、数据返回部分
return true;
}
/**
* 修改用户资料
* @param RequestParameter $inParam
* @param ReturnParameter $outParam
* @return bool
*/
public function editSalesInfo($inParam, $outParam)
{
$request_data = isset($inParam->biz_content) ? $inParam->biz_content : '';
if (!is_array($request_data))
{
//参数格式错误
$outParam->SetErrors(ERRORCODE_INPARAMERROR, ERRORINFO_INPARAMERROR);
return false;
}
$agent_id = @$request_data['agentid']; // 代理id
$channel_id = @$request_data['channelid']; // 渠道id
$sales_id = @$request_data['salesid']; // 代理id
$saus_realname = @$request_data['saus_realname']; // 真实姓名
$saus_wechat = @$request_data['saus_wechat']; // 微信号
$saus_alipay = @$request_data['saus_alipay']; // 支付宝账号
$saus_kaihu_name = @$request_data['saus_kaihu_name']; // 开户人姓名
$saus_kaihu_bank = @$request_data['saus_kaihu_bank']; // 开户银行
$saus_kaihu_zhihang= @$request_data['saus_kaihu_zhihang'];// 开户支行
$saus_kaihu_count = @$request_data['saus_kaihu_count']; // 银行卡号
if (empty($agent_id))
{
$outParam->SetErrors(ERRORCODE_AGENTIDERROR, ERRORINFO_AGENTIDERROR);
return false;
}
if (empty($channel_id))
{
$outParam->SetErrors(ERRORCODE_CHANNELIDERROR, ERRORINFO_CHANNELIDERROR);
return false;
}
if (empty($sales_id))
{
$outParam->SetErrors(ERRORCODE_SALESIDERROR, ERRORINFO_SALESNOTEXISTERROR);
return false;
}
if (empty($saus_realname) ||
empty($saus_wechat) ||
empty($saus_alipay) ||
empty($saus_kaihu_name) ||
empty($saus_kaihu_bank) ||
empty($saus_kaihu_zhihang) ||
empty($saus_kaihu_count)
)
{
$outParam->SetErrors(200, '所有信息为必填项');
return false;
}
// 校验银行卡号
$arr_no = str_split($saus_kaihu_count);
$last_n = $arr_no[count($arr_no)-1];
krsort($arr_no);
$i = 1;
$total = 0;
foreach ($arr_no as $n){
if($i%2==0){
$ix = $n*2;
if($ix>=10){
$nx = 1 + ($ix % 10);
$total += $nx;
}else{
$total += $ix;
}
}else{
$total += $n;
}
$i++;
}
$total -= $last_n;
$x = 10 - ($total % 10);
if($x != $last_n){
$outParam->SetErrors(200, '银行卡号错误');
return false;
}
// 1、查询当前用户信息
$sql = /** @lang text */'
select
idx
from
sales_user
where
saus_agentid = ? and saus_channelid = ? and saus_salesid = ?;';
$result = $this->PDO_Request($sql, $agent_id, $channel_id, $sales_id);
if (!$this->PDO_IsDone())
{
$outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo());
return false;
}
// 2、修改信息
// 入库
$this->PDO_Execute(/** @lang text */
'
update
sales_user
set
saus_realname = ?, saus_wechat = ?, saus_alipay = ?, saus_kaihu_name = ?, saus_kaihu_bank = ?, saus_kaihu_zhihang = ?, saus_kaihu_count = ?
where
idx = ? ; ', $saus_realname, $saus_wechat, $saus_alipay, $saus_kaihu_name, $saus_kaihu_bank, $saus_kaihu_zhihang, $saus_kaihu_count, $result[0]['idx']
);
//c.异常处理
if (!$this->PDO_IsDone())
{
$outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo());
return false;
}
// 5、数据返回部分
return true;
}
/**
* 查看用户是否完善银行卡资料
* @param RequestParameter $inParam
* @param ReturnParameter $outParam
* @return bool
*/
public function checkSalesCard($inParam, $outParam)
{
$request_data = isset($inParam->biz_content) ? $inParam->biz_content : '';
if (!is_array($request_data))
{
//参数格式错误
$outParam->SetErrors(ERRORCODE_INPARAMERROR, ERRORINFO_INPARAMERROR);
return false;
}
$agent_id = @$request_data['agentid']; // 代理id
$channel_id = @$request_data['channelid']; // 渠道id
$sales_id = @$request_data['salesid']; // 代理id
if (empty($agent_id))
{
$outParam->SetErrors(ERRORCODE_AGENTIDERROR, ERRORINFO_AGENTIDERROR);
return false;
}
if (empty($channel_id))
{
$outParam->SetErrors(ERRORCODE_CHANNELIDERROR, ERRORINFO_CHANNELIDERROR);
return false;
}
if (empty($sales_id))
{
$outParam->SetErrors(ERRORCODE_SALESIDERROR, ERRORINFO_SALESNOTEXISTERROR);
return false;
}
// 1、查询当前用户信息
$sql = /** @lang text */'
select
saus_kaihu_count
from
sales_user
where
saus_agentid = ? and saus_channelid = ? and saus_salesid = ?;';
$result = $this->PDO_Request($sql, $agent_id, $channel_id, $sales_id);
//c.异常处理
if (!$this->PDO_IsDone())
{
$outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo());
return false;
}
if(is_null($result[0]['saus_kaihu_count']) || !$result[0]['saus_kaihu_count'] || empty($result[0]['saus_kaihu_count']) ){
$data = 0;
}else{
$data = 1;
}
// 5、数据返回部分
$outParam->biz_content = array(
'have_cardinfo' => $data,
);
return true;
}
/**
* 报表后台登录
* @param RequestParameter $inParam
* @param ReturnParameter $outParam
* @return bool
*/
public function report_login($inParam, $outParam)
{
$request_data = isset($inParam->biz_content) ? $inParam->biz_content : '';
if (!is_array($request_data))
{
//参数格式错误
$outParam->SetErrors(ERRORCODE_INPARAMERROR, ERRORINFO_INPARAMERROR);
return false;
}
// 新增注册功能开始
$action = empty($request_data['action']) ? false : $request_data['action']; // 动作
if($action === 'regist'){
$login_id = empty($request_data['login_id']) ? false : $request_data['login_id']; // 登录账号
$password = empty($request_data['password']) ? false : $request_data['password']; // 登录密码
$nick_name = empty($request_data['nick_name']) ? false : $request_data['nick_name']; // 管理昵称
if (!$login_id || !$password || !$nick_name) {
$outParam->SetErrors(000001, '账号或密码不能为空');
return false;
}
// var_dump('regist');
// var_dump($login_id);
// var_dump($password);
// var_dump(md5($password.'6pREn2'));die;
// 用户查重
$adminInfo = $this->PDO_Request(/** @lang text */'
SELECT
id, user_id, password, salt, login_id, nick_name, sex, avatar, level, phone, is_enabled
FROM
ct_manager_info
WHERE
login_id = ?;', $login_id);
if (!$this->PDO_IsDone())
throw new Exception($this->GetErrorInfo(), $this->GetErrorCode());
elseif ($adminInfo)
throw new Exception(ERRORINFO_INVALID_LOGIN_INFORMATION, ERRORCODE_INVALID_LOGIN_INFORMATION);
// 用户入库
// 生成salt
$fix_num_array = array('0','1','2','3','4','5','6','7','8','9');
$fix_upper_case_array = array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z');
$fix_lower_case_array = array('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z');
$array = array();
$array = array_merge($array, $fix_num_array);
$array = array_merge($array, $fix_upper_case_array);
$array = array_merge($array, $fix_lower_case_array);
$salt = '';
$max = count($array);
for ($i=0; $i < 6 ; $i++) {
$key = rand(1, $max-1);
$salt .= $array[$key];
}
$password = md5($password.$salt);
$this->PDO_Execute(
'
INSERT INTO
ct_manager_info (login_id, password, salt, nick_name, level)
VALUES (?, ?, ?, ?, ?)', $login_id, $password, $salt, $nick_name, 1);
if (!$this->PDO_IsDone())
{
$outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo());
return false;
}
return true;
// 新增注册功能结束
}
// 登录
$login_id = empty($request_data['login_id']) ? false : $request_data['login_id']; // 登录账号
$password = empty($request_data['password']) ? false : $request_data['password']; // 登录密码
if (!$login_id || !$password) {
$outParam->SetErrors('H00001', '账号或密码不能为空');
return false;
}
$this->PDO_BeginTransaction();
try
{
$adminInfo = $this->PDO_Request(/** @lang text */'
SELECT
id, user_id, password, salt, login_id, nick_name, sex, avatar, level, phone, is_enabled
FROM
ct_manager_info
WHERE
login_id = ?;', $login_id);
if (!$this->PDO_IsDone())
throw new Exception($this->GetErrorInfo(), $this->GetErrorCode());
elseif (empty($adminInfo))
throw new Exception(ERRORINFO_INVALID_LOGIN_INFORMATION, ERRORCODE_INVALID_LOGIN_INFORMATION);
if ($adminInfo[0]['is_enabled'] != 1) {
$outParam->SetErrors(ERRORCODE_NOPERMISSION_USER, '当前账号已被禁用');
return false;
}
// var_dump('login');
// var_dump($login_id);
// var_dump($password);
// var_dump(md5($password.$adminInfo[0]['salt']));die;
// 密码校验
if($adminInfo[0]['password'] !== md5($password.$adminInfo[0]['salt'])){
throw new Exception(ERRORINFO_INVALID_LOGIN_INFORMATION, ERRORCODE_INVALID_LOGIN_INFORMATION);
}
}
catch(Exception $e)
{
$this->PDO_Rollback();
$outParam->SetErrors($e->getCode(), $e->getMessage());
return false;
}
/// 返回用户信息
unset($adminInfo[0]['password']);
unset($adminInfo[0]['salt']);
unset($adminInfo[0]['is_enabled']);
$outParam->biz_content = $adminInfo[0];
return true;
}
/**
* 解绑代理的上级
* @param $inParam
* @param $outParam
* @return bool
*/
public function salesUnbind($inParam, $outParam)
{
$request_data = isset($inParam->biz_content) ? $inParam->biz_content : '';
if (!is_array($request_data))
{
//参数格式错误
$outParam->SetErrors(ERRORCODE_INPARAMERROR, ERRORINFO_INPARAMERROR);
return false;
}
$agent_id = @$request_data['agentid']; // 代理id
$channel_id = @$request_data['channelid']; // 渠道id
$sales_id = @$request_data['salesid']; // 代理id
if (empty($agent_id))
{
$outParam->SetErrors(ERRORCODE_AGENTIDERROR, ERRORINFO_AGENTIDERROR);
return false;
}
if (empty($channel_id))
{
$outParam->SetErrors(ERRORCODE_CHANNELIDERROR, ERRORINFO_CHANNELIDERROR);
return false;
}
if (empty($sales_id))
{
$outParam->SetErrors(ERRORCODE_SALESIDERROR, ERRORINFO_SALESNOTEXISTERROR);
return false;
}
// 验证代理是否存在,上级代理是谁
$sql = /** @lang */'select saus_parentid from sales_user where saus_agentid=? and saus_channelid=? and saus_salesid=? limit 1';
$res = $this->PDO_Request($sql, $agent_id, $channel_id, $sales_id);
if(!$res) {
$outParam->SetErrors(ERRORCODE_SALESNOTEXISTERROR, ERRORINFO_SALESNOTEXISTERROR);
return false;
}
if(empty($res[0]['saus_parentid'])) {
$outParam->SetErrors(400, '没有绑定上级账号');
return false;
}
// 上级账号
$parent_sales_id = $res[0]['saus_parentid'];
try {
// 解绑
$sql = /** @lang */'update sales_user set saus_parentid=null where saus_agentid=? and saus_channelid=? and saus_salesid=? limit 1';
$this->PDO_Execute($sql, $agent_id, $channel_id, $sales_id);
if (!$this->PDO_IsDone())
throw new Exception($this->GetErrorInfo(), $this->GetErrorCode());
//记录本地日志
$ret = $this->PDO_Execute(/** @lang */
'
insert into sales_operate_log
(agent_id, channel_id, sales_id, operate_type, operate_data, create_time)
values
(?, ?, ?, ?, ?, ?)',
$agent_id, $channel_id, $sales_id, 2, $parent_sales_id, date('Y-m-d H:i:s', time()));
if ( !$ret || !$this->PDO_IsDone())
throw new Exception($this->GetErrorInfo(), $this->GetErrorCode());
$this->pdo_commit();
return true;
}
catch (Exception $e)
{
$this->pdo_rollback();
$outParam->seterrors($e->getcode(), $e->getmessage());
return false;
}
}
}