- 按 docs/renew-code-comment.md 将 PHP 文件头改为带边框的 Author 注释\n- 注释中的 crmeb.com 替换为 uj345.cn(代码字符串中的外链未改)\n- 新增 docs/renew-code-comment.md 说明 Made-with: Cursor
55 lines
1.6 KiB
PHP
55 lines
1.6 KiB
PHP
<?php
|
|
// +----------------------------------------------------------------------
|
|
// | Author: ScottPan Team
|
|
// +----------------------------------------------------------------------
|
|
|
|
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;
|
|
}
|
|
|
|
/**
|
|
* @param string $alias
|
|
* @param string $joinAlias
|
|
* @param string $join
|
|
* @return \crmeb\basic\BaseModel
|
|
*/
|
|
protected function getModel(string $alias = 'm', string $joinAlias = 'g', string $join = 'left')
|
|
{
|
|
/** @var WechatUser $wechcatUser */
|
|
$wechcatUser = app()->make($this->setJoinModel());
|
|
$table = $wechcatUser->getName();
|
|
return parent::getModel()->alias($alias)->join($table . ' ' . $joinAlias, $alias . '.chat_id = ' . $joinAlias . '.chat_id', $join);
|
|
}
|
|
|
|
/**
|
|
* @param array $where
|
|
* @return \crmeb\basic\BaseModel
|
|
*/
|
|
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']);
|
|
}
|
|
|
|
}
|