quanwei
18 hours ago c441dea81bd86bdfb12dff35821fed51f4cc91c2
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
<?php
 
namespace app\operations\controller\plus\vip;
 
use app\operations\controller\Controller;
use app\operations\model\plus\vip\Apply as VipApplyModel;
use app\common\model\plus\vip\User as VipUserModel;
 
/**
 * VIP专区申请管理
 */
class Apply extends Controller
{
    /**
     * 申请列表
     */
    public function index()
    {
        $model = new VipApplyModel;
        $list = $model->getList($this->postData());
        return $this->renderSuccess('', compact('list'));
    }
 
    /**
     * 申请审核
     */
    public function audit()
    {
        $data = $this->postData();
        $model = new VipApplyModel;
        $detail = $model::detail($data['id']);
        
        if (!$detail) {
            return $this->renderError('申请记录不存在');
        }
 
        if ($detail['apply_status'] != 10) {
            return $this->renderError('该申请已处理');
        }
 
        // 更新审核状态
        $updateData = [
            'apply_status' => $data['apply_status'],
            'audit_time' => time()
        ];
 
        if ($data['apply_status'] == 30) {
            // 驳回,需要填写驳回原因
            if (empty($data['reject_reason'])) {
                return $this->renderError('请填写驳回原因');
            }
            $updateData['reject_reason'] = $data['reject_reason'];
        }
 
        if ($model->where('id', $data['id'])->update($updateData)) {
            return $this->renderSuccess('审核成功');
        }
        return $this->renderError('审核失败');
    }
}