feat : kitchen

This commit is contained in:
2024-11-08 16:27:25 +08:00
parent 79782dbb4e
commit c491fb79d8
15 changed files with 727 additions and 25 deletions

63
app/Model/Kitchen.php Normal file
View File

@@ -0,0 +1,63 @@
<?php
declare(strict_types=1);
namespace App\Model;
use App\Constants\Common\SiteCode;
use Hyperf\Database\Model\Builder;
use Hyperf\DbConnection\Model\Model;
/**
* @property int $id
* @property int $city_id
* @property string $name
* @property string $address
* @property string $lng
* @property string $lat
* @property int $status
* @property int $is_del
* @property string $create_time
* @property string $update_time
*/
class Kitchen extends Model
{
/**
* The table associated with the model.
*/
protected ?string $table = 'kitchen';
/**
* 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', 'city_id' => 'integer', 'status' => 'integer'];
const string CREATED_AT = 'create_time';
const string UPDATED_AT = 'update_time';
/**
* @param string $name
* @return \Hyperf\Database\Model\Model|Builder|null
*/
public function getInfoByName(string $name): \Hyperf\Database\Model\Model|Builder|null
{
return $this->where('name', $name)->where('is_del',SiteCode::KITCHEN_NO_DEL)->first();
}
/**
* @param int $id
* @return \Hyperf\Database\Model\Model|Builder|null
*/
public function getInfoById(int $id): \Hyperf\Database\Model\Model|Builder|null
{
return $this->where('id',$id)->where('is_del',SiteCode::KITCHEN_NO_DEL)->first();
}
}

65
app/Model/Site.php Normal file
View File

@@ -0,0 +1,65 @@
<?php
declare(strict_types=1);
namespace App\Model;
use App\Constants\Common\SiteCode;
use Hyperf\DbConnection\Model\Model;
/**
* @property int $id
* @property int $pid
* @property string $name
* @property int $city_id
* @property int $kitchen_id
* @property string $address
* @property string $lng
* @property string $lat
* @property string $remark
* @property string $expected_delivery_time
* @property string $distance
* @property string $expected_spend_time
* @property int $status
* @property int $image_id
* @property int $delivered_id
* @property string $create_time
* @property string $update_time
* @property int $is_del
*/
class Site extends Model
{
/**
* The table associated with the model.
*/
protected ?string $table = 'site';
/**
* 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', 'pid' => 'integer', 'city_id' => 'integer', 'kitchen_id' => 'integer', 'status' => 'integer', 'image_id' => 'integer', 'delivered_id' => 'integer', 'is_del' => 'integer'];
const string CREATED_AT = 'create_time';
const string UPDATED_AT = 'update_time';
/**
* 禁用厨房下所有点
* @param int $kitchenId
* @return int
*/
public function disableStatusByKitchenId(int $kitchenId)
{
return $this
->where('kitchen_id',$kitchenId)
->where('is_del',SiteCode::SITE_NO_DEL)
->update(['status' => SiteCode::SITE_DISABLE]);
}
}

View File

@@ -58,4 +58,13 @@ class SystemCity extends Model
{
return $this->where('id', $id)->where('is_del',CityCode::IS_NOT_DELETE)->first();
}
/**
* @param $ids
* @return array
*/
public function getCityNameByIds($ids): array
{
return $this->whereIn('id',$ids)->pluck('title','id')->toArray();
}
}