<?php

namespace App\Http\Controllers\Wap\Other;

use App\Http\Controllers\Wap\BaseController;
use App\Modules\Complaints\Services\UserComplaintsService;
use Hashids;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use DB;

class ComplaintsController extends BaseController
{
    /**
     * 获取投诉标签
     * @param Request $request
     * @return mixed
     */
    public function getComplaintTags(Request $request) {
        $tags = array(
            ['id'=>1,'name'=>'色情低俗'],
            ['id'=>2,'name'=>'政治敏感'],
            ['id'=>3,'name'=>'违法犯罪'],
            ['id'=>4,'name'=>'广告骚扰'],
            ['id'=>5,'name'=>'无法继续阅读'],
            ['id'=>6,'name'=>'内容质量差'],
            ['id'=>7,'name'=>'其它'],
        );
        return response()->success($tags);
    }

    public function complaints(Request $request) {
        if(!$this->checkUid()){
            return response()->error('WAP_NOT_LOGIN');
        }
        $tag_id = $request->input('tag_id','');
        $tag_name = $request->input('tag_name','');
        $content = $request->input('content','');
        $bid = $request->input('bid','');
        $cid = $request->input('cid','');
        $distribution_channel_id = $request->input('distribution_channel_id','');
        $phone = $request->input('phone','');
        $uid = $this->uid;
        $bid = Hashids::decode($bid)[0];

        if(empty($tag_id)){
            return response()->error('PARAM_EMPTY');
        }
        $params = compact('tag_id','tag_name','content','uid','bid','cid','distribution_channel_id','phone');
        $added = UserComplaintsService::addComplaints($params);
        return response()->success();
    }
}
