新增回款计划模块

This commit is contained in:
yaooo 2023-12-13 15:51:19 +08:00
parent 9ca70a6b35
commit a76be6abfa
5 changed files with 449 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\finance;
use app\adminapi\controller\BaseAdminController;
use app\adminapi\lists\finance\FinanceReturnedMoneyLists;
use app\adminapi\logic\finance\FinanceReturnedMoneyLogic;
use app\adminapi\validate\finance\FinanceReturnedMoneyValidate;
/**
* FinanceReturnedMoney控制器
* Class FinanceReturnedMoneyController
* @package app\adminapi\controller\finance
*/
class FinanceReturnedMoneyController extends BaseAdminController
{
/**
* @notes 获取列表
* @return \think\response\Json
* @author likeadmin
* @date 2023/12/13 15:38
*/
public function lists()
{
return $this->dataLists(new FinanceReturnedMoneyLists());
}
/**
* @notes 添加
* @return \think\response\Json
* @author likeadmin
* @date 2023/12/13 15:38
*/
public function add()
{
$params = (new FinanceReturnedMoneyValidate())->post()->goCheck('add');
$result = FinanceReturnedMoneyLogic::add($params);
if (true === $result) {
return $this->success('添加成功', [], 1, 1);
}
return $this->fail(FinanceReturnedMoneyLogic::getError());
}
/**
* @notes 编辑
* @return \think\response\Json
* @author likeadmin
* @date 2023/12/13 15:38
*/
public function edit()
{
$params = (new FinanceReturnedMoneyValidate())->post()->goCheck('edit');
$result = FinanceReturnedMoneyLogic::edit($params);
if (true === $result) {
return $this->success('编辑成功', [], 1, 1);
}
return $this->fail(FinanceReturnedMoneyLogic::getError());
}
/**
* @notes 删除
* @return \think\response\Json
* @author likeadmin
* @date 2023/12/13 15:38
*/
public function delete()
{
$params = (new FinanceReturnedMoneyValidate())->post()->goCheck('delete');
FinanceReturnedMoneyLogic::delete($params);
return $this->success('删除成功', [], 1, 1);
}
/**
* @notes 获取详情
* @return \think\response\Json
* @author likeadmin
* @date 2023/12/13 15:38
*/
public function detail()
{
$params = (new FinanceReturnedMoneyValidate())->goCheck('detail');
$result = FinanceReturnedMoneyLogic::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\finance;
use app\adminapi\lists\BaseAdminDataLists;
use app\common\model\finance\FinanceReturnedMoney;
use app\common\lists\ListsSearchInterface;
/**
* FinanceReturnedMoney列表
* Class FinanceReturnedMoneyLists
* @package app\adminapi\listsfinance
*/
class FinanceReturnedMoneyLists extends BaseAdminDataLists implements ListsSearchInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author likeadmin
* @date 2023/12/13 15:38
*/
public function setSearch(): array
{
return [
'=' => ['customer_id', 'contract_id'],
];
}
/**
* @notes 获取列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author likeadmin
* @date 2023/12/13 15:38
*/
public function lists(): array
{
return FinanceReturnedMoney::where($this->searchWhere)
->field(['*'])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()
->toArray();
}
/**
* @notes 获取数量
* @return int
* @author likeadmin
* @date 2023/12/13 15:38
*/
public function count(): int
{
return FinanceReturnedMoney::where($this->searchWhere)->count();
}
}

View File

@ -0,0 +1,125 @@
<?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\finance;
use app\common\model\finance\FinanceReturnedMoney;
use app\common\logic\BaseLogic;
use think\facade\Db;
/**
* FinanceReturnedMoney逻辑
* Class FinanceReturnedMoneyLogic
* @package app\adminapi\logic\finance
*/
class FinanceReturnedMoneyLogic extends BaseLogic
{
/**
* @notes 添加
* @param array $params
* @return bool
* @author likeadmin
* @date 2023/12/13 15:38
*/
public static function add(array $params): bool
{
Db::startTrans();
try {
FinanceReturnedMoney::create([
'customer_id' => $params['customer_id'] ?? 0,
'contract_id' => $params['contract_id'] ?? 0,
'return_date' => $params['return_date'] ?? '',
'period' => $params['period'] ?? '',
'amount' => $params['amount'] ?? 0,
'return_status' => $params['return_status'] ?? 0,
'return_duty_id' => $params['return_duty_id'] ?? 0,
'remark' => $params['remark'] ?? '',
'annex' => $params['annex'] ?? '',
]);
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/13 15:38
*/
public static function edit(array $params): bool
{
Db::startTrans();
try {
FinanceReturnedMoney::where('id', $params['id'])->update([
'customer_id' => $params['customer_id'] ?? 0,
'contract_id' => $params['contract_id'] ?? 0,
'return_date' => $params['return_date'] ?? '',
'period' => $params['period'] ?? '',
'amount' => $params['amount'] ?? 0,
'return_status' => $params['return_status'] ?? 0,
'return_duty_id' => $params['return_duty_id'] ?? 0,
'remark' => $params['remark'] ?? '',
'annex' => $params['annex'] ?? '',
]);
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/13 15:38
*/
public static function delete(array $params): bool
{
return FinanceReturnedMoney::destroy($params['id']);
}
/**
* @notes 获取详情
* @param $params
* @return array
* @author likeadmin
* @date 2023/12/13 15:38
*/
public static function detail($params): array
{
$financeReturnedMoney = FinanceReturnedMoney::findOrEmpty($params['id']);
$financeReturnedMoney->contract = $financeReturnedMoney->contract;
$financeReturnedMoney->custom = $financeReturnedMoney->custom;
return $financeReturnedMoney->toArray();
}
}

View File

@ -0,0 +1,96 @@
<?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\finance;
use app\common\validate\BaseValidate;
/**
* FinanceReturnedMoney验证器
* Class FinanceReturnedMoneyValidate
* @package app\adminapi\validate\finance
*/
class FinanceReturnedMoneyValidate extends BaseValidate
{
/**
* 设置校验规则
* @var string[]
*/
protected $rule = [
'id' => 'require',
'customer_id' => 'require',
'contract_id' => 'require',
];
/**
* 参数描述
* @var string[]
*/
protected $field = [
'id' => 'id',
];
/**
* @notes 添加场景
* @return FinanceReturnedMoneyValidate
* @author likeadmin
* @date 2023/12/13 15:38
*/
public function sceneAdd()
{
return $this->remove('id', true);
}
/**
* @notes 编辑场景
* @return FinanceReturnedMoneyValidate
* @author likeadmin
* @date 2023/12/13 15:38
*/
public function sceneEdit()
{
return $this->only(['id', 'customer_id', 'contract_id']);
}
/**
* @notes 删除场景
* @return FinanceReturnedMoneyValidate
* @author likeadmin
* @date 2023/12/13 15:38
*/
public function sceneDelete()
{
return $this->only(['id']);
}
/**
* @notes 详情场景
* @return FinanceReturnedMoneyValidate
* @author likeadmin
* @date 2023/12/13 15:38
*/
public function sceneDetail()
{
return $this->only(['id']);
}
}

View File

@ -0,0 +1,43 @@
<?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\finance;
use app\common\model\BaseModel;
use think\model\concern\SoftDelete;
/**
* FinanceReturnedMoney模型
* Class FinanceReturnedMoney
* @package app\common\model\finance
*/
class FinanceReturnedMoney extends BaseModel
{
use SoftDelete;
protected $name = 'finance_returned_money';
protected $deleteTime = 'delete_time';
public function custom()
{
return $this->belongsTo(\app\common\model\custom\Custom::class, 'customer_id');
}
public function contract()
{
return $this->belongsTo(\app\common\model\contract\Contract::class, 'contract_id');
}
}