/** * 获取一个人的组织类型 * 门市、代理商、组团社、提供商 * @author wjh 20141113 * @param null $userid * @return string * @throws Exception */ public static function getOrgType($userid = null) { if (empty($userid)) { $userid = BDataHelper::getCurrentUserid(); } $isRole = BDataHelper::checkCurrentUserRole('group_'); if ($isRole) { return GroupTransaction::ORGTYPE_GROUP; } $isRole = BDataHelper::checkCurrentUserRole('sales_'); if ($isRole) { return GroupTransaction::ORGTYPE_SALES; } $isRole = BDataHelper::checkCurrentUserRole('provider_'); if ($isRole) { return GroupTransaction::ORGTYPE_PROVIDER; } $isRole = BDataHelper::checkCurrentUserRole('agent_'); if ($isRole) { return GroupTransaction::ORGTYPE_AGENT; } return GroupTransaction::ORGTYPE_SALES; }
/** * 获取用户分管组织 * @author wjh 2014-8-21 * @param null $userid * @return int */ public static function getUserManager($userid = null) { if (is_null($userid)) { $userid = BDataHelper::getCurrentUserid(); } $user = User::model()->with('org')->findAll("level in(%s,%s) and orgid=%s ", User::LEVEL_DM, User::LEVEL_GM, $userid); return $user->org; }