EnterpriseUser.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. namespace app\models\user;
  3. use app\models\article\Article;
  4. use crmeb\services\SystemConfigService;
  5. use app\models\user\InterestUser as InterestUser;
  6. use think\facade\Session;
  7. use crmeb\traits\ModelTrait;
  8. use crmeb\basic\BaseModel;
  9. use crmeb\traits\JwtAuthModelTrait;
  10. use think\Model;
  11. class EnterpriseUser extends BaseModel
  12. {
  13. protected $name = 'enterprise_user';
  14. protected $pk = 'uid';
  15. // 认证
  16. public function auth($val){
  17. }
  18. public function inserts($data,$user){
  19. if($user){
  20. $headimg=$user['avatar'];
  21. $data=[
  22. 'uid' =>$user['uid'],
  23. 'name' =>$data['name'],
  24. 'type' =>$data['type'],
  25. 'contacts' =>$data['contacts'],
  26. 'post' =>$data['post'],
  27. 'phone' =>$data['phone'],
  28. 'password' =>md5($data['password']),
  29. 'user' =>$data['phone'],
  30. 'is_auth' =>1,
  31. 'headimg'=>$headimg,
  32. 'reason'=>"审核中",
  33. ];
  34. // 先查询是否已存在改用户绑定的公司
  35. $slct=self::where('uid',$user['uid'])->find();
  36. if($slct&&$slct['is_auth']!=0) return $ruls=1;
  37. if($slct['is_auth']==0){
  38. $res=self::where('uid',$user['uid'])->update($data);
  39. if($res){
  40. return $ruls=2;
  41. }
  42. }
  43. if(!$slct){
  44. $res=self::insert($data);
  45. if($res){
  46. return $ruls=2;
  47. }
  48. }
  49. }
  50. }
  51. // 根据文章id查找到订阅号信息
  52. public static function getInfo($id,$uid){
  53. $list=self::where('id', $id)->field('id,name,sub,headimg')->find();
  54. // 获取文章数
  55. // 查询该用户是否已订阅该媒体
  56. $is_sub=InterestUser::where('uid',$uid)->where('mer_id',$list['id'])->count();
  57. $list=empty($list) ?[]:$list->toArray();
  58. $essay=Article::where('mer_id',$id)->count();
  59. $list['count'] = $essay;
  60. $list['is_sub'] = $is_sub;
  61. return $list;
  62. }
  63. }