예제 #1
0
 public function actionReply()
 {
     //        if (!$_POST['ID']||!trim($_POST['reply'])) {
     //            $this->redirect(array('index'));
     //        }
     $ID = Yii::app()->request->getParam('ID');
     $reply = trim(Yii::app()->request->getParam('reply'));
     if (!$ID || mb_strlen($reply, 'utf8') < 2 || mb_strlen($reply, 'utf8') > 50) {
         echo json_encode(array('error' => '回复失败,请稍后再试!'));
         exit;
     }
     $OrganID = Yii::app()->user->getOrganID();
     $res = PapEvaluationGoods::model()->updateByPk($ID, array('SellerToEvalRemark' => htmlspecialchars($reply), 'UpdateTime' => time()), "SellerToEvalRemark ='' and OrganID={$OrganID}");
     if ($res) {
         echo json_encode(array('success' => 1));
     } else {
         echo json_encode(array('error' => '回复失败,请稍后再试!'));
     }
 }
예제 #2
0
 public function run($args)
 {
     Yii::app()->getComponent('log');
     Yii::log(date('Y-m-d H:i:s') . " [AutoEvaluation] start", 'info', 'command');
     //所要执行的任务,如数据符合某条件更新,删除,修改
     $Timeeva = time() - 24 * 60 * 60 * 10;
     //定义时间  收货15天后自动评价
     //服务店评价
     $model = PapOrder::model()->findAll("Status=9 and (EvaStatus = 0 or EvaStatus = 16)");
     //查询符合要求的已收货订单
     foreach ($model as $value) {
         if ($value['ReceiptTime'] < $Timeeva) {
             //已经收货订单执行下面代码
             $modelg = PapOrderGoods::model()->findAll("OrderID=:ID", array(":ID" => $value['ID']));
             //获得订单的商品
             $gbool = 1;
             foreach ($modelg as $valueg) {
                 //获得机构ID
                 $goodsinfo = PapGoods::model()->find("ID=:ID", array(":ID" => $valueg['GoodsID']));
                 $gevaluation = new PapEvaluationGoods();
                 $gevaluation->OrganID = $goodsinfo->OrganID;
                 $gevaluation->OrderID = $value['ID'];
                 $gevaluation->GoodsID = $goodsinfo->ID;
                 $gevaluation->BuyerID = $value['BuyerID'];
                 $gevaluation->CreateTime = time();
                 $gevaluation->Status = 1;
                 $model = $gevaluation->save();
                 //插入对单个商品的评价
                 if ($model) {
                     $m = PapGoods::model()->findByPk($goodsinfo->ID);
                     if ($m['CommentNo']) {
                         PapGoods::model()->updateByPk($goodsinfo->ID, array('CommentNo' => $m['CommentNo'] + 1));
                     } else {
                         PapGoods::model()->updateByPk($goodsinfo->ID, array('CommentNo' => 1));
                     }
                 } else {
                     $gbool = 0;
                 }
             }
             $oevaluation = new PapEvaluationDealer();
             $oevaluation->OrganID = $value['BuyerID'];
             $oevaluation->SellerID = $value['SellerID'];
             $ID = $oevaluation->OrderID = $value['ID'];
             $oevaluation->SellerBusiness = 5;
             $oevaluation->SellerService = 5;
             $oevaluation->SellerExact = 5;
             $oevaluation->SellerSpeed = 5;
             $oevaluation->ItemDescription = 5;
             $oevaluation->SellerPrice = 5;
             $oevaluation->SellerScore = 5;
             $oevaluation->CreateTime = time();
             $obool = $oevaluation->save();
             //插入对商家的评价
             if ($obool && $gbool) {
                 //评价插入成功后,修改订单的状态
                 if ($value['EvaStatus'] == 0) {
                     $EvaStatus = 15;
                     //如果该订单服务店先评价,把状态改为15
                 } elseif ($value['EvaStatus'] == 16) {
                     $EvaStatus = 20;
                     //如果该订单之前经销商评价过一次,则服务店此时评价状态改为20
                 }
                 PapOrder::model()->updateByPK($ID, array('EvaStatus' => $EvaStatus));
             }
         }
     }
     //经销商评价
     $modeld = PapOrder::model()->findAll("Status=9 and (EvaStatus = 0 or EvaStatus = 15)");
     //查询符合要求的已收货订单
     foreach ($modeld as $value) {
         if ($value['ReceiptTime'] < $Timeeva) {
             $model = new PapEvaluationService();
             $model->BuyerID = $value['BuyerID'];
             $ID = $model->OrderID = $value['ID'];
             $model->OrganID = $value['SellerID'];
             $model->BuyerFamily = 5;
             $model->BuyerAccept = 5;
             $model->BuyerBusiness = 5;
             $model->BuyerSpeed = 5;
             $model->BuyerCommunication = 5;
             $model->BuyerScore = 5;
             $model->CreateTime = time();
             $bool = $model->insert();
             if ($bool) {
                 if ($value['EvaStatus'] == 0) {
                     $EvaStatus = 16;
                     //如果该订单经销商先评价,把状态改为16
                 } else {
                     if ($value['EvaStatus'] == 15) {
                         $EvaStatus = 20;
                         //如果该订单之前服务店评价过一次,则经销商此时评价状态改为20
                     }
                 }
                 PapOrder::model()->updateByPK($ID, array('EvaStatus' => $EvaStatus));
             }
         }
     }
     Yii::log(date('Y-m-d H:i:s') . " [AutoEvaluation] end \n", 'info', 'command');
     echo date('Y-m-d H:i:s') . " [AutoEvaluation] end \n";
 }
예제 #3
0
 public function actionSaveevaluation()
 {
     $OrderID = $_POST['evalOrderID'];
     //避免重复评论  如果该订单 修理厂评价过15 或者 双方都评价过20
     $omodel = PapOrder::model()->findByPk($OrderID, '(EvaStatus=15 or EvaStatus=20) and (Status=9 or Status = 16)');
     if ($omodel) {
         echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />';
         echo "<script>alert('该订单已评论!');window.location.href='" . Yii::app()->createUrl('pap/orderreview/index', array('orderstype' => 4, 'evastatus' => 1)) . "'</script>";
         exit;
     }
     $this->pageTitle = Yii::app()->name . '-' . "保存评价";
     $BuyerID = Yii::app()->user->getOrganID();
     //处理前台穿过来的数据
     $BuyerToEvalRemark = explode(',', $_POST['BuyerToEvalRemark']);
     $Status = explode(',', $_POST['Status']);
     $GoodsID = explode(',', $_POST['GoodsID']);
     //var_dump(ltrim($_POST['GoodsID'],"0,"));die;
     $OrganID = $_POST['OrganID'];
     $OrderStatus = $_POST['OrderStatus'];
     $EvaStatus = $_POST['EvaStatus'] ? $_POST['EvaStatus'] : null;
     $evaID = Yii::app()->request->getParam('evaID');
     //删除已添加的评价
     PapEvaluationGoods::model()->deleteAll('OrderID=:OrderID', array(':OrderID' => $OrderID));
     $length = count($Status);
     $gbool = 1;
     for ($i = 1; $i < $length; $i++) {
         $gevaluation = new PapEvaluationGoods();
         $gevaluation->OrganID = $OrganID;
         $gevaluation->GoodsID = $GoodsID[$i];
         $gevaluation->BuyerID = $BuyerID;
         if ($BuyerToEvalRemark[$i] != '质量如何?来说说吧...') {
             $gevaluation->BuyerToEvalRemark = htmlspecialchars($BuyerToEvalRemark[$i]);
         }
         $gevaluation->CreateTime = time();
         $gevaluation->OrderID = $OrderID;
         $gevaluation->Status = $Status[$i];
         $model = $gevaluation->save();
         $evasID[$i] = Yii::app()->papdb->getLastinsertID();
         $goodsImages = Yii::app()->request->getParam("goodsImages" . ($i - 1));
         if (isset($goodsImages) && !empty($goodsImages)) {
             $this->saveorganphoto($goodsImages, $GoodsID[$i], $evasID[$i]);
         }
         if ($model) {
             $m = PapGoods::model()->findByPk($GoodsID[$i]);
             if ($m['CommentNo']) {
                 PapGoods::model()->updateByPk($GoodsID[$i], array('CommentNo' => $m['CommentNo'] + 1));
             } else {
                 PapGoods::model()->updateByPk($GoodsID[$i], array('CommentNo' => 1));
             }
         } else {
             $gbool = 0;
             foreach ($gevaluation->errors as $errorsv) {
                 if (!$error) {
                     $error = $errorsv[0];
                 }
             }
         }
     }
     //获取修理厂评价经销商的商品积分
     $pap_eva_goods = "select OrganID,Status,OrderID from pap_evaluation_goods where OrganID ={$OrganID} and OrderID=" . $OrderID;
     $bool2 = Yii::app()->papdb->createCommand($pap_eva_goods)->queryAll();
     $sum = 0;
     foreach ($bool2 as $v) {
         if ($v['Status'] == 3) {
             $sum += -1;
         }
         if ($v['Status'] == 2) {
             $sum += 0;
         }
         if ($v['Status'] == 1) {
             $sum += 1;
         }
     }
     //获取经销商的信用等级
     $organGrade = "select Grade from jpd_organ where ID=" . $bool2[0]['OrganID'];
     $bool3 = Yii::app()->jpdb->createCommand($organGrade)->queryRow();
     //更新经销商的信用等级
     $sum2 = $sum + $bool3['Grade'];
     $Gradesum = "update jpd_organ set Grade ={$sum2} where ID=" . $bool2[0]['OrganID'];
     $bool4 = Yii::app()->jpdb->createCommand($Gradesum)->execute();
     $addsql = "insert into pap_evaluation_organ (Identity,OrganID,Recier,JudgeID,OrderID,Score,CreateTime) values ";
     $keytop = 1;
     foreach ($evaID as $ekeys => $evalue) {
         if ($keytop != 1) {
             $addsql .= ",";
         }
         $addsql .= "(";
         $addsql .= 2;
         $addsql .= ",";
         $addsql .= $BuyerID;
         $addsql .= ",";
         $addsql .= $OrganID;
         $addsql .= ",";
         $addsql .= $ekeys;
         $addsql .= ",";
         $addsql .= $OrderID;
         $addsql .= ",";
         $addsql .= $evalue;
         $addsql .= ",";
         $addsql .= time();
         $addsql .= ")";
         $keytop = 2;
         //            EvaluateService::addjudgerecord($ekeys, $evalue, $OrganID, 2, $OrderID);
     }
     $obool = Yii::app()->papdb->createCommand($addsql)->execute();
     if ($gbool && $obool) {
         if ($OrderStatus == 9 && $EvaStatus == null) {
             $EvaStatus = 15;
             //如果该订单服务店先评价,把状态改为15
         } elseif ($OrderStatus == 9 && $EvaStatus == 16) {
             $EvaStatus = 20;
             //如果该订单之前经销商评价过一次,则服务店此时评价状态改为20
         }
         $bool2 = PapOrder::model()->updateByPK($OrderID, array('EvaStatus' => $EvaStatus));
         $rs = array('success' => 1, 'errorMsg' => '评价成功');
     } else {
         $rs = array('success' => 0, 'errorMsg' => '评价失败', 'error' => $error);
     }
     $this->render("evaresult", array('result' => $rs));
 }
예제 #4
0
 public function actionGeteva()
 {
     $goodsid = $_GET['goodsid'];
     $organid = $_GET['organid'];
     $page = $_GET['page'];
     $criteria = new CDbCriteria();
     //过滤有图片的评论
     if ($_GET['status'] == 'pic') {
         $sql = "select Group_Concat(DISTINCT EvalID) as eval FROM `pap_evaluation_goods_image` where GoodsID={$goodsid}";
         $res = Yii::app()->papdb->createCommand($sql)->queryRow();
         if ($res && !is_null($res['eval'])) {
             $criteria->addCondition("ID in({$res['eval']})", "AND");
         } else {
             $criteria->addCondition("ID in('')", "AND");
         }
     } else {
         if ($_GET['status'] == 'good') {
             $criteria->addCondition("Status=1 ", "AND");
         } else {
             if ($_GET['status'] == 'medium') {
                 $criteria->addCondition("Status=2 ", "AND");
             } else {
                 if ($_GET['status'] == 'bad') {
                     $criteria->addCondition("Status=3 ", "AND");
                 }
             }
         }
     }
     //评价有无内容过滤
     if ($_GET['content'] == 'content') {
         $criteria->addCondition("BuyerToEvalRemark != '0' and BuyerToEvalRemark != '' ", "AND");
     }
     //评价排序
     if ($_GET['orderby'] == 'orderID') {
         $criteria->order = "id DESC";
     } elseif ($_GET['orderby'] == 'ordertimeup') {
         $criteria->order = "CreateTime ASC";
     } elseif ($_GET['orderby'] == 'ordertimedrop') {
         $criteria->order = "CreateTime DESC";
     }
     $criteria->addCondition("t.GoodsID= " . $goodsid, "AND");
     $criteria->addCondition("t.OrganID= " . $organid, "AND");
     $criteria->addCondition("OrderID!=''", "AND");
     //        $criteria->select = 't.*';
     //        $criteria->join = "join pap_evaluation_goods_image b on t.ID=b.EvalID";
     //分页
     $count = PapEvaluationGoods::model()->count($criteria);
     $pages = new CPagination($count);
     $pages->pageSize = 5;
     $pages->applyLimit($criteria);
     $model = PapEvaluationGoods::model()->findAll($criteria);
     $data = array();
     $zi = 1500;
     foreach ($model as $key => $value) {
         $data[$key]['BuyerToEvalRemark'] = !empty($value["BuyerToEvalRemark"]) ? $value["BuyerToEvalRemark"] : '';
         $data[$key]['SellerToEvalRemark'] = $value["SellerToEvalRemark"];
         $data[$key]['BCreateTime'] = date("Y-m-d H:i:s", $value["CreateTime"]);
         $data[$key]['UpdateTime'] = date('Y-m-d H:i:s', $value['UpdateTime']);
         $sql = "select MakeID,CarID,Year,ModelID from pap_order_goods where OrderID={$value['OrderID']} and GoodsID={$value['GoodsID']}";
         $res = Yii::app()->papdb->createCommand($sql)->queryRow();
         $carstr = MallService::getCarmodeltxt(array('make' => $res['MakeID'], 'series' => $res['CarID'], 'year' => $res['Year'], 'model' => $res['ModelID']));
         $data[$key]['CarmodelText'] = $carstr ? $carstr : '无';
         //获得图片
         //   $goodsimg = OrganPhoto::model()->findAll("OrganID=:userID", array(":userID" => $userID));
         //  $data[$key]['GoodsIMG'] = $goodsimg[0]->Path;
         switch ($value['Status']) {
             case '2':
                 $data[$key]['Eval'] = '中评';
                 break;
             case '3':
                 $data[$key]['Eval'] = '差评';
                 break;
             default:
                 $data[$key]['Eval'] = '好评';
                 break;
         }
         $data[$key]['BuyerID'] = $value["BuyerID"];
         $buyerinfo = Organ::model()->findByPk($value["BuyerID"]);
         $data[$key]['BuyerName'] = $buyerinfo->OrganName;
         $data[$key]['Grade'] = $buyerinfo->Grade;
         $data[$key]['zindex'] = $zi--;
         //信用等级
         $xylevel = EvaluateService::getpets($data[$key]['Grade']);
         if (empty($xylevel) || !$xylevel[0] || !$xylevel[1]) {
             $data[$key]['Xylv'] = "<div title='积分:暂无' style='color:#888;text-indent:0px;float:left'>暂无</div>";
         } else {
             $data[$key]['Xylv'] = '<div class="showlv" title = "积分:' . $data[$key]['Grade'] . '">' . str_repeat("<i class='buyer-level" . $xylevel[0] . "'></i>", $xylevel[1]) . '</div>';
         }
         //获取评论图片
         if ($value->image) {
             foreach ($value->image as $k => $v) {
                 $data[$key]['Picture'][$k]['ImageUrl'] = $v['ImageUrl'];
             }
         }
     }
     $rs['rows'] = $data;
     //获得分页
     $rs['page'] = $this->getPagination($count, $pages->pageSize, $page);
     echo json_encode($rs);
     yii::app()->end();
 }
예제 #5
0
 public static function geteval($ID)
 {
     $OrganID = Yii::app()->user->getOrganID();
     $model = PapEvaluationGoods::model()->findByPk($ID, "SellerToEvalRemark ='' and OrganID={$OrganID}")->attributes;
     if (!$model) {
         return array('error' => 1);
     } else {
         return $model;
     }
 }