6 changed files with 92 additions and 20 deletions
@ -0,0 +1,48 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace app\enterprise\model; |
||||
|
|
||||
|
use think\Model; |
||||
|
|
||||
|
class MessageView extends Model |
||||
|
{ |
||||
|
public static function addView($msg_id, $user_id, $file_id, $src) |
||||
|
{ |
||||
|
$where = [ |
||||
|
'user_id' => $user_id, |
||||
|
'compress_img' => $src, |
||||
|
'file_id' => $file_id |
||||
|
]; |
||||
|
$fileRes = File::where($where)->find(); |
||||
|
if (!$fileRes) { |
||||
|
return false; |
||||
|
} |
||||
|
$data = [ |
||||
|
'msg_id' => $msg_id, |
||||
|
'user_id' => $user_id, |
||||
|
]; |
||||
|
$query = self::where($data)->field('id')->find(); |
||||
|
if ($query) { |
||||
|
return false; |
||||
|
} |
||||
|
$data['type'] = 1; |
||||
|
$data['status'] = 1; |
||||
|
$data['create_time'] = time(); |
||||
|
$data['view_time'] = time(); |
||||
|
|
||||
|
(new self())->save($data); |
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
public static function isView($msg_id, $user_id) |
||||
|
{ |
||||
|
$where = [ |
||||
|
'msg_id' => $msg_id, |
||||
|
'user_id' => $user_id, |
||||
|
'type' => 1, |
||||
|
'status' => 1 |
||||
|
]; |
||||
|
$query = self::where($where)->field('id')->find(); |
||||
|
return $query ? 1 : 0; |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue