public function get_list($params = array(), $page = 1, $rows = 10) { if (!empty($params) && is_array($params)) { foreach ($params as $pk => $pv) { $tmp[] = $pk . '=' . $pv; } } $query_str = !empty($tmp) ? implode(" and ", $tmp) : ''; $sql = "select count(1) as num from op_key"; $db = Yii::$app->db; if (!empty($query_str)) { $sql .= "where " . $query_str; } $total = $db->createCommand($sql)->queryOne(); $sql = "select * from op_key "; if (!empty($query_str)) { $sql .= "where " . $query_str; } $sql .= " order by created_at desc "; if ($page >= 1) { $page = ($page - 1) * $rows; $sql .= " limit {$page}, {$rows}"; } $re = $db->createCommand($sql)->queryAll(); $apply_id = common\Assist::get_fields($re, 'apply_id'); $apply_tmp = array(); if (!empty($apply_id)) { $apply_info = (new Api_apply())->get_info_fieldid($apply_id); if (!empty($apply_info)) { foreach ($apply_info as $ak => $av) { $apply_tmp[$av['id']] = $av; } } } foreach ($re as $rk => $rv) { $re[$rk]['uid'] = isset($apply_tmp[$rv['apply_id']]['uid']) ? $apply_tmp[$rv['apply_id']]['uid'] : ''; $re[$rk]['aid'] = isset($apply_tmp[$rv['apply_id']]['aid']) ? $apply_tmp[$rv['apply_id']]['aid'] : ''; $re[$rk]['rate'] = isset($apply_tmp[$rv['apply_id']]['rate']) ? $apply_tmp[$rv['apply_id']]['rate'] : ''; $re[$rk]['is_agree'] = isset($apply_tmp[$rv['apply_id']]['is_agree']) ? $apply_tmp[$rv['apply_id']]['is_agree'] : ''; } common\multi::get_multi($re); if (!$re) { return false; } return array('total' => $total['num'], 'rows' => $re); }
public function process_allly_info($apply_info) { $aids = \app\models\common\Assist::get_fields($apply_info, 'id'); $secret_obj = new \app\models\Secret(); $secret_info = $secret_obj->get_info_applyid($aids); if (empty($secret_info)) { return false; } $stat_obj = new \app\models\Stat(); // 查询每个secret_key的历史访问峰值 foreach ($secret_info as $sk => $sv) { // 查询一个最多的值 $num = $stat_obj->get_most_num('secret_key_id', $sv['id']); $sv['access_num'] = $num; $secret_tmp[$sv['apply_id']] = $sv; } foreach ($apply_info as $ak => $av) { $apply_info[$ak]['secret_key'] = $secret_tmp[$av['id']]['secret_key']; $apply_info[$ak]['access_num'] = $secret_tmp[$av['id']]['access_num']; } return $apply_info; }