123456789101112131415161718192021222324252627282930313233343536 |
- <?php
- namespace app\common\model;
- use library\tools\Data;
- use think\Model;
- // 会员设备号
- class UserFacility extends Model
- {
- // 验证登录设备号
- public static function checkFacility($user_id,$type,$facility,$account = '')
- {
- if(!in_array($type,[1,2,3,4])) return true;
- $check_info = self::where(['user_id'=>$user_id,'type'=>$type])->find();
- if(empty($check_info) || $check_info->facility == '') {
- Data::save('UserFacility',
- [
- 'user_id'=>$user_id,
- 'type'=>$type,
- 'facility'=>$facility,
- 'set_time'=>date('Y-m-d H:i:s'),
- 'account' => $account,
- ],
- 'user_id',['user_id'=>$user_id,'type'=>$type]);
- return true;
- }
- return $check_info->facility == $facility ? true : false;
- }
- // 验证设备号是否设置过
- public static function checkSetFacility($user_id,$type,$facility){
- return self::where(['user_id'=>$user_id,'type'=>$type,'facility'=>$facility])->value('id');
- }
- }
|