/** * 生成唯一订单号 */ public function build_order_no() { $no = date('Ymd').substr(implode(NULL, array_map('ord', str_split(substr(uniqid(), 7, 13), 1))), 0, 8); //检测是否存在 $db = M('Order'); $info = $db->where(array('number'=>$no))->find(); (!empty($info)) && $no = $this->build_order_no(); return $no; }