12345678910111213141516171819202122232425262728293031323334353637383940 |
- <?php
- namespace app\user\model;
- class AccountCompany extends Base
- {
- protected $schema = [
- 'id' =>'bigint',
- 'account_id' =>'bigint',
- 'companyCode' =>'varchar',
- 'companyName' =>'varchar',
- 'company_type' =>'tinyint',
- 'is_main' =>'tinyint',
- 'status' =>'tinyint',
- 'is_del' =>'tinyint',
- 'addtime' =>'datetime',
- 'updatetime' =>'datetime',
- ];
- protected $updateTime='updatetime';
- protected $createTime='addtime';
- protected $append= ['invoice_code'];
-
- public function accountInfo(){
- return $this->belongsTo(Account::class,"account_id","id")->bind(['nickname','user_mobile','mobile','openId','depart_name','itemid','depart_link','position',"username"]);
- }
- public function getInvoiceCodeAttr($value,$data){
- return Headquarters::where(['code'=>$data['companyCode']])->value("invoice_code",'');
- }
- public static function SupplierHasAcount($code){
- $isRela=self::where(['companyCode'=>$code,'status'=>1,'is_del'=>0])->select();
- if ($isRela->isEmpty()) return false;
- $account_id = $isRela->column("account_id");
- $info = Account::whereIn("id",$account_id)->where(["status"=>1,"level"=>3])->select();
- return !$info->isEmpty();
- }
- }
|