creatDir('storage/word_html/'.date('Ymd').'/'); } $htmlPath=$path.md5($filePath).'.html'; if(!is_file($htmlPath)){ $phpWord = IOFactory::load($filePath); $htmlWriter =new HTML($phpWord); $htmlWriter->save($htmlPath); } $htmlContent = file_get_contents($htmlPath); $htmlContent=strip_tags($htmlContent); return !strpos($htmlContent,$searchChar)===false; } /** * 合同保存的时候生成文本替换内容 * @throws \PhpOffice\PhpWord\Exception\Exception */ function replaceWordText($file_path,$file_name,$json) { $filePath=public_path($file_path); $phpWord = new TemplateProcessor($filePath); $data = json_decode($json,true); foreach ($data as $key=>$text){ $custom='{$' . $key . '}'; $phpWord->setValue($custom, $text); } CommonServer::creatServer()->creatDir('storage/contractComplete'); $phpWord->saveAs(public_path('storage/contractComplete/'.$file_name)); return true; } /** * 获取相关收益信息 * @param $factoring * @param $type * @return string */ function getEarningTextKey($factoring,$type) { $str='0%'; $type=str_replace($type,'earning_type',$type); if(empty($type) || !is_numeric($type)){ return $str; } $model=FactoringEarning::where('factoring_id',$factoring['id'])->where('earning_type',$type)->first(); if(empty($model)){ return $str; } return $model->{'earning_num'}.'%('.$model->{'earning_msg'}.')'; } /** * 企业基本信息匹配 * @param $propertys * @param $key * @param $type * @return false|string */ function getPropertyFirmTextKey($propertys,$key,$type) { $data=[]; foreach ($propertys as $property){ if($type=='zrf'){ $firmName=Firm::where('id',$property['firm_id'])->value('firm_name'); }elseif ($type=='yszw'){ $firmName=$property['original_debtor']; }elseif ($type=='hxqy'){ $firmName=$property['core_enterprise']; }elseif ($type=='bls'){ $firmName=Firm::where('id',$property['factor_id'])->value('firm_name'); } if(empty($firmName)){ return false; } if($key=='firm_name'){ $data[]=$firmName; }else{ $firm=$this->getFirmTextKey($firmName); if(empty($firm)){ $data[]='无'; }else{ $data[]=empty($firm[$key])?'无':$firm[$key]; } } } $data=array_unique($data); return implode(';',$data); } /** * 获取企业基本信息 * @param $firmName * @return Firm|\Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Eloquent\Model|mixed|object|null */ function getFirmTextKey($firmName) { $firmData=RedisDataServer::creatServer()->getData(md5($firmName),'json'); if(empty($firmData)){ $firmData=FirmServer::creatServer()->queryFirm($firmName); RedisDataServer::creatServer()->setData(md5($firmName),$firmData,'json'); } return $firmData; } /** * 合同信息获取 * @param $factoring_contract * @param $key * @return mixed|string */ function getContractTextKey($factoring_contract,$key) { $str=''; if($key=='contract_sn'){ $str=$factoring_contract->{'contract_sn'}; } return $str; } /** * 获取基础替换信息 * @param $key * @param $factoring_contract * @param $factoring * @return mixed|void */ function getTextKey($key,$factoring_contract,$factoring) { if (isset($factoring_contract[$key])){ return $factoring_contract[$key]; } if (isset($factoring[$key])){ return $factoring[$key]; } return ''; } /** * 获取资产替换信息 * @param $property * @param $key * @return string */ function getPropertyTextKey($property,$key) { $data=[]; foreach ($property as $value){ if($key=='id'){ $data[]=$value->{'id'} . '('.$value->{'property_name'}.')'; }elseif ($key=='name'){ $data[]=$value->{'property_name'}; }elseif ($key=='contract_sn'){ $data[]=$value->{'contract_sn'} . '('.$value->{'property_name'}.')'; }elseif ($key=='original_credit'){ $data[]=$value->{'original_credit'} . '('.$value->{'property_name'}.')'; }elseif ($key=='original_debtor'){ $data[]=$value->{'original_debtor'} . '('.$value->{'property_name'}.')'; }elseif ($key=='end_date'){ $data[]=$value->{'end_date'} . '('.$value->{'property_name'}.')'; }elseif ($key=='due_date'){ $data[]=$value->{'due_date'} . '('.$value->{'property_name'}.')'; }elseif ($key=='property_sn'){ $data[]=$value->{'property_sn'} . '('.$value->{'property_name'}.')'; } } return implode(';',$data); } }