139 lines
5.3 KiB
PHP
139 lines
5.3 KiB
PHP
<?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\ProcurementContract;
|
||
use app\common\model\contract\SubcontractingContract;
|
||
use app\common\model\contract\SubcontractingContractDetail;
|
||
use app\common\logic\BaseLogic;
|
||
use app\common\model\project\Project;
|
||
use app\common\model\project\ProjectSubpackageBudgetDetail;
|
||
use app\common\model\supplier\Supplier;
|
||
use think\facade\Db;
|
||
|
||
|
||
/**
|
||
* 分包合同-分包明细逻辑
|
||
* Class SubcontractingContractDetailLogic
|
||
* @package app\adminapi\logic\contract
|
||
*/
|
||
class SubcontractingContractDetailLogic extends BaseLogic
|
||
{
|
||
|
||
|
||
/**
|
||
* @notes 添加分包合同-分包明细
|
||
* @param array $params
|
||
* @return bool
|
||
* @author likeadmin
|
||
* @date 2023/12/28 22:08
|
||
*/
|
||
public static function add(array $params): bool
|
||
{
|
||
Db::startTrans();
|
||
try {
|
||
SubcontractingContractDetail::create([
|
||
'subcontracting_contract_id' => $params['subcontracting_contract_id'],
|
||
'subcontracting_budget' => $params['subcontracting_budget'],
|
||
'workload' => $params['workload'],
|
||
'unit_price_including_tax' => $params['unit_price_including_tax'],
|
||
'amount_excluding_tax' => $params['amount_excluding_tax'],
|
||
'amount_including_tax' => $params['amount_including_tax'],
|
||
'remark' => $params['remark']
|
||
]);
|
||
|
||
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/28 22:08
|
||
*/
|
||
public static function edit(array $params): bool
|
||
{
|
||
Db::startTrans();
|
||
try {
|
||
SubcontractingContractDetail::where('id', $params['id'])->update([
|
||
'subcontracting_contract_id' => $params['subcontracting_contract_id'],
|
||
'subcontracting_budget' => $params['subcontracting_budget'],
|
||
'workload' => $params['workload'],
|
||
'unit_price_including_tax' => $params['unit_price_including_tax'],
|
||
'amount_excluding_tax' => $params['amount_excluding_tax'],
|
||
'amount_including_tax' => $params['amount_including_tax'],
|
||
'remark' => $params['remark']
|
||
]);
|
||
|
||
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/28 22:08
|
||
*/
|
||
public static function delete(array $params): bool
|
||
{
|
||
return SubcontractingContractDetail::destroy($params['id']);
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 获取分包合同-分包明细详情
|
||
* @param $params
|
||
* @return array
|
||
* @author likeadmin
|
||
* @date 2023/12/28 22:08
|
||
*/
|
||
public static function detail($params): array
|
||
{
|
||
$data = SubcontractingContractDetail::field('id,contract_id,subpackage_budget_detail_id,num,price,tax_rate,amount_excluding_tax,amount_including_tax,remark')->findOrEmpty($params['id']);
|
||
$contract = SubcontractingContract::field('contract_no,contract_name,project_id,supplier_id,contract_type')->where('id',$data['contract_id'])->findOrEmpty();
|
||
$project = Project::field('name,project_code')->where('id',$contract['project_id'])->findOrEmpty();
|
||
$supplier = Supplier::field('supplier_code,supplier_name')->where('id',$contract['supplier_id'])->findOrEmpty();
|
||
$subpackage_budget_detail = ProjectSubpackageBudgetDetail::field('work_type,work_content,project_features,unit')->where('id',$data['subpackage_budget_detail_id'])->findOrEmpty();
|
||
$data['project_code'] = $project['project_code'];
|
||
$data['project_name'] = $project['name'];
|
||
$data['supplier_code'] = $supplier['supplier_code'];
|
||
$data['supplier_name'] = $supplier['supplier_name'];
|
||
$data['contract_name'] = $contract['contract_name'];
|
||
$data['contract_no'] = $contract['contract_no'];
|
||
$data['contract_type'] = $contract->contract_type_text;
|
||
$data['work_type'] = $subpackage_budget_detail['work_type'];
|
||
$data['work_content'] = $subpackage_budget_detail['work_content'];
|
||
$data['project_features'] = $subpackage_budget_detail['project_features'];
|
||
$data['unit'] = $subpackage_budget_detail['unit'];
|
||
return $data->toArray();
|
||
}
|
||
} |