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.
101 lines
2.6 KiB
101 lines
2.6 KiB
<?php
|
|
|
|
namespace app\api\controller;
|
|
|
|
|
|
use app\common\model\GoodsCategoryRel;
|
|
use app\common\service\GoodsCateEs;
|
|
use app\common\service\GoodsEs;
|
|
use think\App;
|
|
|
|
class GoodsNew extends Controller
|
|
{
|
|
public function index()
|
|
{
|
|
$goodsService = new GoodsEs();
|
|
$data = $goodsService->list([]);
|
|
dd($data);
|
|
}
|
|
|
|
public function search()
|
|
{
|
|
$keyword = $this->request->param('keyword');
|
|
$page = $this->request->param('page', 1);
|
|
$limit = $this->request->param('limit', 10);
|
|
if (!$keyword) {
|
|
$this->renderError('请输入搜索关键字');
|
|
}
|
|
$params = ['goods_name' => $keyword, 'status' => 10];
|
|
|
|
//限制过滤条件-渠道
|
|
$params['channels'] = $this->storeInfo['open_channel'] ? array_merge(['zy'], explode(",", $this->storeInfo['open_channel'])) : [];
|
|
//分类利润-利润率
|
|
$params['fliter_condition'] = $this->storeInfo['fliter_condition'];
|
|
|
|
|
|
$goodsService = new GoodsCateEs();
|
|
$list = $goodsService->list( $params, $page, $limit);
|
|
$data['list'] = $list;
|
|
$data['total'] = $goodsService->count($params);
|
|
|
|
return $this->renderSuccess($data);
|
|
}
|
|
|
|
|
|
/**
|
|
* 添加商品
|
|
*/
|
|
public function add()
|
|
{
|
|
$goods_id = 1;
|
|
$goods_data = \app\common\model\Goods::where('goods_id', '=', $goods_id)
|
|
->order('goods_id desc')
|
|
->find()
|
|
->toArray();
|
|
$goodsService = new GoodsCateEs();
|
|
$data = $goodsService->createData($goods_id, $goods_data);
|
|
$this->renderSuccess($data);
|
|
}
|
|
|
|
/**
|
|
* 创建分类
|
|
*/
|
|
public function create()
|
|
{
|
|
$cate_id = 1;
|
|
$cate_data = GoodsCategoryRel::where('goods_id', '=', $cate_id)
|
|
->order('id desc')
|
|
->find()
|
|
->toArray();
|
|
$goodsService = new GoodsCateEs();
|
|
$data = $goodsService->createCateData($cate_id, $cate_data);
|
|
$this->renderSuccess($data);
|
|
}
|
|
|
|
/**
|
|
* 更新商品
|
|
*/
|
|
public function update()
|
|
{
|
|
$goods_id = 1;
|
|
$update = [
|
|
'goods_name' => '测试商品',
|
|
'selling_point' => '测试商品',
|
|
'goods_price_min' => 100,
|
|
'goods_price_max' => 100,
|
|
];
|
|
$goodsService = new GoodsEs();
|
|
$data = $goodsService->updateData($goods_id, $update);
|
|
$this->renderSuccess($data);
|
|
}
|
|
/**
|
|
* 删除
|
|
*/
|
|
public function delete()
|
|
{
|
|
$goods_id = 1;
|
|
$goodsService = new GoodsEs();
|
|
$data = $goodsService->delete($goods_id);
|
|
$this->renderSuccess($data);
|
|
}
|
|
} |