Files
duolamaojiazhen/application/admin/logic/PointsLogic.php
2025-12-22 13:59:40 +08:00

161 lines
4.4 KiB
PHP

<?php
namespace app\admin\logic;
use think\Db;
use app\common\server\UrlServer;
class PointsLogic{
/**
* 积分商品列表内容
* @return mixed
*/
public static function lists($get){
$where=[];
$where[] = ['del', '=', 0];
$count =Db::name('printer_goods')
->where($where)
->count();
$lists =Db::name('printer_goods')
->where($where)
->page($get['page'],$get['limit'])
->order('id desc')
->select();
foreach ($lists as &$item){
$item['create_time']=date('Y-m-d H:i:s');
$type_name=self::typeinfo($item['brand_id']);
if($type_name){
$item['tpye_name']=$type_name['name'];
}else{
$item['tpye_name']='-';
}
$item['images'] = UrlServer::getFileUrl($item['images']);
}
return ['count'=>$count , 'lists'=>$lists];
}
/**
* 根据ID查询积分商品内容
* @return mixed
*/
public static function info($id){
$data=Db::name('printer_goods')->where('id',$id)->find();
$data['images']= UrlServer::getFileUrl($data['images']);
return $data;
}
/**
* 修改积分套餐的内容
* @return mixed
*/
public static function edit($post){
$data=[
'name' => $post['name'],
'price' => $post['price'],
'unit' => $post['unit'],
'images' => $post['image'],
'inventory' => $post['inventory'],
'warn' => $post['warn'],
'content' => $post['content'],
'brand_id' => $post['brand_id'],
];
return Db::name('printer_goods')->where('id',$post['id'])->update($data);
}
/**
* 创建积分商品
* @return mixed
*/
public static function add($post){
$data=[
'name' => $post['name'],
'price' => $post['price'],
'unit' => $post['unit'],
'images' => $post['image'],
'inventory' => $post['inventory'],
'warn' => $post['warn'],
'content' => $post['content'],
'brand_id' => $post['brand_id'],
'create_time'=> time()
];
return Db::name('printer_goods')->data($data)->insert();
}
/**
* 删除积分商品
* @return mixed
*/
public static function del($id){
return Db::name('printer_goods')->where('id',$id)->update(['del'=>1]);
}
/**
* 积分分类列表
* @return mixed
*/
public static function type($get){
$where=[];
$where[] = ['del', '=', 0];
$count =Db::name('printer_type')
->where($where)
->count();
$lists =Db::name('printer_type')
->where($where)
->page($get['page'],$get['limit'])
->order('id desc')
->select();
foreach ($lists as &$item){
$item['create_time']=date('Y-m-d H:i:s');
}
return ['count'=>$count , 'lists'=>$lists];
}
/**
* 积分商品分类
* @return mixed
*/
public static function typeadd($post){
return Db::name('printer_type')->data($post)->insert();
}
/**
* 根据ID查询分类的
* @return mixed
*/
public static function typeinfo($id){
return Db::name('printer_type')->where(['del'=>0,'id'=>$id])->find();
}
/**
* 修改分类的名称
* @return mixed
*/
public static function typeedit($post){
return Db::name('printer_type')->where('id',$post['id'])->update(['name'=>$post['name']]);
}
/**
* 修改分类的名称
* @return mixed
*/
public static function typedel($id){
return Db::name('printer_type')->where('id',$id)->update(['del'=>1]);
}
/**
* 获取积分商城的全部分类
* @return mixed
*/
public static function typelist(){
return Db::name('printer_type')->where('del',0)->select();
}
}