static function add($_row) { $row = self::getSaveRow($_row); $row['add_time'] = Utils::date_time_now(); $row['op_uid'] = Model_Admin_Auth::get_user_id(); return self::_db()->insert(self::TABLE_REVISIT, $row); }
static function add($_row) { $row = self::getPorderSaveRow($_row); $row['orderno'] = self::get_orderno(self::TABLE_PORDER); $row['add_time'] = Utils::date_time_now(); $row['op_uid'] = Model_Admin_Auth::get_user_id(); return self::_db()->insert(self::TABLE_PORDER, $row); }
function test_get_stf_id_by_mobile() { $mobile = "13555555553"; $stf_id = \Model_Admin_Staff::get_staff_id_by_mobile($mobile); $res = \Model_Admin_Staff::get_auth_user_by_stf_id($stf_id); $password = $res['password']; $salt = $res['salt']; $_password = \Model_Admin_Auth::gen_password("111111", $salt); var_export($_password); }
static function add($msg, $method) { $ip = Utils::ip(); $date = Utils::date_time_now(); // $row = array( // "ip" => $ip, // "add_time" => $date, // "msg" => $msg, // "method" => $method, // "user_id" => Model_Admin_Auth::get_user_id(), // ); $row = array("action_ip" => Utils::ip(true), "create_time" => time(), "remark" => $msg, "model" => $method, "user_id" => Model_Admin_Auth::get_user_id()); self::_db()->insert(self::TABLE, $row); }
static function add($_row) { $row = self::getOrderSaveRow($_row); if ($row['orderno']) { $table = self::TABLE_ORDER; $order = self::_db()->select_row("select * from {$table} where orderno = ?", $row['orderno']); if ($order) { _throw("订单号:" . $row['orderno'] . " 已存在"); } } $row['add_time'] = Utils::date_time_now(); $row['op_uid'] = Model_Admin_Auth::get_user_id(); $staff_info = Model_Admin_Staff::detail_by_uid($row['op_uid']); $row['op_name'] = $staff_info['name']; $items = self::getOrderItemsSaveRows($_row); $id = self::_db()->insert(self::TABLE_ORDER, $row); foreach ($items as &$item) { $item['order_id'] = $id; } if ($items) { self::_db()->insert("crm_client_order_item", $items); } return $id; }
function __construct() { \Model_Admin_Auth::set_login_session(-1); $this->obj = new User(); }
function test_gen_password() { //afdfc8aa0e94cc2d65bd82a841d579dc echo $password = \Model_Admin_Auth::gen_password("111111", "0301d9ff0daaee5ac3b0f6dc755efa63"); }
static function list_rows($condition = array(), $pager = array(), $order = array()) { $sort_field = !in_array($order['sort_field'], array("id")) ? "id" : $order['sort_field']; $table_alias = "a"; $sort_field = $table_alias . "." . $sort_field; $where = "where {$table_alias}.is_del = 0"; $args = array(); $table = self::TABLE; if (!empty($condition['name'])) { $where .= " and {$table_alias}.name like ?"; $args[] = "%" . $condition['name'] . "%"; } if (!empty($condition['charger_name'])) { $where .= " and {$table_alias}.charger_name like ?"; $args[] = "%" . $condition['charger_name'] . "%"; } if (!empty($condition['tel'])) { $where .= " and {$table_alias}.tel like ?"; $args[] = "%" . $condition['tel'] . "%"; } if (!empty($condition['zxs_uid'])) { $where .= " and {$table_alias}.zxs_uid like ?"; $args[] = "%" . $condition['zxs_uid'] . "%"; } if (!empty($condition['kf_uid'])) { $where .= " and {$table_alias}.kf_uid like ?"; $args[] = "%" . $condition['kf_uid'] . "%"; } if (!empty($condition['area_id'])) { $where .= " and {$table_alias}.area_id = ?"; $args[] = $condition['area_id']; } if (!empty($condition['agent_id'])) { $where .= " and {$table_alias}.agent_id = ?"; $args[] = $condition['agent_id']; } if (!empty($condition['start_time'])) { $where .= " and {$table_alias}.add_time >= ?"; $args[] = $condition['start_time'] . " 00:01"; } if (!empty($condition['end_time'])) { $where .= " and {$table_alias}.add_time <= ?"; $args[] = $condition['end_time'] . " 23:59"; } $user_id = Model_Admin_Auth::get_user_id(); if ($user_id > 0) { $uids = Model_Admin_Staff::get_sub_position_uids($user_id); $uids[] = $user_id; $where .= " and ({$table_alias}.op_uid in (" . implode(",", $uids) . ") or\n {$table_alias}.zxs_uid = ? or\n {$table_alias}.zxz_uid = ?)"; $args[] = $user_id; $args[] = $user_id; } $sort_type_tpl = array("ascend" => "asc", "descend" => "desc"); $sort_type = !in_array($order['sort_type'], array_keys($sort_type_tpl)) ? "desc" : $sort_type_tpl[$order['sort_type']]; //_throw($sort_type); $count_res = self::_db()->select_row("SELECT COUNT({$table_alias}.id) AS total FROM {$table} as {$table_alias} {$where}", $args); $records = $count_res['total']; $page = $pager['page']; $limit = $pager['limit']; if ($records > 0) { $total_pages = ceil($records / $limit); } else { $total_pages = 1; } $skip = ($page - 1) * $limit; $sql = "SELECT {$table_alias}.*,{$table_alias}.id as `key`,{$table_alias}.id FROM {$table} as {$table_alias} {$where} ORDER BY {$sort_field} {$sort_type} LIMIT {$skip},{$limit} "; //_throw($sql); //self::_debug(array($sql,$args,$condition,$pager,$order,$sort_field,$sort_type)); $rows = self::_db()->select_rows($sql, $args); foreach ($rows as &$row) { $row['key'] = $row['id']; if ($row['agent_id']) { $agent_info = Model_Crm_Agent::detail($row['agent_id']); if ($agent_info && $agent_info['is_del'] == 0) { $row['agent_name'] = $agent_info['com_name']; $row['area_id'] = $agent_info['area_id']; $row['province_id'] = $agent_info['province_id']; } else { $row['agent_name'] = ""; $row['area_id'] = ""; $row['province_id'] = ""; } } else { $row['area_id'] = ""; $row['province_id'] = ""; $row['agent_name'] = ""; } $row['area_name'] = Model_Crm_Area::detail($row['area_id']); $row['province_name'] = Model_Province::detail($row['province_id']); $op_uid = $row['op_uid']; $staff_info = Model_Admin_Staff::get_staff_info_by_uid_from_cache($op_uid); if ($staff_info) { $row['op_name'] = $staff_info['name']; $row['op_avatar'] = $staff_info['avatar']; } else { $row['op_name'] = ""; $row['op_avatar'] = ""; } } return array("total_pages" => $total_pages, "total" => $records, "rows" => $rows); }
function action_add($row) { $res = self::getSaveRow($row); $table = self::table(); $pk = self::pk(); $res['row']['add_time'] = Utils::date_time_now(); if (!Utils::is_mobile($res['row']['mobile'])) { _throw("手机号不合法"); } $mobile = $res['row']['mobile']; $user_mobile = self::_db()->row("select mobile from {$table} where mobile = ?", $mobile); if ($user_mobile) { _throw("手机号已存在"); } if (!empty($res['row']['password'])) { $password = $res['row']['password']; $salt = \Model_Admin_Auth::gen_salt(); $res['row']['password'] = \Model_Admin_Auth::gen_password($password, $salt); $res['row']['salt'] = $salt; } else { _throw("密码不能为空"); } $user_id = self::_db()->insert($table, $res['row']); $stf_id = Model_Admin_Staff::get_staff_id_by_mobile($mobile); if ($stf_id) { Model_Admin_Staff::bind_staff_user($stf_id, $user_id); } $res = $this->action_row($user_id); $res['row'][$pk] = $user_id; return $res; }
function action_add($row) { $table = self::table(); $res = self::getSaveRow($row); $res['row']['add_time'] = Utils::date_time_now(); if (!empty($res['row']['mobile'])) { $mobile = $res['row']['mobile']; $staff = self::_db()->row("select mobile from {$table} where mobile = ?", $mobile); if ($staff) { _throw("手机号已存在"); } } $password = null; if (!empty($res['row']['password'])) { $password = $res['row']['password']; unset($res['row']['password']); } unset($res['row']['password']); $id = self::_db()->insert($table, $res['row']); if ($password) { $table_user = self::_table("user"); $user_mobile = self::_db()->row("select user_id from {$table_user} where mobile = ?", $res['row']['mobile']); if (!$user_mobile) { $salt = \Model_Admin_Auth::gen_salt(); $password = \Model_Admin_Auth::gen_password($password, $salt); $user_row = array("password" => $password, "mobile" => $res['row']['mobile'], "salt" => $salt, "add_time" => Utils::date_time_now()); $user_id = self::_db()->insert($table_user, $user_row); } else { $user_id = $table_user['user_id']; } self::_db()->insert(self::_table("staff_user"), array("stf_id" => $id, "user_id" => $user_id)); } return array("stf_id" => $id, "row" => self::get_detail($id)); }
static function check($node) { $role_id = Model_Admin_Auth::get_role_id(); return self::_check($role_id, $node); }
static function __check_admin_login($username, $password) { $res = Model_Admin_Auth::check_login($username, $password); return $res; }
function __construct() { Model_Admin_Auth::check_logined(); }