You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

WorkGroupMsgSendResultGroupChatDao.php 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace app\dao\work;
  3. use app\dao\BaseDao;
  4. use app\model\wechat\WechatUser;
  5. use app\model\work\WorkGroupChat;
  6. use app\model\work\WorkGroupMsgSendResult;
  7. class WorkGroupMsgSendResultGroupChatDao extends BaseDao
  8. {
  9. protected function setModel(): string
  10. {
  11. return WorkGroupMsgSendResult::class;
  12. }
  13. protected function setJoinModel(): string
  14. {
  15. return WorkGroupChat::class;
  16. }
  17. /**
  18. * @param string $alias
  19. * @param string $joinAlias
  20. * @param string $join
  21. */
  22. protected function getModel(string $alias = 'm', string $joinAlias = 'g', string $join = 'left')
  23. {
  24. /** @var WechatUser $wechcatUser */
  25. $wechcatUser = app()->make($this->setJoinModel());
  26. $table = $wechcatUser->getName();
  27. return parent::getModel()->alias($alias)->join($table . ' ' . $joinAlias, $alias . '.chat_id = ' . $joinAlias . '.chat_id', $join);
  28. }
  29. /**
  30. * @param array $where
  31. */
  32. public function groupChat(array $where)
  33. {
  34. return $this->getModel()->when(!empty($where['chat_id']), function ($query) use ($where) {
  35. $query->whereIn('m.chat_id', $where['chat_id']);
  36. })->when(isset($where['status']) && $where['status'] !== '', function ($query) use ($where) {
  37. $query->where('m.status', $where['status']);
  38. })->field(['m.*', 'g.name', 'g.member_num']);
  39. }
  40. }