*/
class Tender extends Admin
{
/**
* 列表数据接口
* @return mixed|string|\think\Collection|\think\response\Json
* @throws \app\common\SdException
*/
public function listData()
{
return $this->setJoin([
['member', 'i.member_id = member.id ', 'left'],
['bidding', 'i.bidding_id = bidding.id ', 'left'],
])
->setField('i.id,member.username member_username,member.company,i.member_id,bidding.title bidding_title,i.bidding_id,i.tender_price,i.file_id,i.create_time,i.ip,i.ip_address')
->setSort('create_time,desc')
->setCustomReturn(function ($data){
foreach ($data['data'] as $key => &$value) {
$resource = Db::name('resource')->where('id',$value['file_id'])->find();
if($resource){
$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'] = ''.$resource['tag'].'';
}else{
$data['data'][$key]['file_id'] = ''.$resource['tag'].'';
}
}else{
$data['data'][$key]['file_id'] = '无';
}
}else{
$data['data'][$key]['file_id'] = '无';
}
}
return json([
'code' => 0,
'msg' => '成功!',
'count' => $data['total'] ?? 0,
'data' => $data['data']
]);
}
)
->listsRequest();
}
}