feat: spu

This commit is contained in:
2025-01-22 11:04:12 +08:00
parent 2beb8d9e55
commit 9b7390129d
10 changed files with 426 additions and 10 deletions

View File

@@ -51,4 +51,13 @@ class Cycle extends Model
{
return $this->where('id',$id)->first();
}
/**
* @param string $date
* @return int
*/
public function getIdByDate(string $date): int
{
return $this->where('dates',$date)->value('id') ?? 0;
}
}

View File

@@ -6,6 +6,7 @@ namespace App\Model;
use App\Constants\Common\GoodCode;
use Hyperf\Database\Model\Builder;
use Hyperf\Database\Model\Collection;
use Hyperf\DbConnection\Model\Model;
/**
@@ -18,6 +19,8 @@ use Hyperf\DbConnection\Model\Model;
* @property string $sub_title
* @property int $category_id
* @property int $saleable
* @property int $type
* @property int $sort
* @property int $is_del
* @property string $create_time
* @property string $update_time
@@ -39,7 +42,7 @@ class Spu extends Model
/**
* The attributes that should be cast to native types.
*/
protected array $casts = ['id' => 'integer', 'cycle_id' => 'integer', 'city_id' => 'integer', 'kitchen_id' => 'integer','chef_id' => 'integer', 'category_id' => 'integer', 'saleable' => 'integer'];
protected array $casts = ['id' => 'integer', 'cycle_id' => 'integer', 'city_id' => 'integer', 'kitchen_id' => 'integer','chef_id' => 'integer', 'category_id' => 'integer', 'saleable' => 'integer','type' => 'integer','sort' => 'integer'];
const string CREATED_AT = 'create_time';
const string UPDATED_AT = 'update_time';
@@ -63,4 +66,21 @@ class Spu extends Model
{
return $this->where('id', $id)->where('is_del',GoodCode::SPU_IS_NO_DEL)->first();
}
/**
* @param int $cycleId
* @param int $kitchenId
* @param int $type
* @return Builder[]|Collection
*/
public function getListByCycleIdAndType(int $cycleId, int $kitchenId, int $type): Collection|array
{
return $this
->where('cycle_id',$cycleId)
->where('kitchen_id',$kitchenId)
->where('is_del',GoodCode::SPU_IS_NO_DEL)
->where('type',$type)
->orderBy('sort')
->get();
}
}