new-admin-api/app/common/dao/store/broadcast/BroadcastAssistantDao.php

39 lines
1010 B
PHP

<?php
namespace app\common\dao\store\broadcast;
use app\common\dao\BaseDao;
use app\common\model\store\broadcast\BroadcastAssistant;
use think\exception\ValidateException;
class BroadcastAssistantDao extends BaseDao
{
protected function getModel(): string
{
return BroadcastAssistant::class;
}
public function merExists(int $id, int $merId)
{
return $this->existsWhere([$this->getPk() => $id, 'is_del' => 0, 'mer_id' => $merId]);
}
public function intersection(?string $ids, int $merId)
{
if (!$ids) return [0];
return $this->getModel()::getDb()->whereIn('assistant_id',$ids)->where('mer_id', $merId)->column('assistant_id');
}
public function existsAll($ids, $merId)
{
foreach ($ids as $id) {
$has = $this->getModel()::getDb()->where('assistant_id',$id)->where('mer_id',$merId)->count();
if (!$has) throw new ValidateException('ID:'.$id.' 不存在');
}
return true;
}
}