feat: spu
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user