新增银行账户模块
This commit is contained in:
parent
dd5e0ffd61
commit
e58daa28d2
108
app/adminapi/controller/bank/BankAccountController.php
Normal file
108
app/adminapi/controller/bank/BankAccountController.php
Normal file
@ -0,0 +1,108 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace app\adminapi\controller\bank;
|
||||
|
||||
|
||||
use app\adminapi\controller\BaseAdminController;
|
||||
use app\adminapi\lists\bank\BankAccountLists;
|
||||
use app\adminapi\logic\bank\BankAccountLogic;
|
||||
use app\adminapi\validate\bank\BankAccountValidate;
|
||||
|
||||
|
||||
/**
|
||||
* BankAccount控制器
|
||||
* Class BankAccountController
|
||||
* @package app\adminapi\controller\bank
|
||||
*/
|
||||
class BankAccountController extends BaseAdminController
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取列表
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2023/12/20 15:04
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new BankAccountLists());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2023/12/20 15:04
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = (new BankAccountValidate())->post()->goCheck('add');
|
||||
$result = BankAccountLogic::add($params);
|
||||
if (true === $result) {
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(BankAccountLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2023/12/20 15:04
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = (new BankAccountValidate())->post()->goCheck('edit');
|
||||
$result = BankAccountLogic::edit($params);
|
||||
if (true === $result) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(BankAccountLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2023/12/20 15:04
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = (new BankAccountValidate())->post()->goCheck('delete');
|
||||
BankAccountLogic::delete($params);
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取详情
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2023/12/20 15:04
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new BankAccountValidate())->goCheck('detail');
|
||||
$result = BankAccountLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
}
|
77
app/adminapi/lists/bank/BankAccountLists.php
Normal file
77
app/adminapi/lists/bank/BankAccountLists.php
Normal file
@ -0,0 +1,77 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\lists\bank;
|
||||
|
||||
|
||||
use app\adminapi\lists\BaseAdminDataLists;
|
||||
use app\common\model\bank\BankAccount;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
|
||||
|
||||
/**
|
||||
* BankAccount列表
|
||||
* Class BankAccountLists
|
||||
* @package app\adminapi\listsbank
|
||||
*/
|
||||
class BankAccountLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author likeadmin
|
||||
* @date 2023/12/20 15:04
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['org_id', 'dept_id', 'account_sn', 'account'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author likeadmin
|
||||
* @date 2023/12/20 15:04
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
return BankAccount::where($this->searchWhere)
|
||||
->field(['id', 'org_id', 'dept_id', 'account_sn', 'deposit_bank', 'account_name', 'account', 'account_opening_date', 'opening_amount', 'remark'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取数量
|
||||
* @return int
|
||||
* @author likeadmin
|
||||
* @date 2023/12/20 15:04
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return BankAccount::where($this->searchWhere)->count();
|
||||
}
|
||||
|
||||
}
|
122
app/adminapi/logic/bank/BankAccountLogic.php
Normal file
122
app/adminapi/logic/bank/BankAccountLogic.php
Normal file
@ -0,0 +1,122 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\logic\bank;
|
||||
|
||||
|
||||
use app\common\model\bank\BankAccount;
|
||||
use app\common\logic\BaseLogic;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
/**
|
||||
* BankAccount逻辑
|
||||
* Class BankAccountLogic
|
||||
* @package app\adminapi\logic\bank
|
||||
*/
|
||||
class BankAccountLogic extends BaseLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2023/12/20 15:04
|
||||
*/
|
||||
public static function add(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
BankAccount::create([
|
||||
'org_id' => $params['org_id'] ?? 0,
|
||||
'dept_id' => $params['dept_id'] ?? 0,
|
||||
'account_sn' => $params['account_sn'] ?? '',
|
||||
'deposit_bank' => $params['deposit_bank'] ?? '',
|
||||
'account_name' => $params['account_name'] ?? '',
|
||||
'account' => $params['account'] ?? '',
|
||||
'account_opening_date' => $params['account_opening_date'] ?? '',
|
||||
'opening_amount' => $params['opening_amount'] ?? 0,
|
||||
'remark' => $params['remark'] ?? '',
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2023/12/20 15:04
|
||||
*/
|
||||
public static function edit(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
BankAccount::where('id', $params['id'])->update([
|
||||
'org_id' => $params['org_id'] ?? 0,
|
||||
'dept_id' => $params['dept_id'] ?? 0,
|
||||
'account_sn' => $params['account_sn'] ?? '',
|
||||
'deposit_bank' => $params['deposit_bank'] ?? '',
|
||||
'account_name' => $params['account_name'] ?? '',
|
||||
'account' => $params['account'] ?? '',
|
||||
'account_opening_date' => $params['account_opening_date'] ?? '',
|
||||
'opening_amount' => $params['opening_amount'] ?? 0,
|
||||
'remark' => $params['remark'] ?? '',
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2023/12/20 15:04
|
||||
*/
|
||||
public static function delete(array $params): bool
|
||||
{
|
||||
return BankAccount::destroy($params['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author likeadmin
|
||||
* @date 2023/12/20 15:04
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
return BankAccount::findOrEmpty($params['id'])->toArray();
|
||||
}
|
||||
}
|
106
app/adminapi/validate/bank/BankAccountValidate.php
Normal file
106
app/adminapi/validate/bank/BankAccountValidate.php
Normal file
@ -0,0 +1,106 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\validate\bank;
|
||||
|
||||
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
|
||||
/**
|
||||
* BankAccount验证器
|
||||
* Class BankAccountValidate
|
||||
* @package app\adminapi\validate\bank
|
||||
*/
|
||||
class BankAccountValidate extends BaseValidate
|
||||
{
|
||||
|
||||
/**
|
||||
* 设置校验规则
|
||||
* @var string[]
|
||||
*/
|
||||
protected $rule = [
|
||||
'id' => 'require',
|
||||
'org_id' => 'require',
|
||||
'dept_id' => 'require',
|
||||
'deposit_bank' => 'require',
|
||||
'account_name' => 'require',
|
||||
'account' => 'require',
|
||||
'opening_amount' => 'require',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* 参数描述
|
||||
* @var string[]
|
||||
*/
|
||||
protected $field = [
|
||||
'id' => 'id',
|
||||
'org_id' => '组织id',
|
||||
'dept_id' => '部门id',
|
||||
'deposit_bank' => '开户银行',
|
||||
'account_name' => '开户名称',
|
||||
'account' => '账号',
|
||||
'opening_amount' => '期初金额',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加场景
|
||||
* @return BankAccountValidate
|
||||
* @author likeadmin
|
||||
* @date 2023/12/20 15:04
|
||||
*/
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->only(['org_id','dept_id','deposit_bank','account_name','account','opening_amount']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑场景
|
||||
* @return BankAccountValidate
|
||||
* @author likeadmin
|
||||
* @date 2023/12/20 15:04
|
||||
*/
|
||||
public function sceneEdit()
|
||||
{
|
||||
return $this->only(['id','org_id','dept_id','deposit_bank','account_name','account','opening_amount']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除场景
|
||||
* @return BankAccountValidate
|
||||
* @author likeadmin
|
||||
* @date 2023/12/20 15:04
|
||||
*/
|
||||
public function sceneDelete()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 详情场景
|
||||
* @return BankAccountValidate
|
||||
* @author likeadmin
|
||||
* @date 2023/12/20 15:04
|
||||
*/
|
||||
public function sceneDetail()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
}
|
34
app/common/model/bank/BankAccount.php
Normal file
34
app/common/model/bank/BankAccount.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\common\model\bank;
|
||||
|
||||
|
||||
use app\common\model\BaseModel;
|
||||
use think\model\concern\SoftDelete;
|
||||
|
||||
|
||||
/**
|
||||
* BankAccount模型
|
||||
* Class BankAccount
|
||||
* @package app\common\model\bank
|
||||
*/
|
||||
class BankAccount extends BaseModel
|
||||
{
|
||||
use SoftDelete;
|
||||
protected $name = 'bank_account';
|
||||
protected $deleteTime = 'delete_time';
|
||||
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user