初始化代码
This commit is contained in:
110
app/farm/model/InfoRecord.php
Normal file
110
app/farm/model/InfoRecord.php
Normal file
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
namespace app\farm\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use think\facade\Db;
|
||||
|
||||
class InfoRecord extends BaseModel
|
||||
{
|
||||
//定义表名
|
||||
protected $name = 'lbfarm_v2_info_record';
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:04
|
||||
* @功能说明:添加
|
||||
*/
|
||||
public function dataAdd($data){
|
||||
|
||||
$data['create_time'] = time();
|
||||
|
||||
$res = $this->insert($data);
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:05
|
||||
* @功能说明:编辑
|
||||
*/
|
||||
public function dataUpdate($dis,$data){
|
||||
|
||||
$res = $this->where($dis)->update($data);
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:06
|
||||
* @功能说明:列表
|
||||
*/
|
||||
public function dataList($dis,$page=10){
|
||||
|
||||
$data = $this->where($dis)->order('id desc')->paginate($page)->toArray();
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:43
|
||||
* @功能说明:
|
||||
*/
|
||||
public function dataInfo($dis){
|
||||
|
||||
$data = $this->where($dis)->find();
|
||||
|
||||
return !empty($data)?$data->toArray():[];
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-08-22 16:03
|
||||
* @功能说明:获取已读数量
|
||||
*/
|
||||
public function noReadCount($user_id,$uniacid){
|
||||
|
||||
$dis = [
|
||||
|
||||
'a.user_id' => $user_id,
|
||||
|
||||
'b.status' => 1,
|
||||
|
||||
'b.type' => 3
|
||||
];
|
||||
|
||||
$read_count = $this->alias('a')
|
||||
->join('lbfarm_v2_welfare_column b','a.info_id = b.id')
|
||||
->where($dis)
|
||||
->count();
|
||||
|
||||
$info_model = new WelfareColumn();
|
||||
|
||||
$info_count = $info_model->where(['uniacid'=>$uniacid,'status'=>1,'type'=>3])->count();
|
||||
|
||||
return ($info_count - $read_count)>0?$info_count - $read_count:0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user