105 lines
4.2 KiB
PHP
105 lines
4.2 KiB
PHP
<?php
|
|
|
|
namespace app\admin\controller;
|
|
|
|
use app\model\AccountManager as modelAccountManager;
|
|
use think\Db;
|
|
use app\model\BankAccount;
|
|
use think\facade\Env;
|
|
|
|
class AccountManager extends Base
|
|
{
|
|
/**
|
|
* @api {post} admin/AccountManager/getAccountManager 获取客户经理列表
|
|
*/
|
|
public function getAccountManager(){
|
|
$bank_id = $this->request->post('bank_id');
|
|
$name = $this->request->post('name');
|
|
if(!$bank_id) return $this->buildFailed( '银行id不能为空');
|
|
$where[] = ['bank_sub_id', '=', $bank_id];
|
|
if(!empty($name)) {
|
|
$where[] = ['name', 'like', '%'. $name. '%'];
|
|
}
|
|
$data = (new modelAccountManager())->getAccountManager($where, 'id,name, mobile');
|
|
|
|
return $this->buildSuccess($data,"操作成功",1);
|
|
}
|
|
|
|
/**
|
|
* @api {post} admin/AccountManager/addBankAccount 新增银行账户
|
|
*/
|
|
public function addBankAccount(BankAccount $bankAccount) {
|
|
$postData['type'] = $this->request->post('type', '', 'int');
|
|
$postData['name'] = $this->request->post('name', '', 'trim');
|
|
$postData['bank_account'] = $this->request->post('bank_account', '', 'trim');
|
|
$postData['bank_card'] = $this->request->post('bank_card', '', 'trim');
|
|
$postData['bank'] = $this->request->post('bank', '', 'trim');
|
|
$postData['id'] = $this->request->post('id', '', 'int');
|
|
if (empty($postData['type'])) return $this->buildFailed('请选择账户类型');
|
|
if (empty($postData['name'])) return $this->buildFailed('账户名称不能为空');
|
|
if (empty($postData['bank_account'])) return $this->buildFailed('账户户名不能为空');
|
|
if (empty($postData['bank_card'])) return $this->buildFailed('银行账户不能为空');
|
|
if (empty($postData['bank'])) return $this->buildFailed('开户银行不能为空');
|
|
|
|
$postData['create_uid'] = $this->userInfo['user_id'];
|
|
$postData['update_time'] = time();
|
|
if (empty($postData['id'])) {
|
|
$check = $bankAccount->where(['type'=>$postData['type'], 'bank_card' => $postData['bank_card']])->find();
|
|
if($check){
|
|
return $this->buildFailed('该银行名已经存在,不能重复添加!');
|
|
}
|
|
$postData['create_time'] = time();
|
|
$res = $bankAccount->allowField(true)->save($postData);
|
|
if (!$res) {
|
|
return $this->buildFailed('添加失败!');
|
|
}
|
|
} else {
|
|
$id = $postData['id'];
|
|
unset($postData['id']);
|
|
$res = $bankAccount->allowField(true)->save($postData, ['id'=>$id]);
|
|
if (!$res) {
|
|
return $this->buildFailed('更新失败!');
|
|
}
|
|
}
|
|
|
|
return $this->buildSuccess();
|
|
}
|
|
|
|
/**
|
|
* @api {post} admin/AccountManager/index 银行账户列表
|
|
*/
|
|
public function index(BankAccount $bankAccount) {
|
|
$name = input('search_text');
|
|
$where = [];
|
|
if ($name) {
|
|
$where[] = ['name', 'like', '%' . $name . '%'];
|
|
}
|
|
$result = $bankAccount->getBankAccount($where, $this->getPage());
|
|
if ($result === false)
|
|
return $this->buildFailed('银行账户读取失败!');
|
|
return $this->buildSuccess(['count'=>$result['total'], 'list'=>$result['data']]);
|
|
}
|
|
|
|
/**
|
|
* @api {post} admin/AccountManager/getBankAccountInfo 获取银行账户信息
|
|
*/
|
|
public function getBankAccountInfo(BankAccount $bankAccount) {
|
|
$id = input('id');
|
|
if (empty($id)) return $this->buildFailed('参数不能为空!');
|
|
$res = $bankAccount->field('id,name,type,bank_account,bank_card,bank')->where('id', $id)->find();
|
|
return $this->buildSuccess($res);
|
|
}
|
|
|
|
/**
|
|
* @api {post} admin/AccountManager/setStatus 设置状态
|
|
*/
|
|
public function setStatus(BankAccount $bankAccount) {
|
|
$id = input('id');
|
|
$status = input('status');
|
|
if (empty($id) || empty($status)) return $this->buildFailed('参数不能为空!');
|
|
if (!$bankAccount->where('id', $id)->update(['status' => $status, 'update_time' => time()])) {
|
|
return $this->buildFailed('更新状态失败!');
|
|
}
|
|
return $this->buildSuccess();
|
|
}
|
|
} |