mirror of
https://gitee.com/technical-laohu/mpay_v2_webman.git
synced 2026-04-26 20:14:26 +08:00
重构初始化
This commit is contained in:
47
app/repository/merchant/base/MerchantGroupRepository.php
Normal file
47
app/repository/merchant/base/MerchantGroupRepository.php
Normal 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();
|
||||
}
|
||||
}
|
||||
|
||||
32
app/repository/merchant/base/MerchantPolicyRepository.php
Normal file
32
app/repository/merchant/base/MerchantPolicyRepository.php
Normal 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
43
app/repository/merchant/base/MerchantRepository.php
Normal file
43
app/repository/merchant/base/MerchantRepository.php
Normal 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user