123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <?php
- namespace app\dao\work;
- use app\dao\BaseDao;
- use app\model\wechat\WechatUser;
- use app\model\work\WorkGroupChat;
- use app\model\work\WorkGroupMsgSendResult;
- class WorkGroupMsgSendResultGroupChatDao extends BaseDao
- {
- protected function setModel(): string
- {
- return WorkGroupMsgSendResult::class;
- }
- protected function setJoinModel(): string
- {
- return WorkGroupChat::class;
- }
-
- protected function getModel(string $alias = 'm', string $joinAlias = 'g', string $join = 'left')
- {
-
- $wechcatUser = app()->make($this->setJoinModel());
- $table = $wechcatUser->getName();
- return parent::getModel()->alias($alias)->join($table . ' ' . $joinAlias, $alias . '.chat_id = ' . $joinAlias . '.chat_id', $join);
- }
-
- public function groupChat(array $where)
- {
- return $this->getModel()->when(!empty($where['chat_id']), function ($query) use ($where) {
- $query->whereIn('m.chat_id', $where['chat_id']);
- })->when(isset($where['status']) && $where['status'] !== '', function ($query) use ($where) {
- $query->where('m.status', $where['status']);
- })->field(['m.*', 'g.name', 'g.member_num']);
- }
- }
|