Showing
1 changed file
with
13 additions
and
2 deletions
... | @@ -45,8 +45,19 @@ class Order extends Model | ... | @@ -45,8 +45,19 @@ class Order extends Model |
45 | */ | 45 | */ |
46 | static public function get_sn($prefix = '') | 46 | static public function get_sn($prefix = '') |
47 | { | 47 | { |
48 | - $Sn = $prefix . strtoupper(dechex(date('m'))) . date('d') . substr(time(), -5) . substr(microtime(), 2, 5) . sprintf('%02d', rand(0, 99)); | 48 | + $chars = md5(uniqid(mt_rand(), true)); |
49 | - return $Sn; | 49 | + |
50 | + $len = strlen($prefix); | ||
51 | + | ||
52 | + if ($len > 5) $prefix = substr($prefix, 0, 5); | ||
53 | + | ||
54 | + $uuid = $prefix . dechex(date('m')) . date('d') . substr(time(), -5 + $len) . '-' | ||
55 | + . substr(microtime(), 2, 4) . '-' | ||
56 | + . substr($chars, 12, 4) . '-' | ||
57 | + . substr($chars, 16, 4) . '-' | ||
58 | + . substr($chars, 20, 12); | ||
59 | + | ||
60 | + return strtoupper($uuid); | ||
50 | } | 61 | } |
51 | 62 | ||
52 | } | 63 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or login to post a comment