250 lines
10 KiB
PHP
250 lines
10 KiB
PHP
<?php
|
||
/**
|
||
银行管理控制器
|
||
*/
|
||
namespace app\admin\controller;
|
||
|
||
|
||
use think\Db;
|
||
use app\model\Bank as modelBank;
|
||
|
||
class BanksInfoManage extends Base{
|
||
|
||
public $postData;
|
||
//构造函数
|
||
public function __construct(){
|
||
parent::__construct();
|
||
$this->postData = $this->request->post();
|
||
return true;
|
||
}
|
||
|
||
public function index() {
|
||
|
||
}
|
||
|
||
//银行列表 admin/BanksInfoManage/bankList
|
||
public function bankList(){
|
||
$name = input('search_text');
|
||
$where = [
|
||
'type' => 1,
|
||
'pid' => 0,
|
||
'status' => 1,
|
||
// 正确写法:del_tag=0 或 del_tag IS NULL
|
||
'del_tag' => [
|
||
['=', 0], // 条件1: del_tag = 0
|
||
['null', ''], // 条件2: del_tag IS NULL
|
||
'OR' // 逻辑或
|
||
]
|
||
];
|
||
|
||
// 动态添加名称模糊查询
|
||
if ($name) {
|
||
$where['name'] = ['like', '%' . $name . '%'];
|
||
}
|
||
|
||
$result = modelBank::getBankList($where, $this->getPage());
|
||
if ($result === false)
|
||
return $this->buildFailed('银行读取失败!');
|
||
return $this->buildSuccess(['count'=>$result['total'], 'list'=>$result['data']]);
|
||
}
|
||
|
||
//新增银行 admin/BanksInfoManage/addBank
|
||
public function addBank(modelBank $modelBank){
|
||
$postData = $this->postData;
|
||
if(empty($postData['name'])) return $this->buildFailed('银行名必须填写!');
|
||
if(empty($postData['bank_code'])) return $this->buildFailed('银行代码必须填写!');
|
||
if(empty($postData['bank_abbreviation'])) return $this->buildFailed('银行简称必须填写!');
|
||
|
||
$postData['update_uid'] = $this->userInfo['user_id'];
|
||
$postData['update_name'] = $this->userInfo['user_name'];
|
||
$postData['update_time'] = time();
|
||
if (empty($postData['id'])) {
|
||
$check = $modelBank->where(['pid'=>0,'name'=>trim($postData['name'])])->find();
|
||
if($check){
|
||
return $this->buildFailed('该银行名已经存在,不能重复添加!');
|
||
}
|
||
$postData['type'] = 1;
|
||
$postData['pid'] = 0;
|
||
$postData['create_time'] = time();
|
||
$res = $modelBank->allowField(true)->save($postData);
|
||
if (!$res) {
|
||
return $this->buildFailed('添加失败!');
|
||
}
|
||
} else {
|
||
$id = $postData['id'];
|
||
unset($postData['id']);
|
||
$res = $modelBank->allowField(true)->save($postData, ['id'=>$id]);
|
||
if (!$res) {
|
||
return $this->buildFailed('更新失败!');
|
||
}
|
||
}
|
||
|
||
return $this->buildSuccess();
|
||
}
|
||
|
||
//分行列表 admin/BanksInfoManage/branchList
|
||
public function branchList(){
|
||
$name = input('search_text');
|
||
$pid = input('pid');
|
||
if (empty($pid)) return $this->buildFailed('银行id不能为空!');
|
||
$where = [];
|
||
$where['type'] = 2;
|
||
$where['pid'] = $pid;
|
||
$where['status'] = 1;
|
||
$name && $where['name'] = ['like', '%' . $name . '%'];
|
||
$result = modelBank::getBranchList($where, $this->getPage());
|
||
if ($result === false)
|
||
return $this->buildFailed('银行读取失败!');
|
||
return $this->buildSuccess(['count'=>$result['total'], 'list'=>$result['data']]);
|
||
}
|
||
|
||
//新增分行 admin/BanksInfoManage/reqAddBranchBank
|
||
public function reqAddBranchBank(modelBank $modelBank){
|
||
$postData = $this->postData;
|
||
if(empty($postData['name'])) return $this->buildFailed('分行名必须填写!');
|
||
if(empty($postData['city'])) return $this->buildFailed('请选择城市!');
|
||
if(empty($postData['pid'])) return $this->buildFailed('缺少参数!');
|
||
if($postData['pid'] <= 0) return $this->buildFailed('参数错误!');
|
||
|
||
$postData['update_uid'] = $this->userInfo['user_id'];
|
||
$postData['update_name'] = $this->userInfo['user_name'];
|
||
$postData['update_time'] = time();
|
||
if (empty($postData['id'])) {
|
||
$check = $modelBank->where(['pid'=>$postData['pid'], 'name'=>trim($postData['name'])])->find();
|
||
if($check){
|
||
return $this->buildFailed('该分行已经存在,不能重复添加!');
|
||
}
|
||
$postData['type'] = 2;
|
||
$postData['pid'] = $postData['pid'];
|
||
$postData['create_time'] = time();
|
||
$res = $modelBank->allowField(true)->save($postData);
|
||
if (!$res) {
|
||
return $this->buildFailed('添加失败!');
|
||
}
|
||
} else {
|
||
$id = $postData['id'];
|
||
unset($postData['id']);
|
||
$res = $modelBank->allowField(true)->save($postData, ['id'=>$id]);
|
||
if (!$res) {
|
||
return $this->buildFailed('更新失败!');
|
||
}
|
||
}
|
||
|
||
return $this->buildSuccess();
|
||
}
|
||
|
||
//支行列表 admin/BanksInfoManage/subBranchList
|
||
public function subBranchList(){
|
||
$name = input('search_text');
|
||
$pid = input('pid');
|
||
if (empty($pid)) return $this->buildFailed('分行id不能为空!');
|
||
$where = [];
|
||
$where['a.type'] = 3;
|
||
$where['a.pid'] = $pid;
|
||
$where['a.status'] = 1;
|
||
$name && $where['a.name'] = ['like', '%' . $name . '%'];
|
||
$result = modelBank::getSubBranchList($where, $this->getPage());
|
||
if ($result === false)
|
||
return $this->buildFailed('银行读取失败!');
|
||
return $this->buildSuccess(['count'=>$result['total'], 'list'=>$result['data']]);
|
||
}
|
||
|
||
//新增支行 admin/BanksInfoManage/reqAddSubBank
|
||
public function reqAddSubBank(modelBank $modelBank){
|
||
$postData = $this->postData;
|
||
if(empty($postData['name'])) return $this->buildFailed('支行名必须填写!');
|
||
if(empty($postData['pid'])) return $this->buildFailed('请选择分行!');
|
||
if($postData['pid'] <= 0) return $this->buildFailed('参数错误!');
|
||
|
||
$postData['update_uid'] = $this->userInfo['user_id'];
|
||
$postData['update_name'] = $this->userInfo['user_name'];
|
||
$postData['update_time'] = time();
|
||
if (empty($postData['id'])) {
|
||
$check = $modelBank->where(['pid'=>$postData['pid'], 'name'=>trim($postData['name'])])->find();
|
||
if($check){
|
||
return $this->buildFailed('该支行已经存在!');
|
||
}
|
||
$postData['type'] = 3;
|
||
$postData['pid'] = $postData['pid'];
|
||
$postData['create_time'] = time();
|
||
$res = $modelBank->allowField(true)->save($postData);
|
||
if (!$res) {
|
||
return $this->buildFailed('添加失败!');
|
||
}
|
||
} else {
|
||
$id = $postData['id'];
|
||
unset($postData['id']);
|
||
$res = $modelBank->allowField(true)->save($postData, ['id'=>$id]);
|
||
if (!$res) {
|
||
return $this->buildFailed('更新失败!');
|
||
}
|
||
}
|
||
return $this->buildSuccess();
|
||
}
|
||
|
||
//获取银行信息 admin/BanksInfoManage/reqBankInfo
|
||
public function reqBankInfo(modelBank $modelBank){
|
||
$id = input('id');
|
||
if (empty($id)) return $this->buildFailed('参数不能为空!');
|
||
$where = "pid=0 and (del_tag=0 or del_tag=null ) and id=".$id;
|
||
$banklist = $modelBank->where( $where )->field('id,name,bank_type,bank_code,bank_abbreviation,bank_is_visible,bank_index')->find();
|
||
return $this->buildSuccess($banklist);
|
||
}
|
||
|
||
//获取分行信息 admin/BanksInfoManage/getBranchInfo
|
||
public function getBranchInfo(modelBank $modelBank){
|
||
$id = input('id');
|
||
if (empty($id)) return $this->buildFailed('参数不能为空!');
|
||
|
||
$banklist = $modelBank->alias('a')->join('bank b', 'a.pid=b.id',)->where(['a.id'=> $id])->field('a.id,a.name,b.bank_is_visible,b.bank_index,a.city,a.pid,b.name as bank_name')->find();
|
||
return $this->buildSuccess($banklist);
|
||
}
|
||
|
||
//获取支行信息 admin/BanksInfoManage/getSubBranchInfo
|
||
public function getSubBranchInfo(modelBank $modelBank){
|
||
$id = input('id');
|
||
if (empty($id)) return $this->buildFailed('参数不能为空!');
|
||
|
||
$banklist = $modelBank->alias('a')->join('bank b', 'a.pid=b.id')->join('bank c', 'b.pid=c.id')->where([ 'a.id'=> $id])->field('a.id,a.name,a.remark,a.pid,b.name as branch_name,c.name as bank_name,c.id as bank_id')->order('bank_index DESC')->find();
|
||
return $this->buildSuccess($banklist);
|
||
}
|
||
|
||
//预估单列表 admin/BanksInfoManage/reqEstimatedList
|
||
public function reqEstimatedList() {
|
||
$bank_id = input('bank_id');
|
||
$where = [];
|
||
$where['type'] = 1;
|
||
$where['pid'] = 0;
|
||
$where['del_tag'] = 0;
|
||
$where['del_tag'] = null;
|
||
$where['status'] = 1;
|
||
$bank_id && $where['id'] = $bank_id;
|
||
$result = modelBank::getPredictList($where, $this->getPage());
|
||
if ($result === false)
|
||
return $this->buildFailed('银行读取失败!');
|
||
return $this->buildSuccess(['count'=>$result['total'], 'list'=>$result['data']]);
|
||
}
|
||
|
||
//设置模板状态 admin/BanksInfoManage/setTemplateStatus
|
||
public function setTemplateStatus() {
|
||
$id = input('id');
|
||
$status = input('status');
|
||
if (empty($id) || empty($status)) return $this->buildFailed('参数不能为空!');
|
||
if (!modelBank::where('id', $id)->update(['template_status' => $status, 'update_time' => time()])) {
|
||
return $this->buildFailed('更新状态失败!');
|
||
}
|
||
return $this->buildSuccess();
|
||
}
|
||
|
||
//上传预估单 admin/BanksInfoManage/uploadPredict
|
||
public function uploadPredict() {
|
||
$id = input('id');
|
||
$house_attachment_id = input('house_attachment_id');
|
||
$business_attachment_id = input('business_attachment_id');
|
||
if (empty($id) || empty($house_attachment_id) || empty($business_attachment_id)) return $this->buildFailed('参数不能为空!');
|
||
if (!modelBank::where('id', $id)->update(['house_attachment_id' => $house_attachment_id, 'business_attachment_id' => $business_attachment_id,'update_name' => time()])) {
|
||
return $this->buildFailed('上传预估单失败!');
|
||
}
|
||
return $this->buildSuccess();
|
||
}
|
||
} |