高并发情况下如何生成唯一订单号是每个程序员都要思考的问题,下面给出我的解决思路,代码如图:
public function build_order_num($user_id = 1){
$date_str = date('YmdHis',time());
$rev_time = strrev(time());
$str = $date_str.$user_id.mt_rand(1000,9999).$rev_time;
$order_str = substr($str,0,25);
return $order_str;
}
}