feat : driver

This commit is contained in:
2024-11-13 17:08:31 +08:00
parent 1077cdfcd8
commit 0b0fc8a1ef
7 changed files with 297 additions and 4 deletions

View File

@@ -22,6 +22,7 @@ use Hyperf\DbConnection\Model\Model;
* @property int $is_del
* @property int $role_id
* @property int $section_id
* @property int $city_id
* @property string $create_time
* @property string $update_time
*/

View File

@@ -0,0 +1,49 @@
<?php
declare(strict_types=1);
namespace App\Model;
use Hyperf\Database\Model\Builder;
use Hyperf\DbConnection\Model\Model;
/**
* @property int $id
* @property int $driver_id
* @property int $driver_num
* @property int $sequence
* @property string $create_time
* @property string $update_time
*/
class DriverSequence extends Model
{
/**
* The table associated with the model.
*/
protected ?string $table = 'driver_sequence';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = [];
protected array $guarded = [];
/**
* The attributes that should be cast to native types.
*/
protected array $casts = ['id' => 'integer', 'driver_id' => 'integer', 'driver_num' => 'integer', 'sequence' => 'integer'];
const string CREATED_AT = 'create_time';
const string UPDATED_AT = 'update_time';
/**
* @param int $driverId
* @return Builder|\Hyperf\Database\Model\Model|null
*/
public function getInfoByDriverId(int $driverId): \Hyperf\Database\Model\Model|Builder|null
{
return $this->where('driver_id', $driverId)->first();
}
}

View File

@@ -6,6 +6,7 @@ namespace App\Model;
use App\Constants\Common\SiteCode;
use Hyperf\Database\Model\Builder;
use Hyperf\Database\Model\Collection;
use Hyperf\DbConnection\Model\Model;
/**
@@ -23,7 +24,8 @@ use Hyperf\DbConnection\Model\Model;
* @property string $expected_spend_time
* @property int $status
* @property int $image_id
* @property int $delivered_id
* @property int $delivered_id
* @property int $sequence
* @property string $create_time
* @property string $update_time
* @property int $is_del
@@ -81,4 +83,17 @@ class Site extends Model
{
return $this->where('id',$id)->where('is_del',SiteCode::SITE_NO_DEL)->first();
}
/**
* @param int $driverId
* @return Collection|array
*/
public function getSiteSequenceListByDriver(int $driverId): Collection|array
{
return $this
->where('is_del',SiteCode::SITE_NO_DEL)
->where('status',SiteCode::SITE_ENABLE)
->where('delivered_id',$driverId)
->get(['id','name', 'sequence']);
}
}