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:
52
app/repository/account/balance/MerchantAccountRepository.php
Normal file
52
app/repository/account/balance/MerchantAccountRepository.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace app\repository\account\balance;
|
||||
|
||||
use app\common\base\BaseRepository;
|
||||
use app\model\merchant\MerchantAccount;
|
||||
|
||||
/**
|
||||
* 商户余额账户仓库。
|
||||
*/
|
||||
class MerchantAccountRepository extends BaseRepository
|
||||
{
|
||||
/**
|
||||
* 构造函数,注入对应模型。
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(new MerchantAccount());
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据商户 ID 查询余额账户。
|
||||
*/
|
||||
public function findByMerchantId(int $merchantId, array $columns = ['*'])
|
||||
{
|
||||
return $this->model->newQuery()
|
||||
->where('merchant_id', $merchantId)
|
||||
->first($columns);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据商户 ID 加锁查询余额账户。
|
||||
*/
|
||||
public function findForUpdateByMerchantId(int $merchantId, array $columns = ['*'])
|
||||
{
|
||||
return $this->model->newQuery()
|
||||
->where('merchant_id', $merchantId)
|
||||
->lockForUpdate()
|
||||
->first($columns);
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计商户是否存在资金账户。
|
||||
*/
|
||||
public function countByMerchantId(int $merchantId): int
|
||||
{
|
||||
return (int) $this->model->newQuery()
|
||||
->where('merchant_id', $merchantId)
|
||||
->count();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
namespace app\repository\account\ledger;
|
||||
|
||||
use app\common\base\BaseRepository;
|
||||
use app\model\merchant\MerchantAccountLedger;
|
||||
|
||||
/**
|
||||
* 商户余额流水仓库。
|
||||
*/
|
||||
class MerchantAccountLedgerRepository extends BaseRepository
|
||||
{
|
||||
/**
|
||||
* 构造函数,注入对应模型。
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(new MerchantAccountLedger());
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据幂等键查询流水记录。
|
||||
*/
|
||||
public function findByIdempotencyKey(string $idempotencyKey, array $columns = ['*'])
|
||||
{
|
||||
return $this->model->newQuery()
|
||||
->where('idempotency_key', $idempotencyKey)
|
||||
->first($columns);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据追踪号查询流水记录。
|
||||
*/
|
||||
public function findByTraceNo(string $traceNo, array $columns = ['*'])
|
||||
{
|
||||
return $this->model->newQuery()
|
||||
->where('trace_no', $traceNo)
|
||||
->orderByDesc('id')
|
||||
->first($columns);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询指定追踪号的流水列表。
|
||||
*/
|
||||
public function listByTraceNo(string $traceNo, array $columns = ['*'])
|
||||
{
|
||||
return $this->model->newQuery()
|
||||
->where('trace_no', $traceNo)
|
||||
->orderByDesc('id')
|
||||
->get($columns);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询商户指定业务类型和业务单号的流水列表。
|
||||
*/
|
||||
/**
|
||||
* 查询指定业务单号的流水列表。
|
||||
*/
|
||||
public function listByBizNo(string $bizNo, array $columns = ['*'])
|
||||
{
|
||||
return $this->model->newQuery()
|
||||
->where('biz_no', $bizNo)
|
||||
->orderByDesc('id')
|
||||
->get($columns);
|
||||
}
|
||||
|
||||
public function listByMerchantAndBiz(int $merchantId, int $bizType, string $bizNo, array $columns = ['*'])
|
||||
{
|
||||
return $this->model->newQuery()
|
||||
->where('merchant_id', $merchantId)
|
||||
->where('biz_type', $bizType)
|
||||
->where('biz_no', $bizNo)
|
||||
->orderByDesc('id')
|
||||
->get($columns);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user