142 lines
5.3 KiB
PHP
142 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\bid;
|
||
|
||
|
||
use app\common\model\auth\Admin;
|
||
use app\common\model\bid\BidBiddingDecision;
|
||
use app\common\model\bid\BidBuyBiddingDocument;
|
||
use app\common\model\custom\Custom;
|
||
use app\common\logic\BaseLogic;
|
||
use app\common\model\project\Project;
|
||
use think\facade\Db;
|
||
|
||
|
||
/**
|
||
* 购买标书逻辑
|
||
* Class BidBuyBiddingDocumentLogic
|
||
* @package app\adminapi\logic\bid
|
||
*/
|
||
class BidBuyBiddingDocumentLogic extends BaseLogic
|
||
{
|
||
|
||
|
||
/**
|
||
* @notes 添加购买标书
|
||
* @param array $params
|
||
* @return bool
|
||
* @author likeadmin
|
||
* @date 2023/11/27 18:22
|
||
*/
|
||
public static function add(array $params): bool
|
||
{
|
||
Db::startTrans();
|
||
try {
|
||
BidBuyBiddingDocument::create([
|
||
'project_id' => $params['project_id'],
|
||
'bid_decision_id' => $params['bid_decision_id'],
|
||
'bid_document_no' => data_unique_code('购买标书'),
|
||
'invite_tenders_company_name' => $params['invite_tenders_company_name'],
|
||
'bid_company_name' => $params['bid_company_name'],
|
||
'buyer' => $params['buyer'] ?? 0,
|
||
'amount' => $params['amount'] ?? 0,
|
||
'buy_date' => !empty($params['buy_date']) ? strtotime($params['buy_date']) : 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/11/27 18:22
|
||
*/
|
||
public static function edit(array $params): bool
|
||
{
|
||
Db::startTrans();
|
||
try {
|
||
BidBuyBiddingDocument::where('id', $params['id'])->update([
|
||
'project_id' => $params['project_id'],
|
||
'bid_decision_id' => $params['bid_decision_id'],
|
||
'invite_tenders_company_name' => $params['invite_tenders_company_name'],
|
||
'bid_company_name' => $params['bid_company_name'],
|
||
'buyer' => $params['buyer'] ?? 0,
|
||
'amount' => $params['amount'] ?? 0,
|
||
'buy_date' => !empty($params['buy_date']) ? strtotime($params['buy_date']) : 0,
|
||
'update_time' => time(),
|
||
]);
|
||
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/11/27 18:22
|
||
*/
|
||
public static function delete(array $params): bool
|
||
{
|
||
return BidBuyBiddingDocument::destroy($params['id']);
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 获取购买标书详情
|
||
* @param $params
|
||
* @return array
|
||
* @author likeadmin
|
||
* @date 2023/11/27 18:22
|
||
*/
|
||
public static function detail($params): array
|
||
{
|
||
$data = BidBuyBiddingDocument::field('id,project_id,bid_decision_id,bid_document_no,invite_tenders_company_name,bid_company_name,buyer,amount,buy_date')->findOrEmpty($params['id']);
|
||
$project = Project::field('custom_id,name,project_code')->where('id',$data['project_id'])->findOrEmpty();
|
||
$custom = Custom::field('name')->where('id',$project['custom_id'])->findOrEmpty();
|
||
$bid_decision = BidBiddingDecision::field('code,bidding_project_fund_source,bidding_time,bid_type,is_margin,margin_amount,bid_opening_date,margin_amount_return_date,bid_project_overview,project_desc,annex')->where('id',$data['bid_decision_id'])->findOrEmpty();
|
||
$admin = Admin::field('name')->where('id',$data['buyer'])->findOrEmpty();
|
||
$data['project_name'] = $project['name'];
|
||
$data['project_code'] = $project['project_code'];
|
||
$data['custom_name'] = $custom['name'];
|
||
$data['bid_decision_code'] = $bid_decision['code'];
|
||
$data['bidding_time'] = $bid_decision['bidding_time'];
|
||
$data['bidding_project_fund_source'] = $bid_decision->bidding_project_fund_source_text;
|
||
$data['bid_type'] = $bid_decision->bid_type_text;
|
||
$data['is_margin'] = $bid_decision->is_margin_text;
|
||
$data['margin_amount'] = $bid_decision['margin_amount'];
|
||
$data['bid_opening_date'] = $bid_decision['bid_opening_date'];
|
||
$data['margin_amount_return_date'] = $bid_decision['margin_amount_return_date'];
|
||
$data['bid_project_overview'] = $bid_decision['bid_project_overview'];
|
||
$data['project_desc'] = $bid_decision['project_desc'];
|
||
$data['annex'] = $bid_decision['annex'];
|
||
$data['buyer'] = $admin['name'];
|
||
return $data->toArray();
|
||
}
|
||
} |