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.
yanzong/app/api/controller/GoodsNew.php

91 lines
2.4 KiB

6 months ago
<?php
namespace app\api\controller;
6 months ago
use app\common\model\GoodsCategoryRel;
use app\common\service\GoodsCateEs;
6 months ago
use app\common\service\GoodsEs;
use think\App;
6 months ago
class GoodsNew extends Controller
{
public function index()
{
$goodsService = new GoodsEs();
$data = $goodsService->list([]);
dd($data);
}
public function search()
{
5 months ago
$param = $this->request->param();
$page = $this->request->param('page', 1);
5 months ago
$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'] = $this->storeId;
6 months ago
$goodsService = new GoodsCateEs();
5 months ago
$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();
6 months ago
$goodsService = new GoodsCateEs();
$data = $goodsService->createData($goods_id, $goods_data);
$this->renderSuccess($data);
}
6 months ago
/**
* 创建分类
*/
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);
}
6 months ago
}