Esempio n. 1
0
 public function cleanClothes(Clothes $clothes)
 {
     if ($clothes->getStatus() == "dirty") {
         $clothes = $this->laundry->cleanClothes($clothes);
         return $clothes;
     } else {
         return false;
     }
 }
Esempio n. 2
0
 public function cleanClothes(Clothes $clothes)
 {
     if ($clothes->getStatus() == "dirty") {
         $clothes->setStatus("clean");
         return $clothes;
     } else {
         return false;
     }
 }
Esempio n. 3
0
 public function getInformation($greeting = "Hello")
 {
     $output = $greeting;
     $output .= ", there are ";
     $output .= $this->clothes->getCleanClothes();
     $output .= " clean closes and ";
     $output .= $this->clothes->getDirtyClothes();
     $output .= " dirty clothes in the laundry.";
     return $output;
 }
Esempio n. 4
0
<?php

require 'Clothes.php';
$indexName = "WomenClothes";
$objClothes = new Clothes($indexName);
$question = $_GET["question"];
if (strlen($question) > 0) {
    $infoClothes = $objClothes->getInformationClothes($question, 5);
    foreach ($infoClothes as $clothes) {
        echo $clothes["name"];
        #."  $". $clothes["price"]."  ".$clothes["designer"];
        echo "<br>";
    }
}
Esempio n. 5
0
<?php

require 'Clothes.php';
$indexName = "WomenClothes";
$objClothes = new Clothes($indexName);
$infoClothes = $objClothes->getInformationClothes("skirt", 10);
$infoClothes = $objClothes->arrayToJSON($infoClothes);
?>
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8"/>
    <title> Get clothes </title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" 
    integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">

    <style>
      #livesearch {
        color:red;
      }
    </style>
  </head>

  <body>
    <div class="container">
      <h1>Escenario 1 <small>La consulta es "dress". </small></h1>
      <?php 
//echo $infoClothes;
?>
      <?php 
//if ($infoClothes == "Please, try with other option"):
Esempio n. 6
0
 /**
  * 通过搭配ID获取其衣服详细信息
  **/
 static function beuclothesSelectByDpid($dpid, $touchid)
 {
     $ret = array('status' => 0, 'msg' => '');
     try {
         if (!is_numeric($dpid) || intval($dpid) != $dpid || $dpid <= 0) {
             throw new Exception('搭配编号有误!');
         }
         $where = "baidaid={$dpid} && touchid={$touchid}";
         $dapeiclothesid = Yii::app()->db->createCommand()->select("clothesid")->from("beu_baidaclothes")->where($where)->queryAll();
         if (count($dapeiclothesid) == 0) {
             throw new Exception('未找到单品的数据!');
         }
         $clothesarray = array();
         foreach ($dapeiclothesid as $value) {
             $clothesarray[] = $value["clothesid"];
         }
         $clothesid = implode($clothesarray, ",");
         $sel = Yii::app()->db->createCommand();
         //拼接需要查询的字段
         $select_field = 'beu_clothes.id,beu_clothes.name,thumbnail,beu_clothes.imagescontent';
         if (!empty($_SESSION['table_where'])) {
             $select_field .= ',clothes.price,clothes.discountprice';
         } else {
             $select_field .= ',beu_clothes.price,beu_clothes.discountprice';
         }
         //查询衣服数据
         $sel->select($select_field)->from($_SESSION['clothes_table'] . ' as clothes')->join('beu_clothes', 'beu_clothes.id=clothes.clothesid')->where('beu_clothes.id in (' . $clothesid . ') ')->andwhere("touchid={$touchid}");
         if (!empty($_SESSION['table_where'])) {
             $sel->andwhere($_SESSION['table_where']);
         }
         $con = $sel->queryAll();
         foreach ($con as $key => $value) {
             $is_bool = false;
             //标识当前单品是否有立体图 默认没有
             if (!empty($value['imagescontent'])) {
                 $img_arr = json_decode($value['imagescontent'], true);
                 if (isset($img_arr['graphicmodel'][0])) {
                     $con[$key]['thumbnail'] = $img_arr['graphicmodel'][0];
                     $is_bool = true;
                 }
             }
             if (!$is_bool) {
                 //如果没有找到立体图 就查询其不同穿法的立体图
                 //获取当前单品的不同穿法
                 $different = Clothes::clothesDifferentSelectByClothesid($value['id']);
                 //将不同穿法的“赞”数据读取出来
                 if (count($different) > 0) {
                     //从不同穿法数组里清除当前单品
                     $v_key = array_search($value['id'], $different);
                     if ($v_key !== false) {
                         unset($different[$v_key]);
                     }
                     $different_con = Yii::app()->db->createCommand()->select('beu_clothes.id,beu_clothes.imagescontent')->from('beu_clothes')->where('id in (' . implode(',', $different) . ')');
                     $different_con = $different_con->queryAll();
                     //遍历不同穿法的数据 将其立体图赋给此单品
                     foreach ($different_con as $different_key => $different_value) {
                         if (!empty($different_value['imagescontent'])) {
                             $img_arr = json_decode($different_value['imagescontent'], true);
                             if (isset($img_arr['graphicmodel'][0])) {
                                 $con[$key]['thumbnail'] = $img_arr['graphicmodel'][0];
                                 break;
                             }
                         }
                     }
                 }
             }
             $praise = Yii::app()->db->createCommand()->select('*')->from('beu_clothes_praise')->where('clothes=' . $con[$key]['id'] . '')->order('praise desc,date_time desc')->queryRow();
             $con[$key]['praise_num'] = 0;
             if (!empty($praise)) {
                 $con[$key]['praise_num'] = $praise['praise'];
             }
         }
         if (empty($con)) {
             throw new Exception('未找到当前单品的数据!');
         }
         $ret['data'] = $con;
         $ret['status'] = 1;
     } catch (Exception $e) {
         $ret['msg'] = $e->getMessage();
     }
     return $ret;
 }