UserFacility.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace app\common\model;
  3. use library\tools\Data;
  4. use think\Model;
  5. // 会员设备号
  6. class UserFacility extends Model
  7. {
  8. // 验证登录设备号
  9. public static function checkFacility($user_id,$type,$facility,$account = '')
  10. {
  11. if(!in_array($type,[1,2,3,4])) return true;
  12. $check_info = self::where(['user_id'=>$user_id,'type'=>$type])->find();
  13. if(empty($check_info) || $check_info->facility == '') {
  14. Data::save('UserFacility',
  15. [
  16. 'user_id'=>$user_id,
  17. 'type'=>$type,
  18. 'facility'=>$facility,
  19. 'set_time'=>date('Y-m-d H:i:s'),
  20. 'account' => $account,
  21. ],
  22. 'user_id',['user_id'=>$user_id,'type'=>$type]);
  23. return true;
  24. }
  25. return $check_info->facility == $facility ? true : false;
  26. }
  27. // 验证设备号是否设置过
  28. public static function checkSetFacility($user_id,$type,$facility){
  29. return self::where(['user_id'=>$user_id,'type'=>$type,'facility'=>$facility])->value('id');
  30. }
  31. }