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.
120 lines
3.1 KiB
120 lines
3.1 KiB
<?php
|
|
namespace app\adminapi\controller\v1;
|
|
|
|
use app\adminapi\ApiController;
|
|
use think\facade\Db;
|
|
|
|
class Goods extends ApiController
|
|
{
|
|
public function list(){
|
|
$page = input('page');
|
|
$pageSize = input('pageSize');
|
|
|
|
$do = Db::name('goods')
|
|
->field('goods_id,goods_name,shop_price,goods_type,goods_sn,is_on_sale,is_best,is_new,is_hot,sort_order,goods_number,integral,is_promote,is_sale');
|
|
|
|
$goods=$do
|
|
->page($page,$pageSize)
|
|
->order('goods_id','desc')
|
|
->select()
|
|
->toArray();
|
|
|
|
if(!$goods){
|
|
$goods=[];
|
|
}
|
|
|
|
foreach($goods as $key => $val){
|
|
}
|
|
|
|
$rtn = [
|
|
'total' => $do->count(),
|
|
'data' => $goods
|
|
];
|
|
return $this->Success($rtn);
|
|
}
|
|
|
|
public function add(){
|
|
$data = input('post.');
|
|
print_r($data);
|
|
return;
|
|
/* 檢查貨號是否重複 */
|
|
if(!empty($data['goods_sn'])){
|
|
$goods_sn = Db::name('goods')
|
|
->where('goods_sn',$data['goods_sn'])
|
|
->where('is_delete',0)
|
|
->where('goods_id','<>',$data['goods_id'])
|
|
->find();
|
|
|
|
if($goods_sn){
|
|
return $this->Error('貨號重複');
|
|
}
|
|
}
|
|
|
|
// if(!$result){
|
|
// return $this->Error('操作失败');
|
|
// }
|
|
return $this->Success('操作成功');
|
|
}
|
|
|
|
public function deleteBonus(){
|
|
$id = input('id');
|
|
|
|
$do = Db::name('bonus_type');
|
|
|
|
$do->where('type_id',$id)->delete();
|
|
|
|
return $this->Success('操作成功');
|
|
}
|
|
|
|
public function getUseBonusList(){
|
|
$page = input('page');
|
|
$pageSize = input('pageSize');
|
|
|
|
$do = Db::name('user_bonus');
|
|
|
|
$rtn=$do
|
|
->page($page,$pageSize)
|
|
->select()
|
|
->toArray();
|
|
|
|
if(!$rtn){
|
|
$rtn=[];
|
|
}
|
|
|
|
$send_type = [
|
|
'1' => '會員發放',
|
|
'2' => '商品發放',
|
|
'3' => '訂單方式',
|
|
'4' => '線下發放',
|
|
'5' => '線上發放',
|
|
'6' => '註冊發放',
|
|
];
|
|
|
|
foreach($rtn as $key => $val){
|
|
if(!empty($val['send_type'])){
|
|
$rtn[$key]['send_type'] = $send_type[$val['send_type']];
|
|
}else{
|
|
$rtn[$key]['send_type'] = '未知';
|
|
}
|
|
$rtn[$key]['order_id'] = empty($val['order_id'])?'':$val['order_id'];
|
|
$rtn[$key]['user_id'] = empty($val['user_id'])?'':$val['user_id'];
|
|
$rtn[$key]['used_time'] = empty($val['used_time'])?'未使用':$val['used_time'];
|
|
}
|
|
|
|
$rtn = [
|
|
'total' => $do->count(),
|
|
'data' => $rtn
|
|
];
|
|
return $this->Success($rtn);
|
|
}
|
|
|
|
public function uploadImg(){
|
|
$file = request()->file('file');
|
|
try{
|
|
$savename = \think\facade\Filesystem::disk('public')->putFile('images', $file);
|
|
}catch(\Exception $e){
|
|
return $this->Error('上傳失敗');
|
|
}
|
|
return $this->Success($savename);
|
|
}
|
|
} |