'integer', 'cycle_id' => 'integer', 'city_id' => 'integer', 'kitchen_id' => 'integer','chef_id' => 'integer','caterer_id' => 'integer','category_id' => 'integer', 'saleable' => 'integer','type' => 'integer','sort' => 'integer']; const string CREATED_AT = 'create_time'; const string UPDATED_AT = 'update_time'; /** * @param int $cityId * @param int $cycleId * @param string $title * @return Builder|\Hyperf\Database\Model\Model|null */ public function getInfoByCityIdAndCycleId(int $cityId, int $cycleId,string $title): \Hyperf\Database\Model\Model|Builder|null { return $this->where('city_id', $cityId)->where('cycle_id', $cycleId)->where('title',$title)->where('is_del',GoodCode::SPU_IS_NO_DEL)->first(); } /** * @param int $id * @return Builder|\Hyperf\Database\Model\Model|null */ public function getInfoById(int $id): \Hyperf\Database\Model\Model|Builder|null { 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|null */ public function getListByCycleIdAndType(int $cycleId, int $kitchenId, int $type): Collection|array|null { return $this ->where('cycle_id',$cycleId) ->where('kitchen_id',$kitchenId) ->where('is_del',GoodCode::SPU_IS_NO_DEL) ->where('type',$type) ->where('saleable',GoodCode::LISTING) ->orderBy('sort') ->select(['id','cycle_id','chef_id','title','title','sub_title','category_id']) ->get(); } /** * @param array $ids * @return array */ public function getDataArrByIds(array $ids): array { $res = $this ->whereIn('id',$ids) ->orderBy('sort') ->get(); if ($res->isEmpty()) return []; return $res->toArray(); } /** * @param int $cycle_id * @return array */ public function getCycleIdAddStapleFoodSkuIds(int $cycle_id): array { return $this ->leftJoin('sku','sku.spu_id','=','spu.id') ->where('spu.cycle_id',$cycle_id) ->where('spu.category_id',CategoryCode::EXTRA_STAPLE)->pluck('sku.id') ->toArray(); } }