新增收款计划

This commit is contained in:
yaooo 2023-12-15 11:15:15 +08:00
parent c2a9640bc6
commit 7b885dd3f5
10 changed files with 913 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\FinancePaymentPlanLists;
use app\adminapi\logic\finance\FinancePaymentPlanLogic;
use app\adminapi\validate\finance\FinancePaymentPlanValidate;
/**
* FinancePaymentPlan控制器
* Class FinancePaymentPlanController
* @package app\adminapi\controller\finance
*/
class FinancePaymentPlanController extends BaseAdminController
{
/**
* @notes 获取列表
* @return \think\response\Json
* @author likeadmin
* @date 2023/12/15 11:14
*/
public function lists()
{
return $this->dataLists(new FinancePaymentPlanLists());
}
/**
* @notes 添加
* @return \think\response\Json
* @author likeadmin
* @date 2023/12/15 11:14
*/
public function add()
{
$params = (new FinancePaymentPlanValidate())->post()->goCheck('add');
$result = FinancePaymentPlanLogic::add($params);
if (true === $result) {
return $this->success('添加成功', [], 1, 1);
}
return $this->fail(FinancePaymentPlanLogic::getError());
}
/**
* @notes 编辑
* @return \think\response\Json
* @author likeadmin
* @date 2023/12/15 11:14
*/
public function edit()
{
$params = (new FinancePaymentPlanValidate())->post()->goCheck('edit');
$result = FinancePaymentPlanLogic::edit($params);
if (true === $result) {
return $this->success('编辑成功', [], 1, 1);
}
return $this->fail(FinancePaymentPlanLogic::getError());
}
/**
* @notes 删除
* @return \think\response\Json
* @author likeadmin
* @date 2023/12/15 11:14
*/
public function delete()
{
$params = (new FinancePaymentPlanValidate())->post()->goCheck('delete');
FinancePaymentPlanLogic::delete($params);
return $this->success('删除成功', [], 1, 1);
}
/**
* @notes 获取详情
* @return \think\response\Json
* @author likeadmin
* @date 2023/12/15 11:14
*/
public function detail()
{
$params = (new FinancePaymentPlanValidate())->goCheck('detail');
$result = FinancePaymentPlanLogic::detail($params);
return $this->data($result);
}
}

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\FinanceReceiptRecordLists;
use app\adminapi\logic\finance\FinanceReceiptRecordLogic;
use app\adminapi\validate\finance\FinanceReceiptRecordValidate;
/**
* FinanceReceiptRecord控制器
* Class FinanceReceiptRecordController
* @package app\adminapi\controller\finance
*/
class FinanceReceiptRecordController extends BaseAdminController
{
/**
* @notes 获取列表
* @return \think\response\Json
* @author likeadmin
* @date 2023/12/15 10:20
*/
public function lists()
{
return $this->dataLists(new FinanceReceiptRecordLists());
}
/**
* @notes 添加
* @return \think\response\Json
* @author likeadmin
* @date 2023/12/15 10:20
*/
public function add()
{
$params = (new FinanceReceiptRecordValidate())->post()->goCheck('add');
$result = FinanceReceiptRecordLogic::add($params);
if (true === $result) {
return $this->success('添加成功', [], 1, 1);
}
return $this->fail(FinanceReceiptRecordLogic::getError());
}
/**
* @notes 编辑
* @return \think\response\Json
* @author likeadmin
* @date 2023/12/15 10:20
*/
public function edit()
{
$params = (new FinanceReceiptRecordValidate())->post()->goCheck('edit');
$result = FinanceReceiptRecordLogic::edit($params);
if (true === $result) {
return $this->success('编辑成功', [], 1, 1);
}
return $this->fail(FinanceReceiptRecordLogic::getError());
}
/**
* @notes 删除
* @return \think\response\Json
* @author likeadmin
* @date 2023/12/15 10:20
*/
public function delete()
{
$params = (new FinanceReceiptRecordValidate())->post()->goCheck('delete');
FinanceReceiptRecordLogic::delete($params);
return $this->success('删除成功', [], 1, 1);
}
/**
* @notes 获取详情
* @return \think\response\Json
* @author likeadmin
* @date 2023/12/15 10:20
*/
public function detail()
{
$params = (new FinanceReceiptRecordValidate())->goCheck('detail');
$result = FinanceReceiptRecordLogic::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\FinancePaymentPlan;
use app\common\lists\ListsSearchInterface;
/**
* FinancePaymentPlan列表
* Class FinancePaymentPlanLists
* @package app\adminapi\listsfinance
*/
class FinancePaymentPlanLists extends BaseAdminDataLists implements ListsSearchInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author likeadmin
* @date 2023/12/15 11:14
*/
public function setSearch(): array
{
return [
'=' => ['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/15 11:14
*/
public function lists(): array
{
return FinancePaymentPlan::where($this->searchWhere)
->field(['id', 'supplier_id', 'contract_id', 'period', 'pay_date', 'amount', 'foreign_currency_remark', 'status', 'remark', 'annex'])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()
->toArray();
}
/**
* @notes 获取数量
* @return int
* @author likeadmin
* @date 2023/12/15 11:14
*/
public function count(): int
{
return FinancePaymentPlan::where($this->searchWhere)->count();
}
}

View File

@ -0,0 +1,86 @@
<?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\FinanceReceiptRecord;
use app\common\lists\ListsSearchInterface;
use think\facade\Db;
/**
* FinanceReceiptRecord列表
* Class FinanceReceiptRecordLists
* @package app\adminapi\listsfinance
*/
class FinanceReceiptRecordLists extends BaseAdminDataLists implements ListsSearchInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author likeadmin
* @date 2023/12/15 10:20
*/
public function setSearch(): array
{
return [
'=' => ['frr.supplier_id', 'frr.contract_id', 'frr.commitor', 'frr.invoice_type', 'frr.invoice_no'],
];
}
/**
* @notes 获取列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author likeadmin
* @date 2023/12/15 10:20
*/
public function lists(): array
{
return Db::name('FinanceReceiptRecord')->alias('frr')
->where($this->searchWhere)
->leftJoin('procurement_contract pc','pc.id = frr.contract_id')
->leftJoin('project p','p.id = pc.project_id')
->field('frr.*, p.name, p.id as project_id, p.name as project_name, pc.contract_no')
->limit($this->limitOffset, $this->limitLength)
->order(['frr.id' => 'desc'])
->select()->each(function($item, $key){
//关联数据 供应商后续添加
$item['supplier_name'] = '供应商名称';
$item['contract_type'] = '1';
return $item;
})
->toArray();
}
/**
* @notes 获取数量
* @return int
* @author likeadmin
* @date 2023/12/15 10:20
*/
public function count(): int
{
return FinanceReceiptRecord::where($this->searchWhere)->count();
}
}

View 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\finance;
use app\common\model\finance\FinancePaymentPlan;
use app\common\logic\BaseLogic;
use think\facade\Db;
/**
* FinancePaymentPlan逻辑
* Class FinancePaymentPlanLogic
* @package app\adminapi\logic\finance
*/
class FinancePaymentPlanLogic extends BaseLogic
{
/**
* @notes 添加
* @param array $params
* @return bool
* @author likeadmin
* @date 2023/12/15 11:14
*/
public static function add(array $params): bool
{
Db::startTrans();
try {
FinancePaymentPlan::create([
'supplier_id' => $params['supplier_id'],
'contract_id' => $params['contract_id'],
'period' => $params['period'],
'pay_date' => $params['pay_date'],
'amount' => $params['amount'],
'foreign_currency_remark' => $params['foreign_currency_remark'],
'status' => $params['status'],
'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/15 11:14
*/
public static function edit(array $params): bool
{
Db::startTrans();
try {
FinancePaymentPlan::where('id', $params['id'])->update([
'supplier_id' => $params['supplier_id'],
'contract_id' => $params['contract_id'],
'period' => $params['period'],
'pay_date' => $params['pay_date'],
'amount' => $params['amount'],
'foreign_currency_remark' => $params['foreign_currency_remark'],
'status' => $params['status'],
'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/15 11:14
*/
public static function delete(array $params): bool
{
return FinancePaymentPlan::destroy($params['id']);
}
/**
* @notes 获取详情
* @param $params
* @return array
* @author likeadmin
* @date 2023/12/15 11:14
*/
public static function detail($params): array
{
return FinancePaymentPlan::findOrEmpty($params['id'])->toArray();
}
}

View File

@ -0,0 +1,139 @@
<?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\FinanceReceiptRecord;
use app\common\model\project\Project;
use app\common\logic\BaseLogic;
use think\facade\Db;
/**
* FinanceReceiptRecord逻辑
* Class FinanceReceiptRecordLogic
* @package app\adminapi\logic\finance
*/
class FinanceReceiptRecordLogic extends BaseLogic
{
/**
* @notes 添加
* @param array $params
* @return bool
* @author likeadmin
* @date 2023/12/15 10:20
*/
public static function add(array $params): bool
{
Db::startTrans();
try {
FinanceReceiptRecord::create([
'supplier_id' => $params['supplier_id'] ?? 0,
'contract_id' => $params['contract_id'] ?? 0,
'invoicing_date' => $params['invoicing_date'] ?? '',
'commitor' => $params['commitor'] ?? '',
'invoice_type' => $params['invoice_type'] ?? 0,
'invoice_no' => $params['invoice_no'] ?? '',
'invoice_amount' => $params['invoice_amount'] ?? 0,
'invoice_amount_daxie' => $params['invoice_amount_daxie'] ?? '',
'invoice_tax_rate' => $params['invoice_tax_rate'] ?? 0,
'tax' => $params['tax'] ?? 0,
'amount_excluding_tax' => $params['amount_excluding_tax'] ?? 0,
'receipt_date' => $params['receipt_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/15 10:20
*/
public static function edit(array $params): bool
{
Db::startTrans();
try {
FinanceReceiptRecord::where('id', $params['id'])->update([
'supplier_id' => $params['supplier_id'] ?? 0,
'contract_id' => $params['contract_id'] ?? 0,
'invoicing_date' => $params['invoicing_date'] ?? '',
'commitor' => $params['commitor'] ?? '',
'invoice_type' => $params['invoice_type'] ?? 0,
'invoice_no' => $params['invoice_no'] ?? '',
'invoice_amount' => $params['invoice_amount'] ?? 0,
'invoice_amount_daxie' => $params['invoice_amount_daxie'] ?? '',
'invoice_tax_rate' => $params['invoice_tax_rate'] ?? 0,
'tax' => $params['tax'] ?? 0,
'amount_excluding_tax' => $params['amount_excluding_tax'] ?? 0,
'receipt_date' => $params['receipt_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/15 10:20
*/
public static function delete(array $params): bool
{
return FinanceReceiptRecord::destroy($params['id']);
}
/**
* @notes 获取详情
* @param $params
* @return array
* @author likeadmin
* @date 2023/12/15 10:20
*/
public static function detail($params): array
{
$financeReceiptRecord = FinanceReceiptRecord::findOrEmpty($params['id']);
$financeReceiptRecord->contract;
$financeReceiptRecord->project = null;
if (!empty($financeReceiptRecord->contract->project_id)) {
$financeReceiptRecord->project = Project::findOrEmpty($financeReceiptRecord->contract->project_id);
}
return $financeReceiptRecord->toArray();
}
}

View 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\finance;
use app\common\validate\BaseValidate;
/**
* FinancePaymentPlan验证器
* Class FinancePaymentPlanValidate
* @package app\adminapi\validate\finance
*/
class FinancePaymentPlanValidate extends BaseValidate
{
/**
* 设置校验规则
* @var string[]
*/
protected $rule = [
'id' => 'require',
'supplier_id' => 'require',
'contract_id' => 'require',
'period' => 'require',
'pay_date' => 'require',
'amount' => 'require',
'status' => 'require',
];
/**
* 参数描述
* @var string[]
*/
protected $field = [
'id' => 'id',
'supplier_id' => '供应商id',
'contract_id' => '合同id',
'period' => '期次',
'pay_date' => '计划付款日期',
'amount' => '金额',
'status' => '状态',
];
/**
* @notes 添加场景
* @return FinancePaymentPlanValidate
* @author likeadmin
* @date 2023/12/15 11:14
*/
public function sceneAdd()
{
return $this->only(['supplier_id','contract_id','period','pay_date','amount','status']);
}
/**
* @notes 编辑场景
* @return FinancePaymentPlanValidate
* @author likeadmin
* @date 2023/12/15 11:14
*/
public function sceneEdit()
{
return $this->only(['id','supplier_id','contract_id','period','pay_date','amount','status']);
}
/**
* @notes 删除场景
* @return FinancePaymentPlanValidate
* @author likeadmin
* @date 2023/12/15 11:14
*/
public function sceneDelete()
{
return $this->only(['id']);
}
/**
* @notes 详情场景
* @return FinancePaymentPlanValidate
* @author likeadmin
* @date 2023/12/15 11:14
*/
public function sceneDetail()
{
return $this->only(['id']);
}
}

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;
/**
* FinanceReceiptRecord验证器
* Class FinanceReceiptRecordValidate
* @package app\adminapi\validate\finance
*/
class FinanceReceiptRecordValidate extends BaseValidate
{
/**
* 设置校验规则
* @var string[]
*/
protected $rule = [
'id' => 'require',
'supplier_id' => 'require',
'contract_id' => 'require',
];
/**
* 参数描述
* @var string[]
*/
protected $field = [
'id' => 'id',
];
/**
* @notes 添加场景
* @return FinanceReceiptRecordValidate
* @author likeadmin
* @date 2023/12/15 10:20
*/
public function sceneAdd()
{
return $this->remove('id', true);
}
/**
* @notes 编辑场景
* @return FinanceReceiptRecordValidate
* @author likeadmin
* @date 2023/12/15 10:20
*/
public function sceneEdit()
{
return $this->only(['id', 'supplier_id', 'contract_id']);
}
/**
* @notes 删除场景
* @return FinanceReceiptRecordValidate
* @author likeadmin
* @date 2023/12/15 10:20
*/
public function sceneDelete()
{
return $this->only(['id']);
}
/**
* @notes 详情场景
* @return FinanceReceiptRecordValidate
* @author likeadmin
* @date 2023/12/15 10:20
*/
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\finance;
use app\common\model\BaseModel;
use think\model\concern\SoftDelete;
/**
* FinancePaymentPlan模型
* Class FinancePaymentPlan
* @package app\common\model\finance
*/
class FinancePaymentPlan extends BaseModel
{
use SoftDelete;
protected $name = 'finance_payment_plan';
protected $deleteTime = 'delete_time';
}

View File

@ -0,0 +1,37 @@
<?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;
/**
* FinanceReceiptRecord模型
* Class FinanceReceiptRecord
* @package app\common\model\finance
*/
class FinanceReceiptRecord extends BaseModel
{
use SoftDelete;
protected $name = 'finance_receipt_record';
protected $deleteTime = 'delete_time';
public function contract()
{
return $this->belongsTo(\app\common\model\contract\ProcurementContract::class, 'contract_id');
}
}