WokerTask/app/common/model/contract/ShopContract.php

57 lines
1.8 KiB
PHP
Raw Normal View History

2023-12-27 14:06:33 +08:00
<?php
namespace app\common\model\contract;
use app\common\model\BaseModel;
use app\common\model\Company;
use app\common\model\dict\DictData;
use app\common\model\ShopMerchant;
class ShopContract extends BaseModel
{
protected $name = 'shop_contract';
/**
* @notes 关联company_name
* @return \think\model\relation\HasOne
* @author likeadmin
* @date 2023/07/18 14:28
*/
public function companyName()
{
return $this->hasOne(ShopMerchant::class, 'id', 'company_id')->bind(['company_name']);
}
public function company()
{
return $this->hasOne(ShopMerchant::class, 'id', 'company_id');
}
public function partyAInfo()
{
return $this->hasOne(ShopMerchant::class, 'id', 'party_a')->field('id,company_name,organization_code,master_name,master_phone,master_email,area_manager');
}
public function partyBInfo()
{
// halt($this->type);
// if($this->type==1){
return $this->hasOne(ShopMerchant::class, 'id', 'party_b')->field('id,company_name,organization_code,master_name,master_phone,master_email,area_manager');
// }else{
// return $this->hasOne(User::class, 'id', 'party_b')->field('id,nickname company_name');
// }
}
public function partyA()
{
return $this->hasOne(ShopMerchant::class, 'id', 'party_a')->bind(['party_a_name' => 'company_name']);
}
public function partyB()
{
return $this->hasOne(ShopMerchant::class, 'id', 'party_b')->bind(['party_b_name' => 'company_name']);
}
public function contractType()
{
return $this->hasOne(DictData::class, 'id', 'contract_type')->bind(['contract_type_name' => 'name']);
}
public function getContractTypeNameAttr($value)
{
return DictData::where(['id' => $this->contract_type])->value('name');
}
}