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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<?php
 
namespace app\api\controller\plus\live;
 
use app\api\controller\Controller;
use app\api\model\order\Order as OrderModel;
use app\api\model\plus\live\Room as RoomModel;
use app\api\model\plus\live\LiveProduct as LiveProductModel;
use app\api\model\product\Product as ProductModel;
use app\api\model\supplier\Category as CategoryModel;
/**
 * 主播直播申请
 */
class RoomApply extends Controller
{
    // 当前用户
    private $user;
 
    /**
     * 构造方法
     */
    public function initialize()
    {
        $this->user = $this->getUser();   // 用户信息
    }
 
    /**
     * 微信直播列表
     */
    public function lists()
    {
        $model = new RoomModel();
        $list = $model->getMyList($this->user, $this->postData(), true);
        return $this->renderSuccess('', compact('list'));
    }
 
    /**
     * 保存
     */
    public function addlive()
    {
        $model = new RoomModel;
        if ($model->add($this->user, $this->postData())) {
            $room_id = $model['room_id'];
            return $this->renderSuccess('保存成功', compact('room_id'));
        }
        return $this->renderError($model->getError() ?: '保存失败');
    }
 
    /**
     * 预告
     */
    public function addnotice()
    {
        $model = new RoomModel;
        if ($model->notice($this->user, $this->postData())) {
            $room_id = $model['room_id'];
            return $this->renderSuccess('保存成功', compact('room_id'));
        }
        return $this->renderError($model->getError() ?: '保存失败');
    }
 
    /**
     * 修改查询
     */
    public function detail($room_id)
    {
        $model = RoomModel::detailByUser($this->user['user_id'], $room_id);
        return $this->renderSuccess('', compact('model'));
    }
    /**
     * 保存
     */
    public function edit($room_id)
    {
        $model = RoomModel::detailByUser($this->user['user_id'], $room_id);
        if ($model->edit($this->user, $this->postData())) {
            return $this->renderSuccess('保存成功');
        }
        return $this->renderError($model->getError() ?: '保存失败');
    }
    /**
     * 保存商品
     */
    public function addProduct($productIds)
    {
        $model = new LiveProductModel();
        if($model->add($this->user, $productIds)){
            return $this->renderSuccess('保存成功');
        }
        return $this->renderError($model->getError() ?: '保存失败');
    }
 
    /**
     * 删除商品
     */
    public function delProduct($product_id)
    {
       
        $model = new LiveProductModel();
        if($model->remove($product_id)){
                return $this->renderSuccess('删除成功');
        }
        return $this->renderError($model->getError() ?: '删除失败');
    }
    /**
     * 删除
     */
    public function delete($room_id)
    {
        $model = RoomModel::detailByUser($this->user['user_id'], $room_id);
        if ($model->setDelete($this->user, $this->postData())) {
            return $this->renderSuccess('删除成功');
        }
        return $this->renderError($model->getError() ?: '删除失败');
    }
 
    /**
     * 直播商品列表
     */
    public function liveproduct()
    {
        $model = new LiveProductModel();
        $list = $model->getList($this->postData());
        return $this->renderSuccess('', compact('list'));
    }
    /**
     * 订单列表
     */
    public function orderList(){
        $model = new OrderModel();
        $list = $model->getLiveOrder($this->postData());
        return $this->renderSuccess('', compact('list'));
    }
    /**
     * 供应商商品列表
     */
    public function product_list()
    {
        
        $model = new ProductModel();
        //查找商品
        $param = $this->postData();
        $param['shop_supplier_id'] = $this->user['supplierUser']['shop_supplier_id'];
        $param['product_id'] = (new LiveProductModel())->livProduct($param['shop_supplier_id']);
        $list = $model->getList($param, $this->getUser());
        return $this->renderSuccess('', compact( 'list'));
    }
    //分类列表
    public function category(){
        $list = CategoryModel::getALL();
        return $this->renderSuccess('', compact('list'));
    }
 
}