安徽博创起重服务端程序
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.
 
 
 
 
 

188 lines
4.9 KiB

<?php
namespace app\admin\logic\complain;
use app\common\basics\Logic;
use app\common\model\complain\Complain;
use app\common\model\content\Help;
use app\common\model\content\Resource;
use app\common\server\AreaServer;
use app\common\server\UrlServer;
use Exception;
class ComplainLogic extends Logic
{
/**
* 获取分类
* @param $get
* @return array
*/
public static function lists($get)
{
try {
$where = [
['del', '=', 0]
];
if (!empty($get['title']) and $get['title'])
$where[] = ['title', 'like', '%'.$get['title'].'%'];
if (!empty($get['cid']) and is_numeric($get['cid']))
$where[] = ['cid', '=', $get['cid']];
if (!empty($get['is_complate']) and is_numeric($get['is_complate']))
$where[] = ['is_complate', '=', $get['is_complate']];
$model = new Complain();
$lists = $model->field(true)
->where($where)
->with(['category','user'])
->order('sort', 'asc')
->paginate([
'page' => $get['page'],
'list_rows' => $get['limit'],
'var_page' => 'page'
])
->toArray();
foreach ($lists['data'] as &$item) {
$item['username'] = $item['user']['nickname'] ?? '未知';
$item['is_complate'] = $item['is_complate'] ==1?'已处理': '未处理';
$item['avatar'] = $item['user']['avatar'] ?UrlServer::getFileUrl($item['user']['avatar']) : '';
}
return ['count'=>$lists['total'], 'lists'=>$lists['data']];
} catch (Exception $e) {
return ['error'=>$e->getMessage()];
}
}
public static function getAddr(){
}
/**
* @Notes: 资料详细
* @Author:
* @param $id
* @return array
*/
public static function detail($id)
{
$model = new Complain();
$detail = $model->field(true)->with(['category'])->findOrEmpty($id)->toArray();
$detail['category'] = $detail['category']['name'] ?? '未知';
$detail['image'] = $detail['image'] ? UrlServer::getFileUrl($detail['image']) : '';
return $detail;
}
/**
* @Notes: 添加帮助
* @Author:
* @param $post
* @return bool
*/
public static function add($post)
{
try {
Complain::create([
'cid' => $post['cid'],
'uid' => $post['uid'],
'image' => $post['image'] ?? '',
'content' => $post['content'] ?? '',
'is_complate' => 0
]);
return true;
} catch (\Exception $e) {
static::$error = $e->getMessage();
return false;
}
}
/**
* @Notes: 删除
* @Author:
* @param $id
* @return bool
*/
public static function del($id)
{
try {
Complain::update([
'del' => 1,
'update_time' => time()
], ['id'=>$id]);
return true;
} catch (\Exception $e) {
static::$error = $e->getMessage();
return false;
}
}
/**
* @Notes: 处理
* @Author: 张无忌
* @param $id
* @return bool
*/
public static function complate($post)
{
try {
$model = new Complain();
$article = $model->findOrEmpty($post['id'])->toArray();
Complain::update([
'is_complate' =>1,
'remark' => $post['remark'],
'update_time' => time()
], ['id'=>$post['id']]);
return true;
} catch (\Exception $e) {
static::$error = $e->getMessage();
return false;
}
}
//获取用户投诉列表
public static function getUserComplain($get,$user_id)
{
try {
$model = new Complain();
$lists = $model->field('*')
->order('id', 'desc')
->where([
['uid', '=', $user_id],
['del', '=', 0]
])
->page($get['page_no'], $get['page_size'])
->select()
->toArray();
$count = $model
->where([
['uid', '=', $user_id],
['del', '=', 0]
])
->count();
return [
'count' => $count,
'lists' => $lists,
'page_no' => $get['page_no'],
'page_size' => $get['page_size'],
'more' => is_more($count, $get['page_no'], $get['page_size'])
];
} catch (\Exception $e) {
return ['error'=>$e->getMessage()];
}
}
}