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_action_login() { $auth = new Auth(); $_SESSION = array(); \PtConfig::$userRsaAuth = false; $auth_info = $auth->action_info(); $res = $auth->action_login("13555555555", "111111"); //var_export($res); $user_id = \Model_Admin_Auth::get_user_id(); var_export($user_id); }
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; }
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); }