新增利率设置

This commit is contained in:
yaooo 2023-12-20 16:23:11 +08:00
parent a29fee638a
commit f7b93e1f21
5 changed files with 426 additions and 0 deletions

View 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\RateSettingLists;
use app\adminapi\logic\bank\RateSettingLogic;
use app\adminapi\validate\bank\RateSettingValidate;
/**
* RateSetting控制器
* Class RateSettingController
* @package app\adminapi\controller\bank
*/
class RateSettingController extends BaseAdminController
{
/**
* @notes 获取列表
* @return \think\response\Json
* @author likeadmin
* @date 2023/12/20 16:22
*/
public function lists()
{
return $this->dataLists(new RateSettingLists());
}
/**
* @notes 添加
* @return \think\response\Json
* @author likeadmin
* @date 2023/12/20 16:22
*/
public function add()
{
$params = (new RateSettingValidate())->post()->goCheck('add');
$result = RateSettingLogic::add($params);
if (true === $result) {
return $this->success('添加成功', [], 1, 1);
}
return $this->fail(RateSettingLogic::getError());
}
/**
* @notes 编辑
* @return \think\response\Json
* @author likeadmin
* @date 2023/12/20 16:22
*/
public function edit()
{
$params = (new RateSettingValidate())->post()->goCheck('edit');
$result = RateSettingLogic::edit($params);
if (true === $result) {
return $this->success('编辑成功', [], 1, 1);
}
return $this->fail(RateSettingLogic::getError());
}
/**
* @notes 删除
* @return \think\response\Json
* @author likeadmin
* @date 2023/12/20 16:22
*/
public function delete()
{
$params = (new RateSettingValidate())->post()->goCheck('delete');
RateSettingLogic::delete($params);
return $this->success('删除成功', [], 1, 1);
}
/**
* @notes 获取详情
* @return \think\response\Json
* @author likeadmin
* @date 2023/12/20 16:22
*/
public function detail()
{
$params = (new RateSettingValidate())->goCheck('detail');
$result = RateSettingLogic::detail($params);
return $this->data($result);
}
}

View 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\RateSetting;
use app\common\lists\ListsSearchInterface;
/**
* RateSetting列表
* Class RateSettingLists
* @package app\adminapi\listsbank
*/
class RateSettingLists extends BaseAdminDataLists implements ListsSearchInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author likeadmin
* @date 2023/12/20 16:22
*/
public function setSearch(): array
{
return [
'=' => ['starting_effective_date'],
];
}
/**
* @notes 获取列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author likeadmin
* @date 2023/12/20 16:22
*/
public function lists(): array
{
return RateSetting::where($this->searchWhere)
->field(['id', 'starting_effective_date', 'annualized_interest_rate', 'remark'])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()
->toArray();
}
/**
* @notes 获取数量
* @return int
* @author likeadmin
* @date 2023/12/20 16:22
*/
public function count(): int
{
return RateSetting::where($this->searchWhere)->count();
}
}

View File

@ -0,0 +1,109 @@
<?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\RateSetting;
use app\common\logic\BaseLogic;
use think\facade\Db;
/**
* RateSetting逻辑
* Class RateSettingLogic
* @package app\adminapi\logic\bank
*/
class RateSettingLogic extends BaseLogic
{
/**
* @notes 添加
* @param array $params
* @return bool
* @author likeadmin
* @date 2023/12/20 16:22
*/
public static function add(array $params): bool
{
Db::startTrans();
try {
RateSetting::create([
'starting_effective_date' => $params['starting_effective_date'],
'annualized_interest_rate' => $params['annualized_interest_rate'],
]);
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 16:22
*/
public static function edit(array $params): bool
{
Db::startTrans();
try {
RateSetting::where('id', $params['id'])->update([
'starting_effective_date' => $params['starting_effective_date'],
'annualized_interest_rate' => $params['annualized_interest_rate'],
'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 16:22
*/
public static function delete(array $params): bool
{
return RateSetting::destroy($params['id']);
}
/**
* @notes 获取详情
* @param $params
* @return array
* @author likeadmin
* @date 2023/12/20 16:22
*/
public static function detail($params): array
{
return RateSetting::findOrEmpty($params['id'])->toArray();
}
}

View File

@ -0,0 +1,98 @@
<?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;
/**
* RateSetting验证器
* Class RateSettingValidate
* @package app\adminapi\validate\bank
*/
class RateSettingValidate extends BaseValidate
{
/**
* 设置校验规则
* @var string[]
*/
protected $rule = [
'id' => 'require',
'starting_effective_date' => 'require',
'annualized_interest_rate' => 'require',
];
/**
* 参数描述
* @var string[]
*/
protected $field = [
'id' => 'id',
'starting_effective_date' => '生效日期',
'annualized_interest_rate' => '年化利率(',
];
/**
* @notes 添加场景
* @return RateSettingValidate
* @author likeadmin
* @date 2023/12/20 16:22
*/
public function sceneAdd()
{
return $this->only(['starting_effective_date','annualized_interest_rate']);
}
/**
* @notes 编辑场景
* @return RateSettingValidate
* @author likeadmin
* @date 2023/12/20 16:22
*/
public function sceneEdit()
{
return $this->only(['id','starting_effective_date','annualized_interest_rate']);
}
/**
* @notes 删除场景
* @return RateSettingValidate
* @author likeadmin
* @date 2023/12/20 16:22
*/
public function sceneDelete()
{
return $this->only(['id']);
}
/**
* @notes 详情场景
* @return RateSettingValidate
* @author likeadmin
* @date 2023/12/20 16:22
*/
public function sceneDetail()
{
return $this->only(['id']);
}
}

View 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;
/**
* RateSetting模型
* Class RateSetting
* @package app\common\model\bank
*/
class RateSetting extends BaseModel
{
use SoftDelete;
protected $name = 'rate_setting';
protected $deleteTime = 'delete_time';
}