新增回款记录模块

This commit is contained in:
yaooo 2023-12-13 16:37:45 +08:00
parent a76be6abfa
commit 90f856ff91
6 changed files with 473 additions and 4 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\FinanceReturnedRecordLists;
use app\adminapi\logic\finance\FinanceReturnedRecordLogic;
use app\adminapi\validate\finance\FinanceReturnedRecordValidate;
/**
* FinanceReturnedRecord控制器
* Class FinanceReturnedRecordController
* @package app\adminapi\controller\finance
*/
class FinanceReturnedRecordController extends BaseAdminController
{
/**
* @notes 获取列表
* @return \think\response\Json
* @author likeadmin
* @date 2023/12/13 16:28
*/
public function lists()
{
return $this->dataLists(new FinanceReturnedRecordLists());
}
/**
* @notes 添加
* @return \think\response\Json
* @author likeadmin
* @date 2023/12/13 16:28
*/
public function add()
{
$params = (new FinanceReturnedRecordValidate())->post()->goCheck('add');
$result = FinanceReturnedRecordLogic::add($params);
if (true === $result) {
return $this->success('添加成功', [], 1, 1);
}
return $this->fail(FinanceReturnedRecordLogic::getError());
}
/**
* @notes 编辑
* @return \think\response\Json
* @author likeadmin
* @date 2023/12/13 16:28
*/
public function edit()
{
$params = (new FinanceReturnedRecordValidate())->post()->goCheck('edit');
$result = FinanceReturnedRecordLogic::edit($params);
if (true === $result) {
return $this->success('编辑成功', [], 1, 1);
}
return $this->fail(FinanceReturnedRecordLogic::getError());
}
/**
* @notes 删除
* @return \think\response\Json
* @author likeadmin
* @date 2023/12/13 16:28
*/
public function delete()
{
$params = (new FinanceReturnedRecordValidate())->post()->goCheck('delete');
FinanceReturnedRecordLogic::delete($params);
return $this->success('删除成功', [], 1, 1);
}
/**
* @notes 获取详情
* @return \think\response\Json
* @author likeadmin
* @date 2023/12/13 16:28
*/
public function detail()
{
$params = (new FinanceReturnedRecordValidate())->goCheck('detail');
$result = FinanceReturnedRecordLogic::detail($params);
return $this->data($result);
}
}

View File

@ -71,10 +71,7 @@ class FinanceInvoiceApplyLists extends BaseAdminDataLists implements ListsSearch
*/
public function count(): int
{
$financeInvoiceApply = FinanceInvoiceApply::findOrEmpty($params['id']);
$financeInvoiceApply->project = $financeInvoiceApply->project;
$financeInvoiceApply->custom = $financeInvoiceApply->custom;
return $financeInvoiceApply->toArray();
return FinanceInvoiceApply::where($this->searchWhere)->count();
}
}

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\FinanceReturnedRecord;
use app\common\lists\ListsSearchInterface;
/**
* FinanceReturnedRecord列表
* Class FinanceReturnedRecordLists
* @package app\adminapi\listsfinance
*/
class FinanceReturnedRecordLists extends BaseAdminDataLists implements ListsSearchInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author likeadmin
* @date 2023/12/13 16:28
*/
public function setSearch(): array
{
return [
'=' => ['customer_id', 'contract_id', 'finance_returned_money_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 16:28
*/
public function lists(): array
{
return FinanceReturnedRecord::where($this->searchWhere)
->field(['*'])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()
->toArray();
}
/**
* @notes 获取数量
* @return int
* @author likeadmin
* @date 2023/12/13 16:28
*/
public function count(): int
{
return FinanceReturnedRecord::where($this->searchWhere)->count();
}
}

View File

@ -0,0 +1,142 @@
<?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\FinanceReturnedRecord;
use app\common\logic\BaseLogic;
use think\facade\Db;
/**
* FinanceReturnedRecord逻辑
* Class FinanceReturnedRecordLogic
* @package app\adminapi\logic\finance
*/
class FinanceReturnedRecordLogic extends BaseLogic
{
/**
* @notes 添加
* @param array $params
* @return bool
* @author likeadmin
* @date 2023/12/13 16:28
*/
public static function add(array $params): bool
{
Db::startTrans();
try {
FinanceReturnedRecord::create([
'customer_id' => $params['customer_id'],
'contract_id' => $params['contract_id'],
'finance_returned_money_id' => $params['finance_returned_money_id'],
'return_date' => $params['return_date'],
'period' => $params['period'],
'amount' => $params['amount'],
'collection_type' => $params['collection_type'],
'invoice_status' => $params['invoice_status'],
'pay_type' => $params['pay_type'],
'return_total_amount' => $params['return_total_amount'],
'return_desc' => $params['return_desc'],
'receiver' => $params['receiver'],
'payee_id' => $params['payee_id'],
'is_interest' => $params['is_interest'],
'interest_date' => $params['interest_date'],
'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 16:28
*/
public static function edit(array $params): bool
{
Db::startTrans();
try {
FinanceReturnedRecord::where('id', $params['id'])->update([
'customer_id' => $params['customer_id'],
'contract_id' => $params['contract_id'],
'finance_returned_money_id' => $params['finance_returned_money_id'],
'return_date' => $params['return_date'],
'period' => $params['period'],
'amount' => $params['amount'],
'collection_type' => $params['collection_type'],
'invoice_status' => $params['invoice_status'],
'pay_type' => $params['pay_type'],
'return_total_amount' => $params['return_total_amount'],
'return_desc' => $params['return_desc'],
'receiver' => $params['receiver'],
'payee_id' => $params['payee_id'],
'is_interest' => $params['is_interest'],
'interest_date' => $params['interest_date'],
'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 16:28
*/
public static function delete(array $params): bool
{
return FinanceReturnedRecord::destroy($params['id']);
}
/**
* @notes 获取详情
* @param $params
* @return array
* @author likeadmin
* @date 2023/12/13 16:28
*/
public static function detail($params): array
{
$financeReturnedRecord = FinanceReturnedRecord::findOrEmpty($params['id']);
$financeReturnedRecord->contract = $financeReturnedRecord->contract;
$financeReturnedRecord->custom = $financeReturnedRecord->custom;
$financeReturnedRecord->plan = $financeReturnedRecord->returnedPlan;
return $financeReturnedRecord->toArray();
}
}

View File

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

View File

@ -0,0 +1,48 @@
<?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;
/**
* FinanceReturnedRecord模型
* Class FinanceReturnedRecord
* @package app\common\model\finance
*/
class FinanceReturnedRecord extends BaseModel
{
use SoftDelete;
protected $name = 'finance_returned_record';
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');
}
public function returnedPlan()
{
return $this->belongsTo(\app\common\model\finance\FinanceReturnedMoney::class, 'finance_returned_money_id');
}
}