dggzichahu/application/admin/logic/ScreenPriceLogic.php

111 lines
3.1 KiB
PHP
Executable File

<?php
// +----------------------------------------------------------------------
// | 宏驰云科技开发团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | Author: HcyShop-kiki
// +----------------------------------------------------------------------
namespace app\admin\logic;
use app\admin\model\ScreenPrice;
use think\Db;
class ScreenPriceLogic
{
public static function lists($get)
{
$where = [];
$where[] = ['del', '=', '0'];
$screen_price = new ScreenPrice();
$count = $screen_price->where($where)->count();
$list = $screen_price->where($where)->page($get['page'], $get['limit'])->select();
foreach ($list as &$item) {
$item['create_time'] = date('Y-m-d H:i:s', $item['create_time']);
if ($item['is_show'] == 1) {
$item['is_show_text'] = '启用';
} else {
$item['is_show_text'] = '停用';
}
}
return ['count' => $count, 'lists' => $list];
}
/**
* Desc: 添加专家分类
* @param $post array 文章分类数据
* @return boolean
*/
public static function addScreenPrice($post)
{
$screen_price = new ScreenPrice();
$data = [
'name' => $post['name'],
'start_price' => $post['start_price'],
'end_price' => $post['end_price'],
'is_show' => $post['is_show'],
'create_time' => time(),
];
return $screen_price->save($data);
}
/**
* Desc: 编辑专家分类
* @param $post array 文章分类数据
* @return boolean
*/
public static function editScreenPrice($post)
{
$screen_price = new ScreenPrice();
$data = [
'name' => $post['name'],
'start_price' => $post['start_price'],
'end_price' => $post['end_price'],
'is_show' => $post['is_show'],
'update_time' => time(),
];
return $screen_price->save($data, ['id' => $post['id'], 'del' => 0]);
}
/**
* Desc: 删除专家分类
* @param $id int 文章分类id
* @return boolean
*/
public static function delScreenPrice($id)
{
$screen_price = new ScreenPrice();
$data = [
'update_time' => time(),
'del' => 1,
];
return $screen_price->save($data, ['id' => $id, 'del' => 0]);
}
/**
* Desc: 获取单条专家分类
* @param $id int 文章分类id
* @return boolean
*/
public static function getScreenPrice($id = 0)
{
$where[] = ['del', '=', 0];
if ($id) {
$where[] = ['id', '=', $id];
}
$screen_price = new ScreenPrice();
return $screen_price->where($where)->column('*', 'id');
}
public static function switchStatus($post)
{
$data = [
'is_show' => $post['is_show'],
'update_time' => time(),
];
return Db::name('screen_price')->where(['del' => 0, 'id' => $post['id']])->update($data);
}
}