本文整理汇总了PHP中utils::microtime方法的典型用法代码示例。如果您正苦于以下问题:PHP utils::microtime方法的具体用法?PHP utils::microtime怎么用?PHP utils::microtime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类utils
的用法示例。
在下文中一共展示了utils::microtime方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: request_log
public function request_log($method, $params, $rpc_id)
{
$class = isset(self::$_res_service[$method]) ? self::$_res_service[$method] : '';
$api_mdl = app::get('apiactionlog')->model('apilog');
if ($class) {
$obj = kernel::single($class);
$title = $obj->get_title();
$time = time();
$original_bn = $params['tid'];
if (is_null($rpc_id)) {
$microtime = utils::microtime();
$rpc_id = str_replace('.', '', strval($microtime));
$randval = uniqid('', true);
$rpc_id .= strval($randval);
$rpc_id = md5($rpc_id);
$data = array('apilog' => $rpc_id, 'calltime' => $time, 'params' => $params, 'api_type' => 'request', 'msg_id' => '', 'worker' => $method, 'original_bn' => $original_bn, 'task_name' => $title, 'log_type' => 'order', 'createtime' => $time, 'last_modified' => $time, 'retry' => $retry ? $retry : 0);
} else {
$arr_pk = explode('-', $rpc_id);
$rpc_id = $arr_pk[0];
$tmp = $api_mdl->getList('*', array('apilog' => $rpc_id));
if ($tmp && $tmp[0]['status'] != 'sending') {
$retry = $tmp[0]['retry'] + 1;
}
$data = array('apilog_id' => $tmp[0]['apilog_id'], 'apilog' => $rpc_id, 'calltime' => $time, 'api_type' => 'request', 'worker' => $method, 'original_bn' => $original_bn, 'task_name' => $title, 'log_type' => 'order', 'createtime' => $time, 'last_modified' => $time);
}
$result = $api_mdl->save($data);
$rpc_id = $rpc_id . "-" . $time;
return $rpc_id;
}
}
示例2: begin_transaction
private function begin_transaction($method, $params, $rpc_id = null)
{
$obj_rpc_poll = app::get('base')->model('rpcpoll');
if (is_null($rpc_id)) {
$time = time();
$microtime = utils::microtime();
$rpc_id = str_replace('.', '', strval($microtime));
//mt_srand($microtime);
//$randval = mt_rand();
$randval = uniqid('', true);
$rpc_id .= strval($randval);
$rpc_id = md5($rpc_id);
//$rpc_id = rand(0,$microtime);
$data = array('id' => $rpc_id, 'network' => $this->network_id, 'calltime' => $time, 'method' => $method, 'params' => $params, 'type' => 'request', 'callback' => $this->callback_class . ':' . $this->callback_method, 'callback_params' => $this->callback_params);
$rpc_id = $rpc_id . '-' . $time;
$obj_rpc_poll->insert($data);
} else {
$arr_pk = explode('-', $rpc_id);
$rpc_id = $arr_pk[0];
$rpc_calltime = $arr_pk[1];
$tmp = $obj_rpc_poll->getList('*', array('id' => $rpc_id, 'calltime' => $rpc_calltime));
if ($tmp) {
$data = array('fail_times' => $tmp[0]['fail_times'] + 1);
$fiter = array('id' => $rpc_id, 'calltime' => $rpc_calltime);
$obj_rpc_poll->update($data, $fiter);
}
$rpc_id = $rpc_id . '-' . $rpc_calltime;
}
return $rpc_id;
}
示例3: gen_id
function gen_id()
{
$sign = '9' . date("Ymd");
/*$sqlString = 'SELECT MAX(reship_id) AS maxno FROM sdb_b2c_reship WHERE reship_id LIKE \''.$sign.'%\'';
$aRet = $this->db->selectrow($sqlString);
if(is_null($aRet['maxno'])) $aRet['maxno'] = 0;
$maxno = substr($aRet['maxno'], -6) + 1;
if ($maxno==1000000){
$maxno = 1;
}
return $sign.substr("00000".$maxno, -6);
$microtime = utils::microtime();
mt_srand($microtime);
$randval = mt_rand();*/
while (true) {
$microtime = utils::microtime();
mt_srand($microtime);
$randval = substr(mt_rand(), 0, -3) . rand(100, 999);
$aRet = $this->db->selectrow("SELECT COUNT(*) as c FROM sdb_b2c_reship WHERE reship_id='" . ($sign . $randval) . "'");
if (!$aRet['c']) {
break;
}
}
return $sign . $randval;
}
示例4: apply_id
/**
* 得到唯一的编号.
*
* @params null
*
* @return string 售后序号
*/
public function apply_id()
{
$tb = $this->table_name(1);
do {
$microtime = utils::microtime();
mt_srand($microtime);
$i = substr(mt_rand(), -3);
$request_id = '7' . date('ymdHis') . $i;
$row = $this->db->selectrow('SELECT request_id from ' . $tb . ' where request_id =' . $request_id);
} while ($row);
return $request_id;
}
示例5: apply_id
/**
*
* @params null
* @return string 订单编号
*/
public function apply_id()
{
$tb = $this->table_name(1);
do {
$microtime = utils::microtime();
mt_srand($microtime);
$i = substr(mt_rand(), -5);
$new_order_id = date('y') + date('m') + date('d') . date('His') . $i;
$row = $this->db->selectrow('SELECT order_id from ' . $tb . ' where order_id =' . $new_order_id);
} while ($row);
return $new_order_id;
}
示例6: apply_id
function apply_id($delivery_sdf)
{
$sign = $delivery_sdf['delivery_type'] == 'send' ? '1' : '2';
$tb = $this->table_name(1);
do {
$microtime = utils::microtime();
mt_srand($microtime);
$i = substr(mt_rand(), -3);
$delivery_id = $sign . date('ymdHi') . $i;
$row = $this->db->selectrow('SELECT delivery_id from ' . $tb . ' where delivery_id =' . $delivery_id);
} while ($row);
return $delivery_id;
}
示例7: apply_id
public function apply_id($type = 'comment')
{
$sign = $type == 'comment' ? '8' : '9';
$tb = $this->table_name(1);
do {
$microtime = utils::microtime();
mt_srand($microtime);
$i = substr(mt_rand(), -3);
$comment_id = $sign . (date('y') + date('m') + date('d')) . date('His') . $i;
$row = $this->db->selectrow('SELECT bill_id from ' . $tb . ' where bill_id =' . $bill_id);
} while ($row);
return $comment_id;
}
示例8: _getDeliveryId
private function _getDeliveryId($tid)
{
$sign = '1' . date("Ymd");
while (true) {
$microtime = utils::microtime();
mt_srand($microtime);
$randval = substr(mt_rand(), 0, -3) . rand(100, 999);
$db = app::get('sysitem')->database();
$aRet = $db->executeQuery('select count(*) as c from syslogistics_delivery where tid="' . $tid . '" and delivery_id="' . $sign . $randval . '"')->fetchAll();
if (!$aRet['c']) {
break;
}
}
return $sign . $randval;
}
示例9: apply_id
public function apply_id($bill_sdf)
{
if (is_null($bill_sdf) || empty($bill_sdf['bill_type']) || empty($bill_sdf['pay_object'])) {
trigger_error("单号申请失败", E_USER_ERROR);
exit;
}
$t_map = array('payment' => '1', 'refund' => '2');
$o_map = array('order' => '0', 'recharge' => '1');
$key = $t_map[$bill_sdf['bill_type']] . $o_map[$bill_sdf['pay_object']];
$tb = $this->table_name(1);
do {
$microtime = utils::microtime();
mt_srand($microtime);
$i = substr(mt_rand(), -3);
$bill_id = $key . (date('y') + date('m') + date('d')) . date('His') . $i;
$row = $this->db->selectrow('SELECT bill_id from ' . $tb . ' where bill_id =' . $bill_id);
} while ($row);
return $bill_id;
}
示例10: call
public function call($method, $params, $rpc_id = null, $gzip = false)
{
$api_log = kernel::single('apiactionlog_router_logging');
$rpc_id = $api_log->request_log($method, $params, $rpc_id);
if (!$rpc_id) {
$microtime = utils::microtime();
$rpc_id = str_replace('.', '', strval($microtime));
$randval = uniqid('', true);
$rpc_id .= strval($randval);
$rpc_id = md5($rpc_id);
}
$headers = array('Connection' => 'Close');
if ($gzip) {
$headers['Content-Encoding'] = 'gzip';
}
$query_params = array('app_id' => 'ecos.' . $this->app->app_id, 'method' => $method, 'date' => date('Y-m-d H:i:s'), 'callback_url' => kernel::openapi_url('openapi.rpc_callback', 'async_result_handler', array('id' => $rpc_id, 'app_id' => $this->app->app_id)), 'format' => 'json', 'certi_id' => base_certificate::certi_id(), 'v' => $this->api_version($method), 'from_node_id' => base_shopnode::node_id($this->app->app_id));
$query_params = array_merge((array) $params, $query_params);
// rpc_id 分id 和 calltime
$arr_rpc_key = explode('-', $rpc_id);
$rpc_id = $arr_rpc_key[0];
$rpc_calltime = $arr_rpc_key[1];
$query_params['task'] = $rpc_id;
if (!base_shopnode::token($this->app->app_id)) {
$query_params['sign'] = base_certificate::gen_sign($query_params);
} else {
$query_params['sign'] = base_shopnode::gen_sign($query_params, $this->app->app_id);
}
$url = $this->get_url($this->network_id);
//私有矩阵apiurl
if ("private" == app::get('system')->getConf('system.matrix.set')) {
unset($query_params['sign']);
$query_params['v'] = 'v2_0';
if ($this->network_id == 2) {
$query_params['callback_url'] = "";
}
$query_params['sign'] = kernel::single('system_shopmatrix')->get_sign($query_params, base_shopnode::node_id($this->app->app_id));
$url = kernel::single('system_shopmatrix')->get_api_url(base_shopnode::node_id($this->app->app_id));
}
$core_http = kernel::single('base_httpclient');
$response = $core_http->set_timeout($this->timeout)->post($url, $query_params, $headers);
logger::info('Response: ' . $response);
if ($response === HTTP_TIME_OUT) {
$headers = $core_http->responseHeader;
logger::info('Request timeout, process-id is ' . $headers['process-id']);
$api_log->update(array('msg_id' => $headers['process-id'], 'status' => 'fail', 'msg' => '请求超时'), $rpc_id, $rpc_calltime);
$this->status = RPC_RST_RUNNING;
return false;
} else {
$result = json_decode($response);
if ($result) {
$this->error = $response->error;
switch ($result->rsp) {
case 'running':
$this->status = RPC_RST_RUNNING;
$api_log->update(array('msg_id' => $result->msg_id, 'status' => 'running'), $rpc_id, $rpc_calltime);
// 存入中心给的process-id也就是msg-id
return true;
case 'succ':
$result = json_decode($response, true);
$api_log->update(array('msg_id' => $result['msg_id'], 'status' => 'success', 'calltime' => time()), $rpc_id, $rpc_calltime);
$this->status = RPC_RST_FINISH;
$this->rpc_response = $response;
return $result['data'];
case 'fail':
$this->error = 'Bad response';
$this->status = RPC_RST_ERROR;
$api_log->update(array('msg_id' => $result->msg_id, 'status' => 'fail', 'msg' => $result->res), $rpc_id, $rpc_calltime);
$this->rpc_response = $response;
return false;
}
} else {
//error 解码失败
}
}
}