<?php
|
|
namespace app\shop\controller\plus\goodcoupon;
|
|
use app\common\library\helper;
|
use app\shop\controller\Controller;
|
use app\shop\model\product\Product as ProductModel;
|
use app\shop\model\plus\goodcoupon\Coupon as GoodCouponModel;
|
use app\shop\model\product\Category as CategoryModel;
|
|
/**
|
* 商品运营控制器
|
*/
|
class Coupon extends Controller
|
{
|
/**
|
* 商品列表
|
*/
|
public function index()
|
{
|
$model = new ProductModel;
|
$list = $model->getList(array_merge(['status' => -1,'is_virtual' => 2], $this->postData()));
|
// 分类
|
$category = CategoryModel::getALL();
|
return $this->renderSuccess('', compact('list', 'category'));
|
}
|
|
/**
|
* 编辑
|
*/
|
public function edit($product_id)
|
{
|
$model = new GoodCouponModel();
|
if ($this->request->isGet()) {
|
$good_coupon= GoodCouponModel::detail($product_id);
|
return $this->renderSuccess('', compact('good_coupon'));
|
}
|
if ($model->edit($this->postData())) {
|
return $this->renderSuccess('操作成功');
|
}
|
return $this->renderError($model->getError() ?: '操作失败');
|
}
|
|
/**
|
* 设置状态
|
*/
|
public function setStatus($productIds, $is_good)
|
{
|
$model = new GoodCouponModel();
|
if ($model->setStatus($productIds, $is_good)) {
|
return $this->renderSuccess('操作成功');
|
}
|
return $this->renderError($model->getError() ?: '操作失败');
|
}
|
}
|