You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
212 lines
8.5 KiB
212 lines
8.5 KiB
3 years ago
|
<?php
|
||
|
/**
|
||
|
* Bidding.php
|
||
|
* User: ChenLong
|
||
|
* DateTime: 2020-12-21 14:07:07
|
||
|
*/
|
||
|
|
||
|
namespace app\admin\controller;
|
||
|
|
||
|
use \app\common\controller\Admin;
|
||
|
use app\common\ResponseJson;
|
||
|
use sdModule\layui\tableDetail\TableConstruct as T;
|
||
|
use think\facade\App;
|
||
|
use think\facade\Db;
|
||
|
use sdModule\image\Image;
|
||
|
|
||
|
/**
|
||
|
* Class Bidding
|
||
|
* @package app\admin\controller\Bidding
|
||
|
* @author chenlong <vip_chenlong@163.com>
|
||
|
*/
|
||
|
class Bidding extends Admin
|
||
|
{
|
||
|
/**
|
||
|
* 列表数据接口
|
||
|
* @return mixed|string|\think\Collection|\think\response\Json
|
||
|
* @throws \app\common\SdException
|
||
|
*/
|
||
|
public function listData()
|
||
|
{
|
||
|
return $this
|
||
|
->setField('i.id,i.title,i.province,i.city,i.project_title,i.purchase_unit,i.contact_person,i.contact_person_tel,i.status,i.is_urgent,i.tag_ids,i.open_bid_time,i.create_time,i.status status_1,i.contract_title,i.contractNo,i.projectNo,i.sort')
|
||
|
->setSort('sort,desc')->setSort('create_time,desc')
|
||
|
->listsRequest();
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @return array|string|\think\response\Json
|
||
|
* @throws \think\db\exception\DataNotFoundException
|
||
|
* @throws \think\db\exception\DbException
|
||
|
* @throws \think\db\exception\ModelNotFoundException
|
||
|
* @author Deng
|
||
|
* @date 2020-12-21 18:43
|
||
|
* 中标详情
|
||
|
*/
|
||
|
public function details(){
|
||
|
$id = $this->request->get('id');
|
||
|
if(!$id){
|
||
|
return ResponseJson::fail('参数错误');
|
||
|
}
|
||
|
$bidding = \app\common\model\Bidding::where(['id'=>$id])->find()->toArray();
|
||
|
$data = Db::name('tender')->alias('t')
|
||
|
->leftJoin('member m','m.id=t.member_id')
|
||
|
->where(['t.bidding_id'=>$bidding['id'],'m.delete_time'=>0,'t.delete_time'=>0])
|
||
|
->field('t.tender_price,t.create_time,t.file_id,m.username,m.mobile,m.company')
|
||
|
->find();
|
||
|
if(isset($data['file_id']) && !empty($data['file_id'])){
|
||
|
$update_file = Db::name('resource')->where('id',$data['file_id'])->find();
|
||
|
$data['update_file'] = !empty($update_file) ? '<a href="'.url('download',['tag'=>$update_file['tag'],'path'=>$update_file['path']]).'" >'.$update_file['tag'].'</a>' :'';
|
||
|
}
|
||
|
return T::data([$bidding,$data], true)->title(['标书资料','投标资料'])->render([
|
||
|
[
|
||
|
T::tr(
|
||
|
T::td('标题', 'title'),
|
||
|
T::td('省份', 'province'),
|
||
|
T::td('城市', 'city',3)
|
||
|
),
|
||
|
T::tr(
|
||
|
T::td('项目名称', 'project_title'),
|
||
|
T::td('项目编号', 'projectNo'),
|
||
|
T::td('项目所在地', 'project_address',3)
|
||
|
),
|
||
|
T::tr(
|
||
|
T::td('合同名称', 'contract_title'),
|
||
|
T::td('合同编号', 'contractNo'),
|
||
|
T::td('采购单位', 'purchase_unit',3)
|
||
|
),
|
||
|
T::tr(
|
||
|
T::td('联系人', 'contact_person'),
|
||
|
T::td('招标人', 'bidding_person'),
|
||
|
T::td('联系人电话', 'contact_person_tel'),
|
||
|
T::td('开标时间', 'open_bid_time')
|
||
|
)
|
||
|
],
|
||
|
[
|
||
|
T::tr(
|
||
|
T::td('姓名', 'username'),
|
||
|
T::td('电话', 'mobile'),
|
||
|
T::td('公司', 'company')
|
||
|
),
|
||
|
T::tr(
|
||
|
T::td('投标价格', 'tender_price'),
|
||
|
T::td('投标时间', 'create_time'),
|
||
|
T::td('投标文件', 'update_file')
|
||
|
),
|
||
|
]
|
||
|
]);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @param \app\common\model\Tender $tender
|
||
|
* @return array|\think\response\View
|
||
|
* @author Deng
|
||
|
* @date 2020-12-23 14:58
|
||
|
* 投标列表
|
||
|
*/
|
||
|
public function tenderList(\app\common\model\Tender $tender){
|
||
|
$id = $this->request->get('id');
|
||
|
return $this->fetch('common/list_page',['table'=>$this->getPage()->getTenderList(),'id'=>$id]);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @return array
|
||
|
* @throws \think\db\exception\DbException
|
||
|
* @author Deng
|
||
|
* @date 2020-12-23 14:58
|
||
|
* 投标列表数据
|
||
|
*/
|
||
|
public function tenderData(){
|
||
|
$id = $this->request->get('id');
|
||
|
$limit = $this->request->get('limit');
|
||
|
$data = \app\common\model\Tender::alias('t')
|
||
|
->leftJoin('member m','m.id=t.member_id')
|
||
|
->leftJoin('bidding b','b.id=t.bidding_id')
|
||
|
->field('t.id,t.status,t.tender_price,m.username,b.title,b.contract_title,t.create_time,b.id bidding_id,t.file_id,t.ip,t.ip_address,m.company')
|
||
|
->where(['t.bidding_id'=>$id,'t.delete_time'=>0])->order('tender_price desc')->paginate($limit??10)->toArray();
|
||
|
if($data['data']){
|
||
|
foreach ($data['data'] as $key => $value){
|
||
|
$data['data'][$key]['status'] = $value['status']==1 ? '<span class="layui-badge layui-bg-green">中标</span>' : '<span class="layui-badge layui-bg-red">未中标</span>';
|
||
|
if ($value['file_id']){
|
||
|
$resource = Db::name('resource')->where('id',$value['file_id'])->find();
|
||
|
$path = '/upload/watermark/'.$resource['md5'].'.jpg';
|
||
|
if(file_exists(\think\facade\App::getRootPath().$path)){
|
||
|
if(strstr($resource['tag'],'.pdf')){
|
||
|
$tag = str_replace('.pdf','.jpg',$resource['tag']);
|
||
|
$data['data'][$key]['file_id'] = '<a href="'.url('bidding/download',['tag'=>$tag,'path'=>$path]).'" >'.$resource['tag'].'</a>';
|
||
|
}else{
|
||
|
$data['data'][$key]['file_id'] = '<a href="'.url('bidding/download',['tag'=>$resource['tag'],'path'=>$path]).'" >'.$resource['tag'].'</a>';
|
||
|
}
|
||
|
}else{
|
||
|
$data['data'][$key]['file_id'] = '无';
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|
||
|
return ['code'=>0,'data'=>$data['data'],'count'=>$data['total']];
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @return \think\response\Json
|
||
|
* @throws \think\db\exception\DataNotFoundException
|
||
|
* @throws \think\db\exception\DbException
|
||
|
* @throws \think\db\exception\ModelNotFoundException
|
||
|
* @author Deng
|
||
|
* @date 2020-12-23 17:23
|
||
|
* 中标
|
||
|
*/
|
||
|
public function winningBiding(){
|
||
|
$getData = $this->request->get();
|
||
|
$bidding_info = \app\common\model\Tender::where('id',$getData['id'])->find()->toArray();
|
||
|
if(\app\common\model\Tender::where(['status'=>1,'bidding_id'=>$bidding_info['bidding_id'],'delete_time'=>0])->find()){
|
||
|
return ResponseJson::fail('改标已经中标');
|
||
|
}
|
||
|
Db::startTrans();
|
||
|
try {
|
||
|
//修改投标状态
|
||
|
$upTender = Db::name('tender')->where('id',$getData['id'])->update(['status'=>1,'update_time'=>date('Y-m-d H:i:s')]);
|
||
|
if(!$upTender){
|
||
|
db::rollback();
|
||
|
return ResponseJson::fail('更新投标失败');
|
||
|
}
|
||
|
//修改招标状态
|
||
|
$upBidding = \app\common\model\Bidding::where(['id'=>$bidding_info['bidding_id']])->update(['status'=>1,'update_time'=>date('Y-m-d H:i:s')]);
|
||
|
if(!$upBidding){
|
||
|
db::rollback();
|
||
|
return ResponseJson::fail('修改招标状态失败');
|
||
|
}
|
||
|
//发送通知
|
||
|
$bidding = \app\common\model\Bidding::where('id',$bidding_info['bidding_id'])->find()->toArray();
|
||
|
$content= '恭喜您通过招标。请您和我司负责人'.$bidding['contact_person'].'进行沟通联系方式:'.$bidding['contact_person_tel'];
|
||
|
$createNotice = \app\common\model\Notice::create([
|
||
|
'member_id' => $bidding_info['member_id'],
|
||
|
'bidding_id' => $bidding_info['id'],
|
||
|
'content' => $content,
|
||
|
'contract_title' => $bidding['contract_title']
|
||
|
]);
|
||
|
if(!$createNotice){
|
||
|
db::rollback();
|
||
|
return ResponseJson::fail('发送投标成功通知失败');
|
||
|
}
|
||
|
db::commit();
|
||
|
return ResponseJson::success('','中标成功');
|
||
|
} catch (\Exception $exception) {
|
||
|
db::rollback();
|
||
|
return ResponseJson::fail($exception->getMessage());
|
||
|
}
|
||
|
}
|
||
|
/**
|
||
|
* @return \think\response\File
|
||
|
* @author Deng
|
||
|
* @date 2020-12-21 18:43
|
||
|
* 下载
|
||
|
*/
|
||
|
public function download()
|
||
|
{
|
||
|
$getData = request()->get();
|
||
|
$str = App::getRootPath() . $getData['path'];
|
||
|
return download($str, $getData['tag']);
|
||
|
}
|
||
|
}
|