列:sn=CS201911-0002
$sn = $this->visitinSn("CS"); //生成单据编号
/**
* Notes:生成单据公共接口
* Created by xxg@seabig.cn
* Date: 2019/11/7
* Time: 15:18
*/
public function visitinSn($key)
{
$this->_globals();
//初始化
$sn = "";
$zero = "";
//获取所有单据编号
$reports = $this->mBasic->getList("crm_visitin", array("is_del=0", "sn like '" . $key . date("Ym") . "-%'"), false);
if ($reports) {
foreach ($reports as $v) {
//初始化
$reportSn = "";
$reportSn = substr(strstr($v['sn'], '-'), strlen('-')); //截取
if ($reportSn > $sn) {
$sn = $reportSn;
}
}
} else {
$sn = 0;
}
$sn += 1;
for ($i = 0; $i < (4 - strlen($sn)); $i++) {
$zero .= "0";
}
$sn = $key . date("Ym") . '-' . $zero . $sn;
print_r($sn);die;
return $sn;
}
获取单据编号 不重复 骚
最新推荐文章于 2024-01-20 11:28:37 发布