// +---------------------------------------------------------------------- namespace app\institution\controller\kefu; use app\institution\controller\AuthController; use app\admin\model\user\UserBill; use service\JsonService as Json; use app\admin\model\finance\FinanceModel; use app\admin\model\merchant\MerchantFlowingWater; use app\admin\model\merchant\MerchantBill; use app\admin\model\merchant\Merchant; use service\SystemConfigService; use service\FormBuilder as Form; use service\HookService; use think\Url; use app\admin\model\user\User; use app\admin\model\user\UserExtract; use app\admin\model\kefu\KefuModel; use app\kefu\model\KefuFeedBackModel; use think\Request; use service\JwtService; class Feedback extends AuthController { public function list() { return $this->fetch(); } private function create_feedback_query($search = '', $start_time = '', $end_time = '') { $model = new KefuFeedBackModel; return $model->where(function ($q) use ($search, $start_time, $end_time) { if ($search) { $q->where('real_name|phone|content', 'like', '%' . $search . '%'); } if ($start_time && $end_time) { $q->whereTime('add_time', 'between', [$start_time, $end_time]); } }); } public function get_feedback_list($page = 1, $limit = 20, $search = '', $start_time = '', $end_time = '') { $count = $this->create_feedback_query($search, $start_time, $end_time)->count(); $data = $this->create_feedback_query($search, $start_time, $end_time) ->page($page, $limit) ->where('mer_id',$this->agent) ->order('id', 'desc') ->select(); return Json::successlayui(compact("count", "data")); } public function delete($id) { $feedback = KefuFeedBackModel::get($id); if (!$feedback) return Json::fail("留言不存在!"); $feedback->delete(); return Json::successful("删除成功!"); } public function mark($id) { $feedback = KefuFeedBackModel::get($id); if (!$feedback) return Json::fail("留言不存在!"); $this->assign("feedback", $feedback); return $this->fetch(); } public function save_mark($id, $status = 0, $mark = '') { $feedback = KefuFeedBackModel::get($id); if (!$feedback) return Json::fail("留言不存在!"); if (!$mark) return Json::fail("请输入备注!"); $feedback->status = $status == 0 ? 0 : 1; $feedback->mark = $mark; $feedback->save(); return Json::successful("保存成功!"); } }