AccountCompany.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace app\user\model;
  3. class AccountCompany extends Base
  4. {
  5. //设置字段信息
  6. protected $schema = [
  7. 'id' =>'bigint',//
  8. 'account_id' =>'bigint',//账户id
  9. 'companyCode' =>'varchar',//公司编号
  10. 'companyName' =>'varchar',//公司名称
  11. 'company_type' =>'tinyint',//公司类型:0无设置,1供应商,2业务公司
  12. 'is_main' =>'tinyint',//是否为默认公司
  13. 'status' =>'tinyint',//使用状态 1启用 0禁用
  14. 'is_del' =>'tinyint',//删除1是 0否
  15. 'addtime' =>'datetime',//
  16. 'updatetime' =>'datetime',//
  17. ];
  18. protected $updateTime='updatetime';
  19. protected $createTime='addtime';
  20. // protected $visible = ["id","companyCode","companyName","company_type","is_main","status","addtime"];
  21. public function accountInfo(){
  22. return $this->belongsTo(Account::class,"account_id","id")->bind(['nickname','user_mobile','mobile','openId','depart_name','itemid','depart_link','position',"username"]);
  23. }
  24. public static function SupplierHasAcount($code){
  25. $isRela=self::where(['companyCode'=>$code,'status'=>1,'is_del'=>0])->select();
  26. if ($isRela->isEmpty()) return false;
  27. $account_id = $isRela->column("account_id");
  28. $info = Account::whereIn("id",$account_id)->where(["status"=>1,"level"=>3])->select();
  29. return !$info->isEmpty();
  30. }
  31. }