AdvService.php 731 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. namespace addons\TinyBlog\services;
  3. use addons\TinyBlog\common\models\Adv;
  4. use common\components\Service;
  5. use common\enums\StatusEnum;
  6. /**
  7. * Class AdvService
  8. * @package addons\TinyBlog\services
  9. * @author jianyan74 <751393839@qq.com>
  10. */
  11. class AdvService extends Service
  12. {
  13. /**
  14. * @return array|\yii\db\ActiveRecord[]
  15. */
  16. public function newest()
  17. {
  18. return Adv::find()
  19. ->where(['status' => StatusEnum::ENABLED])
  20. ->andWhere(['<', 'start_time', time()])
  21. ->andWhere(['>', 'end_time', time()])
  22. ->andFilterWhere(['merchant_id' => $this->getMerchantId()])
  23. ->orderBy('sort asc, id desc')
  24. ->asArray()
  25. ->one();
  26. }
  27. }
粤ICP备19079148号