160 lines
5.9 KiB
PHP
160 lines
5.9 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\Contract;
|
||
use app\common\logic\BaseLogic;
|
||
use think\facade\Db;
|
||
|
||
|
||
/**
|
||
* 项目合同逻辑
|
||
* Class ContractLogic
|
||
* @package app\adminapi\logic\contract
|
||
*/
|
||
class ContractLogic extends BaseLogic
|
||
{
|
||
|
||
|
||
/**
|
||
* @notes 添加项目合同
|
||
* @param array $params
|
||
* @return bool
|
||
* @author likeadmin
|
||
* @date 2023/12/02 17:19
|
||
*/
|
||
public static function add(array $params): bool
|
||
{
|
||
Db::startTrans();
|
||
try {
|
||
Contract::create([
|
||
'customer_id' => $params['customer_id'],
|
||
'approve_id' => $params['approve_id'],
|
||
'buy_bidding_document_id' => $params['buy_bidding_document_id'],
|
||
'contract_name' => $params['contract_name'],
|
||
'contract_code' => $params['contract_code'],
|
||
'contract_type' => $params['contract_type'],
|
||
'contract_pricing_method' => $params['contract_pricing_method'],
|
||
'party_a' => $params['party_a'],
|
||
'party_a_contact_address' => $params['party_a_contact_address'],
|
||
'party_a_diretor' => $params['party_a_diretor'],
|
||
'party_a_phone' => $params['party_a_phone'],
|
||
'party_a_mobile' => $params['party_a_mobile'],
|
||
'party_a_email' => $params['party_a_email'],
|
||
'party_b' => $params['party_b'],
|
||
'party_b_contact_address' => $params['party_b_contact_address'],
|
||
'party_b_diretor' => $params['party_b_diretor'],
|
||
'party_b_phone' => $params['party_b_phone'],
|
||
'party_b_mobile' => $params['party_b_mobile'],
|
||
'party_b_email' => $params['party_b_email'],
|
||
'amount' => $params['amount'],
|
||
'amount_daxie' => $params['amount_daxie'],
|
||
'business_director' => $params['business_director'],
|
||
'contract_status' => $params['contract_status'],
|
||
'expire' => $params['expire'],
|
||
'contract_date' => $params['contract_date'],
|
||
'main_content' => $params['main_content'],
|
||
'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/02 17:19
|
||
*/
|
||
public static function edit(array $params): bool
|
||
{
|
||
Db::startTrans();
|
||
try {
|
||
Contract::where('approve_id', $params['approve_id'])->update([
|
||
'customer_id' => $params['customer_id'],
|
||
'approve_id' => $params['approve_id'],
|
||
'buy_bidding_document_id' => $params['buy_bidding_document_id'],
|
||
'contract_name' => $params['contract_name'],
|
||
'contract_code' => $params['contract_code'],
|
||
'contract_type' => $params['contract_type'],
|
||
'contract_pricing_method' => $params['contract_pricing_method'],
|
||
'party_a' => $params['party_a'],
|
||
'party_a_contact_address' => $params['party_a_contact_address'],
|
||
'party_a_diretor' => $params['party_a_diretor'],
|
||
'party_a_phone' => $params['party_a_phone'],
|
||
'party_a_mobile' => $params['party_a_mobile'],
|
||
'party_a_email' => $params['party_a_email'],
|
||
'party_b' => $params['party_b'],
|
||
'party_b_contact_address' => $params['party_b_contact_address'],
|
||
'party_b_diretor' => $params['party_b_diretor'],
|
||
'party_b_phone' => $params['party_b_phone'],
|
||
'party_b_mobile' => $params['party_b_mobile'],
|
||
'party_b_email' => $params['party_b_email'],
|
||
'amount' => $params['amount'],
|
||
'amount_daxie' => $params['amount_daxie'],
|
||
'business_director' => $params['business_director'],
|
||
'contract_status' => $params['contract_status'],
|
||
'expire' => $params['expire'],
|
||
'contract_date' => $params['contract_date'],
|
||
'main_content' => $params['main_content'],
|
||
'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/02 17:19
|
||
*/
|
||
public static function delete(array $params): bool
|
||
{
|
||
return Contract::destroy($params['approve_id']);
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 获取项目合同详情
|
||
* @param $params
|
||
* @return array
|
||
* @author likeadmin
|
||
* @date 2023/12/02 17:19
|
||
*/
|
||
public static function detail($params): array
|
||
{
|
||
return Contract::findOrEmpty($params['approve_id'])->toArray();
|
||
}
|
||
} |