Merge branch 'dev'

This commit is contained in:
2026-01-14 11:25:01 +08:00
+4
View File
@@ -10,6 +10,7 @@ use support\exception\BusinessException;
use support\Log;
use support\Request;
use app\common\model\User;
use support\Redis;
class UsedCarService
{
@@ -106,10 +107,13 @@ class UsedCarService
}
public function getcode($userId){
$userCount = Redis::get('used_car_count_'.$userId, 0);
$todayStart = strtotime('today');
$count = UsedCar::where('user_id',$userId)->where('created_at','>=',$todayStart)->count();
$count = $count<$userCount ? $userCount +1 : $count +1;
$countCode = str_pad($count, 3, '0', STR_PAD_LEFT);
$userCode = str_pad($userId, 3, '0', STR_PAD_LEFT);
Redis::set('used_car_count_'.$userId, $count, 86400);
$user = User::where('id',$userId)->first();
$nameInitials = $this->getNameInitials($user['name']);
return $nameInitials . $userCode . date('Ymd') . $countCode;