以下是我在做电商系统用的订单号生成函数 ::/** * 订单序列生成 16位 * $type支付/提取类型 * $usertype用户类型 * $oid 订单自增长 */public function getOrderNo($type,$usertype,$oid){ $password = array(0 => array(0, 5, 1, 2, 6, 4, 3, 8, 9, 7), 1 => array(9, 8, 7, 6, 5, 4, 3, 2, 1, 0), 2 => array(4, 3, 2, 1, 0, 5, 6, 7, 8, 9), 3 => array(5, 6, 7, 8, 9, 0, 1, 2, 3, 4), 4 => array(9, 0, 8, 1, 7, 3, 6, 4, 5, 2), 5 => array(7, 2, 6, 4, 5, 1, 8, 0, 9, 3), 6 => array(6, 7, 8, 9, 5, 4, 3, 2, 1, 0), 7 => array(5, 9, 7, 8, 3, 4, 2, 6, 1, 0), ); $ret = date(‘ymd‘) . $type . $usertype; $oid = str_pad($oid, 8, "0", STR_PAD_LEFT); for ($i = 0; $i < 8; $i++) { $oid[$i] = $password[$i][$oid[$i]]; } $ret .= $oid; return $ret; }
时间: 2024-10-10 21:36:07