public function score()
 {
     $id = $this->id;
     $result_array = array();
     $result_array_amend = array();
     //查询各个里面的等待评价的单子
     $orderTableArray = array("orderlist", "seckill_orderlist", "teambuy_orderlist", "trial_orderlist", "book_orderlist");
     foreach ($orderTableArray as $tablePiece) {
         $Model = M($tablePiece);
         $result_array = array_merge($result_array, $Model->where("ordstatus=3 and userid={$id}")->select());
     }
     foreach ($result_array as $piece) {
         switch ($piece["ordertype"]) {
             case '1':
                 $goodPrefix = 'good/index';
                 break;
             case '2':
                 $goodPrefix = 'good/seckill';
                 break;
             case '3':
                 $goodPrefix = 'good/teambuy';
                 break;
             case '4':
                 $goodPreifx = 'good/trial';
                 break;
             case '5':
                 $goodPrefix = 'good/book';
                 break;
             default:
                 return false;
         }
         $piece["goodPrefix"] = $goodPrefix;
         //查询所有的标签
         $CommentTagModel = new \Home\Model\CommentTagModel();
         $tag_array = $CommentTagModel->search_important_tag($piece["productid"], $piece["ordertype"]);
         $piece["tag_array"] = $tag_array;
         array_push($result_array_amend, $piece);
     }
     $this->assign("ordlist_to_score", $result_array_amend);
     //渲染已经评价过的
     $orderTableArray = array("orderlist", "seckill_orderlist", "teambuy_orderlist", "trial_orderlist", "book_orderlist");
     $done_result_array = array();
     $done_array_amend = array();
     foreach ($orderTableArray as $tablePiece) {
         $Model = M($tablePiece);
         $done_result_array = array_merge($done_result_array, $Model->where("ordstatus=6 and userid={$id}")->select());
     }
     $BaskModel = new \Home\Model\BaskModel();
     $CommentModel = new \Home\Model\CommentModel();
     foreach ($done_result_array as $piece) {
         switch ($piece["ordertype"]) {
             case '1':
                 $goodPrefix = 'good/index';
                 break;
             case '2':
                 $goodPrefix = 'good/seckill';
                 break;
             case '3':
                 $goodPrefix = 'good/teambuy';
                 break;
             case '4':
                 $goodPreifx = 'good/trial';
                 break;
             case '5':
                 $goodPrefix = 'good/book';
                 break;
             default:
                 return false;
         }
         $img_urls = $BaskModel->search_img($piece["userid"], $piece["productid"], $piece["ordertype"], $piece["ordtime"]);
         $comment_info = $CommentModel->search_user_comment($piece["userid"], $piece["productid"], $piece["ordertype"], $piece["ordtime"]);
         $piece["comment_info"] = $comment_info;
         $piece["img"] = $img_urls;
         $piece["goodPrefix"] = $goodPrefix;
         array_push($done_array_amend, $piece);
     }
     $this->assign("done_comment", $done_array_amend);
     $this->display();
 }
 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"));
 }