|
@@ -30,6 +30,7 @@ class Product extends BaseController {
|
|
|
* @OA\Parameter(name="status", in="query", description="状态 1正常 2删除", @OA\Schema(type="integer",default="1")),
|
|
|
* @OA\Parameter(name="name", in="query", description="产品名称", @OA\Schema(type="string")),
|
|
|
* @OA\Parameter(name="brandId", in="query", description="品牌id", @OA\Schema(type="integer")),
|
|
|
+ * @OA\Parameter(name="storeId", in="query", description="门店id", @OA\Schema(type="integer")),
|
|
|
* @OA\Parameter(name="companyId", in="query", description="公司id", @OA\Schema(type="integer")),
|
|
|
* @OA\Parameter(name="productTypeId", in="query", description="产品类型id", @OA\Schema(type="integer")),
|
|
|
* @OA\Parameter(name="type", in="query", description="产品分类 1洗浴 2小食", @OA\Schema(type="integer")),
|
|
@@ -65,9 +66,9 @@ class Product extends BaseController {
|
|
|
if (!empty($input['companyId'])) {
|
|
|
$where[] = ['p.company_id', '=', "{$input['companyId']}"];
|
|
|
}
|
|
|
- // if (!empty($input['storeId'])) {
|
|
|
- // $where[] = ['s.id', '=', "{$input['storeId']}"];
|
|
|
- // }
|
|
|
+ if (!empty($input['storeId'])) {
|
|
|
+ $where[] = ['spt.store_id', '=', "{$input['storeId']}"];
|
|
|
+ }
|
|
|
if (!empty($input['productTypeId'])) {
|
|
|
$where[] = ['pt.id', '=', $input['productTypeId']];
|
|
|
$where[] = ['pt.status', '=', 1];
|
|
@@ -78,6 +79,9 @@ class Product extends BaseController {
|
|
|
}
|
|
|
$model->setWhere($where);
|
|
|
$data = $model->getProductList();
|
|
|
+ foreach ($data['list'] as &$v) {
|
|
|
+ $v['current_price'] = $v['realPrice'];
|
|
|
+ }
|
|
|
Until::output($data);
|
|
|
}
|
|
|
|
|
@@ -103,17 +107,17 @@ class Product extends BaseController {
|
|
|
$model->setPageSize($input['pageSize'] ?? 10);
|
|
|
$where = [];
|
|
|
if (!$this->isAdmin()) {
|
|
|
- $where[] = ['status','=', 1];
|
|
|
- }else {
|
|
|
+ $where[] = ['status', '=', 1];
|
|
|
+ } else {
|
|
|
if (!empty($input['status'])) {
|
|
|
$where[] = ['status', '=', (int)$input['status'] - 1];
|
|
|
}
|
|
|
}
|
|
|
if (!empty($input['type']) && $input['type'] == 2) {
|
|
|
- $where[] = ['type','=', 2];
|
|
|
+ $where[] = ['type', '=', 2];
|
|
|
}
|
|
|
if (!empty($input['type']) && $input['type'] == 1) {
|
|
|
- $where[] = ['type','=', 1];
|
|
|
+ $where[] = ['type', '=', 1];
|
|
|
}
|
|
|
$model->setWhere($where);
|
|
|
$data = $model->getProductTypeList();
|
|
@@ -144,23 +148,23 @@ class Product extends BaseController {
|
|
|
public function saveType() {
|
|
|
$input = Until::getInput();
|
|
|
$rule = [
|
|
|
- 'name|分类名称' => 'require',
|
|
|
- 'imgUrl|产品分类图片' => 'require',
|
|
|
+ 'name|分类名称' => 'require',
|
|
|
+ 'imgUrl|产品分类图片' => 'require',
|
|
|
];
|
|
|
Until::check($rule, $input);
|
|
|
$model = new ProductTypeModel();
|
|
|
if (!empty($input['id'])) {
|
|
|
$id = (int)$input['id'];
|
|
|
$model::where(['id' => $id])->update([
|
|
|
- 'product_type_name' => $input['name'],
|
|
|
- 'product_type_img' => $input['imgUrl'] ?? '',
|
|
|
- 'type' => $input['type'] ?? 1,
|
|
|
+ 'product_type_name' => $input['name'],
|
|
|
+ 'product_type_img' => $input['imgUrl'] ?? '',
|
|
|
+ 'type' => $input['type'] ?? 1,
|
|
|
]);
|
|
|
} else {
|
|
|
$model->insertGetId([
|
|
|
- 'product_type_name' => $input['name'],
|
|
|
- 'product_type_img' => $input['imgUrl'] ?? '',
|
|
|
- 'type' => $input['type'] ?? 1
|
|
|
+ 'product_type_name' => $input['name'],
|
|
|
+ 'product_type_img' => $input['imgUrl'] ?? '',
|
|
|
+ 'type' => $input['type'] ?? 1
|
|
|
]);
|
|
|
}
|
|
|
Until::output(['isSuccess' => 1]);
|
|
@@ -181,8 +185,8 @@ class Product extends BaseController {
|
|
|
public function deleteType() {
|
|
|
$input = Until::getInput();
|
|
|
$rule = [
|
|
|
- 'id' => 'require',
|
|
|
- 'status' => 'require',
|
|
|
+ 'id' => 'require',
|
|
|
+ 'status' => 'require',
|
|
|
];
|
|
|
Until::check($rule, $input);
|
|
|
$model = new ProductTypeModel();
|
|
@@ -228,8 +232,8 @@ class Product extends BaseController {
|
|
|
'companyId|公司id' => 'require',
|
|
|
'brandId|品牌id' => 'require',
|
|
|
'productContent|产品内容' => 'require',
|
|
|
- 'productTypeId|产品类型' => 'require',
|
|
|
- 'time|产品时间' => 'require'
|
|
|
+ 'productTypeId|产品类型' => 'require',
|
|
|
+ 'time|产品时间' => 'require'
|
|
|
];
|
|
|
Until::check($rule, $input);
|
|
|
$model = new ProductModel();
|
|
@@ -244,11 +248,11 @@ class Product extends BaseController {
|
|
|
'brand_id' => $input['brandId'],
|
|
|
'product_content' => $input['productContent'],
|
|
|
'product_type_id' => $input['productTypeId'],
|
|
|
- 'time' => $input['time'],
|
|
|
+ 'time' => $input['time'],
|
|
|
'status' => $input['status'] ?? 1,
|
|
|
]);
|
|
|
} else {
|
|
|
- $id = $model->insertGetId([
|
|
|
+ $model->insertGetId([
|
|
|
'product_name' => $input['name'],
|
|
|
'product_img' => $input['imgUrl'],
|
|
|
'old_price' => $input['oldPrice'],
|
|
@@ -258,13 +262,11 @@ class Product extends BaseController {
|
|
|
'product_content' => $input['productContent'],
|
|
|
'status' => $input['status'] ?? 1,
|
|
|
'product_type_id' => $input['productTypeId'],
|
|
|
- 'time' => $input['time'],
|
|
|
+ 'time' => $input['time'],
|
|
|
'type' => $input['type'] ?? 1
|
|
|
]);
|
|
|
}
|
|
|
- $model->setWhere([['p.id', '=', (int)$id]]);
|
|
|
- $info = $model->getProductInfo();
|
|
|
- Until::output(['info' => $info]);
|
|
|
+ Until::output();
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -273,14 +275,22 @@ class Product extends BaseController {
|
|
|
* summary="查看产品信息",
|
|
|
* @OA\Parameter(name="token", in="header", description="token", @OA\Schema(type="string")),
|
|
|
* @OA\Parameter(name="id", in="query", description="产品id", @OA\Schema(type="ineger",default="1")),
|
|
|
+ * @OA\Parameter(name="storeId", in="query", description="门店id", @OA\Schema(type="ineger",default="1")),
|
|
|
* @OA\RequestBody(
|
|
|
* ),
|
|
|
* @OA\Response(response="200", description="请求成功")
|
|
|
* )
|
|
|
*/
|
|
|
- public function read($id) {
|
|
|
+ public function read() {
|
|
|
+ $input = Until::getInput();
|
|
|
+ $rule = [
|
|
|
+ 'id|产品id' => 'require',
|
|
|
+ 'storeId|门店id' => 'require',
|
|
|
+ ];
|
|
|
+ Until::check($rule, $input);
|
|
|
$model = new ProductModel();
|
|
|
- $where[] = ['p.id', '=', (int)$id];
|
|
|
+ $where[] = ['p.id', '=', (int)$input['id']];
|
|
|
+ $where[] = ['spt.store_id', '=', (int)$input['storeId']];
|
|
|
$model->setWhere($where);
|
|
|
$info = $model->getProductInfo();
|
|
|
Until::output(['info' => $info]);
|