You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
zhishifufei_php/application/wap/model/user/UserNotice.php

66 lines
2.3 KiB

<?php
// +----------------------------------------------------------------------
// | 天诚科技 [ 刘海东 17600099397赋能开发者,助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2020 https://www.tczxkj.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 该系统并不是自由软件,未经许可不能去掉相关版权
// +----------------------------------------------------------------------
// | Author:甘肃天诚志信电子商务有限公司 刘海东 联系电话维系17600099397
// +----------------------------------------------------------------------
namespace app\wap\model\user;
use app\admin\model\user\UserNoticeSee;
use traits\ModelTrait;
use basic\ModelBasic;
/**
* 用户通知 model
* Class UserNotice
*/
class UserNotice extends ModelBasic
{
use ModelTrait;
public static function getNotice($uid)
{
$count_notice = self::where('uid', 'like', "%,$uid,%")->where("is_send", 1)->count();
$see_notice = UserNoticeSee::where("uid", $uid)->count();
return $count_notice - $see_notice;
}
/**
* @return array
*/
public static function getNoticeList($uid, $page, $limit = 8)
{
//定义分页信息
$count = self::where('uid', 'like', "%,$uid,%")->count();
$data["lastpage"] = ceil($count / $limit) <= ($page + 1) ? 1 : 0;
$where['uid'] = array("like", "%,$uid,%");
$where['is_send'] = 1;
$list = self::where($where)->field('id,user,title,content,add_time')->order("add_time desc")->limit($page * $limit, $limit)->select()->toArray();
foreach ($list as $key => $value) {
$list[$key]["add_time"] = date("Y-m-d H:i:s", $value["add_time"]);
$list[$key]["is_see"] = UserNoticeSee::where("uid", $uid)->where("nid", $value["id"])->count() > 0 ? 1 : 0;
}
$data["list"] = $list;
return $data;
}
/**
* @return array
*/
public static function seeNotice($uid, $nid)
{
if (UserNoticeSee::where("uid", $uid)->where("nid", $nid)->count() <= 0) {
$data["nid"] = $nid;
$data["uid"] = $uid;
$data["add_time"] = time();
UserNoticeSee::set($data);
}
}
}