生成唯一流水号:/**
* [contractNo 获取合同编号]
* Author Yangjun
* DateTime 2017-07-31
* @param [type] $c_id [合同id]
* @param [type] $b_apply_time [合同申请时间]
* @return [type] [description]
*/
protected function contractNo($c_id,$b_apply_time){
$yDate = array("A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z");
$y = date(Y,strtotime($b_apply_time))-2017;
return $yDate[$y].date("md",strtotime($b_apply_time)).floor($c_id/9999).str_pad($c_id%9999,5,0,STR_PAD_LEFT);
}
/**
* [contractNo 根据合同编号获取合同id]
* Author Yangjun
* DateTime 2017-07-31
* @param [type] $contractNo [合同编号]
* @return [type] [description]
*/
protected function contractNoToId($contractNo){
$n = substr($contractNo, 5,-5);
$d = substr($contractNo,-5);
return 9999*$n + (int)$d;
}
结果:$this->contractNo("12312","2017-07-31"); //A0731102313
$this->contractNoToId("A0731102313"); //12312关于 cooljun
do your good at,challenge what do you want to do
如果你觉得这篇文章对你有帮助,请支持我继续更新网站 !捐赠本站
喜欢 (0)or分享 (0)