chengkun
2025-05-20 f6f7bd25619ad0c0dfb5e609332e9fa1db419386
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
<?php
 
 
class comproduct_controller extends adminCommon{
 
    function set_search()
    {
        $search_list[]=array("param"=>"status","name"=>'审核状态',"value"=>array("1"=>"已审核","3"=>"未审核","2"=>"未通过"));
        $search_list[]=array("param"=>"time","name"=>'发布时间',"value"=>array('1'=>'今天','3'=>'最近三天','7'=>'最近七天','15'=>'最近半月','30'=>'最近一个月'));
        $this->yunset("search_list",$search_list);
    }
 
    function index_action()
    {
        $this->set_search();
        
        $companyM = $this->MODEL('company');
        
        if ($_GET['time']) {
            
            if ($_GET['time'] == '1') {
                
                $where['ctime'] = array(
                    '>=',
                    strtotime('today')
                );
            } else {
                $where['ctime'] = array(
                    '>=',
                    strtotime('-' . intval($_GET['time']) . ' day')
                );
            }
            $urlarr['time'] = $_GET['time'];
        }
        
        if ($_GET['status']) {
            
            $status = intval($_GET['status']);
            
            $where['status'] = $status == 3 ? 0 : $status;
            
            $urlarr['status'] = $status;
        }
        
        if ($_GET['keyword']) {
            
            $keytype = intval($_GET['type']);
            
            $keyword = trim($_GET['keyword']);
            
            if ($keytype == 1) {
                
                $cwhere['name'] = array(
                    'like',
                    $keyword
                );
                
                $ctList = $companyM->getList($cwhere, array(
                    'field' => 'uid'
                ));
                
                $comapant = $ctList['list'];
                
                foreach ($comapant as $v) {
                    
                    $comid[] = $v['uid'];
                }
                
                $where['uid'] = array(
                    'in',
                    pylode(',', $comid)
                );
            } elseif ($keytype == 2) {
                
                $where['title'] = array(
                    'like',
                    $keyword
                );
            }
            
            $urlarr['keytype'] = $keytype;
            
            $urlarr['keyword'] = $keyword;
        }
        
        $urlarr['page'] = "{{page}}";
        
        $pageurl = Url($_GET['m'], $urlarr, 'admin');
        
        $pageM = $this->MODEL('page');
        
        $pages = $pageM->pageList('company_product', $where, $pageurl, $_GET['page']);
        
        if ($pages['total'] > 0) {
            // limit order 只有在列表查询时才需要
            if ($_GET['order']) {
                
                $where['orderby'] = $_GET['t'] . ',' . $_GET['order'];
                $urlarr['order'] = $_GET['order'];
                $urlarr['t'] = $_GET['t'];
            } else {
                
                $where['orderby'] = array(
                    'status,asc',
                    'id,desc'
                );
            }
        }
        
        $where['limit'] = $pages['limit'];
        
        $rows = $companyM->getCompanyProductList($where, array(
            'utype' => 'admin',
            'cache' => '1'
        ));
        
        $this->yunset("rows", $rows);
        
        $this->yuntpl(array('admin/admin_comproduct'));
    }
 
    function statusbody_action()
    {
        $CompanyM = $this->MODEL('company');
        
        $id = intval($_GET['id']);
        
        $info = $CompanyM->getComProductInfo(array(
            'id' => $id
        ), array(
            'field' => 'statusbody'
        ));
        
        echo $info['statusbody'];
        die();
    }
 
    function status_action()
    {
        if (empty($_POST['status'])){
            
            $this->ACT_layer_msg("请选择审核状态!", 8, $_SERVER['HTTP_REFERER']);
        }
        
        $CompanyM = $this->MODEL('company');
        
        $sysmsgM = $this->MODEL('sysmsg');
        
        $status = intval($_POST['status']);
        
        $data['status'] = $status;
        
        $data['statusbody'] = $_POST['statusbody'];
        
        $id = $_POST['id'];
        
        if ($id) {
            $nid = $CompanyM->upCompanyProductStatus($id, $data);
            
            $where['id'] = array('in',$id);
            
            $CpList = $CompanyM->getCompanyProductList($where, array(
                'field' => 'uid,title'
            ));
            
            /* 消息前缀 */
            $tagName = '产品';
            
            foreach ($CpList as $v) {
                
                $uids[] = $v['uid'];
                
                /* 处理审核信息 */
                if ($data['status'] == 2) {
                    
                    $statusInfo = $tagName . $v['name'] . '审核未通过 , ';
                    
                    if ($data['statusbody']) {
                        
                        $statusInfo .= '原因:' . $data['statusbody'];
                    }
                    
                    $msg[$v['uid']][] = $statusInfo;
                } elseif ($data['status'] == 1) {
                    
                    $msg[$v['uid']][] = $tagName . $v['name'] . '已审核通过';
                }
            }
            
            $this->MODEL('log')->addAdminLog("企业产品(ID:" . $id . ")审核成功");
            
            $sysmsgM->addInfo(array(
                'uid' => $uids,
                'usertype' => 2,
                'content' => $msg
            ));
            
            $nid ? $this->ACT_layer_msg("产品审核(ID:" . $id . ")设置成功!", 9, $_SERVER['HTTP_REFERER'], 2, 1) : $this->ACT_layer_msg("设置失败!", 8, $_SERVER['HTTP_REFERER']);
        } else {
            
            $this->ACT_layer_msg("非法操作!", 8, $_SERVER['HTTP_REFERER']);
        }
    }
 
    function del_action()
    {
        $CompanyM = $this->Model('company');
        
        $delID = is_array($_POST['del']) ? $_POST['del'] : $_GET['id'];
        
        $return = $CompanyM->delCompanyProduct($delID);
        
        $this->layer_msg($return['msg'], $return['errcode'], $return['layertype'], $_SERVER['HTTP_REFERER']);
    }
}
?>