123456789101112131415161718192021222324252627282930313233343536 |
- <?php
- namespace app\user\model;
- class AccountCompany extends Base
- {
- //设置字段信息
- protected $schema = [
- 'id' =>'bigint',//
- 'account_id' =>'bigint',//账户id
- 'companyCode' =>'varchar',//公司编号
- 'companyName' =>'varchar',//公司名称
- 'company_type' =>'tinyint',//公司类型:0无设置,1供应商,2业务公司
- 'is_main' =>'tinyint',//是否为默认公司
- 'status' =>'tinyint',//使用状态 1启用 0禁用
- 'is_del' =>'tinyint',//删除1是 0否
- 'addtime' =>'datetime',//
- 'updatetime' =>'datetime',//
- ];
- protected $updateTime='updatetime';
- protected $createTime='addtime';
- // protected $visible = ["id","companyCode","companyName","company_type","is_main","status","addtime"];
-
- 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 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();
- }
- }
|