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()); 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 获取投标决策详情 * @notes 获取投标决策详情
* @return \think\response\Json * @return \think\response\Json

View File

@ -18,7 +18,8 @@ namespace app\adminapi\lists\bid;
use app\adminapi\lists\BaseAdminDataLists; use app\adminapi\lists\BaseAdminDataLists;
use app\common\model\bid\BidBiddingDecision; use app\common\model\bid\BidBiddingDecision;
use app\common\lists\ListsSearchInterface; 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 public function setSearch(): array
{ {
return [ 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 public function lists(): array
{ {
return Db::name('BidBiddingDecision')->alias('bbd') $params = $this->request->get(['project_name','custom_name']);
->where($this->searchWhere) $where = [];
->whereNull('bbd.delete_time') if(isset($params['project_name']) && $params['project_name'] != ''){
->leftJoin('project p','p.id = bbd.project_id') $project_ids = Project::where('name','like','%'.$params['project_name'].'%')->column('id');
->leftJoin('custom ct','ct.id = p.custom_id') $where[] = ['project_id','in',$project_ids];
->field('bbd.*, p.custom_id, p.name as project_name, p.project_code, ct.name as custom_name') }
->limit($this->limitOffset, $this->limitLength) if(isset($params['custom_name']) && $params['custom_name'] != ''){
->order(['bbd.id' => 'desc']) $custom_ids = Custom::where('name','like','%'.$params['custom_name'].'%')->column('id');
->select()->each(function($item, $key){ $project_ids = Project::where('custom_id','in',$custom_ids)->column('id');
//关联数据后续添加 $where[] = ['project_id','in',$project_ids];
$item['approve_no'] = '付款单号'; }
$item['approve_step'] = '流程步骤'; return BidBiddingDecision::where($this->searchWhere)->where($where)->limit($this->limitOffset, $this->limitLength)
$item['approve_settle_status'] = 1; ->order(['id' => 'desc'])
$item['bidding_time'] = empty($item['bidding_time']) ? '' : date('Y-m-d H:i:s', $item['bidding_time']); ->select()->each(function($item){
$item['buy_bid_document_date'] = empty($item['buy_bid_document_date']) ? '' : date('Y-m-d H:i:s', $item['buy_bid_document_date']); $project = Project::field('custom_id,name,project_code')->where('id',$item['project_id'])->findOrEmpty();
$item['bid_opening_date'] = empty($item['bid_opening_date']) ? '' : date('Y-m-d H:i:s', $item['bid_opening_date']); $custom = Custom::field('id,name')->where('id',$project['custom_id'])->findOrEmpty();
$item['margin_amount_return_date'] = empty($item['bid_opening_date']) ? '' : date('Y-m-d H:i:s', $item['margin_amount_return_date']); $item['project_name'] = $project['name'];
return $item; $item['project_code'] = $project['project_code'];
}) $item['custom_id'] = $custom['id'];
->toArray(); $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 public function count(): int
{ {
return Db::name('BidBiddingDecision')->alias('bbd') $params = $this->request->get(['project_name','custom_name']);
->where($this->searchWhere) $where = [];
->whereNull('bbd.delete_time') if(isset($params['project_name']) && $params['project_name'] != ''){
->leftJoin('project p','p.id = bbd.project_id')->count(); $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\bid\BidBiddingDecision;
use app\common\model\custom\Custom; use app\common\model\custom\Custom;
use app\common\logic\BaseLogic; 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; use think\facade\Db;
@ -42,25 +45,30 @@ class BidBiddingDecisionLogic extends BaseLogic
Db::startTrans(); Db::startTrans();
try { try {
BidBiddingDecision::create([ BidBiddingDecision::create([
'project_id' => $params['project_id'] ?? 0, 'code' => data_unique_code('投标决策'),
'approve_id' => $params['approve_id'] ?? 0, 'org_id' => $params['org_id'],
'project_estimation' => $params['project_estimation'] ?? 0, '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_project_fund_source' => $params['bidding_project_fund_source'] ?? 0,
'bidding_time' => strtotime($params['bidding_time']), 'bidding_time' => !empty($params['bidding_time']) ? strtotime($params['bidding_time']) : 0,
'buy_bid_document_date' => strtotime($params['buy_bid_document_date']), 'buy_bid_document_date' => !empty($params['buy_bid_document_date']) ? strtotime($params['buy_bid_document_date']) : 0,
'bid_type' => $params['bid_type'] ?? 0, 'bid_type' => $params['bid_type'] ?? 0,
'competitor' => $params['competitor'] ?? '', 'competitor' => $params['competitor'] ?? '',
'is_margin' => $params['is_margin'] ?? 0, 'is_margin' => $params['is_margin'] ?? 0,
'margin_amount' => $params['margin_amount'] ?? 0, 'margin_amount' => $params['margin_amount'] ?? 0,
'bid_opening_date' => strtotime($params['bid_opening_date']), 'bid_opening_date' => !empty($params['bid_opening_date']) ? strtotime($params['bid_opening_date']) : 0,
'margin_amount_return_date' => strtotime($params['margin_amount_return_date']), '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, 'is_internal_resources' => $params['is_internal_resources'] ?? 0,
'project_assurance' => $params['project_assurance'] ?? 0, 'project_assurance' => $params['project_assurance'] ?? 0,
'bid_project_overview' => $params['bid_project_overview'] ?? '', 'bid_project_overview' => $params['bid_project_overview'] ?? '',
'project_desc' => $params['project_desc'] ?? '', '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(); Db::commit();
return true; return true;
} catch (\Exception $e) { } catch (\Exception $e) {
@ -83,25 +91,27 @@ class BidBiddingDecisionLogic extends BaseLogic
Db::startTrans(); Db::startTrans();
try { try {
BidBiddingDecision::where('id', $params['id'])->update([ BidBiddingDecision::where('id', $params['id'])->update([
'project_id' => $params['project_id'] ?? 0, 'code' => data_unique_code('投标决策'),
'approve_id' => $params['approve_id'] ?? 0, 'org_id' => $params['org_id'],
'project_estimation' => $params['project_estimation'] ?? 0, 'dept_id' => $params['dept_id'],
'bidding_project_fund_source' => $params['bidding_project_fund_source'] ?? 0, 'project_id' => $params['project_id'],
'bidding_time' => strtotime($params['bidding_time']), 'project_estimation' => $params['project_estimation'],
'buy_bid_document_date' => strtotime($params['buy_bid_document_date']), 'bidding_project_fund_source' => $params['bidding_project_fund_source'] ?? 0,
'bid_type' => $params['bid_type'] ?? 0, 'bidding_time' => !empty($params['bidding_time']) ? strtotime($params['bidding_time']) : 0,
'competitor' => $params['competitor'] ?? '', 'buy_bid_document_date' => !empty($params['buy_bid_document_date']) ? strtotime($params['buy_bid_document_date']) : 0,
'is_margin' => $params['is_margin'] ?? 0, 'bid_type' => $params['bid_type'] ?? 0,
'margin_amount' => $params['margin_amount'] ?? 0, 'competitor' => $params['competitor'] ?? '',
'bid_opening_date' => strtotime($params['bid_opening_date']), 'is_margin' => $params['is_margin'] ?? 0,
'margin_amount_return_date' => strtotime($params['margin_amount_return_date']), 'margin_amount' => $params['margin_amount'] ?? 0,
'is_internal_resources' => $params['is_internal_resources'] ?? 0, 'bid_opening_date' => !empty($params['bid_opening_date']) ? strtotime($params['bid_opening_date']) : 0,
'project_assurance' => $params['project_assurance'] ?? 0, 'margin_amount_return_date' => !empty($params['margin_amount_return_date']) ? strtotime($params['margin_amount_return_date']) : 0,
'bid_project_overview' => $params['bid_project_overview'] ?? '', 'is_internal_resources' => $params['is_internal_resources'] ?? 0,
'project_desc' => $params['project_desc'] ?? '', 'project_assurance' => $params['project_assurance'] ?? 0,
'annex' => $params['annex'] ?? '', 'bid_project_overview' => $params['bid_project_overview'] ?? '',
'project_desc' => $params['project_desc'] ?? '',
'annex' => !empty($params['annex']) ? $params['annex'] : null,
'update_time' => time(),
]); ]);
Db::commit(); Db::commit();
return true; return true;
} catch (\Exception $e) { } catch (\Exception $e) {
@ -134,13 +144,22 @@ class BidBiddingDecisionLogic extends BaseLogic
*/ */
public static function detail($params): array public static function detail($params): array
{ {
$bidBiddingDecision = BidBiddingDecision::findOrEmpty($params['id']); $data = BidBiddingDecision::findOrEmpty($params['id']);
$bidBiddingDecision->custom = null; $org = Orgs::field('name')->where('id',$data['org_id'])->findOrEmpty();
if (!empty($bidBiddingDecision->project->custom_id)) { $dept = Dept::field('name')->where('id',$data['dept_id'])->findOrEmpty();
$bidBiddingDecision->custom = Custom::findOrEmpty($bidBiddingDecision->project->custom_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();
$bidBiddingDecision->project; $data['org_name'] = $org['name'];
$bidBiddingDecision->annex = json_decode($bidBiddingDecision->annex, true); $data['dept_name'] = $dept['name'];
return $bidBiddingDecision->toArray(); $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, 'file' => !empty($params['file']) ? $params['file'] : null,
]); ]);
Project::where('id', $params['project_id'])->update([ Project::where('id', $params['project_id'])->update([
'status' => 6, 'status' => 1,
'update_time' => time() 'update_time' => time()
]); ]);
Db::commit(); Db::commit();

View File

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

View File

@ -15,6 +15,10 @@
namespace app\adminapi\validate\bid; 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; use app\common\validate\BaseValidate;
@ -32,19 +36,39 @@ class BidBiddingDecisionValidate extends BaseValidate
*/ */
protected $rule = [ protected $rule = [
'id' => 'require', 'id' => 'require',
'project_id' => 'require', 'org_id' => 'require|checkOrg',
'approve_id' => 'require', 'dept_id' => 'require|checkDept',
'project_estimation' => 'require', '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'
]; ];
protected $message = [
/** 'id.require' => '缺少必要参数',
* 参数描述 'org_id.require' => '请选择组织',
* @var string[] 'dept_id.require' => '请选择部门',
*/ 'project_id.require' => '请选择项目',
protected $field = [ 'project_estimation.require' => '请填写项目估算',
'id' => 'id', 'project_estimation.float' => '项目估算值必须是数字',
'project_estimation' => '项目估算', '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 * @date 2023/11/27 18:14
*/ */
public function sceneEdit() 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']); 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\BaseModel;
use app\common\model\dict\DictData;
use think\model\concern\SoftDelete; use think\model\concern\SoftDelete;
@ -30,29 +31,56 @@ class BidBiddingDecision extends BaseModel
protected $name = 'bid_bidding_decision'; protected $name = 'bid_bidding_decision';
protected $deleteTime = 'delete_time'; 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); return empty($value) ? '' : date('Y-m-d', $value);
}
public function getMarginAmountReturnDateAttr($value)
{
return empty($value) ? '' : date('Y-m-d H:i:s', $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);
}
} }