Merge pull request 'update' (#114) from zhangwei into dev

Reviewed-on: #114
This commit is contained in:
weiz 2024-01-05 11:31:46 +08:00
commit 23be4a4a89
7 changed files with 251 additions and 123 deletions

View File

@ -58,39 +58,8 @@ class BidBiddingDecisionController extends BaseAdminController
}
return $this->fail(BidBiddingDecisionLogic::getError());
}
/**
* @notes 编辑投标决策
* @return \think\response\Json
* @author likeadmin
* @date 2023/11/27 18:14
*/
public function edit()
{
$params = (new BidBiddingDecisionValidate())->post()->goCheck('edit');
$result = BidBiddingDecisionLogic::edit($params);
if (true === $result) {
return $this->success('编辑成功', [], 1, 1);
}
return $this->fail(BidBiddingDecisionLogic::getError());
}
/**
* @notes 删除投标决策
* @return \think\response\Json
* @author likeadmin
* @date 2023/11/27 18:14
*/
public function delete()
{
$params = (new BidBiddingDecisionValidate())->post()->goCheck('delete');
BidBiddingDecisionLogic::delete($params);
return $this->success('删除成功', [], 1, 1);
}
/**
* @notes 获取投标决策详情
* @return \think\response\Json

View File

@ -18,7 +18,8 @@ namespace app\adminapi\lists\bid;
use app\adminapi\lists\BaseAdminDataLists;
use app\common\model\bid\BidBiddingDecision;
use app\common\lists\ListsSearchInterface;
use think\facade\Db;
use app\common\model\custom\Custom;
use app\common\model\project\Project;
/**
@ -39,7 +40,8 @@ class BidBiddingDecisionLists extends BaseAdminDataLists implements ListsSearchI
public function setSearch(): array
{
return [
'=' => ['bbd.project_id', 'bbd.bidding_project_fund_source', 'bbd.bid_type'],
'=' => ['project_id', 'bidding_project_fund_source', 'bid_type'],
'%like%' => ['code']
];
}
@ -55,26 +57,35 @@ class BidBiddingDecisionLists extends BaseAdminDataLists implements ListsSearchI
*/
public function lists(): array
{
return Db::name('BidBiddingDecision')->alias('bbd')
->where($this->searchWhere)
->whereNull('bbd.delete_time')
->leftJoin('project p','p.id = bbd.project_id')
->leftJoin('custom ct','ct.id = p.custom_id')
->field('bbd.*, p.custom_id, p.name as project_name, p.project_code, ct.name as custom_name')
->limit($this->limitOffset, $this->limitLength)
->order(['bbd.id' => 'desc'])
->select()->each(function($item, $key){
//关联数据后续添加
$item['approve_no'] = '付款单号';
$item['approve_step'] = '流程步骤';
$item['approve_settle_status'] = 1;
$item['bidding_time'] = empty($item['bidding_time']) ? '' : date('Y-m-d H:i:s', $item['bidding_time']);
$item['buy_bid_document_date'] = empty($item['buy_bid_document_date']) ? '' : date('Y-m-d H:i:s', $item['buy_bid_document_date']);
$item['bid_opening_date'] = empty($item['bid_opening_date']) ? '' : date('Y-m-d H:i:s', $item['bid_opening_date']);
$item['margin_amount_return_date'] = empty($item['bid_opening_date']) ? '' : date('Y-m-d H:i:s', $item['margin_amount_return_date']);
return $item;
})
->toArray();
$params = $this->request->get(['project_name','custom_name']);
$where = [];
if(isset($params['project_name']) && $params['project_name'] != ''){
$project_ids = Project::where('name','like','%'.$params['project_name'].'%')->column('id');
$where[] = ['project_id','in',$project_ids];
}
if(isset($params['custom_name']) && $params['custom_name'] != ''){
$custom_ids = Custom::where('name','like','%'.$params['custom_name'].'%')->column('id');
$project_ids = Project::where('custom_id','in',$custom_ids)->column('id');
$where[] = ['project_id','in',$project_ids];
}
return BidBiddingDecision::where($this->searchWhere)->where($where)->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()->each(function($item){
$project = Project::field('custom_id,name,project_code')->where('id',$item['project_id'])->findOrEmpty();
$custom = Custom::field('id,name')->where('id',$project['custom_id'])->findOrEmpty();
$item['project_name'] = $project['name'];
$item['project_code'] = $project['project_code'];
$item['custom_id'] = $custom['id'];
$item['custom_name'] = $custom['name'];
$item['bidding_project_fund_source'] = $item->bidding_project_fund_source_text;
$item['bid_type'] = $item->bid_type_text;
$item['is_margin'] = $item->is_margin_text;
$item['is_internal_resources'] = $item->is_internal_resources_text;
$item['project_assurance'] = $item->project_assurance_text;
unset($item['org_id'],$item['dept_id'],$item['delete_time']);
return $item;
})
->toArray();
}
@ -86,10 +97,18 @@ class BidBiddingDecisionLists extends BaseAdminDataLists implements ListsSearchI
*/
public function count(): int
{
return Db::name('BidBiddingDecision')->alias('bbd')
->where($this->searchWhere)
->whereNull('bbd.delete_time')
->leftJoin('project p','p.id = bbd.project_id')->count();
$params = $this->request->get(['project_name','custom_name']);
$where = [];
if(isset($params['project_name']) && $params['project_name'] != ''){
$project_ids = Project::where('name','like','%'.$params['project_name'].'%')->column('id');
$where[] = ['project_id','in',$project_ids];
}
if(isset($params['custom_name']) && $params['custom_name'] != ''){
$custom_ids = Custom::where('name','like','%'.$params['custom_name'].'%')->column('id');
$project_ids = Project::where('custom_id','in',$custom_ids)->column('id');
$where[] = ['project_id','in',$project_ids];
}
return BidBiddingDecision::where($this->searchWhere)->where($where)->count();
}
}

View File

@ -18,6 +18,9 @@ namespace app\adminapi\logic\bid;
use app\common\model\bid\BidBiddingDecision;
use app\common\model\custom\Custom;
use app\common\logic\BaseLogic;
use app\common\model\dept\Dept;
use app\common\model\dept\Orgs;
use app\common\model\project\Project;
use think\facade\Db;
@ -42,25 +45,30 @@ class BidBiddingDecisionLogic extends BaseLogic
Db::startTrans();
try {
BidBiddingDecision::create([
'project_id' => $params['project_id'] ?? 0,
'approve_id' => $params['approve_id'] ?? 0,
'project_estimation' => $params['project_estimation'] ?? 0,
'code' => data_unique_code('投标决策'),
'org_id' => $params['org_id'],
'dept_id' => $params['dept_id'],
'project_id' => $params['project_id'],
'project_estimation' => $params['project_estimation'],
'bidding_project_fund_source' => $params['bidding_project_fund_source'] ?? 0,
'bidding_time' => strtotime($params['bidding_time']),
'buy_bid_document_date' => strtotime($params['buy_bid_document_date']),
'bidding_time' => !empty($params['bidding_time']) ? strtotime($params['bidding_time']) : 0,
'buy_bid_document_date' => !empty($params['buy_bid_document_date']) ? strtotime($params['buy_bid_document_date']) : 0,
'bid_type' => $params['bid_type'] ?? 0,
'competitor' => $params['competitor'] ?? '',
'is_margin' => $params['is_margin'] ?? 0,
'margin_amount' => $params['margin_amount'] ?? 0,
'bid_opening_date' => strtotime($params['bid_opening_date']),
'margin_amount_return_date' => strtotime($params['margin_amount_return_date']),
'bid_opening_date' => !empty($params['bid_opening_date']) ? strtotime($params['bid_opening_date']) : 0,
'margin_amount_return_date' => !empty($params['margin_amount_return_date']) ? strtotime($params['margin_amount_return_date']) : 0,
'is_internal_resources' => $params['is_internal_resources'] ?? 0,
'project_assurance' => $params['project_assurance'] ?? 0,
'bid_project_overview' => $params['bid_project_overview'] ?? '',
'project_desc' => $params['project_desc'] ?? '',
'annex' => $params['annex'] ?? '',
'annex' => !empty($params['annex']) ? $params['annex'] : null,
]);
Project::where('id',$params['project_id'])->update([
'status' => 2,
'update_time' => time(),
]);
Db::commit();
return true;
} catch (\Exception $e) {
@ -83,25 +91,27 @@ class BidBiddingDecisionLogic extends BaseLogic
Db::startTrans();
try {
BidBiddingDecision::where('id', $params['id'])->update([
'project_id' => $params['project_id'] ?? 0,
'approve_id' => $params['approve_id'] ?? 0,
'project_estimation' => $params['project_estimation'] ?? 0,
'bidding_project_fund_source' => $params['bidding_project_fund_source'] ?? 0,
'bidding_time' => strtotime($params['bidding_time']),
'buy_bid_document_date' => strtotime($params['buy_bid_document_date']),
'bid_type' => $params['bid_type'] ?? 0,
'competitor' => $params['competitor'] ?? '',
'is_margin' => $params['is_margin'] ?? 0,
'margin_amount' => $params['margin_amount'] ?? 0,
'bid_opening_date' => strtotime($params['bid_opening_date']),
'margin_amount_return_date' => strtotime($params['margin_amount_return_date']),
'is_internal_resources' => $params['is_internal_resources'] ?? 0,
'project_assurance' => $params['project_assurance'] ?? 0,
'bid_project_overview' => $params['bid_project_overview'] ?? '',
'project_desc' => $params['project_desc'] ?? '',
'annex' => $params['annex'] ?? '',
'code' => data_unique_code('投标决策'),
'org_id' => $params['org_id'],
'dept_id' => $params['dept_id'],
'project_id' => $params['project_id'],
'project_estimation' => $params['project_estimation'],
'bidding_project_fund_source' => $params['bidding_project_fund_source'] ?? 0,
'bidding_time' => !empty($params['bidding_time']) ? strtotime($params['bidding_time']) : 0,
'buy_bid_document_date' => !empty($params['buy_bid_document_date']) ? strtotime($params['buy_bid_document_date']) : 0,
'bid_type' => $params['bid_type'] ?? 0,
'competitor' => $params['competitor'] ?? '',
'is_margin' => $params['is_margin'] ?? 0,
'margin_amount' => $params['margin_amount'] ?? 0,
'bid_opening_date' => !empty($params['bid_opening_date']) ? strtotime($params['bid_opening_date']) : 0,
'margin_amount_return_date' => !empty($params['margin_amount_return_date']) ? strtotime($params['margin_amount_return_date']) : 0,
'is_internal_resources' => $params['is_internal_resources'] ?? 0,
'project_assurance' => $params['project_assurance'] ?? 0,
'bid_project_overview' => $params['bid_project_overview'] ?? '',
'project_desc' => $params['project_desc'] ?? '',
'annex' => !empty($params['annex']) ? $params['annex'] : null,
'update_time' => time(),
]);
Db::commit();
return true;
} catch (\Exception $e) {
@ -134,13 +144,22 @@ class BidBiddingDecisionLogic extends BaseLogic
*/
public static function detail($params): array
{
$bidBiddingDecision = BidBiddingDecision::findOrEmpty($params['id']);
$bidBiddingDecision->custom = null;
if (!empty($bidBiddingDecision->project->custom_id)) {
$bidBiddingDecision->custom = Custom::findOrEmpty($bidBiddingDecision->project->custom_id);
}
$bidBiddingDecision->project;
$bidBiddingDecision->annex = json_decode($bidBiddingDecision->annex, true);
return $bidBiddingDecision->toArray();
$data = BidBiddingDecision::findOrEmpty($params['id']);
$org = Orgs::field('name')->where('id',$data['org_id'])->findOrEmpty();
$dept = Dept::field('name')->where('id',$data['dept_id'])->findOrEmpty();
$project = Project::field('custom_id,name,project_code')->where('id',$data['project_id'])->findOrEmpty();
$custom = Custom::field('name')->where('id',$project['custom_id'])->findOrEmpty();
$data['org_name'] = $org['name'];
$data['dept_name'] = $dept['name'];
$data['project_name'] = $project['name'];
$data['project_code'] = $project['project_code'];
$data['custom_name'] = $custom['name'];
$data['bidding_project_fund_source'] = $data->bidding_project_fund_source_text;
$data['bid_type'] = $data->bid_type_text;
$data['is_margin'] = $data->is_margin_text;
$data['is_internal_resources'] = $data->is_internal_resources_text;
$data['project_assurance'] = $data->project_assurance_text;
unset($data['org_id'],$data['dept_id'],$data['project_id'],$data['delete_time']);
return $data->toArray();
}
}

View File

@ -61,7 +61,7 @@ class ProjectFollowUpLogic extends BaseLogic
'file' => !empty($params['file']) ? $params['file'] : null,
]);
Project::where('id', $params['project_id'])->update([
'status' => 6,
'status' => 1,
'update_time' => time()
]);
Db::commit();

View File

@ -75,7 +75,7 @@ class ProjectLogic extends BaseLogic
'industry' => $params['industry'] ?? 0,
'unit_nature' => $params['unit_nature'] ?? 0,
'annex' => $params['annex'] ?? null,
'status' => 1,
'status' => 0,
'add_user' => $adminId
]);
Db::commit();

View File

@ -15,6 +15,10 @@
namespace app\adminapi\validate\bid;
use app\common\model\dept\Dept;
use app\common\model\dept\Orgs;
use app\common\model\dict\DictData;
use app\common\model\project\Project;
use app\common\validate\BaseValidate;
@ -32,19 +36,39 @@ class BidBiddingDecisionValidate extends BaseValidate
*/
protected $rule = [
'id' => 'require',
'project_id' => 'require',
'approve_id' => 'require',
'project_estimation' => 'require',
'org_id' => 'require|checkOrg',
'dept_id' => 'require|checkDept',
'project_id' => 'require|checkProject',
'project_estimation' => 'require|float|egt:0',
'bidding_project_fund_source' => 'checkBiddingProjectFundSource',
'bidding_time' => 'dateFormat:Y-m-d',
'buy_bid_document_date' => 'dateFormat:Y-m-d',
'bid_type' => 'checkBidType',
'is_margin' => 'in:0,1',
'margin_amount' => 'float|egt:0',
'bid_opening_date' => 'dateFormat:Y-m-d',
'margin_amount_return_date' => 'dateFormat:Y-m-d',
'is_internal_resources' => 'in:0,1',
'project_assurance' => 'checkProjectAssurance',
'annex' => 'checkAnnex'
];
/**
* 参数描述
* @var string[]
*/
protected $field = [
'id' => 'id',
'project_estimation' => '项目估算',
protected $message = [
'id.require' => '缺少必要参数',
'org_id.require' => '请选择组织',
'dept_id.require' => '请选择部门',
'project_id.require' => '请选择项目',
'project_estimation.require' => '请填写项目估算',
'project_estimation.float' => '项目估算值必须是数字',
'project_estimation.egt' => '项目估算值必须大于等于0',
'bidding_time.dateFormat' => '投标时间数据格式错误',
'buy_bid_document_date.dateFormat' => '购买标书时间数据格式错误',
'is_margin.in' => '是否需要保证金选项值错误',
'margin_amount.float' => '保证金金额值必须是数字',
'margin_amount.egt' => '保证金金额值必须大于等于0',
'bid_opening_date.dateFormat' => '开标日期数据格式错误',
'margin_amount_return_date.dateFormat' => '保证金退还时间数据格式错误',
'is_internal_resources.in' => '有无内部资源选项值错误',
];
@ -67,9 +91,7 @@ class BidBiddingDecisionValidate extends BaseValidate
* @date 2023/11/27 18:14
*/
public function sceneEdit()
{
return $this->only(['id', 'project_id', 'approve_id', 'project_estimation']);
}
{}
/**
@ -94,5 +116,76 @@ class BidBiddingDecisionValidate extends BaseValidate
{
return $this->only(['id']);
}
public function checkOrg($value): bool|string
{
$org = Orgs::where('id',$value)->findOrEmpty();
if($org->isEmpty()){
return '组织不存在';
}
return true;
}
public function checkDept($value,$rule,$data): bool|string
{
$dept = Dept::where('id',$value)->findOrEmpty();
if($dept->isEmpty()){
return '部门不存在';
}
if($dept['org_id'] != $data['org_id']){
return '部门无效';
}
return true;
}
public function checkProject($value): bool|string
{
$project = Project::where('id',$value)->findOrEmpty();
if($project->isEmpty()){
return '项目不存在';
}
if($project['status'] >= 2){
return '当前项目已投标';
}
return true;
}
public function checkBiddingProjectFundSource($value): bool|string
{
$dictData = DictData::where('type_value','construction_funds_sources')->column('value');
if(!in_array($value,$dictData)){
return '招标项目资金来源无效';
}
return true;
}
public function checkBidType($value): bool|string
{
$dictData = DictData::where('type_value','bidding_method')->column('value');
if(!in_array($value,$dictData)){
return '招标方式无效';
}
return true;
}
public function checkProjectAssurance($value): bool|string
{
$dictData = DictData::where('type_value','project_assurance')->column('value');
if(!in_array($value,$dictData)){
return '项目把握度无效';
}
return true;
}
public function checkAnnex($value): bool|string
{
if(!empty($value) && $value != ''){
$annex = json_decode($value,true);
if(empty($annex) || !is_array($annex)){
return '附件格式错误';
}
}
return true;
}
}

View File

@ -16,6 +16,7 @@ namespace app\common\model\bid;
use app\common\model\BaseModel;
use app\common\model\dict\DictData;
use think\model\concern\SoftDelete;
@ -30,29 +31,56 @@ class BidBiddingDecision extends BaseModel
protected $name = 'bid_bidding_decision';
protected $deleteTime = 'delete_time';
public function project()
public function getBiddingTimeAttr($value): string
{
return $this->belongsTo(\app\common\model\project\Project::class, 'project_id');
return empty($value) ? '' : date('Y-m-d', $value);
}
public function getBiddingTimeAttr($value)
public function getBuyBidDocumentDateAttr($value): string
{
return empty($value) ? '' : date('Y-m-d H:i:s', $value);
return empty($value) ? '' : date('Y-m-d', $value);
}
public function getBuyBidDocumentDateAttr($value)
public function getBidOpeningDateAttr($value): string
{
return empty($value) ? '' : date('Y-m-d H:i:s', $value);
return empty($value) ? '' : date('Y-m-d', $value);
}
public function getBidOpeningDateAttr($value)
public function getMarginAmountReturnDateAttr($value): string
{
return empty($value) ? '' : date('Y-m-d H:i:s', $value);
}
public function getMarginAmountReturnDateAttr($value)
{
return empty($value) ? '' : date('Y-m-d H:i:s', $value);
return empty($value) ? '' : date('Y-m-d', $value);
}
public function getBiddingProjectFundSourceTextAttr($value,$data){
$dictData = DictData::where('type_value','construction_funds_sources')->column('name','value');
return $dictData[$data['bidding_project_fund_source']];
}
public function getBidTypeTextAttr($value,$data){
$dictData = DictData::where('type_value','bidding_method')->column('name','value');
return $dictData[$data['bid_type']];
}
public function getProjectAssuranceTextAttr($value,$data){
$dictData = DictData::where('type_value','project_assurance')->column('name','value');
return $dictData[$data['project_assurance']];
}
public function getIsMarginTextAttr($value,$data): string
{
$is_margin = [0=>'否', 1=>'是'];
return $is_margin[$data['is_margin']];
}
public function getIsInternalResourcesTextAttr($value,$data): string
{
$is_internal_resources = [0=>'无', 1=>'有'];
return $is_internal_resources[$data['is_internal_resources']];
}
public function getAnnexAttr($value)
{
return empty($value) ? null : json_decode($value,true);
}
}