Merge pull request 'update' (#122) from zhangwei into dev
Reviewed-on: #122
This commit is contained in:
commit
1478ee590c
@ -52,7 +52,7 @@ class BidResultController extends BaseAdminController
|
||||
public function add()
|
||||
{
|
||||
$params = (new BidResultValidate())->post()->goCheck('add');
|
||||
$result = BidResultLogic::add($params);
|
||||
$result = BidResultLogic::add($params,$this->adminId);
|
||||
if (true === $result) {
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
@ -69,7 +69,7 @@ class BidResultController extends BaseAdminController
|
||||
public function edit()
|
||||
{
|
||||
$params = (new BidResultValidate())->post()->goCheck('edit');
|
||||
$result = BidResultLogic::edit($params);
|
||||
$result = BidResultLogic::edit($params,$this->adminId);
|
||||
if (true === $result) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
|
@ -16,8 +16,13 @@ namespace app\adminapi\lists\bid;
|
||||
|
||||
|
||||
use app\adminapi\lists\BaseAdminDataLists;
|
||||
use app\common\model\bid\BidBiddingDecision;
|
||||
use app\common\model\bid\BidBuyBiddingDocument;
|
||||
use app\common\model\bid\BidDocumentExamination;
|
||||
use app\common\model\bid\BidResult;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\custom\Custom;
|
||||
use app\common\model\project\Project;
|
||||
|
||||
|
||||
/**
|
||||
@ -54,11 +59,34 @@ class BidResultLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
return BidResult::where($this->searchWhere)
|
||||
->field(['*'])
|
||||
$params = $this->request->get(['bid_document_examination_code','project_name']);
|
||||
$where = [];
|
||||
if(isset($params['bid_document_examination_code']) && $params['bid_document_examination_code'] != ''){
|
||||
$bid_document_examination_ids = BidDocumentExamination::where('code','like','%'.$params['bid_document_examination_code'].'%')->column('id');
|
||||
$where[] = ['bid_document_examination_id','in',$bid_document_examination_ids];
|
||||
}
|
||||
if(isset($params['project_name']) && $params['project_name'] != ''){
|
||||
$project_ids = Project::where('code','like','%'.$params['project_name'].'%')->column('id');
|
||||
$where[] = ['project_id','in',$project_ids];
|
||||
}
|
||||
return BidResult::where($this->searchWhere)->where($where)
|
||||
->field('id,bid_document_examination_id,project_id,is_successful,bidder_company,bidder_amount')
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()
|
||||
->select()->each(function($data){
|
||||
$project = Project::field('name,project_code,custom_id')->where('id',$data['project_id'])->findOrEmpty();
|
||||
$custom = Custom::field('name')->where('id',$project['custom_id'])->findOrEmpty();
|
||||
$bid_document_examination = BidDocumentExamination::field('code,buy_bidding_document_id')->where('id',$data['bid_document_examination_id'])->findOrEmpty();
|
||||
$buy_bidding_document = BidBuyBiddingDocument::field('bid_decision_id')->where('id',$bid_document_examination['buy_bidding_document_id'])->findOrEmpty();
|
||||
$bid_decision = BidBiddingDecision::field('bidding_time,bid_opening_date')->where('id',$buy_bidding_document['bid_decision_id'])->findOrEmpty();
|
||||
$data['project_name'] = $project['name'];
|
||||
$data['project_code'] = $project['project_code'];
|
||||
$data['custom_name'] = $custom['name'];
|
||||
$data['bid_document_examination_code'] = $bid_document_examination['code'];
|
||||
$data['bidding_time'] = $bid_decision['bidding_time'];
|
||||
$data['bid_opening_date'] = $bid_decision['bid_opening_date'];
|
||||
$data['is_successful_text'] = $data->is_successful_text;
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
|
||||
@ -71,7 +99,17 @@ class BidResultLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return BidResult::where($this->searchWhere)->count();
|
||||
$params = $this->request->get(['bid_document_examination_code','project_name']);
|
||||
$where = [];
|
||||
if(isset($params['bid_document_examination_code']) && $params['bid_document_examination_code'] != ''){
|
||||
$bid_document_examination_ids = BidDocumentExamination::where('code','like','%'.$params['bid_document_examination_code'].'%')->column('id');
|
||||
$where[] = ['bid_document_examination_id','in',$bid_document_examination_ids];
|
||||
}
|
||||
if(isset($params['project_name']) && $params['project_name'] != ''){
|
||||
$project_ids = Project::where('code','like','%'.$params['project_name'].'%')->column('id');
|
||||
$where[] = ['project_id','in',$project_ids];
|
||||
}
|
||||
return BidResult::where($this->searchWhere)->where($where)->count();
|
||||
}
|
||||
|
||||
}
|
@ -15,9 +15,16 @@
|
||||
namespace app\adminapi\logic\bid;
|
||||
|
||||
|
||||
use app\common\model\auth\Admin;
|
||||
use app\common\model\bid\BidBiddingDecision;
|
||||
use app\common\model\bid\BidBuyBiddingDocument;
|
||||
use app\common\model\bid\BidDocumentExamination;
|
||||
use app\common\model\bid\BidResult;
|
||||
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;
|
||||
|
||||
|
||||
@ -37,21 +44,24 @@ class BidResultLogic extends BaseLogic
|
||||
* @author likeadmin
|
||||
* @date 2023/12/02 14:54
|
||||
*/
|
||||
public static function add(array $params): bool
|
||||
public static function add(array $params,$admin_id): bool
|
||||
{
|
||||
$bid_document_examination = BidDocumentExamination::field('project_id')->where('id',$params['bid_document_examination_id'])->findOrEmpty();
|
||||
Db::startTrans();
|
||||
try {
|
||||
BidResult::create([
|
||||
'bid_document_examination_id' => $params['bid_document_examination_id'] ?? 0,
|
||||
'project_id' => $params['project_id'] ?? 0,
|
||||
'is_successful' => $params['is_successful'] ?? 0,
|
||||
'bidder' => $params['bidder'] ?? '',
|
||||
'bidder_amount' => $params['bidder_amount'] ?? 0,
|
||||
'bidder_amount_daxie' => $params['bidder_amount_daxie'] ?? '',
|
||||
'org_id' => $params['org_id'],
|
||||
'dept_id' => $params['dept_id'],
|
||||
'bid_document_examination_id' => $params['bid_document_examination_id'],
|
||||
'project_id' => $bid_document_examination['project_id'],
|
||||
'is_successful' => $params['is_successful'],
|
||||
'bidder_company' => $params['bidder_company'],
|
||||
'bidder_amount' => $params['bidder_amount'],
|
||||
'bid_summary' => $params['bid_summary'] ?? '',
|
||||
'annex' => $params['annex'] ?? '',
|
||||
'annex' => !empty($params['annex']) ? $params['annex'] : null,
|
||||
'add_user' => $admin_id,
|
||||
'update_user' => $admin_id,
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
@ -69,21 +79,22 @@ class BidResultLogic extends BaseLogic
|
||||
* @author likeadmin
|
||||
* @date 2023/12/02 14:54
|
||||
*/
|
||||
public static function edit(array $params): bool
|
||||
public static function edit(array $params,$admin_id): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
BidResult::where('id', $params['id'])->update([
|
||||
'bid_document_examination_id' => $params['bid_document_examination_id'] ?? 0,
|
||||
'project_id' => $params['project_id'] ?? 0,
|
||||
'is_successful' => $params['is_successful'] ?? 0,
|
||||
'bidder' => $params['bidder'] ?? '',
|
||||
'bidder_amount' => $params['bidder_amount'] ?? 0,
|
||||
'bidder_amount_daxie' => $params['bidder_amount_daxie'] ?? '',
|
||||
'bid_summary' => $params['bid_summary'] ?? '',
|
||||
'annex' => $params['annex'] ?? '',
|
||||
'org_id' => $params['org_id'],
|
||||
'dept_id' => $params['dept_id'],
|
||||
'bid_document_examination_id' => $params['bid_document_examination_id'],
|
||||
'is_successful' => $params['is_successful'],
|
||||
'bidder_company' => $params['bidder_company'],
|
||||
'bidder_amount' => $params['bidder_amount'],
|
||||
'bid_summary' => $params['bid_summary'] ?? '',
|
||||
'annex' => !empty($params['annex']) ? $params['annex'] : null,
|
||||
'update_user' => $admin_id,
|
||||
'update_time' => time(),
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
@ -116,14 +127,26 @@ class BidResultLogic extends BaseLogic
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
$bidResult = BidResult::findOrEmpty($params['id']);
|
||||
$bidResult->custom = null;
|
||||
if (!empty($bidResult->project->custom_id)) {
|
||||
$bidResult->custom = Custom::findOrEmpty($bidResult->project->custom_id);
|
||||
}
|
||||
$bidResult->project;
|
||||
$bidResult->examination;
|
||||
$bidResult->annex = json_decode($bidResult->annex, true);
|
||||
return $bidResult->toArray();
|
||||
$data = BidResult::field('id,org_id,dept_id,bid_document_examination_id,project_id,is_successful,bidder_company,bidder_amount,bid_summary,annex,add_user,update_user,create_time,update_time')->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('name,project_code,custom_id')->where('id',$data['project_id'])->findOrEmpty();
|
||||
$custom = Custom::field('name')->where('id',$project['custom_id'])->findOrEmpty();
|
||||
$bid_document_examination = BidDocumentExamination::field('code,buy_bidding_document_id')->where('id',$data['bid_document_examination_id'])->findOrEmpty();
|
||||
$buy_bidding_document = BidBuyBiddingDocument::field('bid_decision_id')->where('id',$bid_document_examination['buy_bidding_document_id'])->findOrEmpty();
|
||||
$bid_decision = BidBiddingDecision::field('bidding_time,bid_opening_date')->where('id',$buy_bidding_document['bid_decision_id'])->findOrEmpty();
|
||||
$admin = Admin::where('id','in',[$data['add_user'],$data['update_user']])->column('name','id');
|
||||
$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['bid_document_examination_code'] = $bid_document_examination['code'];
|
||||
$data['bidding_time'] = $bid_decision['bidding_time'];
|
||||
$data['bid_opening_date'] = $bid_decision['bid_opening_date'];
|
||||
$data['is_successful_text'] = $data->is_successful_text;
|
||||
$data['add_user_name'] = $admin[$data['add_user']];
|
||||
$data['update_user_name'] = $admin[$data['update_user']];
|
||||
return $data->toArray();
|
||||
}
|
||||
}
|
@ -15,6 +15,9 @@
|
||||
namespace app\adminapi\validate\bid;
|
||||
|
||||
|
||||
use app\common\model\bid\BidDocumentExamination;
|
||||
use app\common\model\dept\Dept;
|
||||
use app\common\model\dept\Orgs;
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
|
||||
@ -32,20 +35,26 @@ class BidResultValidate extends BaseValidate
|
||||
*/
|
||||
protected $rule = [
|
||||
'id' => 'require',
|
||||
'project_id' => 'require',
|
||||
'bid_document_examination_id'=> 'require',
|
||||
'is_successful' => 'require',
|
||||
'bidder' => 'require',
|
||||
'bidder_amount' => 'require',
|
||||
'org_id' => 'require|checkOrg',
|
||||
'dept_id' => 'require|checkDept',
|
||||
'bid_document_examination_id'=> 'require|checkBidDocumentExamination',
|
||||
'is_successful' => 'require|in:0,1',
|
||||
'bidder_company' => 'require',
|
||||
'bidder_amount' => 'require|float|egt:0',
|
||||
'annex' => 'checkAnnex'
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* 参数描述
|
||||
* @var string[]
|
||||
*/
|
||||
protected $field = [
|
||||
'id' => 'id',
|
||||
|
||||
protected $message = [
|
||||
'id.require' => '缺少必要参数',
|
||||
'org_id.require' => '请选择组织',
|
||||
'dept_id.require' => '请选择部门',
|
||||
'bid_document_examination_id.require'=> '请选择投标编号',
|
||||
'is_successful.require' => '请选择是否中标',
|
||||
'is_successful.in' => '是否中标选项无效',
|
||||
'bidder_company.require' => '请填写中标单位',
|
||||
'bidder_amount.require' => '请填写中标金额',
|
||||
'bidder_amount.float' => '中标金额值必须是数字',
|
||||
'bidder_amount.egt' => '中标金额值必须大于等于0',
|
||||
];
|
||||
|
||||
|
||||
@ -68,9 +77,7 @@ class BidResultValidate extends BaseValidate
|
||||
* @date 2023/12/02 14:54
|
||||
*/
|
||||
public function sceneEdit()
|
||||
{
|
||||
return $this->only(['id', 'project_id', 'bid_document_examination_id', 'is_successful', 'bidder', 'bidder_amount']);
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
/**
|
||||
@ -95,5 +102,46 @@ class BidResultValidate 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 checkBidDocumentExamination($value): bool|string
|
||||
{
|
||||
$data = BidDocumentExamination::where('id',$value)->findOrEmpty();
|
||||
if($data->isEmpty()){
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
@ -30,15 +30,16 @@ class BidResult extends BaseModel
|
||||
use SoftDelete;
|
||||
protected $name = 'bid_result';
|
||||
protected $deleteTime = 'delete_time';
|
||||
|
||||
public function project()
|
||||
{
|
||||
return $this->belongsTo(\app\common\model\project\Project::class, 'project_id');
|
||||
}
|
||||
|
||||
public function examination()
|
||||
{
|
||||
return $this->belongsTo(\app\common\model\bid\BidDocumentExamination::class, 'bid_document_examination_id');
|
||||
}
|
||||
|
||||
public function getIsSuccessfulTextAttr($value,$data): string
|
||||
{
|
||||
$is_successful = [0=>'否', 1=>'是'];
|
||||
return $is_successful[$data['is_successful']];
|
||||
}
|
||||
|
||||
public function getAnnexAttr($value)
|
||||
{
|
||||
return empty($value) ? null : json_decode($value,true);
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user