新增合同变更模块

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

View File

@ -0,0 +1,141 @@
<?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\contract;
use app\common\model\contract\ProcurementContractChange;
use app\common\logic\BaseLogic;
use think\facade\Db;
/**
* ProcurementContractChange逻辑
* Class ProcurementContractChangeLogic
* @package app\adminapi\logic\contract
*/
class ProcurementContractChangeLogic extends BaseLogic
{
/**
* @notes 添加
* @param array $params
* @return bool
* @author likeadmin
* @date 2023/12/12 15:31
*/
public static function add(array $params): bool
{
Db::startTrans();
try {
ProcurementContractChange::create([
'procurement_contract_id' => $params['procurement_contract_id'] ?? 0,
'supplier_id' => $params['supplier_id'] ?? 0,
'approve_id' => $params['approve_id'] ?? 0,
'project_id' => $params['project_id'] ?? 0,
'contract_no' => $params['contract_no'] ?? '',
'supplier_contract_no' => $params['supplier_contract_no'] ?? '',
'contract_type' => $params['contract_type'] ?? 0,
'signing_date' => strtotime($params['signing_date']),
'pay_type' => $params['pay_type'] ?? 0,
'account_period' => $params['account_period'] ?? 0,
'amount' => $params['amount'] ?? 0,
'amount_excluding_tax' => $params['amount_excluding_tax'] ?? 0,
'amount_daxie' => $params['amount_daxie'] ?? '',
'retention_money_rate' => $params['retention_money_rate'] ?? 0,
'retention_money' => $params['retention_money'] ?? 0,
'remark' => $params['remark'] ?? 0,
'annex' => $params['annex'] ?? 0,
]);
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/12 15:31
*/
public static function edit(array $params): bool
{
Db::startTrans();
try {
ProcurementContractChange::where('id', $params['id'])->update([
'procurement_contract_id' => $params['procurement_contract_id'] ?? 0,
'supplier_id' => $params['supplier_id'] ?? 0,
'approve_id' => $params['approve_id'] ?? 0,
'project_id' => $params['project_id'] ?? 0,
'contract_no' => $params['contract_no'] ?? '',
'supplier_contract_no' => $params['supplier_contract_no'] ?? '',
'contract_type' => $params['contract_type'] ?? 0,
'signing_date' => strtotime($params['signing_date']),
'pay_type' => $params['pay_type'] ?? 0,
'account_period' => $params['account_period'] ?? 0,
'amount' => $params['amount'] ?? 0,
'amount_excluding_tax' => $params['amount_excluding_tax'] ?? 0,
'amount_daxie' => $params['amount_daxie'] ?? '',
'retention_money_rate' => $params['retention_money_rate'] ?? 0,
'retention_money' => $params['retention_money'] ?? 0,
'remark' => $params['remark'] ?? 0,
'annex' => $params['annex'] ?? 0,
]);
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/12 15:31
*/
public static function delete(array $params): bool
{
return ProcurementContractChange::destroy($params['id']);
}
/**
* @notes 获取详情
* @param $params
* @return array
* @author likeadmin
* @date 2023/12/12 15:31
*/
public static function detail($params): array
{
$procurementContractChange = ProcurementContractChange::findOrEmpty($params['id']);
$procurementContractChange->contract = $procurementContractChange->contract;
$procurementContractChange->project = $procurementContractChange->project;
return $procurementContractChange->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\contract;
use app\common\validate\BaseValidate;
/**
* ProcurementContractChange验证器
* Class ProcurementContractChangeValidate
* @package app\adminapi\validate\contract
*/
class ProcurementContractChangeValidate extends BaseValidate
{
/**
* 设置校验规则
* @var string[]
*/
protected $rule = [
'id' => 'require',
'procurement_contract_id' => 'require',
'supplier_id' => 'require',
'approve_id' => 'require',
'project_id' => 'require',
'contract_no' => 'require',
];
/**
* 参数描述
* @var string[]
*/
protected $field = [
'id' => 'id',
];
/**
* @notes 添加场景
* @return ProcurementContractChangeValidate
* @author likeadmin
* @date 2023/12/12 15:31
*/
public function sceneAdd()
{
return $this->remove('id', true);
}
/**
* @notes 编辑场景
* @return ProcurementContractChangeValidate
* @author likeadmin
* @date 2023/12/12 15:31
*/
public function sceneEdit()
{
return $this->only(['id', 'procurement_contract_id', 'supplier_id', 'approve_id', 'project_id', 'contract_no']);
}
/**
* @notes 删除场景
* @return ProcurementContractChangeValidate
* @author likeadmin
* @date 2023/12/12 15:31
*/
public function sceneDelete()
{
return $this->only(['id']);
}
/**
* @notes 详情场景
* @return ProcurementContractChangeValidate
* @author likeadmin
* @date 2023/12/12 15:31
*/
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\contract;
use app\common\model\BaseModel;
use think\model\concern\SoftDelete;
/**
* ProcurementContractChange模型
* Class ProcurementContractChange
* @package app\common\model\contract
*/
class ProcurementContractChange extends BaseModel
{
use SoftDelete;
protected $name = 'procurement_contract_change';
protected $deleteTime = 'delete_time';
public function project()
{
return $this->belongsTo(\app\common\model\project\Project::class, 'project_id');
}
public function contract()
{
return $this->belongsTo(\app\common\model\contract\ProcurementContract::class, 'procurement_contract_id');
}
public function getSigningDateAttr($value)
{
return empty($value) ? '' : date('Y-m-d H:i:s', $value);
}
}