mirror of
https://gitee.com/technical-laohu/mpay_v2_webman.git
synced 2026-04-24 11:04:26 +08:00
重构初始化
This commit is contained in:
47
app/http/mer/controller/account/AccountController.php
Normal file
47
app/http/mer/controller/account/AccountController.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace app\http\mer\controller\account;
|
||||
|
||||
use app\common\base\BaseController;
|
||||
use app\http\mer\validation\BalanceValidator;
|
||||
use app\service\account\funds\MerchantAccountService;
|
||||
use app\service\merchant\MerchantService;
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
|
||||
/**
|
||||
* 商户账户控制器。
|
||||
*
|
||||
* 负责商户余额查询等账户类接口。
|
||||
*/
|
||||
class AccountController extends BaseController
|
||||
{
|
||||
/**
|
||||
* 构造函数,注入商户与账户服务。
|
||||
*/
|
||||
public function __construct(
|
||||
protected MerchantService $merchantService,
|
||||
protected MerchantAccountService $merchantAccountService
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* GET /mer/merchant/{merchantNo}/balance
|
||||
*
|
||||
* 查询商户余额。
|
||||
*/
|
||||
public function balance(Request $request, string $merchantNo): Response
|
||||
{
|
||||
$data = $this->validated(['merchant_no' => $merchantNo], BalanceValidator::class, 'show');
|
||||
|
||||
$currentMerchantNo = $this->currentMerchantNo($request);
|
||||
if ($currentMerchantNo !== '' && $currentMerchantNo !== (string) $data['merchant_no']) {
|
||||
return $this->fail('无权查看该商户余额', 403);
|
||||
}
|
||||
|
||||
$merchant = $this->merchantService->findEnabledMerchantByNo((string) $data['merchant_no']);
|
||||
|
||||
return $this->success($this->merchantAccountService->getBalanceSnapshot((int) $merchant->id));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user