/** * 判断是否需要奖励彩金 * Enter description here ... * @param unknown_type $userid */ public function is_no_user($userid) { $agentobj = Myagent::instance(); $agent = $agentobj->get_by_user_id($userid); if ($agent == false) { $is_agent = false; } else { if ($agent['flag'] == 2) { $is_agent = true; } else { $is_agent = false; } } if ($is_agent == false) { $relationobj = Myrelation::instance(); $relation = $relationobj->is_client_user($userid); if ($relation == false) { $is_agent = false; } else { $is_agent = true; } } if (!in_array($userid, self::$no_userid) && $is_agent == false) { return true; } else { return false; } }
public function __construct() { parent::__construct(); role::check('distribution_system_manage'); $this->userDao = Myuser::instance(); $this->agentDao = Myagent::instance(); $this->relationDao = Myrelation::instance(); }
public function template_use($userId, $templateId) { $agentDao = Myagent::instance(); $agent = $agentDao->get_by_user_id($userId); if ($agent == null) { remind::set(Kohana::lang('o_agent.agent_not_exists'), request::referrer(), 'error'); } $rtTemplateDao = MyRealtime_contract_template::instance(); $template = $rtTemplateDao->get_by_id($templateId); if ($template == null) { remind::set(Kohana::lang('o_contract.contract_not_exists'), request::referrer(), 'error'); } $contract = array(); $contract['relation_id'] = 0; $contract['agent_id'] = 0; $contract['user_id'] = $agent['user_id']; $contract['contract_type'] = 0; $contract['type'] = $template['type']; $contract['rate'] = $template['rate']; $contract['taxrate'] = 0; $contract['createtime'] = date("Y-m-d H:i:s", time()); $contract['starttime'] = date("Y-m-d H:i:s", time()); $contract['lastsettletime'] = date("Y-m-d H:i:s", time()); $contract['flag'] = 0; //新建的都是关闭状态 $contract['note'] = null; $rtContractDao = MyRealtime_contract::instance(); if ($rtContractDao->add($contract)) { remind::set(Kohana::lang('o_global.add_success'), 'distribution/realtime_contract/index/' . $userId, 'success'); } else { remind::set(Kohana::lang('o_global.add_error'), request::referrer(), 'error'); } }
public function template_use($userId, $templateId) { $agentDao = Myagent::instance(); $agent = $agentDao->get_by_user_id($userId); if ($agent == null) { remind::set(Kohana::lang('o_agent.agent_not_exists'), request::referrer(), 'error'); } $mtTemplateDao = MyMonth_contract_template::instance(); $template = $mtTemplateDao->get_by_id($templateId); if ($template == null) { remind::set(Kohana::lang('o_contract.contract_not_exists'), request::referrer(), 'error'); } $mtDtlTemplateDao = MyMonth_contract_detail_template::instance(); $searchStruct = array(); $searchStruct['where'] = array('contract_id' => $templateId); $dtlTemplateList = $mtDtlTemplateDao->lists($searchStruct); // tool::filter_strip_tags($data); $mtContractDao = MyMonth_contract::instance(); $mtContractDtlDao = MyMonth_contract_detail::instance(); $contract = array(); $contract['contract_type'] = 0; //普通代理返利 $contract['relation_id'] = 0; $contract['agent_id'] = 0; $contract['user_id'] = $agent['user_id']; $contract['flag'] = 0; $contract['type'] = $template['type']; $contract['taxrate'] = 0; $contract['createtime'] = date("Y-m-d H:i:s", time()); $contract['starttime'] = date("Y-m-d H:i:s", time()); $contract['lastsettletime'] = date("Y-m-d H:i:s", time()); $contract['note'] = null; if ($contractId = $mtContractDao->add($contract)) { foreach ($dtlTemplateList as $aDtlTemplate) { $contractDtl = array(); $contractDtl['contract_id'] = $contractId; $contractDtl['grade'] = $aDtlTemplate['grade']; $contractDtl['minimum'] = $aDtlTemplate['minimum']; $contractDtl['maximum'] = $aDtlTemplate['maximum']; $contractDtl['rate'] = $aDtlTemplate['rate']; $contractDtl['createtime'] = date("Y-m-d H:i:s", time()); $mtContractDtlDao->add($contractDtl); } remind::set(Kohana::lang('o_global.add_success'), 'distribution/month_contract/index/' . $userId, 'success'); } else { remind::set(Kohana::lang('o_global.add_error'), request::referrer(), 'error'); } }
public function index($agentId) { if ($agentId == null) { remind::set(Kohana::lang('o_global.bad_request'), request::referrer(), 'error'); } $agent = Myagent::instance()->get_by_user_id($agentId); if ($agent == null) { remind::set(Kohana::lang('o_agent.agent_not_exists'), request::referrer(), 'error'); } $user_query_struct = array('where' => array(), 'like' => array(), 'orderby' => array(), 'limit' => array('per_page' => 20, 'offset' => 0)); /* 搜索功能 */ $search_arr = array('id', 'email', 'firstname', 'lastname', 'ip', 'mobile', 'real_name'); $search_value = $this->input->get('search_value'); $search_type = $this->input->get('search_type'); $where_view = array(); if ($search_arr) { foreach ($search_arr as $value) { if ($search_type == $value && strlen($search_value) > 0) { $user_query_struct['like'][$value] = $search_value; //$user_query_struct['where'][$value] = $search_value; if ($value == 'ip') { $user_query_struct['like'][$value] = tool::myip2long($search_value); //$user_query_struct['where'][$value] = tool::myip2long($search_value); } } } $where_view['search_type'] = $search_type; $where_view['search_value'] = $search_value; } /* 列表排序 */ $orderby_arr = array(0 => array('id' => 'DESC'), 1 => array('id' => 'ASC'), 4 => array('email' => 'ASC'), 5 => array('email' => 'DESC'), 6 => array('firstname' => 'ASC'), 7 => array('firstname' => 'DESC'), 8 => array('lastname' => 'ASC'), 9 => array('lastname' => 'DESC'), 10 => array('date_add' => 'ASC'), 11 => array('date_add' => 'DESC'), 12 => array('ip' => 'ASC'), 13 => array('ip' => 'DESC'), 14 => array('active' => 'ASC'), 15 => array('active' => 'DESC'), 16 => array('register_mail_active' => 'ASC'), 17 => array('register_mail_active' => 'DESC')); $orderby = controller_tool::orderby($orderby_arr); $user_query_struct['orderby'] = $orderby; /* 每页显示条数 */ $per_page = controller_tool::per_page(); $user_query_struct['limit']['per_page'] = $per_page; /* 调用分页 */ $this->pagination = new Pagination(array('total_items' => Myuser::instance()->query_count($user_query_struct), 'items_per_page' => $per_page)); $user_query_struct['limit']['offset'] = $this->pagination->sql_offset; $user_list = Myuser::instance()->query_assoc($user_query_struct); //找出所有的站点的用户等级信息 $user_levelservice = User_levelService::get_instance(); $query_struct = array('where' => array('active' => 1)); $user_levels = $user_levelservice->index($query_struct); $tmp = array(); foreach ($user_levels as $user_level) { if ($user_level['is_default']) { $tmp['default'] = $user_level; } $tmp[$user_level['id']] = $user_level; } $user_levels = $tmp; foreach ($user_list as $key => $value) { $users[$key]['level'] = ''; if (!empty($user_levels[$value['level_id']])) { $users[$key]['level'] = $user_levels[$value['level_id']]['name_manage']; } else { //$users[$key]['level'] = $user_levels['default']['name_manage']; } } $this->template->content = new View("distribution/client_select_list"); $this->template->content->where = $where_view; $this->template->content->user_list = $user_list; $this->template->content->agent = $agent; }
public function close($agentId) { //权限验证 role::check('distribution_system_manage'); if (!$agentId) { remind::set(Kohana::lang('o_global.bad_request'), request::referrer(), 'error'); } $agentDao = Myagent::instance(); $aAgent = $agentDao->get_by_id($agentId); if ($aAgent == null) { remind::set(Kohana::lang('o_agent.agent_not_exists'), request::referrer(), 'error'); } $aAgent['flag'] = 0; if ($agentDao->edit($aAgent)) { remind::set(Kohana::lang('o_global.update_success'), request::referrer(), 'success'); } else { remind::set(Kohana::lang('o_global.update_fail'), request::referrer(), 'error'); } }