添加网站文件
This commit is contained in:
54
application/api/logic/PointsLogic.php
Normal file
54
application/api/logic/PointsLogic.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
namespace app\api\logic;
|
||||
use think\Db;
|
||||
use think\Exception;
|
||||
use app\common\server\UrlServer;
|
||||
use app\api\logic\UserLogic;
|
||||
|
||||
class PointsLogic
|
||||
{
|
||||
//获取积分的分类
|
||||
public static function classify(){
|
||||
return Db::name('printer_type')->select();
|
||||
}
|
||||
|
||||
|
||||
//获取到积分的商品列表
|
||||
public static function goodslist(){
|
||||
$where=[];
|
||||
$goods = Db::name('printer_goods')
|
||||
->where($where)
|
||||
->select();
|
||||
foreach($goods as &$item){
|
||||
|
||||
$item['images']=UrlServer::getFileUrl($item['images']);
|
||||
|
||||
}
|
||||
return $goods;
|
||||
}
|
||||
//根据ID获取到积分商品
|
||||
public static function goodsIofo($id){
|
||||
|
||||
$data=Db::name('printer_goods')->where('id',$id)->find();
|
||||
$data['images']=UrlServer::getFileUrl($data['images']);
|
||||
return $data;
|
||||
}
|
||||
|
||||
public static function goodsSub($data){
|
||||
|
||||
$data=[
|
||||
'name' =>$data['name'],
|
||||
'goods_id' =>$data['id'],
|
||||
'price' =>$data['price'],
|
||||
'number' =>1,
|
||||
'user_id' =>$data['user_id'],
|
||||
'create_time'=>time()
|
||||
];
|
||||
$insert=Db::name('printer_order')->data($data)->insert();
|
||||
if($insert){
|
||||
$user=UserLogic::getUserInfo($data['user_id']);
|
||||
db::name('user')->where('id',$data['user_id'])->update(['user_integral'=>$user['user_integral']-$data['price']]);
|
||||
// Db::name('printer_goods')->where('')
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user