93 lines
3.2 KiB
PHP
93 lines
3.2 KiB
PHP
<?php
|
|
|
|
namespace app\admin\controller;
|
|
|
|
use app\model\Bank as modelBank;
|
|
use app\util\ReturnCode;
|
|
use think\Db;
|
|
|
|
class Bank extends Base
|
|
{
|
|
|
|
/**
|
|
* @api {post} admin/Bank/getBankForInquiry 获取银行,专属录入询价页面的银行获取下拉框,只有登录用户有建行业务员角色才包含建行选项
|
|
*/
|
|
public function getBankForInquiry(){
|
|
$where = "type=1 and status=1 and (bank_is_visible=0 or bank_is_visible is null)";
|
|
$field = 'id, name';
|
|
$data = Db::name('bank')->field($field)->where($where)->order("bank_index DESC")->select();
|
|
if(empty($this->userInfo)){
|
|
return $this->buildFailed("获取银行列表失败,因用户信息为空,请重新登录","",ReturnCode::AUTH_ERROR);
|
|
}
|
|
$roleCode = $this->userInfo['roleCode'];
|
|
if(in_array('ccb_business',$roleCode) || in_array('ROLE_ADMIN',$roleCode)) {
|
|
//if(in_array('ccb_business',$roleCode)) {
|
|
return $this->buildSuccess($data);
|
|
}else {
|
|
$data_new = array();
|
|
for($i=0; $i < count($data); $i++) {
|
|
if ($data[$i]['id'] != 777) {
|
|
array_push($data_new, $data[$i]);
|
|
}
|
|
}
|
|
return $this->buildSuccess($data_new);
|
|
}
|
|
|
|
}
|
|
/**
|
|
* @api {post} admin/Bank/reqBankList 获取银行
|
|
*/
|
|
public function reqBankList(){
|
|
// $where['type'] = 1;
|
|
//$where['status'] = 1;
|
|
$where = "type=1 and status=1 and (bank_is_visible=0 or bank_is_visible is null)";
|
|
$field = 'id, name';
|
|
$data = Db::name('bank')->field($field)->where($where)->order("bank_index DESC")->select();
|
|
return $this->buildSuccess($data);
|
|
}
|
|
|
|
/**W
|
|
* @api {post} admin/Bank/getBranch 获取下级银行
|
|
*/
|
|
public function getBranch(){
|
|
$id = $this->request->post('id');
|
|
if (empty($id)) return $this->buildFailed('缺少参数!');
|
|
$where['pid'] = $id;
|
|
$where['status'] = 1;
|
|
$data = (new modelBank())->getBankFree($where, 'id, name');
|
|
return $this->responseSuccess($data,true);
|
|
}
|
|
|
|
/**
|
|
* @api {post} admin/Bank/getCity 获取银行所属城市
|
|
*/
|
|
public function getCity(){
|
|
$id = $this->request->post('id'); //银行id
|
|
$name = $this->request->post('name'); //分行名称
|
|
if (empty($id)) return $this->buildFailed('缺少参数!');
|
|
$where['pid'] = $id;
|
|
$where['name'] = $name;
|
|
$data = (new modelBank())->getBankFree($where, 'id, city');
|
|
return $this->buildSuccess($data);
|
|
}
|
|
|
|
|
|
/**
|
|
* @api {post} admin/Bank/getBranchBybank 通过银行获取所有分行
|
|
*/
|
|
public function getBranchBybank(){
|
|
$id = $this->request->post('id');
|
|
if (empty($id)) return $this->buildFailed('缺少参数!');
|
|
//获取所有分行id
|
|
$ids = (new modelBank())->getBankFree(['pid'=>$id], 'id');
|
|
$ids = $ids ? implode(',', array_column($ids , 'id')) : '';
|
|
|
|
//获取所有支行
|
|
$data = (new modelBank())->getBankFree(['id'=>['in', $ids]], 'id,name');
|
|
return $this->buildSuccess($data);
|
|
|
|
}
|
|
|
|
|
|
|
|
} |