<?php
/*
 本代码由 焕岱科技 创建
 技术支持 WX：15285007200
 严禁反编译、逆向等任何形式的侵权行为，违者将追究法律责任
*/

namespace app\api\controller\feedback;

use app\api\controller\Base;
use think\Db;
use app\common\model\bbfxshop\User;


class Feedback extends Base
{
    protected $noNeedLogin = [];
    protected $noNeedRight = ['*'];
    
    public $model = null;
    
    public function submit(){
        $params = $this->param(['content/s']);
        
        
        $data = array(
            "uniacid"=>UNIACID,
            "user_id"=>$this->user['id'],
            "content"=>$params['content'],
            "createtime"=>time()
        );
        
        
        $info = Db::name("bbfx_feedback")->where(["uniacid"=>UNIACID,"user_id"=>$this->user['id'],'content'=>$data['content']])->find();
        if(!empty($info) ){
            __error("您已提交过相同反馈");
        }
        
        $count = Db::name("bbfx_feedback")->where(["uniacid"=>UNIACID,"user_id"=>$this->user['id'],'createtime'=>['>',time()]])->count();
        if($count >= 3){
            __error("操作频繁，请稍后重试");
        }
        
        $res = Db::name("bbfx_feedback")->insert($data);
        
        if($res){
            __success("提交成功，请等待管理员处理");
        }
        else{
            __error("操作失败");
        }
    }
    
}