/** * [改]编辑渠道下指定id的某个分成类型 * author summer */ public function editCommisionType($inParam,$outParam) { // 1、系统非空数据配置初始化agentID、channelID、salesID、typeID、system_commission_rate、user_commission_rate $config = array( # 代理商id 'agentID' => array( 'name' => 'agentid', 'errcode' => ERRORCODE_AGENTIDERROR, 'errinfo' => ERRORINFO_AGENTIDERROR, ), # 渠道商id 'channelID' => array( 'name' => 'channelid', 'errcode' => ERRORCODE_CHANNELIDERROR, 'errinfo' => ERRORINFO_CHANNELIDERROR, ), # 个人代理id 'salesID' => array( 'name' => 'salesid', 'errcode' => ERRORCODE_SALESIDERROR, 'errinfo' => ERRORINFO_SALESIDERROR, ), # 类型id 'typeID' => array( 'name' => 'type_id', 'errcode' => 'H00001', 'errinfo' => 'type_id不能为空', ), ); // 2、数据处理后的结果集 异常标志err:true false $param = $this->inParamHandel($inParam, $outParam, $config); if (!$param) { return false; } // 3、权限验证 $auth = $this->checkAgentAuth($inParam, $outParam, $param['agentID'], $param['channelID'], $param['salesID']); if (!$auth) { return false; } // 4、业务逻辑部分 #a.查看分类是否存在 $item = $this->PDO_Request( ' select * from ct_agent_commission where type_id = ?; ', $param['typeID'] ); if (!$item) { $outParam->SetErrors(ERRORCODE_COMMISSIONNOTEXISTERROR, ERRORINFO_COMMISSIONNOTEXISTERROR); return false; } #b.传了几个改几个,没有传用默认 $system_commission_rate = isset($param['_params']['system_commission_rate']) ? (abs(intval($param['_params']['system_commission_rate'])) / 100) : $item[0]['system_commission_rate']; $user_commission_rate = isset($param['_params']['user_commission_rate']) ? (abs(intval($param['_params']['user_commission_rate'])) / 100) : $item[0]['user_commission_rate']; $parent_user_commission_rate = isset($param['_params']['parent_user_commission_rate']) ? (abs(intval($param['_params']['parent_user_commission_rate'])) / 100) : $item[0]['user_commission_rate']; if ($system_commission_rate >= 1 || $user_commission_rate >= 1 || $parent_user_commission_rate >= 1) { $outParam->SetErrors(ERRORCODE_NUMMAXTEXISTERROR, ERRORINFO_NUMMAXTEXISTERROR); return false; } $this->PDO_Execute( ' update ct_agent_commission set system_commission_rate = ? , user_commission_rate = ? , parent_user_commission_rate = ? where type_id = ?; ', $system_commission_rate, $user_commission_rate, $parent_user_commission_rate, $param['typeID'] ); if (!$this->PDO_IsDone()) { $outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo()); return false; } #c.将最新的分成比例更新到app通知表 $oper_data = $this->PDO_Request( ' select type_id, type_name, floor(system_commission_rate*100) as system_commission_rate from ct_agent_commission where agent_id = ? and channel_id = ? and status = ?; ', $param['agentID'], $param['channelID'], 1 ); if (!$item) { $outParam->SetErrors(ERRORCODE_COMMISSIONNOTEXISTERROR, ERRORINFO_COMMISSIONNOTEXISTERROR); return false; } $oper_data = json_encode($oper_data); #d.通知入库 $this->PDO_Execute( ' INSERT INTO ct_user_process_log (to_agent, to_channel, oper_type, oper_data, remark, oper_time, is_process) VALUES (?, ?, ?, ?, ?, ?, ?)', $param['agentID'], $param['channelID'], 201, $oper_data, '平台分成比例更新', time(), 0 ); if (!$this->PDO_IsDone()) { $outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo()); return false; } $outParam->biz_content = array( 'system_commission_rate' => $system_commission_rate, 'user_commission_rate' => $user_commission_rate, 'typeid' => $param['typeID'], ); return true; } /** * [查]获取渠道下的所有分成类型 * author summer */ public function getCommisionType($inParam, $outParam) { // 1、系统非空数据配置初始化 $config = array( # 代理商id 'agentID' => array( 'name' => 'agentid', 'errcode' => ERRORCODE_AGENTIDERROR, 'errinfo' => ERRORINFO_AGENTIDERROR, ), # 渠道商id 'channelID' => array( 'name' => 'channelid', 'errcode' => ERRORCODE_CHANNELIDERROR, 'errinfo' => ERRORINFO_CHANNELIDERROR, ), # 个人代理id 'salesID' => array( 'name' => 'salesid', 'errcode' => ERRORCODE_SALESIDERROR, 'errinfo' => ERRORINFO_SALESIDERROR, ), ); // 2、数据处理后的结果集 异常标志err:true false $param = $this->inParamHandel($inParam, $outParam, $config); if (!$param) { return false; } // 3、权限验证 $auth = $this->checkAgentAuth($inParam, $outParam, $param['agentID'], $param['channelID'], $param['salesID']); if (!$auth) { return false; } // 4、业务逻辑部分 $items = $this->PDO_Request( " SELECT type_id, type_name, system_commission_rate, user_commission_rate, parent_user_commission_rate FROM ct_agent_commission c WHERE c.agent_id=? AND c.channel_id=? ", $param['agentID'], $param['channelID'] ); if (!is_array($items)) { $outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo()); return false; } // 5、数据返回部分 $outParam->biz_content = $items; return true; } ##------------ 代理分成操作[curd] 总代权限 ##------------[sales_user ct_agent_commission] ----------------> /** * [查]渠道下代理分成设置,总代才有查看的权限 * author summer */ public function getAgentsCommission($inParam, $outParam) { // 1、系统非空数据配置初始化 $config = array( # 代理商id 'agentID' => array( 'name' => 'agentid', 'errcode' => ERRORCODE_AGENTIDERROR, 'errinfo' => ERRORINFO_AGENTIDERROR, ), # 渠道商id 'channelID' => array( 'name' => 'channelid', 'errcode' => ERRORCODE_CHANNELIDERROR, 'errinfo' => ERRORINFO_CHANNELIDERROR, ), # 个人代理id 'salesID' => array( 'name' => 'salesid', 'errcode' => ERRORCODE_SALESIDERROR, 'errinfo' => ERRORINFO_SALESIDERROR, ), ); // 2、数据处理后的结果集 异常标志err:true false $param = $this->inParamHandel($inParam, $outParam, $config); if (!$param) { return false; } # 指定代理id $objsalesid = empty($param['_params']['objsalesid']) ? '' : $param['_params']['objsalesid']; $typeid = empty($param['_params']['typeid']) ? false : $param['_params']['typeid']; // 按类型查询 if ($typeid) { $where_type = ' AND type_id = ' . $typeid; } else { $where_type = ' AND type_id = 001'; // 默认查询普通金币房 } # 分页信息 $keyword = empty($param['_params']['keyword']) ? false : $param['_params']['keyword']; // 查询关键字 if ($keyword) { $where_keyword = ' AND CONCAT(sales_id, nick_name) like "%' . trim($keyword) . '%"'; } else { $where_keyword = ''; } $page_index = empty($param['_params']['page_index']) ? 1 : intval($param['_params']['page_index']); // 当前页 $page_size = empty($param['_params']['page_size']) ? 10 : intval($param['_params']['page_size']); // 单页容量 $start = ($page_index - 1) * $page_size; $strPage = ''; if (!empty($page_index)) { $strPage .= " LIMIT {$start},{$page_size} "; } // 3、权限验证 $auth = $this->checkAgentAuth($inParam, $outParam, $param['agentID'], $param['channelID'], $param['salesID']); if (!$auth) { return false; } // // 、业务逻辑部分 $items = $this->PDO_Request(/** @lang text */'SELECT id, agent_id, channel_id, type_id, type_name, sales_id, nick_name, avatar, is_custom, case ifnull(is_custom, 0) when 0 then default_user_rate else if(isnull(custom_user_rate) || custom_user_rate = \'\', 0, custom_user_rate) end commission_rate, case ifnull(is_custom, 0) when 0 then default_parent_user_rate else if(isnull(parent_commission_rate) || parent_commission_rate = \'\', 0, parent_commission_rate) end parent_commission_rate FROM ( SELECT a.saus_agentid agent_id, a.saus_channelid channel_id, b.type_id, b.type_name, a.saus_salesid sales_id, a.saus_avatar avatar, a.saus_nickname nick_name, floor(b.user_commission_rate*100) default_user_rate, floor(b.parent_user_commission_rate*100) default_parent_user_rate, floor(c.commission_rate*100) custom_user_rate, floor(c.parent_commission_rate*100) parent_commission_rate, c.is_custom, c.id FROM sales_user a left join ct_agent_commission b on a.saus_agentid = b.agent_id and a.saus_channelid = b.channel_id and b.`status` = 1 and a.`saus_salesman` = 1 and a.`saus_salesman` = 1 left join ct_agent_commission_user c on a.saus_agentid = c.agent_id and a.saus_channelid = c.channel_id and b.type_id = c.type_id and a.saus_salesid = c.user_id ) t WHERE agent_id = ? and channel_id = ?' . $where_type . $where_keyword . $strPage . ';', $param['agentID'], $param['channelID'] ); if (!is_array($items)) { $outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo()); return false; } $dbData = $this->PDO_Request( ' SELECT agent_id, channel_id, type_id, type_name, sales_id, nick_name, avatar, case ifnull(is_custom, 0) when 0 then default_user_rate else custom_user_rate end user_rate FROM ( SELECT a.saus_agentid agent_id, a.saus_channelid channel_id, b.type_id, b.type_name, a.saus_salesid sales_id, a.saus_avatar avatar, a.saus_nickname nick_name, floor(b.user_commission_rate*100) default_user_rate, floor(c.commission_rate*100) custom_user_rate, floor(c.parent_commission_rate*100) parent_commission_rate, c.is_custom FROM sales_user a left join ct_agent_commission b on a.saus_agentid = b.agent_id and a.saus_channelid = b.channel_id and b.`status` = 1 and a.`saus_salesman` = 1 and a.`saus_salesman` = 1 left join ct_agent_commission_user c on a.saus_agentid = c.agent_id and a.saus_channelid = c.channel_id and b.type_id = c.type_id and a.saus_salesid = c.user_id ) t WHERE agent_id = ? and channel_id = ?' . $where_type . $where_keyword . ' ; ', $param['agentID'], $param['channelID'] ); if (!is_array($dbData) || count($dbData) < 1) { $outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo()); return false; } $data_count = intval(count($dbData)); $page_count = $data_count / $page_size + 1; // 5、数据返回部分 $outParam->biz_content = array( 'data' => $items, 'page_index' => $page_index, 'page_size' => $page_size, 'page_count' => intval($page_count), 'data_count' => $data_count, ); return true; } /** * [改]代理分成设置 */ public function editAgentsCommission($inParam, $outParam) { // 1、系统非空数据配置初始化 $config = array( # 代理商id 'agentID' => array( 'name' => 'agentid', 'errcode' => ERRORCODE_AGENTIDERROR, 'errinfo' => ERRORINFO_AGENTIDERROR, ), # 渠道商id 'channelID' => array( 'name' => 'channelid', 'errcode' => ERRORCODE_CHANNELIDERROR, 'errinfo' => ERRORINFO_CHANNELIDERROR, ), # 个人代理id 'salesID' => array( 'name' => 'salesid', 'errcode' => ERRORCODE_SALESIDERROR, 'errinfo' => ERRORINFO_SALESIDERROR, ), # 分成类型id 'typeID' => array( 'name' => 'type_id', 'errcode' => 'H00001', 'errinfo' => 'type_id不能为空', ), # 操作对象id 'objID' => array( 'name' => 'obj_id', 'errcode' => 'H00001', 'errinfo' => 'obj_id不能为空', ) ); // 2、数据处理后的结果集 异常标志err:true false $param = $this->inParamHandel($inParam, $outParam, $config); if (!$param) { return false; } // 3、权限验证 $auth = $this->checkAgentAuth($inParam, $outParam, $param['agentID'], $param['channelID'], $param['salesID']); if (!$auth) { return false; } // 4、业务逻辑部分 #a.查看代理是否存在 $item = $this->PDO_Request( ' select * from sales_user where saus_salesid = ?; ', $param['salesID'] ); if (!$item) { $outParam->SetErrors(ERRORCODE_AGENTIDERROR, ERRORINFO_AGENTIDERROR); return false; } // 是否传了修改记录id 没有则表示表中无记录 #b.查看用户比例设置是否已经存在 $exist = $this->PDO_Request( ' SELECT commission_rate, parent_commission_rate FROM ct_agent_commission_user WHERE user_id = ? AND type_id = ?; ', $param['objID'], $param['typeID'] ); if ($exist) { // 存在则修改 #c.传了几个改几个,没有传用之前的 $commission_rate = isset($param['_params']['commission_rate']) ? (abs(intval($param['_params']['commission_rate'])) / 100) : $exist[0]['commission_rate']; $parent_commission_rate = isset($param['_params']['parent_commission_rate']) ? (abs(intval($param['_params']['parent_commission_rate'])) / 100) : $exist[0]['parent_commission_rate']; if ($commission_rate >= 1 || $parent_commission_rate >= 1) { $outParam->SetErrors(ERRORCODE_NUMMAXTEXISTERROR, ERRORINFO_NUMMAXTEXISTERROR); return false; } $this->PDO_Execute( ' update ct_agent_commission_user set commission_rate = ?, parent_commission_rate = ?, update_time = ? where user_id = ? AND type_id = ?; ', $commission_rate, $parent_commission_rate, date("Y-m-d H:i:s", time()), $param['objID'], $param['typeID'] ); } else { // 不存在则添加 #c.获取系统默认配置 $default = $this->PDO_Request( ' select user_commission_rate, parent_user_commission_rate from ct_agent_commission where type_id = ?; ', $param['typeID'] ); #c.传了几个改几个,没有传用默认 $commission_rate = isset($param['_params']['commission_rate']) ? (abs(intval($param['_params']['commission_rate'])) / 100) : $default[0]['user_commission_rate']; $parent_commission_rate = isset($param['_params']['parent_commission_rate']) ? (abs(intval($param['_params']['parent_commission_rate'])) / 100) : $default[0]['parent_user_commission_rate']; if ($commission_rate >= 1 || $parent_commission_rate >= 1) { $outParam->SetErrors(ERRORCODE_NUMMAXTEXISTERROR, ERRORINFO_NUMMAXTEXISTERROR); return false; } $this->PDO_Execute( ' INSERT INTO ct_agent_commission_user (user_id, agent_id, channel_id, type_id, commission_rate, parent_commission_rate, create_time, update_time, is_custom) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)', $param['objID'], $param['agentID'], $param['channelID'], $param['typeID'], $commission_rate, $parent_commission_rate, date("Y-m-d H:i:s", time()), date("Y-m-d H:i:s", time()), 1 ); } //c.异常处理 if (!$this->PDO_IsDone()) { $outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo()); return false; } // 5、数据返回部分 return true; } ##------------ 流水操作[curd] 代理权限 ##------------[表:ct_user_commission] ------------------------- // 移动端api /** * [查]流水明细查询 * author summer * @param RequestParameter $inParam * @param ReturnParameter $outParam * @return boolean */ public function getUserCommissionDetails($inParam, $outParam) { // 1、系统非空数据配置初始化 $config = array( # 代理商id 'agentID' => array( 'name' => 'agentid', 'errcode' => ERRORCODE_AGENTIDERROR, 'errinfo' => ERRORINFO_AGENTIDERROR, ), # 渠道商id 'channelID' => array( 'name' => 'channelid', 'errcode' => ERRORCODE_CHANNELIDERROR, 'errinfo' => ERRORINFO_CHANNELIDERROR, ), # 个人代理id 'salesID' => array( 'name' => 'salesid', 'errcode' => ERRORCODE_SALESIDERROR, 'errinfo' => ERRORINFO_SALESIDERROR, ), ); // 2、数据处理后的结果集 异常标志err:true false $param = $this->inParamHandel($inParam, $outParam, $config); if (!$param) return false; //3.1 可选参数获取 $type = empty($param['_params']['type']) ? '1' : $param['_params']['type']; // 查询类型(1、代理 2、玩家) $objuserid = empty($param['_params']['objuserid']) ? false : $param['_params']['objuserid']; // 指定查询代理/玩家id $beginTime = empty($param['_params']['begintime']) ? false : $param['_params']['begintime']; // 查询开始时间 $endTime = empty($param['_params']['endtime']) ? false : $param['_params']['endtime']; // 查询结束时间 $keyword = empty($param['_params']['keyword']) ? false : trim($param['_params']['keyword']); // 查询关键字 $scope = empty($param['_params']['scope']) ? 1 : trim($param['_params']['scope']); // 查询范围 # 分页信息 $page_index = empty($param['_params']['page_index']) ? 1 : intval($param['_params']['page_index']); // 当前页 $page_size = empty($param['_params']['page_size']) ? 100 : intval($param['_params']['page_size']); // 单页容量 $start = ($page_index - 1) * $page_size; $strPage = ''; if (!empty($page_index)) $strPage .= " limit {$start},{$page_size} "; // 4、业务逻辑部分 if ('1' == $type) { // 代理数据 $cmd = /** @lang text */<< 0 EOL; $pagecmd = /** @lang text */<< 0 EOL; if (!empty($keyword)) { $cmd .= " and a.user_id like '%{$keyword}%'"; $pagecmd .= " and a.user_id like '%{$keyword}%'"; } // 查询对象 $cmd .= " and b.saus_parentid =".$param['salesID']; $pagecmd .= " and b.saus_parentid =".$param['salesID']; if($objuserid){ // 验证对象是否是下级代理 $dbSalesInfo = $this->PDO_Request(/** @lang text */'select idx, global_power from sales_user where saus_agentid=? and saus_channelid=? and saus_salesid=? and saus_parentid=?', $param['agentID'], $param['channelID'], $objuserid, $param['salesID']); if (!$dbSalesInfo) { $outParam->SetErrors(ERRORCODE_NOPOWERERROR, ERRORINFO_NOPOWERERROR); return false; } $cmd .= " and b.saus_salesid =".$objuserid; $pagecmd .= " and b.saus_salesid =".$objuserid; } } else { // 玩家数据 $cmd = /** @lang text */<< 0 EOL; $pagecmd = /** @lang text */<< 0 EOL; // 查询对象 $cmd .= " and b.play_invitecode =".$param['salesID']; $pagecmd .= " and b.play_invitecode =".$param['salesID']; if($objuserid){ // 验证对象是否是下级玩家 $dbSalesInfo = $this->PDO_Request(/** @lang text */'select idx from player where play_agentid=? and play_channelid=? and play_playerid=? and play_invitecode=?', $param['agentID'], $param['channelID'], $objuserid, $param['salesID']); if (!$dbSalesInfo) { $outParam->SetErrors(ERRORCODE_NOPOWERERROR, ERRORINFO_NOPOWERERROR); return false; } $cmd .= " and b.play_playerid =".$objuserid; $pagecmd .= " and b.play_playerid =".$objuserid; } if (!empty($keyword)) { $cmd .= " and a.player_id like '%{$keyword}%'"; $pagecmd .= " and a.player_id like '%{$keyword}%'"; } } // 搜索范围 switch ($scope) { // 金币场 case '2': $cmd .= " and a.commission_total <100"; $pagecmd .= " and a.commission_total <100"; break; // 茶水费 case '3': $cmd .= " and a.commission_total >=100"; $pagecmd .= " and a.commission_total >=100"; break; default: # code... break; } if ($beginTime) { $cmd .= " and a.create_time >= '{$beginTime} 00:00:00'"; $pagecmd .= " and a.create_time >= '{$beginTime} 00:00:00'"; } if ($endTime) { $cmd .= " and a.create_time <= '{$endTime} 23:59:59'"; $pagecmd .= " and a.create_time <= '{$endTime} 23:59:59'"; } $cmd .= PHP_EOL . $strPage; // var_dump($cmd);die; $items = $this->PDO_Request($cmd, $param['agentID']); if (!$this->pdo_isdone()) { $outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo()); return false; } $dbData = $this->PDO_Request($pagecmd, $param['agentID']); if (!$this->pdo_isdone()) { $outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo()); return false; } $data_count = intval($dbData[0]['num']); $page_count = $data_count / $page_size + 1; // 总页数 // 5、数据返回部分 $outParam->biz_content = array( 'data' => $items, 'page_index' => $page_index, 'page_size' => $page_size, 'page_count' => intval($page_count), 'data_count' => $data_count, 'under_check_fee' => 360, // 待审核金额 'freeze_fee' => 60, // 冻结金额 ); return true; } /** * 下级玩家流水合计 * @param $inParam * @param $outParam * @return bool */ public function getUserLowerPlayerCommission($inParam, $outParam) { $param = $inParam->biz_content; $agentid = isset($param['agentid']) ? $param['agentid'] : ''; $channelid = isset($param['channelid']) ? $param['channelid'] : ''; $salesid = isset($param['salesid']) ? $param['salesid'] : ''; $start_time = isset($param['start_time']) ? $param['start_time'] : ''; $end_time = isset($param['end_time']) ? $param['end_time'] : ''; if (empty($agentid)) { $outParam->SetErrors(ERRORCODE_AGENTIDERROR, ERRORINFO_AGENTIDERROR); return false; } if (empty($channelid)) { $outParam->SetErrors(ERRORCODE_CHANNELIDERROR, ERRORINFO_CHANNELIDERROR); return false; } if (empty($salesid)) { $outParam->SetErrors(ERRORCODE_SALESIDERROR, ERRORINFO_SALESIDERROR); return false; } $sql_time = ''; if(!empty($start_time) && !empty($end_time)) { $sql_time = "AND create_time between '{$start_time} 00:00:00' and '{$end_time} 23:59:59'"; } $commission_table_name = 'ct_user_commission'; //if(!empty($time)) //$commission_table_name .= '_'.$time; //$salesid=200175; /*$sql = << 0 GROUP BY agent_id, channel_id, player_id ) c LEFT JOIN player u ON c.agent_id = u.play_agentid AND c.channel_id = u.play_channelid AND c.player_id = u.play_playerid ORDER BY c.player_id; EOL;*/ $sql = << 0 AND target_mode = 0 {$sql_time} GROUP BY agent_id, channel_id, player_id ) c ON c.agent_id = u.play_agentid AND c.channel_id = u.play_channelid AND c.player_id = u.play_playerid WHERE u.play_invitecode = {$salesid} AND u.play_agentid = '{$agentid}' AND u.play_channelid = '{$channelid}' ORDER BY sum_commission_user desc; EOL; $ret = $this->PDO_Request($sql); if (!$this->PDO_IsDone()) { $outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo()); return false; } $outParam->biz_content = $ret; return true; } /** * 下级代理流水 * @param $inParam * @param $outParam * @return bool */ public function getUserLowerSalesCommission($inParam, $outParam) { $param = $inParam->biz_content; $agentid = isset($param['agentid']) ? $param['agentid'] : ''; $channelid = isset($param['channelid']) ? $param['channelid'] : ''; $salesid = isset($param['salesid']) ? $param['salesid'] : ''; $start_time = isset($param['start_time']) ? $param['start_time'] : ''; $end_time = isset($param['end_time']) ? $param['end_time'] : ''; if (empty($agentid)) { $outParam->SetErrors(ERRORCODE_AGENTIDERROR, ERRORINFO_AGENTIDERROR); return false; } if (empty($channelid)) { $outParam->SetErrors(ERRORCODE_CHANNELIDERROR, ERRORINFO_CHANNELIDERROR); return false; } if (empty($salesid)) { $outParam->SetErrors(ERRORCODE_SALESIDERROR, ERRORINFO_SALESIDERROR); return false; } $sql_time = ''; if(!empty($start_time) && !empty($end_time)) { $sql_time = "AND create_time between '{$start_time} 00:00:00' and '{$end_time} 23:59:59'"; } //$salesid=200067; $commission_table_name = 'ct_user_commission'; //if(!empty($time)) //$commission_table_name .= '_'.$time; $sql = << 0 AND target_mode = 0 {$sql_time} GROUP BY agent_id, channel_id, user_id ) c ON s.saus_agentid = c.agent_id AND s.saus_channelid = c.channel_id AND s.saus_salesid = c.user_id WHERE s.saus_parentid = {$salesid} AND s.saus_agentid = '{$agentid}' AND s.saus_channelid = '{$channelid}' ORDER BY sum_commission_parent_user desc EOL; $ret = $this->PDO_Request($sql); if (!$this->PDO_IsDone()) { $outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo()); return false; } $outParam->biz_content = $ret; return true; } /** * [查]获取当前代理统计数据 * author summer */ public function getUserCommissionCount($inParam, $outParam) { // 1、系统非空数据配置初始化 $config = array( # 代理商id 'agentID' => array( 'name' => 'agentid', 'errcode' => ERRORCODE_AGENTIDERROR, 'errinfo' => ERRORINFO_AGENTIDERROR, ), # 渠道商id 'channelID' => array( 'name' => 'channelid', 'errcode' => ERRORCODE_CHANNELIDERROR, 'errinfo' => ERRORINFO_CHANNELIDERROR, ), # 个人代理id 'salesID' => array( 'name' => 'salesid', 'errcode' => ERRORCODE_SALESIDERROR, 'errinfo' => ERRORINFO_SALESIDERROR, ), ); // 2、数据处理后的结果集 异常标志err:true false $param = $this->inParamHandel($inParam, $outParam, $config); if (!$param) { return false; } // 待审核金额 $under_check_fee = $this->PDO_Request( ' SELECT ifnull(sum(request_currency),0) under_check_fee FROM ct_withdraw_record WHERE agent_id = ? AND channel_id = ? AND sales_id = ? AND status = ?;', $param['agentID'], $param['channelID'], $param['salesID'], 0 ); if (!is_array($under_check_fee) || count($under_check_fee) < 1) { $outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo()); return false; } // 可提现金币/已冻结金额 $fee = $this->PDO_Request( ' SELECT currency_withdraw, currency_total, currency_freeze FROM sales_user WHERE saus_agentid = ? AND saus_channelid = ? AND saus_salesid = ?;', $param['agentID'], $param['channelID'], $param['salesID'] ); if (!is_array($fee) || count($fee) < 1) { $outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo()); return false; } // 获取提现倍数设置 $config = $this->PDO_Request( ' SELECT withdraw_init FROM ct_channel_list WHERE agent_id = ? AND channel_id = ?;', $param['agentID'], $param['channelID'] ); if (!$this->PDO_IsDone()) { $outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo()); return false; } // 5、数据返回部分 $outParam->biz_content = array( 'total_fee' => $fee[0]['currency_total'], // 总计分成游戏币 'effect_fee' => $fee[0]['currency_withdraw'] - $under_check_fee[0]['under_check_fee'], // 可提现金币 'under_check_fee' => $under_check_fee[0]['under_check_fee'], // 待审核金额 'freeze_fee' => $fee[0]['currency_freeze'], // 冻结金额 'withdraw_init' => $config[0]['withdraw_init'], // 游戏币提现倍数 ); return true; } // pc端api 1、总代权限 2、统计同渠道所有数据 /** * [查]流水明细查询 * author summer * @param RequestParameter $inParam * @param ReturnParameter $outParam * @return boolean */ public function getUserCommissionDetails4pc($inParam, $outParam) { // 1、系统非空数据配置初始化 sdfsdf sa $config = array( # 代理商id 'agentID' => array( 'name' => 'agentid', 'errcode' => ERRORCODE_AGENTIDERROR, 'errinfo' => ERRORINFO_AGENTIDERROR, ), # 渠道商id 'channelID' => array( 'name' => 'channelid', 'errcode' => ERRORCODE_CHANNELIDERROR, 'errinfo' => ERRORINFO_CHANNELIDERROR, ), # 个人代理id 'salesID' => array( 'name' => 'salesid', 'errcode' => ERRORCODE_SALESIDERROR, 'errinfo' => ERRORINFO_SALESIDERROR, ), ); // 2、数据处理后的结果集 异常标志err:true false $param = $this->inParamHandel($inParam, $outParam, $config); if (!$param) return false; // 3、权限验证 $auth = $this->checkAgentAuth($inParam, $outParam, $param['agentID'], $param['channelID'], $param['salesID']); if (!$auth) return false; //3.1 可选参数获取 $type = empty($param['_params']['type']) ? '1' : $param['_params']['type']; // 查询类型(1、代理 2、玩家) $objuserid = empty($param['_params']['objuserid']) ? false : $param['_params']['objuserid']; // 指定查询代理/玩家id $beginTime = empty($param['_params']['begintime']) ? false : $param['_params']['begintime']; // 查询开始时间 $endTime = empty($param['_params']['endtime']) ? false : $param['_params']['endtime']; // 查询结束时间 $keyword = empty($param['_params']['keyword']) ? false : trim($param['_params']['keyword']);// 查询关键字 $scope = empty($param['_params']['scope']) ? 1 : trim($param['_params']['scope']); // 查询范围 if(!$beginTime){ $outParam->SetErrors(ERRORCODE_BEGINTIMEERROR, ERRORINFO_BEGINTIMEERROR); return false; } if(!$endTime){ $outParam->SetErrors(ERRORCODE_ENDTIMEERROR, ERRORINFO_ENDTIMEERROR); return false; } $mouthTime = strtotime($beginTime); //int 1466028000 将英文文本日期时间解析为 Unix 时间戳: $mouth= date("Ym ",$mouthTime); // $table = 'ct_user_commission_'.$mouth; // 查询的表 分表查询 $table = 'ct_commision_user_detail'; // 查询的表 总表查询 # 分页信息 $page_index = empty($param['_params']['page_index']) ? 1 : intval($param['_params']['page_index']); // 当前页 $page_size = empty($param['_params']['page_size']) ? 100 : intval($param['_params']['page_size']); // 单页容量 $start = ($page_index - 1) * $page_size; $strPage = ''; if (!empty($page_index)) $strPage .= " limit {$start},{$page_size} "; // 4、业务逻辑部分 if($scope == 3){ // 茶水费 $cmd = /** @lang text */<< 0 EOL; }else{ $cmd = /** @lang text */<< 0 EOL; } // 关键字查询 if (!empty($keyword)) $cmd .= " and player_id = {$keyword}"; // 搜索范围 switch ($scope) { // 系统分成 case '2': $cmd .= " and target_mode = 0"; break; default: # code... break; } if ($beginTime) { $cmd .= " and time >= '{$beginTime} 00:00:00'"; } if ($endTime) { $cmd .= " and time <= '{$endTime} 23:59:59'"; } // 分页 $page_cmd = /** @lang text */"select count(0) num from ({$cmd}) d"; $cmd .= $strPage; $items = $this->PDO_Request($cmd, $param['agentID']); if (!$this->pdo_isdone()) { $outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo()); return false; } $dbData = $this->PDO_Request($page_cmd, $param['agentID']); // var_dump($dbData);die; $data_count = isset($dbData[0]['num']) ? intval($dbData[0]['num']) : 0; $page_count = $data_count / $page_size + 1; // 总页数 // 5、数据返回部分 $outParam->biz_content = array( 'data' => $items, 'page_index' => $page_index, 'page_size' => $page_size, 'page_count' => intval($page_count), 'data_count' => $data_count, 'under_check_fee' => 360, // 待审核金额 'freeze_fee' => 60, // 冻结金额 ); return true; } // pc端api 1、总代权限 2、统计同渠道所有数据 /** * [查]流水明细查询 * author summer * @param RequestParameter $inParam * @param ReturnParameter $outParam * @return boolean */ public function getUserCommissionDetails4pcTongji($inParam, $outParam) { // 1、系统非空数据配置初始化 sdfsdf sa $config = array( # 代理商id 'agentID' => array( 'name' => 'agentid', 'errcode' => ERRORCODE_AGENTIDERROR, 'errinfo' => ERRORINFO_AGENTIDERROR, ), # 渠道商id 'channelID' => array( 'name' => 'channelid', 'errcode' => ERRORCODE_CHANNELIDERROR, 'errinfo' => ERRORINFO_CHANNELIDERROR, ), # 个人代理id 'salesID' => array( 'name' => 'salesid', 'errcode' => ERRORCODE_SALESIDERROR, 'errinfo' => ERRORINFO_SALESIDERROR, ), ); // 2、数据处理后的结果集 异常标志err:true false $param = $this->inParamHandel($inParam, $outParam, $config); if (!$param) return false; // 3、权限验证 $auth = $this->checkAgentAuth($inParam, $outParam, $param['agentID'], $param['channelID'], $param['salesID']); if (!$auth) return false; //3.1 可选参数获取 $type = empty($param['_params']['type']) ? '1' : $param['_params']['type']; // 查询类型(1、代理 2、玩家) $objuserid = empty($param['_params']['objuserid']) ? false : $param['_params']['objuserid']; // 指定查询代理/玩家id $beginTime = empty($param['_params']['begintime']) ? false : $param['_params']['begintime']; // 查询开始时间 $endTime = empty($param['_params']['endtime']) ? false : $param['_params']['endtime']; // 查询结束时间 $keyword = empty($param['_params']['keyword']) ? false : trim($param['_params']['keyword']);// 查询关键字 $scope = empty($param['_params']['scope']) ? 1 : trim($param['_params']['scope']); // 查询范围 if(!$beginTime){ $outParam->SetErrors(ERRORCODE_BEGINTIMEERROR, ERRORINFO_BEGINTIMEERROR); return false; } if(!$endTime){ $outParam->SetErrors(ERRORCODE_ENDTIMEERROR, ERRORINFO_ENDTIMEERROR); return false; } $mouthTime = strtotime($beginTime); //int 1466028000 将英文文本日期时间解析为 Unix 时间戳: $mouth= date("Ym ",$mouthTime); // $table = 'ct_user_commission_'.$mouth; // 查询的表 分表查询 $table = 'ct_commision_user_detail'; // 查询的表 总表查询 # 分页信息 $page_index = empty($param['_params']['page_index']) ? 1 : intval($param['_params']['page_index']); // 当前页 $page_size = empty($param['_params']['page_size']) ? 100 : intval($param['_params']['page_size']); // 单页容量 $start = ($page_index - 1) * $page_size; $strPage = ''; if (!empty($page_index)) $strPage .= " limit {$start},{$page_size} "; // 4、业务逻辑部分 if($scope == 3){ // 茶水费 $cmd = /** @lang text */<< 0 EOL; }else{ $cmd = /** @lang text */<< 0 EOL; } // 关键字查询 if (!empty($keyword)) $cmd .= " and player_id = {$keyword}"; // 搜索范围 switch ($scope) { // 系统分成 case '2': $cmd .= " and target_mode = 0"; break; default: # code... break; } if ($beginTime) $cmd .= " and time >= '{$beginTime} 00:00:00'"; if ($endTime) $cmd .= " and time <= '{$endTime} 23:59:59'"; // 统计功能 $cmd .= <<PDO_Request($cmd, $param['agentID']); if (!$this->pdo_isdone()) { $outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo()); return false; } $dbData = $this->PDO_Request($page_cmd, $param['agentID']); if (!$this->pdo_isdone()) { $outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo()); return false; } $data_count = isset($dbData[0]['num']) ? intval($dbData[0]['num']) : 0; $page_count = $data_count / $page_size + 1; // 总页数 // 5、数据返回部分 $outParam->biz_content = array( 'data' => $items, 'page_index' => $page_index, 'page_size' => $page_size, 'page_count' => intval($page_count), 'data_count' => $data_count, 'under_check_fee' => 360, // 待审核金额 'freeze_fee' => 60, // 冻结金额 ); return true; } ##------------ 订单操作[curd] ##------------[表:ct_withdraw_record] -------------------------> /** * [增]创建订单 代理都有权限 * author summer */ public function addWithdrawRecord($inParam, $outParam) { // 1、系统非空数据配置初始化 $config = array( # 代理商id 'agentID' => array( 'name' => 'agentid', 'errcode' => ERRORCODE_AGENTIDERROR, 'errinfo' => ERRORINFO_AGENTIDERROR, ), # 渠道商id 'channelID' => array( 'name' => 'channelid', 'errcode' => ERRORCODE_CHANNELIDERROR, 'errinfo' => ERRORINFO_CHANNELIDERROR, ), # 个人代理id 'salesID' => array( 'name' => 'salesid', 'errcode' => ERRORCODE_SALESIDERROR, 'errinfo' => ERRORINFO_SALESIDERROR, ), # 申请提现游戏币数量 'requestCurrency' => array( 'name' => 'request_currency', 'errcode' => ERRORCODE_INPARAMERROR, 'errinfo' => ERRORINFO_INPARAMERROR, ), ); // 2、数据处理后的结果集 异常标志err:true false $param = $this->inParamHandel($inParam, $outParam, $config); if (!$param) { return false; } // 获取提现倍数设置 $config = $this->PDO_Request( ' SELECT withdraw_init FROM ct_channel_list WHERE agent_id = ? AND channel_id = ?;', $param['agentID'], $param['channelID'] ); if (!$this->PDO_IsDone()) { $outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo()); return false; } // 判断金额 # 1.提现倍数判断 if ($param['requestCurrency'] < $config[0]['withdraw_init'] || $param['requestCurrency'] % $config[0]['withdraw_init'] != 0) { $outParam->SetErrors('H00004', '提现金额需要大于且为'.$config[0]['withdraw_init'].'的整数倍'); return false; } # 2.金额判断 需要加上未通过的审核金额(因为还没从用户可提现金额中扣除) $fee = $this->PDO_Request( ' SELECT currency_withdraw, currency_total, currency_freeze FROM sales_user WHERE saus_agentid = ? AND saus_channelid = ? AND saus_salesid = ?;', $param['agentID'], $param['channelID'], $param['salesID'] ); if (!is_array($fee) || count($fee) < 1) { $outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo()); return false; } $myMoney = $fee[0]['currency_withdraw']; // 可提现金额 // 在审核中的金额(还未扣除) $underCheck = $this->PDO_Request( ' SELECT sum(request_currency) AS sum FROM ct_withdraw_record WHERE agent_id = ? AND channel_id = ? AND sales_id = ? AND status = ?;', $param['agentID'], $param['channelID'], $param['salesID'], 0 ); if($underCheck){ $myMoney += $underCheck[0]['sum']; } if ($myMoney < $param['requestCurrency']) { $outParam->SetErrors('H00003', '账户金额不足'); return false; } // 订单入库 $tmp = range(0, 9); $data = array_rand($tmp, 5); $rangenum = implode('', $data); $order_number = date('YmdHis', time()); $order_number .= $rangenum; $res = $this->PDO_Execute( ' INSERT INTO ct_withdraw_record(order_number, agent_id, channel_id, sales_id, request_currency, request_time, status) VALUES (?, ?, ?, ?, ?, ?, ?)', $order_number, $param['agentID'], $param['channelID'], $param['salesID'], $param['requestCurrency'], date('Y-m-d H:i:s', time()), 0 ); if (!$res) { $outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo()); return false; } // 5、数据返回部分 $outParam->biz_content = array( 'code' => 1, 'msg' => '提交成功', ); return true; } /** * [改]修改订单 更新订单状态 总理都有权限 * author summer */ public function editWithdrawRecord($inParam, $outParam) { $config = array( # 代理商id 'agentID' => array( 'name' => 'agentid', 'errcode' => ERRORCODE_AGENTIDERROR, 'errinfo' => ERRORINFO_AGENTIDERROR, ), # 渠道商id 'channelID' => array( 'name' => 'channelid', 'errcode' => ERRORCODE_CHANNELIDERROR, 'errinfo' => ERRORINFO_CHANNELIDERROR, ), # 个人代理id 'salesID' => array( 'name' => 'salesid', 'errcode' => ERRORCODE_SALESIDERROR, 'errinfo' => ERRORINFO_SALESIDERROR, ), # 操作记录id 'id' => array( 'name' => 'id', 'errcode' => 'H00001', 'errinfo' => 'id不能为空', ), # 类型(0: 待审核;1: 审核通过; 2: 驳回; -1: 撤销) 'type' => array( 'name' => 'type', 'errcode' => 'H00001', 'errinfo' => 'type不能为空', ), ); // 2、数据处理后的结果集 异常标志err:true false $param = $this->inParamHandel($inParam, $outParam, $config); if (!$param) { return false; } if (!in_array($param['type'], [-1, 0, 1, 2])) { $outParam->SetErrors('H00001', 'type只能是[-1, 0, 1, 2]'); return false; } // 3、权限验证 审核需要总代权限 撤销都可以 只有待审核才能撤销(-1) if (in_array($param['type'], [0, 1, 2])) { // 验证总代权限 $auth = $this->checkAgentAuth($inParam, $outParam, $param['agentID'], $param['channelID'], $param['salesID']); if (!$auth) { return false; } } // 4、业务逻辑部分 #a.查看订单是否存在 $item = $this->PDO_Request( ' select * from ct_withdraw_record where id = ?; ', $param['id'] ); if (!$item) { $outParam->SetErrors(ERRORCODE_COMMISSIONNOTEXISTERROR, ERRORINFO_COMMISSIONNOTEXISTERROR); return false; } // 如果是撤销操作且当前状态不为待审核(0) 只有待审核才能撤销(-1) 则返回 if ($param['type'] == -1 && $item[0]['status'] != '0') { $outParam->SetErrors('H00002', '该订单不能撤销'); return false; } // 已撤回/审核的订单不能继续操作 if ($item[0]['status'] == '-1' || $item[0]['status'] == '1' || $item[0]['status'] == '2') { $outParam->SetErrors('H00002', '该订单已锁定'); return false; } // 如果是审核通过从用户金额中扣除 if ($param['type'] == 1) { // 拿到现有金额 $fee = $this->PDO_Request( ' SELECT idx, currency_withdraw, currency_total, currency_freeze FROM sales_user WHERE saus_agentid = ? AND saus_channelid = ? AND saus_salesid = ?;', $param['agentID'], $param['channelID'], $item[0]['sales_id'] ); if (!is_array($fee) || count($fee) < 1) { $outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo()); return false; } // 直接从用户可提现金额中扣除 $currency_withdraw = $fee[0]['currency_withdraw'] - $item[0]['request_currency']; $this->PDO_Execute( ' update sales_user set currency_withdraw = ? where idx = ?; ', $currency_withdraw, $fee[0]['idx'] ); if (!$this->PDO_IsDone()) { $outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo()); return false; } } // 更新订单状态 $this->PDO_Execute( ' update ct_withdraw_record set status = ? , audit_time = ? where id = ?; ', $param['type'], date('Y-m-d H:i:s', time()), $param['id'] ); if (!$this->PDO_IsDone()) { $outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo()); return false; } return true; } /** * [查]查询订单 代理都有权限 * author summer */ public function getWithdrawRecord($inParam, $outParam) { // 1、系统非空数据配置初始化 $config = array( # 代理商id 'agentID' => array( 'name' => 'agentid', 'errcode' => ERRORCODE_AGENTIDERROR, 'errinfo' => ERRORINFO_AGENTIDERROR, ), # 渠道商id 'channelID' => array( 'name' => 'channelid', 'errcode' => ERRORCODE_CHANNELIDERROR, 'errinfo' => ERRORINFO_CHANNELIDERROR, ), # 个人代理id 'salesID' => array( 'name' => 'salesid', 'errcode' => ERRORCODE_SALESIDERROR, 'errinfo' => ERRORINFO_SALESIDERROR, ), ); // 2、数据处理后的结果集 异常标志err:true false $param = $this->inParamHandel($inParam, $outParam, $config); if (!$param) { return false; } //3.1 可选参数获取 $beginTime = empty($param['_params']['begintime']) ? false : $param['_params']['begintime']; // 查询开始时间 $endTime = empty($param['_params']['endtime']) ? false : $param['_params']['endtime']; // 查询结束时间 $keyword = empty($param['_params']['keyword']) ? false : $param['_params']['keyword']; // 查询关键字 if ($keyword) { $where_keyword = ' AND CONCAT(u.saus_salesid, u.saus_nickname) like "%' . trim($keyword) . '%"'; } else { $where_keyword = ''; } # 分页信息 $page_index = empty($param['_params']['page_index']) ? 1 : intval($param['_params']['page_index']); // 当前页 $page_size = empty($param['_params']['page_size']) ? 10 : intval($param['_params']['page_size']); // 单页容量 $start = ($page_index - 1) * $page_size; $strPage = ''; if (!empty($page_index)) { $strPage .= " LIMIT {$start},{$page_size} "; } if ($beginTime) { $where_begin = ' AND r.request_time >= "' . $beginTime . ' 00:00:00"'; } else { $where_begin = ''; } if ($endTime) { $where_end = ' AND r.request_time <= "' . $endTime . ' 23:59:59"'; } else { $where_end = ''; } $items = $this->PDO_Request( ' SELECT r.id, r.order_number, r.request_time, r.request_currency as money, r.status, u.saus_salesid as salesid, u.saus_nickname as nickname, u.saus_avatar as avatar FROM ct_withdraw_record r JOIN sales_user u ON r.sales_id = u.saus_salesid AND r.agent_id = u.saus_agentid AND r.channel_id = u.saus_channelid WHERE agent_id = ? AND channel_id = ? AND sales_id = ?' . $where_begin . $where_end . $where_keyword . ' ORDER BY request_time desc ' . $strPage . ';', $param['agentID'], $param['channelID'], $param['salesID'] ); if (!is_array($items)) { $outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo()); return false; } # 分页计算 $page_count = 1; $dbData = $this->PDO_Request( ' SELECT count(1) num FROM ct_withdraw_record r JOIN sales_user u ON r.sales_id = u.saus_salesid AND r.agent_id = u.saus_agentid AND r.channel_id = u.saus_channelid WHERE agent_id = ? AND channel_id = ? AND sales_id = ?' . $where_begin . $where_end . $where_keyword . ';', $param['agentID'], $param['channelID'], $param['salesID'] ); if (!is_array($dbData) || count($dbData) < 1) { $outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo()); return false; } $data_count = intval($dbData[0]['num']); $page_count = $data_count / $page_size + 1; // 总页数 // 5、数据返回部分 $outParam->biz_content = array( 'data' => $items, 'page_index' => $page_index, 'page_size' => $page_size, 'page_count' => intval($page_count), 'data_count' => $data_count, ); return true; } /** * [查]查询订单 代理都有权限 pc * author summer */ public function getWithdrawRecord4pc($inParam, $outParam) { // 1、系统非空数据配置初始化 $config = array( # 代理商id 'agentID' => array( 'name' => 'agentid', 'errcode' => ERRORCODE_AGENTIDERROR, 'errinfo' => ERRORINFO_AGENTIDERROR, ), # 渠道商id 'channelID' => array( 'name' => 'channelid', 'errcode' => ERRORCODE_CHANNELIDERROR, 'errinfo' => ERRORINFO_CHANNELIDERROR, ), # 个人代理id 'salesID' => array( 'name' => 'salesid', 'errcode' => ERRORCODE_SALESIDERROR, 'errinfo' => ERRORINFO_SALESIDERROR, ), ); // 2、数据处理后的结果集 异常标志err:true false $param = $this->inParamHandel($inParam, $outParam, $config); if (!$param) { return false; } //3.1 可选参数获取 $beginTime = empty($param['_params']['begintime']) ? false : $param['_params']['begintime']; // 查询开始时间 $endTime = empty($param['_params']['endtime']) ? false : $param['_params']['endtime']; // 查询结束时间 $status = empty($param['_params']['status']) ? 5 : $param['_params']['status']; // 查询状态 switch ($status) { // 当前状态(0: 待审核;1: 已审核; 2: 已驳回; -1: 已撤销) case '-1': $where_status = ' AND r.status = -1'; break; case '3': $where_status = ' AND r.status = 0'; break; case '1': $where_status = ' AND r.status = 1'; break; case '2': $where_status = ' AND r.status = 2'; break; default: $where_status = ''; break; } $keyword = empty($param['_params']['keyword']) ? false : $param['_params']['keyword']; // 查询关键字 if ($keyword) { $where_keyword = ' AND CONCAT(u.player_id, u.saus_nickname) like "%' . trim($keyword) . '%"'; } else { $where_keyword = ''; } # 分页信息 $page_index = empty($param['_params']['page_index']) ? 1 : intval($param['_params']['page_index']); // 当前页 $page_size = empty($param['_params']['page_size']) ? 10 : intval($param['_params']['page_size']); // 单页容量 $start = ($page_index - 1) * $page_size; $strPage = ''; if (!empty($page_index)) { $strPage .= " LIMIT {$start},{$page_size} "; } if ($beginTime) { $where_begin = ' AND r.request_time >= "' . $beginTime . ' 00:00:00"'; } else { $where_begin = ''; } if ($endTime) { $where_end = ' AND r.request_time <= "' . $endTime . ' 23:59:59"'; } else { $where_end = ''; } $items = $this->PDO_Request( ' SELECT r.id, r.order_number, r.request_time, r.request_currency as money, r.status, u.player_id as player_id, u.saus_nickname as nickname, u.saus_avatar as avatar, u.saus_alipay as alipay FROM ct_withdraw_record r JOIN sales_user u ON r.sales_id = u.saus_salesid AND r.agent_id = u.saus_agentid AND r.channel_id = u.saus_channelid WHERE agent_id = ? AND channel_id = ?' . $where_begin . $where_end . $where_keyword . $where_status . ' ORDER BY request_time desc ' . $strPage . ';', $param['agentID'], $param['channelID'] ); if (!is_array($items)) { $outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo()); return false; } # 分页计算 $page_count = 1; $dbData = $this->PDO_Request( ' SELECT count(1) num FROM ct_withdraw_record r JOIN sales_user u ON r.sales_id = u.saus_salesid AND r.agent_id = u.saus_agentid AND r.channel_id = u.saus_channelid WHERE agent_id = ? AND channel_id = ?' . $where_begin . $where_end . $where_keyword . $where_status . ';', $param['agentID'], $param['channelID'] ); if (!is_array($dbData) || count($dbData) < 1) { $outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo()); return false; } $data_count = intval($dbData[0]['num']); $page_count = $data_count / $page_size + 1; // 总页数 // 5、数据返回部分 $outParam->biz_content = array( 'data' => $items, 'page_index' => $page_index, 'page_size' => $page_size, 'page_count' => intval($page_count), 'data_count' => $data_count, ); return true; } /** * 导出报表 * @param RequestParameter $request * @param ReturnParameter $return * @return bool */ public function exportReport($inParam, $outParam) { // 1、系统非空数据配置初始化 $config = array( # 代理商id 'agentID' => array( 'name' => 'agentid', 'errcode' => ERRORCODE_AGENTIDERROR, 'errinfo' => ERRORINFO_AGENTIDERROR, ), # 渠道商id 'channelID' => array( 'name' => 'channelid', 'errcode' => ERRORCODE_CHANNELIDERROR, 'errinfo' => ERRORINFO_CHANNELIDERROR, ), # 个人代理id 'salesID' => array( 'name' => 'salesid', 'errcode' => ERRORCODE_SALESIDERROR, 'errinfo' => ERRORINFO_SALESIDERROR, ), ); // 2、数据处理后的结果集 异常标志err:true false $param = $this->inParamHandel($inParam, $outParam, $config); if (!$param) { return false; } //3.1 可选参数获取 $beginTime = empty($param['_params']['begintime']) ? false : $param['_params']['begintime']; // 查询开始时间 $endTime = empty($param['_params']['endtime']) ? false : $param['_params']['endtime']; // 查询结束时间 $status = empty($param['_params']['status']) ? 5 : $param['_params']['status']; // 查询状态 switch ($status) { // 当前状态(0: 待审核;1: 已审核; 2: 已驳回; -1: 已撤销) case '-1': $where_status = ' AND r.status = -1'; break; case '3': $where_status = ' AND r.status = 0'; break; case '1': $where_status = ' AND r.status = 1'; break; case '2': $where_status = ' AND r.status = 2'; break; default: $where_status = ''; break; } $keyword = empty($param['_params']['keyword']) ? false : $param['_params']['keyword']; // 查询关键字 if ($keyword) { $where_keyword = ' AND CONCAT(u.player_id, u.saus_nickname) like "%' . trim($keyword) . '%"'; } else { $where_keyword = ''; } if ($beginTime) { $where_begin = ' AND r.request_time >= "' . $beginTime . ' 00:00:00"'; } else { $where_begin = ''; } if ($endTime) { $where_end = ' AND r.request_time <= "' . $endTime . ' 23:59:59"'; } else { $where_end = ''; } $SqlCommand = ' SELECT r.id, r.order_number, r.request_time, r.request_currency as money, r.status, u.player_id as player_id, u.saus_nickname as nickname, u.saus_avatar as avatar, u.saus_alipay as alipay FROM ct_withdraw_record r JOIN sales_user u ON r.sales_id = u.saus_salesid AND r.agent_id = u.saus_agentid AND r.channel_id = u.saus_channelid WHERE agent_id = \''.$param['agentID'].'\' AND channel_id = \''.$param['channelID']. '\'' . $where_begin . $where_end . $where_keyword . $where_status . ' ORDER BY request_time desc'; $params = [ 'id', 'order_number', 'request_time', 'money', 'player_id', 'nickname', 'avatar', 'alipay', ]; var_dump($SqlCommand);die; $DatabaseHelper->ExportToBrowser($SqlCommand, $params); die; } ##------------ 用户账户操作[curd] 总代权限 ##------------[表:sales_user] ---------------------------------> /** * [查]查询代理用户账户 * author summer */ public function getSalesUser($inParam, $outParam) { // 1、系统非空数据配置初始化 $config = array( # 代理商id 'agentID' => array( 'name' => 'agentid', 'errcode' => ERRORCODE_AGENTIDERROR, 'errinfo' => ERRORINFO_AGENTIDERROR, ), # 渠道商id 'channelID' => array( 'name' => 'channelid', 'errcode' => ERRORCODE_CHANNELIDERROR, 'errinfo' => ERRORINFO_CHANNELIDERROR, ), # 个人代理id 'salesID' => array( 'name' => 'salesid', 'errcode' => ERRORCODE_SALESIDERROR, 'errinfo' => ERRORINFO_SALESIDERROR, ), ); // 2、数据处理后的结果集 异常标志err:true false $param = $this->inParamHandel($inParam, $outParam, $config); if (!$param) return false; // 3、权限验证 $auth = $this->checkAgentAuth($inParam, $outParam, $param['agentID'], $param['channelID'], $param['salesID']); if (!$auth) return false; //3.1 可选参数获取 $status = empty($param['_params']['status']) ? 1 : $param['_params']['status']; // 状态(1、全部 2、正常 3、封禁) $objuserid = empty($param['_params']['objuserid']) ? false : $param['_params']['objuserid']; // 指定查询代理/玩家id $beginTime = empty($param['_params']['begintime']) ? false : $param['_params']['begintime']; // 查询开始时间 $endTime = empty($param['_params']['endtime']) ? false : $param['_params']['endtime']; // 查询结束时间 $keyword = empty($param['_params']['keyword']) ? false : $param['_params']['keyword']; // 查询关键字 $parent_id = empty($param['_params']['parent_id']) ? (empty($param['_params']['keyword']) ? $param['salesID'] : $param['_params']['keyword']) : $param['_params']['parent_id']; // 查询下级 默认登录用户 $global_power = isset($param['_params']['global_power']) ? $param['_params']['global_power'] : 'all'; // 查询总代 $jibie = isset($param['_params']['jibie']) ? $param['_params']['jibie'] : 'all'; // 查询总代 // 如果传了父级id则要遍历出所有上级 if ($parent_id) { $pid = $parent_id; // 要查询的记录id $parents = []; // 装所有的上级容器 $now_sql = /** @lang text */' SELECT idx, saus_avatar, saus_salesid, saus_parentid, saus_nickname FROM sales_user WHERE saus_salesman = 1 AND CONCAT(saus_salesid, saus_nickname) like "%' . trim($parent_id) . '%" AND saus_agentid = ? AND saus_channelid = ?;'; $now = $this->PDO_Request($now_sql, $param['agentID'], $param['channelID']); if (!$this->PDO_IsDone()) { $outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo()); return false; } if(!empty($now['0'])) $parents[] = $now[0]; while ($pid) { $sql = /** @lang text */' SELECT p.idx, p.saus_avatar, p.saus_salesid, p.saus_parentid, p.saus_nickname FROM sales_user p JOIN sales_user c ON c.saus_parentid = p.saus_salesid AND p.saus_salesman = 1 AND CONCAT(c.saus_salesid, c.saus_nickname) like "%' . trim($pid) . '%" AND c.saus_salesman = 1 AND p.saus_agentid = ? AND p.saus_channelid = ? AND c.saus_agentid = ? AND c.saus_channelid = ?;'; $parent = $this->PDO_Request($sql, $param['agentID'], $param['channelID'], $param['agentID'], $param['channelID']); if (!$this->PDO_IsDone()) { $outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo()); return false; } if(!empty($parent['0'])){ $parents[] = $parent[0]; if ($parent['0']['saus_parentid'] != $pid && !empty($parent['0']['saus_parentid'])) { $pid = $parent['0']['saus_salesid']; }else{ $pid =false; } }else{ $pid =false; } } } // 子查询条件 if (!empty($param['_params']['parent_id'])) $parent_where = ' AND a.saus_parentid = '.$param['_params']['parent_id']; else $parent_where = ''; // 总代过滤 $array_fielter = ['0', '1']; if(in_array($global_power, $array_fielter)) $global_where = ' AND a.global_power = '.$global_power; else $global_where = ''; // 级别过滤 if (in_array($jibie, $array_fielter)) { $jibie_where = ' AND a.saus_parentid is null'; }else{ $jibie_where = ''; } switch ($status) { case '2': $where_status = ' AND a.saus_status = 0'; break; case '3': $where_status = ' AND a.saus_status = 1'; break; default: $where_status = ''; break; } if ($keyword) { $where_keyword = ' AND CONCAT(a.saus_salesid, a.saus_nickname) like "%' . trim($keyword) . '%"'; } else { $where_keyword = ''; } # 分页信息 $page_index = empty($param['_params']['page_index']) ? 1 : intval($param['_params']['page_index']); // 当前页 $page_size = empty($param['_params']['page_size']) ? 100 : intval($param['_params']['page_size']); // 单页容量 $start = ($page_index - 1) * $page_size; $strPage = ''; if (!empty($page_index)) { $strPage .= " LIMIT {$start},{$page_size} "; } if ($beginTime) { $where_begin = ' AND a.saus_saletime >= "' . $beginTime . ' 00:00:00"'; } else { $where_begin = ''; } if ($endTime) { $where_end = ' AND a.saus_saletime <= "' . $endTime . ' 23:59:59"'; } else { $where_end = ''; } $items = $this->PDO_Request( ' SELECT a.idx, a.saus_commit_auth, a.saus_salesid, a.saus_avatar, a.saus_firsttime, a.saus_status, a.saus_nickname, a.saus_parentid, a.currency_total, a.currency_withdraw, a.currency_freeze, a.global_power, a.currency_withdraw - ifnull(b.request_currency, 0) real_withdraw, c.play_roomcard, c.play_bean, c.play_logindate FROM sales_user a LEFT JOIN (SELECT agent_id, channel_id, sales_id, sum(request_currency) request_currency FROM ct_withdraw_record WHERE status = 0 GROUP BY agent_id, channel_id, sales_id) b ON a.saus_agentid = b.agent_id AND a.saus_channelid = b.channel_id AND a.saus_salesid = b.sales_id INNER JOIN player c ON a.player_id = c.play_playerid AND c.play_agentid = a.saus_agentid AND c.play_channelid = a.saus_channelid WHERE a.saus_agentid = ? AND a.saus_channelid = ? AND a.saus_salesman = ? ' . $where_begin . $where_end . $where_keyword . $where_status . $parent_where. $global_where. $jibie_where.' ORDER BY a.saus_saletime desc ' . $strPage . ';', $param['agentID'], $param['channelID'], 1 ); if (!is_array($items)) { $outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo()); return false; } # 分页计算 $dbData = $this->PDO_Request( ' SELECT count(1) num FROM sales_user a WHERE saus_agentid = ? AND saus_channelid = ? AND saus_salesman = ?' . $where_begin . $where_end . $where_keyword . $where_status . $parent_where. $global_where. $jibie_where.';' , $param['agentID'], $param['channelID'], 1 ); if (!is_array($dbData) || count($dbData) < 1) { $outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo()); return false; } $data_count = intval($dbData[0]['num']); $page_count = $data_count / $page_size + 1; // 总页数 // 5、数据返回部分 $outParam->biz_content = array( 'data' => $items, 'parents'=>array_reverse($parents), 'page_index' => $page_index, 'page_size' => $page_size, 'page_count' => intval($page_count), 'data_count' => $data_count, ); return true; } /** * [查]查询下级代理账户 * author summer */ public function getPlayer($inParam, $outParam) { // 1、系统非空数据配置初始化 $config = array( # 代理商id 'agentID' => array( 'name' => 'agentid', 'errcode' => ERRORCODE_AGENTIDERROR, 'errinfo' => ERRORINFO_AGENTIDERROR, ), # 渠道商id 'channelID' => array( 'name' => 'channelid', 'errcode' => ERRORCODE_CHANNELIDERROR, 'errinfo' => ERRORINFO_CHANNELIDERROR, ), # 个人代理id 'salesID' => array( 'name' => 'salesid', 'errcode' => ERRORCODE_SALESIDERROR, 'errinfo' => ERRORINFO_SALESIDERROR, ), ); // 2、数据处理后的结果集 异常标志err:true false $param = $this->inParamHandel($inParam, $outParam, $config); if (!$param) return false; // 3、权限验证 $auth = $this->checkAgentAuth($inParam, $outParam, $param['agentID'], $param['channelID'], $param['salesID']); if (!$auth) return false; //3.1 可选参数获取 $status = empty($param['_params']['status']) ? 1 : $param['_params']['status']; // 状态(1、全部 2、正常 3、封禁) $objuserid = empty($param['_params']['objuserid']) ? false : $param['_params']['objuserid']; // 指定查询代理/玩家id $beginTime = empty($param['_params']['begintime']) ? false : $param['_params']['begintime']; // 查询开始时间 $endTime = empty($param['_params']['endtime']) ? false : $param['_params']['endtime']; // 查询结束时间 $keyword = empty($param['_params']['keyword']) ? false : $param['_params']['keyword']; // 查询关键字 $parent_id = empty($param['_params']['parent_id']) ? (empty($param['_params']['keyword']) ? $param['salesID'] : $param['_params']['keyword']) : $param['_params']['parent_id']; // 查询下级 默认登录用户 // 如果传了父级id则要遍历出所有上级 if ($parent_id) { $pid = $parent_id; // 要查询的记录id $parents = []; // 装所有的上级容器 $now_sql = /** @lang text */' SELECT idx, saus_avatar, saus_salesid, saus_parentid, saus_nickname FROM sales_user WHERE saus_salesman = 1 AND CONCAT(saus_salesid, saus_nickname) like "%' . trim($parent_id) . '%" AND saus_agentid = ? AND saus_channelid = ?;'; $now = $this->PDO_Request($now_sql, $param['agentID'], $param['channelID']); if (!$this->PDO_IsDone()) { $outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo()); return false; } if(!empty($now['0'])) $parents[] = $now[0]; while ($pid) { $sql = /** @lang text */' SELECT p.idx, p.saus_avatar, p.saus_salesid, p.saus_parentid, p.saus_nickname FROM sales_user p JOIN sales_user c ON c.saus_parentid = p.saus_salesid AND p.saus_salesman = 1 AND CONCAT(c.saus_salesid, c.saus_nickname) like "%' . trim($pid) . '%" AND c.saus_salesman = 1 AND p.saus_agentid = ? AND p.saus_channelid = ? AND c.saus_agentid = ? AND c.saus_channelid = ?;'; $parent = $this->PDO_Request($sql, $param['agentID'], $param['channelID'], $param['agentID'], $param['channelID']); if (!$this->PDO_IsDone()) { $outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo()); return false; } if(!empty($parent['0'])){ $parents[] = $parent[0]; if ($parent['0']['saus_parentid'] != $pid && !empty($parent['0']['saus_parentid'])) { $pid = $parent['0']['saus_salesid']; }else{ $pid =false; } }else{ $pid =false; } } } // 子查询条件 if (!empty($param['_params']['parent_id'])) $parent_where = ' AND a.play_invitecode = '.$param['_params']['parent_id']; else $parent_where = ''; // 用户状态 switch ($status) { case '2': $where_status = ' AND a.play_status = 0'; // 正常用户 break; case '3': $where_status = ' AND a.play_status = 1'; // 被封用户 break; default: $where_status = ''; // 全部用户 break; } // 通过玩家id和昵称查询玩家 if ($keyword) $where_keyword = ' AND CONCAT(a.play_playerid, a.play_nickname) like "%' . trim($keyword) . '%"'; else $where_keyword = ''; # 分页信息 $page_index = empty($param['_params']['page_index']) ? 1 : intval($param['_params']['page_index']); // 当前页 $page_size = empty($param['_params']['page_size']) ? 100 : intval($param['_params']['page_size']); // 单页容量 $start = ($page_index - 1) * $page_size; $strPage = ''; if (!empty($page_index)) $strPage .= " LIMIT {$start},{$page_size} "; if ($beginTime) $where_begin = ' AND a.play_regtime >= "' . $beginTime . ' 00:00:00"'; else $where_begin = ''; if ($endTime) $where_end = ' AND a.play_regtime <= "' . $endTime . ' 23:59:59"'; else $where_end = ''; $items = $this->PDO_Request( 'SELECT a.idx, a.play_playerid, a.play_nickname, a.play_avatar, a.play_roomcard, a.play_bean, a.play_regtime, a.play_lasttime, a.play_logindate, a.play_usecard, a.play_taskaward FROM player a WHERE a.play_agentid = ? AND a.play_channelid = ? ' . $where_begin . $where_end . $where_keyword . $where_status . $parent_where.' ORDER BY a.play_regtime desc ' . $strPage . ';', $param['agentID'], $param['channelID'] ); if (!is_array($items)) { $outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo()); return false; } # 分页计算 $dbData = $this->PDO_Request( ' SELECT count(1) num FROM player a WHERE play_agentid = ? AND play_channelid = ?' . $where_begin . $where_end . $where_keyword . $where_status . $parent_where.';' , $param['agentID'], $param['channelID'] ); if (!is_array($dbData) || count($dbData) < 1) { $outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo()); return false; } $data_count = intval($dbData[0]['num']); $page_count = $data_count / $page_size + 1; // 总页数 // 5、数据返回部分 $outParam->biz_content = array( 'data' => $items, 'parents'=>array_reverse($parents), 'page_index' => $page_index, 'page_size' => $page_size, 'page_count' => intval($page_count), 'data_count' => $data_count, ); return true; } /** * [改]修改用户账户 * author summer */ public function editSalesUser($inParam, $outParam) { $config = array( # 代理商id 'agentID' => array( 'name' => 'agentid', 'errcode' => ERRORCODE_AGENTIDERROR, 'errinfo' => ERRORINFO_AGENTIDERROR, ), # 渠道商id 'channelID' => array( 'name' => 'channelid', 'errcode' => ERRORCODE_CHANNELIDERROR, 'errinfo' => ERRORINFO_CHANNELIDERROR, ), # 个人代理id 'salesID' => array( 'name' => 'salesid', 'errcode' => ERRORCODE_SALESIDERROR, 'errinfo' => ERRORINFO_SALESIDERROR, ), # 操作记录id 'id' => array( 'name' => 'id', 'errcode' => 000002, 'errinfo' => 'id不能为空', ), ); // 2、数据处理后的结果集 异常标志err:true false $param = $this->inParamHandel($inParam, $outParam, $config); if (!$param) { return false; } // 3、权限验证 $auth = $this->checkAgentAuth($inParam, $outParam, $param['agentID'], $param['channelID'], $param['salesID']); if (!$auth) { return false; } // 4、业务逻辑部分 #a.查看分类是否存在 $item = $this->PDO_Request( ' select * from sales_user where idx = ?; ', $param['id'] ); if (!$item) { $outParam->SetErrors(ERRORCODE_COMMISSIONNOTEXISTERROR, ERRORINFO_COMMISSIONNOTEXISTERROR); return false; } #b.传了几个改几个,没有传用默认 // $saus_nickname = isset($param['_params']['saus_nickname']) ? $param['_params']['saus_nickname'] : $item[0]['saus_nickname']; // 昵称 // $saus_wechat = isset($param['_params']['saus_wechat']) ? $param['_params']['saus_wechat'] : $item[0]['saus_wechat']; // 微信 // $saus_tel = isset($param['_params']['saus_tel']) ? $param['_params']['saus_tel'] : $item[0]['saus_tel']; // 电话 $currency_freeze = isset($param['_params']['currency_freeze']) ? $param['_params']['currency_freeze'] : $item[0]['currency_freeze']; // 冻结金额 $saus_status = isset($param['_params']['saus_status']) ? $param['_params']['saus_status'] : $item[0]['saus_status']; // 用户状态 $saus_commit_auth = isset($param['_params']['saus_commit_auth']) ? $param['_params']['saus_commit_auth'] : $item[0]['saus_commit_auth']; // 用户状态 if (isset($param['_params']['currency_freeze'])) { // 冻结金额需要扣除可提现金额 $fee = $this->PDO_Request( ' SELECT currency_withdraw, currency_total, currency_freeze FROM sales_user WHERE idx = ?;', $param['id'] ); if (!is_array($fee) || count($fee) < 1) { $outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo()); return false; } // 冻结金额不能大于账户可提现金额 if ($param['_params']['currency_freeze'] < 0) { $outParam->SetErrors(0000001, '冻结金额不能小于0'); return false; } // 冻结金额不能大于账户可提现金额 if ($param['_params']['currency_freeze'] > ($fee[0]['currency_withdraw'] + $fee[0]['currency_freeze'])) { $outParam->SetErrors(0000001, '超出可冻结范围'); return false; } // 冻结金额需要扣除可提现金额 $currency_withdraw = $fee[0]['currency_withdraw'] + $fee[0]['currency_freeze'] - $param['_params']['currency_freeze']; $this->PDO_Execute( ' update sales_user set currency_withdraw = ? where idx = ?;', $currency_withdraw, $param['id'] ); if (!$this->PDO_IsDone()) { $outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo()); return false; } } $this->PDO_Execute( ' update sales_user set currency_freeze = ?, saus_status = ?, saus_commit_auth = ? where idx = ?; ', $currency_freeze, $saus_status ,$saus_commit_auth , $param['id'] ); if (!$this->PDO_IsDone()) { $outParam->SetErrors($this->GetErrorCode(), $this->GetErrorInfo()); return false; } return true; } ##------------ 工具方法[curd] ##------------[summer 2017/11/6 Handel] -----------------------> /** * 输入参数标准化处理 * @param RequestParameter $inParam * @param ReturnParameter $outParam * @param array $config 待处理变量配置文件 * * @return array data * * author:summer 2017/11/6 */ public function inParamHandel($inParam, $outParam, $config) { foreach ($config as $k => $v) { // 1、全局校验 $data['_params'] = $request_data = isset($inParam->biz_content) ? $inParam->biz_content : ''; if (!is_array($request_data)) { $outParam->SetErrors(ERRORCODE_INPARAMERROR, ERRORINFO_INPARAMERROR); return false; } // 2、单元校验 $data[$k] = isset($request_data[$v['name']]) ? $request_data[$v['name']] : ''; if (empty($data[$k])) { $outParam->SetErrors($v['errcode'], $v['errinfo']); return false; } } // 3、返回处理后的数据 return $data; } /** * 代理权限认证 * @param RequestParameter $agentid 代理商id * @param RequestParameter $channelid 渠道商id * @param RequestParameter $salesid 代理人id * * @return array data * * author:summer 2017/11/6 */ public function checkAgentAuth($inParam, $outParam, $agentID, $channelID, $salesID) { //只有总代理才有权限 $dbSalesInfo = $this->PDO_Request( ' 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->GetErrorCode(), $this->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; } return true; } }