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.
92 lines
2.4 KiB
92 lines
2.4 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 getList()
|
|
{
|
|
$param = $this->request->param();
|
|
$page = $this->request->param('page', 1);
|
|
$pageSize = $this->request->param('pageSize', 10);
|
|
$param['channels'] = $this->storeInfo['open_channel'] ? array_merge(['zy'], explode(",", $this->storeInfo['open_channel'])) : [];
|
|
$param['fliter_condition'] = $this->storeInfo['fliter_condition'];
|
|
$param['status'] = 10;
|
|
$param['store_id'] = 10038;//$this->storeId;
|
|
$goodsService = new GoodsCateEs();
|
|
$data = $goodsService->list($param, $page, $pageSize);
|
|
|
|
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);
|
|
}
|
|
} |