更新行政收款

This commit is contained in:
yaooo 2023-12-19 14:57:12 +08:00
parent bc90e84749
commit 529b8cc2b3
5 changed files with 483 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\administrative;
use app\adminapi\controller\BaseAdminController;
use app\adminapi\lists\administrative\AdministrativePaymentsLists;
use app\adminapi\logic\administrative\AdministrativePaymentsLogic;
use app\adminapi\validate\administrative\AdministrativePaymentsValidate;
/**
* AdministrativePayments控制器
* Class AdministrativePaymentsController
* @package app\adminapi\controller\administrative
*/
class AdministrativePaymentsController extends BaseAdminController
{
/**
* @notes 获取列表
* @return \think\response\Json
* @author likeadmin
* @date 2023/12/19 14:50
*/
public function lists()
{
return $this->dataLists(new AdministrativePaymentsLists());
}
/**
* @notes 添加
* @return \think\response\Json
* @author likeadmin
* @date 2023/12/19 14:50
*/
public function add()
{
$params = (new AdministrativePaymentsValidate())->post()->goCheck('add');
$result = AdministrativePaymentsLogic::add($params);
if (true === $result) {
return $this->success('添加成功', [], 1, 1);
}
return $this->fail(AdministrativePaymentsLogic::getError());
}
/**
* @notes 编辑
* @return \think\response\Json
* @author likeadmin
* @date 2023/12/19 14:50
*/
public function edit()
{
$params = (new AdministrativePaymentsValidate())->post()->goCheck('edit');
$result = AdministrativePaymentsLogic::edit($params);
if (true === $result) {
return $this->success('编辑成功', [], 1, 1);
}
return $this->fail(AdministrativePaymentsLogic::getError());
}
/**
* @notes 删除
* @return \think\response\Json
* @author likeadmin
* @date 2023/12/19 14:50
*/
public function delete()
{
$params = (new AdministrativePaymentsValidate())->post()->goCheck('delete');
AdministrativePaymentsLogic::delete($params);
return $this->success('删除成功', [], 1, 1);
}
/**
* @notes 获取详情
* @return \think\response\Json
* @author likeadmin
* @date 2023/12/19 14:50
*/
public function detail()
{
$params = (new AdministrativePaymentsValidate())->goCheck('detail');
$result = AdministrativePaymentsLogic::detail($params);
return $this->data($result);
}
}

View File

@ -0,0 +1,94 @@
<?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\administrative;
use app\adminapi\lists\BaseAdminDataLists;
use app\common\model\administrative\AdministrativePayments;
use app\common\lists\ListsSearchInterface;
use think\facade\Db;
/**
* AdministrativePayments列表
* Class AdministrativePaymentsLists
* @package app\adminapi\listsadministrative
*/
class AdministrativePaymentsLists extends BaseAdminDataLists implements ListsSearchInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author likeadmin
* @date 2023/12/19 14:50
*/
public function setSearch(): array
{
return [
'=' => ['ap.org_id', 'ap.dept_id', 'ap.approve_id', 'ap.administrative_contract_id', 'ap.pay_type'],
];
}
/**
* @notes 获取列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author likeadmin
* @date 2023/12/19 14:50
*/
public function lists(): array
{
return Db::name('AdministrativePayments')->alias('ap')
->where($this->searchWhere)
->whereNull('ap.delete_time')
->leftJoin('orgs o','o.id = ap.org_id')
->leftJoin('dept d','d.id = ap.dept_id')
->leftJoin('administrative_contract ac','ac.id = ap.administrative_contract_id')
->field('ap.*, d.name as dept_name, o.name as org_name, ac.supplier_id, ac.contract_no, ac.contract_name')
->limit($this->limitOffset, $this->limitLength)
->order(['ap.id' => 'desc'])
->select()->each(function($item, $key){
//关联数据后续添加
$item['supplier_name'] = '供应商名称';
$item['approve_no'] = '付款单号';
$item['approve_step'] = '流程步骤';
$item['approve_settle_status'] = 1;
return $item;
})
->toArray();
}
/**
* @notes 获取数量
* @return int
* @author likeadmin
* @date 2023/12/19 14:50
*/
public function count(): int
{
return Db::name('AdministrativePayments')->alias('ap')
->where($this->searchWhere)
->whereNull('ap.delete_time')
->leftJoin('orgs o','o.id = ap.org_id')
->leftJoin('dept d','d.id = ap.dept_id')
->leftJoin('administrative_contract ac','ac.id = ap.administrative_contract_id')->count();
}
}

View File

@ -0,0 +1,132 @@
<?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\administrative;
use app\common\model\administrative\AdministrativePayments;
use app\common\logic\BaseLogic;
use think\facade\Db;
/**
* AdministrativePayments逻辑
* Class AdministrativePaymentsLogic
* @package app\adminapi\logic\administrative
*/
class AdministrativePaymentsLogic extends BaseLogic
{
/**
* @notes 添加
* @param array $params
* @return bool
* @author likeadmin
* @date 2023/12/19 14:50
*/
public static function add(array $params): bool
{
Db::startTrans();
try {
AdministrativePayments::create([
'org_id' => $params['org_id'] ?? 0,
'dept_id' => $params['dept_id'] ?? 0,
'approve_id' => $params['approve_id'] ?? 0,
'administrative_contract_id' => $params['administrative_contract_id'] ?? 0,
'applier' => $params['applier'] ?? '',
'apply_date' => $params['apply_date'] ?? '',
'pay_type' => $params['pay_type'] ?? 0,
'payment_rate' => $params['payment_rate'] ?? 0,
'payment_amount' => $params['payment_amount'] ?? 0,
'remark' => $params['remark'] ?? '',
'annex' => $params['annex'] ?? '',
'deposit_bank' => $params['deposit_bank'] ?? '',
'account_name' => $params['account_name'] ?? '',
'account' => $params['account'] ?? '',
]);
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/19 14:50
*/
public static function edit(array $params): bool
{
Db::startTrans();
try {
AdministrativePayments::where('id', $params['id'])->update([
'org_id' => $params['org_id'],
'dept_id' => $params['dept_id'],
'approve_id' => $params['approve_id'],
'administrative_contract_id' => $params['administrative_contract_id'],
'applier' => $params['applier'],
'apply_date' => $params['apply_date'],
'pay_type' => $params['pay_type'],
'payment_rate' => $params['payment_rate'],
'payment_amount' => $params['payment_amount'],
'remark' => $params['remark'],
'annex' => $params['annex'],
'deposit_bank' => $params['deposit_bank'],
'account_name' => $params['account_name'],
'account' => $params['account'],
]);
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/19 14:50
*/
public static function delete(array $params): bool
{
return AdministrativePayments::destroy($params['id']);
}
/**
* @notes 获取详情
* @param $params
* @return array
* @author likeadmin
* @date 2023/12/19 14:50
*/
public static function detail($params): array
{
return AdministrativePayments::findOrEmpty($params['id'])->toArray();
}
}

View File

@ -0,0 +1,104 @@
<?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\administrative;
use app\common\validate\BaseValidate;
/**
* AdministrativePayments验证器
* Class AdministrativePaymentsValidate
* @package app\adminapi\validate\administrative
*/
class AdministrativePaymentsValidate extends BaseValidate
{
/**
* 设置校验规则
* @var string[]
*/
protected $rule = [
'id' => 'require',
'org_id' => 'require',
'dept_id' => 'require',
'approve_id' => 'require',
'pay_type' => 'require',
'payment_amount' => 'require',
];
/**
* 参数描述
* @var string[]
*/
protected $field = [
'id' => 'id',
'org_id' => '组织id',
'dept_id' => '部门id',
'approve_id' => '审批id',
'pay_type' => '付款方式',
'payment_amount' => '本次支付金额',
];
/**
* @notes 添加场景
* @return AdministrativePaymentsValidate
* @author likeadmin
* @date 2023/12/19 14:50
*/
public function sceneAdd()
{
return $this->only(['org_id','dept_id','approve_id','pay_type','payment_amount']);
}
/**
* @notes 编辑场景
* @return AdministrativePaymentsValidate
* @author likeadmin
* @date 2023/12/19 14:50
*/
public function sceneEdit()
{
return $this->only(['id','org_id','dept_id','approve_id','pay_type','payment_amount']);
}
/**
* @notes 删除场景
* @return AdministrativePaymentsValidate
* @author likeadmin
* @date 2023/12/19 14:50
*/
public function sceneDelete()
{
return $this->only(['id']);
}
/**
* @notes 详情场景
* @return AdministrativePaymentsValidate
* @author likeadmin
* @date 2023/12/19 14:50
*/
public function sceneDetail()
{
return $this->only(['id']);
}
}

View File

@ -0,0 +1,45 @@
<?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\administrative;
use app\common\model\BaseModel;
use think\model\concern\SoftDelete;
/**
* AdministrativePayments模型
* Class AdministrativePayments
* @package app\common\model\administrative
*/
class AdministrativePayments extends BaseModel
{
use SoftDelete;
protected $name = 'administrative_payments';
protected $deleteTime = 'delete_time';
/**
* @notes 关联contract
* @return \think\model\relation\HasOne
* @author likeadmin
* @date 2023/12/19 14:50
*/
public function contract()
{
return $this->hasOne(\app\common\model\contract\AdministrativeContract::class, 'id', 'administrative_contract_id');
}
}