mirror of
https://gitee.com/technical-laohu/mpay_v2_webman.git
synced 2026-05-09 18:34:26 +08:00
1. 维护代码健壮
2. 更新项目结构文档
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace app\repository\payment\trade;
|
||||
|
||||
use app\common\base\BaseRepository;
|
||||
use app\common\constant\TradeConstant;
|
||||
use app\model\payment\PayOrder;
|
||||
|
||||
/**
|
||||
@@ -159,6 +160,47 @@ class PayOrderRepository extends BaseRepository
|
||||
->first($columns);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询已过期但还未进入终态的支付单。
|
||||
*
|
||||
* @param string $now 当前时间
|
||||
* @param int $limit 限制条数
|
||||
* @return \Illuminate\Database\Eloquent\Collection<int, PayOrder> 支付单列表
|
||||
*/
|
||||
public function listExpiredMutable(string $now, int $limit = 100)
|
||||
{
|
||||
return $this->model->newQuery()
|
||||
->whereIn('status', TradeConstant::orderMutableStatuses())
|
||||
->whereNotNull('expire_at')
|
||||
->where('expire_at', '<=', $now)
|
||||
->orderBy('expire_at')
|
||||
->orderBy('id')
|
||||
->limit(max(1, $limit))
|
||||
->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询需要主动查单的支付中订单。
|
||||
*
|
||||
* @param string $before 最早拉起时间
|
||||
* @param int $limit 限制条数
|
||||
* @return \Illuminate\Database\Eloquent\Collection<int, PayOrder> 支付单列表
|
||||
*/
|
||||
public function listPayingForActiveQuery(string $before, int $limit = 50)
|
||||
{
|
||||
return $this->model->newQuery()
|
||||
->where('status', TradeConstant::ORDER_STATUS_PAYING)
|
||||
->where('request_at', '<=', $before)
|
||||
->where(function ($query) {
|
||||
$query->whereNull('expire_at')
|
||||
->orWhere('expire_at', '>', date('Y-m-d H:i:s'));
|
||||
})
|
||||
->orderBy('request_at')
|
||||
->orderBy('id')
|
||||
->limit(max(1, $limit))
|
||||
->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询商户最近支付单列表,用于总览展示。
|
||||
*
|
||||
@@ -189,4 +231,3 @@ class PayOrderRepository extends BaseRepository
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -107,6 +107,7 @@ class RefundOrderRepository extends BaseRepository
|
||||
{
|
||||
return $this->model->newQuery()
|
||||
->where('pay_no', $payNo)
|
||||
->orderByDesc('id')
|
||||
->first($columns);
|
||||
}
|
||||
|
||||
@@ -151,6 +152,7 @@ class RefundOrderRepository extends BaseRepository
|
||||
{
|
||||
return $this->model->newQuery()
|
||||
->where('pay_no', $payNo)
|
||||
->orderByDesc('id')
|
||||
->lockForUpdate()
|
||||
->first($columns);
|
||||
}
|
||||
@@ -171,5 +173,3 @@ class RefundOrderRepository extends BaseRepository
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
50
app/repository/payment/trade/TransferOrderRepository.php
Normal file
50
app/repository/payment/trade/TransferOrderRepository.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace app\repository\payment\trade;
|
||||
|
||||
use app\common\base\BaseRepository;
|
||||
use app\model\payment\TransferOrder;
|
||||
|
||||
/**
|
||||
* 转账单仓库。
|
||||
*/
|
||||
class TransferOrderRepository extends BaseRepository
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(new TransferOrder());
|
||||
}
|
||||
|
||||
public function findByBizNo(string $bizNo, array $columns = ['*'])
|
||||
{
|
||||
return $this->model->newQuery()
|
||||
->where('biz_no', $bizNo)
|
||||
->first($columns);
|
||||
}
|
||||
|
||||
public function findByOutBizNo(int $merchantId, string $outBizNo, array $columns = ['*'])
|
||||
{
|
||||
return $this->model->newQuery()
|
||||
->where('merchant_id', $merchantId)
|
||||
->where('out_biz_no', $outBizNo)
|
||||
->first($columns);
|
||||
}
|
||||
|
||||
public function findForUpdateByBizNo(string $bizNo, array $columns = ['*'])
|
||||
{
|
||||
return $this->model->newQuery()
|
||||
->where('biz_no', $bizNo)
|
||||
->lockForUpdate()
|
||||
->first($columns);
|
||||
}
|
||||
|
||||
public function findForUpdateByOutBizNo(int $merchantId, string $outBizNo, array $columns = ['*'])
|
||||
{
|
||||
return $this->model->newQuery()
|
||||
->where('merchant_id', $merchantId)
|
||||
->where('out_biz_no', $outBizNo)
|
||||
->lockForUpdate()
|
||||
->first($columns);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user