public static function updateUserCompetence($nameList, $smsnum) { self::initDB(); $successnum = 0; $success = array(); $error = array(); //设置批量修改记录标志变量 foreach ($nameList as $from) { $table = "`power_global_user`"; //获取用户的global_user_id $filed = "global_user_id"; $where = " global_user_status = 1 AND global_user_is_delete = 0 AND (global_user_login_name = '{$from}' OR global_user_name = '{$from}') LIMIT 1 "; $ret = self::selectOneTable($table, $filed, $where); if (!$ret[0]['global_user_id']) { self::$errCode = "1057"; self::$errMsg = "获取用户资料失败"; return false; } $from = $ret[0]['global_user_id']; $username = $ret[0]['global_user_name']; $field = "num"; $sql = "SELECT {$field} FROM `" . C('PREFIX') . self::$tabsmspower . "` WHERE 1 AND `global_user_id` = '{$from}' AND `is_delete` = 0 LIMIT 1 "; $query = self::$dbConn->query($sql); $sumnum = self::$dbConn->fetch_array_all($query); //查询在nt_sms_power中是否有sms_num记录 if ($sumnum) { //存在记录则更新 $field = "num"; $sql = "UPDATE " . C('PREFIX') . self::$tabsmspower . " SET num = '{$smsnum}' WHERE global_user_id = '{$from}'"; $query = self::$dbConn->query($sql); if ($query) { $affectedrows = self::$dbConn->affected_rows(); $successnum++; array_push($success, $username); } else { array_push($error, $username); } } else { //不存在记录则插入 $data = array("global_user_id" => $from, "num" => $smsnum, "is_delete" => "0"); $def = array2sql($data); //将数组转为SET后面的sql语句 $def = "INSERT INTO `" . C('PREFIX') . self::$tabsmspower . "` SET " . $def; $query = self::$dbConn->query($def); if ($query) { $successnum++; array_push($success, $username); } else { array_push($error, $username); } } } if ($successnum === count($nameList)) { return array("ret" => "ok", "success" => $success); } else { return array("ret" => "no", "errorUser" => $error, "success" => $success); } }
/** * UserCompetenceModel::showCompetence($uid) * 查看用户权限 * @param int $uid 用户id * @return array */ public static function showCompetence($uid) { self::initDB(); $sql = "SELECT * FROM " . self::$prefix . self::$table_user . " WHERE user_id = {$uid}"; $query = self::$dbConn->query($sql); if ($query) { $affectedrows = self::$dbConn->affected_rows(); if ($affectedrows) { $ret = self::$dbConn->fetch_array_all($query); return $ret; } else { self::$errCode = "10000"; self::$errMsg = "尚未数据,暂不能修改"; return false; } } else { self::$errCode = "10001"; self::$errMsg = "获取数据失败"; return false; } }
/** * UserCompetenceModel::listAccount() * 列出某个或全部平台用户帐号 * @param int $pid 平台ID * @return array */ public static function listAccount($pfid) { self::initDB(); if ($pfid == 0) { $sql = "SELECT id,account FROM " . self::$table_account . " WHERE is_delete = 0"; } else { $sql = "SELECT id,account FROM " . self::$table_account . " WHERE platformId = {$pfid} AND is_delete = 0"; } //echo $sql; $query = self::$dbConn->query($sql); if ($query) { $ret = self::$dbConn->fetch_array_all($query); return $ret; } else { self::$errCode = "1060"; self::$errMsg = "获取数据失败"; return false; } }
/** * UserCompetenceModel::getCompetenceById() * 获取某个用户开放权限ID信息 * @param integer $gid 权限ID * @return array */ public static function getCompetenceById($gid) { self::initDB(); $sql = "SELECT * FROM `" . self::$prefix . self::$table . "` WHERE gid = {$gid}"; $query = self::$dbConn->query($sql); if ($query) { return self::$dbConn->fetch_array($query); } else { self::$errCode = 10000; self::$errMsg = "执行SQL语句出错"; return false; } }
public static function getCompetenceVisiblePlat($uid) { self::initDB(); $sql = "SELECT * FROM wh_userCompetence where globalUserId={$uid}"; $query = self::$dbConn->query($sql); if ($query) { $data = array(); $ret = self::$dbConn->fetch_array($query); if (!empty($ret)) { $data = array(); if (!empty($ret['visiblePlatformAccount'])) { $visible_platform_account = json_decode($ret['visiblePlatformAccount'], true); foreach ($visible_platform_account as $key => $value) { $visible_account[] = $key; } $data = array_filter($visible_account); } } return $data; } else { self::$errCode = "401"; self::$errMsg = "获取数据失败"; return false; } }