liyaozhi
2025-10-28 1320688354fd168c51cf2e05f29a2253f4ed9c00
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?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() ?: '操作失败');
    }
}