You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
2.5 KiB
PHTML

5 years ago
<?php
namespace Admin\Model;
use Think\Model;
class CompanyRelationModel extends Model
{
protected $db = 'company_relation';
// 数据表前缀
protected $tablePrefix = 'tab_';
public $InvoiceType=[
"0"=>"无",
5 years ago
"1"=>"专票",
"2"=>"普票"
];
public $SettlementType=[
"0"=>"无",
"1"=>"周结",
"2"=>"月结"
];
public $empty = "--";
/**
* 返回公司基础信息
*
* @param [type] $company_type 公司类型
* @param [type] $company_id 公司id
* @param boolean $type true:返回映射后的中午false:返回原字段
* @return void
*/
public function getCompanyRelation($company_type,$company_id,$type = true)
5 years ago
{
$res = $this->where("(first_company_type = '{$company_type}' AND first_company_id = '{$company_id}') OR (second_company_type = '{$company_type}' AND second_company_id = '{$company_id}')")->find();
if(empty($res)){
if($type){
$senddata = [
'company_id'=>$company_id,
"is_payment"=>$this->empty,
"collection"=>$this->empty,
"invoice_type"=>$this->empty,
"invoice_content"=>$this->empty,
"settlement_type"=>$this->empty
];
}else{
return false;
}
5 years ago
}else{
$senddata = [
'company_id'=>$company_id,
"is_payment"=>$res['is_payment'],
"invoice_content"=>$res['invoice_content']
];
if($type){
5 years ago
if($res["first_company_type"] == $company_type){
$s = ($res['collection'] == 1 ? "是" : "否");
}else{
$s = ($res['collection'] == 2 ? "是" : "否");
}
$senddata["invoice_type"] = $this->InvoiceType[$res['invoice_type']];
$senddata["settlement_type"] = $this->SettlementType[$res['settlement_type']];
5 years ago
}else{
5 years ago
if($res["first_company_type"] == $company_type){
$s = ($res['collection'] == 1 ? 1 : 0);
}else{
$s = ($res['collection'] == 2 ? 1 : 0);
}
$senddata["invoice_type"] = $res['invoice_type'];
$senddata["settlement_type"]=$res['settlement_type'];
5 years ago
}
5 years ago
$senddata["collection"] = $s;
5 years ago
}
return $senddata;
5 years ago
}
}