TransmitService.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace addons\TinyShop\services\common;
  3. use common\components\Service;
  4. use addons\TinyShop\common\models\common\Transmit;
  5. /**
  6. * Class TransmitService
  7. * @package addons\TinyShop\services\common
  8. * @author jianyan74 <751393839@qq.com>
  9. */
  10. class TransmitService extends Service
  11. {
  12. /**
  13. * @param $topic_id
  14. * @param $topic_type
  15. * @param $member_id
  16. * @return Transmit|array|\yii\db\ActiveRecord|null
  17. */
  18. public function findByTopicId($topic_id, $topic_type, $member_id)
  19. {
  20. $model = Transmit::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 Transmit();
  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 Transmit::find()
  40. ->where(['id' => $id, 'member_id' => $member_id])
  41. ->andFilterWhere(['merchant_id' => $this->getMerchantId()])
  42. ->one();
  43. }
  44. }
粤ICP备19079148号