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

Reviewed-on: #115
This commit is contained in:
weiz 2024-01-05 14:51:07 +08:00
commit 5ddeda8912
7 changed files with 220 additions and 109 deletions

View File

@ -58,38 +58,7 @@ class BidBuyBiddingDocumentController extends BaseAdminController
}
return $this->fail(BidBuyBiddingDocumentLogic::getError());
}
/**
* @notes 编辑购买标书
* @return \think\response\Json
* @author likeadmin
* @date 2023/11/27 18:22
*/
public function edit()
{
$params = (new BidBuyBiddingDocumentValidate())->post()->goCheck('edit');
$result = BidBuyBiddingDocumentLogic::edit($params);
if (true === $result) {
return $this->success('编辑成功', [], 1, 1);
}
return $this->fail(BidBuyBiddingDocumentLogic::getError());
}
/**
* @notes 删除购买标书
* @return \think\response\Json
* @author likeadmin
* @date 2023/11/27 18:22
*/
public function delete()
{
$params = (new BidBuyBiddingDocumentValidate())->post()->goCheck('delete');
BidBuyBiddingDocumentLogic::delete($params);
return $this->success('删除成功', [], 1, 1);
}
/**
* @notes 获取购买标书详情

View File

@ -16,8 +16,11 @@ namespace app\adminapi\lists\bid;
use app\adminapi\lists\BaseAdminDataLists;
use app\common\model\auth\Admin;
use app\common\model\bid\BidBuyBiddingDocument;
use app\common\lists\ListsSearchInterface;
use app\common\model\custom\Custom;
use app\common\model\project\Project;
use think\facade\Db;
@ -39,7 +42,8 @@ class BidBuyBiddingDocumentLists extends BaseAdminDataLists implements ListsSear
public function setSearch(): array
{
return [
'=' => ['project_id', 'bid_document_no', 'invite_tenders_company_name', 'bid_company_name'],
'%like%' => ['code', 'bid_document_no', 'invite_tenders_company_name', 'bid_company_name'],
'=' => ['project_id']
];
}
@ -55,21 +59,32 @@ class BidBuyBiddingDocumentLists extends BaseAdminDataLists implements ListsSear
*/
public function lists(): array
{
return Db::name('BidBuyBiddingDocument')->alias('bbbd')
->where($this->searchWhere)
->whereNull('bbbd.delete_time')
->leftJoin('project p','p.id = bbbd.project_id')
->leftJoin('custom ct','ct.id = p.custom_id')
->field('bbbd.*, bbbd.project_id, p.name as project_name, p.project_code, ct.name as customer_name')
$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 BidBuyBiddingDocument::field('id,org_id,dept_id,project_id,code,bid_document_no,invite_tenders_company_name,bid_company_name,buyer,amount,project_fund_source,bid_date,buy_date,invite_tenders_type,bid_address,is_margin,margin_amount,bid_project_overview,project_desc,annex')
->where($this->searchWhere)->where($where)
->limit($this->limitOffset, $this->limitLength)
->order(['bbbd.id' => 'desc'])
->select()->each(function($item, $key){
//关联数据后续添加
$item['approve_no'] = '付款单号';
$item['approve_step'] = '流程步骤';
$item['approve_settle_status'] = 1;
$item['bid_date'] = empty($item['bid_date']) ? '' : date('Y-m-d H:i:s', $item['bid_date']);
$item['buy_date'] = empty($item['buy_date']) ? '' : date('Y-m-d H:i:s', $item['buy_date']);
->order(['id' => 'desc'])
->select()->each(function($item){
$project = Project::field('custom_id,name,project_code')->where('id',$item['project_id'])->findOrEmpty();
$custom = Custom::field('name')->where('id',$project['custom_id'])->findOrEmpty();
$admin = Admin::field('name')->where('id',$item['buyer'])->findOrEmpty();
$item['project_name'] = $project['name'];
$item['project_code'] = $project['project_code'];
$item['custom_name'] = $custom['name'];
$item['buyer'] = $admin['name'];
$item['project_fund_source'] = $item->project_fund_source_text;
$item['invite_tenders_type'] = $item->invite_tenders_type_text;
$item['is_margin'] = $item->is_margin_text;
return $item;
})
->toArray();
@ -84,11 +99,18 @@ class BidBuyBiddingDocumentLists extends BaseAdminDataLists implements ListsSear
*/
public function count(): int
{
return Db::name('BidBuyBiddingDocument')->alias('bbbd')
->where($this->searchWhere)
->whereNull('bbbd.delete_time')
->leftJoin('project p','p.id = bbbd.project_id')
->leftJoin('custom ct','ct.id = p.custom_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 BidBuyBiddingDocument::where($this->searchWhere)->where($where)->count();
}
}

View File

@ -91,7 +91,6 @@ class BidBiddingDecisionLogic extends BaseLogic
Db::startTrans();
try {
BidBiddingDecision::where('id', $params['id'])->update([
'code' => data_unique_code('投标决策'),
'org_id' => $params['org_id'],
'dept_id' => $params['dept_id'],
'project_id' => $params['project_id'],

View File

@ -15,9 +15,13 @@
namespace app\adminapi\logic\bid;
use app\common\model\auth\Admin;
use app\common\model\bid\BidBuyBiddingDocument;
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 +46,26 @@ class BidBuyBiddingDocumentLogic extends BaseLogic
Db::startTrans();
try {
BidBuyBiddingDocument::create([
'project_id' => $params['project_id'] ?? 0,
'approve_id' => $params['approve_id'] ?? 0,
'bid_document_no' => $params['bid_document_no'] ?? '',
'invite_tenders_company_name' => $params['invite_tenders_company_name'] ?? '',
'bid_company_name' => $params['bid_company_name'] ?? '',
'org_id' => $params['org_id'],
'dept_id' => $params['dept_id'],
'code' => data_unique_code('购买标书'),
'project_id' => $params['project_id'],
'bid_document_no' => $params['bid_document_no'],
'invite_tenders_company_name' => $params['invite_tenders_company_name'],
'bid_company_name' => $params['bid_company_name'],
'buyer' => $params['buyer'] ?? 0,
'amount' => $params['amount'] ?? 0,
'project_fund_source' => $params['project_fund_source'] ?? 0,
'bid_date' => strtotime($params['bid_date']),
'buy_date' => strtotime($params['buy_date']),
'bid_date' => !empty($params['bid_date']) ? strtotime($params['bid_date']) : 0,
'buy_date' => !empty($params['buy_date']) ? strtotime($params['buy_date']) : 0,
'invite_tenders_type' => $params['invite_tenders_type'] ?? 0,
'bid_address' => $params['bid_address'] ?? '',
'is_margin' => $params['is_margin'] ?? 0,
'margin_amount' => $params['margin_amount'] ?? 0,
'bid_project_overview' => $params['bid_project_overview'] ?? '',
'project_desc' => $params['project_desc'] ?? '',
'annex' => $params['annex'] ?? '',
'annex' => !empty($params['annex']) ? $params['annex'] : null,
]);
Db::commit();
return true;
} catch (\Exception $e) {
@ -83,24 +88,26 @@ class BidBuyBiddingDocumentLogic extends BaseLogic
Db::startTrans();
try {
BidBuyBiddingDocument::where('id', $params['id'])->update([
'project_id' => $params['project_id'],
'bid_document_no' => $params['bid_document_no'],
'invite_tenders_company_name' => $params['invite_tenders_company_name'],
'bid_company_name' => $params['bid_company_name'],
'buyer' => $params['buyer'],
'amount' => $params['amount'],
'project_fund_source' => $params['project_fund_source'],
'bid_date' => strtotime($params['bid_date']),
'buy_date' => strtotime($params['buy_date']),
'invite_tenders_type' => $params['invite_tenders_type'],
'bid_address' => $params['bid_address'],
'is_margin' => $params['is_margin'],
'margin_amount' => $params['margin_amount'],
'bid_project_overview' => $params['bid_project_overview'],
'project_desc' => $params['project_desc'],
'annex' => $params['annex']
'org_id' => $params['org_id'],
'dept_id' => $params['dept_id'],
'project_id' => $params['project_id'],
'bid_document_no' => $params['bid_document_no'],
'invite_tenders_company_name' => $params['invite_tenders_company_name'],
'bid_company_name' => $params['bid_company_name'],
'buyer' => $params['buyer'] ?? 0,
'amount' => $params['amount'] ?? 0,
'project_fund_source' => $params['project_fund_source'] ?? 0,
'bid_date' => !empty($params['bid_date']) ? strtotime($params['bid_date']) : 0,
'buy_date' => !empty($params['buy_date']) ? strtotime($params['buy_date']) : 0,
'invite_tenders_type' => $params['invite_tenders_type'] ?? 0,
'bid_address' => $params['bid_address'] ?? '',
'is_margin' => $params['is_margin'] ?? 0,
'margin_amount' => $params['margin_amount'] ?? 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) {
@ -133,13 +140,21 @@ class BidBuyBiddingDocumentLogic extends BaseLogic
*/
public static function detail($params): array
{
$bidBuyBiddingDocument = BidBuyBiddingDocument::findOrEmpty($params['id']);
$bidBuyBiddingDocument->project;
$bidBuyBiddingDocument->custom = null;
if (!empty($bidBuyBiddingDocument->project->custom_id)) {
$bidBuyBiddingDocument->custom = Custom::findOrEmpty($bidBuyBiddingDocument->project->custom_id);
}
$bidBuyBiddingDocument->annex = json_decode($bidBuyBiddingDocument->annex, true);
return $bidBuyBiddingDocument->toArray();
$data = BidBuyBiddingDocument::field('id,org_id,dept_id,project_id,code,bid_document_no,invite_tenders_company_name,bid_company_name,buyer,amount,project_fund_source,bid_date,buy_date,invite_tenders_type,bid_address,is_margin,margin_amount,bid_project_overview,project_desc,annex')->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();
$admin = Admin::field('name')->where('id',$data['buyer'])->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['buyer'] = $admin['name'];
$data['project_fund_source'] = $data->project_fund_source_text;
$data['invite_tenders_type'] = $data->invite_tenders_type_text;
$data['is_margin'] = $data->is_margin_text;
return $data->toArray();
}
}

View File

@ -144,9 +144,6 @@ class BidBiddingDecisionValidate extends BaseValidate
if($project->isEmpty()){
return '项目不存在';
}
if($project['status'] >= 2){
return '当前项目已投标';
}
return true;
}

View File

@ -15,6 +15,11 @@
namespace app\adminapi\validate\bid;
use app\common\model\auth\Admin;
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,17 +37,38 @@ class BidBuyBiddingDocumentValidate extends BaseValidate
*/
protected $rule = [
'id' => 'require',
'project_id' => 'require',
'approve_id' => 'require',
'org_id' => 'require|checkOrg',
'dept_id' => 'require|checkDept',
'project_id' => 'require|checkProject',
'bid_document_no' => 'require',
'invite_tenders_company_name' => 'require',
'bid_company_name' => 'require',
'buyer' => 'checkBuyer',
'amount' => 'float|egt:0',
'project_fund_source' => 'checkProjectFundSource',
'bid_date' => 'dateFormat:Y-m-d',
'buy_date' => 'dateFormat:Y-m-d',
'invite_tenders_type' => 'checkInviteTendersType',
'is_margin' => 'in:0,1',
'margin_amount' => 'float|egt:0',
'annex' => 'checkAnnex',
];
/**
* 参数描述
* @var string[]
*/
protected $field = [
'id' => 'id',
protected $message = [
'id.require' => '缺少必要参数',
'org_id.require' => '请选择组织',
'dept_id.require' => '请选择部门',
'project_id.require' => '请选择项目',
'bid_document_no.require' => '请填写标书编号',
'invite_tenders_company_name.require' => '请填写招标公司名称',
'bid_company_name.require' => '请填写投标公司名称',
'amount.float' => '购买标书金额值必须是数字',
'amount.egt' => '购买标书金额值必须大于等于0',
'bid_date.dateFormat' => '投标时间数据格式错误',
'buy_date.dateFormat' => '购买标书时间数据格式错误',
'is_margin.in' => '是否需要保证金选项数据错误',
'margin_amount.float' => '保证金金额值必须是数字',
'margin_amount.egt' => '保证金金额值必须大于等于0',
];
@ -65,9 +91,7 @@ class BidBuyBiddingDocumentValidate extends BaseValidate
* @date 2023/11/27 18:22
*/
public function sceneEdit()
{
return $this->only(['id', 'project_id', 'approve_id']);
}
{}
/**
@ -92,5 +116,73 @@ class BidBuyBiddingDocumentValidate 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 '项目不存在';
}
return true;
}
public function checkBuyer($value): bool|string
{
$admin = Admin::where('id',$value)->findOrEmpty();
if($admin->isEmpty()){
return '购买人员信息不存在';
}
return true;
}
public function checkProjectFundSource($value): bool|string
{
$dictData = DictData::where('type_value','construction_funds_sources')->column('value');
if(!in_array($value,$dictData)){
return '招标项目资金来源无效';
}
return true;
}
public function checkInviteTendersType($value): bool|string
{
$dictData = DictData::where('type_value','bidding_method')->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;
@ -29,20 +30,36 @@ class BidBuyBiddingDocument extends BaseModel
use SoftDelete;
protected $name = 'bid_buy_bidding_document';
protected $deleteTime = 'delete_time';
public function getAnnexAttr($value)
{
return empty($value) ? null : json_decode($value,true);
}
public function project()
{
return $this->belongsTo(\app\common\model\project\Project::class, 'project_id');
}
public function getBidDateAttr($value)
public function getBidDateAttr($value): string
{
return empty($value) ? '' : date('Y-m-d', $value);
}
public function getBuyDateAttr($value)
public function getBuyDateAttr($value): string
{
return empty($value) ? '' : date('Y-m-d', $value);
}
public function getIsMarginTextAttr($value,$data): string
{
$is_margin = [0=>'否', 1=>'是'];
return $is_margin[$data['is_margin']];
}
public function getProjectFundSourceTextAttr($value,$data){
$dictData = DictData::where('type_value','construction_funds_sources')->column('name','value');
return $dictData[$data['project_fund_source']];
}
public function getInviteTendersTypeTextAttr($value,$data){
$dictData = DictData::where('type_value','bidding_method')->column('name','value');
return $dictData[$data['invite_tenders_type']];
}
}