<?php

namespace Act\Lib;

use Dever;

class Feedback
{
    # 发表反馈
    public function submit($uid, $username, $name, $type_id, $contact, $content)
    {
        $where['uid'] = $uid;
        $where['username'] = $username;
        $where['name'] = $name;
        $where['content'] = Dever::emoji($content);
        $table = 'act/feedback';
        $info = Dever::db($table)->one($where);
        if (!$info) {
            $where['type_id'] = $type_id;
            $where['contact'] = $contact;
            $id = Dever::db($table)->insert($where);
        } else {
            $where['where_id'] = $info['id'];
            $where['type_id'] = $type_id;
            $where['contact'] = $contact;
            Dever::db($table)->update($where);
            $id = $info['id'];
        }
        Dever::score($uid, 'submit_feedback', '发表反馈');

        return $id;
    }
}