erp/app/api/controller/merchant/MerchantController.php
2024-05-23 09:57:19 +08:00

78 lines
2.3 KiB
PHP

<?php
namespace app\api\controller\merchant;
use app\admin\validate\withdraw\MerchantWithdrawValidate;
use app\api\lists\merchant\MerchantLists;
use app\api\controller\BaseApiController;
use app\api\lists\withdraw\MerchantWithdrawLists;
use app\api\logic\merchant\MerchantLogic;
class MerchantController extends BaseApiController
{
public function lists()
{
return $this->dataLists(new MerchantLists());
}
//提现列表
public function taking_lists()
{
return $this->dataLists(new MerchantWithdrawLists());
}
//获取用户余额和绑定银行账户信息
public function amount_account()
{
$merchant = $this->request->userInfo['merchant'];
if (!$merchant) {
return $this->fail('当前用户非商户');
}
if (!$merchant->isEmpty()) {
$res=MerchantLogic::amount_account($merchant);
if(MerchantLogic::hasError()){
return $this->fail(MerchantLogic::getError());
}
return $this->success('获取成功',$res);
}
return $this->fail('获取失败');
}
//用户提现操作
public function withdraw()
{
$params = (new MerchantWithdrawValidate())->post()->goCheck('withdraw');
$merchant = $this->request->userInfo['merchant'];
if (!$merchant) {
return $this->fail('当前用户非商户');
}
if (!$merchant->isEmpty()) {
MerchantLogic::withdraw($params,$merchant);
if(MerchantLogic::hasError()){
return $this->fail(MerchantLogic::getError());
}
return $this->success('提现成功,等待管理员审核');
}
return $this->fail('提现异常');
}
/**
* 提现总次数和金额
*/
public function taking_info()
{
$merchant = $this->request->userInfo['merchant'];
if (!$merchant) {
return $this->fail('当前用户非商户');
}
if (!$merchant->isEmpty()) {
$res=MerchantLogic::taking_info($merchant);
if(MerchantLogic::hasError()){
return $this->fail(MerchantLogic::getError());
}
return $this->success('ok',$res);
}
return $this->success('ok');
}
}