重构初始化

This commit is contained in:
技术老胡
2026-04-15 11:45:46 +08:00
parent 72d72d735b
commit 7612026773
381 changed files with 28287 additions and 14717 deletions

View File

@@ -0,0 +1,47 @@
<?php
namespace app\repository\merchant\base;
use app\common\base\BaseRepository;
use app\model\merchant\MerchantGroup;
/**
* 商户分组仓库。
*/
class MerchantGroupRepository extends BaseRepository
{
/**
* 构造函数,注入对应模型。
*/
public function __construct()
{
parent::__construct(new MerchantGroup());
}
/**
* 获取所有启用的商户分组。
*/
public function enabledList(array $columns = ['*'])
{
return $this->model->newQuery()
->where('status', 1)
->orderBy('id', 'asc')
->get($columns);
}
/**
* 判断分组名称是否已存在。
*/
public function existsByGroupName(string $groupName, int $ignoreId = 0): bool
{
$query = $this->model->newQuery()
->where('group_name', $groupName);
if ($ignoreId > 0) {
$query->where('id', '<>', $ignoreId);
}
return $query->exists();
}
}

View File

@@ -0,0 +1,32 @@
<?php
namespace app\repository\merchant\base;
use app\common\base\BaseRepository;
use app\model\merchant\MerchantPolicy;
/**
* 商户策略仓库。
*/
class MerchantPolicyRepository extends BaseRepository
{
/**
* 构造函数,注入对应模型。
*/
public function __construct()
{
parent::__construct(new MerchantPolicy());
}
/**
* 根据商户 ID 查询商户策略。
*/
public function findByMerchantId(int $merchantId, array $columns = ['*'])
{
return $this->model->newQuery()
->where('merchant_id', $merchantId)
->first($columns);
}
}

View File

@@ -0,0 +1,43 @@
<?php
namespace app\repository\merchant\base;
use app\common\base\BaseRepository;
use app\model\merchant\Merchant;
/**
* 商户仓库。
*/
class MerchantRepository extends BaseRepository
{
/**
* 构造函数,注入对应模型。
*/
public function __construct()
{
parent::__construct(new Merchant());
}
/**
* 根据商户编号查询商户。
*/
public function findByMerchantNo(string $merchantNo, array $columns = ['*']): ?Merchant
{
return $this->model->newQuery()
->where('merchant_no', $merchantNo)
->first($columns);
}
/**
* 获取所有启用的商户。
*/
public function enabledList(array $columns = ['*'])
{
return $this->model->newQuery()
->where('status', 1)
->orderBy('id', 'desc')
->get($columns);
}
}