This commit is contained in:
邓皓元 2019-06-06 14:05:12 +08:00
parent 578ff82c3e
commit 163e3d2130
2 changed files with 4 additions and 2 deletions

View File

@ -14,7 +14,6 @@ class CommonService
public static function stringifyCompanyId($companyId)
{
return sprintf('No%011d', $companyId);
return intval(str_replace('No', '', $companyId));
}
/**

View File

@ -77,7 +77,10 @@ class CompanyService extends Service
if (!$attributes['id']) {
$maxId = Company::withTrashed()->max('id');
$attributes['id'] = $maxId ? $maxId + 1 : 1;
$attributes['sn'] = CommonService::stringifyCompanyId($attributes['id']);
$maxSn = Company::withTrashed()->max('sn');
$maxSn = intval(str_replace('No', '', $maxSn));
$attributes['sn'] = CommonService::stringifyCompanyId($maxSn);
$node = $this->companyRepository->create($attributes);
}