This commit is contained in:
weiz 2024-04-12 17:22:48 +08:00
parent d997e609f6
commit 52e9b02b7a
3 changed files with 121 additions and 2 deletions

View File

@ -0,0 +1,119 @@
<?php
namespace app\adminapi\controller\marketing;
use app\adminapi\controller\BaseAdminController;
use app\common\model\auth\Admin;
use app\common\model\bid\BidResult;
use app\common\model\dict\DictData;
use app\common\model\marketing\MarketingBidEvaluation;
use app\common\model\marketing\MarketingBidInfo;
use app\common\model\marketing\MarketingBidResult;
use app\common\model\marketing\MarketingBusinessOpportunity;
use app\common\model\marketing\MarketingCustom;
use think\response\Json;
class MarketingBidStatisticsController extends BaseAdminController
{
//中标项目一览表
public function winningProject(): Json
{
$params = $this->request->get();
$page_no = !empty($params['page_no']) ? $params['page_no'] : 1;
$page_size = !empty($params['page_size']) ? $params['page_size'] : 15;
$where = [];
if (isset($params['business_opportunity_id']) && $params['business_opportunity_id'] != '') {
$bid_evaluation_ids = MarketingBidEvaluation::where('business_opportunity_id', $params['business_opportunity_id'])->column('id');
$bid_info_ids = MarketingBidInfo::where('bid_evaluation_id', 'in', $bid_evaluation_ids)->column('id');
$where[] = ['bid_info_id', 'in', $bid_info_ids];
}
if (isset($params['bid_head']) && $params['bid_head'] != '') {
$bid_info_ids1 = MarketingBidInfo::where('bid_head', $params['bid_head'])->column('id');
$where[] = ['bid_info_id', 'in', $bid_info_ids1];
}
if (isset($params['bid_open_date']) && $params['bid_open_date'] != '') {
$date = explode(',', $params['bid_open_date']);
$where[] = ['bid_open_date', 'between', [strtotime($date[0] . ' 00:00:00'), strtotime($date[1] . ' 23:59:59')]];
}
$lists = BidResult::field('bid_result_code,bid_info_id,quotation,bid_open_date,manager')->where($where)
->page($page_no, $page_size)->order('id desc')
->select()->each(function ($data) {
$bid_info = MarketingBidInfo::field('bid_evaluation_id,bid_head')->where('id', $data['bid_info_id'])->findOrEmpty();
$bid_evaluation = MarketingBidEvaluation::field('business_opportunity_id,bid_type')->where('id', $bid_info['bid_evaluation_id'])->findOrEmpty();
$business_opportunity = MarketingBusinessOpportunity::field('project_name,construct_company,total_investment,industry_nature,project_address')->where('id', $bid_evaluation['business_opportunity_id'])->findOrEmpty();
$construct_company = MarketingCustom::field('name')->where('id', $business_opportunity['construct_company'])->findOrEmpty();
$bid_head = Admin::field('name')->where('id', $bid_info['bid_head'])->findOrEmpty();
$manager = Admin::field('name')->where('id', $data['manager'])->findOrEmpty();
$data['project_name'] = $business_opportunity?->project_name;
$data['construct_company'] = $construct_company?->name;
$data['total_investment'] = $business_opportunity?->total_investment;
$data['project_address'] = $business_opportunity?->project_address;
$data['industry_nature'] = $business_opportunity?->industry_nature_text;
$data['bid_type'] = $bid_evaluation?->bid_type_text;
$data['bid_head'] = $bid_head?->name;
$data['manager'] = $manager?->name;
})->toArray();
$count = BidResult::where($where)->count();
return $this->success('成功', compact('count', 'lists', 'page_no', 'page_size'));
}
//投标项目状态明细表
public function bidProjectStatus(): Json
{
$status = [0 => '未启动投标', 1 => '参与投标', 2 => '未开标', 3 => '已中标', 4 => '未中标'];
$data = [];
foreach ($status as $k => $v) {
$count = MarketingBusinessOpportunity::field('id')->where('status', $k)->count();
$data[] = [
'name' => $v,
'value' => $count
];
}
return $this->success('success', compact('status', 'data'));
}
//投标项目数量明细表
public function bidProjectNum(): Json
{
$column = [0 => '未启动投标', 1 => '参与投标', 2 => '未开标', 3 => '已中标', 4 => '未中标'];
$series = [
'name' => '数量',
'data' => []
];
foreach ($column as $k => $v) {
$series['data'][] = MarketingBusinessOpportunity::field('id')->where('status', $k)->count();
}
$result = [
'column' => $column,
'series' => $series
];
return $this->success('success', $result);
}
//投标项目分析
public function bidProjectAnalysis(): Json
{
$column = DictData::where('type_value', 'cost_consultation_business_nature')->column('name', 'value');
$series = [
'name' => '数量',
'data' => []
];
foreach ($column as $k => $v) {
$business_opportunity_ids = MarketingBusinessOpportunity::where('business_nature', $k)->column('id');
$bid_evaluation_ids = MarketingBidEvaluation::where('business_opportunity_id', 'in', $business_opportunity_ids)->column('id');
$bid_info_ids = MarketingBidInfo::where('bid_evaluation_id', 'in', $bid_evaluation_ids)->column('id');
$series['data'][] = MarketingBidResult::field('id')->where('bid_info_id', 'in', $bid_info_ids)->count();
}
$result = [
'column' => $column,
'series' => $series
];
return $this->success('success', $result);
}
//行业投标分析
public function bidIndustryAnalysis()
{
}
}

View File

@ -55,7 +55,7 @@
*/
public function lists(): array
{
return MarketingCompetitor::widthoutField('create_time,update_time,delete_time')->where($this->searchWhere)
return MarketingCompetitor::withoutField('create_time,update_time,delete_time')->where($this->searchWhere)
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()->each(function ($data) {

View File

@ -121,7 +121,7 @@
*/
public static function detail($params): array
{
$data = MarketingCompetitor::widthoutField('create_time,update_time,delete_time')->findOrEmpty($params['id']);
$data = MarketingCompetitor::withoutField('create_time,update_time,delete_time')->findOrEmpty($params['id']);
$data['company_type_text'] = $data->company_type_text;
return $data->toArray();
}