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.
155 lines
4.5 KiB
155 lines
4.5 KiB
<?php
|
|
|
|
|
|
namespace app\admin\logic\financeService;
|
|
|
|
|
|
use app\common\basics\Logic;
|
|
use app\common\model\financeService\Contract;
|
|
use app\common\model\job\Job;
|
|
use app\common\model\job\JobSalary;
|
|
use app\common\server\AreaServer;
|
|
use Exception;
|
|
use think\facade\Db;
|
|
|
|
class ContractLogic 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['cate_id']) and is_numeric($get['cate_id']))
|
|
$where[] = ['cate_id', '=', $get['cate_id']];
|
|
|
|
$model = new Contract();
|
|
$lists = $model->field(true)
|
|
->where($where)
|
|
->paginate([
|
|
'page' => $get['page'],
|
|
'list_rows' => $get['limit'],
|
|
'var_page' => 'page'
|
|
])
|
|
->toArray();
|
|
|
|
$cates1 = Db::name("contract_cate")->where(['del'=>0,'is_show'=>1])->select()->toArray();
|
|
$cates = array_column($cates1,"name","id");
|
|
|
|
foreach ($lists['data'] as &$item) {
|
|
$item['cate_name'] = $cates[$item['cate_id']] ?? "未知";
|
|
$item['is_show'] = $item['is_show'] ? '显示' : '隐藏';
|
|
$item['start_time_str'] = $item['start_time'] ? date("Y-m-d",$item['start_time']) : '-';
|
|
$item['end_time_str'] = $item['end_time'] ? date("Y-m-d",$item['end_time']) : '-';
|
|
$item['is_show'] = $item['is_show'] ? '显示' : '隐藏';
|
|
}
|
|
|
|
return ['count'=>$lists['total'], 'lists'=>$lists['data']];
|
|
} catch (Exception $e) {
|
|
return ['error'=>$e->getMessage()];
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @Notes: 文章详细
|
|
* @Author: 张无忌
|
|
* @param $id
|
|
* @return array
|
|
*/
|
|
public static function detail($id)
|
|
{
|
|
$model = new Contract();
|
|
$data = $model->field(true)->findOrEmpty($id)->toArray();
|
|
return $data;
|
|
}
|
|
|
|
/**
|
|
* @Notes: 添加文章
|
|
* @Author: 张无忌
|
|
* @param $post
|
|
* @return bool
|
|
*/
|
|
public static function add($post)
|
|
{
|
|
try {
|
|
Contract::create([
|
|
'title' => $post['title'],
|
|
'partA' => $post['partA'],
|
|
'partB' => $post['partB'],
|
|
'partC' => $post['partC'],
|
|
'cate_id' => $post['cate_id'] ?? 0,
|
|
'start_time' => $post['start_time'] ? strtotime($post['start_time']) : 0,
|
|
'end_time' => $post['end_time'] ? strtotime($post['start_time']." 23:59:59") : 0,
|
|
'term' => $post['term'] ?? 0,
|
|
'money' => $post['money'] ?? 0.00,
|
|
'path' => $post['path'] ,
|
|
]);
|
|
|
|
return true;
|
|
} catch (\Exception $e) {
|
|
static::$error = $e->getMessage();
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @Notes: 编辑文章
|
|
* @Author: 张无忌
|
|
* @param $post
|
|
* @return bool
|
|
*/
|
|
public static function edit($post)
|
|
{
|
|
try {
|
|
Contract::update([
|
|
'title' => $post['title'],
|
|
'partA' => $post['partA'],
|
|
'partB' => $post['partB'],
|
|
'partC' => $post['partC'],
|
|
'cate_id' => $post['cate_id'] ?? 0,
|
|
'start_time' => $post['start_time'] ? strtotime($post['start_time']) : 0,
|
|
'end_time' => $post['end_time'] ? strtotime($post['start_time']." 23:59:59") : 0,
|
|
'term' => $post['term'] ?? 0,
|
|
'money' => $post['money'] ?? 0.00,
|
|
'path' => $post['path'] ,
|
|
], ['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 {
|
|
Contract::update([
|
|
'del' => 1,
|
|
'update_time' => time()
|
|
], ['id'=>$id]);
|
|
|
|
return true;
|
|
} catch (\Exception $e) {
|
|
static::$error = $e->getMessage();
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
|