glhcp/server/app/shop/controller/finance/Withdrawal.php

96 lines
2.6 KiB
PHP

<?php
namespace app\shop\controller\finance;
use app\common\basics\ShopBase;
use app\common\model\shop\Shop;
use app\common\server\ConfigServer;
use app\common\server\JsonServer;
use app\shop\logic\BankLogic;
use app\shop\logic\finance\WithdrawalLogic;
use think\facade\View;
class Withdrawal extends ShopBase
{
/**
* @Notes: 提现列表
* @Author: 张无忌
*/
public function lists()
{
if ($this->request->isAjax()) {
$get = $this->request->get();
$lists = WithdrawalLogic::lists($get, $this->shop_id);
return JsonServer::success('获取成功', $lists);
}
View::assign('statistics', WithdrawalLogic::statistics($this->shop_id));
View::assign('summary', WithdrawalLogic::summary($this->shop_id));
return view();
}
/**
* @Notes: 选项卡数据统计
* @Author: 张无忌
*/
public function statistics()
{
if ($this->request->isAjax()) {
$statistics = WithdrawalLogic::statistics($this->shop_id);
return JsonServer::success('获取成功', $statistics);
}
return JsonServer::error('异常');
}
/**
* @Notes: 申请提现
* @Author: 张无忌
*/
public function add()
{
if ($this->request->isAjax()) {
$post = $this->request->post();
$res = WithdrawalLogic::add($post, $this->shop_id);
if ($res === false) {
$error = BankLogic::getError() ?: '申请失败';
return JsonServer::error($error);
}
return JsonServer::success('申请成功');
}
View::assign('withdrawal_service_charge', ConfigServer::get('shop_withdrawal', 'withdrawal_service_charge', 0));
View::assign('shop', (new Shop())->findOrEmpty($this->shop_id)->toArray());
View::assign('bank', BankLogic::getBankByShopId($this->shop_id));
return view();
}
/**
* @Notes: 申请详细
* @Author: 张无忌
*/
public function detail()
{
$id = $this->request->get('id');
View::assign('detail', WithdrawalLogic::detail($id, $this->shop_id));
return view();
}
/**
* @notes 导出Excel
* @return \think\response\Json
* @author 段誉
* @date 2022/4/24 11:57
*/
public function export()
{
$params = $this->request->get();
$result = WithdrawalLogic::lists($params, $this->shop_id, true);
if(false === $result) {
return JsonServer::error(WithdrawalLogic::getError() ?: '导出失败');
}
return JsonServer::success('', $result);
}
}