129 lines
6.2 KiB
PHP
129 lines
6.2 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\bid\BidDocumentExamination;
|
||
use app\common\model\bid\BidDocumentExaminationDetail;
|
||
use app\common\logic\BaseLogic;
|
||
use app\common\model\custom\Custom;
|
||
use app\common\model\project\Project;
|
||
use think\facade\Db;
|
||
|
||
|
||
/**
|
||
* 标书审查逻辑
|
||
* Class BidDocumentExaminationLogic
|
||
* @package app\adminapi\logic\bid
|
||
*/
|
||
class BidDocumentExaminationLogic extends BaseLogic
|
||
{
|
||
|
||
|
||
/**
|
||
* @notes 添加标书审查
|
||
* @param array $params
|
||
* @return bool
|
||
* @author likeadmin
|
||
* @date 2023/12/02 09:52
|
||
*/
|
||
public static function add(array $params,$admin_id): bool
|
||
{
|
||
$buy_bidding_document = BidBuyBiddingDocument::field('project_id')->where('id',$params['buy_bidding_document_id'])->findOrEmpty();
|
||
Db::startTrans();
|
||
try {
|
||
$bidDocumentExamination = BidDocumentExamination::create([
|
||
'code' => data_unique_code('标书审查'),
|
||
'project_id' => $buy_bidding_document['project_id'],
|
||
'buy_bidding_document_id' => $params['buy_bidding_document_id'],
|
||
'technical_protocol_deviation' => $params['technical_protocol_deviation'] ?? '',
|
||
'protocol_deviation_handling_plan' => $params['protocol_deviation_handling_plan'] ?? '',
|
||
'technical_review_annex' => !empty($params['technical_review_annex']) ? $params['technical_review_annex'] : null,
|
||
'tax_rate' => $params['tax_rate'] ?? 0,
|
||
'pay_type' => $params['pay_type'] ?? 0,
|
||
'pay_rate' => $params['pay_rate'] ?? '',
|
||
'business_contract_deviation' => $params['business_contract_deviation'] ?? '',
|
||
'business_contract_deviation_handling_plan' => $params['business_contract_deviation_handling_plan'] ?? '',
|
||
'business_contract_deviation_annex' => !empty($params['business_contract_deviation_annex']) ? $params['business_contract_deviation_annex'] : null,
|
||
]);
|
||
if(!empty($params['quotation_detail'])){
|
||
$quotation_detail = $params['quotation_detail'];
|
||
foreach ($quotation_detail as $item)
|
||
{
|
||
BidDocumentExaminationDetail::create([
|
||
'bid_document_examination_id' => $bidDocumentExamination->id,
|
||
'product_id' => $item['product_id'],
|
||
'num' => $item['num'],
|
||
'points' => $item['points'] ?? 0,
|
||
'cost_price' => $item['cost_price'],
|
||
'sale_price' => $item['sale_price'],
|
||
'cost_amount' => $item['cost_price'] * $item['num'],
|
||
'sale_amount' => $item['sale_price'] * $item['num'],
|
||
'add_user' => $admin_id,
|
||
'update_user' => $admin_id
|
||
]);
|
||
}
|
||
}
|
||
Db::commit();
|
||
return true;
|
||
} catch (\Exception $e) {
|
||
Db::rollback();
|
||
self::setError($e->getMessage());
|
||
return false;
|
||
}
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 获取标书审查详情
|
||
* @param $params
|
||
* @return array
|
||
* @author likeadmin
|
||
* @date 2023/12/02 09:52
|
||
*/
|
||
public static function detail($params): array
|
||
{
|
||
$field = 'id,code,project_id,buy_bidding_document_id,technical_protocol_deviation,protocol_deviation_handling_plan,technical_review_annex,tax_rate,pay_type,pay_rate,business_contract_deviation,business_contract_deviation_handling_plan,business_contract_deviation_annex';
|
||
$data = BidDocumentExamination::field($field)->findOrEmpty($params['id']);
|
||
$project = Project::field('custom_id,name')->where('id',$data['project_id'])->findOrEmpty();
|
||
$custom = Custom::field('name')->where('id',$project['custom_id'])->findOrEmpty();
|
||
$bid_buy_doc = BidBuyBiddingDocument::field('bid_decision_id,bid_document_no,buyer,invite_tenders_company_name,bid_company_name,amount,buy_date')->where('id',$data['buy_bidding_document_id'])->findOrEmpty();
|
||
$buyer = Admin::field('name')->where('id',$bid_buy_doc['buyer'])->findOrEmpty();
|
||
$bid_decision = BidBiddingDecision::field('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',$bid_buy_doc['bid_decision_id'])->findOrEmpty();
|
||
$data['project_name'] = $project['name'];
|
||
$data['custom_name'] = $custom['name'];
|
||
$data['bid_document_no'] = $bid_buy_doc['bid_document_no'];
|
||
$data['buyer'] = $buyer['name'];
|
||
$data['invite_tenders_company_name'] = $bid_buy_doc['invite_tenders_company_name'];
|
||
$data['bid_company_name'] = $bid_buy_doc['bid_company_name'];
|
||
$data['bid_document_amount'] = $bid_buy_doc['amount'];
|
||
$data['bidding_project_fund_source'] = $bid_decision->bidding_project_fund_source_text;
|
||
$data['bidding_time'] = $bid_decision['bidding_time'];
|
||
$data['buy_date'] = $bid_buy_doc['buy_date'];
|
||
$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['total_amount'] = BidDocumentExaminationDetail::where('bid_document_examination_id',$data['id'])->sum('sale_amount');
|
||
return $data->toArray();
|
||
}
|
||
} |