NiceService.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace addons\TinyShop\services\common;
  3. use common\components\Service;
  4. use addons\TinyShop\common\models\common\Nice;
  5. /**
  6. * Class NiceService
  7. * @package addons\TinyShop\services\common
  8. * @author jianyan74 <751393839@qq.com>
  9. */
  10. class NiceService extends Service
  11. {
  12. /**
  13. * @param $topic_id
  14. * @param $topic_type
  15. * @param $member_id
  16. * @return Nice|array|\yii\db\ActiveRecord|null
  17. */
  18. public function findByTopicId($topic_id, $topic_type, $member_id)
  19. {
  20. $model = Nice::find()
  21. ->where([
  22. 'topic_id' => $topic_id,
  23. 'topic_type' => $topic_type,
  24. 'member_id' => $member_id,
  25. ])
  26. ->andFilterWhere(['merchant_id' => $this->getMerchantId()])
  27. ->one();
  28. if (!$model) {
  29. $model = new Nice();
  30. }
  31. return $model;
  32. }
  33. /**
  34. * @param $id
  35. * @return array|\yii\db\ActiveRecord|null
  36. */
  37. public function findById($id, $member_id)
  38. {
  39. return Nice::find()
  40. ->where(['id' => $id, 'member_id' => $member_id])
  41. ->andFilterWhere(['merchant_id' => $this->getMerchantId()])
  42. ->one();
  43. }
  44. }
粤ICP备19079148号