This commit is contained in:
weiz 2024-04-11 17:36:55 +08:00
parent 73a440ed38
commit 4bb44bfca4
10 changed files with 1487 additions and 0 deletions

View File

@ -0,0 +1,141 @@
<?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\controller\marketing;
use app\adminapi\controller\BaseAdminController;
use app\adminapi\lists\marketing\MarketingBidEvaluationLists;
use app\adminapi\logic\marketing\MarketingBidEvaluationLogic;
use app\adminapi\validate\marketing\MarketingBidEvaluationValidate;
use app\common\model\oa\Flow;
use app\common\model\oa\FlowType;
/**
* 市场经营--投标管理--投标评审控制器
* Class MarketingBidEvaluationController
* @package app\adminapi\controller\marketing
*/
class MarketingBidEvaluationController extends BaseAdminController
{
/**
* @notes 获取市场经营--投标管理--投标评审列表
* @return \think\response\Json
* @author likeadmin
* @date 2024/04/11 15:42
*/
public function lists()
{
return $this->dataLists(new MarketingBidEvaluationLists());
}
/**
* @notes 添加市场经营--投标管理--投标评审
* @return \think\response\Json
* @author likeadmin
* @date 2024/04/11 15:42
*/
public function add()
{
$params = (new MarketingBidEvaluationValidate())->post()->goCheck('add');
$result = MarketingBidEvaluationLogic::add($params);
if (true === $result) {
return $this->success('添加成功', [], 1, 1);
}
return $this->fail(MarketingBidEvaluationLogic::getError());
}
/**
* @notes 市场经营--投标管理--投标评审-报名
* @return \think\response\Json
* @author likeadmin
* @date 2024/04/11 15:42
*/
public function reg()
{
$params = (new MarketingBidEvaluationValidate())->post()->goCheck('reg');
$result = MarketingBidEvaluationLogic::reg($params);
if (true === $result) {
return $this->success('报名成功', [], 1, 1);
}
return $this->fail(MarketingBidEvaluationLogic::getError());
}
/**
* @notes 编辑市场经营--投标管理--投标评审
* @return \think\response\Json
* @author likeadmin
* @date 2024/04/11 15:42
*/
public function edit()
{
$params = (new MarketingBidEvaluationValidate())->post()->goCheck('edit');
$result = MarketingBidEvaluationLogic::edit($params);
if (true === $result) {
return $this->success('编辑成功', [], 1, 1);
}
return $this->fail(MarketingBidEvaluationLogic::getError());
}
/**
* @notes 删除市场经营--投标管理--投标评审
* @return \think\response\Json
* @author likeadmin
* @date 2024/04/11 15:42
*/
public function delete()
{
$params = (new MarketingBidEvaluationValidate())->post()->goCheck('delete');
MarketingBidEvaluationLogic::delete($params);
return $this->success('删除成功', [], 1, 1);
}
/**
* @notes 获取市场经营--投标管理--投标评审详情
* @return \think\response\Json
* @author likeadmin
* @date 2024/04/11 15:42
*/
public function detail()
{
$params = (new MarketingBidEvaluationValidate())->goCheck('detail');
$result = MarketingBidEvaluationLogic::detail($params);
return $this->data($result);
}
//获取审批流程列表
public function flows(): \think\response\Json
{
$flow_type = FlowType::where('type', 1)->where('name', 'TBPS')->findOrEmpty();
$data = Flow::field('id,name')->where('flow_cate', $flow_type['id'])->where('status', 2)->select();
return $this->success('请求成功', $data->toArray());
}
//添加审批
public function approve(): \think\response\Json
{
$params = (new MarketingBidEvaluationValidate())->post()->goCheck('approve');
$result = MarketingBidEvaluationLogic::approve($params, $this->adminId);
if (true === $result) {
return $this->success('提交审核信息成功', [], 1, 1);
}
return $this->fail(MarketingBidEvaluationLogic::getError());
}
}

View File

@ -0,0 +1,134 @@
<?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\controller\marketing;
use app\adminapi\controller\BaseAdminController;
use app\adminapi\lists\marketing\MarketingBusinessOpportunityLists;
use app\adminapi\logic\marketing\MarketingBusinessOpportunityLogic;
use app\adminapi\validate\marketing\MarketingBusinessOpportunityValidate;
use app\common\model\oa\Flow;
use app\common\model\oa\FlowType;
/**
* 市场经营--投标管理--业务机会控制器
* Class MarketingBusinessOpportunityController
* @package app\adminapi\controller\marketing
*/
class MarketingBusinessOpportunityController extends BaseAdminController
{
/**
* @notes 获取市场经营--投标管理--业务机会列表
* @return \think\response\Json
* @author likeadmin
* @date 2024/04/11 14:27
*/
public function lists()
{
return $this->dataLists(new MarketingBusinessOpportunityLists());
}
/**
* @notes 添加市场经营--投标管理--业务机会
* @return \think\response\Json
* @author likeadmin
* @date 2024/04/11 14:27
*/
public function add()
{
$params = (new MarketingBusinessOpportunityValidate())->post()->goCheck('add');
$result = MarketingBusinessOpportunityLogic::add($params);
if (true === $result) {
return $this->success('添加成功', [], 1, 1);
}
return $this->fail(MarketingBusinessOpportunityLogic::getError());
}
/**
* @notes 编辑市场经营--投标管理--业务机会
* @return \think\response\Json
* @author likeadmin
* @date 2024/04/11 14:27
*/
public function edit()
{
$params = (new MarketingBusinessOpportunityValidate())->post()->goCheck('edit');
$result = MarketingBusinessOpportunityLogic::edit($params);
if (true === $result) {
return $this->success('编辑成功', [], 1, 1);
}
return $this->fail(MarketingBusinessOpportunityLogic::getError());
}
/**
* @notes 删除市场经营--投标管理--业务机会
* @return \think\response\Json
* @author likeadmin
* @date 2024/04/11 14:27
*/
public function delete()
{
$params = (new MarketingBusinessOpportunityValidate())->post()->goCheck('delete');
MarketingBusinessOpportunityLogic::delete($params);
return $this->success('删除成功', [], 1, 1);
}
public function datas(): \think\response\Json
{
return $this->data(MarketingBusinessOpportunityLogic::datas());
}
/**
* @notes 获取市场经营--投标管理--业务机会详情
* @return \think\response\Json
* @author likeadmin
* @date 2024/04/11 14:27
*/
public function detail()
{
$params = (new MarketingBusinessOpportunityValidate())->goCheck('detail');
$result = MarketingBusinessOpportunityLogic::detail($params);
return $this->data($result);
}
//获取审批流程列表
public function flows(): \think\response\Json
{
$flow_type = FlowType::where('type', 1)->where('name', 'ywjh')->findOrEmpty();
$data = Flow::field('id,name')->where('flow_cate', $flow_type['id'])->where('status', 2)->select();
return $this->success('请求成功', $data->toArray());
}
//添加审批
public function approve(): \think\response\Json
{
$params = (new MarketingBusinessOpportunityValidate())->post()->goCheck('approve');
$result = MarketingBusinessOpportunityLogic::approve($params, $this->adminId);
if (true === $result) {
return $this->success('提交审核信息成功', [], 1, 1);
}
return $this->fail(MarketingBusinessOpportunityLogic::getError());
}
}

View File

@ -0,0 +1,121 @@
<?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\lists\marketing;
use app\adminapi\lists\BaseAdminDataLists;
use app\common\lists\ListsSearchInterface;
use app\common\model\auth\Admin;
use app\common\model\dept\Dept;
use app\common\model\marketing\MarketingBidEvaluation;
use app\common\model\marketing\MarketingBusinessOpportunity;
use app\common\model\marketing\MarketingCustom;
use app\common\model\oa\FlowApprove;
/**
* 市场经营--投标管理--投标评审列表
* Class MarketingBidEvaluationLists
* @package app\adminapi\listsmarketing
*/
class MarketingBidEvaluationLists extends BaseAdminDataLists implements ListsSearchInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author likeadmin
* @date 2024/04/11 15:42
*/
public function setSearch(): array
{
return [
'=' => ['business_opportunity_id', 'bid_type', 'bid_nature'],
'%like%' => ['bid_code'],
];
}
/**
* @notes 获取市场经营--投标管理--投标评审列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author likeadmin
* @date 2024/04/11 15:42
*/
public function lists(): array
{
return MarketingBidEvaluation::withoutField('create_time,update_time,delete_time')->where($this->searchWhere)
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()->each(function ($data) {
$business_opportunity = MarketingBusinessOpportunity::withoutField('bid_date,contacts,annex,approve_id,create_time,update_time,delete_time')->where('id', $data['business_opportunity_id'])->findOrEmpty();
$data['business_opportunity'] = $business_opportunity->toArray();
$construct_company = MarketingCustom::field('name')->where('id', $data['construct_company'])->findOrEmpty();
$admin = Admin::where('id', 'in', [$data['head'], $data['leader']])->column('name', 'id');
$dept = Dept::field('name')->where('id', $data['dept'])->findOrEmpty();
$data['business_opportunity']['construct_company_name'] = $construct_company?->name;
$data['business_opportunity']['business_nature_text'] = $business_opportunity->business_nature_text;
$data['business_opportunity']['industry_nature_text'] = $business_opportunity->industry_nature_text;
$data['business_opportunity']['info_sources_text'] = $business_opportunity->info_sources_text;
$data['business_opportunity']['fund_sources_text'] = $business_opportunity->fund_sources_text;
$data['business_opportunity']['const_area_text'] = $business_opportunity->const_area_text;
$data['business_opportunity']['status_text'] = $business_opportunity->status_text;
$data['business_opportunity']['dept_name'] = $dept?->name;
$data['business_opportunity']['head_name'] = $admin[$data['head']] ?? '';
$data['business_opportunity']['leader_name'] = $admin[$data['leader']] ?? '';
$data['bid_type_text'] = $data->bid_type_text;
$data['bid_nature_text'] = $data->bid_nature_text;
if (empty($data['reg_date'])) {
$data['reg_status'] = 0;
$data['reg_status_text'] = '未报名';
} else {
$data['reg_status'] = 1;
$data['reg_status_text'] = '已报名';
}
if (!empty($data['approve_id'])) {
$approve = FlowApprove::field('check_status')->where('content_id', $data['id'])->where('content_model', 'app\common\model\marketing\MarketingBidEvaluation')->findOrEmpty();
$data['approve_status'] = $approve['check_status'];
$data['approve_status_text'] = match ($approve['check_status']) {
0 => '待审核',
1 => '审核中',
2 => '审核通过',
3 => '审核不通过',
4 => '撤销审核',
};
} else {
$data['approve_status'] = 0;
$data['approve_status_text'] = '待审核';
}
})
->toArray();
}
/**
* @notes 获取市场经营--投标管理--投标评审数量
* @return int
* @author likeadmin
* @date 2024/04/11 15:42
*/
public function count(): int
{
return MarketingBidEvaluation::where($this->searchWhere)->count();
}
}

View File

@ -0,0 +1,109 @@
<?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\lists\marketing;
use app\adminapi\lists\BaseAdminDataLists;
use app\common\lists\ListsSearchInterface;
use app\common\model\auth\Admin;
use app\common\model\dept\Dept;
use app\common\model\marketing\MarketingBusinessOpportunity;
use app\common\model\marketing\MarketingCustom;
use app\common\model\oa\FlowApprove;
/**
* 市场经营--投标管理--业务机会列表
* Class MarketingBusinessOpportunityLists
* @package app\adminapi\listsmarketing
*/
class MarketingBusinessOpportunityLists extends BaseAdminDataLists implements ListsSearchInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author likeadmin
* @date 2024/04/11 14:27
*/
public function setSearch(): array
{
return [
'=' => ['construct_company', 'business_nature', 'industry_nature', 'info_sources', 'fund_sources', 'const_area', 'status'],
'%like%' => ['project_name', 'project_code'],
];
}
/**
* @notes 获取市场经营--投标管理--业务机会列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author likeadmin
* @date 2024/04/11 14:27
*/
public function lists(): array
{
return MarketingBusinessOpportunity::withoutField('create_time,update_time,delete_time')->where($this->searchWhere)
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()->each(function ($data) {
$construct_company = MarketingCustom::field('name')->where('id', $data['construct_company'])->findOrEmpty();
$admin = Admin::where('id', 'in', [$data['head'], $data['leader']])->column('name', 'id');
$dept = Dept::field('name')->where('id', $data['dept'])->findOrEmpty();
$data['construct_company_name'] = $construct_company?->name;
$data['business_nature_text'] = $data->business_nature_text;
$data['industry_nature_text'] = $data->industry_nature_text;
$data['info_sources_text'] = $data->info_sources_text;
$data['fund_sources_text'] = $data->fund_sources_text;
$data['const_area_text'] = $data->const_area_text;
$data['status_text'] = $data->status_text;
$data['dept_name'] = $dept?->name;
$data['head_name'] = $admin[$data['head']] ?? '';
$data['leader_name'] = $admin[$data['leader']] ?? '';
if (!empty($data['approve_id'])) {
$approve = FlowApprove::field('check_status')->where('content_id', $data['id'])->where('content_model', 'app\common\model\marketing\MarketingBusinessOpportunity')->findOrEmpty();
$data['approve_status'] = $approve['check_status'];
$data['approve_status_text'] = match ($approve['check_status']) {
0 => '待审核',
1 => '审核中',
2 => '审核通过',
3 => '审核不通过',
4 => '撤销审核',
};
} else {
$data['approve_status'] = 0;
$data['approve_status_text'] = '待审核';
}
})
->toArray();
}
/**
* @notes 获取市场经营--投标管理--业务机会数量
* @return int
* @author likeadmin
* @date 2024/04/11 14:27
*/
public function count(): int
{
return MarketingBusinessOpportunity::where($this->searchWhere)->count();
}
}

View File

@ -0,0 +1,215 @@
<?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\marketing;
use app\common\logic\BaseLogic;
use app\common\model\auth\Admin;
use app\common\model\dept\Dept;
use app\common\model\marketing\MarketingBidEvaluation;
use app\common\model\marketing\MarketingBusinessOpportunity;
use app\common\model\marketing\MarketingCustom;
use app\common\model\oa\FlowApprove;
use think\facade\Db;
/**
* 市场经营--投标管理--投标评审逻辑
* Class MarketingBidEvaluationLogic
* @package app\adminapi\logic\marketing
*/
class MarketingBidEvaluationLogic extends BaseLogic
{
/**
* @notes 添加市场经营--投标管理--投标评审
* @param array $params
* @return bool
* @author likeadmin
* @date 2024/04/11 15:42
*/
public static function add(array $params): bool
{
Db::startTrans();
try {
MarketingBidEvaluation::create([
'business_opportunity_id' => $params['business_opportunity_id'],
'bid_type' => $params['bid_type'] ?? 0,
'bid_nature' => $params['bid_nature'] ?? 0,
'bid_code' => $params['bid_code'],
'bid_margin' => $params['bid_margin'] ?? 0,
'bid_amount' => $params['bid_amount'] ?? 0,
'quotation_amount' => $params['quotation_amount'] ?? 0,
'end_date' => !empty($params['end_date']) ? strtotime($params['end_date']) : 0,
'bid_date' => !empty($params['bid_date']) ? strtotime($params['bid_date']) : 0,
'service_duration' => $params['service_duration'] ?? '',
'bid_address' => $params['bid_address'] ?? '',
'bid_agency' => $params['bid_agency'] ?? '',
'bid_agency_address' => $params['bid_agency_address'] ?? '',
'bid_agency_contacts' => $params['bid_agency_contacts'] ?? '',
'bid_agency_telephone' => $params['bid_agency_telephone'] ?? '',
'annex' => $params['annex'] ? json_encode($params['annex']) : null,
]);
MarketingBusinessOpportunity::where('id', $params['business_opportunity_id'])->update(['status' => 1]);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
return false;
}
}
/**
* @notes 编辑市场经营--投标管理--投标评审
* @param array $params
* @return bool
* @author likeadmin
* @date 2024/04/11 15:42
*/
public static function edit(array $params): bool
{
Db::startTrans();
try {
MarketingBidEvaluation::where('id', $params['id'])->update([
'business_opportunity_id' => $params['business_opportunity_id'],
'bid_type' => $params['bid_type'] ?? 0,
'bid_nature' => $params['bid_nature'] ?? 0,
'bid_code' => $params['bid_code'],
'bid_margin' => $params['bid_margin'] ?? 0,
'bid_amount' => $params['bid_amount'] ?? 0,
'quotation_amount' => $params['quotation_amount'] ?? 0,
'end_date' => !empty($params['end_date']) ? strtotime($params['end_date']) : 0,
'bid_date' => !empty($params['bid_date']) ? strtotime($params['bid_date']) : 0,
'service_duration' => $params['service_duration'] ?? '',
'bid_address' => $params['bid_address'] ?? '',
'bid_agency' => $params['bid_agency'] ?? '',
'bid_agency_address' => $params['bid_agency_address'] ?? '',
'bid_agency_contacts' => $params['bid_agency_contacts'] ?? '',
'bid_agency_telephone' => $params['bid_agency_telephone'] ?? '',
'annex' => $params['annex'] ? json_encode($params['annex']) : null,
]);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
return false;
}
}
/**
* @notes 市场经营--投标管理--投标评审--报名
* @param array $params
* @return bool
* @author likeadmin
* @date 2024/04/11 15:42
*/
public static function reg(array $params): bool
{
Db::startTrans();
try {
MarketingBidEvaluation::where('id', $params['id'])->update([
'reg_date' => !empty($params['reg_date']) ? strtotime($params['reg_date']) : 0,
'review_status' => $params['review_status'] ?? 0,
'reg_result' => $params['reg_result'] ?? 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 2024/04/11 15:42
*/
public static function delete(array $params): bool
{
return MarketingBidEvaluation::destroy($params['id']);
}
/**
* @notes 获取市场经营--投标管理--投标评审详情
* @param $params
* @return array
* @author likeadmin
* @date 2024/04/11 15:42
*/
public static function detail($params): array
{
$data = MarketingBidEvaluation::withoutField('create_time,update_time,delete_time')->findOrEmpty($params['id']);
$business_opportunity = MarketingBusinessOpportunity::withoutField('bid_date,contacts,annex,approve_id,create_time,update_time,delete_time')->where('id', $data['business_opportunity_id'])->findOrEmpty();
$data['business_opportunity'] = $business_opportunity->toArray();
$construct_company = MarketingCustom::field('name')->where('id', $data['construct_company'])->findOrEmpty();
$admin = Admin::where('id', 'in', [$data['head'], $data['leader']])->column('name', 'id');
$dept = Dept::field('name')->where('id', $data['dept'])->findOrEmpty();
$data['business_opportunity']['construct_company_name'] = $construct_company?->name;
$data['business_opportunity']['business_nature_text'] = $business_opportunity->business_nature_text;
$data['business_opportunity']['industry_nature_text'] = $business_opportunity->industry_nature_text;
$data['business_opportunity']['info_sources_text'] = $business_opportunity->info_sources_text;
$data['business_opportunity']['fund_sources_text'] = $business_opportunity->fund_sources_text;
$data['business_opportunity']['const_area_text'] = $business_opportunity->const_area_text;
$data['business_opportunity']['status_text'] = $business_opportunity->status_text;
$data['business_opportunity']['dept_name'] = $dept?->name;
$data['business_opportunity']['head_name'] = $admin[$data['head']] ?? '';
$data['business_opportunity']['leader_name'] = $admin[$data['leader']] ?? '';
$data['bid_type_text'] = $data->bid_type_text;
$data['bid_nature_text'] = $data->bid_nature_text;
return $data->toArray();
}
public static function approve($params, $admin_id): bool
{
$data = MarketingBidEvaluation::where('id', $params['id'])->findOrEmpty();
$approve_data = FlowApprove::where('id', $data['approve_id'])->findOrEmpty();
if (!empty($data['approve_id']) && $approve_data['check_status'] != 3) {
self::setError('当前内容存在审核信息,请勿重复提交');
return false;
}
Db::startTrans();
try {
$res = addApprove(
'投标评审',
$params['id'],
'app\common\model\marketing\MarketingBidEvaluation',
$params['path'],
$params['flow_id'],
$admin_id
);
if ($res) {
MarketingBidEvaluation::where('id', $params['id'])->update([
'approve_id' => $res,
]);
}
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
return false;
}
}
}

View File

@ -0,0 +1,198 @@
<?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\marketing;
use app\common\logic\BaseLogic;
use app\common\model\auth\Admin;
use app\common\model\dept\Dept;
use app\common\model\marketing\MarketingBusinessOpportunity;
use app\common\model\marketing\MarketingCustom;
use app\common\model\oa\FlowApprove;
use think\facade\Db;
/**
* 市场经营--投标管理--业务机会逻辑
* Class MarketingBusinessOpportunityLogic
* @package app\adminapi\logic\marketing
*/
class MarketingBusinessOpportunityLogic extends BaseLogic
{
/**
* @notes 添加市场经营--投标管理--业务机会
* @param array $params
* @return bool
* @author likeadmin
* @date 2024/04/11 14:27
*/
public static function add(array $params): bool
{
Db::startTrans();
try {
MarketingBusinessOpportunity::create([
'project_name' => $params['project_name'],
'project_code' => data_unique_code('YWJH'),
'bid_date' => !empty($params['bid_date']) ? strtotime($params['bid_date']) : 0,
'construct_company' => $params['construct_company'],
'management_company' => $params['management_company'],
'business_nature' => $params['business_nature'] ?? 0,
'industry_nature' => $params['industry_nature'] ?? 0,
'info_sources' => $params['info_sources'] ?? 0,
'fund_sources' => $params['fund_sources'] ?? 0,
'const_area' => $params['const_area'] ?? 0,
'project_address' => $params['project_address'] ?? '',
'total_investment' => $params['total_investment'] ?? 0,
'jianan_investment' => $params['jianan_investment'] ?? 0,
'project_overview' => $params['project_overview'] ?? '',
'remark' => $params['remark'] ?? '',
'head' => $params['head'] ?? 0,
'dept' => $params['dept'] ?? 0,
'leader' => $params['leader'] ?? 0,
'contacts' => $params['contacts'] ?? '',
'annex' => $params['annex'] ? json_encode($params['annex']) : null,
]);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
return false;
}
}
/**
* @notes 编辑市场经营--投标管理--业务机会
* @param array $params
* @return bool
* @author likeadmin
* @date 2024/04/11 14:27
*/
public static function edit(array $params): bool
{
Db::startTrans();
try {
MarketingBusinessOpportunity::where('id', $params['id'])->update([
'project_name' => $params['project_name'],
'bid_date' => !empty($params['bid_date']) ? strtotime($params['bid_date']) : 0,
'construct_company' => $params['construct_company'],
'management_company' => $params['management_company'],
'business_nature' => $params['business_nature'] ?? 0,
'industry_nature' => $params['industry_nature'] ?? 0,
'info_sources' => $params['info_sources'] ?? 0,
'fund_sources' => $params['fund_sources'] ?? 0,
'const_area' => $params['const_area'] ?? 0,
'project_address' => $params['project_address'] ?? '',
'total_investment' => $params['total_investment'] ?? 0,
'jianan_investment' => $params['jianan_investment'] ?? 0,
'project_overview' => $params['project_overview'] ?? '',
'remark' => $params['remark'] ?? '',
'head' => $params['head'] ?? 0,
'dept' => $params['dept'] ?? 0,
'leader' => $params['leader'] ?? 0,
'contacts' => $params['contacts'] ?? '',
'annex' => $params['annex'] ? json_encode($params['annex']) : null,
]);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
return false;
}
}
/**
* @notes 删除市场经营--投标管理--业务机会
* @param array $params
* @return bool
* @author likeadmin
* @date 2024/04/11 14:27
*/
public static function delete(array $params): bool
{
return MarketingBusinessOpportunity::destroy($params['id']);
}
/**
* @notes 获取市场经营--投标管理--业务机会详情
* @param $params
* @return array
* @author likeadmin
* @date 2024/04/11 14:27
*/
public static function detail($params): array
{
$data = MarketingBusinessOpportunity::withoutField('create_time,update_time,delete_time')->findOrEmpty($params['id']);
$construct_company = MarketingCustom::field('name')->where('id', $data['construct_company'])->findOrEmpty();
$admin = Admin::where('id', 'in', [$data['head'], $data['leader']])->column('name', 'id');
$dept = Dept::field('name')->where('id', $data['dept'])->findOrEmpty();
$data['construct_company_name'] = $construct_company?->name;
$data['business_nature_text'] = $data->business_nature_text;
$data['industry_nature_text'] = $data->industry_nature_text;
$data['info_sources_text'] = $data->info_sources_text;
$data['fund_sources_text'] = $data->fund_sources_text;
$data['const_area_text'] = $data->const_area_text;
$data['status_text'] = $data->status_text;
$data['dept_name'] = $dept?->name;
$data['head_name'] = $admin[$data['head']] ?? '';
$data['leader_name'] = $admin[$data['leader']] ?? '';
return $data->toArray();
}
public static function datas(): array
{
return MarketingBusinessOpportunity::field(['id', 'project_name'])->order(['id' => 'desc'])->select()->each(function ($data) {
$data['projectinfo'] = 'ID' . $data['id'] . ' / 名称:' . $data['project_name'];
})->toArray();
}
public static function approve($params, $admin_id): bool
{
$data = MarketingBusinessOpportunity::where('id', $params['id'])->findOrEmpty();
$approve_data = FlowApprove::where('id', $data['approve_id'])->findOrEmpty();
if (!empty($data['approve_id']) && $approve_data['check_status'] != 3) {
self::setError('当前内容存在审核信息,请勿重复提交');
return false;
}
Db::startTrans();
try {
$res = addApprove(
'业务机会',
$params['id'],
'app\common\model\marketing\MarketingBusinessOpportunity',
$params['path'],
$params['flow_id'],
$admin_id
);
if ($res) {
MarketingBusinessOpportunity::where('id', $params['id'])->update([
'approve_id' => $res,
]);
}
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
return false;
}
}
}

View File

@ -0,0 +1,196 @@
<?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\validate\marketing;
use app\common\model\dict\DictData;
use app\common\model\marketing\MarketingBidEvaluation;
use app\common\model\marketing\MarketingBusinessOpportunity;
use app\common\validate\BaseValidate;
/**
* 市场经营--投标管理--投标评审验证器
* Class MarketingBidEvaluationValidate
* @package app\adminapi\validate\marketing
*/
class MarketingBidEvaluationValidate extends BaseValidate
{
/**
* 设置校验规则
* @var string[]
*/
protected $rule = [
'id' => 'require|checkData',
'business_opportunity_id' => 'require|checkBusinessOpportunity',
'bid_type' => 'checkBidType',
'bid_nature' => 'checkBidNature',
'bid_code' => 'require',
'bid_margin' => 'float|egt:0',
'bid_amount' => 'float|egt:0',
'quotation_amount' => 'float|egt:0',
'end_date' => 'dateFormat:y-m-d',
'bid_date' => 'require|dateFormat:y-m-d',
'annex' => 'checkAnnex',
'flow_id' => 'require|checkFlow',
'path' => 'require',
'reg_date' => 'require|dateFormat:y-m-d',
'review_status' => 'require|in:0,1',
'reg_result' => 'require|in:0,1',
];
/**
* 参数描述
* @var string[]
*/
protected $field = [
'id' => 'id',
'business_opportunity_id' => '业务机会id',
'bid_type' => '招标方式',
'bid__nature' => '投标性质',
'bid_code' => '投标项目编号',
'bid_margin' => '投标保证金',
'bid_amount' => '报名和标书费',
'quotation_amount' => '报价范围',
'end_date' => '报名截止日期',
'bid_date' => '投标日期',
'service_duration' => '服务工期',
'bid_address' => '投标地点',
'bid_agency' => '招标代理单位',
'bid_agency_address' => '联系地址',
'bid_agency_contacts' => '联系人',
'bid_agency_telephone' => '联系方式',
'flow_id' => '审批流id',
'path' => '路径',
'reg_date' => '报名时间',
'review_status' => '资审情况',
'reg_result' => '报名结果',
];
/**
* @notes 添加场景
* @return MarketingBidEvaluationValidate
* @author likeadmin
* @date 2024/04/11 15:42
*/
public function sceneAdd()
{
return $this->remove('id', true)
->remove('flow_id', true)
->remove('path', true)
->remove('reg_date', true)
->remove('review_status', true)->remove('reg_result', true);
}
/**
* @notes 编辑场景
* @return MarketingBidEvaluationValidate
* @author likeadmin
* @date 2024/04/11 15:42
*/
public function sceneEdit()
{
return $this->remove('flow_id', true)->remove('path', true)->remove('reg_date', true)
->remove('review_status', true)->remove('reg_result', true);
}
/**
* @notes 删除场景
* @return MarketingBidEvaluationValidate
* @author likeadmin
* @date 2024/04/11 15:42
*/
public function sceneDelete()
{
return $this->only(['id'])->remove('id', 'checkData');
}
/**
* @notes 详情场景
* @return MarketingBidEvaluationValidate
* @author likeadmin
* @date 2024/04/11 15:42
*/
public function sceneDetail()
{
return $this->only(['id']);
}
/**
* @notes 审批场景
* @return MarketingBidEvaluationValidate
* @author likeadmin
* @date 2024/04/11 14:27
*/
public function sceneApprove()
{
return $this->only(['id', 'flow_id', 'path']);
}
/**
* @notes 报名场景
* @return MarketingBidEvaluationValidate
* @author likeadmin
* @date 2024/04/11 14:27
*/
public function sceneReg()
{
return $this->only(['id', 'reg_date', 'review_status', 'reg_result']);
}
public function checkData($value): bool|string
{
$data = MarketingBidEvaluation::where('id', $value)->findOrEmpty();
return $data->isEmpty() ? '数据不存在' : true;
}
public function checkBusinessOpportunity($value): bool|string
{
$data = MarketingBusinessOpportunity::where('id', $value)->findOrEmpty();
return $data->isEmpty() ? '关联业务机会数据不存在' : true;
}
public function checkBidType($value): bool|string
{
if (empty($value)) return true;
$dict = DictData::where('type_value', 'bidding_method')->column('value');
if (!in_array($value, $dict)) {
return '招标方式数据值无效';
}
return true;
}
public function checkBidNature($value): bool|string
{
if (empty($value)) return true;
$dict = DictData::where('type_value', 'bid_nature')->column('value');
if (!in_array($value, $dict)) {
return '投标性质数据值无效';
}
return true;
}
}

View File

@ -0,0 +1,230 @@
<?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\validate\marketing;
use app\common\model\auth\Admin;
use app\common\model\dept\Dept;
use app\common\model\dict\DictData;
use app\common\model\marketing\MarketingBusinessOpportunity;
use app\common\model\marketing\MarketingCustom;
use app\common\validate\BaseValidate;
/**
* 市场经营--投标管理--业务机会验证器
* Class MarketingBusinessOpportunityValidate
* @package app\adminapi\validate\marketing
*/
class MarketingBusinessOpportunityValidate extends BaseValidate
{
/**
* 设置校验规则
* @var string[]
*/
protected $rule = [
'id' => 'require|checkData',
'project_name' => 'require',
'bid_date' => 'require|dateFormat:Y-m-d',
'construct_company' => 'require|checkConstructCompany',
'management_company' => 'require',
'business_nature' => 'checkBusinessNature',
'industry_nature' => 'checkIndustryNature',
'info_sources' => 'checkInfoSources',
'fund_sources' => 'checkFundSources',
'const_area' => 'checkConstArea',
'total_investment' => 'float|egt:0',
'jianan_investment' => 'float|egt:0',
'head' => 'checkHead',
'dept' => 'checkDept',
'leader' => 'checkLeader',
'annex' => 'checkAnnex',
'flow_id' => 'require|checkFlow',
'path' => 'require',
];
/**
* 参数描述
* @var string[]
*/
protected $field = [
'id' => 'id',
'project_name' => '项目名称',
'project_code' => '项目编号',
'bid_date' => '预计招标日期',
'construct_company' => '建设单位',
'management_company' => '建设管理单位',
'business_nature' => '业务性质',
'industry_nature' => '行业性质',
'info_sources' => '消息来源',
'fund_sources' => '资金来源',
'const_area' => '建设区域',
'project_address' => '项目地点',
'total_investment' => '工程总投资',
'jianan_investment' => '建安投资额',
'project_overview' => '工程概况',
'remark' => '备注',
'head' => '负责人',
'dept' => '负责部门',
'leader' => '分管领导',
'contacts' => '联系人信息',
'flow_id' => '审批流id',
'path' => '路径',
];
/**
* @notes 添加场景
* @return MarketingBusinessOpportunityValidate
* @author likeadmin
* @date 2024/04/11 14:27
*/
public function sceneAdd()
{
return $this->remove('id', true)->remove('flow_id', true)->remove('path', true);
}
/**
* @notes 编辑场景
* @return MarketingBusinessOpportunityValidate
* @author likeadmin
* @date 2024/04/11 14:27
*/
public function sceneEdit()
{
return $this->remove('flow_id', true)->remove('path', true);
}
/**
* @notes 删除场景
* @return MarketingBusinessOpportunityValidate
* @author likeadmin
* @date 2024/04/11 14:27
*/
public function sceneDelete()
{
return $this->only(['id'])->remove('id', 'checkData');
}
/**
* @notes 详情场景
* @return MarketingBusinessOpportunityValidate
* @author likeadmin
* @date 2024/04/11 14:27
*/
public function sceneDetail()
{
return $this->only(['id']);
}
/**
* @notes 审批场景
* @return MarketingBusinessOpportunityValidate
* @author likeadmin
* @date 2024/04/11 14:27
*/
public function sceneApprove()
{
return $this->only(['id', 'flow_id', 'path']);
}
public function checkData($value): bool|string
{
$data = MarketingBusinessOpportunity::where('id', $value)->findOrEmpty();
return $data->isEmpty() ? '数据不存在' : true;
}
public function checkConstructCompany($value): bool|string
{
$data = MarketingCustom::where('id', $value)->findOrEmpty();
return $data->isEmpty() ? '建设单位数据不存在' : true;
}
public function checkBusinessNature($value): bool|string
{
if (empty($value)) return true;
$dict = DictData::where('type_value', 'cost_consultation_business_nature')->column('value');
if (!in_array($value, $dict)) {
return '业务性质数据值无效';
}
return true;
}
public function checkIndustryNature($value): bool|string
{
if (empty($value)) return true;
$dict = DictData::where('type_value', 'cost_consultation_industry_nature')->column('value');
if (!in_array($value, $dict)) {
return '行业性质数据值无效';
}
return true;
}
public function checkInfoSources($value): bool|string
{
if (empty($value)) return true;
$dict = DictData::where('type_value', 'info_sources')->column('value');
if (!in_array($value, $dict)) {
return '消息来源数据值无效';
}
return true;
}
public function checkFundSources($value): bool|string
{
if (empty($value)) return true;
$dict = DictData::where('type_value', 'cost_consultation_fund_sources')->column('value');
if (!in_array($value, $dict)) {
return '资金来源数据值无效';
}
return true;
}
public function checkConstArea($value): bool|string
{
if (empty($value)) return true;
$dict = DictData::where('type_value', 'cost_consultation_const_area')->column('value');
if (!in_array($value, $dict)) {
return '建设区域数据值无效';
}
return true;
}
public function checkHead($value): bool|string
{
if (empty($value)) return true;
$data = Admin::where('id', $value)->findOrEmpty();
return $data->isEmpty() ? '负责人数据不存在' : true;
}
public function checkDept($value): bool|string
{
if (empty($value)) return true;
$data = Dept::where('id', $value)->findOrEmpty();
return $data->isEmpty() ? '负责部门数据不存在' : true;
}
public function checkLeader($value): bool|string
{
if (empty($value)) return true;
$data = Admin::where('id', $value)->findOrEmpty();
return $data->isEmpty() ? '分管领导数据不存在' : true;
}
}

View File

@ -0,0 +1,68 @@
<?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\common\model\marketing;
use app\common\model\BaseModel;
use app\common\model\dict\DictData;
use think\model\concern\SoftDelete;
/**
* 市场经营--投标管理--投标评审模型
* Class MarketingBidEvaluation
* @package app\common\model\marketing
*/
class MarketingBidEvaluation extends BaseModel
{
use SoftDelete;
protected $name = 'marketing_bid_evaluation';
protected $deleteTime = 'delete_time';
public function getBidTypeTextAttr($value, $data)
{
$dict = DictData::where('type_value', 'bidding_method')->column('name', 'value');
return !empty($data['bid_type']) ? $dict[$data['bid_type']] : '';
}
public function getBidNatureTextAttr($value, $data)
{
$dict = DictData::where('type_value', 'bid_nature')->column('name', 'value');
return !empty($data['bid_nature']) ? $dict[$data['bid_nature']] : '';
}
public function getEndDateAttr($value): string
{
return !empty($value) ? date('Y-m-d', $value) : '';
}
public function getBidDateAttr($value): string
{
return !empty($value) ? date('Y-m-d', $value) : '';
}
public function getReviewStatusTextAttr($value, $data): string
{
$arr = [0 => '通过', 1 => '不通过'];
return $arr[$data['review_status']];
}
public function getRegResultTextAttr($value, $data): string
{
$arr = [0 => '通过', 1 => '不通过'];
return $arr[$data['reg_result']];
}
}

View File

@ -0,0 +1,75 @@
<?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\common\model\marketing;
use app\common\model\BaseModel;
use app\common\model\dict\DictData;
use think\model\concern\SoftDelete;
/**
* 市场经营--投标管理--业务机会模型
* Class MarketingBusinessOpportunity
* @package app\common\model\marketing
*/
class MarketingBusinessOpportunity extends BaseModel
{
use SoftDelete;
protected $name = 'marketing_business_opportunity';
protected $deleteTime = 'delete_time';
public function getBusinessNatureTextAttr($value, $data)
{
$dict = DictData::where('type_value', 'cost_consultation_business_nature')->column('name', 'value');
return !empty($data['business_nature']) ? $dict[$data['business_nature']] : '';
}
public function getIndustryNatureTextAttr($value, $data)
{
$dict = DictData::where('type_value', 'cost_consultation_industry_nature')->column('name', 'value');
return !empty($data['industry_nature']) ? $dict[$data['industry_nature']] : '';
}
public function getInfoSourcesTextAttr($value, $data)
{
$dict = DictData::where('type_value', 'info_sources')->column('name', 'value');
return !empty($data['info_sources']) ? $dict[$data['info_sources']] : '';
}
public function getFundSourcesTextAttr($value, $data)
{
$dict = DictData::where('type_value', 'cost_consultation_fund_sources')->column('name', 'value');
return !empty($data['fund_sources']) ? $dict[$data['fund_sources']] : '';
}
public function getConstAreaTextAttr($value, $data)
{
$dict = DictData::where('type_value', 'cost_consultation_const_area')->column('name', 'value');
return !empty($data['const_area']) ? $dict[$data['const_area']] : '';
}
public function getStatusTextAttr($value, $data): string
{
$arr = [0 => '未启动投标', 1 => '参与投标'];
return $arr[$data['status']];
}
public function getBidDateAttr($value): string
{
return !empty($value) ? date('Y-m-d', $value) : '';
}
}