public function add_score() { $json_raw = file_get_contents("php://input"); $json_data = json_decode($json_raw); $score = $json_data->score; $tags = $json_data->tags; $content = $json_data->content; $img_url = $json_data->img_url; $good_type_id = $json_data->good_type_id; $good_id = $json_data->good_id; $order_time = $json_data->order_time; $user_id = $this->check_user(); //往comment表里面插入数据 $CommentModel = new \Home\Model\CommentModel(); $status = $CommentModel->add_comment($good_id, $user_id, $order_time, $tags, $score, $content, $good_type_id); if (!$status) { echo json_encode(array("status" => "0")); return; } else { //更新订单状态 switch ($good_type_id) { case '1': $tableName = 'orderlist'; break; case '2': $tableName = 'seckill_orderlist'; break; case '3': $tableName = 'teambuy_orderlist'; break; case '4': $tableName = 'trial_orderlist'; break; case '5': $tableName = 'book_orderlist'; break; default: return false; } $tableModel = M($tableName); $ordstatus_data["ordstatus"] = 8; $status = $tableModel->where("userid={$user_id} and ordtime='{$order_time}' and ordertype={$good_type_id} and productid={$good_id}")->data($ordstatus_data)->save(); if (!$status) { echo json_encode(array("status" => "0")); return; } } //更新comment_tags列表 $CommentTagModel = new \Home\Model\CommentTagModel(); foreach ($tags as $tag) { $status = $CommentTagModel->add_tag($good_id, $good_type_id, $tag); if (!$status) { echo json_encode(array("status" => "0")); return; } } //更新bask_order表 $BaskModel = new \Home\Model\BaskModel(); foreach ($img_url as $piece) { $status = $BaskModel->add_img($user_id, $good_id, $good_type_id, $piece, $order_time); if (!$status) { echo json_encode(array("status" => "0")); return; } } echo json_encode(array("status" => "1")); }