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

281 lines
8.0 KiB

<?php
namespace app\admin\logic\community;
use app\common\basics\Logic;
use app\common\logic\CommunityArticleLogic as CommonArticleLogic;
use app\common\model\community\CommunityArticle;
use app\common\model\community\OrganTeam;
use app\common\model\complain\Complain;
use app\common\model\content\Help;
use app\common\model\content\Resource;
use app\common\model\user\User;
use app\common\server\AreaServer;
use app\common\server\UrlServer;
use Exception;
use think\facade\Db;
class OrganTeamLogic extends Logic
{
/**
* 获取分类
* @param $get
* @return array
*/
public static function lists($get,$type=0)
{
try {
$where = [
['del', '=', 0]
];
$where[] = ['type', '=', $type];
if (!empty($get['name']) && $get['name'])
$where[] = ['name', 'like', '%'.$get['name'].'%'];
if (isset($get['audit_status']) && $get['audit_status']!=""){
$where[] = ['audit_status','=',intval($get['audit_status'])];
}
if (isset($get['uid'])){
$where[] = ['uid','=',intval($get['uid'])];
}
$model = new OrganTeam();
$lists = $model->field(true)
->where($where)
->order('sort', 'asc')
->order('id', 'desc')
->paginate([
'page' => $get['page'],
'list_rows' => $get['limit'],
'var_page' => 'page'
])
->toArray();
foreach ($lists['data'] as &$item) {
$item['is_show'] = $item['is_show'] ? '显示' : '隐藏';
$item['address'] = $item['province_id']?AreaServer::getAddress([
$item['province_id'],
$item['city_id'],
]):'';
$item['username'] = "系统后台";
$item['mobile'] = "";
if($item['uid']>0){
$model = new User();
$user = $model->findOrEmpty($item['uid']);
if($user){
$item['username'] = $user['nickname'];
$item['mobile'] = $user['mobile'];
}
}
}
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 OrganTeam();
$detail = $model->field(true)->findOrEmpty($id)->toArray();
// $detail['path'] = UrlServer::getFileUrl($detail['path']);
$detail['address'] = $detail['province_id']?AreaServer::getAddress([
$detail['province_id'],
$detail['city_id'],
]):'';
return $detail;
}
/**
* @Notes: 添加帮助
* @Author:
* @param $post
* @return bool
*/
public static function add($post,$uid=0)
{
try {
OrganTeam::create([
'uid' => $uid,
'name' => $post['name'],
'image' => $post['image'] ?? '',
'intro' => $post['intro'] ?? '',
'content' => $post['content'] ?? '',
'type' => $post['type'] ?? 0,
'province_id' => $post['province_id'] ?? 0,
'city_id' => $post['city_id'] ?? 0,
'district_id' => $post['district_id'] ?? 0,
'address_detail' => $post['address_detail'] ?? '',
'visit' => 0,
'contact' => $post['contact'] ?? '',
'sort' => $post['sort'] ?? 0,
'is_show' => $post['is_show']??0,
'company' => $post['company'] ?? '',
'audit_status' =>$post['audit_status'] ?? 1,
]);
return true;
} catch (\Exception $e) {
static::$error = $e->getMessage();
return false;
}
}
/**
* @Notes: 编辑帮助
* @Author: 张无忌
* @param $post
* @return bool
*/
public static function edit($post,$uid=0)
{
try {
OrganTeam::update([
'uid' => $uid,
'name' => $post['name'],
'image' => $post['image'] ?? '',
'intro' => $post['intro'] ?? '',
'content' => $post['content'] ?? '',
'company' => $post['company'] ?? '',
'type' => $post['type'] ?? 0,
'province_id' => $post['province_id'] ?? 0,
'city_id' => $post['city_id'] ?? 0,
'district_id' => $post['district_id'] ?? 0,
'address_detail' => $post['address_detail'] ?? '',
'visit' => 0,
'contact' => $post['contact'] ?? '',
'sort' => $post['sort'] ?? 0,
'is_show' => $post['is_show']??0,
'audit_status' =>$post['audit_status'] ?? 1,
], ['id'=>$post['id']]);
return true;
} catch (\Exception $e) {
static::$error = $e->getMessage();
return false;
}
}
/**
* @Notes: 删除
* @Author:
* @param $id
* @return bool
*/
public static function del($id)
{
try {
OrganTeam::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 hide($id)
{
try {
$model = new OrganTeam();
$article = $model->findOrEmpty($id)->toArray();
OrganTeam::update([
'is_show' => !$article['is_show'],
'update_time' => time()
], ['id'=>$id]);
return true;
} catch (\Exception $e) {
static::$error = $e->getMessage();
return false;
}
}
//获取用户投诉列表
public static function getUserOrgan($get,$user_id)
{
try {
$model = new OrganTeam();
$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()];
}
}
/**
* @notes 审核文章
* @param $post
* @return bool
* @author 段誉
* @date 2022/5/12 16:57
*/
public static function audit($post)
{
try {
$article = OrganTeam::findOrEmpty($post['id']);
$article->audit_status = $post['audit_status'];
$article->audit_remark = $post['audit_remark'] ?? '';
$article->audit_time = time();
$article->save();
return true;
} catch (\Exception $e) {
Db::rollback();
self::$error = $e->getMessage();
return false;
}
}
}